aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8903.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-15 14:14:34 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-03-16 11:56:54 -0400
commit37f88e8407f75fc6ced5cefb633c314556de3ad1 (patch)
tree95b4bd8d967f4c229becaad4b5dc503be6f46448 /sound/soc/codecs/wm8903.c
parent73b34ead7429789f35eea147a3e185abd61c7d94 (diff)
ASoC: Initial WM8903 microphone bias and short detection
Provide support for WM8903 microphone presence and short detection using the GPIOs to route out a logic signal suitable for handling using snd_soc_jack_add_gpios() on the processor GPIOs. 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.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 36952d77c271..467e6c335c5a 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -11,7 +11,6 @@
11 * 11 *
12 * TODO: 12 * TODO:
13 * - TDM mode configuration. 13 * - TDM mode configuration.
14 * - Mic detect.
15 * - Digital microphone support. 14 * - Digital microphone support.
16 * - Interrupt support (mic detect and sequencer). 15 * - Interrupt support (mic detect and sequencer).
17 */ 16 */
@@ -246,10 +245,10 @@ static int wm8903_run_sequence(struct snd_soc_codec *codec, unsigned int start)
246 245
247 BUG_ON(start > 48); 246 BUG_ON(start > 48);
248 247
249 /* Enable the sequencer */ 248 /* Enable the sequencer if it's not already on */
250 reg[0] = snd_soc_read(codec, WM8903_WRITE_SEQUENCER_0); 249 reg[0] = snd_soc_read(codec, WM8903_WRITE_SEQUENCER_0);
251 reg[0] |= WM8903_WSEQ_ENA; 250 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_0,
252 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_0, reg[0]); 251 reg[0] | WM8903_WSEQ_ENA);
253 252
254 dev_dbg(&i2c->dev, "Starting sequence at %d\n", start); 253 dev_dbg(&i2c->dev, "Starting sequence at %d\n", start);
255 254
@@ -268,9 +267,8 @@ static int wm8903_run_sequence(struct snd_soc_codec *codec, unsigned int start)
268 267
269 dev_dbg(&i2c->dev, "Sequence complete\n"); 268 dev_dbg(&i2c->dev, "Sequence complete\n");
270 269
271 /* Disable the sequencer again */ 270 /* Disable the sequencer again if we enabled it */
272 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_0, 271 snd_soc_write(codec, WM8903_WRITE_SEQUENCER_0, reg[0]);
273 reg[0] & ~WM8903_WSEQ_ENA);
274 272
275 return 0; 273 return 0;
276} 274}
@@ -1578,7 +1576,7 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
1578 1576
1579 wm8903_reset(codec); 1577 wm8903_reset(codec);
1580 1578
1581 /* Set up GPIOs */ 1579 /* Set up GPIOs and microphone detection */
1582 if (pdata) { 1580 if (pdata) {
1583 for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) { 1581 for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) {
1584 if (!pdata->gpio_cfg[i]) 1582 if (!pdata->gpio_cfg[i])
@@ -1587,6 +1585,16 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
1587 snd_soc_write(codec, WM8903_GPIO_CONTROL_1 + i, 1585 snd_soc_write(codec, WM8903_GPIO_CONTROL_1 + i,
1588 pdata->gpio_cfg[i] & 0xffff); 1586 pdata->gpio_cfg[i] & 0xffff);
1589 } 1587 }
1588
1589 snd_soc_write(codec, WM8903_MIC_BIAS_CONTROL_0,
1590 pdata->micdet_cfg);
1591
1592 /* Microphone detection needs the WSEQ clock */
1593 if (pdata->micdet_cfg)
1594 snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0,
1595 WM8903_WSEQ_ENA, WM8903_WSEQ_ENA);
1596
1597 wm8903->mic_delay = pdata->micdet_delay;
1590 } 1598 }
1591 1599
1592 /* power on device */ 1600 /* power on device */