All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: Daniel Palmer <daniel@0x0f.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH] serial: goldfish: Add DEBUG_UART support
Date: Mon, 9 Mar 2026 17:10:26 +0800	[thread overview]
Message-ID: <aa6OgiIKC2Z6Hwv0@google.com> (raw)
In-Reply-To: <20260309023234.640209-1-daniel@0x0f.com>

On Mon, Mar 09, 2026 at 11:32:34AM +0900, Daniel Palmer wrote:
> 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 <daniel@0x0f.com>
> ---
>  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.

> 
> diff --git a/doc/board/emulation/qemu-m68k.rst b/doc/board/emulation/qemu-m68k.rst
> index 6c4de54cf6a8..2f2e6bd6444a 100644
> --- a/doc/board/emulation/qemu-m68k.rst
> +++ b/doc/board/emulation/qemu-m68k.rst
> @@ -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:
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index b84cb9ec781d..f6a696e6c94c 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -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
> diff --git a/drivers/serial/serial_goldfish.c b/drivers/serial/serial_goldfish.c
> index 4ac2cfb62315..58c494918786 100644
> --- a/drivers/serial/serial_goldfish.c
> +++ b/drivers/serial/serial_goldfish.c
> @@ -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;

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

> +
> +	__raw_writel(ch, base + GOLDFISH_TTY_PUT_CHAR);
> +}
> +
> +DEBUG_UART_FUNCS
> +#endif
> -- 
> 2.51.0
> 

  reply	other threads:[~2026-03-09 13:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-09  2:32 [PATCH] serial: goldfish: Add DEBUG_UART support Daniel Palmer
2026-03-09  9:10 ` Kuan-Wei Chiu [this message]
2026-03-09  9:54   ` Daniel Palmer
2026-04-12  1:03 ` Daniel Palmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aa6OgiIKC2Z6Hwv0@google.com \
    --to=visitorckw@gmail.com \
    --cc=daniel@0x0f.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.