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>
17 struct ti_sci_handle *get_ti_sci_handle(void)
22 ret = uclass_get_device_by_name(UCLASS_FIRMWARE, "dmsc", &dev);
24 panic("Failed to get SYSFW (%d)\n", ret);
26 return (struct ti_sci_handle *)ti_sci_get_handle_from_sysfw(dev);
29 #ifdef CONFIG_SYS_K3_SPL_ATF
30 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
35 * It is assumed that remoteproc device 1 is the corresponding
36 * Cortex-A core which runs ATF. Make sure DT reflects the same.
38 ret = rproc_dev_init(1);
40 panic("%s: ATF failed to initialize on rproc (%d)\n", __func__,
43 ret = rproc_load(1, spl_image->entry_point, 0x200);
45 panic("%s: ATF failed to load on rproc (%d)\n", __func__, ret);
47 /* Add an extra newline to differentiate the ATF logs from SPL */
48 printf("Starting ATF on ARM64 core...\n\n");
52 panic("%s: ATF failed to start on rproc (%d)\n", __func__, ret);
54 debug("ATF started. Waiting indefinitely...\n");
60 #if defined(CONFIG_OF_LIBFDT)
61 int fdt_fixup_msmc_ram(void *blob, char *parent_path, char *node_name)
63 u64 msmc_start = 0, msmc_end = 0, msmc_size, reg[2];
64 struct ti_sci_handle *ti_sci = get_ti_sci_handle();
65 int ret, node, subnode, len, prev_node;
66 u32 range[4], addr, size;
67 const fdt32_t *sub_reg;
69 ti_sci->ops.core_ops.query_msmc(ti_sci, &msmc_start, &msmc_end);
70 msmc_size = msmc_end - msmc_start + 1;
71 debug("%s: msmc_start = 0x%llx, msmc_size = 0x%llx\n", __func__,
72 msmc_start, msmc_size);
74 /* find or create "msmc_sram node */
75 ret = fdt_path_offset(blob, parent_path);
79 node = fdt_find_or_add_subnode(blob, ret, node_name);
83 ret = fdt_setprop_string(blob, node, "compatible", "mmio-sram");
87 reg[0] = cpu_to_fdt64(msmc_start);
88 reg[1] = cpu_to_fdt64(msmc_size);
89 ret = fdt_setprop(blob, node, "reg", reg, sizeof(reg));
93 fdt_setprop_cell(blob, node, "#address-cells", 1);
94 fdt_setprop_cell(blob, node, "#size-cells", 1);
97 range[1] = cpu_to_fdt32(msmc_start >> 32);
98 range[2] = cpu_to_fdt32(msmc_start & 0xffffffff);
99 range[3] = cpu_to_fdt32(msmc_size);
100 ret = fdt_setprop(blob, node, "ranges", range, sizeof(range));
104 subnode = fdt_first_subnode(blob, node);
107 /* Look for invalid subnodes and delete them */
108 while (subnode >= 0) {
109 sub_reg = fdt_getprop(blob, subnode, "reg", &len);
110 addr = fdt_read_number(sub_reg, 1);
112 size = fdt_read_number(sub_reg, 1);
113 debug("%s: subnode = %d, addr = 0x%x. size = 0x%x\n", __func__,
114 subnode, addr, size);
115 if (addr + size > msmc_size ||
116 !strncmp(fdt_get_name(blob, subnode, &len), "sysfw", 5) ||
117 !strncmp(fdt_get_name(blob, subnode, &len), "l3cache", 7)) {
118 fdt_del_node(blob, subnode);
119 debug("%s: deleting subnode %d\n", __func__, subnode);
121 subnode = fdt_first_subnode(blob, node);
123 subnode = fdt_next_subnode(blob, prev_node);
126 subnode = fdt_next_subnode(blob, prev_node);