Commit f641aec6 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: arizona: Calculate OUTDIV first

OUTDIV will remain unchanged whilst the rest of the FLL configuration is
calculated so do this first.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 8ccefcd2
...@@ -1415,6 +1415,18 @@ static int arizona_calc_fll(struct arizona_fll *fll, ...@@ -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); 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 */ /* Fref must be <=13.5MHz */
div = 1; div = 1;
cfg->refdiv = 0; cfg->refdiv = 0;
...@@ -1429,18 +1441,6 @@ static int arizona_calc_fll(struct arizona_fll *fll, ...@@ -1429,18 +1441,6 @@ static int arizona_calc_fll(struct arizona_fll *fll,
/* Apply the division for our remaining calculations */ /* Apply the division for our remaining calculations */
Fref /= div; 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 */ /* Find an appropraite FLL_FRATIO and factor it out of the target */
for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) { for (i = 0; i < ARRAY_SIZE(fll_fratios); i++) {
if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) { if (fll_fratios[i].min <= Fref && Fref <= fll_fratios[i].max) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment