diff options
author | Marek Vasut <marex@denx.de> | 2012-09-13 01:26:42 +0200 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2012-10-15 11:53:51 -0700 |
commit | b57c652802ca735c80810c599c4eae9a6752415d (patch) | |
tree | 42162895ff24df50f25c99dc817eef438e9b9f9f /arch | |
parent | 6cb3273d11368363c630ad0192b704641cc9b604 (diff) | |
download | u-boot-imx-b57c652802ca735c80810c599c4eae9a6752415d.zip u-boot-imx-b57c652802ca735c80810c599c4eae9a6752415d.tar.gz u-boot-imx-b57c652802ca735c80810c599c4eae9a6752415d.tar.bz2 |
serial: powerpc: Implement CONFIG_SERIAL_MULTI into mpc5xx serial driver
Implement support for CONFIG_SERIAL_MULTI into mpc5xx 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 mpc5xx 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: Anatolij Gustschin <agust@denx.de>
Cc: Stefan Roese <sr@denx.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/cpu/mpc5xx/serial.c | 95 |
1 files changed, 74 insertions, 21 deletions
diff --git a/arch/powerpc/cpu/mpc5xx/serial.c b/arch/powerpc/cpu/mpc5xx/serial.c index 88c6db8..a4fd6bc 100644 --- a/arch/powerpc/cpu/mpc5xx/serial.c +++ b/arch/powerpc/cpu/mpc5xx/serial.c @@ -33,20 +33,40 @@ #include <watchdog.h> #include <command.h> #include <mpc5xx.h> +#include <serial.h> +#include <linux/compiler.h> DECLARE_GLOBAL_DATA_PTR; /* - * Local function prototypes + * Local functions */ -static int ready_to_send(void); +static int ready_to_send(void) +{ + volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; + volatile short status; + + do { +#if defined(CONFIG_5xx_CONS_SCI1) + status = immr->im_qsmcm.qsmcm_sc1sr; +#else + status = immr->im_qsmcm.qsmcm_sc2sr; +#endif + +#if defined(CONFIG_WATCHDOG) + reset_5xx_watchdog (immr); +#endif + } while ((status & SCI_TDRE) == 0); + return 1; + +} /* * Minimal global serial functions needed to use one of the SCI modules. */ -int serial_init (void) +static int mpc5xx_serial_init(void) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; @@ -63,7 +83,7 @@ int serial_init (void) return 0; } -void serial_putc(const char c) +static void mpc5xx_serial_putc(const char c) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; @@ -85,7 +105,7 @@ void serial_putc(const char c) } } -int serial_getc(void) +static int mpc5xx_serial_getc(void) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; volatile short status; @@ -113,7 +133,7 @@ int serial_getc(void) return tmp; } -int serial_tstc() +static int mpc5xx_serial_tstc(void) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; short status; @@ -127,7 +147,7 @@ int serial_tstc() return (status & SCI_RDRF); } -void serial_setbrg (void) +static void mpc5xx_serial_setbrg(void) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; short scxbr; @@ -141,7 +161,7 @@ void serial_setbrg (void) #endif } -void serial_puts (const char *s) +static void mpc5xx_serial_puts(const char *s) { while (*s) { serial_putc(*s); @@ -149,22 +169,55 @@ void serial_puts (const char *s) } } -int ready_to_send(void) +#ifdef CONFIG_SERIAL_MULTI +static struct serial_device mpc5xx_serial_drv = { + .name = "mpc5xx_serial", + .start = mpc5xx_serial_init, + .stop = NULL, + .setbrg = mpc5xx_serial_setbrg, + .putc = mpc5xx_serial_putc, + .puts = mpc5xx_serial_puts, + .getc = mpc5xx_serial_getc, + .tstc = mpc5xx_serial_tstc, +}; + +void mpc5xx_serial_initialize(void) { - volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; - volatile short status; + serial_register(&mpc5xx_serial_drv); +} - do { -#if defined(CONFIG_5xx_CONS_SCI1) - status = immr->im_qsmcm.qsmcm_sc1sr; +__weak struct serial_device *default_serial_console(void) +{ + return &mpc5xx_serial_drv; +} #else - status = immr->im_qsmcm.qsmcm_sc2sr; -#endif +int serial_init(void) +{ + return mpc5xx_serial_init(); +} -#if defined(CONFIG_WATCHDOG) - reset_5xx_watchdog (immr); -#endif - } while ((status & SCI_TDRE) == 0); - return 1; +void serial_setbrg(void) +{ + mpc5xx_serial_setbrg(); +} +void serial_putc(const char c) +{ + mpc5xx_serial_putc(c); } + +void serial_puts(const char *s) +{ + mpc5xx_serial_puts(s); +} + +int serial_getc(void) +{ + return mpc5xx_serial_getc(); +} + +int serial_tstc(void) +{ + return mpc5xx_serial_tstc(); +} +#endif |