]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - arch/powerpc/cpu/mpc512x/serial.c
serial: mpc512x: Move serial registration from serial_initialize()
[karo-tx-uboot.git] / arch / powerpc / cpu / mpc512x / serial.c
index cb5bbf09b21223b34884291af461da3d9efa7d1a..bc10c501aac2c53f7e736cae1168decc31b69eb3 100644 (file)
@@ -30,6 +30,7 @@
  */
 
 #include <common.h>
+#include <linux/compiler.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <serial.h>
@@ -139,7 +140,7 @@ void serial_setbrg_dev(unsigned int idx)
                if (br_env)
                        baudrate = simple_strtoul(br_env, NULL, 10);
 
-               debug("%s: idx %d, baudrate %d\n", __func__, idx, baudrate);
+               debug("%s: idx %d, baudrate %ld\n", __func__, idx, baudrate);
        }
 
        /* calculate divisor for setting PSC CTUR and CTLR registers */
@@ -318,42 +319,68 @@ int serial_getcts_dev(unsigned int idx)
                serial_puts_dev(port, s); \
        }
 
-#define INIT_PSC_SERIAL_STRUCTURE(port, name, bus) { \
-       name, \
-       bus, \
-       serial##port##_init, \
-       serial##port##_uninit, \
-       serial##port##_setbrg, \
-       serial##port##_getc, \
-       serial##port##_tstc, \
-       serial##port##_putc, \
-       serial##port##_puts, \
+#define INIT_PSC_SERIAL_STRUCTURE(port, __name) {      \
+       .name   = __name,                               \
+       .start  = serial##port##_init,                  \
+       .stop   = serial##port##_uninit,                \
+       .setbrg = serial##port##_setbrg,                \
+       .getc   = serial##port##_getc,                  \
+       .tstc   = serial##port##_tstc,                  \
+       .putc   = serial##port##_putc,                  \
+       .puts   = serial##port##_puts,                  \
 }
 
 #if defined(CONFIG_SYS_PSC1)
 DECLARE_PSC_SERIAL_FUNCTIONS(1);
 struct serial_device serial1_device =
-INIT_PSC_SERIAL_STRUCTURE(1, "psc1", "UART1");
+INIT_PSC_SERIAL_STRUCTURE(1, "psc1");
 #endif
 
 #if defined(CONFIG_SYS_PSC3)
 DECLARE_PSC_SERIAL_FUNCTIONS(3);
 struct serial_device serial3_device =
-INIT_PSC_SERIAL_STRUCTURE(3, "psc3", "UART3");
+INIT_PSC_SERIAL_STRUCTURE(3, "psc3");
 #endif
 
 #if defined(CONFIG_SYS_PSC4)
 DECLARE_PSC_SERIAL_FUNCTIONS(4);
 struct serial_device serial4_device =
-INIT_PSC_SERIAL_STRUCTURE(4, "psc4", "UART4");
+INIT_PSC_SERIAL_STRUCTURE(4, "psc4");
 #endif
 
 #if defined(CONFIG_SYS_PSC6)
 DECLARE_PSC_SERIAL_FUNCTIONS(6);
 struct serial_device serial6_device =
-INIT_PSC_SERIAL_STRUCTURE(6, "psc6", "UART6");
+INIT_PSC_SERIAL_STRUCTURE(6, "psc6");
 #endif
 
+__weak struct serial_device *default_serial_console(void)
+{
+#if (CONFIG_PSC_CONSOLE == 3)
+       return &serial3_device;
+#elif (CONFIG_PSC_CONSOLE == 6)
+       return &serial6_device;
+#else
+#error "invalid CONFIG_PSC_CONSOLE"
+#endif
+}
+
+void mpc512x_serial_initialize(void)
+{
+#if defined(CONFIG_SYS_PSC1)
+       serial_register(&serial1_device);
+#endif
+#if defined(CONFIG_SYS_PSC3)
+       serial_register(&serial3_device);
+#endif
+#if defined(CONFIG_SYS_PSC4)
+       serial_register(&serial4_device);
+#endif
+#if defined(CONFIG_SYS_PSC6)
+       serial_register(&serial6_device);
+#endif
+}
+
 #else
 
 void serial_setbrg(void)