All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Move twl4030 scripts to platform data
@ 2008-10-07 14:34 Peter 'p2' De Schrijver
  2008-10-07 14:34 ` [PATCH 1/3] Add twl4030 scripts to 3430sdp " Peter 'p2' De Schrijver
  2008-10-07 16:05 ` [PATCH 0/3] Move twl4030 scripts to platform data David Brownell
  0 siblings, 2 replies; 10+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-07 14:34 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver

This patch set move the twl4030 scripts to platform data and integrates the code to download the scripts with the new twl4030 codebase.

Peter 'p2' De Schrijver (3):
  Add twl4030 scripts to 3430sdp platform data
  Adapt twl4030 power code to new twl4030 code
  Add twl4030 power platform device

 arch/arm/mach-omap2/board-3430sdp.c |   61 ++++++++
 drivers/i2c/chips/twl4030-core.c    |   41 +++++
 drivers/i2c/chips/twl4030-power.c   |  290 ++++++++++++++---------------------
 include/linux/i2c/twl4030.h         |   64 ++++++++
 4 files changed, 283 insertions(+), 173 deletions(-)


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

* [PATCH 1/3] Add twl4030 scripts to 3430sdp platform data
  2008-10-07 14:34 [PATCH 0/3] Move twl4030 scripts to platform data Peter 'p2' De Schrijver
@ 2008-10-07 14:34 ` Peter 'p2' De Schrijver
  2008-10-07 14:34   ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code Peter 'p2' De Schrijver
  2008-10-07 16:05 ` [PATCH 0/3] Move twl4030 scripts to platform data David Brownell
  1 sibling, 1 reply; 10+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-07 14:34 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver


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

diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 4264b68..c03a35f 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -48,6 +48,8 @@
 
 #include "sdram-qimonda-hyb18m512160af-6.h"
 
+#define CONFIG_DISABLE_HFCLK 1
+
 #define	SDP3430_SMC91X_CS	3
 
 #define ENABLE_VAUX3_DEDICATED	0x03
@@ -330,6 +332,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,
@@ -339,6 +399,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,
 };
 
-- 
1.5.6.3


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

* [PATCH 2/3] Adapt twl4030 power code to new twl4030 code
  2008-10-07 14:34 ` [PATCH 1/3] Add twl4030 scripts to 3430sdp " Peter 'p2' De Schrijver
@ 2008-10-07 14:34   ` Peter 'p2' De Schrijver
  2008-10-07 14:34     ` [PATCH 3/3] Add twl4030 power platform device Peter 'p2' De Schrijver
  2008-10-07 16:19     ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code David Brownell
  0 siblings, 2 replies; 10+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-07 14:34 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver


Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
 drivers/i2c/chips/twl4030-power.c |  290 +++++++++++++++----------------------
 include/linux/i2c/twl4030.h       |   64 ++++++++
 2 files changed, 181 insertions(+), 173 deletions(-)

diff --git a/drivers/i2c/chips/twl4030-power.c b/drivers/i2c/chips/twl4030-power.c
index cb325b0..4a543a2 100644
--- a/drivers/i2c/chips/twl4030-power.c
+++ b/drivers/i2c/chips/twl4030-power.c
@@ -26,17 +26,20 @@
 #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_RECIEVER(p)	(p - 0x5b)
+#define PHY_TO_OFF_PM_RECEIVER(p)	(p - 0x5b)
 
 /* resource - hfclk */
-#define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECIEVER(0xe6)
+#define R_HFCLKOUT_DEV_GRP 	PHY_TO_OFF_PM_RECEIVER(0xe6)
 
 /* PM events */
 #define R_P1_SW_EVENTS		PHY_TO_OFF_PM_MASTER(0x46)
@@ -50,8 +53,6 @@
 
 #define ENABLE_WARMRESET (1<<4)
 
-/* sequence script */
-
 #define END_OF_SCRIPT		0x3f
 
 #define R_SEQ_ADD_A2S		PHY_TO_OFF_PM_MASTER(0x55)
@@ -61,112 +62,10 @@
 #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;
@@ -193,7 +92,7 @@ static int __init twl4030_write_script_ins(u8 address, u16 pmb_message,
 	return err;
 }
 
-static int __init twl4030_write_script(u8 address, struct triton_ins *script,
+static int __init twl4030_write_script(u8 address, struct twl4030_ins *script,
 					int len)
 {
 	int err = 0;
@@ -214,37 +113,37 @@ static int __init twl4030_write_script(u8 address, struct triton_ins *script,
 	return err;
 }
 
-static int __init config_sleep_wake_sequence(void)
+static int __init config_wakeup3_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.
-	 */
+	/* 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_RECEIVER,
-				  0x20, R_HFCLKOUT_DEV_GRP);
+	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");
 
-	/* Set ACTIVE to SLEEP SEQ address in T2 memory*/
-	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0x2B,
-				  R_SEQ_ADD_A2S);
+	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, 0x2F,
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
 				  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));
+	/* 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;
@@ -256,83 +155,115 @@ static int __init config_sleep_wake_sequence(void)
 						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");
+		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);
 
-/* Programming the WARMRESET Sequence on TRITON */
-static int __init config_warmreset_sequence(void)
+	if (err)
+		printk(KERN_ERR "TWL4030 sleep sequence config error\n");
+
+	return err;
+}
+
+static int __init config_warmreset_sequence(u8 address)
 {
 
-	int e = 0;
+	int err = 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));
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address,
+					R_SEQ_ADD_WARM);
 
 	/* P1/P2/P3 enable WARMRESET */
-	e |= twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &rd_data,
-				R_P1_SW_EVENTS);
+	err |= 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);
+	err |= 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);
+	err |= 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);
+	err |= 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);
+	err |= 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);
+	err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, rd_data,
+					R_P3_SW_EVENTS);
 
-	if (e)
+	if (err)
 		printk(KERN_ERR
 			"TWL4030 Power Companion Warmreset seq config error\n");
-	return e;
+	return err;
 }
 
-static int __init twl4030_power_init(void)
+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;
+}
+
+static int __init twl4030_power_probe(struct platform_device *pdev)
 {
+	struct twl4030_power_data *triton2_scripts =
+		(struct twl4030_power_data *)pdev->dev.platform_data;
 	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;
 
-	err = config_sleep_wake_sequence();
-	if (err)
-		return err;
-
-	err = config_warmreset_sequence();
-	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);
 
@@ -340,4 +271,17 @@ static int __init twl4030_power_init(void)
 
 }
 
+static struct platform_driver twl4030_power = {
+	.probe		= twl4030_power_probe,
+	.driver		= {
+		.name = "twl4030_power",
+		.owner = THIS_MODULE,
+	},
+};
+
+static int __init twl4030_power_init(void)
+{
+	return platform_driver_register(&twl4030_power);
+}
+
 module_init(twl4030_power_init);
diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h
index f5a1bfa..0ef5695 100644
--- a/include/linux/i2c/twl4030.h
+++ b/include/linux/i2c/twl4030.h
@@ -98,6 +98,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;
@@ -105,6 +168,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] 10+ messages in thread

* [PATCH 3/3] Add twl4030 power platform device
  2008-10-07 14:34   ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code Peter 'p2' De Schrijver
@ 2008-10-07 14:34     ` Peter 'p2' De Schrijver
  2008-10-07 16:19     ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code David Brownell
  1 sibling, 0 replies; 10+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-07 14:34 UTC (permalink / raw)
  To: linux-omap; +Cc: Peter 'p2' De Schrijver


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

diff --git a/drivers/i2c/chips/twl4030-core.c b/drivers/i2c/chips/twl4030-core.c
index 9debab4..42d9e4f 100644
--- a/drivers/i2c/chips/twl4030-core.c
+++ b/drivers/i2c/chips/twl4030-core.c
@@ -70,6 +70,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
@@ -838,6 +844,41 @@ static int add_children(struct twl4030_platform_data *pdata)
 		}
 	}
 
+	if (twl_has_power() && pdata->power) {
+		twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3];
+
+		pdev = platform_device_alloc("twl4030_power", -1);
+		if (!pdev) {
+			pr_debug("%s: can't alloc power dev\n", DRIVER_NAME);
+			status = -ENOMEM;
+			goto err;
+		}
+
+		if (status == 0) {
+			pdev->dev.parent = &twl->client->dev;
+			status = platform_device_add_data(pdev, pdata->power,
+					sizeof(*pdata->power));
+			if (status < 0) {
+				platform_device_put(pdev);
+				dev_dbg(&twl->client->dev,
+					"can't add power data, %d\n",
+					status);
+				goto err;
+			}
+		}
+
+		if (status == 0)
+			status = platform_device_add(pdev);
+
+		if (status < 0) {
+			platform_device_put(pdev);
+			dev_dbg(&twl->client->dev,
+					"can't create power dev, %d\n",
+					status);
+			goto err;
+		}
+	}
+
 	if (twl_has_rtc()) {
 		twl = &twl4030_modules[TWL4030_SLAVENUM_NUM3];
 
-- 
1.5.6.3


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

* Re: [PATCH 0/3] Move twl4030 scripts to platform data
  2008-10-07 14:34 [PATCH 0/3] Move twl4030 scripts to platform data Peter 'p2' De Schrijver
  2008-10-07 14:34 ` [PATCH 1/3] Add twl4030 scripts to 3430sdp " Peter 'p2' De Schrijver
@ 2008-10-07 16:05 ` David Brownell
  1 sibling, 0 replies; 10+ messages in thread
From: David Brownell @ 2008-10-07 16:05 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 07 October 2008, Peter 'p2' De Schrijver wrote:
> This patch set move the twl4030 scripts to platform data
> and integrates the code to download the scripts with the
> new twl4030 codebase.  
> 
> Peter 'p2' De Schrijver (3):
>   Add twl4030 scripts to 3430sdp platform data
>   Adapt twl4030 power code to new twl4030 code
>   Add twl4030 power platform device

Good. Those scripts were absolutely not in the
right kind of location before!

Your patch comments are all rather uniformly
empty though, worth fixing ... 

... and patch #1 (add scripts) breaks compiles,
it should include the header update from #2.

And I'll suggest a patch #4 to move this from
the drivers/i2c/chips directory to someplace
more appropriate.  Not that I have a sugggestion
on where; but drivers/i2c is clearly wrong!

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

* Re: [PATCH 2/3] Adapt twl4030 power code to new twl4030 code
  2008-10-07 14:34   ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code Peter 'p2' De Schrijver
  2008-10-07 14:34     ` [PATCH 3/3] Add twl4030 power platform device Peter 'p2' De Schrijver
@ 2008-10-07 16:19     ` David Brownell
  2008-10-08  6:49       ` Peter 'p2' De Schrijver
  1 sibling, 1 reply; 10+ messages in thread
From: David Brownell @ 2008-10-07 16:19 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 07 October 2008, Peter 'p2' De Schrijver wrote:
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
> ---
>  drivers/i2c/chips/twl4030-power.c |  290 +++++++++++++++----------------------
>  include/linux/i2c/twl4030.h       |   64 ++++++++
>  2 files changed, 181 insertions(+), 173 deletions(-)
> 
> diff --git a/drivers/i2c/chips/twl4030-power.c b/drivers/i2c/chips/twl4030-power.c
> index cb325b0..4a543a2 100644
> --- a/drivers/i2c/chips/twl4030-power.c
> +++ b/drivers/i2c/chips/twl4030-power.c

> -#if defined(CONFIG_MACH_OMAP_3430SDP) || defined(CONFIG_MACH_OMAP_3430LABRADOR)
> -
> -	...
> -#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

Your set of patches seems to have discarded support for quite
a few platforms.  I don't quite know the details of what these
PM scripts are doing ... could they be misbehaving on Beagle,
so that they explain why "reboot" on RC8 fails?


> +static int __init twl4030_power_probe(struct platform_device *pdev)

Pretty much everything here is "init" code, which is fine;
I like seeing smaller runtime images.  But:


>  
> @@ -340,4 +271,17 @@ static int __init twl4030_power_init(void)
>  
>  }
>  
> +static struct platform_driver twl4030_power = {
> +	.probe		= twl4030_power_probe,
> +	.driver		= {
> +		.name = "twl4030_power",
> +		.owner = THIS_MODULE,
> +	},
> +};
> +
> +static int __init twl4030_power_init(void)
> +{
> +	return platform_driver_register(&twl4030_power);

... in that case, why not platform_driver_probe(), so there's
not even a whiff of a notion that this driver remain init is
done?

And I can't help but wonder why this isn't just part of
the twl4030-core code, without even a platform device/driver.

I didn't move it to drivers/mfd because it seemed almost all
SDP-specific.  But to the extent that it's something generic
and "part of the core", maybe that's where it should be.
Not necessarily part of the same file.

- Dave


> +}
> +
>  module_init(twl4030_power_init);

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

* Re: [PATCH 2/3] Adapt twl4030 power code to new twl4030 code
  2008-10-07 16:19     ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code David Brownell
@ 2008-10-08  6:49       ` Peter 'p2' De Schrijver
  2008-10-08  7:16         ` David Brownell
                           ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-08  6:49 UTC (permalink / raw)
  To: ext David Brownell; +Cc: linux-omap

Hi David,

> 
> Your set of patches seems to have discarded support for quite
> a few platforms.  I don't quite know the details of what these
> PM scripts are doing ... could they be misbehaving on Beagle,
> so that they explain why "reboot" on RC8 fails?
> 
> 

It might. At least the warmreset script might cause problems on Beagle.
I'm not familiar enough with beagle to know for sure.

> > +static int __init twl4030_power_probe(struct platform_device *pdev)
> 
> Pretty much everything here is "init" code, which is fine;
> I like seeing smaller runtime images.  But:
> 
> 
> >  
> > @@ -340,4 +271,17 @@ static int __init twl4030_power_init(void)
> >  
> >  }
> >  
> > +static struct platform_driver twl4030_power = {
> > +	.probe		= twl4030_power_probe,
> > +	.driver		= {
> > +		.name = "twl4030_power",
> > +		.owner = THIS_MODULE,
> > +	},
> > +};
> > +
> > +static int __init twl4030_power_init(void)
> > +{
> > +	return platform_driver_register(&twl4030_power);
> 
> ... in that case, why not platform_driver_probe(), so there's
> not even a whiff of a notion that this driver remain init is
> done?
> 

That's correct. The 'driver' basically loads the scripts in the twl4030 and
that's it. The hw will then execute the scripts when necessary.

> And I can't help but wonder why this isn't just part of
> the twl4030-core code, without even a platform device/driver.

If you think all this script loading stuff can go into twl4030-core, I
can make a patch to move it there.

> 
> I didn't move it to drivers/mfd because it seemed almost all
> SDP-specific.  But to the extent that it's something generic
> and "part of the core", maybe that's where it should be.
> Not necessarily part of the same file.
> 

It's not SDP specific, but it is OMAP specific I think. At least I can't
see use cases outside OMAP2/3.

Cheers,

Peter.

-- 
goa is a state of mind

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

* Re: [PATCH 2/3] Adapt twl4030 power code to new twl4030 code
  2008-10-08  6:49       ` Peter 'p2' De Schrijver
@ 2008-10-08  7:16         ` David Brownell
  2008-10-08  7:22         ` David Brownell
  2008-11-08  0:05         ` David Brownell
  2 siblings, 0 replies; 10+ messages in thread
From: David Brownell @ 2008-10-08  7:16 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 07 October 2008, Peter 'p2' De Schrijver wrote:
> > And I can't help but wonder why this isn't just part of
> > the twl4030-core code, without even a platform device/driver.
> 
> If you think all this script loading stuff can go into twl4030-core, I
> can make a patch to move it there.

Well, link it with twl-core, call it as a subroutine,
add some kind of header to hold the subroutine decl.
Not unlike the linkage structure "today".

Right now I'm thinking the {core, irq, "power"} structure
will be OK, if the "irq" gets generalized so it's not just
the one SIH module (which I have, partially done) ... and
the "power" bits lose the board-specific stuff.

 
> > I didn't move it to drivers/mfd because it seemed almost all
> > SDP-specific.  But to the extent that it's something generic
> > and "part of the core", maybe that's where it should be.
> > Not necessarily part of the same file.
> > 
> 
> It's not SDP specific, but it is OMAP specific I think. At least I can't
> see use cases outside OMAP2/3.

We'll know when/if this is used on non-OMAP hardware!

Likely not soon.  I'd like to have the code build cleanly
on most hardware, so we get the build fixes and API update
that implies.  That's mostly IRQ cleanup.  Board designers
will do what they want, and I suspect you're right there.

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

* Re: [PATCH 2/3] Adapt twl4030 power code to new twl4030 code
  2008-10-08  6:49       ` Peter 'p2' De Schrijver
  2008-10-08  7:16         ` David Brownell
@ 2008-10-08  7:22         ` David Brownell
  2008-11-08  0:05         ` David Brownell
  2 siblings, 0 replies; 10+ messages in thread
From: David Brownell @ 2008-10-08  7:22 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 07 October 2008, Peter 'p2' De Schrijver wrote:
> > 
> > Your set of patches seems to have discarded support for quite
> > a few platforms.  I don't quite know the details of what these
> > PM scripts are doing ... could they be misbehaving on Beagle,
> > so that they explain why "reboot" on RC8 fails?
> 
> It might. At least the warmreset script might cause problems on Beagle.
> I'm not familiar enough with beagle to know for sure.

An RC3 kernel of mine reboots fine; RC7 and RC8 don't.  I'm
told other folk have seen the issue too.

The problem certainly doesn't kick in *before* the twl-power
code runs (as I happened to notice due to a bug), but I have
no particular reason to suspect that's an issue ... beyond it
having fingers in that reset process.

If the next version of your patches changes this behavior,
that might be some evidence.  ;)

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

* Re: [PATCH 2/3] Adapt twl4030 power code to new twl4030 code
  2008-10-08  6:49       ` Peter 'p2' De Schrijver
  2008-10-08  7:16         ` David Brownell
  2008-10-08  7:22         ` David Brownell
@ 2008-11-08  0:05         ` David Brownell
  2 siblings, 0 replies; 10+ messages in thread
From: David Brownell @ 2008-11-08  0:05 UTC (permalink / raw)
  To: Peter 'p2' De Schrijver; +Cc: linux-omap

On Tuesday 07 October 2008, Peter 'p2' De Schrijver wrote:
> 
> > 		 I don't quite know the details of what these
> > PM scripts are doing ... could they be misbehaving on Beagle,
> > so that they explain why "reboot" on RC8 fails?
> 
> It might. At least the warmreset script might cause problems on Beagle.
> I'm not familiar enough with beagle to know for sure.

Just for the record, now that I finally got around to making
that experiment:  if I disable CONFIG_TWL4030_POWER, "reset"
works again on my Beagle (with current GIT).

Exactly why it fails on Beagle but not on Overo (with twl5030
not twl4030), I don't know.

- Dave

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

end of thread, other threads:[~2008-11-08  0:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-07 14:34 [PATCH 0/3] Move twl4030 scripts to platform data Peter 'p2' De Schrijver
2008-10-07 14:34 ` [PATCH 1/3] Add twl4030 scripts to 3430sdp " Peter 'p2' De Schrijver
2008-10-07 14:34   ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code Peter 'p2' De Schrijver
2008-10-07 14:34     ` [PATCH 3/3] Add twl4030 power platform device Peter 'p2' De Schrijver
2008-10-07 16:19     ` [PATCH 2/3] Adapt twl4030 power code to new twl4030 code David Brownell
2008-10-08  6:49       ` Peter 'p2' De Schrijver
2008-10-08  7:16         ` David Brownell
2008-10-08  7:22         ` David Brownell
2008-11-08  0:05         ` David Brownell
2008-10-07 16:05 ` [PATCH 0/3] Move twl4030 scripts to platform data David Brownell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.