diff options
author | Diana Z <dzigterman@chromium.org> | 2020-10-19 15:30:33 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-20 21:11:32 +0000 |
commit | edd8b73e8a062b709c2757d6f0085d0fe8146f43 (patch) | |
tree | d7d74b8c70f4ce175e0879560bdb6349ef043f17 | |
parent | 9fe1b8982470e4a5d300b98470d353afb3a9d8c1 (diff) | |
download | chrome-ec-edd8b73e8a062b709c2757d6f0085d0fe8146f43.tar.gz |
SM5803: Disable ramps on current set in discharge
Disabling the ramps on the current set in discharge reduces issues seen
with dongles drawing current during initial connection.
BRANCH=None
BUG=b:169966133,b:170517117
TEST=on drawlat, confirm CableCreations dongle can now consistently plug
in without having Vbus shut off
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I31e9d95cc6ca75b8b59b00aab2b24caad1c8cc72
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486297
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | driver/charger/sm5803.c | 10 | ||||
-rw-r--r-- | driver/charger/sm5803.h | 12 |
2 files changed, 18 insertions, 4 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index 14c81469ef..4b996e9e64 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -1332,6 +1332,11 @@ static enum ec_error_list sm5803_enable_otg_power(int chgnum, int enabled) reg &= ~SM5803_ANA_EN1_CLS_DISABLE; rv = chg_write8(chgnum, SM5803_REG_ANA_EN1, reg); + /* Disable ramps on current set in discharge */ + rv |= chg_read8(chgnum, SM5803_REG_DISCH_CONF6, ®); + reg |= SM5803_DISCH_CONF6_RAMPS_DIS; + rv |= chg_write8(chgnum, SM5803_REG_DISCH_CONF6, reg); + /* * In order to ensure the Vbus output doesn't overshoot too * much, turn the starting voltage down to 4.8 V and ramp up @@ -1368,6 +1373,11 @@ static enum ec_error_list sm5803_enable_otg_power(int chgnum, int enabled) rv |= chg_write8(chgnum, SM5803_REG_STATUS_DISCHG, status); + /* Re-enable ramps on current set in discharge */ + rv |= chg_read8(chgnum, SM5803_REG_DISCH_CONF6, ®); + reg &= ~SM5803_DISCH_CONF6_RAMPS_DIS; + rv |= chg_write8(chgnum, SM5803_REG_DISCH_CONF6, reg); + /* * PD tasks will always turn off previous sourcing on init. * Protect ourselves from brown out on init by checking if we're diff --git a/driver/charger/sm5803.h b/driver/charger/sm5803.h index a4989ab09e..59074830f8 100644 --- a/driver/charger/sm5803.h +++ b/driver/charger/sm5803.h @@ -239,6 +239,10 @@ enum sm5803_charger_modes { #define SM5803_DISCH_CONF5_CLS_LIMIT GENMASK(6, 0) #define SM5803_CLS_CURRENT_STEP 50 +#define SM5803_REG_DISCH_CONF6 0x35 +#define SM5803_DISCH_CONF6_RAMPS_DIS BIT(0) +#define SM5803_DISCH_CONF6_SMOOTH_DIS BIT(1) + /* * Vsys is 11 bits, with the lower 3 bits in the LSB register. * The pre-regulation value is 2.72 V + Vsys_prereg * 10 mV @@ -277,10 +281,6 @@ enum sm5803_charger_modes { #define SM5803_REG_FAST_CONF4 0x3C #define SM5803_CONF4_ICHG_FAST GENMASK(5, 0) -/* Precharge current limit is also intervals of 100 mA */ -#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) @@ -294,6 +294,10 @@ enum sm5803_charger_modes { /* LSB is in 1.67mOhm steps. */ #define SM5803_REG_IR_COMP2 0x40 +/* Precharge current limit is also intervals of 100 mA */ +#define SM5803_REG_PRECHG 0x41 +#define SM5803_PRECHG_ICHG_PRE_SET GENMASK(5, 0) + #define SM5803_REG_LOG1 0x42 #define SM5803_BATFET_ON BIT(2) |