From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Mark Gross <markgross@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
platform-driver-x86@vger.kernel.org, linux-gpio@vger.kernel.org
Subject: Re: [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support
Date: Wed, 23 Feb 2022 17:04:04 +0200 [thread overview]
Message-ID: <YhZM5BOIckEAez4k@smile.fi.intel.com> (raw)
In-Reply-To: <20220223133153.730337-6-hdegoede@redhat.com>
On Wed, Feb 23, 2022 at 02:31:53PM +0100, Hans de Goede wrote:
> 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,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/platform/x86/x86-android-tablets.c | 69 ++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
> index c3d2b30dbe26..f446be72e539 100644
> --- a/drivers/platform/x86/x86-android-tablets.c
> +++ b/drivers/platform/x86/x86-android-tablets.c
> @@ -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");
To avoid typos in messages you may define "codec_32khz_clk" and reuse in all (three?)
cases.
> +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 */
> --
> 2.35.1
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2022-02-23 15:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
2022-02-23 13:31 ` [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk Hans de Goede
2022-02-23 14:54 ` Andy Shevchenko
2022-02-23 15:27 ` Andy Shevchenko
2022-02-23 13:31 ` [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs Hans de Goede
2022-02-23 14:56 ` Andy Shevchenko
2022-02-23 15:16 ` Hans de Goede
2022-02-23 15:38 ` Andy Shevchenko
2022-02-24 16:49 ` Hans de Goede
2022-02-23 13:31 ` [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data Hans de Goede
2022-02-23 15:04 ` Andy Shevchenko
2022-02-23 13:31 ` [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang Hans de Goede
2022-02-23 14:58 ` Andy Shevchenko
2022-02-24 16:57 ` Hans de Goede
2022-02-25 16:35 ` Andy Shevchenko
2022-02-23 13:31 ` [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support Hans de Goede
2022-02-23 15:04 ` Andy Shevchenko [this message]
2022-02-23 14:55 ` [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Andy Shevchenko
2022-02-24 16:43 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YhZM5BOIckEAez4k@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=hdegoede@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox