Commit cc773e75 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'pm-domains'

* pm-domains:
  PM / Domains: Fix compatible for domain idle state
  PM / Domains: Do not print PM domain add error message if EPROBE_DEFER
  PM / Domains: Fix a warning message
  PM / Domains: check for negative return from of_count_phandle_with_args()
  PM / doc: Update device documentation for devices in IRQ-safe PM domains
  PM / Domains: Support IRQ safe PM domains
  PM / Domains: Abstract genpd locking
  dt/bindings / PM/Domains: Update binding for PM domain idle states
  PM / Domains: Save the fwnode in genpd_power_state
  PM / Domains: Allow domain power states to be read from DT
  PM / Domains: Add residency property to genpd states
  PM / Domains: Make genpd state allocation dynamic

Conflicts:
	arch/arm/mach-imx/gpc.c
parents 69973b83 598da548
PM Domain Idle State Node:
A domain idle state node represents the state parameters that will be used to
select the state when there are no active components in the domain.
The state node has the following parameters -
- compatible:
Usage: Required
Value type: <string>
Definition: Must be "domain-idle-state".
- entry-latency-us
Usage: Required
Value type: <prop-encoded-array>
Definition: u32 value representing worst case latency in
microseconds required to enter the idle state.
The exit-latency-us duration may be guaranteed
only after entry-latency-us has passed.
- exit-latency-us
Usage: Required
Value type: <prop-encoded-array>
Definition: u32 value representing worst case latency
in microseconds required to exit the idle state.
- min-residency-us
Usage: Required
Value type: <prop-encoded-array>
Definition: u32 value representing minimum residency duration
in microseconds after which the idle state will yield
power benefits after overcoming the overhead in entering
i the idle state.
...@@ -29,6 +29,15 @@ Optional properties: ...@@ -29,6 +29,15 @@ Optional properties:
specified by this binding. More details about power domain specifier are specified by this binding. More details about power domain specifier are
available in the next section. available in the next section.
- domain-idle-states : A phandle of an idle-state that shall be soaked into a
generic domain power state. The idle state definitions are
compatible with domain-idle-state specified in [1].
The domain-idle-state property reflects the idle state of this PM domain and
not the idle states of the devices or sub-domains in the PM domain. Devices
and sub-domains have their own idle-states independent of the parent
domain's idle states. In the absence of this property, the domain would be
considered as capable of being powered-on or powered-off.
Example: Example:
power: power-controller@12340000 { power: power-controller@12340000 {
...@@ -59,6 +68,38 @@ The nodes above define two power controllers: 'parent' and 'child'. ...@@ -59,6 +68,38 @@ The nodes above define two power controllers: 'parent' and 'child'.
Domains created by the 'child' power controller are subdomains of '0' power Domains created by the 'child' power controller are subdomains of '0' power
domain provided by the 'parent' power controller. domain provided by the 'parent' power controller.
Example 3:
parent: power-controller@12340000 {
compatible = "foo,power-controller";
reg = <0x12340000 0x1000>;
#power-domain-cells = <0>;
domain-idle-states = <&DOMAIN_RET>, <&DOMAIN_PWR_DN>;
};
child: power-controller@12341000 {
compatible = "foo,power-controller";
reg = <0x12341000 0x1000>;
power-domains = <&parent 0>;
#power-domain-cells = <0>;
domain-idle-states = <&DOMAIN_PWR_DN>;
};
DOMAIN_RET: state@0 {
compatible = "domain-idle-state";
reg = <0x0>;
entry-latency-us = <1000>;
exit-latency-us = <2000>;
min-residency-us = <10000>;
};
DOMAIN_PWR_DN: state@1 {
compatible = "domain-idle-state";
reg = <0x1>;
entry-latency-us = <5000>;
exit-latency-us = <8000>;
min-residency-us = <7000>;
};
==PM domain consumers== ==PM domain consumers==
Required properties: Required properties:
...@@ -76,3 +117,5 @@ Example: ...@@ -76,3 +117,5 @@ Example:
The node above defines a typical PM domain consumer device, which is located The node above defines a typical PM domain consumer device, which is located
inside a PM domain with index 0 of a power controller represented by a node inside a PM domain with index 0 of a power controller represented by a node
with the label "power". with the label "power".
[1]. Documentation/devicetree/bindings/power/domain-idle-state.txt
...@@ -607,7 +607,9 @@ individually. Instead, a set of devices sharing a power resource can be put ...@@ -607,7 +607,9 @@ individually. Instead, a set of devices sharing a power resource can be put
into a low-power state together at the same time by turning off the shared into a low-power state together at the same time by turning off the shared
power resource. Of course, they also need to be put into the full-power state power resource. Of course, they also need to be put into the full-power state
together, by turning the shared power resource on. A set of devices with this together, by turning the shared power resource on. A set of devices with this
property is often referred to as a power domain. property is often referred to as a power domain. A power domain may also be
nested inside another power domain. The nested domain is referred to as the
sub-domain of the parent domain.
Support for power domains is provided through the pm_domain field of struct Support for power domains is provided through the pm_domain field of struct
device. This field is a pointer to an object of type struct dev_pm_domain, device. This field is a pointer to an object of type struct dev_pm_domain,
...@@ -629,6 +631,16 @@ support for power domains into subsystem-level callbacks, for example by ...@@ -629,6 +631,16 @@ support for power domains into subsystem-level callbacks, for example by
modifying the platform bus type. Other platforms need not implement it or take modifying the platform bus type. Other platforms need not implement it or take
it into account in any way. it into account in any way.
Devices may be defined as IRQ-safe which indicates to the PM core that their
runtime PM callbacks may be invoked with disabled interrupts (see
Documentation/power/runtime_pm.txt for more information). If an IRQ-safe
device belongs to a PM domain, the runtime PM of the domain will be
disallowed, unless the domain itself is defined as IRQ-safe. However, it
makes sense to define a PM domain as IRQ-safe only if all the devices in it
are IRQ-safe. Moreover, if an IRQ-safe domain has a parent domain, the runtime
PM of the parent is only allowed if the parent itself is IRQ-safe too with the
additional restriction that all child domains of an IRQ-safe parent must also
be IRQ-safe.
Device Low Power (suspend) States Device Low Power (suspend) States
--------------------------------- ---------------------------------
......
...@@ -380,13 +380,6 @@ static struct pu_domain imx6q_pu_domain = { ...@@ -380,13 +380,6 @@ static struct pu_domain imx6q_pu_domain = {
.name = "PU", .name = "PU",
.power_off = imx6q_pm_pu_power_off, .power_off = imx6q_pm_pu_power_off,
.power_on = imx6q_pm_pu_power_on, .power_on = imx6q_pm_pu_power_on,
.states = {
[0] = {
.power_off_latency_ns = 25000,
.power_on_latency_ns = 2000000,
},
},
.state_count = 1,
}, },
}; };
...@@ -430,6 +423,16 @@ static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg) ...@@ -430,6 +423,16 @@ static int imx_gpc_genpd_init(struct device *dev, struct regulator *pu_reg)
if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS)) if (!IS_ENABLED(CONFIG_PM_GENERIC_DOMAINS))
return 0; return 0;
imx6q_pu_domain.base.states = devm_kzalloc(dev,
sizeof(*imx6q_pu_domain.base.states),
GFP_KERNEL);
if (!imx6q_pu_domain.base.states)
return -ENOMEM;
imx6q_pu_domain.base.states[0].power_off_latency_ns = 25000;
imx6q_pu_domain.base.states[0].power_on_latency_ns = 2000000;
imx6q_pu_domain.base.state_count = 1;
for (i = 0; i < ARRAY_SIZE(imx_gpc_domains); i++) for (i = 0; i < ARRAY_SIZE(imx_gpc_domains); i++)
pm_genpd_init(imx_gpc_domains[i], NULL, false); pm_genpd_init(imx_gpc_domains[i], NULL, false);
......
This diff is collapsed.
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/spinlock.h>
/* Defines used for the flags field in the struct generic_pm_domain */ /* Defines used for the flags field in the struct generic_pm_domain */
#define GENPD_FLAG_PM_CLK (1U << 0) /* PM domain uses PM clk */ #define GENPD_FLAG_PM_CLK (1U << 0) /* PM domain uses PM clk */
#define GENPD_FLAG_IRQ_SAFE (1U << 1) /* PM domain operates in atomic */
#define GENPD_MAX_NUM_STATES 8 /* Number of possible low power states */
enum gpd_status { enum gpd_status {
GPD_STATE_ACTIVE = 0, /* PM domain is active */ GPD_STATE_ACTIVE = 0, /* PM domain is active */
...@@ -40,15 +40,18 @@ struct gpd_dev_ops { ...@@ -40,15 +40,18 @@ struct gpd_dev_ops {
struct genpd_power_state { struct genpd_power_state {
s64 power_off_latency_ns; s64 power_off_latency_ns;
s64 power_on_latency_ns; s64 power_on_latency_ns;
s64 residency_ns;
struct fwnode_handle *fwnode;
}; };
struct genpd_lock_ops;
struct generic_pm_domain { struct generic_pm_domain {
struct dev_pm_domain domain; /* PM domain operations */ struct dev_pm_domain domain; /* PM domain operations */
struct list_head gpd_list_node; /* Node in the global PM domains list */ struct list_head gpd_list_node; /* Node in the global PM domains list */
struct list_head master_links; /* Links with PM domain as a master */ struct list_head master_links; /* Links with PM domain as a master */
struct list_head slave_links; /* Links with PM domain as a slave */ struct list_head slave_links; /* Links with PM domain as a slave */
struct list_head dev_list; /* List of devices */ struct list_head dev_list; /* List of devices */
struct mutex lock;
struct dev_power_governor *gov; struct dev_power_governor *gov;
struct work_struct power_off_work; struct work_struct power_off_work;
struct fwnode_handle *provider; /* Identity of the domain provider */ struct fwnode_handle *provider; /* Identity of the domain provider */
...@@ -70,9 +73,18 @@ struct generic_pm_domain { ...@@ -70,9 +73,18 @@ struct generic_pm_domain {
void (*detach_dev)(struct generic_pm_domain *domain, void (*detach_dev)(struct generic_pm_domain *domain,
struct device *dev); struct device *dev);
unsigned int flags; /* Bit field of configs for genpd */ unsigned int flags; /* Bit field of configs for genpd */
struct genpd_power_state states[GENPD_MAX_NUM_STATES]; struct genpd_power_state *states;
unsigned int state_count; /* number of states */ unsigned int state_count; /* number of states */
unsigned int state_idx; /* state that genpd will go to when off */ unsigned int state_idx; /* state that genpd will go to when off */
void *free; /* Free the state that was allocated for default */
const struct genpd_lock_ops *lock_ops;
union {
struct mutex mlock;
struct {
spinlock_t slock;
unsigned long lock_flags;
};
};
}; };
...@@ -205,6 +217,8 @@ extern int of_genpd_add_device(struct of_phandle_args *args, ...@@ -205,6 +217,8 @@ extern int of_genpd_add_device(struct of_phandle_args *args,
extern int of_genpd_add_subdomain(struct of_phandle_args *parent, extern int of_genpd_add_subdomain(struct of_phandle_args *parent,
struct of_phandle_args *new_subdomain); struct of_phandle_args *new_subdomain);
extern struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); extern struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
extern int of_genpd_parse_idle_states(struct device_node *dn,
struct genpd_power_state **states, int *n);
int genpd_dev_pm_attach(struct device *dev); int genpd_dev_pm_attach(struct device *dev);
#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
...@@ -234,6 +248,12 @@ static inline int of_genpd_add_subdomain(struct of_phandle_args *parent, ...@@ -234,6 +248,12 @@ static inline int of_genpd_add_subdomain(struct of_phandle_args *parent,
return -ENODEV; return -ENODEV;
} }
static inline int of_genpd_parse_idle_states(struct device_node *dn,
struct genpd_power_state **states, int *n)
{
return -ENODEV;
}
static inline int genpd_dev_pm_attach(struct device *dev) static inline int genpd_dev_pm_attach(struct device *dev)
{ {
return -ENODEV; return -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment