183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+ 29f3183d2SMingkai Hu /* 39f3183d2SMingkai Hu * Copyright 2014-2015 Freescale Semiconductor, Inc. 49f3183d2SMingkai Hu */ 59f3183d2SMingkai Hu 69f3183d2SMingkai Hu #include <common.h> 75a37a2f0SAlexander Graf #include <efi_loader.h> 8b08c8c48SMasahiro Yamada #include <linux/libfdt.h> 99f3183d2SMingkai Hu #include <fdt_support.h> 109f3183d2SMingkai Hu #include <phy.h> 119f3183d2SMingkai Hu #ifdef CONFIG_FSL_LSCH3 129f3183d2SMingkai Hu #include <asm/arch/fdt.h> 139f3183d2SMingkai Hu #endif 149f3183d2SMingkai Hu #ifdef CONFIG_FSL_ESDHC 159f3183d2SMingkai Hu #include <fsl_esdhc.h> 169f3183d2SMingkai Hu #endif 170e52b6feSQianyu Gong #ifdef CONFIG_SYS_DPAA_FMAN 180e52b6feSQianyu Gong #include <fsl_fman.h> 190e52b6feSQianyu Gong #endif 209f3183d2SMingkai Hu #ifdef CONFIG_MP 219f3183d2SMingkai Hu #include <asm/arch/mp.h> 229f3183d2SMingkai Hu #endif 23f13c99c2SAlex Porosanu #include <fsl_sec.h> 24f13c99c2SAlex Porosanu #include <asm/arch-fsl-layerscape/soc.h> 25032d5bb4SHou Zhiqiang #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT 26032d5bb4SHou Zhiqiang #include <asm/armv8/sec_firmware.h> 27032d5bb4SHou Zhiqiang #endif 2844262327SAhmed Mansour #include <asm/arch/speed.h> 2944262327SAhmed Mansour #include <fsl_qbman.h> 309f3183d2SMingkai Hu 31e8297341SShaohui Xie int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc) 32e8297341SShaohui Xie { 33e8297341SShaohui Xie return fdt_setprop_string(blob, offset, "phy-connection-type", 34e8297341SShaohui Xie phy_string_for_interface(phyc)); 35e8297341SShaohui Xie } 36e8297341SShaohui Xie 379f3183d2SMingkai Hu #ifdef CONFIG_MP 389f3183d2SMingkai Hu void ft_fixup_cpu(void *blob) 399f3183d2SMingkai Hu { 409f3183d2SMingkai Hu int off; 419f3183d2SMingkai Hu __maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr(); 429f3183d2SMingkai Hu fdt32_t *reg; 439f3183d2SMingkai Hu int addr_cells; 449f3183d2SMingkai Hu u64 val, core_id; 459f3183d2SMingkai Hu size_t *boot_code_size = &(__secondary_boot_code_size); 4620c73051SWenbin song u32 mask = cpu_pos_mask(); 4720c73051SWenbin song int off_prev = -1; 4820c73051SWenbin song 4920c73051SWenbin song off = fdt_path_offset(blob, "/cpus"); 5020c73051SWenbin song if (off < 0) { 5120c73051SWenbin song puts("couldn't find /cpus node\n"); 5220c73051SWenbin song return; 5320c73051SWenbin song } 5420c73051SWenbin song 5520c73051SWenbin song fdt_support_default_count_cells(blob, off, &addr_cells, NULL); 5620c73051SWenbin song 5720c73051SWenbin song off = fdt_node_offset_by_prop_value(blob, off_prev, "device_type", 5820c73051SWenbin song "cpu", 4); 5920c73051SWenbin song while (off != -FDT_ERR_NOTFOUND) { 6020c73051SWenbin song reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); 6120c73051SWenbin song if (reg) { 6220c73051SWenbin song core_id = fdt_read_number(reg, addr_cells); 6320c73051SWenbin song if (!test_bit(id_to_core(core_id), &mask)) { 6420c73051SWenbin song fdt_del_node(blob, off); 6520c73051SWenbin song off = off_prev; 6620c73051SWenbin song } 6720c73051SWenbin song } 6820c73051SWenbin song off_prev = off; 6920c73051SWenbin song off = fdt_node_offset_by_prop_value(blob, off_prev, 7020c73051SWenbin song "device_type", "cpu", 4); 7120c73051SWenbin song } 7220c73051SWenbin song 732d16a1a6Smacro.wave.z@gmail.com #if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \ 74daa92644SHou Zhiqiang defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI) 75032d5bb4SHou Zhiqiang int node; 76032d5bb4SHou Zhiqiang u32 psci_ver; 779f3183d2SMingkai Hu 78032d5bb4SHou Zhiqiang /* Check the psci version to determine if the psci is supported */ 79032d5bb4SHou Zhiqiang psci_ver = sec_firmware_support_psci_version(); 80032d5bb4SHou Zhiqiang if (psci_ver == 0xffffffff) { 81032d5bb4SHou Zhiqiang /* remove psci DT node */ 82032d5bb4SHou Zhiqiang node = fdt_path_offset(blob, "/psci"); 83032d5bb4SHou Zhiqiang if (node >= 0) 84032d5bb4SHou Zhiqiang goto remove_psci_node; 85032d5bb4SHou Zhiqiang 86032d5bb4SHou Zhiqiang node = fdt_node_offset_by_compatible(blob, -1, "arm,psci"); 87032d5bb4SHou Zhiqiang if (node >= 0) 88032d5bb4SHou Zhiqiang goto remove_psci_node; 89032d5bb4SHou Zhiqiang 90032d5bb4SHou Zhiqiang node = fdt_node_offset_by_compatible(blob, -1, "arm,psci-0.2"); 91032d5bb4SHou Zhiqiang if (node >= 0) 92032d5bb4SHou Zhiqiang goto remove_psci_node; 93032d5bb4SHou Zhiqiang 94032d5bb4SHou Zhiqiang node = fdt_node_offset_by_compatible(blob, -1, "arm,psci-1.0"); 95032d5bb4SHou Zhiqiang if (node >= 0) 96032d5bb4SHou Zhiqiang goto remove_psci_node; 97032d5bb4SHou Zhiqiang 98032d5bb4SHou Zhiqiang remove_psci_node: 99032d5bb4SHou Zhiqiang if (node >= 0) 100032d5bb4SHou Zhiqiang fdt_del_node(blob, node); 101032d5bb4SHou Zhiqiang } else { 102032d5bb4SHou Zhiqiang return; 103032d5bb4SHou Zhiqiang } 104032d5bb4SHou Zhiqiang #endif 1059f3183d2SMingkai Hu off = fdt_path_offset(blob, "/cpus"); 1069f3183d2SMingkai Hu if (off < 0) { 1079f3183d2SMingkai Hu puts("couldn't find /cpus node\n"); 1089f3183d2SMingkai Hu return; 1099f3183d2SMingkai Hu } 110eed36609SSimon Glass fdt_support_default_count_cells(blob, off, &addr_cells, NULL); 1119f3183d2SMingkai Hu 1129f3183d2SMingkai Hu off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4); 1139f3183d2SMingkai Hu while (off != -FDT_ERR_NOTFOUND) { 1149f3183d2SMingkai Hu reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0); 1159f3183d2SMingkai Hu if (reg) { 116eed36609SSimon Glass core_id = fdt_read_number(reg, addr_cells); 1179f3183d2SMingkai Hu if (core_id == 0 || (is_core_online(core_id))) { 1189f3183d2SMingkai Hu val = spin_tbl_addr; 1199f3183d2SMingkai Hu val += id_to_core(core_id) * 1209f3183d2SMingkai Hu SPIN_TABLE_ELEM_SIZE; 1219f3183d2SMingkai Hu val = cpu_to_fdt64(val); 1229f3183d2SMingkai Hu fdt_setprop_string(blob, off, "enable-method", 1239f3183d2SMingkai Hu "spin-table"); 1249f3183d2SMingkai Hu fdt_setprop(blob, off, "cpu-release-addr", 1259f3183d2SMingkai Hu &val, sizeof(val)); 1269f3183d2SMingkai Hu } else { 1279f3183d2SMingkai Hu debug("skipping offline core\n"); 1289f3183d2SMingkai Hu } 1299f3183d2SMingkai Hu } else { 1309f3183d2SMingkai Hu puts("Warning: found cpu node without reg property\n"); 1319f3183d2SMingkai Hu } 1329f3183d2SMingkai Hu off = fdt_node_offset_by_prop_value(blob, off, "device_type", 1339f3183d2SMingkai Hu "cpu", 4); 1349f3183d2SMingkai Hu } 1359f3183d2SMingkai Hu 1369f3183d2SMingkai Hu fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code, 1379f3183d2SMingkai Hu *boot_code_size); 1389b5e6396SStephen Warren #if CONFIG_IS_ENABLED(EFI_LOADER) 1395a37a2f0SAlexander Graf efi_add_memory_map((uintptr_t)&secondary_boot_code, 1405a37a2f0SAlexander Graf ALIGN(*boot_code_size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT, 1415a37a2f0SAlexander Graf EFI_RESERVED_MEMORY_TYPE, false); 1425a37a2f0SAlexander Graf #endif 1439f3183d2SMingkai Hu } 1449f3183d2SMingkai Hu #endif 1459f3183d2SMingkai Hu 146c93db4f7SSriram Dash void fsl_fdt_disable_usb(void *blob) 147c93db4f7SSriram Dash { 148c93db4f7SSriram Dash int off; 149c93db4f7SSriram Dash /* 150c93db4f7SSriram Dash * SYSCLK is used as a reference clock for USB. When the USB 151c93db4f7SSriram Dash * controller is used, SYSCLK must meet the additional requirement 152c93db4f7SSriram Dash * of 100 MHz. 153c93db4f7SSriram Dash */ 154c93db4f7SSriram Dash if (CONFIG_SYS_CLK_FREQ != 100000000) { 155c93db4f7SSriram Dash off = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3"); 156c93db4f7SSriram Dash while (off != -FDT_ERR_NOTFOUND) { 157c93db4f7SSriram Dash fdt_status_disabled(blob, off); 158c93db4f7SSriram Dash off = fdt_node_offset_by_compatible(blob, off, 159c93db4f7SSriram Dash "snps,dwc3"); 160c93db4f7SSriram Dash } 161c93db4f7SSriram Dash } 162c93db4f7SSriram Dash } 163c93db4f7SSriram Dash 164fa18ed76SWenbin Song #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN 165fa18ed76SWenbin Song static void fdt_fixup_gic(void *blob) 166fa18ed76SWenbin Song { 167fa18ed76SWenbin Song int offset, err; 168fa18ed76SWenbin Song u64 reg[8]; 169fa18ed76SWenbin Song struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); 170fa18ed76SWenbin Song unsigned int val; 171fa18ed76SWenbin Song struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR; 172fa18ed76SWenbin Song int align_64k = 0; 173fa18ed76SWenbin Song 174fa18ed76SWenbin Song val = gur_in32(&gur->svr); 175fa18ed76SWenbin Song 176a8f33034SWenbin song if (!IS_SVR_DEV(val, SVR_DEV(SVR_LS1043A))) { 177fa18ed76SWenbin Song align_64k = 1; 178fa18ed76SWenbin Song } else if (SVR_REV(val) != REV1_0) { 179fa18ed76SWenbin Song val = scfg_in32(&scfg->gic_align) & (0x01 << GIC_ADDR_BIT); 180fa18ed76SWenbin Song if (!val) 181fa18ed76SWenbin Song align_64k = 1; 182fa18ed76SWenbin Song } 183fa18ed76SWenbin Song 184fa18ed76SWenbin Song offset = fdt_subnode_offset(blob, 0, "interrupt-controller@1400000"); 185fa18ed76SWenbin Song if (offset < 0) { 186fa18ed76SWenbin Song printf("WARNING: fdt_subnode_offset can't find node %s: %s\n", 187fa18ed76SWenbin Song "interrupt-controller@1400000", fdt_strerror(offset)); 188fa18ed76SWenbin Song return; 189fa18ed76SWenbin Song } 190fa18ed76SWenbin Song 191fa18ed76SWenbin Song /* Fixup gic node align with 64K */ 192fa18ed76SWenbin Song if (align_64k) { 193fa18ed76SWenbin Song reg[0] = cpu_to_fdt64(GICD_BASE_64K); 194fa18ed76SWenbin Song reg[1] = cpu_to_fdt64(GICD_SIZE_64K); 195fa18ed76SWenbin Song reg[2] = cpu_to_fdt64(GICC_BASE_64K); 196fa18ed76SWenbin Song reg[3] = cpu_to_fdt64(GICC_SIZE_64K); 197fa18ed76SWenbin Song reg[4] = cpu_to_fdt64(GICH_BASE_64K); 198fa18ed76SWenbin Song reg[5] = cpu_to_fdt64(GICH_SIZE_64K); 199fa18ed76SWenbin Song reg[6] = cpu_to_fdt64(GICV_BASE_64K); 200fa18ed76SWenbin Song reg[7] = cpu_to_fdt64(GICV_SIZE_64K); 201fa18ed76SWenbin Song } else { 202fa18ed76SWenbin Song /* Fixup gic node align with default */ 203fa18ed76SWenbin Song reg[0] = cpu_to_fdt64(GICD_BASE); 204fa18ed76SWenbin Song reg[1] = cpu_to_fdt64(GICD_SIZE); 205fa18ed76SWenbin Song reg[2] = cpu_to_fdt64(GICC_BASE); 206fa18ed76SWenbin Song reg[3] = cpu_to_fdt64(GICC_SIZE); 207fa18ed76SWenbin Song reg[4] = cpu_to_fdt64(GICH_BASE); 208fa18ed76SWenbin Song reg[5] = cpu_to_fdt64(GICH_SIZE); 209fa18ed76SWenbin Song reg[6] = cpu_to_fdt64(GICV_BASE); 210fa18ed76SWenbin Song reg[7] = cpu_to_fdt64(GICV_SIZE); 211fa18ed76SWenbin Song } 212fa18ed76SWenbin Song 213fa18ed76SWenbin Song err = fdt_setprop(blob, offset, "reg", reg, sizeof(reg)); 214fa18ed76SWenbin Song if (err < 0) { 215fa18ed76SWenbin Song printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", 216fa18ed76SWenbin Song "reg", "interrupt-controller@1400000", 217fa18ed76SWenbin Song fdt_strerror(err)); 218fa18ed76SWenbin Song return; 219fa18ed76SWenbin Song } 220fa18ed76SWenbin Song 221fa18ed76SWenbin Song return; 222fa18ed76SWenbin Song } 223fa18ed76SWenbin Song #endif 224fa18ed76SWenbin Song 2252ca84bf7SWenbin Song #ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI 2262ca84bf7SWenbin Song static int _fdt_fixup_msi_node(void *blob, const char *name, 2272ca84bf7SWenbin Song int irq_0, int irq_1, int rev) 2282ca84bf7SWenbin Song { 2292ca84bf7SWenbin Song int err, offset, len; 2302ca84bf7SWenbin Song u32 tmp[4][3]; 2312ca84bf7SWenbin Song void *p; 2322ca84bf7SWenbin Song 2332ca84bf7SWenbin Song offset = fdt_path_offset(blob, name); 2342ca84bf7SWenbin Song if (offset < 0) { 2352ca84bf7SWenbin Song printf("WARNING: fdt_path_offset can't find path %s: %s\n", 2362ca84bf7SWenbin Song name, fdt_strerror(offset)); 2372ca84bf7SWenbin Song return 0; 2382ca84bf7SWenbin Song } 2392ca84bf7SWenbin Song 2402ca84bf7SWenbin Song /*fixup the property of interrupts*/ 2412ca84bf7SWenbin Song 2422ca84bf7SWenbin Song tmp[0][0] = cpu_to_fdt32(0x0); 2432ca84bf7SWenbin Song tmp[0][1] = cpu_to_fdt32(irq_0); 2442ca84bf7SWenbin Song tmp[0][2] = cpu_to_fdt32(0x4); 2452ca84bf7SWenbin Song 2462ca84bf7SWenbin Song if (rev > REV1_0) { 2472ca84bf7SWenbin Song tmp[1][0] = cpu_to_fdt32(0x0); 2482ca84bf7SWenbin Song tmp[1][1] = cpu_to_fdt32(irq_1); 2492ca84bf7SWenbin Song tmp[1][2] = cpu_to_fdt32(0x4); 2502ca84bf7SWenbin Song tmp[2][0] = cpu_to_fdt32(0x0); 2512ca84bf7SWenbin Song tmp[2][1] = cpu_to_fdt32(irq_1 + 1); 2522ca84bf7SWenbin Song tmp[2][2] = cpu_to_fdt32(0x4); 2532ca84bf7SWenbin Song tmp[3][0] = cpu_to_fdt32(0x0); 2542ca84bf7SWenbin Song tmp[3][1] = cpu_to_fdt32(irq_1 + 2); 2552ca84bf7SWenbin Song tmp[3][2] = cpu_to_fdt32(0x4); 2562ca84bf7SWenbin Song len = sizeof(tmp); 2572ca84bf7SWenbin Song } else { 2582ca84bf7SWenbin Song len = sizeof(tmp[0]); 2592ca84bf7SWenbin Song } 2602ca84bf7SWenbin Song 2612ca84bf7SWenbin Song err = fdt_setprop(blob, offset, "interrupts", tmp, len); 2622ca84bf7SWenbin Song if (err < 0) { 2632ca84bf7SWenbin Song printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", 2642ca84bf7SWenbin Song "interrupts", name, fdt_strerror(err)); 2652ca84bf7SWenbin Song return 0; 2662ca84bf7SWenbin Song } 2672ca84bf7SWenbin Song 2682ca84bf7SWenbin Song /*fixup the property of reg*/ 2692ca84bf7SWenbin Song p = (char *)fdt_getprop(blob, offset, "reg", &len); 2702ca84bf7SWenbin Song if (!p) { 2712ca84bf7SWenbin Song printf("WARNING: fdt_getprop can't get %s from node %s\n", 2722ca84bf7SWenbin Song "reg", name); 2732ca84bf7SWenbin Song return 0; 2742ca84bf7SWenbin Song } 2752ca84bf7SWenbin Song 2762ca84bf7SWenbin Song memcpy((char *)tmp, p, len); 2772ca84bf7SWenbin Song 2782ca84bf7SWenbin Song if (rev > REV1_0) 2792ca84bf7SWenbin Song *((u32 *)tmp + 3) = cpu_to_fdt32(0x1000); 2802ca84bf7SWenbin Song else 2812ca84bf7SWenbin Song *((u32 *)tmp + 3) = cpu_to_fdt32(0x8); 2822ca84bf7SWenbin Song 2832ca84bf7SWenbin Song err = fdt_setprop(blob, offset, "reg", tmp, len); 2842ca84bf7SWenbin Song if (err < 0) { 2852ca84bf7SWenbin Song printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", 2862ca84bf7SWenbin Song "reg", name, fdt_strerror(err)); 2872ca84bf7SWenbin Song return 0; 2882ca84bf7SWenbin Song } 2892ca84bf7SWenbin Song 2902ca84bf7SWenbin Song /*fixup the property of compatible*/ 2912ca84bf7SWenbin Song if (rev > REV1_0) 2922ca84bf7SWenbin Song err = fdt_setprop_string(blob, offset, "compatible", 2932ca84bf7SWenbin Song "fsl,ls1043a-v1.1-msi"); 2942ca84bf7SWenbin Song else 2952ca84bf7SWenbin Song err = fdt_setprop_string(blob, offset, "compatible", 2962ca84bf7SWenbin Song "fsl,ls1043a-msi"); 2972ca84bf7SWenbin Song if (err < 0) { 2982ca84bf7SWenbin Song printf("WARNING: fdt_setprop can't set %s from node %s: %s\n", 2992ca84bf7SWenbin Song "compatible", name, fdt_strerror(err)); 3002ca84bf7SWenbin Song return 0; 3012ca84bf7SWenbin Song } 3022ca84bf7SWenbin Song 3032ca84bf7SWenbin Song return 1; 3042ca84bf7SWenbin Song } 3052ca84bf7SWenbin Song 3062ca84bf7SWenbin Song static int _fdt_fixup_pci_msi(void *blob, const char *name, int rev) 3072ca84bf7SWenbin Song { 3082ca84bf7SWenbin Song int offset, len, err; 3092ca84bf7SWenbin Song void *p; 3102ca84bf7SWenbin Song int val; 3112ca84bf7SWenbin Song u32 tmp[4][8]; 3122ca84bf7SWenbin Song 3132ca84bf7SWenbin Song offset = fdt_path_offset(blob, name); 3142ca84bf7SWenbin Song if (offset < 0) { 3152ca84bf7SWenbin Song printf("WARNING: fdt_path_offset can't find path %s: %s\n", 3162ca84bf7SWenbin Song name, fdt_strerror(offset)); 3172ca84bf7SWenbin Song return 0; 3182ca84bf7SWenbin Song } 3192ca84bf7SWenbin Song 3202ca84bf7SWenbin Song p = (char *)fdt_getprop(blob, offset, "interrupt-map", &len); 3212ca84bf7SWenbin Song if (!p || len != sizeof(tmp)) { 3222ca84bf7SWenbin Song printf("WARNING: fdt_getprop can't get %s from node %s\n", 3232ca84bf7SWenbin Song "interrupt-map", name); 3242ca84bf7SWenbin Song return 0; 3252ca84bf7SWenbin Song } 3262ca84bf7SWenbin Song 3272ca84bf7SWenbin Song memcpy((char *)tmp, p, len); 3282ca84bf7SWenbin Song 3292ca84bf7SWenbin Song val = fdt32_to_cpu(tmp[0][6]); 330*5b994e85SHou Zhiqiang if (rev == REV1_0) { 3312ca84bf7SWenbin Song tmp[1][6] = cpu_to_fdt32(val + 1); 3322ca84bf7SWenbin Song tmp[2][6] = cpu_to_fdt32(val + 2); 3332ca84bf7SWenbin Song tmp[3][6] = cpu_to_fdt32(val + 3); 3342ca84bf7SWenbin Song } else { 3352ca84bf7SWenbin Song tmp[1][6] = cpu_to_fdt32(val); 3362ca84bf7SWenbin Song tmp[2][6] = cpu_to_fdt32(val); 3372ca84bf7SWenbin Song tmp[3][6] = cpu_to_fdt32(val); 3382ca84bf7SWenbin Song } 3392ca84bf7SWenbin Song 3402ca84bf7SWenbin Song err = fdt_setprop(blob, offset, "interrupt-map", tmp, sizeof(tmp)); 3412ca84bf7SWenbin Song if (err < 0) { 3422ca84bf7SWenbin Song printf("WARNING: fdt_setprop can't set %s from node %s: %s.\n", 3432ca84bf7SWenbin Song "interrupt-map", name, fdt_strerror(err)); 3442ca84bf7SWenbin Song return 0; 3452ca84bf7SWenbin Song } 3462ca84bf7SWenbin Song return 1; 3472ca84bf7SWenbin Song } 3482ca84bf7SWenbin Song 3492ca84bf7SWenbin Song /* Fixup msi node for ls1043a rev1.1*/ 3502ca84bf7SWenbin Song 3512ca84bf7SWenbin Song static void fdt_fixup_msi(void *blob) 3522ca84bf7SWenbin Song { 3532ca84bf7SWenbin Song struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); 3542ca84bf7SWenbin Song unsigned int rev; 3552ca84bf7SWenbin Song 3562ca84bf7SWenbin Song rev = gur_in32(&gur->svr); 3572ca84bf7SWenbin Song 358a8f33034SWenbin song if (!IS_SVR_DEV(rev, SVR_DEV(SVR_LS1043A))) 3592ca84bf7SWenbin Song return; 3602ca84bf7SWenbin Song 3612ca84bf7SWenbin Song rev = SVR_REV(rev); 3622ca84bf7SWenbin Song 3632ca84bf7SWenbin Song _fdt_fixup_msi_node(blob, "/soc/msi-controller1@1571000", 3642ca84bf7SWenbin Song 116, 111, rev); 3652ca84bf7SWenbin Song _fdt_fixup_msi_node(blob, "/soc/msi-controller2@1572000", 3662ca84bf7SWenbin Song 126, 121, rev); 3672ca84bf7SWenbin Song _fdt_fixup_msi_node(blob, "/soc/msi-controller3@1573000", 3682ca84bf7SWenbin Song 160, 155, rev); 3692ca84bf7SWenbin Song 3702ca84bf7SWenbin Song _fdt_fixup_pci_msi(blob, "/soc/pcie@3400000", rev); 3712ca84bf7SWenbin Song _fdt_fixup_pci_msi(blob, "/soc/pcie@3500000", rev); 3722ca84bf7SWenbin Song _fdt_fixup_pci_msi(blob, "/soc/pcie@3600000", rev); 3732ca84bf7SWenbin Song } 3742ca84bf7SWenbin Song #endif 3752ca84bf7SWenbin Song 376a797f274SRuchika Gupta #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT 377a797f274SRuchika Gupta /* Remove JR node used by SEC firmware */ 378a797f274SRuchika Gupta void fdt_fixup_remove_jr(void *blob) 379a797f274SRuchika Gupta { 380a797f274SRuchika Gupta int jr_node, addr_cells, len; 381a797f274SRuchika Gupta int crypto_node = fdt_path_offset(blob, "crypto"); 382a797f274SRuchika Gupta u64 jr_offset, used_jr; 383a797f274SRuchika Gupta fdt32_t *reg; 384a797f274SRuchika Gupta 385a797f274SRuchika Gupta used_jr = sec_firmware_used_jobring_offset(); 386a797f274SRuchika Gupta fdt_support_default_count_cells(blob, crypto_node, &addr_cells, NULL); 387a797f274SRuchika Gupta 388a797f274SRuchika Gupta jr_node = fdt_node_offset_by_compatible(blob, crypto_node, 389a797f274SRuchika Gupta "fsl,sec-v4.0-job-ring"); 390a797f274SRuchika Gupta 391a797f274SRuchika Gupta while (jr_node != -FDT_ERR_NOTFOUND) { 392a797f274SRuchika Gupta reg = (fdt32_t *)fdt_getprop(blob, jr_node, "reg", &len); 393a797f274SRuchika Gupta jr_offset = fdt_read_number(reg, addr_cells); 394a797f274SRuchika Gupta if (jr_offset == used_jr) { 395a797f274SRuchika Gupta fdt_del_node(blob, jr_node); 396a797f274SRuchika Gupta break; 397a797f274SRuchika Gupta } 398a797f274SRuchika Gupta jr_node = fdt_node_offset_by_compatible(blob, jr_node, 399a797f274SRuchika Gupta "fsl,sec-v4.0-job-ring"); 400a797f274SRuchika Gupta } 401a797f274SRuchika Gupta } 402a797f274SRuchika Gupta #endif 403a797f274SRuchika Gupta 4049f3183d2SMingkai Hu void ft_cpu_setup(void *blob, bd_t *bd) 4059f3183d2SMingkai Hu { 406f13c99c2SAlex Porosanu struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR); 407a797f274SRuchika Gupta unsigned int svr = gur_in32(&gur->svr); 408f13c99c2SAlex Porosanu 409f13c99c2SAlex Porosanu /* delete crypto node if not on an E-processor */ 410f13c99c2SAlex Porosanu if (!IS_E_PROCESSOR(svr)) 411f13c99c2SAlex Porosanu fdt_fixup_crypto_node(blob, 0); 412f13c99c2SAlex Porosanu #if CONFIG_SYS_FSL_SEC_COMPAT >= 4 413f13c99c2SAlex Porosanu else { 414f13c99c2SAlex Porosanu ccsr_sec_t __iomem *sec; 415f13c99c2SAlex Porosanu 416a797f274SRuchika Gupta #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT 417a797f274SRuchika Gupta fdt_fixup_remove_jr(blob); 418b6bb93deSRuchika Gupta fdt_fixup_kaslr(blob); 419a797f274SRuchika Gupta #endif 420a797f274SRuchika Gupta 421f13c99c2SAlex Porosanu sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR; 422f13c99c2SAlex Porosanu fdt_fixup_crypto_node(blob, sec_in32(&sec->secvid_ms)); 423f13c99c2SAlex Porosanu } 424f13c99c2SAlex Porosanu #endif 425f13c99c2SAlex Porosanu 4269f3183d2SMingkai Hu #ifdef CONFIG_MP 4279f3183d2SMingkai Hu ft_fixup_cpu(blob); 4289f3183d2SMingkai Hu #endif 4299f3183d2SMingkai Hu 4309f3183d2SMingkai Hu #ifdef CONFIG_SYS_NS16550 4319f3183d2SMingkai Hu do_fixup_by_compat_u32(blob, "fsl,ns16550", 4329f3183d2SMingkai Hu "clock-frequency", CONFIG_SYS_NS16550_CLK, 1); 4339f3183d2SMingkai Hu #endif 4349f3183d2SMingkai Hu 4353d91f46cSYangbo Lu do_fixup_by_path_u32(blob, "/sysclk", "clock-frequency", 4363d91f46cSYangbo Lu CONFIG_SYS_CLK_FREQ, 1); 4376f14e257SPrabhakar Kushwaha 4389f3183d2SMingkai Hu #ifdef CONFIG_PCI 4399f3183d2SMingkai Hu ft_pci_setup(blob, bd); 4409f3183d2SMingkai Hu #endif 4419f3183d2SMingkai Hu 4429f3183d2SMingkai Hu #ifdef CONFIG_FSL_ESDHC 4439f3183d2SMingkai Hu fdt_fixup_esdhc(blob, bd); 4449f3183d2SMingkai Hu #endif 4459f3183d2SMingkai Hu 44644262327SAhmed Mansour #ifdef CONFIG_SYS_DPAA_QBMAN 44744262327SAhmed Mansour fdt_fixup_bportals(blob); 44844262327SAhmed Mansour fdt_fixup_qportals(blob); 44944262327SAhmed Mansour do_fixup_by_compat_u32(blob, "fsl,qman", 45044262327SAhmed Mansour "clock-frequency", get_qman_freq(), 1); 45144262327SAhmed Mansour #endif 45244262327SAhmed Mansour 4530e52b6feSQianyu Gong #ifdef CONFIG_SYS_DPAA_FMAN 4540e52b6feSQianyu Gong fdt_fixup_fman_firmware(blob); 4550e52b6feSQianyu Gong #endif 4565436c6a3SRan Wang #ifndef CONFIG_ARCH_LS1012A 457c93db4f7SSriram Dash fsl_fdt_disable_usb(blob); 458132a1468SYingxi Yu #endif 459fa18ed76SWenbin Song #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN 460fa18ed76SWenbin Song fdt_fixup_gic(blob); 461fa18ed76SWenbin Song #endif 4622ca84bf7SWenbin Song #ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI 4632ca84bf7SWenbin Song fdt_fixup_msi(blob); 4642ca84bf7SWenbin Song #endif 4659f3183d2SMingkai Hu } 466