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