1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * arch/arm/include/debug/8250.S
4 *
5 *  Copyright (C) 1994-2013 Russell King
6 */
7#include <linux/serial_reg.h>
8
9		.macro	addruart, rp, rv, tmp
10		ldr	\rp, =CONFIG_DEBUG_UART_PHYS
11		ldr	\rv, =CONFIG_DEBUG_UART_VIRT
12		.endm
13
14#ifdef CONFIG_DEBUG_UART_8250_WORD
15		.macro	store, rd, rx:vararg
16		str	\rd, \rx
17		.endm
18
19		.macro	load, rd, rx:vararg
20		ldr	\rd, \rx
21		.endm
22#else
23		.macro	store, rd, rx:vararg
24		strb	\rd, \rx
25		.endm
26
27		.macro	load, rd, rx:vararg
28		ldrb	\rd, \rx
29		.endm
30#endif
31
32#define UART_SHIFT CONFIG_DEBUG_UART_8250_SHIFT
33
34		.macro	senduart,rd,rx
35		store	\rd, [\rx, #UART_TX << UART_SHIFT]
36		.endm
37
38		.macro	busyuart,rd,rx
391002:		load	\rd, [\rx, #UART_LSR << UART_SHIFT]
40		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
41		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
42		bne	1002b
43		.endm
44
45		.macro	waituart,rd,rx
46#ifdef CONFIG_DEBUG_UART_8250_FLOW_CONTROL
471001:		load	\rd, [\rx, #UART_MSR << UART_SHIFT]
48		tst	\rd, #UART_MSR_CTS
49		beq	1001b
50#endif
51		.endm
52