clk.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Clock framework definitions for SPEAr platform
  3. *
  4. * Copyright (C) 2012 ST Microelectronics
  5. * Viresh Kumar <viresh.kumar@st.com>
  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. /* VCO-PLL clk */
  52. struct pll_rate_tbl {
  53. u8 mode;
  54. u16 m;
  55. u8 n;
  56. u8 p;
  57. };
  58. struct clk_vco {
  59. struct clk_hw hw;
  60. void __iomem *mode_reg;
  61. void __iomem *cfg_reg;
  62. struct pll_rate_tbl *rtbl;
  63. u8 rtbl_cnt;
  64. spinlock_t *lock;
  65. };
  66. struct clk_pll {
  67. struct clk_hw hw;
  68. struct clk_vco *vco;
  69. const char *parent[1];
  70. spinlock_t *lock;
  71. };
  72. typedef unsigned long (*clk_calc_rate)(struct clk_hw *hw, unsigned long prate,
  73. int index);
  74. /* clk register routines */
  75. struct clk *clk_register_aux(const char *aux_name, const char *gate_name,
  76. const char *parent_name, unsigned long flags, void __iomem *reg,
  77. struct aux_clk_masks *masks, struct aux_rate_tbl *rtbl,
  78. u8 rtbl_cnt, spinlock_t *lock, struct clk **gate_clk);
  79. struct clk *clk_register_vco_pll(const char *vco_name, const char *pll_name,
  80. const char *vco_gate_name, const char *parent_name,
  81. unsigned long flags, void __iomem *mode_reg, void __iomem
  82. *cfg_reg, struct pll_rate_tbl *rtbl, u8 rtbl_cnt,
  83. spinlock_t *lock, struct clk **pll_clk,
  84. struct clk **vco_gate_clk);
  85. long clk_round_rate_index(struct clk_hw *hw, unsigned long drate,
  86. unsigned long parent_rate, clk_calc_rate calc_rate, u8 rtbl_cnt,
  87. int *index);
  88. #endif /* __SPEAR_CLK_H */