casta : set a charging voltage limit
limit charging voltage to battery voltage max
BRANCH=master
TEST=flash EC and check battery charging.
* Battery pack vendor provided charging profile
*/
+#include "battery.h"
#include "battery_fuel_gauge.h"
#include "battery_smart.h"
#include "charge_state.h"
@@ -76,6 +77,7 @@ int charger_profile_override(struct charge_state_data *curr)
int voltage;
/* battery temp in 0.1 deg C */
int bat_temp_c;
+ const struct battery_info *batt_info;
/*
* Keep track of battery temperature range:
@@ -103,6 +105,7 @@ int charger_profile_override(struct charge_state_data *curr)
current = curr->requested_current;
voltage = curr->requested_voltage;
bat_temp_c = curr->batt.temperature - 2731;
+ batt_info = battery_get_info();
/*
* If the temperature reading is bad, assume the temperature
@@ -143,6 +146,9 @@ int charger_profile_override(struct charge_state_data *curr)
break;
}
+ if(voltage > batt_info->voltage_max)
+ voltage = batt_info->voltage_max;
+
curr->requested_voltage = MIN(curr->requested_voltage, voltage);
curr->requested_current = MIN(curr->requested_current, current);
