Commit 39fb51a1 authored by Mark Brown's avatar Mark Brown

ASoC: Implement runtime PM for WM8994/58

This allows us to communicate our power management state back to the
parent device, allowing it to do a full power down when the device is
idle.
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: default avatarLiam Girdwood <lrg@slimlogic.co.uk>
parent 2e19b0c8
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
...@@ -1803,6 +1804,8 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, ...@@ -1803,6 +1804,8 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) {
pm_runtime_get_sync(codec->dev);
/* Tweak DC servo and DSP configuration for /* Tweak DC servo and DSP configuration for
* improved performance. */ * improved performance. */
if (control->type == WM8994 && wm8994->revision < 4) { if (control->type == WM8994 && wm8994->revision < 4) {
...@@ -1878,6 +1881,8 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, ...@@ -1878,6 +1881,8 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
WM8994_STARTUP_BIAS_ENA | WM8994_STARTUP_BIAS_ENA |
WM8994_VMID_BUF_ENA | WM8994_VMID_BUF_ENA |
WM8994_VMID_RAMP_MASK, 0); WM8994_VMID_RAMP_MASK, 0);
pm_runtime_put(codec->dev);
} }
break; break;
} }
...@@ -2780,6 +2785,9 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -2780,6 +2785,9 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994->pdata = dev_get_platdata(codec->dev->parent); wm8994->pdata = dev_get_platdata(codec->dev->parent);
wm8994->codec = codec; wm8994->codec = codec;
pm_runtime_enable(codec->dev);
pm_runtime_resume(codec->dev);
/* Read our current status back from the chip - we don't want to /* Read our current status back from the chip - we don't want to
* reset as this may interfere with the GPIO or LDO operation. */ * reset as this may interfere with the GPIO or LDO operation. */
for (i = 0; i < WM8994_CACHE_SIZE; i++) { for (i = 0; i < WM8994_CACHE_SIZE; i++) {
...@@ -2995,6 +3003,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) ...@@ -2995,6 +3003,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
wm8994_set_bias_level(codec, SND_SOC_BIAS_OFF); wm8994_set_bias_level(codec, SND_SOC_BIAS_OFF);
pm_runtime_disable(codec->dev);
switch (control->type) { switch (control->type) {
case WM8994: case WM8994:
wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT,
......
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