From: Jason Wang Date: Tue, 3 Aug 2010 13:03:53 +0300 Subject: [PATCH] omap: Fix DEBUG_LL uart to access phys addr when MMU isn't enable Now we use a memory address to store the debug port info, So we need to read/write this address when we choose DEBUG_LL. When MMU isn't enable(I.E. the begining part of init stage of the linux kernel boot), we need to access physical address instead of virtual address, otherwise the kernel will crash. Signed-off-by: Jason Wang [tony@atomide.com: updated to work with the addruart patches from Jeremy Kerr Signed-off-by: Tony Lindgren diff --git a/arch/arm/mach-omap1/include/mach/debug-macro.S b/arch/arm/mach-omap1/include/mach/debug-macro.S index 4a4dfde..6a0fa04 100644 --- a/arch/arm/mach-omap1/include/mach/debug-macro.S +++ b/arch/arm/mach-omap1/include/mach/debug-macro.S @@ -31,19 +31,22 @@ omap_uart_virt: .word 0x0 .macro addruart, rp, rv /* Use omap_uart_phys/virt if already configured */ -9: ldr \rp, =omap_uart_phys @ physical base address - ldr \rv, =omap_uart_virt @ virtual base +9: mrc p15, 0, \rp, c1, c0 + tst \rp, #1 @ MMU enabled? + ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled + ldrne \rp, =omap_uart_phys @ MMU enabled + add \rv, \rp, #4 @ omap_uart_virt ldr \rp, [\rp, #0] ldr \rv, [\rv, #0] cmp \rp, #0 @ is port configured? cmpne \rv, #0 bne 99f @ already configured - /* Check the debug UART configuration set in uncompress.h. - * We cheat a little here, in that we know that the first time - * we're called (to establish the debug mappings), the MMU is - * disabled. */ - ldr \rp, =OMAP_UART_INFO + /* Check the debug UART configuration set in uncompress.h */ + mrc p15, 0, \rp, c1, c0 + tst \rp, #1 @ MMU enabled? + ldreq \rp, =OMAP_UART_INFO @ MMU not enabled + ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled ldr \rp, [\rp, #0] /* Select the UART to use based on the UART1 scratchpad value */ @@ -68,12 +71,15 @@ omap_uart_virt: .word 0x0 /* Store both phys and virt address for the uart */ 98: add \rp, \rp, #0xff000000 @ phys base - ldr \rv, =omap_uart_phys + mrc p15, 0, \rv, c1, c0 + tst \rv, #1 @ MMU enabled? + ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled + ldrne \rv, =omap_uart_phys @ MMU enabled + str \rp, [\rv, #0] + sub \rp, \rp, #0xff000000 @ phys base + add \rp, \rp, #0xfe000000 @ virt base + add \rv, \rv, #4 @ omap_uart_lsr str \rp, [\rv, #0] - sub \rv, \rp, #0xff000000 @ phys base - add \rv, \rv, #0xfe000000 @ virt base - ldr \rp, =omap_uart_virt - str \rv, [\rp, #0] b 9b 99: .endm diff --git a/arch/arm/mach-omap2/include/mach/debug-macro.S b/arch/arm/mach-omap2/include/mach/debug-macro.S index 2714ad1..6a4d413 100644 --- a/arch/arm/mach-omap2/include/mach/debug-macro.S +++ b/arch/arm/mach-omap2/include/mach/debug-macro.S @@ -34,19 +34,22 @@ omap_uart_lsr: .word 0 .macro addruart, rp, rv /* Use omap_uart_phys/virt if already configured */ -10: ldr \rp, =omap_uart_phys @ physical base address - ldr \rv, =omap_uart_virt @ virtual base address +10: mrc p15, 0, \rp, c1, c0 + tst \rp, #1 @ MMU enabled? + ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled + ldrne \rp, =omap_uart_phys @ MMU enabled + add \rv, \rp, #4 @ omap_uart_virt ldr \rp, [\rp, #0] ldr \rv, [\rv, #0] cmp \rp, #0 @ is port configured? cmpne \rv, #0 bne 99f @ already configured - /* Check the debug UART configuration set in uncompress.h. - * We cheat a little here, in that we know that the first time - * we're called (to establish the debug mappings), the MMU is - * disabled. */ - ldr \rp, =OMAP_UART_INFO + /* Check the debug UART configuration set in uncompress.h */ + mrc p15, 0, \rp, c1, c0 + tst \rp, #1 @ MMU enabled? + ldreq \rp, =OMAP_UART_INFO @ MMU not enabled + ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled ldr \rp, [\rp, #0] /* Select the UART to use based on the UART1 scratchpad value */ @@ -89,26 +92,32 @@ omap_uart_lsr: .word 0 44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE) b 98f 95: ldr \rp, =ZOOM_UART_BASE - ldr \rv, =omap_uart_phys + mrc p15, 0, \rv, c1, c0 + tst \rv, #1 @ MMU enabled? + ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled + ldrne \rv, =omap_uart_phys @ MMU enabled str \rp, [\rv, #0] ldr \rp, =ZOOM_UART_VIRT - ldr \rv, =omap_uart_virt + add \rv, \rv, #4 @ omap_uart_virt str \rp, [\rv, #0] mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT) - ldr \rv, =omap_uart_lsr + add \rv, \rv, #4 @ omap_uart_lsr str \rp, [\rv, #0] b 10b /* Store both phys and virt address for the uart */ 98: add \rp, \rp, #0x48000000 @ phys base - ldr \rv, =omap_uart_phys + mrc p15, 0, \rv, c1, c0 + tst \rv, #1 @ MMU enabled? + ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled + ldrne \rv, =omap_uart_phys @ MMU enabled + str \rp, [\rv, #0] + sub \rp, \rp, #0x48000000 @ phys base + add \rp, \rp, #0xfa000000 @ virt base + add \rv, \rv, #4 @ omap_uart_virt str \rp, [\rv, #0] - sub \rv, \rp, #0x48000000 @ phys base - add \rv, \rv, #0xfa000000 @ virt base - ldr \rp, =omap_uart_virt - str \rv, [\rp, #0] mov \rp, #(UART_LSR << OMAP_PORT_SHIFT) - ldr \rv, =omap_uart_lsr + add \rv, \rv, #4 @ omap_uart_lsr str \rp, [\rv, #0] b 10b @@ -120,7 +129,10 @@ omap_uart_lsr: .word 0 .endm .macro busyuart,rd,rx -1001: ldr \rd, =omap_uart_lsr +1001: mrc p15, 0, \rd, c1, c0 + tst \rd, #1 @ MMU enabled? + ldreq \rd, =__virt_to_phys(omap_uart_lsr) @ MMU not enabled + ldrne \rd, =omap_uart_lsr @ MMU enabled ldr \rd, [\rd, #0] ldrb \rd, [\rx, \rd] and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)