ccu_nkmp.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _CCU_NKMP_H_
  14. #define _CCU_NKMP_H_
  15. #include <linux/clk-provider.h>
  16. #include "ccu_common.h"
  17. #include "ccu_div.h"
  18. #include "ccu_mult.h"
  19. /*
  20. * struct ccu_nkmp - Definition of an N-K-M-P clock
  21. *
  22. * Clocks based on the formula parent * N * K >> P / M
  23. */
  24. struct ccu_nkmp {
  25. u32 enable;
  26. u32 lock;
  27. struct ccu_mult_internal n;
  28. struct ccu_mult_internal k;
  29. struct ccu_div_internal m;
  30. struct ccu_div_internal p;
  31. unsigned int fixed_post_div;
  32. struct ccu_common common;
  33. };
  34. #define SUNXI_CCU_NKMP_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
  35. _nshift, _nwidth, \
  36. _kshift, _kwidth, \
  37. _mshift, _mwidth, \
  38. _pshift, _pwidth, \
  39. _gate, _lock, _flags) \
  40. struct ccu_nkmp _struct = { \
  41. .enable = _gate, \
  42. .lock = _lock, \
  43. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  44. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  45. .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
  46. .p = _SUNXI_CCU_DIV(_pshift, _pwidth), \
  47. .common = { \
  48. .reg = _reg, \
  49. .hw.init = CLK_HW_INIT(_name, \
  50. _parent, \
  51. &ccu_nkmp_ops, \
  52. _flags), \
  53. }, \
  54. }
  55. static inline struct ccu_nkmp *hw_to_ccu_nkmp(struct clk_hw *hw)
  56. {
  57. struct ccu_common *common = hw_to_ccu_common(hw);
  58. return container_of(common, struct ccu_nkmp, common);
  59. }
  60. extern const struct clk_ops ccu_nkmp_ops;
  61. #endif /* _CCU_NKMP_H_ */