Thomas Gleixner | 55716d2 | 2019-06-01 10:08:42 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 2 | /* |
| 3 | * pm_domain.h - Definitions and headers related to device power domains. |
| 4 | * |
| 5 | * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp. |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef _LINUX_PM_DOMAIN_H |
| 9 | #define _LINUX_PM_DOMAIN_H |
| 10 | |
| 11 | #include <linux/device.h> |
Paul Gortmaker | 313162d | 2012-01-30 11:46:54 -0500 | [diff] [blame] | 12 | #include <linux/mutex.h> |
| 13 | #include <linux/pm.h> |
Guennadi Liakhovetski | 4f042cd | 2011-12-01 00:05:31 +0100 | [diff] [blame] | 14 | #include <linux/err.h> |
Thomas Abraham | c8aa130 | 2012-01-27 15:22:07 +0900 | [diff] [blame] | 15 | #include <linux/of.h> |
Rafael J. Wysocki | 6ff7bb0d0 | 2012-05-01 21:34:07 +0200 | [diff] [blame] | 16 | #include <linux/notifier.h> |
Lina Iyer | d716f47 | 2016-10-14 10:47:55 -0700 | [diff] [blame] | 17 | #include <linux/spinlock.h> |
Ulf Hansson | eb594b7 | 2019-03-27 15:35:46 +0100 | [diff] [blame] | 18 | #include <linux/cpumask.h> |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 19 | |
Ulf Hansson | e5089c2 | 2018-10-03 16:38:16 +0200 | [diff] [blame] | 20 | /* |
| 21 | * Flags to control the behaviour of a genpd. |
| 22 | * |
| 23 | * These flags may be set in the struct generic_pm_domain's flags field by a |
| 24 | * genpd backend driver. The flags must be set before it calls pm_genpd_init(), |
| 25 | * which initializes a genpd. |
| 26 | * |
| 27 | * GENPD_FLAG_PM_CLK: Instructs genpd to use the PM clk framework, |
| 28 | * while powering on/off attached devices. |
| 29 | * |
| 30 | * GENPD_FLAG_IRQ_SAFE: This informs genpd that its backend callbacks, |
| 31 | * ->power_on|off(), doesn't sleep. Hence, these |
| 32 | * can be invoked from within atomic context, which |
| 33 | * enables genpd to power on/off the PM domain, |
| 34 | * even when pm_runtime_is_irq_safe() returns true, |
| 35 | * for any of its attached devices. Note that, a |
| 36 | * genpd having this flag set, requires its |
| 37 | * masterdomains to also have it set. |
| 38 | * |
| 39 | * GENPD_FLAG_ALWAYS_ON: Instructs genpd to always keep the PM domain |
| 40 | * powered on. |
| 41 | * |
| 42 | * GENPD_FLAG_ACTIVE_WAKEUP: Instructs genpd to keep the PM domain powered |
| 43 | * on, in case any of its attached devices is used |
| 44 | * in the wakeup path to serve system wakeups. |
Ulf Hansson | eb594b7 | 2019-03-27 15:35:46 +0100 | [diff] [blame] | 45 | * |
| 46 | * GENPD_FLAG_CPU_DOMAIN: Instructs genpd that it should expect to get |
| 47 | * devices attached, which may belong to CPUs or |
| 48 | * possibly have subdomains with CPUs attached. |
| 49 | * This flag enables the genpd backend driver to |
| 50 | * deploy idle power management support for CPUs |
| 51 | * and groups of CPUs. Note that, the backend |
| 52 | * driver must then comply with the so called, |
| 53 | * last-man-standing algorithm, for the CPUs in the |
| 54 | * PM domain. |
Leonard Crestez | ed61e18 | 2019-04-30 15:06:11 +0000 | [diff] [blame] | 55 | * |
| 56 | * GENPD_FLAG_RPM_ALWAYS_ON: Instructs genpd to always keep the PM domain |
| 57 | * powered on except for system suspend. |
Ulf Hansson | e5089c2 | 2018-10-03 16:38:16 +0200 | [diff] [blame] | 58 | */ |
| 59 | #define GENPD_FLAG_PM_CLK (1U << 0) |
| 60 | #define GENPD_FLAG_IRQ_SAFE (1U << 1) |
| 61 | #define GENPD_FLAG_ALWAYS_ON (1U << 2) |
| 62 | #define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) |
Ulf Hansson | eb594b7 | 2019-03-27 15:35:46 +0100 | [diff] [blame] | 63 | #define GENPD_FLAG_CPU_DOMAIN (1U << 4) |
Leonard Crestez | ed61e18 | 2019-04-30 15:06:11 +0000 | [diff] [blame] | 64 | #define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5) |
Ulf Hansson | c11f6f5 | 2014-12-01 12:50:21 +0100 | [diff] [blame] | 65 | |
Rafael J. Wysocki | 17b75ec | 2011-07-12 00:39:29 +0200 | [diff] [blame] | 66 | enum gpd_status { |
| 67 | GPD_STATE_ACTIVE = 0, /* PM domain is active */ |
Rafael J. Wysocki | 17b75ec | 2011-07-12 00:39:29 +0200 | [diff] [blame] | 68 | GPD_STATE_POWER_OFF, /* PM domain is off */ |
| 69 | }; |
Rafael J. Wysocki | 596ba34 | 2011-07-01 22:13:19 +0200 | [diff] [blame] | 70 | |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 71 | struct dev_power_governor { |
| 72 | bool (*power_down_ok)(struct dev_pm_domain *domain); |
Ulf Hansson | 9df3921 | 2016-03-31 11:21:25 +0200 | [diff] [blame] | 73 | bool (*suspend_ok)(struct device *dev); |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 74 | }; |
| 75 | |
Rafael J. Wysocki | d5e4cbf | 2011-11-27 13:11:36 +0100 | [diff] [blame] | 76 | struct gpd_dev_ops { |
| 77 | int (*start)(struct device *dev); |
| 78 | int (*stop)(struct device *dev); |
Rafael J. Wysocki | d5e4cbf | 2011-11-27 13:11:36 +0100 | [diff] [blame] | 79 | }; |
| 80 | |
Axel Haslam | fc5cbf0 | 2016-02-15 11:10:51 +0100 | [diff] [blame] | 81 | struct genpd_power_state { |
| 82 | s64 power_off_latency_ns; |
| 83 | s64 power_on_latency_ns; |
Lina Iyer | 405f722 | 2016-10-14 10:47:50 -0700 | [diff] [blame] | 84 | s64 residency_ns; |
Lina Iyer | 0c9b694 | 2016-10-14 10:47:52 -0700 | [diff] [blame] | 85 | struct fwnode_handle *fwnode; |
Thara Gopinath | afece3a | 2017-07-14 13:10:15 -0400 | [diff] [blame] | 86 | ktime_t idle_time; |
Ulf Hansson | 49a27e2 | 2019-03-27 15:35:45 +0100 | [diff] [blame] | 87 | void *data; |
Axel Haslam | fc5cbf0 | 2016-02-15 11:10:51 +0100 | [diff] [blame] | 88 | }; |
| 89 | |
Lina Iyer | 35241d1 | 2016-10-14 10:47:54 -0700 | [diff] [blame] | 90 | struct genpd_lock_ops; |
Viresh Kumar | 6e41766 | 2017-11-29 15:21:51 +0530 | [diff] [blame] | 91 | struct dev_pm_opp; |
Viresh Kumar | 1067ae3 | 2018-11-02 11:18:08 +0530 | [diff] [blame] | 92 | struct opp_table; |
Lina Iyer | 35241d1 | 2016-10-14 10:47:54 -0700 | [diff] [blame] | 93 | |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 94 | struct generic_pm_domain { |
Viresh Kumar | 401ea15 | 2017-03-17 11:26:19 +0530 | [diff] [blame] | 95 | struct device dev; |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 96 | struct dev_pm_domain domain; /* PM domain operations */ |
Rafael J. Wysocki | 5125bbf38 | 2011-07-13 12:31:52 +0200 | [diff] [blame] | 97 | struct list_head gpd_list_node; /* Node in the global PM domains list */ |
Rafael J. Wysocki | 5063ce1 | 2011-08-08 23:43:40 +0200 | [diff] [blame] | 98 | struct list_head master_links; /* Links with PM domain as a master */ |
| 99 | struct list_head slave_links; /* Links with PM domain as a slave */ |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 100 | struct list_head dev_list; /* List of devices */ |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 101 | struct dev_power_governor *gov; |
| 102 | struct work_struct power_off_work; |
Jon Hunter | de0aa06d | 2016-09-12 12:01:12 +0100 | [diff] [blame] | 103 | struct fwnode_handle *provider; /* Identity of the domain provider */ |
| 104 | bool has_provider; |
Geert Uytterhoeven | d07e9c1 | 2014-08-29 15:13:21 +0200 | [diff] [blame] | 105 | const char *name; |
Rafael J. Wysocki | c4bb316 | 2011-08-08 23:43:04 +0200 | [diff] [blame] | 106 | atomic_t sd_count; /* Number of subdomains with power "on" */ |
Rafael J. Wysocki | 17b75ec | 2011-07-12 00:39:29 +0200 | [diff] [blame] | 107 | enum gpd_status status; /* Current state of the domain */ |
Rafael J. Wysocki | 596ba34 | 2011-07-01 22:13:19 +0200 | [diff] [blame] | 108 | unsigned int device_count; /* Number of devices */ |
| 109 | unsigned int suspended_count; /* System suspend device counter */ |
| 110 | unsigned int prepared_count; /* Suspend counter of prepared devices */ |
Viresh Kumar | 42f6284 | 2017-10-12 15:07:23 +0530 | [diff] [blame] | 111 | unsigned int performance_state; /* Aggregated max performance state */ |
Ulf Hansson | eb594b7 | 2019-03-27 15:35:46 +0100 | [diff] [blame] | 112 | cpumask_var_t cpus; /* A cpumask of the attached CPUs */ |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 113 | int (*power_off)(struct generic_pm_domain *domain); |
| 114 | int (*power_on)(struct generic_pm_domain *domain); |
Viresh Kumar | 1067ae3 | 2018-11-02 11:18:08 +0530 | [diff] [blame] | 115 | struct opp_table *opp_table; /* OPP table of the genpd */ |
Viresh Kumar | 6e41766 | 2017-11-29 15:21:51 +0530 | [diff] [blame] | 116 | unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd, |
| 117 | struct dev_pm_opp *opp); |
Viresh Kumar | 42f6284 | 2017-10-12 15:07:23 +0530 | [diff] [blame] | 118 | int (*set_performance_state)(struct generic_pm_domain *genpd, |
| 119 | unsigned int state); |
Rafael J. Wysocki | d5e4cbf | 2011-11-27 13:11:36 +0100 | [diff] [blame] | 120 | struct gpd_dev_ops dev_ops; |
Rafael J. Wysocki | 221e9b5 | 2011-12-01 00:02:10 +0100 | [diff] [blame] | 121 | s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ |
Rafael J. Wysocki | 6ff7bb0d0 | 2012-05-01 21:34:07 +0200 | [diff] [blame] | 122 | bool max_off_time_changed; |
| 123 | bool cached_power_down_ok; |
Ulf Hansson | e949996 | 2019-04-11 20:17:33 +0200 | [diff] [blame] | 124 | bool cached_power_down_state_idx; |
Ulf Hansson | c16561e | 2014-11-06 00:37:08 +0100 | [diff] [blame] | 125 | int (*attach_dev)(struct generic_pm_domain *domain, |
| 126 | struct device *dev); |
| 127 | void (*detach_dev)(struct generic_pm_domain *domain, |
| 128 | struct device *dev); |
Ulf Hansson | c11f6f5 | 2014-12-01 12:50:21 +0100 | [diff] [blame] | 129 | unsigned int flags; /* Bit field of configs for genpd */ |
Lina Iyer | 59d65b7 | 2016-10-14 10:47:49 -0700 | [diff] [blame] | 130 | struct genpd_power_state *states; |
Ulf Hansson | 49a27e2 | 2019-03-27 15:35:45 +0100 | [diff] [blame] | 131 | void (*free_states)(struct genpd_power_state *states, |
| 132 | unsigned int state_count); |
Axel Haslam | fc5cbf0 | 2016-02-15 11:10:51 +0100 | [diff] [blame] | 133 | unsigned int state_count; /* number of states */ |
| 134 | unsigned int state_idx; /* state that genpd will go to when off */ |
Thara Gopinath | afece3a | 2017-07-14 13:10:15 -0400 | [diff] [blame] | 135 | ktime_t on_time; |
| 136 | ktime_t accounting_time; |
Lina Iyer | 35241d1 | 2016-10-14 10:47:54 -0700 | [diff] [blame] | 137 | const struct genpd_lock_ops *lock_ops; |
Lina Iyer | d716f47 | 2016-10-14 10:47:55 -0700 | [diff] [blame] | 138 | union { |
| 139 | struct mutex mlock; |
| 140 | struct { |
| 141 | spinlock_t slock; |
| 142 | unsigned long lock_flags; |
| 143 | }; |
| 144 | }; |
Axel Haslam | fc5cbf0 | 2016-02-15 11:10:51 +0100 | [diff] [blame] | 145 | |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 146 | }; |
| 147 | |
Rafael J. Wysocki | 596ba34 | 2011-07-01 22:13:19 +0200 | [diff] [blame] | 148 | static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) |
| 149 | { |
| 150 | return container_of(pd, struct generic_pm_domain, domain); |
| 151 | } |
| 152 | |
Rafael J. Wysocki | 5063ce1 | 2011-08-08 23:43:40 +0200 | [diff] [blame] | 153 | struct gpd_link { |
| 154 | struct generic_pm_domain *master; |
| 155 | struct list_head master_node; |
| 156 | struct generic_pm_domain *slave; |
| 157 | struct list_head slave_node; |
Viresh Kumar | 18edf49 | 2018-11-02 14:40:19 +0530 | [diff] [blame] | 158 | |
| 159 | /* Sub-domain's per-master domain performance state */ |
| 160 | unsigned int performance_state; |
| 161 | unsigned int prev_performance_state; |
Rafael J. Wysocki | 5063ce1 | 2011-08-08 23:43:40 +0200 | [diff] [blame] | 162 | }; |
| 163 | |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 164 | struct gpd_timing_data { |
Ulf Hansson | 2b1d88c | 2015-10-15 17:02:19 +0200 | [diff] [blame] | 165 | s64 suspend_latency_ns; |
| 166 | s64 resume_latency_ns; |
Rafael J. Wysocki | a5bef810 | 2012-04-29 22:54:17 +0200 | [diff] [blame] | 167 | s64 effective_constraint_ns; |
Rafael J. Wysocki | 6ff7bb0d0 | 2012-05-01 21:34:07 +0200 | [diff] [blame] | 168 | bool constraint_changed; |
Ulf Hansson | 9df3921 | 2016-03-31 11:21:25 +0200 | [diff] [blame] | 169 | bool cached_suspend_ok; |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
Ulf Hansson | 00e7c29 | 2014-11-14 08:41:32 +0100 | [diff] [blame] | 172 | struct pm_domain_data { |
| 173 | struct list_head list_node; |
| 174 | struct device *dev; |
| 175 | }; |
| 176 | |
Rafael J. Wysocki | cd0ea67 | 2011-09-26 20:22:02 +0200 | [diff] [blame] | 177 | struct generic_pm_domain_data { |
| 178 | struct pm_domain_data base; |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 179 | struct gpd_timing_data td; |
Rafael J. Wysocki | 6ff7bb0d0 | 2012-05-01 21:34:07 +0200 | [diff] [blame] | 180 | struct notifier_block nb; |
Ulf Hansson | f9ccd7c | 2019-04-25 11:04:13 +0200 | [diff] [blame] | 181 | int cpu; |
Viresh Kumar | 42f6284 | 2017-10-12 15:07:23 +0530 | [diff] [blame] | 182 | unsigned int performance_state; |
Dave Gerlach | a5ea7a0 | 2017-04-04 08:51:29 -0700 | [diff] [blame] | 183 | void *data; |
Rafael J. Wysocki | cd0ea67 | 2011-09-26 20:22:02 +0200 | [diff] [blame] | 184 | }; |
| 185 | |
Guennadi Liakhovetski | 9b4f617b | 2012-02-04 22:26:49 +0100 | [diff] [blame] | 186 | #ifdef CONFIG_PM_GENERIC_DOMAINS |
Rafael J. Wysocki | cd0ea67 | 2011-09-26 20:22:02 +0200 | [diff] [blame] | 187 | static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd) |
| 188 | { |
| 189 | return container_of(pdd, struct generic_pm_domain_data, base); |
| 190 | } |
| 191 | |
Rafael J. Wysocki | d5e4cbf | 2011-11-27 13:11:36 +0100 | [diff] [blame] | 192 | static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) |
| 193 | { |
| 194 | return to_gpd_data(dev->power.subsys_data->domain_data); |
| 195 | } |
| 196 | |
Ulf Hansson | 1a7a670 | 2018-05-29 12:04:14 +0200 | [diff] [blame] | 197 | int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev); |
Ulf Hansson | 924f448 | 2018-05-29 12:04:15 +0200 | [diff] [blame] | 198 | int pm_genpd_remove_device(struct device *dev); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 199 | int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, |
Ulf Hansson | 0d1e16c | 2019-07-16 11:43:20 +0200 | [diff] [blame] | 200 | struct generic_pm_domain *subdomain); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 201 | int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, |
Ulf Hansson | 0d1e16c | 2019-07-16 11:43:20 +0200 | [diff] [blame] | 202 | struct generic_pm_domain *subdomain); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 203 | int pm_genpd_init(struct generic_pm_domain *genpd, |
| 204 | struct dev_power_governor *gov, bool is_off); |
| 205 | int pm_genpd_remove(struct generic_pm_domain *genpd); |
| 206 | int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state); |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 207 | |
Ulf Hansson | ae3c511 | 2014-09-03 12:52:31 +0200 | [diff] [blame] | 208 | extern struct dev_power_governor simple_qos_governor; |
Mark Brown | 925b44a | 2011-12-08 23:27:28 +0100 | [diff] [blame] | 209 | extern struct dev_power_governor pm_domain_always_on_gov; |
Ulf Hansson | e949996 | 2019-04-11 20:17:33 +0200 | [diff] [blame] | 210 | #ifdef CONFIG_CPU_IDLE |
| 211 | extern struct dev_power_governor pm_domain_cpu_gov; |
| 212 | #endif |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 213 | #else |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 214 | |
Magnus Damm | b642631 | 2012-02-25 22:14:18 +0100 | [diff] [blame] | 215 | static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev) |
| 216 | { |
| 217 | return ERR_PTR(-ENOSYS); |
| 218 | } |
Ulf Hansson | 1a7a670 | 2018-05-29 12:04:14 +0200 | [diff] [blame] | 219 | static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, |
| 220 | struct device *dev) |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 221 | { |
| 222 | return -ENOSYS; |
| 223 | } |
Ulf Hansson | 924f448 | 2018-05-29 12:04:15 +0200 | [diff] [blame] | 224 | static inline int pm_genpd_remove_device(struct device *dev) |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 225 | { |
| 226 | return -ENOSYS; |
| 227 | } |
| 228 | static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, |
Ulf Hansson | 0d1e16c | 2019-07-16 11:43:20 +0200 | [diff] [blame] | 229 | struct generic_pm_domain *subdomain) |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 230 | { |
| 231 | return -ENOSYS; |
| 232 | } |
| 233 | static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, |
Ulf Hansson | 0d1e16c | 2019-07-16 11:43:20 +0200 | [diff] [blame] | 234 | struct generic_pm_domain *subdomain) |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 235 | { |
| 236 | return -ENOSYS; |
| 237 | } |
Ulf Hansson | 7eb231c | 2016-06-17 12:27:52 +0200 | [diff] [blame] | 238 | static inline int pm_genpd_init(struct generic_pm_domain *genpd, |
| 239 | struct dev_power_governor *gov, bool is_off) |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 240 | { |
Ulf Hansson | 7eb231c | 2016-06-17 12:27:52 +0200 | [diff] [blame] | 241 | return -ENOSYS; |
Rafael J. Wysocki | b02c999 | 2011-12-01 00:02:05 +0100 | [diff] [blame] | 242 | } |
Jon Hunter | 3fe5771 | 2016-09-12 12:01:13 +0100 | [diff] [blame] | 243 | static inline int pm_genpd_remove(struct generic_pm_domain *genpd) |
| 244 | { |
| 245 | return -ENOTSUPP; |
| 246 | } |
Geert Uytterhoeven | 16d0bf1 | 2017-02-08 19:37:55 +0100 | [diff] [blame] | 247 | |
Viresh Kumar | 42f6284 | 2017-10-12 15:07:23 +0530 | [diff] [blame] | 248 | static inline int dev_pm_genpd_set_performance_state(struct device *dev, |
| 249 | unsigned int state) |
| 250 | { |
| 251 | return -ENOTSUPP; |
| 252 | } |
| 253 | |
Geert Uytterhoeven | 16d0bf1 | 2017-02-08 19:37:55 +0100 | [diff] [blame] | 254 | #define simple_qos_governor (*(struct dev_power_governor *)(NULL)) |
| 255 | #define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL)) |
Rafael J. Wysocki | 17f2ae7 | 2011-08-14 13:34:31 +0200 | [diff] [blame] | 256 | #endif |
| 257 | |
Rafael J. Wysocki | 77f827d | 2012-08-06 01:39:57 +0200 | [diff] [blame] | 258 | #ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 259 | void pm_genpd_syscore_poweroff(struct device *dev); |
| 260 | void pm_genpd_syscore_poweron(struct device *dev); |
Rafael J. Wysocki | 77f827d | 2012-08-06 01:39:57 +0200 | [diff] [blame] | 261 | #else |
Ulf Hansson | d47e646 | 2014-09-03 12:52:24 +0200 | [diff] [blame] | 262 | static inline void pm_genpd_syscore_poweroff(struct device *dev) {} |
| 263 | static inline void pm_genpd_syscore_poweron(struct device *dev) {} |
Rafael J. Wysocki | 77f827d | 2012-08-06 01:39:57 +0200 | [diff] [blame] | 264 | #endif |
| 265 | |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 266 | /* OF PM domain providers */ |
| 267 | struct of_device_id; |
| 268 | |
Thierry Reding | 4084552 | 2017-03-29 18:34:50 +0200 | [diff] [blame] | 269 | typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args, |
| 270 | void *data); |
| 271 | |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 272 | struct genpd_onecell_data { |
| 273 | struct generic_pm_domain **domains; |
| 274 | unsigned int num_domains; |
Thierry Reding | 4084552 | 2017-03-29 18:34:50 +0200 | [diff] [blame] | 275 | genpd_xlate_t xlate; |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 276 | }; |
| 277 | |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 278 | #ifdef CONFIG_PM_GENERIC_DOMAINS_OF |
Jon Hunter | 892ebdcc | 2016-09-12 12:01:09 +0100 | [diff] [blame] | 279 | int of_genpd_add_provider_simple(struct device_node *np, |
| 280 | struct generic_pm_domain *genpd); |
| 281 | int of_genpd_add_provider_onecell(struct device_node *np, |
| 282 | struct genpd_onecell_data *data); |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 283 | void of_genpd_del_provider(struct device_node *np); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 284 | int of_genpd_add_device(struct of_phandle_args *args, struct device *dev); |
Ulf Hansson | 0d1e16c | 2019-07-16 11:43:20 +0200 | [diff] [blame] | 285 | int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, |
| 286 | struct of_phandle_args *subdomain_spec); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 287 | struct generic_pm_domain *of_genpd_remove_last(struct device_node *np); |
| 288 | int of_genpd_parse_idle_states(struct device_node *dn, |
| 289 | struct genpd_power_state **states, int *n); |
Viresh Kumar | e38f89d | 2018-06-13 20:22:04 +0530 | [diff] [blame] | 290 | unsigned int pm_genpd_opp_to_performance_state(struct device *genpd_dev, |
| 291 | struct dev_pm_opp *opp); |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 292 | |
| 293 | int genpd_dev_pm_attach(struct device *dev); |
Ulf Hansson | 3c095f3 | 2018-05-31 12:59:58 +0200 | [diff] [blame] | 294 | struct device *genpd_dev_pm_attach_by_id(struct device *dev, |
| 295 | unsigned int index); |
Ulf Hansson | 5d6be70 | 2018-06-29 13:04:31 +0200 | [diff] [blame] | 296 | struct device *genpd_dev_pm_attach_by_name(struct device *dev, |
Douglas Anderson | 7416f1f | 2019-02-14 10:12:48 -0800 | [diff] [blame] | 297 | const char *name); |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 298 | #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ |
Jon Hunter | 892ebdcc | 2016-09-12 12:01:09 +0100 | [diff] [blame] | 299 | static inline int of_genpd_add_provider_simple(struct device_node *np, |
| 300 | struct generic_pm_domain *genpd) |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 301 | { |
Jon Hunter | 892ebdcc | 2016-09-12 12:01:09 +0100 | [diff] [blame] | 302 | return -ENOTSUPP; |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 303 | } |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 304 | |
Jon Hunter | 892ebdcc | 2016-09-12 12:01:09 +0100 | [diff] [blame] | 305 | static inline int of_genpd_add_provider_onecell(struct device_node *np, |
| 306 | struct genpd_onecell_data *data) |
| 307 | { |
| 308 | return -ENOTSUPP; |
| 309 | } |
| 310 | |
| 311 | static inline void of_genpd_del_provider(struct device_node *np) {} |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 312 | |
Jon Hunter | ec69572 | 2016-09-12 12:01:05 +0100 | [diff] [blame] | 313 | static inline int of_genpd_add_device(struct of_phandle_args *args, |
| 314 | struct device *dev) |
| 315 | { |
| 316 | return -ENODEV; |
| 317 | } |
| 318 | |
Ulf Hansson | 0d1e16c | 2019-07-16 11:43:20 +0200 | [diff] [blame] | 319 | static inline int of_genpd_add_subdomain(struct of_phandle_args *parent_spec, |
| 320 | struct of_phandle_args *subdomain_spec) |
Jon Hunter | ec69572 | 2016-09-12 12:01:05 +0100 | [diff] [blame] | 321 | { |
| 322 | return -ENODEV; |
| 323 | } |
| 324 | |
Lina Iyer | 30f6042 | 2016-10-14 10:47:51 -0700 | [diff] [blame] | 325 | static inline int of_genpd_parse_idle_states(struct device_node *dn, |
| 326 | struct genpd_power_state **states, int *n) |
| 327 | { |
| 328 | return -ENODEV; |
| 329 | } |
| 330 | |
Viresh Kumar | 6e41766 | 2017-11-29 15:21:51 +0530 | [diff] [blame] | 331 | static inline unsigned int |
Viresh Kumar | e38f89d | 2018-06-13 20:22:04 +0530 | [diff] [blame] | 332 | pm_genpd_opp_to_performance_state(struct device *genpd_dev, |
| 333 | struct dev_pm_opp *opp) |
| 334 | { |
| 335 | return 0; |
| 336 | } |
| 337 | |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 338 | static inline int genpd_dev_pm_attach(struct device *dev) |
| 339 | { |
Ulf Hansson | 919b730 | 2018-05-09 12:17:52 +0200 | [diff] [blame] | 340 | return 0; |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 341 | } |
Jon Hunter | 1792655 | 2016-09-12 12:01:14 +0100 | [diff] [blame] | 342 | |
Ulf Hansson | 3c095f3 | 2018-05-31 12:59:58 +0200 | [diff] [blame] | 343 | static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev, |
| 344 | unsigned int index) |
| 345 | { |
| 346 | return NULL; |
| 347 | } |
| 348 | |
Ulf Hansson | 5d6be70 | 2018-06-29 13:04:31 +0200 | [diff] [blame] | 349 | static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev, |
Douglas Anderson | 7416f1f | 2019-02-14 10:12:48 -0800 | [diff] [blame] | 350 | const char *name) |
Ulf Hansson | 5d6be70 | 2018-06-29 13:04:31 +0200 | [diff] [blame] | 351 | { |
| 352 | return NULL; |
| 353 | } |
| 354 | |
Jon Hunter | 1792655 | 2016-09-12 12:01:14 +0100 | [diff] [blame] | 355 | static inline |
| 356 | struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) |
| 357 | { |
| 358 | return ERR_PTR(-ENOTSUPP); |
| 359 | } |
Tomasz Figa | aa42240 | 2014-09-19 20:27:36 +0200 | [diff] [blame] | 360 | #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ |
| 361 | |
Ulf Hansson | f48c767 | 2014-09-29 13:58:47 +0200 | [diff] [blame] | 362 | #ifdef CONFIG_PM |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 363 | int dev_pm_domain_attach(struct device *dev, bool power_on); |
Ulf Hansson | 82e12d9 | 2018-05-31 12:59:59 +0200 | [diff] [blame] | 364 | struct device *dev_pm_domain_attach_by_id(struct device *dev, |
| 365 | unsigned int index); |
Ulf Hansson | 27dceb8 | 2018-06-29 13:04:32 +0200 | [diff] [blame] | 366 | struct device *dev_pm_domain_attach_by_name(struct device *dev, |
Douglas Anderson | eeb35df | 2019-02-14 10:12:49 -0800 | [diff] [blame] | 367 | const char *name); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 368 | void dev_pm_domain_detach(struct device *dev, bool power_off); |
Ulf Hansson | ca765a8 | 2019-10-16 15:16:03 +0200 | [diff] [blame] | 369 | int dev_pm_domain_start(struct device *dev); |
Ulf Hansson | 781b9d6 | 2018-05-29 12:04:13 +0200 | [diff] [blame] | 370 | void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); |
Ulf Hansson | f48c767 | 2014-09-29 13:58:47 +0200 | [diff] [blame] | 371 | #else |
| 372 | static inline int dev_pm_domain_attach(struct device *dev, bool power_on) |
| 373 | { |
Ulf Hansson | 919b730 | 2018-05-09 12:17:52 +0200 | [diff] [blame] | 374 | return 0; |
Ulf Hansson | f48c767 | 2014-09-29 13:58:47 +0200 | [diff] [blame] | 375 | } |
Ulf Hansson | 82e12d9 | 2018-05-31 12:59:59 +0200 | [diff] [blame] | 376 | static inline struct device *dev_pm_domain_attach_by_id(struct device *dev, |
| 377 | unsigned int index) |
| 378 | { |
| 379 | return NULL; |
| 380 | } |
Ulf Hansson | 27dceb8 | 2018-06-29 13:04:32 +0200 | [diff] [blame] | 381 | static inline struct device *dev_pm_domain_attach_by_name(struct device *dev, |
Douglas Anderson | eeb35df | 2019-02-14 10:12:49 -0800 | [diff] [blame] | 382 | const char *name) |
Ulf Hansson | 27dceb8 | 2018-06-29 13:04:32 +0200 | [diff] [blame] | 383 | { |
| 384 | return NULL; |
| 385 | } |
Ulf Hansson | f48c767 | 2014-09-29 13:58:47 +0200 | [diff] [blame] | 386 | static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {} |
Ulf Hansson | ca765a8 | 2019-10-16 15:16:03 +0200 | [diff] [blame] | 387 | static inline int dev_pm_domain_start(struct device *dev) |
| 388 | { |
| 389 | return 0; |
| 390 | } |
Tomeu Vizoso | 989561d | 2016-01-07 16:46:13 +0100 | [diff] [blame] | 391 | static inline void dev_pm_domain_set(struct device *dev, |
| 392 | struct dev_pm_domain *pd) {} |
Ulf Hansson | f48c767 | 2014-09-29 13:58:47 +0200 | [diff] [blame] | 393 | #endif |
| 394 | |
Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame] | 395 | #endif /* _LINUX_PM_DOMAIN_H */ |