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