/*
 *  include/asm-arm/arch-mx3/debug-macro.S
 *
 * Debugging macro include header
 *
 *  Copyright 2004 Freescale Semiconductor, Inc. All Rights Reserved.
 *
 * 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.
 *
 */

        .macro  addruart,rx
                mrc     p15, 0, \rx, c1, c0
                tst     \rx, #1                 /* MMU enabled? */
#ifdef CONFIG_SERIAL_8250_CONSOLE
                ldreq   \rx, =CS4_BASE_ADDR + 0x10000 /* Physical Addr of EXT UART A */
                ldrne   \rx, =CS4_IO_ADDRESS(CS4_BASE_ADDR + 0x10000) /* Virtual Addr */
#else
                ldreq   \rx, =UART2_BASE_ADDR /* Physical Addr of MXC UART 2 */
                ldrne   \rx, =AIPS1_IO_ADDRESS(UART2_BASE_ADDR) /* Virtual Addr */
#endif

        .endm

        .macro  senduart,rd,rx
#ifdef CONFIG_SERIAL_8250_CONSOLE
                strb    \rd, [\rx]
#else
                strh    \rd, [\rx, #0x40]
#endif
        .endm

        .macro  busyuart,rd,rx
        .endm

        .macro  waituart,rd,rx
#ifdef CONFIG_SERIAL_8250_CONSOLE
1001:           ldrb    \rd, [\rx, #0x5]        /* LSR_TEMPT ? */
                tst     \rd, #0x40
#else
1001:           ldrh    \rd, [\rx, #0x98]       /* TXFE ? */
                tst     \rd, #0x4000
#endif
                beq     1001b
        .endm
