Skip to contentSkip to conversation

platform/x86: x86-android-tablets: Add battery swnode support

PATCH In review Hans de Goede 2 participants 14 messages Feb 5, 2022 – Feb 11, 2022 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 platform/x86: x86-android-tablets: Add battery swnode support

power_supply_get_battery_info() which is used by charger and fuel-gauge drivers on x86-android-tablets, expects the battery properties to be described in a stand-alone battery fwnode which is then referenced from both the charger and fuel-gauge device's fwnodes.

Add support for registering + unregistering a swnode for this.

---
 drivers/platform/x86/x86-android-tablets.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/platform/x86/x86-android-tablets.c +11 -0
index 3120acf9837c..80d113c41623 100644
@@ -146,6 +146,7 @@ struct x86_serdev_info {
 struct x86_dev_info {
 	char *invalid_aei_gpiochip;
 	const char * const *modules;
+	const struct software_node *bat_swnode;
 	struct gpiod_lookup_table * const *gpiod_lookup_tables;
 	const struct x86_i2c_client_info *i2c_client_info;
 	const struct platform_device_info *pdev_info;
@@ -727,6 +728,7 @@ static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
 static struct gpiod_lookup_table * const *gpiod_lookup_tables;
+static const struct software_node *bat_swnode;
 static void (*exit_handler)(void);
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
@@ -850,6 +852,8 @@ static void x86_android_tablet_cleanup(void)
 
 	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
 		gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
+
+	software_node_unregister(bat_swnode);
 }
 
 static __init int x86_android_tablet_init(void)
@@ -886,6 +890,13 @@ static __init int x86_android_tablet_init(void)
 	for (i = 0; dev_info->modules && dev_info->modules[i]; i++)
 		request_module(dev_info->modules[i]);
 
+	bat_swnode = dev_info->bat_swnode;
+	if (bat_swnode) {
+		ret = software_node_register(bat_swnode);
+		if (ret)
+			return ret;
+	}
+
 	gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
 	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
 		gpiod_add_lookup_table(gpiod_lookup_tables[i]);
Signature · 1 line
2.33.1
#1 lore raw

PATCH 2/6 platform/x86: x86-android-tablets: Add Asus ME176C/TF103C charger and fuelgauge props

Add properties describing the battery on the Asus ME176C / TF103C tablets. The max constant charge volt / current settings were taken from the factory Android image on these tablets.

---
 drivers/platform/x86/x86-android-tablets.c | 97 +++++++++++++++++++---
 1 file changed, 85 insertions(+), 12 deletions(-)
drivers/platform/x86/x86-android-tablets.c +85 -12
index 80d113c41623..45a951002401 100644
@@ -158,21 +158,27 @@ struct x86_dev_info {
 	void (*exit)(void);
 };
 
-/* Generic / shared bq24190 settings */
-static const char * const bq24190_suppliers[] = { "tusb1210-psy" };
-
-static const struct property_entry bq24190_props[] = {
-	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
-	PROPERTY_ENTRY_BOOL("omit-battery-class"),
-	PROPERTY_ENTRY_BOOL("disable-reset"),
+/* Generic / shared charger / battery settings */
+static const char * const bq24190_suppliers[] = { "tusb1211-charger-detect" };
+static const char * const ug3105_suppliers[] = { "bq24190-charger" };
+
+/* LiPo HighVoltage (max 4.35V) settings used by most devs with a HV bat. */
+static const struct property_entry generic_lipo_hv_4v35_battery_props[] = {
+	PROPERTY_ENTRY_STRING("compatible", "simple-battery"),
+	PROPERTY_ENTRY_STRING("device-chemistry", "lithium-ion"),
+	PROPERTY_ENTRY_U32("precharge-current-microamp", 256000),
+	PROPERTY_ENTRY_U32("charge-term-current-microamp", 128000),
+	PROPERTY_ENTRY_U32("constant-charge-current-max-microamp", 1856000),
+	PROPERTY_ENTRY_U32("constant-charge-voltage-max-microvolt", 4352000),
+	PROPERTY_ENTRY_U32("factory-internal-resistance-micro-ohms", 150000),
 	{ }
 };
 
-static const struct software_node bq24190_node = {
-	.properties = bq24190_props,
+static const struct software_node generic_lipo_hv_4v35_battery_node = {
+	.properties = generic_lipo_hv_4v35_battery_props,
 };
 
-/* For enableing the bq24190 5V boost based on id-pin */
+/* For enabling the bq24190 5V boost based on id-pin */
 static struct regulator_consumer_supply intel_int3496_consumer = {
 	.supply = "vbus",
 	.dev_name = "intel-int3496",
@@ -230,6 +236,30 @@ static const struct software_node asus_me176c_accel_node = {
 	.properties = asus_me176c_accel_props,
 };
 
+static const struct property_entry asus_me176c_bq24190_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
+	PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
+	PROPERTY_ENTRY_U32("ti,system-minimum-microvolt", 3600000),
+	PROPERTY_ENTRY_BOOL("omit-battery-class"),
+	PROPERTY_ENTRY_BOOL("disable-reset"),
+	{ }
+};
+
+static const struct software_node asus_me176c_bq24190_node = {
+	.properties = asus_me176c_bq24190_props,
+};
+
+static const struct property_entry asus_me176c_ug3105_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", ug3105_suppliers),
+	PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
+	PROPERTY_ENTRY_U32("upi,rsns-microohm", 10000),
+	{ }
+};
+
+static const struct software_node asus_me176c_ug3105_node = {
+	.properties = asus_me176c_ug3105_props,
+};
+
 static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst = {
 	{
 		/* bq24190 battery charger */
@@ -237,7 +267,7 @@ static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst =
 			.type = "bq24190",
 			.addr = 0x6b,
 			.dev_name = "bq24190",
-			.swnode = &bq24190_node,
+			.swnode = &asus_me176c_bq24190_node,
 			.platform_data = &bq24190_pdata,
 		},
 		.adapter_path = "\\_SB_.I2C1",
@@ -253,6 +283,7 @@ static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst =
 			.type = "ug3105",
 			.addr = 0x70,
 			.dev_name = "ug3105",
+			.swnode = &asus_me176c_ug3105_node,
 		},
 		.adapter_path = "\\_SB_.I2C1",
 	}, {
@@ -321,6 +352,7 @@ static const struct x86_dev_info asus_me176c_info __initconst = {
 	.serdev_info = asus_me176c_serdevs,
 	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
 	.gpiod_lookup_tables = asus_me176c_gpios,
+	.bat_swnode = &generic_lipo_hv_4v35_battery_node,
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
 };
@@ -350,6 +382,45 @@ static const struct software_node asus_tf103c_touchscreen_node = {
 	.properties = asus_tf103c_touchscreen_props,
 };
 
+static const struct property_entry asus_tf103c_battery_props[] = {
+	PROPERTY_ENTRY_STRING("compatible", "simple-battery"),
+	PROPERTY_ENTRY_STRING("device-chemistry", "lithium-ion-polymer"),
+	PROPERTY_ENTRY_U32("precharge-current-microamp", 256000),
+	PROPERTY_ENTRY_U32("charge-term-current-microamp", 128000),
+	PROPERTY_ENTRY_U32("constant-charge-current-max-microamp", 2048000),
+	PROPERTY_ENTRY_U32("constant-charge-voltage-max-microvolt", 4208000),
+	PROPERTY_ENTRY_U32("factory-internal-resistance-micro-ohms", 150000),
+	{ }
+};
+
+static const struct software_node asus_tf103c_battery_node = {
+	.properties = asus_tf103c_battery_props,
+};
+
+static const struct property_entry asus_tf103c_bq24190_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
+	PROPERTY_ENTRY_REF("monitored-battery", &asus_tf103c_battery_node),
+	PROPERTY_ENTRY_U32("ti,system-minimum-microvolt", 3600000),
+	PROPERTY_ENTRY_BOOL("omit-battery-class"),
+	PROPERTY_ENTRY_BOOL("disable-reset"),
+	{ }
+};
+
+static const struct software_node asus_tf103c_bq24190_node = {
+	.properties = asus_tf103c_bq24190_props,
+};
+
+static const struct property_entry asus_tf103c_ug3105_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", ug3105_suppliers),
+	PROPERTY_ENTRY_REF("monitored-battery", &asus_tf103c_battery_node),
+	PROPERTY_ENTRY_U32("upi,rsns-microohm", 5000),
+	{ }
+};
+
+static const struct software_node asus_tf103c_ug3105_node = {
+	.properties = asus_tf103c_ug3105_props,
+};
+
 static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst = {
 	{
 		/* bq24190 battery charger */
@@ -357,7 +428,7 @@ static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst =
 			.type = "bq24190",
 			.addr = 0x6b,
 			.dev_name = "bq24190",
-			.swnode = &bq24190_node,
+			.swnode = &asus_tf103c_bq24190_node,
 			.platform_data = &bq24190_pdata,
 		},
 		.adapter_path = "\\_SB_.I2C1",
@@ -373,6 +444,7 @@ static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst =
 			.type = "ug3105",
 			.addr = 0x70,
 			.dev_name = "ug3105",
+			.swnode = &asus_tf103c_ug3105_node,
 		},
 		.adapter_path = "\\_SB_.I2C1",
 	}, {
@@ -422,6 +494,7 @@ static const struct x86_dev_info asus_tf103c_info __initconst = {
 	.pdev_info = int3496_pdevs,
 	.pdev_count = ARRAY_SIZE(int3496_pdevs),
 	.gpiod_lookup_tables = asus_tf103c_gpios,
+	.bat_swnode = &asus_tf103c_battery_node,
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
 };
Signature · 1 line
2.33.1
#2 lore raw

PATCH 3/6 platform/x86: x86-android-tablets: Add x86_android_tablet_get_gpiod() helper

In reply to Hans de Goede

Factor the code to go from a gpiochip label + pin-numer to a gpio_desc out of x86_acpi_irq_helper_get() and make it into a new x86_android_tablet_get_gpiod() helper, as this will be necessary in some x86_dev_info.init() functions too.

---
 drivers/platform/x86/x86-android-tablets.c | 35 ++++++++++++++--------
 1 file changed, 23 insertions(+), 12 deletions(-)
drivers/platform/x86/x86-android-tablets.c +23 -12
index 45a951002401..40243ea3ae39 100644
@@ -53,13 +53,33 @@ static int gpiochip_find_match_label(struct gpio_chip *gc, void *data)
 	return gc->label && !strcmp(gc->label, data);
 }
 
+static int x86_android_tablet_get_gpiod(char *label, int pin, struct gpio_desc **desc)
+{
+	struct gpio_desc *gpiod;
+	struct gpio_chip *chip;
+
+	chip = gpiochip_find(label, gpiochip_find_match_label);
+	if (!chip) {
+		pr_err("error cannot find GPIO chip %s\n", label);
+		return -ENODEV;
+	}
+
+	gpiod = gpiochip_get_desc(chip, pin);
+	if (IS_ERR(gpiod)) {
+		pr_err("error %ld getting GPIO %s %d\n", PTR_ERR(gpiod), label, pin);
+		return PTR_ERR(gpiod);
+	}
+
+	*desc = gpiod;
+	return 0;
+}
+
 static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 {
 	struct irq_fwspec fwspec = { };
 	struct irq_domain *domain;
 	struct acpi_device *adev;
 	struct gpio_desc *gpiod;
-	struct gpio_chip *chip;
 	unsigned int irq_type;
 	acpi_handle handle;
 	acpi_status status;
@@ -74,18 +94,9 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 		return irq;
 	case X86_ACPI_IRQ_TYPE_GPIOINT:
 		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
-		chip = gpiochip_find(data->chip, gpiochip_find_match_label);
-		if (!chip) {
-			pr_err("error cannot find GPIO chip %s\n", data->chip);
-			return -ENODEV;
-		}
-
-		gpiod = gpiochip_get_desc(chip, data->index);
-		if (IS_ERR(gpiod)) {
-			ret = PTR_ERR(gpiod);
-			pr_err("error %d getting GPIO %s %d\n", ret, data->chip, data->index);
+		ret = x86_android_tablet_get_gpiod(data->chip, data->index, &gpiod);
+		if (ret)
 			return ret;
-		}
 
 		irq = gpiod_to_irq(gpiod);
 		if (irq < 0) {
Signature · 1 line
2.33.1
#3 lore raw

PATCH 4/6 platform/x86: x86-android-tablets: Add lid-switch gpio-keys pdev to Asus ME176C + TF103C

In reply to Hans de Goede

The Asus ME176C + TF103C both have a lid-switch (for a cover in the ME176C case), add a gpio-keys platform-device and platform-data describing the lid-switch on both.

---
 drivers/platform/x86/x86-android-tablets.c | 57 ++++++++++++++++++++--
 1 file changed, 53 insertions(+), 4 deletions(-)
drivers/platform/x86/x86-android-tablets.c +53 -4
index 40243ea3ae39..6174aad572bc 100644
@@ -12,10 +12,12 @@
 
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/gpio_keys.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
+#include <linux/input.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
 #include <linux/module.h>
@@ -231,6 +233,51 @@ static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = {
 	},
 };
 
+/* Asus ME176C and TF103C tablets shared data */
+static struct gpio_keys_button asus_me176c_tf103c_lid = {
+	.code = SW_LID,
+	/* .gpio gets filled in by asus_me176c_tf103c_init() */
+	.active_low = true,
+	.desc = "lid_sw",
+	.type = EV_SW,
+	.wakeup = true,
+	.debounce_interval = 50,
+};
+
+static const struct gpio_keys_platform_data asus_me176c_tf103c_lid_pdata __initconst = {
+	.buttons = &asus_me176c_tf103c_lid,
+	.nbuttons = 1,
+	.name = "lid_sw",
+};
+
+static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst = {
+	{
+		.name = "gpio-keys",
+		.id = PLATFORM_DEVID_AUTO,
+		.data = &asus_me176c_tf103c_lid_pdata,
+		.size_data = sizeof(asus_me176c_tf103c_lid_pdata),
+	},
+	{
+		/* For micro USB ID pin handling */
+		.name = "intel-int3496",
+		.id = PLATFORM_DEVID_NONE,
+	},
+};
+
+static int __init asus_me176c_tf103c_init(void)
+{
+	struct gpio_desc *gpiod;
+	int ret;
+
+	ret = x86_android_tablet_get_gpiod("INT33FC:02", 12, &gpiod);
+	if (ret < 0)
+		return ret;
+	asus_me176c_tf103c_lid.gpio = desc_to_gpio(gpiod);
+
+	return 0;
+}
+
+
 /* Asus ME176C tablets have an Android factory img with everything hardcoded */
 static const char * const asus_me176c_accel_mount_matrix[] = {
 	"-1", "0", "0",
@@ -358,14 +405,15 @@ static struct gpiod_lookup_table * const asus_me176c_gpios[] = {
 static const struct x86_dev_info asus_me176c_info __initconst = {
 	.i2c_client_info = asus_me176c_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(asus_me176c_i2c_clients),
-	.pdev_info = int3496_pdevs,
-	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.pdev_info = asus_me176c_tf103c_pdevs,
+	.pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),
 	.serdev_info = asus_me176c_serdevs,
 	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
 	.gpiod_lookup_tables = asus_me176c_gpios,
 	.bat_swnode = &generic_lipo_hv_4v35_battery_node,
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
+	.init = asus_me176c_tf103c_init,
 };
 
 /* Asus TF103C tablets have an Android factory img with everything hardcoded */
@@ -502,12 +550,13 @@ static struct gpiod_lookup_table * const asus_tf103c_gpios[] = {
 static const struct x86_dev_info asus_tf103c_info __initconst = {
 	.i2c_client_info = asus_tf103c_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(asus_tf103c_i2c_clients),
-	.pdev_info = int3496_pdevs,
-	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.pdev_info = asus_me176c_tf103c_pdevs,
+	.pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),
 	.gpiod_lookup_tables = asus_tf103c_gpios,
 	.bat_swnode = &asus_tf103c_battery_node,
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
+	.init = asus_me176c_tf103c_init,
 };
 
 /*
Signature · 1 line
2.33.1
#4 lore raw

Re: [PATCH 4/6] platform/x86: x86-android-tablets: Add lid-switch gpio-keys pdev to Asus ME176C + TF103C

Quoted 4 lines · Hans de Goede

The Asus ME176C + TF103C both have a lid-switch (for a cover in the ME176C case), add a gpio-keys platform-device and platform-data describing the lid-switch on both.

USB ID change is not described here.

...

+/* Asus ME176C and TF103C tablets shared data */

drivers/platform/x86/x86-android-tablets.c static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = { · line 239

Quoted 4 lines
drivers/platform/x86/x86-android-tablets.c +3 -0
+static struct gpio_keys_button asus_me176c_tf103c_lid = {
+       .code = SW_LID,
 
+       /* .gpio gets filled in by asus_me176c_tf103c_init() */

I'm wondering if we can switch gpio_keys*.c drivers to accept GPIO descriptor directly.

Quoted 6 lines
drivers/platform/x86/x86-android-tablets.c +6 -0
+       .active_low = true,
+       .desc = "lid_sw",
+       .type = EV_SW,
+       .wakeup = true,
+       .debounce_interval = 50,
+};
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [PATCH 4/6] platform/x86: x86-android-tablets: Add lid-switch gpio-keys pdev to Asus ME176C + TF103C

Hi,

Quoted 7 lines · Andy Shevchenko
Quoted 4 lines · Hans de Goede

The Asus ME176C + TF103C both have a lid-switch (for a cover in the ME176C case), add a gpio-keys platform-device and platform-data describing the lid-switch on both.

USB ID change is not described here.

There is no USB-ID change, the

- .pdev_info = int3496_pdevs,
- .pdev_count = ARRAY_SIZE(int3496_pdevs),

members of struct x86_dev_info used to point to int3496_pdevs which is a generic pdev array with just the single:

/* Generic pdevs array and gpio-lookups for micro USB ID pin handling */

static const struct platform_device_info int3496_pdevs[] __initconst = {
        {
                /* For micro USB ID pin handling */
                .name = "intel-int3496",
                .id = PLATFORM_DEVID_NONE,
        },
};

entry in there.

Since adding lid_switch support involves adding a second pdev, the contents of the generic int3496_pdevs now gets duplicated into the new pdevs array which adds the lid gpio_keys pdev:

static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst = {
        {
                .name = "gpio-keys",
                .id = PLATFORM_DEVID_AUTO,
                .data = &asus_me176c_tf103c_lid_pdata,
                .size_data = sizeof(asus_me176c_tf103c_lid_pdata),
        },
        {
                /* For micro USB ID pin handling */
                .name = "intel-int3496",
                .id = PLATFORM_DEVID_NONE,
        },
};

So only the "gpio-keys" pdev is new, the other one just needs to be duplicated because pdev_info now points to the new asus_me176c_tf103c_pdevs array:

+ .pdev_info = asus_me176c_tf103c_pdevs,
+ .pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),

And without the duplication the dropping of the reference to the old array would cause the "intel-int3496" pdev to go away. So what looks like an extra change actually is there to avoid changing behavior.

Quoted 10 lines

...

+/* Asus ME176C and TF103C tablets shared data */

drivers/platform/x86/x86-android-tablets.c static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = { · line 239

Quoted 4 lines
drivers/platform/x86/x86-android-tablets.c +3 -0
+static struct gpio_keys_button asus_me176c_tf103c_lid = {
+       .code = SW_LID,
 
+       /* .gpio gets filled in by asus_me176c_tf103c_init() */

I'm wondering if we can switch gpio_keys*.c drivers to accept GPIO descriptor directly.

The current gpio_keys_platform_data struct which expects an old style gpio integer number is used in a ton of places:

drivers/platform/surface/surface3_button.c
drivers/platform/x86/meraki-mx100.c
drivers/platform/x86/barco-p50-gpio.c
drivers/platform/x86/pcengines-apuv2.c
drivers/platform/x86/x86-android-tablets.c
drivers/mfd/rohm-bd718x7.c
drivers/mfd/rohm-bd71828.c
drivers/mfd/ucb1x00-assabet.c
drivers/input/keyboard/gpio_keys_polled.c
drivers/input/keyboard/gpio_keys.c
drivers/input/misc/soc_button_array.c
arch/x86/platform/geode/net5501.c
arch/x86/platform/geode/alix.c
arch/x86/platform/geode/geos.c
arch/sh/boards/mach-x3proto/setup.c
arch/sh/boards/mach-rsk/devices-rsk7203.c
arch/arm/mach-sa1100/h3xxx.c
arch/arm/mach-sa1100/collie.c
arch/arm/mach-sa1100/assabet.c
arch/arm/mach-sa1100/simpad.c
arch/arm/mach-omap1/board-htcherald.c
arch/arm/mach-orion5x/ls_hgl-setup.c
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-orion5x/net2big-setup.c
arch/arm/mach-orion5x/ts409-setup.c
arch/arm/mach-orion5x/ts209-setup.c
arch/arm/mach-orion5x/mv2120-setup.c
arch/arm/mach-orion5x/wrt350n-v2-setup.c
arch/arm/mach-s3c/mach-h1940.c
arch/arm/mach-s3c/mach-rx1950.c
arch/arm/mach-s3c/mach-mini2440.c
arch/arm/mach-s3c/mach-gta02.c
arch/arm/mach-s3c/mach-n30.c
arch/arm/mach-s3c/mach-smartq7.c
arch/arm/mach-s3c/mach-smartq5.c
arch/arm/mach-s3c/mach-crag6410.c
arch/arm/mach-pxa/hx4700.c
arch/arm/mach-pxa/palmld.c
arch/arm/mach-pxa/tosa.c
arch/arm/mach-pxa/palmt5.c
arch/arm/mach-pxa/magician.c
arch/arm/mach-pxa/csb701.c
arch/arm/mach-pxa/vpac270.c
arch/arm/mach-pxa/z2.c
arch/arm/mach-pxa/palmtx.c
arch/arm/mach-pxa/palmte2.c
arch/arm/mach-pxa/corgi.c
arch/arm/mach-pxa/palmtc.c
arch/arm/mach-pxa/mioa701.c
arch/arm/mach-pxa/spitz.c
arch/arm/mach-pxa/ezx.c
arch/arm/mach-pxa/mainstone.c
arch/arm/mach-davinci/board-da850-evm.c
arch/mips/bcm47xx/buttons.c
arch/mips/alchemy/board-mtx1.c
arch/mips/alchemy/devboards/db1300.c

So changing this is going to be a lot of work, it certainly is out of scope for this patch-set.

Regards,

Hans

#6 lore raw

Re: [PATCH 4/6] platform/x86: x86-android-tablets: Add lid-switch gpio-keys pdev to Asus ME176C + TF103C

Quoted 2 lines · Hans de Goede
Quoted 1 line · Andy Shevchenko

On Sat, Feb 5, 2022 at 9:14 PM Hans de Goede <[email protected]> wrote:

...

Quoted 3 lines
Quoted 1 line

USB ID change is not described here.

There is no USB-ID change,

...

Quoted 3 lines

Since adding lid_switch support involves adding a second pdev, the contents of the generic int3496_pdevs now gets duplicated into the new pdevs array which adds the lid gpio_keys pdev:

I see now. Perhaps a comment about it in the commit message?

...

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

+ /* .gpio gets filled in by asus_me176c_tf103c_init() */

I'm wondering if we can switch gpio_keys*.c drivers to accept GPIO descriptor directly.

The current gpio_keys_platform_data struct which expects an old style gpio integer number is used in a ton of places:

Yes.

Quoted 1 line

So changing this is going to be a lot of work,

gpio_keys does already operate with descriptors inside. It would be easy to add a new member and extend a check, but...

Quoted 2 lines

it certainly is
out of scope for this patch-set.

...yes, it's not directly related to this series.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

Re: [PATCH 4/6] platform/x86: x86-android-tablets: Add lid-switch gpio-keys pdev to Asus ME176C + TF103C

Hi,

Quoted 10 lines · Andy Shevchenko
Quoted 2 lines · Hans de Goede
Quoted 1 line · Andy Shevchenko

On Sat, Feb 5, 2022 at 9:14 PM Hans de Goede <[email protected]> wrote:

...

Quoted 3 lines
Quoted 1 line

USB ID change is not described here.

There is no USB-ID change,

Quoted 7 lines

...

Quoted 3 lines

Since adding lid_switch support involves adding a second pdev, the contents of the generic int3496_pdevs now gets duplicated into the new pdevs array which adds the lid gpio_keys pdev:

I see now. Perhaps a comment about it in the commit message?

Ok, I've added a comment to the commit msg while merging this series into my review-hans branch.

Regards,

Hans

#8 lore raw

PATCH 5/6 platform/x86: x86-android-tablets: Add IRQ to Asus ME176C accelerometer info

In reply to Hans de Goede

Add the IRQ for the accelerometer to the Asus ME176C board info.

---
 drivers/platform/x86/x86-android-tablets.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/platform/x86/x86-android-tablets.c +6 -0
index 6174aad572bc..6d3a453d90eb 100644
@@ -361,6 +361,12 @@ static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst =
 			.swnode = &asus_me176c_accel_node,
 		},
 		.adapter_path = "\\_SB_.I2C5",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_APIC,
+			.index = 0x44,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
 	}, {
 		/* goodix touchscreen */
 		.board_info = {
Signature · 1 line
2.33.1
#9 lore raw

PATCH 6/6 platform/x86: x86-android-tablets: Add Nextbook Ares 8 data

In reply to Hans de Goede

The Nextbook Ares 8 is a x86 ACPI tablet which ships with Android x86 as factory OS. Its DSDT contains a bunch of I2C devices which are not actually there, causing various resource conflicts. Enumeration of these is skipped through the acpi_quirk_skip_i2c_client_enumeration().

Add support for manually instantiating the I2C devices which are actually present on this tablet by adding the necessary device info to the x86-android-tablets module.

---
 drivers/platform/x86/x86-android-tablets.c | 88 +++++++++++++++++++++-
 1 file changed, 87 insertions(+), 1 deletion(-)
drivers/platform/x86/x86-android-tablets.c +87 -1
index 6d3a453d90eb..838d667126e5 100644
@@ -669,6 +669,84 @@ static const struct x86_dev_info czc_p10t __initconst = {
 	.init = czc_p10t_init,
 };
 
+/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
+static const char * const nextbook_ares8_accel_mount_matrix[] = {
+	"0", "-1", "0",
+	"-1", "0", "0",
+	"0", "0", "1"
+};
+
+static const struct property_entry nextbook_ares8_accel_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", nextbook_ares8_accel_mount_matrix),
+	{ }
+};
+
+static const struct software_node nextbook_ares8_accel_node = {
+	.properties = nextbook_ares8_accel_props,
+};
+
+static const struct property_entry nextbook_ares8_touchscreen_props[] = {
+	PROPERTY_ENTRY_U32("touchscreen-size-x", 800),
+	PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
+	{ }
+};
+
+static const struct software_node nextbook_ares8_touchscreen_node = {
+	.properties = nextbook_ares8_touchscreen_props,
+};
+
+static const struct x86_i2c_client_info nextbook_ares8_i2c_clients[] __initconst = {
+	{
+		/* Freescale MMA8653FC accel */
+		.board_info = {
+			.type = "mma8653",
+			.addr = 0x1d,
+			.dev_name = "mma8653",
+			.swnode = &nextbook_ares8_accel_node,
+		},
+		.adapter_path = "\\_SB_.I2C3",
+	}, {
+		/* FT5416DQ9 touchscreen controller */
+		.board_info = {
+			.type = "edt-ft5x06",
+			.addr = 0x38,
+			.dev_name = "ft5416",
+			.swnode = &nextbook_ares8_touchscreen_node,
+		},
+		.adapter_path = "\\_SB_.I2C4",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FC:02",
+			.index = 3,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
+	},
+};
+
+static struct gpiod_lookup_table nextbook_ares8_int3496_gpios = {
+	.dev_id = "intel-int3496",
+	.table = {
+		GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("INT33FC:02", 18, "id", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table * const nextbook_ares8_gpios[] = {
+	&nextbook_ares8_int3496_gpios,
+	NULL
+};
+
+static const struct x86_dev_info nextbook_ares8_info __initconst = {
+	.i2c_client_info = nextbook_ares8_i2c_clients,
+	.i2c_client_count = ARRAY_SIZE(nextbook_ares8_i2c_clients),
+	.pdev_info = int3496_pdevs,
+	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.gpiod_lookup_tables = nextbook_ares8_gpios,
+	.invalid_aei_gpiochip = "INT33FC:02",
+};
+
 /*
  * Whitelabel (sold as various brands) TM800A550L tablets.
  * These tablet's DSDT contains a whole bunch of bogus ACPI I2C devices
@@ -830,7 +908,7 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 		.driver_data = (void *)&czc_p10t,
 	},
 	{
-		/* A variant of CZC P10T */
+		/* CZC P10T variant */
 		.ident = "ViewSonic ViewPad 10",
 		.matches = {
 			DMI_MATCH(DMI_SYS_VENDOR, "ViewSonic"),
@@ -838,6 +916,14 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 		},
 		.driver_data = (void *)&czc_p10t,
 	},
+	{
+		/* Nextbook Ares 8 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "M890BAP"),
+		},
+		.driver_data = (void *)&nextbook_ares8_info,
+	},
 	{
 		/* Whitelabel (sold as various brands) TM800A550L */
 		.matches = {
Signature · 1 line
2.33.1
Reviewed-by on v1 1/6
#10 lore raw
In reply to Hans de Goede
Quoted 7 lines · Hans de Goede

power_supply_get_battery_info() which is used by charger and fuel-gauge drivers on x86-android-tablets, expects the battery properties to be described in a stand-alone battery fwnode which is then referenced from both the charger and fuel-gauge device's fwnodes.

Add support for registering + unregistering a swnode for this.

All non-commented looks good to me,

Quoted 51 lines
---
 drivers/platform/x86/x86-android-tablets.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/platform/x86/x86-android-tablets.c +11 -1
index 3120acf9837c..80d113c41623 100644
@@ -146,6 +146,7 @@ struct x86_serdev_info {
 struct x86_dev_info {
        char *invalid_aei_gpiochip;
        const char * const *modules;
+       const struct software_node *bat_swnode;
        struct gpiod_lookup_table * const *gpiod_lookup_tables;
        const struct x86_i2c_client_info *i2c_client_info;
        const struct platform_device_info *pdev_info;
@@ -727,6 +728,7 @@ static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
 static struct gpiod_lookup_table * const *gpiod_lookup_tables;
+static const struct software_node *bat_swnode;
 static void (*exit_handler)(void);
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
@@ -850,6 +852,8 @@ static void x86_android_tablet_cleanup(void)
 
        for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
                gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
+
+       software_node_unregister(bat_swnode);
 }
 
 static __init int x86_android_tablet_init(void)
@@ -886,6 +890,13 @@ static __init int x86_android_tablet_init(void)
        for (i = 0; dev_info->modules && dev_info->modules[i]; i++)
                request_module(dev_info->modules[i]);
 
+       bat_swnode = dev_info->bat_swnode;
+       if (bat_swnode) {
+               ret = software_node_register(bat_swnode);
+               if (ret)
+                       return ret;
+       }
+
        gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
        for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
                gpiod_add_lookup_table(gpiod_lookup_tables[i]);
--

2.33.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Hi,

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Hans de Goede

power_supply_get_battery_info() which is used by charger and fuel-gauge drivers on x86-android-tablets, expects the battery properties to be described in a stand-alone battery fwnode which is then referenced from both the charger and fuel-gauge device's fwnodes.

Add support for registering + unregistering a swnode for this.

All non-commented looks good to me,

Just to be clear, you mean that I may add your Reviewed-by tag to all patches in this series to which you did not comment, correct ?

Regards,

Hans

Quoted 54 lines
Quoted 52 lines
---
 drivers/platform/x86/x86-android-tablets.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/platform/x86/x86-android-tablets.c +11 -1
index 3120acf9837c..80d113c41623 100644
@@ -146,6 +146,7 @@ struct x86_serdev_info {
 struct x86_dev_info {
        char *invalid_aei_gpiochip;
        const char * const *modules;
+       const struct software_node *bat_swnode;
        struct gpiod_lookup_table * const *gpiod_lookup_tables;
        const struct x86_i2c_client_info *i2c_client_info;
        const struct platform_device_info *pdev_info;
@@ -727,6 +728,7 @@ static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
 static struct gpiod_lookup_table * const *gpiod_lookup_tables;
+static const struct software_node *bat_swnode;
 static void (*exit_handler)(void);
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
@@ -850,6 +852,8 @@ static void x86_android_tablet_cleanup(void)
 
        for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
                gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
+
+       software_node_unregister(bat_swnode);
 }
 
 static __init int x86_android_tablet_init(void)
@@ -886,6 +890,13 @@ static __init int x86_android_tablet_init(void)
        for (i = 0; dev_info->modules && dev_info->modules[i]; i++)
                request_module(dev_info->modules[i]);
 
+       bat_swnode = dev_info->bat_swnode;
+       if (bat_swnode) {
+               ret = software_node_register(bat_swnode);
+               if (ret)
+                       return ret;
+       }
+
        gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
        for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
                gpiod_add_lookup_table(gpiod_lookup_tables[i]);
--

2.33.1

#12 lore raw
Quoted 2 lines · Hans de Goede
Quoted 1 line · Andy Shevchenko

On Sat, Feb 5, 2022 at 9:14 PM Hans de Goede <[email protected]> wrote:

...

Quoted 6 lines
Quoted 2 lines

All non-commented looks good to me,

Just to be clear, you mean that I may add your Reviewed-by tag to all patches in this series to which you did not comment, correct ?

Yep!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#13 lore raw
In reply to Hans de Goede

Hi,

Quoted 8 lines · Hans de Goede

power_supply_get_battery_info() which is used by charger and fuel-gauge drivers on x86-android-tablets, expects the battery properties to be described in a stand-alone battery fwnode which is then referenced from both the charger and fuel-gauge device's fwnodes.

Add support for registering + unregistering a swnode for this.

I've added this series to my review-hans (soon to be for-next) branch now.

Regards,

Hans

Quoted 48 lines
---
 drivers/platform/x86/x86-android-tablets.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/platform/x86/x86-android-tablets.c +11 -0
index 3120acf9837c..80d113c41623 100644
@@ -146,6 +146,7 @@ struct x86_serdev_info {
 struct x86_dev_info {
 	char *invalid_aei_gpiochip;
 	const char * const *modules;
+	const struct software_node *bat_swnode;
 	struct gpiod_lookup_table * const *gpiod_lookup_tables;
 	const struct x86_i2c_client_info *i2c_client_info;
 	const struct platform_device_info *pdev_info;
@@ -727,6 +728,7 @@ static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
 static struct gpiod_lookup_table * const *gpiod_lookup_tables;
+static const struct software_node *bat_swnode;
 static void (*exit_handler)(void);
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
@@ -850,6 +852,8 @@ static void x86_android_tablet_cleanup(void)
 
 	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
 		gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
+
+	software_node_unregister(bat_swnode);
 }
 
 static __init int x86_android_tablet_init(void)
@@ -886,6 +890,13 @@ static __init int x86_android_tablet_init(void)
 	for (i = 0; dev_info->modules && dev_info->modules[i]; i++)
 		request_module(dev_info->modules[i]);
 
+	bat_swnode = dev_info->bat_swnode;
+	if (bat_swnode) {
+		ret = software_node_register(bat_swnode);
+		if (ret)
+			return ret;
+	}
+
 	gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
 	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
 		gpiod_add_lookup_table(gpiod_lookup_tables[i]);