fdt_fixup_cores_nodes_am625(blob, k3_get_core_nr());
fdt_fixup_gpu_nodes_am625(blob, k3_has_gpu());
fdt_fixup_pru_node_am625(blob, k3_has_pru());
+ fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
+ fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
return 0;
}
return ret;
}
+
+int fdt_fixup_reserved(void *blob, const char *name,
+ unsigned int new_address, unsigned int new_size)
+{
+ int nodeoffset, subnode;
+ int ret;
+
+ /* Find reserved-memory */
+ nodeoffset = fdt_subnode_offset(blob, 0, "reserved-memory");
+ if (nodeoffset < 0) {
+ debug("Could not find reserved-memory node\n");
+ return 0;
+ }
+
+ /* Find existing matching subnode and remove it */
+ fdt_for_each_subnode(subnode, blob, nodeoffset) {
+ const char *node_name;
+ fdt_addr_t addr;
+ fdt_size_t size;
+
+ /* Name matching */
+ node_name = fdt_get_name(blob, subnode, NULL);
+ if (!name)
+ return -EINVAL;
+ if (!strncmp(node_name, name, strlen(name))) {
+ /* Read out old size first */
+ addr = fdtdec_get_addr_size(blob, subnode, "reg", &size);
+ if (addr == FDT_ADDR_T_NONE)
+ return -EINVAL;
+ new_size = size;
+
+ /* Delete node */
+ ret = fdt_del_node(blob, subnode);
+ if (ret < 0)
+ return ret;
+
+ /* Only one matching node */
+ break;
+ }
+ }
+
+ struct fdt_memory carveout = {
+ .start = new_address,
+ .end = new_address + new_size - 1,
+ };
+ ret = fdtdec_add_reserved_memory(blob, name, &carveout, NULL, 0, NULL,
+ FDTDEC_RESERVED_MEMORY_NO_MAP);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
int fdt_fixup_msmc_ram_k3(void *blob);
int fdt_del_node_path(void *blob, const char *path);
+int fdt_fixup_reserved(void *blob, const char *name,
+ unsigned int new_address, unsigned int new_size);
#endif /* _COMMON_FDT_H */