pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support
Subsystems (4)
cover pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support
Hi All,
This series consists of 2 parts:
Patch 1 : pinctrl: baytrail: Add pinconf group + function for the pmu_clk
Patch 2-5 : platform/x86: x86-android-tablets: Add Lenovo Yoga Tab2 support
Patch 5 has a runtime dependency on patch 1, but this is only runtime and there are some other patches in flight to other subsystems which are also needed for the Lenovo Yoga Tab2 support.
As such I believe that patch 1 can be merged independently through the pinctrl-intel tree and then I'll merge patches 2-5 through the pdx86 tree.
The only reason for sending this out as a series is because patch 5 uses the new pmu_clk pinconf added by patch 1.
Regards,
Hans
Hans de Goede (5):
pinctrl: baytrail: Add pinconf group + function for the pmu_clk platform/x86: x86-android-tablets: Fix EBUSY error when requesting
IOAPIC IRQs
platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050
data
platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2
830/1050 poweroff hang
platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound
support
drivers/pinctrl/intel/pinctrl-baytrail.c | 9 + drivers/platform/x86/x86-android-tablets.c | 280 +++++++++++++++++++++ 2 files changed, 289 insertions(+)
Signature · 1 line
2.35.1
PATCH 1/5 pinctrl: baytrail: Add pinconf group + function for the pmu_clk
On the Lenovo Yoga Tablet 2 830 / 1050 / 1051 models the 32KHz PMU clk, which can be muxed externally to SUS pin 5 and/or 6 is used as a clock for the audio codec.
On the 830 and 1050 models, with ship with Android as factory OS the pin-muxing for this is not setup by the BIOS.
Add a pinconf group + function for the pmu_clk on SUS pin 5 and 6 to allow setting the pinmux up from within the x86-android-tablets platform code.
--- drivers/pinctrl/intel/pinctrl-baytrail.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/pinctrl/intel/pinctrl-baytrail.c +9 -0
@@ -444,6 +444,9 @@ static const unsigned int byt_sus_pcu_spi_pins[] = { 21 };static const unsigned int byt_sus_pcu_spi_mode_values[] = {0 };static const unsigned int byt_sus_pcu_spi_gpio_mode_values[] = {1 }; +static const unsigned int byt_sus_pmu_clk1_pins[] = {5 }; +static const unsigned int byt_sus_pmu_clk2_pins[] = {6 }; +static const struct intel_pingroup byt_sus_groups[] = {PIN_GROUP ("usb_oc_grp" , byt_sus_usb_over_current_pins, byt_sus_usb_over_current_mode_values),PIN_GROUP ("usb_ulpi_grp" , byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mode_values),
@@ -451,20 +454,26 @@ static const struct intel_pingroup byt_sus_groups[] = {PIN_GROUP ("usb_oc_grp_gpio" , byt_sus_usb_over_current_pins, byt_sus_usb_over_current_gpio_mode_values),PIN_GROUP ("usb_ulpi_grp_gpio" , byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_gpio_mode_values),PIN_GROUP ("pcu_spi_grp_gpio" , byt_sus_pcu_spi_pins, byt_sus_pcu_spi_gpio_mode_values), +PIN_GROUP ("pmu_clk1_grp" , byt_sus_pmu_clk1_pins,1 ), + PIN_GROUP("pmu_clk2_grp", byt_sus_pmu_clk2_pins, 1), };static const char *const byt_sus_usb_groups[] = {"usb_oc_grp" ,"usb_ulpi_grp" , };static const char *const byt_sus_spi_groups[] = {"pcu_spi_grp" }; +static const char *const byt_sus_pmu_clk_groups[] = { +"pmu_clk1_grp" ,"pmu_clk2_grp" };static const char *const byt_sus_gpio_groups[] = {"usb_oc_grp_gpio" ,"usb_ulpi_grp_gpio" ,"pcu_spi_grp_gpio" , +"pmu_clk1_grp" ,"pmu_clk2_grp" , };static const struct intel_function byt_sus_functions[] = {FUNCTION ("usb" , byt_sus_usb_groups),FUNCTION ("spi" , byt_sus_spi_groups),FUNCTION ("gpio" , byt_sus_gpio_groups), +FUNCTION ("pmu_clk" , byt_sus_pmu_clk_groups), }; static const struct intel_community byt_sus_communities[] = {
Signature · 1 line
2.35.1
Re: [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk
Quoted 10 lines · Hans de Goede
On the Lenovo Yoga Tablet 2 830 / 1050 / 1051 models the 32KHz PMU clk, which can be muxed externally to SUS pin 5 and/or 6 is used as a clock for the audio codec.
On the 830 and 1050 models, with ship with Android as factory OS the pin-muxing for this is not setup by the BIOS.
Add a pinconf group + function for the
pmu_clkon SUS pin 5 and 6 to allow setting the pinmux up from within the x86-android-tablets platform code.
With nit-pick addressed,
Quoted 23 lines
Signed-off-by Hans de Goede <[email protected]>--- drivers/pinctrl/intel/pinctrl-baytrail.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/pinctrl/intel/pinctrl-baytrail.c +3
-0@@ -444,6 +444,9 @@ static const unsigned int byt_sus_pcu_spi_pins[] = { 21 };static const unsigned int byt_sus_pcu_spi_mode_values[] = {0 };static const unsigned int byt_sus_pcu_spi_gpio_mode_values[] = {1 }; +static const unsigned int byt_sus_pmu_clk1_pins[] = {5 }; +static const unsigned int byt_sus_pmu_clk2_pins[] = {6 }; +static const struct intel_pingroup byt_sus_groups[] = {PIN_GROUP ("usb_oc_grp" , byt_sus_usb_over_current_pins, byt_sus_usb_over_current_mode_values),PIN_GROUP ("usb_ulpi_grp" , byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mode_values),@@ -451,20 +454,26 @@ static const struct intel_pingroup byt_sus_groups[] = {PIN_GROUP ("usb_oc_grp_gpio" , byt_sus_usb_over_current_pins, byt_sus_usb_over_current_gpio_mode_values),PIN_GROUP ("usb_ulpi_grp_gpio" , byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_gpio_mode_values), PIN_GROUP("pcu_spi_grp_gpio", byt_sus_pcu_spi_pins, byt_sus_pcu_spi_gpio_mode_values),
drivers/pinctrl/intel/pinctrl-baytrail.c static const struct intel_pingroup byt_sus_groups[] = { · line 466
Quoted 10 lines
drivers/pinctrl/intel/pinctrl-baytrail.c +4
-0+PIN_GROUP ("pmu_clk1_grp" , byt_sus_pmu_clk1_pins,1 ), + PIN_GROUP("pmu_clk2_grp", byt_sus_pmu_clk2_pins, 1), };static const char *const byt_sus_usb_groups[] = {"usb_oc_grp" ,"usb_ulpi_grp" , };static const char *const byt_sus_spi_groups[] = {"pcu_spi_grp" }; +static const char *const byt_sus_pmu_clk_groups[] = { +"pmu_clk1_grp" ,"pmu_clk2_grp" };
}; on new line.
Quoted 16 lines
drivers/pinctrl/intel/pinctrl-baytrail.c +2
-0static const char *const byt_sus_gpio_groups[] = {"usb_oc_grp_gpio" ,"usb_ulpi_grp_gpio" ,"pcu_spi_grp_gpio" , +"pmu_clk1_grp" ,"pmu_clk2_grp" , };static const struct intel_function byt_sus_functions[] = {FUNCTION ("usb" , byt_sus_usb_groups),FUNCTION ("spi" , byt_sus_spi_groups),FUNCTION ("gpio" , byt_sus_gpio_groups), +FUNCTION ("pmu_clk" , byt_sus_pmu_clk_groups), };static const struct intel_community byt_sus_communities[] = {Signature · 1 line
2.35.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk
Quoted 1 line · Andy Shevchenko
On Wed, Feb 23, 2022 at 02:31:49PM +0100, Hans de Goede wrote:
...
Quoted 8 lines
drivers/pinctrl/intel/pinctrl-baytrail.c static const struct intel_pingroup byt_sus_groups[] = { · line 466
Quoted 6 lines
static const char * const byt_sus_usb_groups[] = {
drivers/pinctrl/intel/pinctrl-baytrail.c +2
-0"usb_oc_grp", "usb_ulpi_grp", };static const char *const byt_sus_spi_groups[] = {"pcu_spi_grp" }; +static const char *const byt_sus_pmu_clk_groups[] = { +"pmu_clk1_grp" ,"pmu_clk2_grp" };}; on new line.
And add a comma in that case.
See how USB is written above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 2/5 platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
In reply to Hans de GoedeSometimes IRQs used by GPIOs in direct-IRQ mode are already registered because they are used as ACPI "Interrupt () {}" resource for one of the many bogus I2C devices present in the broken DSDTs of Android x86 tablets.
This is an issue if the existing (bogus) ACPI resource uses different trigger settings then what is being requested, leading to an -EBUSY error return of acpi_register_gsi().
Fix this by calling acpi_unregister_gsi() first, so that the acpi_register_gsi() is allowed to change the trigger settings.
In cases where the GSI has not been registered yet the acpi_unregister_gsi() is a no-op.
--- drivers/platform/x86/x86-android-tablets.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/platform/x86/x86-android-tablets.c +6 -0
@@ -89,6 +89,12 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)switch (data->type) {case X86_ACPI_IRQ_TYPE_APIC : +/* +* The DSDT may already reference the GSI in a device skipped by +* acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI +* to avoid EBUSY errors in this case. +*/ +acpi_unregister_gsi (data->index); irq =acpi_register_gsi (NULL , data->index, data->trigger, data->polarity);if (irq <0 )pr_err ("error %d getting APIC IRQ %d\n" , irq, data->index);
Signature · 1 line
2.35.1
Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
Quoted 13 lines · Hans de Goede
Sometimes IRQs used by GPIOs in direct-IRQ mode are already registered because they are used as ACPI "Interrupt () {}" resource for one of the many bogus I2C devices present in the broken DSDTs of Android x86 tablets.
This is an issue if the existing (bogus) ACPI resource uses different trigger settings then what is being requested, leading to an
-EBUSYerror return ofacpi_register_gsi().Fix this by calling
acpi_unregister_gsi()first, so that theacpi_register_gsi()is allowed to change the trigger settings.In cases where the GSI has not been registered yet the
acpi_unregister_gsi()is a no-op.
...
drivers/platform/x86/x86-android-tablets.c static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data) · line 97
Quoted 7 lines
drivers/platform/x86/x86-android-tablets.c +6
-0case X86_ACPI_IRQ_TYPE_APIC : +/* +* The DSDT may already reference the GSI in a device skipped by +* acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI +* to avoid EBUSY errors in this case. +*/ +acpi_unregister_gsi (data->index);
Perhaps a warning (or at least debug) message?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
Hi,
Quoted 17 lines · Andy Shevchenko
Quoted 13 lines · Hans de Goede
Sometimes IRQs used by GPIOs in direct-IRQ mode are already registered because they are used as ACPI "Interrupt () {}" resource for one of the many bogus I2C devices present in the broken DSDTs of Android x86 tablets.
This is an issue if the existing (bogus) ACPI resource uses different trigger settings then what is being requested, leading to an
-EBUSYerror return ofacpi_register_gsi().Fix this by calling
acpi_unregister_gsi()first, so that theacpi_register_gsi()is allowed to change the trigger settings.In cases where the GSI has not been registered yet the
acpi_unregister_gsi()is a no-op....
Quoted 9 lines
drivers/platform/x86/x86-android-tablets.c static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data) · line 97
Quoted 7 lines
drivers/platform/x86/x86-android-tablets.c +6
-0case X86_ACPI_IRQ_TYPE_APIC : +/* +* The DSDT may already reference the GSI in a device skipped by +* acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI +* to avoid EBUSY errors in this case. +*/ +acpi_unregister_gsi (data->index);Perhaps a warning (or at least debug) message?
The function returns void, so we cannot check if it did anything or not.
Regards,
Hans
Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
Quoted 2 lines · Hans de Goede
Quoted 1 line · Andy Shevchenko
On Wed, Feb 23, 2022 at 02:31:50PM +0100, Hans de Goede wrote:
...
Quoted 11 lines
Quoted 9 lines
drivers/platform/x86/x86-android-tablets.c static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data) · line 97
Quoted 7 lines
drivers/platform/x86/x86-android-tablets.c +6
-0case X86_ACPI_IRQ_TYPE_APIC : +/* +* The DSDT may already reference the GSI in a device skipped by +* acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI +* to avoid EBUSY errors in this case. +*/ +acpi_unregister_gsi (data->index);Perhaps a warning (or at least debug) message?
The function returns void, so we cannot check if it did anything or not.
Another approach may be to try to register GSI and if fail, try unregister and register again?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
Hi,
Quoted 16 lines · Andy Shevchenko
Quoted 2 lines · Hans de Goede
Quoted 1 line · Andy Shevchenko
On Wed, Feb 23, 2022 at 02:31:50PM +0100, Hans de Goede wrote:
...
Quoted 10 lines
Quoted 9 lines
drivers/platform/x86/x86-android-tablets.c static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data) · line 97
Quoted 7 lines
drivers/platform/x86/x86-android-tablets.c +6
-0case X86_ACPI_IRQ_TYPE_APIC : +/* +* The DSDT may already reference the GSI in a device skipped by +* acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI +* to avoid EBUSY errors in this case. +*/ +acpi_unregister_gsi (data->index);Perhaps a warning (or at least debug) message?
Quoted 4 lines
Quoted 1 line
The function returns void, so we cannot check if it did anything or not.
Another approach may be to try to register GSI and if fail, try unregister and register again?
Since we only run this on boards where it is specifically enabled and it thus has been tested to be safe I believe that that needlessly complicates things, so I'm just going to merge this as is.
Regards,
Hans
PATCH 3/5 platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data
In reply to Hans de GoedeThe Lenovo Yoga Tablet 2 series comes in 4 versions: 830F, 830L, 1050F and 1050L. The F postfix indicates a wifi only version and the L postfix indicates a LTE version. The 830 models are 8" and the 1050 models are 10".
Despite there being 8" and 10" versions all models use the same mainboard, with an identical BIOS and thus identical DMI strings, so support for all 4 models is added through a single DMI table entry.
As all devices dealt with in the x86-android-tablets modules, these are x86 ACPI tablets which ships with Android x86 as factory OS. The mainboard's DSDT contain 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.
This has been tested on a 830F and a 1050L tablet.
--- drivers/platform/x86/x86-android-tablets.c | 184 +++++++++++++++++++++ 1 file changed, 184 insertions(+)
drivers/platform/x86/x86-android-tablets.c +184 -0
@@ -22,8 +22,10 @@#include <linux/irqdomain.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/platform_data/lp855x.h> #include <linux/platform_device.h> #include <linux/power/bq24190_charger.h> +#include <linux/rmi.h> #include <linux/serdev.h> #include <linux/string.h> /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
@@ -182,6 +184,15 @@ static const char * const tusb1211_chg_det_psy[] = { "tusb1211-charger-detect" }static const char *const bq24190_psy[] = {"bq24190-charger" };static const char *const bq25890_psy[] = {"bq25890-charger" }; +static const struct property_entry fg_bq24190_supply_props[] = { +PROPERTY_ENTRY_STRING_ARRAY ("supplied-from" , bq24190_psy), + { } +}; + +static const struct software_node fg_bq24190_supply_node = { + .properties = fg_bq24190_supply_props, +}; +static const struct property_entry fg_bq25890_supply_props[] = {PROPERTY_ENTRY_STRING_ARRAY ("supplied-from" , bq25890_psy), { }
@@ -704,6 +715,165 @@ static const struct x86_dev_info lenovo_yogabook_x9x_info __initconst = { .i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x9x_i2c_clients), }; +/* Lenovo Yoga Tablet 2 1050F/L's Android factory img has everything hardcoded */ +static const struct property_entry lenovo_yoga_tab2_830_1050_bq24190_props[] = { +PROPERTY_ENTRY_STRING_ARRAY ("supplied-from" , tusb1211_chg_det_psy), +PROPERTY_ENTRY_REF ("monitored-battery" , &generic_lipo_hv_4v35_battery_node), +PROPERTY_ENTRY_BOOL ("omit-battery-class" ), +PROPERTY_ENTRY_BOOL ("disable-reset" ), + { } +}; + +static const struct software_node lenovo_yoga_tab2_830_1050_bq24190_node = { + .properties = lenovo_yoga_tab2_830_1050_bq24190_props, +}; + +/* This gets filled by lenovo_yoga_tab2_830_1050_init() */ +static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { }; + +static struct lp855x_platform_data lenovo_yoga_tab2_830_1050_lp8557_pdata = { + .device_control =0x86 , + .initial_brightness =128 , +}; + +static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[]__initconst = { + { +/* bq24292i battery charger */ + .board_info = { + .type ="bq24190" , + .addr =0x6b , + .dev_name ="bq24292i" , + .swnode = &lenovo_yoga_tab2_830_1050_bq24190_node, + .platform_data = &bq24190_pdata, + }, + .adapter_path ="\\_SB_.I2C1" , + .irq_data = { + .type =X86_ACPI_IRQ_TYPE_GPIOINT , + .chip ="INT33FC:02" , + .index =2 , + .trigger =ACPI_EDGE_SENSITIVE , + .polarity =ACPI_ACTIVE_HIGH , + }, + }, { +/* BQ27541 fuel-gauge */ + .board_info = { + .type ="bq27541" , + .addr =0x55 , + .dev_name ="bq27541" , + .swnode = &fg_bq24190_supply_node, + }, + .adapter_path ="\\_SB_.I2C1" , + }, { +/* Synaptics RMI touchscreen */ + .board_info = { + .type ="rmi4_i2c" , + .addr =0x38 , + .dev_name ="rmi4_i2c" , + .platform_data = &lenovo_yoga_tab2_830_1050_rmi_pdata, + }, + .adapter_path ="\\_SB_.I2C6" , + .irq_data = { + .type =X86_ACPI_IRQ_TYPE_APIC , + .index =0x45 , + .trigger =ACPI_EDGE_SENSITIVE , + .polarity =ACPI_ACTIVE_HIGH , + }, + }, { +/* LP8557 Backlight controller */ + .board_info = { + .type ="lp8557" , + .addr =0x2c , + .dev_name ="lp8557" , + .platform_data = &lenovo_yoga_tab2_830_1050_lp8557_pdata, + }, + .adapter_path ="\\_SB_.I2C3" , + }, +}; + +static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = { + .dev_id ="intel-int3496" , + .table = { +GPIO_LOOKUP ("INT33FC:02" ,1 ,"mux" ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP ("INT33FC:02" ,24 ,"id" ,GPIO_ACTIVE_HIGH ), + { } + }, +}; + +static struct gpiod_lookup_table *const lenovo_yoga_tab2_830_1050_gpios[] = { + &lenovo_yoga_tab2_830_1050_int3496_gpios, +NULL +}; + +static int __init lenovo_yoga_tab2_830_1050_init (void ); +static void lenovo_yoga_tab2_830_1050_exit (void ); + +static struct x86_dev_info lenovo_yoga_tab2_830_1050_info__initdata = { + .i2c_client_info = lenovo_yoga_tab2_830_1050_i2c_clients, +/* i2c_client_count gets set by lenovo_yoga_tab2_830_1050_init() */ + .pdev_info = int3496_pdevs, + .pdev_count =ARRAY_SIZE (int3496_pdevs), + .gpiod_lookup_tables = lenovo_yoga_tab2_830_1050_gpios, + .bat_swnode = &generic_lipo_hv_4v35_battery_node, + .modules = bq24190_modules, + .invalid_aei_gpiochip ="INT33FC:02" , + .init = lenovo_yoga_tab2_830_1050_init, +}; + +/* +* The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same +* mainboard, but they need some different treatment related to the display: +* 1. The 830 uses a portrait LCD panel with a landscape touchscreen, requiring +* the touchscreen driver to adjust the touch-coords to match the LCD. +* 2. Both use an TI LP8557 LED backlight controller. On the 1050 the LP8557's +* PWM input is connected to the PMIC's PWM output and everything works fine +* with the defaults programmed into the LP8557 by the BIOS. +* But on the 830 the LP8557's PWM input is connected to a PWM output coming +* from the LCD panel's controller. The Android code has a hack in the i915 +* driver to write the non-standard DSI reg 0x9f with the desired backlight +* level to set the duty-cycle of the LCD's PWM output. +* +* To avoid having to have a similar hack in the mainline kernel the LP8557 +* entry in lenovo_yoga_tab2_830_1050_i2c_clients instead just programs the +* LP8557 to directly set the level, ignoring the PWM input. This means that +* the LP8557 i2c_client should only be instantiated on the 830. +*/ +static int __init lenovo_yoga_tab2_830_1050_init_display (void ) +{ +struct gpio_desc *gpiod; +int ret; + +/* Use PMIC GPIO 10 bootstrap pin to differentiate 830 vs 1050 */ + ret =x86_android_tablet_get_gpiod ("gpio_crystalcove" ,10 , &gpiod); +if (ret) +return ret; + + ret =gpiod_get_value_cansleep (gpiod); +if (ret) { +pr_info ("detected Lenovo Yoga Tablet 2 1050F/L\n" ); + lenovo_yoga_tab2_830_1050_info.i2c_client_count = +ARRAY_SIZE (lenovo_yoga_tab2_830_1050_i2c_clients) -1 ; + }else { +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_info.i2c_client_count = +ARRAY_SIZE (lenovo_yoga_tab2_830_1050_i2c_clients); + } + +return 0 ; +} + +static int __init lenovo_yoga_tab2_830_1050_init (void ) +{ +int ret; + + ret =lenovo_yoga_tab2_830_1050_init_display (); +if (ret) +return ret; + +return 0 ; +} +/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */ static const char *const nextbook_ares8_accel_mount_matrix[] = {"0" ,"-1" ,"0" ,
@@ -948,6 +1118,20 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = { }, .driver_data = (void *)&lenovo_yogabook_x9x_info, }, + { +/* +* Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10" +* Lenovo Yoga Tablet 2 use the same mainboard) +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corp." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"VALLEYVIEW C0 PLATFORM" ), +DMI_MATCH (DMI_BOARD_NAME ,"BYT-T FFD8" ), +/* Partial match on beginning of BIOS version */ + DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"), + }, + .driver_data = (void *)&lenovo_yoga_tab2_830_1050_info, + }, {/* Nextbook Ares 8 */ .matches = {
Signature · 1 line
2.35.1
Re: [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data
Quoted 14 lines · Hans de Goede
The Lenovo Yoga Tablet 2 series comes in 4 versions: 830F, 830L, 1050F and 1050L. The F postfix indicates a wifi only version and the L postfix indicates a LTE version. The 830 models are 8" and the 1050 models are 10".
Despite there being 8" and 10" versions all models use the same mainboard, with an identical BIOS and thus identical DMI strings, so support for all 4 models is added through a single DMI table entry.
As all devices dealt with in the x86-android-tablets modules, these are x86 ACPI tablets which ships with Android x86 as factory OS. The mainboard's DSDT contain 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().
Quoted 5 lines
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.
This has been tested on a 830F and a 1050L tablet.
Quoted 226 lines
Signed-off-by Hans de Goede <[email protected]>--- drivers/platform/x86/x86-android-tablets.c | 184 +++++++++++++++++++++ 1 file changed, 184 insertions(+)drivers/platform/x86/x86-android-tablets.c +184
-0@@ -22,8 +22,10 @@#include <linux/irqdomain.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/platform_data/lp855x.h> #include <linux/platform_device.h> #include <linux/power/bq24190_charger.h> +#include <linux/rmi.h> #include <linux/serdev.h> #include <linux/string.h> /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */ @@ -182,6 +184,15 @@ static const char * const tusb1211_chg_det_psy[] = { "tusb1211-charger-detect" }static const char *const bq24190_psy[] = {"bq24190-charger" };static const char *const bq25890_psy[] = {"bq25890-charger" }; +static const struct property_entry fg_bq24190_supply_props[] = { +PROPERTY_ENTRY_STRING_ARRAY ("supplied-from" , bq24190_psy), + { } +}; + +static const struct software_node fg_bq24190_supply_node = { + .properties = fg_bq24190_supply_props, +}; +static const struct property_entry fg_bq25890_supply_props[] = {PROPERTY_ENTRY_STRING_ARRAY ("supplied-from" , bq25890_psy), { }@@ -704,6 +715,165 @@ static const struct x86_dev_info lenovo_yogabook_x9x_info __initconst = { .i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x9x_i2c_clients), }; +/* Lenovo Yoga Tablet 2 1050F/L's Android factory img has everything hardcoded */ +static const struct property_entry lenovo_yoga_tab2_830_1050_bq24190_props[] = { +PROPERTY_ENTRY_STRING_ARRAY ("supplied-from" , tusb1211_chg_det_psy), +PROPERTY_ENTRY_REF ("monitored-battery" , &generic_lipo_hv_4v35_battery_node), +PROPERTY_ENTRY_BOOL ("omit-battery-class" ), +PROPERTY_ENTRY_BOOL ("disable-reset" ), + { } +}; + +static const struct software_node lenovo_yoga_tab2_830_1050_bq24190_node = { + .properties = lenovo_yoga_tab2_830_1050_bq24190_props, +}; + +/* This gets filled by lenovo_yoga_tab2_830_1050_init() */ +static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { }; + +static struct lp855x_platform_data lenovo_yoga_tab2_830_1050_lp8557_pdata = { + .device_control =0x86 , + .initial_brightness =128 , +}; + +static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[]__initconst = { + { +/* bq24292i battery charger */ + .board_info = { + .type ="bq24190" , + .addr =0x6b , + .dev_name ="bq24292i" , + .swnode = &lenovo_yoga_tab2_830_1050_bq24190_node, + .platform_data = &bq24190_pdata, + }, + .adapter_path ="\\_SB_.I2C1" , + .irq_data = { + .type =X86_ACPI_IRQ_TYPE_GPIOINT , + .chip ="INT33FC:02" , + .index =2 , + .trigger =ACPI_EDGE_SENSITIVE , + .polarity =ACPI_ACTIVE_HIGH , + }, + }, { +/* BQ27541 fuel-gauge */ + .board_info = { + .type ="bq27541" , + .addr =0x55 , + .dev_name ="bq27541" , + .swnode = &fg_bq24190_supply_node, + }, + .adapter_path ="\\_SB_.I2C1" , + }, { +/* Synaptics RMI touchscreen */ + .board_info = { + .type ="rmi4_i2c" , + .addr =0x38 , + .dev_name ="rmi4_i2c" , + .platform_data = &lenovo_yoga_tab2_830_1050_rmi_pdata, + }, + .adapter_path ="\\_SB_.I2C6" , + .irq_data = { + .type =X86_ACPI_IRQ_TYPE_APIC , + .index =0x45 , + .trigger =ACPI_EDGE_SENSITIVE , + .polarity =ACPI_ACTIVE_HIGH , + }, + }, { +/* LP8557 Backlight controller */ + .board_info = { + .type ="lp8557" , + .addr =0x2c , + .dev_name ="lp8557" , + .platform_data = &lenovo_yoga_tab2_830_1050_lp8557_pdata, + }, + .adapter_path ="\\_SB_.I2C3" , + }, +}; + +static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = { + .dev_id ="intel-int3496" , + .table = { +GPIO_LOOKUP ("INT33FC:02" ,1 ,"mux" ,GPIO_ACTIVE_LOW ), +GPIO_LOOKUP ("INT33FC:02" ,24 ,"id" ,GPIO_ACTIVE_HIGH ), + { } + }, +}; + +static struct gpiod_lookup_table *const lenovo_yoga_tab2_830_1050_gpios[] = { + &lenovo_yoga_tab2_830_1050_int3496_gpios, +NULL +}; + +static int __init lenovo_yoga_tab2_830_1050_init (void ); +static void lenovo_yoga_tab2_830_1050_exit (void ); + +static struct x86_dev_info lenovo_yoga_tab2_830_1050_info__initdata = { + .i2c_client_info = lenovo_yoga_tab2_830_1050_i2c_clients, +/* i2c_client_count gets set by lenovo_yoga_tab2_830_1050_init() */ + .pdev_info = int3496_pdevs, + .pdev_count =ARRAY_SIZE (int3496_pdevs), + .gpiod_lookup_tables = lenovo_yoga_tab2_830_1050_gpios, + .bat_swnode = &generic_lipo_hv_4v35_battery_node, + .modules = bq24190_modules, + .invalid_aei_gpiochip ="INT33FC:02" , + .init = lenovo_yoga_tab2_830_1050_init, +}; + +/* +* The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same +* mainboard, but they need some different treatment related to the display: +* 1. The 830 uses a portrait LCD panel with a landscape touchscreen, requiring +* the touchscreen driver to adjust the touch-coords to match the LCD. +* 2. Both use an TI LP8557 LED backlight controller. On the 1050 the LP8557's +* PWM input is connected to the PMIC's PWM output and everything works fine +* with the defaults programmed into the LP8557 by the BIOS. +* But on the 830 the LP8557's PWM input is connected to a PWM output coming +* from the LCD panel's controller. The Android code has a hack in the i915 +* driver to write the non-standard DSI reg 0x9f with the desired backlight +* level to set the duty-cycle of the LCD's PWM output. +* +* To avoid having to have a similar hack in the mainline kernel the LP8557 +* entry in lenovo_yoga_tab2_830_1050_i2c_clients instead just programs the +* LP8557 to directly set the level, ignoring the PWM input. This means that +* the LP8557 i2c_client should only be instantiated on the 830. +*/ +static int __init lenovo_yoga_tab2_830_1050_init_display (void ) +{ +struct gpio_desc *gpiod; +int ret; + +/* Use PMIC GPIO 10 bootstrap pin to differentiate 830 vs 1050 */ + ret =x86_android_tablet_get_gpiod ("gpio_crystalcove" ,10 , &gpiod); +if (ret) +return ret; + + ret =gpiod_get_value_cansleep (gpiod); +if (ret) { +pr_info ("detected Lenovo Yoga Tablet 2 1050F/L\n" ); + lenovo_yoga_tab2_830_1050_info.i2c_client_count = +ARRAY_SIZE (lenovo_yoga_tab2_830_1050_i2c_clients) -1 ; + }else { +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_info.i2c_client_count = +ARRAY_SIZE (lenovo_yoga_tab2_830_1050_i2c_clients); + } + +return 0 ; +} + +static int __init lenovo_yoga_tab2_830_1050_init (void ) +{ +int ret; + + ret =lenovo_yoga_tab2_830_1050_init_display (); +if (ret) +return ret; + +return 0 ; +} +/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */ static const char *const nextbook_ares8_accel_mount_matrix[] = {"0" ,"-1" ,"0" ,@@ -948,6 +1118,20 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = { }, .driver_data = (void *)&lenovo_yogabook_x9x_info, }, + { +/* +* Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10" +* Lenovo Yoga Tablet 2 use the same mainboard) +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Intel Corp." ), +DMI_MATCH (DMI_PRODUCT_NAME ,"VALLEYVIEW C0 PLATFORM" ), +DMI_MATCH (DMI_BOARD_NAME ,"BYT-T FFD8" ), +/* Partial match on beginning of BIOS version */ + DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"), + }, + .driver_data = (void *)&lenovo_yoga_tab2_830_1050_info, + }, {/* Nextbook Ares 8 */ .matches = {Signature · 1 line
2.35.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 4/5 platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
In reply to Hans de GoedeThese tablets' DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off gets used as pm_power_off handler. This causes "poweroff" on these tablets to hang hard. Requiring pressing the powerbutton for 30 seconds *twice* followed by a normal 3 second press to recover.
Avoid this by overriding the global pm_power_off handler to do an EFI poweroff instead.
--- drivers/platform/x86/x86-android-tablets.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/platform/x86/x86-android-tablets.c +21 -0
@@ -12,6 +12,7 @@#include <linux/acpi.h> #include <linux/dmi.h> +#include <linux/efi.h> #include <linux/gpio_keys.h> #include <linux/gpio/consumer.h> #include <linux/gpio/driver.h>
@@ -24,6 +25,7 @@#include <linux/mod_devicetable.h> #include <linux/platform_data/lp855x.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/power/bq24190_charger.h> #include <linux/rmi.h> #include <linux/serdev.h>
@@ -817,6 +819,7 @@ static struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initdata = { .modules = bq24190_modules, .invalid_aei_gpiochip = "INT33FC:02", .init = lenovo_yoga_tab2_830_1050_init, + .exit = lenovo_yoga_tab2_830_1050_exit, };/*
@@ -863,6 +866,18 @@ static int __init lenovo_yoga_tab2_830_1050_init_display(void)return 0 ; } +/* +* These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off +* gets used as pm_power_off handler. This causes "poweroff" on these tablets +* to hang hard. Requiring pressing the powerbutton for 30 seconds *twice* +* followed by a normal 3 second press to recover. Avoid this by doing an EFI +* poweroff instead. +*/ +static void lenovo_yoga_tab2_830_1050_power_off (void ) +{ + efi.reset_system (EFI_RESET_SHUTDOWN ,EFI_SUCCESS ,0 ,NULL ); +} +static int __init lenovo_yoga_tab2_830_1050_init (void ) {int ret;
@@ -871,9 +886,15 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)if (ret)return ret; + pm_power_off = lenovo_yoga_tab2_830_1050_power_off;return 0 ; } +static void lenovo_yoga_tab2_830_1050_exit (void ) +{ + pm_power_off =NULL ;/* Just turn poweroff into halt on module unload */ +} +/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */ static const char *const nextbook_ares8_accel_mount_matrix[] = {"0" ,"-1" ,"0" ,
Signature · 1 line
2.35.1
Re: [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
Quoted 7 lines · Hans de Goede
These tablets' DSDT does not set
acpi_gbl_reduced_hardware, soacpi_power_offgets used aspm_power_offhandler. This causes "poweroff" on these tablets to hang hard. Requiring pressing the powerbutton for 30 seconds *twice* followed by a normal 3 second press to recover.Avoid this by overriding the global
pm_power_offhandler to do an EFI poweroff instead.
Oh, you eventually found the root cause (reduced HW bit)? Perhaps we need to enforce it based on a quirk?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
Hi,
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Hans de Goede
These tablets' DSDT does not set
acpi_gbl_reduced_hardware, soacpi_power_offgets used aspm_power_offhandler. This causes "poweroff" on these tablets to hang hard. Requiring pressing the powerbutton for 30 seconds *twice* followed by a normal 3 second press to recover.Avoid this by overriding the global
pm_power_offhandler to do an EFI poweroff instead.Oh, you eventually found the root cause (reduced HW bit)?
I'm not sure, it is possible that not setting the reduced HW bit is actually correct for this hw, but that does lead to using acpi_power_off which seems broken on this system.
I've updated the commit message while merging this to reflect that using acpi_power_off is the problem, rather then not setting the reduced HW bit.
Also note that the issue of reboot being the same as poweroff once the system has been rebooted at least once is still unresolved.
Regards,
Hans
Re: [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
Quoted 14 lines · Hans de Goede
Hi,
Quoted 10 lines · Andy Shevchenko
Quoted 7 lines · Hans de Goede
These tablets' DSDT does not set
acpi_gbl_reduced_hardware, soacpi_power_offgets used aspm_power_offhandler. This causes "poweroff" on these tablets to hang hard. Requiring pressing the powerbutton for 30 seconds *twice* followed by a normal 3 second press to recover.Avoid this by overriding the global
pm_power_offhandler to do an EFI poweroff instead.Oh, you eventually found the root cause (reduced HW bit)?
Quoted 7 lines
I'm not sure, it is possible that not setting the reduced HW bit is actually correct for this hw, but that does lead to using
acpi_power_offwhich seems broken on this system.I've updated the commit message while merging this to reflect that using
acpi_power_offis the problem, rather then not setting the reduced HW bit.
Understood. Thanks!
Quoted 2 lines
Also note that the issue of reboot being the same as poweroff once the system has been rebooted at least once is still unresolved.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 5/5 platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support
In reply to Hans de GoedeThe ACPI tables for the codec setup on the Lenovo Yoga Tablet 2 830/1050 miss 2 things compared to their Windows (Lenovo Yoga Tablet 2 1051) counterparts:
1. There is no CLKE ACPI method to enable output of the 32KHz PMU clock on pin 6 of the SUS GPIO controller
2. The GPIOs used by the codec are not listed in the fwnode for the codec
Add pinctrl code to set the SUS6 pin mux manually and a gpio-lookup table for the GPIOs to work around both issues.
--- drivers/platform/x86/x86-android-tablets.c | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)
drivers/platform/x86/x86-android-tablets.c +69 -0
@@ -23,12 +23,15 @@#include <linux/irqdomain.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/pinctrl/consumer.h> +#include <linux/pinctrl/machine.h> #include <linux/platform_data/lp855x.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/power/bq24190_charger.h> #include <linux/rmi.h> #include <linux/serdev.h> +#include <linux/spi/spi.h> #include <linux/string.h> /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */ #include "../../gpio/gpiolib.h"
@@ -801,8 +804,22 @@ static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = { }, }; +#define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00" + +static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_codec_gpios = { + .dev_id =LENOVO_YOGA_TAB2_830_1050_CODEC_NAME , + .table = { +GPIO_LOOKUP ("gpio_crystalcove" ,3 ,"reset" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("INT33FC:01" ,23 ,"wlf,ldoena" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("arizona" ,2 ,"wlf,spkvdd-ena" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("arizona" ,4 ,"wlf,micd-pol" ,GPIO_ACTIVE_LOW ), + { } + }, +}; +static struct gpiod_lookup_table *const lenovo_yoga_tab2_830_1050_gpios[] = { &lenovo_yoga_tab2_830_1050_int3496_gpios, + &lenovo_yoga_tab2_830_1050_codec_gpios,NULL };
@@ -866,6 +883,49 @@ static int __init lenovo_yoga_tab2_830_1050_init_display(void)return 0 ; } +/* SUS (INT33FC:02) pin 6 needs to be configured as pmu_clk for the audio codec */ +static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map = +PIN_MAP_MUX_GROUP (LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ,"codec_32khz_clk" , +"INT33FC:02" ,"pmu_clk2_grp" ,"pmu_clk" ); + +static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl; + +static int __init lenovo_yoga_tab2_830_1050_init_codec (void ) +{ +struct device *codec_dev; +struct pinctrl *pinctrl; +int ret; + + codec_dev =bus_find_device_by_name (&spi_bus_type,NULL , +LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ); +if (!codec_dev) { +pr_err ("error cannot find %s device\n" ,LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ); +return -ENODEV ; + } + + ret =pinctrl_register_mappings (&lenovo_yoga_tab2_830_1050_codec_pinctrl_map,1 ); +if (ret) + goto err_put_device; + + pinctrl =pinctrl_get_select (codec_dev,"codec_32khz_clk" ); +if (IS_ERR (pinctrl)) { + ret =dev_err_probe (codec_dev,PTR_ERR (pinctrl),"selecting codec_32khz_clk\n" ); + goto err_unregister_mappings; + } + +/* We're done with the codec_dev now */ +put_device (codec_dev); + + lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl; +return 0 ; + +err_unregister_mappings: +pinctrl_unregister_mappings (&lenovo_yoga_tab2_830_1050_codec_pinctrl_map); +err_put_device: +put_device (codec_dev); +return ret; +} +/* * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off * gets used as pm_power_off handler. This causes "poweroff" on these tablets
@@ -886,6 +946,10 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)if (ret)return ret; + ret =lenovo_yoga_tab2_830_1050_init_codec (); +if (ret) +return ret; + pm_power_off = lenovo_yoga_tab2_830_1050_power_off;return 0 ; }
@@ -893,6 +957,11 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)static void lenovo_yoga_tab2_830_1050_exit (void ) { pm_power_off =NULL ;/* Just turn poweroff into halt on module unload */ + +if (lenovo_yoga_tab2_830_1050_codec_pinctrl) { +pinctrl_put (lenovo_yoga_tab2_830_1050_codec_pinctrl); +pinctrl_unregister_mappings (&lenovo_yoga_tab2_830_1050_codec_pinctrl_map); + } }/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
Signature · 1 line
2.35.1
Re: [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support
Quoted 11 lines · Hans de Goede
The ACPI tables for the codec setup on the Lenovo Yoga Tablet 2 830/1050 miss 2 things compared to their Windows (Lenovo Yoga Tablet 2 1051) counterparts:
1. There is no CLKE ACPI method to enable output of the 32KHz PMU clock on pin 6 of the SUS GPIO controller
2. The GPIOs used by the codec are not listed in the fwnode for the codec
Add pinctrl code to set the SUS6 pin mux manually and a gpio-lookup table for the GPIOs to work around both issues.
With or without an addressed nit-pick,
Quoted 49 lines
Signed-off-by Hans de Goede <[email protected]>--- drivers/platform/x86/x86-android-tablets.c | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+)drivers/platform/x86/x86-android-tablets.c +17
-0@@ -23,12 +23,15 @@#include <linux/irqdomain.h> #include <linux/module.h> #include <linux/mod_devicetable.h> +#include <linux/pinctrl/consumer.h> +#include <linux/pinctrl/machine.h> #include <linux/platform_data/lp855x.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/power/bq24190_charger.h> #include <linux/rmi.h> #include <linux/serdev.h> +#include <linux/spi/spi.h> #include <linux/string.h> /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */ #include "../../gpio/gpiolib.h" @@ -801,8 +804,22 @@ static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = { }, }; +#define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00" + +static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_codec_gpios = { + .dev_id =LENOVO_YOGA_TAB2_830_1050_CODEC_NAME , + .table = { +GPIO_LOOKUP ("gpio_crystalcove" ,3 ,"reset" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("INT33FC:01" ,23 ,"wlf,ldoena" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("arizona" ,2 ,"wlf,spkvdd-ena" ,GPIO_ACTIVE_HIGH ), +GPIO_LOOKUP ("arizona" ,4 ,"wlf,micd-pol" ,GPIO_ACTIVE_LOW ), + { } + }, +}; +static struct gpiod_lookup_table *const lenovo_yoga_tab2_830_1050_gpios[] = { &lenovo_yoga_tab2_830_1050_int3496_gpios, + &lenovo_yoga_tab2_830_1050_codec_gpios,NULL };
drivers/platform/x86/x86-android-tablets.c static int __init lenovo_yoga_tab2_830_1050_init_display(void) · line 890
Quoted 8 lines
drivers/platform/x86/x86-android-tablets.c +4
-0@@ -866,6 +883,49 @@ static int __init lenovo_yoga_tab2_830_1050_init_display(void)return 0 ; } +/* SUS (INT33FC:02) pin 6 needs to be configured as pmu_clk for the audio codec */ +static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map = +PIN_MAP_MUX_GROUP (LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ,"codec_32khz_clk" , +"INT33FC:02" ,"pmu_clk2_grp" ,"pmu_clk" );
To avoid typos in messages you may define "codec_32khz_clk" and reuse in all (three?) cases.
Quoted 67 lines
drivers/platform/x86/x86-android-tablets.c +47
-0+static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl; + +static int __init lenovo_yoga_tab2_830_1050_init_codec (void ) +{ +struct device *codec_dev; +struct pinctrl *pinctrl; +int ret; + + codec_dev =bus_find_device_by_name (&spi_bus_type,NULL , +LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ); +if (!codec_dev) { +pr_err ("error cannot find %s device\n" ,LENOVO_YOGA_TAB2_830_1050_CODEC_NAME ); +return -ENODEV ; + } + + ret =pinctrl_register_mappings (&lenovo_yoga_tab2_830_1050_codec_pinctrl_map,1 ); +if (ret) + goto err_put_device; + + pinctrl =pinctrl_get_select (codec_dev,"codec_32khz_clk" ); +if (IS_ERR (pinctrl)) { + ret =dev_err_probe (codec_dev,PTR_ERR (pinctrl),"selecting codec_32khz_clk\n" ); + goto err_unregister_mappings; + } + +/* We're done with the codec_dev now */ +put_device (codec_dev); + + lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl; +return 0 ; + +err_unregister_mappings: +pinctrl_unregister_mappings (&lenovo_yoga_tab2_830_1050_codec_pinctrl_map); +err_put_device: +put_device (codec_dev); +return ret; +} +/* * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off * gets used as pm_power_off handler. This causes "poweroff" on these tablets @@ -886,6 +946,10 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)if (ret)return ret; + ret =lenovo_yoga_tab2_830_1050_init_codec (); +if (ret) +return ret; + pm_power_off = lenovo_yoga_tab2_830_1050_power_off;return 0 ; }@@ -893,6 +957,11 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)static void lenovo_yoga_tab2_830_1050_exit (void ) { pm_power_off =NULL ;/* Just turn poweroff into halt on module unload */ + +if (lenovo_yoga_tab2_830_1050_codec_pinctrl) { +pinctrl_put (lenovo_yoga_tab2_830_1050_codec_pinctrl); +pinctrl_unregister_mappings (&lenovo_yoga_tab2_830_1050_codec_pinctrl_map); + } }/* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */ Signature · 1 line
2.35.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 11 lines · Hans de Goede
Hi All,
This series consists of 2 parts:
Patch 1 : pinctrl: baytrail: Add pinconf group + function for the
pmu_clk
Patch 2-5 : platform/x86: x86-android-tablets: Add Lenovo Yoga Tab2 supportPatch 5 has a runtime dependency on patch 1, but this is only runtime and there are some other patches in flight to other subsystems which are also needed for the Lenovo Yoga Tab2 support.
Quoted 5 lines
As such I believe that patch 1 can be merged independently through the pinctrl-intel tree and then I'll merge patches 2-5 through the pdx86 tree.
The only reason for sending this out as a series is because patch 5 uses the new
pmu_clkpinconf added by patch 1.
You may route via PDx86 and provide an IB to me, thanks!
Quoted 23 lines
Regards,
Hans
Hans de Goede (5):
pinctrl: baytrail: Add pinconf group + function for thepmu_clkplatform/x86: x86-android-tablets: Fix EBUSY error when requesting
IOAPIC IRQs
platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050
data
platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2830/1050 poweroff hangplatform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound
supportdrivers/pinctrl/intel/pinctrl-baytrail.c | 9 + drivers/platform/x86/x86-android-tablets.c | 280 +++++++++++++++++++++ 2 files changed, 289 insertions(+)Signature · 1 line
2.35.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi,
Quoted 12 lines · Andy Shevchenko
Quoted 11 lines · Hans de Goede
Hi All,
This series consists of 2 parts:
Patch 1 : pinctrl: baytrail: Add pinconf group + function for the
pmu_clk
Patch 2-5 : platform/x86: x86-android-tablets: Add Lenovo Yoga Tab2 supportPatch 5 has a runtime dependency on patch 1, but this is only runtime and there are some other patches in flight to other subsystems which are also needed for the Lenovo Yoga Tab2 support.
Quoted 7 lines
Quoted 5 lines
As such I believe that patch 1 can be merged independently through the pinctrl-intel tree and then I'll merge patches 2-5 through the pdx86 tree.
The only reason for sending this out as a series is because patch 5 uses the new
pmu_clkpinconf added by patch 1.You may route via PDx86 and provide an IB to me, thanks!
Ok, I've just created an immutable-branch + signed tag for this, with your 2 small nitpicks fixed.
I'll send you a pull-req for this right away.
Regards,
Hans
Quoted 25 lines
Quoted 24 lines
Regards,
Hans
Hans de Goede (5):
pinctrl: baytrail: Add pinconf group + function for thepmu_clkplatform/x86: x86-android-tablets: Fix EBUSY error when requesting
IOAPIC IRQs
platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050
data
platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2830/1050 poweroff hangplatform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound
supportdrivers/pinctrl/intel/pinctrl-baytrail.c | 9 + drivers/platform/x86/x86-android-tablets.c | 280 +++++++++++++++++++++ 2 files changed, 289 insertions(+)Signature · 1 line
2.35.1