ASoC: wm8994: Restore AIFnCLK after reducing it for low clock rates
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 29 Jan 2013 15:17:12 +0000 (23:17 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Thu, 21 Mar 2013 20:37:09 +0000 (21:37 +0100)
This helps to ensure a smooth startup when we restore.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm8994.h

index 318ea64..1c02a47 100644 (file)
@@ -2268,10 +2268,26 @@ out:
         */
        if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) {
                dev_dbg(codec->dev, "Configuring AIFs for 128fs\n");
+
+               wm8994->aifdiv[0] = snd_soc_read(codec, WM8994_AIF1_RATE)
+                       & WM8994_AIF1CLK_RATE_MASK;
+               wm8994->aifdiv[1] = snd_soc_read(codec, WM8994_AIF2_RATE)
+                       & WM8994_AIF1CLK_RATE_MASK;
+
                snd_soc_update_bits(codec, WM8994_AIF1_RATE,
                                    WM8994_AIF1CLK_RATE_MASK, 0x1);
                snd_soc_update_bits(codec, WM8994_AIF2_RATE,
                                    WM8994_AIF2CLK_RATE_MASK, 0x1);
+       } else if (wm8994->aifdiv[0]) {
+               snd_soc_update_bits(codec, WM8994_AIF1_RATE,
+                                   WM8994_AIF1CLK_RATE_MASK,
+                                   wm8994->aifdiv[0]);
+               snd_soc_update_bits(codec, WM8994_AIF2_RATE,
+                                   WM8994_AIF2CLK_RATE_MASK,
+                                   wm8994->aifdiv[1]);
+
+               wm8994->aifdiv[0] = 0;
+               wm8994->aifdiv[1] = 0;
        }
 
        return 0;
@@ -2368,10 +2384,26 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
         */
        if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) {
                dev_dbg(codec->dev, "Configuring AIFs for 128fs\n");
+
+               wm8994->aifdiv[0] = snd_soc_read(codec, WM8994_AIF1_RATE)
+                       & WM8994_AIF1CLK_RATE_MASK;
+               wm8994->aifdiv[1] = snd_soc_read(codec, WM8994_AIF2_RATE)
+                       & WM8994_AIF1CLK_RATE_MASK;
+
                snd_soc_update_bits(codec, WM8994_AIF1_RATE,
                                    WM8994_AIF1CLK_RATE_MASK, 0x1);
                snd_soc_update_bits(codec, WM8994_AIF2_RATE,
                                    WM8994_AIF2CLK_RATE_MASK, 0x1);
+       } else if (wm8994->aifdiv[0]) {
+               snd_soc_update_bits(codec, WM8994_AIF1_RATE,
+                                   WM8994_AIF1CLK_RATE_MASK,
+                                   wm8994->aifdiv[0]);
+               snd_soc_update_bits(codec, WM8994_AIF2_RATE,
+                                   WM8994_AIF2CLK_RATE_MASK,
+                                   wm8994->aifdiv[1]);
+
+               wm8994->aifdiv[0] = 0;
+               wm8994->aifdiv[1] = 0;
        }
 
        return 0;
index 45f1927..928e2c2 100644 (file)
@@ -79,6 +79,7 @@ struct wm8994_priv {
        int sysclk_rate[2];
        int mclk[2];
        int aifclk[2];
+       int aifdiv[2];
        int channels[2];
        struct wm8994_fll_config fll[2], fll_suspend[2];
        struct completion fll_locked[2];