blob: 14fb0953fa478b81e792849703c4398a3e5fdc7a [file] [log] [blame]
Rafael J. Wysockif7218892011-07-01 22:12:45 +02001/*
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
Rafael J. Wysocki596ba342011-07-01 22:13:19 +020014#define GPD_IN_SUSPEND 1
15#define GPD_POWER_OFF 2
16
Rafael J. Wysockif7218892011-07-01 22:12:45 +020017struct dev_power_governor {
18 bool (*power_down_ok)(struct dev_pm_domain *domain);
19};
20
21struct 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 */
27 struct mutex lock;
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 */
Rafael J. Wysocki596ba342011-07-01 22:13:19 +020033 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 */
Rafael J. Wysockif7218892011-07-01 22:12:45 +020037 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);
Rafael J. Wysockid4f2d872011-07-01 22:13:29 +020041 bool (*active_wakeup)(struct device *dev);
Rafael J. Wysockif7218892011-07-01 22:12:45 +020042};
43
Rafael J. Wysocki596ba342011-07-01 22:13:19 +020044static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
45{
46 return container_of(pd, struct generic_pm_domain, domain);
47}
48
Rafael J. Wysockif7218892011-07-01 22:12:45 +020049struct dev_list_entry {
50 struct list_head node;
51 struct device *dev;
52 bool need_restore;
53};
54
55#ifdef CONFIG_PM_GENERIC_DOMAINS
56extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
57 struct device *dev);
58extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
59 struct device *dev);
60extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
61 struct generic_pm_domain *new_subdomain);
62extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
63 struct generic_pm_domain *target);
64extern void pm_genpd_init(struct generic_pm_domain *genpd,
65 struct dev_power_governor *gov, bool is_off);
Magnus Damm18b4f3f2011-07-10 10:39:14 +020066extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
Rafael J. Wysockif7218892011-07-01 22:12:45 +020067#else
68static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
69 struct device *dev)
70{
71 return -ENOSYS;
72}
73static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd,
74 struct device *dev)
75{
76 return -ENOSYS;
77}
78static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
79 struct generic_pm_domain *new_sd)
80{
81 return -ENOSYS;
82}
83static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
84 struct generic_pm_domain *target)
85{
86 return -ENOSYS;
87}
88static inline void pm_genpd_init(struct generic_pm_domain *genpd,
89 struct dev_power_governor *gov, bool is_off) {}
Magnus Damm18b4f3f2011-07-10 10:39:14 +020090static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
91{
92 return -ENOSYS;
93}
Rafael J. Wysockif7218892011-07-01 22:12:45 +020094#endif
95
96#endif /* _LINUX_PM_DOMAIN_H */