Skip to contentSkip to conversation

ASoC: rt5682s: Separate the regulator consumer controls

PATCH Superseded [email protected] 2 participants 2 messages Mar 25, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: rt5682s: Separate the regulator consumer controls

From: Derek Fang <[email protected]>

Control the regulators separately instead of using regulator_bulk to accord to the timing request in the datasheet.

---
 sound/soc/codecs/rt5682s.c | 26 +++++++++++++++++++++-----
 sound/soc/codecs/rt5682s.h |  6 +++++-
 2 files changed, 26 insertions(+), 6 deletions(-)
sound/soc/codecs/rt5682s.c +21 -5
index 1cba8ec7cedb..b8bf9aede29c 100644
@@ -42,8 +42,8 @@ static const struct rt5682s_platform_data i2s_default_platform_data = {
 };
 
 static const char *rt5682s_supply_names[RT5682S_NUM_SUPPLIES] = {
-	"AVDD",
-	"MICVDD",
+	[RT5682S_SUPPLY_AVDD] = "AVDD",
+	[RT5682S_SUPPLY_MICVDD] = "MICVDD",
 };
 
 static const struct reg_sequence patch_list[] = {
@@ -3025,8 +3025,17 @@ static struct snd_soc_dai_driver rt5682s_dai[] = {
 static void rt5682s_i2c_disable_regulators(void *data)
 {
 	struct rt5682s_priv *rt5682s = data;
+	int ret;
+
+	ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_AVDD].consumer);
+	if (ret)
+		pr_err("%s: Failed to disable supply AVDD: %d\n", __func__, ret);
 
-	regulator_bulk_disable(ARRAY_SIZE(rt5682s->supplies), rt5682s->supplies);
+	usleep_range(1000, 1500);
+
+	ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_MICVDD].consumer);
+	if (ret)
+		pr_err("%s: Failed to disable supply MICVDD: %d\n", __func__, ret);
 }
 
 static int rt5682s_i2c_probe(struct i2c_client *i2c,
@@ -3071,9 +3080,16 @@ static int rt5682s_i2c_probe(struct i2c_client *i2c,
 	if (ret)
 		return ret;
 
-	ret = regulator_bulk_enable(ARRAY_SIZE(rt5682s->supplies), rt5682s->supplies);
+	ret = regulator_enable(rt5682s->supplies[RT5682S_SUPPLY_MICVDD].consumer);
+	if (ret) {
+		dev_err(&i2c->dev, "Failed to enable supply MICVDD: %d\n", ret);
+		return ret;
+	}
+	usleep_range(1000, 1500);
+
+	ret = regulator_enable(rt5682s->supplies[RT5682S_SUPPLY_AVDD].consumer);
 	if (ret) {
-		dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
+		dev_err(&i2c->dev, "Failed to enable supply AVDD: %d\n", ret);
 		return ret;
 	}
 
sound/soc/codecs/rt5682s.h +5 -1
index 397a2531b6f6..7353831c73dd 100644
@@ -1434,7 +1434,11 @@ struct pll_calc_map {
 	bool sel_ps;
 };
 
-#define RT5682S_NUM_SUPPLIES 2
+enum {
+	RT5682S_SUPPLY_AVDD,
+	RT5682S_SUPPLY_MICVDD,
+	RT5682S_NUM_SUPPLIES,
+};
 
 struct rt5682s_priv {
 	struct snd_soc_component *component;
Signature · 1 line
2.17.1
maintainer
#1 lore raw

sound/soc/codecs/rt5682s.c static struct snd_soc_dai_driver rt5682s_dai[] = { · line 3032

Quoted 9 lines · On Fri, Mar 25, 2022 at 03:55:32PM +0800, [email protected] wrote:
sound/soc/codecs/rt5682s.c +5 -0
@@ -3025,8 +3025,17 @@ static struct snd_soc_dai_driver rt5682s_dai[] = {
 static void rt5682s_i2c_disable_regulators(void *data)
 {
 	struct rt5682s_priv *rt5682s = data;
+	int ret;
+
+	ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_AVDD].consumer);
+	if (ret)
+		pr_err("%s: Failed to disable supply AVDD: %d\n", __func__, ret);

Please use dev_err() for error reporting. Otherwise this looks fine.