linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] ASoC: mxs: register saif mclk to clock framework
Date: Mon, 1 Jul 2013 16:16:10 +0800	[thread overview]
Message-ID: <1372666571-17276-4-git-send-email-shawn.guo@linaro.org> (raw)
In-Reply-To: <1372666571-17276-1-git-send-email-shawn.guo@linaro.org>

Mostly the mxs system design uses saif0 mclk output as the clock source
of codec.  Since the mclk is implemented as a general divider with the
saif clk as the parent clock, let's register the mclk as a basic
clk-divider to common clock framework.  Then with it being a clock
provdier, clk_get() call in codec driver probe function will just work.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
 sound/soc/mxs/mxs-saif.c |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index 49d8700..54511c5 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -24,6 +24,7 @@
 #include <linux/slab.h>
 #include <linux/dma-mapping.h>
 #include <linux/clk.h>
+#include <linux/clk-provider.h>
 #include <linux/delay.h>
 #include <linux/time.h>
 #include <sound/core.h>
@@ -658,6 +659,33 @@ static irqreturn_t mxs_saif_irq(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static int mxs_saif_mclk_init(struct platform_device *pdev)
+{
+	struct mxs_saif *saif = platform_get_drvdata(pdev);
+	struct device_node *np = pdev->dev.of_node;
+	struct clk *clk;
+	int ret;
+
+	clk = clk_register_divider(&pdev->dev, "mxs_saif_mclk",
+				   __clk_get_name(saif->clk), 0,
+				   saif->base + SAIF_CTRL,
+				   BP_SAIF_CTRL_BITCLK_MULT_RATE, 3,
+				   0, NULL);
+	if (IS_ERR(clk)) {
+		ret = PTR_ERR(clk);
+		if (ret == -EEXIST)
+			return 0;
+		dev_err(&pdev->dev, "failed to register mclk: %d\n", ret);
+		return PTR_ERR(clk);
+	}
+
+	ret = of_clk_add_provider(np, of_clk_src_simple_get, clk);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int mxs_saif_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -734,6 +762,13 @@ static int mxs_saif_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, saif);
 
+	/* We only support saif0 being tx and clock master */
+	if (saif->id == 0) {
+		ret = mxs_saif_mclk_init(pdev);
+		if (ret)
+			dev_warn(&pdev->dev, "failed to init clocks\n");
+	}
+
 	ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component,
 					 &mxs_saif_dai, 1);
 	if (ret) {
-- 
1.7.9.5

  parent reply	other threads:[~2013-07-01  8:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01  8:16 [PATCH 0/4] Fix mxs audio regressions Shawn Guo
2013-07-01  8:16 ` [PATCH 1/4] ASoC: sgtl5000: give it a ramping time before writting Shawn Guo
2013-07-01 10:07   ` Mark Brown
2013-07-01 10:54     ` Marek Vasut
2013-07-01 13:55       ` Shawn Guo
2013-07-01 14:12       ` [alsa-devel] " Fabio Estevam
2013-07-01 14:26         ` Shawn Guo
2013-07-01 14:34           ` Shawn Guo
2013-07-01 15:11             ` Fabio Estevam
2013-07-01 15:33               ` Shawn Guo
2013-07-01 15:42                 ` Fabio Estevam
2013-07-01 17:43                   ` Marek Vasut
2013-07-01 19:14                     ` Fabio Estevam
2013-07-01 19:28                       ` Alexandre Belloni
2013-07-02  2:16                     ` Shawn Guo
2013-07-01 19:23                   ` Alexandre Belloni
2013-07-01 14:04     ` Shawn Guo
2013-07-01 10:57   ` Lothar Waßmann
2013-07-01  8:16 ` [PATCH 2/4] ASoC: sgtl5000: defer the probe if clock is not found Shawn Guo
2013-07-01  9:45   ` Mark Brown
2013-07-01 11:33     ` Russell King - ARM Linux
2013-07-01 12:51       ` Mark Brown
2013-07-01  8:16 ` Shawn Guo [this message]
2013-07-01 10:11   ` [PATCH 3/4] ASoC: mxs: register saif mclk to clock framework Mark Brown
2013-07-01  8:16 ` [PATCH 4/4] ARM: mxs: saif0 is the clock provider to sgtl5000 Shawn Guo

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=1372666571-17276-4-git-send-email-shawn.guo@linaro.org \
    --to=shawn.guo@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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).