feat(zynqmp): add DTB console to platform.mk
In the platform.mk file, new console types named dtb are to be created
a macro, ZYNQMP_CONSOLE_ID_dtb, will be introduced to check DT console.
Users will have the option to select ZYNQMP_CONSOLE to dtb, which will
run from the DDR address. The address XILINX_OF_BOARD_DTB_ADDR needs
to be provided. This configuration will register the DT console in TF-A.
Flags for the ZynqMP platform and other AMD-Xilinx platforms will be
updated to utilize common code.
Change-Id: If74da4a80196575335c9d5562e6d8cd12d99561c
Signed-off-by: Prasad Kummari <prasad.kummari@amd.com>
Signed-off-by: Maheedhar Bollapalli <MaheedharSai.Bollapalli@amd.com>
diff --git a/plat/xilinx/common/plat_console.c b/plat/xilinx/common/plat_console.c
index 72fd881..f253534 100644
--- a/plat/xilinx/common/plat_console.c
+++ b/plat/xilinx/common/plat_console.c
@@ -25,8 +25,9 @@
static console_t boot_console;
-#if (defined(XILINX_OF_BOARD_DTB_ADDR) && !IS_TFA_IN_OCM(BL31_BASE)) || \
- defined(CONSOLE_RUNTIME)
+#if (CONSOLE_IS(dtb) && defined(XILINX_OF_BOARD_DTB_ADDR)) && \
+ (!defined(PLAT_zynqmp) || (defined(PLAT_zynqmp) && \
+ !IS_TFA_IN_OCM(BL31_BASE))) || defined(CONSOLE_RUNTIME)
/**
* register_console() - Registers the runtime uart with console list.
* @uart_base: UART base address
@@ -67,8 +68,10 @@
}
#endif
-#if (defined(XILINX_OF_BOARD_DTB_ADDR) && !IS_TFA_IN_OCM(BL31_BASE))
+#if (CONSOLE_IS(dtb) && defined(XILINX_OF_BOARD_DTB_ADDR)) && \
+ (!defined(PLAT_zynqmp) || (defined(PLAT_zynqmp) && \
+ !IS_TFA_IN_OCM(BL31_BASE)))
static console_t dt_console;
/**
* get_baudrate() - Get the baudrate form DTB.
@@ -202,21 +205,18 @@
ret = is_valid_dtb(dtb);
if (ret < 0) {
ERROR("Invalid Device Tree at %p: error %d\n", dtb, ret);
- ret = -FDT_ERR_NOTFOUND;
goto error;
}
node = fdt_get_stdout_node_offset(dtb);
if (node < 0) {
ERROR("DT get stdout node failed : %d\n", node);
- ret = -FDT_ERR_NOTFOUND;
goto error;
}
ret = fdt_add_uart_info(info, node, dtb);
if (ret < 0) {
ERROR("Failed to add DT UART info: %d\n", ret);
- ret = -FDT_ERR_NOTFOUND;
goto error;
}
@@ -366,9 +366,10 @@
static console_t runtime_console;
uintptr_t rt_uart_base = 0;
uint32_t buad_rate = 0;
- static dt_uart_info_t dt_info = {0};
-#if (defined(XILINX_OF_BOARD_DTB_ADDR) && !IS_TFA_IN_OCM(BL31_BASE))
+#if (CONSOLE_IS(dtb) && defined(XILINX_OF_BOARD_DTB_ADDR)) && \
+ (!defined(PLAT_zynqmp) || (defined(PLAT_zynqmp) && \
+ !IS_TFA_IN_OCM(BL31_BASE)))
console_t *console = &dt_console;
#else
console_t *console = &boot_console;
@@ -377,6 +378,7 @@
#if (RT_CONSOLE_IS(dtb) && defined(XILINX_OF_BOARD_DTB_ADDR)) && \
(!defined(PLAT_zynqmp) || (defined(PLAT_zynqmp) && \
!IS_TFA_IN_OCM(BL31_BASE)))
+ static dt_uart_info_t dt_info = {0};
uint32_t rc = parse_uart_info(&dt_info);
if (rc < 0) {
@@ -422,6 +424,21 @@
int32_t rc;
uint32_t uart_clk = get_uart_clk();
+#if (CONSOLE_IS(dtb) && defined(XILINX_OF_BOARD_DTB_ADDR)) && \
+ (!defined(PLAT_zynqmp) || (defined(PLAT_zynqmp) && \
+ !IS_TFA_IN_OCM(BL31_BASE)))
+
+ static dt_uart_info_t uart_info = {0};
+
+ /* Initialize the DTB console using UART information from the DTB */
+ rc = dt_console_init(&uart_info, &boot_console, uart_clk);
+ if (rc < 0) {
+ ERROR("Failed to initialize DT console: %d\n", rc);
+ } else {
+ goto cnslsetup;
+ }
+#endif
+
#if defined(PLAT_zynqmp)
if (CONSOLE_IS(cadence) || (CONSOLE_IS(cadence1))) {
rc = console_cdns_register(UART_BASE,
@@ -457,15 +474,11 @@
panic();
}
}
- INFO("BL31: Early console setup\n");
-#if (defined(XILINX_OF_BOARD_DTB_ADDR) && !IS_TFA_IN_OCM(BL31_BASE))
- static dt_uart_info_t uart_info = {0};
-
- /* Initialize the DTB console using UART information from the DTB */
- rc = dt_console_init(&uart_info, &boot_console, uart_clk);
- if (rc < 0) {
- ERROR("Failed to initialize DT console: %d\n", rc);
- }
+#if (CONSOLE_IS(dtb) && defined(XILINX_OF_BOARD_DTB_ADDR)) && \
+ (!defined(PLAT_zynqmp) || (defined(PLAT_zynqmp) && \
+ !IS_TFA_IN_OCM(BL31_BASE)))
+cnslsetup:
#endif
+ INFO("BL31: Early console setup\n");
}
diff --git a/plat/xilinx/zynqmp/include/zynqmp_def.h b/plat/xilinx/zynqmp/include/zynqmp_def.h
index ef72c2c..1144534 100644
--- a/plat/xilinx/zynqmp/include/zynqmp_def.h
+++ b/plat/xilinx/zynqmp/include/zynqmp_def.h
@@ -14,6 +14,7 @@
#define ZYNQMP_CONSOLE_ID_cadence0 1
#define ZYNQMP_CONSOLE_ID_cadence1 2
#define ZYNQMP_CONSOLE_ID_dcc 3
+#define ZYNQMP_CONSOLE_ID_dtb 4
#define CONSOLE_IS(con) (ZYNQMP_CONSOLE_ID_ ## con == ZYNQMP_CONSOLE)
@@ -153,7 +154,8 @@
#define ZYNQMP_UART0_BASE U(0xFF000000)
#define ZYNQMP_UART1_BASE U(0xFF010000)
-#if CONSOLE_IS(cadence) || CONSOLE_IS(dcc)
+/* Boot console */
+#if CONSOLE_IS(cadence) || CONSOLE_IS(dcc) || CONSOLE_IS(dtb)
# define UART_BASE ZYNQMP_UART0_BASE
#elif CONSOLE_IS(cadence1)
# define UART_BASE ZYNQMP_UART1_BASE
diff --git a/plat/xilinx/zynqmp/platform.mk b/plat/xilinx/zynqmp/platform.mk
index 92c9d1f..d6ad49c 100644
--- a/plat/xilinx/zynqmp/platform.mk
+++ b/plat/xilinx/zynqmp/platform.mk
@@ -111,7 +111,7 @@
${XLAT_TABLES_LIB_SRCS}
ZYNQMP_CONSOLE ?= cadence
-ifeq (${ZYNQMP_CONSOLE}, $(filter ${ZYNQMP_CONSOLE},cadence cadence0 cadence1 dcc))
+ifeq (${ZYNQMP_CONSOLE}, $(filter ${ZYNQMP_CONSOLE},cadence cadence0 cadence1 dcc dtb))
else
$(error "Please define ZYNQMP_CONSOLE")
endif