Merge mainline (v2.6.34-rc7)
[sfrench/cifs-2.6.git] / arch / arm / mach-omap1 / include / mach / debug-macro.S
1 /* arch/arm/mach-omap1/include/mach/debug-macro.S
2  *
3  * Debugging macro include header
4  *
5  *  Copyright (C) 1994-1999 Russell King
6  *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  *
12 */
13
14 #include <linux/serial_reg.h>
15
16 #include <plat/serial.h>
17
18                 .pushsection .data
19 omap_uart_phys: .word   0x0
20 omap_uart_virt: .word   0x0
21                 .popsection
22
23                 /*
24                  * Note that this code won't work if the bootloader passes
25                  * a wrong machine ID number in r1. To debug, just hardcode
26                  * the desired UART phys and virt addresses temporarily into
27                  * the omap_uart_phys and omap_uart_virt above.
28                  */
29                 .macro  addruart, rx, tmp
30
31                 /* Use omap_uart_phys/virt if already configured */
32 9:              mrc     p15, 0, \rx, c1, c0
33                 tst     \rx, #1                 @ MMU enabled?
34                 ldreq   \rx, =omap_uart_phys    @ physical base address
35                 ldrne   \rx, =omap_uart_virt    @ virtual base
36                 ldr     \rx, [\rx, #0]
37                 cmp     \rx, #0                 @ is port configured?
38                 bne     99f                     @ already configured
39
40                 /* Check 7XX UART1 scratchpad register for uart to use */
41                 mrc     p15, 0, \rx, c1, c0
42                 tst     \rx, #1                 @ MMU enabled?
43                 moveq   \rx, #0xff000000        @ physical base address
44                 movne   \rx, #0xfe000000        @ virtual base
45                 orr     \rx, \rx, #0x00fb0000   @ OMAP1UART1
46                 ldrb    \rx, [\rx, #(UART_SCR << OMAP7XX_PORT_SHIFT)]
47                 cmp     \rx, #0                 @ anything in 7XX scratchpad?
48                 bne     10f                     @ found 7XX uart
49
50                 /* Check 15xx/16xx UART1 scratchpad register for uart to use */
51                 mrc     p15, 0, \rx, c1, c0
52                 tst     \rx, #1                 @ MMU enabled?
53                 moveq   \rx, #0xff000000        @ physical base address
54                 movne   \rx, #0xfe000000        @ virtual base
55                 orr     \rx, \rx, #0x00fb0000   @ OMAP1UART1
56                 ldrb    \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)]
57
58                 /* Select the UART to use based on the UART1 scratchpad value */
59 10:             cmp     \rx, #0                 @ no port configured?
60                 beq     11f                     @ if none, try to use UART1
61                 cmp     \rx, #OMAP1UART1
62                 beq     11f                     @ configure OMAP1UART1
63                 cmp     \rx, #OMAP1UART2
64                 beq     12f                     @ configure OMAP1UART2
65                 cmp     \rx, #OMAP1UART3
66                 beq     13f                     @ configure OMAP2UART3
67
68                 /* Configure the UART offset from the phys/virt base */
69 11:             mov     \rx, #0x00fb0000        @ OMAP1UART1
70                 b       98f
71 12:             mov     \rx, #0x00fb0000        @ OMAP1UART1
72                 orr     \rx, \rx, #0x00000800   @ OMAP1UART2
73                 b       98f
74 13:             mov     \rx, #0x00fb0000        @ OMAP1UART1
75                 orr     \rx, \rx, #0x00000800   @ OMAP1UART2
76                 orr     \rx, \rx, #0x00009000   @ OMAP1UART3
77
78                 /* Store both phys and virt address for the uart */
79 98:             add     \rx, \rx, #0xff000000   @ phys base
80                 ldr     \tmp, =omap_uart_phys
81                 str     \rx, [\tmp, #0]
82                 sub     \rx, \rx, #0xff000000   @ phys base
83                 add     \rx, \rx, #0xfe000000   @ virt base
84                 ldr     \tmp, =omap_uart_virt
85                 str     \rx, [\tmp, #0]
86                 b       9b
87 99:
88                 .endm
89
90                 .macro  senduart,rd,rx
91                 strb    \rd, [\rx]
92                 .endm
93
94                 .macro  busyuart,rd,rx
95 1001:           ldrb    \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
96                 and     \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
97                 teq     \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
98                 beq     1002f
99                 ldrb    \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
100                 and     \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
101                 teq     \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
102                 bne     1001b
103 1002:
104                 .endm
105
106                 .macro  waituart,rd,rx
107                 .endm