diff options
author | Jonas Aaberg <jonas.aberg@stericsson.com> | 2011-08-17 13:20:21 +0200 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-02-04 09:28:43 +0100 |
commit | 7c34d7c2b54818078678a6507ce9a79c3d479243 (patch) | |
tree | 3581b691f9e2d94b0c423c6f81b9d9d4a8883762 /drivers/mfd/ab8500-sysctrl.c | |
parent | mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back (diff) | |
download | linux-7c34d7c2b54818078678a6507ce9a79c3d479243.tar.xz linux-7c34d7c2b54818078678a6507ce9a79c3d479243.zip |
mfd: ab8500-sysctrl: If a charger is present, reboot instead
If a charger is attached on power off, reboot the system
into charging mode instead of powering it off.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
Diffstat (limited to 'drivers/mfd/ab8500-sysctrl.c')
-rw-r--r-- | drivers/mfd/ab8500-sysctrl.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c index 888e066c715b..188d22b77a28 100644 --- a/drivers/mfd/ab8500-sysctrl.c +++ b/drivers/mfd/ab8500-sysctrl.c @@ -8,7 +8,9 @@ #include <linux/module.h> #include <linux/platform_device.h> #include <linux/pm.h> +#include <linux/reboot.h> #include <linux/signal.h> +#include <linux/power_supply.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ab8500-sysctrl.h> @@ -19,6 +21,31 @@ void ab8500_power_off(void) { sigset_t old; sigset_t all; + static char *pss[] = {"ab8500_ac", "ab8500_usb"}; + int i; + + /* + * If we have a charger connected and we're powering off, + * reboot into charge-only mode. + */ + + for (i = 0; i < ARRAY_SIZE(pss); i++) { + union power_supply_propval val; + struct power_supply *psy; + int ret; + + psy = power_supply_get_by_name(pss[i]); + if (!psy) + continue; + ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val); + + if (!ret && val.intval) { + printk(KERN_INFO + "Charger \"%s\" is connected. Rebooting.\n", + pss[i]); + machine_restart(NULL); + } + } sigfillset(&all); |