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

ASoC: Warn if WM8903 platform data is used to enable microphone IRQ

The WM8903 interrupts are clear on read so if the WM8903 detection is
enabled from platform data when the IRQ is in use (rather than using a
direct signal from a GPIO) status may be lost during startup. Help users
spot this misconfiguration by adding a WARN_ON().

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>

+22
+22
sound/soc/codecs/wm8903.c
··· 1917 1917 1918 1918 /* Set up GPIOs and microphone detection */ 1919 1919 if (pdata) { 1920 + bool mic_gpio = false; 1921 + 1920 1922 for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) { 1921 1923 if (pdata->gpio_cfg[i] == WM8903_GPIO_NO_CONFIG) 1922 1924 continue; 1923 1925 1924 1926 snd_soc_write(codec, WM8903_GPIO_CONTROL_1 + i, 1925 1927 pdata->gpio_cfg[i] & 0xffff); 1928 + 1929 + val = (pdata->gpio_cfg[i] & WM8903_GP1_FN_MASK) 1930 + >> WM8903_GP1_FN_SHIFT; 1931 + 1932 + switch (val) { 1933 + case WM8903_GPn_FN_MICBIAS_CURRENT_DETECT: 1934 + case WM8903_GPn_FN_MICBIAS_SHORT_DETECT: 1935 + mic_gpio = true; 1936 + break; 1937 + default: 1938 + break; 1939 + } 1926 1940 } 1927 1941 1928 1942 snd_soc_write(codec, WM8903_MIC_BIAS_CONTROL_0, ··· 1946 1932 if (pdata->micdet_cfg) 1947 1933 snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0, 1948 1934 WM8903_WSEQ_ENA, WM8903_WSEQ_ENA); 1935 + 1936 + /* If microphone detection is enabled by pdata but 1937 + * detected via IRQ then interrupts can be lost before 1938 + * the machine driver has set up microphone detection 1939 + * IRQs as the IRQs are clear on read. The detection 1940 + * will be enabled when the machine driver configures. 1941 + */ 1942 + WARN_ON(!mic_gpio && (pdata->micdet_cfg & WM8903_MICDET_ENA)); 1949 1943 1950 1944 wm8903->mic_delay = pdata->micdet_delay; 1951 1945 }