From: Igor Grinberg <grinberg@compulab.co.il>
To: Igor Grinberg <grinberg@compulab.co.il>
Cc: Samuel Ortiz <sameo@linux.intel.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] MFD: TWL: add power off functionality
Date: Sun, 27 Nov 2011 11:42:17 +0200 [thread overview]
Message-ID: <4ED205F9.3070908@compulab.co.il> (raw)
In-Reply-To: <1321177790-5886-1-git-send-email-grinberg@compulab.co.il>
ping!
On 11/13/11 11:49, Igor Grinberg wrote:
> TWL family of PMICs, used in master mode, have a power off
> functionality. The resulting power off sequence shuts down all the SoC
> supplies, LDOs, etc. The sequence is described in the datasheets
> chapter "Power-Off Sequence".
> Note, that board must be wired correctly for the power off to work as
> expected.
>
> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
> ---
> drivers/mfd/twl4030-power.c | 42 ++++++++++++++++++++++++++++++++++++++++--
> include/linux/i2c/twl.h | 2 ++
> 2 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index a764676..d905f51 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -34,7 +34,8 @@
> static u8 twl4030_start_script_address = 0x2b;
>
> #define PWR_P1_SW_EVENTS 0x10
> -#define PWR_DEVOFF (1<<0)
> +#define PWR_DEVOFF (1 << 0)
> +#define SEQ_OFFSYNC (1 << 0)
>
> #define PHY_TO_OFF_PM_MASTER(p) (p - 0x36)
> #define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b)
> @@ -511,12 +512,27 @@ int twl4030_remove_script(u8 flags)
> return err;
> }
>
> +/*
> + * In master mode, start the power off sequence.
> + * After a successful execution, TWL shuts down the power to the SoC
> + * and all peripherals connected to it.
> + */
> +void twl4030_power_off(void)
> +{
> + int err;
> +
> + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, PWR_DEVOFF,
> + TWL4030_PM_MASTER_P1_SW_EVENTS);
> + if (err)
> + pr_err("TWL4030 Unable to power off\n");
> +}
> +
> void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
> {
> int err = 0;
> int i;
> struct twl4030_resconfig *resconfig;
> - u8 address = twl4030_start_script_address;
> + u8 val, address = twl4030_start_script_address;
>
> err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER,
> TWL4030_PM_MASTER_KEY_CFG1,
> @@ -548,6 +564,28 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
> }
> }
>
> + /* Board has to be wired properly to use this feature */
> + if (twl4030_scripts->use_poweroff && !pm_power_off) {
> + /* Default for SEQ_OFFSYNC is set, lets ensure this */
> + err = twl_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
> + TWL4030_PM_MASTER_CFG_P123_TRANSITION);
> + if (err) {
> + pr_warning("TWL4030 Unable to read registers\n");
> +
> + } else if (!(val & SEQ_OFFSYNC)) {
> + val |= SEQ_OFFSYNC;
> + err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
> + TWL4030_PM_MASTER_CFG_P123_TRANSITION);
> + if (err) {
> + pr_err("TWL4030 Unable to setup SEQ_OFFSYNC\n");
> + goto relock;
> + }
> + }
> +
> + pm_power_off = twl4030_power_off;
> + }
> +
> +relock:
> err = twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0,
> TWL4030_PM_MASTER_PROTECT_KEY);
> if (err)
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index 114c0f6..78d3465 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -652,10 +652,12 @@ struct twl4030_power_data {
> unsigned num;
> struct twl4030_resconfig *resource_config;
> #define TWL4030_RESCONFIG_UNDEF ((u8)-1)
> + bool use_poweroff; /* Board is wired for TWL poweroff */
> };
>
> extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
> extern int twl4030_remove_script(u8 flags);
> +extern void twl4030_power_off(void);
>
> struct twl4030_codec_data {
> unsigned int digimic_delay; /* in ms */
--
Regards,
Igor.
next prev parent reply other threads:[~2011-11-27 9:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-13 9:49 [PATCH] MFD: TWL: add power off functionality Igor Grinberg
2011-11-27 9:42 ` Igor Grinberg [this message]
2011-12-03 1:35 ` NeilBrown
2011-12-04 9:56 ` Igor Grinberg
2011-12-04 10:58 ` NeilBrown
2011-12-04 21:43 ` NeilBrown
2011-12-05 7:31 ` Igor Grinberg
2011-12-13 9:50 ` Igor Grinberg
2011-12-19 11:36 ` Samuel Ortiz
2011-12-19 11:45 ` NeilBrown
2011-12-19 15:38 ` Samuel Ortiz
2011-12-19 15:05 ` Igor Grinberg
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=4ED205F9.3070908@compulab.co.il \
--to=grinberg@compulab.co.il \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox