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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 /* 26 * Copyright 2019, Joyent, Inc. 27 */ 28 29 #ifndef _SYS_PCIE_H 30 #define _SYS_PCIE_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/pci.h> 37 38 /* 39 * PCI Express capability registers in PCI configuration space relative to 40 * the PCI Express Capability structure. 41 */ 42 #define PCIE_CAP_ID PCI_CAP_ID 43 #define PCIE_CAP_NEXT_PTR PCI_CAP_NEXT_PTR 44 #define PCIE_PCIECAP 0x02 /* PCI-e Capability Reg */ 45 #define PCIE_DEVCAP 0x04 /* Device Capability */ 46 #define PCIE_DEVCTL 0x08 /* Device Control */ 47 #define PCIE_DEVSTS 0x0A /* Device Status */ 48 #define PCIE_LINKCAP 0x0C /* Link Capability */ 49 #define PCIE_LINKCTL 0x10 /* Link Control */ 50 #define PCIE_LINKSTS 0x12 /* Link Status */ 51 #define PCIE_SLOTCAP 0x14 /* Slot Capability */ 52 #define PCIE_SLOTCTL 0x18 /* Slot Control */ 53 #define PCIE_SLOTSTS 0x1A /* Slot Status */ 54 #define PCIE_ROOTCTL 0x1C /* Root Control */ 55 #define PCIE_ROOTCAP 0x1E /* Root Capabilities */ 56 #define PCIE_ROOTSTS 0x20 /* Root Status */ 57 #define PCIE_DEVCAP2 0x24 /* Device Capability 2 */ 58 #define PCIE_DEVCTL2 0x28 /* Device Control 2 */ 59 #define PCIE_DEVSTS2 0x2A /* Device Status 2 */ 60 #define PCIE_LINKCAP2 0x2C /* Link Capability 2 */ 61 #define PCIE_LINKCTL2 0x30 /* Link Control 2 */ 62 #define PCIE_LINKSTS2 0x32 /* Link Status 2 */ 63 #define PCIE_SLOTCAP2 0x34 /* Slot Capability 2 */ 64 #define PCIE_SLOTCTL2 0x38 /* Slot Control 2 */ 65 #define PCIE_SLOTSTS2 0x3A /* Slot Status 2 */ 66 67 /* 68 * PCI-Express Config Space size 69 */ 70 #define PCIE_CONF_HDR_SIZE 4096 /* PCIe configuration header size */ 71 72 /* 73 * PCI-Express Capabilities Register (2 bytes) 74 */ 75 #define PCIE_PCIECAP_VER_1_0 0x1 /* PCI-E spec 1.0 */ 76 #define PCIE_PCIECAP_VER_2_0 0x2 /* PCI-E spec 2.0 */ 77 #define PCIE_PCIECAP_VER_MASK 0xF /* Version Mask */ 78 #define PCIE_PCIECAP_DEV_TYPE_PCIE_DEV 0x00 /* PCI-E Endpont Device */ 79 #define PCIE_PCIECAP_DEV_TYPE_PCI_DEV 0x10 /* "Leg PCI" Endpont Device */ 80 #define PCIE_PCIECAP_DEV_TYPE_ROOT 0x40 /* Root Port of Root Complex */ 81 #define PCIE_PCIECAP_DEV_TYPE_UP 0x50 /* Upstream Port of Switch */ 82 #define PCIE_PCIECAP_DEV_TYPE_DOWN 0x60 /* Downstream Port of Switch */ 83 #define PCIE_PCIECAP_DEV_TYPE_PCIE2PCI 0x70 /* PCI-E to PCI Bridge */ 84 #define PCIE_PCIECAP_DEV_TYPE_PCI2PCIE 0x80 /* PCI to PCI-E Bridge */ 85 #define PCIE_PCIECAP_DEV_TYPE_RC_IEP 0x90 /* RootComplex Integrated Dev */ 86 #define PCIE_PCIECAP_DEV_TYPE_RC_EC 0xA0 /* RootComplex Evt Collector */ 87 #define PCIE_PCIECAP_DEV_TYPE_MASK 0xF0 /* Device/Port Type Mask */ 88 #define PCIE_PCIECAP_SLOT_IMPL 0x100 /* Slot Impl vs Integrated */ 89 #define PCIE_PCIECAP_INT_MSG_NUM 0x3E00 /* Interrupt Message Number */ 90 91 /* 92 * Device Capabilities Register (4 bytes) 93 */ 94 #define PCIE_DEVCAP_MAX_PAYLOAD_128 0x0 95 #define PCIE_DEVCAP_MAX_PAYLOAD_256 0x1 96 #define PCIE_DEVCAP_MAX_PAYLOAD_512 0x2 97 #define PCIE_DEVCAP_MAX_PAYLOAD_1024 0x3 98 #define PCIE_DEVCAP_MAX_PAYLOAD_2048 0x4 99 #define PCIE_DEVCAP_MAX_PAYLOAD_4096 0x5 100 #define PCIE_DEVCAP_MAX_PAYLOAD_MASK 0x7 /* Max Payload Size Supported */ 101 102 #define PCIE_DEVCAP_PHTM_FUNC_NONE 0x00 /* No Function # bits used */ 103 #define PCIE_DEVCAP_PHTM_FUNC_ONE 0x08 /* First most sig. bit used */ 104 #define PCIE_DEVCAP_PHTM_FUNC_TWO 0x10 /* First 2 most sig bit used */ 105 #define PCIE_DEVCAP_PHTM_FUNC_THREE 0x18 /* All 3 bits used */ 106 #define PCIE_DEVCAP_PHTM_FUNC_MASK 0x18 /* Phantom Func Supported */ 107 108 #define PCIE_DEVCAP_EXT_TAG_5BIT 0x00 /* 5-Bit Tag Field Supported */ 109 #define PCIE_DEVCAP_EXT_TAG_8BIT 0x20 /* 8-Bit Tag Field Supported */ 110 #define PCIE_DEVCAP_EXT_TAG_MASK 0x20 /* Ext. Tag Field Supported */ 111 112 #define PCIE_DEVCAP_EP_L0S_LAT_MIN 0x000 /* < 64 ns */ 113 #define PCIE_DEVCAP_EP_L0S_LAT_64ns 0x040 /* 64 ns - 128 ns */ 114 #define PCIE_DEVCAP_EP_L0S_LAT_128ns 0x080 /* 128 ns - 256 ns */ 115 #define PCIE_DEVCAP_EP_L0S_LAT_256ns 0x0C0 /* 256 ns - 512 ns */ 116 #define PCIE_DEVCAP_EP_L0S_LAT_512ns 0x100 /* 512 ns - 1 us */ 117 #define PCIE_DEVCAP_EP_L0S_LAT_1us 0x140 /* 1 us - 2 us */ 118 #define PCIE_DEVCAP_EP_L0S_LAT_2us 0x180 /* 2 us - 4 us */ 119 #define PCIE_DEVCAP_EP_L0S_LAT_MAX 0x1C0 /* > 4 us */ 120 #define PCIE_DEVCAP_EP_L0S_LAT_MASK 0x1C0 /* EP L0s Accetable Latency */ 121 122 #define PCIE_DEVCAP_EP_L1_LAT_MIN 0x000 /* < 1 us */ 123 #define PCIE_DEVCAP_EP_L1_LAT_1us 0x140 /* 1 us - 2 us */ 124 #define PCIE_DEVCAP_EP_L1_LAT_2us 0x180 /* 2 us - 4 us */ 125 #define PCIE_DEVCAP_EP_L1_LAT_4us 0x140 /* 4 us - 8 us */ 126 #define PCIE_DEVCAP_EP_L1_LAT_8us 0x180 /* 8 us - 16 us */ 127 #define PCIE_DEVCAP_EP_L1_LAT_16us 0x140 /* 16 us - 32 us */ 128 #define PCIE_DEVCAP_EP_L1_LAT_32us 0x180 /* 32 us - 64 us */ 129 #define PCIE_DEVCAP_EP_L1_LAT_MAX 0x1C0 /* > 64 us */ 130 #define PCIE_DEVCAP_EP_L1_LAT_MASK 0x700 /* EP L1 Accetable Latency */ 131 132 /* 133 * As of PCIe 2.x these three bits are now undefined. 134 */ 135 #define PCIE_DEVCAP_ATTN_BUTTON 0x1000 /* Attention Button Present */ 136 #define PCIE_DEVCAP_ATTN_INDICATOR 0x2000 /* Attn Indicator Present */ 137 #define PCIE_DEVCAP_PWR_INDICATOR 0x4000 /* Power Indicator Present */ 138 139 #define PCIE_DEVCAP_ROLE_BASED_ERR_REP 0x8000 /* Role Based Error Reporting */ 140 141 #define PCIE_DEVCAP_PLMT_VAL_SHIFT 18 /* Power Limit Value Shift */ 142 #define PCIE_DEVCAP_PLMT_VAL_MASK 0xFF /* Power Limit Value Mask */ 143 144 #define PCIE_DEVCAP_PLMT_SCL_1_BY_1 0x0000000 /* 1x Scale */ 145 #define PCIE_DEVCAP_PLMT_SCL_1_BY_10 0x4000000 /* 0.1x Scale */ 146 #define PCIE_DEVCAP_PLMT_SCL_1_BY_100 0x8000000 /* 0.01x Scale */ 147 #define PCIE_DEVCAP_PLMT_SCL_1_BY_1000 0xC000000 /* 0.001x Scale */ 148 #define PCIE_DEVCAP_PLMT_SCL_MASK 0xC000000 /* Power Limit Scale */ 149 150 #define PCIE_DEVCAP_FLR 0x10000000 /* Function Level Reset */ 151 152 /* 153 * Device Control Register (2 bytes) 154 */ 155 #define PCIE_DEVCTL_CE_REPORTING_EN 0x1 /* Correctable Error Enable */ 156 #define PCIE_DEVCTL_NFE_REPORTING_EN 0x2 /* Non-Fatal Error Enable */ 157 #define PCIE_DEVCTL_FE_REPORTING_EN 0x4 /* Fatal Error Enable */ 158 #define PCIE_DEVCTL_UR_REPORTING_EN 0x8 /* Unsupported Request Enable */ 159 #define PCIE_DEVCTL_ERR_MASK 0xF /* All of the above bits */ 160 161 #define PCIE_DEVCTL_RO_EN 0x10 /* Enable Relaxed Ordering */ 162 163 #define PCIE_DEVCTL_MAX_PAYLOAD_128 0x00 164 #define PCIE_DEVCTL_MAX_PAYLOAD_256 0x20 165 #define PCIE_DEVCTL_MAX_PAYLOAD_512 0x40 166 #define PCIE_DEVCTL_MAX_PAYLOAD_1024 0x60 167 #define PCIE_DEVCTL_MAX_PAYLOAD_2048 0x80 168 #define PCIE_DEVCTL_MAX_PAYLOAD_4096 0xA0 169 #define PCIE_DEVCTL_MAX_PAYLOAD_MASK 0xE0 /* Max_Payload_Size */ 170 #define PCIE_DEVCTL_MAX_PAYLOAD_SHIFT 0x5 171 172 #define PCIE_DEVCTL_EXT_TAG_FIELD_EN 0x100 /* Extended Tag Field Enable */ 173 #define PCIE_DEVCTL_PHTM_FUNC_EN 0x200 /* Phantom Functions Enable */ 174 #define PCIE_DEVCTL_AUX_POWER_PM_EN 0x400 /* Auxiliary Power PM Enable */ 175 #define PCIE_DEVCTL_ENABLE_NO_SNOOP 0x800 /* Enable No Snoop */ 176 177 #define PCIE_DEVCTL_MAX_READ_REQ_128 0x0000 178 #define PCIE_DEVCTL_MAX_READ_REQ_256 0x1000 179 #define PCIE_DEVCTL_MAX_READ_REQ_512 0x2000 180 #define PCIE_DEVCTL_MAX_READ_REQ_1024 0x3000 181 #define PCIE_DEVCTL_MAX_READ_REQ_2048 0x4000 182 #define PCIE_DEVCTL_MAX_READ_REQ_4096 0x5000 183 #define PCIE_DEVCTL_MAX_READ_REQ_MASK 0x7000 /* Max_Read_Request_Size */ 184 #define PCIE_DEVCTL_MAX_READ_REQ_SHIFT 0xC 185 186 #define PCIE_DEVCTL_BRIDGE_RETRY 0x8000 /* Bridge can return CRS */ 187 #define PCIE_DEVCTL_INITIATE_FLR 0x8000 /* Start Function Level Reset */ 188 189 /* 190 * Device Status Register (2 bytes) 191 */ 192 #define PCIE_DEVSTS_CE_DETECTED 0x1 /* Correctable Error Detected */ 193 #define PCIE_DEVSTS_NFE_DETECTED 0x2 /* Non Fatal Error Detected */ 194 #define PCIE_DEVSTS_FE_DETECTED 0x4 /* Fatal Error Detected */ 195 #define PCIE_DEVSTS_UR_DETECTED 0x8 /* Unsupported Req Detected */ 196 #define PCIE_DEVSTS_AUX_POWER 0x10 /* AUX Power Detected */ 197 #define PCIE_DEVSTS_TRANS_PENDING 0x20 /* Transactions Pending */ 198 #define PCIE_DEVSTS_EPR_DETECTED 0x40 /* Emergency Power Reduction */ 199 200 /* 201 * Link Capability Register (4 bytes) 202 */ 203 #define PCIE_LINKCAP_MAX_SPEED_2_5 0x1 /* 2.5 GT/s Speed */ 204 /* 205 * In version 2 of PCI express, this indicated that both 5.0 GT/s and 2.5 GT/s 206 * speeds were supported. The use of this as the maximum link speed was added 207 * with PCIex v3. 208 */ 209 #define PCIE_LINKCAP_MAX_SPEED_5 0x2 /* 5.0 GT/s Speed */ 210 #define PCIE_LINKCAP_MAX_SPEED_8 0x3 /* 8.0 GT/s Speed */ 211 #define PCIE_LINKCAP_MAX_SPEED_16 0x4 /* 16.0 GT/s Speed */ 212 #define PCIE_LINKCAP_MAX_SPEED_MASK 0xF /* Maximum Link Speed */ 213 #define PCIE_LINKCAP_MAX_WIDTH_X1 0x010 214 #define PCIE_LINKCAP_MAX_WIDTH_X2 0x020 215 #define PCIE_LINKCAP_MAX_WIDTH_X4 0x040 216 #define PCIE_LINKCAP_MAX_WIDTH_X8 0x080 217 #define PCIE_LINKCAP_MAX_WIDTH_X12 0x0C0 218 #define PCIE_LINKCAP_MAX_WIDTH_X16 0x100 219 #define PCIE_LINKCAP_MAX_WIDTH_X32 0x200 220 #define PCIE_LINKCAP_MAX_WIDTH_MASK 0x3f0 /* Maximum Link Width */ 221 222 #define PCIE_LINKCAP_ASPM_SUP_L0S 0x400 /* L0s Entry Supported */ 223 #define PCIE_LINKCAP_ASPM_SUP_L1 0x800 /* L1 Entry Supported */ 224 #define PCIE_LINKCAP_ASPM_SUP_L0S_L1 0xC00 /* L0s abd L1 Supported */ 225 #define PCIE_LINKCAP_ASPM_SUP_MASK 0xC00 /* ASPM Support */ 226 227 #define PCIE_LINKCAP_L0S_EXIT_LAT_MIN 0x0000 /* < 64 ns */ 228 #define PCIE_LINKCAP_L0S_EXIT_LAT_64ns 0x1000 /* 64 ns - 128 ns */ 229 #define PCIE_LINKCAP_L0S_EXIT_LAT_128ns 0x2000 /* 128 ns - 256 ns */ 230 #define PCIE_LINKCAP_L0S_EXIT_LAT_256ns 0x3000 /* 256 ns - 512 ns */ 231 #define PCIE_LINKCAP_L0S_EXIT_LAT_512ns 0x4000 /* 512 ns - 1 us */ 232 #define PCIE_LINKCAP_L0S_EXIT_LAT_1us 0x5000 /* 1 us - 2 us */ 233 #define PCIE_LINKCAP_L0S_EXIT_LAT_2us 0x6000 /* 2 us - 4 us */ 234 #define PCIE_LINKCAP_L0S_EXIT_LAT_MAX 0x7000 /* > 4 us */ 235 #define PCIE_LINKCAP_L0S_EXIT_LAT_MASK 0x7000 /* L0s Exit Latency */ 236 237 #define PCIE_LINKCAP_L1_EXIT_LAT_MIN 0x00000 /* < 1 us */ 238 #define PCIE_LINKCAP_L1_EXIT_LAT_1us 0x08000 /* 1 us - 2 us */ 239 #define PCIE_LINKCAP_L1_EXIT_LAT_2us 0x10000 /* 2 us - 4 us */ 240 #define PCIE_LINKCAP_L1_EXIT_LAT_4us 0x18000 /* 4 us - 8 us */ 241 #define PCIE_LINKCAP_L1_EXIT_LAT_8us 0x20000 /* 8 us - 16 us */ 242 #define PCIE_LINKCAP_L1_EXIT_LAT_16us 0x28000 /* 16 us - 32 us */ 243 #define PCIE_LINKCAP_L1_EXIT_LAT_32us 0x30000 /* 32 us - 64 us */ 244 #define PCIE_LINKCAP_L1_EXIT_LAT_MAX 0x38000 /* > 64 us */ 245 #define PCIE_LINKCAP_L1_EXIT_LAT_MASK 0x38000 /* L1 Exit Latency */ 246 247 #define PCIE_LINKCAP_CLOCK_POWER_MGMT 0x40000 /* Clock Power Management */ 248 #define PCIE_LINKCAP_SDER_CAP 0x80000 /* Surprise Down Err report */ 249 #define PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE 0x100000 /* DLL Active */ 250 /* Capable bit */ 251 #define PCIE_LINKCAP_LINK_BW_NOTIFY_CAP 0x200000 /* Link Bandwidth Notify Cap */ 252 #define PCIE_LINKCAP_ASPM_OPTIONAL 0x400000 /* ASPM Opt. Comp. */ 253 254 #define PCIE_LINKCAP_PORT_NUMBER 0xFF000000 /* Port Number */ 255 #define PCIE_LINKCAP_PORT_NUMBER_SHIFT 24 /* Port Number Shift */ 256 #define PCIE_LINKCAP_PORT_NUMBER_MASK 0xFF /* Port Number Mask */ 257 258 /* 259 * Link Control Register (2 bytes) 260 */ 261 #define PCIE_LINKCTL_ASPM_CTL_DIS 0x0 /* ASPM Disable */ 262 #define PCIE_LINKCTL_ASPM_CTL_L0S 0x1 /* ASPM L0s only */ 263 #define PCIE_LINKCTL_ASPM_CTL_L1 0x2 /* ASPM L1 only */ 264 #define PCIE_LINKCTL_ASPM_CTL_L0S_L1 0x3 /* ASPM L0s and L1 only */ 265 #define PCIE_LINKCTL_ASPM_CTL_MASK 0x3 /* ASPM Control */ 266 267 #define PCIE_LINKCTL_RCB_64_BYTE 0x0 /* 64 Byte */ 268 #define PCIE_LINKCTL_RCB_128_BYTE 0x8 /* 128 Byte */ 269 #define PCIE_LINKCTL_RCB_MASK 0x8 /* Read Completion Boundary */ 270 271 #define PCIE_LINKCTL_LINK_DISABLE 0x10 /* Link Disable */ 272 #define PCIE_LINKCTL_RETRAIN_LINK 0x20 /* Retrain Link */ 273 #define PCIE_LINKCTL_COMMON_CLK_CFG 0x40 /* Common Clock Configuration */ 274 #define PCIE_LINKCTL_EXT_SYNCH 0x80 /* Extended Synch */ 275 #define PCIE_LINKCTL_CLOCK_POWER_MGMT 0x100 /* Enable Clock Power Mgmt. */ 276 #define PCIE_LINKCTL_HW_WIDTH_DISABLE 0x200 /* hw auto width disable */ 277 #define PCIE_LINKCTL_LINK_BW_INTR_EN 0x400 /* Link bw mgmt intr */ 278 #define PCIE_LINKCTL_LINK_AUTO_BW_INTR_EN 0x800 /* Auto bw intr */ 279 280 #define PCI_LINKCTRL_DRS_SIG_CTRL_NO_REP 0x00 281 #define PCI_LINKCTRL_DRS_SIG_CTRL_IE 0x4000 282 #define PCI_LINKCTRL_DRS_SIG_CTRL_DRS_FRS 0x8000 283 #define PCIE_LINKCTL_DRS_SIG_CTRL_MASK 0xC000 /* DRS Signaling Control */ 284 285 /* 286 * Link Status Register (2 bytes) 287 */ 288 #define PCIE_LINKSTS_SPEED_2_5 0x1 /* 2.5 GT/s Link Speed */ 289 #define PCIE_LINKSTS_SPEED_5 0x2 /* 5.0 GT/s Link Speed */ 290 #define PCIE_LINKSTS_SPEED_8 0x3 /* 8.0 GT/s Link Speed */ 291 #define PCIE_LINKSTS_SPEED_16 0x4 /* 16.0 GT/s Link Speed */ 292 #define PCIE_LINKSTS_SPEED_MASK 0xF /* Link Speed */ 293 294 #define PCIE_LINKSTS_NEG_WIDTH_X1 0x010 295 #define PCIE_LINKSTS_NEG_WIDTH_X2 0x020 296 #define PCIE_LINKSTS_NEG_WIDTH_X4 0x040 297 #define PCIE_LINKSTS_NEG_WIDTH_X8 0x080 298 #define PCIE_LINKSTS_NEG_WIDTH_X12 0x0C0 299 #define PCIE_LINKSTS_NEG_WIDTH_X16 0x100 300 #define PCIE_LINKSTS_NEG_WIDTH_X32 0x200 301 #define PCIE_LINKSTS_NEG_WIDTH_MASK 0x3F0 /* Negotiated Link Width */ 302 303 /* This bit is undefined as of PCIe 2.x */ 304 #define PCIE_LINKSTS_TRAINING_ERROR 0x400 /* Training Error */ 305 #define PCIE_LINKSTS_LINK_TRAINING 0x800 /* Link Training */ 306 #define PCIE_LINKSTS_SLOT_CLK_CFG 0x1000 /* Slot Clock Configuration */ 307 #define PCIE_LINKSTS_DLL_LINK_ACTIVE 0x2000 /* DLL Link Active */ 308 #define PCIE_LINKSTS_LINK_BW_MGMT 0x4000 /* Link bw mgmt status */ 309 #define PCIE_LINKSTS_AUTO_BW 0x8000 /* Link auto BW status */ 310 311 /* 312 * Slot Capability Register (4 bytes) 313 */ 314 #define PCIE_SLOTCAP_ATTN_BUTTON 0x1 /* Attention Button Present */ 315 #define PCIE_SLOTCAP_POWER_CONTROLLER 0x2 /* Power Controller Present */ 316 #define PCIE_SLOTCAP_MRL_SENSOR 0x4 /* MRL Sensor Present */ 317 #define PCIE_SLOTCAP_ATTN_INDICATOR 0x8 /* Attn Indicator Present */ 318 #define PCIE_SLOTCAP_PWR_INDICATOR 0x10 /* Power Indicator Present */ 319 #define PCIE_SLOTCAP_HP_SURPRISE 0x20 /* Hot-Plug Surprise */ 320 #define PCIE_SLOTCAP_HP_CAPABLE 0x40 /* Hot-Plug Capable */ 321 322 #define PCIE_SLOTCAP_PLMT_VAL_SHIFT 7 /* Slot Pwr Limit Value Shift */ 323 #define PCIE_SLOTCAP_PLMT_VAL_MASK 0xFF /* Slot Pwr Limit Value */ 324 325 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_1 0x00000 /* 1x Scale */ 326 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_10 0x08000 /* 0.1x Scale */ 327 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_100 0x10000 /* 0.01x Scale */ 328 #define PCIE_SLOTCAP_PLMT_SCL_1_BY_1000 0x18000 /* 0.001x Scale */ 329 #define PCIE_SLOTCAP_PLMT_SCL_MASK 0x18000 /* Slot Power Limit Scale */ 330 #define PCIE_SLOTCAP_EMI_LOCK_PRESENT 0x20000 /* EMI Lock Present */ 331 #define PCIE_SLOTCAP_NO_CMD_COMP_SUPP 0x40000 /* No Command Comp. Supported */ 332 333 #define PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT 19 /* Physical Slot Num Shift */ 334 #define PCIE_SLOTCAP_PHY_SLOT_NUM_MASK 0x1FFF /* Physical Slot Num Mask */ 335 336 #define PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \ 337 (((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \ 338 PCIE_SLOTCAP_PHY_SLOT_NUM_MASK) 339 340 /* 341 * Slot Control Register (2 bytes) 342 */ 343 #define PCIE_SLOTCTL_ATTN_BTN_EN 0x1 /* Attn Button Pressed Enable */ 344 #define PCIE_SLOTCTL_PWR_FAULT_EN 0x2 /* Pwr Fault Detected Enable */ 345 #define PCIE_SLOTCTL_MRL_SENSOR_EN 0x4 /* MRL Sensor Changed Enable */ 346 #define PCIE_SLOTCTL_PRESENCE_CHANGE_EN 0x8 /* Presence Detect Changed En */ 347 #define PCIE_SLOTCTL_CMD_INTR_EN 0x10 /* CMD Completed Interrupt En */ 348 #define PCIE_SLOTCTL_HP_INTR_EN 0x20 /* Hot-Plug Interrupt Enable */ 349 #define PCIE_SLOTCTL_PWR_CONTROL 0x0400 /* Power controller Control */ 350 #define PCIE_SLOTCTL_EMI_LOCK_CONTROL 0x0800 /* EMI Lock control */ 351 #define PCIE_SLOTCTL_DLL_STATE_EN 0x1000 /* DLL State Changed En */ 352 #define PCIE_SLOTCTL_AUTO_SLOT_PL_DIS 0x2000 /* Auto Slot Power Limit Dis */ 353 #define PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0 /* Attn Indicator mask */ 354 #define PCIE_SLOTCTL_PWR_INDICATOR_MASK 0x0300 /* Power Indicator mask */ 355 #define PCIE_SLOTCTL_INTR_MASK 0x103f /* Supported intr mask */ 356 357 /* State values for the Power and Attention Indicators */ 358 #define PCIE_SLOTCTL_INDICATOR_STATE_ON 0x1 /* indicator ON */ 359 #define PCIE_SLOTCTL_INDICATOR_STATE_BLINK 0x2 /* indicator BLINK */ 360 #define PCIE_SLOTCTL_INDICATOR_STATE_OFF 0x3 /* indicator OFF */ 361 362 /* 363 * Macros to set/get the state of Power and Attention Indicators 364 * in the PCI Express Slot Control Register. 365 */ 366 #define pcie_slotctl_pwr_indicator_get(reg) \ 367 (((reg) & PCIE_SLOTCTL_PWR_INDICATOR_MASK) >> 8) 368 #define pcie_slotctl_attn_indicator_get(ctrl) \ 369 (((ctrl) & PCIE_SLOTCTL_ATTN_INDICATOR_MASK) >> 6) 370 #define pcie_slotctl_attn_indicator_set(ctrl, v)\ 371 (((ctrl) & ~PCIE_SLOTCTL_ATTN_INDICATOR_MASK) | ((v) << 6)) 372 #define pcie_slotctl_pwr_indicator_set(ctrl, v)\ 373 (((ctrl) & ~PCIE_SLOTCTL_PWR_INDICATOR_MASK) | ((v) << 8)) 374 375 /* 376 * Slot Status register (2 bytes) 377 */ 378 #define PCIE_SLOTSTS_ATTN_BTN_PRESSED 0x1 /* Attention Button Pressed */ 379 #define PCIE_SLOTSTS_PWR_FAULT_DETECTED 0x2 /* Power Fault Detected */ 380 #define PCIE_SLOTSTS_MRL_SENSOR_CHANGED 0x4 /* MRL Sensor Changed */ 381 #define PCIE_SLOTSTS_PRESENCE_CHANGED 0x8 /* Presence Detect Changed */ 382 #define PCIE_SLOTSTS_COMMAND_COMPLETED 0x10 /* Command Completed */ 383 #define PCIE_SLOTSTS_MRL_SENSOR_OPEN 0x20 /* MRL Sensor Open */ 384 #define PCIE_SLOTSTS_PRESENCE_DETECTED 0x40 /* Card Present in slot */ 385 #define PCIE_SLOTSTS_EMI_LOCK_SET 0x0080 /* EMI Lock set */ 386 #define PCIE_SLOTSTS_DLL_STATE_CHANGED 0x0100 /* DLL State Changed */ 387 #define PCIE_SLOTSTS_STATUS_EVENTS 0x11f /* Supported events */ 388 389 /* 390 * Root Control Register (2 bytes) 391 */ 392 #define PCIE_ROOTCTL_SYS_ERR_ON_CE_EN 0x1 /* Sys Err on Cor Err Enable */ 393 #define PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN 0x2 /* Sys Err on NF Err Enable */ 394 #define PCIE_ROOTCTL_SYS_ERR_ON_FE_EN 0x4 /* Sys Err on Fatal Err En */ 395 #define PCIE_ROOTCTL_PME_INTERRUPT_EN 0x8 /* PME Interrupt Enable */ 396 #define PCIE_ROOTCTL_CRS_SW_VIS_EN 0x10 /* CRS SW Visibility EN */ 397 398 /* 399 * Root Capabilities register (2 bytes) 400 */ 401 #define PCIE_ROOTCAP_CRS_SW_VIS 0x01 /* CRS SW Visible */ 402 403 /* 404 * Root Status Register (4 bytes) 405 */ 406 #define PCIE_ROOTSTS_PME_REQ_ID_SHIFT 0 /* PME Requestor ID */ 407 #define PCIE_ROOTSTS_PME_REQ_ID_MASK 0xFFFF /* PME Requestor ID */ 408 409 #define PCIE_ROOTSTS_PME_STATUS 0x10000 /* PME Status */ 410 #define PCIE_ROOTSTS_PME_PENDING 0x20000 /* PME Pending */ 411 412 /* 413 * Device Capabilities 2 Register (4 bytes) 414 */ 415 #define PCIE_DEVCAP2_COM_TO_RANGE_MASK 0xF 416 #define PCIE_DEVCAP2_COM_TO_DISABLE 0x10 417 #define PCIE_DEVCAP2_ARI_FORWARD 0x20 418 #define PCIE_DEVCAP2_ATOMICOP_ROUTING 0x40 419 #define PCIE_DEVCAP2_32_ATOMICOP_COMPL 0x80 420 #define PCIE_DEVCAP2_64_ATOMICOP_COMPL 0x100 421 #define PCIE_DEVCAP2_128_CAS_COMPL 0x200 422 #define PCIE_DEVCAP2_NO_RO_PR_PR_PASS 0x400 423 #define PCIE_DEVCAP2_LTR_MECH 0x800 424 #define PCIE_DEVCAP2_TPH_COMP_SHIFT 12 425 #define PCIE_DEVCAP2_TPH_COMP_MASK 0x3 426 #define PCIE_DEVCAP2_LNSYS_CLS_SHIFT 14 427 #define PCIE_DEVCAP2_LNSYS_CLS_MASK 0x3 428 #define PCIE_DEVCAP2_10B_TAG_COMP_SUP 0x10000 429 #define PCIE_DEVCAP2_10B_TAG_REQ_SUP 0x20000 430 #define PCIE_DEVCAP2_OBFF_SHIFT 18 431 #define PCIE_DEVCAP2_OBFF_MASK 0x3 432 #define PCIE_DEVCAP2_EXT_FMT_FIELD 0x100000 433 #define PCIE_DEVCAP2_END_END_TLP_PREFIX 0x200000 434 #define PCIE_DEVCAP2_MAX_END_END_SHIFT 22 435 #define PCIE_DEVCAP2_MAX_END_END_MASK 0x3 436 #define PCIE_DEVCAP2_EPR_SUP_SHIFT 24 437 #define PCIE_DEVCAP2_EPR_SUP_MASK 0x3 438 #define PCIE_DEVCAP2_EPR_INIT_REQ 0x4000000 439 #define PCIE_DEVCAP2_FRS_SUP 0x80000000 440 441 /* 442 * Device Control 2 Register (2 bytes) 443 */ 444 #define PCIE_DEVCTL2_COM_TO_RANGE_MASK 0xf 445 #define PCIE_DEVCTL2_COM_TO_RANGE_0 0x0 446 #define PCIE_DEVCTL2_COM_TO_RANGE_1 0x1 447 #define PCIE_DEVCTL2_COM_TO_RANGE_2 0x2 448 #define PCIE_DEVCTL2_COM_TO_RANGE_3 0x5 449 #define PCIE_DEVCTL2_COM_TO_RANGE_4 0x6 450 #define PCIE_DEVCTL2_COM_TO_RANGE_5 0x9 451 #define PCIE_DEVCTL2_COM_TO_RANGE_6 0xa 452 #define PCIE_DEVCTL2_COM_TO_RANGE_7 0xd 453 #define PCIE_DEVCTL2_COM_TO_RANGE_8 0xe 454 #define PCIE_DEVCTL2_COM_TO_DISABLE 0x10 455 #define PCIE_DEVCTL2_ARI_FORWARD_EN 0x20 456 #define PCIE_DEVCTL2_ATOMICOP_REQ_EN 0x40 457 #define PCIE_DEVCTL2_ATOMICOP_EGRS_BLK 0x80 458 #define PCIE_DEVCTL2_IDO_REQ_EN 0x100 459 #define PCIE_DEVCTL2_IDO_COMPL_EN 0x200 460 #define PCIE_DEVCTL2_LTR_MECH_EN 0x400 461 #define PCIE_DEVCTL2_EPR_REQ 0x800 462 #define PCIE_DEVCTL2_10BTAG_REQ_EN 0x1000 463 #define PCIE_DEVCTL2_OBFF_MASK 0x6000 464 #define PCIE_DEVCTL2_OBFF_DISABLE 0x0000 465 #define PCIE_DEVCTL2_OBFF_EN_VARA 0x2000 466 #define PCIE_DEVCTL2_OBFF_EN_VARB 0x4000 467 #define PCIE_DEVCTL2_OBFF_EN_WAKE 0x6000 468 #define PCIE_DEVCTL2_END_END_TLP_PREFIX 0x8000 469 470 471 /* 472 * Link Capability 2 Register (4 bytes) 473 */ 474 #define PCIE_LINKCAP2_SPEED_2_5 0x02 475 #define PCIE_LINKCAP2_SPEED_5 0x04 476 #define PCIE_LINKCAP2_SPEED_8 0x08 477 #define PCIE_LINKCAP2_SPEED_16 0x10 478 #define PCIE_LINKCAP2_SPEED_MASK 0xfe 479 #define PCIE_LINKCAP2_CROSSLINK 0x100 480 #define PCIE_LINKCAP2_LSKP_OSGSS_MASK 0xfe00 481 #define PCIE_LINKCAP2_LKSP_OSGSS_2_5 0x0200 482 #define PCIE_LINKCAP2_LKSP_OSGSS_5 0x0400 483 #define PCIE_LINKCAP2_LKSP_OSGSS_8 0x0800 484 #define PCIE_LINKCAP2_LKSP_OSGSS_16 0x1000 485 #define PCIE_LINKCAP2_LKSP_OSRSS_MASK 0x7f0000 486 #define PCIE_LINKCAP2_LKSP_OSRSS_2_5 0x010000 487 #define PCIE_LINKCAP2_LKSP_OSRSS_5 0x020000 488 #define PCIE_LINKCAP2_LKSP_OSRSS_8 0x040000 489 #define PCIE_LINKCAP2_LKSP_OSRSS_16 0x080000 490 #define PCIE_LINKCAP2_RTPD_SUP 0x800000 491 #define PCIE_LINKCAP2_TRTPD_SUP 0x01000000 492 #define PCIE_LINKCAP2_DRS 0x80000000 493 494 /* 495 * Link Control 2 Register (2 bytes) 496 */ 497 #define PCIE_LINKCTL2_TARGET_SPEED_MASK 0x000f 498 #define PICE_LINKCTL2_ENTER_COMPLIANCE 0x0010 499 #define PCIE_LINKCTL2_HW_AUTO_SPEED_DIS 0x0020 500 #define PCIE_LINKCTL2_SELECT_DEEMPH 0x0040 501 #define PCIE_LINKCTL2_TX_MARGIN_MASK 0x0380 502 #define PCIE_LINKCTL2_ENTER_MOD_COMP 0x0400 503 #define PCIE_LINKCTL2_COMP_SOS 0x0800 504 #define PCIE_LINKCTL2_COMP_DEEMPM_MASK 0xf000 505 506 /* 507 * Link Status 2 Register (2 bytes) 508 */ 509 #define PCIE_LINKSTS2_CUR_DEEMPH 0x0001 510 #define PCIE_LINKSTS2_EQ8GT_COMP 0x0002 511 #define PCIE_LINKSTS2_EQ8GT_P1_SUC 0x0004 512 #define PCIE_LINKSTS2_EQ8GT_P2_SUC 0x0008 513 #define PCIE_LINKSTS2_EQ8GT_P3_SUC 0x0010 514 #define PCIE_LINKSTS2_LINK_EQ_REQ 0x0020 515 #define PCIE_LINKSTS2_RETIMER_PRES_DET 0x0040 516 #define PCIE_LINKSTS2_2RETIMER_PRES_DET 0x0080 517 #define PCIE_LINKSTS2_XLINK_RES 0x0300 518 #define PCIE_LINKSTS2_DS_COMP_PRES_MASK 0x7000 519 #define PCIE_LINKSTS2_DRS_MSG_RX 0x8000 520 521 /* 522 * PCI-Express Enhanced Capabilities Link Entry Bit Offsets 523 */ 524 #define PCIE_EXT_CAP 0x100 /* Base Address of Ext Cap */ 525 526 #define PCIE_EXT_CAP_ID_SHIFT 0 /* PCI-e Ext Cap ID */ 527 #define PCIE_EXT_CAP_ID_MASK 0xFFFF 528 #define PCIE_EXT_CAP_VER_SHIFT 16 /* PCI-e Ext Cap Ver */ 529 #define PCIE_EXT_CAP_VER_MASK 0xF 530 #define PCIE_EXT_CAP_NEXT_PTR_SHIFT 20 /* PCI-e Ext Cap Next Ptr */ 531 #define PCIE_EXT_CAP_NEXT_PTR_MASK 0xFFF 532 533 #define PCIE_EXT_CAP_NEXT_PTR_NULL 0x0 534 535 /* 536 * PCI-Express Enhanced Capability Identifier Values 537 */ 538 #define PCIE_EXT_CAP_ID_AER 0x1 /* Advanced Error Handling */ 539 #define PCIE_EXT_CAP_ID_VC 0x2 /* Virtual Channel, no MFVC */ 540 #define PCIE_EXT_CAP_ID_SER 0x3 /* Serial Number */ 541 #define PCIE_EXT_CAP_ID_PWR_BUDGET 0x4 /* Power Budgeting */ 542 #define PCIE_EXT_CAP_ID_RC_LINK_DECL 0x5 /* RC Link Declaration */ 543 #define PCIE_EXT_CAP_ID_RC_INT_LINKCTRL 0x6 /* RC Internal Link Control */ 544 #define PCIE_EXT_CAP_ID_RC_EVNT_CEA 0x7 /* RC Event Collector */ 545 /* Endpoint Association */ 546 #define PCIE_EXT_CAP_ID_MFVC 0x8 /* Multi-func Virtual Channel */ 547 #define PCIE_EXT_CAP_ID_VC_WITH_MFVC 0x9 /* Virtual Channel w/ MFVC */ 548 #define PCIE_EXT_CAP_ID_RCRB 0xA /* Root Complex Register Blck */ 549 #define PCIE_EXT_CAP_ID_VS 0xB /* Vendor Spec Extended Cap */ 550 #define PCIE_EXT_CAP_ID_CAC 0xC /* Config Access Correlation */ 551 #define PCIE_EXT_CAP_ID_ACS 0xD /* Access Control Services */ 552 #define PCIE_EXT_CAP_ID_ARI 0xE /* Alternative Routing ID */ 553 #define PCIE_EXT_CAP_ID_ATS 0xF /* Address Translation Svcs */ 554 #define PCIE_EXT_CAP_ID_SRIOV 0x10 /* Single Root I/O Virt. */ 555 #define PCIE_EXT_CAP_ID_MRIOV 0x11 /* Multi Root I/O Virt. */ 556 #define PCIE_EXT_CAP_ID_MULTICAST 0x12 /* Multicast Services */ 557 #define PCIE_EXT_CAP_ID_EA 0x14 /* Enhanced Allocation */ 558 #define PCIE_EXT_CAP_ID_RESIZE_BAR 0x15 /* Resizable BAR */ 559 #define PCIE_EXT_CAP_ID_DPA 0x16 /* Dynamic Power Allocation */ 560 #define PCIE_EXT_CAP_ID_TPH_REQ 0x17 /* TPH Requester */ 561 #define PCIE_EXT_CAP_ID_LTR 0x18 /* Latency Tolerance Report */ 562 #define PCIE_EXT_CAP_ID_PCIE2 0x19 /* PCI Express Capability 2 */ 563 #define PCIE_EXT_CAP_ID_PASID 0x1B /* PASID */ 564 #define PCIE_EXT_CAP_ID_LNR 0x1C /* LNR */ 565 #define PCIE_EXT_CAP_ID_DPC 0x1D /* DPC */ 566 #define PCIE_EXT_CAP_ID_L1PM 0x1E /* L1 PM Substrates */ 567 #define PCIE_EXT_CAP_ID_PTM 0x1F /* Precision Time Management */ 568 #define PCIE_EXT_CAP_ID_FRS 0x21 /* Function Ready Stat. Queue */ 569 #define PCIE_EXT_CAP_ID_RTR 0x22 /* Readiness Time Reporting */ 570 #define PCIE_EXT_CAP_ID_DVS 0x23 /* Designated Vendor-Specific */ 571 #define PCIE_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */ 572 #define PCIE_EXT_CAP_ID_PL16GTE 0x26 /* Physical Layer 16.0 GT/s */ 573 #define PCIE_EXT_CAP_ID_LANE_MARGIN 0x27 /* Lane Margining */ 574 #define PCIE_EXT_CAP_ID_HIEARCHY_ID 0x28 /* Hierarchy ID */ 575 #define PCIE_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Mgmt */ 576 577 /* 578 * PCI-Express Advanced Error Reporting Extended Capability Offsets 579 */ 580 #define PCIE_AER_CAP 0x0 /* Enhanced Capability Header */ 581 #define PCIE_AER_UCE_STS 0x4 /* Uncorrectable Error Status */ 582 #define PCIE_AER_UCE_MASK 0x8 /* Uncorrectable Error Mask */ 583 #define PCIE_AER_UCE_SERV 0xc /* Uncor Error Severity */ 584 #define PCIE_AER_CE_STS 0x10 /* Correctable Error Status */ 585 #define PCIE_AER_CE_MASK 0x14 /* Correctable Error Mask */ 586 #define PCIE_AER_CTL 0x18 /* AER Capability & Control */ 587 #define PCIE_AER_HDR_LOG 0x1c /* Header Log */ 588 589 /* Root Ports Only */ 590 #define PCIE_AER_RE_CMD 0x2c /* Root Error Command */ 591 #define PCIE_AER_RE_STS 0x30 /* Root Error Status */ 592 #define PCIE_AER_CE_SRC_ID 0x34 /* Error Source ID */ 593 #define PCIE_AER_ERR_SRC_ID 0x36 /* Error Source ID */ 594 595 /* Bridges Only */ 596 #define PCIE_AER_SUCE_STS 0x2c /* Secondary UCE Status */ 597 #define PCIE_AER_SUCE_MASK 0x30 /* Secondary UCE Mask */ 598 #define PCIE_AER_SUCE_SERV 0x34 /* Secondary UCE Severity */ 599 #define PCIE_AER_SCTL 0x38 /* Secondary Cap & Ctl */ 600 #define PCIE_AER_SHDR_LOG 0x3c /* Secondary Header Log */ 601 602 /* 603 * AER Uncorrectable Error Status/Mask/Severity Register 604 */ 605 #define PCIE_AER_UCE_TRAINING 0x1 /* Training Error Status */ 606 #define PCIE_AER_UCE_DLP 0x10 /* Data Link Protocol Error */ 607 #define PCIE_AER_UCE_SD 0x20 /* Link Surprise down */ 608 #define PCIE_AER_UCE_PTLP 0x1000 /* Poisoned TLP Status */ 609 #define PCIE_AER_UCE_FCP 0x2000 /* Flow Control Protocol Sts */ 610 #define PCIE_AER_UCE_TO 0x4000 /* Completion Timeout Status */ 611 #define PCIE_AER_UCE_CA 0x8000 /* Completer Abort Status */ 612 #define PCIE_AER_UCE_UC 0x10000 /* Unexpected Completion Sts */ 613 #define PCIE_AER_UCE_RO 0x20000 /* Receiver Overflow Status */ 614 #define PCIE_AER_UCE_MTLP 0x40000 /* Malformed TLP Status */ 615 #define PCIE_AER_UCE_ECRC 0x80000 /* ECRC Error Status */ 616 #define PCIE_AER_UCE_UR 0x100000 /* Unsupported Req */ 617 #define PCIE_AER_UCE_BITS (PCIE_AER_UCE_TRAINING | \ 618 PCIE_AER_UCE_DLP | PCIE_AER_UCE_SD | PCIE_AER_UCE_PTLP | \ 619 PCIE_AER_UCE_FCP | PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | \ 620 PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | PCIE_AER_UCE_MTLP | \ 621 PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR) 622 #define PCIE_AER_UCE_LOG_BITS (PCIE_AER_UCE_PTLP | PCIE_AER_UCE_CA | \ 623 PCIE_AER_UCE_UC | PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR) 624 625 /* 626 * AER Correctable Error Status/Mask Register 627 */ 628 #define PCIE_AER_CE_RECEIVER_ERR 0x1 /* Receiver Error Status */ 629 #define PCIE_AER_CE_BAD_TLP 0x40 /* Bad TLP Status */ 630 #define PCIE_AER_CE_BAD_DLLP 0x80 /* Bad DLLP Status */ 631 #define PCIE_AER_CE_REPLAY_ROLLOVER 0x100 /* REPLAY_NUM Rollover Status */ 632 #define PCIE_AER_CE_REPLAY_TO 0x1000 /* Replay Timer Timeout Sts */ 633 #define PCIE_AER_CE_AD_NFE 0x2000 /* Advisory Non-Fatal Status */ 634 #define PCIE_AER_CE_BITS (PCIE_AER_CE_RECEIVER_ERR | \ 635 PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \ 636 PCIE_AER_CE_REPLAY_TO) 637 638 /* 639 * AER Capability & Control 640 */ 641 #define PCIE_AER_CTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */ 642 #define PCIE_AER_CTL_ECRC_GEN_CAP 0x20 /* ECRC Generation Capable */ 643 #define PCIE_AER_CTL_ECRC_GEN_ENA 0x40 /* ECRC Generation Enable */ 644 #define PCIE_AER_CTL_ECRC_CHECK_CAP 0x80 /* ECRC Check Capable */ 645 #define PCIE_AER_CTL_ECRC_CHECK_ENA 0x100 /* ECRC Check Enable */ 646 647 /* 648 * AER Root Command Register 649 */ 650 #define PCIE_AER_RE_CMD_CE_REP_EN 0x1 /* Correctable Error Enable */ 651 #define PCIE_AER_RE_CMD_NFE_REP_EN 0x2 /* Non-Fatal Error Enable */ 652 #define PCIE_AER_RE_CMD_FE_REP_EN 0x4 /* Fatal Error Enable */ 653 654 /* 655 * AER Root Error Status Register 656 */ 657 #define PCIE_AER_RE_STS_CE_RCVD 0x1 /* ERR_COR Received */ 658 #define PCIE_AER_RE_STS_MUL_CE_RCVD 0x2 /* Multiple ERR_COR Received */ 659 #define PCIE_AER_RE_STS_FE_NFE_RCVD 0x4 /* FATAL/NON-FATAL Received */ 660 #define PCIE_AER_RE_STS_MUL_FE_NFE_RCVD 0x8 /* Multiple ERR_F/NF Received */ 661 #define PCIE_AER_RE_STS_FIRST_UC_FATAL 0x10 /* First Uncorrectable Fatal */ 662 #define PCIE_AER_RE_STS_NFE_MSGS_RCVD 0x20 /* Non-Fatal Error Msgs Rcvd */ 663 #define PCIE_AER_RE_STS_FE_MSGS_RCVD 0x40 /* Fatal Error Messages Rcvd */ 664 665 #define PCIE_AER_RE_STS_MSG_NUM_SHIFT 27 /* Offset of Intr Msg Number */ 666 #define PCIE_AER_RE_STS_MSG_NUM_MASK 0x1F /* Intr Msg Number Mask */ 667 668 /* 669 * AER Error Source Identification Register 670 */ 671 #define PCIE_AER_ERR_SRC_ID_CE_SHIFT 0 /* ERR_COR Source ID */ 672 #define PCIE_AER_ERR_SRC_ID_CE_MASK 0xFFFF 673 #define PCIE_AER_ERR_SRC_ID_UE_SHIFT 16 /* ERR_FATAL/NONFATAL Src ID */ 674 #define PCIE_AER_ERR_SRC_ID_UE_MASK 0xFFFF 675 676 /* 677 * AER Secondary Uncorrectable Error Register 678 */ 679 #define PCIE_AER_SUCE_TA_ON_SC 0x1 /* Target Abort on Split Comp */ 680 #define PCIE_AER_SUCE_MA_ON_SC 0x2 /* Master Abort on Split Comp */ 681 #define PCIE_AER_SUCE_RCVD_TA 0x4 /* Received Target Abort */ 682 #define PCIE_AER_SUCE_RCVD_MA 0x8 /* Received Master Abort */ 683 #define PCIE_AER_SUCE_USC_ERR 0x20 /* Unexpected Split Comp Err */ 684 #define PCIE_AER_SUCE_USC_MSG_DATA_ERR 0x40 /* USC Message Data Error */ 685 #define PCIE_AER_SUCE_UC_DATA_ERR 0x80 /* Uncorrectable Data Error */ 686 #define PCIE_AER_SUCE_UC_ATTR_ERR 0x100 /* UC Attribute Err */ 687 #define PCIE_AER_SUCE_UC_ADDR_ERR 0x200 /* Uncorrectable Address Err */ 688 #define PCIE_AER_SUCE_TIMER_EXPIRED 0x400 /* Delayed xtion discard */ 689 #define PCIE_AER_SUCE_PERR_ASSERT 0x800 /* PERR Assertion Detected */ 690 #define PCIE_AER_SUCE_SERR_ASSERT 0x1000 /* SERR Assertion Detected */ 691 #define PCIE_AER_SUCE_INTERNAL_ERR 0x2000 /* Internal Bridge Err Detect */ 692 693 #define PCIE_AER_SUCE_HDR_CMD_LWR_MASK 0xF /* Lower Command Mask */ 694 #define PCIE_AER_SUCE_HDR_CMD_LWR_SHIFT 4 /* Lower Command Shift */ 695 #define PCIE_AER_SUCE_HDR_CMD_UP_MASK 0xF /* Upper Command Mask */ 696 #define PCIE_AER_SUCE_HDR_CMD_UP_SHIFT 8 /* Upper Command Shift */ 697 #define PCIE_AER_SUCE_HDR_ADDR_SHIFT 32 /* Upper Command Shift */ 698 699 #define PCIE_AER_SUCE_BITS (PCIE_AER_SUCE_TA_ON_SC | \ 700 PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \ 701 PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \ 702 PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \ 703 PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_TIMER_EXPIRED | \ 704 PCIE_AER_SUCE_PERR_ASSERT | PCIE_AER_SUCE_SERR_ASSERT | \ 705 PCIE_AER_SUCE_INTERNAL_ERR) 706 #define PCIE_AER_SUCE_LOG_BITS (PCIE_AER_SUCE_TA_ON_SC | \ 707 PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \ 708 PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \ 709 PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \ 710 PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_PERR_ASSERT) 711 712 /* 713 * AER Secondary Capability & Control 714 */ 715 #define PCIE_AER_SCTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */ 716 717 /* 718 * AER Secondary Headers 719 * The Secondary Header Logs is 4 DW long. 720 * The first 2 DW are split into 3 sections 721 * o Transaction Attribute 722 * o Transaction Command Lower 723 * o Transaction Command Higher 724 * The last 2 DW is the Transaction Address 725 */ 726 #define PCIE_AER_SHDR_LOG_ATTR_MASK 0xFFFFFFFFF 727 #define PCIE_AER_SHDR_LOG_CMD_LOW_MASK 0xF000000000 728 #define PCIE_AER_SHDR_LOG_CMD_HIGH_MASK 0xF0000000000 729 #define PCIE_AER_SHDR_LOG_ADDR_MASK 0xFFFFFFFFFFFFFFFF 730 731 /* 732 * PCI-Express Device Serial Number Capability Offsets. 733 */ 734 #define PCIE_SER_CAP 0x0 /* Enhanced Capability Header */ 735 #define PCIE_SER_SID_LOWER_DW 0x4 /* Lower 32-bit Serial Number */ 736 #define PCIE_SER_SID_UPPER_DW 0x8 /* Upper 32-bit Serial Number */ 737 738 /* 739 * ARI Capability Offsets 740 */ 741 #define PCIE_ARI_HDR 0x0 /* Enhanced Capability Header */ 742 #define PCIE_ARI_CAP 0x4 /* ARI Capability Register */ 743 #define PCIE_ARI_CTL 0x6 /* ARI Control Register */ 744 745 #define PCIE_ARI_CAP_MFVC_FUNC_GRP 0x01 746 #define PCIE_ARI_CAP_ASC_FUNC_GRP 0x02 747 748 #define PCIE_ARI_CAP_NEXT_FUNC_SHIFT 8 749 #define PCIE_ARI_CAP_NEXT_FUNC_MASK 0xffff 750 751 #define PCIE_ARI_CTRL_MFVC_FUNC_GRP 0x01 752 #define PCIE_ARI_CTRL_ASC_FUNC_GRP 0x02 753 754 #define PCIE_ARI_CTRL_FUNC_GRP_SHIFT 4 755 #define PCIE_ARI_CTRL_FUNC_GRP_MASK 0x7 756 757 /* 758 * PCI-E Common TLP Header Fields 759 */ 760 #define PCIE_TLP_FMT_3DW 0x00 761 #define PCIE_TLP_FMT_4DW 0x20 762 #define PCIE_TLP_FMT_3DW_DATA 0x40 763 #define PCIE_TLP_FMT_4DW_DATA 0x60 764 765 #define PCIE_TLP_TYPE_MEM 0x0 766 #define PCIE_TLP_TYPE_MEMLK 0x1 767 #define PCIE_TLP_TYPE_IO 0x2 768 #define PCIE_TLP_TYPE_CFG0 0x4 769 #define PCIE_TLP_TYPE_CFG1 0x5 770 #define PCIE_TLP_TYPE_MSG 0x10 771 #define PCIE_TLP_TYPE_CPL 0xA 772 #define PCIE_TLP_TYPE_CPLLK 0xB 773 #define PCIE_TLP_TYPE_MSI 0x18 774 775 #define PCIE_TLP_MRD3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM) 776 #define PCIE_TLP_MRD4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM) 777 #define PCIE_TLP_MRDLK3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK) 778 #define PCIE_TLP_MRDLK4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK) 779 #define PCIE_TLP_MRDWR3 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM) 780 #define PCIE_TLP_MRDWR4 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM) 781 #define PCIE_TLP_IORD (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO) 782 #define PCIE_TLP_IOWR (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO) 783 #define PCIE_TLP_CFGRD0 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0) 784 #define PCIE_TLP_CFGWR0 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0) 785 #define PCIE_TLP_CFGRD1 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1) 786 #define PCIE_TLP_CFGWR1 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1) 787 #define PCIE_TLP_MSG (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG) 788 #define PCIE_TLP_MSGD (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG) 789 #define PCIE_TLP_CPL (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL) 790 #define PCIE_TLP_CPLD (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL) 791 #define PCIE_TLP_CPLLK (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK) 792 #define PCIE_TLP_CPLDLK (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK) 793 #define PCIE_TLP_MSI32 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI) 794 #define PCIE_TLP_MSI64 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI) 795 796 typedef uint16_t pcie_req_id_t; 797 798 #define PCIE_REQ_ID_BUS_SHIFT 8 799 #define PCIE_REQ_ID_BUS_MASK 0xFF00 800 #define PCIE_REQ_ID_DEV_SHIFT 3 801 #define PCIE_REQ_ID_DEV_MASK 0x00F8 802 #define PCIE_REQ_ID_FUNC_SHIFT 0 803 #define PCIE_REQ_ID_FUNC_MASK 0x0007 804 #define PCIE_REQ_ID_ARI_FUNC_MASK 0x00FF 805 806 #define PCIE_CPL_STS_SUCCESS 0 807 #define PCIE_CPL_STS_UR 1 808 #define PCIE_CPL_STS_CRS 2 809 #define PCIE_CPL_STS_CA 4 810 811 #if defined(_BIT_FIELDS_LTOH) 812 /* 813 * PCI Express little-endian common TLP header format 814 */ 815 typedef struct pcie_tlp_hdr { 816 uint32_t len :10, 817 rsvd3 :2, 818 attr :2, 819 ep :1, 820 td :1, 821 rsvd2 :4, 822 tc :3, 823 rsvd1 :1, 824 type :5, 825 fmt :2, 826 rsvd0 :1; 827 } pcie_tlp_hdr_t; 828 829 typedef struct pcie_mem64 { 830 uint32_t fbe :4, 831 lbe :4, 832 tag :8, 833 rid :16; 834 uint32_t addr1; 835 uint32_t rsvd0 :2, 836 addr0 :30; 837 } pcie_mem64_t; 838 839 typedef struct pcie_memio32 { 840 uint32_t fbe :4, 841 lbe :4, 842 tag :8, 843 rid :16; 844 uint32_t rsvd0 :2, 845 addr0 :30; 846 } pcie_memio32_t; 847 848 typedef struct pcie_cfg { 849 uint32_t fbe :4, 850 lbe :4, 851 tag :8, 852 rid :16; 853 uint32_t rsvd1 :2, 854 reg :6, 855 extreg :4, 856 rsvd0 :4, 857 func :3, 858 dev :5, 859 bus :8; 860 } pcie_cfg_t; 861 862 typedef struct pcie_cpl { 863 uint32_t bc :12, 864 bcm :1, 865 status :3, 866 cid :16; 867 uint32_t laddr :7, 868 rsvd0 :1, 869 tag :8, 870 rid :16; 871 } pcie_cpl_t; 872 873 /* 874 * PCI-Express Message Request Header 875 */ 876 typedef struct pcie_msg { 877 uint32_t msg_code:8, /* DW1 */ 878 tag :8, 879 rid :16; 880 uint32_t unused[2]; /* DW 2 & 3 */ 881 } pcie_msg_t; 882 883 #elif defined(_BIT_FIELDS_HTOL) 884 /* 885 * PCI Express big-endian common TLP header format 886 */ 887 typedef struct pcie_tlp_hdr { 888 uint32_t rsvd0 :1, 889 fmt :2, 890 type :5, 891 rsvd1 :1, 892 tc :3, 893 rsvd2 :4, 894 td :1, 895 ep :1, 896 attr :2, 897 rsvd3 :2, 898 len :10; 899 } pcie_tlp_hdr_t; 900 901 typedef struct pcie_mem64 { 902 uint32_t rid :16, 903 tag :8, 904 lbe :4, 905 fbe :4; 906 uint32_t addr1; 907 uint32_t addr0 :30, 908 rsvd0 :2; 909 } pcie_mem64_t; 910 911 typedef struct pcie_memio32 { 912 uint32_t rid :16, 913 tag :8, 914 lbe :4, 915 fbe :4; 916 uint32_t addr0 :30, 917 rsvd0 :2; 918 } pcie_memio32_t; 919 920 typedef struct pcie_cfg { 921 uint32_t rid :16, 922 tag :8, 923 lbe :4, 924 fbe :4; 925 uint32_t bus :8, 926 dev :5, 927 func :3, 928 rsvd0 :4, 929 extreg :4, 930 reg :6, 931 rsvd1 :2; 932 } pcie_cfg_t; 933 934 typedef struct pcie_cpl { 935 uint32_t cid :16, 936 status :3, 937 bcm :1, 938 bc :12; 939 uint32_t rid :16, 940 tag :8, 941 rsvd0 :1, 942 laddr :7; 943 } pcie_cpl_t; 944 945 /* 946 * PCI-Express Message Request Header 947 */ 948 typedef struct pcie_msg { 949 uint32_t rid :16, /* DW1 */ 950 tag :8, 951 msg_code:8; 952 uint32_t unused[2]; /* DW 2 & 3 */ 953 } pcie_msg_t; 954 #else 955 #error "bit field not defined" 956 #endif 957 958 #define PCIE_MSG_CODE_ERR_COR 0x30 959 #define PCIE_MSG_CODE_ERR_NONFATAL 0x31 960 #define PCIE_MSG_CODE_ERR_FATAL 0x33 961 962 #ifdef __cplusplus 963 } 964 #endif 965 966 #endif /* _SYS_PCIE_H */ 967