2 * Generic DPI Panels support
4 * Copyright (C) 2010 Canonical Ltd.
5 * Author: Bryan Wu <bryan.wu@canonical.com>
7 * LCD panel driver for Sharp LQ043T1DG01
9 * Copyright (C) 2009 Texas Instruments Inc
10 * Author: Vaibhav Hiremath <hvaibhav@ti.com>
12 * LCD panel driver for Toppoly TDO35S
14 * Copyright (C) 2009 CompuLab, Ltd.
15 * Author: Mike Rapoport <mike@compulab.co.il>
17 * Copyright (C) 2008 Nokia Corporation
18 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
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.
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
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/>.
33 #include <linux/module.h>
34 #include <linux/delay.h>
35 #include <linux/slab.h>
36 #include <video/omapdss.h>
38 #include <video/omap-panel-generic-dpi.h>
41 struct omap_video_timings timings;
43 int acbi; /* ac-bias pin transitions per interrupt */
44 /* Unit: line clocks */
45 int acb; /* ac-bias pin frequency */
47 enum omap_panel_config config;
53 * Used to match device to panel configuration
54 * when use generic panel driver
59 /* Panel configurations */
60 static struct panel_config generic_dpi_panels[] = {
79 .config = OMAP_DSS_LCD_TFT,
85 /* Sharp LQ043T1DG01 */
103 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
104 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO,
105 .power_on_delay = 50,
106 .power_off_delay = 100,
110 /* Sharp LS037V7DW01 */
116 .pixel_clock = 19200,
128 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
130 .power_on_delay = 50,
131 .power_off_delay = 100,
141 .pixel_clock = 26000,
153 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
154 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IPC |
157 .power_off_delay = 0,
158 .name = "toppoly_tdo35s",
161 /* Samsung LTE430WQ-F0C */
179 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
182 .power_off_delay = 0,
183 .name = "samsung_lte430wq_f0c",
186 /* Seiko 70WVW1TZ3Z3 */
192 .pixel_clock = 33000,
204 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
207 .power_off_delay = 0,
208 .name = "seiko_70wvw1tz3",
211 /* Powertip PH480272T */
229 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
230 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO,
232 .power_off_delay = 0,
233 .name = "powertip_ph480272t",
237 struct panel_drv_data {
239 struct omap_dss_device *dssdev;
241 struct panel_config *panel_config;
244 static inline struct panel_generic_dpi_data
245 *get_panel_data(const struct omap_dss_device *dssdev)
247 return (struct panel_generic_dpi_data *) dssdev->data;
250 static int generic_dpi_panel_power_on(struct omap_dss_device *dssdev)
253 struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
254 struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
255 struct panel_config *panel_config = drv_data->panel_config;
257 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
260 r = omapdss_dpi_display_enable(dssdev);
264 /* wait couple of vsyncs until enabling the LCD */
265 if (panel_config->power_on_delay)
266 msleep(panel_config->power_on_delay);
268 if (panel_data->platform_enable) {
269 r = panel_data->platform_enable(dssdev);
276 omapdss_dpi_display_disable(dssdev);
281 static void generic_dpi_panel_power_off(struct omap_dss_device *dssdev)
283 struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
284 struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
285 struct panel_config *panel_config = drv_data->panel_config;
287 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
290 if (panel_data->platform_disable)
291 panel_data->platform_disable(dssdev);
293 /* wait couple of vsyncs after disabling the LCD */
294 if (panel_config->power_off_delay)
295 msleep(panel_config->power_off_delay);
297 omapdss_dpi_display_disable(dssdev);
300 static int generic_dpi_panel_probe(struct omap_dss_device *dssdev)
302 struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
303 struct panel_config *panel_config = NULL;
304 struct panel_drv_data *drv_data = NULL;
307 dev_dbg(&dssdev->dev, "probe\n");
309 if (!panel_data || !panel_data->name)
312 for (i = 0; i < ARRAY_SIZE(generic_dpi_panels); i++) {
313 if (strcmp(panel_data->name, generic_dpi_panels[i].name) == 0) {
314 panel_config = &generic_dpi_panels[i];
322 dssdev->panel.config = panel_config->config;
323 dssdev->panel.timings = panel_config->timings;
324 dssdev->panel.acb = panel_config->acb;
325 dssdev->panel.acbi = panel_config->acbi;
327 drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
331 drv_data->dssdev = dssdev;
332 drv_data->panel_config = panel_config;
334 dev_set_drvdata(&dssdev->dev, drv_data);
339 static void __exit generic_dpi_panel_remove(struct omap_dss_device *dssdev)
341 struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
343 dev_dbg(&dssdev->dev, "remove\n");
347 dev_set_drvdata(&dssdev->dev, NULL);
350 static int generic_dpi_panel_enable(struct omap_dss_device *dssdev)
354 r = generic_dpi_panel_power_on(dssdev);
358 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
363 static void generic_dpi_panel_disable(struct omap_dss_device *dssdev)
365 generic_dpi_panel_power_off(dssdev);
367 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
370 static int generic_dpi_panel_suspend(struct omap_dss_device *dssdev)
372 generic_dpi_panel_power_off(dssdev);
374 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
379 static int generic_dpi_panel_resume(struct omap_dss_device *dssdev)
383 r = generic_dpi_panel_power_on(dssdev);
387 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
392 static void generic_dpi_panel_set_timings(struct omap_dss_device *dssdev,
393 struct omap_video_timings *timings)
395 dpi_set_timings(dssdev, timings);
398 static void generic_dpi_panel_get_timings(struct omap_dss_device *dssdev,
399 struct omap_video_timings *timings)
401 *timings = dssdev->panel.timings;
404 static int generic_dpi_panel_check_timings(struct omap_dss_device *dssdev,
405 struct omap_video_timings *timings)
407 return dpi_check_timings(dssdev, timings);
410 static struct omap_dss_driver dpi_driver = {
411 .probe = generic_dpi_panel_probe,
412 .remove = __exit_p(generic_dpi_panel_remove),
414 .enable = generic_dpi_panel_enable,
415 .disable = generic_dpi_panel_disable,
416 .suspend = generic_dpi_panel_suspend,
417 .resume = generic_dpi_panel_resume,
419 .set_timings = generic_dpi_panel_set_timings,
420 .get_timings = generic_dpi_panel_get_timings,
421 .check_timings = generic_dpi_panel_check_timings,
424 .name = "generic_dpi_panel",
425 .owner = THIS_MODULE,
429 static int __init generic_dpi_panel_drv_init(void)
431 return omap_dss_register_driver(&dpi_driver);
434 static void __exit generic_dpi_panel_drv_exit(void)
436 omap_dss_unregister_driver(&dpi_driver);
439 module_init(generic_dpi_panel_drv_init);
440 module_exit(generic_dpi_panel_drv_exit);
441 MODULE_LICENSE("GPL");