#include <config.h>
#include <stdint.h>
#include <util.h>
#include <machine/io.h>
#include <plat/machine/devices.h>
#define UART_REG(x) ((volatile uint32_t *)(UART_PPTR + (x)))
#define MU_IO 0x40
#define MU_IIR 0x44
#define MU_IER 0x48
#define MU_LCR 0x4C
#define MU_MCR 0x50
#define MU_LSR 0x54
#define MU_MSR 0x58
#define MU_SCRATCH 0x5C
#define MU_CNTL 0x60
#define MU_LSR_TXEMPTY BIT(5)
#define MU_LSR_TXIDLE BIT(6)
#define MU_LSR_RXOVERRUN BIT(1)
#define MU_LSR_DATAREADY BIT(0)
#define MU_LCR_DLAB BIT(7)
#define MU_LCR_BREAK BIT(6)
#define MU_LCR_DATASIZE BIT(0)
#if defined(CONFIG_DEBUG_BUILD) || defined(CONFIG_PRINTING)
void putDebugChar(unsigned char c)
{
while ( !(*UART_REG(MU_LSR) & MU_LSR_TXIDLE) );
*UART_REG(MU_IO) = (c & 0xff);
}
#endif
#ifdef CONFIG_DEBUG_BUILD
unsigned char getDebugChar(void)
{
while ( !(*UART_REG(MU_LSR) & MU_LSR_DATAREADY) );
return *UART_REG(MU_IO);
}
#endif