Lines Matching refs:dep
190 struct dwc3_ep *dep = dwc->eps[(num << 1) | 1]; in dwc3_gadget_resize_tx_fifos() local
194 if (!(dep->flags & DWC3_EP_ENABLED)) in dwc3_gadget_resize_tx_fifos()
197 if (usb_endpoint_xfer_bulk(dep->endpoint.desc) in dwc3_gadget_resize_tx_fifos()
198 || usb_endpoint_xfer_isoc(dep->endpoint.desc)) in dwc3_gadget_resize_tx_fifos()
212 tmp = mult * (dep->endpoint.maxpacket + mdwidth); in dwc3_gadget_resize_tx_fifos()
220 dep->name, last_fifo_depth, fifo_size & 0xffff); in dwc3_gadget_resize_tx_fifos()
230 void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, in dwc3_gadget_giveback() argument
233 struct dwc3 *dwc = dep->dwc; in dwc3_gadget_giveback()
236 dep->busy_slot++; in dwc3_gadget_giveback()
242 if (((dep->busy_slot & DWC3_TRB_MASK) == in dwc3_gadget_giveback()
244 usb_endpoint_xfer_isoc(dep->endpoint.desc)) in dwc3_gadget_giveback()
245 dep->busy_slot++; in dwc3_gadget_giveback()
257 if (dwc->ep0_bounced && dep->number == 0) in dwc3_gadget_giveback()
264 req, dep->name, req->request.actual, in dwc3_gadget_giveback()
268 usb_gadget_giveback_request(&dep->endpoint, &req->request); in dwc3_gadget_giveback()
330 static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep, in dwc3_trb_dma_offset() argument
333 u32 offset = (char *) trb - (char *) dep->trb_pool; in dwc3_trb_dma_offset()
335 return dep->trb_pool_dma + offset; in dwc3_trb_dma_offset()
338 static int dwc3_alloc_trb_pool(struct dwc3_ep *dep) in dwc3_alloc_trb_pool() argument
340 if (dep->trb_pool) in dwc3_alloc_trb_pool()
343 if (dep->number == 0 || dep->number == 1) in dwc3_alloc_trb_pool()
346 dep->trb_pool = dma_alloc_coherent(sizeof(struct dwc3_trb) * in dwc3_alloc_trb_pool()
348 (unsigned long *)&dep->trb_pool_dma); in dwc3_alloc_trb_pool()
349 if (!dep->trb_pool) { in dwc3_alloc_trb_pool()
350 dev_err(dep->dwc->dev, "failed to allocate trb pool for %s\n", in dwc3_alloc_trb_pool()
351 dep->name); in dwc3_alloc_trb_pool()
358 static void dwc3_free_trb_pool(struct dwc3_ep *dep) in dwc3_free_trb_pool() argument
360 dma_free_coherent(dep->trb_pool); in dwc3_free_trb_pool()
362 dep->trb_pool = NULL; in dwc3_free_trb_pool()
363 dep->trb_pool_dma = 0; in dwc3_free_trb_pool()
366 static int dwc3_gadget_start_config(struct dwc3 *dwc, struct dwc3_ep *dep) in dwc3_gadget_start_config() argument
373 if (dep->number != 1) { in dwc3_gadget_start_config()
376 if (dep->number > 1) { in dwc3_gadget_start_config()
389 static int dwc3_gadget_set_ep_config(struct dwc3 *dwc, struct dwc3_ep *dep, in dwc3_gadget_set_ep_config() argument
403 u32 burst = dep->endpoint.maxburst - 1; in dwc3_gadget_set_ep_config()
413 params.param2 |= dep->saved_state; in dwc3_gadget_set_ep_config()
422 dep->stream_capable = true; in dwc3_gadget_set_ep_config()
434 params.param1 |= DWC3_DEPCFG_EP_NUMBER(dep->number); in dwc3_gadget_set_ep_config()
440 if (dep->direction) in dwc3_gadget_set_ep_config()
441 params.param0 |= DWC3_DEPCFG_FIFO_NUMBER(dep->number >> 1); in dwc3_gadget_set_ep_config()
445 dep->interval = 1 << (desc->bInterval - 1); in dwc3_gadget_set_ep_config()
448 return dwc3_send_gadget_ep_cmd(dwc, dep->number, in dwc3_gadget_set_ep_config()
452 static int dwc3_gadget_set_xfer_resource(struct dwc3 *dwc, struct dwc3_ep *dep) in dwc3_gadget_set_xfer_resource() argument
460 return dwc3_send_gadget_ep_cmd(dwc, dep->number, in dwc3_gadget_set_xfer_resource()
471 static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, in __dwc3_gadget_ep_enable() argument
476 struct dwc3 *dwc = dep->dwc; in __dwc3_gadget_ep_enable()
480 dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); in __dwc3_gadget_ep_enable()
482 if (!(dep->flags & DWC3_EP_ENABLED)) { in __dwc3_gadget_ep_enable()
483 ret = dwc3_gadget_start_config(dwc, dep); in __dwc3_gadget_ep_enable()
488 ret = dwc3_gadget_set_ep_config(dwc, dep, desc, comp_desc, ignore, in __dwc3_gadget_ep_enable()
493 if (!(dep->flags & DWC3_EP_ENABLED)) { in __dwc3_gadget_ep_enable()
497 ret = dwc3_gadget_set_xfer_resource(dwc, dep); in __dwc3_gadget_ep_enable()
501 dep->endpoint.desc = desc; in __dwc3_gadget_ep_enable()
502 dep->comp_desc = comp_desc; in __dwc3_gadget_ep_enable()
503 dep->type = usb_endpoint_type(desc); in __dwc3_gadget_ep_enable()
504 dep->flags |= DWC3_EP_ENABLED; in __dwc3_gadget_ep_enable()
507 reg |= DWC3_DALEPENA_EP(dep->number); in __dwc3_gadget_ep_enable()
514 trb_st_hw = &dep->trb_pool[0]; in __dwc3_gadget_ep_enable()
516 trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; in __dwc3_gadget_ep_enable()
519 trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); in __dwc3_gadget_ep_enable()
520 trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); in __dwc3_gadget_ep_enable()
529 static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep) in dwc3_remove_requests() argument
533 if (!list_empty(&dep->req_queued)) { in dwc3_remove_requests()
534 dwc3_stop_active_transfer(dwc, dep->number, true); in dwc3_remove_requests()
537 while (!list_empty(&dep->req_queued)) { in dwc3_remove_requests()
538 req = next_request(&dep->req_queued); in dwc3_remove_requests()
540 dwc3_gadget_giveback(dep, req, -ESHUTDOWN); in dwc3_remove_requests()
544 while (!list_empty(&dep->request_list)) { in dwc3_remove_requests()
545 req = next_request(&dep->request_list); in dwc3_remove_requests()
547 dwc3_gadget_giveback(dep, req, -ESHUTDOWN); in dwc3_remove_requests()
559 static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) in __dwc3_gadget_ep_disable() argument
561 struct dwc3 *dwc = dep->dwc; in __dwc3_gadget_ep_disable()
564 dwc3_remove_requests(dwc, dep); in __dwc3_gadget_ep_disable()
567 if (dep->flags & DWC3_EP_STALL) in __dwc3_gadget_ep_disable()
568 __dwc3_gadget_ep_set_halt(dep, 0, false); in __dwc3_gadget_ep_disable()
571 reg &= ~DWC3_DALEPENA_EP(dep->number); in __dwc3_gadget_ep_disable()
574 dep->stream_capable = false; in __dwc3_gadget_ep_disable()
575 dep->endpoint.desc = NULL; in __dwc3_gadget_ep_disable()
576 dep->comp_desc = NULL; in __dwc3_gadget_ep_disable()
577 dep->type = 0; in __dwc3_gadget_ep_disable()
578 dep->flags = 0; in __dwc3_gadget_ep_disable()
601 struct dwc3_ep *dep; in dwc3_gadget_ep_enable() local
615 dep = to_dwc3_ep(ep); in dwc3_gadget_ep_enable()
617 if (dep->flags & DWC3_EP_ENABLED) { in dwc3_gadget_ep_enable()
619 dep->name); in dwc3_gadget_ep_enable()
625 strlcat(dep->name, "-control", sizeof(dep->name)); in dwc3_gadget_ep_enable()
628 strlcat(dep->name, "-isoc", sizeof(dep->name)); in dwc3_gadget_ep_enable()
631 strlcat(dep->name, "-bulk", sizeof(dep->name)); in dwc3_gadget_ep_enable()
634 strlcat(dep->name, "-int", sizeof(dep->name)); in dwc3_gadget_ep_enable()
637 dev_err(dep->dwc->dev, "invalid endpoint transfer type\n"); in dwc3_gadget_ep_enable()
641 ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false, false); in dwc3_gadget_ep_enable()
649 struct dwc3_ep *dep; in dwc3_gadget_ep_disable() local
658 dep = to_dwc3_ep(ep); in dwc3_gadget_ep_disable()
660 if (!(dep->flags & DWC3_EP_ENABLED)) { in dwc3_gadget_ep_disable()
662 dep->name); in dwc3_gadget_ep_disable()
666 snprintf(dep->name, sizeof(dep->name), "ep%d%s", in dwc3_gadget_ep_disable()
667 dep->number >> 1, in dwc3_gadget_ep_disable()
668 (dep->number & 1) ? "in" : "out"); in dwc3_gadget_ep_disable()
671 ret = __dwc3_gadget_ep_disable(dep); in dwc3_gadget_ep_disable()
681 struct dwc3_ep *dep = to_dwc3_ep(ep); in dwc3_gadget_ep_alloc_request() local
687 req->epnum = dep->number; in dwc3_gadget_ep_alloc_request()
688 req->dep = dep; in dwc3_gadget_ep_alloc_request()
706 static void dwc3_prepare_one_trb(struct dwc3_ep *dep, in dwc3_prepare_one_trb() argument
712 dev_vdbg(dep->dwc->dev, "%s: req %p dma %08llx length %d%s%s\n", in dwc3_prepare_one_trb()
713 dep->name, req, (unsigned long long)dma, in dwc3_prepare_one_trb()
717 trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK]; in dwc3_prepare_one_trb()
722 req->trb_dma = dwc3_trb_dma_offset(dep, trb); in dwc3_prepare_one_trb()
723 req->start_slot = dep->free_slot & DWC3_TRB_MASK; in dwc3_prepare_one_trb()
726 dep->free_slot++; in dwc3_prepare_one_trb()
728 if (((dep->free_slot & DWC3_TRB_MASK) == DWC3_TRB_NUM - 1) && in dwc3_prepare_one_trb()
729 usb_endpoint_xfer_isoc(dep->endpoint.desc)) in dwc3_prepare_one_trb()
730 dep->free_slot++; in dwc3_prepare_one_trb()
736 switch (usb_endpoint_type(dep->endpoint.desc)) { in dwc3_prepare_one_trb()
763 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in dwc3_prepare_one_trb()
773 if (usb_endpoint_xfer_bulk(dep->endpoint.desc) && dep->stream_capable) in dwc3_prepare_one_trb()
791 static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) in dwc3_prepare_trbs() argument
800 trbs_left = (dep->busy_slot - dep->free_slot) & DWC3_TRB_MASK; in dwc3_prepare_trbs()
803 if (!usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in dwc3_prepare_trbs()
804 max = DWC3_TRB_NUM - (dep->free_slot & DWC3_TRB_MASK); in dwc3_prepare_trbs()
829 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in dwc3_prepare_trbs()
830 dep->busy_slot = 1; in dwc3_prepare_trbs()
831 dep->free_slot = 1; in dwc3_prepare_trbs()
833 dep->busy_slot = 0; in dwc3_prepare_trbs()
834 dep->free_slot = 0; in dwc3_prepare_trbs()
839 if ((trbs_left <= 1) && usb_endpoint_xfer_isoc(dep->endpoint.desc)) in dwc3_prepare_trbs()
842 list_for_each_entry_safe(req, n, &dep->request_list, list) { in dwc3_prepare_trbs()
849 dwc3_prepare_one_trb(dep, req, dma, length, in dwc3_prepare_trbs()
856 static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, in __dwc3_gadget_kick_transfer() argument
861 struct dwc3 *dwc = dep->dwc; in __dwc3_gadget_kick_transfer()
865 if (start_new && (dep->flags & DWC3_EP_BUSY)) { in __dwc3_gadget_kick_transfer()
866 dev_vdbg(dwc->dev, "%s: endpoint busy\n", dep->name); in __dwc3_gadget_kick_transfer()
869 dep->flags &= ~DWC3_EP_PENDING_REQUEST; in __dwc3_gadget_kick_transfer()
876 if (list_empty(&dep->req_queued)) in __dwc3_gadget_kick_transfer()
877 dwc3_prepare_trbs(dep, start_new); in __dwc3_gadget_kick_transfer()
880 req = next_request(&dep->req_queued); in __dwc3_gadget_kick_transfer()
882 dwc3_prepare_trbs(dep, start_new); in __dwc3_gadget_kick_transfer()
887 req = next_request(&dep->req_queued); in __dwc3_gadget_kick_transfer()
890 dep->flags |= DWC3_EP_PENDING_REQUEST; in __dwc3_gadget_kick_transfer()
905 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); in __dwc3_gadget_kick_transfer()
920 dep->flags |= DWC3_EP_BUSY; in __dwc3_gadget_kick_transfer()
923 dep->resource_index = dwc3_gadget_ep_get_transfer_index(dwc, in __dwc3_gadget_kick_transfer()
924 dep->number); in __dwc3_gadget_kick_transfer()
925 WARN_ON_ONCE(!dep->resource_index); in __dwc3_gadget_kick_transfer()
932 struct dwc3_ep *dep, u32 cur_uf) in __dwc3_gadget_start_isoc() argument
936 if (list_empty(&dep->request_list)) { in __dwc3_gadget_start_isoc()
938 dep->name); in __dwc3_gadget_start_isoc()
939 dep->flags |= DWC3_EP_PENDING_REQUEST; in __dwc3_gadget_start_isoc()
944 uf = cur_uf + dep->interval * 4; in __dwc3_gadget_start_isoc()
946 __dwc3_gadget_kick_transfer(dep, uf, 1); in __dwc3_gadget_start_isoc()
950 struct dwc3_ep *dep, const struct dwc3_event_depevt *event) in dwc3_gadget_start_isoc() argument
954 mask = ~(dep->interval - 1); in dwc3_gadget_start_isoc()
957 __dwc3_gadget_start_isoc(dwc, dep, cur_uf); in dwc3_gadget_start_isoc()
960 static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) in __dwc3_gadget_ep_queue() argument
962 struct dwc3 *dwc = dep->dwc; in __dwc3_gadget_ep_queue()
967 req->direction = dep->direction; in __dwc3_gadget_ep_queue()
968 req->epnum = dep->number; in __dwc3_gadget_ep_queue()
974 if (dep->direction == 0 && in __dwc3_gadget_ep_queue()
975 req->request.length < dep->endpoint.maxpacket) in __dwc3_gadget_ep_queue()
976 req->request.length = dep->endpoint.maxpacket; in __dwc3_gadget_ep_queue()
991 dep->direction); in __dwc3_gadget_ep_queue()
995 list_add_tail(&req->list, &dep->request_list); in __dwc3_gadget_ep_queue()
1008 if (dep->flags & DWC3_EP_PENDING_REQUEST) { in __dwc3_gadget_ep_queue()
1015 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in __dwc3_gadget_ep_queue()
1016 if (list_empty(&dep->req_queued)) { in __dwc3_gadget_ep_queue()
1017 dwc3_stop_active_transfer(dwc, dep->number, true); in __dwc3_gadget_ep_queue()
1018 dep->flags = DWC3_EP_ENABLED; in __dwc3_gadget_ep_queue()
1023 ret = __dwc3_gadget_kick_transfer(dep, 0, true); in __dwc3_gadget_ep_queue()
1026 dep->name); in __dwc3_gadget_ep_queue()
1035 if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && in __dwc3_gadget_ep_queue()
1036 (dep->flags & DWC3_EP_BUSY) && in __dwc3_gadget_ep_queue()
1037 !(dep->flags & DWC3_EP_MISSED_ISOC)) { in __dwc3_gadget_ep_queue()
1038 WARN_ON_ONCE(!dep->resource_index); in __dwc3_gadget_ep_queue()
1039 ret = __dwc3_gadget_kick_transfer(dep, dep->resource_index, in __dwc3_gadget_ep_queue()
1043 dep->name); in __dwc3_gadget_ep_queue()
1052 if (dep->stream_capable) { in __dwc3_gadget_ep_queue()
1055 ret = __dwc3_gadget_kick_transfer(dep, 0, true); in __dwc3_gadget_ep_queue()
1058 dep->name); in __dwc3_gadget_ep_queue()
1069 struct dwc3_ep *dep = to_dwc3_ep(ep); in dwc3_gadget_ep_queue() local
1076 if (!dep->endpoint.desc) { in dwc3_gadget_ep_queue()
1077 dev_dbg(dep->dwc->dev, in dwc3_gadget_ep_queue()
1084 if (req->dep != dep) { in dwc3_gadget_ep_queue()
1086 req->dep->name); in dwc3_gadget_ep_queue()
1091 dev_vdbg(dep->dwc->dev, "queing request %p to %s length %d\n", in dwc3_gadget_ep_queue()
1094 ret = __dwc3_gadget_ep_queue(dep, req); in dwc3_gadget_ep_queue()
1108 struct dwc3_ep *dep = to_dwc3_ep(ep); in dwc3_gadget_ep_dequeue() local
1109 struct dwc3 *dwc = dep->dwc; in dwc3_gadget_ep_dequeue()
1116 list_for_each_entry(r, &dep->request_list, list) { in dwc3_gadget_ep_dequeue()
1122 list_for_each_entry(r, &dep->req_queued, list) { in dwc3_gadget_ep_dequeue()
1128 dwc3_stop_active_transfer(dwc, dep->number, true); in dwc3_gadget_ep_dequeue()
1139 dwc3_gadget_giveback(dep, req, -ECONNRESET); in dwc3_gadget_ep_dequeue()
1147 int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol) in __dwc3_gadget_ep_set_halt() argument
1150 struct dwc3 *dwc = dep->dwc; in __dwc3_gadget_ep_set_halt()
1153 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in __dwc3_gadget_ep_set_halt()
1154 dev_err(dwc->dev, "%s is of Isochronous type\n", dep->name); in __dwc3_gadget_ep_set_halt()
1161 if (!protocol && ((dep->direction && dep->flags & DWC3_EP_BUSY) || in __dwc3_gadget_ep_set_halt()
1162 (!list_empty(&dep->req_queued) || in __dwc3_gadget_ep_set_halt()
1163 !list_empty(&dep->request_list)))) { in __dwc3_gadget_ep_set_halt()
1165 dep->name); in __dwc3_gadget_ep_set_halt()
1169 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, in __dwc3_gadget_ep_set_halt()
1173 dep->name); in __dwc3_gadget_ep_set_halt()
1175 dep->flags |= DWC3_EP_STALL; in __dwc3_gadget_ep_set_halt()
1177 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, in __dwc3_gadget_ep_set_halt()
1181 dep->name); in __dwc3_gadget_ep_set_halt()
1183 dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE); in __dwc3_gadget_ep_set_halt()
1191 struct dwc3_ep *dep = to_dwc3_ep(ep); in dwc3_gadget_ep_set_halt() local
1198 ret = __dwc3_gadget_ep_set_halt(dep, value, false); in dwc3_gadget_ep_set_halt()
1206 struct dwc3_ep *dep = to_dwc3_ep(ep); in dwc3_gadget_ep_set_wedge() local
1211 dep->flags |= DWC3_EP_WEDGE; in dwc3_gadget_ep_set_wedge()
1213 if (dep->number == 0 || dep->number == 1) in dwc3_gadget_ep_set_wedge()
1216 ret = __dwc3_gadget_ep_set_halt(dep, 1, false); in dwc3_gadget_ep_set_wedge()
1453 struct dwc3_ep *dep; in dwc3_gadget_start() local
1512 dep = dwc->eps[0]; in dwc3_gadget_start()
1513 ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false, in dwc3_gadget_start()
1516 dev_err(dwc->dev, "failed to enable %s\n", dep->name); in dwc3_gadget_start()
1520 dep = dwc->eps[1]; in dwc3_gadget_start()
1521 ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false, in dwc3_gadget_start()
1524 dev_err(dwc->dev, "failed to enable %s\n", dep->name); in dwc3_gadget_start()
1582 struct dwc3_ep *dep; in dwc3_gadget_init_hw_endpoints() local
1588 dep = kzalloc(sizeof(*dep), GFP_KERNEL); in dwc3_gadget_init_hw_endpoints()
1589 if (!dep) in dwc3_gadget_init_hw_endpoints()
1592 dep->dwc = dwc; in dwc3_gadget_init_hw_endpoints()
1593 dep->number = epnum; in dwc3_gadget_init_hw_endpoints()
1594 dep->direction = !!direction; in dwc3_gadget_init_hw_endpoints()
1595 dwc->eps[epnum] = dep; in dwc3_gadget_init_hw_endpoints()
1597 snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1, in dwc3_gadget_init_hw_endpoints()
1600 dep->endpoint.name = dep->name; in dwc3_gadget_init_hw_endpoints()
1602 dev_vdbg(dwc->dev, "initializing %s\n", dep->name); in dwc3_gadget_init_hw_endpoints()
1605 usb_ep_set_maxpacket_limit(&dep->endpoint, 512); in dwc3_gadget_init_hw_endpoints()
1606 dep->endpoint.maxburst = 1; in dwc3_gadget_init_hw_endpoints()
1607 dep->endpoint.ops = &dwc3_gadget_ep0_ops; in dwc3_gadget_init_hw_endpoints()
1609 dwc->gadget.ep0 = &dep->endpoint; in dwc3_gadget_init_hw_endpoints()
1613 usb_ep_set_maxpacket_limit(&dep->endpoint, 512); in dwc3_gadget_init_hw_endpoints()
1614 dep->endpoint.max_streams = 15; in dwc3_gadget_init_hw_endpoints()
1615 dep->endpoint.ops = &dwc3_gadget_ep_ops; in dwc3_gadget_init_hw_endpoints()
1616 list_add_tail(&dep->endpoint.ep_list, in dwc3_gadget_init_hw_endpoints()
1619 ret = dwc3_alloc_trb_pool(dep); in dwc3_gadget_init_hw_endpoints()
1624 INIT_LIST_HEAD(&dep->request_list); in dwc3_gadget_init_hw_endpoints()
1625 INIT_LIST_HEAD(&dep->req_queued); in dwc3_gadget_init_hw_endpoints()
1654 struct dwc3_ep *dep; in dwc3_gadget_free_endpoints() local
1658 dep = dwc->eps[epnum]; in dwc3_gadget_free_endpoints()
1659 if (!dep) in dwc3_gadget_free_endpoints()
1671 dwc3_free_trb_pool(dep); in dwc3_gadget_free_endpoints()
1672 list_del(&dep->endpoint.ep_list); in dwc3_gadget_free_endpoints()
1675 kfree(dep); in dwc3_gadget_free_endpoints()
1681 static int __dwc3_cleanup_done_trbs(struct dwc3 *dwc, struct dwc3_ep *dep, in __dwc3_cleanup_done_trbs() argument
1699 dep->name, trb); in __dwc3_cleanup_done_trbs()
1702 if (dep->direction) { in __dwc3_cleanup_done_trbs()
1707 dep->name); in __dwc3_cleanup_done_trbs()
1723 dep->flags |= DWC3_EP_MISSED_ISOC; in __dwc3_cleanup_done_trbs()
1726 dep->name); in __dwc3_cleanup_done_trbs()
1730 dep->flags &= ~DWC3_EP_MISSED_ISOC; in __dwc3_cleanup_done_trbs()
1757 static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, in dwc3_cleanup_done_reqs() argument
1764 req = next_request(&dep->req_queued); in dwc3_cleanup_done_reqs()
1772 usb_endpoint_xfer_isoc(dep->endpoint.desc)) in dwc3_cleanup_done_reqs()
1775 trb = &dep->trb_pool[slot]; in dwc3_cleanup_done_reqs()
1778 __dwc3_cleanup_done_trbs(dwc, dep, req, trb, event, status); in dwc3_cleanup_done_reqs()
1779 dwc3_gadget_giveback(dep, req, status); in dwc3_cleanup_done_reqs()
1781 if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && in dwc3_cleanup_done_reqs()
1782 list_empty(&dep->req_queued)) { in dwc3_cleanup_done_reqs()
1783 if (list_empty(&dep->request_list)) { in dwc3_cleanup_done_reqs()
1790 dep->flags = DWC3_EP_PENDING_REQUEST; in dwc3_cleanup_done_reqs()
1792 dwc3_stop_active_transfer(dwc, dep->number, true); in dwc3_cleanup_done_reqs()
1793 dep->flags = DWC3_EP_ENABLED; in dwc3_cleanup_done_reqs()
1802 struct dwc3_ep *dep, const struct dwc3_event_depevt *event) in dwc3_endpoint_transfer_complete() argument
1810 clean_busy = dwc3_cleanup_done_reqs(dwc, dep, event, status); in dwc3_endpoint_transfer_complete()
1812 dep->flags &= ~DWC3_EP_BUSY; in dwc3_endpoint_transfer_complete()
1823 dep = dwc->eps[i]; in dwc3_endpoint_transfer_complete()
1825 if (!(dep->flags & DWC3_EP_ENABLED)) in dwc3_endpoint_transfer_complete()
1828 if (!list_empty(&dep->req_queued)) in dwc3_endpoint_transfer_complete()
1843 struct dwc3_ep *dep; in dwc3_endpoint_interrupt() local
1846 dep = dwc->eps[epnum]; in dwc3_endpoint_interrupt()
1848 if (!(dep->flags & DWC3_EP_ENABLED)) in dwc3_endpoint_interrupt()
1858 dep->resource_index = 0; in dwc3_endpoint_interrupt()
1860 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in dwc3_endpoint_interrupt()
1862 dep->name); in dwc3_endpoint_interrupt()
1866 dwc3_endpoint_transfer_complete(dwc, dep, event); in dwc3_endpoint_interrupt()
1869 dwc3_endpoint_transfer_complete(dwc, dep, event); in dwc3_endpoint_interrupt()
1872 if (usb_endpoint_xfer_isoc(dep->endpoint.desc)) { in dwc3_endpoint_interrupt()
1873 dwc3_gadget_start_isoc(dwc, dep, event); in dwc3_endpoint_interrupt()
1878 dep->name, event->status & in dwc3_endpoint_interrupt()
1883 ret = __dwc3_gadget_kick_transfer(dep, 0, 1); in dwc3_endpoint_interrupt()
1888 dep->name); in dwc3_endpoint_interrupt()
1893 if (!usb_endpoint_xfer_bulk(dep->endpoint.desc)) { in dwc3_endpoint_interrupt()
1895 dep->name); in dwc3_endpoint_interrupt()
1912 dev_dbg(dwc->dev, "%s FIFO Overrun\n", dep->name); in dwc3_endpoint_interrupt()
1960 struct dwc3_ep *dep; in dwc3_stop_active_transfer() local
1965 dep = dwc->eps[epnum]; in dwc3_stop_active_transfer()
1967 if (!dep->resource_index) in dwc3_stop_active_transfer()
1992 cmd |= DWC3_DEPCMD_PARAM(dep->resource_index); in dwc3_stop_active_transfer()
1994 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, ¶ms); in dwc3_stop_active_transfer()
1996 dep->resource_index = 0; in dwc3_stop_active_transfer()
1997 dep->flags &= ~DWC3_EP_BUSY; in dwc3_stop_active_transfer()
2006 struct dwc3_ep *dep; in dwc3_stop_active_transfers() local
2008 dep = dwc->eps[epnum]; in dwc3_stop_active_transfers()
2009 if (!dep) in dwc3_stop_active_transfers()
2012 if (!(dep->flags & DWC3_EP_ENABLED)) in dwc3_stop_active_transfers()
2015 dwc3_remove_requests(dwc, dep); in dwc3_stop_active_transfers()
2024 struct dwc3_ep *dep; in dwc3_clear_stall_all_ep() local
2028 dep = dwc->eps[epnum]; in dwc3_clear_stall_all_ep()
2029 if (!dep) in dwc3_clear_stall_all_ep()
2032 if (!(dep->flags & DWC3_EP_STALL)) in dwc3_clear_stall_all_ep()
2035 dep->flags &= ~DWC3_EP_STALL; in dwc3_clear_stall_all_ep()
2038 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, in dwc3_clear_stall_all_ep()
2142 struct dwc3_ep *dep; in dwc3_gadget_conndone_interrupt() local
2225 dep = dwc->eps[0]; in dwc3_gadget_conndone_interrupt()
2226 ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true, in dwc3_gadget_conndone_interrupt()
2229 dev_err(dwc->dev, "failed to enable %s\n", dep->name); in dwc3_gadget_conndone_interrupt()
2233 dep = dwc->eps[1]; in dwc3_gadget_conndone_interrupt()
2234 ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true, in dwc3_gadget_conndone_interrupt()
2237 dev_err(dwc->dev, "failed to enable %s\n", dep->name); in dwc3_gadget_conndone_interrupt()