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

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

Merge "power: supply: qcom: add support to control hvdcp3 detection dynamically"

parents a8909822 986bff58
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -328,6 +328,7 @@ static struct device_attribute power_supply_attrs[] = {
	POWER_SUPPLY_ATTR(batt_full_current),
	POWER_SUPPLY_ATTR(recharge_soc),
	POWER_SUPPLY_ATTR(toggle_stat),
	POWER_SUPPLY_ATTR(allow_hvdcp3),
	/* Local extensions of type int64_t */
	POWER_SUPPLY_ATTR(charge_counter_ext),
	/* Properties of type `const char *' */
+42 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ struct smbchg_chip {
	bool				vbat_above_headroom;
	bool				force_aicl_rerun;
	bool				hvdcp3_supported;
	bool				allow_hvdcp3_detection;
	bool				restricted_charging;
	bool				skip_usb_suspend_for_fake_battery;
	bool				hvdcp_not_supported;
@@ -5021,6 +5022,30 @@ static int fake_insertion_removal(struct smbchg_chip *chip, bool insertion)
	return 0;
}

static void smbchg_handle_hvdcp3_disable(struct smbchg_chip *chip)
{
	enum power_supply_type usb_supply_type;
	char *usb_type_name = "NULL";

	if (chip->allow_hvdcp3_detection)
		return;

	chip->pulse_cnt = 0;

	if (is_hvdcp_present(chip)) {
		smbchg_change_usb_supply_type(chip,
			POWER_SUPPLY_TYPE_USB_HVDCP);
	} else if (is_usb_present(chip)) {
		read_usb_type(chip, &usb_type_name, &usb_supply_type);
		smbchg_change_usb_supply_type(chip, usb_supply_type);
		if (usb_supply_type == POWER_SUPPLY_TYPE_USB_DCP)
			schedule_delayed_work(&chip->hvdcp_det_work,
				msecs_to_jiffies(HVDCP_NOTIFY_MS));
	} else {
		smbchg_change_usb_supply_type(chip, POWER_SUPPLY_TYPE_UNKNOWN);
	}
}

static int smbchg_prepare_for_pulsing(struct smbchg_chip *chip)
{
	int rc = 0;
@@ -5241,6 +5266,9 @@ static int smbchg_unprepare_for_pulsing(struct smbchg_chip *chip)
		pr_smb(PR_MISC, "HVDCP removed\n");
		update_usb_status(chip, 0, 0);
	}

	smbchg_handle_hvdcp3_disable(chip);

	return rc;
}

@@ -5425,6 +5453,8 @@ static int smbchg_unprepare_for_pulsing_lite(struct smbchg_chip *chip)
	if (rc < 0)
		pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc);

	smbchg_handle_hvdcp3_disable(chip);

	return rc;
}

@@ -5713,6 +5743,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
	POWER_SUPPLY_PROP_RERUN_AICL,
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
	POWER_SUPPLY_PROP_ALLOW_HVDCP3,
};

static int smbchg_battery_set_property(struct power_supply *psy,
@@ -5790,6 +5821,12 @@ static int smbchg_battery_set_property(struct power_supply *psy,
		if (chip->typec_psy)
			update_typec_otg_status(chip, val->intval, false);
		break;
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		if (chip->allow_hvdcp3_detection != val->intval) {
			chip->allow_hvdcp3_detection = !!val->intval;
			power_supply_changed(chip->batt_psy);
		}
		break;
	default:
		return -EINVAL;
	}
@@ -5813,6 +5850,7 @@ static int smbchg_battery_is_writeable(struct power_supply *psy,
	case POWER_SUPPLY_PROP_DP_DM:
	case POWER_SUPPLY_PROP_RERUN_AICL:
	case POWER_SUPPLY_PROP_RESTRICTED_CHARGING:
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		rc = 1;
		break;
	default:
@@ -5913,6 +5951,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_INPUT_CURRENT_NOW:
		val->intval = smbchg_get_iusb(chip);
		break;
	case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
		val->intval = chip->allow_hvdcp3_detection;
		break;
	default:
		return -EINVAL;
	}
@@ -8247,6 +8288,7 @@ static int smbchg_probe(struct platform_device *pdev)
			goto out;
		}
	}
	chip->allow_hvdcp3_detection = true;

	if (chip->cfg_chg_led_support &&
			chip->schg_version == QPNP_SCHG_LITE) {
+1 −0
Original line number Diff line number Diff line
@@ -279,6 +279,7 @@ enum power_supply_property {
	POWER_SUPPLY_PROP_BATT_FULL_CURRENT,
	POWER_SUPPLY_PROP_RECHARGE_SOC,
	POWER_SUPPLY_PROP_TOGGLE_STAT,
	POWER_SUPPLY_PROP_ALLOW_HVDCP3,
	/* Local extensions of type int64_t */
	POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
	/* Properties of type `const char *' */