summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang Denk <wd@pollux.denx.de>2006-08-30 23:02:10 +0200
committerWolfgang Denk <wd@pollux.denx.de>2006-08-30 23:02:10 +0200
commit0fd30252c840ee54d2a80475d6504766d43b8add (patch)
tree1ca4d91cd9ef225477cfc5aeeb9008f08ac587c2
parent2b75062a0f97ad6ff19d9d2c030d4b29829260f1 (diff)
downloadblackbird-obmc-uboot-0fd30252c840ee54d2a80475d6504766d43b8add.tar.gz
blackbird-obmc-uboot-0fd30252c840ee54d2a80475d6504766d43b8add.zip
Make the serial driver framework work with CONFIG_SERIAL_MULTI enabled
-rw-r--r--CHANGELOG3
-rw-r--r--common/serial.c28
-rw-r--r--drivers/ns9750_serial.c4
-rw-r--r--drivers/serial.c111
-rw-r--r--include/configs/mcc200.h7
-rw-r--r--include/serial.h7
6 files changed, 157 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 02ccd30a3e..87341755e2 100644
--- 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
diff --git a/common/serial.c b/common/serial.c
index 38057d21f6..605d4e34be 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -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);
}
diff --git a/drivers/ns9750_serial.c b/drivers/ns9750_serial.c
index 8dff367745..02c0d39520 100644
--- a/drivers/ns9750_serial.c
+++ b/drivers/ns9750_serial.c
@@ -35,6 +35,10 @@
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 );
diff --git a/drivers/serial.c b/drivers/serial.c
index 228781b46a..8d1ae96bf8 100644
--- a/drivers/serial.c
+++ b/drivers/serial.c
@@ -30,10 +30,20 @@
#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
diff --git a/include/configs/mcc200.h b/include/configs/mcc200.h
index fc5781e438..61014ecd1f 100644
--- a/include/configs/mcc200.h
+++ b/include/configs/mcc200.h
@@ -72,12 +72,15 @@
*/
#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
diff --git a/include/serial.h b/include/serial.h
index 8c7b1c26c1..48800595d7 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -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
OpenPOWER on IntegriCloud