ccu_nkm.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  4. */
  5. #ifndef _CCU_NKM_H_
  6. #define _CCU_NKM_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_nkm - Definition of an N-K-M clock
  13. *
  14. * Clocks based on the formula parent * N * K / M
  15. */
  16. struct ccu_nkm {
  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_mux_internal mux;
  23. unsigned int fixed_post_div;
  24. struct ccu_common common;
  25. };
  26. #define SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(_struct, _name, _parents, _reg, \
  27. _nshift, _nwidth, \
  28. _kshift, _kwidth, \
  29. _mshift, _mwidth, \
  30. _muxshift, _muxwidth, \
  31. _gate, _lock, _flags) \
  32. struct ccu_nkm _struct = { \
  33. .enable = _gate, \
  34. .lock = _lock, \
  35. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  36. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  37. .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
  38. .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
  39. .common = { \
  40. .reg = _reg, \
  41. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  42. _parents, \
  43. &ccu_nkm_ops, \
  44. _flags), \
  45. }, \
  46. }
  47. #define SUNXI_CCU_NKM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
  48. _nshift, _nwidth, \
  49. _kshift, _kwidth, \
  50. _mshift, _mwidth, \
  51. _gate, _lock, _flags) \
  52. struct ccu_nkm _struct = { \
  53. .enable = _gate, \
  54. .lock = _lock, \
  55. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  56. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  57. .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
  58. .common = { \
  59. .reg = _reg, \
  60. .hw.init = CLK_HW_INIT(_name, \
  61. _parent, \
  62. &ccu_nkm_ops, \
  63. _flags), \
  64. }, \
  65. }
  66. static inline struct ccu_nkm *hw_to_ccu_nkm(struct clk_hw *hw)
  67. {
  68. struct ccu_common *common = hw_to_ccu_common(hw);
  69. return container_of(common, struct ccu_nkm, common);
  70. }
  71. extern const struct clk_ops ccu_nkm_ops;
  72. #endif /* _CCU_NKM_H_ */