blob: 4e26d87b28cb38a908a28d9331296b5b81d2d3f8 [file] [log] [blame]
Tejas Patel354fe572018-12-14 00:55:37 -08001/*
Tanmay Shahff34daa2021-08-09 11:00:41 -07002 * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
Tanmay Shahfdae9e82022-08-26 15:06:00 -07003 * Copyright (c) 2022, Advanced Micro Devices, Inc. All rights reserved.
Tejas Patel354fe572018-12-14 00:55:37 -08004 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8/*
9 * Top-level SMC handler for Versal power management calls and
10 * IPI setup functions for communication with PMC.
11 */
12
13#include <errno.h>
14#include <plat_private.h>
Tejas Patel59c608a2019-01-09 04:10:29 -080015#include <stdbool.h>
16#include <common/runtime_svc.h>
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053017#include <plat/common/platform.h>
Tejas Patel59c608a2019-01-09 04:10:29 -080018#include "pm_api_sys.h"
Tejas Patel354fe572018-12-14 00:55:37 -080019#include "pm_client.h"
20#include "pm_ipi.h"
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060021#include <drivers/arm/gicv3.h>
22
23#define XSCUGIC_SGIR_EL1_INITID_SHIFT 24U
Abhyuday Godhasaraedc38ae2021-08-04 23:58:46 -070024#define INVALID_SGI 0xFFU
Tanmay Shahfdae9e82022-08-26 15:06:00 -070025#define PM_INIT_SUSPEND_CB (30U)
26#define PM_NOTIFY_CB (32U)
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060027DEFINE_RENAME_SYSREG_RW_FUNCS(icc_asgi1r_el1, S3_0_C12_C11_6)
Tejas Patel354fe572018-12-14 00:55:37 -080028
Tejas Patel59c608a2019-01-09 04:10:29 -080029/* pm_up = true - UP, pm_up = false - DOWN */
30static bool pm_up;
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +053031static uint32_t sgi = (uint32_t)INVALID_SGI;
Tejas Patel59c608a2019-01-09 04:10:29 -080032
Tanmay Shahfdae9e82022-08-26 15:06:00 -070033static void notify_os(void)
34{
35 int32_t cpu;
36 uint32_t reg;
37
38 cpu = plat_my_core_pos() + 1U;
39
40 reg = (cpu | (sgi << XSCUGIC_SGIR_EL1_INITID_SHIFT));
41 write_icc_asgi1r_el1(reg);
42}
43
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053044static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle,
45 void *cookie)
46{
Tanmay Shahfdae9e82022-08-26 15:06:00 -070047 uint32_t payload[4] = {0};
48
49 VERBOSE("Received IPI FIQ from firmware\n");
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060050
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053051 (void)plat_ic_acknowledge_interrupt();
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060052
Tanmay Shahfdae9e82022-08-26 15:06:00 -070053 pm_get_callbackdata(payload, ARRAY_SIZE(payload), 0, 0);
54 switch (payload[0]) {
55 case PM_INIT_SUSPEND_CB:
56 case PM_NOTIFY_CB:
57 if (sgi != INVALID_SGI) {
58 notify_os();
59 }
60 break;
61 default:
62 pm_ipi_irq_clear(primary_proc);
63 WARN("Invalid IPI payload\n");
64 break;
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060065 }
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +053066
67 /* Clear FIQ */
68 plat_ic_end_of_interrupt(id);
69
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060070 return 0;
71}
72
73/**
74 * pm_register_sgi() - PM register the IPI interrupt
75 *
76 * @sgi - SGI number to be used for communication.
Venkatesh Yadav Abbarapuc8bbedc2021-04-19 07:49:57 -060077 * @reset - Reset to invalid SGI when reset=1.
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060078 * @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 * Update the SGI number to be used.
83 *
84 */
Venkatesh Yadav Abbarapu2cefbcd2022-07-31 14:05:40 +053085int32_t pm_register_sgi(uint32_t sgi_num, uint32_t reset)
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060086{
Venkatesh Yadav Abbarapuc8bbedc2021-04-19 07:49:57 -060087 if (reset == 1U) {
88 sgi = INVALID_SGI;
89 return 0;
90 }
91
92 if (sgi != INVALID_SGI) {
Venkatesh Yadav Abbarapuaa4898a2021-03-31 03:07:40 -060093 return -EBUSY;
94 }
95
96 if (sgi_num >= GICV3_MAX_SGI_TARGETS) {
97 return -EINVAL;
98 }
99
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +0530100 sgi = (uint32_t)sgi_num;
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +0530101 return 0;
102}
103
Tejas Patel354fe572018-12-14 00:55:37 -0800104/**
105 * pm_setup() - PM service setup
106 *
107 * @return On success, the initialization function must return 0.
108 * Any other return value will cause the framework to ignore
109 * the service
110 *
111 * Initialization functions for Versal power management for
112 * communicaton with PMC.
113 *
114 * Called from sip_svc_setup initialization function with the
115 * rt_svc_init signature.
116 */
Venkatesh Yadav Abbarapu2cefbcd2022-07-31 14:05:40 +0530117int32_t pm_setup(void)
Tejas Patel354fe572018-12-14 00:55:37 -0800118{
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +0530119 int32_t status, ret = 0;
Tejas Patel354fe572018-12-14 00:55:37 -0800120
121 status = pm_ipi_init(primary_proc);
122
123 if (status < 0) {
124 INFO("BL31: PM Service Init Failed, Error Code %d!\n", status);
125 ret = status;
Tejas Patel59c608a2019-01-09 04:10:29 -0800126 } else {
127 pm_up = true;
Tejas Patel354fe572018-12-14 00:55:37 -0800128 }
129
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +0530130 /*
131 * Enable IPI IRQ
132 * assume the rich OS is OK to handle callback IRQs now.
133 * Even if we were wrong, it would not enable the IRQ in
134 * the GIC.
135 */
136 pm_ipi_irq_enable(primary_proc);
137
138 ret = request_intr_type_el3(PLAT_VERSAL_IPI_IRQ, ipi_fiq_handler);
Abhyuday Godhasara44877942021-08-05 02:59:26 -0700139 if (ret != 0) {
Shubhrajyoti Dattaabf61222021-03-17 23:01:17 +0530140 WARN("BL31: registering IPI interrupt failed\n");
141 }
Tejas Patel354fe572018-12-14 00:55:37 -0800142 return ret;
143}
Tejas Patel59c608a2019-01-09 04:10:29 -0800144
145/**
Tanmay Shahff34daa2021-08-09 11:00:41 -0700146 * eemi_for_compatibility() - EEMI calls handler for deprecated calls
Tejas Patel59c608a2019-01-09 04:10:29 -0800147 *
Tanmay Shahff34daa2021-08-09 11:00:41 -0700148 * @return - If EEMI API found then, uintptr_t type address, else 0
Tejas Patel59c608a2019-01-09 04:10:29 -0800149 *
Tanmay Shahff34daa2021-08-09 11:00:41 -0700150 * Some EEMI API's use case needs to be changed in Linux driver, so they
151 * can take advantage of common EEMI handler in TF-A. As of now the old
152 * implementation of these APIs are required to maintain backward compatibility
153 * until their use case in linux driver changes.
Tejas Patel59c608a2019-01-09 04:10:29 -0800154 */
Tanmay Shahff34daa2021-08-09 11:00:41 -0700155static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg,
156 void *handle, uint32_t security_flag)
Tejas Patel59c608a2019-01-09 04:10:29 -0800157{
158 enum pm_ret_status ret;
159
Tanmay Shahff34daa2021-08-09 11:00:41 -0700160 switch (api_id) {
Tejas Patel59c608a2019-01-09 04:10:29 -0800161
Tejas Patel9141f442019-01-10 03:03:48 -0800162 case PM_IOCTL:
163 {
164 uint32_t value;
165
166 ret = pm_api_ioctl(pm_arg[0], pm_arg[1], pm_arg[2],
Venkatesh Yadav Abbarapu4b233392021-10-20 22:11:53 -0600167 pm_arg[3], pm_arg[4],
168 &value, security_flag);
Tanmay Shahff34daa2021-08-09 11:00:41 -0700169 if (ret == PM_RET_ERROR_NOTSUPPORTED)
170 return (uintptr_t)0;
171
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530172 SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U);
Tejas Patel9141f442019-01-10 03:03:48 -0800173 }
174
Tejas Patela3e34ad2019-02-01 17:25:19 +0530175 case PM_QUERY_DATA:
176 {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700177 uint32_t data[PAYLOAD_ARG_CNT] = { 0 };
Tejas Patela3e34ad2019-02-01 17:25:19 +0530178
179 ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2],
Michal Simek57cf55a2022-07-29 07:48:59 +0200180 pm_arg[3], data, security_flag);
Rajan Vaja030620d2020-11-23 04:13:54 -0800181
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530182 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)data[0] << 32U),
Michal Simek57cf55a2022-07-29 07:48:59 +0200183 (uint64_t)data[1] | ((uint64_t)data[2] << 32U));
Rajan Vaja030620d2020-11-23 04:13:54 -0800184 }
Tejas Patel59c608a2019-01-09 04:10:29 -0800185
Tanmay Shahff34daa2021-08-09 11:00:41 -0700186 case PM_FEATURE_CHECK:
Tejas Patel59c608a2019-01-09 04:10:29 -0800187 {
Ronak Jain70d1c582022-02-04 00:42:55 -0800188 uint32_t result[PAYLOAD_ARG_CNT] = {0U};
Tejas Patel59c608a2019-01-09 04:10:29 -0800189
Ronak Jain70d1c582022-02-04 00:42:55 -0800190 ret = pm_feature_check(pm_arg[0], result, security_flag);
Venkatesh Yadav Abbarapua0657d92022-07-20 09:03:22 +0530191 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32U),
192 (uint64_t)result[1] | ((uint64_t)result[2] << 32U));
Tejas Patel59c608a2019-01-09 04:10:29 -0800193 }
194
Tanmay Shahff34daa2021-08-09 11:00:41 -0700195 case PM_LOAD_PDI:
Tejas Patel59c608a2019-01-09 04:10:29 -0800196 {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700197 ret = pm_load_pdi(pm_arg[0], pm_arg[1], pm_arg[2],
198 security_flag);
199 SMC_RET1(handle, (uint64_t)ret);
200 }
Tejas Patel59c608a2019-01-09 04:10:29 -0800201
Tanmay Shahff34daa2021-08-09 11:00:41 -0700202 default:
203 return (uintptr_t)0;
Tejas Patel59c608a2019-01-09 04:10:29 -0800204 }
Tanmay Shahff34daa2021-08-09 11:00:41 -0700205}
Tejas Patel59c608a2019-01-09 04:10:29 -0800206
Tanmay Shahff34daa2021-08-09 11:00:41 -0700207/**
208 * eemi_psci_debugfs_handler() - EEMI API invoked from PSCI
209 *
210 * These EEMI APIs performs CPU specific power management tasks.
211 * These EEMI APIs are invoked either from PSCI or from debugfs in kernel.
212 * These calls require CPU specific processing before sending IPI request to
213 * Platform Management Controller. For example enable/disable CPU specific
214 * interrupts. This requires separate handler for these calls and may not be
215 * handled using common eemi handler
216 */
217static uintptr_t eemi_psci_debugfs_handler(uint32_t api_id, uint32_t *pm_arg,
218 void *handle, uint32_t security_flag)
219{
220 enum pm_ret_status ret;
Tejas Patel59c608a2019-01-09 04:10:29 -0800221
Tanmay Shahff34daa2021-08-09 11:00:41 -0700222 switch (api_id) {
Tejas Patel59c608a2019-01-09 04:10:29 -0800223
Tanmay Shahff34daa2021-08-09 11:00:41 -0700224 case PM_SELF_SUSPEND:
225 ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
226 pm_arg[3], security_flag);
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530227 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel59c608a2019-01-09 04:10:29 -0800228
Tanmay Shahff34daa2021-08-09 11:00:41 -0700229 case PM_FORCE_POWERDOWN:
230 ret = pm_force_powerdown(pm_arg[0], pm_arg[1], security_flag);
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530231 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel84275bf2020-09-01 04:43:53 -0700232
Tanmay Shahff34daa2021-08-09 11:00:41 -0700233 case PM_REQ_SUSPEND:
234 ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2],
235 pm_arg[3], security_flag);
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530236 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel84275bf2020-09-01 04:43:53 -0700237
Tanmay Shahff34daa2021-08-09 11:00:41 -0700238 case PM_ABORT_SUSPEND:
239 ret = pm_abort_suspend(pm_arg[0], security_flag);
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530240 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel59c608a2019-01-09 04:10:29 -0800241
Tanmay Shahff34daa2021-08-09 11:00:41 -0700242 case PM_SYSTEM_SHUTDOWN:
243 ret = pm_system_shutdown(pm_arg[0], pm_arg[1], security_flag);
Venkatesh Yadav Abbarapud90e47b2022-07-28 08:50:30 +0530244 SMC_RET1(handle, (u_register_t)ret);
Tejas Patel59c608a2019-01-09 04:10:29 -0800245
Tanmay Shahff34daa2021-08-09 11:00:41 -0700246 default:
247 return (uintptr_t)0;
Tejas Patel59c608a2019-01-09 04:10:29 -0800248 }
Tanmay Shahff34daa2021-08-09 11:00:41 -0700249}
Tejas Patel59c608a2019-01-09 04:10:29 -0800250
Tanmay Shahff34daa2021-08-09 11:00:41 -0700251/**
252 * TF_A_specific_handler() - SMC handler for TF-A specific functionality
253 *
254 * These EEMI calls performs functionality that does not require
255 * IPI transaction. The handler ends in TF-A and returns requested data to
256 * kernel from TF-A
257 */
258static uintptr_t TF_A_specific_handler(uint32_t api_id, uint32_t *pm_arg,
259 void *handle, uint32_t security_flag)
260{
261 switch (api_id) {
Tejas Patel59c608a2019-01-09 04:10:29 -0800262
Tanmay Shah0dde16c2021-12-14 04:53:40 -0800263 case TF_A_PM_REGISTER_SGI:
264 {
Venkatesh Yadav Abbarapubde87592022-05-24 11:11:12 +0530265 int32_t ret;
Tanmay Shah0dde16c2021-12-14 04:53:40 -0800266
267 ret = pm_register_sgi(pm_arg[0], pm_arg[1]);
268 if (ret != 0) {
269 SMC_RET1(handle, (uint32_t)PM_RET_ERROR_ARGS);
270 }
271
272 SMC_RET1(handle, (uint32_t)PM_RET_SUCCESS);
273 }
274
Tanmay Shahff34daa2021-08-09 11:00:41 -0700275 case PM_GET_CALLBACK_DATA:
Tejas Patel59c608a2019-01-09 04:10:29 -0800276 {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700277 uint32_t result[4] = {0};
Tejas Patel59c608a2019-01-09 04:10:29 -0800278
Tanmay Shahfdae9e82022-08-26 15:06:00 -0700279 pm_get_callbackdata(result, ARRAY_SIZE(result), security_flag, 1U);
Tanmay Shahff34daa2021-08-09 11:00:41 -0700280 SMC_RET2(handle,
Venkatesh Yadav Abbarapua0657d92022-07-20 09:03:22 +0530281 (uint64_t)result[0] | ((uint64_t)result[1] << 32U),
282 (uint64_t)result[2] | ((uint64_t)result[3] << 32U));
Tejas Patel59c608a2019-01-09 04:10:29 -0800283 }
284
Tejas Patel044001d2019-01-21 17:56:48 +0530285 case PM_GET_TRUSTZONE_VERSION:
286 SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS |
Venkatesh Yadav Abbarapua0657d92022-07-20 09:03:22 +0530287 ((uint64_t)VERSAL_TZ_VERSION << 32U));
Tejas Patel044001d2019-01-21 17:56:48 +0530288
Tanmay Shahff34daa2021-08-09 11:00:41 -0700289 default:
290 return (uintptr_t)0;
Ravi Patelbd4aa5a2019-08-12 03:17:54 -0700291 }
Tanmay Shahff34daa2021-08-09 11:00:41 -0700292}
Ravi Patelbd4aa5a2019-08-12 03:17:54 -0700293
Tanmay Shahff34daa2021-08-09 11:00:41 -0700294/**
295 * eemi_handler() - Prepare EEMI payload and perform IPI transaction
296 *
297 * EEMI - Embedded Energy Management Interface is Xilinx proprietary protocol
298 * to allow communication between power management controller and different
299 * processing clusters.
300 *
301 * This handler prepares EEMI protocol payload received from kernel and performs
302 * IPI transaction.
303 */
304static uintptr_t eemi_handler(uint32_t api_id, uint32_t *pm_arg,
305 void *handle, uint32_t security_flag)
306{
307 enum pm_ret_status ret;
308 uint32_t buf[PAYLOAD_ARG_CNT] = {0};
Ravi Patel22b0b492019-03-06 12:34:46 +0530309
Tanmay Shahff34daa2021-08-09 11:00:41 -0700310 ret = pm_handle_eemi_call(security_flag, api_id, pm_arg[0], pm_arg[1],
311 pm_arg[2], pm_arg[3], pm_arg[4],
312 (uint64_t *)buf);
313 /*
314 * Two IOCTLs, to get clock name and pinctrl name of pm_query_data API
315 * receives 5 words of respoonse from firmware. Currently linux driver can
316 * receive only 4 words from TF-A. So, this needs to be handled separately
317 * than other eemi calls.
318 */
319 if (api_id == PM_QUERY_DATA) {
320 if ((pm_arg[0] == XPM_QID_CLOCK_GET_NAME ||
321 pm_arg[0] == XPM_QID_PINCTRL_GET_FUNCTION_NAME) &&
322 ret == PM_RET_SUCCESS) {
Venkatesh Yadav Abbarapu2d27cb92022-07-31 14:08:53 +0530323 SMC_RET2(handle, (uint64_t)buf[0] | ((uint64_t)buf[1] << 32U),
324 (uint64_t)buf[2] | ((uint64_t)buf[3] << 32U));
Tanmay Shahff34daa2021-08-09 11:00:41 -0700325 }
Ravi Patel22b0b492019-03-06 12:34:46 +0530326 }
327
Venkatesh Yadav Abbarapu2d27cb92022-07-31 14:08:53 +0530328 SMC_RET2(handle, (uint64_t)ret | ((uint64_t)buf[0] << 32U),
329 (uint64_t)buf[1] | ((uint64_t)buf[2] << 32U));
Tanmay Shahff34daa2021-08-09 11:00:41 -0700330}
Jolly Shahed05a712019-03-22 05:33:39 +0530331
Tanmay Shahff34daa2021-08-09 11:00:41 -0700332/**
333 * pm_smc_handler() - SMC handler for PM-API calls coming from EL1/EL2.
334 * @smc_fid - Function Identifier
335 * @x1 - x4 - SMC64 Arguments from kernel
Venkatesh Yadav Abbarapu4b233392021-10-20 22:11:53 -0600336 * x3 (upper 32-bits) and x4 are Unused
Tanmay Shahff34daa2021-08-09 11:00:41 -0700337 * @cookie - Unused
338 * @handler - Pointer to caller's context structure
339 *
340 * @return - Unused
341 *
342 * Determines that smc_fid is valid and supported PM SMC Function ID from the
343 * list of pm_api_ids, otherwise completes the request with
344 * the unknown SMC Function ID
345 *
346 * The SMC calls for PM service are forwarded from SIP Service SMC handler
347 * function with rt_svc_handle signature
348 */
349uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
Venkatesh Yadav Abbarapud3c0eb42022-05-24 14:02:52 +0530350 uint64_t x4, const void *cookie, void *handle, uint64_t flags)
Tanmay Shahff34daa2021-08-09 11:00:41 -0700351{
352 uintptr_t ret;
353 uint32_t pm_arg[PAYLOAD_ARG_CNT] = {0};
354 uint32_t security_flag = SECURE_FLAG;
355 uint32_t api_id;
Saeed Nowshadi2294b422019-06-03 10:22:35 -0700356
Tanmay Shahff34daa2021-08-09 11:00:41 -0700357 /* Handle case where PM wasn't initialized properly */
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530358 if (!pm_up) {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700359 SMC_RET1(handle, SMC_UNK);
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530360 }
Saeed Nowshadi2294b422019-06-03 10:22:35 -0700361
Tanmay Shahff34daa2021-08-09 11:00:41 -0700362 /*
363 * Mark BIT24 payload (i.e 1st bit of pm_arg[3] ) as non-secure (1)
364 * if smc called is non secure
365 */
366 if (is_caller_non_secure(flags)) {
367 security_flag = NON_SECURE_FLAG;
Tejas Patel5c154e12020-11-25 01:53:12 -0800368 }
369
Tanmay Shahff34daa2021-08-09 11:00:41 -0700370 pm_arg[0] = (uint32_t)x1;
Venkatesh Yadav Abbarapu2d27cb92022-07-31 14:08:53 +0530371 pm_arg[1] = (uint32_t)(x1 >> 32U);
Tanmay Shahff34daa2021-08-09 11:00:41 -0700372 pm_arg[2] = (uint32_t)x2;
Venkatesh Yadav Abbarapu2d27cb92022-07-31 14:08:53 +0530373 pm_arg[3] = (uint32_t)(x2 >> 32U);
Venkatesh Yadav Abbarapu4b233392021-10-20 22:11:53 -0600374 pm_arg[4] = (uint32_t)x3;
Tanmay Shahff34daa2021-08-09 11:00:41 -0700375 (void)(x4);
376 api_id = smc_fid & FUNCID_NUM_MASK;
Tejas Patel42015552020-11-25 01:56:57 -0800377
Tanmay Shahff34daa2021-08-09 11:00:41 -0700378 ret = eemi_for_compatibility(api_id, pm_arg, handle, security_flag);
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530379 if (ret != (uintptr_t)0) {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700380 return ret;
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530381 }
Tanmay Shahff34daa2021-08-09 11:00:41 -0700382
383 ret = eemi_psci_debugfs_handler(api_id, pm_arg, handle, flags);
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530384 if (ret != (uintptr_t)0) {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700385 return ret;
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530386 }
Tanmay Shahff34daa2021-08-09 11:00:41 -0700387
388 ret = TF_A_specific_handler(api_id, pm_arg, handle, security_flag);
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530389 if (ret != (uintptr_t)0) {
Tanmay Shahff34daa2021-08-09 11:00:41 -0700390 return ret;
Venkatesh Yadav Abbarapuab167132022-05-25 15:18:24 +0530391 }
Tanmay Shahff34daa2021-08-09 11:00:41 -0700392
393 ret = eemi_handler(api_id, pm_arg, handle, security_flag);
394
395 return ret;
Tejas Patel59c608a2019-01-09 04:10:29 -0800396}