Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 1 | /* |
Tejas Patel | 5b433b6 | 2020-01-29 22:09:55 -0800 | [diff] [blame] | 2 | * Copyright (c) 2019-2020, Xilinx, Inc. All rights reserved. |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | /* |
| 8 | * Top-level SMC handler for Versal power management calls and |
| 9 | * IPI setup functions for communication with PMC. |
| 10 | */ |
| 11 | |
| 12 | #include <errno.h> |
| 13 | #include <plat_private.h> |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 14 | #include <stdbool.h> |
| 15 | #include <common/runtime_svc.h> |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 16 | #include <plat/common/platform.h> |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 17 | #include "pm_api_sys.h" |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 18 | #include "pm_client.h" |
| 19 | #include "pm_ipi.h" |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 20 | #include <drivers/arm/gicv3.h> |
| 21 | |
| 22 | #define XSCUGIC_SGIR_EL1_INITID_SHIFT 24U |
| 23 | #define INVALID_SGI 0xFF |
| 24 | DEFINE_RENAME_SYSREG_RW_FUNCS(icc_asgi1r_el1, S3_0_C12_C11_6) |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 25 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 26 | /* pm_up = true - UP, pm_up = false - DOWN */ |
| 27 | static bool pm_up; |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 28 | static unsigned int sgi = INVALID_SGI; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 29 | |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 30 | static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle, |
| 31 | void *cookie) |
| 32 | { |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 33 | int cpu; |
| 34 | unsigned int reg; |
| 35 | |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 36 | (void)plat_ic_acknowledge_interrupt(); |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 37 | cpu = plat_my_core_pos() + 1; |
| 38 | |
| 39 | if (sgi != INVALID_SGI) { |
| 40 | reg = (cpu | (sgi << XSCUGIC_SGIR_EL1_INITID_SHIFT)); |
| 41 | write_icc_asgi1r_el1(reg); |
| 42 | } |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 43 | |
| 44 | /* Clear FIQ */ |
| 45 | plat_ic_end_of_interrupt(id); |
| 46 | |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * pm_register_sgi() - PM register the IPI interrupt |
| 52 | * |
| 53 | * @sgi - SGI number to be used for communication. |
| 54 | * @return On success, the initialization function must return 0. |
| 55 | * Any other return value will cause the framework to ignore |
| 56 | * the service |
| 57 | * |
| 58 | * Update the SGI number to be used. |
| 59 | * |
| 60 | */ |
| 61 | int pm_register_sgi(unsigned int sgi_num) |
| 62 | { |
| 63 | if (sgi != INVALID_SGI) { |
| 64 | return -EBUSY; |
| 65 | } |
| 66 | |
| 67 | if (sgi_num >= GICV3_MAX_SGI_TARGETS) { |
| 68 | return -EINVAL; |
| 69 | } |
| 70 | |
| 71 | sgi = sgi_num; |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 75 | /** |
| 76 | * pm_setup() - PM service setup |
| 77 | * |
| 78 | * @return On success, the initialization function must return 0. |
| 79 | * Any other return value will cause the framework to ignore |
| 80 | * the service |
| 81 | * |
| 82 | * Initialization functions for Versal power management for |
| 83 | * communicaton with PMC. |
| 84 | * |
| 85 | * Called from sip_svc_setup initialization function with the |
| 86 | * rt_svc_init signature. |
| 87 | */ |
| 88 | int pm_setup(void) |
| 89 | { |
| 90 | int status, ret = 0; |
| 91 | |
| 92 | status = pm_ipi_init(primary_proc); |
| 93 | |
| 94 | if (status < 0) { |
| 95 | INFO("BL31: PM Service Init Failed, Error Code %d!\n", status); |
| 96 | ret = status; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 97 | } else { |
| 98 | pm_up = true; |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 99 | } |
| 100 | |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 101 | /* |
| 102 | * Enable IPI IRQ |
| 103 | * assume the rich OS is OK to handle callback IRQs now. |
| 104 | * Even if we were wrong, it would not enable the IRQ in |
| 105 | * the GIC. |
| 106 | */ |
| 107 | pm_ipi_irq_enable(primary_proc); |
| 108 | |
| 109 | ret = request_intr_type_el3(PLAT_VERSAL_IPI_IRQ, ipi_fiq_handler); |
| 110 | if (ret) { |
| 111 | WARN("BL31: registering IPI interrupt failed\n"); |
| 112 | } |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 113 | return ret; |
| 114 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * pm_smc_handler() - SMC handler for PM-API calls coming from EL1/EL2. |
| 118 | * @smc_fid - Function Identifier |
| 119 | * @x1 - x4 - Arguments |
| 120 | * @cookie - Unused |
| 121 | * @handler - Pointer to caller's context structure |
| 122 | * |
| 123 | * @return - Unused |
| 124 | * |
| 125 | * Determines that smc_fid is valid and supported PM SMC Function ID from the |
| 126 | * list of pm_api_ids, otherwise completes the request with |
| 127 | * the unknown SMC Function ID |
| 128 | * |
| 129 | * The SMC calls for PM service are forwarded from SIP Service SMC handler |
| 130 | * function with rt_svc_handle signature |
| 131 | */ |
| 132 | uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3, |
| 133 | uint64_t x4, void *cookie, void *handle, uint64_t flags) |
| 134 | { |
| 135 | enum pm_ret_status ret; |
| 136 | |
| 137 | uint32_t pm_arg[4]; |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 138 | uint32_t security_flag = SECURE_FLAG; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 139 | |
| 140 | /* Handle case where PM wasn't initialized properly */ |
| 141 | if (!pm_up) |
| 142 | SMC_RET1(handle, SMC_UNK); |
| 143 | |
| 144 | pm_arg[0] = (uint32_t)x1; |
| 145 | pm_arg[1] = (uint32_t)(x1 >> 32); |
| 146 | pm_arg[2] = (uint32_t)x2; |
| 147 | pm_arg[3] = (uint32_t)(x2 >> 32); |
| 148 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 149 | /* |
| 150 | * Mark BIT24 payload (i.e 1st bit of pm_arg[3] ) as non-secure (1) |
| 151 | * if smc called is non secure |
| 152 | */ |
| 153 | if (is_caller_non_secure(flags)) { |
| 154 | security_flag = NON_SECURE_FLAG; |
| 155 | } |
| 156 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 157 | switch (smc_fid & FUNCID_NUM_MASK) { |
| 158 | /* PM API Functions */ |
| 159 | case PM_SELF_SUSPEND: |
| 160 | ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2], |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 161 | pm_arg[3], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 162 | SMC_RET1(handle, (uint64_t)ret); |
| 163 | |
Tejas Patel | 6b28225 | 2019-01-10 03:03:47 -0800 | [diff] [blame] | 164 | case PM_FORCE_POWERDOWN: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 165 | ret = pm_force_powerdown(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 6b28225 | 2019-01-10 03:03:47 -0800 | [diff] [blame] | 166 | SMC_RET1(handle, (uint64_t)ret); |
| 167 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 168 | case PM_REQ_SUSPEND: |
| 169 | ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2], |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 170 | pm_arg[3], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 171 | SMC_RET1(handle, (uint64_t)ret); |
| 172 | |
| 173 | case PM_ABORT_SUSPEND: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 174 | ret = pm_abort_suspend(pm_arg[0], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 175 | SMC_RET1(handle, (uint64_t)ret); |
| 176 | |
Tejas Patel | 6b28225 | 2019-01-10 03:03:47 -0800 | [diff] [blame] | 177 | case PM_SYSTEM_SHUTDOWN: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 178 | ret = pm_system_shutdown(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 6b28225 | 2019-01-10 03:03:47 -0800 | [diff] [blame] | 179 | SMC_RET1(handle, (uint64_t)ret); |
| 180 | |
Tejas Patel | 49cd871 | 2019-01-23 14:18:51 +0530 | [diff] [blame] | 181 | case PM_REQ_WAKEUP: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 182 | ret = pm_req_wakeup(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3], |
| 183 | security_flag); |
Tejas Patel | 49cd871 | 2019-01-23 14:18:51 +0530 | [diff] [blame] | 184 | SMC_RET1(handle, (uint64_t)ret); |
| 185 | |
Tejas Patel | db81205 | 2019-01-23 14:18:53 +0530 | [diff] [blame] | 186 | case PM_SET_WAKEUP_SOURCE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 187 | ret = pm_set_wakeup_source(pm_arg[0], pm_arg[1], pm_arg[2], |
| 188 | security_flag); |
Tejas Patel | db81205 | 2019-01-23 14:18:53 +0530 | [diff] [blame] | 189 | SMC_RET1(handle, (uint64_t)ret); |
| 190 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 191 | case PM_REQUEST_DEVICE: |
| 192 | ret = pm_request_device(pm_arg[0], pm_arg[1], pm_arg[2], |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 193 | pm_arg[3], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 194 | SMC_RET1(handle, (uint64_t)ret); |
| 195 | |
| 196 | case PM_RELEASE_DEVICE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 197 | ret = pm_release_device(pm_arg[0], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 198 | SMC_RET1(handle, (uint64_t)ret); |
| 199 | |
| 200 | case PM_SET_REQUIREMENT: |
| 201 | ret = pm_set_requirement(pm_arg[0], pm_arg[1], pm_arg[2], |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 202 | pm_arg[3], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 203 | SMC_RET1(handle, (uint64_t)ret); |
| 204 | |
| 205 | case PM_GET_API_VERSION: |
| 206 | { |
| 207 | uint32_t api_version; |
| 208 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 209 | ret = pm_get_api_version(&api_version, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 210 | SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS | |
| 211 | ((uint64_t)api_version << 32)); |
| 212 | } |
| 213 | |
| 214 | case PM_GET_DEVICE_STATUS: |
| 215 | { |
| 216 | uint32_t buff[3]; |
| 217 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 218 | ret = pm_get_device_status(pm_arg[0], buff, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 219 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)buff[0] << 32), |
| 220 | (uint64_t)buff[1] | ((uint64_t)buff[2] << 32)); |
| 221 | } |
| 222 | |
| 223 | case PM_RESET_ASSERT: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 224 | ret = pm_reset_assert(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 225 | SMC_RET1(handle, (uint64_t)ret); |
| 226 | |
| 227 | case PM_RESET_GET_STATUS: |
| 228 | { |
| 229 | uint32_t reset_status; |
| 230 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 231 | ret = pm_reset_get_status(pm_arg[0], &reset_status, |
| 232 | security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 233 | SMC_RET1(handle, (uint64_t)ret | |
| 234 | ((uint64_t)reset_status << 32)); |
| 235 | } |
| 236 | |
Tejas Patel | 0266202 | 2019-01-21 17:56:49 +0530 | [diff] [blame] | 237 | case PM_INIT_FINALIZE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 238 | ret = pm_init_finalize(security_flag); |
Ravi Patel | 476b5b1 | 2019-08-12 03:10:10 -0700 | [diff] [blame] | 239 | SMC_RET1(handle, (uint64_t)ret); |
Tejas Patel | 0266202 | 2019-01-21 17:56:49 +0530 | [diff] [blame] | 240 | |
Rajan Vaja | 649e924 | 2019-03-04 11:09:40 +0530 | [diff] [blame] | 241 | case PM_GET_CALLBACK_DATA: |
| 242 | { |
| 243 | uint32_t result[4] = {0}; |
| 244 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 245 | pm_get_callbackdata(result, ARRAY_SIZE(result), security_flag); |
Rajan Vaja | 649e924 | 2019-03-04 11:09:40 +0530 | [diff] [blame] | 246 | SMC_RET2(handle, |
| 247 | (uint64_t)result[0] | ((uint64_t)result[1] << 32), |
| 248 | (uint64_t)result[2] | ((uint64_t)result[3] << 32)); |
| 249 | } |
| 250 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 251 | case PM_PINCTRL_REQUEST: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 252 | ret = pm_pinctrl_request(pm_arg[0], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 253 | SMC_RET1(handle, (uint64_t)ret); |
| 254 | |
| 255 | case PM_PINCTRL_RELEASE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 256 | ret = pm_pinctrl_release(pm_arg[0], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 257 | SMC_RET1(handle, (uint64_t)ret); |
| 258 | |
| 259 | case PM_PINCTRL_GET_FUNCTION: |
| 260 | { |
| 261 | uint32_t value = 0; |
| 262 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 263 | ret = pm_pinctrl_get_function(pm_arg[0], &value, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 264 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32); |
| 265 | } |
| 266 | |
| 267 | case PM_PINCTRL_SET_FUNCTION: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 268 | ret = pm_pinctrl_set_function(pm_arg[0], pm_arg[1], |
| 269 | security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 270 | SMC_RET1(handle, (uint64_t)ret); |
| 271 | |
| 272 | case PM_PINCTRL_CONFIG_PARAM_GET: |
| 273 | { |
| 274 | uint32_t value; |
| 275 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 276 | ret = pm_pinctrl_get_pin_param(pm_arg[0], pm_arg[1], &value, |
| 277 | security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 278 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32); |
| 279 | } |
| 280 | |
| 281 | case PM_PINCTRL_CONFIG_PARAM_SET: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 282 | ret = pm_pinctrl_set_pin_param(pm_arg[0], pm_arg[1], pm_arg[2], |
| 283 | security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 284 | SMC_RET1(handle, (uint64_t)ret); |
| 285 | |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 286 | case PM_IOCTL: |
| 287 | { |
| 288 | uint32_t value; |
| 289 | |
| 290 | ret = pm_api_ioctl(pm_arg[0], pm_arg[1], pm_arg[2], |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 291 | pm_arg[3], &value, security_flag); |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 292 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32); |
| 293 | } |
| 294 | |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 295 | case PM_QUERY_DATA: |
| 296 | { |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 297 | uint32_t data[8] = { 0 }; |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 298 | |
| 299 | ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2], |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 300 | pm_arg[3], data, security_flag); |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 301 | |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 302 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)data[0] << 32), |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 303 | (uint64_t)data[1] | ((uint64_t)data[2] << 32)); |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 304 | |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 305 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 306 | case PM_CLOCK_ENABLE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 307 | ret = pm_clock_enable(pm_arg[0], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 308 | SMC_RET1(handle, (uint64_t)ret); |
| 309 | |
| 310 | case PM_CLOCK_DISABLE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 311 | ret = pm_clock_disable(pm_arg[0], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 312 | SMC_RET1(handle, (uint64_t)ret); |
| 313 | |
| 314 | case PM_CLOCK_GETSTATE: |
| 315 | { |
| 316 | uint32_t value; |
| 317 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 318 | ret = pm_clock_get_state(pm_arg[0], &value, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 319 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32); |
| 320 | } |
| 321 | |
| 322 | case PM_CLOCK_SETDIVIDER: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 323 | ret = pm_clock_set_divider(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 324 | SMC_RET1(handle, (uint64_t)ret); |
| 325 | |
| 326 | case PM_CLOCK_GETDIVIDER: |
| 327 | { |
| 328 | uint32_t value; |
| 329 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 330 | ret = pm_clock_get_divider(pm_arg[0], &value, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 331 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32); |
| 332 | } |
| 333 | |
| 334 | case PM_CLOCK_SETPARENT: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 335 | ret = pm_clock_set_parent(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 336 | SMC_RET1(handle, (uint64_t)ret); |
| 337 | |
| 338 | case PM_CLOCK_GETPARENT: |
| 339 | { |
| 340 | uint32_t value; |
| 341 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 342 | ret = pm_clock_get_parent(pm_arg[0], &value, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 343 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32); |
| 344 | } |
| 345 | |
Tejas Patel | 84275bf | 2020-09-01 04:43:53 -0700 | [diff] [blame] | 346 | case PM_CLOCK_GETRATE: |
| 347 | { |
| 348 | uint32_t rate[2] = { 0 }; |
| 349 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 350 | ret = pm_clock_get_rate(pm_arg[0], rate, security_flag); |
Tejas Patel | 84275bf | 2020-09-01 04:43:53 -0700 | [diff] [blame] | 351 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)rate[0] << 32), |
| 352 | rate[1]); |
| 353 | } |
| 354 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 355 | case PM_PLL_SET_PARAMETER: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 356 | ret = pm_pll_set_param(pm_arg[0], pm_arg[1], pm_arg[2], |
| 357 | security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 358 | SMC_RET1(handle, (uint64_t)ret); |
| 359 | |
| 360 | case PM_PLL_GET_PARAMETER: |
| 361 | { |
| 362 | uint32_t value; |
| 363 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 364 | ret = pm_pll_get_param(pm_arg[0], pm_arg[1], &value, |
| 365 | security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 366 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32)); |
| 367 | } |
| 368 | |
| 369 | case PM_PLL_SET_MODE: |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 370 | ret = pm_pll_set_mode(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 371 | SMC_RET1(handle, (uint64_t)ret); |
| 372 | |
| 373 | case PM_PLL_GET_MODE: |
| 374 | { |
| 375 | uint32_t mode; |
| 376 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 377 | ret = pm_pll_get_mode(pm_arg[0], &mode, security_flag); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 378 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32)); |
| 379 | } |
| 380 | |
Tejas Patel | 044001d | 2019-01-21 17:56:48 +0530 | [diff] [blame] | 381 | case PM_GET_TRUSTZONE_VERSION: |
| 382 | SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS | |
| 383 | ((uint64_t)VERSAL_TZ_VERSION << 32)); |
| 384 | |
Ravi Patel | bd4aa5a | 2019-08-12 03:17:54 -0700 | [diff] [blame] | 385 | case PM_GET_CHIPID: |
| 386 | { |
| 387 | uint32_t result[2]; |
| 388 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 389 | ret = pm_get_chipid(result, security_flag); |
Ravi Patel | bd4aa5a | 2019-08-12 03:17:54 -0700 | [diff] [blame] | 390 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32), |
| 391 | result[1]); |
| 392 | } |
| 393 | |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 394 | case PM_FEATURE_CHECK: |
| 395 | { |
| 396 | uint32_t version; |
| 397 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 398 | ret = pm_feature_check(pm_arg[0], &version, security_flag); |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 399 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)version << 32)); |
| 400 | } |
| 401 | |
Jolly Shah | ed05a71 | 2019-03-22 05:33:39 +0530 | [diff] [blame] | 402 | case PM_LOAD_PDI: |
| 403 | { |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 404 | ret = pm_load_pdi(pm_arg[0], pm_arg[1], pm_arg[2], |
| 405 | security_flag); |
Jolly Shah | ed05a71 | 2019-03-22 05:33:39 +0530 | [diff] [blame] | 406 | SMC_RET1(handle, (uint64_t)ret); |
| 407 | } |
| 408 | |
Saeed Nowshadi | 2294b42 | 2019-06-03 10:22:35 -0700 | [diff] [blame] | 409 | case PM_GET_OP_CHARACTERISTIC: |
| 410 | { |
| 411 | uint32_t result; |
| 412 | |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 413 | ret = pm_get_op_characteristic(pm_arg[0], pm_arg[1], &result, |
| 414 | security_flag); |
Saeed Nowshadi | 2294b42 | 2019-06-03 10:22:35 -0700 | [diff] [blame] | 415 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)result << 32)); |
| 416 | } |
| 417 | |
Tejas Patel | 5c154e1 | 2020-11-25 01:53:12 -0800 | [diff] [blame] | 418 | case PM_SET_MAX_LATENCY: |
| 419 | { |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 420 | ret = pm_set_max_latency(pm_arg[0], pm_arg[1], security_flag); |
Tejas Patel | 5c154e1 | 2020-11-25 01:53:12 -0800 | [diff] [blame] | 421 | SMC_RET1(handle, (uint64_t)ret); |
| 422 | } |
| 423 | |
Tejas Patel | 4201555 | 2020-11-25 01:56:57 -0800 | [diff] [blame] | 424 | case PM_REGISTER_NOTIFIER: |
| 425 | { |
Tejas Patel | 18072da | 2021-02-25 20:16:56 -0800 | [diff] [blame] | 426 | ret = pm_register_notifier(pm_arg[0], pm_arg[1], pm_arg[2], |
| 427 | pm_arg[3], security_flag); |
Tejas Patel | 4201555 | 2020-11-25 01:56:57 -0800 | [diff] [blame] | 428 | SMC_RET1(handle, (uint64_t)ret); |
| 429 | } |
| 430 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 431 | default: |
| 432 | WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid); |
| 433 | SMC_RET1(handle, SMC_UNK); |
| 434 | } |
| 435 | } |