ARM: rk3288: Add PM Domain support
Subsystems (4)
v10 cover ARM: rk3288: Add PM Domain support
Add power domain drivers based on generic power domain for Rockchip platform, and support RK3288.
https://chromium-review.googlesource.com/#/c/220253/9
This is the GPU driver, add the following information in DT, and it can support the PMDOMAIN
gpu: gpu at ffa30000 {
compatible = "arm,malit764",
"arm,malit76x",
"arm,malit7xx",
"arm,mali-midgard";
reg = <0xffa30000 0x10000>;
interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
interrupt-names = "JOB", "MMU", "GPU";
clocks = <&cru ACLK_GPU>;
clock-names = "aclk_gpu";
operating-points = <
/* KHz uV */
100000 800000
200000 850000
300000 950000
400000 1000000
600000 1150000
>;
power-domains = <&power RK3288_PD_GPU>;
status = "disabled";
};Based on:
- [PATCH v1 1/4] PM / clock_ops: Add pm_clk_add_clk()
http://www.mail-archive.com/linux-kernel at vger.kernel.org/msg735599.html
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 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.
- 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 (3):
dt-bindings: add document of Rockchip power domain
power-domain: rockchip: add power doamin driver
ARM: dts: add rk3288 power-domain node
.../bindings/arm/rockchip/power_domain.txt | 48 +++ arch/arm/boot/dts/rk3288.dtsi | 66 +++ arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/Makefile | 1 + arch/arm/mach-rockchip/pm_domains.c | 469 +++++++++++++++++++++ include/dt-bindings/power-domain/rk3288.h | 11 + 6 files changed, 596 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
PATCH v10 1/3 dt-bindings: add document of Rockchip power domain
This add the necessary binding documentation for the power domain found on Rockchip Socs.
---
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/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
@@ -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
PATCH v10 2/3 power-domain: rockchip: add power doamin driver
In reply to Caesar WangIn 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 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 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.
- 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"
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/Makefile | 1 + arch/arm/mach-rockchip/pm_domains.c | 469 ++++++++++++++++++++++++++++++ include/dt-bindings/power-domain/rk3288.h | 11 + 4 files changed, 482 insertions(+) create mode 100644 arch/arm/mach-rockchip/pm_domains.c create mode 100644 include/dt-bindings/power-domain/rk3288.h
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -13,6 +13,7 @@ config ARCH_ROCKCHIP select DW_APB_TIMER_OF 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
@@ -1,4 +1,5 @@ CFLAGS_platsmp.o := -march=armv7-a obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o +obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o
arch/arm/mach-rockchip/pm_domains.c new file +469 -0
469 lines not on this page · raw message
include/dt-bindings/power-domain/rk3288.h new file +11 -0
@@ -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
PATCH v10 3/3 ARM: dts: add rk3288 power-domain node
In reply to Caesar WangThis 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 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 | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
arch/arm/boot/dts/rk3288.dtsi +66 -0
@@ -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 "skeleton.dtsi" / {
@@ -989,4 +990,69 @@ }; }; }; + + 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_NIU>, + <&cru ACLK_RGA>, + <&cru ACLK_VIO0_NIU>, + <&cru ACLK_VIO1_NIU>, + <&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_VIO_AHB_ARBI>, + <&cru HCLK_VIO_NIU>, + <&cru HCLK_VIO2_H2P>, + <&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 PCLK_VIO2_H2P>, + <&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>; + }; + }; };
Signature · 1 line
1.9.1
Re: [PATCH v10 2/3] power-domain: rockchip: add power doamin driver
In reply to Caesar WangQuoted 15 lines · 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.
Signed-off-by Jack Dai <[email protected]>Signed-off-by jinkun.hong <[email protected]>Signed-off-by Caesar Wang <[email protected]>---
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.
Quoted 7 lines
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 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.
I still don't like having lists of clocks in the power-domain DT.
DT is supposed to describe the hardware, and clocks are properties of devices, not power-domains, so the DT description should follow from that.
I understand that some device may not be probed etc. when a power-domain needs to transition, but the power-domain driver can still get the list of clocks it needs from the device nodes within the domain, so it shouldn't matter whether devices are probed or not.
Kevin
Heiko Stübner
maintainerRe: [PATCH v10 2/3] power-domain: rockchip: add power doamin driver
Am Dienstag, 11. November 2014, 08:53:13 schrieb Kevin Hilman:
Quoted 26 lines
Quoted 16 lines · 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.
Signed-off-by Jack Dai <[email protected]>Signed-off-by jinkun.hong <[email protected]>Signed-off-by Caesar Wang <[email protected]>---
Changes in v10:
- this switches over domain infos to use masks instead of recomputingthem each time and also gets rid of custom domain translator and uses standard onecell on.
Quoted 8 lines
Changes in v9:
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain havelists 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.
Quoted 4 lines
I still don't like having lists of clocks in the power-domain DT.
DT is supposed to describe the hardware, and clocks are properties of devices, not power-domains, so the DT description should follow from that.
on the policy side one could argue that if the clock needs to be enabled to achieve sucessful domain state-changes, that it is also a property of the domain itself in addition to the device.
And on the pratical side we don't have drivers nor bindings for a big part of the domain users - and this will probably be true for quite some time. This of course makes it very impractical (or impossible) to collect the clocks for parts like the gpu (mali), hevc, vcodec (video encoder/decoder), rga (2d stuff), iep, isp.
Heiko
Re: [PATCH v10 2/3] power-domain: rockchip: add power doamin driver
In reply to Caesar WangCaesar,
Quoted 1 line · Caesar Wang
+
pm_genpd_init(&pd->genpd, NULL, false);
As Dmitry pointed out in another context, maybe this should be "pm_genpd_init(&pd->genpd, NULL, !is_on);"
Re: [PATCH v10 2/3] power-domain: rockchip: add power doamin driver
In reply to Heiko StübnerQuoted 27 lines · Heiko St?bner
Am Dienstag, 11. November 2014, 08:53:13 schrieb Kevin Hilman:
Quoted 26 lines
Quoted 24 lines · 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.
Signed-off-by Jack Dai <[email protected]>Signed-off-by jinkun.hong <[email protected]>Signed-off-by Caesar Wang <[email protected]>---
Changes in v10:
- this switches over domain infos to use masks instead of recomputingthem 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 havelists 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.
Quoted 8 lines
Quoted 4 lines
I still don't like having lists of clocks in the power-domain DT.
DT is supposed to describe the hardware, and clocks are properties of devices, not power-domains, so the DT description should follow from that.
on the policy side one could argue that if the clock needs to be enabled to achieve sucessful domain state-changes, that it is also a property of the domain itself in addition to the device.
You could, but from a hardware perspective, the clock is a property of the device.
Quoted 5 lines
And on the pratical side we don't have drivers nor bindings for a big part of the domain users - and this will probably be true for quite some time. This of course makes it very impractical (or impossible) to collect the clocks for parts like the gpu (mali), hevc, vcodec (video encoder/decoder), rga (2d stuff), iep, isp.
This doesn't sound impossible at all.
You have to collect the clocks anyways. The only debate is whether to list them in the device node or the power-domain node.
Even for devices without drivers, you just need a minimal node in the DT if which lists the clocks and has a phandle to the parent power domain.
Sounds rather simple to me, and since the DT is supposed to describe the hardware, doing it this way makes looking at the DT actually help understand the hardware.
Kevin