xref: /openbmc/u-boot/arch/arm/cpu/armv8/fsl-layerscape/fdt.c (revision 5436c6a347918bf278d4cc9e5678f9bd94bdbcbc)
19f3183d2SMingkai Hu /*
29f3183d2SMingkai Hu  * Copyright 2014-2015 Freescale Semiconductor, Inc.
39f3183d2SMingkai Hu  *
49f3183d2SMingkai Hu  * SPDX-License-Identifier:	GPL-2.0+
59f3183d2SMingkai Hu  */
69f3183d2SMingkai Hu 
79f3183d2SMingkai Hu #include <common.h>
85a37a2f0SAlexander Graf #include <efi_loader.h>
99f3183d2SMingkai Hu #include <libfdt.h>
109f3183d2SMingkai Hu #include <fdt_support.h>
119f3183d2SMingkai Hu #include <phy.h>
129f3183d2SMingkai Hu #ifdef CONFIG_FSL_LSCH3
139f3183d2SMingkai Hu #include <asm/arch/fdt.h>
149f3183d2SMingkai Hu #endif
159f3183d2SMingkai Hu #ifdef CONFIG_FSL_ESDHC
169f3183d2SMingkai Hu #include <fsl_esdhc.h>
179f3183d2SMingkai Hu #endif
180e52b6feSQianyu Gong #ifdef CONFIG_SYS_DPAA_FMAN
190e52b6feSQianyu Gong #include <fsl_fman.h>
200e52b6feSQianyu Gong #endif
219f3183d2SMingkai Hu #ifdef CONFIG_MP
229f3183d2SMingkai Hu #include <asm/arch/mp.h>
239f3183d2SMingkai Hu #endif
24f13c99c2SAlex Porosanu #include <fsl_sec.h>
25f13c99c2SAlex Porosanu #include <asm/arch-fsl-layerscape/soc.h>
26032d5bb4SHou Zhiqiang #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
27032d5bb4SHou Zhiqiang #include <asm/armv8/sec_firmware.h>
28032d5bb4SHou Zhiqiang #endif
299f3183d2SMingkai Hu 
30e8297341SShaohui Xie int fdt_fixup_phy_connection(void *blob, int offset, phy_interface_t phyc)
31e8297341SShaohui Xie {
32e8297341SShaohui Xie 	return fdt_setprop_string(blob, offset, "phy-connection-type",
33e8297341SShaohui Xie 					 phy_string_for_interface(phyc));
34e8297341SShaohui Xie }
35e8297341SShaohui Xie 
369f3183d2SMingkai Hu #ifdef CONFIG_MP
379f3183d2SMingkai Hu void ft_fixup_cpu(void *blob)
389f3183d2SMingkai Hu {
399f3183d2SMingkai Hu 	int off;
409f3183d2SMingkai Hu 	__maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr();
419f3183d2SMingkai Hu 	fdt32_t *reg;
429f3183d2SMingkai Hu 	int addr_cells;
439f3183d2SMingkai Hu 	u64 val, core_id;
449f3183d2SMingkai Hu 	size_t *boot_code_size = &(__secondary_boot_code_size);
452d16a1a6Smacro.wave.z@gmail.com #if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \
46daa92644SHou Zhiqiang 	defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI)
47032d5bb4SHou Zhiqiang 	int node;
48032d5bb4SHou Zhiqiang 	u32 psci_ver;
499f3183d2SMingkai Hu 
50032d5bb4SHou Zhiqiang 	/* Check the psci version to determine if the psci is supported */
51032d5bb4SHou Zhiqiang 	psci_ver = sec_firmware_support_psci_version();
52032d5bb4SHou Zhiqiang 	if (psci_ver == 0xffffffff) {
53032d5bb4SHou Zhiqiang 		/* remove psci DT node */
54032d5bb4SHou Zhiqiang 		node = fdt_path_offset(blob, "/psci");
55032d5bb4SHou Zhiqiang 		if (node >= 0)
56032d5bb4SHou Zhiqiang 			goto remove_psci_node;
57032d5bb4SHou Zhiqiang 
58032d5bb4SHou Zhiqiang 		node = fdt_node_offset_by_compatible(blob, -1, "arm,psci");
59032d5bb4SHou Zhiqiang 		if (node >= 0)
60032d5bb4SHou Zhiqiang 			goto remove_psci_node;
61032d5bb4SHou Zhiqiang 
62032d5bb4SHou Zhiqiang 		node = fdt_node_offset_by_compatible(blob, -1, "arm,psci-0.2");
63032d5bb4SHou Zhiqiang 		if (node >= 0)
64032d5bb4SHou Zhiqiang 			goto remove_psci_node;
65032d5bb4SHou Zhiqiang 
66032d5bb4SHou Zhiqiang 		node = fdt_node_offset_by_compatible(blob, -1, "arm,psci-1.0");
67032d5bb4SHou Zhiqiang 		if (node >= 0)
68032d5bb4SHou Zhiqiang 			goto remove_psci_node;
69032d5bb4SHou Zhiqiang 
70032d5bb4SHou Zhiqiang remove_psci_node:
71032d5bb4SHou Zhiqiang 		if (node >= 0)
72032d5bb4SHou Zhiqiang 			fdt_del_node(blob, node);
73032d5bb4SHou Zhiqiang 	} else {
74032d5bb4SHou Zhiqiang 		return;
75032d5bb4SHou Zhiqiang 	}
76032d5bb4SHou Zhiqiang #endif
779f3183d2SMingkai Hu 	off = fdt_path_offset(blob, "/cpus");
789f3183d2SMingkai Hu 	if (off < 0) {
799f3183d2SMingkai Hu 		puts("couldn't find /cpus node\n");
809f3183d2SMingkai Hu 		return;
819f3183d2SMingkai Hu 	}
82eed36609SSimon Glass 	fdt_support_default_count_cells(blob, off, &addr_cells, NULL);
839f3183d2SMingkai Hu 
849f3183d2SMingkai Hu 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
859f3183d2SMingkai Hu 	while (off != -FDT_ERR_NOTFOUND) {
869f3183d2SMingkai Hu 		reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
879f3183d2SMingkai Hu 		if (reg) {
88eed36609SSimon Glass 			core_id = fdt_read_number(reg, addr_cells);
899f3183d2SMingkai Hu 			if (core_id  == 0 || (is_core_online(core_id))) {
909f3183d2SMingkai Hu 				val = spin_tbl_addr;
919f3183d2SMingkai Hu 				val += id_to_core(core_id) *
929f3183d2SMingkai Hu 				       SPIN_TABLE_ELEM_SIZE;
939f3183d2SMingkai Hu 				val = cpu_to_fdt64(val);
949f3183d2SMingkai Hu 				fdt_setprop_string(blob, off, "enable-method",
959f3183d2SMingkai Hu 						   "spin-table");
969f3183d2SMingkai Hu 				fdt_setprop(blob, off, "cpu-release-addr",
979f3183d2SMingkai Hu 					    &val, sizeof(val));
989f3183d2SMingkai Hu 			} else {
999f3183d2SMingkai Hu 				debug("skipping offline core\n");
1009f3183d2SMingkai Hu 			}
1019f3183d2SMingkai Hu 		} else {
1029f3183d2SMingkai Hu 			puts("Warning: found cpu node without reg property\n");
1039f3183d2SMingkai Hu 		}
1049f3183d2SMingkai Hu 		off = fdt_node_offset_by_prop_value(blob, off, "device_type",
1059f3183d2SMingkai Hu 						    "cpu", 4);
1069f3183d2SMingkai Hu 	}
1079f3183d2SMingkai Hu 
1089f3183d2SMingkai Hu 	fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
1099f3183d2SMingkai Hu 			*boot_code_size);
1105a37a2f0SAlexander Graf #if defined(CONFIG_EFI_LOADER) && !defined(CONFIG_SPL_BUILD)
1115a37a2f0SAlexander Graf 	efi_add_memory_map((uintptr_t)&secondary_boot_code,
1125a37a2f0SAlexander Graf 			   ALIGN(*boot_code_size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
1135a37a2f0SAlexander Graf 			   EFI_RESERVED_MEMORY_TYPE, false);
1145a37a2f0SAlexander Graf #endif
1159f3183d2SMingkai Hu }
1169f3183d2SMingkai Hu #endif
1179f3183d2SMingkai Hu 
118c93db4f7SSriram Dash void fsl_fdt_disable_usb(void *blob)
119c93db4f7SSriram Dash {
120c93db4f7SSriram Dash 	int off;
121c93db4f7SSriram Dash 	/*
122c93db4f7SSriram Dash 	 * SYSCLK is used as a reference clock for USB. When the USB
123c93db4f7SSriram Dash 	 * controller is used, SYSCLK must meet the additional requirement
124c93db4f7SSriram Dash 	 * of 100 MHz.
125c93db4f7SSriram Dash 	 */
126c93db4f7SSriram Dash 	if (CONFIG_SYS_CLK_FREQ != 100000000) {
127c93db4f7SSriram Dash 		off = fdt_node_offset_by_compatible(blob, -1, "snps,dwc3");
128c93db4f7SSriram Dash 		while (off != -FDT_ERR_NOTFOUND) {
129c93db4f7SSriram Dash 			fdt_status_disabled(blob, off);
130c93db4f7SSriram Dash 			off = fdt_node_offset_by_compatible(blob, off,
131c93db4f7SSriram Dash 							    "snps,dwc3");
132c93db4f7SSriram Dash 		}
133c93db4f7SSriram Dash 	}
134c93db4f7SSriram Dash }
135c93db4f7SSriram Dash 
136fa18ed76SWenbin Song #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN
137fa18ed76SWenbin Song static void fdt_fixup_gic(void *blob)
138fa18ed76SWenbin Song {
139fa18ed76SWenbin Song 	int offset, err;
140fa18ed76SWenbin Song 	u64 reg[8];
141fa18ed76SWenbin Song 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
142fa18ed76SWenbin Song 	unsigned int val;
143fa18ed76SWenbin Song 	struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR;
144fa18ed76SWenbin Song 	int align_64k = 0;
145fa18ed76SWenbin Song 
146fa18ed76SWenbin Song 	val = gur_in32(&gur->svr);
147fa18ed76SWenbin Song 
148fa18ed76SWenbin Song 	if (SVR_SOC_VER(val) != SVR_LS1043A) {
149fa18ed76SWenbin Song 		align_64k = 1;
150fa18ed76SWenbin Song 	} else if (SVR_REV(val) != REV1_0) {
151fa18ed76SWenbin Song 		val = scfg_in32(&scfg->gic_align) & (0x01 << GIC_ADDR_BIT);
152fa18ed76SWenbin Song 		if (!val)
153fa18ed76SWenbin Song 			align_64k = 1;
154fa18ed76SWenbin Song 	}
155fa18ed76SWenbin Song 
156fa18ed76SWenbin Song 	offset = fdt_subnode_offset(blob, 0, "interrupt-controller@1400000");
157fa18ed76SWenbin Song 	if (offset < 0) {
158fa18ed76SWenbin Song 		printf("WARNING: fdt_subnode_offset can't find node %s: %s\n",
159fa18ed76SWenbin Song 		       "interrupt-controller@1400000", fdt_strerror(offset));
160fa18ed76SWenbin Song 		return;
161fa18ed76SWenbin Song 	}
162fa18ed76SWenbin Song 
163fa18ed76SWenbin Song 	/* Fixup gic node align with 64K */
164fa18ed76SWenbin Song 	if (align_64k) {
165fa18ed76SWenbin Song 		reg[0] = cpu_to_fdt64(GICD_BASE_64K);
166fa18ed76SWenbin Song 		reg[1] = cpu_to_fdt64(GICD_SIZE_64K);
167fa18ed76SWenbin Song 		reg[2] = cpu_to_fdt64(GICC_BASE_64K);
168fa18ed76SWenbin Song 		reg[3] = cpu_to_fdt64(GICC_SIZE_64K);
169fa18ed76SWenbin Song 		reg[4] = cpu_to_fdt64(GICH_BASE_64K);
170fa18ed76SWenbin Song 		reg[5] = cpu_to_fdt64(GICH_SIZE_64K);
171fa18ed76SWenbin Song 		reg[6] = cpu_to_fdt64(GICV_BASE_64K);
172fa18ed76SWenbin Song 		reg[7] = cpu_to_fdt64(GICV_SIZE_64K);
173fa18ed76SWenbin Song 	} else {
174fa18ed76SWenbin Song 	/* Fixup gic node align with default */
175fa18ed76SWenbin Song 		reg[0] = cpu_to_fdt64(GICD_BASE);
176fa18ed76SWenbin Song 		reg[1] = cpu_to_fdt64(GICD_SIZE);
177fa18ed76SWenbin Song 		reg[2] = cpu_to_fdt64(GICC_BASE);
178fa18ed76SWenbin Song 		reg[3] = cpu_to_fdt64(GICC_SIZE);
179fa18ed76SWenbin Song 		reg[4] = cpu_to_fdt64(GICH_BASE);
180fa18ed76SWenbin Song 		reg[5] = cpu_to_fdt64(GICH_SIZE);
181fa18ed76SWenbin Song 		reg[6] = cpu_to_fdt64(GICV_BASE);
182fa18ed76SWenbin Song 		reg[7] = cpu_to_fdt64(GICV_SIZE);
183fa18ed76SWenbin Song 	}
184fa18ed76SWenbin Song 
185fa18ed76SWenbin Song 	err = fdt_setprop(blob, offset, "reg", reg, sizeof(reg));
186fa18ed76SWenbin Song 	if (err < 0) {
187fa18ed76SWenbin Song 		printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
188fa18ed76SWenbin Song 		       "reg", "interrupt-controller@1400000",
189fa18ed76SWenbin Song 		       fdt_strerror(err));
190fa18ed76SWenbin Song 		return;
191fa18ed76SWenbin Song 	}
192fa18ed76SWenbin Song 
193fa18ed76SWenbin Song 	return;
194fa18ed76SWenbin Song }
195fa18ed76SWenbin Song #endif
196fa18ed76SWenbin Song 
1972ca84bf7SWenbin Song #ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI
1982ca84bf7SWenbin Song static int _fdt_fixup_msi_node(void *blob, const char *name,
1992ca84bf7SWenbin Song 				  int irq_0, int irq_1, int rev)
2002ca84bf7SWenbin Song {
2012ca84bf7SWenbin Song 	int err, offset, len;
2022ca84bf7SWenbin Song 	u32 tmp[4][3];
2032ca84bf7SWenbin Song 	void *p;
2042ca84bf7SWenbin Song 
2052ca84bf7SWenbin Song 	offset = fdt_path_offset(blob, name);
2062ca84bf7SWenbin Song 	if (offset < 0) {
2072ca84bf7SWenbin Song 		printf("WARNING: fdt_path_offset can't find path %s: %s\n",
2082ca84bf7SWenbin Song 		       name, fdt_strerror(offset));
2092ca84bf7SWenbin Song 		return 0;
2102ca84bf7SWenbin Song 	}
2112ca84bf7SWenbin Song 
2122ca84bf7SWenbin Song 	/*fixup the property of interrupts*/
2132ca84bf7SWenbin Song 
2142ca84bf7SWenbin Song 	tmp[0][0] = cpu_to_fdt32(0x0);
2152ca84bf7SWenbin Song 	tmp[0][1] = cpu_to_fdt32(irq_0);
2162ca84bf7SWenbin Song 	tmp[0][2] = cpu_to_fdt32(0x4);
2172ca84bf7SWenbin Song 
2182ca84bf7SWenbin Song 	if (rev > REV1_0) {
2192ca84bf7SWenbin Song 		tmp[1][0] = cpu_to_fdt32(0x0);
2202ca84bf7SWenbin Song 		tmp[1][1] = cpu_to_fdt32(irq_1);
2212ca84bf7SWenbin Song 		tmp[1][2] = cpu_to_fdt32(0x4);
2222ca84bf7SWenbin Song 		tmp[2][0] = cpu_to_fdt32(0x0);
2232ca84bf7SWenbin Song 		tmp[2][1] = cpu_to_fdt32(irq_1 + 1);
2242ca84bf7SWenbin Song 		tmp[2][2] = cpu_to_fdt32(0x4);
2252ca84bf7SWenbin Song 		tmp[3][0] = cpu_to_fdt32(0x0);
2262ca84bf7SWenbin Song 		tmp[3][1] = cpu_to_fdt32(irq_1 + 2);
2272ca84bf7SWenbin Song 		tmp[3][2] = cpu_to_fdt32(0x4);
2282ca84bf7SWenbin Song 		len = sizeof(tmp);
2292ca84bf7SWenbin Song 	} else {
2302ca84bf7SWenbin Song 		len = sizeof(tmp[0]);
2312ca84bf7SWenbin Song 	}
2322ca84bf7SWenbin Song 
2332ca84bf7SWenbin Song 	err = fdt_setprop(blob, offset, "interrupts", tmp, len);
2342ca84bf7SWenbin Song 	if (err < 0) {
2352ca84bf7SWenbin Song 		printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
2362ca84bf7SWenbin Song 		       "interrupts", name, fdt_strerror(err));
2372ca84bf7SWenbin Song 		return 0;
2382ca84bf7SWenbin Song 	}
2392ca84bf7SWenbin Song 
2402ca84bf7SWenbin Song 	/*fixup the property of reg*/
2412ca84bf7SWenbin Song 	p = (char *)fdt_getprop(blob, offset, "reg", &len);
2422ca84bf7SWenbin Song 	if (!p) {
2432ca84bf7SWenbin Song 		printf("WARNING: fdt_getprop can't get %s from node %s\n",
2442ca84bf7SWenbin Song 		       "reg", name);
2452ca84bf7SWenbin Song 		return 0;
2462ca84bf7SWenbin Song 	}
2472ca84bf7SWenbin Song 
2482ca84bf7SWenbin Song 	memcpy((char *)tmp, p, len);
2492ca84bf7SWenbin Song 
2502ca84bf7SWenbin Song 	if (rev > REV1_0)
2512ca84bf7SWenbin Song 		*((u32 *)tmp + 3) = cpu_to_fdt32(0x1000);
2522ca84bf7SWenbin Song 	else
2532ca84bf7SWenbin Song 		*((u32 *)tmp + 3) = cpu_to_fdt32(0x8);
2542ca84bf7SWenbin Song 
2552ca84bf7SWenbin Song 	err = fdt_setprop(blob, offset, "reg", tmp, len);
2562ca84bf7SWenbin Song 	if (err < 0) {
2572ca84bf7SWenbin Song 		printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
2582ca84bf7SWenbin Song 		       "reg", name, fdt_strerror(err));
2592ca84bf7SWenbin Song 		return 0;
2602ca84bf7SWenbin Song 	}
2612ca84bf7SWenbin Song 
2622ca84bf7SWenbin Song 	/*fixup the property of compatible*/
2632ca84bf7SWenbin Song 	if (rev > REV1_0)
2642ca84bf7SWenbin Song 		err = fdt_setprop_string(blob, offset, "compatible",
2652ca84bf7SWenbin Song 					 "fsl,ls1043a-v1.1-msi");
2662ca84bf7SWenbin Song 	else
2672ca84bf7SWenbin Song 		err = fdt_setprop_string(blob, offset, "compatible",
2682ca84bf7SWenbin Song 					 "fsl,ls1043a-msi");
2692ca84bf7SWenbin Song 	if (err < 0) {
2702ca84bf7SWenbin Song 		printf("WARNING: fdt_setprop can't set %s from node %s: %s\n",
2712ca84bf7SWenbin Song 		       "compatible", name, fdt_strerror(err));
2722ca84bf7SWenbin Song 		return 0;
2732ca84bf7SWenbin Song 	}
2742ca84bf7SWenbin Song 
2752ca84bf7SWenbin Song 	return 1;
2762ca84bf7SWenbin Song }
2772ca84bf7SWenbin Song 
2782ca84bf7SWenbin Song static int _fdt_fixup_pci_msi(void *blob, const char *name, int rev)
2792ca84bf7SWenbin Song {
2802ca84bf7SWenbin Song 	int offset, len, err;
2812ca84bf7SWenbin Song 	void *p;
2822ca84bf7SWenbin Song 	int val;
2832ca84bf7SWenbin Song 	u32 tmp[4][8];
2842ca84bf7SWenbin Song 
2852ca84bf7SWenbin Song 	offset = fdt_path_offset(blob, name);
2862ca84bf7SWenbin Song 	if (offset < 0) {
2872ca84bf7SWenbin Song 		printf("WARNING: fdt_path_offset can't find path %s: %s\n",
2882ca84bf7SWenbin Song 		       name, fdt_strerror(offset));
2892ca84bf7SWenbin Song 		return 0;
2902ca84bf7SWenbin Song 	}
2912ca84bf7SWenbin Song 
2922ca84bf7SWenbin Song 	p = (char *)fdt_getprop(blob, offset, "interrupt-map", &len);
2932ca84bf7SWenbin Song 	if (!p || len != sizeof(tmp)) {
2942ca84bf7SWenbin Song 		printf("WARNING: fdt_getprop can't get %s from node %s\n",
2952ca84bf7SWenbin Song 		       "interrupt-map", name);
2962ca84bf7SWenbin Song 		return 0;
2972ca84bf7SWenbin Song 	}
2982ca84bf7SWenbin Song 
2992ca84bf7SWenbin Song 	memcpy((char *)tmp, p, len);
3002ca84bf7SWenbin Song 
3012ca84bf7SWenbin Song 	val = fdt32_to_cpu(tmp[0][6]);
3022ca84bf7SWenbin Song 	if (rev > REV1_0) {
3032ca84bf7SWenbin Song 		tmp[1][6] = cpu_to_fdt32(val + 1);
3042ca84bf7SWenbin Song 		tmp[2][6] = cpu_to_fdt32(val + 2);
3052ca84bf7SWenbin Song 		tmp[3][6] = cpu_to_fdt32(val + 3);
3062ca84bf7SWenbin Song 	} else {
3072ca84bf7SWenbin Song 		tmp[1][6] = cpu_to_fdt32(val);
3082ca84bf7SWenbin Song 		tmp[2][6] = cpu_to_fdt32(val);
3092ca84bf7SWenbin Song 		tmp[3][6] = cpu_to_fdt32(val);
3102ca84bf7SWenbin Song 	}
3112ca84bf7SWenbin Song 
3122ca84bf7SWenbin Song 	err = fdt_setprop(blob, offset, "interrupt-map", tmp, sizeof(tmp));
3132ca84bf7SWenbin Song 	if (err < 0) {
3142ca84bf7SWenbin Song 		printf("WARNING: fdt_setprop can't set %s from node %s: %s.\n",
3152ca84bf7SWenbin Song 		       "interrupt-map", name, fdt_strerror(err));
3162ca84bf7SWenbin Song 		return 0;
3172ca84bf7SWenbin Song 	}
3182ca84bf7SWenbin Song 	return 1;
3192ca84bf7SWenbin Song }
3202ca84bf7SWenbin Song 
3212ca84bf7SWenbin Song /* Fixup msi node for ls1043a rev1.1*/
3222ca84bf7SWenbin Song 
3232ca84bf7SWenbin Song static void fdt_fixup_msi(void *blob)
3242ca84bf7SWenbin Song {
3252ca84bf7SWenbin Song 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
3262ca84bf7SWenbin Song 	unsigned int rev;
3272ca84bf7SWenbin Song 
3282ca84bf7SWenbin Song 	rev = gur_in32(&gur->svr);
3292ca84bf7SWenbin Song 
3302ca84bf7SWenbin Song 	if (SVR_SOC_VER(rev) != SVR_LS1043A)
3312ca84bf7SWenbin Song 		return;
3322ca84bf7SWenbin Song 
3332ca84bf7SWenbin Song 	rev = SVR_REV(rev);
3342ca84bf7SWenbin Song 
3352ca84bf7SWenbin Song 	_fdt_fixup_msi_node(blob, "/soc/msi-controller1@1571000",
3362ca84bf7SWenbin Song 			    116, 111, rev);
3372ca84bf7SWenbin Song 	_fdt_fixup_msi_node(blob, "/soc/msi-controller2@1572000",
3382ca84bf7SWenbin Song 			    126, 121, rev);
3392ca84bf7SWenbin Song 	_fdt_fixup_msi_node(blob, "/soc/msi-controller3@1573000",
3402ca84bf7SWenbin Song 			    160, 155, rev);
3412ca84bf7SWenbin Song 
3422ca84bf7SWenbin Song 	_fdt_fixup_pci_msi(blob, "/soc/pcie@3400000", rev);
3432ca84bf7SWenbin Song 	_fdt_fixup_pci_msi(blob, "/soc/pcie@3500000", rev);
3442ca84bf7SWenbin Song 	_fdt_fixup_pci_msi(blob, "/soc/pcie@3600000", rev);
3452ca84bf7SWenbin Song }
3462ca84bf7SWenbin Song #endif
3472ca84bf7SWenbin Song 
348a797f274SRuchika Gupta #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
349a797f274SRuchika Gupta /* Remove JR node used by SEC firmware */
350a797f274SRuchika Gupta void fdt_fixup_remove_jr(void *blob)
351a797f274SRuchika Gupta {
352a797f274SRuchika Gupta 	int jr_node, addr_cells, len;
353a797f274SRuchika Gupta 	int crypto_node = fdt_path_offset(blob, "crypto");
354a797f274SRuchika Gupta 	u64 jr_offset, used_jr;
355a797f274SRuchika Gupta 	fdt32_t *reg;
356a797f274SRuchika Gupta 
357a797f274SRuchika Gupta 	used_jr = sec_firmware_used_jobring_offset();
358a797f274SRuchika Gupta 	fdt_support_default_count_cells(blob, crypto_node, &addr_cells, NULL);
359a797f274SRuchika Gupta 
360a797f274SRuchika Gupta 	jr_node = fdt_node_offset_by_compatible(blob, crypto_node,
361a797f274SRuchika Gupta 						"fsl,sec-v4.0-job-ring");
362a797f274SRuchika Gupta 
363a797f274SRuchika Gupta 	while (jr_node != -FDT_ERR_NOTFOUND) {
364a797f274SRuchika Gupta 		reg = (fdt32_t *)fdt_getprop(blob, jr_node, "reg", &len);
365a797f274SRuchika Gupta 		jr_offset = fdt_read_number(reg, addr_cells);
366a797f274SRuchika Gupta 		if (jr_offset == used_jr) {
367a797f274SRuchika Gupta 			fdt_del_node(blob, jr_node);
368a797f274SRuchika Gupta 			break;
369a797f274SRuchika Gupta 		}
370a797f274SRuchika Gupta 		jr_node = fdt_node_offset_by_compatible(blob, jr_node,
371a797f274SRuchika Gupta 							"fsl,sec-v4.0-job-ring");
372a797f274SRuchika Gupta 	}
373a797f274SRuchika Gupta }
374a797f274SRuchika Gupta #endif
375a797f274SRuchika Gupta 
3769f3183d2SMingkai Hu void ft_cpu_setup(void *blob, bd_t *bd)
3779f3183d2SMingkai Hu {
378f13c99c2SAlex Porosanu 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
379a797f274SRuchika Gupta 	unsigned int svr = gur_in32(&gur->svr);
380f13c99c2SAlex Porosanu 
381f13c99c2SAlex Porosanu 	/* delete crypto node if not on an E-processor */
382f13c99c2SAlex Porosanu 	if (!IS_E_PROCESSOR(svr))
383f13c99c2SAlex Porosanu 		fdt_fixup_crypto_node(blob, 0);
384f13c99c2SAlex Porosanu #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
385f13c99c2SAlex Porosanu 	else {
386f13c99c2SAlex Porosanu 		ccsr_sec_t __iomem *sec;
387f13c99c2SAlex Porosanu 
388a797f274SRuchika Gupta #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
389a797f274SRuchika Gupta 		if (fdt_fixup_kaslr(blob))
390a797f274SRuchika Gupta 			fdt_fixup_remove_jr(blob);
391a797f274SRuchika Gupta #endif
392a797f274SRuchika Gupta 
393f13c99c2SAlex Porosanu 		sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR;
394f13c99c2SAlex Porosanu 		fdt_fixup_crypto_node(blob, sec_in32(&sec->secvid_ms));
395f13c99c2SAlex Porosanu 	}
396f13c99c2SAlex Porosanu #endif
397f13c99c2SAlex Porosanu 
3989f3183d2SMingkai Hu #ifdef CONFIG_MP
3999f3183d2SMingkai Hu 	ft_fixup_cpu(blob);
4009f3183d2SMingkai Hu #endif
4019f3183d2SMingkai Hu 
4029f3183d2SMingkai Hu #ifdef CONFIG_SYS_NS16550
4039f3183d2SMingkai Hu 	do_fixup_by_compat_u32(blob, "fsl,ns16550",
4049f3183d2SMingkai Hu 			       "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
4059f3183d2SMingkai Hu #endif
4069f3183d2SMingkai Hu 
4073d91f46cSYangbo Lu 	do_fixup_by_path_u32(blob, "/sysclk", "clock-frequency",
4083d91f46cSYangbo Lu 			     CONFIG_SYS_CLK_FREQ, 1);
4096f14e257SPrabhakar Kushwaha 
4109f3183d2SMingkai Hu #ifdef CONFIG_PCI
4119f3183d2SMingkai Hu 	ft_pci_setup(blob, bd);
4129f3183d2SMingkai Hu #endif
4139f3183d2SMingkai Hu 
4149f3183d2SMingkai Hu #ifdef CONFIG_FSL_ESDHC
4159f3183d2SMingkai Hu 	fdt_fixup_esdhc(blob, bd);
4169f3183d2SMingkai Hu #endif
4179f3183d2SMingkai Hu 
4180e52b6feSQianyu Gong #ifdef CONFIG_SYS_DPAA_FMAN
4190e52b6feSQianyu Gong 	fdt_fixup_fman_firmware(blob);
4200e52b6feSQianyu Gong #endif
421*5436c6a3SRan Wang #ifndef CONFIG_ARCH_LS1012A
422c93db4f7SSriram Dash 	fsl_fdt_disable_usb(blob);
423132a1468SYingxi Yu #endif
424fa18ed76SWenbin Song #ifdef CONFIG_HAS_FEATURE_GIC64K_ALIGN
425fa18ed76SWenbin Song 	fdt_fixup_gic(blob);
426fa18ed76SWenbin Song #endif
4272ca84bf7SWenbin Song #ifdef CONFIG_HAS_FEATURE_ENHANCED_MSI
4282ca84bf7SWenbin Song 	fdt_fixup_msi(blob);
4292ca84bf7SWenbin Song #endif
4309f3183d2SMingkai Hu }
431