[U-Boot] [PATCH 3/6] serial: Enable up to 6 eserial devices

Andrew Bradford andrew at bradfordembedded.com
Wed Sep 26 22:04:16 CEST 2012


Increase the number of possible eserial devices from 4 to 6.

Signed-off-by: Andrew Bradford <andrew at bradfordembedded.com>
---
 common/serial.c         |    6 ++++++
 drivers/serial/serial.c |   39 +++++++++++++++++++++++++++++++++++----
 include/serial.h        |    2 ++
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/common/serial.c b/common/serial.c
index 75cc1bb..c237aee 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -70,6 +70,12 @@ void serial_initialize(void)
 #if defined(CONFIG_SYS_NS16550_COM4)
 	serial_register(&eserial4_device);
 #endif
+#if defined(CONFIG_SYS_NS16550_COM5)
+	serial_register(&eserial5_device);
+#endif
+#if defined(CONFIG_SYS_NS16550_COM6)
+	serial_register(&eserial6_device);
+#endif
 #endif /* CONFIG_SYS_NS16550_SERIAL */
 #if defined(CONFIG_FFUART)
 	serial_register(&serial_ffuart_device);
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index b10bab7..ba05f7f 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -43,7 +43,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #else
 #error	"No console index specified."
 #endif /* CONFIG_SERIAL_MULTI */
-#elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 4)
+#elif (CONFIG_CONS_INDEX < 1) || (CONFIG_CONS_INDEX > 6)
 #error	"Invalid console index value."
 #endif
 
@@ -55,12 +55,16 @@ DECLARE_GLOBAL_DATA_PTR;
 #error	"Console port 3 defined but not configured."
 #elif CONFIG_CONS_INDEX == 4 && !defined(CONFIG_SYS_NS16550_COM4)
 #error	"Console port 4 defined but not configured."
+#elif CONFIG_CONS_INDEX == 5 && !defined(CONFIG_SYS_NS16550_COM5)
+#error	"Console port 5 defined but not configured."
+#elif CONFIG_CONS_INDEX == 6 && !defined(CONFIG_SYS_NS16550_COM6)
+#error	"Console port 6 defined but not configured."
 #endif
 
 /* Note: The port number specified in the functions is 1 based.
  *	 the array is 0 based.
  */
-static NS16550_t serial_ports[4] = {
+static NS16550_t serial_ports[6] = {
 #ifdef CONFIG_SYS_NS16550_COM1
 	(NS16550_t)CONFIG_SYS_NS16550_COM1,
 #else
@@ -77,7 +81,17 @@ static NS16550_t serial_ports[4] = {
 	NULL,
 #endif
 #ifdef CONFIG_SYS_NS16550_COM4
-	(NS16550_t)CONFIG_SYS_NS16550_COM4
+	(NS16550_t)CONFIG_SYS_NS16550_COM4,
+#else
+	NULL,
+#endif
+#ifdef CONFIG_SYS_NS16550_COM5
+	(NS16550_t)CONFIG_SYS_NS16550_COM5,
+#else
+	NULL,
+#endif
+#ifdef CONFIG_SYS_NS16550_COM6
+	(NS16550_t)CONFIG_SYS_NS16550_COM6
 #else
 	NULL
 #endif
@@ -175,7 +189,14 @@ int serial_init (void)
 	clock_divisor = calc_divisor(serial_ports[3]);
 	NS16550_init(serial_ports[3], clock_divisor);
 #endif
-
+#ifdef CONFIG_SYS_NS16550_COM5
+	clock_divisor = calc_divisor(serial_ports[4]);
+	NS16550_init(serial_ports[4], clock_divisor);
+#endif
+#ifdef CONFIG_SYS_NS16550_COM6
+	clock_divisor = calc_divisor(serial_ports[5]);
+	NS16550_init(serial_ports[5], clock_divisor);
+#endif
 	return (0);
 }
 #endif
@@ -323,6 +344,12 @@ struct serial_device eserial3_device =
 DECLARE_ESERIAL_FUNCTIONS(4);
 struct serial_device eserial4_device =
 	INIT_ESERIAL_STRUCTURE(4, "eserial3");
+DECLARE_ESERIAL_FUNCTIONS(5);
+struct serial_device eserial5_device =
+	INIT_ESERIAL_STRUCTURE(5, "eserial4");
+DECLARE_ESERIAL_FUNCTIONS(6);
+struct serial_device eserial6_device =
+	INIT_ESERIAL_STRUCTURE(6, "eserial5");
 
 __weak struct serial_device *default_serial_console(void)
 {
@@ -334,6 +361,10 @@ __weak struct serial_device *default_serial_console(void)
 	return &eserial3_device;
 #elif CONFIG_CONS_INDEX == 4
 	return &eserial4_device;
+#elif CONFIG_CONS_INDEX == 5
+	return &eserial5_device;
+#elif CONFIG_CONS_INDEX == 6
+	return &eserial6_device;
 #else
 #error "Bad CONFIG_CONS_INDEX."
 #endif
diff --git a/include/serial.h b/include/serial.h
index d76d6df..dcb2d97 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -40,6 +40,8 @@ extern struct serial_device eserial1_device;
 extern struct serial_device eserial2_device;
 extern struct serial_device eserial3_device;
 extern struct serial_device eserial4_device;
+extern struct serial_device eserial5_device;
+extern struct serial_device eserial6_device;
 #endif /* CONFIG_SYS_NS16550_SERIAL */
 
 #endif
-- 
1.7.10



More information about the U-Boot mailing list