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

Commit 0708b193 authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa
Browse files

phy-msm-usb: Perform sdp_check for SDP charger as well



In case of wearables, there is a chance that usb pins get dirty and due to
that, USB might be out of low power mode. This could cause battery draining
faster as enumeration might fail due to dirty pins and charger ends up
stopping charging. Fix the issue by having workaround to have timer to
check whether USB enumeration happened or not. If no enumeration, treat as
disconnect & notify ETIMEDOUT to charger driver and enter low power mode.

Change-Id: I8b92f18c962a56b49ff5ac4d514b39babce1f370
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent d2b7b305
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -295,6 +295,8 @@ Optional properties :
- qcom,usbeth-reset-gpio: If present then an external usb-to-eth is connected to
	the USB host controller and its RESET_N signal is connected to this
	usbeth-reset-gpio GPIO. It should be driven LOW to RESET the usb-to-eth.
- qcom,enumeration-check-for-sdp: If present, start timer for SDP charger to check enumeration
	happen or not.

Example HSUSB OTG controller device node :
	usb@f9690000 {
+2 −0
Original line number Diff line number Diff line
@@ -400,7 +400,9 @@ static int hw_device_state(u32 dma)
		hw_cwrite(CAP_USBINTR, ~0,
			     USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
		hw_cwrite(CAP_USBCMD, USBCMD_RS, USBCMD_RS);
		udc->transceiver->flags |= PHY_SOFT_CONNECT;
	} else {
		udc->transceiver->flags &= ~PHY_SOFT_CONNECT;
		hw_cwrite(CAP_USBCMD, USBCMD_RS, 0);
		hw_cwrite(CAP_USBINTR, ~0, 0);
		/* Clear BIT(31) to disable AHB2AHB Bypass functionality */
+21 −11
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ struct msm_otg_platform_data {
};

#define SDP_CHECK_DELAY_MS 10000 /* in ms */
#define SDP_CHECK_BOOT_DELAY_MS 30000 /* in ms */

#define MSM_USB_BASE	(motg->regs)
#define MSM_USB_PHY_CSR_BASE (motg->phy_csr_regs)
@@ -1910,13 +1911,14 @@ static void msm_otg_notify_charger(struct msm_otg *motg, unsigned int mA)
							motg->chg_type);

	psy_type = get_psy_type(motg);
	if (psy_type == POWER_SUPPLY_TYPE_USB_FLOAT) {
		if (!mA)
	if (psy_type == POWER_SUPPLY_TYPE_USB_FLOAT ||
		(psy_type == POWER_SUPPLY_TYPE_USB &&
			motg->enable_sdp_check_timer)) {
		if (!mA) {
			pval.intval = -ETIMEDOUT;
		else
			pval.intval = 1000 * mA;
			goto set_prop;
		}
	}

	if (motg->cur_power == mA)
		return;
@@ -2766,7 +2768,7 @@ static void check_for_sdp_connection(struct work_struct *w)
	struct msm_otg *motg = container_of(w, struct msm_otg, sdp_check.work);

	/* Cable disconnected or device enumerated as SDP */
	if (!motg->vbus_state || motg->phy.otg->gadget->state >=
	if (!motg->vbus_state || motg->phy.otg->gadget->state >
							USB_STATE_DEFAULT)
		return;

@@ -2847,13 +2849,18 @@ static void msm_otg_sm_work(struct work_struct *w)
				break;
			}

			if (get_psy_type(motg) == POWER_SUPPLY_TYPE_USB_FLOAT)
				queue_delayed_work(motg->otg_wq,
				  &motg->sdp_check,
				  msecs_to_jiffies(SDP_CHECK_DELAY_MS));

			pm_runtime_get_sync(otg->usb_phy->dev);
			msm_otg_start_peripheral(otg, 1);
			if (get_psy_type(motg) == POWER_SUPPLY_TYPE_USB_FLOAT ||
				(get_psy_type(motg) == POWER_SUPPLY_TYPE_USB &&
				motg->enable_sdp_check_timer)) {
				queue_delayed_work(motg->otg_wq,
					&motg->sdp_check,
					msecs_to_jiffies(
					(phy->flags & PHY_SOFT_CONNECT) ?
					SDP_CHECK_DELAY_MS :
					SDP_CHECK_BOOT_DELAY_MS));
			}
			otg->state = OTG_STATE_B_PERIPHERAL;
		} else {
			pr_debug("Cable disconnected\n");
@@ -4107,6 +4114,9 @@ static int msm_otg_probe(struct platform_device *pdev)
	of_property_read_u32(pdev->dev.of_node, "qcom,pm-qos-latency",
				&motg->pm_qos_latency);

	motg->enable_sdp_check_timer = of_property_read_bool(pdev->dev.of_node,
				"qcom,enumeration-check-for-sdp");

	pdata = msm_otg_dt_to_pdata(pdev);
	if (!pdata) {
		ret = -ENOMEM;
+1 −0
Original line number Diff line number Diff line
@@ -330,6 +330,7 @@ struct msm_otg {
	struct work_struct notify_charger_work;
	struct work_struct extcon_register_work;
	struct notifier_block psy_nb;
	bool enable_sdp_check_timer;
};

struct ci13xxx_platform_data {
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#define PHY_LS_MODE		BIT(9)
#define PHY_USB_DP_CONCURRENT_MODE	BIT(10)
#define PHY_WAKEUP_WA_EN	BIT(11)
#define PHY_SOFT_CONNECT	BIT(12)

enum usb_phy_interface {
	USBPHY_INTERFACE_MODE_UNKNOWN,