Merge branch 'x86-pat-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / arch / arm / mach-omap2 / include / mach / debug-macro.S
1 /* arch/arm/mach-omap2/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 #define UART_OFFSET(addr)       ((addr) & 0x00ffffff)
19
20                 .pushsection .data
21 omap_uart_phys: .word   0
22 omap_uart_virt: .word   0
23 omap_uart_lsr:  .word   0
24                 .popsection
25
26                 /*
27                  * Note that this code won't work if the bootloader passes
28                  * a wrong machine ID number in r1. To debug, just hardcode
29                  * the desired UART phys and virt addresses temporarily into
30                  * the omap_uart_phys and omap_uart_virt above.
31                  */
32                 .macro  addruart, rx, tmp
33
34                 /* Use omap_uart_phys/virt if already configured */
35 10:             mrc     p15, 0, \rx, c1, c0
36                 tst     \rx, #1                 @ MMU enabled?
37                 ldreq   \rx, =omap_uart_phys    @ physical base address
38                 ldrne   \rx, =omap_uart_virt    @ virtual base address
39                 ldr     \rx, [\rx, #0]
40                 cmp     \rx, #0                 @ is port configured?
41                 bne     99f                     @ already configured
42
43                 /* Check UART1 scratchpad register for uart to use */
44                 mrc     p15, 0, \rx, c1, c0
45                 tst     \rx, #1                 @ MMU enabled?
46                 moveq   \rx, #0x48000000        @ physical base address
47                 movne   \rx, #0xfa000000        @ virtual base
48                 orr     \rx, \rx, #0x0006a000   @ uart1 on omap2/3/4
49                 ldrb    \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)] @ scratchpad
50
51                 /* Select the UART to use based on the UART1 scratchpad value */
52                 cmp     \rx, #0                 @ no port configured?
53                 beq     21f                     @ if none, try to use UART1
54                 cmp     \rx, #OMAP2UART1        @ OMAP2/3/4UART1
55                 beq     21f                     @ configure OMAP2/3/4UART1
56                 cmp     \rx, #OMAP2UART2        @ OMAP2/3/4UART2
57                 beq     22f                     @ configure OMAP2/3/4UART2
58                 cmp     \rx, #OMAP2UART3        @ only on 24xx
59                 beq     23f                     @ configure OMAP2UART3
60                 cmp     \rx, #OMAP3UART3        @ only on 34xx
61                 beq     33f                     @ configure OMAP3UART3
62                 cmp     \rx, #OMAP4UART3        @ only on 44xx
63                 beq     43f                     @ configure OMAP4UART3
64                 cmp     \rx, #OMAP3UART4        @ only on 36xx
65                 beq     34f                     @ configure OMAP3UART4
66                 cmp     \rx, #OMAP4UART4        @ only on 44xx
67                 beq     44f                     @ configure OMAP4UART4
68                 cmp     \rx, #ZOOM_UART         @ only on zoom2/3
69                 beq     95f                     @ configure ZOOM_UART
70
71                 /* Configure the UART offset from the phys/virt base */
72 21:             mov     \rx, #UART_OFFSET(OMAP2_UART1_BASE)     @ omap2/3/4
73                 b       98f
74 22:             mov     \rx, #UART_OFFSET(OMAP2_UART2_BASE)     @ omap2/3/4
75                 b       98f
76 23:             mov     \rx, #UART_OFFSET(OMAP2_UART3_BASE)
77                 b       98f
78 33:             mov     \rx, #UART_OFFSET(OMAP3_UART1_BASE)
79                 add     \rx, \rx, #0x00fb0000
80                 add     \rx, \rx, #0x00006000           @ OMAP3_UART3_BASE
81                 b       98f
82 34:             mov     \rx, #UART_OFFSET(OMAP3_UART1_BASE)
83                 add     \rx, \rx, #0x00fb0000
84                 add     \rx, \rx, #0x00028000           @ OMAP3_UART4_BASE
85                 b       98f
86 43:             mov     \rx, #UART_OFFSET(OMAP4_UART3_BASE)
87                 b       98f
88 44:             mov     \rx, #UART_OFFSET(OMAP4_UART4_BASE)
89                 b       98f
90 95:             mov     \rx, #ZOOM_UART_BASE
91                 ldr     \tmp, =omap_uart_phys
92                 str     \rx, [\tmp, #0]
93                 mov     \rx, #ZOOM_UART_VIRT
94                 ldr     \tmp, =omap_uart_virt
95                 str     \rx, [\tmp, #0]
96                 mov     \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
97                 ldr     \tmp, =omap_uart_lsr
98                 str     \rx, [\tmp, #0]
99                 b       10b
100
101                 /* Store both phys and virt address for the uart */
102 98:             add     \rx, \rx, #0x48000000   @ phys base
103                 ldr     \tmp, =omap_uart_phys
104                 str     \rx, [\tmp, #0]
105                 sub     \rx, \rx, #0x48000000   @ phys base
106                 add     \rx, \rx, #0xfa000000   @ virt base
107                 ldr     \tmp, =omap_uart_virt
108                 str     \rx, [\tmp, #0]
109                 mov     \rx, #(UART_LSR << OMAP_PORT_SHIFT)
110                 ldr     \tmp, =omap_uart_lsr
111                 str     \rx, [\tmp, #0]
112
113                 b       10b
114 99:
115                 .endm
116
117                 .macro  senduart,rd,rx
118                 strb    \rd, [\rx]
119                 .endm
120
121                 .macro  busyuart,rd,rx
122 1001:           ldr     \rd, =omap_uart_lsr
123                 ldr     \rd, [\rd, #0]
124                 ldrb    \rd, [\rx, \rd]
125                 and     \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
126                 teq     \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
127                 bne     1001b
128                 .endm
129
130                 .macro  waituart,rd,rx
131                 .endm