Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+47 -4
+4
include/linux/mfd/wm8994/pdata.h
··· 164 164 int num_micd_rates; 165 165 struct wm8958_micd_rate *micd_rates; 166 166 167 + /* Power up delays to add after microphone bias power up (ms) */ 168 + int micb1_delay; 169 + int micb2_delay; 170 + 167 171 /* LINEOUT can be differential or single ended */ 168 172 unsigned int lineout1_diff:1; 169 173 unsigned int lineout2_diff:1;
+4
include/sound/wm8993.h
··· 32 32 unsigned int lineout1fb:1; 33 33 unsigned int lineout2fb:1; 34 34 35 + /* Delay to add for microphones to stabalise after power up */ 36 + int micbias1_delay; 37 + int micbias2_delay; 38 + 35 39 /* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */ 36 40 unsigned int micbias1_lvl:1; 37 41 unsigned int micbias2_lvl:1;
+2
sound/soc/codecs/wm8993.c
··· 1520 1520 wm8993->pdata.lineout2fb, 1521 1521 wm8993->pdata.jd_scthr, 1522 1522 wm8993->pdata.jd_thr, 1523 + wm8993->pdata.micbias1_delay, 1524 + wm8993->pdata.micbias2_delay, 1523 1525 wm8993->pdata.micbias1_lvl, 1524 1526 wm8993->pdata.micbias2_lvl); 1525 1527
+2
sound/soc/codecs/wm8994.c
··· 3145 3145 pdata->lineout2fb, 3146 3146 pdata->jd_scthr, 3147 3147 pdata->jd_thr, 3148 + pdata->micb1_delay, 3149 + pdata->micb2_delay, 3148 3150 pdata->micbias1_lvl, 3149 3151 pdata->micbias2_lvl); 3150 3152
+31 -4
sound/soc/codecs/wm_hubs.c
··· 644 644 return 0; 645 645 } 646 646 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 + 647 669 void wm_hubs_update_class_w(struct snd_soc_codec *codec) 648 670 { 649 671 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); ··· 856 834 SND_SOC_DAPM_INPUT("IN2RN"), 857 835 SND_SOC_DAPM_INPUT("IN2RP:VXRP"), 858 836 859 - SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0, NULL, 0), 860 - SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0, NULL, 0), 837 + SND_SOC_DAPM_SUPPLY("MICBIAS2", WM8993_POWER_MANAGEMENT_1, 5, 0, 838 + micbias_event, SND_SOC_DAPM_POST_PMU), 839 + SND_SOC_DAPM_SUPPLY("MICBIAS1", WM8993_POWER_MANAGEMENT_1, 4, 0, 840 + micbias_event, SND_SOC_DAPM_POST_PMU), 861 841 862 842 SND_SOC_DAPM_MIXER("IN1L PGA", WM8993_POWER_MANAGEMENT_2, 6, 0, 863 843 in1l_pga, ARRAY_SIZE(in1l_pga)), ··· 1194 1170 int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, 1195 1171 int lineout1_diff, int lineout2_diff, 1196 1172 int lineout1fb, int lineout2fb, 1197 - int jd_scthr, int jd_thr, int micbias1_lvl, 1198 - int micbias2_lvl) 1173 + int jd_scthr, int jd_thr, 1174 + int micbias1_delay, int micbias2_delay, 1175 + int micbias1_lvl, int micbias2_lvl) 1199 1176 { 1200 1177 struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); 1201 1178 1202 1179 hubs->lineout1_se = !lineout1_diff; 1203 1180 hubs->lineout2_se = !lineout2_diff; 1181 + hubs->micb1_delay = micbias1_delay; 1182 + hubs->micb2_delay = micbias2_delay; 1204 1183 1205 1184 if (!lineout1_diff) 1206 1185 snd_soc_update_bits(codec, WM8993_LINE_MIXER1,
+4
sound/soc/codecs/wm_hubs.h
··· 36 36 struct list_head dcs_cache; 37 37 bool (*check_class_w_digital)(struct snd_soc_codec *); 38 38 39 + int micb1_delay; 40 + int micb2_delay; 41 + 39 42 bool lineout1_se; 40 43 bool lineout1n_ena; 41 44 bool lineout1p_ena; ··· 59 56 int lineout1_diff, int lineout2_diff, 60 57 int lineout1fb, int lineout2fb, 61 58 int jd_scthr, int jd_thr, 59 + int micbias1_dly, int micbias2_dly, 62 60 int micbias1_lvl, int micbias2_lvl); 63 61 64 62 extern irqreturn_t wm_hubs_dcs_done(int irq, void *data);