dsi_pll_5nm.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  4. */
  5. #include "dsi_pll.h"
  6. /* Register Offsets from PLL base address */
  7. #define PLL_ANALOG_CONTROLS_ONE 0x0000
  8. #define PLL_ANALOG_CONTROLS_TWO 0x0004
  9. #define PLL_INT_LOOP_SETTINGS 0x0008
  10. #define PLL_INT_LOOP_SETTINGS_TWO 0x000C
  11. #define PLL_ANALOG_CONTROLS_THREE 0x0010
  12. #define PLL_ANALOG_CONTROLS_FOUR 0x0014
  13. #define PLL_ANALOG_CONTROLS_FIVE 0x0018
  14. #define PLL_INT_LOOP_CONTROLS 0x001C
  15. #define PLL_DSM_DIVIDER 0x0020
  16. #define PLL_FEEDBACK_DIVIDER 0x0024
  17. #define PLL_SYSTEM_MUXES 0x0028
  18. #define PLL_FREQ_UPDATE_CONTROL_OVERRIDES 0x002C
  19. #define PLL_CMODE 0x0030
  20. #define PLL_PSM_CTRL 0x0034
  21. #define PLL_RSM_CTRL 0x0038
  22. #define PLL_VCO_TUNE_MAP 0x003C
  23. #define PLL_PLL_CNTRL 0x0040
  24. #define PLL_CALIBRATION_SETTINGS 0x0044
  25. #define PLL_BAND_SEL_CAL_TIMER_LOW 0x0048
  26. #define PLL_BAND_SEL_CAL_TIMER_HIGH 0x004C
  27. #define PLL_BAND_SEL_CAL_SETTINGS 0x0050
  28. #define PLL_BAND_SEL_MIN 0x0054
  29. #define PLL_BAND_SEL_MAX 0x0058
  30. #define PLL_BAND_SEL_PFILT 0x005C
  31. #define PLL_BAND_SEL_IFILT 0x0060
  32. #define PLL_BAND_SEL_CAL_SETTINGS_TWO 0x0064
  33. #define PLL_BAND_SEL_CAL_SETTINGS_THREE 0x0068
  34. #define PLL_BAND_SEL_CAL_SETTINGS_FOUR 0x006C
  35. #define PLL_BAND_SEL_ICODE_HIGH 0x0070
  36. #define PLL_BAND_SEL_ICODE_LOW 0x0074
  37. #define PLL_FREQ_DETECT_SETTINGS_ONE 0x0078
  38. #define PLL_FREQ_DETECT_THRESH 0x007C
  39. #define PLL_FREQ_DET_REFCLK_HIGH 0x0080
  40. #define PLL_FREQ_DET_REFCLK_LOW 0x0084
  41. #define PLL_FREQ_DET_PLLCLK_HIGH 0x0088
  42. #define PLL_FREQ_DET_PLLCLK_LOW 0x008C
  43. #define PLL_PFILT 0x0090
  44. #define PLL_IFILT 0x0094
  45. #define PLL_PLL_GAIN 0x0098
  46. #define PLL_ICODE_LOW 0x009C
  47. #define PLL_ICODE_HIGH 0x00A0
  48. #define PLL_LOCKDET 0x00A4
  49. #define PLL_OUTDIV 0x00A8
  50. #define PLL_FASTLOCK_CONTROL 0x00AC
  51. #define PLL_PASS_OUT_OVERRIDE_ONE 0x00B0
  52. #define PLL_PASS_OUT_OVERRIDE_TWO 0x00B4
  53. #define PLL_CORE_OVERRIDE 0x00B8
  54. #define PLL_CORE_INPUT_OVERRIDE 0x00BC
  55. #define PLL_RATE_CHANGE 0x00C0
  56. #define PLL_PLL_DIGITAL_TIMERS 0x00C4
  57. #define PLL_PLL_DIGITAL_TIMERS_TWO 0x00C8
  58. #define PLL_DECIMAL_DIV_START 0x00CC
  59. #define PLL_FRAC_DIV_START_LOW 0x00D0
  60. #define PLL_FRAC_DIV_START_MID 0x00D4
  61. #define PLL_FRAC_DIV_START_HIGH 0x00D8
  62. #define PLL_DEC_FRAC_MUXES 0x00DC
  63. #define PLL_DECIMAL_DIV_START_1 0x00E0
  64. #define PLL_FRAC_DIV_START_LOW_1 0x00E4
  65. #define PLL_FRAC_DIV_START_MID_1 0x00E8
  66. #define PLL_FRAC_DIV_START_HIGH_1 0x00EC
  67. #define PLL_DECIMAL_DIV_START_2 0x00F0
  68. #define PLL_FRAC_DIV_START_LOW_2 0x00F4
  69. #define PLL_FRAC_DIV_START_MID_2 0x00F8
  70. #define PLL_FRAC_DIV_START_HIGH_2 0x00FC
  71. #define PLL_MASH_CONTROL 0x0100
  72. #define PLL_SSC_STEPSIZE_LOW 0x0104
  73. #define PLL_SSC_STEPSIZE_HIGH 0x0108
  74. #define PLL_SSC_DIV_PER_LOW 0x010C
  75. #define PLL_SSC_DIV_PER_HIGH 0x0110
  76. #define PLL_SSC_ADJPER_LOW 0x0114
  77. #define PLL_SSC_ADJPER_HIGH 0x0118
  78. #define PLL_SSC_MUX_CONTROL 0x011C
  79. #define PLL_SSC_STEPSIZE_LOW_1 0x0120
  80. #define PLL_SSC_STEPSIZE_HIGH_1 0x0124
  81. #define PLL_SSC_DIV_PER_LOW_1 0x0128
  82. #define PLL_SSC_DIV_PER_HIGH_1 0x012C
  83. #define PLL_SSC_ADJPER_LOW_1 0x0130
  84. #define PLL_SSC_ADJPER_HIGH_1 0x0134
  85. #define PLL_SSC_STEPSIZE_LOW_2 0x0138
  86. #define PLL_SSC_STEPSIZE_HIGH_2 0x013C
  87. #define PLL_SSC_DIV_PER_LOW_2 0x0140
  88. #define PLL_SSC_DIV_PER_HIGH_2 0x0144
  89. #define PLL_SSC_ADJPER_LOW_2 0x0148
  90. #define PLL_SSC_ADJPER_HIGH_2 0x014C
  91. #define PLL_SSC_CONTROL 0x0150
  92. #define PLL_PLL_OUTDIV_RATE 0x0154
  93. #define PLL_PLL_LOCKDET_RATE_1 0x0158
  94. #define PLL_PLL_LOCKDET_RATE_2 0x015C
  95. #define PLL_PLL_PROP_GAIN_RATE_1 0x0160
  96. #define PLL_PLL_PROP_GAIN_RATE_2 0x0164
  97. #define PLL_PLL_BAND_SEL_RATE_1 0x0168
  98. #define PLL_PLL_BAND_SEL_RATE_2 0x016C
  99. #define PLL_PLL_INT_GAIN_IFILT_BAND_1 0x0170
  100. #define PLL_PLL_INT_GAIN_IFILT_BAND_2 0x0174
  101. #define PLL_PLL_FL_INT_GAIN_PFILT_BAND_1 0x0178
  102. #define PLL_PLL_FL_INT_GAIN_PFILT_BAND_2 0x017C
  103. #define PLL_PLL_FASTLOCK_EN_BAND 0x0180
  104. #define PLL_FREQ_TUNE_ACCUM_INIT_MID 0x0184
  105. #define PLL_FREQ_TUNE_ACCUM_INIT_HIGH 0x0188
  106. #define PLL_FREQ_TUNE_ACCUM_INIT_MUX 0x018C
  107. #define PLL_PLL_LOCK_OVERRIDE 0x0190
  108. #define PLL_PLL_LOCK_DELAY 0x0194
  109. #define PLL_PLL_LOCK_MIN_DELAY 0x0198
  110. #define PLL_CLOCK_INVERTERS 0x019C
  111. #define PLL_SPARE_AND_JPC_OVERRIDES 0x01A0
  112. #define PLL_BIAS_CONTROL_1 0x01A4
  113. #define PLL_BIAS_CONTROL_2 0x01A8
  114. #define PLL_ALOG_OBSV_BUS_CTRL_1 0x01AC
  115. #define PLL_COMMON_STATUS_ONE 0x01B0
  116. #define PLL_COMMON_STATUS_TWO 0x01B4
  117. #define PLL_BAND_SEL_CAL 0x01B8
  118. #define PLL_ICODE_ACCUM_STATUS_LOW 0x01BC
  119. #define PLL_ICODE_ACCUM_STATUS_HIGH 0x01C0
  120. #define PLL_FD_OUT_LOW 0x01C4
  121. #define PLL_FD_OUT_HIGH 0x01C8
  122. #define PLL_ALOG_OBSV_BUS_STATUS_1 0x01CC
  123. #define PLL_PLL_MISC_CONFIG 0x01D0
  124. #define PLL_FLL_CONFIG 0x01D4
  125. #define PLL_FLL_FREQ_ACQ_TIME 0x01D8
  126. #define PLL_FLL_CODE0 0x01DC
  127. #define PLL_FLL_CODE1 0x01E0
  128. #define PLL_FLL_GAIN0 0x01E4
  129. #define PLL_FLL_GAIN1 0x01E8
  130. #define PLL_SW_RESET 0x01EC
  131. #define PLL_FAST_PWRUP 0x01F0
  132. #define PLL_LOCKTIME0 0x01F4
  133. #define PLL_LOCKTIME1 0x01F8
  134. #define PLL_DEBUG_BUS_SEL 0x01FC
  135. #define PLL_DEBUG_BUS0 0x0200
  136. #define PLL_DEBUG_BUS1 0x0204
  137. #define PLL_DEBUG_BUS2 0x0208
  138. #define PLL_DEBUG_BUS3 0x020C
  139. #define PLL_ANALOG_FLL_CONTROL_OVERRIDES 0x0210
  140. #define PLL_VCO_CONFIG 0x0214
  141. #define PLL_VCO_CAL_CODE1_MODE0_STATUS 0x0218
  142. #define PLL_VCO_CAL_CODE1_MODE1_STATUS 0x021C
  143. #define PLL_RESET_SM_STATUS 0x0220
  144. #define PLL_TDC_OFFSET 0x0224
  145. #define PLL_PS3_PWRDOWN_CONTROLS 0x0228
  146. #define PLL_PS4_PWRDOWN_CONTROLS 0x022C
  147. #define PLL_PLL_RST_CONTROLS 0x0230
  148. #define PLL_GEAR_BAND_SELECT_CONTROLS 0x0234
  149. #define PLL_PSM_CLK_CONTROLS 0x0238
  150. #define PLL_SYSTEM_MUXES_2 0x023C
  151. #define PLL_VCO_CONFIG_1 0x0240
  152. #define PLL_VCO_CONFIG_2 0x0244
  153. #define PLL_CLOCK_INVERTERS_1 0x0248
  154. #define PLL_CLOCK_INVERTERS_2 0x024C
  155. #define PLL_CMODE_1 0x0250
  156. #define PLL_CMODE_2 0x0254
  157. #define PLL_ANALOG_CONTROLS_FIVE_1 0x0258
  158. #define PLL_ANALOG_CONTROLS_FIVE_2 0x025C
  159. #define PLL_PERF_OPTIMIZE 0x0260
  160. /* Register Offsets from PHY base address */
  161. #define PHY_CMN_CLK_CFG0 0x010
  162. #define PHY_CMN_CLK_CFG1 0x014
  163. #define PHY_CMN_GLBL_CTRL 0x018
  164. #define PHY_CMN_RBUF_CTRL 0x01C
  165. #define PHY_CMN_CTRL_0 0x024
  166. #define PHY_CMN_CTRL_2 0x02C
  167. #define PHY_CMN_CTRL_3 0x030
  168. #define PHY_CMN_PLL_CNTRL 0x03C
  169. #define PHY_CMN_GLBL_DIGTOP_SPARE4 0x128
  170. /* Bit definition of SSC control registers */
  171. #define SSC_CENTER BIT(0)
  172. #define SSC_EN BIT(1)
  173. #define SSC_FREQ_UPDATE BIT(2)
  174. #define SSC_FREQ_UPDATE_MUX BIT(3)
  175. #define SSC_UPDATE_SSC BIT(4)
  176. #define SSC_UPDATE_SSC_MUX BIT(5)
  177. #define SSC_START BIT(6)
  178. #define SSC_START_MUX BIT(7)
  179. /* Dynamic Refresh Control Registers */
  180. #define DSI_DYNAMIC_REFRESH_PLL_CTRL0 (0x014)
  181. #define DSI_DYNAMIC_REFRESH_PLL_CTRL1 (0x018)
  182. #define DSI_DYNAMIC_REFRESH_PLL_CTRL2 (0x01C)
  183. #define DSI_DYNAMIC_REFRESH_PLL_CTRL3 (0x020)
  184. #define DSI_DYNAMIC_REFRESH_PLL_CTRL4 (0x024)
  185. #define DSI_DYNAMIC_REFRESH_PLL_CTRL5 (0x028)
  186. #define DSI_DYNAMIC_REFRESH_PLL_CTRL6 (0x02C)
  187. #define DSI_DYNAMIC_REFRESH_PLL_CTRL7 (0x030)
  188. #define DSI_DYNAMIC_REFRESH_PLL_CTRL8 (0x034)
  189. #define DSI_DYNAMIC_REFRESH_PLL_CTRL9 (0x038)
  190. #define DSI_DYNAMIC_REFRESH_PLL_CTRL10 (0x03C)
  191. #define DSI_DYNAMIC_REFRESH_PLL_CTRL11 (0x040)
  192. #define DSI_DYNAMIC_REFRESH_PLL_CTRL12 (0x044)
  193. #define DSI_DYNAMIC_REFRESH_PLL_CTRL13 (0x048)
  194. #define DSI_DYNAMIC_REFRESH_PLL_CTRL14 (0x04C)
  195. #define DSI_DYNAMIC_REFRESH_PLL_CTRL15 (0x050)
  196. #define DSI_DYNAMIC_REFRESH_PLL_CTRL16 (0x054)
  197. #define DSI_DYNAMIC_REFRESH_PLL_CTRL17 (0x058)
  198. #define DSI_DYNAMIC_REFRESH_PLL_CTRL18 (0x05C)
  199. #define DSI_DYNAMIC_REFRESH_PLL_CTRL19 (0x060)
  200. #define DSI_DYNAMIC_REFRESH_PLL_CTRL20 (0x064)
  201. #define DSI_DYNAMIC_REFRESH_PLL_CTRL21 (0x068)
  202. #define DSI_DYNAMIC_REFRESH_PLL_CTRL22 (0x06C)
  203. #define DSI_DYNAMIC_REFRESH_PLL_CTRL23 (0x070)
  204. #define DSI_DYNAMIC_REFRESH_PLL_CTRL24 (0x074)
  205. #define DSI_DYNAMIC_REFRESH_PLL_CTRL25 (0x078)
  206. #define DSI_DYNAMIC_REFRESH_PLL_CTRL26 (0x07C)
  207. #define DSI_DYNAMIC_REFRESH_PLL_CTRL27 (0x080)
  208. #define DSI_DYNAMIC_REFRESH_PLL_CTRL28 (0x084)
  209. #define DSI_DYNAMIC_REFRESH_PLL_CTRL29 (0x088)
  210. #define DSI_DYNAMIC_REFRESH_PLL_CTRL30 (0x08C)
  211. #define DSI_DYNAMIC_REFRESH_PLL_CTRL31 (0x090)
  212. #define DSI_DYNAMIC_REFRESH_PLL_UPPER_ADDR (0x094)
  213. #define DSI_DYNAMIC_REFRESH_PLL_UPPER_ADDR2 (0x098)
  214. #define DSI_PHY_TO_PLL_OFFSET (0x500)
  215. enum {
  216. DSI_PLL_0,
  217. DSI_PLL_1,
  218. DSI_PLL_MAX
  219. };
  220. struct dsi_pll_div_table pll_5nm_dphy_lb[] = {
  221. {27270000, 30000000, 2, 11},
  222. {30000000, 33330000, 4, 5},
  223. {33330000, 37500000, 2, 9},
  224. {37500000, 40000000, 8, 2},
  225. {40000000, 42860000, 1, 15},
  226. {42860000, 46150000, 2, 7},
  227. {46150000, 50000000, 1, 13},
  228. {50000000, 54550000, 4, 3},
  229. {54550000, 60000000, 1, 11},
  230. {60000000, 66670000, 2, 5},
  231. {66670000, 75000000, 1, 9},
  232. {75000000, 85710000, 8, 1},
  233. {85710000, 100000000, 1, 7},
  234. {100000000, 120000000, 2, 3},
  235. {120000000, 150000000, 1, 5},
  236. {150000000, 200000000, 4, 1},
  237. {200000000, 300000000, 1, 3},
  238. {300000000, 600000000, 2, 1},
  239. {600000000, 1500000000, 1, 1}
  240. };
  241. struct dsi_pll_div_table pll_5nm_dphy_hb[] = {
  242. {68180000, 75000000, 2, 11},
  243. {75000000, 83330000, 4, 5},
  244. {83330000, 93750000, 2, 9},
  245. {93750000, 100000000, 8, 2},
  246. {100000000, 107140000, 1, 15},
  247. {107140000, 115380000, 2, 7},
  248. {115380000, 125000000, 1, 13},
  249. {125000000, 136360000, 4, 3},
  250. {136360000, 150000000, 1, 11},
  251. {150000000, 166670000, 2, 5},
  252. {166670000, 187500000, 1, 9},
  253. {187500000, 214290000, 8, 1},
  254. {214290000, 250000000, 1, 7},
  255. {250000000, 300000000, 2, 3},
  256. {300000000, 375000000, 1, 5},
  257. {375000000, 500000000, 4, 1},
  258. {500000000, 750000000, 1, 3},
  259. {750000000, 1500000000, 2, 1},
  260. {1500000000, 5000000000, 1, 1}
  261. };
  262. struct dsi_pll_div_table pll_5nm_cphy_lb[] = {
  263. {30000000, 37500000, 4, 5},
  264. {37500000, 50000000, 8, 2},
  265. {50000000, 60000000, 4, 3},
  266. {60000000, 75000000, 2, 5},
  267. {75000000, 100000000, 8, 1},
  268. {100000000, 120000000, 2, 3},
  269. {120000000, 150000000, 1, 5},
  270. {150000000, 200000000, 4, 1},
  271. {200000000, 300000000, 1, 3},
  272. {300000000, 600000000, 2, 1},
  273. {600000000, 1500000000, 1, 1}
  274. };
  275. struct dsi_pll_div_table pll_5nm_cphy_hb[] = {
  276. {75000000, 93750000, 4, 5},
  277. {93750000, 12500000, 8, 2},
  278. {125000000, 150000000, 4, 3},
  279. {150000000, 187500000, 2, 5},
  280. {187500000, 250000000, 8, 1},
  281. {250000000, 300000000, 2, 3},
  282. {300000000, 375000000, 1, 5},
  283. {375000000, 500000000, 4, 1},
  284. {500000000, 750000000, 1, 3},
  285. {750000000, 1500000000, 2, 1},
  286. {1500000000, 5000000000, 1, 1}
  287. };