Skip to content

Commit

Permalink
LF-2644-3 ASoC: ak4458: use reset control instead of gpio
Browse files Browse the repository at this point in the history
Use reset control instead of GPIO to manage codec PDN pin.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
  • Loading branch information
Viorel Suman authored and Dong Aisheng committed Nov 2, 2021
1 parent 11c1c06 commit 2aee460
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sound/soc/codecs/ak4458.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <linux/of_gpio.h>
#include <linux/pm_runtime.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
#include <linux/slab.h>
#include <sound/initval.h>
#include <sound/pcm_params.h>
Expand Down Expand Up @@ -46,6 +47,7 @@ struct ak4458_priv {
struct device *dev;
struct regmap *regmap;
struct gpio_desc *reset_gpiod;
struct reset_control *reset;
struct gpio_desc *mute_gpiod;
int digfil; /* SSLOW, SD, SLOW bits */
int fs; /* sampling rate */
Expand Down Expand Up @@ -626,6 +628,12 @@ static void ak4458_reset(struct ak4458_priv *ak4458, bool active)
if (ak4458->reset_gpiod) {
gpiod_set_value_cansleep(ak4458->reset_gpiod, active);
usleep_range(1000, 2000);
} else if (!IS_ERR_OR_NULL(ak4458->reset)) {
if (active)
reset_control_assert(ak4458->reset);
else
reset_control_deassert(ak4458->reset);
msleep(5);
}
}

Expand Down Expand Up @@ -661,7 +669,6 @@ static int __maybe_unused ak4458_runtime_resume(struct device *dev)
if (ak4458->mute_gpiod)
gpiod_set_value_cansleep(ak4458->mute_gpiod, 1);

ak4458_reset(ak4458, true);
ak4458_reset(ak4458, false);

regcache_cache_only(ak4458->regmap, false);
Expand Down Expand Up @@ -743,6 +750,10 @@ static int ak4458_i2c_probe(struct i2c_client *i2c)

ak4458->drvdata = of_device_get_match_data(&i2c->dev);

ak4458->reset = devm_reset_control_get_optional_shared(ak4458->dev, NULL);
if (IS_ERR(ak4458->reset))
return PTR_ERR(ak4458->reset);

ak4458->reset_gpiod = devm_gpiod_get_optional(ak4458->dev, "reset",
GPIOD_OUT_LOW);
if (IS_ERR(ak4458->reset_gpiod))
Expand Down

0 comments on commit 2aee460

Please sign in to comment.