xref: /rk3399_ARM-atf/plat/xilinx/common/tsp/tsp_plat_setup.c (revision 639b3676cc30dcf3e3e4d478906e7f7f37a7f1e4)
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>
107ff4d4fbSPrasad 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 
297ff4d4fbSPrasad 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);
347ff4d4fbSPrasad Kummari #else
357ff4d4fbSPrasad Kummari 	rc = console_pl011_register((uintptr_t)UART_BASE,
367ff4d4fbSPrasad Kummari 				    (uint32_t)get_uart_clk(),
377ff4d4fbSPrasad Kummari 				    (uint32_t)UART_BAUDRATE,
387ff4d4fbSPrasad Kummari 				    &tsp_boot_console);
397ff4d4fbSPrasad Kummari #endif
407ff4d4fbSPrasad 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 {
547ff4d4fbSPrasad Kummari /*
557ff4d4fbSPrasad Kummari  * For ZynqMP, the GICv2 driver needs to be initialized in S-EL1,
567ff4d4fbSPrasad Kummari  * and for other platforms, the GICv3 driver is initialized in EL3.
577ff4d4fbSPrasad Kummari  * This is because S-EL1 can use GIC system registers to manage
587ff4d4fbSPrasad Kummari  * interrupts and does not need to be initialized again in SEL1.
597ff4d4fbSPrasad Kummari  */
607ff4d4fbSPrasad Kummari #if defined(PLAT_zynqmp)
614c7abf85SPrasad Kummari 	plat_arm_gic_driver_init();
624c7abf85SPrasad Kummari 	plat_arm_gic_init();
637ff4d4fbSPrasad 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),
79*639b3676SPrasad Kummari #if defined(PLAT_zynqmp) || defined(PLAT_versal)
804c7abf85SPrasad Kummari 		MAP_REGION_FLAT(BL_COHERENT_RAM_BASE,
814c7abf85SPrasad Kummari 			BL_COHERENT_RAM_END - BL_COHERENT_RAM_BASE,
824c7abf85SPrasad Kummari 			MT_DEVICE | MT_RW | MT_SECURE),
83*639b3676SPrasad Kummari #endif
844c7abf85SPrasad Kummari 		{0}
854c7abf85SPrasad Kummari 	};
864c7abf85SPrasad Kummari 
874c7abf85SPrasad Kummari 	setup_page_tables(bl_regions, plat_get_mmap());
884c7abf85SPrasad Kummari 	enable_mmu_el1(0);
894c7abf85SPrasad Kummari }
90