From edd8b73e8a062b709c2757d6f0085d0fe8146f43 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Mon, 19 Oct 2020 15:30:33 -0600 Subject: 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 Change-Id: I31e9d95cc6ca75b8b59b00aab2b24caad1c8cc72 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2486297 Reviewed-by: Aseda Aboagye --- driver/charger/sm5803.c | 10 ++++++++++ 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) -- cgit v1.2.1