summaryrefslogtreecommitdiff
path: root/drivers/serial/serial_ixp.c
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-14 22:35:14 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:56 -0700
commitb6cd0fef93b84c3238edeafc95134dbcabb838ca (patch)
tree2310e713a22e028f8757f5bdbd43eeb73522ef5f /drivers/serial/serial_ixp.c
parent7882e7c18297ae1d00fd4068cabd80d3c5762453 (diff)
downloadu-boot-imx-b6cd0fef93b84c3238edeafc95134dbcabb838ca.zip
u-boot-imx-b6cd0fef93b84c3238edeafc95134dbcabb838ca.tar.gz
u-boot-imx-b6cd0fef93b84c3238edeafc95134dbcabb838ca.tar.bz2
serial: arm: Implement CONFIG_SERIAL_MULTI into ixp serial driver
Implement support for CONFIG_SERIAL_MULTI into ixp 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 ixp 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: Michael Schwingen <michael@schwingen.org>
Diffstat (limited to 'drivers/serial/serial_ixp.c')
-rw-r--r--drivers/serial/serial_ixp.c68
1 files changed, 61 insertions, 7 deletions
diff --git a/drivers/serial/serial_ixp.c b/drivers/serial/serial_ixp.c
index a9acd47..6e3f7f0 100644
--- a/drivers/serial/serial_ixp.c
+++ b/drivers/serial/serial_ixp.c
@@ -31,6 +31,8 @@
#include <common.h>
#include <asm/arch/ixp425.h>
#include <watchdog.h>
+#include <serial.h>
+#include <linux/compiler.h>
/*
* 14.7456 MHz
@@ -41,7 +43,7 @@
DECLARE_GLOBAL_DATA_PTR;
-void serial_setbrg (void)
+static void ixp_serial_setbrg(void)
{
unsigned int quot = 0;
int uart = CONFIG_SYS_IXP425_CONSOLE;
@@ -72,7 +74,7 @@ void serial_setbrg (void)
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*
*/
-int serial_init (void)
+static int ixp_serial_init(void)
{
serial_setbrg ();
@@ -83,7 +85,7 @@ int serial_init (void)
/*
* Output a single byte to the serial port.
*/
-void serial_putc (const char c)
+static void ixp_serial_putc(const char c)
{
/* wait for room in the tx FIFO on UART */
while ((LSR(CONFIG_SYS_IXP425_CONSOLE) & LSR_TEMT) == 0)
@@ -101,7 +103,7 @@ void serial_putc (const char c)
* otherwise. When the function is succesfull, the character read is
* written into its argument c.
*/
-int serial_tstc (void)
+static int ixp_serial_tstc(void)
{
return LSR(CONFIG_SYS_IXP425_CONSOLE) & LSR_DR;
}
@@ -111,7 +113,7 @@ int serial_tstc (void)
* otherwise. When the function is succesfull, the character read is
* written into its argument c.
*/
-int serial_getc (void)
+static int ixp_serial_getc(void)
{
while (!(LSR(CONFIG_SYS_IXP425_CONSOLE) & LSR_DR))
WATCHDOG_RESET(); /* Reset HW Watchdog, if needed */
@@ -119,10 +121,62 @@ int serial_getc (void)
return (char) RBR(CONFIG_SYS_IXP425_CONSOLE) & 0xff;
}
-void
-serial_puts (const char *s)
+static void ixp_serial_puts(const char *s)
{
while (*s) {
serial_putc (*s++);
}
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device ixp_serial_drv = {
+ .name = "ixp_serial",
+ .start = ixp_serial_init,
+ .stop = NULL,
+ .setbrg = ixp_serial_setbrg,
+ .putc = ixp_serial_putc,
+ .puts = ixp_serial_puts,
+ .getc = ixp_serial_getc,
+ .tstc = ixp_serial_tstc,
+};
+
+void ixp_serial_initialize(void)
+{
+ serial_register(&ixp_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &ixp_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return ixp_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ ixp_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ ixp_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ ixp_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return ixp_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return ixp_serial_tstc();
+}
+#endif