Merge branch 'for_linus' of git://cavan.codon.org.uk/platform-drivers-x86
[pandora-kernel.git] / arch / arm / mach-davinci / include / mach / debug-macro.S
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
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>
20
21 #include <mach/serial.h>
22
23 #define UART_SHIFT      2
24
25                 .pushsection .data
26 davinci_uart_phys:      .word   0
27 davinci_uart_virt:      .word   0
28                 .popsection
29
30                 .macro addruart, rp, rv, tmp
31
32                 /* Use davinci_uart_phys/virt if already configured */
33 10:             adr     \rp, 99f                @ get effective addr of 99f
34                 ldr     \rv, [\rp]              @ get absolute addr of 99f
35                 sub     \rv, \rv, \rp           @ offset between the two
36                 ldr     \rp, [\rp, #4]          @ abs addr of omap_uart_phys
37                 sub     \tmp, \rp, \rv          @ make it effective
38                 ldr     \rp, [\tmp, #0]         @ davinci_uart_phys
39                 ldr     \rv, [\tmp, #4]         @ davinci_uart_virt
40                 cmp     \rp, #0                 @ is port configured?
41                 cmpne   \rv, #0
42                 bne     100f                    @ already configured
43
44                 /* Check the debug UART address set in uncompress.h */
45                 and     \rp, pc, #0xff000000
46                 ldr     \rv, =DAVINCI_UART_INFO_OFS
47                 add     \rp, \rp, \rv
48
49                 /* Copy uart phys address from decompressor uart info */
50                 ldr     \rv, [\rp, #0]
51                 str     \rv, [\tmp, #0]
52
53                 /* Copy uart virt address from decompressor uart info */
54                 ldr     \rv, [\rp, #4]
55                 str     \rv, [\tmp, #4]
56
57                 b       10b
58
59                 .align
60 99:             .word   .
61                 .word   davinci_uart_phys
62                 .ltorg
63
64 100:
65                 .endm
66
67                 .macro  senduart,rd,rx
68                 str     \rd, [\rx, #UART_TX << UART_SHIFT]
69                 .endm
70
71                 .macro  busyuart,rd,rx
72 1002:           ldr     \rd, [\rx, #UART_LSR << UART_SHIFT]
73                 and     \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
74                 teq     \rd, #UART_LSR_TEMT | UART_LSR_THRE
75                 bne     1002b
76                 .endm
77
78                 .macro  waituart,rd,rx
79 #ifdef FLOW_CONTROL
80 1001:           ldr     \rd, [\rx, #UART_MSR << UART_SHIFT]
81                 tst     \rd, #UART_MSR_CTS
82                 beq     1001b
83 #endif
84                 .endm
85