From nobody Wed Nov 27 14:36:35 2024 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6B41169397; Wed, 9 Oct 2024 08:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=92.121.34.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728461416; cv=none; b=RlQ0okohnXy9C3NVlxv6u9hWMGiNEaHt7z2Lhs267Xo3egWsh/x+PKoSKTwY2Sy8VBrz0aEiq7K7vFnwk4ZtRuRv9NP4nebw06FndUWqyebBVzlmsPytuXOGexEGTfSFgTygCTZJH5b7d2eoSY483VAo9A9Jtw67P42RCPm0yFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728461416; c=relaxed/simple; bh=B0M9xs1LqzT8oCRHj3FSkWt6xZSJRwnB2NPO0CekjJ4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=d6u7sFAtxB7izVDwXESeSWHaV1zF8mkqhwOADeVTSZyYRnX1vcSucM4ibcsocLTtd1dtaKklrzjlaIg01GpCQvNRb/hKq5IuXi/CurfM789BsLaRJV1hvPNSPFInl2kqq+zmILkBVVW2ZhFS/4HDHKVVT1L4+0+AVX3XKwi18xc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; arc=none smtp.client-ip=92.121.34.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2BBAD1A27D8; Wed, 9 Oct 2024 10:10:07 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id E7AC31A1D73; Wed, 9 Oct 2024 10:10:06 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 38FFD183F0C7; Wed, 9 Oct 2024 16:10:05 +0800 (+08) From: Shengjiu Wang To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, chancel.liu@nxp.com Subject: [PATCH 1/2] ASoC: imx-card: Set mclk for codec Date: Wed, 9 Oct 2024 15:46:43 +0800 Message-Id: <1728460004-364-2-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1728460004-364-1-git-send-email-shengjiu.wang@nxp.com> References: <1728460004-364-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Chancel Liu In some cases, ASoC machine driver may modify the mclk frequency according to sample rate but the value in codec is still initial frequency which should be replaced. For example, we should update mclk before setup for cs42xx8 mclk relating registers. Signed-off-by: Chancel Liu Signed-off-by: Shengjiu Wang Reviewed-by: Iuliana Prodan --- sound/soc/fsl/imx-card.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c index a7215bad6484..2f3dbbd15791 100644 --- a/sound/soc/fsl/imx-card.c +++ b/sound/soc/fsl/imx-card.c @@ -370,6 +370,11 @@ static int imx_aif_hw_params(struct snd_pcm_substream = *substream, dev_err(dev, "failed to set cpui dai mclk1 rate (%lu): %d\n", mclk_freq,= ret); return ret; } + ret =3D snd_soc_dai_set_sysclk(codec_dai, 0, mclk_freq, SND_SOC_CLOCK_IN); + if (ret && ret !=3D -ENOTSUPP) { + dev_err(dev, "failed to set codec dai mclk rate (%lu): %d\n", mclk_freq,= ret); + return ret; + } =20 return 0; } --=20 2.34.1 From nobody Wed Nov 27 14:36:35 2024 Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61542187FEA; Wed, 9 Oct 2024 08:10:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=92.121.34.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728461417; cv=none; b=gkipsDNp7qeZyoNXljfz1VJN0yJsmDT5v1scHTMsdOvdBAW0taqmIGcPw+3ZbVkuu/s+0Bv1N074Mqlu1/rBOEWjCuq8Su7zhWC8RYiD21wjaK/biGWYfrdYUB3oNPJOLuYfYE4Wq9Rr0Gu9WORb4PkzTIZed/k/t4wasDlC/bc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728461417; c=relaxed/simple; bh=tFE5nv9zTJEDkzyKc8O9At/Af8djsSGyqcmqplt/6pI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References; b=nmfp3Z/9SxTxttWonXez5nmIIs/jJ+06NN4zrbneFCqt2eGp8aR5XCTwCb7PXybp8t7gkr2uw2Aad4n9S9sjse30MPfSx9OlQVK0titbvlCD7SIJ8BoGzIZe5ZXWKTfxaf44nCeVFbFPvqRjXz2RrFGFjugTa2l28UbamaIOS5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; arc=none smtp.client-ip=92.121.34.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 124A41A27F8; Wed, 9 Oct 2024 10:10:08 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id CEA541A223E; Wed, 9 Oct 2024 10:10:07 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 71A87183F0C0; Wed, 9 Oct 2024 16:10:06 +0800 (+08) From: Shengjiu Wang To: shengjiu.wang@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, chancel.liu@nxp.com Subject: [PATCH 2/2] ASoC: imx-card: Add CS42888 support Date: Wed, 9 Oct 2024 15:46:44 +0800 Message-Id: <1728460004-364-3-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1728460004-364-1-git-send-email-shengjiu.wang@nxp.com> References: <1728460004-364-1-git-send-email-shengjiu.wang@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Chancel Liu CS42888 codec provides 4 multi-bit ADC and 8 multi-bit DAC. Add support for this codec in imx-card ASoC machine driver. Signed-off-by: Chancel Liu Signed-off-by: Shengjiu Wang Reviewed-by: Iuliana Prodan --- sound/soc/fsl/imx-card.c | 54 ++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c index 2f3dbbd15791..306168b164d3 100644 --- a/sound/soc/fsl/imx-card.c +++ b/sound/soc/fsl/imx-card.c @@ -25,6 +25,7 @@ enum codec_type { CODEC_AK4458, CODEC_AK4497, CODEC_AK5552, + CODEC_CS42888, }; =20 /* @@ -185,6 +186,16 @@ static struct imx_akcodec_tdm_fs_mul ak5558_tdm_fs_mul= [] =3D { { .min =3D 512, .max =3D 512, .mul =3D 1024 }, }; =20 +static struct imx_akcodec_fs_mul cs42888_fs_mul[] =3D { + { .rmin =3D 8000, .rmax =3D 48000, .wmin =3D 256, .wmax =3D 1024, }, + { .rmin =3D 64000, .rmax =3D 96000, .wmin =3D 128, .wmax =3D 512, }, + { .rmin =3D 176400, .rmax =3D 192000, .wmin =3D 64, .wmax =3D 256, }, +}; + +static struct imx_akcodec_tdm_fs_mul cs42888_tdm_fs_mul[] =3D { + { .min =3D 256, .max =3D 256, .mul =3D 256 }, +}; + static const u32 akcodec_rates[] =3D { 8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000, 705600, 768000, @@ -210,6 +221,14 @@ static const u32 ak5558_tdm_channels[] =3D { 1, 2, 3, 4, 5, 6, 7, 8, }; =20 +static const u32 cs42888_channels[] =3D { + 1, 2, 4, 6, 8, +}; + +static const u32 cs42888_tdm_channels[] =3D { + 1, 2, 3, 4, 5, 6, 7, 8, +}; + static bool format_is_dsd(struct snd_pcm_hw_params *params) { snd_pcm_format_t format =3D params_format(params); @@ -241,6 +260,7 @@ static bool codec_is_akcodec(unsigned int type) case CODEC_AK4497: case CODEC_AK5558: case CODEC_AK5552: + case CODEC_CS42888: return true; default: break; @@ -340,13 +360,15 @@ static int imx_aif_hw_params(struct snd_pcm_substream= *substream, return ret; } =20 - ret =3D snd_soc_dai_set_tdm_slot(codec_dai, - BIT(slots) - 1, - BIT(slots) - 1, - slots, slot_width); - if (ret && ret !=3D -ENOTSUPP) { - dev_err(dev, "failed to set codec dai[%d] tdm slot: %d\n", i, ret); - return ret; + if (format_is_tdm(link_data)) { + ret =3D snd_soc_dai_set_tdm_slot(codec_dai, + BIT(slots) - 1, + BIT(slots) - 1, + slots, slot_width); + if (ret && ret !=3D -ENOTSUPP) { + dev_err(dev, "failed to set codec dai[%d] tdm slot: %d\n", i, ret); + return ret; + } } } =20 @@ -609,6 +631,8 @@ static int imx_card_parse_of(struct imx_card_data *data) plat_data->type =3D CODEC_AK5558; else if (!strcmp(link->codecs->dai_name, "ak5552-aif")) plat_data->type =3D CODEC_AK5552; + else if (!strcmp(link->codecs->dai_name, "cs42888")) + plat_data->type =3D CODEC_CS42888; =20 } else { link->codecs =3D &snd_soc_dummy_dlc; @@ -766,6 +790,12 @@ static int imx_card_probe(struct platform_device *pdev) data->dapm_routes[i].sink =3D "ASRC-Capture"; data->dapm_routes[i].source =3D "CPU-Capture"; break; + case CODEC_CS42888: + data->dapm_routes[0].sink =3D "Playback"; + data->dapm_routes[0].source =3D "CPU-Playback"; + data->dapm_routes[1].sink =3D "CPU-Capture"; + data->dapm_routes[1].source =3D "Capture"; + break; default: break; } @@ -805,6 +835,16 @@ static int imx_card_probe(struct platform_device *pdev) plat_data->support_tdm_channels =3D ak5558_tdm_channels; plat_data->num_tdm_channels =3D ARRAY_SIZE(ak5558_tdm_channels); break; + case CODEC_CS42888: + plat_data->fs_mul =3D cs42888_fs_mul; + plat_data->num_fs_mul =3D ARRAY_SIZE(cs42888_fs_mul); + plat_data->tdm_fs_mul =3D cs42888_tdm_fs_mul; + plat_data->num_tdm_fs_mul =3D ARRAY_SIZE(cs42888_tdm_fs_mul); + plat_data->support_channels =3D cs42888_channels; + plat_data->num_channels =3D ARRAY_SIZE(cs42888_channels); + plat_data->support_tdm_channels =3D cs42888_tdm_channels; + plat_data->num_tdm_channels =3D ARRAY_SIZE(cs42888_tdm_channels); + break; default: break; } --=20 2.34.1