Skip to content

Commit

Permalink
ASoC: wm2000: Integrate with clock API
Browse files Browse the repository at this point in the history
Request MCLK as a clock and then enable it when carrying out a state
transtion and while ANC is active, minimising system power consumption
in idle modes.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
broonie committed Dec 24, 2012
1 parent a49f0d1 commit 514cfd6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion sound/soc/codecs/wm2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/firmware.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
Expand Down Expand Up @@ -62,6 +63,7 @@ enum wm2000_anc_mode {
struct wm2000_priv {
struct i2c_client *i2c;
struct regmap *regmap;
struct clk *mclk;

struct regulator_bulk_data supplies[WM2000_NUM_SUPPLIES];

Expand Down Expand Up @@ -550,6 +552,15 @@ static int wm2000_anc_transition(struct wm2000_priv *wm2000,
return -EINVAL;
}

/* Maintain clock while active */
if (anc_transitions[i].source == ANC_OFF) {
ret = clk_prepare_enable(wm2000->mclk);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to enable MCLK: %d\n", ret);
return ret;
}
}

for (j = 0; j < ARRAY_SIZE(anc_transitions[j].step); j++) {
if (!anc_transitions[i].step[j])
break;
Expand All @@ -559,7 +570,10 @@ static int wm2000_anc_transition(struct wm2000_priv *wm2000,
return ret;
}

return 0;
if (anc_transitions[i].dest == ANC_OFF)
clk_disable_unprepare(wm2000->mclk);

return ret;
}

static int wm2000_anc_set_mode(struct wm2000_priv *wm2000)
Expand Down Expand Up @@ -823,6 +837,13 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
reg = wm2000_read(i2c, WM2000_REG_REVISON);
dev_info(&i2c->dev, "revision %c\n", reg + 'A');

wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK");
if (IS_ERR(wm2000->mclk)) {
ret = PTR_ERR(wm2000->mclk);
dev_err(&i2c->dev, "Failed to get MCLK: %d\n", ret);
goto err_supplies;
}

filename = "wm2000_anc.bin";
pdata = dev_get_platdata(&i2c->dev);
if (pdata) {
Expand Down

0 comments on commit 514cfd6

Please sign in to comment.