Skip to content

Commit

Permalink
arm: return both physical and virtual addresses from addruart
Browse files Browse the repository at this point in the history
Rather than checking the MMU status in every instance of addruart, do it
once in kernel/debug.S, and change the existing addruart macros to
return both physical and virtual addresses. The main debug code can then
select the appropriate address to use.

This will also allow us to retreive the address of a uart for the MMU
state that we're not current in.

Updated with fixes for OMAP from Jason Wang <jason77.wang@gmail.com>
and Tony Lindgren <tony@atomide.com>, and fix for versatile express from
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>.

Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Jason Wang <jason77.wang@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Tested-by: Kevin Hilman <khilman@deeprootsystems.com>
  • Loading branch information
Jeremy Kerr authored and npitre committed Oct 20, 2010
1 parent 1ea6461 commit 0ea1293
Show file tree
Hide file tree
Showing 56 changed files with 440 additions and 454 deletions.
22 changes: 19 additions & 3 deletions arch/arm/kernel/debug.S
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#if defined(CONFIG_DEBUG_ICEDCC)
@@ debug using ARM EmbeddedICE DCC channel

.macro addruart, rx, tmp
.macro addruart, rp, rv
.endm

#if defined(CONFIG_CPU_V6)
Expand Down Expand Up @@ -121,6 +121,22 @@ wait: mrc p14, 0, pc, c0, c1, 0
#include <mach/debug-macro.S>
#endif /* CONFIG_DEBUG_ICEDCC */

#ifdef CONFIG_MMU
.macro addruart_current, rx, tmp1, tmp2
addruart \tmp1, \tmp2
mrc p15, 0, \rx, c1, c0
tst \rx, #1
moveq \rx, \tmp1
movne \rx, \tmp2
.endm

#else /* !CONFIG_MMU */
.macro addruart_current, rx, tmp1, tmp2
addruart \rx, \tmp1
.endm

#endif /* CONFIG_MMU */

/*
* Useful debugging routines
*/
Expand Down Expand Up @@ -155,7 +171,7 @@ ENDPROC(printhex2)
.ltorg

ENTRY(printascii)
addruart r3, r1
addruart_current r3, r1, r2
b 2f
1: waituart r2, r3
senduart r1, r3
Expand All @@ -171,7 +187,7 @@ ENTRY(printascii)
ENDPROC(printascii)

ENTRY(printch)
addruart r3, r1
addruart_current r3, r1, r2
mov r1, r0
mov r0, #0
b 1b
Expand Down
10 changes: 4 additions & 6 deletions arch/arm/mach-aaec2000/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
*/

#include "hardware.h"
.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x80000000 @ physical
movne \rx, #io_p2v(0x80000000) @ virtual
orr \rx, \rx, #0x00000800
.macro addruart, rp, rv
mov \rp, 0x00000800
orr \rv, \rp, #io_p2v(0x80000000) @ virtual
orr \rp, \rp, #0x80000000 @ physical
.endm

.macro senduart,rd,rx
Expand Down
8 changes: 3 additions & 5 deletions arch/arm/mach-at91/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
#include <mach/hardware.h>
#include <mach/at91_dbgu.h>

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =(AT91_BASE_SYS + AT91_DBGU) @ System peripherals (phys address)
ldrne \rx, =(AT91_VA_BASE_SYS + AT91_DBGU) @ System peripherals (virt address)
.macro addruart, rp, rv
ldr \rp, =(AT91_BASE_SYS + AT91_DBGU) @ System peripherals (phys address)
ldr \rv, =(AT91_VA_BASE_SYS + AT91_DBGU) @ System peripherals (virt address)
.endm

.macro senduart,rd,rx
Expand Down
12 changes: 5 additions & 7 deletions arch/arm/mach-clps711x/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
#include <mach/hardware.h>
#include <asm/hardware/clps7111.h>

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #CLPS7111_PHYS_BASE
movne \rx, #CLPS7111_VIRT_BASE
.macro addruart, rp, rv
#ifndef CONFIG_DEBUG_CLPS711X_UART2
add \rx, \rx, #0x0000 @ UART1
mov \rp, #0x0000 @ UART1
#else
add \rx, \rx, #0x1000 @ UART2
mov \rp, #0x1000 @ UART2
#endif
orr \rv, \rp, #CLPS7111_VIRT_BASE
orr \rp, \rp, #CLPS7111_PHYS_BASE
.endm

.macro senduart,rd,rx
Expand Down
10 changes: 4 additions & 6 deletions arch/arm/mach-cns3xxx/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
* published by the Free Software Foundation.
*/

.macro addruart,rx
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x10000000
movne \rx, #0xf0000000 @ virtual base
orr \rx, \rx, #0x00009000
.macro addruart,rp,rv
mov \rp, #0x00009000
orr \rv, \rp, #0xf0000000 @ virtual base
orr \rp, \rp, #0x10000000
.endm

#include <asm/hardware/debug-pl01x.S>
46 changes: 25 additions & 21 deletions arch/arm/mach-davinci/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,39 @@ davinci_uart_phys: .word 0
davinci_uart_virt: .word 0
.popsection

.macro addruart, rx, tmp
.macro addruart, rp, rv

/* Use davinci_uart_phys/virt if already configured */
10: mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =__virt_to_phys(davinci_uart_phys)
ldrne \rx, =davinci_uart_virt
ldr \rx, [\rx]
cmp \rx, #0 @ is port configured?
10: mrc p15, 0, \rp, c1, c0
tst \rp, #1 @ MMU enabled?
ldreq \rp, =__virt_to_phys(davinci_uart_phys)
ldrne \rp, =davinci_uart_phys
add \rv, \rp, #4 @ davinci_uart_virt
ldr \rp, [\rp, #0]
ldr \rv, [\rv, #0]
cmp \rp, #0 @ is port configured?
cmpne \rv, #0
bne 99f @ already configured

mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
/* Check the debug UART address set in uncompress.h */
mrc p15, 0, \rp, c1, c0
tst \rp, #1 @ MMU enabled?

/* Copy uart phys address from decompressor uart info */
ldreq \tmp, =__virt_to_phys(davinci_uart_phys)
ldrne \tmp, =davinci_uart_phys
ldreq \rx, =DAVINCI_UART_INFO
ldrne \rx, =__phys_to_virt(DAVINCI_UART_INFO)
ldr \rx, [\rx, #0]
str \rx, [\tmp]
ldreq \rv, =__virt_to_phys(davinci_uart_phys)
ldrne \rv, =davinci_uart_phys
ldreq \rp, =DAVINCI_UART_INFO
ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
ldr \rp, [\rp, #0]
str \rp, [\rv]

/* Copy uart virt address from decompressor uart info */
ldreq \tmp, =__virt_to_phys(davinci_uart_virt)
ldrne \tmp, =davinci_uart_virt
ldreq \rx, =DAVINCI_UART_INFO
ldrne \rx, =__phys_to_virt(DAVINCI_UART_INFO)
ldr \rx, [\rx, #4]
str \rx, [\tmp]
ldreq \rv, =__virt_to_phys(davinci_uart_virt)
ldrne \rv, =davinci_uart_virt
ldreq \rp, =DAVINCI_UART_INFO
ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
ldr \rp, [\rp, #4]
str \rp, [\rv]

b 10b
99:
Expand Down
11 changes: 5 additions & 6 deletions arch/arm/mach-dove/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@

#include <mach/bridge-regs.h>

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =DOVE_SB_REGS_PHYS_BASE
ldrne \rx, =DOVE_SB_REGS_VIRT_BASE
orr \rx, \rx, #0x00012000
.macro addruart, rp, rv
ldr \rp, =DOVE_SB_REGS_PHYS_BASE
ldr \rv, =DOVE_SB_REGS_VIRT_BASE
orr \rp, \rp, #0x00012000
orr \rv, \rv, #0x00012000
.endm

#define UART_SHIFT 2
Expand Down
7 changes: 4 additions & 3 deletions arch/arm/mach-ebsa110/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
*
**/

.macro addruart, rx, tmp
mov \rx, #0xf0000000
orr \rx, \rx, #0x00000be0
.macro addruart, rp, rv
mov \rp, #0xf0000000
orr \rp, \rp, #0x00000be0
mov \rp, \rv
.endm

#define UART_SHIFT 2
Expand Down
11 changes: 5 additions & 6 deletions arch/arm/mach-ep93xx/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
*/
#include <mach/ep93xx-regs.h>

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =EP93XX_APB_PHYS_BASE @ Physical base
ldrne \rx, =EP93XX_APB_VIRT_BASE @ virtual base
orr \rx, \rx, #0x000c0000
.macro addruart, rp, rv
ldr \rp, =EP93XX_APB_PHYS_BASE @ Physical base
ldr \rv, =EP93XX_APB_VIRT_BASE @ virtual base
orr \rp, \rp, #0x000c0000
orr \rv, \rv, #0x000c0000
.endm

#include <asm/hardware/debug-pl01x.S>
22 changes: 10 additions & 12 deletions arch/arm/mach-footbridge/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@

#ifndef CONFIG_DEBUG_DC21285_PORT
/* For NetWinder debugging */
.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x7c000000 @ physical
movne \rx, #0xff000000 @ virtual
orr \rx, \rx, #0x000003f8
.macro addruart, rp, rv
mov \rp, #0x000003f8
orr \rv, \rp, #0x7c000000 @ physical
orr \rp, \rp, #0xff000000 @ virtual
.endm

#define UART_SHIFT 0
Expand All @@ -32,14 +30,14 @@
.equ dc21285_high, ARMCSR_BASE & 0xff000000
.equ dc21285_low, ARMCSR_BASE & 0x00ffffff

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x42000000
movne \rx, #dc21285_high
.macro addruart, rp, rv
.if dc21285_low
orrne \rx, \rx, #dc21285_low
mov \rp, #dc21285_low
.else
mov \rp, #0
.endif
orr \rv, \rp, #0x42000000
orr \rp, \rp, #dc21285_high
.endm

.macro senduart,rd,rx
Expand Down
8 changes: 3 additions & 5 deletions arch/arm/mach-gemini/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@
*/
#include <mach/hardware.h>

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =GEMINI_UART_BASE @ physical
ldrne \rx, =IO_ADDRESS(GEMINI_UART_BASE) @ virtual
.macro addruart, rp, rv
ldr \rp, =GEMINI_UART_BASE @ physical
ldr \rv, =IO_ADDRESS(GEMINI_UART_BASE) @ virtual
.endm

#define UART_SHIFT 2
Expand Down
10 changes: 4 additions & 6 deletions arch/arm/mach-h720x/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
.equ io_virt, IO_VIRT
.equ io_phys, IO_PHYS

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #io_phys @ physical base address
movne \rx, #io_virt @ virtual address
add \rx, \rx, #0x00020000 @ UART1
.macro addruart, rp, rv
mov \rp, #0x00020000 @ UART1
add \rv, \rp, #io_virt @ virtual address
add \rp, \rp, #io_phys @ physical base address
.endm

.macro senduart,rd,rx
Expand Down
10 changes: 4 additions & 6 deletions arch/arm/mach-integrator/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
*
*/

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0x16000000 @ physical base address
movne \rx, #0xf0000000 @ virtual base
addne \rx, \rx, #0x16000000 >> 4
.macro addruart, rp, rv
mov \rp, #0x16000000 @ physical base address
mov \rv, #0xf0000000 @ virtual base
add \rv, \rv, #0x16000000 >> 4
.endm

#include <asm/hardware/debug-pl01x.S>
16 changes: 7 additions & 9 deletions arch/arm/mach-iop13xx/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
* published by the Free Software Foundation.
*/

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ mmu enabled?
moveq \rx, #0xff000000 @ physical
orreq \rx, \rx, #0x00d80000
movne \rx, #0xfe000000 @ virtual
orrne \rx, \rx, #0x00e80000
orr \rx, \rx, #0x00002300
orr \rx, \rx, #0x00000040
.macro addruart, rp, rv
mov \rp, #0x00002300
orr \rp, \rp, #0x00000040
orr \rv, \rp, #0xfe000000 @ virtual
orr \rv, \rv, #0x00e80000
orr \rp, \rp, #0xff000000 @ physical
orr \rp, \rp, #0x00d80000
.endm

#define UART_SHIFT 2
Expand Down
7 changes: 4 additions & 3 deletions arch/arm/mach-iop32x/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
* published by the Free Software Foundation.
*/

.macro addruart, rx, tmp
mov \rx, #0xfe000000 @ physical as well as virtual
orr \rx, \rx, #0x00800000 @ location of the UART
.macro addruart, rp, rv
mov \rp, #0xfe000000 @ physical as well as virtual
orr \rp, \rp, #0x00800000 @ location of the UART
mov \rv, \rp
.endm

#define UART_SHIFT 0
Expand Down
12 changes: 5 additions & 7 deletions arch/arm/mach-iop33x/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
* published by the Free Software Foundation.
*/

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ mmu enabled?
moveq \rx, #0xff000000 @ physical
movne \rx, #0xfe000000 @ virtual
orr \rx, \rx, #0x00ff0000
orr \rx, \rx, #0x0000f700
.macro addruart, rp, rv
mov \rp, #0x00ff0000
orr \rp, \rp, #0x0000f700
orr \rv, #0xfe000000 @ virtual
orr \rp, #0xff000000 @ physical
.endm

#define UART_SHIFT 2
Expand Down
14 changes: 6 additions & 8 deletions arch/arm/mach-ixp2000/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@
*
*/

.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0xc0000000 @ Physical base
movne \rx, #0xfe000000 @ virtual base
orrne \rx, \rx, #0x00f00000
orr \rx, \rx, #0x00030000
.macro addruart, rp, rv
mov \rp, #0x00030000
#ifdef __ARMEB__
orr \rx, \rx, #0x00000003
orr \rp, \rp, #0x00000003
#endif
orr \rv, \rp, #0xfe000000 @ virtual base
orr \rv, \rv, #0x00f00000
orr \rp, \rp, #0xc0000000 @ Physical base
.endm

#define UART_SHIFT 2
Expand Down
Loading

0 comments on commit 0ea1293

Please sign in to comment.