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

Commit 29a6b28a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-smbcharger: do not float DP/DM lines during QC3.0 detection"

parents 4298339d ca064e42
Loading
Loading
Loading
Loading
+48 −2
Original line number Diff line number Diff line
@@ -5214,6 +5214,8 @@ static int smbchg_prepare_for_pulsing(struct smbchg_chip *chip)
		goto handle_removal;
	}

	set_usb_psy_dp_dm(chip, POWER_SUPPLY_DP_DM_DP0P6_DMF);

	/* disable APSD */
	pr_smb(PR_MISC, "Disabling APSD\n");
	rc = smbchg_sec_masked_write(chip,
@@ -5237,7 +5239,6 @@ static int smbchg_prepare_for_pulsing(struct smbchg_chip *chip)
	smbchg_sec_masked_write(chip, chip->usb_chgpth_base + USB_AICL_CFG,
			AICL_EN_BIT, AICL_EN_BIT);

	set_usb_psy_dp_dm(chip, POWER_SUPPLY_DP_DM_DP0P6_DMF);
	/*
	 * DCP will switch to HVDCP in this time by removing the short
	 * between DP DM
@@ -5705,6 +5706,42 @@ static int smbchg_dp_dm(struct smbchg_chip *chip, int val)
	return rc;
}

static int smbchg_get_prop_batt_charge_counter(struct smbchg_chip *chip)
{
	int rc;
	union power_supply_propval val;

	if (!chip->bms_psy)
		return -EINVAL;

	rc = power_supply_get_property(chip->bms_psy,
				POWER_SUPPLY_PROP_CHARGE_COUNTER, &val);
	if (rc < 0) {
		pr_smb(PR_STATUS, "Couldn't get charge count rc = %d\n", rc);
		return rc;
	}

	return val.intval;
}

static int smbchg_get_prop_batt_current_max(struct smbchg_chip *chip)
{
	int rc;
	union power_supply_propval val;

	if (!chip->usb_psy)
		return -EINVAL;

	rc = power_supply_get_property(chip->usb_psy,
				POWER_SUPPLY_PROP_CURRENT_MAX, &val);
	if (rc < 0) {
		pr_smb(PR_STATUS, "Couldn't get current max rc = %d\n", rc);
		return rc;
	}

	return val.intval;
}

static void update_typec_capability_status(struct smbchg_chip *chip,
					const union power_supply_propval *val)
{
@@ -5883,6 +5920,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_MAX,
	POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
	POWER_SUPPLY_PROP_CURRENT_MAX,
	POWER_SUPPLY_PROP_CURRENT_NOW,
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -5895,6 +5933,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_FLASH_ACTIVE,
	POWER_SUPPLY_PROP_FLASH_TRIGGER,
	POWER_SUPPLY_PROP_DP_DM,
	POWER_SUPPLY_PROP_CHARGE_COUNTER,
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
	POWER_SUPPLY_PROP_RERUN_AICL,
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
@@ -6046,6 +6085,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
		val->intval = smbchg_float_voltage_get(chip);
		break;
	case POWER_SUPPLY_PROP_CURRENT_MAX:
		val->intval = smbchg_get_prop_batt_current_max(chip);
		break;
	case POWER_SUPPLY_PROP_HEALTH:
		val->intval = get_prop_batt_health(chip);
		break;
@@ -6105,6 +6147,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_DP_DM:
		val->intval = chip->pulse_cnt;
		break;
	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
		val->intval = smbchg_get_prop_batt_charge_counter(chip);
		break;
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
		val->intval = smbchg_is_input_current_limited(chip);
		break;
@@ -6548,7 +6593,8 @@ static irqreturn_t usbin_uv_handler(int irq, void *_chip)
	if (chip->hvdcp_3_det_ignore_uv)
		goto out;

	if ((reg & USBIN_UV_BIT) && (reg & USBIN_SRC_DET_BIT)) {
	if ((reg & USBIN_UV_BIT) && (reg & USBIN_SRC_DET_BIT) &&
		!chip->hvdcp_3_det_ignore_uv) {
		pr_smb(PR_STATUS, "Very weak charger detected\n");
		chip->very_weak_charger = true;
		rc = smbchg_read(chip, &reg,