clk-rcg.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright (c) 2013, The Linux Foundation. All rights reserved.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef __QCOM_CLK_RCG_H__
  14. #define __QCOM_CLK_RCG_H__
  15. #include <linux/clk-provider.h>
  16. #include "clk-regmap.h"
  17. struct freq_tbl {
  18. unsigned long freq;
  19. u8 src;
  20. u8 pre_div;
  21. u16 m;
  22. u16 n;
  23. };
  24. /**
  25. * struct parent_map - map table for PLL source select configuration values
  26. * @src: source PLL
  27. * @cfg: configuration value
  28. */
  29. struct parent_map {
  30. u8 src;
  31. u8 cfg;
  32. };
  33. /**
  34. * struct mn - M/N:D counter
  35. * @mnctr_en_bit: bit to enable mn counter
  36. * @mnctr_reset_bit: bit to assert mn counter reset
  37. * @mnctr_mode_shift: lowest bit of mn counter mode field
  38. * @n_val_shift: lowest bit of n value field
  39. * @m_val_shift: lowest bit of m value field
  40. * @width: number of bits in m/n/d values
  41. * @reset_in_cc: true if the mnctr_reset_bit is in the CC register
  42. */
  43. struct mn {
  44. u8 mnctr_en_bit;
  45. u8 mnctr_reset_bit;
  46. u8 mnctr_mode_shift;
  47. #define MNCTR_MODE_DUAL 0x2
  48. #define MNCTR_MODE_MASK 0x3
  49. u8 n_val_shift;
  50. u8 m_val_shift;
  51. u8 width;
  52. bool reset_in_cc;
  53. };
  54. /**
  55. * struct pre_div - pre-divider
  56. * @pre_div_shift: lowest bit of pre divider field
  57. * @pre_div_width: number of bits in predivider
  58. */
  59. struct pre_div {
  60. u8 pre_div_shift;
  61. u8 pre_div_width;
  62. };
  63. /**
  64. * struct src_sel - source selector
  65. * @src_sel_shift: lowest bit of source selection field
  66. * @parent_map: map from software's parent index to hardware's src_sel field
  67. */
  68. struct src_sel {
  69. u8 src_sel_shift;
  70. #define SRC_SEL_MASK 0x7
  71. const struct parent_map *parent_map;
  72. };
  73. /**
  74. * struct clk_rcg - root clock generator
  75. *
  76. * @ns_reg: NS register
  77. * @md_reg: MD register
  78. * @mn: mn counter
  79. * @p: pre divider
  80. * @s: source selector
  81. * @freq_tbl: frequency table
  82. * @clkr: regmap clock handle
  83. * @lock: register lock
  84. *
  85. */
  86. struct clk_rcg {
  87. u32 ns_reg;
  88. u32 md_reg;
  89. struct mn mn;
  90. struct pre_div p;
  91. struct src_sel s;
  92. const struct freq_tbl *freq_tbl;
  93. struct clk_regmap clkr;
  94. };
  95. extern const struct clk_ops clk_rcg_ops;
  96. extern const struct clk_ops clk_rcg_bypass_ops;
  97. extern const struct clk_ops clk_rcg_bypass2_ops;
  98. extern const struct clk_ops clk_rcg_pixel_ops;
  99. extern const struct clk_ops clk_rcg_esc_ops;
  100. extern const struct clk_ops clk_rcg_lcc_ops;
  101. #define to_clk_rcg(_hw) container_of(to_clk_regmap(_hw), struct clk_rcg, clkr)
  102. /**
  103. * struct clk_dyn_rcg - root clock generator with glitch free mux
  104. *
  105. * @mux_sel_bit: bit to switch glitch free mux
  106. * @ns_reg: NS0 and NS1 register
  107. * @md_reg: MD0 and MD1 register
  108. * @bank_reg: register to XOR @mux_sel_bit into to switch glitch free mux
  109. * @mn: mn counter (banked)
  110. * @s: source selector (banked)
  111. * @freq_tbl: frequency table
  112. * @clkr: regmap clock handle
  113. * @lock: register lock
  114. *
  115. */
  116. struct clk_dyn_rcg {
  117. u32 ns_reg[2];
  118. u32 md_reg[2];
  119. u32 bank_reg;
  120. u8 mux_sel_bit;
  121. struct mn mn[2];
  122. struct pre_div p[2];
  123. struct src_sel s[2];
  124. const struct freq_tbl *freq_tbl;
  125. struct clk_regmap clkr;
  126. };
  127. extern const struct clk_ops clk_dyn_rcg_ops;
  128. #define to_clk_dyn_rcg(_hw) \
  129. container_of(to_clk_regmap(_hw), struct clk_dyn_rcg, clkr)
  130. /**
  131. * struct clk_rcg2 - root clock generator
  132. *
  133. * @cmd_rcgr: corresponds to *_CMD_RCGR
  134. * @mnd_width: number of bits in m/n/d values
  135. * @hid_width: number of bits in half integer divider
  136. * @parent_map: map from software's parent index to hardware's src_sel field
  137. * @freq_tbl: frequency table
  138. * @current_freq: last cached frequency when using branches with shared RCGs
  139. * @clkr: regmap clock handle
  140. *
  141. */
  142. struct clk_rcg2 {
  143. u32 cmd_rcgr;
  144. u8 mnd_width;
  145. u8 hid_width;
  146. const struct parent_map *parent_map;
  147. const struct freq_tbl *freq_tbl;
  148. unsigned long current_freq;
  149. struct clk_regmap clkr;
  150. };
  151. #define to_clk_rcg2(_hw) container_of(to_clk_regmap(_hw), struct clk_rcg2, clkr)
  152. extern const struct clk_ops clk_rcg2_ops;
  153. extern const struct clk_ops clk_rcg2_shared_ops;
  154. extern const struct clk_ops clk_edp_pixel_ops;
  155. extern const struct clk_ops clk_byte_ops;
  156. extern const struct clk_ops clk_byte2_ops;
  157. extern const struct clk_ops clk_pixel_ops;
  158. #endif