diff options
author | YB.Ha <ybha@samsung.com> | 2014-08-08 08:55:56 +0900 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-08-08 05:25:47 +0000 |
commit | 09a9aeca19fbfc550a84e87ec95a7c8904cbacfa (patch) | |
tree | e34ea13ac1ad657f86ff5610abdba2cdcf8f8ae4 | |
parent | 79d2e5767ef433f79b528d40c35225a116b7d5c7 (diff) | |
download | chrome-ec-09a9aeca19fbfc550a84e87ec95a7c8904cbacfa.tar.gz |
Winky : Check battery error by overvoltage
Stop to charge and enter battery error state
when battery pack voltage is higher than charging voltage.
Battery error state by overvoltage is cleared only once
when battery was reconnected.
Battery error should be checked
before translate battery flags.
BUG=chrome-os-partner:30951
TEST=emerge-winky chromeos-ec
Check battery error state by over voltage.
Change-Id: I485d3be9f75bf32e0f2769401eeab8ec887f83ae
Reviewed-on: https://chromium-review.googlesource.com/210016
Reviewed-by: yoojin lee <yoojin7.lee@samsung.com>
Tested-by: yoojin lee <yoojin7.lee@samsung.com>
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
Commit-Queue: yoojin lee <yoojin7.lee@samsung.com>
-rwxr-xr-x | board/winky/battery.c | 33 | ||||
-rwxr-xr-x | board/winky/board.h | 5 | ||||
-rwxr-xr-x | common/charge_state.c | 13 | ||||
-rwxr-xr-x | include/config.h | 7 |
4 files changed, 53 insertions, 5 deletions
diff --git a/board/winky/battery.c b/board/winky/battery.c index fc193bfa3e..1c21042f93 100755 --- a/board/winky/battery.c +++ b/board/winky/battery.c @@ -7,6 +7,7 @@ #include "battery.h" #include "battery_smart.h" +#include "charge_state.h" #include "console.h" #include "gpio.h" #include "host_command.h" @@ -64,3 +65,35 @@ DECLARE_CONSOLE_COMMAND(battcutoff, command_battcutoff, NULL, "Enable battery cutoff (ship mode)", NULL); + +#ifdef CONFIG_BATTERY_OVERRIDE_PARAMS +static int oem_battery_state; +#define OEM_BATTERY_STATE_DEFAULT 0x00 +#define OEM_BATTERY_STATE_ERROR 0x01 + +inline void board_battery_not_connected(void) +{ + oem_battery_state = OEM_BATTERY_STATE_DEFAULT; +} + +void battery_override_params(struct batt_params *batt) +{ + int chstate = charge_get_state(); + + if(oem_battery_state == OEM_BATTERY_STATE_DEFAULT) { + if((chstate == PWR_STATE_CHARGE) || + (chstate == PWR_STATE_CHARGE_NEAR_FULL)) { + /* Check battery overvoltage */ + if(batt->voltage > info.voltage_max) { + oem_battery_state |= OEM_BATTERY_STATE_ERROR; + } + } + } + + if(oem_battery_state & OEM_BATTERY_STATE_ERROR) { + batt->flags |= BATT_FLAG_BAD_VOLTAGE; + batt->desired_voltage = 0; + batt->desired_current = 0; + } +} +#endif /* CONFIG_BATTERY_OVERRIDE_PARAMS */ diff --git a/board/winky/board.h b/board/winky/board.h index 08e4e1262a..ef862b8264 100755 --- a/board/winky/board.h +++ b/board/winky/board.h @@ -11,7 +11,9 @@ /* Optional features */ #define CONFIG_AP_HANG_DETECT #define CONFIG_BACKLIGHT_LID +#define CONFIG_BATTERY_NOT_CONNECTED #define CONFIG_BATTERY_SMART +#define CONFIG_BATTERY_OVERRIDE_PARAMS #define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_DETECT_L #define CONFIG_BATTERY_RESPONSIVE_TIMER 180 /* battery responsive, 3min */ #define CONFIG_BOARD_VERSION @@ -198,6 +200,9 @@ enum temp_sensor_id { /* Discharge battery when on AC power for factory test. */ int board_discharge_on_ac(int enable); +/* OEM battery function when battery is removed. */ +void board_battery_not_connected(void); + #endif /* !__ASSEMBLER__ */ #endif /* __BOARD_H */ diff --git a/common/charge_state.c b/common/charge_state.c index 3a38e9716c..e8d89e293e 100755 --- a/common/charge_state.c +++ b/common/charge_state.c @@ -256,6 +256,9 @@ static int state_common(struct charge_state_context *ctx) defined(CONFIG_BATTERY_PRESENT_GPIO) if (!battery_is_present()) { curr->error |= F_BATTERY_NOT_CONNECTED; +#ifdef CONFIG_BATTERY_NOT_CONNECTED + board_battery_not_connected(); +#endif /* This is the only place accumulating previous state to only send one event */ if(*batt_flags & EC_BATT_FLAG_BATT_PRESENT) { @@ -301,6 +304,11 @@ static int state_common(struct charge_state_context *ctx) ctx->battery_responsive = 1; } +#ifdef CONFIG_BATTERY_OVERRIDE_PARAMS + /* Apply battery pack vendor charging method */ + battery_override_params(batt); +#endif + /* Translate flags */ if (batt->flags & BATT_FLAG_BAD_ANY) curr->error |= F_BATTERY_GET_PARAMS; @@ -362,11 +370,6 @@ static int state_common(struct charge_state_context *ctx) *ctx->memmap_batt_flags &= ~EC_BATT_FLAG_LEVEL_CRITICAL; } -#ifdef CONFIG_BATTERY_OVERRIDE_PARAMS - /* Apply battery pack vendor charging method */ - battery_override_params(batt); -#endif - #ifdef CONFIG_CHARGER_CURRENT_LIMIT if (batt->desired_current > CONFIG_CHARGER_CURRENT_LIMIT) batt->desired_current = CONFIG_CHARGER_CURRENT_LIMIT; diff --git a/include/config.h b/include/config.h index 667fc2064d..bd6bb63c87 100755 --- a/include/config.h +++ b/include/config.h @@ -111,6 +111,13 @@ #undef CONFIG_BATTERY_MOCK /* +* Check battery connection +* +* If defined, board-specific function is called when battery is removed. +*/ +#undef CONFIG_BATTERY_NOT_CONNECTED + +/* * Charger should call battery_override_params() to limit/correct the voltage * and current requested by the battery pack before acting on the request. */ |