diff options
author | Jack Miller <jack@codezen.org> | 2011-04-14 18:32:08 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2011-05-05 23:32:41 -0400 |
commit | a0496d450ab8c17f6c4d86979b1f6ba486fe9365 (patch) | |
tree | accb4fa5d2695770a1c6992f7437df57e9f14868 /arch | |
parent | a1d0d98daf6ce580d017a43b09fe30a375cde3e8 (diff) |
powerpc: Add early debug for WSP platforms
Signed-off-by: Jack Miller <jack@codezen.org>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/Kconfig.debug | 5 | ||||
-rw-r--r-- | arch/powerpc/include/asm/reg_a2.h | 9 | ||||
-rw-r--r-- | arch/powerpc/include/asm/udbg.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/exceptions-64e.S | 17 | ||||
-rw-r--r-- | arch/powerpc/kernel/udbg.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/udbg_16550.c | 51 |
6 files changed, 85 insertions, 0 deletions
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug index 2d38a50e66ba..a597dd77b903 100644 --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug | |||
@@ -267,6 +267,11 @@ config PPC_EARLY_DEBUG_USBGECKO | |||
267 | Select this to enable early debugging for Nintendo GameCube/Wii | 267 | Select this to enable early debugging for Nintendo GameCube/Wii |
268 | consoles via an external USB Gecko adapter. | 268 | consoles via an external USB Gecko adapter. |
269 | 269 | ||
270 | config PPC_EARLY_DEBUG_WSP | ||
271 | bool "Early debugging via WSP's internal UART" | ||
272 | depends on PPC_WSP | ||
273 | select PPC_UDBG_16550 | ||
274 | |||
270 | endchoice | 275 | endchoice |
271 | 276 | ||
272 | config PPC_EARLY_DEBUG_44x_PHYSLOW | 277 | config PPC_EARLY_DEBUG_44x_PHYSLOW |
diff --git a/arch/powerpc/include/asm/reg_a2.h b/arch/powerpc/include/asm/reg_a2.h index 3ba9c6f096fc..3d52a1132f3d 100644 --- a/arch/powerpc/include/asm/reg_a2.h +++ b/arch/powerpc/include/asm/reg_a2.h | |||
@@ -110,6 +110,15 @@ | |||
110 | #define TLB1_UR ASM_CONST(0x0000000000000002) | 110 | #define TLB1_UR ASM_CONST(0x0000000000000002) |
111 | #define TLB1_SR ASM_CONST(0x0000000000000001) | 111 | #define TLB1_SR ASM_CONST(0x0000000000000001) |
112 | 112 | ||
113 | #ifdef CONFIG_PPC_EARLY_DEBUG_WSP | ||
114 | #define WSP_UART_PHYS 0xffc000c000 | ||
115 | /* This needs to be careful chosen to hit a !0 congruence class | ||
116 | * in the TLB since we bolt it in way 3, which is already occupied | ||
117 | * by our linear mapping primary bolted entry in CC 0. | ||
118 | */ | ||
119 | #define WSP_UART_VIRT 0xf000000000001000 | ||
120 | #endif | ||
121 | |||
113 | /* A2 erativax attributes definitions */ | 122 | /* A2 erativax attributes definitions */ |
114 | #define ERATIVAX_RS_IS_ALL 0x000 | 123 | #define ERATIVAX_RS_IS_ALL 0x000 |
115 | #define ERATIVAX_RS_IS_TID 0x040 | 124 | #define ERATIVAX_RS_IS_TID 0x040 |
diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h index 11ae699135ba..58580e94a2bb 100644 --- a/arch/powerpc/include/asm/udbg.h +++ b/arch/powerpc/include/asm/udbg.h | |||
@@ -52,6 +52,7 @@ 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 | extern void __init udbg_init_usbgecko(void); |
55 | extern void __init udbg_init_wsp(void); | ||
55 | 56 | ||
56 | #endif /* __KERNEL__ */ | 57 | #endif /* __KERNEL__ */ |
57 | #endif /* _ASM_POWERPC_UDBG_H */ | 58 | #endif /* _ASM_POWERPC_UDBG_H */ |
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S index c98e9d260621..4d0abb4930a1 100644 --- a/arch/powerpc/kernel/exceptions-64e.S +++ b/arch/powerpc/kernel/exceptions-64e.S | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <asm/cputable.h> | 17 | #include <asm/cputable.h> |
18 | #include <asm/setup.h> | 18 | #include <asm/setup.h> |
19 | #include <asm/thread_info.h> | 19 | #include <asm/thread_info.h> |
20 | #include <asm/reg_a2.h> | ||
20 | #include <asm/exception-64e.h> | 21 | #include <asm/exception-64e.h> |
21 | #include <asm/bug.h> | 22 | #include <asm/bug.h> |
22 | #include <asm/irqflags.h> | 23 | #include <asm/irqflags.h> |
@@ -951,6 +952,22 @@ a2_tlbinit_after_linear_map: | |||
951 | .globl a2_tlbinit_after_iprot_flush | 952 | .globl a2_tlbinit_after_iprot_flush |
952 | a2_tlbinit_after_iprot_flush: | 953 | a2_tlbinit_after_iprot_flush: |
953 | 954 | ||
955 | #ifdef CONFIG_PPC_EARLY_DEBUG_WSP | ||
956 | /* Now establish early debug mappings if applicable */ | ||
957 | /* Restore the MAS0 we used for linear mapping load */ | ||
958 | mtspr SPRN_MAS0,r11 | ||
959 | |||
960 | lis r3,(MAS1_VALID | MAS1_IPROT)@h | ||
961 | ori r3,r3,(BOOK3E_PAGESZ_4K << MAS1_TSIZE_SHIFT) | ||
962 | mtspr SPRN_MAS1,r3 | ||
963 | LOAD_REG_IMMEDIATE(r3, WSP_UART_VIRT | MAS2_I | MAS2_G) | ||
964 | mtspr SPRN_MAS2,r3 | ||
965 | LOAD_REG_IMMEDIATE(r3, WSP_UART_PHYS | MAS3_SR | MAS3_SW) | ||
966 | mtspr SPRN_MAS7_MAS3,r3 | ||
967 | /* re-use the MAS8 value from the linear mapping */ | ||
968 | tlbwe | ||
969 | #endif /* CONFIG_PPC_EARLY_DEBUG_WSP */ | ||
970 | |||
954 | PPC_TLBILX(0,0,0) | 971 | PPC_TLBILX(0,0,0) |
955 | sync | 972 | sync |
956 | isync | 973 | isync |
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c index e39cad83c884..23d65abbedce 100644 --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c | |||
@@ -62,6 +62,8 @@ void __init udbg_early_init(void) | |||
62 | udbg_init_cpm(); | 62 | udbg_init_cpm(); |
63 | #elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO) | 63 | #elif defined(CONFIG_PPC_EARLY_DEBUG_USBGECKO) |
64 | udbg_init_usbgecko(); | 64 | udbg_init_usbgecko(); |
65 | #elif defined(CONFIG_PPC_EARLY_DEBUG_WSP) | ||
66 | udbg_init_wsp(); | ||
65 | #endif | 67 | #endif |
66 | 68 | ||
67 | #ifdef CONFIG_PPC_EARLY_DEBUG | 69 | #ifdef CONFIG_PPC_EARLY_DEBUG |
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c index baa33a7517bc..6837f839ab78 100644 --- a/arch/powerpc/kernel/udbg_16550.c +++ b/arch/powerpc/kernel/udbg_16550.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <asm/udbg.h> | 12 | #include <asm/udbg.h> |
13 | #include <asm/io.h> | 13 | #include <asm/io.h> |
14 | #include <asm/reg_a2.h> | ||
14 | 15 | ||
15 | extern u8 real_readb(volatile u8 __iomem *addr); | 16 | extern u8 real_readb(volatile u8 __iomem *addr); |
16 | extern void real_writeb(u8 data, volatile u8 __iomem *addr); | 17 | extern void real_writeb(u8 data, volatile u8 __iomem *addr); |
@@ -298,3 +299,53 @@ void __init udbg_init_40x_realmode(void) | |||
298 | udbg_getc_poll = NULL; | 299 | udbg_getc_poll = NULL; |
299 | } | 300 | } |
300 | #endif /* CONFIG_PPC_EARLY_DEBUG_40x */ | 301 | #endif /* CONFIG_PPC_EARLY_DEBUG_40x */ |
302 | |||
303 | #ifdef CONFIG_PPC_EARLY_DEBUG_WSP | ||
304 | static void udbg_wsp_flush(void) | ||
305 | { | ||
306 | if (udbg_comport) { | ||
307 | while ((readb(&udbg_comport->lsr) & LSR_THRE) == 0) | ||
308 | /* wait for idle */; | ||
309 | } | ||
310 | } | ||
311 | |||
312 | static void udbg_wsp_putc(char c) | ||
313 | { | ||
314 | if (udbg_comport) { | ||
315 | if (c == '\n') | ||
316 | udbg_wsp_putc('\r'); | ||
317 | udbg_wsp_flush(); | ||
318 | writeb(c, &udbg_comport->thr); eieio(); | ||
319 | } | ||
320 | } | ||
321 | |||
322 | static int udbg_wsp_getc(void) | ||
323 | { | ||
324 | if (udbg_comport) { | ||
325 | while ((readb(&udbg_comport->lsr) & LSR_DR) == 0) | ||
326 | ; /* wait for char */ | ||
327 | return readb(&udbg_comport->rbr); | ||
328 | } | ||
329 | return -1; | ||
330 | } | ||
331 | |||
332 | static int udbg_wsp_getc_poll(void) | ||
333 | { | ||
334 | if (udbg_comport) | ||
335 | if (readb(&udbg_comport->lsr) & LSR_DR) | ||
336 | return readb(&udbg_comport->rbr); | ||
337 | return -1; | ||
338 | } | ||
339 | |||
340 | void __init udbg_init_wsp(void) | ||
341 | { | ||
342 | udbg_comport = (struct NS16550 __iomem *)WSP_UART_VIRT; | ||
343 | |||
344 | udbg_init_uart(udbg_comport, 57600, 50000000); | ||
345 | |||
346 | udbg_putc = udbg_wsp_putc; | ||
347 | udbg_flush = udbg_wsp_flush; | ||
348 | udbg_getc = udbg_wsp_getc; | ||
349 | udbg_getc_poll = udbg_wsp_getc_poll; | ||
350 | } | ||
351 | #endif /* CONFIG_PPC_EARLY_DEBUG_WSP */ | ||