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