Skip to content

Commit

Permalink
mfd: arizona: Fully support the use of MCLK1 as the 32kHz clock source
Browse files Browse the repository at this point in the history
MCLK1 is not in the AoD power domain so if it is used as the 32kHz clock
source we need to hold a runtime PM reference to keep the device from going
into low power mode.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Mark Brown authored and Samuel Ortiz committed Apr 8, 2013
1 parent 7adafc5 commit 247fa19
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions drivers/mfd/arizona-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ int arizona_clk32k_enable(struct arizona *arizona)

arizona->clk32k_ref++;

if (arizona->clk32k_ref == 1)
if (arizona->clk32k_ref == 1) {
switch (arizona->pdata.clk32k_src) {
case ARIZONA_32KZ_MCLK1:
ret = pm_runtime_get_sync(arizona->dev);
if (ret != 0)
goto out;
break;
}

ret = regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
ARIZONA_CLK_32K_ENA,
ARIZONA_CLK_32K_ENA);
}

out:
if (ret != 0)
arizona->clk32k_ref--;

Expand All @@ -63,10 +73,17 @@ int arizona_clk32k_disable(struct arizona *arizona)

arizona->clk32k_ref--;

if (arizona->clk32k_ref == 0)
if (arizona->clk32k_ref == 0) {
regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
ARIZONA_CLK_32K_ENA, 0);

switch (arizona->pdata.clk32k_src) {
case ARIZONA_32KZ_MCLK1:
pm_runtime_put_sync(arizona->dev);
break;
}
}

mutex_unlock(&arizona->clk_lock);

return ret;
Expand Down

0 comments on commit 247fa19

Please sign in to comment.