Arizona FLL fixes and Clocking Improvements
Subsystems (6)
cover Arizona FLL fixes and Clocking Improvements
Hi,
The first 3 patches in this series fix some small issues with the FLL configuration in the driver. The second 3 patches add support for requesting the input clocks for the CODEC through the clock framework. This is some what of an intermediate step until all the clocking itself in the CODEC can be brought under the clock framework but as there are machine drivers that want to be merged now with source clocks that require gating and difficult to resolve issues between the SPI and clock framework an intermediate solution seems warranted.
Whilst the two halfs of this series do fairly different things, I have sent them as once series as they touch a lot of the same code, so this seemed the simpler approach to pushing them both through. The series is based of Mark's ASoC for-next tree.
Thanks,
Charles
Charles Keepax (5):
ASoC: arizona: Correct handling of FLL theta in synchroniser mode
ASoC: arizona: Allow specification of base for arizona_is_enabled_fll
ASoC: arizona: Avoid changing SYNC_ENA whilst the FLL_ENA is set
ASoC: arizona: Add gating for clock when used for direct MCLK
ASoC: arizona: Add gating for source clocks of the FLLs
Sylwester Nawrocki (1):
mfd: arizona: Add gating of external MCLKn clocks
drivers/mfd/arizona-core.c | 30 +++++++++- include/linux/mfd/arizona/core.h | 9 +++ sound/soc/codecs/arizona.c | 124 +++++++++++++++++++++++++++++++++++---- sound/soc/codecs/arizona.h | 2 + sound/soc/codecs/cs47l24.c | 6 +- sound/soc/codecs/wm5102.c | 9 ++- sound/soc/codecs/wm5110.c | 10 +++- sound/soc/codecs/wm8997.c | 9 ++- sound/soc/codecs/wm8998.c | 6 +- 9 files changed, 179 insertions(+), 26 deletions(-)
Signature · 1 line
2.1.4
PATCH 1/6 ASoC: arizona: Correct handling of FLL theta in synchroniser mode
Theta/lambda is used to give the fractional portion of the FLL frequency multiplication. When the synchroniser is active the reference path lambda value is hard coded in the hardware to 65536. This patch corrects the handling of theta such that it is scaled to match this denominator, when the synchroniser is active.
--- sound/soc/codecs/arizona.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/soc/codecs/arizona.c +6 -2
@@ -1920,8 +1920,8 @@ static struct {struct arizona_fll_cfg {int n; -int theta; -int lambda; +unsigned int theta; +unsigned int lambda;int refdiv;int outdiv;int fratio;
@@ -2233,6 +2233,10 @@ static int arizona_enable_fll(struct arizona_fll *fll) fll->ref_src != fll->sync_src) {arizona_calc_fll (fll, &cfg, fll->ref_freq, false); +/* Ref path hardcodes lambda to 65536 when sync is on */ +if (fll->sync_src >=0 && cfg.lambda) + cfg.theta = (cfg.theta * (1 <<16 )) / cfg.lambda; +arizona_apply_fll (arizona, fll->base, &cfg, fll->ref_src, false);if (fll->sync_src >=0 ) {
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: arizona: Correct handling of FLL theta in synchroniser mode" to the asoc tree
The patch
ASoC: arizona: Correct handling of FLL theta in synchroniser mode
has been applied to the asoc tree at
git://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
e87d9ae8886783f3a5a8dd6863e8261783214e3bMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 2 Sep 2016 16:52:43 +0100
Subject: [PATCH] ASoC: arizona: Correct handling of FLL theta in synchroniser
mode
Theta/lambda is used to give the fractional portion of the FLL frequency multiplication. When the synchroniser is active the reference path lambda value is hard coded in the hardware to 65536. This patch corrects the handling of theta such that it is scaled to match this denominator, when the synchroniser is active.
--- sound/soc/codecs/arizona.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
sound/soc/codecs/arizona.c +6 -2
@@ -1920,8 +1920,8 @@ static struct {struct arizona_fll_cfg {int n; -int theta; -int lambda; +unsigned int theta; +unsigned int lambda;int refdiv;int outdiv;int fratio;
@@ -2233,6 +2233,10 @@ static int arizona_enable_fll(struct arizona_fll *fll) fll->ref_src != fll->sync_src) {arizona_calc_fll (fll, &cfg, fll->ref_freq, false); +/* Ref path hardcodes lambda to 65536 when sync is on */ +if (fll->sync_src >=0 && cfg.lambda) + cfg.theta = (cfg.theta * (1 <<16 )) / cfg.lambda; +arizona_apply_fll (arizona, fll->base, &cfg, fll->ref_src, false);if (fll->sync_src >=0 ) {
Signature · 1 line
2.9.3
PATCH 2/6 ASoC: arizona: Allow specification of base for arizona_is_enabled_fll
In reply to Charles KeepaxIn preparation for future improvements allow a base to be passed to arizona_is_enabled_fll, this will allow it to be used to check the state of the synchroniser path as well.
--- sound/soc/codecs/arizona.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/arizona.c +3 -3
@@ -2188,13 +2188,13 @@ static void arizona_apply_fll(struct arizona *arizona, unsigned int base, ARIZONA_FLL1_CTRL_UPD | cfg->n); } -static int arizona_is_enabled_fll (struct arizona_fll *fll) +static int arizona_is_enabled_fll (struct arizona_fll *fll,int base) {struct arizona *arizona = fll->arizona;unsigned int reg;int ret; - ret =regmap_read (arizona->regmap, fll->base +1 , ®); + ret =regmap_read (arizona->regmap, base +1 , ®);if (ret !=0 ) {arizona_fll_err (fll,"Failed to read current state: %d\n" , ret);
@@ -2208,7 +2208,7 @@ static int arizona_enable_fll(struct arizona_fll *fll) {struct arizona *arizona = fll->arizona;bool use_sync = false; -int already_enabled =arizona_is_enabled_fll (fll); +int already_enabled =arizona_is_enabled_fll (fll, fll->base);struct arizona_fll_cfg cfg;int i;unsigned int val;
Signature · 1 line
2.1.4
Mark Brown
maintainerApplied "ASoC: arizona: Allow specification of base for arizona_is_enabled_fll" to the asoc tree
The patch
ASoC: arizona: Allow specification of base for arizona_is_enabled_fll
has been applied to the asoc tree at
git://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
62bb7104687c0ac1e85b1cf45a85a20b492b06a6Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 2 Sep 2016 16:52:44 +0100
Subject: [PATCH] ASoC: arizona: Allow specification of base for
arizona_is_enabled_fll
In preparation for future improvements allow a base to be passed to arizona_is_enabled_fll, this will allow it to be used to check the state of the synchroniser path as well.
--- sound/soc/codecs/arizona.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
sound/soc/codecs/arizona.c +3 -3
@@ -2188,13 +2188,13 @@ static void arizona_apply_fll(struct arizona *arizona, unsigned int base, ARIZONA_FLL1_CTRL_UPD | cfg->n); } -static int arizona_is_enabled_fll (struct arizona_fll *fll) +static int arizona_is_enabled_fll (struct arizona_fll *fll,int base) {struct arizona *arizona = fll->arizona;unsigned int reg;int ret; - ret =regmap_read (arizona->regmap, fll->base +1 , ®); + ret =regmap_read (arizona->regmap, base +1 , ®);if (ret !=0 ) {arizona_fll_err (fll,"Failed to read current state: %d\n" , ret);
@@ -2208,7 +2208,7 @@ static int arizona_enable_fll(struct arizona_fll *fll) {struct arizona *arizona = fll->arizona;bool use_sync = false; -int already_enabled =arizona_is_enabled_fll (fll); +int already_enabled =arizona_is_enabled_fll (fll, fll->base);struct arizona_fll_cfg cfg;int i;unsigned int val;
Signature · 1 line
2.8.1
PATCH 3/6 ASoC: arizona: Avoid changing SYNC_ENA whilst the FLL_ENA is set
In reply to Charles KeepaxFor best performance changing the synchroniser state whilst the FLL is running should be avoided. As this has been done fairly regularly in practice rather than hard preventing this, simply improve the FLL enable sequence and give a warning if the user changes the synchroniser state.
--- sound/soc/codecs/arizona.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/codecs/arizona.c +8 -2
@@ -2209,12 +2209,15 @@ static int arizona_enable_fll(struct arizona_fll *fll)struct arizona *arizona = fll->arizona;bool use_sync = false;int already_enabled =arizona_is_enabled_fll (fll, fll->base); +int sync_enabled =arizona_is_enabled_fll (fll, fll->base +0x10 );struct arizona_fll_cfg cfg;int i;unsigned int val;if (already_enabled <0 )return already_enabled; +if (sync_enabled <0 ) +return sync_enabled;if (already_enabled) {/* Facilitate smooth refclk across the transition */
@@ -2259,6 +2262,9 @@ static int arizona_enable_fll(struct arizona_fll *fll)return -EINVAL ; } +if (already_enabled && !!sync_enabled != use_sync) +arizona_fll_warn (fll,"Synchroniser changed on active FLL\n" ); +/* * Increase the bandwidth if we're not using a low frequency * sync source.
@@ -2274,12 +2280,12 @@ static int arizona_enable_fll(struct arizona_fll *fll)if (!already_enabled)pm_runtime_get_sync (arizona->dev); -regmap_update_bits_async (arizona->regmap, fll->base +1 , -ARIZONA_FLL1_ENA ,ARIZONA_FLL1_ENA );if (use_sync)regmap_update_bits_async (arizona->regmap, fll->base +0x11 ,ARIZONA_FLL1_SYNC_ENA ,ARIZONA_FLL1_SYNC_ENA ); +regmap_update_bits_async (arizona->regmap, fll->base +1 , +ARIZONA_FLL1_ENA ,ARIZONA_FLL1_ENA );if (already_enabled) regmap_update_bits_async(arizona->regmap, fll->base + 1,
Signature · 1 line
2.1.4
PATCH 4/6 mfd: arizona: Add gating of external MCLKn clocks
In reply to Charles KeepaxFrom: Sylwester Nawrocki <[email protected]>
This patch adds requesting of the clocks supplied on MCLK1, MCLK2 pins, gating of the 32k clock is added to the arizona_clk32k_enable(), arizona_clk32k_disable() helpers.
It's a temporary change until the CODEC's clock controller gets exposed through the clk API and is helpful for board configurations where the MCLK clocks are not provided by always on oscillators.
--- drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)
drivers/mfd/arizona-core.c +28 -2
@@ -10,6 +10,7 @@* published by the Free Software Foundation. */ +#include <linux/clk.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/gpio.h>
@@ -49,7 +50,15 @@ int arizona_clk32k_enable(struct arizona *arizona)case ARIZONA_32KZ_MCLK1 : ret =pm_runtime_get_sync (arizona->dev);if (ret !=0 ) - goto out; + goto err_ref; + ret =clk_prepare_enable (arizona->mclk[ARIZONA_MCLK1 ]); +if (ret !=0 ) + goto err_pm; +break ; +case ARIZONA_32KZ_MCLK2 : + ret =clk_prepare_enable (arizona->mclk[ARIZONA_MCLK2 ]); +if (ret !=0 ) + goto err_ref;break ; }
@@ -58,7 +67,9 @@ int arizona_clk32k_enable(struct arizona *arizona) ARIZONA_CLK_32K_ENA); } -out: +err_pm: +pm_runtime_put_sync (arizona->dev); +err_ref:if (ret !=0 ) arizona->clk32k_ref--;
@@ -83,6 +94,10 @@ int arizona_clk32k_disable(struct arizona *arizona)switch (arizona->pdata.clk32k_src) {case ARIZONA_32KZ_MCLK1 :pm_runtime_put_sync (arizona->dev); +clk_disable_unprepare (arizona->mclk[ARIZONA_MCLK1 ]); +break ; +case ARIZONA_32KZ_MCLK2 : +clk_disable_unprepare (arizona->mclk[ARIZONA_MCLK2 ]);break ; } }
@@ -1000,6 +1015,7 @@ static const struct mfd_cell wm8998_devs[] = {int arizona_dev_init (struct arizona *arizona) { +const char *const mclk_name[] = {"mclk1" ,"mclk2" };struct device *dev = arizona->dev;const char *type_name =NULL ;unsigned int reg, val, mask;
@@ -1016,6 +1032,16 @@ int arizona_dev_init(struct arizona *arizona)else arizona_of_get_core_pdata (arizona); +BUILD_BUG_ON (ARRAY_SIZE (arizona->mclk) !=ARRAY_SIZE (mclk_name)); +for (i =0 ; i <ARRAY_SIZE (arizona->mclk); i++) { + arizona->mclk[i] =devm_clk_get (arizona->dev, mclk_name[i]); +if (IS_ERR (arizona->mclk[i])) { +dev_info (arizona->dev,"Failed to get %s: %ld\n" , + mclk_name[i],PTR_ERR (arizona->mclk[i])); + arizona->mclk[i] =NULL ; + } + } +regcache_cache_only (arizona->regmap, true);switch (arizona->type) {
include/linux/mfd/arizona/core.h +9 -0
@@ -13,6 +13,7 @@#ifndef _WM_ARIZONA_CORE_H#define _WM_ARIZONA_CORE_H +#include <linux/clk.h> #include <linux/interrupt.h> #include <linux/notifier.h> #include <linux/regmap.h>
@@ -21,6 +22,12 @@#define ARIZONA_MAX_CORE_SUPPLIES 2 +enum { +ARIZONA_MCLK1 , +ARIZONA_MCLK2 , +ARIZONA_NUM_MCLK +}; +enum arizona_type {WM5102 =1 ,WM5110 =2 ,
@@ -139,6 +146,8 @@ struct arizona {struct mutex clk_lock;int clk32k_ref; +struct clk *mclk[ARIZONA_NUM_MCLK ]; +bool ctrlif_error;struct snd_soc_dapm_context *dapm;
Signature · 1 line
2.1.4
Re: [PATCH 4/6] mfd: arizona: Add gating of external MCLKn clocks
Quoted 10 lines · Charles Keepax
From: Sylwester Nawrocki <[email protected]>
This patch adds requesting of the clocks supplied on MCLK1, MCLK2 pins, gating of the 32k clock is added to the
arizona_clk32k_enable(),arizona_clk32k_disable()helpers.It's a temporary change until the CODEC's clock controller gets exposed through the clk API and is helpful for board configurations where the MCLK clocks are not provided by always on oscillators.
Quoted 6 lines
Signed-off-by Sylwester Nawrocki <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)
Can I take this?
Quoted 110 lines
drivers/mfd/arizona-core.c +28
-2@@ -10,6 +10,7 @@* published by the Free Software Foundation. */ +#include <linux/clk.h> #include <linux/delay.h> #include <linux/err.h> #include <linux/gpio.h> @@ -49,7 +50,15 @@ int arizona_clk32k_enable(struct arizona *arizona)case ARIZONA_32KZ_MCLK1 : ret =pm_runtime_get_sync (arizona->dev);if (ret !=0 ) - goto out; + goto err_ref; + ret =clk_prepare_enable (arizona->mclk[ARIZONA_MCLK1 ]); +if (ret !=0 ) + goto err_pm; +break ; +case ARIZONA_32KZ_MCLK2 : + ret =clk_prepare_enable (arizona->mclk[ARIZONA_MCLK2 ]); +if (ret !=0 ) + goto err_ref;break ; }@@ -58,7 +67,9 @@ int arizona_clk32k_enable(struct arizona *arizona) ARIZONA_CLK_32K_ENA); } -out: +err_pm: +pm_runtime_put_sync (arizona->dev); +err_ref:if (ret !=0 ) arizona->clk32k_ref--;@@ -83,6 +94,10 @@ int arizona_clk32k_disable(struct arizona *arizona)switch (arizona->pdata.clk32k_src) {case ARIZONA_32KZ_MCLK1 :pm_runtime_put_sync (arizona->dev); +clk_disable_unprepare (arizona->mclk[ARIZONA_MCLK1 ]); +break ; +case ARIZONA_32KZ_MCLK2 : +clk_disable_unprepare (arizona->mclk[ARIZONA_MCLK2 ]);break ; } }@@ -1000,6 +1015,7 @@ static const struct mfd_cell wm8998_devs[] = {int arizona_dev_init (struct arizona *arizona) { +const char *const mclk_name[] = {"mclk1" ,"mclk2" };struct device *dev = arizona->dev;const char *type_name =NULL ;unsigned int reg, val, mask;@@ -1016,6 +1032,16 @@ int arizona_dev_init(struct arizona *arizona)else arizona_of_get_core_pdata (arizona); +BUILD_BUG_ON (ARRAY_SIZE (arizona->mclk) !=ARRAY_SIZE (mclk_name)); +for (i =0 ; i <ARRAY_SIZE (arizona->mclk); i++) { + arizona->mclk[i] =devm_clk_get (arizona->dev, mclk_name[i]); +if (IS_ERR (arizona->mclk[i])) { +dev_info (arizona->dev,"Failed to get %s: %ld\n" , + mclk_name[i],PTR_ERR (arizona->mclk[i])); + arizona->mclk[i] =NULL ; + } + } +regcache_cache_only (arizona->regmap, true);switch (arizona->type) {include/linux/mfd/arizona/core.h +9
-0@@ -13,6 +13,7 @@#ifndef _WM_ARIZONA_CORE_H#define _WM_ARIZONA_CORE_H +#include <linux/clk.h> #include <linux/interrupt.h> #include <linux/notifier.h> #include <linux/regmap.h> @@ -21,6 +22,12 @@#define ARIZONA_MAX_CORE_SUPPLIES 2 +enum { +ARIZONA_MCLK1 , +ARIZONA_MCLK2 , +ARIZONA_NUM_MCLK +}; +enum arizona_type {WM5102 =1 ,WM5110 =2 ,@@ -139,6 +146,8 @@ struct arizona {struct mutex clk_lock;int clk32k_ref; +struct clk *mclk[ARIZONA_NUM_MCLK ]; +bool ctrlif_error;struct snd_soc_dapm_context *dapm;
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH 4/6] mfd: arizona: Add gating of external MCLKn clocks
Quoted 19 lines · Lee Jones
Quoted 10 lines · Charles Keepax
From: Sylwester Nawrocki <[email protected]>
This patch adds requesting of the clocks supplied on MCLK1, MCLK2 pins, gating of the 32k clock is added to the
arizona_clk32k_enable(),arizona_clk32k_disable()helpers.It's a temporary change until the CODEC's clock controller gets exposed through the clk API and is helpful for board configurations where the MCLK clocks are not provided by always on oscillators.
Quoted 6 lines
Signed-off-by Sylwester Nawrocki <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)
Quoted 4 lines
Acked-for-MFD-by Lee Jones <[email protected]>Can I take this?
The two following ASoC patches depend on it, so its probably slightly easier if they go through together.
Thanks,
Charles
Re: [PATCH 4/6] mfd: arizona: Add gating of external MCLKn clocks
Quoted 20 lines · Charles Keepax
Quoted 19 lines · Lee Jones
Quoted 16 lines · Charles Keepax
From: Sylwester Nawrocki <[email protected]>
This patch adds requesting of the clocks supplied on MCLK1, MCLK2 pins, gating of the 32k clock is added to the
arizona_clk32k_enable(),arizona_clk32k_disable()helpers.It's a temporary change until the CODEC's clock controller gets exposed through the clk API and is helpful for board configurations where the MCLK clocks are not provided by always on oscillators.
Signed-off-by Sylwester Nawrocki <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)
Quoted 7 lines
Quoted 4 lines
Acked-for-MFD-by Lee Jones <[email protected]>Can I take this?
The two following ASoC patches depend on it, so its probably slightly easier if they go through together.
Okay, let me know when you have all your Acks.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH 4/6] mfd: arizona: Add gating of external MCLKn clocks
Quoted 24 lines · Lee Jones
Quoted 22 lines · Charles Keepax
Quoted 21 lines · Lee Jones
Quoted 10 lines · Charles Keepax
From: Sylwester Nawrocki <[email protected]>
This patch adds requesting of the clocks supplied on MCLK1, MCLK2 pins, gating of the 32k clock is added to the
arizona_clk32k_enable(),arizona_clk32k_disable()helpers.It's a temporary change until the CODEC's clock controller gets exposed through the clk API and is helpful for board configurations where the MCLK clocks are not provided by always on oscillators.
Quoted 6 lines
Signed-off-by Sylwester Nawrocki <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)Acked-for-MFD-by Lee Jones <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Can I take this?
The two following ASoC patches depend on it, so its probably slightly easier if they go through together.
Okay, let me know when you have all your Acks.
Hi Lee, I see you have merged this patch on your public MFD branch, is it possible to send Mark a branch to pull from now? So we can get the other two patches merged.
Thanks,
Charles
Re: [PATCH 4/6] mfd: arizona: Add gating of external MCLKn clocks
Quoted 31 lines · Charles Keepax
Quoted 30 lines · Lee Jones
Quoted 27 lines · Charles Keepax
Quoted 19 lines · Lee Jones
Quoted 10 lines · Charles Keepax
From: Sylwester Nawrocki <[email protected]>
This patch adds requesting of the clocks supplied on MCLK1, MCLK2 pins, gating of the 32k clock is added to the
arizona_clk32k_enable(),arizona_clk32k_disable()helpers.It's a temporary change until the CODEC's clock controller gets exposed through the clk API and is helpful for board configurations where the MCLK clocks are not provided by always on oscillators.
Quoted 6 lines
Signed-off-by Sylwester Nawrocki <[email protected]>Signed-off-by Charles Keepax <[email protected]>--- drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)Quoted 4 lines
Acked-for-MFD-by Lee Jones <[email protected]>Can I take this?
The two following ASoC patches depend on it, so its probably slightly easier if they go through together.
Quoted 6 lines
Quoted 2 lines
Okay, let me know when you have all your Acks.
Hi Lee, I see you have merged this patch on your public MFD branch, is it possible to send Mark a branch to pull from now? So we can get the other two patches merged.
Done.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Mark Brown
maintainerRe: [PATCH 4/6] mfd: arizona: Add gating of external MCLKn clocks
In reply to Lee JonesQuoted 5 lines · Lee Jones
On Fri, 02 Sep 2016, Charles Keepax wrote:
Acked-for-MFD-by Lee Jones <[email protected]>Can I take this?
The easiest thing would be if you applied it and then sent me a pull request.
[GIT PULL] Immutable branch between MFD and Regulator due for the v4.9 merge window
Mark,
As requested.
Quoted 9 lines · Mark Brown
Quoted 5 lines · Lee Jones
On Fri, 02 Sep 2016, Charles Keepax wrote:
Acked-for-MFD-by Lee Jones <[email protected]>Can I take this?
The easiest thing would be if you applied it and then sent me a pull request.
The following changes since commit 29b4817d4018df78086157ea3a55c1d9424a7cfc:
Linux 4.8-rc1 (2016-08-07 18:18:00 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-regulator-v4.9-1
for you to fetch changes up to cdd8da8cc66b3d205120560649e530978ccbc567:
mfd: arizona: Add gating of external MCLKn clocks (2016-10-04 15:46:07 +0100)
----------------------------------------------------------------
Immutable branch between MFD and Regulator due for the v4.9 merge window
----------------------------------------------------------------
Sylwester Nawrocki (1):
mfd: arizona: Add gating of external MCLKn clocks
drivers/mfd/arizona-core.c | 30 ++++++++++++++++++++++++++++-- include/linux/mfd/arizona/core.h | 9 +++++++++ 2 files changed, 37 insertions(+), 2 deletions(-)
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH 5/6 ASoC: arizona: Add gating for clock when used for direct MCLK
In reply to Charles KeepaxWhilst ultimately we would like to move all the clocking over to the clock framework, as an intermediate step to get people going for now gating the source clocks for SYSCLK/ASYNCCLK when they are configured to come directly from an MCLK pin.
--- sound/soc/codecs/arizona.c | 40 ++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/arizona.h | 2 ++ sound/soc/codecs/cs47l24.c | 6 ++++-- sound/soc/codecs/wm5102.c | 9 +++++++-- sound/soc/codecs/wm5110.c | 10 +++++++--- sound/soc/codecs/wm8997.c | 9 +++++++-- sound/soc/codecs/wm8998.c | 6 ++++-- 7 files changed, 71 insertions(+), 11 deletions(-)
sound/soc/codecs/arizona.c +40 -0
@@ -1195,6 +1195,46 @@ static int arizona_set_opclk(struct snd_soc_codec *codec, unsigned int clk,return -EINVAL ; } +int arizona_clk_ev (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct snd_soc_codec *codec =snd_soc_dapm_to_codec (w->dapm); +struct arizona *arizona =dev_get_drvdata (codec->dev->parent); +unsigned int val; +int clk_idx; +int ret; + + ret =regmap_read (arizona->regmap, w->reg, &val); +if (ret) { +dev_err (codec->dev,"Failed to check clock source: %d\n" , ret); +return ret; + } + + val = (val &ARIZONA_SYSCLK_SRC_MASK ) >>ARIZONA_SYSCLK_SRC_SHIFT ; + +switch (val) { +case ARIZONA_CLK_SRC_MCLK1 : + clk_idx =ARIZONA_MCLK1 ; +break ; +case ARIZONA_CLK_SRC_MCLK2 : + clk_idx =ARIZONA_MCLK2 ; +break ; +default : +return 0 ; + } + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return clk_prepare_enable (arizona->mclk[clk_idx]); +case SND_SOC_DAPM_POST_PMD : +clk_disable_unprepare (arizona->mclk[clk_idx]); +return 0 ; +default : +return 0 ; + } +} +EXPORT_SYMBOL_GPL (arizona_clk_ev); +int arizona_set_sysclk (struct snd_soc_codec *codec,int clk_id,int source,unsigned int freq,int dir) {
sound/soc/codecs/arizona.h +2 -0
@@ -272,6 +272,8 @@ extern int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol,extern int arizona_lhpf_coeff_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); +extern int arizona_clk_ev (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event);extern int arizona_set_sysclk (struct snd_soc_codec *codec,int clk_id,int source,unsigned int freq,int dir);
sound/soc/codecs/cs47l24.c +4 -2
@@ -335,9 +335,11 @@ static const struct snd_kcontrol_new cs47l24_aec_loopback_mux =static const struct snd_soc_dapm_widget cs47l24_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 , -ARIZONA_SYSCLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_SYSCLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm5102.c +7 -2
@@ -607,6 +607,9 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,break ;case SND_SOC_DAPM_PRE_PMD :break ; +case SND_SOC_DAPM_PRE_PMU : +case SND_SOC_DAPM_POST_PMD : +return arizona_clk_ev (w, kcontrol, event);default :return 0 ; }
@@ -1077,9 +1080,11 @@ static const struct snd_kcontrol_new wm5102_aec_loopback_mux =static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 ,ARIZONA_SYSCLK_ENA_SHIFT ,0 , wm5102_sysclk_ev, -SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD | +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm5110.c +7 -3
@@ -183,7 +183,9 @@ static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,regmap_write_async (regmap, patch[i].reg, patch[i].def);break ; - +case SND_SOC_DAPM_PRE_PMU : +case SND_SOC_DAPM_POST_PMD : +return arizona_clk_ev (w, kcontrol, event);default :break ; }
@@ -1073,9 +1075,11 @@ static const struct snd_kcontrol_new wm5110_output_anc_src[] = {static const struct snd_soc_dapm_widget wm5110_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 ,ARIZONA_SYSCLK_ENA_SHIFT , -0 , wm5110_sysclk_ev,SND_SOC_DAPM_POST_PMU ), +0 , wm5110_sysclk_ev,SND_SOC_DAPM_POST_PMU | +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm8997.c +7 -2
@@ -108,6 +108,9 @@ static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w,break ;case SND_SOC_DAPM_PRE_PMD :break ; +case SND_SOC_DAPM_PRE_PMU : +case SND_SOC_DAPM_POST_PMD : +return arizona_clk_ev (w, kcontrol, event);default :return 0 ; }
@@ -408,9 +411,11 @@ static const struct snd_kcontrol_new wm8997_aec_loopback_mux =static const struct snd_soc_dapm_widget wm8997_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 ,ARIZONA_SYSCLK_ENA_SHIFT ,0 , wm8997_sysclk_ev, -SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD | +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm8998.c +4 -2
@@ -541,9 +541,11 @@ static const struct snd_kcontrol_new wm8998_aec_loopback_mux[] = {static const struct snd_soc_dapm_widget wm8998_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 , -ARIZONA_SYSCLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_SYSCLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
Signature · 1 line
2.1.4
Re: [PATCH 5/6] ASoC: arizona: Add gating for clock when used for direct MCLK
Quoted 6 lines · Charles Keepax
Whilst ultimately we would like to move all the clocking over to the clock framework, as an intermediate step to get people going for now gating the source clocks for SYSCLK/ASYNCCLK when they are configured to come directly from an MCLK pin.
Signed-off-by Charles Keepax <[email protected]>
I've tested this patch on TM2 board with WM5110 codec and I didn't notice any issues. The clock management looked good with this patch.
Mark Brown
maintainerApplied "ASoC: arizona: Add gating for clock when used for direct MCLK" to the asoc tree
In reply to Charles KeepaxThe patch
ASoC: arizona: Add gating for clock when used for direct MCLK
has been applied to the asoc tree at
git://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
7a4413d0dc964eecbed8dcb0e0d0b6e0aa9051f1Mon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 21 Oct 2016 14:15:57 +0100
Subject: [PATCH] ASoC: arizona: Add gating for clock when used for direct MCLK
Whilst ultimately we would like to move all the clocking over to the clock framework, as an intermediate step to get people going for now gating the source clocks for SYSCLK/ASYNCCLK when they are configured to come directly from an MCLK pin.
--- sound/soc/codecs/arizona.c | 40 ++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/arizona.h | 2 ++ sound/soc/codecs/cs47l24.c | 6 ++++-- sound/soc/codecs/wm5102.c | 9 +++++++-- sound/soc/codecs/wm5110.c | 10 +++++++--- sound/soc/codecs/wm8997.c | 9 +++++++-- sound/soc/codecs/wm8998.c | 6 ++++-- 7 files changed, 71 insertions(+), 11 deletions(-)
sound/soc/codecs/arizona.c +40 -0
@@ -1233,6 +1233,46 @@ static int arizona_set_opclk(struct snd_soc_codec *codec, unsigned int clk,return -EINVAL ; } +int arizona_clk_ev (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event) +{ +struct snd_soc_codec *codec =snd_soc_dapm_to_codec (w->dapm); +struct arizona *arizona =dev_get_drvdata (codec->dev->parent); +unsigned int val; +int clk_idx; +int ret; + + ret =regmap_read (arizona->regmap, w->reg, &val); +if (ret) { +dev_err (codec->dev,"Failed to check clock source: %d\n" , ret); +return ret; + } + + val = (val &ARIZONA_SYSCLK_SRC_MASK ) >>ARIZONA_SYSCLK_SRC_SHIFT ; + +switch (val) { +case ARIZONA_CLK_SRC_MCLK1 : + clk_idx =ARIZONA_MCLK1 ; +break ; +case ARIZONA_CLK_SRC_MCLK2 : + clk_idx =ARIZONA_MCLK2 ; +break ; +default : +return 0 ; + } + +switch (event) { +case SND_SOC_DAPM_PRE_PMU : +return clk_prepare_enable (arizona->mclk[clk_idx]); +case SND_SOC_DAPM_POST_PMD : +clk_disable_unprepare (arizona->mclk[clk_idx]); +return 0 ; +default : +return 0 ; + } +} +EXPORT_SYMBOL_GPL (arizona_clk_ev); +int arizona_set_sysclk (struct snd_soc_codec *codec,int clk_id,int source,unsigned int freq,int dir) {
sound/soc/codecs/arizona.h +2 -0
@@ -273,6 +273,8 @@ extern int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol,extern int arizona_lhpf_coeff_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol); +extern int arizona_clk_ev (struct snd_soc_dapm_widget *w, +struct snd_kcontrol *kcontrol,int event);extern int arizona_set_sysclk (struct snd_soc_codec *codec,int clk_id,int source,unsigned int freq,int dir);
sound/soc/codecs/cs47l24.c +4 -2
@@ -335,9 +335,11 @@ static const struct snd_kcontrol_new cs47l24_aec_loopback_mux =static const struct snd_soc_dapm_widget cs47l24_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 , -ARIZONA_SYSCLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_SYSCLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm5102.c +7 -2
@@ -607,6 +607,9 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,break ;case SND_SOC_DAPM_PRE_PMD :break ; +case SND_SOC_DAPM_PRE_PMU : +case SND_SOC_DAPM_POST_PMD : +return arizona_clk_ev (w, kcontrol, event);default :return 0 ; }
@@ -1077,9 +1080,11 @@ static const struct snd_kcontrol_new wm5102_aec_loopback_mux =static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 ,ARIZONA_SYSCLK_ENA_SHIFT ,0 , wm5102_sysclk_ev, -SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD | +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm5110.c +7 -3
@@ -183,7 +183,9 @@ static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w,regmap_write_async (regmap, patch[i].reg, patch[i].def);break ; - +case SND_SOC_DAPM_PRE_PMU : +case SND_SOC_DAPM_POST_PMD : +return arizona_clk_ev (w, kcontrol, event);default :break ; }
@@ -1073,9 +1075,11 @@ static const struct snd_kcontrol_new wm5110_output_anc_src[] = {static const struct snd_soc_dapm_widget wm5110_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 ,ARIZONA_SYSCLK_ENA_SHIFT , -0 , wm5110_sysclk_ev,SND_SOC_DAPM_POST_PMU ), +0 , wm5110_sysclk_ev,SND_SOC_DAPM_POST_PMU | +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm8997.c +7 -2
@@ -108,6 +108,9 @@ static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w,break ;case SND_SOC_DAPM_PRE_PMD :break ; +case SND_SOC_DAPM_PRE_PMU : +case SND_SOC_DAPM_POST_PMD : +return arizona_clk_ev (w, kcontrol, event);default :return 0 ; }
@@ -408,9 +411,11 @@ static const struct snd_kcontrol_new wm8997_aec_loopback_mux =static const struct snd_soc_dapm_widget wm8997_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 ,ARIZONA_SYSCLK_ENA_SHIFT ,0 , wm8997_sysclk_ev, -SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD ), +SND_SOC_DAPM_POST_PMU |SND_SOC_DAPM_PRE_PMD | +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
sound/soc/codecs/wm8998.c +4 -2
@@ -541,9 +541,11 @@ static const struct snd_kcontrol_new wm8998_aec_loopback_mux[] = {static const struct snd_soc_dapm_widget wm8998_dapm_widgets[] = {SND_SOC_DAPM_SUPPLY ("SYSCLK" ,ARIZONA_SYSTEM_CLOCK_1 , -ARIZONA_SYSCLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_SYSCLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("ASYNCCLK" ,ARIZONA_ASYNC_CLOCK_1 , -ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 ,NULL ,0 ), +ARIZONA_ASYNC_CLK_ENA_SHIFT ,0 , arizona_clk_ev, +SND_SOC_DAPM_PRE_PMU |SND_SOC_DAPM_POST_PMD ),SND_SOC_DAPM_SUPPLY ("OPCLK" ,ARIZONA_OUTPUT_SYSTEM_CLOCK ,ARIZONA_OPCLK_ENA_SHIFT ,0 ,NULL ,0 ), SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
Signature · 1 line
2.8.1
PATCH 6/6 ASoC: arizona: Add gating for source clocks of the FLLs
In reply to Charles KeepaxWhilst ultimately we would like to move all the clocking over to the clock framework, as an intermediate step to get people going for now enable the source clocks for FLLs as they are powered up.
--- sound/soc/codecs/arizona.c | 60 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 6 deletions(-)
sound/soc/codecs/arizona.c +54 -6
@@ -2244,6 +2244,42 @@ static int arizona_is_enabled_fll(struct arizona_fll *fll, int base)return reg &ARIZONA_FLL1_ENA ; } +static int arizona_set_fll_clks (struct arizona_fll *fll,int base,bool ena) +{ +struct arizona *arizona = fll->arizona; +unsigned int val; +struct clk *clk; +int ret; + + ret =regmap_read (arizona->regmap, base +6 , &val); +if (ret !=0 ) { +arizona_fll_err (fll,"Failed to read current source: %d\n" , + ret); +return ret; + } + + val &=ARIZONA_FLL1_CLK_REF_SRC_MASK ; + val >>=ARIZONA_FLL1_CLK_REF_SRC_SHIFT ; + +switch (val) { +case ARIZONA_FLL_SRC_MCLK1 : + clk = arizona->mclk[ARIZONA_MCLK1 ]; +break ; +case ARIZONA_FLL_SRC_MCLK2 : + clk = arizona->mclk[ARIZONA_MCLK2 ]; +break ; +default : +return 0 ; + } + +if (ena) { +return clk_prepare_enable (clk); + }else { +clk_disable_unprepare (clk); +return 0 ; + } +} +static int arizona_enable_fll (struct arizona_fll *fll) {struct arizona *arizona = fll->arizona;
@@ -2266,6 +2302,10 @@ static int arizona_enable_fll(struct arizona_fll *fll)udelay (32 );regmap_update_bits_async (fll->arizona->regmap, fll->base +0x9 ,ARIZONA_FLL1_GAIN_MASK ,0 ); + +if (arizona_is_enabled_fll (fll, fll->base +0x10 ) >0 ) +arizona_set_fll_clks (fll, fll->base +0x10 , false); +arizona_set_fll_clks (fll, fll->base, false); }/*
@@ -2320,10 +2360,13 @@ static int arizona_enable_fll(struct arizona_fll *fll)if (!already_enabled)pm_runtime_get_sync (arizona->dev); -if (use_sync) +if (use_sync) { +arizona_set_fll_clks (fll, fll->base +0x10 , true);regmap_update_bits_async (arizona->regmap, fll->base +0x11 ,ARIZONA_FLL1_SYNC_ENA ,ARIZONA_FLL1_SYNC_ENA ); + } +arizona_set_fll_clks (fll, fll->base, true);regmap_update_bits_async (arizona->regmap, fll->base +1 ,ARIZONA_FLL1_ENA ,ARIZONA_FLL1_ENA );
@@ -2356,19 +2399,24 @@ static int arizona_enable_fll(struct arizona_fll *fll)static void arizona_disable_fll (struct arizona_fll *fll) {struct arizona *arizona = fll->arizona; -bool change; +bool ref_change, sync_change;regmap_update_bits_async (arizona->regmap, fll->base +1 ,ARIZONA_FLL1_FREERUN ,ARIZONA_FLL1_FREERUN );regmap_update_bits_check (arizona->regmap, fll->base +1 , -ARIZONA_FLL1_ENA ,0 , &change); -regmap_update_bits (arizona->regmap, fll->base +0x11 , -ARIZONA_FLL1_SYNC_ENA ,0 ); +ARIZONA_FLL1_ENA ,0 , &ref_change); +regmap_update_bits_check (arizona->regmap, fll->base +0x11 , +ARIZONA_FLL1_SYNC_ENA ,0 , &sync_change);regmap_update_bits_async (arizona->regmap, fll->base +1 ,ARIZONA_FLL1_FREERUN ,0 ); -if (change) +if (sync_change) +arizona_set_fll_clks (fll, fll->base +0x10 , false); + +if (ref_change) { +arizona_set_fll_clks (fll, fll->base, false);pm_runtime_put_autosuspend (arizona->dev); + } } int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
Signature · 1 line
2.1.4
Re: [PATCH 6/6] ASoC: arizona: Add gating for source clocks of the FLLs
Quoted 5 lines · Charles Keepax
Whilst ultimately we would like to move all the clocking over to the clock framework, as an intermediate step to get people going for now enable the source clocks for FLLs as they are powered up.
Signed-off-by Charles Keepax <[email protected]>
Mark Brown
maintainerApplied "ASoC: arizona: Add gating for source clocks of the FLLs" to the asoc tree
In reply to Charles KeepaxThe patch
ASoC: arizona: Add gating for source clocks of the FLLs
has been applied to the asoc tree at
git://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
ae1ea48c5c5998c5730cebaa2374ab02ad4d7d4fMon Sep 17 00:00:00 2001
From: Charles Keepax <[email protected]>
Date: Fri, 21 Oct 2016 14:15:58 +0100
Subject: [PATCH] ASoC: arizona: Add gating for source clocks of the FLLs
Whilst ultimately we would like to move all the clocking over to the clock framework, as an intermediate step to get people going for now enable the source clocks for FLLs as they are powered up.
--- sound/soc/codecs/arizona.c | 60 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 6 deletions(-)
sound/soc/codecs/arizona.c +54 -6
@@ -2282,6 +2282,42 @@ static int arizona_is_enabled_fll(struct arizona_fll *fll, int base)return reg &ARIZONA_FLL1_ENA ; } +static int arizona_set_fll_clks (struct arizona_fll *fll,int base,bool ena) +{ +struct arizona *arizona = fll->arizona; +unsigned int val; +struct clk *clk; +int ret; + + ret =regmap_read (arizona->regmap, base +6 , &val); +if (ret !=0 ) { +arizona_fll_err (fll,"Failed to read current source: %d\n" , + ret); +return ret; + } + + val &=ARIZONA_FLL1_CLK_REF_SRC_MASK ; + val >>=ARIZONA_FLL1_CLK_REF_SRC_SHIFT ; + +switch (val) { +case ARIZONA_FLL_SRC_MCLK1 : + clk = arizona->mclk[ARIZONA_MCLK1 ]; +break ; +case ARIZONA_FLL_SRC_MCLK2 : + clk = arizona->mclk[ARIZONA_MCLK2 ]; +break ; +default : +return 0 ; + } + +if (ena) { +return clk_prepare_enable (clk); + }else { +clk_disable_unprepare (clk); +return 0 ; + } +} +static int arizona_enable_fll (struct arizona_fll *fll) {struct arizona *arizona = fll->arizona;
@@ -2304,6 +2340,10 @@ static int arizona_enable_fll(struct arizona_fll *fll)udelay (32 );regmap_update_bits_async (fll->arizona->regmap, fll->base +0x9 ,ARIZONA_FLL1_GAIN_MASK ,0 ); + +if (arizona_is_enabled_fll (fll, fll->base +0x10 ) >0 ) +arizona_set_fll_clks (fll, fll->base +0x10 , false); +arizona_set_fll_clks (fll, fll->base, false); }/*
@@ -2358,10 +2398,13 @@ static int arizona_enable_fll(struct arizona_fll *fll)if (!already_enabled)pm_runtime_get_sync (arizona->dev); -if (use_sync) +if (use_sync) { +arizona_set_fll_clks (fll, fll->base +0x10 , true);regmap_update_bits_async (arizona->regmap, fll->base +0x11 ,ARIZONA_FLL1_SYNC_ENA ,ARIZONA_FLL1_SYNC_ENA ); + } +arizona_set_fll_clks (fll, fll->base, true);regmap_update_bits_async (arizona->regmap, fll->base +1 ,ARIZONA_FLL1_ENA ,ARIZONA_FLL1_ENA );
@@ -2394,19 +2437,24 @@ static int arizona_enable_fll(struct arizona_fll *fll)static void arizona_disable_fll (struct arizona_fll *fll) {struct arizona *arizona = fll->arizona; -bool change; +bool ref_change, sync_change;regmap_update_bits_async (arizona->regmap, fll->base +1 ,ARIZONA_FLL1_FREERUN ,ARIZONA_FLL1_FREERUN );regmap_update_bits_check (arizona->regmap, fll->base +1 , -ARIZONA_FLL1_ENA ,0 , &change); -regmap_update_bits (arizona->regmap, fll->base +0x11 , -ARIZONA_FLL1_SYNC_ENA ,0 ); +ARIZONA_FLL1_ENA ,0 , &ref_change); +regmap_update_bits_check (arizona->regmap, fll->base +0x11 , +ARIZONA_FLL1_SYNC_ENA ,0 , &sync_change);regmap_update_bits_async (arizona->regmap, fll->base +1 ,ARIZONA_FLL1_FREERUN ,0 ); -if (change) +if (sync_change) +arizona_set_fll_clks (fll, fll->base +0x10 , false); + +if (ref_change) { +arizona_set_fll_clks (fll, fll->base, false);pm_runtime_put_autosuspend (arizona->dev); + } } int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
Signature · 1 line
2.8.1