]> git.proxmox.com Git - mirror_edk2.git/blob - BeagleBoardPkg/Library/BeagleBoardLib/BeagleBoard.c
8acb6d9710dcb1ae8b9cc1c406ffd597ed535be0
[mirror_edk2.git] / BeagleBoardPkg / Library / BeagleBoardLib / BeagleBoard.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 <Omap3530/Omap3530.h>
21 #include <BeagleBoard.h>
22
23 VOID
24 PadConfiguration (
25 BEAGLEBOARD_REVISION Revision
26 );
27
28 VOID
29 ClockInit (
30 VOID
31 );
32
33 /**
34 Detect board revision
35
36 @return Board revision
37 **/
38 BEAGLEBOARD_REVISION
39 BeagleBoardGetRevision (
40 VOID
41 )
42 {
43 UINT32 OldPinDir;
44 UINT32 Revision;
45
46 // Read GPIO 171, 172, 173
47 OldPinDir = MmioRead32 (GPIO6_BASE + GPIO_OE);
48 MmioWrite32(GPIO6_BASE + GPIO_OE, (OldPinDir | BIT11 | BIT12 | BIT13));
49 Revision = MmioRead32 (GPIO6_BASE + GPIO_DATAIN);
50
51 // Restore I/O settings
52 MmioWrite32 (GPIO6_BASE + GPIO_OE, OldPinDir);
53
54 return (BEAGLEBOARD_REVISION)((Revision >> 11) & 0x7);
55 }
56
57 /**
58 Return if Trustzone is supported by your platform
59
60 A non-zero value must be returned if you want to support a Secure World on your platform.
61 ArmPlatformTrustzoneInit() will later set up the secure regions.
62 This function can return 0 even if Trustzone is supported by your processor. In this case,
63 the platform will continue to run in Secure World.
64
65 @return A non-zero value if Trustzone supported.
66
67 **/
68 UINTN
69 ArmPlatformTrustzoneSupported (
70 VOID
71 )
72 {
73 // The BeagleBoard starts in Normal World (Non Secure World)
74 return FALSE;
75 }
76
77 /**
78 Initialize the Secure peripherals and memory regions
79
80 If Trustzone is supported by your platform then this function makes the required initialization
81 of the secure peripherals and memory regions.
82
83 **/
84 VOID
85 ArmPlatformTrustzoneInit (
86 VOID
87 )
88 {
89 ASSERT(FALSE);
90 }
91
92 /**
93 Remap the memory at 0x0
94
95 Some platform requires or gives the ability to remap the memory at the address 0x0.
96 This function can do nothing if this feature is not relevant to your platform.
97
98 **/
99 VOID
100 ArmPlatformBootRemapping (
101 VOID
102 )
103 {
104 // Do nothing for the BeagleBoard
105 }
106
107 /**
108 Return the current Boot Mode
109
110 This function returns the boot reason on the platform
111
112 **/
113 EFI_BOOT_MODE
114 ArmPlatformGetBootMode (
115 VOID
116 )
117 {
118 return BOOT_WITH_FULL_CONFIGURATION;
119 }
120
121 /**
122 Initialize controllers that must setup at the early stage
123
124 Some peripherals must be initialized in Secure World.
125 For example, some L2x0 requires to be initialized in Secure World
126
127 **/
128 VOID
129 ArmPlatformNormalInitialize (
130 VOID
131 )
132 {
133 BEAGLEBOARD_REVISION Revision;
134
135 Revision = BeagleBoardGetRevision();
136
137 // Set up Pin muxing.
138 PadConfiguration (Revision);
139
140 // Set up system clocking
141 ClockInit ();
142
143 // Turn off the functional clock for Timer 3
144 MmioAnd32 (CM_FCLKEN_PER, 0xFFFFFFFF ^ CM_ICLKEN_PER_EN_GPT3_ENABLE );
145 ArmDataSyncronizationBarrier ();
146
147 // Clear IRQs
148 MmioWrite32 (INTCPS_CONTROL, INTCPS_CONTROL_NEWIRQAGR);
149 ArmDataSyncronizationBarrier ();
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
159 ArmPlatformInitializeSystemMemory (
160 VOID
161 )
162 {
163 // We do not need to initialize the System Memory on RTSM
164 }