fdt_pmu.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: BSD-2-Clause
  2. /*
  3. * fdt_pmu.c - Flat Device Tree PMU helper routines
  4. *
  5. * Copyright (c) 2021 Western Digital Corporation or its affiliates.
  6. *
  7. * Authors:
  8. * Atish Patra <atish.patra@wdc.com>
  9. */
  10. #ifndef __FDT_PMU_H__
  11. #define __FDT_PMU_H__
  12. #include <sbi/sbi_types.h>
  13. #ifdef CONFIG_FDT_PMU
  14. /**
  15. * Fix up the PMU node in the device tree
  16. *
  17. * This routine:
  18. * 1. Disables opensbi specific properties from the DT
  19. *
  20. * It is recommended that platform support call this function in
  21. * their final_init() platform operation.
  22. *
  23. * @param fdt device tree blob
  24. */
  25. void fdt_pmu_fixup(void *fdt);
  26. /**
  27. * Setup PMU data from device tree
  28. *
  29. * @param fdt device tree blob
  30. *
  31. * @return 0 on success and negative error code on failure
  32. */
  33. int fdt_pmu_setup(void *fdt);
  34. /**
  35. * Get the mhpmevent select value read from DT for a given event
  36. * @param event_idx Event ID of the given event
  37. *
  38. * @return The select value read from DT or 0 if given index was not found
  39. */
  40. uint64_t fdt_pmu_get_select_value(uint32_t event_idx);
  41. #else
  42. static inline void fdt_pmu_fixup(void *fdt) { }
  43. static inline int fdt_pmu_setup(void *fdt) { return 0; }
  44. static inline uint64_t fdt_pmu_get_select_value(uint32_t event_idx) { return 0; }
  45. #endif
  46. #endif