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

Commit 8cc67b7b authored by Robert Baldyga's avatar Robert Baldyga Committed by Felipe Balbi
Browse files

usb: gadget: goku_udc: add goku_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.

[ balbi@ti.com : fix build breakage ]

Signed-off-by: default avatarRobert Baldyga <r.baldyga@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 3e8b2318
Loading
Loading
Loading
Loading
+2 −18
Original line number Original line Diff line number Diff line
@@ -86,24 +86,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
	/* First, apply chip-specific "best usage" knowledge.
	/* First, apply chip-specific "best usage" knowledge.
	 * This might make a good usb_gadget_ops hook ...
	 * This might make a good usb_gadget_ops hook ...
	 */
	 */
	if (gadget_is_goku(gadget)) {
		if (USB_ENDPOINT_XFER_INT == type) {
			/* single buffering is enough */
			ep = gadget_find_ep_by_name(gadget, "ep3-bulk");
			if (ep && usb_gadget_ep_match_desc(gadget,
					ep, desc, ep_comp))
				goto found_ep;
		} else if (USB_ENDPOINT_XFER_BULK == type
				&& (USB_DIR_IN & desc->bEndpointAddress)) {
			/* DMA may be available */
			ep = gadget_find_ep_by_name(gadget, "ep2-bulk");
			if (ep && usb_gadget_ep_match_desc(gadget,
					ep, desc, ep_comp))
				goto found_ep;
		}

#ifdef CONFIG_BLACKFIN
#ifdef CONFIG_BLACKFIN
	} else if (gadget_is_musbhdrc(gadget)) {
	if (gadget_is_musbhdrc(gadget)) {
		if ((USB_ENDPOINT_XFER_BULK == type) ||
		if ((USB_ENDPOINT_XFER_BULK == type) ||
		    (USB_ENDPOINT_XFER_ISOC == type)) {
		    (USB_ENDPOINT_XFER_ISOC == type)) {
			if (USB_DIR_IN & desc->bEndpointAddress)
			if (USB_DIR_IN & desc->bEndpointAddress)
@@ -119,8 +103,8 @@ struct usb_ep *usb_ep_autoconfig_ss(
			ep = NULL;
			ep = NULL;
		if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
		if (ep && usb_gadget_ep_match_desc(gadget, ep, desc, ep_comp))
			goto found_ep;
			goto found_ep;
#endif
	}
	}
#endif


	/* Second, look at endpoints until an unclaimed one looks usable */
	/* Second, look at endpoints until an unclaimed one looks usable */
	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
	list_for_each_entry (ep, &gadget->ep_list, ep_list) {
+30 −0
Original line number Original line Diff line number Diff line
@@ -990,6 +990,35 @@ static int goku_get_frame(struct usb_gadget *_gadget)
	return -EOPNOTSUPP;
	return -EOPNOTSUPP;
}
}


static struct usb_ep *goku_match_ep(struct usb_gadget *g,
		struct usb_endpoint_descriptor *desc,
		struct usb_ss_ep_comp_descriptor *ep_comp)
{
	struct goku_udc	*dev = to_goku_udc(g);
	struct usb_ep *ep;

	switch (usb_endpoint_type(desc)) {
	case USB_ENDPOINT_XFER_INT:
		/* single buffering is enough */
		ep = &dev->ep[3].ep;
		if (usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
			return ep;
		break;
	case USB_ENDPOINT_XFER_BULK:
		if (usb_endpoint_dir_in(desc)) {
			/* DMA may be available */
			ep = &dev->ep[2].ep;
			if (usb_gadget_ep_match_desc(g, ep, desc, ep_comp))
				return ep;
		}
		break;
	default:
		/* nothing */ ;
	}

	return NULL;
}

static int goku_udc_start(struct usb_gadget *g,
static int goku_udc_start(struct usb_gadget *g,
		struct usb_gadget_driver *driver);
		struct usb_gadget_driver *driver);
static int goku_udc_stop(struct usb_gadget *g);
static int goku_udc_stop(struct usb_gadget *g);
@@ -998,6 +1027,7 @@ static const struct usb_gadget_ops goku_ops = {
	.get_frame	= goku_get_frame,
	.get_frame	= goku_get_frame,
	.udc_start	= goku_udc_start,
	.udc_start	= goku_udc_start,
	.udc_stop	= goku_udc_stop,
	.udc_stop	= goku_udc_stop,
	.match_ep	= goku_match_ep,
	// no remote wakeup
	// no remote wakeup
	// not selfpowered
	// not selfpowered
};
};