Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Janusz Krzysztofik and committed by
Bartlomiej Zolnierkiewicz
02f17ffd e5017716

+22 -33
+22 -33
drivers/video/fbdev/omap/lcd_ams_delta.c
··· 24 24 #include <linux/platform_device.h> 25 25 #include <linux/io.h> 26 26 #include <linux/delay.h> 27 + #include <linux/gpio/consumer.h> 27 28 #include <linux/lcd.h> 28 - #include <linux/gpio.h> 29 29 30 30 #include <mach/hardware.h> 31 - #include <mach/board-ams-delta.h> 32 31 33 32 #include "omapfb.h" 34 33 ··· 40 41 /* LCD class device section */ 41 42 42 43 static int ams_delta_lcd; 44 + static struct gpio_desc *gpiod_vblen; 45 + static struct gpio_desc *gpiod_ndisp; 43 46 44 47 static int ams_delta_lcd_set_power(struct lcd_device *dev, int power) 45 48 { ··· 100 99 101 100 /* omapfb panel section */ 102 101 103 - static const struct gpio _gpios[] = { 104 - { 105 - .gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN, 106 - .flags = GPIOF_OUT_INIT_LOW, 107 - .label = "lcd_vblen", 108 - }, 109 - { 110 - .gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP, 111 - .flags = GPIOF_OUT_INIT_LOW, 112 - .label = "lcd_ndisp", 113 - }, 114 - }; 115 - 116 - static int ams_delta_panel_init(struct lcd_panel *panel, 117 - struct omapfb_device *fbdev) 118 - { 119 - return gpio_request_array(_gpios, ARRAY_SIZE(_gpios)); 120 - } 121 - 122 - static void ams_delta_panel_cleanup(struct lcd_panel *panel) 123 - { 124 - gpio_free_array(_gpios, ARRAY_SIZE(_gpios)); 125 - } 126 - 127 102 static int ams_delta_panel_enable(struct lcd_panel *panel) 128 103 { 129 - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 1); 130 - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 1); 104 + gpiod_set_value(gpiod_ndisp, 1); 105 + gpiod_set_value(gpiod_vblen, 1); 131 106 return 0; 132 107 } 133 108 134 109 static void ams_delta_panel_disable(struct lcd_panel *panel) 135 110 { 136 - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_VBLEN, 0); 137 - gpio_set_value(AMS_DELTA_GPIO_PIN_LCD_NDISP, 0); 111 + gpiod_set_value(gpiod_vblen, 0); 112 + gpiod_set_value(gpiod_ndisp, 0); 138 113 } 139 114 140 115 static struct lcd_panel ams_delta_panel = { ··· 131 154 .pcd = 0, 132 155 .acb = 37, 133 156 134 - .init = ams_delta_panel_init, 135 - .cleanup = ams_delta_panel_cleanup, 136 157 .enable = ams_delta_panel_enable, 137 158 .disable = ams_delta_panel_disable, 138 159 }; ··· 141 166 static int ams_delta_panel_probe(struct platform_device *pdev) 142 167 { 143 168 struct lcd_device *lcd_device = NULL; 144 - #ifdef CONFIG_LCD_CLASS_DEVICE 145 169 int ret; 146 170 171 + gpiod_vblen = devm_gpiod_get(&pdev->dev, "vblen", GPIOD_OUT_LOW); 172 + if (IS_ERR(gpiod_vblen)) { 173 + ret = PTR_ERR(gpiod_vblen); 174 + dev_err(&pdev->dev, "VBLEN GPIO request failed (%d)\n", ret); 175 + return ret; 176 + } 177 + 178 + gpiod_ndisp = devm_gpiod_get(&pdev->dev, "ndisp", GPIOD_OUT_LOW); 179 + if (IS_ERR(gpiod_ndisp)) { 180 + ret = PTR_ERR(gpiod_ndisp); 181 + dev_err(&pdev->dev, "NDISP GPIO request failed (%d)\n", ret); 182 + return ret; 183 + } 184 + 185 + #ifdef CONFIG_LCD_CLASS_DEVICE 147 186 lcd_device = lcd_device_register("omapfb", &pdev->dev, NULL, 148 187 &ams_delta_lcd_ops); 149 188