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

Commit 26b8aa45 authored by Robert Baldyga's avatar Robert Baldyga Committed by Felipe Balbi
Browse files

usb: musb: gadget: add musb_match_ep() function



Add 'match_ep' callback to utilize chip-specific knowledge in endpoint matching
process. Function does the same that was done by chip-specific code inside
of epautoconf. Now this code can be removed from there to separate generic code
from platform specific logic.

Signed-off-by: default avatarRobert Baldyga <r.baldyga@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 8cc67b7b
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -83,29 +83,6 @@ struct usb_ep *usb_ep_autoconfig_ss(
			goto found_ep;
	}

	/* First, apply chip-specific "best usage" knowledge.
	 * This might make a good usb_gadget_ops hook ...
	 */
#ifdef CONFIG_BLACKFIN
	if (gadget_is_musbhdrc(gadget)) {
		if ((USB_ENDPOINT_XFER_BULK == type) ||
		    (USB_ENDPOINT_XFER_ISOC == type)) {
			if (USB_DIR_IN & desc->bEndpointAddress)
				ep = gadget_find_ep_by_name(gadget, "ep5in");
			else
				ep = gadget_find_ep_by_name(gadget, "ep6out");
		} else if (USB_ENDPOINT_XFER_INT == type) {
			if (USB_DIR_IN & desc->bEndpointAddress)
				ep = gadget_find_ep_by_name(gadget, "ep1in");
			else
				ep = gadget_find_ep_by_name(gadget, "ep2out");
		} else
			ep = NULL;
		if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
			goto found_ep;
	}
#endif

	/* Second, look at endpoints until an unclaimed one looks usable */
	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
		if (usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
+34 −0
Original line number Diff line number Diff line
@@ -1684,6 +1684,39 @@ static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on)
	return 0;
}

#ifdef CONFIG_BLACKFIN
static struct usb_ep *musb_match_ep(struct usb_gadget *g,
		struct usb_endpoint_descriptor *desc,
		struct usb_ss_ep_comp_descriptor *ep_comp)
{
	struct usb_ep *ep = NULL;

	switch (usb_endpoint_type(desc)) {
	case USB_ENDPOINT_XFER_ISOC:
	case USB_ENDPOINT_XFER_BULK:
		if (usb_endpoint_dir_in(desc))
			ep = gadget_find_ep_by_name(g, "ep5in");
		else
			ep = gadget_find_ep_by_name(g, "ep6out");
		break;
	case USB_ENDPOINT_XFER_INT:
		if (usb_endpoint_dir_in(desc))
			ep = gadget_find_ep_by_name(g, "ep1in");
		else
			ep = gadget_find_ep_by_name(g, "ep2out");
		break;
	default:
	}

	if (ep && usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
		return ep;

	return NULL;
}
#else
#define musb_match_ep NULL
#endif

static int musb_gadget_start(struct usb_gadget *g,
		struct usb_gadget_driver *driver);
static int musb_gadget_stop(struct usb_gadget *g);
@@ -1697,6 +1730,7 @@ static const struct usb_gadget_ops musb_gadget_operations = {
	.pullup			= musb_gadget_pullup,
	.udc_start		= musb_gadget_start,
	.udc_stop		= musb_gadget_stop,
	.match_ep		= musb_match_ep,
};

/* ----------------------------------------------------------------------- */