fdt_domain.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. struct sbi_domain;
  14. /**
  15. * Iterate over each domains in device tree
  16. *
  17. * @param fdt device tree blob
  18. * @param opaque private pointer for each iteration
  19. * @param fn callback function for each iteration
  20. *
  21. * @return 0 on success and negative error code on failure
  22. */
  23. int fdt_iterate_each_domain(void *fdt, void *opaque,
  24. int (*fn)(void *fdt, int domain_offset,
  25. void *opaque));
  26. /**
  27. * Iterate over each memregion of a domain in device tree
  28. *
  29. * @param fdt device tree blob
  30. * @param domain_offset domain DT node offset
  31. * @param opaque private pointer for each iteration
  32. * @param fn callback function for each iteration
  33. *
  34. * @return 0 on success and negative error code on failure
  35. */
  36. int fdt_iterate_each_memregion(void *fdt, int domain_offset, void *opaque,
  37. int (*fn)(void *fdt, int domain_offset,
  38. int region_offset, u32 region_access,
  39. void *opaque));
  40. /**
  41. * Fix up the domain configuration in the device tree
  42. *
  43. * This routine:
  44. * 1. Disables MMIO devices not accessible to the coldboot HART domain
  45. * 2. Removes "opensbi-domain" DT property from CPU DT nodes
  46. * 3. Removes domain configuration DT node under /chosen DT node
  47. *
  48. * It is recommended that platform support call this function in
  49. * their final_init() platform operation.
  50. *
  51. * @param fdt device tree blob
  52. */
  53. void fdt_domain_fixup(void *fdt);
  54. /**
  55. * Populate domains from device tree
  56. *
  57. * It is recommended that platform support call this function in
  58. * their domains_init() platform operation.
  59. *
  60. * @param fdt device tree blob
  61. *
  62. * @return 0 on success and negative error code on failure
  63. */
  64. int fdt_domains_populate(void *fdt);
  65. #endif /* __FDT_DOMAIN_H__ */