コード例 #1
0
/**
 * dwc3_otg_set_peripheral -  bind/unbind the peripheral controller driver.
 *
 * Returns 0 on success otherwise negative errno.
 */
static int dwc3_otg_set_peripheral(struct usb_otg *otg,
				struct usb_gadget *gadget)
{
	struct dwc3_otg	*dotg = container_of(otg, struct dwc3_otg, otg);
	struct otg_fsm	*fsm = &dotg->fsm;
	struct device	*dev = dotg->dwc->dev;

	if (gadget) {
		dev_err(dev, "Binding gadget %s\n", gadget->name);

		otg->gadget = gadget;
	} else {
		dev_err(dev, "Unbinding gadget\n");

		mutex_lock(&fsm->lock);
		if (otg->phy->state == OTG_STATE_B_PERIPHERAL) {
			/* Reset OTG SM */
			fsm->reset = 1;
			dwc3_otg_statemachine(fsm);
			fsm->reset = 0;
		}
		otg->gadget = NULL;
		mutex_unlock(&fsm->lock);

		dwc3_otg_run_sm(fsm);
	}

	return 0;
}
コード例 #2
0
void dwc3_otg_run_sm(struct otg_fsm *fsm)
{
	int	state_changed;

	mutex_lock(&fsm->lock);
	do {
		state_changed = dwc3_otg_statemachine(fsm);
	} while (state_changed > 0);
	mutex_unlock(&fsm->lock);
}
コード例 #3
0
ファイル: otg.c プロジェクト: qkdang/m462
void dwc3_otg_run_sm(struct otg_fsm *fsm)
{
	struct dwc3_otg	*dotg = container_of(fsm, struct dwc3_otg, fsm);
	int		state_changed;

	/* Prevent running SM on early system resume */
	if (!dotg->ready)
		return;

	mutex_lock(&fsm->lock);
	do {
		state_changed = dwc3_otg_statemachine(fsm);
	} while (state_changed > 0);
	mutex_unlock(&fsm->lock);
}