xref: /rk3399_ARM-atf/plat/xilinx/common/tsp/tsp_plat_setup.c (revision 7ff4d4fbe58273541da86fa72786d4bd4604be9a)
14c7abf85SPrasad Kummari /*
24c7abf85SPrasad Kummari  * Copyright (c) 2014-2019, Arm Limited and Contributors. All rights reserved.
34c7abf85SPrasad Kummari  * Copyright (c) 2023, Advanced Micro Devices. All rights reserved.
44c7abf85SPrasad Kummari  *
54c7abf85SPrasad Kummari  * SPDX-License-Identifier: BSD-3-Clause
64c7abf85SPrasad Kummari  */
74c7abf85SPrasad Kummari 
84c7abf85SPrasad Kummari #include <common/bl_common.h>
94c7abf85SPrasad Kummari #include <common/debug.h>
10*7ff4d4fbSPrasad Kummari #include <drivers/arm/pl011.h>
114c7abf85SPrasad Kummari #include <drivers/console.h>
124c7abf85SPrasad Kummari #include <plat/arm/common/plat_arm.h>
134c7abf85SPrasad Kummari #include <platform_tsp.h>
144c7abf85SPrasad Kummari 
154c7abf85SPrasad Kummari #include <plat_private.h>
164c7abf85SPrasad Kummari 
174c7abf85SPrasad Kummari /*******************************************************************************
184c7abf85SPrasad Kummari  * Initialize the UART
194c7abf85SPrasad Kummari  ******************************************************************************/
204c7abf85SPrasad Kummari void tsp_early_platform_setup(void)
214c7abf85SPrasad Kummari {
224c7abf85SPrasad Kummari 	/*
234c7abf85SPrasad Kummari 	 * Register a different console than already in use to display
244c7abf85SPrasad Kummari 	 * messages from TSP
254c7abf85SPrasad Kummari 	 */
264c7abf85SPrasad Kummari 	static console_t tsp_boot_console;
274c7abf85SPrasad Kummari 	int32_t rc;
284c7abf85SPrasad Kummari 
29*7ff4d4fbSPrasad Kummari #if defined(PLAT_zynqmp)
304c7abf85SPrasad Kummari 	rc = console_cdns_register((uintptr_t)UART_BASE,
314c7abf85SPrasad Kummari 				   (uint32_t)get_uart_clk(),
324c7abf85SPrasad Kummari 				   (uint32_t)UART_BAUDRATE,
334c7abf85SPrasad Kummari 				   &tsp_boot_console);
34*7ff4d4fbSPrasad Kummari #else
35*7ff4d4fbSPrasad Kummari 	rc = console_pl011_register((uintptr_t)UART_BASE,
36*7ff4d4fbSPrasad Kummari 				    (uint32_t)get_uart_clk(),
37*7ff4d4fbSPrasad Kummari 				    (uint32_t)UART_BAUDRATE,
38*7ff4d4fbSPrasad Kummari 				    &tsp_boot_console);
39*7ff4d4fbSPrasad Kummari #endif
40*7ff4d4fbSPrasad Kummari 
414c7abf85SPrasad Kummari 	if (rc == 0) {
424c7abf85SPrasad Kummari 		panic();
434c7abf85SPrasad Kummari 	}
444c7abf85SPrasad Kummari 
454c7abf85SPrasad Kummari 	console_set_scope(&tsp_boot_console,
464c7abf85SPrasad Kummari 			  CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_BOOT);
474c7abf85SPrasad Kummari }
484c7abf85SPrasad Kummari 
494c7abf85SPrasad Kummari /*******************************************************************************
504c7abf85SPrasad Kummari  * Perform platform specific setup placeholder
514c7abf85SPrasad Kummari  ******************************************************************************/
524c7abf85SPrasad Kummari void tsp_platform_setup(void)
534c7abf85SPrasad Kummari {
54*7ff4d4fbSPrasad Kummari /*
55*7ff4d4fbSPrasad Kummari  * For ZynqMP, the GICv2 driver needs to be initialized in S-EL1,
56*7ff4d4fbSPrasad Kummari  * and for other platforms, the GICv3 driver is initialized in EL3.
57*7ff4d4fbSPrasad Kummari  * This is because S-EL1 can use GIC system registers to manage
58*7ff4d4fbSPrasad Kummari  * interrupts and does not need to be initialized again in SEL1.
59*7ff4d4fbSPrasad Kummari  */
60*7ff4d4fbSPrasad Kummari #if defined(PLAT_zynqmp)
614c7abf85SPrasad Kummari 	plat_arm_gic_driver_init();
624c7abf85SPrasad Kummari 	plat_arm_gic_init();
63*7ff4d4fbSPrasad Kummari #endif
644c7abf85SPrasad Kummari }
654c7abf85SPrasad Kummari 
664c7abf85SPrasad Kummari /*******************************************************************************
674c7abf85SPrasad Kummari  * Perform the very early platform specific architectural setup here. At the
684c7abf85SPrasad Kummari  * moment this is only initializes the MMU
694c7abf85SPrasad Kummari  ******************************************************************************/
704c7abf85SPrasad Kummari void tsp_plat_arch_setup(void)
714c7abf85SPrasad Kummari {
724c7abf85SPrasad Kummari 	const mmap_region_t bl_regions[] = {
734c7abf85SPrasad Kummari 		MAP_REGION_FLAT(BL32_BASE, BL32_END - BL32_BASE,
744c7abf85SPrasad Kummari 			MT_MEMORY | MT_RW | MT_SECURE),
754c7abf85SPrasad Kummari 		MAP_REGION_FLAT(BL_CODE_BASE, BL_CODE_END - BL_CODE_BASE,
764c7abf85SPrasad Kummari 			MT_CODE | MT_SECURE),
774c7abf85SPrasad Kummari 		MAP_REGION_FLAT(BL_RO_DATA_BASE, BL_RO_DATA_END - BL_RO_DATA_BASE,
784c7abf85SPrasad Kummari 			MT_RO_DATA | MT_SECURE),
794c7abf85SPrasad Kummari 		MAP_REGION_FLAT(BL_COHERENT_RAM_BASE,
804c7abf85SPrasad Kummari 			BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
814c7abf85SPrasad Kummari 			MT_DEVICE | MT_RW | MT_SECURE),
824c7abf85SPrasad Kummari 		{0}
834c7abf85SPrasad Kummari 	};
844c7abf85SPrasad Kummari 
854c7abf85SPrasad Kummari 	setup_page_tables(bl_regions, plat_get_mmap());
864c7abf85SPrasad Kummari 	enable_mmu_el1(0);
874c7abf85SPrasad Kummari }
88