Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 17cc4335 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb1398: Do not read the registers before system resume"

parents 26d6f9e3 774896bc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1393,6 +1393,7 @@ static int smb1390_get_prop(struct power_supply *psy,
		rc = smb1390_get_prop_suspended(chip, prop, val);
		if (!rc)
			return rc;
		rc = 0;
	}

	switch (prop) {
+70 −13
Original line number Diff line number Diff line
@@ -310,6 +310,12 @@ struct smb1398_chip {
	u32			pl_input_mode;
	enum isns_mode		current_capability;
	int			cc_mode_taper_main_icl_ua;
	int			cp_status1;
	int			cp_status2;
	int			cp_enable;
	int			cp_isns_master;
	int			cp_isns_slave;
	int			cp_ilim;

	bool			status_change_running;
	bool			taper_work_running;
@@ -827,6 +833,45 @@ static enum power_supply_property div2_cp_master_props[] = {
	POWER_SUPPLY_PROP_MIN_ICL,
};

static int div2_cp_master_get_prop_suspended(struct smb1398_chip *chip,
				enum power_supply_property prop,
				union power_supply_propval *val)
{
	switch (prop) {
	case POWER_SUPPLY_PROP_CP_STATUS1:
		val->intval = chip->cp_status1;
		break;
	case POWER_SUPPLY_PROP_CP_STATUS2:
		val->intval = chip->cp_status2;
		break;
	case POWER_SUPPLY_PROP_CP_ENABLE:
		val->intval = chip->cp_enable;
		break;
	case POWER_SUPPLY_PROP_CP_SWITCHER_EN:
		val->intval = chip->switcher_en;
		break;
	case POWER_SUPPLY_PROP_CP_DIE_TEMP:
		val->intval = chip->die_temp;
		break;
	case POWER_SUPPLY_PROP_CP_ISNS:
		val->intval = chip->cp_isns_master;
		break;
	case POWER_SUPPLY_PROP_CP_ISNS_SLAVE:
		val->intval = chip->cp_isns_slave;
		break;
	case POWER_SUPPLY_PROP_CP_IRQ_STATUS:
		val->intval = chip->div2_irq_status;
		break;
	case POWER_SUPPLY_PROP_CP_ILIM:
		val->intval = chip->cp_ilim;
		break;
	default:
		return -EINVAL;
	}

	return 0;
}

static int div2_cp_master_get_prop(struct power_supply *psy,
				enum power_supply_property prop,
				union power_supply_propval *val)
@@ -835,21 +880,32 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
	int rc = 0, ilim_ma, temp, isns_ua;
	u8 status;

	/*
	 * Return the cached values when the system is in suspend state
	 * instead of reading the registers to avoid read failures.
	 */
	if (chip->in_suspend) {
		rc = div2_cp_master_get_prop_suspended(chip, prop, val);
		if (!rc)
			return rc;
		rc = 0;
	}

	switch (prop) {
	case POWER_SUPPLY_PROP_CP_STATUS1:
		rc = smb1398_div2_cp_get_status1(chip, &status);
		if (!rc)
			val->intval = status;
			chip->cp_status1 = val->intval = status;
		break;
	case POWER_SUPPLY_PROP_CP_STATUS2:
		rc = smb1398_div2_cp_get_status2(chip, &status);
		if (!rc)
			val->intval = status;
			chip->cp_status2 = val->intval = status;
		break;
	case POWER_SUPPLY_PROP_CP_ENABLE:
		rc = smb1398_get_enable_status(chip);
		if (!rc)
			val->intval = chip->smb_en &&
			chip->cp_enable = val->intval = chip->smb_en &&
				!get_effective_result(
						chip->div2_cp_disable_votable);
		break;
@@ -861,27 +917,27 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CP_ISNS:
		rc = smb1398_div2_cp_get_master_isns(chip, &isns_ua);
		if (rc >= 0)
			val->intval = isns_ua;
			chip->cp_isns_master = val->intval = isns_ua;
		break;
	case POWER_SUPPLY_PROP_CP_ISNS_SLAVE:
		rc = smb1398_div2_cp_get_slave_isns(chip, &isns_ua);
		if (rc >= 0)
			val->intval = isns_ua;
			chip->cp_isns_slave = val->intval = isns_ua;
		break;
	case POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER:
		val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_CP_DIE_TEMP:
		if (!chip->in_suspend) {
		rc = smb1398_get_die_temp(chip, &temp);
			if ((rc >= 0) && (temp <= THERMAL_SUSPEND_DECIDEGC))
		if (rc >= 0) {
			val->intval = temp;
			if (temp <= THERMAL_SUSPEND_DECIDEGC)
				chip->die_temp = temp;
		}

		if (chip->die_temp != -ENODATA)
			val->intval = chip->die_temp;
		else
			else if (chip->die_temp == -ENODATA)
				rc = -ENODATA;
			else
				val->intval = chip->die_temp;
		}
		break;
	case POWER_SUPPLY_PROP_CP_IRQ_STATUS:
		val->intval = chip->div2_irq_status;
@@ -899,6 +955,7 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
			if (!rc)
				val->intval = ilim_ma * 1000;
		}
		chip->cp_ilim = val->intval;
		break;
	case POWER_SUPPLY_PROP_CHIP_VERSION:
		val->intval = chip->pmic_rev_id->rev4;