[PATCH v2 1/2] platform: x86-android-tablets: lenovo: Add Yoga Book haptics entries

Yauhen Kharuzhy posted 2 patches 1 month ago
[PATCH v2 1/2] platform: x86-android-tablets: lenovo: Add Yoga Book haptics entries
Posted by Yauhen Kharuzhy 1 month ago
Add drv2604l i2c_board_info for drv2604l haptics drivers present in
Lenovo Yoga Book YB1-X90 and YB1-X91. Set properties required for device
initialization and self-calibration.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
---
 drivers/platform/x86/x86-android-tablets/lenovo.c | 92 +++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c
index 8d825e0b4661..bc10f00da8c6 100644
--- a/drivers/platform/x86/x86-android-tablets/lenovo.c
+++ b/drivers/platform/x86/x86-android-tablets/lenovo.c
@@ -10,6 +10,8 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <linux/cleanup.h>
+#include <linux/device.h>
 #include <linux/efi.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio/property.h>
@@ -114,6 +116,32 @@ static const struct software_node lenovo_yb1_x90_hideep_ts_node = {
 	.properties = lenovo_yb1_x90_hideep_ts_props,
 };
 
+static const struct property_entry lenovo_yb1_x9x_drv2604l_0_props[] = {
+	PROPERTY_ENTRY_U32("vib-rated-mv", 1500),
+	PROPERTY_ENTRY_U32("vib-overdrive-mv", 2100),
+	PROPERTY_ENTRY_U32("mode", 0), /* LRA */
+	PROPERTY_ENTRY_U32("library-sel", 0), /* DRV260X_LIB_EMPTY */
+	PROPERTY_ENTRY_GPIO("enable-gpios", &cherryview_gpiochip_nodes[0], 79, GPIO_ACTIVE_HIGH),
+	{}
+};
+
+static const struct software_node lenovo_yb1_x9x_drv2604l_0_node = {
+	.properties = lenovo_yb1_x9x_drv2604l_0_props,
+};
+
+static const struct property_entry lenovo_yb1_x9x_drv2604l_1_props[] = {
+	PROPERTY_ENTRY_U32("vib-rated-mv", 1500),
+	PROPERTY_ENTRY_U32("vib-overdrive-mv", 2100),
+	PROPERTY_ENTRY_U32("mode", 0), /* LRA */
+	PROPERTY_ENTRY_U32("library-sel", 0), /* DRV260X_LIB_EMPTY */
+	PROPERTY_ENTRY_GPIO("enable-gpios", &cherryview_gpiochip_nodes[1], 47, GPIO_ACTIVE_HIGH),
+	{}
+};
+
+static const struct software_node lenovo_yb1_x9x_drv2604l_1_node = {
+	.properties = lenovo_yb1_x9x_drv2604l_1_props,
+};
+
 static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst = {
 	{
 		/* BQ27542 fuel-gauge */
@@ -159,6 +187,24 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
 			.polarity = ACPI_ACTIVE_LOW,
 			.con_id = "wacom_irq",
 		},
+	}, {
+		/* Keyboard haptics driver */
+		.board_info = {
+			.type = "drv2604l",
+			.addr = 0x5a,
+			.dev_name = "drv2604l.0",
+			.swnode = &lenovo_yb1_x9x_drv2604l_0_node,
+		},
+		.adapter_path = "\\_SB_.PCI0.I2C1",
+	}, {
+		/* Keyboard haptics driver */
+		.board_info = {
+			.type = "drv2604l",
+			.addr = 0x5a,
+			.dev_name = "drv2604l.1",
+			.swnode = &lenovo_yb1_x9x_drv2604l_1_node,
+		},
+		.adapter_path = "\\_SB_.PCI0.I2C4",
 	}, {
 		/* LP8557 Backlight controller */
 		.board_info = {
@@ -283,9 +329,55 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init
 	},
 };
 
+#define YB1_X91_DRV2604L_0_DEVICE "i2c-DRV2604:00"
+#define YB1_X91_DRV2604L_1_DEVICE "i2c-DRV2604:01"
+
+static int __init lenovo_yb1_x91_init(struct device *dev)
+{
+	struct device *drv2604l_0_dev __free(put_device) = NULL;
+	struct device *drv2604l_1_dev __free(put_device) = NULL;
+	int ret = 0;
+
+	drv2604l_0_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
+						 YB1_X91_DRV2604L_0_DEVICE);
+	if (!drv2604l_0_dev) {
+		pr_err("error: cannot find %s device\n",
+		       YB1_X91_DRV2604L_0_DEVICE);
+		return -ENODEV;
+	}
+
+	ret = device_create_managed_software_node(drv2604l_0_dev,
+					lenovo_yb1_x9x_drv2604l_0_props, NULL);
+	if (ret) {
+		pr_err("error: cannot create software node for %s: %d\n",
+		       YB1_X91_DRV2604L_0_DEVICE, ret);
+		return ret;
+	}
+
+	drv2604l_1_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
+						 YB1_X91_DRV2604L_1_DEVICE);
+	if (!drv2604l_1_dev) {
+		pr_err("error: cannot find %s device\n",
+		       YB1_X91_DRV2604L_1_DEVICE);
+		return -ENODEV;
+	}
+
+	ret = device_create_managed_software_node(drv2604l_1_dev,
+					lenovo_yb1_x9x_drv2604l_1_props, NULL);
+	if (ret) {
+		pr_err("error: cannot create software node for %s\n",
+		       YB1_X91_DRV2604L_1_DEVICE);
+		return ret;
+	}
+
+	return 0;
+}
+
 const struct x86_dev_info lenovo_yogabook_x91_info __initconst = {
 	.i2c_client_info = lenovo_yogabook_x91_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x91_i2c_clients),
+	.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
+	.init = lenovo_yb1_x91_init,
 };
 
 /* Lenovo Yoga Tablet 2 1050F/L's Android factory image has everything hardcoded */

-- 
2.51.0
Re: [PATCH v2 1/2] platform: x86-android-tablets: lenovo: Add Yoga Book haptics entries
Posted by Ilpo Järvinen 1 month ago
On Mon, 2 Mar 2026, Yauhen Kharuzhy wrote:

> Add drv2604l i2c_board_info for drv2604l haptics drivers present in
> Lenovo Yoga Book YB1-X90 and YB1-X91. Set properties required for device
> initialization and self-calibration.
> 
> Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
> ---
>  drivers/platform/x86/x86-android-tablets/lenovo.c | 92 +++++++++++++++++++++++
>  1 file changed, 92 insertions(+)
> 
> diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c
> index 8d825e0b4661..bc10f00da8c6 100644
> --- a/drivers/platform/x86/x86-android-tablets/lenovo.c
> +++ b/drivers/platform/x86/x86-android-tablets/lenovo.c
> @@ -10,6 +10,8 @@
>  
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
> +#include <linux/cleanup.h>
> +#include <linux/device.h>
>  #include <linux/efi.h>
>  #include <linux/gpio/machine.h>
>  #include <linux/gpio/property.h>
> @@ -114,6 +116,32 @@ static const struct software_node lenovo_yb1_x90_hideep_ts_node = {
>  	.properties = lenovo_yb1_x90_hideep_ts_props,
>  };
>  
> +static const struct property_entry lenovo_yb1_x9x_drv2604l_0_props[] = {
> +	PROPERTY_ENTRY_U32("vib-rated-mv", 1500),
> +	PROPERTY_ENTRY_U32("vib-overdrive-mv", 2100),
> +	PROPERTY_ENTRY_U32("mode", 0), /* LRA */
> +	PROPERTY_ENTRY_U32("library-sel", 0), /* DRV260X_LIB_EMPTY */
> +	PROPERTY_ENTRY_GPIO("enable-gpios", &cherryview_gpiochip_nodes[0], 79, GPIO_ACTIVE_HIGH),
> +	{}
> +};
> +
> +static const struct software_node lenovo_yb1_x9x_drv2604l_0_node = {
> +	.properties = lenovo_yb1_x9x_drv2604l_0_props,
> +};
> +
> +static const struct property_entry lenovo_yb1_x9x_drv2604l_1_props[] = {
> +	PROPERTY_ENTRY_U32("vib-rated-mv", 1500),
> +	PROPERTY_ENTRY_U32("vib-overdrive-mv", 2100),
> +	PROPERTY_ENTRY_U32("mode", 0), /* LRA */
> +	PROPERTY_ENTRY_U32("library-sel", 0), /* DRV260X_LIB_EMPTY */
> +	PROPERTY_ENTRY_GPIO("enable-gpios", &cherryview_gpiochip_nodes[1], 47, GPIO_ACTIVE_HIGH),
> +	{}
> +};
> +
> +static const struct software_node lenovo_yb1_x9x_drv2604l_1_node = {
> +	.properties = lenovo_yb1_x9x_drv2604l_1_props,
> +};
> +
>  static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst = {
>  	{
>  		/* BQ27542 fuel-gauge */
> @@ -159,6 +187,24 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
>  			.polarity = ACPI_ACTIVE_LOW,
>  			.con_id = "wacom_irq",
>  		},
> +	}, {
> +		/* Keyboard haptics driver */
> +		.board_info = {
> +			.type = "drv2604l",
> +			.addr = 0x5a,
> +			.dev_name = "drv2604l.0",
> +			.swnode = &lenovo_yb1_x9x_drv2604l_0_node,
> +		},
> +		.adapter_path = "\\_SB_.PCI0.I2C1",
> +	}, {
> +		/* Keyboard haptics driver */
> +		.board_info = {
> +			.type = "drv2604l",
> +			.addr = 0x5a,
> +			.dev_name = "drv2604l.1",
> +			.swnode = &lenovo_yb1_x9x_drv2604l_1_node,
> +		},
> +		.adapter_path = "\\_SB_.PCI0.I2C4",
>  	}, {
>  		/* LP8557 Backlight controller */
>  		.board_info = {
> @@ -283,9 +329,55 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init
>  	},
>  };
>  
> +#define YB1_X91_DRV2604L_0_DEVICE "i2c-DRV2604:00"
> +#define YB1_X91_DRV2604L_1_DEVICE "i2c-DRV2604:01"
> +
> +static int __init lenovo_yb1_x91_init(struct device *dev)
> +{
> +	struct device *drv2604l_0_dev __free(put_device) = NULL;
> +	struct device *drv2604l_1_dev __free(put_device) = NULL;
> +	int ret = 0;
> +
> +	drv2604l_0_dev = bus_find_device_by_name(&i2c_bus_type, NULL,

Hi,

Please read the long comment at the beginning of include/linux/cleanup.h
(in particular the part where it talks about those varname = NULL 
constructs).

While the ordering is not a problem here as is, we don't want to use 
patterns that are dangerous in other situations.

-- 
 i.

> +						 YB1_X91_DRV2604L_0_DEVICE);
> +	if (!drv2604l_0_dev) {
> +		pr_err("error: cannot find %s device\n",
> +		       YB1_X91_DRV2604L_0_DEVICE);
> +		return -ENODEV;
> +	}
> +
> +	ret = device_create_managed_software_node(drv2604l_0_dev,
> +					lenovo_yb1_x9x_drv2604l_0_props, NULL);
> +	if (ret) {
> +		pr_err("error: cannot create software node for %s: %d\n",
> +		       YB1_X91_DRV2604L_0_DEVICE, ret);
> +		return ret;
> +	}
> +
> +	drv2604l_1_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
> +						 YB1_X91_DRV2604L_1_DEVICE);
> +	if (!drv2604l_1_dev) {
> +		pr_err("error: cannot find %s device\n",
> +		       YB1_X91_DRV2604L_1_DEVICE);
> +		return -ENODEV;
> +	}
> +
> +	ret = device_create_managed_software_node(drv2604l_1_dev,
> +					lenovo_yb1_x9x_drv2604l_1_props, NULL);
> +	if (ret) {
> +		pr_err("error: cannot create software node for %s\n",
> +		       YB1_X91_DRV2604L_1_DEVICE);
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  const struct x86_dev_info lenovo_yogabook_x91_info __initconst = {
>  	.i2c_client_info = lenovo_yogabook_x91_i2c_clients,
>  	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x91_i2c_clients),
> +	.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
> +	.init = lenovo_yb1_x91_init,
>  };
>  
>  /* Lenovo Yoga Tablet 2 1050F/L's Android factory image has everything hardcoded */
> 
>
Re: [PATCH v2 1/2] platform: x86-android-tablets: lenovo: Add Yoga Book haptics entries
Posted by Yauhen Kharuzhy 1 month ago
On Mon, Mar 02, 2026 at 01:52:38PM +0200, Ilpo Järvinen wrote:
> On Mon, 2 Mar 2026, Yauhen Kharuzhy wrote:
> 
> > Add drv2604l i2c_board_info for drv2604l haptics drivers present in
> > Lenovo Yoga Book YB1-X90 and YB1-X91. Set properties required for device
> > initialization and self-calibration.
> > 
> > Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
> > ---
> >  drivers/platform/x86/x86-android-tablets/lenovo.c | 92 +++++++++++++++++++++++
> >  1 file changed, 92 insertions(+)
> > 
> > diff --git a/drivers/platform/x86/x86-android-tablets/lenovo.c b/drivers/platform/x86/x86-android-tablets/lenovo.c
> > index 8d825e0b4661..bc10f00da8c6 100644
> > --- a/drivers/platform/x86/x86-android-tablets/lenovo.c
> > +++ b/drivers/platform/x86/x86-android-tablets/lenovo.c
> > @@ -10,6 +10,8 @@
> >  
> >  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> >  
> > +#include <linux/cleanup.h>
> > +#include <linux/device.h>
> >  #include <linux/efi.h>
> >  #include <linux/gpio/machine.h>
> >  #include <linux/gpio/property.h>
> > @@ -114,6 +116,32 @@ static const struct software_node lenovo_yb1_x90_hideep_ts_node = {
> >  	.properties = lenovo_yb1_x90_hideep_ts_props,
> >  };
> >  
> > +static const struct property_entry lenovo_yb1_x9x_drv2604l_0_props[] = {
> > +	PROPERTY_ENTRY_U32("vib-rated-mv", 1500),
> > +	PROPERTY_ENTRY_U32("vib-overdrive-mv", 2100),
> > +	PROPERTY_ENTRY_U32("mode", 0), /* LRA */
> > +	PROPERTY_ENTRY_U32("library-sel", 0), /* DRV260X_LIB_EMPTY */
> > +	PROPERTY_ENTRY_GPIO("enable-gpios", &cherryview_gpiochip_nodes[0], 79, GPIO_ACTIVE_HIGH),
> > +	{}
> > +};
> > +
> > +static const struct software_node lenovo_yb1_x9x_drv2604l_0_node = {
> > +	.properties = lenovo_yb1_x9x_drv2604l_0_props,
> > +};
> > +
> > +static const struct property_entry lenovo_yb1_x9x_drv2604l_1_props[] = {
> > +	PROPERTY_ENTRY_U32("vib-rated-mv", 1500),
> > +	PROPERTY_ENTRY_U32("vib-overdrive-mv", 2100),
> > +	PROPERTY_ENTRY_U32("mode", 0), /* LRA */
> > +	PROPERTY_ENTRY_U32("library-sel", 0), /* DRV260X_LIB_EMPTY */
> > +	PROPERTY_ENTRY_GPIO("enable-gpios", &cherryview_gpiochip_nodes[1], 47, GPIO_ACTIVE_HIGH),
> > +	{}
> > +};
> > +
> > +static const struct software_node lenovo_yb1_x9x_drv2604l_1_node = {
> > +	.properties = lenovo_yb1_x9x_drv2604l_1_props,
> > +};
> > +
> >  static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst = {
> >  	{
> >  		/* BQ27542 fuel-gauge */
> > @@ -159,6 +187,24 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
> >  			.polarity = ACPI_ACTIVE_LOW,
> >  			.con_id = "wacom_irq",
> >  		},
> > +	}, {
> > +		/* Keyboard haptics driver */
> > +		.board_info = {
> > +			.type = "drv2604l",
> > +			.addr = 0x5a,
> > +			.dev_name = "drv2604l.0",
> > +			.swnode = &lenovo_yb1_x9x_drv2604l_0_node,
> > +		},
> > +		.adapter_path = "\\_SB_.PCI0.I2C1",
> > +	}, {
> > +		/* Keyboard haptics driver */
> > +		.board_info = {
> > +			.type = "drv2604l",
> > +			.addr = 0x5a,
> > +			.dev_name = "drv2604l.1",
> > +			.swnode = &lenovo_yb1_x9x_drv2604l_1_node,
> > +		},
> > +		.adapter_path = "\\_SB_.PCI0.I2C4",
> >  	}, {
> >  		/* LP8557 Backlight controller */
> >  		.board_info = {
> > @@ -283,9 +329,55 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init
> >  	},
> >  };
> >  
> > +#define YB1_X91_DRV2604L_0_DEVICE "i2c-DRV2604:00"
> > +#define YB1_X91_DRV2604L_1_DEVICE "i2c-DRV2604:01"
> > +
> > +static int __init lenovo_yb1_x91_init(struct device *dev)
> > +{
> > +	struct device *drv2604l_0_dev __free(put_device) = NULL;
> > +	struct device *drv2604l_1_dev __free(put_device) = NULL;
> > +	int ret = 0;
> > +
> > +	drv2604l_0_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
> 
> Hi,
> 
> Please read the long comment at the beginning of include/linux/cleanup.h
> (in particular the part where it talks about those varname = NULL 
> constructs).
> 
> While the ordering is not a problem here as is, we don't want to use 
> patterns that are dangerous in other situations.

Got it, thanks for pointing that out, I missed that nuance when I was reading
the comment. I will move declaration from function start to real assignments.

> 
> -- 
>  i.
> 
> > +						 YB1_X91_DRV2604L_0_DEVICE);
> > +	if (!drv2604l_0_dev) {
> > +		pr_err("error: cannot find %s device\n",
> > +		       YB1_X91_DRV2604L_0_DEVICE);
> > +		return -ENODEV;
> > +	}
> > +
> > +	ret = device_create_managed_software_node(drv2604l_0_dev,
> > +					lenovo_yb1_x9x_drv2604l_0_props, NULL);
> > +	if (ret) {
> > +		pr_err("error: cannot create software node for %s: %d\n",
> > +		       YB1_X91_DRV2604L_0_DEVICE, ret);
> > +		return ret;
> > +	}
> > +
> > +	drv2604l_1_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
> > +						 YB1_X91_DRV2604L_1_DEVICE);
> > +	if (!drv2604l_1_dev) {
> > +		pr_err("error: cannot find %s device\n",
> > +		       YB1_X91_DRV2604L_1_DEVICE);
> > +		return -ENODEV;
> > +	}
> > +
> > +	ret = device_create_managed_software_node(drv2604l_1_dev,
> > +					lenovo_yb1_x9x_drv2604l_1_props, NULL);
> > +	if (ret) {
> > +		pr_err("error: cannot create software node for %s\n",
> > +		       YB1_X91_DRV2604L_1_DEVICE);
> > +		return ret;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  const struct x86_dev_info lenovo_yogabook_x91_info __initconst = {
> >  	.i2c_client_info = lenovo_yogabook_x91_i2c_clients,
> >  	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x91_i2c_clients),
> > +	.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
> > +	.init = lenovo_yb1_x91_init,
> >  };
> >  
> >  /* Lenovo Yoga Tablet 2 1050F/L's Android factory image has everything hardcoded */
> > 
> > 
> 

-- 
Yauhen Kharuzhy