* [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd
@ 2008-10-10 16:56 Peter 'p2' De Schrijver
0 siblings, 0 replies; 12+ 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] 12+ messages in thread
* [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd
@ 2008-10-13 15:44 Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
2008-10-14 17:44 ` [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd David Brownell
0 siblings, 2 replies; 12+ 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 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 | 84 ++++++
arch/arm/mach-omap2/board-ldp.c | 84 ++++++
arch/arm/mach-omap2/board-omap3beagle.c | 4 +-
arch/arm/mach-omap2/board-omap3evm.c | 4 +-
arch/arm/mach-omap2/board-overo.c | 4 +-
arch/arm/mach-omap2/twl4030-generic-scripts.c | 78 ++++++
arch/arm/mach-omap2/twl4030-generic-scripts.h | 8 +
drivers/i2c/chips/Makefile | 2 +-
drivers/i2c/chips/twl4030-power.c | 343 -------------------------
drivers/mfd/Kconfig | 7 +
drivers/mfd/Makefile | 1 +
drivers/mfd/twl4030-core.c | 11 +
drivers/mfd/twl4030-power.c | 270 +++++++++++++++++++
include/linux/i2c/twl4030.h | 64 +++++
15 files changed, 620 insertions(+), 353 deletions(-)
create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.c
create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.h
delete mode 100644 drivers/i2c/chips/twl4030-power.c
create mode 100644 drivers/mfd/twl4030-power.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/7] Remove existing twl4030 power script code.
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 ` 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-14 17:44 ` [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd David Brownell
1 sibling, 1 reply; 12+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-13 15:44 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/Makefile | 2 +-
drivers/i2c/chips/twl4030-power.c | 343 -------------------------------------
2 files changed, 1 insertions(+), 344 deletions(-)
delete mode 100644 drivers/i2c/chips/twl4030-power.c
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index ba41a57..7e0fdfa 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -24,7 +24,7 @@ obj-$(CONFIG_GPIOEXPANDER_OMAP) += gpio_expander_omap.o
obj-$(CONFIG_MENELAUS) += menelaus.o
obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o
-obj-$(CONFIG_TWL4030_CORE) += twl4030-pwrirq.o twl4030-power.o
+obj-$(CONFIG_TWL4030_CORE) += twl4030-pwrirq.o
obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
obj-$(CONFIG_TWL4030_POWEROFF) += twl4030-poweroff.o
obj-$(CONFIG_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o
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] 12+ messages in thread
* [PATCH 2/7] Add defines and data types for twl4030.
2008-10-13 15:44 ` [PATCH 1/7] Remove existing twl4030 power script code Peter 'p2' De Schrijver
@ 2008-10-13 15:44 ` Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 3/7] Twl4030 power code updated for new twl4030 core Peter 'p2' De Schrijver
0 siblings, 1 reply; 12+ 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 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] 12+ messages in thread
* [PATCH 3/7] Twl4030 power code updated for new twl4030 core
2008-10-13 15:44 ` [PATCH 2/7] Add defines and data types for twl4030 Peter 'p2' De Schrijver
@ 2008-10-13 15:44 ` 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:38 ` [PATCH 3/7] Twl4030 power code updated for new " David Brownell
0 siblings, 2 replies; 12+ 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 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..d9d1655
--- /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 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)
+ printk(KERN_ERR
+ "TWL4030 Unable to unlock registers\n");
+
+ for (i = 0; i < triton2_scripts->size; i++) {
+ err = load_triton_script(triton2_scripts->scripts[i]);
+ if (err)
+ break;
+ }
+
+ if (twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, R_PROTECT_KEY))
+ printk(KERN_ERR
+ "TWL4030 Unable to relock registers\n");
+}
--
1.5.6.3
^ permalink raw reply related [flat|nested] 12+ 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-13 15:44 ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
2008-10-14 17:42 ` [PATCH 4/7] Hook twl4030 power code into twl4030 core David Brownell
2008-10-14 17:38 ` [PATCH 3/7] Twl4030 power code updated for new " David Brownell
1 sibling, 2 replies; 12+ 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] 12+ messages in thread
* [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts.
2008-10-13 15:44 ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
@ 2008-10-13 15:44 ` Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
2008-10-14 17:42 ` [PATCH 4/7] Hook twl4030 power code into twl4030 core David Brownell
1 sibling, 1 reply; 12+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-13 15:44 UTC (permalink / raw)
To: linux-omap; +Cc: Peter 'p2' De Schrijver
The TI 3430dsp and ldp boards have a custom power script to handle sleep and off modes.
Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
---
arch/arm/mach-omap2/board-3430sdp.c | 84 +++++++++++++++++++++++++++++++++++
arch/arm/mach-omap2/board-ldp.c | 84 +++++++++++++++++++++++++++++++++++
2 files changed, 168 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 56f28ae..bb591bb 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,87 @@ static struct twl4030_madc_platform_data sdp3430_madc_data = {
.irq_line = 1,
};
+
+static struct twl4030_ins __initdata sleep_on_seq[] = {
+/*
+ * Turn off VDD1 and VDD2.
+ */
+ {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
+#ifdef CONFIG_DISABLE_HFCLK
+/*
+ * And also turn off the OMAP3 PLLs and the sysclk output.
+ */
+ {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
+/*
+ * Wakeup VDD1 and VDD2.
+ */
+ {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
+#else
+/*
+ * Reenable the OMAP3 PLLs.
+ * Wakeup VDD1 and VDD2.
+ * Reenable sysclk output.
+ */
+ {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 = {
+/*
+ * Reset twl4030.
+ * Reset VDD1 regulator.
+ * Reset VDD2 regulator.
+ * Reset VPLL1 regulator.
+ * Enable sysclk output.
+ * Reenable twl4030.
+ */
+ {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2},
+ {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
+ {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2},
+};
+static struct twl4030_script wrst_script __initdata = {
+ .script = wrst_seq,
+ .size = ARRAY_SIZE(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 +421,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..d4d4e90 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,87 @@ static int ldp_batt_table[] = {
4040, 3910, 3790, 3670, 3550
};
+static struct twl4030_ins __initdata sleep_on_seq[] = {
+/*
+ * Turn off VDD1 and VDD2.
+ */
+ {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2},
+#ifdef CONFIG_DISABLE_HFCLK
+/*
+ * And also turn off the OMAP3 PLLs and the sysclk output.
+ */
+ {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
+/*
+ * Wakeup VDD1 and VDD2.
+ */
+ {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2},
+#else
+/*
+ * Reenable the OMAP3 PLLs.
+ * Wakeup VDD1 and VDD2.
+ * Reenable sysclk output.
+ */
+ {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 = {
+/*
+ * Reset twl4030.
+ * Reset VDD1 regulator.
+ * Reset VDD2 regulator.
+ * Reset VPLL1 regulator.
+ * Enable sysclk output.
+ * Reenable twl4030.
+ */
+ {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2},
+ {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60},
+ {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2},
+ {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2},
+};
+
+static struct twl4030_script wrst_script __initdata = {
+ .script = wrst_seq,
+ .size = ARRAY_SIZE(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 +305,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] 12+ messages in thread
* [PATCH 6/7] Generic twl4030 power script for 3430 based boards.
2008-10-13 15:44 ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
@ 2008-10-13 15:44 ` Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script Peter 'p2' De Schrijver
0 siblings, 1 reply; 12+ 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 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 +++++++++++++++++++++++++
arch/arm/mach-omap2/twl4030-generic-scripts.h | 8 +++
2 files changed, 86 insertions(+), 0 deletions(-)
create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.c
create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.h
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),
+};
+
+
diff --git a/arch/arm/mach-omap2/twl4030-generic-scripts.h b/arch/arm/mach-omap2/twl4030-generic-scripts.h
new file mode 100644
index 0000000..64d8d3f
--- /dev/null
+++ b/arch/arm/mach-omap2/twl4030-generic-scripts.h
@@ -0,0 +1,8 @@
+#ifndef __TWL4030_GENERIC_SCRIPTS_H
+#define __TWL4030_GENERIC_SCRIPTS_H
+
+#include <linux/i2c/twl4030.h>
+
+extern struct twl4030_power_data generic3430_t2scripts_data;
+
+#endif
--
1.5.6.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
2008-10-13 15:44 ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
@ 2008-10-13 15:44 ` Peter 'p2' De Schrijver
0 siblings, 0 replies; 12+ messages in thread
From: Peter 'p2' De Schrijver @ 2008-10-13 15:44 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 | 4 ++--
arch/arm/mach-omap2/board-omap3evm.c | 4 ++--
arch/arm/mach-omap2/board-overo.c | 4 ++--
4 files changed, 12 insertions(+), 9 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..cc9506b 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -24,8 +24,6 @@
#include <linux/input.h>
#include <linux/gpio_keys.h>
-#include <linux/i2c/twl4030.h>
-
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
@@ -45,6 +43,7 @@
#include <mach/nand.h>
#include <mach/mux.h>
+#include "twl4030-generic-scripts.h"
#define GPMC_CS0_BASE 0x60
#define GPMC_CS_SIZE 0x30
@@ -149,6 +148,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..a72772f 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -20,8 +20,6 @@
#include <linux/clk.h>
#include <linux/input.h>
-#include <linux/i2c/twl4030.h>
-
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
#include <linux/i2c/twl4030.h>
@@ -41,6 +39,7 @@
#include <mach/mcspi.h>
#include "sdram-micron-mt46h32m32lf-6.h"
+#include "twl4030-generic-scripts.h"
static struct resource omap3evm_smc911x_resources[] = {
[0] = {
@@ -139,6 +138,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..b0e5cec 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -27,8 +27,6 @@
#include <linux/kernel.h>
#include <linux/platform_device.h>
-#include <linux/i2c/twl4030.h>
-
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
@@ -50,6 +48,7 @@
#include <mach/usb-musb.h>
#include "sdram-micron-mt46h32m32lf-6.h"
+#include "twl4030-generic-scripts.h"
#define NAND_BLOCK_SIZE SZ_128K
#define GPMC_CS0_BASE 0x60
@@ -160,6 +159,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] 12+ messages in thread
* Re: [PATCH 3/7] Twl4030 power code updated for new 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 ` [PATCH 4/7] Hook twl4030 power code into " Peter 'p2' De Schrijver
@ 2008-10-14 17:38 ` David Brownell
1 sibling, 0 replies; 12+ messages in thread
From: David Brownell @ 2008-10-14 17:38 UTC (permalink / raw)
To: Peter 'p2' De Schrijver; +Cc: linux-omap
On Monday 13 October 2008, Peter 'p2' De Schrijver wrote:
> ---
> drivers/mfd/twl4030-power.c | 270 +++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 270 insertions(+), 0 deletions(-)
I tend to agree with the comment from Felipe that moving
this file from i2c/chips to mfd should be one patch.
Again, the general rule about such stuff is that a patch
series should preserve bisectability. Else it gets hard
to use "git bisect" to track down particularly pernicious
problem patterns, promptly puncturing perplexing puzzles.
:)
--
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] 12+ 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-13 15:44 ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
@ 2008-10-14 17:42 ` David Brownell
1 sibling, 0 replies; 12+ 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] 12+ messages in thread
* Re: [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd
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-14 17:44 ` David Brownell
1 sibling, 0 replies; 12+ messages in thread
From: David Brownell @ 2008-10-14 17:44 UTC (permalink / raw)
To: Peter 'p2' De Schrijver; +Cc: linux-omap
On Monday 13 October 2008, Peter 'p2' De Schrijver wrote:
> This patchset integrates the twl4030 power code into the new
> twl4030 mfd framework. The scripts will be moved to the board
> specific data.
This basically looks OK, assuming the previous comments get
addressed.
> 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
>
--
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] 12+ messages in thread
end of thread, other threads:[~2008-10-14 17:58 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-13 15:44 ` [PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 6/7] Generic twl4030 power script for 3430 based boards Peter 'p2' De Schrijver
2008-10-13 15:44 ` [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script Peter 'p2' De Schrijver
2008-10-14 17:42 ` [PATCH 4/7] Hook twl4030 power code into twl4030 core David Brownell
2008-10-14 17:38 ` [PATCH 3/7] Twl4030 power code updated for new " David Brownell
2008-10-14 17:44 ` [PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd David Brownell
-- strict thread matches above, loose matches on Subject: below --
2008-10-10 16:56 Peter 'p2' De Schrijver
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox