]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ASoC: max98383: fix i2c probe failure
authorfengchunguo <chunguo.feng@amlogic.com>
Mon, 15 Jul 2019 09:55:56 +0000 (17:55 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 22 Jul 2019 12:26:15 +0000 (13:26 +0100)
Added reset_gpio configuration for i2c probe successfully.
If not,i2c address can't be found rightly.

Error information:
max98373 3-0031: Failed to read: 0x21FF

Fixed:
[3.761299@3] max98373 3-0031: MAX98373 revisionID: 0x43
[3.828911@3] asoc-aml-card auge_sound: max98373-aif1 <-> TDM-B mapping ok

Signed-off-by: fengchunguo <chunguo.feng@amlogic.com>
Link: https://lore.kernel.org/r/20190715095556.1614-1-chunguo.feng@amlogic.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/max98373.c
sound/soc/codecs/max98373.h

index 528695cd6a1ca7fef5e2812d86fbe283f677b34e..9a1eb7222357d2b8d38a2d81b3c9a121b2b23f55 100644 (file)
@@ -12,6 +12,7 @@
 #include <sound/pcm_params.h>
 #include <sound/soc.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
 #include <linux/of_gpio.h>
 #include <sound/tlv.h>
 #include "max98373.h"
@@ -895,6 +896,17 @@ static void max98373_slot_config(struct i2c_client *i2c,
        else
                max98373->i_slot = 1;
 
+       max98373->reset_gpio = of_get_named_gpio(dev->of_node,
+                                               "maxim,reset-gpio", 0);
+       if (!gpio_is_valid(max98373->reset_gpio)) {
+               dev_err(dev, "Looking up %s property in node %s failed %d\n",
+                       "maxim,reset-gpio", dev->of_node->full_name,
+                       max98373->reset_gpio);
+       } else {
+               dev_dbg(dev, "maxim,reset-gpio=%d",
+                       max98373->reset_gpio);
+       }
+
        if (!device_property_read_u32(dev, "maxim,spkfb-slot-no", &value))
                max98373->spkfb_slot = value & 0xF;
        else
@@ -923,7 +935,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c,
        else
                max98373->interleave_mode = false;
 
-
        /* regmap initialization */
        max98373->regmap
                = devm_regmap_init_i2c(i2c, &max98373_regmap);
@@ -934,6 +945,24 @@ static int max98373_i2c_probe(struct i2c_client *i2c,
                return ret;
        }
 
+       /* voltage/current slot & gpio configuration */
+       max98373_slot_config(i2c, max98373);
+
+       /* Power on device */
+       if (gpio_is_valid(max98373->reset_gpio)) {
+               ret = gpio_request(max98373->reset_gpio, "MAX98373_RESET");
+               if (ret) {
+                       dev_err(&i2c->dev, "%s: Failed to request gpio %d\n",
+                               __func__, max98373->reset_gpio);
+                       gpio_free(max98373->reset_gpio);
+                       return -EINVAL;
+               }
+               gpio_direction_output(max98373->reset_gpio, 0);
+               msleep(50);
+               gpio_direction_output(max98373->reset_gpio, 1);
+               msleep(20);
+       }
+
        /* Check Revision ID */
        ret = regmap_read(max98373->regmap,
                MAX98373_R21FF_REV_ID, &reg);
@@ -944,9 +973,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c,
        }
        dev_info(&i2c->dev, "MAX98373 revisionID: 0x%02X\n", reg);
 
-       /* voltage/current slot configuration */
-       max98373_slot_config(i2c, max98373);
-
        /* codec registeration */
        ret = devm_snd_soc_register_component(&i2c->dev, &soc_codec_dev_max98373,
                max98373_dai, ARRAY_SIZE(max98373_dai));
index f6a37aa02f2665ea67dda2dcc4441763765b9f76..533d2053f6087d95a7707a30a31088b43861456e 100644 (file)
 
 struct max98373_priv {
        struct regmap *regmap;
+       int reset_gpio;
        unsigned int v_slot;
        unsigned int i_slot;
        unsigned int spkfb_slot;