blob: 09331bbbda52b66e267756b58cf8294472a010bb [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 */
Tony Lindgren4e6d4882010-02-01 23:26:53 +010034 .macro addruart, rx, tmp
Tony Lindgren0c8219f2010-02-15 08:49:01 -080035
36 /* Use omap_uart_phys/virt if already configured */
3710: mrc p15, 0, \rx, c1, c0
38 tst \rx, #1 @ MMU enabled?
Jason Wang7e788b42010-08-03 11:44:18 +080039 ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address
Tony Lindgren0c8219f2010-02-15 08:49:01 -080040 ldrne \rx, =omap_uart_virt @ virtual base address
41 ldr \rx, [\rx, #0]
42 cmp \rx, #0 @ is port configured?
43 bne 99f @ already configured
44
Tony Lindgren96554d72010-04-30 17:39:19 -070045 /* Check the debug UART configuration set in uncompress.h */
Russell Kinga09e64f2008-08-05 16:14:15 +010046 mrc p15, 0, \rx, c1, c0
47 tst \rx, #1 @ MMU enabled?
Tony Lindgren96554d72010-04-30 17:39:19 -070048 ldreq \rx, =OMAP_UART_INFO
49 ldrne \rx, =__phys_to_virt(OMAP_UART_INFO)
50 ldr \rx, [\rx, #0]
Syed Mohammed, Khasimcc26b3b2008-10-09 17:51:41 +030051
Tony Lindgren0c8219f2010-02-15 08:49:01 -080052 /* Select the UART to use based on the UART1 scratchpad value */
53 cmp \rx, #0 @ no port configured?
54 beq 21f @ if none, try to use UART1
55 cmp \rx, #OMAP2UART1 @ OMAP2/3/4UART1
56 beq 21f @ configure OMAP2/3/4UART1
57 cmp \rx, #OMAP2UART2 @ OMAP2/3/4UART2
58 beq 22f @ configure OMAP2/3/4UART2
59 cmp \rx, #OMAP2UART3 @ only on 24xx
60 beq 23f @ configure OMAP2UART3
61 cmp \rx, #OMAP3UART3 @ only on 34xx
62 beq 33f @ configure OMAP3UART3
63 cmp \rx, #OMAP4UART3 @ only on 44xx
64 beq 43f @ configure OMAP4UART3
65 cmp \rx, #OMAP3UART4 @ only on 36xx
66 beq 34f @ configure OMAP3UART4
67 cmp \rx, #OMAP4UART4 @ only on 44xx
68 beq 44f @ configure OMAP4UART4
69 cmp \rx, #ZOOM_UART @ only on zoom2/3
70 beq 95f @ configure ZOOM_UART
71
72 /* Configure the UART offset from the phys/virt base */
7321: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
74 b 98f
7522: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
76 b 98f
7723: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE)
78 b 98f
7933: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
80 add \rx, \rx, #0x00fb0000
81 add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE
82 b 98f
8334: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
84 add \rx, \rx, #0x00fb0000
85 add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE
86 b 98f
8743: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE)
88 b 98f
8944: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE)
90 b 98f
Tony Lindgrena4f57b82010-04-30 12:57:14 -07009195: ldr \rx, =ZOOM_UART_BASE
Jason Wang7e788b42010-08-03 11:44:18 +080092 mrc p15, 0, \tmp, c1, c0
93 tst \tmp, #1 @ MMU enabled?
94 ldreq \tmp, =__virt_to_phys(omap_uart_phys)
95 ldrne \tmp, =omap_uart_phys
Tony Lindgren0c8219f2010-02-15 08:49:01 -080096 str \rx, [\tmp, #0]
Tony Lindgrena4f57b82010-04-30 12:57:14 -070097 ldr \rx, =ZOOM_UART_VIRT
Jason Wang7e788b42010-08-03 11:44:18 +080098 ldreq \tmp, =__virt_to_phys(omap_uart_virt)
99 ldrne \tmp, =omap_uart_virt
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800100 str \rx, [\tmp, #0]
101 mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
Jason Wang7e788b42010-08-03 11:44:18 +0800102 ldreq \tmp, =__virt_to_phys(omap_uart_lsr)
103 ldrne \tmp, =omap_uart_lsr
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800104 str \rx, [\tmp, #0]
105 b 10b
106
107 /* Store both phys and virt address for the uart */
10898: add \rx, \rx, #0x48000000 @ phys base
Jason Wang7e788b42010-08-03 11:44:18 +0800109 mrc p15, 0, \tmp, c1, c0
110 tst \tmp, #1 @ MMU enabled?
111 ldreq \tmp, =__virt_to_phys(omap_uart_phys)
112 ldrne \tmp, =omap_uart_phys
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800113 str \rx, [\tmp, #0]
114 sub \rx, \rx, #0x48000000 @ phys base
115 add \rx, \rx, #0xfa000000 @ virt base
Jason Wang7e788b42010-08-03 11:44:18 +0800116 ldreq \tmp, =__virt_to_phys(omap_uart_virt)
117 ldrne \tmp, =omap_uart_virt
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800118 str \rx, [\tmp, #0]
119 mov \rx, #(UART_LSR << OMAP_PORT_SHIFT)
Jason Wang7e788b42010-08-03 11:44:18 +0800120 ldreq \tmp, =__virt_to_phys(omap_uart_lsr)
121 ldrne \tmp, =omap_uart_lsr
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800122 str \rx, [\tmp, #0]
123
124 b 10b
12599:
Russell Kinga09e64f2008-08-05 16:14:15 +0100126 .endm
127
128 .macro senduart,rd,rx
129 strb \rd, [\rx]
130 .endm
131
132 .macro busyuart,rd,rx
Jason Wang7e788b42010-08-03 11:44:18 +08001331001: mrc p15, 0, \rd, c1, c0
134 tst \rd, #1 @ MMU enabled?
135 ldreq \rd, =__virt_to_phys(omap_uart_lsr)
136 ldrne \rd, =omap_uart_lsr
Tony Lindgren0c8219f2010-02-15 08:49:01 -0800137 ldr \rd, [\rd, #0]
138 ldrb \rd, [\rx, \rd]
Tony Lindgren4f2c49f2010-02-15 08:48:53 -0800139 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
140 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
Russell Kinga09e64f2008-08-05 16:14:15 +0100141 bne 1001b
Russell Kinga09e64f2008-08-05 16:14:15 +0100142 .endm
143
144 .macro waituart,rd,rx
145 .endm