serial driver PMC MSP71xx, kernel linux-mips.git mast er
Subsystems (2)
Quoted 32 lines · Sergei Shtylyov
Quoted 22 lines · Marc St-Jean
Here is my second attempt at the serial driver patch for the PMC-Sierra MSP71xx device.
There are three different fixes:
1. Fix for THRE errata
- I verified theUART_BUG_TXENfix does not help with this erratum.
- I left our current fix in until I get our platform booting on 2.6.20-rc4 to try the mm tree "8250-uart-backup-timer.patch". Feel free to ignore for now.2. Fix for Busy Detect on LCR write
- Moved to newUPIO_DWAPBiotype. Because the new type is a memory mapped device and there are several tests forUPIO_MEM, this involved updatingserial_core.cand8250_early.cin addition to 8250.c.
- I tried implementing this totally inserial_inas suggested, but it can't be done because of bit overlap betweenUART_IIR_NO_INTandUART_IIR_BUSY. Also there is no way to set the interrupt "handled = 1" fromserial_in.3. Workaround for interrupt/data concurrency issue
- Moved to newUPIO_DWAPBiotype.Quoted 6 lines
Index: linux_2_6/drivers/serial/8250.c
===================================================================
RCS file: linux_2_6/drivers/serial/8250.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 8250.c
--- linux_2_6/drivers/serial/8250.c 19 Oct 2006 21:00:58 -00001.1.1.7
Quoted 1 line
+++ linux_2_6/drivers/serial/8250.c 24 Jan 2007 23:55:27 -0000
[...]
Quoted 7 lines
Review line 335
Quoted 3 lines
(quoted diff) +0
-0@@ -333,6 +334,8 @@ static void serial_out(struct uart_8250_port *up, int offset, int value)Your patch is clearly garbled again, something added an extra space
to all
lines stating with space... :-/
I see that but was under the impression cvs diff did that so all lines lineup correctly whether they have a +, -, or neither. It doesn't affect applying the patches for me, did you try?
Quoted 5 lines
Review line 338
Quoted 3 lines
(quoted diff) +2
-0{ + /* Save the offset before it's remapped */ + int save_offset = offset;Is there real need to save this? What regshift equals for this UART?
Yes, we have a regshift of 2 on this SoC and it could be different on other SoCs which reuse the UART IP.
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0
-0offset = map_8250_out_reg(up, offset) << up->port.regshift; switch (up->port.iotype) {@@ -359,6 +362,19 @@ writeb(value, up->port.membase + offset); break;
Quoted 11 lines
Review line 373
Quoted 9 lines
(quoted diff) +9
-0+ case UPIO_DWAPB: + /* Save the LCR value so it can be re-written when a + * Busy Detect interrupt occurs. */ + if (save_offset == UART_LCR) + up->lcr = value; + writeb(value, up->port.membase + offset); + /* Read the IER to ensure any interrupt is cleared before + * returning from ISR. */ + if ((save_offset == UART_TX || save_offset == UART_IER) &&Not sure how an IER read ensures that...
It's just a dummy read to ensure that any writes which clear interrupts have reached the device before returning from the IRQ.
Quoted 5 lines
Review line 374
Quoted 1 line
(quoted diff) +1
-0+ in_irq())I'd suggest to either indent this line right (start below 2ns paren
of if
stmt) or keep on the same line.
OK, moved onto same line.
Quoted 26 lines
Quoted 7 lines
(quoted diff) +3
-0+ value = serial_in(up, UART_IER); + break; + default: outb(value, up->port.iobase + offset); }Review line 1038
Quoted 7 lines
(quoted diff) +4
-0@@ -1016,6 +1032,17 @@ up->bugs |= UART_BUG_NOMSR; #endif + /* Workaround: + * The DesignWare SoC UART part has a bug for all + * versions before 3.03a (2005-07-18) + * In brief, this is a non-standard 16550 in that the THREinterrupt
Review line 1039
Quoted 1 line
(quoted diff) +1
-0+ * will not re-assert itself simply by disabling andre-enabling the
Review line 1040
Quoted 1 line
(quoted diff) +1
-0+ * THRI bit in the IER, it is only re-enabled if a character isactually
Quoted 7 lines
(quoted diff) +5
-0+ * sent out. + */ + if( up->port.flags & UPF_DW_THRE_BUG ) + up->bugs |= UART_BUG_DWTHRE; + serial_outp(up, UART_LCR, save_lcr);
Quoted 12 lines
Review line 1175
Quoted 10 lines
(quoted diff) +5
-0if (up->capabilities != uart_config[up->port.type].flags) {@@ -1141,6 +1168,12 @@ iir = serial_in(up, UART_IIR); if (lsr & UART_LSR_TEMT && iir & UART_IIR_NO_INT) transmit_chars(up); + } else if (up->bugs & UART_BUG_DWTHRE) { + unsigned char lsr, iir; + lsr = serial_in(up, UART_LSR); + iir = serial_in(up, UART_IIR); + if (lsr & UART_LSR_THRE)Why read IIR if you don't check it?
Good point. I didn't write that one and assumed reading the IIR was part of the fix. It just tested fine without it so it's gone.
Quoted 57 lines
Review line 2409
Quoted 12 lines
(quoted diff) +5
-3@@ -2352,9 +2402,12 @@ add_preferred_console("ttyS", line, options); printk("Adding console on ttyS%d at %s 0x%lx (options '%s')\n", - line, port->iotype == UPIO_MEM ? "MMIO" : "I/O port", - port->iotype == UPIO_MEM ? (unsigned long) port->mapbase : - (unsigned long) port->iobase, options); + line, + (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB) + ? "MMIO" : "I/O port", + (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB) + ? (unsigned long) port->mapbase : (unsignedlong)
port->iobase,Quoted 4 lines
(quoted diff) +1
-0+ options); if (!(serial8250_console.flags & CON_ENABLED)) { serial8250_console.flags &= ~CON_PRINTBUFFER; register_console(&serial8250_console);[...]
Quoted 6 lines
Index:
linux_2_6/drivers/serial/8250_early.c
===================================================================
RCS file: linux_2_6/drivers/serial/8250_early.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.38250_early.c
---linux_2_6/drivers/serial/8250_early.c19 Oct 2006 20:08:20-0000 1.1.1.3
Review line 47
Quoted 4 lines
+++
linux_2_6/drivers/serial/8250_early.c24 Jan 2007 23:55:27 -0000(quoted diff) +0
-0@@ -46,7 +46,7 @@ static unsigned int __init serial_in(struct uart_port *port, intoffset)
Review line 55
Quoted 9 lines
(quoted diff) +1
-1{ - if (port->iotype == UPIO_MEM) + if (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB) return readb(port->membase + offset); else return inb(port->iobase + offset);@@ -54,7 +54,7 @@ static void __init serial_out(struct uart_port *port, int offset,int value)
Quoted 7 lines
(quoted diff) +1
-1{ - if (port->iotype == UPIO_MEM) + if (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB) writeb(value, port->membase + offset); else outb(value, port->iobase + offset);Review line 239
Quoted 8 lines
(quoted diff) +1
-1@@ -233,7 +233,7 @@ return 0; /* Try to start the normal driver on a matching line. */ - mmio = (port->iotype == UPIO_MEM); + mmio = (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB); line = serial8250_start_console(port, device->options); if (line < 0) printk("No ttyS device at %s 0x%lx for console\n",From your 8250_eraly.c changes I can conclude regshift == 1 (it doesn't
Quoted 2 lines
currently support other cases). So,
serial_pot()doesn't needsave_offset. :-)
Our regshift is definitely 2 on this SoC and we don't have any problems with console output before the serial driver opens. So assuming it's using 8250_early.c for initial console output I can only conclude that it works because UART_TX is offset 0 and the port was left configured from our ROM monitor.
Quoted 23 lines
Quoted 6 lines
Index:
linux_2_6/drivers/serial/serial_core.c
===================================================================
RCS file: linux_2_6/drivers/serial/serial_core.c,v retrieving revision 1.1.1.7
diff -u -r1.1.1.7serial_core.c
---linux_2_6/drivers/serial/serial_core.c19 Oct 2006 21:00:58-0000 1.1.1.7
Review line 1674
Quoted 8 lines
+++
linux_2_6/drivers/serial/serial_core.c24 Jan 2007 23:55:28 -0000(quoted diff) +0
-3@@ -1669,9 +1669,10 @@ ret = sprintf(buf, "%d: uart:%s %s%08lX irq:%d", port->line, uart_type(port), - port->iotype == UPIO_MEM ? "mmio:0x" : "port:", - port->iotype == UPIO_MEM ? port->mapbase : - (unsigned long)
port->iobase,Review line 1672
Quoted 1 line
(quoted diff) +1
-0+ (port->iotype == UPIO_MEM || port->iotype ==
UPIO_DWAPB)Review line 1674
Quoted 2 lines
(quoted diff) +2
-0+ ? "mmio:0x" : "port:", + (port->iotype == UPIO_MEM || port->iotype ==
UPIO_DWAPB)Review line 1675
Quoted 1 line
(quoted diff) +1
-0+ ? port->mapbase : (unsigned long)
port->iobase,
Quoted 8 lines
Review line 1677
Quoted 2 lines
(quoted diff) +0
-0port->irq); if (port->type == PORT_UNKNOWN) {Needless change. My patch that fixes this function is in Linus' tree
since
September, not sure why you don't have it:
I have it, I forgot to respin against the master.
Quoted 13 lines
Quoted 7 lines
Index:
linux_2_6/include/linux/serial_core.h
===================================================================
RCS file: linux_2_6/include/linux/serial_core.h,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7serial_core.h
---linux_2_6/include/linux/serial_core.h19 Oct 2006 21:01:02-0000 1.1.1.7
Quoted 1 line
+++
linux_2_6/include/linux/serial_core.h24 Jan 2007 23:55:28 -0000[...]
Review line 277
Quoted 2 lines
(quoted diff) +0
-0@@ -274,6 +277,7 @@ struct device *dev; /* parentdevice */
Quoted 8 lines
Review line 278
Quoted 1 line
(quoted diff) +0
-0unsigned char hub6; /* this shouldbe in the 8250 driver */
Review line 280
Quoted 2 lines
(quoted diff) +1
-0unsigned char unused[3]; + void *user; /*generic platform 'user' pointer */
Erm, 'private' or 'data' would've sounded better in the kernel context,
IMHO... :-)
OK, I picked 'data'.
Quoted 12 lines
Quoted 6 lines
Index:
linux_2_6/include/linux/serial_reg.h
===================================================================
RCS file: linux_2_6/include/linux/serial_reg.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2serial_reg.h
---linux_2_6/include/linux/serial_reg.h19 Oct 2006 18:29:50-0000 1.1.1.2
Quoted 5 lines
+++
linux_2_6/include/linux/serial_reg.h24 Jan 2007 23:55:29 -0000(quoted diff) +0
-0@@ -218,6 +218,10 @@ #define UART_FCR_PXAR16 0x80 /* receive FIFO treshold = 16 */ #define UART_FCR_PXAR32 0xc0 /* receive FIFO treshold = 32 */
Quoted 8 lines
Review line 224
Quoted 4 lines
(quoted diff) +4
-0+/* + * DesignWare APB UART + */ +#define UART_IIR_BUSY 0x07 /* Busy Detect */I'd suggest keeping this with other UART_IIR_* #defines, separated
by the
more elaborate comment.
Will do. I noticed that the other non-standard value UART_IIR_TOD 0x08 is with the Xscale stuff so I followed suit.
Marc
Hello.
Quoted 39 lines · Marc St-Jean
Quoted 31 lines
Quoted 22 lines
Here is my second attempt at the serial driver patch for the PMC-Sierra MSP71xx device.
There are three different fixes:
1. Fix for THRE errata
- I verified theUART_BUG_TXENfix does not help with this erratum.
- I left our current fix in until I get our platform booting on 2.6.20-rc4 to try the mm tree "8250-uart-backup-timer.patch". Feel free to ignore for now.2. Fix for Busy Detect on LCR write
- Moved to newUPIO_DWAPBiotype. Because the new type is a memory mapped device and there are several tests forUPIO_MEM, this involved updatingserial_core.cand8250_early.cin addition to 8250.c.
- I tried implementing this totally inserial_inas suggested, but it can't be done because of bit overlap betweenUART_IIR_NO_INTandUART_IIR_BUSY. Also there is no way to set the interrupt "handled = 1" fromserial_in.3. Workaround for interrupt/data concurrency issue
- Moved to newUPIO_DWAPBiotype.Quoted 6 lines
Index: linux_2_6/drivers/serial/8250.c
===================================================================
RCS file: linux_2_6/drivers/serial/8250.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 8250.c
--- linux_2_6/drivers/serial/8250.c 19 Oct 2006 21:00:58 -00001.1.1.7
Quoted 1 line
+++ linux_2_6/drivers/serial/8250.c 24 Jan 2007 23:55:27 -0000
[...]
Quoted 7 lines
Review line 335
Quoted 3 lines
(quoted diff) +0
-0@@ -333,6 +334,8 @@ static void serial_out(struct uart_8250_port *up, int offset, int value)Your patch is clearly garbled again, something added an extra space
to all
lines stating with space... :-/
Quoted 2 lines
I see that but was under the impression cvs diff did that so all lines lineup correctly whether they have a +, -, or neither.
Yes. And your mailer has probably added another space to lines already
begginign with space. Some mailers tend to do it, don't know sure why... :-/
Quoted 1 line
It doesn't affect applying the patches for me, did you try?
I hadn't but I had no doubts it'll fail... just tried, not a single hunk
applied. :-]
Quoted 8 lines
Quoted 5 lines
Review line 338
Quoted 3 lines
(quoted diff) +2
-0{ + /* Save the offset before it's remapped */ + int save_offset = offset;Is there real need to save this? What regshift equals for this UART?
Yes, we have a regshift of 2 on this SoC and it could be different on other SoCs which reuse the UART IP.
Agreed then (though still seems avoidable).
Quoted 19 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0
-0offset = map_8250_out_reg(up, offset) << up->port.regshift; switch (up->port.iotype) {@@ -359,6 +362,19 @@ writeb(value, up->port.membase + offset); break;Quoted 11 lines
Review line 373
Quoted 9 lines
(quoted diff) +9
-0+ case UPIO_DWAPB: + /* Save the LCR value so it can be re-written when a + * Busy Detect interrupt occurs. */ + if (save_offset == UART_LCR) + up->lcr = value; + writeb(value, up->port.membase + offset); + /* Read the IER to ensure any interrupt is cleared before + * returning from ISR. */ + if ((save_offset == UART_TX || save_offset == UART_IER) &&Not sure how an IER read ensures that...
Quoted 2 lines
It's just a dummy read to ensure that any writes which clear interrupts have reached the device before returning from the IRQ.
Hm, isn't it CPU write buffer flush? Shouldn't this be handled more
generically?
[...]
Quoted 41 lines
Quoted 31 lines
Quoted 6 lines
Index:
linux_2_6/drivers/serial/8250_early.c
===================================================================
RCS file: linux_2_6/drivers/serial/8250_early.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.38250_early.c
---linux_2_6/drivers/serial/8250_early.c19 Oct 2006 20:08:20-0000 1.1.1.3
Review line 47
Quoted 4 lines
+++
linux_2_6/drivers/serial/8250_early.c24 Jan 2007 23:55:27 -0000(quoted diff) +0
-0@@ -46,7 +46,7 @@ static unsigned int __init serial_in(struct uart_port *port, intoffset)
Review line 55
Quoted 9 lines
(quoted diff) +1
-1{ - if (port->iotype == UPIO_MEM) + if (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB) return readb(port->membase + offset); else return inb(port->iobase + offset);@@ -54,7 +54,7 @@ static void __init serial_out(struct uart_port *port, int offset,int value)
Quoted 9 lines
(quoted diff) +1
-1{ - if (port->iotype == UPIO_MEM) + if (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB) writeb(value, port->membase + offset); else outb(value, port->iobase + offset);@@ -233,7 +233,7 @@ return 0;Quoted 9 lines
Review line 239
Quoted 6 lines
(quoted diff) +1
-1/* Try to start the normal driver on a matching line. */ - mmio = (port->iotype == UPIO_MEM); + mmio = (port->iotype == UPIO_MEM || port->iotype == UPIO_DWAPB); line = serial8250_start_console(port, device->options); if (line < 0) printk("No ttyS device at %s 0x%lx for console\n",From your
8250_eraly.cchanges I can conclude regshift == 1 (it doesn't
currently support other cases). So,serial_pot()doesn't needsave_offset. :-)
Quoted 3 lines
Our regshift is definitely 2 on this SoC and we don't have any problems with console output before the serial driver opens. So assuming it's using
8250_early.cfor initial console output I can only conclude that it works
It comes into action only if you specify console=uart,... kernel option
for the eraly console support. The "plain" 8250 console driver is containded within 8250.c itself.
Quoted 2 lines
because
UART_TXis offset 0 and the port was left configured from our ROM monitor.
Well, this part of the patch can't be considered complete then (how LSR
polling is going to work?), so should either be removed or the proper regshift support added.
Quoted 21 lines
Quoted 12 lines
Quoted 6 lines
Index:
linux_2_6/include/linux/serial_reg.h
===================================================================
RCS file: linux_2_6/include/linux/serial_reg.h,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2serial_reg.h
---linux_2_6/include/linux/serial_reg.h19 Oct 2006 18:29:50-0000 1.1.1.2
Quoted 5 lines
+++
linux_2_6/include/linux/serial_reg.h24 Jan 2007 23:55:29 -0000(quoted diff) +0
-0@@ -218,6 +218,10 @@ #define UART_FCR_PXAR16 0x80 /* receive FIFO treshold = 16 */ #define UART_FCR_PXAR32 0xc0 /* receive FIFO treshold = 32 */Quoted 8 lines
Review line 224
Quoted 4 lines
(quoted diff) +4
-0+/* + * DesignWare APB UART + */ +#define UART_IIR_BUSY 0x07 /* Busy Detect */I'd suggest keeping this with other UART_IIR_* #defines, separated
by the
more elaborate comment.
Quoted 2 lines
Will do. I noticed that the other non-standard value
UART_IIR_TOD0x08is with the Xscale stuff so I followed suit.
Well, Xscale introduced several bits. And note that 16650 definitions are
kept with the "standard" 16550 ones. Well, be sure to elaborate the comment whereever you stick that #define.
Quoted 1 line
Marc
MBR, Sergei