blob: 4a63a2ea484dd58681a3f403f926a64861e023a9 [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
16#include <plat/serial.h>
17
Tony Lindgren0c8219f2010-02-15 08:49:01 -080018#define UART_OFFSET(addr) ((addr) & 0x00ffffff)
19
20 .pushsection .data
21omap_uart_phys: .word 0
22omap_uart_virt: .word 0
23omap_uart_lsr: .word 0
24 .popsection
25
26 /*
27 * Note that this code won't work if the bootloader passes
28 * a wrong machine ID number in r1. To debug, just hardcode
29 * the desired UART phys and virt addresses temporarily into
30 * the omap_uart_phys and omap_uart_virt above.
31 */
Tony Lindgren4e6d4882010-02-01 23:26:53 +010032 .macro addruart, rx, tmp
Tony Lindgren0c8219f2010-02-15 08:49:01 -080033
34 /* Use omap_uart_phys/virt if already configured */
3510: mrc p15, 0, \rx, c1, c0
36 tst \rx, #1 @ MMU enabled?
37 ldreq \rx, =omap_uart_phys @ physical base address
38 ldrne \rx, =omap_uart_virt @ virtual base address
39 ldr \rx, [\rx, #0]
40 cmp \rx, #0 @ is port configured?
41 bne 99f @ already configured
42
43 /* Check UART1 scratchpad register for uart to use */
Russell Kinga09e64f2008-08-05 16:14:15 +010044 mrc p15, 0, \rx, c1, c0
45 tst \rx, #1 @ MMU enabled?
Russell Kinga09e64f2008-08-05 16:14:15 +010046 moveq \rx, #0x48000000 @ physical base address
Santosh Shilimkarb4224b22009-10-19 17:25:55 -070047 movne \rx, #0xfa000000 @ virtual base
Tony Lindgren0c8219f2010-02-15 08:49:01 -080048 orr \rx, \rx, #0x0006a000 @ uart1 on omap2/3/4
49 ldrb \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)] @ scratchpad
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030050
Tony Lindgren0c8219f2010-02-15 08:49:01 -080051 /* Select the UART to use based on the UART1 scratchpad value */
52 cmp \rx, #0 @ no port configured?
53 beq 21f @ if none, try to use UART1
54 cmp \rx, #OMAP2UART1 @ OMAP2/3/4UART1
55 beq 21f @ configure OMAP2/3/4UART1
56 cmp \rx, #OMAP2UART2 @ OMAP2/3/4UART2
57 beq 22f @ configure OMAP2/3/4UART2
58 cmp \rx, #OMAP2UART3 @ only on 24xx
59 beq 23f @ configure OMAP2UART3
60 cmp \rx, #OMAP3UART3 @ only on 34xx
61 beq 33f @ configure OMAP3UART3
62 cmp \rx, #OMAP4UART3 @ only on 44xx
63 beq 43f @ configure OMAP4UART3
64 cmp \rx, #OMAP3UART4 @ only on 36xx
65 beq 34f @ configure OMAP3UART4
66 cmp \rx, #OMAP4UART4 @ only on 44xx
67 beq 44f @ configure OMAP4UART4
68 cmp \rx, #ZOOM_UART @ only on zoom2/3
69 beq 95f @ configure ZOOM_UART
70
71 /* Configure the UART offset from the phys/virt base */
7221: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
73 b 98f
7422: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
75 b 98f
7623: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE)
77 b 98f
7833: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
79 add \rx, \rx, #0x00fb0000
80 add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE
81 b 98f
8234: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
83 add \rx, \rx, #0x00fb0000
84 add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE
85 b 98f
8643: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE)
87 b 98f
8844: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE)
89 b 98f
9095: mov \rx, #ZOOM_UART_BASE
91 ldr \tmp, =omap_uart_phys
92 str \rx, [\tmp, #0]
93 mov \rx, #ZOOM_UART_VIRT
94 ldr \tmp, =omap_uart_virt
95 str \rx, [\tmp, #0]
96 mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
97 ldr \tmp, =omap_uart_lsr
98 str \rx, [\tmp, #0]
99 b 10b
100
101 /* Store both phys and virt address for the uart */
10298: add \rx, \rx, #0x48000000 @ phys base
103 ldr \tmp, =omap_uart_phys
104 str \rx, [\tmp, #0]
105 sub \rx, \rx, #0x48000000 @ phys base
106 add \rx, \rx, #0xfa000000 @ virt base
107 ldr \tmp, =omap_uart_virt
108 str \rx, [\tmp, #0]
109 mov \rx, #(UART_LSR << OMAP_PORT_SHIFT)
110 ldr \tmp, =omap_uart_lsr
111 str \rx, [\tmp, #0]
112
113 b 10b
11499:
Russell Kinga09e64f2008-08-05 16:14:15 +0100115 .endm
116
117 .macro senduart,rd,rx
118 strb \rd, [\rx]
119 .endm
120
121 .macro busyuart,rd,rx
Tony Lindgren0c8219f2010-02-15 08:49:01 -08001221001: ldr \rd, =omap_uart_lsr
123 ldr \rd, [\rd, #0]
124 ldrb \rd, [\rx, \rd]
Tony Lindgren4f2c49f2010-02-15 08:48:53 -0800125 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
126 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
Russell Kinga09e64f2008-08-05 16:14:15 +0100127 bne 1001b
Russell Kinga09e64f2008-08-05 16:14:15 +0100128 .endm
129
130 .macro waituart,rd,rx
131 .endm