Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2020 NXP |
| 4 | * Layerscape PCIe EP driver |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Wasim Khan | 8b3d2d2 | 2020-09-28 16:26:04 +0530 | [diff] [blame] | 8 | #include <asm/arch/fsl_serdes.h> |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 9 | #include <dm.h> |
| 10 | #include <dm/devres.h> |
| 11 | #include <errno.h> |
| 12 | #include <pci_ep.h> |
| 13 | #include <asm/io.h> |
| 14 | #include <linux/sizes.h> |
| 15 | #include <linux/log2.h> |
| 16 | #include "pcie_layerscape.h" |
| 17 | |
| 18 | DECLARE_GLOBAL_DATA_PTR; |
| 19 | |
| 20 | static void ls_pcie_ep_enable_cfg(struct ls_pcie_ep *pcie_ep) |
| 21 | { |
| 22 | struct ls_pcie *pcie = pcie_ep->pcie; |
| 23 | u32 config; |
| 24 | |
| 25 | config = ctrl_readl(pcie, PCIE_PF_CONFIG); |
| 26 | config |= PCIE_CONFIG_READY; |
| 27 | ctrl_writel(pcie, config, PCIE_PF_CONFIG); |
| 28 | } |
| 29 | |
| 30 | static int ls_ep_set_bar(struct udevice *dev, uint fn, struct pci_bar *ep_bar) |
| 31 | { |
| 32 | struct ls_pcie_ep *pcie_ep = dev_get_priv(dev); |
| 33 | struct ls_pcie *pcie = pcie_ep->pcie; |
| 34 | dma_addr_t bar_phys = ep_bar->phys_addr; |
| 35 | enum pci_barno bar = ep_bar->barno; |
| 36 | u32 reg = PCI_BASE_ADDRESS_0 + (4 * bar); |
| 37 | int flags = ep_bar->flags; |
| 38 | int type, idx; |
| 39 | u64 size; |
| 40 | |
| 41 | idx = bar; |
| 42 | /* BAR size is 2^(aperture + 11) */ |
| 43 | size = max_t(size_t, ep_bar->size, FSL_PCIE_EP_MIN_APERTURE); |
| 44 | |
| 45 | if (!(flags & PCI_BASE_ADDRESS_SPACE)) |
| 46 | type = PCIE_ATU_TYPE_MEM; |
| 47 | else |
| 48 | type = PCIE_ATU_TYPE_IO; |
| 49 | |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 50 | ls_pcie_atu_inbound_set(pcie, fn, 0, type, idx, bar, bar_phys); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 51 | |
| 52 | dbi_writel(pcie, lower_32_bits(size - 1), reg + PCIE_NO_SRIOV_BAR_BASE); |
| 53 | dbi_writel(pcie, flags, reg); |
| 54 | |
| 55 | if (flags & PCI_BASE_ADDRESS_MEM_TYPE_64) { |
| 56 | dbi_writel(pcie, upper_32_bits(size - 1), |
| 57 | reg + 4 + PCIE_NO_SRIOV_BAR_BASE); |
| 58 | dbi_writel(pcie, 0, reg + 4); |
| 59 | } |
| 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static struct pci_ep_ops ls_pcie_ep_ops = { |
| 65 | .set_bar = ls_ep_set_bar, |
| 66 | }; |
| 67 | |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 68 | static void ls_pcie_ep_setup_atu(struct ls_pcie_ep *pcie_ep, u32 pf) |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 69 | { |
| 70 | struct ls_pcie *pcie = pcie_ep->pcie; |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 71 | u32 vf_flag = 0; |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 72 | u64 phys = 0; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 73 | |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 74 | phys = CONFIG_SYS_PCI_EP_MEMORY_BASE + pf * SZ_64M; |
| 75 | |
| 76 | phys = ALIGN(phys, PCIE_BAR0_SIZE); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 77 | /* ATU 0 : INBOUND : map BAR0 */ |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 78 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 79 | 0 + pf * BAR_NUM, 0, phys); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 80 | /* ATU 1 : INBOUND : map BAR1 */ |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 81 | phys = ALIGN(phys + PCIE_BAR0_SIZE, PCIE_BAR1_SIZE); |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 82 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 83 | 1 + pf * BAR_NUM, 1, phys); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 84 | /* ATU 2 : INBOUND : map BAR2 */ |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 85 | phys = ALIGN(phys + PCIE_BAR1_SIZE, PCIE_BAR2_SIZE); |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 86 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 87 | 2 + pf * BAR_NUM, 2, phys); |
| 88 | /* ATU 3 : INBOUND : map BAR2 */ |
| 89 | phys = ALIGN(phys + PCIE_BAR2_SIZE, PCIE_BAR4_SIZE); |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 90 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 91 | 3 + pf * BAR_NUM, 4, phys); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 92 | |
Xiaowei Bao | ecb85db | 2020-07-09 23:31:39 +0800 | [diff] [blame] | 93 | if (pcie_ep->sriov_flag) { |
| 94 | vf_flag = 1; |
| 95 | /* ATU 4 : INBOUND : map BAR0 */ |
| 96 | phys = ALIGN(phys + PCIE_BAR4_SIZE, PCIE_BAR0_SIZE); |
| 97 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
| 98 | 4 + pf * BAR_NUM, 0, phys); |
| 99 | /* ATU 5 : INBOUND : map BAR1 */ |
| 100 | phys = ALIGN(phys + PCIE_BAR0_SIZE * PCIE_VF_NUM, |
| 101 | PCIE_BAR1_SIZE); |
| 102 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
| 103 | 5 + pf * BAR_NUM, 1, phys); |
| 104 | /* ATU 6 : INBOUND : map BAR2 */ |
| 105 | phys = ALIGN(phys + PCIE_BAR1_SIZE * PCIE_VF_NUM, |
| 106 | PCIE_BAR2_SIZE); |
| 107 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
| 108 | 6 + pf * BAR_NUM, 2, phys); |
| 109 | /* ATU 7 : INBOUND : map BAR4 */ |
| 110 | phys = ALIGN(phys + PCIE_BAR2_SIZE * PCIE_VF_NUM, |
| 111 | PCIE_BAR4_SIZE); |
| 112 | ls_pcie_atu_inbound_set(pcie, pf, vf_flag, PCIE_ATU_TYPE_MEM, |
| 113 | 7 + pf * BAR_NUM, 4, phys); |
| 114 | } |
| 115 | |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 116 | /* ATU: OUTBOUND : map MEM */ |
| 117 | ls_pcie_atu_outbound_set(pcie, pf, PCIE_ATU_TYPE_MEM, |
| 118 | (u64)pcie_ep->addr_res.start + |
| 119 | pf * CONFIG_SYS_PCI_MEMORY_SIZE, |
| 120 | 0, CONFIG_SYS_PCI_MEMORY_SIZE); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | /* BAR0 and BAR1 are 32bit BAR2 and BAR4 are 64bit */ |
| 124 | static void ls_pcie_ep_setup_bar(void *bar_base, int bar, u32 size) |
| 125 | { |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 126 | u32 mask; |
| 127 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 128 | /* The least inbound window is 4KiB */ |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 129 | if (size < SZ_4K) |
| 130 | mask = 0; |
| 131 | else |
| 132 | mask = size - 1; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 133 | |
| 134 | switch (bar) { |
| 135 | case 0: |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 136 | writel(mask, bar_base + PCI_BASE_ADDRESS_0); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 137 | break; |
| 138 | case 1: |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 139 | writel(mask, bar_base + PCI_BASE_ADDRESS_1); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 140 | break; |
| 141 | case 2: |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 142 | writel(mask, bar_base + PCI_BASE_ADDRESS_2); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 143 | writel(0, bar_base + PCI_BASE_ADDRESS_3); |
| 144 | break; |
| 145 | case 4: |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 146 | writel(mask, bar_base + PCI_BASE_ADDRESS_4); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 147 | writel(0, bar_base + PCI_BASE_ADDRESS_5); |
| 148 | break; |
| 149 | default: |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | static void ls_pcie_ep_setup_bars(void *bar_base) |
| 155 | { |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 156 | /* BAR0 - 32bit - MEM */ |
| 157 | ls_pcie_ep_setup_bar(bar_base, 0, PCIE_BAR0_SIZE); |
| 158 | /* BAR1 - 32bit - MEM*/ |
| 159 | ls_pcie_ep_setup_bar(bar_base, 1, PCIE_BAR1_SIZE); |
| 160 | /* BAR2 - 64bit - MEM */ |
| 161 | ls_pcie_ep_setup_bar(bar_base, 2, PCIE_BAR2_SIZE); |
| 162 | /* BAR4 - 64bit - MEM */ |
| 163 | ls_pcie_ep_setup_bar(bar_base, 4, PCIE_BAR4_SIZE); |
| 164 | } |
| 165 | |
| 166 | static void ls_pcie_ep_setup_vf_bars(void *bar_base) |
| 167 | { |
| 168 | /* VF BAR0 MASK register at offset 0x19c*/ |
| 169 | bar_base += PCIE_SRIOV_VFBAR0 - PCI_BASE_ADDRESS_0; |
| 170 | |
| 171 | /* VF-BAR0 - 32bit - MEM */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 172 | ls_pcie_ep_setup_bar(bar_base, 0, PCIE_BAR0_SIZE); |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 173 | /* VF-BAR1 - 32bit - MEM*/ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 174 | ls_pcie_ep_setup_bar(bar_base, 1, PCIE_BAR1_SIZE); |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 175 | /* VF-BAR2 - 64bit - MEM */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 176 | ls_pcie_ep_setup_bar(bar_base, 2, PCIE_BAR2_SIZE); |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 177 | /* VF-BAR4 - 64bit - MEM */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 178 | ls_pcie_ep_setup_bar(bar_base, 4, PCIE_BAR4_SIZE); |
| 179 | } |
| 180 | |
| 181 | static void ls_pcie_setup_ep(struct ls_pcie_ep *pcie_ep) |
| 182 | { |
| 183 | u32 sriov; |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 184 | u32 pf, vf; |
| 185 | void *bar_base = NULL; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 186 | struct ls_pcie *pcie = pcie_ep->pcie; |
| 187 | |
| 188 | sriov = readl(pcie->dbi + PCIE_SRIOV); |
| 189 | if (PCI_EXT_CAP_ID(sriov) == PCI_EXT_CAP_ID_SRIOV) { |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 190 | pcie_ep->sriov_flag = 1; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 191 | for (pf = 0; pf < PCIE_PF_NUM; pf++) { |
Xiaowei Bao | 06a329a | 2020-07-09 23:31:37 +0800 | [diff] [blame] | 192 | /* |
| 193 | * The VF_BARn_REG register's Prefetchable and Type bit |
| 194 | * fields are overwritten by a write to VF's BAR Mask |
| 195 | * register. Before writing to the VF_BARn_MASK_REG |
| 196 | * register, write 0b to the PCIE_MISC_CONTROL_1_OFF |
| 197 | * register. |
| 198 | */ |
| 199 | writel(0, pcie->dbi + PCIE_MISC_CONTROL_1_OFF); |
| 200 | |
Xiaowei Bao | cdecb97 | 2020-07-09 23:31:38 +0800 | [diff] [blame] | 201 | bar_base = pcie->dbi + |
Xiaowei Bao | 4a602b5 | 2020-07-09 23:31:41 +0800 | [diff] [blame] | 202 | PCIE_MASK_OFFSET(pcie_ep->cfg2_flag, pf, |
| 203 | pcie_ep->pf1_offset); |
Xiaowei Bao | cdecb97 | 2020-07-09 23:31:38 +0800 | [diff] [blame] | 204 | |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 205 | if (pcie_ep->cfg2_flag) { |
Xiaowei Bao | cdecb97 | 2020-07-09 23:31:38 +0800 | [diff] [blame] | 206 | ctrl_writel(pcie, |
| 207 | PCIE_LCTRL0_VAL(pf, 0), |
| 208 | PCIE_PF_VF_CTRL); |
| 209 | ls_pcie_ep_setup_bars(bar_base); |
| 210 | |
| 211 | for (vf = 1; vf <= PCIE_VF_NUM; vf++) { |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 212 | ctrl_writel(pcie, |
| 213 | PCIE_LCTRL0_VAL(pf, vf), |
| 214 | PCIE_PF_VF_CTRL); |
Xiaowei Bao | cdecb97 | 2020-07-09 23:31:38 +0800 | [diff] [blame] | 215 | ls_pcie_ep_setup_vf_bars(bar_base); |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 216 | } |
Xiaowei Bao | cdecb97 | 2020-07-09 23:31:38 +0800 | [diff] [blame] | 217 | } else { |
| 218 | ls_pcie_ep_setup_bars(bar_base); |
| 219 | ls_pcie_ep_setup_vf_bars(bar_base); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 220 | } |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 221 | |
| 222 | ls_pcie_ep_setup_atu(pcie_ep, pf); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 223 | } |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 224 | |
| 225 | if (pcie_ep->cfg2_flag) /* Disable CFG2 */ |
| 226 | ctrl_writel(pcie, 0, PCIE_PF_VF_CTRL); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 227 | } else { |
| 228 | ls_pcie_ep_setup_bars(pcie->dbi + PCIE_NO_SRIOV_BAR_BASE); |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 229 | ls_pcie_ep_setup_atu(pcie_ep, 0); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 230 | } |
| 231 | |
Xiaowei Bao | bb3f713 | 2020-07-09 23:31:40 +0800 | [diff] [blame] | 232 | ls_pcie_dump_atu(pcie, PCIE_ATU_REGION_NUM_SRIOV, |
| 233 | PCIE_ATU_REGION_INBOUND); |
| 234 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 235 | ls_pcie_ep_enable_cfg(pcie_ep); |
| 236 | } |
| 237 | |
| 238 | static int ls_pcie_ep_probe(struct udevice *dev) |
| 239 | { |
| 240 | struct ls_pcie_ep *pcie_ep = dev_get_priv(dev); |
| 241 | struct ls_pcie *pcie; |
| 242 | u16 link_sta; |
| 243 | int ret; |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 244 | u32 svr; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 245 | |
| 246 | pcie = devm_kmalloc(dev, sizeof(*pcie), GFP_KERNEL); |
| 247 | if (!pcie) |
| 248 | return -ENOMEM; |
| 249 | |
| 250 | pcie_ep->pcie = pcie; |
| 251 | |
| 252 | pcie->dbi = (void __iomem *)devfdt_get_addr_index(dev, 0); |
| 253 | if (!pcie->dbi) |
| 254 | return -ENOMEM; |
| 255 | |
| 256 | pcie->ctrl = (void __iomem *)devfdt_get_addr_index(dev, 1); |
| 257 | if (!pcie->ctrl) |
| 258 | return -ENOMEM; |
| 259 | |
| 260 | ret = fdt_get_named_resource(gd->fdt_blob, dev_of_offset(dev), |
| 261 | "reg", "reg-names", |
| 262 | "addr_space", &pcie_ep->addr_res); |
| 263 | if (ret) { |
| 264 | printf("%s: resource \"addr_space\" not found\n", dev->name); |
| 265 | return ret; |
| 266 | } |
| 267 | |
| 268 | pcie->idx = ((unsigned long)pcie->dbi - PCIE_SYS_BASE_ADDR) / |
| 269 | PCIE_CCSR_SIZE; |
| 270 | |
| 271 | pcie->big_endian = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev), |
| 272 | "big-endian"); |
| 273 | |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 274 | svr = SVR_SOC_VER(get_svr()); |
| 275 | |
Xiaowei Bao | 4a602b5 | 2020-07-09 23:31:41 +0800 | [diff] [blame] | 276 | if (svr == SVR_LX2160A) |
| 277 | pcie_ep->pf1_offset = LX2160_PCIE_PF1_OFFSET; |
| 278 | else |
| 279 | pcie_ep->pf1_offset = LS_PCIE_PF1_OFFSET; |
| 280 | |
Xiaowei Bao | b4d63b0 | 2020-07-09 23:31:36 +0800 | [diff] [blame] | 281 | if (svr == SVR_LS2080A || svr == SVR_LS2085A) |
| 282 | pcie_ep->cfg2_flag = 1; |
| 283 | else |
| 284 | pcie_ep->cfg2_flag = 0; |
| 285 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 286 | pcie->mode = readb(pcie->dbi + PCI_HEADER_TYPE) & 0x7f; |
| 287 | if (pcie->mode != PCI_HEADER_TYPE_NORMAL) |
| 288 | return 0; |
| 289 | |
| 290 | pcie_ep->max_functions = fdtdec_get_int(gd->fdt_blob, |
| 291 | dev_of_offset(dev), |
| 292 | "max-functions", 1); |
| 293 | pcie_ep->num_ib_wins = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), |
| 294 | "num-ib-windows", 8); |
| 295 | pcie_ep->num_ob_wins = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), |
| 296 | "num-ob-windows", 8); |
| 297 | |
Wasim Khan | 8b3d2d2 | 2020-09-28 16:26:04 +0530 | [diff] [blame] | 298 | printf("PCIe%u: %s %s", PCIE_SRDS_PRTCL(pcie->idx), dev->name, |
| 299 | "Endpoint"); |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 300 | ls_pcie_setup_ep(pcie_ep); |
| 301 | |
| 302 | if (!ls_pcie_link_up(pcie)) { |
| 303 | /* Let the user know there's no PCIe link */ |
| 304 | printf(": no link\n"); |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | /* Print the negotiated PCIe link width */ |
| 309 | link_sta = readw(pcie->dbi + PCIE_LINK_STA); |
| 310 | printf(": x%d gen%d\n", (link_sta & PCIE_LINK_WIDTH_MASK) >> 4, |
| 311 | link_sta & PCIE_LINK_SPEED_MASK); |
| 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | static int ls_pcie_ep_remove(struct udevice *dev) |
| 317 | { |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | const struct udevice_id ls_pcie_ep_ids[] = { |
| 322 | { .compatible = "fsl,ls-pcie-ep" }, |
| 323 | { } |
| 324 | }; |
| 325 | |
| 326 | U_BOOT_DRIVER(pci_layerscape_ep) = { |
| 327 | .name = "pci_layerscape_ep", |
| 328 | .id = UCLASS_PCI_EP, |
| 329 | .of_match = ls_pcie_ep_ids, |
| 330 | .ops = &ls_pcie_ep_ops, |
| 331 | .probe = ls_pcie_ep_probe, |
| 332 | .remove = ls_pcie_ep_remove, |
| 333 | .priv_auto_alloc_size = sizeof(struct ls_pcie_ep), |
| 334 | }; |