panel-simple.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  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 lg_lp129qe_mode = {
  355. .clock = 285250,
  356. .hdisplay = 2560,
  357. .hsync_start = 2560 + 48,
  358. .hsync_end = 2560 + 48 + 32,
  359. .htotal = 2560 + 48 + 32 + 80,
  360. .vdisplay = 1700,
  361. .vsync_start = 1700 + 3,
  362. .vsync_end = 1700 + 3 + 10,
  363. .vtotal = 1700 + 3 + 10 + 36,
  364. .vrefresh = 60,
  365. };
  366. static const struct panel_desc lg_lp129qe = {
  367. .modes = &lg_lp129qe_mode,
  368. .num_modes = 1,
  369. .size = {
  370. .width = 272,
  371. .height = 181,
  372. },
  373. };
  374. static const struct drm_display_mode samsung_ltn101nt05_mode = {
  375. .clock = 54030,
  376. .hdisplay = 1024,
  377. .hsync_start = 1024 + 24,
  378. .hsync_end = 1024 + 24 + 136,
  379. .htotal = 1024 + 24 + 136 + 160,
  380. .vdisplay = 600,
  381. .vsync_start = 600 + 3,
  382. .vsync_end = 600 + 3 + 6,
  383. .vtotal = 600 + 3 + 6 + 61,
  384. .vrefresh = 60,
  385. };
  386. static const struct panel_desc samsung_ltn101nt05 = {
  387. .modes = &samsung_ltn101nt05_mode,
  388. .num_modes = 1,
  389. .size = {
  390. .width = 1024,
  391. .height = 600,
  392. },
  393. };
  394. static const struct of_device_id platform_of_match[] = {
  395. {
  396. .compatible = "auo,b101aw03",
  397. .data = &auo_b101aw03,
  398. }, {
  399. .compatible = "auo,b133xtn01",
  400. .data = &auo_b133xtn01,
  401. }, {
  402. .compatible = "chunghwa,claa101wa01a",
  403. .data = &chunghwa_claa101wa01a
  404. }, {
  405. .compatible = "chunghwa,claa101wb01",
  406. .data = &chunghwa_claa101wb01
  407. }, {
  408. .compatible = "edt,et057090dhu",
  409. .data = &edt_et057090dhu,
  410. }, {
  411. .compatible = "edt,et070080dh6",
  412. .data = &edt_etm0700g0dh6,
  413. }, {
  414. .compatible = "edt,etm0700g0dh6",
  415. .data = &edt_etm0700g0dh6,
  416. }, {
  417. .compatible = "foxlink,fl500wvr00-a0t",
  418. .data = &foxlink_fl500wvr00_a0t,
  419. }, {
  420. .compatible = "lg,lp129qe",
  421. .data = &lg_lp129qe,
  422. }, {
  423. .compatible = "samsung,ltn101nt05",
  424. .data = &samsung_ltn101nt05,
  425. }, {
  426. .compatible = "simple-panel",
  427. }, {
  428. /* sentinel */
  429. }
  430. };
  431. MODULE_DEVICE_TABLE(of, platform_of_match);
  432. static int panel_simple_platform_probe(struct platform_device *pdev)
  433. {
  434. const struct of_device_id *id;
  435. id = of_match_node(platform_of_match, pdev->dev.of_node);
  436. if (!id)
  437. return -ENODEV;
  438. return panel_simple_probe(&pdev->dev, id->data);
  439. }
  440. static int panel_simple_platform_remove(struct platform_device *pdev)
  441. {
  442. return panel_simple_remove(&pdev->dev);
  443. }
  444. static void panel_simple_platform_shutdown(struct platform_device *pdev)
  445. {
  446. panel_simple_shutdown(&pdev->dev);
  447. }
  448. static struct platform_driver panel_simple_platform_driver = {
  449. .driver = {
  450. .name = "panel-simple",
  451. .owner = THIS_MODULE,
  452. .of_match_table = platform_of_match,
  453. },
  454. .probe = panel_simple_platform_probe,
  455. .remove = panel_simple_platform_remove,
  456. .shutdown = panel_simple_platform_shutdown,
  457. };
  458. struct panel_desc_dsi {
  459. struct panel_desc desc;
  460. unsigned long flags;
  461. enum mipi_dsi_pixel_format format;
  462. unsigned int lanes;
  463. };
  464. static const struct drm_display_mode lg_ld070wx3_sl01_mode = {
  465. .clock = 71000,
  466. .hdisplay = 800,
  467. .hsync_start = 800 + 32,
  468. .hsync_end = 800 + 32 + 1,
  469. .htotal = 800 + 32 + 1 + 57,
  470. .vdisplay = 1280,
  471. .vsync_start = 1280 + 28,
  472. .vsync_end = 1280 + 28 + 1,
  473. .vtotal = 1280 + 28 + 1 + 14,
  474. .vrefresh = 60,
  475. };
  476. static const struct panel_desc_dsi lg_ld070wx3_sl01 = {
  477. .desc = {
  478. .modes = &lg_ld070wx3_sl01_mode,
  479. .num_modes = 1,
  480. .size = {
  481. .width = 94,
  482. .height = 151,
  483. },
  484. },
  485. .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_CLOCK_NON_CONTINUOUS,
  486. .format = MIPI_DSI_FMT_RGB888,
  487. .lanes = 4,
  488. };
  489. static const struct drm_display_mode lg_lh500wx1_sd03_mode = {
  490. .clock = 67000,
  491. .hdisplay = 720,
  492. .hsync_start = 720 + 12,
  493. .hsync_end = 720 + 12 + 4,
  494. .htotal = 720 + 12 + 4 + 112,
  495. .vdisplay = 1280,
  496. .vsync_start = 1280 + 8,
  497. .vsync_end = 1280 + 8 + 4,
  498. .vtotal = 1280 + 8 + 4 + 12,
  499. .vrefresh = 60,
  500. };
  501. static const struct panel_desc_dsi lg_lh500wx1_sd03 = {
  502. .desc = {
  503. .modes = &lg_lh500wx1_sd03_mode,
  504. .num_modes = 1,
  505. .size = {
  506. .width = 62,
  507. .height = 110,
  508. },
  509. },
  510. .flags = MIPI_DSI_MODE_VIDEO,
  511. .format = MIPI_DSI_FMT_RGB888,
  512. .lanes = 4,
  513. };
  514. static const struct drm_display_mode panasonic_vvx10f004b00_mode = {
  515. .clock = 157200,
  516. .hdisplay = 1920,
  517. .hsync_start = 1920 + 154,
  518. .hsync_end = 1920 + 154 + 16,
  519. .htotal = 1920 + 154 + 16 + 32,
  520. .vdisplay = 1200,
  521. .vsync_start = 1200 + 17,
  522. .vsync_end = 1200 + 17 + 2,
  523. .vtotal = 1200 + 17 + 2 + 16,
  524. .vrefresh = 60,
  525. };
  526. static const struct panel_desc_dsi panasonic_vvx10f004b00 = {
  527. .desc = {
  528. .modes = &panasonic_vvx10f004b00_mode,
  529. .num_modes = 1,
  530. .size = {
  531. .width = 217,
  532. .height = 136,
  533. },
  534. },
  535. .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
  536. MIPI_DSI_CLOCK_NON_CONTINUOUS,
  537. .format = MIPI_DSI_FMT_RGB888,
  538. .lanes = 4,
  539. };
  540. static const struct of_device_id dsi_of_match[] = {
  541. {
  542. .compatible = "lg,ld070wx3-sl01",
  543. .data = &lg_ld070wx3_sl01
  544. }, {
  545. .compatible = "lg,lh500wx1-sd03",
  546. .data = &lg_lh500wx1_sd03
  547. }, {
  548. .compatible = "panasonic,vvx10f004b00",
  549. .data = &panasonic_vvx10f004b00
  550. }, {
  551. /* sentinel */
  552. }
  553. };
  554. MODULE_DEVICE_TABLE(of, dsi_of_match);
  555. static int panel_simple_dsi_probe(struct mipi_dsi_device *dsi)
  556. {
  557. const struct panel_desc_dsi *desc;
  558. const struct of_device_id *id;
  559. int err;
  560. id = of_match_node(dsi_of_match, dsi->dev.of_node);
  561. if (!id)
  562. return -ENODEV;
  563. desc = id->data;
  564. err = panel_simple_probe(&dsi->dev, &desc->desc);
  565. if (err < 0)
  566. return err;
  567. dsi->mode_flags = desc->flags;
  568. dsi->format = desc->format;
  569. dsi->lanes = desc->lanes;
  570. return mipi_dsi_attach(dsi);
  571. }
  572. static int panel_simple_dsi_remove(struct mipi_dsi_device *dsi)
  573. {
  574. int err;
  575. err = mipi_dsi_detach(dsi);
  576. if (err < 0)
  577. dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
  578. return panel_simple_remove(&dsi->dev);
  579. }
  580. static void panel_simple_dsi_shutdown(struct mipi_dsi_device *dsi)
  581. {
  582. panel_simple_shutdown(&dsi->dev);
  583. }
  584. static struct mipi_dsi_driver panel_simple_dsi_driver = {
  585. .driver = {
  586. .name = "panel-simple-dsi",
  587. .owner = THIS_MODULE,
  588. .of_match_table = dsi_of_match,
  589. },
  590. .probe = panel_simple_dsi_probe,
  591. .remove = panel_simple_dsi_remove,
  592. .shutdown = panel_simple_dsi_shutdown,
  593. };
  594. static int __init panel_simple_init(void)
  595. {
  596. int err;
  597. err = platform_driver_register(&panel_simple_platform_driver);
  598. if (err < 0)
  599. return err;
  600. if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
  601. err = mipi_dsi_driver_register(&panel_simple_dsi_driver);
  602. if (err < 0)
  603. return err;
  604. }
  605. return 0;
  606. }
  607. module_init(panel_simple_init);
  608. static void __exit panel_simple_exit(void)
  609. {
  610. if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
  611. mipi_dsi_driver_unregister(&panel_simple_dsi_driver);
  612. platform_driver_unregister(&panel_simple_platform_driver);
  613. }
  614. module_exit(panel_simple_exit);
  615. MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
  616. MODULE_DESCRIPTION("DRM Driver for Simple Panels");
  617. MODULE_LICENSE("GPL and additional rights");