diff options
author | Marek Vasut <marex@denx.de> | 2012-09-14 22:34:22 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-10-15 11:53:55 -0700 |
commit | 8b029db85916b1332c5f9cae024a91ddbe418b8e (patch) | |
tree | 016ddd17b1c24c92557ae77b41f58637c65332d4 /drivers | |
parent | cef46b7792d4171bc7b17a3a4ae4c53bb6e78654 (diff) | |
download | u-boot-8b029db85916b1332c5f9cae024a91ddbe418b8e.zip u-boot-8b029db85916b1332c5f9cae024a91ddbe418b8e.tar.gz u-boot-8b029db85916b1332c5f9cae024a91ddbe418b8e.tar.bz2 |
serial: arm: Implement CONFIG_SERIAL_MULTI into clps7111 serial driver
Implement support for CONFIG_SERIAL_MULTI into clps7111 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 clps7111 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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/serial/serial_clps7111.c | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/drivers/serial/serial_clps7111.c b/drivers/serial/serial_clps7111.c index a6aecad..e1bed90 100644 --- a/drivers/serial/serial_clps7111.c +++ b/drivers/serial/serial_clps7111.c @@ -33,7 +33,7 @@ DECLARE_GLOBAL_DATA_PTR; -void serial_setbrg (void) +static void clps7111_serial_setbrg(void) { unsigned int reg = 0; @@ -63,7 +63,7 @@ void serial_setbrg (void) * are always 8 data bits, no parity, 1 stop bit, no start bits. * */ -int serial_init (void) +static int clps7111_serial_init(void) { serial_setbrg (); @@ -74,7 +74,7 @@ int serial_init (void) /* * Output a single byte to the serial port. */ -void serial_putc (const char c) +static void clps7111_serial_putc(const char c) { int tmo; @@ -95,7 +95,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 clps7111_serial_tstc(void) { return !(IO_SYSFLG1 & SYSFLG1_URXFE); } @@ -105,17 +105,69 @@ 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 clps7111_serial_getc(void) { while (IO_SYSFLG1 & SYSFLG1_URXFE); return IO_UARTDR1 & 0xff; } -void -serial_puts (const char *s) +static void clps7111_serial_puts(const char *s) { while (*s) { serial_putc (*s++); } } + +#ifdef CONFIG_SERIAL_MULTI +static struct serial_device clps7111_serial_drv = { + .name = "clps7111_serial", + .start = clps7111_serial_init, + .stop = NULL, + .setbrg = clps7111_serial_setbrg, + .putc = clps7111_serial_putc, + .puts = clps7111_serial_puts, + .getc = clps7111_serial_getc, + .tstc = clps7111_serial_tstc, +}; + +void clps7111_serial_initialize(void) +{ + serial_register(&clps7111_serial_drv); +} + +__weak struct serial_device *default_serial_console(void) +{ + return &clps7111_serial_drv; +} +#else +int serial_init(void) +{ + return clps7111_serial_init(); +} + +void serial_setbrg(void) +{ + clps7111_serial_setbrg(); +} + +void serial_putc(const char c) +{ + clps7111_serial_putc(c); +} + +void serial_puts(const char *s) +{ + clps7111_serial_puts(s); +} + +int serial_getc(void) +{ + return clps7111_serial_getc(); +} + +int serial_tstc(void) +{ + return clps7111_serial_tstc(); +} +#endif |