summaryrefslogtreecommitdiff
path: root/drivers/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/Makefile1
-rw-r--r--drivers/serial/opencores_yanu.c52
-rw-r--r--drivers/serial/serial.c2
-rw-r--r--drivers/serial/serial_arc.c105
-rw-r--r--drivers/serial/serial_s5p.c4
-rw-r--r--drivers/serial/serial_xuartlite.c14
-rw-r--r--drivers/serial/usbtty.h4
7 files changed, 136 insertions, 46 deletions
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 85374fad8f..571c18fa93 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_ZYNQ_SERIAL) += serial_zynq.o
obj-$(CONFIG_BFIN_SERIAL) += serial_bfin.o
obj-$(CONFIG_FSL_LPUART) += serial_lpuart.o
obj-$(CONFIG_MXS_AUART) += mxs_auart.o
+obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_USB_TTY) += usbtty.o
diff --git a/drivers/serial/opencores_yanu.c b/drivers/serial/opencores_yanu.c
index 8de2eca2ac..d4ed60c303 100644
--- a/drivers/serial/opencores_yanu.c
+++ b/drivers/serial/opencores_yanu.c
@@ -8,6 +8,7 @@
#include <watchdog.h>
#include <asm/io.h>
#include <nios2-yanu.h>
+#include <serial.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -17,62 +18,34 @@ DECLARE_GLOBAL_DATA_PTR;
static yanu_uart_t *uart = (yanu_uart_t *)CONFIG_SYS_NIOS_CONSOLE;
-#if defined(CONFIG_SYS_NIOS_FIXEDBAUD)
-
-/* Everything's already setup for fixed-baud PTF assignment*/
-
static void oc_serial_setbrg(void)
{
int n, k;
const unsigned max_uns = 0xFFFFFFFF;
unsigned best_n, best_m, baud;
+ unsigned baudrate;
- /* compute best N and M couple */
- best_n = YANU_MAX_PRESCALER_N;
- for (n = YANU_MAX_PRESCALER_N; n >= 0; n--) {
- if ((unsigned)CONFIG_SYS_CLK_FREQ / (1 << (n + 4)) >=
- (unsigned)CONFIG_BAUDRATE) {
- best_n = n;
- break;
- }
- }
- for (k = 0;; k++) {
- if ((unsigned)CONFIG_BAUDRATE <= (max_uns >> (15+n-k)))
- break;
- }
- best_m =
- ((unsigned)CONFIG_BAUDRATE * (1 << (15 + n - k))) /
- ((unsigned)CONFIG_SYS_CLK_FREQ >> k);
-
- baud = best_m + best_n * YANU_BAUDE;
- writel(baud, &uart->baud);
-
- return;
-}
-
+#if defined(CONFIG_SYS_NIOS_FIXEDBAUD)
+ /* Everything's already setup for fixed-baud PTF assignment */
+ baudrate = CONFIG_BAUDRATE;
#else
-
-static void oc_serial_setbrg(void)
-{
- int n, k;
- const unsigned max_uns = 0xFFFFFFFF;
- unsigned best_n, best_m, baud;
-
+ baudrate = gd->baudrate;
+#endif
/* compute best N and M couple */
best_n = YANU_MAX_PRESCALER_N;
for (n = YANU_MAX_PRESCALER_N; n >= 0; n--) {
if ((unsigned)CONFIG_SYS_CLK_FREQ / (1 << (n + 4)) >=
- gd->baudrate) {
+ baudrate) {
best_n = n;
break;
}
}
for (k = 0;; k++) {
- if (gd->baudrate <= (max_uns >> (15+n-k)))
+ if (baudrate <= (max_uns >> (15+n-k)))
break;
}
best_m =
- (gd->baudrate * (1 << (15 + n - k))) /
+ (baudrate * (1 << (15 + n - k))) /
((unsigned)CONFIG_SYS_CLK_FREQ >> k);
baud = best_m + best_n * YANU_BAUDE;
@@ -81,9 +54,6 @@ static void oc_serial_setbrg(void)
return;
}
-
-#endif /* CONFIG_SYS_NIOS_FIXEDBAUD */
-
static int oc_serial_init(void)
{
unsigned action,control;
@@ -154,7 +124,7 @@ static int oc_serial_tstc(void)
((1 << YANU_RFIFO_CHARS_N) - 1)) > 0);
}
-statoc int oc_serial_getc(void)
+static int oc_serial_getc(void)
{
while (serial_tstc() == 0)
WATCHDOG_RESET ();
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index ed1643f7b5..df05bde461 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -159,6 +159,7 @@ serial_initfunc(sa1100_serial_initialize);
serial_initfunc(sh_serial_initialize);
serial_initfunc(arm_dcc_initialize);
serial_initfunc(mxs_auart_initialize);
+serial_initfunc(arc_serial_initialize);
/**
* serial_register() - Register serial driver with serial driver core
@@ -251,6 +252,7 @@ void serial_initialize(void)
sh_serial_initialize();
arm_dcc_initialize();
mxs_auart_initialize();
+ arc_serial_initialize();
serial_assign(default_serial_console()->name);
}
diff --git a/drivers/serial/serial_arc.c b/drivers/serial/serial_arc.c
new file mode 100644
index 0000000000..e63d25d794
--- /dev/null
+++ b/drivers/serial/serial_arc.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
+ *
+ * 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 <common.h>
+#include <serial.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct arc_serial_regs {
+ unsigned int id0;
+ unsigned int id1;
+ unsigned int id2;
+ unsigned int id3;
+ unsigned int data;
+ unsigned int status;
+ unsigned int baudl;
+ unsigned int baudh;
+};
+
+/* Bit definitions of STATUS register */
+#define UART_RXEMPTY (1 << 5)
+#define UART_OVERFLOW_ERR (1 << 1)
+#define UART_TXEMPTY (1 << 7)
+
+struct arc_serial_regs *regs;
+
+static void arc_serial_setbrg(void)
+{
+ int arc_console_baud;
+
+ if (!gd->baudrate)
+ gd->baudrate = CONFIG_BAUDRATE;
+
+ arc_console_baud = gd->cpu_clk / (gd->baudrate * 4) - 1;
+ writel(arc_console_baud & 0xff, &regs->baudl);
+ writel((arc_console_baud & 0xff00) >> 8, &regs->baudh);
+}
+
+static int arc_serial_init(void)
+{
+ regs = (struct arc_serial_regs *)CONFIG_ARC_UART_BASE;
+ serial_setbrg();
+ return 0;
+}
+
+static void arc_serial_putc(const char c)
+{
+ if (c == '\n')
+ arc_serial_putc('\r');
+
+ while (!(readl(&regs->status) & UART_TXEMPTY))
+ ;
+
+ writel(c, &regs->data);
+}
+
+static int arc_serial_tstc(void)
+{
+ return !(readl(&regs->status) & UART_RXEMPTY);
+}
+
+static int arc_serial_getc(void)
+{
+ while (!arc_serial_tstc())
+ ;
+
+ /* Check for overflow errors */
+ if (readl(&regs->status) & UART_OVERFLOW_ERR)
+ return 0;
+
+ return readl(&regs->data) & 0xFF;
+}
+
+static void arc_serial_puts(const char *s)
+{
+ while (*s)
+ arc_serial_putc(*s++);
+}
+
+static struct serial_device arc_serial_drv = {
+ .name = "arc_serial",
+ .start = arc_serial_init,
+ .stop = NULL,
+ .setbrg = arc_serial_setbrg,
+ .putc = arc_serial_putc,
+ .puts = arc_serial_puts,
+ .getc = arc_serial_getc,
+ .tstc = arc_serial_tstc,
+};
+
+void arc_serial_initialize(void)
+{
+ serial_register(&arc_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &arc_serial_drv;
+}
diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c
index 89f5d68dd0..98c62b4c14 100644
--- a/drivers/serial/serial_s5p.c
+++ b/drivers/serial/serial_s5p.c
@@ -100,8 +100,8 @@ static int serial_init_dev(const int dev_index)
{
struct s5p_uart *const uart = s5p_get_base_uart(dev_index);
- /* enable FIFOs */
- writel(0x1, &uart->ufcon);
+ /* enable FIFOs, auto clear Rx FIFO */
+ writel(0x3, &uart->ufcon);
writel(0, &uart->umcon);
/* 8N1 */
writel(0x3, &uart->ulcon);
diff --git a/drivers/serial/serial_xuartlite.c b/drivers/serial/serial_xuartlite.c
index e6139943ba..988438e754 100644
--- a/drivers/serial/serial_xuartlite.c
+++ b/drivers/serial/serial_xuartlite.c
@@ -18,10 +18,14 @@
#define SR_RX_FIFO_VALID_DATA 0x01 /* data in receive FIFO */
#define SR_RX_FIFO_FULL 0x02 /* receive FIFO full */
+#define ULITE_CONTROL_RST_TX 0x01
+#define ULITE_CONTROL_RST_RX 0x02
+
struct uartlite {
unsigned int rx_fifo;
unsigned int tx_fifo;
unsigned int status;
+ unsigned int control;
};
static struct uartlite *userial_ports[4] = {
@@ -75,8 +79,16 @@ static int uartlite_serial_tstc(const int port)
static int uartlite_serial_init(const int port)
{
- if (userial_ports[port])
+ struct uartlite *regs = userial_ports[port];
+
+ if (regs) {
+ out_be32(&regs->control, 0);
+ out_be32(&regs->control,
+ ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX);
+ in_be32(&regs->control);
return 0;
+ }
+
return -1;
}
diff --git a/drivers/serial/usbtty.h b/drivers/serial/usbtty.h
index 819dec663f..21a3ef4d97 100644
--- a/drivers/serial/usbtty.h
+++ b/drivers/serial/usbtty.h
@@ -20,8 +20,8 @@
#include <usb/pxa27x_udc.h>
#elif defined(CONFIG_DW_UDC)
#include <usb/designware_udc.h>
-#elif defined(CONFIG_MV_UDC)
-#include <usb/mv_udc.h>
+#elif defined(CONFIG_CI_UDC)
+#include <usb/ci_udc.h>
#endif
#include <usb/udc.h>