composite.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. //
  3. // Spreadtrum composite clock driver
  4. //
  5. // Copyright (C) 2017 Spreadtrum, Inc.
  6. // Author: Chunyan Zhang <[email protected]>
  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_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
  18. _mshift, _mwidth, _dshift, _dwidth, \
  19. _flags, _fn) \
  20. struct sprd_comp _struct = { \
  21. .mux = _SPRD_MUX_CLK(_mshift, _mwidth, _table), \
  22. .div = _SPRD_DIV_CLK(_dshift, _dwidth), \
  23. .common = { \
  24. .regmap = NULL, \
  25. .reg = _reg, \
  26. .hw.init = _fn(_name, _parent, \
  27. &sprd_comp_ops, _flags), \
  28. } \
  29. }
  30. #define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table, \
  31. _mshift, _mwidth, _dshift, _dwidth, _flags) \
  32. SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
  33. _mshift, _mwidth, _dshift, _dwidth, \
  34. _flags, CLK_HW_INIT_PARENTS)
  35. #define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift, \
  36. _mwidth, _dshift, _dwidth, _flags) \
  37. SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, NULL, \
  38. _mshift, _mwidth, _dshift, _dwidth, _flags)
  39. #define SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, _table, \
  40. _mshift, _mwidth, _dshift, \
  41. _dwidth, _flags) \
  42. SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
  43. _mshift, _mwidth, _dshift, _dwidth, \
  44. _flags, CLK_HW_INIT_PARENTS_DATA)
  45. #define SPRD_COMP_CLK_DATA(_struct, _name, _parent, _reg, _mshift, \
  46. _mwidth, _dshift, _dwidth, _flags) \
  47. SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, NULL, \
  48. _mshift, _mwidth, _dshift, _dwidth, \
  49. _flags)
  50. static inline struct sprd_comp *hw_to_sprd_comp(const struct clk_hw *hw)
  51. {
  52. struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
  53. return container_of(common, struct sprd_comp, common);
  54. }
  55. extern const struct clk_ops sprd_comp_ops;
  56. #endif /* _SPRD_COMPOSITE_H_ */