1 // SPDX-License-Identifier: GPL-2.0-only
3 * axp288_fuel_gauge.c - Xpower AXP288 PMIC Fuel Gauge Driver
5 * Copyright (C) 2020-2021 Andrejus Basovas <xxx@yyy.tld>
6 * Copyright (C) 2016-2021 Hans de Goede <hdegoede@redhat.com>
7 * Copyright (C) 2014 Intel Corporation
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 #include <linux/acpi.h>
13 #include <linux/dmi.h>
14 #include <linux/module.h>
15 #include <linux/kernel.h>
16 #include <linux/device.h>
17 #include <linux/regmap.h>
18 #include <linux/jiffies.h>
19 #include <linux/interrupt.h>
20 #include <linux/mfd/axp20x.h>
21 #include <linux/platform_device.h>
22 #include <linux/power_supply.h>
23 #include <linux/iio/consumer.h>
24 #include <asm/unaligned.h>
25 #include <asm/iosf_mbi.h>
27 #define PS_STAT_VBUS_TRIGGER (1 << 0)
28 #define PS_STAT_BAT_CHRG_DIR (1 << 2)
29 #define PS_STAT_VBAT_ABOVE_VHOLD (1 << 3)
30 #define PS_STAT_VBUS_VALID (1 << 4)
31 #define PS_STAT_VBUS_PRESENT (1 << 5)
33 #define CHRG_STAT_BAT_SAFE_MODE (1 << 3)
34 #define CHRG_STAT_BAT_VALID (1 << 4)
35 #define CHRG_STAT_BAT_PRESENT (1 << 5)
36 #define CHRG_STAT_CHARGING (1 << 6)
37 #define CHRG_STAT_PMIC_OTP (1 << 7)
39 #define CHRG_CCCV_CC_MASK 0xf /* 4 bits */
40 #define CHRG_CCCV_CC_BIT_POS 0
41 #define CHRG_CCCV_CC_OFFSET 200 /* 200mA */
42 #define CHRG_CCCV_CC_LSB_RES 200 /* 200mA */
43 #define CHRG_CCCV_ITERM_20P (1 << 4) /* 20% of CC */
44 #define CHRG_CCCV_CV_MASK 0x60 /* 2 bits */
45 #define CHRG_CCCV_CV_BIT_POS 5
46 #define CHRG_CCCV_CV_4100MV 0x0 /* 4.10V */
47 #define CHRG_CCCV_CV_4150MV 0x1 /* 4.15V */
48 #define CHRG_CCCV_CV_4200MV 0x2 /* 4.20V */
49 #define CHRG_CCCV_CV_4350MV 0x3 /* 4.35V */
50 #define CHRG_CCCV_CHG_EN (1 << 7)
52 #define FG_CNTL_OCV_ADJ_STAT (1 << 2)
53 #define FG_CNTL_OCV_ADJ_EN (1 << 3)
54 #define FG_CNTL_CAP_ADJ_STAT (1 << 4)
55 #define FG_CNTL_CAP_ADJ_EN (1 << 5)
56 #define FG_CNTL_CC_EN (1 << 6)
57 #define FG_CNTL_GAUGE_EN (1 << 7)
59 #define FG_15BIT_WORD_VALID (1 << 15)
60 #define FG_15BIT_VAL_MASK 0x7fff
62 #define FG_REP_CAP_VALID (1 << 7)
63 #define FG_REP_CAP_VAL_MASK 0x7F
65 #define FG_DES_CAP1_VALID (1 << 7)
66 #define FG_DES_CAP_RES_LSB 1456 /* 1.456mAhr */
68 #define FG_DES_CC_RES_LSB 1456 /* 1.456mAhr */
70 #define FG_OCV_CAP_VALID (1 << 7)
71 #define FG_OCV_CAP_VAL_MASK 0x7F
72 #define FG_CC_CAP_VALID (1 << 7)
73 #define FG_CC_CAP_VAL_MASK 0x7F
75 #define FG_LOW_CAP_THR1_MASK 0xf0 /* 5% tp 20% */
76 #define FG_LOW_CAP_THR1_VAL 0xa0 /* 15 perc */
77 #define FG_LOW_CAP_THR2_MASK 0x0f /* 0% to 15% */
78 #define FG_LOW_CAP_WARN_THR 14 /* 14 perc */
79 #define FG_LOW_CAP_CRIT_THR 4 /* 4 perc */
80 #define FG_LOW_CAP_SHDN_THR 0 /* 0 perc */
82 #define DEV_NAME "axp288_fuel_gauge"
84 /* 1.1mV per LSB expressed in uV */
85 #define VOLTAGE_FROM_ADC(a) ((a * 11) / 10)
86 /* properties converted to uV, uA */
87 #define PROP_VOLT(a) ((a) * 1000)
88 #define PROP_CURR(a) ((a) * 1000)
90 #define AXP288_REG_UPDATE_INTERVAL (60 * HZ)
91 #define AXP288_FG_INTR_NUM 6
93 #define AXP288_QUIRK_NO_BATTERY BIT(0)
95 static bool no_current_sense_res;
96 module_param(no_current_sense_res, bool, 0444);
97 MODULE_PARM_DESC(no_current_sense_res, "No (or broken) current sense resistor");
115 struct axp288_fg_info {
117 struct regmap *regmap;
118 int irq[AXP288_FG_INTR_NUM];
119 struct iio_channel *iio_channel[IIO_CHANNEL_NUM];
120 struct power_supply *bat;
126 struct dentry *debug_file;
128 char valid; /* zero until following fields are valid */
129 unsigned long last_updated; /* in jiffies */
141 static enum power_supply_property fuel_gauge_props[] = {
142 POWER_SUPPLY_PROP_STATUS,
143 POWER_SUPPLY_PROP_PRESENT,
144 POWER_SUPPLY_PROP_HEALTH,
145 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
146 POWER_SUPPLY_PROP_VOLTAGE_NOW,
147 POWER_SUPPLY_PROP_VOLTAGE_OCV,
148 POWER_SUPPLY_PROP_CAPACITY,
149 POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN,
150 POWER_SUPPLY_PROP_TECHNOLOGY,
151 /* The 3 props below are not used when no_current_sense_res is set */
152 POWER_SUPPLY_PROP_CHARGE_FULL,
153 POWER_SUPPLY_PROP_CHARGE_NOW,
154 POWER_SUPPLY_PROP_CURRENT_NOW,
157 static int fuel_gauge_reg_readb(struct axp288_fg_info *info, int reg)
162 ret = regmap_read(info->regmap, reg, &val);
164 dev_err(info->dev, "Error reading reg 0x%02x err: %d\n", reg, ret);
171 static int fuel_gauge_reg_writeb(struct axp288_fg_info *info, int reg, u8 val)
175 ret = regmap_write(info->regmap, reg, (unsigned int)val);
178 dev_err(info->dev, "Error writing reg 0x%02x err: %d\n", reg, ret);
183 static int fuel_gauge_read_15bit_word(struct axp288_fg_info *info, int reg)
185 unsigned char buf[2];
188 ret = regmap_bulk_read(info->regmap, reg, buf, 2);
190 dev_err(info->dev, "Error reading reg 0x%02x err: %d\n", reg, ret);
194 ret = get_unaligned_be16(buf);
195 if (!(ret & FG_15BIT_WORD_VALID)) {
196 dev_err(info->dev, "Error reg 0x%02x contents not valid\n", reg);
200 return ret & FG_15BIT_VAL_MASK;
203 static int fuel_gauge_read_12bit_word(struct axp288_fg_info *info, int reg)
205 unsigned char buf[2];
208 ret = regmap_bulk_read(info->regmap, reg, buf, 2);
210 dev_err(info->dev, "Error reading reg 0x%02x err: %d\n", reg, ret);
214 /* 12-bit data values have upper 8 bits in buf[0], lower 4 in buf[1] */
215 return (buf[0] << 4) | ((buf[1] >> 4) & 0x0f);
218 static int fuel_gauge_update_registers(struct axp288_fg_info *info)
222 if (info->valid && time_before(jiffies, info->last_updated + AXP288_REG_UPDATE_INTERVAL))
225 dev_dbg(info->dev, "Fuel Gauge updating register values...\n");
227 ret = iosf_mbi_block_punit_i2c_access();
231 ret = fuel_gauge_reg_readb(info, AXP20X_PWR_INPUT_STATUS);
234 info->pwr_stat = ret;
236 if (no_current_sense_res)
237 ret = fuel_gauge_reg_readb(info, AXP288_FG_OCV_CAP_REG);
239 ret = fuel_gauge_reg_readb(info, AXP20X_FG_RES);
244 ret = iio_read_channel_raw(info->iio_channel[BAT_VOLT], &info->bat_volt);
248 ret = fuel_gauge_read_12bit_word(info, AXP288_FG_OCVH_REG);
253 if (no_current_sense_res)
254 goto out_no_current_sense_res;
256 if (info->pwr_stat & PS_STAT_BAT_CHRG_DIR) {
258 ret = iio_read_channel_raw(info->iio_channel[BAT_CHRG_CURR], &info->c_curr);
263 ret = iio_read_channel_raw(info->iio_channel[BAT_D_CURR], &info->d_curr);
268 ret = fuel_gauge_read_15bit_word(info, AXP288_FG_CC_MTR1_REG);
271 info->fg_cc_mtr1 = ret;
273 ret = fuel_gauge_read_15bit_word(info, AXP288_FG_DES_CAP1_REG);
276 info->fg_des_cap1 = ret;
278 out_no_current_sense_res:
279 info->last_updated = jiffies;
283 iosf_mbi_unblock_punit_i2c_access();
287 static void fuel_gauge_get_status(struct axp288_fg_info *info)
289 int pwr_stat = info->pwr_stat;
290 int fg_res = info->fg_res;
291 int curr = info->d_curr;
293 /* Report full if Vbus is valid and the reported capacity is 100% */
294 if (!(pwr_stat & PS_STAT_VBUS_VALID))
297 if (!(fg_res & FG_REP_CAP_VALID))
300 fg_res &= ~FG_REP_CAP_VALID;
302 info->status = POWER_SUPPLY_STATUS_FULL;
307 * Sometimes the charger turns itself off before fg-res reaches 100%.
308 * When this happens the AXP288 reports a not-charging status and
309 * 0 mA discharge current.
311 if (fg_res < 90 || (pwr_stat & PS_STAT_BAT_CHRG_DIR) || no_current_sense_res)
315 info->status = POWER_SUPPLY_STATUS_FULL;
320 if (pwr_stat & PS_STAT_BAT_CHRG_DIR)
321 info->status = POWER_SUPPLY_STATUS_CHARGING;
323 info->status = POWER_SUPPLY_STATUS_DISCHARGING;
326 static int fuel_gauge_battery_health(struct axp288_fg_info *info)
328 int vocv = VOLTAGE_FROM_ADC(info->ocv);
329 int health = POWER_SUPPLY_HEALTH_UNKNOWN;
331 if (vocv > info->max_volt)
332 health = POWER_SUPPLY_HEALTH_OVERVOLTAGE;
334 health = POWER_SUPPLY_HEALTH_GOOD;
339 static int fuel_gauge_get_property(struct power_supply *ps,
340 enum power_supply_property prop,
341 union power_supply_propval *val)
343 struct axp288_fg_info *info = power_supply_get_drvdata(ps);
346 mutex_lock(&info->lock);
348 ret = fuel_gauge_update_registers(info);
353 case POWER_SUPPLY_PROP_STATUS:
354 fuel_gauge_get_status(info);
355 val->intval = info->status;
357 case POWER_SUPPLY_PROP_HEALTH:
358 val->intval = fuel_gauge_battery_health(info);
360 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
361 value = VOLTAGE_FROM_ADC(info->bat_volt);
362 val->intval = PROP_VOLT(value);
364 case POWER_SUPPLY_PROP_VOLTAGE_OCV:
365 value = VOLTAGE_FROM_ADC(info->ocv);
366 val->intval = PROP_VOLT(value);
368 case POWER_SUPPLY_PROP_CURRENT_NOW:
369 if (info->d_curr > 0)
370 value = -1 * info->d_curr;
372 value = info->c_curr;
374 val->intval = PROP_CURR(value);
376 case POWER_SUPPLY_PROP_PRESENT:
377 if (info->pwr_op & CHRG_STAT_BAT_PRESENT)
382 case POWER_SUPPLY_PROP_CAPACITY:
383 if (!(info->fg_res & FG_REP_CAP_VALID))
384 dev_err(info->dev, "capacity measurement not valid\n");
385 val->intval = (info->fg_res & FG_REP_CAP_VAL_MASK);
387 case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
388 val->intval = (info->low_cap & 0x0f);
390 case POWER_SUPPLY_PROP_TECHNOLOGY:
391 val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
393 case POWER_SUPPLY_PROP_CHARGE_NOW:
394 val->intval = info->fg_cc_mtr1 * FG_DES_CAP_RES_LSB;
396 case POWER_SUPPLY_PROP_CHARGE_FULL:
397 val->intval = info->fg_des_cap1 * FG_DES_CAP_RES_LSB;
399 case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
400 val->intval = PROP_VOLT(info->max_volt);
407 mutex_unlock(&info->lock);
411 static int fuel_gauge_set_property(struct power_supply *ps,
412 enum power_supply_property prop,
413 const union power_supply_propval *val)
415 struct axp288_fg_info *info = power_supply_get_drvdata(ps);
416 int new_low_cap, ret = 0;
418 mutex_lock(&info->lock);
420 case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
421 if ((val->intval < 0) || (val->intval > 15)) {
425 new_low_cap = info->low_cap;
427 new_low_cap |= (val->intval & 0xf);
428 ret = fuel_gauge_reg_writeb(info, AXP288_FG_LOW_CAP_REG, new_low_cap);
430 info->low_cap = new_low_cap;
437 mutex_unlock(&info->lock);
441 static int fuel_gauge_property_is_writeable(struct power_supply *psy,
442 enum power_supply_property psp)
447 case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
457 static irqreturn_t fuel_gauge_thread_handler(int irq, void *dev)
459 struct axp288_fg_info *info = dev;
462 for (i = 0; i < AXP288_FG_INTR_NUM; i++) {
463 if (info->irq[i] == irq)
467 if (i >= AXP288_FG_INTR_NUM) {
468 dev_warn(info->dev, "spurious interrupt!!\n");
474 dev_info(info->dev, "Quit Battery under temperature in work mode IRQ (QWBTU)\n");
477 dev_info(info->dev, "Battery under temperature in work mode IRQ (WBTU)\n");
480 dev_info(info->dev, "Quit Battery over temperature in work mode IRQ (QWBTO)\n");
483 dev_info(info->dev, "Battery over temperature in work mode IRQ (WBTO)\n");
486 dev_info(info->dev, "Low Batt Warning(2) INTR\n");
489 dev_info(info->dev, "Low Batt Warning(1) INTR\n");
492 dev_warn(info->dev, "Spurious Interrupt!!!\n");
495 mutex_lock(&info->lock);
496 info->valid = 0; /* Force updating of the cached registers */
497 mutex_unlock(&info->lock);
499 power_supply_changed(info->bat);
503 static void fuel_gauge_external_power_changed(struct power_supply *psy)
505 struct axp288_fg_info *info = power_supply_get_drvdata(psy);
507 mutex_lock(&info->lock);
508 info->valid = 0; /* Force updating of the cached registers */
509 mutex_unlock(&info->lock);
510 power_supply_changed(psy);
513 static struct power_supply_desc fuel_gauge_desc = {
515 .type = POWER_SUPPLY_TYPE_BATTERY,
516 .properties = fuel_gauge_props,
517 .num_properties = ARRAY_SIZE(fuel_gauge_props),
518 .get_property = fuel_gauge_get_property,
519 .set_property = fuel_gauge_set_property,
520 .property_is_writeable = fuel_gauge_property_is_writeable,
521 .external_power_changed = fuel_gauge_external_power_changed,
525 * Some devices have no battery (HDMI sticks) and the axp288 battery's
526 * detection reports one despite it not being there.
527 * Please keep this listed sorted alphabetically.
529 static const struct dmi_system_id axp288_quirks[] = {
531 /* ACEPC T8 Cherry Trail Z8350 mini PC */
533 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."),
534 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
535 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "T8"),
536 /* also match on somewhat unique bios-version */
537 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
539 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
542 /* ACEPC T11 Cherry Trail Z8350 mini PC */
544 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "To be filled by O.E.M."),
545 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Cherry Trail CR"),
546 DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "T11"),
547 /* also match on somewhat unique bios-version */
548 DMI_EXACT_MATCH(DMI_BIOS_VERSION, "1.000"),
550 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
553 /* Intel Cherry Trail Compute Stick, Windows version */
555 DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
556 DMI_MATCH(DMI_PRODUCT_NAME, "STK1AW32SC"),
558 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
561 /* Intel Cherry Trail Compute Stick, version without an OS */
563 DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
564 DMI_MATCH(DMI_PRODUCT_NAME, "STK1A32SC"),
566 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
571 DMI_MATCH(DMI_PRODUCT_NAME, "MEEGOPAD T02"),
573 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
575 { /* Mele PCG03 Mini PC */
577 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "Mini PC"),
578 DMI_EXACT_MATCH(DMI_BOARD_NAME, "Mini PC"),
580 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
583 /* Minix Neo Z83-4 mini PC */
585 DMI_MATCH(DMI_SYS_VENDOR, "MINIX"),
586 DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"),
588 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
592 * One Mix 1, this uses the "T3 MRD" boardname used by
593 * generic mini PCs, but it is a mini laptop so it does
594 * actually have a battery!
597 DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
598 DMI_MATCH(DMI_BIOS_DATE, "06/14/2018"),
604 * Various Ace PC/Meegopad/MinisForum/Wintel Mini-PCs/HDMI-sticks
605 * This entry must be last because it is generic, this allows
606 * adding more specifuc quirks overriding this generic entry.
609 DMI_MATCH(DMI_BOARD_NAME, "T3 MRD"),
610 DMI_MATCH(DMI_CHASSIS_TYPE, "3"),
611 DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
613 .driver_data = (void *)AXP288_QUIRK_NO_BATTERY,
618 static int axp288_fuel_gauge_read_initial_regs(struct axp288_fg_info *info)
624 * On some devices the fuelgauge and charger parts of the axp288 are
625 * not used, check that the fuelgauge is enabled (CC_CTRL != 0).
627 ret = regmap_read(info->regmap, AXP20X_CC_CTRL, &val);
633 ret = fuel_gauge_reg_readb(info, AXP288_FG_DES_CAP1_REG);
637 if (!(ret & FG_DES_CAP1_VALID)) {
638 dev_err(info->dev, "axp288 not configured by firmware\n");
642 ret = fuel_gauge_reg_readb(info, AXP20X_CHRG_CTRL1);
645 switch ((ret & CHRG_CCCV_CV_MASK) >> CHRG_CCCV_CV_BIT_POS) {
646 case CHRG_CCCV_CV_4100MV:
647 info->max_volt = 4100;
649 case CHRG_CCCV_CV_4150MV:
650 info->max_volt = 4150;
652 case CHRG_CCCV_CV_4200MV:
653 info->max_volt = 4200;
655 case CHRG_CCCV_CV_4350MV:
656 info->max_volt = 4350;
660 ret = fuel_gauge_reg_readb(info, AXP20X_PWR_OP_MODE);
665 ret = fuel_gauge_reg_readb(info, AXP288_FG_LOW_CAP_REG);
673 static void axp288_fuel_gauge_release_iio_chans(void *data)
675 struct axp288_fg_info *info = data;
678 for (i = 0; i < IIO_CHANNEL_NUM; i++)
679 if (!IS_ERR_OR_NULL(info->iio_channel[i]))
680 iio_channel_release(info->iio_channel[i]);
683 static int axp288_fuel_gauge_probe(struct platform_device *pdev)
685 struct axp288_fg_info *info;
686 struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
687 struct power_supply_config psy_cfg = {};
688 static const char * const iio_chan_name[] = {
689 [BAT_CHRG_CURR] = "axp288-chrg-curr",
690 [BAT_D_CURR] = "axp288-chrg-d-curr",
691 [BAT_VOLT] = "axp288-batt-volt",
693 const struct dmi_system_id *dmi_id;
694 struct device *dev = &pdev->dev;
695 unsigned long quirks = 0;
699 * Normally the native AXP288 fg/charger drivers are preferred but
700 * on some devices the ACPI drivers should be used instead.
702 if (!acpi_quirk_skip_acpi_ac_and_battery())
705 dmi_id = dmi_first_match(axp288_quirks);
707 quirks = (unsigned long)dmi_id->driver_data;
709 if (quirks & AXP288_QUIRK_NO_BATTERY)
712 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
717 info->regmap = axp20x->regmap;
718 info->status = POWER_SUPPLY_STATUS_UNKNOWN;
721 platform_set_drvdata(pdev, info);
723 mutex_init(&info->lock);
725 for (i = 0; i < AXP288_FG_INTR_NUM; i++) {
726 pirq = platform_get_irq(pdev, i);
729 ret = regmap_irq_get_virq(axp20x->regmap_irqc, pirq);
731 return dev_err_probe(dev, ret, "getting vIRQ %d\n", pirq);
736 for (i = 0; i < IIO_CHANNEL_NUM; i++) {
738 * Note cannot use devm_iio_channel_get because x86 systems
739 * lack the device<->channel maps which iio_channel_get will
740 * try to use when passed a non NULL device pointer.
742 info->iio_channel[i] =
743 iio_channel_get(NULL, iio_chan_name[i]);
744 if (IS_ERR(info->iio_channel[i])) {
745 ret = PTR_ERR(info->iio_channel[i]);
746 dev_dbg(dev, "error getting iiochan %s: %d\n", iio_chan_name[i], ret);
747 /* Wait for axp288_adc to load */
751 axp288_fuel_gauge_release_iio_chans(info);
756 ret = devm_add_action_or_reset(dev, axp288_fuel_gauge_release_iio_chans, info);
760 ret = iosf_mbi_block_punit_i2c_access();
764 ret = axp288_fuel_gauge_read_initial_regs(info);
765 iosf_mbi_unblock_punit_i2c_access();
769 psy_cfg.drv_data = info;
770 if (no_current_sense_res)
771 fuel_gauge_desc.num_properties = ARRAY_SIZE(fuel_gauge_props) - 3;
772 info->bat = devm_power_supply_register(dev, &fuel_gauge_desc, &psy_cfg);
773 if (IS_ERR(info->bat)) {
774 ret = PTR_ERR(info->bat);
775 dev_err(dev, "failed to register battery: %d\n", ret);
779 for (i = 0; i < AXP288_FG_INTR_NUM; i++) {
780 ret = devm_request_threaded_irq(dev, info->irq[i], NULL,
781 fuel_gauge_thread_handler,
782 IRQF_ONESHOT, DEV_NAME, info);
784 return dev_err_probe(dev, ret, "requesting IRQ %d\n", info->irq[i]);
790 static const struct platform_device_id axp288_fg_id_table[] = {
791 { .name = DEV_NAME },
794 MODULE_DEVICE_TABLE(platform, axp288_fg_id_table);
796 static struct platform_driver axp288_fuel_gauge_driver = {
797 .probe = axp288_fuel_gauge_probe,
798 .id_table = axp288_fg_id_table,
804 module_platform_driver(axp288_fuel_gauge_driver);
806 MODULE_AUTHOR("Ramakrishna Pallala <ramakrishna.pallala@intel.com>");
807 MODULE_AUTHOR("Todd Brandt <todd.e.brandt@linux.intel.com>");
808 MODULE_DESCRIPTION("Xpower AXP288 Fuel Gauge Driver");
809 MODULE_LICENSE("GPL");