linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH v4 0/2] rework of usbgecko-based early debug
@ 2009-12-03 20:34 Albert Herranz
  2009-12-03 20:34 ` [RFC PATCH v4 1/2] powerpc: reserve fixmap entries for " Albert Herranz
  2009-12-03 20:35 ` [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko Albert Herranz
  0 siblings, 2 replies; 8+ messages in thread
From: Albert Herranz @ 2009-12-03 20:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Albert Herranz

This is v4 of the "early debugging using usbgecko" patch.

It tries to implement the ideas suggested by Benjamin Herrenschmidt
regarding the use of a set of fixmap entries to provide safe
virtual address space for an early mapping.

Albert Herranz (2):
  powerpc: reserve fixmap entries 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                    |    1 +
 arch/powerpc/kernel/head_32.S                      |   25 +++++++++
 arch/powerpc/kernel/udbg.c                         |    2 +
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   56 ++++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
 7 files changed, 97 insertions(+), 0 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC PATCH v4 1/2] powerpc: reserve fixmap entries for early debug
  2009-12-03 20:34 [RFC PATCH v4 0/2] rework of usbgecko-based early debug Albert Herranz
@ 2009-12-03 20:34 ` Albert Herranz
  2009-12-11 22:15   ` Benjamin Herrenschmidt
  2009-12-03 20:35 ` [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko Albert Herranz
  1 sibling, 1 reply; 8+ messages in thread
From: Albert Herranz @ 2009-12-03 20:34 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Albert Herranz

Add a set of entries to the fixmap table to allow usage of known
reserved virtual address space by early debug code.

The address space reserved is the top 128K of the 32-bit address
space. This allows, if required, the use of a BAT to do the mappings.

Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
---
 arch/powerpc/include/asm/fixmap.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
index f1f4e23..5c2c023 100644
--- a/arch/powerpc/include/asm/fixmap.h
+++ b/arch/powerpc/include/asm/fixmap.h
@@ -44,6 +44,9 @@
  */
 enum fixed_addresses {
 	FIX_HOLE,
+	/* reserve the top 128K for early debugging purposes */
+	FIX_EARLY_DEBUG_TOP = FIX_HOLE,
+	FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+((128*1024)/PAGE_SIZE)-1,
 #ifdef CONFIG_HIGHMEM
 	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
 	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko
  2009-12-03 20:34 [RFC PATCH v4 0/2] rework of usbgecko-based early debug Albert Herranz
  2009-12-03 20:34 ` [RFC PATCH v4 1/2] powerpc: reserve fixmap entries for " Albert Herranz
@ 2009-12-03 20:35 ` Albert Herranz
  2009-12-04 12:04   ` Segher Boessenkool
  2009-12-11 22:16   ` Benjamin Herrenschmidt
  1 sibling, 2 replies; 8+ messages in thread
From: Albert Herranz @ 2009-12-03 20:35 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: 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.

Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>
---
 arch/powerpc/Kconfig.debug                         |    8 +++
 arch/powerpc/include/asm/udbg.h                    |    1 +
 arch/powerpc/kernel/head_32.S                      |   25 +++++++++
 arch/powerpc/kernel/udbg.c                         |    2 +
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   56 ++++++++++++++++++++
 arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
 6 files changed, 94 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index 3b10051..11e385b 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -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
diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h
index cd21e5e..11ae699 100644
--- a/arch/powerpc/include/asm/udbg.h
+++ b/arch/powerpc/include/asm/udbg.h
@@ -51,6 +51,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 */
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 829c3fe..00b89c0 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -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,28 @@ 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
+	/*
+	 * The virtual address used must match the virtual address
+	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
+	 */
+	lis	r11, 0xfffe	/* top 128K */
+	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.
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index fc9af47..e39cad8 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -60,6 +60,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
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
index ba4c7cc..edc956c 100644
--- a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
+++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
@@ -17,6 +17,7 @@
 #include <asm/io.h>
 #include <asm/prom.h>
 #include <asm/udbg.h>
+#include <asm/fixmap.h>
 
 #include "usbgecko_udbg.h"
 
@@ -270,3 +271,58 @@ done:
 		of_node_put(np);
 	return;
 }
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
+
+static phys_addr_t __init ug_early_grab_io_addr(void)
+{
+#if defined(CONFIG_GAMECUBE)
+	return 0x0c000000;
+#elif defined(CONFIG_WII)
+	return 0x0d000000;
+#else
+#error Invalid platform for USB Gecko based early debugging.
+#endif
+}
+
+/*
+ * USB Gecko early debug support initialization for udbg.
+ */
+void __init udbg_init_usbgecko(void)
+{
+	void __iomem *early_debug_area;
+	void __iomem *exi_io_base;
+
+	/*
+	 * At this point we have a BAT already setup that enables I/O
+	 * to the EXI hardware.
+	 *
+	 * The BAT uses a virtual address range reserved at the fixmap.
+	 * This must match the virtual address configured in
+	 * head_32.S:setup_usbgecko_bat().
+	 */
+	early_debug_area = (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE);
+	exi_io_base = early_debug_area + 0x00006800;
+
+	/* try to detect a USB Gecko */
+	if (!ug_udbg_probe(exi_io_base))
+		return;
+
+	/* we found a USB Gecko, load udbg hooks */
+	udbg_putc = ug_udbg_putc;
+	udbg_getc = ug_udbg_getc;
+	udbg_getc_poll = ug_udbg_getc_poll;
+
+	/*
+	 * Prepare again the same BAT for MMU_init.
+	 * This allows udbg I/O to continue working after the MMU is
+	 * turned on for real.
+	 * It is safe to continue using the same virtual address as it is
+	 * a reserved fixmap area.
+	 */
+	setbat(1, (unsigned long)early_debug_area,
+	       ug_early_grab_io_addr(), 128*1024, PAGE_KERNEL_NCG);
+}
+
+#endif /* CONFIG_PPC_EARLY_DEBUG_USBGECKO */
+
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
index 3929de3..bb6cde4 100644
--- a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
+++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
@@ -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 */
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko
  2009-12-03 20:35 ` [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko Albert Herranz
@ 2009-12-04 12:04   ` Segher Boessenkool
  2009-12-04 16:54     ` Albert Herranz
  2009-12-11 22:16   ` Benjamin Herrenschmidt
  1 sibling, 1 reply; 8+ messages in thread
From: Segher Boessenkool @ 2009-12-04 12:04 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev

> +#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

A kernel with both CONFIG_WII and CONFIG_GAMECUBE works fine
on either, right?  If so, could you please switch the two #ifs?
A dual-platform kernel will be used on a Wii much more likely
than on a GC.

> +	/*
> +	 * The virtual address used must match the virtual address
> +	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
> +	 */
> +	lis	r11, 0xfffe	/* top 128K */
> +	ori	r8, r8, 0x002a	/* uncached, guarded ,rw */
> +	ori	r11, r11, 0x3	/* 128K */

I think you should clear Vp since the BAT mapping can survive until
after user space is started; it won't hurt to remove it either way.
So 2 instead of 3.  And put the meaning in the comment :-)

Looks fine otherwise.


Segher

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko
  2009-12-04 12:04   ` Segher Boessenkool
@ 2009-12-04 16:54     ` Albert Herranz
  2009-12-04 19:56       ` Segher Boessenkool
  0 siblings, 1 reply; 8+ messages in thread
From: Albert Herranz @ 2009-12-04 16:54 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Segher Boessenkool wrote:
>> +#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
> 
> A kernel with both CONFIG_WII and CONFIG_GAMECUBE works fine
> on either, right?  If so, could you please switch the two #ifs?
> A dual-platform kernel will be used on a Wii much more likely
> than on a GC.
> 

Nope, a GameCube kernel currently doesn't work on a Wii and the same the other way around.

But I can make that particular check a runtime check.
The idea would be to enclose that snippet in GAMECUBE_COMMON and check the PVR. If it is a Gekko (a fixed value) then we have a GameCube, otherwise we assume a Wii.

>> +    /*
>> +     * The virtual address used must match the virtual address
>> +     * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
>> +     */
>> +    lis    r11, 0xfffe    /* top 128K */
>> +    ori    r8, r8, 0x002a    /* uncached, guarded ,rw */
>> +    ori    r11, r11, 0x3    /* 128K */
> 
> I think you should clear Vp since the BAT mapping can survive until
> after user space is started; it won't hurt to remove it either way.
> So 2 instead of 3.  And put the meaning in the comment :-)

This BAT is re-setup again on MMU_init, way before starting userspace.
But I'll make it Vs=1, Vp=0 here too :)

> 
> Looks fine otherwise.
> 

Thanks.

> 
> Segher
> 
> 

Cheers,
Albert

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko
  2009-12-04 16:54     ` Albert Herranz
@ 2009-12-04 19:56       ` Segher Boessenkool
  0 siblings, 0 replies; 8+ messages in thread
From: Segher Boessenkool @ 2009-12-04 19:56 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev

>>> +#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
>>
>> A kernel with both CONFIG_WII and CONFIG_GAMECUBE works fine
>> on either, right?  If so, could you please switch the two #ifs?
>> A dual-platform kernel will be used on a Wii much more likely
>> than on a GC.
>
> Nope, a GameCube kernel currently doesn't work on a Wii and the same the
> other way around.

What is the problem, just the wrappers?

> But I can make that particular check a runtime check.

Nah, don't bother, this is just early debug stuff.

> The idea would be to enclose that snippet in GAMECUBE_COMMON and check the
> PVR.

Ugly!


Segher

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH v4 1/2] powerpc: reserve fixmap entries for early debug
  2009-12-03 20:34 ` [RFC PATCH v4 1/2] powerpc: reserve fixmap entries for " Albert Herranz
@ 2009-12-11 22:15   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2009-12-11 22:15 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev

On Thu, 2009-12-03 at 21:34 +0100, Albert Herranz wrote:
> Add a set of entries to the fixmap table to allow usage of known
> reserved virtual address space by early debug code.
> 
> The address space reserved is the top 128K of the 32-bit address
> space. This allows, if required, the use of a BAT to do the mappings.
> 
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

That will do for now. I have ideas to clean it up a bit but for now it's
fine.

> ---
>  arch/powerpc/include/asm/fixmap.h |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/fixmap.h b/arch/powerpc/include/asm/fixmap.h
> index f1f4e23..5c2c023 100644
> --- a/arch/powerpc/include/asm/fixmap.h
> +++ b/arch/powerpc/include/asm/fixmap.h
> @@ -44,6 +44,9 @@
>   */
>  enum fixed_addresses {
>  	FIX_HOLE,
> +	/* reserve the top 128K for early debugging purposes */
> +	FIX_EARLY_DEBUG_TOP = FIX_HOLE,
> +	FIX_EARLY_DEBUG_BASE = FIX_EARLY_DEBUG_TOP+((128*1024)/PAGE_SIZE)-1,
>  #ifdef CONFIG_HIGHMEM
>  	FIX_KMAP_BEGIN,	/* reserved pte's for temporary kernel mappings */
>  	FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko
  2009-12-03 20:35 ` [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko Albert Herranz
  2009-12-04 12:04   ` Segher Boessenkool
@ 2009-12-11 22:16   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2009-12-11 22:16 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev

On Thu, 2009-12-03 at 21:35 +0100, Albert Herranz wrote:
> 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.
> 
> Signed-off-by: Albert Herranz <albert_herranz@yahoo.es>

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> ---
>  arch/powerpc/Kconfig.debug                         |    8 +++
>  arch/powerpc/include/asm/udbg.h                    |    1 +
>  arch/powerpc/kernel/head_32.S                      |   25 +++++++++
>  arch/powerpc/kernel/udbg.c                         |    2 +
>  arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c |   56 ++++++++++++++++++++
>  arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h |    2 +
>  6 files changed, 94 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
> index 3b10051..11e385b 100644
> --- a/arch/powerpc/Kconfig.debug
> +++ b/arch/powerpc/Kconfig.debug
> @@ -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
> diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h
> index cd21e5e..11ae699 100644
> --- a/arch/powerpc/include/asm/udbg.h
> +++ b/arch/powerpc/include/asm/udbg.h
> @@ -51,6 +51,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 */
> diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
> index 829c3fe..00b89c0 100644
> --- a/arch/powerpc/kernel/head_32.S
> +++ b/arch/powerpc/kernel/head_32.S
> @@ -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,28 @@ 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
> +	/*
> +	 * The virtual address used must match the virtual address
> +	 * associated to the fixmap entry FIX_EARLY_DEBUG_BASE.
> +	 */
> +	lis	r11, 0xfffe	/* top 128K */
> +	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.
> diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
> index fc9af47..e39cad8 100644
> --- a/arch/powerpc/kernel/udbg.c
> +++ b/arch/powerpc/kernel/udbg.c
> @@ -60,6 +60,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
> diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
> index ba4c7cc..edc956c 100644
> --- a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
> +++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
> @@ -17,6 +17,7 @@
>  #include <asm/io.h>
>  #include <asm/prom.h>
>  #include <asm/udbg.h>
> +#include <asm/fixmap.h>
>  
>  #include "usbgecko_udbg.h"
>  
> @@ -270,3 +271,58 @@ done:
>  		of_node_put(np);
>  	return;
>  }
> +
> +#ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO
> +
> +static phys_addr_t __init ug_early_grab_io_addr(void)
> +{
> +#if defined(CONFIG_GAMECUBE)
> +	return 0x0c000000;
> +#elif defined(CONFIG_WII)
> +	return 0x0d000000;
> +#else
> +#error Invalid platform for USB Gecko based early debugging.
> +#endif
> +}
> +
> +/*
> + * USB Gecko early debug support initialization for udbg.
> + */
> +void __init udbg_init_usbgecko(void)
> +{
> +	void __iomem *early_debug_area;
> +	void __iomem *exi_io_base;
> +
> +	/*
> +	 * At this point we have a BAT already setup that enables I/O
> +	 * to the EXI hardware.
> +	 *
> +	 * The BAT uses a virtual address range reserved at the fixmap.
> +	 * This must match the virtual address configured in
> +	 * head_32.S:setup_usbgecko_bat().
> +	 */
> +	early_debug_area = (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE);
> +	exi_io_base = early_debug_area + 0x00006800;
> +
> +	/* try to detect a USB Gecko */
> +	if (!ug_udbg_probe(exi_io_base))
> +		return;
> +
> +	/* we found a USB Gecko, load udbg hooks */
> +	udbg_putc = ug_udbg_putc;
> +	udbg_getc = ug_udbg_getc;
> +	udbg_getc_poll = ug_udbg_getc_poll;
> +
> +	/*
> +	 * Prepare again the same BAT for MMU_init.
> +	 * This allows udbg I/O to continue working after the MMU is
> +	 * turned on for real.
> +	 * It is safe to continue using the same virtual address as it is
> +	 * a reserved fixmap area.
> +	 */
> +	setbat(1, (unsigned long)early_debug_area,
> +	       ug_early_grab_io_addr(), 128*1024, PAGE_KERNEL_NCG);
> +}
> +
> +#endif /* CONFIG_PPC_EARLY_DEBUG_USBGECKO */
> +
> diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
> index 3929de3..bb6cde4 100644
> --- a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
> +++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
> @@ -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 */

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-12-11 22:16 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-03 20:34 [RFC PATCH v4 0/2] rework of usbgecko-based early debug Albert Herranz
2009-12-03 20:34 ` [RFC PATCH v4 1/2] powerpc: reserve fixmap entries for " Albert Herranz
2009-12-11 22:15   ` Benjamin Herrenschmidt
2009-12-03 20:35 ` [RFC PATCH v4 2/2] powerpc: gamecube/wii: early debugging using usbgecko Albert Herranz
2009-12-04 12:04   ` Segher Boessenkool
2009-12-04 16:54     ` Albert Herranz
2009-12-04 19:56       ` Segher Boessenkool
2009-12-11 22:16   ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).