linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC] uartlite driver MicroBlaze compatability
@ 2007-05-01  4:55 John Williams
  2007-05-01  5:55 ` Grant Likely
  2007-05-02 13:45 ` Peter Korsgaard
  0 siblings, 2 replies; 11+ messages in thread
From: John Williams @ 2007-05-01  4:55 UTC (permalink / raw)
  To: linuxppc-embedded, jacmet

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]

Hi Peter,

The attached patch gets your uartlite driver going on MicroBlaze.

All readb/writeb ops are converted to ioread32/iowrite32.

On MicroBlaze readb/writeb are picking up the MSB, instead of LSB, and 
thus reading all zeros instead of the 8-bit control/status/FIFO 
registers that you intended.

Can you please confirm if this works on PPC?

I note that Grant's recent bootloader driver uses in_be32/out_be32 - 
would you prefer that instead of ioread32/iowrite32?

Thanks,

John

[-- Attachment #2: 00001-uartlite-32bit-ops.patch --]
[-- Type: text/plain, Size: 3731 bytes --]

Convert readb/writeb ops into ioread32/iowrite32.

This gets the driver working with MicroBlaze (2.6.20).

signed-off-by: John Williams jwilliams@itee.uq.edu.au

Index: linux-2.6.x/drivers/serial/uartlite.c
===================================================================
--- linux-2.6.x/drivers/serial/uartlite.c	(revision 2561)
+++ linux-2.6.x/drivers/serial/uartlite.c	(working copy)
@@ -61,7 +61,7 @@
 	/* stats */
 	if (stat & ULITE_STATUS_RXVALID) {
 		port->icount.rx++;
-		ch = readb(port->membase + ULITE_RX);
+		ch = ioread32(port->membase + ULITE_RX);
 
 		if (stat & ULITE_STATUS_PARITY)
 			port->icount.parity++;
@@ -106,7 +106,7 @@
 		return 0;
 
 	if (port->x_char) {
-		writeb(port->x_char, port->membase + ULITE_TX);
+		iowrite32(port->x_char, port->membase + ULITE_TX);
 		port->x_char = 0;
 		port->icount.tx++;
 		return 1;
@@ -115,7 +115,7 @@
 	if (uart_circ_empty(xmit) || uart_tx_stopped(port))
 		return 0;
 
-	writeb(xmit->buf[xmit->tail], port->membase + ULITE_TX);
+	iowrite32(xmit->buf[xmit->tail], port->membase + ULITE_TX);
 	xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
 	port->icount.tx++;
 
@@ -132,7 +132,7 @@
 	int busy;
 
 	do {
-		int stat = readb(port->membase + ULITE_STATUS);
+		int stat = ioread32(port->membase + ULITE_STATUS);
 		busy  = ulite_receive(port, stat);
 		busy |= ulite_transmit(port, stat);
 	} while (busy);
@@ -148,7 +148,7 @@
 	unsigned int ret;
 
 	spin_lock_irqsave(&port->lock, flags);
-	ret = readb(port->membase + ULITE_STATUS);
+	ret = ioread32(port->membase + ULITE_STATUS);
 	spin_unlock_irqrestore(&port->lock, flags);
 
 	return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0;
@@ -171,7 +171,7 @@
 
 static void ulite_start_tx(struct uart_port *port)
 {
-	ulite_transmit(port, readb(port->membase + ULITE_STATUS));
+	ulite_transmit(port, ioread32(port->membase + ULITE_STATUS));
 }
 
 static void ulite_stop_rx(struct uart_port *port)
@@ -200,17 +200,17 @@
 	if (ret)
 		return ret;
 
-	writeb(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
+	iowrite32(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
 	       port->membase + ULITE_CONTROL);
-	writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
+	iowrite32(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
 
 	return 0;
 }
 
 static void ulite_shutdown(struct uart_port *port)
 {
-	writeb(0, port->membase + ULITE_CONTROL);
-	readb(port->membase + ULITE_CONTROL); /* dummy */
+	iowrite32(0, port->membase + ULITE_CONTROL);
+	ioread32(port->membase + ULITE_CONTROL); /* dummy */
 	free_irq(port->irq, port);
 }
 
@@ -314,7 +314,7 @@
 
 	/* wait up to 10ms for the character(s) to be sent */
 	for (i = 0; i < 10000; i++) {
-		if (readb(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY)
+		if (ioread32(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY)
 			break;
 		udelay(1);
 	}
@@ -323,7 +323,7 @@
 static void ulite_console_putchar(struct uart_port *port, int ch)
 {
 	ulite_console_wait_tx(port);
-	writeb(ch, port->membase + ULITE_TX);
+	iowrite32(ch, port->membase + ULITE_TX);
 }
 
 static void ulite_console_write(struct console *co, const char *s,
@@ -340,8 +340,8 @@
 		spin_lock_irqsave(&port->lock, flags);
 
 	/* save and disable interrupt */
-	ier = readb(port->membase + ULITE_STATUS) & ULITE_STATUS_IE;
-	writeb(0, port->membase + ULITE_CONTROL);
+	ier = ioread32(port->membase + ULITE_STATUS) & ULITE_STATUS_IE;
+	iowrite32(0, port->membase + ULITE_CONTROL);
 
 	uart_console_write(port, s, count, ulite_console_putchar);
 
@@ -349,7 +349,7 @@
 
 	/* restore interrupt state */
 	if (ier)
-		writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
+		iowrite32(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
 
 	if (locked)
 		spin_unlock_irqrestore(&port->lock, flags);

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-05-03 10:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-01  4:55 [RFC] uartlite driver MicroBlaze compatability John Williams
2007-05-01  5:55 ` Grant Likely
2007-05-01  6:42   ` John Williams
2007-05-02  5:47     ` Grant Likely
2007-05-02  6:18       ` John Williams
2007-05-02 14:09       ` Peter Korsgaard
2007-05-02 15:59         ` Grant Likely
2007-05-02 13:59   ` Peter Korsgaard
2007-05-02 13:45 ` Peter Korsgaard
2007-05-03  1:08   ` John Williams
2007-05-03 10:22     ` David H. Lynch Jr.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).