Lines Matching refs:ep

40 static void mv_u3d_nuke(struct mv_u3d_ep *ep, int status);
55 struct mv_u3d_ep *ep;
60 ep = &u3d->eps[i];
61 ep->u3d = u3d;
63 /* ep0 ep context, ep0 in and out share the same ep context */
64 ep->ep_context = &u3d->ep_context[1];
67 /* reset ep state machine */
166 "complete_tr error: ep=%d %s: error = 0x%x\n",
187 void mv_u3d_done(struct mv_u3d_ep *ep, struct mv_u3d_req *req, int status)
188 __releases(&ep->udc->lock)
189 __acquires(&ep->udc->lock)
191 struct mv_u3d *u3d = (struct mv_u3d *)ep->u3d;
194 /* Removed the req from ep queue */
208 dma_unmap_single(ep->u3d->gadget.dev.parent,
216 usb_gadget_unmap_request(&u3d->gadget, &req->req, mv_u3d_ep_dir(ep));
220 ep->ep.name, &req->req, status,
224 spin_unlock(&ep->u3d->lock);
226 usb_gadget_giveback_request(&ep->ep, &req->req);
228 spin_lock(&ep->u3d->lock);
231 static int mv_u3d_queue_trb(struct mv_u3d_ep *ep, struct mv_u3d_req *req)
238 u3d = ep->u3d;
239 direction = mv_u3d_ep_dir(ep);
241 /* ep0 in and out share the same ep context slot 1*/
242 if (ep->ep_num == 0)
245 ep_context = &(u3d->ep_context[ep->ep_num * 2 + direction]);
248 if (!list_empty(&ep->queue)) {
268 /* ring bell the ep */
269 if (ep->ep_num == 0)
272 tmp = ep->ep_num * 2
293 u3d = req->ep->u3d;
322 if (req->ep->ep_num == 0)
329 direction = mv_u3d_ep_dir(req->ep);
356 u3d = req->ep->u3d;
368 if (req->ep->ep_num == 0)
375 direction = mv_u3d_ep_dir(req->ep);
383 if (*length == 0 || (*length % req->ep->ep.maxpacket) != 0)
423 u3d = req->ep->u3d;
482 mv_u3d_start_queue(struct mv_u3d_ep *ep)
484 struct mv_u3d *u3d = ep->u3d;
488 if (!list_empty(&ep->req_list) && !ep->processing)
489 req = list_entry(ep->req_list.next, struct mv_u3d_req, list);
493 ep->processing = 1;
497 mv_u3d_ep_dir(ep));
507 ret = mv_u3d_queue_trb(ep, req);
509 ep->processing = 0;
513 ep->processing = 0;
520 list_add_tail(&req->queue, &ep->queue);
529 struct mv_u3d_ep *ep;
538 ep = container_of(_ep, struct mv_u3d_ep, ep);
539 u3d = ep->u3d;
544 direction = mv_u3d_ep_dir(ep);
552 ep_context = (struct mv_u3d_ep_context *)ep->ep_context;
560 "than 16 on bulk ep\n");
565 "maxburst: %d on bulk %s\n", maxburst, ep->name);
575 "max burst should be 1 on int ep "
584 "max burst should be 1 on isoc ep "
594 ep->ep.maxpacket = max;
595 ep->ep.desc = desc;
596 ep->enabled = 1;
600 epxcr = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
602 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
605 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
611 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxoutcr1);
613 epxcr = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
615 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
618 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
624 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxincr1);
635 struct mv_u3d_ep *ep;
643 ep = container_of(_ep, struct mv_u3d_ep, ep);
644 if (!ep->ep.desc)
647 u3d = ep->u3d;
650 ep_context = ep->ep_context;
652 direction = mv_u3d_ep_dir(ep);
656 mv_u3d_nuke(ep, -ESHUTDOWN);
661 epxcr = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxoutcr1);
664 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxoutcr1);
666 epxcr = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxincr1);
669 iowrite32(epxcr, &u3d->vuc_regs->epcr[ep->ep_num].epxincr1);
672 ep->enabled = 0;
674 ep->ep.desc = NULL;
703 struct mv_u3d_ep *ep = container_of(_ep, struct mv_u3d_ep, ep);
708 if (!ep->enabled)
711 u3d = ep->u3d;
712 direction = mv_u3d_ep_dir(ep);
715 if (!ep->ep_num) {
735 tmp = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
737 iowrite32(tmp, &u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
741 while (ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0) &
749 "EP FLUSH TIMEOUT for ep%d%s\n", ep->ep_num,
757 tmp = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
759 iowrite32(tmp, &u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
763 while (ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxincr0) &
771 "EP FLUSH TIMEOUT for ep%d%s\n", ep->ep_num,
785 struct mv_u3d_ep *ep;
794 ep = container_of(_ep, struct mv_u3d_ep, ep);
795 u3d = ep->u3d;
799 if (!ep->ep_num
822 if (unlikely(!ep->ep.desc)) {
823 dev_err(u3d->dev, "%s, bad ep\n", __func__);
826 if (ep->ep.desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
827 if (req->req.length > ep->ep.maxpacket)
837 req->ep = ep;
840 spin_lock_irqsave(&ep->req_lock, flags);
841 is_first_req = list_empty(&ep->req_list);
842 list_add_tail(&req->list, &ep->req_list);
843 spin_unlock_irqrestore(&ep->req_lock, flags);
851 mv_u3d_start_queue(ep);
859 struct mv_u3d_ep *ep;
871 ep = container_of(_ep, struct mv_u3d_ep, ep);
872 u3d = ep->u3d;
874 spin_lock_irqsave(&ep->u3d->lock, flags);
877 list_for_each_entry(req, &ep->queue, queue) {
887 if (ep->queue.next == &req->queue) {
891 /* The request isn't the last request in this ep queue */
892 if (req->queue.next != &ep->queue) {
894 "it is the last request in this ep queue\n");
895 ep_context = ep->ep_context;
904 ep_context = ep->ep_context;
912 mv_u3d_done(ep, req, -ECONNRESET);
914 /* remove the req from the ep req list */
915 if (!list_empty(&ep->req_list)) {
917 curr_req = list_entry(ep->req_list.next,
921 ep->processing = 0;
926 spin_unlock_irqrestore(&ep->u3d->lock, flags);
934 struct mv_u3d_ep *ep = u3d->eps;
938 tmp = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
943 iowrite32(tmp, &u3d->vuc_regs->epcr[ep->ep_num].epxoutcr0);
945 tmp = ioread32(&u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
950 iowrite32(tmp, &u3d->vuc_regs->epcr[ep->ep_num].epxincr0);
956 struct mv_u3d_ep *ep;
961 ep = container_of(_ep, struct mv_u3d_ep, ep);
962 u3d = ep->u3d;
963 if (!ep->ep.desc) {
968 if (ep->ep.desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
974 * Attempt to halt IN ep will fail if any transfer requests
977 if (halt && (mv_u3d_ep_dir(ep) == MV_U3D_EP_DIR_IN)
978 && !list_empty(&ep->queue)) {
983 spin_lock_irqsave(&ep->u3d->lock, flags);
984 mv_u3d_ep_set_stall(u3d, ep->ep_num, mv_u3d_ep_dir(ep), halt);
986 ep->wedge = 1;
988 ep->wedge = 0;
989 spin_unlock_irqrestore(&ep->u3d->lock, flags);
991 if (ep->ep_num == 0)
1062 /* Enable ctrl ep */
1316 struct mv_u3d_ep *ep;
1321 ep = &u3d->eps[1];
1322 ep->u3d = u3d;
1323 strncpy(ep->name, "ep0", sizeof(ep->name));
1324 ep->ep.name = ep->name;
1325 ep->ep.ops = &mv_u3d_ep_ops;
1326 ep->wedge = 0;
1327 usb_ep_set_maxpacket_limit(&ep->ep, MV_U3D_EP0_MAX_PKT_SIZE);
1328 ep->ep_num = 0;
1329 ep->ep.desc = &mv_u3d_ep0_desc;
1330 INIT_LIST_HEAD(&ep->queue);
1331 INIT_LIST_HEAD(&ep->req_list);
1332 ep->ep_type = USB_ENDPOINT_XFER_CONTROL;
1335 ep->ep_context = &u3d->ep_context[1];
1339 ep = &u3d->eps[i];
1341 snprintf(name, sizeof(name), "ep%din", i >> 1);
1342 ep->direction = MV_U3D_EP_DIR_IN;
1344 snprintf(name, sizeof(name), "ep%dout", i >> 1);
1345 ep->direction = MV_U3D_EP_DIR_OUT;
1347 ep->u3d = u3d;
1348 strncpy(ep->name, name, sizeof(ep->name));
1349 ep->ep.name = ep->name;
1351 ep->ep.ops = &mv_u3d_ep_ops;
1352 usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0);
1353 ep->ep_num = i / 2;
1355 INIT_LIST_HEAD(&ep->queue);
1356 list_add_tail(&ep->ep.ep_list, &u3d->gadget.ep_list);
1358 INIT_LIST_HEAD(&ep->req_list);
1359 spin_lock_init(&ep->req_lock);
1360 ep->ep_context = &u3d->ep_context[i];
1367 static void mv_u3d_nuke(struct mv_u3d_ep *ep, int status)
1370 mv_u3d_ep_fifo_flush(&ep->ep);
1372 while (!list_empty(&ep->queue)) {
1374 req = list_entry(ep->queue.next, struct mv_u3d_req, queue);
1375 mv_u3d_done(ep, req, status);
1383 struct mv_u3d_ep *ep;
1387 list_for_each_entry(ep, &u3d->gadget.ep_list, ep.ep_list) {
1388 mv_u3d_nuke(ep, -ESHUTDOWN);
1625 dev_dbg(u3d->dev, "tr_complete: ep: 0x%x\n", tmp);
1644 /* remove req out of ep request list after completion */
1674 dev_dbg(u3d->dev, "call mv_u3d_start_queue from ep complete\n");
1723 dev_err(u3d->dev, "under run, ep%d\n", trbunderrun);
1875 dev_err(&dev->dev, "allocate ep context memory failed\n");
1936 u3d->gadget.ep0 = &u3d->eps[1].ep; /* gadget ep0 */