summaryrefslogtreecommitdiff
path: root/common/charger_profile_override.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2017-02-06 11:55:21 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-02-10 19:02:55 -0800
commitf30a8cf6863e6f2a491e8baff73632e6faf371d0 (patch)
tree44705231bd7ec9651636adb28f5035a067ee64ca /common/charger_profile_override.c
parent16ce25ce44d2d74c08d33f6277b8528793d7389d (diff)
downloadchrome-ec-f30a8cf6863e6f2a491e8baff73632e6faf371d0.tar.gz
charger_profile: support multiple battery voltage range thresholds
Current fast charge assumes only one battery voltage threshold range for charger profile override. However we have multiple battery voltage threshold ranges for few batteries hence added a code which can consider multiple battery threshold ranges and choose respective charge profile. BUG=chrome-os-partner:62653 BRANCH=none TEST=Manually tested on Electro. Manipulate smp_cos4870 & sonycorp battery voltage & temperature ranges and observed correct charge profile is selected. Change-Id: Icddc047e608cc8f63cd0c19be716e0f7908ca715 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/438804 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'common/charger_profile_override.c')
-rw-r--r--common/charger_profile_override.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/common/charger_profile_override.c b/common/charger_profile_override.c
index ac5339f868..2b691b9a5a 100644
--- a/common/charger_profile_override.c
+++ b/common/charger_profile_override.c
@@ -25,9 +25,9 @@ int charger_profile_override_common(struct charge_state_data *curr,
const struct fast_charge_profile **prev_chg_prof_info,
int batt_vtg_max)
{
+ int i, voltage_range;
/* temp in 0.1 deg C */
int temp_c = curr->batt.temperature - 2731;
- enum fast_chg_voltage_ranges voltage_range;
int temp_ranges = fast_chg_params->total_temp_ranges;
const struct fast_charge_profile *chg_profile_info =
fast_chg_params->chg_profile_info;
@@ -74,11 +74,18 @@ int charger_profile_override_common(struct charge_state_data *curr,
* not in the charger profile voltage range, consider battery has high
* voltage range so that we charge at lower current limit.
*/
- if (!(curr->batt.flags & BATT_FLAG_BAD_VOLTAGE) &&
- curr->batt.voltage < fast_chg_params->vtg_low_limit_mV)
- voltage_range = VOLTAGE_RANGE_LOW;
- else
- voltage_range = VOLTAGE_RANGE_HIGH;
+ voltage_range = CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES - 1;
+
+ if (!(curr->batt.flags & BATT_FLAG_BAD_VOLTAGE)) {
+ for (i = 0; i < CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES - 1;
+ i++) {
+ if (curr->batt.voltage <
+ fast_chg_params->voltage_mV[i]) {
+ voltage_range = i;
+ break;
+ }
+ }
+ }
/*
* If we are not charging or we aren't using fast charging profiles,