summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2020-04-09 10:25:43 +0100
committerAndre Przywara <andre.przywara@arm.com>2020-05-05 15:36:51 +0100
commitdee3042cd6cfcd7b6995260a944d741bb93adce0 (patch)
tree68fa4ead88405702f487c8c9ff908c5762e69267
parent1a0f9366d82f7e9fac96a29bd38c78828044a147 (diff)
downloadarm-trusted-firmware-dee3042cd6cfcd7b6995260a944d741bb93adce0.tar.gz
arm_fpga: Read UART address from DT
The arm_fpga port requires a DTB, to launch a BL33 payload. To make this port more flexible, we can also use the information in the DT to configure the console driver. For a start, find the DT node pointed to by the stdout-path property, and read the base address from there. This assumes for now that the stdout-path points to a PL011 UART. This allows to remove platform specific addresses from the image. We keep the original base address for the crash console. Change-Id: I46a990de2315f81cae4d7913ae99a07b0bec5cb1 Signed-off-by: Andre Przywara <andre.przywara@arm.com>
-rw-r--r--plat/arm/board/arm_fpga/fpga_console.c23
-rw-r--r--plat/arm/board/arm_fpga/fpga_def.h8
2 files changed, 25 insertions, 6 deletions
diff --git a/plat/arm/board/arm_fpga/fpga_console.c b/plat/arm/board/arm_fpga/fpga_console.c
index a1fdb7832..8c1da62e2 100644
--- a/plat/arm/board/arm_fpga/fpga_console.c
+++ b/plat/arm/board/arm_fpga/fpga_console.c
@@ -4,8 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <drivers/console.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <common/fdt_wrappers.h>
#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
#include <platform_def.h>
@@ -13,8 +17,21 @@ static console_t console;
void fpga_console_init(void)
{
- (void)console_pl011_register(PLAT_FPGA_BOOT_UART_BASE, 0, 0,
- &console);
+ const void *fdt = (void *)(uintptr_t)FPGA_PRELOADED_DTB_BASE;
+ uintptr_t base_addr = PLAT_FPGA_CRASH_UART_BASE;
+ int node;
+
+ /*
+ * Try to read the UART base address from the DT, by chasing the
+ * stdout-path property of the chosen node.
+ * If this does not work, use the crash console address as a fallback.
+ */
+ node = fdt_get_stdout_node_offset(fdt);
+ if (node >= 0) {
+ fdt_get_reg_props_by_index(fdt, node, 0, &base_addr, NULL);
+ }
+
+ (void)console_pl011_register(base_addr, 0, 0, &console);
console_set_scope(&console, CONSOLE_FLAG_BOOT |
CONSOLE_FLAG_RUNTIME);
diff --git a/plat/arm/board/arm_fpga/fpga_def.h b/plat/arm/board/arm_fpga/fpga_def.h
index 0bb2b22e0..03787293c 100644
--- a/plat/arm/board/arm_fpga/fpga_def.h
+++ b/plat/arm/board/arm_fpga/fpga_def.h
@@ -27,9 +27,11 @@
* FPGA image memory map related constants
******************************************************************************/
-/* UART base address, as configured by the image */
-#define PLAT_FPGA_BOOT_UART_BASE 0x7ff80000
-#define PLAT_FPGA_CRASH_UART_BASE PLAT_FPGA_BOOT_UART_BASE
+/*
+ * UART base address, just for the crash console, as a fallback.
+ * The actual console UART address is taken from the DT.
+ */
+#define PLAT_FPGA_CRASH_UART_BASE 0x7ff80000
#define FPGA_DEFAULT_TIMER_FREQUENCY 10000000