Skip to contentSkip to conversation

Test R-Car Gen3 SYSC power domains used by FCPCS and VDPB

PATCH New Magnus Damm 1 participant 6 messages Nov 21, 2018

Subsystems (3)
lore
Share & tools
lore

Magnus Damm

author maintainer
#0 lore raw

cover Test R-Car Gen3 SYSC power domains used by FCPCS and VDPB

Test R-Car Gen3 SYSC power domains used by FCPCS and VDPB

[PATCH 01/05] Hack FCP driver to poke at FCPCS and VDPB during probe [PATCH 02/05] arm64: dts: renesas: r8a7795: Add FCPCS+VDPB node for R-Car H3 [PATCH 03/05] arm64: dts: renesas: r8a7796: Add FCPCS+VDPB node for R-Car M3-W [PATCH 04/05] arm64: dts: renesas: r8a77965: Add FCPCS+VDPB node for R-Car M3-N [PATCH 05/05] arm64: dts: renesas: r8a77990: Add FCPCS+VDPB node for R-Car E3

These patches temporarily extend the FCP driver to manage power domain power and poke at FCPCS and VDPB devices after power on and optionally after power off as well. Access while power off is expected to fail and is currently disabled by #ifdef wrap.

Example of console printout from H3 ULCB:

[    1.921670] Enabling FCPCS device (Runtime PM on)
[    1.926449] Power-on FCPCS version is 0x00000103
[    1.931117] Power-on VDPB read at offset 0x200 is 0x00000000
[    1.936819] Disabling FCPCS device (Runtime PM off) 
[    1.941853] rcar_sysc_pd_power_off: a2vc1
[    1.945960] sysc power off domain 26: 0000000e -> 0
[    1.950892] rcar_sysc_pd_power_off: a3vc
[    1.954903] sysc power off domain 14: 0000000e -> 0

Register details for FCPCS and VDPB are omitted from the data sheet, however this code assumes the version register in FCPCS is available following same register layout as other documented FCP devices.

As can be seen by the printout above, some sort of value is read out when the power domain is on. Reading out the same register when turned off triggers an exception on H3 ES2 as expected.

Please note that repeated power on-off-on has not been performed. Also no verification has been made that devices actually are located in A2VC instead of for instance A3VC. Since A3VC is parent of A2VC an incorrect power domain pointer in DT to A2VC while the (rather undocumented) device is located in A3VC might result in some hidden errors.

The VDPB register access results in all-zero value while powered on. Which actual register that should be used for poking remains guess work at this point. Reading VDPB while powered off results in an exception on H3 ES2.

The basic testing performed by this series shows that A2VC power domain handling for H3 ES2 seems to work as expected.

This series is not intended for upstream merge.

Created as an example of how to test power domains for a certain device. I hope to use this approach to test IPMMU power domain support in the future.

---

Developed on top of renesas-devel-20181119-v4.20-rc3

 arch/arm64/boot/dts/renesas/r8a7795.dtsi  |    9 ++++++
 arch/arm64/boot/dts/renesas/r8a7796.dtsi  |    9 ++++++
 arch/arm64/boot/dts/renesas/r8a77965.dtsi |    9 ++++++
 arch/arm64/boot/dts/renesas/r8a77990.dtsi |    9 ++++++
 drivers/media/platform/rcar-fcp.c         |   42 ++++++++++++++++++++++++++++-
 drivers/soc/renesas/rcar-sysc.c           |    1 
 6 files changed, 78 insertions(+), 1 deletion(-)
author maintainer
#1 lore raw

PATCH 1/5 Hack FCP driver to poke at FCPCS and VDPB during probe

From: Magnus Damm <[email protected]>

Hack up the FCP driver to test the power domains and dump registers.

This prototype level code is not intended for upstream merge.

---

 drivers/media/platform/rcar-fcp.c |   42 ++++++++++++++++++++++++++++++++++++-
 drivers/soc/renesas/rcar-sysc.c   |    1 
 2 files changed, 42 insertions(+), 1 deletion(-)
drivers/media/platform/rcar-fcp.c +41 -1
@@ -8,10 +8,12 @@
  */
 
 #include <linux/device.h>
+#include <linux/io.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
@@ -26,6 +28,8 @@ struct rcar_fcp_device {
 static LIST_HEAD(fcp_devices);
 static DEFINE_MUTEX(fcp_lock);
 
+#define FCP_VCR 0 /* Version register at offset 0 */
+
 /* -----------------------------------------------------------------------------
  * Public API
  */
@@ -118,7 +122,7 @@ EXPORT_SYMBOL_GPL(rcar_fcp_enable);
 void rcar_fcp_disable(struct rcar_fcp_device *fcp)
 {
 	if (fcp)
-		pm_runtime_put(fcp->dev);
+		pm_runtime_put_sync(fcp->dev);
 }
 EXPORT_SYMBOL_GPL(rcar_fcp_disable);
 
@@ -144,6 +148,41 @@ static int rcar_fcp_probe(struct platfor
 
 	platform_set_drvdata(pdev, fcp);
 
+	/* self-test VCPCS on ->probe() */
+	if (of_device_get_match_data(&pdev->dev)) {
+		struct resource *io;
+		void __iomem *mmio, *mmio2;
+
+		printk("Enabling FCPCS device (Runtime PM on)\n");
+		rcar_fcp_enable(fcp);
+
+		io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		mmio = devm_ioremap_resource(&pdev->dev, io);
+		if (!IS_ERR(mmio))
+			printk("Power-on FCPCS version is 0x%08lx\n",
+			       (unsigned long) ioread32(mmio + FCP_VCR));
+
+		io = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+		mmio2 = devm_ioremap_resource(&pdev->dev, io);
+
+		if (!IS_ERR(mmio2))
+			printk("Power-on VDPB read at offset 0x200 is 0x%08lx\n",
+			       (unsigned long) ioread32(mmio2 + 0x200));
+
+		printk("Disabling FCPCS device (Runtime PM off)\n");
+		rcar_fcp_disable(fcp);
+
+#ifdef IOREAD_POWER_OFF_TEST
+		if (!IS_ERR(mmio))
+			printk("Power-off FCPCS version is 0x%08lx\n",
+			       (unsigned long) ioread32(mmio + FCP_VCR));
+
+		if (!IS_ERR(mmio2))
+			printk("Power-off VDPB read at offset 0x200 is 0x%08lx\n",
+			       (unsigned long) ioread32(mmio2 + 0x200));
+#endif
+	}
+
 	return 0;
 }
 
@@ -163,6 +202,7 @@ static int rcar_fcp_remove(struct platfo
 static const struct of_device_id rcar_fcp_of_match[] = {
 	{ .compatible = "renesas,fcpf" },
 	{ .compatible = "renesas,fcpv" },
+	{ .compatible = "renesas,fcpc", .data = &rcar_fcp_of_match[0] },
 	{ },
 };
 MODULE_DEVICE_TABLE(of, rcar_fcp_of_match);
drivers/soc/renesas/rcar-sysc.c +1 -0
@@ -6,6 +6,7 @@
  * Copyright (C) 2015-2017 Glider bvba
  */
 
+#define DEBUG
 #include <linux/clk/renesas.h>
 #include <linux/delay.h>
 #include <linux/err.h>
author maintainer
#2 lore raw

PATCH 2/5 arm64: dts: renesas: r8a7795: Add FCPCS+VDPB node for R-Car H3

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add a temporary FCPCS device that also includes VDPB for testing purpose. This prototype level code is not intended for upstream merge.

---

 arch/arm64/boot/dts/renesas/r8a7795.dtsi |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/renesas/r8a7795.dtsi +9 -0
@@ -2647,6 +2647,15 @@
 			resets = <&cpg 820>;
 		};
 
+		fcpcs: fcp@fe90f000 {
+			compatible = "renesas,fcpc";
+			reg = <0 0xfe90f000 0 0x200>,
+			      <0 0xfe900000 0 0x400>; /* Hack to test VDPB */
+			clocks = <&cpg CPG_MOD 619>;
+			power-domains = <&sysc R8A7795_PD_A2VC1>;
+			resets = <&cpg 619>;
+		};
+
 		fdp1@fe940000 {
 			compatible = "renesas,fdp1";
 			reg = <0 0xfe940000 0 0x2400>;
author maintainer
#3 lore raw

PATCH 3/5 arm64: dts: renesas: r8a7796: Add FCPCS+VDPB node for R-Car M3-W

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add a temporary FCPCS device that also includes VDPB for testing purpose. This prototype level code is not intended for upstream merge.

---

 arch/arm64/boot/dts/renesas/r8a7796.dtsi |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/renesas/r8a7796.dtsi +9 -0
@@ -2209,6 +2209,15 @@
 			resets = <&cpg 822>;
 		};
 
+		fcpcs: fcp@fe90f000 {
+			compatible = "renesas,fcpc";
+			reg = <0 0xfe90f000 0 0x200>,
+			      <0 0xfe900000 0 0x400>; /* Hack to test VDPB */
+			clocks = <&cpg CPG_MOD 619>;
+			power-domains = <&sysc R8A7796_PD_A2VC0>;
+			resets = <&cpg 619>;
+		};
+
 		fdp1@fe940000 {
 			compatible = "renesas,fdp1";
 			reg = <0 0xfe940000 0 0x2400>;
author maintainer
#4 lore raw

PATCH 4/5 arm64: dts: renesas: r8a77965: Add FCPCS+VDPB node for R-Car M3-N

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add a temporary FCPCS device that also includes VDPB for testing purpose. This prototype level code is not intended for upstream merge.

---

 arch/arm64/boot/dts/renesas/r8a77965.dtsi |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/renesas/r8a77965.dtsi +9 -0
@@ -1890,6 +1890,15 @@
 			status = "disabled";
 		};
 
+		fcpcs: fcp@fe90f000 {
+			compatible = "renesas,fcpc";
+			reg = <0 0xfe90f000 0 0x200>,
+			      <0 0xfe900000 0 0x400>; /* Hack to test VDPB */
+			clocks = <&cpg CPG_MOD 619>;
+			power-domains = <&sysc R8A77965_PD_A2VC1>;
+			resets = <&cpg 619>;
+		};
+
 		fdp1@fe940000 {
 			compatible = "renesas,fdp1";
 			reg = <0 0xfe940000 0 0x2400>;
author maintainer
#5 lore raw

PATCH 5/5 arm64: dts: renesas: r8a77990: Add FCPCS+VDPB node for R-Car E3

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add a temporary FCPCS device that also includes VDPB for testing purpose. This prototype level code is not intended for upstream merge.

---

 arch/arm64/boot/dts/renesas/r8a77990.dtsi |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/boot/dts/renesas/r8a77990.dtsi +9 -0
@@ -1419,6 +1419,15 @@
 			resets = <&cpg 408>;
 		};
 
+		fcpcs: fcp@fe90f000 {
+			compatible = "renesas,fcpc";
+			reg = <0 0xfe90f000 0 0x200>,
+			      <0 0xfe900000 0 0x400>; /* Hack to test VDPB */
+			clocks = <&cpg CPG_MOD 619>;
+			power-domains = <&sysc R8A77990_PD_A2VC1>;
+			resets = <&cpg 619>;
+		};
+
 		vspb0: vsp@fe960000 {
 			compatible = "renesas,vsp2";
 			reg = <0 0xfe960000 0 0x8000>;