diff options
author | Marek Vasut <marex@denx.de> | 2012-09-14 22:34:51 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-10-15 11:53:55 -0700 |
commit | 7882e7c18297ae1d00fd4068cabd80d3c5762453 (patch) | |
tree | d21093c35777b4e6a9bcfbd2263182e1dd66443c /drivers/serial | |
parent | 8b029db85916b1332c5f9cae024a91ddbe418b8e (diff) |
serial: arm: Implement CONFIG_SERIAL_MULTI into imx serial driver
Implement support for CONFIG_SERIAL_MULTI into imx 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 imx 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: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/serial_imx.c | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c index b9ca748f69b..d37ec29bd9f 100644 --- a/drivers/serial/serial_imx.c +++ b/drivers/serial/serial_imx.c @@ -19,6 +19,8 @@ #include <common.h> #include <asm/arch/imx-regs.h> +#include <serial.h> +#include <linux/compiler.h> #if defined CONFIG_IMX_SERIAL1 #define UART_BASE IMX_UART1_BASE @@ -50,7 +52,7 @@ struct imx_serial { DECLARE_GLOBAL_DATA_PTR; -void serial_setbrg (void) +static void imx_serial_setbrg(void) { serial_init(); } @@ -62,7 +64,7 @@ extern void imx_gpio_mode(int gpio_mode); * are always 8 data bits, no parity, 1 stop bit, no start bits. * */ -int serial_init (void) +static int imx_serial_init(void) { volatile struct imx_serial* base = (struct imx_serial *)UART_BASE; unsigned int ufcr_rfdiv; @@ -163,7 +165,7 @@ int serial_init (void) * otherwise. When the function is successful, the character read is * written into its argument c. */ -int serial_getc (void) +static int imx_serial_getc(void) { volatile struct imx_serial* base = (struct imx_serial *)UART_BASE; unsigned char ch; @@ -185,7 +187,7 @@ int hwflow_onoff(int on) /* * Output a single byte to the serial port. */ -void serial_putc (const char c) +static void imx_serial_putc(const char c) { volatile struct imx_serial* base = (struct imx_serial *)UART_BASE; @@ -202,7 +204,7 @@ void serial_putc (const char c) /* * Test whether a character is in the RX buffer */ -int serial_tstc (void) +static int imx_serial_tstc(void) { volatile struct imx_serial* base = (struct imx_serial *)UART_BASE; @@ -212,10 +214,62 @@ int serial_tstc (void) return 1; } -void -serial_puts (const char *s) +static void imx_serial_puts(const char *s) { while (*s) { serial_putc (*s++); } } + +#ifdef CONFIG_SERIAL_MULTI +static struct serial_device imx_serial_drv = { + .name = "imx_serial", + .start = imx_serial_init, + .stop = NULL, + .setbrg = imx_serial_setbrg, + .putc = imx_serial_putc, + .puts = imx_serial_puts, + .getc = imx_serial_getc, + .tstc = imx_serial_tstc, +}; + +void imx_serial_initialize(void) +{ + serial_register(&imx_serial_drv); +} + +__weak struct serial_device *default_serial_console(void) +{ + return &imx_serial_drv; +} +#else +int serial_init(void) +{ + return imx_serial_init(); +} + +void serial_setbrg(void) +{ + imx_serial_setbrg(); +} + +void serial_putc(const char c) +{ + imx_serial_putc(c); +} + +void serial_puts(const char *s) +{ + imx_serial_puts(s); +} + +int serial_getc(void) +{ + return imx_serial_getc(); +} + +int serial_tstc(void) +{ + return imx_serial_tstc(); +} +#endif |