Skip to content

Commit b40088b

Browse files
dtorij-intel
authored andcommitted
platform/x86: x86-android-tablets: convert Goodix devices to GPIO references
Now that gpiolib supports software nodes to describe GPIOs, switch the driver away from using GPIO lookup tables for Goodix touchscreens to using PROPERTY_ENTRY_GPIO() to keep all touchscreen properties together. Since the tablets are using either Baytrail or Cherryview GPIO controllers x86_dev_info structure has been extended to carry gpiochip type information so that the code can instantiate correct set of software nodes representing the GPIO chip. Because this adds a new point of failure in x86_android_tablet_probe(), x86_android_tablet_remove() is rearranged to handle cases where battery swnode has not been registered yet, and registering of GPIO lookup tables is moved earlier as it can not fail. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Hans de Goede <hansg@kernel.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Hans de Goede <hansg@kernel.org> Link: https://patch.msgid.link/20250920200713.20193-2-hansg@kernel.org Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent e3b1320 commit b40088b

5 files changed

Lines changed: 105 additions & 58 deletions

File tree

drivers/platform/x86/x86-android-tablets/asus.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/gpio/machine.h>
12+
#include <linux/gpio/property.h>
1213
#include <linux/input.h>
1314
#include <linux/platform_device.h>
1415

@@ -77,6 +78,16 @@ static const struct software_node asus_me176c_ug3105_node = {
7778
.properties = asus_me176c_ug3105_props,
7879
};
7980

81+
static const struct property_entry asus_me176c_touchscreen_props[] = {
82+
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[0], 60, GPIO_ACTIVE_HIGH),
83+
PROPERTY_ENTRY_GPIO("irq-gpios", &baytrail_gpiochip_nodes[2], 28, GPIO_ACTIVE_HIGH),
84+
{ }
85+
};
86+
87+
static const struct software_node asus_me176c_touchscreen_node = {
88+
.properties = asus_me176c_touchscreen_props,
89+
};
90+
8091
static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst = {
8192
{
8293
/* bq24297 battery charger */
@@ -132,6 +143,7 @@ static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst =
132143
.type = "GDIX1001:00",
133144
.addr = 0x14,
134145
.dev_name = "goodix_ts",
146+
.swnode = &asus_me176c_touchscreen_node,
135147
},
136148
.adapter_path = "\\_SB_.I2C6",
137149
.irq_data = {
@@ -152,18 +164,8 @@ static const struct x86_serdev_info asus_me176c_serdevs[] __initconst = {
152164
},
153165
};
154166

155-
static struct gpiod_lookup_table asus_me176c_goodix_gpios = {
156-
.dev_id = "i2c-goodix_ts",
157-
.table = {
158-
GPIO_LOOKUP("INT33FC:00", 60, "reset", GPIO_ACTIVE_HIGH),
159-
GPIO_LOOKUP("INT33FC:02", 28, "irq", GPIO_ACTIVE_HIGH),
160-
{ }
161-
},
162-
};
163-
164167
static struct gpiod_lookup_table * const asus_me176c_gpios[] = {
165168
&int3496_gpo2_pin22_gpios,
166-
&asus_me176c_goodix_gpios,
167169
NULL
168170
};
169171

@@ -179,6 +181,7 @@ const struct x86_dev_info asus_me176c_info __initconst = {
179181
.gpiod_lookup_tables = asus_me176c_gpios,
180182
.bat_swnode = &generic_lipo_hv_4v35_battery_node,
181183
.modules = bq24190_modules,
184+
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
182185
};
183186

184187
/* Asus TF103C tablets have an Android factory image with everything hardcoded */

drivers/platform/x86/x86-android-tablets/core.c

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ static struct serdev_device **serdevs;
155155
static struct gpio_keys_button *buttons;
156156
static struct gpiod_lookup_table * const *gpiod_lookup_tables;
157157
static const struct software_node *bat_swnode;
158+
static const struct software_node **gpiochip_node_group;
158159
static void (*exit_handler)(void);
159160

160161
static __init struct i2c_adapter *
@@ -330,6 +331,34 @@ static __init int x86_instantiate_serdev(const struct x86_dev_info *dev_info, in
330331
return ret;
331332
}
332333

334+
const struct software_node baytrail_gpiochip_nodes[] = {
335+
{ .name = "INT33FC:00" },
336+
{ .name = "INT33FC:01" },
337+
{ .name = "INT33FC:02" },
338+
};
339+
340+
static const struct software_node *baytrail_gpiochip_node_group[] = {
341+
&baytrail_gpiochip_nodes[0],
342+
&baytrail_gpiochip_nodes[1],
343+
&baytrail_gpiochip_nodes[2],
344+
NULL
345+
};
346+
347+
const struct software_node cherryview_gpiochip_nodes[] = {
348+
{ .name = "INT33FF:00" },
349+
{ .name = "INT33FF:01" },
350+
{ .name = "INT33FF:02" },
351+
{ .name = "INT33FF:03" },
352+
};
353+
354+
static const struct software_node *cherryview_gpiochip_node_group[] = {
355+
&cherryview_gpiochip_nodes[0],
356+
&cherryview_gpiochip_nodes[1],
357+
&cherryview_gpiochip_nodes[2],
358+
&cherryview_gpiochip_nodes[3],
359+
NULL
360+
};
361+
333362
static void x86_android_tablet_remove(struct platform_device *pdev)
334363
{
335364
int i;
@@ -360,10 +389,14 @@ static void x86_android_tablet_remove(struct platform_device *pdev)
360389
if (exit_handler)
361390
exit_handler();
362391

392+
if (bat_swnode)
393+
software_node_unregister(bat_swnode);
394+
395+
if (gpiochip_node_group)
396+
software_node_unregister_node_group(gpiochip_node_group);
397+
363398
for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
364399
gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
365-
366-
software_node_unregister(bat_swnode);
367400
}
368401

369402
static __init int x86_android_tablet_probe(struct platform_device *pdev)
@@ -387,16 +420,36 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev)
387420
for (i = 0; dev_info->modules && dev_info->modules[i]; i++)
388421
request_module(dev_info->modules[i]);
389422

390-
bat_swnode = dev_info->bat_swnode;
391-
if (bat_swnode) {
392-
ret = software_node_register(bat_swnode);
423+
gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
424+
for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
425+
gpiod_add_lookup_table(gpiod_lookup_tables[i]);
426+
427+
switch (dev_info->gpiochip_type) {
428+
case X86_GPIOCHIP_BAYTRAIL:
429+
gpiochip_node_group = baytrail_gpiochip_node_group;
430+
break;
431+
case X86_GPIOCHIP_CHERRYVIEW:
432+
gpiochip_node_group = cherryview_gpiochip_node_group;
433+
break;
434+
case X86_GPIOCHIP_UNSPECIFIED:
435+
gpiochip_node_group = NULL;
436+
break;
437+
}
438+
439+
if (gpiochip_node_group) {
440+
ret = software_node_register_node_group(gpiochip_node_group);
393441
if (ret)
394442
return ret;
395443
}
396444

397-
gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
398-
for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
399-
gpiod_add_lookup_table(gpiod_lookup_tables[i]);
445+
if (dev_info->bat_swnode) {
446+
ret = software_node_register(dev_info->bat_swnode);
447+
if (ret) {
448+
x86_android_tablet_remove(pdev);
449+
return ret;
450+
}
451+
bat_swnode = dev_info->bat_swnode;
452+
}
400453

401454
if (dev_info->init) {
402455
ret = dev_info->init(&pdev->dev);

drivers/platform/x86/x86-android-tablets/lenovo.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <linux/efi.h>
1414
#include <linux/gpio/machine.h>
15+
#include <linux/gpio/property.h>
1516
#include <linux/mfd/arizona/pdata.h>
1617
#include <linux/mfd/arizona/registers.h>
1718
#include <linux/mfd/intel_soc_pmic.h>
@@ -61,6 +62,16 @@ static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = {
6162

6263
/* Lenovo Yoga Book X90F / X90L's Android factory image has everything hardcoded */
6364

65+
static const struct property_entry lenovo_yb1_x90_goodix_props[] = {
66+
PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[1], 53, GPIO_ACTIVE_HIGH),
67+
PROPERTY_ENTRY_GPIO("irq-gpios", &cherryview_gpiochip_nodes[1], 56, GPIO_ACTIVE_HIGH),
68+
{ }
69+
};
70+
71+
static const struct software_node lenovo_yb1_x90_goodix_node = {
72+
.properties = lenovo_yb1_x90_goodix_props,
73+
};
74+
6475
static const struct property_entry lenovo_yb1_x90_wacom_props[] = {
6576
PROPERTY_ENTRY_U32("hid-descr-addr", 0x0001),
6677
PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 150),
@@ -108,6 +119,7 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
108119
.type = "GDIX1001:00",
109120
.addr = 0x14,
110121
.dev_name = "goodix_ts",
122+
.swnode = &lenovo_yb1_x90_goodix_node,
111123
},
112124
.adapter_path = "\\_SB_.PCI0.I2C2",
113125
.irq_data = {
@@ -198,15 +210,6 @@ static const struct x86_gpio_button lenovo_yb1_x90_lid __initconst = {
198210
.pin = 19,
199211
};
200212

201-
static struct gpiod_lookup_table lenovo_yb1_x90_goodix_gpios = {
202-
.dev_id = "i2c-goodix_ts",
203-
.table = {
204-
GPIO_LOOKUP("INT33FF:01", 53, "reset", GPIO_ACTIVE_HIGH),
205-
GPIO_LOOKUP("INT33FF:01", 56, "irq", GPIO_ACTIVE_HIGH),
206-
{ }
207-
},
208-
};
209-
210213
static struct gpiod_lookup_table lenovo_yb1_x90_hideep_gpios = {
211214
.dev_id = "i2c-hideep_ts",
212215
.table = {
@@ -225,7 +228,6 @@ static struct gpiod_lookup_table lenovo_yb1_x90_wacom_gpios = {
225228

226229
static struct gpiod_lookup_table * const lenovo_yb1_x90_gpios[] = {
227230
&lenovo_yb1_x90_hideep_gpios,
228-
&lenovo_yb1_x90_goodix_gpios,
229231
&lenovo_yb1_x90_wacom_gpios,
230232
NULL
231233
};
@@ -259,6 +261,7 @@ const struct x86_dev_info lenovo_yogabook_x90_info __initconst = {
259261
.gpio_button = &lenovo_yb1_x90_lid,
260262
.gpio_button_count = 1,
261263
.gpiod_lookup_tables = lenovo_yb1_x90_gpios,
264+
.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
262265
.init = lenovo_yb1_x90_init,
263266
};
264267

drivers/platform/x86/x86-android-tablets/other.c

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/acpi.h>
1212
#include <linux/gpio/machine.h>
13+
#include <linux/gpio/property.h>
1314
#include <linux/input.h>
1415
#include <linux/leds.h>
1516
#include <linux/pci.h>
@@ -297,6 +298,8 @@ static const struct software_node medion_lifetab_s10346_accel_node = {
297298
static const struct property_entry medion_lifetab_s10346_touchscreen_props[] = {
298299
PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
299300
PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
301+
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[1], 26, GPIO_ACTIVE_HIGH),
302+
PROPERTY_ENTRY_GPIO("irq-gpios", &baytrail_gpiochip_nodes[2], 3, GPIO_ACTIVE_HIGH),
300303
{ }
301304
};
302305

@@ -340,24 +343,10 @@ static const struct x86_i2c_client_info medion_lifetab_s10346_i2c_clients[] __in
340343
},
341344
};
342345

343-
static struct gpiod_lookup_table medion_lifetab_s10346_goodix_gpios = {
344-
.dev_id = "i2c-goodix_ts",
345-
.table = {
346-
GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
347-
GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
348-
{ }
349-
},
350-
};
351-
352-
static struct gpiod_lookup_table * const medion_lifetab_s10346_gpios[] = {
353-
&medion_lifetab_s10346_goodix_gpios,
354-
NULL
355-
};
356-
357346
const struct x86_dev_info medion_lifetab_s10346_info __initconst = {
358347
.i2c_client_info = medion_lifetab_s10346_i2c_clients,
359348
.i2c_client_count = ARRAY_SIZE(medion_lifetab_s10346_i2c_clients),
360-
.gpiod_lookup_tables = medion_lifetab_s10346_gpios,
349+
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
361350
};
362351

363352
/* Nextbook Ares 8 (BYT) tablets have an Android factory image with everything hardcoded */
@@ -543,6 +532,8 @@ static const struct property_entry whitelabel_tm800a550l_goodix_props[] = {
543532
PROPERTY_ENTRY_STRING("firmware-name", "gt912-tm800a550l.fw"),
544533
PROPERTY_ENTRY_STRING("goodix,config-name", "gt912-tm800a550l.cfg"),
545534
PROPERTY_ENTRY_U32("goodix,main-clk", 54),
535+
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[1], 26, GPIO_ACTIVE_HIGH),
536+
PROPERTY_ENTRY_GPIO("irq-gpios", &baytrail_gpiochip_nodes[2], 3, GPIO_ACTIVE_HIGH),
546537
{ }
547538
};
548539

@@ -578,24 +569,10 @@ static const struct x86_i2c_client_info whitelabel_tm800a550l_i2c_clients[] __in
578569
},
579570
};
580571

581-
static struct gpiod_lookup_table whitelabel_tm800a550l_goodix_gpios = {
582-
.dev_id = "i2c-goodix_ts",
583-
.table = {
584-
GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
585-
GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
586-
{ }
587-
},
588-
};
589-
590-
static struct gpiod_lookup_table * const whitelabel_tm800a550l_gpios[] = {
591-
&whitelabel_tm800a550l_goodix_gpios,
592-
NULL
593-
};
594-
595572
const struct x86_dev_info whitelabel_tm800a550l_info __initconst = {
596573
.i2c_client_info = whitelabel_tm800a550l_i2c_clients,
597574
.i2c_client_count = ARRAY_SIZE(whitelabel_tm800a550l_i2c_clients),
598-
.gpiod_lookup_tables = whitelabel_tm800a550l_gpios,
575+
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
599576
};
600577

601578
/*

drivers/platform/x86/x86-android-tablets/x86-android-tablets.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ enum x86_acpi_irq_type {
3232
X86_ACPI_IRQ_TYPE_PMIC,
3333
};
3434

35+
enum x86_gpiochip_type {
36+
X86_GPIOCHIP_UNSPECIFIED = 0,
37+
X86_GPIOCHIP_BAYTRAIL,
38+
X86_GPIOCHIP_CHERRYVIEW,
39+
};
40+
3541
struct x86_acpi_irq_data {
3642
char *chip; /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */
3743
enum x86_acpi_irq_type type;
@@ -99,13 +105,18 @@ struct x86_dev_info {
99105
int (*init)(struct device *dev);
100106
void (*exit)(void);
101107
bool use_pci;
108+
enum x86_gpiochip_type gpiochip_type;
102109
};
103110

104111
int x86_android_tablet_get_gpiod(const char *chip, int pin, const char *con_id,
105112
bool active_low, enum gpiod_flags dflags,
106113
struct gpio_desc **desc);
107114
int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data);
108115

116+
/* Software nodes representing GPIO chips used by various tablets */
117+
extern const struct software_node baytrail_gpiochip_nodes[];
118+
extern const struct software_node cherryview_gpiochip_nodes[];
119+
109120
/*
110121
* Extern declarations of x86_dev_info structs so there can be a single
111122
* MODULE_DEVICE_TABLE(dmi, ...), while splitting the board descriptions.

0 commit comments

Comments
 (0)