Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Based on drivers/video/omap/lcd_inn1510.c
3 *
4 * LCD panel support for the Amstrad E3 (Delta) videophone.
5 *
6 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
7 *
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.
12 *
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.
17 *
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.
21 */
22
23#include <linux/module.h>
24#include <linux/platform_device.h>
25#include <linux/io.h>
26#include <linux/delay.h>
27#include <linux/gpio/consumer.h>
28#include <linux/lcd.h>
29
30#include <mach/hardware.h>
31
32#include "omapfb.h"
33
34#define AMS_DELTA_DEFAULT_CONTRAST 112
35
36#define AMS_DELTA_MAX_CONTRAST 0x00FF
37#define AMS_DELTA_LCD_POWER 0x0100
38
39
40/* LCD class device section */
41
42static int ams_delta_lcd;
43static struct gpio_desc *gpiod_vblen;
44static struct gpio_desc *gpiod_ndisp;
45
46static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
47{
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,
51 OMAP_PWL_ENABLE);
52 omap_writeb(1, OMAP_PWL_CLK_ENABLE);
53 ams_delta_lcd |= AMS_DELTA_LCD_POWER;
54 }
55 } else {
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;
60 }
61 }
62 return 0;
63}
64
65static int ams_delta_lcd_set_contrast(struct lcd_device *dev, int value)
66{
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;
71 }
72 return 0;
73}
74
75#ifdef CONFIG_LCD_CLASS_DEVICE
76static int ams_delta_lcd_get_power(struct lcd_device *dev)
77{
78 if (ams_delta_lcd & AMS_DELTA_LCD_POWER)
79 return FB_BLANK_UNBLANK;
80 else
81 return FB_BLANK_POWERDOWN;
82}
83
84static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
85{
86 if (!(ams_delta_lcd & AMS_DELTA_LCD_POWER))
87 return 0;
88
89 return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
90}
91
92static 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,
97};
98#endif
99
100
101/* omapfb panel section */
102
103static int ams_delta_panel_enable(struct lcd_panel *panel)
104{
105 gpiod_set_value(gpiod_ndisp, 1);
106 gpiod_set_value(gpiod_vblen, 1);
107 return 0;
108}
109
110static void ams_delta_panel_disable(struct lcd_panel *panel)
111{
112 gpiod_set_value(gpiod_vblen, 0);
113 gpiod_set_value(gpiod_ndisp, 0);
114}
115
116static struct lcd_panel ams_delta_panel = {
117 .name = "ams-delta",
118 .config = 0,
119
120 .bpp = 12,
121 .data_lines = 16,
122 .x_res = 480,
123 .y_res = 320,
124 .pixel_clock = 4687,
125 .hsw = 3,
126 .hfp = 1,
127 .hbp = 1,
128 .vsw = 1,
129 .vfp = 0,
130 .vbp = 0,
131 .pcd = 0,
132 .acb = 37,
133
134 .enable = ams_delta_panel_enable,
135 .disable = ams_delta_panel_disable,
136};
137
138
139/* platform driver section */
140
141static int ams_delta_panel_probe(struct platform_device *pdev)
142{
143 struct lcd_device *lcd_device = NULL;
144 int ret;
145
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);
150 return ret;
151 }
152
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);
157 return ret;
158 }
159
160#ifdef CONFIG_LCD_CLASS_DEVICE
161 lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
162 &ams_delta_lcd_ops);
163
164 if (IS_ERR(lcd_device)) {
165 ret = PTR_ERR(lcd_device);
166 dev_err(&pdev->dev, "failed to register device\n");
167 return ret;
168 }
169
170 platform_set_drvdata(pdev, lcd_device);
171 lcd_device->props.max_contrast = AMS_DELTA_MAX_CONTRAST;
172#endif
173
174 ams_delta_lcd_set_contrast(lcd_device, AMS_DELTA_DEFAULT_CONTRAST);
175 ams_delta_lcd_set_power(lcd_device, FB_BLANK_UNBLANK);
176
177 omapfb_register_panel(&ams_delta_panel);
178 return 0;
179}
180
181static struct platform_driver ams_delta_panel_driver = {
182 .probe = ams_delta_panel_probe,
183 .driver = {
184 .name = "lcd_ams_delta",
185 },
186};
187
188module_platform_driver(ams_delta_panel_driver);
189
190MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
191MODULE_DESCRIPTION("LCD panel support for the Amstrad E3 (Delta) videophone");
192MODULE_LICENSE("GPL");