1 // SPDX-License-Identifier: BSD-2-Clause 2 /* 3 * fdt_fixup.h - Flat Device Tree manipulation helper routines 4 * Implement platform specific DT fixups on top of libfdt. 5 * 6 * Copyright (C) 2020 Bin Meng <bmeng.cn@gmail.com> 7 */ 8 9 #ifndef __FDT_FIXUP_H__ 10 #define __FDT_FIXUP_H__ 11 12 /** 13 * Fix up the CPU node in the device tree 14 * 15 * This routine updates the "status" property of a CPU node in the device tree 16 * to "disabled" if that hart is in disabled state in OpenSBI. 17 * 18 * It is recommended that platform codes call this helper in their final_init() 19 * 20 * @param fdt: device tree blob 21 */ 22 void fdt_cpu_fixup(void *fdt); 23 24 /** 25 * Fix up the PLIC node in the device tree 26 * 27 * This routine updates the "interrupt-extended" property of the PLIC node in 28 * the device tree to hide the M-mode external interrupt from CPUs. 29 * 30 * It is recommended that platform codes call this helper in their final_init() 31 * 32 * @param fdt: device tree blob 33 * @param compat: PLIC node compatible string 34 */ 35 void fdt_plic_fixup(void *fdt, const char *compat); 36 37 /** 38 * Fix up the reserved memory node in the device tree 39 * 40 * This routine inserts a child node of the reserved memory node in the device 41 * tree that describes the protected memory region done by OpenSBI via PMP. 42 * 43 * It is recommended that platform codes call this helper in their final_init() 44 * 45 * @param fdt: device tree blob 46 * @return zero on success and -ve on failure 47 */ 48 int fdt_reserved_memory_fixup(void *fdt); 49 50 /** 51 * Fix up the reserved memory subnodes in the device tree 52 * 53 * This routine adds the no-map property to the reserved memory subnodes so 54 * that the OS does not map those PMP protected memory regions. 55 * 56 * Platform codes must call this helper in their final_init() after fdt_fixups() 57 * if the OS should not map the PMP protected reserved regions. 58 * 59 * @param fdt: device tree blob 60 * @return zero on success and -ve on failure 61 */ 62 int fdt_reserved_memory_nomap_fixup(void *fdt); 63 64 /** 65 * General device tree fix-up 66 * 67 * This routine do all required device tree fix-ups for a typical platform. 68 * It fixes up the PLIC node and the reserved memory node in the device tree 69 * by calling the corresponding helper routines to accomplish the task. 70 * 71 * It is recommended that platform codes call this helper in their final_init() 72 * 73 * @param fdt: device tree blob 74 */ 75 void fdt_fixups(void *fdt); 76 77 #endif /* __FDT_FIXUP_H__ */ 78 79