Skip to contentSkip to conversation

rework of usbgecko-based early debug

RFC PATCH Superseded Albert Herranz 5 participants 11 messages Nov 30, 2009 – Dec 3, 2009 PowerPC

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover rework of usbgecko-based early debug

This series is a rework of the previously posted patch:
- [RFC PATCH v2 08/11] powerpc: gamecube/wii: early debugging using usbgecko

It tries to implement the ideas suggested by Benjamin Herrenschmidt regarding the use of a fixmap entry to provide a valid I/O mapping immediately after MMU_init runs and MMU is definitively enabled.

Albert Herranz (3):
powerpc: udbg: add early remap hook
powerpc: udbg: add fixmap entry for early debug
powerpc: gamecube/wii: early debugging using usbgecko

 arch/powerpc/Kconfig.debug                         |    8 +++
 arch/powerpc/include/asm/fixmap.h                  |    3 +
 arch/powerpc/include/asm/udbg.h                    |    4 +
 arch/powerpc/kernel/head_32.S                      |   21 +++++++
 arch/powerpc/kernel/udbg.c                         |    5 ++
 arch/powerpc/mm/init_32.c                          |   10 +++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   59 ++++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
 8 files changed, 112 insertions(+), 0 deletions(-)
#1 lore raw

RFC PATCH v3 1/3 powerpc: udbg: add early remap hook

The udbg facility provides an early debug extension that can be enabled using CONFIG_PPC_EARLY_DEBUG.
In some cases, this early debugging facility cannot be used after MMU_init runs (and the MMU is loaded and enabled with the definitive mappings) because the early mappings are not valid anymore.

This patch provides a udbg hook called udbg_early_remap that gets called at the end of MMU_init and can be used by a low level udbg driver to accomplish several goals, like:
- extending the early debugging life by configuring and using a new valid I/O mapping
- safely disabling the early debugging

---
 arch/powerpc/include/asm/udbg.h |    3 +++
 arch/powerpc/kernel/udbg.c      |    3 +++
 arch/powerpc/mm/init_32.c       |   10 ++++++++++
 3 files changed, 16 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/udbg.h +3 -0
index cd21e5e..9dfedec 100644
@@ -18,6 +18,9 @@ extern void (*udbg_putc)(char c);
 extern void (*udbg_flush)(void);
 extern int (*udbg_getc)(void);
 extern int (*udbg_getc_poll)(void);
+#ifdef CONFIG_PPC_EARLY_DEBUG
+extern void (*udbg_early_remap)(void);
+#endif
 
 extern void udbg_puts(const char *s);
 extern int udbg_write(const char *s, int n);
arch/powerpc/kernel/udbg.c +3 -0
index fc9af47..2711050 100644
@@ -21,6 +21,9 @@ void (*udbg_putc)(char c);
 void (*udbg_flush)(void);
 int (*udbg_getc)(void);
 int (*udbg_getc_poll)(void);
+#ifdef CONFIG_PPC_EARLY_DEBUG
+void (*udbg_early_remap)(void);
+#endif
 
 /*
  * Early debugging facilities. You can enable _one_ of these via .config,
arch/powerpc/mm/init_32.c +10 -0
index 9ddcfb4..066e4ff 100644
@@ -43,6 +43,7 @@
 #include <asm/tlb.h>
 #include <asm/sections.h>
 #include <asm/system.h>
+#include <asm/udbg.h>
 
 #include "mmu_decl.h"
 
@@ -180,6 +181,15 @@ void __init MMU_init(void)
 #ifdef CONFIG_BOOTX_TEXT
 	btext_unmap();
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG
+	/*
+	 * This hook can be used by a low level early udbg driver to either
+	 * provide a new valid I/O mapping to be used after MMU_init
+	 * or just to safely disable actual udbg I/O from now on.
+	 */
+	if (udbg_early_remap)
+		udbg_early_remap();
+#endif
 }
 
 /* This is only called until mem_init is done. */
Signature · 1 line
1.6.3.3
#2 lore raw

RFC PATCH v3 2/3 powerpc: udbg: add fixmap entry for early debug

In reply to Albert Herranz

Add a new entry to the fixmap table to allow low level early udbg drivers to safely reserve virtual address space and create their I/O mappings.

---
 arch/powerpc/include/asm/fixmap.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/fixmap.h +3 -0
index f1f4e23..424e5a6 100644
@@ -48,6 +48,9 @@ enum fixed_addresses {
 	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
 	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG
+	FIX_EARLY_DEBUG_BASE,
+#endif
 	/* FIX_PCIE_MCFG, */
 	__end_of_fixed_addresses
 };
Signature · 1 line
1.6.3.3
#3 lore raw

Re: [RFC PATCH v3 2/3] powerpc: udbg: add fixmap entry for early debug

Quoted 13 lines · Albert Herranz

Add a new entry to the fixmap table to allow low level early udbg drivers to safely reserve virtual address space and create their I/O mappings.

---
 arch/powerpc/include/asm/fixmap.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/fixmap.h +0 -0
index f1f4e23..424e5a6 100644

arch/powerpc/include/asm/fixmap.h enum fixed_addresses { · line 56

Quoted 9 lines
arch/powerpc/include/asm/fixmap.h +3 -0
@@ -48,6 +48,9 @@ enum fixed_addresses {
 	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
 	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG
+	FIX_EARLY_DEBUG_BASE,
+#endif
 	/* FIX_PCIE_MCFG, */
 	__end_of_fixed_addresses
 };

Rather than a hook to hop between the BAT and the later single page mapping, I would have just used the fixmap as a way to reserve virtual space for the BAT and keep it around.

However, that does mean having more than one entry in the fixmap, in fact, enough to cope with the BAT min size +/- alignment. Maybe to avoid the alignment problem, an option would be to always use the top of the fixmap for the "debug area" and make it always something nice and fat to fit a BAT, like 128K or whatever is the min size. No need for CONFIG_* there even, I won't cry for 128K of virtual space reserved there instead of just one page currently. And we could have good use of it for other early debug stuff even.

Cheers,
Ben.

#4 lore raw

RFC PATCH v3 3/3 powerpc: gamecube/wii: early debugging using usbgecko

In reply to Albert Herranz

Add support for using the USB Gecko adapter as an early debugging console on the Nintendo GameCube and Wii video game consoles. The USB Gecko is a 3rd party memory card interface adapter that provides a EXI (External Interface) to USB serial converter.

---
 arch/powerpc/Kconfig.debug                         |    8 +++
 arch/powerpc/include/asm/udbg.h                    |    1 +
 arch/powerpc/kernel/head_32.S                      |   21 +++++++
 arch/powerpc/kernel/udbg.c                         |    2 +
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   59 ++++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
 6 files changed, 93 insertions(+), 0 deletions(-)
arch/powerpc/Kconfig.debug +8 -0
index 3b10051..11e385b 100644
@@ -254,6 +254,14 @@ config PPC_EARLY_DEBUG_CPM
 	  using a CPM-based serial port.  This assumes that the bootwrapper
 	  has run, and set up the CPM in a particular way.
 
+config PPC_EARLY_DEBUG_USBGECKO
+	bool "Early debugging through the USB Gecko adapter"
+	depends on GAMECUBE_COMMON
+	select USBGECKO_UDBG
+	help
+	  Select this to enable early debugging for Nintendo GameCube/Wii
+	  consoles via an external USB Gecko adapter.
+
 endchoice
 
 config PPC_EARLY_DEBUG_44x_PHYSLOW
arch/powerpc/include/asm/udbg.h +1 -0
index 9dfedec..5abfd0f 100644
@@ -54,6 +54,7 @@ extern void __init udbg_init_btext(void);
 extern void __init udbg_init_44x_as1(void);
 extern void __init udbg_init_40x_realmode(void);
 extern void __init udbg_init_cpm(void);
+extern void __init udbg_init_usbgecko(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
arch/powerpc/kernel/head_32.S +21 -0
index 829c3fe..c3f3737 100644
@@ -164,6 +164,9 @@ __after_mmu_off:
 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM
 	bl	setup_cpm_bat
 #endif
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+	bl	setup_usbgecko_bat
+#endif
 
 /*
  * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1203,6 +1206,24 @@ setup_cpm_bat:
 	blr
 #endif
 
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+setup_usbgecko_bat:
+	/* prepare a BAT for early io */
+#if defined(CONFIG_GAMECUBE)
+	lis	r8, 0x0c00
+#elif defined(CONFIG_WII)
+	lis	r8, 0x0d00
+#else
+#error Invalid platform for USB Gecko based early debugging.
+#endif
+	mr	r11, r8
+	ori	r8, r8, 0x002a	/* uncached, guarded ,rw */
+	ori	r11, r11, 0x3	/* 128K */
+	mtspr	SPRN_DBAT1L, r8
+	mtspr	SPRN_DBAT1U, r11
+	blr
+#endif
+
 #ifdef CONFIG_8260
 /* Jump into the system reset for the rom.
  * We first disable the MMU, and then jump to the ROM reset address.
arch/powerpc/kernel/udbg.c +2 -0
index 2711050..65a7926 100644
@@ -63,6 +63,8 @@ void __init udbg_early_init(void)
 	udbg_init_40x_realmode();
 #elif defined(CONFIG_PPC_EARLY_DEBUG_CPM)
 	udbg_init_cpm();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO)
+	udbg_init_usbgecko();
 #endif
 
 #ifdef CONFIG_PPC_EARLY_DEBUG
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +59 -0

68 lines not on this page · raw message

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h +2 -0
index 3929de3..bb6cde4 100644
@@ -27,4 +27,6 @@ static inline void __init ug_udbg_init(void)
 
 #endif /* CONFIG_USBGECKO_UDBG */
 
+void __init udbg_init_usbgecko(void);
+
 #endif /* __USBGECKO_UDBG_H */
Signature · 1 line
1.6.3.3
#5 lore raw

Re: [RFC PATCH v3 3/3] powerpc: gamecube/wii: early debugging using usbgecko

Quoted 24 lines · Albert Herranz

Add support for using the USB Gecko adapter as an early debugging console on the Nintendo GameCube and Wii video game consoles. The USB Gecko is a 3rd party memory card interface adapter that provides a EXI (External Interface) to USB serial converter.

---
 arch/powerpc/Kconfig.debug                         |    8 +++
 arch/powerpc/include/asm/udbg.h                    |    1 +
 arch/powerpc/kernel/head_32.S                      |   21 +++++++
 arch/powerpc/kernel/udbg.c                         |    2 +
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   59 ++++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
 6 files changed, 93 insertions(+), 0 deletions(-)
arch/powerpc/Kconfig.debug +1 -0
index 3b10051..11e385b 100644
@@ -254,6 +254,14 @@ config PPC_EARLY_DEBUG_CPM
 	  using a CPM-based serial port.  This assumes that the bootwrapper
 	  has run, and set up the CPM in a particular way.
 
+config PPC_EARLY_DEBUG_USBGECKO

arch/powerpc/Kconfig.debug config PPC_EARLY_DEBUG_CPM · line 267

Quoted 10 lines
arch/powerpc/Kconfig.debug +7 -0
+	bool "Early debugging through the USB Gecko adapter"
+	depends on GAMECUBE_COMMON
+	select USBGECKO_UDBG
+	help
+	  Select this to enable early debugging for Nintendo GameCube/Wii
+	  consoles via an external USB Gecko adapter.
+
 endchoice
 
 config PPC_EARLY_DEBUG_44x_PHYSLOW

Small nit, my preference would be for this to be in the patch 1 where it is first referenced.

Quoted 13 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +1 -0
index ba4c7cc..3f125b6 100644
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/udbg.h>
+#include <asm/fixmap.h>
 
 #include "usbgecko_udbg.h"
 

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c done: · line 277

Quoted 7 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +4 -0
@@ -270,3 +271,61 @@ done:
 		of_node_put(np);
 	return;
 }
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+
+static void __init ug_early_remap(void)

you may want to rename the ug_ prefix, it took me a while looking back and forth through the patch to convince myself it wasn't a typo.

-Richard Holden

#6 lore raw

Re: [RFC PATCH v3 3/3] powerpc: gamecube/wii: early debugging using usbgecko

Quoted 34 lines · Richard Holden
Quoted 33 lines · Albert Herranz

Add support for using the USB Gecko adapter as an early debugging console on the Nintendo GameCube and Wii video game consoles. The USB Gecko is a 3rd party memory card interface adapter that provides a EXI (External Interface) to USB serial converter.

---
 arch/powerpc/Kconfig.debug                         |    8 +++
 arch/powerpc/include/asm/udbg.h                    |    1 +
 arch/powerpc/kernel/head_32.S                      |   21 +++++++
 arch/powerpc/kernel/udbg.c                         |    2 +
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   59 ++++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
 6 files changed, 93 insertions(+), 0 deletions(-)
arch/powerpc/Kconfig.debug +8 -0
index 3b10051..11e385b 100644
@@ -254,6 +254,14 @@ config PPC_EARLY_DEBUG_CPM
 	  using a CPM-based serial port.  This assumes that the bootwrapper
 	  has run, and set up the CPM in a particular way.
 
+config PPC_EARLY_DEBUG_USBGECKO
+	bool "Early debugging through the USB Gecko adapter"
+	depends on GAMECUBE_COMMON
+	select USBGECKO_UDBG
+	help
+	  Select this to enable early debugging for Nintendo GameCube/Wii
+	  consoles via an external USB Gecko adapter.
+
 endchoice
 
Quoted 5 lines

arch/powerpc/Kconfig.debug config PPC_EARLY_DEBUG_CPM · line 267

Quoted 1 line
arch/powerpc/Kconfig.debug +0 -0
 config PPC_EARLY_DEBUG_44x_PHYSLOW

Small nit, my preference would be for this to be in the patch 1 where it is first referenced.

The first patch is generic, and uses PPC_EARLY_DEBUG.
This is the first patch where PPC_EARLY_DEBUG_USBGECKO is referenced.

Quoted 12 lines
Quoted 12 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +1 -0
index ba4c7cc..3f125b6 100644
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/udbg.h>
+#include <asm/fixmap.h>
 
 #include "usbgecko_udbg.h"
 
Quoted 12 lines

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c done: · line 277

Quoted 8 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +4 -0
@@ -270,3 +271,61 @@ done:
 		of_node_put(np);
 	return;
 }
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+
+static void __init ug_early_remap(void)

you may want to rename the ug_ prefix, it took me a while looking back and forth through the patch to convince myself it wasn't a typo.

What's wrong with ug_ ? (ug = (u)sb(g)ecko)

Quoted 2 lines

-Richard Holden

Thanks,
Albert

#7 lore raw

Re: [RFC PATCH v3 3/3] powerpc: gamecube/wii: early debugging using usbgecko

Quoted 26 lines · Albert Herranz
Quoted 12 lines · Richard Holden
Quoted 12 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +1 -0
index ba4c7cc..3f125b6 100644
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/udbg.h>
+#include <asm/fixmap.h>
 
 #include "usbgecko_udbg.h"
 
Quoted 12 lines

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c done: · line 277

Quoted 8 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +4 -0
@@ -270,3 +271,61 @@ done:
 		of_node_put(np);
 	return;
 }
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+
+static void __init ug_early_remap(void)

you may want to rename the ug_ prefix, it took me a while looking back and forth through the patch to convince myself it wasn't a typo.

Quoted 1 line

What's wrong with ug_ ? (ug = (u)sb(g)ecko)

What's wrong with usb_gecko_early_remap() :)

cheers

#8 lore raw

Re: [RFC PATCH v3 3/3] powerpc: gamecube/wii: early debugging using usbgecko

Quoted 7 lines · Michael Ellerman
Quoted 4 lines
Quoted 3 lines

you may want to rename the ug_ prefix, it took me a while looking back and forth through the patch to convince myself it wasn't a typo.

What's wrong with ug_ ? (ug = (u)sb(g)ecko)

What's wrong with usb_gecko_early_remap() :)

Nothing, except that names end up been way long for my taste (like for example usb_gecko_early_grab_exi_io_base()) I prefer to use a shorter prefix consistently.

But that's my taste :)

Cheers,
Albert

#9 lore raw

Re: [RFC PATCH v3 3/3] powerpc: gamecube/wii: early debugging using usbgecko

In reply to Albert Herranz
Quoted 4 lines · Albert Herranz
Quoted 1 line · Richard Holden

Albert Herranz wrote:

The first patch is generic, and uses PPC_EARLY_DEBUG.
This is the first patch where PPC_EARLY_DEBUG_USBGECKO is referenced.

Sorry, you are correct.

Quoted 1 line
Quoted 1 line

=

Quoted 1 line
= renamed from arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +0 -0

b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

index ba4c7cc..3f125b6 100644

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +1 -0
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/udbg.h>
+#include <asm/fixmap.h>

=20
#include "usbgecko_udbg.h"
=20

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +0 -0
@@ -270,3 +271,61 @@ done:
 		of_node_put(np);
Quoted 8 lines
Quoted 8 lines

arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c done: · line 277

Quoted 6 lines
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +4 -0
 	return;
 }
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+
+static void __init ug_early_remap(void)

=20
you may want to rename the ug_ prefix, it took me a while looking =

back

Quoted 5 lines
Quoted 2 lines

and forth through the patch to convince myself it wasn't a typo. =20

=20
What's wrong with ug_ ? (ug =3D (u)sb(g)ecko)
=20

At first look I thought it was a typo of udbg_early_remap. I prefer the = longer names although we could use gecko_early_remap unless the gecko = prefix conflicts with anything else. If there is not going to be a non = usb gecko then there is no need to have usb in the prefix.

-Richard Holden=

#10 lore raw

Re: [RFC PATCH v3 3/3] powerpc: gamecube/wii: early debugging using usbgecko

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

you may want to rename the ug_ prefix, it took me a while looking back and forth through the patch to convince myself it wasn't a typo.

What's wrong with ug_ ? (ug = (u)sb(g)ecko)

At first look I thought it was a typo of udbg_early_remap. I prefer the longer names although we could use gecko_early_remap unless the gecko prefix conflicts with anything else.

All these names are local to this file. Shorter names are nicer than longer names :-)

Quoted 1 line

If there is not going to be a non usb gecko then there is no need to have usb in the prefix.

There already is a Gecko device that plugs into the memory card slot as well. It is older than the USB Gecko, and much more widespread.

It doesn't give you a serial connection, it's memory only.

Segher