2 * LCD panel driver for Sharp LS037V7DW01
4 * Copyright (C) 2008 Nokia Corporation
5 * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
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.
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
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/>.
20 #include <linux/module.h>
21 #include <linux/delay.h>
22 #include <linux/device.h>
23 #include <linux/backlight.h>
25 #include <linux/err.h>
26 #include <linux/slab.h>
28 #include <plat/display.h>
31 struct backlight_device
*bl
;
34 static struct omap_video_timings sharp_ls_timings
= {
49 static int sharp_ls_bl_update_status(struct backlight_device
*bl
)
51 struct omap_dss_device
*dssdev
= dev_get_drvdata(&bl
->dev
);
54 if (!dssdev
->set_backlight
)
57 if (bl
->props
.fb_blank
== FB_BLANK_UNBLANK
&&
58 bl
->props
.power
== FB_BLANK_UNBLANK
)
59 level
= bl
->props
.brightness
;
63 return dssdev
->set_backlight(dssdev
, level
);
66 static int sharp_ls_bl_get_brightness(struct backlight_device
*bl
)
68 if (bl
->props
.fb_blank
== FB_BLANK_UNBLANK
&&
69 bl
->props
.power
== FB_BLANK_UNBLANK
)
70 return bl
->props
.brightness
;
75 static const struct backlight_ops sharp_ls_bl_ops
= {
76 .get_brightness
= sharp_ls_bl_get_brightness
,
77 .update_status
= sharp_ls_bl_update_status
,
82 static int sharp_ls_panel_probe(struct omap_dss_device
*dssdev
)
84 struct backlight_properties props
;
85 struct backlight_device
*bl
;
86 struct sharp_data
*sd
;
89 dssdev
->panel
.config
= OMAP_DSS_LCD_TFT
| OMAP_DSS_LCD_IVS
|
91 dssdev
->panel
.acb
= 0x28;
92 dssdev
->panel
.timings
= sharp_ls_timings
;
94 sd
= kzalloc(sizeof(*sd
), GFP_KERNEL
);
98 dev_set_drvdata(&dssdev
->dev
, sd
);
100 memset(&props
, 0, sizeof(struct backlight_properties
));
101 props
.max_brightness
= dssdev
->max_backlight_level
;
103 bl
= backlight_device_register("sharp-ls", &dssdev
->dev
, dssdev
,
104 &sharp_ls_bl_ops
, &props
);
112 bl
->props
.fb_blank
= FB_BLANK_UNBLANK
;
113 bl
->props
.power
= FB_BLANK_UNBLANK
;
114 bl
->props
.brightness
= dssdev
->max_backlight_level
;
115 r
= sharp_ls_bl_update_status(bl
);
117 dev_err(&dssdev
->dev
, "failed to set lcd brightness\n");
122 static void sharp_ls_panel_remove(struct omap_dss_device
*dssdev
)
124 struct sharp_data
*sd
= dev_get_drvdata(&dssdev
->dev
);
125 struct backlight_device
*bl
= sd
->bl
;
127 bl
->props
.power
= FB_BLANK_POWERDOWN
;
128 sharp_ls_bl_update_status(bl
);
129 backlight_device_unregister(bl
);
134 static int sharp_ls_power_on(struct omap_dss_device
*dssdev
)
138 r
= omapdss_dpi_display_enable(dssdev
);
142 /* wait couple of vsyncs until enabling the LCD */
145 if (dssdev
->platform_enable
) {
146 r
= dssdev
->platform_enable(dssdev
);
153 omapdss_dpi_display_disable(dssdev
);
158 static void sharp_ls_power_off(struct omap_dss_device
*dssdev
)
160 if (dssdev
->platform_disable
)
161 dssdev
->platform_disable(dssdev
);
163 /* wait at least 5 vsyncs after disabling the LCD */
167 omapdss_dpi_display_disable(dssdev
);
170 static int sharp_ls_panel_enable(struct omap_dss_device
*dssdev
)
173 r
= sharp_ls_power_on(dssdev
);
174 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
178 static void sharp_ls_panel_disable(struct omap_dss_device
*dssdev
)
180 sharp_ls_power_off(dssdev
);
181 dssdev
->state
= OMAP_DSS_DISPLAY_DISABLED
;
184 static int sharp_ls_panel_suspend(struct omap_dss_device
*dssdev
)
186 sharp_ls_power_off(dssdev
);
187 dssdev
->state
= OMAP_DSS_DISPLAY_SUSPENDED
;
191 static int sharp_ls_panel_resume(struct omap_dss_device
*dssdev
)
194 r
= sharp_ls_power_on(dssdev
);
195 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
199 static struct omap_dss_driver sharp_ls_driver
= {
200 .probe
= sharp_ls_panel_probe
,
201 .remove
= sharp_ls_panel_remove
,
203 .enable
= sharp_ls_panel_enable
,
204 .disable
= sharp_ls_panel_disable
,
205 .suspend
= sharp_ls_panel_suspend
,
206 .resume
= sharp_ls_panel_resume
,
209 .name
= "sharp_ls_panel",
210 .owner
= THIS_MODULE
,
214 static int __init
sharp_ls_panel_drv_init(void)
216 return omap_dss_register_driver(&sharp_ls_driver
);
219 static void __exit
sharp_ls_panel_drv_exit(void)
221 omap_dss_unregister_driver(&sharp_ls_driver
);
224 module_init(sharp_ls_panel_drv_init
);
225 module_exit(sharp_ls_panel_drv_exit
);
226 MODULE_LICENSE("GPL");