pm_clock.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * pm_clock.h - Definitions and headers related to device clocks.
  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_CLOCK_H
  9. #define _LINUX_PM_CLOCK_H
  10. #include <linux/device.h>
  11. #include <linux/notifier.h>
  12. struct pm_clk_notifier_block {
  13. struct notifier_block nb;
  14. struct dev_pm_domain *pm_domain;
  15. char *con_ids[];
  16. };
  17. struct clk;
  18. #ifdef CONFIG_PM
  19. extern int pm_clk_runtime_suspend(struct device *dev);
  20. extern int pm_clk_runtime_resume(struct device *dev);
  21. #define USE_PM_CLK_RUNTIME_OPS \
  22. .runtime_suspend = pm_clk_runtime_suspend, \
  23. .runtime_resume = pm_clk_runtime_resume,
  24. #else
  25. #define USE_PM_CLK_RUNTIME_OPS
  26. #endif
  27. #ifdef CONFIG_PM_CLK
  28. static inline bool pm_clk_no_clocks(struct device *dev)
  29. {
  30. return dev && dev->power.subsys_data
  31. && list_empty(&dev->power.subsys_data->clock_list);
  32. }
  33. extern void pm_clk_init(struct device *dev);
  34. extern int pm_clk_create(struct device *dev);
  35. extern void pm_clk_destroy(struct device *dev);
  36. extern int pm_clk_add(struct device *dev, const char *con_id);
  37. extern int pm_clk_add_clk(struct device *dev, struct clk *clk);
  38. extern int of_pm_clk_add_clk(struct device *dev, const char *name);
  39. extern int of_pm_clk_add_clks(struct device *dev);
  40. extern void pm_clk_remove(struct device *dev, const char *con_id);
  41. extern void pm_clk_remove_clk(struct device *dev, struct clk *clk);
  42. extern int pm_clk_suspend(struct device *dev);
  43. extern int pm_clk_resume(struct device *dev);
  44. #else
  45. static inline bool pm_clk_no_clocks(struct device *dev)
  46. {
  47. return true;
  48. }
  49. static inline void pm_clk_init(struct device *dev)
  50. {
  51. }
  52. static inline int pm_clk_create(struct device *dev)
  53. {
  54. return -EINVAL;
  55. }
  56. static inline void pm_clk_destroy(struct device *dev)
  57. {
  58. }
  59. static inline int pm_clk_add(struct device *dev, const char *con_id)
  60. {
  61. return -EINVAL;
  62. }
  63. static inline int pm_clk_add_clk(struct device *dev, struct clk *clk)
  64. {
  65. return -EINVAL;
  66. }
  67. static inline int of_pm_clk_add_clks(struct device *dev)
  68. {
  69. return -EINVAL;
  70. }
  71. static inline void pm_clk_remove(struct device *dev, const char *con_id)
  72. {
  73. }
  74. #define pm_clk_suspend NULL
  75. #define pm_clk_resume NULL
  76. static inline void pm_clk_remove_clk(struct device *dev, struct clk *clk)
  77. {
  78. }
  79. #endif
  80. #ifdef CONFIG_HAVE_CLK
  81. extern void pm_clk_add_notifier(struct bus_type *bus,
  82. struct pm_clk_notifier_block *clknb);
  83. #else
  84. static inline void pm_clk_add_notifier(struct bus_type *bus,
  85. struct pm_clk_notifier_block *clknb)
  86. {
  87. }
  88. #endif
  89. #endif