1 // SPDX-License-Identifier: GPL-2.0+
3 * K3: Common Architecture initialization
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 * Lokesh Vutla <lokeshvutla@ti.com>
13 #include <remoteproc.h>
14 #include <linux/soc/ti/ti_sci_protocol.h>
15 #include <fdt_support.h>
16 #include <asm/arch/sys_proto.h>
17 #include <asm/hardware.h>
20 struct ti_sci_handle *get_ti_sci_handle(void)
25 ret = uclass_get_device(UCLASS_FIRMWARE, 0, &dev);
27 panic("Failed to get SYSFW (%d)\n", ret);
29 return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw(dev);
32 DECLARE_GLOBAL_DATA_PTR;
34 #ifdef CONFIG_K3_EARLY_CONS
35 int early_console_init(void)
40 gd->baudrate = CONFIG_BAUDRATE;
42 ret = uclass_get_device_by_seq(UCLASS_SERIAL, CONFIG_K3_EARLY_CONS_IDX,
45 printf("Error getting serial dev for early console! (%d)\n",
50 gd->cur_serial_dev = dev;
51 gd->flags |= GD_FLG_SERIAL_READY;
58 #ifdef CONFIG_SYS_K3_SPL_ATF
59 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
61 struct ti_sci_handle *ti_sci = get_ti_sci_handle();
64 /* Release all the exclusive devices held by SPL before starting ATF */
65 ti_sci->ops.dev_ops.release_exclusive_devices(ti_sci);
68 * It is assumed that remoteproc device 1 is the corresponding
69 * Cortex-A core which runs ATF. Make sure DT reflects the same.
71 ret = rproc_dev_init(1);
73 panic("%s: ATF failed to initialize on rproc (%d)\n", __func__,
76 ret = rproc_load(1, spl_image->entry_point, 0x200);
78 panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret);
80 /* Add an extra newline to differentiate the ATF logs from SPL */
81 printf("Starting ATF on ARM64 core...\n\n");
85 panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret);
87 debug("Releasing resources...\n");
88 release_resources_for_core_shutdown();
90 debug("Finalizing core shutdown...\n");
96 #if defined(CONFIG_OF_LIBFDT)
97 int fdt_fixup_msmc_ram(void *blob, char *parent_path, char *node_name)
99 u64 msmc_start = 0, msmc_end = 0, msmc_size, reg[2];
100 struct ti_sci_handle *ti_sci = get_ti_sci_handle();
101 int ret, node, subnode, len, prev_node;
102 u32 range[4], addr, size;
103 const fdt32_t *sub_reg;
105 ti_sci->ops.core_ops.query_msmc(ti_sci, &msmc_start, &msmc_end);
106 msmc_size = msmc_end - msmc_start + 1;
107 debug("%s: msmc_start = 0x%llx, msmc_size = 0x%llx\n", __func__,
108 msmc_start, msmc_size);
110 /* find or create "msmc_sram node */
111 ret = fdt_path_offset(blob, parent_path);
115 node = fdt_find_or_add_subnode(blob, ret, node_name);
119 ret = fdt_setprop_string(blob, node, "compatible", "mmio-sram");
123 reg[0] = cpu_to_fdt64(msmc_start);
124 reg[1] = cpu_to_fdt64(msmc_size);
125 ret = fdt_setprop(blob, node, "reg", reg, sizeof(reg));
129 fdt_setprop_cell(blob, node, "#address-cells", 1);
130 fdt_setprop_cell(blob, node, "#size-cells", 1);
133 range[1] = cpu_to_fdt32(msmc_start >> 32);
134 range[2] = cpu_to_fdt32(msmc_start & 0xffffffff);
135 range[3] = cpu_to_fdt32(msmc_size);
136 ret = fdt_setprop(blob, node, "ranges", range, sizeof(range));
140 subnode = fdt_first_subnode(blob, node);
143 /* Look for invalid subnodes and delete them */
144 while (subnode >= 0) {
145 sub_reg = fdt_getprop(blob, subnode, "reg", &len);
146 addr = fdt_read_number(sub_reg, 1);
148 size = fdt_read_number(sub_reg, 1);
149 debug("%s: subnode = %d, addr = 0x%x. size = 0x%x\n", __func__,
150 subnode, addr, size);
151 if (addr + size > msmc_size ||
152 !strncmp(fdt_get_name(blob, subnode, &len), "sysfw", 5) ||
153 !strncmp(fdt_get_name(blob, subnode, &len), "l3cache", 7)) {
154 fdt_del_node(blob, subnode);
155 debug("%s: deleting subnode %d\n", __func__, subnode);
157 subnode = fdt_first_subnode(blob, node);
159 subnode = fdt_next_subnode(blob, prev_node);
162 subnode = fdt_next_subnode(blob, prev_node);
169 int fdt_disable_node(void *blob, char *node_path)
174 offs = fdt_path_offset(blob, node_path);
176 debug("Node %s not found.\n", node_path);
179 ret = fdt_setprop_string(blob, offs, "status", "disabled");
181 printf("Could not add status property to node %s: %s\n",
182 node_path, fdt_strerror(ret));
190 #ifndef CONFIG_SYSRESET
191 void reset_cpu(ulong ignored)
196 #if defined(CONFIG_DISPLAY_CPUINFO)
197 int print_cpuinfo(void)
202 soc = (readl(CTRLMMR_WKUP_JTAG_DEVICE_ID) &
203 DEVICE_ID_FAMILY_MASK) >> DEVICE_ID_FAMILY_SHIFT;
204 rev = (readl(CTRLMMR_WKUP_JTAG_ID) &
205 JTAG_ID_VARIANT_MASK) >> JTAG_ID_VARIANT_SHIFT;
216 name = "Unknown Silicon";
219 printf("%s PG ", name);
228 name = "Unknown Revision";
230 printf("%s\n", name);