All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: alsa-devel@alsa-project.org, Samuel Ortiz <sameo@linux.intel.com>,
	Tony Lindgren <tony@atomide.com>, Dmitry Torokhov <dtor@mail.ru>,
	linux-kernel@vger.kernel.org,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Misael Lopez Cruz <misael.lopez@ti.com>,
	linux-omap@vger.kernel.org, Liam Girdwood <lrg@ti.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC 7/7] MFD: TWL6040: Add regulator support for VIO, V2V1 supplies
Date: Thu, 02 Feb 2012 15:18:09 +0200	[thread overview]
Message-ID: <4F2A8D11.9010705@ti.com> (raw)
In-Reply-To: <20120202125250.GJ7428@opensource.wolfsonmicro.com>

On 02/02/2012 02:52 PM, Mark Brown wrote:
> On Thu, Feb 02, 2012 at 02:16:59PM +0200, Peter Ujfalusi wrote:
> 
>> +	twl6040->vio = regulator_get(&client->dev, "vio");
>> +	if (IS_ERR(twl6040->vio)) {
>> +		ret = PTR_ERR(twl6040->vio);
>> +		dev_err(&client->dev, "Failed to request VIO supply: %d\n",
>> +			ret);
>> +		goto regulator_get_err;
>> +	}
>> +	twl6040->v2v1 = regulator_get(&client->dev, "v2v1");
>> +	if (IS_ERR(twl6040->v2v1)) {
>> +		ret = PTR_ERR(twl6040->v2v1);
>> +		dev_err(&client->dev, "Failed to request V2V1 supply: %d\n",
>> +			ret);
>> +		regulator_put(twl6040->vio);
>> +		goto regulator_get_err;
>> +	}
> 
> Looks like you want regulator_bulk_get() here.  Or (better yet though
> it'd be a potential issue for merge via MFD and the benefits aren't that
> exciting since you still need to disable) devm_regulator_bulk_get().

I need separate control for the two power source since we can hit
different power levels depending on which is powered/not powered:
power down: vio, v2v1 is OFF
deep sleep: vio is ON, v2v1 is OFF
sleep/power on: vio, v2v1 is ON

And we have certain sequence to move between power states.

> 
>> +	ret = regulator_enable(twl6040->vio);
>> +	if (ret != 0) {
>> +		dev_err(&client->dev, "Failed to enable VIO: %d\n", ret);
>> +		goto power_err;
>> +	}
>> +	ret = regulator_enable(twl6040->v2v1);
>> +	if (ret != 0) {
>> +		dev_err(&client->dev, "Failed to enable V2V1: %d\n", ret);
>> +		regulator_disable(twl6040->vio);

I disable the vio here, if the v2v1 enable fails.

>> +		goto power_err;
>> +	}
> 
> Similarly regulator_bulk_enable() here, and it'll fix...
> 
>>  gpio1_err:
>> +	regulator_disable(twl6040->v2v1);
>> +	regulator_disable(twl6040->vio);
> 
> ...the fact that if you fail to enable the v2.1 regulator you don't
> disable vio.

It is handled within the if(){}
With the devm_regulator this will be much nicer for sure.

-- 
Péter

WARNING: multiple messages have this Message-ID (diff)
From: peter.ujfalusi@ti.com (Peter Ujfalusi)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 7/7] MFD: TWL6040: Add regulator support for VIO, V2V1 supplies
Date: Thu, 02 Feb 2012 15:18:09 +0200	[thread overview]
Message-ID: <4F2A8D11.9010705@ti.com> (raw)
In-Reply-To: <20120202125250.GJ7428@opensource.wolfsonmicro.com>

On 02/02/2012 02:52 PM, Mark Brown wrote:
> On Thu, Feb 02, 2012 at 02:16:59PM +0200, Peter Ujfalusi wrote:
> 
>> +	twl6040->vio = regulator_get(&client->dev, "vio");
>> +	if (IS_ERR(twl6040->vio)) {
>> +		ret = PTR_ERR(twl6040->vio);
>> +		dev_err(&client->dev, "Failed to request VIO supply: %d\n",
>> +			ret);
>> +		goto regulator_get_err;
>> +	}
>> +	twl6040->v2v1 = regulator_get(&client->dev, "v2v1");
>> +	if (IS_ERR(twl6040->v2v1)) {
>> +		ret = PTR_ERR(twl6040->v2v1);
>> +		dev_err(&client->dev, "Failed to request V2V1 supply: %d\n",
>> +			ret);
>> +		regulator_put(twl6040->vio);
>> +		goto regulator_get_err;
>> +	}
> 
> Looks like you want regulator_bulk_get() here.  Or (better yet though
> it'd be a potential issue for merge via MFD and the benefits aren't that
> exciting since you still need to disable) devm_regulator_bulk_get().

I need separate control for the two power source since we can hit
different power levels depending on which is powered/not powered:
power down: vio, v2v1 is OFF
deep sleep: vio is ON, v2v1 is OFF
sleep/power on: vio, v2v1 is ON

And we have certain sequence to move between power states.

> 
>> +	ret = regulator_enable(twl6040->vio);
>> +	if (ret != 0) {
>> +		dev_err(&client->dev, "Failed to enable VIO: %d\n", ret);
>> +		goto power_err;
>> +	}
>> +	ret = regulator_enable(twl6040->v2v1);
>> +	if (ret != 0) {
>> +		dev_err(&client->dev, "Failed to enable V2V1: %d\n", ret);
>> +		regulator_disable(twl6040->vio);

I disable the vio here, if the v2v1 enable fails.

>> +		goto power_err;
>> +	}
> 
> Similarly regulator_bulk_enable() here, and it'll fix...
> 
>>  gpio1_err:
>> +	regulator_disable(twl6040->v2v1);
>> +	regulator_disable(twl6040->vio);
> 
> ...the fact that if you fail to enable the v2.1 regulator you don't
> disable vio.

It is handled within the if(){}
With the devm_regulator this will be much nicer for sure.

-- 
P?ter

WARNING: multiple messages have this Message-ID (diff)
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Tony Lindgren <tony@atomide.com>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	Liam Girdwood <lrg@ti.com>, Dmitry Torokhov <dtor@mail.ru>,
	Misael Lopez Cruz <misael.lopez@ti.com>,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	alsa-devel@alsa-project.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC 7/7] MFD: TWL6040: Add regulator support for VIO, V2V1 supplies
Date: Thu, 02 Feb 2012 15:18:09 +0200	[thread overview]
Message-ID: <4F2A8D11.9010705@ti.com> (raw)
In-Reply-To: <20120202125250.GJ7428@opensource.wolfsonmicro.com>

On 02/02/2012 02:52 PM, Mark Brown wrote:
> On Thu, Feb 02, 2012 at 02:16:59PM +0200, Peter Ujfalusi wrote:
> 
>> +	twl6040->vio = regulator_get(&client->dev, "vio");
>> +	if (IS_ERR(twl6040->vio)) {
>> +		ret = PTR_ERR(twl6040->vio);
>> +		dev_err(&client->dev, "Failed to request VIO supply: %d\n",
>> +			ret);
>> +		goto regulator_get_err;
>> +	}
>> +	twl6040->v2v1 = regulator_get(&client->dev, "v2v1");
>> +	if (IS_ERR(twl6040->v2v1)) {
>> +		ret = PTR_ERR(twl6040->v2v1);
>> +		dev_err(&client->dev, "Failed to request V2V1 supply: %d\n",
>> +			ret);
>> +		regulator_put(twl6040->vio);
>> +		goto regulator_get_err;
>> +	}
> 
> Looks like you want regulator_bulk_get() here.  Or (better yet though
> it'd be a potential issue for merge via MFD and the benefits aren't that
> exciting since you still need to disable) devm_regulator_bulk_get().

I need separate control for the two power source since we can hit
different power levels depending on which is powered/not powered:
power down: vio, v2v1 is OFF
deep sleep: vio is ON, v2v1 is OFF
sleep/power on: vio, v2v1 is ON

And we have certain sequence to move between power states.

> 
>> +	ret = regulator_enable(twl6040->vio);
>> +	if (ret != 0) {
>> +		dev_err(&client->dev, "Failed to enable VIO: %d\n", ret);
>> +		goto power_err;
>> +	}
>> +	ret = regulator_enable(twl6040->v2v1);
>> +	if (ret != 0) {
>> +		dev_err(&client->dev, "Failed to enable V2V1: %d\n", ret);
>> +		regulator_disable(twl6040->vio);

I disable the vio here, if the v2v1 enable fails.

>> +		goto power_err;
>> +	}
> 
> Similarly regulator_bulk_enable() here, and it'll fix...
> 
>>  gpio1_err:
>> +	regulator_disable(twl6040->v2v1);
>> +	regulator_disable(twl6040->vio);
> 
> ...the fact that if you fail to enable the v2.1 regulator you don't
> disable vio.

It is handled within the if(){}
With the devm_regulator this will be much nicer for sure.

-- 
Péter

  reply	other threads:[~2012-02-02 13:18 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02 12:16 [RFC 0/7] MFD: twl6040: Conversion to i2c driver Peter Ujfalusi
2012-02-02 12:16 ` Peter Ujfalusi
2012-02-02 12:16 ` [RFC 1/7] MFD: twl-core: Detach twl6040 from the pmic mfd driver Peter Ujfalusi
2012-02-02 12:16   ` Peter Ujfalusi
2012-02-02 12:16   ` Peter Ujfalusi
2012-02-02 12:16 ` [RFC 2/7] MFD: twl6040: Convert to i2c driver, and separate it from twl core Peter Ujfalusi
2012-02-02 12:16   ` Peter Ujfalusi
2012-02-02 12:48   ` Mark Brown
2012-02-02 12:48     ` Mark Brown
2012-02-02 13:01     ` Peter Ujfalusi
2012-02-02 13:01       ` Peter Ujfalusi
2012-02-02 13:27       ` Mark Brown
2012-02-02 13:27         ` Mark Brown
2012-02-02 13:27         ` Mark Brown
2012-02-02 12:16 ` [RFC 3/7] ASoC: twl6040: Remove dependency on twl4030 from Kconfig Peter Ujfalusi
2012-02-02 12:42   ` Mark Brown
2012-02-02 12:42     ` Mark Brown
2012-02-02 12:42     ` Mark Brown
2012-02-02 12:16 ` [RFC 4/7] OMAP: 4430sdp: Correct fixed regulator device ID Peter Ujfalusi
2012-02-02 12:16   ` Peter Ujfalusi
2012-02-02 12:38   ` Mark Brown
2012-02-02 12:38     ` Mark Brown
2012-02-02 12:38     ` Mark Brown
2012-02-02 12:16 ` [RFC 5/7] OMAP: sdp4430: Add fixed regulator for twl6040 needs Peter Ujfalusi
2012-02-02 12:40   ` Mark Brown
2012-02-02 12:40     ` Mark Brown
2012-02-02 12:40     ` Mark Brown
2012-02-02 13:03     ` Peter Ujfalusi
2012-02-02 13:03       ` Peter Ujfalusi
2012-02-02 12:16 ` [RFC 6/7] OMAP: omap4panda: " Peter Ujfalusi
2012-02-02 12:41   ` Mark Brown
2012-02-02 12:41     ` Mark Brown
2012-02-02 12:41     ` Mark Brown
2012-02-02 12:16 ` [RFC 7/7] MFD: TWL6040: Add regulator support for VIO, V2V1 supplies Peter Ujfalusi
2012-02-02 12:52   ` Mark Brown
2012-02-02 12:52     ` Mark Brown
2012-02-02 12:52     ` Mark Brown
2012-02-02 13:18     ` Peter Ujfalusi [this message]
2012-02-02 13:18       ` Peter Ujfalusi
2012-02-02 13:18       ` Peter Ujfalusi
2012-02-02 13:32       ` Mark Brown
2012-02-02 13:32         ` Mark Brown
2012-02-02 13:32         ` Mark Brown
2012-02-02 13:59         ` Peter Ujfalusi
2012-02-02 13:59           ` Peter Ujfalusi
2012-02-02 13:59           ` Peter Ujfalusi
2012-02-02 14:19           ` Mark Brown
2012-02-02 14:19             ` Mark Brown
2012-02-02 14:19             ` 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=4F2A8D11.9010705@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dtor@mail.ru \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=misael.lopez@ti.com \
    --cc=sameo@linux.intel.com \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.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.