2 * 1-wire client/driver for the Maxim/Dallas DS2781 Stand-Alone Fuel Gauge IC
4 * Author: Renata Sayakhova <renata@oktetlabs.ru>
6 * Based on ds2780_battery drivers
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
14 #include <linux/module.h>
15 #include <linux/slab.h>
16 #include <linux/param.h>
18 #include <linux/platform_device.h>
19 #include <linux/power_supply.h>
20 #include <linux/idr.h>
23 #include "../w1/slaves/w1_ds2781.h"
25 /* Current unit measurement in uA for a 1 milli-ohm sense resistor */
26 #define DS2781_CURRENT_UNITS 1563
27 /* Charge unit measurement in uAh for a 1 milli-ohm sense resistor */
28 #define DS2781_CHARGE_UNITS 6250
29 /* Number of bytes in user EEPROM space */
30 #define DS2781_USER_EEPROM_SIZE (DS2781_EEPROM_BLOCK0_END - \
31 DS2781_EEPROM_BLOCK0_START + 1)
32 /* Number of bytes in parameter EEPROM space */
33 #define DS2781_PARAM_EEPROM_SIZE (DS2781_EEPROM_BLOCK1_END - \
34 DS2781_EEPROM_BLOCK1_START + 1)
36 struct ds2781_device_info
{
38 struct power_supply bat
;
39 struct device
*w1_dev
;
40 struct task_struct
*mutex_holder
;
48 static const char model
[] = "DS2781";
49 static const char manufacturer
[] = "Maxim/Dallas";
51 static inline struct ds2781_device_info
*
52 to_ds2781_device_info(struct power_supply
*psy
)
54 return container_of(psy
, struct ds2781_device_info
, bat
);
57 static inline struct power_supply
*to_power_supply(struct device
*dev
)
59 return dev_get_drvdata(dev
);
62 static inline int ds2781_battery_io(struct ds2781_device_info
*dev_info
,
63 char *buf
, int addr
, size_t count
, int io
)
65 if (dev_info
->mutex_holder
== current
)
66 return w1_ds2781_io_nolock(dev_info
->w1_dev
, buf
, addr
,
69 return w1_ds2781_io(dev_info
->w1_dev
, buf
, addr
, count
, io
);
72 int w1_ds2781_read(struct ds2781_device_info
*dev_info
, char *buf
,
73 int addr
, size_t count
)
75 return ds2781_battery_io(dev_info
, buf
, addr
, count
, 0);
78 static inline int ds2781_read8(struct ds2781_device_info
*dev_info
, u8
*val
,
81 return ds2781_battery_io(dev_info
, val
, addr
, sizeof(u8
), 0);
84 static int ds2781_read16(struct ds2781_device_info
*dev_info
, s16
*val
,
90 ret
= ds2781_battery_io(dev_info
, raw
, addr
, sizeof(raw
), 0);
94 *val
= (raw
[0] << 8) | raw
[1];
99 static inline int ds2781_read_block(struct ds2781_device_info
*dev_info
,
100 u8
*val
, int addr
, size_t count
)
102 return ds2781_battery_io(dev_info
, val
, addr
, count
, 0);
105 static inline int ds2781_write(struct ds2781_device_info
*dev_info
, u8
*val
,
106 int addr
, size_t count
)
108 return ds2781_battery_io(dev_info
, val
, addr
, count
, 1);
111 static inline int ds2781_store_eeprom(struct device
*dev
, int addr
)
113 return w1_ds2781_eeprom_cmd(dev
, addr
, W1_DS2781_COPY_DATA
);
116 static inline int ds2781_recall_eeprom(struct device
*dev
, int addr
)
118 return w1_ds2781_eeprom_cmd(dev
, addr
, W1_DS2781_RECALL_DATA
);
121 static int ds2781_save_eeprom(struct ds2781_device_info
*dev_info
, int reg
)
125 ret
= ds2781_store_eeprom(dev_info
->w1_dev
, reg
);
129 ret
= ds2781_recall_eeprom(dev_info
->w1_dev
, reg
);
136 /* Set sense resistor value in mhos */
137 static int ds2781_set_sense_register(struct ds2781_device_info
*dev_info
,
142 ret
= ds2781_write(dev_info
, &conductance
,
143 DS2781_RSNSP
, sizeof(u8
));
147 return ds2781_save_eeprom(dev_info
, DS2781_RSNSP
);
150 /* Get RSGAIN value from 0 to 1.999 in steps of 0.001 */
151 static int ds2781_get_rsgain_register(struct ds2781_device_info
*dev_info
,
154 return ds2781_read16(dev_info
, rsgain
, DS2781_RSGAIN_MSB
);
157 /* Set RSGAIN value from 0 to 1.999 in steps of 0.001 */
158 static int ds2781_set_rsgain_register(struct ds2781_device_info
*dev_info
,
162 u8 raw
[] = {rsgain
>> 8, rsgain
& 0xFF};
164 ret
= ds2781_write(dev_info
, raw
,
165 DS2781_RSGAIN_MSB
, sizeof(raw
));
169 return ds2781_save_eeprom(dev_info
, DS2781_RSGAIN_MSB
);
172 static int ds2781_get_voltage(struct ds2781_device_info
*dev_info
,
179 ret
= w1_ds2781_read(dev_info
, val
, DS2781_VOLT_MSB
, 2 * sizeof(u8
));
183 * The voltage value is located in 10 bits across the voltage MSB
184 * and LSB registers in two's compliment form
185 * Sign bit of the voltage value is in bit 7 of the voltage MSB register
186 * Bits 9 - 3 of the voltage value are in bits 6 - 0 of the
187 * voltage MSB register
188 * Bits 2 - 0 of the voltage value are in bits 7 - 5 of the
189 * voltage LSB register
191 voltage_raw
= (val
[0] << 3) |
194 /* DS2781 reports voltage in units of 9.76mV, but the battery class
195 * reports in units of uV, so convert by multiplying by 9760. */
196 *voltage_uV
= voltage_raw
* 9760;
201 static int ds2781_get_temperature(struct ds2781_device_info
*dev_info
,
208 ret
= w1_ds2781_read(dev_info
, val
, DS2781_TEMP_MSB
, 2 * sizeof(u8
));
212 * The temperature value is located in 10 bits across the temperature
213 * MSB and LSB registers in two's compliment form
214 * Sign bit of the temperature value is in bit 7 of the temperature
216 * Bits 9 - 3 of the temperature value are in bits 6 - 0 of the
217 * temperature MSB register
218 * Bits 2 - 0 of the temperature value are in bits 7 - 5 of the
219 * temperature LSB register
221 temp_raw
= ((val
[0]) << 3) |
223 *temp
= temp_raw
+ (temp_raw
/ 4);
228 static int ds2781_get_current(struct ds2781_device_info
*dev_info
,
229 enum current_types type
, int *current_uA
)
233 u8 sense_res_raw
, reg_msb
;
236 * The units of measurement for current are dependent on the value of
237 * the sense resistor.
239 ret
= ds2781_read8(dev_info
, &sense_res_raw
, DS2781_RSNSP
);
243 if (sense_res_raw
== 0) {
244 dev_err(dev_info
->dev
, "sense resistor value is 0\n");
247 sense_res
= 1000 / sense_res_raw
;
249 if (type
== CURRENT_NOW
)
250 reg_msb
= DS2781_CURRENT_MSB
;
251 else if (type
== CURRENT_AVG
)
252 reg_msb
= DS2781_IAVG_MSB
;
257 * The current value is located in 16 bits across the current MSB
258 * and LSB registers in two's compliment form
259 * Sign bit of the current value is in bit 7 of the current MSB register
260 * Bits 14 - 8 of the current value are in bits 6 - 0 of the current
262 * Bits 7 - 0 of the current value are in bits 7 - 0 of the current
265 ret
= ds2781_read16(dev_info
, ¤t_raw
, reg_msb
);
269 *current_uA
= current_raw
* (DS2781_CURRENT_UNITS
/ sense_res
);
273 static int ds2781_get_accumulated_current(struct ds2781_device_info
*dev_info
,
274 int *accumulated_current
)
281 * The units of measurement for accumulated current are dependent on
282 * the value of the sense resistor.
284 ret
= ds2781_read8(dev_info
, &sense_res_raw
, DS2781_RSNSP
);
288 if (sense_res_raw
== 0) {
289 dev_err(dev_info
->dev
, "sense resistor value is 0\n");
292 sense_res
= 1000 / sense_res_raw
;
295 * The ACR value is located in 16 bits across the ACR MSB and
297 * Bits 15 - 8 of the ACR value are in bits 7 - 0 of the ACR
299 * Bits 7 - 0 of the ACR value are in bits 7 - 0 of the ACR
302 ret
= ds2781_read16(dev_info
, ¤t_raw
, DS2781_ACR_MSB
);
306 *accumulated_current
= current_raw
* (DS2781_CHARGE_UNITS
/ sense_res
);
310 static int ds2781_get_capacity(struct ds2781_device_info
*dev_info
,
316 ret
= ds2781_read8(dev_info
, &raw
, DS2781_RARC
);
324 static int ds2781_get_status(struct ds2781_device_info
*dev_info
, int *status
)
326 int ret
, current_uA
, capacity
;
328 ret
= ds2781_get_current(dev_info
, CURRENT_NOW
, ¤t_uA
);
332 ret
= ds2781_get_capacity(dev_info
, &capacity
);
336 if (power_supply_am_i_supplied(&dev_info
->bat
)) {
338 *status
= POWER_SUPPLY_STATUS_FULL
;
339 else if (current_uA
> 50000)
340 *status
= POWER_SUPPLY_STATUS_CHARGING
;
342 *status
= POWER_SUPPLY_STATUS_NOT_CHARGING
;
344 *status
= POWER_SUPPLY_STATUS_DISCHARGING
;
349 static int ds2781_get_charge_now(struct ds2781_device_info
*dev_info
,
356 * The RAAC value is located in 16 bits across the RAAC MSB and
358 * Bits 15 - 8 of the RAAC value are in bits 7 - 0 of the RAAC
360 * Bits 7 - 0 of the RAAC value are in bits 7 - 0 of the RAAC
363 ret
= ds2781_read16(dev_info
, &charge_raw
, DS2781_RAAC_MSB
);
367 *charge_now
= charge_raw
* 1600;
371 static int ds2781_get_control_register(struct ds2781_device_info
*dev_info
,
374 return ds2781_read8(dev_info
, control_reg
, DS2781_CONTROL
);
377 static int ds2781_set_control_register(struct ds2781_device_info
*dev_info
,
382 ret
= ds2781_write(dev_info
, &control_reg
,
383 DS2781_CONTROL
, sizeof(u8
));
387 return ds2781_save_eeprom(dev_info
, DS2781_CONTROL
);
390 static int ds2781_battery_get_property(struct power_supply
*psy
,
391 enum power_supply_property psp
,
392 union power_supply_propval
*val
)
395 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
398 case POWER_SUPPLY_PROP_VOLTAGE_NOW
:
399 ret
= ds2781_get_voltage(dev_info
, &val
->intval
);
402 case POWER_SUPPLY_PROP_TEMP
:
403 ret
= ds2781_get_temperature(dev_info
, &val
->intval
);
406 case POWER_SUPPLY_PROP_MODEL_NAME
:
410 case POWER_SUPPLY_PROP_MANUFACTURER
:
411 val
->strval
= manufacturer
;
414 case POWER_SUPPLY_PROP_CURRENT_NOW
:
415 ret
= ds2781_get_current(dev_info
, CURRENT_NOW
, &val
->intval
);
418 case POWER_SUPPLY_PROP_CURRENT_AVG
:
419 ret
= ds2781_get_current(dev_info
, CURRENT_AVG
, &val
->intval
);
422 case POWER_SUPPLY_PROP_STATUS
:
423 ret
= ds2781_get_status(dev_info
, &val
->intval
);
426 case POWER_SUPPLY_PROP_CAPACITY
:
427 ret
= ds2781_get_capacity(dev_info
, &val
->intval
);
430 case POWER_SUPPLY_PROP_CHARGE_COUNTER
:
431 ret
= ds2781_get_accumulated_current(dev_info
, &val
->intval
);
434 case POWER_SUPPLY_PROP_CHARGE_NOW
:
435 ret
= ds2781_get_charge_now(dev_info
, &val
->intval
);
445 static enum power_supply_property ds2781_battery_props
[] = {
446 POWER_SUPPLY_PROP_STATUS
,
447 POWER_SUPPLY_PROP_VOLTAGE_NOW
,
448 POWER_SUPPLY_PROP_TEMP
,
449 POWER_SUPPLY_PROP_MODEL_NAME
,
450 POWER_SUPPLY_PROP_MANUFACTURER
,
451 POWER_SUPPLY_PROP_CURRENT_NOW
,
452 POWER_SUPPLY_PROP_CURRENT_AVG
,
453 POWER_SUPPLY_PROP_CAPACITY
,
454 POWER_SUPPLY_PROP_CHARGE_COUNTER
,
455 POWER_SUPPLY_PROP_CHARGE_NOW
,
458 static ssize_t
ds2781_get_pmod_enabled(struct device
*dev
,
459 struct device_attribute
*attr
,
464 struct power_supply
*psy
= to_power_supply(dev
);
465 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
468 ret
= ds2781_get_control_register(dev_info
, &control_reg
);
472 return sprintf(buf
, "%d\n",
473 !!(control_reg
& DS2781_CONTROL_PMOD
));
476 static ssize_t
ds2781_set_pmod_enabled(struct device
*dev
,
477 struct device_attribute
*attr
,
482 u8 control_reg
, new_setting
;
483 struct power_supply
*psy
= to_power_supply(dev
);
484 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
487 ret
= ds2781_get_control_register(dev_info
, &control_reg
);
491 ret
= kstrtou8(buf
, 0, &new_setting
);
495 if ((new_setting
!= 0) && (new_setting
!= 1)) {
496 dev_err(dev_info
->dev
, "Invalid pmod setting (0 or 1)\n");
501 control_reg
|= DS2781_CONTROL_PMOD
;
503 control_reg
&= ~DS2781_CONTROL_PMOD
;
505 ret
= ds2781_set_control_register(dev_info
, control_reg
);
512 static ssize_t
ds2781_get_sense_resistor_value(struct device
*dev
,
513 struct device_attribute
*attr
,
518 struct power_supply
*psy
= to_power_supply(dev
);
519 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
521 ret
= ds2781_read8(dev_info
, &sense_resistor
, DS2781_RSNSP
);
525 ret
= sprintf(buf
, "%d\n", sense_resistor
);
529 static ssize_t
ds2781_set_sense_resistor_value(struct device
*dev
,
530 struct device_attribute
*attr
,
536 struct power_supply
*psy
= to_power_supply(dev
);
537 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
539 ret
= kstrtou8(buf
, 0, &new_setting
);
543 ret
= ds2781_set_sense_register(dev_info
, new_setting
);
550 static ssize_t
ds2781_get_rsgain_setting(struct device
*dev
,
551 struct device_attribute
*attr
,
556 struct power_supply
*psy
= to_power_supply(dev
);
557 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
559 ret
= ds2781_get_rsgain_register(dev_info
, &rsgain
);
563 return sprintf(buf
, "%d\n", rsgain
);
566 static ssize_t
ds2781_set_rsgain_setting(struct device
*dev
,
567 struct device_attribute
*attr
,
573 struct power_supply
*psy
= to_power_supply(dev
);
574 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
576 ret
= kstrtou16(buf
, 0, &new_setting
);
580 /* Gain can only be from 0 to 1.999 in steps of .001 */
581 if (new_setting
> 1999) {
582 dev_err(dev_info
->dev
, "Invalid rsgain setting (0 - 1999)\n");
586 ret
= ds2781_set_rsgain_register(dev_info
, new_setting
);
593 static ssize_t
ds2781_get_pio_pin(struct device
*dev
,
594 struct device_attribute
*attr
,
599 struct power_supply
*psy
= to_power_supply(dev
);
600 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
602 ret
= ds2781_read8(dev_info
, &sfr
, DS2781_SFR
);
606 ret
= sprintf(buf
, "%d\n", sfr
& DS2781_SFR_PIOSC
);
610 static ssize_t
ds2781_set_pio_pin(struct device
*dev
,
611 struct device_attribute
*attr
,
617 struct power_supply
*psy
= to_power_supply(dev
);
618 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
620 ret
= kstrtou8(buf
, 0, &new_setting
);
624 if ((new_setting
!= 0) && (new_setting
!= 1)) {
625 dev_err(dev_info
->dev
, "Invalid pio_pin setting (0 or 1)\n");
629 ret
= ds2781_write(dev_info
, &new_setting
,
630 DS2781_SFR
, sizeof(u8
));
637 static ssize_t
ds2781_read_param_eeprom_bin(struct file
*filp
,
638 struct kobject
*kobj
,
639 struct bin_attribute
*bin_attr
,
640 char *buf
, loff_t off
, size_t count
)
642 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
643 struct power_supply
*psy
= to_power_supply(dev
);
644 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
646 count
= min_t(loff_t
, count
, DS2781_PARAM_EEPROM_SIZE
- off
);
648 return ds2781_read_block(dev_info
, buf
,
649 DS2781_EEPROM_BLOCK1_START
+ off
, count
);
652 static ssize_t
ds2781_write_param_eeprom_bin(struct file
*filp
,
653 struct kobject
*kobj
,
654 struct bin_attribute
*bin_attr
,
655 char *buf
, loff_t off
, size_t count
)
657 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
658 struct power_supply
*psy
= to_power_supply(dev
);
659 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
662 count
= min_t(loff_t
, count
, DS2781_PARAM_EEPROM_SIZE
- off
);
664 ret
= ds2781_write(dev_info
, buf
,
665 DS2781_EEPROM_BLOCK1_START
+ off
, count
);
669 ret
= ds2781_save_eeprom(dev_info
, DS2781_EEPROM_BLOCK1_START
);
676 static struct bin_attribute ds2781_param_eeprom_bin_attr
= {
678 .name
= "param_eeprom",
679 .mode
= S_IRUGO
| S_IWUSR
,
681 .size
= DS2781_PARAM_EEPROM_SIZE
,
682 .read
= ds2781_read_param_eeprom_bin
,
683 .write
= ds2781_write_param_eeprom_bin
,
686 static ssize_t
ds2781_read_user_eeprom_bin(struct file
*filp
,
687 struct kobject
*kobj
,
688 struct bin_attribute
*bin_attr
,
689 char *buf
, loff_t off
, size_t count
)
691 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
692 struct power_supply
*psy
= to_power_supply(dev
);
693 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
695 count
= min_t(loff_t
, count
, DS2781_USER_EEPROM_SIZE
- off
);
697 return ds2781_read_block(dev_info
, buf
,
698 DS2781_EEPROM_BLOCK0_START
+ off
, count
);
702 static ssize_t
ds2781_write_user_eeprom_bin(struct file
*filp
,
703 struct kobject
*kobj
,
704 struct bin_attribute
*bin_attr
,
705 char *buf
, loff_t off
, size_t count
)
707 struct device
*dev
= container_of(kobj
, struct device
, kobj
);
708 struct power_supply
*psy
= to_power_supply(dev
);
709 struct ds2781_device_info
*dev_info
= to_ds2781_device_info(psy
);
712 count
= min_t(loff_t
, count
, DS2781_USER_EEPROM_SIZE
- off
);
714 ret
= ds2781_write(dev_info
, buf
,
715 DS2781_EEPROM_BLOCK0_START
+ off
, count
);
719 ret
= ds2781_save_eeprom(dev_info
, DS2781_EEPROM_BLOCK0_START
);
726 static struct bin_attribute ds2781_user_eeprom_bin_attr
= {
728 .name
= "user_eeprom",
729 .mode
= S_IRUGO
| S_IWUSR
,
731 .size
= DS2781_USER_EEPROM_SIZE
,
732 .read
= ds2781_read_user_eeprom_bin
,
733 .write
= ds2781_write_user_eeprom_bin
,
736 static DEVICE_ATTR(pmod_enabled
, S_IRUGO
| S_IWUSR
, ds2781_get_pmod_enabled
,
737 ds2781_set_pmod_enabled
);
738 static DEVICE_ATTR(sense_resistor_value
, S_IRUGO
| S_IWUSR
,
739 ds2781_get_sense_resistor_value
, ds2781_set_sense_resistor_value
);
740 static DEVICE_ATTR(rsgain_setting
, S_IRUGO
| S_IWUSR
, ds2781_get_rsgain_setting
,
741 ds2781_set_rsgain_setting
);
742 static DEVICE_ATTR(pio_pin
, S_IRUGO
| S_IWUSR
, ds2781_get_pio_pin
,
746 static struct attribute
*ds2781_attributes
[] = {
747 &dev_attr_pmod_enabled
.attr
,
748 &dev_attr_sense_resistor_value
.attr
,
749 &dev_attr_rsgain_setting
.attr
,
750 &dev_attr_pio_pin
.attr
,
754 static const struct attribute_group ds2781_attr_group
= {
755 .attrs
= ds2781_attributes
,
758 static int __devinit
ds2781_battery_probe(struct platform_device
*pdev
)
761 struct ds2781_device_info
*dev_info
;
763 dev_info
= kzalloc(sizeof(*dev_info
), GFP_KERNEL
);
769 platform_set_drvdata(pdev
, dev_info
);
771 dev_info
->dev
= &pdev
->dev
;
772 dev_info
->w1_dev
= pdev
->dev
.parent
;
773 dev_info
->bat
.name
= dev_name(&pdev
->dev
);
774 dev_info
->bat
.type
= POWER_SUPPLY_TYPE_BATTERY
;
775 dev_info
->bat
.properties
= ds2781_battery_props
;
776 dev_info
->bat
.num_properties
= ARRAY_SIZE(ds2781_battery_props
);
777 dev_info
->bat
.get_property
= ds2781_battery_get_property
;
778 dev_info
->mutex_holder
= current
;
780 ret
= power_supply_register(&pdev
->dev
, &dev_info
->bat
);
782 dev_err(dev_info
->dev
, "failed to register battery\n");
786 ret
= sysfs_create_group(&dev_info
->bat
.dev
->kobj
, &ds2781_attr_group
);
788 dev_err(dev_info
->dev
, "failed to create sysfs group\n");
789 goto fail_unregister
;
792 ret
= sysfs_create_bin_file(&dev_info
->bat
.dev
->kobj
,
793 &ds2781_param_eeprom_bin_attr
);
795 dev_err(dev_info
->dev
,
796 "failed to create param eeprom bin file");
797 goto fail_remove_group
;
800 ret
= sysfs_create_bin_file(&dev_info
->bat
.dev
->kobj
,
801 &ds2781_user_eeprom_bin_attr
);
803 dev_err(dev_info
->dev
,
804 "failed to create user eeprom bin file");
805 goto fail_remove_bin_file
;
808 dev_info
->mutex_holder
= NULL
;
812 fail_remove_bin_file
:
813 sysfs_remove_bin_file(&dev_info
->bat
.dev
->kobj
,
814 &ds2781_param_eeprom_bin_attr
);
816 sysfs_remove_group(&dev_info
->bat
.dev
->kobj
, &ds2781_attr_group
);
818 power_supply_unregister(&dev_info
->bat
);
825 static int __devexit
ds2781_battery_remove(struct platform_device
*pdev
)
827 struct ds2781_device_info
*dev_info
= platform_get_drvdata(pdev
);
829 dev_info
->mutex_holder
= current
;
831 /* remove attributes */
832 sysfs_remove_group(&dev_info
->bat
.dev
->kobj
, &ds2781_attr_group
);
834 power_supply_unregister(&dev_info
->bat
);
840 static struct platform_driver ds2781_battery_driver
= {
842 .name
= "ds2781-battery",
844 .probe
= ds2781_battery_probe
,
845 .remove
= __devexit_p(ds2781_battery_remove
),
848 static int __init
ds2781_battery_init(void)
850 return platform_driver_register(&ds2781_battery_driver
);
853 static void __exit
ds2781_battery_exit(void)
855 platform_driver_unregister(&ds2781_battery_driver
);
858 module_init(ds2781_battery_init
);
859 module_exit(ds2781_battery_exit
);
862 MODULE_LICENSE("GPL");
863 MODULE_AUTHOR("Renata Sayakhova <renata@oktetlabs.ru>");
864 MODULE_DESCRIPTION("Maxim/Dallas DS2781 Stand-Alone Fuel Gauage IC driver");
865 MODULE_ALIAS("platform:ds2781-battery");