Skip to content

Commit

Permalink
ASoC: arizona: Calculate OUTDIV first
Browse files Browse the repository at this point in the history
OUTDIV will remain unchanged whilst the rest of the FLL configuration is
calculated so do this first.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Charles Keepax authored and Mark Brown committed Mar 9, 2014
1 parent 8ccefcd commit f641aec
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions sound/soc/codecs/arizona.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,18 @@ static int arizona_calc_fll(struct arizona_fll *fll,

arizona_fll_dbg(fll, "Fref=%u Fout=%u\n", Fref, fll->fout);

/* Fvco should be over the targt; don't check the upper bound */
div = ARIZONA_FLL_MIN_OUTDIV;
while (fll->fout * div < ARIZONA_FLL_MIN_FVCO * fll->vco_mult) {
div++;
if (div > ARIZONA_FLL_MAX_OUTDIV)
return -EINVAL;
}
target = fll->fout * div / fll->vco_mult;
cfg->outdiv = div;

arizona_fll_dbg(fll, "Fvco=%dHz\n", target);

/* Fref must be <=13.5MHz */
div = 1;
cfg->refdiv = 0;
Expand All @@ -1429,18 +1441,6 @@ static int arizona_calc_fll(struct arizona_fll *fll,
/* Apply the division for our remaining calculations */
Fref /= div;

/* Fvco should be over the targt; don't check the upper bound */
div = ARIZONA_FLL_MIN_OUTDIV;
while (fll->fout * div < ARIZONA_FLL_MIN_FVCO * fll->vco_mult) {
div++;
if (div > ARIZONA_FLL_MAX_OUTDIV)
return -EINVAL;
}
target = fll->fout * div / fll->vco_mult;
cfg->outdiv = div;

arizona_fll_dbg(fll, "Fvco=%dHz\n", target);

/* Find an appropraite FLL_FRATIO and factor it out of the target */
for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) {
if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) {
Expand Down

0 comments on commit f641aec

Please sign in to comment.