1/*
2 * arch/arm/include/debug/8250.S
3 *
4 *  Copyright (C) 1994-2013 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#include <linux/serial_reg.h>
11
12		.macro	addruart, rp, rv, tmp
13		ldr	\rp, =CONFIG_DEBUG_UART_PHYS
14		ldr	\rv, =CONFIG_DEBUG_UART_VIRT
15		.endm
16
17#ifdef CONFIG_DEBUG_UART_8250_WORD
18		.macro	store, rd, rx:vararg
19		str	\rd, \rx
20		.endm
21
22		.macro	load, rd, rx:vararg
23		ldr	\rd, \rx
24		.endm
25#else
26		.macro	store, rd, rx:vararg
27		strb	\rd, \rx
28		.endm
29
30		.macro	load, rd, rx:vararg
31		ldrb	\rd, \rx
32		.endm
33#endif
34
35#define UART_SHIFT CONFIG_DEBUG_UART_8250_SHIFT
36
37		.macro	senduart,rd,rx
38		store	\rd, [\rx, #UART_TX << UART_SHIFT]
39		.endm
40
41		.macro	busyuart,rd,rx
421002:		load	\rd, [\rx, #UART_LSR << UART_SHIFT]
43		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
44		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
45		bne	1002b
46		.endm
47
48		.macro	waituart,rd,rx
49#ifdef CONFIG_DEBUG_UART_8250_FLOW_CONTROL
501001:		load	\rd, [\rx, #UART_MSR << UART_SHIFT]
51		tst	\rd, #UART_MSR_CTS
52		beq	1001b
53#endif
54		.endm
55