composite.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Spreadtrum composite clock driver
  4. //
  5. // Copyright (C) 2017 Spreadtrum, Inc.
  6. // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
  7. #ifndef _SPRD_COMPOSITE_H_
  8. #define _SPRD_COMPOSITE_H_
  9. #include "common.h"
  10. #include "mux.h"
  11. #include "div.h"
  12. struct sprd_comp {
  13. struct sprd_mux_ssel mux;
  14. struct sprd_div_internal div;
  15. struct sprd_clk_common common;
  16. };
  17. #define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table, \
  18. _mshift, _mwidth, _dshift, _dwidth, _flags) \
  19. struct sprd_comp _struct = { \
  20. .mux = _SPRD_MUX_CLK(_mshift, _mwidth, _table), \
  21. .div = _SPRD_DIV_CLK(_dshift, _dwidth), \
  22. .common = { \
  23. .regmap = NULL, \
  24. .reg = _reg, \
  25. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  26. _parent, \
  27. &sprd_comp_ops, \
  28. _flags), \
  29. } \
  30. }
  31. #define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift, \
  32. _mwidth, _dshift, _dwidth, _flags) \
  33. SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, \
  34. NULL, _mshift, _mwidth, \
  35. _dshift, _dwidth, _flags)
  36. static inline struct sprd_comp *hw_to_sprd_comp(const struct clk_hw *hw)
  37. {
  38. struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
  39. return container_of(common, struct sprd_comp, common);
  40. }
  41. extern const struct clk_ops sprd_comp_ops;
  42. #endif /* _SPRD_COMPOSITE_H_ */