panel-generic-dpi.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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. int acbi; /* ac-bias pin transitions per interrupt */
  40. /* Unit: line clocks */
  41. int acb; /* ac-bias pin frequency */
  42. enum omap_panel_config config;
  43. int power_on_delay;
  44. int power_off_delay;
  45. /*
  46. * Used to match device to panel configuration
  47. * when use generic panel driver
  48. */
  49. const char *name;
  50. };
  51. /* Panel configurations */
  52. static struct panel_config generic_dpi_panels[] = {
  53. /* Sharp LQ043T1DG01 */
  54. {
  55. {
  56. .x_res = 480,
  57. .y_res = 272,
  58. .pixel_clock = 9000,
  59. .hsw = 42,
  60. .hfp = 3,
  61. .hbp = 2,
  62. .vsw = 11,
  63. .vfp = 3,
  64. .vbp = 2,
  65. },
  66. .acbi = 0x0,
  67. .acb = 0x0,
  68. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  69. OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO,
  70. .power_on_delay = 50,
  71. .power_off_delay = 100,
  72. .name = "sharp_lq",
  73. },
  74. /* Sharp LS037V7DW01 */
  75. {
  76. {
  77. .x_res = 480,
  78. .y_res = 640,
  79. .pixel_clock = 19200,
  80. .hsw = 2,
  81. .hfp = 1,
  82. .hbp = 28,
  83. .vsw = 1,
  84. .vfp = 1,
  85. .vbp = 1,
  86. },
  87. .acbi = 0x0,
  88. .acb = 0x28,
  89. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  90. OMAP_DSS_LCD_IHS,
  91. .power_on_delay = 50,
  92. .power_off_delay = 100,
  93. .name = "sharp_ls",
  94. },
  95. /* Toppoly TDO35S */
  96. {
  97. {
  98. .x_res = 480,
  99. .y_res = 640,
  100. .pixel_clock = 26000,
  101. .hfp = 104,
  102. .hsw = 8,
  103. .hbp = 8,
  104. .vfp = 4,
  105. .vsw = 2,
  106. .vbp = 2,
  107. },
  108. .acbi = 0x0,
  109. .acb = 0x0,
  110. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  111. OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IPC |
  112. OMAP_DSS_LCD_ONOFF,
  113. .power_on_delay = 0,
  114. .power_off_delay = 0,
  115. .name = "toppoly_tdo35s",
  116. },
  117. /* Samsung LTE430WQ-F0C */
  118. {
  119. {
  120. .x_res = 480,
  121. .y_res = 272,
  122. .pixel_clock = 9200,
  123. .hfp = 8,
  124. .hsw = 41,
  125. .hbp = 45 - 41,
  126. .vfp = 4,
  127. .vsw = 10,
  128. .vbp = 12 - 10,
  129. },
  130. .acbi = 0x0,
  131. .acb = 0x0,
  132. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  133. OMAP_DSS_LCD_IHS,
  134. .power_on_delay = 0,
  135. .power_off_delay = 0,
  136. .name = "samsung_lte430wq_f0c",
  137. },
  138. /* Seiko 70WVW1TZ3Z3 */
  139. {
  140. {
  141. .x_res = 800,
  142. .y_res = 480,
  143. .pixel_clock = 33000,
  144. .hsw = 128,
  145. .hfp = 10,
  146. .hbp = 10,
  147. .vsw = 2,
  148. .vfp = 4,
  149. .vbp = 11,
  150. },
  151. .acbi = 0x0,
  152. .acb = 0x0,
  153. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  154. OMAP_DSS_LCD_IHS,
  155. .power_on_delay = 0,
  156. .power_off_delay = 0,
  157. .name = "seiko_70wvw1tz3",
  158. },
  159. /* Powertip PH480272T */
  160. {
  161. {
  162. .x_res = 480,
  163. .y_res = 272,
  164. .pixel_clock = 9000,
  165. .hsw = 40,
  166. .hfp = 2,
  167. .hbp = 2,
  168. .vsw = 10,
  169. .vfp = 2,
  170. .vbp = 2,
  171. },
  172. .acbi = 0x0,
  173. .acb = 0x0,
  174. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  175. OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO,
  176. .power_on_delay = 0,
  177. .power_off_delay = 0,
  178. .name = "powertip_ph480272t",
  179. },
  180. /* Innolux AT070TN83 */
  181. {
  182. {
  183. .x_res = 800,
  184. .y_res = 480,
  185. .pixel_clock = 40000,
  186. .hsw = 48,
  187. .hfp = 1,
  188. .hbp = 1,
  189. .vsw = 3,
  190. .vfp = 12,
  191. .vbp = 25,
  192. },
  193. .acbi = 0x0,
  194. .acb = 0x28,
  195. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  196. OMAP_DSS_LCD_IHS,
  197. .power_on_delay = 0,
  198. .power_off_delay = 0,
  199. .name = "innolux_at070tn83",
  200. },
  201. /* NEC NL2432DR22-11B */
  202. {
  203. {
  204. .x_res = 240,
  205. .y_res = 320,
  206. .pixel_clock = 5400,
  207. .hsw = 3,
  208. .hfp = 3,
  209. .hbp = 39,
  210. .vsw = 1,
  211. .vfp = 2,
  212. .vbp = 7,
  213. },
  214. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  215. OMAP_DSS_LCD_IHS,
  216. .name = "nec_nl2432dr22-11b",
  217. },
  218. /* Unknown panel used in OMAP H4 */
  219. {
  220. {
  221. .x_res = 240,
  222. .y_res = 320,
  223. .pixel_clock = 6250,
  224. .hsw = 15,
  225. .hfp = 15,
  226. .hbp = 60,
  227. .vsw = 1,
  228. .vfp = 1,
  229. .vbp = 1,
  230. },
  231. .config = OMAP_DSS_LCD_TFT,
  232. .name = "h4",
  233. },
  234. /* Unknown panel used in Samsung OMAP2 Apollon */
  235. {
  236. {
  237. .x_res = 480,
  238. .y_res = 272,
  239. .pixel_clock = 6250,
  240. .hsw = 41,
  241. .hfp = 2,
  242. .hbp = 2,
  243. .vsw = 10,
  244. .vfp = 2,
  245. .vbp = 2,
  246. },
  247. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  248. OMAP_DSS_LCD_IHS,
  249. .name = "apollon",
  250. },
  251. /* FocalTech ETM070003DH6 */
  252. {
  253. {
  254. .x_res = 800,
  255. .y_res = 480,
  256. .pixel_clock = 28000,
  257. .hsw = 48,
  258. .hfp = 40,
  259. .hbp = 40,
  260. .vsw = 3,
  261. .vfp = 13,
  262. .vbp = 29,
  263. },
  264. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  265. OMAP_DSS_LCD_IHS,
  266. .name = "focaltech_etm070003dh6",
  267. },
  268. /* Microtips Technologies - UMSH-8173MD */
  269. {
  270. {
  271. .x_res = 800,
  272. .y_res = 480,
  273. .pixel_clock = 34560,
  274. .hsw = 13,
  275. .hfp = 101,
  276. .hbp = 101,
  277. .vsw = 23,
  278. .vfp = 1,
  279. .vbp = 1,
  280. },
  281. .acbi = 0x0,
  282. .acb = 0x0,
  283. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  284. OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IPC,
  285. .power_on_delay = 0,
  286. .power_off_delay = 0,
  287. .name = "microtips_umsh_8173md",
  288. },
  289. /* OrtusTech COM43H4M10XTC */
  290. {
  291. {
  292. .x_res = 480,
  293. .y_res = 272,
  294. .pixel_clock = 8000,
  295. .hsw = 41,
  296. .hfp = 8,
  297. .hbp = 4,
  298. .vsw = 10,
  299. .vfp = 4,
  300. .vbp = 2,
  301. },
  302. .config = OMAP_DSS_LCD_TFT,
  303. .name = "ortustech_com43h4m10xtc",
  304. },
  305. /* Innolux AT080TN52 */
  306. {
  307. {
  308. .x_res = 800,
  309. .y_res = 600,
  310. .pixel_clock = 41142,
  311. .hsw = 20,
  312. .hfp = 210,
  313. .hbp = 46,
  314. .vsw = 10,
  315. .vfp = 12,
  316. .vbp = 23,
  317. },
  318. .acb = 0x0,
  319. .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
  320. OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO,
  321. .name = "innolux_at080tn52",
  322. },
  323. };
  324. struct panel_drv_data {
  325. struct omap_dss_device *dssdev;
  326. struct panel_config *panel_config;
  327. };
  328. static inline struct panel_generic_dpi_data
  329. *get_panel_data(const struct omap_dss_device *dssdev)
  330. {
  331. return (struct panel_generic_dpi_data *) dssdev->data;
  332. }
  333. static int generic_dpi_panel_power_on(struct omap_dss_device *dssdev)
  334. {
  335. int r;
  336. struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
  337. struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
  338. struct panel_config *panel_config = drv_data->panel_config;
  339. if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
  340. return 0;
  341. r = omapdss_dpi_display_enable(dssdev);
  342. if (r)
  343. goto err0;
  344. /* wait couple of vsyncs until enabling the LCD */
  345. if (panel_config->power_on_delay)
  346. msleep(panel_config->power_on_delay);
  347. if (panel_data->platform_enable) {
  348. r = panel_data->platform_enable(dssdev);
  349. if (r)
  350. goto err1;
  351. }
  352. return 0;
  353. err1:
  354. omapdss_dpi_display_disable(dssdev);
  355. err0:
  356. return r;
  357. }
  358. static void generic_dpi_panel_power_off(struct omap_dss_device *dssdev)
  359. {
  360. struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
  361. struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
  362. struct panel_config *panel_config = drv_data->panel_config;
  363. if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
  364. return;
  365. if (panel_data->platform_disable)
  366. panel_data->platform_disable(dssdev);
  367. /* wait couple of vsyncs after disabling the LCD */
  368. if (panel_config->power_off_delay)
  369. msleep(panel_config->power_off_delay);
  370. omapdss_dpi_display_disable(dssdev);
  371. }
  372. static int generic_dpi_panel_probe(struct omap_dss_device *dssdev)
  373. {
  374. struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
  375. struct panel_config *panel_config = NULL;
  376. struct panel_drv_data *drv_data = NULL;
  377. int i;
  378. dev_dbg(&dssdev->dev, "probe\n");
  379. if (!panel_data || !panel_data->name)
  380. return -EINVAL;
  381. for (i = 0; i < ARRAY_SIZE(generic_dpi_panels); i++) {
  382. if (strcmp(panel_data->name, generic_dpi_panels[i].name) == 0) {
  383. panel_config = &generic_dpi_panels[i];
  384. break;
  385. }
  386. }
  387. if (!panel_config)
  388. return -EINVAL;
  389. dssdev->panel.config = panel_config->config;
  390. dssdev->panel.timings = panel_config->timings;
  391. dssdev->panel.acb = panel_config->acb;
  392. dssdev->panel.acbi = panel_config->acbi;
  393. drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
  394. if (!drv_data)
  395. return -ENOMEM;
  396. drv_data->dssdev = dssdev;
  397. drv_data->panel_config = panel_config;
  398. dev_set_drvdata(&dssdev->dev, drv_data);
  399. return 0;
  400. }
  401. static void __exit generic_dpi_panel_remove(struct omap_dss_device *dssdev)
  402. {
  403. struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
  404. dev_dbg(&dssdev->dev, "remove\n");
  405. kfree(drv_data);
  406. dev_set_drvdata(&dssdev->dev, NULL);
  407. }
  408. static int generic_dpi_panel_enable(struct omap_dss_device *dssdev)
  409. {
  410. int r = 0;
  411. r = generic_dpi_panel_power_on(dssdev);
  412. if (r)
  413. return r;
  414. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  415. return 0;
  416. }
  417. static void generic_dpi_panel_disable(struct omap_dss_device *dssdev)
  418. {
  419. generic_dpi_panel_power_off(dssdev);
  420. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  421. }
  422. static int generic_dpi_panel_suspend(struct omap_dss_device *dssdev)
  423. {
  424. generic_dpi_panel_power_off(dssdev);
  425. dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
  426. return 0;
  427. }
  428. static int generic_dpi_panel_resume(struct omap_dss_device *dssdev)
  429. {
  430. int r = 0;
  431. r = generic_dpi_panel_power_on(dssdev);
  432. if (r)
  433. return r;
  434. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  435. return 0;
  436. }
  437. static void generic_dpi_panel_set_timings(struct omap_dss_device *dssdev,
  438. struct omap_video_timings *timings)
  439. {
  440. dpi_set_timings(dssdev, timings);
  441. }
  442. static void generic_dpi_panel_get_timings(struct omap_dss_device *dssdev,
  443. struct omap_video_timings *timings)
  444. {
  445. *timings = dssdev->panel.timings;
  446. }
  447. static int generic_dpi_panel_check_timings(struct omap_dss_device *dssdev,
  448. struct omap_video_timings *timings)
  449. {
  450. return dpi_check_timings(dssdev, timings);
  451. }
  452. static struct omap_dss_driver dpi_driver = {
  453. .probe = generic_dpi_panel_probe,
  454. .remove = __exit_p(generic_dpi_panel_remove),
  455. .enable = generic_dpi_panel_enable,
  456. .disable = generic_dpi_panel_disable,
  457. .suspend = generic_dpi_panel_suspend,
  458. .resume = generic_dpi_panel_resume,
  459. .set_timings = generic_dpi_panel_set_timings,
  460. .get_timings = generic_dpi_panel_get_timings,
  461. .check_timings = generic_dpi_panel_check_timings,
  462. .driver = {
  463. .name = "generic_dpi_panel",
  464. .owner = THIS_MODULE,
  465. },
  466. };
  467. static int __init generic_dpi_panel_drv_init(void)
  468. {
  469. return omap_dss_register_driver(&dpi_driver);
  470. }
  471. static void __exit generic_dpi_panel_drv_exit(void)
  472. {
  473. omap_dss_unregister_driver(&dpi_driver);
  474. }
  475. module_init(generic_dpi_panel_drv_init);
  476. module_exit(generic_dpi_panel_drv_exit);
  477. MODULE_LICENSE("GPL");