]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
UBUNTU: SAUCE: (no-up) ASoC: rt5660: Add ACPI support
authorShrirang Bagul <shrirang.bagul@canonical.com>
Wed, 11 Apr 2018 07:18:29 +0000 (15:18 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 12 Apr 2018 15:21:30 +0000 (10:21 -0500)
BugLink: http://bugs.launchpad.net/bugs/1657674
On Dell IoT Gateways, RT5660 codec is available with ACPI ID 10EC3277.
Also, GPIO's are only available by index, so we register mappings to allow
machine drivers to access them by name.

Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Acked-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
(cherry picked from commit 08b421848245f749d449f8db4d664e377f8100e3)
(source: git://kernel.ubuntu.com/ubuntu/ubuntu-xenial.git)
Signed-off-by: Shrirang Bagul <shrirang.bagul@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
sound/soc/codecs/rt5660.c

index d22ef00e0d964e09c9930f58d62c5f5c247e1a25..39dc2289d651148bbf0a4a3c57dd791490854ccd 100644 (file)
@@ -9,6 +9,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
@@ -1245,10 +1246,31 @@ MODULE_DEVICE_TABLE(of, rt5660_of_match);
 
 static const struct acpi_device_id rt5660_acpi_match[] = {
        { "10EC5660", 0 },
+       { "10EC3277", 0 },
        { },
 };
 MODULE_DEVICE_TABLE(acpi, rt5660_acpi_match);
 
+static const struct acpi_gpio_params audio_wake_intr_gpio = { 0, 0, false };
+static const struct acpi_gpio_params lineout_mute_gpio = { 1, 0, true };
+
+static const struct acpi_gpio_mapping byt_rt5660_gpios[] = {
+       { "audio-wake-intr-gpios", &audio_wake_intr_gpio, 1 },
+       { "lineout-mute-gpios", &lineout_mute_gpio , 1 },
+       { NULL },
+};
+
+static void rt5660_read_acpi_properties(struct rt5660_priv *rt5660,
+               struct device *dev)
+{
+       int ret;
+
+       ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
+                       byt_rt5660_gpios);
+       if (ret)
+               dev_warn(dev, "Failed to add driver gpios\n");
+}
+
 static int rt5660_parse_dt(struct rt5660_priv *rt5660, struct device *dev)
 {
        rt5660->pdata.in1_diff = device_property_read_bool(dev,
@@ -1288,6 +1310,10 @@ static int rt5660_i2c_probe(struct i2c_client *i2c,
                rt5660->pdata = *pdata;
        else if (i2c->dev.of_node)
                rt5660_parse_dt(rt5660, &i2c->dev);
+       else if (ACPI_HANDLE(&i2c->dev))
+               rt5660_read_acpi_properties(rt5660, &i2c->dev);
+       else
+               return -EINVAL;
 
        rt5660->regmap = devm_regmap_init_i2c(i2c, &rt5660_regmap);
        if (IS_ERR(rt5660->regmap)) {