power/axp288_fuel_gauge: axp288 fuel gauge driver
PATCH 3/3 power/axp288_fuel_gauge: axp288 fuel gauge driver
X-Power AXP288 PMIC Fuel Gauge Driver
new power_supply driver at driver/power interfaces with the axp20x mfd driver as a cell provides battery info and monitors for changes generates alerts on temperature and capacity issues
----
drivers/power/Kconfig | 9 + drivers/power/Makefile | 1 + drivers/power/axp288_fuel_gauge.c | 1108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1118 insertions(+)
drivers/power/Kconfig +9 -0
@@ -192,6 +192,15 @@ config BATTERY_DA9052 Say Y here to enable support for batteries charger integrated into DA9052 PMIC. +config AXP288_FUEL_GAUGE + tristate "X-Powers AXP288 Fuel Gauge" + depends on MFD_AXP20X + help + Say yes here to have support for X-Power power management IC (PMIC) + Fuel Gauge. The device provides battery statistics and status + monitoring as well as alerts for battery over/under voltage and + over/under temperature. + config BATTERY_MAX17040 tristate "Maxim MAX17040 Fuel Gauge" depends on I2C
drivers/power/Makefile +1 -0
@@ -59,3 +59,4 @@ obj-$(CONFIG_POWER_AVS) += avs/ obj-$(CONFIG_CHARGER_SMB347) += smb347-charger.o obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o obj-$(CONFIG_POWER_RESET) += reset/ +obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o
drivers/power/axp288_fuel_gauge.c new file +1108 -0
1,108 lines not on this page · raw message
Hi,
Quoted 17 lines · Todd E Brandt
X-Power AXP288 PMIC Fuel Gauge Driver
new
power_supplydriver at driver/power interfaces with the axp20x mfd driver as a cell provides battery info and monitors for changes generates alerts on temperature and capacity issues[...]
drivers/power/axp288_fuel_gauge.c new file +8
-0+static int fuel_gauge_battery_health (struct axp288_fg_info *info) +{ +int temp, vocv; +int ret, health =POWER_SUPPLY_HEALTH_UNKNOWN ; + + ret =fuel_gauge_get_btemp (info, &temp); +if (ret <0 ) + goto health_read_fail;
drivers/power/axp288_fuel_gauge.c line 519
Quoted 10 lines
drivers/power/axp288_fuel_gauge.c new file +10
-0+ + ret =fuel_gauge_get_vocv (info, &vocv); +if (ret <0 ) + goto health_read_fail; + +if (vocv > info->pdata->max_volt) + health =POWER_SUPPLY_HEALTH_OVERVOLTAGE ; +else if (temp > info->pdata->max_temp || + temp < info->pdata->min_temp) + health =POWER_SUPPLY_HEALTH_OVERHEAT ;
if (temp < info->pdata->min_temp)
health = POWER_SUPPLY_HEALTH_COLD;
Quoted 5 lines
drivers/power/axp288_fuel_gauge.c new file +5
-0+else if (vocv < info->pdata->min_volt) + health =POWER_SUPPLY_HEALTH_DEAD ; +else + health =POWER_SUPPLY_HEALTH_GOOD ; +
drivers/power/axp288_fuel_gauge.c line 538
Quoted 10 lines
drivers/power/axp288_fuel_gauge.c new file +7
-0+health_read_fail: +return health; +} +static int axp288_fuel_gauge_remove (struct platform_device *pdev) +{ +return 0 ; +}
You can drop this function if nothing needs to be cleaned, but that's not the case, so where is the cleanup code?
Quoted 1 line
[...]
-- Sebastian
Quoted 32 lines · Sebastian Reichel
Hi,
Quoted 17 lines · Todd E Brandt
X-Power AXP288 PMIC Fuel Gauge Driver
new
power_supplydriver at driver/power interfaces with the axp20x mfd driver as a cell provides battery info and monitors for changes generates alerts on temperature and capacity issues[...]
drivers/power/axp288_fuel_gauge.c new file +8
-0+static int fuel_gauge_battery_health (struct axp288_fg_info *info) +{ +int temp, vocv; +int ret, health =POWER_SUPPLY_HEALTH_UNKNOWN ; + + ret =fuel_gauge_get_btemp (info, &temp); +if (ret <0 ) + goto health_read_fail;drivers/power/axp288_fuel_gauge.c line 519
Quoted 10 lines
drivers/power/axp288_fuel_gauge.c new file +10
-0+ + ret =fuel_gauge_get_vocv (info, &vocv); +if (ret <0 ) + goto health_read_fail; + +if (vocv > info->pdata->max_volt) + health =POWER_SUPPLY_HEALTH_OVERVOLTAGE ; +else if (temp > info->pdata->max_temp || + temp < info->pdata->min_temp) + health =POWER_SUPPLY_HEALTH_OVERHEAT ;if (temp <
info->pdata->min_temp)
Quoted 1 line
health = POWER_SUPPLY_HEALTH_COLD;
Will add in v2, thanks.
Quoted 12 lines
Quoted 12 lines
drivers/power/axp288_fuel_gauge.c new file +8
-0+else if (vocv < info->pdata->min_volt) + health =POWER_SUPPLY_HEALTH_DEAD ; +else + health =POWER_SUPPLY_HEALTH_GOOD ; + +health_read_fail: +return health; +}
Quoted 7 lines
drivers/power/axp288_fuel_gauge.c line 1087
Quoted 4 lines
drivers/power/axp288_fuel_gauge.c new file +4
-0+static int axp288_fuel_gauge_remove (struct platform_device *pdev) +{ +return 0 ; +}You can drop this function if nothing needs to be cleaned, but that's not the case, so where is the cleanup code?
You're right, I believe it needs:
cancel_delayed_work_sync(&info->status_monitor);power_supply_unregister(&info->bat);
will add in v2, thanks
Quoted 4 lines
Quoted 2 lines
[...]
-- Sebastian