Skip to content

Commit

Permalink
ASoC: tlv320aic31xx: Reset registers during power up
Browse files Browse the repository at this point in the history
Add a reset function that toggles the reset line if available or uses
the software reset command otherwise. Use this in power up to ensure the
registers are in a sane state. This is useful when the driver module
is reloaded, or after Kexec, warm-reboots, etc..

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Andrew F. Davis authored and Mark Brown committed Dec 7, 2017
1 parent cd15da8 commit 0ce918c
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions sound/soc/codecs/tlv320aic31xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,22 @@ static int aic31xx_regulator_event(struct notifier_block *nb,
return 0;
}

static int aic31xx_reset(struct aic31xx_priv *aic31xx)
{
int ret = 0;

if (aic31xx->gpio_reset) {
gpiod_set_value(aic31xx->gpio_reset, 1);
ndelay(10); /* At least 10ns */
gpiod_set_value(aic31xx->gpio_reset, 0);
} else {
ret = regmap_write(aic31xx->regmap, AIC31XX_RESET, 1);
}
mdelay(1); /* At least 1ms */

return ret;
}

static void aic31xx_clk_on(struct snd_soc_codec *codec)
{
struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
Expand Down Expand Up @@ -1098,11 +1114,13 @@ static int aic31xx_power_on(struct snd_soc_codec *codec)
if (ret)
return ret;

if (aic31xx->gpio_reset) {
gpiod_set_value(aic31xx->gpio_reset, 0);
udelay(100);
}
regcache_cache_only(aic31xx->regmap, false);

/* Reset device registers for a consistent power-on like state */
ret = aic31xx_reset(aic31xx);
if (ret < 0)
dev_err(aic31xx->dev, "Could not reset device: %d\n", ret);

ret = regcache_sync(aic31xx->regmap);
if (ret) {
dev_err(codec->dev,
Expand Down

0 comments on commit 0ce918c

Please sign in to comment.