blob: 16125ad4fa35bab16863171cf4aad086972b9a78 [file] [log] [blame]
Dan Handley9df48042015-03-19 18:58:55 +00001/*
Antonio Nino Diaz93bd9162018-05-04 12:59:45 +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
7#include <arm_def.h>
8#include <bl_common.h>
9#include <console.h>
Antonio Nino Diaz93bd9162018-05-04 12:59:45 +010010#include <debug.h>
11#include <pl011.h>
Isla Mitchelld2548792017-07-14 10:48:25 +010012#include <plat_arm.h>
Dan Handley9df48042015-03-19 18:58:55 +000013#include <platform_def.h>
14#include <platform_tsp.h>
Dan Handley9df48042015-03-19 18:58:55 +000015
Dan Handley9df48042015-03-19 18:58:55 +000016#define BL32_END (unsigned long)(&__BL32_END__)
17
Dan Handley9df48042015-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
23
24/*******************************************************************************
25 * Initialize the UART
26 ******************************************************************************/
Antonio Nino Diaz93bd9162018-05-04 12:59:45 +010027#if MULTI_CONSOLE_API
28static console_pl011_t arm_tsp_runtime_console;
29#endif
30
Dan Handley9df48042015-03-19 18:58:55 +000031void arm_tsp_early_platform_setup(void)
32{
Antonio Nino Diaz93bd9162018-05-04 12:59:45 +010033#if MULTI_CONSOLE_API
Dan Handley9df48042015-03-19 18:58:55 +000034 /*
35 * Initialize a different console than already in use to display
36 * messages from TSP
37 */
Antonio Nino Diaz93bd9162018-05-04 12:59:45 +010038 int rc = console_pl011_register(PLAT_ARM_TSP_UART_BASE,
39 PLAT_ARM_TSP_UART_CLK_IN_HZ,
40 ARM_CONSOLE_BAUDRATE,
41 &arm_tsp_runtime_console);
42 if (rc == 0)
43 panic();
44
45 console_set_scope(&arm_tsp_runtime_console.console,
46 CONSOLE_FLAG_BOOT | CONSOLE_FLAG_RUNTIME);
47#else
Dan Handley9df48042015-03-19 18:58:55 +000048 console_init(PLAT_ARM_TSP_UART_BASE, PLAT_ARM_TSP_UART_CLK_IN_HZ,
49 ARM_CONSOLE_BAUDRATE);
Antonio Nino Diaz93bd9162018-05-04 12:59:45 +010050#endif /* MULTI_CONSOLE_API */
Dan Handley9df48042015-03-19 18:58:55 +000051}
52
53void tsp_early_platform_setup(void)
54{
55 arm_tsp_early_platform_setup();
56}
57
58/*******************************************************************************
59 * Perform platform specific setup placeholder
60 ******************************************************************************/
61void tsp_platform_setup(void)
62{
Achin Gupta1fa7eb62015-11-03 14:18:34 +000063 plat_arm_gic_driver_init();
Dan Handley9df48042015-03-19 18:58:55 +000064}
65
66/*******************************************************************************
67 * Perform the very early platform specific architectural setup here. At the
68 * moment this is only intializes the MMU
69 ******************************************************************************/
70void tsp_plat_arch_setup(void)
71{
Sandrine Bailleuxecdc4d32016-07-08 14:38:16 +010072 arm_setup_page_tables(BL32_BASE,
73 (BL32_END - BL32_BASE),
74 BL_CODE_BASE,
Masahiro Yamada51bef612017-01-18 02:10:08 +090075 BL_CODE_END,
Sandrine Bailleuxecdc4d32016-07-08 14:38:16 +010076 BL_RO_DATA_BASE,
Masahiro Yamada51bef612017-01-18 02:10:08 +090077 BL_RO_DATA_END
Dan Handley9df48042015-03-19 18:58:55 +000078#if USE_COHERENT_MEM
Masahiro Yamada0fac5af2016-12-28 16:11:41 +090079 , BL_COHERENT_RAM_BASE,
80 BL_COHERENT_RAM_END
Dan Handley9df48042015-03-19 18:58:55 +000081#endif
82 );
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010083 enable_mmu_el1(0);
Dan Handley9df48042015-03-19 18:58:55 +000084}