blob: a18f84506e440677646ed4a71612a19c339c5fa5 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Rajan Vaja83687612018-01-17 02:39:20 -08002 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
Soren Brinkmann76fcae32016-03-06 20:16:27 -08003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmann76fcae32016-03-06 20:16:27 -08005 */
6
7/*
8 * Top-level SMC handler for ZynqMP power management calls and
9 * IPI setup functions for communication with PMU.
10 */
11
12#include <errno.h>
Soren Brinkmann76fcae32016-03-06 20:16:27 -080013#include <runtime_svc.h>
Isla Mitchelle3631462017-07-14 10:46:32 +010014#include "../zynqmp_private.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080015#include "pm_api_sys.h"
16#include "pm_client.h"
17#include "pm_ipi.h"
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +053018#if ZYNQMP_WDT_RESTART
19#include <arch_helpers.h>
20#include <gicv2.h>
21#include <mmio.h>
22#include <platform.h>
23#include <spinlock.h>
24#endif
Soren Brinkmann76fcae32016-03-06 20:16:27 -080025
Siva Durga Prasad Paladugu43b23a32018-04-27 16:26:47 +053026#define PM_SET_SUSPEND_MODE 0xa02
Rajan Vajac7ee23d2018-02-14 23:10:54 -080027#define PM_GET_TRUSTZONE_VERSION 0xa03
Soren Brinkmann84f0af42016-09-30 14:24:25 -070028
Siva Durga Prasad Paladugu79f75952018-04-30 19:39:49 +053029/* !0 - UP, 0 - DOWN */
30static int32_t pm_up = 0;
Soren Brinkmann76fcae32016-03-06 20:16:27 -080031
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +053032#if ZYNQMP_WDT_RESTART
33static spinlock_t inc_lock;
34static int active_cores = 0;
35#endif
36
37
Soren Brinkmann76fcae32016-03-06 20:16:27 -080038/**
39 * pm_context - Structure which contains data for power management
40 * @api_version version of PM API, must match with one on PMU side
41 * @payload payload array used to store received
42 * data from ipi buffer registers
43 */
44static struct {
45 uint32_t api_version;
46 uint32_t payload[PAYLOAD_ARG_CNT];
47} pm_ctx;
48
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +053049#if ZYNQMP_WDT_RESTART
50/**
51 * trigger_wdt_restart() - Trigger warm restart event to APU cores
52 *
53 * This function triggers SGI for all active APU CPUs. SGI handler then
54 * power down CPU and call system reset.
55 */
56static void trigger_wdt_restart(void)
57{
58 uint32_t core_count = 0;
59 uint32_t core_status[3];
60 uint32_t target_cpu_list = 0;
61 int i;
62
63 for (i = 0; i < 4; i++) {
64 pm_get_node_status(NODE_APU_0 + i, core_status);
65 if (core_status[0] == 1) {
66 core_count++;
67 target_cpu_list |= (1 << i);
68 }
69 }
70
71 spin_lock(&inc_lock);
72 active_cores = core_count;
73 spin_unlock(&inc_lock);
74
75 INFO("Active Cores: %d\n", active_cores);
76
77 /* trigger SGI to active cores */
78 gicv2_raise_sgi(ARM_IRQ_SEC_SGI_7, target_cpu_list);
79}
80
81/**
82 * ttc_fiq_handler() - TTC Handler for timer event
83 * @id number of the highest priority pending interrupt of the type
84 * that this handler was registered for
85 * @flags security state, bit[0]
86 * @handler pointer to 'cpu_context' structure of the current CPU for the
87 * security state specified in the 'flags' parameter
88 * @cookie unused
89 *
90 * Function registered as INTR_TYPE_EL3 interrupt handler
91 *
92 * When WDT event is received in PMU, PMU needs to notify master to do cleanup
93 * if required. PMU sets up timer and starts timer to overflow in zero time upon
94 * WDT event. ATF handles this timer event and takes necessary action required
95 * for warm restart.
96 *
97 * In presence of non-secure software layers (EL1/2) sets the interrupt
98 * at registered entrance in GIC and informs that PMU responsed or demands
99 * action.
100 */
101static uint64_t ttc_fiq_handler(uint32_t id, uint32_t flags, void *handle,
102 void *cookie)
103{
104 INFO("BL31: Got TTC FIQ\n");
105
106 /* Clear TTC interrupt by reading interrupt register */
107 mmio_read_32(TTC3_INTR_REGISTER_1);
108
109 /* Disable the timer interrupts */
110 mmio_write_32(TTC3_INTR_ENABLE_1, 0);
111
112 trigger_wdt_restart();
113
114 return 0;
115}
116
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800117/**
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +0530118 * zynqmp_sgi7_irq() - Handler for SGI7 IRQ
119 * @id number of the highest priority pending interrupt of the type
120 * that this handler was registered for
121 * @flags security state, bit[0]
122 * @handler pointer to 'cpu_context' structure of the current CPU for the
123 * security state specified in the 'flags' parameter
124 * @cookie unused
125 *
126 * Function registered as INTR_TYPE_EL3 interrupt handler
127 *
128 * On receiving WDT event from PMU, ATF generates SGI7 to all running CPUs.
129 * In response to SGI7 interrupt, each CPUs do clean up if required and last
130 * running CPU calls system restart.
131 */
132static uint64_t __unused __dead2 zynqmp_sgi7_irq(uint32_t id, uint32_t flags,
133 void *handle, void *cookie)
134{
135 int i;
136 /* enter wfi and stay there */
137 INFO("Entering wfi\n");
138
139 spin_lock(&inc_lock);
140 active_cores--;
141
142 for (i = 0; i < 4; i++) {
143 mmio_write_32(BASE_GICD_BASE + GICD_CPENDSGIR + 4 * i,
144 0xffffffff);
145 }
146
147 spin_unlock(&inc_lock);
148
149 if (active_cores == 0) {
150 pm_system_shutdown(PMF_SHUTDOWN_TYPE_RESET,
151 PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM);
152 }
153
154 /* enter wfi and stay there */
155 while (1)
156 wfi();
157}
158
159/**
160 * pm_wdt_restart_setup() - Setup warm restart interrupts
161 *
162 * This function sets up handler for SGI7 and TTC interrupts
163 * used for warm restart.
164 */
165static int pm_wdt_restart_setup(void)
166{
167 int ret;
168
169 /* register IRQ handler for SGI7 */
170 ret = request_intr_type_el3(ARM_IRQ_SEC_SGI_7, zynqmp_sgi7_irq);
171 if (ret) {
172 WARN("BL31: registering SGI7 interrupt failed\n");
173 goto err;
174 }
175
176 ret = request_intr_type_el3(IRQ_TTC3_1, ttc_fiq_handler);
177 if (ret)
178 WARN("BL31: registering TTC3 interrupt failed\n");
179
180err:
181 return ret;
182}
183#endif
184
185/**
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800186 * pm_setup() - PM service setup
187 *
188 * @return On success, the initialization function must return 0.
189 * Any other return value will cause the framework to ignore
190 * the service
191 *
192 * Initialization functions for ZynqMP power management for
193 * communicaton with PMU.
194 *
195 * Called from sip_svc_setup initialization function with the
196 * rt_svc_init signature.
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800197 */
198int pm_setup(void)
199{
Wendy Liang328105c2017-10-03 23:21:11 -0700200 int status, ret;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800201
Wendy Liang328105c2017-10-03 23:21:11 -0700202 status = pm_ipi_init(primary_proc);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800203
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +0530204#if ZYNQMP_WDT_RESTART
205 status = pm_wdt_restart_setup();
206 if (status)
207 WARN("BL31: warm-restart setup failed\n");
208#endif
209
Wendy Liang328105c2017-10-03 23:21:11 -0700210 if (status >= 0) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800211 INFO("BL31: PM Service Init Complete: API v%d.%d\n",
212 PM_VERSION_MAJOR, PM_VERSION_MINOR);
Wendy Liang328105c2017-10-03 23:21:11 -0700213 ret = 0;
214 } else {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800215 INFO("BL31: PM Service Init Failed, Error Code %d!\n", status);
Wendy Liang328105c2017-10-03 23:21:11 -0700216 ret = status;
217 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800218
Siva Durga Prasad Paladugu79f75952018-04-30 19:39:49 +0530219 pm_up = !status;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800220
Wendy Liang328105c2017-10-03 23:21:11 -0700221 return ret;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800222}
223
224/**
225 * pm_smc_handler() - SMC handler for PM-API calls coming from EL1/EL2.
226 * @smc_fid - Function Identifier
227 * @x1 - x4 - Arguments
228 * @cookie - Unused
229 * @handler - Pointer to caller's context structure
230 *
231 * @return - Unused
232 *
233 * Determines that smc_fid is valid and supported PM SMC Function ID from the
234 * list of pm_api_ids, otherwise completes the request with
235 * the unknown SMC Function ID
236 *
237 * The SMC calls for PM service are forwarded from SIP Service SMC handler
238 * function with rt_svc_handle signature
239 */
240uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
241 uint64_t x4, void *cookie, void *handle, uint64_t flags)
242{
243 enum pm_ret_status ret;
244
245 uint32_t pm_arg[4];
246
247 /* Handle case where PM wasn't initialized properly */
Siva Durga Prasad Paladugu79f75952018-04-30 19:39:49 +0530248 if (!pm_up)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800249 SMC_RET1(handle, SMC_UNK);
250
251 pm_arg[0] = (uint32_t)x1;
252 pm_arg[1] = (uint32_t)(x1 >> 32);
253 pm_arg[2] = (uint32_t)x2;
254 pm_arg[3] = (uint32_t)(x2 >> 32);
255
256 switch (smc_fid & FUNCID_NUM_MASK) {
257 /* PM API Functions */
258 case PM_SELF_SUSPEND:
259 ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
260 pm_arg[3]);
261 SMC_RET1(handle, (uint64_t)ret);
262
263 case PM_REQ_SUSPEND:
264 ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
265 pm_arg[3]);
266 SMC_RET1(handle, (uint64_t)ret);
267
268 case PM_REQ_WAKEUP:
Filip Drazic78ba1452017-02-07 12:03:57 +0100269 {
270 /* Use address flag is encoded in the 1st bit of the low-word */
271 unsigned int set_addr = pm_arg[1] & 0x1;
272 uint64_t address = (uint64_t)pm_arg[2] << 32;
273
274 address |= pm_arg[1] & (~0x1);
275 ret = pm_req_wakeup(pm_arg[0], set_addr, address,
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800276 pm_arg[3]);
277 SMC_RET1(handle, (uint64_t)ret);
Filip Drazic78ba1452017-02-07 12:03:57 +0100278 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800279
280 case PM_FORCE_POWERDOWN:
281 ret = pm_force_powerdown(pm_arg[0], pm_arg[1]);
282 SMC_RET1(handle, (uint64_t)ret);
283
284 case PM_ABORT_SUSPEND:
285 ret = pm_abort_suspend(pm_arg[0]);
286 SMC_RET1(handle, (uint64_t)ret);
287
288 case PM_SET_WAKEUP_SOURCE:
289 ret = pm_set_wakeup_source(pm_arg[0], pm_arg[1], pm_arg[2]);
290 SMC_RET1(handle, (uint64_t)ret);
291
292 case PM_SYSTEM_SHUTDOWN:
Soren Brinkmann58fbb9b2016-09-02 09:50:54 -0700293 ret = pm_system_shutdown(pm_arg[0], pm_arg[1]);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800294 SMC_RET1(handle, (uint64_t)ret);
295
296 case PM_REQ_NODE:
297 ret = pm_req_node(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3]);
298 SMC_RET1(handle, (uint64_t)ret);
299
300 case PM_RELEASE_NODE:
301 ret = pm_release_node(pm_arg[0]);
302 SMC_RET1(handle, (uint64_t)ret);
303
304 case PM_SET_REQUIREMENT:
305 ret = pm_set_requirement(pm_arg[0], pm_arg[1], pm_arg[2],
306 pm_arg[3]);
307 SMC_RET1(handle, (uint64_t)ret);
308
309 case PM_SET_MAX_LATENCY:
310 ret = pm_set_max_latency(pm_arg[0], pm_arg[1]);
311 SMC_RET1(handle, (uint64_t)ret);
312
313 case PM_GET_API_VERSION:
314 /* Check is PM API version already verified */
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700315 if (pm_ctx.api_version == PM_VERSION) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800316 SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
317 ((uint64_t)PM_VERSION << 32));
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700318 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800319
320 ret = pm_get_api_version(&pm_ctx.api_version);
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700321 /*
322 * Enable IPI IRQ
323 * assume the rich OS is OK to handle callback IRQs now.
324 * Even if we were wrong, it would not enable the IRQ in
325 * the GIC.
326 */
Wendy Liang328105c2017-10-03 23:21:11 -0700327 pm_ipi_irq_enable(primary_proc);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800328 SMC_RET1(handle, (uint64_t)ret |
329 ((uint64_t)pm_ctx.api_version << 32));
330
331 case PM_SET_CONFIGURATION:
332 ret = pm_set_configuration(pm_arg[0]);
333 SMC_RET1(handle, (uint64_t)ret);
334
Filip Drazicf2ddd912017-03-15 11:50:47 +0100335 case PM_INIT_FINALIZE:
336 ret = pm_init_finalize();
337 SMC_RET1(handle, (uint64_t)ret);
338
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800339 case PM_GET_NODE_STATUS:
Anes Hadziahmetagic1caf88e2017-01-27 18:42:44 +0100340 {
341 uint32_t buff[3];
342
343 ret = pm_get_node_status(pm_arg[0], buff);
344 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)buff[0] << 32),
345 (uint64_t)buff[1] | ((uint64_t)buff[2] << 32));
346 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800347
348 case PM_GET_OP_CHARACTERISTIC:
Anes Hadziahmetagic92aee012016-05-12 16:17:30 +0200349 {
350 uint32_t result;
351
352 ret = pm_get_op_characteristic(pm_arg[0], pm_arg[1], &result);
353 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)result << 32));
354 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800355
356 case PM_REGISTER_NOTIFIER:
357 ret = pm_register_notifier(pm_arg[0], pm_arg[1], pm_arg[2],
358 pm_arg[3]);
359 SMC_RET1(handle, (uint64_t)ret);
360
361 case PM_RESET_ASSERT:
362 ret = pm_reset_assert(pm_arg[0], pm_arg[1]);
363 SMC_RET1(handle, (uint64_t)ret);
364
365 case PM_RESET_GET_STATUS:
366 {
367 uint32_t reset_status;
368
369 ret = pm_reset_get_status(pm_arg[0], &reset_status);
370 SMC_RET1(handle, (uint64_t)ret |
371 ((uint64_t)reset_status << 32));
372 }
373
374 /* PM memory access functions */
375 case PM_MMIO_WRITE:
376 ret = pm_mmio_write(pm_arg[0], pm_arg[1], pm_arg[2]);
377 SMC_RET1(handle, (uint64_t)ret);
378
379 case PM_MMIO_READ:
380 {
381 uint32_t value;
382
383 ret = pm_mmio_read(pm_arg[0], &value);
384 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
385 }
Nava kishore Manne68d460c2016-08-20 23:18:09 +0530386
387 case PM_FPGA_LOAD:
388 ret = pm_fpga_load(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3]);
389 SMC_RET1(handle, (uint64_t)ret);
390
391 case PM_FPGA_GET_STATUS:
392 {
393 uint32_t value;
394
395 ret = pm_fpga_get_status(&value);
396 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
397 }
398
Siva Durga Prasad Paladugu16427d12016-08-24 11:45:47 +0530399 case PM_GET_CHIPID:
Soren Brinkmanncb366812016-09-22 12:21:11 -0700400 {
401 uint32_t result[2];
402
403 ret = pm_get_chipid(result);
404 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32),
405 result[1]);
406 }
Siva Durga Prasad Paladugu16427d12016-08-24 11:45:47 +0530407
Siva Durga Prasad Paladugude93d982018-04-30 15:49:27 +0530408 case PM_SECURE_RSA_AES:
409 ret = pm_secure_rsaaes(pm_arg[0], pm_arg[1], pm_arg[2],
410 pm_arg[3]);
411 SMC_RET1(handle, (uint64_t)ret);
412
Rajan Vaja83687612018-01-17 02:39:20 -0800413 case PM_PINCTRL_REQUEST:
414 ret = pm_pinctrl_request(pm_arg[0]);
415 SMC_RET1(handle, (uint64_t)ret);
416
417 case PM_PINCTRL_RELEASE:
418 ret = pm_pinctrl_release(pm_arg[0]);
419 SMC_RET1(handle, (uint64_t)ret);
420
421 case PM_PINCTRL_GET_FUNCTION:
422 {
Jolly Shah69fb5bf2018-02-07 16:25:41 -0800423 uint32_t value = 0;
Rajan Vaja83687612018-01-17 02:39:20 -0800424
425 ret = pm_pinctrl_get_function(pm_arg[0], &value);
426 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
427 }
428
429 case PM_PINCTRL_SET_FUNCTION:
430 ret = pm_pinctrl_set_function(pm_arg[0], pm_arg[1]);
431 SMC_RET1(handle, (uint64_t)ret);
432
433 case PM_PINCTRL_CONFIG_PARAM_GET:
434 {
435 uint32_t value;
436
437 ret = pm_pinctrl_get_config(pm_arg[0], pm_arg[1], &value);
438 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
439 }
440
441 case PM_PINCTRL_CONFIG_PARAM_SET:
442 ret = pm_pinctrl_set_config(pm_arg[0], pm_arg[1], pm_arg[2]);
443 SMC_RET1(handle, (uint64_t)ret);
444
Rajan Vaja5529a012018-01-17 02:39:23 -0800445 case PM_IOCTL:
446 {
447 uint32_t value;
448
449 ret = pm_ioctl(pm_arg[0], pm_arg[1], pm_arg[2],
450 pm_arg[3], &value);
451 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
452 }
453
Rajan Vaja35116132018-01-17 02:39:25 -0800454 case PM_QUERY_DATA:
455 {
Jolly Shah69fb5bf2018-02-07 16:25:41 -0800456 uint32_t data[4] = { 0 };
Rajan Vaja35116132018-01-17 02:39:25 -0800457
458 ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2],
459 pm_arg[3], data);
460 SMC_RET2(handle, (uint64_t)data[0] | ((uint64_t)data[1] << 32),
461 (uint64_t)data[2] | ((uint64_t)data[3] << 32));
462 }
463
464 case PM_CLOCK_ENABLE:
465 ret = pm_clock_enable(pm_arg[0]);
466 SMC_RET1(handle, (uint64_t)ret);
467
468 case PM_CLOCK_DISABLE:
469 ret = pm_clock_disable(pm_arg[0]);
470 SMC_RET1(handle, (uint64_t)ret);
471
472 case PM_CLOCK_GETSTATE:
473 {
474 uint32_t value;
475
476 ret = pm_clock_getstate(pm_arg[0], &value);
477 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
478 }
479
480 case PM_CLOCK_SETDIVIDER:
481 ret = pm_clock_setdivider(pm_arg[0], pm_arg[1]);
482 SMC_RET1(handle, (uint64_t)ret);
483
484 case PM_CLOCK_GETDIVIDER:
485 {
486 uint32_t value;
487
488 ret = pm_clock_getdivider(pm_arg[0], &value);
489 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
490 }
491
492 case PM_CLOCK_SETRATE:
493 ret = pm_clock_setrate(pm_arg[0],
494 ((uint64_t)pm_arg[2]) << 32 | pm_arg[1]);
495
496 SMC_RET1(handle, (uint64_t)ret);
497
498 case PM_CLOCK_GETRATE:
499 {
500 uint64_t value;
501
502 ret = pm_clock_getrate(pm_arg[0], &value);
Jolly Shah69fb5bf2018-02-07 16:25:41 -0800503 SMC_RET2(handle, (uint64_t)ret |
504 (((uint64_t)value & 0xFFFFFFFFU) << 32U),
505 (value >> 32U) & 0xFFFFFFFFU);
Rajan Vaja35116132018-01-17 02:39:25 -0800506
507 }
508
509 case PM_CLOCK_SETPARENT:
510 ret = pm_clock_setparent(pm_arg[0], pm_arg[1]);
511 SMC_RET1(handle, (uint64_t)ret);
512
513 case PM_CLOCK_GETPARENT:
514 {
515 uint32_t value;
516
517 ret = pm_clock_getparent(pm_arg[0], &value);
518 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
519 }
520
Rajan Vajac7ee23d2018-02-14 23:10:54 -0800521 case PM_GET_TRUSTZONE_VERSION:
522 SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
523 ((uint64_t)ZYNQMP_TZ_VERSION << 32));
524
Siva Durga Prasad Paladugu43b23a32018-04-27 16:26:47 +0530525 case PM_SET_SUSPEND_MODE:
526 ret = pm_set_suspend_mode(pm_arg[0]);
527 SMC_RET1(handle, (uint64_t)ret);
528
Siva Durga Prasad Paladuguf3994cc2018-05-01 11:12:55 +0530529 case PM_SECURE_SHA:
530 ret = pm_sha_hash(pm_arg[0], pm_arg[1], pm_arg[2],
531 pm_arg[3]);
532 SMC_RET1(handle, (uint64_t)ret);
533
534 case PM_SECURE_RSA:
535 ret = pm_rsa_core(pm_arg[0], pm_arg[1], pm_arg[2],
536 pm_arg[3]);
537 SMC_RET1(handle, (uint64_t)ret);
538
Siva Durga Prasad Paladugua4ed4b22018-04-30 20:06:58 +0530539 case PM_SECURE_IMAGE:
540 {
541 uint32_t result[2];
542
543 ret = pm_secure_image(pm_arg[0], pm_arg[1], pm_arg[2],
544 pm_arg[3], &result[0]);
545 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32),
546 result[1]);
547 }
548
Siva Durga Prasad Paladugu7c6516a2018-09-04 17:41:34 +0530549 case PM_FPGA_READ:
550 {
551 uint32_t value;
552
553 ret = pm_fpga_read(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3],
554 &value);
555 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
556 }
557
Siva Durga Prasad Paladugu8bd905b2018-09-04 18:05:50 +0530558 case PM_SECURE_AES:
559 {
560 uint32_t value;
561
562 ret = pm_aes_engine(pm_arg[0], pm_arg[1], &value);
563 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
564 }
565
Jolly Shaha7cc5ee2019-01-02 12:27:00 -0800566 case PM_PLL_SET_PARAMETER:
567 ret = pm_pll_set_parameter(pm_arg[0], pm_arg[1], pm_arg[2]);
568 SMC_RET1(handle, (uint64_t)ret);
569
Jolly Shahcb2f45d2019-01-04 11:28:38 -0800570 case PM_PLL_GET_PARAMETER:
571 {
572 uint32_t value;
573
574 ret = pm_pll_get_parameter(pm_arg[0], pm_arg[1], &value);
575 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32));
576 }
577
Jolly Shah1f0d5852019-01-04 11:32:31 -0800578 case PM_PLL_SET_MODE:
579 ret = pm_pll_set_mode(pm_arg[0], pm_arg[1]);
580 SMC_RET1(handle, (uint64_t)ret);
581
Jolly Shah141421e2019-01-04 11:35:48 -0800582 case PM_PLL_GET_MODE:
583 {
584 uint32_t mode;
585
586 ret = pm_pll_get_mode(pm_arg[0], &mode);
587 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32));
588 }
589
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800590 default:
591 WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
592 SMC_RET1(handle, SMC_UNK);
593 }
594}