zynqmp_pm_api_sys.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2023, Advanced Micro Devices, Inc. All rights reserved.
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef ZYNQMP_PM_API_SYS_H
  8. #define ZYNQMP_PM_API_SYS_H
  9. #include <stdint.h>
  10. #include "pm_defs.h"
  11. #include "zynqmp_pm_defs.h"
  12. enum pm_query_ids {
  13. PM_QID_INVALID,
  14. PM_QID_CLOCK_GET_NAME,
  15. PM_QID_CLOCK_GET_TOPOLOGY,
  16. PM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
  17. PM_QID_CLOCK_GET_PARENTS,
  18. PM_QID_CLOCK_GET_ATTRIBUTES,
  19. PM_QID_PINCTRL_GET_NUM_PINS,
  20. PM_QID_PINCTRL_GET_NUM_FUNCTIONS,
  21. PM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS,
  22. PM_QID_PINCTRL_GET_FUNCTION_NAME,
  23. PM_QID_PINCTRL_GET_FUNCTION_GROUPS,
  24. PM_QID_PINCTRL_GET_PIN_GROUPS,
  25. PM_QID_CLOCK_GET_NUM_CLOCKS,
  26. PM_QID_CLOCK_GET_MAX_DIVISOR,
  27. };
  28. enum pm_register_access_id {
  29. CONFIG_REG_WRITE,
  30. CONFIG_REG_READ,
  31. };
  32. /*
  33. * Assigning of argument values into array elements.
  34. */
  35. #define PM_PACK_PAYLOAD1(pl, arg0) { \
  36. pl[0] = (uint32_t)(arg0); \
  37. }
  38. #define PM_PACK_PAYLOAD2(pl, arg0, arg1) { \
  39. pl[1] = (uint32_t)(arg1); \
  40. PM_PACK_PAYLOAD1(pl, arg0); \
  41. }
  42. #define PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2) { \
  43. pl[2] = (uint32_t)(arg2); \
  44. PM_PACK_PAYLOAD2(pl, arg0, arg1); \
  45. }
  46. #define PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3) { \
  47. pl[3] = (uint32_t)(arg3); \
  48. PM_PACK_PAYLOAD3(pl, arg0, arg1, arg2); \
  49. }
  50. #define PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4) { \
  51. pl[4] = (uint32_t)(arg4); \
  52. PM_PACK_PAYLOAD4(pl, arg0, arg1, arg2, arg3); \
  53. }
  54. #define PM_PACK_PAYLOAD6(pl, arg0, arg1, arg2, arg3, arg4, arg5) { \
  55. pl[5] = (uint32_t)(arg5); \
  56. PM_PACK_PAYLOAD5(pl, arg0, arg1, arg2, arg3, arg4); \
  57. }
  58. /**********************************************************
  59. * System-level API function declarations
  60. **********************************************************/
  61. enum pm_ret_status pm_req_suspend(enum pm_node_id target,
  62. enum pm_request_ack ack,
  63. uint32_t latency,
  64. uint32_t state);
  65. enum pm_ret_status pm_self_suspend(enum pm_node_id nid,
  66. uint32_t latency,
  67. uint32_t state,
  68. uintptr_t address);
  69. enum pm_ret_status pm_force_powerdown(enum pm_node_id target,
  70. enum pm_request_ack ack);
  71. enum pm_ret_status pm_abort_suspend(enum pm_abort_reason reason);
  72. enum pm_ret_status pm_req_wakeup(enum pm_node_id target,
  73. uint32_t set_address,
  74. uintptr_t address,
  75. enum pm_request_ack ack);
  76. enum pm_ret_status pm_set_wakeup_source(enum pm_node_id target,
  77. enum pm_node_id wkup_node,
  78. uint32_t enable);
  79. enum pm_ret_status pm_system_shutdown(uint32_t type, uint32_t subtype);
  80. /* API functions for managing PM Slaves */
  81. enum pm_ret_status pm_req_node(enum pm_node_id nid,
  82. uint32_t capabilities,
  83. uint32_t qos,
  84. enum pm_request_ack ack);
  85. enum pm_ret_status pm_set_requirement(enum pm_node_id nid,
  86. uint32_t capabilities,
  87. uint32_t qos,
  88. enum pm_request_ack ack);
  89. /* Miscellaneous API functions */
  90. enum pm_ret_status pm_get_api_version(uint32_t *version);
  91. enum pm_ret_status pm_get_node_status(enum pm_node_id nid,
  92. uint32_t *ret_buff);
  93. /* Direct-Control API functions */
  94. enum pm_ret_status pm_mmio_write(uintptr_t address,
  95. uint32_t mask,
  96. uint32_t value);
  97. enum pm_ret_status pm_mmio_read(uintptr_t address, uint32_t *value);
  98. enum pm_ret_status pm_fpga_load(uint32_t address_low,
  99. uint32_t address_high,
  100. uint32_t size,
  101. uint32_t flags);
  102. enum pm_ret_status pm_fpga_get_status(uint32_t *value);
  103. enum pm_ret_status pm_get_chipid(uint32_t *value);
  104. enum pm_ret_status pm_secure_rsaaes(uint32_t address_low,
  105. uint32_t address_high,
  106. uint32_t size,
  107. uint32_t flags);
  108. uint32_t pm_get_shutdown_scope(void);
  109. enum pm_ret_status pm_get_callbackdata(uint32_t *data, size_t count);
  110. enum pm_ret_status pm_ioctl(enum pm_node_id nid,
  111. uint32_t ioctl_id,
  112. uint32_t arg1,
  113. uint32_t arg2,
  114. uint32_t *value);
  115. enum pm_ret_status pm_clock_enable(uint32_t clock_id);
  116. enum pm_ret_status pm_clock_disable(uint32_t clock_id);
  117. enum pm_ret_status pm_clock_getstate(uint32_t clock_id,
  118. uint32_t *state);
  119. enum pm_ret_status pm_clock_setdivider(uint32_t clock_id,
  120. uint32_t divider);
  121. enum pm_ret_status pm_clock_getdivider(uint32_t clock_id,
  122. uint32_t *divider);
  123. enum pm_ret_status pm_clock_setparent(uint32_t clock_id,
  124. uint32_t parent_index);
  125. enum pm_ret_status pm_clock_getparent(uint32_t clock_id,
  126. uint32_t *parent_index);
  127. void pm_query_data(enum pm_query_ids qid, uint32_t arg1, uint32_t arg2,
  128. uint32_t arg3, uint32_t *data);
  129. enum pm_ret_status pm_sha_hash(uint32_t address_high,
  130. uint32_t address_low,
  131. uint32_t size,
  132. uint32_t flags);
  133. enum pm_ret_status pm_rsa_core(uint32_t address_high,
  134. uint32_t address_low,
  135. uint32_t size,
  136. uint32_t flags);
  137. enum pm_ret_status pm_secure_image(uint32_t address_low,
  138. uint32_t address_high,
  139. uint32_t key_lo,
  140. uint32_t key_hi,
  141. uint32_t *value);
  142. enum pm_ret_status pm_fpga_read(uint32_t reg_numframes,
  143. uint32_t address_low,
  144. uint32_t address_high,
  145. uint32_t readback_type,
  146. uint32_t *value);
  147. enum pm_ret_status pm_aes_engine(uint32_t address_high,
  148. uint32_t address_low,
  149. uint32_t *value);
  150. enum pm_ret_status pm_register_access(uint32_t register_access_id,
  151. uint32_t address,
  152. uint32_t mask,
  153. uint32_t value,
  154. uint32_t *out);
  155. enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
  156. enum pm_pll_param param_id,
  157. uint32_t value);
  158. enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
  159. enum pm_pll_param param_id,
  160. uint32_t *value);
  161. enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode);
  162. enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode);
  163. enum pm_ret_status pm_efuse_access(uint32_t address_high,
  164. uint32_t address_low, uint32_t *value);
  165. enum pm_ret_status pm_feature_check(uint32_t api_id, uint32_t *version,
  166. uint32_t *bit_mask, uint8_t len);
  167. enum pm_ret_status check_api_dependency(uint8_t id);
  168. #endif /* ZYNQMP_PM_API_SYS_H */