#include <dm/platform_data/serial_mxc.h>
#include <serial.h>
#include <linux/compiler.h>
+#include <linux/delay.h>
/* UART Control Register Bit Fields.*/
#define URXD_CHARRDY (1<<15)
u32 ts;
};
+static void _mxc_serial_flush(struct mxc_uart *base)
+{
+ unsigned int timeout = 4000;
+
+ if (!(readl(&base->cr1) & UCR1_UARTEN) ||
+ !(readl(&base->cr2) & UCR2_TXEN))
+ return;
+
+ while (!(readl(&base->sr2) & USR2_TXDC) && --timeout)
+ udelay(1);
+}
+
static void _mxc_serial_init(struct mxc_uart *base, int use_dte)
{
+ _mxc_serial_flush(base);
+
writel(0, &base->cr1);
writel(0, &base->cr2);
{
u32 tmp;
+ _mxc_serial_flush(base);
+
tmp = RFDIV << UFCR_RFDIV_SHF;
if (use_dte)
tmp |= UFCR_DCEDTE;
return 0;
}
+static int mxc_serial_stop(void)
+{
+ _mxc_serial_flush(mxc_base);
+
+ return 0;
+}
+
static struct serial_device mxc_serial_drv = {
.name = "mxc_serial",
.start = mxc_serial_init,
- .stop = NULL,
+ .stop = mxc_serial_stop,
.setbrg = mxc_serial_setbrg,
.putc = mxc_serial_putc,
.puts = default_serial_puts,