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

Commit fcabf414 authored by Rohith Kollalsi's avatar Rohith Kollalsi Committed by Gerrit - the friendly Code Review server
Browse files

usb: dwc3: Drive a pulse on DP for iio based cdp charger detection also



Charger detection can be iio based or psy based or ADSP based. In case
of psy based charger detection POWER_SUPPLY_USB_TYPE_CDP enum is
returned, while in case of iio based charger detection
POWER_SUPPLY_TYPE_USB_CDP enum is returned for cdp detection. Current
case is handling only psy based charger detection i.e driving a pulse
on DP for cdp detection is happening only for psy based charger
detection ensuring proper CDP detection, while failure is seen in
case of iio based cdp charger detection. Hence add support to check
appropriate enum for iio based charger detection as well. To add more
info for ADSP based charger detection driving of dp pulse will be
taken care by adsp.

Change-Id: I991a44efb77542b21fbfce14ab98ffad3f102edb
Signed-off-by: default avatarRohith Kollalsi <rkollals@codeaurora.org>
parent 7657cd1d
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -4070,6 +4070,7 @@ static int dwc3_msm_vbus_notifier(struct notifier_block *nb,
	struct dwc3_msm *mdwc = enb->mdwc;
	char *eud_str;
	const char *edev_name;
	bool is_cdp;

	if (!edev || !mdwc)
		return NOTIFY_DONE;
@@ -4094,12 +4095,21 @@ static int dwc3_msm_vbus_notifier(struct notifier_block *nb,
		mdwc->vbus_active = event;
	}

	/*
	 * In case of ADSP based charger detection driving a pulse on
	 * DP to ensure proper CDP detection will be taken care by
	 * ADSP.
	 */
	is_cdp = ((mdwc->apsd_source == IIO) &&
		(get_chg_type(mdwc) == POWER_SUPPLY_TYPE_USB_CDP)) ||
		((mdwc->apsd_source == PSY) &&
		(get_chg_type(mdwc) == POWER_SUPPLY_USB_TYPE_CDP));

	/*
	 * Drive a pulse on DP to ensure proper CDP detection
	 * and only when the vbus connect event is a valid one.
	 */
	if (get_chg_type(mdwc) == POWER_SUPPLY_USB_TYPE_CDP &&
			mdwc->vbus_active && !mdwc->check_eud_state) {
	if (is_cdp && mdwc->vbus_active && !mdwc->check_eud_state) {
		dev_dbg(mdwc->dev, "Connected to CDP, pull DP up\n");
		mdwc->hs_phy->charger_detect(mdwc->hs_phy);
	}