diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-08 22:03:20 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-11 20:59:46 -0400 |
commit | 20c5fd399482ef5b87a41ab064b3255f1faaaee4 (patch) | |
tree | 05c51195d628c1bf47770623e7a5733f3fdb41c3 /sound/soc/codecs/wm8903.c | |
parent | 48e278746070b5fc62ec3da2e65f7cd511f6bbf4 (diff) |
ASoC: wm8903: Move pin configuration into I2C probe() function
Ensure that the device pins are configured as soon as possible by moving
the pin configration (including MICBIAS) into the I2C probe() function.
This had been done in the CODEC probe() function when we were relying on
the ASoC register I/O code.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Tested-by: Stephen Warren <swarren@wwwdotorg.org>
Diffstat (limited to 'sound/soc/codecs/wm8903.c')
-rw-r--r-- | sound/soc/codecs/wm8903.c | 92 |
1 files changed, 47 insertions, 45 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index 3abd450842ee..64ca9042bad3 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * wm8903.c -- WM8903 ALSA SoC Audio driver | 2 | * wm8903.c -- WM8903 ALSA SoC Audio driver |
3 | * | 3 | * |
4 | * Copyright 2008-11 Wolfson Microelectronics | 4 | * Copyright 2008-12 Wolfson Microelectronics |
5 | * Copyright 2011-2012 NVIDIA, Inc. | 5 | * Copyright 2011-2012 NVIDIA, Inc. |
6 | * | 6 | * |
7 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> | 7 | * Author: Mark Brown <broonie@opensource.wolfsonmicro.com> |
@@ -1880,10 +1880,9 @@ static int wm8903_probe(struct snd_soc_codec *codec) | |||
1880 | { | 1880 | { |
1881 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | 1881 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); |
1882 | struct wm8903_platform_data *pdata = wm8903->pdata; | 1882 | struct wm8903_platform_data *pdata = wm8903->pdata; |
1883 | int ret, i; | 1883 | int ret; |
1884 | int trigger, irq_pol; | 1884 | int trigger, irq_pol; |
1885 | u16 val; | 1885 | u16 val; |
1886 | bool mic_gpio = false; | ||
1887 | 1886 | ||
1888 | wm8903->codec = codec; | 1887 | wm8903->codec = codec; |
1889 | codec->control_data = wm8903->regmap; | 1888 | codec->control_data = wm8903->regmap; |
@@ -1894,47 +1893,6 @@ static int wm8903_probe(struct snd_soc_codec *codec) | |||
1894 | return ret; | 1893 | return ret; |
1895 | } | 1894 | } |
1896 | 1895 | ||
1897 | /* Set up GPIOs, detect if any are MIC detect outputs */ | ||
1898 | for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) { | ||
1899 | if ((!pdata->gpio_cfg[i]) || | ||
1900 | (pdata->gpio_cfg[i] > WM8903_GPIO_CONFIG_ZERO)) | ||
1901 | continue; | ||
1902 | |||
1903 | snd_soc_write(codec, WM8903_GPIO_CONTROL_1 + i, | ||
1904 | pdata->gpio_cfg[i] & 0x7fff); | ||
1905 | |||
1906 | val = (pdata->gpio_cfg[i] & WM8903_GP1_FN_MASK) | ||
1907 | >> WM8903_GP1_FN_SHIFT; | ||
1908 | |||
1909 | switch (val) { | ||
1910 | case WM8903_GPn_FN_MICBIAS_CURRENT_DETECT: | ||
1911 | case WM8903_GPn_FN_MICBIAS_SHORT_DETECT: | ||
1912 | mic_gpio = true; | ||
1913 | break; | ||
1914 | default: | ||
1915 | break; | ||
1916 | } | ||
1917 | } | ||
1918 | |||
1919 | /* Set up microphone detection */ | ||
1920 | snd_soc_write(codec, WM8903_MIC_BIAS_CONTROL_0, | ||
1921 | pdata->micdet_cfg); | ||
1922 | |||
1923 | /* Microphone detection needs the WSEQ clock */ | ||
1924 | if (pdata->micdet_cfg) | ||
1925 | snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0, | ||
1926 | WM8903_WSEQ_ENA, WM8903_WSEQ_ENA); | ||
1927 | |||
1928 | /* If microphone detection is enabled by pdata but | ||
1929 | * detected via IRQ then interrupts can be lost before | ||
1930 | * the machine driver has set up microphone detection | ||
1931 | * IRQs as the IRQs are clear on read. The detection | ||
1932 | * will be enabled when the machine driver configures. | ||
1933 | */ | ||
1934 | WARN_ON(!mic_gpio && (pdata->micdet_cfg & WM8903_MICDET_ENA)); | ||
1935 | |||
1936 | wm8903->mic_delay = pdata->micdet_delay; | ||
1937 | |||
1938 | if (wm8903->irq) { | 1896 | if (wm8903->irq) { |
1939 | if (pdata->irq_active_low) { | 1897 | if (pdata->irq_active_low) { |
1940 | trigger = IRQF_TRIGGER_LOW; | 1898 | trigger = IRQF_TRIGGER_LOW; |
@@ -2115,8 +2073,9 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c, | |||
2115 | { | 2073 | { |
2116 | struct wm8903_platform_data *pdata = dev_get_platdata(&i2c->dev); | 2074 | struct wm8903_platform_data *pdata = dev_get_platdata(&i2c->dev); |
2117 | struct wm8903_priv *wm8903; | 2075 | struct wm8903_priv *wm8903; |
2076 | bool mic_gpio = false; | ||
2118 | unsigned int val; | 2077 | unsigned int val; |
2119 | int ret; | 2078 | int ret, i; |
2120 | 2079 | ||
2121 | wm8903 = devm_kzalloc(&i2c->dev, sizeof(struct wm8903_priv), | 2080 | wm8903 = devm_kzalloc(&i2c->dev, sizeof(struct wm8903_priv), |
2122 | GFP_KERNEL); | 2081 | GFP_KERNEL); |
@@ -2160,6 +2119,8 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c, | |||
2160 | } | 2119 | } |
2161 | } | 2120 | } |
2162 | 2121 | ||
2122 | pdata = wm8903->pdata; | ||
2123 | |||
2163 | ret = regmap_read(wm8903->regmap, WM8903_SW_RESET_AND_ID, &val); | 2124 | ret = regmap_read(wm8903->regmap, WM8903_SW_RESET_AND_ID, &val); |
2164 | if (ret != 0) { | 2125 | if (ret != 0) { |
2165 | dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret); | 2126 | dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret); |
@@ -2184,6 +2145,47 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c, | |||
2184 | 2145 | ||
2185 | wm8903_init_gpio(wm8903); | 2146 | wm8903_init_gpio(wm8903); |
2186 | 2147 | ||
2148 | /* Set up GPIO pin state, detect if any are MIC detect outputs */ | ||
2149 | for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) { | ||
2150 | if ((!pdata->gpio_cfg[i]) || | ||
2151 | (pdata->gpio_cfg[i] > WM8903_GPIO_CONFIG_ZERO)) | ||
2152 | continue; | ||
2153 | |||
2154 | regmap_write(wm8903->regmap, WM8903_GPIO_CONTROL_1 + i, | ||
2155 | pdata->gpio_cfg[i] & 0x7fff); | ||
2156 | |||
2157 | val = (pdata->gpio_cfg[i] & WM8903_GP1_FN_MASK) | ||
2158 | >> WM8903_GP1_FN_SHIFT; | ||
2159 | |||
2160 | switch (val) { | ||
2161 | case WM8903_GPn_FN_MICBIAS_CURRENT_DETECT: | ||
2162 | case WM8903_GPn_FN_MICBIAS_SHORT_DETECT: | ||
2163 | mic_gpio = true; | ||
2164 | break; | ||
2165 | default: | ||
2166 | break; | ||
2167 | } | ||
2168 | } | ||
2169 | |||
2170 | /* Set up microphone detection */ | ||
2171 | regmap_write(wm8903->regmap, WM8903_MIC_BIAS_CONTROL_0, | ||
2172 | pdata->micdet_cfg); | ||
2173 | |||
2174 | /* Microphone detection needs the WSEQ clock */ | ||
2175 | if (pdata->micdet_cfg) | ||
2176 | regmap_update_bits(wm8903->regmap, WM8903_WRITE_SEQUENCER_0, | ||
2177 | WM8903_WSEQ_ENA, WM8903_WSEQ_ENA); | ||
2178 | |||
2179 | /* If microphone detection is enabled by pdata but | ||
2180 | * detected via IRQ then interrupts can be lost before | ||
2181 | * the machine driver has set up microphone detection | ||
2182 | * IRQs as the IRQs are clear on read. The detection | ||
2183 | * will be enabled when the machine driver configures. | ||
2184 | */ | ||
2185 | WARN_ON(!mic_gpio && (pdata->micdet_cfg & WM8903_MICDET_ENA)); | ||
2186 | |||
2187 | wm8903->mic_delay = pdata->micdet_delay; | ||
2188 | |||
2187 | ret = snd_soc_register_codec(&i2c->dev, | 2189 | ret = snd_soc_register_codec(&i2c->dev, |
2188 | &soc_codec_dev_wm8903, &wm8903_dai, 1); | 2190 | &soc_codec_dev_wm8903, &wm8903_dai, 1); |
2189 | if (ret != 0) | 2191 | if (ret != 0) |