2 * pm_domain.h - Definitions and headers related to device power domains.
4 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Renesas Electronics Corp.
6 * This file is released under the GPLv2.
9 #ifndef _LINUX_PM_DOMAIN_H
10 #define _LINUX_PM_DOMAIN_H
12 #include <linux/device.h>
14 #define GPD_IN_SUSPEND 1
15 #define GPD_POWER_OFF 2
17 struct dev_power_governor
{
18 bool (*power_down_ok
)(struct dev_pm_domain
*domain
);
21 struct generic_pm_domain
{
22 struct dev_pm_domain domain
; /* PM domain operations */
23 struct list_head sd_node
; /* Node in the parent's subdomain list */
24 struct generic_pm_domain
*parent
; /* Parent PM domain */
25 struct list_head sd_list
; /* List of dubdomains */
26 struct list_head dev_list
; /* List of devices */
28 struct dev_power_governor
*gov
;
29 struct work_struct power_off_work
;
30 unsigned int in_progress
; /* Number of devices being suspended now */
31 unsigned int sd_count
; /* Number of subdomains with power "on" */
32 bool power_is_off
; /* Whether or not power has been removed */
33 unsigned int device_count
; /* Number of devices */
34 unsigned int suspended_count
; /* System suspend device counter */
35 unsigned int prepared_count
; /* Suspend counter of prepared devices */
36 bool suspend_power_off
; /* Power status before system suspend */
37 int (*power_off
)(struct generic_pm_domain
*domain
);
38 int (*power_on
)(struct generic_pm_domain
*domain
);
39 int (*start_device
)(struct device
*dev
);
40 int (*stop_device
)(struct device
*dev
);
43 static inline struct generic_pm_domain
*pd_to_genpd(struct dev_pm_domain
*pd
)
45 return container_of(pd
, struct generic_pm_domain
, domain
);
48 struct dev_list_entry
{
49 struct list_head node
;
54 #ifdef CONFIG_PM_GENERIC_DOMAINS
55 extern int pm_genpd_add_device(struct generic_pm_domain
*genpd
,
57 extern int pm_genpd_remove_device(struct generic_pm_domain
*genpd
,
59 extern int pm_genpd_add_subdomain(struct generic_pm_domain
*genpd
,
60 struct generic_pm_domain
*new_subdomain
);
61 extern int pm_genpd_remove_subdomain(struct generic_pm_domain
*genpd
,
62 struct generic_pm_domain
*target
);
63 extern void pm_genpd_init(struct generic_pm_domain
*genpd
,
64 struct dev_power_governor
*gov
, bool is_off
);
66 static inline int pm_genpd_add_device(struct generic_pm_domain
*genpd
,
71 static inline int pm_genpd_remove_device(struct generic_pm_domain
*genpd
,
76 static inline int pm_genpd_add_subdomain(struct generic_pm_domain
*genpd
,
77 struct generic_pm_domain
*new_sd
)
81 static inline int pm_genpd_remove_subdomain(struct generic_pm_domain
*genpd
,
82 struct generic_pm_domain
*target
)
86 static inline void pm_genpd_init(struct generic_pm_domain
*genpd
,
87 struct dev_power_governor
*gov
, bool is_off
) {}
90 #endif /* _LINUX_PM_DOMAIN_H */