summaryrefslogtreecommitdiff
path: root/arch/powerpc
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2012-09-13 01:34:16 +0200
committerTom Rini <trini@ti.com>2012-10-15 11:53:51 -0700
commitd68f4da2fa13f42d2dc970ddc7f8e907d6949e83 (patch)
treef381a9716f62c42b2d4acfbe08a12e985559ca70 /arch/powerpc
parent2063a54e1487a933b406b5413f4fa3774fd31c91 (diff)
downloadu-boot-imx-d68f4da2fa13f42d2dc970ddc7f8e907d6949e83.zip
u-boot-imx-d68f4da2fa13f42d2dc970ddc7f8e907d6949e83.tar.gz
u-boot-imx-d68f4da2fa13f42d2dc970ddc7f8e907d6949e83.tar.bz2
serial: powerpc: Implement CONFIG_SERIAL_MULTI into mpc8260 serial drivers
Implement support for CONFIG_SERIAL_MULTI into both SCC and SMC mpc8260 serial drivers. These drivers were 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 mpc8260 drivers. 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/powerpc')
-rw-r--r--arch/powerpc/cpu/mpc8260/serial_scc.c71
-rw-r--r--arch/powerpc/cpu/mpc8260/serial_smc.c71
2 files changed, 120 insertions, 22 deletions
diff --git a/arch/powerpc/cpu/mpc8260/serial_scc.c b/arch/powerpc/cpu/mpc8260/serial_scc.c
index 4ab6a28..7bfd420 100644
--- a/arch/powerpc/cpu/mpc8260/serial_scc.c
+++ b/arch/powerpc/cpu/mpc8260/serial_scc.c
@@ -31,6 +31,8 @@
#include <common.h>
#include <mpc8260.h>
#include <asm/cpm_8260.h>
+#include <serial.h>
+#include <linux/compiler.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -82,7 +84,7 @@ DECLARE_GLOBAL_DATA_PTR;
#endif
-int serial_init (void)
+static int mpc8260_scc_serial_init(void)
{
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
volatile scc_t *sp;
@@ -180,8 +182,7 @@ int serial_init (void)
return (0);
}
-void
-serial_setbrg (void)
+static void mpc8260_scc_serial_setbrg(void)
{
#if defined(CONFIG_CONS_USE_EXTC)
m8260_cpm_extcbrg(SCC_INDEX, gd->baudrate,
@@ -191,8 +192,7 @@ serial_setbrg (void)
#endif
}
-void
-serial_putc(const char c)
+static void mpc8260_scc_serial_putc(const char c)
{
volatile scc_uart_t *up;
volatile cbd_t *tbdf;
@@ -217,16 +217,14 @@ serial_putc(const char c)
tbdf->cbd_sc |= BD_SC_READY;
}
-void
-serial_puts (const char *s)
+static void mpc8260_scc_serial_puts(const char *s)
{
while (*s) {
serial_putc (*s++);
}
}
-int
-serial_getc(void)
+static int mpc8260_scc_serial_getc(void)
{
volatile cbd_t *rbdf;
volatile scc_uart_t *up;
@@ -250,8 +248,7 @@ serial_getc(void)
return (c);
}
-int
-serial_tstc()
+static int mpc8260_scc_serial_tstc(void)
{
volatile cbd_t *rbdf;
volatile scc_uart_t *up;
@@ -264,6 +261,58 @@ serial_tstc()
return ((rbdf->cbd_sc & BD_SC_EMPTY) == 0);
}
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device mpc8260_scc_serial_drv = {
+ .name = "mpc8260_scc_uart",
+ .start = mpc8260_scc_serial_init,
+ .stop = NULL,
+ .setbrg = mpc8260_scc_serial_setbrg,
+ .putc = mpc8260_scc_serial_putc,
+ .puts = mpc8260_scc_serial_puts,
+ .getc = mpc8260_scc_serial_getc,
+ .tstc = mpc8260_scc_serial_tstc,
+};
+
+void mpc8260_scc_serial_initialize(void)
+{
+ serial_register(&mpc8260_scc_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &mpc8260_scc_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return mpc8260_scc_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ mpc8260_scc_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ mpc8260_scc_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ mpc8260_scc_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return mpc8260_scc_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return mpc8260_scc_serial_tstc();
+}
+#endif
#endif /* CONFIG_CONS_ON_SCC */
#if defined(CONFIG_KGDB_ON_SCC)
diff --git a/arch/powerpc/cpu/mpc8260/serial_smc.c b/arch/powerpc/cpu/mpc8260/serial_smc.c
index 7b6eaba..0f3b834 100644
--- a/arch/powerpc/cpu/mpc8260/serial_smc.c
+++ b/arch/powerpc/cpu/mpc8260/serial_smc.c
@@ -33,6 +33,8 @@
#include <common.h>
#include <mpc8260.h>
#include <asm/cpm_8260.h>
+#include <serial.h>
+#include <linux/compiler.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -91,7 +93,7 @@ static unsigned char brg_map[] = {
3, /* BRG1 for SCC4 */
};
-int serial_init (void)
+static int mpc8260_smc_serial_init(void)
{
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
volatile smc_t *sp;
@@ -183,8 +185,7 @@ int serial_init (void)
return (0);
}
-void
-serial_setbrg (void)
+static void mpc8260_smc_serial_setbrg(void)
{
#if defined(CONFIG_CONS_USE_EXTC)
m8260_cpm_extcbrg(brg_map[SMC_INDEX], gd->baudrate,
@@ -194,8 +195,7 @@ serial_setbrg (void)
#endif
}
-void
-serial_putc(const char c)
+static void mpc8260_smc_serial_putc(const char c)
{
volatile smc_uart_t *up;
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
@@ -216,16 +216,14 @@ serial_putc(const char c)
rtx->txbd.cbd_sc |= BD_SC_READY;
}
-void
-serial_puts (const char *s)
+static void mpc8260_smc_serial_puts(const char *s)
{
while (*s) {
serial_putc (*s++);
}
}
-int
-serial_getc(void)
+static int mpc8260_smc_serial_getc(void)
{
volatile smc_uart_t *up;
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
@@ -254,8 +252,7 @@ serial_getc(void)
return(c);
}
-int
-serial_tstc()
+static int mpc8260_smc_serial_tstc(void)
{
volatile smc_uart_t *up;
volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
@@ -267,6 +264,58 @@ serial_tstc()
return !(rtx->rxbd.cbd_sc & BD_SC_EMPTY);
}
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device mpc8260_smc_serial_drv = {
+ .name = "mpc8260_smc_uart",
+ .start = mpc8260_smc_serial_init,
+ .stop = NULL,
+ .setbrg = mpc8260_smc_serial_setbrg,
+ .putc = mpc8260_smc_serial_putc,
+ .puts = mpc8260_smc_serial_puts,
+ .getc = mpc8260_smc_serial_getc,
+ .tstc = mpc8260_smc_serial_tstc,
+};
+
+void mpc8260_smc_serial_initialize(void)
+{
+ serial_register(&mpc8260_smc_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+ return &mpc8260_smc_serial_drv;
+}
+#else
+int serial_init(void)
+{
+ return mpc8260_smc_serial_init();
+}
+
+void serial_setbrg(void)
+{
+ mpc8260_smc_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+ mpc8260_smc_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+ mpc8260_smc_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+ return mpc8260_smc_serial_getc();
+}
+
+int serial_tstc(void)
+{
+ return mpc8260_smc_serial_tstc();
+}
+#endif
#endif /* CONFIG_CONS_ON_SMC */
#if defined(CONFIG_KGDB_ON_SMC)