1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2001 Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Andreas Heppel <aheppel@sysgo.de>
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
13 #define PCI_CFG_SPACE_SIZE 256
14 #define PCI_CFG_SPACE_EXP_SIZE 4096
17 * Under PCI, each device has 256 bytes of configuration address space,
18 * of which the first 64 bytes are standardized as follows:
20 #define PCI_VENDOR_ID 0x00 /* 16 bits */
21 #define PCI_DEVICE_ID 0x02 /* 16 bits */
22 #define PCI_COMMAND 0x04 /* 16 bits */
23 #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
24 #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
25 #define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
26 #define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */
27 #define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */
28 #define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */
29 #define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */
30 #define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */
31 #define PCI_COMMAND_SERR 0x100 /* Enable SERR */
32 #define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */
34 #define PCI_STATUS 0x06 /* 16 bits */
35 #define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
36 #define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */
37 #define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */
38 #define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */
39 #define PCI_STATUS_PARITY 0x100 /* Detected parity error */
40 #define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */
41 #define PCI_STATUS_DEVSEL_FAST 0x000
42 #define PCI_STATUS_DEVSEL_MEDIUM 0x200
43 #define PCI_STATUS_DEVSEL_SLOW 0x400
44 #define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */
45 #define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */
46 #define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */
47 #define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */
48 #define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */
50 #define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8
52 #define PCI_REVISION_ID 0x08 /* Revision ID */
53 #define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */
54 #define PCI_CLASS_DEVICE 0x0a /* Device class */
55 #define PCI_CLASS_CODE 0x0b /* Device class code */
56 #define PCI_CLASS_CODE_TOO_OLD 0x00
57 #define PCI_CLASS_CODE_STORAGE 0x01
58 #define PCI_CLASS_CODE_NETWORK 0x02
59 #define PCI_CLASS_CODE_DISPLAY 0x03
60 #define PCI_CLASS_CODE_MULTIMEDIA 0x04
61 #define PCI_CLASS_CODE_MEMORY 0x05
62 #define PCI_CLASS_CODE_BRIDGE 0x06
63 #define PCI_CLASS_CODE_COMM 0x07
64 #define PCI_CLASS_CODE_PERIPHERAL 0x08
65 #define PCI_CLASS_CODE_INPUT 0x09
66 #define PCI_CLASS_CODE_DOCKING 0x0A
67 #define PCI_CLASS_CODE_PROCESSOR 0x0B
68 #define PCI_CLASS_CODE_SERIAL 0x0C
69 #define PCI_CLASS_CODE_WIRELESS 0x0D
70 #define PCI_CLASS_CODE_I2O 0x0E
71 #define PCI_CLASS_CODE_SATELLITE 0x0F
72 #define PCI_CLASS_CODE_CRYPTO 0x10
73 #define PCI_CLASS_CODE_DATA 0x11
74 /* Base Class 0x12 - 0xFE is reserved */
75 #define PCI_CLASS_CODE_OTHER 0xFF
77 #define PCI_CLASS_SUB_CODE 0x0a /* Device sub-class code */
78 #define PCI_CLASS_SUB_CODE_TOO_OLD_NOTVGA 0x00
79 #define PCI_CLASS_SUB_CODE_TOO_OLD_VGA 0x01
80 #define PCI_CLASS_SUB_CODE_STORAGE_SCSI 0x00
81 #define PCI_CLASS_SUB_CODE_STORAGE_IDE 0x01
82 #define PCI_CLASS_SUB_CODE_STORAGE_FLOPPY 0x02
83 #define PCI_CLASS_SUB_CODE_STORAGE_IPIBUS 0x03
84 #define PCI_CLASS_SUB_CODE_STORAGE_RAID 0x04
85 #define PCI_CLASS_SUB_CODE_STORAGE_ATA 0x05
86 #define PCI_CLASS_SUB_CODE_STORAGE_SATA 0x06
87 #define PCI_CLASS_SUB_CODE_STORAGE_SAS 0x07
88 #define PCI_CLASS_SUB_CODE_STORAGE_OTHER 0x80
89 #define PCI_CLASS_SUB_CODE_NETWORK_ETHERNET 0x00
90 #define PCI_CLASS_SUB_CODE_NETWORK_TOKENRING 0x01
91 #define PCI_CLASS_SUB_CODE_NETWORK_FDDI 0x02
92 #define PCI_CLASS_SUB_CODE_NETWORK_ATM 0x03
93 #define PCI_CLASS_SUB_CODE_NETWORK_ISDN 0x04
94 #define PCI_CLASS_SUB_CODE_NETWORK_WORLDFIP 0x05
95 #define PCI_CLASS_SUB_CODE_NETWORK_PICMG 0x06
96 #define PCI_CLASS_SUB_CODE_NETWORK_OTHER 0x80
97 #define PCI_CLASS_SUB_CODE_DISPLAY_VGA 0x00
98 #define PCI_CLASS_SUB_CODE_DISPLAY_XGA 0x01
99 #define PCI_CLASS_SUB_CODE_DISPLAY_3D 0x02
100 #define PCI_CLASS_SUB_CODE_DISPLAY_OTHER 0x80
101 #define PCI_CLASS_SUB_CODE_MULTIMEDIA_VIDEO 0x00
102 #define PCI_CLASS_SUB_CODE_MULTIMEDIA_AUDIO 0x01
103 #define PCI_CLASS_SUB_CODE_MULTIMEDIA_PHONE 0x02
104 #define PCI_CLASS_SUB_CODE_MULTIMEDIA_OTHER 0x80
105 #define PCI_CLASS_SUB_CODE_MEMORY_RAM 0x00
106 #define PCI_CLASS_SUB_CODE_MEMORY_FLASH 0x01
107 #define PCI_CLASS_SUB_CODE_MEMORY_OTHER 0x80
108 #define PCI_CLASS_SUB_CODE_BRIDGE_HOST 0x00
109 #define PCI_CLASS_SUB_CODE_BRIDGE_ISA 0x01
110 #define PCI_CLASS_SUB_CODE_BRIDGE_EISA 0x02
111 #define PCI_CLASS_SUB_CODE_BRIDGE_MCA 0x03
112 #define PCI_CLASS_SUB_CODE_BRIDGE_PCI 0x04
113 #define PCI_CLASS_SUB_CODE_BRIDGE_PCMCIA 0x05
114 #define PCI_CLASS_SUB_CODE_BRIDGE_NUBUS 0x06
115 #define PCI_CLASS_SUB_CODE_BRIDGE_CARDBUS 0x07
116 #define PCI_CLASS_SUB_CODE_BRIDGE_RACEWAY 0x08
117 #define PCI_CLASS_SUB_CODE_BRIDGE_SEMI_PCI 0x09
118 #define PCI_CLASS_SUB_CODE_BRIDGE_INFINIBAND 0x0A
119 #define PCI_CLASS_SUB_CODE_BRIDGE_OTHER 0x80
120 #define PCI_CLASS_SUB_CODE_COMM_SERIAL 0x00
121 #define PCI_CLASS_SUB_CODE_COMM_PARALLEL 0x01
122 #define PCI_CLASS_SUB_CODE_COMM_MULTIPORT 0x02
123 #define PCI_CLASS_SUB_CODE_COMM_MODEM 0x03
124 #define PCI_CLASS_SUB_CODE_COMM_GPIB 0x04
125 #define PCI_CLASS_SUB_CODE_COMM_SMARTCARD 0x05
126 #define PCI_CLASS_SUB_CODE_COMM_OTHER 0x80
127 #define PCI_CLASS_SUB_CODE_PERIPHERAL_PIC 0x00
128 #define PCI_CLASS_SUB_CODE_PERIPHERAL_DMA 0x01
129 #define PCI_CLASS_SUB_CODE_PERIPHERAL_TIMER 0x02
130 #define PCI_CLASS_SUB_CODE_PERIPHERAL_RTC 0x03
131 #define PCI_CLASS_SUB_CODE_PERIPHERAL_HOTPLUG 0x04
132 #define PCI_CLASS_SUB_CODE_PERIPHERAL_SD 0x05
133 #define PCI_CLASS_SUB_CODE_PERIPHERAL_OTHER 0x80
134 #define PCI_CLASS_SUB_CODE_INPUT_KEYBOARD 0x00
135 #define PCI_CLASS_SUB_CODE_INPUT_DIGITIZER 0x01
136 #define PCI_CLASS_SUB_CODE_INPUT_MOUSE 0x02
137 #define PCI_CLASS_SUB_CODE_INPUT_SCANNER 0x03
138 #define PCI_CLASS_SUB_CODE_INPUT_GAMEPORT 0x04
139 #define PCI_CLASS_SUB_CODE_INPUT_OTHER 0x80
140 #define PCI_CLASS_SUB_CODE_DOCKING_GENERIC 0x00
141 #define PCI_CLASS_SUB_CODE_DOCKING_OTHER 0x80
142 #define PCI_CLASS_SUB_CODE_PROCESSOR_386 0x00
143 #define PCI_CLASS_SUB_CODE_PROCESSOR_486 0x01
144 #define PCI_CLASS_SUB_CODE_PROCESSOR_PENTIUM 0x02
145 #define PCI_CLASS_SUB_CODE_PROCESSOR_ALPHA 0x10
146 #define PCI_CLASS_SUB_CODE_PROCESSOR_POWERPC 0x20
147 #define PCI_CLASS_SUB_CODE_PROCESSOR_MIPS 0x30
148 #define PCI_CLASS_SUB_CODE_PROCESSOR_COPROC 0x40
149 #define PCI_CLASS_SUB_CODE_SERIAL_1394 0x00
150 #define PCI_CLASS_SUB_CODE_SERIAL_ACCESSBUS 0x01
151 #define PCI_CLASS_SUB_CODE_SERIAL_SSA 0x02
152 #define PCI_CLASS_SUB_CODE_SERIAL_USB 0x03
153 #define PCI_CLASS_SUB_CODE_SERIAL_FIBRECHAN 0x04
154 #define PCI_CLASS_SUB_CODE_SERIAL_SMBUS 0x05
155 #define PCI_CLASS_SUB_CODE_SERIAL_INFINIBAND 0x06
156 #define PCI_CLASS_SUB_CODE_SERIAL_IPMI 0x07
157 #define PCI_CLASS_SUB_CODE_SERIAL_SERCOS 0x08
158 #define PCI_CLASS_SUB_CODE_SERIAL_CANBUS 0x09
159 #define PCI_CLASS_SUB_CODE_WIRELESS_IRDA 0x00
160 #define PCI_CLASS_SUB_CODE_WIRELESS_IR 0x01
161 #define PCI_CLASS_SUB_CODE_WIRELESS_RF 0x10
162 #define PCI_CLASS_SUB_CODE_WIRELESS_BLUETOOTH 0x11
163 #define PCI_CLASS_SUB_CODE_WIRELESS_BROADBAND 0x12
164 #define PCI_CLASS_SUB_CODE_WIRELESS_80211A 0x20
165 #define PCI_CLASS_SUB_CODE_WIRELESS_80211B 0x21
166 #define PCI_CLASS_SUB_CODE_WIRELESS_OTHER 0x80
167 #define PCI_CLASS_SUB_CODE_I2O_V1_0 0x00
168 #define PCI_CLASS_SUB_CODE_SATELLITE_TV 0x01
169 #define PCI_CLASS_SUB_CODE_SATELLITE_AUDIO 0x02
170 #define PCI_CLASS_SUB_CODE_SATELLITE_VOICE 0x03
171 #define PCI_CLASS_SUB_CODE_SATELLITE_DATA 0x04
172 #define PCI_CLASS_SUB_CODE_CRYPTO_NETWORK 0x00
173 #define PCI_CLASS_SUB_CODE_CRYPTO_ENTERTAINMENT 0x10
174 #define PCI_CLASS_SUB_CODE_CRYPTO_OTHER 0x80
175 #define PCI_CLASS_SUB_CODE_DATA_DPIO 0x00
176 #define PCI_CLASS_SUB_CODE_DATA_PERFCNTR 0x01
177 #define PCI_CLASS_SUB_CODE_DATA_COMMSYNC 0x10
178 #define PCI_CLASS_SUB_CODE_DATA_MGMT 0x20
179 #define PCI_CLASS_SUB_CODE_DATA_OTHER 0x80
181 #define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */
182 #define PCI_LATENCY_TIMER 0x0d /* 8 bits */
183 #define PCI_HEADER_TYPE 0x0e /* 8 bits */
184 #define PCI_HEADER_TYPE_NORMAL 0
185 #define PCI_HEADER_TYPE_BRIDGE 1
186 #define PCI_HEADER_TYPE_CARDBUS 2
188 #define PCI_BIST 0x0f /* 8 bits */
189 #define PCI_BIST_CODE_MASK 0x0f /* Return result */
190 #define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */
191 #define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */
194 * Base addresses specify locations in memory or I/O space.
195 * Decoded size can be determined by writing a value of
196 * 0xffffffff to the register, and reading it back. Only
197 * 1 bits are decoded.
199 #define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */
200 #define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */
201 #define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */
202 #define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */
203 #define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */
204 #define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */
205 #define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */
206 #define PCI_BASE_ADDRESS_SPACE_IO 0x01
207 #define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
208 #define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
209 #define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */
210 #define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */
211 #define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
212 #define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
213 #define PCI_BASE_ADDRESS_MEM_MASK (~0x0fULL)
214 #define PCI_BASE_ADDRESS_IO_MASK (~0x03ULL)
215 /* bit 1 is reserved if address_space = 1 */
217 /* Header type 0 (normal devices) */
218 #define PCI_CARDBUS_CIS 0x28
219 #define PCI_SUBSYSTEM_VENDOR_ID 0x2c
220 #define PCI_SUBSYSTEM_ID 0x2e
221 #define PCI_ROM_ADDRESS 0x30 /* Bits 31..11 are address, 10..1 reserved */
222 #define PCI_ROM_ADDRESS_ENABLE 0x01
223 #define PCI_ROM_ADDRESS_MASK (~0x7ffULL)
225 #define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
227 /* 0x35-0x3b are reserved */
228 #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
229 #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
230 #define PCI_MIN_GNT 0x3e /* 8 bits */
231 #define PCI_MAX_LAT 0x3f /* 8 bits */
233 #define PCI_INTERRUPT_LINE_DISABLE 0xff
235 /* Header type 1 (PCI-to-PCI bridges) */
236 #define PCI_PRIMARY_BUS 0x18 /* Primary bus number */
237 #define PCI_SECONDARY_BUS 0x19 /* Secondary bus number */
238 #define PCI_SUBORDINATE_BUS 0x1a /* Highest bus number behind the bridge */
239 #define PCI_SEC_LATENCY_TIMER 0x1b /* Latency timer for secondary interface */
240 #define PCI_IO_BASE 0x1c /* I/O range behind the bridge */
241 #define PCI_IO_LIMIT 0x1d
242 #define PCI_IO_RANGE_TYPE_MASK 0x0f /* I/O bridging type */
243 #define PCI_IO_RANGE_TYPE_16 0x00
244 #define PCI_IO_RANGE_TYPE_32 0x01
245 #define PCI_IO_RANGE_MASK ~0x0f
246 #define PCI_SEC_STATUS 0x1e /* Secondary status register, only bit 14 used */
247 #define PCI_MEMORY_BASE 0x20 /* Memory range behind */
248 #define PCI_MEMORY_LIMIT 0x22
249 #define PCI_MEMORY_RANGE_TYPE_MASK 0x0f
250 #define PCI_MEMORY_RANGE_MASK ~0x0f
251 #define PCI_PREF_MEMORY_BASE 0x24 /* Prefetchable memory range behind */
252 #define PCI_PREF_MEMORY_LIMIT 0x26
253 #define PCI_PREF_RANGE_TYPE_MASK 0x0f
254 #define PCI_PREF_RANGE_TYPE_32 0x00
255 #define PCI_PREF_RANGE_TYPE_64 0x01
256 #define PCI_PREF_RANGE_MASK ~0x0f
257 #define PCI_PREF_BASE_UPPER32 0x28 /* Upper half of prefetchable memory range */
258 #define PCI_PREF_LIMIT_UPPER32 0x2c
259 #define PCI_IO_BASE_UPPER16 0x30 /* Upper half of I/O addresses */
260 #define PCI_IO_LIMIT_UPPER16 0x32
261 /* 0x34 same as for htype 0 */
262 /* 0x35-0x3b is reserved */
263 #define PCI_ROM_ADDRESS1 0x38 /* Same as PCI_ROM_ADDRESS, but for htype 1 */
264 /* 0x3c-0x3d are same as for htype 0 */
265 #define PCI_BRIDGE_CONTROL 0x3e
266 #define PCI_BRIDGE_CTL_PARITY 0x01 /* Enable parity detection on secondary interface */
267 #define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */
268 #define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */
269 #define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */
270 #define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */
271 #define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */
272 #define PCI_BRIDGE_CTL_FAST_BACK 0x80 /* Fast Back2Back enabled on secondary interface */
274 /* Header type 2 (CardBus bridges) */
275 #define PCI_CB_CAPABILITY_LIST 0x14
277 #define PCI_CB_SEC_STATUS 0x16 /* Secondary status */
278 #define PCI_CB_PRIMARY_BUS 0x18 /* PCI bus number */
279 #define PCI_CB_CARD_BUS 0x19 /* CardBus bus number */
280 #define PCI_CB_SUBORDINATE_BUS 0x1a /* Subordinate bus number */
281 #define PCI_CB_LATENCY_TIMER 0x1b /* CardBus latency timer */
282 #define PCI_CB_MEMORY_BASE_0 0x1c
283 #define PCI_CB_MEMORY_LIMIT_0 0x20
284 #define PCI_CB_MEMORY_BASE_1 0x24
285 #define PCI_CB_MEMORY_LIMIT_1 0x28
286 #define PCI_CB_IO_BASE_0 0x2c
287 #define PCI_CB_IO_BASE_0_HI 0x2e
288 #define PCI_CB_IO_LIMIT_0 0x30
289 #define PCI_CB_IO_LIMIT_0_HI 0x32
290 #define PCI_CB_IO_BASE_1 0x34
291 #define PCI_CB_IO_BASE_1_HI 0x36
292 #define PCI_CB_IO_LIMIT_1 0x38
293 #define PCI_CB_IO_LIMIT_1_HI 0x3a
294 #define PCI_CB_IO_RANGE_MASK ~0x03
295 /* 0x3c-0x3d are same as for htype 0 */
296 #define PCI_CB_BRIDGE_CONTROL 0x3e
297 #define PCI_CB_BRIDGE_CTL_PARITY 0x01 /* Similar to standard bridge control register */
298 #define PCI_CB_BRIDGE_CTL_SERR 0x02
299 #define PCI_CB_BRIDGE_CTL_ISA 0x04
300 #define PCI_CB_BRIDGE_CTL_VGA 0x08
301 #define PCI_CB_BRIDGE_CTL_MASTER_ABORT 0x20
302 #define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
303 #define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
304 #define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100 /* Prefetch enable for both memory regions */
305 #define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
306 #define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
307 #define PCI_CB_SUBSYSTEM_VENDOR_ID 0x40
308 #define PCI_CB_SUBSYSTEM_ID 0x42
309 #define PCI_CB_LEGACY_MODE_BASE 0x44 /* 16-bit PC Card legacy mode base address (ExCa) */
310 /* 0x48-0x7f reserved */
312 /* Capability lists */
314 #define PCI_CAP_LIST_ID 0 /* Capability ID */
315 #define PCI_CAP_ID_PM 0x01 /* Power Management */
316 #define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */
317 #define PCI_CAP_ID_VPD 0x03 /* Vital Product Data */
318 #define PCI_CAP_ID_SLOTID 0x04 /* Slot Identification */
319 #define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
320 #define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
321 #define PCI_CAP_ID_PCIX 0x07 /* PCI-X */
322 #define PCI_CAP_ID_HT 0x08 /* HyperTransport */
323 #define PCI_CAP_ID_VNDR 0x09 /* Vendor-Specific */
324 #define PCI_CAP_ID_DBG 0x0A /* Debug port */
325 #define PCI_CAP_ID_CCRC 0x0B /* CompactPCI Central Resource Control */
326 #define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */
327 #define PCI_CAP_ID_SSVID 0x0D /* Bridge subsystem vendor/device ID */
328 #define PCI_CAP_ID_AGP3 0x0E /* AGP Target PCI-PCI bridge */
329 #define PCI_CAP_ID_SECDEV 0x0F /* Secure Device */
330 #define PCI_CAP_ID_EXP 0x10 /* PCI Express */
331 #define PCI_CAP_ID_MSIX 0x11 /* MSI-X */
332 #define PCI_CAP_ID_SATA 0x12 /* SATA Data/Index Conf. */
333 #define PCI_CAP_ID_AF 0x13 /* PCI Advanced Features */
334 #define PCI_CAP_ID_EA 0x14 /* PCI Enhanced Allocation */
335 #define PCI_CAP_ID_MAX PCI_CAP_ID_EA
336 #define PCI_CAP_LIST_NEXT 1 /* Next capability in the list */
337 #define PCI_CAP_FLAGS 2 /* Capability defined flags (16 bits) */
338 #define PCI_CAP_SIZEOF 4
340 /* Power Management Registers */
342 #define PCI_PM_CAP_VER_MASK 0x0007 /* Version */
343 #define PCI_PM_CAP_PME_CLOCK 0x0008 /* PME clock required */
344 #define PCI_PM_CAP_AUX_POWER 0x0010 /* Auxilliary power support */
345 #define PCI_PM_CAP_DSI 0x0020 /* Device specific initialization */
346 #define PCI_PM_CAP_D1 0x0200 /* D1 power state support */
347 #define PCI_PM_CAP_D2 0x0400 /* D2 power state support */
348 #define PCI_PM_CAP_PME 0x0800 /* PME pin supported */
349 #define PCI_PM_CTRL 4 /* PM control and status register */
350 #define PCI_PM_CTRL_STATE_MASK 0x0003 /* Current power state (D0 to D3) */
351 #define PCI_PM_CTRL_PME_ENABLE 0x0100 /* PME pin enable */
352 #define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00 /* Data select (??) */
353 #define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000 /* Data scale (??) */
354 #define PCI_PM_CTRL_PME_STATUS 0x8000 /* PME pin status */
355 #define PCI_PM_PPB_EXTENSIONS 6 /* PPB support extensions (??) */
356 #define PCI_PM_PPB_B2_B3 0x40 /* Stop clock when in D3hot (??) */
357 #define PCI_PM_BPCC_ENABLE 0x80 /* Bus power/clock control enable (??) */
358 #define PCI_PM_DATA_REGISTER 7 /* (??) */
359 #define PCI_PM_SIZEOF 8
363 #define PCI_AGP_VERSION 2 /* BCD version number */
364 #define PCI_AGP_RFU 3 /* Rest of capability flags */
365 #define PCI_AGP_STATUS 4 /* Status register */
366 #define PCI_AGP_STATUS_RQ_MASK 0xff000000 /* Maximum number of requests - 1 */
367 #define PCI_AGP_STATUS_SBA 0x0200 /* Sideband addressing supported */
368 #define PCI_AGP_STATUS_64BIT 0x0020 /* 64-bit addressing supported */
369 #define PCI_AGP_STATUS_FW 0x0010 /* FW transfers supported */
370 #define PCI_AGP_STATUS_RATE4 0x0004 /* 4x transfer rate supported */
371 #define PCI_AGP_STATUS_RATE2 0x0002 /* 2x transfer rate supported */
372 #define PCI_AGP_STATUS_RATE1 0x0001 /* 1x transfer rate supported */
373 #define PCI_AGP_COMMAND 8 /* Control register */
374 #define PCI_AGP_COMMAND_RQ_MASK 0xff000000 /* Master: Maximum number of requests */
375 #define PCI_AGP_COMMAND_SBA 0x0200 /* Sideband addressing enabled */
376 #define PCI_AGP_COMMAND_AGP 0x0100 /* Allow processing of AGP transactions */
377 #define PCI_AGP_COMMAND_64BIT 0x0020 /* Allow processing of 64-bit addresses */
378 #define PCI_AGP_COMMAND_FW 0x0010 /* Force FW transfers */
379 #define PCI_AGP_COMMAND_RATE4 0x0004 /* Use 4x rate */
380 #define PCI_AGP_COMMAND_RATE2 0x0002 /* Use 4x rate */
381 #define PCI_AGP_COMMAND_RATE1 0x0001 /* Use 4x rate */
382 #define PCI_AGP_SIZEOF 12
384 /* PCI-X registers */
386 #define PCI_X_CMD_DPERR_E 0x0001 /* Data Parity Error Recovery Enable */
387 #define PCI_X_CMD_ERO 0x0002 /* Enable Relaxed Ordering */
388 #define PCI_X_CMD_MAX_READ 0x0000 /* Max Memory Read Byte Count */
389 #define PCI_X_CMD_MAX_SPLIT 0x0030 /* Max Outstanding Split Transactions */
390 #define PCI_X_CMD_VERSION(x) (((x) >> 12) & 3) /* Version */
393 /* Slot Identification */
395 #define PCI_SID_ESR 2 /* Expansion Slot Register */
396 #define PCI_SID_ESR_NSLOTS 0x1f /* Number of expansion slots available */
397 #define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
398 #define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
400 /* Message Signalled Interrupts registers */
402 #define PCI_MSI_FLAGS 2 /* Various flags */
403 #define PCI_MSI_FLAGS_64BIT 0x80 /* 64-bit addresses allowed */
404 #define PCI_MSI_FLAGS_QSIZE 0x70 /* Message queue size configured */
405 #define PCI_MSI_FLAGS_QMASK 0x0e /* Maximum queue size available */
406 #define PCI_MSI_FLAGS_ENABLE 0x01 /* MSI feature enabled */
407 #define PCI_MSI_RFU 3 /* Rest of capability flags */
408 #define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
409 #define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
410 #define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
411 #define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
413 #define PCI_MAX_PCI_DEVICES 32
414 #define PCI_MAX_PCI_FUNCTIONS 8
416 #define PCI_FIND_CAP_TTL 0x48
417 #define CAP_START_POS 0x40
419 /* Extended Capabilities (PCI-X 2.0 and Express) */
420 #define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
421 #define PCI_EXT_CAP_VER(header) ((header >> 16) & 0xf)
422 #define PCI_EXT_CAP_NEXT(header) ((header >> 20) & 0xffc)
424 #define PCI_EXT_CAP_ID_ERR 0x01 /* Advanced Error Reporting */
425 #define PCI_EXT_CAP_ID_VC 0x02 /* Virtual Channel Capability */
426 #define PCI_EXT_CAP_ID_DSN 0x03 /* Device Serial Number */
427 #define PCI_EXT_CAP_ID_PWR 0x04 /* Power Budgeting */
428 #define PCI_EXT_CAP_ID_RCLD 0x05 /* Root Complex Link Declaration */
429 #define PCI_EXT_CAP_ID_RCILC 0x06 /* Root Complex Internal Link Control */
430 #define PCI_EXT_CAP_ID_RCEC 0x07 /* Root Complex Event Collector */
431 #define PCI_EXT_CAP_ID_MFVC 0x08 /* Multi-Function VC Capability */
432 #define PCI_EXT_CAP_ID_VC9 0x09 /* same as _VC */
433 #define PCI_EXT_CAP_ID_RCRB 0x0A /* Root Complex RB? */
434 #define PCI_EXT_CAP_ID_VNDR 0x0B /* Vendor-Specific */
435 #define PCI_EXT_CAP_ID_CAC 0x0C /* Config Access - obsolete */
436 #define PCI_EXT_CAP_ID_ACS 0x0D /* Access Control Services */
437 #define PCI_EXT_CAP_ID_ARI 0x0E /* Alternate Routing ID */
438 #define PCI_EXT_CAP_ID_ATS 0x0F /* Address Translation Services */
439 #define PCI_EXT_CAP_ID_SRIOV 0x10 /* Single Root I/O Virtualization */
440 #define PCI_EXT_CAP_ID_MRIOV 0x11 /* Multi Root I/O Virtualization */
441 #define PCI_EXT_CAP_ID_MCAST 0x12 /* Multicast */
442 #define PCI_EXT_CAP_ID_PRI 0x13 /* Page Request Interface */
443 #define PCI_EXT_CAP_ID_AMD_XXX 0x14 /* Reserved for AMD */
444 #define PCI_EXT_CAP_ID_REBAR 0x15 /* Resizable BAR */
445 #define PCI_EXT_CAP_ID_DPA 0x16 /* Dynamic Power Allocation */
446 #define PCI_EXT_CAP_ID_TPH 0x17 /* TPH Requester */
447 #define PCI_EXT_CAP_ID_LTR 0x18 /* Latency Tolerance Reporting */
448 #define PCI_EXT_CAP_ID_SECPCI 0x19 /* Secondary PCIe Capability */
449 #define PCI_EXT_CAP_ID_PMUX 0x1A /* Protocol Multiplexing */
450 #define PCI_EXT_CAP_ID_PASID 0x1B /* Process Address Space ID */
451 #define PCI_EXT_CAP_ID_DPC 0x1D /* Downstream Port Containment */
452 #define PCI_EXT_CAP_ID_L1SS 0x1E /* L1 PM Substates */
453 #define PCI_EXT_CAP_ID_PTM 0x1F /* Precision Time Measurement */
454 #define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PTM
456 /* Include the ID list */
462 #ifdef CONFIG_SYS_PCI_64BIT
463 typedef u64 pci_addr_t;
464 typedef u64 pci_size_t;
466 typedef u32 pci_addr_t;
467 typedef u32 pci_size_t;
471 pci_addr_t bus_start; /* Start on the bus */
472 phys_addr_t phys_start; /* Start in physical address space */
473 pci_size_t size; /* Size */
474 unsigned long flags; /* Resource flags */
476 pci_addr_t bus_lower;
479 #define PCI_REGION_MEM 0x00000000 /* PCI memory space */
480 #define PCI_REGION_IO 0x00000001 /* PCI IO space */
481 #define PCI_REGION_TYPE 0x00000001
482 #define PCI_REGION_PREFETCH 0x00000008 /* prefetchable PCI memory */
484 #define PCI_REGION_SYS_MEMORY 0x00000100 /* System memory */
485 #define PCI_REGION_RO 0x00000200 /* Read-only memory */
487 static inline void pci_set_region(struct pci_region *reg,
488 pci_addr_t bus_start,
489 phys_addr_t phys_start,
491 unsigned long flags) {
492 reg->bus_start = bus_start;
493 reg->phys_start = phys_start;
498 typedef int pci_dev_t;
500 #define PCI_BUS(d) (((d) >> 16) & 0xff)
501 #define PCI_DEV(d) (((d) >> 11) & 0x1f)
502 #define PCI_FUNC(d) (((d) >> 8) & 0x7)
503 #define PCI_DEVFN(d, f) ((d) << 11 | (f) << 8)
504 #define PCI_MASK_BUS(bdf) ((bdf) & 0xffff)
505 #define PCI_ADD_BUS(bus, devfn) (((bus) << 16) | (devfn))
506 #define PCI_BDF(b, d, f) ((b) << 16 | PCI_DEVFN(d, f))
507 #define PCI_VENDEV(v, d) (((v) << 16) | (d))
508 #define PCI_ANY_ID (~0)
510 struct pci_device_id {
511 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
512 unsigned int subvendor, subdevice; /* Subsystem ID's or PCI_ANY_ID */
513 unsigned int class, class_mask; /* (class,subclass,prog-if) triplet */
514 unsigned long driver_data; /* Data private to the driver */
517 struct pci_controller;
519 struct pci_config_table {
520 unsigned int vendor, device; /* Vendor and device ID or PCI_ANY_ID */
521 unsigned int class; /* Class ID, or PCI_ANY_ID */
522 unsigned int bus; /* Bus number, or PCI_ANY_ID */
523 unsigned int dev; /* Device number, or PCI_ANY_ID */
524 unsigned int func; /* Function number, or PCI_ANY_ID */
526 void (*config_device)(struct pci_controller* hose, pci_dev_t dev,
527 struct pci_config_table *);
528 unsigned long priv[3];
531 extern void pci_cfgfunc_do_nothing(struct pci_controller* hose, pci_dev_t dev,
532 struct pci_config_table *);
533 extern void pci_cfgfunc_config_device(struct pci_controller* hose, pci_dev_t dev,
534 struct pci_config_table *);
536 #define MAX_PCI_REGIONS 7
538 #define INDIRECT_TYPE_NO_PCIE_LINK 1
541 * Structure of a PCI controller (host bridge)
543 * With driver model this is dev_get_uclass_priv(bus)
545 struct pci_controller {
548 struct udevice *ctlr;
550 struct pci_controller *next;
556 volatile unsigned int *cfg_addr;
557 volatile unsigned char *cfg_data;
562 * TODO(sjg@chromium.org): With driver model we use struct
563 * pci_controller for both the controller and any bridge devices
564 * attached to it. But there is only one region list and it is in the
565 * top-level controller.
567 * This could be changed so that struct pci_controller is only used
568 * for PCI controllers and a separate UCLASS (or perhaps
569 * UCLASS_PCI_GENERIC) is used for bridges.
571 struct pci_region regions[MAX_PCI_REGIONS];
574 struct pci_config_table *config_table;
576 void (*fixup_irq)(struct pci_controller *, pci_dev_t);
577 #ifndef CONFIG_DM_PCI
578 /* Low-level architecture-dependent routines */
579 int (*read_byte)(struct pci_controller*, pci_dev_t, int where, u8 *);
580 int (*read_word)(struct pci_controller*, pci_dev_t, int where, u16 *);
581 int (*read_dword)(struct pci_controller*, pci_dev_t, int where, u32 *);
582 int (*write_byte)(struct pci_controller*, pci_dev_t, int where, u8);
583 int (*write_word)(struct pci_controller*, pci_dev_t, int where, u16);
584 int (*write_dword)(struct pci_controller*, pci_dev_t, int where, u32);
587 /* Used by auto config */
588 struct pci_region *pci_mem, *pci_io, *pci_prefetch;
590 #ifndef CONFIG_DM_PCI
597 #ifndef CONFIG_DM_PCI
598 static inline void pci_set_ops(struct pci_controller *hose,
599 int (*read_byte)(struct pci_controller*,
600 pci_dev_t, int where, u8 *),
601 int (*read_word)(struct pci_controller*,
602 pci_dev_t, int where, u16 *),
603 int (*read_dword)(struct pci_controller*,
604 pci_dev_t, int where, u32 *),
605 int (*write_byte)(struct pci_controller*,
606 pci_dev_t, int where, u8),
607 int (*write_word)(struct pci_controller*,
608 pci_dev_t, int where, u16),
609 int (*write_dword)(struct pci_controller*,
610 pci_dev_t, int where, u32)) {
611 hose->read_byte = read_byte;
612 hose->read_word = read_word;
613 hose->read_dword = read_dword;
614 hose->write_byte = write_byte;
615 hose->write_word = write_word;
616 hose->write_dword = write_dword;
620 #ifdef CONFIG_PCI_INDIRECT_BRIDGE
621 extern void pci_setup_indirect(struct pci_controller* hose, u32 cfg_addr, u32 cfg_data);
624 #if !defined(CONFIG_DM_PCI) || defined(CONFIG_DM_PCI_COMPAT)
625 extern phys_addr_t pci_hose_bus_to_phys(struct pci_controller* hose,
626 pci_addr_t addr, unsigned long flags);
627 extern pci_addr_t pci_hose_phys_to_bus(struct pci_controller* hose,
628 phys_addr_t addr, unsigned long flags);
630 #define pci_phys_to_bus(dev, addr, flags) \
631 pci_hose_phys_to_bus(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))
632 #define pci_bus_to_phys(dev, addr, flags) \
633 pci_hose_bus_to_phys(pci_bus_to_hose(PCI_BUS(dev)), (addr), (flags))
635 #define pci_virt_to_bus(dev, addr, flags) \
636 pci_hose_phys_to_bus(pci_bus_to_hose(PCI_BUS(dev)), \
637 (virt_to_phys(addr)), (flags))
638 #define pci_bus_to_virt(dev, addr, flags, len, map_flags) \
639 map_physmem(pci_hose_bus_to_phys(pci_bus_to_hose(PCI_BUS(dev)), \
643 #define pci_phys_to_mem(dev, addr) \
644 pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)
645 #define pci_mem_to_phys(dev, addr) \
646 pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)
647 #define pci_phys_to_io(dev, addr) pci_phys_to_bus((dev), (addr), PCI_REGION_IO)
648 #define pci_io_to_phys(dev, addr) pci_bus_to_phys((dev), (addr), PCI_REGION_IO)
650 #define pci_virt_to_mem(dev, addr) \
651 pci_virt_to_bus((dev), (addr), PCI_REGION_MEM)
652 #define pci_mem_to_virt(dev, addr, len, map_flags) \
653 pci_bus_to_virt((dev), (addr), PCI_REGION_MEM, (len), (map_flags))
654 #define pci_virt_to_io(dev, addr) \
655 pci_virt_to_bus((dev), (addr), PCI_REGION_IO)
656 #define pci_io_to_virt(dev, addr, len, map_flags) \
657 pci_bus_to_virt((dev), (addr), PCI_REGION_IO, (len), (map_flags))
659 /* For driver model these are defined in macros in pci_compat.c */
660 extern int pci_hose_read_config_byte(struct pci_controller *hose,
661 pci_dev_t dev, int where, u8 *val);
662 extern int pci_hose_read_config_word(struct pci_controller *hose,
663 pci_dev_t dev, int where, u16 *val);
664 extern int pci_hose_read_config_dword(struct pci_controller *hose,
665 pci_dev_t dev, int where, u32 *val);
666 extern int pci_hose_write_config_byte(struct pci_controller *hose,
667 pci_dev_t dev, int where, u8 val);
668 extern int pci_hose_write_config_word(struct pci_controller *hose,
669 pci_dev_t dev, int where, u16 val);
670 extern int pci_hose_write_config_dword(struct pci_controller *hose,
671 pci_dev_t dev, int where, u32 val);
674 #ifndef CONFIG_DM_PCI
675 extern int pci_read_config_byte(pci_dev_t dev, int where, u8 *val);
676 extern int pci_read_config_word(pci_dev_t dev, int where, u16 *val);
677 extern int pci_read_config_dword(pci_dev_t dev, int where, u32 *val);
678 extern int pci_write_config_byte(pci_dev_t dev, int where, u8 val);
679 extern int pci_write_config_word(pci_dev_t dev, int where, u16 val);
680 extern int pci_write_config_dword(pci_dev_t dev, int where, u32 val);
683 void pciauto_region_init(struct pci_region *res);
684 void pciauto_region_align(struct pci_region *res, pci_size_t size);
685 void pciauto_config_init(struct pci_controller *hose);
688 * pciauto_region_allocate() - Allocate resources from a PCI resource region
690 * Allocates @size bytes from the PCI resource @res. If @supports_64bit is
691 * false, the result will be guaranteed to fit in 32 bits.
693 * @res: PCI region to allocate from
694 * @size: Amount of bytes to allocate
695 * @bar: Returns the PCI bus address of the allocated resource
696 * @supports_64bit: Whether to allow allocations above the 32-bit boundary
697 * @return 0 if successful, -1 on failure
699 int pciauto_region_allocate(struct pci_region *res, pci_size_t size,
700 pci_addr_t *bar, bool supports_64bit);
702 #if !defined(CONFIG_DM_PCI) || defined(CONFIG_DM_PCI_COMPAT)
703 extern int pci_hose_read_config_byte_via_dword(struct pci_controller *hose,
704 pci_dev_t dev, int where, u8 *val);
705 extern int pci_hose_read_config_word_via_dword(struct pci_controller *hose,
706 pci_dev_t dev, int where, u16 *val);
707 extern int pci_hose_write_config_byte_via_dword(struct pci_controller *hose,
708 pci_dev_t dev, int where, u8 val);
709 extern int pci_hose_write_config_word_via_dword(struct pci_controller *hose,
710 pci_dev_t dev, int where, u16 val);
712 extern void *pci_map_bar(pci_dev_t pdev, int bar, int flags);
713 extern void pci_register_hose(struct pci_controller* hose);
714 extern struct pci_controller* pci_bus_to_hose(int bus);
715 extern struct pci_controller *find_hose_by_cfg_addr(void *cfg_addr);
716 extern struct pci_controller *pci_get_hose_head(void);
718 extern int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev);
719 extern int pci_hose_scan(struct pci_controller *hose);
720 extern int pci_hose_scan_bus(struct pci_controller *hose, int bus);
722 extern void pciauto_setup_device(struct pci_controller *hose,
723 pci_dev_t dev, int bars_num,
724 struct pci_region *mem,
725 struct pci_region *prefetch,
726 struct pci_region *io);
727 extern void pciauto_prescan_setup_bridge(struct pci_controller *hose,
728 pci_dev_t dev, int sub_bus);
729 extern void pciauto_postscan_setup_bridge(struct pci_controller *hose,
730 pci_dev_t dev, int sub_bus);
731 extern int pciauto_config_device(struct pci_controller *hose, pci_dev_t dev);
733 extern pci_dev_t pci_find_device (unsigned int vendor, unsigned int device, int index);
734 extern pci_dev_t pci_find_devices (struct pci_device_id *ids, int index);
735 pci_dev_t pci_find_class(unsigned int find_class, int index);
737 extern int pci_hose_config_device(struct pci_controller *hose,
741 unsigned long command);
743 extern int pci_hose_find_capability(struct pci_controller *hose, pci_dev_t dev,
745 extern int pci_hose_find_cap_start(struct pci_controller *hose, pci_dev_t dev,
747 extern int pci_find_cap(struct pci_controller *hose, pci_dev_t dev, int pos,
750 int pci_find_next_ext_capability(struct pci_controller *hose,
751 pci_dev_t dev, int start, int cap);
752 int pci_hose_find_ext_capability(struct pci_controller *hose,
753 pci_dev_t dev, int cap);
755 #ifdef CONFIG_PCI_FIXUP_DEV
756 extern void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev,
757 unsigned short vendor,
758 unsigned short device,
759 unsigned short class);
761 #endif /* !defined(CONFIG_DM_PCI) || defined(CONFIG_DM_PCI_COMPAT) */
763 const char * pci_class_str(u8 class);
764 int pci_last_busno(void);
766 #ifdef CONFIG_MPC85xx
767 extern void pci_mpc85xx_init (struct pci_controller *hose);
770 #ifdef CONFIG_PCIE_IMX
771 extern void imx_pcie_remove(void);
774 #if !defined(CONFIG_DM_PCI) || defined(CONFIG_DM_PCI_COMPAT)
776 * pci_write_bar32() - Write the address of a BAR including control bits
778 * This writes a raw address (with control bits) to a bar. This can be used
779 * with devices which require hard-coded addresses, not part of the normal
780 * PCI enumeration process.
782 * @hose: PCI hose to use
783 * @dev: PCI device to update
784 * @barnum: BAR number (0-5)
785 * @addr: BAR address with control bits
787 void pci_write_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum,
791 * pci_read_bar32() - read the address of a bar
793 * @hose: PCI hose to use
794 * @dev: PCI device to inspect
795 * @barnum: BAR number (0-5)
796 * @return address of the bar, masking out any control bits
798 u32 pci_read_bar32(struct pci_controller *hose, pci_dev_t dev, int barnum);
801 * pci_hose_find_devices() - Find devices by vendor/device ID
803 * @hose: PCI hose to search
804 * @busnum: Bus number to search
805 * @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record
806 * @indexp: Pointer to device index to find. To find the first matching
807 * device, pass 0; to find the second, pass 1, etc. This
808 * parameter is decremented for each non-matching device so
809 * can be called repeatedly.
811 pci_dev_t pci_hose_find_devices(struct pci_controller *hose, int busnum,
812 struct pci_device_id *ids, int *indexp);
813 #endif /* !CONFIG_DM_PCI || CONFIG_DM_PCI_COMPAT */
815 /* Access sizes for PCI reads and writes */
826 * struct pci_child_platdata - information stored about each PCI device
828 * Every device on a PCI bus has this per-child data.
830 * It can be accessed using dev_get_parent_priv(dev) if dev->parent is a
831 * PCI bus (i.e. UCLASS_PCI)
833 * @devfn: Encoded device and function index - see PCI_DEVFN()
834 * @vendor: PCI vendor ID (see pci_ids.h)
835 * @device: PCI device ID (see pci_ids.h)
836 * @class: PCI class, 3 bytes: (base, sub, prog-if)
838 struct pci_child_platdata {
840 unsigned short vendor;
841 unsigned short device;
845 /* PCI bus operations */
848 * read_config() - Read a PCI configuration value
850 * PCI buses must support reading and writing configuration values
851 * so that the bus can be scanned and its devices configured.
853 * Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always.
854 * If bridges exist it is possible to use the top-level bus to
855 * access a sub-bus. In that case @bus will be the top-level bus
856 * and PCI_BUS(bdf) will be a different (higher) value
858 * @bus: Bus to read from
859 * @bdf: Bus, device and function to read
860 * @offset: Byte offset within the device's configuration space
861 * @valuep: Place to put the returned value
863 * @return 0 if OK, -ve on error
865 int (*read_config)(struct udevice *bus, pci_dev_t bdf, uint offset,
866 ulong *valuep, enum pci_size_t size);
868 * write_config() - Write a PCI configuration value
870 * @bus: Bus to write to
871 * @bdf: Bus, device and function to write
872 * @offset: Byte offset within the device's configuration space
873 * @value: Value to write
875 * @return 0 if OK, -ve on error
877 int (*write_config)(struct udevice *bus, pci_dev_t bdf, uint offset,
878 ulong value, enum pci_size_t size);
881 /* Get access to a PCI bus' operations */
882 #define pci_get_ops(dev) ((struct dm_pci_ops *)(dev)->driver->ops)
885 * dm_pci_get_bdf() - Get the BDF value for a device
887 * @dev: Device to check
888 * @return bus/device/function value (see PCI_BDF())
890 pci_dev_t dm_pci_get_bdf(struct udevice *dev);
893 * pci_bind_bus_devices() - scan a PCI bus and bind devices
895 * Scan a PCI bus looking for devices. Bind each one that is found. If
896 * devices are already bound that match the scanned devices, just update the
897 * child data so that the device can be used correctly (this happens when
898 * the device tree describes devices we expect to see on the bus).
900 * Devices that are bound in this way will use a generic PCI driver which
901 * does nothing. The device can still be accessed but will not provide any
904 * @bus: Bus containing devices to bind
905 * @return 0 if OK, -ve on error
907 int pci_bind_bus_devices(struct udevice *bus);
910 * pci_auto_config_devices() - configure bus devices ready for use
912 * This works through all devices on a bus by scanning the driver model
913 * data structures (normally these have been set up by pci_bind_bus_devices()
916 * Space is allocated for each PCI base address register (BAR) so that the
917 * devices are mapped into memory and I/O space ready for use.
919 * @bus: Bus containing devices to bind
920 * @return 0 if OK, -ve on error
922 int pci_auto_config_devices(struct udevice *bus);
925 * dm_pci_bus_find_bdf() - Find a device given its PCI bus address
927 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
928 * @devp: Returns the device for this address, if found
929 * @return 0 if OK, -ENODEV if not found
931 int dm_pci_bus_find_bdf(pci_dev_t bdf, struct udevice **devp);
934 * pci_bus_find_devfn() - Find a device on a bus
936 * @find_devfn: PCI device address (device and function only)
937 * @devp: Returns the device for this address, if found
938 * @return 0 if OK, -ENODEV if not found
940 int pci_bus_find_devfn(struct udevice *bus, pci_dev_t find_devfn,
941 struct udevice **devp);
944 * pci_find_first_device() - return the first available PCI device
946 * This function and pci_find_first_device() allow iteration through all
947 * available PCI devices on all buses. Assuming there are any, this will
948 * return the first one.
950 * @devp: Set to the first available device, or NULL if no more are left
952 * @return 0 if all is OK, -ve on error (e.g. a bus/bridge failed to probe)
954 int pci_find_first_device(struct udevice **devp);
957 * pci_find_next_device() - return the next available PCI device
959 * Finds the next available PCI device after the one supplied, or sets @devp
960 * to NULL if there are no more.
962 * @devp: On entry, the last device returned. Set to the next available
963 * device, or NULL if no more are left or we got an error
964 * @return 0 if all is OK, -ve on error (e.g. a bus/bridge failed to probe)
966 int pci_find_next_device(struct udevice **devp);
969 * pci_get_ff() - Returns a mask for the given access size
972 * @return 0xff for PCI_SIZE_8, 0xffff for PCI_SIZE_16, 0xffffffff for
975 int pci_get_ff(enum pci_size_t size);
978 * pci_bus_find_devices () - Find devices on a bus
980 * @bus: Bus to search
981 * @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record
982 * @indexp: Pointer to device index to find. To find the first matching
983 * device, pass 0; to find the second, pass 1, etc. This
984 * parameter is decremented for each non-matching device so
985 * can be called repeatedly.
986 * @devp: Returns matching device if found
987 * @return 0 if found, -ENODEV if not
989 int pci_bus_find_devices(struct udevice *bus, struct pci_device_id *ids,
990 int *indexp, struct udevice **devp);
993 * pci_find_device_id() - Find a device on any bus
995 * @ids: PCI vendor/device IDs to look for, terminated by 0, 0 record
996 * @index: Index number of device to find, 0 for the first match, 1 for
998 * @devp: Returns matching device if found
999 * @return 0 if found, -ENODEV if not
1001 int pci_find_device_id(struct pci_device_id *ids, int index,
1002 struct udevice **devp);
1005 * dm_pci_hose_probe_bus() - probe a subordinate bus, scanning it for devices
1007 * This probes the given bus which causes it to be scanned for devices. The
1008 * devices will be bound but not probed.
1010 * @hose specifies the PCI hose that will be used for the scan. This is
1011 * always a top-level bus with uclass UCLASS_PCI. The bus to scan is
1012 * in @bdf, and is a subordinate bus reachable from @hose.
1014 * @hose: PCI hose to scan
1015 * @bdf: PCI bus address to scan (PCI_BUS(bdf) is the bus number)
1016 * @return 0 if OK, -ve on error
1018 int dm_pci_hose_probe_bus(struct udevice *bus);
1021 * pci_bus_read_config() - Read a configuration value from a device
1023 * TODO(sjg@chromium.org): We should be able to pass just a device and have
1024 * it do the right thing. It would be good to have that function also.
1026 * @bus: Bus to read from
1027 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
1028 * @offset: Register offset to read
1029 * @valuep: Place to put the returned value
1030 * @size: Access size
1031 * @return 0 if OK, -ve on error
1033 int pci_bus_read_config(struct udevice *bus, pci_dev_t bdf, int offset,
1034 unsigned long *valuep, enum pci_size_t size);
1037 * pci_bus_write_config() - Write a configuration value to a device
1039 * @bus: Bus to write from
1040 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
1041 * @offset: Register offset to write
1042 * @value: Value to write
1043 * @size: Access size
1044 * @return 0 if OK, -ve on error
1046 int pci_bus_write_config(struct udevice *bus, pci_dev_t bdf, int offset,
1047 unsigned long value, enum pci_size_t size);
1050 * pci_bus_clrset_config32() - Update a configuration value for a device
1052 * The register at @offset is updated to (oldvalue & ~clr) | set.
1054 * @bus: Bus to access
1055 * @bdf: PCI device address: bus, device and function -see PCI_BDF()
1056 * @offset: Register offset to update
1057 * @clr: Bits to clear
1059 * @return 0 if OK, -ve on error
1061 int pci_bus_clrset_config32(struct udevice *bus, pci_dev_t bdf, int offset,
1065 * Driver model PCI config access functions. Use these in preference to others
1066 * when you have a valid device
1068 int dm_pci_read_config(struct udevice *dev, int offset, unsigned long *valuep,
1069 enum pci_size_t size);
1071 int dm_pci_read_config8(struct udevice *dev, int offset, u8 *valuep);
1072 int dm_pci_read_config16(struct udevice *dev, int offset, u16 *valuep);
1073 int dm_pci_read_config32(struct udevice *dev, int offset, u32 *valuep);
1075 int dm_pci_write_config(struct udevice *dev, int offset, unsigned long value,
1076 enum pci_size_t size);
1078 int dm_pci_write_config8(struct udevice *dev, int offset, u8 value);
1079 int dm_pci_write_config16(struct udevice *dev, int offset, u16 value);
1080 int dm_pci_write_config32(struct udevice *dev, int offset, u32 value);
1083 * These permit convenient read/modify/write on PCI configuration. The
1084 * register is updated to (oldvalue & ~clr) | set.
1086 int dm_pci_clrset_config8(struct udevice *dev, int offset, u32 clr, u32 set);
1087 int dm_pci_clrset_config16(struct udevice *dev, int offset, u32 clr, u32 set);
1088 int dm_pci_clrset_config32(struct udevice *dev, int offset, u32 clr, u32 set);
1091 * The following functions provide access to the above without needing the
1092 * size parameter. We are trying to encourage the use of the 8/16/32-style
1093 * functions, rather than byte/word/dword. But both are supported.
1095 int pci_write_config32(pci_dev_t pcidev, int offset, u32 value);
1096 int pci_write_config16(pci_dev_t pcidev, int offset, u16 value);
1097 int pci_write_config8(pci_dev_t pcidev, int offset, u8 value);
1098 int pci_read_config32(pci_dev_t pcidev, int offset, u32 *valuep);
1099 int pci_read_config16(pci_dev_t pcidev, int offset, u16 *valuep);
1100 int pci_read_config8(pci_dev_t pcidev, int offset, u8 *valuep);
1103 * pci_generic_mmap_write_config() - Generic helper for writing to
1104 * memory-mapped PCI configuration space.
1105 * @bus: Pointer to the PCI bus
1106 * @addr_f: Callback for calculating the config space address
1107 * @bdf: Identifies the PCI device to access
1108 * @offset: The offset into the device's configuration space
1109 * @value: The value to write
1110 * @size: Indicates the size of access to perform
1112 * Write the value @value of size @size from offset @offset within the
1113 * configuration space of the device identified by the bus, device & function
1114 * numbers in @bdf on the PCI bus @bus. The callback function @addr_f is
1115 * responsible for calculating the CPU address of the respective configuration
1118 * Return: 0 on success, else -EINVAL
1120 int pci_generic_mmap_write_config(
1121 struct udevice *bus,
1122 int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp),
1126 enum pci_size_t size);
1129 * pci_generic_mmap_read_config() - Generic helper for reading from
1130 * memory-mapped PCI configuration space.
1131 * @bus: Pointer to the PCI bus
1132 * @addr_f: Callback for calculating the config space address
1133 * @bdf: Identifies the PCI device to access
1134 * @offset: The offset into the device's configuration space
1135 * @valuep: A pointer at which to store the read value
1136 * @size: Indicates the size of access to perform
1138 * Read a value of size @size from offset @offset within the configuration
1139 * space of the device identified by the bus, device & function numbers in @bdf
1140 * on the PCI bus @bus. The callback function @addr_f is responsible for
1141 * calculating the CPU address of the respective configuration space offset.
1143 * Return: 0 on success, else -EINVAL
1145 int pci_generic_mmap_read_config(
1146 struct udevice *bus,
1147 int (*addr_f)(struct udevice *bus, pci_dev_t bdf, uint offset, void **addrp),
1151 enum pci_size_t size);
1153 #ifdef CONFIG_DM_PCI_COMPAT
1154 /* Compatibility with old naming */
1155 static inline int pci_write_config_dword(pci_dev_t pcidev, int offset,
1158 return pci_write_config32(pcidev, offset, value);
1161 /* Compatibility with old naming */
1162 static inline int pci_write_config_word(pci_dev_t pcidev, int offset,
1165 return pci_write_config16(pcidev, offset, value);
1168 /* Compatibility with old naming */
1169 static inline int pci_write_config_byte(pci_dev_t pcidev, int offset,
1172 return pci_write_config8(pcidev, offset, value);
1175 /* Compatibility with old naming */
1176 static inline int pci_read_config_dword(pci_dev_t pcidev, int offset,
1179 return pci_read_config32(pcidev, offset, valuep);
1182 /* Compatibility with old naming */
1183 static inline int pci_read_config_word(pci_dev_t pcidev, int offset,
1186 return pci_read_config16(pcidev, offset, valuep);
1189 /* Compatibility with old naming */
1190 static inline int pci_read_config_byte(pci_dev_t pcidev, int offset,
1193 return pci_read_config8(pcidev, offset, valuep);
1195 #endif /* CONFIG_DM_PCI_COMPAT */
1198 * dm_pciauto_config_device() - configure a device ready for use
1200 * Space is allocated for each PCI base address register (BAR) so that the
1201 * devices are mapped into memory and I/O space ready for use.
1203 * @dev: Device to configure
1204 * @return 0 if OK, -ve on error
1206 int dm_pciauto_config_device(struct udevice *dev);
1209 * pci_conv_32_to_size() - convert a 32-bit read value to the given size
1211 * Some PCI buses must always perform 32-bit reads. The data must then be
1212 * shifted and masked to reflect the required access size and offset. This
1213 * function performs this transformation.
1215 * @value: Value to transform (32-bit value read from @offset & ~3)
1216 * @offset: Register offset that was read
1217 * @size: Required size of the result
1218 * @return the value that would have been obtained if the read had been
1219 * performed at the given offset with the correct size
1221 ulong pci_conv_32_to_size(ulong value, uint offset, enum pci_size_t size);
1224 * pci_conv_size_to_32() - update a 32-bit value to prepare for a write
1226 * Some PCI buses must always perform 32-bit writes. To emulate a smaller
1227 * write the old 32-bit data must be read, updated with the required new data
1228 * and written back as a 32-bit value. This function performs the
1229 * transformation from the old value to the new value.
1231 * @value: Value to transform (32-bit value read from @offset & ~3)
1232 * @offset: Register offset that should be written
1233 * @size: Required size of the write
1234 * @return the value that should be written as a 32-bit access to @offset & ~3.
1236 ulong pci_conv_size_to_32(ulong old, ulong value, uint offset,
1237 enum pci_size_t size);
1240 * pci_get_controller() - obtain the controller to use for a bus
1242 * @dev: Device to check
1243 * @return pointer to the controller device for this bus
1245 struct udevice *pci_get_controller(struct udevice *dev);
1248 * pci_get_regions() - obtain pointers to all the region types
1250 * @dev: Device to check
1251 * @iop: Returns a pointer to the I/O region, or NULL if none
1252 * @memp: Returns a pointer to the memory region, or NULL if none
1253 * @prefp: Returns a pointer to the pre-fetch region, or NULL if none
1254 * @return the number of non-NULL regions returned, normally 3
1256 int pci_get_regions(struct udevice *dev, struct pci_region **iop,
1257 struct pci_region **memp, struct pci_region **prefp);
1260 * dm_pci_write_bar32() - Write the address of a BAR
1262 * This writes a raw address to a bar
1264 * @dev: PCI device to update
1265 * @barnum: BAR number (0-5)
1266 * @addr: BAR address
1268 void dm_pci_write_bar32(struct udevice *dev, int barnum, u32 addr);
1271 * dm_pci_read_bar32() - read a base address register from a device
1273 * @dev: Device to check
1274 * @barnum: Bar number to read (numbered from 0)
1275 * @return: value of BAR
1277 u32 dm_pci_read_bar32(struct udevice *dev, int barnum);
1280 * dm_pci_bus_to_phys() - convert a PCI bus address to a physical address
1282 * @dev: Device containing the PCI address
1283 * @addr: PCI address to convert
1284 * @flags: Flags for the region type (PCI_REGION_...)
1285 * @return physical address corresponding to that PCI bus address
1287 phys_addr_t dm_pci_bus_to_phys(struct udevice *dev, pci_addr_t addr,
1288 unsigned long flags);
1291 * dm_pci_phys_to_bus() - convert a physical address to a PCI bus address
1293 * @dev: Device containing the bus address
1294 * @addr: Physical address to convert
1295 * @flags: Flags for the region type (PCI_REGION_...)
1296 * @return PCI bus address corresponding to that physical address
1298 pci_addr_t dm_pci_phys_to_bus(struct udevice *dev, phys_addr_t addr,
1299 unsigned long flags);
1302 * dm_pci_map_bar() - get a virtual address associated with a BAR region
1304 * Looks up a base address register and finds the physical memory address
1305 * that corresponds to it
1307 * @dev: Device to check
1308 * @bar: Bar number to read (numbered from 0)
1309 * @flags: Flags for the region type (PCI_REGION_...)
1310 * @return: pointer to the virtual address to use
1312 void *dm_pci_map_bar(struct udevice *dev, int bar, int flags);
1314 #define dm_pci_virt_to_bus(dev, addr, flags) \
1315 dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), (flags))
1316 #define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \
1317 map_physmem(dm_pci_bus_to_phys(dev, (addr), (flags)), \
1320 #define dm_pci_phys_to_mem(dev, addr) \
1321 dm_pci_phys_to_bus((dev), (addr), PCI_REGION_MEM)
1322 #define dm_pci_mem_to_phys(dev, addr) \
1323 dm_pci_bus_to_phys((dev), (addr), PCI_REGION_MEM)
1324 #define dm_pci_phys_to_io(dev, addr) \
1325 dm_pci_phys_to_bus((dev), (addr), PCI_REGION_IO)
1326 #define dm_pci_io_to_phys(dev, addr) \
1327 dm_pci_bus_to_phys((dev), (addr), PCI_REGION_IO)
1329 #define dm_pci_virt_to_mem(dev, addr) \
1330 dm_pci_virt_to_bus((dev), (addr), PCI_REGION_MEM)
1331 #define dm_pci_mem_to_virt(dev, addr, len, map_flags) \
1332 dm_pci_bus_to_virt((dev), (addr), PCI_REGION_MEM, (len), (map_flags))
1333 #define dm_pci_virt_to_io(dev, addr) \
1334 dm_pci_virt_to_bus((dev), (addr), PCI_REGION_IO)
1335 #define dm_pci_io_to_virt(dev, addr, len, map_flags) \
1336 dm_pci_bus_to_virt((dev), (addr), PCI_REGION_IO, (len), (map_flags))
1339 * dm_pci_find_device() - find a device by vendor/device ID
1341 * @vendor: Vendor ID
1342 * @device: Device ID
1343 * @index: 0 to find the first match, 1 for second, etc.
1344 * @devp: Returns pointer to the device, if found
1345 * @return 0 if found, -ve on error
1347 int dm_pci_find_device(unsigned int vendor, unsigned int device, int index,
1348 struct udevice **devp);
1351 * dm_pci_find_class() - find a device by class
1353 * @find_class: 3-byte (24-bit) class value to find
1354 * @index: 0 to find the first match, 1 for second, etc.
1355 * @devp: Returns pointer to the device, if found
1356 * @return 0 if found, -ve on error
1358 int dm_pci_find_class(uint find_class, int index, struct udevice **devp);
1361 * struct dm_pci_emul_ops - PCI device emulator operations
1363 struct dm_pci_emul_ops {
1365 * get_devfn(): Check which device and function this emulators
1367 * @dev: device to check
1368 * @return the device and function this emulates, or -ve on error
1370 int (*get_devfn)(struct udevice *dev);
1372 * read_config() - Read a PCI configuration value
1374 * @dev: Emulated device to read from
1375 * @offset: Byte offset within the device's configuration space
1376 * @valuep: Place to put the returned value
1377 * @size: Access size
1378 * @return 0 if OK, -ve on error
1380 int (*read_config)(struct udevice *dev, uint offset, ulong *valuep,
1381 enum pci_size_t size);
1383 * write_config() - Write a PCI configuration value
1385 * @dev: Emulated device to write to
1386 * @offset: Byte offset within the device's configuration space
1387 * @value: Value to write
1388 * @size: Access size
1389 * @return 0 if OK, -ve on error
1391 int (*write_config)(struct udevice *dev, uint offset, ulong value,
1392 enum pci_size_t size);
1394 * read_io() - Read a PCI I/O value
1396 * @dev: Emulated device to read from
1397 * @addr: I/O address to read
1398 * @valuep: Place to put the returned value
1399 * @size: Access size
1400 * @return 0 if OK, -ENOENT if @addr is not mapped by this device,
1401 * other -ve value on error
1403 int (*read_io)(struct udevice *dev, unsigned int addr, ulong *valuep,
1404 enum pci_size_t size);
1406 * write_io() - Write a PCI I/O value
1408 * @dev: Emulated device to write from
1409 * @addr: I/O address to write
1410 * @value: Value to write
1411 * @size: Access size
1412 * @return 0 if OK, -ENOENT if @addr is not mapped by this device,
1413 * other -ve value on error
1415 int (*write_io)(struct udevice *dev, unsigned int addr,
1416 ulong value, enum pci_size_t size);
1418 * map_physmem() - Map a device into sandbox memory
1420 * @dev: Emulated device to map
1421 * @addr: Memory address, normally corresponding to a PCI BAR.
1422 * The device should have been configured to have a BAR
1424 * @lenp: On entry, the size of the area to map, On exit it is
1425 * updated to the size actually mapped, which may be less
1426 * if the device has less space
1427 * @ptrp: Returns a pointer to the mapped address. The device's
1428 * space can be accessed as @lenp bytes starting here
1429 * @return 0 if OK, -ENOENT if @addr is not mapped by this device,
1430 * other -ve value on error
1432 int (*map_physmem)(struct udevice *dev, phys_addr_t addr,
1433 unsigned long *lenp, void **ptrp);
1435 * unmap_physmem() - undo a memory mapping
1437 * This must be called after map_physmem() to undo the mapping.
1438 * Some devices can use this to check what has been written into
1439 * their mapped memory and perform an operations they require on it.
1440 * In this way, map/unmap can be used as a sort of handshake between
1441 * the emulated device and its users.
1443 * @dev: Emuated device to unmap
1444 * @vaddr: Mapped memory address, as passed to map_physmem()
1445 * @len: Size of area mapped, as returned by map_physmem()
1446 * @return 0 if OK, -ve on error
1448 int (*unmap_physmem)(struct udevice *dev, const void *vaddr,
1452 /* Get access to a PCI device emulator's operations */
1453 #define pci_get_emul_ops(dev) ((struct dm_pci_emul_ops *)(dev)->driver->ops)
1456 * sandbox_pci_get_emul() - Get the emulation device for a PCI device
1458 * Searches for a suitable emulator for the given PCI bus device
1460 * @bus: PCI bus to search
1461 * @find_devfn: PCI device and function address (PCI_DEVFN())
1462 * @containerp: Returns container device if found
1463 * @emulp: Returns emulated device if found
1464 * @return 0 if found, -ENODEV if not found
1466 int sandbox_pci_get_emul(struct udevice *bus, pci_dev_t find_devfn,
1467 struct udevice **containerp, struct udevice **emulp);
1469 #endif /* CONFIG_DM_PCI */
1472 * PCI_DEVICE - macro used to describe a specific pci device
1473 * @vend: the 16 bit PCI Vendor ID
1474 * @dev: the 16 bit PCI Device ID
1476 * This macro is used to create a struct pci_device_id that matches a
1477 * specific device. The subvendor and subdevice fields will be set to
1480 #define PCI_DEVICE(vend, dev) \
1481 .vendor = (vend), .device = (dev), \
1482 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
1485 * PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem
1486 * @vend: the 16 bit PCI Vendor ID
1487 * @dev: the 16 bit PCI Device ID
1488 * @subvend: the 16 bit PCI Subvendor ID
1489 * @subdev: the 16 bit PCI Subdevice ID
1491 * This macro is used to create a struct pci_device_id that matches a
1492 * specific device with subsystem information.
1494 #define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \
1495 .vendor = (vend), .device = (dev), \
1496 .subvendor = (subvend), .subdevice = (subdev)
1499 * PCI_DEVICE_CLASS - macro used to describe a specific pci device class
1500 * @dev_class: the class, subclass, prog-if triple for this device
1501 * @dev_class_mask: the class mask for this device
1503 * This macro is used to create a struct pci_device_id that matches a
1504 * specific PCI class. The vendor, device, subvendor, and subdevice
1505 * fields will be set to PCI_ANY_ID.
1507 #define PCI_DEVICE_CLASS(dev_class, dev_class_mask) \
1508 .class = (dev_class), .class_mask = (dev_class_mask), \
1509 .vendor = PCI_ANY_ID, .device = PCI_ANY_ID, \
1510 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID
1513 * PCI_VDEVICE - macro used to describe a specific pci device in short form
1514 * @vend: the vendor name
1515 * @dev: the 16 bit PCI Device ID
1517 * This macro is used to create a struct pci_device_id that matches a
1518 * specific PCI device. The subvendor, and subdevice fields will be set
1519 * to PCI_ANY_ID. The macro allows the next field to follow as the device
1523 #define PCI_VDEVICE(vend, dev) \
1524 .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
1525 .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
1528 * struct pci_driver_entry - Matches a driver to its pci_device_id list
1529 * @driver: Driver to use
1530 * @match: List of match records for this driver, terminated by {}
1532 struct pci_driver_entry {
1533 struct driver *driver;
1534 const struct pci_device_id *match;
1537 #define U_BOOT_PCI_DEVICE(__name, __match) \
1538 ll_entry_declare(struct pci_driver_entry, __name, pci_driver_entry) = {\
1539 .driver = llsym(struct driver, __name, driver), \
1543 #endif /* __ASSEMBLY__ */