]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEb.c
5709ca6c01c0a6d901e2eed035706b702b72c442
[mirror_edk2.git] / ArmPlatformPkg / ArmRealViewEbPkg / Library / ArmRealViewEbLibRTSM / ArmRealViewEb.c
1 /** @file
2 *
3 * Copyright (c) 2011, 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 <Drivers/PL341Dmc.h>
21 #include <Drivers/SP804Timer.h>
22
23 #include <ArmPlatform.h>
24
25 /**
26 Return if Trustzone is supported by your platform
27
28 A non-zero value must be returned if you want to support a Secure World on your platform.
29 ArmPlatformTrustzoneInit() will later set up the secure regions.
30 This function can return 0 even if Trustzone is supported by your processor. In this case,
31 the platform will continue to run in Secure World.
32
33 @return A non-zero value if Trustzone supported.
34
35 **/
36 UINTN
37 ArmPlatformTrustzoneSupported (
38 VOID
39 )
40 {
41 // There is no Trustzone controllers (TZPC & TZASC) and no Secure Memory on RTSM
42 return FALSE;
43 }
44
45 /**
46 Initialize the Secure peripherals and memory regions
47
48 If Trustzone is supported by your platform then this function makes the required initialization
49 of the secure peripherals and memory regions.
50
51 **/
52 VOID
53 ArmPlatformTrustzoneInit (
54 VOID
55 )
56 {
57 ASSERT(FALSE);
58 }
59
60 /**
61 Remap the memory at 0x0
62
63 Some platform requires or gives the ability to remap the memory at the address 0x0.
64 This function can do nothing if this feature is not relevant to your platform.
65
66 **/
67 VOID
68 ArmPlatformBootRemapping (
69 VOID
70 )
71 {
72 // Disable memory remapping and return to normal mapping
73 MmioOr32 (ARM_EB_SYSCTRL, BIT8); //EB_SP810_CTRL_BASE
74 }
75
76 /**
77 Return the current Boot Mode
78
79 This function returns the boot reason on the platform
80
81 **/
82 EFI_BOOT_MODE
83 ArmPlatformGetBootMode (
84 VOID
85 )
86 {
87 return BOOT_WITH_FULL_CONFIGURATION;
88 }
89
90 /**
91 Initialize controllers that must setup at the early stage
92
93 Some peripherals must be initialized in Secure World.
94 For example, some L2x0 requires to be initialized in Secure World
95
96 **/
97 VOID
98 ArmPlatformSecInitialize (
99 VOID
100 ) {
101 // Do nothing yet
102 }
103
104 /**
105 Initialize controllers that must setup in the normal world
106
107 This function is called by the ArmPlatformPkg/PrePi or ArmPlatformPkg/PlatformPei
108 in the PEI phase.
109
110 **/
111 VOID
112 ArmPlatformNormalInitialize (
113 VOID
114 )
115 {
116 // Configure periodic timer (TIMER0) for 1MHz operation
117 MmioOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER0_TIMCLK);
118 // Configure 1MHz clock
119 MmioOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, SP810_SYS_CTRL_TIMER1_TIMCLK);
120 // configure SP810 to use 1MHz clock and disable
121 MmioAndThenOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER2_EN, SP810_SYS_CTRL_TIMER2_TIMCLK);
122 // Configure SP810 to use 1MHz clock and disable
123 MmioAndThenOr32 (SP810_CTRL_BASE + SP810_SYS_CTRL_REG, ~SP810_SYS_CTRL_TIMER3_EN, SP810_SYS_CTRL_TIMER3_TIMCLK);
124 }
125
126 /**
127 Initialize the system (or sometimes called permanent) memory
128
129 This memory is generally represented by the DRAM.
130
131 **/
132 VOID
133 ArmPlatformInitializeSystemMemory (
134 VOID
135 )
136 {
137 // We do not need to initialize the System Memory on RTSM
138 }