Generic Device Tree based power domain look-up
Subsystems (9)
v4 cover Generic Device Tree based power domain look-up
Up till now there was no single generic method to bind devices to their power domains using Device Tree. Each platform has been doing this using its own way, example of which are Exynos power domain bindings [1] and look-up code [2].
This series is intended to change this and provide generic DT bindings for power domain specification and generic code performing look-up of power domains and binding them to devices.
First two patches are the most important part of this series, as they introduce $subject. Patch 3 converts mach-exynos to use the new generic method. Further patches are adding one more user of the new code, mach-s3c64xx, with first 3 patches (4-6) required to clean-up its power domain driver a bit and last 3 patches (9-11) adding display support for Mini6410 board, including a node for display controller (FIMD) which is a power domain consumer.
The design of DT bindings and provider code is heavily inspired by implementation of clock providers in Common Clock Framework, while the code binding devices to power domains by my Exynos power domain implementation (now removed by this series ;)).
Successfully tested on Exynos4210-based Trats and Exynos4412-based Trats2 boards using MFC,
[1] Documentation/devicetree/bindings/arm/exynos/power_domain.txt
[2] arch/arm/mach-exynos/pm_domains.c
Changes since v3:
(http://thread.gmane.org/gmane.linux.power-management.general/44571)
- rebased onto current Rafael's linux-pm bleeding-edge branch (0a112bf),
- renamed "power-domain" property to "power-domains" to facilitate further extension to support multiple power domains per device in future.
Changes since v2:
(http://thread.gmane.org/gmane.linux.kernel/1658926)
- rebased onto current Rafael's linux-pm bleeding-edge branch,
- dropped patches for s3c64xx for now. I will send them in separate series,
- do not call pm_genpd_dev_need_restore(true) in genpd_bind_domain(),
- fixed various stylistic issues reported in review comments.
Changes since v1 (RFC):
[https://lkml.org/lkml/2014/1/11/141]
- rebased onto current Rafael's linux-pm bleeding-edge branch,
- reordered the patches a bit (to have the generic ones first),
- dropped renaming of S3C64xx power domains (as suggested by Mark Brown),
- added support for deferred probing (as suggested by Stephen Boyd),
- fixed several minor issues pointed by Stephen Boyd,
- replaced notifiers with direct hooks in driver core to make power domain support independent from specific bus type and allow error handling.
Tomasz Figa (3):
base: power: Add generic OF-based power domain look-up
drivercore: Bind/unbind power domain on probe/remove
ARM: exynos: Move to generic power domain bindings
.../bindings/arm/exynos/power_domain.txt | 12 +- .../devicetree/bindings/power/power_domain.txt | 51 ++++ arch/arm/mach-exynos/pm_domains.c | 81 +----- drivers/base/dd.c | 9 +- drivers/base/power/domain.c | 283 +++++++++++++++++++++ include/linux/pm_domain.h | 46 ++++ kernel/power/Kconfig | 4 + 7 files changed, 398 insertions(+), 88 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/power_domain.txt
Signature · 1 line
1.9.2
PATCH v4 1/3 base: power: Add generic OF-based power domain look-up
This patch introduces generic code to perform power domain look-up using device tree and automatically bind devices to their power domains. Generic device tree binding is introduced to specify power domains of devices in their device tree nodes.
Backwards compatibility with legacy Samsung-specific power domain bindings is provided, but for now the new code is not compiled when CONFIG_ARCH_EXYNOS is selected to avoid collision with legacy code. This will change as soon as Exynos power domain code gets converted to use the generic framework in further patch.
--- .../devicetree/bindings/power/power_domain.txt | 51 ++++ drivers/base/power/domain.c | 283 +++++++++++++++++++++ include/linux/pm_domain.h | 46 ++++ kernel/power/Kconfig | 4 + 4 files changed, 384 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/power_domain.txt
Documentation/devicetree/bindings/power/power_domain.txt new file +51 -0
@@ -0,0 +1,51 @@ +* Generic power domains + +System on chip designs are often divided into multiple power domains that +can be used for power gating of selected IP blocks for power saving by +reduced leakage current. + +This device tree binding can be used to bind power domain consumer devices +with their power domains provided by power domain providers. A power domain +provider can be represented by any node in the device tree and can provide +one or more power domains. A consumer node can refer to the provider by +a phandle and a set of phandle arguments (so called power domain specifier) +of length specified by #power-domain-cells property in the power domain +provider node. + +==Power domain providers== + +Required properties: + - #power-domain-cells : Number of cells in a power domain specifier; + Typically 0 for nodes representing a single power domain and 1 for nodes + providing multiple power domains (e.g. power controllers), but can be + any value as specified by device tree binding documentation of particular + provider. + +Example: + + power: power-controller at 12340000 { + compatible = "foo,power-controller"; + reg = <0x12340000 0x1000>; + #power-domain-cells = <1>; + }; + +The node above defines a power controller that is a power domain provider +and expects one cell as its phandle argument. + +==Power domain consumers== + +Required properties: + - power-domains : A phandle and power domain specifier as defined by bindings + of power controller specified by phandle. + +Example: + + leaky-device at 12350000 { + compatible = "foo,i-leak-current"; + reg = <0x12350000 0x1000>; + power-domains = <&power 0>; + }; + +The node above defines a typical power domain consumer device, which is located +inside power domain with index 0 of power controller represented by node with +label "power".
drivers/base/power/domain.c +283 -0
292 lines not on this page · raw message
include/linux/pm_domain.h +46 -0
50 lines not on this page · raw message
kernel/power/Kconfig +4 -0
@@ -306,6 +306,10 @@ config PM_GENERIC_DOMAINS_RUNTIME def_bool y depends on PM_RUNTIME && PM_GENERIC_DOMAINS +config PM_GENERIC_DOMAINS_OF + def_bool y + depends on PM_GENERIC_DOMAINS && OF && !ARCH_EXYNOS + config CPU_PM bool depends on SUSPEND || CPU_IDLE
Signature · 1 line
1.9.2
PATCH v4 2/3 drivercore: Bind/unbind power domain on probe/remove
In reply to Tomasz FigaOn a number of platforms, devices are part of controllable power domains, which need to be enabled before such devices can be accessed and may be powered down when the device is idle to save some power. This means that on systems that support power domain control using generic power domains subsystem, it is necessary to add device to its power domain before binding a driver to it and remove it from its power domain after its driver is unbound to make sure that an unused device does not affect power domain state.
Since this is not limited to particular busses and specific archs/platforms, it is more convenient to do the above directly in driver core, just as done with pinctrl default configuration. This patch adds necessary code to really_probe() and __device_release_driver() to achieve this and maintain consistent stack-like ordering of operations happening when binding and unbinding a driver.
--- drivers/base/dd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/base/dd.c +8 -1
@@ -23,6 +23,7 @@#include <linux/kthread.h> #include <linux/wait.h> #include <linux/async.h> +#include <linux/pm_domain.h> #include <linux/pm_runtime.h> #include <linux/pinctrl/devinfo.h>
@@ -287,6 +288,11 @@ static int really_probe(struct device *dev, struct device_driver *drv) dev->driver = drv; +/* If using genpd, bind power domain now before probing */ + ret =genpd_bind_domain (dev); +if (ret) + goto probe_failed; +/* If using pinctrl, bind pins now before probing */ ret =pinctrl_bind_pins (dev);if (ret)
@@ -317,6 +323,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) probe_failed:devres_release_all (dev);driver_sysfs_remove (dev); +genpd_unbind_domain (dev); dev->driver =NULL ;dev_set_drvdata (dev,NULL );
@@ -530,7 +537,7 @@ static void __device_release_driver(struct device *dev)blocking_notifier_call_chain (&dev->bus->p->bus_notifier,BUS_NOTIFY_UNBOUND_DRIVER , dev); - +genpd_unbind_domain (dev); } }
Signature · 1 line
1.9.2
PATCH v4 3/3 ARM: exynos: Move to generic power domain bindings
In reply to Tomasz FigaThis patch moves Exynos power domain code to use the new generic power domain look-up framework introduced by previous patch, allowing the new code to be compiled with CONFIG_ARCH_EXYNOS selected as well.
--- .../bindings/arm/exynos/power_domain.txt | 12 ++-- arch/arm/mach-exynos/pm_domains.c | 81 +--------------------- kernel/power/Kconfig | 2 +- 3 files changed, 7 insertions(+), 88 deletions(-)
Documentation/devicetree/bindings/arm/exynos/power_domain.txt +5 -7
@@ -8,6 +8,8 @@ Required Properties: * samsung,exynos4210-pd - for exynos4210 type power domain. - reg: physical base address of the controller and length of memory mapped region. +- #power-domain-cells: number of cells in power domain specifier; + must be 0. Node of a device using power domains must have a samsung,power-domain property defined with a phandle to respective power domain.
@@ -17,12 +19,8 @@ Example: lcd0: power-domain-lcd0 { compatible = "samsung,exynos4210-pd"; reg = <0x10023C00 0x10>; + #power-domain-cells = <0>; }; -Example of the node using power domain: - - node { - /* ... */ - samsung,power-domain = <&lcd0>; - /* ... */ - }; +See Documentation/devicetree/bindings/power/power_domain.txt for description +of consumer-side bindings.
arch/arm/mach-exynos/pm_domains.c +1 -80
107 lines not on this page · raw message
kernel/power/Kconfig +1 -1
@@ -308,7 +308,7 @@ config PM_GENERIC_DOMAINS_RUNTIME config PM_GENERIC_DOMAINS_OF def_bool y - depends on PM_GENERIC_DOMAINS && OF && !ARCH_EXYNOS + depends on PM_GENERIC_DOMAINS && OF config CPU_PM bool
Signature · 1 line
1.9.2
Sent with wrong Rafael's address, please ignore this thread. Just resent with correct address. Sorry for the noise.
Best regards,
Tomasz
Quoted 66 lines · Tomasz Figa
Up till now there was no single generic method to bind devices to their power domains using Device Tree. Each platform has been doing this using its own way, example of which are Exynos power domain bindings [1] and look-up code [2].
This series is intended to change this and provide generic DT bindings for power domain specification and generic code performing look-up of power domains and binding them to devices.
First two patches are the most important part of this series, as they introduce $subject. Patch 3 converts mach-exynos to use the new generic method. Further patches are adding one more user of the new code, mach-s3c64xx, with first 3 patches (4-6) required to clean-up its power domain driver a bit and last 3 patches (9-11) adding display support for Mini6410 board, including a node for display controller (FIMD) which is a power domain consumer.
The design of DT bindings and provider code is heavily inspired by implementation of clock providers in Common Clock Framework, while the code binding devices to power domains by my Exynos power domain implementation (now removed by this series ;)).
Successfully tested on Exynos4210-based Trats and Exynos4412-based Trats2 boards using MFC,
[1]
Documentation/devicetree/bindings/arm/exynos/power_domain.txt
[2]arch/arm/mach-exynos/pm_domains.cChanges since v3:
(http://thread.gmane.org/gmane.linux.power-management.general/44571)
- rebased onto current Rafael's linux-pm bleeding-edge branch (0a112bf),
- renamed "power-domain" property to "power-domains" to facilitate further extension to support multiple power domains per device in future.Changes since v2:
(http://thread.gmane.org/gmane.linux.kernel/1658926)
- rebased onto current Rafael's linux-pm bleeding-edge branch,
- dropped patches for s3c64xx for now. I will send them in separate series,
- do not callpm_genpd_dev_need_restore(true)ingenpd_bind_domain(),
- fixed various stylistic issues reported in review comments.Changes since v1 (RFC):
[https://lkml.org/lkml/2014/1/11/141]
- rebased onto current Rafael's linux-pm bleeding-edge branch,
- reordered the patches a bit (to have the generic ones first),
- dropped renaming of S3C64xx power domains (as suggested by Mark Brown),
- added support for deferred probing (as suggested by Stephen Boyd),
- fixed several minor issues pointed by Stephen Boyd,
- replaced notifiers with direct hooks in driver core to make power domain support independent from specific bus type and allow error handling.Tomasz Figa (3):
base: power: Add generic OF-based power domain look-up
drivercore: Bind/unbind power domain on probe/remove
ARM: exynos: Move to generic power domain bindings.../bindings/arm/exynos/power_domain.txt | 12 +- .../devicetree/bindings/power/power_domain.txt | 51 ++++ arch/arm/mach-exynos/pm_domains.c | 81 +----- drivers/base/dd.c | 9 +- drivers/base/power/domain.c | 283 +++++++++++++++++++++ include/linux/pm_domain.h | 46 ++++ kernel/power/Kconfig | 4 + 7 files changed, 398 insertions(+), 88 deletions(-) create mode 100644 Documentation/devicetree/bindings/power/power_domain.txt