ccu_mp.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_MP_H_
  14. #define _CCU_MP_H_
  15. #include <linux/clk-provider.h>
  16. #include "ccu_common.h"
  17. #include "ccu_div.h"
  18. #include "ccu_mult.h"
  19. #include "ccu_mux.h"
  20. /*
  21. * struct ccu_mp - Definition of an M-P clock
  22. *
  23. * Clocks based on the formula parent >> P / M
  24. */
  25. struct ccu_mp {
  26. u32 enable;
  27. struct _ccu_div m;
  28. struct _ccu_div p;
  29. struct ccu_mux_internal mux;
  30. struct ccu_common common;
  31. };
  32. #define SUNXI_CCU_MP_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
  33. _mshift, _mwidth, \
  34. _pshift, _pwidth, \
  35. _muxshift, _muxwidth, \
  36. _gate, _flags) \
  37. struct ccu_mp _struct = { \
  38. .enable = _gate, \
  39. .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
  40. .p = _SUNXI_CCU_DIV(_pshift, _pwidth), \
  41. .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
  42. .common = { \
  43. .reg = _reg, \
  44. .hw.init = CLK_HW_INIT_PARENTS(_name, \
  45. _parents, \
  46. &ccu_mp_ops, \
  47. _flags), \
  48. } \
  49. }
  50. #define SUNXI_CCU_MP_WITH_MUX(_struct, _name, _parents, _reg, \
  51. _mshift, _mwidth, \
  52. _pshift, _pwidth, \
  53. _muxshift, _muxwidth, \
  54. _flags) \
  55. SUNXI_CCU_MP_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
  56. _mshift, _mwidth, \
  57. _pshift, _pwidth, \
  58. _muxshift, _muxwidth, \
  59. 0, _flags)
  60. static inline struct ccu_mp *hw_to_ccu_mp(struct clk_hw *hw)
  61. {
  62. struct ccu_common *common = hw_to_ccu_common(hw);
  63. return container_of(common, struct ccu_mp, common);
  64. }
  65. extern const struct clk_ops ccu_mp_ops;
  66. #endif /* _CCU_MP_H_ */