| @@ -16,6 +16,7 @@ · 15 unmodified lines |
| 16 | #include <linux/of.h> | 16 | #include <linux/of.h> |
| 17 | #include <linux/notifier.h> | 17 | #include <linux/notifier.h> |
| 18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
| | 19 | #include <linux/cpumask.h> |
| 19 | | 20 | |
| 20 | /* | 21 | /* |
| 21 | * Flags to control the behaviour of a genpd. | 22 | * Flags to control the behaviour of a genpd. |
| @@ -42,11 +43,22 @@ · 20 unmodified lines |
| 42 | * GENPD_FLAG_ACTIVE_WAKEUP: Instructs genpd to keep the PM domain powered | 43 | * GENPD_FLAG_ACTIVE_WAKEUP: Instructs genpd to keep the PM domain powered |
| 43 | * on, in case any of its attached devices is used | 44 | * on, in case any of its attached devices is used |
| 44 | * in the wakeup path to serve system wakeups. | 45 | * in the wakeup path to serve system wakeups. |
| | 46 | * |
| | 47 | * GENPD_FLAG_CPU_DOMAIN: Instructs genpd that it should expect to get |
| | 48 | * devices attached, which may belong to CPUs or |
| | 49 | * possibly have subdomains with CPUs attached. |
| | 50 | * This flag enables the genpd backend driver to |
| | 51 | * deploy idle power management support for CPUs |
| | 52 | * and groups of CPUs. Note that, the backend |
| | 53 | * driver must then comply with the so called, |
| | 54 | * last-man-standing algorithm, for the CPUs in the |
| | 55 | * PM domain. |
| 45 | */ | 56 | */ |
| 46 | #define GENPD_FLAG_PM_CLK (1U << 0) | 57 | #define GENPD_FLAG_PM_CLK (1U << 0) |
| 47 | #define GENPD_FLAG_IRQ_SAFE (1U << 1) | 58 | #define GENPD_FLAG_IRQ_SAFE (1U << 1) |
| 48 | #define GENPD_FLAG_ALWAYS_ON (1U << 2) | 59 | #define GENPD_FLAG_ALWAYS_ON (1U << 2) |
| 49 | #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) | 60 | #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) |
| | 61 | #define GENPD_FLAG_CPU_DOMAIN (1U << 4) |
| 50 | | 62 | |
| 51 | enum gpd_status { | 63 | enum gpd_status { |
| 52 | GPD_STATE_ACTIVE = 0, /* PM domain is active */ | 64 | GPD_STATE_ACTIVE = 0, /* PM domain is active */ |
| @@ -69,6 +81,7 @@ struct genpd_power_state { · 16 unmodified lines |
| 69 | s64 residency_ns; | 81 | s64 residency_ns; |
| 70 | struct fwnode_handle *fwnode; | 82 | struct fwnode_handle *fwnode; |
| 71 | ktime_t idle_time; | 83 | ktime_t idle_time; |
| | 84 | void *data; |
| 72 | }; | 85 | }; |
| 73 | | 86 | |
| 74 | struct genpd_lock_ops; | 87 | struct genpd_lock_ops; |
| @@ -93,6 +106,7 @@ struct generic_pm_domain { · 18 unmodified lines |
| 93 | unsigned int suspended_count; /* System suspend device counter */ | 106 | unsigned int suspended_count; /* System suspend device counter */ |
| 94 | unsigned int prepared_count; /* Suspend counter of prepared devices */ | 107 | unsigned int prepared_count; /* Suspend counter of prepared devices */ |
| 95 | unsigned int performance_state; /* Aggregated max performance state */ | 108 | unsigned int performance_state; /* Aggregated max performance state */ |
| | 109 | cpumask_var_t cpus; /* A cpumask of the attached CPUs */ |
| 96 | int (*power_off)(struct generic_pm_domain *domain); | 110 | int (*power_off)(struct generic_pm_domain *domain); |
| 97 | int (*power_on)(struct generic_pm_domain *domain); | 111 | int (*power_on)(struct generic_pm_domain *domain); |
| 98 | struct opp_table *opp_table; /* OPP table of the genpd */ | 112 | struct opp_table *opp_table; /* OPP table of the genpd */ |
| @@ -104,15 +118,17 @@ struct generic_pm_domain { · 5 unmodified lines |
| 104 | s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ | 118 | s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ |
| 105 | bool max_off_time_changed; | 119 | bool max_off_time_changed; |
| 106 | bool cached_power_down_ok; | 120 | bool cached_power_down_ok; |
| | 121 | bool cached_power_down_state_idx; |
| 107 | int (*attach_dev)(struct generic_pm_domain *domain, | 122 | int (*attach_dev)(struct generic_pm_domain *domain, |
| 108 | struct device *dev); | 123 | struct device *dev); |
| 109 | void (*detach_dev)(struct generic_pm_domain *domain, | 124 | void (*detach_dev)(struct generic_pm_domain *domain, |
| 110 | struct device *dev); | 125 | struct device *dev); |
| 111 | unsigned int flags; /* Bit field of configs for genpd */ | 126 | unsigned int flags; /* Bit field of configs for genpd */ |
| 112 | struct genpd_power_state *states; | 127 | struct genpd_power_state *states; |
| | 128 | void (*free_states)(struct genpd_power_state *states, |
| | 129 | unsigned int state_count); |
| 113 | unsigned int state_count; /* number of states */ | 130 | unsigned int state_count; /* number of states */ |
| 114 | unsigned int state_idx; /* state that genpd will go to when off */ | 131 | unsigned int state_idx; /* state that genpd will go to when off */ |
| 115 | void *free; /* Free the state that was allocated for default */ | | |
| 116 | ktime_t on_time; | 132 | ktime_t on_time; |
| 117 | ktime_t accounting_time; | 133 | ktime_t accounting_time; |
| 118 | const struct genpd_lock_ops *lock_ops; | 134 | const struct genpd_lock_ops *lock_ops; |
| @@ -187,6 +203,9 @@ int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); · 68 unmodified lines |
| 187 | | 203 | |
| 188 | extern struct dev_power_governor simple_qos_governor; | 204 | extern struct dev_power_governor simple_qos_governor; |
| 189 | extern struct dev_power_governor pm_domain_always_on_gov; | 205 | extern struct dev_power_governor pm_domain_always_on_gov; |
| | 206 | #ifdef CONFIG_CPU_IDLE |
| | 207 | extern struct dev_power_governor pm_domain_cpu_gov; |
| | 208 | #endif |
| 190 | #else | 209 | #else |
| 191 | | 210 | |
| 192 | static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) | 211 | static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) |