Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: ak4458: add optional reset control to instead of gpio

Add optional reset control instead of GPIO to manage codec
PDN pin.

As there is reference counter for reset control, so need
to remove one ak4458_reset in runtime resume to make the
reference counter balance.

Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Link: https://lore.kernel.org/r/1665664611-21350-1-git-send-email-shengjiu.wang@nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Viorel Suman and committed by
Mark Brown
8a0de73c 29dbfeec

+12 -1
+12 -1
sound/soc/codecs/ak4458.c
··· 13 13 #include <linux/of_gpio.h> 14 14 #include <linux/pm_runtime.h> 15 15 #include <linux/regulator/consumer.h> 16 + #include <linux/reset.h> 16 17 #include <linux/slab.h> 17 18 #include <sound/initval.h> 18 19 #include <sound/pcm_params.h> ··· 47 46 struct device *dev; 48 47 struct regmap *regmap; 49 48 struct gpio_desc *reset_gpiod; 49 + struct reset_control *reset; 50 50 struct gpio_desc *mute_gpiod; 51 51 int digfil; /* SSLOW, SD, SLOW bits */ 52 52 int fs; /* sampling rate */ ··· 635 633 if (ak4458->reset_gpiod) { 636 634 gpiod_set_value_cansleep(ak4458->reset_gpiod, active); 637 635 usleep_range(1000, 2000); 636 + } else if (!IS_ERR_OR_NULL(ak4458->reset)) { 637 + if (active) 638 + reset_control_assert(ak4458->reset); 639 + else 640 + reset_control_deassert(ak4458->reset); 641 + usleep_range(1000, 2000); 638 642 } 639 643 } 640 644 ··· 676 668 if (ak4458->mute_gpiod) 677 669 gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); 678 670 679 - ak4458_reset(ak4458, true); 680 671 ak4458_reset(ak4458, false); 681 672 682 673 regcache_cache_only(ak4458->regmap, false); ··· 754 747 ak4458->dev = &i2c->dev; 755 748 756 749 ak4458->drvdata = of_device_get_match_data(&i2c->dev); 750 + 751 + ak4458->reset = devm_reset_control_get_optional_shared(ak4458->dev, NULL); 752 + if (IS_ERR(ak4458->reset)) 753 + return PTR_ERR(ak4458->reset); 757 754 758 755 ak4458->reset_gpiod = devm_gpiod_get_optional(ak4458->dev, "reset", 759 756 GPIOD_OUT_LOW);