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 <asm/memory.h>
18 #include <plat/serial.h>
20 #define UART_OFFSET(addr) ((addr) & 0x00ffffff)
23 omap_uart_phys: .word 0
24 omap_uart_virt: .word 0
25 omap_uart_lsr: .word 0
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.
34 .macro addruart, rx, tmp
36 /* Use omap_uart_phys/virt if already configured */
37 10: mrc p15, 0, \rx, c1, c0
38 tst \rx, #1 @ MMU enabled?
39 ldreq \rx, =omap_uart_phys @ physical base address
40 ldrne \rx, =omap_uart_virt @ virtual base address
42 cmp \rx, #0 @ is port configured?
43 bne 99f @ already configured
45 /* Check the debug UART configuration set in uncompress.h */
46 mrc p15, 0, \rx, c1, c0
47 tst \rx, #1 @ MMU enabled?
48 ldreq \rx, =OMAP_UART_INFO
49 ldrne \rx, =__phys_to_virt(OMAP_UART_INFO)
52 /* 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
72 /* Configure the UART offset from the phys/virt base */
73 21: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
75 22: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
77 23: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE)
79 33: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
80 add \rx, \rx, #0x00fb0000
81 add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE
83 34: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
84 add \rx, \rx, #0x00fb0000
85 add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE
87 43: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE)
89 44: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE)
91 95: ldr \rx, =ZOOM_UART_BASE
92 ldr \tmp, =omap_uart_phys
94 ldr \rx, =ZOOM_UART_VIRT
95 ldr \tmp, =omap_uart_virt
97 mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
98 ldr \tmp, =omap_uart_lsr
102 /* Store both phys and virt address for the uart */
103 98: add \rx, \rx, #0x48000000 @ phys base
104 ldr \tmp, =omap_uart_phys
106 sub \rx, \rx, #0x48000000 @ phys base
107 add \rx, \rx, #0xfa000000 @ virt base
108 ldr \tmp, =omap_uart_virt
110 mov \rx, #(UART_LSR << OMAP_PORT_SHIFT)
111 ldr \tmp, =omap_uart_lsr
118 .macro senduart,rd,rx
122 .macro busyuart,rd,rx
123 1001: ldr \rd, =omap_uart_lsr
126 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
127 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
131 .macro waituart,rd,rx