summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorShengjiu Wang <shengjiu.wang@nxp.com>2018-08-02 19:54:37 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commite6fe335f9ee2a880849f677a34ae3f234e6ba864 (patch)
treef51c1e43075b1a118f4d369610db2726a7f7495f /sound
parent9ce3285ce088652bcb78b7774c993589e54d0c9e (diff)
MLK-19118-3: ASoC: AK5558: add regulators for ak5558
add regulators for ak5558 Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/ak5558.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c
index f09fb9d9e480..4218178a6c47 100644
--- a/sound/soc/codecs/ak5558.c
+++ b/sound/soc/codecs/ak5558.c
@@ -29,6 +29,7 @@
#include <linux/of_gpio.h>
#include <linux/regmap.h>
#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
#include "ak5558.h"
@@ -37,6 +38,12 @@
/* enable debug */
/* #define AK5558_DEBUG */
+#define AK5558_NUM_SUPPLIES 2
+static const char *ak5558_supply_names[AK5558_NUM_SUPPLIES] = {
+ "DVDD",
+ "AVDD",
+};
+
/* AK5558 Codec Private Data */
struct ak5558_priv {
struct snd_soc_codec codec;
@@ -47,6 +54,7 @@ struct ak5558_priv {
int pdn_gpio; /* Power on / Reset GPIO */
int slots;
int slot_width;
+ struct regulator_bulk_data supplies[AK5558_NUM_SUPPLIES];
};
/* ak5558 register cache & default register settings */
@@ -744,8 +752,9 @@ static int ak5558_i2c_probe(struct i2c_client *i2c,
struct device_node *np = i2c->dev.of_node;
struct ak5558_priv *ak5558;
int ret = 0;
+ int i;
- dev_err(&i2c->dev, "%s(%d)\n", __func__, __LINE__);
+ dev_dbg(&i2c->dev, "%s(%d)\n", __func__, __LINE__);
ak5558 = devm_kzalloc(&i2c->dev, sizeof(struct ak5558_priv),
GFP_KERNEL);
@@ -769,6 +778,23 @@ static int ak5558_i2c_probe(struct i2c_client *i2c,
}
}
+ for (i = 0; i < ARRAY_SIZE(ak5558->supplies); i++)
+ ak5558->supplies[i].supply = ak5558_supply_names[i];
+
+ ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(ak5558->supplies),
+ ak5558->supplies);
+ if (ret != 0) {
+ dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
+ return ret;
+ }
+
+ ret = regulator_bulk_enable(ARRAY_SIZE(ak5558->supplies),
+ ak5558->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_ak5558,
&ak5558_dai, 1);
if (ret)