xref: /arm-trusted-firmware/plat/marvell/armada/common/marvell_bl1_setup.c (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700Schasinglulu /*
2*91f16700Schasinglulu  * Copyright (C) 2018 Marvell International Ltd.
3*91f16700Schasinglulu  *
4*91f16700Schasinglulu  * SPDX-License-Identifier:     BSD-3-Clause
5*91f16700Schasinglulu  * https://spdx.org/licenses
6*91f16700Schasinglulu  */
7*91f16700Schasinglulu 
8*91f16700Schasinglulu #include <platform_def.h>
9*91f16700Schasinglulu 
10*91f16700Schasinglulu #include <bl1/bl1.h>
11*91f16700Schasinglulu #include <common/bl_common.h>
12*91f16700Schasinglulu #include <common/debug.h>
13*91f16700Schasinglulu #include <drivers/arm/sp805.h>
14*91f16700Schasinglulu #include <drivers/console.h>
15*91f16700Schasinglulu #include <plat/common/platform.h>
16*91f16700Schasinglulu 
17*91f16700Schasinglulu #include <plat_marvell.h>
18*91f16700Schasinglulu 
19*91f16700Schasinglulu /* Weak definitions may be overridden in specific Marvell standard platform */
20*91f16700Schasinglulu #pragma weak bl1_early_platform_setup
21*91f16700Schasinglulu #pragma weak bl1_plat_arch_setup
22*91f16700Schasinglulu #pragma weak bl1_platform_setup
23*91f16700Schasinglulu #pragma weak bl1_plat_sec_mem_layout
24*91f16700Schasinglulu 
25*91f16700Schasinglulu /* Data structure which holds the extents of the RAM for BL1*/
26*91f16700Schasinglulu static meminfo_t bl1_ram_layout;
27*91f16700Schasinglulu 
28*91f16700Schasinglulu meminfo_t *bl1_plat_sec_mem_layout(void)
29*91f16700Schasinglulu {
30*91f16700Schasinglulu 	return &bl1_ram_layout;
31*91f16700Schasinglulu }
32*91f16700Schasinglulu 
33*91f16700Schasinglulu /*
34*91f16700Schasinglulu  * BL1 specific platform actions shared between Marvell standard platforms.
35*91f16700Schasinglulu  */
36*91f16700Schasinglulu void marvell_bl1_early_platform_setup(void)
37*91f16700Schasinglulu {
38*91f16700Schasinglulu 	/* Initialize the console to provide early debug support */
39*91f16700Schasinglulu 	marvell_console_boot_init();
40*91f16700Schasinglulu 
41*91f16700Schasinglulu 	/* Allow BL1 to see the whole Trusted RAM */
42*91f16700Schasinglulu 	bl1_ram_layout.total_base = MARVELL_BL_RAM_BASE;
43*91f16700Schasinglulu 	bl1_ram_layout.total_size = MARVELL_BL_RAM_SIZE;
44*91f16700Schasinglulu }
45*91f16700Schasinglulu 
46*91f16700Schasinglulu void bl1_early_platform_setup(void)
47*91f16700Schasinglulu {
48*91f16700Schasinglulu 	marvell_bl1_early_platform_setup();
49*91f16700Schasinglulu }
50*91f16700Schasinglulu 
51*91f16700Schasinglulu /*
52*91f16700Schasinglulu  * Perform the very early platform specific architecture setup shared between
53*91f16700Schasinglulu  * MARVELL standard platforms. This only does basic initialization. Later
54*91f16700Schasinglulu  * architectural setup (bl1_arch_setup()) does not do anything platform
55*91f16700Schasinglulu  * specific.
56*91f16700Schasinglulu  */
57*91f16700Schasinglulu void marvell_bl1_plat_arch_setup(void)
58*91f16700Schasinglulu {
59*91f16700Schasinglulu 	marvell_setup_page_tables(bl1_ram_layout.total_base,
60*91f16700Schasinglulu 				  bl1_ram_layout.total_size,
61*91f16700Schasinglulu 				  BL1_RO_BASE,
62*91f16700Schasinglulu 				  BL1_RO_LIMIT,
63*91f16700Schasinglulu 				  BL1_RO_DATA_BASE,
64*91f16700Schasinglulu 				  BL1_RO_DATA_END
65*91f16700Schasinglulu #if USE_COHERENT_MEM
66*91f16700Schasinglulu 				, BL_COHERENT_RAM_BASE,
67*91f16700Schasinglulu 				  BL_COHERENT_RAM_END
68*91f16700Schasinglulu #endif
69*91f16700Schasinglulu 				);
70*91f16700Schasinglulu 	enable_mmu_el3(0);
71*91f16700Schasinglulu }
72*91f16700Schasinglulu 
73*91f16700Schasinglulu void bl1_plat_arch_setup(void)
74*91f16700Schasinglulu {
75*91f16700Schasinglulu 	marvell_bl1_plat_arch_setup();
76*91f16700Schasinglulu }
77*91f16700Schasinglulu 
78*91f16700Schasinglulu /*
79*91f16700Schasinglulu  * Perform the platform specific architecture setup shared between
80*91f16700Schasinglulu  * MARVELL standard platforms.
81*91f16700Schasinglulu  */
82*91f16700Schasinglulu void marvell_bl1_platform_setup(void)
83*91f16700Schasinglulu {
84*91f16700Schasinglulu 	/* Initialise the IO layer and register platform IO devices */
85*91f16700Schasinglulu 	plat_marvell_io_setup();
86*91f16700Schasinglulu }
87*91f16700Schasinglulu 
88*91f16700Schasinglulu void bl1_platform_setup(void)
89*91f16700Schasinglulu {
90*91f16700Schasinglulu 	marvell_bl1_platform_setup();
91*91f16700Schasinglulu }
92*91f16700Schasinglulu 
93*91f16700Schasinglulu void bl1_plat_prepare_exit(entry_point_info_t *ep_info)
94*91f16700Schasinglulu {
95*91f16700Schasinglulu #ifdef EL3_PAYLOAD_BASE
96*91f16700Schasinglulu 	/*
97*91f16700Schasinglulu 	 * Program the EL3 payload's entry point address into the CPUs mailbox
98*91f16700Schasinglulu 	 * in order to release secondary CPUs from their holding pen and make
99*91f16700Schasinglulu 	 * them jump there.
100*91f16700Schasinglulu 	 */
101*91f16700Schasinglulu 	marvell_program_trusted_mailbox(ep_info->pc);
102*91f16700Schasinglulu 	dsbsy();
103*91f16700Schasinglulu 	sev();
104*91f16700Schasinglulu #endif
105*91f16700Schasinglulu }
106