blob: 8e69243400ce0a4256847253eb95fbdb55cde474 [file] [log] [blame]
Chia-Wei Wanga7556d82022-11-02 17:50:21 +08001/*
2 * Copyright (c) 2023, Aspeed Technology Inc.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <common/debug.h>
9#include <drivers/arm/gicv3.h>
10#include <drivers/console.h>
11#include <lib/mmio.h>
12#include <lib/psci/psci.h>
13#include <plat/common/platform.h>
14
15static uintptr_t sec_ep;
16
17static int plat_pwr_domain_on(u_register_t mpidr)
18{
19 unsigned int cpu = plat_core_pos_by_mpidr(mpidr);
20 uintptr_t ep_reg;
21
22 switch (cpu) {
23 case 1U:
24 ep_reg = SCU_CPU_SMP_EP1;
25 break;
26 case 2U:
27 ep_reg = SCU_CPU_SMP_EP2;
28 break;
29 case 3U:
30 ep_reg = SCU_CPU_SMP_EP3;
31 break;
32 default:
33 return PSCI_E_INVALID_PARAMS;
34 }
35
36 mmio_write_64(ep_reg, sec_ep);
37
38 dsbsy();
39
40 sev();
41
42 return PSCI_E_SUCCESS;
43}
44
45static void plat_pwr_domain_on_finish(const psci_power_state_t *target_state)
46{
47 gicv3_rdistif_init(plat_my_core_pos());
48 gicv3_cpuif_enable(plat_my_core_pos());
49}
50
51static const plat_psci_ops_t plat_psci_ops = {
52 .pwr_domain_on = plat_pwr_domain_on,
53 .pwr_domain_on_finish = plat_pwr_domain_on_finish,
54};
55
56int plat_setup_psci_ops(uintptr_t sec_entrypoint,
57 const plat_psci_ops_t **psci_ops)
58{
59 sec_ep = sec_entrypoint;
60 *psci_ops = &plat_psci_ops;
61
62 return 0;
63}