aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/arizona.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-04 03:00:19 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-03-04 21:00:22 -0500
commitff680a173506e0f5f15c1d9c70251e7e3208c761 (patch)
treeb3f8740fb73740897d1dbd275712c989f1a8d0e7 /sound/soc/codecs/arizona.c
parent1c5617fc230b399c1d84711b8a2e316199387eb9 (diff)
ASoC: arizona: If we only have a clock to synchronise with make it REFCLK
If there is only one clock active the FLL should use REFCLK rather than SYNCCLK as the clock to synchronise with since REFCLK is always required. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/arizona.c')
-rw-r--r--sound/soc/codecs/arizona.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index e456cb4b196e..0599ff8ea935 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -1132,14 +1132,30 @@ static void arizona_enable_fll(struct arizona_fll *fll,
1132 struct arizona *arizona = fll->arizona; 1132 struct arizona *arizona = fll->arizona;
1133 int ret; 1133 int ret;
1134 1134
1135 regmap_update_bits(arizona->regmap, fll->base + 5, 1135 /*
1136 ARIZONA_FLL1_OUTDIV_MASK, 1136 * If we have both REFCLK and SYNCCLK then enable both,
1137 ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); 1137 * otherwise apply the SYNCCLK settings to REFCLK.
1138 1138 */
1139 arizona_apply_fll(arizona, fll->base, ref, fll->ref_src); 1139 if (fll->ref_src >= 0 && fll->ref_src != fll->sync_src) {
1140 if (fll->sync_src >= 0) 1140 regmap_update_bits(arizona->regmap, fll->base + 5,
1141 arizona_apply_fll(arizona, fll->base + 0x10, sync, 1141 ARIZONA_FLL1_OUTDIV_MASK,
1142 ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
1143
1144 arizona_apply_fll(arizona, fll->base, ref, fll->ref_src);
1145 if (fll->sync_src >= 0)
1146 arizona_apply_fll(arizona, fll->base + 0x10, sync,
1147 fll->sync_src);
1148 } else if (fll->sync_src >= 0) {
1149 regmap_update_bits(arizona->regmap, fll->base + 5,
1150 ARIZONA_FLL1_OUTDIV_MASK,
1151 sync->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT);
1152
1153 arizona_apply_fll(arizona, fll->base, sync,
1142 fll->sync_src); 1154 fll->sync_src);
1155 } else {
1156 arizona_fll_err(fll, "No clocks provided\n");
1157 return;
1158 }
1143 1159
1144 if (!arizona_is_enabled_fll(fll)) 1160 if (!arizona_is_enabled_fll(fll))
1145 pm_runtime_get(arizona->dev); 1161 pm_runtime_get(arizona->dev);
@@ -1149,7 +1165,8 @@ static void arizona_enable_fll(struct arizona_fll *fll,
1149 1165
1150 regmap_update_bits(arizona->regmap, fll->base + 1, 1166 regmap_update_bits(arizona->regmap, fll->base + 1,
1151 ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); 1167 ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA);
1152 if (fll->sync_src >= 0) 1168 if (fll->ref_src >= 0 && fll->sync_src >= 0 &&
1169 fll->ref_src != fll->sync_src)
1153 regmap_update_bits(arizona->regmap, fll->base + 0x11, 1170 regmap_update_bits(arizona->regmap, fll->base + 0x11,
1154 ARIZONA_FLL1_SYNC_ENA, 1171 ARIZONA_FLL1_SYNC_ENA,
1155 ARIZONA_FLL1_SYNC_ENA); 1172 ARIZONA_FLL1_SYNC_ENA);
@@ -1180,9 +1197,6 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source,
1180 struct arizona_fll_cfg ref, sync; 1197 struct arizona_fll_cfg ref, sync;
1181 int ret; 1198 int ret;
1182 1199
1183 if (source < 0)
1184 return -EINVAL;
1185
1186 if (fll->ref_src == source && fll->ref_freq == Fref) 1200 if (fll->ref_src == source && fll->ref_freq == Fref)
1187 return 0; 1201 return 0;
1188 1202
@@ -1216,39 +1230,25 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
1216 struct arizona_fll_cfg ref, sync; 1230 struct arizona_fll_cfg ref, sync;
1217 int ret; 1231 int ret;
1218 1232
1219 if (fll->ref_src < 0 || fll->ref_src == source) { 1233 if (fll->sync_src == source &&
1220 if (fll->sync_src == ARIZONA_FLL_SRC_NONE && 1234 fll->sync_freq == Fref && fll->fout == Fout)
1221 fll->ref_src == source && fll->ref_freq == Fref && 1235 return 0;
1222 fll->fout == Fout)
1223 return 0;
1224
1225 if (Fout) {
1226 ret = arizona_calc_fll(fll, &ref, Fref, Fout);
1227 if (ret != 0)
1228 return ret;
1229 }
1230
1231 fll->sync_src = ARIZONA_FLL_SRC_NONE;
1232 fll->ref_src = source;
1233 fll->ref_freq = Fref;
1234 } else {
1235 if (fll->sync_src == source &&
1236 fll->sync_freq == Fref && fll->fout == Fout)
1237 return 0;
1238
1239 if (Fout) {
1240 ret = arizona_calc_fll(fll, &ref, fll->ref_freq, Fout);
1241 if (ret != 0)
1242 return ret;
1243 1236
1244 ret = arizona_calc_fll(fll, &sync, Fref, Fout); 1237 if (Fout) {
1238 if (fll->ref_src >= 0) {
1239 ret = arizona_calc_fll(fll, &ref, fll->ref_freq,
1240 Fout);
1245 if (ret != 0) 1241 if (ret != 0)
1246 return ret; 1242 return ret;
1247 } 1243 }
1248 1244
1249 fll->sync_src = source; 1245 ret = arizona_calc_fll(fll, &sync, Fref, Fout);
1250 fll->sync_freq = Fref; 1246 if (ret != 0)
1247 return ret;
1251 } 1248 }
1249
1250 fll->sync_src = source;
1251 fll->sync_freq = Fref;
1252 fll->fout = Fout; 1252 fll->fout = Fout;
1253 1253
1254 if (Fout) { 1254 if (Fout) {