Commit 5a3935c7 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown

ASoC: arizona: Calculate FLL gain last

No part of the FLL calculation depends on the value determined for the
gain but the gain does depend on other values. In preparation for future
updates this patch moves the gain to be the last thing calculated.
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent f641aec6
...@@ -1455,18 +1455,6 @@ static int arizona_calc_fll(struct arizona_fll *fll, ...@@ -1455,18 +1455,6 @@ static int arizona_calc_fll(struct arizona_fll *fll,
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < ARRAY_SIZE(fll_gains); i++) {
if (fll_gains[i].min <= Fref && Fref <= fll_gains[i].max) {
cfg->gain = fll_gains[i].gain;
break;
}
}
if (i == ARRAY_SIZE(fll_gains)) {
arizona_fll_err(fll, "Unable to find gain for Fref=%uHz\n",
Fref);
return -EINVAL;
}
cfg->n = target / (ratio * Fref); cfg->n = target / (ratio * Fref);
if (target % (ratio * Fref)) { if (target % (ratio * Fref)) {
...@@ -1490,6 +1478,18 @@ static int arizona_calc_fll(struct arizona_fll *fll, ...@@ -1490,6 +1478,18 @@ static int arizona_calc_fll(struct arizona_fll *fll,
cfg->lambda >>= 1; cfg->lambda >>= 1;
} }
for (i = 0; i < ARRAY_SIZE(fll_gains); i++) {
if (fll_gains[i].min <= Fref && Fref <= fll_gains[i].max) {
cfg->gain = fll_gains[i].gain;
break;
}
}
if (i == ARRAY_SIZE(fll_gains)) {
arizona_fll_err(fll, "Unable to find gain for Fref=%uHz\n",
Fref);
return -EINVAL;
}
arizona_fll_dbg(fll, "N=%x THETA=%x LAMBDA=%x\n", arizona_fll_dbg(fll, "N=%x THETA=%x LAMBDA=%x\n",
cfg->n, cfg->theta, cfg->lambda); cfg->n, cfg->theta, cfg->lambda);
arizona_fll_dbg(fll, "FRATIO=%x(%d) OUTDIV=%x REFCLK_DIV=%x\n", arizona_fll_dbg(fll, "FRATIO=%x(%d) OUTDIV=%x REFCLK_DIV=%x\n",
......
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