ccu_mult.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _CCU_MULT_H_
  3. #define _CCU_MULT_H_
  4. #include "ccu_common.h"
  5. #include "ccu_frac.h"
  6. #include "ccu_mux.h"
  7. struct ccu_mult_internal {
  8. u8 offset;
  9. u8 shift;
  10. u8 width;
  11. u8 min;
  12. u8 max;
  13. };
  14. #define _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, _min, _max) \
  15. { \
  16. .min = _min, \
  17. .max = _max, \
  18. .offset = _offset, \
  19. .shift = _shift, \
  20. .width = _width, \
  21. }
  22. #define _SUNXI_CCU_MULT_MIN(_shift, _width, _min) \
  23. _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, _min, 0)
  24. #define _SUNXI_CCU_MULT_OFFSET(_shift, _width, _offset) \
  25. _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, 1, 0)
  26. #define _SUNXI_CCU_MULT(_shift, _width) \
  27. _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, 1, 0)
  28. struct ccu_mult {
  29. u32 enable;
  30. u32 lock;
  31. struct ccu_frac_internal frac;
  32. struct ccu_mult_internal mult;
  33. struct ccu_mux_internal mux;
  34. struct ccu_common common;
  35. };
  36. #define SUNXI_CCU_N_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
  37. _mshift, _mwidth, _gate, _lock, \
  38. _flags) \
  39. struct ccu_mult _struct = { \
  40. .enable = _gate, \
  41. .lock = _lock, \
  42. .mult = _SUNXI_CCU_MULT(_mshift, _mwidth), \
  43. .common = { \
  44. .reg = _reg, \
  45. .hw.init = CLK_HW_INIT(_name, \
  46. _parent, \
  47. &ccu_mult_ops, \
  48. _flags), \
  49. }, \
  50. }
  51. static inline struct ccu_mult *hw_to_ccu_mult(struct clk_hw *hw)
  52. {
  53. struct ccu_common *common = hw_to_ccu_common(hw);
  54. return container_of(common, struct ccu_mult, common);
  55. }
  56. extern const struct clk_ops ccu_mult_ops;
  57. #endif /* _CCU_MULT_H_ */