clear-pkgs-linux-iot-lts2018/0253-ASoC-Intel-Add-support...

571 lines
16 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Hardik Shah <hardik.t.shah@intel.com>
Date: Tue, 28 Jun 2016 15:48:56 +0530
Subject: [PATCH] ASoC:Intel: Add support for ALC700 machine driver
Change-Id: Idcec9e08faaedbb92f714548d9fea15af4de6b91
Signed-off-by: Hardik Shah <hardik.t.shah@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
sound/soc/intel/boards/Kconfig | 11 +
sound/soc/intel/boards/Makefile | 2 +
sound/soc/intel/boards/cnl_rt700.c | 319 +++++++++++++++++++++++++++++
sound/soc/intel/skylake/skl.c | 162 +++++++++++++++
4 files changed, 494 insertions(+)
create mode 100644 sound/soc/intel/boards/cnl_rt700.c
diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index ca140a77d992..e6b065fa1dff 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -306,6 +306,17 @@ config SND_SOC_INTEL_CNL_CS42L42_MACH
Say Y or m if you have such a device. This is a recommended option.
If unsure select "N".
+config SND_SOC_INTEL_CNL_RT700_MACH
+ tristate "Cannonlake with RT700 SDW mode"
+ depends on MFD_INTEL_LPSS && I2C && ACPI
+ select SND_SOC_RT700
+ select SND_SOC_DMIC
+ help
+ This adds support for ASoC RT700 codec SDW machine driver. This will
+ create an alsa sound card for RT700.
+ Say Y or m if you have such a device. This is a recommended option.
+ If unsure select "N".
+
config SND_SOC_INTEL_CNL_SVFPGA_MACH
tristate "Cannonlake with SVFPGA PDM SDW mode"
depends on MFD_INTEL_LPSS && I2C && ACPI
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile
index 4f2b9b38edd0..c5e0ff065610 100644
--- a/sound/soc/intel/boards/Makefile
+++ b/sound/soc/intel/boards/Makefile
@@ -23,6 +23,7 @@ snd-soc-skl_rt286-objs := skl_rt286.o
snd-skl_nau88l25_max98357a-objs := skl_nau88l25_max98357a.o
snd-soc-skl_nau88l25_ssm4567-objs := skl_nau88l25_ssm4567.o
snd-soc-cnl_cs42l42-objs := cnl_cs42l42.o
+snd-soc-cnl_rt700-objs := cnl_rt700.o
snd-soc-cnl_svfpga-objs := cnl_svfpga.o
obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o
@@ -49,4 +50,5 @@ obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o
obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH) += snd-skl_nau88l25_max98357a.o
obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH) += snd-soc-skl_nau88l25_ssm4567.o
obj-$(CONFIG_SND_SOC_INTEL_CNL_CS42L42_MACH) += snd-soc-cnl_cs42l42.o
+obj-$(CONFIG_SND_SOC_INTEL_CNL_RT700_MACH) += snd-soc-cnl_rt700.o
obj-$(CONFIG_SND_SOC_INTEL_CNL_SVFPGA_MACH) += snd-soc-cnl_svfpga.o
diff --git a/sound/soc/intel/boards/cnl_rt700.c b/sound/soc/intel/boards/cnl_rt700.c
new file mode 100644
index 000000000000..e0b93e571fb9
--- /dev/null
+++ b/sound/soc/intel/boards/cnl_rt700.c
@@ -0,0 +1,319 @@
+/*
+ * cnl_rt700.c - ASOC Machine driver for Intel cnl_rt700 platform
+ * with ALC700 SoundWire codec.
+ *
+ * Copyright (C) 2016 Intel Corp
+ * Author: Hardik Shah <hardik.t.shah@intel.com>
+ *
+ * Based on
+ * moor_dpcm_florida.c - ASOC Machine driver for Intel Moorefield platform
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include <linux/async.h>
+#include <linux/delay.h>
+#include <linux/gpio.h>
+#include <linux/acpi.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/jack.h>
+#include <linux/input.h>
+
+struct cnl_rt700_mc_private {
+ u8 pmic_id;
+ void __iomem *osc_clk0_reg;
+ int bt_mode;
+};
+
+static const struct snd_soc_dapm_widget cnl_rt700_widgets[] = {
+ SND_SOC_DAPM_HP("Headphones", NULL),
+ SND_SOC_DAPM_MIC("AMIC", NULL),
+ SND_SOC_DAPM_MIC("SoC DMIC", NULL),
+ SND_SOC_DAPM_SPK("Speaker", NULL),
+};
+
+static const struct snd_soc_dapm_route cnl_rt700_map[] = {
+ /*Headphones*/
+ { "Headphones", NULL, "HP" },
+ { "Speaker", NULL, "SPK" },
+ { "I2NP", NULL, "AMIC" },
+
+ /* SWM map link the SWM outs to codec AIF */
+ { "DP1 Playback", NULL, "SDW Tx"},
+ { "SDW Tx", NULL, "sdw_codec0_out"},
+ { "SDW Tx10", NULL, "sdw_codec1_out"},
+
+ { "sdw_codec0_in", NULL, "SDW Rx" },
+ { "SDW Rx", NULL, "DP2 Capture" },
+ {"sdw_codec2_in", NULL, "SDW Rx10"},
+ {"SDW Rx10", NULL, "DP4 Capture"},
+
+ {"DMic", NULL, "SoC DMIC"},
+ {"DMIC01 Rx", NULL, "Capture"},
+ {"dmic01_hifi", NULL, "DMIC01 Rx"},
+
+};
+
+static const struct snd_kcontrol_new cnl_rt700_controls[] = {
+ SOC_DAPM_PIN_SWITCH("Headphones"),
+ SOC_DAPM_PIN_SWITCH("AMIC"),
+ SOC_DAPM_PIN_SWITCH("Speaker"),
+};
+
+
+static int cnl_rt700_init(struct snd_soc_pcm_runtime *runtime)
+{
+ int ret;
+ struct snd_soc_card *card = runtime->card;
+
+ pr_info("Entry %s\n", __func__);
+ card->dapm.idle_bias_off = true;
+
+ ret = snd_soc_add_card_controls(card, cnl_rt700_controls,
+ ARRAY_SIZE(cnl_rt700_controls));
+ if (ret) {
+ pr_err("unable to add card controls\n");
+ return ret;
+ }
+ return 0;
+}
+
+static unsigned int rates_48000[] = {
+ 48000,
+ 16000,
+ 8000,
+};
+
+static struct snd_pcm_hw_constraint_list constraints_48000 = {
+ .count = ARRAY_SIZE(rates_48000),
+ .list = rates_48000,
+};
+
+static int cnl_rt700_startup(struct snd_pcm_substream *substream)
+{
+ return snd_pcm_hw_constraint_list(substream->runtime, 0,
+ SNDRV_PCM_HW_PARAM_RATE,
+ &constraints_48000);
+}
+
+static struct snd_soc_ops cnl_rt700_ops = {
+ .startup = cnl_rt700_startup,
+};
+
+static int cnl_rt700_codec_fixup(struct snd_soc_pcm_runtime *rtd,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_soc_dai *be_cpu_dai;
+ int slot_width = 24;
+ struct snd_interval *rate = hw_param_interval(params,
+ SNDRV_PCM_HW_PARAM_RATE);
+ struct snd_interval *channels = hw_param_interval(params,
+ SNDRV_PCM_HW_PARAM_CHANNELS);
+
+ pr_debug("Invoked %s for dailink %s\n", __func__, rtd->dai_link->name);
+ slot_width = 24;
+ rate->min = rate->max = 48000;
+ channels->min = channels->max = 2;
+ snd_mask_none(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT));
+ snd_mask_set(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT),
+ (unsigned int __force)SNDRV_PCM_FORMAT_S24_LE);
+
+ pr_info("param width set to:0x%x\n",
+ snd_pcm_format_width(params_format(params)));
+ pr_info("Slot width = %d\n", slot_width);
+
+ be_cpu_dai = rtd->cpu_dai;
+ return 0;
+}
+
+static int cnl_dmic_fixup(struct snd_soc_pcm_runtime *rtd,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_interval *channels = hw_param_interval(params,
+ SNDRV_PCM_HW_PARAM_CHANNELS);
+ channels->min = channels->max = 2;
+
+ return 0;
+}
+
+static struct snd_soc_dai_link cnl_rt700_msic_dailink[] = {
+ {
+ .name = "Bxtn Audio Port",
+ .stream_name = "Audio",
+ .cpu_dai_name = "System Pin",
+ .codec_name = "snd-soc-dummy",
+ .codec_dai_name = "snd-soc-dummy-dai",
+ .platform_name = "0000:02:18.0",
+ .init = cnl_rt700_init,
+ .ignore_suspend = 1,
+ .nonatomic = 1,
+ .dynamic = 1,
+ .dpcm_playback = 1,
+ .dpcm_capture = 1,
+ .ops = &cnl_rt700_ops,
+ },
+ {
+ .name = "CNL Reference Port",
+ .stream_name = "Reference Capture",
+ .cpu_dai_name = "Reference Pin",
+ .codec_name = "snd-soc-dummy",
+ .codec_dai_name = "snd-soc-dummy-dai",
+ .platform_name = "0000:02:18.0",
+ .ignore_suspend = 1,
+ .nonatomic = 1,
+ .dynamic = 1,
+ .dpcm_capture = 1,
+ .ops = &cnl_rt700_ops,
+ },
+ {
+ .name = "CNL Deepbuffer Port",
+ .stream_name = "Deep Buffer Audio",
+ .cpu_dai_name = "Deepbuffer Pin",
+ .codec_name = "snd-soc-dummy",
+ .codec_dai_name = "snd-soc-dummy-dai",
+ .platform_name = "0000:02:18.0",
+ .dpcm_playback = 1,
+ .ignore_suspend = 1,
+ .nonatomic = 1,
+ .dynamic = 1,
+ .ops = &cnl_rt700_ops,
+ },
+
+ {
+ .name = "SDW0-Codec",
+ .cpu_dai_name = "SDW Pin",
+ .platform_name = "0000:02:18.0",
+ .codec_name = "sdw-slave0-10:02:5d:07:01:00",
+ .codec_dai_name = "rt700-aif1",
+ .be_hw_params_fixup = cnl_rt700_codec_fixup,
+ .ignore_suspend = 1,
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .dpcm_capture = 1,
+ },
+ {
+ .name = "SDW1-Codec",
+ .cpu_dai_name = "SDW10 Pin",
+ .platform_name = "0000:02:18.0",
+ .codec_name = "sdw-slave0-10:02:5d:07:01:00",
+ .codec_dai_name = "rt700-aif2",
+ .be_hw_params_fixup = cnl_rt700_codec_fixup,
+ .ignore_suspend = 1,
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .dpcm_capture = 1,
+ },
+ {
+ .name = "dmic01",
+ .cpu_dai_name = "DMIC01 Pin",
+ .codec_name = "dmic-codec",
+ .codec_dai_name = "dmic-hifi",
+ .platform_name = "0000:02:18.0",
+ .ignore_suspend = 1,
+ .no_pcm = 1,
+ .dpcm_capture = 1,
+ .be_hw_params_fixup = cnl_dmic_fixup,
+ },
+};
+
+/* SoC card */
+static struct snd_soc_card snd_soc_card_cnl_rt700 = {
+ .name = "cnl_rt700-audio",
+ .dai_link = cnl_rt700_msic_dailink,
+ .num_links = ARRAY_SIZE(cnl_rt700_msic_dailink),
+ .dapm_widgets = cnl_rt700_widgets,
+ .num_dapm_widgets = ARRAY_SIZE(cnl_rt700_widgets),
+ .dapm_routes = cnl_rt700_map,
+ .num_dapm_routes = ARRAY_SIZE(cnl_rt700_map),
+};
+
+
+static int snd_cnl_rt700_mc_probe(struct platform_device *pdev)
+{
+ int ret_val = 0;
+ struct cnl_rt700_mc_private *drv;
+
+ pr_debug("Entry %s\n", __func__);
+
+ drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
+ if (!drv)
+ return -ENOMEM;
+
+ snd_soc_card_cnl_rt700.dev = &pdev->dev;
+ snd_soc_card_set_drvdata(&snd_soc_card_cnl_rt700, drv);
+ /* Register the card */
+ ret_val = snd_soc_register_card(&snd_soc_card_cnl_rt700);
+ if (ret_val && (ret_val != -EPROBE_DEFER)) {
+ pr_err("snd_soc_register_card failed %d\n", ret_val);
+ goto unalloc;
+ }
+ platform_set_drvdata(pdev, &snd_soc_card_cnl_rt700);
+ return ret_val;
+
+unalloc:
+ return ret_val;
+}
+
+static int snd_cnl_rt700_mc_remove(struct platform_device *pdev)
+{
+ struct snd_soc_card *soc_card = platform_get_drvdata(pdev);
+ struct cnl_rt700_mc_private *drv = snd_soc_card_get_drvdata(soc_card);
+
+ devm_kfree(&pdev->dev, drv);
+ snd_soc_card_set_drvdata(soc_card, NULL);
+ snd_soc_unregister_card(soc_card);
+ platform_set_drvdata(pdev, NULL);
+ return 0;
+}
+
+static const struct platform_device_id cnl_board_ids[] = {
+ { .name = "cnl_rt700" },
+ { .name = "icl_rt700" },
+ { }
+};
+
+static struct platform_driver snd_cnl_rt700_mc_driver = {
+ .driver = {
+ .name = "cnl_rt700",
+ },
+ .probe = snd_cnl_rt700_mc_probe,
+ .remove = snd_cnl_rt700_mc_remove,
+ .id_table = cnl_board_ids
+};
+
+static int snd_cnl_rt700_driver_init(void)
+{
+ return platform_driver_register(&snd_cnl_rt700_mc_driver);
+}
+module_init(snd_cnl_rt700_driver_init);
+
+static void snd_cnl_rt700_driver_exit(void)
+{
+ platform_driver_unregister(&snd_cnl_rt700_mc_driver);
+}
+module_exit(snd_cnl_rt700_driver_exit)
+
+MODULE_DESCRIPTION("ASoC CNL Machine driver");
+MODULE_AUTHOR("Hardik Shah <hardik.t.shah>");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:cnl_rt700");
+MODULE_ALIAS("platform:icl_rt700");
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index d1b2740cd0c3..b037b0d566c0 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -499,12 +499,17 @@ static int skl_find_machine(struct skl *skl, void *driver_data)
struct snd_soc_acpi_mach *mach = driver_data;
struct skl_machine_pdata *pdata;
+ if (IS_ENABLED(CONFIG_SND_SOC_RT700) ||
+ IS_ENABLED(CONFIG_SND_SOC_INTEL_CNL_FPGA))
+ goto out;
+
mach = snd_soc_acpi_find_machine(mach);
if (mach == NULL) {
dev_err(bus->dev, "No matching machine driver found\n");
return -ENODEV;
}
+out:
skl->mach = mach;
skl->fw_name = mach->fw_filename;
pdata = mach->pdata;
@@ -1053,6 +1058,163 @@ static void skl_remove(struct pci_dev *pci)
dev_set_drvdata(&pci->dev, NULL);
}
+static struct snd_soc_acpi_codecs skl_codecs = {
+ .num_codecs = 1,
+ .codecs = {"10508825"}
+};
+
+static struct snd_soc_acpi_codecs kbl_codecs = {
+ .num_codecs = 1,
+ .codecs = {"10508825"}
+};
+
+static struct snd_soc_acpi_codecs bxt_codecs = {
+ .num_codecs = 1,
+ .codecs = {"MX98357A"}
+};
+
+static struct snd_soc_acpi_codecs kbl_poppy_codecs = {
+ .num_codecs = 1,
+ .codecs = {"10EC5663"}
+};
+
+static struct snd_soc_acpi_codecs kbl_5663_5514_codecs = {
+ .num_codecs = 2,
+ .codecs = {"10EC5663", "10EC5514"}
+};
+
+static struct snd_soc_acpi_codecs kbl_7219_98357_codecs = {
+ .num_codecs = 1,
+ .codecs = {"MX98357A"}
+};
+
+static struct skl_machine_pdata cnl_pdata = {
+ .use_tplg_pcm = true,
+};
+
+static struct snd_soc_acpi_mach sst_skl_devdata[] = {
+ {
+ .id = "INT343A",
+ .drv_name = "skl_alc286s_i2s",
+ .fw_filename = "intel/dsp_fw_release.bin",
+ },
+ {
+ .id = "INT343B",
+ .drv_name = "skl_n88l25_s4567",
+ .fw_filename = "intel/dsp_fw_release.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &skl_codecs,
+ .pdata = &skl_dmic_data
+ },
+ {
+ .id = "MX98357A",
+ .drv_name = "skl_n88l25_m98357a",
+ .fw_filename = "intel/dsp_fw_release.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &skl_codecs,
+ .pdata = &skl_dmic_data
+ },
+ {}
+};
+
+static struct snd_soc_acpi_mach sst_bxtp_devdata[] = {
+ {
+ .id = "INT343A",
+ .drv_name = "bxt_alc298s_i2s",
+ .fw_filename = "intel/dsp_fw_bxtn.bin",
+ },
+ {
+ .id = "DLGS7219",
+ .drv_name = "bxt_da7219_max98357a_i2s",
+ .fw_filename = "intel/dsp_fw_bxtn.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &bxt_codecs,
+ },
+ {}
+};
+
+static struct snd_soc_acpi_mach sst_kbl_devdata[] = {
+ {
+ .id = "INT343A",
+ .drv_name = "kbl_alc286s_i2s",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ },
+ {
+ .id = "INT343B",
+ .drv_name = "kbl_n88l25_s4567",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &kbl_codecs,
+ .pdata = &skl_dmic_data
+ },
+ {
+ .id = "MX98357A",
+ .drv_name = "kbl_n88l25_m98357a",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &kbl_codecs,
+ .pdata = &skl_dmic_data
+ },
+ {
+ .id = "MX98927",
+ .drv_name = "kbl_r5514_5663_max",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &kbl_5663_5514_codecs,
+ .pdata = &skl_dmic_data
+ },
+ {
+ .id = "MX98927",
+ .drv_name = "kbl_rt5663_m98927",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &kbl_poppy_codecs,
+ .pdata = &skl_dmic_data
+ },
+ {
+ .id = "10EC5663",
+ .drv_name = "kbl_rt5663",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ },
+ {
+ .id = "DLGS7219",
+ .drv_name = "kbl_da7219_max98357a",
+ .fw_filename = "intel/dsp_fw_kbl.bin",
+ .machine_quirk = snd_soc_acpi_codec_list,
+ .quirk_data = &kbl_7219_98357_codecs,
+ .pdata = &skl_dmic_data
+ },
+
+ {}
+};
+
+static struct snd_soc_acpi_mach sst_glk_devdata[] = {
+ {
+ .id = "INT343A",
+ .drv_name = "glk_alc298s_i2s",
+ .fw_filename = "intel/dsp_fw_glk.bin",
+ },
+ {}
+};
+
+static const struct snd_soc_acpi_mach sst_cnl_devdata[] = {
+#if !IS_ENABLED(CONFIG_SND_SOC_RT700)
+ {
+ .id = "INT34C2",
+ .drv_name = "cnl_rt274",
+ .fw_filename = "intel/dsp_fw_cnl.bin",
+ .pdata = &cnl_pdata,
+ },
+#else
+ {
+ .drv_name = "cnl_rt700",
+ .fw_filename = "intel/dsp_fw_cnl.bin",
+ .pdata = &cnl_pdata,
+ },
+#endif
+ {}
+};
+
/* PCI IDs */
static const struct pci_device_id skl_ids[] = {
/* Sunrise Point-LP */
--
https://clearlinux.org