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>
15 GPD_STATE_ACTIVE
= 0, /* PM domain is active */
16 GPD_STATE_WAIT_MASTER
, /* PM domain's master is being waited for */
17 GPD_STATE_BUSY
, /* Something is happening to the PM domain */
18 GPD_STATE_REPEAT
, /* Power off in progress, to be repeated */
19 GPD_STATE_POWER_OFF
, /* PM domain is off */
22 struct dev_power_governor
{
23 bool (*power_down_ok
)(struct dev_pm_domain
*domain
);
26 struct generic_pm_domain
{
27 struct dev_pm_domain domain
; /* PM domain operations */
28 struct list_head gpd_list_node
; /* Node in the global PM domains list */
29 struct list_head master_links
; /* Links with PM domain as a master */
30 struct list_head slave_links
; /* Links with PM domain as a slave */
31 struct list_head dev_list
; /* List of devices */
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 atomic_t sd_count
; /* Number of subdomains with power "on" */
37 enum gpd_status status
; /* Current state of the domain */
38 wait_queue_head_t status_wait_queue
;
39 struct task_struct
*poweroff_task
; /* Powering off task */
40 unsigned int resume_count
; /* Number of devices being resumed */
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 */
45 bool dev_irq_safe
; /* Device callbacks are IRQ-safe */
46 int (*power_off
)(struct generic_pm_domain
*domain
);
47 int (*power_on
)(struct generic_pm_domain
*domain
);
48 int (*start_device
)(struct device
*dev
);
49 int (*stop_device
)(struct device
*dev
);
50 bool (*active_wakeup
)(struct device
*dev
);
53 static inline struct generic_pm_domain
*pd_to_genpd(struct dev_pm_domain
*pd
)
55 return container_of(pd
, struct generic_pm_domain
, domain
);
59 struct generic_pm_domain
*master
;
60 struct list_head master_node
;
61 struct generic_pm_domain
*slave
;
62 struct list_head slave_node
;
65 struct generic_pm_domain_data
{
66 struct pm_domain_data base
;
70 static inline struct generic_pm_domain_data
*to_gpd_data(struct pm_domain_data
*pdd
)
72 return container_of(pdd
, struct generic_pm_domain_data
, base
);
75 #ifdef CONFIG_PM_GENERIC_DOMAINS
76 extern int pm_genpd_add_device(struct generic_pm_domain
*genpd
,
78 extern int pm_genpd_remove_device(struct generic_pm_domain
*genpd
,
80 extern int pm_genpd_add_subdomain(struct generic_pm_domain
*genpd
,
81 struct generic_pm_domain
*new_subdomain
);
82 extern int pm_genpd_remove_subdomain(struct generic_pm_domain
*genpd
,
83 struct generic_pm_domain
*target
);
84 extern void pm_genpd_init(struct generic_pm_domain
*genpd
,
85 struct dev_power_governor
*gov
, bool is_off
);
86 extern int pm_genpd_poweron(struct generic_pm_domain
*genpd
);
88 static inline int pm_genpd_add_device(struct generic_pm_domain
*genpd
,
93 static inline int pm_genpd_remove_device(struct generic_pm_domain
*genpd
,
98 static inline int pm_genpd_add_subdomain(struct generic_pm_domain
*genpd
,
99 struct generic_pm_domain
*new_sd
)
103 static inline int pm_genpd_remove_subdomain(struct generic_pm_domain
*genpd
,
104 struct generic_pm_domain
*target
)
108 static inline void pm_genpd_init(struct generic_pm_domain
*genpd
,
109 struct dev_power_governor
*gov
, bool is_off
) {}
110 static inline int pm_genpd_poweron(struct generic_pm_domain
*genpd
)
116 #ifdef CONFIG_PM_GENERIC_DOMAINS_RUNTIME
117 extern void genpd_queue_power_off_work(struct generic_pm_domain
*genpd
);
118 extern void pm_genpd_poweroff_unused(void);
120 static inline void genpd_queue_power_off_work(struct generic_pm_domain
*gpd
) {}
121 static inline void pm_genpd_poweroff_unused(void) {}
124 #endif /* _LINUX_PM_DOMAIN_H */