Skip to content

Commit 0b0cb52

Browse files
arndbLee Jones
authored andcommitted
video: backlight: tosa: Use GPIO lookup table
The driver should not require a machine specific header. Change it to pass the GPIO line through a lookup table, and move the timing generator definitions into the drivers itself. Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Robert Jarzmik <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 8663c18 commit 0b0cb52

File tree

5 files changed

+56
-27
lines changed

5 files changed

+56
-27
lines changed

arch/arm/mach-pxa/include/mach/tosa.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@
7272
#define TOSA_GPIO_BAT0_TH_ON (TOSA_TC6393XB_GPIO_BASE + 14)
7373
#define TOSA_GPIO_BAT1_TH_ON (TOSA_TC6393XB_GPIO_BASE + 15)
7474

75-
/*
76-
* Timing Generator
77-
*/
78-
#define TG_PNLCTL 0x00
79-
#define TG_TPOSCTL 0x01
80-
#define TG_DUTYCTL 0x02
81-
#define TG_GPOSR 0x03
82-
#define TG_GPODR1 0x04
83-
#define TG_GPODR2 0x05
84-
#define TG_PINICTL 0x06
85-
#define TG_HPOSCTL 0x07
86-
8775
/*
8876
* PXA GPIOs
8977
*/
@@ -192,7 +180,4 @@
192180
#define TOSA_KEY_MAIL KEY_MAIL
193181
#endif
194182

195-
struct spi_device;
196-
extern int tosa_bl_enable(struct spi_device *spi, int enable);
197-
198183
#endif /* _ASM_ARCH_TOSA_H_ */

arch/arm/mach-pxa/tosa.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,26 @@ static struct pxa2xx_spi_controller pxa_ssp_master_info = {
813813
.num_chipselect = 1,
814814
};
815815

816+
static struct gpiod_lookup_table tosa_lcd_gpio_table = {
817+
.dev_id = "spi2.0",
818+
.table = {
819+
GPIO_LOOKUP("tc6393xb",
820+
TOSA_GPIO_TG_ON - TOSA_TC6393XB_GPIO_BASE,
821+
"tg #pwr", GPIO_ACTIVE_HIGH),
822+
{ },
823+
},
824+
};
825+
826+
static struct gpiod_lookup_table tosa_lcd_bl_gpio_table = {
827+
.dev_id = "i2c-tosa-bl",
828+
.table = {
829+
GPIO_LOOKUP("tc6393xb",
830+
TOSA_GPIO_BL_C20MA - TOSA_TC6393XB_GPIO_BASE,
831+
"backlight", GPIO_ACTIVE_HIGH),
832+
{ },
833+
},
834+
};
835+
816836
static struct spi_board_info spi_board_info[] __initdata = {
817837
{
818838
.modalias = "tosa-lcd",
@@ -923,6 +943,8 @@ static void __init tosa_init(void)
923943
platform_scoop_config = &tosa_pcmcia_config;
924944

925945
pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
946+
gpiod_add_lookup_table(&tosa_lcd_gpio_table);
947+
gpiod_add_lookup_table(&tosa_lcd_bl_gpio_table);
926948
spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
927949

928950
clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);

drivers/video/backlight/tosa_bl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include <asm/mach/sharpsl_param.h>
2020

21-
#include <mach/tosa.h>
21+
#include "tosa_bl.h"
2222

2323
#define COMADJ_DEFAULT 97
2424

@@ -28,6 +28,7 @@
2828
struct tosa_bl_data {
2929
struct i2c_client *i2c;
3030
struct backlight_device *bl;
31+
struct gpio_desc *gpio;
3132

3233
int comadj;
3334
};
@@ -42,7 +43,7 @@ static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness)
4243
i2c_smbus_write_byte_data(data->i2c, DAC_CH2, (u8)(brightness & 0xff));
4344

4445
/* SetBacklightVR */
45-
gpio_set_value(TOSA_GPIO_BL_C20MA, brightness & 0x100);
46+
gpiod_set_value(data->gpio, brightness & 0x100);
4647

4748
tosa_bl_enable(spi, brightness);
4849
}
@@ -87,9 +88,8 @@ static int tosa_bl_probe(struct i2c_client *client,
8788
return -ENOMEM;
8889

8990
data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj;
90-
91-
ret = devm_gpio_request_one(&client->dev, TOSA_GPIO_BL_C20MA,
92-
GPIOF_OUT_INIT_LOW, "backlight");
91+
data->gpio = devm_gpiod_get(&client->dev, "backlight", GPIOD_OUT_LOW);
92+
ret = PTR_ERR_OR_ZERO(data->gpio);
9393
if (ret) {
9494
dev_dbg(&data->bl->dev, "Unable to request gpio!\n");
9595
return ret;

drivers/video/backlight/tosa_bl.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
#ifndef _TOSA_BL_H
3+
#define _TOSA_BL_H
4+
5+
struct spi_device;
6+
extern int tosa_bl_enable(struct spi_device *spi, int enable);
7+
8+
#endif

drivers/video/backlight/tosa_lcd.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <asm/mach/sharpsl_param.h>
2121

22-
#include <mach/tosa.h>
22+
#include "tosa_bl.h"
2323

2424
#define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL)
2525

@@ -28,12 +28,26 @@
2828
#define TG_REG0_UD 0x0004
2929
#define TG_REG0_LR 0x0008
3030

31+
/*
32+
* Timing Generator
33+
*/
34+
#define TG_PNLCTL 0x00
35+
#define TG_TPOSCTL 0x01
36+
#define TG_DUTYCTL 0x02
37+
#define TG_GPOSR 0x03
38+
#define TG_GPODR1 0x04
39+
#define TG_GPODR2 0x05
40+
#define TG_PINICTL 0x06
41+
#define TG_HPOSCTL 0x07
42+
43+
3144
#define DAC_BASE 0x4e
3245

3346
struct tosa_lcd_data {
3447
struct spi_device *spi;
3548
struct lcd_device *lcd;
3649
struct i2c_client *i2c;
50+
struct gpio_desc *gpiod_tg;
3751

3852
int lcd_power;
3953
bool is_vga;
@@ -66,7 +80,7 @@ EXPORT_SYMBOL(tosa_bl_enable);
6680
static void tosa_lcd_tg_init(struct tosa_lcd_data *data)
6781
{
6882
/* TG on */
69-
gpio_set_value(TOSA_GPIO_TG_ON, 0);
83+
gpiod_set_value(data->gpiod_tg, 0);
7084

7185
mdelay(60);
7286

@@ -100,6 +114,7 @@ static void tosa_lcd_tg_on(struct tosa_lcd_data *data)
100114
*/
101115
struct i2c_adapter *adap = i2c_get_adapter(0);
102116
struct i2c_board_info info = {
117+
.dev_name = "tosa-bl",
103118
.type = "tosa-bl",
104119
.addr = DAC_BASE,
105120
.platform_data = data->spi,
@@ -121,7 +136,7 @@ static void tosa_lcd_tg_off(struct tosa_lcd_data *data)
121136
mdelay(50);
122137

123138
/* TG Off */
124-
gpio_set_value(TOSA_GPIO_TG_ON, 1);
139+
gpiod_set_value(data->gpiod_tg, 1);
125140
mdelay(100);
126141
}
127142

@@ -191,10 +206,9 @@ static int tosa_lcd_probe(struct spi_device *spi)
191206
data->spi = spi;
192207
spi_set_drvdata(spi, data);
193208

194-
ret = devm_gpio_request_one(&spi->dev, TOSA_GPIO_TG_ON,
195-
GPIOF_OUT_INIT_LOW, "tg #pwr");
196-
if (ret < 0)
197-
return ret;
209+
data->gpiod_tg = devm_gpiod_get(&spi->dev, "tg #pwr", GPIOD_OUT_LOW);
210+
if (IS_ERR(data->gpiod_tg))
211+
return PTR_ERR(data->gpiod_tg);
198212

199213
mdelay(60);
200214

0 commit comments

Comments
 (0)