linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd
@ 2008-10-10 16:56 Peter 'p2' De Schrijver
  2008-10-10 16:56 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
  0 siblings, 1 reply; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patchset integrates the twl4030 power code into the new twl4030 mfd framework. The scripts will be moved to the board specific data.

Peter 'p2' De Schrijver (7):
  Remove existing twl4030 power script code.
  Add defines and data types for twl4030.
  Twl4030 power code updated for new twl4030 core
  Hook twl4030 power code into twl4030 core.
  3430sdp and ldp use custom twl4030 power scripts.
  Generic twl4030 power script for 3430 based boards.
  omap3 evm beagle and overo use the generic twl4030 script

 arch/arm/mach-omap2/Makefile                  |    9 +-
 arch/arm/mach-omap2/board-3430sdp.c           |   61 +++++
 arch/arm/mach-omap2/board-ldp.c               |   62 +++++
 arch/arm/mach-omap2/board-omap3beagle.c       |    3 +
 arch/arm/mach-omap2/board-omap3evm.c          |    3 +
 arch/arm/mach-omap2/board-overo.c             |    3 +
 arch/arm/mach-omap2/twl4030-generic-scripts.c |   78 ++++++
 drivers/i2c/chips/twl4030-power.c             |  343 -------------------------
 drivers/mfd/twl4030-core.c                    |   11 +
 drivers/mfd/twl4030-power.c                   |  270 +++++++++++++++++++
 include/linux/i2c/twl4030.h                   |   64 +++++
 11 files changed, 561 insertions(+), 346 deletions(-)
 create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.c
 delete mode 100644 drivers/i2c/chips/twl4030-power.c
 create mode 100644 drivers/mfd/twl4030-power.c


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

* [PATCH 1/7] Remove existing twl4030 power script code.
  2008-10-10 16:56 [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd Peter 'p2' De Schrijver
@ 2008-10-10 16:56 ` Peter 'p2' De Schrijver
  2008-10-10 16:56   ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
  2008-10-11 18:45   ` [PATCH 1/7] Remove existing twl4030 power script code Felipe Balbi
  0 siblings, 2 replies; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

First we remove the existing twl4030 power sequencer code.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/i2c/chips/twl4030-power.c |  343 -------------------------------------
 1 files changed, 0 insertions(+), 343 deletions(-)
 delete mode 100644 drivers/i2c/chips/twl4030-power.c

diff --git a/drivers/i2c/chips/twl4030-power.c b/drivers/i2c/chips/twl4030-power.c
deleted file mode 100644
index cb325b0..0000000
--- a/drivers/i2c/chips/twl4030-power.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * linux/drivers/i2c/chips/twl4030-power.c
- *
- * Handle TWL4030 Power initialization
- *
- * Copyright (C) 2008 Nokia Corporation
- * Copyright (C) 2006 Texas Instruments, Inc
- *
- * Written by 	Kalle Jokiniemi
- *		Peter De Schrijver <peter.de-schrijver@nokia.com>
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License. See the file "COPYING" in the main directory of this
- * archive for more details.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#include <linux/module.h>
-#include <linux/pm.h>
-#include <linux/i2c/twl4030.h>
-
-#include <asm/mach-types.h>
-
-#define PWR_P1_SW_EVENTS	0x10
-#define PWR_DEVOFF	(1<<0)
-
-#define PHY_TO_OFF_PM_MASTER(p)		(p - 0x36)
-#define PHY_TO_OFF_PM_RECIEVER(p)	(p - 0x5b)
-
-/* resource - hfclk */
-#define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECIEVER(0xe6)
-
-/* PM events */
-#define R_P1_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x46)
-#define R_P2_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x47)
-#define R_P3_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x48)
-#define R_CFG_P1_TRANSITION	PHY_TO_OFF_PM_MASTER(0x36)
-#define R_CFG_P2_TRANSITION	PHY_TO_OFF_PM_MASTER(0x37)
-#define R_CFG_P3_TRANSITION	PHY_TO_OFF_PM_MASTER(0x38)
-
-#define LVL_WAKEUP	0x08
-
-#define ENABLE_WARMRESET (1<<4)
-
-/* sequence script */
-
-#define END_OF_SCRIPT		0x3f
-
-#define R_SEQ_ADD_A2S		PHY_TO_OFF_PM_MASTER(0x55)
-#define R_SEQ_ADD_SA12		PHY_TO_OFF_PM_MASTER(0x56)
-#define	R_SEQ_ADD_S2A3		PHY_TO_OFF_PM_MASTER(0x57)
-#define	R_SEQ_ADD_WARM		PHY_TO_OFF_PM_MASTER(0x58)
-#define R_MEMORY_ADDRESS	PHY_TO_OFF_PM_MASTER(0x59)
-#define R_MEMORY_DATA		PHY_TO_OFF_PM_MASTER(0x5a)
-
-/* Power bus message definitions */
-
-#define DEV_GRP_NULL		0x0
-#define DEV_GRP_P1		0x1
-#define DEV_GRP_P2		0x2
-#define DEV_GRP_P3		0x4
-
-#define RES_GRP_RES		0x0
-#define RES_GRP_PP		0x1
-#define RES_GRP_RC		0x2
-#define RES_GRP_PP_RC		0x3
-#define RES_GRP_PR		0x4
-#define RES_GRP_PP_PR		0x5
-#define RES_GRP_RC_PR		0x6
-#define RES_GRP_ALL		0x7
-
-#define RES_TYPE2_R0		0x0
-
-#define RES_TYPE_ALL		0x7
-
-#define RES_STATE_WRST		0xF
-#define RES_STATE_ACTIVE	0xE
-#define RES_STATE_SLEEP		0x8
-#define RES_STATE_OFF		0x0
-
-/*
-*	Power Bus Message Format
-*
-*	Broadcast Message (16 Bits)
-*	DEV_GRP[15:13] MT[12]  RES_GRP[11:9]  RES_TYPE2[8:7] RES_TYPE[6:4]
-*	RES_STATE[3:0]
-*
-*	Singular Message (16 Bits)
-*	DEV_GRP[15:13] MT[12]  RES_ID[11:4]  RES_STATE[3:0]
-*
-*/
-
-#define MSG_BROADCAST(devgrp, grp, type, type2, state) \
-	(devgrp << 13 | 1 << 12 | grp << 9 | type2 << 7 | type << 4 | state)
-
-#define MSG_SINGULAR(devgrp, id, state) \
-	(devgrp << 13 | 0 << 12 | id << 4 | state)
-
-#define R_PROTECT_KEY		0x0E
-#define KEY_1			0xC0
-#define KEY_2			0x0C
-
-struct triton_ins {
-	u16 pmb_message;
-	u8 delay;
-};
-
-
-#define CONFIG_DISABLE_HFCLK	1
-
-#if defined(CONFIG_MACH_OMAP_3430SDP) || defined(CONFIG_MACH_OMAP_3430LABRADOR)
-
-struct triton_ins sleep_on_seq[] __initdata = {
-	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
-#ifdef CONFIG_DISABLE_HFCLK
-	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3},
-#endif /* #ifdef CONFIG_DISABLE_HFCLK */
-};
-
-struct triton_ins sleep_off_seq[] __initdata = {
-#ifndef CONFIG_DISABLE_HFCLK
-	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
-#else
-	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
-	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
-	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
-#endif /* #ifndef CONFIG_DISABLE_HFCLK */
-};
-
-struct triton_ins t2_wrst_seq[] __initdata = {
-	{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},
-};
-#else
-struct triton_ins sleep_on_seq[] __initdata = {
-	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0,
-			RES_STATE_SLEEP), 4},
-	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, RES_TYPE2_R0,
-			RES_STATE_SLEEP), 4},
-};
-
-struct triton_ins sleep_off_seq[] __initdata = {
-	{MSG_SINGULAR(DEV_GRP_NULL, 0x17, RES_STATE_ACTIVE), 0x30},
-	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP_PR, RES_TYPE_ALL, RES_TYPE2_R0,
-			RES_STATE_ACTIVE), 0x37},
-	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, RES_TYPE2_R0,
-			RES_STATE_ACTIVE), 0x2},
-};
-
-struct triton_ins t2_wrst_seq[] __initdata = { };
-
-#endif
-
-static int __init twl4030_write_script_byte(u8 address, u8 byte)
-{
-	int err;
-
-	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
-					R_MEMORY_ADDRESS);
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte,
-					R_MEMORY_DATA);
-
-	return err;
-}
-
-static int __init twl4030_write_script_ins(u8 address, u16 pmb_message,
-						u8 delay, u8 next)
-{
-	int err = 0;
-
-	address *= 4;
-	err |= twl4030_write_script_byte(address++, pmb_message >> 8);
-	err |= twl4030_write_script_byte(address++, pmb_message & 0xff);
-	err |= twl4030_write_script_byte(address++, delay);
-	err |= twl4030_write_script_byte(address++, next);
-
-	return err;
-}
-
-static int __init twl4030_write_script(u8 address, struct triton_ins *script,
-					int len)
-{
-	int err = 0;
-
-	for (; len; len--, address++, script++) {
-		if (len == 1)
-			err |= twl4030_write_script_ins(address,
-							script->pmb_message,
-							script->delay,
-							END_OF_SCRIPT);
-		else
-			err |= twl4030_write_script_ins(address,
-							script->pmb_message,
-							script->delay,
-							address + 1);
-	}
-
-	return err;
-}
-
-static int __init config_sleep_wake_sequence(void)
-{
-	int err = 0;
-
-	/*
-	 * CLKREQ is pulled high on the 2430SDP, therefore, we need to take
-	 * it out of the HFCLKOUT DEV_GRP for P1 else HFCLKOUT can't be stopped.
-	 */
-
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
-				  0x20, R_HFCLKOUT_DEV_GRP);
-
-	/* Set ACTIVE to SLEEP SEQ address in T2 memory*/
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x2B,
-				  R_SEQ_ADD_A2S);
-
-	/* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x2F,
-				  R_SEQ_ADD_SA12);
-
-	/* Set SLEEP to ACTIVE SEQ address for P3 */
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x2F,
-				  R_SEQ_ADD_S2A3);
-
-	/* Install Active->Sleep (A2S) sequence */
-	err |= twl4030_write_script(0x2B, sleep_on_seq,
-					ARRAY_SIZE(sleep_on_seq));
-
-	/* Install Sleep->Active (S2A) sequence */
-	err |= twl4030_write_script(0x2F, sleep_off_seq,
-					ARRAY_SIZE(sleep_off_seq));
-
-	if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
-		u8 data;
-		/* Disabling AC charger effect on sleep-active transitions */
-		err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
-						R_CFG_P1_TRANSITION);
-		data &= ~(1<<1);
-		err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data ,
-						R_CFG_P1_TRANSITION);
-	}
-
-	/* P1/P2/P3 LVL_WAKEUP should be on LEVEL */
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, LVL_WAKEUP,
-					R_P1_SW_EVENTS);
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, LVL_WAKEUP,
-					R_P2_SW_EVENTS);
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, LVL_WAKEUP,
-				R_P3_SW_EVENTS);
-
-	if (err)
-		printk(KERN_ERR "TWL4030 sleep-wake sequence config error\n");
-
-	return err;
-}
-
-
-/* Programming the WARMRESET Sequence on TRITON */
-static int __init config_warmreset_sequence(void)
-{
-
-	int e = 0;
-	u8 rd_data;
-
-	if (!ARRAY_SIZE(t2_wrst_seq))
-		return 0;
-
-	/* Set WARM RESET SEQ address for P1 */
-	e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x38,
-				R_SEQ_ADD_WARM);
-
-	/* Install Warm Reset sequence */
-	e |= twl4030_write_script(0x38, t2_wrst_seq,
-					ARRAY_SIZE(t2_wrst_seq));
-
-	/* P1/P2/P3 enable WARMRESET */
-	e |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
-				R_P1_SW_EVENTS);
-	rd_data |= ENABLE_WARMRESET;
-	e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
-				R_P1_SW_EVENTS);
-
-	e |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
-				R_P2_SW_EVENTS);
-	rd_data |= ENABLE_WARMRESET;
-	e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
-				R_P2_SW_EVENTS);
-
-	e |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
-				R_P3_SW_EVENTS);
-	rd_data |= ENABLE_WARMRESET;
-	e |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
-				R_P3_SW_EVENTS);
-
-	if (e)
-		printk(KERN_ERR
-			"TWL4030 Power Companion Warmreset seq config error\n");
-	return e;
-}
-
-static int __init twl4030_power_init(void)
-{
-	int err = 0;
-
-	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_1,
-				R_PROTECT_KEY);
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_2,
-				R_PROTECT_KEY);
-
-	if (err)
-		return err;
-
-	err = config_sleep_wake_sequence();
-	if (err)
-		return err;
-
-	err = config_warmreset_sequence();
-	if (err)
-		return err;
-
-	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
-
-	return err;
-
-}
-
-module_init(twl4030_power_init);
-- 
1.5.6.3


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

* [PATCH 2/7] Add defines and data types for twl4030.
  2008-10-10 16:56 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
@ 2008-10-10 16:56   ` Peter 'p2' De Schrijver
  2008-10-10 16:56     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
  2008-10-11 18:46     ` [PATCH 2/7] Add defines and data types for twl4030 Felipe Balbi
  2008-10-11 18:45   ` [PATCH 1/7] Remove existing twl4030 power script code Felipe Balbi
  1 sibling, 2 replies; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch adds a bunch of data types and defines to handle the twl4030 power sequence scripts.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 include/linux/i2c/twl4030.h |   64 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index cdb4531..7dc4ee1 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -264,6 +264,69 @@ struct twl4030_usb_data {
 	enum twl4030_usb_mode	usb_mode;
 };
 
+struct twl4030_ins {
+	u16 pmb_message;
+	u8 delay;
+};
+
+struct twl4030_script {
+	struct twl4030_ins *script;
+	unsigned size;
+	u8 flags;
+};
+#define TRITON_WRST_SCRIPT	(1<<0)
+#define TRITON_WAKEUP12_SCRIPT	(1<<1)
+#define TRITON_WAKEUP3_SCRIPT	(1<<2)
+#define TRITON_SLEEP_SCRIPT	(1<<3)
+
+struct twl4030_power_data {
+	struct twl4030_script **scripts;
+	unsigned size;
+};
+
+/* Power bus message definitions */
+
+#define DEV_GRP_NULL		0x0
+#define DEV_GRP_P1		0x1
+#define DEV_GRP_P2		0x2
+#define DEV_GRP_P3		0x4
+
+#define RES_GRP_RES		0x0
+#define RES_GRP_PP		0x1
+#define RES_GRP_RC		0x2
+#define RES_GRP_PP_RC		0x3
+#define RES_GRP_PR		0x4
+#define RES_GRP_PP_PR		0x5
+#define RES_GRP_RC_PR		0x6
+#define RES_GRP_ALL		0x7
+
+#define RES_TYPE2_R0		0x0
+
+#define RES_TYPE_ALL		0x7
+
+#define RES_STATE_WRST		0xF
+#define RES_STATE_ACTIVE	0xE
+#define RES_STATE_SLEEP		0x8
+#define RES_STATE_OFF		0x0
+
+/*
+*	Power Bus Message Format
+*
+*	Broadcast Message (16 Bits)
+*	DEV_GRP[15:13] MT[12]  RES_GRP[11:9]  RES_TYPE2[8:7] RES_TYPE[6:4]
+*	RES_STATE[3:0]
+*
+*	Singular Message (16 Bits)
+*	DEV_GRP[15:13] MT[12]  RES_ID[11:4]  RES_STATE[3:0]
+*
+*/
+
+#define MSG_BROADCAST(devgrp, grp, type, type2, state) \
+	(devgrp << 13 | 1 << 12 | grp << 9 | type2 << 7 | type << 4 | state)
+
+#define MSG_SINGULAR(devgrp, id, state) \
+	(devgrp << 13 | 0 << 12 | id << 4 | state)
+
 struct twl4030_platform_data {
 	unsigned				irq_base, irq_end;
 	struct twl4030_bci_platform_data	*bci;
@@ -271,6 +334,7 @@ struct twl4030_platform_data {
 	struct twl4030_madc_platform_data	*madc;
 	struct twl4030_keypad_data		*keypad;
 	struct twl4030_usb_data			*usb;
+	struct twl4030_power_data		*power;
 
 	/* REVISIT more to come ... _nothing_ should be hard-wired */
 };
-- 
1.5.6.3


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

* [PATCH 3/7] Twl4030 power code updated for new twl4030 core
  2008-10-10 16:56   ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
@ 2008-10-10 16:56     ` Peter 'p2' De Schrijver
  2008-10-10 16:56       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
  2008-10-11 18:49       ` [PATCH 3/7] Twl4030 power code updated for new " Felipe Balbi
  2008-10-11 18:46     ` [PATCH 2/7] Add defines and data types for twl4030 Felipe Balbi
  1 sibling, 2 replies; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch adds the twl4030 power handling. It downloads the scripts provided
by the board configuration to the twl4030 and configures the chip to call
the relevant script for each event (processor group 1 and 2 sleep,
processor group 3 sleep, wakeup or warm reset).

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/mfd/twl4030-power.c |  270 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 270 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/twl4030-power.c

diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c
new file mode 100644
index 0000000..bdeac36
--- /dev/null
+++ b/drivers/mfd/twl4030-power.c
@@ -0,0 +1,270 @@
+/*
+ * linux/drivers/i2c/chips/twl4030-power.c
+ *
+ * Handle TWL4030 Power initialization
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Copyright (C) 2006 Texas Instruments, Inc
+ *
+ * Written by 	Kalle Jokiniemi
+ *		Peter De Schrijver <peter.de-schrijver@nokia.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/module.h>
+#include <linux/pm.h>
+#include <linux/i2c/twl4030.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach-types.h>
+
+static u8 triton_next_free_address = 0x2b;
+
+#define PWR_P1_SW_EVENTS	0x10
+#define PWR_DEVOFF	(1<<0)
+
+#define PHY_TO_OFF_PM_MASTER(p)		(p - 0x36)
+#define PHY_TO_OFF_PM_RECEIVER(p)	(p - 0x5b)
+
+/* resource - hfclk */
+#define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECEIVER(0xe6)
+
+/* PM events */
+#define R_P1_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x46)
+#define R_P2_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x47)
+#define R_P3_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x48)
+#define R_CFG_P1_TRANSITION	PHY_TO_OFF_PM_MASTER(0x36)
+#define R_CFG_P2_TRANSITION	PHY_TO_OFF_PM_MASTER(0x37)
+#define R_CFG_P3_TRANSITION	PHY_TO_OFF_PM_MASTER(0x38)
+
+#define LVL_WAKEUP	0x08
+
+#define ENABLE_WARMRESET (1<<4)
+
+#define END_OF_SCRIPT		0x3f
+
+#define R_SEQ_ADD_A2S		PHY_TO_OFF_PM_MASTER(0x55)
+#define R_SEQ_ADD_SA12		PHY_TO_OFF_PM_MASTER(0x56)
+#define	R_SEQ_ADD_S2A3		PHY_TO_OFF_PM_MASTER(0x57)
+#define	R_SEQ_ADD_WARM		PHY_TO_OFF_PM_MASTER(0x58)
+#define R_MEMORY_ADDRESS	PHY_TO_OFF_PM_MASTER(0x59)
+#define R_MEMORY_DATA		PHY_TO_OFF_PM_MASTER(0x5a)
+
+#define R_PROTECT_KEY		0x0E
+#define KEY_1			0xC0
+#define KEY_2			0x0C
+
+static int __init twl4030_write_script_byte(u8 address, u8 byte)
+{
+	int err;
+
+	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
+					R_MEMORY_ADDRESS);
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte,
+					R_MEMORY_DATA);
+
+	return err;
+}
+
+static int __init twl4030_write_script_ins(u8 address, u16 pmb_message,
+						u8 delay, u8 next)
+{
+	int err = 0;
+
+	address *= 4;
+	err |= twl4030_write_script_byte(address++, pmb_message >> 8);
+	err |= twl4030_write_script_byte(address++, pmb_message & 0xff);
+	err |= twl4030_write_script_byte(address++, delay);
+	err |= twl4030_write_script_byte(address++, next);
+
+	return err;
+}
+
+static int __init twl4030_write_script(u8 address, struct twl4030_ins *script,
+					int len)
+{
+	int err = 0;
+
+	for (; len; len--, address++, script++) {
+		if (len == 1)
+			err |= twl4030_write_script_ins(address,
+							script->pmb_message,
+							script->delay,
+							END_OF_SCRIPT);
+		else
+			err |= twl4030_write_script_ins(address,
+							script->pmb_message,
+							script->delay,
+							address + 1);
+	}
+
+	return err;
+}
+
+static int __init config_wakeup3_sequence(u8 address)
+{
+
+	int err = 0;
+
+	/* Set SLEEP to ACTIVE SEQ address for P3 */
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
+				  R_SEQ_ADD_S2A3);
+
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, LVL_WAKEUP,
+					R_P3_SW_EVENTS);
+	if (err)
+		printk(KERN_ERR "TWL4030 wakeup sequence for P3" \
+				"config error\n");
+
+	return err;
+}
+
+static int __init config_wakeup12_sequence(u8 address)
+{
+	int err = 0;
+
+	/* Set SLEEP to ACTIVE SEQ address for P1 and P2 */
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
+				  R_SEQ_ADD_SA12);
+
+	/* P1/P2/P3 LVL_WAKEUP should be on LEVEL */
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, LVL_WAKEUP,
+					R_P1_SW_EVENTS);
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, LVL_WAKEUP,
+					R_P2_SW_EVENTS);
+
+	if (machine_is_omap_3430sdp() || machine_is_omap_ldp()) {
+		u8 data;
+		/* Disabling AC charger effect on sleep-active transitions */
+		err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &data,
+						R_CFG_P1_TRANSITION);
+		data &= ~(1<<1);
+		err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, data ,
+						R_CFG_P1_TRANSITION);
+	}
+
+	if (err)
+		printk(KERN_ERR "TWL4030 wakeup sequence for P1 and P2" \
+				"config error\n");
+
+	return err;
+}
+
+static int __init config_sleep_sequence(u8 address)
+{
+	int err = 0;
+
+	/*
+	 * CLKREQ is pulled high on the 2430SDP, therefore, we need to take
+	 * it out of the HFCLKOUT DEV_GRP for P1 else HFCLKOUT can't be stopped.
+	 */
+
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
+				  0x20, R_HFCLKOUT_DEV_GRP);
+
+	/* Set ACTIVE to SLEEP SEQ address in T2 memory*/
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
+				  R_SEQ_ADD_A2S);
+
+	if (err)
+		printk(KERN_ERR "TWL4030 sleep sequence config error\n");
+
+	return err;
+}
+
+static int __init config_warmreset_sequence(u8 address)
+{
+
+	int err = 0;
+	u8 rd_data;
+
+	/* Set WARM RESET SEQ address for P1 */
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
+					R_SEQ_ADD_WARM);
+
+	/* P1/P2/P3 enable WARMRESET */
+	err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
+					R_P1_SW_EVENTS);
+	rd_data |= ENABLE_WARMRESET;
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
+					R_P1_SW_EVENTS);
+
+	err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
+					R_P2_SW_EVENTS);
+	rd_data |= ENABLE_WARMRESET;
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
+					R_P2_SW_EVENTS);
+
+	err |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
+					R_P3_SW_EVENTS);
+	rd_data |= ENABLE_WARMRESET;
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
+					R_P3_SW_EVENTS);
+
+	if (err)
+		printk(KERN_ERR
+			"TWL4030 Power Companion Warmreset seq config error\n");
+	return err;
+}
+
+static int __init load_triton_script(struct twl4030_script *tscript)
+{
+	u8 address = triton_next_free_address;
+	int err;
+
+	err = twl4030_write_script(address, tscript->script, tscript->size);
+	if (err)
+		return err;
+
+	triton_next_free_address += tscript->size;
+
+	if (tscript->flags & TRITON_WRST_SCRIPT)
+		err |= config_warmreset_sequence(address);
+
+	if (tscript->flags & TRITON_WAKEUP12_SCRIPT)
+		err |= config_wakeup12_sequence(address);
+
+	if (tscript->flags & TRITON_WAKEUP3_SCRIPT)
+		err |= config_wakeup3_sequence(address);
+
+	if (tscript->flags & TRITON_SLEEP_SCRIPT)
+		err |= config_sleep_sequence(address);
+
+	return err;
+}
+
+void __init twl4030_power_init(struct twl4030_power_data *triton2_scripts)
+{
+	int err = 0;
+	int i;
+
+	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_1,
+				R_PROTECT_KEY);
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, KEY_2,
+				R_PROTECT_KEY);
+	if (err)
+		return err;
+
+	for (i = 0; i < triton2_scripts->size; i++) {
+		err = load_triton_script(triton2_scripts->scripts[i]);
+		if (err)
+			return err;
+	}
+
+	err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY);
+
+	return err;
+
+}
-- 
1.5.6.3


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

* [PATCH 4/7] Hook twl4030 power code into twl4030 core.
  2008-10-10 16:56     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
@ 2008-10-10 16:56       ` Peter 'p2' De Schrijver
  2008-10-10 16:56         ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
                           ` (2 more replies)
  2008-10-11 18:49       ` [PATCH 3/7] Twl4030 power code updated for new " Felipe Balbi
  1 sibling, 3 replies; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch makes twl4030 core call the power code in case the scripts are present in the platform data.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/mfd/twl4030-core.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index fd9a016..7a5c9d0 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -81,6 +81,12 @@
 #define twl_has_madc()	false
 #endif
 
+#ifdef CONFIG_TWL4030_POWER
+#define twl_has_power()        true
+#else
+#define twl_has_power()        false
+#endif
+
 #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
 #define twl_has_rtc()	true
 #else
@@ -106,6 +112,8 @@ static inline void activate_irq(int irq)
 #endif
 }
 
+extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
+
 /* Primary Interrupt Handler on TWL4030 Registers */
 
 /* Register Definitions */
@@ -794,6 +802,9 @@ static int add_children(struct twl4030_platform_data *pdata)
 		}
 	}
 
+	if (twl_has_power() && pdata->power)
+		twl4030_power_init(pdata->power);
+
 	if (twl_has_rtc()) {
 		twl = &twl4030_modules[3];
 
-- 
1.5.6.3


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

* [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts.
  2008-10-10 16:56       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
@ 2008-10-10 16:56         ` Peter 'p2' De Schrijver
  2008-10-10 16:56           ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
  2008-10-10 17:53           ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts David Brownell
  2008-10-10 17:57         ` [PATCH 4/7] Hook twl4030 power code into twl4030 core David Brownell
  2008-10-11 18:50         ` Felipe Balbi
  2 siblings, 2 replies; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

The TI 3430dsp and ldp boards have a custom power script.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 arch/arm/mach-omap2/board-3430sdp.c |   61 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-omap2/board-ldp.c     |   62 +++++++++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 56f28ae..93347d2 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -47,6 +47,8 @@
 
 #include "sdram-qimonda-hyb18m512160af-6.h"
 
+#define CONFIG_DISABLE_HFCLK 1
+
 #define	SDP3430_SMC91X_CS	3
 
 #define ENABLE_VAUX3_DEDICATED	0x03
@@ -329,6 +331,64 @@ static struct twl4030_madc_platform_data sdp3430_madc_data = {
 	.irq_line	= 1,
 };
 
+static struct twl4030_ins __initdata sleep_on_seq[] = {
+	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
+#ifdef CONFIG_DISABLE_HFCLK
+	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3},
+#endif
+};
+
+static struct twl4030_script sleep_on_script __initdata = {
+	.script	= sleep_on_seq,
+	.size	= ARRAY_SIZE(sleep_on_seq),
+	.flags	= TRITON_SLEEP_SCRIPT,
+};
+
+static struct twl4030_ins wakeup_seq[] __initdata = {
+#ifndef CONFIG_DISABLE_HFCLK
+	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
+#else
+	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
+	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
+#endif /* #ifndef CONFIG_DISABLE_HFCLK */
+};
+
+static struct twl4030_script wakeup_script __initdata = {
+	.script	= wakeup_seq,
+	.size	= ARRAY_SIZE(wakeup_seq),
+	.flags	= TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT,
+};
+
+static struct twl4030_ins wrst_seq[] __initdata = {
+	{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(wakeup_seq),
+	.flags  = TRITON_WRST_SCRIPT,
+};
+
+static struct twl4030_script *twl4030_scripts[] __initdata = {
+	&sleep_on_script,
+	&wakeup_script,
+	&wrst_script,
+};
+
+static struct twl4030_power_data sdp3430_t2scripts_data __initdata = {
+	.scripts	= twl4030_scripts,
+	.size		= ARRAY_SIZE(twl4030_scripts),
+};
+
 static struct twl4030_platform_data sdp3430_twldata = {
 	.irq_base	= TWL4030_IRQ_BASE,
 	.irq_end	= TWL4030_IRQ_END,
@@ -338,6 +398,7 @@ 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,
 };
 
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 92710c3..498a786 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -41,6 +41,8 @@
 #include <asm/delay.h>
 #include <mach/control.h>
 
+#define CONFIG_DISABLE_HFCLK 1
+
 #define ENABLE_VAUX1_DEDICATED	0x03
 #define ENABLE_VAUX1_DEV_GRP	0x20
 
@@ -195,6 +197,65 @@ static int ldp_batt_table[] = {
 4040,   3910,   3790,   3670,   3550
 };
 
+static struct twl4030_ins __initdata sleep_on_seq[] = {
+	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
+#ifdef CONFIG_DISABLE_HFCLK
+	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3},
+#endif
+};
+
+static struct twl4030_script sleep_on_script __initdata = {
+	.script	= sleep_on_seq,
+	.size	= ARRAY_SIZE(sleep_on_seq),
+	.flags	= TRITON_SLEEP_SCRIPT,
+};
+
+static struct twl4030_ins wakeup_seq[] __initdata = {
+#ifndef CONFIG_DISABLE_HFCLK
+	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
+#else
+	{MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30},
+	{MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37},
+	{MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3},
+#endif /* #ifndef CONFIG_DISABLE_HFCLK */
+};
+
+static struct twl4030_script wakeup_script __initdata = {
+	.script	= wakeup_seq,
+	.size	= ARRAY_SIZE(wakeup_seq),
+	.flags	= TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT,
+};
+
+static struct twl4030_ins wrst_seq[] __initdata = {
+	{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(wakeup_seq),
+	.flags  = TRITON_WRST_SCRIPT,
+};
+
+static struct twl4030_script *twl4030_scripts[] __initdata = {
+	&sleep_on_script,
+	&wakeup_script,
+	&wrst_script,
+};
+
+static struct twl4030_power_data sdp3430_t2scripts_data __initdata = {
+	.scripts	= twl4030_scripts,
+	.size		= ARRAY_SIZE(twl4030_scripts),
+};
+
 static struct twl4030_bci_platform_data ldp_bci_data = {
 	.battery_tmp_tbl	= ldp_batt_table,
 	.tblsize		= ARRAY_SIZE(ldp_batt_table),
@@ -222,6 +283,7 @@ static struct twl4030_platform_data ldp_twldata = {
 	.bci		= &ldp_bci_data,
 	.madc		= &ldp_madc_data,
 	.usb		= &ldp_usb_data,
+	.power		= &sdp3430_t2scripts_data,
 	.gpio		= &ldp_gpio_data,
 };
 
-- 
1.5.6.3


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

* [PATCH 6/7] Generic twl4030 power script for 3430 based boards.
  2008-10-10 16:56         ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
@ 2008-10-10 16:56           ` Peter 'p2' De Schrijver
  2008-10-10 16:56             ` [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script Peter 'p2' De Schrijver
  2008-10-10 17:53           ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts David Brownell
  1 sibling, 1 reply; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This is a generic twl4030 power script for 3430 based boards. It handles
sleep and wakeup events. In case of a sleep event it will first put the
Reset and Control (RC) resources to sleep and then put the voltage regulators
to sleep. In case of a wakeup event, the system clock will be started first,
then the voltage regulators will be woken up and finally the RC resources will
be woken up.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 arch/arm/mach-omap2/twl4030-generic-scripts.c |   78 +++++++++++++++++++++++++
 1 files changed, 78 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.c

diff --git a/arch/arm/mach-omap2/twl4030-generic-scripts.c b/arch/arm/mach-omap2/twl4030-generic-scripts.c
new file mode 100644
index 0000000..f41c9ef
--- /dev/null
+++ b/arch/arm/mach-omap2/twl4030-generic-scripts.c
@@ -0,0 +1,78 @@
+/*
+ * arch/arm/mach-omap2/twl4030-generic-scripts.c
+ *
+ * Generic power control scripts for TWL4030
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ * Copyright (C) 2006 Texas Instruments, Inc
+ *
+ * Written by 	Kalle Jokiniemi
+ *		Peter De Schrijver <peter.de-schrijver@nokia.com>
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of this
+ * archive for more details.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/init.h>
+#include <linux/i2c/twl4030.h>
+
+/*
+ * This script instructs twl4030 to first put the Reset and Control (RC)
+ * resources to sleep and then all the other resources.
+ */
+
+static struct twl4030_ins sleep_on_seq[] __initdata = {
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0,
+			RES_STATE_SLEEP), 4},
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, RES_TYPE2_R0,
+			RES_STATE_SLEEP), 4},
+};
+
+static struct twl4030_script sleep_on_script __initdata = {
+	.script = sleep_on_seq,
+	.size   = ARRAY_SIZE(sleep_on_seq),
+	.flags  = TRITON_SLEEP_SCRIPT,
+};
+
+/*
+ * This script instructs twl4030 to first enable CLKEN, then wakeup the
+ * regulators and then all other resources.
+ */
+
+static struct twl4030_ins wakeup_seq[] __initdata = {
+	{MSG_SINGULAR(DEV_GRP_NULL, 0x17, RES_STATE_ACTIVE), 0x30},
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP_PR, RES_TYPE_ALL, RES_TYPE2_R0,
+			RES_STATE_ACTIVE), 0x37},
+	{MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, RES_TYPE2_R0,
+			RES_STATE_ACTIVE), 0x2},
+};
+
+static struct twl4030_script wakeup_script __initdata = {
+	.script = wakeup_seq,
+	.size   = ARRAY_SIZE(wakeup_seq),
+	.flags  = TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT,
+};
+
+static struct twl4030_script *twl4030_scripts[] __initdata = {
+	&sleep_on_script,
+	&wakeup_script,
+};
+
+struct twl4030_power_data generic3430_t2scripts_data __initdata = {
+	.scripts        = twl4030_scripts,
+	.size           = ARRAY_SIZE(twl4030_scripts),
+};
+
+
-- 
1.5.6.3


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

* [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
  2008-10-10 16:56           ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
@ 2008-10-10 16:56             ` Peter 'p2' De Schrijver
  2008-10-10 17:50               ` David Brownell
  0 siblings, 1 reply; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-10 16:56 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

Make omap3 evm, beagle and overo use the generic twl4030 script.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 arch/arm/mach-omap2/Makefile            |    9 ++++++---
 arch/arm/mach-omap2/board-omap3beagle.c |    3 +++
 arch/arm/mach-omap2/board-omap3evm.c    |    3 +++
 arch/arm/mach-omap2/board-overo.c       |    3 +++
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 33de217..ed0cd7a 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -58,10 +58,12 @@ obj-$(CONFIG_MACH_OMAP_3430SDP)		+= board-3430sdp.o \
 obj-$(CONFIG_MACH_OMAP3EVM)		+= board-omap3evm.o \
 					   hsmmc.o \
 					   usb-musb.o usb-ehci.o \
-					   board-omap3evm-flash.o
+					   board-omap3evm-flash.o \
+					   twl4030-generic-scripts.o
 obj-$(CONFIG_MACH_OMAP3_BEAGLE)		+= board-omap3beagle.o \
 					   usb-musb.o usb-ehci.o \
-					   hsmmc.o
+					   hsmmc.o \
+					   twl4030-generic-scripts.o
 obj-$(CONFIG_MACH_OMAP_LDP)		+= board-ldp.o \
 					   hsmmc.o \
 					   usb-musb.o
@@ -77,7 +79,8 @@ obj-$(CONFIG_MACH_NOKIA_N810)		+= board-n810.o
 obj-$(CONFIG_MACH_OVERO)		+= board-overo.o \
 					   hsmmc.o \
 					   usb-musb.o \
-					   usb-ehci.o
+					   usb-ehci.o \
+					   twl4030-generic-scripts.o
 
 # TUSB 6010 chips
 obj-$(CONFIG_MACH_OMAP2_TUSB6010)	+= usb-tusb6010.o
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 19702c7..1579a5e 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -51,6 +51,8 @@
 
 #define NAND_BLOCK_SIZE		SZ_128K
 
+extern struct twl4030_power_data generic3430_t2scripts_data;
+
 static struct mtd_partition omap3beagle_nand_partitions[] = {
 	/* All the partition sizes are listed in terms of NAND block size */
 	{
@@ -149,6 +151,7 @@ static struct twl4030_platform_data beagle_twldata = {
 	/* platform_data for children goes here */
 	.usb		= &beagle_usb_data,
 	.gpio		= &beagle_gpio_data,
+	.power		= &generic3430_t2scripts_data,
 };
 
 static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index 3538067..dd7d1b7 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -42,6 +42,8 @@
 
 #include "sdram-micron-mt46h32m32lf-6.h"
 
+extern struct twl4030_power_data generic3430_t2scripts_data;
+
 static struct resource omap3evm_smc911x_resources[] = {
 	[0] =	{
 		.start  = OMAP3EVM_ETHR_START,
@@ -139,6 +141,7 @@ static struct twl4030_platform_data omap3evm_twldata = {
 	.keypad		= &omap3evm_kp_data,
 	.madc		= &omap3evm_madc_data,
 	.usb		= &omap3evm_usb_data,
+	.power		= &generic3430_t2scripts_data,
 	.gpio		= &omap3evm_gpio_data,
 };
 
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 4e2781a..4d2203f 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -55,6 +55,8 @@
 #define GPMC_CS0_BASE  0x60
 #define GPMC_CS_SIZE   0x30
 
+extern struct twl4030_power_data generic3430_t2scripts_data;
+
 static struct mtd_partition overo_nand_partitions[] = {
 	{
 		.name           = "xloader",
@@ -160,6 +162,7 @@ static struct twl4030_platform_data overo_twldata = {
 	.irq_end	= TWL4030_IRQ_END,
 	.gpio		= &overo_gpio_data,
 	.usb		= &overo_usb_data,
+	.power		= &generic3430_t2scripts_data,
 };
 
 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
-- 
1.5.6.3


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

* Re: [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
  2008-10-10 16:56             ` [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script Peter 'p2' De Schrijver
@ 2008-10-10 17:50               ` David Brownell
  2008-10-13  8:23                 ` Peter 'p2' De Schrijver
  0 siblings, 1 reply; 22+ messages in thread
From: David Brownell @ 2008-10-10 17:50 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Friday 10 October 2008, Peter 'p2' De Schrijver wrote:
> +extern struct twl4030_power_data generic3430_t2scripts_data;

Such "extern" decls should as a rule be in header files...

In this case the rule is appropriate, since you've got the
same decl in three different places.  That's about two times
more often than I'm comfortable making exceptions to such a
rule ... :)

- Dave


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

* Re: [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts.
  2008-10-10 16:56         ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
  2008-10-10 16:56           ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
@ 2008-10-10 17:53           ` David Brownell
  2008-10-13  8:45             ` Peter 'p2' De Schrijver
  1 sibling, 1 reply; 22+ messages in thread
From: David Brownell @ 2008-10-10 17:53 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Friday 10 October 2008, Peter 'p2' De Schrijver wrote:
> The TI 3430dsp and ldp boards have a custom power script.

And for those of us less conversant in this tech ... could
you summarize, in words of one syllable or less, just what
these scripts do that's different from the "generic" one?
And why the generic script is inappropriate?

IMO the C files should have at least brief comments about
that, and the patch comment can have more detail.

- Dave


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

* Re: [PATCH 4/7] Hook twl4030 power code into twl4030 core.
  2008-10-10 16:56       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
  2008-10-10 16:56         ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
@ 2008-10-10 17:57         ` David Brownell
  2008-10-11 18:50         ` Felipe Balbi
  2 siblings, 0 replies; 22+ messages in thread
From: David Brownell @ 2008-10-10 17:57 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Friday 10 October 2008, Peter 'p2' De Schrijver wrote:
> +#ifdef CONFIG_TWL4030_POWER

Nothing in your patches seems to set that... or update
the Makefile so that this file gets linked.

Wouldn't it be simpler to just not have that #ifdef,
and always link it?  If there's no script to install,
no problem; I'll not worry about some __init code.

- Dave


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

* Re: [PATCH 1/7] Remove existing twl4030 power script code.
  2008-10-10 16:56 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
  2008-10-10 16:56   ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
@ 2008-10-11 18:45   ` Felipe Balbi
  1 sibling, 0 replies; 22+ messages in thread
From: Felipe Balbi @ 2008-10-11 18:45 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Fri, Oct 10, 2008 at 07:56:10PM +0300, Peter 'p2' De Schrijver wrote:
> First we remove the existing twl4030 power sequencer code.
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
> ---
>  drivers/i2c/chips/twl4030-power.c |  343 -------------------------------------

Missed Makefile changes. Will break tree compilation.

-- 
balbi

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

* Re: [PATCH 2/7] Add defines and data types for twl4030.
  2008-10-10 16:56   ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
  2008-10-10 16:56     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
@ 2008-10-11 18:46     ` Felipe Balbi
  1 sibling, 0 replies; 22+ messages in thread
From: Felipe Balbi @ 2008-10-11 18:46 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Fri, Oct 10, 2008 at 07:56:11PM +0300, Peter 'p2' De Schrijver wrote:
> This patch adds a bunch of data types and defines to handle the twl4030 power sequence scripts.
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>

Should Cc Sam Ortiz

> ---
>  include/linux/i2c/twl4030.h |   64 +++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 64 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
> index cdb4531..7dc4ee1 100644
> --- a/include/linux/i2c/twl4030.h
> +++ b/include/linux/i2c/twl4030.h
> @@ -264,6 +264,69 @@ struct twl4030_usb_data {
>  	enum twl4030_usb_mode	usb_mode;
>  };
>  
> +struct twl4030_ins {
> +	u16 pmb_message;
> +	u8 delay;
> +};
> +
> +struct twl4030_script {
> +	struct twl4030_ins *script;
> +	unsigned size;
> +	u8 flags;
> +};

add a blank like here

> +#define TRITON_WRST_SCRIPT	(1<<0)
> +#define TRITON_WAKEUP12_SCRIPT	(1<<1)
> +#define TRITON_WAKEUP3_SCRIPT	(1<<2)
> +#define TRITON_SLEEP_SCRIPT	(1<<3)
> +
> +struct twl4030_power_data {
> +	struct twl4030_script **scripts;
> +	unsigned size;
> +};
> +
> +/* Power bus message definitions */
> +
> +#define DEV_GRP_NULL		0x0
> +#define DEV_GRP_P1		0x1
> +#define DEV_GRP_P2		0x2
> +#define DEV_GRP_P3		0x4
> +
> +#define RES_GRP_RES		0x0
> +#define RES_GRP_PP		0x1
> +#define RES_GRP_RC		0x2
> +#define RES_GRP_PP_RC		0x3
> +#define RES_GRP_PR		0x4
> +#define RES_GRP_PP_PR		0x5
> +#define RES_GRP_RC_PR		0x6
> +#define RES_GRP_ALL		0x7
> +
> +#define RES_TYPE2_R0		0x0
> +
> +#define RES_TYPE_ALL		0x7
> +
> +#define RES_STATE_WRST		0xF
> +#define RES_STATE_ACTIVE	0xE
> +#define RES_STATE_SLEEP		0x8
> +#define RES_STATE_OFF		0x0
> +
> +/*
> +*	Power Bus Message Format
> +*
> +*	Broadcast Message (16 Bits)
> +*	DEV_GRP[15:13] MT[12]  RES_GRP[11:9]  RES_TYPE2[8:7] RES_TYPE[6:4]
> +*	RES_STATE[3:0]
> +*
> +*	Singular Message (16 Bits)
> +*	DEV_GRP[15:13] MT[12]  RES_ID[11:4]  RES_STATE[3:0]
> +*
> +*/

I'd fix this comment style. The * should be aligned with the first one.

> +
> +#define MSG_BROADCAST(devgrp, grp, type, type2, state) \
> +	(devgrp << 13 | 1 << 12 | grp << 9 | type2 << 7 | type << 4 | state)
> +
> +#define MSG_SINGULAR(devgrp, id, state) \
> +	(devgrp << 13 | 0 << 12 | id << 4 | state)
> +
>  struct twl4030_platform_data {
>  	unsigned				irq_base, irq_end;
>  	struct twl4030_bci_platform_data	*bci;
> @@ -271,6 +334,7 @@ struct twl4030_platform_data {
>  	struct twl4030_madc_platform_data	*madc;
>  	struct twl4030_keypad_data		*keypad;
>  	struct twl4030_usb_data			*usb;
> +	struct twl4030_power_data		*power;
>  
>  	/* REVISIT more to come ... _nothing_ should be hard-wired */
>  };

-- 
balbi

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

* Re: [PATCH 3/7] Twl4030 power code updated for new twl4030 core
  2008-10-10 16:56     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
  2008-10-10 16:56       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
@ 2008-10-11 18:49       ` Felipe Balbi
  1 sibling, 0 replies; 22+ messages in thread
From: Felipe Balbi @ 2008-10-11 18:49 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Fri, Oct 10, 2008 at 07:56:12PM +0300, Peter 'p2' De Schrijver wrote:
> This patch adds the twl4030 power handling. It downloads the scripts provided
> by the board configuration to the twl4030 and configures the chip to call
> the relevant script for each event (processor group 1 and 2 sleep,
> processor group 3 sleep, wakeup or warm reset).
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>

Looking now I'd say patches 1 - 3 could be one. And generate use the -C
flag from git format-patch so we can see what really changed in the
process.

-- 
balbi

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

* Re: [PATCH 4/7] Hook twl4030 power code into twl4030 core.
  2008-10-10 16:56       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
  2008-10-10 16:56         ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
  2008-10-10 17:57         ` [PATCH 4/7] Hook twl4030 power code into twl4030 core David Brownell
@ 2008-10-11 18:50         ` Felipe Balbi
  2008-10-20 22:27           ` Samuel Ortiz
  2 siblings, 1 reply; 22+ messages in thread
From: Felipe Balbi @ 2008-10-11 18:50 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap, sameo

On Fri, Oct 10, 2008 at 07:56:13PM +0300, Peter 'p2' De Schrijver wrote:
> This patch makes twl4030 core call the power code in case the scripts are present in the platform data.
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
> ---
>  drivers/mfd/twl4030-core.c |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
> index fd9a016..7a5c9d0 100644
> --- a/drivers/mfd/twl4030-core.c
> +++ b/drivers/mfd/twl4030-core.c
> @@ -81,6 +81,12 @@
>  #define twl_has_madc()	false
>  #endif
>  
> +#ifdef CONFIG_TWL4030_POWER
> +#define twl_has_power()        true
> +#else
> +#define twl_has_power()        false
> +#endif
> +
>  #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
>  #define twl_has_rtc()	true
>  #else
> @@ -106,6 +112,8 @@ static inline void activate_irq(int irq)
>  #endif
>  }
>  
> +extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);

normally we avoid extern prototypes in C files. Tony and Sam, any
comments ??

> +
>  /* Primary Interrupt Handler on TWL4030 Registers */
>  
>  /* Register Definitions */
> @@ -794,6 +802,9 @@ static int add_children(struct twl4030_platform_data *pdata)
>  		}
>  	}
>  
> +	if (twl_has_power() && pdata->power)
> +		twl4030_power_init(pdata->power);
> +
>  	if (twl_has_rtc()) {
>  		twl = &twl4030_modules[3];
>  
> -- 
> 1.5.6.3
> 
> --
> 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

-- 
balbi

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

* Re: [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
  2008-10-10 17:50               ` David Brownell
@ 2008-10-13  8:23                 ` Peter 'p2' De Schrijver
  2008-10-14 16:26                   ` David Brownell
  0 siblings, 1 reply; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-13  8:23 UTC (permalink / raw)
  To: ext David Brownell; +Cc: linux-omap

On Fri, Oct 10, 2008 at 10:50:29AM -0700, ext David Brownell wrote:
> On Friday 10 October 2008, Peter 'p2' De Schrijver wrote:
> > +extern struct twl4030_power_data generic3430_t2scripts_data;
> 
> Such "extern" decls should as a rule be in header files...
> 
> In this case the rule is appropriate, since you've got the
> same decl in three different places.  That's about two times
> more often than I'm comfortable making exceptions to such a
> rule ... :)

Please suggest an appropriate header file. I couldn't find one and
creating a header file for a single extern declaration ?

Cheers,

Peter.

-- 
goa is a state of mind

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

* Re: [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts.
  2008-10-10 17:53           ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts David Brownell
@ 2008-10-13  8:45             ` Peter 'p2' De Schrijver
  2008-10-14 16:28               ` David Brownell
  0 siblings, 1 reply; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-13  8:45 UTC (permalink / raw)
  To: ext David Brownell; +Cc: linux-omap

On Fri, Oct 10, 2008 at 10:53:22AM -0700, ext David Brownell wrote:
> On Friday 10 October 2008, Peter 'p2' De Schrijver wrote:
> > The TI 3430dsp and ldp boards have a custom power script.
> 
> And for those of us less conversant in this tech ... could
> you summarize, in words of one syllable or less, just what
> these scripts do that's different from the "generic" one?
> And why the generic script is inappropriate?
> 

These scripts are already in linux-omap, so this just maintaining
existing functionality. I don't have access to an LDP, and have no idea
why they don't use the generic script.

Cheers,

Peter.

-- 
goa is a state of mind

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

* [PATCH 4/7] Hook twl4030 power code into twl4030 core.
  2008-10-13 15:44     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
@ 2008-10-13 15:44       ` Peter 'p2' De Schrijver
  2008-10-14 17:42         ` David Brownell
  0 siblings, 1 reply; 22+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-13 15:44 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch makes twl4030 core call the power code in case the scripts are present in the platform data.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/mfd/Kconfig        |    7 +++++++
 drivers/mfd/Makefile       |    1 +
 drivers/mfd/twl4030-core.c |   11 +++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index e643f6b..f3a5f63 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -64,6 +64,13 @@ config TWL4030_CORE
 	  high speed USB OTG transceiver, an audio codec (on most
 	  versions) and many other features.
 
+config TWL4030_POWER
+	bool "Support power sequencing scripts on TWL4030/TPS659x0"
+	depends on TWL4030_CORE=y
+	help
+	  Say yes here if you want to use the power management features of
+	  the TWL4030/TPS659x0.
+
 config MFD_TMIO
 	bool
 	default n
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 5650e7b..08c5dfe 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_MFD_TC6387XB)	+= tc6387xb.o
 obj-$(CONFIG_MFD_TC6393XB)	+= tc6393xb.o
 
 obj-$(CONFIG_TWL4030_CORE)	+= twl4030-core.o
+obj-$(CONFIG_TWL4030_POWER)	+= twl4030-power.o
 
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
 
diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index fd9a016..7a5c9d0 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -81,6 +81,12 @@
 #define twl_has_madc()	false
 #endif
 
+#ifdef CONFIG_TWL4030_POWER
+#define twl_has_power()        true
+#else
+#define twl_has_power()        false
+#endif
+
 #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
 #define twl_has_rtc()	true
 #else
@@ -106,6 +112,8 @@ static inline void activate_irq(int irq)
 #endif
 }
 
+extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
+
 /* Primary Interrupt Handler on TWL4030 Registers */
 
 /* Register Definitions */
@@ -794,6 +802,9 @@ static int add_children(struct twl4030_platform_data *pdata)
 		}
 	}
 
+	if (twl_has_power() && pdata->power)
+		twl4030_power_init(pdata->power);
+
 	if (twl_has_rtc()) {
 		twl = &twl4030_modules[3];
 
-- 
1.5.6.3


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

* Re: [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
  2008-10-13  8:23                 ` Peter 'p2' De Schrijver
@ 2008-10-14 16:26                   ` David Brownell
  0 siblings, 0 replies; 22+ messages in thread
From: David Brownell @ 2008-10-14 16:26 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Monday 13 October 2008, Peter 'p2' De Schrijver wrote:
> > > +extern struct twl4030_power_data generic3430_t2scripts_data;
> > 
> > Such "extern" decls should as a rule be in header files...
> > 
> > In this case the rule is appropriate, since you've got the
> > same decl in three different places.  That's about two times
> > more often than I'm comfortable making exceptions to such a
> > rule ... :)
> 
> Please suggest an appropriate header file. I couldn't find one and
> creating a header file for a single extern declaration ?

Maybe arch/arm/mach-omap2/pm.h would be the most natural fit.

--
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] 22+ messages in thread

* Re: [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts.
  2008-10-13  8:45             ` Peter 'p2' De Schrijver
@ 2008-10-14 16:28               ` David Brownell
  0 siblings, 0 replies; 22+ messages in thread
From: David Brownell @ 2008-10-14 16:28 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Monday 13 October 2008, Peter 'p2' De Schrijver wrote:
> On Fri, Oct 10, 2008 at 10:53:22AM -0700, ext David Brownell wrote:
> > On Friday 10 October 2008, Peter 'p2' De Schrijver wrote:
> > > The TI 3430dsp and ldp boards have a custom power script.
> > 
> > And for those of us less conversant in this tech ... could
> > you summarize, in words of one syllable or less, just what
> > these scripts do that's different from the "generic" one?
> > And why the generic script is inappropriate?
> > 
> 
> These scripts are already in linux-omap, so this just maintaining
> existing functionality.

I realize that ...


> I don't have access to an LDP, and have no idea 
> why they don't use the generic script.

Hmm.  Maybe someone from TI can explain.  I suspect
part of it is that several of the other boards aren't
actually battery powered, but it's unclear whether
that's the whole story.

- Dave




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

* Re: [PATCH 4/7] Hook twl4030 power code into twl4030 core.
  2008-10-13 15:44       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
@ 2008-10-14 17:42         ` David Brownell
  0 siblings, 0 replies; 22+ messages in thread
From: David Brownell @ 2008-10-14 17:42 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Monday 13 October 2008, Peter 'p2' De Schrijver wrote:
> +config TWL4030_POWER
> +       bool "Support power sequencing scripts on TWL4030/TPS659x0"
> +       depends on TWL4030_CORE=y

Don't need "=y" for that, since the CORE is already boolean.


> +       help
> +         Say yes here if you want to use the power management features of
> +         the TWL4030/TPS659x0.

Saying "power management features" is misleading; there are lots
of PM features this doesn't cover.  Just say "power sequencing
scripts" here too ... and maybe add a sentence saying what such
a script *is* (controlling what type of action on what type of
event).


> +


--
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] 22+ messages in thread

* Re: [PATCH 4/7] Hook twl4030 power code into twl4030 core.
  2008-10-11 18:50         ` Felipe Balbi
@ 2008-10-20 22:27           ` Samuel Ortiz
  0 siblings, 0 replies; 22+ messages in thread
From: Samuel Ortiz @ 2008-10-20 22:27 UTC (permalink / raw)
  To: Felipe Balbi; +Cc: Peter 'p2' De Schrijver, linux-omap

On Sat, Oct 11, 2008 at 09:50:36PM +0300, Felipe Balbi wrote:
> On Fri, Oct 10, 2008 at 07:56:13PM +0300, Peter 'p2' De Schrijver wrote:
> > This patch makes twl4030 core call the power code in case the scripts are present in the platform data.
> > 
> > Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
> > ---
> >  drivers/mfd/twl4030-core.c |   11 +++++++++++
> >  1 files changed, 11 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
> > index fd9a016..7a5c9d0 100644
> > --- a/drivers/mfd/twl4030-core.c
> > +++ b/drivers/mfd/twl4030-core.c
> > @@ -81,6 +81,12 @@
> >  #define twl_has_madc()	false
> >  #endif
> >  
> > +#ifdef CONFIG_TWL4030_POWER
> > +#define twl_has_power()        true
> > +#else
> > +#define twl_has_power()        false
> > +#endif
> > +
> >  #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE)
> >  #define twl_has_rtc()	true
> >  #else
> > @@ -106,6 +112,8 @@ static inline void activate_irq(int irq)
> >  #endif
> >  }
> >  
> > +extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts);
> 
> normally we avoid extern prototypes in C files. Tony and Sam, any
> comments ??
checkpatch will bitch about it at least.
No big deal, but it's probably cleaner to have that in some header file.

Cheers,
Samuel.

> > +
> >  /* Primary Interrupt Handler on TWL4030 Registers */
> >  
> >  /* Register Definitions */
> > @@ -794,6 +802,9 @@ static int add_children(struct twl4030_platform_data *pdata)
> >  		}
> >  	}
> >  
> > +	if (twl_has_power() && pdata->power)
> > +		twl4030_power_init(pdata->power);
> > +
> >  	if (twl_has_rtc()) {
> >  		twl = &twl4030_modules[3];
> >  
> > -- 
> > 1.5.6.3
> > 
> > --
> > 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
> 
> -- 
> balbi

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2008-10-20 22:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-10 16:56 [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd Peter 'p2' De Schrijver
2008-10-10 16:56 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
2008-10-10 16:56   ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
2008-10-10 16:56     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
2008-10-10 16:56       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
2008-10-10 16:56         ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
2008-10-10 16:56           ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
2008-10-10 16:56             ` [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script Peter 'p2' De Schrijver
2008-10-10 17:50               ` David Brownell
2008-10-13  8:23                 ` Peter 'p2' De Schrijver
2008-10-14 16:26                   ` David Brownell
2008-10-10 17:53           ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts David Brownell
2008-10-13  8:45             ` Peter 'p2' De Schrijver
2008-10-14 16:28               ` David Brownell
2008-10-10 17:57         ` [PATCH 4/7] Hook twl4030 power code into twl4030 core David Brownell
2008-10-11 18:50         ` Felipe Balbi
2008-10-20 22:27           ` Samuel Ortiz
2008-10-11 18:49       ` [PATCH 3/7] Twl4030 power code updated for new " Felipe Balbi
2008-10-11 18:46     ` [PATCH 2/7] Add defines and data types for twl4030 Felipe Balbi
2008-10-11 18:45   ` [PATCH 1/7] Remove existing twl4030 power script code Felipe Balbi
  -- strict thread matches above, loose matches on Subject: below --
2008-10-13 15:44 [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
2008-10-13 15:44   ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
2008-10-13 15:44     ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
2008-10-13 15:44       ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
2008-10-14 17:42         ` David Brownell

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