2 * Copyright 2014-2015 Freescale Semiconductor, Inc.
3 * Layerscape PCIe driver
5 * SPDX-License-Identifier: GPL-2.0+
8 #ifndef _PCIE_LAYERSCAPE_H_
9 #define _PCIE_LAYERSCAPE_H_
13 #ifndef CONFIG_SYS_PCI_MEMORY_BUS
14 #define CONFIG_SYS_PCI_MEMORY_BUS CONFIG_SYS_SDRAM_BASE
17 #ifndef CONFIG_SYS_PCI_MEMORY_PHYS
18 #define CONFIG_SYS_PCI_MEMORY_PHYS CONFIG_SYS_SDRAM_BASE
21 #ifndef CONFIG_SYS_PCI_MEMORY_SIZE
22 #define CONFIG_SYS_PCI_MEMORY_SIZE (2 * 1024 * 1024 * 1024UL) /* 2G */
25 #ifndef CONFIG_SYS_PCI_EP_MEMORY_BASE
26 #define CONFIG_SYS_PCI_EP_MEMORY_BASE CONFIG_SYS_LOAD_ADDR
30 #define PCIE_ATU_VIEWPORT 0x900
31 #define PCIE_ATU_REGION_INBOUND (0x1 << 31)
32 #define PCIE_ATU_REGION_OUTBOUND (0x0 << 31)
33 #define PCIE_ATU_REGION_INDEX0 (0x0 << 0)
34 #define PCIE_ATU_REGION_INDEX1 (0x1 << 0)
35 #define PCIE_ATU_REGION_INDEX2 (0x2 << 0)
36 #define PCIE_ATU_REGION_INDEX3 (0x3 << 0)
37 #define PCIE_ATU_REGION_NUM 6
38 #define PCIE_ATU_CR1 0x904
39 #define PCIE_ATU_TYPE_MEM (0x0 << 0)
40 #define PCIE_ATU_TYPE_IO (0x2 << 0)
41 #define PCIE_ATU_TYPE_CFG0 (0x4 << 0)
42 #define PCIE_ATU_TYPE_CFG1 (0x5 << 0)
43 #define PCIE_ATU_CR2 0x908
44 #define PCIE_ATU_ENABLE (0x1 << 31)
45 #define PCIE_ATU_BAR_MODE_ENABLE (0x1 << 30)
46 #define PCIE_ATU_BAR_NUM(bar) ((bar) << 8)
47 #define PCIE_ATU_LOWER_BASE 0x90C
48 #define PCIE_ATU_UPPER_BASE 0x910
49 #define PCIE_ATU_LIMIT 0x914
50 #define PCIE_ATU_LOWER_TARGET 0x918
51 #define PCIE_ATU_BUS(x) (((x) & 0xff) << 24)
52 #define PCIE_ATU_DEV(x) (((x) & 0x1f) << 19)
53 #define PCIE_ATU_FUNC(x) (((x) & 0x7) << 16)
54 #define PCIE_ATU_UPPER_TARGET 0x91C
57 #define PCIE_SRIOV 0x178
58 #define PCIE_STRFMR1 0x71c /* Symbol Timer & Filter Mask Register1 */
59 #define PCIE_DBI_RO_WR_EN 0x8bc
61 #define PCIE_LINK_CAP 0x7c
62 #define PCIE_LINK_SPEED_MASK 0xf
63 #define PCIE_LINK_WIDTH_MASK 0x3f0
64 #define PCIE_LINK_STA 0x82
66 #define LTSSM_STATE_MASK 0x3f
67 #define LTSSM_PCIE_L0 0x11 /* L0 state */
69 #define PCIE_DBI_SIZE 0x100000 /* 1M */
71 #define PCIE_LCTRL0_CFG2_ENABLE (1 << 31)
72 #define PCIE_LCTRL0_VF(vf) ((vf) << 22)
73 #define PCIE_LCTRL0_PF(pf) ((pf) << 16)
74 #define PCIE_LCTRL0_VF_ACTIVE (1 << 21)
75 #define PCIE_LCTRL0_VAL(pf, vf) (PCIE_LCTRL0_PF(pf) | \
76 PCIE_LCTRL0_VF(vf) | \
77 ((vf) == 0 ? 0 : PCIE_LCTRL0_VF_ACTIVE) | \
78 PCIE_LCTRL0_CFG2_ENABLE)
80 #define PCIE_NO_SRIOV_BAR_BASE 0x1000
83 #define PCIE_VF_NUM 64
85 #define PCIE_BAR0_SIZE (4 * 1024) /* 4K */
86 #define PCIE_BAR1_SIZE (8 * 1024) /* 8K for MSIX */
87 #define PCIE_BAR2_SIZE (4 * 1024) /* 4K */
88 #define PCIE_BAR4_SIZE (1 * 1024 * 1024) /* 1M */
91 #define PCIE_LUT_UDR(n) (0x800 + (n) * 8)
92 #define PCIE_LUT_LDR(n) (0x804 + (n) * 8)
93 #define PCIE_LUT_ENABLE (1 << 31)
94 #define PCIE_LUT_ENTRY_COUNT 32
96 /* PF Controll registers */
97 #define PCIE_PF_VF_CTRL 0x7F8
98 #define PCIE_PF_DBG 0x7FC
100 #define PCIE_SRDS_PRTCL(idx) (PCIE1 + (idx))
101 #define PCIE_SYS_BASE_ADDR 0x3400000
102 #define PCIE_CCSR_SIZE 0x0100000
105 #define PCIE_CS2_OFFSET 0x1000 /* For PCIe without SR-IOV */
107 #define SVR_LS102XA 0
108 #define SVR_VAR_PER_SHIFT 8
109 #define SVR_LS102XA_MASK 0x700
111 /* LS1021a PCIE space */
112 #define LS1021_PCIE_SPACE_OFFSET 0x4000000000ULL
113 #define LS1021_PCIE_SPACE_SIZE 0x0800000000ULL
115 /* LS1021a PEX1/2 Misc Ports Status Register */
116 #define LS1021_PEXMSCPORTSR(pex_idx) (0x94 + (pex_idx) * 4)
117 #define LS1021_LTSSM_STATE_SHIFT 20
121 struct list_head list;
123 struct fdt_resource dbi_res;
124 struct fdt_resource lut_res;
125 struct fdt_resource ctrl_res;
126 struct fdt_resource cfg_res;
135 struct pci_controller hose;
138 extern struct list_head ls_pcie_list;
140 #endif /* _PCIE_LAYERSCAPE_H_ */