summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxiong.huang <xiong.huang@bitland.corp-partner.google.com>2019-11-03 19:45:07 +0800
committerCommit Bot <commit-bot@chromium.org>2019-11-08 05:13:15 +0000
commit65682795d639b111f950057a82d9d46647996875 (patch)
treef4d63230fbcd6f1bb6aab96d1c14472a5fb0df8d
parentafb2ed0ec1901eaeb38ae944e1d15562eba2fe7e (diff)
downloadchrome-ec-65682795d639b111f950057a82d9d46647996875.tar.gz
Kodama: SMP battery cannot be charged in over discharge state
SMP battery uses HW pre-charge circuit and pre-charge current is limited to ~50mA. Once the charge current is lower than IEOC level within CHG_TEDG_EOC, and TE is enabled, the charging power path will be turned off. Charger vendor advice that disable EOC and TE when battery stays over discharge state, otherwise enable EOC and TE. BUG=b:142630134 TEST=Verified on both SMP battery and Celxpert battery in over discharge state, all passed. BRANCH=kukui Change-Id: I7d6907d54ab555587a489333350de6e9aeffe60e Signed-off-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1893901 Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
-rw-r--r--board/kodama/battery.c30
-rw-r--r--driver/charger/rt946x.c6
-rw-r--r--driver/charger/rt946x.h5
3 files changed, 38 insertions, 3 deletions
diff --git a/board/kodama/battery.c b/board/kodama/battery.c
index 21e5672879..e64e0c167a 100644
--- a/board/kodama/battery.c
+++ b/board/kodama/battery.c
@@ -83,10 +83,37 @@ enum battery_present battery_hw_present(void)
int charger_profile_override(struct charge_state_data *curr)
{
+ const struct battery_info *batt_info = battery_get_info();
+ static int normal_charge_lock, over_discharge_lock;
/* battery temp in 0.1 deg C */
int bat_temp_c = curr->batt.temperature - 2731;
/*
+ * SMP battery uses HW pre-charge circuit and pre-charge current is
+ * limited to ~50mA. Once the charge current is lower than IEOC level
+ * within CHG_TEDG_EOC, and TE is enabled, the charging power path will
+ * be turned off. Disable EOC and TE when battery stays over discharge
+ * state, otherwise enable EOC and TE.
+ */
+ if (curr->batt.voltage < batt_info->voltage_min) {
+ normal_charge_lock = 0;
+
+ if (!over_discharge_lock && curr->state == ST_CHARGE) {
+ over_discharge_lock = 1;
+ rt946x_enable_charge_eoc(0);
+ rt946x_enable_charge_termination(0);
+ }
+ } else {
+ over_discharge_lock = 0;
+
+ if (!normal_charge_lock) {
+ normal_charge_lock = 1;
+ rt946x_enable_charge_eoc(1);
+ rt946x_enable_charge_termination(1);
+ }
+ }
+
+ /*
* When smart battery temperature is more than 45 deg C, the max
* charging voltage is 4100mV.
*/
@@ -107,9 +134,6 @@ int charger_profile_override(struct charge_state_data *curr)
if (!curr->batt.is_present &&
curr->requested_voltage == 0 &&
curr->requested_current == 0) {
- const struct battery_info *batt_info =
- battery_get_info();
-
/*
* b/138978212: With adapter plugged in S0, the system
* will set charging current and voltage as 0V/0A once
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c
index d6933b8736..cb7c36be3b 100644
--- a/driver/charger/rt946x.c
+++ b/driver/charger/rt946x.c
@@ -1198,6 +1198,12 @@ int rt946x_enable_charge_termination(int en)
(RT946X_REG_CHGCTRL2, RT946X_MASK_TE);
}
+int rt946x_enable_charge_eoc(int en)
+{
+ return (en ? rt946x_set_bit : rt946x_clr_bit)
+ (RT946X_REG_CHGCTRL9, RT946X_MASK_EOC);
+}
+
#ifdef CONFIG_CHARGER_MT6370
/* MT6370 LDO */
diff --git a/driver/charger/rt946x.h b/driver/charger/rt946x.h
index 86a0e7cd65..9cb8b7dfd8 100644
--- a/driver/charger/rt946x.h
+++ b/driver/charger/rt946x.h
@@ -335,8 +335,10 @@
#define RT946X_MASK_IPREC (0xF << RT946X_SHIFT_IPREC)
/* ========== CHGCTRL9 0x09 ============ */
+#define RT946X_SHIFT_EOC 3
#define RT946X_SHIFT_IEOC 4
+#define RT946X_MASK_EOC BIT(RT946X_SHIFT_EOC)
#define RT946X_MASK_IEOC (0xF << RT946X_SHIFT_IEOC)
/* ========== CHGCTRL10 0x0A ============ */
@@ -663,6 +665,9 @@ int rt946x_cutoff_battery(void);
/* Enable/Disable charge temination */
int rt946x_enable_charge_termination(int en);
+/* Enable/Disable charge EOC */
+int rt946x_enable_charge_eoc(int en);
+
/**
* Toggle BC12 detection
*