i.MX6 PU power domain support
v4 cover i.MX6 PU power domain support
The i.MX6Q can gate off the CPU and PU (GPU/VPU) power domains using the Power Gating Controller (PGC) in the GPC register space. The CPU power domain is already handled by wait state code, but the PU power domain can be controlled using the generic power domain framework and power off the PU supply regulator if all devices in the power domain are (runtime) suspended.
This patchset adds a GPC platform device initialized at subsys_initcall time (after anatop regulators) that binds to the gpc device tree node and sets up the PU power domain:
gpc: gpc at 020dc000 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "fsl,imx6q-gpc";
reg = <0x020dc000 0x4000>;
interrupts = <0 89 0x04 0 90 0x04>;
pu-supply = <®_pu>;
pd_pu: pu-power-domain at 020dc260 {
compatible = "fsl,imx6q-power-domain";
reg = <0x020dc260 0x10>;
};
pd_arm: cpu-power-domain at 020dc2a0 {
compatible = "fsl,imx6q-power-domain";
reg = <0x020dc2a0 0x10>;
};
};The cpu-power-domain node is included for completeness' sake, it is not currently used by the code.
It registers a platform bus notifier so that it can add GPU and VPU devices to the power domain when they are bound. If finds devices to be added to the power domain by scanning the device tree for nodes that contain a
power-domain = <&pd_pu>;
property.
For i.MX6QDL there is only one power domain that can be disabled at runtime, on i.MX6SL there is an additional DISPLAY power domain, which is not yet handled by the code.
Changes since v3:
- Use fsl,power-domain property name to link devices to power domains
regards
Philipp
Philipp Zabel (7):
Documentation: Add device tree bindings for Freescale i.MX GPC
ARM: imx6: gpc: Add PU power domain for GPU/VPU
ARM: imx6: gpc: Add pm clock support to PU power domain
ARM: imx6: gpc: Add observed worst case latencies
ARM: dts: imx6qdl: Allow disabling the PU regulator, add a enable ramp
delay
ARM: dts: imx6qdl: Add power-domain information to gpc node
ARM: dts: imx6sl: Add power-domain information to gpc node
.../devicetree/bindings/power/fsl,imx-gpc.txt | 58 +++++ arch/arm/boot/dts/imx6qdl.dtsi | 16 +- arch/arm/boot/dts/imx6sl.dtsi | 18 ++ arch/arm/mach-imx/Kconfig | 2 + arch/arm/mach-imx/gpc.c | 256 +++++++++++++++++++++ 5 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
Signature · 1 line
1.8.5.3
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
The i.MX6 contains a power controller that controls power gating and sequencing for the SoC's power domains.
---
Changes since v3:
- Updated documentation to use fsl,power-domain property name and pu-power-domain as node name.
- Removed address-cells/size-cells
--- .../devicetree/bindings/power/fsl,imx-gpc.txt | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt new file +58 -0
@@ -0,0 +1,58 @@ +Freescale i.MX General Power Controller +======================================= + +The i.MX6Q General Power Control (GPC) block contains DVFS load tracking +counters and Power Gating Control (PGC) for the CPU and PU (GPU/VPU) power +domains. + +Required properties: +- compatible: Should be "fsl,imx6q-gpc" +- reg: should be register base and length as documented in the + datasheet +- interrupts: Should contain GPC interrupt request 1 +- pu-supply: Link to the LDO regulator powering the PU power domain + +The gpc node should contain a 'pu-power-domain' subnode that serves as a +phandle target for devices belonging to the PU power domain: + +Power domains controlled by a PGC register set +============================================== + +Required properties: +- compatible: Should be "fsl,imx6q-power-domain" +- reg: should be register base and length as documented in the + datasheet + +Specifying power domain for IP modules +====================================== + +IP cores belonging to a power domain should contain a 'power-domain' property +that is a phandle pointing to the power-domain subnode of the gpc device node. + +Required properties: +- fsl,power-domain: A phandle pointing to the power-domain device tree node + + +Example: + + gpc: gpc at 020dc000 { + compatible = "fsl,imx6q-gpc"; + reg = <0x020dc000 0x4000>; + interrupts = <0 89 0x04 0 90 0x04>; + pu-supply = <®_pu>; + + pd_pu: pu-power-domain at 020dc260 { + compatible = "fsl,imx6q-power-domain"; + reg = <0x020dc260 0x10>; + }; + }; + +Example of a device that is part of a power domain: + + vpu: vpu at 02040000 { + reg = <0x02040000 0x3c000>; + /* ... */ + fsl,power-domain = <&pd_pu>; + /* ... */ + }; +
Signature · 1 line
1.8.5.3
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt line 58
Quoted 10 lines · On Tuesday 18 February 2014 16:34:41 Philipp Zabel wrote:
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt new file +10
-0+ +Example of a device that is part of a power domain: + + vpu: vpu at 02040000 { + reg = <0x02040000 0x3c000>; + /* ... */ + fsl,power-domain = <&pd_pu>; + /* ... */ + }; +
I'm really not too happy about platforms starting to add random bindings for power domains. Unfortunately I didn't catch exynos doing this first, but I don't want to see another platform like that.
Can we please come up with a proper generic power domain binding first and then add platform specific users?
Arnd
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
Hi Arnd,
[adding Samsung guys into the loop]
Am Dienstag, den 18.02.2014, 19:10 +0100 schrieb Arnd Bergmann:
Quoted 17 lines · On Tuesday 18 February 2014 16:34:41 Philipp Zabel wrote:
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt line 58
Quoted 10 lines
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt new file +10
-0+ +Example of a device that is part of a power domain: + + vpu: vpu at 02040000 { + reg = <0x02040000 0x3c000>; + /* ... */ + fsl,power-domain = <&pd_pu>; + /* ... */ + }; +I'm really not too happy about platforms starting to add random bindings for power domains. Unfortunately I didn't catch exynos doing this first, but I don't want to see another platform like that.
Quoted 2 lines
Can we please come up with a proper generic power domain binding first and then add platform specific users?
what is the process here? I've seen the samsung bindings and copied the pattern. I guess the Exynos bindings are set in stone, and the i.MX power domains can be handled using the same bindings.
regards
Philipp
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
Quoted 18 lines · Philipp Zabel
Am Dienstag, den 18.02.2014, 19:10 +0100 schrieb Arnd Bergmann:
Quoted 17 lines · On Tuesday 18 February 2014 16:34:41 Philipp Zabel wrote:
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt line 58
Quoted 10 lines
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt new file +10
-0+ +Example of a device that is part of a power domain: + + vpu: vpu at 02040000 { + reg = <0x02040000 0x3c000>; + /* ... */ + fsl,power-domain = <&pd_pu>; + /* ... */ + }; +I'm really not too happy about platforms starting to add random bindings for power domains. Unfortunately I didn't catch exynos doing this first, but I don't want to see another platform like that.
Quoted 6 lines
Quoted 2 lines
Can we please come up with a proper generic power domain binding first and then add platform specific users?
what is the process here? I've seen the samsung bindings and copied the pattern. I guess the Exynos bindings are set in stone, and the i.MX power domains can be handled using the same bindings.
* First of all, get the pm domain maintainers into the loop, then make sure all other users of pm domains are aware of what you are doing.
* Come up with a way to describe a pm_domain in a sufficiently generic way. It's possible you just need a phandle, but experience on other subsystems suggests that it helps to allow arguments, as we do for clocks, dmas, mailboxes, etc.
* Draft a generic binding that can work on all platforms
* Implement support for the generic binding in the platform independent code.
* Add a specific binding for your hardware.
* Implement support for your hardware binding on top of the generic code.
* Get everyone involved to Ack the generic binding and implementation.
Arnd
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
Quoted 40 lines · Arnd Bergmann
Quoted 18 lines · Philipp Zabel
Am Dienstag, den 18.02.2014, 19:10 +0100 schrieb Arnd Bergmann:
Quoted 17 lines · On Tuesday 18 February 2014 16:34:41 Philipp Zabel wrote:
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt line 58
Quoted 10 lines
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt new file +10
-0+ +Example of a device that is part of a power domain: + + vpu: vpu at 02040000 { + reg = <0x02040000 0x3c000>; + /* ... */ + fsl,power-domain = <&pd_pu>; + /* ... */ + }; +I'm really not too happy about platforms starting to add random bindings for power domains. Unfortunately I didn't catch exynos doing this first, but I don't want to see another platform like that.
Quoted 6 lines
Quoted 2 lines
Can we please come up with a proper generic power domain binding first and then add platform specific users?
what is the process here? I've seen the samsung bindings and copied the pattern. I guess the Exynos bindings are set in stone, and the i.MX power domains can be handled using the same bindings.
* First of all, get the pm domain maintainers into the loop, then make sure all other users of pm domains are aware of what you are doing.
* Come up with a way to describe a
pm_domainin a sufficiently generic way. It's possible you just need a phandle, but experience on other subsystems suggests that it helps to allow arguments, as we do for clocks, dmas, mailboxes, etc.* Draft a generic binding that can work on all platforms
* Implement support for the generic binding in the platform independent code.
Quoted 9 lines
* Add a specific binding for your hardware.
* Implement support for your hardware binding on top of the generic code.
* Get everyone involved to Ack the generic binding and implementation.
Arnd
Just wanted to share a link with you. ;)
http://www.spinics.net/lists/devicetree/msg18051.html
Best regards,
Tomasz
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
Quoted 4 lines · On Wednesday 19 February 2014 15:51:21 Tomasz Figa wrote:
Just wanted to share a link with you.
Excellent, thanks for the heads-up.
Philipp, please review that patch and see if you can build on top of that for your work.
Arnd
PATCH v4 1/7 Documentation: Add device tree bindings for Freescale i.MX GPC
Am Mittwoch, den 19.02.2014, 15:56 +0100 schrieb Arnd Bergmann:
Quoted 10 lines · On Wednesday 19 February 2014 15:51:21 Tomasz Figa wrote:
Quoted 4 lines
Just wanted to share a link with you.
Excellent, thanks for the heads-up.
Philipp, please review that patch and see if you can build on top of that for your work.
Thanks, I'll do that.
regards
Philipp
PATCH v4 2/7 ARM: imx6: gpc: Add PU power domain for GPU/VPU
In reply to Philipp ZabelWhen generic pm domain support is enabled, the PGC can be used to completely gate power to the PU power domain containing GPU3D, GPU2D, and VPU cores.
This code triggers the PGC powerdown sequence to disable the GPU/VPU isolation cells and gate power and then disables the PU regulator. To reenable, the reverse powerup sequence is triggered after the PU regulaotor is enabled again.
---
Changes since v3:
- Use fsl,power-domain property name to link devices to power domains
--- arch/arm/mach-imx/Kconfig | 2 + arch/arm/mach-imx/gpc.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 175 insertions(+)
arch/arm/mach-imx/Kconfig +2 -0
@@ -808,6 +808,7 @@ config SOC_IMX6Q select PL310_ERRATA_727915 if CACHE_PL310 select PL310_ERRATA_769419 if CACHE_PL310 select PM_OPP if PM + select PM_GENERIC_DOMAINS if PM help This enables support for Freescale i.MX6 Quad processor.
@@ -827,6 +828,7 @@ config SOC_IMX6SL select PL310_ERRATA_588369 if CACHE_PL310 select PL310_ERRATA_727915 if CACHE_PL310 select PL310_ERRATA_769419 if CACHE_PL310 + select PM_GENERIC_DOMAINS if PM help This enables support for Freescale i.MX6 SoloLite processor.
arch/arm/mach-imx/gpc.c +173 -0
195 lines not on this page · raw message
Signature · 1 line
1.8.5.3
PATCH v4 3/7 ARM: imx6: gpc: Add pm clock support to PU power domain
In reply to Philipp ZabelDrivers still handle clocks themselves, we only enable pm clocks of the GPU and VPU devices in the PU power domain temporarily during powerup so that the reset machinery can work.
--- arch/arm/mach-imx/gpc.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+)
arch/arm/mach-imx/gpc.c +74 -0
@@ -18,6 +18,7 @@#include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/platform_device.h> +#include <linux/pm_clock.h> #include <linux/pm_domain.h> #include <linux/regulator/consumer.h> #include <linux/irqchip/arm-gic.h>
@@ -182,6 +183,7 @@ static int imx6q_pm_pu_power_off(struct generic_pm_domain *genpd)static int imx6q_pm_pu_power_on (struct generic_pm_domain *genpd) { +struct pm_domain_data *pdd;int ret;u32 val;int sw, sw2iso;
@@ -192,6 +194,10 @@ static int imx6q_pm_pu_power_on(struct generic_pm_domain *genpd)return ret; } +/* Enable PM clocks for all devices in the PU domain */ +list_for_each_entry (pdd, &genpd->dev_list, list_node) +pm_clk_resume (pdd->dev); +/* Gate off PU domain when GPU/VPU when powered down */ writel_relaxed (0x1 , gpc_base +GPC_PGC_GPU_PDN );
@@ -208,6 +214,10 @@ static int imx6q_pm_pu_power_on(struct generic_pm_domain *genpd)/* Wait ISO + ISO2SW IPG clock cycles */ ndelay ((sw + sw2iso) *1000 /66 ); +/* Disable PM clocks for all devices in the PU domain */ +list_for_each_entry (pdd, &genpd->dev_list, list_node) +pm_clk_suspend (pdd->dev); +return 0 ; }
@@ -217,6 +227,68 @@ static struct generic_pm_domain imx6q_pu_domain = { .power_on = imx6q_pm_pu_power_on, }; +int imx6q_pm_clk_add (struct device *dev) +{ +struct device_node *np = dev->of_node; +const char *con_id; +struct clk *clk; +int i =0 ; + +/* Add and prepare named clocks */ +while (!of_property_read_string_index (np,"clock-names" , i, &con_id)) { +pm_clk_add (dev, con_id); + clk =of_clk_get (np, i); +if (!IS_ERR (clk)) { +clk_prepare (clk); +clk_put (clk); + } + i++; + } + +/* If no named clocks are given, add and prepare unnamed clock */ +if (i ==1 &&of_find_property (dev->of_node,"clocks" ,NULL )) { +pm_clk_add (dev,NULL ); + clk =of_clk_get (np,0 ); +if (!IS_ERR (clk)) { +clk_prepare (clk); +clk_put (clk); + } + } + +return 0 ; +} + +int imx6q_pm_clk_remove (struct device *dev) +{ +struct device_node *np = dev->of_node; +const char *con_id; +struct clk *clk; +int i =0 ; + +/* Remove and unprepare named clocks */ +while (!of_property_read_string_index (np,"clock-names" , i, &con_id)) { +pm_clk_remove (dev, con_id); + clk =of_clk_get (np, i); +if (!IS_ERR (clk)) { +clk_unprepare (clk); +clk_put (clk); + } + i++; + } + +/* If no named clocks are given, remove and unprepare unnamed clock */ +if (i ==1 &&of_find_property (dev->of_node,"clocks" ,NULL )) { +pm_clk_remove (dev,NULL ); + clk =of_clk_get (np,0 ); +if (!IS_ERR (clk)) { +clk_unprepare (clk); +clk_put (clk); + } + } + +return 0 ; +} +static int imx6q_pm_notifier_call (struct notifier_block *nb,unsigned long event,void *data) {
@@ -235,6 +307,7 @@ static int imx6q_pm_notifier_call(struct notifier_block *nb,if (ret)dev_err (dev,"failed to add to power domain: %d\n" , ret); +imx6q_pm_clk_add (dev);break ;case BUS_NOTIFY_UNBOUND_DRIVER : genpd =dev_to_genpd (dev);
@@ -245,6 +318,7 @@ static int imx6q_pm_notifier_call(struct notifier_block *nb,if (ret)dev_err (dev,"failed to remove from power domain: %d\n" , ret); +imx6q_pm_clk_remove (dev);break ; }
Signature · 1 line
1.8.5.3
PATCH v4 4/7 ARM: imx6: gpc: Add observed worst case latencies
In reply to Philipp ZabelThis avoids the "... latency exceeded, new value ..." warnings emitted by the power domain framework code whenever the PU domain is enabled or disabled.
--- arch/arm/mach-imx/gpc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm/mach-imx/gpc.c +10 -1
@@ -225,6 +225,8 @@ static struct generic_pm_domain imx6q_pu_domain = { .name = "PU", .power_off = imx6q_pm_pu_power_off, .power_on = imx6q_pm_pu_power_on, + .power_off_latency_ns = 25000, + .power_on_latency_ns = 2000000, };int imx6q_pm_clk_add (struct device *dev)
@@ -289,6 +291,13 @@ int imx6q_pm_clk_remove(struct device *dev)return 0 ; } +static struct gpd_timing_data pu_timing_data = { + .stop_latency_ns =2000 , + .start_latency_ns =2000 , + .save_state_latency_ns =5000 , + .restore_state_latency_ns =20000000 ,/* VPU firmware reload */ +}; +static int imx6q_pm_notifier_call (struct notifier_block *nb,unsigned long event,void *data) {
@@ -303,7 +312,7 @@ static int imx6q_pm_notifier_call(struct notifier_block *nb,if (!np || np != imx6q_pu_domain.of_node)return NOTIFY_DONE ; - ret =pm_genpd_of_add_device (np, dev); + ret =__pm_genpd_of_add_device (np, dev, &pu_timing_data);if (ret)dev_err (dev,"failed to add to power domain: %d\n" , ret);
Signature · 1 line
1.8.5.3
PATCH v4 5/7 ARM: dts: imx6qdl: Allow disabling the PU regulator, add a enable ramp delay
In reply to Philipp ZabelThe PU regulator is enabled during boot, but not necessarily always-on. It can be disabled by the generic pm domain framework when the PU power domain is shut down. The ramp delay of 150 us might be a bit conservative, the value is taken from the Freescale kernel.
--- arch/arm/boot/dts/imx6qdl.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/boot/dts/imx6qdl.dtsi +2 -1
@@ -515,7 +515,8 @@ regulator-name = "vddpu"; regulator-min-microvolt = <725000>; regulator-max-microvolt = <1450000>; - regulator-always-on; + regulator-enable-ramp-delay = <150>; + regulator-boot-on; anatop-reg-offset = <0x140>; anatop-vol-bit-shift = <9>; anatop-vol-bit-width = <5>;
Signature · 1 line
1.8.5.3
PATCH v4 6/7 ARM: dts: imx6qdl: Add power-domain information to gpc node
In reply to Philipp ZabelThe PGC that is part of GPC controls isolation and power sequencing of the power domains. The PU power domain will be handled by the generic pm domain framework and needs a phandle to the PU regulator to turn off power when the domain is disabled.
--- arch/arm/boot/dts/imx6qdl.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/boot/dts/imx6qdl.dtsi +13 -0
@@ -598,9 +598,22 @@ }; gpc: gpc at 020dc000 { + #address-cells = <1>; + #size-cells = <1>; compatible = "fsl,imx6q-gpc"; reg = <0x020dc000 0x4000>; interrupts = <0 89 0x04 0 90 0x04>; + pu-supply = <®_pu>; + + pd_pu: pu-power-domain at 020dc260 { + compatible = "fsl,imx6q-power-domain"; + reg = <0x020dc260 0x10>; + }; + + pd_arm: cpu-power-domain at 020dc2a0 { + compatible = "fsl,imx6q-power-domain"; + reg = <0x020dc2a0 0x10>; + }; }; gpr: iomuxc-gpr at 020e0000 {
Signature · 1 line
1.8.5.3
PATCH v4 7/7 ARM: dts: imx6sl: Add power-domain information to gpc node
In reply to Philipp ZabelThe PGC that is part of GPC controls isolation and power sequencing of the power domains. The PU power domain will be handled by the generic pm domain framework and needs a phandle to the PU regulator to turn off power when the domain is disabled.
--- arch/arm/boot/dts/imx6sl.dtsi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
arch/arm/boot/dts/imx6sl.dtsi +18 -0
@@ -529,9 +529,27 @@ }; gpc: gpc at 020dc000 { + #address-cells = <1>; + #size-cells = <1>; compatible = "fsl,imx6sl-gpc", "fsl,imx6q-gpc"; reg = <0x020dc000 0x4000>; interrupts = <0 89 0x04>; + pu-supply = <®_pu>; + + pd_display: display-power-domain at 020dc240 { + compatible = "fsl,imx6q-power-domain"; + reg = <0x020dc240 0x10>; + }; + + pd_pu: pu-power-domain at 020dc260 { + compatible = "fsl,imx6q-power-domain"; + reg = <0x020dc260 0x10>; + }; + + pd_arm: cpu-power-domain at 020dc2a0 { + compatible = "fsl,imx6q-power-domain"; + reg = <0x020dc2a0 0x10>; + }; }; gpr: iomuxc-gpr at 020e0000 {
Signature · 1 line
1.8.5.3