summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKo <ko_ko@compal.corp-partner.google.com>2019-07-25 11:18:34 +0800
committerCommit Bot <commit-bot@chromium.org>2019-07-26 20:21:27 +0000
commit9ff89625dc098838a60ace547b2db4ebb27dee41 (patch)
tree1e03410dc09c0b78f29d94449b9e26c0ac22e47d
parent95ff1a1b6af7183160b8de1f480d32430afc1b97 (diff)
downloadchrome-ec-9ff89625dc098838a60ace547b2db4ebb27dee41.tar.gz
isl923x: Check max current in isl923x_set_dc_prochot
The DCProchot register takes a value in multiple of 128 up to 12800 mA. This patch makes isl923x_set_dc_prochot return error when a value exceeding the max is passed. Signed-off-by: Ko Ko <ko_ko@compal.corp-partner.google.com> BUG=b/130387567 BRANCH=Nami TEST=buildall Change-Id: If2155d7fc74c1491bf7c0a742ba8356c268a94a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1716673 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--driver/charger/isl923x.c15
-rw-r--r--driver/charger/isl923x.h9
2 files changed, 22 insertions, 2 deletions
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c
index 6911897d63..04abb042c8 100644
--- a/driver/charger/isl923x.c
+++ b/driver/charger/isl923x.c
@@ -318,6 +318,21 @@ int isl923x_set_ac_prochot(uint16_t ma)
return rv;
}
+int isl923x_set_dc_prochot(uint16_t ma)
+{
+ int rv;
+
+ if (ma > ISL923X_DC_PROCHOT_CURRENT_MAX) {
+ CPRINTS("%s: invalid current (%d mA)\n", __func__, ma);
+ return EC_ERROR_INVAL;
+ }
+
+ rv = raw_write16(ISL923X_REG_PROCHOT_DC, ma);
+ if (rv)
+ CPRINTS("%s failed (%d)", __func__, rv);
+ return rv;
+}
+
static void isl923x_init(void)
{
int reg;
diff --git a/driver/charger/isl923x.h b/driver/charger/isl923x.h
index 89595a60fa..8076b72e38 100644
--- a/driver/charger/isl923x.h
+++ b/driver/charger/isl923x.h
@@ -300,12 +300,17 @@ enum isl9237_fsm_state {
#endif /* __CROS_EC_ISL923X_H */
/**
- * Initialize AC prochot threshold
+ * Initialize AC & DC prochot threshold
*
- * @param Porchot threshold current in mA: multiple of 128 up to 6400 mA
+ * @param AC Porchot threshold current in mA:
+ * multiple of 128 up to 6400 mA
+ * DC Porchot threshold current in mA:
+ * multiple of 128 up to 12800 mA
* Bits below 128mA are truncated (ignored).
* @return enum ec_error_list
*/
int isl923x_set_ac_prochot(uint16_t ma);
+int isl923x_set_dc_prochot(uint16_t ma);
#define ISL923X_AC_PROCHOT_CURRENT_MAX 6400 /* mA */
+#define ISL923X_DC_PROCHOT_CURRENT_MAX 12800 /* mA */