aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/codecs/arizona.c
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-02-20 17:28:38 +0000
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-04 11:01:00 +0800
commit357228153b4a158bdeb05f1c46ee13ef60a675a6 (patch)
tree7a95ba002e72198ac8cff85145e57a85da559a6f /sound/soc/codecs/arizona.c
parent7604054e13897c2da3570e33a67ecb76462212d8 (diff)
ASoC: arizona: Factor out FLL enable
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> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/arizona.c')
-rw-r--r--sound/soc/codecs/arizona.c66
1 files changed, 36 insertions, 30 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index a8821a819ad..e770945fa01 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);
}