Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 1 | /* |
Michal Simek | 2a47faa | 2023-04-14 08:43:51 +0200 | [diff] [blame] | 2 | * Copyright (c) 2014-2019, Arm Limited and Contributors. All rights reserved. |
Prasad Kummari | 877efa7 | 2023-10-31 15:05:29 +0530 | [diff] [blame] | 3 | * Copyright (c) 2023, Advanced Micro Devices. All rights reserved. |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 4 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 5 | * SPDX-License-Identifier: BSD-3-Clause |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 6 | */ |
| 7 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | #include <common/bl_common.h> |
| 9 | #include <common/debug.h> |
Prasad Kummari | 6dee9fb | 2023-10-31 15:20:00 +0530 | [diff] [blame] | 10 | #include <drivers/arm/pl011.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <drivers/console.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 12 | #include <plat/arm/common/plat_arm.h> |
Isla Mitchell | e363146 | 2017-07-14 10:46:32 +0100 | [diff] [blame] | 13 | #include <platform_tsp.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 14 | |
Prasad Kummari | 536e110 | 2023-06-22 10:50:02 +0530 | [diff] [blame] | 15 | #include <plat_private.h> |
| 16 | |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 17 | /******************************************************************************* |
| 18 | * Initialize the UART |
| 19 | ******************************************************************************/ |
| 20 | void tsp_early_platform_setup(void) |
| 21 | { |
| 22 | /* |
Ambroise Vincent | 53f193f | 2019-05-29 11:46:08 +0100 | [diff] [blame] | 23 | * Register a different console than already in use to display |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 24 | * messages from TSP |
| 25 | */ |
Andre Przywara | 8ccc4a4 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 26 | static console_t tsp_boot_console; |
Prasad Kummari | 877efa7 | 2023-10-31 15:05:29 +0530 | [diff] [blame] | 27 | int32_t rc; |
| 28 | |
Prasad Kummari | 6dee9fb | 2023-10-31 15:20:00 +0530 | [diff] [blame] | 29 | #if defined(PLAT_zynqmp) |
Prasad Kummari | 877efa7 | 2023-10-31 15:05:29 +0530 | [diff] [blame] | 30 | rc = console_cdns_register((uintptr_t)UART_BASE, |
| 31 | (uint32_t)get_uart_clk(), |
| 32 | (uint32_t)UART_BAUDRATE, |
| 33 | &tsp_boot_console); |
Prasad Kummari | 6dee9fb | 2023-10-31 15:20:00 +0530 | [diff] [blame] | 34 | #else |
| 35 | rc = console_pl011_register((uintptr_t)UART_BASE, |
| 36 | (uint32_t)get_uart_clk(), |
| 37 | (uint32_t)UART_BAUDRATE, |
| 38 | &tsp_boot_console); |
| 39 | #endif |
| 40 | |
Prasad Kummari | 877efa7 | 2023-10-31 15:05:29 +0530 | [diff] [blame] | 41 | if (rc == 0) { |
| 42 | panic(); |
| 43 | } |
| 44 | |
Andre Przywara | 8ccc4a4 | 2020-01-25 00:58:35 +0000 | [diff] [blame] | 45 | console_set_scope(&tsp_boot_console, |
Ambroise Vincent | 53f193f | 2019-05-29 11:46:08 +0100 | [diff] [blame] | 46 | CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_BOOT); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | /******************************************************************************* |
| 50 | * Perform platform specific setup placeholder |
| 51 | ******************************************************************************/ |
| 52 | void tsp_platform_setup(void) |
| 53 | { |
Prasad Kummari | 6dee9fb | 2023-10-31 15:20:00 +0530 | [diff] [blame] | 54 | /* |
| 55 | * For ZynqMP, the GICv2 driver needs to be initialized in S-EL1, |
| 56 | * and for other platforms, the GICv3 driver is initialized in EL3. |
| 57 | * This is because S-EL1 can use GIC system registers to manage |
| 58 | * interrupts and does not need to be initialized again in SEL1. |
| 59 | */ |
| 60 | #if defined(PLAT_zynqmp) |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 61 | plat_arm_gic_driver_init(); |
| 62 | plat_arm_gic_init(); |
Prasad Kummari | 6dee9fb | 2023-10-31 15:20:00 +0530 | [diff] [blame] | 63 | #endif |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | /******************************************************************************* |
| 67 | * Perform the very early platform specific architectural setup here. At the |
Elyes Haouas | 2be03c0 | 2023-02-13 09:14:48 +0100 | [diff] [blame] | 68 | * moment this is only initializes the MMU |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 69 | ******************************************************************************/ |
| 70 | void tsp_plat_arch_setup(void) |
| 71 | { |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 72 | const mmap_region_t bl_regions[] = { |
| 73 | MAP_REGION_FLAT(BL32_BASE, BL32_END - BL32_BASE, |
| 74 | MT_MEMORY | MT_RW | MT_SECURE), |
| 75 | MAP_REGION_FLAT(BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE, |
| 76 | MT_CODE | MT_SECURE), |
| 77 | MAP_REGION_FLAT(BL_RO_DATA_BASE, BL_RO_DATA_END - BL_RO_DATA_BASE, |
| 78 | MT_RO_DATA | MT_SECURE), |
Prasad Kummari | 5317488 | 2023-10-27 13:54:20 +0530 | [diff] [blame] | 79 | #if defined(PLAT_zynqmp) || defined(PLAT_versal) |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 80 | MAP_REGION_FLAT(BL_COHERENT_RAM_BASE, |
| 81 | BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE, |
| 82 | MT_DEVICE | MT_RW | MT_SECURE), |
Prasad Kummari | 5317488 | 2023-10-27 13:54:20 +0530 | [diff] [blame] | 83 | #endif |
Daniel Boulby | 45a2c9e | 2018-07-06 16:54:44 +0100 | [diff] [blame] | 84 | {0} |
| 85 | }; |
| 86 | |
Prasad Kummari | 0b37714 | 2023-10-26 16:32:26 +0530 | [diff] [blame] | 87 | setup_page_tables(bl_regions, plat_get_mmap()); |
Sandrine Bailleux | 4a1267a | 2016-05-18 16:11:47 +0100 | [diff] [blame] | 88 | enable_mmu_el1(0); |
Soren Brinkmann | 76fcae3 | 2016-03-06 20:16:27 -0800 | [diff] [blame] | 89 | } |