OMAP34xx poweroff
authorPeter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
Mon, 28 Jan 2008 16:46:58 +0000 (18:46 +0200)
committerTony Lindgren <tony@atomide.com>
Wed, 30 Jan 2008 00:21:09 +0000 (16:21 -0800)
Add support for software controlled power off of omap34xx and TWL4030
based devices.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@nokia.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/i2c/chips/Kconfig
drivers/i2c/chips/Makefile
drivers/i2c/chips/twl4030_poweroff.c [new file with mode: 0644]

index 1f5eee6..f8b4e54 100644 (file)
@@ -157,8 +157,13 @@ config TWL4030_USB_HS_ULPI
        help
          Say Y here if the TWL4030 is connected to high-speed USB
          controller through a ULPI interface.
+
 endchoice
 
+config TWL4030_POWEROFF
+       bool "TWL4030 device poweroff"
+       depends on TWL4030_CORE
+
 config SENSORS_M41T00
        tristate "ST M41T00 RTC chip (DEPRECATED)"
        depends on PPC32
index 4a079df..72a053d 100644 (file)
@@ -20,6 +20,7 @@ obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o
 obj-$(CONFIG_TWL4030_CORE)     += twl4030_core.o
 obj-$(CONFIG_TWL4030_GPIO)     += twl4030_gpio.o
 obj-$(CONFIG_TWL4030_USB)      += twl4030_usb.o
+obj-$(CONFIG_TWL4030_POWEROFF) += twl4030_poweroff.o
 obj-$(CONFIG_RTC_X1205_I2C)    += x1205.o
 
 ifeq ($(CONFIG_I2C_DEBUG_CHIP),y)
diff --git a/drivers/i2c/chips/twl4030_poweroff.c b/drivers/i2c/chips/twl4030_poweroff.c
new file mode 100644 (file)
index 0000000..7a176d9
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * linux/drivers/i2c/chips/twl4030_poweroff.c
+ *
+ * Power off device
+ *
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * Written by 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 <asm/arch/twl4030.h>
+
+#define PWR_P1_SW_EVENTS       0x10
+#define PWR_DEVOFF     (1<<0)
+
+void twl4030_poweroff(void)
+{
+       u8 val;
+       int err;
+
+       err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
+                                 PWR_P1_SW_EVENTS);
+       if (err) {
+               printk(KERN_WARNING "I2C error %d while reading TWL4030"
+                                       "PM_MASTER P1_SW_EVENTS\n", err);
+               return ;
+       }
+
+       val |= PWR_DEVOFF;
+
+       err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
+                                  PWR_P1_SW_EVENTS);
+
+       if (err) {
+               printk(KERN_WARNING "I2C error %d while writing TWL4030"
+                                       "PM_MASTER P1_SW_EVENTS\n", err);
+               return ;
+       }
+
+       return;
+}
+
+static int __init twl4030_poweroff_init(void)
+{
+       pm_power_off = twl4030_poweroff;
+
+       return 0;
+}
+
+static void __exit twl4030_poweroff_exit(void)
+{
+       pm_power_off = NULL;
+}
+
+module_init(twl4030_poweroff_init);
+module_exit(twl4030_poweroff_exit);
+
+MODULE_DESCRIPTION("Triton2 device power off");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Peter De Schrijver");