intel_dsi.c 46 KB

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