Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 2 | /* |
Wasim Khan | 54e44ef | 2020-01-06 12:05:57 +0000 | [diff] [blame] | 3 | * Copyright 2017-2020 NXP |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 4 | * Copyright 2014-2015 Freescale Semiconductor, Inc. |
| 5 | * Layerscape PCIe driver |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Simon Glass | e4f6107 | 2020-07-19 10:15:49 -0600 | [diff] [blame] | 9 | #include <dm.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 12 | #include <pci.h> |
| 13 | #include <asm/arch/fsl_serdes.h> |
| 14 | #include <asm/io.h> |
| 15 | #include <errno.h> |
| 16 | #ifdef CONFIG_OF_BOARD_SETUP |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 17 | #include <linux/libfdt.h> |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 18 | #include <fdt_support.h> |
Simon Glass | 243182c | 2017-05-17 08:23:06 -0600 | [diff] [blame] | 19 | #ifdef CONFIG_ARM |
| 20 | #include <asm/arch/clock.h> |
| 21 | #endif |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 22 | #include "pcie_layerscape.h" |
Wasim Khan | 54e44ef | 2020-01-06 12:05:57 +0000 | [diff] [blame] | 23 | #include "pcie_layerscape_fixup_common.h" |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 24 | |
Bharat Bhushan | 36e36be | 2017-03-22 12:06:30 +0530 | [diff] [blame] | 25 | #if defined(CONFIG_FSL_LSCH3) || defined(CONFIG_FSL_LSCH2) |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 26 | /* |
| 27 | * Return next available LUT index. |
| 28 | */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 29 | static int ls_pcie_next_lut_index(struct ls_pcie_rc *pcie_rc) |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 30 | { |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 31 | if (pcie_rc->next_lut_index < PCIE_LUT_ENTRY_COUNT) |
| 32 | return pcie_rc->next_lut_index++; |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 33 | else |
| 34 | return -ENOSPC; /* LUT is full */ |
| 35 | } |
| 36 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 37 | static void lut_writel(struct ls_pcie_rc *pcie_rc, unsigned int value, |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 38 | unsigned int offset) |
| 39 | { |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 40 | struct ls_pcie *pcie = pcie_rc->pcie; |
| 41 | |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 42 | if (pcie->big_endian) |
| 43 | out_be32(pcie->lut + offset, value); |
| 44 | else |
| 45 | out_le32(pcie->lut + offset, value); |
| 46 | } |
| 47 | |
| 48 | /* |
| 49 | * Program a single LUT entry |
| 50 | */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 51 | static void ls_pcie_lut_set_mapping(struct ls_pcie_rc *pcie_rc, int index, |
| 52 | u32 devid, u32 streamid) |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 53 | { |
| 54 | /* leave mask as all zeroes, want to match all bits */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 55 | lut_writel(pcie_rc, devid << 16, PCIE_LUT_UDR(index)); |
| 56 | lut_writel(pcie_rc, streamid | PCIE_LUT_ENABLE, PCIE_LUT_LDR(index)); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | /* |
| 60 | * An msi-map is a property to be added to the pci controller |
| 61 | * node. It is a table, where each entry consists of 4 fields |
| 62 | * e.g.: |
| 63 | * |
| 64 | * msi-map = <[devid] [phandle-to-msi-ctrl] [stream-id] [count] |
| 65 | * [devid] [phandle-to-msi-ctrl] [stream-id] [count]>; |
| 66 | */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 67 | static void fdt_pcie_set_msi_map_entry_ls(void *blob, |
| 68 | struct ls_pcie_rc *pcie_rc, |
Wasim Khan | 8cb089e | 2019-11-15 09:23:35 +0000 | [diff] [blame] | 69 | u32 devid, u32 streamid) |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 70 | { |
| 71 | u32 *prop; |
| 72 | u32 phandle; |
| 73 | int nodeoffset; |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 74 | uint svr; |
| 75 | char *compat = NULL; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 76 | struct ls_pcie *pcie = pcie_rc->pcie; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 77 | |
| 78 | /* find pci controller node */ |
| 79 | nodeoffset = fdt_node_offset_by_compat_reg(blob, "fsl,ls-pcie", |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 80 | pcie_rc->dbi_res.start); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 81 | if (nodeoffset < 0) { |
Hou Zhiqiang | d553bf2 | 2016-12-13 14:54:24 +0800 | [diff] [blame] | 82 | #ifdef CONFIG_FSL_PCIE_COMPAT /* Compatible with older version of dts node */ |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 83 | svr = (get_svr() >> SVR_VAR_PER_SHIFT) & 0xFFFFFE; |
| 84 | if (svr == SVR_LS2088A || svr == SVR_LS2084A || |
Priyanka Jain | 2b36178 | 2017-04-27 15:08:06 +0530 | [diff] [blame] | 85 | svr == SVR_LS2048A || svr == SVR_LS2044A || |
| 86 | svr == SVR_LS2081A || svr == SVR_LS2041A) |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 87 | compat = "fsl,ls2088a-pcie"; |
| 88 | else |
| 89 | compat = CONFIG_FSL_PCIE_COMPAT; |
| 90 | if (compat) |
| 91 | nodeoffset = fdt_node_offset_by_compat_reg(blob, |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 92 | compat, pcie_rc->dbi_res.start); |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 93 | #endif |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 94 | if (nodeoffset < 0) |
| 95 | return; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | /* get phandle to MSI controller */ |
| 99 | prop = (u32 *)fdt_getprop(blob, nodeoffset, "msi-parent", 0); |
| 100 | if (prop == NULL) { |
| 101 | debug("\n%s: ERROR: missing msi-parent: PCIe%d\n", |
| 102 | __func__, pcie->idx); |
| 103 | return; |
| 104 | } |
| 105 | phandle = fdt32_to_cpu(*prop); |
| 106 | |
| 107 | /* set one msi-map row */ |
| 108 | fdt_appendprop_u32(blob, nodeoffset, "msi-map", devid); |
| 109 | fdt_appendprop_u32(blob, nodeoffset, "msi-map", phandle); |
| 110 | fdt_appendprop_u32(blob, nodeoffset, "msi-map", streamid); |
| 111 | fdt_appendprop_u32(blob, nodeoffset, "msi-map", 1); |
| 112 | } |
| 113 | |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 114 | /* |
| 115 | * An iommu-map is a property to be added to the pci controller |
| 116 | * node. It is a table, where each entry consists of 4 fields |
| 117 | * e.g.: |
| 118 | * |
| 119 | * iommu-map = <[devid] [phandle-to-iommu-ctrl] [stream-id] [count] |
| 120 | * [devid] [phandle-to-iommu-ctrl] [stream-id] [count]>; |
| 121 | */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 122 | static void fdt_pcie_set_iommu_map_entry_ls(void *blob, |
| 123 | struct ls_pcie_rc *pcie_rc, |
Wasim Khan | 8cb089e | 2019-11-15 09:23:35 +0000 | [diff] [blame] | 124 | u32 devid, u32 streamid) |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 125 | { |
| 126 | u32 *prop; |
| 127 | u32 iommu_map[4]; |
| 128 | int nodeoffset; |
| 129 | int lenp; |
Bharat Bhushan | 42aea35 | 2017-08-31 13:26:46 +0530 | [diff] [blame] | 130 | uint svr; |
| 131 | char *compat = NULL; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 132 | struct ls_pcie *pcie = pcie_rc->pcie; |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 133 | |
| 134 | /* find pci controller node */ |
| 135 | nodeoffset = fdt_node_offset_by_compat_reg(blob, "fsl,ls-pcie", |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 136 | pcie_rc->dbi_res.start); |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 137 | if (nodeoffset < 0) { |
| 138 | #ifdef CONFIG_FSL_PCIE_COMPAT /* Compatible with older version of dts node */ |
Bharat Bhushan | 42aea35 | 2017-08-31 13:26:46 +0530 | [diff] [blame] | 139 | svr = (get_svr() >> SVR_VAR_PER_SHIFT) & 0xFFFFFE; |
| 140 | if (svr == SVR_LS2088A || svr == SVR_LS2084A || |
| 141 | svr == SVR_LS2048A || svr == SVR_LS2044A || |
| 142 | svr == SVR_LS2081A || svr == SVR_LS2041A) |
| 143 | compat = "fsl,ls2088a-pcie"; |
| 144 | else |
| 145 | compat = CONFIG_FSL_PCIE_COMPAT; |
| 146 | |
| 147 | if (compat) |
| 148 | nodeoffset = fdt_node_offset_by_compat_reg(blob, |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 149 | compat, pcie_rc->dbi_res.start); |
Bharat Bhushan | 42aea35 | 2017-08-31 13:26:46 +0530 | [diff] [blame] | 150 | #endif |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 151 | if (nodeoffset < 0) |
| 152 | return; |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | /* get phandle to iommu controller */ |
| 156 | prop = fdt_getprop_w(blob, nodeoffset, "iommu-map", &lenp); |
| 157 | if (prop == NULL) { |
| 158 | debug("\n%s: ERROR: missing iommu-map: PCIe%d\n", |
| 159 | __func__, pcie->idx); |
| 160 | return; |
| 161 | } |
| 162 | |
| 163 | /* set iommu-map row */ |
| 164 | iommu_map[0] = cpu_to_fdt32(devid); |
| 165 | iommu_map[1] = *++prop; |
| 166 | iommu_map[2] = cpu_to_fdt32(streamid); |
| 167 | iommu_map[3] = cpu_to_fdt32(1); |
| 168 | |
| 169 | if (devid == 0) { |
| 170 | fdt_setprop_inplace(blob, nodeoffset, "iommu-map", |
| 171 | iommu_map, 16); |
| 172 | } else { |
| 173 | fdt_appendprop(blob, nodeoffset, "iommu-map", iommu_map, 16); |
| 174 | } |
| 175 | } |
| 176 | |
Wasim Khan | 8cb089e | 2019-11-15 09:23:35 +0000 | [diff] [blame] | 177 | static void fdt_fixup_pcie_ls(void *blob) |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 178 | { |
| 179 | struct udevice *dev, *bus; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 180 | struct ls_pcie_rc *pcie_rc; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 181 | int streamid; |
| 182 | int index; |
| 183 | pci_dev_t bdf; |
| 184 | |
| 185 | /* Scan all known buses */ |
| 186 | for (pci_find_first_device(&dev); |
| 187 | dev; |
| 188 | pci_find_next_device(&dev)) { |
| 189 | for (bus = dev; device_is_on_pci_bus(bus);) |
| 190 | bus = bus->parent; |
Michael Walle | 4f1b7b8 | 2020-08-04 00:16:33 +0200 | [diff] [blame] | 191 | |
| 192 | /* Only do the fixups for layerscape PCIe controllers */ |
| 193 | if (!device_is_compatible(bus, "fsl,ls-pcie") && |
| 194 | !device_is_compatible(bus, CONFIG_FSL_PCIE_COMPAT)) |
| 195 | continue; |
| 196 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 197 | pcie_rc = dev_get_priv(bus); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 198 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 199 | streamid = pcie_next_streamid(pcie_rc->stream_id_cur, |
| 200 | pcie_rc->pcie->idx); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 201 | if (streamid < 0) { |
| 202 | debug("ERROR: no stream ids free\n"); |
| 203 | continue; |
Wasim Khan | 9d3d230 | 2020-01-06 12:05:59 +0000 | [diff] [blame] | 204 | } else { |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 205 | pcie_rc->stream_id_cur++; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 206 | } |
| 207 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 208 | index = ls_pcie_next_lut_index(pcie_rc); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 209 | if (index < 0) { |
| 210 | debug("ERROR: no LUT indexes free\n"); |
| 211 | continue; |
| 212 | } |
| 213 | |
| 214 | /* the DT fixup must be relative to the hose first_busno */ |
| 215 | bdf = dm_pci_get_bdf(dev) - PCI_BDF(bus->seq, 0, 0); |
| 216 | /* map PCI b.d.f to streamID in LUT */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 217 | ls_pcie_lut_set_mapping(pcie_rc, index, bdf >> 8, |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 218 | streamid); |
| 219 | /* update msi-map in device tree */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 220 | fdt_pcie_set_msi_map_entry_ls(blob, pcie_rc, bdf >> 8, |
Wasim Khan | 8cb089e | 2019-11-15 09:23:35 +0000 | [diff] [blame] | 221 | streamid); |
Bharat Bhushan | 50514b9 | 2017-03-22 12:12:33 +0530 | [diff] [blame] | 222 | /* update iommu-map in device tree */ |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 223 | fdt_pcie_set_iommu_map_entry_ls(blob, pcie_rc, bdf >> 8, |
Wasim Khan | 8cb089e | 2019-11-15 09:23:35 +0000 | [diff] [blame] | 224 | streamid); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 225 | } |
Wasim Khan | 70bec5c | 2020-01-06 12:06:00 +0000 | [diff] [blame] | 226 | pcie_board_fix_fdt(blob); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 227 | } |
| 228 | #endif |
| 229 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 230 | static void ft_pcie_rc_fix(void *blob, struct ls_pcie_rc *pcie_rc) |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 231 | { |
| 232 | int off; |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 233 | uint svr; |
| 234 | char *compat = NULL; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 235 | struct ls_pcie *pcie = pcie_rc->pcie; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 236 | |
| 237 | off = fdt_node_offset_by_compat_reg(blob, "fsl,ls-pcie", |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 238 | pcie_rc->dbi_res.start); |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 239 | if (off < 0) { |
Hou Zhiqiang | d553bf2 | 2016-12-13 14:54:24 +0800 | [diff] [blame] | 240 | #ifdef CONFIG_FSL_PCIE_COMPAT /* Compatible with older version of dts node */ |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 241 | svr = (get_svr() >> SVR_VAR_PER_SHIFT) & 0xFFFFFE; |
| 242 | if (svr == SVR_LS2088A || svr == SVR_LS2084A || |
Priyanka Jain | 2b36178 | 2017-04-27 15:08:06 +0530 | [diff] [blame] | 243 | svr == SVR_LS2048A || svr == SVR_LS2044A || |
| 244 | svr == SVR_LS2081A || svr == SVR_LS2041A) |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 245 | compat = "fsl,ls2088a-pcie"; |
| 246 | else |
| 247 | compat = CONFIG_FSL_PCIE_COMPAT; |
| 248 | if (compat) |
| 249 | off = fdt_node_offset_by_compat_reg(blob, |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 250 | compat, pcie_rc->dbi_res.start); |
Hou Zhiqiang | 8cd3f48 | 2017-03-03 12:35:10 +0800 | [diff] [blame] | 251 | #endif |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 252 | if (off < 0) |
| 253 | return; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 254 | } |
| 255 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 256 | if (pcie_rc->enabled && pcie->mode == PCI_HEADER_TYPE_BRIDGE) |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 257 | fdt_set_node_status(blob, off, FDT_STATUS_OKAY, 0); |
| 258 | else |
| 259 | fdt_set_node_status(blob, off, FDT_STATUS_DISABLED, 0); |
| 260 | } |
| 261 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 262 | static void ft_pcie_ep_fix(void *blob, struct ls_pcie_rc *pcie_rc) |
Xiaowei Bao | 8d7e2e8 | 2018-10-26 09:56:26 +0800 | [diff] [blame] | 263 | { |
| 264 | int off; |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 265 | struct ls_pcie *pcie = pcie_rc->pcie; |
Xiaowei Bao | 8d7e2e8 | 2018-10-26 09:56:26 +0800 | [diff] [blame] | 266 | |
Pankaj Bansal | 64d85a2 | 2019-11-30 13:14:10 +0000 | [diff] [blame] | 267 | off = fdt_node_offset_by_compat_reg(blob, CONFIG_FSL_PCIE_EP_COMPAT, |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 268 | pcie_rc->dbi_res.start); |
Xiaowei Bao | 8d7e2e8 | 2018-10-26 09:56:26 +0800 | [diff] [blame] | 269 | if (off < 0) |
| 270 | return; |
| 271 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 272 | if (pcie_rc->enabled && pcie->mode == PCI_HEADER_TYPE_NORMAL) |
Xiaowei Bao | 8d7e2e8 | 2018-10-26 09:56:26 +0800 | [diff] [blame] | 273 | fdt_set_node_status(blob, off, FDT_STATUS_OKAY, 0); |
| 274 | else |
| 275 | fdt_set_node_status(blob, off, FDT_STATUS_DISABLED, 0); |
| 276 | } |
| 277 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 278 | static void ft_pcie_ls_setup(void *blob, struct ls_pcie_rc *pcie_rc) |
Xiaowei Bao | 8d7e2e8 | 2018-10-26 09:56:26 +0800 | [diff] [blame] | 279 | { |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 280 | ft_pcie_ep_fix(blob, pcie_rc); |
| 281 | ft_pcie_rc_fix(blob, pcie_rc); |
Xiaowei Bao | 8d7e2e8 | 2018-10-26 09:56:26 +0800 | [diff] [blame] | 282 | } |
| 283 | |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 284 | /* Fixup Kernel DT for PCIe */ |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 285 | void ft_pci_setup_ls(void *blob, struct bd_info *bd) |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 286 | { |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 287 | struct ls_pcie_rc *pcie_rc; |
Minghuan Lian | c106784 | 2016-12-13 14:54:17 +0800 | [diff] [blame] | 288 | |
Xiaowei Bao | 13b277f | 2020-07-09 23:31:33 +0800 | [diff] [blame] | 289 | list_for_each_entry(pcie_rc, &ls_pcie_list, list) |
| 290 | ft_pcie_ls_setup(blob, pcie_rc); |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 291 | |
Bharat Bhushan | 36e36be | 2017-03-22 12:06:30 +0530 | [diff] [blame] | 292 | #if defined(CONFIG_FSL_LSCH3) || defined(CONFIG_FSL_LSCH2) |
Wasim Khan | 8cb089e | 2019-11-15 09:23:35 +0000 | [diff] [blame] | 293 | fdt_fixup_pcie_ls(blob); |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 294 | #endif |
| 295 | } |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 296 | |
| 297 | #else /* !CONFIG_OF_BOARD_SETUP */ |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 298 | void ft_pci_setup_ls(void *blob, struct bd_info *bd) |
Hou Zhiqiang | 09716a7b | 2016-12-13 14:54:16 +0800 | [diff] [blame] | 299 | { |
| 300 | } |
| 301 | #endif |