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 <plat/serial.h>
19 omap_uart_phys: .word 0x0
20 omap_uart_virt: .word 0x0
24 * Note that this code won't work if the bootloader passes
25 * a wrong machine ID number in r1. To debug, just hardcode
26 * the desired UART phys and virt addresses temporarily into
27 * the omap_uart_phys and omap_uart_virt above.
29 .macro addruart, rx, tmp
31 /* Use omap_uart_phys/virt if already configured */
32 9: mrc p15, 0, \rx, c1, c0
33 tst \rx, #1 @ MMU enabled?
34 ldreq \rx, =omap_uart_phys @ physical base address
35 ldrne \rx, =omap_uart_virt @ virtual base
37 cmp \rx, #0 @ is port configured?
38 bne 99f @ already configured
40 /* Check 7XX UART1 scratchpad register for uart to use */
41 mrc p15, 0, \rx, c1, c0
42 tst \rx, #1 @ MMU enabled?
43 moveq \rx, #0xff000000 @ physical base address
44 movne \rx, #0xfe000000 @ virtual base
45 orr \rx, \rx, #0x00fb0000 @ OMAP1UART1
46 ldrb \rx, [\rx, #(UART_SCR << OMAP7XX_PORT_SHIFT)]
47 cmp \rx, #0 @ anything in 7XX scratchpad?
48 bne 10f @ found 7XX uart
50 /* Check 15xx/16xx UART1 scratchpad register for uart to use */
51 mrc p15, 0, \rx, c1, c0
52 tst \rx, #1 @ MMU enabled?
53 moveq \rx, #0xff000000 @ physical base address
54 movne \rx, #0xfe000000 @ virtual base
55 orr \rx, \rx, #0x00fb0000 @ OMAP1UART1
56 ldrb \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)]
58 /* Select the UART to use based on the UART1 scratchpad value */
59 10: cmp \rx, #0 @ no port configured?
60 beq 11f @ if none, try to use UART1
62 beq 11f @ configure OMAP1UART1
64 beq 12f @ configure OMAP1UART2
66 beq 13f @ configure OMAP2UART3
68 /* Configure the UART offset from the phys/virt base */
69 11: mov \rx, #0x00fb0000 @ OMAP1UART1
71 12: mov \rx, #0x00fb0000 @ OMAP1UART1
72 orr \rx, \rx, #0x00000800 @ OMAP1UART2
74 13: mov \rx, #0x00fb0000 @ OMAP1UART1
75 orr \rx, \rx, #0x00000800 @ OMAP1UART2
76 orr \rx, \rx, #0x00009000 @ OMAP1UART3
78 /* Store both phys and virt address for the uart */
79 98: add \rx, \rx, #0xff000000 @ phys base
80 ldr \tmp, =omap_uart_phys
82 sub \rx, \rx, #0xff000000 @ phys base
83 add \rx, \rx, #0xfe000000 @ virt base
84 ldr \tmp, =omap_uart_virt
95 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
96 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
97 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
99 ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
100 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
101 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
106 .macro waituart,rd,rx