From: Alifer Moraes <alifer.m@variscite.com>
To: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
devicetree@vger.kernel.org, eran.m@variscite.com,
festevam@gmail.com, lgirdwood@gmail.com,
linuxppc-dev@lists.ozlabs.org, nicoleotsuka@gmail.com,
patches@opensource.cirrus.com, perex@perex.cz,
pierluigi.p@variscite.com, robh+dt@kernel.org,
shengjiu.wang@gmail.com, tiwai@suse.com, Xiubo.Lee@gmail.com
Subject: [PATCH 1/4] ASoC: fsl-asoc-card: add WM8904 support
Date: Mon, 7 Mar 2022 11:10:38 -0300 [thread overview]
Message-ID: <20220307141041.27538-1-alifer.m@variscite.com> (raw)
From: Pierluigi Passaro <pierluigi.p@variscite.com>
The codec WM8904 can use internal FLL as PLL source.
Whenever the PLL source is not an external MCLK, this source
must be setup during hw_params callback otherwise the BCLK
could be wrongly evaluated.
The SND_SOC_BIAS_PREPARE event is raised after the hw_params
callback, so there is no need to set again PLL and SYSCLK and
actually there's no need at all the set_bias_level function.
Also, when esai is used, a dedicated snd_soc_dai_set_tdm_slot
call is required.
Signed-off-by: Pierluigi Passaro <pierluigi.p@variscite.com>
Signed-off by: Alifer Moraes <alifer.m@variscite.com>
---
sound/soc/fsl/fsl-asoc-card.c | 47 +++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 5ee945505281..817dbc1ec635 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -23,6 +23,7 @@
#include "imx-audmux.h"
#include "../codecs/sgtl5000.h"
+#include "../codecs/wm8904.h"
#include "../codecs/wm8962.h"
#include "../codecs/wm8960.h"
#include "../codecs/wm8994.h"
@@ -257,6 +258,38 @@ static int fsl_asoc_card_hw_free(struct snd_pcm_substream *substream)
}
}
+ if (of_device_is_compatible(dev->of_node, "fsl,imx-audio-wm8904")) {
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+ unsigned int pll_out;
+
+ ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0, 0, 2,
+ params_physical_width(params));
+ if (ret) {
+ dev_err(dev, "failed to set TDM slot for cpu dai\n");
+ return ret;
+ }
+
+ if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE)
+ pll_out = priv->sample_rate * 384;
+ else
+ pll_out = priv->sample_rate * 256;
+
+ ret = snd_soc_dai_set_pll(codec_dai, codec_priv->pll_id,
+ codec_priv->pll_id,
+ codec_priv->mclk_freq, pll_out);
+ if (ret) {
+ dev_err(dev, "failed to start FLL: %d\n", ret);
+ return ret;
+ }
+
+ ret = snd_soc_dai_set_sysclk(codec_dai, codec_priv->fll_id,
+ pll_out, SND_SOC_CLOCK_IN);
+ if (ret) {
+ dev_err(dev, "failed to set SYSCLK: %d\n", ret);
+ return ret;
+ }
+ }
+
return 0;
}
@@ -651,6 +684,19 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
priv->codec_priv.fll_id = WM8960_SYSCLK_AUTO;
priv->codec_priv.pll_id = WM8960_SYSCLK_AUTO;
priv->dai_fmt |= SND_SOC_DAIFMT_CBP_CFP;
+ } else if (of_device_is_compatible(np, "fsl,imx-audio-wm8904")) {
+ codec_dai_name = "wm8904-hifi";
+ priv->card.set_bias_level = NULL;
+ priv->codec_priv.mclk_id = WM8904_CLK_FLL;
+ priv->codec_priv.fll_id = WM8904_CLK_FLL;
+ priv->codec_priv.pll_id = WM8904_FLL_MCLK;
+ priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
+ if (strstr(cpu_np->name, "esai")) {
+ priv->cpu_priv.sysclk_freq[TX] = priv->codec_priv.mclk_freq;
+ priv->cpu_priv.sysclk_freq[RX] = priv->codec_priv.mclk_freq;
+ priv->cpu_priv.sysclk_dir[TX] = SND_SOC_CLOCK_OUT;
+ priv->cpu_priv.sysclk_dir[RX] = SND_SOC_CLOCK_OUT;
+ }
} else if (of_device_is_compatible(np, "fsl,imx-audio-ac97")) {
codec_dai_name = "ac97-hifi";
priv->dai_fmt = SND_SOC_DAIFMT_AC97;
@@ -900,6 +946,7 @@ static const struct of_device_id fsl_asoc_card_dt_ids[] = {
{ .compatible = "fsl,imx-audio-tlv320aic32x4", },
{ .compatible = "fsl,imx-audio-tlv320aic31xx", },
{ .compatible = "fsl,imx-audio-sgtl5000", },
+ { .compatible = "fsl,imx-audio-wm8904", },
{ .compatible = "fsl,imx-audio-wm8962", },
{ .compatible = "fsl,imx-audio-wm8960", },
{ .compatible = "fsl,imx-audio-mqs", },
--
2.25.1
next reply other threads:[~2022-03-07 14:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-07 14:10 Alifer Moraes [this message]
2022-03-07 14:10 ` [PATCH 2/4] ASoC: bindings: fsl-asoc-card: Add compatible string for wm8904 Alifer Moraes
2022-03-07 14:10 ` [PATCH 3/4] ASoC: wm8904: extend device tree support Alifer Moraes
2022-03-07 16:16 ` Mark Brown
2022-03-10 20:51 ` Rob Herring
2022-06-20 14:39 ` Pierluigi Passaro
2022-03-07 14:10 ` [PATCH 4/4] ASoC: wm8904: add DMIC support Alifer Moraes
2022-03-07 16:25 ` Mark Brown
2022-06-20 19:53 ` Pierluigi Passaro
2022-06-21 13:11 ` Mark Brown
2022-03-11 17:16 ` [PATCH 1/4] ASoC: fsl-asoc-card: add WM8904 support Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220307141041.27538-1-alifer.m@variscite.com \
--to=alifer.m@variscite.com \
--cc=Xiubo.Lee@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=eran.m@variscite.com \
--cc=festevam@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nicoleotsuka@gmail.com \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=pierluigi.p@variscite.com \
--cc=robh+dt@kernel.org \
--cc=shengjiu.wang@gmail.com \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®