Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/33735
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
mb/emulation/qemu-riscv: Use generic 8250 uart driver
Drop hacked uart code and use the generic 8250 uart driver for ns16550a.
Tested on qemu-system-riscv64: * The UART is still working.
Change-Id: I6efda913fa39e0cfa466b52c570572aca90dacdf Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com --- M src/mainboard/emulation/qemu-riscv/Kconfig M src/mainboard/emulation/qemu-riscv/uart.c 2 files changed, 2 insertions(+), 35 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/35/33735/1
diff --git a/src/mainboard/emulation/qemu-riscv/Kconfig b/src/mainboard/emulation/qemu-riscv/Kconfig index d15c99e..f0f658d 100644 --- a/src/mainboard/emulation/qemu-riscv/Kconfig +++ b/src/mainboard/emulation/qemu-riscv/Kconfig @@ -37,9 +37,9 @@ def_bool y select SOC_UCB_RISCV select BOARD_ROMSIZE_KB_4096 - select HAVE_UART_SPECIAL select BOOT_DEVICE_NOT_SPI_FLASH select MISSING_BOARD_RESET + select DRIVERS_UART_8250MEM
config MAINBOARD_DIR string diff --git a/src/mainboard/emulation/qemu-riscv/uart.c b/src/mainboard/emulation/qemu-riscv/uart.c index 021713a..271e994 100644 --- a/src/mainboard/emulation/qemu-riscv/uart.c +++ b/src/mainboard/emulation/qemu-riscv/uart.c @@ -15,42 +15,9 @@
#include <types.h> #include <console/uart.h> -#include <boot/coreboot_tables.h> #include <mainboard/addressmap.h>
-static uint8_t *buf = (void *)QEMU_VIRT_UART0; uintptr_t uart_platform_base(int idx) { - return (uintptr_t) buf; + return (uintptr_t) QEMU_VIRT_UART0; } - -void uart_init(int idx) -{ -} - -unsigned char uart_rx_byte(int idx) -{ - return *buf; -} - -void uart_tx_byte(int idx, unsigned char data) -{ - *buf = data; -} - -void uart_tx_flush(int idx) -{ -} - -#ifndef __PRE_RAM__ -void uart_fill_lb(void *data) -{ - struct lb_serial serial; - serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; - serial.baseaddr = QEMU_VIRT_UART0; - serial.baud = 115200; - serial.regwidth = 1; - lb_add_serial(&serial, data); - lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); -} -#endif
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33735 )
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
Patch Set 1:
The change brings in dependency of udelay(), so printk() before mtime_init() in riscv/mcall.c:hls_init() is wrong. It's BIOS_SPEW and UART code may never actually reach the udelay(), but there's a possible die() there in the path for this case.
Looking into riscv/arch_timer.c:timer_monotonic_get(), HLS()->time seems uninitialized and probably does not reference the intended hardware register SIFIVE_TIME_BASE (yet). Also, I see SIFIVE_CLINT_TIMEBASE_FREQ 10+E6 in QEMU, assuming 10 MHz or 1/10 us per tick.
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33735 )
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
Patch Set 2:
Patch Set 1:
The change brings in dependency of udelay(), so printk() before mtime_init() in riscv/mcall.c:hls_init() is wrong. It's BIOS_SPEW and UART code may never actually reach the udelay(), but there's a possible die() there in the path for this case.
Looking into riscv/arch_timer.c:timer_monotonic_get(), HLS()->time seems uninitialized and probably does not reference the intended hardware register SIFIVE_TIME_BASE (yet). Also, I see SIFIVE_CLINT_TIMEBASE_FREQ 10+E6 in QEMU, assuming 10 MHz or 1/10 us per tick.
Dropped debug code in a separate commit (https://review.coreboot.org/c/coreboot/+/33786). It has no effect anyway as console_init() hasn't been called yet.
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33735 )
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
Patch Set 2: Code-Review+1
Please check if the monotonic timer rate commented earlier is correct. (Unrelated, but I'll defer my +2 here due to that).
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33735 )
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
Patch Set 2: Code-Review+2
Philipp Hug has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33735 )
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
Patch Set 2: Code-Review+2
Thanks
Patrick Rudolph has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/33735 )
Change subject: mb/emulation/qemu-riscv: Use generic 8250 uart driver ......................................................................
mb/emulation/qemu-riscv: Use generic 8250 uart driver
Drop hacked uart code and use the generic 8250 uart driver for ns16550a.
Tested on qemu-system-riscv64: * The UART is still working.
Change-Id: I6efda913fa39e0cfa466b52c570572aca90dacdf Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/33735 Reviewed-by: Kyösti Mälkki kyosti.malkki@gmail.com Reviewed-by: Philipp Hug philipp@hug.cx Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/mainboard/emulation/qemu-riscv/Kconfig M src/mainboard/emulation/qemu-riscv/uart.c 2 files changed, 2 insertions(+), 35 deletions(-)
Approvals: build bot (Jenkins): Verified Kyösti Mälkki: Looks good to me, approved Philipp Hug: Looks good to me, approved
diff --git a/src/mainboard/emulation/qemu-riscv/Kconfig b/src/mainboard/emulation/qemu-riscv/Kconfig index d15c99e..f0f658d 100644 --- a/src/mainboard/emulation/qemu-riscv/Kconfig +++ b/src/mainboard/emulation/qemu-riscv/Kconfig @@ -37,9 +37,9 @@ def_bool y select SOC_UCB_RISCV select BOARD_ROMSIZE_KB_4096 - select HAVE_UART_SPECIAL select BOOT_DEVICE_NOT_SPI_FLASH select MISSING_BOARD_RESET + select DRIVERS_UART_8250MEM
config MAINBOARD_DIR string diff --git a/src/mainboard/emulation/qemu-riscv/uart.c b/src/mainboard/emulation/qemu-riscv/uart.c index 021713a..271e994 100644 --- a/src/mainboard/emulation/qemu-riscv/uart.c +++ b/src/mainboard/emulation/qemu-riscv/uart.c @@ -15,42 +15,9 @@
#include <types.h> #include <console/uart.h> -#include <boot/coreboot_tables.h> #include <mainboard/addressmap.h>
-static uint8_t *buf = (void *)QEMU_VIRT_UART0; uintptr_t uart_platform_base(int idx) { - return (uintptr_t) buf; + return (uintptr_t) QEMU_VIRT_UART0; } - -void uart_init(int idx) -{ -} - -unsigned char uart_rx_byte(int idx) -{ - return *buf; -} - -void uart_tx_byte(int idx, unsigned char data) -{ - *buf = data; -} - -void uart_tx_flush(int idx) -{ -} - -#ifndef __PRE_RAM__ -void uart_fill_lb(void *data) -{ - struct lb_serial serial; - serial.type = LB_SERIAL_TYPE_MEMORY_MAPPED; - serial.baseaddr = QEMU_VIRT_UART0; - serial.baud = 115200; - serial.regwidth = 1; - lb_add_serial(&serial, data); - lb_add_console(LB_TAG_CONSOLE_SERIAL8250MEM, data); -} -#endif