blob: 300eff5de1b4830490e6a5f36d48adf8b63a5b1e [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
42 r = omapdss_dpi_display_enable(dssdev);
43 if (r)
44 goto err0;
45
46 if (dssdev->platform_enable) {
47 r = dssdev->platform_enable(dssdev);
48 if (r)
49 goto err1;
50 }
51
52 return 0;
53err1:
54 omapdss_dpi_display_disable(dssdev);
55err0:
56 return r;
57}
58
59static void generic_panel_power_off(struct omap_dss_device *dssdev)
60{
61 if (dssdev->platform_disable)
62 dssdev->platform_disable(dssdev);
63
64 omapdss_dpi_display_disable(dssdev);
65}
66
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020067static int generic_panel_probe(struct omap_dss_device *dssdev)
68{
69 dssdev->panel.config = OMAP_DSS_LCD_TFT;
70 dssdev->panel.timings = generic_panel_timings;
71
72 return 0;
73}
74
75static void generic_panel_remove(struct omap_dss_device *dssdev)
76{
77}
78
79static int generic_panel_enable(struct omap_dss_device *dssdev)
80{
81 int r = 0;
82
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020083 r = generic_panel_power_on(dssdev);
84 if (r)
85 return r;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020086
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020087 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
88
89 return 0;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020090}
91
92static void generic_panel_disable(struct omap_dss_device *dssdev)
93{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020094 generic_panel_power_off(dssdev);
95
96 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020097}
98
99static int generic_panel_suspend(struct omap_dss_device *dssdev)
100{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200101 generic_panel_power_off(dssdev);
102 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200103 return 0;
104}
105
106static int generic_panel_resume(struct omap_dss_device *dssdev)
107{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200108 int r = 0;
109
110 r = generic_panel_power_on(dssdev);
111 if (r)
112 return r;
113
114 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
115
116 return 0;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200117}
118
Tomi Valkeinen8871d542010-03-04 17:52:43 +0200119static void generic_panel_set_timings(struct omap_dss_device *dssdev,
120 struct omap_video_timings *timings)
121{
122 dpi_set_timings(dssdev, timings);
123}
124
125static void generic_panel_get_timings(struct omap_dss_device *dssdev,
126 struct omap_video_timings *timings)
127{
128 *timings = dssdev->panel.timings;
129}
130
131static int generic_panel_check_timings(struct omap_dss_device *dssdev,
132 struct omap_video_timings *timings)
133{
134 return dpi_check_timings(dssdev, timings);
135}
136
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200137static struct omap_dss_driver generic_driver = {
138 .probe = generic_panel_probe,
139 .remove = generic_panel_remove,
140
141 .enable = generic_panel_enable,
142 .disable = generic_panel_disable,
143 .suspend = generic_panel_suspend,
144 .resume = generic_panel_resume,
145
Tomi Valkeinen8871d542010-03-04 17:52:43 +0200146 .set_timings = generic_panel_set_timings,
147 .get_timings = generic_panel_get_timings,
148 .check_timings = generic_panel_check_timings,
149
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200150 .driver = {
151 .name = "generic_panel",
152 .owner = THIS_MODULE,
153 },
154};
155
156static int __init generic_panel_drv_init(void)
157{
158 return omap_dss_register_driver(&generic_driver);
159}
160
161static void __exit generic_panel_drv_exit(void)
162{
163 omap_dss_unregister_driver(&generic_driver);
164}
165
166module_init(generic_panel_drv_init);
167module_exit(generic_panel_drv_exit);
168MODULE_LICENSE("GPL");