20#define PCI_VENDOR_ID 0x00
23#define PCI_DEVICE_ID 0x02
26#define PCI_COMMAND 0x04
27#define PCI_COMMAND_IO 0x0001
28#define PCI_COMMAND_MEM 0x0002
29#define PCI_COMMAND_MASTER 0x0004
30#define PCI_COMMAND_INVALIDATE 0x0010
31#define PCI_COMMAND_PARITY 0x0040
32#define PCI_COMMAND_SERR 0x0100
33#define PCI_COMMAND_INTX_DISABLE 0x0400
36#define PCI_STATUS 0x06
37#define PCI_STATUS_CAP_LIST 0x0010
38#define PCI_STATUS_PARITY 0x0100
39#define PCI_STATUS_REC_TARGET_ABORT 0x1000
40#define PCI_STATUS_REC_MASTER_ABORT 0x2000
41#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000
42#define PCI_STATUS_DETECTED_PARITY 0x8000
45#define PCI_REVISION 0x08
48#define PCI_CACHE_LINE_SIZE 0x0c
51#define PCI_LATENCY_TIMER 0x0d
54#define PCI_HEADER_TYPE 0x0e
55#define PCI_HEADER_TYPE_NORMAL 0x00
56#define PCI_HEADER_TYPE_BRIDGE 0x01
57#define PCI_HEADER_TYPE_CARDBUS 0x02
58#define PCI_HEADER_TYPE_MASK 0x7f
59#define PCI_HEADER_TYPE_MULTI 0x80
62#define PCI_BASE_ADDRESS(n) ( 0x10 + ( 4 * (n) ) )
63#define PCI_BASE_ADDRESS_0 PCI_BASE_ADDRESS ( 0 )
64#define PCI_BASE_ADDRESS_1 PCI_BASE_ADDRESS ( 1 )
65#define PCI_BASE_ADDRESS_2 PCI_BASE_ADDRESS ( 2 )
66#define PCI_BASE_ADDRESS_3 PCI_BASE_ADDRESS ( 3 )
67#define PCI_BASE_ADDRESS_4 PCI_BASE_ADDRESS ( 4 )
68#define PCI_BASE_ADDRESS_5 PCI_BASE_ADDRESS ( 5 )
69#define PCI_BASE_ADDRESS_SPACE_IO 0x00000001UL
70#define PCI_BASE_ADDRESS_IO_MASK 0x00000003UL
71#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x00000004UL
72#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x00000006UL
73#define PCI_BASE_ADDRESS_MEM_MASK 0x0000000fUL
76#define PCI_SUBSYSTEM_VENDOR_ID 0x2c
79#define PCI_SUBSYSTEM_ID 0x2e
82#define PCI_ROM_ADDRESS 0x30
85#define PCI_CAPABILITY_LIST 0x34
88#define PCI_CB_CAPABILITY_LIST 0x14
91#define PCI_INTERRUPT_LINE 0x3c
94#define PCI_CAP_ID 0x00
95#define PCI_CAP_ID_PM 0x01
96#define PCI_CAP_ID_VPD 0x03
97#define PCI_CAP_ID_VNDR 0x09
98#define PCI_CAP_ID_EXP 0x10
99#define PCI_CAP_ID_MSIX 0x11
100#define PCI_CAP_ID_EA 0x14
103#define PCI_CAP_NEXT 0x01
106#define PCI_PM_CTRL 0x04
107#define PCI_PM_CTRL_STATE_MASK 0x0003
108#define PCI_PM_CTRL_PME_ENABLE 0x0100
109#define PCI_PM_CTRL_PME_STATUS 0x8000
112#define PCI_EXP_DEVCTL 0x08
113#define PCI_EXP_DEVCTL_FLR 0x8000
116#define PCI_MSIX_CTRL 0x02
117#define PCI_MSIX_CTRL_ENABLE 0x8000
118#define PCI_MSIX_CTRL_MASK 0x4000
119#define PCI_MSIX_CTRL_SIZE(x) ( (x) & 0x07ff )
120#define PCI_MSIX_DESC_TABLE 0x04
121#define PCI_MSIX_DESC_PBA 0x08
122#define PCI_MSIX_DESC_BIR(x) ( (x) & 0x00000007 )
123#define PCI_MSIX_DESC_OFFSET(x) ( (x) & 0xfffffff8 )
126#define PCI_ERR_UNCOR_STATUS 0x04
129#define PCI_CLASS_NETWORK 0x02
132#define PCI_CLASS_BRIDGE 0x06
133#define PCI_CLASS_BRIDGE_PCI 0x04
136#define PCI_CLASS_SERIAL 0x0c
137#define PCI_CLASS_SERIAL_USB 0x03
138#define PCI_CLASS_SERIAL_USB_UHCI 0x00
139#define PCI_CLASS_SERIAL_USB_OHCI 0x10
140#define PCI_CLASS_SERIAL_USB_EHCI 0x20
141#define PCI_CLASS_SERIAL_USB_XHCI 0x30
144#define PCI_PRIMARY 0x18
147#define PCI_SECONDARY 0x19
150#define PCI_SUBORDINATE 0x1a
153#define PCI_MEM_BASE 0x20
154#define PCI_MEM_LIMIT 0x22
155#define PCI_MEM_MASK 0x000fUL
156#define PCI_PREFMEM_BASE 0x24
157#define PCI_PREFMEM_LIMIT 0x26
158#define PCI_PREFMEM_BASE_HI 0x28
159#define PCI_PREFMEM_LIMIT_HI 0x2c
167#define PCI_CLASS( base, sub, progif ) \
168 ( ( ( (base) & 0xff ) << 16 ) | ( ( (sub) & 0xff ) << 8 ) | \
169 ( ( (progif) & 0xff) << 0 ) )
172#define PCI_EXP_FLR_DELAY_MS 100
187#define PCI_ANY_ID 0xffff
203#define PCI_CLASS_ID( base, sub, progif ) { \
204 .class = PCI_CLASS ( base, sub, progif ), \
205 .mask = ( ( ( ( (base) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 16 ) | \
206 ( ( ( (sub) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 8 ) | \
207 ( ( ( (progif) == PCI_ANY_ID ) ? 0x00 : 0xff ) << 0 ) ), \
275#define PCI_DRIVERS __table ( struct pci_driver, "pci_drivers" )
278#define __pci_driver __table_entry ( PCI_DRIVERS, 01 )
281#define __pci_driver_fallback __table_entry ( PCI_DRIVERS, 02 )
283#define PCI_SEG( busdevfn ) ( ( (busdevfn) >> 16 ) & 0xffff )
284#define PCI_BUS( busdevfn ) ( ( (busdevfn) >> 8 ) & 0xff )
285#define PCI_SLOT( busdevfn ) ( ( (busdevfn) >> 3 ) & 0x1f )
286#define PCI_FUNC( busdevfn ) ( ( (busdevfn) >> 0 ) & 0x07 )
287#define PCI_FIRST_FUNC( busdevfn ) ( (busdevfn) & ~0x07 )
288#define PCI_LAST_FUNC( busdevfn ) ( (busdevfn) | 0x07 )
290#define PCI_BASE_CLASS( class ) ( (class) >> 16 )
291#define PCI_SUB_CLASS( class ) ( ( (class) >> 8 ) & 0xff )
292#define PCI_PROG_INTF( class ) ( (class) & 0xff )
302#define PCI_ID( _vendor, _device, _name, _description, _data ) { \
306 .driver_data = _data \
308#define PCI_ROM( _vendor, _device, _name, _description, _data ) \
309 PCI_ID( _vendor, _device, _name, _description, _data )
312#define PCI_FMT "%04x:%02x:%02x.%x"
315#define PCI_ARGS( pci ) \
316 PCI_SEG ( (pci)->busdevfn ), PCI_BUS ( (pci)->busdevfn ), \
317 PCI_SLOT ( (pci)->busdevfn ), PCI_FUNC ( (pci)->busdevfn )
323 unsigned long start );
uint8_t id
Request identifier.
uint16_t busdevfn
PCI bus:dev.fn address.
uint32_t start
Starting offset.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
u16 capability
Capability flags.
static unsigned int unsigned int reg
void pci_reset(struct pci_device *pci, unsigned int exp)
Perform PCI Express function-level reset (FLR)
unsigned long pci_bar_size(struct pci_device *pci, unsigned int reg)
Get the size of a PCI BAR.
int pci_find_driver(struct pci_device *pci)
Find driver for PCI device.
int pci_find_next(struct pci_device *pci, uint32_t *busdevfn)
Find next device on PCI bus.
int pci_probe(struct pci_device *pci)
Probe a PCI device.
void pci_bar_set(struct pci_device *pci, unsigned int reg, unsigned long start)
Set the start of a PCI BAR.
static void pci_init(struct pci_device *pci, unsigned int busdevfn)
Initialise PCI device.
int pci_find_next_capability(struct pci_device *pci, int pos, int capability)
Look for another PCI capability.
int pci_read_config(struct pci_device *pci)
Read PCI device configuration.
void pci_remove(struct pci_device *pci)
Remove a PCI device.
static void pci_set_drvdata(struct pci_device *pci, void *priv)
Set PCI driver-private data.
void adjust_pci_device(struct pci_device *pci)
Enable PCI device.
static void * pci_get_drvdata(struct pci_device *pci)
Get PCI driver-private data.
unsigned long pci_bar_start(struct pci_device *pci, unsigned int reg)
Find the start of a PCI BAR.
static void pci_set_driver(struct pci_device *pci, struct pci_driver *driver, struct pci_device_id *id)
Set PCI driver.
int pci_find_capability(struct pci_device *pci, int capability)
Look for a PCI capability.
const char * driver_name
Driver name.
A PCI device ID list entry.
unsigned long driver_data
Arbitrary driver data.
uint16_t vendor
PCI vendor ID.
uint16_t device
PCI device ID.
unsigned long ioaddr
I/O address.
uint32_t busdevfn
Segment, bus, device, and function (bus:dev.fn) number.
unsigned long membase
Memory base.
uint8_t hdrtype
Header type.
uint8_t irq
Interrupt number.
struct pci_driver * driver
Driver for this device.
struct device dev
Generic device.
struct pci_device_id * id
Driver device ID.
void * priv
Driver-private data.
uint16_t vendor
Vendor ID.
uint16_t device
Device ID.
struct dma_device dma
DMA device.
void(* remove)(struct pci_device *pci)
Remove device.
struct pci_class_id class
PCI class ID.
struct pci_device_id * ids
PCI ID table.
int(* probe)(struct pci_device *pci)
Probe device.
unsigned int id_count
Number of entries in PCI ID table.
static struct tlan_private * priv