summaryrefslogtreecommitdiff
path: root/driver/charger/sm5803.h
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-08-03 17:13:39 -0700
committerCommit Bot <commit-bot@chromium.org>2020-08-15 02:01:55 +0000
commit75ff886b073bede08cbe64b935fc6e042f0d12ab (patch)
treed91e2659bbedb4587a4201fb2eaa67b95a4069b8 /driver/charger/sm5803.h
parent55554e281b65e4ca780bc1dfee28c2599e781efc (diff)
downloadchrome-ec-75ff886b073bede08cbe64b935fc6e042f0d12ab.tar.gz
sm5803: Add support for OCPC
This commit updates the SM5803 driver to add the required functionality for supporting OCPC. As this part does not have the ability to measure ISYS, one needs to make sure that flag is set in the OCPC chg_flags bitfield. Currently, sourcing out the mainboard port while charging through an auxiliary charger is not working. BUG=b:155224387 BRANCH=None TEST=Enable on waddledee, flash, verify DUT can charge thru the sub board port. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I7b60dec51e503c83a24799d523eb75408f91ce86 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2336175 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Justin TerAvest <teravest@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Justin TerAvest <teravest@chromium.org> Auto-Submit: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/charger/sm5803.h')
-rw-r--r--driver/charger/sm5803.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/driver/charger/sm5803.h b/driver/charger/sm5803.h
index 9fc04de0f4..d16f000323 100644
--- a/driver/charger/sm5803.h
+++ b/driver/charger/sm5803.h
@@ -138,6 +138,16 @@ enum sm5803_gpio0_modes {
#define SM5803_TINT_LOW_LEVEL 0xBF
#define SM5803_TINT_HIGH_LEVEL 0xD1
+/* IBAT levels - The IBAT levels increment in 7.32mA */
+#define SM5803_REG_IBAT_CHG_MEAS_MSB 0x44
+#define SM5803_REG_IBAT_CHG_MEAS_LSB 0x45
+#define SM5803_IBAT_CHG_MEAS_LSB GENMASK(1, 0)
+
+/* IBUS levels - The IBUS levels increment in 7.32mA */
+#define SM5803_REG_IBUS_CHG_MEAS_MSB 0x46
+#define SM5803_REG_IBUS_CHG_MEAS_LSB 0x47
+#define SM5803_IBUS_CHG_MEAS_LSB GENMASK(1, 0)
+
#define SM5803_REG_VBUS_MEAS_MSB 0x48
#define SM5803_REG_VBUS_MEAS_LSB 0x49
#define SM5803_VBUS_MEAS_LSB GENMASK(1, 0)
@@ -148,6 +158,11 @@ enum sm5803_gpio0_modes {
#define SM5803_REG_TINT_MEAS_MSB 0x4E
+/* VSYS levels - The VSYS levels increment in 23.4mV steps. */
+#define SM5803_REG_VSYS_MEAS_MSB 0x4C
+#define SM5803_REG_VSYS_MEAS_LSB 0x4D
+#define SM5803_VSYS_MEAS_LSB GENMASK(1, 0)
+
/* Charger registers (address 0x32) */
#define SM5803_REG_FLOW1 0x1C
@@ -180,6 +195,9 @@ enum sm5803_charger_modes {
#define SM5803_FLOW3_FW_SWITCH_PAUSE BIT(2)
#define SM5803_FLOW3_SOFT_DISABLE_EN BIT(3)
+#define SM5803_REG_SWITCHER_CONF 0x1F
+#define SM5803_SW_BCK_BST_CONF_AUTO BIT(0)
+
#define SM5803_REG_ANA_EN1 0x21
#define SM5803_ANA_EN1_CLS_DISABLE BIT(7)
@@ -249,12 +267,26 @@ enum sm5803_charger_modes {
#define SM5803_REG_PRECHG 0x41
#define SM5803_PRECHG_ICHG_PRE_SET GENMASK(5, 0)
+/* Fast charge Termination */
+#define SM5803_REG_FAST_CONF5 0x3D
+#define SM5803_CONF5_IBAT_EOC_TH GENMASK(3, 0)
+
+/* IR drop compensation */
+#define SM5803_REG_IR_COMP1 0x3F
+#define SM5803_IR_COMP_RES_SET_MSB GENMASK(7, 6)
+#define SM5803_IR_COMP_RES_SET_MSB_SHIFT 6
+#define SM5803_IR_COMP_EN BIT(5)
+
+/* LSB is in 1.67mOhm steps. */
+#define SM5803_REG_IR_COMP2 0x40
+
#define SM5803_REG_PHOT1 0x72
#define SM5803_PHOT1_IBAT_PHOT_COMP_EN BIT(0)
#define SM5803_PHOT1_IBUS_PHOT_COMP_EN BIT(1)
#define SM5803_PHOT1_VSYS_MON_EN BIT(2)
#define SM5803_PHOT1_VBUS_MON_EN BIT(3)
#define SM5803_PHOT1_DURATION GENMASK(6, 4)
+#define SM5803_PHOT1_DURATION_SHIFT 4
#define SM5803_PHOT1_IRQ_MODE BIT(7)
#define CHARGER_NAME "sm5803"