owl-mux.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. //
  3. // OWL mux 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_MUX_H_
  11. #define _OWL_MUX_H_
  12. #include "owl-common.h"
  13. struct owl_mux_hw {
  14. u32 reg;
  15. u8 shift;
  16. u8 width;
  17. };
  18. struct owl_mux {
  19. struct owl_mux_hw mux_hw;
  20. struct owl_clk_common common;
  21. };
  22. #define OWL_MUX_HW(_reg, _shift, _width) \
  23. { \
  24. .reg = _reg, \
  25. .shift = _shift, \
  26. .width = _width, \
  27. }
  28. #define OWL_MUX(_struct, _name, _parents, _reg, \
  29. _shift, _width, _flags) \
  30. struct owl_mux _struct = { \
  31. .mux_hw = OWL_MUX_HW(_reg, _shift, _width), \
  32. .common = { \
  33. .regmap = NULL, \
  34. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  35. _parents, \
  36. &owl_mux_ops, \
  37. _flags), \
  38. }, \
  39. }
  40. static inline struct owl_mux *hw_to_owl_mux(const struct clk_hw *hw)
  41. {
  42. struct owl_clk_common *common = hw_to_owl_clk_common(hw);
  43. return container_of(common, struct owl_mux, common);
  44. }
  45. u8 owl_mux_helper_get_parent(const struct owl_clk_common *common,
  46. const struct owl_mux_hw *mux_hw);
  47. int owl_mux_helper_set_parent(const struct owl_clk_common *common,
  48. struct owl_mux_hw *mux_hw, u8 index);
  49. extern const struct clk_ops owl_mux_ops;
  50. #endif /* _OWL_MUX_H_ */