1 /*
2  * Copyright (c) 2006-2019, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2023-02-21     GuEe-GUI     replace with drivers/psci
9  */
10 #include <rthw.h>
11 #include <rtthread.h>
12 
13 #define DBG_TAG "cpu.aa64"
14 #define DBG_LVL DBG_INFO
15 #include <rtdbg.h>
16 
17 #include <cpu.h>
18 #include <cpuport.h>
19 #include <psci.h>
20 
psci_cpu_boot(rt_uint32_t cpuid,rt_uint64_t entry)21 static int psci_cpu_boot(rt_uint32_t cpuid, rt_uint64_t entry)
22 {
23     return rt_psci_cpu_on(cpuid, entry);
24 }
25 
psci_cpu_shutdown(void)26 static void psci_cpu_shutdown(void)
27 {
28     rt_uint32_t state, state_id = PSCI_POWER_STATE_ID(0, 0, 0, PSCI_POWER_STATE_ID_POWERDOWN);
29 
30     state = PSCI_POWER_STATE(PSCI_POWER_STATE_LEVEL_CORES, PSCI_POWER_STATE_TYPE_STANDBY, state_id);
31 
32     rt_psci_cpu_off(state);
33 }
34 
35 struct cpu_ops_t cpu_psci_ops =
36 {
37     .method = "psci",
38     .cpu_boot = psci_cpu_boot,
39     .cpu_shutdown = psci_cpu_shutdown,
40 };
41