diff options
author | Shengjiu Wang <shengjiu.wang@nxp.com> | 2018-08-02 19:53:36 +0800 |
---|---|---|
committer | Leonard Crestez <leonard.crestez@nxp.com> | 2018-08-24 12:41:33 +0300 |
commit | 1da83163044ff48b458b2380b206b95bd7a8171c (patch) | |
tree | e0182ce0e421f919ae6577cc8ed68ece72014a29 /sound | |
parent | e5fc2bf1176a4cbd06e53a44703b591fc866cf75 (diff) |
MLK-19118-1: ASoC: AK4458: add regulator for ak4458
add regulator for ak4458
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/ak4458.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index cb51b124fb5b..9f010fb3c064 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -32,9 +32,16 @@ #include <sound/tlv.h> #include <sound/pcm_params.h> #include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> #include "ak4458.h" +#define AK4458_NUM_SUPPLIES 2 +static const char *ak4458_supply_names[AK4458_NUM_SUPPLIES] = { + "DVDD", + "AVDD", +}; + /* AK4458 Codec Private Data */ struct ak4458_priv { struct device *dev; @@ -48,6 +55,7 @@ struct ak4458_priv { int fmt; int slots; int slot_width; + struct regulator_bulk_data supplies[AK4458_NUM_SUPPLIES]; }; static const struct reg_default ak4458_reg_defaults[] = { @@ -1109,6 +1117,7 @@ int ak4458_probe(struct device *dev, struct regmap *regmap) struct ak4458_priv *ak4458; struct device_node *np = dev->of_node; int ret; + int i; ak4458 = devm_kzalloc(dev, sizeof(*ak4458), GFP_KERNEL); if (!ak4458) @@ -1139,6 +1148,23 @@ int ak4458_probe(struct device *dev, struct regmap *regmap) } } + for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++) + ak4458->supplies[i].supply = ak4458_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ak4458->supplies), + ak4458->supplies); + if (ret != 0) { + dev_err(dev, "Failed to request supplies: %d\n", ret); + return ret; + } + + ret = regulator_bulk_enable(ARRAY_SIZE(ak4458->supplies), + ak4458->supplies); + if (ret != 0) { + dev_err(dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + ret = snd_soc_register_codec(dev, &soc_codec_dev_ak4458, &ak4458_dai, 1); if (ret < 0) { |