Commit | Line | Data |
---|---|---|
aca59b89 | 1 | /* arch/arm/mach-omap2/include/mach/debug-macro.S |
1da177e4 LT |
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 | ||
4f2c49fe TL |
14 | #include <linux/serial_reg.h> |
15 | ||
96554d70 TL |
16 | #include <asm/memory.h> |
17 | ||
4f2c49fe TL |
18 | #include <plat/serial.h> |
19 | ||
0c8219f0 TL |
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 | */ | |
0ea12930 | 34 | .macro addruart, rp, rv |
0c8219f0 TL |
35 | |
36 | /* Use omap_uart_phys/virt if already configured */ | |
0ea12930 JK |
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 | |
0c8219f0 TL |
46 | bne 99f @ already configured |
47 | ||
96554d70 | 48 | /* Check the debug UART configuration set in uncompress.h */ |
0ea12930 JK |
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] | |
0c8219f0 TL |
54 | |
55 | /* Select the UART to use based on the UART1 scratchpad value */ | |
0ea12930 | 56 | cmp \rp, #0 @ no port configured? |
0c8219f0 | 57 | beq 21f @ if none, try to use UART1 |
0ea12930 | 58 | cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1 |
0c8219f0 | 59 | beq 21f @ configure OMAP2/3/4UART1 |
0ea12930 | 60 | cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2 |
0c8219f0 | 61 | beq 22f @ configure OMAP2/3/4UART2 |
0ea12930 | 62 | cmp \rp, #OMAP2UART3 @ only on 24xx |
0c8219f0 | 63 | beq 23f @ configure OMAP2UART3 |
0ea12930 | 64 | cmp \rp, #OMAP3UART3 @ only on 34xx |
0c8219f0 | 65 | beq 33f @ configure OMAP3UART3 |
0ea12930 | 66 | cmp \rp, #OMAP4UART3 @ only on 44xx |
0c8219f0 | 67 | beq 43f @ configure OMAP4UART3 |
0ea12930 | 68 | cmp \rp, #OMAP3UART4 @ only on 36xx |
0c8219f0 | 69 | beq 34f @ configure OMAP3UART4 |
0ea12930 | 70 | cmp \rp, #OMAP4UART4 @ only on 44xx |
0c8219f0 | 71 | beq 44f @ configure OMAP4UART4 |
0ea12930 | 72 | cmp \rp, #ZOOM_UART @ only on zoom2/3 |
0c8219f0 TL |
73 | beq 95f @ configure ZOOM_UART |
74 | ||
75 | /* Configure the UART offset from the phys/virt base */ | |
0ea12930 | 76 | 21: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4 |
0c8219f0 | 77 | b 98f |
0ea12930 | 78 | 22: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4 |
0c8219f0 | 79 | b 98f |
0ea12930 | 80 | 23: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE) |
0c8219f0 | 81 | b 98f |
0ea12930 JK |
82 | 33: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE) |
83 | add \rp, \rp, #0x00fb0000 | |
84 | add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE | |
0c8219f0 | 85 | b 98f |
0ea12930 JK |
86 | 34: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE) |
87 | add \rp, \rp, #0x00fb0000 | |
88 | add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE | |
0c8219f0 | 89 | b 98f |
0ea12930 | 90 | 43: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE) |
0c8219f0 | 91 | b 98f |
0ea12930 | 92 | 44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE) |
0c8219f0 | 93 | b 98f |
0ea12930 JK |
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] | |
0c8219f0 TL |
106 | b 10b |
107 | ||
108 | /* Store both phys and virt address for the uart */ | |
0ea12930 JK |
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] | |
0c8219f0 TL |
122 | |
123 | b 10b | |
124 | 99: | |
1da177e4 LT |
125 | .endm |
126 | ||
127 | .macro senduart,rd,rx | |
128 | strb \rd, [\rx] | |
129 | .endm | |
130 | ||
131 | .macro busyuart,rd,rx | |
7e788b42 | 132 | 1001: mrc p15, 0, \rd, c1, c0 |
0ea12930 JK |
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 | |
0c8219f0 TL |
136 | ldr \rd, [\rd, #0] |
137 | ldrb \rd, [\rx, \rd] | |
4f2c49fe TL |
138 | and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE) |
139 | teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE) | |
1da177e4 | 140 | bne 1001b |
1da177e4 LT |
141 | .endm |
142 | ||
143 | .macro waituart,rd,rx | |
144 | .endm |