Skip to contentSkip to conversation

platform/x86: x86-android-tablets: Update Yoga Book HiDeep touchscreen comment

PATCH In review Hans de Goede 1 participant 5 messages Apr 16, 2023 – Apr 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/4 platform/x86: x86-android-tablets: Update Yoga Book HiDeep touchscreen comment

After recent i2c-hid-of changes, the i2c-hid-of driver could be used for the Yoga Book HiDeep touchscreen comment instead of the native hideep driver. Update the comment to reflect this.

---
 drivers/platform/x86/x86-android-tablets/lenovo.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/platform/x86/x86-android-tablets/lenovo.c +7 -4
index a571dcd11544..b5dd74bf9e8c 100644
@@ -41,10 +41,13 @@ static struct lp855x_platform_data lenovo_lp8557_pdata = {
 /* Lenovo Yoga Book X90F / X90L's Android factory img has everything hardcoded */
 
 /*
- * The HiDeep IST940E touchscreen comes up in HID mode and could alternatively
- * be used in I2C-HID mode (I2C-HID descriptor reg 0x0020) if i2c-hid-of.c is
- * modified to use generic (non-OF) device-properties and thought to deal with
- * the reset GPIO. "hideep,force-native-protocol" resets it to native mode.
+ * The HiDeep IST940E touchscreen comes up in I2C-HID mode. The native protocol
+ * reports ABS_MT_PRESSURE and ABS_MT_TOUCH_MAJOR which are not reported in HID
+ * mode, so using native mode is preferred.
+ * It could alternatively be used in HID mode by changing the properties to:
+ *	PROPERTY_ENTRY_U32("hid-descr-addr", 0x0020),
+ *	PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 120),
+ * and changing board_info.type to "hid-over-i2c".
  */
 static const struct property_entry lenovo_yb1_x90_hideep_ts_props[] = {
 	PROPERTY_ENTRY_U32("touchscreen-size-x", 1200),
Signature · 1 line
2.39.2
#1 lore raw

PATCH 2/4 platform/x86: x86-android-tablets: Add Wacom digitizer info for Lenovo Yoga Book

The Lenovo Yoga Book has a wacom digitizer in its keyboard half, add the necessary info to instantiate an i2c_client for the digitizer.

---
 .../platform/x86/x86-android-tablets/lenovo.c | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +35 -0
index b5dd74bf9e8c..438de8b92dc6 100644
@@ -40,6 +40,16 @@ static struct lp855x_platform_data lenovo_lp8557_pdata = {
 
 /* Lenovo Yoga Book X90F / X90L's Android factory img has everything hardcoded */
 
+static const struct property_entry lenovo_yb1_x90_wacom_props[] = {
+	PROPERTY_ENTRY_U32("hid-descr-addr", 0x0001),
+	PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 150),
+	{ }
+};
+
+static const struct software_node lenovo_yb1_x90_wacom_node = {
+	.properties = lenovo_yb1_x90_wacom_props,
+};
+
 /*
  * The HiDeep IST940E touchscreen comes up in I2C-HID mode. The native protocol
  * reports ABS_MT_PRESSURE and ABS_MT_TOUCH_MAJOR which are not reported in HID
@@ -86,6 +96,22 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
 			.trigger = ACPI_EDGE_SENSITIVE,
 			.polarity = ACPI_ACTIVE_LOW,
 		},
+	}, {
+		/* Wacom Digitizer in keyboard half */
+		.board_info = {
+			.type = "hid-over-i2c",
+			.addr = 0x09,
+			.dev_name = "wacom",
+			.swnode = &lenovo_yb1_x90_wacom_node,
+		},
+		.adapter_path = "\\_SB_.PCI0.I2C4",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FF:01",
+			.index = 49,
+			.trigger = ACPI_LEVEL_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
 	}, {
 		/* LP8557 Backlight controller */
 		.board_info = {
@@ -131,9 +157,18 @@ static struct gpiod_lookup_table lenovo_yb1_x90_hideep_gpios = {
 	},
 };
 
+static struct gpiod_lookup_table lenovo_yb1_x90_wacom_gpios = {
+	.dev_id = "i2c-wacom",
+	.table = {
+		GPIO_LOOKUP("INT33FF:00", 82, "reset", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
 static struct gpiod_lookup_table * const lenovo_yb1_x90_gpios[] = {
 	&lenovo_yb1_x90_hideep_gpios,
 	&lenovo_yb1_x90_goodix_gpios,
+	&lenovo_yb1_x90_wacom_gpios,
 	NULL
 };
 
Signature · 1 line
2.39.2
#2 lore raw

PATCH 3/4 platform/x86: x86-android-tablets: Add "yogabook-touch-kbd-digitizer-switch" pdev for Lenovo Yoga Book

In reply to Hans de Goede

Add a "yogabook-touch-kbd-digitizer-switch" platform-device, for the lenovo-yogabook driver to bind to, to the x86_dev_info for the Lenovo Yoga Book 1 Android models (yb1-x90f/l).

---
 drivers/platform/x86/x86-android-tablets/lenovo.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +9 -0
index 438de8b92dc6..cf1629970f98 100644
@@ -140,6 +140,13 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
 	},
 };
 
+static const struct platform_device_info lenovo_yb1_x90_pdevs[] __initconst = {
+	{
+		.name = "yogabook-touch-kbd-digitizer-switch",
+		.id = PLATFORM_DEVID_NONE,
+	},
+};
+
 static struct gpiod_lookup_table lenovo_yb1_x90_goodix_gpios = {
 	.dev_id = "i2c-goodix_ts",
 	.table = {
@@ -194,6 +201,8 @@ static int __init lenovo_yb1_x90_init(void)
 const struct x86_dev_info lenovo_yogabook_x90_info __initconst = {
 	.i2c_client_info = lenovo_yb1_x90_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(lenovo_yb1_x90_i2c_clients),
+	.pdev_info = lenovo_yb1_x90_pdevs,
+	.pdev_count = ARRAY_SIZE(lenovo_yb1_x90_pdevs),
 	.gpiod_lookup_tables = lenovo_yb1_x90_gpios,
 	.init = lenovo_yb1_x90_init,
 };
Signature · 1 line
2.39.2
#3 lore raw

PATCH 4/4 platform/x86: x86-android-tablets: Add accelerometer support for Yoga Tablet 2 1050/830 series

In reply to Hans de Goede

The Yoga Tablet 2 1050/830 series have a LSM303DA accelerometer + magnetometer (IMU), add this to the list of i2c_clients to instantiate on these models.

---
 .../platform/x86/x86-android-tablets/lenovo.c | 32 ++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)
drivers/platform/x86/x86-android-tablets/lenovo.c +31 -1
index cf1629970f98..65cfccaa2894 100644
@@ -255,8 +255,19 @@ static struct x86_gpio_button lenovo_yoga_tab2_830_1050_lid = {
 /* This gets filled by lenovo_yoga_tab2_830_1050_init() */
 static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
 
-static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initconst = {
+static struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initdata = {
 	{
+		/*
+		 * This must be the first entry because lenovo_yoga_tab2_830_1050_init()
+		 * may update its swnode. LSM303DA accelerometer + magnetometer.
+		 */
+		.board_info = {
+			.type = "lsm303d",
+			.addr = 0x1d,
+			.dev_name = "lsm303d",
+		},
+		.adapter_path = "\\_SB_.I2C5",
+	}, {
 		/* bq24292i battery charger */
 		.board_info = {
 			.type = "bq24190",
@@ -357,7 +368,24 @@ const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = {
  * The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same
  * mainboard, but the 830 uses a portrait LCD panel with a landscape touchscreen,
  * requiring the touchscreen driver to adjust the touch-coords to match the LCD.
+ * And requiring the accelerometer to have a mount-matrix set to correct for
+ * the 90° rotation of the LCD vs the frame.
  */
+static const char * const lenovo_yoga_tab2_830_lms303d_mount_matrix[] = {
+	"0", "1", "0",
+	"-1", "0", "0",
+	"0", "0", "1"
+};
+
+static const struct property_entry lenovo_yoga_tab2_830_lms303d_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", lenovo_yoga_tab2_830_lms303d_mount_matrix),
+	{ }
+};
+
+static const struct software_node lenovo_yoga_tab2_830_lms303d_node = {
+	.properties = lenovo_yoga_tab2_830_lms303d_props,
+};
+
 static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
 {
 	struct gpio_desc *gpiod;
@@ -375,6 +403,8 @@ static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
 		pr_info("detected Lenovo Yoga Tablet 2 830F/L\n");
 		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.swap_axes = true;
 		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.flip_y = true;
+		lenovo_yoga_tab2_830_1050_i2c_clients[0].board_info.swnode =
+			&lenovo_yoga_tab2_830_lms303d_node;
 	}
 
 	return 0;
Signature · 1 line
2.39.2
#4 lore raw
In reply to Hans de Goede

Hi,

Quoted 5 lines · Hans de Goede

After recent i2c-hid-of changes, the i2c-hid-of driver could be used for the Yoga Book HiDeep touchscreen comment instead of the native hideep driver. Update the comment to reflect this.

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

Regards,

Hans

Quoted 26 lines
---
 drivers/platform/x86/x86-android-tablets/lenovo.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/platform/x86/x86-android-tablets/lenovo.c +7 -4
index a571dcd11544..b5dd74bf9e8c 100644
@@ -41,10 +41,13 @@ static struct lp855x_platform_data lenovo_lp8557_pdata = {
 /* Lenovo Yoga Book X90F / X90L's Android factory img has everything hardcoded */
 
 /*
- * The HiDeep IST940E touchscreen comes up in HID mode and could alternatively
- * be used in I2C-HID mode (I2C-HID descriptor reg 0x0020) if i2c-hid-of.c is
- * modified to use generic (non-OF) device-properties and thought to deal with
- * the reset GPIO. "hideep,force-native-protocol" resets it to native mode.
+ * The HiDeep IST940E touchscreen comes up in I2C-HID mode. The native protocol
+ * reports ABS_MT_PRESSURE and ABS_MT_TOUCH_MAJOR which are not reported in HID
+ * mode, so using native mode is preferred.
+ * It could alternatively be used in HID mode by changing the properties to:
+ *	PROPERTY_ENTRY_U32("hid-descr-addr", 0x0020),
+ *	PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 120),
+ * and changing board_info.type to "hid-over-i2c".
  */
 static const struct property_entry lenovo_yb1_x90_hideep_ts_props[] = {
 	PROPERTY_ENTRY_U32("touchscreen-size-x", 1200),