ASoC: Support FLL input clock selection on WM8994
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 20 Apr 2010 03:56:18 +0000 (12:56 +0900)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 20 Apr 2010 16:41:26 +0000 (01:41 +0900)
The WM8994 FLL can be clocked from one of four inputs, the two MCLKs and
the LRCLK and BCLK of the AIF associated with the FLL. Allow all four
inputs to be used rather than defaulting to MCLK1.

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

index 29c4cfccd6b911ff748462f9a1008a0a9c731275..a27b2ff769d9f5c7f3f9e40789449a16f951a048 100644 (file)
@@ -2843,6 +2843,16 @@ static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src,
                return -EINVAL;
        }
 
+       switch (src) {
+       case WM8994_FLL_SRC_MCLK1:
+       case WM8994_FLL_SRC_MCLK2:
+       case WM8994_FLL_SRC_LRCLK:
+       case WM8994_FLL_SRC_BCLK:
+               break;
+       default:
+               return -EINVAL;
+       }
+
        /* Are we changing anything? */
        if (wm8994->fll[id].src == src &&
            wm8994->fll[id].in == freq_in && wm8994->fll[id].out == freq_out)
@@ -2883,8 +2893,10 @@ static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src,
                                    fll.n << WM8994_FLL1_N_SHIFT);
 
        snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset,
-                           WM8994_FLL1_REFCLK_DIV_MASK,
-                           fll.clk_ref_div << WM8994_FLL1_REFCLK_DIV_SHIFT);
+                           WM8994_FLL1_REFCLK_DIV_MASK |
+                           WM8994_FLL1_REFCLK_SRC_MASK,
+                           (fll.clk_ref_div << WM8994_FLL1_REFCLK_DIV_SHIFT) |
+                           (src - 1));
 
        /* Enable (with fractional mode if required) */
        if (freq_out) {
@@ -2899,6 +2911,7 @@ static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src,
 
        wm8994->fll[id].in = freq_in;
        wm8994->fll[id].out = freq_out;
+       wm8994->fll[id].src = src;
 
        /* Enable any gated AIF clocks */
        snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1,
index 79d5915ae4b38d1e6dbd582ce4ed73488195493b..7072dc539354fbd6d9ac6d5bd5b62251eedd23b2 100644 (file)
@@ -23,6 +23,11 @@ extern struct snd_soc_dai wm8994_dai[];
 #define WM8994_FLL1 1
 #define WM8994_FLL2 2
 
+#define WM8994_FLL_SRC_MCLK1  1
+#define WM8994_FLL_SRC_MCLK2  2
+#define WM8994_FLL_SRC_LRCLK  3
+#define WM8994_FLL_SRC_BCLK   4
+
 int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
                      int micbias, int det, int shrt);