diff options
author | Janusz Krzysztofik <jmkrzyszt@gmail.com> | 2018-10-08 06:57:36 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2018-10-08 06:57:36 -0400 |
commit | 02f17ffd34885ddf5afcab4d5e201b596156f862 (patch) | |
tree | e10b7cbf06487e8447d4b80b45006aa295436568 | |
parent | e5017716adb8aa5c01c52386c1b7470101ffe9c5 (diff) |
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>
-rw-r--r-- | drivers/video/fbdev/omap/lcd_ams_delta.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/drivers/video/fbdev/omap/lcd_ams_delta.c b/drivers/video/fbdev/omap/lcd_ams_delta.c index e8c748a0dfe2..cddbd00cbf9f 100644 --- a/drivers/video/fbdev/omap/lcd_ams_delta.c +++ b/drivers/video/fbdev/omap/lcd_ams_delta.c | |||
@@ -24,11 +24,10 @@ | |||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/gpio/consumer.h> | ||
27 | #include <linux/lcd.h> | 28 | #include <linux/lcd.h> |
28 | #include <linux/gpio.h> | ||
29 | 29 | ||
30 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
31 | #include <mach/board-ams-delta.h> | ||
32 | 31 | ||
33 | #include "omapfb.h" | 32 | #include "omapfb.h" |
34 | 33 | ||
@@ -41,6 +40,8 @@ | |||
41 | /* LCD class device section */ | 40 | /* LCD class device section */ |
42 | 41 | ||
43 | static int ams_delta_lcd; | 42 | static int ams_delta_lcd; |
43 | static struct gpio_desc *gpiod_vblen; | ||
44 | static struct gpio_desc *gpiod_ndisp; | ||
44 | 45 | ||
45 | static int ams_delta_lcd_set_power(struct lcd_device *dev, int power) | 46 | static int ams_delta_lcd_set_power(struct lcd_device *dev, int power) |
46 | { | 47 | { |
@@ -99,41 +100,17 @@ static struct lcd_ops ams_delta_lcd_ops = { | |||
99 | 100 | ||
100 | /* omapfb panel section */ | 101 | /* omapfb panel section */ |
101 | 102 | ||
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 | |||
126 | static int ams_delta_panel_enable(struct lcd_panel *panel) | 103 | static int ams_delta_panel_enable(struct lcd_panel *panel) |
127 | { | 104 | { |
128 | gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1); | 105 | gpiod_set_value(gpiod_ndisp, 1); |
129 | gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1); | 106 | gpiod_set_value(gpiod_vblen, 1); |
130 | return 0; | 107 | return 0; |
131 | } | 108 | } |
132 | 109 | ||
133 | static void ams_delta_panel_disable(struct lcd_panel *panel) | 110 | static void ams_delta_panel_disable(struct lcd_panel *panel) |
134 | { | 111 | { |
135 | gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0); | 112 | gpiod_set_value(gpiod_vblen, 0); |
136 | gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0); | 113 | gpiod_set_value(gpiod_ndisp, 0); |
137 | } | 114 | } |
138 | 115 | ||
139 | static struct lcd_panel ams_delta_panel = { | 116 | static struct lcd_panel ams_delta_panel = { |
@@ -154,8 +131,6 @@ static struct lcd_panel ams_delta_panel = { | |||
154 | .pcd = 0, | 131 | .pcd = 0, |
155 | .acb = 37, | 132 | .acb = 37, |
156 | 133 | ||
157 | .init = ams_delta_panel_init, | ||
158 | .cleanup = ams_delta_panel_cleanup, | ||
159 | .enable = ams_delta_panel_enable, | 134 | .enable = ams_delta_panel_enable, |
160 | .disable = ams_delta_panel_disable, | 135 | .disable = ams_delta_panel_disable, |
161 | }; | 136 | }; |
@@ -166,9 +141,23 @@ static struct lcd_panel ams_delta_panel = { | |||
166 | static int ams_delta_panel_probe(struct platform_device *pdev) | 141 | static int ams_delta_panel_probe(struct platform_device *pdev) |
167 | { | 142 | { |
168 | struct lcd_device *lcd_device = NULL; | 143 | struct lcd_device *lcd_device = NULL; |
169 | #ifdef CONFIG_LCD_CLASS_DEVICE | ||
170 | int ret; | 144 | int ret; |
171 | 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 | ||
172 | lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, | 161 | lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, |
173 | &ams_delta_lcd_ops); | 162 | &ams_delta_lcd_ops); |
174 | 163 | ||