2 * BQ27x00 battery driver
4 * Copyright (C) 2008 Rodolfo Giometti <giometti@linux.it>
5 * Copyright (C) 2008 Eurotech S.p.A. <info@eurotech.it>
6 * Copyright (C) 2010-2011 Lars-Peter Clausen <lars@metafoo.de>
7 * Copyright (C) 2011 Pali Rohár <pali.rohar@gmail.com>
9 * Based on a previous work by Copyright (C) 2008 Texas Instruments, Inc.
11 * This package is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * http://focus.ti.com/docs/prod/folders/print/bq27000.html
24 * http://focus.ti.com/docs/prod/folders/print/bq27500.html
27 #include <linux/module.h>
28 #include <linux/param.h>
29 #include <linux/jiffies.h>
30 #include <linux/workqueue.h>
31 #include <linux/delay.h>
32 #include <linux/platform_device.h>
33 #include <linux/power_supply.h>
34 #include <linux/idr.h>
35 #include <linux/i2c.h>
36 #include <linux/slab.h>
37 #include <asm/unaligned.h>
39 #include <linux/power/bq27x00_battery.h>
41 #define DRIVER_VERSION "1.2.0"
43 #define BQ27x00_REG_TEMP 0x06
44 #define BQ27x00_REG_VOLT 0x08
45 #define BQ27x00_REG_AI 0x14
46 #define BQ27x00_REG_FLAGS 0x0A
47 #define BQ27x00_REG_TTE 0x16
48 #define BQ27x00_REG_TTF 0x18
49 #define BQ27x00_REG_TTECP 0x26
50 #define BQ27x00_REG_NAC 0x0C /* Nominal available capaciy */
51 #define BQ27x00_REG_LMD 0x12 /* Last measured discharge */
52 #define BQ27x00_REG_CYCT 0x2A /* Cycle count total */
53 #define BQ27x00_REG_AE 0x22 /* Available enery */
55 #define BQ27000_REG_RSOC 0x0B /* Relative State-of-Charge */
56 #define BQ27000_REG_ILMD 0x76 /* Initial last measured discharge */
57 #define BQ27000_FLAG_EDVF BIT(0) /* Final End-of-Discharge-Voltage flag */
58 #define BQ27000_FLAG_EDV1 BIT(1) /* First End-of-Discharge-Voltage flag */
59 #define BQ27000_FLAG_CI BIT(4) /* Capacity Inaccurate flag */
60 #define BQ27000_FLAG_FC BIT(5)
61 #define BQ27000_FLAG_CHGS BIT(7) /* Charge state flag */
63 #define BQ27000_FLAGS_IMPORTANT (BQ27000_FLAG_FC|BQ27000_FLAG_CHGS|BIT(31))
65 #define BQ27500_REG_SOC 0x2C
66 #define BQ27500_REG_DCAP 0x3C /* Design capacity */
67 #define BQ27500_FLAG_DSC BIT(0)
68 #define BQ27500_FLAG_SOCF BIT(1) /* State-of-Charge threshold final */
69 #define BQ27500_FLAG_SOC1 BIT(2) /* State-of-Charge threshold 1 */
70 #define BQ27500_FLAG_FC BIT(9)
72 #define BQ27500_FLAGS_IMPORTANT (BQ27500_FLAG_FC|BQ27500_FLAG_DSC|BIT(31))
74 #define BQ27000_RS 20 /* Resistor sense */
76 struct bq27x00_device_info;
77 struct bq27x00_access_methods {
78 int (*read)(struct bq27x00_device_info *di, u8 reg, bool single);
81 enum bq27x00_chip { BQ27000, BQ27500 };
83 struct bq27x00_reg_cache {
86 int time_to_empty_avg;
95 struct bq27x00_device_info {
98 enum bq27x00_chip chip;
100 struct bq27x00_reg_cache cache;
101 int charge_design_full;
103 unsigned long last_update;
104 struct delayed_work work;
106 struct power_supply bat;
108 struct bq27x00_access_methods bus;
113 static enum power_supply_property bq27x00_battery_props[] = {
114 POWER_SUPPLY_PROP_STATUS,
115 POWER_SUPPLY_PROP_PRESENT,
116 POWER_SUPPLY_PROP_VOLTAGE_NOW,
117 POWER_SUPPLY_PROP_CURRENT_NOW,
118 POWER_SUPPLY_PROP_CAPACITY,
119 POWER_SUPPLY_PROP_CAPACITY_LEVEL,
120 POWER_SUPPLY_PROP_TEMP,
121 POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
122 POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
123 POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
124 POWER_SUPPLY_PROP_TECHNOLOGY,
125 POWER_SUPPLY_PROP_CHARGE_FULL,
126 POWER_SUPPLY_PROP_CHARGE_NOW,
127 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
128 POWER_SUPPLY_PROP_CYCLE_COUNT,
129 POWER_SUPPLY_PROP_ENERGY_NOW,
132 static unsigned int poll_interval = 360;
133 module_param(poll_interval, uint, 0644);
134 MODULE_PARM_DESC(poll_interval, "battery poll interval in seconds - " \
135 "0 disables polling");
138 * Common code for BQ27x00 devices
141 static inline int bq27x00_read(struct bq27x00_device_info *di, u8 reg,
144 return di->bus.read(di, reg, single);
148 * Return the battery Relative State-of-Charge
149 * Or < 0 if something fails.
151 static int bq27x00_battery_read_rsoc(struct bq27x00_device_info *di)
155 if (di->chip == BQ27500)
156 rsoc = bq27x00_read(di, BQ27500_REG_SOC, false);
158 rsoc = bq27x00_read(di, BQ27000_REG_RSOC, true);
161 dev_dbg(di->dev, "error reading relative State-of-Charge\n");
167 * Return a battery charge value in µAh
168 * Or < 0 if something fails.
170 static int bq27x00_battery_read_charge(struct bq27x00_device_info *di, u8 reg)
174 charge = bq27x00_read(di, reg, false);
176 dev_dbg(di->dev, "error reading charge register %02x: %d\n",
181 if (di->chip == BQ27500)
184 charge = charge * 3570 / BQ27000_RS;
190 * Return the battery Nominal available capaciy in µAh
191 * Or < 0 if something fails.
193 static inline int bq27x00_battery_read_nac(struct bq27x00_device_info *di)
195 return bq27x00_battery_read_charge(di, BQ27x00_REG_NAC);
199 * Return the battery Last measured discharge in µAh
200 * Or < 0 if something fails.
202 static inline int bq27x00_battery_read_lmd(struct bq27x00_device_info *di)
204 return bq27x00_battery_read_charge(di, BQ27x00_REG_LMD);
208 * Return the battery Initial last measured discharge in µAh
209 * Or < 0 if something fails.
211 static int bq27x00_battery_read_ilmd(struct bq27x00_device_info *di)
215 if (di->chip == BQ27500)
216 ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false);
218 ilmd = bq27x00_read(di, BQ27000_REG_ILMD, true);
221 dev_dbg(di->dev, "error reading initial last measured discharge\n");
225 if (di->chip == BQ27500)
228 ilmd = ilmd * 256 * 3570 / BQ27000_RS;
234 * Return the battery Available energy in µWh
235 * Or < 0 if something fails.
237 static int bq27x00_battery_read_energy(struct bq27x00_device_info *di)
241 ae = bq27x00_read(di, BQ27x00_REG_AE, false);
243 dev_dbg(di->dev, "error reading available energy\n");
247 if (di->chip == BQ27500)
250 ae = ae * 29200 / BQ27000_RS;
256 * Return the battery temperature in tenths of degree Celsius
257 * Or < 0 if something fails.
259 static int bq27x00_battery_read_temperature(struct bq27x00_device_info *di)
263 temp = bq27x00_read(di, BQ27x00_REG_TEMP, false);
265 dev_err(di->dev, "error reading temperature\n");
269 if (di->chip == BQ27500)
272 temp = ((temp * 5) - 5463) / 2;
278 * Return the battery Cycle count total
279 * Or < 0 if something fails.
281 static int bq27x00_battery_read_cyct(struct bq27x00_device_info *di)
285 cyct = bq27x00_read(di, BQ27x00_REG_CYCT, false);
287 dev_err(di->dev, "error reading cycle count total\n");
293 * Read a time register.
294 * Return < 0 if something fails.
296 static int bq27x00_battery_read_time(struct bq27x00_device_info *di, u8 reg)
300 tval = bq27x00_read(di, reg, false);
302 dev_dbg(di->dev, "error reading time register %02x: %d\n",
313 static void bq27x00_update(struct bq27x00_device_info *di)
315 struct bq27x00_reg_cache cache = {0, };
316 bool is_bq27500 = di->chip == BQ27500;
319 cache.flags = bq27x00_read(di, BQ27x00_REG_FLAGS, is_bq27500);
320 if (cache.flags >= 0) {
321 if (!is_bq27500 && (cache.flags & BQ27000_FLAG_CI)) {
322 dev_info(di->dev, "battery is not calibrated! ignoring capacity values\n");
323 cache.capacity = -ENODATA;
324 cache.energy = -ENODATA;
325 cache.time_to_empty = -ENODATA;
326 cache.time_to_empty_avg = -ENODATA;
327 cache.time_to_full = -ENODATA;
328 cache.charge_full = -ENODATA;
330 cache.capacity = bq27x00_battery_read_rsoc(di);
331 cache.energy = bq27x00_battery_read_energy(di);
332 cache.time_to_empty = bq27x00_battery_read_time(di, BQ27x00_REG_TTE);
333 cache.time_to_empty_avg = bq27x00_battery_read_time(di, BQ27x00_REG_TTECP);
334 cache.time_to_full = bq27x00_battery_read_time(di, BQ27x00_REG_TTF);
335 cache.charge_full = bq27x00_battery_read_lmd(di);
337 cache.temperature = bq27x00_battery_read_temperature(di);
338 cache.cycle_count = bq27x00_battery_read_cyct(di);
340 /* We only have to read charge design full once */
341 if (di->charge_design_full <= 0)
342 di->charge_design_full = bq27x00_battery_read_ilmd(di);
345 flags_changed = di->cache.flags ^ cache.flags;
348 flags_changed &= BQ27500_FLAGS_IMPORTANT;
350 flags_changed &= BQ27000_FLAGS_IMPORTANT;
352 power_supply_changed(&di->bat);
354 di->last_update = jiffies;
357 static void bq27x00_battery_poll(struct work_struct *work)
359 struct bq27x00_device_info *di =
360 container_of(work, struct bq27x00_device_info, work.work);
364 if (poll_interval > 0) {
365 /* The timer does not have to be accurate. */
366 set_timer_slack(&di->work.timer, poll_interval * HZ / 4);
367 schedule_delayed_work(&di->work, poll_interval * HZ);
372 * Return the battery average current in µA
373 * Note that current can be negative signed as well
374 * Or 0 if something fails.
376 static int bq27x00_battery_current(struct bq27x00_device_info *di,
377 union power_supply_propval *val)
382 curr = bq27x00_read(di, BQ27x00_REG_AI, false);
384 dev_err(di->dev, "error reading current\n");
388 if (di->chip == BQ27500) {
389 /* bq27500 returns signed value */
390 val->intval = (int)((s16)curr) * 1000;
392 flags = bq27x00_read(di, BQ27x00_REG_FLAGS, false);
393 if (flags & BQ27000_FLAG_CHGS) {
394 dev_dbg(di->dev, "negative current!\n");
398 val->intval = curr * 3570 / BQ27000_RS;
404 static int bq27x00_battery_status(struct bq27x00_device_info *di,
405 union power_supply_propval *val)
409 if (di->chip == BQ27500) {
410 if (di->cache.flags & BQ27500_FLAG_FC)
411 status = POWER_SUPPLY_STATUS_FULL;
412 else if (di->cache.flags & BQ27500_FLAG_DSC)
413 status = POWER_SUPPLY_STATUS_DISCHARGING;
415 status = POWER_SUPPLY_STATUS_CHARGING;
417 if (di->cache.flags & BQ27000_FLAG_FC)
418 status = POWER_SUPPLY_STATUS_FULL;
419 else if (di->cache.flags & BQ27000_FLAG_CHGS)
420 status = POWER_SUPPLY_STATUS_CHARGING;
421 else if (power_supply_am_i_supplied(&di->bat))
422 status = POWER_SUPPLY_STATUS_NOT_CHARGING;
424 status = POWER_SUPPLY_STATUS_DISCHARGING;
427 val->intval = status;
432 static int bq27x00_battery_capacity_level(struct bq27x00_device_info *di,
433 union power_supply_propval *val)
437 if (di->chip == BQ27500) {
438 if (di->cache.flags & BQ27500_FLAG_FC)
439 level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
440 else if (di->cache.flags & BQ27500_FLAG_SOC1)
441 level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
442 else if (di->cache.flags & BQ27500_FLAG_SOCF)
443 level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
445 level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
447 if (di->cache.flags & BQ27000_FLAG_FC)
448 level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
449 else if (di->cache.flags & BQ27000_FLAG_EDV1)
450 level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
451 else if (di->cache.flags & BQ27000_FLAG_EDVF)
452 level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
454 level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
463 * Return the battery Voltage in milivolts
464 * Or < 0 if something fails.
466 static int bq27x00_battery_voltage(struct bq27x00_device_info *di,
467 union power_supply_propval *val)
471 volt = bq27x00_read(di, BQ27x00_REG_VOLT, false);
473 dev_err(di->dev, "error reading voltage\n");
477 val->intval = volt * 1000;
482 static int bq27x00_simple_value(int value,
483 union power_supply_propval *val)
493 #define to_bq27x00_device_info(x) container_of((x), \
494 struct bq27x00_device_info, bat);
496 static int bq27x00_battery_get_property(struct power_supply *psy,
497 enum power_supply_property psp,
498 union power_supply_propval *val)
501 struct bq27x00_device_info *di = to_bq27x00_device_info(psy);
503 mutex_lock(&di->lock);
504 if (time_is_before_jiffies(di->last_update + 5 * HZ)) {
505 cancel_delayed_work_sync(&di->work);
506 bq27x00_battery_poll(&di->work.work);
508 mutex_unlock(&di->lock);
510 if (psp != POWER_SUPPLY_PROP_PRESENT && di->cache.flags < 0)
514 case POWER_SUPPLY_PROP_STATUS:
515 ret = bq27x00_battery_status(di, val);
517 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
518 ret = bq27x00_battery_voltage(di, val);
520 case POWER_SUPPLY_PROP_PRESENT:
521 val->intval = di->cache.flags < 0 ? 0 : 1;
523 case POWER_SUPPLY_PROP_CURRENT_NOW:
524 ret = bq27x00_battery_current(di, val);
526 case POWER_SUPPLY_PROP_CAPACITY:
527 ret = bq27x00_simple_value(di->cache.capacity, val);
529 case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
530 ret = bq27x00_battery_capacity_level(di, val);
532 case POWER_SUPPLY_PROP_TEMP:
533 ret = bq27x00_simple_value(di->cache.temperature, val);
535 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW:
536 ret = bq27x00_simple_value(di->cache.time_to_empty, val);
538 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
539 ret = bq27x00_simple_value(di->cache.time_to_empty_avg, val);
541 case POWER_SUPPLY_PROP_TIME_TO_FULL_NOW:
542 ret = bq27x00_simple_value(di->cache.time_to_full, val);
544 case POWER_SUPPLY_PROP_TECHNOLOGY:
545 val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
547 case POWER_SUPPLY_PROP_CHARGE_NOW:
548 ret = bq27x00_simple_value(bq27x00_battery_read_nac(di), val);
550 case POWER_SUPPLY_PROP_CHARGE_FULL:
551 ret = bq27x00_simple_value(di->cache.charge_full, val);
553 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
554 ret = bq27x00_simple_value(di->charge_design_full, val);
556 case POWER_SUPPLY_PROP_CYCLE_COUNT:
557 ret = bq27x00_simple_value(di->cache.cycle_count, val);
559 case POWER_SUPPLY_PROP_ENERGY_NOW:
560 ret = bq27x00_simple_value(di->cache.energy, val);
569 static void bq27x00_external_power_changed(struct power_supply *psy)
571 struct bq27x00_device_info *di = to_bq27x00_device_info(psy);
573 cancel_delayed_work_sync(&di->work);
574 set_timer_slack(&di->work.timer, 2 * HZ);
575 schedule_delayed_work(&di->work, 2 * HZ);
578 static int bq27x00_powersupply_init(struct bq27x00_device_info *di)
582 di->bat.type = POWER_SUPPLY_TYPE_BATTERY;
583 di->bat.properties = bq27x00_battery_props;
584 di->bat.num_properties = ARRAY_SIZE(bq27x00_battery_props);
585 di->bat.get_property = bq27x00_battery_get_property;
586 di->bat.external_power_changed = bq27x00_external_power_changed;
588 INIT_DELAYED_WORK(&di->work, bq27x00_battery_poll);
589 mutex_init(&di->lock);
591 ret = power_supply_register(di->dev, &di->bat);
593 dev_err(di->dev, "failed to register battery: %d\n", ret);
597 dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION);
604 static void bq27x00_powersupply_unregister(struct bq27x00_device_info *di)
607 * power_supply_unregister call bq27x00_battery_get_property which
608 * call bq27x00_battery_poll.
609 * Make sure that bq27x00_battery_poll will not call
610 * schedule_delayed_work again after unregister (which cause OOPS).
614 cancel_delayed_work_sync(&di->work);
616 power_supply_unregister(&di->bat);
618 mutex_destroy(&di->lock);
622 /* i2c specific code */
623 #ifdef CONFIG_BATTERY_BQ27X00_I2C
625 /* If the system has several batteries we need a different name for each
628 static DEFINE_IDR(battery_id);
629 static DEFINE_MUTEX(battery_mutex);
631 static int bq27x00_read_i2c(struct bq27x00_device_info *di, u8 reg, bool single)
633 struct i2c_client *client = to_i2c_client(di->dev);
634 struct i2c_msg msg[2];
635 unsigned char data[2];
638 if (!client->adapter)
641 msg[0].addr = client->addr;
644 msg[0].len = sizeof(reg);
645 msg[1].addr = client->addr;
646 msg[1].flags = I2C_M_RD;
653 ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
658 ret = get_unaligned_le16(data);
665 static int bq27x00_battery_probe(struct i2c_client *client,
666 const struct i2c_device_id *id)
669 struct bq27x00_device_info *di;
673 /* Get new ID for the new battery device */
674 retval = idr_pre_get(&battery_id, GFP_KERNEL);
677 mutex_lock(&battery_mutex);
678 retval = idr_get_new(&battery_id, client, &num);
679 mutex_unlock(&battery_mutex);
683 name = kasprintf(GFP_KERNEL, "%s-%d", id->name, num);
685 dev_err(&client->dev, "failed to allocate device name\n");
690 di = kzalloc(sizeof(*di), GFP_KERNEL);
692 dev_err(&client->dev, "failed to allocate device info data\n");
698 di->dev = &client->dev;
699 di->chip = id->driver_data;
701 di->bus.read = &bq27x00_read_i2c;
703 if (bq27x00_powersupply_init(di))
706 i2c_set_clientdata(client, di);
715 mutex_lock(&battery_mutex);
716 idr_remove(&battery_id, num);
717 mutex_unlock(&battery_mutex);
722 static int bq27x00_battery_remove(struct i2c_client *client)
724 struct bq27x00_device_info *di = i2c_get_clientdata(client);
726 bq27x00_powersupply_unregister(di);
730 mutex_lock(&battery_mutex);
731 idr_remove(&battery_id, di->id);
732 mutex_unlock(&battery_mutex);
739 static const struct i2c_device_id bq27x00_id[] = {
740 { "bq27200", BQ27000 }, /* bq27200 is same as bq27000, but with i2c */
741 { "bq27500", BQ27500 },
744 MODULE_DEVICE_TABLE(i2c, bq27x00_id);
746 static struct i2c_driver bq27x00_battery_driver = {
748 .name = "bq27x00-battery",
750 .probe = bq27x00_battery_probe,
751 .remove = bq27x00_battery_remove,
752 .id_table = bq27x00_id,
755 static inline int bq27x00_battery_i2c_init(void)
757 int ret = i2c_add_driver(&bq27x00_battery_driver);
759 printk(KERN_ERR "Unable to register BQ27x00 i2c driver\n");
764 static inline void bq27x00_battery_i2c_exit(void)
766 i2c_del_driver(&bq27x00_battery_driver);
771 static inline int bq27x00_battery_i2c_init(void) { return 0; }
772 static inline void bq27x00_battery_i2c_exit(void) {};
776 /* platform specific code */
777 #ifdef CONFIG_BATTERY_BQ27X00_PLATFORM
779 static int bq27000_read_platform(struct bq27x00_device_info *di, u8 reg,
782 struct device *dev = di->dev;
783 struct bq27000_platform_data *pdata = dev->platform_data;
784 unsigned int timeout = 3;
789 /* Make sure the value has not changed in between reading the
790 * lower and the upper part */
791 upper = pdata->read(dev, reg + 1);
797 lower = pdata->read(dev, reg);
801 upper = pdata->read(dev, reg + 1);
802 } while (temp != upper && --timeout);
807 return (upper << 8) | lower;
810 return pdata->read(dev, reg);
813 static int __devinit bq27000_battery_probe(struct platform_device *pdev)
815 struct bq27x00_device_info *di;
816 struct bq27000_platform_data *pdata = pdev->dev.platform_data;
820 dev_err(&pdev->dev, "no platform_data supplied\n");
825 dev_err(&pdev->dev, "no hdq read callback supplied\n");
829 di = kzalloc(sizeof(*di), GFP_KERNEL);
831 dev_err(&pdev->dev, "failed to allocate device info data\n");
835 platform_set_drvdata(pdev, di);
837 di->dev = &pdev->dev;
840 di->bat.name = pdata->name ?: dev_name(&pdev->dev);
841 di->bus.read = &bq27000_read_platform;
843 ret = bq27x00_powersupply_init(di);
850 platform_set_drvdata(pdev, NULL);
856 static int __devexit bq27000_battery_remove(struct platform_device *pdev)
858 struct bq27x00_device_info *di = platform_get_drvdata(pdev);
860 bq27x00_powersupply_unregister(di);
862 platform_set_drvdata(pdev, NULL);
868 static struct platform_driver bq27000_battery_driver = {
869 .probe = bq27000_battery_probe,
870 .remove = __devexit_p(bq27000_battery_remove),
872 .name = "bq27000-battery",
873 .owner = THIS_MODULE,
877 static inline int bq27x00_battery_platform_init(void)
879 int ret = platform_driver_register(&bq27000_battery_driver);
881 printk(KERN_ERR "Unable to register BQ27000 platform driver\n");
886 static inline void bq27x00_battery_platform_exit(void)
888 platform_driver_unregister(&bq27000_battery_driver);
893 static inline int bq27x00_battery_platform_init(void) { return 0; }
894 static inline void bq27x00_battery_platform_exit(void) {};
902 static int __init bq27x00_battery_init(void)
906 ret = bq27x00_battery_i2c_init();
910 ret = bq27x00_battery_platform_init();
912 bq27x00_battery_i2c_exit();
916 module_init(bq27x00_battery_init);
918 static void __exit bq27x00_battery_exit(void)
920 bq27x00_battery_platform_exit();
921 bq27x00_battery_i2c_exit();
923 module_exit(bq27x00_battery_exit);
925 MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>");
926 MODULE_DESCRIPTION("BQ27x00 battery monitor driver");
927 MODULE_LICENSE("GPL");