diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2013-10-01 15:38:59 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2013-10-01 15:38:57 -0700 |
| commit | 60fcf7d42a9b5396569917d40e5ca0ed1dec61a3 (patch) | |
| tree | 71c093acce7e9be4c2f83e6d661661dc7f7ac474 | |
| parent | 095944148a11d41f792560f32286458f503bd2aa (diff) | |
| parent | a2f7217450da3f1d9a99a3bb0e2425961865a99d (diff) | |
Merge "power: qpnp-bms: fix boot time iavg calculation algorithm"
| -rw-r--r-- | drivers/power/qpnp-bms.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/power/qpnp-bms.c b/drivers/power/qpnp-bms.c index 04d966fd3ff..0f396054f37 100644 --- a/drivers/power/qpnp-bms.c +++ b/drivers/power/qpnp-bms.c @@ -1264,7 +1264,6 @@ static int adjust_uuc(struct qpnp_bms_chip *chip, } #define MIN_IAVG_MA 250 -#define MIN_SECONDS_FOR_VALID_SAMPLE 20 static int calculate_unusable_charge_uah(struct qpnp_bms_chip *chip, struct soc_params *params, int batt_temp) @@ -1288,17 +1287,19 @@ static int calculate_unusable_charge_uah(struct qpnp_bms_chip *chip, chip->iavg_num_samples = IAVG_SAMPLES; } - /* - * if charging use a nominal avg current to keep - * a reasonable UUC while charging - */ - if (uuc_iavg_ma < MIN_IAVG_MA) - uuc_iavg_ma = MIN_IAVG_MA; - chip->iavg_samples_ma[chip->iavg_index] = uuc_iavg_ma; - chip->iavg_index = (chip->iavg_index + 1) % IAVG_SAMPLES; - chip->iavg_num_samples++; - if (chip->iavg_num_samples >= IAVG_SAMPLES) - chip->iavg_num_samples = IAVG_SAMPLES; + if (params->delta_time_s >= IAVG_MINIMAL_TIME) { + /* + * if charging use a nominal avg current to keep + * a reasonable UUC while charging + */ + if (uuc_iavg_ma < MIN_IAVG_MA) + uuc_iavg_ma = MIN_IAVG_MA; + chip->iavg_samples_ma[chip->iavg_index] = uuc_iavg_ma; + chip->iavg_index = (chip->iavg_index + 1) % IAVG_SAMPLES; + chip->iavg_num_samples++; + if (chip->iavg_num_samples >= IAVG_SAMPLES) + chip->iavg_num_samples = IAVG_SAMPLES; + } /* now that this sample is added calcualte the average */ uuc_iavg_ma = 0; @@ -1329,7 +1330,6 @@ static int calculate_unusable_charge_uah(struct qpnp_bms_chip *chip, uuc_uah_iavg = adjust_uuc(chip, params, pc_unusable, uuc_uah_iavg, batt_temp); - chip->first_time_calc_uuc = 0; return uuc_uah_iavg; } @@ -2361,6 +2361,7 @@ done_calculating: get_current_time(&chip->last_recalc_time); chip->first_time_calc_soc = 0; + chip->first_time_calc_uuc = 0; return chip->calculated_soc; } |
