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