diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2013-02-20 12:28:38 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-03-03 22:01:00 -0500 |
commit | 357228153b4a158bdeb05f1c46ee13ef60a675a6 (patch) | |
tree | 7a95ba002e72198ac8cff85145e57a85da559a6f | |
parent | 7604054e13897c2da3570e33a67ecb76462212d8 (diff) |
ASoC: arizona: Factor out FLL enable
In preparation for additional features on the FLL this patch factors out
the code for enabling an FLL into a seperate function.
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 | 66 |
1 files changed, 36 insertions, 30 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index a8821a819adc..e770945fa019 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
@@ -1090,6 +1090,41 @@ static bool arizona_is_enabled_fll(struct arizona_fll *fll) | |||
1090 | return reg & ARIZONA_FLL1_ENA; | 1090 | return reg & ARIZONA_FLL1_ENA; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | static void arizona_enable_fll(struct arizona_fll *fll, | ||
1094 | struct arizona_fll_cfg *ref, | ||
1095 | struct arizona_fll_cfg *sync) | ||
1096 | { | ||
1097 | struct arizona *arizona = fll->arizona; | ||
1098 | int ret; | ||
1099 | |||
1100 | regmap_update_bits(arizona->regmap, fll->base + 5, | ||
1101 | ARIZONA_FLL1_OUTDIV_MASK, | ||
1102 | ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); | ||
1103 | |||
1104 | arizona_apply_fll(arizona, fll->base, ref, fll->ref_src); | ||
1105 | if (fll->sync_src >= 0) | ||
1106 | arizona_apply_fll(arizona, fll->base + 0x10, sync, | ||
1107 | fll->sync_src); | ||
1108 | |||
1109 | if (!arizona_is_enabled_fll(fll)) | ||
1110 | pm_runtime_get(arizona->dev); | ||
1111 | |||
1112 | /* Clear any pending completions */ | ||
1113 | try_wait_for_completion(&fll->ok); | ||
1114 | |||
1115 | regmap_update_bits(arizona->regmap, fll->base + 1, | ||
1116 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); | ||
1117 | if (fll->sync_src >= 0) | ||
1118 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | ||
1119 | ARIZONA_FLL1_SYNC_ENA, | ||
1120 | ARIZONA_FLL1_SYNC_ENA); | ||
1121 | |||
1122 | ret = wait_for_completion_timeout(&fll->ok, | ||
1123 | msecs_to_jiffies(250)); | ||
1124 | if (ret == 0) | ||
1125 | arizona_fll_warn(fll, "Timed out waiting for lock\n"); | ||
1126 | } | ||
1127 | |||
1093 | static void arizona_disable_fll(struct arizona_fll *fll) | 1128 | static void arizona_disable_fll(struct arizona_fll *fll) |
1094 | { | 1129 | { |
1095 | struct arizona *arizona = fll->arizona; | 1130 | struct arizona *arizona = fll->arizona; |
@@ -1107,9 +1142,7 @@ static void arizona_disable_fll(struct arizona_fll *fll) | |||
1107 | int arizona_set_fll(struct arizona_fll *fll, int source, | 1142 | int arizona_set_fll(struct arizona_fll *fll, int source, |
1108 | unsigned int Fref, unsigned int Fout) | 1143 | unsigned int Fref, unsigned int Fout) |
1109 | { | 1144 | { |
1110 | struct arizona *arizona = fll->arizona; | ||
1111 | struct arizona_fll_cfg ref, sync; | 1145 | struct arizona_fll_cfg ref, sync; |
1112 | bool ena; | ||
1113 | int ret; | 1146 | int ret; |
1114 | 1147 | ||
1115 | if (fll->fref == Fref && fll->fout == Fout) | 1148 | if (fll->fref == Fref && fll->fout == Fout) |
@@ -1140,35 +1173,8 @@ int arizona_set_fll(struct arizona_fll *fll, int source, | |||
1140 | fll->sync_freq = Fref; | 1173 | fll->sync_freq = Fref; |
1141 | } | 1174 | } |
1142 | 1175 | ||
1143 | ena = arizona_is_enabled_fll(fll); | ||
1144 | |||
1145 | if (Fout) { | 1176 | if (Fout) { |
1146 | regmap_update_bits(arizona->regmap, fll->base + 5, | 1177 | arizona_enable_fll(fll, &ref, &sync); |
1147 | ARIZONA_FLL1_OUTDIV_MASK, | ||
1148 | ref.outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); | ||
1149 | |||
1150 | arizona_apply_fll(arizona, fll->base, &ref, fll->ref_src); | ||
1151 | if (fll->sync_src >= 0) | ||
1152 | arizona_apply_fll(arizona, fll->base + 0x10, &sync, | ||
1153 | fll->sync_src); | ||
1154 | |||
1155 | if (!ena) | ||
1156 | pm_runtime_get(arizona->dev); | ||
1157 | |||
1158 | /* Clear any pending completions */ | ||
1159 | try_wait_for_completion(&fll->ok); | ||
1160 | |||
1161 | regmap_update_bits(arizona->regmap, fll->base + 1, | ||
1162 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); | ||
1163 | if (fll->sync_src >= 0) | ||
1164 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | ||
1165 | ARIZONA_FLL1_SYNC_ENA, | ||
1166 | ARIZONA_FLL1_SYNC_ENA); | ||
1167 | |||
1168 | ret = wait_for_completion_timeout(&fll->ok, | ||
1169 | msecs_to_jiffies(250)); | ||
1170 | if (ret == 0) | ||
1171 | arizona_fll_warn(fll, "Timed out waiting for lock\n"); | ||
1172 | } else { | 1178 | } else { |
1173 | arizona_disable_fll(fll); | 1179 | arizona_disable_fll(fll); |
1174 | } | 1180 | } |