blob: b082acbd50178c1123f9c305fb217f8e5fe01315 [file] [log] [blame]
Tejas Patel354fe572018-12-14 00:55:37 -08001/*
Abhyuday Godhasaraddc46622021-08-05 03:14:17 -07002 * Copyright (c) 2019-2021, Xilinx, Inc. All rights reserved.
Tejas Patel354fe572018-12-14 00:55:37 -08003 *
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 Patel59c608a2019-01-09 04:10:29 -080014#include <stdbool.h>
15#include <common/runtime_svc.h>
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053016#include <plat/common/platform.h>
Tejas Patel59c608a2019-01-09 04:10:29 -080017#include "pm_api_sys.h"
Tejas Patel354fe572018-12-14 00:55:37 -080018#include "pm_client.h"
19#include "pm_ipi.h"
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060020#include <drivers/arm/gicv3.h>
21
22#define XSCUGIC_SGIR_EL1_INITID_SHIFT 24U
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070023#define INVALID_SGI 0xFFU
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060024DEFINE_RENAME_SYSREG_RW_FUNCS(icc_asgi1r_el1, S3_0_C12_C11_6)
Tejas Patel354fe572018-12-14 00:55:37 -080025
Tejas Patel59c608a2019-01-09 04:10:29 -080026/* pm_up = true - UP, pm_up = false - DOWN */
27static bool pm_up;
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070028static unsigned int sgi = (unsigned int)INVALID_SGI;
Tejas Patel59c608a2019-01-09 04:10:29 -080029
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053030static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
31 void *cookie)
32{
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070033 unsigned int cpu;
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060034 unsigned int reg;
35
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053036 (void)plat_ic_acknowledge_interrupt();
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070037 cpu = plat_my_core_pos() + 1U;
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060038
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070039 if ((unsigned int)sgi != (unsigned int)INVALID_SGI) {
40 reg = (cpu | ((unsigned int)sgi << (unsigned int)XSCUGIC_SGIR_EL1_INITID_SHIFT));
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060041 write_icc_asgi1r_el1(reg);
42 }
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053043
44 /* Clear FIQ */
45 plat_ic_end_of_interrupt(id);
46
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060047 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 */
61int pm_register_sgi(unsigned int sgi_num)
62{
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070063 if ((unsigned int)sgi != (unsigned int)INVALID_SGI) {
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060064 return -EBUSY;
65 }
66
67 if (sgi_num >= GICV3_MAX_SGI_TARGETS) {
68 return -EINVAL;
69 }
70
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070071 sgi = (unsigned int)sgi_num;
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053072 return 0;
73}
74
Tejas Patel354fe572018-12-14 00:55:37 -080075/**
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 */
88int 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 Patel59c608a2019-01-09 04:10:29 -080097 } else {
98 pm_up = true;
Tejas Patel354fe572018-12-14 00:55:37 -080099 }
100
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +0530101 /*
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);
Abhyuday Godhasara44877942021-08-05 02:59:26 -0700110 if (ret != 0) {
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +0530111 WARN("BL31: registering IPI interrupt failed\n");
112 }
Tejas Patel354fe572018-12-14 00:55:37 -0800113 return ret;
114}
Tejas Patel59c608a2019-01-09 04:10:29 -0800115
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 */
132uint64_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 Patel18072da2021-02-25 20:16:56 -0800138 uint32_t security_flag = SECURE_FLAG;
Tejas Patel59c608a2019-01-09 04:10:29 -0800139
140 /* Handle case where PM wasn't initialized properly */
Abhyuday Godhasara44877942021-08-05 02:59:26 -0700141 if (pm_up == false) {
Tejas Patel59c608a2019-01-09 04:10:29 -0800142 SMC_RET1(handle, SMC_UNK);
Abhyuday Godhasaraddc46622021-08-05 03:14:17 -0700143 }
Tejas Patel59c608a2019-01-09 04:10:29 -0800144
145 pm_arg[0] = (uint32_t)x1;
146 pm_arg[1] = (uint32_t)(x1 >> 32);
147 pm_arg[2] = (uint32_t)x2;
148 pm_arg[3] = (uint32_t)(x2 >> 32);
149
Tejas Patel18072da2021-02-25 20:16:56 -0800150 /*
151 * Mark BIT24 payload (i.e 1st bit of pm_arg[3] ) as non-secure (1)
152 * if smc called is non secure
153 */
Abhyuday Godhasara44877942021-08-05 02:59:26 -0700154 if (is_caller_non_secure(flags) != 0) {
Tejas Patel18072da2021-02-25 20:16:56 -0800155 security_flag = NON_SECURE_FLAG;
156 }
157
Tejas Patel59c608a2019-01-09 04:10:29 -0800158 switch (smc_fid & FUNCID_NUM_MASK) {
159 /* PM API Functions */
160 case PM_SELF_SUSPEND:
161 ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
Tejas Patel18072da2021-02-25 20:16:56 -0800162 pm_arg[3], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800163 SMC_RET1(handle, (uint64_t)ret);
164
Tejas Patel6b282252019-01-10 03:03:47 -0800165 case PM_FORCE_POWERDOWN:
Tejas Patel18072da2021-02-25 20:16:56 -0800166 ret = pm_force_powerdown(pm_arg[0], pm_arg[1], security_flag);
Tejas Patel6b282252019-01-10 03:03:47 -0800167 SMC_RET1(handle, (uint64_t)ret);
168
Tejas Patel59c608a2019-01-09 04:10:29 -0800169 case PM_REQ_SUSPEND:
170 ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
Tejas Patel18072da2021-02-25 20:16:56 -0800171 pm_arg[3], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800172 SMC_RET1(handle, (uint64_t)ret);
173
174 case PM_ABORT_SUSPEND:
Tejas Patel18072da2021-02-25 20:16:56 -0800175 ret = pm_abort_suspend(pm_arg[0], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800176 SMC_RET1(handle, (uint64_t)ret);
177
Tejas Patel6b282252019-01-10 03:03:47 -0800178 case PM_SYSTEM_SHUTDOWN:
Tejas Patel18072da2021-02-25 20:16:56 -0800179 ret = pm_system_shutdown(pm_arg[0], pm_arg[1], security_flag);
Tejas Patel6b282252019-01-10 03:03:47 -0800180 SMC_RET1(handle, (uint64_t)ret);
181
Tejas Patel49cd8712019-01-23 14:18:51 +0530182 case PM_REQ_WAKEUP:
Tejas Patel18072da2021-02-25 20:16:56 -0800183 ret = pm_req_wakeup(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3],
184 security_flag);
Tejas Patel49cd8712019-01-23 14:18:51 +0530185 SMC_RET1(handle, (uint64_t)ret);
186
Tejas Pateldb812052019-01-23 14:18:53 +0530187 case PM_SET_WAKEUP_SOURCE:
Tejas Patel18072da2021-02-25 20:16:56 -0800188 ret = pm_set_wakeup_source(pm_arg[0], pm_arg[1], pm_arg[2],
189 security_flag);
Tejas Pateldb812052019-01-23 14:18:53 +0530190 SMC_RET1(handle, (uint64_t)ret);
191
Tejas Patel59c608a2019-01-09 04:10:29 -0800192 case PM_REQUEST_DEVICE:
193 ret = pm_request_device(pm_arg[0], pm_arg[1], pm_arg[2],
Tejas Patel18072da2021-02-25 20:16:56 -0800194 pm_arg[3], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800195 SMC_RET1(handle, (uint64_t)ret);
196
197 case PM_RELEASE_DEVICE:
Tejas Patel18072da2021-02-25 20:16:56 -0800198 ret = pm_release_device(pm_arg[0], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800199 SMC_RET1(handle, (uint64_t)ret);
200
201 case PM_SET_REQUIREMENT:
202 ret = pm_set_requirement(pm_arg[0], pm_arg[1], pm_arg[2],
Tejas Patel18072da2021-02-25 20:16:56 -0800203 pm_arg[3], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800204 SMC_RET1(handle, (uint64_t)ret);
205
206 case PM_GET_API_VERSION:
207 {
208 uint32_t api_version;
209
Tejas Patel18072da2021-02-25 20:16:56 -0800210 ret = pm_get_api_version(&api_version, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700211 SMC_RET1(handle, (u_register_t)PM_RET_SUCCESS |
212 ((u_register_t)api_version << 32));
Tejas Patel59c608a2019-01-09 04:10:29 -0800213 }
214
215 case PM_GET_DEVICE_STATUS:
216 {
217 uint32_t buff[3];
218
Tejas Patel18072da2021-02-25 20:16:56 -0800219 ret = pm_get_device_status(pm_arg[0], buff, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700220 SMC_RET2(handle, (u_register_t)ret | ((u_register_t)buff[0] << 32),
221 (u_register_t)buff[1] | ((u_register_t)buff[2] << 32));
Tejas Patel59c608a2019-01-09 04:10:29 -0800222 }
223
224 case PM_RESET_ASSERT:
Tejas Patel18072da2021-02-25 20:16:56 -0800225 ret = pm_reset_assert(pm_arg[0], pm_arg[1], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800226 SMC_RET1(handle, (uint64_t)ret);
227
228 case PM_RESET_GET_STATUS:
229 {
230 uint32_t reset_status;
231
Tejas Patel18072da2021-02-25 20:16:56 -0800232 ret = pm_reset_get_status(pm_arg[0], &reset_status,
233 security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700234 SMC_RET1(handle, (u_register_t)ret |
235 ((u_register_t)reset_status << 32));
Tejas Patel59c608a2019-01-09 04:10:29 -0800236 }
237
Tejas Patel02662022019-01-21 17:56:49 +0530238 case PM_INIT_FINALIZE:
Tejas Patel18072da2021-02-25 20:16:56 -0800239 ret = pm_init_finalize(security_flag);
Ravi Patel476b5b12019-08-12 03:10:10 -0700240 SMC_RET1(handle, (uint64_t)ret);
Tejas Patel02662022019-01-21 17:56:49 +0530241
Rajan Vaja649e9242019-03-04 11:09:40 +0530242 case PM_GET_CALLBACK_DATA:
243 {
244 uint32_t result[4] = {0};
245
Tejas Patel18072da2021-02-25 20:16:56 -0800246 pm_get_callbackdata(result, ARRAY_SIZE(result), security_flag);
Rajan Vaja649e9242019-03-04 11:09:40 +0530247 SMC_RET2(handle,
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700248 (u_register_t)result[0] | ((u_register_t)result[1] << 32),
249 (u_register_t)result[2] | ((u_register_t)result[3] << 32));
Rajan Vaja649e9242019-03-04 11:09:40 +0530250 }
251
Tejas Patel59c608a2019-01-09 04:10:29 -0800252 case PM_PINCTRL_REQUEST:
Tejas Patel18072da2021-02-25 20:16:56 -0800253 ret = pm_pinctrl_request(pm_arg[0], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800254 SMC_RET1(handle, (uint64_t)ret);
255
256 case PM_PINCTRL_RELEASE:
Tejas Patel18072da2021-02-25 20:16:56 -0800257 ret = pm_pinctrl_release(pm_arg[0], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800258 SMC_RET1(handle, (uint64_t)ret);
259
260 case PM_PINCTRL_GET_FUNCTION:
261 {
262 uint32_t value = 0;
263
Tejas Patel18072da2021-02-25 20:16:56 -0800264 ret = pm_pinctrl_get_function(pm_arg[0], &value, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700265 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value) << 32);
Tejas Patel59c608a2019-01-09 04:10:29 -0800266 }
267
268 case PM_PINCTRL_SET_FUNCTION:
Tejas Patel18072da2021-02-25 20:16:56 -0800269 ret = pm_pinctrl_set_function(pm_arg[0], pm_arg[1],
270 security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800271 SMC_RET1(handle, (uint64_t)ret);
272
273 case PM_PINCTRL_CONFIG_PARAM_GET:
274 {
275 uint32_t value;
276
Tejas Patel18072da2021-02-25 20:16:56 -0800277 ret = pm_pinctrl_get_pin_param(pm_arg[0], pm_arg[1], &value,
278 security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700279 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value) << 32);
Tejas Patel59c608a2019-01-09 04:10:29 -0800280 }
281
282 case PM_PINCTRL_CONFIG_PARAM_SET:
Tejas Patel18072da2021-02-25 20:16:56 -0800283 ret = pm_pinctrl_set_pin_param(pm_arg[0], pm_arg[1], pm_arg[2],
284 security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800285 SMC_RET1(handle, (uint64_t)ret);
286
Tejas Patel9141f442019-01-10 03:03:48 -0800287 case PM_IOCTL:
288 {
289 uint32_t value;
290
291 ret = pm_api_ioctl(pm_arg[0], pm_arg[1], pm_arg[2],
Tejas Patel18072da2021-02-25 20:16:56 -0800292 pm_arg[3], &value, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700293 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value) << 32);
Tejas Patel9141f442019-01-10 03:03:48 -0800294 }
295
Tejas Patela3e34ad2019-02-01 17:25:19 +0530296 case PM_QUERY_DATA:
297 {
Rajan Vaja030620d2020-11-23 04:13:54 -0800298 uint32_t data[8] = { 0 };
Tejas Patela3e34ad2019-02-01 17:25:19 +0530299
300 ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2],
Tejas Patel18072da2021-02-25 20:16:56 -0800301 pm_arg[3], data, security_flag);
Rajan Vaja030620d2020-11-23 04:13:54 -0800302
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700303 SMC_RET2(handle, (u_register_t)ret | ((u_register_t)data[0] << 32),
304 (u_register_t)data[1] | ((u_register_t)data[2] << 32));
Tejas Patela3e34ad2019-02-01 17:25:19 +0530305
Rajan Vaja030620d2020-11-23 04:13:54 -0800306 }
Tejas Patel59c608a2019-01-09 04:10:29 -0800307 case PM_CLOCK_ENABLE:
Tejas Patel18072da2021-02-25 20:16:56 -0800308 ret = pm_clock_enable(pm_arg[0], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800309 SMC_RET1(handle, (uint64_t)ret);
310
311 case PM_CLOCK_DISABLE:
Tejas Patel18072da2021-02-25 20:16:56 -0800312 ret = pm_clock_disable(pm_arg[0], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800313 SMC_RET1(handle, (uint64_t)ret);
314
315 case PM_CLOCK_GETSTATE:
316 {
317 uint32_t value;
318
Tejas Patel18072da2021-02-25 20:16:56 -0800319 ret = pm_clock_get_state(pm_arg[0], &value, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700320 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value) << 32);
Tejas Patel59c608a2019-01-09 04:10:29 -0800321 }
322
323 case PM_CLOCK_SETDIVIDER:
Tejas Patel18072da2021-02-25 20:16:56 -0800324 ret = pm_clock_set_divider(pm_arg[0], pm_arg[1], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800325 SMC_RET1(handle, (uint64_t)ret);
326
327 case PM_CLOCK_GETDIVIDER:
328 {
329 uint32_t value;
330
Tejas Patel18072da2021-02-25 20:16:56 -0800331 ret = pm_clock_get_divider(pm_arg[0], &value, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700332 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value) << 32);
Tejas Patel59c608a2019-01-09 04:10:29 -0800333 }
334
335 case PM_CLOCK_SETPARENT:
Tejas Patel18072da2021-02-25 20:16:56 -0800336 ret = pm_clock_set_parent(pm_arg[0], pm_arg[1], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800337 SMC_RET1(handle, (uint64_t)ret);
338
339 case PM_CLOCK_GETPARENT:
340 {
341 uint32_t value;
342
Tejas Patel18072da2021-02-25 20:16:56 -0800343 ret = pm_clock_get_parent(pm_arg[0], &value, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700344 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value) << 32);
Tejas Patel59c608a2019-01-09 04:10:29 -0800345 }
346
Tejas Patel84275bf2020-09-01 04:43:53 -0700347 case PM_CLOCK_GETRATE:
348 {
349 uint32_t rate[2] = { 0 };
350
Tejas Patel18072da2021-02-25 20:16:56 -0800351 ret = pm_clock_get_rate(pm_arg[0], rate, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700352 SMC_RET2(handle, (u_register_t)ret | ((u_register_t)rate[0] << 32),
353 (u_register_t)rate[1] | ((u_register_t)0U << 32));
Tejas Patel84275bf2020-09-01 04:43:53 -0700354 }
355
Tejas Patel59c608a2019-01-09 04:10:29 -0800356 case PM_PLL_SET_PARAMETER:
Tejas Patel18072da2021-02-25 20:16:56 -0800357 ret = pm_pll_set_param(pm_arg[0], pm_arg[1], pm_arg[2],
358 security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800359 SMC_RET1(handle, (uint64_t)ret);
360
361 case PM_PLL_GET_PARAMETER:
362 {
363 uint32_t value;
364
Tejas Patel18072da2021-02-25 20:16:56 -0800365 ret = pm_pll_get_param(pm_arg[0], pm_arg[1], &value,
366 security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700367 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)value << 32));
Tejas Patel59c608a2019-01-09 04:10:29 -0800368 }
369
370 case PM_PLL_SET_MODE:
Tejas Patel18072da2021-02-25 20:16:56 -0800371 ret = pm_pll_set_mode(pm_arg[0], pm_arg[1], security_flag);
Tejas Patel59c608a2019-01-09 04:10:29 -0800372 SMC_RET1(handle, (uint64_t)ret);
373
374 case PM_PLL_GET_MODE:
375 {
376 uint32_t mode;
377
Tejas Patel18072da2021-02-25 20:16:56 -0800378 ret = pm_pll_get_mode(pm_arg[0], &mode, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700379 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)mode << 32));
Tejas Patel59c608a2019-01-09 04:10:29 -0800380 }
381
Tejas Patel044001d2019-01-21 17:56:48 +0530382 case PM_GET_TRUSTZONE_VERSION:
383 SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
384 ((uint64_t)VERSAL_TZ_VERSION << 32));
385
Ravi Patelbd4aa5a2019-08-12 03:17:54 -0700386 case PM_GET_CHIPID:
387 {
388 uint32_t result[2];
389
Tejas Patel18072da2021-02-25 20:16:56 -0800390 ret = pm_get_chipid(result, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700391 SMC_RET2(handle, (u_register_t)ret | ((u_register_t)result[0] << 32),
392 (u_register_t)result[1] | ((u_register_t)0U << 32));
Ravi Patelbd4aa5a2019-08-12 03:17:54 -0700393 }
394
Ravi Patel22b0b492019-03-06 12:34:46 +0530395 case PM_FEATURE_CHECK:
396 {
397 uint32_t version;
398
Tejas Patel18072da2021-02-25 20:16:56 -0800399 ret = pm_feature_check(pm_arg[0], &version, security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700400 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)version << 32));
Ravi Patel22b0b492019-03-06 12:34:46 +0530401 }
402
Jolly Shahed05a712019-03-22 05:33:39 +0530403 case PM_LOAD_PDI:
404 {
Tejas Patel18072da2021-02-25 20:16:56 -0800405 ret = pm_load_pdi(pm_arg[0], pm_arg[1], pm_arg[2],
406 security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700407 SMC_RET1(handle, (u_register_t)ret);
Jolly Shahed05a712019-03-22 05:33:39 +0530408 }
409
Saeed Nowshadi2294b422019-06-03 10:22:35 -0700410 case PM_GET_OP_CHARACTERISTIC:
411 {
412 uint32_t result;
413
Tejas Patel18072da2021-02-25 20:16:56 -0800414 ret = pm_get_op_characteristic(pm_arg[0], pm_arg[1], &result,
415 security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700416 SMC_RET1(handle, (u_register_t)ret | ((u_register_t)result << 32));
Saeed Nowshadi2294b422019-06-03 10:22:35 -0700417 }
418
Tejas Patel5c154e12020-11-25 01:53:12 -0800419 case PM_SET_MAX_LATENCY:
420 {
Tejas Patel18072da2021-02-25 20:16:56 -0800421 ret = pm_set_max_latency(pm_arg[0], pm_arg[1], security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700422 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel5c154e12020-11-25 01:53:12 -0800423 }
424
Tejas Patel42015552020-11-25 01:56:57 -0800425 case PM_REGISTER_NOTIFIER:
426 {
Tejas Patel18072da2021-02-25 20:16:56 -0800427 ret = pm_register_notifier(pm_arg[0], pm_arg[1], pm_arg[2],
428 pm_arg[3], security_flag);
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -0700429 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel42015552020-11-25 01:56:57 -0800430 }
431
Tejas Patel59c608a2019-01-09 04:10:29 -0800432 default:
433 WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
434 SMC_RET1(handle, SMC_UNK);
435 }
436}