[U-Boot] [PATCH 44/70] serial: Implement CONFIG_SERIAL_MULTI into ns9750 serial driver

Marek Vasut marex at denx.de
Sat Sep 29 02:31:01 CEST 2012


Implement support for CONFIG_SERIAL_MULTI into ns9750 serial driver.
This driver was so far only usable directly, but this patch also adds
support for the multi method. This allows using more than one serial
driver alongside the ns9750 driver. Also, add a weak implementation
of default_serial_console() returning this driver.

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Marek Vasut <marek.vasut at gmail.com>
Cc: Tom Rini <trini at ti.com>
---
 common/serial.c                |    2 ++
 drivers/serial/ns9750_serial.c |   65 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/common/serial.c b/common/serial.c
index fa16dce..c6a275d 100644
--- a/common/serial.c
+++ b/common/serial.c
@@ -74,6 +74,7 @@ serial_initfunc(altera_serial_initialize);
 serial_initfunc(atmel_serial_initialize);
 serial_initfunc(lpc32xx_serial_initialize);
 serial_initfunc(mcf_serial_initialize);
+serial_initfunc(ns9750_serial_initialize);
 
 void serial_register(struct serial_device *dev)
 {
@@ -126,6 +127,7 @@ void serial_initialize(void)
 	atmel_serial_initialize();
 	lpc32xx_serial_initialize();
 	mcf_serial_initialize();
+	ns9750_serial_initialize();
 
 	serial_assign(default_serial_console()->name);
 }
diff --git a/drivers/serial/ns9750_serial.c b/drivers/serial/ns9750_serial.c
index e9645a0..829f6d5 100644
--- a/drivers/serial/ns9750_serial.c
+++ b/drivers/serial/ns9750_serial.c
@@ -52,7 +52,7 @@ static unsigned int unCharCache; /* unCharCache is only valid if
  * @Descr: configures GPIOs and UART. Requires BBUS Master Reset turned off
  ***********************************************************************/
 
-int serial_init( void )
+static int ns9750_serial_init(void)
 {
 	unsigned int aunGPIOTxD[] = { 0, 8, 40, 44 };
 	unsigned int aunGPIORxD[] = { 1, 9, 41, 45 };
@@ -85,7 +85,7 @@ int serial_init( void )
  * @Descr: writes one character to the FIFO. Blocks until FIFO is not full
  ***********************************************************************/
 
-void serial_putc( const char c )
+static void ns9750_serial_putc(const char c)
 {
 	if (c == '\n')
 		serial_putc( '\r' );
@@ -105,7 +105,7 @@ void serial_putc( const char c )
  * @Descr: writes non-zero string to the FIFO.
  ***********************************************************************/
 
-void serial_puts( const char *s )
+static void ns9750_serial_puts(const char *s)
 {
 	while (*s) {
 		serial_putc( *s++ );
@@ -118,7 +118,7 @@ void serial_puts( const char *s )
  * @Descr: performs only 8bit accesses to the FIFO. No error handling
  ***********************************************************************/
 
-int serial_getc( void )
+static int ns9750_serial_getc(void)
 {
 	int i;
 
@@ -142,7 +142,7 @@ int serial_getc( void )
  *	   unCharCache and the numbers of characters in cCharsAvailable
  ***********************************************************************/
 
-int serial_tstc( void )
+static int ns9750_serial_tstc(void)
 {
 	unsigned int unRegCache;
 
@@ -171,7 +171,7 @@ int serial_tstc( void )
 	return 0;
 }
 
-void serial_setbrg( void )
+static void ns9750_serial_setbrg(void)
 {
 	*get_ser_reg_addr_channel( NS9750_SER_BITRATE, CONSOLE ) =
 		calcBitrateRegister();
@@ -208,3 +208,56 @@ static unsigned int calcRxCharGapRegister( void )
 {
 	return NS9750_SER_RX_CHAR_TIMER_TRUN;
 }
+
+#ifdef CONFIG_SERIAL_MULTI
+static struct serial_device ns9750_serial_drv = {
+	.name	= "ns9750_serial",
+	.start	= ns9750_serial_init,
+	.stop	= NULL,
+	.setbrg	= ns9750_serial_setbrg,
+	.putc	= ns9750_serial_putc,
+	.puts	= ns9750_serial_puts,
+	.getc	= ns9750_serial_getc,
+	.tstc	= ns9750_serial_tstc,
+};
+
+void ns9750_serial_initialize(void)
+{
+	serial_register(&ns9750_serial_drv);
+}
+
+__weak struct serial_device *default_serial_console(void)
+{
+	return &ns9750_serial_drv;
+}
+#else
+int serial_init(void)
+{
+	return ns9750_serial_init();
+}
+
+void serial_setbrg(void)
+{
+	ns9750_serial_setbrg();
+}
+
+void serial_putc(const char c)
+{
+	ns9750_serial_putc(c);
+}
+
+void serial_puts(const char *s)
+{
+	ns9750_serial_puts(s);
+}
+
+int serial_getc(void)
+{
+	return ns9750_serial_getc();
+}
+
+int serial_tstc(void)
+{
+	return ns9750_serial_tstc();
+}
+#endif
-- 
1.7.10.4



More information about the U-Boot mailing list