summaryrefslogtreecommitdiff
path: root/driver/charger
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-12-01 16:02:32 -0800
committerCommit Bot <commit-bot@chromium.org>2020-12-10 00:47:15 +0000
commit32892ef493fc4be12b24d90f753b8c89d4d9dfb8 (patch)
tree5b8f0ebd781b2888acd0c7639cce328d62a23aa0 /driver/charger
parent8ec0b306daa502ed9bd035587e1cebb877bbc9da (diff)
downloadchrome-ec-32892ef493fc4be12b24d90f753b8c89d4d9dfb8.tar.gz
sm5803: Add is_icl_reached method
The SM5803A has a more precise and faster way to determine if the input current limit is being reached. This commit registers that method with the common charger driver framework for use by the system. BUG=b:174167890 BRANCH=dedede TEST=`make -j buildall` Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I5f96e86f37294b6cbd4bcc57827bd0ffa845b7da Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2568564 Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver/charger')
-rw-r--r--driver/charger/sm5803.c17
-rw-r--r--driver/charger/sm5803.h3
2 files changed, 20 insertions, 0 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c
index 541499b256..525492f47c 100644
--- a/driver/charger/sm5803.c
+++ b/driver/charger/sm5803.c
@@ -14,6 +14,7 @@
#include "i2c.h"
#include "sm5803.h"
#include "system.h"
+#include "stdbool.h"
#include "throttle_ap.h"
#include "timer.h"
#include "usb_charge.h"
@@ -1331,6 +1332,21 @@ static enum ec_error_list sm5803_get_option(int chgnum, int *option)
return rv;
}
+static enum ec_error_list sm5803_is_input_current_limit_reached(int chgnum,
+ bool *reached)
+{
+ enum ec_error_list rv;
+ int reg;
+
+ rv = chg_read8(chgnum, SM5803_REG_LOG2, &reg);
+ if (rv)
+ return rv;
+
+ *reached = (reg & SM5803_ISOLOOP_ON) ? true : false;
+
+ return EC_SUCCESS;
+}
+
static enum ec_error_list sm5803_set_option(int chgnum, int option)
{
enum ec_error_list rv;
@@ -1624,6 +1640,7 @@ const struct charger_drv sm5803_drv = {
.enable_otg_power = &sm5803_enable_otg_power,
.is_sourcing_otg_power = &sm5803_is_sourcing_otg_power,
.set_vsys_compensation = &sm5803_set_vsys_compensation,
+ .is_icl_reached = &sm5803_is_input_current_limit_reached,
#ifdef CONFIG_CHARGE_RAMP_HW
.set_hw_ramp = &sm5803_set_hw_ramp,
.ramp_is_stable = &sm5803_ramp_is_stable,
diff --git a/driver/charger/sm5803.h b/driver/charger/sm5803.h
index d1181478a4..f46a23d880 100644
--- a/driver/charger/sm5803.h
+++ b/driver/charger/sm5803.h
@@ -313,6 +313,9 @@ enum sm5803_charger_modes {
#define SM5803_REG_LOG1 0x42
#define SM5803_BATFET_ON BIT(2)
+#define SM5803_REG_LOG2 0x43
+#define SM5803_ISOLOOP_ON BIT(1)
+
#define SM5803_REG_STATUS_CHG_REG 0x48
#define SM5803_STATUS_CHG_BATT_REMOVAL BIT(0)
#define SM5803_STATUS_CHG_CHG_REMOVAL BIT(1)