xref: /illumos-gate/usr/src/uts/common/sys/pcie.h (revision 956e8222f10bf55e45b41d8b56084f72ebc113c9)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_PCIE_H
28 #define	_SYS_PCIE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/pci.h>
37 
38 /*
39  * PCI-Express Capability Registers Offsets
40  */
41 #define	PCIE_CAP_ID			PCI_CAP_ID
42 #define	PCIE_CAP_NEXT_PTR		PCI_CAP_NEXT_PTR
43 #define	PCIE_PCIECAP			0x02	/* PCI-e Capability Reg */
44 #define	PCIE_DEVCAP			0x04	/* Device Capability */
45 #define	PCIE_DEVCTL			0x08	/* Device Control */
46 #define	PCIE_DEVSTS			0x0A	/* Device Status */
47 #define	PCIE_LINKCAP			0x04	/* Link Capability */
48 #define	PCIE_LINKCTL			0x0C	/* Link Control */
49 #define	PCIE_LINKSTS			0x10	/* Link Status */
50 #define	PCIE_SLOTCAP			0x14	/* Slot Capability */
51 #define	PCIE_SLOTCTL			0x18	/* Slot Control */
52 #define	PCIE_SLOTSTS			0x1A	/* Slot Status */
53 #define	PCIE_ROOTCTL			0x1C	/* Root Control */
54 #define	PCIE_ROOTSTS			0x20	/* Root Status */
55 
56 /*
57  * PCI-Express Capabilities Register
58  */
59 #define	PCIE_PCIECAP_VER_1_0		0x1	/* PCI-E spec 1.0 */
60 #define	PCIE_PCIECAP_VER_MASK		0xF	/* Version Mask */
61 #define	PCIE_PCIECAP_DEV_TYPE_PCIE_DEV	0x00	/* PCI-E Endpont Device */
62 #define	PCIE_PCIECAP_DEV_TYPE_PCI_DEV	0x10	/* Leg PCI Endpont Device */
63 #define	PCIE_PCIECAP_DEV_TYPE_ROOT	0x40	/* Root Port of Root Complex */
64 #define	PCIE_PCIECAP_DEV_TYPE_UP	0x50	/* Upstream Port of Switch */
65 #define	PCIE_PCIECAP_DEV_TYPE_DOWN	0x60	/* Downstream Port of Switch */
66 #define	PCIE_PCIECAP_DEV_TYPE_PCIE2PCI	0x70	/* PCI-E to PCI Bridge */
67 #define	PCIE_PCIECAP_DEV_TYPE_PCI2PCIE	0x80	/* PCI to PCI-E Bridge */
68 #define	PCIE_PCIECAP_DEV_TYPE_MASK	0xF0	/* Device/Port Type Mask */
69 #define	PCIE_PCIECAP_SLOT_IMPL		0x100	/* Slot Impl vs Integrated */
70 #define	PCIE_PCIECAP_INT_MSG_NUM	0x3700	/* Interrupt Message Number */
71 
72 /*
73  * Device Capabilities Register
74  */
75 #define	PCIE_DEVCAP_MAX_PAYLOAD_128	0x0
76 #define	PCIE_DEVCAP_MAX_PAYLOAD_256	0x1
77 #define	PCIE_DEVCAP_MAX_PAYLOAD_512	0x2
78 #define	PCIE_DEVCAP_MAX_PAYLOAD_1024	0x3
79 #define	PCIE_DEVCAP_MAX_PAYLOAD_2048	0x4
80 #define	PCIE_DEVCAP_MAX_PAYLOAD_4096	0x5
81 #define	PCIE_DEVCAP_MAX_PAYLOAD_MASK	0x7	/* Max Payload Size Supported */
82 
83 #define	PCIE_DEVCAP_PHTM_FUNC_NONE	0x00	/* No Function # bits used */
84 #define	PCIE_DEVCAP_PHTM_FUNC_ONE	0x08	/* First most sig. bit used */
85 #define	PCIE_DEVCAP_PHTM_FUNC_TWO	0x10	/* First 2 most sig bit used */
86 #define	PCIE_DEVCAP_PHTM_FUNC_THREE	0x18	/* All 3 bits used */
87 #define	PCIE_DEVCAP_PHTM_FUNC_MASK	0x18	/* Phantom Func Supported */
88 
89 #define	PCIE_DEVCAP_EXT_TAG_5BIT	0x00	/* 5-Bit Tag Field Supported */
90 #define	PCIE_DEVCAP_EXT_TAG_8BIT	0x20	/* 8-Bit Tag Field Supported */
91 #define	PCIE_DEVCAP_EXT_TAG_MASK	0x20	/* Ext. Tag Field Supported */
92 
93 #define	PCIE_DEVCAP_EP_L0S_LAT_MIN	0x000	/* < 64 ns */
94 #define	PCIE_DEVCAP_EP_L0S_LAT_64ns	0x040	/* 64 ns - 128 ns */
95 #define	PCIE_DEVCAP_EP_L0S_LAT_128ns	0x080	/* 128 ns - 256 ns */
96 #define	PCIE_DEVCAP_EP_L0S_LAT_256ns	0x0C0	/* 256 ns - 512 ns */
97 #define	PCIE_DEVCAP_EP_L0S_LAT_512ns	0x100	/* 512 ns - 1 us */
98 #define	PCIE_DEVCAP_EP_L0S_LAT_1us	0x140	/* 1 us - 2 us */
99 #define	PCIE_DEVCAP_EP_L0S_LAT_2us	0x180	/* 2 us - 4 us */
100 #define	PCIE_DEVCAP_EP_L0S_LAT_MAX	0x1C0	/* > 4 us */
101 #define	PCIE_DEVCAP_EP_L0S_LAT_MASK	0x1C0	/* EP L0s Accetable Latency */
102 
103 #define	PCIE_DEVCAP_EP_L1_LAT_MIN	0x000	/* < 1 us */
104 #define	PCIE_DEVCAP_EP_L1_LAT_1us	0x140	/* 1 us - 2 us */
105 #define	PCIE_DEVCAP_EP_L1_LAT_2us	0x180	/* 2 us - 4 us */
106 #define	PCIE_DEVCAP_EP_L1_LAT_4us	0x140	/* 4 us - 8 us */
107 #define	PCIE_DEVCAP_EP_L1_LAT_8us	0x180	/* 8 us - 16 us */
108 #define	PCIE_DEVCAP_EP_L1_LAT_16us	0x140	/* 16 us - 32 us */
109 #define	PCIE_DEVCAP_EP_L1_LAT_32us	0x180	/* 32 us - 64 us */
110 #define	PCIE_DEVCAP_EP_L1_LAT_MAX	0x1C0	/* > 64 us */
111 #define	PCIE_DEVCAP_EP_L1_LAT_MASK	0x700	/* EP L1 Accetable Latency */
112 
113 #define	PCIE_DEVCAP_ATTN_BUTTON		0x1000	/* Attention Button Present */
114 #define	PCIE_DEVCAP_ATTN_INDICATOR	0x2000	/* Attn Indicator Present */
115 #define	PCIE_DEVCAP_PWR_INDICATOR	0x4000	/* Power Indicator Present */
116 
117 #define	PCIE_DEVCAP_PLMT_VAL_SHIFT	18	/* Power Limit Value Shift */
118 #define	PCIE_DEVCAP_PLMT_VAL_MASK	0xFF	/* Power Limit Value Mask */
119 
120 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_1	0x0000000	/* 1x Scale */
121 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_10	0x4000000	/* 0.1x Scale */
122 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_100	0x8000000	/* 0.01x Scale */
123 #define	PCIE_DEVCAP_PLMT_SCL_1_BY_1000	0xC000000	/* 0.001x Scale */
124 #define	PCIE_DEVCAP_PLMT_SCL_MASK	0xC000000	/* Power Limit Scale */
125 
126 /*
127  * Device Control Register
128  */
129 #define	PCIE_DEVCTL_CE_REPORTING_EN	0x1	/* Correctable Error Enable */
130 #define	PCIE_DEVCTL_NFE_REPORTING_EN	0x2	/* Non-Fatal Error Enable */
131 #define	PCIE_DEVCTL_FE_REPORTING_EN	0x4	/* Fatal Error Enable */
132 #define	PCIE_DEVCTL_UR_REPORTING_EN	0x8	/* Unsupported Request Enable */
133 #define	PCIE_DEVCTL_RO_EN		0x10	/* Enable Relaxed Ordering */
134 
135 #define	PCIE_DEVCTL_MAX_PAYLOAD_128	0x00
136 #define	PCIE_DEVCTL_MAX_PAYLOAD_256	0x20
137 #define	PCIE_DEVCTL_MAX_PAYLOAD_512	0x40
138 #define	PCIE_DEVCTL_MAX_PAYLOAD_1024	0x60
139 #define	PCIE_DEVCTL_MAX_PAYLOAD_2048	0x80
140 #define	PCIE_DEVCTL_MAX_PAYLOAD_4096	0xA0
141 #define	PCIE_DEVCTL_MAX_PAYLOAD_MASK	0xE0	/* Max_Payload_Size */
142 
143 #define	PCIE_DEVCTL_EXT_TAG_FIELD_EN	0x100	/* Extended Tag Field Enable */
144 #define	PCIE_DEVCTL_PHTM_FUNC_EN	0x200	/* Phantom Functions Enable */
145 #define	PCIE_DEVCTL_AUX_POWER_PM_EN	0x400	/* Auxiliary Power PM Enable */
146 #define	PCIE_DEVCTL_ENABLE_NO_SNOOP	0x800	/* Enable No Snoop */
147 
148 #define	PCIE_DEVCTL_MAX_READ_REQ_128	0x00
149 #define	PCIE_DEVCTL_MAX_READ_REQ_256	0x10
150 #define	PCIE_DEVCTL_MAX_READ_REQ_512	0x20
151 #define	PCIE_DEVCTL_MAX_READ_REQ_1024	0x30
152 #define	PCIE_DEVCTL_MAX_READ_REQ_2048	0x40
153 #define	PCIE_DEVCTL_MAX_READ_REQ_4096	0x50
154 #define	PCIE_DEVCTL_MAX_READ_REQ_MASK	0x7000	/* Max_Read_Request_Size */
155 
156 /*
157  * Device Status Register
158  */
159 #define	PCIE_DEVSTS_CE_DETECTED		0x1	/* Correctable Error Detected */
160 #define	PCIE_DEVSTS_NFE_DETECTED	0x2	/* Non Fatal Error Detected */
161 #define	PCIE_DEVSTS_FE_DETECTED		0x4	/* Fatal Error Detected */
162 #define	PCIE_DEVSTS_UR_DETECTED		0x8	/* Unsupported Req Detected */
163 #define	PCIE_DEVSTS_AUX_POWER		0x10	/* AUX Power Detected */
164 #define	PCIE_DEVSTS_TRANS_PENDING	0x20	/* Transactions Pending */
165 
166 /*
167  * Link Capability Register
168  */
169 #define	PCIE_LINKCAP_MAX_SPEED_2_5	0x1	/* 2.5 Gb/s Speed */
170 #define	PCIE_LINKCAP_MAX_SPEED_MASK	0xF	/* Maximum Link Speed */
171 #define	PCIE_LINKCAP_MAX_WIDTH_X1	0x010
172 #define	PCIE_LINKCAP_MAX_WIDTH_X2	0x020
173 #define	PCIE_LINKCAP_MAX_WIDTH_X4	0x040
174 #define	PCIE_LINKCAP_MAX_WIDTH_X8	0x080
175 #define	PCIE_LINKCAP_MAX_WIDTH_X12	0x0C0
176 #define	PCIE_LINKCAP_MAX_WIDTH_X16	0x100
177 #define	PCIE_LINKCAP_MAX_WIDTH_X32	0x200
178 #define	PCIE_LINKCAP_MAX_WIDTH_MASK	0x3f0	/* Maximum Link Width */
179 
180 #define	PCIE_LINKCAP_ASPM_SUP_L0S	0x400	/* L0s Entry Supported */
181 #define	PCIE_LINKCAP_ASPM_SUP_L0S_L1	0xC00	/* L0s abd L1 Supported */
182 #define	PCIE_LINKCAP_ASPM_SUP_MASK	0xC00	/* ASPM Support */
183 
184 #define	PCIE_LINKCAP_L0S_EXIT_LAT_MIN	0x0000	/* < 64 ns */
185 #define	PCIE_LINKCAP_L0S_EXIT_LAT_64ns	0x1000	/* 64 ns - 128 ns */
186 #define	PCIE_LINKCAP_L0S_EXIT_LAT_128ns	0x2000	/* 128 ns - 256 ns */
187 #define	PCIE_LINKCAP_L0S_EXIT_LAT_256ns	0x3000	/* 256 ns - 512 ns */
188 #define	PCIE_LINKCAP_L0S_EXIT_LAT_512ns	0x4000	/* 512 ns - 1 us */
189 #define	PCIE_LINKCAP_L0S_EXIT_LAT_1us	0x5000	/* 1 us - 2 us */
190 #define	PCIE_LINKCAP_L0S_EXIT_LAT_2us	0x6000	/* 2 us - 4 us */
191 #define	PCIE_LINKCAP_L0S_EXIT_LAT_MAX	0x7000	/* > 4 us */
192 #define	PCIE_LINKCAP_L0S_EXIT_LAT_MASK	0x7000	/* L0s Exit Latency */
193 
194 #define	PCIE_LINKCAP_L1_EXIT_LAT_MIN	0x00000	/* < 1 us */
195 #define	PCIE_LINKCAP_L1_EXIT_LAT_1us	0x08000	/* 1 us - 2 us */
196 #define	PCIE_LINKCAP_L1_EXIT_LAT_2us	0x10000	/* 2 us - 4 us */
197 #define	PCIE_LINKCAP_L1_EXIT_LAT_4us	0x18000	/* 4 us - 8 us */
198 #define	PCIE_LINKCAP_L1_EXIT_LAT_8us	0x20000	/* 8 us - 16 us */
199 #define	PCIE_LINKCAP_L1_EXIT_LAT_16us	0x28000	/* 16 us - 32 us */
200 #define	PCIE_LINKCAP_L1_EXIT_LAT_32us	0x30000	/* 32 us - 64 us */
201 #define	PCIE_LINKCAP_L1_EXIT_LAT_MAX	0x38000	/* > 64 us */
202 #define	PCIE_LINKCAP_L1_EXIT_LAT_MASK	0x38000	/* L1 Exit Latency */
203 
204 #define	PCIE_LINKCAP_PORT_NUMBER	0xF0000000	/* Port Number */
205 
206 /*
207  * Link Control Register
208  */
209 #define	PCIE_LINKCTL_ASPM_CTL_DIS	0x0	/* ASPM Disable */
210 #define	PCIE_LINKCTL_ASPM_CTL_L0S	0x1	/* ASPM L0s only */
211 #define	PCIE_LINKCTL_ASPM_CTL_L1	0x2	/* ASPM L1 only */
212 #define	PCIE_LINKCTL_ASPM_CTL_L0S_L1	0x3	/* ASPM L0s and L1 only */
213 #define	PCIE_LINKCTL_ASPM_CTL_MASK	0x3	/* ASPM Control */
214 
215 #define	PCIE_LINKCTL_RCB_64_BYTE	0x0	/* 64 Byte */
216 #define	PCIE_LINKCTL_RCB_128_BYTE	0x8	/* 128 Byte */
217 #define	PCIE_LINKCTL_RCB_MASK		0x8	/* Read Completion Boundary */
218 
219 #define	PCIE_LINKCTL_LINK_DISABLE	0x10	/* Link Disable */
220 #define	PCIE_LINKCTL_RETRAIN_LINK	0x20	/* Retrain Link */
221 #define	PCIE_LINKCTL_COMMON_CLK_CFG	0x40	/* Common Clock Configuration */
222 #define	PCIE_LINKCTL_EXT_SYNCH		0x80	/* Extended Synch */
223 
224 /*
225  * Link Status Register
226  */
227 #define	PCIE_LINKSTS_SPEED_2_5		0x1	/* Link Speed */
228 #define	PCIE_LINKSTS_SPEED_MASK		0xF	/* Link Speed */
229 
230 #define	PCIE_LINKSTS_NEG_WIDTH_X1	0x010
231 #define	PCIE_LINKSTS_NEG_WIDTH_X2	0x020
232 #define	PCIE_LINKSTS_NEG_WIDTH_X4	0x040
233 #define	PCIE_LINKSTS_NEG_WIDTH_X8	0x080
234 #define	PCIE_LINKSTS_NEG_WIDTH_X12	0x0C0
235 #define	PCIE_LINKSTS_NEG_WIDTH_X16	0x100
236 #define	PCIE_LINKSTS_NEG_WIDTH_X32	0x200
237 #define	PCIE_LINKSTS_NEG_WIDTH_MASK	0x3F0	/* Negotiated Link Width */
238 
239 #define	PCIE_LINKSTS_TRAINING_ERROR	0x400	/* Training Error */
240 #define	PCIE_LINKSTS_LINK_TRAINING	0x800	/* Link Training */
241 #define	PCIE_LINKSTS_SLOT_CLK_CFG	0x1000	/* Slot Clock Configuration */
242 
243 /*
244  * Slot Capability Register
245  */
246 #define	PCIE_SLOTCAP_ATTN_BUTTON	0x1	/* Attention Button Present */
247 #define	PCIE_SLOTCAP_POWER_CONTROLLER	0x2	/* Power Controller Present */
248 #define	PCIE_SLOTCAP_MRL_SENSOR		0x4	/* MRL Sensor Present */
249 #define	PCIE_SLOTCAP_ATTN_INDICATOR	0x8	/* Attn Indicator Present */
250 #define	PCIE_SLOTCAP_PWR_INDICATOR	0x10	/* Power Indicator Present */
251 #define	PCIE_SLOTCAP_HP_SURPRISE	0x20	/* Hot-Plug Surprise */
252 #define	PCIE_SLOTCAP_HP_CAPABLE		0x40	/* Hot-Plug Capable */
253 
254 #define	PCIE_SLOTCAP_PLMT_VAL_SHIFT	7	/* Slot Pwr Limit Value Shift */
255 #define	PCIE_SLOTCAP_PLMT_VAL_MASK	0xFF	/* Slot Pwr Limit Value */
256 
257 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_1	0x00000	/* 1x Scale */
258 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_10	0x08000	/* 0.1x Scale */
259 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_100	0x10000	/* 0.01x Scale */
260 #define	PCIE_SLOTCAP_PLMT_SCL_1_BY_1000	0x18000	/* 0.001x Scale */
261 #define	PCIE_SLOTCAP_PLMT_SCL_MASK	0x18000	/* Slot Power Limit Scale */
262 
263 #define	PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT	19	/* Physical Slot Num Shift */
264 #define	PCIE_SLOTCAP_PHY_SLOT_NUM_MASK	0x1FFF	/* Physical Slot Num Mask */
265 
266 /*
267  * Slot Control Register
268  */
269 #define	PCIE_SLOTCTL_ATTN_BTN_EN	0x1	/* Attn Button Pressed Enable */
270 #define	PCIE_SLOTCTL_PWR_FAULT_EN	0x2	/* Pwr Fault Detected Enable */
271 #define	PCIE_SLOTCTL_MRL_SENSOR_EN	0x4	/* MRL Sensor Changed Enable */
272 #define	PCIE_SLOTCTL_PRESENCE_CHANGE_EN	0x8	/* Presence Detect Changed En */
273 #define	PCIE_SLOTCTL_CMD_INTR_EN	0x10	/* CMD Completed Interrupt En */
274 #define	PCIE_SLOTCTL_HP_INTR_EN		0x20	/* Hot-Plug Interrupt Enable */
275 
276 #define	PCIE_SLOTCTL_ATTN_CTL_ON	0x40	/* On  */
277 #define	PCIE_SLOTCTL_ATTN_CTL_BLINK	0x80	/* Blink */
278 #define	PCIE_SLOTCTL_ATTN_CTL_OFF	0xC0	/* Off */
279 #define	PCIE_SLOTCTL_ATTN_CTL_MASK	0xC0	/* Attn Indicator Control */
280 
281 #define	PCIE_SLOTCTL_PWR_CTL_ON		0x100	/* On  */
282 #define	PCIE_SLOTCTL_PWR_CTL_BLINK	0x200	/* Blink */
283 #define	PCIE_SLOTCTL_PWR_CTL_OFF	0x300	/* Off */
284 #define	PCIE_SLOTCTL_PWR_CTL_MASK	0x300	/* Power Indicator Control */
285 
286 #define	PCIE_SLOTCTL_PWR_CONTROLLER_CTL	0x400	/* Power Controller Control */
287 
288 /*
289  * Slot Status Register
290  */
291 #define	PCIE_SLOTSTS_ATTN_BTN_PRESSED	0x1	/* Attention Button Pressed */
292 #define	PCIE_SLOTSTS_PWR_FAULT_DETECTED	0x2	/* Power Fault Detected */
293 #define	PCIE_SLOTSTS_MRL_SENSOR_CHANGED	0x4	/* MRL Sensor Changed */
294 #define	PCIE_SLOTSTS_PRESENCE_CHANGED	0x8	/* Presence Detect Changed */
295 #define	PCIE_SLOTSTS_COMMAND_COMPLETED	0x10	/* Command Completed */
296 #define	PCIE_SLOTSTS_MRL_SENSOR_OPEN	0x20	/* MRL Open */
297 #define	PCIE_SLOTSTS_PRESENCE_DETECTED	0x40	/* Card Present in slot */
298 
299 /*
300  * Root Control Register
301  */
302 #define	PCIE_ROOTCTL_SYS_ERR_ON_CE_EN	0x1	/* Sys Err on Cor Err Enable */
303 #define	PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN	0x2	/* Sys Err on NF Err Enable */
304 #define	PCIE_ROOTCTL_SYS_ERR_ON_FE_EN	0x3	/* Sys Err on Fatal Err En */
305 #define	PCIE_ROOTCTL_PME_INTERRUPT_EN	0x4	/* PME Interrupt Enable */
306 
307 /*
308  * Root Status Register
309  */
310 #define	PCIE_ROOTSTS_PME_REQ_ID_SHIFT	0	/* PME Requestor ID */
311 #define	PCIE_ROOTSTS_PME_REQ_ID_MASK	0xFFFF	/* PME Requestor ID */
312 
313 #define	PCIE_ROOTSTS_PME_STATUS		0x10000	/* PME Status */
314 #define	PCIE_ROOTSTS_PME_PENDING	0x20000	/* PME Pending */
315 
316 
317 /*
318  * PCI-Express Enhanced Capabilities Link Entry Bit Offsets
319  */
320 #define	PCIE_EXT_CAP			0x100	/* Base Address of Ext Cap */
321 
322 #define	PCIE_EXT_CAP_ID_SHIFT		0	/* PCI-e Ext Cap ID */
323 #define	PCIE_EXT_CAP_ID_MASK		0xFFFF
324 #define	PCIE_EXT_CAP_VER_SHIFT		16	/* PCI-e Ext Cap Ver */
325 #define	PCIE_EXT_CAP_VER_MASK		0xF
326 #define	PCIE_EXT_CAP_NEXT_PTR_SHIFT	20	/* PCI-e Ext Cap Next Ptr */
327 #define	PCIE_EXT_CAP_NEXT_PTR_MASK	0xFFF
328 
329 #define	PCIE_EXT_CAP_NEXT_PTR_NULL	0x0
330 
331 /*
332  * PCI-Express Enhanced Capability Identifier Values
333  */
334 #define	PCIE_EXT_CAP_ID_AER		0x1	/* Advanced Error Handling */
335 #define	PCIE_EXT_CAP_ID_VC		0x2	/* Virtual Channel */
336 #define	PCIE_EXT_CAP_ID_SER		0x3	/* Serial Number */
337 #define	PCIE_EXT_CAP_ID_PWR_BUDGET	0x4	/* Power Budgeting */
338 
339 /*
340  * PCI-Express Advanced Error Reporting Extended Capability Offsets
341  */
342 #define	PCIE_AER_CAP			0x0	/* Enhanced Capability Header */
343 #define	PCIE_AER_UCE_STS		0x4	/* Uncorrectable Error Status */
344 #define	PCIE_AER_UCE_MASK		0x8	/* Uncorrectable Error Mask */
345 #define	PCIE_AER_UCE_SERV		0xc	/* Uncor Error Severity */
346 #define	PCIE_AER_CE_STS			0x10	/* Correctable Error Status */
347 #define	PCIE_AER_CE_MASK		0x14	/* Correctable Error Mask */
348 #define	PCIE_AER_CTL			0x18	/* AER Capability & Control */
349 #define	PCIE_AER_HDR_LOG		0x1c	/* Header Log */
350 
351 /* Root Ports Only */
352 #define	PCIE_AER_RE_CMD			0x2c	/* Root Error Command */
353 #define	PCIE_AER_RE_STS			0x30	/* Root Error Status */
354 #define	PCIE_AER_CE_SRC_ID		0x34	/* Error Source ID */
355 #define	PCIE_AER_ERR_SRC_ID		0x36	/* Error Source ID */
356 
357 /* Bridges Only */
358 #define	PCIE_AER_SUCE_STS		0x2c	/* Secondary UCE Status */
359 #define	PCIE_AER_SUCE_MASK		0x30	/* Secondary UCE Mask */
360 #define	PCIE_AER_SUCE_SERV		0x34	/* Secondary UCE Severity */
361 #define	PCIE_AER_SCTL			0x38	/* Secondary Cap & Ctl */
362 #define	PCIE_AER_SHDR_LOG		0x3c	/* Secondary Header Log */
363 
364 /*
365  * AER Uncorrectable Error Status/Mask/Severity Register
366  */
367 #define	PCIE_AER_UCE_TRAINING		0x0	/* Training Error Status */
368 #define	PCIE_AER_UCE_DLP		0x10	/* Data Link Protocol Error */
369 #define	PCIE_AER_UCE_PTLP		0x1000	/* Poisoned TLP Status */
370 #define	PCIE_AER_UCE_FCP		0x2000	/* Flow Control Protocol Sts */
371 #define	PCIE_AER_UCE_TO			0x4000	/* Completion Timeout Status */
372 #define	PCIE_AER_UCE_CA			0x8000	/* Completer Abort Status */
373 #define	PCIE_AER_UCE_UC			0x10000	/* Unexpected Completion Sts */
374 #define	PCIE_AER_UCE_RO			0x20000	/* Receiver Overflow Status */
375 #define	PCIE_AER_UCE_MTLP		0x40000	/* Malformed TLP Status */
376 #define	PCIE_AER_UCE_ECRC		0x80000	/* ECRC Error Status */
377 #define	PCIE_AER_UCE_UR		0x100000	/* Unsupported Req */
378 #define	PCIE_AER_UCE_BITS		(PCIE_AER_UCE_TRAINING | \
379     PCIE_AER_UCE_DLP | PCIE_AER_UCE_PTLP | PCIE_AER_UCE_FCP | \
380     PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | \
381     PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
382 
383 /*
384  * AER Correctable Error Status/Mask Register
385  */
386 #define	PCIE_AER_CE_RECEIVER_ERR	0x1	/* Receiver Error Status */
387 #define	PCIE_AER_CE_BAD_TLP		0x40	/* Bad TLP Status */
388 #define	PCIE_AER_CE_BAD_DLLP		0x80	/* Bad DLLP Status */
389 #define	PCIE_AER_CE_REPLAY_ROLLOVER	0x100	/* REPLAY_NUM Rollover Status */
390 #define	PCIE_AER_CE_REPLAY_TO		0x1000	/* Replay Timer Timeout Sts */
391 #define	PCIE_AER_CE_BITS		(PCIE_AER_CE_RECEIVER_ERR | \
392     PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \
393     PCIE_AER_CE_REPLAY_TO)
394 
395 /*
396  * AER Capability & Control
397  */
398 #define	PCIE_AER_CTL_FST_ERR_PTR_MASK	0x1F	/* First Error Pointer */
399 #define	PCIE_AER_CTL_ECRC_GEN_CAP	0x20	/* ECRC Generation Capable */
400 #define	PCIE_AER_CTL_ECRC_GEN_ENA	0x40	/* ECRC Generation Enable */
401 #define	PCIE_AER_CTL_ECRC_CHECK_CAP	0x80	/* ECRC Check Capable */
402 #define	PCIE_AER_CTL_ECRC_CHECK_ENA	0x100	/* ECRC Check Enable */
403 
404 /*
405  * AER Root Command Register
406  */
407 #define	PCIE_AER_RE_CMD_CE_REP_EN	0x1	/* Correctable Error Enable */
408 #define	PCIE_AER_RE_CMD_NFE_REP_EN	0x2	/* Non-Fatal Error Enable */
409 #define	PCIE_AER_RE_CMD_FE_REP_EN	0x4	/* Fatal Error Enable */
410 
411 /*
412  * AER Root Error Status Register
413  */
414 #define	PCIE_AER_RE_STS_CE_RCVD		0x1	/* ERR_COR Received */
415 #define	PCIE_AER_RE_STS_MUL_CE_RCVD	0x2	/* Multiple ERR_COR Received */
416 #define	PCIE_AER_RE_STS_FE_NFE_RCVD	0x4	/* FATAL/NON-FATAL Received */
417 #define	PCIE_AER_RE_STS_MUL_FE_NFE_RCVD	0x8	/* Multiple ERR_F/NF Received */
418 #define	PCIE_AER_RE_STS_FIRST_UC_FATAL	0x10	/* First Uncorrectable Fatal */
419 #define	PCIE_AER_RE_STS_NFE_MSGS_RCVD	0x20	/* Non-Fatal Error Msgs Rcvd */
420 #define	PCIE_AER_RE_STS_FE_MSGS_RCVD	0x40	/* Fatal Error Messages Rcvd */
421 
422 #define	PCIE_AER_RE_STS_MSG_NUM_SHIFT	27	/* Offset of Intr Msg Number */
423 #define	PCIE_AER_RE_STS_MSG_NUM_MASK	0x1F	/* Intr Msg Number Mask */
424 
425 /*
426  * AER Error Source Identification Register
427  */
428 #define	PCIE_AER_ERR_SRC_ID_CE_SHIFT	0	/* ERR_COR Source ID */
429 #define	PCIE_AER_ERR_SRC_ID_CE_MASK	0xFFFF
430 #define	PCIE_AER_ERR_SRC_ID_UE_SHIFT	16	/* ERR_FATAL/NONFATAL Src ID */
431 #define	PCIE_AER_ERR_SRC_ID_UE_MASK	0xFFF
432 
433 /*
434  * AER Secondary Uncorrectable Error Register
435  */
436 #define	PCIE_AER_SUCE_TA_ON_SC		0x1	/* Target Abort on Split Comp */
437 #define	PCIE_AER_SUCE_MA_ON_SC 		0x2	/* Master Abort on Split Comp */
438 #define	PCIE_AER_SUCE_RCVD_TA		0x4	/* Received Target Abort */
439 #define	PCIE_AER_SUCE_RCVD_MA 		0x8	/* Received Master Abort */
440 #define	PCIE_AER_SUCE_USC_ERR 		0x20	/* Unexpected Split Comp Err */
441 #define	PCIE_AER_SUCE_USC_MSG_DATA_ERR	0x40	/* USC Message Data Error */
442 #define	PCIE_AER_SUCE_UC_DATA_ERR	0x80	/* Uncorrectable Data Error */
443 #define	PCIE_AER_SUCE_UC_ATTR_ERR	0x100	/* UC Attribute Err */
444 #define	PCIE_AER_SUCE_UC_ADDR_ERR	0x200	/* Uncorrectable Address Err */
445 #define	PCIE_AER_SUCE_TIMER_EXPIRED	0x400	/* Delayed xtion discard */
446 #define	PCIE_AER_SUCE_PERR_ASSERT	0x800	/* PERR Assertion Detected */
447 #define	PCIE_AER_SUCE_SERR_ASSERT	0x1000	/* SERR Assertion Detected */
448 #define	PCIE_AER_SUCE_INTERNAL_ERR	0x2000	/* Internal Bridge Err Detect */
449 #define	PCIE_AER_SUCE_BITS		(PCIE_AER_SUCE_TA_ON_SC | \
450     PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
451     PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
452     PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
453     PCIE_AER_SUCE_UC_ADDR_ERR |	PCIE_AER_SUCE_TIMER_EXPIRED | \
454     PCIE_AER_SUCE_PERR_ASSERT |	PCIE_AER_SUCE_SERR_ASSERT | \
455     PCIE_AER_SUCE_INTERNAL_ERR)
456 
457 /*
458  * AER Secondary Capability & Control
459  */
460 #define	PCIE_AER_SCTL_FST_ERR_PTR_MASK	0x1F	/* First Error Pointer */
461 
462 /*
463  * AER Secondary Headers
464  * The Secondary Header Logs is 4 DW long.
465  * The first 2 DW are split into 3 sections
466  * o Transaction Attribute
467  * o Transaction Command Lower
468  * o Transaction Command Higher
469  * The last 2 DW is the Transaction Address
470  */
471 #define	PCIE_AER_SHDR_LOG_ATTR_MASK	0xFFFFFFFFF
472 #define	PCIE_AER_SHDR_LOG_CMD_LOW_MASK	0xF000000000
473 #define	PCIE_AER_SHDR_LOG_CMD_HIGH_MASK	0xF0000000000
474 #define	PCIE_AER_SHDR_LOG_ADDR_MASK	0xFFFFFFFFFFFFFFFF
475 
476 /*
477  * PCI-E Common TLP Header Fields
478  */
479 #define	PCIE_TLP_FMT_3DW 	0x00
480 #define	PCIE_TLP_FMT_4DW	0x20
481 #define	PCIE_TLP_FMT_3DW_DATA	0x40
482 #define	PCIE_TLP_FMT_4DW_DATA	0x60
483 
484 #define	PCIE_TLP_TYPE_MEM	0x0
485 #define	PCIE_TLP_TYPE_MEMLK	0x1
486 #define	PCIE_TLP_TYPE_IO 	0x2
487 #define	PCIE_TLP_TYPE_CFG0	0x4
488 #define	PCIE_TLP_TYPE_CFG1	0x5
489 #define	PCIE_TLP_TYPE_MSG 	0x10
490 #define	PCIE_TLP_TYPE_CPL	0xA
491 #define	PCIE_TLP_TYPE_CPLLK	0xB
492 #define	PCIE_TLP_TYPE_MSI	0x18
493 
494 #define	PCIE_TLP_MRD3		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM)
495 #define	PCIE_TLP_MRD4		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM)
496 #define	PCIE_TLP_MRDLK3		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK)
497 #define	PCIE_TLP_MRDLK4		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK)
498 #define	PCIE_TLP_MRDWR3		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM)
499 #define	PCIE_TLP_MRDWR4		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM)
500 #define	PCIE_TLP_IORD 		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO)
501 #define	PCIE_TLP_IOWR 		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO)
502 #define	PCIE_TLP_CFGRD0		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0)
503 #define	PCIE_TLP_CFGWR0		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0)
504 #define	PCIE_TLP_CFGRD1		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1)
505 #define	PCIE_TLP_CFGWR1		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1)
506 #define	PCIE_TLP_MSG 		(PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG)
507 #define	PCIE_TLP_MSGD 		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG)
508 #define	PCIE_TLP_CPL		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL)
509 #define	PCIE_TLP_CPLD		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL)
510 #define	PCIE_TLP_CPLLK		(PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK)
511 #define	PCIE_TLP_CPLDLK		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK)
512 #define	PCIE_TLP_MSI32		(PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI)
513 #define	PCIE_TLP_MSI64		(PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI)
514 
515 typedef uint16_t pcie_req_id_t;
516 
517 #define	PCIE_REQ_ID_BUS_SHIFT	8
518 #define	PCIE_REQ_ID_BUS_MASK	0xFF00
519 #define	PCIE_REQ_ID_DEV_SHIFT	3
520 #define	PCIE_REQ_ID_DEV_MASK	0x00F1
521 #define	PCIE_REQ_ID_FUNC_SHIFT	0
522 #define	PCIE_REQ_ID_FUNC_MASK	0x0007
523 
524 /*
525  * PCI-Express Message Request Header
526  */
527 typedef struct pcie_msg {
528 	uint32_t	rsvd1	:16,	/* DW0 */
529 			td	:1,
530 			ep	:1,
531 			attr	:2,
532 			rsvd2	:2,
533 			len	:10;
534 	uint32_t	rid	:16,	/* DW1 */
535 			tag	:8,
536 			msg_code:8;
537 	uint32_t	unused[2];	/* DW 2 & 3 */
538 } pcie_msg_t;
539 
540 #define	PCIE_MSG_CODE_ERR_COR		0x30
541 #define	PCIE_MSG_CODE_ERR_NONFATAL	0x31
542 #define	PCIE_MSG_CODE_ERR_FATAL		0x33
543 
544 /*
545  * Exported PCI-express property names
546  */
547 #define	SAVED_PCIEX_CAP_REG	"pciex-cap-reg"
548 #define	SAVED_PCIEX_SLOTCAP_REG	"pciex-slotcap-reg"
549 
550 #ifdef	__cplusplus
551 }
552 #endif
553 
554 #endif	/* _SYS_PCIE_H */
555