pm_api_sys.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
  3. * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef PM_API_SYS_H
  8. #define PM_API_SYS_H
  9. #include <stdint.h>
  10. #include "pm_defs.h"
  11. /*********************************************************************
  12. * Target module IDs macros
  13. ********************************************************************/
  14. #define LIBPM_MODULE_ID 0x2U
  15. #define LOADER_MODULE_ID 0x7U
  16. #define MODULE_ID_MASK 0x0000ff00U
  17. /**********************************************************
  18. * PM API function declarations
  19. **********************************************************/
  20. enum pm_ret_status pm_handle_eemi_call(uint32_t flag, uint32_t x0, uint32_t x1,
  21. uint32_t x2, uint32_t x3, uint32_t x4,
  22. uint32_t x5, uint64_t *result);
  23. enum pm_ret_status pm_self_suspend(uint32_t nid,
  24. uint32_t latency,
  25. uint32_t state,
  26. uintptr_t address, uint32_t flag);
  27. enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason, uint32_t flag);
  28. enum pm_ret_status pm_req_suspend(uint32_t target,
  29. uint8_t ack,
  30. uint32_t latency,
  31. uint32_t state, uint32_t flag);
  32. enum pm_ret_status pm_req_wakeup(uint32_t target, uint32_t set_address,
  33. uintptr_t address, uint8_t ack, uint32_t flag);
  34. enum pm_ret_status pm_set_wakeup_source(uint32_t target, uint32_t device_id,
  35. uint8_t enable, uint32_t flag);
  36. enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count, uint32_t flag,
  37. uint32_t ack);
  38. void pm_client_set_wakeup_sources(uint32_t node_id);
  39. enum pm_ret_status pm_pll_set_param(uint32_t clk_id, uint32_t param,
  40. uint32_t value, uint32_t flag);
  41. enum pm_ret_status pm_pll_get_param(uint32_t clk_id, uint32_t param,
  42. uint32_t *value, uint32_t flag);
  43. enum pm_ret_status pm_pll_set_mode(uint32_t clk_id, uint32_t mode,
  44. uint32_t flag);
  45. enum pm_ret_status pm_pll_get_mode(uint32_t clk_id, uint32_t *mode,
  46. uint32_t flag);
  47. enum pm_ret_status pm_force_powerdown(uint32_t target, uint8_t ack,
  48. uint32_t flag);
  49. enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype,
  50. uint32_t flag);
  51. enum pm_ret_status pm_query_data(uint32_t qid, uint32_t arg1, uint32_t arg2,
  52. uint32_t arg3, uint32_t *data, uint32_t flag);
  53. uint32_t pm_get_shutdown_scope(void);
  54. enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *ret_payload,
  55. uint32_t flag);
  56. enum pm_ret_status pm_load_pdi(uint32_t src, uint32_t address_low,
  57. uint32_t address_high, uint32_t flag);
  58. enum pm_ret_status pm_register_notifier(uint32_t device_id, uint32_t event,
  59. uint32_t wake, uint32_t enable,
  60. uint32_t flag);
  61. enum pm_ret_status pm_get_chipid(uint32_t *value);
  62. enum pm_ret_status eemi_feature_check(uint32_t api_id, uint32_t *ret_payload);
  63. /*
  64. * Assigning of argument values into array elements.
  65. */
  66. #define PM_PACK_PAYLOAD1(pl, mid, flag, arg0) { \
  67. pl[0] = (uint32_t)(((uint32_t)(arg0) & 0xFFU) | ((mid) << 8U) | ((flag) << 24U)); \
  68. }
  69. #define PM_PACK_PAYLOAD2(pl, mid, flag, arg0, arg1) { \
  70. pl[1] = (uint32_t)(arg1); \
  71. PM_PACK_PAYLOAD1(pl, (mid), (flag), (arg0)); \
  72. }
  73. #define PM_PACK_PAYLOAD3(pl, mid, flag, arg0, arg1, arg2) { \
  74. pl[2] = (uint32_t)(arg2); \
  75. PM_PACK_PAYLOAD2(pl, (mid), (flag), (arg0), (arg1)); \
  76. }
  77. #define PM_PACK_PAYLOAD4(pl, mid, flag, arg0, arg1, arg2, arg3) { \
  78. pl[3] = (uint32_t)(arg3); \
  79. PM_PACK_PAYLOAD3(pl, (mid), (flag), (arg0), (arg1), (arg2)); \
  80. }
  81. #define PM_PACK_PAYLOAD5(pl, mid, flag, arg0, arg1, arg2, arg3, arg4) { \
  82. pl[4] = (uint32_t)(arg4); \
  83. PM_PACK_PAYLOAD4(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3)); \
  84. }
  85. #define PM_PACK_PAYLOAD6(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5) { \
  86. pl[5] = (uint32_t)(arg5); \
  87. PM_PACK_PAYLOAD5(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4)); \
  88. }
  89. #define PM_PACK_PAYLOAD7(pl, mid, flag, arg0, arg1, arg2, arg3, arg4, arg5, arg6) { \
  90. pl[6] = (uint32_t)(arg6); \
  91. PM_PACK_PAYLOAD6(pl, (mid), (flag), (arg0), (arg1), (arg2), (arg3), (arg4), (arg5)); \
  92. }
  93. #endif /* PM_API_SYS_H */