1b4315306SDan Handley /* 2*b5fa6563SSandrine 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 39b4315306SDan Handley /* 40b4315306SDan Handley * The next 3 constants identify the extents of the code & RO data region and 41d178637dSJuan Castillo * the limit of the BL32 image. These addresses are used by the MMU setup code 42b4315306SDan Handley * and therefore they must be page-aligned. It is the responsibility of the 43b4315306SDan Handley * linker script to ensure that __RO_START__, __RO_END__ & & __BL32_END__ 44b4315306SDan Handley * linker symbols refer to page-aligned addresses. 45b4315306SDan Handley */ 46b4315306SDan Handley #define BL32_RO_BASE (unsigned long)(&__RO_START__) 47b4315306SDan Handley #define BL32_RO_LIMIT (unsigned long)(&__RO_END__) 48b4315306SDan Handley #define BL32_END (unsigned long)(&__BL32_END__) 49b4315306SDan Handley 50b4315306SDan Handley #if USE_COHERENT_MEM 51b4315306SDan Handley /* 52b4315306SDan Handley * The next 2 constants identify the extents of the coherent memory region. 53b4315306SDan Handley * These addresses are used by the MMU setup code and therefore they must be 54b4315306SDan Handley * page-aligned. It is the responsibility of the linker script to ensure that 55b4315306SDan Handley * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to 56b4315306SDan Handley * page-aligned addresses. 57b4315306SDan Handley */ 58b4315306SDan Handley #define BL32_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) 59b4315306SDan Handley #define BL32_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) 60b4315306SDan Handley #endif 61b4315306SDan Handley 62b4315306SDan Handley 63b4315306SDan Handley /* Weak definitions may be overridden in specific ARM standard platform */ 64b4315306SDan Handley #pragma weak tsp_early_platform_setup 65b4315306SDan Handley #pragma weak tsp_platform_setup 66b4315306SDan Handley #pragma weak tsp_plat_arch_setup 67b4315306SDan Handley 68b4315306SDan Handley 69b4315306SDan Handley /******************************************************************************* 70b4315306SDan Handley * Initialize the UART 71b4315306SDan Handley ******************************************************************************/ 72b4315306SDan Handley void arm_tsp_early_platform_setup(void) 73b4315306SDan Handley { 74b4315306SDan Handley /* 75b4315306SDan Handley * Initialize a different console than already in use to display 76b4315306SDan Handley * messages from TSP 77b4315306SDan Handley */ 78b4315306SDan Handley console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ, 79b4315306SDan Handley ARM_CONSOLE_BAUDRATE); 80b4315306SDan Handley } 81b4315306SDan Handley 82b4315306SDan Handley void tsp_early_platform_setup(void) 83b4315306SDan Handley { 84b4315306SDan Handley arm_tsp_early_platform_setup(); 85b4315306SDan Handley } 86b4315306SDan Handley 87b4315306SDan Handley /******************************************************************************* 88b4315306SDan Handley * Perform platform specific setup placeholder 89b4315306SDan Handley ******************************************************************************/ 90b4315306SDan Handley void tsp_platform_setup(void) 91b4315306SDan Handley { 9227573c59SAchin Gupta plat_arm_gic_driver_init(); 93b4315306SDan Handley } 94b4315306SDan Handley 95b4315306SDan Handley /******************************************************************************* 96b4315306SDan Handley * Perform the very early platform specific architectural setup here. At the 97b4315306SDan Handley * moment this is only intializes the MMU 98b4315306SDan Handley ******************************************************************************/ 99b4315306SDan Handley void tsp_plat_arch_setup(void) 100b4315306SDan Handley { 101*b5fa6563SSandrine Bailleux arm_setup_page_tables(BL32_RO_BASE, 102b4315306SDan Handley (BL32_END - BL32_RO_BASE), 103b4315306SDan Handley BL32_RO_BASE, 104b4315306SDan Handley BL32_RO_LIMIT 105b4315306SDan Handley #if USE_COHERENT_MEM 106b4315306SDan Handley , BL32_COHERENT_RAM_BASE, 107b4315306SDan Handley BL32_COHERENT_RAM_LIMIT 108b4315306SDan Handley #endif 109b4315306SDan Handley ); 110*b5fa6563SSandrine Bailleux enable_mmu_el1(0); 111b4315306SDan Handley } 112