summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2018-01-09 16:31:44 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-10 06:02:13 -0800
commit31e68a035b83acf13b73f3b5b63fbb99540faea9 (patch)
treee9d3af5cb1d176487fd1994a70eba4f86949df50
parent1caa2788c5198f3a89e022a559191b27b93adada (diff)
downloadchrome-ec-31e68a035b83acf13b73f3b5b63fbb99540faea9.tar.gz
driver/charger/isl923x: Make sure CONFIG_CHARGER_NARROW_VDC is set
Without this, the battery will discharge if we disallow battery charging (e.g. calling charge_request with either voltage == 0 or current == 0, either by policy, or when the battery is full). Also update config.h to set the option whenever isl923x is used. BRANCH=none BUG=b:66575472 BUG=b:35585464 TEST=make buildall -j Change-Id: Id5515d5ea82a393a3693a3da44cbdc2778296a95 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/856538 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/chell/board.h1
-rw-r--r--board/elm/board.h1
-rw-r--r--board/glados/board.h1
-rw-r--r--board/nami/board.h1
-rw-r--r--board/nautilus/board.h1
-rw-r--r--board/oak/board.h1
-rw-r--r--board/poppy/board.h1
-rw-r--r--board/rowan/board.h1
-rw-r--r--board/wheatley/board.h1
-rw-r--r--common/charge_state_v2.c6
-rw-r--r--driver/charger/isl923x.c4
-rw-r--r--include/config.h11
12 files changed, 19 insertions, 11 deletions
diff --git a/board/chell/board.h b/board/chell/board.h
index 9f3e93cda9..b2eb1271f2 100644
--- a/board/chell/board.h
+++ b/board/chell/board.h
@@ -32,7 +32,6 @@
#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/elm/board.h b/board/elm/board.h
index 4886d010ac..41af08ee4e 100644
--- a/board/elm/board.h
+++ b/board/elm/board.h
@@ -38,7 +38,6 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_ISL9237
#define CONFIG_CHARGER_MAX_INPUT_CURRENT 3000
-#define CONFIG_CHARGER_NARROW_VDC
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
#define CONFIG_CHARGER_DISCHARGE_ON_AC
diff --git a/board/glados/board.h b/board/glados/board.h
index 24f1ac1b57..507cbcd001 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -34,7 +34,6 @@
#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/nami/board.h b/board/nami/board.h
index 9e077163c9..86bb976c82 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -83,7 +83,6 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
-#define CONFIG_CHARGER_NARROW_VDC
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index 3bd80a1d84..f6cd650b48 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -83,7 +83,6 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
-#define CONFIG_CHARGER_NARROW_VDC
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/board/oak/board.h b/board/oak/board.h
index 432b1454d1..9828e4e9a0 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -46,7 +46,6 @@
#define CONFIG_CHARGE_RAMP_HW
#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/poppy/board.h b/board/poppy/board.h
index 41aa1f19d9..3fd10a9b20 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -83,7 +83,6 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
-#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/rowan/board.h b/board/rowan/board.h
index 1eee437180..07bdf64283 100644
--- a/board/rowan/board.h
+++ b/board/rowan/board.h
@@ -43,7 +43,6 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_ISL9237
#define CONFIG_CHARGER_MAX_INPUT_CURRENT 3000
-#define CONFIG_CHARGER_NARROW_VDC
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
#define CONFIG_CHARGER_DISCHARGE_ON_AC
diff --git a/board/wheatley/board.h b/board/wheatley/board.h
index 56f8169b7e..c3ccf33a84 100644
--- a/board/wheatley/board.h
+++ b/board/wheatley/board.h
@@ -27,7 +27,6 @@
#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 4ecc48fbcd..71d46265a5 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -546,7 +546,11 @@ static int charge_request(int voltage, int current)
if (!voltage || !current) {
#ifdef CONFIG_CHARGER_NARROW_VDC
current = 0;
- /* With NVDC charger, keep VSYS voltage higher than battery */
+ /*
+ * With NVDC charger, keep VSYS voltage higher than battery,
+ * otherwise the BGATE FET body diode would conduct and
+ * discharge the battery.
+ */
voltage = charger_closest_voltage(
curr.batt.voltage + charger_get_info()->voltage_step);
/* If the battery is full, request the max voltage. */
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c
index 0117ad74d4..5f6312c7c7 100644
--- a/driver/charger/isl923x.c
+++ b/driver/charger/isl923x.c
@@ -18,6 +18,10 @@
#include "timer.h"
#include "util.h"
+#ifndef CONFIG_CHARGER_NARROW_VDC
+#error "ISL9237/8 is a NVDC charger, please enable CONFIG_CHARGER_NARROW_VDC."
+#endif
+
#define DEFAULT_R_AC 20
#define DEFAULT_R_SNS 10
#define R_AC CONFIG_CHARGER_SENSE_RESISTOR_AC
diff --git a/include/config.h b/include/config.h
index 3e8d2d6935..918c6ceb54 100644
--- a/include/config.h
+++ b/include/config.h
@@ -584,7 +584,7 @@
/* Minimum battery percentage for power on */
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
-/* Narrow VDC power path */
+/* Set this option when using a Narrow VDC (NVDC) charger, such as ISL9237/8. */
#undef CONFIG_CHARGER_NARROW_VDC
/*
@@ -3218,6 +3218,15 @@
/*****************************************************************************/
/*
+ * Define CONFIG_CHARGER_NARROW_VDC for chargers that use a Narrow VDC power
+ * architecture.
+ */
+#if defined(CONFIG_CHARGER_ISL9237) || defined(CONFIG_CHARGER_ISL9238)
+#define CONFIG_CHARGER_NARROW_VDC
+#endif
+
+/*****************************************************************************/
+/*
* Define CONFIG_BUTTON_TRIGGERED_RECOVERY if a board has a dedicated recovery
* button.
*/