summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2021-04-10 13:06:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-05-03 13:58:52 +0200
commitb1c7e757443508a7e5e91df29c4d9b6275c38973 (patch)
tree7660f9a387bd4d5a3ba31bb52390642bb0760477
parent6a1a4c73923f41d83249ca6271beb682a931b848 (diff)
downloadbarebox-b1c7e757443508a7e5e91df29c4d9b6275c38973.tar.gz
barebox-b1c7e757443508a7e5e91df29c4d9b6275c38973.tar.xz
RISC-V: board-dt-2nd: add PBL console support for virt
The Virt machine has a ns16550a UART at address 0x10000000. As we reuse the generic DT image for this platform, we can't use either DEBUG_LL or pbl_console as we would need to hardcode information on what UART is available where, which wouldn't be correct for other boards. However, if we parse the board compatible, we could match it with the appropriate PBL console implementation without sacrificing portability. Do so. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20210410110638.2106658-3-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/riscv/boot/board-dt-2nd.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/arch/riscv/boot/board-dt-2nd.c b/arch/riscv/boot/board-dt-2nd.c
index be28ea23cd..e9810f8add 100644
--- a/arch/riscv/boot/board-dt-2nd.c
+++ b/arch/riscv/boot/board-dt-2nd.c
@@ -3,7 +3,7 @@
#include <common.h>
#include <asm/sections.h>
#include <linux/sizes.h>
-#include <debug_ll.h>
+#include <asm/ns16550.h>
#include <pbl.h>
#include <fdt.h>
@@ -22,10 +22,29 @@
#include <asm/barebox-riscv.h>
+static void virt_ns16550_putc(void *base, int ch)
+{
+ early_ns16550_putc(ch, base, 0, readb, writeb);
+}
+
+static void virt_ns16550_init(void)
+{
+ void __iomem *base = IOMEM(0x10000000);
+
+ early_ns16550_init(base, 3686400 / CONFIG_BAUDRATE, 0, writeb);
+ pbl_set_putc(virt_ns16550_putc, base);
+}
+
+static const struct fdt_device_id console_ids[] = {
+ { .compatible = "riscv-virtio", .data = virt_ns16550_init },
+ { /* sentinel */ }
+};
+
ENTRY_FUNCTION(start_dt_2nd, a0, _fdt, a2)
{
unsigned long membase, memsize, endmem, endfdt, uncompressed_len;
struct fdt_header *fdt = (void *)_fdt;
+ void (*pbl_uart_init)(void);
if (!fdt)
hang();
@@ -33,6 +52,12 @@ ENTRY_FUNCTION(start_dt_2nd, a0, _fdt, a2)
relocate_to_current_adr();
setup_c();
+ pbl_uart_init = fdt_device_get_match_data(fdt, "/", console_ids);
+ if (pbl_uart_init) {
+ pbl_uart_init();
+ putchar('>');
+ }
+
fdt_find_mem(fdt, &membase, &memsize);
endmem = membase + memsize;
endfdt = _fdt + be32_to_cpu(fdt->totalsize);