]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
serial: arm: Implement CONFIG_SERIAL_MULTI into s3c64xx serial driver
authorMarek Vasut <marex@denx.de>
Thu, 13 Sep 2012 14:53:49 +0000 (16:53 +0200)
committerTom Rini <trini@ti.com>
Mon, 15 Oct 2012 18:53:55 +0000 (11:53 -0700)
Implement support for CONFIG_SERIAL_MULTI into s3c64xx 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 s3c64xx 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: John Rigby <john.rigby@linaro.org>
Cc: Minkyu Kang <mk7.kang@samsung.com>
common/serial.c
drivers/serial/s3c64xx.c

index ebf6d6bbb7e1d5341cabdc8cc608919813eb936d..db577d1ad098dd38f12899de18e1a768fc06ada1 100644 (file)
@@ -78,6 +78,7 @@ serial_initfunc(mcf_serial_initialize);
 serial_initfunc(ns9750_serial_initialize);
 serial_initfunc(oc_serial_initialize);
 serial_initfunc(s3c4510b_serial_initialize);
+serial_initfunc(s3c64xx_serial_initialize);
 
 void serial_register(struct serial_device *dev)
 {
@@ -134,6 +135,7 @@ void serial_initialize(void)
        ns9750_serial_initialize();
        oc_serial_initialize();
        s3c4510b_serial_initialize();
+       s3c64xx_serial_initialize();
 
        serial_assign(default_serial_console()->name);
 }
index a88e930945d4928945f6041bdfe61a14c70c0f70..823425bbeac0ffc5b455d3f1364aa1da04c7c12b 100644 (file)
@@ -68,7 +68,7 @@ static const int udivslot[] = {
        0xffdf,
 };
 
-void serial_setbrg(void)
+static void s3c64xx_serial_setbrg(void)
 {
        s3c64xx_uart *const uart = s3c64xx_get_base_uart(UART_NR);
        u32 pclk = get_PCLK();
@@ -88,7 +88,7 @@ void serial_setbrg(void)
  * Initialise the serial port with the given baudrate. The settings
  * are always 8 data bits, no parity, 1 stop bit, no start bits.
  */
-int serial_init(void)
+static int s3c64xx_serial_init(void)
 {
        s3c64xx_uart *const uart = s3c64xx_get_base_uart(UART_NR);
 
@@ -110,7 +110,7 @@ int serial_init(void)
  * otherwise. When the function is succesfull, the character read is
  * written into its argument c.
  */
-int serial_getc(void)
+static int s3c64xx_serial_getc(void)
 {
        s3c64xx_uart *const uart = s3c64xx_get_base_uart(UART_NR);
 
@@ -137,7 +137,7 @@ void enable_putc(void)
 /*
  * Output a single byte to the serial port.
  */
-void serial_putc(const char c)
+static void s3c64xx_serial_putc(const char c)
 {
        s3c64xx_uart *const uart = s3c64xx_get_base_uart(UART_NR);
 
@@ -159,15 +159,68 @@ void serial_putc(const char c)
 /*
  * Test whether a character is in the RX buffer
  */
-int serial_tstc(void)
+static int s3c64xx_serial_tstc(void)
 {
        s3c64xx_uart *const uart = s3c64xx_get_base_uart(UART_NR);
 
        return uart->UTRSTAT & 0x1;
 }
 
-void serial_puts(const char *s)
+static void s3c64xx_serial_puts(const char *s)
 {
        while (*s)
                serial_putc(*s++);
 }
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device s3c64xx_serial_drv = {
+       .name   = "s3c64xx_serial",
+       .start  = s3c64xx_serial_init,
+       .stop   = NULL,
+       .setbrg = s3c64xx_serial_setbrg,
+       .putc   = s3c64xx_serial_putc,
+       .puts   = s3c64xx_serial_puts,
+       .getc   = s3c64xx_serial_getc,
+       .tstc   = s3c64xx_serial_tstc,
+};
+
+void s3c64xx_serial_initialize(void)
+{
+       serial_register(&s3c64xx_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+       return &s3c64xx_serial_drv;
+}
+#else
+int serial_init(void)
+{
+       return s3c64xx_serial_init();
+}
+
+void serial_setbrg(void)
+{
+       s3c64xx_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+       s3c64xx_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+       s3c64xx_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+       return s3c64xx_serial_getc();
+}
+
+int serial_tstc(void)
+{
+       return s3c64xx_serial_tstc();
+}
+#endif