ccu_common.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016 Maxime Ripard. All rights reserved.
  4. */
  5. #ifndef _COMMON_H_
  6. #define _COMMON_H_
  7. #include <linux/compiler.h>
  8. #include <linux/clk-provider.h>
  9. #define CCU_FEATURE_FRACTIONAL BIT(0)
  10. #define CCU_FEATURE_VARIABLE_PREDIV BIT(1)
  11. #define CCU_FEATURE_FIXED_PREDIV BIT(2)
  12. #define CCU_FEATURE_FIXED_POSTDIV BIT(3)
  13. #define CCU_FEATURE_ALL_PREDIV BIT(4)
  14. #define CCU_FEATURE_LOCK_REG BIT(5)
  15. #define CCU_FEATURE_MMC_TIMING_SWITCH BIT(6)
  16. #define CCU_FEATURE_SIGMA_DELTA_MOD BIT(7)
  17. #define CCU_FEATURE_KEY_FIELD BIT(8)
  18. /* MMC timing mode switch bit */
  19. #define CCU_MMC_NEW_TIMING_MODE BIT(30)
  20. struct device_node;
  21. struct ccu_common {
  22. void __iomem *base;
  23. u16 reg;
  24. u16 lock_reg;
  25. u32 prediv;
  26. unsigned long features;
  27. spinlock_t *lock;
  28. struct clk_hw hw;
  29. };
  30. static inline struct ccu_common *hw_to_ccu_common(struct clk_hw *hw)
  31. {
  32. return container_of(hw, struct ccu_common, hw);
  33. }
  34. struct sunxi_ccu_desc {
  35. struct ccu_common **ccu_clks;
  36. unsigned long num_ccu_clks;
  37. struct clk_hw_onecell_data *hw_clks;
  38. struct ccu_reset_map *resets;
  39. unsigned long num_resets;
  40. };
  41. void ccu_helper_wait_for_lock(struct ccu_common *common, u32 lock);
  42. struct ccu_pll_nb {
  43. struct notifier_block clk_nb;
  44. struct ccu_common *common;
  45. u32 enable;
  46. u32 lock;
  47. };
  48. #define to_ccu_pll_nb(_nb) container_of(_nb, struct ccu_pll_nb, clk_nb)
  49. int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb);
  50. int devm_sunxi_ccu_probe(struct device *dev, void __iomem *reg,
  51. const struct sunxi_ccu_desc *desc);
  52. void of_sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
  53. const struct sunxi_ccu_desc *desc);
  54. #endif /* _COMMON_H_ */