summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-14 22:33:21 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:55 -0700
commitcef46b7792d4171bc7b17a3a4ae4c53bb6e78654 (patch)
tree1e59e2978a7fc534eb3bea3fd906356debcfe0ef /drivers
parentcc61c31df26f06a1ee92bfee51fb4cf74ee30d06 (diff)
downloadu-boot-imx-cef46b7792d4171bc7b17a3a4ae4c53bb6e78654.zip
u-boot-imx-cef46b7792d4171bc7b17a3a4ae4c53bb6e78654.tar.gz
u-boot-imx-cef46b7792d4171bc7b17a3a4ae4c53bb6e78654.tar.bz2
serial: sandbox: Implement CONFIG_SERIAL_MULTI into sandbox serial driver
Implement support for CONFIG_SERIAL_MULTI into sandbox 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 sandbox 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: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/sandbox.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c
index 1927c16..d60fbba 100644
--- a/drivers/serial/sandbox.c
+++ b/drivers/serial/sandbox.c
@@ -27,28 +27,30 @@
#include <common.h>
#include <os.h>
+#include <serial.h>
+#include <linux/compiler.h>
-int serial_init(void)
+static int sandbox_serial_init(void)
{
os_tty_raw(0);
return 0;
}
-void serial_setbrg(void)
+static void sandbox_serial_setbrg(void)
{
}
-void serial_putc(const char ch)
+static void sandbox_serial_putc(const char ch)
{
os_write(1, &ch, 1);
}
-void serial_puts(const char *str)
+static void sandbox_serial_puts(const char *str)
{
os_write(1, str, strlen(str));
}
-int serial_getc(void)
+static int sandbox_serial_getc(void)
{
char buf;
ssize_t count;
@@ -57,7 +59,60 @@ int serial_getc(void)
return count == 1 ? buf : 0;
}
-int serial_tstc(void)
+static int sandbox_serial_tstc(void)
{
return 0;
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device sandbox_serial_drv = {
+ .name = "sandbox_serial",
+ .start = sandbox_serial_init,
+ .stop = NULL,
+ .setbrg = sandbox_serial_setbrg,
+ .putc = sandbox_serial_putc,
+ .puts = sandbox_serial_puts,
+ .getc = sandbox_serial_getc,
+ .tstc = sandbox_serial_tstc,
+};
+
+void sandbox_serial_initialize(void)
+{
+ serial_register(&sandbox_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &sandbox_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return sandbox_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ sandbox_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ sandbox_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ sandbox_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return sandbox_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return sandbox_serial_tstc();
+}
+#endif