blob: f8b7ea4f6235f6f5dc66aa15d9bfe203523f4486 [file] [log] [blame]
Kevin Hilman7c6337e2007-04-30 19:37:19 +01001/*
2 * Debugging macro for DaVinci
3 *
4 * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
5 *
6 * 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
Chaithrika U S17eb1572009-01-19 14:13:05 +053012/* Modifications
13 * Jan 2009 Chaithrika U S Added senduart, busyuart, waituart
14 * macros, based on debug-8250.S file
15 * but using 32-bit accesses required for
16 * some davinci devices.
17 */
18
19#include <linux/serial_reg.h>
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040020
21#include <asm/memory.h>
22
23#include <mach/serial.h>
24
Chaithrika U S17eb1572009-01-19 14:13:05 +053025#define UART_SHIFT 2
26
Kevin Hilman5cf4c802011-04-19 16:52:56 -070027#define davinci_uart_v2p(x) ((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
28#define davinci_uart_p2v(x) ((x) - PLAT_PHYS_OFFSET + PAGE_OFFSET)
29
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040030 .pushsection .data
31davinci_uart_phys: .word 0
32davinci_uart_virt: .word 0
33 .popsection
34
Jeremy Kerr0ea12932010-07-06 18:30:06 +080035 .macro addruart, rp, rv
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040036
37 /* Use davinci_uart_phys/virt if already configured */
Jeremy Kerr0ea12932010-07-06 18:30:06 +08003810: mrc p15, 0, \rp, c1, c0
39 tst \rp, #1 @ MMU enabled?
Kevin Hilman5cf4c802011-04-19 16:52:56 -070040 ldreq \rp, =davinci_uart_v2p(davinci_uart_phys)
Jeremy Kerr0ea12932010-07-06 18:30:06 +080041 ldrne \rp, =davinci_uart_phys
42 add \rv, \rp, #4 @ davinci_uart_virt
43 ldr \rp, [\rp, #0]
44 ldr \rv, [\rv, #0]
45 cmp \rp, #0 @ is port configured?
46 cmpne \rv, #0
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040047 bne 99f @ already configured
48
Jeremy Kerr0ea12932010-07-06 18:30:06 +080049 /* Check the debug UART address set in uncompress.h */
50 mrc p15, 0, \rp, c1, c0
51 tst \rp, #1 @ MMU enabled?
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040052
53 /* Copy uart phys address from decompressor uart info */
Kevin Hilman5cf4c802011-04-19 16:52:56 -070054 ldreq \rv, =davinci_uart_v2p(davinci_uart_phys)
Jeremy Kerr0ea12932010-07-06 18:30:06 +080055 ldrne \rv, =davinci_uart_phys
56 ldreq \rp, =DAVINCI_UART_INFO
Kevin Hilman5cf4c802011-04-19 16:52:56 -070057 ldrne \rp, =davinci_uart_p2v(DAVINCI_UART_INFO)
Jeremy Kerr0ea12932010-07-06 18:30:06 +080058 ldr \rp, [\rp, #0]
59 str \rp, [\rv]
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040060
61 /* Copy uart virt address from decompressor uart info */
Kevin Hilman5cf4c802011-04-19 16:52:56 -070062 ldreq \rv, =davinci_uart_v2p(davinci_uart_virt)
Jeremy Kerr0ea12932010-07-06 18:30:06 +080063 ldrne \rv, =davinci_uart_virt
64 ldreq \rp, =DAVINCI_UART_INFO
Kevin Hilman5cf4c802011-04-19 16:52:56 -070065 ldrne \rp, =davinci_uart_p2v(DAVINCI_UART_INFO)
Jeremy Kerr0ea12932010-07-06 18:30:06 +080066 ldr \rp, [\rp, #4]
67 str \rp, [\rv]
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040068
69 b 10b
7099:
Kevin Hilman7c6337e2007-04-30 19:37:19 +010071 .endm
72
Chaithrika U S17eb1572009-01-19 14:13:05 +053073 .macro senduart,rd,rx
74 str \rd, [\rx, #UART_TX << UART_SHIFT]
75 .endm
76
77 .macro busyuart,rd,rx
781002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
79 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
80 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
81 bne 1002b
82 .endm
83
84 .macro waituart,rd,rx
85#ifdef FLOW_CONTROL
861001: ldr \rd, [\rx, #UART_MSR << UART_SHIFT]
87 tst \rd, #UART_MSR_CTS
88 beq 1001b
89#endif
90 .endm
91