Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 332118
b: refs/heads/master
c: b306e84
h: refs/heads/master
v: v3
  • Loading branch information
Mark Brown committed Sep 19, 2012
1 parent b798ef1 commit 57fb28e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 35ecf7cd96a79d92c1b8433c950a827a2a723db9
refs/heads/master: b306e84f9a15e465812d9b66f8d6ecadae806f4c
60 changes: 33 additions & 27 deletions trunk/sound/soc/codecs/wm8961.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,6 @@ static bool wm8961_readable(struct device *dev, unsigned int reg)
}
}

static int wm8961_reset(struct snd_soc_codec *codec)
{
return snd_soc_write(codec, WM8961_SOFTWARE_RESET, 0);
}

/*
* The headphone output supports special anti-pop sequences giving
* silent power up and power down.
Expand Down Expand Up @@ -840,7 +835,6 @@ static struct snd_soc_dai_driver wm8961_dai = {

static int wm8961_probe(struct snd_soc_codec *codec)
{
struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec);
struct snd_soc_dapm_context *dapm = &codec->dapm;
int ret = 0;
u16 reg;
Expand All @@ -851,27 +845,6 @@ static int wm8961_probe(struct snd_soc_codec *codec)
return ret;
}

reg = snd_soc_read(codec, WM8961_SOFTWARE_RESET);
if (reg != 0x1801) {
dev_err(codec->dev, "Device is not a WM8961: ID=0x%x\n", reg);
return -EINVAL;
}

/* This isn't volatile - readback doesn't correspond to write */
regcache_cache_bypass(wm8961->regmap, true);
reg = snd_soc_read(codec, WM8961_RIGHT_INPUT_VOLUME);
regcache_cache_bypass(wm8961->regmap, false);
dev_info(codec->dev, "WM8961 family %d revision %c\n",
(reg & WM8961_DEVICE_ID_MASK) >> WM8961_DEVICE_ID_SHIFT,
((reg & WM8961_CHIP_REV_MASK) >> WM8961_CHIP_REV_SHIFT)
+ 'A');

ret = wm8961_reset(codec);
if (ret < 0) {
dev_err(codec->dev, "Failed to issue reset\n");
return ret;
}

/* Enable class W */
reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B);
reg |= WM8961_CP_DYN_PWR_MASK;
Expand Down Expand Up @@ -968,6 +941,7 @@ static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct wm8961_priv *wm8961;
unsigned int val;
int ret;

wm8961 = devm_kzalloc(&i2c->dev, sizeof(struct wm8961_priv),
Expand All @@ -979,6 +953,38 @@ static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
if (IS_ERR(wm8961->regmap))
return PTR_ERR(wm8961->regmap);

ret = regmap_read(wm8961->regmap, WM8961_SOFTWARE_RESET, &val);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to read chip ID: %d\n", ret);
return ret;
}

if (val != 0x1801) {
dev_err(&i2c->dev, "Device is not a WM8961: ID=0x%x\n", val);
return -EINVAL;
}

/* This isn't volatile - readback doesn't correspond to write */
regcache_cache_bypass(wm8961->regmap, true);
ret = regmap_read(wm8961->regmap, WM8961_RIGHT_INPUT_VOLUME, &val);
regcache_cache_bypass(wm8961->regmap, false);

if (ret != 0) {
dev_err(&i2c->dev, "Failed to read chip revision: %d\n", ret);
return ret;
}

dev_info(&i2c->dev, "WM8961 family %d revision %c\n",
(val & WM8961_DEVICE_ID_MASK) >> WM8961_DEVICE_ID_SHIFT,
((val & WM8961_CHIP_REV_MASK) >> WM8961_CHIP_REV_SHIFT)
+ 'A');

ret = regmap_write(wm8961->regmap, WM8961_SOFTWARE_RESET, 0x1801);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret);
return ret;
}

i2c_set_clientdata(i2c, wm8961);

ret = snd_soc_register_codec(&i2c->dev,
Expand Down

0 comments on commit 57fb28e

Please sign in to comment.