pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / pcie.h
blob05b70a56fad1d78e06b0242a2b0afc6d97515209
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_PCIE_H
27 #define _SYS_PCIE_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
33 #include <sys/pci.h>
36 * PCI Express capability registers in PCI configuration space relative to
37 * the PCI Express Capability structure.
39 #define PCIE_CAP_ID PCI_CAP_ID
40 #define PCIE_CAP_NEXT_PTR PCI_CAP_NEXT_PTR
41 #define PCIE_PCIECAP 0x02 /* PCI-e Capability Reg */
42 #define PCIE_DEVCAP 0x04 /* Device Capability */
43 #define PCIE_DEVCTL 0x08 /* Device Control */
44 #define PCIE_DEVSTS 0x0A /* Device Status */
45 #define PCIE_LINKCAP 0x0C /* Link Capability */
46 #define PCIE_LINKCTL 0x10 /* Link Control */
47 #define PCIE_LINKSTS 0x12 /* Link Status */
48 #define PCIE_SLOTCAP 0x14 /* Slot Capability */
49 #define PCIE_SLOTCTL 0x18 /* Slot Control */
50 #define PCIE_SLOTSTS 0x1A /* Slot Status */
51 #define PCIE_ROOTCTL 0x1C /* Root Control */
52 #define PCIE_ROOTSTS 0x20 /* Root Status */
53 #define PCIE_DEVCAP2 0x24 /* Device Capability 2 */
54 #define PCIE_DEVCTL2 0x28 /* Device Control 2 */
55 #define PCIE_DEVSTS2 0x2A /* Device Status 2 */
56 #define PCIE_LINKCAP2 0x2C /* Link Capability 2 */
57 #define PCIE_LINKCTL2 0x30 /* Link Control 2 */
58 #define PCIE_LINKSTS2 0x32 /* Link Status 2 */
59 #define PCIE_SLOTCAP2 0x34 /* Slot Capability 2 */
60 #define PCIE_SLOTCTL2 0x38 /* Slot Control 2 */
61 #define PCIE_SLOTSTS2 0x3A /* Slot Status 2 */
64 * PCI-Express Config Space size
66 #define PCIE_CONF_HDR_SIZE 4096 /* PCIe configuration header size */
69 * PCI-Express Capabilities Register (2 bytes)
71 #define PCIE_PCIECAP_VER_1_0 0x1 /* PCI-E spec 1.0 */
72 #define PCIE_PCIECAP_VER_2_0 0x2 /* PCI-E spec 2.0 */
73 #define PCIE_PCIECAP_VER_MASK 0xF /* Version Mask */
74 #define PCIE_PCIECAP_DEV_TYPE_PCIE_DEV 0x00 /* PCI-E Endpont Device */
75 #define PCIE_PCIECAP_DEV_TYPE_PCI_DEV 0x10 /* "Leg PCI" Endpont Device */
76 #define PCIE_PCIECAP_DEV_TYPE_ROOT 0x40 /* Root Port of Root Complex */
77 #define PCIE_PCIECAP_DEV_TYPE_UP 0x50 /* Upstream Port of Switch */
78 #define PCIE_PCIECAP_DEV_TYPE_DOWN 0x60 /* Downstream Port of Switch */
79 #define PCIE_PCIECAP_DEV_TYPE_PCIE2PCI 0x70 /* PCI-E to PCI Bridge */
80 #define PCIE_PCIECAP_DEV_TYPE_PCI2PCIE 0x80 /* PCI to PCI-E Bridge */
81 #define PCIE_PCIECAP_DEV_TYPE_RC_IEP 0x90 /* RootComplex Integrated Dev */
82 #define PCIE_PCIECAP_DEV_TYPE_RC_EC 0xA0 /* RootComplex Evt Collector */
83 #define PCIE_PCIECAP_DEV_TYPE_MASK 0xF0 /* Device/Port Type Mask */
84 #define PCIE_PCIECAP_SLOT_IMPL 0x100 /* Slot Impl vs Integrated */
85 #define PCIE_PCIECAP_INT_MSG_NUM 0x3E00 /* Interrupt Message Number */
88 * Device Capabilities Register (4 bytes)
90 #define PCIE_DEVCAP_MAX_PAYLOAD_128 0x0
91 #define PCIE_DEVCAP_MAX_PAYLOAD_256 0x1
92 #define PCIE_DEVCAP_MAX_PAYLOAD_512 0x2
93 #define PCIE_DEVCAP_MAX_PAYLOAD_1024 0x3
94 #define PCIE_DEVCAP_MAX_PAYLOAD_2048 0x4
95 #define PCIE_DEVCAP_MAX_PAYLOAD_4096 0x5
96 #define PCIE_DEVCAP_MAX_PAYLOAD_MASK 0x7 /* Max Payload Size Supported */
98 #define PCIE_DEVCAP_PHTM_FUNC_NONE 0x00 /* No Function # bits used */
99 #define PCIE_DEVCAP_PHTM_FUNC_ONE 0x08 /* First most sig. bit used */
100 #define PCIE_DEVCAP_PHTM_FUNC_TWO 0x10 /* First 2 most sig bit used */
101 #define PCIE_DEVCAP_PHTM_FUNC_THREE 0x18 /* All 3 bits used */
102 #define PCIE_DEVCAP_PHTM_FUNC_MASK 0x18 /* Phantom Func Supported */
104 #define PCIE_DEVCAP_EXT_TAG_5BIT 0x00 /* 5-Bit Tag Field Supported */
105 #define PCIE_DEVCAP_EXT_TAG_8BIT 0x20 /* 8-Bit Tag Field Supported */
106 #define PCIE_DEVCAP_EXT_TAG_MASK 0x20 /* Ext. Tag Field Supported */
108 #define PCIE_DEVCAP_EP_L0S_LAT_MIN 0x000 /* < 64 ns */
109 #define PCIE_DEVCAP_EP_L0S_LAT_64ns 0x040 /* 64 ns - 128 ns */
110 #define PCIE_DEVCAP_EP_L0S_LAT_128ns 0x080 /* 128 ns - 256 ns */
111 #define PCIE_DEVCAP_EP_L0S_LAT_256ns 0x0C0 /* 256 ns - 512 ns */
112 #define PCIE_DEVCAP_EP_L0S_LAT_512ns 0x100 /* 512 ns - 1 us */
113 #define PCIE_DEVCAP_EP_L0S_LAT_1us 0x140 /* 1 us - 2 us */
114 #define PCIE_DEVCAP_EP_L0S_LAT_2us 0x180 /* 2 us - 4 us */
115 #define PCIE_DEVCAP_EP_L0S_LAT_MAX 0x1C0 /* > 4 us */
116 #define PCIE_DEVCAP_EP_L0S_LAT_MASK 0x1C0 /* EP L0s Accetable Latency */
118 #define PCIE_DEVCAP_EP_L1_LAT_MIN 0x000 /* < 1 us */
119 #define PCIE_DEVCAP_EP_L1_LAT_1us 0x140 /* 1 us - 2 us */
120 #define PCIE_DEVCAP_EP_L1_LAT_2us 0x180 /* 2 us - 4 us */
121 #define PCIE_DEVCAP_EP_L1_LAT_4us 0x140 /* 4 us - 8 us */
122 #define PCIE_DEVCAP_EP_L1_LAT_8us 0x180 /* 8 us - 16 us */
123 #define PCIE_DEVCAP_EP_L1_LAT_16us 0x140 /* 16 us - 32 us */
124 #define PCIE_DEVCAP_EP_L1_LAT_32us 0x180 /* 32 us - 64 us */
125 #define PCIE_DEVCAP_EP_L1_LAT_MAX 0x1C0 /* > 64 us */
126 #define PCIE_DEVCAP_EP_L1_LAT_MASK 0x700 /* EP L1 Accetable Latency */
128 #define PCIE_DEVCAP_ATTN_BUTTON 0x1000 /* Attention Button Present */
129 #define PCIE_DEVCAP_ATTN_INDICATOR 0x2000 /* Attn Indicator Present */
130 #define PCIE_DEVCAP_PWR_INDICATOR 0x4000 /* Power Indicator Present */
132 #define PCIE_DEVCAP_ROLE_BASED_ERR_REP 0x8000 /* Role Based Error Reporting */
134 #define PCIE_DEVCAP_PLMT_VAL_SHIFT 18 /* Power Limit Value Shift */
135 #define PCIE_DEVCAP_PLMT_VAL_MASK 0xFF /* Power Limit Value Mask */
137 #define PCIE_DEVCAP_PLMT_SCL_1_BY_1 0x0000000 /* 1x Scale */
138 #define PCIE_DEVCAP_PLMT_SCL_1_BY_10 0x4000000 /* 0.1x Scale */
139 #define PCIE_DEVCAP_PLMT_SCL_1_BY_100 0x8000000 /* 0.01x Scale */
140 #define PCIE_DEVCAP_PLMT_SCL_1_BY_1000 0xC000000 /* 0.001x Scale */
141 #define PCIE_DEVCAP_PLMT_SCL_MASK 0xC000000 /* Power Limit Scale */
144 * Device Control Register (2 bytes)
146 #define PCIE_DEVCTL_CE_REPORTING_EN 0x1 /* Correctable Error Enable */
147 #define PCIE_DEVCTL_NFE_REPORTING_EN 0x2 /* Non-Fatal Error Enable */
148 #define PCIE_DEVCTL_FE_REPORTING_EN 0x4 /* Fatal Error Enable */
149 #define PCIE_DEVCTL_UR_REPORTING_EN 0x8 /* Unsupported Request Enable */
150 #define PCIE_DEVCTL_ERR_MASK 0xF /* All of the above bits */
152 #define PCIE_DEVCTL_RO_EN 0x10 /* Enable Relaxed Ordering */
154 #define PCIE_DEVCTL_MAX_PAYLOAD_128 0x00
155 #define PCIE_DEVCTL_MAX_PAYLOAD_256 0x20
156 #define PCIE_DEVCTL_MAX_PAYLOAD_512 0x40
157 #define PCIE_DEVCTL_MAX_PAYLOAD_1024 0x60
158 #define PCIE_DEVCTL_MAX_PAYLOAD_2048 0x80
159 #define PCIE_DEVCTL_MAX_PAYLOAD_4096 0xA0
160 #define PCIE_DEVCTL_MAX_PAYLOAD_MASK 0xE0 /* Max_Payload_Size */
161 #define PCIE_DEVCTL_MAX_PAYLOAD_SHIFT 0x5
163 #define PCIE_DEVCTL_EXT_TAG_FIELD_EN 0x100 /* Extended Tag Field Enable */
164 #define PCIE_DEVCTL_PHTM_FUNC_EN 0x200 /* Phantom Functions Enable */
165 #define PCIE_DEVCTL_AUX_POWER_PM_EN 0x400 /* Auxiliary Power PM Enable */
166 #define PCIE_DEVCTL_ENABLE_NO_SNOOP 0x800 /* Enable No Snoop */
168 #define PCIE_DEVCTL_MAX_READ_REQ_128 0x0000
169 #define PCIE_DEVCTL_MAX_READ_REQ_256 0x1000
170 #define PCIE_DEVCTL_MAX_READ_REQ_512 0x2000
171 #define PCIE_DEVCTL_MAX_READ_REQ_1024 0x3000
172 #define PCIE_DEVCTL_MAX_READ_REQ_2048 0x4000
173 #define PCIE_DEVCTL_MAX_READ_REQ_4096 0x5000
174 #define PCIE_DEVCTL_MAX_READ_REQ_MASK 0x7000 /* Max_Read_Request_Size */
175 #define PCIE_DEVCTL_MAX_READ_REQ_SHIFT 0xC
178 * Device Status Register (2 bytes)
180 #define PCIE_DEVSTS_CE_DETECTED 0x1 /* Correctable Error Detected */
181 #define PCIE_DEVSTS_NFE_DETECTED 0x2 /* Non Fatal Error Detected */
182 #define PCIE_DEVSTS_FE_DETECTED 0x4 /* Fatal Error Detected */
183 #define PCIE_DEVSTS_UR_DETECTED 0x8 /* Unsupported Req Detected */
184 #define PCIE_DEVSTS_AUX_POWER 0x10 /* AUX Power Detected */
185 #define PCIE_DEVSTS_TRANS_PENDING 0x20 /* Transactions Pending */
188 * Link Capability Register (4 bytes)
190 #define PCIE_LINKCAP_MAX_SPEED_2_5 0x1 /* 2.5 Gb/s Speed */
191 #define PCIE_LINKCAP_MAX_SPEED_MASK 0xF /* Maximum Link Speed */
192 #define PCIE_LINKCAP_MAX_WIDTH_X1 0x010
193 #define PCIE_LINKCAP_MAX_WIDTH_X2 0x020
194 #define PCIE_LINKCAP_MAX_WIDTH_X4 0x040
195 #define PCIE_LINKCAP_MAX_WIDTH_X8 0x080
196 #define PCIE_LINKCAP_MAX_WIDTH_X12 0x0C0
197 #define PCIE_LINKCAP_MAX_WIDTH_X16 0x100
198 #define PCIE_LINKCAP_MAX_WIDTH_X32 0x200
199 #define PCIE_LINKCAP_MAX_WIDTH_MASK 0x3f0 /* Maximum Link Width */
201 #define PCIE_LINKCAP_ASPM_SUP_L0S 0x400 /* L0s Entry Supported */
202 #define PCIE_LINKCAP_ASPM_SUP_L0S_L1 0xC00 /* L0s abd L1 Supported */
203 #define PCIE_LINKCAP_ASPM_SUP_MASK 0xC00 /* ASPM Support */
205 #define PCIE_LINKCAP_L0S_EXIT_LAT_MIN 0x0000 /* < 64 ns */
206 #define PCIE_LINKCAP_L0S_EXIT_LAT_64ns 0x1000 /* 64 ns - 128 ns */
207 #define PCIE_LINKCAP_L0S_EXIT_LAT_128ns 0x2000 /* 128 ns - 256 ns */
208 #define PCIE_LINKCAP_L0S_EXIT_LAT_256ns 0x3000 /* 256 ns - 512 ns */
209 #define PCIE_LINKCAP_L0S_EXIT_LAT_512ns 0x4000 /* 512 ns - 1 us */
210 #define PCIE_LINKCAP_L0S_EXIT_LAT_1us 0x5000 /* 1 us - 2 us */
211 #define PCIE_LINKCAP_L0S_EXIT_LAT_2us 0x6000 /* 2 us - 4 us */
212 #define PCIE_LINKCAP_L0S_EXIT_LAT_MAX 0x7000 /* > 4 us */
213 #define PCIE_LINKCAP_L0S_EXIT_LAT_MASK 0x7000 /* L0s Exit Latency */
215 #define PCIE_LINKCAP_L1_EXIT_LAT_MIN 0x00000 /* < 1 us */
216 #define PCIE_LINKCAP_L1_EXIT_LAT_1us 0x08000 /* 1 us - 2 us */
217 #define PCIE_LINKCAP_L1_EXIT_LAT_2us 0x10000 /* 2 us - 4 us */
218 #define PCIE_LINKCAP_L1_EXIT_LAT_4us 0x18000 /* 4 us - 8 us */
219 #define PCIE_LINKCAP_L1_EXIT_LAT_8us 0x20000 /* 8 us - 16 us */
220 #define PCIE_LINKCAP_L1_EXIT_LAT_16us 0x28000 /* 16 us - 32 us */
221 #define PCIE_LINKCAP_L1_EXIT_LAT_32us 0x30000 /* 32 us - 64 us */
222 #define PCIE_LINKCAP_L1_EXIT_LAT_MAX 0x38000 /* > 64 us */
223 #define PCIE_LINKCAP_L1_EXIT_LAT_MASK 0x38000 /* L1 Exit Latency */
225 /* PCIe v1.1 spec based */
226 #define PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE 0x100000 /* DLL Active */
227 /* Capable bit */
229 #define PCIE_LINKCAP_PORT_NUMBER 0xFF000000 /* Port Number */
230 #define PCIE_LINKCAP_PORT_NUMBER_SHIFT 24 /* Port Number Shift */
231 #define PCIE_LINKCAP_PORT_NUMBER_MASK 0xFF /* Port Number Mask */
234 * Link Control Register (2 bytes)
236 #define PCIE_LINKCTL_ASPM_CTL_DIS 0x0 /* ASPM Disable */
237 #define PCIE_LINKCTL_ASPM_CTL_L0S 0x1 /* ASPM L0s only */
238 #define PCIE_LINKCTL_ASPM_CTL_L1 0x2 /* ASPM L1 only */
239 #define PCIE_LINKCTL_ASPM_CTL_L0S_L1 0x3 /* ASPM L0s and L1 only */
240 #define PCIE_LINKCTL_ASPM_CTL_MASK 0x3 /* ASPM Control */
242 #define PCIE_LINKCTL_RCB_64_BYTE 0x0 /* 64 Byte */
243 #define PCIE_LINKCTL_RCB_128_BYTE 0x8 /* 128 Byte */
244 #define PCIE_LINKCTL_RCB_MASK 0x8 /* Read Completion Boundary */
246 #define PCIE_LINKCTL_LINK_DISABLE 0x10 /* Link Disable */
247 #define PCIE_LINKCTL_RETRAIN_LINK 0x20 /* Retrain Link */
248 #define PCIE_LINKCTL_COMMON_CLK_CFG 0x40 /* Common Clock Configuration */
249 #define PCIE_LINKCTL_EXT_SYNCH 0x80 /* Extended Synch */
252 * Link Status Register (2 bytes)
254 #define PCIE_LINKSTS_SPEED_2_5 0x1 /* Link Speed */
255 #define PCIE_LINKSTS_SPEED_MASK 0xF /* Link Speed */
257 #define PCIE_LINKSTS_NEG_WIDTH_X1 0x010
258 #define PCIE_LINKSTS_NEG_WIDTH_X2 0x020
259 #define PCIE_LINKSTS_NEG_WIDTH_X4 0x040
260 #define PCIE_LINKSTS_NEG_WIDTH_X8 0x080
261 #define PCIE_LINKSTS_NEG_WIDTH_X12 0x0C0
262 #define PCIE_LINKSTS_NEG_WIDTH_X16 0x100
263 #define PCIE_LINKSTS_NEG_WIDTH_X32 0x200
264 #define PCIE_LINKSTS_NEG_WIDTH_MASK 0x3F0 /* Negotiated Link Width */
266 #define PCIE_LINKSTS_TRAINING_ERROR 0x400 /* Training Error */
267 #define PCIE_LINKSTS_LINK_TRAINING 0x800 /* Link Training */
268 #define PCIE_LINKSTS_SLOT_CLK_CFG 0x1000 /* Slot Clock Configuration */
270 /* PCIe v1.1 spec based */
271 #define PCIE_LINKSTS_DLL_LINK_ACTIVE 0x2000 /* DLL Link Active */
274 * Slot Capability Register (4 bytes)
276 #define PCIE_SLOTCAP_ATTN_BUTTON 0x1 /* Attention Button Present */
277 #define PCIE_SLOTCAP_POWER_CONTROLLER 0x2 /* Power Controller Present */
278 #define PCIE_SLOTCAP_MRL_SENSOR 0x4 /* MRL Sensor Present */
279 #define PCIE_SLOTCAP_ATTN_INDICATOR 0x8 /* Attn Indicator Present */
280 #define PCIE_SLOTCAP_PWR_INDICATOR 0x10 /* Power Indicator Present */
281 #define PCIE_SLOTCAP_HP_SURPRISE 0x20 /* Hot-Plug Surprise */
282 #define PCIE_SLOTCAP_HP_CAPABLE 0x40 /* Hot-Plug Capable */
284 #define PCIE_SLOTCAP_PLMT_VAL_SHIFT 7 /* Slot Pwr Limit Value Shift */
285 #define PCIE_SLOTCAP_PLMT_VAL_MASK 0xFF /* Slot Pwr Limit Value */
287 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_1 0x00000 /* 1x Scale */
288 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_10 0x08000 /* 0.1x Scale */
289 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_100 0x10000 /* 0.01x Scale */
290 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_1000 0x18000 /* 0.001x Scale */
291 #define PCIE_SLOTCAP_PLMT_SCL_MASK 0x18000 /* Slot Power Limit Scale */
292 #define PCIE_SLOTCAP_EMI_LOCK_PRESENT 0x20000 /* EMI Lock Present */
293 #define PCIE_SLOTCAP_NO_CMD_COMP_SUPP 0x40000 /* No Command Comp. Supported */
295 #define PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT 19 /* Physical Slot Num Shift */
296 #define PCIE_SLOTCAP_PHY_SLOT_NUM_MASK 0x1FFF /* Physical Slot Num Mask */
298 #define PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \
299 (((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \
300 PCIE_SLOTCAP_PHY_SLOT_NUM_MASK)
303 * Slot Control Register (2 bytes)
305 #define PCIE_SLOTCTL_ATTN_BTN_EN 0x1 /* Attn Button Pressed Enable */
306 #define PCIE_SLOTCTL_PWR_FAULT_EN 0x2 /* Pwr Fault Detected Enable */
307 #define PCIE_SLOTCTL_MRL_SENSOR_EN 0x4 /* MRL Sensor Changed Enable */
308 #define PCIE_SLOTCTL_PRESENCE_CHANGE_EN 0x8 /* Presence Detect Changed En */
309 #define PCIE_SLOTCTL_CMD_INTR_EN 0x10 /* CMD Completed Interrupt En */
310 #define PCIE_SLOTCTL_HP_INTR_EN 0x20 /* Hot-Plug Interrupt Enable */
311 #define PCIE_SLOTCTL_PWR_CONTROL 0x0400 /* Power controller Control */
312 #define PCIE_SLOTCTL_EMI_LOCK_CONTROL 0x0800 /* EMI Lock control */
313 #define PCIE_SLOTCTL_DLL_STATE_EN 0x1000 /* DLL State Changed En */
314 #define PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0 /* Attn Indicator mask */
315 #define PCIE_SLOTCTL_PWR_INDICATOR_MASK 0x0300 /* Power Indicator mask */
316 #define PCIE_SLOTCTL_INTR_MASK 0x103f /* Supported intr mask */
318 /* State values for the Power and Attention Indicators */
319 #define PCIE_SLOTCTL_INDICATOR_STATE_ON 0x1 /* indicator ON */
320 #define PCIE_SLOTCTL_INDICATOR_STATE_BLINK 0x2 /* indicator BLINK */
321 #define PCIE_SLOTCTL_INDICATOR_STATE_OFF 0x3 /* indicator OFF */
324 * Macros to set/get the state of Power and Attention Indicators
325 * in the PCI Express Slot Control Register.
327 #define pcie_slotctl_pwr_indicator_get(reg) \
328 (((reg) & PCIE_SLOTCTL_PWR_INDICATOR_MASK) >> 8)
329 #define pcie_slotctl_attn_indicator_get(ctrl) \
330 (((ctrl) & PCIE_SLOTCTL_ATTN_INDICATOR_MASK) >> 6)
331 #define pcie_slotctl_attn_indicator_set(ctrl, v)\
332 (((ctrl) & ~PCIE_SLOTCTL_ATTN_INDICATOR_MASK) | ((v) << 6))
333 #define pcie_slotctl_pwr_indicator_set(ctrl, v)\
334 (((ctrl) & ~PCIE_SLOTCTL_PWR_INDICATOR_MASK) | ((v) << 8))
337 * Slot Status register (2 bytes)
339 #define PCIE_SLOTSTS_ATTN_BTN_PRESSED 0x1 /* Attention Button Pressed */
340 #define PCIE_SLOTSTS_PWR_FAULT_DETECTED 0x2 /* Power Fault Detected */
341 #define PCIE_SLOTSTS_MRL_SENSOR_CHANGED 0x4 /* MRL Sensor Changed */
342 #define PCIE_SLOTSTS_PRESENCE_CHANGED 0x8 /* Presence Detect Changed */
343 #define PCIE_SLOTSTS_COMMAND_COMPLETED 0x10 /* Command Completed */
344 #define PCIE_SLOTSTS_MRL_SENSOR_OPEN 0x20 /* MRL Sensor Open */
345 #define PCIE_SLOTSTS_PRESENCE_DETECTED 0x40 /* Card Present in slot */
346 #define PCIE_SLOTSTS_EMI_LOCK_SET 0x0080 /* EMI Lock set */
347 #define PCIE_SLOTSTS_DLL_STATE_CHANGED 0x0100 /* DLL State Changed */
348 #define PCIE_SLOTSTS_STATUS_EVENTS 0x11f /* Supported events */
351 * Root Control Register (2 bytes)
353 #define PCIE_ROOTCTL_SYS_ERR_ON_CE_EN 0x1 /* Sys Err on Cor Err Enable */
354 #define PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN 0x2 /* Sys Err on NF Err Enable */
355 #define PCIE_ROOTCTL_SYS_ERR_ON_FE_EN 0x4 /* Sys Err on Fatal Err En */
356 #define PCIE_ROOTCTL_PME_INTERRUPT_EN 0x8 /* PME Interrupt Enable */
359 * Root Status Register (4 bytes)
361 #define PCIE_ROOTSTS_PME_REQ_ID_SHIFT 0 /* PME Requestor ID */
362 #define PCIE_ROOTSTS_PME_REQ_ID_MASK 0xFFFF /* PME Requestor ID */
364 #define PCIE_ROOTSTS_PME_STATUS 0x10000 /* PME Status */
365 #define PCIE_ROOTSTS_PME_PENDING 0x20000 /* PME Pending */
368 * Device Capabilities 2 Register (4 bytes)
370 #define PCIE_DEVCAP2_COM_TO_RANGE_MASK 0xF
371 #define PCIE_DEVCAP2_COM_TO_DISABLE 0x10
372 #define PCIE_DEVCAP2_ARI_FORWARD 0x20
373 #define PCIE_DEVCAP2_ATOMICOP_ROUTING 0x40
374 #define PCIE_DEVCAP2_32_ATOMICOP_COMPL 0x80
375 #define PCIE_DEVCAP2_64_ATOMICOP_COMPL 0x100
376 #define PCIE_DEVCAP2_128_CAS_COMPL 0x200
377 #define PCIE_DEVCAP2_NO_RO_PR_PR_PASS 0x400
378 #define PCIE_DEVCAP2_LTR_MECH 0x800
379 #define PCIE_DEVCAP2_TPH_COMP_SHIFT 12
380 #define PCIE_DEVCAP2_TPH_COMP_MASK 0x3
381 #define PCIE_DEVCAP2_EXT_FMT_FIELD 0x100000
382 #define PCIE_DEVCAP2_END_END_TLP_PREFIX 0x200000
383 #define PCIE_DEVCAP2_MAX_END_END_SHIFT 22
384 #define PCIE_DEVCAP2_MAX_END_END_MASK 0x3
387 * Device Control 2 Register (2 bytes)
389 #define PCIE_DEVCTL2_COM_TO_RANGE_0 0x0
390 #define PCIE_DEVCTL2_COM_TO_RANGE_1 0x1
391 #define PCIE_DEVCTL2_COM_TO_RANGE_2 0x2
392 #define PCIE_DEVCTL2_COM_TO_RANGE_3 0x5
393 #define PCIE_DEVCTL2_COM_TO_RANGE_4 0x6
394 #define PCIE_DEVCTL2_COM_TO_RANGE_5 0x9
395 #define PCIE_DEVCTL2_COM_TO_RANGE_6 0xa
396 #define PCIE_DEVCTL2_COM_TO_RANGE_7 0xd
397 #define PCIE_DEVCTL2_COM_TO_RANGE_8 0xe
398 #define PCIE_DEVCTL2_COM_TO_DISABLE 0x10
399 #define PCIE_DEVCTL2_ARI_FORWARD_EN 0x20
400 #define PCIE_DEVCTL2_ATOMICOP_REQ_EN 0x40
401 #define PCIE_DEVCTL2_ATOMICOP_EGRS_BLK 0x80
402 #define PCIE_DEVCTL2_IDO_REQ_EN 0x100
403 #define PCIE_DEVCTL2_IDO_COMPL_EN 0x200
404 #define PCIE_DEVCTL2_LTR_MECH_EN 0x400
405 #define PCIE_DEVCTL2_END_END_TLP_PREFIX 0x8000
412 * PCI-Express Enhanced Capabilities Link Entry Bit Offsets
414 #define PCIE_EXT_CAP 0x100 /* Base Address of Ext Cap */
416 #define PCIE_EXT_CAP_ID_SHIFT 0 /* PCI-e Ext Cap ID */
417 #define PCIE_EXT_CAP_ID_MASK 0xFFFF
418 #define PCIE_EXT_CAP_VER_SHIFT 16 /* PCI-e Ext Cap Ver */
419 #define PCIE_EXT_CAP_VER_MASK 0xF
420 #define PCIE_EXT_CAP_NEXT_PTR_SHIFT 20 /* PCI-e Ext Cap Next Ptr */
421 #define PCIE_EXT_CAP_NEXT_PTR_MASK 0xFFF
423 #define PCIE_EXT_CAP_NEXT_PTR_NULL 0x0
426 * PCI-Express Enhanced Capability Identifier Values
428 #define PCIE_EXT_CAP_ID_AER 0x1 /* Advanced Error Handling */
429 #define PCIE_EXT_CAP_ID_VC 0x2 /* Virtual Channel, no MFVC */
430 #define PCIE_EXT_CAP_ID_SER 0x3 /* Serial Number */
431 #define PCIE_EXT_CAP_ID_PWR_BUDGET 0x4 /* Power Budgeting */
432 #define PCIE_EXT_CAP_ID_RC_LINK_DECL 0x5 /* RC Link Declaration */
433 #define PCIE_EXT_CAP_ID_RC_INT_LINKCTRL 0x6 /* RC Internal Link Control */
434 #define PCIE_EXT_CAP_ID_RC_EVNT_CEA 0x7 /* RC Event Collector */
435 /* Endpoint Association */
436 #define PCIE_EXT_CAP_ID_MFVC 0x8 /* Multi-func Virtual Channel */
437 #define PCIE_EXT_CAP_ID_VC_WITH_MFVC 0x9 /* Virtual Channel w/ MFVC */
438 #define PCIE_EXT_CAP_ID_RCRB 0xA /* Root Complex Register Blck */
439 #define PCIE_EXT_CAP_ID_VS 0xB /* Vendor Spec Extended Cap */
440 #define PCIE_EXT_CAP_ID_CAC 0xC /* Config Access Correlation */
441 #define PCIE_EXT_CAP_ID_ACS 0xD /* Access Control Services */
442 #define PCIE_EXT_CAP_ID_ARI 0xE /* Alternative Routing ID */
443 #define PCIE_EXT_CAP_ID_ATS 0xF /* Address Translation Svcs */
446 * PCI-Express Advanced Error Reporting Extended Capability Offsets
448 #define PCIE_AER_CAP 0x0 /* Enhanced Capability Header */
449 #define PCIE_AER_UCE_STS 0x4 /* Uncorrectable Error Status */
450 #define PCIE_AER_UCE_MASK 0x8 /* Uncorrectable Error Mask */
451 #define PCIE_AER_UCE_SERV 0xc /* Uncor Error Severity */
452 #define PCIE_AER_CE_STS 0x10 /* Correctable Error Status */
453 #define PCIE_AER_CE_MASK 0x14 /* Correctable Error Mask */
454 #define PCIE_AER_CTL 0x18 /* AER Capability & Control */
455 #define PCIE_AER_HDR_LOG 0x1c /* Header Log */
457 /* Root Ports Only */
458 #define PCIE_AER_RE_CMD 0x2c /* Root Error Command */
459 #define PCIE_AER_RE_STS 0x30 /* Root Error Status */
460 #define PCIE_AER_CE_SRC_ID 0x34 /* Error Source ID */
461 #define PCIE_AER_ERR_SRC_ID 0x36 /* Error Source ID */
463 /* Bridges Only */
464 #define PCIE_AER_SUCE_STS 0x2c /* Secondary UCE Status */
465 #define PCIE_AER_SUCE_MASK 0x30 /* Secondary UCE Mask */
466 #define PCIE_AER_SUCE_SERV 0x34 /* Secondary UCE Severity */
467 #define PCIE_AER_SCTL 0x38 /* Secondary Cap & Ctl */
468 #define PCIE_AER_SHDR_LOG 0x3c /* Secondary Header Log */
471 * AER Uncorrectable Error Status/Mask/Severity Register
473 #define PCIE_AER_UCE_TRAINING 0x1 /* Training Error Status */
474 #define PCIE_AER_UCE_DLP 0x10 /* Data Link Protocol Error */
475 #define PCIE_AER_UCE_SD 0x20 /* Link Surprise down */
476 #define PCIE_AER_UCE_PTLP 0x1000 /* Poisoned TLP Status */
477 #define PCIE_AER_UCE_FCP 0x2000 /* Flow Control Protocol Sts */
478 #define PCIE_AER_UCE_TO 0x4000 /* Completion Timeout Status */
479 #define PCIE_AER_UCE_CA 0x8000 /* Completer Abort Status */
480 #define PCIE_AER_UCE_UC 0x10000 /* Unexpected Completion Sts */
481 #define PCIE_AER_UCE_RO 0x20000 /* Receiver Overflow Status */
482 #define PCIE_AER_UCE_MTLP 0x40000 /* Malformed TLP Status */
483 #define PCIE_AER_UCE_ECRC 0x80000 /* ECRC Error Status */
484 #define PCIE_AER_UCE_UR 0x100000 /* Unsupported Req */
485 #define PCIE_AER_UCE_BITS (PCIE_AER_UCE_TRAINING | \
486 PCIE_AER_UCE_DLP | PCIE_AER_UCE_SD | PCIE_AER_UCE_PTLP | \
487 PCIE_AER_UCE_FCP | PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | \
488 PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | PCIE_AER_UCE_MTLP | \
489 PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
490 #define PCIE_AER_UCE_LOG_BITS (PCIE_AER_UCE_PTLP | PCIE_AER_UCE_CA | \
491 PCIE_AER_UCE_UC | PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR)
494 * AER Correctable Error Status/Mask Register
496 #define PCIE_AER_CE_RECEIVER_ERR 0x1 /* Receiver Error Status */
497 #define PCIE_AER_CE_BAD_TLP 0x40 /* Bad TLP Status */
498 #define PCIE_AER_CE_BAD_DLLP 0x80 /* Bad DLLP Status */
499 #define PCIE_AER_CE_REPLAY_ROLLOVER 0x100 /* REPLAY_NUM Rollover Status */
500 #define PCIE_AER_CE_REPLAY_TO 0x1000 /* Replay Timer Timeout Sts */
501 #define PCIE_AER_CE_AD_NFE 0x2000 /* Advisory Non-Fatal Status */
502 #define PCIE_AER_CE_BITS (PCIE_AER_CE_RECEIVER_ERR | \
503 PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \
504 PCIE_AER_CE_REPLAY_TO)
507 * AER Capability & Control
509 #define PCIE_AER_CTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */
510 #define PCIE_AER_CTL_ECRC_GEN_CAP 0x20 /* ECRC Generation Capable */
511 #define PCIE_AER_CTL_ECRC_GEN_ENA 0x40 /* ECRC Generation Enable */
512 #define PCIE_AER_CTL_ECRC_CHECK_CAP 0x80 /* ECRC Check Capable */
513 #define PCIE_AER_CTL_ECRC_CHECK_ENA 0x100 /* ECRC Check Enable */
516 * AER Root Command Register
518 #define PCIE_AER_RE_CMD_CE_REP_EN 0x1 /* Correctable Error Enable */
519 #define PCIE_AER_RE_CMD_NFE_REP_EN 0x2 /* Non-Fatal Error Enable */
520 #define PCIE_AER_RE_CMD_FE_REP_EN 0x4 /* Fatal Error Enable */
523 * AER Root Error Status Register
525 #define PCIE_AER_RE_STS_CE_RCVD 0x1 /* ERR_COR Received */
526 #define PCIE_AER_RE_STS_MUL_CE_RCVD 0x2 /* Multiple ERR_COR Received */
527 #define PCIE_AER_RE_STS_FE_NFE_RCVD 0x4 /* FATAL/NON-FATAL Received */
528 #define PCIE_AER_RE_STS_MUL_FE_NFE_RCVD 0x8 /* Multiple ERR_F/NF Received */
529 #define PCIE_AER_RE_STS_FIRST_UC_FATAL 0x10 /* First Uncorrectable Fatal */
530 #define PCIE_AER_RE_STS_NFE_MSGS_RCVD 0x20 /* Non-Fatal Error Msgs Rcvd */
531 #define PCIE_AER_RE_STS_FE_MSGS_RCVD 0x40 /* Fatal Error Messages Rcvd */
533 #define PCIE_AER_RE_STS_MSG_NUM_SHIFT 27 /* Offset of Intr Msg Number */
534 #define PCIE_AER_RE_STS_MSG_NUM_MASK 0x1F /* Intr Msg Number Mask */
537 * AER Error Source Identification Register
539 #define PCIE_AER_ERR_SRC_ID_CE_SHIFT 0 /* ERR_COR Source ID */
540 #define PCIE_AER_ERR_SRC_ID_CE_MASK 0xFFFF
541 #define PCIE_AER_ERR_SRC_ID_UE_SHIFT 16 /* ERR_FATAL/NONFATAL Src ID */
542 #define PCIE_AER_ERR_SRC_ID_UE_MASK 0xFFFF
545 * AER Secondary Uncorrectable Error Register
547 #define PCIE_AER_SUCE_TA_ON_SC 0x1 /* Target Abort on Split Comp */
548 #define PCIE_AER_SUCE_MA_ON_SC 0x2 /* Master Abort on Split Comp */
549 #define PCIE_AER_SUCE_RCVD_TA 0x4 /* Received Target Abort */
550 #define PCIE_AER_SUCE_RCVD_MA 0x8 /* Received Master Abort */
551 #define PCIE_AER_SUCE_USC_ERR 0x20 /* Unexpected Split Comp Err */
552 #define PCIE_AER_SUCE_USC_MSG_DATA_ERR 0x40 /* USC Message Data Error */
553 #define PCIE_AER_SUCE_UC_DATA_ERR 0x80 /* Uncorrectable Data Error */
554 #define PCIE_AER_SUCE_UC_ATTR_ERR 0x100 /* UC Attribute Err */
555 #define PCIE_AER_SUCE_UC_ADDR_ERR 0x200 /* Uncorrectable Address Err */
556 #define PCIE_AER_SUCE_TIMER_EXPIRED 0x400 /* Delayed xtion discard */
557 #define PCIE_AER_SUCE_PERR_ASSERT 0x800 /* PERR Assertion Detected */
558 #define PCIE_AER_SUCE_SERR_ASSERT 0x1000 /* SERR Assertion Detected */
559 #define PCIE_AER_SUCE_INTERNAL_ERR 0x2000 /* Internal Bridge Err Detect */
561 #define PCIE_AER_SUCE_HDR_CMD_LWR_MASK 0xF /* Lower Command Mask */
562 #define PCIE_AER_SUCE_HDR_CMD_LWR_SHIFT 4 /* Lower Command Shift */
563 #define PCIE_AER_SUCE_HDR_CMD_UP_MASK 0xF /* Upper Command Mask */
564 #define PCIE_AER_SUCE_HDR_CMD_UP_SHIFT 8 /* Upper Command Shift */
565 #define PCIE_AER_SUCE_HDR_ADDR_SHIFT 32 /* Upper Command Shift */
567 #define PCIE_AER_SUCE_BITS (PCIE_AER_SUCE_TA_ON_SC | \
568 PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
569 PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
570 PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
571 PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_TIMER_EXPIRED | \
572 PCIE_AER_SUCE_PERR_ASSERT | PCIE_AER_SUCE_SERR_ASSERT | \
573 PCIE_AER_SUCE_INTERNAL_ERR)
574 #define PCIE_AER_SUCE_LOG_BITS (PCIE_AER_SUCE_TA_ON_SC | \
575 PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \
576 PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \
577 PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \
578 PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_PERR_ASSERT)
581 * AER Secondary Capability & Control
583 #define PCIE_AER_SCTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */
586 * AER Secondary Headers
587 * The Secondary Header Logs is 4 DW long.
588 * The first 2 DW are split into 3 sections
589 * o Transaction Attribute
590 * o Transaction Command Lower
591 * o Transaction Command Higher
592 * The last 2 DW is the Transaction Address
594 #define PCIE_AER_SHDR_LOG_ATTR_MASK 0xFFFFFFFFF
595 #define PCIE_AER_SHDR_LOG_CMD_LOW_MASK 0xF000000000
596 #define PCIE_AER_SHDR_LOG_CMD_HIGH_MASK 0xF0000000000
597 #define PCIE_AER_SHDR_LOG_ADDR_MASK 0xFFFFFFFFFFFFFFFF
600 * PCI-Express Device Serial Number Capability Offsets.
602 #define PCIE_SER_CAP 0x0 /* Enhanced Capability Header */
603 #define PCIE_SER_SID_LOWER_DW 0x4 /* Lower 32-bit Serial Number */
604 #define PCIE_SER_SID_UPPER_DW 0x8 /* Upper 32-bit Serial Number */
607 * ARI Capability Offsets
609 #define PCIE_ARI_HDR 0x0 /* Enhanced Capability Header */
610 #define PCIE_ARI_CAP 0x4 /* ARI Capability Register */
611 #define PCIE_ARI_CTL 0x6 /* ARI Control Register */
613 #define PCIE_ARI_CAP_MFVC_FUNC_GRP 0x01
614 #define PCIE_ARI_CAP_ASC_FUNC_GRP 0x02
616 #define PCIE_ARI_CAP_NEXT_FUNC_SHIFT 8
617 #define PCIE_ARI_CAP_NEXT_FUNC_MASK 0xffff
619 #define PCIE_ARI_CTRL_MFVC_FUNC_GRP 0x01
620 #define PCIE_ARI_CTRL_ASC_FUNC_GRP 0x02
622 #define PCIE_ARI_CTRL_FUNC_GRP_SHIFT 4
623 #define PCIE_ARI_CTRL_FUNC_GRP_MASK 0x7
626 * PCI-E Common TLP Header Fields
628 #define PCIE_TLP_FMT_3DW 0x00
629 #define PCIE_TLP_FMT_4DW 0x20
630 #define PCIE_TLP_FMT_3DW_DATA 0x40
631 #define PCIE_TLP_FMT_4DW_DATA 0x60
633 #define PCIE_TLP_TYPE_MEM 0x0
634 #define PCIE_TLP_TYPE_MEMLK 0x1
635 #define PCIE_TLP_TYPE_IO 0x2
636 #define PCIE_TLP_TYPE_CFG0 0x4
637 #define PCIE_TLP_TYPE_CFG1 0x5
638 #define PCIE_TLP_TYPE_MSG 0x10
639 #define PCIE_TLP_TYPE_CPL 0xA
640 #define PCIE_TLP_TYPE_CPLLK 0xB
641 #define PCIE_TLP_TYPE_MSI 0x18
643 #define PCIE_TLP_MRD3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM)
644 #define PCIE_TLP_MRD4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM)
645 #define PCIE_TLP_MRDLK3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK)
646 #define PCIE_TLP_MRDLK4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK)
647 #define PCIE_TLP_MRDWR3 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM)
648 #define PCIE_TLP_MRDWR4 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM)
649 #define PCIE_TLP_IORD (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO)
650 #define PCIE_TLP_IOWR (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO)
651 #define PCIE_TLP_CFGRD0 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0)
652 #define PCIE_TLP_CFGWR0 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0)
653 #define PCIE_TLP_CFGRD1 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1)
654 #define PCIE_TLP_CFGWR1 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1)
655 #define PCIE_TLP_MSG (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG)
656 #define PCIE_TLP_MSGD (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG)
657 #define PCIE_TLP_CPL (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL)
658 #define PCIE_TLP_CPLD (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL)
659 #define PCIE_TLP_CPLLK (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK)
660 #define PCIE_TLP_CPLDLK (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK)
661 #define PCIE_TLP_MSI32 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI)
662 #define PCIE_TLP_MSI64 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI)
664 typedef uint16_t pcie_req_id_t;
666 #define PCIE_REQ_ID_BUS_SHIFT 8
667 #define PCIE_REQ_ID_BUS_MASK 0xFF00
668 #define PCIE_REQ_ID_DEV_SHIFT 3
669 #define PCIE_REQ_ID_DEV_MASK 0x00F8
670 #define PCIE_REQ_ID_FUNC_SHIFT 0
671 #define PCIE_REQ_ID_FUNC_MASK 0x0007
672 #define PCIE_REQ_ID_ARI_FUNC_MASK 0x00FF
674 #define PCIE_CPL_STS_SUCCESS 0
675 #define PCIE_CPL_STS_UR 1
676 #define PCIE_CPL_STS_CRS 2
677 #define PCIE_CPL_STS_CA 4
679 #if defined(_BIT_FIELDS_LTOH)
681 * PCI Express little-endian common TLP header format
683 typedef struct pcie_tlp_hdr {
684 uint32_t len :10,
685 rsvd3 :2,
686 attr :2,
687 ep :1,
688 td :1,
689 rsvd2 :4,
690 tc :3,
691 rsvd1 :1,
692 type :5,
693 fmt :2,
694 rsvd0 :1;
695 } pcie_tlp_hdr_t;
697 typedef struct pcie_mem64 {
698 uint32_t fbe :4,
699 lbe :4,
700 tag :8,
701 rid :16;
702 uint32_t addr1;
703 uint32_t rsvd0 :2,
704 addr0 :30;
705 } pcie_mem64_t;
707 typedef struct pcie_memio32 {
708 uint32_t fbe :4,
709 lbe :4,
710 tag :8,
711 rid :16;
712 uint32_t rsvd0 :2,
713 addr0 :30;
714 } pcie_memio32_t;
716 typedef struct pcie_cfg {
717 uint32_t fbe :4,
718 lbe :4,
719 tag :8,
720 rid :16;
721 uint32_t rsvd1 :2,
722 reg :6,
723 extreg :4,
724 rsvd0 :4,
725 func :3,
726 dev :5,
727 bus :8;
728 } pcie_cfg_t;
730 typedef struct pcie_cpl {
731 uint32_t bc :12,
732 bcm :1,
733 status :3,
734 cid :16;
735 uint32_t laddr :7,
736 rsvd0 :1,
737 tag :8,
738 rid :16;
739 } pcie_cpl_t;
742 * PCI-Express Message Request Header
744 typedef struct pcie_msg {
745 uint32_t msg_code:8, /* DW1 */
746 tag :8,
747 rid :16;
748 uint32_t unused[2]; /* DW 2 & 3 */
749 } pcie_msg_t;
751 #elif defined(_BIT_FIELDS_HTOL)
753 * PCI Express big-endian common TLP header format
755 typedef struct pcie_tlp_hdr {
756 uint32_t rsvd0 :1,
757 fmt :2,
758 type :5,
759 rsvd1 :1,
760 tc :3,
761 rsvd2 :4,
762 td :1,
763 ep :1,
764 attr :2,
765 rsvd3 :2,
766 len :10;
767 } pcie_tlp_hdr_t;
769 typedef struct pcie_mem64 {
770 uint32_t rid :16,
771 tag :8,
772 lbe :4,
773 fbe :4;
774 uint32_t addr1;
775 uint32_t addr0 :30,
776 rsvd0 :2;
777 } pcie_mem64_t;
779 typedef struct pcie_memio32 {
780 uint32_t rid :16,
781 tag :8,
782 lbe :4,
783 fbe :4;
784 uint32_t addr0 :30,
785 rsvd0 :2;
786 } pcie_memio32_t;
788 typedef struct pcie_cfg {
789 uint32_t rid :16,
790 tag :8,
791 lbe :4,
792 fbe :4;
793 uint32_t bus :8,
794 dev :5,
795 func :3,
796 rsvd0 :4,
797 extreg :4,
798 reg :6,
799 rsvd1 :2;
800 } pcie_cfg_t;
802 typedef struct pcie_cpl {
803 uint32_t cid :16,
804 status :3,
805 bcm :1,
806 bc :12;
807 uint32_t rid :16,
808 tag :8,
809 rsvd0 :1,
810 laddr :7;
811 } pcie_cpl_t;
814 * PCI-Express Message Request Header
816 typedef struct pcie_msg {
817 uint32_t rid :16, /* DW1 */
818 tag :8,
819 msg_code:8;
820 uint32_t unused[2]; /* DW 2 & 3 */
821 } pcie_msg_t;
822 #else
823 #error "bit field not defined"
824 #endif
826 #define PCIE_MSG_CODE_ERR_COR 0x30
827 #define PCIE_MSG_CODE_ERR_NONFATAL 0x31
828 #define PCIE_MSG_CODE_ERR_FATAL 0x33
830 #ifdef __cplusplus
832 #endif
834 #endif /* _SYS_PCIE_H */