All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH] serial: a3720: Implement pending method for output direction
Date: Thu, 14 Jan 2021 15:46:35 +0100	[thread overview]
Message-ID: <20210114144635.20049-1-pali@kernel.org> (raw)

To check if some output characters are waiting either in Transmitter
Holding Register or Transmitter Shift Register we need to look at
TX_EMPTY bit of UART Status Register.

Signed-off-by: Pali Roh?r <pali@kernel.org>
---
 drivers/serial/serial_mvebu_a3700.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_mvebu_a3700.c b/drivers/serial/serial_mvebu_a3700.c
index fb43f88eaf..909901c9f0 100644
--- a/drivers/serial/serial_mvebu_a3700.c
+++ b/drivers/serial/serial_mvebu_a3700.c
@@ -23,6 +23,7 @@ struct mvebu_platdata {
 #define UART_POSSR_REG		0x14
 
 #define UART_STATUS_RX_RDY	0x10
+#define UART_STATUS_TX_EMPTY	0x40
 #define UART_STATUS_TXFIFO_FULL	0x800
 
 #define UART_CTRL_RXFIFO_RESET	0x4000
@@ -59,8 +60,13 @@ static int mvebu_serial_pending(struct udevice *dev, bool input)
 	struct mvebu_platdata *plat = dev_get_platdata(dev);
 	void __iomem *base = plat->base;
 
-	if (readl(base + UART_STATUS_REG) & UART_STATUS_RX_RDY)
-		return 1;
+	if (input) {
+		if (readl(base + UART_STATUS_REG) & UART_STATUS_RX_RDY)
+			return 1;
+	} else {
+		if (!(readl(base + UART_STATUS_REG) & UART_STATUS_TX_EMPTY))
+			return 1;
+	}
 
 	return 0;
 }
-- 
2.20.1

             reply	other threads:[~2021-01-14 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 14:46 Pali Rohár [this message]
2021-01-15 14:50 ` [PATCH] serial: a3720: Implement pending method for output direction Stefan Roese
2021-01-15 15:07   ` Pali Rohár

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=20210114144635.20049-1-pali@kernel.org \
    --to=pali@kernel.org \
    --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.