summaryrefslogtreecommitdiff
path: root/driver/charger
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-07-21 13:51:01 -0600
committerCommit Bot <commit-bot@chromium.org>2020-07-23 19:48:39 +0000
commit8850f12ce079659f926e7ded69cc7fa6a928e227 (patch)
treead164faa69ecf8f87dc8c4606007ab27582d76cd /driver/charger
parent3397e18cec9902d7e249064756269d68ec53a4b1 (diff)
downloadchrome-ec-8850f12ce079659f926e7ded69cc7fa6a928e227.tar.gz
SM5803: Enable Vbus monitor when sourcing
The Vbus monitor is required when sourcing out power from the charger. Without it, the charger will not output 5V to a port partner. However, it should still be disabled when the charger is sinking to avoid false PROCHOT triggers. BRANCH=None BUG=b:160995584 TEST=on waddledee, confirm 5V can source out to Apple and HooToo dongles. Confirm on unplug that Vbus monitor is disabled through i2c read. Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I63ab87cc7080485a92c2e708bc70d1a398f87492 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2310861 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver/charger')
-rw-r--r--driver/charger/sm5803.c16
-rw-r--r--driver/charger/sm5803.h8
2 files changed, 23 insertions, 1 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c
index 37c055bef5..1dcc4fd39d 100644
--- a/driver/charger/sm5803.c
+++ b/driver/charger/sm5803.c
@@ -774,8 +774,22 @@ static enum ec_error_list sm5803_enable_otg_power(int chgnum, int enabled)
rv = chg_write8(chgnum, SM5803_REG_ANA_EN1, reg);
}
+ /*
+ * Vbus monitor comparator must be enabled for sourcing out voltage, and
+ * should be disabled when sinking to prevent false Vbus PROCHOT
+ * triggers
+ */
+ rv = chg_read8(chgnum, SM5803_REG_PHOT1, &reg);
+ if (rv)
+ return rv;
+ if (enabled)
+ reg |= SM5803_PHOT1_VBUS_MON_EN;
+ else
+ reg &= ~SM5803_PHOT1_VBUS_MON_EN;
+ rv |= chg_write8(chgnum, SM5803_REG_PHOT1, reg);
+
mutex_lock(&flow1_access_lock[chgnum]);
- rv = chg_read8(chgnum, SM5803_REG_FLOW1, &reg);
+ rv |= chg_read8(chgnum, SM5803_REG_FLOW1, &reg);
if (rv) {
mutex_unlock(&flow1_access_lock[chgnum]);
return rv;
diff --git a/driver/charger/sm5803.h b/driver/charger/sm5803.h
index f2791edca3..37626501fb 100644
--- a/driver/charger/sm5803.h
+++ b/driver/charger/sm5803.h
@@ -238,6 +238,14 @@ enum sm5803_gpio0_modes {
#define SM5803_REG_FAST_CONF4 0x3C
#define SM5803_CONF4_ICHG_FAST GENMASK(5, 0)
+#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_IRQ_MODE BIT(7)
+
#define CHARGER_NAME "sm5803"
#define CHARGE_V_MAX 20000