blob: e1b0f17b092796172b0063a8f4b0391894e613de [file] [log] [blame]
Tony Lindgrenaca59b82009-10-19 17:26:17 -07001/* arch/arm/mach-omap2/include/mach/debug-macro.S
Russell Kinga09e64f2008-08-05 16:14:15 +01002 *
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
Tony Lindgren4f2c49f2010-02-15 08:48:53 -080014#include <linux/serial_reg.h>
15
Tony Lindgren96554d72010-04-30 17:39:19 -070016#include <asm/memory.h>
17
Tony Lindgren4f2c49f2010-02-15 08:48:53 -080018#include <plat/serial.h>
19
Tony Lindgren0c8219f2010-02-15 08:49:01 -080020#define UART_OFFSET(addr) ((addr) & 0x00ffffff)
21
22 .pushsection .data
23omap_uart_phys: .word 0
24omap_uart_virt: .word 0
25omap_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 */
Jeremy Kerr0ea12932010-07-06 18:30:06 +080034 .macro addruart, rp, rv
Tony Lindgren0c8219f2010-02-15 08:49:01 -080035
36 /* Use omap_uart_phys/virt if already configured */
Jeremy Kerr0ea12932010-07-06 18:30:06 +08003710: 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
Tony Lindgren0c8219f2010-02-15 08:49:01 -080046 bne 99f @ already configured
47
Tony Lindgren96554d72010-04-30 17:39:19 -070048 /* Check the debug UART configuration set in uncompress.h */
Jeremy Kerr0ea12932010-07-06 18:30:06 +080049 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]
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030054
Tony Lindgren0c8219f2010-02-15 08:49:01 -080055 /* Select the UART to use based on the UART1 scratchpad value */
Jeremy Kerr0ea12932010-07-06 18:30:06 +080056 cmp \rp, #0 @ no port configured?
Tony Lindgren0c8219f2010-02-15 08:49:01 -080057 beq 21f @ if none, try to use UART1
Jeremy Kerr0ea12932010-07-06 18:30:06 +080058 cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1
Tony Lindgren0c8219f2010-02-15 08:49:01 -080059 beq 21f @ configure OMAP2/3/4UART1
Jeremy Kerr0ea12932010-07-06 18:30:06 +080060 cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2
Tony Lindgren0c8219f2010-02-15 08:49:01 -080061 beq 22f @ configure OMAP2/3/4UART2
Jeremy Kerr0ea12932010-07-06 18:30:06 +080062 cmp \rp, #OMAP2UART3 @ only on 24xx
Tony Lindgren0c8219f2010-02-15 08:49:01 -080063 beq 23f @ configure OMAP2UART3
Jeremy Kerr0ea12932010-07-06 18:30:06 +080064 cmp \rp, #OMAP3UART3 @ only on 34xx
Tony Lindgren0c8219f2010-02-15 08:49:01 -080065 beq 33f @ configure OMAP3UART3
Jeremy Kerr0ea12932010-07-06 18:30:06 +080066 cmp \rp, #OMAP4UART3 @ only on 44xx
Tony Lindgren0c8219f2010-02-15 08:49:01 -080067 beq 43f @ configure OMAP4UART3
Jeremy Kerr0ea12932010-07-06 18:30:06 +080068 cmp \rp, #OMAP3UART4 @ only on 36xx
Tony Lindgren0c8219f2010-02-15 08:49:01 -080069 beq 34f @ configure OMAP3UART4
Jeremy Kerr0ea12932010-07-06 18:30:06 +080070 cmp \rp, #OMAP4UART4 @ only on 44xx
Tony Lindgren0c8219f2010-02-15 08:49:01 -080071 beq 44f @ configure OMAP4UART4
Hemant Pedanekar4d887a22011-02-15 23:06:17 +053072 cmp \rp, #TI816XUART1 @ ti816x UART offsets different
73 beq 81f @ configure UART1
74 cmp \rp, #TI816XUART2 @ ti816x UART offsets different
75 beq 82f @ configure UART2
76 cmp \rp, #TI816XUART3 @ ti816x UART offsets different
77 beq 83f @ configure UART3
Jeremy Kerr0ea12932010-07-06 18:30:06 +080078 cmp \rp, #ZOOM_UART @ only on zoom2/3
Tony Lindgren0c8219f2010-02-15 08:49:01 -080079 beq 95f @ configure ZOOM_UART
80
81 /* Configure the UART offset from the phys/virt base */
Jeremy Kerr0ea12932010-07-06 18:30:06 +08008221: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
Tony Lindgren0c8219f2010-02-15 08:49:01 -080083 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +08008422: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
Tony Lindgren0c8219f2010-02-15 08:49:01 -080085 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +08008623: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
Tony Lindgren0c8219f2010-02-15 08:49:01 -080087 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +08008833: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
89 add \rp, \rp, #0x00fb0000
90 add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
Tony Lindgren0c8219f2010-02-15 08:49:01 -080091 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +08009234: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
93 add \rp, \rp, #0x00fb0000
94 add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
Tony Lindgren0c8219f2010-02-15 08:49:01 -080095 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +08009643: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
Tony Lindgren0c8219f2010-02-15 08:49:01 -080097 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +08009844: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
Tony Lindgren0c8219f2010-02-15 08:49:01 -080099 b 98f
Hemant Pedanekar4d887a22011-02-15 23:06:17 +053010081: mov \rp, #UART_OFFSET(TI816X_UART1_BASE)
101 b 98f
10282: mov \rp, #UART_OFFSET(TI816X_UART2_BASE)
103 b 98f
10483: mov \rp, #UART_OFFSET(TI816X_UART3_BASE)
105 b 98f
Jeremy Kerr0ea12932010-07-06 18:30:06 +080010695: ldr \rp, =ZOOM_UART_BASE
107 mrc p15, 0, \rv, c1, c0
108 tst \rv, #1 @ MMU enabled?
109 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
110 ldrne \rv, =omap_uart_phys @ MMU enabled
111 str \rp, [\rv, #0]
112 ldr \rp, =ZOOM_UART_VIRT
113 add \rv, \rv, #4 @ omap_uart_virt
114 str \rp, [\rv, #0]
115 mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
116 add \rv, \rv, #4 @ omap_uart_lsr
117 str \rp, [\rv, #0]
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800118 b 10b
119
120 /* Store both phys and virt address for the uart */
Jeremy Kerr0ea12932010-07-06 18:30:06 +080012198: add \rp, \rp, #0x48000000 @ phys base
122 mrc p15, 0, \rv, c1, c0
123 tst \rv, #1 @ MMU enabled?
124 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
125 ldrne \rv, =omap_uart_phys @ MMU enabled
126 str \rp, [\rv, #0]
127 sub \rp, \rp, #0x48000000 @ phys base
128 add \rp, \rp, #0xfa000000 @ virt base
129 add \rv, \rv, #4 @ omap_uart_virt
130 str \rp, [\rv, #0]
131 mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
132 add \rv, \rv, #4 @ omap_uart_lsr
133 str \rp, [\rv, #0]
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800134
135 b 10b
13699:
Russell Kinga09e64f2008-08-05 16:14:15 +0100137 .endm
138
139 .macro senduart,rd,rx
140 strb \rd, [\rx]
141 .endm
142
143 .macro busyuart,rd,rx
Jason Wang7e788b42010-08-03 11:44:18 +08001441001: mrc p15, 0, \rd, c1, c0
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800145 tst \rd, #1 @ MMU enabled?
146 ldreq \rd, =__virt_to_phys(omap_uart_lsr) @ MMU not enabled
147 ldrne \rd, =omap_uart_lsr @ MMU enabled
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800148 ldr \rd, [\rd, #0]
149 ldrb \rd, [\rx, \rd]
Tony Lindgren4f2c49f2010-02-15 08:48:53 -0800150 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
151 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
Russell Kinga09e64f2008-08-05 16:14:15 +0100152 bne 1001b
Russell Kinga09e64f2008-08-05 16:14:15 +0100153 .endm
154
155 .macro waituart,rd,rx
156 .endm