aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8903.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-02-10 09:20:49 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-02-11 06:14:05 -0500
commitb4d06f456dcf956761e2c927e62b03861f07dbbf (patch)
tree5d80c3997c85dffa704f9ec9ab32a7f1bb33474c /sound/soc/codecs/wm8903.c
parent22f226dd1496a0fa470e64a66e2da474f34eebf8 (diff)
ASoC: Use explicit sequence for WM8903 bias off
This makes no real difference compared to the write sequencer sequence that was previously used but can run without a clock being provided. Also remove the write sequencer support code as this was the last use of it. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/codecs/wm8903.c')
-rw-r--r--sound/soc/codecs/wm8903.c66
1 files changed, 21 insertions, 45 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index e203a3ec655a..c7b52a04fe1a 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -229,8 +229,6 @@ struct wm8903_priv {
229 /* Reference count */ 229 /* Reference count */
230 int class_w_users; 230 int class_w_users;
231 231
232 struct completion wseq;
233
234 struct snd_soc_jack *mic_jack; 232 struct snd_soc_jack *mic_jack;
235 int mic_det; 233 int mic_det;
236 int mic_short; 234 int mic_short;
@@ -262,41 +260,6 @@ static int wm8903_volatile_register(struct snd_soc_codec *codec, unsigned int re
262 } 260 }
263} 261}
264 262
265static int wm8903_run_sequence(struct snd_soc_codec *codec, unsigned int start)
266{
267 u16 reg[5];
268 struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
269
270 BUG_ON(start > 48);
271
272 /* Enable the sequencer if it's not already on */
273 reg[0] = snd_soc_read(codec, WM8903_WRITE_SEQUENCER_0);
274 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_0,
275 reg[0] | WM8903_WSEQ_ENA);
276
277 dev_dbg(codec->dev, "Starting sequence at %d\n", start);
278
279 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_3,
280 start | WM8903_WSEQ_START);
281
282 /* Wait for it to complete. If we have the interrupt wired up then
283 * that will break us out of the poll early.
284 */
285 do {
286 wait_for_completion_timeout(&wm8903->wseq,
287 msecs_to_jiffies(10));
288
289 reg[4] = snd_soc_read(codec, WM8903_WRITE_SEQUENCER_4);
290 } while (reg[4] & WM8903_WSEQ_BUSY);
291
292 dev_dbg(codec->dev, "Sequence complete\n");
293
294 /* Disable the sequencer again if we enabled it */
295 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_0, reg[0]);
296
297 return 0;
298}
299
300static void wm8903_reset(struct snd_soc_codec *codec) 263static void wm8903_reset(struct snd_soc_codec *codec)
301{ 264{
302 snd_soc_write(codec, WM8903_SW_RESET_AND_ID, 0); 265 snd_soc_write(codec, WM8903_SW_RESET_AND_ID, 0);
@@ -1213,11 +1176,26 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec,
1213 break; 1176 break;
1214 1177
1215 case SND_SOC_BIAS_OFF: 1178 case SND_SOC_BIAS_OFF:
1216 snd_soc_update_bits(codec, WM8903_CLOCK_RATES_2, 1179 snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0,
1217 WM8903_CLK_SYS_ENA, WM8903_CLK_SYS_ENA); 1180 WM8903_BIAS_ENA, 0);
1218 wm8903_run_sequence(codec, 32); 1181
1219 snd_soc_update_bits(codec, WM8903_CLOCK_RATES_2, 1182 snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0,
1220 WM8903_CLK_SYS_ENA, 0); 1183 WM8903_VMID_SOFT_MASK,
1184 2 << WM8903_VMID_SOFT_SHIFT);
1185
1186 snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0,
1187 WM8903_VMID_BUF_ENA, 0);
1188
1189 msleep(290);
1190
1191 snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0,
1192 WM8903_VMID_TIE_ENA | WM8903_BUFIO_ENA |
1193 WM8903_VMID_IO_ENA | WM8903_VMID_RES_MASK |
1194 WM8903_VMID_SOFT_MASK |
1195 WM8903_VMID_BUF_ENA, 0);
1196
1197 snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0,
1198 WM8903_STARTUP_BIAS_ENA, 0);
1221 break; 1199 break;
1222 } 1200 }
1223 1201
@@ -1670,8 +1648,7 @@ static irqreturn_t wm8903_irq(int irq, void *data)
1670 int_val = snd_soc_read(codec, WM8903_INTERRUPT_STATUS_1) & mask; 1648 int_val = snd_soc_read(codec, WM8903_INTERRUPT_STATUS_1) & mask;
1671 1649
1672 if (int_val & WM8903_WSEQ_BUSY_EINT) { 1650 if (int_val & WM8903_WSEQ_BUSY_EINT) {
1673 dev_dbg(codec->dev, "Write sequencer done\n"); 1651 dev_warn(codec->dev, "Write sequencer done\n");
1674 complete(&wm8903->wseq);
1675 } 1652 }
1676 1653
1677 /* 1654 /*
@@ -1918,7 +1895,6 @@ static int wm8903_probe(struct snd_soc_codec *codec)
1918 u16 val; 1895 u16 val;
1919 1896
1920 wm8903->codec = codec; 1897 wm8903->codec = codec;
1921 init_completion(&wm8903->wseq);
1922 1898
1923 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C); 1899 ret = snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_I2C);
1924 if (ret != 0) { 1900 if (ret != 0) {