From db6a2b5c681e30351061df089ab2e86bae4509a9 Mon Sep 17 00:00:00 2001 From: Bin Meng <bmeng.cn@gmail.com> Date: Tue, 17 Mar 2020 07:59:50 -0700 Subject: lib: utils: Add a general device tree fix-up helper This adds a general device tree fix-up helper to do all required device tree fix-ups for a typical platform. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com> --- include/sbi_utils/fdt/fdt_helper.h | 13 +++++++++++++ lib/utils/fdt/fdt_helper.c | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/include/sbi_utils/fdt/fdt_helper.h b/include/sbi_utils/fdt/fdt_helper.h index d3b065a..079b619 100644 --- a/include/sbi_utils/fdt/fdt_helper.h +++ b/include/sbi_utils/fdt/fdt_helper.h @@ -47,4 +47,17 @@ void fdt_plic_fixup(void *fdt, const char *compat); */ int fdt_reserved_memory_fixup(void *fdt); +/** + * General device tree fix-up + * + * This routine do all required device tree fix-ups for a typical platform. + * It fixes up the PLIC node and the reserved memory node in the device tree + * by calling the corresponding helper routines to accomplish the task. + * + * It is recommended that platform codes call this helper in their final_init() + * + * @param fdt: device tree blob + */ +void fdt_fixups(void *fdt); + #endif /* __FDT_HELPER_H__ */ diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c index 4ef7a5e..47cd1d3 100644 --- a/lib/utils/fdt/fdt_helper.c +++ b/lib/utils/fdt/fdt_helper.c @@ -191,3 +191,10 @@ int fdt_reserved_memory_fixup(void *fdt) return 0; } + +void fdt_fixups(void *fdt) +{ + fdt_plic_fixup(fdt, "riscv,plic0"); + + fdt_reserved_memory_fixup(fdt); +} -- cgit v1.2.3