Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Daniel Drake and committed by
H. Peter Anvin
e1040ac6 2cf2baea

+40 -1
+3 -1
arch/x86/Kconfig
··· 2082 2082 2083 2083 config OLPC_XO1_SCI 2084 2084 bool "OLPC XO-1 SCI extras" 2085 - depends on OLPC && OLPC_XO1_PM 2085 + depends on OLPC && OLPC_XO1_PM && POWER_SUPPLY 2086 2086 select GPIO_CS5535 2087 2087 select MFD_CORE 2088 2088 ---help--- ··· 2091 2091 - Power button 2092 2092 - Ebook switch 2093 2093 - Lid switch 2094 + - AC adapter status updates 2095 + - Battery status updates 2094 2096 2095 2097 endif # X86_32 2096 2098
+37
arch/x86/platform/olpc/olpc-xo1-sci.c
··· 19 19 #include <linux/platform_device.h> 20 20 #include <linux/pm.h> 21 21 #include <linux/mfd/core.h> 22 + #include <linux/power_supply.h> 22 23 #include <linux/suspend.h> 23 24 #include <linux/workqueue.h> 24 25 ··· 52 51 [LID_WAKE_OPEN] = "open", 53 52 [LID_WAKE_CLOSE] = "close", 54 53 }; 54 + 55 + static void battery_status_changed(void) 56 + { 57 + struct power_supply *psy = power_supply_get_by_name("olpc-battery"); 58 + 59 + if (psy) { 60 + power_supply_changed(psy); 61 + put_device(psy->dev); 62 + } 63 + } 64 + 65 + static void ac_status_changed(void) 66 + { 67 + struct power_supply *psy = power_supply_get_by_name("olpc-ac"); 68 + 69 + if (psy) { 70 + power_supply_changed(psy); 71 + put_device(psy->dev); 72 + } 73 + } 55 74 56 75 /* Report current ebook switch state through input layer */ 57 76 static void send_ebook_state(void) ··· 172 151 173 152 pr_debug(PFX "SCI 0x%x received\n", data); 174 153 154 + switch (data) { 155 + case EC_SCI_SRC_BATERR: 156 + case EC_SCI_SRC_BATSOC: 157 + case EC_SCI_SRC_BATTERY: 158 + case EC_SCI_SRC_BATCRIT: 159 + battery_status_changed(); 160 + break; 161 + case EC_SCI_SRC_ACPWR: 162 + ac_status_changed(); 163 + break; 164 + } 165 + 175 166 if (data == EC_SCI_SRC_EBOOK && propagate_events) 176 167 send_ebook_state(); 177 168 } while (data); ··· 273 240 274 241 /* Enable all EC events */ 275 242 olpc_ec_mask_write(EC_SCI_SRC_ALL); 243 + 244 + /* Power/battery status might have changed too */ 245 + battery_status_changed(); 246 + ac_status_changed(); 276 247 return 0; 277 248 } 278 249