mbox series

[v3,0/5] Renesas SCI fixes

Message ID 20230320105339.236279-1-biju.das.jz@bp.renesas.com
Headers show
Series Renesas SCI fixes | expand

Message

Biju Das March 20, 2023, 10:53 a.m. UTC
RZ/G2UL SMARC EVK has sci pins exposed through PMOD1 interface.
On testing, found that irq handler, tx and rx is broken.

This series fixes these issues.

v2->v3:
 * Cced stable@vger.kernel.org
 * Added Rx, Tx and Tx end interrupt handler patch.
v1->v2:
 * Replaced the wrong fixes tag
 * Added a simpler check in sci_init_single() and added a check in
   probe to catch invalid interrupt count.
Tested the SCI0 interface on RZ/G2UL by connecting to PMOD USBUART.
 39:          0     GICv3 437 Level     1004d000.serial:rx err
 40:         12     GICv3 438 Edge      1004d000.serial:rx full
 41:         70     GICv3 439 Edge      1004d000.serial:tx empty
 42:         18     GICv3 440 Level     1004d000.serial:tx end

Overlay compilation:
--------------------
Enable CONFIG_OF_OVERLAY in defconfig

cpp -nostdinc -I include -I arch -undef -x assembler-with-cpp \
  arch/arm64/boot//dts/renesas/r9a07g043u11-smarc.dts \
  r9a07g043u11-smarc.dts.tmp

dtc -@ -i include/ -I dts -O dtb -o arch/arm64/boot/dts/renesas/r9a07g043u11-smarc.dtb   r9a07g043u11-smarc.dts.tmp

cpp -nostdinc -I include -I arch -undef -x assembler-with-cpp \
  arch/arm64/boot/dts/renesas/r9a07g043-smarc.dtso \
  r9a07g043-smarc.dtso.tmp

dtc -@ -i include/ -I dts -O dtb -o arch/arm64/boot/dts/renesas/r9a07g043-smarc.dtbo   r9a07g043-smarc.dtso.tmp

Applying overlay:
-----------------
apply_overlay=tftp 0x48000000 RZ-G2UL/r9a07g043u11-smarc.dtb;fdt addr 0x48000000;fdt resize 8192;tftp 0x4A000000 RZ-G2UL/r9a07g043-smarc.dtbo;fdt apply 0x4A000000
bootcmd-overlay=run apply_overlay;tftp 0x48080000 RZ-G2UL/Image;booti 0x48080000 - 0x48000000

Biju Das (5):
  tty: serial: sh-sci: Fix transmit end interrupt handler
  tty: serial: sh-sci: Fix Rx on RZ/G2L SCI
  tty: serial: sh-sci: Fix Tx on SCI IP
  tty: serial: sh-sci: Add support for tx end interrupt handling
  arm64: dts: renesas: r9a07g044: Enable sci0 nodes using dt overlay

 arch/arm64/boot/dts/renesas/Makefile          |  1 +
 .../boot/dts/renesas/r9a07g043-smarc.dtso     | 45 ++++++++++++
 drivers/tty/serial/sh-sci.c                   | 72 +++++++++++++++++--
 drivers/tty/serial/sh-sci.h                   |  3 +
 4 files changed, 115 insertions(+), 6 deletions(-)
 create mode 100644 arch/arm64/boot/dts/renesas/r9a07g043-smarc.dtso

Comments

Biju Das March 21, 2023, 7:55 a.m. UTC | #1
Hi Geert,

Thanks for the feedback.

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: Monday, March 20, 2023 7:12 PM
> To: Biju Das <biju.das.jz@bp.renesas.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; 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: Re: [PATCH v3 2/5] tty: serial: sh-sci: Fix Rx on RZ/G2L SCI
> 
> Hi Biju,
> 
> On Mon, Mar 20, 2023 at 11:53 AM Biju Das <biju.das.jz@bp.renesas.com>
> wrote:
> > SCI IP on RZ/G2L alike SoCs do not need regshift compared to other SCI
> > IPs on the SH platform. Currently, it does regshift and configuring Rx
> > wrongly. Drop adding regshift for RZ/G2L alike SoCs.
> >
> > Fixes: f9a2adcc9e90 ("arm64: dts: renesas: r9a07g044: Add SCI[0-1]
> > nodes")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v3:
> >  * New patch.
> 
> Thanks for your patch!
> 
> > --- a/drivers/tty/serial/sh-sci.c
> > +++ b/drivers/tty/serial/sh-sci.c
> > @@ -158,6 +158,7 @@ struct sci_port {
> >
> >         bool has_rtscts;
> >         bool autorts;
> > +       bool is_rz_sci;
> >  };
> >
> >  #define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS @@ -2937,7 +2938,7
> > @@ static int sci_init_single(struct platform_device *dev,
> >         port->flags             = UPF_FIXED_PORT | UPF_BOOT_AUTOCONF | p-
> >flags;
> >         port->fifosize          = sci_port->params->fifosize;
> >
> > -       if (port->type == PORT_SCI) {
> > +       if (port->type == PORT_SCI && !sci_port->is_rz_sci) {
> 
> Perhaps check for !dev->dev.of_node instead? Values of 1 or 2 for regshift
> are only needed for sh770x/sh7750/sh7760, which don't use DT yet.  When they
> are converted to DT, we can extend the driver to support the more-or-less
> standard "reg-shift" DT property.

Agreed.

> 
> >                 if (sci_port->reg_size >= 0x20)
> >                         port->regshift = 2;
> >                 else
> > @@ -3353,6 +3354,11 @@ static int sci_probe(struct platform_device *dev)
> >         sp = &sci_ports[dev_id];
> >         platform_set_drvdata(dev, sp);
> >
> > +       if (of_device_is_compatible(dev->dev.of_node, "renesas,r9a07g043-
> sci") ||
> > +           of_device_is_compatible(dev->dev.of_node, "renesas,r9a07g044-
> sci") ||
> > +           of_device_is_compatible(dev->dev.of_node,
> > + "renesas,r9a07g054-sci"))
> 
> Please, no of_device_is_compatible() checks in a driver that uses proper DT
> matching.

OK, will drop this.

Cheers,
Biju

> 
> > +               sp->is_rz_sci = 1;
> > +
> >         ret = sci_probe_single(dev, dev_id, p, sp);
> >         if (ret)
> >                 return ret;
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like
> that.
>                                 -- Linus Torvalds