xref: /rk3399_ARM-atf/plat/arm/common/arm_bl2u_setup.c (revision 09d40e0e08283a249e7dce0e106c07c5141f9b7e)
1dcda29f6SYatharth Kochar /*
21af540efSRoberto Vargas  * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3dcda29f6SYatharth Kochar  *
482cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
5dcda29f6SYatharth Kochar  */
6dcda29f6SYatharth Kochar 
7d323af9eSDaniel Boulby #include <assert.h>
8dcda29f6SYatharth Kochar #include <string.h>
9dcda29f6SYatharth Kochar 
10*09d40e0eSAntonio Nino Diaz #include <platform_def.h>
11*09d40e0eSAntonio Nino Diaz 
12*09d40e0eSAntonio Nino Diaz #include <arch_helpers.h>
13*09d40e0eSAntonio Nino Diaz #include <common/bl_common.h>
14*09d40e0eSAntonio Nino Diaz #include <drivers/generic_delay_timer.h>
15*09d40e0eSAntonio Nino Diaz #include <plat/common/platform.h>
16*09d40e0eSAntonio Nino Diaz 
17*09d40e0eSAntonio Nino Diaz #include <arm_def.h>
18*09d40e0eSAntonio Nino Diaz #include <plat_arm.h>
19*09d40e0eSAntonio Nino Diaz 
20dcda29f6SYatharth Kochar /* Weak definitions may be overridden in specific ARM standard platform */
21dcda29f6SYatharth Kochar #pragma weak bl2u_platform_setup
22dcda29f6SYatharth Kochar #pragma weak bl2u_early_platform_setup
23dcda29f6SYatharth Kochar #pragma weak bl2u_plat_arch_setup
24dcda29f6SYatharth Kochar 
25d323af9eSDaniel Boulby #define MAP_BL2U_TOTAL		MAP_REGION_FLAT(			\
26d323af9eSDaniel Boulby 					BL2U_BASE,			\
27d323af9eSDaniel Boulby 					BL2U_LIMIT - BL2U_BASE,		\
28d323af9eSDaniel Boulby 					MT_MEMORY | MT_RW | MT_SECURE)
29d323af9eSDaniel Boulby 
30dcda29f6SYatharth Kochar /*
31dcda29f6SYatharth Kochar  * Perform ARM standard platform setup for BL2U
32dcda29f6SYatharth Kochar  */
33dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void)
34dcda29f6SYatharth Kochar {
35dcda29f6SYatharth Kochar 	/* Initialize the secure environment */
36dcda29f6SYatharth Kochar 	plat_arm_security_setup();
37dcda29f6SYatharth Kochar }
38dcda29f6SYatharth Kochar 
39dcda29f6SYatharth Kochar void bl2u_platform_setup(void)
40dcda29f6SYatharth Kochar {
41dcda29f6SYatharth Kochar 	arm_bl2u_platform_setup();
42dcda29f6SYatharth Kochar }
43dcda29f6SYatharth Kochar 
446c77e749SSandrine Bailleux void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
45dcda29f6SYatharth Kochar {
46dcda29f6SYatharth Kochar 	/* Initialize the console to provide early debug support */
4788a0523eSAntonio Nino Diaz 	arm_console_boot_init();
4888a0523eSAntonio Nino Diaz 
4974847ab2SSoby Mathew 	generic_delay_timer_init();
50dcda29f6SYatharth Kochar }
51dcda29f6SYatharth Kochar 
52dcda29f6SYatharth Kochar /*******************************************************************************
53dcda29f6SYatharth Kochar  * BL1 can pass platform dependent information to BL2U in x1.
54dcda29f6SYatharth Kochar  * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
55dcda29f6SYatharth Kochar  * In case of ARM FVP platforms x1 is not used.
56dcda29f6SYatharth Kochar  * In both cases, x0 contains the extents of the memory available to BL2U
57dcda29f6SYatharth Kochar  ******************************************************************************/
586c77e749SSandrine Bailleux void bl2u_early_platform_setup(struct meminfo *mem_layout, void *plat_info)
59dcda29f6SYatharth Kochar {
60dcda29f6SYatharth Kochar 	arm_bl2u_early_platform_setup(mem_layout, plat_info);
61dcda29f6SYatharth Kochar }
62dcda29f6SYatharth Kochar 
63dcda29f6SYatharth Kochar /*******************************************************************************
64dcda29f6SYatharth Kochar  * Perform the very early platform specific architectural setup here. At the
65dcda29f6SYatharth Kochar  * moment this is only initializes the mmu in a quick and dirty way.
66dcda29f6SYatharth Kochar  * The memory that is used by BL2U is only mapped.
67dcda29f6SYatharth Kochar  ******************************************************************************/
68dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void)
69dcda29f6SYatharth Kochar {
70d323af9eSDaniel Boulby 
71dcda29f6SYatharth Kochar #if USE_COHERENT_MEM
72d323af9eSDaniel Boulby 	/* Ensure ARM platforms dont use coherent memory in BL2U */
73d323af9eSDaniel Boulby 	assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
74dcda29f6SYatharth Kochar #endif
75d323af9eSDaniel Boulby 
76d323af9eSDaniel Boulby 	const mmap_region_t bl_regions[] = {
77d323af9eSDaniel Boulby 		MAP_BL2U_TOTAL,
782ecaafd2SDaniel Boulby 		ARM_MAP_BL_RO,
791eb735d7SRoberto Vargas #if USE_ROMLIB
801eb735d7SRoberto Vargas 		ARM_MAP_ROMLIB_CODE,
811eb735d7SRoberto Vargas 		ARM_MAP_ROMLIB_DATA,
821eb735d7SRoberto Vargas #endif
83d323af9eSDaniel Boulby 		{0}
84d323af9eSDaniel Boulby 	};
85d323af9eSDaniel Boulby 
860916c38dSRoberto Vargas 	setup_page_tables(bl_regions, plat_arm_get_mmap());
87d323af9eSDaniel Boulby 
881bd61d0aSYatharth Kochar #ifdef AARCH32
891e54cbb8SAntonio Nino Diaz 	enable_mmu_svc_mon(0);
901bd61d0aSYatharth Kochar #else
91b5fa6563SSandrine Bailleux 	enable_mmu_el1(0);
921bd61d0aSYatharth Kochar #endif
931eb735d7SRoberto Vargas 	arm_setup_romlib();
94dcda29f6SYatharth Kochar }
95dcda29f6SYatharth Kochar 
96dcda29f6SYatharth Kochar void bl2u_plat_arch_setup(void)
97dcda29f6SYatharth Kochar {
98dcda29f6SYatharth Kochar 	arm_bl2u_plat_arch_setup();
99dcda29f6SYatharth Kochar }
100