From: Fabio Estevam <festevam@gmail.com>
To: broonie@kernel.org
Cc: nicoleotsuka@gmail.com,
Fabio Estevam <fabio.estevam@freescale.com>,
alsa-devel@alsa-project.org
Subject: [PATCH] ASoC: fsl-asoc-card: Allow to describe master or slave mode
Date: Mon, 22 Sep 2014 01:40:54 -0300 [thread overview]
Message-ID: <1411360854-16891-1-git-send-email-festevam@gmail.com> (raw)
From: Fabio Estevam <fabio.estevam@freescale.com>
Provide a mechanism to describe whether the system runs in master or slave mode.
In order to keep compatibilty with existing dtb's let slave mode be default one.
Tested on a imx6q-sabresd board in both modes.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Documentation/devicetree/bindings/sound/fsl-asoc-card.txt | 5 +++++
sound/soc/fsl/fsl-asoc-card.c | 15 ++++++++++++---
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
index a96774c..1bbc828 100644
--- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
+++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt
@@ -59,6 +59,10 @@ Optional properties:
- audio-asrc : The phandle of ASRC. It can be absent if there's no
need to add ASRC support via DPCM.
+ - audio-cpu-mode : The operating mode for the audio cpu interface.
+ "slave" - audio clock comes from the external codec
+ "master" -audio clock is generated from the audio cpu
+
Example:
sound-cs42888 {
compatible = "fsl,imx-audio-cs42888";
@@ -66,6 +70,7 @@ sound-cs42888 {
audio-cpu = <&esai>;
audio-asrc = <&asrc>;
audio-codec = <&cs42888>;
+ audio-cpu-mode = "master";
audio-routing =
"Line Out Jack", "AOUT1L",
"Line Out Jack", "AOUT1R",
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 007c772..bd903cc 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -393,6 +393,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
struct clk *codec_clk;
u32 width;
int ret;
+ const char *mode;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -441,6 +442,17 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
/* Assign a default DAI format, and allow each card to overwrite it */
priv->dai_fmt = DAI_FMT_BASE;
+ mode = of_get_property(np, "audio-cpu-mode", NULL);
+ if (mode) {
+ if (!strcmp(mode, "master"))
+ priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
+ else if (!strcmp(mode, "slave"))
+ priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
+ } else {
+ /* Assign slave mode by default */
+ priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
+ }
+
/* Diversify the card configurations */
if (of_device_is_compatible(np, "fsl,imx-audio-cs42888")) {
priv->card.set_bias_level = NULL;
@@ -448,16 +460,13 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
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;
- priv->dai_fmt |= SND_SOC_DAIFMT_CBS_CFS;
} else if (of_device_is_compatible(np, "fsl,imx-audio-sgtl5000")) {
priv->codec_priv.mclk_id = SGTL5000_SYSCLK;
- priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
} else if (of_device_is_compatible(np, "fsl,imx-audio-wm8962")) {
priv->card.set_bias_level = fsl_asoc_card_set_bias_level;
priv->codec_priv.mclk_id = WM8962_SYSCLK_MCLK;
priv->codec_priv.fll_id = WM8962_SYSCLK_FLL;
priv->codec_priv.pll_id = WM8962_FLL;
- priv->dai_fmt |= SND_SOC_DAIFMT_CBM_CFM;
} else {
dev_err(&pdev->dev, "unknown Device Tree compatible\n");
return -EINVAL;
--
1.9.1
next reply other threads:[~2014-09-22 4:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-22 4:40 Fabio Estevam [this message]
2014-09-22 5:44 ` [PATCH] ASoC: fsl-asoc-card: Allow to describe master or slave mode Michael Trimarchi
2014-09-22 6:10 ` Nicolin Chen
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=1411360854-16891-1-git-send-email-festevam@gmail.com \
--to=festevam@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=fabio.estevam@freescale.com \
--cc=nicoleotsuka@gmail.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;
as well as URLs for NNTP newsgroup(s).