Commit 3f32e596 authored by Yong Zhi's avatar Yong Zhi Committed by Mark Brown

ASoC: Intel: sof_da7219_max98373: Add support for max98360a speaker amp

Add Maxim MAX98360A plug-and-play Class-D amplifier support on SSP1,
new card ID is sofda7219max98360a, name sof-da7219max98360a.
Signed-off-by: default avatarYong Zhi <yong.zhi@intel.com>
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200312194859.4051-9-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 42432196
...@@ -507,7 +507,7 @@ endif ## SND_SOC_SOF_COMETLAKE_LP && SND_SOC_SOF_HDA_LINK ...@@ -507,7 +507,7 @@ endif ## SND_SOC_SOF_COMETLAKE_LP && SND_SOC_SOF_HDA_LINK
if SND_SOC_SOF_JASPERLAKE if SND_SOC_SOF_JASPERLAKE
config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH
tristate "SOF with DA7219 and MAX98373 in I2S Mode" tristate "SOF with DA7219 and MAX98373/MAX98360A in I2S Mode"
depends on I2C && ACPI depends on I2C && ACPI
depends on MFD_INTEL_LPSS || COMPILE_TEST depends on MFD_INTEL_LPSS || COMPILE_TEST
depends on SND_HDA_CODEC_HDMI depends on SND_HDA_CODEC_HDMI
...@@ -516,7 +516,7 @@ config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH ...@@ -516,7 +516,7 @@ config SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH
select SND_SOC_DMIC select SND_SOC_DMIC
help help
This adds support for ASoC machine driver for SOF platforms This adds support for ASoC machine driver for SOF platforms
with DA7219 + MAX98373 I2S audio codec. with DA7219 + MAX98373/MAX98360A I2S audio codec.
Say Y if you have such a device. Say Y if you have such a device.
If unsure select "N". If unsure select "N".
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Copyright(c) 2019 Intel Corporation. // Copyright(c) 2019 Intel Corporation.
/* /*
* Intel SOF Machine driver for DA7219 + MAX98373 codec * Intel SOF Machine driver for DA7219 + MAX98373/MAX98360A codec
*/ */
#include <linux/input.h> #include <linux/input.h>
...@@ -69,11 +69,14 @@ static const struct snd_kcontrol_new controls[] = { ...@@ -69,11 +69,14 @@ static const struct snd_kcontrol_new controls[] = {
SOC_DAPM_PIN_SWITCH("Right Spk"), SOC_DAPM_PIN_SWITCH("Right Spk"),
}; };
static const struct snd_kcontrol_new m98360a_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Headset Mic"),
};
static const struct snd_soc_dapm_widget widgets[] = { static const struct snd_soc_dapm_widget widgets[] = {
SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_HP("Headphone Jack", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
platform_clock_control, SND_SOC_DAPM_POST_PMD | platform_clock_control, SND_SOC_DAPM_POST_PMD |
SND_SOC_DAPM_PRE_PMU), SND_SOC_DAPM_PRE_PMU),
...@@ -83,15 +86,23 @@ static const struct snd_soc_dapm_route audio_map[] = { ...@@ -83,15 +86,23 @@ static const struct snd_soc_dapm_route audio_map[] = {
{ "Headphone Jack", NULL, "HPL" }, { "Headphone Jack", NULL, "HPL" },
{ "Headphone Jack", NULL, "HPR" }, { "Headphone Jack", NULL, "HPR" },
{ "Left Spk", NULL, "Left BE_OUT" },
{ "Right Spk", NULL, "Right BE_OUT" },
{ "MIC", NULL, "Headset Mic" }, { "MIC", NULL, "Headset Mic" },
{ "Headphone Jack", NULL, "Platform Clock" }, { "Headphone Jack", NULL, "Platform Clock" },
{ "Headset Mic", NULL, "Platform Clock" }, { "Headset Mic", NULL, "Platform Clock" },
}; };
/* For MAX98373 amp */
static const struct snd_soc_dapm_widget max98373_widgets[] = {
SND_SOC_DAPM_SPK("Left Spk", NULL),
SND_SOC_DAPM_SPK("Right Spk", NULL),
};
static const struct snd_soc_dapm_route max98373_map[] = {
{ "Left Spk", NULL, "Left BE_OUT" },
{ "Right Spk", NULL, "Right BE_OUT" },
};
static struct snd_soc_jack headset; static struct snd_soc_jack headset;
static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
...@@ -133,6 +144,21 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd) ...@@ -133,6 +144,21 @@ static int da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
static int speaker_amp_init(struct snd_soc_pcm_runtime *rtd)
{
int ret;
/* Add widgets */
ret = snd_soc_dapm_new_controls(&rtd->card->dapm, max98373_widgets,
ARRAY_SIZE(max98373_widgets));
if (ret)
return ret;
/* Add routes */
return snd_soc_dapm_add_routes(&rtd->card->dapm, max98373_map,
ARRAY_SIZE(max98373_map));
}
static int ssp1_hw_params(struct snd_pcm_substream *substream, static int ssp1_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
...@@ -223,6 +249,8 @@ SND_SOC_DAILINK_DEF(ssp1_amps, ...@@ -223,6 +249,8 @@ SND_SOC_DAILINK_DEF(ssp1_amps,
DAILINK_COMP_ARRAY( DAILINK_COMP_ARRAY(
/* Left */ COMP_CODEC(MAXIM_DEV0_NAME, MAX98373_CODEC_DAI), /* Left */ COMP_CODEC(MAXIM_DEV0_NAME, MAX98373_CODEC_DAI),
/* Right */ COMP_CODEC(MAXIM_DEV1_NAME, MAX98373_CODEC_DAI))); /* Right */ COMP_CODEC(MAXIM_DEV1_NAME, MAX98373_CODEC_DAI)));
/* For the driver-less spk amp */
SND_SOC_DAILINK_DEF(dummy, DAILINK_COMP_ARRAY(COMP_DUMMY()));
SND_SOC_DAILINK_DEF(dmic_pin, SND_SOC_DAILINK_DEF(dmic_pin,
DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin"))); DAILINK_COMP_ARRAY(COMP_CPU("DMIC01 Pin")));
...@@ -254,6 +282,7 @@ static struct snd_soc_dai_link dais[] = { ...@@ -254,6 +282,7 @@ static struct snd_soc_dai_link dais[] = {
.id = 0, .id = 0,
.ignore_pmdown_time = 1, .ignore_pmdown_time = 1,
.no_pcm = 1, .no_pcm = 1,
.init = speaker_amp_init,
.dpcm_playback = 1, .dpcm_playback = 1,
.dpcm_capture = 1, /* IV feedback */ .dpcm_capture = 1, /* IV feedback */
.ops = &ssp1_ops, .ops = &ssp1_ops,
...@@ -320,6 +349,21 @@ static struct snd_soc_card card_da7219_m98373 = { ...@@ -320,6 +349,21 @@ static struct snd_soc_card card_da7219_m98373 = {
.late_probe = card_late_probe, .late_probe = card_late_probe,
}; };
static struct snd_soc_card card_da7219_m98360a = {
.name = "da7219max98360a",
.owner = THIS_MODULE,
.dai_link = dais,
.num_links = ARRAY_SIZE(dais),
.controls = m98360a_controls,
.num_controls = ARRAY_SIZE(m98360a_controls),
.dapm_widgets = widgets,
.num_dapm_widgets = ARRAY_SIZE(widgets),
.dapm_routes = audio_map,
.num_dapm_routes = ARRAY_SIZE(audio_map),
.fully_routed = true,
.late_probe = card_late_probe,
};
static int audio_probe(struct platform_device *pdev) static int audio_probe(struct platform_device *pdev)
{ {
static struct snd_soc_card *card; static struct snd_soc_card *card;
...@@ -331,6 +375,17 @@ static int audio_probe(struct platform_device *pdev) ...@@ -331,6 +375,17 @@ static int audio_probe(struct platform_device *pdev)
if (!ctx) if (!ctx)
return -ENOMEM; return -ENOMEM;
/* By default dais[0] is configured for max98373 */
if (!strcmp(pdev->name, "sof_da7219_max98360a")) {
dais[0] = (struct snd_soc_dai_link) {
.name = "SSP1-Codec",
.id = 0,
.no_pcm = 1,
.dpcm_playback = 1,
.ignore_pmdown_time = 1,
SND_SOC_DAILINK_REG(ssp1_pin, dummy, platform) };
}
INIT_LIST_HEAD(&ctx->hdmi_pcm_list); INIT_LIST_HEAD(&ctx->hdmi_pcm_list);
card = (struct snd_soc_card *)pdev->id_entry->driver_data; card = (struct snd_soc_card *)pdev->id_entry->driver_data;
card->dev = &pdev->dev; card->dev = &pdev->dev;
...@@ -351,13 +406,17 @@ static const struct platform_device_id board_ids[] = { ...@@ -351,13 +406,17 @@ static const struct platform_device_id board_ids[] = {
.name = "sof_da7219_max98373", .name = "sof_da7219_max98373",
.driver_data = (kernel_ulong_t)&card_da7219_m98373, .driver_data = (kernel_ulong_t)&card_da7219_m98373,
}, },
{
.name = "sof_da7219_max98360a",
.driver_data = (kernel_ulong_t)&card_da7219_m98360a,
},
{ } { }
}; };
static struct platform_driver audio = { static struct platform_driver audio = {
.probe = audio_probe, .probe = audio_probe,
.driver = { .driver = {
.name = "sof_da7219_max98373", .name = "sof_da7219_max98_360a_373",
.pm = &snd_soc_pm_ops, .pm = &snd_soc_pm_ops,
}, },
.id_table = board_ids, .id_table = board_ids,
...@@ -368,4 +427,5 @@ module_platform_driver(audio) ...@@ -368,4 +427,5 @@ module_platform_driver(audio)
MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver"); MODULE_DESCRIPTION("ASoC Intel(R) SOF Machine driver");
MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>"); MODULE_AUTHOR("Yong Zhi <yong.zhi@intel.com>");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:sof_da7219_max98360a");
MODULE_ALIAS("platform:sof_da7219_max98373"); MODULE_ALIAS("platform:sof_da7219_max98373");
...@@ -9,13 +9,30 @@ ...@@ -9,13 +9,30 @@
#include <sound/soc-acpi.h> #include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h> #include <sound/soc-acpi-intel-match.h>
static struct snd_soc_acpi_codecs jsl_7219_98373_codecs = {
.num_codecs = 1,
.codecs = {"MX98373"}
};
/*
* When adding new entry to the snd_soc_acpi_intel_jsl_machines array,
* use .quirk_data member to distinguish different machine driver,
* and keep ACPI .id field unchanged for the common codec.
*/
struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = {
{ {
.id = "DLGS7219", .id = "DLGS7219",
.drv_name = "sof_da7219_max98373", .drv_name = "sof_da7219_max98373",
.machine_quirk = snd_soc_acpi_codec_list,
.sof_fw_filename = "sof-jsl.ri", .sof_fw_filename = "sof-jsl.ri",
.sof_tplg_filename = "sof-jsl-da7219.tplg", .sof_tplg_filename = "sof-jsl-da7219.tplg",
.machine_quirk = snd_soc_acpi_codec_list,
.quirk_data = &jsl_7219_98373_codecs,
},
{
.id = "DLGS7219",
.drv_name = "sof_da7219_max98360a",
.sof_fw_filename = "sof-jsl.ri",
.sof_tplg_filename = "sof-jsl-da7219-mx98360a.tplg",
}, },
{}, {},
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment