intel_dsi.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614
  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 <linux/gpio/consumer.h>
  34. #include "i915_drv.h"
  35. #include "intel_drv.h"
  36. #include "intel_dsi.h"
  37. static const struct {
  38. u16 panel_id;
  39. struct drm_panel * (*init)(struct intel_dsi *intel_dsi, u16 panel_id);
  40. } intel_dsi_drivers[] = {
  41. {
  42. .panel_id = MIPI_DSI_GENERIC_PANEL_ID,
  43. .init = vbt_panel_init,
  44. },
  45. };
  46. /* return pixels in terms of txbyteclkhs */
  47. static u16 txbyteclkhs(u16 pixels, int bpp, int lane_count,
  48. u16 burst_mode_ratio)
  49. {
  50. return DIV_ROUND_UP(DIV_ROUND_UP(pixels * bpp * burst_mode_ratio,
  51. 8 * 100), lane_count);
  52. }
  53. /* return pixels equvalent to txbyteclkhs */
  54. static u16 pixels_from_txbyteclkhs(u16 clk_hs, int bpp, int lane_count,
  55. u16 burst_mode_ratio)
  56. {
  57. return DIV_ROUND_UP((clk_hs * lane_count * 8 * 100),
  58. (bpp * burst_mode_ratio));
  59. }
  60. enum mipi_dsi_pixel_format pixel_format_from_register_bits(u32 fmt)
  61. {
  62. /* It just so happens the VBT matches register contents. */
  63. switch (fmt) {
  64. case VID_MODE_FORMAT_RGB888:
  65. return MIPI_DSI_FMT_RGB888;
  66. case VID_MODE_FORMAT_RGB666:
  67. return MIPI_DSI_FMT_RGB666;
  68. case VID_MODE_FORMAT_RGB666_PACKED:
  69. return MIPI_DSI_FMT_RGB666_PACKED;
  70. case VID_MODE_FORMAT_RGB565:
  71. return MIPI_DSI_FMT_RGB565;
  72. default:
  73. MISSING_CASE(fmt);
  74. return MIPI_DSI_FMT_RGB666;
  75. }
  76. }
  77. static void wait_for_dsi_fifo_empty(struct intel_dsi *intel_dsi, enum port port)
  78. {
  79. struct drm_encoder *encoder = &intel_dsi->base.base;
  80. struct drm_device *dev = encoder->dev;
  81. struct drm_i915_private *dev_priv = to_i915(dev);
  82. u32 mask;
  83. mask = LP_CTRL_FIFO_EMPTY | HS_CTRL_FIFO_EMPTY |
  84. LP_DATA_FIFO_EMPTY | HS_DATA_FIFO_EMPTY;
  85. if (intel_wait_for_register(dev_priv,
  86. MIPI_GEN_FIFO_STAT(port), mask, mask,
  87. 100))
  88. DRM_ERROR("DPI FIFOs are not empty\n");
  89. }
  90. static void write_data(struct drm_i915_private *dev_priv,
  91. i915_reg_t reg,
  92. const u8 *data, u32 len)
  93. {
  94. u32 i, j;
  95. for (i = 0; i < len; i += 4) {
  96. u32 val = 0;
  97. for (j = 0; j < min_t(u32, len - i, 4); j++)
  98. val |= *data++ << 8 * j;
  99. I915_WRITE(reg, val);
  100. }
  101. }
  102. static void read_data(struct drm_i915_private *dev_priv,
  103. i915_reg_t reg,
  104. u8 *data, u32 len)
  105. {
  106. u32 i, j;
  107. for (i = 0; i < len; i += 4) {
  108. u32 val = I915_READ(reg);
  109. for (j = 0; j < min_t(u32, len - i, 4); j++)
  110. *data++ = val >> 8 * j;
  111. }
  112. }
  113. static ssize_t intel_dsi_host_transfer(struct mipi_dsi_host *host,
  114. const struct mipi_dsi_msg *msg)
  115. {
  116. struct intel_dsi_host *intel_dsi_host = to_intel_dsi_host(host);
  117. struct drm_device *dev = intel_dsi_host->intel_dsi->base.base.dev;
  118. struct drm_i915_private *dev_priv = to_i915(dev);
  119. enum port port = intel_dsi_host->port;
  120. struct mipi_dsi_packet packet;
  121. ssize_t ret;
  122. const u8 *header, *data;
  123. i915_reg_t data_reg, ctrl_reg;
  124. u32 data_mask, ctrl_mask;
  125. ret = mipi_dsi_create_packet(&packet, msg);
  126. if (ret < 0)
  127. return ret;
  128. header = packet.header;
  129. data = packet.payload;
  130. if (msg->flags & MIPI_DSI_MSG_USE_LPM) {
  131. data_reg = MIPI_LP_GEN_DATA(port);
  132. data_mask = LP_DATA_FIFO_FULL;
  133. ctrl_reg = MIPI_LP_GEN_CTRL(port);
  134. ctrl_mask = LP_CTRL_FIFO_FULL;
  135. } else {
  136. data_reg = MIPI_HS_GEN_DATA(port);
  137. data_mask = HS_DATA_FIFO_FULL;
  138. ctrl_reg = MIPI_HS_GEN_CTRL(port);
  139. ctrl_mask = HS_CTRL_FIFO_FULL;
  140. }
  141. /* note: this is never true for reads */
  142. if (packet.payload_length) {
  143. if (intel_wait_for_register(dev_priv,
  144. MIPI_GEN_FIFO_STAT(port),
  145. data_mask, 0,
  146. 50))
  147. DRM_ERROR("Timeout waiting for HS/LP DATA FIFO !full\n");
  148. write_data(dev_priv, data_reg, packet.payload,
  149. packet.payload_length);
  150. }
  151. if (msg->rx_len) {
  152. I915_WRITE(MIPI_INTR_STAT(port), GEN_READ_DATA_AVAIL);
  153. }
  154. if (intel_wait_for_register(dev_priv,
  155. MIPI_GEN_FIFO_STAT(port),
  156. ctrl_mask, 0,
  157. 50)) {
  158. DRM_ERROR("Timeout waiting for HS/LP CTRL FIFO !full\n");
  159. }
  160. I915_WRITE(ctrl_reg, header[2] << 16 | header[1] << 8 | header[0]);
  161. /* ->rx_len is set only for reads */
  162. if (msg->rx_len) {
  163. data_mask = GEN_READ_DATA_AVAIL;
  164. if (intel_wait_for_register(dev_priv,
  165. MIPI_INTR_STAT(port),
  166. data_mask, data_mask,
  167. 50))
  168. DRM_ERROR("Timeout waiting for read data.\n");
  169. read_data(dev_priv, data_reg, msg->rx_buf, msg->rx_len);
  170. }
  171. /* XXX: fix for reads and writes */
  172. return 4 + packet.payload_length;
  173. }
  174. static int intel_dsi_host_attach(struct mipi_dsi_host *host,
  175. struct mipi_dsi_device *dsi)
  176. {
  177. return 0;
  178. }
  179. static int intel_dsi_host_detach(struct mipi_dsi_host *host,
  180. struct mipi_dsi_device *dsi)
  181. {
  182. return 0;
  183. }
  184. static const struct mipi_dsi_host_ops intel_dsi_host_ops = {
  185. .attach = intel_dsi_host_attach,
  186. .detach = intel_dsi_host_detach,
  187. .transfer = intel_dsi_host_transfer,
  188. };
  189. static struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
  190. enum port port)
  191. {
  192. struct intel_dsi_host *host;
  193. struct mipi_dsi_device *device;
  194. host = kzalloc(sizeof(*host), GFP_KERNEL);
  195. if (!host)
  196. return NULL;
  197. host->base.ops = &intel_dsi_host_ops;
  198. host->intel_dsi = intel_dsi;
  199. host->port = port;
  200. /*
  201. * We should call mipi_dsi_host_register(&host->base) here, but we don't
  202. * have a host->dev, and we don't have OF stuff either. So just use the
  203. * dsi framework as a library and hope for the best. Create the dsi
  204. * devices by ourselves here too. Need to be careful though, because we
  205. * don't initialize any of the driver model devices here.
  206. */
  207. device = kzalloc(sizeof(*device), GFP_KERNEL);
  208. if (!device) {
  209. kfree(host);
  210. return NULL;
  211. }
  212. device->host = &host->base;
  213. host->device = device;
  214. return host;
  215. }
  216. /*
  217. * send a video mode command
  218. *
  219. * XXX: commands with data in MIPI_DPI_DATA?
  220. */
  221. static int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs,
  222. enum port port)
  223. {
  224. struct drm_encoder *encoder = &intel_dsi->base.base;
  225. struct drm_device *dev = encoder->dev;
  226. struct drm_i915_private *dev_priv = to_i915(dev);
  227. u32 mask;
  228. /* XXX: pipe, hs */
  229. if (hs)
  230. cmd &= ~DPI_LP_MODE;
  231. else
  232. cmd |= DPI_LP_MODE;
  233. /* clear bit */
  234. I915_WRITE(MIPI_INTR_STAT(port), SPL_PKT_SENT_INTERRUPT);
  235. /* XXX: old code skips write if control unchanged */
  236. if (cmd == I915_READ(MIPI_DPI_CONTROL(port)))
  237. DRM_ERROR("Same special packet %02x twice in a row.\n", cmd);
  238. I915_WRITE(MIPI_DPI_CONTROL(port), cmd);
  239. mask = SPL_PKT_SENT_INTERRUPT;
  240. if (intel_wait_for_register(dev_priv,
  241. MIPI_INTR_STAT(port), mask, mask,
  242. 100))
  243. DRM_ERROR("Video mode command 0x%08x send failed.\n", cmd);
  244. return 0;
  245. }
  246. static void band_gap_reset(struct drm_i915_private *dev_priv)
  247. {
  248. mutex_lock(&dev_priv->sb_lock);
  249. vlv_flisdsi_write(dev_priv, 0x08, 0x0001);
  250. vlv_flisdsi_write(dev_priv, 0x0F, 0x0005);
  251. vlv_flisdsi_write(dev_priv, 0x0F, 0x0025);
  252. udelay(150);
  253. vlv_flisdsi_write(dev_priv, 0x0F, 0x0000);
  254. vlv_flisdsi_write(dev_priv, 0x08, 0x0000);
  255. mutex_unlock(&dev_priv->sb_lock);
  256. }
  257. static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
  258. {
  259. return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
  260. }
  261. static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
  262. {
  263. return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
  264. }
  265. static bool intel_dsi_compute_config(struct intel_encoder *encoder,
  266. struct intel_crtc_state *pipe_config)
  267. {
  268. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  269. struct intel_dsi *intel_dsi = container_of(encoder, struct intel_dsi,
  270. base);
  271. struct intel_connector *intel_connector = intel_dsi->attached_connector;
  272. struct intel_crtc *crtc = to_intel_crtc(pipe_config->base.crtc);
  273. const struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  274. struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
  275. int ret;
  276. DRM_DEBUG_KMS("\n");
  277. pipe_config->has_dsi_encoder = true;
  278. if (fixed_mode) {
  279. intel_fixed_panel_mode(fixed_mode, adjusted_mode);
  280. if (HAS_GMCH_DISPLAY(dev_priv))
  281. intel_gmch_panel_fitting(crtc, pipe_config,
  282. intel_connector->panel.fitting_mode);
  283. else
  284. intel_pch_panel_fitting(crtc, pipe_config,
  285. intel_connector->panel.fitting_mode);
  286. }
  287. /* DSI uses short packets for sync events, so clear mode flags for DSI */
  288. adjusted_mode->flags = 0;
  289. if (IS_BROXTON(dev_priv)) {
  290. /* Dual link goes to DSI transcoder A. */
  291. if (intel_dsi->ports == BIT(PORT_C))
  292. pipe_config->cpu_transcoder = TRANSCODER_DSI_C;
  293. else
  294. pipe_config->cpu_transcoder = TRANSCODER_DSI_A;
  295. }
  296. ret = intel_compute_dsi_pll(encoder, pipe_config);
  297. if (ret)
  298. return false;
  299. pipe_config->clock_set = true;
  300. return true;
  301. }
  302. static void bxt_dsi_device_ready(struct intel_encoder *encoder)
  303. {
  304. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  305. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  306. enum port port;
  307. u32 val;
  308. DRM_DEBUG_KMS("\n");
  309. /* Exit Low power state in 4 steps*/
  310. for_each_dsi_port(port, intel_dsi->ports) {
  311. /* 1. Enable MIPI PHY transparent latch */
  312. val = I915_READ(BXT_MIPI_PORT_CTRL(port));
  313. I915_WRITE(BXT_MIPI_PORT_CTRL(port), val | LP_OUTPUT_HOLD);
  314. usleep_range(2000, 2500);
  315. /* 2. Enter ULPS */
  316. val = I915_READ(MIPI_DEVICE_READY(port));
  317. val &= ~ULPS_STATE_MASK;
  318. val |= (ULPS_STATE_ENTER | DEVICE_READY);
  319. I915_WRITE(MIPI_DEVICE_READY(port), val);
  320. usleep_range(2, 3);
  321. /* 3. Exit ULPS */
  322. val = I915_READ(MIPI_DEVICE_READY(port));
  323. val &= ~ULPS_STATE_MASK;
  324. val |= (ULPS_STATE_EXIT | DEVICE_READY);
  325. I915_WRITE(MIPI_DEVICE_READY(port), val);
  326. usleep_range(1000, 1500);
  327. /* Clear ULPS and set device ready */
  328. val = I915_READ(MIPI_DEVICE_READY(port));
  329. val &= ~ULPS_STATE_MASK;
  330. val |= DEVICE_READY;
  331. I915_WRITE(MIPI_DEVICE_READY(port), val);
  332. }
  333. }
  334. static void vlv_dsi_device_ready(struct intel_encoder *encoder)
  335. {
  336. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  337. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  338. enum port port;
  339. u32 val;
  340. DRM_DEBUG_KMS("\n");
  341. mutex_lock(&dev_priv->sb_lock);
  342. /* program rcomp for compliance, reduce from 50 ohms to 45 ohms
  343. * needed everytime after power gate */
  344. vlv_flisdsi_write(dev_priv, 0x04, 0x0004);
  345. mutex_unlock(&dev_priv->sb_lock);
  346. /* bandgap reset is needed after everytime we do power gate */
  347. band_gap_reset(dev_priv);
  348. for_each_dsi_port(port, intel_dsi->ports) {
  349. I915_WRITE(MIPI_DEVICE_READY(port), ULPS_STATE_ENTER);
  350. usleep_range(2500, 3000);
  351. /* Enable MIPI PHY transparent latch
  352. * Common bit for both MIPI Port A & MIPI Port C
  353. * No similar bit in MIPI Port C reg
  354. */
  355. val = I915_READ(MIPI_PORT_CTRL(PORT_A));
  356. I915_WRITE(MIPI_PORT_CTRL(PORT_A), val | LP_OUTPUT_HOLD);
  357. usleep_range(1000, 1500);
  358. I915_WRITE(MIPI_DEVICE_READY(port), ULPS_STATE_EXIT);
  359. usleep_range(2500, 3000);
  360. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY);
  361. usleep_range(2500, 3000);
  362. }
  363. }
  364. static void intel_dsi_device_ready(struct intel_encoder *encoder)
  365. {
  366. struct drm_device *dev = encoder->base.dev;
  367. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))
  368. vlv_dsi_device_ready(encoder);
  369. else if (IS_BROXTON(dev))
  370. bxt_dsi_device_ready(encoder);
  371. }
  372. static void intel_dsi_port_enable(struct intel_encoder *encoder)
  373. {
  374. struct drm_device *dev = encoder->base.dev;
  375. struct drm_i915_private *dev_priv = to_i915(dev);
  376. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->base.crtc);
  377. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  378. enum port port;
  379. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK) {
  380. u32 temp;
  381. temp = I915_READ(VLV_CHICKEN_3);
  382. temp &= ~PIXEL_OVERLAP_CNT_MASK |
  383. intel_dsi->pixel_overlap <<
  384. PIXEL_OVERLAP_CNT_SHIFT;
  385. I915_WRITE(VLV_CHICKEN_3, temp);
  386. }
  387. for_each_dsi_port(port, intel_dsi->ports) {
  388. i915_reg_t port_ctrl = IS_BROXTON(dev) ?
  389. BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(port);
  390. u32 temp;
  391. temp = I915_READ(port_ctrl);
  392. temp &= ~LANE_CONFIGURATION_MASK;
  393. temp &= ~DUAL_LINK_MODE_MASK;
  394. if (intel_dsi->ports == (BIT(PORT_A) | BIT(PORT_C))) {
  395. temp |= (intel_dsi->dual_link - 1)
  396. << DUAL_LINK_MODE_SHIFT;
  397. temp |= intel_crtc->pipe ?
  398. LANE_CONFIGURATION_DUAL_LINK_B :
  399. LANE_CONFIGURATION_DUAL_LINK_A;
  400. }
  401. /* assert ip_tg_enable signal */
  402. I915_WRITE(port_ctrl, temp | DPI_ENABLE);
  403. POSTING_READ(port_ctrl);
  404. }
  405. }
  406. static void intel_dsi_port_disable(struct intel_encoder *encoder)
  407. {
  408. struct drm_device *dev = encoder->base.dev;
  409. struct drm_i915_private *dev_priv = to_i915(dev);
  410. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  411. enum port port;
  412. for_each_dsi_port(port, intel_dsi->ports) {
  413. i915_reg_t port_ctrl = IS_BROXTON(dev) ?
  414. BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(port);
  415. u32 temp;
  416. /* de-assert ip_tg_enable signal */
  417. temp = I915_READ(port_ctrl);
  418. I915_WRITE(port_ctrl, temp & ~DPI_ENABLE);
  419. POSTING_READ(port_ctrl);
  420. }
  421. }
  422. static void intel_dsi_enable(struct intel_encoder *encoder)
  423. {
  424. struct drm_device *dev = encoder->base.dev;
  425. struct drm_i915_private *dev_priv = to_i915(dev);
  426. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  427. enum port port;
  428. DRM_DEBUG_KMS("\n");
  429. if (is_cmd_mode(intel_dsi)) {
  430. for_each_dsi_port(port, intel_dsi->ports)
  431. I915_WRITE(MIPI_MAX_RETURN_PKT_SIZE(port), 8 * 4);
  432. } else {
  433. msleep(20); /* XXX */
  434. for_each_dsi_port(port, intel_dsi->ports)
  435. dpi_send_cmd(intel_dsi, TURN_ON, false, port);
  436. msleep(100);
  437. drm_panel_enable(intel_dsi->panel);
  438. for_each_dsi_port(port, intel_dsi->ports)
  439. wait_for_dsi_fifo_empty(intel_dsi, port);
  440. intel_dsi_port_enable(encoder);
  441. }
  442. intel_panel_enable_backlight(intel_dsi->attached_connector);
  443. }
  444. static void intel_dsi_prepare(struct intel_encoder *intel_encoder);
  445. static void intel_dsi_pre_enable(struct intel_encoder *encoder)
  446. {
  447. struct drm_device *dev = encoder->base.dev;
  448. struct drm_i915_private *dev_priv = to_i915(dev);
  449. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  450. struct intel_crtc *crtc = to_intel_crtc(encoder->base.crtc);
  451. enum port port;
  452. DRM_DEBUG_KMS("\n");
  453. /*
  454. * The BIOS may leave the PLL in a wonky state where it doesn't
  455. * lock. It needs to be fully powered down to fix it.
  456. */
  457. intel_disable_dsi_pll(encoder);
  458. intel_enable_dsi_pll(encoder, crtc->config);
  459. intel_dsi_prepare(encoder);
  460. /* Panel Enable over CRC PMIC */
  461. if (intel_dsi->gpio_panel)
  462. gpiod_set_value_cansleep(intel_dsi->gpio_panel, 1);
  463. msleep(intel_dsi->panel_on_delay);
  464. if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
  465. u32 val;
  466. /* Disable DPOunit clock gating, can stall pipe */
  467. val = I915_READ(DSPCLK_GATE_D);
  468. val |= DPOUNIT_CLOCK_GATE_DISABLE;
  469. I915_WRITE(DSPCLK_GATE_D, val);
  470. }
  471. /* put device in ready state */
  472. intel_dsi_device_ready(encoder);
  473. drm_panel_prepare(intel_dsi->panel);
  474. for_each_dsi_port(port, intel_dsi->ports)
  475. wait_for_dsi_fifo_empty(intel_dsi, port);
  476. /* Enable port in pre-enable phase itself because as per hw team
  477. * recommendation, port should be enabled befor plane & pipe */
  478. intel_dsi_enable(encoder);
  479. }
  480. static void intel_dsi_enable_nop(struct intel_encoder *encoder)
  481. {
  482. DRM_DEBUG_KMS("\n");
  483. /* for DSI port enable has to be done before pipe
  484. * and plane enable, so port enable is done in
  485. * pre_enable phase itself unlike other encoders
  486. */
  487. }
  488. static void intel_dsi_pre_disable(struct intel_encoder *encoder)
  489. {
  490. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  491. enum port port;
  492. DRM_DEBUG_KMS("\n");
  493. intel_panel_disable_backlight(intel_dsi->attached_connector);
  494. if (is_vid_mode(intel_dsi)) {
  495. /* Send Shutdown command to the panel in LP mode */
  496. for_each_dsi_port(port, intel_dsi->ports)
  497. dpi_send_cmd(intel_dsi, SHUTDOWN, false, port);
  498. msleep(10);
  499. }
  500. }
  501. static void intel_dsi_disable(struct intel_encoder *encoder)
  502. {
  503. struct drm_device *dev = encoder->base.dev;
  504. struct drm_i915_private *dev_priv = to_i915(dev);
  505. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  506. enum port port;
  507. u32 temp;
  508. DRM_DEBUG_KMS("\n");
  509. if (is_vid_mode(intel_dsi)) {
  510. for_each_dsi_port(port, intel_dsi->ports)
  511. wait_for_dsi_fifo_empty(intel_dsi, port);
  512. intel_dsi_port_disable(encoder);
  513. msleep(2);
  514. }
  515. for_each_dsi_port(port, intel_dsi->ports) {
  516. /* Panel commands can be sent when clock is in LP11 */
  517. I915_WRITE(MIPI_DEVICE_READY(port), 0x0);
  518. intel_dsi_reset_clocks(encoder, port);
  519. I915_WRITE(MIPI_EOT_DISABLE(port), CLOCKSTOP);
  520. temp = I915_READ(MIPI_DSI_FUNC_PRG(port));
  521. temp &= ~VID_MODE_FORMAT_MASK;
  522. I915_WRITE(MIPI_DSI_FUNC_PRG(port), temp);
  523. I915_WRITE(MIPI_DEVICE_READY(port), 0x1);
  524. }
  525. /* if disable packets are sent before sending shutdown packet then in
  526. * some next enable sequence send turn on packet error is observed */
  527. drm_panel_disable(intel_dsi->panel);
  528. for_each_dsi_port(port, intel_dsi->ports)
  529. wait_for_dsi_fifo_empty(intel_dsi, port);
  530. }
  531. static void intel_dsi_clear_device_ready(struct intel_encoder *encoder)
  532. {
  533. struct drm_device *dev = encoder->base.dev;
  534. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  535. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  536. enum port port;
  537. DRM_DEBUG_KMS("\n");
  538. for_each_dsi_port(port, intel_dsi->ports) {
  539. /* Common bit for both MIPI Port A & MIPI Port C on VLV/CHV */
  540. i915_reg_t port_ctrl = IS_BROXTON(dev) ?
  541. BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(PORT_A);
  542. u32 val;
  543. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  544. ULPS_STATE_ENTER);
  545. usleep_range(2000, 2500);
  546. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  547. ULPS_STATE_EXIT);
  548. usleep_range(2000, 2500);
  549. I915_WRITE(MIPI_DEVICE_READY(port), DEVICE_READY |
  550. ULPS_STATE_ENTER);
  551. usleep_range(2000, 2500);
  552. /* Wait till Clock lanes are in LP-00 state for MIPI Port A
  553. * only. MIPI Port C has no similar bit for checking
  554. */
  555. if (intel_wait_for_register(dev_priv,
  556. port_ctrl, AFE_LATCHOUT, 0,
  557. 30))
  558. DRM_ERROR("DSI LP not going Low\n");
  559. /* Disable MIPI PHY transparent latch */
  560. val = I915_READ(port_ctrl);
  561. I915_WRITE(port_ctrl, val & ~LP_OUTPUT_HOLD);
  562. usleep_range(1000, 1500);
  563. I915_WRITE(MIPI_DEVICE_READY(port), 0x00);
  564. usleep_range(2000, 2500);
  565. }
  566. intel_disable_dsi_pll(encoder);
  567. }
  568. static void intel_dsi_post_disable(struct intel_encoder *encoder)
  569. {
  570. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  571. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  572. DRM_DEBUG_KMS("\n");
  573. intel_dsi_disable(encoder);
  574. intel_dsi_clear_device_ready(encoder);
  575. if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
  576. u32 val;
  577. val = I915_READ(DSPCLK_GATE_D);
  578. val &= ~DPOUNIT_CLOCK_GATE_DISABLE;
  579. I915_WRITE(DSPCLK_GATE_D, val);
  580. }
  581. drm_panel_unprepare(intel_dsi->panel);
  582. msleep(intel_dsi->panel_off_delay);
  583. /* Panel Disable over CRC PMIC */
  584. if (intel_dsi->gpio_panel)
  585. gpiod_set_value_cansleep(intel_dsi->gpio_panel, 0);
  586. /*
  587. * FIXME As we do with eDP, just make a note of the time here
  588. * and perform the wait before the next panel power on.
  589. */
  590. msleep(intel_dsi->panel_pwr_cycle_delay);
  591. }
  592. static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
  593. enum pipe *pipe)
  594. {
  595. struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
  596. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  597. struct drm_device *dev = encoder->base.dev;
  598. enum intel_display_power_domain power_domain;
  599. enum port port;
  600. bool active = false;
  601. DRM_DEBUG_KMS("\n");
  602. power_domain = intel_display_port_power_domain(encoder);
  603. if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
  604. return false;
  605. /*
  606. * On Broxton the PLL needs to be enabled with a valid divider
  607. * configuration, otherwise accessing DSI registers will hang the
  608. * machine. See BSpec North Display Engine registers/MIPI[BXT].
  609. */
  610. if (IS_BROXTON(dev_priv) && !intel_dsi_pll_is_enabled(dev_priv))
  611. goto out_put_power;
  612. /* XXX: this only works for one DSI output */
  613. for_each_dsi_port(port, intel_dsi->ports) {
  614. i915_reg_t ctrl_reg = IS_BROXTON(dev) ?
  615. BXT_MIPI_PORT_CTRL(port) : MIPI_PORT_CTRL(port);
  616. bool enabled = I915_READ(ctrl_reg) & DPI_ENABLE;
  617. /*
  618. * Due to some hardware limitations on VLV/CHV, the DPI enable
  619. * bit in port C control register does not get set. As a
  620. * workaround, check pipe B conf instead.
  621. */
  622. if ((IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) && port == PORT_C)
  623. enabled = I915_READ(PIPECONF(PIPE_B)) & PIPECONF_ENABLE;
  624. /* Try command mode if video mode not enabled */
  625. if (!enabled) {
  626. u32 tmp = I915_READ(MIPI_DSI_FUNC_PRG(port));
  627. enabled = tmp & CMD_MODE_DATA_WIDTH_MASK;
  628. }
  629. if (!enabled)
  630. continue;
  631. if (!(I915_READ(MIPI_DEVICE_READY(port)) & DEVICE_READY))
  632. continue;
  633. if (IS_BROXTON(dev_priv)) {
  634. u32 tmp = I915_READ(MIPI_CTRL(port));
  635. tmp &= BXT_PIPE_SELECT_MASK;
  636. tmp >>= BXT_PIPE_SELECT_SHIFT;
  637. if (WARN_ON(tmp > PIPE_C))
  638. continue;
  639. *pipe = tmp;
  640. } else {
  641. *pipe = port == PORT_A ? PIPE_A : PIPE_B;
  642. }
  643. active = true;
  644. break;
  645. }
  646. out_put_power:
  647. intel_display_power_put(dev_priv, power_domain);
  648. return active;
  649. }
  650. static void bxt_dsi_get_pipe_config(struct intel_encoder *encoder,
  651. struct intel_crtc_state *pipe_config)
  652. {
  653. struct drm_device *dev = encoder->base.dev;
  654. struct drm_i915_private *dev_priv = to_i915(dev);
  655. struct drm_display_mode *adjusted_mode =
  656. &pipe_config->base.adjusted_mode;
  657. struct drm_display_mode *adjusted_mode_sw;
  658. struct intel_crtc *intel_crtc;
  659. struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
  660. unsigned int lane_count = intel_dsi->lane_count;
  661. unsigned int bpp, fmt;
  662. enum port port;
  663. u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp;
  664. u16 hfp_sw, hsync_sw, hbp_sw;
  665. u16 crtc_htotal_sw, crtc_hsync_start_sw, crtc_hsync_end_sw,
  666. crtc_hblank_start_sw, crtc_hblank_end_sw;
  667. intel_crtc = to_intel_crtc(encoder->base.crtc);
  668. adjusted_mode_sw = &intel_crtc->config->base.adjusted_mode;
  669. /*
  670. * Atleast one port is active as encoder->get_config called only if
  671. * encoder->get_hw_state() returns true.
  672. */
  673. for_each_dsi_port(port, intel_dsi->ports) {
  674. if (I915_READ(BXT_MIPI_PORT_CTRL(port)) & DPI_ENABLE)
  675. break;
  676. }
  677. fmt = I915_READ(MIPI_DSI_FUNC_PRG(port)) & VID_MODE_FORMAT_MASK;
  678. pipe_config->pipe_bpp =
  679. mipi_dsi_pixel_format_to_bpp(
  680. pixel_format_from_register_bits(fmt));
  681. bpp = pipe_config->pipe_bpp;
  682. /* In terms of pixels */
  683. adjusted_mode->crtc_hdisplay =
  684. I915_READ(BXT_MIPI_TRANS_HACTIVE(port));
  685. adjusted_mode->crtc_vdisplay =
  686. I915_READ(BXT_MIPI_TRANS_VACTIVE(port));
  687. adjusted_mode->crtc_vtotal =
  688. I915_READ(BXT_MIPI_TRANS_VTOTAL(port));
  689. hactive = adjusted_mode->crtc_hdisplay;
  690. hfp = I915_READ(MIPI_HFP_COUNT(port));
  691. /*
  692. * Meaningful for video mode non-burst sync pulse mode only,
  693. * can be zero for non-burst sync events and burst modes
  694. */
  695. hsync = I915_READ(MIPI_HSYNC_PADDING_COUNT(port));
  696. hbp = I915_READ(MIPI_HBP_COUNT(port));
  697. /* harizontal values are in terms of high speed byte clock */
  698. hfp = pixels_from_txbyteclkhs(hfp, bpp, lane_count,
  699. intel_dsi->burst_mode_ratio);
  700. hsync = pixels_from_txbyteclkhs(hsync, bpp, lane_count,
  701. intel_dsi->burst_mode_ratio);
  702. hbp = pixels_from_txbyteclkhs(hbp, bpp, lane_count,
  703. intel_dsi->burst_mode_ratio);
  704. if (intel_dsi->dual_link) {
  705. hfp *= 2;
  706. hsync *= 2;
  707. hbp *= 2;
  708. }
  709. /* vertical values are in terms of lines */
  710. vfp = I915_READ(MIPI_VFP_COUNT(port));
  711. vsync = I915_READ(MIPI_VSYNC_PADDING_COUNT(port));
  712. vbp = I915_READ(MIPI_VBP_COUNT(port));
  713. adjusted_mode->crtc_htotal = hactive + hfp + hsync + hbp;
  714. adjusted_mode->crtc_hsync_start = hfp + adjusted_mode->crtc_hdisplay;
  715. adjusted_mode->crtc_hsync_end = hsync + adjusted_mode->crtc_hsync_start;
  716. adjusted_mode->crtc_hblank_start = adjusted_mode->crtc_hdisplay;
  717. adjusted_mode->crtc_hblank_end = adjusted_mode->crtc_htotal;
  718. adjusted_mode->crtc_vsync_start = vfp + adjusted_mode->crtc_vdisplay;
  719. adjusted_mode->crtc_vsync_end = vsync + adjusted_mode->crtc_vsync_start;
  720. adjusted_mode->crtc_vblank_start = adjusted_mode->crtc_vdisplay;
  721. adjusted_mode->crtc_vblank_end = adjusted_mode->crtc_vtotal;
  722. /*
  723. * In BXT DSI there is no regs programmed with few horizontal timings
  724. * in Pixels but txbyteclkhs.. So retrieval process adds some
  725. * ROUND_UP ERRORS in the process of PIXELS<==>txbyteclkhs.
  726. * Actually here for the given adjusted_mode, we are calculating the
  727. * value programmed to the port and then back to the horizontal timing
  728. * param in pixels. This is the expected value, including roundup errors
  729. * And if that is same as retrieved value from port, then
  730. * (HW state) adjusted_mode's horizontal timings are corrected to
  731. * match with SW state to nullify the errors.
  732. */
  733. /* Calculating the value programmed to the Port register */
  734. hfp_sw = adjusted_mode_sw->crtc_hsync_start -
  735. adjusted_mode_sw->crtc_hdisplay;
  736. hsync_sw = adjusted_mode_sw->crtc_hsync_end -
  737. adjusted_mode_sw->crtc_hsync_start;
  738. hbp_sw = adjusted_mode_sw->crtc_htotal -
  739. adjusted_mode_sw->crtc_hsync_end;
  740. if (intel_dsi->dual_link) {
  741. hfp_sw /= 2;
  742. hsync_sw /= 2;
  743. hbp_sw /= 2;
  744. }
  745. hfp_sw = txbyteclkhs(hfp_sw, bpp, lane_count,
  746. intel_dsi->burst_mode_ratio);
  747. hsync_sw = txbyteclkhs(hsync_sw, bpp, lane_count,
  748. intel_dsi->burst_mode_ratio);
  749. hbp_sw = txbyteclkhs(hbp_sw, bpp, lane_count,
  750. intel_dsi->burst_mode_ratio);
  751. /* Reverse calculating the adjusted mode parameters from port reg vals*/
  752. hfp_sw = pixels_from_txbyteclkhs(hfp_sw, bpp, lane_count,
  753. intel_dsi->burst_mode_ratio);
  754. hsync_sw = pixels_from_txbyteclkhs(hsync_sw, bpp, lane_count,
  755. intel_dsi->burst_mode_ratio);
  756. hbp_sw = pixels_from_txbyteclkhs(hbp_sw, bpp, lane_count,
  757. intel_dsi->burst_mode_ratio);
  758. if (intel_dsi->dual_link) {
  759. hfp_sw *= 2;
  760. hsync_sw *= 2;
  761. hbp_sw *= 2;
  762. }
  763. crtc_htotal_sw = adjusted_mode_sw->crtc_hdisplay + hfp_sw +
  764. hsync_sw + hbp_sw;
  765. crtc_hsync_start_sw = hfp_sw + adjusted_mode_sw->crtc_hdisplay;
  766. crtc_hsync_end_sw = hsync_sw + crtc_hsync_start_sw;
  767. crtc_hblank_start_sw = adjusted_mode_sw->crtc_hdisplay;
  768. crtc_hblank_end_sw = crtc_htotal_sw;
  769. if (adjusted_mode->crtc_htotal == crtc_htotal_sw)
  770. adjusted_mode->crtc_htotal = adjusted_mode_sw->crtc_htotal;
  771. if (adjusted_mode->crtc_hsync_start == crtc_hsync_start_sw)
  772. adjusted_mode->crtc_hsync_start =
  773. adjusted_mode_sw->crtc_hsync_start;
  774. if (adjusted_mode->crtc_hsync_end == crtc_hsync_end_sw)
  775. adjusted_mode->crtc_hsync_end =
  776. adjusted_mode_sw->crtc_hsync_end;
  777. if (adjusted_mode->crtc_hblank_start == crtc_hblank_start_sw)
  778. adjusted_mode->crtc_hblank_start =
  779. adjusted_mode_sw->crtc_hblank_start;
  780. if (adjusted_mode->crtc_hblank_end == crtc_hblank_end_sw)
  781. adjusted_mode->crtc_hblank_end =
  782. adjusted_mode_sw->crtc_hblank_end;
  783. }
  784. static void intel_dsi_get_config(struct intel_encoder *encoder,
  785. struct intel_crtc_state *pipe_config)
  786. {
  787. struct drm_device *dev = encoder->base.dev;
  788. u32 pclk;
  789. DRM_DEBUG_KMS("\n");
  790. pipe_config->has_dsi_encoder = true;
  791. if (IS_BROXTON(dev))
  792. bxt_dsi_get_pipe_config(encoder, pipe_config);
  793. pclk = intel_dsi_get_pclk(encoder, pipe_config->pipe_bpp,
  794. pipe_config);
  795. if (!pclk)
  796. return;
  797. pipe_config->base.adjusted_mode.crtc_clock = pclk;
  798. pipe_config->port_clock = pclk;
  799. }
  800. static enum drm_mode_status
  801. intel_dsi_mode_valid(struct drm_connector *connector,
  802. struct drm_display_mode *mode)
  803. {
  804. struct intel_connector *intel_connector = to_intel_connector(connector);
  805. const struct drm_display_mode *fixed_mode = intel_connector->panel.fixed_mode;
  806. int max_dotclk = to_i915(connector->dev)->max_dotclk_freq;
  807. DRM_DEBUG_KMS("\n");
  808. if (mode->flags & DRM_MODE_FLAG_DBLSCAN) {
  809. DRM_DEBUG_KMS("MODE_NO_DBLESCAN\n");
  810. return MODE_NO_DBLESCAN;
  811. }
  812. if (fixed_mode) {
  813. if (mode->hdisplay > fixed_mode->hdisplay)
  814. return MODE_PANEL;
  815. if (mode->vdisplay > fixed_mode->vdisplay)
  816. return MODE_PANEL;
  817. if (fixed_mode->clock > max_dotclk)
  818. return MODE_CLOCK_HIGH;
  819. }
  820. return MODE_OK;
  821. }
  822. /* return txclkesc cycles in terms of divider and duration in us */
  823. static u16 txclkesc(u32 divider, unsigned int us)
  824. {
  825. switch (divider) {
  826. case ESCAPE_CLOCK_DIVIDER_1:
  827. default:
  828. return 20 * us;
  829. case ESCAPE_CLOCK_DIVIDER_2:
  830. return 10 * us;
  831. case ESCAPE_CLOCK_DIVIDER_4:
  832. return 5 * us;
  833. }
  834. }
  835. static void set_dsi_timings(struct drm_encoder *encoder,
  836. const struct drm_display_mode *adjusted_mode)
  837. {
  838. struct drm_device *dev = encoder->dev;
  839. struct drm_i915_private *dev_priv = to_i915(dev);
  840. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  841. enum port port;
  842. unsigned int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
  843. unsigned int lane_count = intel_dsi->lane_count;
  844. u16 hactive, hfp, hsync, hbp, vfp, vsync, vbp;
  845. hactive = adjusted_mode->crtc_hdisplay;
  846. hfp = adjusted_mode->crtc_hsync_start - adjusted_mode->crtc_hdisplay;
  847. hsync = adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start;
  848. hbp = adjusted_mode->crtc_htotal - adjusted_mode->crtc_hsync_end;
  849. if (intel_dsi->dual_link) {
  850. hactive /= 2;
  851. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
  852. hactive += intel_dsi->pixel_overlap;
  853. hfp /= 2;
  854. hsync /= 2;
  855. hbp /= 2;
  856. }
  857. vfp = adjusted_mode->crtc_vsync_start - adjusted_mode->crtc_vdisplay;
  858. vsync = adjusted_mode->crtc_vsync_end - adjusted_mode->crtc_vsync_start;
  859. vbp = adjusted_mode->crtc_vtotal - adjusted_mode->crtc_vsync_end;
  860. /* horizontal values are in terms of high speed byte clock */
  861. hactive = txbyteclkhs(hactive, bpp, lane_count,
  862. intel_dsi->burst_mode_ratio);
  863. hfp = txbyteclkhs(hfp, bpp, lane_count, intel_dsi->burst_mode_ratio);
  864. hsync = txbyteclkhs(hsync, bpp, lane_count,
  865. intel_dsi->burst_mode_ratio);
  866. hbp = txbyteclkhs(hbp, bpp, lane_count, intel_dsi->burst_mode_ratio);
  867. for_each_dsi_port(port, intel_dsi->ports) {
  868. if (IS_BROXTON(dev)) {
  869. /*
  870. * Program hdisplay and vdisplay on MIPI transcoder.
  871. * This is different from calculated hactive and
  872. * vactive, as they are calculated per channel basis,
  873. * whereas these values should be based on resolution.
  874. */
  875. I915_WRITE(BXT_MIPI_TRANS_HACTIVE(port),
  876. adjusted_mode->crtc_hdisplay);
  877. I915_WRITE(BXT_MIPI_TRANS_VACTIVE(port),
  878. adjusted_mode->crtc_vdisplay);
  879. I915_WRITE(BXT_MIPI_TRANS_VTOTAL(port),
  880. adjusted_mode->crtc_vtotal);
  881. }
  882. I915_WRITE(MIPI_HACTIVE_AREA_COUNT(port), hactive);
  883. I915_WRITE(MIPI_HFP_COUNT(port), hfp);
  884. /* meaningful for video mode non-burst sync pulse mode only,
  885. * can be zero for non-burst sync events and burst modes */
  886. I915_WRITE(MIPI_HSYNC_PADDING_COUNT(port), hsync);
  887. I915_WRITE(MIPI_HBP_COUNT(port), hbp);
  888. /* vertical values are in terms of lines */
  889. I915_WRITE(MIPI_VFP_COUNT(port), vfp);
  890. I915_WRITE(MIPI_VSYNC_PADDING_COUNT(port), vsync);
  891. I915_WRITE(MIPI_VBP_COUNT(port), vbp);
  892. }
  893. }
  894. static u32 pixel_format_to_reg(enum mipi_dsi_pixel_format fmt)
  895. {
  896. switch (fmt) {
  897. case MIPI_DSI_FMT_RGB888:
  898. return VID_MODE_FORMAT_RGB888;
  899. case MIPI_DSI_FMT_RGB666:
  900. return VID_MODE_FORMAT_RGB666;
  901. case MIPI_DSI_FMT_RGB666_PACKED:
  902. return VID_MODE_FORMAT_RGB666_PACKED;
  903. case MIPI_DSI_FMT_RGB565:
  904. return VID_MODE_FORMAT_RGB565;
  905. default:
  906. MISSING_CASE(fmt);
  907. return VID_MODE_FORMAT_RGB666;
  908. }
  909. }
  910. static void intel_dsi_prepare(struct intel_encoder *intel_encoder)
  911. {
  912. struct drm_encoder *encoder = &intel_encoder->base;
  913. struct drm_device *dev = encoder->dev;
  914. struct drm_i915_private *dev_priv = to_i915(dev);
  915. struct intel_crtc *intel_crtc = to_intel_crtc(encoder->crtc);
  916. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  917. const struct drm_display_mode *adjusted_mode = &intel_crtc->config->base.adjusted_mode;
  918. enum port port;
  919. unsigned int bpp = mipi_dsi_pixel_format_to_bpp(intel_dsi->pixel_format);
  920. u32 val, tmp;
  921. u16 mode_hdisplay;
  922. DRM_DEBUG_KMS("pipe %c\n", pipe_name(intel_crtc->pipe));
  923. mode_hdisplay = adjusted_mode->crtc_hdisplay;
  924. if (intel_dsi->dual_link) {
  925. mode_hdisplay /= 2;
  926. if (intel_dsi->dual_link == DSI_DUAL_LINK_FRONT_BACK)
  927. mode_hdisplay += intel_dsi->pixel_overlap;
  928. }
  929. for_each_dsi_port(port, intel_dsi->ports) {
  930. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
  931. /*
  932. * escape clock divider, 20MHz, shared for A and C.
  933. * device ready must be off when doing this! txclkesc?
  934. */
  935. tmp = I915_READ(MIPI_CTRL(PORT_A));
  936. tmp &= ~ESCAPE_CLOCK_DIVIDER_MASK;
  937. I915_WRITE(MIPI_CTRL(PORT_A), tmp |
  938. ESCAPE_CLOCK_DIVIDER_1);
  939. /* read request priority is per pipe */
  940. tmp = I915_READ(MIPI_CTRL(port));
  941. tmp &= ~READ_REQUEST_PRIORITY_MASK;
  942. I915_WRITE(MIPI_CTRL(port), tmp |
  943. READ_REQUEST_PRIORITY_HIGH);
  944. } else if (IS_BROXTON(dev)) {
  945. enum pipe pipe = intel_crtc->pipe;
  946. tmp = I915_READ(MIPI_CTRL(port));
  947. tmp &= ~BXT_PIPE_SELECT_MASK;
  948. tmp |= BXT_PIPE_SELECT(pipe);
  949. I915_WRITE(MIPI_CTRL(port), tmp);
  950. }
  951. /* XXX: why here, why like this? handling in irq handler?! */
  952. I915_WRITE(MIPI_INTR_STAT(port), 0xffffffff);
  953. I915_WRITE(MIPI_INTR_EN(port), 0xffffffff);
  954. I915_WRITE(MIPI_DPHY_PARAM(port), intel_dsi->dphy_reg);
  955. I915_WRITE(MIPI_DPI_RESOLUTION(port),
  956. adjusted_mode->crtc_vdisplay << VERTICAL_ADDRESS_SHIFT |
  957. mode_hdisplay << HORIZONTAL_ADDRESS_SHIFT);
  958. }
  959. set_dsi_timings(encoder, adjusted_mode);
  960. val = intel_dsi->lane_count << DATA_LANES_PRG_REG_SHIFT;
  961. if (is_cmd_mode(intel_dsi)) {
  962. val |= intel_dsi->channel << CMD_MODE_CHANNEL_NUMBER_SHIFT;
  963. val |= CMD_MODE_DATA_WIDTH_8_BIT; /* XXX */
  964. } else {
  965. val |= intel_dsi->channel << VID_MODE_CHANNEL_NUMBER_SHIFT;
  966. val |= pixel_format_to_reg(intel_dsi->pixel_format);
  967. }
  968. tmp = 0;
  969. if (intel_dsi->eotp_pkt == 0)
  970. tmp |= EOT_DISABLE;
  971. if (intel_dsi->clock_stop)
  972. tmp |= CLOCKSTOP;
  973. if (IS_BROXTON(dev_priv)) {
  974. tmp |= BXT_DPHY_DEFEATURE_EN;
  975. if (!is_cmd_mode(intel_dsi))
  976. tmp |= BXT_DEFEATURE_DPI_FIFO_CTR;
  977. }
  978. for_each_dsi_port(port, intel_dsi->ports) {
  979. I915_WRITE(MIPI_DSI_FUNC_PRG(port), val);
  980. /* timeouts for recovery. one frame IIUC. if counter expires,
  981. * EOT and stop state. */
  982. /*
  983. * In burst mode, value greater than one DPI line Time in byte
  984. * clock (txbyteclkhs) To timeout this timer 1+ of the above
  985. * said value is recommended.
  986. *
  987. * In non-burst mode, Value greater than one DPI frame time in
  988. * byte clock(txbyteclkhs) To timeout this timer 1+ of the above
  989. * said value is recommended.
  990. *
  991. * In DBI only mode, value greater than one DBI frame time in
  992. * byte clock(txbyteclkhs) To timeout this timer 1+ of the above
  993. * said value is recommended.
  994. */
  995. if (is_vid_mode(intel_dsi) &&
  996. intel_dsi->video_mode_format == VIDEO_MODE_BURST) {
  997. I915_WRITE(MIPI_HS_TX_TIMEOUT(port),
  998. txbyteclkhs(adjusted_mode->crtc_htotal, bpp,
  999. intel_dsi->lane_count,
  1000. intel_dsi->burst_mode_ratio) + 1);
  1001. } else {
  1002. I915_WRITE(MIPI_HS_TX_TIMEOUT(port),
  1003. txbyteclkhs(adjusted_mode->crtc_vtotal *
  1004. adjusted_mode->crtc_htotal,
  1005. bpp, intel_dsi->lane_count,
  1006. intel_dsi->burst_mode_ratio) + 1);
  1007. }
  1008. I915_WRITE(MIPI_LP_RX_TIMEOUT(port), intel_dsi->lp_rx_timeout);
  1009. I915_WRITE(MIPI_TURN_AROUND_TIMEOUT(port),
  1010. intel_dsi->turn_arnd_val);
  1011. I915_WRITE(MIPI_DEVICE_RESET_TIMER(port),
  1012. intel_dsi->rst_timer_val);
  1013. /* dphy stuff */
  1014. /* in terms of low power clock */
  1015. I915_WRITE(MIPI_INIT_COUNT(port),
  1016. txclkesc(intel_dsi->escape_clk_div, 100));
  1017. if (IS_BROXTON(dev) && (!intel_dsi->dual_link)) {
  1018. /*
  1019. * BXT spec says write MIPI_INIT_COUNT for
  1020. * both the ports, even if only one is
  1021. * getting used. So write the other port
  1022. * if not in dual link mode.
  1023. */
  1024. I915_WRITE(MIPI_INIT_COUNT(port ==
  1025. PORT_A ? PORT_C : PORT_A),
  1026. intel_dsi->init_count);
  1027. }
  1028. /* recovery disables */
  1029. I915_WRITE(MIPI_EOT_DISABLE(port), tmp);
  1030. /* in terms of low power clock */
  1031. I915_WRITE(MIPI_INIT_COUNT(port), intel_dsi->init_count);
  1032. /* in terms of txbyteclkhs. actual high to low switch +
  1033. * MIPI_STOP_STATE_STALL * MIPI_LP_BYTECLK.
  1034. *
  1035. * XXX: write MIPI_STOP_STATE_STALL?
  1036. */
  1037. I915_WRITE(MIPI_HIGH_LOW_SWITCH_COUNT(port),
  1038. intel_dsi->hs_to_lp_count);
  1039. /* XXX: low power clock equivalence in terms of byte clock.
  1040. * the number of byte clocks occupied in one low power clock.
  1041. * based on txbyteclkhs and txclkesc.
  1042. * txclkesc time / txbyteclk time * (105 + MIPI_STOP_STATE_STALL
  1043. * ) / 105.???
  1044. */
  1045. I915_WRITE(MIPI_LP_BYTECLK(port), intel_dsi->lp_byte_clk);
  1046. /* the bw essential for transmitting 16 long packets containing
  1047. * 252 bytes meant for dcs write memory command is programmed in
  1048. * this register in terms of byte clocks. based on dsi transfer
  1049. * rate and the number of lanes configured the time taken to
  1050. * transmit 16 long packets in a dsi stream varies. */
  1051. I915_WRITE(MIPI_DBI_BW_CTRL(port), intel_dsi->bw_timer);
  1052. I915_WRITE(MIPI_CLK_LANE_SWITCH_TIME_CNT(port),
  1053. intel_dsi->clk_lp_to_hs_count << LP_HS_SSW_CNT_SHIFT |
  1054. intel_dsi->clk_hs_to_lp_count << HS_LP_PWR_SW_CNT_SHIFT);
  1055. if (is_vid_mode(intel_dsi))
  1056. /* Some panels might have resolution which is not a
  1057. * multiple of 64 like 1366 x 768. Enable RANDOM
  1058. * resolution support for such panels by default */
  1059. I915_WRITE(MIPI_VIDEO_MODE_FORMAT(port),
  1060. intel_dsi->video_frmt_cfg_bits |
  1061. intel_dsi->video_mode_format |
  1062. IP_TG_CONFIG |
  1063. RANDOM_DPI_DISPLAY_RESOLUTION);
  1064. }
  1065. }
  1066. static enum drm_connector_status
  1067. intel_dsi_detect(struct drm_connector *connector, bool force)
  1068. {
  1069. return connector_status_connected;
  1070. }
  1071. static int intel_dsi_get_modes(struct drm_connector *connector)
  1072. {
  1073. struct intel_connector *intel_connector = to_intel_connector(connector);
  1074. struct drm_display_mode *mode;
  1075. DRM_DEBUG_KMS("\n");
  1076. if (!intel_connector->panel.fixed_mode) {
  1077. DRM_DEBUG_KMS("no fixed mode\n");
  1078. return 0;
  1079. }
  1080. mode = drm_mode_duplicate(connector->dev,
  1081. intel_connector->panel.fixed_mode);
  1082. if (!mode) {
  1083. DRM_DEBUG_KMS("drm_mode_duplicate failed\n");
  1084. return 0;
  1085. }
  1086. drm_mode_probed_add(connector, mode);
  1087. return 1;
  1088. }
  1089. static int intel_dsi_set_property(struct drm_connector *connector,
  1090. struct drm_property *property,
  1091. uint64_t val)
  1092. {
  1093. struct drm_device *dev = connector->dev;
  1094. struct intel_connector *intel_connector = to_intel_connector(connector);
  1095. struct drm_crtc *crtc;
  1096. int ret;
  1097. ret = drm_object_property_set_value(&connector->base, property, val);
  1098. if (ret)
  1099. return ret;
  1100. if (property == dev->mode_config.scaling_mode_property) {
  1101. if (val == DRM_MODE_SCALE_NONE) {
  1102. DRM_DEBUG_KMS("no scaling not supported\n");
  1103. return -EINVAL;
  1104. }
  1105. if (HAS_GMCH_DISPLAY(dev) &&
  1106. val == DRM_MODE_SCALE_CENTER) {
  1107. DRM_DEBUG_KMS("centering not supported\n");
  1108. return -EINVAL;
  1109. }
  1110. if (intel_connector->panel.fitting_mode == val)
  1111. return 0;
  1112. intel_connector->panel.fitting_mode = val;
  1113. }
  1114. crtc = intel_attached_encoder(connector)->base.crtc;
  1115. if (crtc && crtc->state->enable) {
  1116. /*
  1117. * If the CRTC is enabled, the display will be changed
  1118. * according to the new panel fitting mode.
  1119. */
  1120. intel_crtc_restore_mode(crtc);
  1121. }
  1122. return 0;
  1123. }
  1124. static void intel_dsi_connector_destroy(struct drm_connector *connector)
  1125. {
  1126. struct intel_connector *intel_connector = to_intel_connector(connector);
  1127. DRM_DEBUG_KMS("\n");
  1128. intel_panel_fini(&intel_connector->panel);
  1129. drm_connector_cleanup(connector);
  1130. kfree(connector);
  1131. }
  1132. static void intel_dsi_encoder_destroy(struct drm_encoder *encoder)
  1133. {
  1134. struct intel_dsi *intel_dsi = enc_to_intel_dsi(encoder);
  1135. if (intel_dsi->panel) {
  1136. drm_panel_detach(intel_dsi->panel);
  1137. /* XXX: Logically this call belongs in the panel driver. */
  1138. drm_panel_remove(intel_dsi->panel);
  1139. }
  1140. /* dispose of the gpios */
  1141. if (intel_dsi->gpio_panel)
  1142. gpiod_put(intel_dsi->gpio_panel);
  1143. intel_encoder_destroy(encoder);
  1144. }
  1145. static const struct drm_encoder_funcs intel_dsi_funcs = {
  1146. .destroy = intel_dsi_encoder_destroy,
  1147. };
  1148. static const struct drm_connector_helper_funcs intel_dsi_connector_helper_funcs = {
  1149. .get_modes = intel_dsi_get_modes,
  1150. .mode_valid = intel_dsi_mode_valid,
  1151. };
  1152. static const struct drm_connector_funcs intel_dsi_connector_funcs = {
  1153. .dpms = drm_atomic_helper_connector_dpms,
  1154. .detect = intel_dsi_detect,
  1155. .late_register = intel_connector_register,
  1156. .early_unregister = intel_connector_unregister,
  1157. .destroy = intel_dsi_connector_destroy,
  1158. .fill_modes = drm_helper_probe_single_connector_modes,
  1159. .set_property = intel_dsi_set_property,
  1160. .atomic_get_property = intel_connector_atomic_get_property,
  1161. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  1162. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  1163. };
  1164. static void intel_dsi_add_properties(struct intel_connector *connector)
  1165. {
  1166. struct drm_device *dev = connector->base.dev;
  1167. if (connector->panel.fixed_mode) {
  1168. drm_mode_create_scaling_mode_property(dev);
  1169. drm_object_attach_property(&connector->base.base,
  1170. dev->mode_config.scaling_mode_property,
  1171. DRM_MODE_SCALE_ASPECT);
  1172. connector->panel.fitting_mode = DRM_MODE_SCALE_ASPECT;
  1173. }
  1174. }
  1175. void intel_dsi_init(struct drm_device *dev)
  1176. {
  1177. struct intel_dsi *intel_dsi;
  1178. struct intel_encoder *intel_encoder;
  1179. struct drm_encoder *encoder;
  1180. struct intel_connector *intel_connector;
  1181. struct drm_connector *connector;
  1182. struct drm_display_mode *scan, *fixed_mode = NULL;
  1183. struct drm_i915_private *dev_priv = to_i915(dev);
  1184. enum port port;
  1185. unsigned int i;
  1186. DRM_DEBUG_KMS("\n");
  1187. /* There is no detection method for MIPI so rely on VBT */
  1188. if (!intel_bios_is_dsi_present(dev_priv, &port))
  1189. return;
  1190. if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev)) {
  1191. dev_priv->mipi_mmio_base = VLV_MIPI_BASE;
  1192. } else if (IS_BROXTON(dev)) {
  1193. dev_priv->mipi_mmio_base = BXT_MIPI_BASE;
  1194. } else {
  1195. DRM_ERROR("Unsupported Mipi device to reg base");
  1196. return;
  1197. }
  1198. intel_dsi = kzalloc(sizeof(*intel_dsi), GFP_KERNEL);
  1199. if (!intel_dsi)
  1200. return;
  1201. intel_connector = intel_connector_alloc();
  1202. if (!intel_connector) {
  1203. kfree(intel_dsi);
  1204. return;
  1205. }
  1206. intel_encoder = &intel_dsi->base;
  1207. encoder = &intel_encoder->base;
  1208. intel_dsi->attached_connector = intel_connector;
  1209. connector = &intel_connector->base;
  1210. drm_encoder_init(dev, encoder, &intel_dsi_funcs, DRM_MODE_ENCODER_DSI,
  1211. "DSI %c", port_name(port));
  1212. intel_encoder->compute_config = intel_dsi_compute_config;
  1213. intel_encoder->pre_enable = intel_dsi_pre_enable;
  1214. intel_encoder->enable = intel_dsi_enable_nop;
  1215. intel_encoder->disable = intel_dsi_pre_disable;
  1216. intel_encoder->post_disable = intel_dsi_post_disable;
  1217. intel_encoder->get_hw_state = intel_dsi_get_hw_state;
  1218. intel_encoder->get_config = intel_dsi_get_config;
  1219. intel_connector->get_hw_state = intel_connector_get_hw_state;
  1220. /*
  1221. * On BYT/CHV, pipe A maps to MIPI DSI port A, pipe B maps to MIPI DSI
  1222. * port C. BXT isn't limited like this.
  1223. */
  1224. if (IS_BROXTON(dev_priv))
  1225. intel_encoder->crtc_mask = BIT(PIPE_A) | BIT(PIPE_B) | BIT(PIPE_C);
  1226. else if (port == PORT_A)
  1227. intel_encoder->crtc_mask = BIT(PIPE_A);
  1228. else
  1229. intel_encoder->crtc_mask = BIT(PIPE_B);
  1230. if (dev_priv->vbt.dsi.config->dual_link) {
  1231. intel_dsi->ports = BIT(PORT_A) | BIT(PORT_C);
  1232. switch (dev_priv->vbt.dsi.config->dl_dcs_backlight_ports) {
  1233. case DL_DCS_PORT_A:
  1234. intel_dsi->dcs_backlight_ports = BIT(PORT_A);
  1235. break;
  1236. case DL_DCS_PORT_C:
  1237. intel_dsi->dcs_backlight_ports = BIT(PORT_C);
  1238. break;
  1239. default:
  1240. case DL_DCS_PORT_A_AND_C:
  1241. intel_dsi->dcs_backlight_ports = BIT(PORT_A) | BIT(PORT_C);
  1242. break;
  1243. }
  1244. switch (dev_priv->vbt.dsi.config->dl_dcs_cabc_ports) {
  1245. case DL_DCS_PORT_A:
  1246. intel_dsi->dcs_cabc_ports = BIT(PORT_A);
  1247. break;
  1248. case DL_DCS_PORT_C:
  1249. intel_dsi->dcs_cabc_ports = BIT(PORT_C);
  1250. break;
  1251. default:
  1252. case DL_DCS_PORT_A_AND_C:
  1253. intel_dsi->dcs_cabc_ports = BIT(PORT_A) | BIT(PORT_C);
  1254. break;
  1255. }
  1256. } else {
  1257. intel_dsi->ports = BIT(port);
  1258. intel_dsi->dcs_backlight_ports = BIT(port);
  1259. intel_dsi->dcs_cabc_ports = BIT(port);
  1260. }
  1261. if (!dev_priv->vbt.dsi.config->cabc_supported)
  1262. intel_dsi->dcs_cabc_ports = 0;
  1263. /* Create a DSI host (and a device) for each port. */
  1264. for_each_dsi_port(port, intel_dsi->ports) {
  1265. struct intel_dsi_host *host;
  1266. host = intel_dsi_host_init(intel_dsi, port);
  1267. if (!host)
  1268. goto err;
  1269. intel_dsi->dsi_hosts[port] = host;
  1270. }
  1271. for (i = 0; i < ARRAY_SIZE(intel_dsi_drivers); i++) {
  1272. intel_dsi->panel = intel_dsi_drivers[i].init(intel_dsi,
  1273. intel_dsi_drivers[i].panel_id);
  1274. if (intel_dsi->panel)
  1275. break;
  1276. }
  1277. if (!intel_dsi->panel) {
  1278. DRM_DEBUG_KMS("no device found\n");
  1279. goto err;
  1280. }
  1281. /*
  1282. * In case of BYT with CRC PMIC, we need to use GPIO for
  1283. * Panel control.
  1284. */
  1285. if (dev_priv->vbt.dsi.config->pwm_blc == PPS_BLC_PMIC) {
  1286. intel_dsi->gpio_panel =
  1287. gpiod_get(dev->dev, "panel", GPIOD_OUT_HIGH);
  1288. if (IS_ERR(intel_dsi->gpio_panel)) {
  1289. DRM_ERROR("Failed to own gpio for panel control\n");
  1290. intel_dsi->gpio_panel = NULL;
  1291. }
  1292. }
  1293. intel_encoder->type = INTEL_OUTPUT_DSI;
  1294. intel_encoder->cloneable = 0;
  1295. drm_connector_init(dev, connector, &intel_dsi_connector_funcs,
  1296. DRM_MODE_CONNECTOR_DSI);
  1297. drm_connector_helper_add(connector, &intel_dsi_connector_helper_funcs);
  1298. connector->display_info.subpixel_order = SubPixelHorizontalRGB; /*XXX*/
  1299. connector->interlace_allowed = false;
  1300. connector->doublescan_allowed = false;
  1301. intel_connector_attach_encoder(intel_connector, intel_encoder);
  1302. drm_panel_attach(intel_dsi->panel, connector);
  1303. mutex_lock(&dev->mode_config.mutex);
  1304. drm_panel_get_modes(intel_dsi->panel);
  1305. list_for_each_entry(scan, &connector->probed_modes, head) {
  1306. if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
  1307. fixed_mode = drm_mode_duplicate(dev, scan);
  1308. break;
  1309. }
  1310. }
  1311. mutex_unlock(&dev->mode_config.mutex);
  1312. if (!fixed_mode) {
  1313. DRM_DEBUG_KMS("no fixed mode\n");
  1314. goto err;
  1315. }
  1316. connector->display_info.width_mm = fixed_mode->width_mm;
  1317. connector->display_info.height_mm = fixed_mode->height_mm;
  1318. intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
  1319. intel_panel_setup_backlight(connector, INVALID_PIPE);
  1320. intel_dsi_add_properties(intel_connector);
  1321. return;
  1322. err:
  1323. drm_encoder_cleanup(&intel_encoder->base);
  1324. kfree(intel_dsi);
  1325. kfree(intel_connector);
  1326. }