Commit 4d67dc19 authored by Alejandro Tafalla's avatar Alejandro Tafalla Committed by Mark Brown

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: default avatarAlejandro Tafalla <atafalla@dnyon.com>
Link: https://lore.kernel.org/r/d74b12a79ae9ca728d5d9e64c55b3e59e8c0e509.1633572679.git.atafalla@dnyon.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent dc1fad25
...@@ -897,6 +897,19 @@ static int max98927_i2c_probe(struct i2c_client *i2c, ...@@ -897,6 +897,19 @@ static int max98927_i2c_probe(struct i2c_client *i2c,
"Failed to allocate regmap: %d\n", ret); "Failed to allocate regmap: %d\n", ret);
return 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 */ /* Check Revision ID */
ret = regmap_read(max98927->regmap, ret = regmap_read(max98927->regmap,
...@@ -921,6 +934,17 @@ static int max98927_i2c_probe(struct i2c_client *i2c, ...@@ -921,6 +934,17 @@ static int max98927_i2c_probe(struct i2c_client *i2c,
return ret; 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[] = { static const struct i2c_device_id max98927_i2c_id[] = {
{ "max98927", 0}, { "max98927", 0},
{ }, { },
...@@ -952,6 +976,7 @@ static struct i2c_driver max98927_i2c_driver = { ...@@ -952,6 +976,7 @@ static struct i2c_driver max98927_i2c_driver = {
.pm = &max98927_pm, .pm = &max98927_pm,
}, },
.probe = max98927_i2c_probe, .probe = max98927_i2c_probe,
.remove = max98927_i2c_remove,
.id_table = max98927_i2c_id, .id_table = max98927_i2c_id,
}; };
......
...@@ -255,6 +255,7 @@ struct max98927_priv { ...@@ -255,6 +255,7 @@ struct max98927_priv {
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_component *component; struct snd_soc_component *component;
struct max98927_pdata *pdata; struct max98927_pdata *pdata;
struct gpio_desc *reset_gpio;
unsigned int spk_gain; unsigned int spk_gain;
unsigned int sysclk; unsigned int sysclk;
unsigned int v_l_slot; unsigned int v_l_slot;
......
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