Skip to content

Commit 06a659d

Browse files
djrscallyrafaeljw
authored andcommitted
platform/x86: int3472: Support multiple gpio lookups in board data
Currently, we only support passing a single gpiod_lookup_table as part of the board data for the tps68470 driver. This carries the implicit assumption that each TPS68470 device will only support a single sensor, which does not hold true. Extend the code to support the possibility of multiple sensors each having a gpiod_lookup_table, and opportunistically add the lookup table for the Surface Go line's IR camera. Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Daniel Scally <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 43cf369 commit 06a659d

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

drivers/platform/x86/intel/int3472/tps68470.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client)
150150
int n_consumers;
151151
int device_type;
152152
int ret;
153+
int i;
153154

154155
n_consumers = skl_int3472_fill_clk_pdata(&client->dev, &clk_pdata);
155156
if (n_consumers < 0)
@@ -194,15 +195,18 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client)
194195
cells[1].pdata_size = sizeof(struct tps68470_regulator_platform_data);
195196
cells[2].name = "tps68470-gpio";
196197

197-
gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_table);
198+
for (i = 0; i < board_data->n_gpiod_lookups; i++)
199+
gpiod_add_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
198200

199201
ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
200202
cells, TPS68470_WIN_MFD_CELL_COUNT,
201203
NULL, 0, NULL);
202204
kfree(cells);
203205

204-
if (ret)
205-
gpiod_remove_lookup_table(board_data->tps68470_gpio_lookup_table);
206+
if (ret) {
207+
for (i = 0; i < board_data->n_gpiod_lookups; i++)
208+
gpiod_remove_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
209+
}
206210

207211
break;
208212
case DESIGNED_FOR_CHROMEOS:
@@ -226,10 +230,13 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client)
226230
static int skl_int3472_tps68470_remove(struct i2c_client *client)
227231
{
228232
const struct int3472_tps68470_board_data *board_data;
233+
int i;
229234

230235
board_data = int3472_tps68470_get_board_data(dev_name(&client->dev));
231-
if (board_data)
232-
gpiod_remove_lookup_table(board_data->tps68470_gpio_lookup_table);
236+
if (board_data) {
237+
for (i = 0; i < board_data->n_gpiod_lookups; i++)
238+
gpiod_remove_lookup_table(board_data->tps68470_gpio_lookup_tables[i]);
239+
}
233240

234241
return 0;
235242
}

drivers/platform/x86/intel/int3472/tps68470.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ struct tps68470_regulator_platform_data;
1616

1717
struct int3472_tps68470_board_data {
1818
const char *dev_name;
19-
struct gpiod_lookup_table *tps68470_gpio_lookup_table;
2019
const struct tps68470_regulator_platform_data *tps68470_regulator_pdata;
20+
unsigned int n_gpiod_lookups;
21+
struct gpiod_lookup_table *tps68470_gpio_lookup_tables[];
2122
};
2223

2324
const struct int3472_tps68470_board_data *int3472_tps68470_get_board_data(const char *dev_name);

drivers/platform/x86/intel/int3472/tps68470_board_data.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static const struct tps68470_regulator_platform_data surface_go_tps68470_pdata =
9696
},
9797
};
9898

99-
static struct gpiod_lookup_table surface_go_tps68470_gpios = {
99+
static struct gpiod_lookup_table surface_go_int347a_gpios = {
100100
.dev_id = "i2c-INT347A:00",
101101
.table = {
102102
GPIO_LOOKUP("tps68470-gpio", 9, "reset", GPIO_ACTIVE_LOW),
@@ -105,16 +105,31 @@ static struct gpiod_lookup_table surface_go_tps68470_gpios = {
105105
}
106106
};
107107

108+
static struct gpiod_lookup_table surface_go_int347e_gpios = {
109+
.dev_id = "i2c-INT347E:00",
110+
.table = {
111+
GPIO_LOOKUP("tps68470-gpio", 5, "enable", GPIO_ACTIVE_HIGH),
112+
{ }
113+
}
114+
};
115+
108116
static const struct int3472_tps68470_board_data surface_go_tps68470_board_data = {
109117
.dev_name = "i2c-INT3472:05",
110-
.tps68470_gpio_lookup_table = &surface_go_tps68470_gpios,
111118
.tps68470_regulator_pdata = &surface_go_tps68470_pdata,
119+
.n_gpiod_lookups = 2,
120+
.tps68470_gpio_lookup_tables = {
121+
&surface_go_int347a_gpios,
122+
&surface_go_int347e_gpios,
123+
},
112124
};
113125

114126
static const struct int3472_tps68470_board_data surface_go3_tps68470_board_data = {
115127
.dev_name = "i2c-INT3472:01",
116-
.tps68470_gpio_lookup_table = &surface_go_tps68470_gpios,
117128
.tps68470_regulator_pdata = &surface_go_tps68470_pdata,
129+
.n_gpiod_lookups = 1,
130+
.tps68470_gpio_lookup_tables = {
131+
&surface_go_int347a_gpios
132+
},
118133
};
119134

120135
static const struct dmi_system_id int3472_tps68470_board_data_table[] = {

0 commit comments

Comments
 (0)