diff options
author | Alejandro Tafalla <atafalla@dnyon.com> | 2021-10-07 04:38:56 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-10-07 15:45:18 +0100 |
commit | 4d67dc1998f1890a9d22d03208037075ea9f2562 (patch) | |
tree | 03e92c0be550ca71ca9073e972d7eeea012531b3 /sound/soc/codecs/max98927.c | |
parent | dc1fad25bbd0698e8e61a0468e3920c5c29a803f (diff) | |
download | linux-stable-4d67dc1998f1890a9d22d03208037075ea9f2562.tar.gz linux-stable-4d67dc1998f1890a9d22d03208037075ea9f2562.tar.bz2 linux-stable-4d67dc1998f1890a9d22d03208037075ea9f2562.zip |
ASoC: max98927: Handle reset gpio when probing i2c
The max98927 codec on some devices requires pulling a reset gpio before
responding to any i2c command. This commit adds support for it through
an optional reset-gpios property.
Signed-off-by: Alejandro Tafalla <atafalla@dnyon.com>
Link: https://lore.kernel.org/r/d74b12a79ae9ca728d5d9e64c55b3e59e8c0e509.1633572679.git.atafalla@dnyon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/codecs/max98927.c')
-rw-r--r-- | sound/soc/codecs/max98927.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index 8b206ee77709..5ba5f876eab8 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -897,6 +897,19 @@ static int max98927_i2c_probe(struct i2c_client *i2c, "Failed to allocate regmap: %d\n", ret); return ret; } + + max98927->reset_gpio + = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(max98927->reset_gpio)) { + ret = PTR_ERR(max98927->reset_gpio); + return dev_err_probe(&i2c->dev, ret, "failed to request GPIO reset pin"); + } + + if (max98927->reset_gpio) { + gpiod_set_value_cansleep(max98927->reset_gpio, 0); + /* Wait for i2c port to be ready */ + usleep_range(5000, 6000); + } /* Check Revision ID */ ret = regmap_read(max98927->regmap, @@ -921,6 +934,17 @@ static int max98927_i2c_probe(struct i2c_client *i2c, return ret; } +static int max98927_i2c_remove(struct i2c_client *i2c) +{ + struct max98927_priv *max98927 = i2c_get_clientdata(i2c); + + if (max98927->reset_gpio) { + gpiod_set_value_cansleep(max98927->reset_gpio, 1); + } + + return 0; +} + static const struct i2c_device_id max98927_i2c_id[] = { { "max98927", 0}, { }, @@ -952,6 +976,7 @@ static struct i2c_driver max98927_i2c_driver = { .pm = &max98927_pm, }, .probe = max98927_i2c_probe, + .remove = max98927_i2c_remove, .id_table = max98927_i2c_id, }; |