serial: goldfish: Add DEBUG_UART support
PATCH 1/1 serial: goldfish: Add DEBUG_UART support
Add debug support for the goldfish tty so it can be used for early debugging. This will be really useful when adding support for relocation etc.
--- doc/board/emulation/qemu-m68k.rst | 10 ++++++++++ drivers/serial/Kconfig | 8 ++++++++ drivers/serial/serial_goldfish.c | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+)
doc/board/emulation/qemu-m68k.rst +10 -0
@@ -31,6 +31,16 @@ The minimal QEMU command line to get U-Boot up and running is: Note that the `-nographic` option is used to redirect the console to stdio, which connects to the emulated Goldfish TTY device. +Debugging U-Boot +---------------- + +If you need early debugging output enable `CONFIG_DEBUG_UART_GOLDFISH`. +The base address for the UART can be found by activating the QEMU monitor, +running `info qtree`, and then looking for the goldfish tty device and +taking the mmio address. + +Baud rate doesn't matter. + Hardware Support ---------------- The following QEMU virt peripherals are supported in U-Boot:
drivers/serial/Kconfig +8 -0
@@ -510,6 +510,14 @@ config DEBUG_UART_XTENSA_SEMIHOSTING start up driver model. The driver will be available until the real driver model serial is running. +config DEBUG_UART_GOLDFISH + bool "Goldfish TTY" + help + Select this to enable the debug UART using the Goldfish TTY driver. + This provides basic serial output from the console without needing to + start up driver model. The driver will be available until the real + driver model serial is running. + endchoice config DEBUG_UART_BASE
drivers/serial/serial_goldfish.c +18 -0
@@ -115,3 +115,21 @@ U_BOOT_DRIVER(serial_goldfish) = { .priv_auto = sizeof(struct goldfish_tty_priv), .flags = DM_FLAG_PRE_RELOC, }; + +#ifdef CONFIG_DEBUG_UART_GOLDFISH + +#include <debug_uart.h> + +static inline void _debug_uart_init (void ) +{ +} + +static inline void _debug_uart_putc (int ch) +{ +void *base = (void *)CONFIG_DEBUG_UART_BASE ; + +__raw_writel (ch, base +GOLDFISH_TTY_PUT_CHAR ); +} + +DEBUG_UART_FUNCS +#endif
Signature · 1 line
2.51.0
Quoted 10 lines · Daniel Palmer
Add debug support for the goldfish tty so it can be used for early debugging. This will be really useful when adding support for relocation etc.
Signed-off-by Daniel Palmer <[email protected]>--- doc/board/emulation/qemu-m68k.rst | 10 ++++++++++ drivers/serial/Kconfig | 8 ++++++++ drivers/serial/serial_goldfish.c | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+)
I think we should also call debug_uart_init() in qemu-m68k.c. This way, the <debug_uart> string will be properly printed when the CONFIG_DEBUG_UART_ANNOUNCE option is enabled.
Quoted 51 lines
doc/board/emulation/qemu-m68k.rst +10
-0@@ -31,6 +31,16 @@ The minimal QEMU command line to get U-Boot up and running is: Note that the `-nographic` option is used to redirect the console to stdio, which connects to the emulated Goldfish TTY device. +Debugging U-Boot +---------------- + +If you need early debugging output enable `CONFIG_DEBUG_UART_GOLDFISH`. +The base address for the UART can be found by activating the QEMU monitor, +running `info qtree`, and then looking for the goldfish tty device and +taking the mmio address. + +Baud rate doesn't matter. + Hardware Support ---------------- The following QEMU virt peripherals are supported in U-Boot:drivers/serial/Kconfig +8
-0@@ -510,6 +510,14 @@ config DEBUG_UART_XTENSA_SEMIHOSTING start up driver model. The driver will be available until the real driver model serial is running. +config DEBUG_UART_GOLDFISH + bool "Goldfish TTY" + help + Select this to enable the debug UART using the Goldfish TTY driver. + This provides basic serial output from the console without needing to + start up driver model. The driver will be available until the real + driver model serial is running. + endchoice config DEBUG_UART_BASEdrivers/serial/serial_goldfish.c +2
-0@@ -115,3 +115,21 @@ U_BOOT_DRIVER(serial_goldfish) = { .priv_auto = sizeof(struct goldfish_tty_priv), .flags = DM_FLAG_PRE_RELOC, }; + +#ifdef CONFIG_DEBUG_UART_GOLDFISH
drivers/serial/serial_goldfish.c U_BOOT_DRIVER(serial_goldfish) = { · line 129
Quoted 10 lines
drivers/serial/serial_goldfish.c +10
-0+ +#include <debug_uart.h> + +static inline void _debug_uart_init (void ) +{ +} + +static inline void _debug_uart_putc (int ch) +{ +void *base = (void *)CONFIG_DEBUG_UART_BASE ;
It might be better to use CONFIG_VAL(DEBUG_UART_BASE) here to keep it robust for potential future SPL/TPL builds.
Also, since this is a mmio register, I think casting to void __iomem * would be more appropriate.
Regards,
Kuan-Wei
Quoted 9 lines
drivers/serial/serial_goldfish.c +6
-0+ +__raw_writel (ch, base +GOLDFISH_TTY_PUT_CHAR ); +} + +DEBUG_UART_FUNCS +#endif Signature · 1 line
2.51.0
Hi Kuan-Wei,
Quoted 3 lines · Kuan-Wei Chiu
I think we should also call
debug_uart_init()inqemu-m68k.c. This way, the <debug_uart> string will be properly printed when theCONFIG_DEBUG_UART_ANNOUNCEoption is enabled.
I looked up the other callers to debug_uart_init() and it looks like a lot of them are in the start.S for the arch.
Maybe it should be added to arch/m68k/cpu/m680x0/start.S?
Quoted 7 lines
Quoted 1 line
+ void *base = (void *)CONFIG_DEBUG_UART_BASE;
It might be better to use
CONFIG_VAL(DEBUG_UART_BASE)here to keep it robust for potential future SPL/TPL builds.Also, since this is a mmio register, I think casting to void
__iomem* would be more appropriate.
Noted. I'll fix that up.
Cheers,
Daniel
Hi all,
Quoted 7 lines · Daniel Palmer
Add debug support for the goldfish tty so it can be used for early debugging. This will be really useful when adding support for relocation etc.
Signed-off-by Daniel Palmer <[email protected]>---
I think this has been reviewed and out of other comments for long enough now? If possible can someone merge it?
Thanks,
Daniel