Skip to contentSkip to conversation

serial: goldfish: Add debug uart support

PATCH In review Daniel Palmer 4 participants 10 messages Mar 9 – Apr 15 m68k architecture

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 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 to the m68k qemu virt machine.

---
 drivers/serial/Kconfig           |  8 ++++++++
 drivers/serial/serial_goldfish.c | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)
drivers/serial/Kconfig +8 -0
index b84cb9ec781d..f6a696e6c94c 100644
@@ -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
index 4ac2cfb62315..91dc040fcf26 100644
@@ -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 __iomem *base = (void __iomem *)CONFIG_VAL(DEBUG_UART_BASE);
+
+	__raw_writel(ch, base + GOLDFISH_TTY_PUT_CHAR);
+}
+
+DEBUG_UART_FUNCS
+#endif
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 2/3 m68k: m680x0: Initialise the debug uart

Once the stack is ready we can init the debug uart to help with debugging so do that.

---
 arch/m68k/cpu/m680x0/start.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/m68k/cpu/m680x0/start.S +5 -0
index 0802ca1fca2c..fdfcd66f7785 100644
@@ -42,6 +42,11 @@ ENTRY(_start)
 	/* Setup initial stack pointer */
 	move.l	#CFG_SYS_INIT_SP_ADDR, %sp
 
+	/* Setup the debug uart if enabled */
+#ifdef CONFIG_DEBUG_UART
+	bsr.l	debug_uart_init
+#endif
+
 	/*
 	 * Allocate Global Data (GD)
 	 * board_init_f_alloc_reserve(top) returns the new top of stack in %d0
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v2 2/3] m68k: m680x0: Initialise the debug uart

+Cc Angelo since this touches arch/m68k/

Quoted 27 lines · Daniel Palmer

Once the stack is ready we can init the debug uart to help with debugging so do that.

---
 arch/m68k/cpu/m680x0/start.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/m68k/cpu/m680x0/start.S +5 -0
index 0802ca1fca2c..fdfcd66f7785 100644
@@ -42,6 +42,11 @@ ENTRY(_start)
 	/* Setup initial stack pointer */
 	move.l	#CFG_SYS_INIT_SP_ADDR, %sp
 
+	/* Setup the debug uart if enabled */
+#ifdef CONFIG_DEBUG_UART
+	bsr.l	debug_uart_init
+#endif
+
 	/*
 	 * Allocate Global Data (GD)
 	 * board_init_f_alloc_reserve(top) returns the new top of stack in %d0
Signature · 1 line
2.51.0
#3 lore raw

Re: [PATCH v2 2/3] m68k: m680x0: Initialise the debug uart

Quoted 19 lines · Kuan-Wei Chiu

+Cc Angelo since this touches arch/m68k/

Quoted 16 lines · Daniel Palmer

Once the stack is ready we can init the debug uart to help with debugging so do that.

---
 arch/m68k/cpu/m680x0/start.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/m68k/cpu/m680x0/start.S +0 -0
index 0802ca1fca2c..fdfcd66f7785 100644
@@ -42,6 +42,11 @@ ENTRY(_start)
 	/* Setup initial stack pointer */
 	move.l	#CFG_SYS_INIT_SP_ADDR, %sp
 
Quoted 11 lines
Quoted 11 lines
arch/m68k/cpu/m680x0/start.S +5 -0
+	/* Setup the debug uart if enabled */
+#ifdef CONFIG_DEBUG_UART
+	bsr.l	debug_uart_init
+#endif
+
 	/*
 	 * Allocate Global Data (GD)
 	 * board_init_f_alloc_reserve(top) returns the new top of stack in %d0
Signature · 1 line
2.51.0

-- Angelo

#4 lore raw

Re: [PATCH v2 2/3] m68k: m680x0: Initialise the debug uart

In reply to Kuan-Wei Chiu

Hi Daniel,

Quoted 19 lines · Kuan-Wei Chiu

+Cc Angelo since this touches arch/m68k/

Quoted 16 lines · Daniel Palmer

Once the stack is ready we can init the debug uart to help with debugging so do that.

---
 arch/m68k/cpu/m680x0/start.S | 5 +++++
 1 file changed, 5 insertions(+)
arch/m68k/cpu/m680x0/start.S +0 -0
index 0802ca1fca2c..fdfcd66f7785 100644
@@ -42,6 +42,11 @@ ENTRY(_start)
 	/* Setup initial stack pointer */
 	move.l	#CFG_SYS_INIT_SP_ADDR, %sp
 
Quoted 11 lines
Quoted 11 lines
arch/m68k/cpu/m680x0/start.S +5 -0
+	/* Setup the debug uart if enabled */
+#ifdef CONFIG_DEBUG_UART
+	bsr.l	debug_uart_init
+#endif
+
 	/*
 	 * Allocate Global Data (GD)
 	 * board_init_f_alloc_reserve(top) returns the new top of stack in %d0
Signature · 1 line
2.51.0

-- Angelo

#5 lore raw

PATCH v2 3/3 doc: board: virt: m68k: Detail how to use debug uart

In reply to Daniel Palmer

Add a paragraph to explain how to get the address of the goldfish tty and use it as the debug uart. I think the address is actually fixed right now but it might change in the future.

---
 doc/board/emulation/qemu-m68k.rst | 10 ++++++++++
 1 file changed, 10 insertions(+)
doc/board/emulation/qemu-m68k.rst +10 -0
index 6c4de54cf6a8..2f2e6bd6444a 100644
@@ -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:
Signature · 1 line
2.51.0
Reviewed-by Tested-by on v2 1/3
#6 lore raw
In reply to Daniel Palmer
Quoted 9 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 to the m68k qemu virt machine.

---
 drivers/serial/Kconfig           |  8 ++++++++
 drivers/serial/serial_goldfish.c | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)

For the series:

Hi Tom,
Would you take this patchset directly, or would you prefer a pull request?

Regards,
Kuan-Wei

#7 lore raw
Quoted 11 lines · Kuan-Wei Chiu
Quoted 9 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 to the m68k qemu virt machine.

---
 drivers/serial/Kconfig           |  8 ++++++++
 drivers/serial/serial_goldfish.c | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)
Quoted 8 lines

For the series:

Hi Tom,
Would you take this patchset directly, or would you prefer a pull request?

I will apply this to next directly, after it's been posted for about 2 weeks to allow for other reviews.

Signature · 1 line
Tom
#8 lore raw
Quoted 17 lines · Tom Rini
Quoted 16 lines · Kuan-Wei Chiu
Quoted 9 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 to the m68k qemu virt machine.

---
 drivers/serial/Kconfig           |  8 ++++++++
 drivers/serial/serial_goldfish.c | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)

For the series:

Quoted 6 lines
Quoted 3 lines

Hi Tom,
Would you take this patchset directly, or would you prefer a pull request?

I will apply this to next directly, after it's been posted for about 2 weeks to allow for other reviews.

Sure. Thanks!
I just wanted to clarify who would be picking it up after the review period, so it doesn't fall through the cracks.

Regards,
Kuan-Wei

#9 lore raw
In reply to Daniel Palmer
Quoted 5 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 to the m68k qemu virt machine.

Applied to u-boot/master, thanks!

[1/3] serial: goldfish: Add debug uart support

      commit: cbfb9b3f2248ff30724a12583981e3e7523272d6
[2/3] m68k: m680x0: Initialise the debug uart
      commit: 2df4926ca4f215d9b1a91d0c02c6fef49c845837
[3/3] doc: board: virt: m68k: Detail how to use debug uart
      commit: c15a08b730e3399c26622c8cb083bf521039606a
Signature · 1 line
Tom