summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-13 12:28:07 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:53 -0700
commitc45a14ad576d0126932325e8df8f2e4357465546 (patch)
tree58226d73eabeb93f404da0113ac3f6749650f3cd
parent5dee6f559f2b14f2f673be6796bb57f0b191609f (diff)
downloadu-boot-imx-c45a14ad576d0126932325e8df8f2e4357465546.zip
u-boot-imx-c45a14ad576d0126932325e8df8f2e4357465546.tar.gz
u-boot-imx-c45a14ad576d0126932325e8df8f2e4357465546.tar.bz2
serial: powerpc: Implement CONFIG_SERIAL_MULTI into bmw serial driver
Implement support for CONFIG_SERIAL_MULTI into bmw 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 bmw 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: Anatolij Gustschin <agust@denx.de> Cc: Stefan Roese <sr@denx.de>
-rw-r--r--board/bmw/serial.c68
-rw-r--r--common/serial.c2
2 files changed, 64 insertions, 6 deletions
diff --git a/board/bmw/serial.c b/board/bmw/serial.c
index 0c97f12..569131f 100644
--- a/board/bmw/serial.c
+++ b/board/bmw/serial.c
@@ -22,6 +22,9 @@
*/
#include <common.h>
+#include <serial.h>
+#include <linux/compiler.h>
+
#include "ns16550.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -38,7 +41,7 @@ static struct NS16550 *console =
extern ulong get_bus_freq (ulong);
-int serial_init (void)
+static int bmw_serial_init(void)
{
int clock_divisor = gd->bus_clk / 16 / gd->baudrate;
@@ -47,7 +50,7 @@ int serial_init (void)
return (0);
}
-void serial_putc (const char c)
+static void bmw_serial_putc(const char c)
{
if (c == '\n') {
serial_putc ('\r');
@@ -55,7 +58,7 @@ void serial_putc (const char c)
NS16550_putc (console, c);
}
-void serial_puts (const char *s)
+static void bmw_serial_puts(const char *s)
{
while (*s) {
serial_putc (*s++);
@@ -63,19 +66,72 @@ void serial_puts (const char *s)
}
-int serial_getc (void)
+static int bmw_serial_getc(void)
{
return NS16550_getc (console);
}
-int serial_tstc (void)
+static int bmw_serial_tstc(void)
{
return NS16550_tstc (console);
}
-void serial_setbrg (void)
+static void bmw_serial_setbrg(void)
{
int clock_divisor = get_bus_freq (0) / 16 / gd->baudrate;
NS16550_reinit (console, clock_divisor);
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device bmw_serial_drv = {
+ .name = "bmw_serial",
+ .start = bmw_serial_init,
+ .stop = NULL,
+ .setbrg = bmw_serial_setbrg,
+ .putc = bmw_serial_putc,
+ .puts = bmw_serial_puts,
+ .getc = bmw_serial_getc,
+ .tstc = bmw_serial_tstc,
+};
+
+void bmw_serial_initialize(void)
+{
+ serial_register(&bmw_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &bmw_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return bmw_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ bmw_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ bmw_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ bmw_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return bmw_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return bmw_serial_tstc();
+}
+#endif
diff --git a/common/serial.c b/common/serial.c
index ed8bb65..755e14f 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -63,6 +63,7 @@ serial_initfunc(leon2_serial_initialize);
serial_initfunc(leon3_serial_initialize);
serial_initfunc(marvell_serial_initialize);
serial_initfunc(amirix_serial_initialize);
+serial_initfunc(bmw_serial_initialize);
void serial_register(struct serial_device *dev)
{
@@ -104,6 +105,7 @@ void serial_initialize(void)
leon3_serial_initialize();
marvell_serial_initialize();
amirix_serial_initialize();
+ bmw_serial_initialize();
serial_assign(default_serial_console()->name);
}