Linux SPI subsystem development
 help / color / mirror / Atom feed
* [PATCH v4 0/9] Add RZ/G3E xSPI support
@ 2025-04-01 14:35 Biju Das
  2025-04-01 14:35 ` [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area Biju Das
  0 siblings, 1 reply; 4+ messages in thread
From: Biju Das @ 2025-04-01 14:35 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Rob Herring, Conor Dooley, Mark Brown,
	Geert Uytterhoeven, Magnus Damm
  Cc: Biju Das, devicetree, linux-renesas-soc, linux-spi,
	Prabhakar Mahadev Lad, Biju Das

The xSPI IP found on RZ/G3E SoC similar to RPC-IF interface, but it
can support writes on memory-mapped area. Even though the registers are
different, the rpcif driver code can be reused for xSPI by adding wrapper
function to it.

This patch series tested on RZ/G2L and RZ/G3E by overwriting boot
partitions.

v3->v4:
 * Added a definition for the spi core clock in the R9A09G047 CPG bindings
   header file.
 * Updated the example with spi core clock
 * Retained Rb tag from Rob as these changes are trivial.
 * Fixed the duplicate most outer set of parentheses in patch#2.
 * Updated commit description for patch{#4,#7,#8}.
 * Renamed the functions *_helper()->*_impl().
 * Replaced ssize_t->size_t as the return data type for
   rpcif_dirmap_read_impl().
 * Renamed the local variable length->read and it's data type
   ssize_t->size_t.
 * Added comment for addr_nbytes in struct rpcif_priv.
 * Added struct rpcif_impl for holding the function pointers and data to
   handle the differences between xspi and rpc-if interface and added
   suffix _impl() for functions.
 * The enabling/disabling of spi/spix2 clocks at runtime leading to
   flash write failure. So, enable these clocks during probe() and
   disable it in remove().
 * Collected tags.
v2->v3:
 * Fixed RPCIF_DRENR_CDB macro error.
v1->v2:
 * As rz-xspi is too generic, replaced file name rz-xspi->rzg3e-xspi
   and dropped generic compatible rz-xspi.
 * Dropped prefix spi from interrupt names.
 * Updated the example with above changes.
 * Retained Rb tag from Rob as these changes are trivial.
 * Fixed the build error reported by bot by dropping 
   EXPORT_SYMBOL(xspi_dirmap_read) and restoring
   EXPORT_SYMBOL(rpcif_dirmap_read).
 * Replaced enum XSPI_RZ->XSPI_RZ_G3E.
 * Replaced compatible rz-xspi->r9a09g047-xspi and device data
   xspi_info_rz->xspi_info_r9a09g047.

Biju Das (9):
  dt-bindings: memory: Document RZ/G3E support
  memory: renesas-rpc-if: Fix RPCIF_DRENR_CDB macro error
  memory: renesas-rpc-if: Move rpc-if reg definitions
  memory: renesas-rpc-if: Use devm_reset_control_array_get_exclusive()
  memory: renesas-rpc-if: Move rpcif_info definitions near to the user
  memory: renesas-rpc-if: Add regmap to struct rpcif_info
  memory: renesas-rpc-if: Add wrapper functions
  memory: renesas-rpc-if: Add RZ/G3E xSPI support
  spi: rpc-if: Add write support for memory-mapped area

 .../renesas,rzg3e-xspi.yaml                   | 135 ++++
 drivers/memory/renesas-rpc-if-regs.h          | 147 ++++
 drivers/memory/renesas-rpc-if.c               | 703 +++++++++++++-----
 drivers/memory/renesas-xspi-if-regs.h         | 105 +++
 drivers/spi/spi-rpc-if.c                      |  16 +-
 .../dt-bindings/clock/renesas,r9a09g047-cpg.h |   1 +
 include/memory/renesas-rpc-if.h               |   4 +
 7 files changed, 919 insertions(+), 192 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/renesas,rzg3e-xspi.yaml
 create mode 100644 drivers/memory/renesas-rpc-if-regs.h
 create mode 100644 drivers/memory/renesas-xspi-if-regs.h

-- 
2.43.0


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

* [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area
  2025-04-01 14:35 [PATCH v4 0/9] Add RZ/G3E xSPI support Biju Das
@ 2025-04-01 14:35 ` Biju Das
  2025-04-15  6:07   ` Krzysztof Kozlowski
  0 siblings, 1 reply; 4+ messages in thread
From: Biju Das @ 2025-04-01 14:35 UTC (permalink / raw)
  To: Mark Brown
  Cc: Biju Das, linux-spi, Krzysztof Kozlowski, Geert Uytterhoeven,
	Prabhakar Mahadev Lad, Biju Das, linux-renesas-soc

Add write support for memory-mapped area as xSPI interface require
it.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v3->v4:
 * No change.
v2->v3:
 * No change.
v1->v2:
 * No change.
---
 drivers/spi/spi-rpc-if.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-rpc-if.c b/drivers/spi/spi-rpc-if.c
index e0c66a24a3cb..627cffea5d5c 100644
--- a/drivers/spi/spi-rpc-if.c
+++ b/drivers/spi/spi-rpc-if.c
@@ -75,6 +75,19 @@ static bool rpcif_spi_mem_supports_op(struct spi_mem *mem,
 	return true;
 }
 
+static ssize_t xspi_spi_mem_dirmap_write(struct spi_mem_dirmap_desc *desc,
+					 u64 offs, size_t len, const void *buf)
+{
+	struct rpcif *rpc = spi_controller_get_devdata(desc->mem->spi->controller);
+
+	if (offs + desc->info.offset + len > U32_MAX)
+		return -EINVAL;
+
+	rpcif_spi_mem_prepare(desc->mem->spi, &desc->info.op_tmpl, &offs, &len);
+
+	return xspi_dirmap_write(rpc->dev, offs, len, buf);
+}
+
 static ssize_t rpcif_spi_mem_dirmap_read(struct spi_mem_dirmap_desc *desc,
 					 u64 offs, size_t len, void *buf)
 {
@@ -103,7 +116,7 @@ static int rpcif_spi_mem_dirmap_create(struct spi_mem_dirmap_desc *desc)
 	if (!rpc->dirmap)
 		return -EOPNOTSUPP;
 
-	if (desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN)
+	if (!rpc->xspi && desc->info.op_tmpl.data.dir != SPI_MEM_DATA_IN)
 		return -EOPNOTSUPP;
 
 	return 0;
@@ -125,6 +138,7 @@ static const struct spi_controller_mem_ops rpcif_spi_mem_ops = {
 	.exec_op	= rpcif_spi_mem_exec_op,
 	.dirmap_create	= rpcif_spi_mem_dirmap_create,
 	.dirmap_read	= rpcif_spi_mem_dirmap_read,
+	.dirmap_write	= xspi_spi_mem_dirmap_write,
 };
 
 static int rpcif_spi_probe(struct platform_device *pdev)
-- 
2.43.0


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

* Re: [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area
  2025-04-01 14:35 ` [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area Biju Das
@ 2025-04-15  6:07   ` Krzysztof Kozlowski
  2025-04-15  7:42     ` Biju Das
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Kozlowski @ 2025-04-15  6:07 UTC (permalink / raw)
  To: Biju Das, Mark Brown
  Cc: linux-spi, Geert Uytterhoeven, Prabhakar Mahadev Lad, Biju Das,
	linux-renesas-soc

On 01/04/2025 16:35, Biju Das wrote:
> Add write support for memory-mapped area as xSPI interface require
> it.
> 
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> v3->v4:
>  * No change.
> v2->v3:
>  * No change.
> v1->v2:
>  * No change.
> ---
>  drivers/spi/spi-rpc-if.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
That's also unrelated change to memory controller. Cover letter explains
nothing about dependencies and merging (checked few first lines where
this should be documented).

Best regards,
Krzysztof

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

* RE: [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area
  2025-04-15  6:07   ` Krzysztof Kozlowski
@ 2025-04-15  7:42     ` Biju Das
  0 siblings, 0 replies; 4+ messages in thread
From: Biju Das @ 2025-04-15  7:42 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Mark Brown
  Cc: linux-spi@vger.kernel.org, Geert Uytterhoeven,
	Prabhakar Mahadev Lad, biju.das.au,
	linux-renesas-soc@vger.kernel.org

Hi Krzysztof Kozlowski,

Thanks for the feedback.

> -----Original Message-----
> From: Krzysztof Kozlowski <krzk@kernel.org>
> Sent: 15 April 2025 07:07
> Subject: Re: [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area
> 
> On 01/04/2025 16:35, Biju Das wrote:
> > Add write support for memory-mapped area as xSPI interface require it.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > v3->v4:
> >  * No change.
> > v2->v3:
> >  * No change.
> > v1->v2:
> >  * No change.
> > ---
> >  drivers/spi/spi-rpc-if.c | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> That's also unrelated change to memory controller. Cover letter explains nothing about dependencies
> and merging (checked few first lines where this should be documented).

Thanks, I missed that. I will update the cover letter for merge dependency.

Cheers,
Biju

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

end of thread, other threads:[~2025-04-15  7:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 14:35 [PATCH v4 0/9] Add RZ/G3E xSPI support Biju Das
2025-04-01 14:35 ` [PATCH v4 9/9] spi: rpc-if: Add write support for memory-mapped area Biju Das
2025-04-15  6:07   ` Krzysztof Kozlowski
2025-04-15  7:42     ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox