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

Commit 0dd1e2fd authored by Bar Weiner's avatar Bar Weiner Committed by Matt Wagantall
Browse files

usb: dwc3: gadget: Allow pullup on/off during LPM



gadget_pullup is currently used as part of dynamic
usb composition switch. If the user try to switch
composition while the core is in low power mode, it
results in unclocked access to usb core registers.
This change insures that the core is not in LPM
during the pullup on/off sequence.

Change-Id: I0b0913674a8fbf5af3d9be40fa749bac251b075a
Signed-off-by: default avatarBar Weiner <bweiner@codeaurora.org>
parent a859812e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -904,6 +904,7 @@ struct dwc3 {
	unsigned		err_evt_seen:1;
	unsigned		usb3_u1u2_disable:1;
	unsigned		enable_bus_suspend:1;
	unsigned		disable_during_lpm:1;

	struct dwc3_gadget_events	dbg_gadget_events;

+16 −0
Original line number Diff line number Diff line
@@ -1668,6 +1668,22 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
		return 0;
	}

	/*
	 * This insures that the core is not in LPM during the pullup
	 * on/off toggling.
	 */
	spin_unlock_irqrestore(&dwc->lock, flags);
	if (atomic_read(&dwc->in_lpm) && !is_on) {
		pm_runtime_get_sync(dwc->dev);
		dwc->disable_during_lpm = true;
	}

	if (is_on && dwc->disable_during_lpm) {
		pm_runtime_put_sync(dwc->dev);
		dwc->disable_during_lpm = false;
	}
	spin_lock_irqsave(&dwc->lock, flags);

	ret = dwc3_gadget_run_stop(dwc, is_on, false);

	spin_unlock_irqrestore(&dwc->lock, flags);