summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-13 16:51:38 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:54 -0700
commitabaef69fbe683197607febeb2cc619490aca2a10 (patch)
tree184dc891b66e51100c9c76142387199d6098d63c
parente503f90a5764856b932aeaa9d66c60f037852557 (diff)
downloadu-boot-imx-abaef69fbe683197607febeb2cc619490aca2a10.zip
u-boot-imx-abaef69fbe683197607febeb2cc619490aca2a10.tar.gz
u-boot-imx-abaef69fbe683197607febeb2cc619490aca2a10.tar.bz2
serial: mcf: Implement CONFIG_SERIAL_MULTI into MCF serial driver
Implement support for CONFIG_SERIAL_MULTI into MCF serial driver. This driver was so far only usable directly, but this patch also adds support for the multi method. This allows using more than one serial driver alongside the MCF driver. Also, add a weak implementation of default_serial_console() returning this driver. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Marek Vasut <marek.vasut@gmail.com> Cc: Tom Rini <trini@ti.com> Cc: TsiChung Liew <tsicliew@gmail.com>
-rw-r--r--common/serial.c2
-rw-r--r--drivers/serial/mcfuart.c65
2 files changed, 61 insertions, 6 deletions
diff --git a/common/serial.c b/common/serial.c
index b065a99..e077df9 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -74,6 +74,7 @@ serial_initfunc(altera_jtag_serial_initialize);
serial_initfunc(altera_serial_initialize);
serial_initfunc(atmel_serial_initialize);
serial_initfunc(lpc32xx_serial_initialize);
+serial_initfunc(mcf_serial_initialize);
void serial_register(struct serial_device *dev)
{
@@ -126,6 +127,7 @@ void serial_initialize(void)
altera_serial_initialize();
atmel_serial_initialize();
lpc32xx_serial_initialize();
+ mcf_serial_initialize();
serial_assign(default_serial_console()->name);
}
diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c
index d93b24b..7e0b765 100644
--- a/drivers/serial/mcfuart.c
+++ b/drivers/serial/mcfuart.c
@@ -36,7 +36,7 @@ DECLARE_GLOBAL_DATA_PTR;
extern void uart_port_conf(int port);
-int serial_init(void)
+static int mcf_serial_init(void)
{
volatile uart_t *uart;
u32 counter;
@@ -74,7 +74,7 @@ int serial_init(void)
return (0);
}
-void serial_putc(const char c)
+static void mcf_serial_putc(const char c)
{
volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
@@ -87,14 +87,14 @@ void serial_putc(const char c)
uart->utb = c;
}
-void serial_puts(const char *s)
+static void mcf_serial_puts(const char *s)
{
while (*s) {
serial_putc(*s++);
}
}
-int serial_getc(void)
+static int mcf_serial_getc(void)
{
volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
@@ -103,14 +103,14 @@ int serial_getc(void)
return uart->urb;
}
-int serial_tstc(void)
+static int mcf_serial_tstc(void)
{
volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
return (uart->usr & UART_USR_RXRDY);
}
-void serial_setbrg(void)
+static void mcf_serial_setbrg(void)
{
volatile uart_t *uart = (volatile uart_t *)(CONFIG_SYS_UART_BASE);
u32 counter;
@@ -129,3 +129,56 @@ void serial_setbrg(void)
uart->ucr = UART_UCR_RX_ENABLED | UART_UCR_TX_ENABLED;
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device mcf_serial_drv = {
+ .name = "mcf_serial",
+ .start = mcf_serial_init,
+ .stop = NULL,
+ .setbrg = mcf_serial_setbrg,
+ .putc = mcf_serial_putc,
+ .puts = mcf_serial_puts,
+ .getc = mcf_serial_getc,
+ .tstc = mcf_serial_tstc,
+};
+
+void mcf_serial_initialize(void)
+{
+ serial_register(&mcf_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &mcf_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return mcf_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ mcf_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ mcf_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ mcf_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return mcf_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return mcf_serial_tstc();
+}
+#endif