summaryrefslogtreecommitdiff
path: root/driver/charger
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-07-09 11:14:47 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-21 01:34:31 +0000
commit032bbb26f089d6285cf4198442c65c2621294290 (patch)
treed57367e1bcba479758ad63508674aa3e386822bd /driver/charger
parent3e083f33a6739b00ea69ba1387dedfc4af8821a6 (diff)
downloadchrome-ec-032bbb26f089d6285cf4198442c65c2621294290.tar.gz
OCPC: Calculate system & battery resistance
In order to optimize charging from the auxiliary charger, we need to calculate the system resistance as well as the battery resistance. This allows some charger ICs to compensate for the losses from their output node to the battery. In order to perform this calculation, we must do it when the AP is off (or in suspend) which provides the condition that nearly all of the charge current is entering the battery and isn't being largely consumed by the rest of the system. The combined Rsys+Rbatt calculation is relatively straightforward as it's the delta between the VSYS output and the battery voltage divided by the current entering the battery. In order to separate out the two terms, we can look at the delta between the VSYS output and the VSYS node that's connected to the BFET as well as look at the egress current from the auxiliary charger and the current entering the battery. This commit adds this system resistance measurements and enables it for the RAA489000. The resistances are updated in S5/G3 when charging from the auxiliary charger every ~2.4s. BUG=b:148980020 BRANCH=None TEST=Build and flash waddledoo, verify that charging continues to work in all power states and battery can become full. TEST=Verify that charge current is still close to the target without excessively exceeding it. TEST=Verify charging in constant load via `stressapptest`. TEST=Verify charging in bursty workload via `stressapptest` with pauses for power spikes while monitoring charge current with a current probe. TEST=Verify charging works out of battery cutoff from the auxiliary charger. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I1faa3a0b2b3d8f4fd44d72cd1f546226268df0c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2290058 Reviewed-by: Diana Z <dzigterman@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/charger')
-rw-r--r--driver/charger/isl923x.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c
index 797cac170d..fb6f60a8ed 100644
--- a/driver/charger/isl923x.c
+++ b/driver/charger/isl923x.c
@@ -1042,16 +1042,17 @@ static enum ec_error_list raa489000_set_vsys_compensation(int chgnum,
/*
* Rp1 is set between 36-156mOhms in 4mOhm increments. This must be
- * non-zero in order for compensation to work. The system keeps track
- * of combined resistance; we'll assume that Rp2 is what was statically
- * defined leaving Rp1 as the difference. If Rp1 is less than 36mOhms,
- * then the compensation is disabled.
+ * non-zero in order for compensation to work.
*
- * TODO(b/148980020): When we can calculate Rsys vs Rbatt, update this
- * accordingly.
+ * To get Rp1, we need to look at the delta between VSYS measured by the
+ * auxiliary charger IC and the primary charger IC where the actual VSYS
+ * node is as well as the current provided by the auxiliary charger IC.
+ * The system keeps track of combined resistance; therefore, Rp2 is the
+ * difference between the combined resistance and Rp1 that we calculate.
+ * If Rp1 is less than 36mOhms, then the compensation is disabled.
*/
- rp1 = o->combined_rsys_rbatt_mo - CONFIG_OCPC_DEF_RBATT_MOHMS;
- rp1 = MIN(rp1, RAA489000_RP1_MAX);
+
+ rp1 = MIN(o->rsys_mo, RAA489000_RP1_MAX);
rp1 -= RAA489000_RP1_MIN;
if (rp1 < 0) {
if (o->last_vsys == OCPC_UNINIT)
@@ -1064,7 +1065,7 @@ static enum ec_error_list raa489000_set_vsys_compensation(int chgnum,
}
/* Rp2 is set between 0-124mOhms in 4mOhm increments. */
- rp2 = CONFIG_OCPC_DEF_RBATT_MOHMS;
+ rp2 = o->rbatt_mo;
rp2 = CLAMP(rp2, RAA489000_RP2_MIN, RAA489000_RP2_MAX);
rp2 /= 4;