intel_dsi_pll.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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 m_min, m_max, p_min = 2, p_max = 6;
  53. unsigned int m, n, p;
  54. unsigned int calc_m, calc_p;
  55. int delta, ref_clk;
  56. /* target_dsi_clk is expected in kHz */
  57. if (target_dsi_clk < 300000 || target_dsi_clk > 1150000) {
  58. DRM_ERROR("DSI CLK Out of Range\n");
  59. return -ECHRNG;
  60. }
  61. if (IS_CHERRYVIEW(dev_priv)) {
  62. ref_clk = 100000;
  63. n = 4;
  64. m_min = 70;
  65. m_max = 96;
  66. } else {
  67. ref_clk = 25000;
  68. n = 1;
  69. m_min = 62;
  70. m_max = 92;
  71. }
  72. calc_p = p_min;
  73. calc_m = m_min;
  74. delta = abs(target_dsi_clk - (m_min * ref_clk) / (p_min * n));
  75. for (m = m_min; m <= m_max && delta; m++) {
  76. for (p = p_min; p <= p_max && delta; p++) {
  77. /*
  78. * Find the optimal m and p divisors with minimal delta
  79. * +/- the required clock
  80. */
  81. int calc_dsi_clk = (m * ref_clk) / (p * n);
  82. int d = abs(target_dsi_clk - calc_dsi_clk);
  83. if (d < delta) {
  84. delta = d;
  85. calc_m = m;
  86. calc_p = p;
  87. }
  88. }
  89. }
  90. /* register has log2(N1), this works fine for powers of two */
  91. config->dsi_pll.ctrl = 1 << (DSI_PLL_P1_POST_DIV_SHIFT + calc_p - 2);
  92. config->dsi_pll.div =
  93. (ffs(n) - 1) << DSI_PLL_N1_DIV_SHIFT |
  94. (u32)lfsr_converts[calc_m - 62] << 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 = to_i915(encoder->base.dev);
  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 (intel_wait_for_register(dev_priv,
  196. BXT_DSI_PLL_ENABLE,
  197. BXT_DSI_PLL_LOCKED,
  198. 0,
  199. 1))
  200. DRM_ERROR("Timeout waiting for PLL lock deassertion\n");
  201. }
  202. static void assert_bpp_mismatch(enum mipi_dsi_pixel_format fmt, int pipe_bpp)
  203. {
  204. int bpp = mipi_dsi_pixel_format_to_bpp(fmt);
  205. WARN(bpp != pipe_bpp,
  206. "bpp match assertion failure (expected %d, current %d)\n",
  207. bpp, pipe_bpp);
  208. }
  209. static u32 vlv_dsi_get_pclk(struct intel_encoder *encoder, int pipe_bpp,
  210. struct intel_crtc_state *config)
  211. {
  212. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  213. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  214. u32 dsi_clock, pclk;
  215. u32 pll_ctl, pll_div;
  216. u32 m = 0, p = 0, n;
  217. int refclk = IS_CHERRYVIEW(dev_priv) ? 100000 : 25000;
  218. int i;
  219. DRM_DEBUG_KMS("\n");
  220. mutex_lock(&dev_priv->sb_lock);
  221. pll_ctl = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_CONTROL);
  222. pll_div = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_DIVIDER);
  223. mutex_unlock(&dev_priv->sb_lock);
  224. config->dsi_pll.ctrl = pll_ctl & ~DSI_PLL_LOCK;
  225. config->dsi_pll.div = pll_div;
  226. /* mask out other bits and extract the P1 divisor */
  227. pll_ctl &= DSI_PLL_P1_POST_DIV_MASK;
  228. pll_ctl = pll_ctl >> (DSI_PLL_P1_POST_DIV_SHIFT - 2);
  229. /* N1 divisor */
  230. n = (pll_div & DSI_PLL_N1_DIV_MASK) >> DSI_PLL_N1_DIV_SHIFT;
  231. n = 1 << n; /* register has log2(N1) */
  232. /* mask out the other bits and extract the M1 divisor */
  233. pll_div &= DSI_PLL_M1_DIV_MASK;
  234. pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT;
  235. while (pll_ctl) {
  236. pll_ctl = pll_ctl >> 1;
  237. p++;
  238. }
  239. p--;
  240. if (!p) {
  241. DRM_ERROR("wrong P1 divisor\n");
  242. return 0;
  243. }
  244. for (i = 0; i < ARRAY_SIZE(lfsr_converts); i++) {
  245. if (lfsr_converts[i] == pll_div)
  246. break;
  247. }
  248. if (i == ARRAY_SIZE(lfsr_converts)) {
  249. DRM_ERROR("wrong m_seed programmed\n");
  250. return 0;
  251. }
  252. m = i + 62;
  253. dsi_clock = (m * refclk) / (p * n);
  254. /* pixel_format and pipe_bpp should agree */
  255. assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
  256. pclk = DIV_ROUND_CLOSEST(dsi_clock * intel_dsi->lane_count, pipe_bpp);
  257. return pclk;
  258. }
  259. static u32 bxt_dsi_get_pclk(struct intel_encoder *encoder, int pipe_bpp,
  260. struct intel_crtc_state *config)
  261. {
  262. u32 pclk;
  263. u32 dsi_clk;
  264. u32 dsi_ratio;
  265. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  266. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  267. /* Divide by zero */
  268. if (!pipe_bpp) {
  269. DRM_ERROR("Invalid BPP(0)\n");
  270. return 0;
  271. }
  272. config->dsi_pll.ctrl = I915_READ(BXT_DSI_PLL_CTL);
  273. dsi_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK;
  274. dsi_clk = (dsi_ratio * BXT_REF_CLOCK_KHZ) / 2;
  275. /* pixel_format and pipe_bpp should agree */
  276. assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
  277. pclk = DIV_ROUND_CLOSEST(dsi_clk * intel_dsi->lane_count, pipe_bpp);
  278. DRM_DEBUG_DRIVER("Calculated pclk=%u\n", pclk);
  279. return pclk;
  280. }
  281. u32 intel_dsi_get_pclk(struct intel_encoder *encoder, int pipe_bpp,
  282. struct intel_crtc_state *config)
  283. {
  284. if (IS_BROXTON(encoder->base.dev))
  285. return bxt_dsi_get_pclk(encoder, pipe_bpp, config);
  286. else
  287. return vlv_dsi_get_pclk(encoder, pipe_bpp, config);
  288. }
  289. static void vlv_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
  290. {
  291. u32 temp;
  292. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  293. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  294. temp = I915_READ(MIPI_CTRL(port));
  295. temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  296. I915_WRITE(MIPI_CTRL(port), temp |
  297. intel_dsi->escape_clk_div <<
  298. ESCAPE_CLOCK_DIVIDER_SHIFT);
  299. }
  300. /* Program BXT Mipi clocks and dividers */
  301. static void bxt_dsi_program_clocks(struct drm_device *dev, enum port port,
  302. const struct intel_crtc_state *config)
  303. {
  304. struct drm_i915_private *dev_priv = to_i915(dev);
  305. u32 tmp;
  306. u32 dsi_rate = 0;
  307. u32 pll_ratio = 0;
  308. u32 rx_div;
  309. u32 tx_div;
  310. u32 rx_div_upper;
  311. u32 rx_div_lower;
  312. u32 mipi_8by3_divider;
  313. /* Clear old configurations */
  314. tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
  315. tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
  316. tmp &= ~(BXT_MIPI_RX_ESCLK_UPPER_FIXDIV_MASK(port));
  317. tmp &= ~(BXT_MIPI_8X_BY3_DIVIDER_MASK(port));
  318. tmp &= ~(BXT_MIPI_RX_ESCLK_LOWER_FIXDIV_MASK(port));
  319. /* Get the current DSI rate(actual) */
  320. pll_ratio = config->dsi_pll.ctrl & BXT_DSI_PLL_RATIO_MASK;
  321. dsi_rate = (BXT_REF_CLOCK_KHZ * pll_ratio) / 2;
  322. /*
  323. * tx clock should be <= 20MHz and the div value must be
  324. * subtracted by 1 as per bspec
  325. */
  326. tx_div = DIV_ROUND_UP(dsi_rate, 20000) - 1;
  327. /*
  328. * rx clock should be <= 150MHz and the div value must be
  329. * subtracted by 1 as per bspec
  330. */
  331. rx_div = DIV_ROUND_UP(dsi_rate, 150000) - 1;
  332. /*
  333. * rx divider value needs to be updated in the
  334. * two differnt bit fields in the register hence splitting the
  335. * rx divider value accordingly
  336. */
  337. rx_div_lower = rx_div & RX_DIVIDER_BIT_1_2;
  338. rx_div_upper = (rx_div & RX_DIVIDER_BIT_3_4) >> 2;
  339. /* As per bpsec program the 8/3X clock divider to the below value */
  340. if (dev_priv->vbt.dsi.config->is_cmd_mode)
  341. mipi_8by3_divider = 0x2;
  342. else
  343. mipi_8by3_divider = 0x3;
  344. tmp |= BXT_MIPI_8X_BY3_DIVIDER(port, mipi_8by3_divider);
  345. tmp |= BXT_MIPI_TX_ESCLK_DIVIDER(port, tx_div);
  346. tmp |= BXT_MIPI_RX_ESCLK_LOWER_DIVIDER(port, rx_div_lower);
  347. tmp |= BXT_MIPI_RX_ESCLK_UPPER_DIVIDER(port, rx_div_upper);
  348. I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
  349. }
  350. static int bxt_compute_dsi_pll(struct intel_encoder *encoder,
  351. struct intel_crtc_state *config)
  352. {
  353. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  354. u8 dsi_ratio;
  355. u32 dsi_clk;
  356. dsi_clk = dsi_clk_from_pclk(intel_dsi->pclk, intel_dsi->pixel_format,
  357. intel_dsi->lane_count);
  358. /*
  359. * From clock diagram, to get PLL ratio divider, divide double of DSI
  360. * link rate (i.e., 2*8x=16x frequency value) by ref clock. Make sure to
  361. * round 'up' the result
  362. */
  363. dsi_ratio = DIV_ROUND_UP(dsi_clk * 2, BXT_REF_CLOCK_KHZ);
  364. if (dsi_ratio < BXT_DSI_PLL_RATIO_MIN ||
  365. dsi_ratio > BXT_DSI_PLL_RATIO_MAX) {
  366. DRM_ERROR("Cant get a suitable ratio from DSI PLL ratios\n");
  367. return -ECHRNG;
  368. }
  369. /*
  370. * Program DSI ratio and Select MIPIC and MIPIA PLL output as 8x
  371. * Spec says both have to be programmed, even if one is not getting
  372. * used. Configure MIPI_CLOCK_CTL dividers in modeset
  373. */
  374. config->dsi_pll.ctrl = dsi_ratio | BXT_DSIA_16X_BY2 | BXT_DSIC_16X_BY2;
  375. /* As per recommendation from hardware team,
  376. * Prog PVD ratio =1 if dsi ratio <= 50
  377. */
  378. if (dsi_ratio <= 50)
  379. config->dsi_pll.ctrl |= BXT_DSI_PLL_PVD_RATIO_1;
  380. return 0;
  381. }
  382. static void bxt_enable_dsi_pll(struct intel_encoder *encoder,
  383. const struct intel_crtc_state *config)
  384. {
  385. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  386. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  387. enum port port;
  388. u32 val;
  389. DRM_DEBUG_KMS("\n");
  390. /* Configure PLL vales */
  391. I915_WRITE(BXT_DSI_PLL_CTL, config->dsi_pll.ctrl);
  392. POSTING_READ(BXT_DSI_PLL_CTL);
  393. /* Program TX, RX, Dphy clocks */
  394. for_each_dsi_port(port, intel_dsi->ports)
  395. bxt_dsi_program_clocks(encoder->base.dev, port, config);
  396. /* Enable DSI PLL */
  397. val = I915_READ(BXT_DSI_PLL_ENABLE);
  398. val |= BXT_DSI_PLL_DO_ENABLE;
  399. I915_WRITE(BXT_DSI_PLL_ENABLE, val);
  400. /* Timeout and fail if PLL not locked */
  401. if (intel_wait_for_register(dev_priv,
  402. BXT_DSI_PLL_ENABLE,
  403. BXT_DSI_PLL_LOCKED,
  404. BXT_DSI_PLL_LOCKED,
  405. 1)) {
  406. DRM_ERROR("Timed out waiting for DSI PLL to lock\n");
  407. return;
  408. }
  409. DRM_DEBUG_KMS("DSI PLL locked\n");
  410. }
  411. bool intel_dsi_pll_is_enabled(struct drm_i915_private *dev_priv)
  412. {
  413. if (IS_BROXTON(dev_priv))
  414. return bxt_dsi_pll_is_enabled(dev_priv);
  415. MISSING_CASE(INTEL_DEVID(dev_priv));
  416. return false;
  417. }
  418. int intel_compute_dsi_pll(struct intel_encoder *encoder,
  419. struct intel_crtc_state *config)
  420. {
  421. struct drm_device *dev = encoder->base.dev;
  422. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  423. return vlv_compute_dsi_pll(encoder, config);
  424. else if (IS_BROXTON(dev))
  425. return bxt_compute_dsi_pll(encoder, config);
  426. return -ENODEV;
  427. }
  428. void intel_enable_dsi_pll(struct intel_encoder *encoder,
  429. const struct intel_crtc_state *config)
  430. {
  431. struct drm_device *dev = encoder->base.dev;
  432. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  433. vlv_enable_dsi_pll(encoder, config);
  434. else if (IS_BROXTON(dev))
  435. bxt_enable_dsi_pll(encoder, config);
  436. }
  437. void intel_disable_dsi_pll(struct intel_encoder *encoder)
  438. {
  439. struct drm_device *dev = encoder->base.dev;
  440. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  441. vlv_disable_dsi_pll(encoder);
  442. else if (IS_BROXTON(dev))
  443. bxt_disable_dsi_pll(encoder);
  444. }
  445. static void bxt_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
  446. {
  447. u32 tmp;
  448. struct drm_device *dev = encoder->base.dev;
  449. struct drm_i915_private *dev_priv = to_i915(dev);
  450. /* Clear old configurations */
  451. tmp = I915_READ(BXT_MIPI_CLOCK_CTL);
  452. tmp &= ~(BXT_MIPI_TX_ESCLK_FIXDIV_MASK(port));
  453. tmp &= ~(BXT_MIPI_RX_ESCLK_UPPER_FIXDIV_MASK(port));
  454. tmp &= ~(BXT_MIPI_8X_BY3_DIVIDER_MASK(port));
  455. tmp &= ~(BXT_MIPI_RX_ESCLK_LOWER_FIXDIV_MASK(port));
  456. I915_WRITE(BXT_MIPI_CLOCK_CTL, tmp);
  457. I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
  458. }
  459. void intel_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)
  460. {
  461. struct drm_device *dev = encoder->base.dev;
  462. if (IS_BROXTON(dev))
  463. bxt_dsi_reset_clocks(encoder, port);
  464. else if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  465. vlv_dsi_reset_clocks(encoder, port);
  466. }