diff options
| author | Albert Herranz <albert_herranz@yahoo.es> | 2009-12-12 01:31:51 -0500 |
|---|---|---|
| committer | Grant Likely <grant.likely@secretlab.ca> | 2009-12-13 00:24:31 -0500 |
| commit | d1d56f8c1d5a622228177eca47e9dcff0498bddb (patch) | |
| tree | 450b587fbe84b0e1e6f46f8d6c3bf1b5420b6e39 | |
| parent | b8e8efaa86399c4424becd96402993cf230dab57 (diff) | |
powerpc: gamecube/wii: early debugging using usbgecko
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>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
| -rw-r--r-- | arch/powerpc/Kconfig.debug | 8 | ||||
| -rw-r--r-- | arch/powerpc/include/asm/udbg.h | 1 | ||||
| -rw-r--r-- | arch/powerpc/kernel/head_32.S | 25 | ||||
| -rw-r--r-- | arch/powerpc/kernel/udbg.c | 2 | ||||
| -rw-r--r-- | arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c | 56 | ||||
| -rw-r--r-- | 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 3b1005185390..11e385bd2b3d 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug | |||
| @@ -254,6 +254,14 @@ config PPC_EARLY_DEBUG_CPM | |||
| 254 | using a CPM-based serial port. This assumes that the bootwrapper | 254 | using a CPM-based serial port. This assumes that the bootwrapper |
| 255 | has run, and set up the CPM in a particular way. | 255 | has run, and set up the CPM in a particular way. |
| 256 | 256 | ||
| 257 | config PPC_EARLY_DEBUG_USBGECKO | ||
| 258 | bool "Early debugging through the USB Gecko adapter" | ||
| 259 | depends on GAMECUBE_COMMON | ||
| 260 | select USBGECKO_UDBG | ||
| 261 | help | ||
| 262 | Select this to enable early debugging for Nintendo GameCube/Wii | ||
| 263 | consoles via an external USB Gecko adapter. | ||
| 264 | |||
| 257 | endchoice | 265 | endchoice |
| 258 | 266 | ||
| 259 | config PPC_EARLY_DEBUG_44x_PHYSLOW | 267 | config PPC_EARLY_DEBUG_44x_PHYSLOW |
diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h index cd21e5e6b04f..11ae699135ba 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); | |||
| 51 | extern void __init udbg_init_44x_as1(void); | 51 | extern void __init udbg_init_44x_as1(void); |
| 52 | extern void __init udbg_init_40x_realmode(void); | 52 | extern void __init udbg_init_40x_realmode(void); |
| 53 | extern void __init udbg_init_cpm(void); | 53 | extern void __init udbg_init_cpm(void); |
| 54 | extern void __init udbg_init_usbgecko(void); | ||
| 54 | 55 | ||
| 55 | #endif /* __KERNEL__ */ | 56 | #endif /* __KERNEL__ */ |
| 56 | #endif /* _ASM_POWERPC_UDBG_H */ | 57 | #endif /* _ASM_POWERPC_UDBG_H */ |
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S index 829c3fe7c5a2..e025e89fe93e 100644 --- a/arch/powerpc/kernel/head_32.S +++ b/arch/powerpc/kernel/head_32.S | |||
| @@ -164,6 +164,9 @@ __after_mmu_off: | |||
| 164 | #ifdef CONFIG_PPC_EARLY_DEBUG_CPM | 164 | #ifdef CONFIG_PPC_EARLY_DEBUG_CPM |
| 165 | bl setup_cpm_bat | 165 | bl setup_cpm_bat |
| 166 | #endif | 166 | #endif |
| 167 | #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO | ||
| 168 | bl setup_usbgecko_bat | ||
| 169 | #endif | ||
| 167 | 170 | ||
| 168 | /* | 171 | /* |
| 169 | * Call setup_cpu for CPU 0 and initialize 6xx Idle | 172 | * Call setup_cpu for CPU 0 and initialize 6xx Idle |
| @@ -1203,6 +1206,28 @@ setup_cpm_bat: | |||
| 1203 | blr | 1206 | blr |
| 1204 | #endif | 1207 | #endif |
| 1205 | 1208 | ||
| 1209 | #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO | ||
| 1210 | setup_usbgecko_bat: | ||
| 1211 | /* prepare a BAT for early io */ | ||
| 1212 | #if defined(CONFIG_GAMECUBE) | ||
| 1213 | lis r8, 0x0c00 | ||
| 1214 | #elif defined(CONFIG_WII) | ||
| 1215 | lis r8, 0x0d00 | ||
| 1216 | #else | ||
| 1217 | #error Invalid platform for USB Gecko based early debugging. | ||
| 1218 | #endif | ||
| 1219 | /* | ||
| 1220 | * The virtual address used must match the virtual address | ||
| 1221 | * associated to the fixmap entry FIX_EARLY_DEBUG_BASE. | ||
| 1222 | */ | ||
| 1223 | lis r11, 0xfffe /* top 128K */ | ||
| 1224 | ori r8, r8, 0x002a /* uncached, guarded ,rw */ | ||
| 1225 | ori r11, r11, 0x2 /* 128K, Vs=1, Vp=0 */ | ||
| 1226 | mtspr SPRN_DBAT1L, r8 | ||
| 1227 | mtspr SPRN_DBAT1U, r11 | ||
| 1228 | blr | ||
| 1229 | #endif | ||
| 1230 | |||
| 1206 | #ifdef CONFIG_8260 | 1231 | #ifdef CONFIG_8260 |
| 1207 | /* Jump into the system reset for the rom. | 1232 | /* Jump into the system reset for the rom. |
| 1208 | * We first disable the MMU, and then jump to the ROM reset address. | 1233 | * 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 fc9af47e2128..e39cad83c884 100644 --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c | |||
| @@ -60,6 +60,8 @@ void __init udbg_early_init(void) | |||
| 60 | udbg_init_40x_realmode(); | 60 | udbg_init_40x_realmode(); |
| 61 | #elif defined(CONFIG_PPC_EARLY_DEBUG_CPM) | 61 | #elif defined(CONFIG_PPC_EARLY_DEBUG_CPM) |
| 62 | udbg_init_cpm(); | 62 | udbg_init_cpm(); |
| 63 | #elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO) | ||
| 64 | udbg_init_usbgecko(); | ||
| 63 | #endif | 65 | #endif |
| 64 | 66 | ||
| 65 | #ifdef CONFIG_PPC_EARLY_DEBUG | 67 | #ifdef CONFIG_PPC_EARLY_DEBUG |
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c index ba4c7cc4f0f1..edc956cc8b13 100644 --- a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c +++ b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
| 18 | #include <asm/prom.h> | 18 | #include <asm/prom.h> |
| 19 | #include <asm/udbg.h> | 19 | #include <asm/udbg.h> |
| 20 | #include <asm/fixmap.h> | ||
| 20 | 21 | ||
| 21 | #include "usbgecko_udbg.h" | 22 | #include "usbgecko_udbg.h" |
| 22 | 23 | ||
| @@ -270,3 +271,58 @@ done: | |||
| 270 | of_node_put(np); | 271 | of_node_put(np); |
| 271 | return; | 272 | return; |
| 272 | } | 273 | } |
| 274 | |||
| 275 | #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO | ||
| 276 | |||
| 277 | static phys_addr_t __init ug_early_grab_io_addr(void) | ||
| 278 | { | ||
| 279 | #if defined(CONFIG_GAMECUBE) | ||
| 280 | return 0x0c000000; | ||
| 281 | #elif defined(CONFIG_WII) | ||
| 282 | return 0x0d000000; | ||
| 283 | #else | ||
| 284 | #error Invalid platform for USB Gecko based early debugging. | ||
| 285 | #endif | ||
| 286 | } | ||
| 287 | |||
| 288 | /* | ||
| 289 | * USB Gecko early debug support initialization for udbg. | ||
| 290 | */ | ||
| 291 | void __init udbg_init_usbgecko(void) | ||
| 292 | { | ||
| 293 | void __iomem *early_debug_area; | ||
| 294 | void __iomem *exi_io_base; | ||
| 295 | |||
| 296 | /* | ||
| 297 | * At this point we have a BAT already setup that enables I/O | ||
| 298 | * to the EXI hardware. | ||
| 299 | * | ||
| 300 | * The BAT uses a virtual address range reserved at the fixmap. | ||
| 301 | * This must match the virtual address configured in | ||
| 302 | * head_32.S:setup_usbgecko_bat(). | ||
| 303 | */ | ||
| 304 | early_debug_area = (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE); | ||
| 305 | exi_io_base = early_debug_area + 0x00006800; | ||
| 306 | |||
| 307 | /* try to detect a USB Gecko */ | ||
| 308 | if (!ug_udbg_probe(exi_io_base)) | ||
| 309 | return; | ||
| 310 | |||
| 311 | /* we found a USB Gecko, load udbg hooks */ | ||
| 312 | udbg_putc = ug_udbg_putc; | ||
| 313 | udbg_getc = ug_udbg_getc; | ||
| 314 | udbg_getc_poll = ug_udbg_getc_poll; | ||
| 315 | |||
| 316 | /* | ||
| 317 | * Prepare again the same BAT for MMU_init. | ||
| 318 | * This allows udbg I/O to continue working after the MMU is | ||
| 319 | * turned on for real. | ||
| 320 | * It is safe to continue using the same virtual address as it is | ||
| 321 | * a reserved fixmap area. | ||
| 322 | */ | ||
| 323 | setbat(1, (unsigned long)early_debug_area, | ||
| 324 | ug_early_grab_io_addr(), 128*1024, PAGE_KERNEL_NCG); | ||
| 325 | } | ||
| 326 | |||
| 327 | #endif /* CONFIG_PPC_EARLY_DEBUG_USBGECKO */ | ||
| 328 | |||
diff --git a/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h b/arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h index 3929de366cf1..bb6cde4ad764 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) | |||
| 27 | 27 | ||
| 28 | #endif /* CONFIG_USBGECKO_UDBG */ | 28 | #endif /* CONFIG_USBGECKO_UDBG */ |
| 29 | 29 | ||
| 30 | void __init udbg_init_usbgecko(void); | ||
| 31 | |||
| 30 | #endif /* __USBGECKO_UDBG_H */ | 32 | #endif /* __USBGECKO_UDBG_H */ |
