pm_domain.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #ifndef _LINUX_PM_DOMAIN_H
  9. #define _LINUX_PM_DOMAIN_H
  10. #include <linux/device.h>
  11. #define GPD_IN_SUSPEND 1
  12. #define GPD_POWER_OFF 2
  13. struct dev_power_governor {
  14. bool (*power_down_ok)(struct dev_pm_domain *domain);
  15. };
  16. struct generic_pm_domain {
  17. struct dev_pm_domain domain; /* PM domain operations */
  18. struct list_head sd_node; /* Node in the parent's subdomain list */
  19. struct generic_pm_domain *parent; /* Parent PM domain */
  20. struct list_head sd_list; /* List of dubdomains */
  21. struct list_head dev_list; /* List of devices */
  22. struct mutex lock;
  23. struct dev_power_governor *gov;
  24. struct work_struct power_off_work;
  25. unsigned int in_progress; /* Number of devices being suspended now */
  26. unsigned int sd_count; /* Number of subdomains with power "on" */
  27. bool power_is_off; /* Whether or not power has been removed */
  28. unsigned int device_count; /* Number of devices */
  29. unsigned int suspended_count; /* System suspend device counter */
  30. unsigned int prepared_count; /* Suspend counter of prepared devices */
  31. bool suspend_power_off; /* Power status before system suspend */
  32. int (*power_off)(struct generic_pm_domain *domain);
  33. int (*power_on)(struct generic_pm_domain *domain);
  34. int (*start_device)(struct device *dev);
  35. int (*stop_device)(struct device *dev);
  36. bool (*active_wakeup)(struct device *dev);
  37. };
  38. static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
  39. {
  40. return container_of(pd, struct generic_pm_domain, domain);
  41. }
  42. struct dev_list_entry {
  43. struct list_head node;
  44. struct device *dev;
  45. bool need_restore;
  46. };
  47. #ifdef CONFIG_PM_GENERIC_DOMAINS
  48. extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
  49. struct device *dev);
  50. extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
  51. struct device *dev);
  52. extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
  53. struct generic_pm_domain *new_subdomain);
  54. extern int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
  55. struct generic_pm_domain *target);
  56. extern void pm_genpd_init(struct generic_pm_domain *genpd,
  57. struct dev_power_governor *gov, bool is_off);
  58. extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
  59. #else
  60. static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
  61. struct device *dev)
  62. {
  63. return -ENOSYS;
  64. }
  65. static inline int pm_genpd_remove_device(struct generic_pm_domain *genpd,
  66. struct device *dev)
  67. {
  68. return -ENOSYS;
  69. }
  70. static inline int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,
  71. struct generic_pm_domain *new_sd)
  72. {
  73. return -ENOSYS;
  74. }
  75. static inline int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
  76. struct generic_pm_domain *target)
  77. {
  78. return -ENOSYS;
  79. }
  80. static inline void pm_genpd_init(struct generic_pm_domain *genpd,
  81. struct dev_power_governor *gov, bool is_off) {}
  82. static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
  83. {
  84. return -ENOSYS;
  85. }
  86. #endif
  87. #endif /* _LINUX_PM_DOMAIN_H */