* [PATCH] ASoC: AK4458: add regulator for ak4458
@ 2019-05-16 13:00 Viorel Suman
2019-05-16 13:14 ` [alsa-devel] " Fabio Estevam
2019-05-16 14:16 ` Daniel Baluta
0 siblings, 2 replies; 5+ messages in thread
From: Viorel Suman @ 2019-05-16 13:00 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
S.j. Wang, Viorel Suman, Daniel Baluta, Julia Lawall,
Colin Ian King, alsa-devel, linux-kernel
Cc: dl-linux-imx, Viorel Suman
From: Shengjiu Wang <shengjiu.wang@nxp.com>
Add regulator for ak4458.
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
---
sound/soc/codecs/ak4458.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
index 7156215..06dcf13 100644
--- a/sound/soc/codecs/ak4458.c
+++ b/sound/soc/codecs/ak4458.c
@@ -12,6 +12,7 @@
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/pm_runtime.h>
+#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <sound/initval.h>
#include <sound/pcm_params.h>
@@ -21,6 +22,12 @@
#include "ak4458.h"
+#define AK4458_NUM_SUPPLIES 2
+static const char *ak4458_supply_names[AK4458_NUM_SUPPLIES] = {
+ "DVDD",
+ "AVDD",
+};
+
struct ak4458_drvdata {
struct snd_soc_dai_driver *dai_drv;
const struct snd_soc_component_driver *comp_drv;
@@ -37,6 +44,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[] = {
@@ -666,7 +674,7 @@ static int ak4458_i2c_probe(struct i2c_client *i2c)
{
struct ak4458_priv *ak4458;
const struct ak4458_drvdata *drvdata;
- int ret;
+ int ret, i;
ak4458 = devm_kzalloc(&i2c->dev, sizeof(*ak4458), GFP_KERNEL);
if (!ak4458)
@@ -691,6 +699,23 @@ static int ak4458_i2c_probe(struct i2c_client *i2c)
if (IS_ERR(ak4458->mute_gpiod))
return PTR_ERR(ak4458->mute_gpiod);
+ for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++)
+ ak4458->supplies[i].supply = ak4458_supply_names[i];
+
+ ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies),
+ ak4458->supplies);
+ if (ret != 0) {
+ dev_err(ak4458->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(ak4458->dev, "Failed to enable supplies: %d\n", ret);
+ return ret;
+ }
+
ret = devm_snd_soc_register_component(ak4458->dev, drvdata->comp_drv,
drvdata->dai_drv, 1);
if (ret < 0) {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH] ASoC: AK4458: add regulator for ak4458
2019-05-16 13:00 [PATCH] ASoC: AK4458: add regulator for ak4458 Viorel Suman
@ 2019-05-16 13:14 ` Fabio Estevam
2019-05-16 14:11 ` Viorel Suman
2019-05-16 16:54 ` Mark Brown
2019-05-16 14:16 ` Daniel Baluta
1 sibling, 2 replies; 5+ messages in thread
From: Fabio Estevam @ 2019-05-16 13:14 UTC (permalink / raw)
To: Viorel Suman
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
S.j. Wang, Daniel Baluta, Julia Lawall, Colin Ian King,
alsa-devel, linux-kernel, Viorel Suman, dl-linux-imx
On Thu, May 16, 2019 at 10:02 AM Viorel Suman <viorel.suman@nxp.com> wrote:
> + for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++)
> + ak4458->supplies[i].supply = ak4458_supply_names[i];
> +
> + ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies),
> + ak4458->supplies);
> + if (ret != 0) {
> + dev_err(ak4458->dev, "Failed to request supplies: %d\n", ret);
> + return ret;
This would break existing users that do not pass the regulators in device tree.
Ok, in this case there is no ak4458 user in any dts, so that would not
be an issue.
Please update the dt-bindings with the regulator entries.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH] ASoC: AK4458: add regulator for ak4458
2019-05-16 13:14 ` [alsa-devel] " Fabio Estevam
@ 2019-05-16 14:11 ` Viorel Suman
2019-05-16 16:54 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Viorel Suman @ 2019-05-16 14:11 UTC (permalink / raw)
To: festevam
Cc: dl-linux-imx, linux-kernel, colin.king, viorel.suman, broonie,
tiwai, lgirdwood, S.j. Wang, Julia.Lawall, Daniel Baluta, perex,
alsa-devel
On Jo, 2019-05-16 at 10:14 -0300, Fabio Estevam wrote:
> On Thu, May 16, 2019 at 10:02 AM Viorel Suman <viorel.suman@nxp.com> wrote:
>
> >
> > + for (i = 0; i < ARRAY_SIZE(ak4458->supplies); i++)
> > + ak4458->supplies[i].supply = ak4458_supply_names[i];
> > +
> > + ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies),
> > + ak4458->supplies);
> > + if (ret != 0) {
> > + dev_err(ak4458->dev, "Failed to request supplies: %d\n", ret);
> > + return ret;
> This would break existing users that do not pass the regulators in device tree.
>
> Ok, in this case there is no ak4458 user in any dts, so that would not
> be an issue.
>
> Please update the dt-bindings with the regulator entries.
Thanks, will send in V2.
/Viorel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: AK4458: add regulator for ak4458
2019-05-16 13:00 [PATCH] ASoC: AK4458: add regulator for ak4458 Viorel Suman
2019-05-16 13:14 ` [alsa-devel] " Fabio Estevam
@ 2019-05-16 14:16 ` Daniel Baluta
1 sibling, 0 replies; 5+ messages in thread
From: Daniel Baluta @ 2019-05-16 14:16 UTC (permalink / raw)
To: linux-kernel, colin.king, broonie, tiwai, lgirdwood,
Viorel Suman, S.j. Wang, Julia.Lawall, perex, alsa-devel
Cc: dl-linux-imx, viorel.suman
On Thu, 2019-05-16 at 13:00 +0000, Viorel Suman wrote:
> From: Shengjiu Wang <shengjiu.wang@nxp.com>
>
> Add regulator for ak4458.
>
Hi Viorel,
While at it please disable/enable the regulator in suspend/resume.
thanks,
Daniel.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH] ASoC: AK4458: add regulator for ak4458
2019-05-16 13:14 ` [alsa-devel] " Fabio Estevam
2019-05-16 14:11 ` Viorel Suman
@ 2019-05-16 16:54 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2019-05-16 16:54 UTC (permalink / raw)
To: Fabio Estevam
Cc: Viorel Suman, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
S.j. Wang, Daniel Baluta, Julia Lawall, Colin Ian King,
alsa-devel, linux-kernel, Viorel Suman, dl-linux-imx
[-- Attachment #1: Type: text/plain, Size: 675 bytes --]
On Thu, May 16, 2019 at 10:14:42AM -0300, Fabio Estevam wrote:
> > + ret = devm_regulator_bulk_get(ak4458->dev, ARRAY_SIZE(ak4458->supplies),
> > + ak4458->supplies);
> > + if (ret != 0) {
> > + dev_err(ak4458->dev, "Failed to request supplies: %d\n", ret);
> > + return ret;
> This would break existing users that do not pass the regulators in device tree.
It won't, if you're using regulator_get() and there's just no regulator
in the DT the regulator framework just assumes that there is actually a
regulator there which isn't described in the DT and substitutes in a
dummy regulator for you.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-05-16 16:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 13:00 [PATCH] ASoC: AK4458: add regulator for ak4458 Viorel Suman
2019-05-16 13:14 ` [alsa-devel] " Fabio Estevam
2019-05-16 14:11 ` Viorel Suman
2019-05-16 16:54 ` Mark Brown
2019-05-16 14:16 ` Daniel Baluta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).