From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Russell King - ARM Linux <linux@armlinux.org.uk>,
Stephen Boyd <sboyd@codeaurora.org>,
Rob Herring <robh@kernel.org>,
Linux-ALSA <alsa-devel@alsa-project.org>,
Linux-DT <devicetree@vger.kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Linux-Kernel <linux-kernel@vger.kernel.org>,
Mark Brown <broonie@kernel.org>, <linux-clk@vger.kernel.org>,
Linux-ARM <linux-arm-kernel@lists.infradead.org>
Subject: [PATCH 3/3] ASoC: simple-card-utils: enable clocks/clock-names/clock-ranges
Date: Mon, 5 Dec 2016 05:23:56 +0000 [thread overview]
Message-ID: <87zikbuezr.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <874m2jvtmw.wl%kuninori.morimoto.gx@renesas.com>
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Current simple-card is supporting this style for clocks
sound {
...
simple-audio-card,cpu {
sound-dai = <&xxx>;
clocks = <&cpu_clock>;
};
simple-audio-card,codec {
sound-dai = <&xxx>;
clocks = <&codec_clock>;
};
};
Now, it can support this style too, because we can use
devm_get_clk_from_child() now.
sound {
...
clocks = <&cpu_clock>, <&codec_clock>;
clock-names = "cpu", "codec";
clock-ranges;
...
simple-audio-card,cpu {
sound-dai = <&xxx>;
};
simple-audio-card,codec {
sound-dai = <&xxx>;
};
};
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
.../devicetree/bindings/sound/simple-card.txt | 32 ++++++++++++++++++
sound/soc/generic/simple-card-utils.c | 39 +++++++++++++++++++++-
2 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index c7a9393..43a710b 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -86,6 +86,7 @@ Optional CPU/CODEC subnodes properties:
in dai startup() and disabled with
clk_disable_unprepare() in dai
shutdown().
+ see Clock Example.
Example 1 - single DAI link:
@@ -199,3 +200,34 @@ sound {
clocks = ...
};
};
+
+
+Clock Example 1 - clock settings on each subnode
+
+sound {
+ ...
+ simple-audio-card,cpu {
+ sound-dai = <&xxx>;
+ clocks = <&cpu_clock>;
+ };
+ simple-audio-card,codec {
+ sound-dai = <&xxx>;
+ clocks = <&codec_clock>;
+ };
+};
+
+Clock Example 2 - clock settings by clocks
+
+sound {
+ ...
+ clocks = <&cpu_clock>, <&codec_clock>;
+ clock-names = "cpu", "codec";
+ clock-ranges;
+ ...
+ simple-audio-card,cpu {
+ sound-dai = <&xxx>;
+ };
+ simple-audio-card,codec {
+ sound-dai = <&xxx>;
+ };
+};
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 4924575..c3031a5 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -104,15 +104,52 @@ int asoc_simple_card_parse_clk(struct device *dev,
struct asoc_simple_dai *simple_dai)
{
struct clk *clk;
+ const char *con_id = NULL;
+ const char *port_name[] = {
+ "cpu", "codec"
+ };
u32 val;
/*
+ * We can use this style if "con_id" is not NULL
+ *
+ * sound {
+ * ...
+ * clocks = <&xxx>, <&xxx>;
+ * clock-names = "cpu", "codec";
+ * clock-ranges;
+ *
+ * simple-audio-card,cpu {
+ * sound-dai = <&xxx>;
+ * };
+ * simple-audio-card,codec {
+ * sound-dai = <&xxx>;
+ * };
+ * };
+ */
+ if (of_find_property(dev->of_node, "clock-names", NULL)) {
+ int i;
+ int port_len, node_len;
+
+ for (i = 0; i < ARRAY_SIZE(port_name); i++) {
+ node_len = strlen(node->name);
+ port_len = strlen(port_name[i]);
+
+ if (0 == strncmp(node->name + node_len - port_len,
+ port_name[i], port_len)) {
+ con_id = port_name[i];
+ break;
+ }
+ }
+ }
+
+ /*
* Parse dai->sysclk come from "clocks = <&xxx>"
* (if system has common clock)
* or "system-clock-frequency = <xxx>"
* or device's module clock.
*/
- clk = devm_get_clk_from_child(dev, node, NULL);
+ clk = devm_get_clk_from_child(dev, node, con_id);
if (!IS_ERR(clk)) {
simple_dai->sysclk = clk_get_rate(clk);
} else if (!of_property_read_u32(node, "system-clock-frequency", &val)) {
--
1.9.1
next prev parent reply other threads:[~2016-12-05 5:24 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-05 5:22 [PATCH 0/3] clkdev: add devm_get_clk_from_child() Kuninori Morimoto
2016-12-05 5:23 ` [PATCH 1/3] " Kuninori Morimoto
2016-12-09 20:31 ` Russell King - ARM Linux
2016-12-05 5:23 ` [PATCH 2/3] ASoC: simple-card: use devm_get_clk_from_child() Kuninori Morimoto
2016-12-08 22:09 ` Stephen Boyd
2016-12-09 0:20 ` Kuninori Morimoto
2016-12-09 0:28 ` Stephen Boyd
2016-12-09 0:33 ` Kuninori Morimoto
2017-01-24 18:39 ` Applied "ASoC: simple-card: use devm_get_clk_from_child()" to the asoc tree Mark Brown
2016-12-05 5:23 ` Kuninori Morimoto [this message]
2016-12-08 22:09 ` [PATCH 3/3] ASoC: simple-card-utils: enable clocks/clock-names/clock-ranges Stephen Boyd
2016-12-09 0:21 ` Kuninori Morimoto
2016-12-09 0:22 ` Kuninori Morimoto
2016-12-09 0:26 ` Stephen Boyd
2016-12-09 0:55 ` Kuninori Morimoto
2016-12-08 22:08 ` [PATCH 0/3] clkdev: add devm_get_clk_from_child() Stephen Boyd
2016-12-09 0:25 ` Kuninori Morimoto
2016-12-15 12:21 ` Mark Brown
2016-12-16 0:02 ` Kuninori Morimoto
2017-03-29 1:16 ` Question about of_clk_put ? Kuninori Morimoto
2017-03-30 1:46 ` [alsa-devel] " Kuninori Morimoto
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=87zikbuezr.wl%kuninori.morimoto.gx@renesas.com \
--to=kuninori.morimoto.gx@renesas.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@codeaurora.org \
/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).