clock.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * arch/arm/plat-spear/include/plat/clock.h
  3. *
  4. * Clock framework definitions for SPEAr platform
  5. *
  6. * Copyright (C) 2009 ST Microelectronics
  7. * Viresh Kumar<viresh.kumar@st.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #ifndef __PLAT_CLOCK_H
  14. #define __PLAT_CLOCK_H
  15. #include <linux/list.h>
  16. #include <linux/clkdev.h>
  17. #include <linux/types.h>
  18. /* clk structure flags */
  19. #define ALWAYS_ENABLED (1 << 0) /* clock always enabled */
  20. #define RESET_TO_ENABLE (1 << 1) /* reset register bit to enable clk */
  21. /**
  22. * struct clkops - clock operations
  23. * @enable: pointer to clock enable function
  24. * @disable: pointer to clock disable function
  25. */
  26. struct clkops {
  27. int (*enable) (struct clk *);
  28. void (*disable) (struct clk *);
  29. };
  30. /**
  31. * struct pclk_info - parents info
  32. * @pclk: pointer to parent clk
  33. * @pclk_mask: value to be written for selecting this parent
  34. * @scalable: Is parent scalable (1 - YES, 0 - NO)
  35. */
  36. struct pclk_info {
  37. struct clk *pclk;
  38. u8 pclk_mask;
  39. u8 scalable;
  40. };
  41. /**
  42. * struct pclk_sel - parents selection configuration
  43. * @pclk_info: pointer to array of parent clock info
  44. * @pclk_count: number of parents
  45. * @pclk_sel_reg: register for selecting a parent
  46. * @pclk_sel_mask: mask for selecting parent (can be used to clear bits also)
  47. */
  48. struct pclk_sel {
  49. struct pclk_info *pclk_info;
  50. u8 pclk_count;
  51. void __iomem *pclk_sel_reg;
  52. unsigned int pclk_sel_mask;
  53. };
  54. /**
  55. * struct clk - clock structure
  56. * @usage_count: num of users who enabled this clock
  57. * @flags: flags for clock properties
  58. * @rate: programmed clock rate in Hz
  59. * @en_reg: clk enable/disable reg
  60. * @en_reg_bit: clk enable/disable bit
  61. * @ops: clk enable/disable ops - generic_clkops selected if NULL
  62. * @recalc: pointer to clock rate recalculate function
  63. * @div_factor: division factor to parent clock. Only for recalc = follow_parent
  64. * @pclk: current parent clk
  65. * @pclk_sel: pointer to parent selection structure
  66. * @pclk_sel_shift: register shift for selecting parent of this clock
  67. * @children: list for childrens or this clock
  68. * @sibling: node for list of clocks having same parents
  69. * @private_data: clock specific private data
  70. */
  71. struct clk {
  72. unsigned int usage_count;
  73. unsigned int flags;
  74. unsigned long rate;
  75. void __iomem *en_reg;
  76. u8 en_reg_bit;
  77. const struct clkops *ops;
  78. void (*recalc) (struct clk *);
  79. unsigned int div_factor;
  80. struct clk *pclk;
  81. struct pclk_sel *pclk_sel;
  82. unsigned int pclk_sel_shift;
  83. struct list_head children;
  84. struct list_head sibling;
  85. void *private_data;
  86. };
  87. /* pll configuration structure */
  88. struct pll_clk_masks {
  89. u32 mode_mask;
  90. u32 mode_shift;
  91. u32 norm_fdbk_m_mask;
  92. u32 norm_fdbk_m_shift;
  93. u32 dith_fdbk_m_mask;
  94. u32 dith_fdbk_m_shift;
  95. u32 div_p_mask;
  96. u32 div_p_shift;
  97. u32 div_n_mask;
  98. u32 div_n_shift;
  99. };
  100. struct pll_clk_config {
  101. void __iomem *mode_reg;
  102. void __iomem *cfg_reg;
  103. struct pll_clk_masks *masks;
  104. };
  105. /* ahb and apb bus configuration structure */
  106. struct bus_clk_masks {
  107. u32 mask;
  108. u32 shift;
  109. };
  110. struct bus_clk_config {
  111. void __iomem *reg;
  112. struct bus_clk_masks *masks;
  113. };
  114. /* Aux clk configuration structure: applicable to UART and FIRDA */
  115. struct aux_clk_masks {
  116. u32 eq_sel_mask;
  117. u32 eq_sel_shift;
  118. u32 eq1_mask;
  119. u32 eq2_mask;
  120. u32 xscale_sel_mask;
  121. u32 xscale_sel_shift;
  122. u32 yscale_sel_mask;
  123. u32 yscale_sel_shift;
  124. };
  125. struct aux_clk_config {
  126. void __iomem *synth_reg;
  127. struct aux_clk_masks *masks;
  128. };
  129. /* GPT clk configuration structure */
  130. struct gpt_clk_masks {
  131. u32 mscale_sel_mask;
  132. u32 mscale_sel_shift;
  133. u32 nscale_sel_mask;
  134. u32 nscale_sel_shift;
  135. };
  136. struct gpt_clk_config {
  137. void __iomem *synth_reg;
  138. struct gpt_clk_masks *masks;
  139. };
  140. /* platform specific clock functions */
  141. void clk_register(struct clk_lookup *cl);
  142. void recalc_root_clocks(void);
  143. /* clock recalc functions */
  144. void follow_parent(struct clk *clk);
  145. void pll_clk_recalc(struct clk *clk);
  146. void bus_clk_recalc(struct clk *clk);
  147. void gpt_clk_recalc(struct clk *clk);
  148. void aux_clk_recalc(struct clk *clk);
  149. #endif /* __PLAT_CLOCK_H */