13 #include <soc/addressmap.h>
17 #include <soc/soc_chip.h>
21 #define PCIE_SETTING_REG 0x80
22 #define PCIE_PCI_IDS_1 0x9c
23 #define PCI_CLASS(class) ((class) << 8)
24 #define PCIE_RC_MODE BIT(0)
26 #define PCIE_CFGNUM_REG 0x140
27 #define PCIE_CFG_DEVFN(devfn) ((devfn) & GENMASK(7, 0))
28 #define PCIE_CFG_BUS(bus) (((bus) << 8) & GENMASK(15, 8))
29 #define PCIE_CFG_OFFSET_ADDR 0x1000
30 #define PCIE_CFG_HEADER(bus, devfn) \
31 (PCIE_CFG_BUS(bus) | PCIE_CFG_DEVFN(devfn))
33 #define PCIE_RST_CTRL_REG 0x148
34 #define PCIE_MAC_RSTB BIT(0)
35 #define PCIE_PHY_RSTB BIT(1)
36 #define PCIE_BRG_RSTB BIT(2)
37 #define PCIE_PE_RSTB BIT(3)
39 #define PCIE_LTSSM_STATUS_REG 0x150
40 #define PCIE_LTSSM_STATE(val) (((val) >> 24) & 0x1f)
42 #define PCIE_LINK_STATUS_REG 0x154
43 #define PCIE_CTRL_LINKUP BIT(8)
45 #define PCI_NUM_INTX 4
46 #define PCIE_INT_ENABLE_REG 0x180
47 #define PCIE_INTX_SHIFT 24
48 #define PCIE_INTX_ENABLE \
49 GENMASK(PCIE_INTX_SHIFT + PCI_NUM_INTX - 1, PCIE_INTX_SHIFT)
51 #define PCIE_TRANS_TABLE_BASE_REG 0x800
52 #define PCIE_ATR_SRC_ADDR_MSB_OFFSET 0x4
53 #define PCIE_ATR_TRSL_ADDR_LSB_OFFSET 0x8
54 #define PCIE_ATR_TRSL_ADDR_MSB_OFFSET 0xc
55 #define PCIE_ATR_TRSL_PARAM_OFFSET 0x10
56 #define PCIE_ATR_TLB_SET_OFFSET 0x20
58 #define PCIE_MAX_TRANS_TABLES 8
59 #define PCIE_ATR_EN BIT(0)
60 #define PCIE_ATR_SIZE(size) \
61 (((((size) - 1) << 1) & GENMASK(6, 1)) | PCIE_ATR_EN)
62 #define PCIE_ATR_ID(id) ((id) & GENMASK(3, 0))
63 #define PCIE_ATR_TYPE_MEM PCIE_ATR_ID(0)
64 #define PCIE_ATR_TYPE_IO PCIE_ATR_ID(1)
65 #define PCIE_ATR_TLP_TYPE(type) (((type) << 16) & GENMASK(18, 16))
66 #define PCIE_ATR_TLP_TYPE_MEM PCIE_ATR_TLP_TYPE(0)
67 #define PCIE_ATR_TLP_TYPE_IO PCIE_ATR_TLP_TYPE(2)
75 "polling.configuration",
76 "config.linkwidthstart",
77 "config.linkwidthaccept",
79 "config.lanenumaccept",
82 "recovery.receiverlock",
83 "recovery.equalization",
85 "recovery.receiverconfig",
133 const char *range_type;
159 "%s: set %s trans window: cpu_addr = %#x, pci_addr = %#x, size = %#x\n",
217 const char *ltssm_state;
240 __func__, perst_time_us);
248 const long min_perst_time_us = 100000;
249 if (perst_time_us < min_perst_time_us) {
250 if (!perst_time_us) {
252 "%s: PCIe early init data not found, sleeping 100ms\n",
257 "%s: Need an extra %ld us delay to meet PERST# deassertion requirement\n",
258 __func__, min_perst_time_us - perst_time_us);
261 udelay(min_perst_time_us - perst_time_us);
274 __func__, ltssm_state);
#define retry(attempts, condition,...)
#define GENMASK(high, low)
#define printk(level,...)
void mdelay(unsigned int msecs)
DEVTREE_CONST struct device * pcidev_path_on_root(pci_devfn_t devfn)
struct resource * new_resource(struct device *dev, unsigned int index)
See if a resource structure already exists for a given index and if not allocate one.
static DEVTREE_CONST void * config_of(const struct device *dev)
static __always_inline uint32_t read32p(const uintptr_t addr)
static __always_inline void write32p(const uintptr_t addr, const uint32_t value)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
#define BIOS_WARNING
BIOS_WARNING - Bad configuration.
static struct resource * mmio_res
#define PCI_DEV2DEVFN(sdev)
#define PCI_DEV2SEGBUS(sdev)
void pci_domain_set_resources(struct device *dev)
#define PCI_CLASS_BRIDGE_PCI
#define IORESOURCE_SUBTRACTIVE
#define IORESOURCE_ASSIGNED
#define IOINDEX_SUBTRACTIVE(IDX, LINK)
const struct mtk_pcie_mmio_res mmio_res_mem
const struct mtk_pcie_mmio_res mmio_res_io