panel-simple.c 22 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. /*
  2. * Copyright (C) 2013, NVIDIA Corporation. All rights reserved.
  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, sub license,
  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
  12. * next paragraph) shall be included in all copies or substantial portions
  13. * of the 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 NON-INFRINGEMENT. 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. #include <linux/backlight.h>
  24. #include <linux/gpio/consumer.h>
  25. #include <linux/module.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/regulator/consumer.h>
  29. #include <drm/drmP.h>
  30. #include <drm/drm_crtc.h>
  31. #include <drm/drm_mipi_dsi.h>
  32. #include <drm/drm_panel.h>
  33. struct panel_desc {
  34. const struct drm_display_mode *modes;
  35. unsigned int num_modes;
  36. unsigned int bpc;
  37. struct {
  38. unsigned int width;
  39. unsigned int height;
  40. } size;
  41. /**
  42. * @prepare: the time (in milliseconds) that it takes for the panel to
  43. * become ready and start receiving video data
  44. * @enable: the time (in milliseconds) that it takes for the panel to
  45. * display the first valid frame after starting to receive
  46. * video data
  47. * @disable: the time (in milliseconds) that it takes for the panel to
  48. * turn the display off (no content is visible)
  49. * @unprepare: the time (in milliseconds) that it takes for the panel
  50. * to power itself down completely
  51. */
  52. struct {
  53. unsigned int prepare;
  54. unsigned int enable;
  55. unsigned int disable;
  56. unsigned int unprepare;
  57. } delay;
  58. u32 bus_format;
  59. };
  60. struct panel_simple {
  61. struct drm_panel base;
  62. bool prepared;
  63. bool enabled;
  64. const struct panel_desc *desc;
  65. struct backlight_device *backlight;
  66. struct regulator *supply;
  67. struct i2c_adapter *ddc;
  68. struct gpio_desc *enable_gpio;
  69. };
  70. static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
  71. {
  72. return container_of(panel, struct panel_simple, base);
  73. }
  74. static int panel_simple_get_fixed_modes(struct panel_simple *panel)
  75. {
  76. struct drm_connector *connector = panel->base.connector;
  77. struct drm_device *drm = panel->base.drm;
  78. struct drm_display_mode *mode;
  79. unsigned int i, num = 0;
  80. if (!panel->desc)
  81. return 0;
  82. for (i = 0; i < panel->desc->num_modes; i++) {
  83. const struct drm_display_mode *m = &panel->desc->modes[i];
  84. mode = drm_mode_duplicate(drm, m);
  85. if (!mode) {
  86. dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
  87. m->hdisplay, m->vdisplay, m->vrefresh);
  88. continue;
  89. }
  90. drm_mode_set_name(mode);
  91. drm_mode_probed_add(connector, mode);
  92. num++;
  93. }
  94. connector->display_info.bpc = panel->desc->bpc;
  95. connector->display_info.width_mm = panel->desc->size.width;
  96. connector->display_info.height_mm = panel->desc->size.height;
  97. if (panel->desc->bus_format)
  98. drm_display_info_set_bus_formats(&connector->display_info,
  99. &panel->desc->bus_format, 1);
  100. return num;
  101. }
  102. static int panel_simple_disable(struct drm_panel *panel)
  103. {
  104. struct panel_simple *p = to_panel_simple(panel);
  105. if (!p->enabled)
  106. return 0;
  107. if (p->backlight) {
  108. p->backlight->props.power = FB_BLANK_POWERDOWN;
  109. backlight_update_status(p->backlight);
  110. }
  111. if (p->desc->delay.disable)
  112. msleep(p->desc->delay.disable);
  113. p->enabled = false;
  114. return 0;
  115. }
  116. static int panel_simple_unprepare(struct drm_panel *panel)
  117. {
  118. struct panel_simple *p = to_panel_simple(panel);
  119. if (!p->prepared)
  120. return 0;
  121. if (p->enable_gpio)
  122. gpiod_set_value_cansleep(p->enable_gpio, 0);
  123. regulator_disable(p->supply);
  124. if (p->desc->delay.unprepare)
  125. msleep(p->desc->delay.unprepare);
  126. p->prepared = false;
  127. return 0;
  128. }
  129. static int panel_simple_prepare(struct drm_panel *panel)
  130. {
  131. struct panel_simple *p = to_panel_simple(panel);
  132. int err;
  133. if (p->prepared)
  134. return 0;
  135. err = regulator_enable(p->supply);
  136. if (err < 0) {
  137. dev_err(panel->dev, "failed to enable supply: %d\n", err);
  138. return err;
  139. }
  140. if (p->enable_gpio)
  141. gpiod_set_value_cansleep(p->enable_gpio, 1);
  142. if (p->desc->delay.prepare)
  143. msleep(p->desc->delay.prepare);
  144. p->prepared = true;
  145. return 0;
  146. }
  147. static int panel_simple_enable(struct drm_panel *panel)
  148. {
  149. struct panel_simple *p = to_panel_simple(panel);
  150. if (p->enabled)
  151. return 0;
  152. if (p->desc->delay.enable)
  153. msleep(p->desc->delay.enable);
  154. if (p->backlight) {
  155. p->backlight->props.power = FB_BLANK_UNBLANK;
  156. backlight_update_status(p->backlight);
  157. }
  158. p->enabled = true;
  159. return 0;
  160. }
  161. static int panel_simple_get_modes(struct drm_panel *panel)
  162. {
  163. struct panel_simple *p = to_panel_simple(panel);
  164. int num = 0;
  165. /* probe EDID if a DDC bus is available */
  166. if (p->ddc) {
  167. struct edid *edid = drm_get_edid(panel->connector, p->ddc);
  168. drm_mode_connector_update_edid_property(panel->connector, edid);
  169. if (edid) {
  170. num += drm_add_edid_modes(panel->connector, edid);
  171. kfree(edid);
  172. }
  173. }
  174. /* add hard-coded panel modes */
  175. num += panel_simple_get_fixed_modes(p);
  176. return num;
  177. }
  178. static const struct drm_panel_funcs panel_simple_funcs = {
  179. .disable = panel_simple_disable,
  180. .unprepare = panel_simple_unprepare,
  181. .prepare = panel_simple_prepare,
  182. .enable = panel_simple_enable,
  183. .get_modes = panel_simple_get_modes,
  184. };
  185. static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
  186. {
  187. struct device_node *backlight, *ddc;
  188. struct panel_simple *panel;
  189. int err;
  190. panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
  191. if (!panel)
  192. return -ENOMEM;
  193. panel->enabled = false;
  194. panel->prepared = false;
  195. panel->desc = desc;
  196. panel->supply = devm_regulator_get(dev, "power");
  197. if (IS_ERR(panel->supply))
  198. return PTR_ERR(panel->supply);
  199. panel->enable_gpio = devm_gpiod_get_optional(dev, "enable",
  200. GPIOD_OUT_LOW);
  201. if (IS_ERR(panel->enable_gpio)) {
  202. err = PTR_ERR(panel->enable_gpio);
  203. dev_err(dev, "failed to request GPIO: %d\n", err);
  204. return err;
  205. }
  206. backlight = of_parse_phandle(dev->of_node, "backlight", 0);
  207. if (backlight) {
  208. panel->backlight = of_find_backlight_by_node(backlight);
  209. of_node_put(backlight);
  210. if (!panel->backlight)
  211. return -EPROBE_DEFER;
  212. }
  213. ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
  214. if (ddc) {
  215. panel->ddc = of_find_i2c_adapter_by_node(ddc);
  216. of_node_put(ddc);
  217. if (!panel->ddc) {
  218. err = -EPROBE_DEFER;
  219. goto free_backlight;
  220. }
  221. }
  222. drm_panel_init(&panel->base);
  223. panel->base.dev = dev;
  224. panel->base.funcs = &panel_simple_funcs;
  225. err = drm_panel_add(&panel->base);
  226. if (err < 0)
  227. goto free_ddc;
  228. dev_set_drvdata(dev, panel);
  229. return 0;
  230. free_ddc:
  231. if (panel->ddc)
  232. put_device(&panel->ddc->dev);
  233. free_backlight:
  234. if (panel->backlight)
  235. put_device(&panel->backlight->dev);
  236. return err;
  237. }
  238. static int panel_simple_remove(struct device *dev)
  239. {
  240. struct panel_simple *panel = dev_get_drvdata(dev);
  241. drm_panel_detach(&panel->base);
  242. drm_panel_remove(&panel->base);
  243. panel_simple_disable(&panel->base);
  244. if (panel->ddc)
  245. put_device(&panel->ddc->dev);
  246. if (panel->backlight)
  247. put_device(&panel->backlight->dev);
  248. return 0;
  249. }
  250. static void panel_simple_shutdown(struct device *dev)
  251. {
  252. struct panel_simple *panel = dev_get_drvdata(dev);
  253. panel_simple_disable(&panel->base);
  254. }
  255. static const struct drm_display_mode auo_b101aw03_mode = {
  256. .clock = 51450,
  257. .hdisplay = 1024,
  258. .hsync_start = 1024 + 156,
  259. .hsync_end = 1024 + 156 + 8,
  260. .htotal = 1024 + 156 + 8 + 156,
  261. .vdisplay = 600,
  262. .vsync_start = 600 + 16,
  263. .vsync_end = 600 + 16 + 6,
  264. .vtotal = 600 + 16 + 6 + 16,
  265. .vrefresh = 60,
  266. };
  267. static const struct panel_desc auo_b101aw03 = {
  268. .modes = &auo_b101aw03_mode,
  269. .num_modes = 1,
  270. .bpc = 6,
  271. .size = {
  272. .width = 223,
  273. .height = 125,
  274. },
  275. };
  276. static const struct drm_display_mode auo_b101xtn01_mode = {
  277. .clock = 72000,
  278. .hdisplay = 1366,
  279. .hsync_start = 1366 + 20,
  280. .hsync_end = 1366 + 20 + 70,
  281. .htotal = 1366 + 20 + 70,
  282. .vdisplay = 768,
  283. .vsync_start = 768 + 14,
  284. .vsync_end = 768 + 14 + 42,
  285. .vtotal = 768 + 14 + 42,
  286. .vrefresh = 60,
  287. .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
  288. };
  289. static const struct panel_desc auo_b101xtn01 = {
  290. .modes = &auo_b101xtn01_mode,
  291. .num_modes = 1,
  292. .bpc = 6,
  293. .size = {
  294. .width = 223,
  295. .height = 125,
  296. },
  297. };
  298. static const struct drm_display_mode auo_b116xw03_mode = {
  299. .clock = 70589,
  300. .hdisplay = 1366,
  301. .hsync_start = 1366 + 40,
  302. .hsync_end = 1366 + 40 + 40,
  303. .htotal = 1366 + 40 + 40 + 32,
  304. .vdisplay = 768,
  305. .vsync_start = 768 + 10,
  306. .vsync_end = 768 + 10 + 12,
  307. .vtotal = 768 + 10 + 12 + 6,
  308. .vrefresh = 60,
  309. };
  310. static const struct panel_desc auo_b116xw03 = {
  311. .modes = &auo_b116xw03_mode,
  312. .num_modes = 1,
  313. .bpc = 6,
  314. .size = {
  315. .width = 256,
  316. .height = 144,
  317. },
  318. };
  319. static const struct drm_display_mode auo_b133xtn01_mode = {
  320. .clock = 69500,
  321. .hdisplay = 1366,
  322. .hsync_start = 1366 + 48,
  323. .hsync_end = 1366 + 48 + 32,
  324. .htotal = 1366 + 48 + 32 + 20,
  325. .vdisplay = 768,
  326. .vsync_start = 768 + 3,
  327. .vsync_end = 768 + 3 + 6,
  328. .vtotal = 768 + 3 + 6 + 13,
  329. .vrefresh = 60,
  330. };
  331. static const struct panel_desc auo_b133xtn01 = {
  332. .modes = &auo_b133xtn01_mode,
  333. .num_modes = 1,
  334. .bpc = 6,
  335. .size = {
  336. .width = 293,
  337. .height = 165,
  338. },
  339. };
  340. static const struct drm_display_mode auo_b133htn01_mode = {
  341. .clock = 150660,
  342. .hdisplay = 1920,
  343. .hsync_start = 1920 + 172,
  344. .hsync_end = 1920 + 172 + 80,
  345. .htotal = 1920 + 172 + 80 + 60,
  346. .vdisplay = 1080,
  347. .vsync_start = 1080 + 25,
  348. .vsync_end = 1080 + 25 + 10,
  349. .vtotal = 1080 + 25 + 10 + 10,
  350. .vrefresh = 60,
  351. };
  352. static const struct panel_desc auo_b133htn01 = {
  353. .modes = &auo_b133htn01_mode,
  354. .num_modes = 1,
  355. .bpc = 6,
  356. .size = {
  357. .width = 293,
  358. .height = 165,
  359. },
  360. .delay = {
  361. .prepare = 105,
  362. .enable = 20,
  363. .unprepare = 50,
  364. },
  365. };
  366. static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
  367. .clock = 72070,
  368. .hdisplay = 1366,
  369. .hsync_start = 1366 + 58,
  370. .hsync_end = 1366 + 58 + 58,
  371. .htotal = 1366 + 58 + 58 + 58,
  372. .vdisplay = 768,
  373. .vsync_start = 768 + 4,
  374. .vsync_end = 768 + 4 + 4,
  375. .vtotal = 768 + 4 + 4 + 4,
  376. .vrefresh = 60,
  377. };
  378. static const struct panel_desc chunghwa_claa101wa01a = {
  379. .modes = &chunghwa_claa101wa01a_mode,
  380. .num_modes = 1,
  381. .bpc = 6,
  382. .size = {
  383. .width = 220,
  384. .height = 120,
  385. },
  386. };
  387. static const struct drm_display_mode chunghwa_claa101wb01_mode = {
  388. .clock = 69300,
  389. .hdisplay = 1366,
  390. .hsync_start = 1366 + 48,
  391. .hsync_end = 1366 + 48 + 32,
  392. .htotal = 1366 + 48 + 32 + 20,
  393. .vdisplay = 768,
  394. .vsync_start = 768 + 16,
  395. .vsync_end = 768 + 16 + 8,
  396. .vtotal = 768 + 16 + 8 + 16,
  397. .vrefresh = 60,
  398. };
  399. static const struct panel_desc chunghwa_claa101wb01 = {
  400. .modes = &chunghwa_claa101wb01_mode,
  401. .num_modes = 1,
  402. .bpc = 6,
  403. .size = {
  404. .width = 223,
  405. .height = 125,
  406. },
  407. };
  408. static const struct drm_display_mode edt_et057090dhu_mode = {
  409. .clock = 25175,
  410. .hdisplay = 640,
  411. .hsync_start = 640 + 16,
  412. .hsync_end = 640 + 16 + 30,
  413. .htotal = 640 + 16 + 30 + 114,
  414. .vdisplay = 480,
  415. .vsync_start = 480 + 10,
  416. .vsync_end = 480 + 10 + 3,
  417. .vtotal = 480 + 10 + 3 + 32,
  418. .vrefresh = 60,
  419. .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
  420. };
  421. static const struct panel_desc edt_et057090dhu = {
  422. .modes = &edt_et057090dhu_mode,
  423. .num_modes = 1,
  424. .bpc = 6,
  425. .size = {
  426. .width = 115,
  427. .height = 86,
  428. },
  429. };
  430. static const struct drm_display_mode edt_etm0700g0dh6_mode = {
  431. .clock = 33260,
  432. .hdisplay = 800,
  433. .hsync_start = 800 + 40,
  434. .hsync_end = 800 + 40 + 128,
  435. .htotal = 800 + 40 + 128 + 88,
  436. .vdisplay = 480,
  437. .vsync_start = 480 + 10,
  438. .vsync_end = 480 + 10 + 2,
  439. .vtotal = 480 + 10 + 2 + 33,
  440. .vrefresh = 60,
  441. .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
  442. };
  443. static const struct panel_desc edt_etm0700g0dh6 = {
  444. .modes = &edt_etm0700g0dh6_mode,
  445. .num_modes = 1,
  446. .bpc = 6,
  447. .size = {
  448. .width = 152,
  449. .height = 91,
  450. },
  451. };
  452. static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
  453. .clock = 32260,
  454. .hdisplay = 800,
  455. .hsync_start = 800 + 168,
  456. .hsync_end = 800 + 168 + 64,
  457. .htotal = 800 + 168 + 64 + 88,
  458. .vdisplay = 480,
  459. .vsync_start = 480 + 37,
  460. .vsync_end = 480 + 37 + 2,
  461. .vtotal = 480 + 37 + 2 + 8,
  462. .vrefresh = 60,
  463. };
  464. static const struct panel_desc foxlink_fl500wvr00_a0t = {
  465. .modes = &foxlink_fl500wvr00_a0t_mode,
  466. .num_modes = 1,
  467. .bpc = 8,
  468. .size = {
  469. .width = 108,
  470. .height = 65,
  471. },
  472. .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
  473. };
  474. static const struct drm_display_mode hannstar_hsd070pww1_mode = {
  475. .clock = 71100,
  476. .hdisplay = 1280,
  477. .hsync_start = 1280 + 1,
  478. .hsync_end = 1280 + 1 + 158,
  479. .htotal = 1280 + 1 + 158 + 1,
  480. .vdisplay = 800,
  481. .vsync_start = 800 + 1,
  482. .vsync_end = 800 + 1 + 21,
  483. .vtotal = 800 + 1 + 21 + 1,
  484. .vrefresh = 60,
  485. };
  486. static const struct panel_desc hannstar_hsd070pww1 = {
  487. .modes = &hannstar_hsd070pww1_mode,
  488. .num_modes = 1,
  489. .bpc = 6,
  490. .size = {
  491. .width = 151,
  492. .height = 94,
  493. },
  494. };
  495. static const struct drm_display_mode hitachi_tx23d38vm0caa_mode = {
  496. .clock = 33333,
  497. .hdisplay = 800,
  498. .hsync_start = 800 + 85,
  499. .hsync_end = 800 + 85 + 86,
  500. .htotal = 800 + 85 + 86 + 85,
  501. .vdisplay = 480,
  502. .vsync_start = 480 + 16,
  503. .vsync_end = 480 + 16 + 13,
  504. .vtotal = 480 + 16 + 13 + 16,
  505. .vrefresh = 60,
  506. };
  507. static const struct panel_desc hitachi_tx23d38vm0caa = {
  508. .modes = &hitachi_tx23d38vm0caa_mode,
  509. .num_modes = 1,
  510. .bpc = 6,
  511. .size = {
  512. .width = 195,
  513. .height = 117,
  514. },
  515. };
  516. static const struct drm_display_mode innolux_g121i1_l01_mode = {
  517. .clock = 71000,
  518. .hdisplay = 1280,
  519. .hsync_start = 1280 + 64,
  520. .hsync_end = 1280 + 64 + 32,
  521. .htotal = 1280 + 64 + 32 + 64,
  522. .vdisplay = 800,
  523. .vsync_start = 800 + 9,
  524. .vsync_end = 800 + 9 + 6,
  525. .vtotal = 800 + 9 + 6 + 9,
  526. .vrefresh = 60,
  527. };
  528. static const struct panel_desc innolux_g121i1_l01 = {
  529. .modes = &innolux_g121i1_l01_mode,
  530. .num_modes = 1,
  531. .bpc = 6,
  532. .size = {
  533. .width = 261,
  534. .height = 163,
  535. },
  536. };
  537. static const struct drm_display_mode innolux_n116bge_mode = {
  538. .clock = 76420,
  539. .hdisplay = 1366,
  540. .hsync_start = 1366 + 136,
  541. .hsync_end = 1366 + 136 + 30,
  542. .htotal = 1366 + 136 + 30 + 60,
  543. .vdisplay = 768,
  544. .vsync_start = 768 + 8,
  545. .vsync_end = 768 + 8 + 12,
  546. .vtotal = 768 + 8 + 12 + 12,
  547. .vrefresh = 60,
  548. .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
  549. };
  550. static const struct panel_desc innolux_n116bge = {
  551. .modes = &innolux_n116bge_mode,
  552. .num_modes = 1,
  553. .bpc = 6,
  554. .size = {
  555. .width = 256,
  556. .height = 144,
  557. },
  558. };
  559. static const struct drm_display_mode innolux_n156bge_l21_mode = {
  560. .clock = 69300,
  561. .hdisplay = 1366,
  562. .hsync_start = 1366 + 16,
  563. .hsync_end = 1366 + 16 + 34,
  564. .htotal = 1366 + 16 + 34 + 50,
  565. .vdisplay = 768,
  566. .vsync_start = 768 + 2,
  567. .vsync_end = 768 + 2 + 6,
  568. .vtotal = 768 + 2 + 6 + 12,
  569. .vrefresh = 60,
  570. };
  571. static const struct panel_desc innolux_n156bge_l21 = {
  572. .modes = &innolux_n156bge_l21_mode,
  573. .num_modes = 1,
  574. .bpc = 6,
  575. .size = {
  576. .width = 344,
  577. .height = 193,
  578. },
  579. };
  580. static const struct drm_display_mode lg_lp129qe_mode = {
  581. .clock = 285250,
  582. .hdisplay = 2560,
  583. .hsync_start = 2560 + 48,
  584. .hsync_end = 2560 + 48 + 32,
  585. .htotal = 2560 + 48 + 32 + 80,
  586. .vdisplay = 1700,
  587. .vsync_start = 1700 + 3,
  588. .vsync_end = 1700 + 3 + 10,
  589. .vtotal = 1700 + 3 + 10 + 36,
  590. .vrefresh = 60,
  591. };
  592. static const struct panel_desc lg_lp129qe = {
  593. .modes = &lg_lp129qe_mode,
  594. .num_modes = 1,
  595. .bpc = 8,
  596. .size = {
  597. .width = 272,
  598. .height = 181,
  599. },
  600. };
  601. static const struct drm_display_mode samsung_ltn101nt05_mode = {
  602. .clock = 54030,
  603. .hdisplay = 1024,
  604. .hsync_start = 1024 + 24,
  605. .hsync_end = 1024 + 24 + 136,
  606. .htotal = 1024 + 24 + 136 + 160,
  607. .vdisplay = 600,
  608. .vsync_start = 600 + 3,
  609. .vsync_end = 600 + 3 + 6,
  610. .vtotal = 600 + 3 + 6 + 61,
  611. .vrefresh = 60,
  612. };
  613. static const struct panel_desc samsung_ltn101nt05 = {
  614. .modes = &samsung_ltn101nt05_mode,
  615. .num_modes = 1,
  616. .bpc = 6,
  617. .size = {
  618. .width = 1024,
  619. .height = 600,
  620. },
  621. };
  622. static const struct of_device_id platform_of_match[] = {
  623. {
  624. .compatible = "auo,b101aw03",
  625. .data = &auo_b101aw03,
  626. }, {
  627. .compatible = "auo,b101xtn01",
  628. .data = &auo_b101xtn01,
  629. }, {
  630. .compatible = "auo,b116xw03",
  631. .data = &auo_b116xw03,
  632. }, {
  633. .compatible = "auo,b133htn01",
  634. .data = &auo_b133htn01,
  635. }, {
  636. .compatible = "auo,b133xtn01",
  637. .data = &auo_b133xtn01,
  638. }, {
  639. .compatible = "chunghwa,claa101wa01a",
  640. .data = &chunghwa_claa101wa01a
  641. }, {
  642. .compatible = "chunghwa,claa101wb01",
  643. .data = &chunghwa_claa101wb01
  644. }, {
  645. .compatible = "edt,et057090dhu",
  646. .data = &edt_et057090dhu,
  647. }, {
  648. .compatible = "edt,et070080dh6",
  649. .data = &edt_etm0700g0dh6,
  650. }, {
  651. .compatible = "edt,etm0700g0dh6",
  652. .data = &edt_etm0700g0dh6,
  653. }, {
  654. .compatible = "foxlink,fl500wvr00-a0t",
  655. .data = &foxlink_fl500wvr00_a0t,
  656. }, {
  657. .compatible = "hannstar,hsd070pww1",
  658. .data = &hannstar_hsd070pww1,
  659. }, {
  660. .compatible = "hit,tx23d38vm0caa",
  661. .data = &hitachi_tx23d38vm0caa
  662. }, {
  663. .compatible ="innolux,g121i1-l01",
  664. .data = &innolux_g121i1_l01
  665. }, {
  666. .compatible = "innolux,n116bge",
  667. .data = &innolux_n116bge,
  668. }, {
  669. .compatible = "innolux,n156bge-l21",
  670. .data = &innolux_n156bge_l21,
  671. }, {
  672. .compatible = "lg,lp129qe",
  673. .data = &lg_lp129qe,
  674. }, {
  675. .compatible = "samsung,ltn101nt05",
  676. .data = &samsung_ltn101nt05,
  677. }, {
  678. /* sentinel */
  679. }
  680. };
  681. MODULE_DEVICE_TABLE(of, platform_of_match);
  682. static int panel_simple_platform_probe(struct platform_device *pdev)
  683. {
  684. const struct of_device_id *id;
  685. id = of_match_node(platform_of_match, pdev->dev.of_node);
  686. if (!id)
  687. return -ENODEV;
  688. return panel_simple_probe(&pdev->dev, id->data);
  689. }
  690. static int panel_simple_platform_remove(struct platform_device *pdev)
  691. {
  692. return panel_simple_remove(&pdev->dev);
  693. }
  694. static void panel_simple_platform_shutdown(struct platform_device *pdev)
  695. {
  696. panel_simple_shutdown(&pdev->dev);
  697. }
  698. static struct platform_driver panel_simple_platform_driver = {
  699. .driver = {
  700. .name = "panel-simple",
  701. .of_match_table = platform_of_match,
  702. },
  703. .probe = panel_simple_platform_probe,
  704. .remove = panel_simple_platform_remove,
  705. .shutdown = panel_simple_platform_shutdown,
  706. };
  707. struct panel_desc_dsi {
  708. struct panel_desc desc;
  709. unsigned long flags;
  710. enum mipi_dsi_pixel_format format;
  711. unsigned int lanes;
  712. };
  713. static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
  714. .clock = 71000,
  715. .hdisplay = 800,
  716. .hsync_start = 800 + 32,
  717. .hsync_end = 800 + 32 + 1,
  718. .htotal = 800 + 32 + 1 + 57,
  719. .vdisplay = 1280,
  720. .vsync_start = 1280 + 28,
  721. .vsync_end = 1280 + 28 + 1,
  722. .vtotal = 1280 + 28 + 1 + 14,
  723. .vrefresh = 60,
  724. };
  725. static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
  726. .desc = {
  727. .modes = &lg_ld070wx3_sl01_mode,
  728. .num_modes = 1,
  729. .bpc = 8,
  730. .size = {
  731. .width = 94,
  732. .height = 151,
  733. },
  734. },
  735. .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
  736. .format = MIPI_DSI_FMT_RGB888,
  737. .lanes = 4,
  738. };
  739. static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
  740. .clock = 67000,
  741. .hdisplay = 720,
  742. .hsync_start = 720 + 12,
  743. .hsync_end = 720 + 12 + 4,
  744. .htotal = 720 + 12 + 4 + 112,
  745. .vdisplay = 1280,
  746. .vsync_start = 1280 + 8,
  747. .vsync_end = 1280 + 8 + 4,
  748. .vtotal = 1280 + 8 + 4 + 12,
  749. .vrefresh = 60,
  750. };
  751. static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
  752. .desc = {
  753. .modes = &lg_lh500wx1_sd03_mode,
  754. .num_modes = 1,
  755. .bpc = 8,
  756. .size = {
  757. .width = 62,
  758. .height = 110,
  759. },
  760. },
  761. .flags = MIPI_DSI_MODE_VIDEO,
  762. .format = MIPI_DSI_FMT_RGB888,
  763. .lanes = 4,
  764. };
  765. static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
  766. .clock = 157200,
  767. .hdisplay = 1920,
  768. .hsync_start = 1920 + 154,
  769. .hsync_end = 1920 + 154 + 16,
  770. .htotal = 1920 + 154 + 16 + 32,
  771. .vdisplay = 1200,
  772. .vsync_start = 1200 + 17,
  773. .vsync_end = 1200 + 17 + 2,
  774. .vtotal = 1200 + 17 + 2 + 16,
  775. .vrefresh = 60,
  776. };
  777. static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
  778. .desc = {
  779. .modes = &panasonic_vvx10f004b00_mode,
  780. .num_modes = 1,
  781. .bpc = 8,
  782. .size = {
  783. .width = 217,
  784. .height = 136,
  785. },
  786. },
  787. .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
  788. MIPI_DSI_CLOCK_NON_CONTINUOUS,
  789. .format = MIPI_DSI_FMT_RGB888,
  790. .lanes = 4,
  791. };
  792. static const struct of_device_id dsi_of_match[] = {
  793. {
  794. .compatible = "lg,ld070wx3-sl01",
  795. .data = &lg_ld070wx3_sl01
  796. }, {
  797. .compatible = "lg,lh500wx1-sd03",
  798. .data = &lg_lh500wx1_sd03
  799. }, {
  800. .compatible = "panasonic,vvx10f004b00",
  801. .data = &panasonic_vvx10f004b00
  802. }, {
  803. /* sentinel */
  804. }
  805. };
  806. MODULE_DEVICE_TABLE(of, dsi_of_match);
  807. static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
  808. {
  809. const struct panel_desc_dsi *desc;
  810. const struct of_device_id *id;
  811. int err;
  812. id = of_match_node(dsi_of_match, dsi->dev.of_node);
  813. if (!id)
  814. return -ENODEV;
  815. desc = id->data;
  816. err = panel_simple_probe(&dsi->dev, &desc->desc);
  817. if (err < 0)
  818. return err;
  819. dsi->mode_flags = desc->flags;
  820. dsi->format = desc->format;
  821. dsi->lanes = desc->lanes;
  822. return mipi_dsi_attach(dsi);
  823. }
  824. static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
  825. {
  826. int err;
  827. err = mipi_dsi_detach(dsi);
  828. if (err < 0)
  829. dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
  830. return panel_simple_remove(&dsi->dev);
  831. }
  832. static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
  833. {
  834. panel_simple_shutdown(&dsi->dev);
  835. }
  836. static struct mipi_dsi_driver panel_simple_dsi_driver = {
  837. .driver = {
  838. .name = "panel-simple-dsi",
  839. .of_match_table = dsi_of_match,
  840. },
  841. .probe = panel_simple_dsi_probe,
  842. .remove = panel_simple_dsi_remove,
  843. .shutdown = panel_simple_dsi_shutdown,
  844. };
  845. static int __init panel_simple_init(void)
  846. {
  847. int err;
  848. err = platform_driver_register(&panel_simple_platform_driver);
  849. if (err < 0)
  850. return err;
  851. if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
  852. err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
  853. if (err < 0)
  854. return err;
  855. }
  856. return 0;
  857. }
  858. module_init(panel_simple_init);
  859. static void __exit panel_simple_exit(void)
  860. {
  861. if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
  862. mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
  863. platform_driver_unregister(&panel_simple_platform_driver);
  864. }
  865. module_exit(panel_simple_exit);
  866. MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
  867. MODULE_DESCRIPTION("DRM Driver for Simple Panels");
  868. MODULE_LICENSE("GPL and additional rights");