Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux...
[pandora-kernel.git] / drivers / video / omap2 / displays / panel-toppoly-tdo35s.c
1 /*
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
29 static 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
45 static int toppoly_tdo_panel_power_on(struct omap_dss_device *dssdev)
46 {
47         int r;
48
49         if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
50                 return 0;
51
52         r = omapdss_dpi_display_enable(dssdev);
53         if (r)
54                 goto err0;
55
56         if (dssdev->platform_enable) {
57                 r = dssdev->platform_enable(dssdev);
58                 if (r)
59                         goto err1;
60         }
61
62         return 0;
63 err1:
64         omapdss_dpi_display_disable(dssdev);
65 err0:
66         return r;
67 }
68
69 static void toppoly_tdo_panel_power_off(struct omap_dss_device *dssdev)
70 {
71         if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
72                 return;
73
74         if (dssdev->platform_disable)
75                 dssdev->platform_disable(dssdev);
76
77         omapdss_dpi_display_disable(dssdev);
78 }
79
80 static int toppoly_tdo_panel_probe(struct omap_dss_device *dssdev)
81 {
82         dssdev->panel.config = OMAP_DSS_LCD_TFT |
83                                OMAP_DSS_LCD_IVS |
84                                OMAP_DSS_LCD_IHS |
85                                OMAP_DSS_LCD_IPC |
86                                OMAP_DSS_LCD_ONOFF;
87
88         dssdev->panel.timings = toppoly_tdo_panel_timings;
89
90         return 0;
91 }
92
93 static void toppoly_tdo_panel_remove(struct omap_dss_device *dssdev)
94 {
95 }
96
97 static int toppoly_tdo_panel_enable(struct omap_dss_device *dssdev)
98 {
99         int r = 0;
100
101         r = toppoly_tdo_panel_power_on(dssdev);
102         if (r)
103                 return r;
104
105         dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
106
107         return 0;
108 }
109
110 static void toppoly_tdo_panel_disable(struct omap_dss_device *dssdev)
111 {
112         toppoly_tdo_panel_power_off(dssdev);
113
114         dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
115 }
116
117 static int toppoly_tdo_panel_suspend(struct omap_dss_device *dssdev)
118 {
119         toppoly_tdo_panel_power_off(dssdev);
120         dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
121         return 0;
122 }
123
124 static int toppoly_tdo_panel_resume(struct omap_dss_device *dssdev)
125 {
126         int r = 0;
127
128         r = toppoly_tdo_panel_power_on(dssdev);
129         if (r)
130                 return r;
131
132         dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
133
134         return 0;
135 }
136
137 static struct omap_dss_driver generic_driver = {
138         .probe          = toppoly_tdo_panel_probe,
139         .remove         = toppoly_tdo_panel_remove,
140
141         .enable         = toppoly_tdo_panel_enable,
142         .disable        = toppoly_tdo_panel_disable,
143         .suspend        = toppoly_tdo_panel_suspend,
144         .resume         = toppoly_tdo_panel_resume,
145
146         .driver         = {
147                 .name   = "toppoly_tdo35s_panel",
148                 .owner  = THIS_MODULE,
149         },
150 };
151
152 static int __init toppoly_tdo_panel_drv_init(void)
153 {
154         return omap_dss_register_driver(&generic_driver);
155 }
156
157 static void __exit toppoly_tdo_panel_drv_exit(void)
158 {
159         omap_dss_unregister_driver(&generic_driver);
160 }
161
162 module_init(toppoly_tdo_panel_drv_init);
163 module_exit(toppoly_tdo_panel_drv_exit);
164 MODULE_LICENSE("GPL");