ccu_nk.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  4. */
  5. #ifndef _CCU_NK_H_
  6. #define _CCU_NK_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_nk - Definition of an N-K clock
  13. *
  14. * Clocks based on the formula parent * N * K
  15. */
  16. struct ccu_nk {
  17. u16 reg;
  18. u32 enable;
  19. u32 lock;
  20. struct ccu_mult_internal n;
  21. struct ccu_mult_internal k;
  22. unsigned int fixed_post_div;
  23. struct ccu_common common;
  24. };
  25. #define SUNXI_CCU_NK_WITH_GATE_LOCK_POSTDIV(_struct, _name, _parent, _reg, \
  26. _nshift, _nwidth, \
  27. _kshift, _kwidth, \
  28. _gate, _lock, _postdiv, \
  29. _flags) \
  30. struct ccu_nk _struct = { \
  31. .enable = _gate, \
  32. .lock = _lock, \
  33. .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
  34. .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
  35. .fixed_post_div = _postdiv, \
  36. .common = { \
  37. .reg = _reg, \
  38. .features = CCU_FEATURE_FIXED_POSTDIV, \
  39. .hw.init = CLK_HW_INIT(_name, \
  40. _parent, \
  41. &ccu_nk_ops, \
  42. _flags), \
  43. }, \
  44. }
  45. static inline struct ccu_nk *hw_to_ccu_nk(struct clk_hw *hw)
  46. {
  47. struct ccu_common *common = hw_to_ccu_common(hw);
  48. return container_of(common, struct ccu_nk, common);
  49. }
  50. extern const struct clk_ops ccu_nk_ops;
  51. #endif /* _CCU_NK_H_ */