[PATCH 2/6] Move existing TWL4030 code to drivers/mfd

2008-10-20 Thread Peter 'p2' De Schrijver
This patches moves the twl4030 power sequencer code to drivers/mfd and
updates the code for the new twl4030 framework. The code handles downloading
the scripts provided by the board configuration and configuring 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 <[EMAIL PROTECTED]>
---
 drivers/i2c/chips/Makefile|1 -
 drivers/i2c/chips/twl4030-power.c |  343 -
 drivers/mfd/twl4030-power.c   |  270 +
 3 files changed, 270 insertions(+), 344 deletions(-)
 delete mode 100644 drivers/i2c/chips/twl4030-power.c
 create mode 100644 drivers/mfd/twl4030-power.c

diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 2b6287b..07a29fe 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -24,7 +24,6 @@ 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-power.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..000
--- 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 <[EMAIL PROTECTED]>
- *
- * 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 
-#include 
-#include 
-
-#include 
-
-#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_TRANSITIONPHY_TO_OFF_PM_MASTER(0x36)
-#define R_CFG_P2_TRANSITIONPHY_TO_OFF_PM_MASTER(0x37)
-#define R_CFG_P3_TRANSITIONPHY_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)
-#defineR_SEQ_ADD_S2A3  PHY_TO_OFF_PM_MASTER(0x57)
-#defineR_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_RES0x0
-#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_ALL0x7
-
-#define RES_TYPE2_R0   0x0
-
-#define RES_TYPE_ALL   0x7
-
-#define RES_STATE_WRST 0xF
-#define RES_STATE_ACTIVE   0xE
-#define RES_STATE_SLEEP0x8
-#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   

[PATCH 2/6] Move existing TWL4030 code to drivers/mfd

2008-10-15 Thread Peter 'p2' De Schrijver
This patches moves the twl4030 power sequencer code to drivers/mfd and
updates the code for the new twl4030 framework. The code handles downloading
the scripts provided by the board configuration and configuring 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 <[EMAIL PROTECTED]>
---
 drivers/i2c/chips/Makefile|2 +-
 drivers/i2c/chips/twl4030-power.c |  343 -
 drivers/mfd/twl4030-power.c   |  270 +
 3 files changed, 271 insertions(+), 344 deletions(-)
 delete mode 100644 drivers/i2c/chips/twl4030-power.c
 create mode 100644 drivers/mfd/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..000
--- 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 <[EMAIL PROTECTED]>
- *
- * 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 
-#include 
-#include 
-
-#include 
-
-#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_TRANSITIONPHY_TO_OFF_PM_MASTER(0x36)
-#define R_CFG_P2_TRANSITIONPHY_TO_OFF_PM_MASTER(0x37)
-#define R_CFG_P3_TRANSITIONPHY_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)
-#defineR_SEQ_ADD_S2A3  PHY_TO_OFF_PM_MASTER(0x57)
-#defineR_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_RES0x0
-#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_ALL0x7
-
-#define RES_TYPE2_R0   0x0
-
-#define RES_TYPE_ALL   0x7
-
-#define RES_STATE_WRST 0xF
-#define RES_STATE_ACTIVE   0xE
-#define RES_STATE_SLEEP0x8
-#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