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

Commit ee117031 authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa
Browse files

USB: dwc3: clear LANE0_PWR_PRESENT bit after initialization



Currently dwc3-msm driver is setting LANE0_PWR_PRESENT in QSCRATCH
SS_PHY_CTRL register, but not clearing this bit after completion of
initialization. This is affecting data lines behaviour during
charger detection issues when connected wall charger or HVDCP charger.
Hence clear this bit after completion of initialization sequence.

CRs-Fixed: 561316
Change-Id: I05fb75b77c45fc9466a832c83cf2be120dbe3fa2
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
parent 759f5a97
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -116,7 +116,6 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
	usb_phy_init(dwc->usb2_phy);
	usb_phy_init(dwc->usb3_phy);

	if (dwc->revision >= DWC3_REVISION_230A)
	dwc3_notify_event(dwc, DWC3_CONTROLLER_RESET_EVENT);

	/* Assert USB3 PHY reset */
@@ -148,7 +147,6 @@ static void dwc3_core_soft_reset(struct dwc3 *dwc)
	reg &= ~DWC3_GCTL_CORESOFTRESET;
	dwc3_writel(dwc->regs, DWC3_GCTL, reg);

	if (dwc->revision >= DWC3_REVISION_230A)
	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT);
}

@@ -455,6 +453,7 @@ void dwc3_post_host_reset_core_init(struct dwc3 *dwc)
{
	dwc3_core_init(dwc);
	dwc3_gadget_restart(dwc);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT);
}

static void (*notify_event) (struct dwc3 *, unsigned);
@@ -709,6 +708,8 @@ static int dwc3_probe(struct platform_device *pdev)
		goto err3;
	}

	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT);

	return 0;

err3:
+1 −0
Original line number Diff line number Diff line
@@ -663,6 +663,7 @@ struct dwc3_scratchpad_array {
#define DWC3_CORE_PM_COMPLETE_EVENT			4
#define DWC3_CORE_PM_SUSPEND_EVENT			5
#define DWC3_CORE_PM_RESUME_EVENT			6
#define DWC3_CONTROLLER_POST_INITIALIZATION_EVENT	7
/**
 * struct dwc3 - representation of our controller
 * @ctrl_req: usb control request which is used for ep0
+5 −0
Original line number Diff line number Diff line
@@ -1185,6 +1185,9 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned event)
{
	struct dwc3_msm *mdwc = dev_get_drvdata(dwc->dev->parent);

	if (dwc->revision < DWC3_REVISION_230A)
		return;

	switch (event) {
	case DWC3_CONTROLLER_ERROR_EVENT:
		dev_info(mdwc->dev, "DWC3_CONTROLLER_ERROR_EVENT received\n");
@@ -1208,6 +1211,8 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned event)
		dwc3_msm_restore_sec_config(mdwc->scm_dev_id);
		dwc->tx_fifo_size = mdwc->tx_fifo_size;
		break;
	case DWC3_CONTROLLER_POST_INITIALIZATION_EVENT:
		usb_phy_post_init(mdwc->ss_phy);
	default:
		dev_dbg(mdwc->dev, "unknown dwc3 event\n");
		break;
+14 −0
Original line number Diff line number Diff line
@@ -299,6 +299,19 @@ static int msm_ssphy_set_params(struct usb_phy *uphy)
	return 0;
}

static int msm_ssphy_post_init(struct usb_phy *uphy)
{
	struct msm_ssphy *phy = container_of(uphy, struct msm_ssphy, phy);
	u32 val;

	/* read initial value */
	val = readl_relaxed(phy->base + SS_PHY_CTRL_REG);
	val &= ~LANE0_PWR_PRESENT;
	writel_relaxed(val, phy->base + SS_PHY_CTRL_REG);

	return 0;
}

static int msm_ssphy_set_suspend(struct usb_phy *uphy, int suspend)
{
	struct msm_ssphy *phy = container_of(uphy, struct msm_ssphy, phy);
@@ -458,6 +471,7 @@ static int msm_ssphy_probe(struct platform_device *pdev)
	phy->phy.init			= msm_ssphy_init;
	phy->phy.set_suspend		= msm_ssphy_set_suspend;
	phy->phy.set_params		= msm_ssphy_set_params;
	phy->phy.post_init		= msm_ssphy_post_init;
	phy->phy.notify_connect		= msm_ssphy_notify_connect;
	phy->phy.notify_disconnect	= msm_ssphy_notify_disconnect;
	phy->phy.type			= USB_PHY_TYPE_USB3;
+12 −0
Original line number Diff line number Diff line
@@ -106,6 +106,9 @@ struct usb_phy {
	/* set additional settings parameters post-init */
	int	(*set_params)(struct usb_phy *x);

	/* do additional settings after complete initialization */
	int	(*post_init)(struct usb_phy *x);

	/* effective for B devices, ignored for A-peripheral */
	int	(*set_power)(struct usb_phy *x,
				unsigned mA);
@@ -202,6 +205,15 @@ usb_phy_set_params(struct usb_phy *x)
	return 0;
}

static inline int
usb_phy_post_init(struct usb_phy *x)
{
	if (x && x->post_init)
		return x->post_init(x);

	return 0;
}

/* for usb host and peripheral controller drivers */
#if IS_ENABLED(CONFIG_USB_PHY)
extern struct usb_phy *usb_get_phy(enum usb_phy_type type);