pm_clock.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 <rjw@sisk.pl>, 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. #else
  44. static inline bool pm_clk_no_clocks(struct device *dev)
  45. {
  46. return true;
  47. }
  48. static inline void pm_clk_init(struct device *dev)
  49. {
  50. }
  51. static inline int pm_clk_create(struct device *dev)
  52. {
  53. return -EINVAL;
  54. }
  55. static inline void pm_clk_destroy(struct device *dev)
  56. {
  57. }
  58. static inline int pm_clk_add(struct device *dev, const char *con_id)
  59. {
  60. return -EINVAL;
  61. }
  62. static inline int pm_clk_add_clk(struct device *dev, struct clk *clk)
  63. {
  64. return -EINVAL;
  65. }
  66. static inline int of_pm_clk_add_clks(struct device *dev)
  67. {
  68. return -EINVAL;
  69. }
  70. static inline void pm_clk_remove(struct device *dev, const char *con_id)
  71. {
  72. }
  73. #define pm_clk_suspend NULL
  74. #define pm_clk_resume NULL
  75. static inline void pm_clk_remove_clk(struct device *dev, struct clk *clk)
  76. {
  77. }
  78. #endif
  79. #ifdef CONFIG_HAVE_CLK
  80. extern void pm_clk_add_notifier(struct bus_type *bus,
  81. struct pm_clk_notifier_block *clknb);
  82. #else
  83. static inline void pm_clk_add_notifier(struct bus_type *bus,
  84. struct pm_clk_notifier_block *clknb)
  85. {
  86. }
  87. #endif
  88. #endif