summaryrefslogtreecommitdiff
path: root/lib/utils/fdt
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2020-03-17 17:59:42 +0300
committerAnup Patel <anup@brainfault.org>2020-03-18 07:10:14 +0300
commit6af55769eb8cd5b9c7fdcd959586e0bc0fce3994 (patch)
treee73e27ae65e4baab3c9b19e38155ecef29fce88b /lib/utils/fdt
parent666be6d62beffc380faf8700cc532142222826d8 (diff)
downloadopensbi-6af55769eb8cd5b9c7fdcd959586e0bc0fce3994.tar.xz
lib: utils: Move PLIC DT fix up codes to fdt_helper.c
Now that we have a dedicated fdt_helper.c file for DT releated helper routines, move plic_fdt_fixup() codes from plic.c to fdt_helper.c and rename it to fdt_plic_fixup() at the same time, to keep name consistency in the same file. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/utils/fdt')
-rw-r--r--lib/utils/fdt/fdt_helper.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/utils/fdt/fdt_helper.c b/lib/utils/fdt/fdt_helper.c
index d95a056..fcae968 100644
--- a/lib/utils/fdt/fdt_helper.c
+++ b/lib/utils/fdt/fdt_helper.c
@@ -12,6 +12,31 @@
#include <sbi/sbi_platform.h>
#include <sbi/sbi_scratch.h>
+void fdt_plic_fixup(void *fdt, const char *compat)
+{
+ u32 *cells;
+ int i, cells_count;
+ int plic_off;
+
+ plic_off = fdt_node_offset_by_compatible(fdt, 0, compat);
+ if (plic_off < 0)
+ return;
+
+ cells = (u32 *)fdt_getprop(fdt, plic_off,
+ "interrupts-extended", &cells_count);
+ if (!cells)
+ return;
+
+ cells_count = cells_count / sizeof(u32);
+ if (!cells_count)
+ return;
+
+ for (i = 0; i < (cells_count / 2); i++) {
+ if (fdt32_to_cpu(cells[2 * i + 1]) == IRQ_M_EXT)
+ cells[2 * i + 1] = cpu_to_fdt32(0xffffffff);
+ }
+}
+
/**
* We use PMP to protect OpenSBI firmware to safe-guard it from buggy S-mode
* software, see pmp_init() in lib/sbi/sbi_hart.c. The protected memory region