ccu_nk.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_NK_H_
  14. #define _CCU_NK_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_nk - Definition of an N-K clock
  21. *
  22. * Clocks based on the formula parent * N * K
  23. */
  24. struct ccu_nk {
  25. u16 reg;
  26. u32 enable;
  27. u32 lock;
  28. struct _ccu_mult n;
  29. struct _ccu_mult k;
  30. unsigned int fixed_post_div;
  31. struct ccu_common common;
  32. };
  33. #define SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(_struct, _name, _parent, _reg, \
  34. _nshift, _nwidth, \
  35. _kshift, _kwidth, \
  36. _gate, _lock, _postdiv, \
  37. _flags) \
  38. struct ccu_nk _struct = { \
  39. .enable = _gate, \
  40. .lock = _lock, \
  41. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  42. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  43. .fixed_post_div = _postdiv, \
  44. .common = { \
  45. .reg = _reg, \
  46. .features = CCU_FEATURE_FIXED_POSTDIV, \
  47. .hw.init = CLK_HW_INIT(_name, \
  48. _parent, \
  49. &ccu_nk_ops, \
  50. _flags), \
  51. }, \
  52. }
  53. static inline struct ccu_nk *hw_to_ccu_nk(struct clk_hw *hw)
  54. {
  55. struct ccu_common *common = hw_to_ccu_common(hw);
  56. return container_of(common, struct ccu_nk, common);
  57. }
  58. extern const struct clk_ops ccu_nk_ops;
  59. #endif /* _CCU_NK_H_ */