diff options
author | Hakan Berg <hakan.berg@stericsson.com> | 2012-05-10 02:43:25 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2013-01-23 06:33:03 -0500 |
commit | 75f2a219ff11e6707903194009656820bba2d5c6 (patch) | |
tree | 67102e924ccc855ef1529aa34b7d95acb3ef9a82 /drivers/power/ab8500_fg.c | |
parent | ff38090aa2e1423e130cc72e790145bad7de8215 (diff) |
ab8500-fg: Adjust for RF bursts voltage drops
Changed conditions for restarting low battery measurements counter
and adjusted the interval between measurements to avoid RF burst
induced voltage drops, and to shorten time to decide to shut down.
Signed-off-by: Hakan Berg <hakan.berg@stericsson.com>
Signed-off-by: Martin Bergstrom <martin.bergstrom@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
Reviewed-by: Marcus COOPER <marcus.xm.cooper@stericsson.com>
Diffstat (limited to 'drivers/power/ab8500_fg.c')
-rw-r--r-- | drivers/power/ab8500_fg.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index cd03549b6227..a0cbbd393fc9 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c | |||
@@ -43,7 +43,7 @@ | |||
43 | 43 | ||
44 | #define NBR_AVG_SAMPLES 20 | 44 | #define NBR_AVG_SAMPLES 20 |
45 | 45 | ||
46 | #define LOW_BAT_CHECK_INTERVAL (2 * HZ) | 46 | #define LOW_BAT_CHECK_INTERVAL (HZ / 16) /* 62.5 ms */ |
47 | 47 | ||
48 | #define VALID_CAPACITY_SEC (45 * 60) /* 45 minutes */ | 48 | #define VALID_CAPACITY_SEC (45 * 60) /* 45 minutes */ |
49 | #define BATT_OK_MIN 2360 /* mV */ | 49 | #define BATT_OK_MIN 2360 /* mV */ |
@@ -169,6 +169,7 @@ struct inst_curr_result_list { | |||
169 | * @recovery_cnt: Counter for recovery mode | 169 | * @recovery_cnt: Counter for recovery mode |
170 | * @high_curr_cnt: Counter for high current mode | 170 | * @high_curr_cnt: Counter for high current mode |
171 | * @init_cnt: Counter for init mode | 171 | * @init_cnt: Counter for init mode |
172 | * @low_bat_cnt Counter for number of consecutive low battery measures | ||
172 | * @nbr_cceoc_irq_cnt Counter for number of CCEOC irqs received since enabled | 173 | * @nbr_cceoc_irq_cnt Counter for number of CCEOC irqs received since enabled |
173 | * @recovery_needed: Indicate if recovery is needed | 174 | * @recovery_needed: Indicate if recovery is needed |
174 | * @high_curr_mode: Indicate if we're in high current mode | 175 | * @high_curr_mode: Indicate if we're in high current mode |
@@ -210,6 +211,7 @@ struct ab8500_fg { | |||
210 | int recovery_cnt; | 211 | int recovery_cnt; |
211 | int high_curr_cnt; | 212 | int high_curr_cnt; |
212 | int init_cnt; | 213 | int init_cnt; |
214 | int low_bat_cnt; | ||
213 | int nbr_cceoc_irq_cnt; | 215 | int nbr_cceoc_irq_cnt; |
214 | bool recovery_needed; | 216 | bool recovery_needed; |
215 | bool high_curr_mode; | 217 | bool high_curr_mode; |
@@ -1879,25 +1881,29 @@ static void ab8500_fg_low_bat_work(struct work_struct *work) | |||
1879 | 1881 | ||
1880 | /* Check if LOW_BAT still fulfilled */ | 1882 | /* Check if LOW_BAT still fulfilled */ |
1881 | if (vbat < di->bm->fg_params->lowbat_threshold) { | 1883 | if (vbat < di->bm->fg_params->lowbat_threshold) { |
1882 | di->flags.low_bat = true; | 1884 | /* Is it time to shut down? */ |
1883 | dev_warn(di->dev, "Battery voltage still LOW\n"); | 1885 | if (di->low_bat_cnt < 1) { |
1884 | 1886 | di->flags.low_bat = true; | |
1885 | /* | 1887 | dev_warn(di->dev, "Shut down pending...\n"); |
1886 | * We need to re-schedule this check to be able to detect | 1888 | } else { |
1887 | * if the voltage increases again during charging | 1889 | /* |
1888 | */ | 1890 | * Else we need to re-schedule this check to be able to detect |
1889 | queue_delayed_work(di->fg_wq, &di->fg_low_bat_work, | 1891 | * if the voltage increases again during charging or |
1890 | round_jiffies(LOW_BAT_CHECK_INTERVAL)); | 1892 | * due to decreasing load. |
1893 | */ | ||
1894 | di->low_bat_cnt--; | ||
1895 | dev_warn(di->dev, "Battery voltage still LOW\n"); | ||
1896 | queue_delayed_work(di->fg_wq, &di->fg_low_bat_work, | ||
1897 | round_jiffies(LOW_BAT_CHECK_INTERVAL)); | ||
1898 | } | ||
1891 | } else { | 1899 | } else { |
1892 | di->flags.low_bat = false; | 1900 | di->flags.low_bat_delay = false; |
1901 | di->low_bat_cnt = 10; | ||
1893 | dev_warn(di->dev, "Battery voltage OK again\n"); | 1902 | dev_warn(di->dev, "Battery voltage OK again\n"); |
1894 | } | 1903 | } |
1895 | 1904 | ||
1896 | /* This is needed to dispatch LOW_BAT */ | 1905 | /* This is needed to dispatch LOW_BAT */ |
1897 | ab8500_fg_check_capacity_limits(di, false); | 1906 | ab8500_fg_check_capacity_limits(di, false); |
1898 | |||
1899 | /* Set this flag to check if LOW_BAT IRQ still occurs */ | ||
1900 | di->flags.low_bat_delay = false; | ||
1901 | } | 1907 | } |
1902 | 1908 | ||
1903 | /** | 1909 | /** |
@@ -2056,6 +2062,7 @@ static irqreturn_t ab8500_fg_lowbatf_handler(int irq, void *_di) | |||
2056 | { | 2062 | { |
2057 | struct ab8500_fg *di = _di; | 2063 | struct ab8500_fg *di = _di; |
2058 | 2064 | ||
2065 | /* Initiate handling in ab8500_fg_low_bat_work() if not already initiated. */ | ||
2059 | if (!di->flags.low_bat_delay) { | 2066 | if (!di->flags.low_bat_delay) { |
2060 | dev_warn(di->dev, "Battery voltage is below LOW threshold\n"); | 2067 | dev_warn(di->dev, "Battery voltage is below LOW threshold\n"); |
2061 | di->flags.low_bat_delay = true; | 2068 | di->flags.low_bat_delay = true; |
@@ -2698,6 +2705,12 @@ static int ab8500_fg_probe(struct platform_device *pdev) | |||
2698 | INIT_DEFERRABLE_WORK(&di->fg_check_hw_failure_work, | 2705 | INIT_DEFERRABLE_WORK(&di->fg_check_hw_failure_work, |
2699 | ab8500_fg_check_hw_failure_work); | 2706 | ab8500_fg_check_hw_failure_work); |
2700 | 2707 | ||
2708 | /* Reset battery low voltage flag */ | ||
2709 | di->flags.low_bat = false; | ||
2710 | |||
2711 | /* Initialize low battery counter */ | ||
2712 | di->low_bat_cnt = 10; | ||
2713 | |||
2701 | /* Initialize OVV, and other registers */ | 2714 | /* Initialize OVV, and other registers */ |
2702 | ret = ab8500_fg_init_hw_registers(di); | 2715 | ret = ab8500_fg_init_hw_registers(di); |
2703 | if (ret) { | 2716 | if (ret) { |