blob: 395a68de399048f90b388b64416531695a07e223 [file] [log] [blame]
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +02001/*
2 * Generic panel support
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/module.h>
21#include <linux/delay.h>
22
23#include <plat/display.h>
24
25static struct omap_video_timings generic_panel_timings = {
26 /* 640 x 480 @ 60 Hz Reduced blanking VESA CVT 0.31M3-R */
27 .x_res = 640,
28 .y_res = 480,
29 .pixel_clock = 23500,
30 .hfp = 48,
31 .hsw = 32,
32 .hbp = 80,
33 .vfp = 3,
34 .vsw = 4,
35 .vbp = 7,
36};
37
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020038static int generic_panel_power_on(struct omap_dss_device *dssdev)
39{
40 int r;
41
Stanley.Miao18016e32010-09-03 05:03:48 +020042 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
43 return 0;
44
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020045 r = omapdss_dpi_display_enable(dssdev);
46 if (r)
47 goto err0;
48
49 if (dssdev->platform_enable) {
50 r = dssdev->platform_enable(dssdev);
51 if (r)
52 goto err1;
53 }
54
55 return 0;
56err1:
57 omapdss_dpi_display_disable(dssdev);
58err0:
59 return r;
60}
61
62static void generic_panel_power_off(struct omap_dss_device *dssdev)
63{
Stanley.Miao18016e32010-09-03 05:03:48 +020064 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
65 return;
66
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020067 if (dssdev->platform_disable)
68 dssdev->platform_disable(dssdev);
69
70 omapdss_dpi_display_disable(dssdev);
71}
72
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020073static int generic_panel_probe(struct omap_dss_device *dssdev)
74{
75 dssdev->panel.config = OMAP_DSS_LCD_TFT;
76 dssdev->panel.timings = generic_panel_timings;
77
78 return 0;
79}
80
81static void generic_panel_remove(struct omap_dss_device *dssdev)
82{
83}
84
85static int generic_panel_enable(struct omap_dss_device *dssdev)
86{
87 int r = 0;
88
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020089 r = generic_panel_power_on(dssdev);
90 if (r)
91 return r;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020092
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020093 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
94
95 return 0;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020096}
97
98static void generic_panel_disable(struct omap_dss_device *dssdev)
99{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200100 generic_panel_power_off(dssdev);
101
102 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200103}
104
105static int generic_panel_suspend(struct omap_dss_device *dssdev)
106{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200107 generic_panel_power_off(dssdev);
108 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200109 return 0;
110}
111
112static int generic_panel_resume(struct omap_dss_device *dssdev)
113{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200114 int r = 0;
115
116 r = generic_panel_power_on(dssdev);
117 if (r)
118 return r;
119
120 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
121
122 return 0;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200123}
124
Tomi Valkeinen8871d542010-03-04 17:52:43 +0200125static void generic_panel_set_timings(struct omap_dss_device *dssdev,
126 struct omap_video_timings *timings)
127{
128 dpi_set_timings(dssdev, timings);
129}
130
131static void generic_panel_get_timings(struct omap_dss_device *dssdev,
132 struct omap_video_timings *timings)
133{
134 *timings = dssdev->panel.timings;
135}
136
137static int generic_panel_check_timings(struct omap_dss_device *dssdev,
138 struct omap_video_timings *timings)
139{
140 return dpi_check_timings(dssdev, timings);
141}
142
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200143static struct omap_dss_driver generic_driver = {
144 .probe = generic_panel_probe,
145 .remove = generic_panel_remove,
146
147 .enable = generic_panel_enable,
148 .disable = generic_panel_disable,
149 .suspend = generic_panel_suspend,
150 .resume = generic_panel_resume,
151
Tomi Valkeinen8871d542010-03-04 17:52:43 +0200152 .set_timings = generic_panel_set_timings,
153 .get_timings = generic_panel_get_timings,
154 .check_timings = generic_panel_check_timings,
155
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200156 .driver = {
157 .name = "generic_panel",
158 .owner = THIS_MODULE,
159 },
160};
161
162static int __init generic_panel_drv_init(void)
163{
164 return omap_dss_register_driver(&generic_driver);
165}
166
167static void __exit generic_panel_drv_exit(void)
168{
169 omap_dss_unregister_driver(&generic_driver);
170}
171
172module_init(generic_panel_drv_init);
173module_exit(generic_panel_drv_exit);
174MODULE_LICENSE("GPL");