From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Daniel Mack <daniel@caiaq.de>
Cc: alsa-devel@alsa-project.org, Timur Tabi <timur@freescale.com>,
Liam Girdwood <lrg@slimlogic.co.uk>
Subject: Re: [PATCH] ALSA: ASoc: Add regulator support to CS4270 codec driver
Date: Fri, 27 Nov 2009 11:25:51 +0000 [thread overview]
Message-ID: <20091127112550.GA29821@rakim.wolfsonmicro.main> (raw)
In-Reply-To: <20091126174245.GJ14091@buzzloop.caiaq.de>
On Thu, Nov 26, 2009 at 06:42:45PM +0100, Daniel Mack wrote:
> On Thu, Nov 26, 2009 at 04:03:51PM +0000, Mark Brown wrote:
> > You can test the flow by defining a fixed voltage regulator with no soft
> > control, obviously it won't actually turn the power on or off but the
> > code will run.
> Ok. I couldn't find a dummy framework for such cases, and registering a
> full regulator just to satisfy the codec code seems a litte cumbersome.
> Is there anything like that? Or should there be?
That's what the fixed voltage regulator was there for originally - the
GPIO is a later additional and is optional.
> > terribly well. Currently the assumption is that if you've built in the
> > regulator API you intend to use it, otherwise it's very hard to tell if
> > the operation failed and broke something or failed because the API isn't
> > in use.
> Hmm - that will break all existing platforms that use this codec and
> need regulators for other drivers. But ok, I'm fine with forcing
> everyone to innovation :)
It's difficult to do much more without making driver code using
regulators more cumbersome - the need to figure out of the error is a
real one or due to partial API usage makes things painful. If this were
supported it'd be better to do it with a fudge in the API rather than in
driver code, we really want to keep the drivers as simple as possible to
reduce the burden on them.
> Ok, done - see the new patch below. I did use the regulator_bulk
> functions in the first place, but due to the VA special case, I had to
> extract the single regulators again from the bulk struct which turned
> out to mess the code quite a bit. Looks better this way.
Yes, due to the one special regulator you have the bulk functions don't
help here.
> +
> + switch (level) {
> + case SND_SOC_BIAS_ON:
> + ret = regulator_enable(cs4270->vd_reg);
> + if (ret < 0)
> + return ret;
> + ret = regulator_enable(cs4270->vlc_reg);
> + if (ret < 0)
> + return ret;
> + /* fall thru */
I'd expect these to just be enabled on OFF->STANDBY (or in the suspend
code indeed) - you'll need to restore the register cache after the
digital comes up anyway.
Also, you'll leak references since you only turn them off when going
into OFF but enable them every time you go to ON.
> + case SND_SOC_BIAS_STANDBY:
> + if (codec->bias_level == SND_SOC_BIAS_OFF) {
> + /* OFF -> STANDBY */
> + ret = regulator_enable(cs4270->va_reg);
> + if (ret < 0)
> + return ret;
> + } else
> + regulator_disable(cs4270->va_reg);
> + break;
Moving this into PREPARE and checking if the previous level was STANDBY
is probably more what you mean, otherwise the audio will be burning
power from startup until the first audio has played.
>
> + cs4270_set_bias_level(codec, SND_SOC_BIAS_OFF);
> +
> return snd_soc_write(codec, CS4270_PWRCTL, reg);
I think you need to reverse these so that you turn off the supplies
after you've done the soft power off.
> @@ -833,6 +918,11 @@ static int cs4270_soc_resume(struct platform_device *pdev)
> struct i2c_client *i2c_client = codec->control_data;
> int reg;
>
> + cs4270_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
> +
> + if (codec->suspend_bias_level == SND_SOC_BIAS_ON)
> + cs4270_set_bias_level(codec, SND_SOC_BIAS_ON);
> +
The core should take care of the BIAS_ON bit for you these days (some
drivers do do it by hand for historical reasons or because they're being
a bit naughty with the bias levels).
next prev parent reply other threads:[~2009-11-27 11:25 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-25 14:36 [PATCH] ALSA: ASoc: Add regulator support to CS4270 codec driver Daniel Mack
2009-11-25 15:01 ` Mark Brown
2009-11-25 15:20 ` Daniel Mack
2009-11-25 15:38 ` Mark Brown
2009-11-25 15:46 ` Daniel Mack
2009-11-26 15:48 ` Daniel Mack
2009-11-26 16:03 ` Mark Brown
2009-11-26 17:42 ` Daniel Mack
2009-11-27 11:25 ` Mark Brown [this message]
2009-11-27 12:41 ` Daniel Mack
2009-11-27 13:32 ` Mark Brown
2009-11-28 20:23 ` Timur Tabi
2009-11-28 20:31 ` Mark Brown
2009-11-28 22:18 ` Timur Tabi
2009-11-29 0:44 ` Daniel Mack
2009-11-29 4:34 ` Timur Tabi
2009-11-29 8:35 ` Daniel Mack
2009-11-30 10:12 ` Daniel Mack
[not found] ` <5610599F537DD74A8D1F5CC946A7507303478C40@az33exm25.fsl.freescale.net>
2009-11-30 12:01 ` Mark Brown
2009-11-30 12:36 ` Daniel Mack
2009-11-30 15:57 ` Daniel Mack
2009-11-30 16:12 ` Mark Brown
2009-11-30 16:51 ` Daniel Mack
2009-11-30 16:56 ` Daniel Mack
2009-12-04 12:00 ` Daniel Mack
2009-12-04 12:07 ` Mark Brown
2009-12-05 2:54 ` Timur Tabi
2009-12-05 3:51 ` Mark Brown
2009-12-05 17:03 ` Timur Tabi
2009-12-07 13:16 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091127112550.GA29821@rakim.wolfsonmicro.main \
--to=broonie@opensource.wolfsonmicro.com \
--cc=alsa-devel@alsa-project.org \
--cc=daniel@caiaq.de \
--cc=lrg@slimlogic.co.uk \
--cc=timur@freescale.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.