blob: 5df4b6e16e2186473caecf4c732c3c62e2bc6306 [file] [log] [blame]
Soren Brinkmann76fcae32016-03-06 20:16:27 -08001/*
Harrison Mutai841c0d42025-03-21 17:08:12 +00002 * Copyright (c) 2014-2025, 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>
Prasad Kummari6dee9fb2023-10-31 15:20:00 +053010#include <drivers/arm/pl011.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000011#include <drivers/console.h>
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000012#include <plat/arm/common/plat_arm.h>
Isla Mitchelle3631462017-07-14 10:46:32 +010013#include <platform_tsp.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000014
Prasad Kummari536e1102023-06-22 10:50:02 +053015#include <plat_private.h>
16
Soren Brinkmann76fcae32016-03-06 20:16:27 -080017/*******************************************************************************
18 * Initialize the UART
19 ******************************************************************************/
Harrison Mutai841c0d42025-03-21 17:08:12 +000020void tsp_early_platform_setup(u_register_t arg0, u_register_t arg1,
21 u_register_t arg2, u_register_t arg3)
Soren Brinkmann76fcae32016-03-06 20:16:27 -080022{
23 /*
Ambroise Vincent53f193f2019-05-29 11:46:08 +010024 * Register a different console than already in use to display
Soren Brinkmann76fcae32016-03-06 20:16:27 -080025 * messages from TSP
26 */
Andre Przywara8ccc4a42020-01-25 00:58:35 +000027 static console_t tsp_boot_console;
Prasad Kummari877efa72023-10-31 15:05:29 +053028 int32_t rc;
29
Prasad Kummari6dee9fb2023-10-31 15:20:00 +053030#if defined(PLAT_zynqmp)
Prasad Kummari877efa72023-10-31 15:05:29 +053031 rc = console_cdns_register((uintptr_t)UART_BASE,
32 (uint32_t)get_uart_clk(),
33 (uint32_t)UART_BAUDRATE,
34 &tsp_boot_console);
Prasad Kummari6dee9fb2023-10-31 15:20:00 +053035#else
36 rc = console_pl011_register((uintptr_t)UART_BASE,
37 (uint32_t)get_uart_clk(),
38 (uint32_t)UART_BAUDRATE,
39 &tsp_boot_console);
40#endif
41
Prasad Kummari877efa72023-10-31 15:05:29 +053042 if (rc == 0) {
43 panic();
44 }
45
Andre Przywara8ccc4a42020-01-25 00:58:35 +000046 console_set_scope(&tsp_boot_console,
Ambroise Vincent53f193f2019-05-29 11:46:08 +010047 CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_BOOT);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080048}
49
50/*******************************************************************************
51 * Perform platform specific setup placeholder
52 ******************************************************************************/
53void tsp_platform_setup(void)
54{
Prasad Kummari6dee9fb2023-10-31 15:20:00 +053055/*
56 * For ZynqMP, the GICv2 driver needs to be initialized in S-EL1,
57 * and for other platforms, the GICv3 driver is initialized in EL3.
58 * This is because S-EL1 can use GIC system registers to manage
59 * interrupts and does not need to be initialized again in SEL1.
60 */
61#if defined(PLAT_zynqmp)
Soren Brinkmann76fcae32016-03-06 20:16:27 -080062 plat_arm_gic_driver_init();
63 plat_arm_gic_init();
Prasad Kummari6dee9fb2023-10-31 15:20:00 +053064#endif
Soren Brinkmann76fcae32016-03-06 20:16:27 -080065}
66
67/*******************************************************************************
68 * Perform the very early platform specific architectural setup here. At the
Elyes Haouas2be03c02023-02-13 09:14:48 +010069 * moment this is only initializes the MMU
Soren Brinkmann76fcae32016-03-06 20:16:27 -080070 ******************************************************************************/
71void tsp_plat_arch_setup(void)
72{
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010073 const mmap_region_t bl_regions[] = {
74 MAP_REGION_FLAT(BL32_BASE, BL32_END - BL32_BASE,
75 MT_MEMORY | MT_RW | MT_SECURE),
76 MAP_REGION_FLAT(BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE,
77 MT_CODE | MT_SECURE),
78 MAP_REGION_FLAT(BL_RO_DATA_BASE, BL_RO_DATA_END - BL_RO_DATA_BASE,
79 MT_RO_DATA | MT_SECURE),
Prasad Kummari53174882023-10-27 13:54:20 +053080#if defined(PLAT_zynqmp) || defined(PLAT_versal)
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010081 MAP_REGION_FLAT(BL_COHERENT_RAM_BASE,
82 BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
83 MT_DEVICE | MT_RW | MT_SECURE),
Prasad Kummari53174882023-10-27 13:54:20 +053084#endif
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010085 {0}
86 };
87
Prasad Kummari0b377142023-10-26 16:32:26 +053088 setup_page_tables(bl_regions, plat_get_mmap());
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010089 enable_mmu_el1(0);
Soren Brinkmann76fcae32016-03-06 20:16:27 -080090}