Skip to content

Commit 02e7947

Browse files
committed
ASoC: wm_hubs: Allow configuration of MICBIAS power up delay via pdata
Sometimes the analogue circuitry connected to the microphone needs some time to settle after power up. Allow systems to configure this delay in the platform data, the driver will then insert the required delay during power up of paths that involve the microphone. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent 20bac1f commit 02e7947

6 files changed

Lines changed: 47 additions & 4 deletions

File tree

‎include/linux/mfd/wm8994/pdata.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ struct wm8994_pdata {
164164
int num_micd_rates;
165165
struct wm8958_micd_rate *micd_rates;
166166

167+
/* Power up delays to add after microphone bias power up (ms) */
168+
int micb1_delay;
169+
int micb2_delay;
170+
167171
/* LINEOUT can be differential or single ended */
168172
unsigned int lineout1_diff:1;
169173
unsigned int lineout2_diff:1;

‎include/sound/wm8993.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ struct wm8993_platform_data {
3232
unsigned int lineout1fb:1;
3333
unsigned int lineout2fb:1;
3434

35+
/* Delay to add for microphones to stabalise after power up */
36+
int micbias1_delay;
37+
int micbias2_delay;
38+
3539
/* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
3640
unsigned int micbias1_lvl:1;
3741
unsigned int micbias2_lvl:1;

‎sound/soc/codecs/wm8993.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,8 @@ static int wm8993_probe(struct snd_soc_codec *codec)
15201520
wm8993->pdata.lineout2fb,
15211521
wm8993->pdata.jd_scthr,
15221522
wm8993->pdata.jd_thr,
1523+
wm8993->pdata.micbias1_delay,
1524+
wm8993->pdata.micbias2_delay,
15231525
wm8993->pdata.micbias1_lvl,
15241526
wm8993->pdata.micbias2_lvl);
15251527

‎sound/soc/codecs/wm8994.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,6 +3145,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
31453145
pdata->lineout2fb,
31463146
pdata->jd_scthr,
31473147
pdata->jd_thr,
3148+
pdata->micb1_delay,
3149+
pdata->micb2_delay,
31483150
pdata->micbias1_lvl,
31493151
pdata->micbias2_lvl);
31503152

‎sound/soc/codecs/wm_hubs.c‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,28 @@ static int lineout_event(struct snd_soc_dapm_widget *w,
644644
return 0;
645645
}
646646

647+
static int micbias_event(struct snd_soc_dapm_widget *w,
648+
struct snd_kcontrol *kcontrol, int event)
649+
{
650+
struct snd_soc_codec *codec = w->codec;
651+
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
652+
653+
switch (w->shift) {
654+
case WM8993_MICB1_ENA_SHIFT:
655+
if (hubs->micb1_delay)
656+
msleep(hubs->micb1_delay);
657+
break;
658+
case WM8993_MICB2_ENA_SHIFT:
659+
if (hubs->micb2_delay)
660+
msleep(hubs->micb2_delay);
661+
break;
662+
default:
663+
return -EINVAL;
664+
}
665+
666+
return 0;
667+
}
668+
647669
void wm_hubs_update_class_w(struct snd_soc_codec *codec)
648670
{
649671
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
@@ -834,8 +856,10 @@ SND_SOC_DAPM_INPUT("IN1RP"),
834856
SND_SOC_DAPM_INPUT("IN2RN"),
835857
SND_SOC_DAPM_INPUT("IN2RP:VXRP"),
836858

837-
SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0, NULL, 0),
838-
SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0, NULL, 0),
859+
SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0,
860+
micbias_event, SND_SOC_DAPM_POST_PMU),
861+
SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0,
862+
micbias_event, SND_SOC_DAPM_POST_PMU),
839863

840864
SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0,
841865
in1l_pga, ARRAY_SIZE(in1l_pga)),
@@ -1170,13 +1194,16 @@ EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes);
11701194
int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec,
11711195
int lineout1_diff, int lineout2_diff,
11721196
int lineout1fb, int lineout2fb,
1173-
int jd_scthr, int jd_thr, int micbias1_lvl,
1174-
int micbias2_lvl)
1197+
int jd_scthr, int jd_thr,
1198+
int micbias1_delay, int micbias2_delay,
1199+
int micbias1_lvl, int micbias2_lvl)
11751200
{
11761201
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec);
11771202

11781203
hubs->lineout1_se = !lineout1_diff;
11791204
hubs->lineout2_se = !lineout2_diff;
1205+
hubs->micb1_delay = micbias1_delay;
1206+
hubs->micb2_delay = micbias2_delay;
11801207

11811208
if (!lineout1_diff)
11821209
snd_soc_update_bits(codec, WM8993_LINE_MIXER1,

‎sound/soc/codecs/wm_hubs.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ struct wm_hubs_data {
3636
struct list_head dcs_cache;
3737
bool (*check_class_w_digital)(struct snd_soc_codec *);
3838

39+
int micb1_delay;
40+
int micb2_delay;
41+
3942
bool lineout1_se;
4043
bool lineout1n_ena;
4144
bool lineout1p_ena;
@@ -56,6 +59,7 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *,
5659
int lineout1_diff, int lineout2_diff,
5760
int lineout1fb, int lineout2fb,
5861
int jd_scthr, int jd_thr,
62+
int micbias1_dly, int micbias2_dly,
5963
int micbias1_lvl, int micbias2_lvl);
6064

6165
extern irqreturn_t wm_hubs_dcs_done(int irq, void *data);

0 commit comments

Comments
 (0)