ccu_nkmp.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  4. */
  5. #ifndef _CCU_NKMP_H_
  6. #define _CCU_NKMP_H_
  7. #include <linux/clk-provider.h>
  8. #include "ccu_common.h"
  9. #include "ccu_div.h"
  10. #include "ccu_mult.h"
  11. /*
  12. * struct ccu_nkmp - Definition of an N-K-M-P clock
  13. *
  14. * Clocks based on the formula parent * N * K >> P / M
  15. */
  16. struct ccu_nkmp {
  17. u32 enable;
  18. u32 lock;
  19. struct ccu_mult_internal n;
  20. struct ccu_mult_internal k;
  21. struct ccu_div_internal m;
  22. struct ccu_div_internal p;
  23. unsigned int fixed_post_div;
  24. unsigned int max_rate;
  25. struct ccu_common common;
  26. };
  27. #define SUNXI_CCU_NKMP_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
  28. _nshift, _nwidth, \
  29. _kshift, _kwidth, \
  30. _mshift, _mwidth, \
  31. _pshift, _pwidth, \
  32. _gate, _lock, _flags) \
  33. struct ccu_nkmp _struct = { \
  34. .enable = _gate, \
  35. .lock = _lock, \
  36. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  37. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  38. .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
  39. .p = _SUNXI_CCU_DIV(_pshift, _pwidth), \
  40. .common = { \
  41. .reg = _reg, \
  42. .hw.init = CLK_HW_INIT(_name, \
  43. _parent, \
  44. &ccu_nkmp_ops, \
  45. _flags), \
  46. }, \
  47. }
  48. static inline struct ccu_nkmp *hw_to_ccu_nkmp(struct clk_hw *hw)
  49. {
  50. struct ccu_common *common = hw_to_ccu_common(hw);
  51. return container_of(common, struct ccu_nkmp, common);
  52. }
  53. extern const struct clk_ops ccu_nkmp_ops;
  54. #endif /* _CCU_NKMP_H_ */