mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: <mturquette@baylibre.com>, <sboyd@codeaurora.org>,
	<tony@atomide.com>, <lee.jones@linaro.org>, <robh+dt@kernel.org>,
	<lgirdwood@gmail.com>, <broonie@kernel.org>
Cc: <t-kristo@ti.com>, <linux-kernel@vger.kernel.org>,
	<linux-clk@vger.kernel.org>, <linux-omap@vger.kernel.org>,
	<devicetree@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<alsa-devel@alsa-project.org>
Subject: [PATCH v1 14/14] ASoC: omap-mcpdm: Add support for pdmclk clock handling
Date: Mon, 30 May 2016 11:55:22 +0300	[thread overview]
Message-ID: <20160530085522.30398-15-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <20160530085522.30398-1-peter.ujfalusi@ti.com>

McPDM module receives it's functional clock from external source. This
clock is the pdmclk provided by the twl6040 audio IC. If the clock is not
available all register accesses to McPDM fails and the module is not
operational.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/sound/omap-mcpdm.txt       | 10 ++++++++
 sound/soc/omap/omap-mcpdm.c                        | 27 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt
index 0741dff048dd..6f6c2f8e908d 100644
--- a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt
+++ b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt
@@ -8,6 +8,8 @@ Required properties:
 - interrupts: Interrupt number for McPDM
 - interrupt-parent: The parent interrupt controller
 - ti,hwmods: Name of the hwmod associated to the McPDM
+- clocks:  phandle for the pdmclk provider, likely <&twl6040>
+- clock-names: Must be "pdmclk"
 
 Example:
 
@@ -19,3 +21,11 @@ mcpdm: mcpdm@40132000 {
 	interrupt-parent = <&gic>;
 	ti,hwmods = "mcpdm";
 };
+
+In board DTS file the pdmclk needs to be added:
+
+&mcpdm {
+	clocks = <&twl6040>;
+	clock-names = "pdmclk";
+	status = "okay";
+};
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index 74d6e6fdcfd0..2d2119e7d094 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -31,6 +31,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/irq.h>
+#include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
 #include <linux/of_device.h>
@@ -54,6 +55,7 @@ struct omap_mcpdm {
 	unsigned long phys_base;
 	void __iomem *io_base;
 	int irq;
+	struct clk *pdmclk;
 
 	struct mutex mutex;
 
@@ -388,6 +390,12 @@ static int omap_mcpdm_probe(struct snd_soc_dai *dai)
 	struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
 	int ret;
 
+	ret = clk_prepare_enable(mcpdm->pdmclk);
+	if (!ret) {
+		dev_err(mcpdm->dev, "Failed to enable PDMCLK: %d\n", ret);
+		return ret;
+	}
+
 	pm_runtime_enable(mcpdm->dev);
 
 	/* Disable lines while request is ongoing */
@@ -422,6 +430,7 @@ static int omap_mcpdm_remove(struct snd_soc_dai *dai)
 
 	pm_runtime_disable(mcpdm->dev);
 
+	clk_disable_unprepare(mcpdm->pdmclk);
 	return 0;
 }
 
@@ -441,12 +450,21 @@ static int omap_mcpdm_suspend(struct snd_soc_dai *dai)
 		mcpdm->pm_active_count++;
 	}
 
+	clk_disable_unprepare(mcpdm->pdmclk);
+
 	return 0;
 }
 
 static int omap_mcpdm_resume(struct snd_soc_dai *dai)
 {
 	struct omap_mcpdm *mcpdm = snd_soc_dai_get_drvdata(dai);
+	int ret;
+
+	ret = clk_prepare_enable(mcpdm->pdmclk);
+	if (!ret) {
+		dev_err(mcpdm->dev, "Failed to enable PDMCLK: %d\n", ret);
+		return ret;
+	}
 
 	if (mcpdm->pm_active_count) {
 		while (mcpdm->pm_active_count--)
@@ -541,6 +559,15 @@ static int asoc_mcpdm_probe(struct platform_device *pdev)
 
 	mcpdm->dev = &pdev->dev;
 
+	mcpdm->pdmclk = devm_clk_get(&pdev->dev, "pdmclk");
+	if (IS_ERR(mcpdm->pdmclk)) {
+		if (PTR_ERR(mcpdm->pdmclk) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		dev_warn(&pdev->dev, "Error getting pdmclk (%ld)!\n",
+			 PTR_ERR(mcpdm->pdmclk));
+		mcpdm->pdmclk = NULL;
+	}
+
 	ret =  devm_snd_soc_register_component(&pdev->dev,
 					       &omap_mcpdm_component,
 					       &omap_mcpdm_dai, 1);
-- 
2.8.3

      parent reply	other threads:[~2016-05-30  8:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-30  8:55 [PATCH v1 00/14] clk/mfd/ASoC/ARM: OMAP4/5: McPDM/twl6040 pdmclk support Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 01/14] clk: twl6040: Correct clk_ops Peter Ujfalusi
2016-08-15 19:10   ` Stephen Boyd
2016-05-30  8:55 ` [PATCH v1 02/14] clk: twl6040: Register the clock as of_clk_provider Peter Ujfalusi
2016-08-15 19:10   ` Stephen Boyd
2016-05-30  8:55 ` [PATCH v1 03/14] clk: twl6040: Rename the driver and use consistent names in the code Peter Ujfalusi
2016-08-15 19:10   ` Stephen Boyd
2016-05-30  8:55 ` [PATCH v1 04/14] mfd: twl6040: The chip does not support bulk access Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 05/14] mfd: twl6040: Register child device for twl6040-pdmclk Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 06/14] ARM: dts: omap5-board-common: Add pdmclk binding for audio Peter Ujfalusi
2016-06-10 11:36   ` Tony Lindgren
2016-05-30  8:55 ` [PATCH v1 07/14] ARM: dts: omap4-panda-common: " Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 08/14] ARM: dts: omap4-sdp: " Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 09/14] ARM: dts: omap4-var-som-om44: " Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 10/14] ARM: dts: omap4-duovero: " Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 11/14] ASoC: omap: Kconfig: SND_OMAP_SOC_OMAP_ABE_TWL6040 to select CLK_TWL6040 Peter Ujfalusi
2016-05-30 16:15   ` Mark Brown
2016-05-30  8:55 ` [PATCH v1 12/14] ASoC: omap-mcpdm: Move the WD enable write inside omap_mcpdm_open_streams() Peter Ujfalusi
2016-05-30  8:55 ` [PATCH v1 13/14] ASoC: omap-mcpdm: Support for suspend resume Peter Ujfalusi
2016-05-30  8:55 ` Peter Ujfalusi [this message]

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=20160530085522.30398-15-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=t-kristo@ti.com \
    --cc=tony@atomide.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®