2 * Based on drivers/video/omap/lcd_inn1510.c
4 * LCD panel support for the Amstrad E3 (Delta) videophone.
6 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <linux/module.h>
24 #include <linux/platform_device.h>
26 #include <linux/delay.h>
27 #include <linux/gpio/consumer.h>
28 #include <linux/lcd.h>
30 #include <mach/hardware.h>
34 #define AMS_DELTA_DEFAULT_CONTRAST 112
36 #define AMS_DELTA_MAX_CONTRAST 0x00FF
37 #define AMS_DELTA_LCD_POWER 0x0100
40 /* LCD class device section */
42 static int ams_delta_lcd;
43 static struct gpio_desc *gpiod_vblen;
44 static struct gpio_desc *gpiod_ndisp;
46 static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
48 if (power == FB_BLANK_UNBLANK) {
49 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER)) {
50 omap_writeb(ams_delta_lcd & AMS_DELTA_MAX_CONTRAST,
52 omap_writeb(1, OMAP_PWL_CLK_ENABLE);
53 ams_delta_lcd |= AMS_DELTA_LCD_POWER;
56 if (ams_delta_lcd & AMS_DELTA_LCD_POWER) {
57 omap_writeb(0, OMAP_PWL_ENABLE);
58 omap_writeb(0, OMAP_PWL_CLK_ENABLE);
59 ams_delta_lcd &= ~AMS_DELTA_LCD_POWER;
65 static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
67 if ((value >= 0) && (value <= AMS_DELTA_MAX_CONTRAST)) {
68 omap_writeb(value, OMAP_PWL_ENABLE);
69 ams_delta_lcd &= ~AMS_DELTA_MAX_CONTRAST;
70 ams_delta_lcd |= value;
75 #ifdef CONFIG_LCD_CLASS_DEVICE
76 static int ams_delta_lcd_get_power(struct lcd_device *dev)
78 if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
79 return FB_BLANK_UNBLANK;
81 return FB_BLANK_POWERDOWN;
84 static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
86 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
89 return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
92 static struct lcd_ops ams_delta_lcd_ops = {
93 .get_power = ams_delta_lcd_get_power,
94 .set_power = ams_delta_lcd_set_power,
95 .get_contrast = ams_delta_lcd_get_contrast,
96 .set_contrast = ams_delta_lcd_set_contrast,
101 /* omapfb panel section */
103 static int ams_delta_panel_enable(struct lcd_panel *panel)
105 gpiod_set_value(gpiod_ndisp, 1);
106 gpiod_set_value(gpiod_vblen, 1);
110 static void ams_delta_panel_disable(struct lcd_panel *panel)
112 gpiod_set_value(gpiod_vblen, 0);
113 gpiod_set_value(gpiod_ndisp, 0);
116 static struct lcd_panel ams_delta_panel = {
134 .enable = ams_delta_panel_enable,
135 .disable = ams_delta_panel_disable,
139 /* platform driver section */
141 static int ams_delta_panel_probe(struct platform_device *pdev)
143 struct lcd_device *lcd_device = NULL;
146 gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW);
147 if (IS_ERR(gpiod_vblen)) {
148 ret = PTR_ERR(gpiod_vblen);
149 dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret);
153 gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW);
154 if (IS_ERR(gpiod_ndisp)) {
155 ret = PTR_ERR(gpiod_ndisp);
156 dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret);
160 #ifdef CONFIG_LCD_CLASS_DEVICE
161 lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
164 if (IS_ERR(lcd_device)) {
165 ret = PTR_ERR(lcd_device);
166 dev_err(&pdev->dev, "failed to register device\n");
170 platform_set_drvdata(pdev, lcd_device);
171 lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
174 ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
175 ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
177 omapfb_register_panel(&ams_delta_panel);
181 static struct platform_driver ams_delta_panel_driver = {
182 .probe = ams_delta_panel_probe,
184 .name = "lcd_ams_delta",
188 module_platform_driver(ams_delta_panel_driver);
190 MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
191 MODULE_DESCRIPTION("LCD panel support for the Amstrad E3 (Delta) videophone");
192 MODULE_LICENSE("GPL");