mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: RE: [PATCH 2/2] spi: rzv2m-csi: Add Slave mode support
Date: Wed, 27 Sep 2023 10:05:18 +0000	[thread overview]
Message-ID: <TYWPR01MB877535CB8661AE4B789519B9C2C2A@TYWPR01MB8775.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAMuHMdWUr5ReouCWV3WsOJE=2faBO-y70aDC8W8qBGVBhaMTAg@mail.gmail.com>

Hi Geert,

Thanks for your reply!

> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Subject: Re: [PATCH 2/2] spi: rzv2m-csi: Add Slave mode support
> 
> Hi Fabrizio,
> 
> On Tue, Sep 26, 2023 at 11:08 PM Fabrizio Castro
> <fabrizio.castro.jz@renesas.com> wrote:
> > The CSI IP found inside the Renesas RZ/V2M SoC supports
> > both SPI Master and SPI Slave roles.
> >
> > When working in slave mode, the CSI IP has the option
> > of using its Slave Select (SS) pin to enable TX and RX
> > operations. Since the SPI slave cannot control the clock,
> > when working as slave it's best not to stop operations
> > during a transfer, as by doing so the IP will not send or
> > receive data, regardless of clock and active level on pin SS.
> > A side effect from not stopping operations is that the RX
> > FIFO needs to be flushed, word by word, when RX data needs
> > to be discarded.
> >
> > Finally, when in slave mode timings are tighter, as missing a
> > deadline translates to errors being thrown, resulting in
> > aborting the transfer. In order to speed things up, we can
> > avoid waiting for the TX FIFO to be empty, we can just wait
> > for the RX FIFO to contain at least the number of words that
> > we expect.
> >
> > Add slave support to the currently existing CSI driver.
> >
> > Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/spi/Kconfig
> > +++ b/drivers/spi/Kconfig
> > @@ -861,8 +861,10 @@ config SPI_RSPI
> >  config SPI_RZV2M_CSI
> >         tristate "Renesas RZ/V2M CSI controller"
> >         depends on ARCH_RENESAS || COMPILE_TEST
> > +       depends on SPI_SLAVE
> 
> Isn't that a bit too strict?
> The driver can/should be used/usable in host mode when SPI_SLAVE
> is not enabled.

Good point, I'll take this dependency out.

> 
> >         help
> > -         SPI driver for Renesas RZ/V2M Clocked Serial Interface
> (CSI)
> > +         SPI driver for Renesas RZ/V2M Clocked Serial Interface
> (CSI).
> > +         CSI supports master and slave roles.
> >
> >  config SPI_QCOM_QSPI
> >         tristate "QTI QSPI controller"
> 
> > --- a/drivers/spi/spi-rzv2m-csi.c
> > +++ b/drivers/spi/spi-rzv2m-csi.c
> 
> > @@ -99,6 +112,9 @@ struct rzv2m_csi_priv {
> >         wait_queue_head_t wait;
> >         u32 errors;
> >         u32 status;
> > +       int mode;
> 
> Do you need this flag?

Nope, it's just that testing it is going to be slightly faster.

> You can use spi_controller_is_target() instead.

Will do.

> 
> > +       int slave_select;
> > +       bool slave_aborted;
> >  };
> >
> >  static void rzv2m_csi_reg_write_bit(const struct rzv2m_csi_priv
> *csi,
> 
> > @@ -279,32 +303,23 @@ static int rzv2m_csi_wait_for_interrupt(struct
> rzv2m_csi_priv *csi,
> >
> >         rzv2m_csi_enable_irqs(csi, enable_bits);
> >
> > -       ret = wait_event_timeout(csi->wait,
> > -                                ((csi->status & wait_mask) ==
> wait_mask) ||
> > -                                csi->errors, HZ);
> > +       if (csi->mode == RZV2M_CSI_SPI_SLAVE) {
> 
> spi_controller_is_target()

Will change.

> 
> > +               ret = wait_event_interruptible(csi->wait,
> > +                               ((csi->status & wait_mask) ==
> wait_mask) ||
> > +                               csi->errors || csi->slave_aborted);
> 
> target_aborted (everywhere)

Will change.

Cheers,
Fab

> 
> > +               if (ret || csi->slave_aborted)
> > +                       ret = -EINTR;
> > +       } else {
> > +               ret = wait_event_timeout(csi->wait,
> > +                               ((csi->status & wait_mask) ==
> wait_mask) ||
> > +                               csi->errors, HZ) == 0 ? -ETIMEDOUT :
> 0;
> > +       }
> 
> 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

      reply	other threads:[~2023-09-27 10:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 21:08 [PATCH 0/2] Add RZ/V2M CSI slave support Fabrizio Castro
2023-09-26 21:08 ` [PATCH 1/2] spi: renesas,rzv2m-csi: Add SPI Slave related properties Fabrizio Castro
2023-09-27  7:59   ` Geert Uytterhoeven
2023-09-27  9:00     ` Mark Brown
2023-09-27  9:10       ` Geert Uytterhoeven
2023-09-27  9:21         ` Mark Brown
2023-09-27  9:44           ` Geert Uytterhoeven
2023-09-27 10:05             ` Mark Brown
2023-09-27 10:18               ` Fabrizio Castro
2023-09-27 10:22                 ` Mark Brown
2023-09-27  9:43         ` Fabrizio Castro
2023-09-27  9:36     ` Fabrizio Castro
2023-09-27  8:56   ` Mark Brown
2023-09-27  9:40     ` Fabrizio Castro
2023-09-26 21:08 ` [PATCH 2/2] spi: rzv2m-csi: Add Slave mode support Fabrizio Castro
2023-09-27  9:02   ` Mark Brown
2023-09-27  9:12     ` Geert Uytterhoeven
2023-09-27  9:15       ` Mark Brown
2023-09-27  9:51   ` Geert Uytterhoeven
2023-09-27 10:05     ` Fabrizio Castro [this message]

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=TYWPR01MB877535CB8661AE4B789519B9C2C2A@TYWPR01MB8775.jpnprd01.prod.outlook.com \
    --to=fabrizio.castro.jz@renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=biju.das@bp.renesas.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh+dt@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®