X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?p=linux-2.6-omap-h63xx.git;a=blobdiff_plain;f=drivers%2Fi2c%2Fchips%2Ftwl4030-poweroff.c;fp=drivers%2Fi2c%2Fchips%2Ftwl4030-poweroff.c;h=0ebab0ba4e9441251e7bd5c429f909d57382859e;hp=0000000000000000000000000000000000000000;hb=0d5f2216edfeb9904e0d6512f803b0f93871baaf;hpb=14fc69723d3442ef46f8f82b3f481e82f06a346d diff --git a/drivers/i2c/chips/twl4030-poweroff.c b/drivers/i2c/chips/twl4030-poweroff.c new file mode 100644 index 00000000000..0ebab0ba4e9 --- /dev/null +++ b/drivers/i2c/chips/twl4030-poweroff.c @@ -0,0 +1,76 @@ +/* + * linux/drivers/i2c/chips/twl4030_poweroff.c + * + * Power off device + * + * Copyright (C) 2008 Nokia Corporation + * + * Written by Peter De Schrijver + * + * 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 + +#define PWR_P1_SW_EVENTS 0x10 +#define PWR_DEVOFF (1<<0) + +static 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_ALIAS("i2c:twl4030-poweroff"); +MODULE_DESCRIPTION("Triton2 device power off"); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Peter De Schrijver");