diff options
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/sm5803.c | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c index a3d59b1e55..460dcf4093 100644 --- a/driver/charger/sm5803.c +++ b/driver/charger/sm5803.c @@ -653,12 +653,6 @@ static void sm5803_init(int chgnum) rv = chg_write8(chgnum, SM5803_REG_DPM_VL_SET_MSB, (reg >> 3)); rv |= chg_write8(chgnum, SM5803_REG_DPM_VL_SET_LSB, (reg & 0x7)); - /* Set the VCHGPWR thresholds to mirror those for VBUS. */ - rv |= meas_write8(chgnum, SM5803_REG_VCHG_PWR_HIGH_TH, - SM5803_VBUS_HIGH_LEVEL); - rv |= meas_write8(chgnum, SM5803_REG_VCHG_PWR_LOW_TH, - SM5803_VBUS_LOW_LEVEL); - /* Set default input current */ reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_INPUT_CURRENT) & SM5803_CHG_ILIM_RAW; @@ -689,12 +683,8 @@ static void sm5803_init(int chgnum) rv |= main_write8(chgnum, SM5803_REG_INT2_EN, reg); - /* - * Configure TINT & VCHGPWR interrupts to fire after thresholds are set. - */ - rv |= main_read8(chgnum, SM5803_REG_INT2_EN, ®); - reg |= SM5803_INT2_TINT | SM5803_INT2_VCHGPWR; - rv |= main_write8(chgnum, SM5803_REG_INT2_EN, reg); + /* Configure TINT interrupts to fire after thresholds are set */ + rv |= main_write8(chgnum, SM5803_REG_INT2_EN, SM5803_INT2_TINT); /* * Configure CHG_ENABLE to only be set through I2C by setting @@ -1071,6 +1061,7 @@ void sm5803_handle_interrupt(int chgnum) if (IS_ENABLED(CONFIG_USB_CHARGER)) usb_charger_vbus_change(chgnum, 1); } + board_check_extpower(); } rv = main_read8(chgnum, SM5803_REG_INT2_REQ, &int_reg); @@ -1114,10 +1105,6 @@ void sm5803_handle_interrupt(int chgnum) */ } - /* Update extpower if VCHGPWR changes. */ - if (int_reg & SM5803_INT2_VCHGPWR) - board_check_extpower(); - if (int_reg & SM5803_INT2_VBATSNSP) { int meas_volt; uint32_t platform_id; @@ -1597,33 +1584,30 @@ static enum ec_error_list sm5803_get_option(int chgnum, int *option) enum ec_error_list sm5803_is_acok(int chgnum, bool *acok) { int rv; - enum sm5803_charger_modes mode; - int reg; + int reg, vbus_mv; + + rv = main_read8(chgnum, SM5803_REG_STATUS1, ®); - rv = chg_read8(chgnum, SM5803_REG_FLOW1, ®); if (rv) return rv; - /* The charger mode is contained in the last 2 bits. */ - reg &= SM5803_FLOW1_MODE; - mode = (enum sm5803_charger_modes)reg; - /* If we're not sinking, then AC can't be OK. */ - if (mode != CHARGER_MODE_SINK) { + if (!(reg & SM5803_STATUS1_CHG_DET)) { *acok = false; return EC_SUCCESS; } /* - * Okay, we're sinking. Check that VCHGPWR has some voltage. This + * Okay, we're sinking. Check that VBUS has some voltage. This * should indicate that the path is good. */ - rv = meas_read8(chgnum, SM5803_REG_VCHG_PWR_MSB, ®); + rv = charger_get_vbus_voltage(chgnum, &vbus_mv); + if (rv) return rv; - /* Assume that ACOK would be asserted if VCHGPWR is higher than ~4V. */ - *acok = reg >= SM5803_VBUS_HIGH_LEVEL; + /* Assume that ACOK would be asserted if VBUS is higher than ~4V. */ + *acok = vbus_mv >= 4000; return EC_SUCCESS; } |