aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/wm8903.h29
-rw-r--r--sound/soc/codecs/wm8903.c24
-rw-r--r--sound/soc/codecs/wm8903.h22
3 files changed, 45 insertions, 30 deletions
diff --git a/include/sound/wm8903.h b/include/sound/wm8903.h
index 00458589fe85..22b66a76febd 100644
--- a/include/sound/wm8903.h
+++ b/include/sound/wm8903.h
@@ -15,6 +15,28 @@
15#define WM8903_GPIO_NO_CONFIG 0x8000 15#define WM8903_GPIO_NO_CONFIG 0x8000
16 16
17/* 17/*
18 * R6 (0x06) - Mic Bias Control 0
19 */
20#define WM8903_MICDET_HYST_ENA 0x0080 /* MICDET_HYST_ENA */
21#define WM8903_MICDET_HYST_ENA_MASK 0x0080 /* MICDET_HYST_ENA */
22#define WM8903_MICDET_HYST_ENA_SHIFT 7 /* MICDET_HYST_ENA */
23#define WM8903_MICDET_HYST_ENA_WIDTH 1 /* MICDET_HYST_ENA */
24#define WM8903_MICDET_THR_MASK 0x0070 /* MICDET_THR - [6:4] */
25#define WM8903_MICDET_THR_SHIFT 4 /* MICDET_THR - [6:4] */
26#define WM8903_MICDET_THR_WIDTH 3 /* MICDET_THR - [6:4] */
27#define WM8903_MICSHORT_THR_MASK 0x000C /* MICSHORT_THR - [3:2] */
28#define WM8903_MICSHORT_THR_SHIFT 2 /* MICSHORT_THR - [3:2] */
29#define WM8903_MICSHORT_THR_WIDTH 2 /* MICSHORT_THR - [3:2] */
30#define WM8903_MICDET_ENA 0x0002 /* MICDET_ENA */
31#define WM8903_MICDET_ENA_MASK 0x0002 /* MICDET_ENA */
32#define WM8903_MICDET_ENA_SHIFT 1 /* MICDET_ENA */
33#define WM8903_MICDET_ENA_WIDTH 1 /* MICDET_ENA */
34#define WM8903_MICBIAS_ENA 0x0001 /* MICBIAS_ENA */
35#define WM8903_MICBIAS_ENA_MASK 0x0001 /* MICBIAS_ENA */
36#define WM8903_MICBIAS_ENA_SHIFT 0 /* MICBIAS_ENA */
37#define WM8903_MICBIAS_ENA_WIDTH 1 /* MICBIAS_ENA */
38
39/*
18 * R116 (0x74) - GPIO Control 1 40 * R116 (0x74) - GPIO Control 1
19 */ 41 */
20#define WM8903_GP1_FN_MASK 0x1F00 /* GP1_FN - [12:8] */ 42#define WM8903_GP1_FN_MASK 0x1F00 /* GP1_FN - [12:8] */
@@ -210,6 +232,13 @@
210#define WM8903_GP5_DB_WIDTH 1 /* GP5_DB */ 232#define WM8903_GP5_DB_WIDTH 1 /* GP5_DB */
211 233
212struct wm8903_platform_data { 234struct wm8903_platform_data {
235 /* Default register value for R6 (Mic bias), used to configure
236 * microphone detection. In conjunction with gpio_cfg this
237 * can be used to route the microphone status signals out onto
238 * the GPIOs for use with snd_soc_jack_add_gpios().
239 */
240 u16 micdet_cfg;
241
213 u32 gpio_cfg[5]; /* Default register values for GPIO pin mux */ 242 u32 gpio_cfg[5]; /* Default register values for GPIO pin mux */
214}; 243};
215 244
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 */
diff --git a/sound/soc/codecs/wm8903.h b/sound/soc/codecs/wm8903.h
index 551736cf2195..8f19a2413785 100644
--- a/sound/soc/codecs/wm8903.h
+++ b/sound/soc/codecs/wm8903.h
@@ -173,28 +173,6 @@ extern struct snd_soc_codec_device soc_codec_dev_wm8903;
173#define WM8903_VMID_RES_5K 4 173#define WM8903_VMID_RES_5K 4
174 174
175/* 175/*
176 * R6 (0x06) - Mic Bias Control 0
177 */
178#define WM8903_MICDET_HYST_ENA 0x0080 /* MICDET_HYST_ENA */
179#define WM8903_MICDET_HYST_ENA_MASK 0x0080 /* MICDET_HYST_ENA */
180#define WM8903_MICDET_HYST_ENA_SHIFT 7 /* MICDET_HYST_ENA */
181#define WM8903_MICDET_HYST_ENA_WIDTH 1 /* MICDET_HYST_ENA */
182#define WM8903_MICDET_THR_MASK 0x0070 /* MICDET_THR - [6:4] */
183#define WM8903_MICDET_THR_SHIFT 4 /* MICDET_THR - [6:4] */
184#define WM8903_MICDET_THR_WIDTH 3 /* MICDET_THR - [6:4] */
185#define WM8903_MICSHORT_THR_MASK 0x000C /* MICSHORT_THR - [3:2] */
186#define WM8903_MICSHORT_THR_SHIFT 2 /* MICSHORT_THR - [3:2] */
187#define WM8903_MICSHORT_THR_WIDTH 2 /* MICSHORT_THR - [3:2] */
188#define WM8903_MICDET_ENA 0x0002 /* MICDET_ENA */
189#define WM8903_MICDET_ENA_MASK 0x0002 /* MICDET_ENA */
190#define WM8903_MICDET_ENA_SHIFT 1 /* MICDET_ENA */
191#define WM8903_MICDET_ENA_WIDTH 1 /* MICDET_ENA */
192#define WM8903_MICBIAS_ENA 0x0001 /* MICBIAS_ENA */
193#define WM8903_MICBIAS_ENA_MASK 0x0001 /* MICBIAS_ENA */
194#define WM8903_MICBIAS_ENA_SHIFT 0 /* MICBIAS_ENA */
195#define WM8903_MICBIAS_ENA_WIDTH 1 /* MICBIAS_ENA */
196
197/*
198 * R8 (0x08) - Analogue DAC 0 176 * R8 (0x08) - Analogue DAC 0
199 */ 177 */
200#define WM8903_DACBIAS_SEL_MASK 0x0018 /* DACBIAS_SEL - [4:3] */ 178#define WM8903_DACBIAS_SEL_MASK 0x0018 /* DACBIAS_SEL - [4:3] */