ccu_nkmp.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 n;
  28. struct _ccu_mult k;
  29. struct _ccu_div m;
  30. struct _ccu_div p;
  31. struct ccu_common common;
  32. };
  33. #define SUNXI_CCU_NKMP_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
  34. _nshift, _nwidth, \
  35. _kshift, _kwidth, \
  36. _mshift, _mwidth, \
  37. _pshift, _pwidth, \
  38. _gate, _lock, _flags) \
  39. struct ccu_nkmp _struct = { \
  40. .enable = _gate, \
  41. .lock = _lock, \
  42. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  43. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  44. .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
  45. .p = _SUNXI_CCU_DIV(_pshift, _pwidth), \
  46. .common = { \
  47. .reg = _reg, \
  48. .hw.init = CLK_HW_INIT(_name, \
  49. _parent, \
  50. &ccu_nkmp_ops, \
  51. _flags), \
  52. }, \
  53. }
  54. static inline struct ccu_nkmp *hw_to_ccu_nkmp(struct clk_hw *hw)
  55. {
  56. struct ccu_common *common = hw_to_ccu_common(hw);
  57. return container_of(common, struct ccu_nkmp, common);
  58. }
  59. extern const struct clk_ops ccu_nkmp_ops;
  60. #endif /* _CCU_NKMP_H_ */