owl-divider.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. //
  3. // OWL divider clock driver
  4. //
  5. // Copyright (c) 2014 Actions Semi Inc.
  6. // Author: David Liu <liuwei@actions-semi.com>
  7. //
  8. // Copyright (c) 2018 Linaro Ltd.
  9. // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
  10. #ifndef _OWL_DIVIDER_H_
  11. #define _OWL_DIVIDER_H_
  12. #include "owl-common.h"
  13. struct owl_divider_hw {
  14. u32 reg;
  15. u8 shift;
  16. u8 width;
  17. u8 div_flags;
  18. struct clk_div_table *table;
  19. };
  20. struct owl_divider {
  21. struct owl_divider_hw div_hw;
  22. struct owl_clk_common common;
  23. };
  24. #define OWL_DIVIDER_HW(_reg, _shift, _width, _div_flags, _table) \
  25. { \
  26. .reg = _reg, \
  27. .shift = _shift, \
  28. .width = _width, \
  29. .div_flags = _div_flags, \
  30. .table = _table, \
  31. }
  32. #define OWL_DIVIDER(_struct, _name, _parent, _reg, \
  33. _shift, _width, _table, _div_flags, _flags) \
  34. struct owl_divider _struct = { \
  35. .div_hw = OWL_DIVIDER_HW(_reg, _shift, _width, \
  36. _div_flags, _table), \
  37. .common = { \
  38. .regmap = NULL, \
  39. .hw.init = CLK_HW_INIT(_name, \
  40. _parent, \
  41. &owl_divider_ops, \
  42. _flags), \
  43. }, \
  44. }
  45. static inline struct owl_divider *hw_to_owl_divider(const struct clk_hw *hw)
  46. {
  47. struct owl_clk_common *common = hw_to_owl_clk_common(hw);
  48. return container_of(common, struct owl_divider, common);
  49. }
  50. long owl_divider_helper_round_rate(struct owl_clk_common *common,
  51. const struct owl_divider_hw *div_hw,
  52. unsigned long rate,
  53. unsigned long *parent_rate);
  54. unsigned long owl_divider_helper_recalc_rate(struct owl_clk_common *common,
  55. const struct owl_divider_hw *div_hw,
  56. unsigned long parent_rate);
  57. int owl_divider_helper_set_rate(const struct owl_clk_common *common,
  58. const struct owl_divider_hw *div_hw,
  59. unsigned long rate,
  60. unsigned long parent_rate);
  61. extern const struct clk_ops owl_divider_ops;
  62. #endif /* _OWL_DIVIDER_H_ */