1 /* $NetBSD: pcireg.h,v 1.39 2002/09/21 16:16:31 drochner Exp $ */ 2 3 /* 4 * Copyright (c) 1995, 1996, 1999, 2000 5 * Christopher G. Demetriou. All rights reserved. 6 * Copyright (c) 1994, 1996 Charles M. Hannum. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by Charles M. Hannum. 19 * 4. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #ifndef _DEV_PCI_PCIREG_H_ 35 #define _DEV_PCI_PCIREG_H_ 36 37 /* 38 * Standardized PCI configuration information 39 * 40 * XXX This is not complete. 41 */ 42 43 /* 44 * Device identification register; contains a vendor ID and a device ID. 45 */ 46 #define PCI_ID_REG 0x00 47 48 typedef u_int16_t pci_vendor_id_t; 49 typedef u_int16_t pci_product_id_t; 50 51 #define PCI_VENDOR_SHIFT 0 52 #define PCI_VENDOR_MASK 0xffff 53 #define PCI_VENDOR(id) \ 54 (((id) >> PCI_VENDOR_SHIFT) & PCI_VENDOR_MASK) 55 56 #define PCI_PRODUCT_SHIFT 16 57 #define PCI_PRODUCT_MASK 0xffff 58 #define PCI_PRODUCT(id) \ 59 (((id) >> PCI_PRODUCT_SHIFT) & PCI_PRODUCT_MASK) 60 61 #define PCI_ID_CODE(vid,pid) \ 62 ((((vid) & PCI_VENDOR_MASK) << PCI_VENDOR_SHIFT) | \ 63 (((pid) & PCI_PRODUCT_MASK) << PCI_PRODUCT_SHIFT)) \ 64 65 /* 66 * Command and status register. 67 */ 68 #define PCI_COMMAND_STATUS_REG 0x04 69 #define PCI_COMMAND_SHIFT 0 70 #define PCI_COMMAND_MASK 0xffff 71 #define PCI_STATUS_SHIFT 16 72 #define PCI_STATUS_MASK 0xffff 73 74 #define PCI_COMMAND_STATUS_CODE(cmd,stat) \ 75 ((((cmd) & PCI_COMMAND_MASK) >> PCI_COMMAND_SHIFT) | \ 76 (((stat) & PCI_STATUS_MASK) >> PCI_STATUS_SHIFT)) \ 77 78 #define PCI_COMMAND_IO_ENABLE 0x00000001 79 #define PCI_COMMAND_MEM_ENABLE 0x00000002 80 #define PCI_COMMAND_MASTER_ENABLE 0x00000004 81 #define PCI_COMMAND_SPECIAL_ENABLE 0x00000008 82 #define PCI_COMMAND_INVALIDATE_ENABLE 0x00000010 83 #define PCI_COMMAND_PALETTE_ENABLE 0x00000020 84 #define PCI_COMMAND_PARITY_ENABLE 0x00000040 85 #define PCI_COMMAND_STEPPING_ENABLE 0x00000080 86 #define PCI_COMMAND_SERR_ENABLE 0x00000100 87 #define PCI_COMMAND_BACKTOBACK_ENABLE 0x00000200 88 89 #define PCI_STATUS_CAPLIST_SUPPORT 0x00100000 90 #define PCI_STATUS_66MHZ_SUPPORT 0x00200000 91 #define PCI_STATUS_UDF_SUPPORT 0x00400000 92 #define PCI_STATUS_BACKTOBACK_SUPPORT 0x00800000 93 #define PCI_STATUS_PARITY_ERROR 0x01000000 94 #define PCI_STATUS_DEVSEL_FAST 0x00000000 95 #define PCI_STATUS_DEVSEL_MEDIUM 0x02000000 96 #define PCI_STATUS_DEVSEL_SLOW 0x04000000 97 #define PCI_STATUS_DEVSEL_MASK 0x06000000 98 #define PCI_STATUS_TARGET_TARGET_ABORT 0x08000000 99 #define PCI_STATUS_MASTER_TARGET_ABORT 0x10000000 100 #define PCI_STATUS_MASTER_ABORT 0x20000000 101 #define PCI_STATUS_SPECIAL_ERROR 0x40000000 102 #define PCI_STATUS_PARITY_DETECT 0x80000000 103 104 /* 105 * PCI Class and Revision Register; defines type and revision of device. 106 */ 107 #define PCI_CLASS_REG 0x08 108 109 typedef u_int8_t pci_class_t; 110 typedef u_int8_t pci_subclass_t; 111 typedef u_int8_t pci_interface_t; 112 typedef u_int8_t pci_revision_t; 113 114 #define PCI_CLASS_SHIFT 24 115 #define PCI_CLASS_MASK 0xff 116 #define PCI_CLASS(cr) \ 117 (((cr) >> PCI_CLASS_SHIFT) & PCI_CLASS_MASK) 118 119 #define PCI_SUBCLASS_SHIFT 16 120 #define PCI_SUBCLASS_MASK 0xff 121 #define PCI_SUBCLASS(cr) \ 122 (((cr) >> PCI_SUBCLASS_SHIFT) & PCI_SUBCLASS_MASK) 123 124 #define PCI_INTERFACE_SHIFT 8 125 #define PCI_INTERFACE_MASK 0xff 126 #define PCI_INTERFACE(cr) \ 127 (((cr) >> PCI_INTERFACE_SHIFT) & PCI_INTERFACE_MASK) 128 129 #define PCI_REVISION_SHIFT 0 130 #define PCI_REVISION_MASK 0xff 131 #define PCI_REVISION(cr) \ 132 (((cr) >> PCI_REVISION_SHIFT) & PCI_REVISION_MASK) 133 134 #define PCI_CLASS_CODE(mainclass, subclass, interface) \ 135 ((((mainclass) & PCI_CLASS_MASK) << PCI_CLASS_SHIFT) | \ 136 (((subclass) & PCI_SUBCLASS_MASK) << PCI_SUBCLASS_SHIFT) | \ 137 (((interface) & PCI_INTERFACE_MASK) << PCI_INTERFACE_SHIFT)) 138 139 /* base classes */ 140 #define PCI_CLASS_PREHISTORIC 0x00 141 #define PCI_CLASS_MASS_STORAGE 0x01 142 #define PCI_CLASS_NETWORK 0x02 143 #define PCI_CLASS_DISPLAY 0x03 144 #define PCI_CLASS_MULTIMEDIA 0x04 145 #define PCI_CLASS_MEMORY 0x05 146 #define PCI_CLASS_BRIDGE 0x06 147 #define PCI_CLASS_COMMUNICATIONS 0x07 148 #define PCI_CLASS_SYSTEM 0x08 149 #define PCI_CLASS_INPUT 0x09 150 #define PCI_CLASS_DOCK 0x0a 151 #define PCI_CLASS_PROCESSOR 0x0b 152 #define PCI_CLASS_SERIALBUS 0x0c 153 #define PCI_CLASS_WIRELESS 0x0d 154 #define PCI_CLASS_I2O 0x0e 155 #define PCI_CLASS_SATCOM 0x0f 156 #define PCI_CLASS_CRYPTO 0x10 157 #define PCI_CLASS_DASP 0x11 158 #define PCI_CLASS_UNDEFINED 0xff 159 160 /* 0x00 prehistoric subclasses */ 161 #define PCI_SUBCLASS_PREHISTORIC_MISC 0x00 162 #define PCI_SUBCLASS_PREHISTORIC_VGA 0x01 163 164 /* 0x01 mass storage subclasses */ 165 #define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00 166 #define PCI_SUBCLASS_MASS_STORAGE_IDE 0x01 167 #define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x02 168 #define PCI_SUBCLASS_MASS_STORAGE_IPI 0x03 169 #define PCI_SUBCLASS_MASS_STORAGE_RAID 0x04 170 #define PCI_SUBCLASS_MASS_STORAGE_ATA 0x05 171 #define PCI_SUBCLASS_MASS_STORAGE_SATA 0x06 172 #define PCI_SUBCLASS_MASS_STORAGE_MISC 0x80 173 174 /* 0x02 network subclasses */ 175 #define PCI_SUBCLASS_NETWORK_ETHERNET 0x00 176 #define PCI_SUBCLASS_NETWORK_TOKENRING 0x01 177 #define PCI_SUBCLASS_NETWORK_FDDI 0x02 178 #define PCI_SUBCLASS_NETWORK_ATM 0x03 179 #define PCI_SUBCLASS_NETWORK_ISDN 0x04 180 #define PCI_SUBCLASS_NETWORK_WORLDFIP 0x05 181 #define PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP 0x06 182 #define PCI_SUBCLASS_NETWORK_MISC 0x80 183 184 /* 0x03 display subclasses */ 185 #define PCI_SUBCLASS_DISPLAY_VGA 0x00 186 #define PCI_SUBCLASS_DISPLAY_XGA 0x01 187 #define PCI_SUBCLASS_DISPLAY_3D 0x02 188 #define PCI_SUBCLASS_DISPLAY_MISC 0x80 189 190 /* 0x04 multimedia subclasses */ 191 #define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00 192 #define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01 193 #define PCI_SUBCLASS_MULTIMEDIA_TELEPHONY 0x02 194 #define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80 195 196 /* 0x05 memory subclasses */ 197 #define PCI_SUBCLASS_MEMORY_RAM 0x00 198 #define PCI_SUBCLASS_MEMORY_FLASH 0x01 199 #define PCI_SUBCLASS_MEMORY_MISC 0x80 200 201 /* 0x06 bridge subclasses */ 202 #define PCI_SUBCLASS_BRIDGE_HOST 0x00 203 #define PCI_SUBCLASS_BRIDGE_ISA 0x01 204 #define PCI_SUBCLASS_BRIDGE_EISA 0x02 205 #define PCI_SUBCLASS_BRIDGE_MC 0x03 /* XXX _MCA? */ 206 #define PCI_SUBCLASS_BRIDGE_PCI 0x04 207 #define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05 208 #define PCI_SUBCLASS_BRIDGE_NUBUS 0x06 209 #define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07 210 #define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08 211 #define PCI_SUBCLASS_BRIDGE_STPCI 0x09 212 #define PCI_SUBCLASS_BRIDGE_INFINIBAND 0x0a 213 #define PCI_SUBCLASS_BRIDGE_MISC 0x80 214 215 /* 0x07 communications subclasses */ 216 #define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00 217 #define PCI_SUBCLASS_COMMUNICATIONS_PARALLEL 0x01 218 #define PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL 0x02 219 #define PCI_SUBCLASS_COMMUNICATIONS_MODEM 0x03 220 #define PCI_SUBCLASS_COMMUNICATIONS_GPIB 0x04 221 #define PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD 0x05 222 #define PCI_SUBCLASS_COMMUNICATIONS_MISC 0x80 223 224 /* 0x08 system subclasses */ 225 #define PCI_SUBCLASS_SYSTEM_PIC 0x00 226 #define PCI_SUBCLASS_SYSTEM_DMA 0x01 227 #define PCI_SUBCLASS_SYSTEM_TIMER 0x02 228 #define PCI_SUBCLASS_SYSTEM_RTC 0x03 229 #define PCI_SUBCLASS_SYSTEM_PCIHOTPLUG 0x04 230 #define PCI_SUBCLASS_SYSTEM_MISC 0x80 231 232 /* 0x09 input subclasses */ 233 #define PCI_SUBCLASS_INPUT_KEYBOARD 0x00 234 #define PCI_SUBCLASS_INPUT_DIGITIZER 0x01 235 #define PCI_SUBCLASS_INPUT_MOUSE 0x02 236 #define PCI_SUBCLASS_INPUT_SCANNER 0x03 237 #define PCI_SUBCLASS_INPUT_GAMEPORT 0x04 238 #define PCI_SUBCLASS_INPUT_MISC 0x80 239 240 /* 0x0a dock subclasses */ 241 #define PCI_SUBCLASS_DOCK_GENERIC 0x00 242 #define PCI_SUBCLASS_DOCK_MISC 0x80 243 244 /* 0x0b processor subclasses */ 245 #define PCI_SUBCLASS_PROCESSOR_386 0x00 246 #define PCI_SUBCLASS_PROCESSOR_486 0x01 247 #define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02 248 #define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10 249 #define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20 250 #define PCI_SUBCLASS_PROCESSOR_MIPS 0x30 251 #define PCI_SUBCLASS_PROCESSOR_COPROC 0x40 252 253 /* 0x0c serial bus subclasses */ 254 #define PCI_SUBCLASS_SERIALBUS_FIREWIRE 0x00 255 #define PCI_SUBCLASS_SERIALBUS_ACCESS 0x01 256 #define PCI_SUBCLASS_SERIALBUS_SSA 0x02 257 #define PCI_SUBCLASS_SERIALBUS_USB 0x03 258 #define PCI_SUBCLASS_SERIALBUS_FIBER 0x04 /* XXX _FIBRECHANNEL */ 259 #define PCI_SUBCLASS_SERIALBUS_SMBUS 0x05 260 #define PCI_SUBCLASS_SERIALBUS_INFINIBAND 0x06 261 #define PCI_SUBCLASS_SERIALBUS_IPMI 0x07 262 #define PCI_SUBCLASS_SERIALBUS_SERCOS 0x08 263 #define PCI_SUBCLASS_SERIALBUS_CANBUS 0x09 264 265 /* 0x0d wireless subclasses */ 266 #define PCI_SUBCLASS_WIRELESS_IRDA 0x00 267 #define PCI_SUBCLASS_WIRELESS_CONSUMERIR 0x01 268 #define PCI_SUBCLASS_WIRELESS_RF 0x10 269 #define PCI_SUBCLASS_WIRELESS_BLUETOOTH 0x11 270 #define PCI_SUBCLASS_WIRELESS_BROADBAND 0x12 271 #define PCI_SUBCLASS_WIRELESS_802_11A 0x20 272 #define PCI_SUBCLASS_WIRELESS_802_11B 0x21 273 #define PCI_SUBCLASS_WIRELESS_MISC 0x80 274 275 /* 0x0e I2O (Intelligent I/O) subclasses */ 276 #define PCI_SUBCLASS_I2O_STANDARD 0x00 277 278 /* 0x0f satellite communication subclasses */ 279 /* PCI_SUBCLASS_SATCOM_??? 0x00 / * XXX ??? */ 280 #define PCI_SUBCLASS_SATCOM_TV 0x01 281 #define PCI_SUBCLASS_SATCOM_AUDIO 0x02 282 #define PCI_SUBCLASS_SATCOM_VOICE 0x03 283 #define PCI_SUBCLASS_SATCOM_DATA 0x04 284 285 /* 0x10 encryption/decryption subclasses */ 286 #define PCI_SUBCLASS_CRYPTO_NETCOMP 0x00 287 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10 288 #define PCI_SUBCLASS_CRYPTO_MISC 0x80 289 290 /* 0x11 data acquisition and signal processing subclasses */ 291 #define PCI_SUBCLASS_DASP_DPIO 0x00 292 #define PCI_SUBCLASS_DASP_TIMEFREQ 0x01 293 #define PCI_SUBCLASS_DASP_SYNC 0x10 294 #define PCI_SUBCLASS_DASP_MGMT 0x20 295 #define PCI_SUBCLASS_DASP_MISC 0x80 296 297 /* 298 * PCI BIST/Header Type/Latency Timer/Cache Line Size Register. 299 */ 300 #define PCI_BHLC_REG 0x0c 301 302 #define PCI_BIST_SHIFT 24 303 #define PCI_BIST_MASK 0xff 304 #define PCI_BIST(bhlcr) \ 305 (((bhlcr) >> PCI_BIST_SHIFT) & PCI_BIST_MASK) 306 307 #define PCI_HDRTYPE_SHIFT 16 308 #define PCI_HDRTYPE_MASK 0xff 309 #define PCI_HDRTYPE(bhlcr) \ 310 (((bhlcr) >> PCI_HDRTYPE_SHIFT) & PCI_HDRTYPE_MASK) 311 312 #define PCI_HDRTYPE_TYPE(bhlcr) \ 313 (PCI_HDRTYPE(bhlcr) & 0x7f) 314 #define PCI_HDRTYPE_MULTIFN(bhlcr) \ 315 ((PCI_HDRTYPE(bhlcr) & 0x80) != 0) 316 317 #define PCI_LATTIMER_SHIFT 8 318 #define PCI_LATTIMER_MASK 0xff 319 #define PCI_LATTIMER(bhlcr) \ 320 (((bhlcr) >> PCI_LATTIMER_SHIFT) & PCI_LATTIMER_MASK) 321 322 #define PCI_CACHELINE_SHIFT 0 323 #define PCI_CACHELINE_MASK 0xff 324 #define PCI_CACHELINE(bhlcr) \ 325 (((bhlcr) >> PCI_CACHELINE_SHIFT) & PCI_CACHELINE_MASK) 326 327 #define PCI_BHLC_CODE(bist,type,multi,latency,cacheline) \ 328 ((((bist) & PCI_BIST_MASK) << PCI_BIST_SHIFT) | \ 329 (((type) & PCI_HDRTYPE_MASK) << PCI_HDRTYPE_SHIFT) | \ 330 (((multi)?0x80:0) << PCI_HDRTYPE_SHIFT) | \ 331 (((latency) & PCI_LATTIMER_MASK) << PCI_LATTIMER_SHIFT) | \ 332 (((cacheline) & PCI_CACHELINE_MASK) << PCI_CACHELINE_SHIFT)) 333 334 /* 335 * Mapping registers 336 */ 337 #define PCI_MAPREG_START 0x10 338 #define PCI_MAPREG_END 0x28 339 #define PCI_MAPREG_ROM 0x30 340 #define PCI_MAPREG_PPB_END 0x18 341 #define PCI_MAPREG_PCB_END 0x14 342 343 #define PCI_MAPREG_TYPE(mr) \ 344 ((mr) & PCI_MAPREG_TYPE_MASK) 345 #define PCI_MAPREG_TYPE_MASK 0x00000001 346 347 #define PCI_MAPREG_TYPE_MEM 0x00000000 348 #define PCI_MAPREG_TYPE_IO 0x00000001 349 #define PCI_MAPREG_ROM_ENABLE 0x00000001 350 351 #define PCI_MAPREG_MEM_TYPE(mr) \ 352 ((mr) & PCI_MAPREG_MEM_TYPE_MASK) 353 #define PCI_MAPREG_MEM_TYPE_MASK 0x00000006 354 355 #define PCI_MAPREG_MEM_TYPE_32BIT 0x00000000 356 #define PCI_MAPREG_MEM_TYPE_32BIT_1M 0x00000002 357 #define PCI_MAPREG_MEM_TYPE_64BIT 0x00000004 358 359 #define PCI_MAPREG_MEM_PREFETCHABLE(mr) \ 360 (((mr) & PCI_MAPREG_MEM_PREFETCHABLE_MASK) != 0) 361 #define PCI_MAPREG_MEM_PREFETCHABLE_MASK 0x00000008 362 363 #define PCI_MAPREG_MEM_ADDR(mr) \ 364 ((mr) & PCI_MAPREG_MEM_ADDR_MASK) 365 #define PCI_MAPREG_MEM_SIZE(mr) \ 366 (PCI_MAPREG_MEM_ADDR(mr) & -PCI_MAPREG_MEM_ADDR(mr)) 367 #define PCI_MAPREG_MEM_ADDR_MASK 0xfffffff0 368 369 #define PCI_MAPREG_MEM64_ADDR(mr) \ 370 ((mr) & PCI_MAPREG_MEM64_ADDR_MASK) 371 #define PCI_MAPREG_MEM64_SIZE(mr) \ 372 (PCI_MAPREG_MEM64_ADDR(mr) & -PCI_MAPREG_MEM64_ADDR(mr)) 373 #define PCI_MAPREG_MEM64_ADDR_MASK 0xfffffffffffffff0ULL 374 375 #define PCI_MAPREG_IO_ADDR(mr) \ 376 ((mr) & PCI_MAPREG_IO_ADDR_MASK) 377 #define PCI_MAPREG_IO_SIZE(mr) \ 378 (PCI_MAPREG_IO_ADDR(mr) & -PCI_MAPREG_IO_ADDR(mr)) 379 #define PCI_MAPREG_IO_ADDR_MASK 0xfffffffc 380 381 #define PCI_MAPREG_SIZE_TO_MASK(size) \ 382 (-(size)) 383 384 #define PCI_MAPREG_NUM(offset) \ 385 (((unsigned)(offset)-PCI_MAPREG_START)/4) 386 387 388 /* 389 * Cardbus CIS pointer (PCI rev. 2.1) 390 */ 391 #define PCI_CARDBUS_CIS_REG 0x28 392 393 /* 394 * Subsystem identification register; contains a vendor ID and a device ID. 395 * Types/macros for PCI_ID_REG apply. 396 * (PCI rev. 2.1) 397 */ 398 #define PCI_SUBSYS_ID_REG 0x2c 399 400 /* 401 * capabilities link list (PCI rev. 2.2) 402 */ 403 #define PCI_CAPLISTPTR_REG 0x34 /* header type 0 */ 404 #define PCI_CARDBUS_CAPLISTPTR_REG 0x14 /* header type 2 */ 405 #define PCI_CAPLIST_PTR(cpr) ((cpr) & 0xff) 406 #define PCI_CAPLIST_NEXT(cr) (((cr) >> 8) & 0xff) 407 #define PCI_CAPLIST_CAP(cr) ((cr) & 0xff) 408 409 #define PCI_CAP_RESERVED0 0x00 410 #define PCI_CAP_PWRMGMT 0x01 411 #define PCI_CAP_AGP 0x02 412 #define PCI_CAP_VPD 0x03 413 #define PCI_CAP_SLOTID 0x04 414 #define PCI_CAP_MSI 0x05 415 #define PCI_CAP_CPCI_HOTSWAP 0x06 416 #define PCI_CAP_PCIX 0x07 417 #define PCI_CAP_LDT 0x08 418 #define PCI_CAP_VENDSPEC 0x09 419 #define PCI_CAP_DEBUGPORT 0x0a 420 #define PCI_CAP_CPCI_RSRCCTL 0x0b 421 #define PCI_CAP_HOTPLUG 0x0c 422 #define PCI_CAP_AGP8 0x0e 423 #define PCI_CAP_SECURE 0x0f 424 #define PCI_CAP_PCIEXPRESS 0x10 425 #define PCI_CAP_MSIX 0x11 426 427 /* 428 * Power Management Capability; access via capability pointer. 429 */ 430 431 /* Power Management Capability Register */ 432 #define PCI_PMCR 0x02 433 #define PCI_PMCR_D1SUPP 0x0200 434 #define PCI_PMCR_D2SUPP 0x0400 435 /* Power Management Control Status Register */ 436 #define PCI_PMCSR 0x04 437 #define PCI_PMCSR_STATE_MASK 0x03 438 #define PCI_PMCSR_STATE_D0 0x00 439 #define PCI_PMCSR_STATE_D1 0x01 440 #define PCI_PMCSR_STATE_D2 0x02 441 #define PCI_PMCSR_STATE_D3 0x03 442 443 /* 444 * Interrupt Configuration Register; contains interrupt pin and line. 445 */ 446 #define PCI_INTERRUPT_REG 0x3c 447 448 typedef u_int8_t pci_intr_latency_t; 449 typedef u_int8_t pci_intr_grant_t; 450 typedef u_int8_t pci_intr_pin_t; 451 typedef u_int8_t pci_intr_line_t; 452 453 #define PCI_MAX_LAT_SHIFT 24 454 #define PCI_MAX_LAT_MASK 0xff 455 #define PCI_MAX_LAT(icr) \ 456 (((icr) >> PCI_MAX_LAT_SHIFT) & PCI_MAX_LAT_MASK) 457 458 #define PCI_MIN_GNT_SHIFT 16 459 #define PCI_MIN_GNT_MASK 0xff 460 #define PCI_MIN_GNT(icr) \ 461 (((icr) >> PCI_MIN_GNT_SHIFT) & PCI_MIN_GNT_MASK) 462 463 #define PCI_INTERRUPT_GRANT_SHIFT 24 464 #define PCI_INTERRUPT_GRANT_MASK 0xff 465 #define PCI_INTERRUPT_GRANT(icr) \ 466 (((icr) >> PCI_INTERRUPT_GRANT_SHIFT) & PCI_INTERRUPT_GRANT_MASK) 467 468 #define PCI_INTERRUPT_LATENCY_SHIFT 16 469 #define PCI_INTERRUPT_LATENCY_MASK 0xff 470 #define PCI_INTERRUPT_LATENCY(icr) \ 471 (((icr) >> PCI_INTERRUPT_LATENCY_SHIFT) & PCI_INTERRUPT_LATENCY_MASK) 472 473 #define PCI_INTERRUPT_PIN_SHIFT 8 474 #define PCI_INTERRUPT_PIN_MASK 0xff 475 #define PCI_INTERRUPT_PIN(icr) \ 476 (((icr) >> PCI_INTERRUPT_PIN_SHIFT) & PCI_INTERRUPT_PIN_MASK) 477 478 #define PCI_INTERRUPT_LINE_SHIFT 0 479 #define PCI_INTERRUPT_LINE_MASK 0xff 480 #define PCI_INTERRUPT_LINE(icr) \ 481 (((icr) >> PCI_INTERRUPT_LINE_SHIFT) & PCI_INTERRUPT_LINE_MASK) 482 483 #define PCI_INTERRUPT_CODE(lat,gnt,pin,line) \ 484 ((((lat)&PCI_INTERRUPT_LATENCY_MASK)<<PCI_INTERRUPT_LATENCY_SHIFT)| \ 485 (((gnt)&PCI_INTERRUPT_GRANT_MASK) <<PCI_INTERRUPT_GRANT_SHIFT) | \ 486 (((pin)&PCI_INTERRUPT_PIN_MASK) <<PCI_INTERRUPT_PIN_SHIFT) | \ 487 (((line)&PCI_INTERRUPT_LINE_MASK) <<PCI_INTERRUPT_LINE_SHIFT)) 488 489 #define PCI_INTERRUPT_PIN_NONE 0x00 490 #define PCI_INTERRUPT_PIN_A 0x01 491 #define PCI_INTERRUPT_PIN_B 0x02 492 #define PCI_INTERRUPT_PIN_C 0x03 493 #define PCI_INTERRUPT_PIN_D 0x04 494 #define PCI_INTERRUPT_PIN_MAX 0x04 495 496 /* Header Type 1 (Bridge) configuration registers */ 497 #define PCI_BRIDGE_BUS_REG 0x18 498 #define PCI_BRIDGE_BUS_PRIMARY_SHIFT 0 499 #define PCI_BRIDGE_BUS_SECONDARY_SHIFT 8 500 #define PCI_BRIDGE_BUS_SUBORDINATE_SHIFT 16 501 502 #define PCI_BRIDGE_STATIO_REG 0x1C 503 #define PCI_BRIDGE_STATIO_IOBASE_SHIFT 0 504 #define PCI_BRIDGE_STATIO_IOLIMIT_SHIFT 8 505 #define PCI_BRIDGE_STATIO_STATUS_SHIFT 16 506 #define PCI_BRIDGE_STATIO_IOBASE_MASK 0xf0 507 #define PCI_BRIDGE_STATIO_IOLIMIT_MASK 0xf0 508 #define PCI_BRIDGE_STATIO_STATUS_MASK 0xffff 509 #define PCI_BRIDGE_IO_32BITS(reg) (((reg) & 0xf) == 1) 510 511 #define PCI_BRIDGE_MEMORY_REG 0x20 512 #define PCI_BRIDGE_MEMORY_BASE_SHIFT 4 513 #define PCI_BRIDGE_MEMORY_LIMIT_SHIFT 20 514 #define PCI_BRIDGE_MEMORY_BASE_MASK 0xffff 515 #define PCI_BRIDGE_MEMORY_LIMIT_MASK 0xffff 516 517 #define PCI_BRIDGE_PREFETCHMEM_REG 0x24 518 #define PCI_BRIDGE_PREFETCHMEM_BASE_SHIFT 4 519 #define PCI_BRIDGE_PREFETCHMEM_LIMIT_SHIFT 20 520 #define PCI_BRIDGE_PREFETCHMEM_BASE_MASK 0xffff 521 #define PCI_BRIDGE_PREFETCHMEM_LIMIT_MASK 0xffff 522 #define PCI_BRIDGE_PREFETCHMEM_64BITS(reg) ((reg) & 0xf) 523 524 #define PCI_BRIDGE_PREFETCHBASE32_REG 0x28 525 #define PCI_BRIDGE_PREFETCHLIMIT32_REG 0x2C 526 527 #define PCI_BRIDGE_IOHIGH_REG 0x30 528 #define PCI_BRIDGE_IOHIGH_BASE_SHIFT 0 529 #define PCI_BRIDGE_IOHIGH_LIMIT_SHIFT 16 530 #define PCI_BRIDGE_IOHIGH_BASE_MASK 0xffff 531 #define PCI_BRIDGE_IOHIGH_LIMIT_MASK 0xffff 532 533 #define PCI_BRIDGE_CONTROL_REG 0x3C 534 #define PCI_BRIDGE_CONTROL_SHIFT 16 535 #define PCI_BRIDGE_CONTROL_MASK 0xffff 536 #define PCI_BRIDGE_CONTROL_PERE (1 << 0) 537 #define PCI_BRIDGE_CONTROL_SERR (1 << 1) 538 #define PCI_BRIDGE_CONTROL_ISA (1 << 2) 539 #define PCI_BRIDGE_CONTROL_VGA (1 << 3) 540 /* Reserved (1 << 4) */ 541 #define PCI_BRIDGE_CONTROL_MABRT (1 << 5) 542 #define PCI_BRIDGE_CONTROL_SECBR (1 << 6) 543 #define PCI_BRIDGE_CONTROL_SECFASTB2B (1 << 7) 544 #define PCI_BRIDGE_CONTROL_PRI_DISC_TIMER (1 << 8) 545 #define PCI_BRIDGE_CONTROL_SEC_DISC_TIMER (1 << 9) 546 #define PCI_BRIDGE_CONTROL_DISC_TIMER_STAT (1 << 10) 547 #define PCI_BRIDGE_CONTROL_DISC_TIMER_SERR (1 << 11) 548 /* Reserved (1 << 12) - (1 << 15) */ 549 550 /* 551 * Vital Product Data resource tags. 552 */ 553 struct pci_vpd_smallres { 554 uint8_t vpdres_byte0; /* length of data + tag */ 555 /* Actual data. */ 556 } __attribute__((__packed__)); 557 558 struct pci_vpd_largeres { 559 uint8_t vpdres_byte0; 560 uint8_t vpdres_len_lsb; /* length of data only */ 561 uint8_t vpdres_len_msb; 562 /* Actual data. */ 563 } __attribute__((__packed__)); 564 565 #define PCI_VPDRES_ISLARGE(x) ((x) & 0x80) 566 567 #define PCI_VPDRES_SMALL_LENGTH(x) ((x) & 0x7) 568 #define PCI_VPDRES_SMALL_NAME(x) (((x) >> 3) & 0xf) 569 570 #define PCI_VPDRES_LARGE_NAME(x) ((x) & 0x7f) 571 572 #define PCI_VPDRES_TYPE_COMPATIBLE_DEVICE_ID 0x3 /* small */ 573 #define PCI_VPDRES_TYPE_VENDOR_DEFINED 0xe /* small */ 574 #define PCI_VPDRES_TYPE_END_TAG 0xf /* small */ 575 576 #define PCI_VPDRES_TYPE_IDENTIFIER_STRING 0x02 /* large */ 577 #define PCI_VPDRES_TYPE_VPD 0x10 /* large */ 578 579 struct pci_vpd { 580 uint8_t vpd_key0; 581 uint8_t vpd_key1; 582 uint8_t vpd_len; /* length of data only */ 583 /* Actual data. */ 584 } __attribute__((__packed__)); 585 586 /* 587 * Recommended VPD fields: 588 * 589 * PN Part number of assembly 590 * FN FRU part number 591 * EC EC level of assembly 592 * MN Manufacture ID 593 * SN Serial Number 594 * 595 * Conditionally recommended VPD fields: 596 * 597 * LI Load ID 598 * RL ROM Level 599 * RM Alterable ROM Level 600 * NA Network Address 601 * DD Device Driver Level 602 * DG Diagnostic Level 603 * LL Loadable Microcode Level 604 * VI Vendor ID/Device ID 605 * FU Function Number 606 * SI Subsystem Vendor ID/Subsystem ID 607 * 608 * Additional VPD fields: 609 * 610 * Z0-ZZ User/Product Specific 611 */ 612 613 #endif /* _DEV_PCI_PCIREG_H_ */ 614