blob: 5e3b6f7fca97ae33c1cd84f5f0488d11e1442e13 [file] [log] [blame]
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +05301/*
Tejas Patel69409962018-12-14 00:55:29 -08002 * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +05303 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Tejas Patel69409962018-12-14 00:55:29 -08007#include <plat_private.h>
Tejas Patel61717112019-02-27 18:44:57 +05308#include <pm_common.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/debug.h>
10#include <lib/mmio.h>
11#include <lib/psci/psci.h>
12#include <plat/common/platform.h>
13
Tejas Patel61717112019-02-27 18:44:57 +053014#include "pm_api_sys.h"
15#include "pm_client.h"
16
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053017static uintptr_t versal_sec_entry;
18
Tejas Patel61717112019-02-27 18:44:57 +053019static int versal_pwr_domain_on(u_register_t mpidr)
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053020{
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053021 unsigned int cpu_id = plat_core_pos_by_mpidr(mpidr);
Tejas Patel61717112019-02-27 18:44:57 +053022 const struct pm_proc *proc;
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053023
24 VERBOSE("%s: mpidr: 0x%lx\n", __func__, mpidr);
25
26 if (cpu_id == -1)
27 return PSCI_E_INTERN_FAIL;
28
Tejas Patel61717112019-02-27 18:44:57 +053029 proc = pm_get_proc(cpu_id);
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053030
Tejas Patel61717112019-02-27 18:44:57 +053031 /* 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 Paladugufe4af662018-09-25 18:44:58 +053034
Tejas Patel61717112019-02-27 18:44:57 +053035 /* Clear power down request */
36 pm_client_wakeup(proc);
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053037
38 return PSCI_E_SUCCESS;
39}
40
41void 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
50static const struct plat_psci_ops versal_nopmc_psci_ops = {
Tejas Patel61717112019-02-27 18:44:57 +053051 .pwr_domain_on = versal_pwr_domain_on,
Siva Durga Prasad Paladugufe4af662018-09-25 18:44:58 +053052 .pwr_domain_on_finish = versal_pwr_domain_on_finish,
53};
54
55/*******************************************************************************
56 * Export the platform specific power ops.
57 ******************************************************************************/
58int 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}