2003-04-24 08:25:08 +02:00
|
|
|
/*
|
|
|
|
* PCI defines and function prototypes
|
|
|
|
* Copyright 1994, Drew Eckhardt
|
|
|
|
* Copyright 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
|
|
|
*
|
|
|
|
* For more information, please consult the following manuals (look at
|
|
|
|
* http://www.pcisig.com/ for how to get them):
|
|
|
|
*
|
|
|
|
* PCI BIOS Specification
|
|
|
|
* PCI Local Bus Specification
|
|
|
|
* PCI to PCI Bridge Specification
|
|
|
|
* PCI System Design Guide
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PCI_H
|
|
|
|
#define PCI_H
|
|
|
|
|
2019-03-06 01:53:33 +01:00
|
|
|
#if CONFIG(PCI)
|
2014-02-12 13:18:50 +01:00
|
|
|
|
2010-11-05 00:23:47 +01:00
|
|
|
#include <stdint.h>
|
Make the device tree available in the rom stage
We thought about two ways to do this change. The way we decided to try
was to
1. drop all ops from devices in romstage
2. constify all devices in romstage (make them read-only) so we can
compile static.c into romstage
3. the device tree "devices" can be used to read configuration from
the device tree (and nothing else, really)
4. the device tree devices are accessed through struct device * in
romstage only. device_t stays the typedef to int in romstage
5. Use the same static.c file in ramstage and romstage
We declare structs as follows:
ROMSTAGE_CONST struct bus dev_root_links[];
ROMSTAGE_CONST is const in romstage and empty in ramstage; This
forces all of the device tree into the text area.
So a struct looks like this:
static ROMSTAGE_CONST struct device _dev21 = {
#ifndef __PRE_RAM__
.ops = 0,
#endif
.bus = &_dev7_links[0],
.path = {.type=DEVICE_PATH_PCI,{.pci={ .devfn = PCI_DEVFN(0x1c,3)}}},
.enabled = 0,
.on_mainboard = 1,
.subsystem_vendor = 0x1ae0,
.subsystem_device = 0xc000,
.link_list = NULL,
.sibling = &_dev22,
#ifndef __PRE_RAM__
.chip_ops = &southbridge_intel_bd82x6x_ops,
#endif
.chip_info = &southbridge_intel_bd82x6x_info_10,
.next=&_dev22
};
Change-Id: I722454d8d3c40baf7df989f5a6891f6ba7db5727
Signed-off-by: Ronald G. Minnich <rminnich@chromium.org>
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/1398
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-08-01 01:47:25 +02:00
|
|
|
#include <stddef.h>
|
2003-05-19 21:16:21 +02:00
|
|
|
#include <device/pci_def.h>
|
2003-04-24 08:25:08 +02:00
|
|
|
#include <device/resource.h>
|
|
|
|
#include <device/device.h>
|
2019-03-07 13:18:28 +01:00
|
|
|
#include <device/pci_ops.h>
|
2005-01-11 00:16:22 +01:00
|
|
|
#include <device/pci_rom.h>
|
2019-03-03 07:01:05 +01:00
|
|
|
#include <device/pci_type.h>
|
2013-06-25 22:17:43 +02:00
|
|
|
|
2004-10-14 22:54:17 +02:00
|
|
|
/* Common pci operations without a standard interface */
|
|
|
|
struct pci_operations {
|
2004-11-25 18:37:19 +01:00
|
|
|
/* set the Subsystem IDs for the PCI device */
|
2017-08-08 00:55:43 +02:00
|
|
|
void (*set_subsystem)(struct device *dev, unsigned int vendor,
|
2017-03-07 03:01:04 +01:00
|
|
|
unsigned int device);
|
2017-08-08 00:55:43 +02:00
|
|
|
void (*set_L1_ss_latency)(struct device *dev, unsigned int off);
|
2004-10-14 22:54:17 +02:00
|
|
|
};
|
|
|
|
|
2003-04-24 08:25:08 +02:00
|
|
|
struct pci_driver {
|
2009-10-27 22:49:33 +01:00
|
|
|
const struct device_operations *ops;
|
2003-04-24 08:25:08 +02:00
|
|
|
unsigned short vendor;
|
|
|
|
unsigned short device;
|
2012-04-24 21:53:19 +02:00
|
|
|
const unsigned short *devices;
|
2003-04-24 08:25:08 +02:00
|
|
|
};
|
|
|
|
|
2018-05-16 14:56:22 +02:00
|
|
|
struct msix_entry {
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
u32 lower_addr;
|
|
|
|
u32 upper_addr;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
u64 addr;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
u32 data;
|
|
|
|
u32 vec_control;
|
|
|
|
};
|
|
|
|
|
2019-09-27 14:02:32 +02:00
|
|
|
#if ENV_RAMSTAGE
|
2017-07-13 02:20:27 +02:00
|
|
|
#define __pci_driver __attribute__((used, __section__(".rodata.pci_driver")))
|
2019-09-27 14:02:32 +02:00
|
|
|
#else
|
|
|
|
#define __pci_driver __attribute__((unused))
|
2017-08-08 00:55:43 +02:00
|
|
|
#endif
|
2019-09-27 14:02:32 +02:00
|
|
|
|
2004-03-23 22:28:05 +01:00
|
|
|
/** start of compile time generated pci driver array */
|
2015-09-04 00:23:08 +02:00
|
|
|
extern struct pci_driver _pci_drivers[];
|
2004-03-23 22:28:05 +01:00
|
|
|
/** end of compile time generated pci driver array */
|
2015-09-04 00:23:08 +02:00
|
|
|
extern struct pci_driver _epci_drivers[];
|
2003-04-24 08:25:08 +02:00
|
|
|
|
2017-12-11 05:59:49 +01:00
|
|
|
/* Set Subsystem ID operation for PCI devices */
|
|
|
|
extern struct pci_operations pci_dev_ops_pci;
|
2005-07-08 04:49:49 +02:00
|
|
|
extern struct device_operations default_pci_ops_dev;
|
|
|
|
extern struct device_operations default_pci_ops_bus;
|
2003-04-24 08:25:08 +02:00
|
|
|
|
2017-08-08 00:55:43 +02:00
|
|
|
void pci_dev_read_resources(struct device *dev);
|
|
|
|
void pci_bus_read_resources(struct device *dev);
|
|
|
|
void pci_dev_set_resources(struct device *dev);
|
|
|
|
void pci_dev_enable_resources(struct device *dev);
|
|
|
|
void pci_bus_enable_resources(struct device *dev);
|
2005-07-08 04:49:49 +02:00
|
|
|
void pci_bus_reset(struct bus *bus);
|
2017-08-08 00:55:43 +02:00
|
|
|
struct device *pci_probe_dev(struct device *dev, struct bus *bus,
|
|
|
|
unsigned int devfn);
|
2015-03-18 12:09:47 +01:00
|
|
|
|
2018-05-03 12:54:47 +02:00
|
|
|
void do_pci_scan_bridge(struct device *dev,
|
2015-03-18 12:09:47 +01:00
|
|
|
void (*do_scan_bus)(struct bus *bus,
|
2017-03-07 03:01:04 +01:00
|
|
|
unsigned int min_devfn, unsigned int max_devfn));
|
2015-03-18 12:09:47 +01:00
|
|
|
|
2017-08-08 00:55:43 +02:00
|
|
|
void pci_scan_bridge(struct device *bus);
|
2017-03-07 03:01:04 +01:00
|
|
|
void pci_scan_bus(struct bus *bus, unsigned int min_devfn,
|
|
|
|
unsigned int max_devfn);
|
2015-03-18 12:09:47 +01:00
|
|
|
|
2017-03-07 03:01:04 +01:00
|
|
|
uint8_t pci_moving_config8(struct device *dev, unsigned int reg);
|
|
|
|
uint16_t pci_moving_config16(struct device *dev, unsigned int reg);
|
|
|
|
uint32_t pci_moving_config32(struct device *dev, unsigned int reg);
|
2004-10-14 22:54:17 +02:00
|
|
|
struct resource *pci_get_resource(struct device *dev, unsigned long index);
|
2017-08-08 00:55:43 +02:00
|
|
|
void pci_dev_set_subsystem(struct device *dev, unsigned int vendor,
|
2017-03-07 03:01:04 +01:00
|
|
|
unsigned int device);
|
2008-12-18 19:24:11 +01:00
|
|
|
void pci_dev_init(struct device *dev);
|
2017-08-08 00:55:43 +02:00
|
|
|
unsigned int pci_match_simple_dev(struct device *dev, pci_devfn_t sdev);
|
2009-07-21 23:36:41 +02:00
|
|
|
|
2017-03-08 00:24:16 +01:00
|
|
|
const char *pin_to_str(int pin);
|
2017-08-08 00:55:43 +02:00
|
|
|
int get_pci_irq_pins(struct device *dev, struct device **parent_bdg);
|
2019-07-04 20:39:28 +02:00
|
|
|
void pci_assign_irqs(struct device *dev, const unsigned char pIntAtoD[4]);
|
2017-08-08 00:55:43 +02:00
|
|
|
const char *get_pci_class_name(struct device *dev);
|
|
|
|
const char *get_pci_subclass_name(struct device *dev);
|
2003-04-24 08:25:08 +02:00
|
|
|
|
2018-05-16 14:56:22 +02:00
|
|
|
size_t pci_msix_table_size(struct device *dev);
|
|
|
|
int pci_msix_table_bar(struct device *dev, u32 *offset, u8 *idx);
|
|
|
|
struct msix_entry *pci_msix_get_table(struct device *dev);
|
|
|
|
|
2003-04-24 08:25:08 +02:00
|
|
|
#define PCI_IO_BRIDGE_ALIGN 4096
|
|
|
|
#define PCI_MEM_BRIDGE_ALIGN (1024*1024)
|
|
|
|
|
2019-02-08 17:14:34 +01:00
|
|
|
#define PCI_ID(VENDOR_ID, DEVICE_ID) \
|
|
|
|
((((DEVICE_ID) & 0xFFFF) << 16) | ((VENDOR_ID) & 0xFFFF))
|
|
|
|
|
|
|
|
pci_devfn_t pci_locate_device(unsigned int pci_id, pci_devfn_t dev);
|
|
|
|
pci_devfn_t pci_locate_device_on_bus(unsigned int pci_id, unsigned int bus);
|
|
|
|
|
2019-09-26 21:33:51 +02:00
|
|
|
void pci_s_assert_secondary_reset(pci_devfn_t p2p_bridge);
|
|
|
|
void pci_s_deassert_secondary_reset(pci_devfn_t p2p_bridge);
|
|
|
|
void pci_s_bridge_set_secondary(pci_devfn_t p2p_bridge, u8 secondary);
|
|
|
|
|
2014-02-14 11:45:09 +01:00
|
|
|
int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base);
|
2014-02-11 18:56:57 +01:00
|
|
|
|
2016-01-06 02:00:27 +01:00
|
|
|
static inline int pci_base_address_is_memory_space(unsigned int attr)
|
|
|
|
{
|
|
|
|
return (attr & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_MEMORY;
|
|
|
|
}
|
|
|
|
|
2014-02-12 13:18:50 +01:00
|
|
|
#endif /* CONFIG_PCI */
|
|
|
|
|
2019-01-23 15:02:28 +01:00
|
|
|
void pci_early_bridge_init(void);
|
|
|
|
|
2003-04-24 08:25:08 +02:00
|
|
|
#endif /* PCI_H */
|