2021-11-17 01:05:41

by Prabhakar Mahadev Lad

[permalink] [raw]
Subject: [PATCH 0/3] SPI driver support for RZ/G2L

Hi All,

This patch series adds RSPI driver and dt binding support to RZ/G2L SoC.

Cheers,
Prabhakar

Lad Prabhakar (3):
dt-bindings: spi: renesas,rspi: Document RZ/G2L SoC
spi: spi-rspi: Add support to deassert/assert reset line
spi: spi-rspi: Drop redeclaring ret variable in qspi_transfer_in()

.../devicetree/bindings/spi/renesas,rspi.yaml | 13 ++++++++-
drivers/spi/spi-rspi.c | 27 ++++++++++++++++++-
2 files changed, 38 insertions(+), 2 deletions(-)

--
2.17.1



2021-11-17 01:05:43

by Prabhakar Mahadev Lad

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: spi: renesas,rspi: Document RZ/G2L SoC

Add RSPI binding documentation for Renesas RZ/G2L SoC.

RSPI block is identical to one found on RZ/A, so no driver changes are
required the fallback compatible string "renesas,rspi-rz" will be used
on RZ/G2L

Signed-off-by: Lad Prabhakar <[email protected]>
Reviewed-by: Biju Das <[email protected]>
---
.../devicetree/bindings/spi/renesas,rspi.yaml | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/spi/renesas,rspi.yaml b/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
index 8397f60d80a2..604f8452b4f5 100644
--- a/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
+++ b/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
@@ -21,7 +21,8 @@ properties:
- enum:
- renesas,rspi-r7s72100 # RZ/A1H
- renesas,rspi-r7s9210 # RZ/A2
- - const: renesas,rspi-rz # RZ/A
+ - renesas,r9a07g044-rspi # RZ/G2{L,LC}
+ - const: renesas,rspi-rz # RZ/A and RZ/G2{L,LC}

- items:
- enum:
@@ -116,6 +117,16 @@ allOf:
required:
- interrupt-names

+ - if:
+ properties:
+ compatible:
+ contains:
+ enum:
+ - renesas,r9a07g044-rspi
+ then:
+ required:
+ - resets
+
- if:
properties:
compatible:
--
2.17.1


2021-11-17 01:05:46

by Prabhakar Mahadev Lad

[permalink] [raw]
Subject: [PATCH 2/3] spi: spi-rspi: Add support to deassert/assert reset line

On RZ/G2L SoC we need to explicitly deassert the reset line
for the device to work, use this opportunity to deassert/assert
reset line in spi-rspi driver.

This patch adds support to read the "resets" property (if available)
from DT and perform deassert/assert when required.

Signed-off-by: Lad Prabhakar <[email protected]>
Reviewed-by: Biju Das <[email protected]>
---
drivers/spi/spi-rspi.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index d16ed88802d3..592682d96562 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -21,6 +21,7 @@
#include <linux/dma-mapping.h>
#include <linux/of_device.h>
#include <linux/pm_runtime.h>
+#include <linux/reset.h>
#include <linux/sh_dma.h>
#include <linux/spi/spi.h>
#include <linux/spi/rspi.h>
@@ -1225,8 +1226,14 @@ static const struct of_device_id rspi_of_match[] = {

MODULE_DEVICE_TABLE(of, rspi_of_match);

+static void rspi_reset_control_assert(void *data)
+{
+ reset_control_assert(data);
+}
+
static int rspi_parse_dt(struct device *dev, struct spi_controller *ctlr)
{
+ struct reset_control *rstc;
u32 num_cs;
int error;

@@ -1238,6 +1245,24 @@ static int rspi_parse_dt(struct device *dev, struct spi_controller *ctlr)
}

ctlr->num_chipselect = num_cs;
+
+ rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
+ if (IS_ERR(rstc))
+ return dev_err_probe(dev, PTR_ERR(rstc),
+ "failed to get reset ctrl\n");
+
+ error = reset_control_deassert(rstc);
+ if (error) {
+ dev_err(dev, "failed to deassert reset %d\n", error);
+ return error;
+ }
+
+ error = devm_add_action_or_reset(dev, rspi_reset_control_assert, rstc);
+ if (error) {
+ dev_err(dev, "failed to register assert devm action, %d\n", error);
+ return error;
+ }
+
return 0;
}
#else
--
2.17.1


2021-11-17 01:05:49

by Prabhakar Mahadev Lad

[permalink] [raw]
Subject: [PATCH 3/3] spi: spi-rspi: Drop redeclaring ret variable in qspi_transfer_in()

"ret" variable is already declared in qspi_transfer_in() at the
beginning of function, drop redeclaring ret in the if block, fixing
below:

spi-rspi.c: In function ‘qspi_transfer_in’:
spi-rspi.c:838:7: warning: declaration of ‘ret’ shadows a previous local
838 | int ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
| ^~~
spi-rspi.c:835:6: note: shadowed declaration is here
835 | int ret;

Fixes: db30083813b55 ("spi: rspi: avoid uninitialized variable access")
Signed-off-by: Lad Prabhakar <[email protected]>
---
drivers/spi/spi-rspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 592682d96562..815698366412 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -835,7 +835,7 @@ static int qspi_transfer_in(struct rspi_data *rspi, struct spi_transfer *xfer)
int ret;

if (rspi->ctlr->can_dma && __rspi_can_dma(rspi, xfer)) {
- int ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
+ ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
if (ret != -EAGAIN)
return ret;
}
--
2.17.1


2021-11-17 08:51:52

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: spi: renesas,rspi: Document RZ/G2L SoC

Hi Prabhakar,

On Wed, Nov 17, 2021 at 2:05 AM Lad Prabhakar
<[email protected]> wrote:
> Add RSPI binding documentation for Renesas RZ/G2L SoC.
>
> RSPI block is identical to one found on RZ/A, so no driver changes are
> required the fallback compatible string "renesas,rspi-rz" will be used

... required. The ...

> on RZ/G2L
>
> Signed-off-by: Lad Prabhakar <[email protected]>
> Reviewed-by: Biju Das <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

> --- a/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
> +++ b/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
> @@ -21,7 +21,8 @@ properties:
> - enum:
> - renesas,rspi-r7s72100 # RZ/A1H
> - renesas,rspi-r7s9210 # RZ/A2
> - - const: renesas,rspi-rz # RZ/A
> + - renesas,r9a07g044-rspi # RZ/G2{L,LC}
> + - const: renesas,rspi-rz # RZ/A and RZ/G2{L,LC}
>
> - items:
> - enum:
> @@ -116,6 +117,16 @@ allOf:
> required:
> - interrupt-names
>
> + - if:
> + properties:
> + compatible:
> + contains:
> + enum:
> + - renesas,r9a07g044-rspi
> + then:
> + required:
> + - resets
> +

You may want to merge this with the existing section that makes
resets required for renesas,qspi.

> - if:
> properties:
> compatible:

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

2021-11-17 08:56:09

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 2/3] spi: spi-rspi: Add support to deassert/assert reset line

On Wed, Nov 17, 2021 at 2:05 AM Lad Prabhakar
<[email protected]> wrote:
> On RZ/G2L SoC we need to explicitly deassert the reset line
> for the device to work, use this opportunity to deassert/assert
> reset line in spi-rspi driver.
>
> This patch adds support to read the "resets" property (if available)
> from DT and perform deassert/assert when required.
>
> Signed-off-by: Lad Prabhakar <[email protected]>
> Reviewed-by: Biju Das <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

2021-11-17 08:57:20

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH 3/3] spi: spi-rspi: Drop redeclaring ret variable in qspi_transfer_in()

On Wed, Nov 17, 2021 at 2:05 AM Lad Prabhakar
<[email protected]> wrote:
> "ret" variable is already declared in qspi_transfer_in() at the
> beginning of function, drop redeclaring ret in the if block, fixing
> below:
>
> spi-rspi.c: In function ‘qspi_transfer_in’:
> spi-rspi.c:838:7: warning: declaration of ‘ret’ shadows a previous local
> 838 | int ret = rspi_dma_transfer(rspi, NULL, &xfer->rx_sg);
> | ^~~
> spi-rspi.c:835:6: note: shadowed declaration is here
> 835 | int ret;
>
> Fixes: db30083813b55 ("spi: rspi: avoid uninitialized variable access")
> Signed-off-by: Lad Prabhakar <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

2021-11-17 08:58:11

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: spi: renesas,rspi: Document RZ/G2L SoC

Hi Geert,

Thank you for the review.

On Wed, Nov 17, 2021 at 8:51 AM Geert Uytterhoeven <[email protected]> wrote:
>
> Hi Prabhakar,
>
> On Wed, Nov 17, 2021 at 2:05 AM Lad Prabhakar
> <[email protected]> wrote:
> > Add RSPI binding documentation for Renesas RZ/G2L SoC.
> >
> > RSPI block is identical to one found on RZ/A, so no driver changes are
> > required the fallback compatible string "renesas,rspi-rz" will be used
>
> ... required. The ...
>
will fix that.

> > on RZ/G2L
> >
> > Signed-off-by: Lad Prabhakar <[email protected]>
> > Reviewed-by: Biju Das <[email protected]>
>
> Reviewed-by: Geert Uytterhoeven <[email protected]>
>
> > --- a/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
> > +++ b/Documentation/devicetree/bindings/spi/renesas,rspi.yaml
> > @@ -21,7 +21,8 @@ properties:
> > - enum:
> > - renesas,rspi-r7s72100 # RZ/A1H
> > - renesas,rspi-r7s9210 # RZ/A2
> > - - const: renesas,rspi-rz # RZ/A
> > + - renesas,r9a07g044-rspi # RZ/G2{L,LC}
> > + - const: renesas,rspi-rz # RZ/A and RZ/G2{L,LC}
> >
> > - items:
> > - enum:
> > @@ -116,6 +117,16 @@ allOf:
> > required:
> > - interrupt-names
> >
> > + - if:
> > + properties:
> > + compatible:
> > + contains:
> > + enum:
> > + - renesas,r9a07g044-rspi
> > + then:
> > + required:
> > + - resets
> > +
>
> You may want to merge this with the existing section that makes
> resets required for renesas,qspi.
>
Right, I completely missed that.

Cheers,
Prabhakar

> > - if:
> > properties:
> > compatible:
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
>
> 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

2021-11-17 12:55:25

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: spi: renesas,rspi: Document RZ/G2L SoC

On Wed, Nov 17, 2021 at 01:05:25AM +0000, Lad Prabhakar wrote:
> Add RSPI binding documentation for Renesas RZ/G2L SoC.
>
> RSPI block is identical to one found on RZ/A, so no driver changes are
> required the fallback compatible string "renesas,rspi-rz" will be used
> on RZ/G2L

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.


Attachments:
(No filename) (612.00 B)
signature.asc (488.00 B)
Download all attachments

2021-11-17 14:18:17

by Lad, Prabhakar

[permalink] [raw]
Subject: Re: [PATCH 1/3] dt-bindings: spi: renesas,rspi: Document RZ/G2L SoC

Hi Mark,

Thank you for the review.

On Wed, Nov 17, 2021 at 12:55 PM Mark Brown <[email protected]> wrote:
>
> On Wed, Nov 17, 2021 at 01:05:25AM +0000, Lad Prabhakar wrote:
> > Add RSPI binding documentation for Renesas RZ/G2L SoC.
> >
> > RSPI block is identical to one found on RZ/A, so no driver changes are
> > required the fallback compatible string "renesas,rspi-rz" will be used
> > on RZ/G2L
>
> Please submit patches using subject lines reflecting the style for the
> subsystem, this makes it easier for people to identify relevant patches.
> Look at what existing commits in the area you're changing are doing and
> make sure your subject lines visually resemble what they're doing.
> There's no need to resubmit to fix this alone.

My bad will update it to "spi: dt-bindings: renesas,rspi: Document
RZ/G2L SoC" and re-send a v2 along with the review commented by Geert.

Cheers,
Prabhakar