summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-13 12:25:07 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:52 -0700
commitaf7be3b6a986c48673ef5bf903146efd3205814b (patch)
tree08954114e8ef7417bd79811b6a31f371b053ea3b
parentfcc2074d5799255e6a56a2adc48fcc03f0889e00 (diff)
downloadu-boot-imx-af7be3b6a986c48673ef5bf903146efd3205814b.zip
u-boot-imx-af7be3b6a986c48673ef5bf903146efd3205814b.tar.gz
u-boot-imx-af7be3b6a986c48673ef5bf903146efd3205814b.tar.bz2
serial: sparc: Implement CONFIG_SERIAL_MULTI into leon2 serial driver
Implement support for CONFIG_SERIAL_MULTI into leon2 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 leon2 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: Peter Tyser <ptyser@xes-inc.com>
-rw-r--r--arch/sparc/cpu/leon2/serial.c83
-rw-r--r--common/serial.c2
2 files changed, 71 insertions, 14 deletions
diff --git a/arch/sparc/cpu/leon2/serial.c b/arch/sparc/cpu/leon2/serial.c
index 4f41b8e..61d059b 100644
--- a/arch/sparc/cpu/leon2/serial.c
+++ b/arch/sparc/cpu/leon2/serial.c
@@ -26,6 +26,8 @@
#include <common.h>
#include <asm/processor.h>
#include <asm/leon.h>
+#include <serial.h>
+#include <linux/compiler.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -39,7 +41,7 @@ DECLARE_GLOBAL_DATA_PTR;
#define READ_DWORD(var) SPARC_NOCACHE_READ_DWORD((unsigned int)&(var))
#endif
-int serial_init(void)
+static int leon2_serial_init(void)
{
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
LEON2_Uart_regs *regs;
@@ -72,15 +74,7 @@ int serial_init(void)
return 0;
}
-void serial_putc(const char c)
-{
- if (c == '\n')
- serial_putc_raw('\r');
-
- serial_putc_raw(c);
-}
-
-void serial_putc_raw(const char c)
+static void leon2_serial_putc_raw(const char c)
{
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
LEON2_Uart_regs *regs;
@@ -103,14 +97,22 @@ void serial_putc_raw(const char c)
#endif
}
-void serial_puts(const char *s)
+static void leon2_serial_putc(const char c)
+{
+ if (c == '\n')
+ leon2_serial_putc_raw('\r');
+
+ leon2_serial_putc_raw(c);
+}
+
+static void leon2_serial_puts(const char *s)
{
while (*s) {
serial_putc(*s++);
}
}
-int serial_getc(void)
+static int leon2_serial_getc(void)
{
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
LEON2_Uart_regs *regs;
@@ -128,7 +130,7 @@ int serial_getc(void)
return READ_WORD(regs->UART_Channel);
}
-int serial_tstc(void)
+static int leon2_serial_tstc(void)
{
LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
LEON2_Uart_regs *regs;
@@ -143,7 +145,7 @@ int serial_tstc(void)
}
/* set baud rate for uart */
-void serial_setbrg(void)
+static void leon2_serial_setbrg(void)
{
/* update baud rate settings, read it from gd->baudrate */
unsigned int scaler;
@@ -163,3 +165,56 @@ void serial_setbrg(void)
regs->UART_Scaler = scaler;
}
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device leon2_serial_drv = {
+ .name = "leon2_serial",
+ .start = leon2_serial_init,
+ .stop = NULL,
+ .setbrg = leon2_serial_setbrg,
+ .putc = leon2_serial_putc,
+ .puts = leon2_serial_puts,
+ .getc = leon2_serial_getc,
+ .tstc = leon2_serial_tstc,
+};
+
+void leon2_serial_initialize(void)
+{
+ serial_register(&leon2_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &leon2_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return leon2_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ leon2_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ leon2_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ leon2_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return leon2_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return leon2_serial_tstc();
+}
+#endif
diff --git a/common/serial.c b/common/serial.c
index 07573d1..34a6530 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -59,6 +59,7 @@ serial_initfunc(mpc8260_scc_serial_initialize);
serial_initfunc(mpc8260_smc_serial_initialize);
serial_initfunc(mpc85xx_serial_initialize);
serial_initfunc(iop480_serial_initialize);
+serial_initfunc(leon2_serial_initialize);
void serial_register(struct serial_device *dev)
{
@@ -96,6 +97,7 @@ void serial_initialize(void)
mpc8260_smc_serial_initialize();
mpc85xx_serial_initialize();
iop480_serial_initialize();
+ leon2_serial_initialize();
serial_assign(default_serial_console()->name);
}