fdt_fixup.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #ifndef __FDT_FIXUP_H__
  9. #define __FDT_FIXUP_H__
  10. /**
  11. * Fix up the CPU node in the device tree
  12. *
  13. * This routine updates the "status" property of a CPU node in the device tree
  14. * to "disabled" if that hart is in disabled state in OpenSBI.
  15. *
  16. * It is recommended that platform codes call this helper in their final_init()
  17. *
  18. * @param fdt: device tree blob
  19. */
  20. void fdt_cpu_fixup(void *fdt);
  21. /**
  22. * Fix up the PLIC node in the device tree
  23. *
  24. * This routine updates the "interrupt-extended" property of the PLIC node in
  25. * the device tree to hide the M-mode external interrupt from CPUs.
  26. *
  27. * It is recommended that platform codes call this helper in their final_init()
  28. *
  29. * @param fdt: device tree blob
  30. */
  31. void fdt_plic_fixup(void *fdt);
  32. /**
  33. * Fix up the reserved memory node in the device tree
  34. *
  35. * This routine inserts a child node of the reserved memory node in the device
  36. * tree that describes the protected memory region done by OpenSBI via PMP.
  37. *
  38. * It is recommended that platform codes call this helper in their final_init()
  39. *
  40. * @param fdt: device tree blob
  41. * @return zero on success and -ve on failure
  42. */
  43. int fdt_reserved_memory_fixup(void *fdt);
  44. /**
  45. * Fix up the reserved memory subnodes in the device tree
  46. *
  47. * This routine adds the no-map property to the reserved memory subnodes so
  48. * that the OS does not map those PMP protected memory regions.
  49. *
  50. * Platform codes must call this helper in their final_init() after fdt_fixups()
  51. * if the OS should not map the PMP protected reserved regions.
  52. *
  53. * @param fdt: device tree blob
  54. * @return zero on success and -ve on failure
  55. */
  56. int fdt_reserved_memory_nomap_fixup(void *fdt);
  57. /**
  58. * General device tree fix-up
  59. *
  60. * This routine do all required device tree fix-ups for a typical platform.
  61. * It fixes up the PLIC node and the reserved memory node in the device tree
  62. * by calling the corresponding helper routines to accomplish the task.
  63. *
  64. * It is recommended that platform codes call this helper in their final_init()
  65. *
  66. * @param fdt: device tree blob
  67. */
  68. void fdt_fixups(void *fdt);
  69. #endif /* __FDT_FIXUP_H__ */