Skip to contentSkip to conversation

sh-sci: console drainage

PATCH New Magnus Damm 1 participant 1 message Feb 24, 2009 SuperH

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sh-sci: console drainage

From: Magnus Damm <[email protected]>

Modify the serial console code to wait for the transmit FIFO, make sure all bits have been put on the wire before returning.

---

This is the first step against clock framework integration, after all bits are sent we can disable the data clock.

Also useful when debugging or shutting down a system.

Tested with SCIF on sh7785lcr, not sure about SCI and SCIFA.

 drivers/serial/sh-sci.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/serial/sh-sci.c +7 -1
@@ -139,7 +139,7 @@ static void sci_poll_put_char(struct uar
 	} while (!(status & SCxSR_TDxE(port)));
 
 	sci_in(port, SCxSR);            /* Dummy read */
-	sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
+	sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port));
 	sci_out(port, SCxTDR, c);
 }
 #endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */
@@ -1095,6 +1095,7 @@ static void serial_console_write(struct 
 				 unsigned count)
 {
 	struct uart_port *port = &serial_console_port->port;
+	unsigned short bits;
 	int i;
 
 	for (i = 0; i < count; i++) {
@@ -1103,6 +1104,11 @@ static void serial_console_write(struct 
 
 		sci_poll_put_char(port, *s++);
 	}
+
+	/* wait until fifo is empty and last bit has been transmitted */
+	bits = SCxSR_TDxE(port) | SCxSR_TEND(port);
+	while ((sci_in(port, SCxSR) & bits) != bits)
+		cpu_relax();
 }
 
 static int __init serial_console_setup(struct console *co, char *options)