Merge branch 'v2.6.34-rc7.iommu' of git://gitorious.org/~doyu/lk/mainline into omap...
[pandora-kernel.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 <asm/memory.h>
17
18 #include <plat/serial.h>
19
20                 .pushsection .data
21 omap_uart_phys: .word   0x0
22 omap_uart_virt: .word   0x0
23                 .popsection
24
25                 /*
26                  * Note that this code won't work if the bootloader passes
27                  * a wrong machine ID number in r1. To debug, just hardcode
28                  * the desired UART phys and virt addresses temporarily into
29                  * the omap_uart_phys and omap_uart_virt above.
30                  */
31                 .macro  addruart, rx, tmp
32
33                 /* Use omap_uart_phys/virt if already configured */
34 9:              mrc     p15, 0, \rx, c1, c0
35                 tst     \rx, #1                 @ MMU enabled?
36                 ldreq   \rx, =omap_uart_phys    @ physical base address
37                 ldrne   \rx, =omap_uart_virt    @ virtual base
38                 ldr     \rx, [\rx, #0]
39                 cmp     \rx, #0                 @ is port configured?
40                 bne     99f                     @ already configured
41
42                 /* Check the debug UART configuration set in uncompress.h */
43                 mrc     p15, 0, \rx, c1, c0
44                 tst     \rx, #1                 @ MMU enabled?
45                 ldreq   \rx, =OMAP_UART_INFO
46                 ldrne   \rx, =__phys_to_virt(OMAP_UART_INFO)
47                 ldr     \rx, [\rx, #0]
48
49                 /* Select the UART to use based on the UART1 scratchpad value */
50 10:             cmp     \rx, #0                 @ no port configured?
51                 beq     11f                     @ if none, try to use UART1
52                 cmp     \rx, #OMAP1UART1
53                 beq     11f                     @ configure OMAP1UART1
54                 cmp     \rx, #OMAP1UART2
55                 beq     12f                     @ configure OMAP1UART2
56                 cmp     \rx, #OMAP1UART3
57                 beq     13f                     @ configure OMAP2UART3
58
59                 /* Configure the UART offset from the phys/virt base */
60 11:             mov     \rx, #0x00fb0000        @ OMAP1UART1
61                 b       98f
62 12:             mov     \rx, #0x00fb0000        @ OMAP1UART1
63                 orr     \rx, \rx, #0x00000800   @ OMAP1UART2
64                 b       98f
65 13:             mov     \rx, #0x00fb0000        @ OMAP1UART1
66                 orr     \rx, \rx, #0x00000800   @ OMAP1UART2
67                 orr     \rx, \rx, #0x00009000   @ OMAP1UART3
68
69                 /* Store both phys and virt address for the uart */
70 98:             add     \rx, \rx, #0xff000000   @ phys base
71                 ldr     \tmp, =omap_uart_phys
72                 str     \rx, [\tmp, #0]
73                 sub     \rx, \rx, #0xff000000   @ phys base
74                 add     \rx, \rx, #0xfe000000   @ virt base
75                 ldr     \tmp, =omap_uart_virt
76                 str     \rx, [\tmp, #0]
77                 b       9b
78 99:
79                 .endm
80
81                 .macro  senduart,rd,rx
82                 strb    \rd, [\rx]
83                 .endm
84
85                 .macro  busyuart,rd,rx
86 1001:           ldrb    \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
87                 and     \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
88                 teq     \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
89                 beq     1002f
90                 ldrb    \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
91                 and     \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
92                 teq     \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
93                 bne     1001b
94 1002:
95                 .endm
96
97                 .macro  waituart,rd,rx
98                 .endm