Garbage on serial console after serial driver loads
Quoted 6 lines · Russell King
Doesn't matter. The problem is that dwmw2's NS16550A patch (from ages ago) changes the prescaler setting for this device so we can use the higher speed baud rates. This means any programmed divisor (programmed at early serial console initialisation time) suddenly becomes wrong as soon as we fiddle with the prescaler during normal UART initialisation time.
Seems like you are correct, given the below patch fixes the garbage output for me.
Phil
drivers/serial/8250.c +1 -1
@@ -698,7 +698,7 @@serial_outp (up,UART_MCR , status1);if ((status2 ^ status1) &UART_MCR_LOOP ) { -#ifndef CONFIG_PPC +#if 0 serial_outp (up,UART_LCR ,0xE0 ); status1 =serial_in (up,0x04 );/* EXCR1 */ status1 &= ~0xB0 ;/* Disable LOCK, mask out PRESL[01] */
Quoted 10 lines · Phil Oester
Quoted 6 lines · Russell King
Doesn't matter. The problem is that dwmw2's NS16550A patch (from ages ago) changes the prescaler setting for this device so we can use the higher speed baud rates. This means any programmed divisor (programmed at early serial console initialisation time) suddenly becomes wrong as soon as we fiddle with the prescaler during normal UART initialisation time.
Seems like you are correct, given the below patch fixes the garbage output for me.
David,
Is this patch ok for you?
drivers/serial/8250.c +1 -1
@@ -698,7 +698,7 @@serial_outp (up,UART_MCR , status1);if ((status2 ^ status1) &UART_MCR_LOOP ) { -#ifndef CONFIG_PPC +#if 0 serial_outp (up,UART_LCR ,0xE0 ); status1 =serial_in (up,0x04 );/* EXCR1 */ status1 &= ~0xB0 ;/* Disable LOCK, mask out PRESL[01] */
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Quoted 7 lines
Quoted 3 lines
Seems like you are correct, given the below patch fixes the garbage output for me.
David,
Is this patch ok for you?
Just an aside, I've had this patch in my own internal tree for over a year I never thought it would be kernel acceptable... but I noticed this problem a long time ago and thought it was an issue with my internal hardware as I never saw it on a normal board...
Dave.
Quoted 1 line · Russell King
Is this patch ok for you?
Not really; it's just a quick hack applied without any real consideration of the problem. If we're messing up the baud rate when we change the master clock, then just make it change the divisor accordingly at the same time. We don't seem to store the active parameters of the serial console anywhere useful; we can do it just by reading back the divisor and multiplying by eight though...
Tom, does this also mean you don't need the 'ifndef ppc'?
drivers/serial/8250.c renamed from drivers/serial/8250.c~ +13 -1
@@ -567,13 +567,25 @@ static void autoconfig_16550a(struct uarif ((status2 ^ status1) &UART_MCR_LOOP ) {#ifndef CONFIG_PPC +unsigned short quot; +serial_outp (up,UART_LCR ,0xE0 ); status1 =serial_in (up,0x04 );/* EXCR1 */ status1 &= ~0xB0 ;/* Disable LOCK, mask out PRESL[01] */ status1 |=0x10 ;/* 1.625 divisor for baud_base --> 921600 */ serial_outp (up,0x04 , status1); -serial_outp (up,UART_LCR ,0 ); up->port.uartclk =921600 *16 ; + +/* Adjust the baud rate to match, in case we're +already using the port */ + quot =serial_inp (up,UART_DLM ) <<8 ; + quot +=serial_inp (up,UART_DLL ); + quot <<=3 ; +serial_outp (up,UART_DLL , quot &0xff ); +serial_outp (up,UART_DLM , quot >>8 ); + +serial_outp (up,UART_LCR ,0 ); +#endif up->port.type =PORT_NS16550A ;
Signature · 1 line
dwmw2
Quoted 6 lines · David Woodhouse
Not really; it's just a quick hack applied without any real consideration of the problem. If we're messing up the baud rate when we change the master clock, then just make it change the divisor accordingly at the same time. We don't seem to store the active parameters of the serial console anywhere useful; we can do it just by reading back the divisor and multiplying by eight though...
FYI, just tested this patch, and it does solve the garbage problem for me.
Thanks,
Phil
Quoted 11 lines · David Woodhouse
Quoted 1 line · Russell King
Is this patch ok for you?
Not really; it's just a quick hack applied without any real consideration of the problem. If we're messing up the baud rate when we change the master clock, then just make it change the divisor accordingly at the same time. We don't seem to store the active parameters of the serial console anywhere useful; we can do it just by reading back the divisor and multiplying by eight though...
Tom, does this also mean you don't need the 'ifndef ppc'?
I don't recall the problem well enough right now, but I'll go toss this into a current git tree and let you know.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 2 lines · Tom Rini
I don't recall the problem well enough right now, but I'll go toss this into a current git tree and let you know.
With what hardware are you testing? Was this really a NatSemi SuperIO chip, or was it a false positive in the detection?
Signature · 1 line
dwmw2
Quoted 6 lines · David Woodhouse
Quoted 2 lines · Tom Rini
I don't recall the problem well enough right now, but I'll go toss this into a current git tree and let you know.
With what hardware are you testing? Was this really a NatSemi SuperIO chip, or was it a false positive in the detection?
This was on, I believe, the Motorola Sandpoint, which really does have a NatSemi SuperIO.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/
Quoted 11 lines · Tom Rini
Quoted 10 lines · David Woodhouse
Quoted 1 line · Russell King
Is this patch ok for you?
Not really; it's just a quick hack applied without any real consideration of the problem. If we're messing up the baud rate when we change the master clock, then just make it change the divisor accordingly at the same time. We don't seem to store the active parameters of the serial console anywhere useful; we can do it just by reading back the divisor and multiplying by eight though...
Quoted 4 lines
Quoted 1 line
Tom, does this also mean you don't need the 'ifndef ppc'?
I don't recall the problem well enough right now, but I'll go toss this into a current git tree and let you know.
Dropping the 'ifndef ppc' is fine on my Motorola Sandpoint which I do believe exhibited the problem previously. I've cc'd Kumar Gala since I see on IRC that 85xx boards might also have had a problem here.
Signature · 2 lines
Tom Rini http://gate.crashing.org/~trini/