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