Skip to contentSkip to conversation

ARM: rk3288: Add PM Domain support

PATCH Superseded Caesar Wang 2 participants 6 messages Apr 19, 2015 – Apr 20, 2015

Subsystems (4)

v13 of 18 Superseded Latest is v18 →

lore
Share & tools
lore
#0 lore raw

v13 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.

At the moment,there are mass of products are using the driver.
I believe the driver can happy work for next kernel.

Caesar Wang (3):
dt-bindings: add document of Rockchip power domain
power-domain: rockchip: add power domain driver
ARM: dts: add RK3288 power-domain node

 .../bindings/arm/rockchip/power_domain.txt         |  48 ++
 arch/arm/boot/dts/rk3288.dtsi                      |  59 +++
 arch/arm/mach-rockchip/Kconfig                     |   1 +
 arch/arm/mach-rockchip/Makefile                    |   1 +
 arch/arm/mach-rockchip/pm_domains.c                | 509 +++++++++++++++++++++
 include/dt-bindings/power-domain/rk3288.h          |  11 +
 6 files changed, 629 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/rockchip/power_domain.txt
 create mode 100644 arch/arm/mach-rockchip/pm_domains.c
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v13 1/3 dt-bindings: add document of Rockchip power domain

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

---

 .../bindings/arm/rockchip/power_domain.txt         | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/rockchip/power_domain.txt
Documentation/devicetree/bindings/arm/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 v13 2/3 power-domain: rockchip: 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.

---

 arch/arm/mach-rockchip/Kconfig      |   1 +
 arch/arm/mach-rockchip/Makefile     |   1 +
 arch/arm/mach-rockchip/pm_domains.c | 509 ++++++++++++++++++++++++++++++++++++
 3 files changed, 511 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/pm_domains.c
arch/arm/mach-rockchip/Kconfig +1 -0
index ae4eb7c..578206b 100644
@@ -15,6 +15,7 @@ config ARCH_ROCKCHIP
 	select ROCKCHIP_TIMER
 	select ARM_GLOBAL_TIMER
 	select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
+	select PM_GENERIC_DOMAINS if PM
 	help
 	  Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
 	  containing the RK2928, RK30xx and RK31xx series.
arch/arm/mach-rockchip/Makefile +1 -0
index 5c3a9b2..9c902d3 100644
@@ -1,5 +1,6 @@
 CFLAGS_platsmp.o := -march=armv7-a
 
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 obj-$(CONFIG_PM_SLEEP) += pm.o sleep.o
 obj-$(CONFIG_SMP) += headsmp.o platsmp.o
arch/arm/mach-rockchip/pm_domains.c new file +509 -0

509 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

PATCH v13 3/3 ARM: dts: add RK3288 power-domain node

This patch add the needed clocks into power-controller.

why need we do so that?

Firstly, we always be needed turn off clocks to save power when the system enter suspend.So we need to enumerate the clocks are needed to switch power doamin no and off.

Secondly, RK3288 reset circuit should be syncchronous reset and then sync revoked.so we need to enable clocks of all devices.

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 power managment 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:
- 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 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             | 59 +++++++++++++++++++++++++++++++
 include/dt-bindings/power-domain/rk3288.h | 11 ++++++
 2 files changed, 70 insertions(+)
 create mode 100644 include/dt-bindings/power-domain/rk3288.h
arch/arm/boot/dts/rk3288.dtsi +59 -0
index 5999029..f3992db 100644
@@ -15,6 +15,7 @@
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/pinctrl/rockchip.h>
 #include <dt-bindings/clock/rk3288-cru.h>
+#include <dt-bindings/power-domain/rk3288.h>
 #include <dt-bindings/thermal/thermal.h>
 #include "skeleton.dtsi"
 
@@ -1277,4 +1278,62 @@
 			};
 		};
 	};
+
+	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>;
+		};
+	};
 };
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
#4 lore raw

Re: [PATCH v13 2/3] power-domain: rockchip: add power domain driver

In reply to Caesar Wang

arch/arm/mach-rockchip/Makefile

Quoted 2 lines · Caesar Wang
arch/arm/mach-rockchip/Makefile +0 -0

+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o

PM_GENERIC_DOMAINS is a bool symbol, so pm_domains.o can never be part of a module. Is that correct?

arch/arm/mach-rockchip/pm_domains.c

Quoted 4 lines
arch/arm/mach-rockchip/pm_domains.c new file +1 -0
 
+#include <linux/module.h>

This include could probably be dropped.

arch/arm/mach-rockchip/pm_domains.c line 488

Quoted 8 lines
arch/arm/mach-rockchip/pm_domains.c new file +8 -0
+static const struct of_device_id rockchip_pm_domain_dt_match[] = {
+	{
+		.compatible = "rockchip,rk3288-power-controller",
+		.data = (void *)&rk3288_pmu,
+	},
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, rockchip_pm_domain_dt_match);

The MODULE_DEVICE_TABLE() macro will be preprocessed away for built-in code, according to include/linux/module.h.

arch/arm/mach-rockchip/pm_domains.c line 494

Quoted 5 lines
arch/arm/mach-rockchip/pm_domains.c new file +5 -0
+static struct platform_driver rockchip_pm_domain_driver = {
+	.probe = rockchip_pm_domain_probe,
+	.driver = {
+		.name   = "rockchip-pm-domain",
+		.owner  = THIS_MODULE,

According to include/linux/export.h THIS_MODULE is equivalent to NULL for built-in code. So I think this line is not needed.

arch/arm/mach-rockchip/pm_domains.c line 503

Quoted 9 lines
arch/arm/mach-rockchip/pm_domains.c new file +9 -0
+		.of_match_table = rockchip_pm_domain_dt_match,
+		/*
+		 * We can't forcibly eject devices form power domain,
+		 * so we can't really remove power domains once they
+		 * were added.
+		 */
+		.suppress_bind_attrs = true,
+	},
+};

Thanks,

Paul Bolle

#5 lore raw

Re: [PATCH v13 2/3] power-domain: rockchip: add power domain driver

Paul,

Thanks your commnets!:-)

? 2015?04?20? 17:26, Paul Bolle ??:

Quoted 7 lines · Caesar Wang

arch/arm/mach-rockchip/Makefile

Quoted 2 lines
arch/arm/mach-rockchip/Makefile +0 -0

+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o

PM_GENERIC_DOMAINS is a bool symbol, so pm_domains.o can never be part of a module. Is that correct?

Yeah, So this platform_driver does not need to set an owner, it will be populated by the
driver core.

Quoted 5 lines

arch/arm/mach-rockchip/pm_domains.c line 11

Quoted 4 lines
arch/arm/mach-rockchip/pm_domains.c new file +1 -0
+#include <linux/module.h>

This include could probably be dropped.

Yeah. As the about said.

Quoted 10 lines

arch/arm/mach-rockchip/pm_domains.c line 488

Quoted 8 lines
arch/arm/mach-rockchip/pm_domains.c new file +8 -0
+static const struct of_device_id rockchip_pm_domain_dt_match[] = {
+	{
+		.compatible = "rockchip,rk3288-power-controller",
+		.data = (void *)&rk3288_pmu,
+	},
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, rockchip_pm_domain_dt_match);

The MODULE_DEVICE_TABLE() macro will be preprocessed away for built-in code, according to include/linux/module.h.

So,do you think we should remove it?
wow.....,looks we should remove it.

Quoted 8 lines

arch/arm/mach-rockchip/pm_domains.c line 494

Quoted 5 lines
arch/arm/mach-rockchip/pm_domains.c new file +5 -0
+static struct platform_driver rockchip_pm_domain_driver = {
+	.probe = rockchip_pm_domain_probe,
+	.driver = {
+		.name   = "rockchip-pm-domain",
+		.owner  = THIS_MODULE,

According to include/linux/export.h THIS_MODULE is equivalent to NULL for built-in code. So I think this line is not needed.

Yeah,you are right.

Quoted 12 lines

arch/arm/mach-rockchip/pm_domains.c line 503

Quoted 9 lines
arch/arm/mach-rockchip/pm_domains.c new file +9 -0
+		.of_match_table = rockchip_pm_domain_dt_match,
+		/*
+		 * We can't forcibly eject devices form power domain,
+		 * so we can't really remove power domains once they
+		 * were added.
+		 */
+		.suppress_bind_attrs = true,
+	},
+};

Thanks,

Quoted 5 lines

Paul Bolle

Thanks,

Caesar

Signature · 17 lines
**************************************************************************************
???    Caesar Wang
Product R&D Dept.III
Fuzhou Rockchip Electronics Co.Ltd
Addr?  NO.18 Building, A District, Fuzhou Software Park,Gulou District,Fuzhou, Fujian,China(Fuzhou Headquarters)
               21F,Malata Building,Kejizhongyi Avenue,Nanshan District,Shenzhen  (Shenzhen Office)
Tel?+86-591-83991906/07 - 8221
Mobile:+86 15059456742
E-mail : wxt at rock-chips.com
***************************************************************************************
***************************************************************************************
IMPORTANT NOTICE: This email is from Fuzhou Rockchip Electronics Co., Ltd .The contents of this email and any attachments may
contain information that is privileged, confidential and/or exempt from disclosure under applicable law and relevant NDA.
If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the
information is STRICTLY PROHIBITED. Please immediately contact the sender as soon as possible and destroy the material
in its entirety in any format. Thank you.
***************************************************************************************