xref: /rk3399_ARM-atf/plat/arm/common/tsp/arm_tsp_setup.c (revision 0af559a833e9cb1be1e1295d00e22ecab1d3f5be)
1b4315306SDan Handley /*
2b5fa6563SSandrine Bailleux  * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3b4315306SDan Handley  *
4b4315306SDan Handley  * Redistribution and use in source and binary forms, with or without
5b4315306SDan Handley  * modification, are permitted provided that the following conditions are met:
6b4315306SDan Handley  *
7b4315306SDan Handley  * Redistributions of source code must retain the above copyright notice, this
8b4315306SDan Handley  * list of conditions and the following disclaimer.
9b4315306SDan Handley  *
10b4315306SDan Handley  * Redistributions in binary form must reproduce the above copyright notice,
11b4315306SDan Handley  * this list of conditions and the following disclaimer in the documentation
12b4315306SDan Handley  * and/or other materials provided with the distribution.
13b4315306SDan Handley  *
14b4315306SDan Handley  * Neither the name of ARM nor the names of its contributors may be used
15b4315306SDan Handley  * to endorse or promote products derived from this software without specific
16b4315306SDan Handley  * prior written permission.
17b4315306SDan Handley  *
18b4315306SDan Handley  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19b4315306SDan Handley  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20b4315306SDan Handley  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21b4315306SDan Handley  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22b4315306SDan Handley  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23b4315306SDan Handley  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24b4315306SDan Handley  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25b4315306SDan Handley  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26b4315306SDan Handley  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27b4315306SDan Handley  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28b4315306SDan Handley  * POSSIBILITY OF SUCH DAMAGE.
29b4315306SDan Handley  */
30b4315306SDan Handley 
31b4315306SDan Handley #include <arm_def.h>
32b4315306SDan Handley #include <bl_common.h>
33b4315306SDan Handley #include <console.h>
34b4315306SDan Handley #include <platform_def.h>
35b4315306SDan Handley #include <platform_tsp.h>
36b4315306SDan Handley #include <plat_arm.h>
37b4315306SDan Handley 
38b4315306SDan Handley #define BL32_END (unsigned long)(&__BL32_END__)
39b4315306SDan Handley 
40b4315306SDan Handley #if USE_COHERENT_MEM
41b4315306SDan Handley /*
42b4315306SDan Handley  * The next 2 constants identify the extents of the coherent memory region.
43b4315306SDan Handley  * These addresses are used by the MMU setup code and therefore they must be
44b4315306SDan Handley  * page-aligned.  It is the responsibility of the linker script to ensure that
45b4315306SDan Handley  * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to
46b4315306SDan Handley  * page-aligned addresses.
47b4315306SDan Handley  */
48b4315306SDan Handley #define BL32_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
49b4315306SDan Handley #define BL32_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
50b4315306SDan Handley #endif
51b4315306SDan Handley 
52b4315306SDan Handley 
53b4315306SDan Handley /* Weak definitions may be overridden in specific ARM standard platform */
54b4315306SDan Handley #pragma weak tsp_early_platform_setup
55b4315306SDan Handley #pragma weak tsp_platform_setup
56b4315306SDan Handley #pragma weak tsp_plat_arch_setup
57b4315306SDan Handley 
58b4315306SDan Handley 
59b4315306SDan Handley /*******************************************************************************
60b4315306SDan Handley  * Initialize the UART
61b4315306SDan Handley  ******************************************************************************/
62b4315306SDan Handley void arm_tsp_early_platform_setup(void)
63b4315306SDan Handley {
64b4315306SDan Handley 	/*
65b4315306SDan Handley 	 * Initialize a different console than already in use to display
66b4315306SDan Handley 	 * messages from TSP
67b4315306SDan Handley 	 */
68b4315306SDan Handley 	console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ,
69b4315306SDan Handley 			ARM_CONSOLE_BAUDRATE);
70b4315306SDan Handley }
71b4315306SDan Handley 
72b4315306SDan Handley void tsp_early_platform_setup(void)
73b4315306SDan Handley {
74b4315306SDan Handley 	arm_tsp_early_platform_setup();
75b4315306SDan Handley }
76b4315306SDan Handley 
77b4315306SDan Handley /*******************************************************************************
78b4315306SDan Handley  * Perform platform specific setup placeholder
79b4315306SDan Handley  ******************************************************************************/
80b4315306SDan Handley void tsp_platform_setup(void)
81b4315306SDan Handley {
8227573c59SAchin Gupta 	plat_arm_gic_driver_init();
83b4315306SDan Handley }
84b4315306SDan Handley 
85b4315306SDan Handley /*******************************************************************************
86b4315306SDan Handley  * Perform the very early platform specific architectural setup here. At the
87b4315306SDan Handley  * moment this is only intializes the MMU
88b4315306SDan Handley  ******************************************************************************/
89b4315306SDan Handley void tsp_plat_arch_setup(void)
90b4315306SDan Handley {
91*0af559a8SSandrine Bailleux 	arm_setup_page_tables(BL32_BASE,
92*0af559a8SSandrine Bailleux 			      (BL32_END - BL32_BASE),
93*0af559a8SSandrine Bailleux 			      BL_CODE_BASE,
94*0af559a8SSandrine Bailleux 			      BL_CODE_LIMIT,
95*0af559a8SSandrine Bailleux 			      BL_RO_DATA_BASE,
96*0af559a8SSandrine Bailleux 			      BL_RO_DATA_LIMIT
97b4315306SDan Handley #if USE_COHERENT_MEM
98b4315306SDan Handley 			      , BL32_COHERENT_RAM_BASE,
99b4315306SDan Handley 			      BL32_COHERENT_RAM_LIMIT
100b4315306SDan Handley #endif
101b4315306SDan Handley 			      );
102b5fa6563SSandrine Bailleux 	enable_mmu_el1(0);
103b4315306SDan Handley }
104