Skip to contentSkip to conversation

spi: Add Renesas R-Car Gen3 RPC-IF SPI driver

PATCH Superseded Mason Yang 5 participants 18 messages Jan 28, 2019 – Mar 27, 2019 4 messages not in the archive

Subsystems (2)

v8 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Mason Yang

author
#0 lore raw

v8 cover spi: Add Renesas R-Car Gen3 RPC-IF SPI driver

Hi Mark,

v8 patch including:
1) Supported SoC-specific values in DTS.
2) Rename device node name as flash.

v7 patch is according to Geert and Sergei's comments:
1) Add all R-Car Gen3 model in dts.
2) patch rpc-if child node search.
3) minror coding style.

v6 patch is accroding to Geert, Marek and Sergei's comments:
1) spi_controller for new code.
2) "renesas,rcar-gen3-rpc" instead of "renesas,r8a77995-rpc."
3) patch external address read mode w/o u64 readq().
4) patch dts for write buffer & drop "renesas,rpc-mode".
5) coding style and so on.

v5 patch is accroding to Sergei's comments:
1) Read 6 bytes ID from Sergei's patch.
2) regmap_update_bits().
3) C++ style comment.

v4 patch is according to Sergei's comments including:
1) Drop soc_device_match().
2) Drop unused RPC registers.
3) Use ilog2() instead of fls().
4) Patch read 6 bytes ID w/ one command.
5) Coding style and so on.

v3 patch is according to Marek and Geert's comments including:
1) soc_device_mach() to set up RPC_PHYCNT_STRTIM.
2) get_unaligned().
3) rpc-mode for rpi-spi-flash or rpc-hyperflash.
4) coding style and so on.

v2 patch including:
1) remove RPC clock enable/dis-able control,
2) patch run time PM.
3) add RPC module software reset,
4) add regmap.
5) other coding style and so on.

thanks for your review.

best regards,
Mason

Mason Yang (2):
spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF controller
bindings

 .../devicetree/bindings/spi/spi-renesas-rpc.txt    |  40 +
 drivers/spi/Kconfig                                |   6 +
 drivers/spi/Makefile                               |   1 +
 drivers/spi/spi-renesas-rpc.c                      | 804 +++++++++++++++++++++
 4 files changed, 851 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt
 create mode 100644 drivers/spi/spi-renesas-rpc.c
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v8 1/2 spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.

---
 drivers/spi/Kconfig           |   6 +
 drivers/spi/Makefile          |   1 +
 drivers/spi/spi-renesas-rpc.c | 804 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 811 insertions(+)
 create mode 100644 drivers/spi/spi-renesas-rpc.c
drivers/spi/Kconfig +6 -0
index 9f89cb1..6ad1782 100644
@@ -544,6 +544,12 @@ config SPI_RSPI
 	help
 	  SPI driver for Renesas RSPI and QSPI blocks.
 
+config SPI_RENESAS_RPC
+	tristate "Renesas R-Car Gen3 RPC-IF controller"
+	depends on ARCH_RENESAS || COMPILE_TEST
+	help
+	  SPI driver for Renesas R-Car Gen3 RPC-IF.
+
 config SPI_QCOM_QSPI
 	tristate "QTI QSPI controller"
 	depends on ARCH_QCOM
drivers/spi/Makefile +1 -0
index f296270..9150732 100644
@@ -84,6 +84,7 @@ obj-$(CONFIG_SPI_QUP)			+= spi-qup.o
 obj-$(CONFIG_SPI_ROCKCHIP)		+= spi-rockchip.o
 obj-$(CONFIG_SPI_RB4XX)			+= spi-rb4xx.o
 obj-$(CONFIG_SPI_RSPI)			+= spi-rspi.o
+obj-$(CONFIG_SPI_RENESAS_RPC)		+= spi-renesas-rpc.o
 obj-$(CONFIG_SPI_S3C24XX)		+= spi-s3c24xx-hw.o
 spi-s3c24xx-hw-y			:= spi-s3c24xx.o
 spi-s3c24xx-hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi-s3c24xx-fiq.o
drivers/spi/spi-renesas-rpc.c new file +804 -0

804 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#2 lore raw

Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

The patch

spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

has been applied to the spi tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 94468990612b8482e7403a80777ad6abfe3d9f8f Mon Sep 17 00:00:00 2001

From: Mason Yang <[email protected]>
Date: Mon, 28 Jan 2019 14:49:17 +0800
Subject: [PATCH] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.

---
 drivers/spi/Kconfig           |   6 +
 drivers/spi/Makefile          |   1 +
 drivers/spi/spi-renesas-rpc.c | 804 ++++++++++++++++++++++++++++++++++
 3 files changed, 811 insertions(+)
 create mode 100644 drivers/spi/spi-renesas-rpc.c
drivers/spi/Kconfig +6 -0
index 17d79b91d7a8..62bee8070499 100644
@@ -564,6 +564,12 @@ config SPI_RSPI
 	help
 	  SPI driver for Renesas RSPI and QSPI blocks.
 
+config SPI_RENESAS_RPC
+	tristate "Renesas R-Car Gen3 RPC-IF controller"
+	depends on ARCH_RENESAS || COMPILE_TEST
+	help
+	  SPI driver for Renesas R-Car Gen3 RPC-IF.
+
 config SPI_QCOM_QSPI
 	tristate "QTI QSPI controller"
 	depends on ARCH_QCOM
drivers/spi/Makefile +1 -0
index 5c5af4676279..ba90f718effe 100644
@@ -86,6 +86,7 @@ obj-$(CONFIG_SPI_QUP)			+= spi-qup.o
 obj-$(CONFIG_SPI_ROCKCHIP)		+= spi-rockchip.o
 obj-$(CONFIG_SPI_RB4XX)			+= spi-rb4xx.o
 obj-$(CONFIG_SPI_RSPI)			+= spi-rspi.o
+obj-$(CONFIG_SPI_RENESAS_RPC)		+= spi-renesas-rpc.o
 obj-$(CONFIG_SPI_S3C24XX)		+= spi-s3c24xx-hw.o
 spi-s3c24xx-hw-y			:= spi-s3c24xx.o
 spi-s3c24xx-hw-$(CONFIG_SPI_S3C24XX_FIQ) += spi-s3c24xx-fiq.o
drivers/spi/spi-renesas-rpc.c new file +804 -0

804 lines not on this page · raw message

Signature · 1 line
2.20.1
#3 lore raw

Re: Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

Quoted 17 lines · Mark Brown

The patch

spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

has been applied to the spi tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

Quoted 6 lines

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

How did that happen when there were still comments and open topics ?

Signature · 2 lines
Best regards,
Marek Vasut
maintainer
#4 lore raw

Re: Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

Quoted 6 lines · Marek Vasut
Quoted 2 lines · Mark Brown

Please add any relevant lists and maintainers to the CCs when replying to this mail.

How did that happen when there were still comments and open topics ?

Mason had submitted a new verison a couple of weeks ago and there'd been no replies on the new version so I'd thought that all the prior issues had been addressed. I guess that's not the case? The thread on the version before was a bit long but seemed to peter out, though looking at the archives it seems the main issue was that Mason stopped replying.

maintainer
#5 lore raw

Re: Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

Quoted 5 lines · Mark Brown

Mason had submitted a new verison a couple of weeks ago and there'd been no replies on the new version so I'd thought that all the prior issues had been addressed. I guess that's not the case? The thread on the version before was a bit long but seemed to peter out, though looking at the archives it seems the main issue was that Mason stopped replying.

Following some IRC discussion with Marek and Sergei I've dropped these for now. The interaction with the HyperFlash support seems unclear still and might be a bit more than a simple refactoring, worst case it'll be binding incompatible though hopefully not. Mason, if you could work with them to figure out the MFD that'll be needed the driver looks fine from a SPI subsystem point of view.

Sorry about the confusion for everyone here.

A message that is not in the archive (sent off-list or not yet received): OF9C8DA179.15D69C0A-ON482583A0.00283EB5-482583A0.002E45C8@mxic.com.tw

maintainer
#7 lore raw

Re: Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

Quoted 3 lines · On Wed, Feb 13, 2019 at 04:25:32PM +0800, [email protected] wrote:

From current mainline branch, MFD seems support the device which is on the same hardware bus(i.e, I2C, SPI, MMIO and SPMI)for multi-function by Read/Write the common same registers.

That's most MFDs but there are some that do some level of enumeration (even if it's just looking at the device ID that got registered) to decide what subdevices get registered, that's what people are suggesting here I think.

Quoted 4 lines

I am checking and not sure if MMIO of MFD could support RPC-IF for different hardware bus on SPI and CFI.
I also doubt if this method is a correct solution for RPC-IF works either in SPI mode or CFI mode.

For MMIO devices MFD just passes through the parent resources.

#8 lore raw

Re: Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

Quoted 10 lines · Mark Brown
Quoted 3 lines · On Wed, Feb 13, 2019 at 04:25:32PM +0800, [email protected] wrote:

From current mainline branch, MFD seems support the device which is on the same hardware bus(i.e, I2C, SPI, MMIO and SPMI)for multi-function by Read/Write the common same registers.

That's most MFDs but there are some that do some level of enumeration (even if it's just looking at the device ID that got registered) to decide what subdevices get registered, that's what people are suggesting here I think.

Right. Although I think some of the code could be shared between the SPI and HF modes.

Quoted 7 lines
Quoted 4 lines

I am checking and not sure if MMIO of MFD could support RPC-IF for different hardware bus on SPI and CFI.
I also doubt if this method is a correct solution for RPC-IF works either in SPI mode or CFI mode.

For MMIO devices MFD just passes through the parent resources.

Signature · 2 lines
Best regards,
Marek Vasut

A message that is not in the archive (sent off-list or not yet received): OF9B3A3A20.C0BF34B8-ON482583A1.002D5F3B-482583A1.00329653@mxic.com.tw

#10 lore raw

Re: Applied "spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver" to the spi tree

Quoted 1 line · On 2/14/19 10:12 AM, [email protected] wrote:

Hi,

Hi,

Quoted 27 lines
Quoted 10 lines

"Marek Vasut" <[email protected]>
2019/02/13 下午 08:37

Quoted 6 lines · Mark Brown
Quoted 3 lines · On Wed, Feb 13, 2019 at 04:25:32PM +0800, [email protected] wrote:

From current mainline branch, MFD seems support the device which is on the same hardware bus(i.e, I2C, SPI, MMIO and SPMI)for multi-function by Read/Write the common same registers.

Quoted 7 lines
Quoted 4 lines

That's most MFDs but there are some that do some level of enumeration (even if it's just looking at the device ID that got registered) to decide what subdevices get registered, that's what people are suggesting here I think.

Right. Although I think some of the code could be shared between the SPI and HF modes.

If it is right that MFD is based on the same hardware bus for multi function
device,i.e,. based on SPI/I2C/PCI bus to register device by mfd_add_devices().

For a multi function device works on different hardware bus, it has nothing to do with mfd-core.c(MFD framework) even though their driver are in drivers/mfd directory, i.e,. mcp-core.x, sm501.c.

Quoted 6 lines

Since RPC-IF works on different hardware bus for SPI bus or CFI HyperFlash bus,
is it a good idea to implement MFD framework for RPC-IF ? Or we just separate RPC-IF driver by spi mode and cfi mode ?

any comments/opinions on RPC-IF/MFD-framework is welcome!

Mark mentioned it before, you can use the MFD for MMIO too. The goal here is to have some common code which is shared by the SPI and HF part of the driver, and then a separate SPI handling code and HF handling code. The common code should determine which part to activate based on the DT.

Signature · 2 lines
Best regards,
Marek Vasut
#11 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

In reply to Mason Yang

Hello!

Quoted 4 lines · Mason Yang

Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.

[...]

Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +0 -0
new file mode 100644
index 0000000..ea12017
@@ -0,0 +1,804 @@

[...]

Quoted 19 lines
drivers/spi/spi-renesas-rpc.c new file +19 -0
+static void rpc_spi_hw_init(struct rpc_spi *rpc)
+{
+	//
+	// NOTE: The 0x260 are undocumented bits, but they must be set.
+	//	RPC_PHYCNT_STRTIM is strobe timing adjustment bit,
+	//	0x0 : the delay is biggest,
+	//	0x1 : the delay is 2nd biggest,
+	//	On H3 ES1.x, the value should be 0, while on others,
+	//	the value should be 6.
+	//
+	regmap_write(rpc->regmap, RPC_PHYCNT, RPC_PHYCNT_CAL |
+				  RPC_PHYCNT_STRTIM(6) | 0x260);
+
+	//
+	// NOTE: The 0x1511144 are undocumented bits, but they must be set
+	//       for RPC_PHYOFFSET1.
+	//	 The 0x31 are undocumented bits, but they must be set
+	//	 for RPC_PHYOFFSET2.
+	//

drivers/spi/spi-renesas-rpc.c line 206

Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10 -0
+	regmap_write(rpc->regmap, RPC_PHYOFFSET1, RPC_PHYOFFSET1_DDRTMG(3) |
+		     0x1511144);
+	regmap_write(rpc->regmap, RPC_PHYOFFSET2, 0x31 |
+		     RPC_PHYOFFSET2_OCTTMG(4));
+	regmap_write(rpc->regmap, RPC_SSLDR, RPC_SSLDR_SPNDL(7) |
+		     RPC_SSLDR_SLNDL(7) | RPC_SSLDR_SCKDL(7));
+	regmap_write(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD | RPC_CMNCR_SFDE |
+		     RPC_CMNCR_MOIIO_HIZ | RPC_CMNCR_IOFV_HIZ |
+		     RPC_CMNCR_BSZ(0));
+}

We clearly need runtime PM get/put() calls around this code. Otherwise,
we're dependant on U-Boot leaving the clocks enabled...

[...]

MBR, Sergei

#12 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Hi Sergei,

Quoted 37 lines · Sergei Shtylyov
Quoted 4 lines · Mason Yang

Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.

[...]

Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +0 -0
new file mode 100644
index 0000000..ea12017
@@ -0,0 +1,804 @@

[...]

Quoted 24 lines
drivers/spi/spi-renesas-rpc.c new file +24 -0
+static void rpc_spi_hw_init(struct rpc_spi *rpc)
+{
+     //
+     // NOTE: The 0x260 are undocumented bits, but they must be set.
+     //      RPC_PHYCNT_STRTIM is strobe timing adjustment bit,
+     //      0x0 : the delay is biggest,
+     //      0x1 : the delay is 2nd biggest,
+     //      On H3 ES1.x, the value should be 0, while on others,
+     //      the value should be 6.
+     //
+     regmap_write(rpc->regmap, RPC_PHYCNT, RPC_PHYCNT_CAL |
+                               RPC_PHYCNT_STRTIM(6) | 0x260);
+
+     //
+     // NOTE: The 0x1511144 are undocumented bits, but they must be set
+     //       for RPC_PHYOFFSET1.
+     //       The 0x31 are undocumented bits, but they must be set
+     //       for RPC_PHYOFFSET2.
+     //
+     regmap_write(rpc->regmap, RPC_PHYOFFSET1, RPC_PHYOFFSET1_DDRTMG(3) |
+                  0x1511144);
+     regmap_write(rpc->regmap, RPC_PHYOFFSET2, 0x31 |
+                  RPC_PHYOFFSET2_OCTTMG(4));
+     regmap_write(rpc->regmap, RPC_SSLDR, RPC_SSLDR_SPNDL(7) |
Quoted 8 lines

drivers/spi/spi-renesas-rpc.c line 206

Quoted 5 lines
drivers/spi/spi-renesas-rpc.c new file +5 -0
+                  RPC_SSLDR_SLNDL(7) | RPC_SSLDR_SCKDL(7));
+     regmap_write(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD | RPC_CMNCR_SFDE |
+                  RPC_CMNCR_MOIIO_HIZ | RPC_CMNCR_IOFV_HIZ |
+                  RPC_CMNCR_BSZ(0));
+}

We clearly need runtime PM get/put() calls around this code. Otherwise,
we're dependant on U-Boot leaving the clocks enabled...

Even that would be futile, as the common clock framework disables all unused clocks at late boot time.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
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
#13 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Hello!

Quoted 45 lines · Geert Uytterhoeven
Quoted 36 lines
Quoted 4 lines

Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.

[...]

Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +0 -0
new file mode 100644
index 0000000..ea12017
@@ -0,0 +1,804 @@

[...]

Quoted 24 lines
drivers/spi/spi-renesas-rpc.c new file +24 -0
+static void rpc_spi_hw_init(struct rpc_spi *rpc)
+{
+     //
+     // NOTE: The 0x260 are undocumented bits, but they must be set.
+     //      RPC_PHYCNT_STRTIM is strobe timing adjustment bit,
+     //      0x0 : the delay is biggest,
+     //      0x1 : the delay is 2nd biggest,
+     //      On H3 ES1.x, the value should be 0, while on others,
+     //      the value should be 6.
+     //
+     regmap_write(rpc->regmap, RPC_PHYCNT, RPC_PHYCNT_CAL |
+                               RPC_PHYCNT_STRTIM(6) | 0x260);
+
+     //
+     // NOTE: The 0x1511144 are undocumented bits, but they must be set
+     //       for RPC_PHYOFFSET1.
+     //       The 0x31 are undocumented bits, but they must be set
+     //       for RPC_PHYOFFSET2.
+     //
+     regmap_write(rpc->regmap, RPC_PHYOFFSET1, RPC_PHYOFFSET1_DDRTMG(3) |
+                  0x1511144);
+     regmap_write(rpc->regmap, RPC_PHYOFFSET2, 0x31 |
+                  RPC_PHYOFFSET2_OCTTMG(4));
+     regmap_write(rpc->regmap, RPC_SSLDR, RPC_SSLDR_SPNDL(7) |
Quoted 8 lines

drivers/spi/spi-renesas-rpc.c line 206

Quoted 5 lines
drivers/spi/spi-renesas-rpc.c new file +5 -0
+                  RPC_SSLDR_SLNDL(7) | RPC_SSLDR_SCKDL(7));
+     regmap_write(rpc->regmap, RPC_CMNCR, RPC_CMNCR_MD | RPC_CMNCR_SFDE |
+                  RPC_CMNCR_MOIIO_HIZ | RPC_CMNCR_IOFV_HIZ |
+                  RPC_CMNCR_BSZ(0));
+}

We clearly need runtime PM get/put() calls around this code. Otherwise,
we're dependant on U-Boot leaving the clocks enabled...

Quoted 2 lines

Even that would be futile, as the common clock framework disables all unused clocks at late boot time.

This code is executed during the probing time and it indeed works. The clocks seem
to be disabled somewhat later...

Quoted 3 lines

Gr{oetje,eeting}s,

Geert

MBR, Sergei

#14 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

In reply to Mason Yang

Hello!

Quoted 4 lines · Mason Yang

Add a driver for Renesas R-Car Gen3 RPC-IF SPI controller.

I've just found an error due to which my flash couldn't be read.

[...]

Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +0 -0
new file mode 100644
index 0000000..ea12017
@@ -0,0 +1,804 @@

[...]

drivers/spi/spi-renesas-rpc.c line 345

Quoted 9 lines
drivers/spi/spi-renesas-rpc.c new file +8 -0
+static void rpc_spi_mem_set_prep_op_cfg(struct spi_device *spi,
+					const struct spi_mem_op *op,
+					u64 *offs, size_t *len)
+{
+	struct rpc_spi *rpc = spi_controller_get_devdata(spi->controller);
 
+	if (op->dummy.nbytes) {
+		rpc->smenr |= RPC_SMENR_DME;
+		rpc->dummy = RPC_SMDMCR_DMCYC(op->dummy.nbytes);

SMDMCR.DMCYC is in bits -- you forgot to multiply by 8.

Quoted 7 lines
drivers/spi/spi-renesas-rpc.c new file +7 -0
+		rpc->totalxferlen += op->dummy.nbytes;
+	}[...]
+static void rpc_spi_transfer_setup(struct rpc_spi *rpc,
+				   struct spi_message *msg)
+{
+	struct spi_transfer *t, xfer[4] = { };
+	u32 i, xfercnt, xferpos = 0;

[...]

drivers/spi/spi-renesas-rpc.c line 587

Quoted 3 lines
drivers/spi/spi-renesas-rpc.c new file +3 -0
+	if (xfercnt > 3 && xfer[2].len && xfer[2].tx_buf) {
+		rpc->smenr |= RPC_SMENR_DME;
+		rpc->dummy = RPC_SMDMCR_DMCYC(xfer[2].len);

Here as well, I guess.

[...]

MBR, Sergei

A message that is not in the archive (sent off-list or not yet received): OF7C1EB3FC.1ABCD2C2-ON482583C8.002D7A69-482583C8.002E899C@mxic.com.tw

#16 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Hello!

Quoted 10 lines · On 03/25/2019 11:28 AM, [email protected] wrote:
Quoted 10 lines
Quoted 9 lines
drivers/spi/spi-renesas-rpc.c new file +8 -0
+static void rpc_spi_mem_set_prep_op_cfg(struct spi_device *spi,
+               const struct spi_mem_op *op,
+               u64 *offs, size_t *len)
+{
+   struct rpc_spi *rpc = spi_controller_get_devdata(spi->controller);
 
+   if (op->dummy.nbytes) {
+      rpc->smenr |= RPC_SMENR_DME;
+      rpc->dummy = RPC_SMDMCR_DMCYC(op->dummy.nbytes);
Quoted 5 lines
Quoted 1 line

SMDMCR.DMCYC is in bits -- you forgot to multiply by 8.

?

It's dummy cycles setting, i.e,. 0 is 1 cycle dummy and

Yeah, I should've written "cycles", sorry about that.

Quoted 2 lines

max is 0x13 for 20 cycle dummy, depends on transfer bit size setting = 1, 4 or 8. right ?

Probably...

[...]

MBR, Sergei

#17 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Quoted 10 lines · Sergei Shtylyov
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
drivers/spi/spi-renesas-rpc.c new file +8 -0
+static void rpc_spi_mem_set_prep_op_cfg(struct spi_device *spi,
+               const struct spi_mem_op *op,
+               u64 *offs, size_t *len)
+{
+   struct rpc_spi *rpc = spi_controller_get_devdata(spi->controller);
 
+   if (op->dummy.nbytes) {
+      rpc->smenr |= RPC_SMENR_DME;
+      rpc->dummy = RPC_SMDMCR_DMCYC(op->dummy.nbytes);
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

SMDMCR.DMCYC is in bits -- you forgot to multiply by 8.

?

It's dummy cycles setting, i.e,. 0 is 1 cycle dummy and

Yeah, I should've written "cycles", sorry about that.

I also should've mentioned that w/o this change the "read SFDP" command
returns garbage and the flash doesn't work.

[...]

MBR, Sergei

A message that is not in the archive (sent off-list or not yet received): OF5BDFBDAB.B66A1ADE-ON482583CA.0006C5C2-482583CA.0008788E@mxic.com.tw

#19 lore raw

Re: [PATCH v8 1/2] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver

Hello!

Quoted 16 lines · On 03/27/2019 04:32 AM, [email protected] wrote:
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 11 lines

drivers/spi/spi-renesas-rpc.c line 345

Quoted 9 lines
drivers/spi/spi-renesas-rpc.c new file +8 -0
+static void rpc_spi_mem_set_prep_op_cfg(struct spi_device *spi,
+               const struct spi_mem_op *op,
+               u64 *offs, size_t *len)
+{
+   struct rpc_spi *rpc = spi_controller_get_devdata(spi->controller);
 
+   if (op->dummy.nbytes) {
+      rpc->smenr |= RPC_SMENR_DME;
+      rpc->dummy = RPC_SMDMCR_DMCYC(op->dummy.nbytes);

SMDMCR.DMCYC is in bits -- you forgot to multiply by 8.

?

It's dummy cycles setting, i.e,. 0 is 1 cycle dummy and

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Yeah, I should've written "cycles", sorry about that.

I also should've mentioned that w/o this change the "read SFDP" command
returns garbage and the flash doesn't work.

Have you checked the dummy cycles setting with logical analysis ?

I don't have a logic analyzer (if you meant it). However, I dumped all the registers
in your driver and Cogent's own driver, and SMDMCR was set to 0 in your driver and to 7 in our driver -- and only our driver then worked correctly.

Quoted 3 lines

As datasheet mentioned it's dummy cycles depends on the transfer bit size setting = 1, 4 or 8. Setting RPC_SMDMCR_DMCYC(0x13) in 8 bits data width I got a 20 dummy cycles. Also confirmed these 20 dummy cycles by logical analysis equipment.

[...]

Quoted 2 lines

best regards,
Mason

MBR, Sergei

author
#20 lore raw

PATCH v8 2/2 dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF controller bindings

In reply to Mason Yang

Document the bindings used by the Renesas R-Car Gen3 RPC-IF controller.

---
 .../devicetree/bindings/spi/spi-renesas-rpc.txt    | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +40 -0
new file mode 100644
index 0000000..7dff7e7
@@ -0,0 +1,40 @@
+Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings
+--------------------------------------------------------------------
+
+Required properties:
+- compatible: should be an SoC-specific compatible value, followed by
+		"renesas,rcar-gen3-rpc" as a fallback.
+		supported SoC-specific values are:
+		"renesas,r8a77995-rpc"	(R-Car D3)
+- reg: should contain three register areas:
+	first for the base address of rpc-if registers,
+	second for the direct mapping read mode and
+	third for the write buffer area.
+- reg-names: should contain "regs", "dirmap" and "wbuf"
+- clocks: should contain 1 entries for the module's clock
+- clock-names: should contain "rpc"
+- #address-cells: should be 1
+- #size-cells: should be 0
+
+Example:
+
+	rpc: rpc@ee200000 {
+		compatible = "renesas,r8a77995-rpc", "renesas,rcar-gen3-rpc";
+		reg = <0 0xee200000 0 0x200>, <0 0x08000000 0 0x4000000>,
+		      <0 0xee208000 0 0x100>;
+		reg-names = "regs", "dirmap", "wbuf";
+		clocks = <&cpg CPG_MOD 917>;
+		clock-names = "rpc";
+		power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+		resets = <&cpg 917>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		flash@0 {
+			compatible = "jedec,spi-nor";
+			reg = <0>;
+			spi-max-frequency = <40000000>;
+			spi-tx-bus-width = <1>;
+			spi-rx-bus-width = <1>;
+		};
+	};
Signature · 1 line
1.9.1
maintainer
#21 lore raw

Applied "dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF controller bindings" to the spi tree

The patch

dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF controller bindings

has been applied to the spi tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 06938aef3e9f33760ea384dc74c0f16d6b98b5a0 Mon Sep 17 00:00:00 2001

From: Mason Yang <[email protected]>
Date: Mon, 28 Jan 2019 14:49:18 +0800
Subject: [PATCH] dt-bindings: spi: Document Renesas R-Car Gen3 RPC-IF
controller bindings

Document the bindings used by the Renesas R-Car Gen3 RPC-IF controller.

---
 .../bindings/spi/spi-renesas-rpc.txt          | 40 +++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt
Documentation/devicetree/bindings/spi/spi-renesas-rpc.txt new file +40 -0
new file mode 100644
index 000000000000..7dff7e7bea97
@@ -0,0 +1,40 @@
+Renesas R-Car Gen3 RPC-IF controller Device Tree Bindings
+--------------------------------------------------------------------
+
+Required properties:
+- compatible: should be an SoC-specific compatible value, followed by
+		"renesas,rcar-gen3-rpc" as a fallback.
+		supported SoC-specific values are:
+		"renesas,r8a77995-rpc"	(R-Car D3)
+- reg: should contain three register areas:
+	first for the base address of rpc-if registers,
+	second for the direct mapping read mode and
+	third for the write buffer area.
+- reg-names: should contain "regs", "dirmap" and "wbuf"
+- clocks: should contain 1 entries for the module's clock
+- clock-names: should contain "rpc"
+- #address-cells: should be 1
+- #size-cells: should be 0
+
+Example:
+
+	rpc: rpc@ee200000 {
+		compatible = "renesas,r8a77995-rpc", "renesas,rcar-gen3-rpc";
+		reg = <0 0xee200000 0 0x200>, <0 0x08000000 0 0x4000000>,
+		      <0 0xee208000 0 0x100>;
+		reg-names = "regs", "dirmap", "wbuf";
+		clocks = <&cpg CPG_MOD 917>;
+		clock-names = "rpc";
+		power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+		resets = <&cpg 917>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		flash@0 {
+			compatible = "jedec,spi-nor";
+			reg = <0>;
+			spi-max-frequency = <40000000>;
+			spi-tx-bus-width = <1>;
+			spi-rx-bus-width = <1>;
+		};
+	};
Signature · 1 line
2.20.1