dsi_pll_8996.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef MDSS_DSI_PLL_8996_H
  6. #define MDSS_DSI_PLL_8996_H
  7. #define DSIPHY_CMN_CLK_CFG0 0x0010
  8. #define DSIPHY_CMN_CLK_CFG1 0x0014
  9. #define DSIPHY_CMN_GLBL_TEST_CTRL 0x0018
  10. #define DSIPHY_CMN_PLL_CNTRL 0x0048
  11. #define DSIPHY_CMN_CTRL_0 0x001c
  12. #define DSIPHY_CMN_CTRL_1 0x0020
  13. #define DSIPHY_CMN_LDO_CNTRL 0x004c
  14. #define DSIPHY_PLL_IE_TRIM 0x0400
  15. #define DSIPHY_PLL_IP_TRIM 0x0404
  16. #define DSIPHY_PLL_IPTAT_TRIM 0x0410
  17. #define DSIPHY_PLL_CLKBUFLR_EN 0x041c
  18. #define DSIPHY_PLL_SYSCLK_EN_RESET 0x0428
  19. #define DSIPHY_PLL_RESETSM_CNTRL 0x042c
  20. #define DSIPHY_PLL_RESETSM_CNTRL2 0x0430
  21. #define DSIPHY_PLL_RESETSM_CNTRL3 0x0434
  22. #define DSIPHY_PLL_RESETSM_CNTRL4 0x0438
  23. #define DSIPHY_PLL_RESETSM_CNTRL5 0x043c
  24. #define DSIPHY_PLL_KVCO_DIV_REF1 0x0440
  25. #define DSIPHY_PLL_KVCO_DIV_REF2 0x0444
  26. #define DSIPHY_PLL_KVCO_COUNT1 0x0448
  27. #define DSIPHY_PLL_KVCO_COUNT2 0x044c
  28. #define DSIPHY_PLL_VREF_CFG1 0x045c
  29. #define DSIPHY_PLL_KVCO_CODE 0x0458
  30. #define DSIPHY_PLL_VCO_DIV_REF1 0x046c
  31. #define DSIPHY_PLL_VCO_DIV_REF2 0x0470
  32. #define DSIPHY_PLL_VCO_COUNT1 0x0474
  33. #define DSIPHY_PLL_VCO_COUNT2 0x0478
  34. #define DSIPHY_PLL_PLLLOCK_CMP1 0x047c
  35. #define DSIPHY_PLL_PLLLOCK_CMP2 0x0480
  36. #define DSIPHY_PLL_PLLLOCK_CMP3 0x0484
  37. #define DSIPHY_PLL_PLLLOCK_CMP_EN 0x0488
  38. #define DSIPHY_PLL_PLL_VCO_TUNE 0x048C
  39. #define DSIPHY_PLL_DEC_START 0x0490
  40. #define DSIPHY_PLL_SSC_EN_CENTER 0x0494
  41. #define DSIPHY_PLL_SSC_ADJ_PER1 0x0498
  42. #define DSIPHY_PLL_SSC_ADJ_PER2 0x049c
  43. #define DSIPHY_PLL_SSC_PER1 0x04a0
  44. #define DSIPHY_PLL_SSC_PER2 0x04a4
  45. #define DSIPHY_PLL_SSC_STEP_SIZE1 0x04a8
  46. #define DSIPHY_PLL_SSC_STEP_SIZE2 0x04ac
  47. #define DSIPHY_PLL_DIV_FRAC_START1 0x04b4
  48. #define DSIPHY_PLL_DIV_FRAC_START2 0x04b8
  49. #define DSIPHY_PLL_DIV_FRAC_START3 0x04bc
  50. #define DSIPHY_PLL_TXCLK_EN 0x04c0
  51. #define DSIPHY_PLL_PLL_CRCTRL 0x04c4
  52. #define DSIPHY_PLL_RESET_SM_READY_STATUS 0x04cc
  53. #define DSIPHY_PLL_PLL_MISC1 0x04e8
  54. #define DSIPHY_PLL_CP_SET_CUR 0x04f0
  55. #define DSIPHY_PLL_PLL_ICPMSET 0x04f4
  56. #define DSIPHY_PLL_PLL_ICPCSET 0x04f8
  57. #define DSIPHY_PLL_PLL_ICP_SET 0x04fc
  58. #define DSIPHY_PLL_PLL_LPF1 0x0500
  59. #define DSIPHY_PLL_PLL_LPF2_POSTDIV 0x0504
  60. #define DSIPHY_PLL_PLL_BANDGAP 0x0508
  61. #define DSI_DYNAMIC_REFRESH_PLL_CTRL15 0x050
  62. #define DSI_DYNAMIC_REFRESH_PLL_CTRL19 0x060
  63. #define DSI_DYNAMIC_REFRESH_PLL_CTRL20 0x064
  64. #define DSI_DYNAMIC_REFRESH_PLL_CTRL21 0x068
  65. #define DSI_DYNAMIC_REFRESH_PLL_CTRL22 0x06C
  66. #define DSI_DYNAMIC_REFRESH_PLL_CTRL23 0x070
  67. #define DSI_DYNAMIC_REFRESH_PLL_CTRL24 0x074
  68. #define DSI_DYNAMIC_REFRESH_PLL_CTRL25 0x078
  69. #define DSI_DYNAMIC_REFRESH_PLL_CTRL26 0x07C
  70. #define DSI_DYNAMIC_REFRESH_PLL_CTRL27 0x080
  71. #define DSI_DYNAMIC_REFRESH_PLL_CTRL28 0x084
  72. #define DSI_DYNAMIC_REFRESH_PLL_CTRL29 0x088
  73. #define DSI_DYNAMIC_REFRESH_PLL_UPPER_ADDR 0x094
  74. #define DSI_DYNAMIC_REFRESH_PLL_UPPER_ADDR2 0x098
  75. struct dsi_pll_input {
  76. u32 fref; /* 19.2 Mhz, reference clk */
  77. u32 fdata; /* bit clock rate */
  78. u32 dsiclk_sel; /* 1, reg: 0x0014 */
  79. u32 n2div; /* 1, reg: 0x0010, bit 4-7 */
  80. u32 ssc_en; /* 1, reg: 0x0494, bit 0 */
  81. u32 ldo_en; /* 0, reg: 0x004c, bit 0 */
  82. /* fixed */
  83. u32 refclk_dbler_en; /* 0, reg: 0x04c0, bit 1 */
  84. u32 vco_measure_time; /* 5, unknown */
  85. u32 kvco_measure_time; /* 5, unknown */
  86. u32 bandgap_timer; /* 4, reg: 0x0430, bit 3 - 5 */
  87. u32 pll_wakeup_timer; /* 5, reg: 0x043c, bit 0 - 2 */
  88. u32 plllock_cnt; /* 1, reg: 0x0488, bit 1 - 2 */
  89. u32 plllock_rng; /* 1, reg: 0x0488, bit 3 - 4 */
  90. u32 ssc_center; /* 0, reg: 0x0494, bit 1 */
  91. u32 ssc_adj_period; /* 37, reg: 0x498, bit 0 - 9 */
  92. u32 ssc_spread; /* 0.005 */
  93. u32 ssc_freq; /* unknown */
  94. u32 pll_ie_trim; /* 4, reg: 0x0400 */
  95. u32 pll_ip_trim; /* 4, reg: 0x0404 */
  96. u32 pll_iptat_trim; /* reg: 0x0410 */
  97. u32 pll_cpcset_cur; /* 1, reg: 0x04f0, bit 0 - 2 */
  98. u32 pll_cpmset_cur; /* 1, reg: 0x04f0, bit 3 - 5 */
  99. u32 pll_icpmset; /* 4, reg: 0x04fc, bit 3 - 5 */
  100. u32 pll_icpcset; /* 4, reg: 0x04fc, bit 0 - 2 */
  101. u32 pll_icpmset_p; /* 0, reg: 0x04f4, bit 0 - 2 */
  102. u32 pll_icpmset_m; /* 0, reg: 0x04f4, bit 3 - 5 */
  103. u32 pll_icpcset_p; /* 0, reg: 0x04f8, bit 0 - 2 */
  104. u32 pll_icpcset_m; /* 0, reg: 0x04f8, bit 3 - 5 */
  105. u32 pll_lpf_res1; /* 3, reg: 0x0504, bit 0 - 3 */
  106. u32 pll_lpf_cap1; /* 11, reg: 0x0500, bit 0 - 3 */
  107. u32 pll_lpf_cap2; /* 1, reg: 0x0500, bit 4 - 7 */
  108. u32 pll_c3ctrl; /* 2, reg: 0x04c4 */
  109. u32 pll_r3ctrl; /* 1, reg: 0x04c4 */
  110. };
  111. struct dsi_pll_output {
  112. u32 pll_txclk_en; /* reg: 0x04c0 */
  113. u32 dec_start; /* reg: 0x0490 */
  114. u32 div_frac_start; /* reg: 0x04b4, 0x4b8, 0x04bc */
  115. u32 ssc_period; /* reg: 0x04a0, 0x04a4 */
  116. u32 ssc_step_size; /* reg: 0x04a8, 0x04ac */
  117. u32 plllock_cmp; /* reg: 0x047c, 0x0480, 0x0484 */
  118. u32 pll_vco_div_ref; /* reg: 0x046c, 0x0470 */
  119. u32 pll_vco_count; /* reg: 0x0474, 0x0478 */
  120. u32 pll_kvco_div_ref; /* reg: 0x0440, 0x0444 */
  121. u32 pll_kvco_count; /* reg: 0x0448, 0x044c */
  122. u32 pll_misc1; /* reg: 0x04e8 */
  123. u32 pll_lpf2_postdiv; /* reg: 0x0504 */
  124. u32 pll_resetsm_cntrl; /* reg: 0x042c */
  125. u32 pll_resetsm_cntrl2; /* reg: 0x0430 */
  126. u32 pll_resetsm_cntrl5; /* reg: 0x043c */
  127. u32 pll_kvco_code; /* reg: 0x0458 */
  128. u32 cmn_clk_cfg0; /* reg: 0x0010 */
  129. u32 cmn_clk_cfg1; /* reg: 0x0014 */
  130. u32 cmn_ldo_cntrl; /* reg: 0x004c */
  131. u32 pll_postdiv; /* vco */
  132. u32 pll_n1div; /* vco */
  133. u32 pll_n2div; /* hr_oclk3, pixel */
  134. u32 fcvo;
  135. };
  136. enum {
  137. DSI_PLL_0,
  138. DSI_PLL_1,
  139. DSI_PLL_NUM
  140. };
  141. struct dsi_pll_db {
  142. struct dsi_pll_db *next;
  143. struct mdss_pll_resources *pll;
  144. struct dsi_pll_input in;
  145. struct dsi_pll_output out;
  146. int source_setup_done;
  147. };
  148. enum {
  149. PLL_OUTPUT_NONE,
  150. PLL_OUTPUT_RIGHT,
  151. PLL_OUTPUT_LEFT,
  152. PLL_OUTPUT_BOTH
  153. };
  154. enum {
  155. PLL_SOURCE_FROM_LEFT,
  156. PLL_SOURCE_FROM_RIGHT
  157. };
  158. enum {
  159. PLL_UNKNOWN,
  160. PLL_STANDALONE,
  161. PLL_SLAVE,
  162. PLL_MASTER
  163. };
  164. int pll_vco_set_rate_8996(struct clk *c, unsigned long rate);
  165. long pll_vco_round_rate_8996(struct clk *c, unsigned long rate);
  166. enum handoff pll_vco_handoff_8996(struct clk *c);
  167. enum handoff shadow_pll_vco_handoff_8996(struct clk *c);
  168. int shadow_post_n1_div_set_div(struct div_clk *clk, int div);
  169. int shadow_post_n1_div_get_div(struct div_clk *clk);
  170. int shadow_n2_div_set_div(struct div_clk *clk, int div);
  171. int shadow_n2_div_get_div(struct div_clk *clk);
  172. int shadow_pll_vco_set_rate_8996(struct clk *c, unsigned long rate);
  173. int pll_vco_prepare_8996(struct clk *c);
  174. void pll_vco_unprepare_8996(struct clk *c);
  175. int set_mdss_byte_mux_sel_8996(struct mux_clk *clk, int sel);
  176. int get_mdss_byte_mux_sel_8996(struct mux_clk *clk);
  177. int set_mdss_pixel_mux_sel_8996(struct mux_clk *clk, int sel);
  178. int get_mdss_pixel_mux_sel_8996(struct mux_clk *clk);
  179. int post_n1_div_set_div(struct div_clk *clk, int div);
  180. int post_n1_div_get_div(struct div_clk *clk);
  181. int n2_div_set_div(struct div_clk *clk, int div);
  182. int n2_div_get_div(struct div_clk *clk);
  183. int dsi_pll_enable_seq_8996(struct mdss_pll_resources *pll);
  184. #endif /* MDSS_DSI_PLL_8996_H */