pm_defs.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. /* Versal power management enums and defines */
  8. #ifndef PM_DEFS_H
  9. #define PM_DEFS_H
  10. #include "pm_node.h"
  11. /*********************************************************************
  12. * Macro definitions
  13. ********************************************************************/
  14. /* State arguments of the self suspend */
  15. #define PM_STATE_CPU_IDLE 0x0U
  16. #define PM_STATE_CPU_OFF 0x1U
  17. #define PM_STATE_SUSPEND_TO_RAM 0xFU
  18. #define MAX_LATENCY (~0U)
  19. #define MAX_QOS 100U
  20. /* Processor core device IDs */
  21. #define APU_DEVID(IDX) NODEID(XPM_NODECLASS_DEVICE, XPM_NODESUBCL_DEV_CORE, \
  22. XPM_NODETYPE_DEV_CORE_APU, (IDX))
  23. #define XPM_DEVID_ACPU_0 APU_DEVID(XPM_NODEIDX_DEV_ACPU_0)
  24. #define XPM_DEVID_ACPU_1 APU_DEVID(XPM_NODEIDX_DEV_ACPU_1)
  25. #define PERIPH_DEVID(IDX) NODEID((uint32_t)XPM_NODECLASS_DEVICE, \
  26. (uint32_t)XPM_NODESUBCL_DEV_PERIPH, \
  27. (uint32_t)XPM_NODETYPE_DEV_PERIPH, (IDX))
  28. #define TF_A_FEATURE_CHECK 0xa00U
  29. #define PM_GET_CALLBACK_DATA 0xa01U
  30. #define PM_GET_TRUSTZONE_VERSION 0xa03U
  31. #define TF_A_PM_REGISTER_SGI 0xa04U
  32. /* PM API Versions */
  33. #define PM_API_BASE_VERSION 1U
  34. #define PM_API_VERSION_2 2U
  35. /* Loader API ids */
  36. #define PM_LOAD_PDI 0x701U
  37. #define PM_LOAD_GET_HANDOFF_PARAMS 0x70BU
  38. /* System shutdown macros */
  39. #define XPM_SHUTDOWN_TYPE_SHUTDOWN 0U
  40. #define XPM_SHUTDOWN_TYPE_RESET 1U
  41. #define XPM_SHUTDOWN_TYPE_SETSCOPE_ONLY 2U
  42. #define XPM_SHUTDOWN_SUBTYPE_RST_SUBSYSTEM 0U
  43. #define XPM_SHUTDOWN_SUBTYPE_RST_PS_ONLY 1U
  44. #define XPM_SHUTDOWN_SUBTYPE_RST_SYSTEM 2U
  45. /*********************************************************************
  46. * Enum definitions
  47. ********************************************************************/
  48. /*
  49. * ioctl id
  50. */
  51. enum {
  52. IOCTL_GET_RPU_OPER_MODE = 0,
  53. IOCTL_SET_RPU_OPER_MODE = 1,
  54. IOCTL_RPU_BOOT_ADDR_CONFIG = 2,
  55. IOCTL_TCM_COMB_CONFIG = 3,
  56. IOCTL_SET_TAPDELAY_BYPASS = 4,
  57. IOCTL_SD_DLL_RESET = 6,
  58. IOCTL_SET_SD_TAPDELAY = 7,
  59. /* Ioctl for clock driver */
  60. IOCTL_SET_PLL_FRAC_MODE = 8,
  61. IOCTL_GET_PLL_FRAC_MODE = 9,
  62. IOCTL_SET_PLL_FRAC_DATA = 10,
  63. IOCTL_GET_PLL_FRAC_DATA = 11,
  64. IOCTL_WRITE_GGS = 12,
  65. IOCTL_READ_GGS = 13,
  66. IOCTL_WRITE_PGGS = 14,
  67. IOCTL_READ_PGGS = 15,
  68. /* IOCTL for ULPI reset */
  69. IOCTL_ULPI_RESET = 16,
  70. /* Set healthy bit value */
  71. IOCTL_SET_BOOT_HEALTH_STATUS = 17,
  72. IOCTL_AFI = 18,
  73. /* Probe counter read/write */
  74. IOCTL_PROBE_COUNTER_READ = 19,
  75. IOCTL_PROBE_COUNTER_WRITE = 20,
  76. IOCTL_OSPI_MUX_SELECT = 21,
  77. /* IOCTL for USB power request */
  78. IOCTL_USB_SET_STATE = 22,
  79. /* IOCTL to get last reset reason */
  80. IOCTL_GET_LAST_RESET_REASON = 23,
  81. /* AI engine NPI ISR clear */
  82. IOCTL_AIE_ISR_CLEAR = 24,
  83. IOCTL_UFS_TXRX_CFGRDY_GET = 40,
  84. IOCTL_UFS_SRAM_CSR_SEL = 41,
  85. };
  86. /**
  87. * enum pm_pll_param - enum represents the parameters for a phase-locked loop.
  88. * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL.
  89. * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL.
  90. * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL.
  91. * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input.
  92. * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode.
  93. * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize.
  94. * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting.
  95. * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control.
  96. * @PM_PLL_PARAM_CP: PLL charge pump control.
  97. * @PM_PLL_PARAM_RES: PLL loop filter resistor control.
  98. * @PM_PLL_PARAM_MAX: Represents the maximum parameter value for the PLL
  99. */
  100. enum pm_pll_param {
  101. PM_PLL_PARAM_DIV2,
  102. PM_PLL_PARAM_FBDIV,
  103. PM_PLL_PARAM_DATA,
  104. PM_PLL_PARAM_PRE_SRC,
  105. PM_PLL_PARAM_POST_SRC,
  106. PM_PLL_PARAM_LOCK_DLY,
  107. PM_PLL_PARAM_LOCK_CNT,
  108. PM_PLL_PARAM_LFHF,
  109. PM_PLL_PARAM_CP,
  110. PM_PLL_PARAM_RES,
  111. PM_PLL_PARAM_MAX,
  112. };
  113. enum pm_api_id {
  114. /* Miscellaneous API functions: */
  115. PM_GET_API_VERSION = 1, /* Do not change or move */
  116. PM_SET_CONFIGURATION,
  117. PM_GET_NODE_STATUS,
  118. PM_GET_OP_CHARACTERISTIC,
  119. PM_REGISTER_NOTIFIER,
  120. /* API for suspending of PUs: */
  121. PM_REQ_SUSPEND,
  122. PM_SELF_SUSPEND,
  123. PM_FORCE_POWERDOWN,
  124. PM_ABORT_SUSPEND,
  125. PM_REQ_WAKEUP,
  126. PM_SET_WAKEUP_SOURCE,
  127. PM_SYSTEM_SHUTDOWN,
  128. /* API for managing PM slaves: */
  129. PM_REQ_NODE,
  130. PM_RELEASE_NODE,
  131. PM_SET_REQUIREMENT,
  132. PM_SET_MAX_LATENCY,
  133. /* Direct control API functions: */
  134. PM_RESET_ASSERT,
  135. PM_RESET_GET_STATUS,
  136. PM_MMIO_WRITE,
  137. PM_MMIO_READ,
  138. PM_INIT_FINALIZE,
  139. PM_FPGA_LOAD,
  140. PM_FPGA_GET_STATUS,
  141. PM_GET_CHIPID,
  142. PM_SECURE_RSA_AES,
  143. PM_SECURE_SHA,
  144. PM_SECURE_RSA,
  145. PM_PINCTRL_REQUEST,
  146. PM_PINCTRL_RELEASE,
  147. PM_PINCTRL_GET_FUNCTION,
  148. PM_PINCTRL_SET_FUNCTION,
  149. PM_PINCTRL_CONFIG_PARAM_GET,
  150. PM_PINCTRL_CONFIG_PARAM_SET,
  151. PM_IOCTL,
  152. /* API to query information from firmware */
  153. PM_QUERY_DATA,
  154. /* Clock control API functions */
  155. PM_CLOCK_ENABLE,
  156. PM_CLOCK_DISABLE,
  157. PM_CLOCK_GETSTATE,
  158. PM_CLOCK_SETDIVIDER,
  159. PM_CLOCK_GETDIVIDER,
  160. PM_CLOCK_SETPARENT = 43,
  161. PM_CLOCK_GETPARENT,
  162. PM_SECURE_IMAGE,
  163. /* FPGA PL Readback */
  164. PM_FPGA_READ,
  165. PM_SECURE_AES,
  166. /* PLL control API functions */
  167. PM_PLL_SET_PARAMETER,
  168. PM_PLL_GET_PARAMETER,
  169. PM_PLL_SET_MODE,
  170. PM_PLL_GET_MODE,
  171. /* PM Register Access API */
  172. PM_REGISTER_ACCESS,
  173. PM_EFUSE_ACCESS,
  174. PM_FPGA_GET_VERSION,
  175. PM_FPGA_GET_FEATURE_LIST,
  176. PM_FEATURE_CHECK = 63,
  177. PM_API_MAX = 74
  178. };
  179. enum pm_abort_reason {
  180. ABORT_REASON_WKUP_EVENT = 100,
  181. ABORT_REASON_PU_BUSY,
  182. ABORT_REASON_NO_PWRDN,
  183. ABORT_REASON_UNKNOWN,
  184. };
  185. enum pm_opchar_type {
  186. PM_OPCHAR_TYPE_POWER = 1,
  187. PM_OPCHAR_TYPE_TEMP,
  188. PM_OPCHAR_TYPE_LATENCY,
  189. };
  190. /*
  191. * Subsystem IDs
  192. */
  193. typedef enum {
  194. XPM_SUBSYSID_PMC,
  195. XPM_SUBSYSID_PSM,
  196. XPM_SUBSYSID_APU,
  197. XPM_SUBSYSID_RPU0_LOCK,
  198. XPM_SUBSYSID_RPU0_0,
  199. XPM_SUBSYSID_RPU0_1,
  200. XPM_SUBSYSID_DDR0,
  201. XPM_SUBSYSID_ME,
  202. XPM_SUBSYSID_PL,
  203. XPM_SUBSYSID_MAX,
  204. } XPm_SubsystemId;
  205. /* TODO: move pm_ret_status from device specific location to common location */
  206. /**
  207. * enum pm_ret_status - enum represents the return status codes for a PM
  208. * operation.
  209. * @PM_RET_SUCCESS: success.
  210. * @PM_RET_ERROR_ARGS: illegal arguments provided (deprecated).
  211. * @PM_RET_ERROR_NOTSUPPORTED: feature not supported (deprecated).
  212. * @PM_RET_ERROR_NOFEATURE: feature is not available.
  213. * @PM_RET_ERROR_INVALID_CRC: invalid crc in IPI communication.
  214. * @PM_RET_ERROR_NOT_ENABLED: feature is not enabled.
  215. * @PM_RET_ERROR_INTERNAL: internal error.
  216. * @PM_RET_ERROR_CONFLICT: conflict.
  217. * @PM_RET_ERROR_ACCESS: access rights violation.
  218. * @PM_RET_ERROR_INVALID_NODE: invalid node.
  219. * @PM_RET_ERROR_DOUBLE_REQ: duplicate request for same node.
  220. * @PM_RET_ERROR_ABORT_SUSPEND: suspend procedure has been aborted.
  221. * @PM_RET_ERROR_TIMEOUT: timeout in communication with PMU.
  222. * @PM_RET_ERROR_NODE_USED: node is already in use.
  223. * @PM_RET_ERROR_NO_FEATURE: indicates that the requested feature is not
  224. * supported.
  225. */
  226. enum pm_ret_status {
  227. PM_RET_SUCCESS,
  228. PM_RET_ERROR_ARGS = 1,
  229. PM_RET_ERROR_NOTSUPPORTED = 4,
  230. PM_RET_ERROR_NOFEATURE = 19,
  231. PM_RET_ERROR_INVALID_CRC = 301,
  232. PM_RET_ERROR_NOT_ENABLED = 29,
  233. PM_RET_ERROR_INTERNAL = 2000,
  234. PM_RET_ERROR_CONFLICT = 2001,
  235. PM_RET_ERROR_ACCESS = 2002,
  236. PM_RET_ERROR_INVALID_NODE = 2003,
  237. PM_RET_ERROR_DOUBLE_REQ = 2004,
  238. PM_RET_ERROR_ABORT_SUSPEND = 2005,
  239. PM_RET_ERROR_TIMEOUT = 2006,
  240. PM_RET_ERROR_NODE_USED = 2007,
  241. PM_RET_ERROR_NO_FEATURE = 2008
  242. };
  243. /*
  244. * Qids
  245. */
  246. enum pm_query_id {
  247. XPM_QID_INVALID,
  248. XPM_QID_CLOCK_GET_NAME,
  249. XPM_QID_CLOCK_GET_TOPOLOGY,
  250. XPM_QID_CLOCK_GET_FIXEDFACTOR_PARAMS,
  251. XPM_QID_CLOCK_GET_MUXSOURCES,
  252. XPM_QID_CLOCK_GET_ATTRIBUTES,
  253. XPM_QID_PINCTRL_GET_NUM_PINS,
  254. XPM_QID_PINCTRL_GET_NUM_FUNCTIONS,
  255. XPM_QID_PINCTRL_GET_NUM_FUNCTION_GROUPS,
  256. XPM_QID_PINCTRL_GET_FUNCTION_NAME,
  257. XPM_QID_PINCTRL_GET_FUNCTION_GROUPS,
  258. XPM_QID_PINCTRL_GET_PIN_GROUPS,
  259. XPM_QID_CLOCK_GET_NUM_CLOCKS,
  260. XPM_QID_CLOCK_GET_MAX_DIVISOR,
  261. XPM_QID_PLD_GET_PARENT,
  262. };
  263. #endif /* PM_DEFS_H */