panel-simple.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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. struct {
  37. unsigned int width;
  38. unsigned int height;
  39. } size;
  40. };
  41. struct panel_simple {
  42. struct drm_panel base;
  43. bool enabled;
  44. const struct panel_desc *desc;
  45. struct backlight_device *backlight;
  46. struct regulator *supply;
  47. struct i2c_adapter *ddc;
  48. struct gpio_desc *enable_gpio;
  49. };
  50. static inline struct panel_simple *to_panel_simple(struct drm_panel *panel)
  51. {
  52. return container_of(panel, struct panel_simple, base);
  53. }
  54. static int panel_simple_get_fixed_modes(struct panel_simple *panel)
  55. {
  56. struct drm_connector *connector = panel->base.connector;
  57. struct drm_device *drm = panel->base.drm;
  58. struct drm_display_mode *mode;
  59. unsigned int i, num = 0;
  60. if (!panel->desc)
  61. return 0;
  62. for (i = 0; i < panel->desc->num_modes; i++) {
  63. const struct drm_display_mode *m = &panel->desc->modes[i];
  64. mode = drm_mode_duplicate(drm, m);
  65. if (!mode) {
  66. dev_err(drm->dev, "failed to add mode %ux%u@%u\n",
  67. m->hdisplay, m->vdisplay, m->vrefresh);
  68. continue;
  69. }
  70. drm_mode_set_name(mode);
  71. drm_mode_probed_add(connector, mode);
  72. num++;
  73. }
  74. connector->display_info.width_mm = panel->desc->size.width;
  75. connector->display_info.height_mm = panel->desc->size.height;
  76. return num;
  77. }
  78. static int panel_simple_disable(struct drm_panel *panel)
  79. {
  80. struct panel_simple *p = to_panel_simple(panel);
  81. if (!p->enabled)
  82. return 0;
  83. if (p->backlight) {
  84. p->backlight->props.power = FB_BLANK_POWERDOWN;
  85. backlight_update_status(p->backlight);
  86. }
  87. if (p->enable_gpio)
  88. gpiod_set_value_cansleep(p->enable_gpio, 0);
  89. regulator_disable(p->supply);
  90. p->enabled = false;
  91. return 0;
  92. }
  93. static int panel_simple_enable(struct drm_panel *panel)
  94. {
  95. struct panel_simple *p = to_panel_simple(panel);
  96. int err;
  97. if (p->enabled)
  98. return 0;
  99. err = regulator_enable(p->supply);
  100. if (err < 0) {
  101. dev_err(panel->dev, "failed to enable supply: %d\n", err);
  102. return err;
  103. }
  104. if (p->enable_gpio)
  105. gpiod_set_value_cansleep(p->enable_gpio, 1);
  106. if (p->backlight) {
  107. p->backlight->props.power = FB_BLANK_UNBLANK;
  108. backlight_update_status(p->backlight);
  109. }
  110. p->enabled = true;
  111. return 0;
  112. }
  113. static int panel_simple_get_modes(struct drm_panel *panel)
  114. {
  115. struct panel_simple *p = to_panel_simple(panel);
  116. int num = 0;
  117. /* probe EDID if a DDC bus is available */
  118. if (p->ddc) {
  119. struct edid *edid = drm_get_edid(panel->connector, p->ddc);
  120. drm_mode_connector_update_edid_property(panel->connector, edid);
  121. if (edid) {
  122. num += drm_add_edid_modes(panel->connector, edid);
  123. kfree(edid);
  124. }
  125. }
  126. /* add hard-coded panel modes */
  127. num += panel_simple_get_fixed_modes(p);
  128. return num;
  129. }
  130. static const struct drm_panel_funcs panel_simple_funcs = {
  131. .disable = panel_simple_disable,
  132. .enable = panel_simple_enable,
  133. .get_modes = panel_simple_get_modes,
  134. };
  135. static int panel_simple_probe(struct device *dev, const struct panel_desc *desc)
  136. {
  137. struct device_node *backlight, *ddc;
  138. struct panel_simple *panel;
  139. int err;
  140. panel = devm_kzalloc(dev, sizeof(*panel), GFP_KERNEL);
  141. if (!panel)
  142. return -ENOMEM;
  143. panel->enabled = false;
  144. panel->desc = desc;
  145. panel->supply = devm_regulator_get(dev, "power");
  146. if (IS_ERR(panel->supply))
  147. return PTR_ERR(panel->supply);
  148. panel->enable_gpio = devm_gpiod_get(dev, "enable");
  149. if (IS_ERR(panel->enable_gpio)) {
  150. err = PTR_ERR(panel->enable_gpio);
  151. if (err != -ENOENT) {
  152. dev_err(dev, "failed to request GPIO: %d\n", err);
  153. return err;
  154. }
  155. panel->enable_gpio = NULL;
  156. } else {
  157. err = gpiod_direction_output(panel->enable_gpio, 0);
  158. if (err < 0) {
  159. dev_err(dev, "failed to setup GPIO: %d\n", err);
  160. return err;
  161. }
  162. }
  163. backlight = of_parse_phandle(dev->of_node, "backlight", 0);
  164. if (backlight) {
  165. panel->backlight = of_find_backlight_by_node(backlight);
  166. of_node_put(backlight);
  167. if (!panel->backlight)
  168. return -EPROBE_DEFER;
  169. }
  170. ddc = of_parse_phandle(dev->of_node, "ddc-i2c-bus", 0);
  171. if (ddc) {
  172. panel->ddc = of_find_i2c_adapter_by_node(ddc);
  173. of_node_put(ddc);
  174. if (!panel->ddc) {
  175. err = -EPROBE_DEFER;
  176. goto free_backlight;
  177. }
  178. }
  179. drm_panel_init(&panel->base);
  180. panel->base.dev = dev;
  181. panel->base.funcs = &panel_simple_funcs;
  182. err = drm_panel_add(&panel->base);
  183. if (err < 0)
  184. goto free_ddc;
  185. dev_set_drvdata(dev, panel);
  186. return 0;
  187. free_ddc:
  188. if (panel->ddc)
  189. put_device(&panel->ddc->dev);
  190. free_backlight:
  191. if (panel->backlight)
  192. put_device(&panel->backlight->dev);
  193. return err;
  194. }
  195. static int panel_simple_remove(struct device *dev)
  196. {
  197. struct panel_simple *panel = dev_get_drvdata(dev);
  198. drm_panel_detach(&panel->base);
  199. drm_panel_remove(&panel->base);
  200. panel_simple_disable(&panel->base);
  201. if (panel->ddc)
  202. put_device(&panel->ddc->dev);
  203. if (panel->backlight)
  204. put_device(&panel->backlight->dev);
  205. return 0;
  206. }
  207. static void panel_simple_shutdown(struct device *dev)
  208. {
  209. struct panel_simple *panel = dev_get_drvdata(dev);
  210. panel_simple_disable(&panel->base);
  211. }
  212. static const struct drm_display_mode auo_b101aw03_mode = {
  213. .clock = 51450,
  214. .hdisplay = 1024,
  215. .hsync_start = 1024 + 156,
  216. .hsync_end = 1024 + 156 + 8,
  217. .htotal = 1024 + 156 + 8 + 156,
  218. .vdisplay = 600,
  219. .vsync_start = 600 + 16,
  220. .vsync_end = 600 + 16 + 6,
  221. .vtotal = 600 + 16 + 6 + 16,
  222. .vrefresh = 60,
  223. };
  224. static const struct panel_desc auo_b101aw03 = {
  225. .modes = &auo_b101aw03_mode,
  226. .num_modes = 1,
  227. .size = {
  228. .width = 223,
  229. .height = 125,
  230. },
  231. };
  232. static const struct drm_display_mode auo_b133xtn01_mode = {
  233. .clock = 69500,
  234. .hdisplay = 1366,
  235. .hsync_start = 1366 + 48,
  236. .hsync_end = 1366 + 48 + 32,
  237. .htotal = 1366 + 48 + 32 + 20,
  238. .vdisplay = 768,
  239. .vsync_start = 768 + 3,
  240. .vsync_end = 768 + 3 + 6,
  241. .vtotal = 768 + 3 + 6 + 13,
  242. .vrefresh = 60,
  243. };
  244. static const struct panel_desc auo_b133xtn01 = {
  245. .modes = &auo_b133xtn01_mode,
  246. .num_modes = 1,
  247. .size = {
  248. .width = 293,
  249. .height = 165,
  250. },
  251. };
  252. static const struct drm_display_mode chunghwa_claa101wa01a_mode = {
  253. .clock = 72070,
  254. .hdisplay = 1366,
  255. .hsync_start = 1366 + 58,
  256. .hsync_end = 1366 + 58 + 58,
  257. .htotal = 1366 + 58 + 58 + 58,
  258. .vdisplay = 768,
  259. .vsync_start = 768 + 4,
  260. .vsync_end = 768 + 4 + 4,
  261. .vtotal = 768 + 4 + 4 + 4,
  262. .vrefresh = 60,
  263. };
  264. static const struct panel_desc chunghwa_claa101wa01a = {
  265. .modes = &chunghwa_claa101wa01a_mode,
  266. .num_modes = 1,
  267. .size = {
  268. .width = 220,
  269. .height = 120,
  270. },
  271. };
  272. static const struct drm_display_mode chunghwa_claa101wb01_mode = {
  273. .clock = 69300,
  274. .hdisplay = 1366,
  275. .hsync_start = 1366 + 48,
  276. .hsync_end = 1366 + 48 + 32,
  277. .htotal = 1366 + 48 + 32 + 20,
  278. .vdisplay = 768,
  279. .vsync_start = 768 + 16,
  280. .vsync_end = 768 + 16 + 8,
  281. .vtotal = 768 + 16 + 8 + 16,
  282. .vrefresh = 60,
  283. };
  284. static const struct panel_desc chunghwa_claa101wb01 = {
  285. .modes = &chunghwa_claa101wb01_mode,
  286. .num_modes = 1,
  287. .size = {
  288. .width = 223,
  289. .height = 125,
  290. },
  291. };
  292. static const struct drm_display_mode edt_et057090dhu_mode = {
  293. .clock = 25175,
  294. .hdisplay = 640,
  295. .hsync_start = 640 + 16,
  296. .hsync_end = 640 + 16 + 30,
  297. .htotal = 640 + 16 + 30 + 114,
  298. .vdisplay = 480,
  299. .vsync_start = 480 + 10,
  300. .vsync_end = 480 + 10 + 3,
  301. .vtotal = 480 + 10 + 3 + 32,
  302. .vrefresh = 60,
  303. .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
  304. };
  305. static const struct panel_desc edt_et057090dhu = {
  306. .modes = &edt_et057090dhu_mode,
  307. .num_modes = 1,
  308. .size = {
  309. .width = 115,
  310. .height = 86,
  311. },
  312. };
  313. static const struct drm_display_mode edt_etm0700g0dh6_mode = {
  314. .clock = 33260,
  315. .hdisplay = 800,
  316. .hsync_start = 800 + 40,
  317. .hsync_end = 800 + 40 + 128,
  318. .htotal = 800 + 40 + 128 + 88,
  319. .vdisplay = 480,
  320. .vsync_start = 480 + 10,
  321. .vsync_end = 480 + 10 + 2,
  322. .vtotal = 480 + 10 + 2 + 33,
  323. .vrefresh = 60,
  324. .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
  325. };
  326. static const struct panel_desc edt_etm0700g0dh6 = {
  327. .modes = &edt_etm0700g0dh6_mode,
  328. .num_modes = 1,
  329. .size = {
  330. .width = 152,
  331. .height = 91,
  332. },
  333. };
  334. static const struct drm_display_mode foxlink_fl500wvr00_a0t_mode = {
  335. .clock = 32260,
  336. .hdisplay = 800,
  337. .hsync_start = 800 + 168,
  338. .hsync_end = 800 + 168 + 64,
  339. .htotal = 800 + 168 + 64 + 88,
  340. .vdisplay = 480,
  341. .vsync_start = 480 + 37,
  342. .vsync_end = 480 + 37 + 2,
  343. .vtotal = 480 + 37 + 2 + 8,
  344. .vrefresh = 60,
  345. };
  346. static const struct panel_desc foxlink_fl500wvr00_a0t = {
  347. .modes = &foxlink_fl500wvr00_a0t_mode,
  348. .num_modes = 1,
  349. .size = {
  350. .width = 108,
  351. .height = 65,
  352. },
  353. };
  354. static const struct drm_display_mode innolux_n156bge_l21_mode = {
  355. .clock = 69300,
  356. .hdisplay = 1366,
  357. .hsync_start = 1366 + 16,
  358. .hsync_end = 1366 + 16 + 34,
  359. .htotal = 1366 + 16 + 34 + 50,
  360. .vdisplay = 768,
  361. .vsync_start = 768 + 2,
  362. .vsync_end = 768 + 2 + 6,
  363. .vtotal = 768 + 2 + 6 + 12,
  364. .vrefresh = 60,
  365. };
  366. static const struct panel_desc innolux_n156bge_l21 = {
  367. .modes = &innolux_n156bge_l21_mode,
  368. .num_modes = 1,
  369. .size = {
  370. .width = 344,
  371. .height = 193,
  372. },
  373. };
  374. static const struct drm_display_mode lg_lp129qe_mode = {
  375. .clock = 285250,
  376. .hdisplay = 2560,
  377. .hsync_start = 2560 + 48,
  378. .hsync_end = 2560 + 48 + 32,
  379. .htotal = 2560 + 48 + 32 + 80,
  380. .vdisplay = 1700,
  381. .vsync_start = 1700 + 3,
  382. .vsync_end = 1700 + 3 + 10,
  383. .vtotal = 1700 + 3 + 10 + 36,
  384. .vrefresh = 60,
  385. };
  386. static const struct panel_desc lg_lp129qe = {
  387. .modes = &lg_lp129qe_mode,
  388. .num_modes = 1,
  389. .size = {
  390. .width = 272,
  391. .height = 181,
  392. },
  393. };
  394. static const struct drm_display_mode samsung_ltn101nt05_mode = {
  395. .clock = 54030,
  396. .hdisplay = 1024,
  397. .hsync_start = 1024 + 24,
  398. .hsync_end = 1024 + 24 + 136,
  399. .htotal = 1024 + 24 + 136 + 160,
  400. .vdisplay = 600,
  401. .vsync_start = 600 + 3,
  402. .vsync_end = 600 + 3 + 6,
  403. .vtotal = 600 + 3 + 6 + 61,
  404. .vrefresh = 60,
  405. };
  406. static const struct panel_desc samsung_ltn101nt05 = {
  407. .modes = &samsung_ltn101nt05_mode,
  408. .num_modes = 1,
  409. .size = {
  410. .width = 1024,
  411. .height = 600,
  412. },
  413. };
  414. static const struct of_device_id platform_of_match[] = {
  415. {
  416. .compatible = "auo,b101aw03",
  417. .data = &auo_b101aw03,
  418. }, {
  419. .compatible = "auo,b133xtn01",
  420. .data = &auo_b133xtn01,
  421. }, {
  422. .compatible = "chunghwa,claa101wa01a",
  423. .data = &chunghwa_claa101wa01a
  424. }, {
  425. .compatible = "chunghwa,claa101wb01",
  426. .data = &chunghwa_claa101wb01
  427. }, {
  428. .compatible = "edt,et057090dhu",
  429. .data = &edt_et057090dhu,
  430. }, {
  431. .compatible = "edt,et070080dh6",
  432. .data = &edt_etm0700g0dh6,
  433. }, {
  434. .compatible = "edt,etm0700g0dh6",
  435. .data = &edt_etm0700g0dh6,
  436. }, {
  437. .compatible = "foxlink,fl500wvr00-a0t",
  438. .data = &foxlink_fl500wvr00_a0t,
  439. }, {
  440. .compatible = "innolux,n156bge-l21",
  441. .data = &innolux_n156bge_l21,
  442. }, {
  443. .compatible = "lg,lp129qe",
  444. .data = &lg_lp129qe,
  445. }, {
  446. .compatible = "samsung,ltn101nt05",
  447. .data = &samsung_ltn101nt05,
  448. }, {
  449. .compatible = "simple-panel",
  450. }, {
  451. /* sentinel */
  452. }
  453. };
  454. MODULE_DEVICE_TABLE(of, platform_of_match);
  455. static int panel_simple_platform_probe(struct platform_device *pdev)
  456. {
  457. const struct of_device_id *id;
  458. id = of_match_node(platform_of_match, pdev->dev.of_node);
  459. if (!id)
  460. return -ENODEV;
  461. return panel_simple_probe(&pdev->dev, id->data);
  462. }
  463. static int panel_simple_platform_remove(struct platform_device *pdev)
  464. {
  465. return panel_simple_remove(&pdev->dev);
  466. }
  467. static void panel_simple_platform_shutdown(struct platform_device *pdev)
  468. {
  469. panel_simple_shutdown(&pdev->dev);
  470. }
  471. static struct platform_driver panel_simple_platform_driver = {
  472. .driver = {
  473. .name = "panel-simple",
  474. .owner = THIS_MODULE,
  475. .of_match_table = platform_of_match,
  476. },
  477. .probe = panel_simple_platform_probe,
  478. .remove = panel_simple_platform_remove,
  479. .shutdown = panel_simple_platform_shutdown,
  480. };
  481. struct panel_desc_dsi {
  482. struct panel_desc desc;
  483. unsigned long flags;
  484. enum mipi_dsi_pixel_format format;
  485. unsigned int lanes;
  486. };
  487. static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
  488. .clock = 71000,
  489. .hdisplay = 800,
  490. .hsync_start = 800 + 32,
  491. .hsync_end = 800 + 32 + 1,
  492. .htotal = 800 + 32 + 1 + 57,
  493. .vdisplay = 1280,
  494. .vsync_start = 1280 + 28,
  495. .vsync_end = 1280 + 28 + 1,
  496. .vtotal = 1280 + 28 + 1 + 14,
  497. .vrefresh = 60,
  498. };
  499. static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
  500. .desc = {
  501. .modes = &lg_ld070wx3_sl01_mode,
  502. .num_modes = 1,
  503. .size = {
  504. .width = 94,
  505. .height = 151,
  506. },
  507. },
  508. .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
  509. .format = MIPI_DSI_FMT_RGB888,
  510. .lanes = 4,
  511. };
  512. static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
  513. .clock = 67000,
  514. .hdisplay = 720,
  515. .hsync_start = 720 + 12,
  516. .hsync_end = 720 + 12 + 4,
  517. .htotal = 720 + 12 + 4 + 112,
  518. .vdisplay = 1280,
  519. .vsync_start = 1280 + 8,
  520. .vsync_end = 1280 + 8 + 4,
  521. .vtotal = 1280 + 8 + 4 + 12,
  522. .vrefresh = 60,
  523. };
  524. static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
  525. .desc = {
  526. .modes = &lg_lh500wx1_sd03_mode,
  527. .num_modes = 1,
  528. .size = {
  529. .width = 62,
  530. .height = 110,
  531. },
  532. },
  533. .flags = MIPI_DSI_MODE_VIDEO,
  534. .format = MIPI_DSI_FMT_RGB888,
  535. .lanes = 4,
  536. };
  537. static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
  538. .clock = 157200,
  539. .hdisplay = 1920,
  540. .hsync_start = 1920 + 154,
  541. .hsync_end = 1920 + 154 + 16,
  542. .htotal = 1920 + 154 + 16 + 32,
  543. .vdisplay = 1200,
  544. .vsync_start = 1200 + 17,
  545. .vsync_end = 1200 + 17 + 2,
  546. .vtotal = 1200 + 17 + 2 + 16,
  547. .vrefresh = 60,
  548. };
  549. static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
  550. .desc = {
  551. .modes = &panasonic_vvx10f004b00_mode,
  552. .num_modes = 1,
  553. .size = {
  554. .width = 217,
  555. .height = 136,
  556. },
  557. },
  558. .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
  559. MIPI_DSI_CLOCK_NON_CONTINUOUS,
  560. .format = MIPI_DSI_FMT_RGB888,
  561. .lanes = 4,
  562. };
  563. static const struct of_device_id dsi_of_match[] = {
  564. {
  565. .compatible = "lg,ld070wx3-sl01",
  566. .data = &lg_ld070wx3_sl01
  567. }, {
  568. .compatible = "lg,lh500wx1-sd03",
  569. .data = &lg_lh500wx1_sd03
  570. }, {
  571. .compatible = "panasonic,vvx10f004b00",
  572. .data = &panasonic_vvx10f004b00
  573. }, {
  574. /* sentinel */
  575. }
  576. };
  577. MODULE_DEVICE_TABLE(of, dsi_of_match);
  578. static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
  579. {
  580. const struct panel_desc_dsi *desc;
  581. const struct of_device_id *id;
  582. int err;
  583. id = of_match_node(dsi_of_match, dsi->dev.of_node);
  584. if (!id)
  585. return -ENODEV;
  586. desc = id->data;
  587. err = panel_simple_probe(&dsi->dev, &desc->desc);
  588. if (err < 0)
  589. return err;
  590. dsi->mode_flags = desc->flags;
  591. dsi->format = desc->format;
  592. dsi->lanes = desc->lanes;
  593. return mipi_dsi_attach(dsi);
  594. }
  595. static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
  596. {
  597. int err;
  598. err = mipi_dsi_detach(dsi);
  599. if (err < 0)
  600. dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
  601. return panel_simple_remove(&dsi->dev);
  602. }
  603. static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
  604. {
  605. panel_simple_shutdown(&dsi->dev);
  606. }
  607. static struct mipi_dsi_driver panel_simple_dsi_driver = {
  608. .driver = {
  609. .name = "panel-simple-dsi",
  610. .owner = THIS_MODULE,
  611. .of_match_table = dsi_of_match,
  612. },
  613. .probe = panel_simple_dsi_probe,
  614. .remove = panel_simple_dsi_remove,
  615. .shutdown = panel_simple_dsi_shutdown,
  616. };
  617. static int __init panel_simple_init(void)
  618. {
  619. int err;
  620. err = platform_driver_register(&panel_simple_platform_driver);
  621. if (err < 0)
  622. return err;
  623. if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
  624. err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
  625. if (err < 0)
  626. return err;
  627. }
  628. return 0;
  629. }
  630. module_init(panel_simple_init);
  631. static void __exit panel_simple_exit(void)
  632. {
  633. if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
  634. mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
  635. platform_driver_unregister(&panel_simple_platform_driver);
  636. }
  637. module_exit(panel_simple_exit);
  638. MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
  639. MODULE_DESCRIPTION("DRM Driver for Simple Panels");
  640. MODULE_LICENSE("GPL and additional rights");