Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 1 | /* |
Tejas Patel | 6940996 | 2018-12-14 00:55:29 -0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Tejas Patel | 6940996 | 2018-12-14 00:55:29 -0800 | [diff] [blame] | 7 | #include <plat_private.h> |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 8 | #include <pm_common.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <common/debug.h> |
| 10 | #include <lib/mmio.h> |
| 11 | #include <lib/psci/psci.h> |
| 12 | #include <plat/common/platform.h> |
| 13 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 14 | #include "pm_api_sys.h" |
| 15 | #include "pm_client.h" |
| 16 | |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 17 | static uintptr_t versal_sec_entry; |
| 18 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 19 | static int versal_pwr_domain_on(u_register_t mpidr) |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 20 | { |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 21 | unsigned int cpu_id = plat_core_pos_by_mpidr(mpidr); |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 22 | const struct pm_proc *proc; |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 23 | |
| 24 | VERBOSE("%s: mpidr: 0x%lx\n", __func__, mpidr); |
| 25 | |
| 26 | if (cpu_id == -1) |
| 27 | return PSCI_E_INTERN_FAIL; |
| 28 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 29 | proc = pm_get_proc(cpu_id); |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 30 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 31 | /* Send request to PMC to wake up selected ACPU core */ |
| 32 | pm_req_wakeup(proc->node_id, (versal_sec_entry & 0xFFFFFFFF) | 0x1, |
| 33 | versal_sec_entry >> 32, 0); |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 34 | |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 35 | /* Clear power down request */ |
| 36 | pm_client_wakeup(proc); |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 37 | |
| 38 | return PSCI_E_SUCCESS; |
| 39 | } |
| 40 | |
| 41 | void versal_pwr_domain_on_finish(const psci_power_state_t *target_state) |
| 42 | { |
| 43 | /* Enable the gic cpu interface */ |
| 44 | plat_versal_gic_pcpu_init(); |
| 45 | |
| 46 | /* Program the gic per-cpu distributor or re-distributor interface */ |
| 47 | plat_versal_gic_cpuif_enable(); |
| 48 | } |
| 49 | |
| 50 | static const struct plat_psci_ops versal_nopmc_psci_ops = { |
Tejas Patel | 6171711 | 2019-02-27 18:44:57 +0530 | [diff] [blame^] | 51 | .pwr_domain_on = versal_pwr_domain_on, |
Siva Durga Prasad Paladugu | fe4af66 | 2018-09-25 18:44:58 +0530 | [diff] [blame] | 52 | .pwr_domain_on_finish = versal_pwr_domain_on_finish, |
| 53 | }; |
| 54 | |
| 55 | /******************************************************************************* |
| 56 | * Export the platform specific power ops. |
| 57 | ******************************************************************************/ |
| 58 | int plat_setup_psci_ops(uintptr_t sec_entrypoint, |
| 59 | const struct plat_psci_ops **psci_ops) |
| 60 | { |
| 61 | versal_sec_entry = sec_entrypoint; |
| 62 | |
| 63 | *psci_ops = &versal_nopmc_psci_ops; |
| 64 | |
| 65 | return 0; |
| 66 | } |