From 0adfd9d2bfdac3886432f085b583d8e23b9443b8 Mon Sep 17 00:00:00 2001 From: "YB.Ha" Date: Fri, 8 Aug 2014 09:22:32 +0900 Subject: Winky : Charging start and stop by battery overtemperature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Charging start temperature : T<0 or T≥45 Charging stop temperature : T<0 or T≥60 Start condition of charge : 0≤T<45 BUG=chrome-os-partner:30951 TEST=emerge-winky chromeos-ec Check to stop and start charging by overtemperature. Change-Id: If73df8423c3d997598a49fcbc2926b290958c829 Reviewed-on: https://chromium-review.googlesource.com/211081 Reviewed-by: yoojin lee Reviewed-by: Mohammed Habibulla Commit-Queue: yoojin lee Tested-by: yoojin lee --- board/winky/battery.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/board/winky/battery.c b/board/winky/battery.c index 1c21042f93..a8a2b30ff7 100755 --- a/board/winky/battery.c +++ b/board/winky/battery.c @@ -70,6 +70,7 @@ DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, static int oem_battery_state; #define OEM_BATTERY_STATE_DEFAULT 0x00 #define OEM_BATTERY_STATE_ERROR 0x01 +#define OEM_BATTERY_STATE_STOP_CHARGE 0x02 inline void board_battery_not_connected(void) { @@ -78,9 +79,26 @@ inline void board_battery_not_connected(void) void battery_override_params(struct batt_params *batt) { + int bat_temp_c = DECI_KELVIN_TO_CELSIUS(batt->temperature); int chstate = charge_get_state(); - if(oem_battery_state == OEM_BATTERY_STATE_DEFAULT) { + /* Check battery temperature */ + if((chstate == PWR_STATE_CHARGE) || + (chstate == PWR_STATE_CHARGE_NEAR_FULL)) { + if((bat_temp_c < info.charging_min_c) || + (bat_temp_c >= info.charging_max_c)) { + oem_battery_state |= OEM_BATTERY_STATE_STOP_CHARGE; + } + } else { + if((bat_temp_c < info.start_charging_min_c) || + (bat_temp_c >= info.start_charging_max_c)) { + oem_battery_state |= OEM_BATTERY_STATE_STOP_CHARGE; + } else { + oem_battery_state &= ~OEM_BATTERY_STATE_STOP_CHARGE; + } + } + + if(!(oem_battery_state & OEM_BATTERY_STATE_ERROR)) { if((chstate == PWR_STATE_CHARGE) || (chstate == PWR_STATE_CHARGE_NEAR_FULL)) { /* Check battery overvoltage */ @@ -95,5 +113,11 @@ void battery_override_params(struct batt_params *batt) batt->desired_voltage = 0; batt->desired_current = 0; } + + if(oem_battery_state & OEM_BATTERY_STATE_STOP_CHARGE) { + batt->flags &= ~BATT_FLAG_WANT_CHARGE; + batt->desired_voltage = 0; + batt->desired_current = 0; + } } #endif /* CONFIG_BATTERY_OVERRIDE_PARAMS */ -- cgit v1.2.1