#define UART_OVERFLOW_ERR (1 << 1)
#define UART_TXEMPTY (1 << 7)
-struct arc_serial_regs *regs;
+struct arc_serial_regs *regs = (struct arc_serial_regs *)CONFIG_ARC_UART_BASE;
static void arc_serial_setbrg(void)
{
gd->baudrate = CONFIG_BAUDRATE;
arc_console_baud = gd->cpu_clk / (gd->baudrate * 4) - 1;
- writel(arc_console_baud & 0xff, ®s->baudl);
- writel((arc_console_baud & 0xff00) >> 8, ®s->baudh);
+ writeb(arc_console_baud & 0xff, ®s->baudl);
+
+#ifdef CONFIG_ARC
+ /*
+ * UART ISS(Instruction Set simulator) emulation has a subtle bug:
+ * A existing value of Baudh = 0 is used as a indication to startup
+ * it's internal state machine.
+ * Thus if baudh is set to 0, 2 times, it chokes.
+ * This happens with BAUD=115200 and the formaula above
+ * Until that is fixed, when running on ISS, we will set baudh to !0
+ */
+ if (gd->arch.running_on_hw)
+ writeb((arc_console_baud & 0xff00) >> 8, ®s->baudh);
+ else
+ writeb(1, ®s->baudh);
+#else
+ writeb((arc_console_baud & 0xff00) >> 8, ®s->baudh);
+#endif
}
static int arc_serial_init(void)
{
- regs = (struct arc_serial_regs *)CONFIG_ARC_UART_BASE;
serial_setbrg();
return 0;
}
if (c == '\n')
arc_serial_putc('\r');
- while (!(readl(®s->status) & UART_TXEMPTY))
+ while (!(readb(®s->status) & UART_TXEMPTY))
;
- writel(c, ®s->data);
+ writeb(c, ®s->data);
}
static int arc_serial_tstc(void)
{
- return !(readl(®s->status) & UART_RXEMPTY);
+ return !(readb(®s->status) & UART_RXEMPTY);
}
static int arc_serial_getc(void)
;
/* Check for overflow errors */
- if (readl(®s->status) & UART_OVERFLOW_ERR)
+ if (readb(®s->status) & UART_OVERFLOW_ERR)
return 0;
- return readl(®s->data) & 0xFF;
-}
-
-static void arc_serial_puts(const char *s)
-{
- while (*s)
- arc_serial_putc(*s++);
+ return readb(®s->data) & 0xFF;
}
static struct serial_device arc_serial_drv = {
.stop = NULL,
.setbrg = arc_serial_setbrg,
.putc = arc_serial_putc,
- .puts = arc_serial_puts,
+ .puts = default_serial_puts,
.getc = arc_serial_getc,
.tstc = arc_serial_tstc,
};