2 * Copyright 2014-2015 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <fdt_support.h>
11 #ifdef CONFIG_FSL_LSCH3
12 #include <asm/arch/fdt.h>
14 #ifdef CONFIG_FSL_ESDHC
15 #include <fsl_esdhc.h>
18 #include <asm/arch/mp.h>
22 void ft_fixup_cpu(void *blob
)
25 __maybe_unused u64 spin_tbl_addr
= (u64
)get_spin_tbl_addr();
29 size_t *boot_code_size
= &(__secondary_boot_code_size
);
31 off
= fdt_path_offset(blob
, "/cpus");
33 puts("couldn't find /cpus node\n");
36 of_bus_default_count_cells(blob
, off
, &addr_cells
, NULL
);
38 off
= fdt_node_offset_by_prop_value(blob
, -1, "device_type", "cpu", 4);
39 while (off
!= -FDT_ERR_NOTFOUND
) {
40 reg
= (fdt32_t
*)fdt_getprop(blob
, off
, "reg", 0);
42 core_id
= of_read_number(reg
, addr_cells
);
43 if (core_id
== 0 || (is_core_online(core_id
))) {
45 val
+= id_to_core(core_id
) *
47 val
= cpu_to_fdt64(val
);
48 fdt_setprop_string(blob
, off
, "enable-method",
50 fdt_setprop(blob
, off
, "cpu-release-addr",
53 debug("skipping offline core\n");
56 puts("Warning: found cpu node without reg property\n");
58 off
= fdt_node_offset_by_prop_value(blob
, off
, "device_type",
62 fdt_add_mem_rsv(blob
, (uintptr_t)&secondary_boot_code
,
68 * the burden is on the the caller to not request a count
69 * exceeding the bounds of the stream_ids[] array
71 void alloc_stream_ids(int start_id
, int count
, u32
*stream_ids
, int max_cnt
)
75 if (count
> max_cnt
) {
76 printf("\n%s: ERROR: max per-device stream ID count exceed\n",
81 for (i
= 0; i
< count
; i
++)
82 stream_ids
[i
] = start_id
++;
86 * This function updates the mmu-masters property on the SMMU
87 * node as per the SMMU binding-- phandle and list of stream IDs
88 * for each MMU master.
90 void append_mmu_masters(void *blob
, const char *smmu_path
,
91 const char *master_name
, u32
*stream_ids
, int count
)
95 int master_nodeoffset
;
98 /* get phandle of mmu master device */
99 master_nodeoffset
= fdt_path_offset(blob
, master_name
);
100 if (master_nodeoffset
< 0) {
101 printf("\n%s: ERROR: master not found\n", __func__
);
104 phandle
= fdt_get_phandle(blob
, master_nodeoffset
);
105 if (!phandle
) { /* if master has no phandle, create one */
106 phandle
= fdt_create_phandle(blob
, master_nodeoffset
);
108 printf("\n%s: ERROR: unable to create phandle\n",
114 /* append it to mmu-masters */
115 smmu_nodeoffset
= fdt_path_offset(blob
, smmu_path
);
116 if (fdt_appendprop_u32(blob
, smmu_nodeoffset
, "mmu-masters",
118 printf("\n%s: ERROR: unable to update SMMU node\n", __func__
);
122 /* for each stream ID, append to mmu-masters */
123 for (i
= 0; i
< count
; i
++) {
124 fdt_appendprop_u32(blob
, smmu_nodeoffset
, "mmu-masters",
128 /* fix up #stream-id-cells with stream ID count */
129 if (fdt_setprop_u32(blob
, master_nodeoffset
, "#stream-id-cells",
131 printf("\n%s: ERROR: unable to update #stream-id-cells\n",
137 * The info below summarizes how streamID partitioning works
138 * for ls2085a and how it is conveyed to the OS via the device tree.
140 * -non-PCI legacy, platform devices (USB, SD/MMC, SATA, DMA)
141 * -all legacy devices get a unique ICID assigned and programmed in
142 * their AMQR registers by u-boot
143 * -u-boot updates the hardware device tree with streamID properties
144 * for each platform/legacy device (smmu-masters property)
147 * -for each PCI controller that is active (as per RCW settings),
148 * u-boot will allocate a range of ICID and convey that to Linux via
149 * the device tree (smmu-masters property)
152 * -u-boot will allocate a range of ICIDs to be used by the Management
153 * Complex for containers and will set these values in the MC DPC image.
154 * -the MC is responsible for allocating and setting up ICIDs
155 * for all DPAA2 devices.
158 #ifdef CONFIG_FSL_LSCH3
159 static void fdt_fixup_smmu(void *blob
)
163 nodeoffset
= fdt_path_offset(blob
, "/iommu@5000000");
164 if (nodeoffset
< 0) {
165 printf("\n%s: WARNING: no SMMU node found\n", __func__
);
169 /* fixup for all PCI controllers */
171 fdt_fixup_smmu_pcie(blob
);
176 void ft_cpu_setup(void *blob
, bd_t
*bd
)
182 #ifdef CONFIG_SYS_NS16550
183 do_fixup_by_compat_u32(blob
, "fsl,ns16550",
184 "clock-frequency", CONFIG_SYS_NS16550_CLK
, 1);
188 ft_pci_setup(blob
, bd
);
191 #ifdef CONFIG_FSL_ESDHC
192 fdt_fixup_esdhc(blob
, bd
);
195 #ifdef CONFIG_FSL_LSCH3
196 fdt_fixup_smmu(blob
);