aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/platform
diff options
context:
space:
mode:
authorDaniel Drake <dsd@laptop.org>2011-06-25 12:34:16 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2011-07-06 17:44:40 -0400
commite1040ac693bac19eaeafbd6c5fd24d9429b5eeb8 (patch)
treefad8ac00517137d31674f6999a8d662ef4af19d5 /arch/x86/platform
parent2cf2baea103f0a3d68b0f989d28df66f16dbc834 (diff)
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')
-rw-r--r--arch/x86/platform/olpc/olpc-xo1-sci.c37
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 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/mfd/core.h> 21#include <linux/mfd/core.h>
22#include <linux/power_supply.h>
22#include <linux/suspend.h> 23#include <linux/suspend.h>
23#include <linux/workqueue.h> 24#include <linux/workqueue.h>
24 25
@@ -52,6 +53,26 @@ static const char * const lid_wake_mode_names[] = {
52 [LID_WAKE_CLOSE] = "close", 53 [LID_WAKE_CLOSE] = "close",
53}; 54};
54 55
56static void battery_status_changed(void)
57{
58 struct power_supply *psy = power_supply_get_by_name("olpc-battery");
59
60 if (psy) {
61 power_supply_changed(psy);
62 put_device(psy->dev);
63 }
64}
65
66static void ac_status_changed(void)
67{
68 struct power_supply *psy = power_supply_get_by_name("olpc-ac");
69
70 if (psy) {
71 power_supply_changed(psy);
72 put_device(psy->dev);
73 }
74}
75
55/* Report current ebook switch state through input layer */ 76/* Report current ebook switch state through input layer */
56static void send_ebook_state(void) 77static void send_ebook_state(void)
57{ 78{
@@ -151,6 +172,18 @@ static void process_sci_queue(bool propagate_events)
151 172
152 pr_debug(PFX "SCI 0x%x received\n", data); 173 pr_debug(PFX "SCI 0x%x received\n", data);
153 174
175 switch (data) {
176 case EC_SCI_SRC_BATERR:
177 case EC_SCI_SRC_BATSOC:
178 case EC_SCI_SRC_BATTERY:
179 case EC_SCI_SRC_BATCRIT:
180 battery_status_changed();
181 break;
182 case EC_SCI_SRC_ACPWR:
183 ac_status_changed();
184 break;
185 }
186
154 if (data == EC_SCI_SRC_EBOOK && propagate_events) 187 if (data == EC_SCI_SRC_EBOOK && propagate_events)
155 send_ebook_state(); 188 send_ebook_state();
156 } while (data); 189 } while (data);
@@ -240,6 +273,10 @@ static int xo1_sci_resume(struct platform_device *pdev)
240 273
241 /* Enable all EC events */ 274 /* Enable all EC events */
242 olpc_ec_mask_write(EC_SCI_SRC_ALL); 275 olpc_ec_mask_write(EC_SCI_SRC_ALL);
276
277 /* Power/battery status might have changed too */
278 battery_status_changed();
279 ac_status_changed();
243 return 0; 280 return 0;
244} 281}
245 282