summaryrefslogtreecommitdiff
path: root/drivers/power/supply/sc27xx_fuel_gauge.c
Commit message (Collapse)AuthorAgeFilesLines
* power: supply: sc27xx: Fix capacity saving functionYuanjiang Yu2019-01-231-5/+59
| | | | | | | | | | | | | | | We found sometimes we can not get the saving capacity to initialize the battery capacity, the reason is the user area registers are put on power always-on region, so we need delay some time to wait until values are updated successfully. Moreover we also should clear the USER_AREA_CLEAR register after setting the USER_AREA_SET register, otherwise we can not save the values in the USER_AREA_SET register. Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: sc27xx: Fix the incorrect formula when converting capacity to ↵Baolin Wang2019-01-231-1/+1
| | | | | | | | | | | coulomb counter We should multiply the calibrated current data (cur_1000ma_adc) when converting current capacity (mAh) to coulomb counter, which can get an accurate coulomb counter from the fuel gauge controller. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: sc27xx: Add one property to read charge voltageBaolin Wang2019-01-231-0/+29
| | | | | | | | | Add POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE property to get charge voltage sampling by ADC controller, which is used to validate if the charge voltage is in normal range or not in charger manager. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: sc27xx: Save last battery capacityYuanjiang Yu2018-12-061-1/+134
| | | | | | | | | | | Our charger manager can optimize the battery capacity periodically, so we can save last battery capacity into registers. Then next system power-on, we can read the last saved battery capacity as the initial battery capacity, which can make the battery capacity more accurate. Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: sc27xx: Add suspend/resume interfacesYuanjiang Yu2018-12-061-0/+77
| | | | | | | | | | Add fuel gauge platform suspend and resume interfaces. In suspend state, we should enable the low voltage and coulomb counter threshold interrupts to wake up system to calibrate the battery capacity in lower voltage stage. Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: sc27xx: Add fuel gauge low voltage alarmYuanjiang Yu2018-12-061-1/+170
| | | | | | | | | Add low voltage alarm support to make sure the battery capacity more accurate in lower voltage stage. Signed-off-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: sc27xx: Add fuel gauge calibrationBaolin Wang2018-12-061-11/+51
| | | | | | | | | This patch adds support to read calibration values from the eFuse controller to calibrate the ADC values corresponding to current and voltage, which can make the current and voltage data more accurate. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
* power: supply: Add Spreadtrum SC27XX fuel gauge unit driverBaolin Wang2018-11-091-0/+656
This patch adds the Spreadtrum SC27XX serial PMICs fuel gauge support, which is used to calculate the battery capacity. Original-by: Yuanjiang Yu <yuanjiang.yu@unisoc.com> Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>