[U-Boot] [PATCH 61/71] serial: sh: Implement CONFIG_SERIAL_MULTI into sh serial driver
Nobuhiro Iwamatsu
iwamatsu at nigauri.org
Tue Sep 18 03:01:11 CEST 2012
On Mon, Sep 17, 2012 at 8:21 AM, Marek Vasut <marex at denx.de> wrote:
> Implement support for CONFIG_SERIAL_MULTI into sh 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 sh driver. Also, add a weak implementation
> of default_serial_console() returning this driver.
>
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Marek Vasut <marek.vasut at gmail.com>
> Cc: Tom Rini <trini at ti.com>
> Cc: Phil Edworthy <PHIL.EDWORTHY at renesas.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Acked-by: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
> ---
> common/serial.c | 2 ++
> drivers/serial/serial_sh.c | 65 ++++++++++++++++++++++++++++++++++++++++----
> 2 files changed, 61 insertions(+), 6 deletions(-)
>
> diff --git a/common/serial.c b/common/serial.c
> index 3dae01b..631af65 100644
> --- a/common/serial.c
> +++ b/common/serial.c
> @@ -91,6 +91,7 @@ serial_initfunc(netarm_serial_initialize);
> serial_initfunc(pl01x_serial_initialize);
> serial_initfunc(s3c44b0_serial_initialize);
> serial_initfunc(sa1100_serial_initialize);
> +serial_initfunc(sh_serial_initialize);
>
> void serial_register(struct serial_device *dev)
> {
> @@ -160,6 +161,7 @@ void serial_initialize(void)
> pl01x_serial_initialize();
> s3c44b0_serial_initialize();
> sa1100_serial_initialize();
> + sh_serial_initialize();
>
> serial_assign(default_serial_console()->name);
> }
> diff --git a/drivers/serial/serial_sh.c b/drivers/serial/serial_sh.c
> index 13919c6..8c30397 100644
> --- a/drivers/serial/serial_sh.c
> +++ b/drivers/serial/serial_sh.c
> @@ -55,13 +55,13 @@ static struct uart_port sh_sci = {
> .type = SCIF_BASE_PORT,
> };
>
> -void serial_setbrg(void)
> +static void sh_serial_setbrg(void)
> {
> DECLARE_GLOBAL_DATA_PTR;
> sci_out(&sh_sci, SCBRR, SCBRR_VALUE(gd->baudrate, CONFIG_SYS_CLK_FREQ));
> }
>
> -int serial_init(void)
> +static int sh_serial_init(void)
> {
> sci_out(&sh_sci, SCSCR , SCSCR_INIT(&sh_sci));
> sci_out(&sh_sci, SCSCR , SCSCR_INIT(&sh_sci));
> @@ -127,21 +127,21 @@ void serial_raw_putc(const char c)
> sci_out(&sh_sci, SCxSR, sci_in(&sh_sci, SCxSR) & ~SCxSR_TEND(&sh_sci));
> }
>
> -void serial_putc(const char c)
> +static void sh_serial_putc(const char c)
> {
> if (c == '\n')
> serial_raw_putc('\r');
> serial_raw_putc(c);
> }
>
> -void serial_puts(const char *s)
> +static void sh_serial_puts(const char *s)
> {
> char c;
> while ((c = *s++) != 0)
> serial_putc(c);
> }
>
> -int serial_tstc(void)
> +static int sh_serial_tstc(void)
> {
> return serial_rx_fifo_level() ? 1 : 0;
> }
> @@ -167,7 +167,7 @@ int serial_getc_check(void)
> return status & (SCIF_DR | SCxSR_RDxF(&sh_sci));
> }
>
> -int serial_getc(void)
> +static int sh_serial_getc(void)
> {
> unsigned short status;
> char ch;
> @@ -187,3 +187,56 @@ int serial_getc(void)
> handle_error();
> return ch;
> }
> +
> +#ifdef CONFIG_SERIAL_MULTI
> +static struct serial_device sh_serial_drv = {
> + .name = "sh_serial",
> + .start = sh_serial_init,
> + .stop = NULL,
> + .setbrg = sh_serial_setbrg,
> + .putc = sh_serial_putc,
> + .puts = sh_serial_puts,
> + .getc = sh_serial_getc,
> + .tstc = sh_serial_tstc,
> +};
> +
> +void sh_serial_initialize(void)
> +{
> + serial_register(&sh_serial_drv);
> +}
> +
> +__weak struct serial_device *default_serial_console(void)
> +{
> + return &sh_serial_drv;
> +}
> +#else
> +int serial_init(void)
> +{
> + return sh_serial_init();
> +}
> +
> +void serial_setbrg(void)
> +{
> + sh_serial_setbrg();
> +}
> +
> +void serial_putc(const char c)
> +{
> + sh_serial_putc(c);
> +}
> +
> +void serial_puts(const char *s)
> +{
> + sh_serial_puts(s);
> +}
> +
> +int serial_getc(void)
> +{
> + return sh_serial_getc();
> +}
> +
> +int serial_tstc(void)
> +{
> + return sh_serial_tstc();
> +}
> +#endif
> --
> 1.7.10.4
>
Best regards,
Nobuhiro
--
Nobuhiro Iwamatsu
iwamatsu at {nigauri.org / debian.org}
GPG ID: 40AD1FA6
More information about the U-Boot
mailing list