11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/types.h>
15 #include <linux/device.h>
19 #include <linux/sched.h>
24 #define EC_BAT_VOLTAGE 0x10
25 #define EC_BAT_CURRENT 0x11
26 #define EC_BAT_ACR 0x12
27 #define EC_BAT_TEMP 0x13
28 #define EC_AMB_TEMP 0x14
29 #define EC_BAT_STATUS 0x15
30 #define EC_BAT_SOC 0x16
31 #define EC_BAT_SERIAL 0x17
32 #define EC_BAT_EEPROM 0x18
33 #define EC_BAT_ERRCODE 0x1f
35 #define BAT_STAT_PRESENT 0x01
36 #define BAT_STAT_FULL 0x02
37 #define BAT_STAT_LOW 0x04
38 #define BAT_STAT_DESTROY 0x08
39 #define BAT_STAT_AC 0x10
40 #define BAT_STAT_CHARGING 0x20
41 #define BAT_STAT_DISCHARGING 0x40
42 #define BAT_STAT_TRICKLE 0x80
44 #define BAT_ERR_INFOFAIL 0x02
45 #define BAT_ERR_OVERVOLTAGE 0x04
46 #define BAT_ERR_OVERTEMP 0x05
47 #define BAT_ERR_GAUGESTOP 0x06
48 #define BAT_ERR_OUT_OF_CONTROL 0x07
49 #define BAT_ERR_ID_FAIL 0x09
50 #define BAT_ERR_ACR_FAIL 0x10
52 #define BAT_ADDR_MFR_TYPE 0x5F
87 .properties = olpc_ac_props,
89 .get_property = olpc_ac_get_prop,
92 static char bat_serial[17];
165 switch (ec_byte >> 4) {
167 val->
strval =
"Gold Peak";
190 switch (ec_byte & 0xf) {
211 ret = olpc_bat_get_tech(&tech);
222 switch (tech.intval) {
261 ret = olpc_bat_get_charge_full_design(&
full);
276 ret = olpc_bat_get_tech(&tech);
287 switch (tech.intval) {
321 static int olpc_bat_get_property(
struct power_supply *psy,
346 ret = olpc_bat_get_status(val, ec_byte);
367 ret = olpc_bat_get_health(val);
374 ret = olpc_bat_get_mfr(val);
379 ret = olpc_bat_get_tech(val);
414 ret = olpc_bat_get_charge_full_design(val);
419 ret = olpc_bat_get_charge_now(val);
453 ret = olpc_bat_get_voltage_max_design(val);
511 #define EEPROM_START 0x20
512 #define EEPROM_END 0x80
513 #define EEPROM_SIZE (EEPROM_END - EEPROM_START)
527 for (i = 0; i <
count; i++) {
532 "EC_BAT_EEPROM cmd @ 0x%x failed - %d!\n",
547 .read = olpc_bat_eeprom_read,
562 return sprintf(buf,
"%d\n", ec_byte);
570 .show = olpc_bat_error_read,
578 .name =
"olpc-battery",
579 .get_property = olpc_bat_get_property,
586 if (device_may_wakeup(olpc_ac.
dev))
591 if (device_may_wakeup(olpc_bat.
dev))
626 if (olpc_board_at_least(olpc_board_pre(0xd0))) {
672 { .compatible =
"olpc,xo1-battery" },
679 .name =
"olpc-battery",
681 .of_match_table = olpc_battery_ids,
683 .probe = olpc_battery_probe,
685 .suspend = olpc_battery_suspend,