blob: 0c6896cea2d0a2d01e593209b201d4d3a44555a5 [file] [log] [blame]
Vaibhav Hiremath1c646062010-01-04 15:34:15 +01001/*
2 * LCD panel driver for Sharp LQ043T1DG01
3 *
4 * Copyright (C) 2009 Texas Instruments Inc
5 * Author: Vaibhav Hiremath <hvaibhav@ti.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#include <linux/device.h>
23#include <linux/err.h>
24
25#include <plat/display.h>
26
27static struct omap_video_timings sharp_lq_timings = {
28 .x_res = 480,
29 .y_res = 272,
30
31 .pixel_clock = 9000,
32
33 .hsw = 42,
34 .hfp = 3,
35 .hbp = 2,
36
37 .vsw = 11,
38 .vfp = 3,
39 .vbp = 2,
40};
41
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020042static int sharp_lq_panel_power_on(struct omap_dss_device *dssdev)
43{
44 int r;
45
Stanley.Miao18016e32010-09-03 05:03:48 +020046 if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
47 return 0;
48
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020049 r = omapdss_dpi_display_enable(dssdev);
50 if (r)
51 goto err0;
52
53 /* wait couple of vsyncs until enabling the LCD */
54 msleep(50);
55
56 if (dssdev->platform_enable) {
57 r = dssdev->platform_enable(dssdev);
58 if (r)
59 goto err1;
60 }
61
62 return 0;
63err1:
64 omapdss_dpi_display_disable(dssdev);
65err0:
66 return r;
67}
68
69static void sharp_lq_panel_power_off(struct omap_dss_device *dssdev)
70{
Stanley.Miao18016e32010-09-03 05:03:48 +020071 if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE)
72 return;
73
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020074 if (dssdev->platform_disable)
75 dssdev->platform_disable(dssdev);
76
77 /* wait at least 5 vsyncs after disabling the LCD */
78 msleep(100);
79
80 omapdss_dpi_display_disable(dssdev);
81}
82
Vaibhav Hiremath1c646062010-01-04 15:34:15 +010083static int sharp_lq_panel_probe(struct omap_dss_device *dssdev)
84{
85
86 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
87 OMAP_DSS_LCD_IHS | OMAP_DSS_LCD_IEO;
88 dssdev->panel.acb = 0x0;
89 dssdev->panel.timings = sharp_lq_timings;
90
91 return 0;
92}
93
94static void sharp_lq_panel_remove(struct omap_dss_device *dssdev)
95{
96}
97
98static int sharp_lq_panel_enable(struct omap_dss_device *dssdev)
99{
100 int r = 0;
101
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200102 r = sharp_lq_panel_power_on(dssdev);
103 if (r)
104 return r;
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100105
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200106 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100107
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200108 return 0;
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100109}
110
111static void sharp_lq_panel_disable(struct omap_dss_device *dssdev)
112{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200113 sharp_lq_panel_power_off(dssdev);
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100114
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200115 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100116}
117
118static int sharp_lq_panel_suspend(struct omap_dss_device *dssdev)
119{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200120 sharp_lq_panel_power_off(dssdev);
121 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100122 return 0;
123}
124
125static int sharp_lq_panel_resume(struct omap_dss_device *dssdev)
126{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200127 int r = 0;
128
129 r = sharp_lq_panel_power_on(dssdev);
130 if (r)
131 return r;
132
133 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
134
135 return 0;
Vaibhav Hiremath1c646062010-01-04 15:34:15 +0100136}
137
138static struct omap_dss_driver sharp_lq_driver = {
139 .probe = sharp_lq_panel_probe,
140 .remove = sharp_lq_panel_remove,
141
142 .enable = sharp_lq_panel_enable,
143 .disable = sharp_lq_panel_disable,
144 .suspend = sharp_lq_panel_suspend,
145 .resume = sharp_lq_panel_resume,
146
147 .driver = {
148 .name = "sharp_lq_panel",
149 .owner = THIS_MODULE,
150 },
151};
152
153static int __init sharp_lq_panel_drv_init(void)
154{
155 return omap_dss_register_driver(&sharp_lq_driver);
156}
157
158static void __exit sharp_lq_panel_drv_exit(void)
159{
160 omap_dss_unregister_driver(&sharp_lq_driver);
161}
162
163module_init(sharp_lq_panel_drv_init);
164module_exit(sharp_lq_panel_drv_exit);
165MODULE_LICENSE("GPL");