Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 1 | /* |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 2 | * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. |
Jay Buddhabhatti | 26e138a | 2022-12-21 23:03:35 -0800 | [diff] [blame] | 3 | * Copyright (c) 2022-2023, Advanced Micro Devices, Inc. All rights reserved. |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 4 | * |
| 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> |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 14 | #include <stdbool.h> |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 15 | |
| 16 | #include "../drivers/arm/gic/v3/gicv3_private.h" |
| 17 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 18 | #include <common/runtime_svc.h> |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 19 | #include <drivers/arm/gicv3.h> |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 20 | #include <lib/psci/psci.h> |
| 21 | #include <plat/arm/common/plat_arm.h> |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 22 | #include <plat/common/platform.h> |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 23 | |
| 24 | #include <plat_private.h> |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 25 | #include "pm_api_sys.h" |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 26 | #include "pm_client.h" |
| 27 | #include "pm_ipi.h" |
Jay Buddhabhatti | 10498a2 | 2023-07-31 00:11:00 -0700 | [diff] [blame] | 28 | #include "pm_svc_main.h" |
Tanmay Shah | fde084c | 2022-09-13 10:24:27 -0700 | [diff] [blame] | 29 | |
| 30 | #define MODE 0x80000000U |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 31 | |
| 32 | #define XSCUGIC_SGIR_EL1_INITID_SHIFT 24U |
Abhyuday Godhasara | edc38ae | 2021-08-04 23:58:46 -0700 | [diff] [blame] | 33 | #define INVALID_SGI 0xFFU |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 34 | #define PM_INIT_SUSPEND_CB (30U) |
| 35 | #define PM_NOTIFY_CB (32U) |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 36 | #define EVENT_CPU_PWRDWN (4U) |
Tanmay Shah | 2c0fd19 | 2024-02-13 17:07:42 -0800 | [diff] [blame^] | 37 | #define MBOX_SGI_SHARED_IPI (7U) |
| 38 | |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 39 | /* 1 sec of wait timeout for secondary core down */ |
| 40 | #define PWRDWN_WAIT_TIMEOUT (1000U) |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 41 | DEFINE_RENAME_SYSREG_RW_FUNCS(icc_asgi1r_el1, S3_0_C12_C11_6) |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 42 | |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 43 | /* pm_up = true - UP, pm_up = false - DOWN */ |
| 44 | static bool pm_up; |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 45 | static uint32_t sgi = (uint32_t)INVALID_SGI; |
Jay Buddhabhatti | 10e71e4 | 2023-06-19 05:08:54 -0700 | [diff] [blame] | 46 | bool pwrdwn_req_received; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 47 | |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 48 | static void notify_os(void) |
| 49 | { |
Jay Buddhabhatti | bfe18c4 | 2023-09-11 23:50:53 -0700 | [diff] [blame] | 50 | plat_ic_raise_ns_sgi(sgi, read_mpidr_el1()); |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 51 | } |
| 52 | |
Jay Buddhabhatti | 1dfe497 | 2023-04-25 04:34:51 -0700 | [diff] [blame] | 53 | static uint64_t cpu_pwrdwn_req_handler(uint32_t id, uint32_t flags, |
| 54 | void *handle, void *cookie) |
| 55 | { |
| 56 | uint32_t cpu_id = plat_my_core_pos(); |
| 57 | |
| 58 | VERBOSE("Powering down CPU %d\n", cpu_id); |
| 59 | |
| 60 | /* Deactivate CPU power down SGI */ |
| 61 | plat_ic_end_of_interrupt(CPU_PWR_DOWN_REQ_INTR); |
| 62 | |
| 63 | return psci_cpu_off(); |
| 64 | } |
| 65 | |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 66 | /** |
| 67 | * raise_pwr_down_interrupt() - Callback function to raise SGI. |
| 68 | * @mpidr: MPIDR for the target CPU. |
| 69 | * |
| 70 | * Raise SGI interrupt to trigger the CPU power down sequence on all the |
| 71 | * online secondary cores. |
| 72 | */ |
| 73 | static void raise_pwr_down_interrupt(u_register_t mpidr) |
| 74 | { |
| 75 | plat_ic_raise_el3_sgi(CPU_PWR_DOWN_REQ_INTR, mpidr); |
| 76 | } |
| 77 | |
Jay Buddhabhatti | 10e71e4 | 2023-06-19 05:08:54 -0700 | [diff] [blame] | 78 | void request_cpu_pwrdwn(void) |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 79 | { |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 80 | enum pm_ret_status ret; |
| 81 | |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 82 | VERBOSE("CPU power down request received\n"); |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 83 | |
| 84 | /* Send powerdown request to online secondary core(s) */ |
| 85 | ret = psci_stop_other_cores(PWRDWN_WAIT_TIMEOUT, raise_pwr_down_interrupt); |
| 86 | if (ret != PSCI_E_SUCCESS) { |
| 87 | ERROR("Failed to powerdown secondary core(s)\n"); |
| 88 | } |
| 89 | |
| 90 | /* Clear IPI IRQ */ |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 91 | pm_ipi_irq_clear(primary_proc); |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 92 | |
| 93 | /* Deactivate IPI IRQ */ |
| 94 | plat_ic_end_of_interrupt(PLAT_VERSAL_IPI_IRQ); |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 95 | } |
| 96 | |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 97 | static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle, |
| 98 | void *cookie) |
| 99 | { |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 100 | uint32_t payload[4] = {0}; |
Naman Trivedi Manojbhai | beec83f | 2023-03-07 12:41:12 +0530 | [diff] [blame] | 101 | enum pm_ret_status ret; |
Tanmay Shah | 2c0fd19 | 2024-02-13 17:07:42 -0800 | [diff] [blame^] | 102 | int ipi_status, i; |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 103 | |
| 104 | VERBOSE("Received IPI FIQ from firmware\n"); |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 105 | |
Jay Buddhabhatti | ebf638d | 2023-10-08 22:08:02 -0700 | [diff] [blame] | 106 | console_flush(); |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 107 | (void)plat_ic_acknowledge_interrupt(); |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 108 | |
Tanmay Shah | 2c0fd19 | 2024-02-13 17:07:42 -0800 | [diff] [blame^] | 109 | /* Check status register for each IPI except PMC */ |
| 110 | for (i = IPI_ID_APU; i <= IPI_ID_5; i++) { |
| 111 | ipi_status = ipi_mb_enquire_status(IPI_ID_APU, i); |
| 112 | |
| 113 | /* If any agent other than PMC has generated IPI FIQ then send SGI to mbox driver */ |
| 114 | if (ipi_status & IPI_MB_STATUS_RECV_PENDING) { |
| 115 | plat_ic_raise_ns_sgi(MBOX_SGI_SHARED_IPI, read_mpidr_el1()); |
| 116 | break; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /* If PMC has not generated interrupt then end ISR */ |
| 121 | ipi_status = ipi_mb_enquire_status(IPI_ID_APU, IPI_ID_PMC); |
| 122 | if ((ipi_status & IPI_MB_STATUS_RECV_PENDING) == 0) { |
| 123 | plat_ic_end_of_interrupt(id); |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | /* Handle PMC case */ |
Naman Trivedi Manojbhai | beec83f | 2023-03-07 12:41:12 +0530 | [diff] [blame] | 128 | ret = pm_get_callbackdata(payload, ARRAY_SIZE(payload), 0, 0); |
| 129 | if (ret != PM_RET_SUCCESS) { |
| 130 | payload[0] = ret; |
| 131 | } |
| 132 | |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 133 | switch (payload[0]) { |
| 134 | case PM_INIT_SUSPEND_CB: |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 135 | if (sgi != INVALID_SGI) { |
| 136 | notify_os(); |
| 137 | } |
| 138 | break; |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 139 | case PM_NOTIFY_CB: |
| 140 | if (sgi != INVALID_SGI) { |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 141 | if (payload[2] == EVENT_CPU_PWRDWN) { |
| 142 | if (pwrdwn_req_received) { |
| 143 | pwrdwn_req_received = false; |
| 144 | request_cpu_pwrdwn(); |
Jay Buddhabhatti | 3c06c7b | 2023-04-25 05:09:15 -0700 | [diff] [blame] | 145 | (void)psci_cpu_off(); |
Jay Buddhabhatti | a0f8557 | 2023-04-25 04:15:51 -0700 | [diff] [blame] | 146 | break; |
| 147 | } else { |
| 148 | pwrdwn_req_received = true; |
| 149 | } |
| 150 | } |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 151 | notify_os(); |
| 152 | } |
| 153 | break; |
Naman Trivedi Manojbhai | beec83f | 2023-03-07 12:41:12 +0530 | [diff] [blame] | 154 | case PM_RET_ERROR_INVALID_CRC: |
| 155 | pm_ipi_irq_clear(primary_proc); |
| 156 | WARN("Invalid CRC in the payload\n"); |
| 157 | break; |
| 158 | |
Tanmay Shah | fdae9e8 | 2022-08-26 15:06:00 -0700 | [diff] [blame] | 159 | default: |
| 160 | pm_ipi_irq_clear(primary_proc); |
| 161 | WARN("Invalid IPI payload\n"); |
| 162 | break; |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 163 | } |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 164 | |
| 165 | /* Clear FIQ */ |
| 166 | plat_ic_end_of_interrupt(id); |
| 167 | |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 172 | * pm_register_sgi() - PM register the IPI interrupt. |
| 173 | * @sgi_num: SGI number to be used for communication. |
| 174 | * @reset: Reset to invalid SGI when reset=1. |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 175 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 176 | * Return: On success, the initialization function must return 0. |
| 177 | * Any other return value will cause the framework to ignore |
| 178 | * the service. |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 179 | * |
| 180 | * Update the SGI number to be used. |
| 181 | * |
| 182 | */ |
Venkatesh Yadav Abbarapu | 2cefbcd | 2022-07-31 14:05:40 +0530 | [diff] [blame] | 183 | int32_t pm_register_sgi(uint32_t sgi_num, uint32_t reset) |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 184 | { |
Venkatesh Yadav Abbarapu | c8bbedc | 2021-04-19 07:49:57 -0600 | [diff] [blame] | 185 | if (reset == 1U) { |
| 186 | sgi = INVALID_SGI; |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | if (sgi != INVALID_SGI) { |
Venkatesh Yadav Abbarapu | aa4898a | 2021-03-31 03:07:40 -0600 | [diff] [blame] | 191 | return -EBUSY; |
| 192 | } |
| 193 | |
| 194 | if (sgi_num >= GICV3_MAX_SGI_TARGETS) { |
| 195 | return -EINVAL; |
| 196 | } |
| 197 | |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 198 | sgi = (uint32_t)sgi_num; |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 199 | return 0; |
| 200 | } |
| 201 | |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 202 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 203 | * pm_setup() - PM service setup. |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 204 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 205 | * Return: On success, the initialization function must return 0. |
| 206 | * Any other return value will cause the framework to ignore |
| 207 | * the service. |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 208 | * |
| 209 | * Initialization functions for Versal power management for |
| 210 | * communicaton with PMC. |
| 211 | * |
| 212 | * Called from sip_svc_setup initialization function with the |
| 213 | * rt_svc_init signature. |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 214 | * |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 215 | */ |
Venkatesh Yadav Abbarapu | 2cefbcd | 2022-07-31 14:05:40 +0530 | [diff] [blame] | 216 | int32_t pm_setup(void) |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 217 | { |
HariBabu Gattem | aa81171 | 2022-10-07 00:07:49 -0700 | [diff] [blame] | 218 | int32_t ret = 0; |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 219 | |
HariBabu Gattem | aa81171 | 2022-10-07 00:07:49 -0700 | [diff] [blame] | 220 | pm_ipi_init(primary_proc); |
| 221 | pm_up = true; |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 222 | |
Jay Buddhabhatti | 1dfe497 | 2023-04-25 04:34:51 -0700 | [diff] [blame] | 223 | /* register SGI handler for CPU power down request */ |
| 224 | ret = request_intr_type_el3(CPU_PWR_DOWN_REQ_INTR, cpu_pwrdwn_req_handler); |
| 225 | if (ret != 0) { |
| 226 | WARN("BL31: registering SGI interrupt failed\n"); |
| 227 | } |
| 228 | |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 229 | /* |
| 230 | * Enable IPI IRQ |
| 231 | * assume the rich OS is OK to handle callback IRQs now. |
| 232 | * Even if we were wrong, it would not enable the IRQ in |
| 233 | * the GIC. |
| 234 | */ |
| 235 | pm_ipi_irq_enable(primary_proc); |
| 236 | |
| 237 | ret = request_intr_type_el3(PLAT_VERSAL_IPI_IRQ, ipi_fiq_handler); |
Abhyuday Godhasara | 4487794 | 2021-08-05 02:59:26 -0700 | [diff] [blame] | 238 | if (ret != 0) { |
Shubhrajyoti Datta | abf6122 | 2021-03-17 23:01:17 +0530 | [diff] [blame] | 239 | WARN("BL31: registering IPI interrupt failed\n"); |
| 240 | } |
Tanmay Shah | fde084c | 2022-09-13 10:24:27 -0700 | [diff] [blame] | 241 | |
| 242 | gicd_write_irouter(gicv3_driver_data->gicd_base, PLAT_VERSAL_IPI_IRQ, MODE); |
Tejas Patel | 354fe57 | 2018-12-14 00:55:37 -0800 | [diff] [blame] | 243 | return ret; |
| 244 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 245 | |
| 246 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 247 | * eemi_for_compatibility() - EEMI calls handler for deprecated calls. |
| 248 | * @api_id: identifier for the API being called. |
| 249 | * @pm_arg: pointer to the argument data for the API call. |
| 250 | * @handle: Pointer to caller's context structure. |
| 251 | * @security_flag: SECURE_FLAG or NON_SECURE_FLAG. |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 252 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 253 | * Return: If EEMI API found then, uintptr_t type address, else 0. |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 254 | * |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 255 | * Some EEMI API's use case needs to be changed in Linux driver, so they |
| 256 | * can take advantage of common EEMI handler in TF-A. As of now the old |
| 257 | * implementation of these APIs are required to maintain backward compatibility |
| 258 | * until their use case in linux driver changes. |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 259 | * |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 260 | */ |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 261 | static uintptr_t eemi_for_compatibility(uint32_t api_id, uint32_t *pm_arg, |
| 262 | void *handle, uint32_t security_flag) |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 263 | { |
| 264 | enum pm_ret_status ret; |
| 265 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 266 | switch (api_id) { |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 267 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 268 | case (uint32_t)PM_IOCTL: |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 269 | { |
Naman Patel | b8434b1 | 2022-11-16 01:54:23 -0800 | [diff] [blame] | 270 | uint32_t value = 0U; |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 271 | |
| 272 | ret = pm_api_ioctl(pm_arg[0], pm_arg[1], pm_arg[2], |
Venkatesh Yadav Abbarapu | 4b23339 | 2021-10-20 22:11:53 -0600 | [diff] [blame] | 273 | pm_arg[3], pm_arg[4], |
| 274 | &value, security_flag); |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 275 | if (ret == PM_RET_ERROR_NOTSUPPORTED) |
| 276 | return (uintptr_t)0; |
| 277 | |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 278 | SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U); |
Tejas Patel | 9141f44 | 2019-01-10 03:03:48 -0800 | [diff] [blame] | 279 | } |
| 280 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 281 | case (uint32_t)PM_QUERY_DATA: |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 282 | { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 283 | uint32_t data[PAYLOAD_ARG_CNT] = { 0 }; |
Tejas Patel | a3e34ad | 2019-02-01 17:25:19 +0530 | [diff] [blame] | 284 | |
| 285 | ret = pm_query_data(pm_arg[0], pm_arg[1], pm_arg[2], |
Michal Simek | 57cf55a | 2022-07-29 07:48:59 +0200 | [diff] [blame] | 286 | pm_arg[3], data, security_flag); |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 287 | |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 288 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)data[0] << 32U), |
Michal Simek | 57cf55a | 2022-07-29 07:48:59 +0200 | [diff] [blame] | 289 | (uint64_t)data[1] | ((uint64_t)data[2] << 32U)); |
Rajan Vaja | 030620d | 2020-11-23 04:13:54 -0800 | [diff] [blame] | 290 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 291 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 292 | case (uint32_t)PM_FEATURE_CHECK: |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 293 | { |
Ronak Jain | 70d1c58 | 2022-02-04 00:42:55 -0800 | [diff] [blame] | 294 | uint32_t result[PAYLOAD_ARG_CNT] = {0U}; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 295 | |
Ronak Jain | 70d1c58 | 2022-02-04 00:42:55 -0800 | [diff] [blame] | 296 | ret = pm_feature_check(pm_arg[0], result, security_flag); |
Venkatesh Yadav Abbarapu | a0657d9 | 2022-07-20 09:03:22 +0530 | [diff] [blame] | 297 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)result[0] << 32U), |
| 298 | (uint64_t)result[1] | ((uint64_t)result[2] << 32U)); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 299 | } |
| 300 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 301 | case PM_LOAD_PDI: |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 302 | { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 303 | ret = pm_load_pdi(pm_arg[0], pm_arg[1], pm_arg[2], |
| 304 | security_flag); |
| 305 | SMC_RET1(handle, (uint64_t)ret); |
| 306 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 307 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 308 | default: |
| 309 | return (uintptr_t)0; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 310 | } |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 311 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 312 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 313 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 314 | * eemi_psci_debugfs_handler() - EEMI API invoked from PSCI. |
| 315 | * @api_id: identifier for the API being called. |
| 316 | * @pm_arg: pointer to the argument data for the API call. |
| 317 | * @handle: Pointer to caller's context structure. |
| 318 | * @security_flag: SECURE_FLAG or NON_SECURE_FLAG. |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 319 | * |
| 320 | * These EEMI APIs performs CPU specific power management tasks. |
| 321 | * These EEMI APIs are invoked either from PSCI or from debugfs in kernel. |
| 322 | * These calls require CPU specific processing before sending IPI request to |
| 323 | * Platform Management Controller. For example enable/disable CPU specific |
| 324 | * interrupts. This requires separate handler for these calls and may not be |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 325 | * handled using common eemi handler. |
| 326 | * |
| 327 | * Return: If EEMI API found then, uintptr_t type address, else 0. |
| 328 | * |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 329 | */ |
| 330 | static uintptr_t eemi_psci_debugfs_handler(uint32_t api_id, uint32_t *pm_arg, |
| 331 | void *handle, uint32_t security_flag) |
| 332 | { |
| 333 | enum pm_ret_status ret; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 334 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 335 | switch (api_id) { |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 336 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 337 | case (uint32_t)PM_SELF_SUSPEND: |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 338 | ret = pm_self_suspend(pm_arg[0], pm_arg[1], pm_arg[2], |
| 339 | pm_arg[3], security_flag); |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 340 | SMC_RET1(handle, (u_register_t)ret); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 341 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 342 | case (uint32_t)PM_FORCE_POWERDOWN: |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 343 | ret = pm_force_powerdown(pm_arg[0], pm_arg[1], security_flag); |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 344 | SMC_RET1(handle, (u_register_t)ret); |
Tejas Patel | 84275bf | 2020-09-01 04:43:53 -0700 | [diff] [blame] | 345 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 346 | case (uint32_t)PM_REQ_SUSPEND: |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 347 | ret = pm_req_suspend(pm_arg[0], pm_arg[1], pm_arg[2], |
| 348 | pm_arg[3], security_flag); |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 349 | SMC_RET1(handle, (u_register_t)ret); |
Tejas Patel | 84275bf | 2020-09-01 04:43:53 -0700 | [diff] [blame] | 350 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 351 | case (uint32_t)PM_ABORT_SUSPEND: |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 352 | ret = pm_abort_suspend(pm_arg[0], security_flag); |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 353 | SMC_RET1(handle, (u_register_t)ret); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 354 | |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 355 | case (uint32_t)PM_SYSTEM_SHUTDOWN: |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 356 | ret = pm_system_shutdown(pm_arg[0], pm_arg[1], security_flag); |
Venkatesh Yadav Abbarapu | d90e47b | 2022-07-28 08:50:30 +0530 | [diff] [blame] | 357 | SMC_RET1(handle, (u_register_t)ret); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 358 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 359 | default: |
| 360 | return (uintptr_t)0; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 361 | } |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 362 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 363 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 364 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 365 | * TF_A_specific_handler() - SMC handler for TF-A specific functionality. |
| 366 | * @api_id: identifier for the API being called. |
| 367 | * @pm_arg: pointer to the argument data for the API call. |
| 368 | * @handle: Pointer to caller's context structure. |
| 369 | * @security_flag: SECURE_FLAG or NON_SECURE_FLAG. |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 370 | * |
| 371 | * These EEMI calls performs functionality that does not require |
| 372 | * IPI transaction. The handler ends in TF-A and returns requested data to |
Michal Simek | 509bfc7 | 2022-09-14 09:32:47 +0200 | [diff] [blame] | 373 | * kernel from TF-A. |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 374 | * |
| 375 | * Return: If TF-A specific API found then, uintptr_t type address, else 0 |
| 376 | * |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 377 | */ |
| 378 | static uintptr_t TF_A_specific_handler(uint32_t api_id, uint32_t *pm_arg, |
| 379 | void *handle, uint32_t security_flag) |
| 380 | { |
| 381 | switch (api_id) { |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 382 | |
Tanmay Shah | 0dde16c | 2021-12-14 04:53:40 -0800 | [diff] [blame] | 383 | case TF_A_PM_REGISTER_SGI: |
| 384 | { |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 385 | int32_t ret; |
Tanmay Shah | 0dde16c | 2021-12-14 04:53:40 -0800 | [diff] [blame] | 386 | |
| 387 | ret = pm_register_sgi(pm_arg[0], pm_arg[1]); |
| 388 | if (ret != 0) { |
| 389 | SMC_RET1(handle, (uint32_t)PM_RET_ERROR_ARGS); |
| 390 | } |
| 391 | |
| 392 | SMC_RET1(handle, (uint32_t)PM_RET_SUCCESS); |
| 393 | } |
| 394 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 395 | case PM_GET_CALLBACK_DATA: |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 396 | { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 397 | uint32_t result[4] = {0}; |
Naman Trivedi Manojbhai | beec83f | 2023-03-07 12:41:12 +0530 | [diff] [blame] | 398 | enum pm_ret_status ret; |
| 399 | |
| 400 | ret = pm_get_callbackdata(result, ARRAY_SIZE(result), security_flag, 1U); |
| 401 | if (ret != 0) { |
| 402 | result[0] = ret; |
| 403 | } |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 404 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 405 | SMC_RET2(handle, |
Venkatesh Yadav Abbarapu | a0657d9 | 2022-07-20 09:03:22 +0530 | [diff] [blame] | 406 | (uint64_t)result[0] | ((uint64_t)result[1] << 32U), |
| 407 | (uint64_t)result[2] | ((uint64_t)result[3] << 32U)); |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 408 | } |
| 409 | |
Tejas Patel | 044001d | 2019-01-21 17:56:48 +0530 | [diff] [blame] | 410 | case PM_GET_TRUSTZONE_VERSION: |
| 411 | SMC_RET1(handle, (uint64_t)PM_RET_SUCCESS | |
Jay Buddhabhatti | c3da9c0 | 2022-04-04 23:42:04 -0700 | [diff] [blame] | 412 | ((uint64_t)TZ_VERSION << 32U)); |
Tejas Patel | 044001d | 2019-01-21 17:56:48 +0530 | [diff] [blame] | 413 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 414 | default: |
| 415 | return (uintptr_t)0; |
Ravi Patel | bd4aa5a | 2019-08-12 03:17:54 -0700 | [diff] [blame] | 416 | } |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 417 | } |
Ravi Patel | bd4aa5a | 2019-08-12 03:17:54 -0700 | [diff] [blame] | 418 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 419 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 420 | * eemi_handler() - Prepare EEMI payload and perform IPI transaction. |
| 421 | * @api_id: identifier for the API being called. |
| 422 | * @pm_arg: pointer to the argument data for the API call. |
| 423 | * @handle: Pointer to caller's context structure. |
| 424 | * @security_flag: SECURE_FLAG or NON_SECURE_FLAG. |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 425 | * |
| 426 | * EEMI - Embedded Energy Management Interface is Xilinx proprietary protocol |
| 427 | * to allow communication between power management controller and different |
| 428 | * processing clusters. |
| 429 | * |
| 430 | * This handler prepares EEMI protocol payload received from kernel and performs |
| 431 | * IPI transaction. |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 432 | * |
| 433 | * Return: If EEMI API found then, uintptr_t type address, else 0 |
| 434 | * |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 435 | */ |
| 436 | static uintptr_t eemi_handler(uint32_t api_id, uint32_t *pm_arg, |
| 437 | void *handle, uint32_t security_flag) |
| 438 | { |
| 439 | enum pm_ret_status ret; |
| 440 | uint32_t buf[PAYLOAD_ARG_CNT] = {0}; |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 441 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 442 | ret = pm_handle_eemi_call(security_flag, api_id, pm_arg[0], pm_arg[1], |
| 443 | pm_arg[2], pm_arg[3], pm_arg[4], |
| 444 | (uint64_t *)buf); |
| 445 | /* |
| 446 | * Two IOCTLs, to get clock name and pinctrl name of pm_query_data API |
| 447 | * receives 5 words of respoonse from firmware. Currently linux driver can |
| 448 | * receive only 4 words from TF-A. So, this needs to be handled separately |
| 449 | * than other eemi calls. |
| 450 | */ |
Jay Buddhabhatti | f2f84b3 | 2023-02-09 22:56:53 -0800 | [diff] [blame] | 451 | if (api_id == (uint32_t)PM_QUERY_DATA) { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 452 | if ((pm_arg[0] == XPM_QID_CLOCK_GET_NAME || |
| 453 | pm_arg[0] == XPM_QID_PINCTRL_GET_FUNCTION_NAME) && |
| 454 | ret == PM_RET_SUCCESS) { |
Venkatesh Yadav Abbarapu | 2d27cb9 | 2022-07-31 14:08:53 +0530 | [diff] [blame] | 455 | SMC_RET2(handle, (uint64_t)buf[0] | ((uint64_t)buf[1] << 32U), |
| 456 | (uint64_t)buf[2] | ((uint64_t)buf[3] << 32U)); |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 457 | } |
Ravi Patel | 22b0b49 | 2019-03-06 12:34:46 +0530 | [diff] [blame] | 458 | } |
| 459 | |
Venkatesh Yadav Abbarapu | 2d27cb9 | 2022-07-31 14:08:53 +0530 | [diff] [blame] | 460 | SMC_RET2(handle, (uint64_t)ret | ((uint64_t)buf[0] << 32U), |
| 461 | (uint64_t)buf[1] | ((uint64_t)buf[2] << 32U)); |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 462 | } |
Jolly Shah | ed05a71 | 2019-03-22 05:33:39 +0530 | [diff] [blame] | 463 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 464 | /** |
| 465 | * pm_smc_handler() - SMC handler for PM-API calls coming from EL1/EL2. |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 466 | * @smc_fid: Function Identifier. |
| 467 | * @x1: SMC64 Arguments from kernel. |
| 468 | * @x2: SMC64 Arguments from kernel. |
| 469 | * @x3: SMC64 Arguments from kernel (upper 32-bits). |
| 470 | * @x4: Unused. |
| 471 | * @cookie: Unused. |
| 472 | * @handle: Pointer to caller's context structure. |
| 473 | * @flags: SECURE_FLAG or NON_SECURE_FLAG. |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 474 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 475 | * Return: Unused. |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 476 | * |
| 477 | * Determines that smc_fid is valid and supported PM SMC Function ID from the |
| 478 | * list of pm_api_ids, otherwise completes the request with |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 479 | * the unknown SMC Function ID. |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 480 | * |
| 481 | * The SMC calls for PM service are forwarded from SIP Service SMC handler |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 482 | * function with rt_svc_handle signature. |
| 483 | * |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 484 | */ |
| 485 | uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3, |
Venkatesh Yadav Abbarapu | d3c0eb4 | 2022-05-24 14:02:52 +0530 | [diff] [blame] | 486 | uint64_t x4, const void *cookie, void *handle, uint64_t flags) |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 487 | { |
| 488 | uintptr_t ret; |
| 489 | uint32_t pm_arg[PAYLOAD_ARG_CNT] = {0}; |
Jay Buddhabhatti | bd603bf | 2023-07-30 23:49:11 -0700 | [diff] [blame] | 490 | uint32_t security_flag = NON_SECURE_FLAG; |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 491 | uint32_t api_id; |
Jay Buddhabhatti | 10498a2 | 2023-07-31 00:11:00 -0700 | [diff] [blame] | 492 | bool status = false, status_tmp = false; |
Saeed Nowshadi | 2294b42 | 2019-06-03 10:22:35 -0700 | [diff] [blame] | 493 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 494 | /* Handle case where PM wasn't initialized properly */ |
Michal Simek | 5e2f596 | 2022-09-13 11:48:53 +0200 | [diff] [blame] | 495 | if (pm_up == false) { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 496 | SMC_RET1(handle, SMC_UNK); |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 497 | } |
Saeed Nowshadi | 2294b42 | 2019-06-03 10:22:35 -0700 | [diff] [blame] | 498 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 499 | /* |
Jay Buddhabhatti | bd603bf | 2023-07-30 23:49:11 -0700 | [diff] [blame] | 500 | * Mark BIT24 payload (i.e 1st bit of pm_arg[3] ) as secure (0) |
| 501 | * if smc called is secure |
Jay Buddhabhatti | 10498a2 | 2023-07-31 00:11:00 -0700 | [diff] [blame] | 502 | * |
| 503 | * Add redundant macro call to immune the code from glitches |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 504 | */ |
Jay Buddhabhatti | 10498a2 | 2023-07-31 00:11:00 -0700 | [diff] [blame] | 505 | SECURE_REDUNDANT_CALL(status, status_tmp, is_caller_secure, flags); |
| 506 | if ((status != false) && (status_tmp != false)) { |
Jay Buddhabhatti | bd603bf | 2023-07-30 23:49:11 -0700 | [diff] [blame] | 507 | security_flag = SECURE_FLAG; |
Tejas Patel | 5c154e1 | 2020-11-25 01:53:12 -0800 | [diff] [blame] | 508 | } |
| 509 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 510 | pm_arg[0] = (uint32_t)x1; |
Venkatesh Yadav Abbarapu | 2d27cb9 | 2022-07-31 14:08:53 +0530 | [diff] [blame] | 511 | pm_arg[1] = (uint32_t)(x1 >> 32U); |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 512 | pm_arg[2] = (uint32_t)x2; |
Venkatesh Yadav Abbarapu | 2d27cb9 | 2022-07-31 14:08:53 +0530 | [diff] [blame] | 513 | pm_arg[3] = (uint32_t)(x2 >> 32U); |
Venkatesh Yadav Abbarapu | 4b23339 | 2021-10-20 22:11:53 -0600 | [diff] [blame] | 514 | pm_arg[4] = (uint32_t)x3; |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 515 | (void)(x4); |
| 516 | api_id = smc_fid & FUNCID_NUM_MASK; |
Tejas Patel | 4201555 | 2020-11-25 01:56:57 -0800 | [diff] [blame] | 517 | |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 518 | ret = eemi_for_compatibility(api_id, pm_arg, handle, security_flag); |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 519 | if (ret != (uintptr_t)0) { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 520 | return ret; |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 521 | } |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 522 | |
| 523 | ret = eemi_psci_debugfs_handler(api_id, pm_arg, handle, flags); |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 524 | if (ret != (uintptr_t)0) { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 525 | return ret; |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 526 | } |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 527 | |
| 528 | ret = TF_A_specific_handler(api_id, pm_arg, handle, security_flag); |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 529 | if (ret != (uintptr_t)0) { |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 530 | return ret; |
Venkatesh Yadav Abbarapu | ab16713 | 2022-05-25 15:18:24 +0530 | [diff] [blame] | 531 | } |
Tanmay Shah | ff34daa | 2021-08-09 11:00:41 -0700 | [diff] [blame] | 532 | |
| 533 | ret = eemi_handler(api_id, pm_arg, handle, security_flag); |
| 534 | |
| 535 | return ret; |
Tejas Patel | 59c608a | 2019-01-09 04:10:29 -0800 | [diff] [blame] | 536 | } |