Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards

2011-03-08 Thread Nishanth Menon

Kevin Hilman wrote, on 03/08/2011 02:32 AM:

Lesly A M  writes:


Power bus message sequence for TWL4030 to enter sleep/wakeup/warm_reset.

TWL4030 power scripts which can be used by different OMAP3 boards
with the power companion chip (TWL4030 series).

The twl4030 generic script is exported and can be used by any other
boardfile to update the power data in twl4030_platform_data.

http://omapedia.org/wiki/TWL4030_power_scripts


This is a very helpful wiki page, thanks for writing that up.

I'd recommend putting a link into the C file as well, saying this code
implements the recommended sequence as detailed at.
yes it definitely will help - esp duplicating essential parts from the 
wiki in C code. one issue I have with wiki based off line documentation 
is the following: we do have a Documentation/ folder which probably 
should contain the documentation necessary for this.


Ideally there are three main events that occur:
a) OFF mode transition
b) RET transition
c) warm reset

in addition assumptions that NSLEEP2 is not plugged to anything else may 
not be true always - for e.g. for handheld devices it is possible that 
NSLEEP2 is controlled by Modem because one of the rails is supplied from 
TWL. These assumptions should be clearly stated in comments as it is 
possible to fall into the trap of using the default scripts without 
understanding the basic assumptions involved.
IMHO, assumption section for the default script should at the very least 
state:
a) what are the rails that will be controlled by the script and what 
rails are expected to be controlled by drivers (e.g. vmmc) - has impact 
on power consumption
b) what signalling is expected in OFF, RET and warm reset - a basic 
assumption is useful here.

c) what rails go to what level on each of the transitions of OFF/RET/reset

Just my 2 cents having forced myself to read code without looking at the 
wiki.


[...]

--
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards

2011-03-08 Thread Menon, Nishanth
On Wed, Mar 2, 2011 at 19:00, Lesly A M  wrote:
[...]
> diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c
> new file mode 100644
> index 000..ff344b3
> --- /dev/null
> +++ b/arch/arm/mach-omap2/twl4030.c
> @@ -0,0 +1,145 @@
> +/*
> + * OMAP power script for PMIC TWL4030
> + *
> + * Author: Lesly A M 
> + *
> + * Copyright (C) 2010 Texas Instruments, Inc.
> + * Lesly A M 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifdef CONFIG_TWL4030_POWER

Why?

> +
> +#include "twl4030.h"
> +
> +/*
> + * Sequence to control the TRITON Power resources,
> + * when the system goes into sleep.
> + * Executed upon P1_P2/P3 transition for sleep.
> + */
try this:
./scripts/kernel-doc --text arch/arm/mach-omap2/twl4030.c
Warning(arch/arm/mach-omap2/twl4030.c): no structured comments found

err... mebbe we need kernel doc styled comments here?

> +static struct twl4030_ins __initdata sleep_on_seq[] = {
does this sequence get triggered for RET or OFF from OMAP perspective?

> +       /* Broadcast message to put res to sleep */
> +       {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
> +                                                       RES_STATE_SLEEP), 2},
At this point - we expect .type=0 and .type2=1 to go to sleep rt?
NRESPWRON is the only one that matched this criteria.

> +       {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +                                                       RES_STATE_SLEEP), 2},
At this point - we expect .type=0 and .type2=1 to go to sleep rt?
HFCLKOUT, VINTANA2 matches this criteria

Which rails are impacted by this? I tried mapping to a spread sheet
and may be lost :(
mebbe documenting it with reasoning why they are chosen will help
reviewers and future
code users understand this better.

> +};
> +
> +static struct twl4030_script sleep_on_script __initdata = {
> +       .script = sleep_on_seq,
> +       .size   = ARRAY_SIZE(sleep_on_seq),
> +       .flags  = TWL4030_SLEEP_SCRIPT,
> +};
> +
> +/*
> + * Sequence to control the TRITON Power resources,
> + * when the system wakeup from sleep.
> + * Executed upon P1_P2 transition for wakeup.
> + */
> +static struct twl4030_ins wakeup_p12_seq[] __initdata = {
> +       /* Broadcast message to put res to active */
> +       {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
> +                                                       RES_STATE_ACTIVE), 2},
.type=0 and .type2=1 are woken up rt?
NRESPWRON wokeup but we put HFCLKOUT and VINTANA2 to sleep - no wakeup
for those?

> +};
> +
> +static struct twl4030_script wakeup_p12_script __initdata = {
> +       .script = wakeup_p12_seq,
> +       .size   = ARRAY_SIZE(wakeup_p12_seq),
> +       .flags  = TWL4030_WAKEUP12_SCRIPT,
> +};
> +
> +/*
> + * Sequence to control the TRITON Power resources,
> + * when the system wakeup from sleep.
> + * Executed upon P3 transition for wakeup.

I need a bit of dumbing it down here - what is P3 transition? is it
waking from OFF/RET? is it follow on from P12 then P3?

> + */
> +static struct twl4030_ins wakeup_p3_seq[] __initdata = {
> +       /* Broadcast message to put res to active */
> +       {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +                                                       RES_STATE_ACTIVE), 2},
ok - so we wakeup HFCLKOUT and VINTANA2 here - makes me wonder why we
chose VINTANA2 and not VINTANA1.

> +};
> +
> +static struct twl4030_script wakeup_p3_script __initdata = {
> +       .script = wakeup_p3_seq,
> +       .size   = ARRAY_SIZE(wakeup_p3_seq),
> +       .flags  = TWL4030_WAKEUP3_SCRIPT,
> +};
> +
> +/*
> + * Sequence to reset the TRITON Power resources,
> + * when the system gets warm reset.
> + * Executed upon warm reset signal.
this one makes sense to me thanks.
> + */
> +static struct twl4030_ins wrst_seq[] __initdata = {
> +/*
> + * Reset twl4030.
Why should I reset twl4030 on warm reset? cant I just let the scripts
sit there while I detect (using some mechanism) that i have already
programmed the scripts, hence dont need to reprogram them again?

> + * Reset Main_Ref.
> + * Reset All type2_group2.
> + * Reset VUSB_3v1.
> + * Reset All type2_group1.
> + * Reset RC.
what is RC?
> + * Reenable twl4030.
re-enable?

but, I dont understand: why are these rails chosen? are *all*
platforms having the same rails? would there be variances?

> + */
> +       {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
> +       {MSG_SINGULAR(DEV_GRP_NULL, RES_Main_Ref, RES_STATE_WRST), 2},
s/RES_Main_Ref/RES_MAIN_REF ?

> +       {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +                                                       RES_STATE_WRST), 2},
> +       {MSG_SINGULAR(DEV_GRP_NULL, RES_VUSB_3V1, RES_STATE_WRST), 2},
> +       {MSG_

Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards

2011-03-07 Thread Manuel, Lesly Arackal
Hi Kevin,

On Tue, Mar 8, 2011 at 2:32 AM, Kevin Hilman  wrote:
> Lesly A M  writes:
>
>> Power bus message sequence for TWL4030 to enter sleep/wakeup/warm_reset.
>>
>> TWL4030 power scripts which can be used by different OMAP3 boards
>> with the power companion chip (TWL4030 series).
>>
>> The twl4030 generic script is exported and can be used by any other
>> boardfile to update the power data in twl4030_platform_data.
>>
>> http://omapedia.org/wiki/TWL4030_power_scripts
>
> This is a very helpful wiki page, thanks for writing that up.
>
> I'd recommend putting a link into the C file as well, saying this code
> implements the recommended sequence as detailed at .
>
> One minor nit on naming here.  I think you should use the public name
> TWL4030 throughout instead of Triton (which AFAIK, is not an acronym and
> should not be capitalized.)
>

I will add this link in the c file,
also correct the naming to TWL4030.

Thanks & Regards,
Lesly A M
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards

2011-03-07 Thread Kevin Hilman
Lesly A M  writes:

> Power bus message sequence for TWL4030 to enter sleep/wakeup/warm_reset.
>
> TWL4030 power scripts which can be used by different OMAP3 boards
> with the power companion chip (TWL4030 series).
>
> The twl4030 generic script is exported and can be used by any other
> boardfile to update the power data in twl4030_platform_data.
>
> http://omapedia.org/wiki/TWL4030_power_scripts

This is a very helpful wiki page, thanks for writing that up.

I'd recommend putting a link into the C file as well, saying this code
implements the recommended sequence as detailed at .

One minor nit on naming here.  I think you should use the public name
TWL4030 throughout instead of Triton (which AFAIK, is not an acronym and
should not be capitalized.)

Kevin

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards

2011-03-02 Thread Lesly A M
Power bus message sequence for TWL4030 to enter sleep/wakeup/warm_reset.

TWL4030 power scripts which can be used by different OMAP3 boards
with the power companion chip (TWL4030 series).

The twl4030 generic script is exported and can be used by any other
boardfile to update the power data in twl4030_platform_data.

http://omapedia.org/wiki/TWL4030_power_scripts

Signed-off-by: Lesly A M 
Cc: Nishanth Menon 
Cc: David Derrick 
Cc: Samuel Ortiz 
---
 arch/arm/mach-omap2/twl4030.c |  145 +
 arch/arm/mach-omap2/twl4030.h |   20 ++
 include/linux/i2c/twl.h   |   33 +-
 3 files changed, 195 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-omap2/twl4030.c
 create mode 100644 arch/arm/mach-omap2/twl4030.h

diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c
new file mode 100644
index 000..ff344b3
--- /dev/null
+++ b/arch/arm/mach-omap2/twl4030.c
@@ -0,0 +1,145 @@
+/*
+ * OMAP power script for PMIC TWL4030
+ *
+ * Author: Lesly A M 
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Lesly A M 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifdef CONFIG_TWL4030_POWER
+
+#include "twl4030.h"
+
+/*
+ * Sequence to control the TRITON Power resources,
+ * when the system goes into sleep.
+ * Executed upon P1_P2/P3 transition for sleep.
+ */
+static struct twl4030_ins __initdata sleep_on_seq[] = {
+   /* Broadcast message to put res to sleep */
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
+   RES_STATE_SLEEP), 2},
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+   RES_STATE_SLEEP), 2},
+};
+
+static struct twl4030_script sleep_on_script __initdata = {
+   .script = sleep_on_seq,
+   .size   = ARRAY_SIZE(sleep_on_seq),
+   .flags  = TWL4030_SLEEP_SCRIPT,
+};
+
+/*
+ * Sequence to control the TRITON Power resources,
+ * when the system wakeup from sleep.
+ * Executed upon P1_P2 transition for wakeup.
+ */
+static struct twl4030_ins wakeup_p12_seq[] __initdata = {
+   /* Broadcast message to put res to active */
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
+   RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wakeup_p12_script __initdata = {
+   .script = wakeup_p12_seq,
+   .size   = ARRAY_SIZE(wakeup_p12_seq),
+   .flags  = TWL4030_WAKEUP12_SCRIPT,
+};
+
+/*
+ * Sequence to control the TRITON Power resources,
+ * when the system wakeup from sleep.
+ * Executed upon P3 transition for wakeup.
+ */
+static struct twl4030_ins wakeup_p3_seq[] __initdata = {
+   /* Broadcast message to put res to active */
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+   RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wakeup_p3_script __initdata = {
+   .script = wakeup_p3_seq,
+   .size   = ARRAY_SIZE(wakeup_p3_seq),
+   .flags  = TWL4030_WAKEUP3_SCRIPT,
+};
+
+/*
+ * Sequence to reset the TRITON Power resources,
+ * when the system gets warm reset.
+ * Executed upon warm reset signal.
+ */
+static struct twl4030_ins wrst_seq[] __initdata = {
+/*
+ * Reset twl4030.
+ * Reset Main_Ref.
+ * Reset All type2_group2.
+ * Reset VUSB_3v1.
+ * Reset All type2_group1.
+ * Reset RC.
+ * Reenable twl4030.
+ */
+   {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_OFF), 2},
+   {MSG_SINGULAR(DEV_GRP_NULL, RES_Main_Ref, RES_STATE_WRST), 2},
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+   RES_STATE_WRST), 2},
+   {MSG_SINGULAR(DEV_GRP_NULL, RES_VUSB_3V1, RES_STATE_WRST), 2},
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
+   RES_STATE_WRST), 2},
+   {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0,
+   RES_STATE_WRST), 2},
+   {MSG_SINGULAR(DEV_GRP_NULL, RES_RESET, RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wrst_script __initdata = {
+   .script = wrst_seq,
+   .size   = ARRAY_SIZE(wrst_seq),
+   .flags  = TWL4030_WRST_SCRIPT,
+};
+
+/* TRITON script for sleep, wakeup & warm_reset */
+static struct twl4030_script *twl4030_scripts[] __initdata = {
+   &wakeup_p12_script,
+   &wakeup_p3_script,
+   &sleep_on_script,
+   &wrst_script,
+};
+
+static struct twl4030_resconfig twl4030_rconfig[] = {
+   { .resource = RES_VPLL1, .devgroup = DEV_GRP_P1, .type = 3,
+   .type2 = 1, .remap_sleep = RES_STATE_OF