owl-gate.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. //
  3. // OWL gate 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_GATE_H_
  11. #define _OWL_GATE_H_
  12. #include "owl-common.h"
  13. struct owl_gate_hw {
  14. u32 reg;
  15. u8 bit_idx;
  16. u8 gate_flags;
  17. };
  18. struct owl_gate {
  19. struct owl_gate_hw gate_hw;
  20. struct owl_clk_common common;
  21. };
  22. #define OWL_GATE_HW(_reg, _bit_idx, _gate_flags) \
  23. { \
  24. .reg = _reg, \
  25. .bit_idx = _bit_idx, \
  26. .gate_flags = _gate_flags, \
  27. }
  28. #define OWL_GATE(_struct, _name, _parent, _reg, \
  29. _bit_idx, _gate_flags, _flags) \
  30. struct owl_gate _struct = { \
  31. .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags), \
  32. .common = { \
  33. .regmap = NULL, \
  34. .hw.init = CLK_HW_INIT(_name, \
  35. _parent, \
  36. &owl_gate_ops, \
  37. _flags), \
  38. } \
  39. } \
  40. #define OWL_GATE_NO_PARENT(_struct, _name, _reg, \
  41. _bit_idx, _gate_flags, _flags) \
  42. struct owl_gate _struct = { \
  43. .gate_hw = OWL_GATE_HW(_reg, _bit_idx, _gate_flags), \
  44. .common = { \
  45. .regmap = NULL, \
  46. .hw.init = CLK_HW_INIT_NO_PARENT(_name, \
  47. &owl_gate_ops, \
  48. _flags), \
  49. }, \
  50. } \
  51. static inline struct owl_gate *hw_to_owl_gate(const struct clk_hw *hw)
  52. {
  53. struct owl_clk_common *common = hw_to_owl_clk_common(hw);
  54. return container_of(common, struct owl_gate, common);
  55. }
  56. void owl_gate_set(const struct owl_clk_common *common,
  57. const struct owl_gate_hw *gate_hw, bool enable);
  58. int owl_gate_clk_is_enabled(const struct owl_clk_common *common,
  59. const struct owl_gate_hw *gate_hw);
  60. extern const struct clk_ops owl_gate_ops;
  61. #endif /* _OWL_GATE_H_ */