]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - sound/soc/intel/atom/sst/sst_acpi.c
ASoC: Intel: move all ACPI match tables to common module
[mirror_ubuntu-bionic-kernel.git] / sound / soc / intel / atom / sst / sst_acpi.c
index 0e928d54305dad366586c6d2ec56829e5bb75ed2..32d6e02e21049719feb32691ee0ded359b5a4572 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/interrupt.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <linux/miscdevice.h>
 #include <linux/platform_device.h>
 #include <linux/firmware.h>
 #include <linux/pm_runtime.h>
 #include <acpi/acpi_bus.h>
 #include <asm/cpu_device_id.h>
 #include <asm/iosf_mbi.h>
+#include <sound/soc-acpi.h>
+#include <sound/soc-acpi-intel-match.h>
 #include "../sst-mfld-platform.h"
 #include "../../common/sst-dsp.h"
-#include "../../common/sst-acpi.h"
 #include "sst.h"
 
 /* LPE viewpoint addresses */
@@ -239,19 +239,26 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)
        return 0;
 }
 
+static int is_byt(void)
+{
+       bool status = false;
+       static const struct x86_cpu_id cpu_ids[] = {
+               { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
+               {}
+       };
+       if (x86_match_cpu(cpu_ids))
+               status = true;
+       return status;
+}
 
 static int is_byt_cr(struct device *dev, bool *bytcr)
 {
        int status = 0;
 
        if (IS_ENABLED(CONFIG_IOSF_MBI)) {
-               static const struct x86_cpu_id cpu_ids[] = {
-                       { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */
-                       {}
-               };
                u32 bios_status;
 
-               if (!x86_match_cpu(cpu_ids) || !iosf_mbi_available()) {
+               if (!is_byt() || !iosf_mbi_available()) {
                        /* bail silently */
                        return status;
                }
@@ -285,7 +292,7 @@ static int sst_acpi_probe(struct platform_device *pdev)
        int ret = 0;
        struct intel_sst_drv *ctx;
        const struct acpi_device_id *id;
-       struct sst_acpi_mach *mach;
+       struct snd_soc_acpi_mach *mach;
        struct platform_device *mdev;
        struct platform_device *plat_dev;
        struct sst_platform_info *pdata;
@@ -297,13 +304,17 @@ static int sst_acpi_probe(struct platform_device *pdev)
                return -ENODEV;
        dev_dbg(dev, "for %s\n", id->id);
 
-       mach = (struct sst_acpi_mach *)id->driver_data;
-       mach = sst_acpi_find_machine(mach);
+       mach = (struct snd_soc_acpi_mach *)id->driver_data;
+       mach = snd_soc_acpi_find_machine(mach);
        if (mach == NULL) {
                dev_err(dev, "No matching machine driver found\n");
                return -ENODEV;
        }
 
+       if (is_byt())
+               mach->pdata = &byt_rvp_platform_data;
+       else
+               mach->pdata = &chv_platform_data;
        pdata = mach->pdata;
 
        ret = kstrtouint(id->id, 16, &dev_id);
@@ -381,286 +392,9 @@ static int sst_acpi_remove(struct platform_device *pdev)
        return 0;
 }
 
-static unsigned long cht_machine_id;
-
-#define CHT_SURFACE_MACH 1
-#define BYT_THINKPAD_10  2
-
-static int cht_surface_quirk_cb(const struct dmi_system_id *id)
-{
-       cht_machine_id = CHT_SURFACE_MACH;
-       return 1;
-}
-
-static int byt_thinkpad10_quirk_cb(const struct dmi_system_id *id)
-{
-       cht_machine_id = BYT_THINKPAD_10;
-       return 1;
-}
-
-
-static const struct dmi_system_id byt_table[] = {
-       {
-               .callback = byt_thinkpad10_quirk_cb,
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-                       DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 10"),
-               },
-       },
-       {
-               .callback = byt_thinkpad10_quirk_cb,
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-                       DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad Tablet B"),
-               },
-       },
-       {
-               .callback = byt_thinkpad10_quirk_cb,
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-                       DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Miix 2 10"),
-               },
-       },
-       { }
-};
-
-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 = {
-       .id = "10EC5640",
-       .drv_name = "cht-bsw-rt5645",
-       .fw_filename = "intel/fw_sst_22a8.bin",
-       .board = "cht-bsw",
-       .pdata = &chv_platform_data,
-};
-
-static struct sst_acpi_mach byt_thinkpad_10 = {
-       .id = "10EC5640",
-       .drv_name = "cht-bsw-rt5672",
-       .fw_filename = "intel/fw_sst_0f28.bin",
-       .board = "cht-bsw",
-       .pdata = &byt_rvp_platform_data,
-};
-
-static 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 *byt_quirk(void *arg)
-{
-       struct sst_acpi_mach *mach = arg;
-
-       dmi_check_system(byt_table);
-
-       if (cht_machine_id == BYT_THINKPAD_10)
-               return &byt_thinkpad_10;
-       else
-               return mach;
-}
-
-
-static struct sst_acpi_mach sst_acpi_bytcr[] = {
-       {
-               .id = "10EC5640",
-               .drv_name = "bytcr_rt5640",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcr_rt5640",
-               .machine_quirk = byt_quirk,
-               .pdata = &byt_rvp_platform_data,
-       },
-       {
-               .id = "10EC5642",
-               .drv_name = "bytcr_rt5640",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcr_rt5640",
-               .pdata = &byt_rvp_platform_data
-       },
-       {
-               .id = "INTCCFFD",
-               .drv_name = "bytcr_rt5640",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcr_rt5640",
-               .pdata = &byt_rvp_platform_data
-       },
-       {
-               .id = "10EC5651",
-               .drv_name = "bytcr_rt5651",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcr_rt5651",
-               .pdata = &byt_rvp_platform_data
-       },
-       {
-               .id = "DLGS7212",
-               .drv_name = "bytcht_da7213",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcht_da7213",
-               .pdata = &byt_rvp_platform_data
-       },
-       {
-               .id = "DLGS7213",
-               .drv_name = "bytcht_da7213",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcht_da7213",
-               .pdata = &byt_rvp_platform_data
-       },
-       /* some Baytrail platforms rely on RT5645, use CHT machine driver */
-       {
-               .id = "10EC5645",
-               .drv_name = "cht-bsw-rt5645",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "cht-bsw",
-               .pdata = &byt_rvp_platform_data
-       },
-       {
-               .id = "10EC5648",
-               .drv_name = "cht-bsw-rt5645",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "cht-bsw",
-               .pdata = &byt_rvp_platform_data
-       },
-#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
-       /*
-        * This is always last in the table so that it is selected only when
-        * enabled explicitly and there is no codec-related information in SSDT
-        */
-       {
-               .id = "80860F28",
-               .drv_name = "bytcht_nocodec",
-               .fw_filename = "intel/fw_sst_0f28.bin",
-               .board = "bytcht_nocodec",
-               .pdata = &byt_rvp_platform_data
-       },
-#endif
-       {},
-};
-
-/* Cherryview-based platforms: CherryTrail and Braswell */
-static struct sst_acpi_mach sst_acpi_chv[] = {
-       {
-               .id = "10EC5670",
-               .drv_name = "cht-bsw-rt5672",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "cht-bsw",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "10EC5672",
-               .drv_name = "cht-bsw-rt5672",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "cht-bsw",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "10EC5645",
-               .drv_name = "cht-bsw-rt5645",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "cht-bsw",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "10EC5650",
-               .drv_name = "cht-bsw-rt5645",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "cht-bsw",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "10EC3270",
-               .drv_name = "cht-bsw-rt5645",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "cht-bsw",
-               .pdata = &chv_platform_data
-       },
-
-       {
-               .id = "193C9890",
-               .drv_name = "cht-bsw-max98090",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "cht-bsw",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "DLGS7212",
-               .drv_name = "bytcht_da7213",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcht_da7213",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "DLGS7213",
-               .drv_name = "bytcht_da7213",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcht_da7213",
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "ESSX8316",
-               .drv_name = "bytcht_es8316",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcht_es8316",
-               .pdata = &chv_platform_data
-       },
-       /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
-       {
-               .id = "10EC5640",
-               .drv_name = "bytcr_rt5640",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcr_rt5640",
-               .machine_quirk = cht_quirk,
-               .pdata = &chv_platform_data
-       },
-       {
-               .id = "10EC3276",
-               .drv_name = "bytcr_rt5640",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcr_rt5640",
-               .pdata = &chv_platform_data
-       },
-       /* some CHT-T platforms rely on RT5651, use Baytrail machine driver */
-       {
-               .id = "10EC5651",
-               .drv_name = "bytcr_rt5651",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcr_rt5651",
-               .pdata = &chv_platform_data
-       },
-#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
-       /*
-        * This is always last in the table so that it is selected only when
-        * enabled explicitly and there is no codec-related information in SSDT
-        */
-       {
-               .id = "808622A8",
-               .drv_name = "bytcht_nocodec",
-               .fw_filename = "intel/fw_sst_22a8.bin",
-               .board = "bytcht_nocodec",
-               .pdata = &chv_platform_data
-       },
-#endif
-       {},
-};
-
 static const struct acpi_device_id sst_acpi_ids[] = {
-       { "80860F28", (unsigned long)&sst_acpi_bytcr},
-       { "808622A8", (unsigned long) &sst_acpi_chv},
+       { "80860F28", (unsigned long)&snd_soc_acpi_intel_baytrail_machines},
+       { "808622A8", (unsigned long)&snd_soc_acpi_intel_cherrytrail_machines},
        { },
 };