1/****************************************************************************** 2** 3** FILE NAME : ifxmips_pcie_reg.h 4** PROJECT : IFX UEIP for VRX200 5** MODULES : PCIe module 6** 7** DATE : 02 Mar 2009 8** AUTHOR : Lei Chuanhua 9** DESCRIPTION : PCIe Root Complex Driver 10** COPYRIGHT : Copyright (c) 2009 11** Infineon Technologies AG 12** Am Campeon 1-12, 85579 Neubiberg, Germany 13** 14** This program is free software; you can redistribute it and/or modify 15** it under the terms of the GNU General Public License as published by 16** the Free Software Foundation; either version 2 of the License, or 17** (at your option) any later version. 18** HISTORY 19** $Version $Date $Author $Comment 20** 0.0.1 17 Mar,2009 Lei Chuanhua Initial version 21*******************************************************************************/ 22#ifndef IFXMIPS_PCIE_REG_H 23#define IFXMIPS_PCIE_REG_H 24#include <linux/version.h> 25#include <linux/types.h> 26#include <linux/pci.h> 27#include <linux/interrupt.h> 28/*! 29 \file ifxmips_pcie_reg.h 30 \ingroup IFX_PCIE 31 \brief header file for PCIe module register definition 32*/ 33/* PCIe Address Mapping Base */ 34#define PCIE_CFG_PHY_BASE 0x1D000000UL 35#define PCIE_CFG_BASE (KSEG1 + PCIE_CFG_PHY_BASE) 36#define PCIE_CFG_SIZE (8 * 1024 * 1024) 37 38#define PCIE_MEM_PHY_BASE 0x1C000000UL 39#define PCIE_MEM_BASE (KSEG1 + PCIE_MEM_PHY_BASE) 40#define PCIE_MEM_SIZE (16 * 1024 * 1024) 41#define PCIE_MEM_PHY_END (PCIE_MEM_PHY_BASE + PCIE_MEM_SIZE - 1) 42 43#define PCIE_IO_PHY_BASE 0x1D800000UL 44#define PCIE_IO_BASE (KSEG1 + PCIE_IO_PHY_BASE) 45#define PCIE_IO_SIZE (1 * 1024 * 1024) 46#define PCIE_IO_PHY_END (PCIE_IO_PHY_BASE + PCIE_IO_SIZE - 1) 47 48#define PCIE_RC_CFG_BASE (KSEG1 + 0x1D900000) 49#define PCIE_APP_LOGIC_REG (KSEG1 + 0x1E100900) 50#define PCIE_MSI_PHY_BASE 0x1F600000UL 51 52#define PCIE_PDI_PHY_BASE 0x1F106800UL 53#define PCIE_PDI_BASE (KSEG1 + PCIE_PDI_PHY_BASE) 54#define PCIE_PDI_SIZE 0x400 55 56#define PCIE1_CFG_PHY_BASE 0x19000000UL 57#define PCIE1_CFG_BASE (KSEG1 + PCIE1_CFG_PHY_BASE) 58#define PCIE1_CFG_SIZE (8 * 1024 * 1024) 59 60#define PCIE1_MEM_PHY_BASE 0x18000000UL 61#define PCIE1_MEM_BASE (KSEG1 + PCIE1_MEM_PHY_BASE) 62#define PCIE1_MEM_SIZE (16 * 1024 * 1024) 63#define PCIE1_MEM_PHY_END (PCIE1_MEM_PHY_BASE + PCIE1_MEM_SIZE - 1) 64 65#define PCIE1_IO_PHY_BASE 0x19800000UL 66#define PCIE1_IO_BASE (KSEG1 + PCIE1_IO_PHY_BASE) 67#define PCIE1_IO_SIZE (1 * 1024 * 1024) 68#define PCIE1_IO_PHY_END (PCIE1_IO_PHY_BASE + PCIE1_IO_SIZE - 1) 69 70#define PCIE1_RC_CFG_BASE (KSEG1 + 0x19900000) 71#define PCIE1_APP_LOGIC_REG (KSEG1 + 0x1E100700) 72#define PCIE1_MSI_PHY_BASE 0x1F400000UL 73 74#define PCIE1_PDI_PHY_BASE 0x1F700400UL 75#define PCIE1_PDI_BASE (KSEG1 + PCIE1_PDI_PHY_BASE) 76#define PCIE1_PDI_SIZE 0x400 77 78#define PCIE_CFG_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_CFG_BASE) : (PCIE_CFG_BASE)) 79#define PCIE_MEM_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_BASE) : (PCIE_MEM_BASE)) 80#define PCIE_IO_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_BASE) : (PCIE_IO_BASE)) 81#define PCIE_MEM_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_MEM_PHY_BASE) : (PCIE_MEM_PHY_BASE)) 82#define PCIE_MEM_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_MEM_PHY_END) : (PCIE_MEM_PHY_END)) 83#define PCIE_IO_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_IO_PHY_BASE) : (PCIE_IO_PHY_BASE)) 84#define PCIE_IO_PHY_PORT_TO_END(X) ((X) > 0 ? (PCIE1_IO_PHY_END) : (PCIE_IO_PHY_END)) 85#define PCIE_APP_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_APP_LOGIC_REG) : (PCIE_APP_LOGIC_REG)) 86#define PCIE_RC_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_RC_CFG_BASE) : (PCIE_RC_CFG_BASE)) 87#define PCIE_PHY_PORT_TO_BASE(X) ((X) > 0 ? (PCIE1_PDI_BASE) : (PCIE_PDI_BASE)) 88 89/* PCIe Application Logic Register */ 90/* RC Core Control Register */ 91#define PCIE_RC_CCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x10) 92/* This should be enabled after initializing configuratin registers 93 * Also should check link status retraining bit 94 */ 95#define PCIE_RC_CCR_LTSSM_ENABLE 0x00000001 /* Enable LTSSM to continue link establishment */ 96 97/* RC Core Debug Register */ 98#define PCIE_RC_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x14) 99#define PCIE_RC_DR_DLL_UP 0x00000001 /* Data Link Layer Up */ 100#define PCIE_RC_DR_CURRENT_POWER_STATE 0x0000000E /* Current Power State */ 101#define PCIE_RC_DR_CURRENT_POWER_STATE_S 1 102#define PCIE_RC_DR_CURRENT_LTSSM_STATE 0x000001F0 /* Current LTSSM State */ 103#define PCIE_RC_DR_CURRENT_LTSSM_STATE_S 4 104 105#define PCIE_RC_DR_PM_DEV_STATE 0x00000E00 /* Power Management D-State */ 106#define PCIE_RC_DR_PM_DEV_STATE_S 9 107 108#define PCIE_RC_DR_PM_ENABLED 0x00001000 /* Power Management State from PMU */ 109#define PCIE_RC_DR_PME_EVENT_ENABLED 0x00002000 /* Power Management Event Enable State */ 110#define PCIE_RC_DR_AUX_POWER_ENABLED 0x00004000 /* Auxiliary Power Enable */ 111 112/* Current Power State Definition */ 113enum { 114 PCIE_RC_DR_D0 = 0, 115 PCIE_RC_DR_D1, /* Not supported */ 116 PCIE_RC_DR_D2, /* Not supported */ 117 PCIE_RC_DR_D3, 118 PCIE_RC_DR_UN, 119}; 120 121/* PHY Link Status Register */ 122#define PCIE_PHY_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x18) 123#define PCIE_PHY_SR_PHY_LINK_UP 0x00000001 /* PHY Link Up/Down Indicator */ 124 125/* Electromechanical Control Register */ 126#define PCIE_EM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x1C) 127#define PCIE_EM_CR_CARD_IS_PRESENT 0x00000001 /* Card Presence Detect State */ 128#define PCIE_EM_CR_MRL_OPEN 0x00000002 /* MRL Sensor State */ 129#define PCIE_EM_CR_POWER_FAULT_SET 0x00000004 /* Power Fault Detected */ 130#define PCIE_EM_CR_MRL_SENSOR_SET 0x00000008 /* MRL Sensor Changed */ 131#define PCIE_EM_CR_PRESENT_DETECT_SET 0x00000010 /* Card Presense Detect Changed */ 132#define PCIE_EM_CR_CMD_CPL_INT_SET 0x00000020 /* Command Complete Interrupt */ 133#define PCIE_EM_CR_SYS_INTERLOCK_SET 0x00000040 /* System Electromechanical IterLock Engaged */ 134#define PCIE_EM_CR_ATTENTION_BUTTON_SET 0x00000080 /* Attention Button Pressed */ 135 136/* Interrupt Status Register */ 137#define PCIE_IR_SR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x20) 138#define PCIE_IR_SR_PME_CAUSE_MSI 0x00000002 /* MSI caused by PME */ 139#define PCIE_IR_SR_HP_PME_WAKE_GEN 0x00000004 /* Hotplug PME Wake Generation */ 140#define PCIE_IR_SR_HP_MSI 0x00000008 /* Hotplug MSI */ 141#define PCIE_IR_SR_AHB_LU_ERR 0x00000030 /* AHB Bridge Lookup Error Signals */ 142#define PCIE_IR_SR_AHB_LU_ERR_S 4 143#define PCIE_IR_SR_INT_MSG_NUM 0x00003E00 /* Interrupt Message Number */ 144#define PCIE_IR_SR_INT_MSG_NUM_S 9 145#define PCIE_IR_SR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */ 146#define PCIE_IR_SR_AER_INT_MSG_NUM_S 27 147 148/* Message Control Register */ 149#define PCIE_MSG_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x30) 150#define PCIE_MSG_CR_GEN_PME_TURN_OFF_MSG 0x00000001 /* Generate PME Turn Off Message */ 151#define PCIE_MSG_CR_GEN_UNLOCK_MSG 0x00000002 /* Generate Unlock Message */ 152 153#define PCIE_VDM_DR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x34) 154 155/* Vendor-Defined Message Requester ID Register */ 156#define PCIE_VDM_RID(X) (PCIE_APP_PORT_TO_BASE (X) + 0x38) 157#define PCIE_VDM_RID_VENROR_MSG_REQ_ID 0x0000FFFF 158#define PCIE_VDM_RID_VDMRID_S 0 159 160/* ASPM Control Register */ 161#define PCIE_ASPM_CR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x40) 162#define PCIE_ASPM_CR_HOT_RST 0x00000001 /* Hot Reset Request to the downstream device */ 163#define PCIE_ASPM_CR_REQ_EXIT_L1 0x00000002 /* Request to Exit L1 */ 164#define PCIE_ASPM_CR_REQ_ENTER_L1 0x00000004 /* Request to Enter L1 */ 165 166/* Vendor Message DW0 Register */ 167#define PCIE_VM_MSG_DW0(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x50) 168#define PCIE_VM_MSG_DW0_TYPE 0x0000001F /* Message type */ 169#define PCIE_VM_MSG_DW0_TYPE_S 0 170#define PCIE_VM_MSG_DW0_FORMAT 0x00000060 /* Format */ 171#define PCIE_VM_MSG_DW0_FORMAT_S 5 172#define PCIE_VM_MSG_DW0_TC 0x00007000 /* Traffic Class */ 173#define PCIE_VM_MSG_DW0_TC_S 12 174#define PCIE_VM_MSG_DW0_ATTR 0x000C0000 /* Atrributes */ 175#define PCIE_VM_MSG_DW0_ATTR_S 18 176#define PCIE_VM_MSG_DW0_EP_TLP 0x00100000 /* Poisoned TLP */ 177#define PCIE_VM_MSG_DW0_TD 0x00200000 /* TLP Digest */ 178#define PCIE_VM_MSG_DW0_LEN 0xFFC00000 /* Length */ 179#define PCIE_VM_MSG_DW0_LEN_S 22 180 181/* Format Definition */ 182enum { 183 PCIE_VM_MSG_FORMAT_00 = 0, /* 3DW Hdr, no data*/ 184 PCIE_VM_MSG_FORMAT_01, /* 4DW Hdr, no data */ 185 PCIE_VM_MSG_FORMAT_10, /* 3DW Hdr, with data */ 186 PCIE_VM_MSG_FORMAT_11, /* 4DW Hdr, with data */ 187}; 188 189/* Traffic Class Definition */ 190enum { 191 PCIE_VM_MSG_TC0 = 0, 192 PCIE_VM_MSG_TC1, 193 PCIE_VM_MSG_TC2, 194 PCIE_VM_MSG_TC3, 195 PCIE_VM_MSG_TC4, 196 PCIE_VM_MSG_TC5, 197 PCIE_VM_MSG_TC6, 198 PCIE_VM_MSG_TC7, 199}; 200 201/* Attributes Definition */ 202enum { 203 PCIE_VM_MSG_ATTR_00 = 0, /* RO and No Snoop cleared */ 204 PCIE_VM_MSG_ATTR_01, /* RO cleared , No Snoop set */ 205 PCIE_VM_MSG_ATTR_10, /* RO set, No Snoop cleared*/ 206 PCIE_VM_MSG_ATTR_11, /* RO and No Snoop set */ 207}; 208 209/* Payload Size Definition */ 210#define PCIE_VM_MSG_LEN_MIN 0 211#define PCIE_VM_MSG_LEN_MAX 1024 212 213/* Vendor Message DW1 Register */ 214#define PCIE_VM_MSG_DW1(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x54) 215#define PCIE_VM_MSG_DW1_FUNC_NUM 0x00000070 /* Function Number */ 216#define PCIE_VM_MSG_DW1_FUNC_NUM_S 8 217#define PCIE_VM_MSG_DW1_CODE 0x00FF0000 /* Message Code */ 218#define PCIE_VM_MSG_DW1_CODE_S 16 219#define PCIE_VM_MSG_DW1_TAG 0xFF000000 /* Tag */ 220#define PCIE_VM_MSG_DW1_TAG_S 24 221 222#define PCIE_VM_MSG_DW2(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x58) 223#define PCIE_VM_MSG_DW3(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x5C) 224 225/* Vendor Message Request Register */ 226#define PCIE_VM_MSG_REQR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x60) 227#define PCIE_VM_MSG_REQR_REQ 0x00000001 /* Vendor Message Request */ 228 229 230/* AHB Slave Side Band Control Register */ 231#define PCIE_AHB_SSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x70) 232#define PCIE_AHB_SSB_REQ_BCM 0x00000001 /* Slave Reques BCM filed */ 233#define PCIE_AHB_SSB_REQ_EP 0x00000002 /* Slave Reques EP filed */ 234#define PCIE_AHB_SSB_REQ_TD 0x00000004 /* Slave Reques TD filed */ 235#define PCIE_AHB_SSB_REQ_ATTR 0x00000018 /* Slave Reques Attribute number */ 236#define PCIE_AHB_SSB_REQ_ATTR_S 3 237#define PCIE_AHB_SSB_REQ_TC 0x000000E0 /* Slave Request TC Field */ 238#define PCIE_AHB_SSB_REQ_TC_S 5 239 240/* AHB Master SideBand Ctrl Register */ 241#define PCIE_AHB_MSB(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x74) 242#define PCIE_AHB_MSB_RESP_ATTR 0x00000003 /* Master Response Attribute number */ 243#define PCIE_AHB_MSB_RESP_ATTR_S 0 244#define PCIE_AHB_MSB_RESP_BAD_EOT 0x00000004 /* Master Response Badeot filed */ 245#define PCIE_AHB_MSB_RESP_BCM 0x00000008 /* Master Response BCM filed */ 246#define PCIE_AHB_MSB_RESP_EP 0x00000010 /* Master Response EP filed */ 247#define PCIE_AHB_MSB_RESP_TD 0x00000020 /* Master Response TD filed */ 248#define PCIE_AHB_MSB_RESP_FUN_NUM 0x000003C0 /* Master Response Function number */ 249#define PCIE_AHB_MSB_RESP_FUN_NUM_S 6 250 251/* AHB Control Register, fixed bus enumeration exception */ 252#define PCIE_AHB_CTRL(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0x78) 253#define PCIE_AHB_CTRL_BUS_ERROR_SUPPRESS 0x00000001 254 255/* Interrupt Enalbe Register */ 256#define PCIE_IRNEN(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF4) 257#define PCIE_IRNCR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xF8) 258#define PCIE_IRNICR(X) (volatile u32*)(PCIE_APP_PORT_TO_BASE(X) + 0xFC) 259 260/* PCIe interrupt enable/control/capture register definition */ 261#define PCIE_IRN_AER_REPORT 0x00000001 /* AER Interrupt */ 262#define PCIE_IRN_AER_MSIX 0x00000002 /* Advanced Error MSI-X Interrupt */ 263#define PCIE_IRN_PME 0x00000004 /* PME Interrupt */ 264#define PCIE_IRN_HOTPLUG 0x00000008 /* Hotplug Interrupt */ 265#define PCIE_IRN_RX_VDM_MSG 0x00000010 /* Vendor-Defined Message Interrupt */ 266#define PCIE_IRN_RX_CORRECTABLE_ERR_MSG 0x00000020 /* Correctable Error Message Interrupt */ 267#define PCIE_IRN_RX_NON_FATAL_ERR_MSG 0x00000040 /* Non-fatal Error Message */ 268#define PCIE_IRN_RX_FATAL_ERR_MSG 0x00000080 /* Fatal Error Message */ 269#define PCIE_IRN_RX_PME_MSG 0x00000100 /* PME Message Interrupt */ 270#define PCIE_IRN_RX_PME_TURNOFF_ACK 0x00000200 /* PME Turnoff Ack Message Interrupt */ 271#define PCIE_IRN_AHB_BR_FATAL_ERR 0x00000400 /* AHB Fatal Error Interrupt */ 272#define PCIE_IRN_LINK_AUTO_BW_STATUS 0x00000800 /* Link Auto Bandwidth Status Interrupt */ 273#define PCIE_IRN_BW_MGT 0x00001000 /* Bandwidth Managment Interrupt */ 274#define PCIE_IRN_INTA 0x00002000 /* INTA */ 275#define PCIE_IRN_INTB 0x00004000 /* INTB */ 276#define PCIE_IRN_INTC 0x00008000 /* INTC */ 277#define PCIE_IRN_INTD 0x00010000 /* INTD */ 278#define PCIE_IRN_WAKEUP 0x00020000 /* Wake up Interrupt */ 279 280#define PCIE_RC_CORE_COMBINED_INT (PCIE_IRN_AER_REPORT | PCIE_IRN_AER_MSIX | PCIE_IRN_PME | \ 281 PCIE_IRN_HOTPLUG | PCIE_IRN_RX_VDM_MSG | PCIE_IRN_RX_CORRECTABLE_ERR_MSG |\ 282 PCIE_IRN_RX_NON_FATAL_ERR_MSG | PCIE_IRN_RX_FATAL_ERR_MSG | \ 283 PCIE_IRN_RX_PME_MSG | PCIE_IRN_RX_PME_TURNOFF_ACK | PCIE_IRN_AHB_BR_FATAL_ERR | \ 284 PCIE_IRN_LINK_AUTO_BW_STATUS | PCIE_IRN_BW_MGT) 285/* PCIe RC Configuration Register */ 286#define PCIE_VDID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x00) 287 288/* Bit definition from pci_reg.h */ 289#define PCIE_PCICMDSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x04) 290#define PCIE_CCRID(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x08) 291#define PCIE_CLSLTHTBR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x0C) /* EP only */ 292/* BAR0, BAR1,Only necessary if the bridges implements a device-specific register set or memory buffer */ 293#define PCIE_BAR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10) /* Not used*/ 294#define PCIE_BAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14) /* Not used */ 295 296#define PCIE_BNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x18) /* Mandatory */ 297/* Bus Number Register bits */ 298#define PCIE_BNR_PRIMARY_BUS_NUM 0x000000FF 299#define PCIE_BNR_PRIMARY_BUS_NUM_S 0 300#define PCIE_PNR_SECONDARY_BUS_NUM 0x0000FF00 301#define PCIE_PNR_SECONDARY_BUS_NUM_S 8 302#define PCIE_PNR_SUB_BUS_NUM 0x00FF0000 303#define PCIE_PNR_SUB_BUS_NUM_S 16 304 305/* IO Base/Limit Register bits */ 306#define PCIE_IOBLSECS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x1C) /* RC only */ 307#define PCIE_IOBLSECS_32BIT_IO_ADDR 0x00000001 308#define PCIE_IOBLSECS_IO_BASE_ADDR 0x000000F0 309#define PCIE_IOBLSECS_IO_BASE_ADDR_S 4 310#define PCIE_IOBLSECS_32BIT_IOLIMT 0x00000100 311#define PCIE_IOBLSECS_IO_LIMIT_ADDR 0x0000F000 312#define PCIE_IOBLSECS_IO_LIMIT_ADDR_S 12 313 314/* Non-prefetchable Memory Base/Limit Register bit */ 315#define PCIE_MBML(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x20) /* RC only */ 316#define PCIE_MBML_MEM_BASE_ADDR 0x0000FFF0 317#define PCIE_MBML_MEM_BASE_ADDR_S 4 318#define PCIE_MBML_MEM_LIMIT_ADDR 0xFFF00000 319#define PCIE_MBML_MEM_LIMIT_ADDR_S 20 320 321/* Prefetchable Memory Base/Limit Register bit */ 322#define PCIE_PMBL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x24) /* RC only */ 323#define PCIE_PMBL_64BIT_ADDR 0x00000001 324#define PCIE_PMBL_UPPER_12BIT 0x0000FFF0 325#define PCIE_PMBL_UPPER_12BIT_S 4 326#define PCIE_PMBL_E64MA 0x00010000 327#define PCIE_PMBL_END_ADDR 0xFFF00000 328#define PCIE_PMBL_END_ADDR_S 20 329#define PCIE_PMBU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x28) /* RC only */ 330#define PCIE_PMLU32(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x2C) /* RC only */ 331 332/* I/O Base/Limit Upper 16 bits register */ 333#define PCIE_IO_BANDL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x30) /* RC only */ 334#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE 0x0000FFFF 335#define PCIE_IO_BANDL_UPPER_16BIT_IO_BASE_S 0 336#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT 0xFFFF0000 337#define PCIE_IO_BANDL_UPPER_16BIT_IO_LIMIT_S 16 338 339#define PCIE_CPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x34) 340#define PCIE_EBBAR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x38) 341 342/* Interrupt and Secondary Bridge Control Register */ 343#define PCIE_INTRBCTRL(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x3C) 344 345#define PCIE_INTRBCTRL_INT_LINE 0x000000FF 346#define PCIE_INTRBCTRL_INT_LINE_S 0 347#define PCIE_INTRBCTRL_INT_PIN 0x0000FF00 348#define PCIE_INTRBCTRL_INT_PIN_S 8 349#define PCIE_INTRBCTRL_PARITY_ERR_RESP_ENABLE 0x00010000 /* #PERR */ 350#define PCIE_INTRBCTRL_SERR_ENABLE 0x00020000 /* #SERR */ 351#define PCIE_INTRBCTRL_ISA_ENABLE 0x00040000 /* ISA enable, IO 64KB only */ 352#define PCIE_INTRBCTRL_VGA_ENABLE 0x00080000 /* VGA enable */ 353#define PCIE_INTRBCTRL_VGA_16BIT_DECODE 0x00100000 /* VGA 16bit decode */ 354#define PCIE_INTRBCTRL_RST_SECONDARY_BUS 0x00400000 /* Secondary bus rest, hot rest, 1ms */ 355/* Others are read only */ 356enum { 357 PCIE_INTRBCTRL_INT_NON = 0, 358 PCIE_INTRBCTRL_INTA, 359 PCIE_INTRBCTRL_INTB, 360 PCIE_INTRBCTRL_INTC, 361 PCIE_INTRBCTRL_INTD, 362}; 363 364#define PCIE_PM_CAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x40) 365 366/* Power Management Control and Status Register */ 367#define PCIE_PM_CSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x44) 368 369#define PCIE_PM_CSR_POWER_STATE 0x00000003 /* Power State */ 370#define PCIE_PM_CSR_POWER_STATE_S 0 371#define PCIE_PM_CSR_SW_RST 0x00000008 /* Soft Reset Enabled */ 372#define PCIE_PM_CSR_PME_ENABLE 0x00000100 /* PME Enable */ 373#define PCIE_PM_CSR_PME_STATUS 0x00008000 /* PME status */ 374 375/* MSI Capability Register for EP */ 376#define PCIE_MCAPR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x50) 377 378#define PCIE_MCAPR_MSI_CAP_ID 0x000000FF /* MSI Capability ID */ 379#define PCIE_MCAPR_MSI_CAP_ID_S 0 380#define PCIE_MCAPR_MSI_NEXT_CAP_PTR 0x0000FF00 /* Next Capability Pointer */ 381#define PCIE_MCAPR_MSI_NEXT_CAP_PTR_S 8 382#define PCIE_MCAPR_MSI_ENABLE 0x00010000 /* MSI Enable */ 383#define PCIE_MCAPR_MULTI_MSG_CAP 0x000E0000 /* Multiple Message Capable */ 384#define PCIE_MCAPR_MULTI_MSG_CAP_S 17 385#define PCIE_MCAPR_MULTI_MSG_ENABLE 0x00700000 /* Multiple Message Enable */ 386#define PCIE_MCAPR_MULTI_MSG_ENABLE_S 20 387#define PCIE_MCAPR_ADDR64_CAP 0X00800000 /* 64-bit Address Capable */ 388 389/* MSI Message Address Register */ 390#define PCIE_MA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x54) 391 392#define PCIE_MA_ADDR_MASK 0xFFFFFFFC /* Message Address */ 393 394/* MSI Message Upper Address Register */ 395#define PCIE_MUA(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x58) 396 397/* MSI Message Data Register */ 398#define PCIE_MD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x5C) 399 400#define PCIE_MD_DATA 0x0000FFFF /* Message Data */ 401#define PCIE_MD_DATA_S 0 402 403/* PCI Express Capability Register */ 404#define PCIE_XCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70) 405 406#define PCIE_XCAP_ID 0x000000FF /* PCI Express Capability ID */ 407#define PCIE_XCAP_ID_S 0 408#define PCIE_XCAP_NEXT_CAP 0x0000FF00 /* Next Capability Pointer */ 409#define PCIE_XCAP_NEXT_CAP_S 8 410#define PCIE_XCAP_VER 0x000F0000 /* PCI Express Capability Version */ 411#define PCIE_XCAP_VER_S 16 412#define PCIE_XCAP_DEV_PORT_TYPE 0x00F00000 /* Device Port Type */ 413#define PCIE_XCAP_DEV_PORT_TYPE_S 20 414#define PCIE_XCAP_SLOT_IMPLEMENTED 0x01000000 /* Slot Implemented */ 415#define PCIE_XCAP_MSG_INT_NUM 0x3E000000 /* Interrupt Message Number */ 416#define PCIE_XCAP_MSG_INT_NUM_S 25 417 418/* Device Capability Register */ 419#define PCIE_DCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74) 420 421#define PCIE_DCAP_MAX_PAYLOAD_SIZE 0x00000007 /* Max Payload size */ 422#define PCIE_DCAP_MAX_PAYLOAD_SIZE_S 0 423#define PCIE_DCAP_PHANTOM_FUNC 0x00000018 /* Phanton Function, not supported */ 424#define PCIE_DCAP_PHANTOM_FUNC_S 3 425#define PCIE_DCAP_EXT_TAG 0x00000020 /* Extended Tag Field */ 426#define PCIE_DCAP_EP_L0S_LATENCY 0x000001C0 /* EP L0s latency only */ 427#define PCIE_DCAP_EP_L0S_LATENCY_S 6 428#define PCIE_DCAP_EP_L1_LATENCY 0x00000E00 /* EP L1 latency only */ 429#define PCIE_DCAP_EP_L1_LATENCY_S 9 430#define PCIE_DCAP_ROLE_BASE_ERR_REPORT 0x00008000 /* Role Based ERR */ 431 432/* Maximum payload size supported */ 433enum { 434 PCIE_MAX_PAYLOAD_128 = 0, 435 PCIE_MAX_PAYLOAD_256, 436 PCIE_MAX_PAYLOAD_512, 437 PCIE_MAX_PAYLOAD_1024, 438 PCIE_MAX_PAYLOAD_2048, 439 PCIE_MAX_PAYLOAD_4096, 440}; 441 442/* Device Control and Status Register */ 443#define PCIE_DCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x78) 444 445#define PCIE_DCTLSTS_CORRECTABLE_ERR_EN 0x00000001 /* COR-ERR */ 446#define PCIE_DCTLSTS_NONFATAL_ERR_EN 0x00000002 /* Non-fatal ERR */ 447#define PCIE_DCTLSTS_FATAL_ERR_EN 0x00000004 /* Fatal ERR */ 448#define PCIE_DCTLSYS_UR_REQ_EN 0x00000008 /* UR ERR */ 449#define PCIE_DCTLSTS_RELAXED_ORDERING_EN 0x00000010 /* Enable relaxing ordering */ 450#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE 0x000000E0 /* Max payload mask */ 451#define PCIE_DCTLSTS_MAX_PAYLOAD_SIZE_S 5 452#define PCIE_DCTLSTS_EXT_TAG_EN 0x00000100 /* Extended tag field */ 453#define PCIE_DCTLSTS_PHANTOM_FUNC_EN 0x00000200 /* Phantom Function Enable */ 454#define PCIE_DCTLSTS_AUX_PM_EN 0x00000400 /* AUX Power PM Enable */ 455#define PCIE_DCTLSTS_NO_SNOOP_EN 0x00000800 /* Enable no snoop, except root port*/ 456#define PCIE_DCTLSTS_MAX_READ_SIZE 0x00007000 /* Max Read Request size*/ 457#define PCIE_DCTLSTS_MAX_READ_SIZE_S 12 458#define PCIE_DCTLSTS_CORRECTABLE_ERR 0x00010000 /* COR-ERR Detected */ 459#define PCIE_DCTLSTS_NONFATAL_ERR 0x00020000 /* Non-Fatal ERR Detected */ 460#define PCIE_DCTLSTS_FATAL_ER 0x00040000 /* Fatal ERR Detected */ 461#define PCIE_DCTLSTS_UNSUPPORTED_REQ 0x00080000 /* UR Detected */ 462#define PCIE_DCTLSTS_AUX_POWER 0x00100000 /* Aux Power Detected */ 463#define PCIE_DCTLSTS_TRANSACT_PENDING 0x00200000 /* Transaction pending */ 464 465#define PCIE_DCTLSTS_ERR_EN (PCIE_DCTLSTS_CORRECTABLE_ERR_EN | \ 466 PCIE_DCTLSTS_NONFATAL_ERR_EN | PCIE_DCTLSTS_FATAL_ERR_EN | \ 467 PCIE_DCTLSYS_UR_REQ_EN) 468 469/* Link Capability Register */ 470#define PCIE_LCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7C) 471#define PCIE_LCAP_MAX_LINK_SPEED 0x0000000F /* Max link speed, 0x1 by default */ 472#define PCIE_LCAP_MAX_LINK_SPEED_S 0 473#define PCIE_LCAP_MAX_LENGTH_WIDTH 0x000003F0 /* Maxium Length Width */ 474#define PCIE_LCAP_MAX_LENGTH_WIDTH_S 4 475#define PCIE_LCAP_ASPM_LEVEL 0x00000C00 /* Active State Link PM Support */ 476#define PCIE_LCAP_ASPM_LEVEL_S 10 477#define PCIE_LCAP_L0S_EIXT_LATENCY 0x00007000 /* L0s Exit Latency */ 478#define PCIE_LCAP_L0S_EIXT_LATENCY_S 12 479#define PCIE_LCAP_L1_EXIT_LATENCY 0x00038000 /* L1 Exit Latency */ 480#define PCIE_LCAP_L1_EXIT_LATENCY_S 15 481#define PCIE_LCAP_CLK_PM 0x00040000 /* Clock Power Management */ 482#define PCIE_LCAP_SDER 0x00080000 /* Surprise Down Error Reporting */ 483#define PCIE_LCAP_DLL_ACTIVE_REPROT 0x00100000 /* Data Link Layer Active Reporting Capable */ 484#define PCIE_LCAP_PORT_NUM 0xFF0000000 /* Port number */ 485#define PCIE_LCAP_PORT_NUM_S 24 486 487/* Maximum Length width definition */ 488#define PCIE_MAX_LENGTH_WIDTH_RES 0x00 489#define PCIE_MAX_LENGTH_WIDTH_X1 0x01 /* Default */ 490#define PCIE_MAX_LENGTH_WIDTH_X2 0x02 491#define PCIE_MAX_LENGTH_WIDTH_X4 0x04 492#define PCIE_MAX_LENGTH_WIDTH_X8 0x08 493#define PCIE_MAX_LENGTH_WIDTH_X12 0x0C 494#define PCIE_MAX_LENGTH_WIDTH_X16 0x10 495#define PCIE_MAX_LENGTH_WIDTH_X32 0x20 496 497/* Active State Link PM definition */ 498enum { 499 PCIE_ASPM_RES0 = 0, 500 PCIE_ASPM_L0S_ENTRY_SUPPORT, /* L0s */ 501 PCIE_ASPM_RES1, 502 PCIE_ASPM_L0S_L1_ENTRY_SUPPORT, /* L0s and L1, default */ 503}; 504 505/* L0s Exit Latency definition */ 506enum { 507 PCIE_L0S_EIXT_LATENCY_L64NS = 0, /* < 64 ns */ 508 PCIE_L0S_EIXT_LATENCY_B64A128, /* > 64 ns < 128 ns */ 509 PCIE_L0S_EIXT_LATENCY_B128A256, /* > 128 ns < 256 ns */ 510 PCIE_L0S_EIXT_LATENCY_B256A512, /* > 256 ns < 512 ns */ 511 PCIE_L0S_EIXT_LATENCY_B512TO1U, /* > 512 ns < 1 us */ 512 PCIE_L0S_EIXT_LATENCY_B1A2U, /* > 1 us < 2 us */ 513 PCIE_L0S_EIXT_LATENCY_B2A4U, /* > 2 us < 4 us */ 514 PCIE_L0S_EIXT_LATENCY_M4US, /* > 4 us */ 515}; 516 517/* L1 Exit Latency definition */ 518enum { 519 PCIE_L1_EXIT_LATENCY_L1US = 0, /* < 1 us */ 520 PCIE_L1_EXIT_LATENCY_B1A2, /* > 1 us < 2 us */ 521 PCIE_L1_EXIT_LATENCY_B2A4, /* > 2 us < 4 us */ 522 PCIE_L1_EXIT_LATENCY_B4A8, /* > 4 us < 8 us */ 523 PCIE_L1_EXIT_LATENCY_B8A16, /* > 8 us < 16 us */ 524 PCIE_L1_EXIT_LATENCY_B16A32, /* > 16 us < 32 us */ 525 PCIE_L1_EXIT_LATENCY_B32A64, /* > 32 us < 64 us */ 526 PCIE_L1_EXIT_LATENCY_M64US, /* > 64 us */ 527}; 528 529/* Link Control and Status Register */ 530#define PCIE_LCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x80) 531#define PCIE_LCTLSTS_ASPM_ENABLE 0x00000003 /* Active State Link PM Control */ 532#define PCIE_LCTLSTS_ASPM_ENABLE_S 0 533#define PCIE_LCTLSTS_RCB128 0x00000008 /* Read Completion Boundary 128*/ 534#define PCIE_LCTLSTS_LINK_DISABLE 0x00000010 /* Link Disable */ 535#define PCIE_LCTLSTS_RETRIAN_LINK 0x00000020 /* Retrain Link */ 536#define PCIE_LCTLSTS_COM_CLK_CFG 0x00000040 /* Common Clock Configuration */ 537#define PCIE_LCTLSTS_EXT_SYNC 0x00000080 /* Extended Synch */ 538#define PCIE_LCTLSTS_CLK_PM_EN 0x00000100 /* Enable Clock Powerm Management */ 539#define PCIE_LCTLSTS_LINK_SPEED 0x000F0000 /* Link Speed */ 540#define PCIE_LCTLSTS_LINK_SPEED_S 16 541#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH 0x03F00000 /* Negotiated Link Width */ 542#define PCIE_LCTLSTS_NEGOTIATED_LINK_WIDTH_S 20 543#define PCIE_LCTLSTS_RETRAIN_PENDING 0x08000000 /* Link training is ongoing */ 544#define PCIE_LCTLSTS_SLOT_CLK_CFG 0x10000000 /* Slot Clock Configuration */ 545#define PCIE_LCTLSTS_DLL_ACTIVE 0x20000000 /* Data Link Layer Active */ 546 547/* Slot Capabilities Register */ 548#define PCIE_SLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x84) 549 550/* Slot Capabilities */ 551#define PCIE_SLCTLSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x88) 552 553/* Root Control and Capability Register */ 554#define PCIE_RCTLCAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x8C) 555#define PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR 0x00000001 /* #SERR on COR-ERR */ 556#define PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR 0x00000002 /* #SERR on Non-Fatal ERR */ 557#define PCIE_RCTLCAP_SERR_ON_FATAL_ERR 0x00000004 /* #SERR on Fatal ERR */ 558#define PCIE_RCTLCAP_PME_INT_EN 0x00000008 /* PME Interrupt Enable */ 559#define PCIE_RCTLCAP_SERR_ENABLE (PCIE_RCTLCAP_SERR_ON_CORRECTABLE_ERR | \ 560 PCIE_RCTLCAP_SERR_ON_NONFATAL_ERR | PCIE_RCTLCAP_SERR_ON_FATAL_ERR) 561/* Root Status Register */ 562#define PCIE_RSTS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x90) 563#define PCIE_RSTS_PME_REQ_ID 0x0000FFFF /* PME Request ID */ 564#define PCIE_RSTS_PME_REQ_ID_S 0 565#define PCIE_RSTS_PME_STATUS 0x00010000 /* PME Status */ 566#define PCIE_RSTS_PME_PENDING 0x00020000 /* PME Pending */ 567 568/* PCI Express Enhanced Capability Header */ 569#define PCIE_ENHANCED_CAP(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x100) 570#define PCIE_ENHANCED_CAP_ID 0x0000FFFF /* PCI Express Extended Capability ID */ 571#define PCIE_ENHANCED_CAP_ID_S 0 572#define PCIE_ENHANCED_CAP_VER 0x000F0000 /* Capability Version */ 573#define PCIE_ENHANCED_CAP_VER_S 16 574#define PCIE_ENHANCED_CAP_NEXT_OFFSET 0xFFF00000 /* Next Capability Offset */ 575#define PCIE_ENHANCED_CAP_NEXT_OFFSET_S 20 576 577/* Uncorrectable Error Status Register */ 578#define PCIE_UES_R(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x104) 579#define PCIE_DATA_LINK_PROTOCOL_ERR 0x00000010 /* Data Link Protocol Error Status */ 580#define PCIE_SURPRISE_DOWN_ERROR 0x00000020 /* Surprise Down Error Status */ 581#define PCIE_POISONED_TLP 0x00001000 /* Poisoned TLP Status */ 582#define PCIE_FC_PROTOCOL_ERR 0x00002000 /* Flow Control Protocol Error Status */ 583#define PCIE_COMPLETION_TIMEOUT 0x00004000 /* Completion Timeout Status */ 584#define PCIE_COMPLETOR_ABORT 0x00008000 /* Completer Abort Error */ 585#define PCIE_UNEXPECTED_COMPLETION 0x00010000 /* Unexpected Completion Status */ 586#define PCIE_RECEIVER_OVERFLOW 0x00020000 /* Receive Overflow Status */ 587#define PCIE_MALFORNED_TLP 0x00040000 /* Malformed TLP Stauts */ 588#define PCIE_ECRC_ERR 0x00080000 /* ECRC Error Stauts */ 589#define PCIE_UR_REQ 0x00100000 /* Unsupported Request Error Status */ 590#define PCIE_ALL_UNCORRECTABLE_ERR (PCIE_DATA_LINK_PROTOCOL_ERR | PCIE_SURPRISE_DOWN_ERROR | \ 591 PCIE_POISONED_TLP | PCIE_FC_PROTOCOL_ERR | PCIE_COMPLETION_TIMEOUT | \ 592 PCIE_COMPLETOR_ABORT | PCIE_UNEXPECTED_COMPLETION | PCIE_RECEIVER_OVERFLOW |\ 593 PCIE_MALFORNED_TLP | PCIE_ECRC_ERR | PCIE_UR_REQ) 594 595/* Uncorrectable Error Mask Register, Mask means no report */ 596#define PCIE_UEMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x108) 597 598/* Uncorrectable Error Severity Register */ 599#define PCIE_UESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x10C) 600 601/* Correctable Error Status Register */ 602#define PCIE_CESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x110) 603#define PCIE_RX_ERR 0x00000001 /* Receive Error Status */ 604#define PCIE_BAD_TLP 0x00000040 /* Bad TLP Status */ 605#define PCIE_BAD_DLLP 0x00000080 /* Bad DLLP Status */ 606#define PCIE_REPLAY_NUM_ROLLOVER 0x00000100 /* Replay Number Rollover Status */ 607#define PCIE_REPLAY_TIMER_TIMEOUT_ERR 0x00001000 /* Reply Timer Timeout Status */ 608#define PCIE_ADVISORY_NONFTAL_ERR 0x00002000 /* Advisory Non-Fatal Error Status */ 609#define PCIE_CORRECTABLE_ERR (PCIE_RX_ERR | PCIE_BAD_TLP | PCIE_BAD_DLLP | PCIE_REPLAY_NUM_ROLLOVER |\ 610 PCIE_REPLAY_TIMER_TIMEOUT_ERR | PCIE_ADVISORY_NONFTAL_ERR) 611 612/* Correctable Error Mask Register */ 613#define PCIE_CEMR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x114) 614 615/* Advanced Error Capabilities and Control Register */ 616#define PCIE_AECCR(X) (volatile u32*)(PCIE_RC_CFG_BASE + 0x118) 617#define PCIE_AECCR_FIRST_ERR_PTR 0x0000001F /* First Error Pointer */ 618#define PCIE_AECCR_FIRST_ERR_PTR_S 0 619#define PCIE_AECCR_ECRC_GEN_CAP 0x00000020 /* ECRC Generation Capable */ 620#define PCIE_AECCR_ECRC_GEN_EN 0x00000040 /* ECRC Generation Enable */ 621#define PCIE_AECCR_ECRC_CHECK_CAP 0x00000080 /* ECRC Check Capable */ 622#define PCIE_AECCR_ECRC_CHECK_EN 0x00000100 /* ECRC Check Enable */ 623 624/* Header Log Register 1 */ 625#define PCIE_HLR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x11C) 626 627/* Header Log Register 2 */ 628#define PCIE_HLR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x120) 629 630/* Header Log Register 3 */ 631#define PCIE_HLR3(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x124) 632 633/* Header Log Register 4 */ 634#define PCIE_HLR4(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x128) 635 636/* Root Error Command Register */ 637#define PCIE_RECR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x12C) 638#define PCIE_RECR_CORRECTABLE_ERR_REPORT_EN 0x00000001 /* COR-ERR */ 639#define PCIE_RECR_NONFATAL_ERR_REPORT_EN 0x00000002 /* Non-Fatal ERR */ 640#define PCIE_RECR_FATAL_ERR_REPORT_EN 0x00000004 /* Fatal ERR */ 641#define PCIE_RECR_ERR_REPORT_EN (PCIE_RECR_CORRECTABLE_ERR_REPORT_EN | \ 642 PCIE_RECR_NONFATAL_ERR_REPORT_EN | PCIE_RECR_FATAL_ERR_REPORT_EN) 643 644/* Root Error Status Register */ 645#define PCIE_RESR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x130) 646#define PCIE_RESR_CORRECTABLE_ERR 0x00000001 /* COR-ERR Receveid */ 647#define PCIE_RESR_MULTI_CORRECTABLE_ERR 0x00000002 /* Multiple COR-ERR Received */ 648#define PCIE_RESR_FATAL_NOFATAL_ERR 0x00000004 /* ERR Fatal/Non-Fatal Received */ 649#define PCIE_RESR_MULTI_FATAL_NOFATAL_ERR 0x00000008 /* Multiple ERR Fatal/Non-Fatal Received */ 650#define PCIE_RESR_FIRST_UNCORRECTABLE_FATAL_ERR 0x00000010 /* First UN-COR Fatal */ 651#define PCIR_RESR_NON_FATAL_ERR 0x00000020 /* Non-Fatal Error Message Received */ 652#define PCIE_RESR_FATAL_ERR 0x00000040 /* Fatal Message Received */ 653#define PCIE_RESR_AER_INT_MSG_NUM 0xF8000000 /* Advanced Error Interrupt Message Number */ 654#define PCIE_RESR_AER_INT_MSG_NUM_S 27 655 656/* Error Source Indentification Register */ 657#define PCIE_ESIR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x134) 658#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID 0x0000FFFF 659#define PCIE_ESIR_CORRECTABLE_ERR_SRC_ID_S 0 660#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID 0xFFFF0000 661#define PCIE_ESIR_FATAL_NON_FATAL_SRC_ID_S 16 662 663/* VC Enhanced Capability Header */ 664#define PCIE_VC_ECH(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x140) 665 666/* Port VC Capability Register */ 667#define PCIE_PVC1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x144) 668#define PCIE_PVC1_EXT_VC_CNT 0x00000007 /* Extended VC Count */ 669#define PCIE_PVC1_EXT_VC_CNT_S 0 670#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT 0x00000070 /* Low Priority Extended VC Count */ 671#define PCIE_PVC1_LOW_PRI_EXT_VC_CNT_S 4 672#define PCIE_PVC1_REF_CLK 0x00000300 /* Reference Clock */ 673#define PCIE_PVC1_REF_CLK_S 8 674#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE 0x00000C00 /* Port Arbitration Table Entry Size */ 675#define PCIE_PVC1_PORT_ARB_TAB_ENTRY_SIZE_S 10 676 677/* Extended Virtual Channel Count Defintion */ 678#define PCIE_EXT_VC_CNT_MIN 0 679#define PCIE_EXT_VC_CNT_MAX 7 680 681/* Port Arbitration Table Entry Size Definition */ 682enum { 683 PCIE_PORT_ARB_TAB_ENTRY_SIZE_S1BIT = 0, 684 PCIE_PORT_ARB_TAB_ENTRY_SIZE_S2BIT, 685 PCIE_PORT_ARB_TAB_ENTRY_SIZE_S4BIT, 686 PCIE_PORT_ARB_TAB_ENTRY_SIZE_S8BIT, 687}; 688 689/* Port VC Capability Register 2 */ 690#define PCIE_PVC2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x148) 691#define PCIE_PVC2_VC_ARB_16P_FIXED_WRR 0x00000001 /* HW Fixed arbitration, 16 phase WRR */ 692#define PCIE_PVC2_VC_ARB_32P_WRR 0x00000002 /* 32 phase WRR */ 693#define PCIE_PVC2_VC_ARB_64P_WRR 0x00000004 /* 64 phase WRR */ 694#define PCIE_PVC2_VC_ARB_128P_WRR 0x00000008 /* 128 phase WRR */ 695#define PCIE_PVC2_VC_ARB_WRR 0x0000000F 696#define PCIE_PVC2_VC_ARB_TAB_OFFSET 0xFF000000 /* VC arbitration table offset, not support */ 697#define PCIE_PVC2_VC_ARB_TAB_OFFSET_S 24 698 699/* Port VC Control and Status Register */ 700#define PCIE_PVCCRSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x14C) 701#define PCIE_PVCCRSR_LOAD_VC_ARB_TAB 0x00000001 /* Load VC Arbitration Table */ 702#define PCIE_PVCCRSR_VC_ARB_SEL 0x0000000E /* VC Arbitration Select */ 703#define PCIE_PVCCRSR_VC_ARB_SEL_S 1 704#define PCIE_PVCCRSR_VC_ARB_TAB_STATUS 0x00010000 /* Arbitration Status */ 705 706/* VC0 Resource Capability Register */ 707#define PCIE_VC0_RC(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x150) 708#define PCIE_VC0_RC_PORT_ARB_HW_FIXED 0x00000001 /* HW Fixed arbitration */ 709#define PCIE_VC0_RC_PORT_ARB_32P_WRR 0x00000002 /* 32 phase WRR */ 710#define PCIE_VC0_RC_PORT_ARB_64P_WRR 0x00000004 /* 64 phase WRR */ 711#define PCIE_VC0_RC_PORT_ARB_128P_WRR 0x00000008 /* 128 phase WRR */ 712#define PCIE_VC0_RC_PORT_ARB_TM_128P_WRR 0x00000010 /* Time-based 128 phase WRR */ 713#define PCIE_VC0_RC_PORT_ARB_TM_256P_WRR 0x00000020 /* Time-based 256 phase WRR */ 714#define PCIE_VC0_RC_PORT_ARB (PCIE_VC0_RC_PORT_ARB_HW_FIXED | PCIE_VC0_RC_PORT_ARB_32P_WRR |\ 715 PCIE_VC0_RC_PORT_ARB_64P_WRR | PCIE_VC0_RC_PORT_ARB_128P_WRR | \ 716 PCIE_VC0_RC_PORT_ARB_TM_128P_WRR | PCIE_VC0_RC_PORT_ARB_TM_256P_WRR) 717 718#define PCIE_VC0_RC_REJECT_SNOOP 0x00008000 /* Reject Snoop Transactioin */ 719#define PCIE_VC0_RC_MAX_TIMESLOTS 0x007F0000 /* Maximum time Slots */ 720#define PCIE_VC0_RC_MAX_TIMESLOTS_S 16 721#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET 0xFF000000 /* Port Arbitration Table Offset */ 722#define PCIE_VC0_RC_PORT_ARB_TAB_OFFSET_S 24 723 724/* VC0 Resource Control Register */ 725#define PCIE_VC0_RC0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x154) 726#define PCIE_VC0_RC0_TVM0 0x00000001 /* TC0 and VC0 */ 727#define PCIE_VC0_RC0_TVM1 0x00000002 /* TC1 and VC1 */ 728#define PCIE_VC0_RC0_TVM2 0x00000004 /* TC2 and VC2 */ 729#define PCIE_VC0_RC0_TVM3 0x00000008 /* TC3 and VC3 */ 730#define PCIE_VC0_RC0_TVM4 0x00000010 /* TC4 and VC4 */ 731#define PCIE_VC0_RC0_TVM5 0x00000020 /* TC5 and VC5 */ 732#define PCIE_VC0_RC0_TVM6 0x00000040 /* TC6 and VC6 */ 733#define PCIE_VC0_RC0_TVM7 0x00000080 /* TC7 and VC7 */ 734#define PCIE_VC0_RC0_TC_VC 0x000000FF /* TC/VC mask */ 735 736#define PCIE_VC0_RC0_LOAD_PORT_ARB_TAB 0x00010000 /* Load Port Arbitration Table */ 737#define PCIE_VC0_RC0_PORT_ARB_SEL 0x000E0000 /* Port Arbitration Select */ 738#define PCIE_VC0_RC0_PORT_ARB_SEL_S 17 739#define PCIE_VC0_RC0_VC_ID 0x07000000 /* VC ID */ 740#define PCIE_VC0_RC0_VC_ID_S 24 741#define PCIE_VC0_RC0_VC_EN 0x80000000 /* VC Enable */ 742 743/* VC0 Resource Status Register */ 744#define PCIE_VC0_RSR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x158) 745#define PCIE_VC0_RSR0_PORT_ARB_TAB_STATUS 0x00010000 /* Port Arbitration Table Status,not used */ 746#define PCIE_VC0_RSR0_VC_NEG_PENDING 0x00020000 /* VC Negotiation Pending */ 747 748/* Ack Latency Timer and Replay Timer Register */ 749#define PCIE_ALTRT(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x700) 750#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT 0x0000FFFF /* Round Trip Latency Time Limit */ 751#define PCIE_ALTRT_ROUND_TRIP_LATENCY_LIMIT_S 0 752#define PCIE_ALTRT_REPLAY_TIME_LIMIT 0xFFFF0000 /* Replay Time Limit */ 753#define PCIE_ALTRT_REPLAY_TIME_LIMIT_S 16 754 755/* Other Message Register */ 756#define PCIE_OMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x704) 757 758/* Port Force Link Register */ 759#define PCIE_PFLR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x708) 760#define PCIE_PFLR_LINK_NUM 0x000000FF /* Link Number */ 761#define PCIE_PFLR_LINK_NUM_S 0 762#define PCIE_PFLR_FORCE_LINK 0x00008000 /* Force link */ 763#define PCIE_PFLR_LINK_STATE 0x003F0000 /* Link State */ 764#define PCIE_PFLR_LINK_STATE_S 16 765#define PCIE_PFLR_LOW_POWER_ENTRY_CNT 0xFF000000 /* Low Power Entrance Count, only for EP */ 766#define PCIE_PFLR_LOW_POWER_ENTRY_CNT_S 24 767 768/* Ack Frequency Register */ 769#define PCIE_AFR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x70C) 770#define PCIE_AFR_AF 0x000000FF /* Ack Frequency */ 771#define PCIE_AFR_AF_S 0 772#define PCIE_AFR_FTS_NUM 0x0000FF00 /* The number of Fast Training Sequence from L0S to L0 */ 773#define PCIE_AFR_FTS_NUM_S 8 774#define PCIE_AFR_COM_FTS_NUM 0x00FF0000 /* N_FTS; when common clock is used*/ 775#define PCIE_AFR_COM_FTS_NUM_S 16 776#define PCIE_AFR_L0S_ENTRY_LATENCY 0x07000000 /* L0s Entrance Latency */ 777#define PCIE_AFR_L0S_ENTRY_LATENCY_S 24 778#define PCIE_AFR_L1_ENTRY_LATENCY 0x38000000 /* L1 Entrance Latency */ 779#define PCIE_AFR_L1_ENTRY_LATENCY_S 27 780#define PCIE_AFR_FTS_NUM_DEFAULT 32 781#define PCIE_AFR_L0S_ENTRY_LATENCY_DEFAULT 7 782#define PCIE_AFR_L1_ENTRY_LATENCY_DEFAULT 5 783 784/* Port Link Control Register */ 785#define PCIE_PLCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x710) 786#define PCIE_PLCR_OTHER_MSG_REQ 0x00000001 /* Other Message Request */ 787#define PCIE_PLCR_SCRAMBLE_DISABLE 0x00000002 /* Scramble Disable */ 788#define PCIE_PLCR_LOOPBACK_EN 0x00000004 /* Loopback Enable */ 789#define PCIE_PLCR_LTSSM_HOT_RST 0x00000008 /* Force LTSSM to the hot reset */ 790#define PCIE_PLCR_DLL_LINK_EN 0x00000020 /* Enable Link initialization */ 791#define PCIE_PLCR_FAST_LINK_SIM_EN 0x00000080 /* Sets all internal timers to fast mode for simulation purposes */ 792#define PCIE_PLCR_LINK_MODE 0x003F0000 /* Link Mode Enable Mask */ 793#define PCIE_PLCR_LINK_MODE_S 16 794#define PCIE_PLCR_CORRUPTED_CRC_EN 0x02000000 /* Enabled Corrupt CRC */ 795 796/* Lane Skew Register */ 797#define PCIE_LSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x714) 798#define PCIE_LSR_LANE_SKEW_NUM 0x00FFFFFF /* Insert Lane Skew for Transmit, not applicable */ 799#define PCIE_LSR_LANE_SKEW_NUM_S 0 800#define PCIE_LSR_FC_DISABLE 0x01000000 /* Disable of Flow Control */ 801#define PCIE_LSR_ACKNAK_DISABLE 0x02000000 /* Disable of Ack/Nak */ 802#define PCIE_LSR_LANE_DESKEW_DISABLE 0x80000000 /* Disable of Lane-to-Lane Skew */ 803 804/* Symbol Number Register */ 805#define PCIE_SNR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x718) 806#define PCIE_SNR_TS 0x0000000F /* Number of TS Symbol */ 807#define PCIE_SNR_TS_S 0 808#define PCIE_SNR_SKP 0x00000700 /* Number of SKP Symbol */ 809#define PCIE_SNR_SKP_S 8 810#define PCIE_SNR_REPLAY_TIMER 0x0007C000 /* Timer Modifier for Replay Timer */ 811#define PCIE_SNR_REPLAY_TIMER_S 14 812#define PCIE_SNR_ACKNAK_LATENCY_TIMER 0x00F80000 /* Timer Modifier for Ack/Nak Latency Timer */ 813#define PCIE_SNR_ACKNAK_LATENCY_TIMER_S 19 814#define PCIE_SNR_FC_TIMER 0x1F000000 /* Timer Modifier for Flow Control Watchdog Timer */ 815#define PCIE_SNR_FC_TIMER_S 28 816 817/* Symbol Timer Register and Filter Mask Register 1 */ 818#define PCIE_STRFMR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x71C) 819#define PCIE_STRFMR_SKP_INTERVAL 0x000007FF /* SKP lnterval Value */ 820#define PCIE_STRFMR_SKP_INTERVAL_S 0 821#define PCIE_STRFMR_FC_WDT_DISABLE 0x00008000 /* Disable of FC Watchdog Timer */ 822#define PCIE_STRFMR_TLP_FUNC_MISMATCH_OK 0x00010000 /* Mask Function Mismatch Filtering for Incoming Requests */ 823#define PCIE_STRFMR_POISONED_TLP_OK 0x00020000 /* Mask Poisoned TLP Filtering */ 824#define PCIE_STRFMR_BAR_MATCH_OK 0x00040000 /* Mask BAR Match Filtering */ 825#define PCIE_STRFMR_TYPE1_CFG_REQ_OK 0x00080000 /* Mask Type 1 Configuration Request Filtering */ 826#define PCIE_STRFMR_LOCKED_REQ_OK 0x00100000 /* Mask Locked Request Filtering */ 827#define PCIE_STRFMR_CPL_TAG_ERR_RULES_OK 0x00200000 /* Mask Tag Error Rules for Received Completions */ 828#define PCIE_STRFMR_CPL_REQUESTOR_ID_MISMATCH_OK 0x00400000 /* Mask Requester ID Mismatch Error for Received Completions */ 829#define PCIE_STRFMR_CPL_FUNC_MISMATCH_OK 0x00800000 /* Mask Function Mismatch Error for Received Completions */ 830#define PCIE_STRFMR_CPL_TC_MISMATCH_OK 0x01000000 /* Mask Traffic Class Mismatch Error for Received Completions */ 831#define PCIE_STRFMR_CPL_ATTR_MISMATCH_OK 0x02000000 /* Mask Attribute Mismatch Error for Received Completions */ 832#define PCIE_STRFMR_CPL_LENGTH_MISMATCH_OK 0x04000000 /* Mask Length Mismatch Error for Received Completions */ 833#define PCIE_STRFMR_TLP_ECRC_ERR_OK 0x08000000 /* Mask ECRC Error Filtering */ 834#define PCIE_STRFMR_CPL_TLP_ECRC_OK 0x10000000 /* Mask ECRC Error Filtering for Completions */ 835#define PCIE_STRFMR_RX_TLP_MSG_NO_DROP 0x20000000 /* Send Message TLPs */ 836#define PCIE_STRFMR_RX_IO_TRANS_ENABLE 0x40000000 /* Mask Filtering of received I/O Requests */ 837#define PCIE_STRFMR_RX_CFG_TRANS_ENABLE 0x80000000 /* Mask Filtering of Received Configuration Requests */ 838 839#define PCIE_DEF_SKP_INTERVAL 700 /* 1180 ~1538 , 125MHz * 2, 250MHz * 1 */ 840 841/* Filter Masker Register 2 */ 842#define PCIE_FMR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x720) 843#define PCIE_FMR2_VENDOR_MSG0_PASSED_TO_TRGT1 0x00000001 /* Mask RADM Filtering and Error Handling Rules */ 844#define PCIE_FMR2_VENDOR_MSG1_PASSED_TO_TRGT1 0x00000002 /* Mask RADM Filtering and Error Handling Rules */ 845 846/* Debug Register 0 */ 847#define PCIE_DBR0(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x728) 848 849/* Debug Register 1 */ 850#define PCIE_DBR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x72C) 851 852/* Transmit Posted FC Credit Status Register */ 853#define PCIE_TPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x730) 854#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS 0x00000FFF /* Transmit Posted Data FC Credits */ 855#define PCIE_TPFCS_TX_P_DATA_FC_CREDITS_S 0 856#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS 0x000FF000 /* Transmit Posted Header FC Credits */ 857#define PCIE_TPFCS_TX_P_HDR_FC_CREDITS_S 12 858 859/* Transmit Non-Posted FC Credit Status */ 860#define PCIE_TNPFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x734) 861#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS 0x00000FFF /* Transmit Non-Posted Data FC Credits */ 862#define PCIE_TNPFCS_TX_NP_DATA_FC_CREDITS_S 0 863#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS 0x000FF000 /* Transmit Non-Posted Header FC Credits */ 864#define PCIE_TNPFCS_TX_NP_HDR_FC_CREDITS_S 12 865 866/* Transmit Complete FC Credit Status Register */ 867#define PCIE_TCFCS(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x738) 868#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS 0x00000FFF /* Transmit Completion Data FC Credits */ 869#define PCIE_TCFCS_TX_CPL_DATA_FC_CREDITS_S 0 870#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS 0x000FF000 /* Transmit Completion Header FC Credits */ 871#define PCIE_TCFCS_TX_CPL_HDR_FC_CREDITS_S 12 872 873/* Queue Status Register */ 874#define PCIE_QSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x73C) 875#define PCIE_QSR_WAIT_UPDATE_FC_DLL 0x00000001 /* Received TLP FC Credits Not Returned */ 876#define PCIE_QSR_TX_RETRY_BUF_NOT_EMPTY 0x00000002 /* Transmit Retry Buffer Not Empty */ 877#define PCIE_QSR_RX_QUEUE_NOT_EMPTY 0x00000004 /* Received Queue Not Empty */ 878 879/* VC Transmit Arbitration Register 1 */ 880#define PCIE_VCTAR1(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x740) 881#define PCIE_VCTAR1_WRR_WEIGHT_VC0 0x000000FF /* WRR Weight for VC0 */ 882#define PCIE_VCTAR1_WRR_WEIGHT_VC1 0x0000FF00 /* WRR Weight for VC1 */ 883#define PCIE_VCTAR1_WRR_WEIGHT_VC2 0x00FF0000 /* WRR Weight for VC2 */ 884#define PCIE_VCTAR1_WRR_WEIGHT_VC3 0xFF000000 /* WRR Weight for VC3 */ 885 886/* VC Transmit Arbitration Register 2 */ 887#define PCIE_VCTAR2(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x744) 888#define PCIE_VCTAR2_WRR_WEIGHT_VC4 0x000000FF /* WRR Weight for VC4 */ 889#define PCIE_VCTAR2_WRR_WEIGHT_VC5 0x0000FF00 /* WRR Weight for VC5 */ 890#define PCIE_VCTAR2_WRR_WEIGHT_VC6 0x00FF0000 /* WRR Weight for VC6 */ 891#define PCIE_VCTAR2_WRR_WEIGHT_VC7 0xFF000000 /* WRR Weight for VC7 */ 892 893/* VC0 Posted Receive Queue Control Register */ 894#define PCIE_VC0_PRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x748) 895#define PCIE_VC0_PRQCR_P_DATA_CREDITS 0x00000FFF /* VC0 Posted Data Credits */ 896#define PCIE_VC0_PRQCR_P_DATA_CREDITS_S 0 897#define PCIE_VC0_PRQCR_P_HDR_CREDITS 0x000FF000 /* VC0 Posted Header Credits */ 898#define PCIE_VC0_PRQCR_P_HDR_CREDITS_S 12 899#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE 0x00E00000 /* VC0 Posted TLP Queue Mode */ 900#define PCIE_VC0_PRQCR_P_TLP_QUEUE_MODE_S 20 901#define PCIE_VC0_PRQCR_TLP_RELAX_ORDER 0x40000000 /* TLP Type Ordering for VC0 */ 902#define PCIE_VC0_PRQCR_VC_STRICT_ORDER 0x80000000 /* VC0 Ordering for Receive Queues */ 903 904/* VC0 Non-Posted Receive Queue Control */ 905#define PCIE_VC0_NPRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x74C) 906#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS 0x00000FFF /* VC0 Non-Posted Data Credits */ 907#define PCIE_VC0_NPRQCR_NP_DATA_CREDITS_S 0 908#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS 0x000FF000 /* VC0 Non-Posted Header Credits */ 909#define PCIE_VC0_NPRQCR_NP_HDR_CREDITS_S 12 910#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE 0x00E00000 /* VC0 Non-Posted TLP Queue Mode */ 911#define PCIE_VC0_NPRQCR_NP_TLP_QUEUE_MODE_S 20 912 913/* VC0 Completion Receive Queue Control */ 914#define PCIE_VC0_CRQCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x750) 915#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS 0x00000FFF /* VC0 Completion TLP Queue Mode */ 916#define PCIE_VC0_CRQCR_CPL_DATA_CREDITS_S 0 917#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS 0x000FF000 /* VC0 Completion Header Credits */ 918#define PCIE_VC0_CRQCR_CPL_HDR_CREDITS_S 12 919#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE 0x00E00000 /* VC0 Completion Data Credits */ 920#define PCIE_VC0_CRQCR_CPL_TLP_QUEUE_MODE_S 21 921 922/* Applicable to the above three registers */ 923enum { 924 PCIE_VC0_TLP_QUEUE_MODE_STORE_FORWARD = 1, 925 PCIE_VC0_TLP_QUEUE_MODE_CUT_THROUGH = 2, 926 PCIE_VC0_TLP_QUEUE_MODE_BYPASS = 4, 927}; 928 929/* VC0 Posted Buffer Depth Register */ 930#define PCIE_VC0_PBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7A8) 931#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Posted Data Queue Depth */ 932#define PCIE_VC0_PBD_P_DATA_QUEUE_ENTRIES_S 0 933#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Posted Header Queue Depth */ 934#define PCIE_VC0_PBD_P_HDR_QUEUE_ENTRIES_S 16 935 936/* VC0 Non-Posted Buffer Depth Register */ 937#define PCIE_VC0_NPBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7AC) 938#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES 0x00003FFF /* VC0 Non-Posted Data Queue Depth */ 939#define PCIE_VC0_NPBD_NP_DATA_QUEUE_ENTRIES_S 0 940#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Non-Posted Header Queue Depth */ 941#define PCIE_VC0_NPBD_NP_HDR_QUEUE_ENTRIES_S 16 942 943/* VC0 Completion Buffer Depth Register */ 944#define PCIE_VC0_CBD(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x7B0) 945#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES 0x00003FFF /* C0 Completion Data Queue Depth */ 946#define PCIE_VC0_CBD_CPL_DATA_QUEUE_ENTRIES_S 0 947#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES 0x03FF0000 /* VC0 Completion Header Queue Depth */ 948#define PCIE_VC0_CBD_CPL_HDR_QUEUE_ENTRIES_S 16 949 950/* PHY Status Register, all zeros in VR9 */ 951#define PCIE_PHYSR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x810) 952 953/* PHY Control Register, all zeros in VR9 */ 954#define PCIE_PHYCR(X) (volatile u32*)(PCIE_RC_PORT_TO_BASE(X) + 0x814) 955 956/* 957 * PCIe PDI PHY register definition, suppose all the following 958 * stuff is confidential. 959 * XXX, detailed bit definition 960 */ 961#define PCIE_PHY_PLL_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x22 << 1)) 962#define PCIE_PHY_PLL_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x23 << 1)) 963#define PCIE_PHY_PLL_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x24 << 1)) 964#define PCIE_PHY_PLL_CTRL4(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x25 << 1)) 965#define PCIE_PHY_PLL_CTRL5(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x26 << 1)) 966#define PCIE_PHY_PLL_CTRL6(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x27 << 1)) 967#define PCIE_PHY_PLL_CTRL7(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x28 << 1)) 968#define PCIE_PHY_PLL_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x29 << 1)) 969#define PCIE_PHY_PLL_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2A << 1)) 970#define PCIE_PHY_PLL_A_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2B << 1)) 971#define PCIE_PHY_PLL_STATUS(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x2C << 1)) 972 973#define PCIE_PHY_TX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x30 << 1)) 974#define PCIE_PHY_TX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x31 << 1)) 975#define PCIE_PHY_TX1_CTRL3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x32 << 1)) 976#define PCIE_PHY_TX1_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x33 << 1)) 977#define PCIE_PHY_TX1_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x34 << 1)) 978#define PCIE_PHY_TX1_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x35 << 1)) 979#define PCIE_PHY_TX1_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x36 << 1)) 980#define PCIE_PHY_TX1_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x37 << 1)) 981 982#define PCIE_PHY_TX2_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x38 << 1)) 983#define PCIE_PHY_TX2_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x39 << 1)) 984#define PCIE_PHY_TX2_A_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3B << 1)) 985#define PCIE_PHY_TX2_A_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3C << 1)) 986#define PCIE_PHY_TX2_MOD1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3D << 1)) 987#define PCIE_PHY_TX2_MOD2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3E << 1)) 988#define PCIE_PHY_TX2_MOD3(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x3F << 1)) 989 990#define PCIE_PHY_RX1_CTRL1(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x50 << 1)) 991#define PCIE_PHY_RX1_CTRL2(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x51 << 1)) 992#define PCIE_PHY_RX1_CDR(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x52 << 1)) 993#define PCIE_PHY_RX1_EI(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x53 << 1)) 994#define PCIE_PHY_RX1_A_CTRL(X) (PCIE_PHY_PORT_TO_BASE(X) + (0x55 << 1)) 995 996/* Interrupt related stuff */ 997#define PCIE_LEGACY_DISABLE 0 998#define PCIE_LEGACY_INTA 1 999#define PCIE_LEGACY_INTB 2 1000#define PCIE_LEGACY_INTC 3 1001#define PCIE_LEGACY_INTD 4 1002#define PCIE_LEGACY_INT_MAX PCIE_LEGACY_INTD 1003 1004#define PCIE_IRQ_LOCK(lock) do { \ 1005 unsigned long flags; \ 1006 spin_lock_irqsave(&(lock), flags); 1007#define PCIE_IRQ_UNLOCK(lock) \ 1008 spin_unlock_irqrestore(&(lock), flags); \ 1009} while (0) 1010 1011#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) 1012#define IRQF_SHARED SA_SHIRQ 1013#endif 1014 1015#define PCIE_MSG_MSI 0x00000001 1016#define PCIE_MSG_ISR 0x00000002 1017#define PCIE_MSG_FIXUP 0x00000004 1018#define PCIE_MSG_READ_CFG 0x00000008 1019#define PCIE_MSG_WRITE_CFG 0x00000010 1020#define PCIE_MSG_CFG (PCIE_MSG_READ_CFG | PCIE_MSG_WRITE_CFG) 1021#define PCIE_MSG_REG 0x00000020 1022#define PCIE_MSG_INIT 0x00000040 1023#define PCIE_MSG_ERR 0x00000080 1024#define PCIE_MSG_PHY 0x00000100 1025#define PCIE_MSG_ANY 0x000001ff 1026 1027#define IFX_PCIE_PORT0 0 1028#define IFX_PCIE_PORT1 1 1029 1030#ifdef CONFIG_IFX_PCIE_2ND_CORE 1031#define IFX_PCIE_CORE_NR 2 1032#else 1033#define IFX_PCIE_CORE_NR 1 1034#endif 1035 1036//#define IFX_PCIE_ERROR_INT 1037 1038//#define IFX_PCIE_DBG 1039 1040#if defined(IFX_PCIE_DBG) 1041#define IFX_PCIE_PRINT(_m, _fmt, args...) do { \ 1042 if (g_pcie_debug_flag & (_m)) { \ 1043 ifx_pcie_debug((_fmt), ##args); \ 1044 } \ 1045} while (0) 1046 1047#define INLINE 1048#else 1049#define IFX_PCIE_PRINT(_m, _fmt, args...) \ 1050 do {} while(0) 1051#define INLINE inline 1052#endif 1053 1054struct ifx_pci_controller { 1055 struct pci_controller pcic; 1056 1057 /* RC specific, per host bus information */ 1058 u32 port; /* Port index, 0 -- 1st core, 1 -- 2nd core */ 1059}; 1060 1061typedef struct ifx_pcie_ir_irq { 1062 const unsigned int irq; 1063 const char name[16]; 1064}ifx_pcie_ir_irq_t; 1065 1066typedef struct ifx_pcie_legacy_irq{ 1067 const u32 irq_bit; 1068 const int irq; 1069}ifx_pcie_legacy_irq_t; 1070 1071typedef struct ifx_pcie_irq { 1072 ifx_pcie_ir_irq_t ir_irq; 1073 ifx_pcie_legacy_irq_t legacy_irq[PCIE_LEGACY_INT_MAX]; 1074}ifx_pcie_irq_t; 1075 1076extern u32 g_pcie_debug_flag; 1077extern void ifx_pcie_debug(const char *fmt, ...); 1078extern void pcie_phy_clock_mode_setup(int pcie_port); 1079extern void pcie_msi_pic_init(int pcie_port); 1080extern u32 ifx_pcie_bus_enum_read_hack(int where, u32 value); 1081extern u32 ifx_pcie_bus_enum_write_hack(int where, u32 value); 1082 1083 1084#include <linux/types.h> 1085#include <linux/delay.h> 1086#include <linux/gpio.h> 1087#include <linux/clk.h> 1088 1089#include <lantiq_soc.h> 1090 1091#define IFX_PCIE_GPIO_RESET 38 1092#define IFX_REG_R32 ltq_r32 1093#define IFX_REG_W32 ltq_w32 1094#define CONFIG_IFX_PCIE_HW_SWAP 1095#define IFX_RCU_AHB_ENDIAN ((volatile u32*)(IFX_RCU + 0x004C)) 1096#define IFX_RCU_RST_REQ ((volatile u32*)(IFX_RCU + 0x0010)) 1097#define IFX_RCU_AHB_BE_PCIE_PDI 0x00000080 /* Configure PCIE PDI module in big endian*/ 1098 1099#define IFX_RCU (KSEG1 | 0x1F203000) 1100#define IFX_RCU_AHB_BE_PCIE_M 0x00000001 /* Configure AHB master port that connects to PCIe RC in big endian */ 1101#define IFX_RCU_AHB_BE_PCIE_S 0x00000010 /* Configure AHB slave port that connects to PCIe RC in little endian */ 1102#define IFX_RCU_AHB_BE_XBAR_M 0x00000002 /* Configure AHB master port that connects to XBAR in big endian */ 1103#define CONFIG_IFX_PCIE_PHY_36MHZ_MODE 1104 1105#define IFX_PMU1_MODULE_PCIE_PHY (0) 1106#define IFX_PMU1_MODULE_PCIE_CTRL (1) 1107#define IFX_PMU1_MODULE_PDI (4) 1108#define IFX_PMU1_MODULE_MSI (5) 1109 1110#define IFX_PMU_MODULE_PCIE_L0_CLK (31) 1111 1112 1113static inline void pcie_ep_gpio_rst_init(int pcie_port) 1114{ 1115} 1116 1117static inline void pcie_ahb_pmu_setup(void) 1118{ 1119 struct clk *clk; 1120 clk = clk_get_sys("ltq_pcie", "ahb"); 1121 clk_enable(clk); 1122 //ltq_pmu_enable(PMU_AHBM | PMU_AHBS); 1123} 1124 1125static inline void pcie_rcu_endian_setup(int pcie_port) 1126{ 1127 u32 reg; 1128 1129 reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN); 1130#ifdef CONFIG_IFX_PCIE_HW_SWAP 1131 reg |= IFX_RCU_AHB_BE_PCIE_M; 1132 reg |= IFX_RCU_AHB_BE_PCIE_S; 1133 reg &= ~IFX_RCU_AHB_BE_XBAR_M; 1134#else 1135 reg |= IFX_RCU_AHB_BE_PCIE_M; 1136 reg &= ~IFX_RCU_AHB_BE_PCIE_S; 1137 reg &= ~IFX_RCU_AHB_BE_XBAR_M; 1138#endif /* CONFIG_IFX_PCIE_HW_SWAP */ 1139 IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN); 1140 IFX_PCIE_PRINT(PCIE_MSG_REG, "%s IFX_RCU_AHB_ENDIAN: 0x%08x\n", __func__, IFX_REG_R32(IFX_RCU_AHB_ENDIAN)); 1141} 1142 1143static inline void pcie_phy_pmu_enable(int pcie_port) 1144{ 1145 struct clk *clk; 1146 clk = clk_get_sys("ltq_pcie", "phy"); 1147 clk_enable(clk); 1148 //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PCIE_PHY); 1149} 1150 1151static inline void pcie_phy_pmu_disable(int pcie_port) 1152{ 1153 struct clk *clk; 1154 clk = clk_get_sys("ltq_pcie", "phy"); 1155 clk_disable(clk); 1156 //ltq_pmu1_disable(1<<IFX_PMU1_MODULE_PCIE_PHY); 1157} 1158 1159static inline void pcie_pdi_big_endian(int pcie_port) 1160{ 1161 u32 reg; 1162 1163 /* SRAM2PDI endianness control. */ 1164 reg = IFX_REG_R32(IFX_RCU_AHB_ENDIAN); 1165 /* Config AHB->PCIe and PDI endianness */ 1166 reg |= IFX_RCU_AHB_BE_PCIE_PDI; 1167 IFX_REG_W32(reg, IFX_RCU_AHB_ENDIAN); 1168} 1169 1170static inline void pcie_pdi_pmu_enable(int pcie_port) 1171{ 1172 struct clk *clk; 1173 clk = clk_get_sys("ltq_pcie", "pdi"); 1174 clk_enable(clk); 1175 //ltq_pmu1_enable(1<<IFX_PMU1_MODULE_PDI); 1176} 1177 1178static inline void pcie_core_rst_assert(int pcie_port) 1179{ 1180 u32 reg; 1181 1182 reg = IFX_REG_R32(IFX_RCU_RST_REQ); 1183 1184 /* Reset PCIe PHY & Core, bit 22, bit 26 may be affected if write it directly */ 1185 reg |= 0x00400000; 1186 IFX_REG_W32(reg, IFX_RCU_RST_REQ); 1187} 1188 1189static inline void pcie_core_rst_deassert(int pcie_port) 1190{ 1191 u32 reg; 1192 1193 /* Make sure one micro-second delay */ 1194 udelay(1); 1195 1196 /* Reset PCIe PHY & Core, bit 22 */ 1197 reg = IFX_REG_R32(IFX_RCU_RST_REQ); 1198 reg &= ~0x00400000; 1199 IFX_REG_W32(reg, IFX_RCU_RST_REQ); 1200} 1201 1202static inline void pcie_phy_rst_assert(int pcie_port) 1203{ 1204 u32 reg; 1205 1206 reg = IFX_REG_R32(IFX_RCU_RST_REQ); 1207 reg |= 0x00001000; /* Bit 12 */ 1208 IFX_REG_W32(reg, IFX_RCU_RST_REQ); 1209} 1210 1211static inline void pcie_phy_rst_deassert(int pcie_port) 1212{ 1213 u32 reg; 1214 1215 /* Make sure one micro-second delay */ 1216 udelay(1); 1217 1218 reg = IFX_REG_R32(IFX_RCU_RST_REQ); 1219 reg &= ~0x00001000; /* Bit 12 */ 1220 IFX_REG_W32(reg, IFX_RCU_RST_REQ); 1221} 1222 1223static inline void pcie_device_rst_assert(int pcie_port) 1224{ 1225 gpio_set_value(IFX_PCIE_GPIO_RESET, 0); 1226 // ifx_gpio_output_clear(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id); 1227} 1228 1229static inline void pcie_device_rst_deassert(int pcie_port) 1230{ 1231 mdelay(100); 1232 gpio_set_value(IFX_PCIE_GPIO_RESET, 1); 1233// ifx_gpio_output_set(IFX_PCIE_GPIO_RESET, ifx_pcie_gpio_module_id); 1234} 1235 1236static inline void pcie_core_pmu_setup(int pcie_port) 1237{ 1238 struct clk *clk; 1239 clk = clk_get_sys("ltq_pcie", "ctl"); 1240 clk_enable(clk); 1241 clk = clk_get_sys("ltq_pcie", "bus"); 1242 clk_enable(clk); 1243 1244 //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_PCIE_CTRL); 1245 //ltq_pmu_enable(1 << IFX_PMU_MODULE_PCIE_L0_CLK); 1246} 1247 1248static inline void pcie_msi_init(int pcie_port) 1249{ 1250 struct clk *clk; 1251 pcie_msi_pic_init(pcie_port); 1252 clk = clk_get_sys("ltq_pcie", "msi"); 1253 clk_enable(clk); 1254 //ltq_pmu1_enable(1 << IFX_PMU1_MODULE_MSI); 1255} 1256 1257static inline u32 1258ifx_pcie_bus_nr_deduct(u32 bus_number, int pcie_port) 1259{ 1260 u32 tbus_number = bus_number; 1261 1262#ifdef CONFIG_IFX_PCI 1263 if (pcibios_host_nr() > 1) { 1264 tbus_number -= pcibios_1st_host_bus_nr(); 1265 } 1266#endif /* CONFIG_IFX_PCI */ 1267 return tbus_number; 1268} 1269 1270static inline u32 1271ifx_pcie_bus_enum_hack(struct pci_bus *bus, u32 devfn, int where, u32 value, int pcie_port, int read) 1272{ 1273 struct pci_dev *pdev; 1274 u32 tvalue = value; 1275 1276 /* Sanity check */ 1277 pdev = pci_get_slot(bus, devfn); 1278 if (pdev == NULL) { 1279 return tvalue; 1280 } 1281 1282 /* Only care about PCI bridge */ 1283 if (pdev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { 1284 return tvalue; 1285 } 1286 1287 if (read) { /* Read hack */ 1288 #ifdef CONFIG_IFX_PCI 1289 if (pcibios_host_nr() > 1) { 1290 tvalue = ifx_pcie_bus_enum_read_hack(where, tvalue); 1291 } 1292 #endif /* CONFIG_IFX_PCI */ 1293 } 1294 else { /* Write hack */ 1295 #ifdef CONFIG_IFX_PCI 1296 if (pcibios_host_nr() > 1) { 1297 tvalue = ifx_pcie_bus_enum_write_hack(where, tvalue); 1298 } 1299 #endif 1300 } 1301 return tvalue; 1302} 1303 1304#endif /* IFXMIPS_PCIE_VR9_H */ 1305 1306