diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index c55bf9208754..0827b7e65ac1 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c @@ -7,6 +7,7 @@ * Author: Liam Girdwood */ +#include #include #include #include @@ -27,6 +28,7 @@ struct wm8974_priv { unsigned int mclk; unsigned int fs; + struct clk *mclk_in; }; static const struct reg_default wm8974_reg_defaults[] = { @@ -617,8 +619,10 @@ static int wm8974_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); u16 power1 = snd_soc_component_read(component, WM8974_POWER1); + clk_prepare_enable(priv->mclk_in); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { power1 |= 0x10; snd_soc_component_write(component, WM8974_POWER1, power1); @@ -631,12 +635,14 @@ static void wm8974_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); u16 power1 = snd_soc_component_read(component, WM8974_POWER1); if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { power1 &= ~0x10; snd_soc_component_write(component, WM8974_POWER1, power1); } + clk_disable_unprepare(priv->mclk_in); } #define WM8974_RATES (SNDRV_PCM_RATE_8000_48000) @@ -730,6 +736,10 @@ static int wm8974_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); + priv->mclk_in = devm_clk_get(&i2c->dev, "mclk"); + if (IS_ERR(priv->mclk_in)) + return PTR_ERR(priv->mclk_in); + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8974, &wm8974_dai, 1);