From nobody Sun Sep 22 07:30:51 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF721C433F5 for ; Thu, 24 Mar 2022 05:39:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347969AbiCXFkm (ORCPT ); Thu, 24 Mar 2022 01:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347797AbiCXFke (ORCPT ); Thu, 24 Mar 2022 01:40:34 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F66913F43; Wed, 23 Mar 2022 22:39:00 -0700 (PDT) X-UUID: 0c9a1f0a47ed4871a21ebd87654b227e-20220324 X-UUID: 0c9a1f0a47ed4871a21ebd87654b227e-20220324 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 961910677; Thu, 24 Mar 2022 13:38:57 +0800 Received: from mtkexhb02.mediatek.inc (172.21.101.103) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 24 Mar 2022 13:38:57 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkexhb02.mediatek.inc (172.21.101.103) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 24 Mar 2022 13:38:56 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 24 Mar 2022 13:38:56 +0800 From: Trevor Wu To: , , , CC: , , , , , , , , , , Subject: [PATCH v4 5/6] ASoC: mediatek: mt8195: add machine support for max98390 and rt5682 Date: Thu, 24 Mar 2022 13:38:50 +0800 Message-ID: <20220324053851.27350-6-trevor.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220324053851.27350-1-trevor.wu@mediatek.com> References: <20220324053851.27350-1-trevor.wu@mediatek.com> MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds support for mt8195 board with mt6359, max98390 and rt5682. Signed-off-by: Trevor Wu Reviewed-by: AngeloGioacchino Del Regno --- sound/soc/mediatek/Kconfig | 1 + sound/soc/mediatek/mt8195/mt8195-mt6359.c | 71 +++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig index bb641dd99681..ae838bbc7933 100644 --- a/sound/soc/mediatek/Kconfig +++ b/sound/soc/mediatek/Kconfig @@ -207,6 +207,7 @@ config SND_SOC_MT8195_MT6359 select SND_SOC_RT1015P select SND_SOC_RT5682_I2C select SND_SOC_RT5682S + select SND_SOC_MAX98390 select SND_SOC_DMIC select SND_SOC_HDMI_CODEC help diff --git a/sound/soc/mediatek/mt8195/mt8195-mt6359.c b/sound/soc/mediatek= /mt8195/mt8195-mt6359.c index e45bd5d38cda..bc8c30b33969 100644 --- a/sound/soc/mediatek/mt8195/mt8195-mt6359.c +++ b/sound/soc/mediatek/mt8195/mt8195-mt6359.c @@ -25,6 +25,7 @@ =20 #define RT1011_SPEAKER_AMP_PRESENT BIT(0) #define RT1019_SPEAKER_AMP_PRESENT BIT(1) +#define MAX98390_SPEAKER_AMP_PRESENT BIT(2) =20 #define RT1011_CODEC_DAI "rt1011-aif" #define RT1011_DEV0_NAME "rt1011.2-0038" @@ -33,6 +34,10 @@ #define RT1019_CODEC_DAI "HiFi" #define RT1019_DEV0_NAME "rt1019p" =20 +#define MAX98390_CODEC_DAI "max98390-aif1" +#define MAX98390_DEV0_NAME "max98390.2-0038" /* right */ +#define MAX98390_DEV1_NAME "max98390.2-0039" /* left */ + #define RT5682_CODEC_DAI "rt5682-aif1" #define RT5682_DEV0_NAME "rt5682.2-001a" =20 @@ -121,6 +126,11 @@ static const struct snd_soc_dapm_route mt8195_rt1019_r= outes[] =3D { { "Ext Spk", NULL, "Speaker" }, }; =20 +static const struct snd_soc_dapm_route mt8195_max98390_routes[] =3D { + { "Left Spk", NULL, "Left BE_OUT" }, + { "Right Spk", NULL, "Right BE_OUT" }, +}; + #define CKSYS_AUD_TOP_CFG 0x032c #define CKSYS_AUD_TOP_MON 0x0330 =20 @@ -668,6 +678,34 @@ static int mt8195_rt1019_init(struct snd_soc_pcm_runti= me *rtd) return ret; } =20 +static int mt8195_max98390_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_card *card =3D rtd->card; + int ret; + + ret =3D snd_soc_dapm_new_controls(&card->dapm, mt8195_dual_speaker_widget= s, + ARRAY_SIZE(mt8195_dual_speaker_widgets)); + if (ret) { + dev_err(rtd->dev, "unable to add dapm controls, ret %d\n", ret); + /* Don't need to add routes if widget addition failed */ + return ret; + } + + ret =3D snd_soc_add_card_controls(card, mt8195_dual_speaker_controls, + ARRAY_SIZE(mt8195_dual_speaker_controls)); + if (ret) { + dev_err(rtd->dev, "unable to add card controls, ret %d\n", ret); + return ret; + } + + ret =3D snd_soc_dapm_add_routes(&card->dapm, mt8195_max98390_routes, + ARRAY_SIZE(mt8195_max98390_routes)); + if (ret) + dev_err(rtd->dev, "unable to add dapm routes, ret %d\n", ret); + + return ret; +} + static int mt8195_etdm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -926,6 +964,12 @@ SND_SOC_DAILINK_DEF(rt1011_comps, COMP_CODEC(RT1011_DEV1_NAME, RT1011_CODEC_DAI))); =20 +SND_SOC_DAILINK_DEF(max98390_comps, + DAILINK_COMP_ARRAY(COMP_CODEC(MAX98390_DEV0_NAME, + MAX98390_CODEC_DAI), + COMP_CODEC(MAX98390_DEV1_NAME, + MAX98390_CODEC_DAI))); + static const struct sof_conn_stream g_sof_conn_streams[] =3D { { "ETDM2_OUT_BE", "AFE_SOF_DL2", SOF_DMA_DL2, SNDRV_PCM_STREAM_PLAYBACK}, { "ETDM1_OUT_BE", "AFE_SOF_DL3", SOF_DMA_DL3, SNDRV_PCM_STREAM_PLAYBACK}, @@ -1249,6 +1293,17 @@ static struct snd_soc_codec_conf rt1011_codec_conf[]= =3D { }, }; =20 +static struct snd_soc_codec_conf max98390_codec_conf[] =3D { + { + .dlc =3D COMP_CODEC_CONF(MAX98390_DEV0_NAME), + .name_prefix =3D "Right", + }, + { + .dlc =3D COMP_CODEC_CONF(MAX98390_DEV1_NAME), + .name_prefix =3D "Left", + }, +}; + static struct snd_soc_card mt8195_mt6359_soc_card =3D { .owner =3D THIS_MODULE, .dai_link =3D mt8195_mt6359_dai_links, @@ -1544,6 +1599,13 @@ static int mt8195_mt6359_dev_probe(struct platform_d= evice *pdev) dai_link->num_codecs =3D ARRAY_SIZE(rt1019_comps); dai_link->init =3D mt8195_rt1019_init; break; + case MAX98390_SPEAKER_AMP_PRESENT: + dai_link->codecs =3D max98390_comps; + dai_link->num_codecs =3D ARRAY_SIZE(max98390_comps); + dai_link->init =3D mt8195_max98390_init; + card->codec_conf =3D max98390_codec_conf; + card->num_configs =3D ARRAY_SIZE(max98390_codec_conf); + break; default: break; } @@ -1574,6 +1636,11 @@ static struct mt8195_card_data mt8195_mt6359_rt1011_= rt5682_card =3D { .quirk =3D RT1011_SPEAKER_AMP_PRESENT, }; =20 +static struct mt8195_card_data mt8195_mt6359_max98390_rt5682_card =3D { + .name =3D "mt8195_m98390_r5682", + .quirk =3D MAX98390_SPEAKER_AMP_PRESENT, +}; + #ifdef CONFIG_OF static const struct of_device_id mt8195_mt6359_dt_match[] =3D { { @@ -1584,6 +1651,10 @@ static const struct of_device_id mt8195_mt6359_dt_ma= tch[] =3D { .compatible =3D "mediatek,mt8195_mt6359_rt1011_rt5682", .data =3D &mt8195_mt6359_rt1011_rt5682_card, }, + { + .compatible =3D "mediatek,mt8195_mt6359_max98390_rt5682", + .data =3D &mt8195_mt6359_max98390_rt5682_card, + }, }; #endif =20 --=20 2.18.0