alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK
@ 2013-02-20 16:09 Charles Keepax
  2013-02-20 16:09 ` [PATCH 1/8] ASoC: arizona: Move selection of FLL REFCLK into init Charles Keepax
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

This patch series adds support for specifying the source of
REFCLK directly for Wolfson Arizona based devices. This should
allow for improved performance by using the highest available
REFCLK source. Should the REFCLK source not be directly specified
then the patches will default to the older behaviour of using the
32kHz clock for REFCLK.

REFCLK is configured using a call to snd_soc_codec_set_pll
specifying one of the new WM51xx_FLLx_REFCLK defines as the
pll_id. It is valid to clear the SYNCCLK source by setting the
source to ARIZONA_FLL_SRC_NONE, however once a REFCLK source it
can only be replaced with another valid REFCLK source.

Charles Keepax (8):
  ASoC: arizona: Move selection of FLL REFCLK into init
  ASoC: arizona: Tidy up SYNCCLK selection and cache values
  ASoC: arizona: Factor out check for enabled FLL
  ASoC: arizona: Factor out FLL disable
  ASoC: arizona: Factor out FLL enable
  ASoC: arizona: Improve suppression of noop FLL updates
  ASoC: arizona: Add support for directly setting the FLL REFCLK
  ASoC: arizona: Add convience define for clearing SYNCCLK

 sound/soc/codecs/arizona.c |  191 ++++++++++++++++++++++++++++++--------------
 sound/soc/codecs/arizona.h |    9 ++-
 sound/soc/codecs/wm5102.c  |    6 ++
 sound/soc/codecs/wm5102.h  |    6 +-
 sound/soc/codecs/wm5110.c  |    6 ++
 sound/soc/codecs/wm5110.h  |    6 +-
 6 files changed, 158 insertions(+), 66 deletions(-)

-- 
1.7.2.5

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/8] ASoC: arizona: Move selection of FLL REFCLK into init
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:09 ` [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values Charles Keepax
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

In preparation for additional features on the FLL this patch moves the
code selecting the REFCLK source based on the 32kHz clock into the FLL
initialisation function.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |   28 ++++++++++++++++------------
 sound/soc/codecs/arizona.h |    3 +++
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index ac948a6..c14e755 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1079,7 +1079,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 {
 	struct arizona *arizona = fll->arizona;
 	struct arizona_fll_cfg cfg, sync;
-	unsigned int reg, val;
+	unsigned int reg;
 	int syncsrc;
 	bool ena;
 	int ret;
@@ -1096,16 +1096,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 	ena = reg & ARIZONA_FLL1_ENA;
 
 	if (Fout) {
-		/* Do we have a 32kHz reference? */
-		regmap_read(arizona->regmap, ARIZONA_CLOCK_32K_1, &val);
-		switch (val & ARIZONA_CLK_32K_SRC_MASK) {
-		case ARIZONA_CLK_SRC_MCLK1:
-		case ARIZONA_CLK_SRC_MCLK2:
-			syncsrc = val & ARIZONA_CLK_32K_SRC_MASK;
-			break;
-		default:
-			syncsrc = -1;
-		}
+		syncsrc = fll->ref_src;
 
 		if (source == syncsrc)
 			syncsrc = -1;
@@ -1115,7 +1106,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 			if (ret != 0)
 				return ret;
 
-			ret = arizona_calc_fll(fll, &cfg, 32768, Fout);
+			ret = arizona_calc_fll(fll, &cfg, fll->ref_freq, Fout);
 			if (ret != 0)
 				return ret;
 		} else {
@@ -1178,6 +1169,7 @@ int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
 		     int ok_irq, struct arizona_fll *fll)
 {
 	int ret;
+	unsigned int val;
 
 	init_completion(&fll->ok);
 
@@ -1185,6 +1177,18 @@ int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
 	fll->base = base;
 	fll->arizona = arizona;
 
+	/* Configure default refclk to 32kHz if we have one */
+	regmap_read(arizona->regmap, ARIZONA_CLOCK_32K_1, &val);
+	switch (val & ARIZONA_CLK_32K_SRC_MASK) {
+	case ARIZONA_CLK_SRC_MCLK1:
+	case ARIZONA_CLK_SRC_MCLK2:
+		fll->ref_src = val & ARIZONA_CLK_32K_SRC_MASK;
+		break;
+	default:
+		fll->ref_src = -1;
+	}
+	fll->ref_freq = 32768;
+
 	snprintf(fll->lock_name, sizeof(fll->lock_name), "FLL%d lock", id);
 	snprintf(fll->clock_ok_name, sizeof(fll->clock_ok_name),
 		 "FLL%d clock OK", id);
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 116372c..124f9f0 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -201,6 +201,9 @@ struct arizona_fll {
 	unsigned int fref;
 	unsigned int fout;
 
+	int ref_src;
+	unsigned int ref_freq;
+
 	char lock_name[ARIZONA_FLL_NAME_LEN];
 	char clock_ok_name[ARIZONA_FLL_NAME_LEN];
 };
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
  2013-02-20 16:09 ` [PATCH 1/8] ASoC: arizona: Move selection of FLL REFCLK into init Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:31   ` Mark Brown
  2013-02-20 16:09 ` [PATCH 3/8] ASoC: arizona: Factor out check for enabled FLL Charles Keepax
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

This patch caches the current SYNCCLK settings in the arizona_fll struct
and uses these to simplify the code which determines which source should
be used for the REFCLK and SYNCCLK inputs.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |  101 ++++++++++++++++++++++----------------------
 sound/soc/codecs/arizona.h |    2 +
 2 files changed, 52 insertions(+), 51 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index c14e755..64d0335 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1078,15 +1078,39 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		    unsigned int Fref, unsigned int Fout)
 {
 	struct arizona *arizona = fll->arizona;
-	struct arizona_fll_cfg cfg, sync;
+	struct arizona_fll_cfg ref, sync;
 	unsigned int reg;
-	int syncsrc;
 	bool ena;
 	int ret;
 
 	if (fll->fref == Fref && fll->fout == Fout)
 		return 0;
 
+	if (fll->ref_src < 0 || fll->ref_src == source) {
+		if (Fout) {
+			ret = arizona_calc_fll(fll, &ref, Fref, Fout);
+			if (ret != 0)
+				return ret;
+		}
+
+		fll->sync_src = -1;
+		fll->ref_src = source;
+		fll->ref_freq = Fref;
+	} else if (fll->ref_src != source) {
+		if (Fout) {
+			ret = arizona_calc_fll(fll, &ref, fll->ref_freq, Fout);
+			if (ret != 0)
+				return ret;
+
+			ret = arizona_calc_fll(fll, &sync, Fref, Fout);
+			if (ret != 0)
+				return ret;
+		}
+
+		fll->sync_src = source;
+		fll->sync_freq = Fref;
+	}
+
 	ret = regmap_read(arizona->regmap, fll->base + 1, &reg);
 	if (ret != 0) {
 		arizona_fll_err(fll, "Failed to read current state: %d\n",
@@ -1096,24 +1120,32 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 	ena = reg & ARIZONA_FLL1_ENA;
 
 	if (Fout) {
-		syncsrc = fll->ref_src;
+		regmap_update_bits(arizona->regmap, fll->base + 5,
+				   ARIZONA_FLL1_OUTDIV_MASK,
+				   ref.outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
 
-		if (source == syncsrc)
-			syncsrc = -1;
+		arizona_apply_fll(arizona, fll->base, &ref, fll->ref_src);
+		if (fll->sync_src >= 0)
+			arizona_apply_fll(arizona, fll->base + 0x10, &sync,
+					  fll->sync_src);
 
-		if (syncsrc >= 0) {
-			ret = arizona_calc_fll(fll, &sync, Fref, Fout);
-			if (ret != 0)
-				return ret;
+		if (!ena)
+			pm_runtime_get(arizona->dev);
 
-			ret = arizona_calc_fll(fll, &cfg, fll->ref_freq, Fout);
-			if (ret != 0)
-				return ret;
-		} else {
-			ret = arizona_calc_fll(fll, &cfg, Fref, Fout);
-			if (ret != 0)
-				return ret;
-		}
+		/* Clear any pending completions */
+		try_wait_for_completion(&fll->ok);
+
+		regmap_update_bits(arizona->regmap, fll->base + 1,
+				   ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
+		if (fll->sync_src >= 0)
+			regmap_update_bits(arizona->regmap, fll->base + 0x11,
+					   ARIZONA_FLL1_SYNC_ENA,
+					   ARIZONA_FLL1_SYNC_ENA);
+
+		ret = wait_for_completion_timeout(&fll->ok,
+						  msecs_to_jiffies(250));
+		if (ret == 0)
+			arizona_fll_warn(fll, "Timed out waiting for lock\n");
 	} else {
 		regmap_update_bits(arizona->regmap, fll->base + 1,
 				   ARIZONA_FLL1_ENA, 0);
@@ -1122,42 +1154,8 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 
 		if (ena)
 			pm_runtime_put_autosuspend(arizona->dev);
-
-		fll->fref = Fref;
-		fll->fout = Fout;
-
-		return 0;
-	}
-
-	regmap_update_bits(arizona->regmap, fll->base + 5,
-			   ARIZONA_FLL1_OUTDIV_MASK,
-			   cfg.outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
-
-	if (syncsrc >= 0) {
-		arizona_apply_fll(arizona, fll->base, &cfg, syncsrc);
-		arizona_apply_fll(arizona, fll->base + 0x10, &sync, source);
-	} else {
-		arizona_apply_fll(arizona, fll->base, &cfg, source);
 	}
 
-	if (!ena)
-		pm_runtime_get(arizona->dev);
-
-	/* Clear any pending completions */
-	try_wait_for_completion(&fll->ok);
-
-	regmap_update_bits(arizona->regmap, fll->base + 1,
-			   ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
-	if (syncsrc >= 0)
-		regmap_update_bits(arizona->regmap, fll->base + 0x11,
-				   ARIZONA_FLL1_SYNC_ENA,
-				   ARIZONA_FLL1_SYNC_ENA);
-
-	ret = wait_for_completion_timeout(&fll->ok,
-					  msecs_to_jiffies(250));
-	if (ret == 0)
-		arizona_fll_warn(fll, "Timed out waiting for lock\n");
-
 	fll->fref = Fref;
 	fll->fout = Fout;
 
@@ -1176,6 +1174,7 @@ int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
 	fll->id = id;
 	fll->base = base;
 	fll->arizona = arizona;
+	fll->sync_src = -1;
 
 	/* Configure default refclk to 32kHz if we have one */
 	regmap_read(arizona->regmap, ARIZONA_CLOCK_32K_1, &val);
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 124f9f0..37766b5 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -201,6 +201,8 @@ struct arizona_fll {
 	unsigned int fref;
 	unsigned int fout;
 
+	int sync_src;
+	unsigned int sync_freq;
 	int ref_src;
 	unsigned int ref_freq;
 
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/8] ASoC: arizona: Factor out check for enabled FLL
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
  2013-02-20 16:09 ` [PATCH 1/8] ASoC: arizona: Move selection of FLL REFCLK into init Charles Keepax
  2013-02-20 16:09 ` [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:09 ` [PATCH 4/8] ASoC: arizona: Factor out FLL disable Charles Keepax
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

In preparation for additional features on the FLL this patch factors out
the code which checks if an FLL is currently enabled into a seperate
function.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 64d0335..0f86634 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1074,12 +1074,27 @@ static void arizona_apply_fll(struct arizona *arizona, unsigned int base,
 			   ARIZONA_FLL1_CTRL_UPD | cfg->n);
 }
 
+static bool arizona_is_enabled_fll(struct arizona_fll *fll)
+{
+	struct arizona *arizona = fll->arizona;
+	unsigned int reg;
+	int ret;
+
+	ret = regmap_read(arizona->regmap, fll->base + 1, &reg);
+	if (ret != 0) {
+		arizona_fll_err(fll, "Failed to read current state: %d\n",
+				ret);
+		return ret;
+	}
+
+	return reg & ARIZONA_FLL1_ENA;
+}
+
 int arizona_set_fll(struct arizona_fll *fll, int source,
 		    unsigned int Fref, unsigned int Fout)
 {
 	struct arizona *arizona = fll->arizona;
 	struct arizona_fll_cfg ref, sync;
-	unsigned int reg;
 	bool ena;
 	int ret;
 
@@ -1111,13 +1126,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		fll->sync_freq = Fref;
 	}
 
-	ret = regmap_read(arizona->regmap, fll->base + 1, &reg);
-	if (ret != 0) {
-		arizona_fll_err(fll, "Failed to read current state: %d\n",
-				ret);
-		return ret;
-	}
-	ena = reg & ARIZONA_FLL1_ENA;
+	ena = arizona_is_enabled_fll(fll);
 
 	if (Fout) {
 		regmap_update_bits(arizona->regmap, fll->base + 5,
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/8] ASoC: arizona: Factor out FLL disable
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (2 preceding siblings ...)
  2013-02-20 16:09 ` [PATCH 3/8] ASoC: arizona: Factor out check for enabled FLL Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:09 ` [PATCH 5/8] ASoC: arizona: Factor out FLL enable Charles Keepax
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

In preparation for additional features on the FLL this patch factors out
the code for disabling an FLL into a seperate function.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 0f86634..72f2f65 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1090,6 +1090,20 @@ static bool arizona_is_enabled_fll(struct arizona_fll *fll)
 	return reg & ARIZONA_FLL1_ENA;
 }
 
+static void arizona_disable_fll(struct arizona_fll *fll)
+{
+	struct arizona *arizona = fll->arizona;
+	bool change;
+
+	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);
+
+	if (change)
+		pm_runtime_put_autosuspend(arizona->dev);
+}
+
 int arizona_set_fll(struct arizona_fll *fll, int source,
 		    unsigned int Fref, unsigned int Fout)
 {
@@ -1156,13 +1170,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		if (ret == 0)
 			arizona_fll_warn(fll, "Timed out waiting for lock\n");
 	} else {
-		regmap_update_bits(arizona->regmap, fll->base + 1,
-				   ARIZONA_FLL1_ENA, 0);
-		regmap_update_bits(arizona->regmap, fll->base + 0x11,
-				   ARIZONA_FLL1_SYNC_ENA, 0);
-
-		if (ena)
-			pm_runtime_put_autosuspend(arizona->dev);
+		arizona_disable_fll(fll);
 	}
 
 	fll->fref = Fref;
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/8] ASoC: arizona: Factor out FLL enable
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (3 preceding siblings ...)
  2013-02-20 16:09 ` [PATCH 4/8] ASoC: arizona: Factor out FLL disable Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:09 ` [PATCH 6/8] ASoC: arizona: Improve suppression of noop FLL updates Charles Keepax
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

In preparation for additional features on the FLL this patch factors out
the code for enabling an FLL into a seperate function.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |   66 ++++++++++++++++++++++++--------------------
 1 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 72f2f65..7ad850c 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1090,6 +1090,41 @@ static bool arizona_is_enabled_fll(struct arizona_fll *fll)
 	return reg & ARIZONA_FLL1_ENA;
 }
 
+static void arizona_enable_fll(struct arizona_fll *fll,
+			      struct arizona_fll_cfg *ref,
+			      struct arizona_fll_cfg *sync)
+{
+	struct arizona *arizona = fll->arizona;
+	int ret;
+
+	regmap_update_bits(arizona->regmap, fll->base + 5,
+			   ARIZONA_FLL1_OUTDIV_MASK,
+			   ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
+
+	arizona_apply_fll(arizona, fll->base, ref, fll->ref_src);
+	if (fll->sync_src >= 0)
+		arizona_apply_fll(arizona, fll->base + 0x10, sync,
+				  fll->sync_src);
+
+	if (!arizona_is_enabled_fll(fll))
+		pm_runtime_get(arizona->dev);
+
+	/* Clear any pending completions */
+	try_wait_for_completion(&fll->ok);
+
+	regmap_update_bits(arizona->regmap, fll->base + 1,
+			   ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
+	if (fll->sync_src >= 0)
+		regmap_update_bits(arizona->regmap, fll->base + 0x11,
+				   ARIZONA_FLL1_SYNC_ENA,
+				   ARIZONA_FLL1_SYNC_ENA);
+
+	ret = wait_for_completion_timeout(&fll->ok,
+					  msecs_to_jiffies(250));
+	if (ret == 0)
+		arizona_fll_warn(fll, "Timed out waiting for lock\n");
+}
+
 static void arizona_disable_fll(struct arizona_fll *fll)
 {
 	struct arizona *arizona = fll->arizona;
@@ -1107,9 +1142,7 @@ static void arizona_disable_fll(struct arizona_fll *fll)
 int arizona_set_fll(struct arizona_fll *fll, int source,
 		    unsigned int Fref, unsigned int Fout)
 {
-	struct arizona *arizona = fll->arizona;
 	struct arizona_fll_cfg ref, sync;
-	bool ena;
 	int ret;
 
 	if (fll->fref == Fref && fll->fout == Fout)
@@ -1140,35 +1173,8 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		fll->sync_freq = Fref;
 	}
 
-	ena = arizona_is_enabled_fll(fll);
-
 	if (Fout) {
-		regmap_update_bits(arizona->regmap, fll->base + 5,
-				   ARIZONA_FLL1_OUTDIV_MASK,
-				   ref.outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
-
-		arizona_apply_fll(arizona, fll->base, &ref, fll->ref_src);
-		if (fll->sync_src >= 0)
-			arizona_apply_fll(arizona, fll->base + 0x10, &sync,
-					  fll->sync_src);
-
-		if (!ena)
-			pm_runtime_get(arizona->dev);
-
-		/* Clear any pending completions */
-		try_wait_for_completion(&fll->ok);
-
-		regmap_update_bits(arizona->regmap, fll->base + 1,
-				   ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
-		if (fll->sync_src >= 0)
-			regmap_update_bits(arizona->regmap, fll->base + 0x11,
-					   ARIZONA_FLL1_SYNC_ENA,
-					   ARIZONA_FLL1_SYNC_ENA);
-
-		ret = wait_for_completion_timeout(&fll->ok,
-						  msecs_to_jiffies(250));
-		if (ret == 0)
-			arizona_fll_warn(fll, "Timed out waiting for lock\n");
+		arizona_enable_fll(fll, &ref, &sync);
 	} else {
 		arizona_disable_fll(fll);
 	}
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/8] ASoC: arizona: Improve suppression of noop FLL updates
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (4 preceding siblings ...)
  2013-02-20 16:09 ` [PATCH 5/8] ASoC: arizona: Factor out FLL enable Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:09 ` [PATCH 7/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

Previously updates that only changes FLL source would be missed, this
patch corrects this. We also ensures that both REFCLK and SYNCCLK
frequency changes are considered, in preparation for future updates.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |   16 ++++++++++------
 sound/soc/codecs/arizona.h |    3 +--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 7ad850c..7283bda 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1145,10 +1145,12 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 	struct arizona_fll_cfg ref, sync;
 	int ret;
 
-	if (fll->fref == Fref && fll->fout == Fout)
-		return 0;
-
 	if (fll->ref_src < 0 || fll->ref_src == source) {
+		if (fll->sync_src == -1 &&
+		    fll->ref_src == source && fll->ref_freq == Fref &&
+		    fll->fout == Fout)
+			return 0;
+
 		if (Fout) {
 			ret = arizona_calc_fll(fll, &ref, Fref, Fout);
 			if (ret != 0)
@@ -1159,6 +1161,10 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		fll->ref_src = source;
 		fll->ref_freq = Fref;
 	} else if (fll->ref_src != source) {
+		if (fll->sync_src == source &&
+		    fll->sync_freq == Fref && fll->fout == Fout)
+			return 0;
+
 		if (Fout) {
 			ret = arizona_calc_fll(fll, &ref, fll->ref_freq, Fout);
 			if (ret != 0)
@@ -1172,6 +1178,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		fll->sync_src = source;
 		fll->sync_freq = Fref;
 	}
+	fll->fout = Fout;
 
 	if (Fout) {
 		arizona_enable_fll(fll, &ref, &sync);
@@ -1179,9 +1186,6 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 		arizona_disable_fll(fll);
 	}
 
-	fll->fref = Fref;
-	fll->fout = Fout;
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(arizona_set_fll);
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 37766b5..bedf12a 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -198,9 +198,8 @@ struct arizona_fll {
 	unsigned int base;
 	unsigned int vco_mult;
 	struct completion ok;
-	unsigned int fref;
-	unsigned int fout;
 
+	unsigned int fout;
 	int sync_src;
 	unsigned int sync_freq;
 	int ref_src;
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 7/8] ASoC: arizona: Add support for directly setting the FLL REFCLK
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (5 preceding siblings ...)
  2013-02-20 16:09 ` [PATCH 6/8] ASoC: arizona: Improve suppression of noop FLL updates Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:09 ` [PATCH 8/8] ASoC: arizona: Add convience define for clearing SYNCCLK Charles Keepax
  2013-02-20 16:44 ` [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Mark Brown
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

This patch allows the REFCLK to be set directly allowing much greater
flexibility in how the FLLs are configured.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |   39 +++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/arizona.h |    2 ++
 sound/soc/codecs/wm5102.c  |    6 ++++++
 sound/soc/codecs/wm5102.h  |    6 ++++--
 sound/soc/codecs/wm5110.c  |    6 ++++++
 sound/soc/codecs/wm5110.h  |    6 ++++--
 6 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 7283bda..b12a489 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1139,6 +1139,45 @@ static void arizona_disable_fll(struct arizona_fll *fll)
 		pm_runtime_put_autosuspend(arizona->dev);
 }
 
+int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
+			   unsigned int Fref, unsigned int Fout)
+{
+	struct arizona_fll_cfg ref, sync;
+	int ret;
+
+	if (source < 0)
+		return -EINVAL;
+
+	if (fll->ref_src == source && fll->ref_freq == Fref &&
+	    fll->fout == Fout)
+		return 0;
+
+	if (Fout) {
+		ret = arizona_calc_fll(fll, &ref, Fref, Fout);
+		if (ret != 0)
+			return ret;
+
+		if (fll->sync_src >= 0) {
+			ret = arizona_calc_fll(fll, &sync, fll->sync_freq, Fout);
+			if (ret != 0)
+				return ret;
+		}
+	}
+
+	fll->ref_src = source;
+	fll->ref_freq = Fref;
+	fll->fout = Fout;
+
+	if (Fout) {
+		arizona_enable_fll(fll, &ref, &sync);
+	} else {
+		arizona_disable_fll(fll);
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(arizona_set_fll_refclk);
+
 int arizona_set_fll(struct arizona_fll *fll, int source,
 		    unsigned int Fref, unsigned int Fout)
 {
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index bedf12a..f2ca41f 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -211,6 +211,8 @@ struct arizona_fll {
 
 extern int arizona_init_fll(struct arizona *arizona, int id, int base,
 			    int lock_irq, int ok_irq, struct arizona_fll *fll);
+extern int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
+				  unsigned int Fref, unsigned int Fout);
 extern int arizona_set_fll(struct arizona_fll *fll, int source,
 			   unsigned int Fref, unsigned int Fout);
 
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index ab69c83..6071673 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -1479,6 +1479,12 @@ static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
 		return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout);
 	case WM5102_FLL2:
 		return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout);
+	case WM5102_FLL1_REFCLK:
+		return arizona_set_fll_refclk(&wm5102->fll[0], source, Fref,
+					      Fout);
+	case WM5102_FLL2_REFCLK:
+		return arizona_set_fll_refclk(&wm5102->fll[1], source, Fref,
+					      Fout);
 	default:
 		return -EINVAL;
 	}
diff --git a/sound/soc/codecs/wm5102.h b/sound/soc/codecs/wm5102.h
index d30477f..adb3804 100644
--- a/sound/soc/codecs/wm5102.h
+++ b/sound/soc/codecs/wm5102.h
@@ -15,7 +15,9 @@
 
 #include "arizona.h"
 
-#define WM5102_FLL1 1
-#define WM5102_FLL2 2
+#define WM5102_FLL1        1
+#define WM5102_FLL2        2
+#define WM5102_FLL1_REFCLK 3
+#define WM5102_FLL2_REFCLK 4
 
 #endif
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index a163132..623e433 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -876,6 +876,12 @@ static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
 		return arizona_set_fll(&wm5110->fll[0], source, Fref, Fout);
 	case WM5110_FLL2:
 		return arizona_set_fll(&wm5110->fll[1], source, Fref, Fout);
+	case WM5110_FLL1_REFCLK:
+		return arizona_set_fll_refclk(&wm5110->fll[0], source, Fref,
+					      Fout);
+	case WM5110_FLL2_REFCLK:
+		return arizona_set_fll_refclk(&wm5110->fll[1], source, Fref,
+					      Fout);
 	default:
 		return -EINVAL;
 	}
diff --git a/sound/soc/codecs/wm5110.h b/sound/soc/codecs/wm5110.h
index 75e9351..e6c0cd4 100644
--- a/sound/soc/codecs/wm5110.h
+++ b/sound/soc/codecs/wm5110.h
@@ -15,7 +15,9 @@
 
 #include "arizona.h"
 
-#define WM5110_FLL1 1
-#define WM5110_FLL2 2
+#define WM5110_FLL1        1
+#define WM5110_FLL2        2
+#define WM5110_FLL1_REFCLK 3
+#define WM5110_FLL2_REFCLK 4
 
 #endif
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 8/8] ASoC: arizona: Add convience define for clearing SYNCCLK
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (6 preceding siblings ...)
  2013-02-20 16:09 ` [PATCH 7/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
@ 2013-02-20 16:09 ` Charles Keepax
  2013-02-20 16:44 ` [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Mark Brown
  8 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:09 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, tiwai, patches, lgirdwood, Charles Keepax

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 sound/soc/codecs/arizona.c |    8 ++++----
 sound/soc/codecs/arizona.h |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index b12a489..6a00904 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1185,7 +1185,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 	int ret;
 
 	if (fll->ref_src < 0 || fll->ref_src == source) {
-		if (fll->sync_src == -1 &&
+		if (fll->sync_src == ARIZONA_FLL_SRC_NONE &&
 		    fll->ref_src == source && fll->ref_freq == Fref &&
 		    fll->fout == Fout)
 			return 0;
@@ -1196,7 +1196,7 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
 				return ret;
 		}
 
-		fll->sync_src = -1;
+		fll->sync_src = ARIZONA_FLL_SRC_NONE;
 		fll->ref_src = source;
 		fll->ref_freq = Fref;
 	} else if (fll->ref_src != source) {
@@ -1240,7 +1240,7 @@ int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
 	fll->id = id;
 	fll->base = base;
 	fll->arizona = arizona;
-	fll->sync_src = -1;
+	fll->sync_src = ARIZONA_FLL_SRC_NONE;
 
 	/* Configure default refclk to 32kHz if we have one */
 	regmap_read(arizona->regmap, ARIZONA_CLOCK_32K_1, &val);
@@ -1250,7 +1250,7 @@ int arizona_init_fll(struct arizona *arizona, int id, int base, int lock_irq,
 		fll->ref_src = val & ARIZONA_CLK_32K_SRC_MASK;
 		break;
 	default:
-		fll->ref_src = -1;
+		fll->ref_src = ARIZONA_FLL_SRC_NONE;
 	}
 	fll->ref_freq = 32768;
 
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index f2ca41f..3f84943 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -32,6 +32,7 @@
 #define ARIZONA_CLK_SRC_AIF2BCLK 0x9
 #define ARIZONA_CLK_SRC_AIF3BCLK 0xa
 
+#define ARIZONA_FLL_SRC_NONE      -1
 #define ARIZONA_FLL_SRC_MCLK1      0
 #define ARIZONA_FLL_SRC_MCLK2      1
 #define ARIZONA_FLL_SRC_SLIMCLK    3
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values
  2013-02-20 16:09 ` [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values Charles Keepax
@ 2013-02-20 16:31   ` Mark Brown
  2013-02-20 16:53     ` Charles Keepax
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2013-02-20 16:31 UTC (permalink / raw)
  To: Charles Keepax; +Cc: tiwai, alsa-devel, patches, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 227 bytes --]

On Wed, Feb 20, 2013 at 04:09:33PM +0000, Charles Keepax wrote:

> +	if (fll->ref_src < 0 || fll->ref_src == source) {

> +	} else if (fll->ref_src != source) {

> +	}

This appears to be missing a final error checking case...

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK
  2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
                   ` (7 preceding siblings ...)
  2013-02-20 16:09 ` [PATCH 8/8] ASoC: arizona: Add convience define for clearing SYNCCLK Charles Keepax
@ 2013-02-20 16:44 ` Mark Brown
  2013-02-20 17:22   ` Charles Keepax
  8 siblings, 1 reply; 13+ messages in thread
From: Mark Brown @ 2013-02-20 16:44 UTC (permalink / raw)
  To: Charles Keepax; +Cc: tiwai, alsa-devel, patches, lgirdwood


[-- Attachment #1.1: Type: text/plain, Size: 505 bytes --]

On Wed, Feb 20, 2013 at 04:09:31PM +0000, Charles Keepax wrote:
> This patch series adds support for specifying the source of
> REFCLK directly for Wolfson Arizona based devices. This should
> allow for improved performance by using the highest available
> REFCLK source. Should the REFCLK source not be directly specified
> then the patches will default to the older behaviour of using the
> 32kHz clock for REFCLK.

These don't apply to either topic/arizona (where I'd expect them to go)
or ASoC -next.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values
  2013-02-20 16:31   ` Mark Brown
@ 2013-02-20 16:53     ` Charles Keepax
  0 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 16:53 UTC (permalink / raw)
  To: Mark Brown; +Cc: tiwai, alsa-devel, patches, lgirdwood

On Wed, Feb 20, 2013 at 04:31:06PM +0000, Mark Brown wrote:
> On Wed, Feb 20, 2013 at 04:09:33PM +0000, Charles Keepax wrote:
> 
> > +	if (fll->ref_src < 0 || fll->ref_src == source) {
> 
> > +	} else if (fll->ref_src != source) {
> 
> > +	}
> 
> This appears to be missing a final error checking case...

Apologies that else if is completely redundant and should just
be an if. I will fix and resend.

Charles

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK
  2013-02-20 16:44 ` [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Mark Brown
@ 2013-02-20 17:22   ` Charles Keepax
  0 siblings, 0 replies; 13+ messages in thread
From: Charles Keepax @ 2013-02-20 17:22 UTC (permalink / raw)
  To: Mark Brown; +Cc: tiwai, alsa-devel, patches, lgirdwood

On Wed, Feb 20, 2013 at 04:44:09PM +0000, Mark Brown wrote:
> These don't apply to either topic/arizona (where I'd expect them to go)
> or ASoC -next.

Apologies not sure what happened there they seem to apply to
for-next for me, since I am sending a v2 anyway I will rebase on
topic/arizona.

Charles

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-02-20 17:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-20 16:09 [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
2013-02-20 16:09 ` [PATCH 1/8] ASoC: arizona: Move selection of FLL REFCLK into init Charles Keepax
2013-02-20 16:09 ` [PATCH 2/8] ASoC: arizona: Tidy up SYNCCLK selection and cache values Charles Keepax
2013-02-20 16:31   ` Mark Brown
2013-02-20 16:53     ` Charles Keepax
2013-02-20 16:09 ` [PATCH 3/8] ASoC: arizona: Factor out check for enabled FLL Charles Keepax
2013-02-20 16:09 ` [PATCH 4/8] ASoC: arizona: Factor out FLL disable Charles Keepax
2013-02-20 16:09 ` [PATCH 5/8] ASoC: arizona: Factor out FLL enable Charles Keepax
2013-02-20 16:09 ` [PATCH 6/8] ASoC: arizona: Improve suppression of noop FLL updates Charles Keepax
2013-02-20 16:09 ` [PATCH 7/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Charles Keepax
2013-02-20 16:09 ` [PATCH 8/8] ASoC: arizona: Add convience define for clearing SYNCCLK Charles Keepax
2013-02-20 16:44 ` [PATCH 0/8] ASoC: arizona: Add support for directly setting the FLL REFCLK Mark Brown
2013-02-20 17:22   ` Charles Keepax

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).