platform/x86: Describe Yoga Book haptics and audio resources
v2 cover platform/x86: Describe Yoga Book haptics and audio resources
The Lenovo Yoga Book YB1-X91F/L firmware omits software properties for its two DRV2604 haptic controllers and does not instantiate or map all resources used by the RT5677 audio design.
Attach board software nodes describing the DRV2604 mode, waveform library and enable GPIOs, instantiate the TS3A227E headset detector, and add lookup entries for the codec GPIOs which control the second speaker amplifier and headphone path.
Changes since v1:
- move the enable-GPIO mapping out of the generic drv260x driver and into the Yoga Book board description, as requested by Dmitry;
- attach the software nodes to the existing ACPI-enumerated I2C devices, reprobe devices which attempted to bind before the nodes were available, and retain the device references until removal; and
- remove the dependency on the withdrawn optional-vbat Input change.
All three patches pass strict checkpatch, W=1 and sparse v0.6.5-rc1. They were tested on a Lenovo Yoga Book YB1-X91L: both haptic devices bind and work after suspend/resume, while speakers, microphone and headset detection use the described audio resources successfully.
With Best Regards,
Maurizio Casciano
Maurizio Casciano (3):
platform/x86: x86-android-tablets: Describe Yoga Book haptics platform/x86: x86-android-tablets: Add Yoga Book TS3A227E platform/x86: x86-android-tablets: Add Yoga Book audio GPIOs
.../platform/x86/x86-android-tablets/lenovo.c | 140 +++++++++++++++++- 1 file changed, 139 insertions(+), 1 deletion(-)
base-commit: 32e17ef088fc55858886738d0b904248e98b30e0
Signature · 1 line
2.53.0
PATCH v2 1/3 platform/x86: x86-android-tablets: Describe Yoga Book haptics
ACPI enumerates the Yoga Book YB1-X91F/L haptic controllers as DRV2604:00 and DRV2604:01, but omits the properties used by drv260x to identify their mode, waveform library and enable GPIO.
Register board software nodes and attach them to the existing I2C devices. Describe the enable signals using their Cherryview GPIO providers and pins from the firmware resource tables, keeping this board-specific mapping out of the generic input driver. Hold device references until removal, reprobe after adding properties to cover an earlier built-in probe, and detach the nodes in reverse order.
--- .../platform/x86/x86-android-tablets/lenovo.c | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +98 -0
@@ -114,6 +114,41 @@ 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_x91_drv2604_0_props[] = { +PROPERTY_ENTRY_U32 ("mode" ,0 ),/* DRV260X_LRA_MODE */ +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 property_entry lenovo_yb1_x91_drv2604_1_props[] = { +PROPERTY_ENTRY_U32 ("mode" ,0 ),/* DRV260X_LRA_MODE */ +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_x91_drv2604_0_node = { + .properties = lenovo_yb1_x91_drv2604_0_props, +}; + +static const struct software_node lenovo_yb1_x91_drv2604_1_node = { + .properties = lenovo_yb1_x91_drv2604_1_props, +}; + +static const struct software_node *lenovo_yb1_x91_swnodes[] = { + &lenovo_yb1_x91_drv2604_0_node, + &lenovo_yb1_x91_drv2604_1_node, +NULL +}; + +static const struct software_node *const lenovo_yb1_x91_drv2604_nodes[] = { + &lenovo_yb1_x91_drv2604_0_node, + &lenovo_yb1_x91_drv2604_1_node, +}; +static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[]__initconst = { {/* BQ27542 fuel-gauge */
@@ -283,9 +318,72 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init }, }; +#define YB1_X91_DRV2604_0_DEVICE "i2c-DRV2604:00" +#define YB1_X91_DRV2604_1_DEVICE "i2c-DRV2604:01" + +static struct device *lenovo_yb1_x91_drv2604_devs[2 ]; + +static void lenovo_yb1_x91_add_haptics_props (struct device *dev,int index, +const char *name) +{ +struct device *haptics_dev; +int ret; + + haptics_dev =bus_find_device_by_name (&i2c_bus_type,NULL , name); +if (!haptics_dev) { +dev_warn (dev,"cannot find %s, haptics will be unavailable\n" , name); +return ; + } + + ret =device_add_software_node (haptics_dev, + lenovo_yb1_x91_drv2604_nodes[index]); +if (ret) { +put_device (haptics_dev); +dev_warn (dev,"failed to add properties to %s: %d\n" , name, ret); +return ; + } + +/* Apply the properties if a built-in driver already attempted to probe. */ + ret =device_reprobe (haptics_dev); +if (ret) +dev_warn (dev,"failed to reprobe %s: %d\n" , name, ret); + + lenovo_yb1_x91_drv2604_devs[index] = haptics_dev; +} + +static void lenovo_yb1_x91_remove_haptics_props (int index) +{ +struct device *haptics_dev = lenovo_yb1_x91_drv2604_devs[index]; + +if (!haptics_dev) +return ; + +device_remove_software_node (haptics_dev); +put_device (haptics_dev); + lenovo_yb1_x91_drv2604_devs[index] =NULL ; +} + +static int __init lenovo_yb1_x91_init (struct device *dev) +{ +lenovo_yb1_x91_add_haptics_props (dev,0 ,YB1_X91_DRV2604_0_DEVICE ); +lenovo_yb1_x91_add_haptics_props (dev,1 ,YB1_X91_DRV2604_1_DEVICE ); + +return 0 ; +} + +static void lenovo_yb1_x91_exit (void ) +{ +lenovo_yb1_x91_remove_haptics_props (1 ); +lenovo_yb1_x91_remove_haptics_props (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), + .swnode_group = lenovo_yb1_x91_swnodes, + .gpiochip_type =X86_GPIOCHIP_CHERRYVIEW , + .init = lenovo_yb1_x91_init, + .exit = lenovo_yb1_x91_exit, };/* Lenovo Yoga Tablet 2 1050F/L's Android factory image has everything hardcoded */
Signature · 1 line
2.53.0
PATCH v2 2/3 platform/x86: x86-android-tablets: Add Yoga Book TS3A227E
In reply to Maurizio CascianoThe Yoga Book YB1-X91F/L firmware describes the TS3A227E headset detector as a secondary resource of the RT5677 codec rather than as an independent I2C device. No client is therefore created for it.
Instantiate the device on I2C1 at address 0x3b, describe its GPIO interrupt, and provide the mic-bias setting used by the Yoga Book design. This lets the ASoC machine driver use jack and button detection.
--- .../platform/x86/x86-android-tablets/lenovo.c | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/platform/x86/x86-android-tablets/lenovo.c +28 -1
@@ -149,6 +149,16 @@ static const struct software_node * const lenovo_yb1_x91_drv2604_nodes[] = { &lenovo_yb1_x91_drv2604_1_node, }; +static const struct property_entry lenovo_yb1_ts3a227e_props[] = { +/* Value taken from the Lenovo Android kernel code drop. */ +PROPERTY_ENTRY_U32 ("ti,micbias" ,7 ), + { } +}; + +static const struct software_node lenovo_yb1_ts3a227e_node = { + .properties = lenovo_yb1_ts3a227e_props, +}; +static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[]__initconst = { {/* BQ27542 fuel-gauge */
@@ -304,7 +314,7 @@ const struct x86_dev_info lenovo_yogabook_x90_info __initconst = { .init = lenovo_yb1_x90_init, }; -/* Lenovo Yoga Book X91F/L Windows tablet needs manual instantiation of the fuel-gauge client */ +/* Lenovo Yoga Book X91F/L Windows tablet needs extra platform descriptions. */ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[]__initconst = { {/* BQ27542 fuel-gauge */
@@ -315,6 +325,23 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init .swnode = &fg_bq25890_supply_node, }, .adapter_path = "\\_SB_.PCI0.I2C1", + }, { +/* The jack-detection IC is described as a secondary RT5677 resource. */ + .board_info = { + .type = "ts3a227e", + .addr = 0x3b, + .dev_name = "ts3a227e", + .swnode = &lenovo_yb1_ts3a227e_node, + }, + .adapter_path = "\\_SB_.PCI0.I2C1", + .irq_data = { + .type = X86_ACPI_IRQ_TYPE_GPIOINT, + .chip = "INT33FF:00", + .index = 77, + .trigger = ACPI_EDGE_SENSITIVE, + .polarity = ACPI_ACTIVE_LOW, + .con_id = "ts3a227e_irq", + }, }, };
Signature · 1 line
2.53.0
PATCH v2 3/3 platform/x86: x86-android-tablets: Add Yoga Book audio GPIOs
In reply to Maurizio CascianoThe Yoga Book YB1-X91F/L uses two GPIOs provided by the RT5677 codec itself. GPIO2 enables the second speaker amplifier and GPIO4 enables the headphone path, but ACPI does not map either signal.
Add lookup entries for the codec device so the Yoga Book ASoC machine driver can request both controls by function name. Register and remove the table with the tablet description lifetime.
--- drivers/platform/x86/x86-android-tablets/lenovo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +13 -0
@@ -345,6 +345,16 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init }, }; +static struct gpiod_lookup_table lenovo_yb1_x91_rt5677_gpios = { + .dev_id ="i2c-10EC5677:00" , + .table = { +/* GPIO2 drives the second speaker amp; GPIO4 drives headphones. */ +GPIO_LOOKUP ("rt5677" ,2 ,"speaker-enable2" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("rt5677" ,4 ,"headphone-enable" ,GPIO_ACTIVE_HIGH ), + { } + }, +}; +#define YB1_X91_DRV2604_0_DEVICE "i2c-DRV2604:00"#define YB1_X91_DRV2604_1_DEVICE "i2c-DRV2604:01"
@@ -392,6 +402,8 @@ static void lenovo_yb1_x91_remove_haptics_props(int index)static int __init lenovo_yb1_x91_init (struct device *dev) { +gpiod_add_lookup_table (&lenovo_yb1_x91_rt5677_gpios); +lenovo_yb1_x91_add_haptics_props (dev,0 ,YB1_X91_DRV2604_0_DEVICE );lenovo_yb1_x91_add_haptics_props (dev,1 ,YB1_X91_DRV2604_1_DEVICE );
@@ -402,6 +414,7 @@ static void lenovo_yb1_x91_exit(void) {lenovo_yb1_x91_remove_haptics_props (1 );lenovo_yb1_x91_remove_haptics_props (0 ); +gpiod_remove_lookup_table (&lenovo_yb1_x91_rt5677_gpios); }const struct x86_dev_info lenovo_yogabook_x91_info__initconst = {
Signature · 1 line
2.53.0
Re: [PATCH v2 3/3] platform/x86: x86-android-tablets: Add Yoga Book audio GPIOs
Hi Maurizio,
Quoted 22 lines · Maurizio Casciano
The Yoga Book YB1-X91F/L uses two GPIOs provided by the RT5677 codec itself. GPIO2 enables the second speaker amplifier and GPIO4 enables the headphone path, but ACPI does not map either signal.
Add lookup entries for the codec device so the Yoga Book ASoC machine driver can request both controls by function name. Register and remove the table with the tablet description lifetime.
Signed-off-by Maurizio Casciano <[email protected]>Assisted-by LLM sparse--- drivers/platform/x86/x86-android-tablets/lenovo.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/platform/x86/x86-android-tablets/lenovo.c +0
-0@@ -345,6 +345,16 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init }, };
drivers/platform/x86/x86-android-tablets/lenovo.c static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init · line 357
Quoted 10 lines
drivers/platform/x86/x86-android-tablets/lenovo.c +10
-0+static struct gpiod_lookup_table lenovo_yb1_x91_rt5677_gpios = { + .dev_id ="i2c-10EC5677:00" , + .table = { +/* GPIO2 drives the second speaker amp; GPIO4 drives headphones. */ +GPIO_LOOKUP ("rt5677" ,2 ,"speaker-enable2" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("rt5677" ,4 ,"headphone-enable" ,GPIO_ACTIVE_HIGH ), + { } + }, +}; +
It would be better if we used software nodes here instead of lookup tables.
Thanks.
Signature · 1 line
Dmitry
v3 cover platform/x86: Describe Yoga Book haptics and audio resources
The Lenovo Yoga Book YB1-X91F/L firmware omits software properties for its two DRV2604 haptic controllers and does not instantiate or map all resources used by the RT5677 audio design.
Attach board software nodes describing the DRV2604 mode, waveform library and enable GPIOs, instantiate the TS3A227E headset detector, and attach software-node GPIO properties to the RT5677 codec for the second speaker amplifier and headphone path.
Changes since v2:
- replace the RT5677 GPIO lookup table with GPIO properties on a codec-attached software node, as suggested by Dmitry; and
- reprobe the codec after attaching the software node so its GPIO provider is initialized with the new fwnode.
All three patches pass strict checkpatch. They were built and booted on a Lenovo Yoga Book YB1-X91L. Both haptic devices played effects before and after s2idle. From a fresh boot, the RT5677 GPIO consumers were present, GPIO2 went high during speaker playback, GPIO4 went high during headphone playback, and microphone capture succeeded.
With Best Regards,
Maurizio Casciano
Maurizio Casciano (3):
platform/x86: x86-android-tablets: Describe Yoga Book haptics platform/x86: x86-android-tablets: Add Yoga Book TS3A227E platform/x86: x86-android-tablets: Add Yoga Book audio GPIOs
.../platform/x86/x86-android-tablets/lenovo.c | 188 +++++++++++++++++- 1 file changed, 187 insertions(+), 1 deletion(-)
base-commit: 32e17ef088fc55858886738d0b904248e98b30e0
Signature · 1 line
2.53.0
PATCH v3 1/3 platform/x86: x86-android-tablets: Describe Yoga Book haptics
ACPI enumerates the Yoga Book YB1-X91F/L haptic controllers as DRV2604:00 and DRV2604:01, but omits the properties used by drv260x to identify their mode, waveform library and enable GPIO.
Register board software nodes and attach them to the existing I2C devices. Describe the enable signals using their Cherryview GPIO providers and pins from the firmware resource tables, keeping this board-specific mapping out of the generic input driver. Hold device references until removal, reprobe after adding properties to cover an earlier built-in probe, and detach the nodes in reverse order.
--- .../platform/x86/x86-android-tablets/lenovo.c | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +98 -0
@@ -114,6 +114,41 @@ 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_x91_drv2604_0_props[] = { +PROPERTY_ENTRY_U32 ("mode" ,0 ),/* DRV260X_LRA_MODE */ +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 property_entry lenovo_yb1_x91_drv2604_1_props[] = { +PROPERTY_ENTRY_U32 ("mode" ,0 ),/* DRV260X_LRA_MODE */ +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_x91_drv2604_0_node = { + .properties = lenovo_yb1_x91_drv2604_0_props, +}; + +static const struct software_node lenovo_yb1_x91_drv2604_1_node = { + .properties = lenovo_yb1_x91_drv2604_1_props, +}; + +static const struct software_node *lenovo_yb1_x91_swnodes[] = { + &lenovo_yb1_x91_drv2604_0_node, + &lenovo_yb1_x91_drv2604_1_node, +NULL +}; + +static const struct software_node *const lenovo_yb1_x91_drv2604_nodes[] = { + &lenovo_yb1_x91_drv2604_0_node, + &lenovo_yb1_x91_drv2604_1_node, +}; +static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[]__initconst = { {/* BQ27542 fuel-gauge */
@@ -283,9 +318,72 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init }, }; +#define YB1_X91_DRV2604_0_DEVICE "i2c-DRV2604:00" +#define YB1_X91_DRV2604_1_DEVICE "i2c-DRV2604:01" + +static struct device *lenovo_yb1_x91_drv2604_devs[2 ]; + +static void lenovo_yb1_x91_add_haptics_props (struct device *dev,int index, +const char *name) +{ +struct device *haptics_dev; +int ret; + + haptics_dev =bus_find_device_by_name (&i2c_bus_type,NULL , name); +if (!haptics_dev) { +dev_warn (dev,"cannot find %s, haptics will be unavailable\n" , name); +return ; + } + + ret =device_add_software_node (haptics_dev, + lenovo_yb1_x91_drv2604_nodes[index]); +if (ret) { +put_device (haptics_dev); +dev_warn (dev,"failed to add properties to %s: %d\n" , name, ret); +return ; + } + +/* Apply the properties if a built-in driver already attempted to probe. */ + ret =device_reprobe (haptics_dev); +if (ret) +dev_warn (dev,"failed to reprobe %s: %d\n" , name, ret); + + lenovo_yb1_x91_drv2604_devs[index] = haptics_dev; +} + +static void lenovo_yb1_x91_remove_haptics_props (int index) +{ +struct device *haptics_dev = lenovo_yb1_x91_drv2604_devs[index]; + +if (!haptics_dev) +return ; + +device_remove_software_node (haptics_dev); +put_device (haptics_dev); + lenovo_yb1_x91_drv2604_devs[index] =NULL ; +} + +static int __init lenovo_yb1_x91_init (struct device *dev) +{ +lenovo_yb1_x91_add_haptics_props (dev,0 ,YB1_X91_DRV2604_0_DEVICE ); +lenovo_yb1_x91_add_haptics_props (dev,1 ,YB1_X91_DRV2604_1_DEVICE ); + +return 0 ; +} + +static void lenovo_yb1_x91_exit (void ) +{ +lenovo_yb1_x91_remove_haptics_props (1 ); +lenovo_yb1_x91_remove_haptics_props (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), + .swnode_group = lenovo_yb1_x91_swnodes, + .gpiochip_type =X86_GPIOCHIP_CHERRYVIEW , + .init = lenovo_yb1_x91_init, + .exit = lenovo_yb1_x91_exit, };/* Lenovo Yoga Tablet 2 1050F/L's Android factory image has everything hardcoded */
Signature · 1 line
2.53.0
PATCH v3 2/3 platform/x86: x86-android-tablets: Add Yoga Book TS3A227E
In reply to Maurizio CascianoThe Yoga Book YB1-X91F/L firmware describes the TS3A227E headset detector as a secondary resource of the RT5677 codec rather than as an independent I2C device. No client is therefore created for it.
Instantiate the device on I2C1 at address 0x3b, describe its GPIO interrupt, and provide the mic-bias setting used by the Yoga Book design. This lets the ASoC machine driver use jack and button detection.
--- .../platform/x86/x86-android-tablets/lenovo.c | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/platform/x86/x86-android-tablets/lenovo.c +28 -1
@@ -149,6 +149,16 @@ static const struct software_node * const lenovo_yb1_x91_drv2604_nodes[] = { &lenovo_yb1_x91_drv2604_1_node, }; +static const struct property_entry lenovo_yb1_ts3a227e_props[] = { +/* Value taken from the Lenovo Android kernel code drop. */ +PROPERTY_ENTRY_U32 ("ti,micbias" ,7 ), + { } +}; + +static const struct software_node lenovo_yb1_ts3a227e_node = { + .properties = lenovo_yb1_ts3a227e_props, +}; +static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[]__initconst = { {/* BQ27542 fuel-gauge */
@@ -304,7 +314,7 @@ const struct x86_dev_info lenovo_yogabook_x90_info __initconst = { .init = lenovo_yb1_x90_init, }; -/* Lenovo Yoga Book X91F/L Windows tablet needs manual instantiation of the fuel-gauge client */ +/* Lenovo Yoga Book X91F/L Windows tablet needs extra platform descriptions. */ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[]__initconst = { {/* BQ27542 fuel-gauge */
@@ -315,6 +325,23 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init .swnode = &fg_bq25890_supply_node, }, .adapter_path = "\\_SB_.PCI0.I2C1", + }, { +/* The jack-detection IC is described as a secondary RT5677 resource. */ + .board_info = { + .type = "ts3a227e", + .addr = 0x3b, + .dev_name = "ts3a227e", + .swnode = &lenovo_yb1_ts3a227e_node, + }, + .adapter_path = "\\_SB_.PCI0.I2C1", + .irq_data = { + .type = X86_ACPI_IRQ_TYPE_GPIOINT, + .chip = "INT33FF:00", + .index = 77, + .trigger = ACPI_EDGE_SENSITIVE, + .polarity = ACPI_ACTIVE_LOW, + .con_id = "ts3a227e_irq", + }, }, };
Signature · 1 line
2.53.0
PATCH v3 3/3 platform/x86: x86-android-tablets: Add Yoga Book audio GPIOs
In reply to Maurizio CascianoThe Yoga Book YB1-X91F/L uses two GPIOs provided by the RT5677 codec itself. GPIO2 enables the second speaker amplifier and GPIO4 enables the headphone path, but ACPI does not map either signal.
Describe both controls with a software node attached to the codec device. The same node identifies the RT5677 GPIO provider, allowing the Yoga Book ASoC machine driver to request the controls by function name. Reprobe the codec after adding the node so the provider is initialized with the new fwnode before the machine driver requests the descriptors. Attach and remove the node with the tablet description lifetime.
--- .../platform/x86/x86-android-tablets/lenovo.c | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +61 -0
@@ -138,9 +138,26 @@ static const struct software_node lenovo_yb1_x91_drv2604_1_node = { .properties = lenovo_yb1_x91_drv2604_1_props, }; +static const struct software_node lenovo_yb1_x91_rt5677_node; + +static const struct property_entry lenovo_yb1_x91_rt5677_props[] = { +/* GPIO2 drives the second speaker amp; GPIO4 drives headphones. */ +PROPERTY_ENTRY_GPIO ("speaker-enable2-gpios" , + &lenovo_yb1_x91_rt5677_node,2 ,GPIO_ACTIVE_HIGH ), +PROPERTY_ENTRY_GPIO ("headphone-enable-gpios" , + &lenovo_yb1_x91_rt5677_node,4 ,GPIO_ACTIVE_HIGH ), + { } +}; + +static const struct software_node lenovo_yb1_x91_rt5677_node = { + .name ="rt5677" , + .properties = lenovo_yb1_x91_rt5677_props, +}; +static const struct software_node *lenovo_yb1_x91_swnodes[] = { &lenovo_yb1_x91_drv2604_0_node, &lenovo_yb1_x91_drv2604_1_node, + &lenovo_yb1_x91_rt5677_node,NULL };
@@ -345,11 +362,53 @@ static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __init }, }; +#define YB1_X91_RT5677_DEVICE "i2c-10EC5677:00"#define YB1_X91_DRV2604_0_DEVICE "i2c-DRV2604:00"#define YB1_X91_DRV2604_1_DEVICE "i2c-DRV2604:01" +static struct device *lenovo_yb1_x91_rt5677_dev;static struct device *lenovo_yb1_x91_drv2604_devs[2 ]; +static void lenovo_yb1_x91_add_audio_props (struct device *dev) +{ +struct device *codec_dev; +int ret; + + codec_dev =bus_find_device_by_name (&i2c_bus_type,NULL , +YB1_X91_RT5677_DEVICE ); +if (!codec_dev) { +dev_warn (dev,"cannot find %s, audio will be unavailable\n" , +YB1_X91_RT5677_DEVICE ); +return ; + } + + ret =device_add_software_node (codec_dev, &lenovo_yb1_x91_rt5677_node); +if (ret) { +put_device (codec_dev); +dev_warn (dev,"failed to add properties to %s: %d\n" , +YB1_X91_RT5677_DEVICE , ret); +return ; + } + +/* Ensure the codec GPIO provider is initialized with the new fwnode. */ + ret =device_reprobe (codec_dev); +if (ret) +dev_warn (dev,"failed to reprobe %s: %d\n" , +YB1_X91_RT5677_DEVICE , ret); + + lenovo_yb1_x91_rt5677_dev = codec_dev; +} + +static void lenovo_yb1_x91_remove_audio_props (void ) +{ +if (!lenovo_yb1_x91_rt5677_dev) +return ; + +device_remove_software_node (lenovo_yb1_x91_rt5677_dev); +put_device (lenovo_yb1_x91_rt5677_dev); + lenovo_yb1_x91_rt5677_dev =NULL ; +} +static void lenovo_yb1_x91_add_haptics_props (struct device *dev,int index,const char *name) {
@@ -392,6 +451,7 @@ static void lenovo_yb1_x91_remove_haptics_props(int index)static int __init lenovo_yb1_x91_init (struct device *dev) { +lenovo_yb1_x91_add_audio_props (dev);lenovo_yb1_x91_add_haptics_props (dev,0 ,YB1_X91_DRV2604_0_DEVICE );lenovo_yb1_x91_add_haptics_props (dev,1 ,YB1_X91_DRV2604_1_DEVICE );
@@ -402,6 +462,7 @@ static void lenovo_yb1_x91_exit(void) {lenovo_yb1_x91_remove_haptics_props (1 );lenovo_yb1_x91_remove_haptics_props (0 ); +lenovo_yb1_x91_remove_audio_props (); }const struct x86_dev_info lenovo_yogabook_x91_info__initconst = {
Signature · 1 line
2.53.0
Hi Hans,
This v3 series has been pending since August 30. It incorporates Dmitry's feedback by describing the RT5677 GPIOs with a codec-attached software node and reprobes the codec after attaching it. The series remains unchanged.
Please let me know if any further changes or testing are needed.
With Best Regards,
Maurizio Casciano