blob: ee1df6c3e7b4e0ec1c652c29d21888e258844961 [file] [log] [blame]
Dan Handleyb4315302015-03-19 18:58:55 +00001/*
Paul Beesley8aabea32019-01-11 18:26:51 +00002 * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
Dan Handleyb4315302015-03-19 18:58:55 +00003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handleyb4315302015-03-19 18:58:55 +00005 */
6
Daniel Boulbyd323af92018-07-06 16:54:44 +01007#include <assert.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00008
Dan Handleyb4315302015-03-19 18:58:55 +00009#include <platform_def.h>
Antonio Nino Diaz09d40e02018-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>
Antonio Nino Diazbd9344f2019-01-25 14:30:04 +000016#include <plat/arm/common/plat_arm.h>
Dan Handleyb4315302015-03-19 18:58:55 +000017
Dan Handleyb4315302015-03-19 18:58:55 +000018/* Weak definitions may be overridden in specific ARM standard platform */
19#pragma weak tsp_early_platform_setup
20#pragma weak tsp_platform_setup
21#pragma weak tsp_plat_arch_setup
22
Daniel Boulbyd323af92018-07-06 16:54:44 +010023#define MAP_BL_TSP_TOTAL MAP_REGION_FLAT( \
24 BL32_BASE, \
25 BL32_END - BL32_BASE, \
26 MT_MEMORY | MT_RW | MT_SECURE)
Dan Handleyb4315302015-03-19 18:58:55 +000027
28/*******************************************************************************
29 * Initialize the UART
30 ******************************************************************************/
Andre Przywaraf695e1e2020-01-25 00:58:35 +000031static console_t arm_tsp_runtime_console;
Antonio Nino Diaz88a05232018-06-19 09:29:36 +010032
Dan Handleyb4315302015-03-19 18:58:55 +000033void arm_tsp_early_platform_setup(void)
34{
35 /*
36 * Initialize a different console than already in use to display
37 * messages from TSP
38 */
Antonio Nino Diaz88a05232018-06-19 09:29:36 +010039 int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
40 PLAT_ARM_TSP_UART_CLK_IN_HZ,
41 ARM_CONSOLE_BAUDRATE,
42 &arm_tsp_runtime_console);
43 if (rc == 0)
44 panic();
45
Andre Przywaraf695e1e2020-01-25 00:58:35 +000046 console_set_scope(&arm_tsp_runtime_console,
Antonio Nino Diaz88a05232018-06-19 09:29:36 +010047 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
Dan Handleyb4315302015-03-19 18:58:55 +000048}
49
50void tsp_early_platform_setup(void)
51{
52 arm_tsp_early_platform_setup();
53}
54
55/*******************************************************************************
56 * Perform platform specific setup placeholder
57 ******************************************************************************/
58void tsp_platform_setup(void)
59{
Achin Gupta27573c52015-11-03 14:18:34 +000060 plat_arm_gic_driver_init();
Dan Handleyb4315302015-03-19 18:58:55 +000061}
62
63/*******************************************************************************
64 * Perform the very early platform specific architectural setup here. At the
65 * moment this is only intializes the MMU
66 ******************************************************************************/
67void tsp_plat_arch_setup(void)
68{
Dan Handleyb4315302015-03-19 18:58:55 +000069#if USE_COHERENT_MEM
Paul Beesley8aabea32019-01-11 18:26:51 +000070 /* Ensure ARM platforms don't use coherent memory in TSP */
Daniel Boulbyd323af92018-07-06 16:54:44 +010071 assert((BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE) == 0U);
Dan Handleyb4315302015-03-19 18:58:55 +000072#endif
Daniel Boulbyd323af92018-07-06 16:54:44 +010073
74 const mmap_region_t bl_regions[] = {
75 MAP_BL_TSP_TOTAL,
Daniel Boulby2ecaafd2018-07-16 14:09:15 +010076 ARM_MAP_BL_RO,
Daniel Boulbyd323af92018-07-06 16:54:44 +010077 {0}
78 };
79
Roberto Vargas0916c382018-10-19 16:44:18 +010080 setup_page_tables(bl_regions, plat_arm_get_mmap());
Sandrine Bailleuxb5fa6562016-05-18 16:11:47 +010081 enable_mmu_el1(0);
Dan Handleyb4315302015-03-19 18:58:55 +000082}