clk.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Clock framework definitions for SPEAr platform
  4. *
  5. * Copyright (C) 2012 ST Microelectronics
  6. * Viresh Kumar <vireshk@kernel.org>
  7. */
  8. #ifndef __SPEAR_CLK_H
  9. #define __SPEAR_CLK_H
  10. #include <linux/clk-provider.h>
  11. #include <linux/spinlock_types.h>
  12. #include <linux/types.h>
  13. /* Auxiliary Synth clk */
  14. /* Default masks */
  15. #define AUX_EQ_SEL_SHIFT 30
  16. #define AUX_EQ_SEL_MASK 1
  17. #define AUX_EQ1_SEL 0
  18. #define AUX_EQ2_SEL 1
  19. #define AUX_XSCALE_SHIFT 16
  20. #define AUX_XSCALE_MASK 0xFFF
  21. #define AUX_YSCALE_SHIFT 0
  22. #define AUX_YSCALE_MASK 0xFFF
  23. #define AUX_SYNT_ENB 31
  24. struct aux_clk_masks {
  25. u32 eq_sel_mask;
  26. u32 eq_sel_shift;
  27. u32 eq1_mask;
  28. u32 eq2_mask;
  29. u32 xscale_sel_mask;
  30. u32 xscale_sel_shift;
  31. u32 yscale_sel_mask;
  32. u32 yscale_sel_shift;
  33. u32 enable_bit;
  34. };
  35. struct aux_rate_tbl {
  36. u16 xscale;
  37. u16 yscale;
  38. u8 eq;
  39. };
  40. struct clk_aux {
  41. struct clk_hw hw;
  42. void __iomem *reg;
  43. const struct aux_clk_masks *masks;
  44. struct aux_rate_tbl *rtbl;
  45. u8 rtbl_cnt;
  46. spinlock_t *lock;
  47. };
  48. /* Fractional Synth clk */
  49. struct frac_rate_tbl {
  50. u32 div;
  51. };
  52. struct clk_frac {
  53. struct clk_hw hw;
  54. void __iomem *reg;
  55. struct frac_rate_tbl *rtbl;
  56. u8 rtbl_cnt;
  57. spinlock_t *lock;
  58. };
  59. /* GPT clk */
  60. struct gpt_rate_tbl {
  61. u16 mscale;
  62. u16 nscale;
  63. };
  64. struct clk_gpt {
  65. struct clk_hw hw;
  66. void __iomem *reg;
  67. struct gpt_rate_tbl *rtbl;
  68. u8 rtbl_cnt;
  69. spinlock_t *lock;
  70. };
  71. /* VCO-PLL clk */
  72. struct pll_rate_tbl {
  73. u8 mode;
  74. u16 m;
  75. u8 n;
  76. u8 p;
  77. };
  78. struct clk_vco {
  79. struct clk_hw hw;
  80. void __iomem *mode_reg;
  81. void __iomem *cfg_reg;
  82. struct pll_rate_tbl *rtbl;
  83. u8 rtbl_cnt;
  84. spinlock_t *lock;
  85. };
  86. struct clk_pll {
  87. struct clk_hw hw;
  88. struct clk_vco *vco;
  89. const char *parent[1];
  90. spinlock_t *lock;
  91. };
  92. typedef unsigned long (*clk_calc_rate)(struct clk_hw *hw, unsigned long prate,
  93. int index);
  94. /* clk register routines */
  95. struct clk *clk_register_aux(const char *aux_name, const char *gate_name,
  96. const char *parent_name, unsigned long flags, void __iomem *reg,
  97. const struct aux_clk_masks *masks, struct aux_rate_tbl *rtbl,
  98. u8 rtbl_cnt, spinlock_t *lock, struct clk **gate_clk);
  99. struct clk *clk_register_frac(const char *name, const char *parent_name,
  100. unsigned long flags, void __iomem *reg,
  101. struct frac_rate_tbl *rtbl, u8 rtbl_cnt, spinlock_t *lock);
  102. struct clk *clk_register_gpt(const char *name, const char *parent_name, unsigned
  103. long flags, void __iomem *reg, struct gpt_rate_tbl *rtbl, u8
  104. rtbl_cnt, spinlock_t *lock);
  105. struct clk *clk_register_vco_pll(const char *vco_name, const char *pll_name,
  106. const char *vco_gate_name, const char *parent_name,
  107. unsigned long flags, void __iomem *mode_reg, void __iomem
  108. *cfg_reg, struct pll_rate_tbl *rtbl, u8 rtbl_cnt,
  109. spinlock_t *lock, struct clk **pll_clk,
  110. struct clk **vco_gate_clk);
  111. long clk_round_rate_index(struct clk_hw *hw, unsigned long drate,
  112. unsigned long parent_rate, clk_calc_rate calc_rate, u8 rtbl_cnt,
  113. int *index);
  114. #endif /* __SPEAR_CLK_H */