diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2013-02-20 12:28:40 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-03 22:01:00 -0500 |
commit | ee929a9780605f21ad67a1ccb626baa41e038c1a (patch) | |
tree | 7f46c9218a20210e1fa8988d723af3c5ba90c0b2 | |
parent | de1e6eedddeab2fa417c38c231d896198f903129 (diff) |
ASoC: arizona: Add support for directly setting the FLL REFCLK
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>
-rw-r--r-- | sound/soc/codecs/arizona.c | 39 | ||||
-rw-r--r-- | sound/soc/codecs/arizona.h | 2 | ||||
-rw-r--r-- | sound/soc/codecs/wm5102.c | 6 | ||||
-rw-r--r-- | sound/soc/codecs/wm5102.h | 6 | ||||
-rw-r--r-- | sound/soc/codecs/wm5110.c | 6 | ||||
-rw-r--r-- | sound/soc/codecs/wm5110.h | 6 |
6 files changed, 61 insertions, 4 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 149e44f42f84..2bebfae3485f 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
@@ -1139,6 +1139,45 @@ static void arizona_disable_fll(struct arizona_fll *fll) | |||
1139 | pm_runtime_put_autosuspend(arizona->dev); | 1139 | pm_runtime_put_autosuspend(arizona->dev); |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | int arizona_set_fll_refclk(struct arizona_fll *fll, int source, | ||
1143 | unsigned int Fref, unsigned int Fout) | ||
1144 | { | ||
1145 | struct arizona_fll_cfg ref, sync; | ||
1146 | int ret; | ||
1147 | |||
1148 | if (source < 0) | ||
1149 | return -EINVAL; | ||
1150 | |||
1151 | if (fll->ref_src == source && fll->ref_freq == Fref && | ||
1152 | fll->fout == Fout) | ||
1153 | return 0; | ||
1154 | |||
1155 | if (Fout) { | ||
1156 | ret = arizona_calc_fll(fll, &ref, Fref, Fout); | ||
1157 | if (ret != 0) | ||
1158 | return ret; | ||
1159 | |||
1160 | if (fll->sync_src >= 0) { | ||
1161 | ret = arizona_calc_fll(fll, &sync, fll->sync_freq, Fout); | ||
1162 | if (ret != 0) | ||
1163 | return ret; | ||
1164 | } | ||
1165 | } | ||
1166 | |||
1167 | fll->ref_src = source; | ||
1168 | fll->ref_freq = Fref; | ||
1169 | fll->fout = Fout; | ||
1170 | |||
1171 | if (Fout) { | ||
1172 | arizona_enable_fll(fll, &ref, &sync); | ||
1173 | } else { | ||
1174 | arizona_disable_fll(fll); | ||
1175 | } | ||
1176 | |||
1177 | return 0; | ||
1178 | } | ||
1179 | EXPORT_SYMBOL_GPL(arizona_set_fll_refclk); | ||
1180 | |||
1142 | int arizona_set_fll(struct arizona_fll *fll, int source, | 1181 | int arizona_set_fll(struct arizona_fll *fll, int source, |
1143 | unsigned int Fref, unsigned int Fout) | 1182 | unsigned int Fref, unsigned int Fout) |
1144 | { | 1183 | { |
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index bedf12a527e5..f2ca41f8dc83 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h | |||
@@ -211,6 +211,8 @@ struct arizona_fll { | |||
211 | 211 | ||
212 | extern int arizona_init_fll(struct arizona *arizona, int id, int base, | 212 | extern int arizona_init_fll(struct arizona *arizona, int id, int base, |
213 | int lock_irq, int ok_irq, struct arizona_fll *fll); | 213 | int lock_irq, int ok_irq, struct arizona_fll *fll); |
214 | extern int arizona_set_fll_refclk(struct arizona_fll *fll, int source, | ||
215 | unsigned int Fref, unsigned int Fout); | ||
214 | extern int arizona_set_fll(struct arizona_fll *fll, int source, | 216 | extern int arizona_set_fll(struct arizona_fll *fll, int source, |
215 | unsigned int Fref, unsigned int Fout); | 217 | unsigned int Fref, unsigned int Fout); |
216 | 218 | ||
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index b8d461db369f..5515d85fd82f 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
@@ -1483,6 +1483,12 @@ static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source, | |||
1483 | return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout); | 1483 | return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout); |
1484 | case WM5102_FLL2: | 1484 | case WM5102_FLL2: |
1485 | return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout); | 1485 | return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout); |
1486 | case WM5102_FLL1_REFCLK: | ||
1487 | return arizona_set_fll_refclk(&wm5102->fll[0], source, Fref, | ||
1488 | Fout); | ||
1489 | case WM5102_FLL2_REFCLK: | ||
1490 | return arizona_set_fll_refclk(&wm5102->fll[1], source, Fref, | ||
1491 | Fout); | ||
1486 | default: | 1492 | default: |
1487 | return -EINVAL; | 1493 | return -EINVAL; |
1488 | } | 1494 | } |
diff --git a/sound/soc/codecs/wm5102.h b/sound/soc/codecs/wm5102.h index d30477f3070c..adb38040f661 100644 --- a/sound/soc/codecs/wm5102.h +++ b/sound/soc/codecs/wm5102.h | |||
@@ -15,7 +15,9 @@ | |||
15 | 15 | ||
16 | #include "arizona.h" | 16 | #include "arizona.h" |
17 | 17 | ||
18 | #define WM5102_FLL1 1 | 18 | #define WM5102_FLL1 1 |
19 | #define WM5102_FLL2 2 | 19 | #define WM5102_FLL2 2 |
20 | #define WM5102_FLL1_REFCLK 3 | ||
21 | #define WM5102_FLL2_REFCLK 4 | ||
20 | 22 | ||
21 | #endif | 23 | #endif |
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index cd17b477781d..2d9b55f57eed 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c | |||
@@ -880,6 +880,12 @@ static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source, | |||
880 | return arizona_set_fll(&wm5110->fll[0], source, Fref, Fout); | 880 | return arizona_set_fll(&wm5110->fll[0], source, Fref, Fout); |
881 | case WM5110_FLL2: | 881 | case WM5110_FLL2: |
882 | return arizona_set_fll(&wm5110->fll[1], source, Fref, Fout); | 882 | return arizona_set_fll(&wm5110->fll[1], source, Fref, Fout); |
883 | case WM5110_FLL1_REFCLK: | ||
884 | return arizona_set_fll_refclk(&wm5110->fll[0], source, Fref, | ||
885 | Fout); | ||
886 | case WM5110_FLL2_REFCLK: | ||
887 | return arizona_set_fll_refclk(&wm5110->fll[1], source, Fref, | ||
888 | Fout); | ||
883 | default: | 889 | default: |
884 | return -EINVAL; | 890 | return -EINVAL; |
885 | } | 891 | } |
diff --git a/sound/soc/codecs/wm5110.h b/sound/soc/codecs/wm5110.h index 75e9351ccab0..e6c0cd4235c5 100644 --- a/sound/soc/codecs/wm5110.h +++ b/sound/soc/codecs/wm5110.h | |||
@@ -15,7 +15,9 @@ | |||
15 | 15 | ||
16 | #include "arizona.h" | 16 | #include "arizona.h" |
17 | 17 | ||
18 | #define WM5110_FLL1 1 | 18 | #define WM5110_FLL1 1 |
19 | #define WM5110_FLL2 2 | 19 | #define WM5110_FLL2 2 |
20 | #define WM5110_FLL1_REFCLK 3 | ||
21 | #define WM5110_FLL2_REFCLK 4 | ||
20 | 22 | ||
21 | #endif | 23 | #endif |