All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial: a3720: Implement pending method for output direction
@ 2021-01-14 14:46 Pali Rohár
  2021-01-15 14:50 ` Stefan Roese
  0 siblings, 1 reply; 3+ messages in thread
From: Pali Rohár @ 2021-01-14 14:46 UTC (permalink / raw
  To: u-boot

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

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

* [PATCH] serial: a3720: Implement pending method for output direction
  2021-01-14 14:46 [PATCH] serial: a3720: Implement pending method for output direction Pali Rohár
@ 2021-01-15 14:50 ` Stefan Roese
  2021-01-15 15:07   ` Pali Rohár
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Roese @ 2021-01-15 14:50 UTC (permalink / raw
  To: u-boot

On 14.01.21 15:46, Pali Roh?r wrote:
> 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>

Reviewed-by: Stefan Roese <sr@denx.de>

BTW: How did you detect this issue?

Thanks,
Stefan

> ---
>   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;
>   }
> 


Viele Gr??e,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de

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

* [PATCH] serial: a3720: Implement pending method for output direction
  2021-01-15 14:50 ` Stefan Roese
@ 2021-01-15 15:07   ` Pali Rohár
  0 siblings, 0 replies; 3+ messages in thread
From: Pali Rohár @ 2021-01-15 15:07 UTC (permalink / raw
  To: u-boot

On Friday 15 January 2021 15:50:46 Stefan Roese wrote:
> On 14.01.21 15:46, Pali Roh?r wrote:
> > 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>
> 
> Reviewed-by: Stefan Roese <sr@denx.de>
> 
> BTW: How did you detect this issue?

During debugging both TF-A and linux kernel as they were eating
characters sent via A3720 UART. Details are in kernel and TF-A patches:

https://lore.kernel.org/linux-serial/20201223191931.18343-1-pali at kernel.org/
https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/7734

I have not spotted this issue in U-Boot (only in TF-A and kernel), but I
decided to look also at the U-Boot A3720 UART implementation... And find
out that it is incomplete too, ignoring 'bool input' function argument.

> Thanks,
> Stefan
> 
> > ---
> >   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;
> >   }
> > 
> 
> 
> Viele Gr??e,
> Stefan
> 
> -- 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de

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

end of thread, other threads:[~2021-01-15 15:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-14 14:46 [PATCH] serial: a3720: Implement pending method for output direction Pali Rohár
2021-01-15 14:50 ` Stefan Roese
2021-01-15 15:07   ` Pali Rohár

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.