Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support

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.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220223133153.730337-6-hdegoede@redhat.com

+69
+69
drivers/platform/x86/x86-android-tablets.c
··· 23 23 #include <linux/irqdomain.h> 24 24 #include <linux/module.h> 25 25 #include <linux/mod_devicetable.h> 26 + #include <linux/pinctrl/consumer.h> 27 + #include <linux/pinctrl/machine.h> 26 28 #include <linux/platform_data/lp855x.h> 27 29 #include <linux/platform_device.h> 28 30 #include <linux/pm.h> 29 31 #include <linux/power/bq24190_charger.h> 30 32 #include <linux/rmi.h> 31 33 #include <linux/serdev.h> 34 + #include <linux/spi/spi.h> 32 35 #include <linux/string.h> 33 36 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */ 34 37 #include "../../gpio/gpiolib.h" ··· 804 801 }, 805 802 }; 806 803 804 + #define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00" 805 + 806 + static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_codec_gpios = { 807 + .dev_id = LENOVO_YOGA_TAB2_830_1050_CODEC_NAME, 808 + .table = { 809 + GPIO_LOOKUP("gpio_crystalcove", 3, "reset", GPIO_ACTIVE_HIGH), 810 + GPIO_LOOKUP("INT33FC:01", 23, "wlf,ldoena", GPIO_ACTIVE_HIGH), 811 + GPIO_LOOKUP("arizona", 2, "wlf,spkvdd-ena", GPIO_ACTIVE_HIGH), 812 + GPIO_LOOKUP("arizona", 4, "wlf,micd-pol", GPIO_ACTIVE_LOW), 813 + { } 814 + }, 815 + }; 816 + 807 817 static struct gpiod_lookup_table * const lenovo_yoga_tab2_830_1050_gpios[] = { 808 818 &lenovo_yoga_tab2_830_1050_int3496_gpios, 819 + &lenovo_yoga_tab2_830_1050_codec_gpios, 809 820 NULL 810 821 }; 811 822 ··· 883 866 return 0; 884 867 } 885 868 869 + /* SUS (INT33FC:02) pin 6 needs to be configured as pmu_clk for the audio codec */ 870 + static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map = 871 + PIN_MAP_MUX_GROUP(LENOVO_YOGA_TAB2_830_1050_CODEC_NAME, "codec_32khz_clk", 872 + "INT33FC:02", "pmu_clk2_grp", "pmu_clk"); 873 + 874 + static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl; 875 + 876 + static int __init lenovo_yoga_tab2_830_1050_init_codec(void) 877 + { 878 + struct device *codec_dev; 879 + struct pinctrl *pinctrl; 880 + int ret; 881 + 882 + codec_dev = bus_find_device_by_name(&spi_bus_type, NULL, 883 + LENOVO_YOGA_TAB2_830_1050_CODEC_NAME); 884 + if (!codec_dev) { 885 + pr_err("error cannot find %s device\n", LENOVO_YOGA_TAB2_830_1050_CODEC_NAME); 886 + return -ENODEV; 887 + } 888 + 889 + ret = pinctrl_register_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map, 1); 890 + if (ret) 891 + goto err_put_device; 892 + 893 + pinctrl = pinctrl_get_select(codec_dev, "codec_32khz_clk"); 894 + if (IS_ERR(pinctrl)) { 895 + ret = dev_err_probe(codec_dev, PTR_ERR(pinctrl), "selecting codec_32khz_clk\n"); 896 + goto err_unregister_mappings; 897 + } 898 + 899 + /* We're done with the codec_dev now */ 900 + put_device(codec_dev); 901 + 902 + lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl; 903 + return 0; 904 + 905 + err_unregister_mappings: 906 + pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map); 907 + err_put_device: 908 + put_device(codec_dev); 909 + return ret; 910 + } 911 + 886 912 /* 887 913 * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off 888 914 * gets used as pm_power_off handler. This causes "poweroff" on these tablets ··· 946 886 if (ret) 947 887 return ret; 948 888 889 + ret = lenovo_yoga_tab2_830_1050_init_codec(); 890 + if (ret) 891 + return ret; 892 + 949 893 pm_power_off = lenovo_yoga_tab2_830_1050_power_off; 950 894 return 0; 951 895 } ··· 957 893 static void lenovo_yoga_tab2_830_1050_exit(void) 958 894 { 959 895 pm_power_off = NULL; /* Just turn poweroff into halt on module unload */ 896 + 897 + if (lenovo_yoga_tab2_830_1050_codec_pinctrl) { 898 + pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl); 899 + pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map); 900 + } 960 901 } 961 902 962 903 /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */