linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27
@ 2011-03-02 13:30 Lesly A M
  2011-03-02 13:30 ` [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence Lesly A M
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Patch series for TWL4030 power scripts and workaround for TWL errata 27.

Changes for implementing TWL4030 power scripts recommended by hardware team.
Introduced a new TWL4030 power script file, which can be used by different
OMAP3 board with the power companion chip TWL4030.

Updated the changes for TWL4030 errata 27 & 28, and modified the
TWL4030 power script.
Workaround for TWL4030 errata 27 & 28 is required for
Si version less than or equal to TWL5030 ES1.1.

TWL4030 script changes rebased on Kevin's PM tree in pm branch.

Changes in v7:
	changes to fix Nishanth Menon's comments
		i) Added the TWL4030 Errata 27 fix
  
	split the first patch in v6
		i)  fix for twl4030 script load
		ii) correct the warning print during script loading

	Added new patch files
		i) changing sys_off signal polarity

Changes in v8:
	updated the change logs
	moving the TWL IDCODE checking to twl-core.c

Since the voltage layer is evolving to a new design, the voltage dependant
changes required for the TRITON script are not incorporated in the patch series.
So this TRITON script patch series can be tested with a separate patch for
voltage layer changes.

	lnk: http://pastebin.mozilla.org/1118306

This changes are tested on OMAP3430 & OMAP3630 SDP with off mode enabled in suspend path.
	Tested with suspend/resume script, which will test system suspend in a loop.
	Tested for more than 1000 iterations.

Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
Lesly A M (7):
  omap3: pm: Fix for the TRITON sleep/wakeup sequence
  omap3: pm: Correct the warning print during script loading
  omap3: pm: TWL4030 power scripts for OMAP3 boards
  omap3: pm: TWL5030 version checking
  mfd: TWL4030: changes for TRITON Errata 27 workaround
  omap3430: Updating the board file to use TWL4030 scripts
  omap3630: Updating the board file to use TWL4030 scripts

 arch/arm/mach-omap2/Makefile                 |   12 +-
 arch/arm/mach-omap2/board-3430sdp.c          |   93 +---------
 arch/arm/mach-omap2/board-zoom-peripherals.c |    2 +
 arch/arm/mach-omap2/twl4030.c                |  259 ++++++++++++++++++++++++++
 arch/arm/mach-omap2/twl4030.h                |   20 ++
 drivers/mfd/twl-core.c                       |   61 ++++++
 drivers/mfd/twl4030-power.c                  |   69 +++++++-
 include/linux/i2c/twl.h                      |   51 +++++-
 8 files changed, 466 insertions(+), 101 deletions(-)
 create mode 100644 arch/arm/mach-omap2/twl4030.c
 create mode 100644 arch/arm/mach-omap2/twl4030.h


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-08 13:14   ` Menon, Nishanth
  2011-03-02 13:30 ` [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading Lesly A M
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Only configure sleep script when the flag is TWL4030_SLEEP_SCRIPT.

Adding the missing brackets for fixing the issue.

Signed-off-by: Lesly A M <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/mfd/twl4030-power.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 16422de..2c0d4d1 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -447,12 +447,13 @@ static int __init load_twl4030_script(struct twl4030_script *tscript,
 		if (err)
 			goto out;
 	}
-	if (tscript->flags & TWL4030_SLEEP_SCRIPT)
+	if (tscript->flags & TWL4030_SLEEP_SCRIPT) {
 		if (order)
 			pr_warning("TWL4030: Bad order of scripts (sleep "\
 					"script before wakeup) Leads to boot"\
 					"failure on some boards\n");
 		err = twl4030_config_sleep_sequence(address);
+	}
 out:
 	return err;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
  2011-03-02 13:30 ` [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-08 13:18   ` Menon, Nishanth
  2011-03-02 13:30 ` [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards Lesly A M
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Correcting the if condition check for printing the warning,
if wakeup script is not updated before updating the sleep script.

Since the flag 'order' is set to '1' while updating the wakeup script for P1P2,
the condition checking for printing the warning should be if(!order)
(ie: print the warning if wakeup script is not updated before updating the sleep script)

Signed-off-by: Lesly A M <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/mfd/twl4030-power.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 2c0d4d1..8373d79 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -448,7 +448,7 @@ static int __init load_twl4030_script(struct twl4030_script *tscript,
 			goto out;
 	}
 	if (tscript->flags & TWL4030_SLEEP_SCRIPT) {
-		if (order)
+		if (!order)
 			pr_warning("TWL4030: Bad order of scripts (sleep "\
 					"script before wakeup) Leads to boot"\
 					"failure on some boards\n");
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
  2011-03-02 13:30 ` [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence Lesly A M
  2011-03-02 13:30 ` [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-07 21:02   ` Kevin Hilman
  2011-03-08 16:03   ` Menon, Nishanth
  2011-03-02 13:30 ` [PATCH v8 4/7] omap3: pm: TWL5030 version checking Lesly A M
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

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 <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 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 0000000..ff344b3
--- /dev/null
+++ b/arch/arm/mach-omap2/twl4030.c
@@ -0,0 +1,145 @@
+/*
+ * OMAP power script for PMIC TWL4030
+ *
+ * Author: Lesly A M <leslyam@ti.com>
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Lesly A M <leslyam@ti.com>
+ *
+ * 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_OFF },
+	{ .resource = RES_VINTANA1, .devgroup = DEV_GRP_ALL, .type = 1,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VINTANA2, .devgroup = DEV_GRP_ALL, .type = 0,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VINTDIG, .devgroup = DEV_GRP_ALL, .type = 1,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VIO, .devgroup = DEV_GRP_ALL, .type = 2,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1,
+		.type = 4, .type2 = 1, .remap_sleep = RES_STATE_OFF },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1,
+		.type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
+	{ .resource = RES_REGEN, .devgroup = DEV_GRP_ALL, .type = 2,
+		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_ALL, .type = 0,
+		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_CLKEN, .devgroup = DEV_GRP_ALL, .type = 3,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_SYSEN, .devgroup = DEV_GRP_ALL, .type = 6,
+		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
+		.type = 0, .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ 0, 0},
+};
+
+struct twl4030_power_data __initdata twl4030_generic_script = {
+	.scripts	= twl4030_scripts,
+	.num		= ARRAY_SIZE(twl4030_scripts),
+	.resource_config = twl4030_rconfig,
+};
+#endif
diff --git a/arch/arm/mach-omap2/twl4030.h b/arch/arm/mach-omap2/twl4030.h
new file mode 100644
index 0000000..ee66e7d
--- /dev/null
+++ b/arch/arm/mach-omap2/twl4030.h
@@ -0,0 +1,20 @@
+/*
+ * OMAP TWL4030 power scripts header file
+ *
+ * Author: Lesly A M <x0080970@ti.com>
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Lesly A M <x0080970@ti.com>
+ *
+ * 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.
+ */
+
+#ifndef __ARCH_ARM_MACH_OMAP3_TWL4030_SCRIPT_H
+#define __ARCH_ARM_MACH_OMAP3_TWL4030_SCRIPT_H
+
+#include <linux/i2c/twl.h>
+
+extern struct twl4030_power_data twl4030_generic_script;
+#endif
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index 61b9609..f4bd475 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -436,9 +436,23 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
 
 /* Power bus message definitions */
 
-/* The TWL4030/5030 splits its power-management resources (the various
- * regulators, clock and reset lines) into 3 processor groups - P1, P2 and
- * P3. These groups can then be configured to transition between sleep, wait-on
+/*
+ * The TWL4030/5030 splits its power-management resources (the various
+ * regulators, clock and reset lines) into 3 processor groups - P1, P2 and P3.
+ *
+ * Resources attached to device group P1 is managed depending on the state of
+ * NSLEEP1 pin of TRITON, which is connected to sys_off signal from OMAP
+ *
+ * Resources attached to device group P2 is managed depending on the state of
+ * NSLEEP2 pin of TRITON, which is can be connected to a modem or
+ * some other processor
+ *
+ * Resources attached to device group P3 is managed depending on the state of
+ * CLKREQ pin of TRITON, which is connected to clk request signal from OMAP
+ *
+ * If required these resources can be attached to combination of P1/P2/P3.
+ *
+ * These groups can then be configured to transition between sleep, wait-on
  * and active states by sending messages to the power bus.  See Section 5.4.2
  * Power Resources of TWL4030 TRM
  */
@@ -448,7 +462,17 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
 #define DEV_GRP_P1		0x1	/* P1: all OMAP devices */
 #define DEV_GRP_P2		0x2	/* P2: all Modem devices */
 #define DEV_GRP_P3		0x4	/* P3: all peripheral devices */
+#define DEV_GRP_ALL		0x7	/* P1/P2/P3: all devices */
 
+/*
+ * The 27 power resources in TRITON is again divided into
+ * analog resources:
+ *	Power Providers - LDO regulators, dc-to-dc regulators
+ *	Power Reference - analog reference
+ *
+ * and digital resources:
+ *	Reset & Clock - reset and clock signals.
+ */
 /* Resource groups */
 #define RES_GRP_RES		0x0	/* Reserved */
 #define RES_GRP_PP		0x1	/* Power providers */
@@ -460,7 +484,10 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
 #define RES_GRP_ALL		0x7	/* All resource groups */
 
 #define RES_TYPE2_R0		0x0
+#define RES_TYPE2_R1		0x1
+#define RES_TYPE2_R2		0x2
 
+#define RES_TYPE_R0		0x0
 #define RES_TYPE_ALL		0x7
 
 /* Resource states */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 4/7] omap3: pm: TWL5030 version checking
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
                   ` (2 preceding siblings ...)
  2011-03-02 13:30 ` [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-03 12:00   ` Krishnamoorthy, Balaji T
  2011-03-10  4:15   ` Menon, Nishanth
  2011-03-02 13:30 ` [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround Lesly A M
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Added api to get the TWL5030 Si version from the IDCODE register.
It is used for enabling the workaround for TWL errata 27.

Signed-off-by: Lesly A M <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/mfd/twl-core.c  |   61 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/i2c/twl.h |   17 ++++++++++++-
 2 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index a35fa7d..5e706d7 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -229,6 +229,9 @@
 /* is driver active, bound to a chip? */
 static bool inuse;
 
+/* TWL IDCODE Register value */
+static u32 twl_idcode;
+
 static unsigned int twl_id;
 unsigned int twl_rev(void)
 {
@@ -487,6 +490,61 @@ EXPORT_SYMBOL(twl_i2c_read_u8);
 
 /*----------------------------------------------------------------------*/
 
+/**
+ * twl_read_idcode_register - api to read the IDCODE register.
+ * @value: returns 32 bit IDCODE register value.
+ *
+ * Unlocks the IDCODE register and read the 32 bit value.
+ */
+int twl_read_idcode_register(void)
+{
+	int err;
+
+	err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, TWL_EEPROM_R_UNLOCK,
+						REG_UNLOCK_TEST_REG);
+	if (err) {
+		pr_err("TWL4030 Unable to unlock IDCODE registers\n");
+		goto fail;
+	}
+
+	err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_idcode),
+						REG_IDCODE_7_0, 4);
+	if (err) {
+		pr_err("TWL4030: unable to read IDCODE -%d\n", err);
+		goto fail;
+	}
+
+	err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, 0x0, REG_UNLOCK_TEST_REG);
+	if (err) {
+		pr_err("TWL4030 Unable to relock IDCODE registers\n");
+		goto fail;
+	}
+fail:
+	return err;
+}
+
+/**
+ * twl_get_si_type - api to get TWL Si type.
+ *
+ * Api to get the TWL Si type from IDCODE value.
+ */
+int twl_get_si_type(void)
+{
+	return TWL_SIL_TYPE(twl_idcode);
+}
+EXPORT_SYMBOL(twl_get_si_type);
+
+/**
+ * twl_get_si_version - api to get TWL Si version.
+ *
+ * Api to get the TWL Si version from IDCODE value.
+ */
+int twl_get_si_version(void)
+{
+	return TWL_SIL_REV(twl_idcode);
+}
+EXPORT_SYMBOL(twl_get_si_version);
+
 static struct device *
 add_numbered_child(unsigned chip, const char *name, int num,
 		void *pdata, unsigned pdata_len,
@@ -1056,6 +1114,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	/* setup clock framework */
 	clocks_init(&client->dev, pdata->clock);
 
+	/* read TWL IDCODE Register */
+	twl_read_idcode_register();
+
 	/* load power event scripts */
 	if (twl_has_power() && pdata->power)
 		twl4030_power_init(pdata->power);
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index f4bd475..d3cc2ac 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -150,7 +150,12 @@
 #define MMC_PU				(0x1 << 3)
 #define MMC_PD				(0x1 << 2)
 
-
+#define TWL_SIL_TYPE(rev)		((rev) & 0x00FFFFFF)
+#define TWL_SIL_REV(rev)		((rev) >> 24)
+#define TWL_SIL_5030			0x09002F
+#define TWL5030_REV_1_0			0x00
+#define TWL5030_REV_1_1			0x10
+#define TWL5030_REV_1_2			0x30
 
 #define TWL4030_CLASS_ID 		0x4030
 #define TWL6030_CLASS_ID 		0x6030
@@ -180,6 +185,9 @@ int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
 int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 
+int twl_get_si_type(void);
+int twl_get_si_version(void);
+
 int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
 int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
 
@@ -279,7 +287,12 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
  *(Use TWL_4030_MODULE_INTBR)
  */
 
+#define REG_IDCODE_7_0			0x00
+#define REG_IDCODE_15_8			0x01
+#define REG_IDCODE_16_23		0x02
+#define REG_IDCODE_31_24		0x03
 #define REG_GPPUPDCTR1			0x0F
+#define REG_UNLOCK_TEST_REG		0x12
 
 /*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
 
@@ -288,6 +301,8 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
 #define SR_I2C_SCL_CTRL_PU		BIT(4)
 #define SR_I2C_SDA_CTRL_PU		BIT(6)
 
+#define TWL_EEPROM_R_UNLOCK		0x49
+
 /*----------------------------------------------------------------------*/
 
 /*
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
                   ` (3 preceding siblings ...)
  2011-03-02 13:30 ` [PATCH v8 4/7] omap3: pm: TWL5030 version checking Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-07 21:14   ` Kevin Hilman
  2011-03-02 13:30 ` [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts Lesly A M
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Workaround for TWL5030 Silicon Errata 27 & 28:
	27 - VDD1, VDD2, may have glitches when their output value is updated.
	28 - VDD1 and / or VDD2 DCDC clock may stop working when internal clock
		is switched from internal to external.

Errata 27:
	If the DCDC regulators is running on their internal oscillator,
	negative glitches may occur on VDD1, VDD2 output when voltage is changed.
	The OMAP device may reboot if the VDD1 or VDD2 go below the
	core minimum operating voltage.

	WORKAROUND
	Set up the TWL5030 DC-DC power supplies to use the HFCLKIN instead of
	the internal oscillator.

Errata 28:
	VDD1/VDD2 clock system may hang during switching the clock source from
	internal oscillator to external. VDD1/VDD2 output voltages may collapse
	if clock stops.

	WORKAROUND
	If HFCLK is disabled in OFFMODE, modify the sleep/wakeup sequence and
	setuptimes to make sure the switching will happen only when HFCLKIN is stable.
	Also use the TWL5030 watchdog to safeguard the first switching from
	internal oscillator to HFCLKIN during the TWL5030 init.

	IMPACT
	power sequence is changed.
	sleep/wakeup time values will be changed.

The workaround changes are called from twl4030_power_init(), since we have to
make some i2c_read calls to check the TRITON version & the i2c will not be
initialized in the early stage.

This workaround is required for TWL5030 Silicon version less than ES1.2
The power script & setup time changes are recommended by TI HW team.

http://omapedia.org/wiki/TWL4030_power_scripts

Changes taken from TRITON Errata27 workaround patch by Nishanth Menon.

Signed-off-by: Lesly A M <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 arch/arm/mach-omap2/twl4030.c |  114 +++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/twl4030-power.c   |   64 +++++++++++++++++++++++
 include/linux/i2c/twl.h       |    1 +
 3 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c
index ff344b3..87de049 100644
--- a/arch/arm/mach-omap2/twl4030.c
+++ b/arch/arm/mach-omap2/twl4030.c
@@ -137,9 +137,123 @@ static struct twl4030_resconfig twl4030_rconfig[] = {
 	{ 0, 0},
 };
 
+/*
+ * Active to Sleep sequence, which is executed upon P1/P2/P3
+ * transition for sleep.
+ *
+ * The sleep sequence is adjusted to do the switching of VDD1/VDD2/VIO OSC from
+ * HFCLKIN to internal oscillator when the HFCLKIN is stable.
+ */
+static struct twl4030_ins __initdata sleep_on_seq_errata27[] = {
+	/*
+	 * Singular message to disable HCLKOUT.
+	 * Wait for ~488.32 uS to do the switching of VDD1/VDD2/VIO OSC from
+	 * HFCLKIN to internal oscillator before disabling HFCLKIN.
+	 */
+	{MSG_SINGULAR(DEV_GRP_NULL, RES_HFCLKOUT, RES_STATE_SLEEP), 20},
+	/* Broadcast message to put res(TYPE2 = 1) to sleep */
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
+							RES_STATE_SLEEP), 2},
+	/* Broadcast message to put res(TYPE2 = 2) to sleep, disable HFCLKIN */
+	{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_errata27 __initdata = {
+	.script	= sleep_on_seq_errata27,
+	.size	= ARRAY_SIZE(sleep_on_seq_errata27),
+	.flags	= TWL4030_SLEEP_SCRIPT,
+};
+
+/*
+ * Sleep to Active sequence, which is executed upon P1/P2/P3
+ * transition for wakeup.
+ *
+ * The wakeup sequence is adjusted to do the VDD1/VDD2 voltage rampup
+ * only after HFCLKIN is stabilized and the HFCLKOUT is enabled.
+ */
+static struct twl4030_ins wakeup_seq_errata27[] __initdata = {
+	/*
+	 * Broadcast message to put res(TYPE2 = 2) to active.
+	 * Wait for ~10 mS (rampup time for OSC on the board)
+	 * after HFCLKIN is enabled
+	 */
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+							RES_STATE_ACTIVE), 55},
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+							RES_STATE_ACTIVE), 55},
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+							RES_STATE_ACTIVE), 54},
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
+							RES_STATE_ACTIVE), 1},
+	/* Singular message to enable HCLKOUT after HFCLKIN is stabilized */
+	{MSG_SINGULAR(DEV_GRP_NULL, RES_HFCLKOUT, RES_STATE_ACTIVE), 1},
+	/*
+	 * Broadcast message to put res(TYPE2 = 1) to active.
+	 * VDD1/VDD2 rampup after HFCLKIN is stable and HFCLKOUT is enabled.
+	 */
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
+							RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wakeup_script_errata27 __initdata = {
+	.script	= wakeup_seq_errata27,
+	.size	= ARRAY_SIZE(wakeup_seq_errata27),
+	.flags	= TWL4030_WAKEUP12_SCRIPT | TWL4030_WAKEUP3_SCRIPT,
+};
+
+/* TRITON script for sleep, wakeup & warm_reset */
+static struct twl4030_script *twl4030_scripts_errata27[] __initdata = {
+	&sleep_on_script_errata27,
+	&wakeup_script_errata27,
+	&wrst_script,
+};
+
+/*
+ * VDD1/VDD2/VPLL are assigned to P1 and P3, to have better control
+ * during OFFMODE. HFCLKOUT is assigned to P1 and P3 (*p2) to turn off
+ * only during OFFMODE.
+ * (*P2 is included if the platform uses it for modem/some other processor)
+ */
+static struct twl4030_resconfig twl4030_rconfig_errata27[] = {
+	{ .resource = RES_VPLL1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
+		.type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
+	{ .resource = RES_VINTANA1, .devgroup = DEV_GRP_ALL, .type = 1,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VINTANA2, .devgroup = DEV_GRP_ALL, .type = 0,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VINTDIG, .devgroup = DEV_GRP_ALL, .type = 1,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VIO, .devgroup = DEV_GRP_ALL, .type = 2,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
+		.type = 4, .type2 = 1, .remap_sleep = RES_STATE_OFF },
+	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
+		.type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
+	{ .resource = RES_REGEN, .devgroup = DEV_GRP_ALL, .type = 2,
+		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_ALL, .type = 0,
+		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_CLKEN, .devgroup = DEV_GRP_ALL, .type = 3,
+		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_SYSEN, .devgroup = DEV_GRP_ALL, .type = 6,
+		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
+		.type = 0, .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
+	{ 0, 0},
+};
+
+void twl5030_script_errata27(void)
+{
+	twl4030_generic_script.scripts = twl4030_scripts_errata27;
+	twl4030_generic_script.num = ARRAY_SIZE(twl4030_scripts_errata27);
+	twl4030_generic_script.resource_config = twl4030_rconfig_errata27;
+}
+
 struct twl4030_power_data __initdata twl4030_generic_script = {
 	.scripts	= twl4030_scripts,
 	.num		= ARRAY_SIZE(twl4030_scripts),
 	.resource_config = twl4030_rconfig,
+	.twl5030_errata27wa_script = twl5030_script_errata27,
 };
 #endif
diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
index 8373d79..db24d09 100644
--- a/drivers/mfd/twl4030-power.c
+++ b/drivers/mfd/twl4030-power.c
@@ -63,6 +63,14 @@ static u8 twl4030_start_script_address = 0x2b;
 #define R_MEMORY_ADDRESS	PHY_TO_OFF_PM_MASTER(0x59)
 #define R_MEMORY_DATA		PHY_TO_OFF_PM_MASTER(0x5a)
 
+#define R_VDD1_OSC		0x5C
+#define R_VDD2_OSC		0x6A
+#define R_VIO_OSC		0x52
+#define EXT_FS_CLK_EN		(0x1 << 6)
+
+#define R_WDT_CFG		0x03
+#define WDT_WRK_TIMEOUT		0x03
+
 /* resource configuration registers
    <RESOURCE>_DEV_GRP   at address 'n+0'
    <RESOURCE>_TYPE      at address 'n+1'
@@ -511,6 +519,53 @@ int twl4030_remove_script(u8 flags)
 	return err;
 }
 
+/**
+ * twl_errata27_workaround() - Workaround for TWL5030 Silicon Errata 27 & 28:
+ * 27 - VDD1, VDD2, may have glitches when their output value is updated.
+ * 28 - VDD1 and / or VDD2 DCDC clock may stop working when internal clock is
+ * switched from internal to external.
+ *
+ * Workaround requires the TWL DCDCs to use HFCLK instead of
+ * internal oscillator. Also enable TWL watchdog before switching the osc
+ * to recover if the VDD1/VDD2 stop working.
+ */
+static void __init twl_errata27_workaround(void)
+{
+	u8 val;
+	u8 smps_osc_reg[] = {R_VDD1_OSC, R_VDD2_OSC, R_VIO_OSC};
+	u8 wdt_counter_val = 0;
+	int i;
+	int err;
+
+	/* Setup the twl wdt to take care of borderline failure case */
+	err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &wdt_counter_val,
+			R_WDT_CFG);
+	err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, WDT_WRK_TIMEOUT,
+			R_WDT_CFG);
+
+	for (i = 0; i < sizeof(smps_osc_reg); i++) {
+		err |= twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &val,
+							smps_osc_reg[i]);
+		val |= EXT_FS_CLK_EN;
+		err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val,
+							smps_osc_reg[i]);
+	}
+
+	/* restore the original value */
+	err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, wdt_counter_val,
+			R_WDT_CFG);
+	if (err)
+		pr_warning("TWL4030: workaround setup failed!\n");
+}
+
+bool is_twl5030_errata27wa_required(void)
+{
+	if (twl_get_si_type() == TWL_SIL_5030)
+		return (twl_get_si_version() < TWL5030_REV_1_2);
+
+	return 0;
+}
+
 void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
 {
 	int err = 0;
@@ -530,6 +585,15 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
 	if (err)
 		goto unlock;
 
+	/* Applying TWL5030 Errata 27 WA based on Si revision &
+	 * flag updated from board file*/
+	if (is_twl5030_errata27wa_required()) {
+		pr_info("TWL5030: Enabling workaround for Si Errata 27\n");
+		twl_errata27_workaround();
+		if (twl4030_scripts->twl5030_errata27wa_script)
+			twl4030_scripts->twl5030_errata27wa_script();
+	}
+
 	for (i = 0; i < twl4030_scripts->num; i++) {
 		err = load_twl4030_script(twl4030_scripts->scripts[i], address);
 		if (err)
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
index d3cc2ac..d114229 100644
--- a/include/linux/i2c/twl.h
+++ b/include/linux/i2c/twl.h
@@ -672,6 +672,7 @@ struct twl4030_power_data {
 	struct twl4030_script **scripts;
 	unsigned num;
 	struct twl4030_resconfig *resource_config;
+	void (*twl5030_errata27wa_script)(void);
 #define TWL4030_RESCONFIG_UNDEF	((u8)-1)
 };
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
                   ` (4 preceding siblings ...)
  2011-03-02 13:30 ` [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-07 19:42   ` Kevin Hilman
  2011-03-02 13:30 ` [PATCH v8 7/7] omap3630: " Lesly A M
  2011-03-07 21:25 ` [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Kevin Hilman
  7 siblings, 1 reply; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Using TWL4030 power scripts to control the LDOs and DCDC regulators
while going to low power mode.

Signed-off-by: Lesly A M <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 arch/arm/mach-omap2/Makefile        |    3 +-
 arch/arm/mach-omap2/board-3430sdp.c |   93 +----------------------------------
 2 files changed, 4 insertions(+), 92 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 742ca67..bb11329 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -175,7 +175,8 @@ obj-$(CONFIG_MACH_OMAP3_PANDORA)	+= board-omap3pandora.o \
 					   hsmmc.o
 obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o \
 					   hsmmc.o \
-					   board-flash.o
+					   board-flash.o \
+					   twl4030.o
 obj-$(CONFIG_MACH_NOKIA_N8X0)		+= board-n8x0.o
 obj-$(CONFIG_MACH_NOKIA_RM680)		+= board-rm680.o \
 					   sdram-nokia.o \
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 813893b..a0bb530 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -46,6 +46,7 @@
 #include "mux.h"
 #include "sdram-qimonda-hyb18m512160af-6.h"
 #include "hsmmc.h"
+#include "twl4030.h"
 #include "pm.h"
 #include "control.h"
 
@@ -425,96 +426,6 @@ static struct twl4030_madc_platform_data sdp3430_madc_data = {
 	.irq_line	= 1,
 };
 
-
-static struct twl4030_ins __initdata sleep_on_seq[] = {
-	/* Turn off HFCLKOUT */
-	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 2},
-	/* Turn OFF VDD1 */
-	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 2},
-	/* Turn OFF VDD2 */
-	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
-	/* Turn OFF VPLL1 */
-	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 2},
-};
-
-static struct twl4030_script sleep_on_script __initdata = {
-	.script	= sleep_on_seq,
-	.size	= ARRAY_SIZE(sleep_on_seq),
-	.flags	= TWL4030_SLEEP_SCRIPT,
-};
-
-static struct twl4030_ins wakeup_p12_seq[] __initdata = {
-	/* Turn on HFCLKOUT */
-	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
-	/* Turn ON VDD1 */
-	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 2},
-	/* Turn ON VDD2 */
-	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
-	/* Turn ON VPLL1 */
-	{MSG_SINGULAR(DEV_GRP_P1, 0x7, 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,
-};
-
-static struct twl4030_ins wakeup_p3_seq[] __initdata = {
-	{MSG_SINGULAR(DEV_GRP_P1, 0x19, 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,
-};
-
-static struct twl4030_ins wrst_seq[] __initdata = {
-/*
- * Reset twl4030.
- * Reset VDD1 regulator.
- * Reset VDD2 regulator.
- * Reset VPLL1 regulator.
- * Enable sysclk output.
- * Reenable twl4030.
- */
-	{MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2},
-	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
-	{MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2},
-};
-static struct twl4030_script wrst_script __initdata = {
-	.script = wrst_seq,
-	.size   = ARRAY_SIZE(wrst_seq),
-	.flags  = TWL4030_WRST_SCRIPT,
-};
-
-static struct twl4030_script *twl4030_scripts[] __initdata = {
-	&sleep_on_script,
-	&wakeup_p12_script,
-	&wakeup_p3_script,
-	&wrst_script,
-};
-
-static struct twl4030_resconfig twl4030_rconfig[] = {
-	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3, .type = -1,
-		.type2 = -1 },
-	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1, .type = -1,
-		.type2 = -1 },
-	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1, .type = -1,
-		.type2 = -1 },
-	{ 0, 0},
-};
-
-static struct twl4030_power_data sdp3430_t2scripts_data __initdata = {
-	.scripts	= twl4030_scripts,
-	.num		= ARRAY_SIZE(twl4030_scripts),
-	.resource_config = twl4030_rconfig,
-};
-
 /*
  * Apply all the fixed voltages since most versions of U-Boot
  * don't bother with that initialization.
@@ -673,8 +584,8 @@ static struct twl4030_platform_data sdp3430_twldata = {
 	.gpio		= &sdp3430_gpio_data,
 	.madc		= &sdp3430_madc_data,
 	.keypad		= &sdp3430_kp_data,
-	.power		= &sdp3430_t2scripts_data,
 	.usb		= &sdp3430_usb_data,
+	.power		= &twl4030_generic_script,
 	.codec		= &sdp3430_codec,
 
 	.vaux1		= &sdp3430_vaux1,
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH v8 7/7] omap3630: Updating the board file to use TWL4030 scripts
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
                   ` (5 preceding siblings ...)
  2011-03-02 13:30 ` [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts Lesly A M
@ 2011-03-02 13:30 ` Lesly A M
  2011-03-07 21:25 ` [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Kevin Hilman
  7 siblings, 0 replies; 24+ messages in thread
From: Lesly A M @ 2011-03-02 13:30 UTC (permalink / raw)
  To: linux-omap; +Cc: Lesly A M, Nishanth Menon, David Derrick, Samuel Ortiz

Using TWL4030 power scripts to control the LDOs and DCDC regulators
while going to low power mode.

Signed-off-by: Lesly A M <leslyam@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: David Derrick <dderrick@ti.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>
---
 arch/arm/mach-omap2/Makefile                 |    9 ++++++---
 arch/arm/mach-omap2/board-zoom-peripherals.c |    2 ++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index bb11329..e6d5d27 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -191,18 +191,21 @@ obj-$(CONFIG_MACH_OMAP_ZOOM2)		+= board-zoom.o \
 					   board-zoom-display.o \
 					   board-flash.o \
 					   hsmmc.o \
-					   board-zoom-debugboard.o
+					   board-zoom-debugboard.o \
+					   twl4030.o
 obj-$(CONFIG_MACH_OMAP_ZOOM3)		+= board-zoom.o \
 					   board-zoom-peripherals.o \
 					   board-zoom-display.o \
 					   board-flash.o \
 					   hsmmc.o \
-					   board-zoom-debugboard.o
+					   board-zoom-debugboard.o \
+					   twl4030.o
 obj-$(CONFIG_MACH_OMAP_3630SDP)		+= board-3630sdp.o \
 					   board-zoom-peripherals.o \
 					   board-zoom-display.o \
 					   board-flash.o \
-					   hsmmc.o
+					   hsmmc.o \
+					   twl4030.o
 obj-$(CONFIG_MACH_CM_T35)		+= board-cm-t35.o \
 					   hsmmc.o
 obj-$(CONFIG_MACH_CM_T3517)		+= board-cm-t3517.o
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index e0e040f..f978f73 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -31,6 +31,7 @@
 
 #include "mux.h"
 #include "hsmmc.h"
+#include "twl4030.h"
 
 #define OMAP_ZOOM_WLAN_PMENA_GPIO	(101)
 #define OMAP_ZOOM_WLAN_IRQ_GPIO		(162)
@@ -341,6 +342,7 @@ static struct twl4030_platform_data zoom_twldata = {
 	.usb		= &zoom_usb_data,
 	.gpio		= &zoom_gpio_data,
 	.keypad		= &zoom_kp_twl4030_data,
+	.power		= &twl4030_generic_script,
 	.codec		= &zoom_codec_data,
 	.vmmc1          = &zoom_vmmc1,
 	.vmmc2          = &zoom_vmmc2,
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 4/7] omap3: pm: TWL5030 version checking
  2011-03-02 13:30 ` [PATCH v8 4/7] omap3: pm: TWL5030 version checking Lesly A M
@ 2011-03-03 12:00   ` Krishnamoorthy, Balaji T
  2011-03-10  4:15   ` Menon, Nishanth
  1 sibling, 0 replies; 24+ messages in thread
From: Krishnamoorthy, Balaji T @ 2011-03-03 12:00 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

On Wed, Mar 2, 2011 at 7:00 PM, Lesly A M <leslyam@ti.com> wrote:
<snip>

>  static struct device *
>  add_numbered_child(unsigned chip, const char *name, int num,
>                void *pdata, unsigned pdata_len,
> @@ -1056,6 +1114,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
>        /* setup clock framework */
>        clocks_init(&client->dev, pdata->clock);
>
> +       /* read TWL IDCODE Register */
> +       twl_read_idcode_register();
> +

you missed check for TRITON again
BTW can you make twl_read_idcode_register static
if you are not exporting ?

@@ -1109,14 +1109,12 @@
 	} else {
 		twl_id = TWL4030_CLASS_ID;
 		twl_map = &twl4030_map[0];
+		twl_read_idcode_register();
 	}

 	/* setup clock framework */
 	clocks_init(&client->dev, pdata->clock);

-	/* read TWL IDCODE Register */
-	twl_read_idcode_register();
-
 	/* load power event scripts */
 	if (twl_has_power() && pdata->power)
 		twl4030_power_init(pdata->power);

>        /* load power event scripts */
>        if (twl_has_power() && pdata->power)
>                twl4030_power_init(pdata->power);
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index f4bd475..d3cc2ac 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -150,7 +150,12 @@
>  #define MMC_PU                         (0x1 << 3)
>  #define MMC_PD                         (0x1 << 2)
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts
  2011-03-02 13:30 ` [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts Lesly A M
@ 2011-03-07 19:42   ` Kevin Hilman
  2011-03-07 21:10     ` Kevin Hilman
  2011-03-08  7:01     ` Manuel, Lesly Arackal
  0 siblings, 2 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-03-07 19:42 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Lesly A M <leslyam@ti.com> writes:

> Using TWL4030 power scripts to control the LDOs and DCDC regulators
> while going to low power mode.
>
> Signed-off-by: Lesly A M <leslyam@ti.com>

Minor: Re: Subject: OMAP is an acronym, please capitalize.

> Cc: Nishanth Menon <nm@ti.com>
> Cc: David Derrick <dderrick@ti.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> ---
>  arch/arm/mach-omap2/Makefile        |    3 +-
>  arch/arm/mach-omap2/board-3430sdp.c |   93 +----------------------------------
>  2 files changed, 4 insertions(+), 92 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 742ca67..bb11329 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -175,7 +175,8 @@ obj-$(CONFIG_MACH_OMAP3_PANDORA)	+= board-omap3pandora.o \
>  					   hsmmc.o
>  obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o \
>  					   hsmmc.o \
> -					   board-flash.o
> +					   board-flash.o \
> +					   twl4030.o

This should not be board-specific in the Makefile, otherwise it will
have to be added for every single board that uses it.

Rather, it should probably be built as long as CONFIG_TWL4030_POWER=y.
Also, please be sure to build test when that option is disabled as well.

Kevin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards
  2011-03-02 13:30 ` [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards Lesly A M
@ 2011-03-07 21:02   ` Kevin Hilman
  2011-03-08  6:50     ` Manuel, Lesly Arackal
  2011-03-08 16:29     ` Nishanth Menon
  2011-03-08 16:03   ` Menon, Nishanth
  1 sibling, 2 replies; 24+ messages in thread
From: Kevin Hilman @ 2011-03-07 21:02 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Lesly A M <leslyam@ti.com> 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 <wiki page>.

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


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts
  2011-03-07 19:42   ` Kevin Hilman
@ 2011-03-07 21:10     ` Kevin Hilman
  2011-03-08  7:06       ` Manuel, Lesly Arackal
  2011-03-08  7:01     ` Manuel, Lesly Arackal
  1 sibling, 1 reply; 24+ messages in thread
From: Kevin Hilman @ 2011-03-07 21:10 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Kevin Hilman <khilman@ti.com> writes:

> Lesly A M <leslyam@ti.com> writes:
>
>> Using TWL4030 power scripts to control the LDOs and DCDC regulators
>> while going to low power mode.
>>
>> Signed-off-by: Lesly A M <leslyam@ti.com>
>
> Minor: Re: Subject: OMAP is an acronym, please capitalize.
>
>> Cc: Nishanth Menon <nm@ti.com>
>> Cc: David Derrick <dderrick@ti.com>
>> Cc: Samuel Ortiz <sameo@linux.intel.com>
>> ---
>>  arch/arm/mach-omap2/Makefile        |    3 +-
>>  arch/arm/mach-omap2/board-3430sdp.c |   93 +----------------------------------
>>  2 files changed, 4 insertions(+), 92 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
>> index 742ca67..bb11329 100644
>> --- a/arch/arm/mach-omap2/Makefile
>> +++ b/arch/arm/mach-omap2/Makefile
>> @@ -175,7 +175,8 @@ obj-$(CONFIG_MACH_OMAP3_PANDORA)	+= board-omap3pandora.o \
>>  					   hsmmc.o
>>  obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o \
>>  					   hsmmc.o \
>> -					   board-flash.o
>> +					   board-flash.o \
>> +					   twl4030.o
>
> This should not be board-specific in the Makefile, otherwise it will
> have to be added for every single board that uses it.
>
> Rather, it should probably be built as long as CONFIG_TWL4030_POWER=y.
> Also, please be sure to build test when that option is disabled as well.

Just notcied that twl4030.c is already wrapped by CONFIG_TWL4030_POWER,
so just build it for CONFIG_PM:

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 65d8701..8bdc969 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -61,7 +61,7 @@ ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)		+= pm24xx.o
 obj-$(CONFIG_ARCH_OMAP2)		+= sleep24xx.o pm_bus.o
 obj-$(CONFIG_ARCH_OMAP3)		+= pm34xx.o sleep34xx.o \
-					   cpuidle34xx.o pm_bus.o
+					   cpuidle34xx.o pm_bus.o twl4030.o
 obj-$(CONFIG_ARCH_OMAP4)		+= pm44xx.o pm_bus.o
 obj-$(CONFIG_PM_DEBUG)			+= pm-debug.o
 obj-$(CONFIG_OMAP_SMARTREFLEX)          += sr_device.o smartreflex.o


Then, you'll also have to modify twl4030.h so that
twl4030_generic_script is NULL when CONFIG_TWL_4030=n so board files
will still compile.

Kevin

^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround
  2011-03-02 13:30 ` [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround Lesly A M
@ 2011-03-07 21:14   ` Kevin Hilman
  2011-03-08  7:14     ` Manuel, Lesly Arackal
  0 siblings, 1 reply; 24+ messages in thread
From: Kevin Hilman @ 2011-03-07 21:14 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Hi Lesly,

Lesly A M <leslyam@ti.com> writes:

> Workaround for TWL5030 Silicon Errata 27 & 28:
> 	27 - VDD1, VDD2, may have glitches when their output value is updated.
> 	28 - VDD1 and / or VDD2 DCDC clock may stop working when internal clock
> 		is switched from internal to external.
>
> Errata 27:
> 	If the DCDC regulators is running on their internal oscillator,
> 	negative glitches may occur on VDD1, VDD2 output when voltage is changed.
> 	The OMAP device may reboot if the VDD1 or VDD2 go below the
> 	core minimum operating voltage.
>
> 	WORKAROUND
> 	Set up the TWL5030 DC-DC power supplies to use the HFCLKIN instead of
> 	the internal oscillator.
>
> Errata 28:
> 	VDD1/VDD2 clock system may hang during switching the clock source from
> 	internal oscillator to external. VDD1/VDD2 output voltages may collapse
> 	if clock stops.
>
> 	WORKAROUND
> 	If HFCLK is disabled in OFFMODE, modify the sleep/wakeup sequence and
> 	setuptimes to make sure the switching will happen only when HFCLKIN is stable.
> 	Also use the TWL5030 watchdog to safeguard the first switching from
> 	internal oscillator to HFCLKIN during the TWL5030 init.
>
> 	IMPACT
> 	power sequence is changed.
> 	sleep/wakeup time values will be changed.
>
> The workaround changes are called from twl4030_power_init(), since we have to
> make some i2c_read calls to check the TRITON version & the i2c will not be
> initialized in the early stage.
>
> This workaround is required for TWL5030 Silicon version less than ES1.2
> The power script & setup time changes are recommended by TI HW team.
>
> http://omapedia.org/wiki/TWL4030_power_scripts
>
> Changes taken from TRITON Errata27 workaround patch by Nishanth Menon.
>
> Signed-off-by: Lesly A M <leslyam@ti.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: David Derrick <dderrick@ti.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>

Some minor comments below,

> ---
>  arch/arm/mach-omap2/twl4030.c |  114 +++++++++++++++++++++++++++++++++++++++++
>  drivers/mfd/twl4030-power.c   |   64 +++++++++++++++++++++++
>  include/linux/i2c/twl.h       |    1 +
>  3 files changed, 179 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c
> index ff344b3..87de049 100644
> --- a/arch/arm/mach-omap2/twl4030.c
> +++ b/arch/arm/mach-omap2/twl4030.c
> @@ -137,9 +137,123 @@ static struct twl4030_resconfig twl4030_rconfig[] = {
>  	{ 0, 0},
>  };
>  
> +/*
> + * Active to Sleep sequence, which is executed upon P1/P2/P3
> + * transition for sleep.
> + *
> + * The sleep sequence is adjusted to do the switching of VDD1/VDD2/VIO OSC from
> + * HFCLKIN to internal oscillator when the HFCLKIN is stable.
> + */
> +static struct twl4030_ins __initdata sleep_on_seq_errata27[] = {
> +	/*
> +	 * Singular message to disable HCLKOUT.
> +	 * Wait for ~488.32 uS to do the switching of VDD1/VDD2/VIO OSC from
> +	 * HFCLKIN to internal oscillator before disabling HFCLKIN.
> +	 */
> +	{MSG_SINGULAR(DEV_GRP_NULL, RES_HFCLKOUT, RES_STATE_SLEEP), 20},
> +	/* Broadcast message to put res(TYPE2 = 1) to sleep */
> +	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
> +							RES_STATE_SLEEP), 2},
> +	/* Broadcast message to put res(TYPE2 = 2) to sleep, disable HFCLKIN */
> +	{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_errata27 __initdata = {
> +	.script	= sleep_on_seq_errata27,
> +	.size	= ARRAY_SIZE(sleep_on_seq_errata27),
> +	.flags	= TWL4030_SLEEP_SCRIPT,
> +};
> +
> +/*
> + * Sleep to Active sequence, which is executed upon P1/P2/P3
> + * transition for wakeup.
> + *
> + * The wakeup sequence is adjusted to do the VDD1/VDD2 voltage rampup
> + * only after HFCLKIN is stabilized and the HFCLKOUT is enabled.
> + */
> +static struct twl4030_ins wakeup_seq_errata27[] __initdata = {
> +	/*
> +	 * Broadcast message to put res(TYPE2 = 2) to active.
> +	 * Wait for ~10 mS (rampup time for OSC on the board)
> +	 * after HFCLKIN is enabled
> +	 */
> +	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +							RES_STATE_ACTIVE), 55},
> +	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +							RES_STATE_ACTIVE), 55},
> +	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +							RES_STATE_ACTIVE), 54},
> +	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
> +							RES_STATE_ACTIVE), 1},
> +	/* Singular message to enable HCLKOUT after HFCLKIN is stabilized */
> +	{MSG_SINGULAR(DEV_GRP_NULL, RES_HFCLKOUT, RES_STATE_ACTIVE), 1},
> +	/*
> +	 * Broadcast message to put res(TYPE2 = 1) to active.
> +	 * VDD1/VDD2 rampup after HFCLKIN is stable and HFCLKOUT is enabled.
> +	 */
> +	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
> +							RES_STATE_ACTIVE), 2},
> +};
> +
> +static struct twl4030_script wakeup_script_errata27 __initdata = {
> +	.script	= wakeup_seq_errata27,
> +	.size	= ARRAY_SIZE(wakeup_seq_errata27),
> +	.flags	= TWL4030_WAKEUP12_SCRIPT | TWL4030_WAKEUP3_SCRIPT,
> +};
> +
> +/* TRITON script for sleep, wakeup & warm_reset */
> +static struct twl4030_script *twl4030_scripts_errata27[] __initdata = {
> +	&sleep_on_script_errata27,
> +	&wakeup_script_errata27,
> +	&wrst_script,
> +};
> +
> +/*
> + * VDD1/VDD2/VPLL are assigned to P1 and P3, to have better control
> + * during OFFMODE. HFCLKOUT is assigned to P1 and P3 (*p2) to turn off
> + * only during OFFMODE.
> + * (*P2 is included if the platform uses it for modem/some other processor)
> + */
> +static struct twl4030_resconfig twl4030_rconfig_errata27[] = {
> +	{ .resource = RES_VPLL1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
> +		.type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
> +	{ .resource = RES_VINTANA1, .devgroup = DEV_GRP_ALL, .type = 1,
> +		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_VINTANA2, .devgroup = DEV_GRP_ALL, .type = 0,
> +		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_VINTDIG, .devgroup = DEV_GRP_ALL, .type = 1,
> +		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_VIO, .devgroup = DEV_GRP_ALL, .type = 2,
> +		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_VDD1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
> +		.type = 4, .type2 = 1, .remap_sleep = RES_STATE_OFF },
> +	{ .resource = RES_VDD2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
> +		.type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
> +	{ .resource = RES_REGEN, .devgroup = DEV_GRP_ALL, .type = 2,
> +		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_ALL, .type = 0,
> +		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_CLKEN, .devgroup = DEV_GRP_ALL, .type = 3,
> +		.type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_SYSEN, .devgroup = DEV_GRP_ALL, .type = 6,
> +		.type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +	{ .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
> +		.type = 0, .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +	{ 0, 0},
> +};
> +
> +void twl5030_script_errata27(void)

static

> +{
> +	twl4030_generic_script.scripts = twl4030_scripts_errata27;
> +	twl4030_generic_script.num = ARRAY_SIZE(twl4030_scripts_errata27);
> +	twl4030_generic_script.resource_config = twl4030_rconfig_errata27;
> +}
> +
>  struct twl4030_power_data __initdata twl4030_generic_script = {
>  	.scripts	= twl4030_scripts,
>  	.num		= ARRAY_SIZE(twl4030_scripts),
>  	.resource_config = twl4030_rconfig,
> +	.twl5030_errata27wa_script = twl5030_script_errata27,
>  };
>  #endif
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index 8373d79..db24d09 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -63,6 +63,14 @@ static u8 twl4030_start_script_address = 0x2b;
>  #define R_MEMORY_ADDRESS	PHY_TO_OFF_PM_MASTER(0x59)
>  #define R_MEMORY_DATA		PHY_TO_OFF_PM_MASTER(0x5a)
>  
> +#define R_VDD1_OSC		0x5C
> +#define R_VDD2_OSC		0x6A
> +#define R_VIO_OSC		0x52
> +#define EXT_FS_CLK_EN		(0x1 << 6)
> +

BIT(6)

> +#define R_WDT_CFG		0x03
> +#define WDT_WRK_TIMEOUT		0x03
> +
>  /* resource configuration registers
>     <RESOURCE>_DEV_GRP   at address 'n+0'
>     <RESOURCE>_TYPE      at address 'n+1'
> @@ -511,6 +519,53 @@ int twl4030_remove_script(u8 flags)
>  	return err;
>  }
>  
> +/**
> + * twl_errata27_workaround() - Workaround for TWL5030 Silicon Errata 27 & 28:
> + * 27 - VDD1, VDD2, may have glitches when their output value is updated.
> + * 28 - VDD1 and / or VDD2 DCDC clock may stop working when internal clock is
> + * switched from internal to external.
> + *
> + * Workaround requires the TWL DCDCs to use HFCLK instead of
> + * internal oscillator. Also enable TWL watchdog before switching the osc
> + * to recover if the VDD1/VDD2 stop working.
> + */
> +static void __init twl_errata27_workaround(void)
> +{
> +	u8 val;
> +	u8 smps_osc_reg[] = {R_VDD1_OSC, R_VDD2_OSC, R_VIO_OSC};
> +	u8 wdt_counter_val = 0;
> +	int i;
> +	int err;
> +
> +	/* Setup the twl wdt to take care of borderline failure case */
> +	err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &wdt_counter_val,
> +			R_WDT_CFG);
> +	err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, WDT_WRK_TIMEOUT,
> +			R_WDT_CFG);
> +
> +	for (i = 0; i < sizeof(smps_osc_reg); i++) {
> +		err |= twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &val,
> +							smps_osc_reg[i]);
> +		val |= EXT_FS_CLK_EN;
> +		err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val,
> +							smps_osc_reg[i]);
> +	}
> +
> +	/* restore the original value */
> +	err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, wdt_counter_val,
> +			R_WDT_CFG);
> +	if (err)
> +		pr_warning("TWL4030: workaround setup failed!\n");
> +}
> +
> +bool is_twl5030_errata27wa_required(void)

static

> +{
> +	if (twl_get_si_type() == TWL_SIL_5030)
> +		return (twl_get_si_version() < TWL5030_REV_1_2);
> +
> +	return 0;
> +}
> +
>  void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
>  {
>  	int err = 0;
> @@ -530,6 +585,15 @@ void __init twl4030_power_init(struct twl4030_power_data *twl4030_scripts)
>  	if (err)
>  		goto unlock;
>  
> +	/* Applying TWL5030 Errata 27 WA based on Si revision &
> +	 * flag updated from board file*/
> +	if (is_twl5030_errata27wa_required()) {
> +		pr_info("TWL5030: Enabling workaround for Si Errata 27\n");
> +		twl_errata27_workaround();
> +		if (twl4030_scripts->twl5030_errata27wa_script)
> +			twl4030_scripts->twl5030_errata27wa_script();
> +	}
> +
>  	for (i = 0; i < twl4030_scripts->num; i++) {
>  		err = load_twl4030_script(twl4030_scripts->scripts[i], address);
>  		if (err)
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index d3cc2ac..d114229 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -672,6 +672,7 @@ struct twl4030_power_data {
>  	struct twl4030_script **scripts;
>  	unsigned num;
>  	struct twl4030_resconfig *resource_config;
> +	void (*twl5030_errata27wa_script)(void);
>  #define TWL4030_RESCONFIG_UNDEF	((u8)-1)
>  };

Kevin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27
  2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
                   ` (6 preceding siblings ...)
  2011-03-02 13:30 ` [PATCH v8 7/7] omap3630: " Lesly A M
@ 2011-03-07 21:25 ` Kevin Hilman
  2011-03-08  7:30   ` Manuel, Lesly Arackal
  7 siblings, 1 reply; 24+ messages in thread
From: Kevin Hilman @ 2011-03-07 21:25 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Lesly A M <leslyam@ti.com> writes:

> Patch series for TWL4030 power scripts and workaround for TWL errata 27.
>
> Changes for implementing TWL4030 power scripts recommended by hardware team.
> Introduced a new TWL4030 power script file, which can be used by different
> OMAP3 board with the power companion chip TWL4030.
>
> Updated the changes for TWL4030 errata 27 & 28, and modified the
> TWL4030 power script.
> Workaround for TWL4030 errata 27 & 28 is required for
> Si version less than or equal to TWL5030 ES1.1.
>
> TWL4030 script changes rebased on Kevin's PM tree in pm branch.

This doesn't apply to the current PM branch.  I dropped the old scripts
from the PM branch some time back.  It should be a simple rebase, and
only affects PATCH 6/8.  After the rebase, it will only add the new
stuff to the 3430SDP board file instead of also delete the old scripts.

Also, minor nit: please consistenly capitlize acronyms: API, OMAP, etc,
and the singular for errata is erattum.  This affects subjects,
changelogs comments etc.

> Changes in v7:
> 	changes to fix Nishanth Menon's comments
> 		i) Added the TWL4030 Errata 27 fix
>   
> 	split the first patch in v6
> 		i)  fix for twl4030 script load
> 		ii) correct the warning print during script loading
>
> 	Added new patch files
> 		i) changing sys_off signal polarity
>
> Changes in v8:
> 	updated the change logs
> 	moving the TWL IDCODE checking to twl-core.c
>
> Since the voltage layer is evolving to a new design, the voltage dependant
> changes required for the TRITON script are not incorporated in the patch series.
> So this TRITON script patch series can be tested with a separate patch for
> voltage layer changes.
>
> 	lnk: http://pastebin.mozilla.org/1118306

I'm OK with leaving the voltage layer changes for a separate series, but
in order to test this should also be rebased against my current PM branch.

For future reference, my pm-core branch includes only patches/series
that are already queued for upstream, or will be queued for the next
merge window.

Kevin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards
  2011-03-07 21:02   ` Kevin Hilman
@ 2011-03-08  6:50     ` Manuel, Lesly Arackal
  2011-03-08 16:29     ` Nishanth Menon
  1 sibling, 0 replies; 24+ messages in thread
From: Manuel, Lesly Arackal @ 2011-03-08  6:50 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Hi Kevin,

On Tue, Mar 8, 2011 at 2:32 AM, Kevin Hilman <khilman@ti.com> wrote:
> Lesly A M <leslyam@ti.com> 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 <wiki page>.
>
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts
  2011-03-07 19:42   ` Kevin Hilman
  2011-03-07 21:10     ` Kevin Hilman
@ 2011-03-08  7:01     ` Manuel, Lesly Arackal
  1 sibling, 0 replies; 24+ messages in thread
From: Manuel, Lesly Arackal @ 2011-03-08  7:01 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Hi Kevin,

On Tue, Mar 8, 2011 at 1:12 AM, Kevin Hilman <khilman@ti.com> wrote:
> Lesly A M <leslyam@ti.com> writes:
>
>> Using TWL4030 power scripts to control the LDOs and DCDC regulators
>> while going to low power mode.
>>
>> Signed-off-by: Lesly A M <leslyam@ti.com>
>
> Minor: Re: Subject: OMAP is an acronym, please capitalize.
Ok

>> Cc: Nishanth Menon <nm@ti.com>
>> Cc: David Derrick <dderrick@ti.com>
>> Cc: Samuel Ortiz <sameo@linux.intel.com>
>> ---
>>  arch/arm/mach-omap2/Makefile        |    3 +-
>>  arch/arm/mach-omap2/board-3430sdp.c |   93 +----------------------------------
>>  2 files changed, 4 insertions(+), 92 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
>> index 742ca67..bb11329 100644
>> --- a/arch/arm/mach-omap2/Makefile
>> +++ b/arch/arm/mach-omap2/Makefile
>> @@ -175,7 +175,8 @@ obj-$(CONFIG_MACH_OMAP3_PANDORA)  += board-omap3pandora.o \
>>                                          hsmmc.o
>>  obj-$(CONFIG_MACH_OMAP_3430SDP)              += board-3430sdp.o \
>>                                          hsmmc.o \
>> -                                        board-flash.o
>> +                                        board-flash.o \
>> +                                        twl4030.o
>
> This should not be board-specific in the Makefile, otherwise it will
> have to be added for every single board that uses it.
>
> Rather, it should probably be built as long as CONFIG_TWL4030_POWER=y.
> Also, please be sure to build test when that option is disabled as well.
Ok, I will make the changes as mentioned in next thread ...

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts
  2011-03-07 21:10     ` Kevin Hilman
@ 2011-03-08  7:06       ` Manuel, Lesly Arackal
  0 siblings, 0 replies; 24+ messages in thread
From: Manuel, Lesly Arackal @ 2011-03-08  7:06 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Hi Kevin,

On Tue, Mar 8, 2011 at 2:40 AM, Kevin Hilman <khilman@ti.com> wrote:
> Kevin Hilman <khilman@ti.com> writes:
>
>> Lesly A M <leslyam@ti.com> writes:
>>
>>> Using TWL4030 power scripts to control the LDOs and DCDC regulators
>>> while going to low power mode.
>>>
>>> Signed-off-by: Lesly A M <leslyam@ti.com>
>>
>> Minor: Re: Subject: OMAP is an acronym, please capitalize.
>>
>>> Cc: Nishanth Menon <nm@ti.com>
>>> Cc: David Derrick <dderrick@ti.com>
>>> Cc: Samuel Ortiz <sameo@linux.intel.com>
>>> ---
>>>  arch/arm/mach-omap2/Makefile        |    3 +-
>>>  arch/arm/mach-omap2/board-3430sdp.c |   93 +----------------------------------
>>>  2 files changed, 4 insertions(+), 92 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
>>> index 742ca67..bb11329 100644
>>> --- a/arch/arm/mach-omap2/Makefile
>>> +++ b/arch/arm/mach-omap2/Makefile
>>> @@ -175,7 +175,8 @@ obj-$(CONFIG_MACH_OMAP3_PANDORA) += board-omap3pandora.o \
>>>                                         hsmmc.o
>>>  obj-$(CONFIG_MACH_OMAP_3430SDP)             += board-3430sdp.o \
>>>                                         hsmmc.o \
>>> -                                       board-flash.o
>>> +                                       board-flash.o \
>>> +                                       twl4030.o
>>
>> This should not be board-specific in the Makefile, otherwise it will
>> have to be added for every single board that uses it.
>>
>> Rather, it should probably be built as long as CONFIG_TWL4030_POWER=y.
>> Also, please be sure to build test when that option is disabled as well.
>
> Just notcied that twl4030.c is already wrapped by CONFIG_TWL4030_POWER,
> so just build it for CONFIG_PM:
>
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 65d8701..8bdc969 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -61,7 +61,7 @@ ifeq ($(CONFIG_PM),y)
>  obj-$(CONFIG_ARCH_OMAP2)               += pm24xx.o
>  obj-$(CONFIG_ARCH_OMAP2)               += sleep24xx.o pm_bus.o
>  obj-$(CONFIG_ARCH_OMAP3)               += pm34xx.o sleep34xx.o \
> -                                          cpuidle34xx.o pm_bus.o
> +                                          cpuidle34xx.o pm_bus.o twl4030.o
>  obj-$(CONFIG_ARCH_OMAP4)               += pm44xx.o pm_bus.o
>  obj-$(CONFIG_PM_DEBUG)                 += pm-debug.o
>  obj-$(CONFIG_OMAP_SMARTREFLEX)          += sr_device.o smartreflex.o
>
>
> Then, you'll also have to modify twl4030.h so that
> twl4030_generic_script is NULL when CONFIG_TWL_4030=n so board files
> will still compile.

Ok, I will do it.

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround
  2011-03-07 21:14   ` Kevin Hilman
@ 2011-03-08  7:14     ` Manuel, Lesly Arackal
  0 siblings, 0 replies; 24+ messages in thread
From: Manuel, Lesly Arackal @ 2011-03-08  7:14 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Hi Kevin,

On Tue, Mar 8, 2011 at 2:44 AM, Kevin Hilman <khilman@ti.com> wrote:
> Hi Lesly,
>
> Lesly A M <leslyam@ti.com> writes:
>
>> Workaround for TWL5030 Silicon Errata 27 & 28:
>>       27 - VDD1, VDD2, may have glitches when their output value is updated.
>>       28 - VDD1 and / or VDD2 DCDC clock may stop working when internal clock
>>               is switched from internal to external.
>>
>> Errata 27:
>>       If the DCDC regulators is running on their internal oscillator,
>>       negative glitches may occur on VDD1, VDD2 output when voltage is changed.
>>       The OMAP device may reboot if the VDD1 or VDD2 go below the
>>       core minimum operating voltage.
>>
>>       WORKAROUND
>>       Set up the TWL5030 DC-DC power supplies to use the HFCLKIN instead of
>>       the internal oscillator.
>>
>> Errata 28:
>>       VDD1/VDD2 clock system may hang during switching the clock source from
>>       internal oscillator to external. VDD1/VDD2 output voltages may collapse
>>       if clock stops.
>>
>>       WORKAROUND
>>       If HFCLK is disabled in OFFMODE, modify the sleep/wakeup sequence and
>>       setuptimes to make sure the switching will happen only when HFCLKIN is stable.
>>       Also use the TWL5030 watchdog to safeguard the first switching from
>>       internal oscillator to HFCLKIN during the TWL5030 init.
>>
>>       IMPACT
>>       power sequence is changed.
>>       sleep/wakeup time values will be changed.
>>
>> The workaround changes are called from twl4030_power_init(), since we have to
>> make some i2c_read calls to check the TRITON version & the i2c will not be
>> initialized in the early stage.
>>
>> This workaround is required for TWL5030 Silicon version less than ES1.2
>> The power script & setup time changes are recommended by TI HW team.
>>
>> http://omapedia.org/wiki/TWL4030_power_scripts
>>
>> Changes taken from TRITON Errata27 workaround patch by Nishanth Menon.
>>
>> Signed-off-by: Lesly A M <leslyam@ti.com>
>> Cc: Nishanth Menon <nm@ti.com>
>> Cc: David Derrick <dderrick@ti.com>
>> Cc: Samuel Ortiz <sameo@linux.intel.com>
>
> Some minor comments below,
>
>> ---
>>  arch/arm/mach-omap2/twl4030.c |  114 +++++++++++++++++++++++++++++++++++++++++
>>  drivers/mfd/twl4030-power.c   |   64 +++++++++++++++++++++++
>>  include/linux/i2c/twl.h       |    1 +
>>  3 files changed, 179 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c
>> index ff344b3..87de049 100644
>> --- a/arch/arm/mach-omap2/twl4030.c
>> +++ b/arch/arm/mach-omap2/twl4030.c
>> @@ -137,9 +137,123 @@ static struct twl4030_resconfig twl4030_rconfig[] = {
>>       { 0, 0},
>>  };
>>
>> +/*
>> + * Active to Sleep sequence, which is executed upon P1/P2/P3
>> + * transition for sleep.
>> + *
>> + * The sleep sequence is adjusted to do the switching of VDD1/VDD2/VIO OSC from
>> + * HFCLKIN to internal oscillator when the HFCLKIN is stable.
>> + */
>> +static struct twl4030_ins __initdata sleep_on_seq_errata27[] = {
>> +     /*
>> +      * Singular message to disable HCLKOUT.
>> +      * Wait for ~488.32 uS to do the switching of VDD1/VDD2/VIO OSC from
>> +      * HFCLKIN to internal oscillator before disabling HFCLKIN.
>> +      */
>> +     {MSG_SINGULAR(DEV_GRP_NULL, RES_HFCLKOUT, RES_STATE_SLEEP), 20},
>> +     /* Broadcast message to put res(TYPE2 = 1) to sleep */
>> +     {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
>> +                                                     RES_STATE_SLEEP), 2},
>> +     /* Broadcast message to put res(TYPE2 = 2) to sleep, disable HFCLKIN */
>> +     {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_errata27 __initdata = {
>> +     .script = sleep_on_seq_errata27,
>> +     .size   = ARRAY_SIZE(sleep_on_seq_errata27),
>> +     .flags  = TWL4030_SLEEP_SCRIPT,
>> +};
>> +
>> +/*
>> + * Sleep to Active sequence, which is executed upon P1/P2/P3
>> + * transition for wakeup.
>> + *
>> + * The wakeup sequence is adjusted to do the VDD1/VDD2 voltage rampup
>> + * only after HFCLKIN is stabilized and the HFCLKOUT is enabled.
>> + */
>> +static struct twl4030_ins wakeup_seq_errata27[] __initdata = {
>> +     /*
>> +      * Broadcast message to put res(TYPE2 = 2) to active.
>> +      * Wait for ~10 mS (rampup time for OSC on the board)
>> +      * after HFCLKIN is enabled
>> +      */
>> +     {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
>> +                                                     RES_STATE_ACTIVE), 55},
>> +     {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
>> +                                                     RES_STATE_ACTIVE), 55},
>> +     {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
>> +                                                     RES_STATE_ACTIVE), 54},
>> +     {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R2,
>> +                                                     RES_STATE_ACTIVE), 1},
>> +     /* Singular message to enable HCLKOUT after HFCLKIN is stabilized */
>> +     {MSG_SINGULAR(DEV_GRP_NULL, RES_HFCLKOUT, RES_STATE_ACTIVE), 1},
>> +     /*
>> +      * Broadcast message to put res(TYPE2 = 1) to active.
>> +      * VDD1/VDD2 rampup after HFCLKIN is stable and HFCLKOUT is enabled.
>> +      */
>> +     {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_R0, RES_TYPE2_R1,
>> +                                                     RES_STATE_ACTIVE), 2},
>> +};
>> +
>> +static struct twl4030_script wakeup_script_errata27 __initdata = {
>> +     .script = wakeup_seq_errata27,
>> +     .size   = ARRAY_SIZE(wakeup_seq_errata27),
>> +     .flags  = TWL4030_WAKEUP12_SCRIPT | TWL4030_WAKEUP3_SCRIPT,
>> +};
>> +
>> +/* TRITON script for sleep, wakeup & warm_reset */
>> +static struct twl4030_script *twl4030_scripts_errata27[] __initdata = {
>> +     &sleep_on_script_errata27,
>> +     &wakeup_script_errata27,
>> +     &wrst_script,
>> +};
>> +
>> +/*
>> + * VDD1/VDD2/VPLL are assigned to P1 and P3, to have better control
>> + * during OFFMODE. HFCLKOUT is assigned to P1 and P3 (*p2) to turn off
>> + * only during OFFMODE.
>> + * (*P2 is included if the platform uses it for modem/some other processor)
>> + */
>> +static struct twl4030_resconfig twl4030_rconfig_errata27[] = {
>> +     { .resource = RES_VPLL1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
>> +             .type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
>> +     { .resource = RES_VINTANA1, .devgroup = DEV_GRP_ALL, .type = 1,
>> +             .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_VINTANA2, .devgroup = DEV_GRP_ALL, .type = 0,
>> +             .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_VINTDIG, .devgroup = DEV_GRP_ALL, .type = 1,
>> +             .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_VIO, .devgroup = DEV_GRP_ALL, .type = 2,
>> +             .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_VDD1, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
>> +             .type = 4, .type2 = 1, .remap_sleep = RES_STATE_OFF },
>> +     { .resource = RES_VDD2, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
>> +             .type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
>> +     { .resource = RES_REGEN, .devgroup = DEV_GRP_ALL, .type = 2,
>> +             .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_ALL, .type = 0,
>> +             .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_CLKEN, .devgroup = DEV_GRP_ALL, .type = 3,
>> +             .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_SYSEN, .devgroup = DEV_GRP_ALL, .type = 6,
>> +             .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
>> +     { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P1 | DEV_GRP_P3,
>> +             .type = 0, .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
>> +     { 0, 0},
>> +};
>> +
>> +void twl5030_script_errata27(void)
>
> static

Ok

>> +{
>> +     twl4030_generic_script.scripts = twl4030_scripts_errata27;
>> +     twl4030_generic_script.num = ARRAY_SIZE(twl4030_scripts_errata27);
>> +     twl4030_generic_script.resource_config = twl4030_rconfig_errata27;
>> +}
>> +
>>  struct twl4030_power_data __initdata twl4030_generic_script = {
>>       .scripts        = twl4030_scripts,
>>       .num            = ARRAY_SIZE(twl4030_scripts),
>>       .resource_config = twl4030_rconfig,
>> +     .twl5030_errata27wa_script = twl5030_script_errata27,
>>  };
>>  #endif
>> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
>> index 8373d79..db24d09 100644
>> --- a/drivers/mfd/twl4030-power.c
>> +++ b/drivers/mfd/twl4030-power.c
>> @@ -63,6 +63,14 @@ static u8 twl4030_start_script_address = 0x2b;
>>  #define R_MEMORY_ADDRESS     PHY_TO_OFF_PM_MASTER(0x59)
>>  #define R_MEMORY_DATA                PHY_TO_OFF_PM_MASTER(0x5a)
>>
>> +#define R_VDD1_OSC           0x5C
>> +#define R_VDD2_OSC           0x6A
>> +#define R_VIO_OSC            0x52
>> +#define EXT_FS_CLK_EN                (0x1 << 6)
>> +
>
> BIT(6)

Ok

>> +#define R_WDT_CFG            0x03
>> +#define WDT_WRK_TIMEOUT              0x03
>> +
>>  /* resource configuration registers
>>     <RESOURCE>_DEV_GRP   at address 'n+0'
>>     <RESOURCE>_TYPE      at address 'n+1'
>> @@ -511,6 +519,53 @@ int twl4030_remove_script(u8 flags)
>>       return err;
>>  }
>>
>> +/**
>> + * twl_errata27_workaround() - Workaround for TWL5030 Silicon Errata 27 & 28:
>> + * 27 - VDD1, VDD2, may have glitches when their output value is updated.
>> + * 28 - VDD1 and / or VDD2 DCDC clock may stop working when internal clock is
>> + * switched from internal to external.
>> + *
>> + * Workaround requires the TWL DCDCs to use HFCLK instead of
>> + * internal oscillator. Also enable TWL watchdog before switching the osc
>> + * to recover if the VDD1/VDD2 stop working.
>> + */
>> +static void __init twl_errata27_workaround(void)
>> +{
>> +     u8 val;
>> +     u8 smps_osc_reg[] = {R_VDD1_OSC, R_VDD2_OSC, R_VIO_OSC};
>> +     u8 wdt_counter_val = 0;
>> +     int i;
>> +     int err;
>> +
>> +     /* Setup the twl wdt to take care of borderline failure case */
>> +     err = twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &wdt_counter_val,
>> +                     R_WDT_CFG);
>> +     err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, WDT_WRK_TIMEOUT,
>> +                     R_WDT_CFG);
>> +
>> +     for (i = 0; i < sizeof(smps_osc_reg); i++) {
>> +             err |= twl_i2c_read_u8(TWL4030_MODULE_PM_RECEIVER, &val,
>> +                                                     smps_osc_reg[i]);
>> +             val |= EXT_FS_CLK_EN;
>> +             err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, val,
>> +                                                     smps_osc_reg[i]);
>> +     }
>> +
>> +     /* restore the original value */
>> +     err |= twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, wdt_counter_val,
>> +                     R_WDT_CFG);
>> +     if (err)
>> +             pr_warning("TWL4030: workaround setup failed!\n");
>> +}
>> +
>> +bool is_twl5030_errata27wa_required(void)
>
> static

Ok, I will do these changes.

Thanks & Regards,
Lesly A M

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27
  2011-03-07 21:25 ` [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Kevin Hilman
@ 2011-03-08  7:30   ` Manuel, Lesly Arackal
  0 siblings, 0 replies; 24+ messages in thread
From: Manuel, Lesly Arackal @ 2011-03-08  7:30 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: linux-omap, Nishanth Menon, David Derrick, Samuel Ortiz

Hi Kevin,

On Tue, Mar 8, 2011 at 2:55 AM, Kevin Hilman <khilman@ti.com> wrote:
> Lesly A M <leslyam@ti.com> writes:
>
>> Patch series for TWL4030 power scripts and workaround for TWL errata 27.
>>
>> Changes for implementing TWL4030 power scripts recommended by hardware team.
>> Introduced a new TWL4030 power script file, which can be used by different
>> OMAP3 board with the power companion chip TWL4030.
>>
>> Updated the changes for TWL4030 errata 27 & 28, and modified the
>> TWL4030 power script.
>> Workaround for TWL4030 errata 27 & 28 is required for
>> Si version less than or equal to TWL5030 ES1.1.
>>
>> TWL4030 script changes rebased on Kevin's PM tree in pm branch.
>
> This doesn't apply to the current PM branch.  I dropped the old scripts
> from the PM branch some time back.  It should be a simple rebase, and
> only affects PATCH 6/8.  After the rebase, it will only add the new
> stuff to the 3430SDP board file instead of also delete the old scripts.
>
> Also, minor nit: please consistenly capitlize acronyms: API, OMAP, etc,
> and the singular for errata is erattum.  This affects subjects,
> changelogs comments etc.

Ok, I wil fix it.

>
>> Changes in v7:
>>       changes to fix Nishanth Menon's comments
>>               i) Added the TWL4030 Errata 27 fix
>>
>>       split the first patch in v6
>>               i)  fix for twl4030 script load
>>               ii) correct the warning print during script loading
>>
>>       Added new patch files
>>               i) changing sys_off signal polarity
>>
>> Changes in v8:
>>       updated the change logs
>>       moving the TWL IDCODE checking to twl-core.c
>>
>> Since the voltage layer is evolving to a new design, the voltage dependant
>> changes required for the TRITON script are not incorporated in the patch series.
>> So this TRITON script patch series can be tested with a separate patch for
>> voltage layer changes.
>>
>>       lnk: http://pastebin.mozilla.org/1118306
>
> I'm OK with leaving the voltage layer changes for a separate series, but
> in order to test this should also be rebased against my current PM branch.
>
> For future reference, my pm-core branch includes only patches/series
> that are already queued for upstream, or will be queued for the next
> merge window.

Ok, I will rebase the patches.

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence
  2011-03-02 13:30 ` [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence Lesly A M
@ 2011-03-08 13:14   ` Menon, Nishanth
  0 siblings, 0 replies; 24+ messages in thread
From: Menon, Nishanth @ 2011-03-08 13:14 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, David Derrick, Samuel Ortiz

minor comment - here and elsewhere - "OMAP", PM is a good idea to be
caps even in $subject.

On Wed, Mar 2, 2011 at 19:00, Lesly A M <leslyam@ti.com> wrote:
>
> Only configure sleep script when the flag is TWL4030_SLEEP_SCRIPT.
>
> Adding the missing brackets for fixing the issue.
>
> Signed-off-by: Lesly A M <leslyam@ti.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: David Derrick <dderrick@ti.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> ---
>  drivers/mfd/twl4030-power.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index 16422de..2c0d4d1 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -447,12 +447,13 @@ static int __init load_twl4030_script(struct twl4030_script *tscript,
>                if (err)
>                        goto out;
>        }
> -       if (tscript->flags & TWL4030_SLEEP_SCRIPT)
> +       if (tscript->flags & TWL4030_SLEEP_SCRIPT) {
>                if (order)
>                        pr_warning("TWL4030: Bad order of scripts (sleep "\
>                                        "script before wakeup) Leads to boot"\
>                                        "failure on some boards\n");
>                err = twl4030_config_sleep_sequence(address);
> +       }
>  out:
>        return err;
>  }
> --
> 1.7.1
>
Otherwise, looks fine to me.
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading
  2011-03-02 13:30 ` [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading Lesly A M
@ 2011-03-08 13:18   ` Menon, Nishanth
  0 siblings, 0 replies; 24+ messages in thread
From: Menon, Nishanth @ 2011-03-08 13:18 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, David Derrick, Samuel Ortiz

On Wed, Mar 2, 2011 at 19:00, Lesly A M <leslyam@ti.com> wrote:
> Correcting the if condition check for printing the warning,
> if wakeup script is not updated before updating the sleep script.
>
> Since the flag 'order' is set to '1' while updating the wakeup script for P1P2,
> the condition checking for printing the warning should be if(!order)
> (ie: print the warning if wakeup script is not updated before updating the sleep script)
>
> Signed-off-by: Lesly A M <leslyam@ti.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: David Derrick <dderrick@ti.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> ---
>  drivers/mfd/twl4030-power.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
> index 2c0d4d1..8373d79 100644
> --- a/drivers/mfd/twl4030-power.c
> +++ b/drivers/mfd/twl4030-power.c
> @@ -448,7 +448,7 @@ static int __init load_twl4030_script(struct twl4030_script *tscript,
>                        goto out;
>        }
>        if (tscript->flags & TWL4030_SLEEP_SCRIPT) {
> -               if (order)
> +               if (!order)
>                        pr_warning("TWL4030: Bad order of scripts (sleep "\
>                                        "script before wakeup) Leads to boot"\
>                                        "failure on some boards\n");
> --
> 1.7.1
>
>
Acked-by: Nishanth Menon <nm@ti.com>

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards
  2011-03-02 13:30 ` [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards Lesly A M
  2011-03-07 21:02   ` Kevin Hilman
@ 2011-03-08 16:03   ` Menon, Nishanth
  1 sibling, 0 replies; 24+ messages in thread
From: Menon, Nishanth @ 2011-03-08 16:03 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, David Derrick, Samuel Ortiz

On Wed, Mar 2, 2011 at 19:00, Lesly A M <leslyam@ti.com> wrote:
[...]
> diff --git a/arch/arm/mach-omap2/twl4030.c b/arch/arm/mach-omap2/twl4030.c
> new file mode 100644
> index 0000000..ff344b3
> --- /dev/null
> +++ b/arch/arm/mach-omap2/twl4030.c
> @@ -0,0 +1,145 @@
> +/*
> + * OMAP power script for PMIC TWL4030
> + *
> + * Author: Lesly A M <leslyam@ti.com>
> + *
> + * Copyright (C) 2010 Texas Instruments, Inc.
> + * Lesly A M <leslyam@ti.com>
> + *
> + * 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_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},

I dont understand this sequence unfortunately. need documentation to
help me here.

> +};
> +
> +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[] = {
overall, I recommend being explicit for the rails  -I believe VPLLs
are an example of that. rationale: imagine doing a OTA update: you'd
have the old scripts programmed in by the previous kernel, then the
new kernel starts up since we do a OMAP restart and not really a TWL
restart, we'd end up with a mixture of scripts in the system.  - this
is definitely a scenario to avoid - things like broadcast events like
those above going through to rails in the wrong groups can have
havoc..

> +       { .resource = RES_VPLL1, .devgroup = DEV_GRP_P1, .type = 3,
> +               .type2 = 1, .remap_sleep = RES_STATE_OFF },
> +       { .resource = RES_VINTANA1, .devgroup = DEV_GRP_ALL, .type = 1,
> +               .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_VINTANA2, .devgroup = DEV_GRP_ALL, .type = 0,
> +               .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_VINTDIG, .devgroup = DEV_GRP_ALL, .type = 1,
> +               .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_VIO, .devgroup = DEV_GRP_ALL, .type = 2,
> +               .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_VDD1, .devgroup = DEV_GRP_P1,
> +               .type = 4, .type2 = 1, .remap_sleep = RES_STATE_OFF },
> +       { .resource = RES_VDD2, .devgroup = DEV_GRP_P1,
> +               .type = 3, .type2 = 1, .remap_sleep = RES_STATE_OFF },
> +       { .resource = RES_REGEN, .devgroup = DEV_GRP_ALL, .type = 2,
> +               .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_NRES_PWRON, .devgroup = DEV_GRP_ALL, .type = 0,
> +               .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_CLKEN, .devgroup = DEV_GRP_ALL, .type = 3,
> +               .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_SYSEN, .devgroup = DEV_GRP_ALL, .type = 6,
> +               .type2 = 1, .remap_sleep = RES_STATE_SLEEP },
> +       { .resource = RES_HFCLKOUT, .devgroup = DEV_GRP_P3,
> +               .type = 0, .type2 = 2, .remap_sleep = RES_STATE_SLEEP },
> +       { 0, 0},

Dumb q:  vpll2, vaux1-3, vmmc1-2,vsim,vdac,vsub1.5,1.8,3.1, regen,
32KHzclk, triton_ref and main_ref are other resources not covered in
the sequence? I think you either need to cover them OR document why
not and probably stuff like vaux, vmmc1-2 are responsibility of
drivers needs to be clearly stated.

> +};
> +
> +struct twl4030_power_data __initdata twl4030_generic_script = {
> +       .scripts        = twl4030_scripts,
> +       .num            = ARRAY_SIZE(twl4030_scripts),
> +       .resource_config = twl4030_rconfig,
> +};
> +#endif
> diff --git a/arch/arm/mach-omap2/twl4030.h b/arch/arm/mach-omap2/twl4030.h
> new file mode 100644
> index 0000000..ee66e7d
> --- /dev/null
> +++ b/arch/arm/mach-omap2/twl4030.h
> @@ -0,0 +1,20 @@
> +/*
> + * OMAP TWL4030 power scripts header file
> + *
> + * Author: Lesly A M <x0080970@ti.com>
> + *
> + * Copyright (C) 2010 Texas Instruments, Inc.
> + * Lesly A M <x0080970@ti.com>
> + *
> + * 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.
> + */
> +
> +#ifndef __ARCH_ARM_MACH_OMAP3_TWL4030_SCRIPT_H
> +#define __ARCH_ARM_MACH_OMAP3_TWL4030_SCRIPT_H
> +
> +#include <linux/i2c/twl.h>
mebbe Kevin can comment if including header in header file is a good idea..

> +
> +extern struct twl4030_power_data twl4030_generic_script;
what if TWL4030 was disabled?

> +#endif
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index 61b9609..f4bd475 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -436,9 +436,23 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
>
>  /* Power bus message definitions */
>
> -/* The TWL4030/5030 splits its power-management resources (the various
> - * regulators, clock and reset lines) into 3 processor groups - P1, P2 and
> - * P3. These groups can then be configured to transition between sleep, wait-on
> +/*
> + * The TWL4030/5030 splits its power-management resources (the various
> + * regulators, clock and reset lines) into 3 processor groups - P1, P2 and P3.
> + *
> + * Resources attached to device group P1 is managed depending on the state of
> + * NSLEEP1 pin of TRITON, which is connected to sys_off signal from OMAP
> + *
> + * Resources attached to device group P2 is managed depending on the state of
> + * NSLEEP2 pin of TRITON, which is can be connected to a modem or
> + * some other processor
how do these map to OMAP - remember - most of us are familiar with
OMAP and not TWL4030 :(

> + *
> + * Resources attached to device group P3 is managed depending on the state of
> + * CLKREQ pin of TRITON, which is connected to clk request signal from OMAP
> + *
> + * If required these resources can be attached to combination of P1/P2/P3.
> + *
> + * These groups can then be configured to transition between sleep, wait-on
>  * and active states by sending messages to the power bus.  See Section 5.4.2
>  * Power Resources of TWL4030 TRM
>  */
> @@ -448,7 +462,17 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
>  #define DEV_GRP_P1             0x1     /* P1: all OMAP devices */
>  #define DEV_GRP_P2             0x2     /* P2: all Modem devices */
>  #define DEV_GRP_P3             0x4     /* P3: all peripheral devices */
> +#define DEV_GRP_ALL            0x7     /* P1/P2/P3: all devices */
>
> +/*
> + * The 27 power resources in TRITON is again divided into
> + * analog resources:
> + *     Power Providers - LDO regulators, dc-to-dc regulators
> + *     Power Reference - analog reference
> + *
> + * and digital resources:
> + *     Reset & Clock - reset and clock signals.
> + */
>  /* Resource groups */
>  #define RES_GRP_RES            0x0     /* Reserved */
>  #define RES_GRP_PP             0x1     /* Power providers */
> @@ -460,7 +484,10 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
>  #define RES_GRP_ALL            0x7     /* All resource groups */
>
>  #define RES_TYPE2_R0           0x0
> +#define RES_TYPE2_R1           0x1
> +#define RES_TYPE2_R2           0x2
>
> +#define RES_TYPE_R0            0x0
>  #define RES_TYPE_ALL           0x7
>
>  /* Resource states */
> --
> 1.7.1
>
>


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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards
  2011-03-07 21:02   ` Kevin Hilman
  2011-03-08  6:50     ` Manuel, Lesly Arackal
@ 2011-03-08 16:29     ` Nishanth Menon
  1 sibling, 0 replies; 24+ messages in thread
From: Nishanth Menon @ 2011-03-08 16:29 UTC (permalink / raw)
  To: Kevin Hilman; +Cc: Lesly A M, linux-omap, David Derrick, Samuel Ortiz

Kevin Hilman wrote, on 03/08/2011 02:32 AM:
> Lesly A M<leslyam@ti.com>  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<wiki page>.
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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH v8 4/7] omap3: pm: TWL5030 version checking
  2011-03-02 13:30 ` [PATCH v8 4/7] omap3: pm: TWL5030 version checking Lesly A M
  2011-03-03 12:00   ` Krishnamoorthy, Balaji T
@ 2011-03-10  4:15   ` Menon, Nishanth
  1 sibling, 0 replies; 24+ messages in thread
From: Menon, Nishanth @ 2011-03-10  4:15 UTC (permalink / raw)
  To: Lesly A M; +Cc: linux-omap, David Derrick, Samuel Ortiz

$subject - OMAP3: pm? this is mfd twl-core rt?

On Wed, Mar 2, 2011 at 19:00, Lesly A M <leslyam@ti.com> wrote:
>
> Added api to get the TWL5030 Si version from the IDCODE register.
Does this work for 4030 and TPS variants as well? since this is
twl-core - how about the impact to 6030?

> It is used for enabling the workaround for TWL errata 27.
>
> Signed-off-by: Lesly A M <leslyam@ti.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: David Derrick <dderrick@ti.com>
> Cc: Samuel Ortiz <sameo@linux.intel.com>
> ---
>  drivers/mfd/twl-core.c  |   61 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/i2c/twl.h |   17 ++++++++++++-
>  2 files changed, 77 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index a35fa7d..5e706d7 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -229,6 +229,9 @@
>  /* is driver active, bound to a chip? */
>  static bool inuse;
>
> +/* TWL IDCODE Register value */
> +static u32 twl_idcode;
> +
>  static unsigned int twl_id;
>  unsigned int twl_rev(void)
>  {
> @@ -487,6 +490,61 @@ EXPORT_SYMBOL(twl_i2c_read_u8);
>
>  /*----------------------------------------------------------------------*/
>
> +/**
> + * twl_read_idcode_register - api to read the IDCODE register.
s/api/API ?
> + * @value: returns 32 bit IDCODE register value.
 Warning(drivers/mfd/twl-core.c:500): Excess function parameter
'value' description in 'twl_read_idcode_register'
please run scripts/kernel-doc on file when you add documentation to
ensure the documentation is in sync
> + *
> + * Unlocks the IDCODE register and read the 32 bit value.
> + */
> +int twl_read_idcode_register(void)
as previously mentioned:
drivers/mfd/twl-core.c:499:5: warning: symbol
'twl_read_idcode_register' was not declared. Should it be static?

> +{
> +       int err;
> +
> +       err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, TWL_EEPROM_R_UNLOCK,
> +                                               REG_UNLOCK_TEST_REG);
> +       if (err) {
> +               pr_err("TWL4030 Unable to unlock IDCODE registers\n");
> +               goto fail;
> +       }
Do you want to be consistent everywhere and provide err value in print as well?


> +
> +       err = twl_i2c_read(TWL4030_MODULE_INTBR, (u8 *)(&twl_idcode),
Why should I cast this if I read only u8, why not make twl_idcode as u8?
Also modify twl_get_si_type, twl_get_si_version to return appropriately?

> +                                               REG_IDCODE_7_0, 4);
> +       if (err) {
> +               pr_err("TWL4030: unable to read IDCODE -%d\n", err);
> +               goto fail;
> +       }
> +
> +       err = twl_i2c_write_u8(TWL4030_MODULE_INTBR, 0x0, REG_UNLOCK_TEST_REG);
> +       if (err) {
> +               pr_err("TWL4030 Unable to relock IDCODE registers\n");
> +               goto fail;
why goto fail here?
> +       }
> +fail:
> +       return err;
> +}
> +
> +/**
> + * twl_get_si_type - api to get TWL Si type.
> + *
> + * Api to get the TWL Si type from IDCODE value.
> + */
> +int twl_get_si_type(void)
> +{
> +       return TWL_SIL_TYPE(twl_idcode);
> +}
> +EXPORT_SYMBOL(twl_get_si_type);
EXPORT_SYMBOL_GPL instead?
> +
> +/**
> + * twl_get_si_version - api to get TWL Si version.
> + *
> + * Api to get the TWL Si version from IDCODE value.
> + */
> +int twl_get_si_version(void)
> +{
> +       return TWL_SIL_REV(twl_idcode);
> +}
> +EXPORT_SYMBOL(twl_get_si_version);
^^^^ here as well.
> +
>  static struct device *
>  add_numbered_child(unsigned chip, const char *name, int num,
>                void *pdata, unsigned pdata_len,
> @@ -1056,6 +1114,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
>        /* setup clock framework */
>        clocks_init(&client->dev, pdata->clock);
>
> +       /* read TWL IDCODE Register */
> +       twl_read_idcode_register();
> +
as already mentioned, what do we do when this fails?

>        /* load power event scripts */
>        if (twl_has_power() && pdata->power)
>                twl4030_power_init(pdata->power);
> diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h
> index f4bd475..d3cc2ac 100644
> --- a/include/linux/i2c/twl.h
> +++ b/include/linux/i2c/twl.h
> @@ -150,7 +150,12 @@
>  #define MMC_PU                         (0x1 << 3)
>  #define MMC_PD                         (0x1 << 2)
>
> -
> +#define TWL_SIL_TYPE(rev)              ((rev) & 0x00FFFFFF)
> +#define TWL_SIL_REV(rev)               ((rev) >> 24)
> +#define TWL_SIL_5030                   0x09002F
> +#define TWL5030_REV_1_0                        0x00
> +#define TWL5030_REV_1_1                        0x10
> +#define TWL5030_REV_1_2                        0x30
how about 4030 and 6030?

>
>  #define TWL4030_CLASS_ID               0x4030
>  #define TWL6030_CLASS_ID               0x6030
> @@ -180,6 +185,9 @@ int twl_i2c_read_u8(u8 mod_no, u8 *val, u8 reg);
>  int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
>  int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
>
> +int twl_get_si_type(void);
> +int twl_get_si_version(void);
Please change the names of these APIs - what is Si?

> +
>  int twl6030_interrupt_unmask(u8 bit_mask, u8 offset);
>  int twl6030_interrupt_mask(u8 bit_mask, u8 offset);
>
> @@ -279,7 +287,12 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
>  *(Use TWL_4030_MODULE_INTBR)
>  */
>
> +#define REG_IDCODE_7_0                 0x00
> +#define REG_IDCODE_15_8                        0x01
> +#define REG_IDCODE_16_23               0x02
> +#define REG_IDCODE_31_24               0x03
>  #define REG_GPPUPDCTR1                 0x0F
> +#:define REG_UNLOCK_TEST_REG            0x12
>
>  /*I2C1 and I2C4(SR) SDA/SCL pull-up control bits */
>
> @@ -288,6 +301,8 @@ static inline int twl6030_mmc_card_detect(struct device *dev, int slot)
>  #define SR_I2C_SCL_CTRL_PU             BIT(4)
>  #define SR_I2C_SDA_CTRL_PU             BIT(6)
>
> +#define TWL_EEPROM_R_UNLOCK            0x49
rest of the file seems to have a convention:
REG_NAME why is this register with a different convention?




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

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2011-03-10  4:16 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02 13:30 [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Lesly A M
2011-03-02 13:30 ` [PATCH v8 1/7] omap3: pm: Fix for the TRITON sleep/wakeup sequence Lesly A M
2011-03-08 13:14   ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 2/7] omap3: pm: Correct the warning print during script loading Lesly A M
2011-03-08 13:18   ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 3/7] omap3: pm: TWL4030 power scripts for OMAP3 boards Lesly A M
2011-03-07 21:02   ` Kevin Hilman
2011-03-08  6:50     ` Manuel, Lesly Arackal
2011-03-08 16:29     ` Nishanth Menon
2011-03-08 16:03   ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 4/7] omap3: pm: TWL5030 version checking Lesly A M
2011-03-03 12:00   ` Krishnamoorthy, Balaji T
2011-03-10  4:15   ` Menon, Nishanth
2011-03-02 13:30 ` [PATCH v8 5/7] mfd: TWL4030: changes for TRITON Errata 27 workaround Lesly A M
2011-03-07 21:14   ` Kevin Hilman
2011-03-08  7:14     ` Manuel, Lesly Arackal
2011-03-02 13:30 ` [PATCH v8 6/7] omap3430: Updating the board file to use TWL4030 scripts Lesly A M
2011-03-07 19:42   ` Kevin Hilman
2011-03-07 21:10     ` Kevin Hilman
2011-03-08  7:06       ` Manuel, Lesly Arackal
2011-03-08  7:01     ` Manuel, Lesly Arackal
2011-03-02 13:30 ` [PATCH v8 7/7] omap3630: " Lesly A M
2011-03-07 21:25 ` [PATCH v8 0/8] omap3: pm: TWL4030 power scripts and workaround for TWL errata 27 Kevin Hilman
2011-03-08  7:30   ` Manuel, Lesly Arackal

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).