]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Make the serial driver framework work with CONFIG_SERIAL_MULTI enabled
authorWolfgang Denk <wd@pollux.denx.de>
Wed, 30 Aug 2006 21:02:10 +0000 (23:02 +0200)
committerWolfgang Denk <wd@pollux.denx.de>
Wed, 30 Aug 2006 21:02:10 +0000 (23:02 +0200)
CHANGELOG
common/serial.c
drivers/ns9750_serial.c
drivers/serial.c
include/configs/mcc200.h
include/serial.h

index 02ccd30a3e704e0b8298770fe65d376b47faca51..87341755e27404bf86e466564ce0eafe62ded5e7 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,9 @@
 Changes since U-Boot 1.1.4:
 ======================================================================
 
+* Make the serial driver framework work with CONFIG_SERIAL_MULTI
+  enabled
+
 * PCIe endpoint support for AMCC Yucca 440SPe board
   Patch by Tirumala R Marri, 26 Aug 2006
 
index 38057d21f6cafc0e026dc2e693d85b6becd76a34..605d4e34be0a681d8d3eb535e3d067188e1c6205 100644 (file)
@@ -42,7 +42,19 @@ struct serial_device *default_serial_console (void)
        return &serial_scc_device;
 #elif defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) \
    || defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
-#if defined(CONFIG_UART1_CONSOLE)
+#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;
@@ -84,6 +96,20 @@ void serial_initialize (void)
        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 */
        serial_assign (default_serial_console ()->name);
 }
 
index 8dff36774500a343f72efb4a9ba6224bc094076b..02c0d3952099c58cf4a8034adf55ae4f51ea8877 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if !defined(CONFIG_CONS_INDEX)
+#error "No console index specified."
+#endif
+
 #define CONSOLE CONFIG_CONS_INDEX
 
 static unsigned int calcBitrateRegister( void );
index 228781b46a63409c2565e3751f2c0c8022644c96..8d1ae96bf8555d07a2b302e14a0677a97a1973e3 100644 (file)
 #include <ns87308.h>
 #endif
 
+#if defined (CONFIG_SERIAL_MULTI)
+#include <serial.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #if !defined(CONFIG_CONS_INDEX)
+#if defined (CONFIG_SERIAL_MULTI)
+/*   with CONFIG_SERIAL_MULTI we might have no console
+ *  on these devices 
+ */
+#else
 #error "No console index specified."
+#endif /* CONFIG_SERIAL_MULTI */
 #elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 4)
 #error "Invalid console index value."
 #endif
@@ -75,7 +85,42 @@ static NS16550_t serial_ports[4] = {
 };
 
 #define PORT   serial_ports[port-1]
+#if defined(CONFIG_CONS_INDEX)
 #define CONSOLE        (serial_ports[CONFIG_CONS_INDEX-1])
+#endif
+
+#if defined(CONFIG_SERIAL_MULTI)
+
+/* Multi serial device functions */
+#define DECLARE_ESERIAL_FUNCTIONS(port) \
+    int  eserial##port##_init (void) {\
+       int clock_divisor; \
+       clock_divisor = calc_divisor(serial_ports[port-1]); \
+       NS16550_init(serial_ports[port-1], clock_divisor); \
+       return(0);}\
+    void eserial##port##_setbrg (void) {\
+       serial_setbrg_dev(port);}\
+    int  eserial##port##_getc (void) {\
+       return serial_getc_dev(port);}\
+    int  eserial##port##_tstc (void) {\
+       return serial_tstc_dev(port);}\
+    void eserial##port##_putc (const char c) {\
+       serial_putc_dev(port, c);}\
+    void eserial##port##_puts (const char *s) {\
+       serial_puts_dev(port, s);}
+
+/* Serial device descriptor */
+#define INIT_ESERIAL_STRUCTURE(port,name,bus) {\
+       name,\
+       bus,\
+       eserial##port##_init,\
+       eserial##port##_setbrg,\
+       eserial##port##_getc,\
+       eserial##port##_tstc,\
+       eserial##port##_putc,\
+       eserial##port##_puts, }
+
+#endif /* CONFIG_SERIAL_MULTI */
 
 static int calc_divisor (NS16550_t port)
 {
@@ -103,6 +148,7 @@ static int calc_divisor (NS16550_t port)
 
 }
 
+#if !defined(CONFIG_SERIAL_MULTI)
 int serial_init (void)
 {
        int clock_divisor;
@@ -130,6 +176,7 @@ int serial_init (void)
 
        return (0);
 }
+#endif
 
 void
 _serial_putc(const char c,const int port)
@@ -176,40 +223,104 @@ _serial_setbrg (const int port)
        NS16550_reinit(PORT, clock_divisor);
 }
 
+#if defined(CONFIG_SERIAL_MULTI)
+static inline void
+serial_putc_dev(unsigned int dev_index,const char c)
+{
+       _serial_putc(c,dev_index);
+}
+#else
 void
 serial_putc(const char c)
 {
        _serial_putc(c,CONFIG_CONS_INDEX);
 }
+#endif
 
+#if defined(CONFIG_SERIAL_MULTI)
+static inline void 
+serial_putc_raw_dev(unsigned int dev_index,const char c)
+{
+       _serial_putc_raw(c,dev_index);
+}
+#else
 void
 serial_putc_raw(const char c)
 {
        _serial_putc_raw(c,CONFIG_CONS_INDEX);
 }
+#endif
 
+#if defined(CONFIG_SERIAL_MULTI)
+static inline void
+serial_puts_dev(unsigned int dev_index,const char *s)
+{
+       _serial_puts(s,dev_index);
+}
+#else
 void
 serial_puts(const char *s)
 {
        _serial_puts(s,CONFIG_CONS_INDEX);
 }
+#endif
 
+#if defined(CONFIG_SERIAL_MULTI)
+static inline int
+serial_getc_dev(unsigned int dev_index)
+{
+       return _serial_getc(dev_index);
+}
+#else
 int
 serial_getc(void)
 {
        return _serial_getc(CONFIG_CONS_INDEX);
 }
+#endif
 
+#if defined(CONFIG_SERIAL_MULTI)
+static inline int
+serial_tstc_dev(unsigned int dev_index)
+{
+       return _serial_tstc(dev_index);
+}
+#else
 int
 serial_tstc(void)
 {
        return _serial_tstc(CONFIG_CONS_INDEX);
 }
+#endif
 
+#if defined(CONFIG_SERIAL_MULTI)
+static inline void
+serial_setbrg_dev(unsigned int dev_index)
+{
+       _serial_setbrg(dev_index);
+}
+#else
 void
 serial_setbrg(void)
 {
        _serial_setbrg(CONFIG_CONS_INDEX);
 }
+#endif
+
+#if defined(CONFIG_SERIAL_MULTI)
+
+DECLARE_ESERIAL_FUNCTIONS(1);
+struct serial_device eserial1_device = 
+       INIT_ESERIAL_STRUCTURE(1,"eserial0","EUART1");
+DECLARE_ESERIAL_FUNCTIONS(2);
+struct serial_device eserial2_device =
+       INIT_ESERIAL_STRUCTURE(2,"eserial1","EUART2");
+DECLARE_ESERIAL_FUNCTIONS(3);
+struct serial_device eserial3_device =
+       INIT_ESERIAL_STRUCTURE(3,"eserial2","EUART3");
+DECLARE_ESERIAL_FUNCTIONS(4);
+struct serial_device eserial4_device =
+       INIT_ESERIAL_STRUCTURE(4,"eserial3","EUART4");
+#endif /* CONFIG_SERIAL_MULTI */
 
 #endif
index fc5781e438fbb9c529f7f828d6807cfd5fe96f46..61014ecd1f2ad1ad3453dc4089799efce5dfb685 100644 (file)
  */
 #if !defined(CONFIG_PRS200)
 /* MCC200 configuration: */
-#undef CONFIG_PSC_CONSOLE
+#define CONFIG_SERIAL_MULTI    1
+#define CONFIG_PSC_CONSOLE     1       /* PSC1 may be COM */
+#define CONFIG_PSC_CONSOLE2    2       /* PSC2 is PSoC */
 #else
 /* PRS200 configuration: */
 #define CONFIG_PSC_CONSOLE     1       /* console is on PSC1           */
 #endif
-#if defined(CONFIG_QUART_CONSOLE) && defined(CONFIG_PSC_CONSOLE)
+#if defined(CONFIG_QUART_CONSOLE) && defined(CONFIG_PSC_CONSOLE) && \
+       !defined(CONFIG_SERIAL_MULTI)
 #error "Select only one console device!"
 #endif
 #define CONFIG_BAUDRATE                115200
index 8c7b1c26c13ba03684e5dbd214267dcbc7508e3d..48800595d7816bed37ad1685bf081d87f58f842a 100644 (file)
@@ -26,6 +26,13 @@ extern struct serial_device * default_serial_console (void);
    || defined(CONFIG_405EP) || defined(CONFIG_MPC5xxx)
 extern struct serial_device serial0_device;
 extern struct serial_device serial1_device;
+#if defined(CFG_NS16550_SERIAL)
+extern struct serial_device eserial1_device;
+extern struct serial_device eserial2_device;
+extern struct serial_device eserial3_device;
+extern struct serial_device eserial4_device;
+#endif /* CFG_NS16550_SERIAL */
+
 #endif