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 /* 221786Sjj156685 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 2327Sjchu * Use is subject to license terms. 2427Sjchu */ 2527Sjchu 2627Sjchu #ifndef _SYS_PCIE_H 2727Sjchu #define _SYS_PCIE_H 2827Sjchu 2927Sjchu #pragma ident "%Z%%M% %I% %E% SMI" 3027Sjchu 3127Sjchu #ifdef __cplusplus 3227Sjchu extern "C" { 3327Sjchu #endif 3427Sjchu 3527Sjchu #include <sys/pci.h> 3627Sjchu 3727Sjchu /* 38881Sjohnny * PCI Express capability registers in PCI configuration space relative to 39881Sjohnny * the PCI Express Capability structure. 4027Sjchu */ 4127Sjchu #define PCIE_CAP_ID PCI_CAP_ID 4227Sjchu #define PCIE_CAP_NEXT_PTR PCI_CAP_NEXT_PTR 4327Sjchu #define PCIE_PCIECAP 0x02 /* PCI-e Capability Reg */ 4427Sjchu #define PCIE_DEVCAP 0x04 /* Device Capability */ 4527Sjchu #define PCIE_DEVCTL 0x08 /* Device Control */ 4627Sjchu #define PCIE_DEVSTS 0x0A /* Device Status */ 471850Sjj156685 #define PCIE_LINKCAP 0x0C /* Link Capability */ 481850Sjj156685 #define PCIE_LINKCTL 0x10 /* Link Control */ 491850Sjj156685 #define PCIE_LINKSTS 0x12 /* Link Status */ 5027Sjchu #define PCIE_SLOTCAP 0x14 /* Slot Capability */ 5127Sjchu #define PCIE_SLOTCTL 0x18 /* Slot Control */ 5227Sjchu #define PCIE_SLOTSTS 0x1A /* Slot Status */ 5327Sjchu #define PCIE_ROOTCTL 0x1C /* Root Control */ 5427Sjchu #define PCIE_ROOTSTS 0x20 /* Root Status */ 5527Sjchu 5627Sjchu /* 57881Sjohnny * PCI-Express Config Space size 58881Sjohnny */ 59881Sjohnny #define PCIE_CONF_HDR_SIZE 4096 /* PCIe configuration header size */ 60881Sjohnny 61881Sjohnny /* 62881Sjohnny * PCI-Express Capabilities Register (2 bytes) 6327Sjchu */ 6427Sjchu #define PCIE_PCIECAP_VER_1_0 0x1 /* PCI-E spec 1.0 */ 6527Sjchu #define PCIE_PCIECAP_VER_MASK 0xF /* Version Mask */ 6627Sjchu #define PCIE_PCIECAP_DEV_TYPE_PCIE_DEV 0x00 /* PCI-E Endpont Device */ 6727Sjchu #define PCIE_PCIECAP_DEV_TYPE_PCI_DEV 0x10 /* Leg PCI Endpont Device */ 6827Sjchu #define PCIE_PCIECAP_DEV_TYPE_ROOT 0x40 /* Root Port of Root Complex */ 6927Sjchu #define PCIE_PCIECAP_DEV_TYPE_UP 0x50 /* Upstream Port of Switch */ 7027Sjchu #define PCIE_PCIECAP_DEV_TYPE_DOWN 0x60 /* Downstream Port of Switch */ 7127Sjchu #define PCIE_PCIECAP_DEV_TYPE_PCIE2PCI 0x70 /* PCI-E to PCI Bridge */ 7227Sjchu #define PCIE_PCIECAP_DEV_TYPE_PCI2PCIE 0x80 /* PCI to PCI-E Bridge */ 7327Sjchu #define PCIE_PCIECAP_DEV_TYPE_MASK 0xF0 /* Device/Port Type Mask */ 7427Sjchu #define PCIE_PCIECAP_SLOT_IMPL 0x100 /* Slot Impl vs Integrated */ 7527Sjchu #define PCIE_PCIECAP_INT_MSG_NUM 0x3700 /* 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 */ 15127Sjchu 15227Sjchu #define PCIE_DEVCTL_EXT_TAG_FIELD_EN 0x100 /* Extended Tag Field Enable */ 15327Sjchu #define PCIE_DEVCTL_PHTM_FUNC_EN 0x200 /* Phantom Functions Enable */ 15427Sjchu #define PCIE_DEVCTL_AUX_POWER_PM_EN 0x400 /* Auxiliary Power PM Enable */ 15527Sjchu #define PCIE_DEVCTL_ENABLE_NO_SNOOP 0x800 /* Enable No Snoop */ 15627Sjchu 1573143Sraghuram #define PCIE_DEVCTL_MAX_READ_REQ_128 0x0000 1583143Sraghuram #define PCIE_DEVCTL_MAX_READ_REQ_256 0x1000 1593143Sraghuram #define PCIE_DEVCTL_MAX_READ_REQ_512 0x2000 1603143Sraghuram #define PCIE_DEVCTL_MAX_READ_REQ_1024 0x3000 1613143Sraghuram #define PCIE_DEVCTL_MAX_READ_REQ_2048 0x4000 1623143Sraghuram #define PCIE_DEVCTL_MAX_READ_REQ_4096 0x5000 16327Sjchu #define PCIE_DEVCTL_MAX_READ_REQ_MASK 0x7000 /* Max_Read_Request_Size */ 16427Sjchu 16527Sjchu /* 166881Sjohnny * Device Status Register (2 bytes) 16727Sjchu */ 16827Sjchu #define PCIE_DEVSTS_CE_DETECTED 0x1 /* Correctable Error Detected */ 16927Sjchu #define PCIE_DEVSTS_NFE_DETECTED 0x2 /* Non Fatal Error Detected */ 17027Sjchu #define PCIE_DEVSTS_FE_DETECTED 0x4 /* Fatal Error Detected */ 17127Sjchu #define PCIE_DEVSTS_UR_DETECTED 0x8 /* Unsupported Req Detected */ 17227Sjchu #define PCIE_DEVSTS_AUX_POWER 0x10 /* AUX Power Detected */ 17327Sjchu #define PCIE_DEVSTS_TRANS_PENDING 0x20 /* Transactions Pending */ 17427Sjchu 17527Sjchu /* 176881Sjohnny * Link Capability Register (4 bytes) 17727Sjchu */ 17827Sjchu #define PCIE_LINKCAP_MAX_SPEED_2_5 0x1 /* 2.5 Gb/s Speed */ 17927Sjchu #define PCIE_LINKCAP_MAX_SPEED_MASK 0xF /* Maximum Link Speed */ 18027Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X1 0x010 18127Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X2 0x020 18227Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X4 0x040 18327Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X8 0x080 18427Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X12 0x0C0 18527Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X16 0x100 18627Sjchu #define PCIE_LINKCAP_MAX_WIDTH_X32 0x200 18727Sjchu #define PCIE_LINKCAP_MAX_WIDTH_MASK 0x3f0 /* Maximum Link Width */ 18827Sjchu 18927Sjchu #define PCIE_LINKCAP_ASPM_SUP_L0S 0x400 /* L0s Entry Supported */ 19027Sjchu #define PCIE_LINKCAP_ASPM_SUP_L0S_L1 0xC00 /* L0s abd L1 Supported */ 19127Sjchu #define PCIE_LINKCAP_ASPM_SUP_MASK 0xC00 /* ASPM Support */ 19227Sjchu 19327Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_MIN 0x0000 /* < 64 ns */ 19427Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_64ns 0x1000 /* 64 ns - 128 ns */ 19527Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_128ns 0x2000 /* 128 ns - 256 ns */ 19627Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_256ns 0x3000 /* 256 ns - 512 ns */ 19727Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_512ns 0x4000 /* 512 ns - 1 us */ 19827Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_1us 0x5000 /* 1 us - 2 us */ 19927Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_2us 0x6000 /* 2 us - 4 us */ 20027Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_MAX 0x7000 /* > 4 us */ 20127Sjchu #define PCIE_LINKCAP_L0S_EXIT_LAT_MASK 0x7000 /* L0s Exit Latency */ 20227Sjchu 20327Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_MIN 0x00000 /* < 1 us */ 20427Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_1us 0x08000 /* 1 us - 2 us */ 20527Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_2us 0x10000 /* 2 us - 4 us */ 20627Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_4us 0x18000 /* 4 us - 8 us */ 20727Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_8us 0x20000 /* 8 us - 16 us */ 20827Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_16us 0x28000 /* 16 us - 32 us */ 20927Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_32us 0x30000 /* 32 us - 64 us */ 21027Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_MAX 0x38000 /* > 64 us */ 21127Sjchu #define PCIE_LINKCAP_L1_EXIT_LAT_MASK 0x38000 /* L1 Exit Latency */ 21227Sjchu 213881Sjohnny /* PCIe v1.1 spec based */ 214881Sjohnny #define PCIE_LINKCAP_DLL_ACTIVE_REP_CAPABLE 0x100000 /* DLL Active */ 215881Sjohnny /* Capable bit */ 216881Sjohnny 21727Sjchu #define PCIE_LINKCAP_PORT_NUMBER 0xF0000000 /* Port Number */ 21827Sjchu 21927Sjchu /* 220881Sjohnny * Link Control Register (2 bytes) 22127Sjchu */ 22227Sjchu #define PCIE_LINKCTL_ASPM_CTL_DIS 0x0 /* ASPM Disable */ 22327Sjchu #define PCIE_LINKCTL_ASPM_CTL_L0S 0x1 /* ASPM L0s only */ 22427Sjchu #define PCIE_LINKCTL_ASPM_CTL_L1 0x2 /* ASPM L1 only */ 22527Sjchu #define PCIE_LINKCTL_ASPM_CTL_L0S_L1 0x3 /* ASPM L0s and L1 only */ 22627Sjchu #define PCIE_LINKCTL_ASPM_CTL_MASK 0x3 /* ASPM Control */ 22727Sjchu 22827Sjchu #define PCIE_LINKCTL_RCB_64_BYTE 0x0 /* 64 Byte */ 22927Sjchu #define PCIE_LINKCTL_RCB_128_BYTE 0x8 /* 128 Byte */ 23027Sjchu #define PCIE_LINKCTL_RCB_MASK 0x8 /* Read Completion Boundary */ 23127Sjchu 23227Sjchu #define PCIE_LINKCTL_LINK_DISABLE 0x10 /* Link Disable */ 23327Sjchu #define PCIE_LINKCTL_RETRAIN_LINK 0x20 /* Retrain Link */ 23427Sjchu #define PCIE_LINKCTL_COMMON_CLK_CFG 0x40 /* Common Clock Configuration */ 23527Sjchu #define PCIE_LINKCTL_EXT_SYNCH 0x80 /* Extended Synch */ 23627Sjchu 23727Sjchu /* 238881Sjohnny * Link Status Register (2 bytes) 23927Sjchu */ 24027Sjchu #define PCIE_LINKSTS_SPEED_2_5 0x1 /* Link Speed */ 24127Sjchu #define PCIE_LINKSTS_SPEED_MASK 0xF /* Link Speed */ 24227Sjchu 24327Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X1 0x010 24427Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X2 0x020 24527Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X4 0x040 24627Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X8 0x080 24727Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X12 0x0C0 24827Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X16 0x100 24927Sjchu #define PCIE_LINKSTS_NEG_WIDTH_X32 0x200 25027Sjchu #define PCIE_LINKSTS_NEG_WIDTH_MASK 0x3F0 /* Negotiated Link Width */ 25127Sjchu 25227Sjchu #define PCIE_LINKSTS_TRAINING_ERROR 0x400 /* Training Error */ 25327Sjchu #define PCIE_LINKSTS_LINK_TRAINING 0x800 /* Link Training */ 25427Sjchu #define PCIE_LINKSTS_SLOT_CLK_CFG 0x1000 /* Slot Clock Configuration */ 25527Sjchu 2561786Sjj156685 /* PCIe v1.1 spec based */ 2571786Sjj156685 #define PCIE_LINKSTS_DLL_LINK_ACTIVE 0x2000 /* DLL Link Active */ 2581786Sjj156685 25927Sjchu /* 260881Sjohnny * Slot Capability Register (4 bytes) 26127Sjchu */ 26227Sjchu #define PCIE_SLOTCAP_ATTN_BUTTON 0x1 /* Attention Button Present */ 26327Sjchu #define PCIE_SLOTCAP_POWER_CONTROLLER 0x2 /* Power Controller Present */ 26427Sjchu #define PCIE_SLOTCAP_MRL_SENSOR 0x4 /* MRL Sensor Present */ 26527Sjchu #define PCIE_SLOTCAP_ATTN_INDICATOR 0x8 /* Attn Indicator Present */ 26627Sjchu #define PCIE_SLOTCAP_PWR_INDICATOR 0x10 /* Power Indicator Present */ 26727Sjchu #define PCIE_SLOTCAP_HP_SURPRISE 0x20 /* Hot-Plug Surprise */ 26827Sjchu #define PCIE_SLOTCAP_HP_CAPABLE 0x40 /* Hot-Plug Capable */ 26927Sjchu 27027Sjchu #define PCIE_SLOTCAP_PLMT_VAL_SHIFT 7 /* Slot Pwr Limit Value Shift */ 27127Sjchu #define PCIE_SLOTCAP_PLMT_VAL_MASK 0xFF /* Slot Pwr Limit Value */ 27227Sjchu 27327Sjchu #define PCIE_SLOTCAP_PLMT_SCL_1_BY_1 0x00000 /* 1x Scale */ 27427Sjchu #define PCIE_SLOTCAP_PLMT_SCL_1_BY_10 0x08000 /* 0.1x Scale */ 27527Sjchu #define PCIE_SLOTCAP_PLMT_SCL_1_BY_100 0x10000 /* 0.01x Scale */ 27627Sjchu #define PCIE_SLOTCAP_PLMT_SCL_1_BY_1000 0x18000 /* 0.001x Scale */ 27727Sjchu #define PCIE_SLOTCAP_PLMT_SCL_MASK 0x18000 /* Slot Power Limit Scale */ 278881Sjohnny #define PCIE_SLOTCAP_EMI_LOCK_PRESENT 0x20000 /* EMI Lock Present */ 279881Sjohnny #define PCIE_SLOTCAP_NO_CMD_COMP_SUPP 0x40000 /* No Command Comp. Supported */ 28027Sjchu 28127Sjchu #define PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT 19 /* Physical Slot Num Shift */ 28227Sjchu #define PCIE_SLOTCAP_PHY_SLOT_NUM_MASK 0x1FFF /* Physical Slot Num Mask */ 28327Sjchu 284881Sjohnny #define PCIE_SLOTCAP_PHY_SLOT_NUM(reg) \ 285881Sjohnny (((reg) >> PCIE_SLOTCAP_PHY_SLOT_NUM_SHIFT) & \ 286881Sjohnny PCIE_SLOTCAP_PHY_SLOT_NUM_MASK) 287881Sjohnny 28827Sjchu /* 289881Sjohnny * Slot Control Register (2 bytes) 29027Sjchu */ 29127Sjchu #define PCIE_SLOTCTL_ATTN_BTN_EN 0x1 /* Attn Button Pressed Enable */ 29227Sjchu #define PCIE_SLOTCTL_PWR_FAULT_EN 0x2 /* Pwr Fault Detected Enable */ 29327Sjchu #define PCIE_SLOTCTL_MRL_SENSOR_EN 0x4 /* MRL Sensor Changed Enable */ 29427Sjchu #define PCIE_SLOTCTL_PRESENCE_CHANGE_EN 0x8 /* Presence Detect Changed En */ 29527Sjchu #define PCIE_SLOTCTL_CMD_INTR_EN 0x10 /* CMD Completed Interrupt En */ 29627Sjchu #define PCIE_SLOTCTL_HP_INTR_EN 0x20 /* Hot-Plug Interrupt Enable */ 297881Sjohnny #define PCIE_SLOTCTL_PWR_CONTROL 0x0400 /* Power controller Control */ 298881Sjohnny #define PCIE_SLOTCTL_EMI_LOCK_CONTROL 0x0800 /* EMI Lock control */ 2991786Sjj156685 #define PCIE_SLOTCTL_DLL_STATE_EN 0x1000 /* DLL State Changed En */ 300881Sjohnny #define PCIE_SLOTCTL_ATTN_INDICATOR_MASK 0x00C0 /* Attn Indicator mask */ 301881Sjohnny #define PCIE_SLOTCTL_PWR_INDICATOR_MASK 0x0300 /* Power Indicator mask */ 30227Sjchu 303881Sjohnny /* State values for the Power and Attention Indicators */ 304881Sjohnny #define PCIE_SLOTCTL_INDICATOR_STATE_ON 0x1 /* indicator ON */ 305881Sjohnny #define PCIE_SLOTCTL_INDICATOR_STATE_BLINK 0x2 /* indicator BLINK */ 306881Sjohnny #define PCIE_SLOTCTL_INDICATOR_STATE_OFF 0x3 /* indicator OFF */ 30727Sjchu 30827Sjchu /* 309881Sjohnny * Macros to set/get the state of Power and Attention Indicators 310881Sjohnny * in the PCI Express Slot Control Register. 311881Sjohnny */ 312881Sjohnny #define pcie_slotctl_pwr_indicator_get(reg) \ 313881Sjohnny (((reg) & PCIE_SLOTCTL_PWR_INDICATOR_MASK) >> 8) 314881Sjohnny #define pcie_slotctl_attn_indicator_get(ctrl) \ 315881Sjohnny (((ctrl) & PCIE_SLOTCTL_ATTN_INDICATOR_MASK) >> 6) 316881Sjohnny #define pcie_slotctl_attn_indicator_set(ctrl, v)\ 317881Sjohnny (((ctrl) & ~PCIE_SLOTCTL_ATTN_INDICATOR_MASK) | ((v) << 6)) 318881Sjohnny #define pcie_slotctl_pwr_indicator_set(ctrl, v)\ 319881Sjohnny (((ctrl) & ~PCIE_SLOTCTL_PWR_INDICATOR_MASK) | ((v) << 8)) 320881Sjohnny 321881Sjohnny /* 322881Sjohnny * Slot Status register (2 bytes) 32327Sjchu */ 32427Sjchu #define PCIE_SLOTSTS_ATTN_BTN_PRESSED 0x1 /* Attention Button Pressed */ 32527Sjchu #define PCIE_SLOTSTS_PWR_FAULT_DETECTED 0x2 /* Power Fault Detected */ 32627Sjchu #define PCIE_SLOTSTS_MRL_SENSOR_CHANGED 0x4 /* MRL Sensor Changed */ 32727Sjchu #define PCIE_SLOTSTS_PRESENCE_CHANGED 0x8 /* Presence Detect Changed */ 32827Sjchu #define PCIE_SLOTSTS_COMMAND_COMPLETED 0x10 /* Command Completed */ 329881Sjohnny #define PCIE_SLOTSTS_MRL_SENSOR_OPEN 0x20 /* MRL Sensor Open */ 33027Sjchu #define PCIE_SLOTSTS_PRESENCE_DETECTED 0x40 /* Card Present in slot */ 331881Sjohnny #define PCIE_SLOTSTS_EMI_LOCK_SET 0x0080 /* EMI Lock set */ 332881Sjohnny #define PCIE_SLOTSTS_DLL_STATE_CHANGED 0x0100 /* DLL State Changed */ 33327Sjchu 33427Sjchu /* 335881Sjohnny * Root Control Register (2 bytes) 33627Sjchu */ 33727Sjchu #define PCIE_ROOTCTL_SYS_ERR_ON_CE_EN 0x1 /* Sys Err on Cor Err Enable */ 33827Sjchu #define PCIE_ROOTCTL_SYS_ERR_ON_NFE_EN 0x2 /* Sys Err on NF Err Enable */ 339881Sjohnny #define PCIE_ROOTCTL_SYS_ERR_ON_FE_EN 0x4 /* Sys Err on Fatal Err En */ 340881Sjohnny #define PCIE_ROOTCTL_PME_INTERRUPT_EN 0x8 /* PME Interrupt Enable */ 34127Sjchu 34227Sjchu /* 343881Sjohnny * Root Status Register (4 bytes) 34427Sjchu */ 34527Sjchu #define PCIE_ROOTSTS_PME_REQ_ID_SHIFT 0 /* PME Requestor ID */ 34627Sjchu #define PCIE_ROOTSTS_PME_REQ_ID_MASK 0xFFFF /* PME Requestor ID */ 34727Sjchu 34827Sjchu #define PCIE_ROOTSTS_PME_STATUS 0x10000 /* PME Status */ 34927Sjchu #define PCIE_ROOTSTS_PME_PENDING 0x20000 /* PME Pending */ 35027Sjchu 35127Sjchu 35227Sjchu /* 35327Sjchu * PCI-Express Enhanced Capabilities Link Entry Bit Offsets 35427Sjchu */ 35527Sjchu #define PCIE_EXT_CAP 0x100 /* Base Address of Ext Cap */ 35627Sjchu 35727Sjchu #define PCIE_EXT_CAP_ID_SHIFT 0 /* PCI-e Ext Cap ID */ 35827Sjchu #define PCIE_EXT_CAP_ID_MASK 0xFFFF 35927Sjchu #define PCIE_EXT_CAP_VER_SHIFT 16 /* PCI-e Ext Cap Ver */ 36027Sjchu #define PCIE_EXT_CAP_VER_MASK 0xF 36127Sjchu #define PCIE_EXT_CAP_NEXT_PTR_SHIFT 20 /* PCI-e Ext Cap Next Ptr */ 36227Sjchu #define PCIE_EXT_CAP_NEXT_PTR_MASK 0xFFF 36327Sjchu 36427Sjchu #define PCIE_EXT_CAP_NEXT_PTR_NULL 0x0 36527Sjchu 36627Sjchu /* 36727Sjchu * PCI-Express Enhanced Capability Identifier Values 36827Sjchu */ 36927Sjchu #define PCIE_EXT_CAP_ID_AER 0x1 /* Advanced Error Handling */ 3703070Sanish #define PCIE_EXT_CAP_ID_VC 0x2 /* Virtual Channel, no MFVC */ 37127Sjchu #define PCIE_EXT_CAP_ID_SER 0x3 /* Serial Number */ 37227Sjchu #define PCIE_EXT_CAP_ID_PWR_BUDGET 0x4 /* Power Budgeting */ 3733070Sanish #define PCIE_EXT_CAP_ID_RC_LINK_DECL 0x5 /* RC Link Declaration */ 3743070Sanish #define PCIE_EXT_CAP_ID_RC_INT_LINKCTRL 0x6 /* RC Internal Link Control */ 3753070Sanish #define PCIE_EXT_CAP_ID_RC_EVNT_CEA 0x7 /* RC Event Collector */ 3763070Sanish /* Endpoint Association */ 3773070Sanish #define PCIE_EXT_CAP_ID_MFVC 0x8 /* Multi-func Virtual Channel */ 3783070Sanish #define PCIE_EXT_CAP_ID_VC_WITH_MFVC 0x9 /* Virtual Channel w/ MFVC */ 3793070Sanish #define PCIE_EXT_CAP_ID_RCRB 0xA /* Root Complex Register Blck */ 3803070Sanish #define PCIE_EXT_CAP_ID_VS 0xB /* Vendor Spec Extended Cap */ 3813070Sanish #define PCIE_EXT_CAP_ID_CAC 0xC /* Config Access Correlation */ 3823070Sanish #define PCIE_EXT_CAP_ID_ACS 0xD /* Access Control Services */ 3833070Sanish #define PCIE_EXT_CAP_ID_ARI 0xE /* Alternative Routing ID */ 3843070Sanish #define PCIE_EXT_CAP_ID_ATS 0xF /* Address Translation Svcs */ 38527Sjchu 38627Sjchu /* 38727Sjchu * PCI-Express Advanced Error Reporting Extended Capability Offsets 38827Sjchu */ 38927Sjchu #define PCIE_AER_CAP 0x0 /* Enhanced Capability Header */ 39027Sjchu #define PCIE_AER_UCE_STS 0x4 /* Uncorrectable Error Status */ 39127Sjchu #define PCIE_AER_UCE_MASK 0x8 /* Uncorrectable Error Mask */ 39227Sjchu #define PCIE_AER_UCE_SERV 0xc /* Uncor Error Severity */ 39327Sjchu #define PCIE_AER_CE_STS 0x10 /* Correctable Error Status */ 39427Sjchu #define PCIE_AER_CE_MASK 0x14 /* Correctable Error Mask */ 39527Sjchu #define PCIE_AER_CTL 0x18 /* AER Capability & Control */ 39627Sjchu #define PCIE_AER_HDR_LOG 0x1c /* Header Log */ 39727Sjchu 39827Sjchu /* Root Ports Only */ 39927Sjchu #define PCIE_AER_RE_CMD 0x2c /* Root Error Command */ 40027Sjchu #define PCIE_AER_RE_STS 0x30 /* Root Error Status */ 40127Sjchu #define PCIE_AER_CE_SRC_ID 0x34 /* Error Source ID */ 40227Sjchu #define PCIE_AER_ERR_SRC_ID 0x36 /* Error Source ID */ 40327Sjchu 40427Sjchu /* Bridges Only */ 40527Sjchu #define PCIE_AER_SUCE_STS 0x2c /* Secondary UCE Status */ 40627Sjchu #define PCIE_AER_SUCE_MASK 0x30 /* Secondary UCE Mask */ 40727Sjchu #define PCIE_AER_SUCE_SERV 0x34 /* Secondary UCE Severity */ 40827Sjchu #define PCIE_AER_SCTL 0x38 /* Secondary Cap & Ctl */ 40927Sjchu #define PCIE_AER_SHDR_LOG 0x3c /* Secondary Header Log */ 41027Sjchu 41127Sjchu /* 41227Sjchu * AER Uncorrectable Error Status/Mask/Severity Register 41327Sjchu */ 4141865Sdilpreet #define PCIE_AER_UCE_TRAINING 0x1 /* Training Error Status */ 41527Sjchu #define PCIE_AER_UCE_DLP 0x10 /* Data Link Protocol Error */ 4161865Sdilpreet #define PCIE_AER_UCE_SD 0x20 /* Link Surprise down */ 41727Sjchu #define PCIE_AER_UCE_PTLP 0x1000 /* Poisoned TLP Status */ 41827Sjchu #define PCIE_AER_UCE_FCP 0x2000 /* Flow Control Protocol Sts */ 41927Sjchu #define PCIE_AER_UCE_TO 0x4000 /* Completion Timeout Status */ 42027Sjchu #define PCIE_AER_UCE_CA 0x8000 /* Completer Abort Status */ 42127Sjchu #define PCIE_AER_UCE_UC 0x10000 /* Unexpected Completion Sts */ 42227Sjchu #define PCIE_AER_UCE_RO 0x20000 /* Receiver Overflow Status */ 42327Sjchu #define PCIE_AER_UCE_MTLP 0x40000 /* Malformed TLP Status */ 42427Sjchu #define PCIE_AER_UCE_ECRC 0x80000 /* ECRC Error Status */ 4251865Sdilpreet #define PCIE_AER_UCE_UR 0x100000 /* Unsupported Req */ 42627Sjchu #define PCIE_AER_UCE_BITS (PCIE_AER_UCE_TRAINING | \ 4271865Sdilpreet PCIE_AER_UCE_DLP | PCIE_AER_UCE_SD | PCIE_AER_UCE_PTLP | \ 4281865Sdilpreet PCIE_AER_UCE_FCP | PCIE_AER_UCE_TO | PCIE_AER_UCE_CA | \ 4291865Sdilpreet PCIE_AER_UCE_UC | PCIE_AER_UCE_RO | PCIE_AER_UCE_MTLP | \ 4301865Sdilpreet PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR) 4311865Sdilpreet #define PCIE_AER_UCE_LOG_BITS (PCIE_AER_UCE_PTLP | PCIE_AER_UCE_CA | \ 4321865Sdilpreet PCIE_AER_UCE_UC | PCIE_AER_UCE_MTLP | PCIE_AER_UCE_ECRC | PCIE_AER_UCE_UR) 43327Sjchu 43427Sjchu /* 43527Sjchu * AER Correctable Error Status/Mask Register 43627Sjchu */ 43727Sjchu #define PCIE_AER_CE_RECEIVER_ERR 0x1 /* Receiver Error Status */ 43827Sjchu #define PCIE_AER_CE_BAD_TLP 0x40 /* Bad TLP Status */ 43927Sjchu #define PCIE_AER_CE_BAD_DLLP 0x80 /* Bad DLLP Status */ 44027Sjchu #define PCIE_AER_CE_REPLAY_ROLLOVER 0x100 /* REPLAY_NUM Rollover Status */ 44127Sjchu #define PCIE_AER_CE_REPLAY_TO 0x1000 /* Replay Timer Timeout Sts */ 4421865Sdilpreet #define PCIE_AER_CE_AD_NFE 0x2000 /* Advisory Non-Fatal Status */ 44327Sjchu #define PCIE_AER_CE_BITS (PCIE_AER_CE_RECEIVER_ERR | \ 44427Sjchu PCIE_AER_CE_BAD_TLP | PCIE_AER_CE_BAD_DLLP | PCIE_AER_CE_REPLAY_ROLLOVER | \ 44527Sjchu PCIE_AER_CE_REPLAY_TO) 44627Sjchu 44727Sjchu /* 44827Sjchu * AER Capability & Control 44927Sjchu */ 45027Sjchu #define PCIE_AER_CTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */ 45127Sjchu #define PCIE_AER_CTL_ECRC_GEN_CAP 0x20 /* ECRC Generation Capable */ 45227Sjchu #define PCIE_AER_CTL_ECRC_GEN_ENA 0x40 /* ECRC Generation Enable */ 45327Sjchu #define PCIE_AER_CTL_ECRC_CHECK_CAP 0x80 /* ECRC Check Capable */ 45427Sjchu #define PCIE_AER_CTL_ECRC_CHECK_ENA 0x100 /* ECRC Check Enable */ 45527Sjchu 45627Sjchu /* 45727Sjchu * AER Root Command Register 45827Sjchu */ 45927Sjchu #define PCIE_AER_RE_CMD_CE_REP_EN 0x1 /* Correctable Error Enable */ 46027Sjchu #define PCIE_AER_RE_CMD_NFE_REP_EN 0x2 /* Non-Fatal Error Enable */ 46127Sjchu #define PCIE_AER_RE_CMD_FE_REP_EN 0x4 /* Fatal Error Enable */ 46227Sjchu 46327Sjchu /* 46427Sjchu * AER Root Error Status Register 46527Sjchu */ 46627Sjchu #define PCIE_AER_RE_STS_CE_RCVD 0x1 /* ERR_COR Received */ 46727Sjchu #define PCIE_AER_RE_STS_MUL_CE_RCVD 0x2 /* Multiple ERR_COR Received */ 46827Sjchu #define PCIE_AER_RE_STS_FE_NFE_RCVD 0x4 /* FATAL/NON-FATAL Received */ 46927Sjchu #define PCIE_AER_RE_STS_MUL_FE_NFE_RCVD 0x8 /* Multiple ERR_F/NF Received */ 47027Sjchu #define PCIE_AER_RE_STS_FIRST_UC_FATAL 0x10 /* First Uncorrectable Fatal */ 47127Sjchu #define PCIE_AER_RE_STS_NFE_MSGS_RCVD 0x20 /* Non-Fatal Error Msgs Rcvd */ 47227Sjchu #define PCIE_AER_RE_STS_FE_MSGS_RCVD 0x40 /* Fatal Error Messages Rcvd */ 47327Sjchu 47427Sjchu #define PCIE_AER_RE_STS_MSG_NUM_SHIFT 27 /* Offset of Intr Msg Number */ 47527Sjchu #define PCIE_AER_RE_STS_MSG_NUM_MASK 0x1F /* Intr Msg Number Mask */ 47627Sjchu 47727Sjchu /* 47827Sjchu * AER Error Source Identification Register 47927Sjchu */ 48027Sjchu #define PCIE_AER_ERR_SRC_ID_CE_SHIFT 0 /* ERR_COR Source ID */ 48127Sjchu #define PCIE_AER_ERR_SRC_ID_CE_MASK 0xFFFF 48227Sjchu #define PCIE_AER_ERR_SRC_ID_UE_SHIFT 16 /* ERR_FATAL/NONFATAL Src ID */ 48327Sjchu #define PCIE_AER_ERR_SRC_ID_UE_MASK 0xFFF 48427Sjchu 48527Sjchu /* 48627Sjchu * AER Secondary Uncorrectable Error Register 48727Sjchu */ 48827Sjchu #define PCIE_AER_SUCE_TA_ON_SC 0x1 /* Target Abort on Split Comp */ 48927Sjchu #define PCIE_AER_SUCE_MA_ON_SC 0x2 /* Master Abort on Split Comp */ 49027Sjchu #define PCIE_AER_SUCE_RCVD_TA 0x4 /* Received Target Abort */ 49127Sjchu #define PCIE_AER_SUCE_RCVD_MA 0x8 /* Received Master Abort */ 49227Sjchu #define PCIE_AER_SUCE_USC_ERR 0x20 /* Unexpected Split Comp Err */ 49327Sjchu #define PCIE_AER_SUCE_USC_MSG_DATA_ERR 0x40 /* USC Message Data Error */ 49427Sjchu #define PCIE_AER_SUCE_UC_DATA_ERR 0x80 /* Uncorrectable Data Error */ 49527Sjchu #define PCIE_AER_SUCE_UC_ATTR_ERR 0x100 /* UC Attribute Err */ 49627Sjchu #define PCIE_AER_SUCE_UC_ADDR_ERR 0x200 /* Uncorrectable Address Err */ 49727Sjchu #define PCIE_AER_SUCE_TIMER_EXPIRED 0x400 /* Delayed xtion discard */ 49827Sjchu #define PCIE_AER_SUCE_PERR_ASSERT 0x800 /* PERR Assertion Detected */ 49927Sjchu #define PCIE_AER_SUCE_SERR_ASSERT 0x1000 /* SERR Assertion Detected */ 50027Sjchu #define PCIE_AER_SUCE_INTERNAL_ERR 0x2000 /* Internal Bridge Err Detect */ 5011865Sdilpreet 5021865Sdilpreet #define PCIE_AER_SUCE_HDR_CMD_LWR_MASK 0xF /* Lower Command Mask */ 5031865Sdilpreet #define PCIE_AER_SUCE_HDR_CMD_LWR_SHIFT 4 /* Lower Command Shift */ 5041865Sdilpreet #define PCIE_AER_SUCE_HDR_CMD_UP_MASK 0xF /* Upper Command Mask */ 5051865Sdilpreet #define PCIE_AER_SUCE_HDR_CMD_UP_SHIFT 8 /* Upper Command Shift */ 5061865Sdilpreet #define PCIE_AER_SUCE_HDR_ADDR_SHIFT 32 /* Upper Command Shift */ 5071865Sdilpreet 50827Sjchu #define PCIE_AER_SUCE_BITS (PCIE_AER_SUCE_TA_ON_SC | \ 50927Sjchu PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \ 51027Sjchu PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \ 51127Sjchu PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \ 51227Sjchu PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_TIMER_EXPIRED | \ 51327Sjchu PCIE_AER_SUCE_PERR_ASSERT | PCIE_AER_SUCE_SERR_ASSERT | \ 51427Sjchu PCIE_AER_SUCE_INTERNAL_ERR) 5151865Sdilpreet #define PCIE_AER_SUCE_LOG_BITS (PCIE_AER_SUCE_TA_ON_SC | \ 5161865Sdilpreet PCIE_AER_SUCE_MA_ON_SC | PCIE_AER_SUCE_RCVD_TA | PCIE_AER_SUCE_RCVD_MA | \ 5171865Sdilpreet PCIE_AER_SUCE_USC_ERR | PCIE_AER_SUCE_USC_MSG_DATA_ERR | \ 5181865Sdilpreet PCIE_AER_SUCE_UC_DATA_ERR | PCIE_AER_SUCE_UC_ATTR_ERR | \ 5191865Sdilpreet PCIE_AER_SUCE_UC_ADDR_ERR | PCIE_AER_SUCE_PERR_ASSERT) 52027Sjchu 52127Sjchu /* 52227Sjchu * AER Secondary Capability & Control 52327Sjchu */ 52427Sjchu #define PCIE_AER_SCTL_FST_ERR_PTR_MASK 0x1F /* First Error Pointer */ 52527Sjchu 52627Sjchu /* 52727Sjchu * AER Secondary Headers 52827Sjchu * The Secondary Header Logs is 4 DW long. 52927Sjchu * The first 2 DW are split into 3 sections 53027Sjchu * o Transaction Attribute 53127Sjchu * o Transaction Command Lower 53227Sjchu * o Transaction Command Higher 53327Sjchu * The last 2 DW is the Transaction Address 53427Sjchu */ 53527Sjchu #define PCIE_AER_SHDR_LOG_ATTR_MASK 0xFFFFFFFFF 53627Sjchu #define PCIE_AER_SHDR_LOG_CMD_LOW_MASK 0xF000000000 53727Sjchu #define PCIE_AER_SHDR_LOG_CMD_HIGH_MASK 0xF0000000000 53827Sjchu #define PCIE_AER_SHDR_LOG_ADDR_MASK 0xFFFFFFFFFFFFFFFF 53927Sjchu 54027Sjchu /* 5413162Sgovinda * PCI-Express Device Serial Number Capability Offsets. 5423162Sgovinda */ 5433162Sgovinda #define PCIE_SER_CAP 0x0 /* Enhanced Capability Header */ 5443162Sgovinda #define PCIE_SER_SID_LOWER_DW 0x4 /* Lower 32-bit Serial Number */ 5453162Sgovinda #define PCIE_SER_SID_UPPER_DW 0x8 /* Upper 32-bit Serial Number */ 5463162Sgovinda 5473162Sgovinda /* 54827Sjchu * PCI-E Common TLP Header Fields 54927Sjchu */ 5501865Sdilpreet #define PCIE_TLP_FMT_3DW 0x00 55127Sjchu #define PCIE_TLP_FMT_4DW 0x20 55227Sjchu #define PCIE_TLP_FMT_3DW_DATA 0x40 55327Sjchu #define PCIE_TLP_FMT_4DW_DATA 0x60 55427Sjchu 55527Sjchu #define PCIE_TLP_TYPE_MEM 0x0 55627Sjchu #define PCIE_TLP_TYPE_MEMLK 0x1 5571865Sdilpreet #define PCIE_TLP_TYPE_IO 0x2 55827Sjchu #define PCIE_TLP_TYPE_CFG0 0x4 55927Sjchu #define PCIE_TLP_TYPE_CFG1 0x5 5601865Sdilpreet #define PCIE_TLP_TYPE_MSG 0x10 56127Sjchu #define PCIE_TLP_TYPE_CPL 0xA 56227Sjchu #define PCIE_TLP_TYPE_CPLLK 0xB 56327Sjchu #define PCIE_TLP_TYPE_MSI 0x18 56427Sjchu 56527Sjchu #define PCIE_TLP_MRD3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEM) 56627Sjchu #define PCIE_TLP_MRD4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEM) 56727Sjchu #define PCIE_TLP_MRDLK3 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_MEMLK) 56827Sjchu #define PCIE_TLP_MRDLK4 (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MEMLK) 56927Sjchu #define PCIE_TLP_MRDWR3 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MEM) 57027Sjchu #define PCIE_TLP_MRDWR4 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MEM) 5711865Sdilpreet #define PCIE_TLP_IORD (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_IO) 5721865Sdilpreet #define PCIE_TLP_IOWR (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_IO) 57327Sjchu #define PCIE_TLP_CFGRD0 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG0) 57427Sjchu #define PCIE_TLP_CFGWR0 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG0) 57527Sjchu #define PCIE_TLP_CFGRD1 (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CFG1) 57627Sjchu #define PCIE_TLP_CFGWR1 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CFG1) 5771865Sdilpreet #define PCIE_TLP_MSG (PCIE_TLP_FMT_4DW | PCIE_TLP_TYPE_MSG) 5781865Sdilpreet #define PCIE_TLP_MSGD (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSG) 57927Sjchu #define PCIE_TLP_CPL (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPL) 58027Sjchu #define PCIE_TLP_CPLD (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPL) 58127Sjchu #define PCIE_TLP_CPLLK (PCIE_TLP_FMT_3DW | PCIE_TLP_TYPE_CPLLK) 58227Sjchu #define PCIE_TLP_CPLDLK (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_CPLLK) 58327Sjchu #define PCIE_TLP_MSI32 (PCIE_TLP_FMT_3DW_DATA | PCIE_TLP_TYPE_MSI) 58427Sjchu #define PCIE_TLP_MSI64 (PCIE_TLP_FMT_4DW_DATA | PCIE_TLP_TYPE_MSI) 58527Sjchu 58627Sjchu typedef uint16_t pcie_req_id_t; 58727Sjchu 58827Sjchu #define PCIE_REQ_ID_BUS_SHIFT 8 58927Sjchu #define PCIE_REQ_ID_BUS_MASK 0xFF00 59027Sjchu #define PCIE_REQ_ID_DEV_SHIFT 3 59127Sjchu #define PCIE_REQ_ID_DEV_MASK 0x00F1 59227Sjchu #define PCIE_REQ_ID_FUNC_SHIFT 0 59327Sjchu #define PCIE_REQ_ID_FUNC_MASK 0x0007 59427Sjchu 595*3274Set142600 #define PCIE_CPL_STS_SUCCESS 0 596*3274Set142600 #define PCIE_CPL_STS_UR 1 597*3274Set142600 #define PCIE_CPL_STS_CRS 2 598*3274Set142600 #define PCIE_CPL_STS_CA 4 599*3274Set142600 6001865Sdilpreet #if defined(_BIT_FIELDS_LTOH) 6011865Sdilpreet /* 6021865Sdilpreet * PCI Express little-endian common TLP header format 6031865Sdilpreet */ 6041865Sdilpreet typedef struct pcie_tlp_hdr { 6051865Sdilpreet uint32_t len :10, 6061865Sdilpreet rsvd3 :2, 6071865Sdilpreet attr :2, 6081865Sdilpreet ep :1, 6091865Sdilpreet td :1, 6101865Sdilpreet rsvd2 :4, 6111865Sdilpreet tc :3, 6121865Sdilpreet rsvd1 :1, 6131865Sdilpreet type :5, 6141865Sdilpreet fmt :2, 6151865Sdilpreet rsvd0 :1; 6161865Sdilpreet } pcie_tlp_hdr_t; 6171865Sdilpreet 6181865Sdilpreet typedef struct pcie_mem64 { 6191865Sdilpreet uint32_t fbe :4, 6201865Sdilpreet lbe :4, 6211865Sdilpreet tag :8, 6221865Sdilpreet rid :16; 6231865Sdilpreet uint32_t addr1; 6241865Sdilpreet uint32_t rsvd0 :2, 6251865Sdilpreet addr0 :30; 6261865Sdilpreet } pcie_mem64_t; 6271865Sdilpreet 6281865Sdilpreet typedef struct pcie_memio32 { 6291865Sdilpreet uint32_t fbe :4, 6301865Sdilpreet lbe :4, 6311865Sdilpreet tag :8, 6321865Sdilpreet rid :16; 6331865Sdilpreet uint32_t rsvd0 :2, 6341865Sdilpreet addr0 :30; 6351865Sdilpreet } pcie_memio32_t; 6361865Sdilpreet 6371865Sdilpreet typedef struct pcie_cfg { 6381865Sdilpreet uint32_t fbe :4, 6391865Sdilpreet lbe :4, 6401865Sdilpreet tag :8, 6411865Sdilpreet rid :16; 6421865Sdilpreet uint32_t rsvd1 :2, 6431865Sdilpreet reg :6, 6441865Sdilpreet extreg :4, 6451865Sdilpreet rsvd0 :4, 6461865Sdilpreet func :3, 6471865Sdilpreet dev :5, 6481865Sdilpreet bus :8; 6491865Sdilpreet } pcie_cfg_t; 6501865Sdilpreet 6511865Sdilpreet typedef struct pcie_cpl { 6521865Sdilpreet uint32_t bc :12, 6531865Sdilpreet bcm :1, 6541865Sdilpreet status :3, 6551865Sdilpreet cid :16; 6561865Sdilpreet uint32_t laddr :7, 6571865Sdilpreet rsvd0 :1, 6581865Sdilpreet tag :8, 6591865Sdilpreet rid :16; 6601865Sdilpreet } pcie_cpl_t; 6611865Sdilpreet 66227Sjchu /* 66327Sjchu * PCI-Express Message Request Header 66427Sjchu */ 66527Sjchu typedef struct pcie_msg { 6661865Sdilpreet uint32_t msg_code:8, /* DW1 */ 6671865Sdilpreet tag :8, 6681865Sdilpreet rid :16; 6691865Sdilpreet uint32_t unused[2]; /* DW 2 & 3 */ 6701865Sdilpreet } pcie_msg_t; 6711865Sdilpreet 6721865Sdilpreet #elif defined(_BIT_FIELDS_HTOL) 6731865Sdilpreet /* 6741865Sdilpreet * PCI Express big-endian common TLP header format 6751865Sdilpreet */ 6761865Sdilpreet typedef struct pcie_tlp_hdr { 6771865Sdilpreet uint32_t rsvd0 :1, 6781865Sdilpreet fmt :2, 6791865Sdilpreet type :5, 6801865Sdilpreet rsvd1 :1, 6811865Sdilpreet tc :3, 6821865Sdilpreet rsvd2 :4, 68327Sjchu td :1, 68427Sjchu ep :1, 68527Sjchu attr :2, 6861865Sdilpreet rsvd3 :2, 68727Sjchu len :10; 6881865Sdilpreet } pcie_tlp_hdr_t; 6891865Sdilpreet 6901865Sdilpreet typedef struct pcie_mem64 { 6911865Sdilpreet uint32_t rid :16, 6921865Sdilpreet tag :8, 6931865Sdilpreet lbe :4, 6941865Sdilpreet fbe :4; 6951865Sdilpreet uint32_t addr1; 6961865Sdilpreet uint32_t addr0 :30, 6971865Sdilpreet rsvd0 :2; 6981865Sdilpreet } pcie_mem64_t; 6991865Sdilpreet 7001865Sdilpreet typedef struct pcie_memio32 { 7011865Sdilpreet uint32_t rid :16, 7021865Sdilpreet tag :8, 7031865Sdilpreet lbe :4, 7041865Sdilpreet fbe :4; 7051865Sdilpreet uint32_t addr0 :30, 7061865Sdilpreet rsvd0 :2; 7071865Sdilpreet } pcie_memio32_t; 7081865Sdilpreet 7091865Sdilpreet typedef struct pcie_cfg { 7101865Sdilpreet uint32_t rid :16, 7111865Sdilpreet tag :8, 7121865Sdilpreet lbe :4, 7131865Sdilpreet fbe :4; 7141865Sdilpreet uint32_t bus :8, 7151865Sdilpreet dev :5, 7161865Sdilpreet func :3, 7171865Sdilpreet rsvd0 :4, 7181865Sdilpreet extreg :4, 7191865Sdilpreet reg :6, 7201865Sdilpreet rsvd1 :2; 7211865Sdilpreet } pcie_cfg_t; 7221865Sdilpreet 7231865Sdilpreet typedef struct pcie_cpl { 7241865Sdilpreet uint32_t cid :16, 7251865Sdilpreet status :3, 7261865Sdilpreet bcm :1, 7271865Sdilpreet bc :12; 7281865Sdilpreet uint32_t rid :16, 7291865Sdilpreet tag :8, 7301865Sdilpreet rsvd0 :1, 7311865Sdilpreet laddr :7; 7321865Sdilpreet } pcie_cpl_t; 7331865Sdilpreet 7341865Sdilpreet /* 7351865Sdilpreet * PCI-Express Message Request Header 7361865Sdilpreet */ 7371865Sdilpreet typedef struct pcie_msg { 73827Sjchu uint32_t rid :16, /* DW1 */ 73927Sjchu tag :8, 74027Sjchu msg_code:8; 74127Sjchu uint32_t unused[2]; /* DW 2 & 3 */ 74227Sjchu } pcie_msg_t; 7431865Sdilpreet #else 7441865Sdilpreet #error "bit field not defined" 7451865Sdilpreet #endif 74627Sjchu 74727Sjchu #define PCIE_MSG_CODE_ERR_COR 0x30 74827Sjchu #define PCIE_MSG_CODE_ERR_NONFATAL 0x31 74927Sjchu #define PCIE_MSG_CODE_ERR_FATAL 0x33 75027Sjchu 75127Sjchu #ifdef __cplusplus 75227Sjchu } 75327Sjchu #endif 75427Sjchu 75527Sjchu #endif /* _SYS_PCIE_H */ 756