Skip to contentSkip to conversation

ARM: rk3288: Add PM Domain support

PATCH Superseded Caesar Wang 2 participants 7 messages Jun 14, 2015 – Jun 16, 2015

Subsystems (2)

v15 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
#0 lore raw

v15 cover ARM: rk3288: Add PM Domain support

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

Verified on url =
https://chromium.googlesource.com/chromiumos/third_party/kernel/+/v3.14

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";
};

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/?h=simple-mfd&id=fcf294c020ff7ee4e3b1e96159e4dc7a17ad59d1

Here is my branch:

9c402ee ARM: dts: add RK3288 power-domain node
b1469c4 power-domain: rockchip: add power domain driver
ce13318 ARM: power-domain: rockchip: add the support type for the rk3288
9824091 dt-bindings: add document of Rockchip power domain
0ff0e5b MFD/OF: document MFD devices and handle simple-mfd
2bfc60d Merge tag 'misc-for-linus-4.1-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
...

Note:

Sorry for long no any update.

As I known, there are somethings needed to do.
(1) about all the device clocks being listed in the power-domains itself, Someone wish was to get the clocks by reading the clocks from the device nodes,

Perhaps, this series patchs are hard to be accepted or need to do more can be accepted.

At the moment, I send the patch v15 to discuss the issue, This patch no any sloved the pervious issue.

Changes in v15:
- change the comment.
- As the kevin suggestion, put the power-doamin driver into driver/soc/vendor.
- As Heiko suggestion, Patch 1: binding doc, 2: binding-header, 3: driver, 4: dts-changes.
- return -ENXIO --> return -ENODEV.
Series-changes: 14
- does not need to set an owner,remove the "THIS_MODULE".
Series-changes: 13
- 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).
Series-changes: 12
- fix the title doamin->domain.
- updated device_attach and device_detach API,otherwise it will compile fail on next kernel.
Series-changes: 11
- fix pm_genpd_init(&pd->genpd, NULL, false).
Series-changes: 10
- 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.
Series-changes: 9
- 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.
Series-changes: 8
- 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.
Series-changes: 7
- Delete unused variables
Series-changes: 6
- 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.
Series-changes: 5
- delete idle_lock.
- add timeout in rockchip_pmu_set_idle_request().
Series-changes: 4
- use list storage dev.
Series-changes: 3
- change use pm_clk_resume() and pm_clk_suspend().
Series-changes: 2
- remove the "pd->pd.of_node = np".
- As Tomasz remarked previously the dts should represent the hardware and the power-domains are part of the pmu.
Series-changes: 12
- 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.
Series-changes: 10
- fix missing the #include <dt-bindings/power-domain/rk3288.h>.
- remove the notes.
Series-changes: 9
- add decription for power-doamin node.
Series-changes: 8
- DTS go back to v2.
Series-changes: 3
- Decomposition power-controller, changed to multiple controller (gpu-power-controller, hevc-power-controller).
Series-changes: 2
- make pd_vio clocks all one entry per line and alphabetize.
- power: power-controller move back to pinctrl: pinctrl.

Changes in v9:
- add document decription.
Series-changes:8
- document go back to v2.
Series-changes:3
- DT structure has changed.
Series-changes:2
- move clocks to "optional".

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

 .../bindings/soc/rockchip/power_domain.txt         |  48 ++
 arch/arm/boot/dts/rk3288.dtsi                      |  62 +++
 drivers/soc/Kconfig                                |   1 +
 drivers/soc/Makefile                               |   1 +
 drivers/soc/rockchip/Kconfig                       |  13 +
 drivers/soc/rockchip/Makefile                      |   4 +
 drivers/soc/rockchip/pm_domains.c                  | 506 +++++++++++++++++++++
 include/dt-bindings/power-domain/rk3288.h          |  11 +
 8 files changed, 646 insertions(+)
 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 v15 1/4 dt-bindings: add document of Rockchip power domain

This add the necessary binding documentation for the power domain found on Rockchip Socs.

---

Changes in v15: None
Changes in v9:
- add document decription.
Series-changes:8
- document go back to v2.
Series-changes:3
- DT structure has changed.
Series-changes:2
- move clocks to "optional".

 .../bindings/soc/rockchip/power_domain.txt         | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt new file +48 -0
new file mode 100644
index 0000000..3e74e6d
@@ -0,0 +1,48 @@
+* 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 type power domain.
+- #power-domain-cells: Number of cells in a power-domain specifier.
+		       should be 1.
+- rockchip,pmu: phandle referencing a syscon providing the pmu registers
+- #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>;
+	       rockchip,pmu = <&pmu>;
+               #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>;
+		/* ... */
+	};
Signature · 1 line
1.9.1
#2 lore raw

PATCH v15 2/4 ARM: power-domain: rockchip: add the support type on RK3288

In reply to Caesar Wang

At the moment, we can support these power-domain type on RK3288. We can add more types on RK3288 in the future, that's need to do.

---

Changes in v15:
- change the comment.

Changes in v9: None

 include/dt-bindings/power-domain/rk3288.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
include/dt-bindings/power-domain/rk3288.h new file +11 -0
new file mode 100644
index 0000000..ca68c11
@@ -0,0 +1,11 @@
+#ifndef __DT_BINDINGS_POWER_DOMAIN_RK3288_H__
+#define __DT_BINDINGS_POWER_DOMAIN_RK3288_H__
+
+/* RK3288 power domain index */
+#define RK3288_PD_GPU          0
+#define RK3288_PD_VIO          1
+#define RK3288_PD_VIDEO        2
+#define RK3288_PD_HEVC         3
+#define RK3288_PD_PERI         4
+
+#endif
Signature · 1 line
1.9.1
#3 lore raw

PATCH v15 3/4 soc: rockchip: power-domain: add power domain driver

In reply to Caesar Wang

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 ot the whole chip.

---

Changes in v15:
- As the kevin suggestion, put the power-doamin driver into driver/soc/vendor.
- As Heiko suggestion, Patch 1: binding doc, 2: binding-header, 3: driver, 4: dts-changes.
- return -ENXIO --> return -ENODEV.
Series-changes: 14
- does not need to set an owner,remove the "THIS_MODULE".
Series-changes: 13
- 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).
Series-changes: 12
- fix the title doamin->domain.
- updated device_attach and device_detach API,otherwise it will compile fail on next kernel.
Series-changes: 11
- fix pm_genpd_init(&pd->genpd, NULL, false).
Series-changes: 10
- 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.
Series-changes: 9
- 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.
Series-changes: 8
- 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.
Series-changes: 7
- Delete unused variables
Series-changes: 6
- 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.
Series-changes: 5
- delete idle_lock.
- add timeout in rockchip_pmu_set_idle_request().
Series-changes: 4
- use list storage dev.
Series-changes: 3
- change use pm_clk_resume() and pm_clk_suspend().
Series-changes: 2
- remove the "pd->pd.of_node = np".

Changes in v9: None

 drivers/soc/Kconfig               |   1 +
 drivers/soc/Makefile              |   1 +
 drivers/soc/rockchip/Kconfig      |  13 +
 drivers/soc/rockchip/Makefile     |   4 +
 drivers/soc/rockchip/pm_domains.c | 506 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 525 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 d8bde82..e897c0ca 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/ti/Kconfig"
 source "drivers/soc/versatile/Kconfig"
 
drivers/soc/Makefile +1 -0
index 70042b2..91f7f18 100644
@@ -4,6 +4,7 @@
 
 obj-$(CONFIG_ARCH_MEDIATEK)	+= mediatek/
 obj-$(CONFIG_ARCH_QCOM)		+= qcom/
+obj-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip/
 obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
 obj-$(CONFIG_SOC_TI)		+= ti/
 obj-$(CONFIG_PLAT_VERSATILE)	+= versatile/
drivers/soc/rockchip/Kconfig new file +13 -0
new file mode 100644
index 0000000..5a7af4c
@@ -0,0 +1,13 @@
+#
+# Rockchip Soc drivers
+#
+config PM_GENERIC_DOMAINS
+        tristate "Rockchip generic power domain"
+        depends on PM
+        help
+          Say y here to enable power doamin 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 ot the whole chip.
+
+          If unsure, say N.
drivers/soc/rockchip/Makefile new file +4 -0
new file mode 100644
index 0000000..1c0fd91
@@ -0,0 +1,4 @@
+#
+# Rockchip Soc drivers
+#
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
drivers/soc/rockchip/pm_domains.c new file +506 -0

506 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH v15 3/4] soc: rockchip: power-domain: add power domain driver

drivers/soc/rockchip/Kconfig line 5

Quoted 5 lines · Caesar Wang
drivers/soc/rockchip/Kconfig new file +2 -0
 
+config PM_GENERIC_DOMAINS
+        tristate "Rockchip generic power domain"

Since my remarks on v13 you removed the module specific code from pm_domains.c. But now this became a tristate symbol. That makes little sense. Why didn't you keep bool?

drivers/soc/rockchip/Kconfig line 8

Quoted 3 lines
drivers/soc/rockchip/Kconfig new file +3 -0
+        depends on PM
+        help
+          Say y here to enable power doamin support.

s/doamin/domain/.

drivers/soc/rockchip/Kconfig line 11

Quoted 3 lines
drivers/soc/rockchip/Kconfig new file +3 -0
+          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 ot the whole chip.

s/ot/of/

Quoted 1 line

+ If unsure, say N.

Thanks,

Paul Bolle

#5 lore raw

Re: [PATCH v15 3/4] soc: rockchip: power-domain: add power domain driver

? 2015?06?15? 23:00, Paul Bolle ??:

Quoted 9 lines · Caesar Wang

drivers/soc/rockchip/Kconfig line 5

Quoted 5 lines
drivers/soc/rockchip/Kconfig new file +2 -0
+config PM_GENERIC_DOMAINS
+        tristate "Rockchip generic power domain"

Since my remarks on v13 you removed the module specific code from pm_domains.c. But now this became a tristate symbol. That makes little sense. Why didn't you keep bool?

Yeah, you are right. :s/tristate/bool

I forget it when the driver is moving from 'arch/arm/mach-rockchip/' to '/driver/soc/rockchip/'.

Quoted 5 lines

drivers/soc/rockchip/Kconfig line 8

Quoted 4 lines
drivers/soc/rockchip/Kconfig new file +3 -0
+        depends on PM
+        help
+          Say y here to enable power doamin support.

s/doamin/domain/.

Done.

Quoted 4 lines

drivers/soc/rockchip/Kconfig line 11

Quoted 3 lines
drivers/soc/rockchip/Kconfig new file +3 -0
+          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 ot the whole chip.

s/ot/of/

Done.

Quoted 5 lines
Quoted 1 line

+ If unsure, say N.

Thanks,

Paul Bolle

Thanks,

Caesar

Quoted 3 lines
Signature · 2 lines
Thanks,
- Caesar
#6 lore raw

PATCH v15 4/4 ARM: dts: add RK3288 power-domain node

In reply to Caesar Wang

This patch add the needed clocks into power-controller.

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.

---

Changes in v15:
- As Tomasz remarked previously the dts should represent the hardware and the power-domains are part of the pmu.
Series-changes: 12
- 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.
Series-changes: 10
- fix missing the #include <dt-bindings/power-domain/rk3288.h>.
- remove the notes.
Series-changes: 9
- add decription for power-doamin node.
Series-changes: 8
- DTS go back to v2.
Series-changes: 3
- Decomposition power-controller, changed to multiple controller (gpu-power-controller, hevc-power-controller).
Series-changes: 2
- make pd_vio clocks all one entry per line and alphabetize.
- power: power-controller move back to pinctrl: pinctrl.

Changes in v9: None

 arch/arm/boot/dts/rk3288.dtsi | 62 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +62 -0
index 165968d..8224070 100644
@@ -550,6 +550,68 @@
 	pmu: power-management at ff730000 {
 		compatible = "rockchip,rk3288-pmu", "syscon";
 		reg = <0xff730000 0x100>;
+
+		pmu: power-management at ff730000 {
+		compatible = "rockchip,rk3288-pmu", "syscon", "simple-mfd";
+		reg = <0xff730000 0x100>;
+
+		power: power-controller {
+			compatible = "rockchip,rk3288-power-controller";
+			#power-domain-cells = <1>;
+			rockchip,pmu = <&pmu>;
+			#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_HDMI_CEC>,
+					 <&cru SCLK_HDMI_HDCP>,
+					 <&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