owl-composite.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. //
  3. // OWL composite clock driver
  4. //
  5. // Copyright (c) 2014 Actions Semi Inc.
  6. // Author: David Liu <[email protected]>
  7. //
  8. // Copyright (c) 2018 Linaro Ltd.
  9. // Author: Manivannan Sadhasivam <[email protected]>
  10. #ifndef _OWL_COMPOSITE_H_
  11. #define _OWL_COMPOSITE_H_
  12. #include "owl-common.h"
  13. #include "owl-mux.h"
  14. #include "owl-gate.h"
  15. #include "owl-factor.h"
  16. #include "owl-fixed-factor.h"
  17. #include "owl-divider.h"
  18. union owl_rate {
  19. struct owl_divider_hw div_hw;
  20. struct owl_factor_hw factor_hw;
  21. struct clk_fixed_factor fix_fact_hw;
  22. };
  23. struct owl_composite {
  24. struct owl_mux_hw mux_hw;
  25. struct owl_gate_hw gate_hw;
  26. union owl_rate rate;
  27. const struct clk_ops *fix_fact_ops;
  28. struct owl_clk_common common;
  29. };
  30. #define OWL_COMP_DIV(_struct, _name, _parent, \
  31. _mux, _gate, _div, _flags) \
  32. struct owl_composite _struct = { \
  33. .mux_hw = _mux, \
  34. .gate_hw = _gate, \
  35. .rate.div_hw = _div, \
  36. .common = { \
  37. .regmap = NULL, \
  38. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  39. _parent, \
  40. &owl_comp_div_ops,\
  41. _flags), \
  42. }, \
  43. }
  44. #define OWL_COMP_DIV_FIXED(_struct, _name, _parent, \
  45. _gate, _div, _flags) \
  46. struct owl_composite _struct = { \
  47. .gate_hw = _gate, \
  48. .rate.div_hw = _div, \
  49. .common = { \
  50. .regmap = NULL, \
  51. .hw.init = CLK_HW_INIT(_name, \
  52. _parent, \
  53. &owl_comp_div_ops,\
  54. _flags), \
  55. }, \
  56. }
  57. #define OWL_COMP_FACTOR(_struct, _name, _parent, \
  58. _mux, _gate, _factor, _flags) \
  59. struct owl_composite _struct = { \
  60. .mux_hw = _mux, \
  61. .gate_hw = _gate, \
  62. .rate.factor_hw = _factor, \
  63. .common = { \
  64. .regmap = NULL, \
  65. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  66. _parent, \
  67. &owl_comp_fact_ops,\
  68. _flags), \
  69. }, \
  70. }
  71. #define OWL_COMP_FIXED_FACTOR(_struct, _name, _parent, \
  72. _gate, _mul, _div, _flags) \
  73. struct owl_composite _struct = { \
  74. .gate_hw = _gate, \
  75. .rate.fix_fact_hw.mult = _mul, \
  76. .rate.fix_fact_hw.div = _div, \
  77. .fix_fact_ops = &clk_fixed_factor_ops, \
  78. .common = { \
  79. .regmap = NULL, \
  80. .hw.init = CLK_HW_INIT(_name, \
  81. _parent, \
  82. &owl_comp_fix_fact_ops,\
  83. _flags), \
  84. }, \
  85. }
  86. #define OWL_COMP_PASS(_struct, _name, _parent, \
  87. _mux, _gate, _flags) \
  88. struct owl_composite _struct = { \
  89. .mux_hw = _mux, \
  90. .gate_hw = _gate, \
  91. .common = { \
  92. .regmap = NULL, \
  93. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  94. _parent, \
  95. &owl_comp_pass_ops,\
  96. _flags), \
  97. }, \
  98. }
  99. static inline struct owl_composite *hw_to_owl_comp(const struct clk_hw *hw)
  100. {
  101. struct owl_clk_common *common = hw_to_owl_clk_common(hw);
  102. return container_of(common, struct owl_composite, common);
  103. }
  104. extern const struct clk_ops owl_comp_div_ops;
  105. extern const struct clk_ops owl_comp_fact_ops;
  106. extern const struct clk_ops owl_comp_fix_fact_ops;
  107. extern const struct clk_ops owl_comp_pass_ops;
  108. extern const struct clk_ops clk_fixed_factor_ops;
  109. #endif /* _OWL_COMPOSITE_H_ */