Rafael J. Wysocki | f721889 | 2011-07-01 22:12:45 +0200 | [diff] [blame^] | 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 | |
| 14 | struct dev_power_governor { |
| 15 | bool (*power_down_ok)(struct dev_pm_domain *domain); |
| 16 | }; |
| 17 | |
| 18 | struct generic_pm_domain { |
| 19 | struct dev_pm_domain domain; /* PM domain operations */ |
| 20 | struct list_head sd_node; /* Node in the parent's subdomain list */ |
| 21 | struct generic_pm_domain *parent; /* Parent PM domain */ |
| 22 | struct list_head sd_list; /* List of dubdomains */ |
| 23 | struct list_head dev_list; /* List of devices */ |
| 24 | struct mutex lock; |
| 25 | struct dev_power_governor *gov; |
| 26 | struct work_struct power_off_work; |
| 27 | unsigned int in_progress; /* Number of devices being suspended now */ |
| 28 | unsigned int sd_count; /* Number of subdomains with power "on" */ |
| 29 | bool power_is_off; /* Whether or not power has been removed */ |
| 30 | int (*power_off)(struct generic_pm_domain *domain); |
| 31 | int (*power_on)(struct generic_pm_domain *domain); |
| 32 | int (*start_device)(struct device *dev); |
| 33 | int (*stop_device)(struct device *dev); |
| 34 | }; |
| 35 | |
| 36 | struct dev_list_entry { |
| 37 | struct list_head node; |
| 38 | struct device *dev; |
| 39 | bool need_restore; |
| 40 | }; |
| 41 | |
| 42 | #ifdef CONFIG_PM_GENERIC_DOMAINS |
| 43 | extern int pm_genpd_add_device(struct generic_pm_domain *genpd, |
| 44 | struct device *dev); |
| 45 | extern int pm_genpd_remove_device(struct generic_pm_domain *genpd, |
| 46 | struct device *dev); |
| 47 | extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, |
| 48 | struct generic_pm_domain *new_subdomain); |
| 49 | extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, |
| 50 | struct generic_pm_domain *target); |
| 51 | extern void pm_genpd_init(struct generic_pm_domain *genpd, |
| 52 | struct dev_power_governor *gov, bool is_off); |
| 53 | #else |
| 54 | static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, |
| 55 | struct device *dev) |
| 56 | { |
| 57 | return -ENOSYS; |
| 58 | } |
| 59 | static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd, |
| 60 | struct device *dev) |
| 61 | { |
| 62 | return -ENOSYS; |
| 63 | } |
| 64 | static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, |
| 65 | struct generic_pm_domain *new_sd) |
| 66 | { |
| 67 | return -ENOSYS; |
| 68 | } |
| 69 | static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, |
| 70 | struct generic_pm_domain *target) |
| 71 | { |
| 72 | return -ENOSYS; |
| 73 | } |
| 74 | static inline void pm_genpd_init(struct generic_pm_domain *genpd, |
| 75 | struct dev_power_governor *gov, bool is_off) {} |
| 76 | #endif |
| 77 | |
| 78 | #endif /* _LINUX_PM_DOMAIN_H */ |