Skip to contentSkip to conversation

Add Rockchip SFC(serial flash controller) support

PATCH Superseded Chris Morgan 4 participants 8 messages Jun 1, 2021 – Jun 2, 2021

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add Rockchip SFC(serial flash controller) support

From: Chris Morgan <[email protected]>

I'm trying to revive an abandoned patch series for the Rockchip serial flash controller (SFC) found on the Rockchip PX30 SOC, as well as other SOCs by Rockchip. I'm picking this up from version 8 of the patch series located from here:

http://patchwork.ozlabs.org/project/linux-mtd/cover/[email protected]/

Changes made in v3:
- Changed the name of the clocks to sfc/ahb (from clk-sfc/clk-hsfc).
- Changed the compatible string from rockchip,sfc to rockchip,rk3036-sfc. A quick glance at the datasheets suggests this driver should work for the PX30, RK180x, RK3036, RK312x, RK3308 and RV1108 SoCs, and possibly more. However, I am currently only able to test this on a PX30 (an RK3326). The technical reference manuals appear to list the same registers for each device.
- Corrected devicetree documentation for formatting and to note these changes.
- Replaced the maintainer with Heiko Stuebner and myself, as we will take ownership of this going forward.
- Noted that the device (per the reference manual) supports 4 CS, but I am only able to test a single CS (CS 0).
- Reordered patches to comply with upstream rules.

Changes made in v2:
- Reimplemented driver using spi-mem subsystem.
- Removed power management code as I couldn't get it working properly.
- Added device tree bindings for Odroid Go Advance.

Changes made in this new series versus the v8 of the old series:
- Added function to read spi-rx-bus-width from device tree, in the event that the SPI chip supports 4x mode but only has 2 pins wired (such as the Odroid Go Advance).
- Changed device tree documentation from txt to yaml format.
- Made "reset" message a dev_dbg from a dev_info.
- Changed read and write fifo functions to remove redundant checks.
- Changed the write and read from relaxed to non-relaxed when starting the DMA transfer or reading the DMA IRQ.
- Changed from dma_coerce_mask_and_coherent to just dma_set_mask_and_coherent.
- Changed name of get_if_type to rockchip_sfc_get_if_type.

Chris Morgan (4):
dt-bindings: rockchip-sfc: Bindings for Rockchip serial flash
controller
spi: rockchip-sfc: add rockchip serial flash controller driver
arm64: dts: rockchip: Add SFC to PX30
arm64: dts: rockchip: Enable SFC for Odroid Go Advance

 .../devicetree/bindings/spi/rockchip,sfc.yaml |  87 ++
 arch/arm64/boot/dts/rockchip/px30.dtsi        |  38 +
 .../boot/dts/rockchip/rk3326-odroid-go2.dts   |  16 +
 drivers/spi/Kconfig                           |   9 +
 drivers/spi/Makefile                          |   1 +
 drivers/spi/spi-rockchip-sfc.c                | 861 ++++++++++++++++++
 6 files changed, 1012 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/rockchip,sfc.yaml
 create mode 100644 drivers/spi/spi-rockchip-sfc.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/4 dt-bindings: rockchip-sfc: Bindings for Rockchip serial flash controller

From: Chris Morgan <[email protected]>

Add bindings for the Rockchip serial flash controller. New device specific parameter of rockchip,sfc-no-dma included in documentation.

---
 .../devicetree/bindings/spi/rockchip,sfc.yaml | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/rockchip,sfc.yaml
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +87 -0
new file mode 100644
index 000000000000..d5f8edd621ae
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/rockchip,sfc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip Serial Flash Controller (SFC)
+
+maintainers:
+  - Heiko Stuebner <[email protected]>
+  - Chris Morgan <[email protected]>
+
+allOf:
+  - $ref: spi-controller.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: rockchip,px30-sfc
+      - const: rockchip,rk1806-sfc
+      - const: rockchip,rk1808-sfc
+      - const: rockchip,rk312x-sfc
+      - const: rockchip,rk3308-sfc
+      - const: rockchip,rv1108-sfc
+      - items:
+          - const: rockchip,rk3036-sfc
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus Clock
+      - description: Module Clock
+
+  clock-names:
+    items:
+      - const: ahb
+      - const: sfc
+
+  power-domains:
+    maxItems: 1
+
+  rockchip,sfc-no-dma:
+    vendor,bool-property:
+      descrption: Boolean value for disabling DMA
+      type: boolean
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/px30-cru.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+    sfc: spi@ff3a0000 {
+        compatible = "rockchip,px30-sfc","rockchip,rk3036-sfc";
+        reg = <0x0 0xff3a0000 0x0 0x4000>;
+        interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&cru SCLK_SFC>, <&cru HCLK_SFC>;
+        clock-names = "sfc", "ahb";
+        pinctrl-0 = <&sfc_clk &sfc_cs &sfc_bus2>;
+        pinctrl-names = "default";
+        power-domains = <&power PX30_PD_MMC_NAND>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        flash@0 {
+            compatible = "jedec,spi-nor";
+            spi-max-frequency = <108000000>;
+            reg = <0>;
+            spi-rx-bus-width = <2>;
+            spi-tx-bus-width = <2>;
+        };
+    };
+
+...
Signature · 1 line
2.25.1
#4 lore raw

PATCH v3 2/4 spi: rockchip-sfc: add rockchip serial flash controller driver

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add the rockchip serial flash controller (SFC) driver.

---
 drivers/spi/Kconfig            |   9 +
 drivers/spi/Makefile           |   1 +
 drivers/spi/spi-rockchip-sfc.c | 861 +++++++++++++++++++++++++++++++++
 3 files changed, 871 insertions(+)
 create mode 100644 drivers/spi/spi-rockchip-sfc.c
drivers/spi/Kconfig +9 -0
index f4481fe48bf0..4d81ba7841e2 100644
@@ -658,6 +658,15 @@ config SPI_ROCKCHIP
 	  The main usecase of this controller is to use spi flash as boot
 	  device.
 
+config SPI_ROCKCHIP_SFC
+	tristate "Rockchip Serial Flash Controller (SFC)"
+	depends on ARCH_ROCKCHIP || COMPILE_TEST
+	depends on HAS_IOMEM && HAS_DMA
+	help
+	  This enables support for Rockchip serial flash controller. This
+	  is a specialized controller used to access SPI flash on some
+	  Rockchip SOCs.
+
 config SPI_RB4XX
 	tristate "Mikrotik RB4XX SPI master"
 	depends on SPI_MASTER && ATH79
drivers/spi/Makefile +1 -0
index 13e54c45e9df..699db95c8441 100644
@@ -95,6 +95,7 @@ obj-$(CONFIG_SPI_QCOM_GENI)		+= spi-geni-qcom.o
 obj-$(CONFIG_SPI_QCOM_QSPI)		+= spi-qcom-qspi.o
 obj-$(CONFIG_SPI_QUP)			+= spi-qup.o
 obj-$(CONFIG_SPI_ROCKCHIP)		+= spi-rockchip.o
+obj-$(CONFIG_SPI_ROCKCHIP_SFC)		+= spi-rockchip-sfc.o
 obj-$(CONFIG_SPI_RB4XX)			+= spi-rb4xx.o
 obj-$(CONFIG_MACH_REALTEK_RTL)		+= spi-realtek-rtl.o
 obj-$(CONFIG_SPI_RPCIF)			+= spi-rpc-if.o
drivers/spi/spi-rockchip-sfc.c new file +861 -0

861 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

PATCH v3 3/4 arm64: dts: rockchip: Add SFC to PX30

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add a devicetree entry for the Rockchip SFC for the PX30 SOC.

---
 arch/arm64/boot/dts/rockchip/px30.dtsi | 38 ++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
arch/arm64/boot/dts/rockchip/px30.dtsi +38 -0
index 09baa8a167ce..1f4feb53e270 100644
@@ -966,6 +966,18 @@ emmc: mmc@ff390000 {
 		status = "disabled";
 	};
 
+	sfc: spi@ff3a0000 {
+		compatible = "rockchip,px30-sfc","rockchip,rk3036-sfc";
+		reg = <0x0 0xff3a0000 0x0 0x4000>;
+		interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&cru SCLK_SFC>, <&cru HCLK_SFC>;
+		clock-names = "sfc", "ahb";
+		pinctrl-0 = <&sfc_clk &sfc_cs &sfc_bus4>;
+		pinctrl-names = "default";
+		power-domains = <&power PX30_PD_MMC_NAND>;
+		status = "disabled";
+	};
+
 	nfc: nand-controller@ff3b0000 {
 		compatible = "rockchip,px30-nfc";
 		reg = <0x0 0xff3b0000 0x0 0x4000>;
@@ -1967,6 +1979,32 @@ flash_bus8: flash-bus8 {
 			};
 		};
 
+		serial_flash {
+			sfc_bus4: sfc-bus4 {
+				rockchip,pins =
+					<1 RK_PA0 3 &pcfg_pull_none>,
+					<1 RK_PA1 3 &pcfg_pull_none>,
+					<1 RK_PA2 3 &pcfg_pull_none>,
+					<1 RK_PA3 3 &pcfg_pull_none>;
+			};
+
+			sfc_bus2: sfc-bus2 {
+				rockchip,pins =
+					<1 RK_PA0 3 &pcfg_pull_none>,
+					<1 RK_PA1 3 &pcfg_pull_none>;
+			};
+
+			sfc_cs: sfc-cs {
+				rockchip,pins =
+					<1 RK_PA4 3 &pcfg_pull_none>;
+			};
+
+			sfc_clk: sfc-clk {
+				rockchip,pins =
+					<1 RK_PB1 3 &pcfg_pull_none>;
+			};
+		};
+
 		lcdc {
 			lcdc_rgb_dclk_pin: lcdc-rgb-dclk-pin {
 				rockchip,pins =
Signature · 1 line
2.25.1
#7 lore raw

PATCH v4 4/4 arm64: dts: rockchip: Enable SFC for Odroid Go Advance

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

This enables the Rockchip Serial Flash Controller for the Odroid Go Advance. Note that while the attached SPI NOR flash and the controller both support quad read mode, only 2 of the required 4 pins are present. The rx and tx bus width is set to 2 for this reason.

---
 .../boot/dts/rockchip/rk3326-odroid-go2.dts      | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/rockchip/rk3326-odroid-go2.dts +16 -0
index 49c97f76df77..46f1d2f356cc 100644
@@ -484,6 +484,22 @@ &sdmmc {
 	status = "okay";
 };
 
+&sfc {
+	pinctrl-0 = <&sfc_clk &sfc_cs &sfc_bus2>;
+	pinctrl-names = "default";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	status = "okay";
+
+	flash@0 {
+		compatible = "jedec,spi-nor";
+		spi-max-frequency = <108000000>;
+		reg = <0>;
+		spi-rx-bus-width = <2>;
+		spi-tx-bus-width = <2>;
+	};
+};
+
 &tsadc {
 	status = "okay";
 };
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 1/4] dt-bindings: rockchip-sfc: Bindings for Rockchip serial flash controller

In reply to Chris Morgan

Hi Chris,

Some comments. Have a look if it's useful.

===
About the title:

dt-bindings: spi: add Rockchip Serial Flash Controller

Include a driver group name.
Start with a verb.
No need to mention "bindings" twice.

===

In order to get this patch reviewed by rob+dt you must include:
[email protected]

Check your review status here:
https://patchwork.ozlabs.org/project/devicetree-bindings/list/

Get the other lists and maintainers with:
./scripts/get_maintainer.pl --noroles --norolestats --nogit-fallback --nogit <patch1> <patch2>

===

Check document with:

make ARCH=arm dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/rockchip-sfc.yaml

make ARCH=arm dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/rockchip-sfc.yaml

make ARCH=arm64 dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/rockchip-sfc.yaml

Remove any errors before submitting.

===

In this serie you are introducing 4 new compatible strings, then also add 4 entries to dtsi files for the completeness.
Could you give us a complete package?

rockchip,px30-sfc
rockchip,rk3036-sfc
rockchip,rk3308-sfc
rockchip,rv1108-sfc

ARM: dts: rockchip: add sfc node for rv1108
Copy node from manufacturer tree in rv1108.dtsi

ARM: dts: rockchip: add sfc node for rk3036
https://github.com/rockchip-linux/kernel/commit/57bfc68e70cb58bd4786a6baff6315f252a19088

arm64: dts: rockchip: add sfc node for PX30

arm64: dts: rockchip: add sfc node for rk3308
https://github.com/rockchip-linux/kernel/commit/036e7e07a41c264a076c70ebf20cfeca031799a0

Fix there commit message and clock names.

===

Johan

Quoted 18 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add bindings for the Rockchip serial flash controller. New device specific parameter of rockchip,sfc-no-dma included in documentation.

---
 .../devicetree/bindings/spi/rockchip,sfc.yaml | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/rockchip,sfc.yaml
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +0 -0
new file mode 100644
index 000000000000..d5f8edd621ae

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 4

Quoted 4 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/rockchip,sfc.yaml#

rockchip-sfc.yaml

The comma is only used between <manufacturer>,<SoC name>-<function> I think. Ask a maintainer for exact name.

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 11

Quoted 8 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +7 -0
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rockchip Serial Flash Controller (SFC)
+
+maintainers:
 
+  - Heiko Stuebner <[email protected]>
+  - Chris Morgan <[email protected]>

sort
no hotmail because it screws the message-ID

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 18

Quoted 8 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +7 -0
+
+allOf:
+  - $ref: spi-controller.yaml#
+
+properties:
+  compatible:
 
+    oneOf:

This format is wrong. Use fall back strings.

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 22

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+      - const: rockchip,px30-sfc
 
+      - const: rockchip,rk1806-sfc
+      - const: rockchip,rk1808-sfc
+      - const: rockchip,rk312x-sfc

remove
I would advice against introducing compatible strings for boards that we don't have support for in mainline. Limit to things that we know what they look like.

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 26

Quoted 4 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+      - const: rockchip,rk3308-sfc
+      - const: rockchip,rv1108-sfc
+      - items:
+          - const: rockchip,rk3036-sfc

oneOf:
- const: rockchip,rk3036-sfc
- items:
- enum:
- rockchip,px30-sfc
- rockchip,rk3308-sfc
- rockchip,rv1108-sfc
- const: rockchip,rk3036-sfc

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 37

Quoted 12 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +11 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
 
+      - description: Bus Clock
+      - description: Module Clock

swap

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 42

Quoted 6 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +5 -0
+
+  clock-names:
+    items:
 
+      - const: ahb
+      - const: sfc

swap
You must keep them in the same order as in your example and in the dtsi files (both mainline as manufacturer tree).

Maybe use this:

- const: clk
- const: hclk

#define HCLK_SFC 257
#define SCLK_SFC 58

	COMPOSITE(SCLK_SFC, "clk_sfc", mux_gpll_cpll_p, 0,
			PX30_CLKSEL_CON(22), 7, 1, MFLAGS, 0, 7, DFLAGS,
			PX30_CLKGATE_CON(6), 7, GFLAGS),

	GATE(HCLK_SFC, "hclk_sfc", "hclk_mmc_nand", 0, PX30_CLKGATE_CON(6), 11,

GFLAGS),

===

From clk-rk3036.c:

	COMPOSITE(SCLK_SFC, "sclk_sfc", mux_pll_src_apll_dpll_gpll_usb480m_p, 0,
			RK2928_CLKSEL_CON(16), 0, 2, MFLAGS, 2, 5, DFLAGS,
			RK2928_CLKGATE_CON(10), 5, GFLAGS),


	GATE(0, "hclk_sfc", "hclk_peri", CLK_IGNORE_UNUSED,

RK2928_CLKGATE_CON(3), 14, GFLAGS),

The HCLK_SFC is missing and ignored in rk3036-cru.h and clk-rk3036.c Maybe this needs a fix?

#define HCLK_SFC 454

See:
clk: rockchip: rk3036: export the sfc clocks
https://github.com/rockchip-linux/kernel/commit/8373cf713ddd32037dc86462cac2d2d3cc859a99

Maybe add more patches to your serie? ;)

===

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 48

Quoted 7 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +6 -0
+
+  power-domains:
+    maxItems: 1
+
+  rockchip,sfc-no-dma:
 
+    vendor,bool-property:

remove
See example vendor,bool-property at:
Documentation/devicetree/bindings/example-schema.yaml

Quoted 1 line

+ descrption: Boolean value for disabling DMA

description:

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +5 -0
+      type: boolean
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +10 -0
+  - interrupts
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/px30-cru.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/power/px30-power.h>

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 74

Quoted 11 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +10 -0
+
+    sfc: spi@ff3a0000 {
+        compatible = "rockchip,px30-sfc","rockchip,rk3036-sfc";
+        reg = <0x0 0xff3a0000 0x0 0x4000>;
+        interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&cru SCLK_SFC>, <&cru HCLK_SFC>;
+        clock-names = "sfc", "ahb";
+        pinctrl-0 = <&sfc_clk &sfc_cs &sfc_bus2>;
+        pinctrl-names = "default";
 
+        power-domains = <&power PX30_PD_MMC_NAND>;

Add include for PX30_PD_MMC_NAND.

Check your example with scripts before you submit!

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 78

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+        #address-cells = <1>;
+        #size-cells = <0>;
+
 
+        flash@0 {

This controller handles only serial flash for now. So limit that with patternProperties.
Also users can't add more then 4 subnodes. That's where these documents are for, so add!

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 81

Quoted 3 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +2 -0
+            compatible = "jedec,spi-nor";
 
+            reg = <0>;
            spi-max-frequency = <108000000>;

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 83

Quoted 2 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +2 -0
+            spi-rx-bus-width = <2>;
+            spi-tx-bus-width = <2>;

The sort order is:
compatible
reg
interrupts
the rest in alphabetical order
(no status in YAML examples)

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+        };
+    };
+
+...
#3 lore raw

Re: [PATCH v3 1/4] dt-bindings: rockchip-sfc: Bindings for Rockchip serial flash controller

Quoted 4 lines · Johan Jonker

Hi Chris,

Some comments. Have a look if it's useful.

All comments are useful. Thank you for your input. :)

Quoted 14 lines

===
About the title:

dt-bindings: spi: add Rockchip Serial Flash Controller

Include a driver group name.
Start with a verb.
No need to mention "bindings" twice.

===

In order to get this patch reviewed by rob+dt you must include:
[email protected]

Quoted 6 lines

Check your review status here:
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.ozlabs.org%2Fproject%2Fdevicetree-bindings%2Flist%2F&amp;data=04%7C01%7C%7Cbadb9f60f0114af4d80308d9259e53f6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637582184210841031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=KhqRF2ly0Smf%2F1aE7yTrJ4FO5XPldagRW1gI8RF515E%3D&amp;reserved=0

Get the other lists and maintainers with:
./scripts/get_maintainer.pl --noroles --norolestats --nogit-fallback --nogit <patch1> <patch2>

Thank you, for now I've just been using the get_maintainer.pl and trying not to bother too many people. I'll do this though going forward.

Quoted 18 lines

===

Check document with:

make ARCH=arm dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/rockchip-sfc.yaml

make ARCH=arm dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/rockchip-sfc.yaml

make ARCH=arm64 dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/rockchip-sfc.yaml

Remove any errors before submitting.

===

Quoted 9 lines

In this serie you are introducing 4 new compatible strings, then also add 4 entries to dtsi files for the completeness.
Could you give us a complete package?

rockchip,px30-sfc
rockchip,rk3036-sfc
rockchip,rk3308-sfc
rockchip,rv1108-sfc

Excluding the px30 I will not be able to test these. Should I just update the compatible strings and clock names then?

Quoted 43 lines

ARM: dts: rockchip: add sfc node for rv1108
Copy node from manufacturer tree in rv1108.dtsi

ARM: dts: rockchip: add sfc node for rk3036
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frockchip-linux%2Fkernel%2Fcommit%2F57bfc68e70cb58bd4786a6baff6315f252a19088&amp;data=04%7C01%7C%7Cbadb9f60f0114af4d80308d9259e53f6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637582184210841031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=C5k6bCkt8qlzOquK9rECDN9fTK6HQDzxTR4Vp4othtA%3D&amp;reserved=0

arm64: dts: rockchip: add sfc node for PX30

arm64: dts: rockchip: add sfc node for rk3308
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frockchip-linux%2Fkernel%2Fcommit%2F036e7e07a41c264a076c70ebf20cfeca031799a0&amp;data=04%7C01%7C%7Cbadb9f60f0114af4d80308d9259e53f6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637582184210841031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NAdFO27S6zQdSjG%2FHMdZfe%2Bx9Nh9VQJhGVAhTopFY7s%3D&amp;reserved=0

Fix there commit message and clock names.

===

Johan

Quoted 18 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add bindings for the Rockchip serial flash controller. New device specific parameter of rockchip,sfc-no-dma included in documentation.

---
 .../devicetree/bindings/spi/rockchip,sfc.yaml | 87 +++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/rockchip,sfc.yaml
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +0 -0
new file mode 100644
index 000000000000..d5f8edd621ae

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 4

Quoted 4 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
@@ -0,0 +1,87 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fspi%2Frockchip%2Csfc.yaml%23&amp;data=04%7C01%7C%7Cbadb9f60f0114af4d80308d9259e53f6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637582184210841031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=RvUO4cmMOZb9B5l2MtUK3riDKebGLlKWt0KnnKaqENQ%3D&amp;reserved=0

rockchip-sfc.yaml

Quoted 2 lines

The comma is only used between <manufacturer>,<SoC name>-<function> I think. Ask a maintainer for exact name.

I was basing this off of names like renesas,rspi.yaml and cdns,qspi-nor.yaml, but this is probably a good question for the maintainers.

Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +5 -0
+$schema: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fdevicetree.org%2Fmeta-schemas%2Fcore.yaml%23&amp;data=04%7C01%7C%7Cbadb9f60f0114af4d80308d9259e53f6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637582184210841031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=OSRmMArQEVaWsZ%2BnxrqvfmO1pWk6dyjWVTunbw6j1Po%3D&amp;reserved=0
+
+title: Rockchip Serial Flash Controller (SFC)
+
+maintainers:
Quoted 5 lines

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 11

Quoted 2 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +2 -0
+  - Heiko Stuebner <[email protected]>
+  - Chris Morgan <[email protected]>

sort
no hotmail because it screws the message-ID

Is that a hard and fast rule? The Hotmail address I will be able to respond to much quicker. I've actually had that address since before they got bought by Microsoft. Worst case I can do the gmail I submit patches from, though, but Hotmail is still preferred by me.

Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +6 -0
+
+allOf:
+  - $ref: spi-controller.yaml#
+
+properties:
+  compatible:
Quoted 4 lines

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 18

Quoted 1 line
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +1 -0
+    oneOf:

This format is wrong. Use fall back strings.

Thank you, I was confused on this one section. I'll try to clean it up more.

Quoted 10 lines

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 22

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+      - const: rockchip,px30-sfc
 
+      - const: rockchip,rk1806-sfc
+      - const: rockchip,rk1808-sfc
+      - const: rockchip,rk312x-sfc

remove
I would advice against introducing compatible strings for boards that we don't have support for in mainline. Limit to things that we know what they look like.

I was under the impression these were also supported by upstream, but I'll remove them if they aren't.

Quoted 37 lines

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 26

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+      - const: rockchip,rk3308-sfc
+      - const: rockchip,rv1108-sfc
+      - items:
+          - const: rockchip,rk3036-sfc

oneOf:
- const: rockchip,rk3036-sfc
- items:
- enum:
- rockchip,px30-sfc
- rockchip,rk3308-sfc
- rockchip,rv1108-sfc
- const: rockchip,rk3036-sfc

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 37

Quoted 12 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +11 -0
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
 
+      - description: Bus Clock
+      - description: Module Clock

swap

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 42

Quoted 6 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +5 -0
+
+  clock-names:
+    items:
 
+      - const: ahb
+      - const: sfc
Quoted 8 lines

swap
You must keep them in the same order as in your example and in the dtsi files (both mainline as manufacturer tree).

Maybe use this:

- const: clk
- const: hclk

Heiko suggested we use clk and ahb as the clock names, to be consistent with the NAND flash controller hardware.

Quoted 22 lines

#define HCLK_SFC 257
#define SCLK_SFC 58

	COMPOSITE(SCLK_SFC, "clk_sfc", mux_gpll_cpll_p, 0,
			PX30_CLKSEL_CON(22), 7, 1, MFLAGS, 0, 7, DFLAGS,
			PX30_CLKGATE_CON(6), 7, GFLAGS),

	GATE(HCLK_SFC, "hclk_sfc", "hclk_mmc_nand", 0, PX30_CLKGATE_CON(6), 11,

GFLAGS),

===

From clk-rk3036.c:

	COMPOSITE(SCLK_SFC, "sclk_sfc", mux_pll_src_apll_dpll_gpll_usb480m_p, 0,
			RK2928_CLKSEL_CON(16), 0, 2, MFLAGS, 2, 5, DFLAGS,
			RK2928_CLKGATE_CON(10), 5, GFLAGS),


	GATE(0, "hclk_sfc", "hclk_peri", CLK_IGNORE_UNUSED,
Quoted 4 lines

RK2928_CLKGATE_CON(3), 14, GFLAGS),

The HCLK_SFC is missing and ignored in rk3036-cru.h and clk-rk3036.c Maybe this needs a fix?

It possibly does, but aside from hoping that I'm doing it right I lack the necessary hardware to test the changes. I can make educated guesses though by looking at the datasheet and board support package kernel.

Quoted 82 lines

#define HCLK_SFC 454

See:
clk: rockchip: rk3036: export the sfc clocks
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frockchip-linux%2Fkernel%2Fcommit%2F8373cf713ddd32037dc86462cac2d2d3cc859a99&amp;data=04%7C01%7C%7Cbadb9f60f0114af4d80308d9259e53f6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637582184210851028%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=KZiR3s3opSYS6uplRJ%2B726qiFWY5tEfvo6GKAp4w81A%3D&amp;reserved=0

Maybe add more patches to your serie? ;)

===

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 48

Quoted 7 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +6 -0
+
+  power-domains:
+    maxItems: 1
+
+  rockchip,sfc-no-dma:
 
+    vendor,bool-property:

remove
See example vendor,bool-property at:
Documentation/devicetree/bindings/example-schema.yaml

Quoted 1 line

+ descrption: Boolean value for disabling DMA

description:

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +5 -0
+      type: boolean
+
+required:
+  - compatible
+  - reg

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 64

Quoted 10 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +10 -0
+  - interrupts
+  - clocks
+  - clock-names
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/px30-cru.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
    #include <dt-bindings/power/px30-power.h>

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 74

Quoted 11 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +10 -0
+
+    sfc: spi@ff3a0000 {
+        compatible = "rockchip,px30-sfc","rockchip,rk3036-sfc";
+        reg = <0x0 0xff3a0000 0x0 0x4000>;
+        interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
+        clocks = <&cru SCLK_SFC>, <&cru HCLK_SFC>;
+        clock-names = "sfc", "ahb";
+        pinctrl-0 = <&sfc_clk &sfc_cs &sfc_bus2>;
+        pinctrl-names = "default";
 
+        power-domains = <&power PX30_PD_MMC_NAND>;

Add include for PX30_PD_MMC_NAND.

Check your example with scripts before you submit!

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 78

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+        #address-cells = <1>;
+        #size-cells = <0>;
+
 
+        flash@0 {

This controller handles only serial flash for now. So limit that with patternProperties.
Also users can't add more then 4 subnodes. That's where these documents are for, so add!

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 81

Quoted 3 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +2 -0
+            compatible = "jedec,spi-nor";
 
+            reg = <0>;
            spi-max-frequency = <108000000>;

Documentation/devicetree/bindings/spi/rockchip,sfc.yaml line 83

Quoted 2 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +2 -0
+            spi-rx-bus-width = <2>;
+            spi-tx-bus-width = <2>;
Quoted 13 lines

The sort order is:
compatible
reg
interrupts
the rest in alphabetical order
(no status in YAML examples)

Quoted 5 lines
Documentation/devicetree/bindings/spi/rockchip,sfc.yaml new file +4 -0
+        };
+    };
+
+...

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#5 lore raw

Re: [PATCH v3 2/4] spi: rockchip-sfc: add rockchip serial flash controller driver

In reply to Chris Morgan

On Tue, Jun 01, 2021 at 03:10:19PM -0500, Chris Morgan wrote:

This looks mostly good, a few mostly minor comments below:

drivers/spi/spi-rockchip-sfc.c line 3

Quoted 4 lines
drivers/spi/spi-rockchip-sfc.c new file +3 -0
@@ -0,0 +1,861 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Rockchip Serial Flash Controller Driver

Please make the entire comment a C++ one to make things look more intentional.

Quoted 4 lines
drivers/spi/spi-rockchip-sfc.c new file +4 -0
+static int rockchip_sfc_get_if_type(const struct spi_mem_op *op,
+				    struct rockchip_sfc *sfc)
+{
+	if (op->data.buswidth == 2)

drivers/spi/spi-rockchip-sfc.c line 197

Quoted 10 lines
drivers/spi/spi-rockchip-sfc.c new file +10 -0
+		return IF_TYPE_DUAL;
+	else if (op->data.buswidth == 4)
+		return IF_TYPE_QUAD;
+	else if (op->data.buswidth == 1)
+		return IF_TYPE_STD;
+
+	dev_err(sfc->dev, "unsupported SPI read mode\n");
+
+	return -EINVAL;
+}

This would be more idiomatically implemented as a switch statement.

Quoted 4 lines
drivers/spi/spi-rockchip-sfc.c new file +4 -0
+static int rockchip_sfc_wait_fifo_ready(struct rockchip_sfc *sfc, int wr, u32 timeout)
+{
+	unsigned long deadline = jiffies + timeout;
+	int level;

drivers/spi/spi-rockchip-sfc.c line 270

Quoted 10 lines
drivers/spi/spi-rockchip-sfc.c new file +10 -0
+
+	while (!(level = rockchip_sfc_get_fifo_level(sfc, wr))) {
+		if (time_after_eq(jiffies, deadline)) {
+			dev_warn(sfc->dev, "%s fifo timeout\n", wr ? "write" : "read");
+			return -ETIMEDOUT;
+		}
+		udelay(1);
+	}
+
+	return level;

The use of the assignment in the while conditional makes it hard to tell if this code is doing what was intended.

Quoted 8 lines
drivers/spi/spi-rockchip-sfc.c new file +8 -0
+static int rockchip_sfc_write_fifo(struct rockchip_sfc *sfc, const u8 *buf, int len)
+{
+	u8 bytes = len & 0x3;
+	u32 dwords;
+	int tx_level;
+	u32 write_words;
+	u32 tmp = 0;
+

drivers/spi/spi-rockchip-sfc.c line 339

Quoted 10 lines
drivers/spi/spi-rockchip-sfc.c new file +10 -0
+	dwords = len >> 2;
+	while (dwords) {
+		tx_level = rockchip_sfc_wait_fifo_ready(sfc, SFC_CMD_DIR_WR, HZ);
+		if (tx_level < 0)
+			return tx_level;
+		write_words = min_t(u32, tx_level, dwords);
+		iowrite32_rep(sfc->regbase + SFC_DATA, buf, write_words);
+		buf += write_words << 2;
+		dwords -= write_words;
+		}

Weird indentation on the } here.

drivers/spi/spi-rockchip-sfc.c line 343

Quoted 3 lines
drivers/spi/spi-rockchip-sfc.c new file +3 -0
+	/* write the rest non word aligned bytes */
+	if (bytes) {
+		tx_level = rockchip_sfc_wait_fifo_ready(sfc, SFC_CMD_DIR_WR, HZ);

It's not the source buffer being aligned that's the issue here, it's the buffer not being a multiple of word size.

Quoted 5 lines
drivers/spi/spi-rockchip-sfc.c new file +5 -0
+static irqreturn_t rockchip_sfc_irq_handler(int irq, void *dev_id)
+{
+	struct rockchip_sfc *sfc = dev_id;
+	u32 reg;
+

drivers/spi/spi-rockchip-sfc.c line 726

Quoted 10 lines
drivers/spi/spi-rockchip-sfc.c new file +10 -0
+	reg = readl(sfc->regbase + SFC_RISR);
+
+	/* Clear interrupt */
+	writel_relaxed(reg, sfc->regbase + SFC_ICLR);
+
+	if (reg & SFC_RISR_TRAN_FINISH)
+		complete(&sfc->cp);
+
+	return IRQ_HANDLED;
+}

This will silently clear any unknown interrupt, and silently claim to have handled an interrupt even if none happened (eg, due to shared IRQs)
- it would be better to only ack interrupts we handle and return IRQ_NONE if we didn't handle any.