debug-macro.S 2.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * Debugging macro for DaVinci
 *
 * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
 *
 * 2007 (c) MontaVista Software, Inc. This file is licensed under
 * the terms of the GNU General Public License version 2. This program
 * is licensed "as is" without any warranty of any kind, whether express
 * or implied.
 */

12 13 14 15 16 17 18 19
/* Modifications
 * Jan 2009	Chaithrika U S	Added senduart, busyuart, waituart
 *				macros, based on debug-8250.S file
 *				but using 32-bit accesses required for
 *                              some davinci devices.
 */

#include <linux/serial_reg.h>
20 21 22 23 24

#include <asm/memory.h>

#include <mach/serial.h>

25 26
#define UART_SHIFT	2

27 28 29
#define davinci_uart_v2p(x)	((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
#define davinci_uart_p2v(x)	((x) - PLAT_PHYS_OFFSET + PAGE_OFFSET)

30 31 32 33 34
		.pushsection .data
davinci_uart_phys:	.word	0
davinci_uart_virt:	.word	0
		.popsection

35
		.macro addruart, rp, rv, tmp
36 37

		/* Use davinci_uart_phys/virt if already configured */
38 39
10:		mrc	p15, 0, \rp, c1, c0
		tst	\rp, #1			@ MMU enabled?
40
		ldreq	\rp, =davinci_uart_v2p(davinci_uart_phys)
41 42 43 44 45 46
		ldrne	\rp, =davinci_uart_phys
		add	\rv, \rp, #4		@ davinci_uart_virt
		ldr	\rp, [\rp, #0]
		ldr	\rv, [\rv, #0]
		cmp	\rp, #0			@ is port configured?
		cmpne	\rv, #0
47 48
		bne	99f			@ already configured

49 50 51
		/* Check the debug UART address set in uncompress.h */
		mrc	p15, 0, \rp, c1, c0
		tst	\rp, #1			@ MMU enabled?
52

53 54 55 56
		and	\rp, pc, #0xff000000
		ldr	\rv, =DAVINCI_UART_INFO_OFS
		add	\rp, \rp, \rv

57
		ldreq	\rv, =davinci_uart_v2p(davinci_uart_phys)
58
		ldrne	\rv, =davinci_uart_phys
59 60 61 62

		/* Copy uart phys address from decompressor uart info */
		ldr	\tmp, [\rp, #0]
		str	\tmp, [\rv, #0]
63 64

		/* Copy uart virt address from decompressor uart info */
65 66
		ldr	\tmp, [\rp, #4]
		str	\tmp, [\rv, #4]
67 68 69

		b	10b
99:
70 71
		.endm

72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
		.macro	senduart,rd,rx
		str	\rd, [\rx, #UART_TX << UART_SHIFT]
		.endm

		.macro	busyuart,rd,rx
1002:		ldr	\rd, [\rx, #UART_LSR << UART_SHIFT]
		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
		bne	1002b
		.endm

		.macro	waituart,rd,rx
#ifdef FLOW_CONTROL
1001:		ldr	\rd, [\rx, #UART_MSR << UART_SHIFT]
		tst	\rd, #UART_MSR_CTS
		beq	1001b
#endif
		.endm