Commit 20f2ab24 authored by Ryan Lee's avatar Ryan Lee Committed by Mark Brown

ASoC: max98373: Added max98373_reset for stable amp reset

This patch added max98373_reset function to avoid amp software reset failure and code duplication.
Reset verification step has been added for stable amp reset and it repeats verification maximum 3 times when it is failed.
Chip revision ID is available when the amp is in the idle state which means software reset is completed well.
Additional 10ms delay was added for every retrial and maximum 30ms delay can be applied.
Signed-off-by: default avatarRyan Lee <ryans.lee@maximintegrated.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0e3460bc
...@@ -724,14 +724,39 @@ static struct snd_soc_dai_driver max98373_dai[] = { ...@@ -724,14 +724,39 @@ static struct snd_soc_dai_driver max98373_dai[] = {
} }
}; };
static void max98373_reset(struct max98373_priv *max98373, struct device *dev)
{
int ret, reg, count;
/* Software Reset */
ret = regmap_update_bits(max98373->regmap,
MAX98373_R2000_SW_RESET,
MAX98373_SOFT_RESET,
MAX98373_SOFT_RESET);
if (ret)
dev_err(dev, "Reset command failed. (ret:%d)\n", ret);
count = 0;
while (count < 3) {
usleep_range(10000, 11000);
/* Software Reset Verification */
ret = regmap_read(max98373->regmap,
MAX98373_R21FF_REV_ID, &reg);
if (!ret) {
dev_info(dev, "Reset completed (retry:%d)\n", count);
return;
}
count++;
}
dev_err(dev, "Reset failed. (ret:%d)\n", ret);
}
static int max98373_probe(struct snd_soc_component *component) static int max98373_probe(struct snd_soc_component *component)
{ {
struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component);
/* Software Reset */ /* Software Reset */
regmap_write(max98373->regmap, max98373_reset(max98373, component->dev);
MAX98373_R2000_SW_RESET, MAX98373_SOFT_RESET);
usleep_range(10000, 11000);
/* IV default slot configuration */ /* IV default slot configuration */
regmap_write(max98373->regmap, regmap_write(max98373->regmap,
...@@ -818,9 +843,7 @@ static int max98373_resume(struct device *dev) ...@@ -818,9 +843,7 @@ static int max98373_resume(struct device *dev)
{ {
struct max98373_priv *max98373 = dev_get_drvdata(dev); struct max98373_priv *max98373 = dev_get_drvdata(dev);
regmap_write(max98373->regmap, max98373_reset(max98373, dev);
MAX98373_R2000_SW_RESET, MAX98373_SOFT_RESET);
usleep_range(10000, 11000);
regcache_cache_only(max98373->regmap, false); regcache_cache_only(max98373->regmap, false);
regcache_sync(max98373->regmap); regcache_sync(max98373->regmap);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment