summaryrefslogtreecommitdiff
path: root/sound/soc
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2018-08-02 19:54:19 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commit9ce3285ce088652bcb78b7774c993589e54d0c9e (patch)
tree4dd917fd1caa130b1a471c0a4d924cb8fa5e5dbd /sound/soc
parent1da83163044ff48b458b2380b206b95bd7a8171c (diff)
MLK-19118-2: ASoC: AK4497: add regulators for ak4497
add regulators for ak4497 Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/ak4497.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/sound/soc/codecs/ak4497.c b/sound/soc/codecs/ak4497.c
index e2f8e3382a89..eee1afb81b8c 100644
--- a/sound/soc/codecs/ak4497.c
+++ b/sound/soc/codecs/ak4497.c
@@ -26,10 +26,16 @@
#include <linux/regmap.h>
#include <sound/pcm_params.h>
#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
#include "ak4497.h"
//#define AK4497_DEBUG //used at debug mode
+#define AK4497_NUM_SUPPLIES 2
+static const char *ak4497_supply_names[AK4497_NUM_SUPPLIES] = {
+ "DVDD",
+ "AVDD",
+};
/* AK4497 Codec Private Data */
struct ak4497_priv {
@@ -41,6 +47,7 @@ struct ak4497_priv {
int pdn_gpio;
int mute_gpio;
int fmt;
+ struct regulator_bulk_data supplies[AK4497_NUM_SUPPLIES];
};
/* ak4497 register cache & default register settings */
@@ -1008,6 +1015,7 @@ static int ak4497_i2c_probe(struct i2c_client *i2c,
{
struct ak4497_priv *ak4497;
int ret = 0;
+ int i;
ak4497 = devm_kzalloc(&i2c->dev,
sizeof(struct ak4497_priv), GFP_KERNEL);
@@ -1021,12 +1029,27 @@ static int ak4497_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, ak4497);
ak4497->i2c = i2c;
+ for (i = 0; i < ARRAY_SIZE(ak4497->supplies); i++)
+ ak4497->supplies[i].supply = ak4497_supply_names[i];
+
+ ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(ak4497->supplies),
+ ak4497->supplies);
+ if (ret != 0) {
+ dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
+ return ret;
+ }
+
+ ret = regulator_bulk_enable(ARRAY_SIZE(ak4497->supplies),
+ ak4497->supplies);
+ if (ret != 0) {
+ dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
+ return ret;
+ }
+
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4497,
&ak4497_dai[0], ARRAY_SIZE(ak4497_dai));
- if (ret < 0) {
- kfree(ak4497);
+ if (ret < 0)
return ret;
- }
pm_runtime_enable(&i2c->dev);