1 /* arch/arm/mach-omap2/include/mach/debug-macro.S
3 * Debugging macro include header
5 * Copyright (C) 1994-1999 Russell King
6 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
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.
14 #include <linux/serial_reg.h>
16 #include <plat/serial.h>
18 #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
21 omap_uart_phys: .word 0
22 omap_uart_virt: .word 0
23 omap_uart_lsr: .word 0
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.
32 .macro addruart, rx, tmp
34 /* Use omap_uart_phys/virt if already configured */
35 10: 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
40 cmp \rx, #0 @ is port configured?
41 bne 99f @ already configured
43 /* Check UART1 scratchpad register for uart to use */
44 mrc p15, 0, \rx, c1, c0
45 tst \rx, #1 @ MMU enabled?
46 moveq \rx, #0x48000000 @ physical base address
47 movne \rx, #0xfa000000 @ virtual base
48 orr \rx, \rx, #0x0006a000 @ uart1 on omap2/3/4
49 ldrb \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)] @ scratchpad
51 /* 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
71 /* Configure the UART offset from the phys/virt base */
72 21: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
74 22: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
76 23: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE)
78 33: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
79 add \rx, \rx, #0x00fb0000
80 add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE
82 34: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
83 add \rx, \rx, #0x00fb0000
84 add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE
86 43: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE)
88 44: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE)
90 95: mov \rx, #ZOOM_UART_BASE
91 ldr \tmp, =omap_uart_phys
93 mov \rx, #ZOOM_UART_VIRT
94 ldr \tmp, =omap_uart_virt
96 mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
97 ldr \tmp, =omap_uart_lsr
101 /* Store both phys and virt address for the uart */
102 98: add \rx, \rx, #0x48000000 @ phys base
103 ldr \tmp, =omap_uart_phys
105 sub \rx, \rx, #0x48000000 @ phys base
106 add \rx, \rx, #0xfa000000 @ virt base
107 ldr \tmp, =omap_uart_virt
109 mov \rx, #(UART_LSR << OMAP_PORT_SHIFT)
110 ldr \tmp, =omap_uart_lsr
117 .macro senduart,rd,rx
121 .macro busyuart,rd,rx
122 1001: ldr \rd, =omap_uart_lsr
125 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
126 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
130 .macro waituart,rd,rx