2 * Copyright 2014 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <fdt_support.h>
10 #include <asm/arch-fsl-lsch3/fdt.h>
11 #ifdef CONFIG_FSL_ESDHC
12 #include <fsl_esdhc.h>
17 void ft_fixup_cpu(void *blob)
20 __maybe_unused u64 spin_tbl_addr = (u64)get_spin_tbl_addr();
24 size_t *boot_code_size = &(__secondary_boot_code_size);
26 off = fdt_path_offset(blob, "/cpus");
28 puts("couldn't find /cpus node\n");
31 of_bus_default_count_cells(blob, off, &addr_cells, NULL);
33 off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
34 while (off != -FDT_ERR_NOTFOUND) {
35 reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
37 core_id = of_read_number(reg, addr_cells);
38 if (core_id == 0 || (is_core_online(core_id))) {
40 val += id_to_core(core_id) *
42 val = cpu_to_fdt64(val);
43 fdt_setprop_string(blob, off, "enable-method",
45 fdt_setprop(blob, off, "cpu-release-addr",
48 debug("skipping offline core\n");
51 puts("Warning: found cpu node without reg property\n");
53 off = fdt_node_offset_by_prop_value(blob, off, "device_type",
57 fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
63 * the burden is on the the caller to not request a count
64 * exceeding the bounds of the stream_ids[] array
66 void alloc_stream_ids(int start_id, int count, u32 *stream_ids, int max_cnt)
70 if (count > max_cnt) {
71 printf("\n%s: ERROR: max per-device stream ID count exceed\n",
76 for (i = 0; i < count; i++)
77 stream_ids[i] = start_id++;
81 * This function updates the mmu-masters property on the SMMU
82 * node as per the SMMU binding-- phandle and list of stream IDs
83 * for each MMU master.
85 void append_mmu_masters(void *blob, const char *smmu_path,
86 const char *master_name, u32 *stream_ids, int count)
90 int master_nodeoffset;
93 /* get phandle of mmu master device */
94 master_nodeoffset = fdt_path_offset(blob, master_name);
95 if (master_nodeoffset < 0) {
96 printf("\n%s: ERROR: master not found\n", __func__);
99 phandle = fdt_get_phandle(blob, master_nodeoffset);
100 if (!phandle) { /* if master has no phandle, create one */
101 phandle = fdt_create_phandle(blob, master_nodeoffset);
103 printf("\n%s: ERROR: unable to create phandle\n",
109 /* append it to mmu-masters */
110 smmu_nodeoffset = fdt_path_offset(blob, smmu_path);
111 if (fdt_appendprop_u32(blob, smmu_nodeoffset, "mmu-masters",
113 printf("\n%s: ERROR: unable to update SMMU node\n", __func__);
117 /* for each stream ID, append to mmu-masters */
118 for (i = 0; i < count; i++) {
119 fdt_appendprop_u32(blob, smmu_nodeoffset, "mmu-masters",
123 /* fix up #stream-id-cells with stream ID count */
124 if (fdt_setprop_u32(blob, master_nodeoffset, "#stream-id-cells",
126 printf("\n%s: ERROR: unable to update #stream-id-cells\n",
132 * The info below summarizes how streamID partitioning works
133 * for ls2085a and how it is conveyed to the OS via the device tree.
135 * -non-PCI legacy, platform devices (USB, SD/MMC, SATA, DMA)
136 * -all legacy devices get a unique ICID assigned and programmed in
137 * their AMQR registers by u-boot
138 * -u-boot updates the hardware device tree with streamID properties
139 * for each platform/legacy device (smmu-masters property)
142 * -for each PCI controller that is active (as per RCW settings),
143 * u-boot will allocate a range of ICID and convey that to Linux via
144 * the device tree (smmu-masters property)
147 * -u-boot will allocate a range of ICIDs to be used by the Management
148 * Complex for containers and will set these values in the MC DPC image.
149 * -the MC is responsible for allocating and setting up ICIDs
150 * for all DPAA2 devices.
153 static void fdt_fixup_smmu(void *blob)
157 nodeoffset = fdt_path_offset(blob, "/iommu@5000000");
158 if (nodeoffset < 0) {
159 printf("\n%s: WARNING: no SMMU node found\n", __func__);
163 /* fixup for all PCI controllers */
165 fdt_fixup_smmu_pcie(blob);
169 void ft_cpu_setup(void *blob, bd_t *bd)
175 #ifdef CONFIG_SYS_NS16550
176 do_fixup_by_compat_u32(blob, "fsl,ns16550",
177 "clock-frequency", CONFIG_SYS_NS16550_CLK, 1);
181 ft_pci_setup(blob, bd);
184 #if defined(CONFIG_FSL_ESDHC)
185 fdt_fixup_esdhc(blob, bd);
188 fdt_fixup_smmu(blob);