]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-davinci/include/mach/debug-macro.S
arm: return both physical and virtual addresses from addruart
[net-next-2.6.git] / arch / arm / mach-davinci / include / mach / debug-macro.S
CommitLineData
7c6337e2
KH
1/*
2 * Debugging macro for DaVinci
3 *
4 * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
5 *
6 * 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
17eb1570
C
12/* Modifications
13 * Jan 2009 Chaithrika U S Added senduart, busyuart, waituart
14 * macros, based on debug-8250.S file
15 * but using 32-bit accesses required for
16 * some davinci devices.
17 */
18
19#include <linux/serial_reg.h>
dc2eb76c
CC
20
21#include <asm/memory.h>
22
23#include <mach/serial.h>
24
17eb1570
C
25#define UART_SHIFT 2
26
dc2eb76c
CC
27 .pushsection .data
28davinci_uart_phys: .word 0
29davinci_uart_virt: .word 0
30 .popsection
31
0ea12930 32 .macro addruart, rp, rv
dc2eb76c
CC
33
34 /* Use davinci_uart_phys/virt if already configured */
0ea12930
JK
3510: mrc p15, 0, \rp, c1, c0
36 tst \rp, #1 @ MMU enabled?
37 ldreq \rp, =__virt_to_phys(davinci_uart_phys)
38 ldrne \rp, =davinci_uart_phys
39 add \rv, \rp, #4 @ davinci_uart_virt
40 ldr \rp, [\rp, #0]
41 ldr \rv, [\rv, #0]
42 cmp \rp, #0 @ is port configured?
43 cmpne \rv, #0
dc2eb76c
CC
44 bne 99f @ already configured
45
0ea12930
JK
46 /* Check the debug UART address set in uncompress.h */
47 mrc p15, 0, \rp, c1, c0
48 tst \rp, #1 @ MMU enabled?
dc2eb76c
CC
49
50 /* Copy uart phys address from decompressor uart info */
0ea12930
JK
51 ldreq \rv, =__virt_to_phys(davinci_uart_phys)
52 ldrne \rv, =davinci_uart_phys
53 ldreq \rp, =DAVINCI_UART_INFO
54 ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
55 ldr \rp, [\rp, #0]
56 str \rp, [\rv]
dc2eb76c
CC
57
58 /* Copy uart virt address from decompressor uart info */
0ea12930
JK
59 ldreq \rv, =__virt_to_phys(davinci_uart_virt)
60 ldrne \rv, =davinci_uart_virt
61 ldreq \rp, =DAVINCI_UART_INFO
62 ldrne \rp, =__phys_to_virt(DAVINCI_UART_INFO)
63 ldr \rp, [\rp, #4]
64 str \rp, [\rv]
dc2eb76c
CC
65
66 b 10b
6799:
7c6337e2
KH
68 .endm
69
17eb1570
C
70 .macro senduart,rd,rx
71 str \rd, [\rx, #UART_TX << UART_SHIFT]
72 .endm
73
74 .macro busyuart,rd,rx
751002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
76 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
77 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
78 bne 1002b
79 .endm
80
81 .macro waituart,rd,rx
82#ifdef FLOW_CONTROL
831001: ldr \rd, [\rx, #UART_MSR << UART_SHIFT]
84 tst \rd, #UART_MSR_CTS
85 beq 1001b
86#endif
87 .endm
88