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

Commit 6a0290fc authored by Vijayavardhan Vennapusa's avatar Vijayavardhan Vennapusa Committed by Hemant Kumar
Browse files

USB: dwc3-msm: Disable Update xfer for DBM on ep disable or dequeue



Enable update xfer for DBM while configuring dbm endpoint
and also clear update xfer before queueing end xfer command as
part of endpoint disable as hardware programming guide.

CRs-Fixed: 965207
Change-Id: Ib5ec650884ad06394280416ccf877c1ccce1eaaf
Signed-off-by: default avatarVijayavardhan Vennapusa <vvreddy@codeaurora.org>
Signed-off-by: default avatarChandana Kishori Chiluveru <cchiluve@codeaurora.org>
Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent c81de8ee
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -339,7 +339,7 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc)
		dwc3_free_one_event_buffer(dwc, evt);

	/* free GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_FREE);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_FREE, 0);
}

/**
@@ -362,7 +362,7 @@ static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length)
	dwc->ev_buf = evt;

	/* alloc GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_ALLOC);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_ALLOC, 0);
	return 0;
}

@@ -387,7 +387,7 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc)
	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);

	/* setup GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_SETUP);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_SETUP, 0);
	return 0;
}

@@ -406,7 +406,7 @@ void dwc3_event_buffers_cleanup(struct dwc3 *dwc)
	dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);

	/* cleanup GSI related event buffers */
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_CLEANUP);
	dwc3_notify_event(dwc, DWC3_GSI_EVT_BUF_CLEANUP, 0);
}

static int dwc3_alloc_scratch_buffers(struct dwc3 *dwc)
@@ -939,7 +939,7 @@ int dwc3_core_init(struct dwc3 *dwc)
		dwc3_writel(dwc->regs, DWC3_GUCTL3, reg);
	}

	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT, 0);

	return 0;

@@ -1049,19 +1049,20 @@ static void __maybe_unused dwc3_core_exit_mode(struct dwc3 *dwc)
	}
}

static void (*notify_event)(struct dwc3 *, unsigned int);
void dwc3_set_notifier(void (*notify)(struct dwc3 *, unsigned int))
static void (*notify_event)(struct dwc3 *, unsigned int, unsigned int);
void dwc3_set_notifier(void (*notify)(struct dwc3 *, unsigned int,
							unsigned int))
{
	notify_event = notify;
}
EXPORT_SYMBOL(dwc3_set_notifier);

int dwc3_notify_event(struct dwc3 *dwc, unsigned int event)
int dwc3_notify_event(struct dwc3 *dwc, unsigned int event, unsigned int value)
{
	int ret = 0;

	if (notify_event)
		notify_event(dwc, event);
		notify_event(dwc, event, value);
	else
		ret = -ENODEV;

@@ -1648,7 +1649,7 @@ static int dwc3_runtime_suspend(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_SUSPEND_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_SUSPEND_EVENT, 0))
		return 0;

	if (dwc3_runtime_checks(dwc))
@@ -1669,7 +1670,7 @@ static int dwc3_runtime_resume(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT, 0))
		return 0;

	device_init_wakeup(dev, false);
@@ -1722,7 +1723,7 @@ static int dwc3_suspend(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_SUSPEND_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_SUSPEND_EVENT, 0))
		return 0;

	ret = dwc3_suspend_common(dwc, PMSG_SUSPEND);
@@ -1740,7 +1741,7 @@ static int dwc3_resume(struct device *dev)
	int		ret;

	/* Check if platform glue driver handling PM, if not then handle here */
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT))
	if (!dwc3_notify_event(dwc, DWC3_CORE_PM_RESUME_EVENT, 0))
		return 0;

	pinctrl_pm_select_default_state(dev);
+18 −15
Original line number Diff line number Diff line
@@ -944,12 +944,13 @@ struct dwc3_scratchpad_array {
#define DWC3_CONTROLLER_NOTIFY_OTG_EVENT		6
#define DWC3_CONTROLLER_SET_CURRENT_DRAW_EVENT		7
#define DWC3_CONTROLLER_RESTART_USB_SESSION		8
#define DWC3_CONTROLLER_NOTIFY_DISABLE_UPDXFER		9

/* USB GSI event buffer related notification */
#define DWC3_GSI_EVT_BUF_ALLOC			9
#define DWC3_GSI_EVT_BUF_SETUP			10
#define DWC3_GSI_EVT_BUF_CLEANUP		11
#define DWC3_GSI_EVT_BUF_FREE			12
#define DWC3_GSI_EVT_BUF_ALLOC			10
#define DWC3_GSI_EVT_BUF_SETUP			11
#define DWC3_GSI_EVT_BUF_CLEANUP		12
#define DWC3_GSI_EVT_BUF_FREE			13

#define MAX_INTR_STATS				10

@@ -1603,7 +1604,9 @@ static inline void dwc3_ulpi_exit(struct dwc3 *dwc)
#endif

extern void dwc3_set_notifier(
		void (*notify)(struct dwc3 *dwc3, unsigned int event));
extern int dwc3_notify_event(struct dwc3 *dwc3, unsigned int event);
		void (*notify)(struct dwc3 *dwc3, unsigned int event,
						unsigned int value));
extern int dwc3_notify_event(struct dwc3 *dwc3, unsigned int event,
						unsigned int value);
void dwc3_usb3_phy_suspend(struct dwc3 *dwc, int suspend);
#endif /* __DRIVERS_USB_DWC3_CORE_H */
+17 −10
Original line number Diff line number Diff line
@@ -467,7 +467,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3_ep *dep, unsigned cmd,
		if (!(cmd & DWC3_DEPCMD_ENDTRANSFER)) {
			dwc->ep_cmd_timeout_cnt++;
			dwc3_notify_event(dwc,
				DWC3_CONTROLLER_RESTART_USB_SESSION);
				DWC3_CONTROLLER_RESTART_USB_SESSION, 0);
		}
		cmd_status = -ETIMEDOUT;
	}
@@ -2107,7 +2107,7 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)
	dwc->vbus_draw = mA;
	dev_dbg(dwc->dev, "Notify controller from %s. mA = %u\n", __func__, mA);
	dbg_event(0xFF, "currentDraw", mA);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_SET_CURRENT_DRAW_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_SET_CURRENT_DRAW_EVENT, 0);
	return 0;
}

@@ -2156,7 +2156,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
	 * during enumeration.
	 */
	dwc->b_suspend = false;
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT, 0);

	ret = dwc3_gadget_run_stop(dwc, is_on, false);
	spin_unlock_irqrestore(&dwc->lock, flags);

@@ -2492,7 +2493,7 @@ static int dwc3_gadget_restart_usb_session(struct usb_gadget *g)
	struct dwc3		*dwc = gadget_to_dwc(g);

	dbg_event(0xFF, "RestartUSBSession", 0);
	return dwc3_notify_event(dwc, DWC3_CONTROLLER_RESTART_USB_SESSION);
	return dwc3_notify_event(dwc, DWC3_CONTROLLER_RESTART_USB_SESSION, 0);
}

static const struct usb_gadget_ops dwc3_gadget_ops = {
@@ -2973,6 +2974,10 @@ void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum, bool force)
	    !dep->resource_index)
		return;

	if (dep->endpoint.endless)
		dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_DISABLE_UPDXFER,
								dep->number);

	/*
	 * NOTICE: We are violating what the Databook says about the
	 * EndTransfer command. Ideally we would _always_ wait for the
@@ -3049,7 +3054,7 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc)
	dbg_event(0xFF, "DISCONNECT INT", 0);
	dev_dbg(dwc->dev, "Notify OTG from %s\n", __func__);
	dwc->b_suspend = false;
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT, 0);

	reg = dwc3_readl(dwc->regs, DWC3_DCTL);
	reg &= ~DWC3_DCTL_INITU1ENA;
@@ -3109,7 +3114,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
	dbg_event(0xFF, "BUS RESET", 0);
	dev_dbg(dwc->dev, "Notify OTG from %s\n", __func__);
	dwc->b_suspend = false;
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT, 0);

	usb_gadget_vbus_draw(&dwc->gadget, 100);

@@ -3246,7 +3251,7 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
		return;
	}

	dwc3_notify_event(dwc, DWC3_CONTROLLER_CONNDONE_EVENT);
	dwc3_notify_event(dwc, DWC3_CONTROLLER_CONNDONE_EVENT, 0);

	/*
	 * Configure PHY via GUSB3PIPECTLn if required.
@@ -3282,7 +3287,8 @@ static void dwc3_gadget_wakeup_interrupt(struct dwc3 *dwc, bool remote_wakeup)
		 */
		dev_dbg(dwc->dev, "Notify OTG from %s\n", __func__);
		dwc->b_suspend = false;
		dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
		dwc3_notify_event(dwc,
				DWC3_CONTROLLER_NOTIFY_OTG_EVENT, 0);

		/*
		 * set state to U0 as function level resume is trying to queue
@@ -3424,7 +3430,7 @@ static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc,

		dev_dbg(dwc->dev, "Notify OTG from %s\n", __func__);
		dwc->b_suspend = true;
		dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT);
		dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_OTG_EVENT, 0);
	}

	dwc->link_state = next;
@@ -3558,7 +3564,8 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt)
			 */
			evt->lpos = (evt->lpos + left) %
					DWC3_EVENT_BUFFERS_SIZE;
			if (dwc3_notify_event(dwc, DWC3_CONTROLLER_ERROR_EVENT))
			if (dwc3_notify_event(dwc,
						DWC3_CONTROLLER_ERROR_EVENT, 0))
				dwc->err_evt_seen = 0;
			break;
		}