diff options
author | Daniel Drake <dsd@laptop.org> | 2011-06-25 17:34:16 +0100 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-07-06 14:44:40 -0700 |
commit | e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8 (patch) | |
tree | fad8ac00517137d31674f6999a8d662ef4af19d5 /arch/x86/platform/olpc/olpc-xo1-sci.c | |
parent | 2cf2baea103f0a3d68b0f989d28df66f16dbc834 (diff) | |
download | blackbird-op-linux-e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8.tar.gz blackbird-op-linux-e1040ac693bac19eaeafbd6c5fd24d9429b5eeb8.zip |
x86, olpc-xo1-sci: Propagate power supply/battery events
EC events indicate change in AC power connectivity, battery state of
charge, battery error, battery presence, etc. Send notifications to
the power supply subsystem when changes are detected.
Signed-off-by: Daniel Drake <dsd@laptop.org>
Link: http://lkml.kernel.org/r/1309019658-1712-10-git-send-email-dsd@laptop.org
Acked-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/platform/olpc/olpc-xo1-sci.c')
-rw-r--r-- | arch/x86/platform/olpc/olpc-xo1-sci.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c index ad0670bca833..1d4c783d7325 100644 --- a/arch/x86/platform/olpc/olpc-xo1-sci.c +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c @@ -19,6 +19,7 @@ #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/mfd/core.h> +#include <linux/power_supply.h> #include <linux/suspend.h> #include <linux/workqueue.h> @@ -52,6 +53,26 @@ static const char * const lid_wake_mode_names[] = { [LID_WAKE_CLOSE] = "close", }; +static void battery_status_changed(void) +{ + struct power_supply *psy = power_supply_get_by_name("olpc-battery"); + + if (psy) { + power_supply_changed(psy); + put_device(psy->dev); + } +} + +static void ac_status_changed(void) +{ + struct power_supply *psy = power_supply_get_by_name("olpc-ac"); + + if (psy) { + power_supply_changed(psy); + put_device(psy->dev); + } +} + /* Report current ebook switch state through input layer */ static void send_ebook_state(void) { @@ -151,6 +172,18 @@ static void process_sci_queue(bool propagate_events) pr_debug(PFX "SCI 0x%x received\n", data); + switch (data) { + case EC_SCI_SRC_BATERR: + case EC_SCI_SRC_BATSOC: + case EC_SCI_SRC_BATTERY: + case EC_SCI_SRC_BATCRIT: + battery_status_changed(); + break; + case EC_SCI_SRC_ACPWR: + ac_status_changed(); + break; + } + if (data == EC_SCI_SRC_EBOOK && propagate_events) send_ebook_state(); } while (data); @@ -240,6 +273,10 @@ static int xo1_sci_resume(struct platform_device *pdev) /* Enable all EC events */ olpc_ec_mask_write(EC_SCI_SRC_ALL); + + /* Power/battery status might have changed too */ + battery_status_changed(); + ac_status_changed(); return 0; } |