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.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
Charles Keepax 2013-02-20 17:28:34 +00:00 committed by Mark Brown
parent 6dbe51c251
commit 19b34bdc6d
2 changed files with 19 additions and 12 deletions

View File

@ -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);

View File

@ -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];
};