From 499e9137526648f72373cce873633b407393071d Mon Sep 17 00:00:00 2001 From: Bradley Morgan Date: Sun, 4 Oct 2026 06:15:45 +0000 Subject: tashaboot: console base from the devicetree The uart address was the last board hardcode. The console probe now walks the dtb for the pl011 node and reads its first reg pair before the first print, the same walker the gic lookup uses. The qemu default remains as the dev path fallback for a tree without the node. receipt: banner and every print on the dtb base, full boot to the busybox shell, four cpus. --- common/console.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'common/console.c') diff --git a/common/console.c b/common/console.c index bdd24c1..64e5128 100644 --- a/common/console.c +++ b/common/console.c @@ -54,14 +54,23 @@ #define UART_IBRD_VAL 13 #define UART_FBRD_VAL 44 -#define PL011_BASE 0x09000000UL +/* the base comes from the devicetree walk, the qemu default + * only covers the dev path before the walk runs + */ +static uintptr_t pl011_base = 0x09000000UL; + +void tb_console_set_pl011(uintptr_t base) +{ + if (base) + pl011_base = base; +} static int console_uart_ok; static void uart_putc(char c) { - volatile uint32_t *fr = (volatile uint32_t *)(PL011_BASE + UART_FR); - volatile uint32_t *dr = (volatile uint32_t *)(PL011_BASE + UART_DR); + volatile uint32_t *fr = (volatile uint32_t *)(pl011_base + UART_FR); + volatile uint32_t *dr = (volatile uint32_t *)(pl011_base + UART_DR); /* TXFF can happen mid line on slow consoles, wait it out */ while (*fr & UART_FR_TXFF) @@ -77,12 +86,12 @@ static void uart_putc(char c) */ static int uart_init(void) { - volatile uint32_t *cr = (volatile uint32_t *)(PL011_BASE + UART_CR); - volatile uint32_t *ibrd = (volatile uint32_t *)(PL011_BASE + UART_IBRD); - volatile uint32_t *fbrd = (volatile uint32_t *)(PL011_BASE + UART_FBRD); - volatile uint32_t *lcrh = (volatile uint32_t *)(PL011_BASE + UART_LCRH); - volatile uint32_t *imsc = (volatile uint32_t *)(PL011_BASE + UART_IMSC); - volatile uint32_t *icr = (volatile uint32_t *)(PL011_BASE + UART_ICR); + volatile uint32_t *cr = (volatile uint32_t *)(pl011_base + UART_CR); + volatile uint32_t *ibrd = (volatile uint32_t *)(pl011_base + UART_IBRD); + volatile uint32_t *fbrd = (volatile uint32_t *)(pl011_base + UART_FBRD); + volatile uint32_t *lcrh = (volatile uint32_t *)(pl011_base + UART_LCRH); + volatile uint32_t *imsc = (volatile uint32_t *)(pl011_base + UART_IMSC); + volatile uint32_t *icr = (volatile uint32_t *)(pl011_base + UART_ICR); /* disable, mask irq, clear pending, divisors, fifo, enable tx */ *cr = 0; @@ -95,7 +104,7 @@ static int uart_init(void) /* self test write, TXFF clearing means the uart answers */ uart_putc('\0'); - while (*(volatile uint32_t *)(PL011_BASE + UART_FR) & UART_FR_BUSY) + while (*(volatile uint32_t *)(pl011_base + UART_FR) & UART_FR_BUSY) ; return 0; -- cgit v1.2.3