blob: 5a31c711b896654372513bd32532eab7d9b88a14 [file] [log] [blame]
Thomas Gleixner55716d22019-06-01 10:08:42 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Rafael J. Wysockif7218892011-07-01 22:12:45 +02002/*
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. Wysockif7218892011-07-01 22:12:45 +02006 */
7
8#ifndef _LINUX_PM_DOMAIN_H
9#define _LINUX_PM_DOMAIN_H
10
11#include <linux/device.h>
Paul Gortmaker313162d2012-01-30 11:46:54 -050012#include <linux/mutex.h>
13#include <linux/pm.h>
Guennadi Liakhovetski4f042cd2011-12-01 00:05:31 +010014#include <linux/err.h>
Thomas Abrahamc8aa1302012-01-27 15:22:07 +090015#include <linux/of.h>
Rafael J. Wysocki6ff7bb0d02012-05-01 21:34:07 +020016#include <linux/notifier.h>
Lina Iyerd716f472016-10-14 10:47:55 -070017#include <linux/spinlock.h>
Ulf Hanssoneb594b72019-03-27 15:35:46 +010018#include <linux/cpumask.h>
Rafael J. Wysockif7218892011-07-01 22:12:45 +020019
Ulf Hanssone5089c22018-10-03 16:38:16 +020020/*
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 Hanssoneb594b72019-03-27 15:35:46 +010045 *
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 Crestezed61e182019-04-30 15:06:11 +000055 *
56 * GENPD_FLAG_RPM_ALWAYS_ON: Instructs genpd to always keep the PM domain
57 * powered on except for system suspend.
Ulf Hanssone5089c22018-10-03 16:38:16 +020058 */
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 Hanssoneb594b72019-03-27 15:35:46 +010063#define GENPD_FLAG_CPU_DOMAIN (1U << 4)
Leonard Crestezed61e182019-04-30 15:06:11 +000064#define GENPD_FLAG_RPM_ALWAYS_ON (1U << 5)
Ulf Hanssonc11f6f52014-12-01 12:50:21 +010065
Rafael J. Wysocki17b75ec2011-07-12 00:39:29 +020066enum gpd_status {
67 GPD_STATE_ACTIVE = 0, /* PM domain is active */
Rafael J. Wysocki17b75ec2011-07-12 00:39:29 +020068 GPD_STATE_POWER_OFF, /* PM domain is off */
69};
Rafael J. Wysocki596ba342011-07-01 22:13:19 +020070
Rafael J. Wysockif7218892011-07-01 22:12:45 +020071struct dev_power_governor {
72 bool (*power_down_ok)(struct dev_pm_domain *domain);
Ulf Hansson9df39212016-03-31 11:21:25 +020073 bool (*suspend_ok)(struct device *dev);
Rafael J. Wysockif7218892011-07-01 22:12:45 +020074};
75
Rafael J. Wysockid5e4cbf2011-11-27 13:11:36 +010076struct gpd_dev_ops {
77 int (*start)(struct device *dev);
78 int (*stop)(struct device *dev);
Rafael J. Wysockid5e4cbf2011-11-27 13:11:36 +010079};
80
Axel Haslamfc5cbf02016-02-15 11:10:51 +010081struct genpd_power_state {
82 s64 power_off_latency_ns;
83 s64 power_on_latency_ns;
Lina Iyer405f7222016-10-14 10:47:50 -070084 s64 residency_ns;
Lina Iyer0c9b6942016-10-14 10:47:52 -070085 struct fwnode_handle *fwnode;
Thara Gopinathafece3a2017-07-14 13:10:15 -040086 ktime_t idle_time;
Ulf Hansson49a27e22019-03-27 15:35:45 +010087 void *data;
Axel Haslamfc5cbf02016-02-15 11:10:51 +010088};
89
Lina Iyer35241d12016-10-14 10:47:54 -070090struct genpd_lock_ops;
Viresh Kumar6e417662017-11-29 15:21:51 +053091struct dev_pm_opp;
Viresh Kumar1067ae32018-11-02 11:18:08 +053092struct opp_table;
Lina Iyer35241d12016-10-14 10:47:54 -070093
Rafael J. Wysockif7218892011-07-01 22:12:45 +020094struct generic_pm_domain {
Viresh Kumar401ea152017-03-17 11:26:19 +053095 struct device dev;
Rafael J. Wysockif7218892011-07-01 22:12:45 +020096 struct dev_pm_domain domain; /* PM domain operations */
Rafael J. Wysocki5125bbf382011-07-13 12:31:52 +020097 struct list_head gpd_list_node; /* Node in the global PM domains list */
Rafael J. Wysocki5063ce12011-08-08 23:43:40 +020098 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. Wysockif7218892011-07-01 22:12:45 +0200100 struct list_head dev_list; /* List of devices */
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200101 struct dev_power_governor *gov;
102 struct work_struct power_off_work;
Jon Hunterde0aa06d2016-09-12 12:01:12 +0100103 struct fwnode_handle *provider; /* Identity of the domain provider */
104 bool has_provider;
Geert Uytterhoevend07e9c12014-08-29 15:13:21 +0200105 const char *name;
Rafael J. Wysockic4bb3162011-08-08 23:43:04 +0200106 atomic_t sd_count; /* Number of subdomains with power "on" */
Rafael J. Wysocki17b75ec2011-07-12 00:39:29 +0200107 enum gpd_status status; /* Current state of the domain */
Rafael J. Wysocki596ba342011-07-01 22:13:19 +0200108 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 Kumar42f62842017-10-12 15:07:23 +0530111 unsigned int performance_state; /* Aggregated max performance state */
Ulf Hanssoneb594b72019-03-27 15:35:46 +0100112 cpumask_var_t cpus; /* A cpumask of the attached CPUs */
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200113 int (*power_off)(struct generic_pm_domain *domain);
114 int (*power_on)(struct generic_pm_domain *domain);
Viresh Kumar1067ae32018-11-02 11:18:08 +0530115 struct opp_table *opp_table; /* OPP table of the genpd */
Viresh Kumar6e417662017-11-29 15:21:51 +0530116 unsigned int (*opp_to_performance_state)(struct generic_pm_domain *genpd,
117 struct dev_pm_opp *opp);
Viresh Kumar42f62842017-10-12 15:07:23 +0530118 int (*set_performance_state)(struct generic_pm_domain *genpd,
119 unsigned int state);
Rafael J. Wysockid5e4cbf2011-11-27 13:11:36 +0100120 struct gpd_dev_ops dev_ops;
Rafael J. Wysocki221e9b52011-12-01 00:02:10 +0100121 s64 max_off_time_ns; /* Maximum allowed "suspended" time. */
Rafael J. Wysocki6ff7bb0d02012-05-01 21:34:07 +0200122 bool max_off_time_changed;
123 bool cached_power_down_ok;
Ulf Hanssone9499962019-04-11 20:17:33 +0200124 bool cached_power_down_state_idx;
Ulf Hanssonc16561e2014-11-06 00:37:08 +0100125 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 Hanssonc11f6f52014-12-01 12:50:21 +0100129 unsigned int flags; /* Bit field of configs for genpd */
Lina Iyer59d65b72016-10-14 10:47:49 -0700130 struct genpd_power_state *states;
Ulf Hansson49a27e22019-03-27 15:35:45 +0100131 void (*free_states)(struct genpd_power_state *states,
132 unsigned int state_count);
Axel Haslamfc5cbf02016-02-15 11:10:51 +0100133 unsigned int state_count; /* number of states */
134 unsigned int state_idx; /* state that genpd will go to when off */
Thara Gopinathafece3a2017-07-14 13:10:15 -0400135 ktime_t on_time;
136 ktime_t accounting_time;
Lina Iyer35241d12016-10-14 10:47:54 -0700137 const struct genpd_lock_ops *lock_ops;
Lina Iyerd716f472016-10-14 10:47:55 -0700138 union {
139 struct mutex mlock;
140 struct {
141 spinlock_t slock;
142 unsigned long lock_flags;
143 };
144 };
Axel Haslamfc5cbf02016-02-15 11:10:51 +0100145
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200146};
147
Rafael J. Wysocki596ba342011-07-01 22:13:19 +0200148static 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. Wysocki5063ce12011-08-08 23:43:40 +0200153struct 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 Kumar18edf492018-11-02 14:40:19 +0530158
159 /* Sub-domain's per-master domain performance state */
160 unsigned int performance_state;
161 unsigned int prev_performance_state;
Rafael J. Wysocki5063ce12011-08-08 23:43:40 +0200162};
163
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100164struct gpd_timing_data {
Ulf Hansson2b1d88c2015-10-15 17:02:19 +0200165 s64 suspend_latency_ns;
166 s64 resume_latency_ns;
Rafael J. Wysockia5bef8102012-04-29 22:54:17 +0200167 s64 effective_constraint_ns;
Rafael J. Wysocki6ff7bb0d02012-05-01 21:34:07 +0200168 bool constraint_changed;
Ulf Hansson9df39212016-03-31 11:21:25 +0200169 bool cached_suspend_ok;
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100170};
171
Ulf Hansson00e7c292014-11-14 08:41:32 +0100172struct pm_domain_data {
173 struct list_head list_node;
174 struct device *dev;
175};
176
Rafael J. Wysockicd0ea672011-09-26 20:22:02 +0200177struct generic_pm_domain_data {
178 struct pm_domain_data base;
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100179 struct gpd_timing_data td;
Rafael J. Wysocki6ff7bb0d02012-05-01 21:34:07 +0200180 struct notifier_block nb;
Ulf Hanssonf9ccd7c2019-04-25 11:04:13 +0200181 int cpu;
Viresh Kumar42f62842017-10-12 15:07:23 +0530182 unsigned int performance_state;
Dave Gerlacha5ea7a02017-04-04 08:51:29 -0700183 void *data;
Rafael J. Wysockicd0ea672011-09-26 20:22:02 +0200184};
185
Guennadi Liakhovetski9b4f617b2012-02-04 22:26:49 +0100186#ifdef CONFIG_PM_GENERIC_DOMAINS
Rafael J. Wysockicd0ea672011-09-26 20:22:02 +0200187static 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. Wysockid5e4cbf2011-11-27 13:11:36 +0100192static 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 Hansson1a7a6702018-05-29 12:04:14 +0200197int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev);
Ulf Hansson924f4482018-05-29 12:04:15 +0200198int pm_genpd_remove_device(struct device *dev);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200199int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
Ulf Hansson0d1e16c2019-07-16 11:43:20 +0200200 struct generic_pm_domain *subdomain);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200201int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
Ulf Hansson0d1e16c2019-07-16 11:43:20 +0200202 struct generic_pm_domain *subdomain);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200203int pm_genpd_init(struct generic_pm_domain *genpd,
204 struct dev_power_governor *gov, bool is_off);
205int pm_genpd_remove(struct generic_pm_domain *genpd);
206int dev_pm_genpd_set_performance_state(struct device *dev, unsigned int state);
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100207
Ulf Hanssonae3c5112014-09-03 12:52:31 +0200208extern struct dev_power_governor simple_qos_governor;
Mark Brown925b44a2011-12-08 23:27:28 +0100209extern struct dev_power_governor pm_domain_always_on_gov;
Ulf Hanssone9499962019-04-11 20:17:33 +0200210#ifdef CONFIG_CPU_IDLE
211extern struct dev_power_governor pm_domain_cpu_gov;
212#endif
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200213#else
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100214
Magnus Dammb6426312012-02-25 22:14:18 +0100215static inline struct generic_pm_domain_data *dev_gpd_data(struct device *dev)
216{
217 return ERR_PTR(-ENOSYS);
218}
Ulf Hansson1a7a6702018-05-29 12:04:14 +0200219static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
220 struct device *dev)
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100221{
222 return -ENOSYS;
223}
Ulf Hansson924f4482018-05-29 12:04:15 +0200224static inline int pm_genpd_remove_device(struct device *dev)
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200225{
226 return -ENOSYS;
227}
228static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
Ulf Hansson0d1e16c2019-07-16 11:43:20 +0200229 struct generic_pm_domain *subdomain)
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200230{
231 return -ENOSYS;
232}
233static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
Ulf Hansson0d1e16c2019-07-16 11:43:20 +0200234 struct generic_pm_domain *subdomain)
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200235{
236 return -ENOSYS;
237}
Ulf Hansson7eb231c2016-06-17 12:27:52 +0200238static inline int pm_genpd_init(struct generic_pm_domain *genpd,
239 struct dev_power_governor *gov, bool is_off)
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100240{
Ulf Hansson7eb231c2016-06-17 12:27:52 +0200241 return -ENOSYS;
Rafael J. Wysockib02c9992011-12-01 00:02:05 +0100242}
Jon Hunter3fe57712016-09-12 12:01:13 +0100243static inline int pm_genpd_remove(struct generic_pm_domain *genpd)
244{
245 return -ENOTSUPP;
246}
Geert Uytterhoeven16d0bf12017-02-08 19:37:55 +0100247
Viresh Kumar42f62842017-10-12 15:07:23 +0530248static inline int dev_pm_genpd_set_performance_state(struct device *dev,
249 unsigned int state)
250{
251 return -ENOTSUPP;
252}
253
Geert Uytterhoeven16d0bf12017-02-08 19:37:55 +0100254#define simple_qos_governor (*(struct dev_power_governor *)(NULL))
255#define pm_domain_always_on_gov (*(struct dev_power_governor *)(NULL))
Rafael J. Wysocki17f2ae72011-08-14 13:34:31 +0200256#endif
257
Rafael J. Wysocki77f827d2012-08-06 01:39:57 +0200258#ifdef CONFIG_PM_GENERIC_DOMAINS_SLEEP
Ulf Hansson781b9d62018-05-29 12:04:13 +0200259void pm_genpd_syscore_poweroff(struct device *dev);
260void pm_genpd_syscore_poweron(struct device *dev);
Rafael J. Wysocki77f827d2012-08-06 01:39:57 +0200261#else
Ulf Hanssond47e6462014-09-03 12:52:24 +0200262static inline void pm_genpd_syscore_poweroff(struct device *dev) {}
263static inline void pm_genpd_syscore_poweron(struct device *dev) {}
Rafael J. Wysocki77f827d2012-08-06 01:39:57 +0200264#endif
265
Tomasz Figaaa422402014-09-19 20:27:36 +0200266/* OF PM domain providers */
267struct of_device_id;
268
Thierry Reding40845522017-03-29 18:34:50 +0200269typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
270 void *data);
271
Tomasz Figaaa422402014-09-19 20:27:36 +0200272struct genpd_onecell_data {
273 struct generic_pm_domain **domains;
274 unsigned int num_domains;
Thierry Reding40845522017-03-29 18:34:50 +0200275 genpd_xlate_t xlate;
Tomasz Figaaa422402014-09-19 20:27:36 +0200276};
277
Tomasz Figaaa422402014-09-19 20:27:36 +0200278#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
Jon Hunter892ebdcc2016-09-12 12:01:09 +0100279int of_genpd_add_provider_simple(struct device_node *np,
280 struct generic_pm_domain *genpd);
281int of_genpd_add_provider_onecell(struct device_node *np,
282 struct genpd_onecell_data *data);
Tomasz Figaaa422402014-09-19 20:27:36 +0200283void of_genpd_del_provider(struct device_node *np);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200284int of_genpd_add_device(struct of_phandle_args *args, struct device *dev);
Ulf Hansson0d1e16c2019-07-16 11:43:20 +0200285int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
286 struct of_phandle_args *subdomain_spec);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200287struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
288int of_genpd_parse_idle_states(struct device_node *dn,
289 struct genpd_power_state **states, int *n);
Viresh Kumare38f89d2018-06-13 20:22:04 +0530290unsigned int pm_genpd_opp_to_performance_state(struct device *genpd_dev,
291 struct dev_pm_opp *opp);
Tomasz Figaaa422402014-09-19 20:27:36 +0200292
293int genpd_dev_pm_attach(struct device *dev);
Ulf Hansson3c095f32018-05-31 12:59:58 +0200294struct device *genpd_dev_pm_attach_by_id(struct device *dev,
295 unsigned int index);
Ulf Hansson5d6be702018-06-29 13:04:31 +0200296struct device *genpd_dev_pm_attach_by_name(struct device *dev,
Douglas Anderson7416f1f2019-02-14 10:12:48 -0800297 const char *name);
Tomasz Figaaa422402014-09-19 20:27:36 +0200298#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
Jon Hunter892ebdcc2016-09-12 12:01:09 +0100299static inline int of_genpd_add_provider_simple(struct device_node *np,
300 struct generic_pm_domain *genpd)
Tomasz Figaaa422402014-09-19 20:27:36 +0200301{
Jon Hunter892ebdcc2016-09-12 12:01:09 +0100302 return -ENOTSUPP;
Tomasz Figaaa422402014-09-19 20:27:36 +0200303}
Tomasz Figaaa422402014-09-19 20:27:36 +0200304
Jon Hunter892ebdcc2016-09-12 12:01:09 +0100305static inline int of_genpd_add_provider_onecell(struct device_node *np,
306 struct genpd_onecell_data *data)
307{
308 return -ENOTSUPP;
309}
310
311static inline void of_genpd_del_provider(struct device_node *np) {}
Tomasz Figaaa422402014-09-19 20:27:36 +0200312
Jon Hunterec695722016-09-12 12:01:05 +0100313static inline int of_genpd_add_device(struct of_phandle_args *args,
314 struct device *dev)
315{
316 return -ENODEV;
317}
318
Ulf Hansson0d1e16c2019-07-16 11:43:20 +0200319static inline int of_genpd_add_subdomain(struct of_phandle_args *parent_spec,
320 struct of_phandle_args *subdomain_spec)
Jon Hunterec695722016-09-12 12:01:05 +0100321{
322 return -ENODEV;
323}
324
Lina Iyer30f60422016-10-14 10:47:51 -0700325static 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 Kumar6e417662017-11-29 15:21:51 +0530331static inline unsigned int
Viresh Kumare38f89d2018-06-13 20:22:04 +0530332pm_genpd_opp_to_performance_state(struct device *genpd_dev,
333 struct dev_pm_opp *opp)
334{
335 return 0;
336}
337
Tomasz Figaaa422402014-09-19 20:27:36 +0200338static inline int genpd_dev_pm_attach(struct device *dev)
339{
Ulf Hansson919b7302018-05-09 12:17:52 +0200340 return 0;
Tomasz Figaaa422402014-09-19 20:27:36 +0200341}
Jon Hunter17926552016-09-12 12:01:14 +0100342
Ulf Hansson3c095f32018-05-31 12:59:58 +0200343static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev,
344 unsigned int index)
345{
346 return NULL;
347}
348
Ulf Hansson5d6be702018-06-29 13:04:31 +0200349static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev,
Douglas Anderson7416f1f2019-02-14 10:12:48 -0800350 const char *name)
Ulf Hansson5d6be702018-06-29 13:04:31 +0200351{
352 return NULL;
353}
354
Jon Hunter17926552016-09-12 12:01:14 +0100355static inline
356struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
357{
358 return ERR_PTR(-ENOTSUPP);
359}
Tomasz Figaaa422402014-09-19 20:27:36 +0200360#endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
361
Ulf Hanssonf48c7672014-09-29 13:58:47 +0200362#ifdef CONFIG_PM
Ulf Hansson781b9d62018-05-29 12:04:13 +0200363int dev_pm_domain_attach(struct device *dev, bool power_on);
Ulf Hansson82e12d92018-05-31 12:59:59 +0200364struct device *dev_pm_domain_attach_by_id(struct device *dev,
365 unsigned int index);
Ulf Hansson27dceb82018-06-29 13:04:32 +0200366struct device *dev_pm_domain_attach_by_name(struct device *dev,
Douglas Andersoneeb35df2019-02-14 10:12:49 -0800367 const char *name);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200368void dev_pm_domain_detach(struct device *dev, bool power_off);
Ulf Hanssonca765a82019-10-16 15:16:03 +0200369int dev_pm_domain_start(struct device *dev);
Ulf Hansson781b9d62018-05-29 12:04:13 +0200370void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
Ulf Hanssonf48c7672014-09-29 13:58:47 +0200371#else
372static inline int dev_pm_domain_attach(struct device *dev, bool power_on)
373{
Ulf Hansson919b7302018-05-09 12:17:52 +0200374 return 0;
Ulf Hanssonf48c7672014-09-29 13:58:47 +0200375}
Ulf Hansson82e12d92018-05-31 12:59:59 +0200376static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
377 unsigned int index)
378{
379 return NULL;
380}
Ulf Hansson27dceb82018-06-29 13:04:32 +0200381static inline struct device *dev_pm_domain_attach_by_name(struct device *dev,
Douglas Andersoneeb35df2019-02-14 10:12:49 -0800382 const char *name)
Ulf Hansson27dceb82018-06-29 13:04:32 +0200383{
384 return NULL;
385}
Ulf Hanssonf48c7672014-09-29 13:58:47 +0200386static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}
Ulf Hanssonca765a82019-10-16 15:16:03 +0200387static inline int dev_pm_domain_start(struct device *dev)
388{
389 return 0;
390}
Tomeu Vizoso989561d2016-01-07 16:46:13 +0100391static inline void dev_pm_domain_set(struct device *dev,
392 struct dev_pm_domain *pd) {}
Ulf Hanssonf48c7672014-09-29 13:58:47 +0200393#endif
394
Rafael J. Wysockif7218892011-07-01 22:12:45 +0200395#endif /* _LINUX_PM_DOMAIN_H */