1 /*
2  * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0.
5  *
6  * @Date: 2021-04-21 10:43:52
7  * @LastEditTime: 2021-04-21 10:43:53
8  * @Description:  Description of file
9  * @Modify History:
10  * * * Ver   Who        Date         Changes
11  * * ----- ------     --------    --------------------------------------
12  */
13 
14 #include "ft_psci.h"
15 #include "ft_smc.h"
16 #include "ft_cpu.h"
17 #include "ft_printf.h"
18 
19 #define PSCI_CPUON_NUM 0x84000003
20 #define PSCI_RESET_NUM 0x84000009
21 
22 /**
23  * @name: FPsci_CpuOn
24  * @msg:  Power up a core
25  * @in param CpuList:  Bits[24:31]: Must be zero.
26  *                     Bits[16:23] Aff2: Match Aff2 of target core MPIDR
27  *                     Bits[8:15] Aff1: Match Aff1 of target core MPIDR
28  *                     Bits[0:7] Aff0: Match Aff0 of target core MPIDR
29  * @in param BootAddr:  a 32-bit entry point physical address (or IPA).
30  * @return {None}
31  */
FPsci_CpuOn(s32 CpuIdMask,u32 BootAddr)32 void FPsci_CpuOn(s32 CpuIdMask, u32 BootAddr)
33 {
34 
35     FSmc_Data_t Input = {0};
36     FSmc_Data_t Output = {0};
37     Input.FunctionIdentifier = PSCI_CPUON_NUM;
38 
39     if ((1 << 0) == CpuIdMask)
40     {
41         Input.a1 = SoftAffiTable[0];
42     }
43     else if ((1 << 1) == CpuIdMask)
44     {
45         Input.a1 = SoftAffiTable[1];
46     }
47     else if ((1 << 2) == CpuIdMask)
48     {
49         Input.a1 = SoftAffiTable[2];
50     }
51     else if ((1 << 3) == CpuIdMask)
52     {
53         Input.a1 = SoftAffiTable[3];
54     }
55     else
56     {
57         return;
58     }
59 
60     /*input.a2 = (u32)(BootAddr >> 32);*/
61     Input.a2 = (u32)(BootAddr & 0xFFFFFFFF);
62     FSmc_Call(&Input, &Output);
63     __asm__ volatile("NOP");
64 }
65 
FPsci_Reset(void)66 void FPsci_Reset(void)
67 {
68 
69     FSmc_Data_t Input = {0};
70     FSmc_Data_t Output = {0};
71 
72     Input.FunctionIdentifier = PSCI_RESET_NUM;
73     FSmc_Call(&Input, &Output);
74 
75     __asm__ volatile("NOP");
76     while (1)
77         ;
78 }
79