blob: 8d51a5e6341c704446e6e7e3e78f780b9ccd9c04 [file] [log] [blame]
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +02001/*
2 * LCD panel driver for Sharp LS037V7DW01
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#include <linux/device.h>
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020023#include <linux/err.h>
24
25#include <plat/display.h>
26
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020027static struct omap_video_timings sharp_ls_timings = {
28 .x_res = 480,
29 .y_res = 640,
30
31 .pixel_clock = 19200,
32
33 .hsw = 2,
34 .hfp = 1,
35 .hbp = 28,
36
37 .vsw = 1,
38 .vfp = 1,
39 .vbp = 1,
40};
41
42static int sharp_ls_panel_probe(struct omap_dss_device *dssdev)
43{
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020044 dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS |
45 OMAP_DSS_LCD_IHS;
46 dssdev->panel.acb = 0x28;
47 dssdev->panel.timings = sharp_ls_timings;
48
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020049 return 0;
50}
51
52static void sharp_ls_panel_remove(struct omap_dss_device *dssdev)
53{
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020054}
55
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020056static int sharp_ls_power_on(struct omap_dss_device *dssdev)
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020057{
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020058 int r = 0;
59
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020060 r = omapdss_dpi_display_enable(dssdev);
61 if (r)
62 goto err0;
63
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020064 /* wait couple of vsyncs until enabling the LCD */
65 msleep(50);
66
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020067 if (dssdev->platform_enable) {
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020068 r = dssdev->platform_enable(dssdev);
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020069 if (r)
70 goto err1;
71 }
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020072
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020073 return 0;
74err1:
75 omapdss_dpi_display_disable(dssdev);
76err0:
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020077 return r;
78}
79
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020080static void sharp_ls_power_off(struct omap_dss_device *dssdev)
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020081{
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020082 if (dssdev->platform_disable)
83 dssdev->platform_disable(dssdev);
84
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +020085 /* wait at least 5 vsyncs after disabling the LCD */
86
87 msleep(100);
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +020088
89 omapdss_dpi_display_disable(dssdev);
90}
91
92static int sharp_ls_panel_enable(struct omap_dss_device *dssdev)
93{
94 int r;
95 r = sharp_ls_power_on(dssdev);
96 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
97 return r;
98}
99
100static void sharp_ls_panel_disable(struct omap_dss_device *dssdev)
101{
102 sharp_ls_power_off(dssdev);
103 dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200104}
105
106static int sharp_ls_panel_suspend(struct omap_dss_device *dssdev)
107{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200108 sharp_ls_power_off(dssdev);
109 dssdev->state = OMAP_DSS_DISPLAY_SUSPENDED;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200110 return 0;
111}
112
113static int sharp_ls_panel_resume(struct omap_dss_device *dssdev)
114{
Tomi Valkeinen37ac60e2010-01-12 15:12:07 +0200115 int r;
116 r = sharp_ls_power_on(dssdev);
117 dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
118 return r;
Tomi Valkeinen3b8f29b2009-12-09 18:19:42 +0200119}
120
121static struct omap_dss_driver sharp_ls_driver = {
122 .probe = sharp_ls_panel_probe,
123 .remove = sharp_ls_panel_remove,
124
125 .enable = sharp_ls_panel_enable,
126 .disable = sharp_ls_panel_disable,
127 .suspend = sharp_ls_panel_suspend,
128 .resume = sharp_ls_panel_resume,
129
130 .driver = {
131 .name = "sharp_ls_panel",
132 .owner = THIS_MODULE,
133 },
134};
135
136static int __init sharp_ls_panel_drv_init(void)
137{
138 return omap_dss_register_driver(&sharp_ls_driver);
139}
140
141static void __exit sharp_ls_panel_drv_exit(void)
142{
143 omap_dss_unregister_driver(&sharp_ls_driver);
144}
145
146module_init(sharp_ls_panel_drv_init);
147module_exit(sharp_ls_panel_drv_exit);
148MODULE_LICENSE("GPL");