David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 1 | /* |
| 2 | * Battery driver for One Laptop Per Child board. |
| 3 | * |
David Woodhouse | 690e85a | 2010-08-09 18:13:09 +0100 | [diff] [blame] | 4 | * Copyright © 2006-2010 David Woodhouse <dwmw2@infradead.org> |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
Andres Salomon | 04a820e | 2009-06-30 02:14:00 -0400 | [diff] [blame] | 11 | #include <linux/kernel.h> |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 12 | #include <linux/module.h> |
Andres Salomon | 144bbea | 2009-06-30 02:15:26 -0400 | [diff] [blame] | 13 | #include <linux/types.h> |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 14 | #include <linux/err.h> |
Andres Salomon | 144bbea | 2009-06-30 02:15:26 -0400 | [diff] [blame] | 15 | #include <linux/device.h> |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/power_supply.h> |
| 18 | #include <linux/jiffies.h> |
| 19 | #include <linux/sched.h> |
Andres Salomon | 3bf9428 | 2012-07-11 01:16:29 -0700 | [diff] [blame] | 20 | #include <linux/olpc-ec.h> |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 21 | #include <asm/olpc.h> |
| 22 | |
| 23 | |
| 24 | #define EC_BAT_VOLTAGE 0x10 /* uint16_t, *9.76/32, mV */ |
| 25 | #define EC_BAT_CURRENT 0x11 /* int16_t, *15.625/120, mA */ |
Andres Salomon | 75d8807 | 2008-05-14 16:20:38 -0700 | [diff] [blame] | 26 | #define EC_BAT_ACR 0x12 /* int16_t, *6250/15, µAh */ |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 27 | #define EC_BAT_TEMP 0x13 /* uint16_t, *100/256, °C */ |
| 28 | #define EC_AMB_TEMP 0x14 /* uint16_t, *100/256, °C */ |
| 29 | #define EC_BAT_STATUS 0x15 /* uint8_t, bitmask */ |
| 30 | #define EC_BAT_SOC 0x16 /* uint8_t, percentage */ |
| 31 | #define EC_BAT_SERIAL 0x17 /* uint8_t[6] */ |
| 32 | #define EC_BAT_EEPROM 0x18 /* uint8_t adr as input, uint8_t output */ |
| 33 | #define EC_BAT_ERRCODE 0x1f /* uint8_t, bitmask */ |
| 34 | |
| 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 |
Andres Salomon | 8f7e579 | 2009-06-30 02:16:17 -0400 | [diff] [blame] | 42 | #define BAT_STAT_TRICKLE 0x80 |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 43 | |
| 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 |
| 51 | |
| 52 | #define BAT_ADDR_MFR_TYPE 0x5F |
| 53 | |
| 54 | /********************************************************************* |
| 55 | * Power |
| 56 | *********************************************************************/ |
| 57 | |
| 58 | static int olpc_ac_get_prop(struct power_supply *psy, |
| 59 | enum power_supply_property psp, |
| 60 | union power_supply_propval *val) |
| 61 | { |
| 62 | int ret = 0; |
| 63 | uint8_t status; |
| 64 | |
| 65 | switch (psp) { |
| 66 | case POWER_SUPPLY_PROP_ONLINE: |
| 67 | ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1); |
| 68 | if (ret) |
| 69 | return ret; |
| 70 | |
| 71 | val->intval = !!(status & BAT_STAT_AC); |
| 72 | break; |
| 73 | default: |
| 74 | ret = -EINVAL; |
| 75 | break; |
| 76 | } |
| 77 | return ret; |
| 78 | } |
| 79 | |
| 80 | static enum power_supply_property olpc_ac_props[] = { |
| 81 | POWER_SUPPLY_PROP_ONLINE, |
| 82 | }; |
| 83 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 84 | static const struct power_supply_desc olpc_ac_desc = { |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 85 | .name = "olpc-ac", |
| 86 | .type = POWER_SUPPLY_TYPE_MAINS, |
| 87 | .properties = olpc_ac_props, |
| 88 | .num_properties = ARRAY_SIZE(olpc_ac_props), |
| 89 | .get_property = olpc_ac_get_prop, |
| 90 | }; |
| 91 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 92 | static struct power_supply *olpc_ac; |
| 93 | |
David Woodhouse | 1ca5b9d | 2008-05-04 01:31:42 -0400 | [diff] [blame] | 94 | static char bat_serial[17]; /* Ick */ |
| 95 | |
Andres Salomon | b2bd8a3 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 96 | static int olpc_bat_get_status(union power_supply_propval *val, uint8_t ec_byte) |
| 97 | { |
| 98 | if (olpc_platform_info.ecver > 0x44) { |
Andres Salomon | 8f7e579 | 2009-06-30 02:16:17 -0400 | [diff] [blame] | 99 | if (ec_byte & (BAT_STAT_CHARGING | BAT_STAT_TRICKLE)) |
Andres Salomon | b2bd8a3 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 100 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
| 101 | else if (ec_byte & BAT_STAT_DISCHARGING) |
| 102 | val->intval = POWER_SUPPLY_STATUS_DISCHARGING; |
| 103 | else if (ec_byte & BAT_STAT_FULL) |
| 104 | val->intval = POWER_SUPPLY_STATUS_FULL; |
| 105 | else /* er,... */ |
| 106 | val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; |
| 107 | } else { |
| 108 | /* Older EC didn't report charge/discharge bits */ |
| 109 | if (!(ec_byte & BAT_STAT_AC)) /* No AC means discharging */ |
| 110 | val->intval = POWER_SUPPLY_STATUS_DISCHARGING; |
| 111 | else if (ec_byte & BAT_STAT_FULL) |
| 112 | val->intval = POWER_SUPPLY_STATUS_FULL; |
| 113 | else /* Not _necessarily_ true but EC doesn't tell all yet */ |
| 114 | val->intval = POWER_SUPPLY_STATUS_CHARGING; |
| 115 | } |
| 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | static int olpc_bat_get_health(union power_supply_propval *val) |
| 121 | { |
| 122 | uint8_t ec_byte; |
| 123 | int ret; |
| 124 | |
| 125 | ret = olpc_ec_cmd(EC_BAT_ERRCODE, NULL, 0, &ec_byte, 1); |
| 126 | if (ret) |
| 127 | return ret; |
| 128 | |
| 129 | switch (ec_byte) { |
| 130 | case 0: |
| 131 | val->intval = POWER_SUPPLY_HEALTH_GOOD; |
| 132 | break; |
| 133 | |
| 134 | case BAT_ERR_OVERTEMP: |
| 135 | val->intval = POWER_SUPPLY_HEALTH_OVERHEAT; |
| 136 | break; |
| 137 | |
| 138 | case BAT_ERR_OVERVOLTAGE: |
| 139 | val->intval = POWER_SUPPLY_HEALTH_OVERVOLTAGE; |
| 140 | break; |
| 141 | |
| 142 | case BAT_ERR_INFOFAIL: |
| 143 | case BAT_ERR_OUT_OF_CONTROL: |
| 144 | case BAT_ERR_ID_FAIL: |
| 145 | case BAT_ERR_ACR_FAIL: |
| 146 | val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; |
| 147 | break; |
| 148 | |
| 149 | default: |
| 150 | /* Eep. We don't know this failure code */ |
| 151 | ret = -EIO; |
| 152 | } |
| 153 | |
| 154 | return ret; |
| 155 | } |
| 156 | |
| 157 | static int olpc_bat_get_mfr(union power_supply_propval *val) |
| 158 | { |
| 159 | uint8_t ec_byte; |
| 160 | int ret; |
| 161 | |
| 162 | ec_byte = BAT_ADDR_MFR_TYPE; |
| 163 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1); |
| 164 | if (ret) |
| 165 | return ret; |
| 166 | |
| 167 | switch (ec_byte >> 4) { |
| 168 | case 1: |
| 169 | val->strval = "Gold Peak"; |
| 170 | break; |
| 171 | case 2: |
| 172 | val->strval = "BYD"; |
| 173 | break; |
| 174 | default: |
| 175 | val->strval = "Unknown"; |
| 176 | break; |
| 177 | } |
| 178 | |
| 179 | return ret; |
| 180 | } |
| 181 | |
| 182 | static int olpc_bat_get_tech(union power_supply_propval *val) |
| 183 | { |
| 184 | uint8_t ec_byte; |
| 185 | int ret; |
| 186 | |
| 187 | ec_byte = BAT_ADDR_MFR_TYPE; |
| 188 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1); |
| 189 | if (ret) |
| 190 | return ret; |
| 191 | |
| 192 | switch (ec_byte & 0xf) { |
| 193 | case 1: |
| 194 | val->intval = POWER_SUPPLY_TECHNOLOGY_NiMH; |
| 195 | break; |
| 196 | case 2: |
| 197 | val->intval = POWER_SUPPLY_TECHNOLOGY_LiFe; |
| 198 | break; |
| 199 | default: |
| 200 | val->intval = POWER_SUPPLY_TECHNOLOGY_UNKNOWN; |
| 201 | break; |
| 202 | } |
| 203 | |
| 204 | return ret; |
| 205 | } |
| 206 | |
Sascha Silbe | b202a5e | 2010-12-10 23:05:19 +0100 | [diff] [blame] | 207 | static int olpc_bat_get_charge_full_design(union power_supply_propval *val) |
| 208 | { |
| 209 | uint8_t ec_byte; |
| 210 | union power_supply_propval tech; |
| 211 | int ret, mfr; |
| 212 | |
| 213 | ret = olpc_bat_get_tech(&tech); |
| 214 | if (ret) |
| 215 | return ret; |
| 216 | |
| 217 | ec_byte = BAT_ADDR_MFR_TYPE; |
| 218 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1); |
| 219 | if (ret) |
| 220 | return ret; |
| 221 | |
| 222 | mfr = ec_byte >> 4; |
| 223 | |
| 224 | switch (tech.intval) { |
| 225 | case POWER_SUPPLY_TECHNOLOGY_NiMH: |
| 226 | switch (mfr) { |
| 227 | case 1: /* Gold Peak */ |
| 228 | val->intval = 3000000*.8; |
| 229 | break; |
| 230 | default: |
| 231 | return -EIO; |
| 232 | } |
| 233 | break; |
| 234 | |
| 235 | case POWER_SUPPLY_TECHNOLOGY_LiFe: |
| 236 | switch (mfr) { |
Richard A. Smith | ecc2edd | 2012-07-15 22:43:51 +0100 | [diff] [blame] | 237 | case 1: /* Gold Peak, fall through */ |
Sascha Silbe | b202a5e | 2010-12-10 23:05:19 +0100 | [diff] [blame] | 238 | case 2: /* BYD */ |
Richard A. Smith | ecc2edd | 2012-07-15 22:43:51 +0100 | [diff] [blame] | 239 | val->intval = 2800000; |
Sascha Silbe | b202a5e | 2010-12-10 23:05:19 +0100 | [diff] [blame] | 240 | break; |
| 241 | default: |
| 242 | return -EIO; |
| 243 | } |
| 244 | break; |
| 245 | |
| 246 | default: |
| 247 | return -EIO; |
| 248 | } |
| 249 | |
| 250 | return ret; |
| 251 | } |
| 252 | |
Sascha Silbe | 20fd983 | 2010-12-10 23:05:20 +0100 | [diff] [blame] | 253 | static int olpc_bat_get_charge_now(union power_supply_propval *val) |
| 254 | { |
| 255 | uint8_t soc; |
| 256 | union power_supply_propval full; |
| 257 | int ret; |
| 258 | |
| 259 | ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &soc, 1); |
| 260 | if (ret) |
| 261 | return ret; |
| 262 | |
| 263 | ret = olpc_bat_get_charge_full_design(&full); |
| 264 | if (ret) |
| 265 | return ret; |
| 266 | |
| 267 | val->intval = soc * (full.intval / 100); |
| 268 | return 0; |
| 269 | } |
| 270 | |
Richard A. Smith | 5619d0b | 2012-07-15 22:43:25 +0100 | [diff] [blame] | 271 | static int olpc_bat_get_voltage_max_design(union power_supply_propval *val) |
| 272 | { |
| 273 | uint8_t ec_byte; |
| 274 | union power_supply_propval tech; |
| 275 | int mfr; |
| 276 | int ret; |
| 277 | |
| 278 | ret = olpc_bat_get_tech(&tech); |
| 279 | if (ret) |
| 280 | return ret; |
| 281 | |
| 282 | ec_byte = BAT_ADDR_MFR_TYPE; |
| 283 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1); |
| 284 | if (ret) |
| 285 | return ret; |
| 286 | |
| 287 | mfr = ec_byte >> 4; |
| 288 | |
| 289 | switch (tech.intval) { |
| 290 | case POWER_SUPPLY_TECHNOLOGY_NiMH: |
| 291 | switch (mfr) { |
| 292 | case 1: /* Gold Peak */ |
| 293 | val->intval = 6000000; |
| 294 | break; |
| 295 | default: |
| 296 | return -EIO; |
| 297 | } |
| 298 | break; |
| 299 | |
| 300 | case POWER_SUPPLY_TECHNOLOGY_LiFe: |
| 301 | switch (mfr) { |
| 302 | case 1: /* Gold Peak */ |
| 303 | val->intval = 6400000; |
| 304 | break; |
| 305 | case 2: /* BYD */ |
| 306 | val->intval = 6500000; |
| 307 | break; |
| 308 | default: |
| 309 | return -EIO; |
| 310 | } |
| 311 | break; |
| 312 | |
| 313 | default: |
| 314 | return -EIO; |
| 315 | } |
| 316 | |
| 317 | return ret; |
| 318 | } |
| 319 | |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 320 | /********************************************************************* |
| 321 | * Battery properties |
| 322 | *********************************************************************/ |
| 323 | static int olpc_bat_get_property(struct power_supply *psy, |
| 324 | enum power_supply_property psp, |
| 325 | union power_supply_propval *val) |
| 326 | { |
| 327 | int ret = 0; |
Harvey Harrison | 8e9c771 | 2008-10-15 22:01:23 -0700 | [diff] [blame] | 328 | __be16 ec_word; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 329 | uint8_t ec_byte; |
Harvey Harrison | 8e9c771 | 2008-10-15 22:01:23 -0700 | [diff] [blame] | 330 | __be64 ser_buf; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 331 | |
| 332 | ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1); |
| 333 | if (ret) |
| 334 | return ret; |
| 335 | |
| 336 | /* Theoretically there's a race here -- the battery could be |
| 337 | removed immediately after we check whether it's present, and |
| 338 | then we query for some other property of the now-absent battery. |
| 339 | It doesn't matter though -- the EC will return the last-known |
| 340 | information, and it's as if we just ran that _little_ bit faster |
| 341 | and managed to read it out before the battery went away. */ |
Andres Salomon | 8f7e579 | 2009-06-30 02:16:17 -0400 | [diff] [blame] | 342 | if (!(ec_byte & (BAT_STAT_PRESENT | BAT_STAT_TRICKLE)) && |
| 343 | psp != POWER_SUPPLY_PROP_PRESENT) |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 344 | return -ENODEV; |
| 345 | |
| 346 | switch (psp) { |
| 347 | case POWER_SUPPLY_PROP_STATUS: |
Andres Salomon | b2bd8a3 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 348 | ret = olpc_bat_get_status(val, ec_byte); |
| 349 | if (ret) |
| 350 | return ret; |
| 351 | break; |
Andres Salomon | ee8076e | 2009-07-02 09:45:18 -0400 | [diff] [blame] | 352 | case POWER_SUPPLY_PROP_CHARGE_TYPE: |
| 353 | if (ec_byte & BAT_STAT_TRICKLE) |
| 354 | val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; |
| 355 | else if (ec_byte & BAT_STAT_CHARGING) |
| 356 | val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; |
| 357 | else |
| 358 | val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; |
| 359 | break; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 360 | case POWER_SUPPLY_PROP_PRESENT: |
Andres Salomon | 8f7e579 | 2009-06-30 02:16:17 -0400 | [diff] [blame] | 361 | val->intval = !!(ec_byte & (BAT_STAT_PRESENT | |
| 362 | BAT_STAT_TRICKLE)); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 363 | break; |
| 364 | |
| 365 | case POWER_SUPPLY_PROP_HEALTH: |
| 366 | if (ec_byte & BAT_STAT_DESTROY) |
| 367 | val->intval = POWER_SUPPLY_HEALTH_DEAD; |
| 368 | else { |
Andres Salomon | b2bd8a3 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 369 | ret = olpc_bat_get_health(val); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 370 | if (ret) |
| 371 | return ret; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 372 | } |
| 373 | break; |
| 374 | |
| 375 | case POWER_SUPPLY_PROP_MANUFACTURER: |
Andres Salomon | b2bd8a3 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 376 | ret = olpc_bat_get_mfr(val); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 377 | if (ret) |
| 378 | return ret; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 379 | break; |
| 380 | case POWER_SUPPLY_PROP_TECHNOLOGY: |
Andres Salomon | b2bd8a3 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 381 | ret = olpc_bat_get_tech(val); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 382 | if (ret) |
| 383 | return ret; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 384 | break; |
| 385 | case POWER_SUPPLY_PROP_VOLTAGE_AVG: |
Sascha Silbe | 22fadd7 | 2010-12-10 23:05:21 +0100 | [diff] [blame] | 386 | case POWER_SUPPLY_PROP_VOLTAGE_NOW: |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 387 | ret = olpc_ec_cmd(EC_BAT_VOLTAGE, NULL, 0, (void *)&ec_word, 2); |
| 388 | if (ret) |
| 389 | return ret; |
| 390 | |
Richard A. Smith | 7cfbb29 | 2010-09-25 19:19:26 +0100 | [diff] [blame] | 391 | val->intval = (s16)be16_to_cpu(ec_word) * 9760L / 32; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 392 | break; |
| 393 | case POWER_SUPPLY_PROP_CURRENT_AVG: |
Sascha Silbe | 22fadd7 | 2010-12-10 23:05:21 +0100 | [diff] [blame] | 394 | case POWER_SUPPLY_PROP_CURRENT_NOW: |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 395 | ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2); |
| 396 | if (ret) |
| 397 | return ret; |
| 398 | |
Richard A. Smith | 7cfbb29 | 2010-09-25 19:19:26 +0100 | [diff] [blame] | 399 | val->intval = (s16)be16_to_cpu(ec_word) * 15625L / 120; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 400 | break; |
| 401 | case POWER_SUPPLY_PROP_CAPACITY: |
| 402 | ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1); |
| 403 | if (ret) |
| 404 | return ret; |
| 405 | val->intval = ec_byte; |
| 406 | break; |
Andres Salomon | b294a29 | 2009-06-30 02:13:01 -0400 | [diff] [blame] | 407 | case POWER_SUPPLY_PROP_CAPACITY_LEVEL: |
| 408 | if (ec_byte & BAT_STAT_FULL) |
| 409 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_FULL; |
| 410 | else if (ec_byte & BAT_STAT_LOW) |
| 411 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_LOW; |
| 412 | else |
| 413 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; |
| 414 | break; |
Sascha Silbe | b202a5e | 2010-12-10 23:05:19 +0100 | [diff] [blame] | 415 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: |
| 416 | ret = olpc_bat_get_charge_full_design(val); |
| 417 | if (ret) |
| 418 | return ret; |
| 419 | break; |
Sascha Silbe | 20fd983 | 2010-12-10 23:05:20 +0100 | [diff] [blame] | 420 | case POWER_SUPPLY_PROP_CHARGE_NOW: |
| 421 | ret = olpc_bat_get_charge_now(val); |
| 422 | if (ret) |
| 423 | return ret; |
| 424 | break; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 425 | case POWER_SUPPLY_PROP_TEMP: |
| 426 | ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); |
| 427 | if (ret) |
| 428 | return ret; |
Harvey Harrison | 8e9c771 | 2008-10-15 22:01:23 -0700 | [diff] [blame] | 429 | |
Richard A. Smith | 7cfbb29 | 2010-09-25 19:19:26 +0100 | [diff] [blame] | 430 | val->intval = (s16)be16_to_cpu(ec_word) * 100 / 256; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 431 | break; |
| 432 | case POWER_SUPPLY_PROP_TEMP_AMBIENT: |
| 433 | ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); |
| 434 | if (ret) |
| 435 | return ret; |
| 436 | |
Harvey Harrison | 8e9c771 | 2008-10-15 22:01:23 -0700 | [diff] [blame] | 437 | val->intval = (int)be16_to_cpu(ec_word) * 100 / 256; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 438 | break; |
Andres Salomon | 8e552c3 | 2008-05-12 21:46:29 -0400 | [diff] [blame] | 439 | case POWER_SUPPLY_PROP_CHARGE_COUNTER: |
| 440 | ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2); |
| 441 | if (ret) |
| 442 | return ret; |
| 443 | |
Richard A. Smith | 7cfbb29 | 2010-09-25 19:19:26 +0100 | [diff] [blame] | 444 | val->intval = (s16)be16_to_cpu(ec_word) * 6250 / 15; |
Andres Salomon | 8e552c3 | 2008-05-12 21:46:29 -0400 | [diff] [blame] | 445 | break; |
David Woodhouse | 1ca5b9d | 2008-05-04 01:31:42 -0400 | [diff] [blame] | 446 | case POWER_SUPPLY_PROP_SERIAL_NUMBER: |
| 447 | ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8); |
| 448 | if (ret) |
| 449 | return ret; |
| 450 | |
| 451 | sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); |
| 452 | val->strval = bat_serial; |
| 453 | break; |
Richard A. Smith | 5619d0b | 2012-07-15 22:43:25 +0100 | [diff] [blame] | 454 | case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: |
| 455 | ret = olpc_bat_get_voltage_max_design(val); |
| 456 | if (ret) |
| 457 | return ret; |
| 458 | break; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 459 | default: |
| 460 | ret = -EINVAL; |
| 461 | break; |
| 462 | } |
| 463 | |
| 464 | return ret; |
| 465 | } |
| 466 | |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 467 | static enum power_supply_property olpc_xo1_bat_props[] = { |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 468 | POWER_SUPPLY_PROP_STATUS, |
Andres Salomon | ee8076e | 2009-07-02 09:45:18 -0400 | [diff] [blame] | 469 | POWER_SUPPLY_PROP_CHARGE_TYPE, |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 470 | POWER_SUPPLY_PROP_PRESENT, |
| 471 | POWER_SUPPLY_PROP_HEALTH, |
| 472 | POWER_SUPPLY_PROP_TECHNOLOGY, |
| 473 | POWER_SUPPLY_PROP_VOLTAGE_AVG, |
Sascha Silbe | 22fadd7 | 2010-12-10 23:05:21 +0100 | [diff] [blame] | 474 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 475 | POWER_SUPPLY_PROP_CURRENT_AVG, |
Sascha Silbe | 22fadd7 | 2010-12-10 23:05:21 +0100 | [diff] [blame] | 476 | POWER_SUPPLY_PROP_CURRENT_NOW, |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 477 | POWER_SUPPLY_PROP_CAPACITY, |
Andres Salomon | b294a29 | 2009-06-30 02:13:01 -0400 | [diff] [blame] | 478 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, |
Sascha Silbe | b202a5e | 2010-12-10 23:05:19 +0100 | [diff] [blame] | 479 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, |
Sascha Silbe | 20fd983 | 2010-12-10 23:05:20 +0100 | [diff] [blame] | 480 | POWER_SUPPLY_PROP_CHARGE_NOW, |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 481 | POWER_SUPPLY_PROP_TEMP, |
| 482 | POWER_SUPPLY_PROP_TEMP_AMBIENT, |
| 483 | POWER_SUPPLY_PROP_MANUFACTURER, |
David Woodhouse | 1ca5b9d | 2008-05-04 01:31:42 -0400 | [diff] [blame] | 484 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
Andres Salomon | 8e552c3 | 2008-05-12 21:46:29 -0400 | [diff] [blame] | 485 | POWER_SUPPLY_PROP_CHARGE_COUNTER, |
Richard A. Smith | 5619d0b | 2012-07-15 22:43:25 +0100 | [diff] [blame] | 486 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 487 | }; |
| 488 | |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 489 | /* XO-1.5 does not have ambient temperature property */ |
| 490 | static enum power_supply_property olpc_xo15_bat_props[] = { |
| 491 | POWER_SUPPLY_PROP_STATUS, |
| 492 | POWER_SUPPLY_PROP_CHARGE_TYPE, |
| 493 | POWER_SUPPLY_PROP_PRESENT, |
| 494 | POWER_SUPPLY_PROP_HEALTH, |
| 495 | POWER_SUPPLY_PROP_TECHNOLOGY, |
| 496 | POWER_SUPPLY_PROP_VOLTAGE_AVG, |
Sascha Silbe | bf542a4 | 2011-01-12 23:23:23 +0100 | [diff] [blame] | 497 | POWER_SUPPLY_PROP_VOLTAGE_NOW, |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 498 | POWER_SUPPLY_PROP_CURRENT_AVG, |
Sascha Silbe | bf542a4 | 2011-01-12 23:23:23 +0100 | [diff] [blame] | 499 | POWER_SUPPLY_PROP_CURRENT_NOW, |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 500 | POWER_SUPPLY_PROP_CAPACITY, |
| 501 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, |
Sascha Silbe | bf542a4 | 2011-01-12 23:23:23 +0100 | [diff] [blame] | 502 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, |
| 503 | POWER_SUPPLY_PROP_CHARGE_NOW, |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 504 | POWER_SUPPLY_PROP_TEMP, |
| 505 | POWER_SUPPLY_PROP_MANUFACTURER, |
| 506 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
| 507 | POWER_SUPPLY_PROP_CHARGE_COUNTER, |
Richard A. Smith | 5619d0b | 2012-07-15 22:43:25 +0100 | [diff] [blame] | 508 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 509 | }; |
| 510 | |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 511 | /* EEPROM reading goes completely around the power_supply API, sadly */ |
| 512 | |
| 513 | #define EEPROM_START 0x20 |
| 514 | #define EEPROM_END 0x80 |
| 515 | #define EEPROM_SIZE (EEPROM_END - EEPROM_START) |
| 516 | |
Chris Wright | 2c3c8be | 2010-05-12 18:28:57 -0700 | [diff] [blame] | 517 | static ssize_t olpc_bat_eeprom_read(struct file *filp, struct kobject *kobj, |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 518 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) |
| 519 | { |
| 520 | uint8_t ec_byte; |
Andres Salomon | 04a820e | 2009-06-30 02:14:00 -0400 | [diff] [blame] | 521 | int ret; |
| 522 | int i; |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 523 | |
Andres Salomon | 04a820e | 2009-06-30 02:14:00 -0400 | [diff] [blame] | 524 | for (i = 0; i < count; i++) { |
| 525 | ec_byte = EEPROM_START + off + i; |
| 526 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &buf[i], 1); |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 527 | if (ret) { |
Andres Salomon | 04a820e | 2009-06-30 02:14:00 -0400 | [diff] [blame] | 528 | pr_err("olpc-battery: " |
| 529 | "EC_BAT_EEPROM cmd @ 0x%x failed - %d!\n", |
| 530 | ec_byte, ret); |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 531 | return -EIO; |
| 532 | } |
| 533 | } |
| 534 | |
| 535 | return count; |
| 536 | } |
| 537 | |
| 538 | static struct bin_attribute olpc_bat_eeprom = { |
| 539 | .attr = { |
| 540 | .name = "eeprom", |
| 541 | .mode = S_IRUGO, |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 542 | }, |
Vladimir Zapolskiy | 3e1d9c6 | 2015-07-27 00:26:49 +0300 | [diff] [blame] | 543 | .size = EEPROM_SIZE, |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 544 | .read = olpc_bat_eeprom_read, |
| 545 | }; |
| 546 | |
Andres Salomon | 144bbea | 2009-06-30 02:15:26 -0400 | [diff] [blame] | 547 | /* Allow userspace to see the specific error value pulled from the EC */ |
| 548 | |
| 549 | static ssize_t olpc_bat_error_read(struct device *dev, |
| 550 | struct device_attribute *attr, char *buf) |
| 551 | { |
| 552 | uint8_t ec_byte; |
| 553 | ssize_t ret; |
| 554 | |
| 555 | ret = olpc_ec_cmd(EC_BAT_ERRCODE, NULL, 0, &ec_byte, 1); |
| 556 | if (ret < 0) |
| 557 | return ret; |
| 558 | |
| 559 | return sprintf(buf, "%d\n", ec_byte); |
| 560 | } |
| 561 | |
| 562 | static struct device_attribute olpc_bat_error = { |
| 563 | .attr = { |
| 564 | .name = "error", |
| 565 | .mode = S_IRUGO, |
| 566 | }, |
| 567 | .show = olpc_bat_error_read, |
| 568 | }; |
| 569 | |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 570 | /********************************************************************* |
| 571 | * Initialisation |
| 572 | *********************************************************************/ |
| 573 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 574 | static struct power_supply_desc olpc_bat_desc = { |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 575 | .name = "olpc-battery", |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 576 | .get_property = olpc_bat_get_property, |
| 577 | .use_for_apm = 1, |
| 578 | }; |
| 579 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 580 | static struct power_supply *olpc_bat; |
| 581 | |
Daniel Drake | cae659a | 2011-08-10 21:46:02 +0100 | [diff] [blame] | 582 | static int olpc_battery_suspend(struct platform_device *pdev, |
| 583 | pm_message_t state) |
| 584 | { |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 585 | if (device_may_wakeup(&olpc_ac->dev)) |
Daniel Drake | cae659a | 2011-08-10 21:46:02 +0100 | [diff] [blame] | 586 | olpc_ec_wakeup_set(EC_SCI_SRC_ACPWR); |
| 587 | else |
| 588 | olpc_ec_wakeup_clear(EC_SCI_SRC_ACPWR); |
| 589 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 590 | if (device_may_wakeup(&olpc_bat->dev)) |
Daniel Drake | cae659a | 2011-08-10 21:46:02 +0100 | [diff] [blame] | 591 | olpc_ec_wakeup_set(EC_SCI_SRC_BATTERY | EC_SCI_SRC_BATSOC |
| 592 | | EC_SCI_SRC_BATERR); |
| 593 | else |
| 594 | olpc_ec_wakeup_clear(EC_SCI_SRC_BATTERY | EC_SCI_SRC_BATSOC |
| 595 | | EC_SCI_SRC_BATERR); |
| 596 | |
| 597 | return 0; |
| 598 | } |
| 599 | |
Bill Pemberton | c8afa64 | 2012-11-19 13:22:23 -0500 | [diff] [blame] | 600 | static int olpc_battery_probe(struct platform_device *pdev) |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 601 | { |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 602 | int ret; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 603 | uint8_t status; |
| 604 | |
Andres Salomon | 484d6d5 | 2008-05-02 13:41:59 -0700 | [diff] [blame] | 605 | /* |
| 606 | * We've seen a number of EC protocol changes; this driver requires |
| 607 | * the latest EC protocol, supported by 0x44 and above. |
| 608 | */ |
| 609 | if (olpc_platform_info.ecver < 0x44) { |
| 610 | printk(KERN_NOTICE "OLPC EC version 0x%02x too old for " |
| 611 | "battery driver.\n", olpc_platform_info.ecver); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 612 | return -ENXIO; |
| 613 | } |
| 614 | |
| 615 | ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &status, 1); |
| 616 | if (ret) |
| 617 | return ret; |
| 618 | |
| 619 | /* Ignore the status. It doesn't actually matter */ |
| 620 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 621 | olpc_ac = power_supply_register(&pdev->dev, &olpc_ac_desc, NULL); |
| 622 | if (IS_ERR(olpc_ac)) |
| 623 | return PTR_ERR(olpc_ac); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 624 | |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 625 | if (olpc_board_at_least(olpc_board_pre(0xd0))) { /* XO-1.5 */ |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 626 | olpc_bat_desc.properties = olpc_xo15_bat_props; |
| 627 | olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo15_bat_props); |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 628 | } else { /* XO-1 */ |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 629 | olpc_bat_desc.properties = olpc_xo1_bat_props; |
| 630 | olpc_bat_desc.num_properties = ARRAY_SIZE(olpc_xo1_bat_props); |
Daniel Drake | c566d29 | 2010-12-29 19:12:01 +0000 | [diff] [blame] | 631 | } |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 632 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 633 | olpc_bat = power_supply_register(&pdev->dev, &olpc_bat_desc, NULL); |
| 634 | if (IS_ERR(olpc_bat)) { |
| 635 | ret = PTR_ERR(olpc_bat); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 636 | goto battery_failed; |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 637 | } |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 638 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 639 | ret = device_create_bin_file(&olpc_bat->dev, &olpc_bat_eeprom); |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 640 | if (ret) |
| 641 | goto eeprom_failed; |
| 642 | |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 643 | ret = device_create_file(&olpc_bat->dev, &olpc_bat_error); |
Andres Salomon | 144bbea | 2009-06-30 02:15:26 -0400 | [diff] [blame] | 644 | if (ret) |
| 645 | goto error_failed; |
| 646 | |
Daniel Drake | cae659a | 2011-08-10 21:46:02 +0100 | [diff] [blame] | 647 | if (olpc_ec_wakeup_available()) { |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 648 | device_set_wakeup_capable(&olpc_ac->dev, true); |
| 649 | device_set_wakeup_capable(&olpc_bat->dev, true); |
Daniel Drake | cae659a | 2011-08-10 21:46:02 +0100 | [diff] [blame] | 650 | } |
| 651 | |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 652 | return 0; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 653 | |
Andres Salomon | 144bbea | 2009-06-30 02:15:26 -0400 | [diff] [blame] | 654 | error_failed: |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 655 | device_remove_bin_file(&olpc_bat->dev, &olpc_bat_eeprom); |
Andres Salomon | d7eb9e3 | 2008-05-02 13:41:58 -0700 | [diff] [blame] | 656 | eeprom_failed: |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 657 | power_supply_unregister(olpc_bat); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 658 | battery_failed: |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 659 | power_supply_unregister(olpc_ac); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 660 | return ret; |
| 661 | } |
| 662 | |
Bill Pemberton | 415ec69 | 2012-11-19 13:26:07 -0500 | [diff] [blame] | 663 | static int olpc_battery_remove(struct platform_device *pdev) |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 664 | { |
Krzysztof Kozlowski | 297d716 | 2015-03-12 08:44:11 +0100 | [diff] [blame] | 665 | device_remove_file(&olpc_bat->dev, &olpc_bat_error); |
| 666 | device_remove_bin_file(&olpc_bat->dev, &olpc_bat_eeprom); |
| 667 | power_supply_unregister(olpc_bat); |
| 668 | power_supply_unregister(olpc_ac); |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 669 | return 0; |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 670 | } |
| 671 | |
Greg Kroah-Hartman | 6d2cea4 | 2012-12-21 15:04:54 -0800 | [diff] [blame] | 672 | static const struct of_device_id olpc_battery_ids[] = { |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 673 | { .compatible = "olpc,xo1-battery" }, |
| 674 | {} |
| 675 | }; |
| 676 | MODULE_DEVICE_TABLE(of, olpc_battery_ids); |
| 677 | |
Anton Vorontsov | 5519d00 | 2011-11-24 22:49:07 +0400 | [diff] [blame] | 678 | static struct platform_driver olpc_battery_driver = { |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 679 | .driver = { |
| 680 | .name = "olpc-battery", |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 681 | .of_match_table = olpc_battery_ids, |
| 682 | }, |
| 683 | .probe = olpc_battery_probe, |
Bill Pemberton | 28ea73f | 2012-11-19 13:20:40 -0500 | [diff] [blame] | 684 | .remove = olpc_battery_remove, |
Daniel Drake | cae659a | 2011-08-10 21:46:02 +0100 | [diff] [blame] | 685 | .suspend = olpc_battery_suspend, |
Daniel Drake | c3503fd | 2011-08-10 21:45:36 +0100 | [diff] [blame] | 686 | }; |
| 687 | |
Axel Lin | 300bac7 | 2011-11-26 12:01:10 +0800 | [diff] [blame] | 688 | module_platform_driver(olpc_battery_driver); |
David Woodhouse | fb97287 | 2007-05-04 00:51:18 +0400 | [diff] [blame] | 689 | |
| 690 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); |
| 691 | MODULE_LICENSE("GPL"); |
| 692 | MODULE_DESCRIPTION("Battery driver for One Laptop Per Child 'XO' machine"); |