plat_pm_helpers.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2024, Rockchip, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PLAT_PM_HELPERS_H
  7. #define PLAT_PM_HELPERS_H
  8. #include <stdint.h>
  9. /**
  10. * Use this macro to define a register region.
  11. * start: start offset from the base address.
  12. * end: end offset from the base address.
  13. * stride: stride of registers in region.
  14. * base: base address of registers in region.
  15. * wmsk: write mask of registers in region.
  16. */
  17. #define REG_REGION(_start, _end, _stride, _base, _wmsk) \
  18. { \
  19. .start = (_base) + (_start), \
  20. .end = (_base) + (_end), \
  21. .stride = _stride, \
  22. .wmsk = _wmsk \
  23. }
  24. struct reg_region {
  25. /* Start address of region */
  26. uint32_t start;
  27. /* End address of region */
  28. uint32_t end;
  29. /* Stride of registers in region */
  30. uint32_t stride;
  31. /* Write mask of registers in region */
  32. uint32_t wmsk;
  33. /* Buffer to save/restore registers in region */
  34. uint32_t *buf;
  35. };
  36. void rockchip_alloc_region_mem(struct reg_region *rgns, uint32_t rgn_num);
  37. void rockchip_reg_rgn_save(struct reg_region *rgns, uint32_t rgn_num);
  38. void rockchip_reg_rgn_restore(struct reg_region *rgns, uint32_t rgn_num);
  39. void rockchip_reg_rgn_restore_reverse(struct reg_region *rgns, uint32_t rgn_num);
  40. void rockchip_regs_dump(uint32_t base,
  41. uint32_t start_offset,
  42. uint32_t end_offset,
  43. uint32_t stride);
  44. void rockchip_dump_reg_rgns(struct reg_region *rgns, uint32_t rgn_num);
  45. #endif /* PLAT_PM_HELPERS_H */