summaryrefslogtreecommitdiff
path: root/arch/riscv/lib/fdt_fixup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/riscv/lib/fdt_fixup.c')
-rw-r--r--arch/riscv/lib/fdt_fixup.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index af12e484db..20e0759f13 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -115,3 +115,36 @@ int board_fix_fdt(void *fdt)
return 0;
}
#endif
+
+int arch_fixup_fdt(void *blob)
+{
+ int err;
+#ifdef CONFIG_EFI_LOADER
+ u32 size;
+ int chosen_offset;
+
+ size = fdt_totalsize(blob);
+ err = fdt_open_into(blob, blob, size + 32);
+ if (err < 0) {
+ printf("Device Tree can't be expanded to accommodate new node");
+ return err;
+ }
+ chosen_offset = fdt_path_offset(blob, "/chosen");
+ if (chosen_offset < 0) {
+ err = fdt_add_subnode(blob, 0, "chosen");
+ if (err < 0) {
+ printf("chosen node can not be added\n");
+ return err;
+ }
+ }
+ /* Overwrite the boot-hartid as U-Boot is the last stage BL */
+ fdt_setprop_u32(blob, chosen_offset, "boot-hartid", gd->arch.boot_hart);
+#endif
+
+ /* Copy the reserved-memory node to the DT used by OS */
+ err = riscv_fdt_copy_resv_mem_node(gd->fdt_blob, blob);
+ if (err < 0)
+ return err;
+
+ return 0;
+}