]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/serial.c
Merge branch 'master' of /home/stefan/git/u-boot/lwmon5
[karo-tx-uboot.git] / common / serial.c
index 4f50911f668af3927b796a42e9b978f327abb293..dee1cc0ab9c6c77a08e34835bf1565d0e2bff0d5 100644 (file)
 #include <serial.h>
 #include <devices.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #if defined(CONFIG_SERIAL_MULTI)
 
 static struct serial_device *serial_devices = NULL;
 static struct serial_device *serial_current = NULL;
 
-#ifndef CONFIG_LWMON
+#if !defined(CONFIG_LWMON) && !defined(CONFIG_PXA27X)
 struct serial_device *default_serial_console (void)
 {
 #if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2)
@@ -38,16 +40,33 @@ struct serial_device *default_serial_console (void)
 #elif defined(CONFIG_8xx_CONS_SCC1) || defined(CONFIG_8xx_CONS_SCC2) \
    || defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)
        return &serial_scc_device;
+#elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
+   || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_MPC5xxx)
+#if defined(CONFIG_CONS_INDEX) && defined(CFG_NS16550_SERIAL)
+#if (CONFIG_CONS_INDEX==1)
+       return &eserial1_device;
+#elif (CONFIG_CONS_INDEX==2)
+       return &eserial2_device;
+#elif (CONFIG_CONS_INDEX==3)
+       return &eserial3_device;
+#elif (CONFIG_CONS_INDEX==4)
+       return &eserial4_device;
+#else
+#error "Bad CONFIG_CONS_INDEX."
+#endif
+#elif defined(CONFIG_UART1_CONSOLE)
+               return &serial1_device;
+#else
+               return &serial0_device;
+#endif
 #else
 #error No default console
 #endif
 }
 #endif
 
-static int serial_register (struct serial_device *dev)
+int serial_register (struct serial_device *dev)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        dev->init += gd->reloc_off;
        dev->setbrg += gd->reloc_off;
        dev->getc += gd->reloc_off;
@@ -71,6 +90,35 @@ void serial_initialize (void)
        serial_register (&serial_scc_device);
 #endif
 
+#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
+ || defined(CONFIG_405EP) || defined(CONFIG_405EZ) || defined(CONFIG_MPC5xxx)
+       serial_register(&serial0_device);
+       serial_register(&serial1_device);
+#endif
+
+#if defined(CFG_NS16550_SERIAL)
+#if defined(CFG_NS16550_COM1)
+       serial_register(&eserial1_device);
+#endif
+#if defined(CFG_NS16550_COM2)
+       serial_register(&eserial2_device);
+#endif
+#if defined(CFG_NS16550_COM3)
+       serial_register(&eserial3_device);
+#endif
+#if defined(CFG_NS16550_COM4)
+       serial_register(&eserial4_device);
+#endif
+#endif /* CFG_NS16550_SERIAL */
+#if defined (CONFIG_FFUART)
+       serial_register(&serial_ffuart_device);
+#endif
+#if defined (CONFIG_BTUART)
+       serial_register(&serial_btuart_device);
+#endif
+#if defined (CONFIG_STUART)
+       serial_register(&serial_stuart_device);
+#endif
        serial_assign (default_serial_console ()->name);
 }
 
@@ -122,8 +170,6 @@ void serial_reinit_all (void)
 
 int serial_init (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!(gd->flags & GD_FLG_RELOC) || !serial_current) {
                struct serial_device *dev = default_serial_console ();
 
@@ -135,8 +181,6 @@ int serial_init (void)
 
 void serial_setbrg (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!(gd->flags & GD_FLG_RELOC) || !serial_current) {
                struct serial_device *dev = default_serial_console ();
 
@@ -149,8 +193,6 @@ void serial_setbrg (void)
 
 int serial_getc (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!(gd->flags & GD_FLG_RELOC) || !serial_current) {
                struct serial_device *dev = default_serial_console ();
 
@@ -162,8 +204,6 @@ int serial_getc (void)
 
 int serial_tstc (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!(gd->flags & GD_FLG_RELOC) || !serial_current) {
                struct serial_device *dev = default_serial_console ();
 
@@ -175,8 +215,6 @@ int serial_tstc (void)
 
 void serial_putc (const char c)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!(gd->flags & GD_FLG_RELOC) || !serial_current) {
                struct serial_device *dev = default_serial_console ();
 
@@ -189,8 +227,6 @@ void serial_putc (const char c)
 
 void serial_puts (const char *s)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (!(gd->flags & GD_FLG_RELOC) || !serial_current) {
                struct serial_device *dev = default_serial_console ();