Skip to content

Commit 93cc26f

Browse files
Linus WalleijLee Jones
authored andcommitted
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>
1 parent 5c8fe58 commit 93cc26f

3 files changed

Lines changed: 25 additions & 46 deletions

File tree

arch/arm/mach-pxa/z2.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <linux/spi/spi.h>
2121
#include <linux/spi/pxa2xx_spi.h>
2222
#include <linux/spi/libertas_spi.h>
23-
#include <linux/spi/lms283gf05.h>
2423
#include <linux/power_supply.h>
2524
#include <linux/mtd/physmap.h>
2625
#include <linux/gpio.h>
@@ -578,8 +577,13 @@ static struct pxa2xx_spi_chip lms283_chip_info = {
578577
.gpio_cs = GPIO88_ZIPITZ2_LCD_CS,
579578
};
580579

581-
static const struct lms283gf05_pdata lms283_pdata = {
582-
.reset_gpio = GPIO19_ZIPITZ2_LCD_RESET,
580+
static struct gpiod_lookup_table lms283_gpio_table = {
581+
.dev_id = "spi2.0", /* SPI bus 2 chip select 0 */
582+
.table = {
583+
GPIO_LOOKUP("gpio-pxa", GPIO19_ZIPITZ2_LCD_RESET,
584+
"reset", GPIO_ACTIVE_LOW),
585+
{ },
586+
},
583587
};
584588

585589
static struct spi_board_info spi_board_info[] __initdata = {
@@ -595,7 +599,6 @@ static struct spi_board_info spi_board_info[] __initdata = {
595599
{
596600
.modalias = "lms283gf05",
597601
.controller_data = &lms283_chip_info,
598-
.platform_data = &lms283_pdata,
599602
.max_speed_hz = 400000,
600603
.bus_num = 2,
601604
.chip_select = 0,
@@ -615,6 +618,7 @@ static void __init z2_spi_init(void)
615618
{
616619
pxa2xx_set_spi_info(1, &pxa_ssp1_master_info);
617620
pxa2xx_set_spi_info(2, &pxa_ssp2_master_info);
621+
gpiod_add_lookup_table(&lms283_gpio_table);
618622
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
619623
}
620624
#else

drivers/video/backlight/lms283gf05.c

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
#include <linux/kernel.h>
1010
#include <linux/delay.h>
1111
#include <linux/slab.h>
12-
#include <linux/gpio.h>
12+
#include <linux/gpio/consumer.h>
1313
#include <linux/lcd.h>
1414

1515
#include <linux/spi/spi.h>
16-
#include <linux/spi/lms283gf05.h>
1716
#include <linux/module.h>
1817

1918
struct lms283gf05_state {
2019
struct spi_device *spi;
2120
struct lcd_device *ld;
21+
struct gpio_desc *reset;
2222
};
2323

2424
struct lms283gf05_seq {
@@ -90,13 +90,13 @@ static const struct lms283gf05_seq disp_pdwnseq[] = {
9090
};
9191

9292

93-
static void lms283gf05_reset(unsigned long gpio, bool inverted)
93+
static void lms283gf05_reset(struct gpio_desc *gpiod)
9494
{
95-
gpio_set_value(gpio, !inverted);
95+
gpiod_set_value(gpiod, 0); /* De-asserted */
9696
mdelay(100);
97-
gpio_set_value(gpio, inverted);
97+
gpiod_set_value(gpiod, 1); /* Asserted */
9898
mdelay(20);
99-
gpio_set_value(gpio, !inverted);
99+
gpiod_set_value(gpiod, 0); /* De-asserted */
100100
mdelay(20);
101101
}
102102

@@ -125,18 +125,15 @@ static int lms283gf05_power_set(struct lcd_device *ld, int power)
125125
{
126126
struct lms283gf05_state *st = lcd_get_data(ld);
127127
struct spi_device *spi = st->spi;
128-
struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev);
129128

130129
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);
134132
lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq));
135133
} else {
136134
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 */
140137
}
141138

142139
return 0;
@@ -150,24 +147,18 @@ static struct lcd_ops lms_ops = {
150147
static int lms283gf05_probe(struct spi_device *spi)
151148
{
152149
struct lms283gf05_state *st;
153-
struct lms283gf05_pdata *pdata = dev_get_platdata(&spi->dev);
154150
struct lcd_device *ld;
155-
int ret = 0;
156-
157-
if (pdata != NULL) {
158-
ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio,
159-
GPIOF_DIR_OUT | (!pdata->reset_inverted ?
160-
GPIOF_INIT_HIGH : GPIOF_INIT_LOW),
161-
"LMS283GF05 RESET");
162-
if (ret)
163-
return ret;
164-
}
165151

166152
st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state),
167153
GFP_KERNEL);
168154
if (st == NULL)
169155
return -ENOMEM;
170156

157+
st->reset = gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
158+
if (IS_ERR(st->reset))
159+
return PTR_ERR(st->reset);
160+
gpiod_set_consumer_name(st->reset, "LMS283GF05 RESET");
161+
171162
ld = devm_lcd_device_register(&spi->dev, "lms283gf05", &spi->dev, st,
172163
&lms_ops);
173164
if (IS_ERR(ld))
@@ -179,8 +170,8 @@ static int lms283gf05_probe(struct spi_device *spi)
179170
spi_set_drvdata(spi, st);
180171

181172
/* kick in the LCD */
182-
if (pdata)
183-
lms283gf05_reset(pdata->reset_gpio, pdata->reset_inverted);
173+
if (st->reset)
174+
lms283gf05_reset(st->reset);
184175
lms283gf05_toggle(spi, disp_initseq, ARRAY_SIZE(disp_initseq));
185176

186177
return 0;

include/linux/spi/lms283gf05.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)