aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhao Xuewen <zhaoxuewen@huawei.com>2015-10-27 12:05:16 +0800
committerXuewen Zhao <zhaoxuewen@huawei.com>2015-10-27 05:15:13 +0000
commit07a4f54efe717e7e726d4010b3e5d79544e3f507 (patch)
tree15ec0a8d88cda5803e9f6687561323bb869d46fa
parent4c2035208345be43daeb92bd381c11acfc99802d (diff)
power:qpnp-bms: use jiffies in bms_resume interfaceandroid-wear-5.1.1_r0.23
Bms_resume interface uses monotonic boottime. When watch is resumed by rtc_alarm(60s) and the soc calculated period(20s) has arrived, it will set wake_lock(qpnp_soc_wake) and triger bms module to recalculate soc. However, beacuse of the wake_lock, watch cost at most 1.2s at one mins update and consumes more power. When use jiffies, will reduce the soc calculated times, and reduce one mins update to 350ms. Reduce the average power consumption of ambient mode about 0.3 ~ 0.6 mA. Change-Id: I4dddb890c8c2d474c089885898cafc87b203c1cf Signed-off-by: libing <l00228880@notesmail.huawei.com>
-rw-r--r--drivers/power/qpnp-bms.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/power/qpnp-bms.c b/drivers/power/qpnp-bms.c
index 7450df80970e..6c7262d960c5 100644
--- a/drivers/power/qpnp-bms.c
+++ b/drivers/power/qpnp-bms.c
@@ -349,6 +349,7 @@ struct qpnp_bms_chip {
int warm_reset_shutdown_soc_valid_limit;
int estimate_new_ocv_flag;
const char *battery_type;
+ unsigned long last_recalc_time_by_jiffies;
#endif
};
@@ -3088,6 +3089,9 @@ done_calculating:
}
get_current_time(&chip->last_recalc_time);
+#ifdef CONFIG_HUAWEI_BATTERY_SETTING
+ chip->last_recalc_time_by_jiffies = (unsigned long)div_u64(get_jiffies_64(),HZ);
+#endif
chip->first_time_calc_soc = 0;
chip->first_time_calc_uuc = 0;
return chip->calculated_soc;
@@ -5352,7 +5356,7 @@ static int bms_suspend(struct device *dev)
static int bms_resume(struct device *dev)
{
- int rc;
+ int rc = 0;
int soc_calc_period;
int time_until_next_recalc = 0;
unsigned long time_since_last_recalc;
@@ -5362,13 +5366,21 @@ static int bms_resume(struct device *dev)
int sleep_duration;
uint16_t ocv_raw;
+#ifdef CONFIG_HUAWEI_BATTERY_SETTING
+ tm_now_sec = (unsigned long)div_u64(get_jiffies_64(),HZ);
+#else
rc = get_current_time(&tm_now_sec);
+#endif
if (rc) {
pr_err("Could not read current time: %d\n", rc);
tm_now_sec = 0;
} else {
soc_calc_period = get_calculation_delay_ms(chip);
+#ifdef CONFIG_HUAWEI_BATTERY_SETTING
+ time_since_last_recalc = tm_now_sec - chip->last_recalc_time_by_jiffies;
+#else
time_since_last_recalc = tm_now_sec - chip->last_recalc_time;
+#endif
pr_debug("Time since last recalc: %lu\n",
time_since_last_recalc);
time_until_next_recalc = max(0, soc_calc_period