blob: a3d2f7157cae67872adae1c3bcc43423482cc006 [file] [log] [blame]
Dan Handley9df48042015-03-19 18:58:55 +00001/*
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +01002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Dan Handley9df48042015-03-19 18:58:55 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handley9df48042015-03-19 18:58:55 +00005 */
6
Daniel Boulby45a2c9e2018-07-06 16:54:44 +01007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Dan Handley9df48042015-03-19 18:58:55 +00009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <bl32/tsp/platform_tsp.h>
12#include <common/bl_common.h>
13#include <common/debug.h>
14#include <drivers/arm/pl011.h>
15#include <drivers/console.h>
16
17#include <arm_def.h>
18#include <plat_arm.h>
Dan Handley9df48042015-03-19 18:58:55 +000019
Dan Handley9df48042015-03-19 18:58:55 +000020#define BL32_END (unsigned long)(&__BL32_END__)
21
Dan Handley9df48042015-03-19 18:58:55 +000022/* Weak definitions may be overridden in specific ARM standard platform */
23#pragma weak tsp_early_platform_setup
24#pragma weak tsp_platform_setup
25#pragma weak tsp_plat_arch_setup
26
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010027#define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \
28 BL32_BASE, \
29 BL32_END - BL32_BASE, \
30 MT_MEMORY | MT_RW | MT_SECURE)
Dan Handley9df48042015-03-19 18:58:55 +000031
32/*******************************************************************************
33 * Initialize the UART
34 ******************************************************************************/
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010035#if MULTI_CONSOLE_API
36static console_pl011_t arm_tsp_runtime_console;
37#endif
38
Dan Handley9df48042015-03-19 18:58:55 +000039void arm_tsp_early_platform_setup(void)
40{
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010041#if MULTI_CONSOLE_API
Dan Handley9df48042015-03-19 18:58:55 +000042 /*
43 * Initialize a different console than already in use to display
44 * messages from TSP
45 */
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010046 int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
47 PLAT_ARM_TSP_UART_CLK_IN_HZ,
48 ARM_CONSOLE_BAUDRATE,
49 &arm_tsp_runtime_console);
50 if (rc == 0)
51 panic();
52
53 console_set_scope(&arm_tsp_runtime_console.console,
54 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
55#else
Dan Handley9df48042015-03-19 18:58:55 +000056 console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ,
57 ARM_CONSOLE_BAUDRATE);
Antonio Nino Diaz23ede6a2018-06-19 09:29:36 +010058#endif /* MULTI_CONSOLE_API */
Dan Handley9df48042015-03-19 18:58:55 +000059}
60
61void tsp_early_platform_setup(void)
62{
63 arm_tsp_early_platform_setup();
64}
65
66/*******************************************************************************
67 * Perform platform specific setup placeholder
68 ******************************************************************************/
69void tsp_platform_setup(void)
70{
Achin Gupta1fa7eb62015-11-03 14:18:34 +000071 plat_arm_gic_driver_init();
Dan Handley9df48042015-03-19 18:58:55 +000072}
73
74/*******************************************************************************
75 * Perform the very early platform specific architectural setup here. At the
76 * moment this is only intializes the MMU
77 ******************************************************************************/
78void tsp_plat_arch_setup(void)
79{
Dan Handley9df48042015-03-19 18:58:55 +000080#if USE_COHERENT_MEM
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010081 /* Ensure ARM platforms dont use coherent memory in TSP */
82 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
Dan Handley9df48042015-03-19 18:58:55 +000083#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010084
85 const mmap_region_t bl_regions[] = {
86 MAP_BL_TSP_TOTAL,
Daniel Boulby4e97abd2018-07-16 14:09:15 +010087 ARM_MAP_BL_RO,
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010088 {0}
89 };
90
Roberto Vargas344ff022018-10-19 16:44:18 +010091 setup_page_tables(bl_regions, plat_arm_get_mmap());
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010092 enable_mmu_el1(0);
Dan Handley9df48042015-03-19 18:58:55 +000093}