stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 3/5] tty: serial: sh-sci: Fix TE setting on SCI IP
       [not found] <20230331113346.170602-1-biju.das.jz@bp.renesas.com>
@ 2023-03-31 11:33 ` Biju Das
  2023-04-12  7:38   ` Biju Das
  0 siblings, 1 reply; 2+ messages in thread
From: Biju Das @ 2023-03-31 11:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Biju Das, Jiri Slaby, Geert Uytterhoeven, Yoshinori Sato,
	linux-serial, Prabhakar Mahadev Lad, linux-renesas-soc, stable

As per the RZ/G2L users hardware manual (Rev.1.20 Sep, 2022), section
23.3.7 Serial Data Transmission (Asynchronous Mode) it is mentioned
that the TE (transmit enable) must be set after setting TIE (transmit
interrupt enable) or these 2 bits are set to 1 simultaneously by a
single instruction. So set these 2 bits in single instruction.

Fixes: 93bcefd4c6ba ("serial: sh-sci: Fix setting SCSCR_TIE while transferring data")
Cc: stable@vger.kernel.org
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v3:
 * New patch moved here from Renesas SCI fixes patch series
 * Updated commit description
 * Moved handling of clearing TE bit as separate patch#5.
---
 drivers/tty/serial/sh-sci.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 15743c2f3d3d..32f5c1f7d697 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -601,6 +601,15 @@ static void sci_start_tx(struct uart_port *port)
 	    port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
 		/* Set TIE (Transmit Interrupt Enable) bit in SCSCR */
 		ctrl = serial_port_in(port, SCSCR);
+
+		/*
+		 * For SCI, TE (transmit enable) must be set after setting TIE
+		 * (transmit interrupt enable) or in the same instruction to start
+		 * the transmit process.
+		 */
+		if (port->type == PORT_SCI)
+			ctrl |= SCSCR_TE;
+
 		serial_port_out(port, SCSCR, ctrl | SCSCR_TIE);
 	}
 }
@@ -2600,8 +2609,14 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
 		sci_set_mctrl(port, port->mctrl);
 	}
 
-	scr_val |= SCSCR_RE | SCSCR_TE |
-		   (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
+	/*
+	 * For SCI, TE (transmit enable) must be set after setting TIE
+	 * (transmit interrupt enable) or in the same instruction to
+	 * start the transmitting process. So skip setting TE here for SCI.
+	 */
+	if (port->type != PORT_SCI)
+		scr_val |= SCSCR_TE;
+	scr_val |= SCSCR_RE | (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
 	serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
 	if ((srr + 1 == 5) &&
 	    (port->type == PORT_SCIFA || port->type == PORT_SCIFB)) {
-- 
2.25.1


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

* RE: [PATCH v3 3/5] tty: serial: sh-sci: Fix TE setting on SCI IP
  2023-03-31 11:33 ` [PATCH v3 3/5] tty: serial: sh-sci: Fix TE setting on SCI IP Biju Das
@ 2023-04-12  7:38   ` Biju Das
  0 siblings, 0 replies; 2+ messages in thread
From: Biju Das @ 2023-04-12  7:38 UTC (permalink / raw)
  To: Biju Das, Greg Kroah-Hartman, Geert Uytterhoeven
  Cc: Jiri Slaby, Yoshinori Sato, linux-serial, Prabhakar Mahadev Lad,
	linux-renesas-soc, stable

Hi All,

> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: Friday, March 31, 2023 12:34 PM
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Biju Das <biju.das.jz@bp.renesas.com>; Jiri Slaby
> <jirislaby@kernel.org>; Geert Uytterhoeven <geert+renesas@glider.be>;
> Yoshinori Sato <ysato@users.sourceforge.jp>; linux-serial@vger.kernel.org;
> Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>; linux-
> renesas-soc@vger.kernel.org; stable@vger.kernel.org
> Subject: [PATCH v3 3/5] tty: serial: sh-sci: Fix TE setting on SCI IP
> 
> As per the RZ/G2L users hardware manual (Rev.1.20 Sep, 2022), section
> 23.3.7 Serial Data Transmission (Asynchronous Mode) it is mentioned that the
> TE (transmit enable) must be set after setting TIE (transmit interrupt
> enable) or these 2 bits are set to 1 simultaneously by a single instruction.
> So set these 2 bits in single instruction.
> 
> Fixes: 93bcefd4c6ba ("serial: sh-sci: Fix setting SCSCR_TIE while
> transferring data")
> Cc: stable@vger.kernel.org

I rechecked and the fixes tag is wrong. So, I would like to remove fixes
tag for this patch in next version.

Cheers,
Biju

> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v3:
>  * New patch moved here from Renesas SCI fixes patch series
>  * Updated commit description
>  * Moved handling of clearing TE bit as separate patch#5.
> ---
>  drivers/tty/serial/sh-sci.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index
> 15743c2f3d3d..32f5c1f7d697 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -601,6 +601,15 @@ static void sci_start_tx(struct uart_port *port)
>  	    port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
>  		/* Set TIE (Transmit Interrupt Enable) bit in SCSCR */
>  		ctrl = serial_port_in(port, SCSCR);
> +
> +		/*
> +		 * For SCI, TE (transmit enable) must be set after setting TIE
> +		 * (transmit interrupt enable) or in the same instruction to
> start
> +		 * the transmit process.
> +		 */
> +		if (port->type == PORT_SCI)
> +			ctrl |= SCSCR_TE;
> +
>  		serial_port_out(port, SCSCR, ctrl | SCSCR_TIE);
>  	}
>  }
> @@ -2600,8 +2609,14 @@ static void sci_set_termios(struct uart_port *port,
> struct ktermios *termios,
>  		sci_set_mctrl(port, port->mctrl);
>  	}
> 
> -	scr_val |= SCSCR_RE | SCSCR_TE |
> -		   (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
> +	/*
> +	 * For SCI, TE (transmit enable) must be set after setting TIE
> +	 * (transmit interrupt enable) or in the same instruction to
> +	 * start the transmitting process. So skip setting TE here for SCI.
> +	 */
> +	if (port->type != PORT_SCI)
> +		scr_val |= SCSCR_TE;
> +	scr_val |= SCSCR_RE | (s->cfg->scscr & ~(SCSCR_CKE1 | SCSCR_CKE0));
>  	serial_port_out(port, SCSCR, scr_val | s->hscif_tot);
>  	if ((srr + 1 == 5) &&
>  	    (port->type == PORT_SCIFA || port->type == PORT_SCIFB)) {
> --
> 2.25.1


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

end of thread, other threads:[~2023-04-12  7:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230331113346.170602-1-biju.das.jz@bp.renesas.com>
2023-03-31 11:33 ` [PATCH v3 3/5] tty: serial: sh-sci: Fix TE setting on SCI IP Biju Das
2023-04-12  7:38   ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).