Lines Matching full:ep

31 	struct isp1760_ep *ep;  member
40 static inline struct isp1760_ep *ep_to_udc_ep(struct usb_ep *ep) in ep_to_udc_ep() argument
42 return container_of(ep, struct isp1760_ep, ep); in ep_to_udc_ep()
116 return &udc->ep[0]; in isp1760_udc_find_ep()
118 for (i = 1; i < ARRAY_SIZE(udc->ep); ++i) { in isp1760_udc_find_ep()
119 if (udc->ep[i].addr == index) in isp1760_udc_find_ep()
120 return udc->ep[i].desc ? &udc->ep[i] : NULL; in isp1760_udc_find_ep()
127 struct isp1760_ep *ep, int dir) in __isp1760_udc_select_ep() argument
129 isp1760_udc_write(udc, DC_ENDPIDX, ep->addr & USB_ENDPOINT_NUMBER_MASK); in __isp1760_udc_select_ep()
139 * @ep: The endpoint
150 struct isp1760_ep *ep) in isp1760_udc_select_ep() argument
152 __isp1760_udc_select_ep(udc, ep, ep->addr & USB_ENDPOINT_DIR_MASK); in isp1760_udc_select_ep()
156 static void isp1760_udc_ctrl_send_status(struct isp1760_ep *ep, int dir) in isp1760_udc_ctrl_send_status() argument
158 struct isp1760_udc *udc = ep->udc; in isp1760_udc_ctrl_send_status()
181 static void isp1760_udc_request_complete(struct isp1760_ep *ep, in isp1760_udc_request_complete() argument
185 struct isp1760_udc *udc = ep->udc; in isp1760_udc_request_complete()
188 dev_dbg(ep->udc->isp->dev, "completing request %p with status %d\n", in isp1760_udc_request_complete()
191 req->ep = NULL; in isp1760_udc_request_complete()
193 req->req.complete(&ep->ep, &req->req); in isp1760_udc_request_complete()
202 if (status == 0 && ep->addr == 0 && udc->ep0_dir == USB_DIR_OUT) in isp1760_udc_request_complete()
203 isp1760_udc_ctrl_send_status(ep, USB_DIR_OUT); in isp1760_udc_request_complete()
208 static void isp1760_udc_ctrl_send_stall(struct isp1760_ep *ep) in isp1760_udc_ctrl_send_stall() argument
210 struct isp1760_udc *udc = ep->udc; in isp1760_udc_ctrl_send_stall()
213 dev_dbg(ep->udc->isp->dev, "%s(ep%02x)\n", __func__, ep->addr); in isp1760_udc_ctrl_send_stall()
218 __isp1760_udc_select_ep(udc, ep, USB_DIR_OUT); in isp1760_udc_ctrl_send_stall()
220 __isp1760_udc_select_ep(udc, ep, USB_DIR_IN); in isp1760_udc_ctrl_send_stall()
234 static bool isp1760_udc_receive(struct isp1760_ep *ep, in isp1760_udc_receive() argument
237 struct isp1760_udc *udc = ep->udc; in isp1760_udc_receive()
242 isp1760_udc_select_ep(udc, ep); in isp1760_udc_receive()
283 __func__, req, req->req.actual, req->req.length, ep->maxpacket, in isp1760_udc_receive()
286 ep->rx_pending = false; in isp1760_udc_receive()
292 if (req->req.actual == req->req.length || len < ep->maxpacket) { in isp1760_udc_receive()
300 static void isp1760_udc_transmit(struct isp1760_ep *ep, in isp1760_udc_transmit() argument
303 struct isp1760_udc *udc = ep->udc; in isp1760_udc_transmit()
308 ep->maxpacket); in isp1760_udc_transmit()
314 __isp1760_udc_select_ep(udc, ep, USB_DIR_IN); in isp1760_udc_transmit()
330 if (ep->addr == 0) in isp1760_udc_transmit()
336 static void isp1760_ep_rx_ready(struct isp1760_ep *ep) in isp1760_ep_rx_ready() argument
338 struct isp1760_udc *udc = ep->udc; in isp1760_ep_rx_ready()
344 if (ep->addr == 0 && udc->ep0_state != ISP1760_CTRL_DATA_OUT) { in isp1760_ep_rx_ready()
351 if (ep->addr != 0 && !ep->desc) { in isp1760_ep_rx_ready()
353 dev_dbg(udc->isp->dev, "%s: ep%02x is disabled\n", __func__, in isp1760_ep_rx_ready()
354 ep->addr); in isp1760_ep_rx_ready()
358 if (list_empty(&ep->queue)) { in isp1760_ep_rx_ready()
359 ep->rx_pending = true; in isp1760_ep_rx_ready()
361 dev_dbg(udc->isp->dev, "%s: ep%02x (%p) has no request queued\n", in isp1760_ep_rx_ready()
362 __func__, ep->addr, ep); in isp1760_ep_rx_ready()
366 req = list_first_entry(&ep->queue, struct isp1760_request, in isp1760_ep_rx_ready()
368 complete = isp1760_udc_receive(ep, req); in isp1760_ep_rx_ready()
373 isp1760_udc_request_complete(ep, req, 0); in isp1760_ep_rx_ready()
376 static void isp1760_ep_tx_complete(struct isp1760_ep *ep) in isp1760_ep_tx_complete() argument
378 struct isp1760_udc *udc = ep->udc; in isp1760_ep_tx_complete()
385 if (ep->addr == 0 && udc->ep0_state != ISP1760_CTRL_DATA_IN) { in isp1760_ep_tx_complete()
392 if (list_empty(&ep->queue)) { in isp1760_ep_tx_complete()
398 if (ep->addr == 0) { in isp1760_ep_tx_complete()
399 isp1760_udc_ctrl_send_status(ep, USB_DIR_IN); in isp1760_ep_tx_complete()
405 dev_dbg(udc->isp->dev, "%s: ep%02x has no request queued\n", in isp1760_ep_tx_complete()
406 __func__, ep->addr); in isp1760_ep_tx_complete()
410 req = list_first_entry(&ep->queue, struct isp1760_request, in isp1760_ep_tx_complete()
415 !(req->req.length % ep->maxpacket) && in isp1760_ep_tx_complete()
420 req, req->req.actual, req->req.length, ep->maxpacket, in isp1760_ep_tx_complete()
431 if (ep->addr == 0) in isp1760_ep_tx_complete()
432 isp1760_udc_ctrl_send_status(ep, USB_DIR_IN); in isp1760_ep_tx_complete()
434 if (!list_empty(&ep->queue)) in isp1760_ep_tx_complete()
435 req = list_first_entry(&ep->queue, in isp1760_ep_tx_complete()
448 isp1760_udc_transmit(ep, req); in isp1760_ep_tx_complete()
453 isp1760_udc_request_complete(ep, complete, 0); in isp1760_ep_tx_complete()
456 static int __isp1760_udc_set_halt(struct isp1760_ep *ep, bool halt) in __isp1760_udc_set_halt() argument
458 struct isp1760_udc *udc = ep->udc; in __isp1760_udc_set_halt()
460 dev_dbg(udc->isp->dev, "%s: %s halt on ep%02x\n", __func__, in __isp1760_udc_set_halt()
461 halt ? "set" : "clear", ep->addr); in __isp1760_udc_set_halt()
463 if (ep->desc && usb_endpoint_xfer_isoc(ep->desc)) { in __isp1760_udc_set_halt()
464 dev_dbg(udc->isp->dev, "%s: ep%02x is isochronous\n", __func__, in __isp1760_udc_set_halt()
465 ep->addr); in __isp1760_udc_set_halt()
469 isp1760_udc_select_ep(udc, ep); in __isp1760_udc_set_halt()
476 if (ep->addr == 0) { in __isp1760_udc_set_halt()
478 __isp1760_udc_select_ep(udc, ep, USB_DIR_IN); in __isp1760_udc_set_halt()
495 if ((ep->addr & USB_DIR_IN) && !list_empty(&ep->queue)) { in __isp1760_udc_set_halt()
498 req = list_first_entry(&ep->queue, in __isp1760_udc_set_halt()
500 isp1760_udc_transmit(ep, req); in __isp1760_udc_set_halt()
504 ep->halted = halt; in __isp1760_udc_set_halt()
516 struct isp1760_ep *ep; in isp1760_udc_get_status() local
532 ep = isp1760_udc_find_ep(udc, le16_to_cpu(req->wIndex)); in isp1760_udc_get_status()
533 if (!ep) in isp1760_udc_get_status()
537 if (ep->halted) in isp1760_udc_get_status()
580 isp1760_udc_ctrl_send_status(&udc->ep[0], USB_DIR_OUT); in isp1760_udc_set_address()
604 struct isp1760_ep *ep; in isp1760_ep0_setup_standard() local
610 ep = isp1760_udc_find_ep(udc, index); in isp1760_ep0_setup_standard()
611 if (!ep) in isp1760_ep0_setup_standard()
621 if (!ep->wedged) in isp1760_ep0_setup_standard()
622 stall = __isp1760_udc_set_halt(ep, false); in isp1760_ep0_setup_standard()
627 isp1760_udc_ctrl_send_status(&udc->ep[0], in isp1760_ep0_setup_standard()
648 struct isp1760_ep *ep; in isp1760_ep0_setup_standard() local
654 ep = isp1760_udc_find_ep(udc, index); in isp1760_ep0_setup_standard()
655 if (!ep) in isp1760_ep0_setup_standard()
660 stall = __isp1760_udc_set_halt(ep, true); in isp1760_ep0_setup_standard()
662 isp1760_udc_ctrl_send_status(&udc->ep[0], in isp1760_ep0_setup_standard()
728 isp1760_udc_ctrl_send_stall(&udc->ep[0]); in isp1760_ep0_setup()
766 isp1760_udc_ctrl_send_stall(&udc->ep[0]); in isp1760_ep0_setup()
773 static int isp1760_ep_enable(struct usb_ep *ep, in isp1760_ep_enable() argument
776 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_enable()
790 le16_to_cpu(desc->wMaxPacketSize) > ep->maxpacket) { in isp1760_ep_enable()
792 "%s: invalid descriptor type %u addr %02x ep addr %02x max packet size %u/%u\n", in isp1760_ep_enable()
795 le16_to_cpu(desc->wMaxPacketSize), ep->maxpacket); in isp1760_ep_enable()
837 static int isp1760_ep_disable(struct usb_ep *ep) in isp1760_ep_disable() argument
839 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_disable()
876 static struct usb_request *isp1760_ep_alloc_request(struct usb_ep *ep, in isp1760_ep_alloc_request() argument
888 static void isp1760_ep_free_request(struct usb_ep *ep, struct usb_request *_req) in isp1760_ep_free_request() argument
895 static int isp1760_ep_queue(struct usb_ep *ep, struct usb_request *_req, in isp1760_ep_queue() argument
899 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_queue()
911 "%s: req %p (%u bytes%s) ep %p(0x%02x)\n", __func__, _req, in isp1760_ep_queue()
914 req->ep = uep; in isp1760_ep_queue()
961 "%s: can't queue request to disabled ep%02x\n", in isp1760_ep_queue()
968 req->ep = NULL; in isp1760_ep_queue()
978 static int isp1760_ep_dequeue(struct usb_ep *ep, struct usb_request *_req) in isp1760_ep_dequeue() argument
981 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_dequeue()
985 dev_dbg(uep->udc->isp->dev, "%s(ep%02x)\n", __func__, uep->addr); in isp1760_ep_dequeue()
989 if (req->ep != uep) in isp1760_ep_dequeue()
1022 dev_dbg(udc->isp->dev, "%s: ep%02x is disabled\n", __func__, in __isp1760_ep_set_halt()
1031 "%s: ep%02x has request pending\n", __func__, in __isp1760_ep_set_halt()
1058 static int isp1760_ep_set_halt(struct usb_ep *ep, int value) in isp1760_ep_set_halt() argument
1060 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_set_halt()
1064 dev_dbg(uep->udc->isp->dev, "%s: %s halt on ep%02x\n", __func__, in isp1760_ep_set_halt()
1074 static int isp1760_ep_set_wedge(struct usb_ep *ep) in isp1760_ep_set_wedge() argument
1076 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_set_wedge()
1080 dev_dbg(uep->udc->isp->dev, "%s: set wedge on ep%02x)\n", __func__, in isp1760_ep_set_wedge()
1090 static void isp1760_ep_fifo_flush(struct usb_ep *ep) in isp1760_ep_fifo_flush() argument
1092 struct isp1760_ep *uep = ep_to_udc_ep(ep); in isp1760_ep_fifo_flush()
1381 struct isp1760_ep *ep = &udc->ep[i*2]; in isp1760_udc_irq() local
1385 isp1760_ep_tx_complete(ep); in isp1760_udc_irq()
1390 isp1760_ep_rx_ready(i ? ep - 1 : ep); in isp1760_udc_irq()
1450 for (i = 0; i < ARRAY_SIZE(udc->ep); ++i) { in isp1760_udc_init_eps()
1451 struct isp1760_ep *ep = &udc->ep[i]; in isp1760_udc_init_eps() local
1455 ep->udc = udc; in isp1760_udc_init_eps()
1457 INIT_LIST_HEAD(&ep->queue); in isp1760_udc_init_eps()
1459 ep->addr = (ep_num && is_in ? USB_DIR_IN : USB_DIR_OUT) in isp1760_udc_init_eps()
1461 ep->desc = NULL; in isp1760_udc_init_eps()
1463 sprintf(ep->name, "ep%u%s", ep_num, in isp1760_udc_init_eps()
1466 ep->ep.ops = &isp1760_ep_ops; in isp1760_udc_init_eps()
1467 ep->ep.name = ep->name; in isp1760_udc_init_eps()
1475 usb_ep_set_maxpacket_limit(&ep->ep, 64); in isp1760_udc_init_eps()
1476 ep->ep.caps.type_control = true; in isp1760_udc_init_eps()
1477 ep->ep.caps.dir_in = true; in isp1760_udc_init_eps()
1478 ep->ep.caps.dir_out = true; in isp1760_udc_init_eps()
1479 ep->maxpacket = 64; in isp1760_udc_init_eps()
1480 udc->gadget.ep0 = &ep->ep; in isp1760_udc_init_eps()
1482 usb_ep_set_maxpacket_limit(&ep->ep, 512); in isp1760_udc_init_eps()
1483 ep->ep.caps.type_iso = true; in isp1760_udc_init_eps()
1484 ep->ep.caps.type_bulk = true; in isp1760_udc_init_eps()
1485 ep->ep.caps.type_int = true; in isp1760_udc_init_eps()
1486 ep->maxpacket = 0; in isp1760_udc_init_eps()
1487 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in isp1760_udc_init_eps()
1491 ep->ep.caps.dir_in = true; in isp1760_udc_init_eps()
1493 ep->ep.caps.dir_out = true; in isp1760_udc_init_eps()