]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/i2c/chips/twl4030-poweroff.c
0ebab0ba4e9441251e7bd5c429f909d57382859e
[linux-2.6-omap-h63xx.git] / drivers / i2c / chips / twl4030-poweroff.c
1 /*
2  * linux/drivers/i2c/chips/twl4030_poweroff.c
3  *
4  * Power off device
5  *
6  * Copyright (C) 2008 Nokia Corporation
7  *
8  * Written by Peter De Schrijver <peter.de-schrijver@nokia.com>
9  *
10  * This file is subject to the terms and conditions of the GNU General
11  * Public License. See the file "COPYING" in the main directory of this
12  * archive for more details.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include <linux/module.h>
25 #include <linux/pm.h>
26 #include <linux/i2c/twl4030.h>
27
28 #define PWR_P1_SW_EVENTS        0x10
29 #define PWR_DEVOFF      (1<<0)
30
31 static void twl4030_poweroff(void)
32 {
33         u8 val;
34         int err;
35
36         err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &val,
37                                   PWR_P1_SW_EVENTS);
38         if (err) {
39                 printk(KERN_WARNING "I2C error %d while reading TWL4030"
40                                         "PM_MASTER P1_SW_EVENTS\n", err);
41                 return ;
42         }
43
44         val |= PWR_DEVOFF;
45
46         err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, val,
47                                    PWR_P1_SW_EVENTS);
48
49         if (err) {
50                 printk(KERN_WARNING "I2C error %d while writing TWL4030"
51                                         "PM_MASTER P1_SW_EVENTS\n", err);
52                 return ;
53         }
54
55         return;
56 }
57
58 static int __init twl4030_poweroff_init(void)
59 {
60         pm_power_off = twl4030_poweroff;
61
62         return 0;
63 }
64
65 static void __exit twl4030_poweroff_exit(void)
66 {
67         pm_power_off = NULL;
68 }
69
70 module_init(twl4030_poweroff_init);
71 module_exit(twl4030_poweroff_exit);
72
73 MODULE_ALIAS("i2c:twl4030-poweroff");
74 MODULE_DESCRIPTION("Triton2 device power off");
75 MODULE_LICENSE("GPL");
76 MODULE_AUTHOR("Peter De Schrijver");