Skip to content
Permalink
Browse files
ASoC: Intel: tgl: add tgl-rt1308 machine driver
backported patches from 5.4/yocto
  b86ce76 ASoC: TGL- update machine driver rt1308
  fec3e3d ASoC: Intel: tgl: add tgl-rt1308 machine driver

We don't support HDAC_HDMI with new mach drivers,
so It was recommended dropping it here.
  • Loading branch information
reddymur authored and ranjan-dutta committed Oct 25, 2021
1 parent f09aa53 commit 877fd5abd34ac2b6abb205f0e8fd194924dec359
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 4 deletions.
@@ -468,6 +468,23 @@ config SND_SOC_INTEL_SOF_PCM512x_MACH

endif ## SND_SOC_SOF_HDA_LINK || SND_SOC_SOF_BAYTRAIL

if SND_SOC_SOF_TIGERLAKE

config SND_SOC_INTEL_TGL_RT1308_MACH
tristate "TGL with RT1308 in I2S Mode"
depends on I2C && ACPI
depends on MFD_INTEL_LPSS || COMPILE_TEST
select SND_SOC_RT1308
select SND_SOC_DMIC
depends on SND_HDA_CODEC_HDMI && SND_SOC_SOF_HDA_AUDIO_CODEC
help
This adds support for ASoC machine driver for Tigerlake platforms
with RT1308 I2S audio codec.
Say Y if you have such a device.
If unsure select "N".

endif ## SND_SOC_SOF_TIGERLAKE

if (SND_SOC_SOF_COMETLAKE && SND_SOC_SOF_HDA_LINK)

config SND_SOC_INTEL_CML_LP_DA7219_MAX98357A_MACH
@@ -39,6 +39,8 @@ snd-soc-sof-sdw-objs += sof_sdw.o \
sof_sdw_rt715.o sof_sdw_rt715_sdca.o \
sof_maxim_common.o \
sof_sdw_dmic.o sof_sdw_hdmi.o hda_dsp_common.o
snd-soc-tgl-rt1308-objs := tgl_rt1308.o

obj-$(CONFIG_SND_SOC_INTEL_SOF_RT5682_MACH) += snd-soc-sof_rt5682.o
obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o
obj-$(CONFIG_SND_SOC_INTEL_BXT_DA7219_MAX98357A_COMMON) += snd-soc-sst-bxt-da7219_max98357a.o
@@ -72,3 +74,4 @@ obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o
obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH) += snd-soc-sof_da7219_max98373.o
obj-$(CONFIG_SND_SOC_INTEL_EHL_RT5660_MACH) += snd-soc-ehl-rt5660.o
obj-$(CONFIG_SND_SOC_INTEL_SOUNDWIRE_SOF_MACH) += snd-soc-sof-sdw.o
obj-$(CONFIG_SND_SOC_INTEL_TGL_RT1308_MACH) += snd-soc-tgl-rt1308.o
@@ -0,0 +1,169 @@
// SPDX-License-Identifier: GPL-2.0
//
// Copyright(c) 2021 Intel Corporation. All rights reserved.

/*
* tgl_rt1308.c - ASoc Machine driver for Intel platforms
* with RT1308 codec.
*/

#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/platform_device.h>

#include <sound/core.h>
#include <sound/jack.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-acpi.h>

#include "../../codecs/rt1308.h"
#include "../../codecs/hdac_hdmi.h"

static int tgl_rt1308_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
int clk_id, clk_freq, pll_out;
int err;

clk_id = RT1308_PLL_S_MCLK;
clk_freq = 38400000;

pll_out = params_rate(params) * 512;

/* Set rt1308 pll */
err = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, pll_out);
if (err < 0) {
dev_err(card->dev, "Failed to set RT1308 PLL: %d\n", err);
return err;
}

/* Set rt1308 sysclk */
err = snd_soc_dai_set_sysclk(codec_dai, RT1308_FS_SYS_S_PLL, pll_out,
SND_SOC_CLOCK_IN);
if (err < 0) {
dev_err(card->dev, "Failed to set RT1308 SYSCLK: %d\n", err);
return err;
}

return 0;
}

/* machine stream operations */
static struct snd_soc_ops tgl_rt1308_ops = {
.hw_params = tgl_rt1308_hw_params,
};

static const struct snd_soc_dapm_widget tgl_rt1308_dapm_widgets[] = {
SND_SOC_DAPM_SPK("Speakers", NULL),
SND_SOC_DAPM_MIC("SoC DMIC", NULL),
};

static const struct snd_kcontrol_new tgl_rt1308_controls[] = {
SOC_DAPM_PIN_SWITCH("Speakers"),
};

static const struct snd_soc_dapm_route tgl_rt1308_dapm_routes[] = {
{ "Speakers", NULL, "SPOL" },
{ "Speakers", NULL, "SPOR" },

/* digital mics */
{"DMic", NULL, "SoC DMIC"},
};

SND_SOC_DAILINK_DEF(ssp2_pin,
DAILINK_COMP_ARRAY(COMP_CPU("SSP2 Pin")));

SND_SOC_DAILINK_DEF(ssp2_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC1308:00", "rt1308-aif")));

SND_SOC_DAILINK_DEF(platform,
DAILINK_COMP_ARRAY(COMP_PLATFORM("0000:00:1f.3")));

SND_SOC_DAILINK_DEF(dmic_pin,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
SND_SOC_DAILINK_DEF(dmic_codec,
DAILINK_COMP_ARRAY(COMP_CODEC("dmic-codec", "dmic-hifi")));
SND_SOC_DAILINK_DEF(dmic16k,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC16k Pin")));

static struct snd_soc_dai_link tgl_rt1308_dailink[] = {
{
.name = "SSP2-Codec",
.id = 0,
.no_pcm = 1,
.ops = &tgl_rt1308_ops,
.dpcm_playback = 1,
.nonatomic = true,
SND_SOC_DAILINK_REG(ssp2_pin, ssp2_codec, platform),
},
{
.name = "dmic01",
.id = 1,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic_pin, dmic_codec, platform),
},
{
.name = "dmic16k",
.id = 2,
.ignore_suspend = 1,
.dpcm_capture = 1,
.no_pcm = 1,
SND_SOC_DAILINK_REG(dmic16k, dmic_codec, platform),
},
};

/* audio machine driver */
static struct snd_soc_card tgl_rt1308_card = {
.name = "tgl_rt1308",
.owner = THIS_MODULE,
.dai_link = tgl_rt1308_dailink,
.num_links = ARRAY_SIZE(tgl_rt1308_dailink),
.controls = tgl_rt1308_controls,
.num_controls = ARRAY_SIZE(tgl_rt1308_controls),
.dapm_widgets = tgl_rt1308_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(tgl_rt1308_dapm_widgets),
.dapm_routes = tgl_rt1308_dapm_routes,
.num_dapm_routes = ARRAY_SIZE(tgl_rt1308_dapm_routes),
};

static int tgl_rt1308_probe(struct platform_device *pdev)
{
struct snd_soc_acpi_mach *mach;
struct snd_soc_card *card = &tgl_rt1308_card;
int ret;

card->dev = &pdev->dev;

mach = (&pdev->dev)->platform_data;

ret = snd_soc_fixup_dai_links_platform_name(card,
mach->mach_params.platform);
if (ret)
return ret;

snd_soc_card_set_drvdata(card, NULL);

return devm_snd_soc_register_card(&pdev->dev, card);
}

static struct platform_driver tgl_rt1308_driver = {
.driver = {
.name = "tgl_rt1308",
.pm = &snd_soc_pm_ops,
},
.probe = tgl_rt1308_probe,
};
module_platform_driver(tgl_rt1308_driver);

MODULE_AUTHOR("Xiuli Pan");
MODULE_DESCRIPTION("ASoC Intel(R) Tiger Lake + RT1308 Machine driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:tgl_rt1308");
@@ -313,11 +313,9 @@ static struct snd_soc_acpi_codecs tgl_max98373_amp = {
struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = {
{
.id = "10EC1308",
.drv_name = "sof_sdw",
.link_mask = 0x1, /* RT711 on SoundWire link0 */
.links = tgl_i2s_rt1308,
.drv_name = "tgl_rt1308",
.sof_fw_filename = "sof-tgl.ri",
.sof_tplg_filename = "sof-tgl-rt711-i2s-rt1308.tplg",
.sof_tplg_filename = "sof-tgl-rt1308.tplg",
},
{
.id = "10EC5682",

0 comments on commit 877fd5a

Please sign in to comment.