xref: /onnv-gate/usr/src/uts/common/sys/pcie.h (revision 6313:3f914b76f189)
127Sjchu /*
227Sjchu  * CDDL HEADER START
327Sjchu  *
427Sjchu  * The contents of this file are subject to the terms of the
51786Sjj156685  * Common Development and Distribution License (the "License").
61786Sjj156685  * You may not use this file except in compliance with the License.
727Sjchu  *
827Sjchu  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
927Sjchu  * or http://www.opensolaris.org/os/licensing.
1027Sjchu  * See the License for the specific language governing permissions
1127Sjchu  * and limitations under the License.
1227Sjchu  *
1327Sjchu  * When distributing Covered Code, include this CDDL HEADER in each
1427Sjchu  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1527Sjchu  * If applicable, add the following below this CDDL HEADER, with the
1627Sjchu  * fields enclosed by brackets "[]" replaced with your own identifying
1727Sjchu  * information: Portions Copyright [yyyy] [name of copyright owner]
1827Sjchu  *
1927Sjchu  * CDDL HEADER END
2027Sjchu  */
2127Sjchu /*
22*6313Skrishnae  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2327Sjchu  * Use is subject to license terms.
2427Sjchu  */
2527Sjchu 
2627Sjchu #ifndef	_SYS_PCIE_H
2727Sjchu #define	_SYS_PCIE_H
2827Sjchu 
2927Sjchu #pragma ident	"%Z%%M%	%I%	%E% SMI"
3027Sjchu 
3127Sjchu #ifdef	__cplusplus
3227Sjchu extern "C" {
3327Sjchu #endif
3427Sjchu 
3527Sjchu #include <sys/pci.h>
3627Sjchu 
3727Sjchu /*
38881Sjohnny  * PCI Express capability registers in PCI configuration space relative to
39881Sjohnny  * the PCI Express Capability structure.
4027Sjchu  */
4127Sjchu #define	PCIE_CAP_ID			PCI_CAP_ID
4227Sjchu #define	PCIE_CAP_NEXT_PTR		PCI_CAP_NEXT_PTR
4327Sjchu #define	PCIE_PCIECAP			0x02	/* PCI-e Capability Reg */
4427Sjchu #define	PCIE_DEVCAP			0x04	/* Device Capability */
4527Sjchu #define	PCIE_DEVCTL			0x08	/* Device Control */
4627Sjchu #define	PCIE_DEVSTS			0x0A	/* Device Status */
471850Sjj156685 #define	PCIE_LINKCAP			0x0C	/* Link Capability */
481850Sjj156685 #define	PCIE_LINKCTL			0x10	/* Link Control */
491850Sjj156685 #define	PCIE_LINKSTS			0x12	/* Link Status */
5027Sjchu #define	PCIE_SLOTCAP			0x14	/* Slot Capability */
5127Sjchu #define	PCIE_SLOTCTL			0x18	/* Slot Control */
5227Sjchu #define	PCIE_SLOTSTS			0x1A	/* Slot Status */
5327Sjchu #define	PCIE_ROOTCTL			0x1C	/* Root Control */
5427Sjchu #define	PCIE_ROOTSTS			0x20	/* Root Status */
5527Sjchu 
5627Sjchu /*
57881Sjohnny  * PCI-Express Config Space size
58881Sjohnny  */
59881Sjohnny #define	PCIE_CONF_HDR_SIZE	4096	/* PCIe configuration header size */
60881Sjohnny 
61881Sjohnny /*
62881Sjohnny  * PCI-Express Capabilities Register (2 bytes)
6327Sjchu  */
6427Sjchu #define	PCIE_PCIECAP_VER_1_0		0x1	/* PCI-E spec 1.0 */
6527Sjchu #define	PCIE_PCIECAP_VER_MASK		0xF	/* Version Mask */
6627Sjchu #define	PCIE_PCIECAP_DEV_TYPE_PCIE_DEV	0x00	/* PCI-E Endpont Device */
6727Sjchu #define	PCIE_PCIECAP_DEV_TYPE_PCI_DEV	0x10	/* Leg PCI Endpont Device */
6827Sjchu #define	PCIE_PCIECAP_DEV_TYPE_ROOT	0x40	/* Root Port of Root Complex */
6927Sjchu #define	PCIE_PCIECAP_DEV_TYPE_UP	0x50	/* Upstream Port of Switch */
7027Sjchu #define	PCIE_PCIECAP_DEV_TYPE_DOWN	0x60	/* Downstream Port of Switch */
7127Sjchu #define	PCIE_PCIECAP_DEV_TYPE_PCIE2PCI	0x70	/* PCI-E to PCI Bridge */
7227Sjchu #define	PCIE_PCIECAP_DEV_TYPE_PCI2PCIE	0x80	/* PCI to PCI-E Bridge */
73*6313Skrishnae #define	PCIE_PCIECAP_DEV_TYPE_RC_IEP	0x90	/* RootComplex Integrated Dev */
74*6313Skrishnae #define	PCIE_PCIECAP_DEV_TYPE_RC_EC	0xA0	/* RootComplex Evt Collector */
7527Sjchu #define	PCIE_PCIECAP_DEV_TYPE_MASK	0xF0	/* Device/Port Type Mask */
7627Sjchu #define	PCIE_PCIECAP_SLOT_IMPL		0x100	/* Slot Impl vs Integrated */
775813Ssuha #define	PCIE_PCIECAP_INT_MSG_NUM	0x3700	/* Interrupt Message Number */
7827Sjchu 
7927Sjchu /*
80881Sjohnny  * Device Capabilities Register (4 bytes)
8127Sjchu  */
8227Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_128	0x0
8327Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_256	0x1
8427Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_512	0x2
8527Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_1024	0x3
8627Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_2048	0x4
8727Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_4096	0x5
8827Sjchu #define	PCIE_DEVCAP_MAX_PAYLOAD_MASK	0x7	/* Max Payload Size Supported */
8927Sjchu 
9027Sjchu #define	PCIE_DEVCAP_PHTM_FUNC_NONE	0x00	/* No Function # bits used */
9127Sjchu #define	PCIE_DEVCAP_PHTM_FUNC_ONE	0x08	/* First most sig. bit used */
9227Sjchu #define	PCIE_DEVCAP_PHTM_FUNC_TWO	0x10	/* First 2 most sig bit used */
9327Sjchu #define	PCIE_DEVCAP_PHTM_FUNC_THREE	0x18	/* All 3 bits used */
9427Sjchu #define	PCIE_DEVCAP_PHTM_FUNC_MASK	0x18	/* Phantom Func Supported */
9527Sjchu 
9627Sjchu #define	PCIE_DEVCAP_EXT_TAG_5BIT	0x00	/* 5-Bit Tag Field Supported */
9727Sjchu #define	PCIE_DEVCAP_EXT_TAG_8BIT	0x20	/* 8-Bit Tag Field Supported */
9827Sjchu #define	PCIE_DEVCAP_EXT_TAG_MASK	0x20	/* Ext. Tag Field Supported */
9927Sjchu 
10027Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_MIN	0x000	/* < 64 ns */
10127Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_64ns	0x040	/* 64 ns - 128 ns */
10227Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_128ns	0x080	/* 128 ns - 256 ns */
10327Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_256ns	0x0C0	/* 256 ns - 512 ns */
10427Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_512ns	0x100	/* 512 ns - 1 us */
10527Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_1us	0x140	/* 1 us - 2 us */
10627Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_2us	0x180	/* 2 us - 4 us */
10727Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_MAX	0x1C0	/* > 4 us */
10827Sjchu #define	PCIE_DEVCAP_EP_L0S_LAT_MASK	0x1C0	/* EP L0s Accetable Latency */
10927Sjchu 
11027Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_MIN	0x000	/* < 1 us */
11127Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_1us	0x140	/* 1 us - 2 us */
11227Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_2us	0x180	/* 2 us - 4 us */
11327Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_4us	0x140	/* 4 us - 8 us */
11427Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_8us	0x180	/* 8 us - 16 us */
11527Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_16us	0x140	/* 16 us - 32 us */
11627Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_32us	0x180	/* 32 us - 64 us */
11727Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_MAX	0x1C0	/* > 64 us */
11827Sjchu #define	PCIE_DEVCAP_EP_L1_LAT_MASK	0x700	/* EP L1 Accetable Latency */
11927Sjchu 
12027Sjchu #define	PCIE_DEVCAP_ATTN_BUTTON		0x1000	/* Attention Button Present */
12127Sjchu #define	PCIE_DEVCAP_ATTN_INDICATOR	0x2000	/* Attn Indicator Present */
12227Sjchu #define	PCIE_DEVCAP_PWR_INDICATOR	0x4000	/* Power Indicator Present */
12327Sjchu 
1243070Sanish #define	PCIE_DEVCAP_ROLE_BASED_ERR_REP	0x8000	/* Role Based Error Reporting */
1253070Sanish 
12627Sjchu #define	PCIE_DEVCAP_PLMT_VAL_SHIFT	18	/* Power Limit Value Shift */
12727Sjchu #define	PCIE_DEVCAP_PLMT_VAL_MASK	0xFF	/* Power Limit Value Mask */
12827Sjchu 
12927Sjchu #define	PCIE_DEVCAP_PLMT_SCL_1_BY_1	0x0000000	/* 1x Scale */
13027Sjchu #define	PCIE_DEVCAP_PLMT_SCL_1_BY_10	0x4000000	/* 0.1x Scale */
13127Sjchu #define	PCIE_DEVCAP_PLMT_SCL_1_BY_100	0x8000000	/* 0.01x Scale */
13227Sjchu #define	PCIE_DEVCAP_PLMT_SCL_1_BY_1000	0xC000000	/* 0.001x Scale */
13327Sjchu #define	PCIE_DEVCAP_PLMT_SCL_MASK	0xC000000	/* Power Limit Scale */
13427Sjchu 
13527Sjchu /*
136881Sjohnny  * Device Control Register (2 bytes)
13727Sjchu  */
13827Sjchu #define	PCIE_DEVCTL_CE_REPORTING_EN	0x1	/* Correctable Error Enable */
13927Sjchu #define	PCIE_DEVCTL_NFE_REPORTING_EN	0x2	/* Non-Fatal Error Enable */
14027Sjchu #define	PCIE_DEVCTL_FE_REPORTING_EN	0x4	/* Fatal Error Enable */
14127Sjchu #define	PCIE_DEVCTL_UR_REPORTING_EN	0x8	/* Unsupported Request Enable */
1423143Sraghuram #define	PCIE_DEVCTL_ERR_MASK		0xF	/* All of the above bits */
1433143Sraghuram 
14427Sjchu #define	PCIE_DEVCTL_RO_EN		0x10	/* Enable Relaxed Ordering */
14527Sjchu 
14627Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_128	0x00
14727Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_256	0x20
14827Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_512	0x40
14927Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_1024	0x60
15027Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_2048	0x80
15127Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_4096	0xA0
15227Sjchu #define	PCIE_DEVCTL_MAX_PAYLOAD_MASK	0xE0	/* Max_Payload_Size */
15327Sjchu 
15427Sjchu #define	PCIE_DEVCTL_EXT_TAG_FIELD_EN	0x100	/* Extended Tag Field Enable */
15527Sjchu #define	PCIE_DEVCTL_PHTM_FUNC_EN	0x200	/* Phantom Functions Enable */
15627Sjchu #define	PCIE_DEVCTL_AUX_POWER_PM_EN	0x400	/* Auxiliary Power PM Enable */
15727Sjchu #define	PCIE_DEVCTL_ENABLE_NO_SNOOP	0x800	/* Enable No Snoop */
15827Sjchu 
1593143Sraghuram #define	PCIE_DEVCTL_MAX_READ_REQ_128	0x0000
1603143Sraghuram #define	PCIE_DEVCTL_MAX_READ_REQ_256	0x1000
1613143Sraghuram #define	PCIE_DEVCTL_MAX_READ_REQ_512	0x2000
1623143Sraghuram #define	PCIE_DEVCTL_MAX_READ_REQ_1024	0x3000
1633143Sraghuram #define	PCIE_DEVCTL_MAX_READ_REQ_2048	0x4000
1643143Sraghuram #define	PCIE_DEVCTL_MAX_READ_REQ_4096	0x5000
16527Sjchu #define	PCIE_DEVCTL_MAX_READ_REQ_MASK	0x7000	/* Max_Read_Request_Size */
16627Sjchu 
16727Sjchu /*
168881Sjohnny  * Device Status Register (2 bytes)
16927Sjchu  */
17027Sjchu #define	PCIE_DEVSTS_CE_DETECTED		0x1	/* Correctable Error Detected */
17127Sjchu #define	PCIE_DEVSTS_NFE_DETECTED	0x2	/* Non Fatal Error Detected */
17227Sjchu #define	PCIE_DEVSTS_FE_DETECTED		0x4	/* Fatal Error Detected */
17327Sjchu #define	PCIE_DEVSTS_UR_DETECTED		0x8	/* Unsupported Req Detected */
17427Sjchu #define	PCIE_DEVSTS_AUX_POWER		0x10	/* AUX Power Detected */
17527Sjchu #define	PCIE_DEVSTS_TRANS_PENDING	0x20	/* Transactions Pending */
17627Sjchu 
17727Sjchu /*
178881Sjohnny  * Link Capability Register (4 bytes)
17927Sjchu  */
18027Sjchu #define	PCIE_LINKCAP_MAX_SPEED_2_5	0x1	/* 2.5 Gb/s Speed */
18127Sjchu #define	PCIE_LINKCAP_MAX_SPEED_MASK	0xF	/* Maximum Link Speed */
18227Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X1	0x010
18327Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X2	0x020
18427Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X4	0x040
18527Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X8	0x080
18627Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X12	0x0C0
18727Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X16	0x100
18827Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_X32	0x200
18927Sjchu #define	PCIE_LINKCAP_MAX_WIDTH_MASK	0x3f0	/* Maximum Link Width */
19027Sjchu 
19127Sjchu #define	PCIE_LINKCAP_ASPM_SUP_L0S	0x400	/* L0s Entry Supported */
19227Sjchu #define	PCIE_LINKCAP_ASPM_SUP_L0S_L1	0xC00	/* L0s abd L1 Supported */
19327Sjchu #define	PCIE_LINKCAP_ASPM_SUP_MASK	0xC00	/* ASPM Support */
19427Sjchu 
19527Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_MIN	0x0000	/* < 64 ns */
19627Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_64ns	0x1000	/* 64 ns - 128 ns */
19727Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_128ns	0x2000	/* 128 ns - 256 ns */
19827Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_256ns	0x3000	/* 256 ns - 512 ns */
19927Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_512ns	0x4000	/* 512 ns - 1 us */
20027Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_1us	0x5000	/* 1 us - 2 us */
20127Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_2us	0x6000	/* 2 us - 4 us */
20227Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_MAX	0x7000	/* > 4 us */
20327Sjchu #define	PCIE_LINKCAP_L0S_EXIT_LAT_MASK	0x7000	/* L0s Exit Latency */
20427Sjchu 
20527Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_MIN	0x00000	/* < 1 us */
20627Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_1us	0x08000	/* 1 us - 2 us */
20727Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_2us	0x10000	/* 2 us - 4 us */
20827Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_4us	0x18000	/* 4 us - 8 us */
20927Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_8us	0x20000	/* 8 us - 16 us */
21027Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_16us	0x28000	/* 16 us - 32 us */
21127Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_32us	0x30000	/* 32 us - 64 us */
21227Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_MAX	0x38000	/* > 64 us */
21327Sjchu #define	PCIE_LINKCAP_L1_EXIT_LAT_MASK	0x38000	/* L1 Exit Latency */
21427Sjchu 
215881Sjohnny /* PCIe v1.1 spec based */
216881Sjohnny #define	PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE	0x100000    /* DLL Active */
217881Sjohnny 							    /* Capable bit */
218881Sjohnny 
21927Sjchu #define	PCIE_LINKCAP_PORT_NUMBER	0xF0000000	/* Port Number */
22027Sjchu 
22127Sjchu /*
222881Sjohnny  * Link Control Register (2 bytes)
22327Sjchu  */
22427Sjchu #define	PCIE_LINKCTL_ASPM_CTL_DIS	0x0	/* ASPM Disable */
22527Sjchu #define	PCIE_LINKCTL_ASPM_CTL_L0S	0x1	/* ASPM L0s only */
22627Sjchu #define	PCIE_LINKCTL_ASPM_CTL_L1	0x2	/* ASPM L1 only */
22727Sjchu #define	PCIE_LINKCTL_ASPM_CTL_L0S_L1	0x3	/* ASPM L0s and L1 only */
22827Sjchu #define	PCIE_LINKCTL_ASPM_CTL_MASK	0x3	/* ASPM Control */
22927Sjchu 
23027Sjchu #define	PCIE_LINKCTL_RCB_64_BYTE	0x0	/* 64 Byte */
23127Sjchu #define	PCIE_LINKCTL_RCB_128_BYTE	0x8	/* 128 Byte */
23227Sjchu #define	PCIE_LINKCTL_RCB_MASK		0x8	/* Read Completion Boundary */
23327Sjchu 
23427Sjchu #define	PCIE_LINKCTL_LINK_DISABLE	0x10	/* Link Disable */
23527Sjchu #define	PCIE_LINKCTL_RETRAIN_LINK	0x20	/* Retrain Link */
23627Sjchu #define	PCIE_LINKCTL_COMMON_CLK_CFG	0x40	/* Common Clock Configuration */
23727Sjchu #define	PCIE_LINKCTL_EXT_SYNCH		0x80	/* Extended Synch */
23827Sjchu 
23927Sjchu /*
240881Sjohnny  * Link Status Register (2 bytes)
24127Sjchu  */
24227Sjchu #define	PCIE_LINKSTS_SPEED_2_5		0x1	/* Link Speed */
24327Sjchu #define	PCIE_LINKSTS_SPEED_MASK		0xF	/* Link Speed */
24427Sjchu 
24527Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X1	0x010
24627Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X2	0x020
24727Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X4	0x040
24827Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X8	0x080
24927Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X12	0x0C0
25027Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X16	0x100
25127Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_X32	0x200
25227Sjchu #define	PCIE_LINKSTS_NEG_WIDTH_MASK	0x3F0	/* Negotiated Link Width */
25327Sjchu 
25427Sjchu #define	PCIE_LINKSTS_TRAINING_ERROR	0x400	/* Training Error */
25527Sjchu #define	PCIE_LINKSTS_LINK_TRAINING	0x800	/* Link Training */
25627Sjchu #define	PCIE_LINKSTS_SLOT_CLK_CFG	0x1000	/* Slot Clock Configuration */
25727Sjchu 
2581786Sjj156685 /* PCIe v1.1 spec based */
2591786Sjj156685 #define	PCIE_LINKSTS_DLL_LINK_ACTIVE	0x2000	/* DLL Link Active */
2601786Sjj156685 
26127Sjchu /*
262881Sjohnny  * Slot Capability Register (4 bytes)
26327Sjchu  */
26427Sjchu #define	PCIE_SLOTCAP_ATTN_BUTTON	0x1	/* Attention Button Present */
26527Sjchu #define	PCIE_SLOTCAP_POWER_CONTROLLER	0x2	/* Power Controller Present */
26627Sjchu #define	PCIE_SLOTCAP_MRL_SENSOR		0x4	/* MRL Sensor Present */
26727Sjchu #define	PCIE_SLOTCAP_ATTN_INDICATOR	0x8	/* Attn Indicator Present */
26827Sjchu #define	PCIE_SLOTCAP_PWR_INDICATOR	0x10	/* Power Indicator Present */
26927Sjchu #define	PCIE_SLOTCAP_HP_SURPRISE	0x20	/* Hot-Plug Surprise */
27027Sjchu #define	PCIE_SLOTCAP_HP_CAPABLE		0x40	/* Hot-Plug Capable */
27127Sjchu 
27227Sjchu #define	PCIE_SLOTCAP_PLMT_VAL_SHIFT	7	/* Slot Pwr Limit Value Shift */
27327Sjchu #define	PCIE_SLOTCAP_PLMT_VAL_MASK	0xFF	/* Slot Pwr Limit Value */
27427Sjchu 
27527Sjchu #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_1	0x00000	/* 1x Scale */
27627Sjchu #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_10	0x08000	/* 0.1x Scale */
27727Sjchu #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_100	0x10000	/* 0.01x Scale */
27827Sjchu #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_1000	0x18000	/* 0.001x Scale */
27927Sjchu #define	PCIE_SLOTCAP_PLMT_SCL_MASK	0x18000	/* Slot Power Limit Scale */
280881Sjohnny #define	PCIE_SLOTCAP_EMI_LOCK_PRESENT	0x20000 /* EMI Lock Present */
281881Sjohnny #define	PCIE_SLOTCAP_NO_CMD_COMP_SUPP	0x40000 /* No Command Comp. Supported */
28227Sjchu 
28327Sjchu #define	PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT	19	/* Physical Slot Num Shift */
28427Sjchu #define	PCIE_SLOTCAP_PHY_SLOT_NUM_MASK	0x1FFF	/* Physical Slot Num Mask */
28527Sjchu 
286881Sjohnny #define	PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \
287881Sjohnny 	    (((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \
288881Sjohnny 	    PCIE_SLOTCAP_PHY_SLOT_NUM_MASK)
289881Sjohnny 
29027Sjchu /*
291881Sjohnny  * Slot Control Register (2 bytes)
29227Sjchu  */
29327Sjchu #define	PCIE_SLOTCTL_ATTN_BTN_EN	0x1	/* Attn Button Pressed Enable */
29427Sjchu #define	PCIE_SLOTCTL_PWR_FAULT_EN	0x2	/* Pwr Fault Detected Enable */
29527Sjchu #define	PCIE_SLOTCTL_MRL_SENSOR_EN	0x4	/* MRL Sensor Changed Enable */
29627Sjchu #define	PCIE_SLOTCTL_PRESENCE_CHANGE_EN	0x8	/* Presence Detect Changed En */
29727Sjchu #define	PCIE_SLOTCTL_CMD_INTR_EN	0x10	/* CMD Completed Interrupt En */
29827Sjchu #define	PCIE_SLOTCTL_HP_INTR_EN		0x20	/* Hot-Plug Interrupt Enable */
299881Sjohnny #define	PCIE_SLOTCTL_PWR_CONTROL	0x0400	/* Power controller Control */
300881Sjohnny #define	PCIE_SLOTCTL_EMI_LOCK_CONTROL	0x0800	/* EMI Lock control */
3011786Sjj156685 #define	PCIE_SLOTCTL_DLL_STATE_EN	0x1000	/* DLL State Changed En */
302881Sjohnny #define	PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0	/* Attn Indicator mask */
303881Sjohnny #define	PCIE_SLOTCTL_PWR_INDICATOR_MASK	0x0300	/* Power Indicator mask */
30427Sjchu 
305881Sjohnny /* State values for the Power and Attention Indicators */
306881Sjohnny #define	PCIE_SLOTCTL_INDICATOR_STATE_ON		0x1	/* indicator ON */
307881Sjohnny #define	PCIE_SLOTCTL_INDICATOR_STATE_BLINK	0x2	/* indicator BLINK */
308881Sjohnny #define	PCIE_SLOTCTL_INDICATOR_STATE_OFF	0x3	/* indicator OFF */
30927Sjchu 
31027Sjchu /*
311881Sjohnny  * Macros to set/get the state of Power and Attention Indicators
312881Sjohnny  * in the PCI Express Slot Control Register.
313881Sjohnny  */
314881Sjohnny #define	pcie_slotctl_pwr_indicator_get(reg)	\
315881Sjohnny 	(((reg) & PCIE_SLOTCTL_PWR_INDICATOR_MASK) >> 8)
316881Sjohnny #define	pcie_slotctl_attn_indicator_get(ctrl)	\
317881Sjohnny 	(((ctrl) & PCIE_SLOTCTL_ATTN_INDICATOR_MASK) >> 6)
318881Sjohnny #define	pcie_slotctl_attn_indicator_set(ctrl, v)\
319881Sjohnny 	(((ctrl) & ~PCIE_SLOTCTL_ATTN_INDICATOR_MASK) | ((v) << 6))
320881Sjohnny #define	pcie_slotctl_pwr_indicator_set(ctrl, v)\
321881Sjohnny 	(((ctrl) & ~PCIE_SLOTCTL_PWR_INDICATOR_MASK) | ((v) << 8))
322881Sjohnny 
323881Sjohnny /*
324881Sjohnny  * Slot Status register (2 bytes)
32527Sjchu  */
32627Sjchu #define	PCIE_SLOTSTS_ATTN_BTN_PRESSED	0x1	/* Attention Button Pressed */
32727Sjchu #define	PCIE_SLOTSTS_PWR_FAULT_DETECTED	0x2	/* Power Fault Detected */
32827Sjchu #define	PCIE_SLOTSTS_MRL_SENSOR_CHANGED	0x4	/* MRL Sensor Changed */
32927Sjchu #define	PCIE_SLOTSTS_PRESENCE_CHANGED	0x8	/* Presence Detect Changed */
33027Sjchu #define	PCIE_SLOTSTS_COMMAND_COMPLETED	0x10	/* Command Completed */
331881Sjohnny #define	PCIE_SLOTSTS_MRL_SENSOR_OPEN	0x20	/* MRL Sensor Open */
33227Sjchu #define	PCIE_SLOTSTS_PRESENCE_DETECTED	0x40	/* Card Present in slot */
333881Sjohnny #define	PCIE_SLOTSTS_EMI_LOCK_SET	0x0080	/* EMI Lock set */
334881Sjohnny #define	PCIE_SLOTSTS_DLL_STATE_CHANGED	0x0100	/* DLL State Changed */
33527Sjchu 
33627Sjchu /*
337881Sjohnny  * Root Control Register (2 bytes)
33827Sjchu  */
33927Sjchu #define	PCIE_ROOTCTL_SYS_ERR_ON_CE_EN	0x1	/* Sys Err on Cor Err Enable */
34027Sjchu #define	PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN	0x2	/* Sys Err on NF Err Enable */
341881Sjohnny #define	PCIE_ROOTCTL_SYS_ERR_ON_FE_EN	0x4	/* Sys Err on Fatal Err En */
342881Sjohnny #define	PCIE_ROOTCTL_PME_INTERRUPT_EN	0x8	/* PME Interrupt Enable */
34327Sjchu 
34427Sjchu /*
345881Sjohnny  * Root Status Register (4 bytes)
34627Sjchu  */
34727Sjchu #define	PCIE_ROOTSTS_PME_REQ_ID_SHIFT	0	/* PME Requestor ID */
34827Sjchu #define	PCIE_ROOTSTS_PME_REQ_ID_MASK	0xFFFF	/* PME Requestor ID */
34927Sjchu 
35027Sjchu #define	PCIE_ROOTSTS_PME_STATUS		0x10000	/* PME Status */
35127Sjchu #define	PCIE_ROOTSTS_PME_PENDING	0x20000	/* PME Pending */
35227Sjchu 
35327Sjchu 
35427Sjchu /*
35527Sjchu  * PCI-Express Enhanced Capabilities Link Entry Bit Offsets
35627Sjchu  */
35727Sjchu #define	PCIE_EXT_CAP			0x100	/* Base Address of Ext Cap */
35827Sjchu 
35927Sjchu #define	PCIE_EXT_CAP_ID_SHIFT		0	/* PCI-e Ext Cap ID */
36027Sjchu #define	PCIE_EXT_CAP_ID_MASK		0xFFFF
36127Sjchu #define	PCIE_EXT_CAP_VER_SHIFT		16	/* PCI-e Ext Cap Ver */
36227Sjchu #define	PCIE_EXT_CAP_VER_MASK		0xF
36327Sjchu #define	PCIE_EXT_CAP_NEXT_PTR_SHIFT	20	/* PCI-e Ext Cap Next Ptr */
36427Sjchu #define	PCIE_EXT_CAP_NEXT_PTR_MASK	0xFFF
36527Sjchu 
36627Sjchu #define	PCIE_EXT_CAP_NEXT_PTR_NULL	0x0
36727Sjchu 
36827Sjchu /*
36927Sjchu  * PCI-Express Enhanced Capability Identifier Values
37027Sjchu  */
37127Sjchu #define	PCIE_EXT_CAP_ID_AER		0x1	/* Advanced Error Handling */
3723070Sanish #define	PCIE_EXT_CAP_ID_VC		0x2	/* Virtual Channel, no MFVC */
37327Sjchu #define	PCIE_EXT_CAP_ID_SER		0x3	/* Serial Number */
37427Sjchu #define	PCIE_EXT_CAP_ID_PWR_BUDGET	0x4	/* Power Budgeting */
3753070Sanish #define	PCIE_EXT_CAP_ID_RC_LINK_DECL	0x5	/* RC Link Declaration */
3763070Sanish #define	PCIE_EXT_CAP_ID_RC_INT_LINKCTRL	0x6	/* RC Internal Link Control */
3773070Sanish #define	PCIE_EXT_CAP_ID_RC_EVNT_CEA	0x7	/* RC Event Collector */
3783070Sanish 						/* Endpoint Association */
3793070Sanish #define	PCIE_EXT_CAP_ID_MFVC		0x8	/* Multi-func Virtual Channel */
3803070Sanish #define	PCIE_EXT_CAP_ID_VC_WITH_MFVC	0x9	/* Virtual Channel w/ MFVC */
3813070Sanish #define	PCIE_EXT_CAP_ID_RCRB		0xA	/* Root Complex Register Blck */
3823070Sanish #define	PCIE_EXT_CAP_ID_VS		0xB	/* Vendor Spec Extended Cap */
3833070Sanish #define	PCIE_EXT_CAP_ID_CAC		0xC	/* Config Access Correlation */
3843070Sanish #define	PCIE_EXT_CAP_ID_ACS		0xD	/* Access Control Services */
3853070Sanish #define	PCIE_EXT_CAP_ID_ARI		0xE	/* Alternative Routing ID */
3863070Sanish #define	PCIE_EXT_CAP_ID_ATS		0xF	/* Address Translation Svcs */
38727Sjchu 
38827Sjchu /*
38927Sjchu  * PCI-Express Advanced Error Reporting Extended Capability Offsets
39027Sjchu  */
39127Sjchu #define	PCIE_AER_CAP			0x0	/* Enhanced Capability Header */
39227Sjchu #define	PCIE_AER_UCE_STS		0x4	/* Uncorrectable Error Status */
39327Sjchu #define	PCIE_AER_UCE_MASK		0x8	/* Uncorrectable Error Mask */
39427Sjchu #define	PCIE_AER_UCE_SERV		0xc	/* Uncor Error Severity */
39527Sjchu #define	PCIE_AER_CE_STS			0x10	/* Correctable Error Status */
39627Sjchu #define	PCIE_AER_CE_MASK		0x14	/* Correctable Error Mask */
39727Sjchu #define	PCIE_AER_CTL			0x18	/* AER Capability & Control */
39827Sjchu #define	PCIE_AER_HDR_LOG		0x1c	/* Header Log */
39927Sjchu 
40027Sjchu /* Root Ports Only */
40127Sjchu #define	PCIE_AER_RE_CMD			0x2c	/* Root Error Command */
40227Sjchu #define	PCIE_AER_RE_STS			0x30	/* Root Error Status */
40327Sjchu #define	PCIE_AER_CE_SRC_ID		0x34	/* Error Source ID */
40427Sjchu #define	PCIE_AER_ERR_SRC_ID		0x36	/* Error Source ID */
40527Sjchu 
40627Sjchu /* Bridges Only */
40727Sjchu #define	PCIE_AER_SUCE_STS		0x2c	/* Secondary UCE Status */
40827Sjchu #define	PCIE_AER_SUCE_MASK		0x30	/* Secondary UCE Mask */
40927Sjchu #define	PCIE_AER_SUCE_SERV		0x34	/* Secondary UCE Severity */
41027Sjchu #define	PCIE_AER_SCTL			0x38	/* Secondary Cap & Ctl */
41127Sjchu #define	PCIE_AER_SHDR_LOG		0x3c	/* Secondary Header Log */
41227Sjchu 
41327Sjchu /*
41427Sjchu  * AER Uncorrectable Error Status/Mask/Severity Register
41527Sjchu  */
4161865Sdilpreet #define	PCIE_AER_UCE_TRAINING		0x1	/* Training Error Status */
41727Sjchu #define	PCIE_AER_UCE_DLP		0x10	/* Data Link Protocol Error */
4181865Sdilpreet #define	PCIE_AER_UCE_SD			0x20	/* Link Surprise down */
41927Sjchu #define	PCIE_AER_UCE_PTLP		0x1000	/* Poisoned TLP Status */
42027Sjchu #define	PCIE_AER_UCE_FCP		0x2000	/* Flow Control Protocol Sts */
42127Sjchu #define	PCIE_AER_UCE_TO			0x4000	/* Completion Timeout Status */
42227Sjchu #define	PCIE_AER_UCE_CA			0x8000	/* Completer Abort Status */
42327Sjchu #define	PCIE_AER_UCE_UC			0x10000	/* Unexpected Completion Sts */
42427Sjchu #define	PCIE_AER_UCE_RO			0x20000	/* Receiver Overflow Status */
42527Sjchu #define	PCIE_AER_UCE_MTLP		0x40000	/* Malformed TLP Status */
42627Sjchu #define	PCIE_AER_UCE_ECRC		0x80000	/* ECRC Error Status */
4271865Sdilpreet #define	PCIE_AER_UCE_UR			0x100000 /* Unsupported Req */
42827Sjchu #define	PCIE_AER_UCE_BITS		(PCIE_AER_UCE_TRAINING | \
4291865Sdilpreet     PCIE_AER_UCE_DLP | PCIE_AER_UCE_SD | PCIE_AER_UCE_PTLP | \
4301865Sdilpreet     PCIE_AER_UCE_FCP | PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | \
4311865Sdilpreet     PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | PCIE_AER_UCE_MTLP | \
4321865Sdilpreet     PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
4331865Sdilpreet #define	PCIE_AER_UCE_LOG_BITS		(PCIE_AER_UCE_PTLP | PCIE_AER_UCE_CA | \
4341865Sdilpreet     PCIE_AER_UCE_UC | PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
43527Sjchu 
43627Sjchu /*
43727Sjchu  * AER Correctable Error Status/Mask Register
43827Sjchu  */
43927Sjchu #define	PCIE_AER_CE_RECEIVER_ERR	0x1	/* Receiver Error Status */
44027Sjchu #define	PCIE_AER_CE_BAD_TLP		0x40	/* Bad TLP Status */
44127Sjchu #define	PCIE_AER_CE_BAD_DLLP		0x80	/* Bad DLLP Status */
44227Sjchu #define	PCIE_AER_CE_REPLAY_ROLLOVER	0x100	/* REPLAY_NUM Rollover Status */
44327Sjchu #define	PCIE_AER_CE_REPLAY_TO		0x1000	/* Replay Timer Timeout Sts */
4441865Sdilpreet #define	PCIE_AER_CE_AD_NFE		0x2000	/* Advisory Non-Fatal Status */
44527Sjchu #define	PCIE_AER_CE_BITS		(PCIE_AER_CE_RECEIVER_ERR | \
44627Sjchu     PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \
44727Sjchu     PCIE_AER_CE_REPLAY_TO)
44827Sjchu 
44927Sjchu /*
45027Sjchu  * AER Capability & Control
45127Sjchu  */
45227Sjchu #define	PCIE_AER_CTL_FST_ERR_PTR_MASK	0x1F	/* First Error Pointer */
45327Sjchu #define	PCIE_AER_CTL_ECRC_GEN_CAP	0x20	/* ECRC Generation Capable */
45427Sjchu #define	PCIE_AER_CTL_ECRC_GEN_ENA	0x40	/* ECRC Generation Enable */
45527Sjchu #define	PCIE_AER_CTL_ECRC_CHECK_CAP	0x80	/* ECRC Check Capable */
45627Sjchu #define	PCIE_AER_CTL_ECRC_CHECK_ENA	0x100	/* ECRC Check Enable */
45727Sjchu 
45827Sjchu /*
45927Sjchu  * AER Root Command Register
46027Sjchu  */
46127Sjchu #define	PCIE_AER_RE_CMD_CE_REP_EN	0x1	/* Correctable Error Enable */
46227Sjchu #define	PCIE_AER_RE_CMD_NFE_REP_EN	0x2	/* Non-Fatal Error Enable */
46327Sjchu #define	PCIE_AER_RE_CMD_FE_REP_EN	0x4	/* Fatal Error Enable */
46427Sjchu 
46527Sjchu /*
46627Sjchu  * AER Root Error Status Register
46727Sjchu  */
46827Sjchu #define	PCIE_AER_RE_STS_CE_RCVD		0x1	/* ERR_COR Received */
46927Sjchu #define	PCIE_AER_RE_STS_MUL_CE_RCVD	0x2	/* Multiple ERR_COR Received */
47027Sjchu #define	PCIE_AER_RE_STS_FE_NFE_RCVD	0x4	/* FATAL/NON-FATAL Received */
47127Sjchu #define	PCIE_AER_RE_STS_MUL_FE_NFE_RCVD	0x8	/* Multiple ERR_F/NF Received */
47227Sjchu #define	PCIE_AER_RE_STS_FIRST_UC_FATAL	0x10	/* First Uncorrectable Fatal */
47327Sjchu #define	PCIE_AER_RE_STS_NFE_MSGS_RCVD	0x20	/* Non-Fatal Error Msgs Rcvd */
47427Sjchu #define	PCIE_AER_RE_STS_FE_MSGS_RCVD	0x40	/* Fatal Error Messages Rcvd */
47527Sjchu 
47627Sjchu #define	PCIE_AER_RE_STS_MSG_NUM_SHIFT	27	/* Offset of Intr Msg Number */
47727Sjchu #define	PCIE_AER_RE_STS_MSG_NUM_MASK	0x1F	/* Intr Msg Number Mask */
47827Sjchu 
47927Sjchu /*
48027Sjchu  * AER Error Source Identification Register
48127Sjchu  */
48227Sjchu #define	PCIE_AER_ERR_SRC_ID_CE_SHIFT	0	/* ERR_COR Source ID */
48327Sjchu #define	PCIE_AER_ERR_SRC_ID_CE_MASK	0xFFFF
48427Sjchu #define	PCIE_AER_ERR_SRC_ID_UE_SHIFT	16	/* ERR_FATAL/NONFATAL Src ID */
485*6313Skrishnae #define	PCIE_AER_ERR_SRC_ID_UE_MASK	0xFFFF
48627Sjchu 
48727Sjchu /*
48827Sjchu  * AER Secondary Uncorrectable Error Register
48927Sjchu  */
49027Sjchu #define	PCIE_AER_SUCE_TA_ON_SC		0x1	/* Target Abort on Split Comp */
49127Sjchu #define	PCIE_AER_SUCE_MA_ON_SC 		0x2	/* Master Abort on Split Comp */
49227Sjchu #define	PCIE_AER_SUCE_RCVD_TA		0x4	/* Received Target Abort */
49327Sjchu #define	PCIE_AER_SUCE_RCVD_MA 		0x8	/* Received Master Abort */
49427Sjchu #define	PCIE_AER_SUCE_USC_ERR 		0x20	/* Unexpected Split Comp Err */
49527Sjchu #define	PCIE_AER_SUCE_USC_MSG_DATA_ERR	0x40	/* USC Message Data Error */
49627Sjchu #define	PCIE_AER_SUCE_UC_DATA_ERR	0x80	/* Uncorrectable Data Error */
49727Sjchu #define	PCIE_AER_SUCE_UC_ATTR_ERR	0x100	/* UC Attribute Err */
49827Sjchu #define	PCIE_AER_SUCE_UC_ADDR_ERR	0x200	/* Uncorrectable Address Err */
49927Sjchu #define	PCIE_AER_SUCE_TIMER_EXPIRED	0x400	/* Delayed xtion discard */
50027Sjchu #define	PCIE_AER_SUCE_PERR_ASSERT	0x800	/* PERR Assertion Detected */
50127Sjchu #define	PCIE_AER_SUCE_SERR_ASSERT	0x1000	/* SERR Assertion Detected */
50227Sjchu #define	PCIE_AER_SUCE_INTERNAL_ERR	0x2000	/* Internal Bridge Err Detect */
5031865Sdilpreet 
5041865Sdilpreet #define	PCIE_AER_SUCE_HDR_CMD_LWR_MASK	0xF	/* Lower Command Mask */
5051865Sdilpreet #define	PCIE_AER_SUCE_HDR_CMD_LWR_SHIFT	4	/* Lower Command Shift */
5061865Sdilpreet #define	PCIE_AER_SUCE_HDR_CMD_UP_MASK	0xF	/* Upper Command Mask */
5071865Sdilpreet #define	PCIE_AER_SUCE_HDR_CMD_UP_SHIFT	8	/* Upper Command Shift */
5081865Sdilpreet #define	PCIE_AER_SUCE_HDR_ADDR_SHIFT	32	/* Upper Command Shift */
5091865Sdilpreet 
51027Sjchu #define	PCIE_AER_SUCE_BITS		(PCIE_AER_SUCE_TA_ON_SC | \
51127Sjchu     PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
51227Sjchu     PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
51327Sjchu     PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
51427Sjchu     PCIE_AER_SUCE_UC_ADDR_ERR |	PCIE_AER_SUCE_TIMER_EXPIRED | \
51527Sjchu     PCIE_AER_SUCE_PERR_ASSERT |	PCIE_AER_SUCE_SERR_ASSERT | \
51627Sjchu     PCIE_AER_SUCE_INTERNAL_ERR)
5171865Sdilpreet #define	PCIE_AER_SUCE_LOG_BITS		(PCIE_AER_SUCE_TA_ON_SC | \
5181865Sdilpreet     PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
5191865Sdilpreet     PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
5201865Sdilpreet     PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
5211865Sdilpreet     PCIE_AER_SUCE_UC_ADDR_ERR |	PCIE_AER_SUCE_PERR_ASSERT)
52227Sjchu 
52327Sjchu /*
52427Sjchu  * AER Secondary Capability & Control
52527Sjchu  */
52627Sjchu #define	PCIE_AER_SCTL_FST_ERR_PTR_MASK	0x1F	/* First Error Pointer */
52727Sjchu 
52827Sjchu /*
52927Sjchu  * AER Secondary Headers
53027Sjchu  * The Secondary Header Logs is 4 DW long.
53127Sjchu  * The first 2 DW are split into 3 sections
53227Sjchu  * o Transaction Attribute
53327Sjchu  * o Transaction Command Lower
53427Sjchu  * o Transaction Command Higher
53527Sjchu  * The last 2 DW is the Transaction Address
53627Sjchu  */
53727Sjchu #define	PCIE_AER_SHDR_LOG_ATTR_MASK	0xFFFFFFFFF
53827Sjchu #define	PCIE_AER_SHDR_LOG_CMD_LOW_MASK	0xF000000000
53927Sjchu #define	PCIE_AER_SHDR_LOG_CMD_HIGH_MASK	0xF0000000000
54027Sjchu #define	PCIE_AER_SHDR_LOG_ADDR_MASK	0xFFFFFFFFFFFFFFFF
54127Sjchu 
54227Sjchu /*
5433162Sgovinda  * PCI-Express Device Serial Number Capability Offsets.
5443162Sgovinda  */
5453162Sgovinda #define	PCIE_SER_CAP		0x0	/* Enhanced Capability Header */
5463162Sgovinda #define	PCIE_SER_SID_LOWER_DW	0x4	/* Lower 32-bit Serial Number */
5473162Sgovinda #define	PCIE_SER_SID_UPPER_DW	0x8	/* Upper 32-bit Serial Number */
5483162Sgovinda 
5493162Sgovinda /*
55027Sjchu  * PCI-E Common TLP Header Fields
55127Sjchu  */
5521865Sdilpreet #define	PCIE_TLP_FMT_3DW	0x00
55327Sjchu #define	PCIE_TLP_FMT_4DW	0x20
55427Sjchu #define	PCIE_TLP_FMT_3DW_DATA	0x40
55527Sjchu #define	PCIE_TLP_FMT_4DW_DATA	0x60
55627Sjchu 
55727Sjchu #define	PCIE_TLP_TYPE_MEM	0x0
55827Sjchu #define	PCIE_TLP_TYPE_MEMLK	0x1
5591865Sdilpreet #define	PCIE_TLP_TYPE_IO	0x2
56027Sjchu #define	PCIE_TLP_TYPE_CFG0	0x4
56127Sjchu #define	PCIE_TLP_TYPE_CFG1	0x5
5621865Sdilpreet #define	PCIE_TLP_TYPE_MSG	0x10
56327Sjchu #define	PCIE_TLP_TYPE_CPL	0xA
56427Sjchu #define	PCIE_TLP_TYPE_CPLLK	0xB
56527Sjchu #define	PCIE_TLP_TYPE_MSI	0x18
56627Sjchu 
56727Sjchu #define	PCIE_TLP_MRD3		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM)
56827Sjchu #define	PCIE_TLP_MRD4		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM)
56927Sjchu #define	PCIE_TLP_MRDLK3		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK)
57027Sjchu #define	PCIE_TLP_MRDLK4		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK)
57127Sjchu #define	PCIE_TLP_MRDWR3		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM)
57227Sjchu #define	PCIE_TLP_MRDWR4		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM)
5731865Sdilpreet #define	PCIE_TLP_IORD		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO)
5741865Sdilpreet #define	PCIE_TLP_IOWR		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO)
57527Sjchu #define	PCIE_TLP_CFGRD0		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0)
57627Sjchu #define	PCIE_TLP_CFGWR0		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0)
57727Sjchu #define	PCIE_TLP_CFGRD1		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1)
57827Sjchu #define	PCIE_TLP_CFGWR1		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1)
5791865Sdilpreet #define	PCIE_TLP_MSG		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG)
5801865Sdilpreet #define	PCIE_TLP_MSGD		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG)
58127Sjchu #define	PCIE_TLP_CPL		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL)
58227Sjchu #define	PCIE_TLP_CPLD		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL)
58327Sjchu #define	PCIE_TLP_CPLLK		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK)
58427Sjchu #define	PCIE_TLP_CPLDLK		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK)
58527Sjchu #define	PCIE_TLP_MSI32		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI)
58627Sjchu #define	PCIE_TLP_MSI64		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI)
58727Sjchu 
58827Sjchu typedef uint16_t pcie_req_id_t;
58927Sjchu 
59027Sjchu #define	PCIE_REQ_ID_BUS_SHIFT	8
59127Sjchu #define	PCIE_REQ_ID_BUS_MASK	0xFF00
59227Sjchu #define	PCIE_REQ_ID_DEV_SHIFT	3
59327Sjchu #define	PCIE_REQ_ID_DEV_MASK	0x00F1
59427Sjchu #define	PCIE_REQ_ID_FUNC_SHIFT	0
59527Sjchu #define	PCIE_REQ_ID_FUNC_MASK	0x0007
59627Sjchu 
5973274Set142600 #define	PCIE_CPL_STS_SUCCESS	0
5983274Set142600 #define	PCIE_CPL_STS_UR		1
5993274Set142600 #define	PCIE_CPL_STS_CRS	2
6003274Set142600 #define	PCIE_CPL_STS_CA		4
6013274Set142600 
6021865Sdilpreet #if defined(_BIT_FIELDS_LTOH)
6031865Sdilpreet /*
6041865Sdilpreet  * PCI Express little-endian common TLP header format
6051865Sdilpreet  */
6061865Sdilpreet typedef struct pcie_tlp_hdr {
6071865Sdilpreet 	uint32_t	len	:10,
6081865Sdilpreet 			rsvd3   :2,
6091865Sdilpreet 			attr    :2,
6101865Sdilpreet 			ep	:1,
6111865Sdilpreet 			td	:1,
6121865Sdilpreet 			rsvd2   :4,
6131865Sdilpreet 			tc	:3,
6141865Sdilpreet 			rsvd1   :1,
6151865Sdilpreet 			type    :5,
6161865Sdilpreet 			fmt	:2,
6171865Sdilpreet 			rsvd0   :1;
6181865Sdilpreet } pcie_tlp_hdr_t;
6191865Sdilpreet 
6201865Sdilpreet typedef struct pcie_mem64 {
6211865Sdilpreet 	uint32_t	fbe	:4,
6221865Sdilpreet 			lbe	:4,
6231865Sdilpreet 			tag	:8,
6241865Sdilpreet 			rid	:16;
6251865Sdilpreet 	uint32_t	addr1;
6261865Sdilpreet 	uint32_t	rsvd0   :2,
6271865Sdilpreet 			addr0   :30;
6281865Sdilpreet } pcie_mem64_t;
6291865Sdilpreet 
6301865Sdilpreet typedef struct pcie_memio32 {
6311865Sdilpreet 	uint32_t	fbe	:4,
6321865Sdilpreet 			lbe	:4,
6331865Sdilpreet 			tag	:8,
6341865Sdilpreet 			rid	:16;
6351865Sdilpreet 	uint32_t	rsvd0   :2,
6361865Sdilpreet 			addr0   :30;
6371865Sdilpreet } pcie_memio32_t;
6381865Sdilpreet 
6391865Sdilpreet typedef struct pcie_cfg {
6401865Sdilpreet 	uint32_t	fbe	:4,
6411865Sdilpreet 			lbe	:4,
6421865Sdilpreet 			tag	:8,
6431865Sdilpreet 			rid	:16;
6441865Sdilpreet 	uint32_t	rsvd1   :2,
6451865Sdilpreet 			reg	:6,
6461865Sdilpreet 			extreg  :4,
6471865Sdilpreet 			rsvd0   :4,
6481865Sdilpreet 			func    :3,
6491865Sdilpreet 			dev	:5,
6501865Sdilpreet 			bus	:8;
6511865Sdilpreet } pcie_cfg_t;
6521865Sdilpreet 
6531865Sdilpreet typedef struct pcie_cpl {
6541865Sdilpreet 	uint32_t	bc	:12,
6551865Sdilpreet 			bcm	:1,
6561865Sdilpreet 			status  :3,
6571865Sdilpreet 			cid	:16;
6581865Sdilpreet 	uint32_t	laddr   :7,
6591865Sdilpreet 			rsvd0   :1,
6601865Sdilpreet 			tag	:8,
6611865Sdilpreet 			rid	:16;
6621865Sdilpreet } pcie_cpl_t;
6631865Sdilpreet 
66427Sjchu /*
66527Sjchu  * PCI-Express Message Request Header
66627Sjchu  */
66727Sjchu typedef struct pcie_msg {
6681865Sdilpreet 	uint32_t	msg_code:8,	/* DW1 */
6691865Sdilpreet 			tag	:8,
6701865Sdilpreet 			rid	:16;
6711865Sdilpreet 	uint32_t	unused[2];	/* DW 2 & 3 */
6721865Sdilpreet } pcie_msg_t;
6731865Sdilpreet 
6741865Sdilpreet #elif defined(_BIT_FIELDS_HTOL)
6751865Sdilpreet /*
6761865Sdilpreet  * PCI Express big-endian common TLP header format
6771865Sdilpreet  */
6781865Sdilpreet typedef struct pcie_tlp_hdr {
6791865Sdilpreet 	uint32_t	rsvd0	:1,
6801865Sdilpreet 			fmt	:2,
6811865Sdilpreet 			type	:5,
6821865Sdilpreet 			rsvd1	:1,
6831865Sdilpreet 			tc	:3,
6841865Sdilpreet 			rsvd2	:4,
68527Sjchu 			td	:1,
68627Sjchu 			ep	:1,
68727Sjchu 			attr	:2,
6881865Sdilpreet 			rsvd3	:2,
68927Sjchu 			len	:10;
6901865Sdilpreet } pcie_tlp_hdr_t;
6911865Sdilpreet 
6921865Sdilpreet typedef struct pcie_mem64 {
6931865Sdilpreet 	uint32_t	rid	:16,
6941865Sdilpreet 			tag	:8,
6951865Sdilpreet 			lbe	:4,
6961865Sdilpreet 			fbe	:4;
6971865Sdilpreet 	uint32_t	addr1;
6981865Sdilpreet 	uint32_t	addr0	:30,
6991865Sdilpreet 			rsvd0	:2;
7001865Sdilpreet } pcie_mem64_t;
7011865Sdilpreet 
7021865Sdilpreet typedef struct pcie_memio32 {
7031865Sdilpreet 	uint32_t	rid	:16,
7041865Sdilpreet 			tag	:8,
7051865Sdilpreet 			lbe	:4,
7061865Sdilpreet 			fbe	:4;
7071865Sdilpreet 	uint32_t	addr0	:30,
7081865Sdilpreet 			rsvd0	:2;
7091865Sdilpreet } pcie_memio32_t;
7101865Sdilpreet 
7111865Sdilpreet typedef struct pcie_cfg {
7121865Sdilpreet 	uint32_t	rid	:16,
7131865Sdilpreet 			tag	:8,
7141865Sdilpreet 			lbe	:4,
7151865Sdilpreet 			fbe	:4;
7161865Sdilpreet 	uint32_t	bus	:8,
7171865Sdilpreet 			dev	:5,
7181865Sdilpreet 			func	:3,
7191865Sdilpreet 			rsvd0	:4,
7201865Sdilpreet 			extreg	:4,
7211865Sdilpreet 			reg	:6,
7221865Sdilpreet 			rsvd1	:2;
7231865Sdilpreet } pcie_cfg_t;
7241865Sdilpreet 
7251865Sdilpreet typedef struct pcie_cpl {
7261865Sdilpreet 	uint32_t	cid	:16,
7271865Sdilpreet 			status	:3,
7281865Sdilpreet 			bcm	:1,
7291865Sdilpreet 			bc	:12;
7301865Sdilpreet 	uint32_t	rid	:16,
7311865Sdilpreet 			tag	:8,
7321865Sdilpreet 			rsvd0	:1,
7331865Sdilpreet 			laddr	:7;
7341865Sdilpreet } pcie_cpl_t;
7351865Sdilpreet 
7361865Sdilpreet /*
7371865Sdilpreet  * PCI-Express Message Request Header
7381865Sdilpreet  */
7391865Sdilpreet typedef struct pcie_msg {
74027Sjchu 	uint32_t	rid	:16,	/* DW1 */
74127Sjchu 			tag	:8,
74227Sjchu 			msg_code:8;
74327Sjchu 	uint32_t	unused[2];	/* DW 2 & 3 */
74427Sjchu } pcie_msg_t;
7451865Sdilpreet #else
7461865Sdilpreet #error "bit field not defined"
7471865Sdilpreet #endif
74827Sjchu 
74927Sjchu #define	PCIE_MSG_CODE_ERR_COR		0x30
75027Sjchu #define	PCIE_MSG_CODE_ERR_NONFATAL	0x31
75127Sjchu #define	PCIE_MSG_CODE_ERR_FATAL		0x33
75227Sjchu 
75327Sjchu #ifdef	__cplusplus
75427Sjchu }
75527Sjchu #endif
75627Sjchu 
75727Sjchu #endif	/* _SYS_PCIE_H */
758