xref: /onnv-gate/usr/src/uts/common/sys/pci.h (revision 6313)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51865Sdilpreet  * Common Development and Distribution License (the "License").
61865Sdilpreet  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*6313Skrishnae  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_PCI_H
270Sstevel@tonic-gate #define	_SYS_PCI_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * PCI Configuration Header offsets
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate #define	PCI_CONF_VENID		0x0	/* vendor id, 2 bytes */
390Sstevel@tonic-gate #define	PCI_CONF_DEVID		0x2	/* device id, 2 bytes */
400Sstevel@tonic-gate #define	PCI_CONF_COMM		0x4	/* command register, 2 bytes */
410Sstevel@tonic-gate #define	PCI_CONF_STAT		0x6	/* status register, 2 bytes */
420Sstevel@tonic-gate #define	PCI_CONF_REVID		0x8	/* revision id, 1 byte */
430Sstevel@tonic-gate #define	PCI_CONF_PROGCLASS	0x9	/* programming class code, 1 byte */
440Sstevel@tonic-gate #define	PCI_CONF_SUBCLASS	0xA	/* sub-class code, 1 byte */
450Sstevel@tonic-gate #define	PCI_CONF_BASCLASS	0xB	/* basic class code, 1 byte */
460Sstevel@tonic-gate #define	PCI_CONF_CACHE_LINESZ	0xC	/* cache line size, 1 byte */
470Sstevel@tonic-gate #define	PCI_CONF_LATENCY_TIMER	0xD	/* latency timer, 1 byte */
480Sstevel@tonic-gate #define	PCI_CONF_HEADER		0xE	/* header type, 1 byte */
490Sstevel@tonic-gate #define	PCI_CONF_BIST		0xF	/* builtin self test, 1 byte */
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * Header type 0 offsets
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate #define	PCI_CONF_BASE0		0x10	/* base register 0, 4 bytes */
550Sstevel@tonic-gate #define	PCI_CONF_BASE1		0x14	/* base register 1, 4 bytes */
560Sstevel@tonic-gate #define	PCI_CONF_BASE2		0x18	/* base register 2, 4 bytes */
570Sstevel@tonic-gate #define	PCI_CONF_BASE3		0x1c	/* base register 3, 4 bytes */
580Sstevel@tonic-gate #define	PCI_CONF_BASE4		0x20	/* base register 4, 4 bytes */
590Sstevel@tonic-gate #define	PCI_CONF_BASE5		0x24	/* base register 5, 4 bytes */
600Sstevel@tonic-gate #define	PCI_CONF_CIS		0x28	/* Cardbus CIS Pointer */
610Sstevel@tonic-gate #define	PCI_CONF_SUBVENID	0x2c	/* Subsystem Vendor ID */
620Sstevel@tonic-gate #define	PCI_CONF_SUBSYSID	0x2e	/* Subsystem ID */
630Sstevel@tonic-gate #define	PCI_CONF_ROM		0x30	/* ROM base register, 4 bytes */
640Sstevel@tonic-gate #define	PCI_CONF_CAP_PTR	0x34	/* capabilities pointer, 1 byte */
650Sstevel@tonic-gate #define	PCI_CONF_ILINE		0x3c	/* interrupt line, 1 byte */
660Sstevel@tonic-gate #define	PCI_CONF_IPIN		0x3d	/* interrupt pin, 1 byte */
670Sstevel@tonic-gate #define	PCI_CONF_MIN_G		0x3e	/* minimum grant, 1 byte */
680Sstevel@tonic-gate #define	PCI_CONF_MAX_L		0x3f	/* maximum grant, 1 byte */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  * PCI to PCI bridge configuration space header format
720Sstevel@tonic-gate  */
730Sstevel@tonic-gate #define	PCI_BCNF_PRIBUS		0x18	/* primary bus number */
740Sstevel@tonic-gate #define	PCI_BCNF_SECBUS		0x19	/* secondary bus number */
750Sstevel@tonic-gate #define	PCI_BCNF_SUBBUS		0x1a	/* subordinate bus number */
760Sstevel@tonic-gate #define	PCI_BCNF_LATENCY_TIMER	0x1b
770Sstevel@tonic-gate #define	PCI_BCNF_IO_BASE_LOW	0x1c
780Sstevel@tonic-gate #define	PCI_BCNF_IO_LIMIT_LOW	0x1d
790Sstevel@tonic-gate #define	PCI_BCNF_SEC_STATUS	0x1e
800Sstevel@tonic-gate #define	PCI_BCNF_MEM_BASE	0x20
810Sstevel@tonic-gate #define	PCI_BCNF_MEM_LIMIT	0x22
820Sstevel@tonic-gate #define	PCI_BCNF_PF_BASE_LOW	0x24
830Sstevel@tonic-gate #define	PCI_BCNF_PF_LIMIT_LOW	0x26
840Sstevel@tonic-gate #define	PCI_BCNF_PF_BASE_HIGH	0x28
850Sstevel@tonic-gate #define	PCI_BCNF_PF_LIMIT_HIGH	0x2c
860Sstevel@tonic-gate #define	PCI_BCNF_IO_BASE_HI	0x30
870Sstevel@tonic-gate #define	PCI_BCNF_IO_LIMIT_HI	0x32
880Sstevel@tonic-gate #define	PCI_BCNF_CAP_PTR	0x34
890Sstevel@tonic-gate #define	PCI_BCNF_ROM		0x38
900Sstevel@tonic-gate #define	PCI_BCNF_ILINE		0x3c
910Sstevel@tonic-gate #define	PCI_BCNF_IPIN		0x3d
920Sstevel@tonic-gate #define	PCI_BCNF_BCNTRL		0x3e
930Sstevel@tonic-gate 
940Sstevel@tonic-gate #define	PCI_BCNF_BASE_NUM	0x2
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /*
970Sstevel@tonic-gate  * PCI to PCI bridge control register (0x3e) format
980Sstevel@tonic-gate  */
990Sstevel@tonic-gate #define	PCI_BCNF_BCNTRL_PARITY_ENABLE	0x1
1000Sstevel@tonic-gate #define	PCI_BCNF_BCNTRL_SERR_ENABLE	0x2
101*6313Skrishnae #define	PCI_BCNF_BCNTRL_ISA_ENABLE	0x4
1023499Srugrat #define	PCI_BCNF_BCNTRL_VGA_ENABLE	0x8
1030Sstevel@tonic-gate #define	PCI_BCNF_BCNTRL_MAST_AB_MODE	0x20
1040Sstevel@tonic-gate #define	PCI_BCNF_BCNTRL_DTO_STAT	0x400
1050Sstevel@tonic-gate 
1062284Srw148561 #define	PCI_BCNF_BCNTRL_RESET		0x0040
1072284Srw148561 #define	PCI_BCNF_BCNTRL_B2B_ENAB	0x0080
1082284Srw148561 
1090Sstevel@tonic-gate #define	PCI_BCNF_IO_MASK	0xf0
1100Sstevel@tonic-gate #define	PCI_BCNF_MEM_MASK	0xfff0
1110Sstevel@tonic-gate 
1120Sstevel@tonic-gate /*
1130Sstevel@tonic-gate  * Header type 2 (Cardbus) offsets
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate #define	PCI_CBUS_SOCK_REG	0x10	/* Cardbus socket regs, 4 bytes */
1160Sstevel@tonic-gate #define	PCI_CBUS_RESERVED1	0x14	/* Reserved, 2 bytes */
1170Sstevel@tonic-gate #define	PCI_CBUS_SEC_STATUS	0x16	/* Secondary status, 2 bytes */
1180Sstevel@tonic-gate #define	PCI_CBUS_PCI_BUS_NO	0x18	/* PCI bus number, 1 byte */
1190Sstevel@tonic-gate #define	PCI_CBUS_CBUS_NO	0x19	/* Cardbus bus number, 1 byte */
1200Sstevel@tonic-gate #define	PCI_CBUS_SUB_BUS_NO	0x1a	/* Subordinate bus number, 1 byte */
1210Sstevel@tonic-gate #define	PCI_CBUS_LATENCY_TIMER	0x1b	/* Cardbus latency timer, 1 byte */
1220Sstevel@tonic-gate #define	PCI_CBUS_MEM_BASE0	0x1c	/* Memory base reg 0, 4 bytes */
1230Sstevel@tonic-gate #define	PCI_CBUS_MEM_LIMIT0	0x20	/* Memory limit reg 0, 4 bytes */
1240Sstevel@tonic-gate #define	PCI_CBUS_MEM_BASE1	0x24	/* Memory base reg 1, 4 bytes */
1250Sstevel@tonic-gate #define	PCI_CBUS_MEM_LIMIT1	0x28	/* Memory limit reg 1, 4 bytes */
1260Sstevel@tonic-gate #define	PCI_CBUS_IO_BASE0	0x2c	/* IO base reg 0, 4 bytes */
1270Sstevel@tonic-gate #define	PCI_CBUS_IO_LIMIT0	0x30	/* IO limit reg 0, 4 bytes */
1280Sstevel@tonic-gate #define	PCI_CBUS_IO_BASE1	0x34	/* IO base reg 1, 4 bytes */
1290Sstevel@tonic-gate #define	PCI_CBUS_IO_LIMIT1	0x38	/* IO limit reg 1, 4 bytes */
1300Sstevel@tonic-gate #define	PCI_CBUS_ILINE		0x3c	/* interrupt line, 1 byte */
1310Sstevel@tonic-gate #define	PCI_CBUS_IPIN		0x3d	/* interrupt pin, 1 byte */
1320Sstevel@tonic-gate #define	PCI_CBUS_BRIDGE_CTRL	0x3e	/* Bridge control, 2 bytes */
1330Sstevel@tonic-gate #define	PCI_CBUS_SUBVENID	0x40	/* Subsystem Vendor ID, 2 bytes */
1340Sstevel@tonic-gate #define	PCI_CBUS_SUBSYSID	0x42	/* Subsystem ID, 2 bytes */
1350Sstevel@tonic-gate #define	PCI_CBUS_LEG_MODE_ADDR	0x44	/* PCCard 16bit IF legacy mode addr */
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate #define	PCI_CBUS_BASE_NUM	0x1	/* number of base registers */
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate /*
1400Sstevel@tonic-gate  * PCI command register bits
1410Sstevel@tonic-gate  */
1420Sstevel@tonic-gate #define	PCI_COMM_IO		0x1	/* I/O access enable */
1430Sstevel@tonic-gate #define	PCI_COMM_MAE		0x2	/* memory access enable */
1440Sstevel@tonic-gate #define	PCI_COMM_ME		0x4	/* master enable */
1450Sstevel@tonic-gate #define	PCI_COMM_SPEC_CYC	0x8
1460Sstevel@tonic-gate #define	PCI_COMM_MEMWR_INVAL	0x10
1470Sstevel@tonic-gate #define	PCI_COMM_PALETTE_SNOOP	0x20
1480Sstevel@tonic-gate #define	PCI_COMM_PARITY_DETECT	0x40
1490Sstevel@tonic-gate #define	PCI_COMM_WAIT_CYC_ENAB	0x80
1500Sstevel@tonic-gate #define	PCI_COMM_SERR_ENABLE	0x100
1510Sstevel@tonic-gate #define	PCI_COMM_BACK2BACK_ENAB	0x200
1520Sstevel@tonic-gate #define	PCI_COMM_INTX_DISABLE	0x400	/* INTx emulation disable */
1530Sstevel@tonic-gate 
1540Sstevel@tonic-gate /*
1550Sstevel@tonic-gate  * PCI Interrupt pin value
1560Sstevel@tonic-gate  */
1570Sstevel@tonic-gate #define	PCI_INTA	1
1580Sstevel@tonic-gate #define	PCI_INTB	2
1590Sstevel@tonic-gate #define	PCI_INTC	3
1600Sstevel@tonic-gate #define	PCI_INTD	4
1610Sstevel@tonic-gate 
1620Sstevel@tonic-gate /*
1630Sstevel@tonic-gate  * PCI status register bits
1640Sstevel@tonic-gate  */
1650Sstevel@tonic-gate #define	PCI_STAT_INTR		0x8	/* Interrupt state */
1660Sstevel@tonic-gate #define	PCI_STAT_CAP		0x10	/* Implements Capabilities */
1670Sstevel@tonic-gate #define	PCI_STAT_66MHZ		0x20	/* 66 MHz capable */
1680Sstevel@tonic-gate #define	PCI_STAT_UDF		0x40	/* UDF supported */
1690Sstevel@tonic-gate #define	PCI_STAT_FBBC		0x80	/* Fast Back-to-Back Capable */
1700Sstevel@tonic-gate #define	PCI_STAT_S_PERROR	0x100	/* Data Parity Reported */
1710Sstevel@tonic-gate #define	PCI_STAT_DEVSELT	0x600	/* Device select timing */
1720Sstevel@tonic-gate #define	PCI_STAT_S_TARG_AB	0x800	/* Signaled Target Abort */
1730Sstevel@tonic-gate #define	PCI_STAT_R_TARG_AB	0x1000	/* Received Target Abort */
1740Sstevel@tonic-gate #define	PCI_STAT_R_MAST_AB	0x2000	/* Received Master Abort */
1750Sstevel@tonic-gate #define	PCI_STAT_S_SYSERR	0x4000	/* Signaled System Error */
1760Sstevel@tonic-gate #define	PCI_STAT_PERROR		0x8000	/* Detected Parity Error */
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /*
1790Sstevel@tonic-gate  * DEVSEL timing values
1800Sstevel@tonic-gate  */
1810Sstevel@tonic-gate #define	PCI_STAT_DEVSELT_FAST	0x0000
1820Sstevel@tonic-gate #define	PCI_STAT_DEVSELT_MEDIUM	0x0200
1830Sstevel@tonic-gate #define	PCI_STAT_DEVSELT_SLOW	0x0400
1840Sstevel@tonic-gate 
1850Sstevel@tonic-gate /*
1860Sstevel@tonic-gate  * BIST values
1870Sstevel@tonic-gate  */
1880Sstevel@tonic-gate #define	PCI_BIST_SUPPORTED	0x80
1890Sstevel@tonic-gate #define	PCI_BIST_GO		0x40
1900Sstevel@tonic-gate #define	PCI_BIST_RESULT_M	0x0f
1910Sstevel@tonic-gate #define	PCI_BIST_RESULT_OK	0x00
1920Sstevel@tonic-gate 
1930Sstevel@tonic-gate /*
1940Sstevel@tonic-gate  * PCI class codes
1950Sstevel@tonic-gate  */
1960Sstevel@tonic-gate #define	PCI_CLASS_NONE		0x0	/* class code for pre-2.0 devices */
1970Sstevel@tonic-gate #define	PCI_CLASS_MASS		0x1	/* Mass storage Controller class */
1980Sstevel@tonic-gate #define	PCI_CLASS_NET		0x2	/* Network Controller class */
1990Sstevel@tonic-gate #define	PCI_CLASS_DISPLAY	0x3	/* Display Controller class */
2000Sstevel@tonic-gate #define	PCI_CLASS_MM		0x4	/* Multimedia Controller class */
2010Sstevel@tonic-gate #define	PCI_CLASS_MEM		0x5	/* Memory Controller class */
2020Sstevel@tonic-gate #define	PCI_CLASS_BRIDGE	0x6	/* Bridge Controller class */
2030Sstevel@tonic-gate #define	PCI_CLASS_COMM		0x7	/* Communications Controller class */
2040Sstevel@tonic-gate #define	PCI_CLASS_PERIPH	0x8	/* Peripheral Controller class */
2050Sstevel@tonic-gate #define	PCI_CLASS_INPUT		0x9	/* Input Device class */
2060Sstevel@tonic-gate #define	PCI_CLASS_DOCK		0xa	/* Docking Station class */
2070Sstevel@tonic-gate #define	PCI_CLASS_PROCESSOR	0xb	/* Processor class */
2080Sstevel@tonic-gate #define	PCI_CLASS_SERIALBUS	0xc	/* Serial Bus class */
2090Sstevel@tonic-gate #define	PCI_CLASS_WIRELESS	0xd	/* Wireless Controller class */
2100Sstevel@tonic-gate #define	PCI_CLASS_INTIO		0xe	/* Intelligent IO Controller class */
2110Sstevel@tonic-gate #define	PCI_CLASS_SATELLITE	0xf	/* Satellite Communication class */
2120Sstevel@tonic-gate #define	PCI_CLASS_CRYPT		0x10	/* Encrytion/Decryption class */
2130Sstevel@tonic-gate #define	PCI_CLASS_SIGNAL	0x11	/* Signal Processing class */
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate /*
2160Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x0 (no new devices should use this code).
2170Sstevel@tonic-gate  */
2180Sstevel@tonic-gate #define	PCI_NONE_NOTVGA		0x0	/* All devices except VGA compatible */
2190Sstevel@tonic-gate #define	PCI_NONE_VGA		0x1	/* VGA compatible */
2200Sstevel@tonic-gate 
2210Sstevel@tonic-gate /*
2220Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x1 (mass storage controllers)
2230Sstevel@tonic-gate  */
2240Sstevel@tonic-gate #define	PCI_MASS_SCSI		0x0	/* SCSI bus Controller */
2250Sstevel@tonic-gate #define	PCI_MASS_IDE		0x1	/* IDE Controller */
2263070Sanish #define	PCI_MASS_FD		0x2	/* Floppy disk Controller */
2270Sstevel@tonic-gate #define	PCI_MASS_IPI		0x3	/* IPI bus Controller */
2280Sstevel@tonic-gate #define	PCI_MASS_RAID		0x4	/* RAID Controller */
2290Sstevel@tonic-gate #define	PCI_MASS_ATA		0x5	/* ATA Controller */
2300Sstevel@tonic-gate #define	PCI_MASS_SATA		0x6	/* Serial ATA */
2313070Sanish #define	PCI_MASS_SAS		0x7	/* Serial Attached SCSI (SAS) Cntrlr */
2320Sstevel@tonic-gate #define	PCI_MASS_OTHER		0x80	/* Other Mass Storage Controller */
2330Sstevel@tonic-gate 
2340Sstevel@tonic-gate /*
2350Sstevel@tonic-gate  * programming interface for IDE (subclass 1)
2360Sstevel@tonic-gate  */
2370Sstevel@tonic-gate #define	PCI_IDE_IF_NATIVE_PRI	0x1	/* primary channel is native */
2380Sstevel@tonic-gate #define	PCI_IDE_IF_PROG_PRI	0x2	/* primary can operate in either mode */
2390Sstevel@tonic-gate #define	PCI_IDE_IF_NATIVE_SEC	0x4	/* secondary channel is native */
2400Sstevel@tonic-gate #define	PCI_IDE_IF_PROG_SEC	0x8	/* sec. can operate in either mode */
2410Sstevel@tonic-gate #define	PCI_IDE_IF_MASK		0xf	/* programming interface mask */
2420Sstevel@tonic-gate 
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate /*
2450Sstevel@tonic-gate  * programming interface for ATA (subclass 5)
2460Sstevel@tonic-gate  */
2470Sstevel@tonic-gate #define	PCI_ATA_IF_SINGLE_DMA	0x20	/* ATA controller with single DMA */
2480Sstevel@tonic-gate #define	PCI_ATA_IF_CHAINED_DMA	0x30	/* ATA controller with chained DMA */
2490Sstevel@tonic-gate 
2500Sstevel@tonic-gate /*
2513070Sanish  * programming interface for ATA (subclass 6) for SATA
2523070Sanish  */
2533070Sanish #define	PCI_SATA_VS_INTERFACE	0x0	/* SATA Ctlr Vendor Specific Intfc */
2543070Sanish #define	PCI_SATA_AHCI_INTERFACE	0x1	/* SATA Ctlr AHCI 1.0 Interface */
2553070Sanish #define	PCI_SATA_SSB_INTERFACE	0x2	/* Serial Storage Bus Interface */
2563070Sanish 
2573070Sanish /*
2583070Sanish  * programming interface for ATA (subclass 7) for SAS
2593070Sanish  */
2603070Sanish #define	PCI_SAS_CONTROLLER	0x0	/* SAS Controller */
2613070Sanish #define	PCI_SAS_BUS_INTERFACE	0x1	/* Serial Storage Bus Interface */
2623070Sanish 
2633070Sanish /*
2640Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x2 (Network controllers)
2650Sstevel@tonic-gate  */
2660Sstevel@tonic-gate #define	PCI_NET_ENET		0x0	/* Ethernet Controller */
2670Sstevel@tonic-gate #define	PCI_NET_TOKEN		0x1	/* Token Ring Controller */
2680Sstevel@tonic-gate #define	PCI_NET_FDDI		0x2	/* FDDI Controller */
2690Sstevel@tonic-gate #define	PCI_NET_ATM		0x3	/* ATM Controller */
2700Sstevel@tonic-gate #define	PCI_NET_ISDN		0x4	/* ISDN Controller */
2710Sstevel@tonic-gate #define	PCI_NET_WFIP		0x5	/* WorldFip Controller */
2720Sstevel@tonic-gate #define	PCI_NET_PICMG		0x6	/* PICMG 2.14 Multi Computing */
2730Sstevel@tonic-gate #define	PCI_NET_OTHER		0x80	/* Other Network Controller */
2740Sstevel@tonic-gate 
2750Sstevel@tonic-gate /*
2760Sstevel@tonic-gate  * PCI Sub-class codes - base class 03 (display controllers)
2770Sstevel@tonic-gate  */
2780Sstevel@tonic-gate #define	PCI_DISPLAY_VGA		0x0	/* VGA device */
2790Sstevel@tonic-gate #define	PCI_DISPLAY_XGA		0x1	/* XGA device */
2800Sstevel@tonic-gate #define	PCI_DISPLAY_3D		0x2	/* 3D controller */
2810Sstevel@tonic-gate #define	PCI_DISPLAY_OTHER	0x80	/* Other Display Device */
2820Sstevel@tonic-gate 
2830Sstevel@tonic-gate /*
2840Sstevel@tonic-gate  * programming interface for display for display class (subclass 0) VGA ctrlrs
2850Sstevel@tonic-gate  */
2860Sstevel@tonic-gate #define	PCI_DISPLAY_IF_VGA	0x0	/* VGA compatible */
2870Sstevel@tonic-gate #define	PCI_DISPLAY_IF_8514	0x1	/* 8514 compatible */
2880Sstevel@tonic-gate 
2890Sstevel@tonic-gate /*
2900Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x4 (multi-media devices)
2910Sstevel@tonic-gate  */
2920Sstevel@tonic-gate #define	PCI_MM_VIDEO		0x0	/* Video device */
2930Sstevel@tonic-gate #define	PCI_MM_AUDIO		0x1	/* Audio device */
2940Sstevel@tonic-gate #define	PCI_MM_TELEPHONY	0x2	/* Computer Telephony device */
2953070Sanish #define	PCI_MM_MIXED_MODE	0x3	/* Mixed Mode device */
2960Sstevel@tonic-gate #define	PCI_MM_OTHER		0x80	/* Other Multimedia Device */
2970Sstevel@tonic-gate 
2980Sstevel@tonic-gate /*
2990Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x5 (memory controllers)
3000Sstevel@tonic-gate  */
3010Sstevel@tonic-gate #define	PCI_MEM_RAM		0x0	/* RAM device */
3020Sstevel@tonic-gate #define	PCI_MEM_FLASH		0x1	/* FLASH device */
3030Sstevel@tonic-gate #define	PCI_MEM_OTHER		0x80	/* Other Memory Controller */
3040Sstevel@tonic-gate 
3050Sstevel@tonic-gate /*
3060Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x6 (Bridge devices)
3070Sstevel@tonic-gate  */
3080Sstevel@tonic-gate #define	PCI_BRIDGE_HOST		0x0	/* Host/PCI Bridge */
3090Sstevel@tonic-gate #define	PCI_BRIDGE_ISA		0x1	/* PCI/ISA Bridge */
3100Sstevel@tonic-gate #define	PCI_BRIDGE_EISA		0x2	/* PCI/EISA Bridge */
3110Sstevel@tonic-gate #define	PCI_BRIDGE_MC		0x3	/* PCI/MC Bridge */
3120Sstevel@tonic-gate #define	PCI_BRIDGE_PCI		0x4	/* PCI/PCI Bridge */
3130Sstevel@tonic-gate #define	PCI_BRIDGE_PCMCIA	0x5	/* PCI/PCMCIA Bridge */
3140Sstevel@tonic-gate #define	PCI_BRIDGE_NUBUS	0x6	/* PCI/NUBUS Bridge */
3150Sstevel@tonic-gate #define	PCI_BRIDGE_CARDBUS	0x7	/* PCI/CARDBUS Bridge */
3160Sstevel@tonic-gate #define	PCI_BRIDGE_RACE		0x8	/* RACE-way Bridge */
3170Sstevel@tonic-gate #define	PCI_BRIDGE_STPCI	0x9	/* Semi-transparent PCI/PCI Bridge */
3180Sstevel@tonic-gate #define	PCI_BRIDGE_IB		0xA	/* InfiniBand/PCI host Bridge */
3193070Sanish #define	PCI_BRIDGE_AS		0xB	/* AS/PCI host Bridge */
3200Sstevel@tonic-gate #define	PCI_BRIDGE_OTHER	0x80	/* PCI/Other Bridge Device */
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate /*
3230Sstevel@tonic-gate  * programming interface for Bridges class 0x6 (subclass 4) PCI-PCI bridge
3240Sstevel@tonic-gate  */
3250Sstevel@tonic-gate #define	PCI_BRIDGE_PCI_IF_PCI2PCI	0x0	/* PCI-PCI bridge */
3260Sstevel@tonic-gate #define	PCI_BRIDGE_PCI_IF_SUBDECODE	0x1	/* Subtractive Decode */
3270Sstevel@tonic-gate 						/* PCI/PCI bridge */
3280Sstevel@tonic-gate 
3290Sstevel@tonic-gate /*
3300Sstevel@tonic-gate  * programming interface for Bridges class 0x6 (subclass 08) RACEway bridge
3310Sstevel@tonic-gate  */
3320Sstevel@tonic-gate #define	PCI_BRIDGE_RACE_IF_TRANSPARENT	0x0	/* Transport mode */
3330Sstevel@tonic-gate #define	PCI_BRIDGE_RACE_IF_ENDPOINT	0x1	/* Endpoint mode */
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate /*
3360Sstevel@tonic-gate  * programming interface for Bridges class 0x6 (subclass 09)
3370Sstevel@tonic-gate  * Semi-transparent PCI-to-PCI bridge
3380Sstevel@tonic-gate  */
3390Sstevel@tonic-gate #define	PCI_BRIDGE_STPCI_IF_PRIMARY	0x40	/* primary PCI side bus */
3400Sstevel@tonic-gate 						/* facing system processor */
3410Sstevel@tonic-gate #define	PCI_BRIDGE_STPCI_IF_SECONDARY	0x80	/* secondary PCI side bus */
3420Sstevel@tonic-gate 						/* facing system processor */
3430Sstevel@tonic-gate 
3440Sstevel@tonic-gate /*
3453070Sanish  * programming interface for Bridges class 0x6 (subclass 0B) AS bridge
3463070Sanish  */
3473070Sanish #define	PCI_BRIDGE_AS_CUSTOM_INTFC	0x0	/* Custom interface */
3483070Sanish #define	PCI_BRIDGE_AS_PORTAL_INTFC	0x1	/* ASI-SIG Portal Interface */
3493070Sanish 
3503070Sanish /*
3510Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x7 (communication devices)
3520Sstevel@tonic-gate  */
3530Sstevel@tonic-gate #define	PCI_COMM_GENERIC_XT	0x0	/* XT Compatible Serial Controller */
3540Sstevel@tonic-gate #define	PCI_COMM_PARALLEL	0x1	/* Parallel Port Controller */
3550Sstevel@tonic-gate #define	PCI_COMM_MSC		0x2	/* Multiport Serial Controller */
3560Sstevel@tonic-gate #define	PCI_COMM_MODEM		0x3	/* Modem Controller */
3570Sstevel@tonic-gate #define	PCI_COMM_GPIB		0x4	/* GPIB Controller */
3580Sstevel@tonic-gate #define	PCI_COMM_SMARTCARD	0x5	/* Smart Card Controller */
3590Sstevel@tonic-gate #define	PCI_COMM_OTHER		0x80	/* Other Communications Controller */
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate /*
3620Sstevel@tonic-gate  * Programming interfaces for class 0x7 / subclass 0x0 (Serial)
3630Sstevel@tonic-gate  */
3640Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_GENERIC	0x0	/* Generic XT-compat serial */
3650Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_16450	0x1	/* 16450-compat serial ctrlr */
3660Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_16550	0x2	/* 16550-compat serial ctrlr */
3670Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_16650	0x3	/* 16650-compat serial ctrlr */
3680Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_16750	0x4	/* 16750-compat serial ctrlr */
3690Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_16850	0x5	/* 16850-compat serial ctrlr */
3700Sstevel@tonic-gate #define	PCI_COMM_SERIAL_IF_16950	0x6	/* 16950-compat serial ctrlr */
3710Sstevel@tonic-gate 
3720Sstevel@tonic-gate /*
3730Sstevel@tonic-gate  * Programming interfaces for class 0x7 / subclass 0x1 (Parallel)
3740Sstevel@tonic-gate  */
3750Sstevel@tonic-gate #define	PCI_COMM_PARALLEL_IF_GENERIC	0x0	/* Generic Parallel port */
3760Sstevel@tonic-gate #define	PCI_COMM_PARALLEL_IF_BIDIRECT	0x1	/* Bi-directional Parallel */
3770Sstevel@tonic-gate #define	PCI_COMM_PARALLEL_IF_ECP	0x2	/* ECP 1.X Parallel port */
3780Sstevel@tonic-gate #define	PCI_COMM_PARALLEL_IF_1284	0x3	/* IEEE 1284 Parallel port */
3790Sstevel@tonic-gate #define	PCI_COMM_PARALLEL_IF_1284_TARG	0xFE	/* IEEE 1284 target device */
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate /*
3820Sstevel@tonic-gate  * Programming interfaces for class 0x7 / subclass 0x3 (Modem)
3830Sstevel@tonic-gate  */
3840Sstevel@tonic-gate #define	PCI_COMM_MODEM_IF_GENERIC	0x0	/* Generic Modem */
3850Sstevel@tonic-gate #define	PCI_COMM_MODEM_IF_HAYES_16450	0x1	/* Hayes 16450-compat Modem */
3860Sstevel@tonic-gate #define	PCI_COMM_MODEM_IF_HAYES_16550	0x2	/* Hayes 16550-compat Modem */
3870Sstevel@tonic-gate #define	PCI_COMM_MODEM_IF_HAYES_16650	0x3	/* Hayes 16650-compat Modem */
3880Sstevel@tonic-gate #define	PCI_COMM_MODEM_IF_HAYES_16750	0x4	/* Hayes 16750-compat Modem */
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate /*
3910Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x8
3920Sstevel@tonic-gate  */
3930Sstevel@tonic-gate #define	PCI_PERIPH_PIC		0x0	/* Generic PIC */
3940Sstevel@tonic-gate #define	PCI_PERIPH_DMA		0x1	/* Generic DMA Controller */
3950Sstevel@tonic-gate #define	PCI_PERIPH_TIMER	0x2	/* Generic System Timer Controller */
3960Sstevel@tonic-gate #define	PCI_PERIPH_RTC		0x3	/* Generic RTC Controller */
3973070Sanish #define	PCI_PERIPH_HPC		0x4	/* Generic PCI Hot-Plug Controller */
3983070Sanish #define	PCI_PERIPH_SD_HC	0x5	/* SD Host Controller */
3993070Sanish #define	PCI_PERIPH_IOMMU	0x6	/* IOMMU */
4000Sstevel@tonic-gate #define	PCI_PERIPH_OTHER	0x80	/* Other System Peripheral */
4010Sstevel@tonic-gate 
4020Sstevel@tonic-gate /*
4030Sstevel@tonic-gate  * Programming interfaces for class 0x8 / subclass 0x0 (interrupt controller)
4040Sstevel@tonic-gate  */
4050Sstevel@tonic-gate #define	PCI_PERIPH_PIC_IF_GENERIC	0x0	/* Generic 8259 APIC */
4060Sstevel@tonic-gate #define	PCI_PERIPH_PIC_IF_ISA		0x1	/* ISA PIC */
4070Sstevel@tonic-gate #define	PCI_PERIPH_PIC_IF_EISA		0x2	/* EISA PIC */
4080Sstevel@tonic-gate #define	PCI_PERIPH_PIC_IF_IO_APIC	0x10	/* I/O APIC interrupt ctrlr */
4090Sstevel@tonic-gate #define	PCI_PERIPH_PIC_IF_IOX_APIC	0x20	/* I/O(x) APIC intr ctrlr */
4100Sstevel@tonic-gate 
4110Sstevel@tonic-gate /*
4120Sstevel@tonic-gate  * Programming interfaces for class 0x8 / subclass 0x1 (DMA controller)
4130Sstevel@tonic-gate  */
4140Sstevel@tonic-gate #define	PCI_PERIPH_DMA_IF_GENERIC	0x0	/* Generic 8237 DMA ctrlr */
4150Sstevel@tonic-gate #define	PCI_PERIPH_DMA_IF_ISA		0x1	/* ISA DMA ctrlr */
4160Sstevel@tonic-gate #define	PCI_PERIPH_DMA_IF_EISA		0x2	/* EISA DMA ctrlr */
4170Sstevel@tonic-gate 
4180Sstevel@tonic-gate /*
4190Sstevel@tonic-gate  * Programming interfaces for class 0x8 / subclass 0x2 (timer)
4200Sstevel@tonic-gate  */
4210Sstevel@tonic-gate #define	PCI_PERIPH_TIMER_IF_GENERIC	0x0	/* Generic 8254 system timer */
4220Sstevel@tonic-gate #define	PCI_PERIPH_TIMER_IF_ISA		0x1	/* ISA system timers */
4230Sstevel@tonic-gate #define	PCI_PERIPH_TIMER_IF_EISA	0x2	/* EISA system timers (two) */
4243070Sanish #define	PCI_PERIPH_TIMER_IF_HPET	0x3	/* High Perf Event timer */
4250Sstevel@tonic-gate 
4260Sstevel@tonic-gate /*
4270Sstevel@tonic-gate  * Programming interfaces for class 0x8 / subclass 0x3 (realtime clock)
4280Sstevel@tonic-gate  */
4290Sstevel@tonic-gate #define	PCI_PERIPH_RTC_IF_GENERIC	0x0	/* Generic RTC controller */
4300Sstevel@tonic-gate #define	PCI_PERIPH_RTC_IF_ISA		0x1	/* ISA RTC controller */
4310Sstevel@tonic-gate 
4320Sstevel@tonic-gate /*
4330Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x9
4340Sstevel@tonic-gate  */
4350Sstevel@tonic-gate #define	PCI_INPUT_KEYBOARD	0x0	/* Keyboard Controller */
4360Sstevel@tonic-gate #define	PCI_INPUT_DIGITIZ	0x1	/* Digitizer (Pen) */
4370Sstevel@tonic-gate #define	PCI_INPUT_MOUSE		0x2	/* Mouse Controller */
4380Sstevel@tonic-gate #define	PCI_INPUT_SCANNER	0x3	/* Scanner Controller */
4390Sstevel@tonic-gate #define	PCI_INPUT_GAMEPORT	0x4	/* Gameport Controller */
4400Sstevel@tonic-gate #define	PCI_INPUT_OTHER		0x80	/* Other Input Controller */
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate /*
4430Sstevel@tonic-gate  * Programming interfaces for class 0x9 / subclass 0x4 (Gameport controller)
4440Sstevel@tonic-gate  */
4450Sstevel@tonic-gate #define	PCI_INPUT_GAMEPORT_IF_GENERIC	0x00	/* Generic controller */
4460Sstevel@tonic-gate #define	PCI_INPUT_GAMEPORT_IF_LEGACY	0x10	/* Legacy controller */
4470Sstevel@tonic-gate 
4480Sstevel@tonic-gate /*
4493070Sanish  * PCI Sub-class codes - base class 0xA
4500Sstevel@tonic-gate  */
4510Sstevel@tonic-gate #define	PCI_DOCK_GENERIC	0x00	/* Generic Docking Station */
4520Sstevel@tonic-gate #define	PCI_DOCK_OTHER		0x80	/* Other Type of Docking Station */
4530Sstevel@tonic-gate 
4540Sstevel@tonic-gate /*
4553070Sanish  * PCI Sub-class codes - base class 0xB
4560Sstevel@tonic-gate  */
4570Sstevel@tonic-gate #define	PCI_PROCESSOR_386	0x0	/* 386 */
4580Sstevel@tonic-gate #define	PCI_PROCESSOR_486	0x1	/* 486 */
4590Sstevel@tonic-gate #define	PCI_PROCESSOR_PENT	0x2	/* Pentium */
4600Sstevel@tonic-gate #define	PCI_PROCESSOR_ALPHA	0x10	/* Alpha */
4610Sstevel@tonic-gate #define	PCI_PROCESSOR_POWERPC	0x20	/* PowerPC */
4620Sstevel@tonic-gate #define	PCI_PROCESSOR_MIPS	0x30	/* MIPS */
4630Sstevel@tonic-gate #define	PCI_PROCESSOR_COPROC	0x40	/* Co-processor */
4643070Sanish #define	PCI_PROCESSOR_OTHER	0x80	/* Other processors */
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate /*
4673070Sanish  * PCI Sub-class codes - base class 0xC (Serial Controllers)
4680Sstevel@tonic-gate  */
4690Sstevel@tonic-gate #define	PCI_SERIAL_FIRE		0x0	/* FireWire (IEEE 1394) */
4700Sstevel@tonic-gate #define	PCI_SERIAL_ACCESS	0x1	/* ACCESS.bus */
4710Sstevel@tonic-gate #define	PCI_SERIAL_SSA		0x2	/* SSA */
4720Sstevel@tonic-gate #define	PCI_SERIAL_USB		0x3	/* Universal Serial Bus */
4730Sstevel@tonic-gate #define	PCI_SERIAL_FIBRE	0x4	/* Fibre Channel */
4740Sstevel@tonic-gate #define	PCI_SERIAL_SMBUS	0x5	/* System Management Bus */
4750Sstevel@tonic-gate #define	PCI_SERIAL_IB		0x6	/* InfiniBand */
4760Sstevel@tonic-gate #define	PCI_SERIAL_IPMI		0x7	/* IPMI */
4770Sstevel@tonic-gate #define	PCI_SERIAL_SERCOS	0x8	/* SERCOS Interface Std (IEC 61491) */
4780Sstevel@tonic-gate #define	PCI_SERIAL_CANBUS	0x9	/* CANbus */
4793070Sanish #define	PCI_SERIAL_OTHER	0x80	/* Other Serial Bus Controllers */
4803070Sanish 
4813070Sanish /*
4823070Sanish  * Programming interfaces for class 0xC / subclass 0x0 (Firewire)
4833070Sanish  */
4843070Sanish #define	PCI_SERIAL_FIRE_WIRE  		0x00	/* IEEE 1394 (Firewire) */
4853070Sanish #define	PCI_SERIAL_FIRE_1394_HCI 	0x10	/* 1394 OpenHCI Host Cntrlr */
4860Sstevel@tonic-gate 
4870Sstevel@tonic-gate /*
4880Sstevel@tonic-gate  * Programming interfaces for class 0xC / subclass 0x3 (USB controller)
4890Sstevel@tonic-gate  */
4900Sstevel@tonic-gate #define	PCI_SERIAL_USB_IF_UHCI 		0x00	/* UHCI Compliant */
4910Sstevel@tonic-gate #define	PCI_SERIAL_USB_IF_OHCI 		0x10	/* OHCI Compliant */
4920Sstevel@tonic-gate #define	PCI_SERIAL_USB_IF_EHCI 		0x20	/* EHCI Compliant */
4930Sstevel@tonic-gate #define	PCI_SERIAL_USB_IF_GENERIC 	0x80	/* no specific HCD */
4940Sstevel@tonic-gate #define	PCI_SERIAL_USB_IF_DEVICE 	0xFE	/* not a HCD */
4950Sstevel@tonic-gate 
4960Sstevel@tonic-gate /*
4970Sstevel@tonic-gate  * Programming interfaces for class 0xC / subclass 0x7 (IPMI controller)
4980Sstevel@tonic-gate  */
4990Sstevel@tonic-gate #define	PCI_SERIAL_IPMI_IF_SMIC 	0x0	/* SMIC Interface */
5000Sstevel@tonic-gate #define	PCI_SERIAL_IPMI_IF_KBD 		0x1	/* Keyboard Ctrl Style Intfc */
5010Sstevel@tonic-gate #define	PCI_SERIAL_IPMI_IF_BTI		0x2	/* Block Transfer Interface */
5020Sstevel@tonic-gate 
5030Sstevel@tonic-gate /*
5043070Sanish  * PCI Sub-class codes - base class 0xD (Wireless controllers)
5050Sstevel@tonic-gate  */
5060Sstevel@tonic-gate #define	PCI_WIRELESS_IRDA		0x0	/* iRDA Compatible Controller */
5070Sstevel@tonic-gate #define	PCI_WIRELESS_IR			0x1	/* Consumer IR Controller */
5080Sstevel@tonic-gate #define	PCI_WIRELESS_RF			0x10	/* RF Controller */
5090Sstevel@tonic-gate #define	PCI_WIRELESS_BLUETOOTH		0x11	/* Bluetooth Controller */
5100Sstevel@tonic-gate #define	PCI_WIRELESS_BROADBAND		0x12	/* Broadband Controller */
5110Sstevel@tonic-gate #define	PCI_WIRELESS_80211A		0x20	/* Ethernet 802.11a 5 GHz */
5120Sstevel@tonic-gate #define	PCI_WIRELESS_80211B		0x21	/* Ethernet 802.11b 2.4 GHz */
5130Sstevel@tonic-gate #define	PCI_WIRELESS_OTHER		0x80	/* Other Wireless Controllers */
5140Sstevel@tonic-gate 
5150Sstevel@tonic-gate /*
5163070Sanish  * Programming interfaces for class 0xD / subclass 0x1 (Consumer IR controller)
5170Sstevel@tonic-gate  */
5183070Sanish #define	PCI_WIRELESS_IR_CONSUMER 	0x00	/* Consumer IR Controller */
5193070Sanish #define	PCI_WIRELESS_IR_UWB_RC 		0x10	/* UWB Radio Controller */
5203070Sanish 
5213070Sanish /*
5223070Sanish  * PCI Sub-class codes - base class 0xE (Intelligent I/O controllers)
5233070Sanish  */
5243070Sanish #define	PCI_INTIO_MSG_FIFO		0x0	/* Message FIFO at off 40h */
5250Sstevel@tonic-gate #define	PCI_INTIO_I20			0x1	/* I20 Arch Spec 1.0 */
5260Sstevel@tonic-gate 
5270Sstevel@tonic-gate /*
5283070Sanish  * PCI Sub-class codes - base class 0xF (Satellite Communication controllers)
5290Sstevel@tonic-gate  */
5300Sstevel@tonic-gate #define	PCI_SATELLITE_COMM_TV		0x01	/* TV */
5310Sstevel@tonic-gate #define	PCI_SATELLITE_COMM_AUDIO	0x02	/* Audio */
5320Sstevel@tonic-gate #define	PCI_SATELLITE_COMM_VOICE	0x03	/* Voice */
5330Sstevel@tonic-gate #define	PCI_SATELLITE_COMM_DATA		0x04	/* DATA */
5343070Sanish #define	PCI_SATELLITE_COMM_OTHER	0x80	/* Other Satelite Comm Cntrlr */
5350Sstevel@tonic-gate 
5360Sstevel@tonic-gate /*
5370Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x10 (Encryption/Decryption controllers)
5380Sstevel@tonic-gate  */
5390Sstevel@tonic-gate #define	PCI_CRYPT_NETWORK		0x00	/* Network and Computing */
5400Sstevel@tonic-gate #define	PCI_CRYPT_ENTERTAINMENT		0x10	/* Entertainment en/decrypt */
5410Sstevel@tonic-gate #define	PCI_CRYPT_OTHER			0x80	/* Other en/decryption ctrlrs */
5420Sstevel@tonic-gate 
5430Sstevel@tonic-gate /*
5440Sstevel@tonic-gate  * PCI Sub-class codes - base class 0x11 (Signal Processing controllers)
5450Sstevel@tonic-gate  */
5460Sstevel@tonic-gate #define	PCI_SIGNAL_DPIO			0x00	/* DPIO modules */
5470Sstevel@tonic-gate #define	PCI_SIGNAL_PERF_COUNTERS	0x01	/* Performance counters */
5480Sstevel@tonic-gate #define	PCI_SIGNAL_COMM_SYNC		0x10	/* Comm. synchronization plus */
5490Sstevel@tonic-gate 						/* time and freq test ctrlr */
5500Sstevel@tonic-gate #define	PCI_SIGNAL_MANAGEMENT		0x20	/* Management card */
5510Sstevel@tonic-gate #define	PCI_SIGNAL_OTHER		0x80	/* DSP/DAP controller */
5520Sstevel@tonic-gate 
5530Sstevel@tonic-gate /* PCI header decode */
5540Sstevel@tonic-gate #define	PCI_HEADER_MULTI	0x80	/* multi-function device */
5550Sstevel@tonic-gate #define	PCI_HEADER_ZERO		0x00	/* type zero PCI header */
5560Sstevel@tonic-gate #define	PCI_HEADER_ONE		0x01	/* type one PCI header */
5570Sstevel@tonic-gate #define	PCI_HEADER_TWO		0x02	/* type two PCI header */
5580Sstevel@tonic-gate #define	PCI_HEADER_PPB		PCI_HEADER_ONE  /* type one PCI to PCI Bridge */
5590Sstevel@tonic-gate #define	PCI_HEADER_CARDBUS	PCI_HEADER_TWO	/* type one PCI header */
5600Sstevel@tonic-gate 
5610Sstevel@tonic-gate #define	PCI_HEADER_TYPE_M	0x7f  /* type mask for header */
5620Sstevel@tonic-gate 
5630Sstevel@tonic-gate /*
5640Sstevel@tonic-gate  * Base register bit definitions.
5650Sstevel@tonic-gate  */
5660Sstevel@tonic-gate #define	PCI_BASE_SPACE_M    0x1  /* memory space indicator */
5670Sstevel@tonic-gate #define	PCI_BASE_SPACE_IO   0x1   /* IO space */
5680Sstevel@tonic-gate #define	PCI_BASE_SPACE_MEM  0x0   /* memory space */
5690Sstevel@tonic-gate 
5700Sstevel@tonic-gate #define	PCI_BASE_TYPE_MEM   0x0   /* 32-bit memory address */
5710Sstevel@tonic-gate #define	PCI_BASE_TYPE_LOW   0x2   /* less than 1Mb address */
5720Sstevel@tonic-gate #define	PCI_BASE_TYPE_ALL   0x4   /* 64-bit memory address */
5730Sstevel@tonic-gate #define	PCI_BASE_TYPE_RES   0x6   /* reserved */
5740Sstevel@tonic-gate 
5750Sstevel@tonic-gate #define	PCI_BASE_TYPE_M		0x00000006  /* type indicator mask */
5760Sstevel@tonic-gate #define	PCI_BASE_PREF_M		0x00000008  /* prefetch mask */
5770Sstevel@tonic-gate #define	PCI_BASE_M_ADDR_M	0xfffffff0  /* memory address mask */
5780Sstevel@tonic-gate #define	PCI_BASE_IO_ADDR_M	0xfffffffe  /* I/O address mask */
5790Sstevel@tonic-gate 
5800Sstevel@tonic-gate #define	PCI_BASE_ROM_ADDR_M	0xfffff800  /* ROM address mask */
5810Sstevel@tonic-gate #define	PCI_BASE_ROM_ENABLE	0x00000001  /* ROM decoder enable */
5820Sstevel@tonic-gate 
5830Sstevel@tonic-gate /*
5840Sstevel@tonic-gate  * Capabilities linked list entry offsets
5850Sstevel@tonic-gate  */
5860Sstevel@tonic-gate #define	PCI_CAP_ID		0x0	/* capability identifier, 1 byte */
5870Sstevel@tonic-gate #define	PCI_CAP_NEXT_PTR	0x1	/* next entry pointer, 1 byte */
588881Sjohnny #define	PCI_CAP_ID_REGS_OFF	0x2	/* cap id register offset */
5890Sstevel@tonic-gate #define	PCI_CAP_MAX_PTR		0x30	/* maximum number of cap pointers */
5900Sstevel@tonic-gate #define	PCI_CAP_PTR_OFF		0x40	/* minimum cap pointer offset */
5910Sstevel@tonic-gate #define	PCI_CAP_PTR_MASK	0xFC	/* mask for capability pointer */
5920Sstevel@tonic-gate 
5930Sstevel@tonic-gate /*
5940Sstevel@tonic-gate  * Capability identifier values
5950Sstevel@tonic-gate  */
5960Sstevel@tonic-gate #define	PCI_CAP_ID_PM		0x1	/* power management entry */
5970Sstevel@tonic-gate #define	PCI_CAP_ID_AGP		0x2	/* AGP supported */
5980Sstevel@tonic-gate #define	PCI_CAP_ID_VPD		0x3	/* VPD supported */
5990Sstevel@tonic-gate #define	PCI_CAP_ID_SLOT_ID	0x4	/* Slot Identification supported */
6000Sstevel@tonic-gate #define	PCI_CAP_ID_MSI		0x5	/* MSI supported */
6010Sstevel@tonic-gate #define	PCI_CAP_ID_cPCI_HS	0x6	/* CompactPCI Host Swap supported */
6020Sstevel@tonic-gate #define	PCI_CAP_ID_PCIX		0x7	/* PCI-X supported */
6030Sstevel@tonic-gate #define	PCI_CAP_ID_HT		0x8	/* HyperTransport supported */
6040Sstevel@tonic-gate #define	PCI_CAP_ID_VS		0x9	/* Vendor Specific */
6050Sstevel@tonic-gate #define	PCI_CAP_ID_DEBUG_PORT	0xA	/* Debug Port supported */
6060Sstevel@tonic-gate #define	PCI_CAP_ID_cPCI_CRC	0xB	/* CompactPCI central resource ctrl */
6070Sstevel@tonic-gate #define	PCI_CAP_ID_PCI_HOTPLUG	0xC	/* PCI Hot Plug supported */
6083070Sanish #define	PCI_CAP_ID_P2P_SUBSYS	0xD	/* PCI bridge Sub-system ID */
6090Sstevel@tonic-gate #define	PCI_CAP_ID_AGP_8X	0xE	/* AGP 8X supported */
6100Sstevel@tonic-gate #define	PCI_CAP_ID_SECURE_DEV	0xF	/* Secure Device supported */
6110Sstevel@tonic-gate #define	PCI_CAP_ID_PCI_E	0x10	/* PCI Express supported */
6120Sstevel@tonic-gate #define	PCI_CAP_ID_MSI_X	0x11	/* MSI-X supported */
6133070Sanish #define	PCI_CAP_ID_SATA		0x12	/* SATA Data/Index Config supported */
6143070Sanish #define	PCI_CAP_ID_FLR		0x13	/* Function Level Reset supported */
6150Sstevel@tonic-gate 
6160Sstevel@tonic-gate /*
6170Sstevel@tonic-gate  * Capability next entry pointer values
6180Sstevel@tonic-gate  */
6190Sstevel@tonic-gate #define	PCI_CAP_NEXT_PTR_NULL	0x0	/* no more entries in the list */
6200Sstevel@tonic-gate 
6210Sstevel@tonic-gate /*
6220Sstevel@tonic-gate  * PCI power management (PM) capability entry offsets
6230Sstevel@tonic-gate  */
6240Sstevel@tonic-gate #define	PCI_PMCAP		0x2	/* PM capabilities, 2 bytes */
6250Sstevel@tonic-gate #define	PCI_PMCSR		0x4	/* PM control/status reg, 2 bytes */
6260Sstevel@tonic-gate #define	PCI_PMCSR_BSE		0x6	/* PCI-PCI bridge extensions, 1 byte */
6270Sstevel@tonic-gate #define	PCI_PMDATA		0x7	/* PM data, 1 byte */
6280Sstevel@tonic-gate 
6290Sstevel@tonic-gate /*
6300Sstevel@tonic-gate  * PM capabilities values - 2 bytes
6310Sstevel@tonic-gate  */
6320Sstevel@tonic-gate #define	PCI_PMCAP_VER_1_0	0x1	/* PCI PM spec 1.0 */
6330Sstevel@tonic-gate #define	PCI_PMCAP_VER_1_1	0x2	/* PCI PM spec 1.1 */
6340Sstevel@tonic-gate #define	PCI_PMCAP_VER_MASK	0x7	/* version mask */
6350Sstevel@tonic-gate #define	PCI_PMCAP_PME_CLOCK	0x8	/* needs PCI clock for PME */
6360Sstevel@tonic-gate #define	PCI_PMCAP_DSI		0x20	/* needs device specific init */
6370Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_SELF	0x0	/* 0 aux current - self powered */
6380Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_55mA	0x40	/* 55 mA aux current */
6390Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_100mA	0x80	/* 100 mA aux current */
6400Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_160mA	0xc0	/* 160 mA aux current */
6410Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_220mA	0x100	/* 220 mA aux current */
6420Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_270mA	0x140	/* 270 mA aux current */
6430Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_320mA	0x180	/* 320 mA aux current */
6440Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_375mA	0x1c0	/* 375 mA aux current */
6450Sstevel@tonic-gate #define	PCI_PMCAP_AUX_CUR_MASK	0x1c0	/* 3.3Vaux aux current needs */
6460Sstevel@tonic-gate #define	PCI_PMCAP_D1		0x200	/* D1 state supported */
6470Sstevel@tonic-gate #define	PCI_PMCAP_D2		0x400	/* D2 state supported */
6480Sstevel@tonic-gate #define	PCI_PMCAP_D0_PME	0x800	/* PME from D0 */
6490Sstevel@tonic-gate #define	PCI_PMCAP_D1_PME	0x1000	/* PME from D1 */
6500Sstevel@tonic-gate #define	PCI_PMCAP_D2_PME	0x2000	/* PME from D2 */
6510Sstevel@tonic-gate #define	PCI_PMCAP_D3HOT_PME	0x4000	/* PME from D3hot */
6520Sstevel@tonic-gate #define	PCI_PMCAP_D3COLD_PME	0x8000	/* PME from D3cold */
6530Sstevel@tonic-gate #define	PCI_PMCAP_PME_MASK	0xf800	/* PME support mask */
6540Sstevel@tonic-gate 
6550Sstevel@tonic-gate /*
6560Sstevel@tonic-gate  * PM control/status values - 2 bytes
6570Sstevel@tonic-gate  */
6580Sstevel@tonic-gate #define	PCI_PMCSR_D0			0x0	/* power state D0 */
6590Sstevel@tonic-gate #define	PCI_PMCSR_D1			0x1	/* power state D1 */
6600Sstevel@tonic-gate #define	PCI_PMCSR_D2			0x2	/* power state D2 */
6610Sstevel@tonic-gate #define	PCI_PMCSR_D3HOT			0x3	/* power state D3hot */
6620Sstevel@tonic-gate #define	PCI_PMCSR_STATE_MASK		0x3	/* power state mask */
6630Sstevel@tonic-gate #define	PCI_PMCSR_PME_EN		0x100	/* enable PME assertion */
6640Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D0_PWR_C		0x0	/* D0 power consumed */
6650Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D1_PWR_C		0x200	/* D1 power consumed */
6660Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D2_PWR_C		0x400	/* D2 power consumed */
6670Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D3_PWR_C		0x600	/* D3 power consumed */
6680Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D0_PWR_D		0x800	/* D0 power dissipated */
6690Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D1_PWR_D		0xa00	/* D1 power dissipated */
6700Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D2_PWR_D		0xc00	/* D2 power dissipated */
6710Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_D3_PWR_D		0xe00	/* D3 power dissipated */
6720Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_COM_C		0x1000	/* common power consumption */
6730Sstevel@tonic-gate #define	PCI_PMCSR_DSEL_MASK		0x1e00	/* data select mask */
6740Sstevel@tonic-gate #define	PCI_PMCSR_DSCL_UNKNOWN		0x0	/* data scale unknown */
6750Sstevel@tonic-gate #define	PCI_PMCSR_DSCL_1_BY_10		0x2000	/* data scale 0.1x */
6760Sstevel@tonic-gate #define	PCI_PMCSR_DSCL_1_BY_100		0x4000	/* data scale 0.01x */
6770Sstevel@tonic-gate #define	PCI_PMCSR_DSCL_1_BY_1000	0x6000	/* data scale 0.001x */
6780Sstevel@tonic-gate #define	PCI_PMCSR_DSCL_MASK		0x6000	/* data scale mask */
6790Sstevel@tonic-gate #define	PCI_PMCSR_PME_STAT		0x8000	/* PME status */
6800Sstevel@tonic-gate 
6810Sstevel@tonic-gate /*
6820Sstevel@tonic-gate  * PM PMCSR PCI to PCI bridge support extension values - 1 byte
6830Sstevel@tonic-gate  */
6840Sstevel@tonic-gate #define	PCI_PMCSR_BSE_B2_B3	0x40	/* bridge D3hot -> secondary B2 */
6850Sstevel@tonic-gate #define	PCI_PMCSR_BSE_BPCC_EN	0x80	/* bus power/clock control enabled */
6860Sstevel@tonic-gate 
6870Sstevel@tonic-gate /*
6880Sstevel@tonic-gate  * PCI-X capability related definitions
6890Sstevel@tonic-gate  */
6900Sstevel@tonic-gate #define	PCI_PCIX_COMMAND	0x2	/* Command register offset */
6911865Sdilpreet #define	PCI_PCIX_STATUS		0x4	/* Status register offset */
6921865Sdilpreet #define	PCI_PCIX_ECC_STATUS	0x8	/* ECC Status register offset */
6931865Sdilpreet #define	PCI_PCIX_ECC_FST_AD	0xC	/* ECC First address register offset */
6941865Sdilpreet #define	PCI_PCIX_ECC_SEC_AD	0x10	/* ECC Second address register offset */
6951865Sdilpreet #define	PCI_PCIX_ECC_ATTR	0x14	/* ECC Attribute register offset */
6960Sstevel@tonic-gate 
6971865Sdilpreet /*
6981865Sdilpreet  * PCI-X bridge capability related definitions
6991865Sdilpreet  */
7003274Set142600 #define	PCI_PCIX_SEC_STATUS		0x2	/* Secondary Status offset */
7013274Set142600 #define	PCI_PCIX_SEC_STATUS_SCD		0x4	/* Split Completion Discarded */
7023274Set142600 #define	PCI_PCIX_SEC_STATUS_USC		0x8	/* Unexpected Split Complete */
7033274Set142600 #define	PCI_PCIX_SEC_STATUS_SCO		0x10	/* Split Completion Overrun */
7043274Set142600 #define	PCI_PCIX_SEC_STATUS_SRD		0x20	/* Split Completion Delayed */
7053274Set142600 #define	PCI_PCIX_SEC_STATUS_ERR_MASK	0x3C
7063274Set142600 
7073274Set142600 #define	PCI_PCIX_BDG_STATUS		0x4	/* Bridge Status offset */
7083274Set142600 #define	PCI_PCIX_BDG_STATUS_USC		0x80000
7093274Set142600 #define	PCI_PCIX_BDG_STATUS_SCO		0x100000
7103274Set142600 #define	PCI_PCIX_BDG_STATUS_SRD		0x200000
7113274Set142600 #define	PCI_PCIX_BDG_STATUS_ERR_MASK	0x380000
7123274Set142600 
7131865Sdilpreet #define	PCI_PCIX_UP_SPL_CTL	0x8	/* Upstream split ctrl reg offset */
7141865Sdilpreet #define	PCI_PCIX_DOWN_SPL_CTL	0xC	/* Downstream split ctrl reg offset */
7151865Sdilpreet #define	PCI_PCIX_BDG_ECC_STATUS	0x10	/* ECC Status register offset */
7161865Sdilpreet #define	PCI_PCIX_BDG_ECC_FST_AD	0x14	/* ECC First address register offset */
7171865Sdilpreet #define	PCI_PCIX_BDG_ECC_SEC_AD	0x18	/* ECC Second address register offset */
7181865Sdilpreet #define	PCI_PCIX_BDG_ECC_ATTR	0x1C	/* ECC Attribute register offset */
7191865Sdilpreet 
7201865Sdilpreet /*
7211865Sdilpreet  * PCIX capabilities values
7221865Sdilpreet  */
7230Sstevel@tonic-gate #define	PCI_PCIX_VER_MASK	0x3000	/* Bits 12 and 13 */
7240Sstevel@tonic-gate #define	PCI_PCIX_VER_0		0x0000	/* PCIX cap list item version 0 */
7250Sstevel@tonic-gate #define	PCI_PCIX_VER_1		0x1000	/* PCIX cap list item version 1 */
7260Sstevel@tonic-gate #define	PCI_PCIX_VER_2		0x2000	/* PCIX cap list item version 2 */
7270Sstevel@tonic-gate 
7281865Sdilpreet #define	PCI_PCIX_SPL_DSCD	0x40000 /* Split Completion Discarded */
7291865Sdilpreet #define	PCI_PCIX_UNEX_SPL	0x80000	/* Unexpected Split Completion */
7301865Sdilpreet #define	PCI_PCIX_RX_SPL_MSG	0x20000000 /* Recieved Spl Comp Error Message */
7311865Sdilpreet 
7321865Sdilpreet #define	PCI_PCIX_ECC_SEL	0x1	/* Secondary ECC register select */
7331865Sdilpreet #define	PCI_PCIX_ECC_EP		0x2	/* Error Present on other side */
7341865Sdilpreet #define	PCI_PCIX_ECC_S_CE	0x4	/* Addl Correctable ECC Error */
7351865Sdilpreet #define	PCI_PCIX_ECC_S_UE	0x8	/* Addl Uncorrectable ECC Error */
7361865Sdilpreet #define	PCI_PCIX_ECC_PHASE	0x70	/* ECC Error Phase */
7371865Sdilpreet #define	PCI_PCIX_ECC_CORR	0x80	/* ECC Error Corrected */
7381865Sdilpreet #define	PCI_PCIX_ECC_SYN	0xff00	/* ECC Error Syndrome */
7391865Sdilpreet #define	PCI_PCIX_ECC_FST_CMD	0xf0000	 /* ECC Error First Command */
7401865Sdilpreet #define	PCI_PCIX_ECC_SEC_CMD	0xf00000 /* ECC Error Second Command */
7411865Sdilpreet #define	PCI_PCIX_ECC_UP_ATTR	0xf000000 /* ECC Error Upper Attributes */
7421865Sdilpreet 
7431865Sdilpreet /*
7441865Sdilpreet  * PCIX ECC Phase Values
7451865Sdilpreet  */
7461865Sdilpreet #define	PCI_PCIX_ECC_PHASE_NOERR	0x0
7471865Sdilpreet #define	PCI_PCIX_ECC_PHASE_FADDR	0x1
7481865Sdilpreet #define	PCI_PCIX_ECC_PHASE_SADDR	0x2
7491865Sdilpreet #define	PCI_PCIX_ECC_PHASE_ATTR		0x3
7501865Sdilpreet #define	PCI_PCIX_ECC_PHASE_DATA32	0x4
7511865Sdilpreet #define	PCI_PCIX_ECC_PHASE_DATA64	0x5
7521865Sdilpreet 
7531865Sdilpreet /*
7541865Sdilpreet  * PCI-X Command Encoding
7551865Sdilpreet  */
7561865Sdilpreet #define	PCI_PCIX_CMD_INTR		0x0
7571865Sdilpreet #define	PCI_PCIX_CMD_SPEC		0x1
7581865Sdilpreet #define	PCI_PCIX_CMD_IORD		0x2
7591865Sdilpreet #define	PCI_PCIX_CMD_IOWR		0x3
7601865Sdilpreet #define	PCI_PCIX_CMD_DEVID		0x5
7611865Sdilpreet #define	PCI_PCIX_CMD_MEMRD_DW		0x6
7621865Sdilpreet #define	PCI_PCIX_CMD_MEMWR		0x7
7631865Sdilpreet #define	PCI_PCIX_CMD_MEMRD_BL		0x8
7641865Sdilpreet #define	PCI_PCIX_CMD_MEMWR_BL		0x9
7651865Sdilpreet #define	PCI_PCIX_CMD_CFRD		0xA
7661865Sdilpreet #define	PCI_PCIX_CMD_CFWR		0xB
7671865Sdilpreet #define	PCI_PCIX_CMD_SPL		0xC
7681865Sdilpreet #define	PCI_PCIX_CMD_DADR		0xD
7691865Sdilpreet #define	PCI_PCIX_CMD_MEMRDBL		0xE
7701865Sdilpreet #define	PCI_PCIX_CMD_MEMWRBL		0xF
7711865Sdilpreet 
7721865Sdilpreet #if defined(_BIT_FIELDS_LTOH)
7731865Sdilpreet typedef struct pcix_attr {
7741865Sdilpreet 	uint32_t	lbc	:8,
7751865Sdilpreet 			rid	:16,
7761865Sdilpreet 			tag	:5,
7771865Sdilpreet 			ro	:1,
7781865Sdilpreet 			ns	:1,
7791865Sdilpreet 			r	:1;
7801865Sdilpreet } pcix_attr_t;
7811865Sdilpreet #elif defined(_BIT_FIELDS_HTOL)
7821865Sdilpreet typedef struct pcix_attr {
7831865Sdilpreet 	uint32_t	r	:1,
7841865Sdilpreet 			ns	:1,
7851865Sdilpreet 			ro	:1,
7861865Sdilpreet 			tag	:5,
7871865Sdilpreet 			rid	:16,
7881865Sdilpreet 			lbc	:8;
7891865Sdilpreet } pcix_attr_t;
7901865Sdilpreet #else
7911865Sdilpreet #error "bit field not defined"
7921865Sdilpreet #endif
7931865Sdilpreet 
7941865Sdilpreet #define	PCI_PCIX_BSS_SPL_DSCD	0x4	/* Secondary split comp discarded */
7951865Sdilpreet #define	PCI_PCIX_BSS_UNEX_SPL	0x8	/* Secondary unexpected split comp */
7961865Sdilpreet #define	PCI_PCIX_BSS_SPL_OR	0x10	/* Secondary split comp overrun */
7971865Sdilpreet #define	PCI_PCIX_BSS_SPL_DLY	0x20	/* Secondary split comp delayed */
7981865Sdilpreet 
7990Sstevel@tonic-gate /*
8000Sstevel@tonic-gate  * PCI Message Signalled Interrupts (MSI) capability entry offsets for 32-bit
8010Sstevel@tonic-gate  */
8020Sstevel@tonic-gate #define	PCI_MSI_CTRL		0x02	/* MSI control register, 2 bytes */
8030Sstevel@tonic-gate #define	PCI_MSI_ADDR_OFFSET	0x04	/* MSI 32-bit msg address, 4 bytes */
8040Sstevel@tonic-gate #define	PCI_MSI_32BIT_DATA	0x08	/* MSI 32-bit msg data, 2 bytes */
8050Sstevel@tonic-gate #define	PCI_MSI_32BIT_MASK	0x0C	/* MSI 32-bit mask bits, 4 bytes */
8060Sstevel@tonic-gate #define	PCI_MSI_32BIT_PENDING	0x10	/* MSI 32-bit pending bits, 4 bytes */
8070Sstevel@tonic-gate 
8080Sstevel@tonic-gate /*
8090Sstevel@tonic-gate  * PCI Message Signalled Interrupts (MSI) capability entry offsets for 64-bit
8100Sstevel@tonic-gate  */
8110Sstevel@tonic-gate #define	PCI_MSI_64BIT_DATA	0x0C	/* MSI 64-bit msg data, 2 bytes */
8120Sstevel@tonic-gate #define	PCI_MSI_64BIT_MASKBITS	0x10	/* MSI 64-bit mask bits, 4 bytes */
8130Sstevel@tonic-gate #define	PCI_MSI_64BIT_PENDING	0x14	/* MSI 64-bit pending bits, 4 bytes */
8140Sstevel@tonic-gate 
8150Sstevel@tonic-gate /*
8160Sstevel@tonic-gate  * PCI Message Signalled Interrupts (MSI) capability masks and shifts
8170Sstevel@tonic-gate  */
8180Sstevel@tonic-gate #define	PCI_MSI_ENABLE_BIT	0x0001	/* MSI enable mask in MSI ctrl reg */
8190Sstevel@tonic-gate #define	PCI_MSI_MMC_MASK	0x000E	/* MMC mask in MSI ctrl reg */
8200Sstevel@tonic-gate #define	PCI_MSI_MMC_SHIFT	0x1	/* Shift for MMC bits */
8210Sstevel@tonic-gate #define	PCI_MSI_MME_MASK	0x0070	/* MME mask in MSI ctrl reg */
8220Sstevel@tonic-gate #define	PCI_MSI_MME_SHIFT	0x4	/* Shift for MME bits */
8230Sstevel@tonic-gate #define	PCI_MSI_64BIT_MASK	0x0080	/* 64bit support mask in MSI ctrl reg */
8240Sstevel@tonic-gate #define	PCI_MSI_PVM_MASK	0x0100	/* PVM support mask in MSI ctrl reg */
8250Sstevel@tonic-gate 
8260Sstevel@tonic-gate /*
8270Sstevel@tonic-gate  * PCI Extended Message Signalled Interrupts (MSI-X) capability entry offsets
8280Sstevel@tonic-gate  */
8290Sstevel@tonic-gate #define	PCI_MSIX_CTRL		0x02	/* MSI-X control register, 2 bytes */
8300Sstevel@tonic-gate #define	PCI_MSIX_TBL_OFFSET	0x04	/* MSI-X table offset, 4 bytes */
831965Sgovinda #define	PCI_MSIX_TBL_BIR_MASK	0x0007	/* MSI-X table BIR mask */
832965Sgovinda #define	PCI_MSIX_PBA_OFFSET	0x08	/* MSI-X pending bit array, 4 bytes */
833965Sgovinda #define	PCI_MSIX_PBA_BIR_MASK	0x0007	/* MSI-X PBA BIR mask */
8340Sstevel@tonic-gate 
8350Sstevel@tonic-gate #define	PCI_MSIX_TBL_SIZE_MASK	0x07FF	/* table size mask in MSI-X ctrl reg */
8360Sstevel@tonic-gate #define	PCI_MSIX_FUNCTION_MASK	0x4000	/* function mask in MSI-X ctrl reg */
8370Sstevel@tonic-gate #define	PCI_MSIX_ENABLE_BIT	0x8000	/* MSI-X enable mask in MSI-X ctl reg */
8380Sstevel@tonic-gate 
8390Sstevel@tonic-gate #define	PCI_MSIX_LOWER_ADDR_OFFSET	0	/* MSI-X lower addr offset */
8400Sstevel@tonic-gate #define	PCI_MSIX_UPPER_ADDR_OFFSET	4	/* MSI-X upper addr offset */
8410Sstevel@tonic-gate #define	PCI_MSIX_DATA_OFFSET		8	/* MSI-X data offset */
8420Sstevel@tonic-gate #define	PCI_MSIX_VECTOR_CTRL_OFFSET	12	/* MSI-X vector ctrl offset */
8430Sstevel@tonic-gate #define	PCI_MSIX_VECTOR_SIZE		16	/* MSI-X size of each vector */
8440Sstevel@tonic-gate 
8450Sstevel@tonic-gate /*
8460Sstevel@tonic-gate  * PCI Message Signalled Interrupts: other interesting constants
8470Sstevel@tonic-gate  */
8480Sstevel@tonic-gate #define	PCI_MSI_MAX_INTRS	32	/* maximum MSI interrupts supported */
8490Sstevel@tonic-gate #define	PCI_MSIX_MAX_INTRS	2048	/* maximum MSI-X interrupts supported */
8500Sstevel@tonic-gate 
8510Sstevel@tonic-gate /*
852881Sjohnny  * PCI Slot Id Capabilities, 2 bytes
853881Sjohnny  */
854881Sjohnny /* Byte 1: Expansion Slot Register (ESR), Byte 2: Chassis Number Register */
855881Sjohnny #define	PCI_CAPSLOT_ESR_NSLOTS_MASK	0x1F	/* Number of slots mask */
856881Sjohnny #define	PCI_CAPSLOT_ESR_FIC		0x20	/* First In Chassis bit */
857881Sjohnny #define	PCI_CAPSLOT_ESR_FIC_MASK	0x01	/* First In Chassis mask */
858881Sjohnny #define	PCI_CAPSLOT_ESR_FIC_SHIFT	5	/* First In Chassis shift */
859881Sjohnny #define	PCI_CAPSLOT_FIC(esr_reg)	((esr_reg) & PCI_CAPSLOT_ESR_FIC)
860881Sjohnny #define	PCI_CAPSLOT_NSLOTS(esr_reg)	((esr_reg) & \
861881Sjohnny 						PCI_CAPSLOT_ESR_NSLOTS_MASK)
862881Sjohnny 
863881Sjohnny /*
8640Sstevel@tonic-gate  * other interesting PCI constants
8650Sstevel@tonic-gate  */
8660Sstevel@tonic-gate #define	PCI_BASE_NUM	6	/* num of base regs in configuration header */
8670Sstevel@tonic-gate #define	PCI_BAR_SZ_32	4	/* size of 32 bit base addr reg in bytes */
8680Sstevel@tonic-gate #define	PCI_BAR_SZ_64	8	/* size of 64 bit base addr reg in bytes */
8690Sstevel@tonic-gate #define	PCI_BASE_SIZE	4	/* size of base reg in bytes */
8700Sstevel@tonic-gate #define	PCI_CONF_HDR_SIZE	256	/* configuration header size */
871881Sjohnny #define	PCI_MAX_BUS_NUM		256		/* Maximum PCI buses allowed */
8722767Sanish #define	PCI_MAX_DEVICES		32		/* Max PCI devices allowed */
8732767Sanish #define	PCI_MAX_FUNCTIONS	8		/* Max PCI functions allowed */
8742767Sanish #define	PCI_MAX_CHILDREN	PCI_MAX_DEVICES * PCI_MAX_FUNCTIONS
8750Sstevel@tonic-gate #define	PCI_CLK_33MHZ	(33 * 1000 * 1000)	/* 33MHz clock speed */
8760Sstevel@tonic-gate #define	PCI_CLK_66MHZ	(66 * 1000 * 1000)	/* 66MHz clock speed */
8770Sstevel@tonic-gate #define	PCI_CLK_133MHZ	(133 * 1000 * 1000)	/* 133MHz clock speed */
8780Sstevel@tonic-gate 
8790Sstevel@tonic-gate /*
8801865Sdilpreet  * pci bus range definition
8811865Sdilpreet  */
8821865Sdilpreet typedef struct pci_bus_range {
8831865Sdilpreet 	uint32_t lo;
8841865Sdilpreet 	uint32_t hi;
8851865Sdilpreet } pci_bus_range_t;
8861865Sdilpreet 
8871865Sdilpreet /*
8881865Sdilpreet  * The following typedef is used to represent an entry in the "ranges"
8891865Sdilpreet  * property of a pci hostbridge device node.
8901865Sdilpreet  */
8911865Sdilpreet typedef struct pci_ranges {
8921865Sdilpreet 	uint32_t child_high;
8931865Sdilpreet 	uint32_t child_mid;
8941865Sdilpreet 	uint32_t child_low;
8951865Sdilpreet 	uint32_t parent_high;
8961865Sdilpreet 	uint32_t parent_low;
8971865Sdilpreet 	uint32_t size_high;
8981865Sdilpreet 	uint32_t size_low;
8991865Sdilpreet } pci_ranges_t;
9001865Sdilpreet 
9011865Sdilpreet /*
9021865Sdilpreet  * The following typedef is used to represent an entry in the "ranges"
9031865Sdilpreet  * property of a pci-pci bridge device node.
9041865Sdilpreet  */
9051865Sdilpreet typedef struct {
9061865Sdilpreet 	uint32_t child_high;
9071865Sdilpreet 	uint32_t child_mid;
9081865Sdilpreet 	uint32_t child_low;
9091865Sdilpreet 	uint32_t parent_high;
9101865Sdilpreet 	uint32_t parent_mid;
9111865Sdilpreet 	uint32_t parent_low;
9121865Sdilpreet 	uint32_t size_high;
9131865Sdilpreet 	uint32_t size_low;
9141865Sdilpreet } ppb_ranges_t;
9151865Sdilpreet 
9161865Sdilpreet /*
9170Sstevel@tonic-gate  * This structure represents one entry of the 1275 "reg" property and
9180Sstevel@tonic-gate  * "assigned-addresses" property for a PCI node.  For the "reg" property, it
9190Sstevel@tonic-gate  * may be one of an arbitrary length array for devices with multiple address
9200Sstevel@tonic-gate  * windows.  For the "assigned-addresses" property, it denotes an assigned
9210Sstevel@tonic-gate  * physical address on the PCI bus.  It may be one entry of the six entries
9220Sstevel@tonic-gate  * for devices with multiple base registers.
9230Sstevel@tonic-gate  *
9240Sstevel@tonic-gate  * The physical address format is:
9250Sstevel@tonic-gate  *
9260Sstevel@tonic-gate  *             Bit#:  33222222 22221111 11111100 00000000
9270Sstevel@tonic-gate  *                    10987654 32109876 54321098 76543210
9280Sstevel@tonic-gate  *
9290Sstevel@tonic-gate  * pci_phys_hi cell:  np0000tt bbbbbbbb dddddfff rrrrrrrr
9300Sstevel@tonic-gate  * pci_phys_mid cell: hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
9310Sstevel@tonic-gate  * pci_phys_low cell: llllllll llllllll llllllll llllllll
9320Sstevel@tonic-gate  *
9330Sstevel@tonic-gate  * n          is 0 if the address is relocatable, 1 otherwise
9340Sstevel@tonic-gate  * p          is 1 if the addressable region is "prefetchable", 0 otherwise
9350Sstevel@tonic-gate  * t          is 1 if the address range is aliased
9360Sstevel@tonic-gate  * tt         is the type code, denoting which address space
9370Sstevel@tonic-gate  * bbbbbbbb   is the 8-bit bus number
9380Sstevel@tonic-gate  * ddddd      is the 5-bit device number
9390Sstevel@tonic-gate  * fff        is the 3-bit function number
9400Sstevel@tonic-gate  * rrrrrrrr   is the 8-bit register number
9410Sstevel@tonic-gate  * hh...hhh   is the 32-bit unsigned number
9420Sstevel@tonic-gate  * ll...lll   is the 32-bit unsigned number
9430Sstevel@tonic-gate  *
9440Sstevel@tonic-gate  * The physical size format is:
9450Sstevel@tonic-gate  *
9460Sstevel@tonic-gate  * pci_size_hi cell:  hhhhhhhh hhhhhhhh hhhhhhhh hhhhhhhh
9470Sstevel@tonic-gate  * pci_size_low cell: llllllll llllllll llllllll llllllll
9480Sstevel@tonic-gate  *
9490Sstevel@tonic-gate  * hh...hhh   is the 32-bit unsigned number
9500Sstevel@tonic-gate  * ll...lll   is the 32-bit unsigned number
9510Sstevel@tonic-gate  */
9520Sstevel@tonic-gate struct pci_phys_spec {
9530Sstevel@tonic-gate 	uint_t pci_phys_hi;		/* child's address, hi word */
9540Sstevel@tonic-gate 	uint_t pci_phys_mid;		/* child's address, middle word */
9550Sstevel@tonic-gate 	uint_t pci_phys_low;		/* child's address, low word */
9560Sstevel@tonic-gate 	uint_t pci_size_hi;		/* high word of size field */
9570Sstevel@tonic-gate 	uint_t pci_size_low;		/* low word of size field */
9580Sstevel@tonic-gate };
9590Sstevel@tonic-gate 
9600Sstevel@tonic-gate typedef struct pci_phys_spec pci_regspec_t;
9610Sstevel@tonic-gate 
9620Sstevel@tonic-gate /*
9630Sstevel@tonic-gate  * PCI masks for pci_phy_hi of PCI 1275 address cell.
9640Sstevel@tonic-gate  */
9650Sstevel@tonic-gate #define	PCI_REG_REG_M		0xff		/* register mask */
9660Sstevel@tonic-gate #define	PCI_REG_FUNC_M		0x700		/* function mask */
9670Sstevel@tonic-gate #define	PCI_REG_DEV_M		0xf800		/* device mask */
9680Sstevel@tonic-gate #define	PCI_REG_BUS_M		0xff0000	/* bus number mask */
9690Sstevel@tonic-gate #define	PCI_REG_ADDR_M		0x3000000	/* address space mask */
9700Sstevel@tonic-gate #define	PCI_REG_ALIAS_M		0x20000000	/* aliased bit mask */
9710Sstevel@tonic-gate #define	PCI_REG_PF_M		0x40000000	/* prefetch bit mask */
9720Sstevel@tonic-gate #define	PCI_REG_REL_M		0x80000000	/* relocation bit mask */
9730Sstevel@tonic-gate #define	PCI_REG_BDFR_M		0xffffff	/* bus, dev, func, reg mask */
9743743Saa72041 #define	PCI_REG_EXTREG_M	0xF0000000	/* extended config bits mask */
9750Sstevel@tonic-gate 
9760Sstevel@tonic-gate #define	PCI_REG_FUNC_SHIFT	8		/* Offset of function bits */
9770Sstevel@tonic-gate #define	PCI_REG_DEV_SHIFT	11		/* Offset of device bits */
9780Sstevel@tonic-gate #define	PCI_REG_BUS_SHIFT	16		/* Offset of bus bits */
9790Sstevel@tonic-gate #define	PCI_REG_ADDR_SHIFT	24		/* Offset of address bits */
9803743Saa72041 #define	PCI_REG_EXTREG_SHIFT	28		/* Offset of ext. config bits */
9810Sstevel@tonic-gate 
9820Sstevel@tonic-gate #define	PCI_REG_REG_G(x)	((x) & PCI_REG_REG_M)
9830Sstevel@tonic-gate #define	PCI_REG_FUNC_G(x)	(((x) & PCI_REG_FUNC_M) >> PCI_REG_FUNC_SHIFT)
9840Sstevel@tonic-gate #define	PCI_REG_DEV_G(x)	(((x) & PCI_REG_DEV_M) >> PCI_REG_DEV_SHIFT)
9850Sstevel@tonic-gate #define	PCI_REG_BUS_G(x)	(((x) & PCI_REG_BUS_M) >> PCI_REG_BUS_SHIFT)
9860Sstevel@tonic-gate #define	PCI_REG_ADDR_G(x)	(((x) & PCI_REG_ADDR_M) >> PCI_REG_ADDR_SHIFT)
9870Sstevel@tonic-gate #define	PCI_REG_BDFR_G(x)	((x) & PCI_REG_BDFR_M)
9880Sstevel@tonic-gate 
9890Sstevel@tonic-gate /*
9900Sstevel@tonic-gate  * PCI bit encodings of pci_phys_hi of PCI 1275 address cell.
9910Sstevel@tonic-gate  */
9920Sstevel@tonic-gate #define	PCI_ADDR_MASK		PCI_REG_ADDR_M
9930Sstevel@tonic-gate #define	PCI_ADDR_CONFIG		0x00000000	/* configuration address */
9940Sstevel@tonic-gate #define	PCI_ADDR_IO		0x01000000	/* I/O address */
9950Sstevel@tonic-gate #define	PCI_ADDR_MEM32		0x02000000	/* 32-bit memory address */
9960Sstevel@tonic-gate #define	PCI_ADDR_MEM64		0x03000000	/* 64-bit memory address */
9970Sstevel@tonic-gate #define	PCI_ALIAS_B		PCI_REG_ALIAS_M	/* aliased bit */
9980Sstevel@tonic-gate #define	PCI_PREFETCH_B		PCI_REG_PF_M	/* prefetch bit */
9990Sstevel@tonic-gate #define	PCI_RELOCAT_B		PCI_REG_REL_M	/* non-relocatable bit */
10000Sstevel@tonic-gate #define	PCI_CONF_ADDR_MASK	0x00ffffff	/* mask for config address */
10010Sstevel@tonic-gate 
10020Sstevel@tonic-gate #define	PCI_HARDDEC_8514 2	/* number of reg entries for 8514 hard-decode */
10030Sstevel@tonic-gate #define	PCI_HARDDEC_VGA	3	/* number of reg entries for VGA hard-decode */
10040Sstevel@tonic-gate #define	PCI_HARDDEC_IDE	4	/* number of reg entries for IDE hard-decode */
10050Sstevel@tonic-gate #define	PCI_HARDDEC_IDE_PRI 2	/* number of reg entries for IDE primary */
10060Sstevel@tonic-gate #define	PCI_HARDDEC_IDE_SEC 2	/* number of reg entries for IDE secondary */
10070Sstevel@tonic-gate 
10080Sstevel@tonic-gate /*
10090Sstevel@tonic-gate  * PCI Expansion ROM Header Format
10100Sstevel@tonic-gate  */
10110Sstevel@tonic-gate #define	PCI_ROM_SIGNATURE		0x0	/* ROM Signature 0xaa55 */
10120Sstevel@tonic-gate #define	PCI_ROM_ARCH_UNIQUE_START	0x2	/* Start of processor unique */
10130Sstevel@tonic-gate #define	PCI_ROM_PCI_DATA_STRUCT_PTR	0x18	/* Ptr to PCI Data Structure */
10140Sstevel@tonic-gate 
10150Sstevel@tonic-gate /*
10160Sstevel@tonic-gate  * PCI Data Structure
10170Sstevel@tonic-gate  *
10180Sstevel@tonic-gate  * The PCI Data Structure is located within the first 64KB
10190Sstevel@tonic-gate  * of the ROM image and must be DWORD aligned.
10200Sstevel@tonic-gate  */
10210Sstevel@tonic-gate #define	PCI_PDS_SIGNATURE	0x0	/* Signature, the string 'PCIR' */
10220Sstevel@tonic-gate #define	PCI_PDS_VENDOR_ID	0x4	/* Vendor Identification */
10230Sstevel@tonic-gate #define	PCI_PDS_DEVICE_ID	0x6	/* Device Identification */
10240Sstevel@tonic-gate #define	PCI_PDS_VPD_PTR		0x8	/* Pointer to Vital Product Data */
10250Sstevel@tonic-gate #define	PCI_PDS_PDS_LENGTH	0xa	/* PCI Data Structure Length */
10260Sstevel@tonic-gate #define	PCI_PDS_PDS_REVISION	0xc	/* PCI Data Structure Revision */
10270Sstevel@tonic-gate #define	PCI_PDS_CLASS_CODE	0xd	/* Class Code */
10280Sstevel@tonic-gate #define	PCI_PDS_IMAGE_LENGTH	0x10	/* Image Length in 512 byte units */
10290Sstevel@tonic-gate #define	PCI_PDS_CODE_REVISON	0x12	/* Revision Level of Code/Data */
10300Sstevel@tonic-gate #define	PCI_PDS_CODE_TYPE	0x14	/* Code Type */
10310Sstevel@tonic-gate #define	PCI_PDS_INDICATOR	0x15	/* Indicates if image is last in ROM */
10320Sstevel@tonic-gate 
10330Sstevel@tonic-gate #define	PCI_PDS_CODE_TYPE_PCAT		0x0	/* Intel x86/PC-AT Type */
10340Sstevel@tonic-gate #define	PCI_PDS_CODE_TYPE_OPEN_FW	0x1	/* Open Firmware */
10350Sstevel@tonic-gate 
10363249Sgovinda /*
10373249Sgovinda  * we recognize the non transparent bridge child nodes with the
10383249Sgovinda  * following property. This is specific to an implementation only.
10393249Sgovinda  * This property is specific to AP nodes only.
10403249Sgovinda  */
10413249Sgovinda #define	PCI_DEV_CONF_MAP_PROP	"pci-parent-indirect"
10423249Sgovinda 
10433249Sgovinda /*
10443249Sgovinda  * If a bridge device provides its own config space access services,
10453249Sgovinda  * and supports a hotplug/hotswap bus below at any level, then
10463249Sgovinda  * the following property must be defined for the node either by
10473249Sgovinda  * the driver or the OBP.
10483249Sgovinda  */
10493249Sgovinda #define	PCI_BUS_CONF_MAP_PROP	"pci-conf-indirect"
10503249Sgovinda 
10510Sstevel@tonic-gate #ifdef	__cplusplus
10520Sstevel@tonic-gate }
10530Sstevel@tonic-gate #endif
10540Sstevel@tonic-gate 
10550Sstevel@tonic-gate #endif	/* _SYS_PCI_H */
1056