feat(versal2): add dtb & runtime console

Modified platform.mk and  bl31_setup to
invoke setup_console and runtime_console
to support dtb console parsing and runtime.

Change-Id: I68c2fffd90e38274cfad4f85dd51c722fae0ee89
Signed-off-by: Maheedhar Bollapalli <MaheedharSai.Bollapalli@amd.com>
This commit is contained in:
Maheedhar Bollapalli 2024-07-01 07:07:53 +00:00 committed by Maheedhar Bollapalli
parent d61ba95eec
commit 11964742d6
3 changed files with 68 additions and 39 deletions

View file

@ -20,6 +20,7 @@
#include <lib/xlat_tables/xlat_tables_v2.h>
#include <plat/common/platform.h>
#include <plat_arm.h>
#include <plat_console.h>
#include <scmi.h>
#include <def.h>
@ -75,8 +76,6 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3)
{
uint32_t uart_clock;
int32_t rc;
static console_t _runtime_console;
board_detection();
@ -122,29 +121,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
uart_clock = get_uart_clk();
if (CONSOLE_IS(pl011_0) || CONSOLE_IS(pl011_1)) {
/* Initialize the console to provide early debug support */
rc = console_pl011_register(UART_BASE, uart_clock,
UART_BAUDRATE,
&_runtime_console);
if (rc == 0) {
panic();
}
console_set_scope(&_runtime_console, CONSOLE_FLAG_BOOT |
CONSOLE_FLAG_RUNTIME | CONSOLE_FLAG_CRASH);
} else if (CONSOLE_IS(dcc)) {
/* Initialize the dcc console for debug.
* dcc is over jtag and does not configures uart0 or uart1.
*/
rc = console_dcc_register(&_runtime_console);
if (rc == 0) {
panic();
}
} else {
/* Making MISRA C 2012 15.7 compliant */
}
setup_console();
NOTICE("TF-A running on %s %d.%d\n", board_name_decode(),
platform_version / 10U, platform_version % 10U);
@ -249,6 +226,8 @@ void bl31_plat_runtime_setup(void)
if (rc != 0) {
panic();
}
console_switch_state(CONSOLE_FLAG_RUNTIME);
}
/*

View file

@ -15,12 +15,22 @@
#define MAX_INTR_EL3 2
/* List all consoles */
#define CONSOLE_ID_pl011 U(1)
#define CONSOLE_ID_pl011_0 U(1)
#define CONSOLE_ID_pl011_1 U(2)
#define CONSOLE_ID_dcc U(3)
#define VERSAL2_CONSOLE_ID_pl011 1
#define VERSAL2_CONSOLE_ID_pl011_0 1
#define VERSAL2_CONSOLE_ID_pl011_1 2
#define VERSAL2_CONSOLE_ID_dcc 3
#define VERSAL2_CONSOLE_ID_dtb 4
#define CONSOLE_IS(con) (CONSOLE_ID_ ## con == CONSOLE)
#define CONSOLE_IS(con) (VERSAL2_CONSOLE_ID_ ## con == VERSAL2_CONSOLE)
/* Runtime console */
#define RT_CONSOLE_ID_pl011 1
#define RT_CONSOLE_ID_pl011_0 1
#define RT_CONSOLE_ID_pl011_1 2
#define RT_CONSOLE_ID_dcc 3
#define RT_CONSOLE_ID_dtb 4
#define RT_CONSOLE_IS(con) (RT_CONSOLE_ID_ ## con == CONSOLE_RUNTIME)
/* List all platforms */
#define SILICON U(0)
@ -143,11 +153,33 @@
#define UART_BAUDRATE 115200
#if CONSOLE_IS(pl011_1)
#define UART_BASE UART1_BASE
#if CONSOLE_IS(pl011) || CONSOLE_IS(dtb)
#define UART_BASE UART0_BASE
# define UART_TYPE CONSOLE_PL011
#elif CONSOLE_IS(pl011_1)
#define UART_BASE UART1_BASE
# define UART_TYPE CONSOLE_PL011
#elif CONSOLE_IS(dcc)
# define UART_BASE 0x0
# define UART_TYPE CONSOLE_DCC
#else
/* Default console is UART0 */
#define UART_BASE UART0_BASE
# error "invalid VERSAL2_CONSOLE"
#endif
/* Runtime console */
#if defined(CONSOLE_RUNTIME)
#if RT_CONSOLE_IS(pl011) || RT_CONSOLE_IS(dtb)
# define RT_UART_BASE UART0_BASE
# define RT_UART_TYPE CONSOLE_PL011
#elif RT_CONSOLE_IS(pl011_1)
# define RT_UART_BASE UART1_BASE
# define RT_UART_TYPE CONSOLE_PL011
#elif RT_CONSOLE_IS(dcc)
# define RT_UART_BASE 0x0
# define RT_UART_TYPE CONSOLE_DCC
#else
# error "invalid CONSOLE_RUNTIME"
#endif
#endif
#endif /* DEF_H */

View file

@ -57,13 +57,28 @@ endif
USE_COHERENT_MEM := 0
HW_ASSISTED_COHERENCY := 1
CONSOLE ?= pl011
ifeq (${CONSOLE}, $(filter ${CONSOLE},pl011 pl011_0 pl011_1 dcc))
else
$(error Please define CONSOLE)
VERSAL2_CONSOLE ?= pl011
ifeq (${VERSAL2_CONSOLE}, $(filter ${VERSAL2_CONSOLE},pl011 pl011_0 pl011_1 dcc dtb))
else
$(error "Please define VERSAL2_CONSOLE")
endif
$(eval $(call add_define_val,VERSAL2_CONSOLE,VERSAL2_CONSOLE_ID_${VERSAL2_CONSOLE}))
# Runtime console in default console in DEBUG build
ifeq ($(DEBUG), 1)
CONSOLE_RUNTIME ?= pl011
endif
# Runtime console
ifdef CONSOLE_RUNTIME
ifeq (${CONSOLE_RUNTIME}, $(filter ${CONSOLE_RUNTIME},pl011 pl011_0 pl011_1 dcc dtb))
$(eval $(call add_define_val,CONSOLE_RUNTIME,RT_CONSOLE_ID_${CONSOLE_RUNTIME}))
else
$(error "Please define CONSOLE_RUNTIME")
endif
endif
$(eval $(call add_define_val,CONSOLE,CONSOLE_ID_${CONSOLE}))
ifdef XILINX_OF_BOARD_DTB_ADDR
$(eval $(call add_define,XILINX_OF_BOARD_DTB_ADDR))
@ -109,6 +124,9 @@ BL31_SOURCES += drivers/arm/cci/cci.c \
BL31_SOURCES += ${PLAT_PATH}/plat_psci.c
BL31_SOURCES += plat/xilinx/common/plat_fdt.c \
common/fdt_wrappers.c \
plat/xilinx/common/plat_fdt.c \
plat/xilinx/common/plat_console.c \
plat/xilinx/common/plat_startup.c \
plat/xilinx/common/ipi.c \
plat/xilinx/common/ipi_mailbox_service/ipi_mailbox_svc.c \