blob: cf94552d52740cd8c8d4903aa0549a05369b73cf [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
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040021#include <mach/serial.h>
22
Chaithrika U S17eb1572009-01-19 14:13:05 +053023#define UART_SHIFT 2
24
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040025 .pushsection .data
26davinci_uart_phys: .word 0
27davinci_uart_virt: .word 0
28 .popsection
29
Nicolas Pitre639da5e2011-08-31 22:55:46 -040030 .macro addruart, rp, rv, tmp
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040031
32 /* Use davinci_uart_phys/virt if already configured */
Nicolas Pitre67f462b22011-09-01 20:50:14 -04003310: adr \rp, 99f @ get effective addr of 99f
34 ldr \rv, [\rp] @ get absolute addr of 99f
35 sub \rv, \rv, \rp @ offset between the two
36 ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys
37 sub \tmp, \rp, \rv @ make it effective
38 ldr \rp, [\tmp, #0] @ davinci_uart_phys
39 ldr \rv, [\tmp, #4] @ davinci_uart_virt
Jeremy Kerr0ea12932010-07-06 18:30:06 +080040 cmp \rp, #0 @ is port configured?
41 cmpne \rv, #0
Nicolas Pitre67f462b22011-09-01 20:50:14 -040042 bne 100f @ already configured
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040043
Jeremy Kerr0ea12932010-07-06 18:30:06 +080044 /* Check the debug UART address set in uncompress.h */
Nicolas Pitree020fe32011-09-01 20:32:21 -040045 and \rp, pc, #0xff000000
46 ldr \rv, =DAVINCI_UART_INFO_OFS
47 add \rp, \rp, \rv
48
Nicolas Pitree020fe32011-09-01 20:32:21 -040049 /* Copy uart phys address from decompressor uart info */
Nicolas Pitre67f462b22011-09-01 20:50:14 -040050 ldr \rv, [\rp, #0]
51 str \rv, [\tmp, #0]
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040052
53 /* Copy uart virt address from decompressor uart info */
Nicolas Pitre67f462b22011-09-01 20:50:14 -040054 ldr \rv, [\rp, #4]
55 str \rv, [\tmp, #4]
Cyril Chemparathydc2eb762010-05-18 12:51:17 -040056
57 b 10b
Nicolas Pitre67f462b22011-09-01 20:50:14 -040058
59 .align
6099: .word .
61 .word davinci_uart_phys
62 .ltorg
63
64100:
Kevin Hilman7c6337e2007-04-30 19:37:19 +010065 .endm
66
Chaithrika U S17eb1572009-01-19 14:13:05 +053067 .macro senduart,rd,rx
68 str \rd, [\rx, #UART_TX << UART_SHIFT]
69 .endm
70
71 .macro busyuart,rd,rx
721002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
73 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
74 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
75 bne 1002b
76 .endm
77
78 .macro waituart,rd,rx
79#ifdef FLOW_CONTROL
801001: ldr \rd, [\rx, #UART_MSR << UART_SHIFT]
81 tst \rd, #UART_MSR_CTS
82 beq 1001b
83#endif
84 .endm
85