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, rp, rv
33 /* Use omap_uart_phys/virt if already configured */
34 9: mrc p15, 0, \rp, c1, c0
35 tst \rp, #1 @ MMU enabled?
36 ldreq \rp, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
37 ldrne \rp, =omap_uart_phys @ MMU enabled
38 add \rv, \rp, #4 @ omap_uart_virt
41 cmp \rp, #0 @ is port configured?
43 bne 99f @ already configured
45 /* Check the debug UART configuration set in uncompress.h */
46 mrc p15, 0, \rp, c1, c0
47 tst \rp, #1 @ MMU enabled?
48 ldreq \rp, =OMAP_UART_INFO @ MMU not enabled
49 ldrne \rp, =__phys_to_virt(OMAP_UART_INFO) @ MMU enabled
52 /* Select the UART to use based on the UART1 scratchpad value */
53 10: cmp \rp, #0 @ no port configured?
54 beq 11f @ if none, try to use UART1
56 beq 11f @ configure OMAP1UART1
58 beq 12f @ configure OMAP1UART2
60 beq 13f @ configure OMAP2UART3
62 /* Configure the UART offset from the phys/virt base */
63 11: mov \rp, #0x00fb0000 @ OMAP1UART1
65 12: mov \rp, #0x00fb0000 @ OMAP1UART1
66 orr \rp, \rp, #0x00000800 @ OMAP1UART2
68 13: mov \rp, #0x00fb0000 @ OMAP1UART1
69 orr \rp, \rp, #0x00000800 @ OMAP1UART2
70 orr \rp, \rp, #0x00009000 @ OMAP1UART3
72 /* Store both phys and virt address for the uart */
73 98: add \rp, \rp, #0xff000000 @ phys base
74 mrc p15, 0, \rv, c1, c0
75 tst \rv, #1 @ MMU enabled?
76 ldreq \rv, =__virt_to_phys(omap_uart_phys) @ MMU not enabled
77 ldrne \rv, =omap_uart_phys @ MMU enabled
79 sub \rp, \rp, #0xff000000 @ phys base
80 add \rp, \rp, #0xfe000000 @ virt base
81 add \rv, \rv, #4 @ omap_uart_lsr
92 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
93 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
94 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
96 ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
97 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
98 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
103 .macro waituart,rd,rx