blob: 7961b0dac4370e004a5462cd7abaefa1532fde0a [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);
41};
42
Rafael J. Wysocki596ba342011-07-01 22:13:19 +020043static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
44{
45 return container_of(pd, struct generic_pm_domain, domain);
46}
47
Rafael J. Wysockif7218892011-07-01 22:12:45 +020048struct dev_list_entry {
49 struct list_head node;
50 struct device *dev;
51 bool need_restore;
52};
53
54#ifdef CONFIG_PM_GENERIC_DOMAINS
55extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
56 struct device *dev);
57extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
58 struct device *dev);
59extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
60 struct generic_pm_domain *new_subdomain);
61extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
62 struct generic_pm_domain *target);
63extern void pm_genpd_init(struct generic_pm_domain *genpd,
64 struct dev_power_governor *gov, bool is_off);
65#else
66static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
67 struct device *dev)
68{
69 return -ENOSYS;
70}
71static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd,
72 struct device *dev)
73{
74 return -ENOSYS;
75}
76static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
77 struct generic_pm_domain *new_sd)
78{
79 return -ENOSYS;
80}
81static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
82 struct generic_pm_domain *target)
83{
84 return -ENOSYS;
85}
86static inline void pm_genpd_init(struct generic_pm_domain *genpd,
87 struct dev_power_governor *gov, bool is_off) {}
88#endif
89
90#endif /* _LINUX_PM_DOMAIN_H */