pm_clock.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * pm_clock.h - Definitions and headers related to device clocks.
  4. *
  5. * Copyright (C) 2011 Rafael J. Wysocki <[email protected]>, Renesas Electronics Corp.
  6. */
  7. #ifndef _LINUX_PM_CLOCK_H
  8. #define _LINUX_PM_CLOCK_H
  9. #include <linux/device.h>
  10. #include <linux/notifier.h>
  11. struct pm_clk_notifier_block {
  12. struct notifier_block nb;
  13. struct dev_pm_domain *pm_domain;
  14. char *con_ids[];
  15. };
  16. struct clk;
  17. #ifdef CONFIG_PM
  18. extern int pm_clk_runtime_suspend(struct device *dev);
  19. extern int pm_clk_runtime_resume(struct device *dev);
  20. #define USE_PM_CLK_RUNTIME_OPS \
  21. .runtime_suspend = pm_clk_runtime_suspend, \
  22. .runtime_resume = pm_clk_runtime_resume,
  23. #else
  24. #define USE_PM_CLK_RUNTIME_OPS
  25. #endif
  26. #ifdef CONFIG_PM_CLK
  27. static inline bool pm_clk_no_clocks(struct device *dev)
  28. {
  29. return dev && dev->power.subsys_data
  30. && list_empty(&dev->power.subsys_data->clock_list);
  31. }
  32. extern void pm_clk_init(struct device *dev);
  33. extern int pm_clk_create(struct device *dev);
  34. extern void pm_clk_destroy(struct device *dev);
  35. extern int pm_clk_add(struct device *dev, const char *con_id);
  36. extern int pm_clk_add_clk(struct device *dev, struct clk *clk);
  37. extern int of_pm_clk_add_clk(struct device *dev, const char *name);
  38. extern int of_pm_clk_add_clks(struct device *dev);
  39. extern void pm_clk_remove(struct device *dev, const char *con_id);
  40. extern void pm_clk_remove_clk(struct device *dev, struct clk *clk);
  41. extern int pm_clk_suspend(struct device *dev);
  42. extern int pm_clk_resume(struct device *dev);
  43. extern int devm_pm_clk_create(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. static inline int devm_pm_clk_create(struct device *dev)
  80. {
  81. return -EINVAL;
  82. }
  83. #endif
  84. #ifdef CONFIG_HAVE_CLK
  85. extern void pm_clk_add_notifier(struct bus_type *bus,
  86. struct pm_clk_notifier_block *clknb);
  87. #else
  88. static inline void pm_clk_add_notifier(struct bus_type *bus,
  89. struct pm_clk_notifier_block *clknb)
  90. {
  91. }
  92. #endif
  93. #endif