Skip to content

Commit 02f17ff

Browse files
jkrzysztbzolnier
authored andcommitted
video: fbdev: omapfb: lcd_ams_delta: use GPIO lookup table
Now as Amstrad Delta board - the only user of this driver - provides GPIO lookup tables, switch from GPIO numbers to GPIO descriptors and use the table to locate required GPIO pins. Declare static variables for storing GPIO descriptors and replace gpio_ function calls with their gpiod_ equivalents. Move GPIO lookup to the driver probe function so device initialization can be deferred instead of aborted if a GPIO pin is not yet available. Pin naming used by the driver should be followed while respective GPIO lookup table is initialized by a board init code. Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Cc: Tony Lindgren <tony@atomide.com> Cc: Aaro Koskinen <aaro.koskinen@iki.fi> Cc: Boris Brezillon <boris.brezillon@bootlin.com> Cc: Miquel Raynal <miquel.raynal@bootlin.com> Cc: Richard Weinberger <richard@nod.at> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Brian Norris <computersforpeace@gmail.com> Cc: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
1 parent e501771 commit 02f17ff

File tree

1 file changed

+22
-33
lines changed

1 file changed

+22
-33
lines changed

drivers/video/fbdev/omap/lcd_ams_delta.c

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
#include <linux/platform_device.h>
2525
#include <linux/io.h>
2626
#include <linux/delay.h>
27+
#include <linux/gpio/consumer.h>
2728
#include <linux/lcd.h>
28-
#include <linux/gpio.h>
2929

3030
#include <mach/hardware.h>
31-
#include <mach/board-ams-delta.h>
3231

3332
#include "omapfb.h"
3433

@@ -41,6 +40,8 @@
4140
/* LCD class device section */
4241

4342
static int ams_delta_lcd;
43+
static struct gpio_desc *gpiod_vblen;
44+
static struct gpio_desc *gpiod_ndisp;
4445

4546
static int ams_delta_lcd_set_power(struct lcd_device *dev, int power)
4647
{
@@ -99,41 +100,17 @@ static struct lcd_ops ams_delta_lcd_ops = {
99100

100101
/* omapfb panel section */
101102

102-
static const struct gpio _gpios[] = {
103-
{
104-
.gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN,
105-
.flags = GPIOF_OUT_INIT_LOW,
106-
.label = "lcd_vblen",
107-
},
108-
{
109-
.gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP,
110-
.flags = GPIOF_OUT_INIT_LOW,
111-
.label = "lcd_ndisp",
112-
},
113-
};
114-
115-
static int ams_delta_panel_init(struct lcd_panel *panel,
116-
struct omapfb_device *fbdev)
117-
{
118-
return gpio_request_array(_gpios, ARRAY_SIZE(_gpios));
119-
}
120-
121-
static void ams_delta_panel_cleanup(struct lcd_panel *panel)
122-
{
123-
gpio_free_array(_gpios, ARRAY_SIZE(_gpios));
124-
}
125-
126103
static int ams_delta_panel_enable(struct lcd_panel *panel)
127104
{
128-
gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1);
129-
gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1);
105+
gpiod_set_value(gpiod_ndisp, 1);
106+
gpiod_set_value(gpiod_vblen, 1);
130107
return 0;
131108
}
132109

133110
static void ams_delta_panel_disable(struct lcd_panel *panel)
134111
{
135-
gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0);
136-
gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0);
112+
gpiod_set_value(gpiod_vblen, 0);
113+
gpiod_set_value(gpiod_ndisp, 0);
137114
}
138115

139116
static struct lcd_panel ams_delta_panel = {
@@ -154,8 +131,6 @@ static struct lcd_panel ams_delta_panel = {
154131
.pcd = 0,
155132
.acb = 37,
156133

157-
.init = ams_delta_panel_init,
158-
.cleanup = ams_delta_panel_cleanup,
159134
.enable = ams_delta_panel_enable,
160135
.disable = ams_delta_panel_disable,
161136
};
@@ -166,9 +141,23 @@ static struct lcd_panel ams_delta_panel = {
166141
static int ams_delta_panel_probe(struct platform_device *pdev)
167142
{
168143
struct lcd_device *lcd_device = NULL;
169-
#ifdef CONFIG_LCD_CLASS_DEVICE
170144
int ret;
171145

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
172161
lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL,
173162
&ams_delta_lcd_ops);
174163

0 commit comments

Comments
 (0)