clk.h 3.1 KB

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