diff options
-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) |