aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8903.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-02 13:39:17 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-12-03 06:00:10 -0500
commit7d46a528c609418e0a61121aac75edaf4992b622 (patch)
treeded806106d32054eaf17b440e42364e827ede758 /sound/soc/codecs/wm8903.c
parentee244ce4ea5651989229d7f287f777f68104a59a (diff)
ASoC: Move initial WM8903 identification and reset to I2C probe
Get control of the device earlier and avoid trying to do an ASoC probe on a card that won't work. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'sound/soc/codecs/wm8903.c')
-rw-r--r--sound/soc/codecs/wm8903.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c
index 0b12a5525c15..a75688b5a568 100644
--- a/sound/soc/codecs/wm8903.c
+++ b/sound/soc/codecs/wm8903.c
@@ -244,11 +244,6 @@ static bool wm8903_volatile_register(struct device *dev, unsigned int reg)
244 } 244 }
245} 245}
246 246
247static void wm8903_reset(struct snd_soc_codec *codec)
248{
249 snd_soc_write(codec, WM8903_SW_RESET_AND_ID, 0);
250}
251
252static int wm8903_cp_event(struct snd_soc_dapm_widget *w, 247static int wm8903_cp_event(struct snd_soc_dapm_widget *w,
253 struct snd_kcontrol *kcontrol, int event) 248 struct snd_kcontrol *kcontrol, int event)
254{ 249{
@@ -1892,19 +1887,6 @@ static int wm8903_probe(struct snd_soc_codec *codec)
1892 return ret; 1887 return ret;
1893 } 1888 }
1894 1889
1895 val = snd_soc_read(codec, WM8903_SW_RESET_AND_ID);
1896 if (val != 0x8903) {
1897 dev_err(codec->dev,
1898 "Device with ID register %x is not a WM8903\n", val);
1899 return -ENODEV;
1900 }
1901
1902 val = snd_soc_read(codec, WM8903_REVISION_NUMBER);
1903 dev_info(codec->dev, "WM8903 revision %c\n",
1904 (val & WM8903_CHIP_REV_MASK) + 'A');
1905
1906 wm8903_reset(codec);
1907
1908 /* Set up GPIOs and microphone detection */ 1890 /* Set up GPIOs and microphone detection */
1909 if (pdata) { 1891 if (pdata) {
1910 bool mic_gpio = false; 1892 bool mic_gpio = false;
@@ -2058,6 +2040,7 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
2058 const struct i2c_device_id *id) 2040 const struct i2c_device_id *id)
2059{ 2041{
2060 struct wm8903_priv *wm8903; 2042 struct wm8903_priv *wm8903;
2043 unsigned int val;
2061 int ret; 2044 int ret;
2062 2045
2063 wm8903 = devm_kzalloc(&i2c->dev, sizeof(struct wm8903_priv), 2046 wm8903 = devm_kzalloc(&i2c->dev, sizeof(struct wm8903_priv),
@@ -2076,6 +2059,28 @@ static __devinit int wm8903_i2c_probe(struct i2c_client *i2c,
2076 i2c_set_clientdata(i2c, wm8903); 2059 i2c_set_clientdata(i2c, wm8903);
2077 wm8903->irq = i2c->irq; 2060 wm8903->irq = i2c->irq;
2078 2061
2062 ret = regmap_read(wm8903->regmap, WM8903_SW_RESET_AND_ID, &val);
2063 if (ret != 0) {
2064 dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret);
2065 goto err;
2066 }
2067 if (val != 0x8903) {
2068 dev_err(&i2c->dev, "Device with ID %x is not a WM8903\n", val);
2069 ret = -ENODEV;
2070 goto err;
2071 }
2072
2073 ret = regmap_read(wm8903->regmap, WM8903_REVISION_NUMBER, &val);
2074 if (ret != 0) {
2075 dev_err(&i2c->dev, "Failed to read chip revision: %d\n", ret);
2076 goto err;
2077 }
2078 dev_info(&i2c->dev, "WM8903 revision %c\n",
2079 (val & WM8903_CHIP_REV_MASK) + 'A');
2080
2081 /* Reset the device */
2082 regmap_write(wm8903->regmap, WM8903_SW_RESET_AND_ID, 0x8903);
2083
2079 ret = snd_soc_register_codec(&i2c->dev, 2084 ret = snd_soc_register_codec(&i2c->dev,
2080 &soc_codec_dev_wm8903, &wm8903_dai, 1); 2085 &soc_codec_dev_wm8903, &wm8903_dai, 1);
2081 if (ret != 0) 2086 if (ret != 0)