blob: 5a320f1baec80c94346c09e072fb94678b352eb5 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Rajan Vaja02d18422019-03-04 11:09:39 +05302 * Copyright (c) 2013-2020, 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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000013
14#include <common/runtime_svc.h>
15#if ZYNQMP_WDT_RESTART
16#include <arch_helpers.h>
17#include <drivers/arm/gicv2.h>
18#include <lib/mmio.h>
19#include <lib/spinlock.h>
20#include <plat/common/platform.h>
21#endif
22
Jolly Shah0bfd7002019-01-08 11:10:47 -080023#include <plat_private.h>
Soren Brinkmann76fcae32016-03-06 20:16:27 -080024#include "pm_api_sys.h"
25#include "pm_client.h"
26#include "pm_ipi.h"
Soren Brinkmann76fcae32016-03-06 20:16:27 -080027
Rajan Vaja02d18422019-03-04 11:09:39 +053028#define PM_GET_CALLBACK_DATA 0xa01
Siva Durga Prasad Paladugu43b23a32018-04-27 16:26:47 +053029#define PM_SET_SUSPEND_MODE 0xa02
Rajan Vajac7ee23d2018-02-14 23:10:54 -080030#define PM_GET_TRUSTZONE_VERSION 0xa03
Soren Brinkmann84f0af42016-09-30 14:24:25 -070031
Siva Durga Prasad Paladugu79f75952018-04-30 19:39:49 +053032/* !0 - UP, 0 - DOWN */
33static int32_t pm_up = 0;
Soren Brinkmann76fcae32016-03-06 20:16:27 -080034
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +053035#if ZYNQMP_WDT_RESTART
36static spinlock_t inc_lock;
37static int active_cores = 0;
38#endif
39
40
Soren Brinkmann76fcae32016-03-06 20:16:27 -080041/**
42 * pm_context - Structure which contains data for power management
43 * @api_version version of PM API, must match with one on PMU side
44 * @payload payload array used to store received
45 * data from ipi buffer registers
46 */
47static struct {
48 uint32_t api_version;
49 uint32_t payload[PAYLOAD_ARG_CNT];
50} pm_ctx;
51
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +053052#if ZYNQMP_WDT_RESTART
53/**
54 * trigger_wdt_restart() - Trigger warm restart event to APU cores
55 *
56 * This function triggers SGI for all active APU CPUs. SGI handler then
57 * power down CPU and call system reset.
58 */
59static void trigger_wdt_restart(void)
60{
61 uint32_t core_count = 0;
62 uint32_t core_status[3];
63 uint32_t target_cpu_list = 0;
64 int i;
65
66 for (i = 0; i < 4; i++) {
67 pm_get_node_status(NODE_APU_0 + i, core_status);
68 if (core_status[0] == 1) {
69 core_count++;
70 target_cpu_list |= (1 << i);
71 }
72 }
73
74 spin_lock(&inc_lock);
75 active_cores = core_count;
76 spin_unlock(&inc_lock);
77
78 INFO("Active Cores: %d\n", active_cores);
79
80 /* trigger SGI to active cores */
81 gicv2_raise_sgi(ARM_IRQ_SEC_SGI_7, target_cpu_list);
82}
83
84/**
85 * ttc_fiq_handler() - TTC Handler for timer event
86 * @id number of the highest priority pending interrupt of the type
87 * that this handler was registered for
88 * @flags security state, bit[0]
89 * @handler pointer to 'cpu_context' structure of the current CPU for the
90 * security state specified in the 'flags' parameter
91 * @cookie unused
92 *
93 * Function registered as INTR_TYPE_EL3 interrupt handler
94 *
95 * When WDT event is received in PMU, PMU needs to notify master to do cleanup
96 * if required. PMU sets up timer and starts timer to overflow in zero time upon
97 * WDT event. ATF handles this timer event and takes necessary action required
98 * for warm restart.
99 *
100 * In presence of non-secure software layers (EL1/2) sets the interrupt
101 * at registered entrance in GIC and informs that PMU responsed or demands
102 * action.
103 */
104static uint64_t ttc_fiq_handler(uint32_t id, uint32_t flags, void *handle,
105 void *cookie)
106{
107 INFO("BL31: Got TTC FIQ\n");
108
109 /* Clear TTC interrupt by reading interrupt register */
110 mmio_read_32(TTC3_INTR_REGISTER_1);
111
112 /* Disable the timer interrupts */
113 mmio_write_32(TTC3_INTR_ENABLE_1, 0);
114
115 trigger_wdt_restart();
116
117 return 0;
118}
119
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800120/**
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +0530121 * zynqmp_sgi7_irq() - Handler for SGI7 IRQ
122 * @id number of the highest priority pending interrupt of the type
123 * that this handler was registered for
124 * @flags security state, bit[0]
125 * @handler pointer to 'cpu_context' structure of the current CPU for the
126 * security state specified in the 'flags' parameter
127 * @cookie unused
128 *
129 * Function registered as INTR_TYPE_EL3 interrupt handler
130 *
131 * On receiving WDT event from PMU, ATF generates SGI7 to all running CPUs.
132 * In response to SGI7 interrupt, each CPUs do clean up if required and last
133 * running CPU calls system restart.
134 */
135static uint64_t __unused __dead2 zynqmp_sgi7_irq(uint32_t id, uint32_t flags,
136 void *handle, void *cookie)
137{
138 int i;
139 /* enter wfi and stay there */
140 INFO("Entering wfi\n");
141
142 spin_lock(&inc_lock);
143 active_cores--;
144
145 for (i = 0; i < 4; i++) {
146 mmio_write_32(BASE_GICD_BASE + GICD_CPENDSGIR + 4 * i,
147 0xffffffff);
148 }
149
150 spin_unlock(&inc_lock);
151
152 if (active_cores == 0) {
153 pm_system_shutdown(PMF_SHUTDOWN_TYPE_RESET,
154 PMF_SHUTDOWN_SUBTYPE_SUBSYSTEM);
155 }
156
157 /* enter wfi and stay there */
158 while (1)
159 wfi();
160}
161
162/**
163 * pm_wdt_restart_setup() - Setup warm restart interrupts
164 *
165 * This function sets up handler for SGI7 and TTC interrupts
166 * used for warm restart.
167 */
168static int pm_wdt_restart_setup(void)
169{
170 int ret;
171
172 /* register IRQ handler for SGI7 */
173 ret = request_intr_type_el3(ARM_IRQ_SEC_SGI_7, zynqmp_sgi7_irq);
174 if (ret) {
175 WARN("BL31: registering SGI7 interrupt failed\n");
176 goto err;
177 }
178
179 ret = request_intr_type_el3(IRQ_TTC3_1, ttc_fiq_handler);
180 if (ret)
181 WARN("BL31: registering TTC3 interrupt failed\n");
182
183err:
184 return ret;
185}
186#endif
187
188/**
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800189 * pm_setup() - PM service setup
190 *
191 * @return On success, the initialization function must return 0.
192 * Any other return value will cause the framework to ignore
193 * the service
194 *
195 * Initialization functions for ZynqMP power management for
196 * communicaton with PMU.
197 *
198 * Called from sip_svc_setup initialization function with the
199 * rt_svc_init signature.
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800200 */
201int pm_setup(void)
202{
Wendy Liang328105c2017-10-03 23:21:11 -0700203 int status, ret;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800204
Wendy Liang328105c2017-10-03 23:21:11 -0700205 status = pm_ipi_init(primary_proc);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800206
Siva Durga Prasad Paladuguefd431b2018-04-30 20:12:12 +0530207#if ZYNQMP_WDT_RESTART
208 status = pm_wdt_restart_setup();
209 if (status)
210 WARN("BL31: warm-restart setup failed\n");
211#endif
212
Wendy Liang328105c2017-10-03 23:21:11 -0700213 if (status >= 0) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800214 INFO("BL31: PM Service Init Complete: API v%d.%d\n",
215 PM_VERSION_MAJOR, PM_VERSION_MINOR);
Wendy Liang328105c2017-10-03 23:21:11 -0700216 ret = 0;
217 } else {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800218 INFO("BL31: PM Service Init Failed, Error Code %d!\n", status);
Wendy Liang328105c2017-10-03 23:21:11 -0700219 ret = status;
220 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800221
Siva Durga Prasad Paladugu79f75952018-04-30 19:39:49 +0530222 pm_up = !status;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800223
Wendy Liang328105c2017-10-03 23:21:11 -0700224 return ret;
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800225}
226
227/**
228 * pm_smc_handler() - SMC handler for PM-API calls coming from EL1/EL2.
229 * @smc_fid - Function Identifier
230 * @x1 - x4 - Arguments
231 * @cookie - Unused
232 * @handler - Pointer to caller's context structure
233 *
234 * @return - Unused
235 *
236 * Determines that smc_fid is valid and supported PM SMC Function ID from the
237 * list of pm_api_ids, otherwise completes the request with
238 * the unknown SMC Function ID
239 *
240 * The SMC calls for PM service are forwarded from SIP Service SMC handler
241 * function with rt_svc_handle signature
242 */
243uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
244 uint64_t x4, void *cookie, void *handle, uint64_t flags)
245{
246 enum pm_ret_status ret;
247
248 uint32_t pm_arg[4];
249
250 /* Handle case where PM wasn't initialized properly */
Siva Durga Prasad Paladugu79f75952018-04-30 19:39:49 +0530251 if (!pm_up)
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800252 SMC_RET1(handle, SMC_UNK);
253
254 pm_arg[0] = (uint32_t)x1;
255 pm_arg[1] = (uint32_t)(x1 >> 32);
256 pm_arg[2] = (uint32_t)x2;
257 pm_arg[3] = (uint32_t)(x2 >> 32);
258
259 switch (smc_fid & FUNCID_NUM_MASK) {
260 /* PM API Functions */
261 case PM_SELF_SUSPEND:
262 ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
263 pm_arg[3]);
264 SMC_RET1(handle, (uint64_t)ret);
265
266 case PM_REQ_SUSPEND:
267 ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
268 pm_arg[3]);
269 SMC_RET1(handle, (uint64_t)ret);
270
271 case PM_REQ_WAKEUP:
Filip Drazic78ba1452017-02-07 12:03:57 +0100272 {
273 /* Use address flag is encoded in the 1st bit of the low-word */
274 unsigned int set_addr = pm_arg[1] & 0x1;
275 uint64_t address = (uint64_t)pm_arg[2] << 32;
276
277 address |= pm_arg[1] & (~0x1);
278 ret = pm_req_wakeup(pm_arg[0], set_addr, address,
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800279 pm_arg[3]);
280 SMC_RET1(handle, (uint64_t)ret);
Filip Drazic78ba1452017-02-07 12:03:57 +0100281 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800282
283 case PM_FORCE_POWERDOWN:
284 ret = pm_force_powerdown(pm_arg[0], pm_arg[1]);
285 SMC_RET1(handle, (uint64_t)ret);
286
287 case PM_ABORT_SUSPEND:
288 ret = pm_abort_suspend(pm_arg[0]);
289 SMC_RET1(handle, (uint64_t)ret);
290
291 case PM_SET_WAKEUP_SOURCE:
292 ret = pm_set_wakeup_source(pm_arg[0], pm_arg[1], pm_arg[2]);
293 SMC_RET1(handle, (uint64_t)ret);
294
295 case PM_SYSTEM_SHUTDOWN:
Soren Brinkmann58fbb9b2016-09-02 09:50:54 -0700296 ret = pm_system_shutdown(pm_arg[0], pm_arg[1]);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800297 SMC_RET1(handle, (uint64_t)ret);
298
299 case PM_REQ_NODE:
300 ret = pm_req_node(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3]);
301 SMC_RET1(handle, (uint64_t)ret);
302
303 case PM_RELEASE_NODE:
304 ret = pm_release_node(pm_arg[0]);
305 SMC_RET1(handle, (uint64_t)ret);
306
307 case PM_SET_REQUIREMENT:
308 ret = pm_set_requirement(pm_arg[0], pm_arg[1], pm_arg[2],
309 pm_arg[3]);
310 SMC_RET1(handle, (uint64_t)ret);
311
312 case PM_SET_MAX_LATENCY:
313 ret = pm_set_max_latency(pm_arg[0], pm_arg[1]);
314 SMC_RET1(handle, (uint64_t)ret);
315
316 case PM_GET_API_VERSION:
317 /* Check is PM API version already verified */
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700318 if (pm_ctx.api_version == PM_VERSION) {
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800319 SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
320 ((uint64_t)PM_VERSION << 32));
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700321 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800322
323 ret = pm_get_api_version(&pm_ctx.api_version);
Soren Brinkmanna1b0a902016-09-30 11:30:21 -0700324 /*
325 * Enable IPI IRQ
326 * assume the rich OS is OK to handle callback IRQs now.
327 * Even if we were wrong, it would not enable the IRQ in
328 * the GIC.
329 */
Wendy Liang328105c2017-10-03 23:21:11 -0700330 pm_ipi_irq_enable(primary_proc);
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800331 SMC_RET1(handle, (uint64_t)ret |
332 ((uint64_t)pm_ctx.api_version << 32));
333
334 case PM_SET_CONFIGURATION:
335 ret = pm_set_configuration(pm_arg[0]);
336 SMC_RET1(handle, (uint64_t)ret);
337
Filip Drazicf2ddd912017-03-15 11:50:47 +0100338 case PM_INIT_FINALIZE:
339 ret = pm_init_finalize();
340 SMC_RET1(handle, (uint64_t)ret);
341
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800342 case PM_GET_NODE_STATUS:
Anes Hadziahmetagic1caf88e2017-01-27 18:42:44 +0100343 {
344 uint32_t buff[3];
345
346 ret = pm_get_node_status(pm_arg[0], buff);
347 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)buff[0] << 32),
348 (uint64_t)buff[1] | ((uint64_t)buff[2] << 32));
349 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800350
351 case PM_GET_OP_CHARACTERISTIC:
Anes Hadziahmetagic92aee012016-05-12 16:17:30 +0200352 {
353 uint32_t result;
354
355 ret = pm_get_op_characteristic(pm_arg[0], pm_arg[1], &result);
356 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)result << 32));
357 }
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800358
359 case PM_REGISTER_NOTIFIER:
360 ret = pm_register_notifier(pm_arg[0], pm_arg[1], pm_arg[2],
361 pm_arg[3]);
362 SMC_RET1(handle, (uint64_t)ret);
363
364 case PM_RESET_ASSERT:
365 ret = pm_reset_assert(pm_arg[0], pm_arg[1]);
366 SMC_RET1(handle, (uint64_t)ret);
367
368 case PM_RESET_GET_STATUS:
369 {
370 uint32_t reset_status;
371
372 ret = pm_reset_get_status(pm_arg[0], &reset_status);
373 SMC_RET1(handle, (uint64_t)ret |
374 ((uint64_t)reset_status << 32));
375 }
376
377 /* PM memory access functions */
378 case PM_MMIO_WRITE:
379 ret = pm_mmio_write(pm_arg[0], pm_arg[1], pm_arg[2]);
380 SMC_RET1(handle, (uint64_t)ret);
381
382 case PM_MMIO_READ:
383 {
384 uint32_t value;
385
386 ret = pm_mmio_read(pm_arg[0], &value);
387 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
388 }
Nava kishore Manne68d460c2016-08-20 23:18:09 +0530389
390 case PM_FPGA_LOAD:
391 ret = pm_fpga_load(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3]);
392 SMC_RET1(handle, (uint64_t)ret);
393
394 case PM_FPGA_GET_STATUS:
395 {
396 uint32_t value;
397
398 ret = pm_fpga_get_status(&value);
399 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
400 }
401
Siva Durga Prasad Paladugu16427d12016-08-24 11:45:47 +0530402 case PM_GET_CHIPID:
Soren Brinkmanncb366812016-09-22 12:21:11 -0700403 {
404 uint32_t result[2];
405
406 ret = pm_get_chipid(result);
407 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32),
408 result[1]);
409 }
Siva Durga Prasad Paladugu16427d12016-08-24 11:45:47 +0530410
Siva Durga Prasad Paladugude93d982018-04-30 15:49:27 +0530411 case PM_SECURE_RSA_AES:
412 ret = pm_secure_rsaaes(pm_arg[0], pm_arg[1], pm_arg[2],
413 pm_arg[3]);
414 SMC_RET1(handle, (uint64_t)ret);
415
Rajan Vaja02d18422019-03-04 11:09:39 +0530416 case PM_GET_CALLBACK_DATA:
417 {
418 uint32_t result[4] = {0};
419
420 pm_get_callbackdata(result, (sizeof(result)/sizeof(uint32_t)));
421 SMC_RET2(handle,
422 (uint64_t)result[0] | ((uint64_t)result[1] << 32),
423 (uint64_t)result[2] | ((uint64_t)result[3] << 32));
424 }
425
Rajan Vaja83687612018-01-17 02:39:20 -0800426 case PM_PINCTRL_REQUEST:
427 ret = pm_pinctrl_request(pm_arg[0]);
428 SMC_RET1(handle, (uint64_t)ret);
429
430 case PM_PINCTRL_RELEASE:
431 ret = pm_pinctrl_release(pm_arg[0]);
432 SMC_RET1(handle, (uint64_t)ret);
433
434 case PM_PINCTRL_GET_FUNCTION:
435 {
Jolly Shah69fb5bf2018-02-07 16:25:41 -0800436 uint32_t value = 0;
Rajan Vaja83687612018-01-17 02:39:20 -0800437
438 ret = pm_pinctrl_get_function(pm_arg[0], &value);
439 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
440 }
441
442 case PM_PINCTRL_SET_FUNCTION:
443 ret = pm_pinctrl_set_function(pm_arg[0], pm_arg[1]);
444 SMC_RET1(handle, (uint64_t)ret);
445
446 case PM_PINCTRL_CONFIG_PARAM_GET:
447 {
448 uint32_t value;
449
450 ret = pm_pinctrl_get_config(pm_arg[0], pm_arg[1], &value);
451 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
452 }
453
454 case PM_PINCTRL_CONFIG_PARAM_SET:
455 ret = pm_pinctrl_set_config(pm_arg[0], pm_arg[1], pm_arg[2]);
456 SMC_RET1(handle, (uint64_t)ret);
457
Rajan Vaja5529a012018-01-17 02:39:23 -0800458 case PM_IOCTL:
459 {
460 uint32_t value;
461
462 ret = pm_ioctl(pm_arg[0], pm_arg[1], pm_arg[2],
463 pm_arg[3], &value);
464 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
465 }
466
Rajan Vaja35116132018-01-17 02:39:25 -0800467 case PM_QUERY_DATA:
468 {
Jolly Shah69fb5bf2018-02-07 16:25:41 -0800469 uint32_t data[4] = { 0 };
Rajan Vaja35116132018-01-17 02:39:25 -0800470
471 ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2],
472 pm_arg[3], data);
473 SMC_RET2(handle, (uint64_t)data[0] | ((uint64_t)data[1] << 32),
474 (uint64_t)data[2] | ((uint64_t)data[3] << 32));
475 }
476
477 case PM_CLOCK_ENABLE:
478 ret = pm_clock_enable(pm_arg[0]);
479 SMC_RET1(handle, (uint64_t)ret);
480
481 case PM_CLOCK_DISABLE:
482 ret = pm_clock_disable(pm_arg[0]);
483 SMC_RET1(handle, (uint64_t)ret);
484
485 case PM_CLOCK_GETSTATE:
486 {
487 uint32_t value;
488
489 ret = pm_clock_getstate(pm_arg[0], &value);
490 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
491 }
492
493 case PM_CLOCK_SETDIVIDER:
494 ret = pm_clock_setdivider(pm_arg[0], pm_arg[1]);
495 SMC_RET1(handle, (uint64_t)ret);
496
497 case PM_CLOCK_GETDIVIDER:
498 {
499 uint32_t value;
500
501 ret = pm_clock_getdivider(pm_arg[0], &value);
502 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
503 }
504
505 case PM_CLOCK_SETRATE:
506 ret = pm_clock_setrate(pm_arg[0],
507 ((uint64_t)pm_arg[2]) << 32 | pm_arg[1]);
508
509 SMC_RET1(handle, (uint64_t)ret);
510
511 case PM_CLOCK_GETRATE:
512 {
513 uint64_t value;
514
515 ret = pm_clock_getrate(pm_arg[0], &value);
Jolly Shah69fb5bf2018-02-07 16:25:41 -0800516 SMC_RET2(handle, (uint64_t)ret |
517 (((uint64_t)value & 0xFFFFFFFFU) << 32U),
518 (value >> 32U) & 0xFFFFFFFFU);
Rajan Vaja35116132018-01-17 02:39:25 -0800519
520 }
521
522 case PM_CLOCK_SETPARENT:
523 ret = pm_clock_setparent(pm_arg[0], pm_arg[1]);
524 SMC_RET1(handle, (uint64_t)ret);
525
526 case PM_CLOCK_GETPARENT:
527 {
528 uint32_t value;
529
530 ret = pm_clock_getparent(pm_arg[0], &value);
531 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
532 }
533
Rajan Vajac7ee23d2018-02-14 23:10:54 -0800534 case PM_GET_TRUSTZONE_VERSION:
535 SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
536 ((uint64_t)ZYNQMP_TZ_VERSION << 32));
537
Siva Durga Prasad Paladugu43b23a32018-04-27 16:26:47 +0530538 case PM_SET_SUSPEND_MODE:
539 ret = pm_set_suspend_mode(pm_arg[0]);
540 SMC_RET1(handle, (uint64_t)ret);
541
Siva Durga Prasad Paladuguf3994cc2018-05-01 11:12:55 +0530542 case PM_SECURE_SHA:
543 ret = pm_sha_hash(pm_arg[0], pm_arg[1], pm_arg[2],
544 pm_arg[3]);
545 SMC_RET1(handle, (uint64_t)ret);
546
547 case PM_SECURE_RSA:
548 ret = pm_rsa_core(pm_arg[0], pm_arg[1], pm_arg[2],
549 pm_arg[3]);
550 SMC_RET1(handle, (uint64_t)ret);
551
Siva Durga Prasad Paladugua4ed4b22018-04-30 20:06:58 +0530552 case PM_SECURE_IMAGE:
553 {
554 uint32_t result[2];
555
556 ret = pm_secure_image(pm_arg[0], pm_arg[1], pm_arg[2],
557 pm_arg[3], &result[0]);
558 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32),
559 result[1]);
560 }
561
Siva Durga Prasad Paladugu7c6516a2018-09-04 17:41:34 +0530562 case PM_FPGA_READ:
563 {
564 uint32_t value;
565
566 ret = pm_fpga_read(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3],
567 &value);
568 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
569 }
570
Siva Durga Prasad Paladugu8bd905b2018-09-04 18:05:50 +0530571 case PM_SECURE_AES:
572 {
573 uint32_t value;
574
575 ret = pm_aes_engine(pm_arg[0], pm_arg[1], &value);
576 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
577 }
578
Jolly Shaha7cc5ee2019-01-02 12:27:00 -0800579 case PM_PLL_SET_PARAMETER:
580 ret = pm_pll_set_parameter(pm_arg[0], pm_arg[1], pm_arg[2]);
581 SMC_RET1(handle, (uint64_t)ret);
582
Jolly Shahcb2f45d2019-01-04 11:28:38 -0800583 case PM_PLL_GET_PARAMETER:
584 {
585 uint32_t value;
586
587 ret = pm_pll_get_parameter(pm_arg[0], pm_arg[1], &value);
588 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32));
589 }
590
Jolly Shah1f0d5852019-01-04 11:32:31 -0800591 case PM_PLL_SET_MODE:
592 ret = pm_pll_set_mode(pm_arg[0], pm_arg[1]);
593 SMC_RET1(handle, (uint64_t)ret);
594
Jolly Shah141421e2019-01-04 11:35:48 -0800595 case PM_PLL_GET_MODE:
596 {
597 uint32_t mode;
598
599 ret = pm_pll_get_mode(pm_arg[0], &mode);
600 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32));
601 }
602
Soren Brinkmann76fcae32016-03-06 20:16:27 -0800603 default:
604 WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
605 SMC_RET1(handle, SMC_UNK);
606 }
607}