summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorNicolin Chen <nicoleotsuka@gmail.com>2014-07-29 18:38:39 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-01-15 21:17:48 -0600
commit033319aeae3a2df09f934ed664c20f38642e5b06 (patch)
tree3d08854aa5295c89e042ab6561dbe4b8a6d3d42e /sound
parent6c90115e5a8a50cd4e0627bf5941bf6e7761a097 (diff)
ASoC: wm8962: Let CODEC driver enable and disable its own MCLK
snd_soc_open() will trigger pm_runtime resume() which will then enable the regulator and initialization. So we should make sure the MCLK is enabled before this resume(). Previously we let the machine driver get the clock and enable it in its probe(). However, considering about power saving, it'll be better to enable it when it's going to be used and disable it after using. So this patch just simply adds clk_get() and clk_enable() to WM8962 driver. Meanwhile, it marks clock pointer to NULL if no clock assigned to it so it will not break any current function. Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com> Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit d7821953cfe9803c593a682320468ce2de862803)
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/wm8962.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index cf77036e43c4..7006646eaeb9 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
+#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/gcd.h>
@@ -3536,6 +3537,8 @@ static int wm8962_set_pdata_from_of(struct i2c_client *i2c,
pdata->gpio_init[i] = 0x0;
}
+ pdata->mclk = devm_clk_get(&i2c->dev, NULL);
+
return 0;
}
@@ -3567,6 +3570,14 @@ static int wm8962_i2c_probe(struct i2c_client *i2c,
return ret;
}
+ /* Mark the mclk pointer to NULL if no mclk assigned */
+ if (IS_ERR(wm8962->pdata.mclk)) {
+ /* But do not ignore the request for probe defer */
+ if (PTR_ERR(wm8962->pdata.mclk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ wm8962->pdata.mclk = NULL;
+ }
+
for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
wm8962->supplies[i].supply = wm8962_supply_names[i];
@@ -3775,6 +3786,12 @@ static int wm8962_runtime_resume(struct device *dev)
struct wm8962_priv *wm8962 = dev_get_drvdata(dev);
int ret;
+ ret = clk_prepare_enable(wm8962->pdata.mclk);
+ if (ret) {
+ dev_err(dev, "Failed to enable MCLK: %d\n", ret);
+ return ret;
+ }
+
ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
wm8962->supplies);
if (ret != 0) {
@@ -3834,6 +3851,8 @@ static int wm8962_runtime_suspend(struct device *dev)
regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies),
wm8962->supplies);
+ clk_disable_unprepare(wm8962->pdata.mclk);
+
return 0;
}
#endif