clk.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2012 Freescale Semiconductor, Inc.
  4. */
  5. #ifndef __MXS_CLK_H
  6. #define __MXS_CLK_H
  7. struct clk;
  8. #include <linux/clk-provider.h>
  9. #include <linux/spinlock.h>
  10. #define SET 0x4
  11. #define CLR 0x8
  12. extern spinlock_t mxs_lock;
  13. int mxs_clk_wait(void __iomem *reg, u8 shift);
  14. struct clk *mxs_clk_pll(const char *name, const char *parent_name,
  15. void __iomem *base, u8 power, unsigned long rate);
  16. struct clk *mxs_clk_ref(const char *name, const char *parent_name,
  17. void __iomem *reg, u8 idx);
  18. struct clk *mxs_clk_div(const char *name, const char *parent_name,
  19. void __iomem *reg, u8 shift, u8 width, u8 busy);
  20. struct clk *mxs_clk_frac(const char *name, const char *parent_name,
  21. void __iomem *reg, u8 shift, u8 width, u8 busy);
  22. static inline struct clk *mxs_clk_fixed(const char *name, int rate)
  23. {
  24. return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
  25. }
  26. static inline struct clk *mxs_clk_gate(const char *name,
  27. const char *parent_name, void __iomem *reg, u8 shift)
  28. {
  29. return clk_register_gate(NULL, name, parent_name, CLK_SET_RATE_PARENT,
  30. reg, shift, CLK_GATE_SET_TO_DISABLE,
  31. &mxs_lock);
  32. }
  33. static inline struct clk *mxs_clk_mux(const char *name, void __iomem *reg,
  34. u8 shift, u8 width, const char *const *parent_names, int num_parents)
  35. {
  36. return clk_register_mux(NULL, name, parent_names, num_parents,
  37. CLK_SET_RATE_PARENT | CLK_SET_RATE_NO_REPARENT,
  38. reg, shift, width, 0, &mxs_lock);
  39. }
  40. static inline struct clk *mxs_clk_fixed_factor(const char *name,
  41. const char *parent_name, unsigned int mult, unsigned int div)
  42. {
  43. return clk_register_fixed_factor(NULL, name, parent_name,
  44. CLK_SET_RATE_PARENT, mult, div);
  45. }
  46. #endif /* __MXS_CLK_H */