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/lcd.h>
28 #include <linux/gpio.h>
30 #include <mach/hardware.h>
31 #include <mach/board-ams-delta.h>
35 #define AMS_DELTA_DEFAULT_CONTRAST 112
37 #define AMS_DELTA_MAX_CONTRAST 0x00FF
38 #define AMS_DELTA_LCD_POWER 0x0100
41 /* LCD class device section */
43 static int ams_delta_lcd
;
45 static int ams_delta_lcd_set_power(struct lcd_device
*dev
, int power
)
47 if (power
== FB_BLANK_UNBLANK
) {
48 if (!(ams_delta_lcd
& AMS_DELTA_LCD_POWER
)) {
49 omap_writeb(ams_delta_lcd
& AMS_DELTA_MAX_CONTRAST
,
51 omap_writeb(1, OMAP_PWL_CLK_ENABLE
);
52 ams_delta_lcd
|= AMS_DELTA_LCD_POWER
;
55 if (ams_delta_lcd
& AMS_DELTA_LCD_POWER
) {
56 omap_writeb(0, OMAP_PWL_ENABLE
);
57 omap_writeb(0, OMAP_PWL_CLK_ENABLE
);
58 ams_delta_lcd
&= ~AMS_DELTA_LCD_POWER
;
64 static int ams_delta_lcd_set_contrast(struct lcd_device
*dev
, int value
)
66 if ((value
>= 0) && (value
<= AMS_DELTA_MAX_CONTRAST
)) {
67 omap_writeb(value
, OMAP_PWL_ENABLE
);
68 ams_delta_lcd
&= ~AMS_DELTA_MAX_CONTRAST
;
69 ams_delta_lcd
|= value
;
74 #ifdef CONFIG_LCD_CLASS_DEVICE
75 static int ams_delta_lcd_get_power(struct lcd_device
*dev
)
77 if (ams_delta_lcd
& AMS_DELTA_LCD_POWER
)
78 return FB_BLANK_UNBLANK
;
80 return FB_BLANK_POWERDOWN
;
83 static int ams_delta_lcd_get_contrast(struct lcd_device
*dev
)
85 if (!(ams_delta_lcd
& AMS_DELTA_LCD_POWER
))
88 return ams_delta_lcd
& AMS_DELTA_MAX_CONTRAST
;
91 static struct lcd_ops ams_delta_lcd_ops
= {
92 .get_power
= ams_delta_lcd_get_power
,
93 .set_power
= ams_delta_lcd_set_power
,
94 .get_contrast
= ams_delta_lcd_get_contrast
,
95 .set_contrast
= ams_delta_lcd_set_contrast
,
100 /* omapfb panel section */
102 static const struct gpio _gpios
[] = {
104 .gpio
= AMS_DELTA_GPIO_PIN_LCD_VBLEN
,
105 .flags
= GPIOF_OUT_INIT_LOW
,
106 .label
= "lcd_vblen",
109 .gpio
= AMS_DELTA_GPIO_PIN_LCD_NDISP
,
110 .flags
= GPIOF_OUT_INIT_LOW
,
111 .label
= "lcd_ndisp",
115 static int ams_delta_panel_init(struct lcd_panel
*panel
,
116 struct omapfb_device
*fbdev
)
118 return gpio_request_array(_gpios
, ARRAY_SIZE(_gpios
));
121 static void ams_delta_panel_cleanup(struct lcd_panel
*panel
)
123 gpio_free_array(_gpios
, ARRAY_SIZE(_gpios
));
126 static int ams_delta_panel_enable(struct lcd_panel
*panel
)
128 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP
, 1);
129 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN
, 1);
133 static void ams_delta_panel_disable(struct lcd_panel
*panel
)
135 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN
, 0);
136 gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP
, 0);
139 static unsigned long ams_delta_panel_get_caps(struct lcd_panel
*panel
)
144 static struct lcd_panel ams_delta_panel
= {
162 .init
= ams_delta_panel_init
,
163 .cleanup
= ams_delta_panel_cleanup
,
164 .enable
= ams_delta_panel_enable
,
165 .disable
= ams_delta_panel_disable
,
166 .get_caps
= ams_delta_panel_get_caps
,
170 /* platform driver section */
172 static int ams_delta_panel_probe(struct platform_device
*pdev
)
174 struct lcd_device
*lcd_device
= NULL
;
175 #ifdef CONFIG_LCD_CLASS_DEVICE
178 lcd_device
= lcd_device_register("omapfb", &pdev
->dev
, NULL
,
181 if (IS_ERR(lcd_device
)) {
182 ret
= PTR_ERR(lcd_device
);
183 dev_err(&pdev
->dev
, "failed to register device\n");
187 platform_set_drvdata(pdev
, lcd_device
);
188 lcd_device
->props
.max_contrast
= AMS_DELTA_MAX_CONTRAST
;
191 ams_delta_lcd_set_contrast(lcd_device
, AMS_DELTA_DEFAULT_CONTRAST
);
192 ams_delta_lcd_set_power(lcd_device
, FB_BLANK_UNBLANK
);
194 omapfb_register_panel(&ams_delta_panel
);
198 static int ams_delta_panel_remove(struct platform_device
*pdev
)
203 static int ams_delta_panel_suspend(struct platform_device
*pdev
,
209 static int ams_delta_panel_resume(struct platform_device
*pdev
)
214 static struct platform_driver ams_delta_panel_driver
= {
215 .probe
= ams_delta_panel_probe
,
216 .remove
= ams_delta_panel_remove
,
217 .suspend
= ams_delta_panel_suspend
,
218 .resume
= ams_delta_panel_resume
,
220 .name
= "lcd_ams_delta",
221 .owner
= THIS_MODULE
,
225 module_platform_driver(ams_delta_panel_driver
);