Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Albert Herranz and committed by
Grant Likely
d1d56f8c b8e8efaa

+94
+8
arch/powerpc/Kconfig.debug
··· 254 254 using a CPM-based serial port. This assumes that the bootwrapper 255 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 265 endchoice 258 266 259 267 config PPC_EARLY_DEBUG_44x_PHYSLOW
+1
arch/powerpc/include/asm/udbg.h
··· 51 51 extern void __init udbg_init_44x_as1(void); 52 52 extern void __init udbg_init_40x_realmode(void); 53 53 extern void __init udbg_init_cpm(void); 54 + extern void __init udbg_init_usbgecko(void); 54 55 55 56 #endif /* __KERNEL__ */ 56 57 #endif /* _ASM_POWERPC_UDBG_H */
+25
arch/powerpc/kernel/head_32.S
··· 164 164 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM 165 165 bl setup_cpm_bat 166 166 #endif 167 + #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO 168 + bl setup_usbgecko_bat 169 + #endif 167 170 168 171 /* 169 172 * Call setup_cpu for CPU 0 and initialize 6xx Idle ··· 1203 1200 ori r11, r11, (BL_1M << 2) | 2 1204 1201 mtspr SPRN_DBAT1U, r11 1205 1202 1203 + blr 1204 + #endif 1205 + 1206 + #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO 1207 + setup_usbgecko_bat: 1208 + /* prepare a BAT for early io */ 1209 + #if defined(CONFIG_GAMECUBE) 1210 + lis r8, 0x0c00 1211 + #elif defined(CONFIG_WII) 1212 + lis r8, 0x0d00 1213 + #else 1214 + #error Invalid platform for USB Gecko based early debugging. 1215 + #endif 1216 + /* 1217 + * The virtual address used must match the virtual address 1218 + * associated to the fixmap entry FIX_EARLY_DEBUG_BASE. 1219 + */ 1220 + lis r11, 0xfffe /* top 128K */ 1221 + ori r8, r8, 0x002a /* uncached, guarded ,rw */ 1222 + ori r11, r11, 0x2 /* 128K, Vs=1, Vp=0 */ 1223 + mtspr SPRN_DBAT1L, r8 1224 + mtspr SPRN_DBAT1U, r11 1206 1225 blr 1207 1226 #endif 1208 1227
+2
arch/powerpc/kernel/udbg.c
··· 60 60 udbg_init_40x_realmode(); 61 61 #elif defined(CONFIG_PPC_EARLY_DEBUG_CPM) 62 62 udbg_init_cpm(); 63 + #elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO) 64 + udbg_init_usbgecko(); 63 65 #endif 64 66 65 67 #ifdef CONFIG_PPC_EARLY_DEBUG
+56
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.c
··· 17 17 #include <asm/io.h> 18 18 #include <asm/prom.h> 19 19 #include <asm/udbg.h> 20 + #include <asm/fixmap.h> 20 21 21 22 #include "usbgecko_udbg.h" 22 23 ··· 271 270 of_node_put(np); 272 271 return; 273 272 } 273 + 274 + #ifdef CONFIG_PPC_EARLY_DEBUG_USBGECKO 275 + 276 + static phys_addr_t __init ug_early_grab_io_addr(void) 277 + { 278 + #if defined(CONFIG_GAMECUBE) 279 + return 0x0c000000; 280 + #elif defined(CONFIG_WII) 281 + return 0x0d000000; 282 + #else 283 + #error Invalid platform for USB Gecko based early debugging. 284 + #endif 285 + } 286 + 287 + /* 288 + * USB Gecko early debug support initialization for udbg. 289 + */ 290 + void __init udbg_init_usbgecko(void) 291 + { 292 + void __iomem *early_debug_area; 293 + void __iomem *exi_io_base; 294 + 295 + /* 296 + * At this point we have a BAT already setup that enables I/O 297 + * to the EXI hardware. 298 + * 299 + * The BAT uses a virtual address range reserved at the fixmap. 300 + * This must match the virtual address configured in 301 + * head_32.S:setup_usbgecko_bat(). 302 + */ 303 + early_debug_area = (void __iomem *)__fix_to_virt(FIX_EARLY_DEBUG_BASE); 304 + exi_io_base = early_debug_area + 0x00006800; 305 + 306 + /* try to detect a USB Gecko */ 307 + if (!ug_udbg_probe(exi_io_base)) 308 + return; 309 + 310 + /* we found a USB Gecko, load udbg hooks */ 311 + udbg_putc = ug_udbg_putc; 312 + udbg_getc = ug_udbg_getc; 313 + udbg_getc_poll = ug_udbg_getc_poll; 314 + 315 + /* 316 + * Prepare again the same BAT for MMU_init. 317 + * This allows udbg I/O to continue working after the MMU is 318 + * turned on for real. 319 + * It is safe to continue using the same virtual address as it is 320 + * a reserved fixmap area. 321 + */ 322 + setbat(1, (unsigned long)early_debug_area, 323 + ug_early_grab_io_addr(), 128*1024, PAGE_KERNEL_NCG); 324 + } 325 + 326 + #endif /* CONFIG_PPC_EARLY_DEBUG_USBGECKO */ 327 +
+2
arch/powerpc/platforms/embedded6xx/usbgecko_udbg.h
··· 27 27 28 28 #endif /* CONFIG_USBGECKO_UDBG */ 29 29 30 + void __init udbg_init_usbgecko(void); 31 + 30 32 #endif /* __USBGECKO_UDBG_H */