1 /** @file
2 *
3 * Copyright (c) 2012, ARM Limited. All rights reserved.
4 *
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
9 *
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 *
13 **/
14
15 #include <Library/IoLib.h>
16 #include <Library/ArmPlatformLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
19
20 #include <Ppi/ArmMpCoreInfo.h>
21
22 #include <ArmPlatform.h>
23
24 ARM_CORE_INFO mVersatileExpressCTA15A7InfoTable[] = {
25 {
26 // Cluster 0, Core 0
27 0x0, 0x0,
28
29 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
30 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR0,
31 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR0,
32 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR0,
33 (UINT64)0
34 },
35 {
36 // Cluster 0, Core 1
37 0x0, 0x1,
38
39 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
40 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR1,
41 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR1,
42 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR1,
43 (UINT64)0
44 },
45 #ifndef ARM_BIGLITTLE_TC2
46 {
47 // Cluster 0, Core 2
48 0x0, 0x2,
49
50 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
51 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR2,
52 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR2,
53 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR2,
54 (UINT64)0
55 },
56 {
57 // Cluster 0, Core 3
58 0x0, 0x3,
59
60 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
61 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR3,
62 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR3,
63 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A15_BX_ADDR3,
64 (UINT64)0
65 },
66 #endif
67 {
68 // Cluster 1, Core 0
69 0x1, 0x0,
70
71 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
72 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR0,
73 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR0,
74 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR0,
75 (UINT64)0
76 },
77 {
78 // Cluster 1, Core 1
79 0x1, 0x1,
80
81 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
82 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR1,
83 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR1,
84 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR1,
85 (UINT64)0
86 },
87 {
88 // Cluster 1, Core 2
89 0x1, 0x2,
90
91 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
92 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR2,
93 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR2,
94 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR2,
95 (UINT64)0
96 }
97 #ifndef ARM_BIGLITTLE_TC2
98 ,{
99 // Cluster 1, Core 3
100 0x1, 0x3,
101
102 // MP Core MailBox Set/Get/Clear Addresses and Clear Value
103 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR3,
104 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR3,
105 (EFI_PHYSICAL_ADDRESS)ARM_CTA15A7_SPC_A7_BX_ADDR3,
106 (UINT64)0
107 }
108 #endif
109 };
110
111 /**
112 Return the current Boot Mode
113
114 This function returns the boot reason on the platform
115
116 @return Return the current Boot Mode of the platform
117
118 **/
119 EFI_BOOT_MODE
ArmPlatformGetBootMode(VOID)120 ArmPlatformGetBootMode (
121 VOID
122 )
123 {
124 if (MmioRead32(ARM_CTA15A7_SCC_SYSINFO) & ARM_CTA15A7_SCC_SYSINFO_UEFI_RESTORE_DEFAULT_NORFLASH) {
125 return BOOT_WITH_DEFAULT_SETTINGS;
126 } else {
127 return BOOT_WITH_FULL_CONFIGURATION;
128 }
129 }
130
131 /**
132 Initialize controllers that must setup in the normal world
133
134 This function is called by the ArmPlatformPkg/Pei or ArmPlatformPkg/Pei/PlatformPeim
135 in the PEI phase.
136
137 **/
138 RETURN_STATUS
ArmPlatformInitialize(IN UINTN MpId)139 ArmPlatformInitialize (
140 IN UINTN MpId
141 )
142 {
143 if (!ArmPlatformIsPrimaryCore (MpId)) {
144 return RETURN_SUCCESS;
145 }
146
147 // Nothing to do here
148
149 return RETURN_SUCCESS;
150 }
151
152 /**
153 Initialize the system (or sometimes called permanent) memory
154
155 This memory is generally represented by the DRAM.
156
157 **/
158 VOID
ArmPlatformInitializeSystemMemory(VOID)159 ArmPlatformInitializeSystemMemory (
160 VOID
161 )
162 {
163 }
164
165 EFI_STATUS
PrePeiCoreGetMpCoreInfo(OUT UINTN * CoreCount,OUT ARM_CORE_INFO ** ArmCoreTable)166 PrePeiCoreGetMpCoreInfo (
167 OUT UINTN *CoreCount,
168 OUT ARM_CORE_INFO **ArmCoreTable
169 )
170 {
171 // Only support one cluster
172 *CoreCount = sizeof(mVersatileExpressCTA15A7InfoTable) / sizeof(ARM_CORE_INFO);
173 *ArmCoreTable = mVersatileExpressCTA15A7InfoTable;
174 return EFI_SUCCESS;
175 }
176
177 ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = { PrePeiCoreGetMpCoreInfo };
178
179 EFI_PEI_PPI_DESCRIPTOR gPlatformPpiTable[] = {
180 {
181 EFI_PEI_PPI_DESCRIPTOR_PPI,
182 &gArmMpCoreInfoPpiGuid,
183 &mMpCoreInfoPpi
184 }
185 };
186
187 VOID
ArmPlatformGetPlatformPpiList(OUT UINTN * PpiListSize,OUT EFI_PEI_PPI_DESCRIPTOR ** PpiList)188 ArmPlatformGetPlatformPpiList (
189 OUT UINTN *PpiListSize,
190 OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
191 )
192 {
193 *PpiListSize = sizeof(gPlatformPpiTable);
194 *PpiList = gPlatformPpiTable;
195 }
196