OMAP34xx poweroff

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add support for software controlled power off of omap34xx and TWL4030
based devices.

Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver@xxxxxxxxx>
---
 drivers/i2c/chips/Kconfig            |    5 ++
 drivers/i2c/chips/Makefile           |    1 +
 drivers/i2c/chips/twl4030_poweroff.c |   75 ++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 0 deletions(-)
 create mode 100644 drivers/i2c/chips/twl4030_poweroff.c

diff --git a/drivers/i2c/chips/Kconfig b/drivers/i2c/chips/Kconfig
index 1f5eee6..f8b4e54 100644
--- a/drivers/i2c/chips/Kconfig
+++ b/drivers/i2c/chips/Kconfig
@@ -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
diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile
index 4a079df..72a053d 100644
--- a/drivers/i2c/chips/Makefile
+++ b/drivers/i2c/chips/Makefile
@@ -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
index 0000000..7a176d9
--- /dev/null
+++ b/drivers/i2c/chips/twl4030_poweroff.c
@@ -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@xxxxxxxxx>
+ *
+ * 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");
-- 
1.5.3.4


-- 
goa is a state of mind
-
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux