/*
 * include/asm-arm/arch-cxd4105/debug-macro.S
 *
 * Debugging macro include header
 *
 * Copyright 2005,2006,2007 Sony Corporation
 *
 * This code is based on include/asm-arm/arch-integrator/debug-macro.S.
 */
/* linux/include/asm-arm/arch-integrator/debug-macro.S
 *
 * Debugging macro include header
 *
 *  Copyright (C) 1994-1999 Russell King
 *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
*/
#include <linux/amba/serial.h>

		.macro	addruart,rx
		mrc	p15, 0, \rx, c1, c0
		tst	\rx, #1			@ MMU enabled?

		moveq	\rx, #0x74000000	@ phy addr of UART
		movne	\rx, #0xe4000000	@ virtual addr
#ifdef CONFIG_CXD4105_UART3
# if defined(CONFIG_ARCH_CXD4108)
		orr	\rx, \rx, #0x00300000	@ UART1
# else
		orr	\rx, \rx, #0x00500000	@ UART3
# endif
#else
# ifdef CONFIG_ARCH_CXD4108
		orr	\rx, \rx, #0x00200000	@ UART0
# else  /* CONFIG_ARCH_CXD4105 */
#  ifdef CONFIG_SERIAL_AMBA2_DEBUG_USE_UART0
		orr	\rx, \rx, #0x00200000	@ UART0
#  else
		orr	\rx, \rx, #0x00400000	@ UART2
#  endif
# endif
#endif
		.endm

		.macro	senduart,rd,rx
		str	\rd, [\rx, #UART01x_DR]
		.endm

		.macro	waituart,rd,rx
1001:		ldr	\rd, [\rx, #UART01x_FR]
		tst	\rd, #UART01x_FR_TXFF	@ 1 when full
		bne	1001b
		.endm

		.macro	busyuart,rd,rx
1001:		ldr	\rd, [\rx, #UART01x_FR]
		tst	\rd, #UART01x_FR_BUSY	@ 1 when busy
		bne	1001b
		.endm
