blob: e320e67d06f3e80cec9bd8f5008d7eb7a07b3b9c [file] [log] [blame]
Mike Rapoport751ef152009-12-14 09:01:07 +01001/*
2 * LCD panel driver for Toppoly TDO35S
3 *
4 * Copyright (C) 2009 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * Based on generic panel support
8 * Copyright (C) 2008 Nokia Corporation
9 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published by
13 * the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along with
21 * this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#include <linux/module.h>
25#include <linux/delay.h>
26
27#include <plat/display.h>
28
29static struct omap_video_timings toppoly_tdo_panel_timings = {
30 /* 640 x 480 @ 60 Hz Reduced blanking VESA CVT 0.31M3-R */
31 .x_res = 480,
32 .y_res = 640,
33
34 .pixel_clock = 26000,
35
36 .hfp = 104,
37 .hsw = 8,
38 .hbp = 8,
39
40 .vfp = 4,
41 .vsw = 2,
42 .vbp = 2,
43};
44
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020045static int toppoly_tdo_panel_power_on(struct omap_dss_device *dssdev)
46{
47 int r;
48
49 r = omapdss_dpi_display_enable(dssdev);
50 if (r)
51 goto err0;
52
53 if (dssdev->platform_enable) {
54 r = dssdev->platform_enable(dssdev);
55 if (r)
56 goto err1;
57 }
58
59 return 0;
60err1:
61 omapdss_dpi_display_disable(dssdev);
62err0:
63 return r;
64}
65
66static void toppoly_tdo_panel_power_off(struct omap_dss_device *dssdev)
67{
68 if (dssdev->platform_disable)
69 dssdev->platform_disable(dssdev);
70
71 omapdss_dpi_display_disable(dssdev);
72}
73
Mike Rapoport751ef152009-12-14 09:01:07 +010074static int toppoly_tdo_panel_probe(struct omap_dss_device *dssdev)
75{
Igor Grinberg451cfbf2010-07-12 12:42:50 +020076 dssdev->panel.config = OMAP_DSS_LCD_TFT |
77 OMAP_DSS_LCD_IVS |
78 OMAP_DSS_LCD_IHS |
79 OMAP_DSS_LCD_IPC |
80 OMAP_DSS_LCD_ONOFF;
81
Mike Rapoport751ef152009-12-14 09:01:07 +010082 dssdev->panel.timings = toppoly_tdo_panel_timings;
83
84 return 0;
85}
86
87static void toppoly_tdo_panel_remove(struct omap_dss_device *dssdev)
88{
89}
90
91static int toppoly_tdo_panel_enable(struct omap_dss_device *dssdev)
92{
93 int r = 0;
94
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020095 r = toppoly_tdo_panel_power_on(dssdev);
96 if (r)
97 return r;
Mike Rapoport751ef152009-12-14 09:01:07 +010098
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020099 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
100
101 return 0;
Mike Rapoport751ef152009-12-14 09:01:07 +0100102}
103
104static void toppoly_tdo_panel_disable(struct omap_dss_device *dssdev)
105{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200106 toppoly_tdo_panel_power_off(dssdev);
107
108 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
Mike Rapoport751ef152009-12-14 09:01:07 +0100109}
110
111static int toppoly_tdo_panel_suspend(struct omap_dss_device *dssdev)
112{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200113 toppoly_tdo_panel_power_off(dssdev);
114 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
Mike Rapoport751ef152009-12-14 09:01:07 +0100115 return 0;
116}
117
118static int toppoly_tdo_panel_resume(struct omap_dss_device *dssdev)
119{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200120 int r = 0;
121
122 r = toppoly_tdo_panel_power_on(dssdev);
123 if (r)
124 return r;
125
126 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
127
128 return 0;
Mike Rapoport751ef152009-12-14 09:01:07 +0100129}
130
131static struct omap_dss_driver generic_driver = {
132 .probe = toppoly_tdo_panel_probe,
133 .remove = toppoly_tdo_panel_remove,
134
135 .enable = toppoly_tdo_panel_enable,
136 .disable = toppoly_tdo_panel_disable,
137 .suspend = toppoly_tdo_panel_suspend,
138 .resume = toppoly_tdo_panel_resume,
139
140 .driver = {
141 .name = "toppoly_tdo35s_panel",
142 .owner = THIS_MODULE,
143 },
144};
145
146static int __init toppoly_tdo_panel_drv_init(void)
147{
148 return omap_dss_register_driver(&generic_driver);
149}
150
151static void __exit toppoly_tdo_panel_drv_exit(void)
152{
153 omap_dss_unregister_driver(&generic_driver);
154}
155
156module_init(toppoly_tdo_panel_drv_init);
157module_exit(toppoly_tdo_panel_drv_exit);
158MODULE_LICENSE("GPL");