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

backlight: lms283gf05: Convert to GPIO descriptors

This converts the lms283gf05 backlight driver to use GPIO
descriptors and switches the single PXA Palm Z2 device
over to defining these.

Since the platform data was only used to convey GPIO
information we can delete the platform data header.

Notice that we define the proper active low semantics in
the board file GPIO descriptor table (active low) and
assert the reset line by bringing it to "1" (asserted).

Cc: Marek Vasut <marex@denx.de>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Daniel Mack <daniel@zonque.org>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Linus Walleij and committed by
Lee Jones
93cc26fa 5c8fe583

+25 -46
+8 -4
arch/arm/mach-pxa/z2.c
··· 20 20 #include <linux/spi/spi.h> 21 21 #include <linux/spi/pxa2xx_spi.h> 22 22 #include <linux/spi/libertas_spi.h> 23 - #include <linux/spi/lms283gf05.h> 24 23 #include <linux/power_supply.h> 25 24 #include <linux/mtd/physmap.h> 26 25 #include <linux/gpio.h> ··· 577 578 .gpio_cs = GPIO88_ZIPITZ2_LCD_CS, 578 579 }; 579 580 580 - static const struct lms283gf05_pdata lms283_pdata = { 581 - .reset_gpio = GPIO19_ZIPITZ2_LCD_RESET, 581 + static struct gpiod_lookup_table lms283_gpio_table = { 582 + .dev_id = "spi2.0", /* SPI bus 2 chip select 0 */ 583 + .table = { 584 + GPIO_LOOKUP("gpio-pxa", GPIO19_ZIPITZ2_LCD_RESET, 585 + "reset", GPIO_ACTIVE_LOW), 586 + { }, 587 + }, 582 588 }; 583 589 584 590 static struct spi_board_info spi_board_info[] __initdata = { ··· 599 595 { 600 596 .modalias = "lms283gf05", 601 597 .controller_data = &lms283_chip_info, 602 - .platform_data = &lms283_pdata, 603 598 .max_speed_hz = 400000, 604 599 .bus_num = 2, 605 600 .chip_select = 0, ··· 618 615 { 619 616 pxa2xx_set_spi_info(1, &pxa_ssp1_master_info); 620 617 pxa2xx_set_spi_info(2, &pxa_ssp2_master_info); 618 + gpiod_add_lookup_table(&lms283_gpio_table); 621 619 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); 622 620 } 623 621 #else
+17 -26
drivers/video/backlight/lms283gf05.c
··· 9 9 #include <linux/kernel.h> 10 10 #include <linux/delay.h> 11 11 #include <linux/slab.h> 12 - #include <linux/gpio.h> 12 + #include <linux/gpio/consumer.h> 13 13 #include <linux/lcd.h> 14 14 15 15 #include <linux/spi/spi.h> 16 - #include <linux/spi/lms283gf05.h> 17 16 #include <linux/module.h> 18 17 19 18 struct lms283gf05_state { 20 19 struct spi_device *spi; 21 20 struct lcd_device *ld; 21 + struct gpio_desc *reset; 22 22 }; 23 23 24 24 struct lms283gf05_seq { ··· 90 90 }; 91 91 92 92 93 - static void lms283gf05_reset(unsigned long gpio, bool inverted) 93 + static void lms283gf05_reset(struct gpio_desc *gpiod) 94 94 { 95 - gpio_set_value(gpio, !inverted); 95 + gpiod_set_value(gpiod, 0); /* De-asserted */ 96 96 mdelay(100); 97 - gpio_set_value(gpio, inverted); 97 + gpiod_set_value(gpiod, 1); /* Asserted */ 98 98 mdelay(20); 99 - gpio_set_value(gpio, !inverted); 99 + gpiod_set_value(gpiod, 0); /* De-asserted */ 100 100 mdelay(20); 101 101 } 102 102 ··· 125 125 { 126 126 struct lms283gf05_state *st = lcd_get_data(ld); 127 127 struct spi_device *spi = st->spi; 128 - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); 129 128 130 129 if (power <= FB_BLANK_NORMAL) { 131 - if (pdata) 132 - lms283gf05_reset(pdata->reset_gpio, 133 - pdata->reset_inverted); 130 + if (st->reset) 131 + lms283gf05_reset(st->reset); 134 132 lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); 135 133 } else { 136 134 lms283gf05_toggle(spi, disp_pdwnseq, ARRAY_SIZE(disp_pdwnseq)); 137 - if (pdata) 138 - gpio_set_value(pdata->reset_gpio, 139 - pdata->reset_inverted); 135 + if (st->reset) 136 + gpiod_set_value(st->reset, 1); /* Asserted */ 140 137 } 141 138 142 139 return 0; ··· 147 150 static int lms283gf05_probe(struct spi_device *spi) 148 151 { 149 152 struct lms283gf05_state *st; 150 - struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev); 151 153 struct lcd_device *ld; 152 - int ret = 0; 153 - 154 - if (pdata != NULL) { 155 - ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio, 156 - GPIOF_DIR_OUT | (!pdata->reset_inverted ? 157 - GPIOF_INIT_HIGH : GPIOF_INIT_LOW), 158 - "LMS283GF05 RESET"); 159 - if (ret) 160 - return ret; 161 - } 162 154 163 155 st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state), 164 156 GFP_KERNEL); 165 157 if (st == NULL) 166 158 return -ENOMEM; 159 + 160 + st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW); 161 + if (IS_ERR(st->reset)) 162 + return PTR_ERR(st->reset); 163 + gpiod_set_consumer_name(st->reset, "LMS283GF05 RESET"); 167 164 168 165 ld = devm_lcd_device_register(&spi->dev, "lms283gf05", &spi->dev, st, 169 166 &lms_ops); ··· 170 179 spi_set_drvdata(spi, st); 171 180 172 181 /* kick in the LCD */ 173 - if (pdata) 174 - lms283gf05_reset(pdata->reset_gpio, pdata->reset_inverted); 182 + if (st->reset) 183 + lms283gf05_reset(st->reset); 175 184 lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq)); 176 185 177 186 return 0;
-16
include/linux/spi/lms283gf05.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * lms283gf05.h - Platform glue for Samsung LMS283GF05 LCD 4 - * 5 - * Copyright (C) 2009 Marek Vasut <marek.vasut@gmail.com> 6 - */ 7 - 8 - #ifndef _INCLUDE_LINUX_SPI_LMS283GF05_H_ 9 - #define _INCLUDE_LINUX_SPI_LMS283GF05_H_ 10 - 11 - struct lms283gf05_pdata { 12 - unsigned long reset_gpio; 13 - bool reset_inverted; 14 - }; 15 - 16 - #endif /* _INCLUDE_LINUX_SPI_LMS283GF05_H_ */