blob: d0a4c0b2f33f5873aacdeffaf008b995f725b0e0 [file] [log] [blame]
Dan Handley9df48042015-03-19 18:58:55 +00001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <arch.h>
32#include <arm_def.h>
33#include <bl_common.h>
34#include <cci.h>
35#include <console.h>
36#include <platform_def.h>
37#include <plat_arm.h>
Juan Castillob6132f12015-10-06 14:01:35 +010038#include <sp805.h>
Sandrine Bailleuxd7c47502015-10-02 09:32:35 +010039#include "../../../bl1/bl1_private.h"
Dan Handley9df48042015-03-19 18:58:55 +000040
41
42#if USE_COHERENT_MEM
43/*
44 * The next 2 constants identify the extents of the coherent memory region.
45 * These addresses are used by the MMU setup code and therefore they must be
46 * page-aligned. It is the responsibility of the linker script to ensure that
47 * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to
48 * page-aligned addresses.
49 */
50#define BL1_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
51#define BL1_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
52#endif
53
54
55/* Weak definitions may be overridden in specific ARM standard platform */
56#pragma weak bl1_early_platform_setup
57#pragma weak bl1_plat_arch_setup
58#pragma weak bl1_platform_setup
59#pragma weak bl1_plat_sec_mem_layout
Dan Handley9df48042015-03-19 18:58:55 +000060
61
62/* Data structure which holds the extents of the trusted SRAM for BL1*/
63static meminfo_t bl1_tzram_layout;
64
65meminfo_t *bl1_plat_sec_mem_layout(void)
66{
67 return &bl1_tzram_layout;
68}
69
70/*******************************************************************************
71 * BL1 specific platform actions shared between ARM standard platforms.
72 ******************************************************************************/
73void arm_bl1_early_platform_setup(void)
74{
75 const size_t bl1_size = BL1_RAM_LIMIT - BL1_RAM_BASE;
76
Juan Castillob6132f12015-10-06 14:01:35 +010077#if !ARM_DISABLE_TRUSTED_WDOG
78 /* Enable watchdog */
79 sp805_start(ARM_SP805_TWDG_BASE, ARM_TWDG_LOAD_VAL);
80#endif
81
Dan Handley9df48042015-03-19 18:58:55 +000082 /* Initialize the console to provide early debug support */
83 console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ,
84 ARM_CONSOLE_BAUDRATE);
85
86 /* Allow BL1 to see the whole Trusted RAM */
87 bl1_tzram_layout.total_base = ARM_BL_RAM_BASE;
88 bl1_tzram_layout.total_size = ARM_BL_RAM_SIZE;
89
90 /* Calculate how much RAM BL1 is using and how much remains free */
91 bl1_tzram_layout.free_base = ARM_BL_RAM_BASE;
92 bl1_tzram_layout.free_size = ARM_BL_RAM_SIZE;
93 reserve_mem(&bl1_tzram_layout.free_base,
94 &bl1_tzram_layout.free_size,
95 BL1_RAM_BASE,
96 bl1_size);
97}
98
99void bl1_early_platform_setup(void)
100{
101 arm_bl1_early_platform_setup();
102
103 /*
104 * Initialize CCI for this cluster during cold boot.
105 * No need for locks as no other CPU is active.
106 */
107 arm_cci_init();
108 /*
109 * Enable CCI coherency for the primary CPU's cluster.
110 */
111 cci_enable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
112}
113
114/******************************************************************************
115 * Perform the very early platform specific architecture setup shared between
116 * ARM standard platforms. This only does basic initialization. Later
117 * architectural setup (bl1_arch_setup()) does not do anything platform
118 * specific.
119 *****************************************************************************/
120void arm_bl1_plat_arch_setup(void)
121{
122 arm_configure_mmu_el3(bl1_tzram_layout.total_base,
123 bl1_tzram_layout.total_size,
124 BL1_RO_BASE,
125 BL1_RO_LIMIT
126#if USE_COHERENT_MEM
127 , BL1_COHERENT_RAM_BASE,
128 BL1_COHERENT_RAM_LIMIT
129#endif
130 );
131}
132
133void bl1_plat_arch_setup(void)
134{
135 arm_bl1_plat_arch_setup();
136}
137
138/*
139 * Perform the platform specific architecture setup shared between
140 * ARM standard platforms.
141 */
142void arm_bl1_platform_setup(void)
143{
144 /* Initialise the IO layer and register platform IO devices */
145 plat_arm_io_setup();
146}
147
148void bl1_platform_setup(void)
149{
150 arm_bl1_platform_setup();
151}
152
Sandrine Bailleux03897bb2015-11-26 16:31:34 +0000153void bl1_plat_prepare_exit(entry_point_info_t *ep_info)
154{
Juan Castillob6132f12015-10-06 14:01:35 +0100155#if !ARM_DISABLE_TRUSTED_WDOG
156 /* Disable watchdog before leaving BL1 */
157 sp805_stop(ARM_SP805_TWDG_BASE);
158#endif
159
Sandrine Bailleux03897bb2015-11-26 16:31:34 +0000160#ifdef EL3_PAYLOAD_BASE
161 /*
162 * Program the EL3 payload's entry point address into the CPUs mailbox
163 * in order to release secondary CPUs from their holding pen and make
164 * them jump there.
165 */
166 arm_program_trusted_mailbox(ep_info->pc);
167 dsbsy();
168 sev();
169#endif
170}