From f9ffa951c1eda17f6aa5cea66b1842b0bbf5d75f Mon Sep 17 00:00:00 2001 From: Rong Chang Date: Wed, 28 Oct 2015 18:02:23 +0800 Subject: [PATCH] chg: add narrow VDC power path support Under NVDC, BGATE natively has a body diode. Hence there's a discharging path if VSYS is lower than VBAT. This change keeps VSYS voltage when turning off charging. BRANCH=none BUG=chrome-os-partner:46698 TEST=manual make buildall -j load on boards with isl9237 charger. charge the battery to full, and check charging voltage and current. Change-Id: I8a6046444dd40a3b57f034be124b9e8fe281de40 Signed-off-by: Rong Chang Reviewed-on: https://chromium-review.googlesource.com/309289 Reviewed-by: Alec Berg --- board/chell/board.h | 1 + board/glados/board.h | 1 + board/kunimitsu/board.h | 1 + board/lars/board.h | 1 + board/oak/board.h | 1 + board/wheatley/board.h | 1 + common/charge_state_v2.c | 9 +++++++++ include/config.h | 3 +++ 8 files changed, 18 insertions(+) diff --git a/board/chell/board.h b/board/chell/board.h index 26edf1b1b6..a777b73eab 100644 --- a/board/chell/board.h +++ b/board/chell/board.h @@ -25,6 +25,7 @@ #define CONFIG_CHARGER_ILIM_PIN_DISABLED #define CONFIG_CHARGER_INPUT_CURRENT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 +#define CONFIG_CHARGER_NARROW_VDC #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/glados/board.h b/board/glados/board.h index b9d0a48255..0d4063c2dd 100644 --- a/board/glados/board.h +++ b/board/glados/board.h @@ -30,6 +30,7 @@ #define CONFIG_CHARGER_ILIM_PIN_DISABLED #define CONFIG_CHARGER_INPUT_CURRENT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 +#define CONFIG_CHARGER_NARROW_VDC #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/kunimitsu/board.h b/board/kunimitsu/board.h index 6783315c09..c92a39d1ce 100644 --- a/board/kunimitsu/board.h +++ b/board/kunimitsu/board.h @@ -32,6 +32,7 @@ #ifndef BOARD_KUNIMITSU_V3 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 #endif +#define CONFIG_CHARGER_NARROW_VDC #define CONFIG_CHARGER_PSYS #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/board/lars/board.h b/board/lars/board.h index 7fb5d1fa80..5e66a368a5 100644 --- a/board/lars/board.h +++ b/board/lars/board.h @@ -25,6 +25,7 @@ #define CONFIG_CHARGER_INPUT_CURRENT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 +#define CONFIG_CHARGER_NARROW_VDC #define CONFIG_TRICKLE_CHARGING /* PSYS register 8.25KOhm */ #define CHARGER_PSYS_REGISTER 8250 diff --git a/board/oak/board.h b/board/oak/board.h index 52814fbf63..8e8f68d983 100644 --- a/board/oak/board.h +++ b/board/oak/board.h @@ -30,6 +30,7 @@ #else #define CONFIG_CHARGER_ISL9237 #define CONFIG_CHARGER_MAX_INPUT_CURRENT 2250 +#define CONFIG_CHARGER_NARROW_VDC #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 #endif /* BOARD_REV */ diff --git a/board/wheatley/board.h b/board/wheatley/board.h index cfbbb128d8..a1ba38d190 100644 --- a/board/wheatley/board.h +++ b/board/wheatley/board.h @@ -28,6 +28,7 @@ #define CONFIG_CHARGER_ILIM_PIN_DISABLED #define CONFIG_CHARGER_INPUT_CURRENT 512 #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 +#define CONFIG_CHARGER_NARROW_VDC #define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_CHARGER_SENSE_RESISTOR 10 #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index b4ffd06aa5..b6ad4b933f 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -373,7 +373,16 @@ static int charge_request(int voltage, int current) static int prev_volt, prev_curr; if (!voltage || !current) +#ifdef CONFIG_CHARGER_NARROW_VDC + current = 0; + /* With NVDC charger, keep VSYS voltage higher than battery */ + voltage = charger_closest_voltage( + curr.batt.voltage + charger_get_info()->voltage_step); + /* And handle dead battery case */ + voltage = MAX(voltage, battery_get_info()->voltage_min); +#else voltage = current = 0; +#endif if (curr.ac) { if (prev_volt != voltage || prev_curr != current) diff --git a/include/config.h b/include/config.h index 0dea808e5b..bfbe0c40b5 100644 --- a/include/config.h +++ b/include/config.h @@ -399,6 +399,9 @@ /* Minimum battery percentage for power on */ #undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON +/* Narrow VDC power path */ +#undef CONFIG_CHARGER_NARROW_VDC + /* * Low energy thresholds - when battery level is below BAT_PCT and an external * charger provides less than CHG_MW of power, inform the AP of the situation