ccu_mult.h 1.6 KB

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