platform: sifive/fu540: Replace cpu0 node fix-up with the new helper
authorBin Meng <bmeng.cn@gmail.com>
Tue, 17 Mar 2020 14:59:49 +0000 (07:59 -0700)
committerAnup Patel <anup@brainfault.org>
Wed, 18 Mar 2020 05:26:43 +0000 (10:56 +0530)
This replaces the FU540 specific cpu0 node "status" property fix-up
with the newly introduced generic fdt_cpu_fixup() helper.

Unlike previous logic, the helper routine does not test the "mmu-type"
property to determine which node we should fix up, instead it uses
sbi_platform_hart_disabled() API.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
platform/sifive/fu540/platform.c

index b655d45..6a8c7b2 100644 (file)
 
 static void fu540_modify_dt(void *fdt)
 {
-       u32 i, size;
-       int err;
-       int cpu_offset;
-       char cpu_node[32] = "";
-       const char *mmu_type;
-
-       size = fdt_totalsize(fdt);
-       err  = fdt_open_into(fdt, fdt, size + 256);
-       if (err < 0)
-               sbi_printf(
-                       "Device Tree can't be expanded to accmodate new node");
-
-       for (i = 0; i < FU540_HART_COUNT; i++) {
-               sbi_sprintf(cpu_node, "/cpus/cpu@%d", i);
-               cpu_offset = fdt_path_offset(fdt, cpu_node);
-               mmu_type   = fdt_getprop(fdt, cpu_offset, "mmu-type", NULL);
-               if (mmu_type && (!strcmp(mmu_type, "riscv,sv32") ||
-                                !strcmp(mmu_type, "riscv,sv39") ||
-                                !strcmp(mmu_type, "riscv,sv48")))
-                       continue;
-               else
-                       fdt_setprop_string(fdt, cpu_offset, "status",
-                                          "disabled");
-               memset(cpu_node, 0, sizeof(cpu_node));
-       }
+       fdt_cpu_fixup(fdt);
 
        fdt_plic_fixup(fdt, "riscv,plic0");