intel_dsi_pll.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /*
  2. * Copyright © 2013 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Shobhit Kumar <shobhit.kumar@intel.com>
  25. * Yogesh Mohan Marimuthu <yogesh.mohan.marimuthu@intel.com>
  26. */
  27. #include <linux/kernel.h>
  28. #include "intel_drv.h"
  29. #include "i915_drv.h"
  30. #include "intel_dsi.h"
  31. static const u16 lfsr_converts[] = {
  32. 426, 469, 234, 373, 442, 221, 110, 311, 411, /* 62 - 70 */
  33. 461, 486, 243, 377, 188, 350, 175, 343, 427, 213, /* 71 - 80 */
  34. 106, 53, 282, 397, 454, 227, 113, 56, 284, 142, /* 81 - 90 */
  35. 71, 35, 273, 136, 324, 418, 465, 488, 500, 506 /* 91 - 100 */
  36. };
  37. /* Get DSI clock from pixel clock */
  38. static u32 dsi_clk_from_pclk(u32 pclk, enum mipi_dsi_pixel_format fmt,
  39. int lane_count)
  40. {
  41. u32 dsi_clk_khz;
  42. u32 bpp = mipi_dsi_pixel_format_to_bpp(fmt);
  43. /* DSI data rate = pixel clock * bits per pixel / lane count
  44. pixel clock is converted from KHz to Hz */
  45. dsi_clk_khz = DIV_ROUND_CLOSEST(pclk * bpp, lane_count);
  46. return dsi_clk_khz;
  47. }
  48. static int dsi_calc_mnp(struct drm_i915_private *dev_priv,
  49. struct intel_crtc_state *config,
  50. int target_dsi_clk)
  51. {
  52. unsigned int calc_m = 0, calc_p = 0;
  53. unsigned int m_min, m_max, p_min = 2, p_max = 6;
  54. unsigned int m, n, p;
  55. int ref_clk;
  56. int delta = target_dsi_clk;
  57. u32 m_seed;
  58. /* target_dsi_clk is expected in kHz */
  59. if (target_dsi_clk < 300000 || target_dsi_clk > 1150000) {
  60. DRM_ERROR("DSI CLK Out of Range\n");
  61. return -ECHRNG;
  62. }
  63. if (IS_CHERRYVIEW(dev_priv)) {
  64. ref_clk = 100000;
  65. n = 4;
  66. m_min = 70;
  67. m_max = 96;
  68. } else {
  69. ref_clk = 25000;
  70. n = 1;
  71. m_min = 62;
  72. m_max = 92;
  73. }
  74. for (m = m_min; m <= m_max && delta; m++) {
  75. for (p = p_min; p <= p_max && delta; p++) {
  76. /*
  77. * Find the optimal m and p divisors with minimal delta
  78. * +/- the required clock
  79. */
  80. int calc_dsi_clk = (m * ref_clk) / (p * n);
  81. int d = abs(target_dsi_clk - calc_dsi_clk);
  82. if (d < delta) {
  83. delta = d;
  84. calc_m = m;
  85. calc_p = p;
  86. }
  87. }
  88. }
  89. /* register has log2(N1), this works fine for powers of two */
  90. n = ffs(n) - 1;
  91. m_seed = lfsr_converts[calc_m - 62];
  92. config->dsi_pll.ctrl = 1 << (DSI_PLL_P1_POST_DIV_SHIFT + calc_p - 2);
  93. config->dsi_pll.div = n << DSI_PLL_N1_DIV_SHIFT |
  94. m_seed << DSI_PLL_M1_DIV_SHIFT;
  95. return 0;
  96. }
  97. /*
  98. * XXX: The muxing and gating is hard coded for now. Need to add support for
  99. * sharing PLLs with two DSI outputs.
  100. */
  101. static int vlv_compute_dsi_pll(struct intel_encoder *encoder,
  102. struct intel_crtc_state *config)
  103. {
  104. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  105. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  106. int ret;
  107. u32 dsi_clk;
  108. dsi_clk = dsi_clk_from_pclk(intel_dsi->pclk, intel_dsi->pixel_format,
  109. intel_dsi->lane_count);
  110. ret = dsi_calc_mnp(dev_priv, config, dsi_clk);
  111. if (ret) {
  112. DRM_DEBUG_KMS("dsi_calc_mnp failed\n");
  113. return ret;
  114. }
  115. if (intel_dsi->ports & (1 << PORT_A))
  116. config->dsi_pll.ctrl |= DSI_PLL_CLK_GATE_DSI0_DSIPLL;
  117. if (intel_dsi->ports & (1 << PORT_C))
  118. config->dsi_pll.ctrl |= DSI_PLL_CLK_GATE_DSI1_DSIPLL;
  119. config->dsi_pll.ctrl |= DSI_PLL_VCO_EN;
  120. DRM_DEBUG_KMS("dsi pll div %08x, ctrl %08x\n",
  121. config->dsi_pll.div, config->dsi_pll.ctrl);
  122. return 0;
  123. }
  124. static void vlv_enable_dsi_pll(struct intel_encoder *encoder,
  125. const struct intel_crtc_state *config)
  126. {
  127. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  128. DRM_DEBUG_KMS("\n");
  129. mutex_lock(&dev_priv->sb_lock);
  130. vlv_cck_write(dev_priv, CCK_REG_DSI_PLL_CONTROL, 0);
  131. vlv_cck_write(dev_priv, CCK_REG_DSI_PLL_DIVIDER, config->dsi_pll.div);
  132. vlv_cck_write(dev_priv, CCK_REG_DSI_PLL_CONTROL,
  133. config->dsi_pll.ctrl & ~DSI_PLL_VCO_EN);
  134. /* wait at least 0.5 us after ungating before enabling VCO */
  135. usleep_range(1, 10);
  136. vlv_cck_write(dev_priv, CCK_REG_DSI_PLL_CONTROL, config->dsi_pll.ctrl);
  137. if (wait_for(vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_CONTROL) &
  138. DSI_PLL_LOCK, 20)) {
  139. mutex_unlock(&dev_priv->sb_lock);
  140. DRM_ERROR("DSI PLL lock failed\n");
  141. return;
  142. }
  143. mutex_unlock(&dev_priv->sb_lock);
  144. DRM_DEBUG_KMS("DSI PLL locked\n");
  145. }
  146. static void vlv_disable_dsi_pll(struct intel_encoder *encoder)
  147. {
  148. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  149. u32 tmp;
  150. DRM_DEBUG_KMS("\n");
  151. mutex_lock(&dev_priv->sb_lock);
  152. tmp = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_CONTROL);
  153. tmp &= ~DSI_PLL_VCO_EN;
  154. tmp |= DSI_PLL_LDO_GATE;
  155. vlv_cck_write(dev_priv, CCK_REG_DSI_PLL_CONTROL, tmp);
  156. mutex_unlock(&dev_priv->sb_lock);
  157. }
  158. static bool bxt_dsi_pll_is_enabled(struct drm_i915_private *dev_priv)
  159. {
  160. bool enabled;
  161. u32 val;
  162. u32 mask;
  163. mask = BXT_DSI_PLL_DO_ENABLE | BXT_DSI_PLL_LOCKED;
  164. val = I915_READ(BXT_DSI_PLL_ENABLE);
  165. enabled = (val & mask) == mask;
  166. if (!enabled)
  167. return false;
  168. /*
  169. * Both dividers must be programmed with valid values even if only one
  170. * of the PLL is used, see BSpec/Broxton Clocks. Check this here for
  171. * paranoia, since BIOS is known to misconfigure PLLs in this way at
  172. * times, and since accessing DSI registers with invalid dividers
  173. * causes a system hang.
  174. */
  175. val = I915_READ(BXT_DSI_PLL_CTL);
  176. if (!(val & BXT_DSIA_16X_MASK) || !(val & BXT_DSIC_16X_MASK)) {
  177. DRM_DEBUG_DRIVER("PLL is enabled with invalid divider settings (%08x)\n",
  178. val);
  179. enabled = false;
  180. }
  181. return enabled;
  182. }
  183. static void bxt_disable_dsi_pll(struct intel_encoder *encoder)
  184. {
  185. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  186. u32 val;
  187. DRM_DEBUG_KMS("\n");
  188. val = I915_READ(BXT_DSI_PLL_ENABLE);
  189. val &= ~BXT_DSI_PLL_DO_ENABLE;
  190. I915_WRITE(BXT_DSI_PLL_ENABLE, val);
  191. /*
  192. * PLL lock should deassert within 200us.
  193. * Wait up to 1ms before timing out.
  194. */
  195. if (wait_for((I915_READ(BXT_DSI_PLL_ENABLE)
  196. & BXT_DSI_PLL_LOCKED) == 0, 1))
  197. DRM_ERROR("Timeout waiting for PLL lock deassertion\n");
  198. }
  199. static void assert_bpp_mismatch(enum mipi_dsi_pixel_format fmt, int pipe_bpp)
  200. {
  201. int bpp = mipi_dsi_pixel_format_to_bpp(fmt);
  202. WARN(bpp != pipe_bpp,
  203. "bpp match assertion failure (expected %d, current %d)\n",
  204. bpp, pipe_bpp);
  205. }
  206. static u32 vlv_dsi_get_pclk(struct intel_encoder *encoder, int pipe_bpp,
  207. struct intel_crtc_state *config)
  208. {
  209. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  210. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  211. u32 dsi_clock, pclk;
  212. u32 pll_ctl, pll_div;
  213. u32 m = 0, p = 0, n;
  214. int refclk = IS_CHERRYVIEW(dev_priv) ? 100000 : 25000;
  215. int i;
  216. DRM_DEBUG_KMS("\n");
  217. mutex_lock(&dev_priv->sb_lock);
  218. pll_ctl = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_CONTROL);
  219. pll_div = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_DIVIDER);
  220. mutex_unlock(&dev_priv->sb_lock);
  221. config->dsi_pll.ctrl = pll_ctl & ~DSI_PLL_LOCK;
  222. config->dsi_pll.div = pll_div;
  223. /* mask out other bits and extract the P1 divisor */
  224. pll_ctl &= DSI_PLL_P1_POST_DIV_MASK;
  225. pll_ctl = pll_ctl >> (DSI_PLL_P1_POST_DIV_SHIFT - 2);
  226. /* N1 divisor */
  227. n = (pll_div & DSI_PLL_N1_DIV_MASK) >> DSI_PLL_N1_DIV_SHIFT;
  228. n = 1 << n; /* register has log2(N1) */
  229. /* mask out the other bits and extract the M1 divisor */
  230. pll_div &= DSI_PLL_M1_DIV_MASK;
  231. pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT;
  232. while (pll_ctl) {
  233. pll_ctl = pll_ctl >> 1;
  234. p++;
  235. }
  236. p--;
  237. if (!p) {
  238. DRM_ERROR("wrong P1 divisor\n");
  239. return 0;
  240. }
  241. for (i = 0; i < ARRAY_SIZE(lfsr_converts); i++) {
  242. if (lfsr_converts[i] == pll_div)
  243. break;
  244. }
  245. if (i == ARRAY_SIZE(lfsr_converts)) {
  246. DRM_ERROR("wrong m_seed programmed\n");
  247. return 0;
  248. }
  249. m = i + 62;
  250. dsi_clock = (m * refclk) / (p * n);
  251. /* pixel_format and pipe_bpp should agree */
  252. assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
  253. pclk = DIV_ROUND_CLOSEST(dsi_clock * intel_dsi->lane_count, pipe_bpp);
  254. return pclk;
  255. }
  256. static u32 bxt_dsi_get_pclk(struct intel_encoder *encoder, int pipe_bpp,
  257. struct intel_crtc_state *config)
  258. {
  259. u32 pclk;
  260. u32 dsi_clk;
  261. u32 dsi_ratio;
  262. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  263. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  264. /* Divide by zero */
  265. if (!pipe_bpp) {
  266. DRM_ERROR("Invalid BPP(0)\n");
  267. return 0;
  268. }
  269. config->dsi_pll.ctrl = I915_READ(BXT_DSI_PLL_CTL);
  270. dsi_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK;
  271. dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2;
  272. /* pixel_format and pipe_bpp should agree */
  273. assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
  274. pclk = DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, pipe_bpp);
  275. DRM_DEBUG_DRIVER("Calculated pclk=%u\n", pclk);
  276. return pclk;
  277. }
  278. u32 intel_dsi_get_pclk(struct intel_encoder *encoder, int pipe_bpp,
  279. struct intel_crtc_state *config)
  280. {
  281. if (IS_BROXTON(encoder->base.dev))
  282. return bxt_dsi_get_pclk(encoder, pipe_bpp, config);
  283. else
  284. return vlv_dsi_get_pclk(encoder, pipe_bpp, config);
  285. }
  286. static void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
  287. {
  288. u32 temp;
  289. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  290. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  291. temp = I915_READ(MIPI_CTRL(port));
  292. temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  293. I915_WRITE(MIPI_CTRL(port), temp |
  294. intel_dsi->escape_clk_div <<
  295. ESCAPE_CLOCK_DIVIDER_SHIFT);
  296. }
  297. /* Program BXT Mipi clocks and dividers */
  298. static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port,
  299. const struct intel_crtc_state *config)
  300. {
  301. struct drm_i915_private *dev_priv = dev->dev_private;
  302. u32 tmp;
  303. u32 dsi_rate = 0;
  304. u32 pll_ratio = 0;
  305. u32 rx_div;
  306. u32 tx_div;
  307. u32 rx_div_upper;
  308. u32 rx_div_lower;
  309. u32 mipi_8by3_divider;
  310. /* Clear old configurations */
  311. tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
  312. tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
  313. tmp &= ~(BXT_MIPI_RX_ESCLK_UPPER_FIXDIV_MASK(port));
  314. tmp &= ~(BXT_MIPI_8X_BY3_DIVIDER_MASK(port));
  315. tmp &= ~(BXT_MIPI_RX_ESCLK_LOWER_FIXDIV_MASK(port));
  316. /* Get the current DSI rate(actual) */
  317. pll_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK;
  318. dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
  319. /*
  320. * tx clock should be <= 20MHz and the div value must be
  321. * subtracted by 1 as per bspec
  322. */
  323. tx_div = DIV_ROUND_UP(dsi_rate, 20000) - 1;
  324. /*
  325. * rx clock should be <= 150MHz and the div value must be
  326. * subtracted by 1 as per bspec
  327. */
  328. rx_div = DIV_ROUND_UP(dsi_rate, 150000) - 1;
  329. /*
  330. * rx divider value needs to be updated in the
  331. * two differnt bit fields in the register hence splitting the
  332. * rx divider value accordingly
  333. */
  334. rx_div_lower = rx_div & RX_DIVIDER_BIT_1_2;
  335. rx_div_upper = (rx_div & RX_DIVIDER_BIT_3_4) >> 2;
  336. /* As per bpsec program the 8/3X clock divider to the below value */
  337. if (dev_priv->vbt.dsi.config->is_cmd_mode)
  338. mipi_8by3_divider = 0x2;
  339. else
  340. mipi_8by3_divider = 0x3;
  341. tmp |= BXT_MIPI_8X_BY3_DIVIDER(port, mipi_8by3_divider);
  342. tmp |= BXT_MIPI_TX_ESCLK_DIVIDER(port, tx_div);
  343. tmp |= BXT_MIPI_RX_ESCLK_LOWER_DIVIDER(port, rx_div_lower);
  344. tmp |= BXT_MIPI_RX_ESCLK_UPPER_DIVIDER(port, rx_div_upper);
  345. I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
  346. }
  347. static int bxt_compute_dsi_pll(struct intel_encoder *encoder,
  348. struct intel_crtc_state *config)
  349. {
  350. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  351. u8 dsi_ratio;
  352. u32 dsi_clk;
  353. dsi_clk = dsi_clk_from_pclk(intel_dsi->pclk, intel_dsi->pixel_format,
  354. intel_dsi->lane_count);
  355. /*
  356. * From clock diagram, to get PLL ratio divider, divide double of DSI
  357. * link rate (i.e., 2*8x=16x frequency value) by ref clock. Make sure to
  358. * round 'up' the result
  359. */
  360. dsi_ratio = DIV_ROUND_UP(dsi_clk * 2, BXT_REF_CLOCK_KHZ);
  361. if (dsi_ratio < BXT_DSI_PLL_RATIO_MIN ||
  362. dsi_ratio > BXT_DSI_PLL_RATIO_MAX) {
  363. DRM_ERROR("Cant get a suitable ratio from DSI PLL ratios\n");
  364. return -ECHRNG;
  365. }
  366. /*
  367. * Program DSI ratio and Select MIPIC and MIPIA PLL output as 8x
  368. * Spec says both have to be programmed, even if one is not getting
  369. * used. Configure MIPI_CLOCK_CTL dividers in modeset
  370. */
  371. config->dsi_pll.ctrl = dsi_ratio | BXT_DSIA_16X_BY2 | BXT_DSIC_16X_BY2;
  372. /* As per recommendation from hardware team,
  373. * Prog PVD ratio =1 if dsi ratio <= 50
  374. */
  375. if (dsi_ratio <= 50)
  376. config->dsi_pll.ctrl |= BXT_DSI_PLL_PVD_RATIO_1;
  377. return 0;
  378. }
  379. static void bxt_enable_dsi_pll(struct intel_encoder *encoder,
  380. const struct intel_crtc_state *config)
  381. {
  382. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  383. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  384. enum port port;
  385. u32 val;
  386. DRM_DEBUG_KMS("\n");
  387. /* Configure PLL vales */
  388. I915_WRITE(BXT_DSI_PLL_CTL, config->dsi_pll.ctrl);
  389. POSTING_READ(BXT_DSI_PLL_CTL);
  390. /* Program TX, RX, Dphy clocks */
  391. for_each_dsi_port(port, intel_dsi->ports)
  392. bxt_dsi_program_clocks(encoder->base.dev, port, config);
  393. /* Enable DSI PLL */
  394. val = I915_READ(BXT_DSI_PLL_ENABLE);
  395. val |= BXT_DSI_PLL_DO_ENABLE;
  396. I915_WRITE(BXT_DSI_PLL_ENABLE, val);
  397. /* Timeout and fail if PLL not locked */
  398. if (wait_for(I915_READ(BXT_DSI_PLL_ENABLE) & BXT_DSI_PLL_LOCKED, 1)) {
  399. DRM_ERROR("Timed out waiting for DSI PLL to lock\n");
  400. return;
  401. }
  402. DRM_DEBUG_KMS("DSI PLL locked\n");
  403. }
  404. bool intel_dsi_pll_is_enabled(struct drm_i915_private *dev_priv)
  405. {
  406. if (IS_BROXTON(dev_priv))
  407. return bxt_dsi_pll_is_enabled(dev_priv);
  408. MISSING_CASE(INTEL_DEVID(dev_priv));
  409. return false;
  410. }
  411. int intel_compute_dsi_pll(struct intel_encoder *encoder,
  412. struct intel_crtc_state *config)
  413. {
  414. struct drm_device *dev = encoder->base.dev;
  415. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  416. return vlv_compute_dsi_pll(encoder, config);
  417. else if (IS_BROXTON(dev))
  418. return bxt_compute_dsi_pll(encoder, config);
  419. return -ENODEV;
  420. }
  421. void intel_enable_dsi_pll(struct intel_encoder *encoder,
  422. const struct intel_crtc_state *config)
  423. {
  424. struct drm_device *dev = encoder->base.dev;
  425. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  426. vlv_enable_dsi_pll(encoder, config);
  427. else if (IS_BROXTON(dev))
  428. bxt_enable_dsi_pll(encoder, config);
  429. }
  430. void intel_disable_dsi_pll(struct intel_encoder *encoder)
  431. {
  432. struct drm_device *dev = encoder->base.dev;
  433. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  434. vlv_disable_dsi_pll(encoder);
  435. else if (IS_BROXTON(dev))
  436. bxt_disable_dsi_pll(encoder);
  437. }
  438. static void bxt_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
  439. {
  440. u32 tmp;
  441. struct drm_device *dev = encoder->base.dev;
  442. struct drm_i915_private *dev_priv = dev->dev_private;
  443. /* Clear old configurations */
  444. tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
  445. tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
  446. tmp &= ~(BXT_MIPI_RX_ESCLK_UPPER_FIXDIV_MASK(port));
  447. tmp &= ~(BXT_MIPI_8X_BY3_DIVIDER_MASK(port));
  448. tmp &= ~(BXT_MIPI_RX_ESCLK_LOWER_FIXDIV_MASK(port));
  449. I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
  450. I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
  451. }
  452. void intel_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
  453. {
  454. struct drm_device *dev = encoder->base.dev;
  455. if (IS_BROXTON(dev))
  456. bxt_dsi_reset_clocks(encoder, port);
  457. else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  458. vlv_dsi_reset_clocks(encoder, port);
  459. }