Skip to contentSkip to conversation

r8a779a0: add RPC support

PATCH Superseded Wolfram Sang 2 participants 6 messages Sep 29, 2021

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover r8a779a0: add RPC support

Here is a non-RFC series with clk and DTS updates to enable the RPC unit on the R-Car V3U SoC. Important: If you want to test it, please use this branch because it contains a patch which avoids data corruption!

git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/v3u/rpc

The patch fixing the corruption is now applied and in for-next, so this series dropped RFC status and can be applied, I think.

Changes since RFC:

* added Geert's tags to patches 1-3
* reduced SPI speed to 40Mhz in patch 4
* removed unneeded leading 0s in patch 4

Kind regards,

Wolfram

Duc Nguyen (1):
arm64: dts: renesas: r8a779a0: Add RPC node

Wolfram Sang (3):
clk: renesas: cpg-lib: move RPC clock registration to the library
clk: renesas: r8a779a0: Add RPC support
arm64: dts: renesas: falcon-cpu: add SPI flash via RPC

 .../boot/dts/renesas/r8a779a0-falcon-cpu.dtsi | 33 +++++++
 arch/arm64/boot/dts/renesas/r8a779a0.dtsi     | 17 ++++
 drivers/clk/renesas/r8a779a0-cpg-mssr.c       | 29 ++++++
 drivers/clk/renesas/rcar-cpg-lib.c            | 83 +++++++++++++++++
 drivers/clk/renesas/rcar-cpg-lib.h            |  7 ++
 drivers/clk/renesas/rcar-gen3-cpg.c           | 89 +------------------
 6 files changed, 171 insertions(+), 87 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/4 clk: renesas: cpg-lib: move RPC clock registration to the library

We want to reuse this code for V3U soon. Because its RPCCKCR register is at a different offset, the moved functions do not use the base register as an argument anymore but the RPCCKCR register itself. Verified that an Eagle board with R-Car V3M still works.

---
 drivers/clk/renesas/rcar-cpg-lib.c  | 83 +++++++++++++++++++++++++++
 drivers/clk/renesas/rcar-cpg-lib.h  |  7 +++
 drivers/clk/renesas/rcar-gen3-cpg.c | 89 +----------------------------
 3 files changed, 92 insertions(+), 87 deletions(-)
drivers/clk/renesas/rcar-cpg-lib.c +83 -0
index 5678768ee1f2..e93f0011eb07 100644
@@ -267,4 +267,87 @@ struct clk * __init cpg_sd_clk_register(const char *name,
 	return clk;
 }
 
+struct rpc_clock {
+	struct clk_divider div;
+	struct clk_gate gate;
+	/*
+	 * One notifier covers both RPC and RPCD2 clocks as they are both
+	 * controlled by the same RPCCKCR register...
+	 */
+	struct cpg_simple_notifier csn;
+};
+
+static const struct clk_div_table cpg_rpc_div_table[] = {
+	{ 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 }, { 0, 0 },
+};
+
+struct clk * __init cpg_rpc_clk_register(const char *name,
+	void __iomem *rpcckcr, const char *parent_name,
+	struct raw_notifier_head *notifiers)
+{
+	struct rpc_clock *rpc;
+	struct clk *clk;
+
+	rpc = kzalloc(sizeof(*rpc), GFP_KERNEL);
+	if (!rpc)
+		return ERR_PTR(-ENOMEM);
+
+	rpc->div.reg = rpcckcr;
+	rpc->div.width = 3;
+	rpc->div.table = cpg_rpc_div_table;
+	rpc->div.lock = &cpg_lock;
+
+	rpc->gate.reg = rpcckcr;
+	rpc->gate.bit_idx = 8;
+	rpc->gate.flags = CLK_GATE_SET_TO_DISABLE;
+	rpc->gate.lock = &cpg_lock;
+
+	rpc->csn.reg = rpcckcr;
+
+	clk = clk_register_composite(NULL, name, &parent_name, 1, NULL, NULL,
+				     &rpc->div.hw,  &clk_divider_ops,
+				     &rpc->gate.hw, &clk_gate_ops,
+				     CLK_SET_RATE_PARENT);
+	if (IS_ERR(clk)) {
+		kfree(rpc);
+		return clk;
+	}
+
+	cpg_simple_notifier_register(notifiers, &rpc->csn);
+	return clk;
+}
+
+struct rpcd2_clock {
+	struct clk_fixed_factor fixed;
+	struct clk_gate gate;
+};
+
+struct clk * __init cpg_rpcd2_clk_register(const char *name,
+					   void __iomem *rpcckcr,
+					   const char *parent_name)
+{
+	struct rpcd2_clock *rpcd2;
+	struct clk *clk;
+
+	rpcd2 = kzalloc(sizeof(*rpcd2), GFP_KERNEL);
+	if (!rpcd2)
+		return ERR_PTR(-ENOMEM);
+
+	rpcd2->fixed.mult = 1;
+	rpcd2->fixed.div = 2;
+
+	rpcd2->gate.reg = rpcckcr;
+	rpcd2->gate.bit_idx = 9;
+	rpcd2->gate.flags = CLK_GATE_SET_TO_DISABLE;
+	rpcd2->gate.lock = &cpg_lock;
+
+	clk = clk_register_composite(NULL, name, &parent_name, 1, NULL, NULL,
+				     &rpcd2->fixed.hw, &clk_fixed_factor_ops,
+				     &rpcd2->gate.hw, &clk_gate_ops,
+				     CLK_SET_RATE_PARENT);
+	if (IS_ERR(clk))
+		kfree(rpcd2);
+
+	return clk;
+}
 
drivers/clk/renesas/rcar-cpg-lib.h +7 -0
index d00c91b116ca..35c0217c2f8b 100644
@@ -30,4 +30,11 @@ struct clk * __init cpg_sd_clk_register(const char *name,
 	void __iomem *base, unsigned int offset, const char *parent_name,
 	struct raw_notifier_head *notifiers, bool skip_first);
 
+struct clk * __init cpg_rpc_clk_register(const char *name,
+	void __iomem *rpcckcr, const char *parent_name,
+	struct raw_notifier_head *notifiers);
+
+struct clk * __init cpg_rpcd2_clk_register(const char *name,
+					   void __iomem *rpcckcr,
+					   const char *parent_name);
 #endif
drivers/clk/renesas/rcar-gen3-cpg.c +2 -87

108 lines not on this page · raw message

Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/4 clk: renesas: r8a779a0: Add RPC support

In reply to Wolfram Sang
---
 drivers/clk/renesas/r8a779a0-cpg-mssr.c | 29 +++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/clk/renesas/r8a779a0-cpg-mssr.c +29 -0
index f16d125ca009..93242dbf54ae 100644
@@ -36,6 +36,9 @@ enum rcar_r8a779a0_clk_types {
 	CLK_TYPE_R8A779A0_SD,
 	CLK_TYPE_R8A779A0_MDSEL,	/* Select parent/divider using mode pin */
 	CLK_TYPE_R8A779A0_OSC,	/* OSC EXTAL predivider and fixed divider */
+	CLK_TYPE_R8A779A0_RPCSRC,
+	CLK_TYPE_R8A779A0_RPC,
+	CLK_TYPE_R8A779A0_RPCD2,
 };
 
 struct rcar_r8a779a0_cpg_pll_config {
@@ -120,6 +123,10 @@ static const struct cpg_core_clk r8a779a0_core_clks[] __initconst = {
 	DEF_FIXED(".s3",		CLK_S3,		CLK_PLL1_DIV2,	4, 1),
 	DEF_FIXED(".sdsrc",		CLK_SDSRC,	CLK_PLL5_DIV4,	1, 1),
 	DEF_RATE(".oco",		CLK_OCO,	32768),
+	DEF_BASE(".rpcsrc",	 CLK_RPCSRC,	   CLK_TYPE_R8A779A0_RPCSRC, CLK_PLL5),
+	DEF_BASE("rpc",		 R8A779A0_CLK_RPC, CLK_TYPE_R8A779A0_RPC, CLK_RPCSRC),
+	DEF_BASE("rpcd2",	 R8A779A0_CLK_RPCD2, CLK_TYPE_R8A779A0_RPCD2,
+		 R8A779A0_CLK_RPC),
 
 	/* Core Clock Outputs */
 	DEF_FIXED("zx",		R8A779A0_CLK_ZX,	CLK_PLL20_DIV2,	2, 1),
@@ -193,6 +200,7 @@ static const struct mssr_mod_clk r8a779a0_mod_clks[] __initconst = {
 	DEF_MOD("msi3",		621,	R8A779A0_CLK_MSO),
 	DEF_MOD("msi4",		622,	R8A779A0_CLK_MSO),
 	DEF_MOD("msi5",		623,	R8A779A0_CLK_MSO),
+	DEF_MOD("rpc-if",	629,	R8A779A0_CLK_RPCD2),
 	DEF_MOD("scif0",	702,	R8A779A0_CLK_S1D8),
 	DEF_MOD("scif1",	703,	R8A779A0_CLK_S1D8),
 	DEF_MOD("scif3",	704,	R8A779A0_CLK_S1D8),
@@ -255,10 +263,16 @@ static const struct mssr_mod_clk r8a779a0_mod_clks[] __initconst = {
 	DEF_MOD("vspx3",	1031,	R8A779A0_CLK_S1D1),
 };
 
+static const struct clk_div_table cpg_rpcsrc_div_table[] = {
+	{ 0, 4 }, { 1, 6 }, { 2, 5 }, { 3, 6 }, { 0, 0 },
+};
+
 static const struct rcar_r8a779a0_cpg_pll_config *cpg_pll_config __initdata;
 static unsigned int cpg_clk_extalr __initdata;
 static u32 cpg_mode __initdata;
 
+#define CPG_RPCCKCR 0x874
+
 static struct clk * __init rcar_r8a779a0_cpg_clk_register(struct device *dev,
 	const struct cpg_core_clk *core, const struct cpg_mssr_info *info,
 	struct clk **clks, void __iomem *base,
@@ -322,6 +336,21 @@ static struct clk * __init rcar_r8a779a0_cpg_clk_register(struct device *dev,
 		div = cpg_pll_config->osc_prediv * core->div;
 		break;
 
+	case CLK_TYPE_R8A779A0_RPCSRC:
+		return clk_register_divider_table(NULL, core->name,
+						  __clk_get_name(parent), 0,
+						  base + CPG_RPCCKCR, 3, 2, 0,
+						  cpg_rpcsrc_div_table,
+						  &cpg_lock);
+
+	case CLK_TYPE_R8A779A0_RPC:
+		return cpg_rpc_clk_register(core->name, base + CPG_RPCCKCR,
+					    __clk_get_name(parent), notifiers);
+
+	case CLK_TYPE_R8A779A0_RPCD2:
+		return cpg_rpcd2_clk_register(core->name, base + CPG_RPCCKCR,
+					      __clk_get_name(parent));
+
 	default:
 		return ERR_PTR(-EINVAL);
 	}
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/4 arm64: dts: renesas: r8a779a0: Add RPC node

In reply to Wolfram Sang

From: Duc Nguyen <[email protected]>

Add device node for RPC on R8A779A0 SoC.

---
 arch/arm64/boot/dts/renesas/r8a779a0.dtsi | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm64/boot/dts/renesas/r8a779a0.dtsi +17 -0
index 631d520cebee..2b3abdc80de8 100644
@@ -1093,6 +1093,23 @@ mmc0: mmc@ee140000 {
 			status = "disabled";
 		};
 
+		rpc: spi@ee200000 {
+			compatible = "renesas,r8a779a0-rpc-if",
+				     "renesas,rcar-gen3-rpc-if";
+			reg = <0 0xee200000 0 0x200>,
+			      <0 0x08000000 0 0x04000000>,
+			      <0 0xee208000 0 0x100>;
+			reg-names = "regs", "dirmap", "wbuf";
+			interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&cpg CPG_MOD 629>;
+			clock-names = "rpc";
+			power-domains = <&sysc R8A779A0_PD_ALWAYS_ON>;
+			resets = <&cpg 629>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
 		gic: interrupt-controller@f1000000 {
 			compatible = "arm,gic-v3";
 			#interrupt-cells = <3>;
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/4 arm64: dts: renesas: falcon-cpu: add SPI flash via RPC

In reply to Wolfram Sang
---
 .../boot/dts/renesas/r8a779a0-falcon-cpu.dtsi | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi +33 -0
index a0a1a1da0d87..7eeee1da9c0b 100644
@@ -166,6 +166,11 @@ mmc_pins: mmc {
 		power-source = <1800>;
 	};
 
+	qspi0_pins: qspi0 {
+		groups = "qspi0_ctrl", "qspi0_data4";
+		function = "qspi0";
+	};
+
 	scif0_pins: scif0 {
 		groups = "scif0_data", "scif0_ctrl";
 		function = "scif0";
@@ -177,6 +182,34 @@ scif_clk_pins: scif_clk {
 	};
 };
 
+&rpc {
+	pinctrl-0 = <&qspi0_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+
+	flash@0 {
+		compatible = "spansion,s25fs512s", "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+		spi-rx-bus-width = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			boot_partition@0 {
+				reg = <0x00000000 0xc40000>;
+				read-only;
+			};
+			user@c40000 {
+				reg = <0x00c40000 0x33c0000>;
+			};
+		};
+	};
+};
+
 &rwdt {
 	timeout-sec = <60>;
 	status = "okay";
Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH 4/4] arm64: dts: renesas: falcon-cpu: add SPI flash via RPC

Quoted 9 lines · Wolfram Sang
---
  .../boot/dts/renesas/r8a779a0-falcon-cpu.dtsi | 33 +++++++++++++++++++
  1 file changed, 33 insertions(+)
arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi +0 -0
index a0a1a1da0d87..7eeee1da9c0b 100644

[...]

Quoted 12 lines
arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi +8 -0
@@ -177,6 +182,34 @@ scif_clk_pins: scif_clk {
  	};
  };
 
+&rpc {
+	pinctrl-0 = <&qspi0_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+
+	flash@0 {
+		compatible = "spansion,s25fs512s", "jedec,spi-nor";

arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi scif_clk_pins: scif_clk { · line 202

Quoted 10 lines
arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi +10 -0
+		reg = <0>;
+		spi-max-frequency = <40000000>;
+		spi-rx-bus-width = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			boot_partition@0 {

Not just boot@...? And hyphens are preferred here over underscores.

arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi scif_clk_pins: scif_clk { · line 212

Quoted 10 lines
arch/arm64/boot/dts/renesas/r8a779a0-falcon-cpu.dtsi +10 -0
+				reg = <0x00000000 0xc40000>;
+				read-only;
+			};
+			user@c40000 {
+				reg = <0x00c40000 0x33c0000>;
+			};
+		};
+	};
+};
+

[...]

MBR, Sergey