intel_dsi.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  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. * Author: Jani Nikula <jani.nikula@intel.com>
  24. */
  25. #include <drm/drmP.h>
  26. #include <drm/drm_atomic_helper.h>
  27. #include <drm/drm_crtc.h>
  28. #include <drm/drm_edid.h>
  29. #include <drm/i915_drm.h>
  30. #include <drm/drm_panel.h>
  31. #include <drm/drm_mipi_dsi.h>
  32. #include <linux/slab.h>
  33. #include "i915_drv.h"
  34. #include "intel_drv.h"
  35. #include "intel_dsi.h"
  36. static const struct {
  37. u16 panel_id;
  38. struct drm_panel * (*init)(struct intel_dsi *intel_dsi, u16 panel_id);
  39. } intel_dsi_drivers[] = {
  40. {
  41. .panel_id = MIPI_DSI_GENERIC_PANEL_ID,
  42. .init = vbt_panel_init,
  43. },
  44. };
  45. static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi, enum port port)
  46. {
  47. struct drm_encoder *encoder = &intel_dsi->base.base;
  48. struct drm_device *dev = encoder->dev;
  49. struct drm_i915_private *dev_priv = dev->dev_private;
  50. u32 mask;
  51. mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
  52. LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
  53. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & mask) == mask, 100))
  54. DRM_ERROR("DPI FIFOs are not empty\n");
  55. }
  56. static void write_data(struct drm_i915_private *dev_priv, u32 reg,
  57. const u8 *data, u32 len)
  58. {
  59. u32 i, j;
  60. for (i = 0; i < len; i += 4) {
  61. u32 val = 0;
  62. for (j = 0; j < min_t(u32, len - i, 4); j++)
  63. val |= *data++ << 8 * j;
  64. I915_WRITE(reg, val);
  65. }
  66. }
  67. static void read_data(struct drm_i915_private *dev_priv, u32 reg,
  68. u8 *data, u32 len)
  69. {
  70. u32 i, j;
  71. for (i = 0; i < len; i += 4) {
  72. u32 val = I915_READ(reg);
  73. for (j = 0; j < min_t(u32, len - i, 4); j++)
  74. *data++ = val >> 8 * j;
  75. }
  76. }
  77. static ssize_t intel_dsi_host_transfer(struct mipi_dsi_host *host,
  78. const struct mipi_dsi_msg *msg)
  79. {
  80. struct intel_dsi_host *intel_dsi_host = to_intel_dsi_host(host);
  81. struct drm_device *dev = intel_dsi_host->intel_dsi->base.base.dev;
  82. struct drm_i915_private *dev_priv = dev->dev_private;
  83. enum port port = intel_dsi_host->port;
  84. struct mipi_dsi_packet packet;
  85. ssize_t ret;
  86. const u8 *header, *data;
  87. u32 data_reg, data_mask, ctrl_reg, ctrl_mask;
  88. ret = mipi_dsi_create_packet(&packet, msg);
  89. if (ret < 0)
  90. return ret;
  91. header = packet.header;
  92. data = packet.payload;
  93. if (msg->flags & MIPI_DSI_MSG_USE_LPM) {
  94. data_reg = MIPI_LP_GEN_DATA(port);
  95. data_mask = LP_DATA_FIFO_FULL;
  96. ctrl_reg = MIPI_LP_GEN_CTRL(port);
  97. ctrl_mask = LP_CTRL_FIFO_FULL;
  98. } else {
  99. data_reg = MIPI_HS_GEN_DATA(port);
  100. data_mask = HS_DATA_FIFO_FULL;
  101. ctrl_reg = MIPI_HS_GEN_CTRL(port);
  102. ctrl_mask = HS_CTRL_FIFO_FULL;
  103. }
  104. /* note: this is never true for reads */
  105. if (packet.payload_length) {
  106. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & data_mask) == 0, 50))
  107. DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n");
  108. write_data(dev_priv, data_reg, packet.payload,
  109. packet.payload_length);
  110. }
  111. if (msg->rx_len) {
  112. I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
  113. }
  114. if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(port)) & ctrl_mask) == 0, 50)) {
  115. DRM_ERROR("Timeout waiting for HS/LP CTRL FIFO !full\n");
  116. }
  117. I915_WRITE(ctrl_reg, header[2] << 16 | header[1] << 8 | header[0]);
  118. /* ->rx_len is set only for reads */
  119. if (msg->rx_len) {
  120. data_mask = GEN_READ_DATA_AVAIL;
  121. if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & data_mask) == data_mask, 50))
  122. DRM_ERROR("Timeout waiting for read data.\n");
  123. read_data(dev_priv, data_reg, msg->rx_buf, msg->rx_len);
  124. }
  125. /* XXX: fix for reads and writes */
  126. return 4 + packet.payload_length;
  127. }
  128. static int intel_dsi_host_attach(struct mipi_dsi_host *host,
  129. struct mipi_dsi_device *dsi)
  130. {
  131. return 0;
  132. }
  133. static int intel_dsi_host_detach(struct mipi_dsi_host *host,
  134. struct mipi_dsi_device *dsi)
  135. {
  136. return 0;
  137. }
  138. static const struct mipi_dsi_host_ops intel_dsi_host_ops = {
  139. .attach = intel_dsi_host_attach,
  140. .detach = intel_dsi_host_detach,
  141. .transfer = intel_dsi_host_transfer,
  142. };
  143. static struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
  144. enum port port)
  145. {
  146. struct intel_dsi_host *host;
  147. struct mipi_dsi_device *device;
  148. host = kzalloc(sizeof(*host), GFP_KERNEL);
  149. if (!host)
  150. return NULL;
  151. host->base.ops = &intel_dsi_host_ops;
  152. host->intel_dsi = intel_dsi;
  153. host->port = port;
  154. /*
  155. * We should call mipi_dsi_host_register(&host->base) here, but we don't
  156. * have a host->dev, and we don't have OF stuff either. So just use the
  157. * dsi framework as a library and hope for the best. Create the dsi
  158. * devices by ourselves here too. Need to be careful though, because we
  159. * don't initialize any of the driver model devices here.
  160. */
  161. device = kzalloc(sizeof(*device), GFP_KERNEL);
  162. if (!device) {
  163. kfree(host);
  164. return NULL;
  165. }
  166. device->host = &host->base;
  167. host->device = device;
  168. return host;
  169. }
  170. /*
  171. * send a video mode command
  172. *
  173. * XXX: commands with data in MIPI_DPI_DATA?
  174. */
  175. static int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs,
  176. enum port port)
  177. {
  178. struct drm_encoder *encoder = &intel_dsi->base.base;
  179. struct drm_device *dev = encoder->dev;
  180. struct drm_i915_private *dev_priv = dev->dev_private;
  181. u32 mask;
  182. /* XXX: pipe, hs */
  183. if (hs)
  184. cmd &= ~DPI_LP_MODE;
  185. else
  186. cmd |= DPI_LP_MODE;
  187. /* clear bit */
  188. I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
  189. /* XXX: old code skips write if control unchanged */
  190. if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
  191. DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
  192. I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
  193. mask = SPL_PKT_SENT_INTERRUPT;
  194. if (wait_for((I915_READ(MIPI_INTR_STAT(port)) & mask) == mask, 100))
  195. DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
  196. return 0;
  197. }
  198. static void band_gap_reset(struct drm_i915_private *dev_priv)
  199. {
  200. mutex_lock(&dev_priv->sb_lock);
  201. vlv_flisdsi_write(dev_priv, 0x08, 0x0001);
  202. vlv_flisdsi_write(dev_priv, 0x0F, 0x0005);
  203. vlv_flisdsi_write(dev_priv, 0x0F, 0x0025);
  204. udelay(150);
  205. vlv_flisdsi_write(dev_priv, 0x0F, 0x0000);
  206. vlv_flisdsi_write(dev_priv, 0x08, 0x0000);
  207. mutex_unlock(&dev_priv->sb_lock);
  208. }
  209. static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
  210. {
  211. return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
  212. }
  213. static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
  214. {
  215. return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
  216. }
  217. static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  218. struct intel_crtc_state *config)
  219. {
  220. struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
  221. base);
  222. struct intel_connector *intel_connector = intel_dsi->attached_connector;
  223. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  224. struct drm_display_mode *adjusted_mode = &config->base.adjusted_mode;
  225. DRM_DEBUG_KMS("\n");
  226. if (fixed_mode)
  227. intel_fixed_panel_mode(fixed_mode, adjusted_mode);
  228. /* DSI uses short packets for sync events, so clear mode flags for DSI */
  229. adjusted_mode->flags = 0;
  230. return true;
  231. }
  232. static void intel_dsi_port_enable(struct intel_encoder *encoder)
  233. {
  234. struct drm_device *dev = encoder->base.dev;
  235. struct drm_i915_private *dev_priv = dev->dev_private;
  236. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  237. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  238. enum port port;
  239. u32 temp;
  240. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
  241. temp = I915_READ(VLV_CHICKEN_3);
  242. temp &= ~PIXEL_OVERLAP_CNT_MASK |
  243. intel_dsi->pixel_overlap <<
  244. PIXEL_OVERLAP_CNT_SHIFT;
  245. I915_WRITE(VLV_CHICKEN_3, temp);
  246. }
  247. for_each_dsi_port(port, intel_dsi->ports) {
  248. temp = I915_READ(MIPI_PORT_CTRL(port));
  249. temp &= ~LANE_CONFIGURATION_MASK;
  250. temp &= ~DUAL_LINK_MODE_MASK;
  251. if (intel_dsi->ports == ((1 << PORT_A) | (1 << PORT_C))) {
  252. temp |= (intel_dsi->dual_link - 1)
  253. << DUAL_LINK_MODE_SHIFT;
  254. temp |= intel_crtc->pipe ?
  255. LANE_CONFIGURATION_DUAL_LINK_B :
  256. LANE_CONFIGURATION_DUAL_LINK_A;
  257. }
  258. /* assert ip_tg_enable signal */
  259. I915_WRITE(MIPI_PORT_CTRL(port), temp | DPI_ENABLE);
  260. POSTING_READ(MIPI_PORT_CTRL(port));
  261. }
  262. }
  263. static void intel_dsi_port_disable(struct intel_encoder *encoder)
  264. {
  265. struct drm_device *dev = encoder->base.dev;
  266. struct drm_i915_private *dev_priv = dev->dev_private;
  267. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  268. enum port port;
  269. u32 temp;
  270. for_each_dsi_port(port, intel_dsi->ports) {
  271. /* de-assert ip_tg_enable signal */
  272. temp = I915_READ(MIPI_PORT_CTRL(port));
  273. I915_WRITE(MIPI_PORT_CTRL(port), temp & ~DPI_ENABLE);
  274. POSTING_READ(MIPI_PORT_CTRL(port));
  275. }
  276. }
  277. static void intel_dsi_device_ready(struct intel_encoder *encoder)
  278. {
  279. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  280. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  281. enum port port;
  282. u32 val;
  283. DRM_DEBUG_KMS("\n");
  284. mutex_lock(&dev_priv->sb_lock);
  285. /* program rcomp for compliance, reduce from 50 ohms to 45 ohms
  286. * needed everytime after power gate */
  287. vlv_flisdsi_write(dev_priv, 0x04, 0x0004);
  288. mutex_unlock(&dev_priv->sb_lock);
  289. /* bandgap reset is needed after everytime we do power gate */
  290. band_gap_reset(dev_priv);
  291. for_each_dsi_port(port, intel_dsi->ports) {
  292. I915_WRITE(MIPI_DEVICE_READY(port), ULPS_STATE_ENTER);
  293. usleep_range(2500, 3000);
  294. /* Enable MIPI PHY transparent latch
  295. * Common bit for both MIPI Port A & MIPI Port C
  296. * No similar bit in MIPI Port C reg
  297. */
  298. val = I915_READ(MIPI_PORT_CTRL(PORT_A));
  299. I915_WRITE(MIPI_PORT_CTRL(PORT_A), val | LP_OUTPUT_HOLD);
  300. usleep_range(1000, 1500);
  301. I915_WRITE(MIPI_DEVICE_READY(port), ULPS_STATE_EXIT);
  302. usleep_range(2500, 3000);
  303. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY);
  304. usleep_range(2500, 3000);
  305. }
  306. }
  307. static void intel_dsi_enable(struct intel_encoder *encoder)
  308. {
  309. struct drm_device *dev = encoder->base.dev;
  310. struct drm_i915_private *dev_priv = dev->dev_private;
  311. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  312. enum port port;
  313. DRM_DEBUG_KMS("\n");
  314. if (is_cmd_mode(intel_dsi)) {
  315. for_each_dsi_port(port, intel_dsi->ports)
  316. I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
  317. } else {
  318. msleep(20); /* XXX */
  319. for_each_dsi_port(port, intel_dsi->ports)
  320. dpi_send_cmd(intel_dsi, TURN_ON, false, port);
  321. msleep(100);
  322. drm_panel_enable(intel_dsi->panel);
  323. for_each_dsi_port(port, intel_dsi->ports)
  324. wait_for_dsi_fifo_empty(intel_dsi, port);
  325. intel_dsi_port_enable(encoder);
  326. }
  327. }
  328. static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  329. {
  330. struct drm_device *dev = encoder->base.dev;
  331. struct drm_i915_private *dev_priv = dev->dev_private;
  332. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  333. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  334. enum pipe pipe = intel_crtc->pipe;
  335. enum port port;
  336. u32 tmp;
  337. DRM_DEBUG_KMS("\n");
  338. /* Disable DPOunit clock gating, can stall pipe
  339. * and we need DPLL REFA always enabled */
  340. tmp = I915_READ(DPLL(pipe));
  341. tmp |= DPLL_REFA_CLK_ENABLE_VLV;
  342. I915_WRITE(DPLL(pipe), tmp);
  343. /* update the hw state for DPLL */
  344. intel_crtc->config->dpll_hw_state.dpll = DPLL_INTEGRATED_CLOCK_VLV |
  345. DPLL_REFA_CLK_ENABLE_VLV;
  346. tmp = I915_READ(DSPCLK_GATE_D);
  347. tmp |= DPOUNIT_CLOCK_GATE_DISABLE;
  348. I915_WRITE(DSPCLK_GATE_D, tmp);
  349. /* put device in ready state */
  350. intel_dsi_device_ready(encoder);
  351. msleep(intel_dsi->panel_on_delay);
  352. drm_panel_prepare(intel_dsi->panel);
  353. for_each_dsi_port(port, intel_dsi->ports)
  354. wait_for_dsi_fifo_empty(intel_dsi, port);
  355. /* Enable port in pre-enable phase itself because as per hw team
  356. * recommendation, port should be enabled befor plane & pipe */
  357. intel_dsi_enable(encoder);
  358. }
  359. static void intel_dsi_enable_nop(struct intel_encoder *encoder)
  360. {
  361. DRM_DEBUG_KMS("\n");
  362. /* for DSI port enable has to be done before pipe
  363. * and plane enable, so port enable is done in
  364. * pre_enable phase itself unlike other encoders
  365. */
  366. }
  367. static void intel_dsi_pre_disable(struct intel_encoder *encoder)
  368. {
  369. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  370. enum port port;
  371. DRM_DEBUG_KMS("\n");
  372. if (is_vid_mode(intel_dsi)) {
  373. /* Send Shutdown command to the panel in LP mode */
  374. for_each_dsi_port(port, intel_dsi->ports)
  375. dpi_send_cmd(intel_dsi, SHUTDOWN, false, port);
  376. msleep(10);
  377. }
  378. }
  379. static void intel_dsi_disable(struct intel_encoder *encoder)
  380. {
  381. struct drm_device *dev = encoder->base.dev;
  382. struct drm_i915_private *dev_priv = dev->dev_private;
  383. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  384. enum port port;
  385. u32 temp;
  386. DRM_DEBUG_KMS("\n");
  387. if (is_vid_mode(intel_dsi)) {
  388. for_each_dsi_port(port, intel_dsi->ports)
  389. wait_for_dsi_fifo_empty(intel_dsi, port);
  390. intel_dsi_port_disable(encoder);
  391. msleep(2);
  392. }
  393. for_each_dsi_port(port, intel_dsi->ports) {
  394. /* Panel commands can be sent when clock is in LP11 */
  395. I915_WRITE(MIPI_DEVICE_READY(port), 0x0);
  396. temp = I915_READ(MIPI_CTRL(port));
  397. temp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  398. I915_WRITE(MIPI_CTRL(port), temp |
  399. intel_dsi->escape_clk_div <<
  400. ESCAPE_CLOCK_DIVIDER_SHIFT);
  401. I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
  402. temp = I915_READ(MIPI_DSI_FUNC_PRG(port));
  403. temp &= ~VID_MODE_FORMAT_MASK;
  404. I915_WRITE(MIPI_DSI_FUNC_PRG(port), temp);
  405. I915_WRITE(MIPI_DEVICE_READY(port), 0x1);
  406. }
  407. /* if disable packets are sent before sending shutdown packet then in
  408. * some next enable sequence send turn on packet error is observed */
  409. drm_panel_disable(intel_dsi->panel);
  410. for_each_dsi_port(port, intel_dsi->ports)
  411. wait_for_dsi_fifo_empty(intel_dsi, port);
  412. }
  413. static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
  414. {
  415. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  416. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  417. enum port port;
  418. u32 val;
  419. DRM_DEBUG_KMS("\n");
  420. for_each_dsi_port(port, intel_dsi->ports) {
  421. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  422. ULPS_STATE_ENTER);
  423. usleep_range(2000, 2500);
  424. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  425. ULPS_STATE_EXIT);
  426. usleep_range(2000, 2500);
  427. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  428. ULPS_STATE_ENTER);
  429. usleep_range(2000, 2500);
  430. /* Wait till Clock lanes are in LP-00 state for MIPI Port A
  431. * only. MIPI Port C has no similar bit for checking
  432. */
  433. if (wait_for(((I915_READ(MIPI_PORT_CTRL(PORT_A)) & AFE_LATCHOUT)
  434. == 0x00000), 30))
  435. DRM_ERROR("DSI LP not going Low\n");
  436. /* Disable MIPI PHY transparent latch
  437. * Common bit for both MIPI Port A & MIPI Port C
  438. */
  439. val = I915_READ(MIPI_PORT_CTRL(PORT_A));
  440. I915_WRITE(MIPI_PORT_CTRL(PORT_A), val & ~LP_OUTPUT_HOLD);
  441. usleep_range(1000, 1500);
  442. I915_WRITE(MIPI_DEVICE_READY(port), 0x00);
  443. usleep_range(2000, 2500);
  444. }
  445. vlv_disable_dsi_pll(encoder);
  446. }
  447. static void intel_dsi_post_disable(struct intel_encoder *encoder)
  448. {
  449. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  450. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  451. u32 val;
  452. DRM_DEBUG_KMS("\n");
  453. intel_dsi_disable(encoder);
  454. intel_dsi_clear_device_ready(encoder);
  455. val = I915_READ(DSPCLK_GATE_D);
  456. val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
  457. I915_WRITE(DSPCLK_GATE_D, val);
  458. drm_panel_unprepare(intel_dsi->panel);
  459. msleep(intel_dsi->panel_off_delay);
  460. msleep(intel_dsi->panel_pwr_cycle_delay);
  461. }
  462. static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
  463. enum pipe *pipe)
  464. {
  465. struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
  466. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  467. struct drm_device *dev = encoder->base.dev;
  468. enum intel_display_power_domain power_domain;
  469. u32 dpi_enabled, func;
  470. enum port port;
  471. DRM_DEBUG_KMS("\n");
  472. power_domain = intel_display_port_power_domain(encoder);
  473. if (!intel_display_power_is_enabled(dev_priv, power_domain))
  474. return false;
  475. /* XXX: this only works for one DSI output */
  476. for_each_dsi_port(port, intel_dsi->ports) {
  477. func = I915_READ(MIPI_DSI_FUNC_PRG(port));
  478. dpi_enabled = I915_READ(MIPI_PORT_CTRL(port)) &
  479. DPI_ENABLE;
  480. /* Due to some hardware limitations on BYT, MIPI Port C DPI
  481. * Enable bit does not get set. To check whether DSI Port C
  482. * was enabled in BIOS, check the Pipe B enable bit
  483. */
  484. if (IS_VALLEYVIEW(dev) && !IS_CHERRYVIEW(dev) &&
  485. (port == PORT_C))
  486. dpi_enabled = I915_READ(PIPECONF(PIPE_B)) &
  487. PIPECONF_ENABLE;
  488. if (dpi_enabled || (func & CMD_MODE_DATA_WIDTH_MASK)) {
  489. if (I915_READ(MIPI_DEVICE_READY(port)) & DEVICE_READY) {
  490. *pipe = port == PORT_A ? PIPE_A : PIPE_B;
  491. return true;
  492. }
  493. }
  494. }
  495. return false;
  496. }
  497. static void intel_dsi_get_config(struct intel_encoder *encoder,
  498. struct intel_crtc_state *pipe_config)
  499. {
  500. u32 pclk;
  501. DRM_DEBUG_KMS("\n");
  502. /*
  503. * DPLL_MD is not used in case of DSI, reading will get some default value
  504. * set dpll_md = 0
  505. */
  506. pipe_config->dpll_hw_state.dpll_md = 0;
  507. pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
  508. if (!pclk)
  509. return;
  510. pipe_config->base.adjusted_mode.crtc_clock = pclk;
  511. pipe_config->port_clock = pclk;
  512. }
  513. static enum drm_mode_status
  514. intel_dsi_mode_valid(struct drm_connector *connector,
  515. struct drm_display_mode *mode)
  516. {
  517. struct intel_connector *intel_connector = to_intel_connector(connector);
  518. struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  519. DRM_DEBUG_KMS("\n");
  520. if (mode->flags & DRM_MODE_FLAG_DBLSCAN) {
  521. DRM_DEBUG_KMS("MODE_NO_DBLESCAN\n");
  522. return MODE_NO_DBLESCAN;
  523. }
  524. if (fixed_mode) {
  525. if (mode->hdisplay > fixed_mode->hdisplay)
  526. return MODE_PANEL;
  527. if (mode->vdisplay > fixed_mode->vdisplay)
  528. return MODE_PANEL;
  529. }
  530. return MODE_OK;
  531. }
  532. /* return txclkesc cycles in terms of divider and duration in us */
  533. static u16 txclkesc(u32 divider, unsigned int us)
  534. {
  535. switch (divider) {
  536. case ESCAPE_CLOCK_DIVIDER_1:
  537. default:
  538. return 20 * us;
  539. case ESCAPE_CLOCK_DIVIDER_2:
  540. return 10 * us;
  541. case ESCAPE_CLOCK_DIVIDER_4:
  542. return 5 * us;
  543. }
  544. }
  545. /* return pixels in terms of txbyteclkhs */
  546. static u16 txbyteclkhs(u16 pixels, int bpp, int lane_count,
  547. u16 burst_mode_ratio)
  548. {
  549. return DIV_ROUND_UP(DIV_ROUND_UP(pixels * bpp * burst_mode_ratio,
  550. 8 * 100), lane_count);
  551. }
  552. static void set_dsi_timings(struct drm_encoder *encoder,
  553. const struct drm_display_mode *mode)
  554. {
  555. struct drm_device *dev = encoder->dev;
  556. struct drm_i915_private *dev_priv = dev->dev_private;
  557. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  558. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  559. enum port port;
  560. unsigned int bpp = intel_crtc->config->pipe_bpp;
  561. unsigned int lane_count = intel_dsi->lane_count;
  562. u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp;
  563. hactive = mode->hdisplay;
  564. hfp = mode->hsync_start - mode->hdisplay;
  565. hsync = mode->hsync_end - mode->hsync_start;
  566. hbp = mode->htotal - mode->hsync_end;
  567. if (intel_dsi->dual_link) {
  568. hactive /= 2;
  569. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
  570. hactive += intel_dsi->pixel_overlap;
  571. hfp /= 2;
  572. hsync /= 2;
  573. hbp /= 2;
  574. }
  575. vfp = mode->vsync_start - mode->vdisplay;
  576. vsync = mode->vsync_end - mode->vsync_start;
  577. vbp = mode->vtotal - mode->vsync_end;
  578. /* horizontal values are in terms of high speed byte clock */
  579. hactive = txbyteclkhs(hactive, bpp, lane_count,
  580. intel_dsi->burst_mode_ratio);
  581. hfp = txbyteclkhs(hfp, bpp, lane_count, intel_dsi->burst_mode_ratio);
  582. hsync = txbyteclkhs(hsync, bpp, lane_count,
  583. intel_dsi->burst_mode_ratio);
  584. hbp = txbyteclkhs(hbp, bpp, lane_count, intel_dsi->burst_mode_ratio);
  585. for_each_dsi_port(port, intel_dsi->ports) {
  586. I915_WRITE(MIPI_HACTIVE_AREA_COUNT(port), hactive);
  587. I915_WRITE(MIPI_HFP_COUNT(port), hfp);
  588. /* meaningful for video mode non-burst sync pulse mode only,
  589. * can be zero for non-burst sync events and burst modes */
  590. I915_WRITE(MIPI_HSYNC_PADDING_COUNT(port), hsync);
  591. I915_WRITE(MIPI_HBP_COUNT(port), hbp);
  592. /* vertical values are in terms of lines */
  593. I915_WRITE(MIPI_VFP_COUNT(port), vfp);
  594. I915_WRITE(MIPI_VSYNC_PADDING_COUNT(port), vsync);
  595. I915_WRITE(MIPI_VBP_COUNT(port), vbp);
  596. }
  597. }
  598. static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
  599. {
  600. struct drm_encoder *encoder = &intel_encoder->base;
  601. struct drm_device *dev = encoder->dev;
  602. struct drm_i915_private *dev_priv = dev->dev_private;
  603. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  604. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  605. struct drm_display_mode *adjusted_mode =
  606. &intel_crtc->config->base.adjusted_mode;
  607. enum port port;
  608. unsigned int bpp = intel_crtc->config->pipe_bpp;
  609. u32 val, tmp;
  610. u16 mode_hdisplay;
  611. DRM_DEBUG_KMS("pipe %c\n", pipe_name(intel_crtc->pipe));
  612. mode_hdisplay = adjusted_mode->hdisplay;
  613. if (intel_dsi->dual_link) {
  614. mode_hdisplay /= 2;
  615. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
  616. mode_hdisplay += intel_dsi->pixel_overlap;
  617. }
  618. for_each_dsi_port(port, intel_dsi->ports) {
  619. /* escape clock divider, 20MHz, shared for A and C.
  620. * device ready must be off when doing this! txclkesc? */
  621. tmp = I915_READ(MIPI_CTRL(PORT_A));
  622. tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  623. I915_WRITE(MIPI_CTRL(PORT_A), tmp | ESCAPE_CLOCK_DIVIDER_1);
  624. /* read request priority is per pipe */
  625. tmp = I915_READ(MIPI_CTRL(port));
  626. tmp &= ~READ_REQUEST_PRIORITY_MASK;
  627. I915_WRITE(MIPI_CTRL(port), tmp | READ_REQUEST_PRIORITY_HIGH);
  628. /* XXX: why here, why like this? handling in irq handler?! */
  629. I915_WRITE(MIPI_INTR_STAT(port), 0xffffffff);
  630. I915_WRITE(MIPI_INTR_EN(port), 0xffffffff);
  631. I915_WRITE(MIPI_DPHY_PARAM(port), intel_dsi->dphy_reg);
  632. I915_WRITE(MIPI_DPI_RESOLUTION(port),
  633. adjusted_mode->vdisplay << VERTICAL_ADDRESS_SHIFT |
  634. mode_hdisplay << HORIZONTAL_ADDRESS_SHIFT);
  635. }
  636. set_dsi_timings(encoder, adjusted_mode);
  637. val = intel_dsi->lane_count << DATA_LANES_PRG_REG_SHIFT;
  638. if (is_cmd_mode(intel_dsi)) {
  639. val |= intel_dsi->channel << CMD_MODE_CHANNEL_NUMBER_SHIFT;
  640. val |= CMD_MODE_DATA_WIDTH_8_BIT; /* XXX */
  641. } else {
  642. val |= intel_dsi->channel << VID_MODE_CHANNEL_NUMBER_SHIFT;
  643. /* XXX: cross-check bpp vs. pixel format? */
  644. val |= intel_dsi->pixel_format;
  645. }
  646. tmp = 0;
  647. if (intel_dsi->eotp_pkt == 0)
  648. tmp |= EOT_DISABLE;
  649. if (intel_dsi->clock_stop)
  650. tmp |= CLOCKSTOP;
  651. for_each_dsi_port(port, intel_dsi->ports) {
  652. I915_WRITE(MIPI_DSI_FUNC_PRG(port), val);
  653. /* timeouts for recovery. one frame IIUC. if counter expires,
  654. * EOT and stop state. */
  655. /*
  656. * In burst mode, value greater than one DPI line Time in byte
  657. * clock (txbyteclkhs) To timeout this timer 1+ of the above
  658. * said value is recommended.
  659. *
  660. * In non-burst mode, Value greater than one DPI frame time in
  661. * byte clock(txbyteclkhs) To timeout this timer 1+ of the above
  662. * said value is recommended.
  663. *
  664. * In DBI only mode, value greater than one DBI frame time in
  665. * byte clock(txbyteclkhs) To timeout this timer 1+ of the above
  666. * said value is recommended.
  667. */
  668. if (is_vid_mode(intel_dsi) &&
  669. intel_dsi->video_mode_format == VIDEO_MODE_BURST) {
  670. I915_WRITE(MIPI_HS_TX_TIMEOUT(port),
  671. txbyteclkhs(adjusted_mode->htotal, bpp,
  672. intel_dsi->lane_count,
  673. intel_dsi->burst_mode_ratio) + 1);
  674. } else {
  675. I915_WRITE(MIPI_HS_TX_TIMEOUT(port),
  676. txbyteclkhs(adjusted_mode->vtotal *
  677. adjusted_mode->htotal,
  678. bpp, intel_dsi->lane_count,
  679. intel_dsi->burst_mode_ratio) + 1);
  680. }
  681. I915_WRITE(MIPI_LP_RX_TIMEOUT(port), intel_dsi->lp_rx_timeout);
  682. I915_WRITE(MIPI_TURN_AROUND_TIMEOUT(port),
  683. intel_dsi->turn_arnd_val);
  684. I915_WRITE(MIPI_DEVICE_RESET_TIMER(port),
  685. intel_dsi->rst_timer_val);
  686. /* dphy stuff */
  687. /* in terms of low power clock */
  688. I915_WRITE(MIPI_INIT_COUNT(port),
  689. txclkesc(intel_dsi->escape_clk_div, 100));
  690. /* recovery disables */
  691. I915_WRITE(MIPI_EOT_DISABLE(port), tmp);
  692. /* in terms of low power clock */
  693. I915_WRITE(MIPI_INIT_COUNT(port), intel_dsi->init_count);
  694. /* in terms of txbyteclkhs. actual high to low switch +
  695. * MIPI_STOP_STATE_STALL * MIPI_LP_BYTECLK.
  696. *
  697. * XXX: write MIPI_STOP_STATE_STALL?
  698. */
  699. I915_WRITE(MIPI_HIGH_LOW_SWITCH_COUNT(port),
  700. intel_dsi->hs_to_lp_count);
  701. /* XXX: low power clock equivalence in terms of byte clock.
  702. * the number of byte clocks occupied in one low power clock.
  703. * based on txbyteclkhs and txclkesc.
  704. * txclkesc time / txbyteclk time * (105 + MIPI_STOP_STATE_STALL
  705. * ) / 105.???
  706. */
  707. I915_WRITE(MIPI_LP_BYTECLK(port), intel_dsi->lp_byte_clk);
  708. /* the bw essential for transmitting 16 long packets containing
  709. * 252 bytes meant for dcs write memory command is programmed in
  710. * this register in terms of byte clocks. based on dsi transfer
  711. * rate and the number of lanes configured the time taken to
  712. * transmit 16 long packets in a dsi stream varies. */
  713. I915_WRITE(MIPI_DBI_BW_CTRL(port), intel_dsi->bw_timer);
  714. I915_WRITE(MIPI_CLK_LANE_SWITCH_TIME_CNT(port),
  715. intel_dsi->clk_lp_to_hs_count << LP_HS_SSW_CNT_SHIFT |
  716. intel_dsi->clk_hs_to_lp_count << HS_LP_PWR_SW_CNT_SHIFT);
  717. if (is_vid_mode(intel_dsi))
  718. /* Some panels might have resolution which is not a
  719. * multiple of 64 like 1366 x 768. Enable RANDOM
  720. * resolution support for such panels by default */
  721. I915_WRITE(MIPI_VIDEO_MODE_FORMAT(port),
  722. intel_dsi->video_frmt_cfg_bits |
  723. intel_dsi->video_mode_format |
  724. IP_TG_CONFIG |
  725. RANDOM_DPI_DISPLAY_RESOLUTION);
  726. }
  727. }
  728. static void intel_dsi_pre_pll_enable(struct intel_encoder *encoder)
  729. {
  730. DRM_DEBUG_KMS("\n");
  731. intel_dsi_prepare(encoder);
  732. vlv_enable_dsi_pll(encoder);
  733. }
  734. static enum drm_connector_status
  735. intel_dsi_detect(struct drm_connector *connector, bool force)
  736. {
  737. return connector_status_connected;
  738. }
  739. static int intel_dsi_get_modes(struct drm_connector *connector)
  740. {
  741. struct intel_connector *intel_connector = to_intel_connector(connector);
  742. struct drm_display_mode *mode;
  743. DRM_DEBUG_KMS("\n");
  744. if (!intel_connector->panel.fixed_mode) {
  745. DRM_DEBUG_KMS("no fixed mode\n");
  746. return 0;
  747. }
  748. mode = drm_mode_duplicate(connector->dev,
  749. intel_connector->panel.fixed_mode);
  750. if (!mode) {
  751. DRM_DEBUG_KMS("drm_mode_duplicate failed\n");
  752. return 0;
  753. }
  754. drm_mode_probed_add(connector, mode);
  755. return 1;
  756. }
  757. static void intel_dsi_connector_destroy(struct drm_connector *connector)
  758. {
  759. struct intel_connector *intel_connector = to_intel_connector(connector);
  760. DRM_DEBUG_KMS("\n");
  761. intel_panel_fini(&intel_connector->panel);
  762. drm_connector_cleanup(connector);
  763. kfree(connector);
  764. }
  765. static void intel_dsi_encoder_destroy(struct drm_encoder *encoder)
  766. {
  767. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  768. if (intel_dsi->panel) {
  769. drm_panel_detach(intel_dsi->panel);
  770. /* XXX: Logically this call belongs in the panel driver. */
  771. drm_panel_remove(intel_dsi->panel);
  772. }
  773. intel_encoder_destroy(encoder);
  774. }
  775. static const struct drm_encoder_funcs intel_dsi_funcs = {
  776. .destroy = intel_dsi_encoder_destroy,
  777. };
  778. static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
  779. .get_modes = intel_dsi_get_modes,
  780. .mode_valid = intel_dsi_mode_valid,
  781. .best_encoder = intel_best_encoder,
  782. };
  783. static const struct drm_connector_funcs intel_dsi_connector_funcs = {
  784. .dpms = intel_connector_dpms,
  785. .detect = intel_dsi_detect,
  786. .destroy = intel_dsi_connector_destroy,
  787. .fill_modes = drm_helper_probe_single_connector_modes,
  788. .atomic_get_property = intel_connector_atomic_get_property,
  789. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  790. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  791. };
  792. void intel_dsi_init(struct drm_device *dev)
  793. {
  794. struct intel_dsi *intel_dsi;
  795. struct intel_encoder *intel_encoder;
  796. struct drm_encoder *encoder;
  797. struct intel_connector *intel_connector;
  798. struct drm_connector *connector;
  799. struct drm_display_mode *scan, *fixed_mode = NULL;
  800. struct drm_i915_private *dev_priv = dev->dev_private;
  801. enum port port;
  802. unsigned int i;
  803. DRM_DEBUG_KMS("\n");
  804. /* There is no detection method for MIPI so rely on VBT */
  805. if (!dev_priv->vbt.has_mipi)
  806. return;
  807. if (IS_VALLEYVIEW(dev)) {
  808. dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
  809. } else {
  810. DRM_ERROR("Unsupported Mipi device to reg base");
  811. return;
  812. }
  813. intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
  814. if (!intel_dsi)
  815. return;
  816. intel_connector = intel_connector_alloc();
  817. if (!intel_connector) {
  818. kfree(intel_dsi);
  819. return;
  820. }
  821. intel_encoder = &intel_dsi->base;
  822. encoder = &intel_encoder->base;
  823. intel_dsi->attached_connector = intel_connector;
  824. connector = &intel_connector->base;
  825. drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI);
  826. /* XXX: very likely not all of these are needed */
  827. intel_encoder->compute_config = intel_dsi_compute_config;
  828. intel_encoder->pre_pll_enable = intel_dsi_pre_pll_enable;
  829. intel_encoder->pre_enable = intel_dsi_pre_enable;
  830. intel_encoder->enable = intel_dsi_enable_nop;
  831. intel_encoder->disable = intel_dsi_pre_disable;
  832. intel_encoder->post_disable = intel_dsi_post_disable;
  833. intel_encoder->get_hw_state = intel_dsi_get_hw_state;
  834. intel_encoder->get_config = intel_dsi_get_config;
  835. intel_connector->get_hw_state = intel_connector_get_hw_state;
  836. intel_connector->unregister = intel_connector_unregister;
  837. /* Pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI port C */
  838. if (dev_priv->vbt.dsi.config->dual_link) {
  839. /* XXX: does dual link work on either pipe? */
  840. intel_encoder->crtc_mask = (1 << PIPE_A);
  841. intel_dsi->ports = ((1 << PORT_A) | (1 << PORT_C));
  842. } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIA) {
  843. intel_encoder->crtc_mask = (1 << PIPE_A);
  844. intel_dsi->ports = (1 << PORT_A);
  845. } else if (dev_priv->vbt.dsi.port == DVO_PORT_MIPIC) {
  846. intel_encoder->crtc_mask = (1 << PIPE_B);
  847. intel_dsi->ports = (1 << PORT_C);
  848. }
  849. /* Create a DSI host (and a device) for each port. */
  850. for_each_dsi_port(port, intel_dsi->ports) {
  851. struct intel_dsi_host *host;
  852. host = intel_dsi_host_init(intel_dsi, port);
  853. if (!host)
  854. goto err;
  855. intel_dsi->dsi_hosts[port] = host;
  856. }
  857. for (i = 0; i < ARRAY_SIZE(intel_dsi_drivers); i++) {
  858. intel_dsi->panel = intel_dsi_drivers[i].init(intel_dsi,
  859. intel_dsi_drivers[i].panel_id);
  860. if (intel_dsi->panel)
  861. break;
  862. }
  863. if (!intel_dsi->panel) {
  864. DRM_DEBUG_KMS("no device found\n");
  865. goto err;
  866. }
  867. intel_encoder->type = INTEL_OUTPUT_DSI;
  868. intel_encoder->cloneable = 0;
  869. drm_connector_init(dev, connector, &intel_dsi_connector_funcs,
  870. DRM_MODE_CONNECTOR_DSI);
  871. drm_connector_helper_add(connector, &intel_dsi_connector_helper_funcs);
  872. connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/
  873. connector->interlace_allowed = false;
  874. connector->doublescan_allowed = false;
  875. intel_connector_attach_encoder(intel_connector, intel_encoder);
  876. drm_connector_register(connector);
  877. drm_panel_attach(intel_dsi->panel, connector);
  878. mutex_lock(&dev->mode_config.mutex);
  879. drm_panel_get_modes(intel_dsi->panel);
  880. list_for_each_entry(scan, &connector->probed_modes, head) {
  881. if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
  882. fixed_mode = drm_mode_duplicate(dev, scan);
  883. break;
  884. }
  885. }
  886. mutex_unlock(&dev->mode_config.mutex);
  887. if (!fixed_mode) {
  888. DRM_DEBUG_KMS("no fixed mode\n");
  889. goto err;
  890. }
  891. intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
  892. return;
  893. err:
  894. drm_encoder_cleanup(&intel_encoder->base);
  895. kfree(intel_dsi);
  896. kfree(intel_connector);
  897. }