2 * Gas Gauge driver for SBS Compliant Batteries
4 * Copyright (c) 2010, NVIDIA Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include <linux/init.h>
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/err.h>
25 #include <linux/power_supply.h>
26 #include <linux/i2c.h>
27 #include <linux/slab.h>
28 #include <linux/interrupt.h>
29 #include <linux/gpio.h>
31 #include <linux/power/sbs-battery.h>
34 REG_MANUFACTURER_DATA,
44 REG_REMAINING_CAPACITY,
45 REG_REMAINING_CAPACITY_CHARGE,
46 REG_FULL_CHARGE_CAPACITY,
47 REG_FULL_CHARGE_CAPACITY_CHARGE,
49 REG_DESIGN_CAPACITY_CHARGE,
53 /* Battery Mode defines */
54 #define BATTERY_MODE_OFFSET 0x03
55 #define BATTERY_MODE_MASK 0x8000
56 enum sbs_battery_mode {
61 /* manufacturer access defines */
62 #define MANUFACTURER_ACCESS_STATUS 0x0006
63 #define MANUFACTURER_ACCESS_SLEEP 0x0011
65 /* battery status value bits */
66 #define BATTERY_DISCHARGING 0x40
67 #define BATTERY_FULL_CHARGED 0x20
68 #define BATTERY_FULL_DISCHARGED 0x10
70 #define SBS_DATA(_psp, _addr, _min_value, _max_value) { \
73 .min_value = _min_value, \
74 .max_value = _max_value, \
77 static const struct chip_data {
78 enum power_supply_property psp;
83 [REG_MANUFACTURER_DATA] =
84 SBS_DATA(POWER_SUPPLY_PROP_PRESENT, 0x00, 0, 65535),
86 SBS_DATA(POWER_SUPPLY_PROP_TEMP, 0x08, 0, 65535),
88 SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_NOW, 0x09, 0, 20000),
90 SBS_DATA(POWER_SUPPLY_PROP_CURRENT_NOW, 0x0A, -32768, 32767),
92 SBS_DATA(POWER_SUPPLY_PROP_CAPACITY, 0x0E, 0, 100),
93 [REG_REMAINING_CAPACITY] =
94 SBS_DATA(POWER_SUPPLY_PROP_ENERGY_NOW, 0x0F, 0, 65535),
95 [REG_REMAINING_CAPACITY_CHARGE] =
96 SBS_DATA(POWER_SUPPLY_PROP_CHARGE_NOW, 0x0F, 0, 65535),
97 [REG_FULL_CHARGE_CAPACITY] =
98 SBS_DATA(POWER_SUPPLY_PROP_ENERGY_FULL, 0x10, 0, 65535),
99 [REG_FULL_CHARGE_CAPACITY_CHARGE] =
100 SBS_DATA(POWER_SUPPLY_PROP_CHARGE_FULL, 0x10, 0, 65535),
101 [REG_TIME_TO_EMPTY] =
102 SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG, 0x12, 0, 65535),
104 SBS_DATA(POWER_SUPPLY_PROP_TIME_TO_FULL_AVG, 0x13, 0, 65535),
106 SBS_DATA(POWER_SUPPLY_PROP_STATUS, 0x16, 0, 65535),
108 SBS_DATA(POWER_SUPPLY_PROP_CYCLE_COUNT, 0x17, 0, 65535),
109 [REG_DESIGN_CAPACITY] =
110 SBS_DATA(POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 0x18, 0, 65535),
111 [REG_DESIGN_CAPACITY_CHARGE] =
112 SBS_DATA(POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 0x18, 0, 65535),
113 [REG_DESIGN_VOLTAGE] =
114 SBS_DATA(POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, 0x19, 0, 65535),
115 [REG_SERIAL_NUMBER] =
116 SBS_DATA(POWER_SUPPLY_PROP_SERIAL_NUMBER, 0x1C, 0, 65535),
119 static enum power_supply_property sbs_properties[] = {
120 POWER_SUPPLY_PROP_STATUS,
121 POWER_SUPPLY_PROP_HEALTH,
122 POWER_SUPPLY_PROP_PRESENT,
123 POWER_SUPPLY_PROP_TECHNOLOGY,
124 POWER_SUPPLY_PROP_CYCLE_COUNT,
125 POWER_SUPPLY_PROP_VOLTAGE_NOW,
126 POWER_SUPPLY_PROP_CURRENT_NOW,
127 POWER_SUPPLY_PROP_CAPACITY,
128 POWER_SUPPLY_PROP_TEMP,
129 POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
130 POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
131 POWER_SUPPLY_PROP_SERIAL_NUMBER,
132 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
133 POWER_SUPPLY_PROP_ENERGY_NOW,
134 POWER_SUPPLY_PROP_ENERGY_FULL,
135 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
136 POWER_SUPPLY_PROP_CHARGE_NOW,
137 POWER_SUPPLY_PROP_CHARGE_FULL,
138 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
142 struct i2c_client *client;
143 struct power_supply power_supply;
144 struct sbs_platform_data *pdata;
147 bool enable_detection;
151 struct delayed_work work;
155 static int sbs_read_word_data(struct i2c_client *client, u8 address)
157 struct sbs_info *chip = i2c_get_clientdata(client);
162 retries = max(chip->pdata->i2c_retry_count + 1, 1);
164 while (retries > 0) {
165 ret = i2c_smbus_read_word_data(client, address);
172 dev_dbg(&client->dev,
173 "%s: i2c read at address 0x%x failed\n",
178 return le16_to_cpu(ret);
181 static int sbs_write_word_data(struct i2c_client *client, u8 address,
184 struct sbs_info *chip = i2c_get_clientdata(client);
189 retries = max(chip->pdata->i2c_retry_count + 1, 1);
191 while (retries > 0) {
192 ret = i2c_smbus_write_word_data(client, address,
200 dev_dbg(&client->dev,
201 "%s: i2c write to address 0x%x failed\n",
209 static int sbs_get_battery_presence_and_health(
210 struct i2c_client *client, enum power_supply_property psp,
211 union power_supply_propval *val)
214 struct sbs_info *chip = i2c_get_clientdata(client);
216 if (psp == POWER_SUPPLY_PROP_PRESENT &&
218 ret = gpio_get_value(chip->pdata->battery_detect);
219 if (ret == chip->pdata->battery_detect_present)
223 chip->is_present = val->intval;
227 /* Write to ManufacturerAccess with
228 * ManufacturerAccess command and then
230 ret = sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr,
231 MANUFACTURER_ACCESS_STATUS);
233 if (psp == POWER_SUPPLY_PROP_PRESENT)
234 val->intval = 0; /* battery removed */
238 ret = sbs_read_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr);
242 if (ret < sbs_data[REG_MANUFACTURER_DATA].min_value ||
243 ret > sbs_data[REG_MANUFACTURER_DATA].max_value) {
248 /* Mask the upper nibble of 2nd byte and
249 * lower byte of response then
250 * shift the result by 8 to get status*/
253 if (psp == POWER_SUPPLY_PROP_PRESENT) {
255 /* battery removed */
259 } else if (psp == POWER_SUPPLY_PROP_HEALTH) {
261 val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
262 else if (ret == 0x0B)
263 val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
264 else if (ret == 0x0C)
265 val->intval = POWER_SUPPLY_HEALTH_DEAD;
267 val->intval = POWER_SUPPLY_HEALTH_GOOD;
273 static int sbs_get_battery_property(struct i2c_client *client,
274 int reg_offset, enum power_supply_property psp,
275 union power_supply_propval *val)
277 struct sbs_info *chip = i2c_get_clientdata(client);
280 ret = sbs_read_word_data(client, sbs_data[reg_offset].addr);
284 /* returned values are 16 bit */
285 if (sbs_data[reg_offset].min_value < 0)
288 if (ret >= sbs_data[reg_offset].min_value &&
289 ret <= sbs_data[reg_offset].max_value) {
291 if (psp != POWER_SUPPLY_PROP_STATUS)
294 if (ret & BATTERY_FULL_CHARGED)
295 val->intval = POWER_SUPPLY_STATUS_FULL;
296 else if (ret & BATTERY_FULL_DISCHARGED)
297 val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
298 else if (ret & BATTERY_DISCHARGING)
299 val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
301 val->intval = POWER_SUPPLY_STATUS_CHARGING;
303 if (chip->poll_time == 0)
304 chip->last_state = val->intval;
305 else if (chip->last_state != val->intval) {
306 cancel_delayed_work_sync(&chip->work);
307 power_supply_changed(&chip->power_supply);
311 if (psp == POWER_SUPPLY_PROP_STATUS)
312 val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
320 static void sbs_unit_adjustment(struct i2c_client *client,
321 enum power_supply_property psp, union power_supply_propval *val)
323 #define BASE_UNIT_CONVERSION 1000
324 #define BATTERY_MODE_CAP_MULT_WATT (10 * BASE_UNIT_CONVERSION)
325 #define TIME_UNIT_CONVERSION 60
326 #define TEMP_KELVIN_TO_CELSIUS 2731
328 case POWER_SUPPLY_PROP_ENERGY_NOW:
329 case POWER_SUPPLY_PROP_ENERGY_FULL:
330 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
331 /* sbs provides energy in units of 10mWh.
334 val->intval *= BATTERY_MODE_CAP_MULT_WATT;
337 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
338 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
339 case POWER_SUPPLY_PROP_CURRENT_NOW:
340 case POWER_SUPPLY_PROP_CHARGE_NOW:
341 case POWER_SUPPLY_PROP_CHARGE_FULL:
342 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
343 val->intval *= BASE_UNIT_CONVERSION;
346 case POWER_SUPPLY_PROP_TEMP:
347 /* sbs provides battery temperature in 0.1K
348 * so convert it to 0.1°C
350 val->intval -= TEMP_KELVIN_TO_CELSIUS;
353 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
354 case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
355 /* sbs provides time to empty and time to full in minutes.
358 val->intval *= TIME_UNIT_CONVERSION;
362 dev_dbg(&client->dev,
363 "%s: no need for unit conversion %d\n", __func__, psp);
367 static enum sbs_battery_mode sbs_set_battery_mode(struct i2c_client *client,
368 enum sbs_battery_mode mode)
370 int ret, original_val;
372 original_val = sbs_read_word_data(client, BATTERY_MODE_OFFSET);
373 if (original_val < 0)
376 if ((original_val & BATTERY_MODE_MASK) == mode)
379 if (mode == BATTERY_MODE_AMPS)
380 ret = original_val & ~BATTERY_MODE_MASK;
382 ret = original_val | BATTERY_MODE_MASK;
384 ret = sbs_write_word_data(client, BATTERY_MODE_OFFSET, ret);
388 return original_val & BATTERY_MODE_MASK;
391 static int sbs_get_battery_capacity(struct i2c_client *client,
392 int reg_offset, enum power_supply_property psp,
393 union power_supply_propval *val)
396 enum sbs_battery_mode mode = BATTERY_MODE_WATTS;
398 if (power_supply_is_amp_property(psp))
399 mode = BATTERY_MODE_AMPS;
401 mode = sbs_set_battery_mode(client, mode);
405 ret = sbs_read_word_data(client, sbs_data[reg_offset].addr);
409 if (psp == POWER_SUPPLY_PROP_CAPACITY) {
410 /* sbs spec says that this can be >100 %
411 * even if max value is 100 % */
412 val->intval = min(ret, 100);
416 ret = sbs_set_battery_mode(client, mode);
423 static char sbs_serial[5];
424 static int sbs_get_battery_serial_number(struct i2c_client *client,
425 union power_supply_propval *val)
429 ret = sbs_read_word_data(client, sbs_data[REG_SERIAL_NUMBER].addr);
433 ret = sprintf(sbs_serial, "%04x", ret);
434 val->strval = sbs_serial;
439 static int sbs_get_property_index(struct i2c_client *client,
440 enum power_supply_property psp)
443 for (count = 0; count < ARRAY_SIZE(sbs_data); count++)
444 if (psp == sbs_data[count].psp)
447 dev_warn(&client->dev,
448 "%s: Invalid Property - %d\n", __func__, psp);
453 static int sbs_get_property(struct power_supply *psy,
454 enum power_supply_property psp,
455 union power_supply_propval *val)
458 struct sbs_info *chip = container_of(psy,
459 struct sbs_info, power_supply);
460 struct i2c_client *client = chip->client;
463 case POWER_SUPPLY_PROP_PRESENT:
464 case POWER_SUPPLY_PROP_HEALTH:
465 ret = sbs_get_battery_presence_and_health(client, psp, val);
466 if (psp == POWER_SUPPLY_PROP_PRESENT)
470 case POWER_SUPPLY_PROP_TECHNOLOGY:
471 val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
474 case POWER_SUPPLY_PROP_ENERGY_NOW:
475 case POWER_SUPPLY_PROP_ENERGY_FULL:
476 case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
477 case POWER_SUPPLY_PROP_CHARGE_NOW:
478 case POWER_SUPPLY_PROP_CHARGE_FULL:
479 case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
480 case POWER_SUPPLY_PROP_CAPACITY:
481 ret = sbs_get_property_index(client, psp);
485 ret = sbs_get_battery_capacity(client, ret, psp, val);
488 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
489 ret = sbs_get_battery_serial_number(client, val);
492 case POWER_SUPPLY_PROP_STATUS:
493 case POWER_SUPPLY_PROP_CYCLE_COUNT:
494 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
495 case POWER_SUPPLY_PROP_CURRENT_NOW:
496 case POWER_SUPPLY_PROP_TEMP:
497 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG:
498 case POWER_SUPPLY_PROP_TIME_TO_FULL_AVG:
499 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
500 ret = sbs_get_property_index(client, psp);
504 ret = sbs_get_battery_property(client, ret, psp, val);
508 dev_err(&client->dev,
509 "%s: INVALID property\n", __func__);
513 if (!chip->enable_detection)
516 if (!chip->gpio_detect &&
517 chip->is_present != (ret >= 0)) {
518 chip->is_present = (ret >= 0);
519 power_supply_changed(&chip->power_supply);
524 /* Convert units to match requirements for power supply class */
525 sbs_unit_adjustment(client, psp, val);
528 dev_dbg(&client->dev,
529 "%s: property = %d, value = %x\n", __func__, psp, val->intval);
531 if (ret && chip->is_present)
534 /* battery not present, so return NODATA for properties */
541 static irqreturn_t sbs_irq(int irq, void *devid)
543 struct power_supply *battery = devid;
545 power_supply_changed(battery);
550 static void sbs_external_power_changed(struct power_supply *psy)
552 struct sbs_info *chip;
554 chip = container_of(psy, struct sbs_info, power_supply);
556 if (chip->ignore_changes > 0) {
557 chip->ignore_changes--;
561 /* cancel outstanding work */
562 cancel_delayed_work_sync(&chip->work);
564 schedule_delayed_work(&chip->work, HZ);
565 chip->poll_time = chip->pdata->poll_retry_count;
568 static void sbs_delayed_work(struct work_struct *work)
570 struct sbs_info *chip;
573 chip = container_of(work, struct sbs_info, work.work);
575 ret = sbs_read_word_data(chip->client, sbs_data[REG_STATUS].addr);
576 /* if the read failed, give up on this work */
582 if (ret & BATTERY_FULL_CHARGED)
583 ret = POWER_SUPPLY_STATUS_FULL;
584 else if (ret & BATTERY_FULL_DISCHARGED)
585 ret = POWER_SUPPLY_STATUS_NOT_CHARGING;
586 else if (ret & BATTERY_DISCHARGING)
587 ret = POWER_SUPPLY_STATUS_DISCHARGING;
589 ret = POWER_SUPPLY_STATUS_CHARGING;
591 if (chip->last_state != ret) {
593 power_supply_changed(&chip->power_supply);
596 if (chip->poll_time > 0) {
597 schedule_delayed_work(&chip->work, HZ);
603 #if defined(CONFIG_OF)
605 #include <linux/of_device.h>
606 #include <linux/of_gpio.h>
608 static const struct of_device_id sbs_dt_ids[] = {
609 { .compatible = "sbs,sbs-battery" },
610 { .compatible = "ti,bq20z75" },
613 MODULE_DEVICE_TABLE(of, sbs_dt_ids);
615 static struct sbs_platform_data *sbs_of_populate_pdata(
616 struct i2c_client *client)
618 struct device_node *of_node = client->dev.of_node;
619 struct sbs_platform_data *pdata = client->dev.platform_data;
620 enum of_gpio_flags gpio_flags;
624 /* verify this driver matches this device */
628 /* if platform data is set, honor it */
632 /* first make sure at least one property is set, otherwise
633 * it won't change behavior from running without pdata.
635 if (!of_get_property(of_node, "sbs,i2c-retry-count", NULL) &&
636 !of_get_property(of_node, "sbs,poll-retry-count", NULL) &&
637 !of_get_property(of_node, "sbs,battery-detect-gpios", NULL))
640 pdata = devm_kzalloc(&client->dev, sizeof(struct sbs_platform_data),
645 rc = of_property_read_u32(of_node, "sbs,i2c-retry-count", &prop);
647 pdata->i2c_retry_count = prop;
649 rc = of_property_read_u32(of_node, "sbs,poll-retry-count", &prop);
651 pdata->poll_retry_count = prop;
653 if (!of_get_property(of_node, "sbs,battery-detect-gpios", NULL)) {
654 pdata->battery_detect = -1;
658 pdata->battery_detect = of_get_named_gpio_flags(of_node,
659 "sbs,battery-detect-gpios", 0, &gpio_flags);
661 if (gpio_flags & OF_GPIO_ACTIVE_LOW)
662 pdata->battery_detect_present = 0;
664 pdata->battery_detect_present = 1;
670 #define sbs_dt_ids NULL
671 static struct sbs_platform_data *sbs_of_populate_pdata(
672 struct i2c_client *client)
674 return client->dev.platform_data;
678 static int __devinit sbs_probe(struct i2c_client *client,
679 const struct i2c_device_id *id)
681 struct sbs_info *chip;
682 struct sbs_platform_data *pdata = client->dev.platform_data;
687 name = kasprintf(GFP_KERNEL, "sbs-%s", dev_name(&client->dev));
689 dev_err(&client->dev, "Failed to allocate device name\n");
693 chip = kzalloc(sizeof(struct sbs_info), GFP_KERNEL);
699 chip->client = client;
700 chip->enable_detection = false;
701 chip->gpio_detect = false;
702 chip->power_supply.name = name;
703 chip->power_supply.type = POWER_SUPPLY_TYPE_BATTERY;
704 chip->power_supply.properties = sbs_properties;
705 chip->power_supply.num_properties = ARRAY_SIZE(sbs_properties);
706 chip->power_supply.get_property = sbs_get_property;
707 /* ignore first notification of external change, it is generated
708 * from the power_supply_register call back
710 chip->ignore_changes = 1;
711 chip->last_state = POWER_SUPPLY_STATUS_UNKNOWN;
712 chip->power_supply.external_power_changed = sbs_external_power_changed;
714 pdata = sbs_of_populate_pdata(client);
717 chip->gpio_detect = gpio_is_valid(pdata->battery_detect);
721 i2c_set_clientdata(client, chip);
723 if (!chip->gpio_detect)
726 rc = gpio_request(pdata->battery_detect, dev_name(&client->dev));
728 dev_warn(&client->dev, "Failed to request gpio: %d\n", rc);
729 chip->gpio_detect = false;
733 rc = gpio_direction_input(pdata->battery_detect);
735 dev_warn(&client->dev, "Failed to get gpio as input: %d\n", rc);
736 gpio_free(pdata->battery_detect);
737 chip->gpio_detect = false;
741 irq = gpio_to_irq(pdata->battery_detect);
743 dev_warn(&client->dev, "Failed to get gpio as irq: %d\n", irq);
744 gpio_free(pdata->battery_detect);
745 chip->gpio_detect = false;
749 rc = request_irq(irq, sbs_irq,
750 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
751 dev_name(&client->dev), &chip->power_supply);
753 dev_warn(&client->dev, "Failed to request irq: %d\n", rc);
754 gpio_free(pdata->battery_detect);
755 chip->gpio_detect = false;
763 rc = power_supply_register(&client->dev, &chip->power_supply);
765 dev_err(&client->dev,
766 "%s: Failed to register power supply\n", __func__);
770 dev_info(&client->dev,
771 "%s: battery gas gauge device registered\n", client->name);
773 INIT_DELAYED_WORK(&chip->work, sbs_delayed_work);
775 chip->enable_detection = true;
781 free_irq(chip->irq, &chip->power_supply);
782 if (chip->gpio_detect)
783 gpio_free(pdata->battery_detect);
793 static int __devexit sbs_remove(struct i2c_client *client)
795 struct sbs_info *chip = i2c_get_clientdata(client);
798 free_irq(chip->irq, &chip->power_supply);
799 if (chip->gpio_detect)
800 gpio_free(chip->pdata->battery_detect);
802 power_supply_unregister(&chip->power_supply);
804 cancel_delayed_work_sync(&chip->work);
806 kfree(chip->power_supply.name);
813 #if defined CONFIG_PM
814 static int sbs_suspend(struct i2c_client *client,
817 struct sbs_info *chip = i2c_get_clientdata(client);
820 if (chip->poll_time > 0)
821 cancel_delayed_work_sync(&chip->work);
823 /* write to manufacturer access with sleep command */
824 ret = sbs_write_word_data(client, sbs_data[REG_MANUFACTURER_DATA].addr,
825 MANUFACTURER_ACCESS_SLEEP);
826 if (chip->is_present && ret < 0)
832 #define sbs_suspend NULL
834 /* any smbus transaction will wake up sbs */
835 #define sbs_resume NULL
837 static const struct i2c_device_id sbs_id[] = {
839 { "sbs-battery", 1 },
842 MODULE_DEVICE_TABLE(i2c, sbs_id);
844 static struct i2c_driver sbs_battery_driver = {
846 .remove = __devexit_p(sbs_remove),
847 .suspend = sbs_suspend,
848 .resume = sbs_resume,
851 .name = "sbs-battery",
852 .of_match_table = sbs_dt_ids,
856 static int __init sbs_battery_init(void)
858 return i2c_add_driver(&sbs_battery_driver);
860 module_init(sbs_battery_init);
862 static void __exit sbs_battery_exit(void)
864 i2c_del_driver(&sbs_battery_driver);
866 module_exit(sbs_battery_exit);
868 MODULE_DESCRIPTION("SBS battery monitor driver");
869 MODULE_LICENSE("GPL");