144603Sdcs/* SPDX-License-Identifier: GPL-2.0-only */
244603Sdcs/* arch/arm/mach-imx/include/mach/debug-macro.S
344603Sdcs *
444603Sdcs * Debugging macro include header
544603Sdcs *
644603Sdcs *  Copyright (C) 1994-1999 Russell King
744603Sdcs *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
844603Sdcs */
944603Sdcs
1044603Sdcs#include <asm/assembler.h>
1144603Sdcs#include "imx-uart.h"
1244603Sdcs
1344603Sdcs/*
1444603Sdcs * FIXME: This is a copy of IMX_IO_P2V in hardware.h, and needs to
1544603Sdcs * stay sync with that.  It's hard to maintain, and should be fixed
1644603Sdcs * globally for multi-platform build to use a fixed virtual address
1744603Sdcs * for low-level debug uart port across platforms.
1844603Sdcs */
1944603Sdcs#define IMX_IO_P2V(x)	(						\
2044603Sdcs			(((x) & 0x80000000) >> 7) |			\
2144603Sdcs			(0xf4000000 +					\
2244603Sdcs			(((x) & 0x50000000) >> 6) +			\
2344603Sdcs			(((x) & 0x0b000000) >> 4) +			\
2444603Sdcs			(((x) & 0x000fffff))))
2550477Speter
2644603Sdcs#define UART_VADDR	IMX_IO_P2V(UART_PADDR)
2744603Sdcs
2844603Sdcs		.macro	addruart, rp, rv, tmp
2944603Sdcs		ldr	\rp, =UART_PADDR	@ physical
3044603Sdcs		ldr	\rv, =UART_VADDR	@ virtual
3144603Sdcs		.endm
3244603Sdcs
3344603Sdcs		.macro	senduart,rd,rx
3444603Sdcs		ARM_BE8(rev \rd, \rd)
3544603Sdcs		str	\rd, [\rx, #0x40]	@ TXDATA
3644603Sdcs		.endm
3744603Sdcs
3844603Sdcs		.macro	waituartcts,rd,rx
3944603Sdcs		.endm
4044603Sdcs
4144603Sdcs		.macro	waituarttxrdy,rd,rx
4244603Sdcs		.endm
4344603Sdcs
4444603Sdcs		.macro	busyuart,rd,rx
4544603Sdcs1002:		ldr	\rd, [\rx, #0x98]	@ SR2
4644603Sdcs		ARM_BE8(rev \rd, \rd)
4744603Sdcs		tst	\rd, #1 << 3		@ TXDC
4844603Sdcs		beq	1002b			@ wait until transmit done
4944603Sdcs		.endm
5044603Sdcs