Skip to contentSkip to conversation

ASoC: omap-mcpdm: Support for handling pdmclk

PATCH Superseded Peter Ujfalusi 4 participants 8 messages Nov 14, 2018 – Nov 28, 2018

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: omap-mcpdm: Support for handling pdmclk

Hi,

This series is on top of the pm_qos changes I have sent earlier today.

I have sent this originally two years ago:
https://patchwork.kernel.org/patch/9119551/

But needed to revert it as the MFD and clk changes were not merged in time:
https://patchwork.kernel.org/patch/9287431/

The dts patches are already upstream, only the patch for McPDM is missing.

I have separated the binding document update and the driver patch and also added the return value check for the clk_prepare_enable() as per Mark's comment.

Regards,
Peter
---
Peter Ujfalusi (2):
dt-bindings: sound: omap-mcpdm: Update documentation for pdmclk
ASoC: omap-mcpdm: Add support for pdmclk clock handling

 .../devicetree/bindings/sound/omap-mcpdm.txt  | 10 ++++++++
 sound/soc/omap/omap-mcpdm.c                   | 23 +++++++++++++++++++
 2 files changed, 33 insertions(+)
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#1 lore raw

PATCH 1/2 dt-bindings: sound: omap-mcpdm: Update documentation for pdmclk

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.

---
 Documentation/devicetree/bindings/sound/omap-mcpdm.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/sound/omap-mcpdm.txt +10 -0
index 5f4e68ca228c..ff98a0cb5b3f 100644
@@ -7,6 +7,8 @@ Required properties:
        <L3 interconnect address, size>;
 - interrupts: Interrupt number for McPDM
 - ti,hwmods: Name of the hwmod associated to the McPDM
+- clocks:  phandle for the pdmclk provider, likely <&twl6040>
+- clock-names: Must be "pdmclk"
 
 Example:
 
@@ -18,3 +20,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";
+};
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#3 lore raw

PATCH 2/2 ASoC: omap-mcpdm: Add support for pdmclk clock handling

In reply to Peter Ujfalusi

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.

---
 sound/soc/omap/omap-mcpdm.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
sound/soc/omap/omap-mcpdm.c +23 -0
index 7d5bdc5a2890..ee9101ab4343 100644
@@ -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>
@@ -56,6 +57,7 @@ struct omap_mcpdm {
 	int irq;
 	struct pm_qos_request pm_qos_req;
 	int latency[2];
+	struct clk *pdmclk;
 
 	struct mutex mutex;
 
@@ -430,6 +432,10 @@ 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)
+		return ret;
+
 	pm_runtime_enable(mcpdm->dev);
 
 	/* Disable lines while request is ongoing */
@@ -468,6 +474,7 @@ static int omap_mcpdm_remove(struct snd_soc_dai *dai)
 	if (pm_qos_request_active(&mcpdm->pm_qos_req))
 		pm_qos_remove_request(&mcpdm->pm_qos_req);
 
+	clk_disable_unprepare(mcpdm->pdmclk);
 	return 0;
 }
 
@@ -487,12 +494,19 @@ 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)
+		return ret;
 
 	if (mcpdm->pm_active_count) {
 		while (mcpdm->pm_active_count--)
@@ -587,6 +601,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);
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer
#5 lore raw
In reply to Peter Ujfalusi
Quoted 2 lines · Peter Ujfalusi

I have separated the binding document update and the driver patch and also added the return value check for the clk_prepare_enable() as per Mark's comment.

I guess this depends on your other series for pm_qos - it's fine itself but doesn't apply, I'm leaving the pm_qos series for a bit longer in case there's more reviews.

#6 lore raw
Quoted 8 lines · Mark Brown
Quoted 2 lines · Peter Ujfalusi

I have separated the binding document update and the driver patch and also added the return value check for the clk_prepare_enable() as per Mark's comment.

I guess this depends on your other series for pm_qos - it's fine itself but doesn't apply, I'm leaving the pm_qos series for a bit longer in case there's more reviews.

Yes, I moved this on top of the pm_qos, I think I have mentioned that in the cover letter.

Yes again, let's wait for Nikolaus to test the pm_qos w/o CPU_IDLE and hopefully 4.19 against the scratchy tenth of seconds observed. Fwiw on omap5-uevm I was able to reproduce bad audio quality with CPU_IDLE which is fixed by the pm_qos patch.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

#7 lore raw

Hi Peter,

Quoted 12 lines

Am 16.11.2018 um 08:58 schrieb Peter Ujfalusi <[email protected]>:

Quoted 8 lines · Mark Brown
Quoted 2 lines · Peter Ujfalusi

I have separated the binding document update and the driver patch and also added the return value check for the clk_prepare_enable() as per Mark's comment.

I guess this depends on your other series for pm_qos - it's fine itself but doesn't apply, I'm leaving the pm_qos series for a bit longer in case there's more reviews.

Quoted 5 lines

Yes, I moved this on top of the pm_qos, I think I have mentioned that in the cover letter.

Yes again, let's wait for Nikolaus to test the pm_qos w/o CPU_IDLE and hopefully 4.19 against the scratchy tenth of seconds observed.

It seems to depend on high volume at the speaker (amixer 'Handsfree') and is also observable with CPU_IDLE=n

root@letux:~# gunzip </proc/config.gz |fgrep IDLE
CONFIG_NO_HZ_IDLE=y
# CONFIG_CPU_IDLE is not set
CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED=y
CONFIG_GENERIC_SMP_IDLE_THREAD=y
CONFIG_GENERIC_IDLE_POLL_SETUP=y
# CONFIG_IDLE_PAGE_TRACKING is not set
CONFIG_NETFILTER_XT_TARGET_IDLETIMER=m
root@letux:~# 

So it is a different issue for future study, e.g. with newer hardware or older kernel binaries.

Quoted 8 lines

Fwiw on
omap5-uevm I was able to reproduce bad audio quality with CPU_IDLE which is fixed by the pm_qos patch.

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

BR and thanks,
Nikolaus

Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] ASoC: omap-mcpdm: Add support for pdmclk clock handling

In reply to Peter Ujfalusi
Quoted 10 lines · Peter Ujfalusi

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.

---
 sound/soc/omap/omap-mcpdm.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
maintainer
#2 lore raw

Applied "dt-bindings: sound: omap-mcpdm: Update documentation for pdmclk" to the asoc tree

In reply to Peter Ujfalusi

The patch

dt-bindings: sound: omap-mcpdm: Update documentation for pdmclk

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 22cc062c4dfb16330fe18e8d7e155d733fd59e61 Mon Sep 17 00:00:00 2001

From: Peter Ujfalusi <[email protected]>
Date: Wed, 14 Nov 2018 14:46:30 +0200
Subject: [PATCH] dt-bindings: sound: omap-mcpdm: Update documentation for
pdmclk

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.

---
 Documentation/devicetree/bindings/sound/omap-mcpdm.txt | 10 ++++++++++
 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/sound/omap-mcpdm.txt +10 -0
index 5f4e68ca228c..ff98a0cb5b3f 100644
@@ -7,6 +7,8 @@ Required properties:
        <L3 interconnect address, size>;
 - interrupts: Interrupt number for McPDM
 - ti,hwmods: Name of the hwmod associated to the McPDM
+- clocks:  phandle for the pdmclk provider, likely <&twl6040>
+- clock-names: Must be "pdmclk"
 
 Example:
 
@@ -18,3 +20,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";
+};
Signature · 1 line
2.19.0.rc2