aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown2021-10-07 22:24:59 +0100
committerMark Brown2021-10-07 22:24:59 +0100
commit06a0fc36a5292ad35ee5768be110b5453a639c1d (patch)
tree751a1312ab5fca8678f4fb6d336c22a1e6f8ceed
parent99f11b6552fa36da107a6a92773a11109107b686 (diff)
parentb23d3189c038c091adc8de382d20a8f5321645a1 (diff)
Merge series "Add reset-gpios handling for max98927" from Alejandro Tafalla <atafalla@dnyon.com>:
The max98927 codec on some devices (i.e. Xiaomi Mi A2 Lite phone) requires hardware-resetting the codec by driving a reset-gpio. This series adds support for it through an optional reset-gpios property. v4: * Correctly assert/deassert the GPIO states * Wait for the i2c port to be ready after reset * Reset device when removed v3: * Fix indentation on the dev_err_probe line v2: * Use dev_err_probe instead of dev_err Alejandro Tafalla (2): ASoC: max98927: Handle reset gpio when probing i2c dt-bindings: sound: max98927: Add reset-gpios optional property .../devicetree/bindings/sound/max9892x.txt | 3 +++ sound/soc/codecs/max98927.c | 25 +++++++++++++++++++ sound/soc/codecs/max98927.h | 1 + 3 files changed, 29 insertions(+) -- 2.33.0
-rw-r--r--Documentation/devicetree/bindings/sound/max9892x.txt3
-rw-r--r--sound/soc/codecs/max98927.c25
-rw-r--r--sound/soc/codecs/max98927.h1
3 files changed, 29 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/sound/max9892x.txt b/Documentation/devicetree/bindings/sound/max9892x.txt
index f6171591ddc6..98cb9ba5b328 100644
--- a/Documentation/devicetree/bindings/sound/max9892x.txt
+++ b/Documentation/devicetree/bindings/sound/max9892x.txt
@@ -30,6 +30,9 @@ Required properties:
- reg : the I2C address of the device for I2C
+Optional properties:
+ - reset-gpios : GPIO to reset the device
+
Example:
codec: max98927@3a {
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,
};
diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h
index 05f495db914d..13f5066d7419 100644
--- a/sound/soc/codecs/max98927.h
+++ b/sound/soc/codecs/max98927.h
@@ -255,6 +255,7 @@ struct max98927_priv {
struct regmap *regmap;
struct snd_soc_component *component;
struct max98927_pdata *pdata;
+ struct gpio_desc *reset_gpio;
unsigned int spk_gain;
unsigned int sysclk;
unsigned int v_l_slot;