summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Aaberg <jonas.aberg@stericsson.com>2011-08-17 13:20:21 +0200
committerPhilippe Langlais <philippe.langlais@stericsson.com>2011-12-06 10:50:24 +0100
commit606bda5f9b97cd36b6198ca3d1abb79dbd33155d (patch)
tree3f35db2f81c5ce46cb16435338031447fc7860e7
parent4d8f1ebafc6f7d4e4e8be19c6eb4ddf80919501b (diff)
MFD: AB8500: If a charger is present, reboot instead
If a changer is present on power off, reboot the system instead of powering it off. ST-Ericsson ID: 354056 ST-Ericsson Linux next: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I03a2a91936219db040f55fa7cd833fdbe5a05657 Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com> Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/28933 Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
-rw-r--r--drivers/mfd/ab8500-sysctrl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index e6de6a279a5..99ddb353984 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -7,7 +7,9 @@
#include <linux/err.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/ab8500.h>
#include <linux/mfd/abx500.h>
#include <linux/mfd/ab8500/sysctrl.h>
@@ -18,6 +20,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);