ASoC: Intel: Atom: Add quirk for Surface 3
authorVinod Koul <vinod.koul@intel.com>
Fri, 8 Jul 2016 10:09:49 +0000 (15:39 +0530)
committerMark Brown <broonie@kernel.org>
Fri, 8 Jul 2016 12:26:26 +0000 (14:26 +0200)
Surface 3 is CHT based device which shows up with RT5645 codec. But the
BIOS reports ACPI ID as 5640!

To solve this, add a DMI overide for cht-5640 machine.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=98001
Signed-off-by: Sachin Mokashi <sachinx.mokashi@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/atom/sst/sst_acpi.c
sound/soc/intel/common/sst-acpi.h

index 3bc4b63b2f9daaefe7d135dd2100e1ea94f479b4..82a374d885a751ff94772a1cf4fb3103335f7c98 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/firmware.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_qos.h>
+#include <linux/dmi.h>
 #include <linux/acpi.h>
 #include <asm/platform_sst_audio.h>
 #include <sound/core.h>
@@ -237,6 +238,9 @@ static int sst_acpi_probe(struct platform_device *pdev)
                dev_err(dev, "No matching machine driver found\n");
                return -ENODEV;
        }
+       if (mach->machine_quirk)
+               mach = mach->machine_quirk(mach);
+
        pdata = mach->pdata;
 
        ret = kstrtouint(id->id, 16, &dev_id);
@@ -320,6 +324,44 @@ static int sst_acpi_remove(struct platform_device *pdev)
        return 0;
 }
 
+static unsigned long cht_machine_id;
+
+#define CHT_SURFACE_MACH 1
+
+static int cht_surface_quirk_cb(const struct dmi_system_id *id)
+{
+       cht_machine_id = CHT_SURFACE_MACH;
+       return 1;
+}
+
+
+static const struct dmi_system_id cht_table[] = {
+       {
+               .callback = cht_surface_quirk_cb,
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
+               },
+       },
+};
+
+
+static struct sst_acpi_mach cht_surface_mach = {
+       "10EC5640", "cht-bsw-rt5645", "intel/fw_sst_22a8.bin", "cht-bsw", NULL,
+                                                               &chv_platform_data };
+
+struct sst_acpi_mach *cht_quirk(void *arg)
+{
+       struct sst_acpi_mach *mach = arg;
+
+       dmi_check_system(cht_table);
+
+       if (cht_machine_id == CHT_SURFACE_MACH)
+               return &cht_surface_mach;
+       else
+               return mach;
+}
+
 static struct sst_acpi_mach sst_acpi_bytcr[] = {
        {"10EC5640", "bytcr_rt5640", "intel/fw_sst_0f28.bin", "bytcr_rt5640", NULL,
                                                &byt_rvp_platform_data },
@@ -343,7 +385,7 @@ static struct sst_acpi_mach sst_acpi_chv[] = {
        {"193C9890", "cht-bsw-max98090", "intel/fw_sst_22a8.bin", "cht-bsw", NULL,
                                                &chv_platform_data },
        /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
-       {"10EC5640", "bytcr_rt5640", "intel/fw_sst_22a8.bin", "bytcr_rt5640", NULL,
+       {"10EC5640", "bytcr_rt5640", "intel/fw_sst_22a8.bin", "bytcr_rt5640", cht_quirk,
                                                &chv_platform_data },
 
        {},
index b02f12900b93e64633a8617877d2dccb8b924598..5d2949324d0ee68969b8102a2eb8da22b65813da 100644 (file)
@@ -40,6 +40,6 @@ struct sst_acpi_mach {
 
        /* board name */
        const char *board;
-       void (*machine_quirk)(void);
+       struct sst_acpi_mach * (*machine_quirk)(void *arg);
        void *pdata;
 };