summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-14 22:39:19 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:57 -0700
commiteb5076697ad1f860db2064b2ccaed3c3c9d555d9 (patch)
tree4fad4e108d27b2a0bbe54b95e07e9aab88ea4b39
parent39f614779f12065a84e5cc49be3db69079114f31 (diff)
serial: arm: Implement CONFIG_SERIAL_MULTI into s3c44b0 serial driver
Implement support for CONFIG_SERIAL_MULTI into s3c44b0 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 s3c44b0 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>
-rw-r--r--common/serial.c2
-rw-r--r--drivers/serial/serial_s3c44b0.c68
2 files changed, 62 insertions, 8 deletions
diff --git a/common/serial.c b/common/serial.c
index 96e69d52b99..d60e6d2750f 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -90,6 +90,7 @@ serial_initfunc(max3100_serial_initialize);
serial_initfunc(mxc_serial_initialize);
serial_initfunc(netarm_serial_initialize);
serial_initfunc(pl01x_serial_initialize);
+serial_initfunc(s3c44b0_serial_initialize);
void serial_register(struct serial_device *dev)
{
@@ -158,6 +159,7 @@ void serial_initialize(void)
mxc_serial_initialize();
netarm_serial_initialize();
pl01x_serial_initialize();
+ s3c44b0_serial_initialize();
serial_assign(default_serial_console()->name);
}
diff --git a/drivers/serial/serial_s3c44b0.c b/drivers/serial/serial_s3c44b0.c
index 95d0266c6c6..8beba1abc82 100644
--- a/drivers/serial/serial_s3c44b0.c
+++ b/drivers/serial/serial_s3c44b0.c
@@ -68,7 +68,7 @@ static int serial_flush_output(void)
}
-void serial_setbrg (void)
+static void s3c44b0_serial_setbrg(void)
{
u32 divisor = 0;
@@ -156,7 +156,7 @@ void serial_setbrg (void)
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*
*/
-int serial_init (void)
+static int s3c44b0_serial_init(void)
{
serial_setbrg ();
@@ -167,7 +167,7 @@ int serial_init (void)
/*
* Output a single byte to the serial port.
*/
-void serial_putc (const char c)
+static void s3c44b0_serial_putc(const char c)
{
/* wait for room in the transmit FIFO */
while(!(UTRSTAT0 & 0x02));
@@ -187,7 +187,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 s3c44b0_serial_tstc(void)
{
return (UTRSTAT0 & 0x01);
}
@@ -197,22 +197,74 @@ 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 s3c44b0_serial_getc(void)
{
int rv;
for(;;) {
- rv = serial_tstc();
+ rv = s3c44b0_serial_tstc();
if(rv > 0)
return URXH0;
}
}
-void
-serial_puts (const char *s)
+static void s3c44b0_serial_puts(const char *s)
{
while (*s) {
serial_putc (*s++);
}
}
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device s3c44b0_serial_drv = {
+ .name = "s3c44b0_serial",
+ .start = s3c44b0_serial_init,
+ .stop = NULL,
+ .setbrg = s3c44b0_serial_setbrg,
+ .putc = s3c44b0_serial_putc,
+ .puts = s3c44b0_serial_puts,
+ .getc = s3c44b0_serial_getc,
+ .tstc = s3c44b0_serial_tstc,
+};
+
+void s3c44b0_serial_initialize(void)
+{
+ serial_register(&s3c44b0_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &s3c44b0_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return s3c44b0_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ s3c44b0_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ s3c44b0_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ s3c44b0_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return s3c44b0_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return s3c44b0_serial_tstc();
+}
+#endif