devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: lgirdwood@gmail.com, broonie@kernel.org,
	kuninori.morimoto.gx@renesas.com
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Daniel Mack <daniel@zonque.org>
Subject: [PATCH 2/3] ASoC: simple-card: make sysclk index configurable
Date: Mon, 28 May 2018 21:35:02 +0200	[thread overview]
Message-ID: <20180528193503.18905-3-daniel@zonque.org> (raw)
In-Reply-To: <20180528193503.18905-1-daniel@zonque.org>

The simple-card driver currently hard-codes the clk_id parameter in
snd_soc_dai_set_sysclk() to 0. Make this configrable for both CPU and
codec dai sub-nodes.

This still has the limitation that only one clk_id can be configured, but it
should help some more platforms to use simple-card in favor to a more
specific machine driver.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 Documentation/devicetree/bindings/sound/simple-card.txt |  3 +++
 include/sound/simple_card_utils.h                       |  1 +
 sound/soc/generic/simple-card-utils.c                   |  3 +++
 sound/soc/generic/simple-card.c                         | 10 ++++++----
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index a4c72d09cd45..c8d268285a9e 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -94,6 +94,9 @@ Optional CPU/CODEC subnodes properties:
 - system-clock-direction-out		: specifies clock direction as 'out' on
 					  initialization. It is useful for some aCPUs with
 					  fixed clocks.
+- system-clock-index			: index of the system clock to use when
+					  the mclk frequency is on the CPU/CODEC
+					  DAI. Defaults to 0.
 
 Example 1 - single DAI link:
 
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 7e25afce6566..ebdf52c9884f 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -21,6 +21,7 @@ struct asoc_simple_dai {
 	unsigned int tx_slot_mask;
 	unsigned int rx_slot_mask;
 	struct clk *clk;
+	int sysclk_id;
 };
 
 struct asoc_simple_card_data {
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 3751a07de6aa..493c9b1f057e 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -199,6 +199,9 @@ int asoc_simple_card_parse_clk(struct device *dev,
 	if (of_property_read_bool(node, "system-clock-direction-out"))
 		simple_dai->clk_direction = SND_SOC_CLOCK_OUT;
 
+	if (!of_property_read_u32(node, "system-clock-index", &val))
+		simple_dai->sysclk_id = val;
+
 	dev_dbg(dev, "%s : sysclk = %d, direction %d\n", name,
 		simple_dai->sysclk, simple_dai->clk_direction);
 
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index ca529a6cab06..5b4afa624395 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -158,13 +158,15 @@ static int asoc_simple_card_hw_params(struct snd_pcm_substream *substream,
 		if (dai_props->cpu_dai.clk)
 			clk_set_rate(dai_props->cpu_dai.clk, mclk);
 
-		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
-					     SND_SOC_CLOCK_IN);
+		ret = snd_soc_dai_set_sysclk(codec_dai,
+					     dai_props->codec_dai.sysclk_id,
+					     mclk, SND_SOC_CLOCK_IN);
 		if (ret && ret != -ENOTSUPP)
 			goto err;
 
-		ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
-					     SND_SOC_CLOCK_OUT);
+		ret = snd_soc_dai_set_sysclk(cpu_dai,
+					     dai_props->cpu_dai.sysclk_id,
+					     mclk, SND_SOC_CLOCK_OUT);
 		if (ret && ret != -ENOTSUPP)
 			goto err;
 	}
-- 
2.14.3

  parent reply	other threads:[~2018-05-28 19:35 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-28 19:35 [PATCH 0/3] ASoC: make simple-card a bit more versatile Daniel Mack
2018-05-28 19:35 ` [PATCH 1/3] ASoC: simple-card: set cpu dai clk in hw_params Daniel Mack
2018-05-29  1:38   ` Kuninori Morimoto
2018-05-29  4:26     ` Daniel Mack
2018-05-29 11:16   ` Mark Brown
2018-05-29 11:17     ` Daniel Mack
2018-05-29 11:32       ` Mark Brown
2018-05-29 20:31         ` Daniel Mack
2018-05-28 19:35 ` Daniel Mack [this message]
2018-05-29  1:35   ` [PATCH 2/3] ASoC: simple-card: make sysclk index configurable Kuninori Morimoto
2018-05-29  4:34     ` Daniel Mack
2018-05-29 11:24   ` Mark Brown
2018-05-29 20:23     ` Daniel Mack
2018-05-30  9:49       ` Mark Brown
2018-05-31 17:02       ` Rob Herring
2018-05-31 20:03         ` Daniel Mack
2018-06-01 14:21           ` Rob Herring
2018-05-28 19:35 ` [PATCH 3/3] ASoC: simple-card: add support for clock divider setup Daniel Mack
2018-05-29  1:31   ` Kuninori Morimoto
2018-05-29 11:35   ` Mark Brown
2018-05-29 20:29     ` Daniel Mack
2018-05-30  9:10       ` Mark Brown
2018-05-30  9:12         ` Daniel Mack
2018-06-23 18:41           ` Daniel Mack
2018-06-25 11:24             ` Mark Brown
2018-06-25 12:55               ` Daniel Mack
2018-06-25 12:57                 ` Mark Brown
2018-06-25 12:57                   ` Daniel Mack

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=20180528193503.18905-3-daniel@zonque.org \
    --to=daniel@zonque.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=lgirdwood@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).