fdt_domain.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: BSD-2-Clause
  2. /*
  3. * fdt_domain.c - Flat Device Tree Domain helper routines
  4. *
  5. * Copyright (c) 2020 Western Digital Corporation or its affiliates.
  6. *
  7. * Authors:
  8. * Anup Patel <anup.patel@wdc.com>
  9. */
  10. #ifndef __FDT_DOMAIN_H__
  11. #define __FDT_DOMAIN_H__
  12. #include <sbi/sbi_types.h>
  13. #ifdef CONFIG_FDT_DOMAIN
  14. struct sbi_domain;
  15. /**
  16. * Iterate over each domains in device tree
  17. *
  18. * @param fdt device tree blob
  19. * @param opaque private pointer for each iteration
  20. * @param fn callback function for each iteration
  21. *
  22. * @return 0 on success and negative error code on failure
  23. */
  24. int fdt_iterate_each_domain(void *fdt, void *opaque,
  25. int (*fn)(void *fdt, int domain_offset,
  26. void *opaque));
  27. /**
  28. * Iterate over each memregion of a domain in device tree
  29. *
  30. * @param fdt device tree blob
  31. * @param domain_offset domain DT node offset
  32. * @param opaque private pointer for each iteration
  33. * @param fn callback function for each iteration
  34. *
  35. * @return 0 on success and negative error code on failure
  36. */
  37. int fdt_iterate_each_memregion(void *fdt, int domain_offset, void *opaque,
  38. int (*fn)(void *fdt, int domain_offset,
  39. int region_offset, u32 region_access,
  40. void *opaque));
  41. /**
  42. * Fix up the domain configuration in the device tree
  43. *
  44. * This routine:
  45. * 1. Disables MMIO devices not accessible to the coldboot HART domain
  46. * 2. Removes "opensbi-domain" DT property from CPU DT nodes
  47. * 3. Removes domain configuration DT node under /chosen DT node
  48. *
  49. * It is recommended that platform support call this function in
  50. * their final_init() platform operation.
  51. *
  52. * @param fdt device tree blob
  53. */
  54. void fdt_domain_fixup(void *fdt);
  55. /**
  56. * Populate domains from device tree
  57. *
  58. * It is recommended that platform support call this function in
  59. * their domains_init() platform operation.
  60. *
  61. * @param fdt device tree blob
  62. *
  63. * @return 0 on success and negative error code on failure
  64. */
  65. int fdt_domains_populate(void *fdt);
  66. #else
  67. static inline void fdt_domain_fixup(void *fdt) { }
  68. static inline int fdt_domains_populate(void *fdt) { return 0; }
  69. #endif
  70. #endif /* __FDT_DOMAIN_H__ */