[alsa-devel] [PATCH 0/2] 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(+)
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 --- Documentation/devicetree/bindings/sound/omap-mcpdm.txt | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt index 5f4e68ca228c..ff98a0cb5b3f 100644 --- a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt +++ b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt @@ -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"; +};
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
From 22cc062c4dfb16330fe18e8d7e155d733fd59e61 Mon Sep 17 00:00:00 2001
From: Peter Ujfalusi peter.ujfalusi@ti.com 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.
Signed-off-by: Peter Ujfalusi peter.ujfalusi@ti.com Acked-by: Rob Herring robh@kernel.org Signed-off-by: Mark Brown broonie@kernel.org --- Documentation/devicetree/bindings/sound/omap-mcpdm.txt | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt index 5f4e68ca228c..ff98a0cb5b3f 100644 --- a/Documentation/devicetree/bindings/sound/omap-mcpdm.txt +++ b/Documentation/devicetree/bindings/sound/omap-mcpdm.txt @@ -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"; +};
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 --- sound/soc/omap/omap-mcpdm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 7d5bdc5a2890..ee9101ab4343 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> @@ -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);
On 11/14/18 2:46 PM, Peter Ujfalusi wrote:
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
sound/soc/omap/omap-mcpdm.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
Acked-by: Jarkko Nikula jarkko.nikula@bitmer.com
On Wed, Nov 14, 2018 at 02:46:29PM +0200, Peter Ujfalusi wrote:
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.
On 2018-11-16 00:30, Mark Brown wrote:
On Wed, Nov 14, 2018 at 02:46:29PM +0200, Peter Ujfalusi wrote:
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
Hi Peter,
Am 16.11.2018 um 08:58 schrieb Peter Ujfalusi peter.ujfalusi@ti.com:
On 2018-11-16 00:30, Mark Brown wrote:
On Wed, Nov 14, 2018 at 02:46:29PM +0200, Peter Ujfalusi wrote:
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.
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.
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
participants (4)
-
H. Nikolaus Schaller
-
Jarkko Nikula
-
Mark Brown
-
Peter Ujfalusi