devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: Bill Huang <bilhuang@nvidia.com>
Cc: sameo@linux.intel.com, rob.herring@calxeda.com,
	pawel.moll@arm.com, mark.rutland@arm.com, swarren@wwwdotorg.org,
	ian.campbell@citrix.com, rob@landley.net, lee.jones@linaro.org,
	broonie@linaro.org, j-keerthy@ti.com, grant.likely@linaro.org,
	ian@slimlogic.co.uk, devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Mallikarjun Kasoju <mkasoju@nvidia.com>
Subject: Re: [PATCH v2 1/1] mfd: palmas: Add power off control
Date: Wed, 31 Jul 2013 06:57:56 -0500	[thread overview]
Message-ID: <51F8FBC4.1040009@ti.com> (raw)
In-Reply-To: <1375255037-10024-1-git-send-email-bilhuang@nvidia.com>

On 07/31/2013 02:17 AM, Bill Huang wrote:
> Hook up "pm_power_off" to palmas power off routine if there is DT
> property "ti,system-power-controller" defined, so platform which is
> powered by this regulator can be powered off properly.
>
> Based on work by:
> Mallikarjun Kasoju <mkasoju@nvidia.com>
>
> Signed-off-by: Bill Huang <bilhuang@nvidia.com>
> cc: Mallikarjun Kasoju <mkasoju@nvidia.com>
> ---
>   .../devicetree/bindings/regulator/palmas-pmic.txt  |    5 +++
>   drivers/mfd/palmas.c                               |   33 ++++++++++++++++++--

Since the specific question on v1 was not answered, I will ask again, 
any reason why it wont fit in drivers/power/reset/ is'nt it the right
place to add this?


>   include/linux/mfd/palmas.h                         |    1 +
>   3 files changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
> index 30b0581..4adca2a 100644
> --- a/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
> +++ b/Documentation/devicetree/bindings/regulator/palmas-pmic.txt
> @@ -36,6 +36,9 @@ Optional nodes:
>   	       ti,smps-range - OTP has the wrong range set for the hardware so override
>   	       0 - low range, 1 - high range.
>
> +- ti,system-power-controller: Telling whether or not this pmic is controlling
> +			      the system power.
> +
>   Example:
>
>   #include <dt-bindings/interrupt-controller/irq.h>
> @@ -48,6 +51,8 @@ pmic {
>
>   	ti,ldo6-vibrator;
>
> +	ti,system-power-controller;
> +
>   	regulators {
>   		smps12_reg : smps12 {
>   			regulator-name = "smps12";
> diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c
> index e4d1c70..220a34d 100644
> --- a/drivers/mfd/palmas.c
> +++ b/drivers/mfd/palmas.c
> @@ -229,6 +229,32 @@ static void palmas_dt_to_pdata(struct i2c_client *i2c,
>   					PALMAS_POWER_CTRL_ENABLE2_MASK;
>   	if (i2c->irq)
>   		palmas_set_pdata_irq_flag(i2c, pdata);
> +
> +	pdata->pm_off = of_property_read_bool(node,
> +			"ti,system-power-controller");
> +}
> +
> +static struct palmas *palmas_dev;
> +static void palmas_power_off(void)
> +{
> +	unsigned int addr;
> +	int ret, slave;
> +
> +	if (!palmas_dev)
> +		return;
> +

If you notice the reference code I send, atleast on TWL6035/37 variants 
of Palmas, USB IRQ unmask is mandatory for power on with USB cable - 
example usage scenario: extremely low battery, device powered off, plug 
in usb cable to restart charging - you'd like to initiate charging logic 
in bootloader, but that wont work if the device does not do OFF-ON 
transition with usb cable plugged in for vbus.

> +	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
> +	addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE, PALMAS_DEV_CTRL);
> +
> +	ret = regmap_update_bits(
> +			palmas_dev->regmap[slave],
> +			addr,
> +			PALMAS_DEV_CTRL_DEV_ON,
> +			0);
> +
> +	if (ret)
> +		pr_err("%s: Unable to write to DEV_CTRL_DEV_ON: %d\n",
> +				__func__, ret);
>   }
>
>   static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST;
> @@ -423,10 +449,13 @@ no_irq:
>   	 */
>   	if (node) {
>   		ret = of_platform_populate(node, NULL, NULL, &i2c->dev);
> -		if (ret < 0)
> +		if (ret < 0) {
>   			goto err_irq;
> -		else
> +		} else if (pdata->pm_off && !pm_power_off) {
> +			palmas_dev = palmas;
> +			pm_power_off = palmas_power_off;
>   			return ret;
> +		}
>   	}
>
>   	return ret;
> diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
> index 1a8dd7a..061cce0 100644
> --- a/include/linux/mfd/palmas.h
> +++ b/include/linux/mfd/palmas.h
> @@ -258,6 +258,7 @@ struct palmas_platform_data {
>   	 */
>   	int mux_from_pdata;
>   	u8 pad1, pad2;
> +	bool pm_off;
>
>   	struct palmas_pmic_platform_data *pmic_pdata;
>   	struct palmas_gpadc_platform_data *gpadc_pdata;
>


-- 
Regards,
Nishanth Menon

  reply	other threads:[~2013-07-31 11:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-31  7:17 [PATCH v2 1/1] mfd: palmas: Add power off control Bill Huang
2013-07-31 11:57 ` Nishanth Menon [this message]
2013-07-31 17:20   ` Stephen Warren
2013-07-31 18:31     ` Nishanth Menon
2013-08-01 11:08   ` Bill Huang
2013-08-01 13:08     ` Nishanth Menon
2013-08-02  5:45       ` Bill Huang
2013-08-02 14:39         ` Nishanth Menon
2013-08-05 10:32           ` Bill Huang

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=51F8FBC4.1040009@ti.com \
    --to=nm@ti.com \
    --cc=bilhuang@nvidia.com \
    --cc=broonie@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=ian@slimlogic.co.uk \
    --cc=j-keerthy@ti.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mkasoju@nvidia.com \
    --cc=pawel.moll@arm.com \
    --cc=rob.herring@calxeda.com \
    --cc=rob@landley.net \
    --cc=sameo@linux.intel.com \
    --cc=swarren@wwwdotorg.org \
    /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 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).