xref: /rk3399_ARM-atf/plat/arm/common/arm_bl2u_setup.c (revision 82cb2c1ad9897473743f08437d0a3995bed561b9)
1dcda29f6SYatharth Kochar /*
2b5fa6563SSandrine Bailleux  * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3dcda29f6SYatharth Kochar  *
4*82cb2c1aSdp-arm  * SPDX-License-Identifier: BSD-3-Clause
5dcda29f6SYatharth Kochar  */
6dcda29f6SYatharth Kochar 
7dcda29f6SYatharth Kochar #include <arch_helpers.h>
8dcda29f6SYatharth Kochar #include <arm_def.h>
9dcda29f6SYatharth Kochar #include <bl_common.h>
10dcda29f6SYatharth Kochar #include <console.h>
11dcda29f6SYatharth Kochar #include <platform_def.h>
12dcda29f6SYatharth Kochar #include <plat_arm.h>
13dcda29f6SYatharth Kochar #include <string.h>
14dcda29f6SYatharth Kochar 
15dcda29f6SYatharth Kochar /* Weak definitions may be overridden in specific ARM standard platform */
16dcda29f6SYatharth Kochar #pragma weak bl2u_platform_setup
17dcda29f6SYatharth Kochar #pragma weak bl2u_early_platform_setup
18dcda29f6SYatharth Kochar #pragma weak bl2u_plat_arch_setup
19dcda29f6SYatharth Kochar 
20dcda29f6SYatharth Kochar /*
21dcda29f6SYatharth Kochar  * Perform ARM standard platform setup for BL2U
22dcda29f6SYatharth Kochar  */
23dcda29f6SYatharth Kochar void arm_bl2u_platform_setup(void)
24dcda29f6SYatharth Kochar {
25dcda29f6SYatharth Kochar 	/* Initialize the secure environment */
26dcda29f6SYatharth Kochar 	plat_arm_security_setup();
27dcda29f6SYatharth Kochar }
28dcda29f6SYatharth Kochar 
29dcda29f6SYatharth Kochar void bl2u_platform_setup(void)
30dcda29f6SYatharth Kochar {
31dcda29f6SYatharth Kochar 	arm_bl2u_platform_setup();
32dcda29f6SYatharth Kochar }
33dcda29f6SYatharth Kochar 
34dcda29f6SYatharth Kochar void arm_bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
35dcda29f6SYatharth Kochar {
36dcda29f6SYatharth Kochar 	/* Initialize the console to provide early debug support */
37dcda29f6SYatharth Kochar 	console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ,
38dcda29f6SYatharth Kochar 			ARM_CONSOLE_BAUDRATE);
39dcda29f6SYatharth Kochar }
40dcda29f6SYatharth Kochar 
41dcda29f6SYatharth Kochar /*******************************************************************************
42dcda29f6SYatharth Kochar  * BL1 can pass platform dependent information to BL2U in x1.
43dcda29f6SYatharth Kochar  * In case of ARM CSS platforms x1 contains SCP_BL2U image info.
44dcda29f6SYatharth Kochar  * In case of ARM FVP platforms x1 is not used.
45dcda29f6SYatharth Kochar  * In both cases, x0 contains the extents of the memory available to BL2U
46dcda29f6SYatharth Kochar  ******************************************************************************/
47dcda29f6SYatharth Kochar void bl2u_early_platform_setup(meminfo_t *mem_layout, void *plat_info)
48dcda29f6SYatharth Kochar {
49dcda29f6SYatharth Kochar 	arm_bl2u_early_platform_setup(mem_layout, plat_info);
50dcda29f6SYatharth Kochar }
51dcda29f6SYatharth Kochar 
52dcda29f6SYatharth Kochar /*******************************************************************************
53dcda29f6SYatharth Kochar  * Perform the very early platform specific architectural setup here. At the
54dcda29f6SYatharth Kochar  * moment this is only initializes the mmu in a quick and dirty way.
55dcda29f6SYatharth Kochar  * The memory that is used by BL2U is only mapped.
56dcda29f6SYatharth Kochar  ******************************************************************************/
57dcda29f6SYatharth Kochar void arm_bl2u_plat_arch_setup(void)
58dcda29f6SYatharth Kochar {
59b2c96eedSSandrine Bailleux 	arm_setup_page_tables(BL2U_BASE,
60dcda29f6SYatharth Kochar 			      BL31_LIMIT,
610af559a8SSandrine Bailleux 			      BL_CODE_BASE,
62ecdc898dSMasahiro Yamada 			      BL_CODE_END,
630af559a8SSandrine Bailleux 			      BL_RO_DATA_BASE,
64ecdc898dSMasahiro Yamada 			      BL_RO_DATA_END
65dcda29f6SYatharth Kochar #if USE_COHERENT_MEM
66dcda29f6SYatharth Kochar 			      ,
6747497053SMasahiro Yamada 			      BL_COHERENT_RAM_BASE,
6847497053SMasahiro Yamada 			      BL_COHERENT_RAM_END
69dcda29f6SYatharth Kochar #endif
70dcda29f6SYatharth Kochar 		);
71b5fa6563SSandrine Bailleux 	enable_mmu_el1(0);
72dcda29f6SYatharth Kochar }
73dcda29f6SYatharth Kochar 
74dcda29f6SYatharth Kochar void bl2u_plat_arch_setup(void)
75dcda29f6SYatharth Kochar {
76dcda29f6SYatharth Kochar 	arm_bl2u_plat_arch_setup();
77dcda29f6SYatharth Kochar }
78