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>
24 #include <linux/err.h>
25 #include <linux/slab.h>
26 #include <linux/gpio.h>
28 #include <video/omapdss.h>
29 #include <video/omap-panel-data.h>
31 static struct omap_video_timings sharp_ls_timings
= {
45 .vsync_level
= OMAPDSS_SIG_ACTIVE_LOW
,
46 .hsync_level
= OMAPDSS_SIG_ACTIVE_LOW
,
47 .data_pclk_edge
= OMAPDSS_DRIVE_SIG_RISING_EDGE
,
48 .de_level
= OMAPDSS_SIG_ACTIVE_HIGH
,
49 .sync_pclk_edge
= OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES
,
52 static inline struct panel_sharp_ls037v7dw01_data
53 *get_panel_data(const struct omap_dss_device
*dssdev
)
55 return (struct panel_sharp_ls037v7dw01_data
*) dssdev
->data
;
58 static int sharp_ls_panel_probe(struct omap_dss_device
*dssdev
)
60 struct panel_sharp_ls037v7dw01_data
*pd
= get_panel_data(dssdev
);
66 dssdev
->panel
.timings
= sharp_ls_timings
;
68 if (gpio_is_valid(pd
->mo_gpio
)) {
69 r
= devm_gpio_request_one(dssdev
->dev
, pd
->mo_gpio
,
70 GPIOF_OUT_INIT_LOW
, "lcd MO");
75 if (gpio_is_valid(pd
->lr_gpio
)) {
76 r
= devm_gpio_request_one(dssdev
->dev
, pd
->lr_gpio
,
77 GPIOF_OUT_INIT_HIGH
, "lcd LR");
82 if (gpio_is_valid(pd
->ud_gpio
)) {
83 r
= devm_gpio_request_one(dssdev
->dev
, pd
->ud_gpio
,
84 GPIOF_OUT_INIT_HIGH
, "lcd UD");
89 if (gpio_is_valid(pd
->resb_gpio
)) {
90 r
= devm_gpio_request_one(dssdev
->dev
, pd
->resb_gpio
,
91 GPIOF_OUT_INIT_LOW
, "lcd RESB");
96 if (gpio_is_valid(pd
->ini_gpio
)) {
97 r
= devm_gpio_request_one(dssdev
->dev
, pd
->ini_gpio
,
98 GPIOF_OUT_INIT_LOW
, "lcd INI");
106 static void __exit
sharp_ls_panel_remove(struct omap_dss_device
*dssdev
)
110 static int sharp_ls_power_on(struct omap_dss_device
*dssdev
)
112 struct panel_sharp_ls037v7dw01_data
*pd
= get_panel_data(dssdev
);
115 if (dssdev
->state
== OMAP_DSS_DISPLAY_ACTIVE
)
118 omapdss_dpi_set_timings(dssdev
, &dssdev
->panel
.timings
);
119 omapdss_dpi_set_data_lines(dssdev
, dssdev
->phy
.dpi
.data_lines
);
121 r
= omapdss_dpi_display_enable(dssdev
);
125 /* wait couple of vsyncs until enabling the LCD */
128 if (gpio_is_valid(pd
->resb_gpio
))
129 gpio_set_value_cansleep(pd
->resb_gpio
, 1);
131 if (gpio_is_valid(pd
->ini_gpio
))
132 gpio_set_value_cansleep(pd
->ini_gpio
, 1);
139 static void sharp_ls_power_off(struct omap_dss_device
*dssdev
)
141 struct panel_sharp_ls037v7dw01_data
*pd
= get_panel_data(dssdev
);
143 if (dssdev
->state
!= OMAP_DSS_DISPLAY_ACTIVE
)
146 if (gpio_is_valid(pd
->ini_gpio
))
147 gpio_set_value_cansleep(pd
->ini_gpio
, 0);
149 if (gpio_is_valid(pd
->resb_gpio
))
150 gpio_set_value_cansleep(pd
->resb_gpio
, 0);
152 /* wait at least 5 vsyncs after disabling the LCD */
156 omapdss_dpi_display_disable(dssdev
);
159 static int sharp_ls_panel_enable(struct omap_dss_device
*dssdev
)
162 r
= sharp_ls_power_on(dssdev
);
163 dssdev
->state
= OMAP_DSS_DISPLAY_ACTIVE
;
167 static void sharp_ls_panel_disable(struct omap_dss_device
*dssdev
)
169 sharp_ls_power_off(dssdev
);
170 dssdev
->state
= OMAP_DSS_DISPLAY_DISABLED
;
173 static struct omap_dss_driver sharp_ls_driver
= {
174 .probe
= sharp_ls_panel_probe
,
175 .remove
= __exit_p(sharp_ls_panel_remove
),
177 .enable
= sharp_ls_panel_enable
,
178 .disable
= sharp_ls_panel_disable
,
181 .name
= "sharp_ls_panel",
182 .owner
= THIS_MODULE
,
186 static int __init
sharp_ls_panel_drv_init(void)
188 return omap_dss_register_driver(&sharp_ls_driver
);
191 static void __exit
sharp_ls_panel_drv_exit(void)
193 omap_dss_unregister_driver(&sharp_ls_driver
);
196 module_init(sharp_ls_panel_drv_init
);
197 module_exit(sharp_ls_panel_drv_exit
);
198 MODULE_LICENSE("GPL");