All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] serial_bcm283x_mu: Flush RX queue after setting baud rate
Date: Tue,  6 Mar 2018 14:13:26 +0100	[thread overview]
Message-ID: <20180306131327.61174-2-agraf@suse.de> (raw)
In-Reply-To: <20180306131327.61174-1-agraf@suse.de>

After the UART was initialized, we may still have bogus data in the
RX queue if it was enabled with incorrect pin muxing before.

So let's flush the RX queue whenever we initialize baud rates.

This fixes a regression with the dynamic pinmuxing code when enable_uart=1
is not set in config.txt.

Fixes: caf2233b28 ("bcm283x: Add pinctrl driver")
Reported-by: Göran Lundberg <goran@lundberg.email>
Reported-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 drivers/serial/serial_bcm283x_mu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c
index 40029fadbc..d87b44e902 100644
--- a/drivers/serial/serial_bcm283x_mu.c
+++ b/drivers/serial/serial_bcm283x_mu.c
@@ -51,6 +51,8 @@ struct bcm283x_mu_priv {
 	struct bcm283x_mu_regs *regs;
 };
 
+static int bcm283x_mu_serial_getc(struct udevice *dev);
+
 static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate)
 {
 	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
@@ -59,13 +61,17 @@ static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate)
 	u32 divider;
 
 	if (plat->skip_init)
-		return 0;
+		goto out;
 
 	divider = plat->clock / (baudrate * 8);
 
 	writel(BCM283X_MU_LCR_DATA_SIZE_8, &regs->lcr);
 	writel(divider - 1, &regs->baud);
 
+out:
+	/* Flush the RX queue - all data in there is bogus */
+	while (bcm283x_mu_serial_getc(dev) != -EAGAIN) ;
+
 	return 0;
 }
 
-- 
2.12.3

  reply	other threads:[~2018-03-06 13:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 13:13 [U-Boot] [PATCH 0/2] [for 2018.03] RPi: Drain RX queue on setbrg Alexander Graf
2018-03-06 13:13 ` Alexander Graf [this message]
2018-03-07 12:57   ` [U-Boot] [PATCH 1/2] serial_bcm283x_mu: Flush RX queue after setting baud rate Peter Robinson
2018-03-06 13:13 ` [U-Boot] [PATCH 2/2] bcm283x_pl011: " Alexander Graf
2018-03-07 12:59   ` Peter Robinson
2018-03-07 21:06     ` Alexander Graf
2018-03-07 13:07 ` [U-Boot] [PATCH 0/2] [for 2018.03] RPi: Drain RX queue on setbrg Peter Robinson
2018-03-07 13:40   ` Alexander Graf

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=20180306131327.61174-2-agraf@suse.de \
    --to=agraf@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.