1 /* arch/arm/mach-omap1/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>
21 omap_uart_phys: .word 0x0
22 omap_uart_virt: .word 0x0
26 * Note that this code won't work if the bootloader passes
27 * a wrong machine ID number in r1. To debug, just hardcode
28 * the desired UART phys and virt addresses temporarily into
29 * the omap_uart_phys and omap_uart_virt above.
31 .macro addruart, rx, tmp
33 /* Use omap_uart_phys/virt if already configured */
34 9: mrc p15, 0, \rx, c1, c0
35 tst \rx, #1 @ MMU enabled?
36 ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address
37 ldrne \rx, =omap_uart_virt @ virtual base
39 cmp \rx, #0 @ is port configured?
40 bne 99f @ already configured
42 /* Check the debug UART configuration set in uncompress.h */
43 mrc p15, 0, \rx, c1, c0
44 tst \rx, #1 @ MMU enabled?
45 ldreq \rx, =OMAP_UART_INFO
46 ldrne \rx, =__phys_to_virt(OMAP_UART_INFO)
49 /* Select the UART to use based on the UART1 scratchpad value */
50 10: cmp \rx, #0 @ no port configured?
51 beq 11f @ if none, try to use UART1
53 beq 11f @ configure OMAP1UART1
55 beq 12f @ configure OMAP1UART2
57 beq 13f @ configure OMAP2UART3
59 /* Configure the UART offset from the phys/virt base */
60 11: mov \rx, #0x00fb0000 @ OMAP1UART1
62 12: mov \rx, #0x00fb0000 @ OMAP1UART1
63 orr \rx, \rx, #0x00000800 @ OMAP1UART2
65 13: mov \rx, #0x00fb0000 @ OMAP1UART1
66 orr \rx, \rx, #0x00000800 @ OMAP1UART2
67 orr \rx, \rx, #0x00009000 @ OMAP1UART3
69 /* Store both phys and virt address for the uart */
70 98: add \rx, \rx, #0xff000000 @ phys base
71 mrc p15, 0, \tmp, c1, c0
72 tst \tmp, #1 @ MMU enabled?
73 ldreq \tmp, =__virt_to_phys(omap_uart_phys)
74 ldrne \tmp, =omap_uart_phys
76 sub \rx, \rx, #0xff000000 @ phys base
77 add \rx, \rx, #0xfe000000 @ virt base
78 ldreq \tmp, =__virt_to_phys(omap_uart_virt)
79 ldrne \tmp, =omap_uart_virt
90 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
91 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
92 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
94 ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
95 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
96 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
101 .macro waituart,rd,rx