Commit 0ea12930 authored by Jeremy Kerr's avatar Jeremy Kerr Committed by Nicolas Pitre
Browse files

arm: return both physical and virtual addresses from addruart


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: default avatarJeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: default avatarJason Wang <jason77.wang@gmail.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Tested-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 1ea64615
......@@ -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)
......@@ -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
*/
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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>
......@@ -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:
......
......@@ -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
......
......@@ -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
......
......@@ -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>
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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>
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -12,13 +12,12 @@
*/
#include <mach/ixp23xx.h>
.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ mmu enabled?
ldreq \rx, =IXP23XX_PERIPHERAL_PHYS @ physical
ldrne \rx, =IXP23XX_PERIPHERAL_VIRT @ virtual
.macro addruart, rp, rv
ldr \rp, =IXP23XX_PERIPHERAL_PHYS @ physical
ldr \rv, =IXP23XX_PERIPHERAL_VIRT @ virtual
#ifdef __ARMEB__
orr \rx, \rx, #0x00000003
orr \rp, \rp, #0x00000003
orr \rv, \rv, #0x00000003
#endif
.endm
......
......@@ -10,16 +10,16 @@
* published by the Free Software Foundation.
*/
.macro addruart, rx, tmp
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0xc8000000
movne \rx, #0xff000000
orrne \rx, \rx, #0x00b00000
.macro addruart, rp, rv
#ifdef __ARMEB__
add \rx,\rx,#3 @ Uart regs are at off set of 3 if
@ byte writes used - Big Endian.
mov \rp, #3 @ Uart regs are at off set of 3 if
@ byte writes used - Big Endian.
#else
mov \rp, #0
#endif
orr \rv, \rp, #0xff000000 @ virtual
orr \rv, \rv, #0x00b00000
orr \rp, \rp, #0xc8000000 @ physical
.endm
#define UART_SHIFT 2
......
......@@ -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, =KIRKWOOD_REGS_PHYS_BASE
ldrne \rx, =KIRKWOOD_REGS_VIRT_BASE
orr \rx, \rx, #0x00012000
.macro addruart, rp, rv
ldr \rp, =KIRKWOOD_REGS_PHYS_BASE
ldr \rv, =KIRKWOOD_REGS_VIRT_BASE
orr \rp, \rp, #0x00012000
orr \rv, \rv, #0x00012000
.endm
#define UART_SHIFT 2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment