Skip to contentSkip to conversation

Add support for directly setting the FLL REFCLK

PATCH Applied Charles Keepax 2 participants 10 messages Feb 20, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Add support for directly setting the FLL REFCLK

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(-)
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH v2 1/8 ASoC: arizona: Move selection of FLL REFCLK into init

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.

---
 sound/soc/codecs/arizona.c |   28 ++++++++++++++++------------
 sound/soc/codecs/arizona.h |    3 +++
 2 files changed, 19 insertions(+), 12 deletions(-)
sound/soc/codecs/arizona.c +16 -12
index ac948a6..c14e755 100644
@@ -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);
sound/soc/codecs/arizona.h +3 -0
index 116372c..124f9f0 100644
@@ -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];
 };
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH v2 2/8 ASoC: arizona: Tidy up SYNCCLK selection and cache values

In reply to 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.

---
 sound/soc/codecs/arizona.c |  101 ++++++++++++++++++++++----------------------
 sound/soc/codecs/arizona.h |    2 +
 2 files changed, 52 insertions(+), 51 deletions(-)
sound/soc/codecs/arizona.c +50 -51
index c14e755..03076ef 100644
@@ -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 (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);
sound/soc/codecs/arizona.h +2 -0
index 124f9f0..37766b5 100644
@@ -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;
 
Signature · 1 line
1.7.2.5
#3 lore raw

PATCH v2 3/8 ASoC: arizona: Factor out check for enabled FLL

In reply to 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.

---
 sound/soc/codecs/arizona.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)
sound/soc/codecs/arizona.c +17 -8
index 03076ef..4640bcc 100644
@@ -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,
Signature · 1 line
1.7.2.5
#4 lore raw

PATCH v2 4/8 ASoC: arizona: Factor out FLL disable

In reply to Charles Keepax

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

---
 sound/soc/codecs/arizona.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
sound/soc/codecs/arizona.c +15 -7
index 4640bcc..a8821a8 100644
@@ -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;
Signature · 1 line
1.7.2.5
#5 lore raw

PATCH v2 5/8 ASoC: arizona: Factor out FLL enable

In reply to Charles Keepax

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

---
 sound/soc/codecs/arizona.c |   66 ++++++++++++++++++++++++--------------------
 1 files changed, 36 insertions(+), 30 deletions(-)
sound/soc/codecs/arizona.c +36 -30
index a8821a8..e770945 100644
@@ -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);
 	}
Signature · 1 line
1.7.2.5
#6 lore raw

PATCH v2 6/8 ASoC: arizona: Improve suppression of noop FLL updates

In reply to 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.

---
 sound/soc/codecs/arizona.c |   16 ++++++++++------
 sound/soc/codecs/arizona.h |    3 +--
 2 files changed, 11 insertions(+), 8 deletions(-)
sound/soc/codecs/arizona.c +10 -6
index e770945..149e44f 100644
@@ -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->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);
sound/soc/codecs/arizona.h +1 -2
index 37766b5..bedf12a 100644
@@ -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;
Signature · 1 line
1.7.2.5
#7 lore raw

PATCH v2 7/8 ASoC: arizona: Add support for directly setting the FLL REFCLK

In reply to Charles Keepax

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

---
 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(-)
sound/soc/codecs/arizona.c +39 -0
index 149e44f..2bebfae 100644
@@ -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)
 {
sound/soc/codecs/arizona.h +2 -0
index bedf12a..f2ca41f 100644
@@ -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);
 
sound/soc/codecs/wm5102.c +6 -0
index ab69c83..6071673 100644
@@ -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;
 	}
sound/soc/codecs/wm5102.h +4 -2
index d30477f..adb3804 100644
@@ -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
sound/soc/codecs/wm5110.c +6 -0
index a163132..623e433 100644
@@ -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;
 	}
sound/soc/codecs/wm5110.h +4 -2
index 75e9351..e6c0cd4 100644
@@ -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
Signature · 1 line
1.7.2.5
#8 lore raw

PATCH v2 8/8 ASoC: arizona: Add convience define for clearing SYNCCLK

In reply to Charles Keepax
---
 sound/soc/codecs/arizona.c |    8 ++++----
 sound/soc/codecs/arizona.h |    1 +
 2 files changed, 5 insertions(+), 4 deletions(-)
sound/soc/codecs/arizona.c +4 -4
index 2bebfae..6837863 100644
@@ -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 {
@@ -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;
 
sound/soc/codecs/arizona.h +1 -0
index f2ca41f..3f84943 100644
@@ -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
Signature · 1 line
1.7.2.5
Applied
#9 lore raw
In reply to Charles Keepax
Quoted 2 lines · Charles Keepax

This patch series adds support for specifying the source of REFCLK directly for Wolfson Arizona based devices. This should

Applied all, thanks.