]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - arch/arm/mach-omap2/include/mach/debug-macro.S
arm: return both physical and virtual addresses from addruart
[mirror_ubuntu-artful-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 <asm/memory.h>
17
18 #include <plat/serial.h>
19
20 #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
21
22 .pushsection .data
23 omap_uart_phys: .word 0
24 omap_uart_virt: .word 0
25 omap_uart_lsr: .word 0
26 .popsection
27
28 /*
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.
33 */
34 .macro addruart, rp, rv
35
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
42 ldr \rp, [\rp, #0]
43 ldr \rv, [\rv, #0]
44 cmp \rp, #0 @ is port configured?
45 cmpne \rv, #0
46 bne 99f @ already configured
47
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
53 ldr \rp, [\rp, #0]
54
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
74
75 /* Configure the UART offset from the phys/virt base */
76 21: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
77 b 98f
78 22: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
79 b 98f
80 23: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
81 b 98f
82 33: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
83 add \rp, \rp, #0x00fb0000
84 add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
85 b 98f
86 34: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
87 add \rp, \rp, #0x00fb0000
88 add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
89 b 98f
90 43: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
91 b 98f
92 44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
93 b 98f
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
99 str \rp, [\rv, #0]
100 ldr \rp, =ZOOM_UART_VIRT
101 add \rv, \rv, #4 @ omap_uart_virt
102 str \rp, [\rv, #0]
103 mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
104 add \rv, \rv, #4 @ omap_uart_lsr
105 str \rp, [\rv, #0]
106 b 10b
107
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
114 str \rp, [\rv, #0]
115 sub \rp, \rp, #0x48000000 @ phys base
116 add \rp, \rp, #0xfa000000 @ virt base
117 add \rv, \rv, #4 @ omap_uart_virt
118 str \rp, [\rv, #0]
119 mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
120 add \rv, \rv, #4 @ omap_uart_lsr
121 str \rp, [\rv, #0]
122
123 b 10b
124 99:
125 .endm
126
127 .macro senduart,rd,rx
128 strb \rd, [\rx]
129 .endm
130
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
136 ldr \rd, [\rd, #0]
137 ldrb \rd, [\rx, \rd]
138 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
139 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
140 bne 1001b
141 .endm
142
143 .macro waituart,rd,rx
144 .endm