public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan@gerhold.net>
To: Ramon Fried <rfried.dev@gmail.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Nicolas Dechesne <nicolas.dechesne@linaro.org>
Subject: Re: [PATCH 3/3] serial: serial_msm: Delay initialization to let pins stabilize
Date: Thu, 15 Jul 2021 08:15:33 +0200	[thread overview]
Message-ID: <YO/ShWLRvUdODaK9@gerhold.net> (raw)
In-Reply-To: <CAGi-RU+wFO2KQP=_T3JDOVg2k947oDBeuV+yVvNAN7LrFvHeHQ@mail.gmail.com>

On Wed, Jul 14, 2021 at 11:39:34PM +0300, Ramon Fried wrote:
> On Wed, Jul 14, 2021 at 11:56 AM Stephan Gerhold <stephan@gerhold.net> wrote:
> >
> > For some reason, the DragonBoard 410c aborts autoboot immediately if
> > U-Boot is started without LK. It looks like it picks up a single broken
> > character via serial and therefore believes a key was pressed to abort
> > autoboot.
> >
> > After some debugging, it seems like adding some delay after pinctrl
> > setup but before UART initialization fixes the issue. It's also worth
> > mentioning that unlike when booting from LK, the pinctrl setup is
> > actually necessary when booting U-Boot without LK since UART is broken
> > if the pinctrl line is removed.
> >
> > I suspect that reconfiguring the pins might take some time to stabilize
> > and if the UART controller is enabled too quickly it will pick up some
> > random noise. Adding a few milliseconds of delay fixes the issue and
> > shouldn't have any other negative side effects.
> >
> > 3ms seems to be the minimum delay required in my tests, use 5ms instead
> > just to be sure.
> >
> > Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
> > ---
> >
> >  drivers/serial/serial_msm.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
> > index d8dd5c1104..ac4d0824b9 100644
> > --- a/drivers/serial/serial_msm.c
> > +++ b/drivers/serial/serial_msm.c
> > @@ -18,6 +18,7 @@
> >  #include <asm/global_data.h>
> >  #include <asm/io.h>
> >  #include <linux/compiler.h>
> > +#include <linux/delay.h>
> >  #include <dm/pinctrl.h>
> >
> >  /* Serial registers - this driver works in uartdm mode*/
> > @@ -193,6 +194,9 @@ static int msm_uart_clk_init(struct udevice *dev)
> >
> >  static void uart_dm_init(struct msm_serial_data *priv)
> >  {
> > +       /* Delay initialization for a bit to let pins stabilize if necessary */
> > +       mdelay(5);
> > +
> >         writel(priv->clk_bit_rate, priv->base + UARTDM_CSR);
> >         writel(0x0, priv->base + UARTDM_MR1);
> >         writel(MSM_BOOT_UART_DM_8_N_1_MODE, priv->base + UARTDM_MR2);
> > --
> > 2.32.0
> >
> Eh...this is not a nice fix, perhaps just clearing the RX buffer after
> initialization will work better ?

I don't like it much either but this is the best I came up with even
after spending several hours trying to track down the problem. I also
tried porting more register initialization from LK, probably even
tried clearing the RX buffer again after initialization.

The problem is: In my tests there was no way to get rid of the delay,
because the character doesn't show up until a few milliseconds after
initialization. What you suggest would only work like this:

  <initialize UART>
  mdelay(5); // Wait for the weird character to show up
  <clear RX buffer>

Which is not much different (and in fact will take longer) than:

  mdelay(5);
  <initialize UART>

So unfortunately I can't think of a way to get rid of the delay. :(

I'm not sure if this is some strange problem of my DB410c, I'd actually
be curious if the problem can also be reproduced on others.

Stephan

  reply	other threads:[~2021-07-15  6:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14  8:56 [PATCH 0/3] board: dragonboard410c: Fix some minor issues Stephan Gerhold
2021-07-14  8:56 ` [PATCH 1/3] board: dragonboard410c: Fix PHYS_SDRAM_1_SIZE Stephan Gerhold
2021-07-14 20:37   ` Ramon Fried
2021-07-24 20:40   ` Tom Rini
2021-07-14  8:56 ` [PATCH 2/3] board: dragonboard410c: Fix fastboot Stephan Gerhold
2021-07-14 20:36   ` Ramon Fried
2021-07-24 20:40   ` Tom Rini
2021-07-14  8:56 ` [PATCH 3/3] serial: serial_msm: Delay initialization to let pins stabilize Stephan Gerhold
2021-07-14 20:39   ` Ramon Fried
2021-07-15  6:15     ` Stephan Gerhold [this message]
2021-07-24 20:40   ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YO/ShWLRvUdODaK9@gerhold.net \
    --to=stephan@gerhold.net \
    --cc=nicolas.dechesne@linaro.org \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox