Skip to contentSkip to conversation

mfd: Add Renesas R-Car Gen3 RPC-IF MFD & SPI driver

PATCH Superseded Mason Yang 2 participants 9 messages Apr 22, 2019 – Apr 23, 2019

Subsystems (3)

v11 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

Mason Yang

author
#0 lore raw

v11 cover mfd: Add Renesas R-Car Gen3 RPC-IF MFD & SPI driver

Hi,

v11 patch including:
1) Patch mfd include header file.
2) mfd coding style.
3) add back wbuf description in dts.

v10 patch including:
1) Address range for > 64M byte flash.
2) Removed dirmap_write due to WBUF 256 bytes transfer issue.
3) Dummy bytes setting according to spi-nor.c layer.

v9 patch is for RPC MFD driver and RPC SPI driver.

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 (3):
mfd: Add Renesas R-Car Gen3 RPC-IF MFD driver
spi: Add Renesas R-Car Gen3 RPC-IF SPI controller driver
dt-bindings: mfd: Document Renesas R-Car Gen3 RPC-IF MFD bindings

 .../devicetree/bindings/mfd/mfd-renesas-rpc.txt    |  39 ++
 drivers/mfd/Kconfig                                |   9 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/renesas-rpc.c                          | 125 +++++
 drivers/spi/Kconfig                                |   6 +
 drivers/spi/Makefile                               |   1 +
 drivers/spi/spi-renesas-rpc.c                      | 571 +++++++++++++++++++++
 include/linux/mfd/renesas-rpc.h                    | 141 +++++
 8 files changed, 893 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt
 create mode 100644 drivers/mfd/renesas-rpc.c
 create mode 100644 drivers/spi/spi-renesas-rpc.c
 create mode 100644 include/linux/mfd/renesas-rpc.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v11 1/3 mfd: Add Renesas R-Car Gen3 RPC-IF MFD driver

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

---
 drivers/mfd/Kconfig             |   9 +++
 drivers/mfd/Makefile            |   1 +
 drivers/mfd/renesas-rpc.c       | 125 +++++++++++++++++++++++++++++++++++
 include/linux/mfd/renesas-rpc.h | 141 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 276 insertions(+)
 create mode 100644 drivers/mfd/renesas-rpc.c
 create mode 100644 include/linux/mfd/renesas-rpc.h
drivers/mfd/Kconfig +9 -0
index 26ad646..efdb1b9 100644
@@ -978,6 +978,15 @@ config MFD_RDC321X
 	  southbridge which provides access to GPIOs and Watchdog using the
 	  southbridge PCI device configuration space.
 
+config MFD_RENESAS_RPC
+	tristate "Renesas R-Car Gen3 RPC-IF MFD driver"
+	select MFD_CORE
+	depends on ARCH_RENESAS
+	help
+	  This supports Renesas R-Car Gen3 RPC-IF multifunction device
+	  which provides either SPI host or HyperFlash.
+	  You have to select individual components under the corresponding menu.
+
 config MFD_RT5033
 	tristate "Richtek RT5033 Power Management IC"
 	depends on I2C
drivers/mfd/Makefile +1 -0
index b4569ed7..4a49699 100644
@@ -183,6 +183,7 @@ obj-$(CONFIG_MFD_INTEL_QUARK_I2C_GPIO)	+= intel_quark_i2c_gpio.o
 obj-$(CONFIG_LPC_SCH)		+= lpc_sch.o
 obj-$(CONFIG_LPC_ICH)		+= lpc_ich.o
 obj-$(CONFIG_MFD_RDC321X)	+= rdc321x-southbridge.o
+obj-$(CONFIG_MFD_RENESAS_RPC)	+= renesas-rpc.o
 obj-$(CONFIG_MFD_JANZ_CMODIO)	+= janz-cmodio.o
 obj-$(CONFIG_MFD_JZ4740_ADC)	+= jz4740-adc.o
 obj-$(CONFIG_MFD_TPS6586X)	+= tps6586x.o
drivers/mfd/renesas-rpc.c new file +125 -0

125 lines not on this page · raw message

include/linux/mfd/renesas-rpc.h new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
1.9.1
author
#2 lore raw

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

In reply to Mason Yang

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 | 571 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 578 insertions(+)
 create mode 100644 drivers/spi/spi-renesas-rpc.c
drivers/spi/Kconfig +6 -0
index f761655..1f52bcf 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 d8fc03c..b3a3deb 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 +571 -0

571 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

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

Quoted 4 lines · Mason Yang

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

[...]

Do dote that I'm opposed to the driver separation as it's presented in
this patches, and I have a large patch reworking both MFD and SPI drivers in the works.

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

[...]

Quoted 29 lines
drivers/spi/spi-renesas-rpc.c new file +29 -0
+static int rpc_spi_probe(struct platform_device *pdev)
+{
+	struct spi_controller *ctlr;
+	struct rpc_mfd *rpc_mfd = dev_get_drvdata(pdev->dev.parent);
+	struct rpc_spi *rpc;
+	int ret;
+
+	ctlr = spi_alloc_master(&pdev->dev, sizeof(*rpc));
+	if (!ctlr)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, ctlr);
+
+	rpc = spi_controller_get_devdata(ctlr);
+
+	rpc->mfd = rpc_mfd;
+	ctlr->dev.of_node = pdev->dev.parent->of_node;
+
+	pm_runtime_enable(&pdev->dev);
+	ctlr->auto_runtime_pm = true;
+
+	ctlr->num_chipselect = 1;
+	ctlr->mem_ops = &rpc_spi_mem_ops;
+	ctlr->transfer_one_message = rpc_spi_transfer_one_message;
+
+	ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
+	ctlr->mode_bits = SPI_CPOL | SPI_CPHA | SPI_TX_QUAD | SPI_RX_QUAD;
+
+	pm_runtime_get_sync(&pdev->dev);

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

Quoted 10 lines
drivers/spi/spi-renesas-rpc.c new file +10 -0
+	rpc_spi_hw_init(rpc);
+	pm_runtime_put(&pdev->dev);
+
+	ret = spi_register_controller(ctlr);
+	if (ret) {
+		dev_err(&pdev->dev, "spi_register_controller failed\n");
+		goto err_put_ctlr;
+	}
+
+	return 0;

Previous formatting was better, shouldn't have moved the empty line above
*return*...

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

Quoted 6 lines
drivers/spi/spi-renesas-rpc.c new file +6 -0
+err_put_ctlr:
+	spi_controller_put(ctlr);
+	pm_runtime_disable(&pdev->dev);
+
+	return ret;
+}

[...]

MBR, Sergei

#4 lore raw

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

Quoted 7 lines · Sergei Shtylyov
Quoted 4 lines

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

[...]

Do dote that I'm opposed to the driver separation as it's presented in

Sorry, s/dote/note/.

Quoted 2 lines

this patches, and I have a large patch reworking both MFD and SPI drivers in the works.

[...]

MBR, Sergei

#5 lore raw

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

In reply to Sergei Shtylyov

Hello,

Quoted 3 lines

Subject

Re: [PATCH v11 2/3] spi: Add Renesas R-Car Gen3 RPC-IF SPI controller

driver

Quoted 11 lines · Mason Yang
Quoted 5 lines

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

[...]

Do dote that I'm opposed to the driver separation as it's presented in
this patches, and I have a large patch reworking both MFD and SPI

drivers

Quoted 2 lines

in the works.

Do you mean add your name in both MFD & dt-binding ?

i.e.,
[PATCH v12 3/3] dt-bindings: mfd: Document Renesas R-Car Gen3 RPC-IF MFD bindings

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

[PATCH v12 1/3] mfd: Add Renesas R-Car Gen3 RPC-IF MFD driver

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

Is it ok ?

best regards,
Mason

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================

============================================================================

CONFIDENTIALITY NOTE:

This e-mail and any attachments may contain confidential information and/or personal data, which is protected by applicable laws. Please be reminded that duplication, disclosure, distribution, or use of this e-mail (and/or its attachments) or any part thereof is prohibited. If you receive this e-mail in error, please notify us immediately and delete this mail as well as its attachment(s) from your system. In addition, please be informed that collection, processing, and/or use of personal data is prohibited unless expressly permitted by personal data protection laws. Thank you for your attention and cooperation.

Macronix International Co., Ltd.

=====================================================================

#6 lore raw

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

Quoted 4 lines · On 04/23/2019 12:22 PM, [email protected] wrote:
Quoted 4 lines
Quoted 4 lines

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

Quoted 8 lines
Quoted 6 lines

[...]

Do dote that I'm opposed to the driver separation as it's presented in
this patches, and I have a large patch reworking both MFD and SPI drivers in the works.

Do you mean add your name in both MFD & dt-binding ?

Of course not!

Quoted 12 lines

i.e.,
[PATCH v12 3/3] dt-bindings: mfd: Document Renesas R-Car Gen3 RPC-IF MFD bindings

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

[PATCH v12 1/3] mfd: Add Renesas R-Car Gen3 RPC-IF MFD driver

Quoted 7 lines

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

Is it ok ?

I'm not OK with the most of the driver code ending up in the SPI driver,
I think most of the code should be kept in the MFD driver and just be called by SPI/HF drivers.

Quoted 2 lines

best regards,
Mason

MBR, Sergei

author
#7 lore raw

PATCH v11 3/3 dt-bindings: mfd: Document Renesas R-Car Gen3 RPC-IF MFD bindings

In reply to Mason Yang

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

---
 .../devicetree/bindings/mfd/mfd-renesas-rpc.txt    | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +39 -0
new file mode 100644
index 0000000..ee3bad8
@@ -0,0 +1,39 @@
+Renesas R-Car Gen3 RPC-IF MFD 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-if@ee200000 {
+		compatible = "renesas,r8a77995-rpc", "renesas,rcar-gen3-rpc";
+		reg = <0 0xee200000 0 0x200>, <0 0x08000000 0 0x4000000>;
+		reg-names = "regs", "dirmap";
+		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
#8 lore raw

Re: [PATCH v11 3/3] dt-bindings: mfd: Document Renesas R-Car Gen3 RPC-IF MFD bindings

Hello!

Quoted 14 lines · Mason Yang

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

---
 .../devicetree/bindings/mfd/mfd-renesas-rpc.txt    | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +0 -0
new file mode 100644
index 0000000..ee3bad8

Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +10 -0
@@ -0,0 +1,39 @@
+Renesas R-Car Gen3 RPC-IF MFD 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,

RPC-IF.

Quoted 4 lines
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +4 -0
+	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

Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt line 24

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +10 -0
+- clock-names: should contain "rpc"
+- #address-cells: should be 1
+- #size-cells: should be 0
+
+Example:
+
+	rpc: rpc-if@ee200000 {
+		compatible = "renesas,r8a77995-rpc", "renesas,rcar-gen3-rpc";
+		reg = <0 0xee200000 0 0x200>, <0 0x08000000 0 0x4000000>;
+		reg-names = "regs", "dirmap";

You forgot to add back the "wbuf" entrees above.

Quoted 6 lines
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +5 -0
+		clocks = <&cpg CPG_MOD 917>;
+		clock-names = "rpc";
+		power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+		resets = <&cpg 917>;
+		#address-cells = <1>;

Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mfd-renesas-rpc.txt new file +10 -0
+		#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>;
+		};
+	};

MBR, Sergei