]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/linux/pm_domain.h
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1...
[mirror_ubuntu-zesty-kernel.git] / include / linux / pm_domain.h
CommitLineData
f721889f
RW
1/*
2 * pm_domain.h - Definitions and headers related to device power domains.
3 *
4 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
5 *
6 * This file is released under the GPLv2.
7 */
8
9#ifndef _LINUX_PM_DOMAIN_H
10#define _LINUX_PM_DOMAIN_H
11
12#include <linux/device.h>
13
17b75eca
RW
14enum gpd_status {
15 GPD_STATE_ACTIVE = 0, /* PM domain is active */
16 GPD_STATE_BUSY, /* Something is happening to the PM domain */
c6d22b37 17 GPD_STATE_REPEAT, /* Power off in progress, to be repeated */
17b75eca
RW
18 GPD_STATE_POWER_OFF, /* PM domain is off */
19};
596ba34b 20
f721889f
RW
21struct dev_power_governor {
22 bool (*power_down_ok)(struct dev_pm_domain *domain);
23};
24
25struct generic_pm_domain {
26 struct dev_pm_domain domain; /* PM domain operations */
5125bbf3 27 struct list_head gpd_list_node; /* Node in the global PM domains list */
f721889f
RW
28 struct list_head sd_node; /* Node in the parent's subdomain list */
29 struct generic_pm_domain *parent; /* Parent PM domain */
30 struct list_head sd_list; /* List of dubdomains */
31 struct list_head dev_list; /* List of devices */
32 struct mutex lock;
33 struct dev_power_governor *gov;
34 struct work_struct power_off_work;
35 unsigned int in_progress; /* Number of devices being suspended now */
36 unsigned int sd_count; /* Number of subdomains with power "on" */
17b75eca
RW
37 enum gpd_status status; /* Current state of the domain */
38 wait_queue_head_t status_wait_queue;
c6d22b37
RW
39 struct task_struct *poweroff_task; /* Powering off task */
40 unsigned int resume_count; /* Number of devices being resumed */
596ba34b
RW
41 unsigned int device_count; /* Number of devices */
42 unsigned int suspended_count; /* System suspend device counter */
43 unsigned int prepared_count; /* Suspend counter of prepared devices */
44 bool suspend_power_off; /* Power status before system suspend */
f721889f
RW
45 int (*power_off)(struct generic_pm_domain *domain);
46 int (*power_on)(struct generic_pm_domain *domain);
47 int (*start_device)(struct device *dev);
48 int (*stop_device)(struct device *dev);
d4f2d87a 49 bool (*active_wakeup)(struct device *dev);
f721889f
RW
50};
51
596ba34b
RW
52static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
53{
54 return container_of(pd, struct generic_pm_domain, domain);
55}
56
f721889f
RW
57struct dev_list_entry {
58 struct list_head node;
59 struct device *dev;
60 bool need_restore;
61};
62
63#ifdef CONFIG_PM_GENERIC_DOMAINS
64extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
65 struct device *dev);
66extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
67 struct device *dev);
68extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
69 struct generic_pm_domain *new_subdomain);
70extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
71 struct generic_pm_domain *target);
72extern void pm_genpd_init(struct generic_pm_domain *genpd,
73 struct dev_power_governor *gov, bool is_off);
18b4f3f5 74extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
5125bbf3 75extern void pm_genpd_poweroff_unused(void);
0bc5b2de 76extern void genpd_queue_power_off_work(struct generic_pm_domain *genpd);
f721889f
RW
77#else
78static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
79 struct device *dev)
80{
81 return -ENOSYS;
82}
83static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd,
84 struct device *dev)
85{
86 return -ENOSYS;
87}
88static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
89 struct generic_pm_domain *new_sd)
90{
91 return -ENOSYS;
92}
93static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
94 struct generic_pm_domain *target)
95{
96 return -ENOSYS;
97}
98static inline void pm_genpd_init(struct generic_pm_domain *genpd,
99 struct dev_power_governor *gov, bool is_off) {}
18b4f3f5
MD
100static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
101{
102 return -ENOSYS;
103}
5125bbf3 104static inline void pm_genpd_poweroff_unused(void) {}
0bc5b2de 105static inline void genpd_queue_power_off_work(struct generic_pm_domain *gpd) {}
f721889f
RW
106#endif
107
108#endif /* _LINUX_PM_DOMAIN_H */