ASoC: arizona: Add support for directly setting the FLL REFCLK
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Wed, 20 Feb 2013 17:28:40 +0000 (17:28 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Mon, 4 Mar 2013 03:01:00 +0000 (11:01 +0800)
This patch allows the REFCLK to be set directly allowing much greater
flexibility in how the FLLs are configured.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
sound/soc/codecs/arizona.c
sound/soc/codecs/arizona.h
sound/soc/codecs/wm5102.c
sound/soc/codecs/wm5102.h
sound/soc/codecs/wm5110.c
sound/soc/codecs/wm5110.h

index 149e44f42f84abf3203d5d74aa2d4fc3ae5ddcc8..2bebfae3485f67512f6e4675e26c77eb645fd6e1 100644 (file)
@@ -1139,6 +1139,45 @@ static void arizona_disable_fll(struct arizona_fll *fll)
                pm_runtime_put_autosuspend(arizona->dev);
 }
 
+int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
+                          unsigned int Fref, unsigned int Fout)
+{
+       struct arizona_fll_cfg ref, sync;
+       int ret;
+
+       if (source < 0)
+               return -EINVAL;
+
+       if (fll->ref_src == source && fll->ref_freq == Fref &&
+           fll->fout == Fout)
+               return 0;
+
+       if (Fout) {
+               ret = arizona_calc_fll(fll, &ref, Fref, Fout);
+               if (ret != 0)
+                       return ret;
+
+               if (fll->sync_src >= 0) {
+                       ret = arizona_calc_fll(fll, &sync, fll->sync_freq, Fout);
+                       if (ret != 0)
+                               return ret;
+               }
+       }
+
+       fll->ref_src = source;
+       fll->ref_freq = Fref;
+       fll->fout = Fout;
+
+       if (Fout) {
+               arizona_enable_fll(fll, &ref, &sync);
+       } else {
+               arizona_disable_fll(fll);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(arizona_set_fll_refclk);
+
 int arizona_set_fll(struct arizona_fll *fll, int source,
                    unsigned int Fref, unsigned int Fout)
 {
index bedf12a527e55a54c026e08ee3aa9fdaed57194a..f2ca41f8dc83fbad8c45db6f7c210cf244d4fb7b 100644 (file)
@@ -211,6 +211,8 @@ struct arizona_fll {
 
 extern int arizona_init_fll(struct arizona *arizona, int id, int base,
                            int lock_irq, int ok_irq, struct arizona_fll *fll);
+extern int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
+                                 unsigned int Fref, unsigned int Fout);
 extern int arizona_set_fll(struct arizona_fll *fll, int source,
                           unsigned int Fref, unsigned int Fout);
 
index b8d461db369f1f2952fb562f9ce78ddd74e5e069..5515d85fd82f14770627c934327754e88a2c77ca 100644 (file)
@@ -1483,6 +1483,12 @@ static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
                return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout);
        case WM5102_FLL2:
                return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout);
+       case WM5102_FLL1_REFCLK:
+               return arizona_set_fll_refclk(&wm5102->fll[0], source, Fref,
+                                             Fout);
+       case WM5102_FLL2_REFCLK:
+               return arizona_set_fll_refclk(&wm5102->fll[1], source, Fref,
+                                             Fout);
        default:
                return -EINVAL;
        }
index d30477f3070c9812938da324300c6cbda84184c7..adb38040f66156fa56a4c36d53e8d88955ba0e41 100644 (file)
@@ -15,7 +15,9 @@
 
 #include "arizona.h"
 
-#define WM5102_FLL1 1
-#define WM5102_FLL2 2
+#define WM5102_FLL1        1
+#define WM5102_FLL2        2
+#define WM5102_FLL1_REFCLK 3
+#define WM5102_FLL2_REFCLK 4
 
 #endif
index cd17b477781d8b370aa78eb2eadad86dcdd4cc31..2d9b55f57eed76abfc814655f4acff058e945db5 100644 (file)
@@ -880,6 +880,12 @@ static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
                return arizona_set_fll(&wm5110->fll[0], source, Fref, Fout);
        case WM5110_FLL2:
                return arizona_set_fll(&wm5110->fll[1], source, Fref, Fout);
+       case WM5110_FLL1_REFCLK:
+               return arizona_set_fll_refclk(&wm5110->fll[0], source, Fref,
+                                             Fout);
+       case WM5110_FLL2_REFCLK:
+               return arizona_set_fll_refclk(&wm5110->fll[1], source, Fref,
+                                             Fout);
        default:
                return -EINVAL;
        }
index 75e9351ccab0032ef815acd676caaaa9f1b71090..e6c0cd4235c5853609ffb755a01b008b4c0e3ab9 100644 (file)
@@ -15,7 +15,9 @@
 
 #include "arizona.h"
 
-#define WM5110_FLL1 1
-#define WM5110_FLL2 2
+#define WM5110_FLL1        1
+#define WM5110_FLL2        2
+#define WM5110_FLL1_REFCLK 3
+#define WM5110_FLL2_REFCLK 4
 
 #endif
This page took 0.031302 seconds and 5 git commands to generate.