Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, Arm Limited and Contributors. All rights reserved. |
Michal Simek | b8eca3b | 2024-04-19 12:16:46 +0200 | [diff] [blame] | 3 | * Copyright (c) 2022-2024, Advanced Micro Devices, Inc. All rights reserved. |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 8 | #include <assert.h> |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <common/debug.h> |
| 11 | #include <lib/mmio.h> |
| 12 | #include <lib/psci/psci.h> |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 13 | #include <plat/arm/common/plat_arm.h> |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 14 | #include <plat/common/platform.h> |
| 15 | #include <plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 16 | |
Jay Buddhabhatti | 10e71e4 | 2023-06-19 05:08:54 -0700 | [diff] [blame] | 17 | #include "drivers/delay_timer.h" |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 18 | #include <plat_private.h> |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame] | 19 | #include "pm_api_sys.h" |
| 20 | #include "pm_client.h" |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 21 | #include <pm_common.h> |
Jay Buddhabhatti | 10e71e4 | 2023-06-19 05:08:54 -0700 | [diff] [blame] | 22 | #include "pm_ipi.h" |
| 23 | #include "pm_svc_main.h" |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame] | 24 | |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 25 | static uintptr_t versal_sec_entry; |
| 26 | |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 27 | static int32_t versal_pwr_domain_on(u_register_t mpidr) |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 28 | { |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 29 | int32_t cpu_id = plat_core_pos_by_mpidr(mpidr); |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame] | 30 | const struct pm_proc *proc; |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 31 | int32_t ret = PSCI_E_INTERN_FAIL; |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 32 | |
| 33 | VERBOSE("%s: mpidr: 0x%lx\n", __func__, mpidr); |
| 34 | |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 35 | if (cpu_id == -1) { |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 36 | goto exit_label; |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 37 | } |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 38 | |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 39 | proc = pm_get_proc((uint32_t)cpu_id); |
Ronak Jain | 807f41b | 2024-05-08 02:41:13 -0700 | [diff] [blame] | 40 | if (proc == NULL) { |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 41 | goto exit_label; |
Michal Simek | b8eca3b | 2024-04-19 12:16:46 +0200 | [diff] [blame] | 42 | } |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 43 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame] | 44 | /* Send request to PMC to wake up selected ACPU core */ |
Abhyuday Godhasara | f435a14 | 2021-08-20 00:04:33 -0700 | [diff] [blame] | 45 | (void)pm_req_wakeup(proc->node_id, (versal_sec_entry & 0xFFFFFFFFU) | 0x1U, |
| 46 | versal_sec_entry >> 32, 0, SECURE_FLAG); |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 47 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame] | 48 | /* Clear power down request */ |
| 49 | pm_client_wakeup(proc); |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 50 | |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 51 | ret = PSCI_E_SUCCESS; |
| 52 | |
| 53 | exit_label: |
| 54 | return ret; |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 55 | } |
| 56 | |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 57 | /** |
| 58 | * versal_pwr_domain_suspend() - This function sends request to PMC to suspend |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 59 | * core. |
| 60 | * @target_state: Targated state. |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 61 | * |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 62 | */ |
| 63 | static void versal_pwr_domain_suspend(const psci_power_state_t *target_state) |
| 64 | { |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 65 | uint32_t state; |
| 66 | uint32_t cpu_id = plat_my_core_pos(); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 67 | const struct pm_proc *proc = pm_get_proc(cpu_id); |
| 68 | |
Ronak Jain | 807f41b | 2024-05-08 02:41:13 -0700 | [diff] [blame] | 69 | if (proc == NULL) { |
Michal Simek | b8eca3b | 2024-04-19 12:16:46 +0200 | [diff] [blame] | 70 | return; |
| 71 | } |
| 72 | |
Abhyuday Godhasara | 589afa5 | 2021-08-11 06:15:13 -0700 | [diff] [blame] | 73 | for (size_t i = 0U; i <= PLAT_MAX_PWR_LVL; i++) { |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 74 | VERBOSE("%s: target_state->pwr_domain_state[%lu]=%x\n", |
| 75 | __func__, i, target_state->pwr_domain_state[i]); |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 76 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 77 | |
| 78 | plat_versal_gic_cpuif_disable(); |
| 79 | |
Ravi Patel | eafc878 | 2019-06-21 05:00:49 -0700 | [diff] [blame] | 80 | if (target_state->pwr_domain_state[1] > PLAT_MAX_RET_STATE) { |
| 81 | plat_versal_gic_save(); |
| 82 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 83 | |
Maheedhar Bollapalli | cc64a79 | 2024-10-14 04:16:03 +0000 | [diff] [blame] | 84 | state = (target_state->pwr_domain_state[1] > PLAT_MAX_RET_STATE) ? |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 85 | PM_STATE_SUSPEND_TO_RAM : PM_STATE_CPU_IDLE; |
| 86 | |
| 87 | /* Send request to PMC to suspend this core */ |
Abhyuday Godhasara | f435a14 | 2021-08-20 00:04:33 -0700 | [diff] [blame] | 88 | (void)pm_self_suspend(proc->node_id, MAX_LATENCY, state, versal_sec_entry, |
| 89 | SECURE_FLAG); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 90 | |
| 91 | /* APU is to be turned off */ |
| 92 | if (target_state->pwr_domain_state[1] > PLAT_MAX_RET_STATE) { |
| 93 | /* disable coherency */ |
| 94 | plat_arm_interconnect_exit_coherency(); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * versal_pwr_domain_suspend_finish() - This function performs actions to finish |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 100 | * suspend procedure. |
| 101 | * @target_state: Targated state. |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 102 | * |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 103 | */ |
| 104 | static void versal_pwr_domain_suspend_finish( |
| 105 | const psci_power_state_t *target_state) |
| 106 | { |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 107 | uint32_t cpu_id = plat_my_core_pos(); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 108 | const struct pm_proc *proc = pm_get_proc(cpu_id); |
| 109 | |
Ronak Jain | 807f41b | 2024-05-08 02:41:13 -0700 | [diff] [blame] | 110 | if (proc == NULL) { |
Michal Simek | b8eca3b | 2024-04-19 12:16:46 +0200 | [diff] [blame] | 111 | return; |
| 112 | } |
| 113 | |
Abhyuday Godhasara | 589afa5 | 2021-08-11 06:15:13 -0700 | [diff] [blame] | 114 | for (size_t i = 0U; i <= PLAT_MAX_PWR_LVL; i++) { |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 115 | VERBOSE("%s: target_state->pwr_domain_state[%lu]=%x\n", |
| 116 | __func__, i, target_state->pwr_domain_state[i]); |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 117 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 118 | |
| 119 | /* Clear the APU power control register for this cpu */ |
| 120 | pm_client_wakeup(proc); |
| 121 | |
| 122 | /* enable coherency */ |
| 123 | plat_arm_interconnect_enter_coherency(); |
| 124 | |
| 125 | /* APU was turned off, so restore GIC context */ |
| 126 | if (target_state->pwr_domain_state[1] > PLAT_MAX_RET_STATE) { |
| 127 | plat_versal_gic_resume(); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 128 | } |
Ravi Patel | eafc878 | 2019-06-21 05:00:49 -0700 | [diff] [blame] | 129 | |
| 130 | plat_versal_gic_cpuif_enable(); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 131 | } |
| 132 | |
Maheedhar Bollapalli | 86d6d70 | 2024-10-07 09:27:58 +0000 | [diff] [blame] | 133 | static void versal_pwr_domain_on_finish(const psci_power_state_t *target_state) |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 134 | { |
| 135 | /* Enable the gic cpu interface */ |
| 136 | plat_versal_gic_pcpu_init(); |
| 137 | |
| 138 | /* Program the gic per-cpu distributor or re-distributor interface */ |
| 139 | plat_versal_gic_cpuif_enable(); |
| 140 | } |
| 141 | |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 142 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 143 | * versal_system_off() - This function sends the system off request to firmware. |
| 144 | * This function does not return. |
| 145 | * |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 146 | */ |
| 147 | static void __dead2 versal_system_off(void) |
| 148 | { |
| 149 | /* Send the power down request to the PMC */ |
Abhyuday Godhasara | f435a14 | 2021-08-20 00:04:33 -0700 | [diff] [blame] | 150 | (void)pm_system_shutdown(XPM_SHUTDOWN_TYPE_SHUTDOWN, |
| 151 | pm_get_shutdown_scope(), SECURE_FLAG); |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 152 | |
Maheedhar Bollapalli | e897f0a | 2024-10-14 06:45:13 +0000 | [diff] [blame] | 153 | while (true) { |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 154 | wfi(); |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 155 | } |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 159 | * versal_system_reset() - This function sends the reset request to firmware |
| 160 | * for the system to reset. This function does not |
| 161 | * return. |
| 162 | * |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 163 | */ |
| 164 | static void __dead2 versal_system_reset(void) |
| 165 | { |
Jay Buddhabhatti | 10e71e4 | 2023-06-19 05:08:54 -0700 | [diff] [blame] | 166 | uint32_t ret, timeout = 10000U; |
| 167 | |
| 168 | request_cpu_pwrdwn(); |
| 169 | |
| 170 | /* |
| 171 | * Send the system reset request to the firmware if power down request |
| 172 | * is not received from firmware. |
| 173 | */ |
| 174 | if (!pwrdwn_req_received) { |
| 175 | (void)pm_system_shutdown(XPM_SHUTDOWN_TYPE_RESET, |
| 176 | pm_get_shutdown_scope(), SECURE_FLAG); |
| 177 | |
| 178 | /* |
| 179 | * Wait for system shutdown request completed and idle callback |
| 180 | * not received. |
| 181 | */ |
| 182 | do { |
| 183 | ret = ipi_mb_enquire_status(primary_proc->ipi->local_ipi_id, |
| 184 | primary_proc->ipi->remote_ipi_id); |
| 185 | udelay(100); |
| 186 | timeout--; |
| 187 | } while ((ret != IPI_MB_STATUS_RECV_PENDING) && (timeout > 0U)); |
| 188 | } |
| 189 | |
| 190 | (void)psci_cpu_off(); |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 191 | |
Maheedhar Bollapalli | e897f0a | 2024-10-14 06:45:13 +0000 | [diff] [blame] | 192 | while (true) { |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 193 | wfi(); |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 194 | } |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 198 | * versal_pwr_domain_off() - This function performs actions to turn off core. |
| 199 | * @target_state: Targated state. |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 200 | * |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 201 | */ |
| 202 | static void versal_pwr_domain_off(const psci_power_state_t *target_state) |
| 203 | { |
Maheedhar Bollapalli | 493c7a2 | 2024-10-08 05:42:28 +0000 | [diff] [blame] | 204 | uint32_t ret, fw_api_version, version_type[RET_PAYLOAD_ARG_CNT] = {0U}; |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 205 | uint32_t cpu_id = plat_my_core_pos(); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 206 | const struct pm_proc *proc = pm_get_proc(cpu_id); |
| 207 | |
Ronak Jain | 807f41b | 2024-05-08 02:41:13 -0700 | [diff] [blame] | 208 | if (proc == NULL) { |
Michal Simek | b8eca3b | 2024-04-19 12:16:46 +0200 | [diff] [blame] | 209 | return; |
| 210 | } |
| 211 | |
Abhyuday Godhasara | 589afa5 | 2021-08-11 06:15:13 -0700 | [diff] [blame] | 212 | for (size_t i = 0U; i <= PLAT_MAX_PWR_LVL; i++) { |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 213 | VERBOSE("%s: target_state->pwr_domain_state[%lu]=%x\n", |
| 214 | __func__, i, target_state->pwr_domain_state[i]); |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 215 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 216 | |
| 217 | /* Prevent interrupts from spuriously waking up this cpu */ |
| 218 | plat_versal_gic_cpuif_disable(); |
| 219 | |
| 220 | /* |
| 221 | * Send request to PMC to power down the appropriate APU CPU |
| 222 | * core. |
| 223 | * According to PSCI specification, CPU_off function does not |
| 224 | * have resume address and CPU core can only be woken up |
| 225 | * invoking CPU_on function, during which resume address will |
| 226 | * be set. |
| 227 | */ |
Maheedhar Bollapalli | 493c7a2 | 2024-10-08 05:42:28 +0000 | [diff] [blame] | 228 | ret = pm_feature_check((uint32_t)PM_SELF_SUSPEND, &version_type[0], SECURE_FLAG); |
Maheedhar Bollapalli | b3c92e6 | 2024-10-21 05:23:53 +0000 | [diff] [blame] | 229 | if (ret == (uint32_t)PM_RET_SUCCESS) { |
Maheedhar Bollapalli | 493c7a2 | 2024-10-08 05:42:28 +0000 | [diff] [blame] | 230 | fw_api_version = version_type[0] & 0xFFFFU; |
Jay Buddhabhatti | 31488a3 | 2023-09-11 23:50:06 -0700 | [diff] [blame] | 231 | if (fw_api_version >= 3U) { |
| 232 | (void)pm_self_suspend(proc->node_id, MAX_LATENCY, PM_STATE_CPU_OFF, 0, |
| 233 | SECURE_FLAG); |
| 234 | } else { |
| 235 | (void)pm_self_suspend(proc->node_id, MAX_LATENCY, PM_STATE_CPU_IDLE, 0, |
| 236 | SECURE_FLAG); |
| 237 | } |
| 238 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /** |
| 242 | * versal_validate_power_state() - This function ensures that the power state |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 243 | * parameter in request is valid. |
| 244 | * @power_state: Power state of core. |
| 245 | * @req_state: Requested state. |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 246 | * |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 247 | * Return: Returns status, either success or reason. |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 248 | * |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 249 | */ |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 250 | static int32_t versal_validate_power_state(uint32_t power_state, |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 251 | psci_power_state_t *req_state) |
| 252 | { |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 253 | int32_t ret = PSCI_E_SUCCESS; |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 254 | VERBOSE("%s: power_state: 0x%x\n", __func__, power_state); |
| 255 | |
Venkatesh Yadav Abbarapu | bde8759 | 2022-05-24 11:11:12 +0530 | [diff] [blame] | 256 | uint32_t pstate = psci_get_pstate_type(power_state); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 257 | |
Maheedhar Bollapalli | 15fa5b5 | 2024-09-27 05:52:21 +0000 | [diff] [blame] | 258 | assert(req_state != NULL); |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 259 | |
| 260 | /* Sanity check the requested state */ |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 261 | if (pstate == PSTATE_TYPE_STANDBY) { |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 262 | req_state->pwr_domain_state[MPIDR_AFFLVL0] = PLAT_MAX_RET_STATE; |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 263 | } else { |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 264 | req_state->pwr_domain_state[MPIDR_AFFLVL0] = PLAT_MAX_OFF_STATE; |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 265 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 266 | |
| 267 | /* We expect the 'state id' to be zero */ |
Abhyuday Godhasara | bacbdee | 2021-08-20 00:27:03 -0700 | [diff] [blame] | 268 | if (psci_get_pstate_id(power_state) != 0U) { |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 269 | ret = PSCI_E_INVALID_PARAMS; |
Abhyuday Godhasara | f55a5cd | 2021-08-09 08:15:13 -0700 | [diff] [blame] | 270 | } |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 271 | |
Maheedhar Bollapalli | 0449b67 | 2024-10-29 00:09:08 +0000 | [diff] [blame^] | 272 | return ret; |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | /** |
Prasad Kummari | 7d0623a | 2023-06-09 14:32:00 +0530 | [diff] [blame] | 276 | * versal_get_sys_suspend_power_state() - Get power state for system suspend. |
| 277 | * @req_state: Requested state. |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 278 | * |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 279 | */ |
| 280 | static void versal_get_sys_suspend_power_state(psci_power_state_t *req_state) |
| 281 | { |
| 282 | req_state->pwr_domain_state[PSCI_CPU_PWR_LVL] = PLAT_MAX_OFF_STATE; |
| 283 | req_state->pwr_domain_state[1] = PLAT_MAX_OFF_STATE; |
| 284 | } |
| 285 | |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 286 | static const struct plat_psci_ops versal_nopmc_psci_ops = { |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame] | 287 | .pwr_domain_on = versal_pwr_domain_on, |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 288 | .pwr_domain_off = versal_pwr_domain_off, |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 289 | .pwr_domain_on_finish = versal_pwr_domain_on_finish, |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 290 | .pwr_domain_suspend = versal_pwr_domain_suspend, |
| 291 | .pwr_domain_suspend_finish = versal_pwr_domain_suspend_finish, |
Saeed Nowshadi | c5a1bda | 2019-12-08 23:35:35 -0800 | [diff] [blame] | 292 | .system_off = versal_system_off, |
| 293 | .system_reset = versal_system_reset, |
Tejas Patel | 54d1319 | 2019-02-27 18:44:55 +0530 | [diff] [blame] | 294 | .validate_power_state = versal_validate_power_state, |
| 295 | .get_sys_suspend_power_state = versal_get_sys_suspend_power_state, |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 296 | }; |
| 297 | |
| 298 | /******************************************************************************* |
| 299 | * Export the platform specific power ops. |
| 300 | ******************************************************************************/ |
Venkatesh Yadav Abbarapu | 2cefbcd | 2022-07-31 14:05:40 +0530 | [diff] [blame] | 301 | int32_t plat_setup_psci_ops(uintptr_t sec_entrypoint, |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 302 | const struct plat_psci_ops **psci_ops) |
| 303 | { |
| 304 | versal_sec_entry = sec_entrypoint; |
| 305 | |
| 306 | *psci_ops = &versal_nopmc_psci_ops; |
| 307 | |
| 308 | return 0; |
| 309 | } |