diff options
author | Bryan Wu <bryan.wu@canonical.com> | 2010-11-17 08:34:33 -0500 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@nokia.com> | 2011-01-10 04:09:53 -0500 |
commit | a9a62b6a886545960488cae3b97acb482361b802 (patch) | |
tree | 2a823adb3f38f088abad13ef7cbc7dfbb573490f /drivers/video/omap2 | |
parent | 36e8c27f3bee5e58f96b0a79d65922fa9e53b030 (diff) |
OMAP: DSS2: Add generic DPI panel display driver
Generic DPI panel driver includes the driver and 4 similar panel configurations. It
will match the panel name which is passed from platform data and setup the
right configurations.
With generic DPI panel driver, we can remove those 4 duplicated panel display
drivers. In the future, it is simple for us just add new panel configuration
date in panel-generic-dpi.c to support new display panel.
Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Acked-by: Archit Taneja <archit@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Diffstat (limited to 'drivers/video/omap2')
-rw-r--r-- | drivers/video/omap2/displays/Kconfig | 8 | ||||
-rw-r--r-- | drivers/video/omap2/displays/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/omap2/displays/panel-generic-dpi.c | 355 |
3 files changed, 364 insertions, 0 deletions
diff --git a/drivers/video/omap2/displays/Kconfig b/drivers/video/omap2/displays/Kconfig index f8152cfedb5f..6d921969e731 100644 --- a/drivers/video/omap2/displays/Kconfig +++ b/drivers/video/omap2/displays/Kconfig | |||
@@ -1,6 +1,14 @@ | |||
1 | menu "OMAP2/3 Display Device Drivers" | 1 | menu "OMAP2/3 Display Device Drivers" |
2 | depends on OMAP2_DSS | 2 | depends on OMAP2_DSS |
3 | 3 | ||
4 | config PANEL_GENERIC_DPI | ||
5 | tristate "Generic DPI Panel" | ||
6 | help | ||
7 | Generic DPI panel driver. | ||
8 | Supports DVI output for Beagle and OMAP3 SDP. | ||
9 | Supports LCD Panel used in TI SDP3430 and EVM boards, | ||
10 | OMAP3517 EVM boards and CM-T35. | ||
11 | |||
4 | config PANEL_GENERIC | 12 | config PANEL_GENERIC |
5 | tristate "Generic Panel" | 13 | tristate "Generic Panel" |
6 | help | 14 | help |
diff --git a/drivers/video/omap2/displays/Makefile b/drivers/video/omap2/displays/Makefile index 8ece91cfe177..48f9c88af0c7 100644 --- a/drivers/video/omap2/displays/Makefile +++ b/drivers/video/omap2/displays/Makefile | |||
@@ -1,3 +1,4 @@ | |||
1 | obj-$(CONFIG_PANEL_GENERIC_DPI) += panel-generic-dpi.o | ||
1 | obj-$(CONFIG_PANEL_GENERIC) += panel-generic.o | 2 | obj-$(CONFIG_PANEL_GENERIC) += panel-generic.o |
2 | obj-$(CONFIG_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o | 3 | obj-$(CONFIG_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o |
3 | obj-$(CONFIG_PANEL_SHARP_LQ043T1DG01) += panel-sharp-lq043t1dg01.o | 4 | obj-$(CONFIG_PANEL_SHARP_LQ043T1DG01) += panel-sharp-lq043t1dg01.o |
diff --git a/drivers/video/omap2/displays/panel-generic-dpi.c b/drivers/video/omap2/displays/panel-generic-dpi.c new file mode 100644 index 000000000000..6702cf6d0a57 --- /dev/null +++ b/drivers/video/omap2/displays/panel-generic-dpi.c | |||
@@ -0,0 +1,355 @@ | |||
1 | /* | ||
2 | * Generic DPI Panels support | ||
3 | * | ||
4 | * Copyright (C) 2010 Canonical Ltd. | ||
5 | * Author: Bryan Wu <bryan.wu@canonical.com> | ||
6 | * | ||
7 | * Copyright (C) 2008 Nokia Corporation | ||
8 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License version 2 as published by | ||
12 | * the Free Software Foundation. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
17 | * more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along with | ||
20 | * this program. If not, see <http://www.gnu.org/licenses/>. | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <linux/slab.h> | ||
26 | |||
27 | #include <plat/panel-generic-dpi.h> | ||
28 | |||
29 | struct panel_config { | ||
30 | struct omap_video_timings timings; | ||
31 | |||
32 | int acbi; /* ac-bias pin transitions per interrupt */ | ||
33 | /* Unit: line clocks */ | ||
34 | int acb; /* ac-bias pin frequency */ | ||
35 | |||
36 | enum omap_panel_config config; | ||
37 | |||
38 | int power_on_delay; | ||
39 | int power_off_delay; | ||
40 | |||
41 | /* | ||
42 | * Used to match device to panel configuration | ||
43 | * when use generic panel driver | ||
44 | */ | ||
45 | const char *name; | ||
46 | }; | ||
47 | |||
48 | /* Panel configurations */ | ||
49 | static struct panel_config generic_dpi_panels[] = { | ||
50 | /* Generic Panel */ | ||
51 | { | ||
52 | { | ||
53 | .x_res = 640, | ||
54 | .y_res = 480, | ||
55 | |||
56 | .pixel_clock = 23500, | ||
57 | |||
58 | .hfp = 48, | ||
59 | .hsw = 32, | ||
60 | .hbp = 80, | ||
61 | |||
62 | .vfp = 3, | ||
63 | .vsw = 4, | ||
64 | .vbp = 7, | ||
65 | }, | ||
66 | .acbi = 0x0, | ||
67 | .acb = 0x0, | ||
68 | .config = OMAP_DSS_LCD_TFT, | ||
69 | .power_on_delay = 0, | ||
70 | .power_off_delay = 0, | ||
71 | .name = "generic", | ||
72 | }, | ||
73 | |||
74 | /* Sharp LQ043T1DG01 */ | ||
75 | { | ||
76 | { | ||
77 | .x_res = 480, | ||
78 | .y_res = 272, | ||
79 | |||
80 | .pixel_clock = 9000, | ||
81 | |||
82 | .hsw = 42, | ||
83 | .hfp = 3, | ||
84 | .hbp = 2, | ||
85 | |||
86 | .vsw = 11, | ||
87 | .vfp = 3, | ||
88 | .vbp = 2, | ||
89 | }, | ||
90 | .acbi = 0x0, | ||
91 | .acb = 0x0, | ||
92 | .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | | ||
93 | OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO, | ||
94 | .power_on_delay = 50, | ||
95 | .power_off_delay = 100, | ||
96 | .name = "sharp_lq", | ||
97 | }, | ||
98 | |||
99 | /* Sharp LS037V7DW01 */ | ||
100 | { | ||
101 | { | ||
102 | .x_res = 480, | ||
103 | .y_res = 640, | ||
104 | |||
105 | .pixel_clock = 19200, | ||
106 | |||
107 | .hsw = 2, | ||
108 | .hfp = 1, | ||
109 | .hbp = 28, | ||
110 | |||
111 | .vsw = 1, | ||
112 | .vfp = 1, | ||
113 | .vbp = 1, | ||
114 | }, | ||
115 | .acbi = 0x0, | ||
116 | .acb = 0x28, | ||
117 | .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | | ||
118 | OMAP_DSS_LCD_IHS, | ||
119 | .power_on_delay = 50, | ||
120 | .power_off_delay = 100, | ||
121 | .name = "sharp_ls", | ||
122 | }, | ||
123 | |||
124 | /* Toppoly TDO35S */ | ||
125 | { | ||
126 | { | ||
127 | .x_res = 480, | ||
128 | .y_res = 640, | ||
129 | |||
130 | .pixel_clock = 26000, | ||
131 | |||
132 | .hfp = 104, | ||
133 | .hsw = 8, | ||
134 | .hbp = 8, | ||
135 | |||
136 | .vfp = 4, | ||
137 | .vsw = 2, | ||
138 | .vbp = 2, | ||
139 | }, | ||
140 | .acbi = 0x0, | ||
141 | .acb = 0x0, | ||
142 | .config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | | ||
143 | OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IPC | | ||
144 | OMAP_DSS_LCD_ONOFF, | ||
145 | .power_on_delay = 0, | ||
146 | .power_off_delay = 0, | ||
147 | .name = "toppoly_tdo35s", | ||
148 | }, | ||
149 | }; | ||
150 | |||
151 | struct panel_drv_data { | ||
152 | |||
153 | struct omap_dss_device *dssdev; | ||
154 | |||
155 | struct panel_config *panel_config; | ||
156 | }; | ||
157 | |||
158 | static inline struct panel_generic_dpi_data | ||
159 | *get_panel_data(const struct omap_dss_device *dssdev) | ||
160 | { | ||
161 | return (struct panel_generic_dpi_data *) dssdev->data; | ||
162 | } | ||
163 | |||
164 | static int generic_dpi_panel_power_on(struct omap_dss_device *dssdev) | ||
165 | { | ||
166 | int r; | ||
167 | struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev); | ||
168 | struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev); | ||
169 | struct panel_config *panel_config = drv_data->panel_config; | ||
170 | |||
171 | if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) | ||
172 | return 0; | ||
173 | |||
174 | r = omapdss_dpi_display_enable(dssdev); | ||
175 | if (r) | ||
176 | goto err0; | ||
177 | |||
178 | /* wait couple of vsyncs until enabling the LCD */ | ||
179 | if (panel_config->power_on_delay) | ||
180 | msleep(panel_config->power_on_delay); | ||
181 | |||
182 | if (panel_data->platform_enable) { | ||
183 | r = panel_data->platform_enable(dssdev); | ||
184 | if (r) | ||
185 | goto err1; | ||
186 | } | ||
187 | |||
188 | return 0; | ||
189 | err1: | ||
190 | omapdss_dpi_display_disable(dssdev); | ||
191 | err0: | ||
192 | return r; | ||
193 | } | ||
194 | |||
195 | static void generic_dpi_panel_power_off(struct omap_dss_device *dssdev) | ||
196 | { | ||
197 | struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev); | ||
198 | struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev); | ||
199 | struct panel_config *panel_config = drv_data->panel_config; | ||
200 | |||
201 | if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) | ||
202 | return; | ||
203 | |||
204 | if (panel_data->platform_disable) | ||
205 | panel_data->platform_disable(dssdev); | ||
206 | |||
207 | /* wait couple of vsyncs after disabling the LCD */ | ||
208 | if (panel_config->power_off_delay) | ||
209 | msleep(panel_config->power_off_delay); | ||
210 | |||
211 | omapdss_dpi_display_disable(dssdev); | ||
212 | } | ||
213 | |||
214 | static int generic_dpi_panel_probe(struct omap_dss_device *dssdev) | ||
215 | { | ||
216 | struct panel_generic_dpi_data *panel_data = get_panel_data(dssdev); | ||
217 | struct panel_config *panel_config = NULL; | ||
218 | struct panel_drv_data *drv_data = NULL; | ||
219 | int i; | ||
220 | |||
221 | dev_dbg(&dssdev->dev, "probe\n"); | ||
222 | |||
223 | if (!panel_data || !panel_data->name) | ||
224 | return -EINVAL; | ||
225 | |||
226 | for (i = 0; i < ARRAY_SIZE(generic_dpi_panels); i++) { | ||
227 | if (strcmp(panel_data->name, generic_dpi_panels[i].name) == 0) { | ||
228 | panel_config = &generic_dpi_panels[i]; | ||
229 | break; | ||
230 | } | ||
231 | } | ||
232 | |||
233 | if (!panel_config) | ||
234 | return -EINVAL; | ||
235 | |||
236 | dssdev->panel.config = panel_config->config; | ||
237 | dssdev->panel.timings = panel_config->timings; | ||
238 | dssdev->panel.acb = panel_config->acb; | ||
239 | dssdev->panel.acbi = panel_config->acbi; | ||
240 | |||
241 | drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); | ||
242 | if (!drv_data) | ||
243 | return -ENOMEM; | ||
244 | |||
245 | drv_data->dssdev = dssdev; | ||
246 | drv_data->panel_config = panel_config; | ||
247 | |||
248 | dev_set_drvdata(&dssdev->dev, drv_data); | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | static void generic_dpi_panel_remove(struct omap_dss_device *dssdev) | ||
254 | { | ||
255 | struct panel_drv_data *drv_data = dev_get_drvdata(&dssdev->dev); | ||
256 | |||
257 | dev_dbg(&dssdev->dev, "remove\n"); | ||
258 | |||
259 | kfree(drv_data); | ||
260 | |||
261 | dev_set_drvdata(&dssdev->dev, NULL); | ||
262 | } | ||
263 | |||
264 | static int generic_dpi_panel_enable(struct omap_dss_device *dssdev) | ||
265 | { | ||
266 | int r = 0; | ||
267 | |||
268 | r = generic_dpi_panel_power_on(dssdev); | ||
269 | if (r) | ||
270 | return r; | ||
271 | |||
272 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | |||
277 | static void generic_dpi_panel_disable(struct omap_dss_device *dssdev) | ||
278 | { | ||
279 | generic_dpi_panel_power_off(dssdev); | ||
280 | |||
281 | dssdev->state = OMAP_DSS_DISPLAY_DISABLED; | ||
282 | } | ||
283 | |||
284 | static int generic_dpi_panel_suspend(struct omap_dss_device *dssdev) | ||
285 | { | ||
286 | generic_dpi_panel_power_off(dssdev); | ||
287 | |||
288 | dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED; | ||
289 | |||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | static int generic_dpi_panel_resume(struct omap_dss_device *dssdev) | ||
294 | { | ||
295 | int r = 0; | ||
296 | |||
297 | r = generic_dpi_panel_power_on(dssdev); | ||
298 | if (r) | ||
299 | return r; | ||
300 | |||
301 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; | ||
302 | |||
303 | return 0; | ||
304 | } | ||
305 | |||
306 | static void generic_dpi_panel_set_timings(struct omap_dss_device *dssdev, | ||
307 | struct omap_video_timings *timings) | ||
308 | { | ||
309 | dpi_set_timings(dssdev, timings); | ||
310 | } | ||
311 | |||
312 | static void generic_dpi_panel_get_timings(struct omap_dss_device *dssdev, | ||
313 | struct omap_video_timings *timings) | ||
314 | { | ||
315 | *timings = dssdev->panel.timings; | ||
316 | } | ||
317 | |||
318 | static int generic_dpi_panel_check_timings(struct omap_dss_device *dssdev, | ||
319 | struct omap_video_timings *timings) | ||
320 | { | ||
321 | return dpi_check_timings(dssdev, timings); | ||
322 | } | ||
323 | |||
324 | static struct omap_dss_driver dpi_driver = { | ||
325 | .probe = generic_dpi_panel_probe, | ||
326 | .remove = generic_dpi_panel_remove, | ||
327 | |||
328 | .enable = generic_dpi_panel_enable, | ||
329 | .disable = generic_dpi_panel_disable, | ||
330 | .suspend = generic_dpi_panel_suspend, | ||
331 | .resume = generic_dpi_panel_resume, | ||
332 | |||
333 | .set_timings = generic_dpi_panel_set_timings, | ||
334 | .get_timings = generic_dpi_panel_get_timings, | ||
335 | .check_timings = generic_dpi_panel_check_timings, | ||
336 | |||
337 | .driver = { | ||
338 | .name = "generic_dpi_panel", | ||
339 | .owner = THIS_MODULE, | ||
340 | }, | ||
341 | }; | ||
342 | |||
343 | static int __init generic_dpi_panel_drv_init(void) | ||
344 | { | ||
345 | return omap_dss_register_driver(&dpi_driver); | ||
346 | } | ||
347 | |||
348 | static void __exit generic_dpi_panel_drv_exit(void) | ||
349 | { | ||
350 | omap_dss_unregister_driver(&dpi_driver); | ||
351 | } | ||
352 | |||
353 | module_init(generic_dpi_panel_drv_init); | ||
354 | module_exit(generic_dpi_panel_drv_exit); | ||
355 | MODULE_LICENSE("GPL"); | ||