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@xxxxxx> --- arch/riscv/boot/board-dt-2nd.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/arch/riscv/boot/board-dt-2nd.c b/arch/riscv/boot/board-dt-2nd.c index be28ea23cd6d..e9810f8add97 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); -- 2.30.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox