blob: 4d4121512f8b085212f64628ccf0545ab3f3c509 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Michal Simek2a47faa2023-04-14 08:43:51 +02002 * Copyright (c) 2014-2019, Arm Limited and Contributors. All rights reserved.
Prasad Kummari877efa72023-10-31 15:05:29 +05303 * Copyright (c) 2023, Advanced Micro Devices. All rights reserved.
Soren Brinkmann76fcae32016-03-06 20:16:27 -08004 *
dp-armfa3cf0b2017-05-03 09:38:09 +01005 * SPDX-License-Identifier: BSD-3-Clause
Soren Brinkmann76fcae32016-03-06 20:16:27 -08006 */
7
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/bl_common.h>
9#include <common/debug.h>
10#include <drivers/console.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000011#include <plat/arm/common/plat_arm.h>
Isla Mitchelle3631462017-07-14 10:46:32 +010012#include <platform_tsp.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000013
Prasad Kummari536e1102023-06-22 10:50:02 +053014#include <plat_private.h>
15
Soren Brinkmann76fcae32016-03-06 20:16:27 -080016/*******************************************************************************
17 * Initialize the UART
18 ******************************************************************************/
19void tsp_early_platform_setup(void)
20{
21 /*
Ambroise Vincent53f193f2019-05-29 11:46:08 +010022 * Register a different console than already in use to display
Soren Brinkmann76fcae32016-03-06 20:16:27 -080023 * messages from TSP
24 */
Andre Przywara8ccc4a42020-01-25 00:58:35 +000025 static console_t tsp_boot_console;
Prasad Kummari877efa72023-10-31 15:05:29 +053026 int32_t rc;
27
28 rc = console_cdns_register((uintptr_t)UART_BASE,
29 (uint32_t)get_uart_clk(),
30 (uint32_t)UART_BAUDRATE,
31 &tsp_boot_console);
32 if (rc == 0) {
33 panic();
34 }
35
Andre Przywara8ccc4a42020-01-25 00:58:35 +000036 console_set_scope(&tsp_boot_console,
Ambroise Vincent53f193f2019-05-29 11:46:08 +010037 CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_BOOT);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080038}
39
40/*******************************************************************************
41 * Perform platform specific setup placeholder
42 ******************************************************************************/
43void tsp_platform_setup(void)
44{
45 plat_arm_gic_driver_init();
46 plat_arm_gic_init();
47}
48
49/*******************************************************************************
50 * Perform the very early platform specific architectural setup here. At the
Elyes Haouas2be03c02023-02-13 09:14:48 +010051 * moment this is only initializes the MMU
Soren Brinkmann76fcae32016-03-06 20:16:27 -080052 ******************************************************************************/
53void tsp_plat_arch_setup(void)
54{
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010055 const mmap_region_t bl_regions[] = {
56 MAP_REGION_FLAT(BL32_BASE, BL32_END - BL32_BASE,
57 MT_MEMORY | MT_RW | MT_SECURE),
58 MAP_REGION_FLAT(BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE,
59 MT_CODE | MT_SECURE),
60 MAP_REGION_FLAT(BL_RO_DATA_BASE, BL_RO_DATA_END - BL_RO_DATA_BASE,
61 MT_RO_DATA | MT_SECURE),
62 MAP_REGION_FLAT(BL_COHERENT_RAM_BASE,
63 BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
64 MT_DEVICE | MT_RW | MT_SECURE),
65 {0}
66 };
67
Prasad Kummari0b377142023-10-26 16:32:26 +053068 setup_page_tables(bl_regions, plat_get_mmap());
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010069 enable_mmu_el1(0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080070}