1 /* arch/arm/mach-omap2/include/mach/debug-macro.S
3 * Debugging macro include header
5 * Copyright (C) 1994-1999 Russell King
6 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
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.
14 #include <linux/serial_reg.h>
16 #include <asm/memory.h>
18 #include <plat/serial.h>
20 #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
23 omap_uart_phys: .word 0
24 omap_uart_virt: .word 0
25 omap_uart_lsr: .word 0
29 * Note that this code won't work if the bootloader passes
30 * a wrong machine ID number in r1. To debug, just hardcode
31 * the desired UART phys and virt addresses temporarily into
32 * the omap_uart_phys and omap_uart_virt above.
34 .macro addruart, rp, rv
36 /* Use omap_uart_phys/virt if already configured */
37 10: mrc p15, 0, \rp, c1, c0
38 tst \rp, #1 @ MMU enabled?
39 ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
40 ldrne \rp, =omap_uart_phys @ MMU enabled
41 add \rv, \rp, #4 @ omap_uart_virt
44 cmp \rp, #0 @ is port configured?
46 bne 99f @ already configured
48 /* Check the debug UART configuration set in uncompress.h */
49 mrc p15, 0, \rp, c1, c0
50 tst \rp, #1 @ MMU enabled?
51 ldreq \rp, =OMAP_UART_INFO @ MMU not enabled
52 ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled
55 /* Select the UART to use based on the UART1 scratchpad value */
56 cmp \rp, #0 @ no port configured?
57 beq 21f @ if none, try to use UART1
58 cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1
59 beq 21f @ configure OMAP2/3/4UART1
60 cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2
61 beq 22f @ configure OMAP2/3/4UART2
62 cmp \rp, #OMAP2UART3 @ only on 24xx
63 beq 23f @ configure OMAP2UART3
64 cmp \rp, #OMAP3UART3 @ only on 34xx
65 beq 33f @ configure OMAP3UART3
66 cmp \rp, #OMAP4UART3 @ only on 44xx
67 beq 43f @ configure OMAP4UART3
68 cmp \rp, #OMAP3UART4 @ only on 36xx
69 beq 34f @ configure OMAP3UART4
70 cmp \rp, #OMAP4UART4 @ only on 44xx
71 beq 44f @ configure OMAP4UART4
72 cmp \rp, #ZOOM_UART @ only on zoom2/3
73 beq 95f @ configure ZOOM_UART
75 /* Configure the UART offset from the phys/virt base */
76 21: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
78 22: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
80 23: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
82 33: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
83 add \rp, \rp, #0x00fb0000
84 add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
86 34: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
87 add \rp, \rp, #0x00fb0000
88 add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
90 43: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
92 44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
94 95: ldr \rp, =ZOOM_UART_BASE
95 mrc p15, 0, \rv, c1, c0
96 tst \rv, #1 @ MMU enabled?
97 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
98 ldrne \rv, =omap_uart_phys @ MMU enabled
100 ldr \rp, =ZOOM_UART_VIRT
101 add \rv, \rv, #4 @ omap_uart_virt
103 mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
104 add \rv, \rv, #4 @ omap_uart_lsr
108 /* Store both phys and virt address for the uart */
109 98: add \rp, \rp, #0x48000000 @ phys base
110 mrc p15, 0, \rv, c1, c0
111 tst \rv, #1 @ MMU enabled?
112 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
113 ldrne \rv, =omap_uart_phys @ MMU enabled
115 sub \rp, \rp, #0x48000000 @ phys base
116 add \rp, \rp, #0xfa000000 @ virt base
117 add \rv, \rv, #4 @ omap_uart_virt
119 mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
120 add \rv, \rv, #4 @ omap_uart_lsr
127 .macro senduart,rd,rx
131 .macro busyuart,rd,rx
132 1001: mrc p15, 0, \rd, c1, c0
133 tst \rd, #1 @ MMU enabled?
134 ldreq \rd, =__virt_to_phys(omap_uart_lsr) @ MMU not enabled
135 ldrne \rd, =omap_uart_lsr @ MMU enabled
138 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
139 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
143 .macro waituart,rd,rx