Re: [PATCH 4/7] mfd: twl4030-power: Add recommended idle configuration

2014-05-20 Thread Lee Jones
 These settings are based on the Recommended Sleep Sequences for
 the Zoom Platform pdf at:
 
 http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf
 
 These settings assume most of the regulators are under control of
 Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
 Linux cannot do it.
 
 For any board specific changes to these, let's patch them in as
 changes to the generic data in the follow-up patches. This keeps
 the board specific changes small.
 
 Note that this does not consider the twl5030 errata 27 and 28.
 That can be added later on after it has been tested. For more
 information about errata 27 and 28, please see:
 
 https://github.com/openembedded/openembedded/blob/master/recipes/linux/linux-omap-2.6.39/mfd/0012-MFD-TWL4030-workaround-changes-for-Erratum-27.patch
 
 Cc: Peter De Schrijver pdeschrij...@nvidia.com
 Cc: Samuel Ortiz sa...@linux.intel.com
 Acked-by: Lee Jones lee.jo...@linaro.org
 Signed-off-by: Tony Lindgren t...@atomide.com
 ---
  .../devicetree/bindings/mfd/twl4030-power.txt  |   4 +
  drivers/mfd/twl4030-power.c| 103 
 +
  2 files changed, 107 insertions(+)

Assuming the magic numbers are replaced by transparent #defines:

  Acked-by: Lee Jones lee.jo...@linaro.org

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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 4/7] mfd: twl4030-power: Add recommended idle configuration

2014-05-20 Thread Tony Lindgren
* Lee Jones lee.jo...@linaro.org [140520 08:15]:
 
 Assuming the magic numbers are replaced by transparent #defines:
 
   Acked-by: Lee Jones lee.jo...@linaro.org

Updated the defines to use a define for the default delay. Did
not touch the number for resource group init order but added some
comments for those. Updated patch below.

Regards,

Tony

8 --
From: Tony Lindgren t...@atomide.com
Date: Tue, 20 May 2014 11:17:54 -0700
Subject: [PATCH] mfd: twl4030-power: Add recommended idle configuration

These settings are based on the Recommended Sleep Sequences for
the Zoom Platform.

The settings assume most of the regulators are under control of
Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
Linux cannot do it.

For any board specific changes to these, let's patch them in as
changes to the generic data in the follow-up patches. This keeps
the board specific changes small.

Note that this does not consider the twl5030 errata 27 and 28.
That can be added later on after it has been tested. For more
information about errata 27 and 28.

Cc: Peter De Schrijver pdeschrij...@nvidia.com
Cc: Samuel Ortiz sa...@linux.intel.com
Acked-by: Lee Jones lee.jo...@linaro.org
Signed-off-by: Tony Lindgren t...@atomide.com

--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -8,10 +8,14 @@ Required properties:
 - compatible : must be one of the following
ti,twl4030-power
ti,twl4030-power-reset
+   ti,twl4030-power-idle
 
 The use of ti,twl4030-power-reset is recommended at least on
 3530 that needs a special configuration for warm reset to work.
 
+When using ti,twl4030-power-idle, the TI recommended configuration
+for idle modes is loaded to the tlw4030 PMIC.
+
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
   SLEEP-to-OFF transition when the system poweroffs.
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index cb5b0cb..2bfbb40 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -145,6 +145,7 @@ enum {
  * omap3 has been made DT only.
  */
 #define TWL_DFLT_DELAY 2   /* typically 2 32 KiHz cycles */
+#define TWL_DEV_GRP_P123   (DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3)
 #define TWL_RESOURCE_SET(res, state)   \
{ MSG_SINGULAR(DEV_GRP_NULL, (res), (state)), TWL_DFLT_DELAY }
 #define TWL_RESOURCE_ON(res)   TWL_RESOURCE_SET(res, RES_STATE_ACTIVE)
@@ -154,14 +155,26 @@ enum {
  * It seems that type1 and type2 is just the resource init order
  * number for the type1 and type2 group.
  */
+#define TWL_RESOURCE_SET_ACTIVE(res, state)\
+   { MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_ACTIVE), (state) }
 #define TWL_RESOURCE_GROUP_RESET(group, type1, type2)  \
{ MSG_BROADCAST(DEV_GRP_NULL, (group), (type1), (type2),\
RES_STATE_WRST), TWL_DFLT_DELAY }
+#define TWL_RESOURCE_GROUP_SLEEP(group, type, type2)   \
+   { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \
+   RES_STATE_SLEEP), TWL_DFLT_DELAY }
+#define TWL_RESOURCE_GROUP_ACTIVE(group, type, type2)  \
+   { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \
+   RES_STATE_ACTIVE), TWL_DFLT_DELAY }
 #define TWL_REMAP_SLEEP(res, devgrp, typ, typ2)
\
{ .resource = (res), .devgroup = (devgrp),  \
  .type = (typ), .type2 = (typ2),   \
  .remap_off = TWL_REMAP_OFF,   \
  .remap_sleep = TWL_REMAP_SLEEP, }
+#define TWL_REMAP_OFF(res, devgrp, typ, typ2)  \
+   { .resource = (res), .devgroup = (devgrp),  \
+ .type = (typ), .type2 = (typ2),   \
+ .remap_off = TWL_REMAP_OFF, .remap_sleep = TWL_REMAP_OFF, }
 
 static int twl4030_write_script_byte(u8 address, u8 byte)
 {
@@ -638,11 +651,104 @@ static struct twl4030_power_data omap3_reset = {
.resource_config= omap3_rconfig,
 };
 
+/* Recommended generic default idle configuration for off-idle */
+
+/* Broadcast message to put res to sleep */
+static struct twl4030_ins omap3_idle_sleep_on_seq[] = {
+   TWL_RESOURCE_GROUP_SLEEP(RES_GRP_ALL, RES_TYPE_ALL, 0),
+};
+
+static struct twl4030_script omap3_idle_sleep_on_script = {
+   .script = omap3_idle_sleep_on_seq,
+   .size   = ARRAY_SIZE(omap3_idle_sleep_on_seq),
+   .flags  = TWL4030_SLEEP_SCRIPT,
+};
+
+/* Broadcast message to put res to active */
+static struct twl4030_ins omap3_idle_wakeup_p12_seq[] = {
+   TWL_RESOURCE_GROUP_ACTIVE(RES_GRP_ALL, RES_TYPE_ALL, 0),
+};
+
+static struct twl4030_script omap3_idle_wakeup_p12_script = {
+   .script = 

[PATCH 4/7] mfd: twl4030-power: Add recommended idle configuration

2014-05-13 Thread Tony Lindgren
These settings are based on the Recommended Sleep Sequences for
the Zoom Platform pdf at:

http://omappedia.com/wiki/File:Recommended_Sleep_Sequences_Zoom.pdf

These settings assume most of the regulators are under control of
Linux, and twl4030 only cuts off VDD1 and VDD2 during off-idle as
Linux cannot do it.

For any board specific changes to these, let's patch them in as
changes to the generic data in the follow-up patches. This keeps
the board specific changes small.

Note that this does not consider the twl5030 errata 27 and 28.
That can be added later on after it has been tested. For more
information about errata 27 and 28, please see:

https://github.com/openembedded/openembedded/blob/master/recipes/linux/linux-omap-2.6.39/mfd/0012-MFD-TWL4030-workaround-changes-for-Erratum-27.patch

Cc: Peter De Schrijver pdeschrij...@nvidia.com
Cc: Samuel Ortiz sa...@linux.intel.com
Acked-by: Lee Jones lee.jo...@linaro.org
Signed-off-by: Tony Lindgren t...@atomide.com
---
 .../devicetree/bindings/mfd/twl4030-power.txt  |   4 +
 drivers/mfd/twl4030-power.c| 103 +
 2 files changed, 107 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/twl4030-power.txt 
b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
index b906116..bbd6603 100644
--- a/Documentation/devicetree/bindings/mfd/twl4030-power.txt
+++ b/Documentation/devicetree/bindings/mfd/twl4030-power.txt
@@ -8,10 +8,14 @@ Required properties:
 - compatible : must be one of the following
ti,twl4030-power
ti,twl4030-power-reset
+   ti,twl4030-power-idle
 
 The use of ti,twl4030-power-reset is recommended at least on
 3530 that needs a special configuration for warm reset to work.
 
+When using ti,twl4030-power-idle, the TI recommended configuration
+for idle modes is loaded to the tlw4030 PMIC.
+
 Optional properties:
 - ti,use_poweroff: With this flag, the chip will initiates an ACTIVE-to-OFF or
   SLEEP-to-OFF transition when the system poweroffs.
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index b61b725..392 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -139,19 +139,32 @@ enum {
TWL_REMAP_ACTIVE = 9,
 };
 
+#define TWL_DEV_GRP_P123   (DEV_GRP_P1 | DEV_GRP_P2 | DEV_GRP_P3)
 #define TWL_RESOURCE_ON(res)   \
{ MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_ACTIVE), 0x02 }
 #define TWL_RESOURCE_OFF(res)  \
{ MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_OFF), 0x02 }
 #define TWL_RESOURCE_RESET(res)
\
{ MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_WRST), 0x02 }
+#define TWL_RESOURCE_SET_ACTIVE(res, state)\
+   { MSG_SINGULAR(DEV_GRP_NULL, (res), RES_STATE_ACTIVE), (state) }
 #define TWL_RESOURCE_GROUP_RESET(group, type1, type2)  \
{ MSG_BROADCAST(DEV_GRP_NULL, (group), (type1), (type2),\
RES_STATE_WRST), 0x02 }
+#define TWL_RESOURCE_GROUP_SLEEP(group, type, type2)   \
+   { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \
+   RES_STATE_SLEEP), 0x02 }
+#define TWL_RESOURCE_GROUP_ACTIVE(group, type, type2)  \
+   { MSG_BROADCAST(DEV_GRP_NULL, (group), (type), (type2), \
+   RES_STATE_ACTIVE), 0x02 }
 #define TWL_REMAP_SLEEP(res, devgrp, typ, typ2)
\
{ .resource = (res), .devgroup = (devgrp),  \
  .type = (typ), .type2 = (typ2),   \
  .remap_off = TWL_REMAP_OFF, .remap_sleep = TWL_REMAP_SLEEP, }
+#define TWL_REMAP_OFF(res, devgrp, typ, typ2)  \
+   { .resource = (res), .devgroup = (devgrp),  \
+ .type = (typ), .type2 = (typ2),   \
+ .remap_off = TWL_REMAP_OFF, .remap_sleep = TWL_REMAP_OFF, }
 
 static int twl4030_write_script_byte(u8 address, u8 byte)
 {
@@ -628,11 +641,101 @@ static struct twl4030_power_data omap3_reset = {
.resource_config= omap3_rconfig,
 };
 
+/* Recommended generic default idle configuration for off-idle */
+
+/* Broadcast message to put res to sleep */
+static struct twl4030_ins omap3_idle_sleep_on_seq[] = {
+   TWL_RESOURCE_GROUP_SLEEP(RES_GRP_ALL, RES_TYPE_ALL, 0),
+};
+
+static struct twl4030_script omap3_idle_sleep_on_script = {
+   .script = omap3_idle_sleep_on_seq,
+   .size   = ARRAY_SIZE(omap3_idle_sleep_on_seq),
+   .flags  = TWL4030_SLEEP_SCRIPT,
+};
+
+/* Broadcast message to put res to active */
+static struct twl4030_ins omap3_idle_wakeup_p12_seq[] = {
+   TWL_RESOURCE_GROUP_ACTIVE(RES_GRP_ALL, RES_TYPE_ALL, 0),
+};
+
+static struct twl4030_script omap3_idle_wakeup_p12_script = {
+   .script = omap3_idle_wakeup_p12_seq,