mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches
@ 2014-05-15 18:14 Fabio Estevam
  2014-05-15 21:21 ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-05-15 18:14 UTC (permalink / raw)
  To: s.hauer; +Cc: Fabio Estevam, barebox, eric.nelson

Bit 7 of UCR3 is described in the i.MX reference manuals (with the exception
of i.MX1) as follows:

ADNIMP: Autobaud Detection Not Improved-. Disables new features of
	autobaud detection (See Baud Rate Automatic Detection
	Protocol, for more details).

	0 Autobaud detection new features selected
	1 Keep old autobaud detection mechanism

The "new features" mechanism occasionally causes the receiver to get out of sync 
and continuously produces received characters of '0xff'.

In order to reproduce the problem:

$ cs0.baudrate=19200
- Change the terminal baudrate to 19200
- Type in the console and it should look good
- Change the terminal baudrate back to 115200
- Type 'b' in the console, then a stream of '0xff' is transmitted in loop

Setting the ADNIMP bit avoids the transmission of '0xff' in loop.

Also rename the bit definition as per the reference manual.

Tested on mx6q.

Based on a patch from Eric Nelson for U-boot.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
As the 0xff character is not seen in the console, an easy way to 'see' it is 
doing like this in order to easily demonstrate the bug:

--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -258,7 +258,8 @@ static int imx_serial_getc(struct console_device *cdev)
        while (readl(priv->regs + priv->devtype->uts) & UTS_RXEMPTY);
 
        ch = readl(priv->regs + URXD0);
-
+       if (ch >= 0x80)
+               ch = '?';
        return ch;
 }

 drivers/serial/serial_imx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_imx.c b/drivers/serial/serial_imx.c
index e0bd185..cb10627 100644
--- a/drivers/serial/serial_imx.c
+++ b/drivers/serial/serial_imx.c
@@ -79,7 +79,7 @@
 #define  UCR3_DSR        (1<<10) /* Data set ready */
 #define  UCR3_DCD        (1<<9)  /* Data carrier detect */
 #define  UCR3_RI         (1<<8)  /* Ring indicator */
-#define  UCR3_TIMEOUTEN  (1<<7)  /* Timeout interrupt enable */
+#define  UCR3_ADNIMP     (1<<7)  /* Autobaud Detection Not Improved */
 #define  UCR3_RXDSEN	 (1<<6)  /* Receive status interrupt enable */
 #define  UCR3_AIRINTEN   (1<<5)  /* Async IR wake interrupt enable */
 #define  UCR3_AWAKEN	 (1<<4)  /* Async wake interrupt enable */
@@ -152,7 +152,7 @@ static struct imx_serial_devtype_data imx1_data = {
 
 static struct imx_serial_devtype_data imx21_data = {
 	.ucr1_val = 0,
-	.ucr3_val = 0x700 | UCR3_RXDMUXSEL,
+	.ucr3_val = 0x700 | UCR3_RXDMUXSEL | UCR3_ADNIMP,
 	.ucr4_val = UCR4_CTSTL_32,
 	.uts = 0xb4,
 	.onems = 0xb0,
-- 
1.8.3.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches
  2014-05-15 18:14 [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches Fabio Estevam
@ 2014-05-15 21:21 ` Sascha Hauer
  2014-05-15 22:05   ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2014-05-15 21:21 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: barebox, eric.nelson

Hi Fabio,

On Thu, May 15, 2014 at 03:14:36PM -0300, Fabio Estevam wrote:
> Bit 7 of UCR3 is described in the i.MX reference manuals (with the exception
> of i.MX1) as follows:
> 
> ADNIMP: Autobaud Detection Not Improved-. Disables new features of
> 	autobaud detection (See Baud Rate Automatic Detection
> 	Protocol, for more details).
> 
> 	0 Autobaud detection new features selected
> 	1 Keep old autobaud detection mechanism
> 
> The "new features" mechanism occasionally causes the receiver to get out of sync 
> and continuously produces received characters of '0xff'.
> 
> In order to reproduce the problem:
> 
> $ cs0.baudrate=19200
> - Change the terminal baudrate to 19200
> - Type in the console and it should look good
> - Change the terminal baudrate back to 115200
> - Type 'b' in the console, then a stream of '0xff' is transmitted in loop
> 
> Setting the ADNIMP bit avoids the transmission of '0xff' in loop.
> 
> Also rename the bit definition as per the reference manual.
> 
> Tested on mx6q.
> 
> Based on a patch from Eric Nelson for U-boot.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> As the 0xff character is not seen in the console, an easy way to 'see' it is 
> doing like this in order to easily demonstrate the bug:
> 
> --- a/drivers/serial/serial_imx.c
> +++ b/drivers/serial/serial_imx.c
> @@ -258,7 +258,8 @@ static int imx_serial_getc(struct console_device *cdev)
>         while (readl(priv->regs + priv->devtype->uts) & UTS_RXEMPTY);
>  
>         ch = readl(priv->regs + URXD0);
> -
> +       if (ch >= 0x80)
> +               ch = '?';

This is not part of the fix, right?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches
  2014-05-15 21:21 ` Sascha Hauer
@ 2014-05-15 22:05   ` Fabio Estevam
  2014-05-28 19:57     ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-05-15 22:05 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Fabio Estevam, barebox, Eric Nelson

Hi Sascha,

On Thu, May 15, 2014 at 6:21 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:

>> --- a/drivers/serial/serial_imx.c
>> +++ b/drivers/serial/serial_imx.c
>> @@ -258,7 +258,8 @@ static int imx_serial_getc(struct console_device *cdev)
>>         while (readl(priv->regs + priv->devtype->uts) & UTS_RXEMPTY);
>>
>>         ch = readl(priv->regs + URXD0);
>> -
>> +       if (ch >= 0x80)
>> +               ch = '?';
>
> This is not part of the fix, right?

Correct, this is not part of the fix.

This code is just to help reproducing the issue in console, without
the need of hooking an oscilloscope to the UART pins or inspecting
directly the UART TX registers.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches
  2014-05-15 22:05   ` Fabio Estevam
@ 2014-05-28 19:57     ` Fabio Estevam
  2014-06-02  7:22       ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2014-05-28 19:57 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Fabio Estevam, barebox, Eric Nelson

On Thu, May 15, 2014 at 7:05 PM, Fabio Estevam <festevam@gmail.com> wrote:
> Hi Sascha,
>
> On Thu, May 15, 2014 at 6:21 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
>>> --- a/drivers/serial/serial_imx.c
>>> +++ b/drivers/serial/serial_imx.c
>>> @@ -258,7 +258,8 @@ static int imx_serial_getc(struct console_device *cdev)
>>>         while (readl(priv->regs + priv->devtype->uts) & UTS_RXEMPTY);
>>>
>>>         ch = readl(priv->regs + URXD0);
>>> -
>>> +       if (ch >= 0x80)
>>> +               ch = '?';
>>
>> This is not part of the fix, right?
>
> Correct, this is not part of the fix.
>
> This code is just to help reproducing the issue in console, without
> the need of hooking an oscilloscope to the UART pins or inspecting
> directly the UART TX registers.

Any comments, Sascha?

The same fix has also been applied to the kernel:
https://git.kernel.org/cgit/linux/kernel/git/gregkh/tty.git/commit/?h=tty-next&id=b38cb7d2571197b56cefae8967f9db15c9361113

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches
  2014-05-28 19:57     ` Fabio Estevam
@ 2014-06-02  7:22       ` Sascha Hauer
  2014-06-02 10:59         ` Fabio Estevam
  0 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2014-06-02  7:22 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: Fabio Estevam, barebox, Eric Nelson

On Wed, May 28, 2014 at 04:57:18PM -0300, Fabio Estevam wrote:
> On Thu, May 15, 2014 at 7:05 PM, Fabio Estevam <festevam@gmail.com> wrote:
> > Hi Sascha,
> >
> > On Thu, May 15, 2014 at 6:21 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> >>> --- a/drivers/serial/serial_imx.c
> >>> +++ b/drivers/serial/serial_imx.c
> >>> @@ -258,7 +258,8 @@ static int imx_serial_getc(struct console_device *cdev)
> >>>         while (readl(priv->regs + priv->devtype->uts) & UTS_RXEMPTY);
> >>>
> >>>         ch = readl(priv->regs + URXD0);
> >>> -
> >>> +       if (ch >= 0x80)
> >>> +               ch = '?';
> >>
> >> This is not part of the fix, right?
> >
> > Correct, this is not part of the fix.
> >
> > This code is just to help reproducing the issue in console, without
> > the need of hooking an oscilloscope to the UART pins or inspecting
> > directly the UART TX registers.
> 
> Any comments, Sascha?

No, I assumed you resend the patch without the hunk above.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches
  2014-06-02  7:22       ` Sascha Hauer
@ 2014-06-02 10:59         ` Fabio Estevam
  0 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2014-06-02 10:59 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Fabio Estevam, barebox, Eric Nelson

Hi Sascha,

On Mon, Jun 2, 2014 at 4:22 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> Any comments, Sascha?
>
> No, I assumed you resend the patch without the hunk above.

The hunk was sent below the --- line, so it is not part of the original patch.

I put it below the --- line just for clarification.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-06-02 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 18:14 [PATCH] serial: imx: Fix buggy transmissions when baudrate mismatches Fabio Estevam
2014-05-15 21:21 ` Sascha Hauer
2014-05-15 22:05   ` Fabio Estevam
2014-05-28 19:57     ` Fabio Estevam
2014-06-02  7:22       ` Sascha Hauer
2014-06-02 10:59         ` Fabio Estevam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox