ccu_mult.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. struct ccu_frac_internal frac;
  30. struct ccu_mult_internal mult;
  31. struct ccu_mux_internal mux;
  32. struct ccu_common common;
  33. };
  34. #define SUNXI_CCU_N_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
  35. _mshift, _mwidth, _gate, _lock, \
  36. _flags) \
  37. struct ccu_mult _struct = { \
  38. .enable = _gate, \
  39. .mult = _SUNXI_CCU_MULT(_mshift, _mwidth), \
  40. .common = { \
  41. .reg = _reg, \
  42. .hw.init = CLK_HW_INIT(_name, \
  43. _parent, \
  44. &ccu_mult_ops, \
  45. _flags), \
  46. }, \
  47. }
  48. static inline struct ccu_mult *hw_to_ccu_mult(struct clk_hw *hw)
  49. {
  50. struct ccu_common *common = hw_to_ccu_common(hw);
  51. return container_of(common, struct ccu_mult, common);
  52. }
  53. extern const struct clk_ops ccu_mult_ops;
  54. #endif /* _CCU_MULT_H_ */