Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 2 | /* |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 3 | * Copyright 2014-2015 Freescale Semiconductor, Inc. |
Florinel Iordache | a618a5a | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 4 | * Copyright 2020 NXP |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 85d6531 | 2019-12-28 10:44:58 -0700 | [diff] [blame] | 8 | #include <clock_legacy.h> |
Alexander Graf | 17b6593 | 2016-11-17 01:03:00 +0100 | [diff] [blame] | 9 | #include <efi_loader.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 11 | #include <asm/cache.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 12 | #include <linux/libfdt.h> |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 13 | #include <fdt_support.h> |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 14 | #include <phy.h> |
| 15 | #ifdef CONFIG_FSL_LSCH3 |
| 16 | #include <asm/arch/fdt.h> |
| 17 | #endif |
Yangbo Lu | d0e295d | 2015-03-20 19:28:31 -0700 | [diff] [blame] | 18 | #ifdef CONFIG_FSL_ESDHC |
| 19 | #include <fsl_esdhc.h> |
| 20 | #endif |
Qianyu Gong | 4026f66 | 2016-02-18 13:02:02 +0800 | [diff] [blame] | 21 | #ifdef CONFIG_SYS_DPAA_FMAN |
| 22 | #include <fsl_fman.h> |
| 23 | #endif |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 24 | #ifdef CONFIG_MP |
| 25 | #include <asm/arch/mp.h> |
| 26 | #endif |
Alex Porosanu | 16286bb | 2016-04-11 10:42:50 +0300 | [diff] [blame] | 27 | #include <fsl_sec.h> |
| 28 | #include <asm/arch-fsl-layerscape/soc.h> |
Michael Walle | 16fd24c | 2020-11-18 17:45:54 +0100 | [diff] [blame] | 29 | #if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) |
Hou Zhiqiang | 21c4d55 | 2016-06-28 20:18:15 +0800 | [diff] [blame] | 30 | #include <asm/armv8/sec_firmware.h> |
| 31 | #endif |
Ahmed Mansour | aa270b4 | 2017-12-15 16:01:00 -0500 | [diff] [blame] | 32 | #include <asm/arch/speed.h> |
| 33 | #include <fsl_qbman.h> |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 34 | |
Shaohui Xie | 0464326 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 35 | int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc) |
| 36 | { |
Florinel Iordache | a618a5a | 2020-03-16 15:35:59 +0200 | [diff] [blame] | 37 | const char *conn; |
| 38 | |
| 39 | /* Do NOT apply fixup for backplane modes specified in DT */ |
| 40 | if (phyc == PHY_INTERFACE_MODE_XGMII) { |
| 41 | conn = fdt_getprop(blob, offset, "phy-connection-type", NULL); |
| 42 | if (is_backplane_mode(conn)) |
| 43 | return 0; |
| 44 | } |
Shaohui Xie | 0464326 | 2015-10-26 19:47:54 +0800 | [diff] [blame] | 45 | return fdt_setprop_string(blob, offset, "phy-connection-type", |
| 46 | phy_string_for_interface(phyc)); |
| 47 | } |
| 48 | |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 49 | #ifdef CONFIG_MP |
| 50 | void ft_fixup_cpu(void *blob) |
| 51 | { |
| 52 | int off; |
| 53 | __maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr(); |
| 54 | fdt32_t *reg; |
| 55 | int addr_cells; |
Arnab Basu | 0cb1942 | 2015-01-06 13:18:41 -0800 | [diff] [blame] | 56 | u64 val, core_id; |
Wenbin song | ea19677 | 2017-12-04 12:18:29 +0800 | [diff] [blame] | 57 | u32 mask = cpu_pos_mask(); |
| 58 | int off_prev = -1; |
| 59 | |
| 60 | off = fdt_path_offset(blob, "/cpus"); |
| 61 | if (off < 0) { |
| 62 | puts("couldn't find /cpus node\n"); |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | fdt_support_default_count_cells(blob, off, &addr_cells, NULL); |
| 67 | |
| 68 | off = fdt_node_offset_by_prop_value(blob, off_prev, "device_type", |
| 69 | "cpu", 4); |
| 70 | while (off != -FDT_ERR_NOTFOUND) { |
| 71 | reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); |
| 72 | if (reg) { |
| 73 | core_id = fdt_read_number(reg, addr_cells); |
| 74 | if (!test_bit(id_to_core(core_id), &mask)) { |
| 75 | fdt_del_node(blob, off); |
| 76 | off = off_prev; |
| 77 | } |
| 78 | } |
| 79 | off_prev = off; |
| 80 | off = fdt_node_offset_by_prop_value(blob, off_prev, |
| 81 | "device_type", "cpu", 4); |
| 82 | } |
| 83 | |
Michael Walle | 16fd24c | 2020-11-18 17:45:54 +0100 | [diff] [blame] | 84 | #if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) && \ |
Hou Zhiqiang | 6be115d | 2017-01-16 17:31:48 +0800 | [diff] [blame] | 85 | defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) |
Hou Zhiqiang | 21c4d55 | 2016-06-28 20:18:15 +0800 | [diff] [blame] | 86 | int node; |
| 87 | u32 psci_ver; |
| 88 | |
| 89 | /* Check the psci version to determine if the psci is supported */ |
| 90 | psci_ver = sec_firmware_support_psci_version(); |
| 91 | if (psci_ver == 0xffffffff) { |
| 92 | /* remove psci DT node */ |
| 93 | node = fdt_path_offset(blob, "/psci"); |
| 94 | if (node >= 0) |
| 95 | goto remove_psci_node; |
| 96 | |
| 97 | node = fdt_node_offset_by_compatible(blob, -1, "arm,psci"); |
| 98 | if (node >= 0) |
| 99 | goto remove_psci_node; |
| 100 | |
| 101 | node = fdt_node_offset_by_compatible(blob, -1, "arm,psci-0.2"); |
| 102 | if (node >= 0) |
| 103 | goto remove_psci_node; |
| 104 | |
| 105 | node = fdt_node_offset_by_compatible(blob, -1, "arm,psci-1.0"); |
| 106 | if (node >= 0) |
| 107 | goto remove_psci_node; |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 108 | |
Hou Zhiqiang | 21c4d55 | 2016-06-28 20:18:15 +0800 | [diff] [blame] | 109 | remove_psci_node: |
| 110 | if (node >= 0) |
| 111 | fdt_del_node(blob, node); |
| 112 | } else { |
| 113 | return; |
| 114 | } |
| 115 | #endif |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 116 | off = fdt_path_offset(blob, "/cpus"); |
| 117 | if (off < 0) { |
| 118 | puts("couldn't find /cpus node\n"); |
| 119 | return; |
| 120 | } |
Simon Glass | bb7c01e | 2017-05-18 20:09:26 -0600 | [diff] [blame] | 121 | fdt_support_default_count_cells(blob, off, &addr_cells, NULL); |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 122 | |
| 123 | off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4); |
| 124 | while (off != -FDT_ERR_NOTFOUND) { |
| 125 | reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); |
| 126 | if (reg) { |
Simon Glass | bb7c01e | 2017-05-18 20:09:26 -0600 | [diff] [blame] | 127 | core_id = fdt_read_number(reg, addr_cells); |
Arnab Basu | 0cb1942 | 2015-01-06 13:18:41 -0800 | [diff] [blame] | 128 | if (core_id == 0 || (is_core_online(core_id))) { |
| 129 | val = spin_tbl_addr; |
| 130 | val += id_to_core(core_id) * |
| 131 | SPIN_TABLE_ELEM_SIZE; |
| 132 | val = cpu_to_fdt64(val); |
| 133 | fdt_setprop_string(blob, off, "enable-method", |
| 134 | "spin-table"); |
| 135 | fdt_setprop(blob, off, "cpu-release-addr", |
| 136 | &val, sizeof(val)); |
| 137 | } else { |
| 138 | debug("skipping offline core\n"); |
| 139 | } |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 140 | } else { |
| 141 | puts("Warning: found cpu node without reg property\n"); |
| 142 | } |
| 143 | off = fdt_node_offset_by_prop_value(blob, off, "device_type", |
| 144 | "cpu", 4); |
| 145 | } |
| 146 | |
Michael Walle | c251f5b | 2020-06-01 21:53:34 +0200 | [diff] [blame] | 147 | fdt_add_mem_rsv(blob, (uintptr_t)secondary_boot_code_start, |
| 148 | secondary_boot_code_size); |
Stephen Warren | d0de806 | 2018-08-30 15:43:43 -0600 | [diff] [blame] | 149 | #if CONFIG_IS_ENABLED(EFI_LOADER) |
Michael Walle | c251f5b | 2020-06-01 21:53:34 +0200 | [diff] [blame] | 150 | efi_add_memory_map((uintptr_t)secondary_boot_code_start, |
| 151 | secondary_boot_code_size, EFI_RESERVED_MEMORY_TYPE); |
Alexander Graf | 17b6593 | 2016-11-17 01:03:00 +0100 | [diff] [blame] | 152 | #endif |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 153 | } |
| 154 | #endif |
| 155 | |
Sriram Dash | f92c2cb | 2016-10-03 16:24:46 +0530 | [diff] [blame] | 156 | void fsl_fdt_disable_usb(void *blob) |
| 157 | { |
| 158 | int off; |
| 159 | /* |
| 160 | * SYSCLK is used as a reference clock for USB. When the USB |
| 161 | * controller is used, SYSCLK must meet the additional requirement |
| 162 | * of 100 MHz. |
| 163 | */ |
| 164 | if (CONFIG_SYS_CLK_FREQ != 100000000) { |
| 165 | off = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3"); |
| 166 | while (off != -FDT_ERR_NOTFOUND) { |
| 167 | fdt_status_disabled(blob, off); |
| 168 | off = fdt_node_offset_by_compatible(blob, off, |
| 169 | "snps,dwc3"); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
Wenbin Song | a8f57a9 | 2017-01-17 18:31:15 +0800 | [diff] [blame] | 174 | #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN |
| 175 | static void fdt_fixup_gic(void *blob) |
| 176 | { |
| 177 | int offset, err; |
| 178 | u64 reg[8]; |
| 179 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 180 | unsigned int val; |
| 181 | struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR; |
| 182 | int align_64k = 0; |
| 183 | |
| 184 | val = gur_in32(&gur->svr); |
| 185 | |
Wenbin song | 5d8a61c | 2017-12-04 12:18:28 +0800 | [diff] [blame] | 186 | if (!IS_SVR_DEV(val, SVR_DEV(SVR_LS1043A))) { |
Wenbin Song | a8f57a9 | 2017-01-17 18:31:15 +0800 | [diff] [blame] | 187 | align_64k = 1; |
| 188 | } else if (SVR_REV(val) != REV1_0) { |
| 189 | val = scfg_in32(&scfg->gic_align) & (0x01 << GIC_ADDR_BIT); |
| 190 | if (!val) |
| 191 | align_64k = 1; |
| 192 | } |
| 193 | |
| 194 | offset = fdt_subnode_offset(blob, 0, "interrupt-controller@1400000"); |
| 195 | if (offset < 0) { |
| 196 | printf("WARNING: fdt_subnode_offset can't find node %s: %s\n", |
| 197 | "interrupt-controller@1400000", fdt_strerror(offset)); |
| 198 | return; |
| 199 | } |
| 200 | |
| 201 | /* Fixup gic node align with 64K */ |
| 202 | if (align_64k) { |
| 203 | reg[0] = cpu_to_fdt64(GICD_BASE_64K); |
| 204 | reg[1] = cpu_to_fdt64(GICD_SIZE_64K); |
| 205 | reg[2] = cpu_to_fdt64(GICC_BASE_64K); |
| 206 | reg[3] = cpu_to_fdt64(GICC_SIZE_64K); |
| 207 | reg[4] = cpu_to_fdt64(GICH_BASE_64K); |
| 208 | reg[5] = cpu_to_fdt64(GICH_SIZE_64K); |
| 209 | reg[6] = cpu_to_fdt64(GICV_BASE_64K); |
| 210 | reg[7] = cpu_to_fdt64(GICV_SIZE_64K); |
| 211 | } else { |
| 212 | /* Fixup gic node align with default */ |
| 213 | reg[0] = cpu_to_fdt64(GICD_BASE); |
| 214 | reg[1] = cpu_to_fdt64(GICD_SIZE); |
| 215 | reg[2] = cpu_to_fdt64(GICC_BASE); |
| 216 | reg[3] = cpu_to_fdt64(GICC_SIZE); |
| 217 | reg[4] = cpu_to_fdt64(GICH_BASE); |
| 218 | reg[5] = cpu_to_fdt64(GICH_SIZE); |
| 219 | reg[6] = cpu_to_fdt64(GICV_BASE); |
| 220 | reg[7] = cpu_to_fdt64(GICV_SIZE); |
| 221 | } |
| 222 | |
| 223 | err = fdt_setprop(blob, offset, "reg", reg, sizeof(reg)); |
| 224 | if (err < 0) { |
| 225 | printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", |
| 226 | "reg", "interrupt-controller@1400000", |
| 227 | fdt_strerror(err)); |
| 228 | return; |
| 229 | } |
| 230 | |
| 231 | return; |
| 232 | } |
| 233 | #endif |
| 234 | |
Wenbin Song | c6bc7c0 | 2017-01-17 18:31:16 +0800 | [diff] [blame] | 235 | #ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI |
| 236 | static int _fdt_fixup_msi_node(void *blob, const char *name, |
| 237 | int irq_0, int irq_1, int rev) |
| 238 | { |
| 239 | int err, offset, len; |
| 240 | u32 tmp[4][3]; |
| 241 | void *p; |
| 242 | |
| 243 | offset = fdt_path_offset(blob, name); |
| 244 | if (offset < 0) { |
| 245 | printf("WARNING: fdt_path_offset can't find path %s: %s\n", |
| 246 | name, fdt_strerror(offset)); |
| 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | /*fixup the property of interrupts*/ |
| 251 | |
| 252 | tmp[0][0] = cpu_to_fdt32(0x0); |
| 253 | tmp[0][1] = cpu_to_fdt32(irq_0); |
| 254 | tmp[0][2] = cpu_to_fdt32(0x4); |
| 255 | |
| 256 | if (rev > REV1_0) { |
| 257 | tmp[1][0] = cpu_to_fdt32(0x0); |
| 258 | tmp[1][1] = cpu_to_fdt32(irq_1); |
| 259 | tmp[1][2] = cpu_to_fdt32(0x4); |
| 260 | tmp[2][0] = cpu_to_fdt32(0x0); |
| 261 | tmp[2][1] = cpu_to_fdt32(irq_1 + 1); |
| 262 | tmp[2][2] = cpu_to_fdt32(0x4); |
| 263 | tmp[3][0] = cpu_to_fdt32(0x0); |
| 264 | tmp[3][1] = cpu_to_fdt32(irq_1 + 2); |
| 265 | tmp[3][2] = cpu_to_fdt32(0x4); |
| 266 | len = sizeof(tmp); |
| 267 | } else { |
| 268 | len = sizeof(tmp[0]); |
| 269 | } |
| 270 | |
| 271 | err = fdt_setprop(blob, offset, "interrupts", tmp, len); |
| 272 | if (err < 0) { |
| 273 | printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", |
| 274 | "interrupts", name, fdt_strerror(err)); |
| 275 | return 0; |
| 276 | } |
| 277 | |
| 278 | /*fixup the property of reg*/ |
| 279 | p = (char *)fdt_getprop(blob, offset, "reg", &len); |
| 280 | if (!p) { |
| 281 | printf("WARNING: fdt_getprop can't get %s from node %s\n", |
| 282 | "reg", name); |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | memcpy((char *)tmp, p, len); |
| 287 | |
| 288 | if (rev > REV1_0) |
| 289 | *((u32 *)tmp + 3) = cpu_to_fdt32(0x1000); |
| 290 | else |
| 291 | *((u32 *)tmp + 3) = cpu_to_fdt32(0x8); |
| 292 | |
| 293 | err = fdt_setprop(blob, offset, "reg", tmp, len); |
| 294 | if (err < 0) { |
| 295 | printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", |
| 296 | "reg", name, fdt_strerror(err)); |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | /*fixup the property of compatible*/ |
| 301 | if (rev > REV1_0) |
| 302 | err = fdt_setprop_string(blob, offset, "compatible", |
| 303 | "fsl,ls1043a-v1.1-msi"); |
| 304 | else |
| 305 | err = fdt_setprop_string(blob, offset, "compatible", |
| 306 | "fsl,ls1043a-msi"); |
| 307 | if (err < 0) { |
| 308 | printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", |
| 309 | "compatible", name, fdt_strerror(err)); |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | return 1; |
| 314 | } |
| 315 | |
| 316 | static int _fdt_fixup_pci_msi(void *blob, const char *name, int rev) |
| 317 | { |
| 318 | int offset, len, err; |
| 319 | void *p; |
| 320 | int val; |
| 321 | u32 tmp[4][8]; |
| 322 | |
| 323 | offset = fdt_path_offset(blob, name); |
| 324 | if (offset < 0) { |
| 325 | printf("WARNING: fdt_path_offset can't find path %s: %s\n", |
| 326 | name, fdt_strerror(offset)); |
| 327 | return 0; |
| 328 | } |
| 329 | |
| 330 | p = (char *)fdt_getprop(blob, offset, "interrupt-map", &len); |
| 331 | if (!p || len != sizeof(tmp)) { |
| 332 | printf("WARNING: fdt_getprop can't get %s from node %s\n", |
| 333 | "interrupt-map", name); |
| 334 | return 0; |
| 335 | } |
| 336 | |
| 337 | memcpy((char *)tmp, p, len); |
| 338 | |
| 339 | val = fdt32_to_cpu(tmp[0][6]); |
Hou Zhiqiang | 35e0e74 | 2018-12-20 06:31:21 +0000 | [diff] [blame] | 340 | if (rev == REV1_0) { |
Wenbin Song | c6bc7c0 | 2017-01-17 18:31:16 +0800 | [diff] [blame] | 341 | tmp[1][6] = cpu_to_fdt32(val + 1); |
| 342 | tmp[2][6] = cpu_to_fdt32(val + 2); |
| 343 | tmp[3][6] = cpu_to_fdt32(val + 3); |
| 344 | } else { |
| 345 | tmp[1][6] = cpu_to_fdt32(val); |
| 346 | tmp[2][6] = cpu_to_fdt32(val); |
| 347 | tmp[3][6] = cpu_to_fdt32(val); |
| 348 | } |
| 349 | |
| 350 | err = fdt_setprop(blob, offset, "interrupt-map", tmp, sizeof(tmp)); |
| 351 | if (err < 0) { |
| 352 | printf("WARNING: fdt_setprop can't set %s from node %s: %s.\n", |
| 353 | "interrupt-map", name, fdt_strerror(err)); |
| 354 | return 0; |
| 355 | } |
| 356 | return 1; |
| 357 | } |
| 358 | |
| 359 | /* Fixup msi node for ls1043a rev1.1*/ |
| 360 | |
| 361 | static void fdt_fixup_msi(void *blob) |
| 362 | { |
| 363 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
| 364 | unsigned int rev; |
| 365 | |
| 366 | rev = gur_in32(&gur->svr); |
| 367 | |
Wenbin song | 5d8a61c | 2017-12-04 12:18:28 +0800 | [diff] [blame] | 368 | if (!IS_SVR_DEV(rev, SVR_DEV(SVR_LS1043A))) |
Wenbin Song | c6bc7c0 | 2017-01-17 18:31:16 +0800 | [diff] [blame] | 369 | return; |
| 370 | |
| 371 | rev = SVR_REV(rev); |
| 372 | |
| 373 | _fdt_fixup_msi_node(blob, "/soc/msi-controller1@1571000", |
| 374 | 116, 111, rev); |
| 375 | _fdt_fixup_msi_node(blob, "/soc/msi-controller2@1572000", |
| 376 | 126, 121, rev); |
| 377 | _fdt_fixup_msi_node(blob, "/soc/msi-controller3@1573000", |
| 378 | 160, 155, rev); |
| 379 | |
| 380 | _fdt_fixup_pci_msi(blob, "/soc/pcie@3400000", rev); |
| 381 | _fdt_fixup_pci_msi(blob, "/soc/pcie@3500000", rev); |
| 382 | _fdt_fixup_pci_msi(blob, "/soc/pcie@3600000", rev); |
| 383 | } |
| 384 | #endif |
| 385 | |
Michael Walle | 16fd24c | 2020-11-18 17:45:54 +0100 | [diff] [blame] | 386 | #if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) |
Ruchika Gupta | db204d7 | 2017-08-16 15:58:10 +0530 | [diff] [blame] | 387 | /* Remove JR node used by SEC firmware */ |
| 388 | void fdt_fixup_remove_jr(void *blob) |
| 389 | { |
| 390 | int jr_node, addr_cells, len; |
| 391 | int crypto_node = fdt_path_offset(blob, "crypto"); |
| 392 | u64 jr_offset, used_jr; |
| 393 | fdt32_t *reg; |
| 394 | |
| 395 | used_jr = sec_firmware_used_jobring_offset(); |
| 396 | fdt_support_default_count_cells(blob, crypto_node, &addr_cells, NULL); |
| 397 | |
| 398 | jr_node = fdt_node_offset_by_compatible(blob, crypto_node, |
| 399 | "fsl,sec-v4.0-job-ring"); |
| 400 | |
| 401 | while (jr_node != -FDT_ERR_NOTFOUND) { |
| 402 | reg = (fdt32_t *)fdt_getprop(blob, jr_node, "reg", &len); |
Priyanka Singh | 15e25a4 | 2020-11-02 11:38:41 +0530 | [diff] [blame] | 403 | if (reg) { |
| 404 | jr_offset = fdt_read_number(reg, addr_cells); |
| 405 | if (jr_offset == used_jr) { |
| 406 | fdt_del_node(blob, jr_node); |
| 407 | break; |
| 408 | } |
Ruchika Gupta | db204d7 | 2017-08-16 15:58:10 +0530 | [diff] [blame] | 409 | } |
| 410 | jr_node = fdt_node_offset_by_compatible(blob, jr_node, |
| 411 | "fsl,sec-v4.0-job-ring"); |
| 412 | } |
| 413 | } |
| 414 | #endif |
| 415 | |
Yuantian Tang | 044719b | 2019-10-10 17:19:37 +0800 | [diff] [blame] | 416 | #ifdef CONFIG_ARCH_LS1028A |
| 417 | static void fdt_disable_multimedia(void *blob, unsigned int svr) |
| 418 | { |
| 419 | int off; |
| 420 | |
| 421 | if (IS_MULTIMEDIA_EN(svr)) |
| 422 | return; |
| 423 | |
| 424 | /* Disable eDP/LCD node */ |
| 425 | off = fdt_node_offset_by_compatible(blob, -1, "arm,mali-dp500"); |
| 426 | if (off != -FDT_ERR_NOTFOUND) |
| 427 | fdt_status_disabled(blob, off); |
| 428 | |
| 429 | /* Disable GPU node */ |
| 430 | off = fdt_node_offset_by_compatible(blob, -1, "fsl,ls1028a-gpu"); |
| 431 | if (off != -FDT_ERR_NOTFOUND) |
| 432 | fdt_status_disabled(blob, off); |
| 433 | } |
| 434 | #endif |
| 435 | |
Alex Marginean | 762a268 | 2019-11-27 17:19:32 +0200 | [diff] [blame] | 436 | #ifdef CONFIG_PCIE_ECAM_GENERIC |
| 437 | __weak void fdt_fixup_ecam(void *blob) |
| 438 | { |
| 439 | } |
| 440 | #endif |
| 441 | |
Michael Walle | 8a1bf73 | 2020-10-16 19:38:18 +0200 | [diff] [blame] | 442 | /* |
| 443 | * If it is a non-E part the crypto is disabled on the following SoCs: |
| 444 | * - LS1043A |
| 445 | * - LS1088A |
| 446 | * - LS2080A |
| 447 | * - LS2088A |
| 448 | * and their personalities. |
| 449 | * |
| 450 | * On all other SoCs just the export-controlled ciphers are disabled, that |
| 451 | * means that the following is still working: |
| 452 | * - hashing (using MDHA - message digest hash accelerator) |
| 453 | * - random number generation (using RNG4) |
| 454 | * - cyclic redundancy checking (using CRCA) |
| 455 | * - runtime integrity checker (RTIC) |
| 456 | * |
| 457 | * The linux driver will figure out what is available and what is not. |
| 458 | * Therefore, we just remove the crypto node on the SoCs which have no crypto |
| 459 | * support at all. |
| 460 | */ |
| 461 | static bool crypto_is_disabled(unsigned int svr) |
| 462 | { |
| 463 | if (IS_E_PROCESSOR(svr)) |
| 464 | return false; |
| 465 | |
| 466 | if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A))) |
| 467 | return true; |
| 468 | |
| 469 | if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1088A))) |
| 470 | return true; |
| 471 | |
| 472 | if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS2080A))) |
| 473 | return true; |
| 474 | |
| 475 | if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS2088A))) |
| 476 | return true; |
| 477 | |
| 478 | return false; |
| 479 | } |
| 480 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 481 | void ft_cpu_setup(void *blob, struct bd_info *bd) |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 482 | { |
Alex Porosanu | 16286bb | 2016-04-11 10:42:50 +0300 | [diff] [blame] | 483 | struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); |
Ruchika Gupta | db204d7 | 2017-08-16 15:58:10 +0530 | [diff] [blame] | 484 | unsigned int svr = gur_in32(&gur->svr); |
Alex Porosanu | 16286bb | 2016-04-11 10:42:50 +0300 | [diff] [blame] | 485 | |
| 486 | /* delete crypto node if not on an E-processor */ |
Michael Walle | 8a1bf73 | 2020-10-16 19:38:18 +0200 | [diff] [blame] | 487 | if (crypto_is_disabled(svr)) |
Alex Porosanu | 16286bb | 2016-04-11 10:42:50 +0300 | [diff] [blame] | 488 | fdt_fixup_crypto_node(blob, 0); |
| 489 | #if CONFIG_SYS_FSL_SEC_COMPAT >= 4 |
| 490 | else { |
| 491 | ccsr_sec_t __iomem *sec; |
| 492 | |
Michael Walle | 16fd24c | 2020-11-18 17:45:54 +0100 | [diff] [blame] | 493 | #if CONFIG_IS_ENABLED(ARMV8_SEC_FIRMWARE_SUPPORT) |
Ruchika Gupta | fc8e340 | 2018-04-12 16:24:35 +0530 | [diff] [blame] | 494 | fdt_fixup_remove_jr(blob); |
| 495 | fdt_fixup_kaslr(blob); |
Ruchika Gupta | db204d7 | 2017-08-16 15:58:10 +0530 | [diff] [blame] | 496 | #endif |
| 497 | |
Alex Porosanu | 16286bb | 2016-04-11 10:42:50 +0300 | [diff] [blame] | 498 | sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR; |
| 499 | fdt_fixup_crypto_node(blob, sec_in32(&sec->secvid_ms)); |
| 500 | } |
| 501 | #endif |
Alex Porosanu | 16286bb | 2016-04-11 10:42:50 +0300 | [diff] [blame] | 502 | |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 503 | #ifdef CONFIG_MP |
| 504 | ft_fixup_cpu(blob); |
| 505 | #endif |
Bhupesh Sharma | c771040 | 2015-01-06 13:18:44 -0800 | [diff] [blame] | 506 | |
| 507 | #ifdef CONFIG_SYS_NS16550 |
Scott Wood | 3e7fd6f | 2015-03-20 19:28:14 -0700 | [diff] [blame] | 508 | do_fixup_by_compat_u32(blob, "fsl,ns16550", |
Bhupesh Sharma | c771040 | 2015-01-06 13:18:44 -0800 | [diff] [blame] | 509 | "clock-frequency", CONFIG_SYS_NS16550_CLK, 1); |
| 510 | #endif |
Yangbo Lu | d0e295d | 2015-03-20 19:28:31 -0700 | [diff] [blame] | 511 | |
Yangbo Lu | 07d1a91 | 2017-04-10 15:04:11 +0800 | [diff] [blame] | 512 | do_fixup_by_path_u32(blob, "/sysclk", "clock-frequency", |
| 513 | CONFIG_SYS_CLK_FREQ, 1); |
Prabhakar Kushwaha | 53d1cdc | 2015-12-24 17:25:06 +0530 | [diff] [blame] | 514 | |
Hou Zhiqiang | 031bb87 | 2020-04-28 10:19:32 +0800 | [diff] [blame] | 515 | #ifdef CONFIG_GIC_V3_ITS |
| 516 | ls_gic_rd_tables_init(blob); |
| 517 | #endif |
| 518 | |
Hou Zhiqiang | 79d34ca | 2019-08-27 03:30:03 +0000 | [diff] [blame] | 519 | #if defined(CONFIG_PCIE_LAYERSCAPE) || defined(CONFIG_PCIE_LAYERSCAPE_GEN4) |
Prabhakar Kushwaha | 940a316 | 2015-05-28 14:53:59 +0530 | [diff] [blame] | 520 | ft_pci_setup(blob, bd); |
| 521 | #endif |
| 522 | |
Mingkai Hu | 0e58b51 | 2015-10-26 19:47:50 +0800 | [diff] [blame] | 523 | #ifdef CONFIG_FSL_ESDHC |
Yangbo Lu | d0e295d | 2015-03-20 19:28:31 -0700 | [diff] [blame] | 524 | fdt_fixup_esdhc(blob, bd); |
| 525 | #endif |
Stuart Yoder | eaea504 | 2015-07-02 11:29:04 +0530 | [diff] [blame] | 526 | |
Ahmed Mansour | aa270b4 | 2017-12-15 16:01:00 -0500 | [diff] [blame] | 527 | #ifdef CONFIG_SYS_DPAA_QBMAN |
| 528 | fdt_fixup_bportals(blob); |
| 529 | fdt_fixup_qportals(blob); |
| 530 | do_fixup_by_compat_u32(blob, "fsl,qman", |
| 531 | "clock-frequency", get_qman_freq(), 1); |
| 532 | #endif |
| 533 | |
Qianyu Gong | 4026f66 | 2016-02-18 13:02:02 +0800 | [diff] [blame] | 534 | #ifdef CONFIG_SYS_DPAA_FMAN |
| 535 | fdt_fixup_fman_firmware(blob); |
| 536 | #endif |
Ran Wang | 9b1d15e | 2017-08-28 10:40:33 +0800 | [diff] [blame] | 537 | #ifndef CONFIG_ARCH_LS1012A |
Sriram Dash | f92c2cb | 2016-10-03 16:24:46 +0530 | [diff] [blame] | 538 | fsl_fdt_disable_usb(blob); |
Yingxi Yu | 8a507da | 2017-03-16 15:18:32 +0800 | [diff] [blame] | 539 | #endif |
Wenbin Song | a8f57a9 | 2017-01-17 18:31:15 +0800 | [diff] [blame] | 540 | #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN |
| 541 | fdt_fixup_gic(blob); |
| 542 | #endif |
Wenbin Song | c6bc7c0 | 2017-01-17 18:31:16 +0800 | [diff] [blame] | 543 | #ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI |
| 544 | fdt_fixup_msi(blob); |
| 545 | #endif |
Yuantian Tang | 044719b | 2019-10-10 17:19:37 +0800 | [diff] [blame] | 546 | #ifdef CONFIG_ARCH_LS1028A |
| 547 | fdt_disable_multimedia(blob, svr); |
| 548 | #endif |
Alex Marginean | 762a268 | 2019-11-27 17:19:32 +0200 | [diff] [blame] | 549 | #ifdef CONFIG_PCIE_ECAM_GENERIC |
| 550 | fdt_fixup_ecam(blob); |
| 551 | #endif |
York Sun | 56cc3db | 2014-09-08 12:20:00 -0700 | [diff] [blame] | 552 | } |