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>
37 #include <plat/panel-generic-dpi.h>
40 struct omap_video_timings timings;
42 int acbi; /* ac-bias pin transitions per interrupt */
43 /* Unit: line clocks */
44 int acb; /* ac-bias pin frequency */
46 enum omap_panel_config config;
52 * Used to match device to panel configuration
53 * when use generic panel driver
58 /* Panel configurations */
59 static struct panel_config generic_dpi_panels[] = {
78 .config = OMAP_DSS_LCD_TFT,
84 /* Sharp LQ043T1DG01 */
102 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
103 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO,
104 .power_on_delay = 50,
105 .power_off_delay = 100,
109 /* Sharp LS037V7DW01 */
115 .pixel_clock = 19200,
127 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
129 .power_on_delay = 50,
130 .power_off_delay = 100,
140 .pixel_clock = 26000,
152 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
153 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IPC |
156 .power_off_delay = 0,
157 .name = "toppoly_tdo35s",
160 /* Samsung LTE430WQ-F0C */
178 .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
181 .power_off_delay = 0,
182 .name = "samsung_lte430wq_f0c",
186 struct panel_drv_data {
188 struct omap_dss_device *dssdev;
190 struct panel_config *panel_config;
193 static inline struct panel_generic_dpi_data
194 *get_panel_data(const struct omap_dss_device *dssdev)
196 return (struct panel_generic_dpi_data *) dssdev->data;
199 static int generic_dpi_panel_power_on(struct omap_dss_device *dssdev)
202 struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
203 struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
204 struct panel_config *panel_config = drv_data->panel_config;
206 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
209 r = omapdss_dpi_display_enable(dssdev);
213 /* wait couple of vsyncs until enabling the LCD */
214 if (panel_config->power_on_delay)
215 msleep(panel_config->power_on_delay);
217 if (panel_data->platform_enable) {
218 r = panel_data->platform_enable(dssdev);
225 omapdss_dpi_display_disable(dssdev);
230 static void generic_dpi_panel_power_off(struct omap_dss_device *dssdev)
232 struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
233 struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
234 struct panel_config *panel_config = drv_data->panel_config;
236 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
239 if (panel_data->platform_disable)
240 panel_data->platform_disable(dssdev);
242 /* wait couple of vsyncs after disabling the LCD */
243 if (panel_config->power_off_delay)
244 msleep(panel_config->power_off_delay);
246 omapdss_dpi_display_disable(dssdev);
249 static int generic_dpi_panel_probe(struct omap_dss_device *dssdev)
251 struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev);
252 struct panel_config *panel_config = NULL;
253 struct panel_drv_data *drv_data = NULL;
256 dev_dbg(&dssdev->dev, "probe\n");
258 if (!panel_data || !panel_data->name)
261 for (i = 0; i < ARRAY_SIZE(generic_dpi_panels); i++) {
262 if (strcmp(panel_data->name, generic_dpi_panels[i].name) == 0) {
263 panel_config = &generic_dpi_panels[i];
271 dssdev->panel.config = panel_config->config;
272 dssdev->panel.timings = panel_config->timings;
273 dssdev->panel.acb = panel_config->acb;
274 dssdev->panel.acbi = panel_config->acbi;
276 drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL);
280 drv_data->dssdev = dssdev;
281 drv_data->panel_config = panel_config;
283 dev_set_drvdata(&dssdev->dev, drv_data);
288 static void generic_dpi_panel_remove(struct omap_dss_device *dssdev)
290 struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev);
292 dev_dbg(&dssdev->dev, "remove\n");
296 dev_set_drvdata(&dssdev->dev, NULL);
299 static int generic_dpi_panel_enable(struct omap_dss_device *dssdev)
303 r = generic_dpi_panel_power_on(dssdev);
307 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
312 static void generic_dpi_panel_disable(struct omap_dss_device *dssdev)
314 generic_dpi_panel_power_off(dssdev);
316 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
319 static int generic_dpi_panel_suspend(struct omap_dss_device *dssdev)
321 generic_dpi_panel_power_off(dssdev);
323 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
328 static int generic_dpi_panel_resume(struct omap_dss_device *dssdev)
332 r = generic_dpi_panel_power_on(dssdev);
336 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
341 static void generic_dpi_panel_set_timings(struct omap_dss_device *dssdev,
342 struct omap_video_timings *timings)
344 dpi_set_timings(dssdev, timings);
347 static void generic_dpi_panel_get_timings(struct omap_dss_device *dssdev,
348 struct omap_video_timings *timings)
350 *timings = dssdev->panel.timings;
353 static int generic_dpi_panel_check_timings(struct omap_dss_device *dssdev,
354 struct omap_video_timings *timings)
356 return dpi_check_timings(dssdev, timings);
359 static struct omap_dss_driver dpi_driver = {
360 .probe = generic_dpi_panel_probe,
361 .remove = generic_dpi_panel_remove,
363 .enable = generic_dpi_panel_enable,
364 .disable = generic_dpi_panel_disable,
365 .suspend = generic_dpi_panel_suspend,
366 .resume = generic_dpi_panel_resume,
368 .set_timings = generic_dpi_panel_set_timings,
369 .get_timings = generic_dpi_panel_get_timings,
370 .check_timings = generic_dpi_panel_check_timings,
373 .name = "generic_dpi_panel",
374 .owner = THIS_MODULE,
378 static int __init generic_dpi_panel_drv_init(void)
380 return omap_dss_register_driver(&dpi_driver);
383 static void __exit generic_dpi_panel_drv_exit(void)
385 omap_dss_unregister_driver(&dpi_driver);
388 module_init(generic_dpi_panel_drv_init);
389 module_exit(generic_dpi_panel_drv_exit);
390 MODULE_LICENSE("GPL");