Skip to contentSkip to conversation

ARM: rk3288: Add PM Domain support

PATCH Superseded Caesar Wang 2 participants 9 messages Sep 2, 2015 – Sep 6, 2015

Subsystems (2)

v17 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
#0 lore raw

v17 cover ARM: rk3288: Add PM Domain support

Thank you all for providing inputs and comments on previous versions of this patchset.
Especially thanks to the (Kevin, Heiko, Dmitry, Doug, ULF, Michael....).

Add power domain drivers based on generic power domain for Rockchip platform, and support RK3288 SoCs.

Verified on url =

    https://chromium.googlesource.com/chromiumos/third_party/kernel/+/v3.14
    localhost / # cat /sys/kernel/debug/pm_genpd/pm_genpd_summary
    domain                      status         slaves
    /device                      runtime        status
    ----------------------------------------------------------------------
    pd_video                        off
    /devices/ff9a0800.iommu                     suspended
    /devices/ff9a0000.video-codec               suspended
    pd_vio                          on
    /devices/ff930300.iommu                     suspended
    /devices/ff940300.iommu                     suspended
    /devices/ff930000.vop                       suspended
    /devices/ff940000.vop                       suspended
    /devices/ff980000.hdmi                      unsupported
    /devices/rockchip-edp                       unsupported
    pd_hevc                         off
    pd_gpu                          off
    /devices/ffa30000.gpu                       suspended

    The following is the easy example.

    vopb: vop at ff930000 {
        compatible = "rockchip,rk3288-vop";
        ...
        iommus = <&vopb_mmu>;
        power-domains = <&power RK3288_PD_VIO>;
        status = "disabled";
        ...
    };

    vopb_mmu: iommu at ff930300 {
        compatible = "rockchip,iommu";
        ...
        interrupt-names = "vopb_mmu";
        power-domains = <&power RK3288_PD_VIO>;
        #iommu-cells = <0>;
        status = "disabled";
        ...
    };

    vopl: vop at ff940000 {
        compatible = "rockchip,rk3288-vop";
        reg = <0xff940000 0x19c>;
        ...
        iommus = <&vopl_mmu>;
        power-domains = <&power RK3288_PD_VIO>;
        status = "disabled";
        ...
    };

    vopl_mmu: iommu at ff940300 {
        compatible = "rockchip,iommu";
        ...
        interrupt-names = "vopl_mmu";
        power-domains = <&power RK3288_PD_VIO>;
        #iommu-cells = <0>;
        status = "disabled";
    };

    Others, we can verify this driver for the EDP.
    We can apply the following these patchs.

    6967631 New          [v2,1/8] drm: exynos/dp: fix code style
    6967741 New          [v2,2/8] drm: exynos/dp: convert to drm bridge mode
    6967801 New          [v2,3/8] drm: bridge: analogix_dp: split exynos dp driver to bridge dir
    6967791 New          [v2,4/8] drm: rockchip/dp: add rockchip platform dp driver
    6968031 New          [v2,5/8] drm: bridge/analogix_dp: add platform device type support
    6968141 New          [v2,6/8] drm: bridge: analogix_dp: add some rk3288 special registers setting
    6967941 New          [v2,7/8] drm: bridge: analogix_dp: try force hpd after plug in lookup failed
    6967971 New          [v2,8/8] drm: bridge/analogix_dp: expand the delay time for hpd detect

    There is a recent addition from Linus Walleij,
    called simple-mfd [a] that is supposed to get added real early for kernel 4.2

    [a]:
    https://git.kernel.org/cgit/linux/kernel/git/linusw/linux-integrator.git/commit/?id=fcf294c020ff7ee4e3b1e96159e4dc7a17ad5

    Here is my branch, Tested by chromeos-3.14 and next-kernel.

    f54144e ARM: dts: add the support power-domain node on RK3288 SoCs
    acf07d3 soc: rockchip: power-domain: Add power domain driver
    8cc2139 ARM: power-domain: rockchip: add all the domain type on RK3288 SoCs
    7114c12 dt-bindings: add document of Rockchip power domains
    ae98207 Merge tag 'pm+acpi-4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
    f1a3c0b Merge tag 'devicetree-for-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux
    089b669 Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial
    45c680b Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/livepatching
    851328f Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
    ......

Changes in v17:
- add the decription in detail for RK3288 SoCs.
- delete the ugly chart in the commit.
- (re)defining config for ROCKCHIP.
- remove clocks of the HDMI ctrl.
- update the description.
- add Reviewed-by: Michale.

Changes in v16:
- remove the pmu node.
- Add more domain decription.
- the driver type from tristate to bool.
- Letter misspelled.
- As Ulf suggestion, remove #include <linux/clk-provider.h>, use "%pC" as the formatting string for the dev_dbg().
- As the Ulf suggestion, set the genpd->flags to assign the ->stop|start() callbacks.
- Manually copy the problem in patch v15.
- rebase the description.

Changes in v15:
- change the comment.
- As the kevin suggestion, put the power-domain driver into driver/soc/vendor.
- As Heiko suggestion, Patch 1: binding doc, 2: binding-header, 3: driver, 4: dts-changes.
- return -ENXIO --> return -ENODEV.
- As Tomasz remarked previously the dts should represent the hardware and the power-domains are part of the pmu.

Changes in v14:
- does not need to set an owner,remove the "THIS_MODULE".
- Remove essential clocks from rk3288 PD_VIO domain, Some clocks are essential for the system health and should not be turned down. However there is no owner for them so if they listed as belonging to power domain we'll try toggling them up and down during power domain transition. As a result we either fail to suspend or resume the system.

Changes in v13:
- Remove essential clocks from rk3288 PD_VIO domain Some clocks are essential for the system health and should not be turned down. However there is no owner for them so if they listed as belonging to power domain we'll try toggling them up and down during power domain.
- Device drivers expect their devices to be powered on before their probing code is invoked. To achieve that we should start with power domains powered on (we may turn them off later once all devices enable runtime powermanagment and go idle).
- This change switches Rockchip power domain driver to use updated device_attach and device_detach API.
- set the gpu/core power domain power delay time.
- fix enumerating PM clocks for devices.
- fix use after free We can't use clk after we did clk_put(clk).

Changes in v12:
- fix the title doamin->domain.
- updated device_attach and device_detach API,otherwise it will compile fail on next kernel.

Changes in v11:
- fix pm_genpd_init(&pd->genpd, NULL, false).

Changes in v10:
- this switches over domain infos to use masks instead of recomputing them each time and also gets rid of custom domain translator and uses standard onecell on.
- fix missing the #include <dt-bindings/power-domain/rk3288.h>.
- remove the notes.

Changes in v9:
- add document decription.
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain have lists of clocks they trigger on and off during power transitions and independently from power domains clocks. We attach clocks to devices comprising power domain and prepare them so they are turn on and off by runtime PM.
- add rockchip_pm_add_one_domain() to control domains.
- add pd_start/pd_stop interface to control clocks.
- add decription for power-doamin node.

Changes in v8:
- document go back to v2.
- This reconciles the v2 and v7 code so that we power domain have lists of clocks they toggle on and off during power transitions and independently from power domains clocks we attach clocks to devices comprising power domain and prepare them so they are turn on and off by runtime PM.
- DTS go back to v2.

Changes in v7:
- Delete unused variables

Changes in v6:
- delete pmu_lock.
- modify dev_lock using mutex.
- pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev).
- pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev).
- add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev.

Changes in v5:
- delete idle_lock.
- add timeout in rockchip_pmu_set_idle_request().

Changes in v4:
- use list storage dev.

Changes in v3:
- DT structure has changed.
- change use pm_clk_resume() and pm_clk_suspend().
- Decomposition power-controller, changed to multiple controller (gpu-power-controller, hevc-power-controller).

Changes in v2:
- move clocks to "optional".
- remove the "pd->pd.of_node = np".
- make pd_vio clocks all one entry per line and alphabetize.
- power: power-controller move back to pinctrl: pinctrl.

Caesar Wang (4):
dt-bindings: add document of Rockchip power domains
ARM: power-domain: rockchip: add all the domain type on RK3288 SoCs
soc: rockchip: power-domain: Add power domain driver
ARM: dts: add the support power-domain node on RK3288 SoCs

 .../bindings/soc/rockchip/power_domain.txt         | 114 +++++
 arch/arm/boot/dts/rk3288.dtsi                      |  58 ++-
 drivers/soc/Kconfig                                |   1 +
 drivers/soc/Makefile                               |   1 +
 drivers/soc/rockchip/Kconfig                       |  14 +
 drivers/soc/rockchip/Makefile                      |   4 +
 drivers/soc/rockchip/pm_domains.c                  | 485 +++++++++++++++++++++
 include/dt-bindings/power-domain/rk3288.h          |  31 ++
 8 files changed, 707 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
 create mode 100644 drivers/soc/rockchip/Kconfig
 create mode 100644 drivers/soc/rockchip/Makefile
 create mode 100644 drivers/soc/rockchip/pm_domains.c
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v17 1/4 dt-bindings: add document of Rockchip power domains

This add the necessary binding documentation for the power domains found on Rockchip SoCs.

---

Changes in v17:
- add the decription in detail for RK3288 SoCs.

Changes in v16:
- remove the pmu node.

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9:
- add document decription.

Changes in v8:
- document go back to v2.

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- DT structure has changed.

Changes in v2:
- move clocks to "optional".

 .../bindings/soc/rockchip/power_domain.txt         | 114 +++++++++++++++++++++
 1 file changed, 114 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +114 -0
new file mode 100644
index 0000000..4cf6b27
@@ -0,0 +1,114 @@
+* Rockchip Power Domains
+
+Rockchip processors include support for multiple power domains which can be
+powered up/down by software based on different application scenes to save power.
+
+Required properties for power domain controller:
+- compatible: Should be one of the following.
+	"rockchip,rk3288-power-controller" - for RK3288 SoCs.
+- #power-domain-cells: Number of cells in a power-domain specifier.
+	Should be 1 for multiple PM domains.
+- #address-cells: Should be 1.
+- #size-cells: Should be 0.
+
+Required properties for power domain sub nodes:
+- reg: index of the power domain, should use macros in:
+	"include/dt-bindings/power-domain/rk3288.h" - for RK3288 type power domain.
+- clocks (optional): phandles to clocks which need to be enabled while power domain
+	switches state.
+
+Example:
+
+	power: power-controller {
+		compatible = "rockchip,rk3288-power-controller";
+		#power-domain-cells = <1>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pd_gpu {
+			reg = <RK3288_PD_GPU>;
+			clocks = <&cru ACLK_GPU>;
+		};
+	};
+
+Node of a device using power domains must have a power-domains property,
+containing a phandle to the power device node and an index specifying which
+power domain to use.
+The index should use macros in:
+	"include/dt-bindings/power-domain/rk3288.h" - for rk3288 type power domain.
+
+Example of the node using power domain:
+
+	node {
+		/* ... */
+		power-domains = <&power RK3288_PD_GPU>;
+		/* ... */
+	};
+
+Others, all the device clocks being listed in the power-domains itself.
+All the device clocks are included in someone domians that need to enable
+before you operate them.
+
+As the chip designs for PM hardware. We need turn on the noc clocks,
+if we are operating the "pd_vio" domain to enter the idle status.
+
+As the following described in detail for every device be included in domains
+on RK3288 SoCs.
+
+	/* GPU's ACLK_GPU on the ACLK_GPU_NIU */
+	pd_gpu {
+		reg = <RK3288_PD_GPU>;
+		clocks = <&cru ACLK_GPU>;
+	};
+
+	/* HEVC AXI clocks */
+	pd_hevc {
+		reg = <RK3288_PD_HEVC>;
+		clocks = <&cru ACLK_HEVC>,
+		<&cru SCLK_HEVC_CABAC>,
+		<&cru SCLK_HEVC_CORE>,
+		<&cru HCLK_HEVC>;
+	};
+
+	/*
+	 * RGA, VOP, MIPI, LVDS, EDP..., says the ACLK* on the ACLK_VIO_NIU,
+	 * others are on the HCLK_VIO_NIU.
+	 */
+	pd_vio {
+		reg = <RK3288_PD_VIO>;
+		clocks = <&cru ACLK_IEP>,
+		<&cru ACLK_ISP>,
+		<&cru ACLK_RGA>,
+		<&cru ACLK_VIP>,
+		<&cru ACLK_VOP0>,
+		<&cru ACLK_VOP1>,
+		<&cru DCLK_VOP0>,
+		<&cru DCLK_VOP1>,
+		<&cru HCLK_IEP>,
+		<&cru HCLK_ISP>,
+		<&cru HCLK_RGA>,
+		<&cru HCLK_VIP>,
+		<&cru HCLK_VOP0>,
+		<&cru HCLK_VOP1>,
+		<&cru PCLK_EDP_CTRL>,
+		<&cru PCLK_HDMI_CTRL>,
+		<&cru PCLK_LVDS_PHY>,
+		<&cru PCLK_MIPI_CSI>,
+		<&cru PCLK_MIPI_DSI0>,
+		<&cru PCLK_MIPI_DSI1>,
+		<&cru SCLK_EDP_24M>,
+		<&cru SCLK_EDP>,
+		<&cru SCLK_ISP_JPE>,
+		<&cru SCLK_ISP>,
+		<&cru SCLK_RGA>;
+	};
+
+	/*
+	 * Video's ACLK_VCODEC on the ACLK_VCODEC_NIU, Video's HCLK_VCODEC,
+	 * on the HCLK_VCODEC_NIU.
+	 */
+	pd_video {
+		reg = <RK3288_PD_VIDEO>;
+		clocks = <&cru ACLK_VCODEC>,
+		<&cru HCLK_VCODEC>;
+	};
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v17 1/4] dt-bindings: add document of Rockchip power domains

Quoted 94 lines · Caesar Wang

This add the necessary binding documentation for the power domains found on Rockchip SoCs.

---

Changes in v17:
- add the decription in detail for RK3288 SoCs.

Changes in v16:
- remove the pmu node.

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9:
- add document decription.

Changes in v8:
- document go back to v2.

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- DT structure has changed.

Changes in v2:
- move clocks to "optional".

 .../bindings/soc/rockchip/power_domain.txt         | 114 +++++++++++++++++++++
 1 file changed, 114 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/rockchip/power_domain.txt

diff --git a/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt b/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file mode 100644
index 0000000..4cf6b27

Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +46 -0
@@ -0,0 +1,114 @@
+* Rockchip Power Domains
+
+Rockchip processors include support for multiple power domains which can be
+powered up/down by software based on different application scenes to save power.
+
+Required properties for power domain controller:
+- compatible: Should be one of the following.
+	"rockchip,rk3288-power-controller" - for RK3288 SoCs.
+- #power-domain-cells: Number of cells in a power-domain specifier.
+	Should be 1 for multiple PM domains.
+- #address-cells: Should be 1.
+- #size-cells: Should be 0.
+
+Required properties for power domain sub nodes:
+- reg: index of the power domain, should use macros in:
+	"include/dt-bindings/power-domain/rk3288.h" - for RK3288 type power domain.
+- clocks (optional): phandles to clocks which need to be enabled while power domain
+	switches state.
+
+Example:
+
+	power: power-controller {
+		compatible = "rockchip,rk3288-power-controller";
+		#power-domain-cells = <1>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pd_gpu {
+			reg = <RK3288_PD_GPU>;
+			clocks = <&cru ACLK_GPU>;
+		};
+	};
+
+Node of a device using power domains must have a power-domains property,
+containing a phandle to the power device node and an index specifying which
+power domain to use.
+The index should use macros in:
+	"include/dt-bindings/power-domain/rk3288.h" - for rk3288 type power domain.
+
+Example of the node using power domain:
+
+	node {
+		/* ... */
+		power-domains = <&power RK3288_PD_GPU>;
+		/* ... */
+	};

Documentation/devicetree/bindings/soc/rockchip/power_domain.txt line 56

Quoted 10 lines
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +10 -0
+
+Others, all the device clocks being listed in the power-domains itself.
+All the device clocks are included in someone domians that need to enable
+before you operate them.
+
+As the chip designs for PM hardware. We need turn on the noc clocks,
+if we are operating the "pd_vio" domain to enter the idle status.
+
+As the following described in detail for every device be included in domains
+on RK3288 SoCs.

IMO, the below isn't really detailed enough, and also, the details should be in the .dts file itself, not in the binding doc.

In particular, it's not obvious from the current series which of the clocks are device clocks, and which are other/parent/infrastructure clocks needed for the synchronous reset.

Kevin

Quoted 57 lines
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +57 -0
+	/* GPU's ACLK_GPU on the ACLK_GPU_NIU */
+	pd_gpu {
+		reg = <RK3288_PD_GPU>;
+		clocks = <&cru ACLK_GPU>;
+	};
+
+	/* HEVC AXI clocks */
+	pd_hevc {
+		reg = <RK3288_PD_HEVC>;
+		clocks = <&cru ACLK_HEVC>,
+		<&cru SCLK_HEVC_CABAC>,
+		<&cru SCLK_HEVC_CORE>,
+		<&cru HCLK_HEVC>;
+	};
+
+	/*
+	 * RGA, VOP, MIPI, LVDS, EDP..., says the ACLK* on the ACLK_VIO_NIU,
+	 * others are on the HCLK_VIO_NIU.
+	 */
+	pd_vio {
+		reg = <RK3288_PD_VIO>;
+		clocks = <&cru ACLK_IEP>,
+		<&cru ACLK_ISP>,
+		<&cru ACLK_RGA>,
+		<&cru ACLK_VIP>,
+		<&cru ACLK_VOP0>,
+		<&cru ACLK_VOP1>,
+		<&cru DCLK_VOP0>,
+		<&cru DCLK_VOP1>,
+		<&cru HCLK_IEP>,
+		<&cru HCLK_ISP>,
+		<&cru HCLK_RGA>,
+		<&cru HCLK_VIP>,
+		<&cru HCLK_VOP0>,
+		<&cru HCLK_VOP1>,
+		<&cru PCLK_EDP_CTRL>,
+		<&cru PCLK_HDMI_CTRL>,
+		<&cru PCLK_LVDS_PHY>,
+		<&cru PCLK_MIPI_CSI>,
+		<&cru PCLK_MIPI_DSI0>,
+		<&cru PCLK_MIPI_DSI1>,
+		<&cru SCLK_EDP_24M>,
+		<&cru SCLK_EDP>,
+		<&cru SCLK_ISP_JPE>,
+		<&cru SCLK_ISP>,
+		<&cru SCLK_RGA>;
+	};
+
+	/*
+	 * Video's ACLK_VCODEC on the ACLK_VCODEC_NIU, Video's HCLK_VCODEC,
+	 * on the HCLK_VCODEC_NIU.
+	 */
+	pd_video {
+		reg = <RK3288_PD_VIDEO>;
+		clocks = <&cru ACLK_VCODEC>,
+		<&cru HCLK_VCODEC>;
+	};
#3 lore raw

Re: [PATCH v17 1/4] dt-bindings: add document of Rockchip power domains

Kevin,

? 2015?09?03? 02:12, Kevin Hilman ??:

Quoted 103 lines
Quoted 101 lines · Caesar Wang

This add the necessary binding documentation for the power domains found on Rockchip SoCs.

---

Changes in v17:
- add the decription in detail for RK3288 SoCs.

Changes in v16:
- remove the pmu node.

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9:
- add document decription.

Changes in v8:
- document go back to v2.

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- DT structure has changed.

Changes in v2:
- move clocks to "optional".

  .../bindings/soc/rockchip/power_domain.txt         | 114 +++++++++++++++++++++
  1 file changed, 114 insertions(+)

create mode 100644 Documentation/devicetree/bindings/soc/rockchip/power_domain.txt

diff --git a/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt b/Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file mode 100644
index 0000000..4cf6b27

Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +53 -0
@@ -0,0 +1,114 @@
+* Rockchip Power Domains
+
+Rockchip processors include support for multiple power domains which can be
+powered up/down by software based on different application scenes to save power.
+
+Required properties for power domain controller:
+- compatible: Should be one of the following.
+	"rockchip,rk3288-power-controller" - for RK3288 SoCs.
+- #power-domain-cells: Number of cells in a power-domain specifier.
+	Should be 1 for multiple PM domains.
+- #address-cells: Should be 1.
+- #size-cells: Should be 0.
+
+Required properties for power domain sub nodes:
+- reg: index of the power domain, should use macros in:
+	"include/dt-bindings/power-domain/rk3288.h" - for RK3288 type power domain.
+- clocks (optional): phandles to clocks which need to be enabled while power domain
+	switches state.
+
+Example:
+
+	power: power-controller {
+		compatible = "rockchip,rk3288-power-controller";
+		#power-domain-cells = <1>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		pd_gpu {
+			reg = <RK3288_PD_GPU>;
+			clocks = <&cru ACLK_GPU>;
+		};
+	};
+
+Node of a device using power domains must have a power-domains property,
+containing a phandle to the power device node and an index specifying which
+power domain to use.
+The index should use macros in:
+	"include/dt-bindings/power-domain/rk3288.h" - for rk3288 type power domain.
+
+Example of the node using power domain:
+
+	node {
+		/* ... */
+		power-domains = <&power RK3288_PD_GPU>;
+		/* ... */
+	};
+
+Others, all the device clocks being listed in the power-domains itself.
+All the device clocks are included in someone domians that need to enable
+before you operate them.
+
+As the chip designs for PM hardware. We need turn on the noc clocks,
+if we are operating the "pd_vio" domain to enter the idle status.
Quoted 8 lines

Documentation/devicetree/bindings/soc/rockchip/power_domain.txt line 56

Quoted 3 lines
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +3 -0
+
+As the following described in detail for every device be included in domains
+on RK3288 SoCs.

IMO, the below isn't really detailed enough, and also, the details should be in the .dts file itself, not in the binding doc. In particular, it's not obvious from the current series which of the clocks are device clocks, and which are other/parent/infrastructure clocks needed for the synchronous reset.

Okay, if we add some comments in dts. Says the following example.

What do you think of it?

I'm no sure if we should add these comments in dts.
It looks like it's always awkward. We can explain in the binding doc, maybe for better reading.

             /*
              * Note: 'ACLK_GPU' is the GPU clock,
              * and on the ACLK_GPU_NIU (NOC).
              */
             pd_gpu {
                 reg = <RK3288_PD_GPU>;
                 clocks = <&cru ACLK_GPU>;
             };

             /*
              * Note: The following 3 are HEVC(H.265) clocks,
              * and on the ACLK_HEVC_NIU (NOC).
              */
             pd_hevc {
                 reg = <RK3288_PD_HEVC>;
                 clocks = <&cru ACLK_HEVC>,
                 <&cru SCLK_HEVC_CABAC>,
                 <&cru SCLK_HEVC_CORE>;
             };

             /*
              * Note: ACLK_VCODEC/HCLK_VCODEC are VCODEC
              * (video endecoder & decoder) clocks that on the
              * ACLK_VCODEC_NIU and HCLK_VCODEC_NIU (NOC).
               */
             pd_video {
                 reg = <RK3288_PD_VIDEO>;
                 clocks = <&cru ACLK_VCODEC>,
                 <&cru HCLK_VCODEC>;
             };

             /*
              * Note: Although SCLK_* are the working clocks
              * of device without including on the NOC, needed for
              * synchronous reset.
              *
              * ACLK_IEP/ACLK_VIP/ACLK_VOP0 are on ACLK_VIO0_NIU (NOC).
              * ACLK_ISP/ACLK_VOP1 are on ACLK_VIO1_NIU (NOC).
               * ACLK_RGA is on ACLK_RGA_NIU (NOC).
              * The others are on HCLK_VIO_NIU (NOC).
              *
              * *_IEP are the Image Enhancement Processos (IEP) clocks.
              * *_ISP are the Image Signal Processing (ISP) clocks.
              * *_RGA are the RGA clocks.
              * *_VOP* are the Visual Output Processor(VOP) clocks.
              * *_EDP* are the EDP clocks.
              * *_LVDS_* are the LVDS clocks.
              * *_HDMI are the HDMI clocks.
              * *_MIPI_* are the MIPI clocks.
              */
             pd_vio {
                 reg = <RK3288_PD_VIO>;
                 clocks = <&cru ACLK_IEP>,
                 <&cru ACLK_ISP>,
                 <&cru ACLK_RGA>,
                 <&cru ACLK_VIP>,
                 <&cru ACLK_VOP0>,
                 <&cru ACLK_VOP1>,
                 <&cru DCLK_VOP0>,
                 <&cru DCLK_VOP1>,
                 <&cru HCLK_IEP>,
                 <&cru HCLK_ISP>,
                 <&cru HCLK_RGA>,
                 <&cru HCLK_VIP>,
                 <&cru HCLK_VOP0>,
                 <&cru HCLK_VOP1>,
                 <&cru PCLK_EDP_CTRL>,
                 <&cru PCLK_HDMI_CTRL>,
                 <&cru PCLK_LVDS_PHY>,
                 <&cru PCLK_MIPI_CSI>,
                 <&cru PCLK_MIPI_DSI0>,
                 <&cru PCLK_MIPI_DSI1>,
                 <&cru SCLK_EDP_24M>,
                 <&cru SCLK_EDP>,
                 <&cru SCLK_ISP_JPE>,
                 <&cru SCLK_ISP>,
                 <&cru SCLK_RGA>;
             };

---
Thanks,
Caesar

Quoted 63 lines

Kevin

Quoted 47 lines
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +47 -0
+	/* GPU's ACLK_GPU on the ACLK_GPU_NIU */
+	pd_gpu {
+		reg = <RK3288_PD_GPU>;
+		clocks = <&cru ACLK_GPU>;
+	};
+
+	/* HEVC AXI clocks */
+	pd_hevc {
+		reg = <RK3288_PD_HEVC>;
+		clocks = <&cru ACLK_HEVC>,
+		<&cru SCLK_HEVC_CABAC>,
+		<&cru SCLK_HEVC_CORE>,
+		<&cru HCLK_HEVC>;
+	};
+
+	/*
+	 * RGA, VOP, MIPI, LVDS, EDP..., says the ACLK* on the ACLK_VIO_NIU,
+	 * others are on the HCLK_VIO_NIU.
+	 */
+	pd_vio {
+		reg = <RK3288_PD_VIO>;
+		clocks = <&cru ACLK_IEP>,
+		<&cru ACLK_ISP>,
+		<&cru ACLK_RGA>,
+		<&cru ACLK_VIP>,
+		<&cru ACLK_VOP0>,
+		<&cru ACLK_VOP1>,
+		<&cru DCLK_VOP0>,
+		<&cru DCLK_VOP1>,
+		<&cru HCLK_IEP>,
+		<&cru HCLK_ISP>,
+		<&cru HCLK_RGA>,
+		<&cru HCLK_VIP>,
+		<&cru HCLK_VOP0>,
+		<&cru HCLK_VOP1>,
+		<&cru PCLK_EDP_CTRL>,
+		<&cru PCLK_HDMI_CTRL>,
+		<&cru PCLK_LVDS_PHY>,
+		<&cru PCLK_MIPI_CSI>,
+		<&cru PCLK_MIPI_DSI0>,
+		<&cru PCLK_MIPI_DSI1>,
+		<&cru SCLK_EDP_24M>,
+		<&cru SCLK_EDP>,
+		<&cru SCLK_ISP_JPE>,
+		<&cru SCLK_ISP>,
+		<&cru SCLK_RGA>;
+	};

Documentation/devicetree/bindings/soc/rockchip/power_domain.txt line 114

Quoted 10 lines
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +10 -0
+
+	/*
+	 * Video's ACLK_VCODEC on the ACLK_VCODEC_NIU, Video's HCLK_VCODEC,
+	 * on the HCLK_VCODEC_NIU.
+	 */
+	pd_video {
+		reg = <RK3288_PD_VIDEO>;
+		clocks = <&cru ACLK_VCODEC>,
+		<&cru HCLK_VCODEC>;
+	};

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#4 lore raw

PATCH v17 2/4 ARM: power-domain: rockchip: add all the domain type on RK3288 SoCs

In reply to Caesar Wang

According to a description from TRM, add all the power domains.

At the moment, we can support some domains on RK3288. We can add more types on RK3288 in the future, that's need to do.

---

Changes in v17:
- delete the ugly chart in the commit.

Changes in v16:
- Add more domain decription.

Changes in v15:
- change the comment.

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/dt-bindings/power-domain/rk3288.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
include/dt-bindings/power-domain/rk3288.h new file +31 -0
new file mode 100644
index 0000000..db5e810
@@ -0,0 +1,31 @@
+#ifndef __DT_BINDINGS_POWER_DOMAIN_RK3288_H__
+#define __DT_BINDINGS_POWER_DOMAIN_RK3288_H__
+
+/**
+ * RK3288 Power Domain and Voltage Domain Summary.
+ */
+
+/* VD_CORE */
+#define RK3288_PD_A17_0		0
+#define RK3288_PD_A17_1		1
+#define RK3288_PD_A17_2		2
+#define RK3288_PD_A17_3		3
+#define RK3288_PD_SCU		4
+#define RK3288_PD_DEBUG		5
+#define RK3288_PD_MEM		6
+
+/* VD_LOGIC */
+#define RK3288_PD_BUS		7
+#define RK3288_PD_PERI		8
+#define RK3288_PD_VIO		9
+#define RK3288_PD_ALIVE		10
+#define RK3288_PD_HEVC		11
+#define RK3288_PD_VIDEO		12
+
+/* VD_GPU */
+#define RK3288_PD_GPU		13
+
+/* VD_PMU */
+#define RK3288_PD_PMU		14
+
+#endif
Signature · 1 line
1.9.1
#5 lore raw

PATCH v17 3/4 soc: rockchip: power-domain: Add power domain driver

In reply to Caesar Wang

This driver is found on RK3288 SoCs.

In order to meet high performance and low power requirements, a power management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power of the whole chip.

PMU can work in the Low Power Mode by setting bit[0] of PMU_PWRMODE_CON register. After setting the register, PMU would enter the Low Power mode. In the low power mode, pmu will auto power on/off the specified power domain, send idle req to specified power domain, shut down/up pll and so on. All of above are configurable by setting corresponding registers.

---

Changes in v17:
- (re)defining config for ROCKCHIP.

Changes in v16:
- the driver type from tristate to bool.
- Letter misspelled.
- As Ulf suggestion, remove #include <linux/clk-provider.h>, use "%pC" as the formatting string for the dev_dbg().
- As the Ulf suggestion, set the genpd->flags to assign the ->stop|start() callbacks.

Changes in v15:
- As the kevin suggestion, put the power-domain driver into driver/soc/vendor.
- As Heiko suggestion, Patch 1: binding doc, 2: binding-header, 3: driver, 4: dts-changes.
- return -ENXIO --> return -ENODEV.

Changes in v14:
- does not need to set an owner,remove the "THIS_MODULE".

Changes in v13:
- Remove essential clocks from rk3288 PD_VIO domain Some clocks are essential for the system health and should not be turned down. However there is no owner for them so if they listed as belonging to power domain we'll try toggling them up and down during power domain.
- Device drivers expect their devices to be powered on before their probing code is invoked. To achieve that we should start with power domains powered on (we may turn them off later once all devices enable runtime powermanagment and go idle).
- This change switches Rockchip power domain driver to use updated device_attach and device_detach API.
- set the gpu/core power domain power delay time.
- fix enumerating PM clocks for devices.
- fix use after free We can't use clk after we did clk_put(clk).

Changes in v12:
- fix the title doamin->domain.
- updated device_attach and device_detach API,otherwise it will compile fail on next kernel.

Changes in v11:
- fix pm_genpd_init(&pd->genpd, NULL, false).

Changes in v10:
- this switches over domain infos to use masks instead of recomputing them each time and also gets rid of custom domain translator and uses standard onecell on.

Changes in v9:
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain have lists of clocks they trigger on and off during power transitions and independently from power domains clocks. We attach clocks to devices comprising power domain and prepare them so they are turn on and off by runtime PM.
- add rockchip_pm_add_one_domain() to control domains.
- add pd_start/pd_stop interface to control clocks.

Changes in v8:
- This reconciles the v2 and v7 code so that we power domain have lists of clocks they toggle on and off during power transitions and independently from power domains clocks we attach clocks to devices comprising power domain and prepare them so they are turn on and off by runtime PM.

Changes in v7:
- Delete unused variables

Changes in v6:
- delete pmu_lock.
- modify dev_lock using mutex.
- pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev).
- pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev).
- add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev.

Changes in v5:
- delete idle_lock.
- add timeout in rockchip_pmu_set_idle_request().

Changes in v4:
- use list storage dev.

Changes in v3:
- change use pm_clk_resume() and pm_clk_suspend().

Changes in v2:
- remove the "pd->pd.of_node = np".

 drivers/soc/Kconfig               |   1 +
 drivers/soc/Makefile              |   1 +
 drivers/soc/rockchip/Kconfig      |  14 ++
 drivers/soc/rockchip/Makefile     |   4 +
 drivers/soc/rockchip/pm_domains.c | 485 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 505 insertions(+)
 create mode 100644 drivers/soc/rockchip/Kconfig
 create mode 100644 drivers/soc/rockchip/Makefile
 create mode 100644 drivers/soc/rockchip/pm_domains.c
drivers/soc/Kconfig +1 -0
index 96ddecb..ecb1a6c 100644
@@ -2,6 +2,7 @@ menu "SOC (System On Chip) specific Drivers"
 
 source "drivers/soc/mediatek/Kconfig"
 source "drivers/soc/qcom/Kconfig"
+source "drivers/soc/rockchip/Kconfig"
 source "drivers/soc/sunxi/Kconfig"
 source "drivers/soc/ti/Kconfig"
 source "drivers/soc/versatile/Kconfig"
drivers/soc/Makefile +1 -0
index 0b12d77..c2b485f 100644
@@ -5,6 +5,7 @@
 obj-$(CONFIG_MACH_DOVE)		+= dove/
 obj-$(CONFIG_ARCH_MEDIATEK)	+= mediatek/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip/
 obj-$(CONFIG_ARCH_SUNXI)	+= sunxi/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-$(CONFIG_SOC_TI)		+= ti/
drivers/soc/rockchip/Kconfig new file +14 -0
new file mode 100644
index 0000000..6ee0399
@@ -0,0 +1,14 @@
+#
+# Rockchip Soc drivers
+#
+config ROCKCHIP_PM_DOMAINS
+        bool "Rockchip generic power domain"
+        depends on PM
+        select PM_GENERIC_DOMAINS
+        help
+          Say y here to enable power domain support.
+          In order to meet high performance and low power requirements, a power
+          management unit is designed or saving power when RK3288 in low power
+          mode. The RK3288 PMU is dedicated for managing the power of the whole chip.
+
+          If unsure, say N.
drivers/soc/rockchip/Makefile new file +4 -0
new file mode 100644
index 0000000..3d73d06
@@ -0,0 +1,4 @@
+#
+# Rockchip Soc drivers
+#
+obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
drivers/soc/rockchip/pm_domains.c new file +485 -0

485 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

Re: [PATCH v17 3/4] soc: rockchip: power-domain: Add power domain driver

Quoted 15 lines · Caesar Wang

This driver is found on RK3288 SoCs.

In order to meet high performance and low power requirements, a power management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power of the whole chip.

PMU can work in the Low Power Mode by setting bit[0] of PMU_PWRMODE_CON register. After setting the register, PMU would enter the Low Power mode. In the low power mode, pmu will auto power on/off the specified power domain, send idle req to specified power domain, shut down/up pll and so on. All of above are configurable by setting corresponding registers.

[...]

drivers/soc/rockchip/pm_domains.c line 322

Quoted 8 lines
drivers/soc/rockchip/pm_domains.c new file +8 -0
+static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd)
+{
+	int i;
+
+	for (i = 0; i < pd->num_clks; i++) {
+		clk_unprepare(pd->clks[i]);
+		clk_put(pd->clks[i]);
+	}

You don't set pd->num_clks = 0 here, which means other places that iterate over the clocks might race with this and try to use clocks that have been unprepared/put.

This might be over-paranoid, but in particular, this could race with rockchip_pd_power().

Also not setting the pd->num_clks to zero would be a problem for a power-controller that is configured as a module which could be unloaded and reloaded (I know that doesn't really work now, but it will eventually, I hope.)

Maybe use the mutex here? It should at least protect the zeroing of pm->num_clks.

Kevin

#7 lore raw

Re: [PATCH v17 3/4] soc: rockchip: power-domain: Add power domain driver

Kevin,

Thanks for having a look into it.

? 2015?09?03? 02:28, Kevin Hilman ??:

Quoted 19 lines
Quoted 15 lines · Caesar Wang

This driver is found on RK3288 SoCs.

In order to meet high performance and low power requirements, a power management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power of the whole chip.

PMU can work in the Low Power Mode by setting bit[0] of PMU_PWRMODE_CON register. After setting the register, PMU would enter the Low Power mode. In the low power mode, pmu will auto power on/off the specified power domain, send idle req to specified power domain, shut down/up pll and so on. All of above are configurable by setting corresponding registers.

[...]

Quoted 12 lines

drivers/soc/rockchip/pm_domains.c line 322

Quoted 8 lines
drivers/soc/rockchip/pm_domains.c new file +8 -0
+static void rockchip_pm_remove_one_domain(struct rockchip_pm_domain *pd)
+{
+	int i;
+
+	for (i = 0; i < pd->num_clks; i++) {
+		clk_unprepare(pd->clks[i]);
+		clk_put(pd->clks[i]);
+	}

You don't set pd->num_clks = 0 here, which means other places that iterate over the clocks might race with this and try to use clocks that have been unprepared/put.

Agree, we should set the "pd->num_cloks=0' in here.

Quoted 7 lines

This might be over-paranoid, but in particular, this could race with rockchip_pd_power().

Also not setting the pd->num_clks to zero would be a problem for a power-controller that is configured as a module which could be unloaded and reloaded (I know that doesn't really work now, but it will eventually, I hope.)

Yep.

Quoted 3 lines

Maybe use the mutex here? It should at least protect the zeroing of pm->num_clks.

Sound resonable.
Done.

---
Thanks,
Caesar

Quoted 7 lines

Kevin

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#8 lore raw

PATCH v17 4/4 ARM: dts: add the support power-domain node on RK3288 SoCs

In reply to Caesar Wang

We can add more domains node in the future.
This patch add the needed clocks into power-controller. As the discuess about all the device clocks being listed in the power-domains itself.

There are several reasons as follows:

Firstly, the clocks need be turned off to save power when the system enter the suspend state. So we need to enumerate the clocks in the dts. In order to power domain can turn on and off.

Secondly, the reset-circuit should reset be synchronous on RK3288, then sync revoked. So we need to enable clocks of all devices. In other words, we have to enable the clocks before you operate them if all the device clocks are included in someone domians.

Thirdly, as the chip designs for PM hardhare. we need turn on the noc clocks, if we are operating the "pd_vio" domain to enter the idle status. The device's clock be included in domains that needed turn on if do that.

The clocks in the dts are needed to enable before you want to happy work. At the moment, This patch is very good work for PM hardware.

Also, we can add it in the future if we have some hidden clocks.

---

Changes in v17:
- remove clocks of the HDMI ctrl.
- update the description.
- add Reviewed-by: Michale.

Changes in v16:
- Manually copy the problem in patch v15.
- rebase the description.

Changes in v15:
- As Tomasz remarked previously the dts should represent the hardware and the power-domains are part of the pmu.

Changes in v14:
- Remove essential clocks from rk3288 PD_VIO domain, Some clocks are essential for the system health and should not be turned down. However there is no owner for them so if they listed as belonging to power domain we'll try toggling them up and down during power domain transition. As a result we either fail to suspend or resume the system.

Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10:
- fix missing the #include <dt-bindings/power-domain/rk3288.h>.
- remove the notes.

Changes in v9:
- add decription for power-doamin node.

Changes in v8:
- DTS go back to v2.

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3:
- Decomposition power-controller, changed to multiple controller (gpu-power-controller, hevc-power-controller).

Changes in v2:
- make pd_vio clocks all one entry per line and alphabetize.
- power: power-controller move back to pinctrl: pinctrl.

 arch/arm/boot/dts/rk3288.dtsi | 58 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)
arch/arm/boot/dts/rk3288.dtsi +57 -1
index 906e938..4ce3099 100644
@@ -44,6 +44,7 @@
 #include <dt-bindings/pinctrl/rockchip.h>
 #include <dt-bindings/clock/rk3288-cru.h>
 #include <dt-bindings/thermal/thermal.h>
+#include <dt-bindings/power-domain/rk3288.h>
 #include "skeleton.dtsi"
 
 / {
@@ -613,8 +614,63 @@
 	};
 
 	pmu: power-management at ff730000 {
-		compatible = "rockchip,rk3288-pmu", "syscon";
+		compatible = "rockchip,rk3288-pmu", "syscon", "simple-mfd";
 		reg = <0xff730000 0x100>;
+
+		power: power-controller {
+			compatible = "rockchip,rk3288-power-controller";
+			#power-domain-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			pd_gpu {
+				reg = <RK3288_PD_GPU>;
+				clocks = <&cru ACLK_GPU>;
+			};
+
+			pd_hevc {
+				reg = <RK3288_PD_HEVC>;
+				clocks = <&cru ACLK_HEVC>,
+					 <&cru SCLK_HEVC_CABAC>,
+					 <&cru SCLK_HEVC_CORE>,
+					 <&cru HCLK_HEVC>;
+			};
+
+			pd_vio {
+				reg = <RK3288_PD_VIO>;
+				clocks = <&cru ACLK_IEP>,
+					 <&cru ACLK_ISP>,
+					 <&cru ACLK_RGA>,
+					 <&cru ACLK_VIP>,
+					 <&cru ACLK_VOP0>,
+					 <&cru ACLK_VOP1>,
+					 <&cru DCLK_VOP0>,
+					 <&cru DCLK_VOP1>,
+					 <&cru HCLK_IEP>,
+					 <&cru HCLK_ISP>,
+					 <&cru HCLK_RGA>,
+					 <&cru HCLK_VIP>,
+					 <&cru HCLK_VOP0>,
+					 <&cru HCLK_VOP1>,
+					 <&cru PCLK_EDP_CTRL>,
+					 <&cru PCLK_HDMI_CTRL>,
+					 <&cru PCLK_LVDS_PHY>,
+					 <&cru PCLK_MIPI_CSI>,
+					 <&cru PCLK_MIPI_DSI0>,
+					 <&cru PCLK_MIPI_DSI1>,
+					 <&cru SCLK_EDP_24M>,
+					 <&cru SCLK_EDP>,
+					 <&cru SCLK_ISP_JPE>,
+					 <&cru SCLK_ISP>,
+					 <&cru SCLK_RGA>;
+			};
+
+			pd_video {
+				reg = <RK3288_PD_VIDEO>;
+				clocks = <&cru ACLK_VCODEC>,
+					 <&cru HCLK_VCODEC>;
+			};
+		};
 	};
 
 	sgrf: syscon at ff740000 {
Signature · 1 line
1.9.1