panel-generic-dpi.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Generic DPI Panels support
  3. *
  4. * Copyright (C) 2010 Canonical Ltd.
  5. * Author: Bryan Wu <bryan.wu@canonical.com>
  6. *
  7. * LCD panel driver for Sharp LQ043T1DG01
  8. *
  9. * Copyright (C) 2009 Texas Instruments Inc
  10. * Author: Vaibhav Hiremath <hvaibhav@ti.com>
  11. *
  12. * LCD panel driver for Toppoly TDO35S
  13. *
  14. * Copyright (C) 2009 CompuLab, Ltd.
  15. * Author: Mike Rapoport <mike@compulab.co.il>
  16. *
  17. * Copyright (C) 2008 Nokia Corporation
  18. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  19. *
  20. * This program is free software; you can redistribute it and/or modify it
  21. * under the terms of the GNU General Public License version 2 as published by
  22. * the Free Software Foundation.
  23. *
  24. * This program is distributed in the hope that it will be useful, but WITHOUT
  25. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  26. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  27. * more details.
  28. *
  29. * You should have received a copy of the GNU General Public License along with
  30. * this program. If not, see <http://www.gnu.org/licenses/>.
  31. */
  32. #include <linux/module.h>
  33. #include <linux/delay.h>
  34. #include <linux/slab.h>
  35. #include <video/omapdss.h>
  36. #include <video/omap-panel-generic-dpi.h>
  37. struct panel_config {
  38. struct omap_video_timings timings;
  39. enum omap_panel_config config;
  40. int power_on_delay;
  41. int power_off_delay;
  42. /*
  43. * Used to match device to panel configuration
  44. * when use generic panel driver
  45. */
  46. const char *name;
  47. };
  48. /* Panel configurations */
  49. static struct panel_config generic_dpi_panels[] = {
  50. /* Sharp LQ043T1DG01 */
  51. {
  52. {
  53. .x_res = 480,
  54. .y_res = 272,
  55. .pixel_clock = 9000,
  56. .hsw = 42,
  57. .hfp = 3,
  58. .hbp = 2,
  59. .vsw = 11,
  60. .vfp = 3,
  61. .vbp = 2,
  62. },
  63. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  64. OMAP_DSS_LCD_IEO,
  65. .power_on_delay = 50,
  66. .power_off_delay = 100,
  67. .name = "sharp_lq",
  68. },
  69. /* Sharp LS037V7DW01 */
  70. {
  71. {
  72. .x_res = 480,
  73. .y_res = 640,
  74. .pixel_clock = 19200,
  75. .hsw = 2,
  76. .hfp = 1,
  77. .hbp = 28,
  78. .vsw = 1,
  79. .vfp = 1,
  80. .vbp = 1,
  81. },
  82. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  83. .power_on_delay = 50,
  84. .power_off_delay = 100,
  85. .name = "sharp_ls",
  86. },
  87. /* Toppoly TDO35S */
  88. {
  89. {
  90. .x_res = 480,
  91. .y_res = 640,
  92. .pixel_clock = 26000,
  93. .hfp = 104,
  94. .hsw = 8,
  95. .hbp = 8,
  96. .vfp = 4,
  97. .vsw = 2,
  98. .vbp = 2,
  99. },
  100. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  101. OMAP_DSS_LCD_IPC |
  102. OMAP_DSS_LCD_ONOFF,
  103. .power_on_delay = 0,
  104. .power_off_delay = 0,
  105. .name = "toppoly_tdo35s",
  106. },
  107. /* Samsung LTE430WQ-F0C */
  108. {
  109. {
  110. .x_res = 480,
  111. .y_res = 272,
  112. .pixel_clock = 9200,
  113. .hfp = 8,
  114. .hsw = 41,
  115. .hbp = 45 - 41,
  116. .vfp = 4,
  117. .vsw = 10,
  118. .vbp = 12 - 10,
  119. },
  120. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  121. .power_on_delay = 0,
  122. .power_off_delay = 0,
  123. .name = "samsung_lte430wq_f0c",
  124. },
  125. /* Seiko 70WVW1TZ3Z3 */
  126. {
  127. {
  128. .x_res = 800,
  129. .y_res = 480,
  130. .pixel_clock = 33000,
  131. .hsw = 128,
  132. .hfp = 10,
  133. .hbp = 10,
  134. .vsw = 2,
  135. .vfp = 4,
  136. .vbp = 11,
  137. },
  138. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  139. .power_on_delay = 0,
  140. .power_off_delay = 0,
  141. .name = "seiko_70wvw1tz3",
  142. },
  143. /* Powertip PH480272T */
  144. {
  145. {
  146. .x_res = 480,
  147. .y_res = 272,
  148. .pixel_clock = 9000,
  149. .hsw = 40,
  150. .hfp = 2,
  151. .hbp = 2,
  152. .vsw = 10,
  153. .vfp = 2,
  154. .vbp = 2,
  155. },
  156. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  157. OMAP_DSS_LCD_IEO,
  158. .power_on_delay = 0,
  159. .power_off_delay = 0,
  160. .name = "powertip_ph480272t",
  161. },
  162. /* Innolux AT070TN83 */
  163. {
  164. {
  165. .x_res = 800,
  166. .y_res = 480,
  167. .pixel_clock = 40000,
  168. .hsw = 48,
  169. .hfp = 1,
  170. .hbp = 1,
  171. .vsw = 3,
  172. .vfp = 12,
  173. .vbp = 25,
  174. },
  175. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  176. .power_on_delay = 0,
  177. .power_off_delay = 0,
  178. .name = "innolux_at070tn83",
  179. },
  180. /* NEC NL2432DR22-11B */
  181. {
  182. {
  183. .x_res = 240,
  184. .y_res = 320,
  185. .pixel_clock = 5400,
  186. .hsw = 3,
  187. .hfp = 3,
  188. .hbp = 39,
  189. .vsw = 1,
  190. .vfp = 2,
  191. .vbp = 7,
  192. },
  193. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  194. .name = "nec_nl2432dr22-11b",
  195. },
  196. /* Unknown panel used in OMAP H4 */
  197. {
  198. {
  199. .x_res = 240,
  200. .y_res = 320,
  201. .pixel_clock = 6250,
  202. .hsw = 15,
  203. .hfp = 15,
  204. .hbp = 60,
  205. .vsw = 1,
  206. .vfp = 1,
  207. .vbp = 1,
  208. },
  209. .name = "h4",
  210. },
  211. /* Unknown panel used in Samsung OMAP2 Apollon */
  212. {
  213. {
  214. .x_res = 480,
  215. .y_res = 272,
  216. .pixel_clock = 6250,
  217. .hsw = 41,
  218. .hfp = 2,
  219. .hbp = 2,
  220. .vsw = 10,
  221. .vfp = 2,
  222. .vbp = 2,
  223. },
  224. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  225. .name = "apollon",
  226. },
  227. /* FocalTech ETM070003DH6 */
  228. {
  229. {
  230. .x_res = 800,
  231. .y_res = 480,
  232. .pixel_clock = 28000,
  233. .hsw = 48,
  234. .hfp = 40,
  235. .hbp = 40,
  236. .vsw = 3,
  237. .vfp = 13,
  238. .vbp = 29,
  239. },
  240. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS,
  241. .name = "focaltech_etm070003dh6",
  242. },
  243. /* Microtips Technologies - UMSH-8173MD */
  244. {
  245. {
  246. .x_res = 800,
  247. .y_res = 480,
  248. .pixel_clock = 34560,
  249. .hsw = 13,
  250. .hfp = 101,
  251. .hbp = 101,
  252. .vsw = 23,
  253. .vfp = 1,
  254. .vbp = 1,
  255. },
  256. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  257. OMAP_DSS_LCD_IPC,
  258. .power_on_delay = 0,
  259. .power_off_delay = 0,
  260. .name = "microtips_umsh_8173md",
  261. },
  262. /* OrtusTech COM43H4M10XTC */
  263. {
  264. {
  265. .x_res = 480,
  266. .y_res = 272,
  267. .pixel_clock = 8000,
  268. .hsw = 41,
  269. .hfp = 8,
  270. .hbp = 4,
  271. .vsw = 10,
  272. .vfp = 4,
  273. .vbp = 2,
  274. },
  275. .name = "ortustech_com43h4m10xtc",
  276. },
  277. /* Innolux AT080TN52 */
  278. {
  279. {
  280. .x_res = 800,
  281. .y_res = 600,
  282. .pixel_clock = 41142,
  283. .hsw = 20,
  284. .hfp = 210,
  285. .hbp = 46,
  286. .vsw = 10,
  287. .vfp = 12,
  288. .vbp = 23,
  289. },
  290. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  291. OMAP_DSS_LCD_IEO,
  292. .name = "innolux_at080tn52",
  293. },
  294. /* Mitsubishi AA084SB01 */
  295. {
  296. {
  297. .x_res = 800,
  298. .y_res = 600,
  299. .pixel_clock = 40000,
  300. .hsw = 1,
  301. .hfp = 254,
  302. .hbp = 1,
  303. .vsw = 1,
  304. .vfp = 26,
  305. .vbp = 1,
  306. },
  307. .name = "mitsubishi_aa084sb01",
  308. },
  309. /* EDT ET0500G0DH6 */
  310. {
  311. {
  312. .x_res = 800,
  313. .y_res = 480,
  314. .pixel_clock = 33260,
  315. .hsw = 128,
  316. .hfp = 216,
  317. .hbp = 40,
  318. .vsw = 2,
  319. .vfp = 35,
  320. .vbp = 10,
  321. },
  322. .name = "edt_et0500g0dh6",
  323. },
  324. /* Prime-View PD050VL1 */
  325. {
  326. {
  327. .x_res = 640,
  328. .y_res = 480,
  329. .pixel_clock = 25000,
  330. .hsw = 96,
  331. .hfp = 18,
  332. .hbp = 46,
  333. .vsw = 2,
  334. .vfp = 10,
  335. .vbp = 33,
  336. },
  337. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  338. OMAP_DSS_LCD_IPC,
  339. .name = "primeview_pd050vl1",
  340. },
  341. /* Prime-View PM070WL4 */
  342. {
  343. {
  344. .x_res = 800,
  345. .y_res = 480,
  346. .pixel_clock = 32000,
  347. .hsw = 128,
  348. .hfp = 42,
  349. .hbp = 86,
  350. .vsw = 2,
  351. .vfp = 10,
  352. .vbp = 33,
  353. },
  354. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  355. OMAP_DSS_LCD_IPC,
  356. .name = "primeview_pm070wl4",
  357. },
  358. /* Prime-View PD104SLF */
  359. {
  360. {
  361. .x_res = 800,
  362. .y_res = 600,
  363. .pixel_clock = 40000,
  364. .hsw = 128,
  365. .hfp = 42,
  366. .hbp = 86,
  367. .vsw = 4,
  368. .vfp = 1,
  369. .vbp = 23,
  370. },
  371. .config = OMAP_DSS_LCD_IVS | OMAP_DSS_LCD_IHS |
  372. OMAP_DSS_LCD_IPC,
  373. .name = "primeview_pd104slf",
  374. },
  375. };
  376. struct panel_drv_data {
  377. struct omap_dss_device *dssdev;
  378. struct panel_config *panel_config;
  379. };
  380. static inline struct panel_generic_dpi_data
  381. *get_panel_data(const struct omap_dss_device *dssdev)
  382. {
  383. return (struct panel_generic_dpi_data *) dssdev->data;
  384. }
  385. static int generic_dpi_panel_power_on(struct omap_dss_device *dssdev)
  386. {
  387. int r;
  388. struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
  389. struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
  390. struct panel_config *panel_config = drv_data->panel_config;
  391. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  392. return 0;
  393. r = omapdss_dpi_display_enable(dssdev);
  394. if (r)
  395. goto err0;
  396. /* wait couple of vsyncs until enabling the LCD */
  397. if (panel_config->power_on_delay)
  398. msleep(panel_config->power_on_delay);
  399. if (panel_data->platform_enable) {
  400. r = panel_data->platform_enable(dssdev);
  401. if (r)
  402. goto err1;
  403. }
  404. return 0;
  405. err1:
  406. omapdss_dpi_display_disable(dssdev);
  407. err0:
  408. return r;
  409. }
  410. static void generic_dpi_panel_power_off(struct omap_dss_device *dssdev)
  411. {
  412. struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
  413. struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
  414. struct panel_config *panel_config = drv_data->panel_config;
  415. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
  416. return;
  417. if (panel_data->platform_disable)
  418. panel_data->platform_disable(dssdev);
  419. /* wait couple of vsyncs after disabling the LCD */
  420. if (panel_config->power_off_delay)
  421. msleep(panel_config->power_off_delay);
  422. omapdss_dpi_display_disable(dssdev);
  423. }
  424. static int generic_dpi_panel_probe(struct omap_dss_device *dssdev)
  425. {
  426. struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
  427. struct panel_config *panel_config = NULL;
  428. struct panel_drv_data *drv_data = NULL;
  429. int i;
  430. dev_dbg(&dssdev->dev, "probe\n");
  431. if (!panel_data || !panel_data->name)
  432. return -EINVAL;
  433. for (i = 0; i < ARRAY_SIZE(generic_dpi_panels); i++) {
  434. if (strcmp(panel_data->name, generic_dpi_panels[i].name) == 0) {
  435. panel_config = &generic_dpi_panels[i];
  436. break;
  437. }
  438. }
  439. if (!panel_config)
  440. return -EINVAL;
  441. dssdev->panel.config = panel_config->config;
  442. dssdev->panel.timings = panel_config->timings;
  443. drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
  444. if (!drv_data)
  445. return -ENOMEM;
  446. drv_data->dssdev = dssdev;
  447. drv_data->panel_config = panel_config;
  448. dev_set_drvdata(&dssdev->dev, drv_data);
  449. return 0;
  450. }
  451. static void __exit generic_dpi_panel_remove(struct omap_dss_device *dssdev)
  452. {
  453. struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
  454. dev_dbg(&dssdev->dev, "remove\n");
  455. kfree(drv_data);
  456. dev_set_drvdata(&dssdev->dev, NULL);
  457. }
  458. static int generic_dpi_panel_enable(struct omap_dss_device *dssdev)
  459. {
  460. int r = 0;
  461. r = generic_dpi_panel_power_on(dssdev);
  462. if (r)
  463. return r;
  464. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  465. return 0;
  466. }
  467. static void generic_dpi_panel_disable(struct omap_dss_device *dssdev)
  468. {
  469. generic_dpi_panel_power_off(dssdev);
  470. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  471. }
  472. static int generic_dpi_panel_suspend(struct omap_dss_device *dssdev)
  473. {
  474. generic_dpi_panel_power_off(dssdev);
  475. dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
  476. return 0;
  477. }
  478. static int generic_dpi_panel_resume(struct omap_dss_device *dssdev)
  479. {
  480. int r = 0;
  481. r = generic_dpi_panel_power_on(dssdev);
  482. if (r)
  483. return r;
  484. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  485. return 0;
  486. }
  487. static void generic_dpi_panel_set_timings(struct omap_dss_device *dssdev,
  488. struct omap_video_timings *timings)
  489. {
  490. dpi_set_timings(dssdev, timings);
  491. }
  492. static int generic_dpi_panel_check_timings(struct omap_dss_device *dssdev,
  493. struct omap_video_timings *timings)
  494. {
  495. return dpi_check_timings(dssdev, timings);
  496. }
  497. static struct omap_dss_driver dpi_driver = {
  498. .probe = generic_dpi_panel_probe,
  499. .remove = __exit_p(generic_dpi_panel_remove),
  500. .enable = generic_dpi_panel_enable,
  501. .disable = generic_dpi_panel_disable,
  502. .suspend = generic_dpi_panel_suspend,
  503. .resume = generic_dpi_panel_resume,
  504. .set_timings = generic_dpi_panel_set_timings,
  505. .check_timings = generic_dpi_panel_check_timings,
  506. .driver = {
  507. .name = "generic_dpi_panel",
  508. .owner = THIS_MODULE,
  509. },
  510. };
  511. static int __init generic_dpi_panel_drv_init(void)
  512. {
  513. return omap_dss_register_driver(&dpi_driver);
  514. }
  515. static void __exit generic_dpi_panel_drv_exit(void)
  516. {
  517. omap_dss_unregister_driver(&dpi_driver);
  518. }
  519. module_init(generic_dpi_panel_drv_init);
  520. module_exit(generic_dpi_panel_drv_exit);
  521. MODULE_LICENSE("GPL");