Lines Matching refs:ep
31 static void fotg210_disable_fifo_int(struct fotg210_ep *ep) in fotg210_disable_fifo_int() argument
33 u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_disable_fifo_int()
35 if (ep->dir_in) in fotg210_disable_fifo_int()
36 value |= DMISGR1_MF_IN_INT(ep->epnum - 1); in fotg210_disable_fifo_int()
38 value |= DMISGR1_MF_OUTSPK_INT(ep->epnum - 1); in fotg210_disable_fifo_int()
39 iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_disable_fifo_int()
42 static void fotg210_enable_fifo_int(struct fotg210_ep *ep) in fotg210_enable_fifo_int() argument
44 u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_enable_fifo_int()
46 if (ep->dir_in) in fotg210_enable_fifo_int()
47 value &= ~DMISGR1_MF_IN_INT(ep->epnum - 1); in fotg210_enable_fifo_int()
49 value &= ~DMISGR1_MF_OUTSPK_INT(ep->epnum - 1); in fotg210_enable_fifo_int()
50 iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_enable_fifo_int()
61 static void fotg210_done(struct fotg210_ep *ep, struct fotg210_request *req, in fotg210_done() argument
67 if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN) in fotg210_done()
72 spin_unlock(&ep->fotg210->lock); in fotg210_done()
73 usb_gadget_giveback_request(&ep->ep, &req->req); in fotg210_done()
74 spin_lock(&ep->fotg210->lock); in fotg210_done()
76 if (ep->epnum) { in fotg210_done()
77 if (list_empty(&ep->queue)) in fotg210_done()
78 fotg210_disable_fifo_int(ep); in fotg210_done()
80 fotg210_set_cxdone(ep->fotg210); in fotg210_done()
84 static void fotg210_fifo_ep_mapping(struct fotg210_ep *ep, u32 epnum, in fotg210_fifo_ep_mapping() argument
87 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_fifo_ep_mapping()
112 static void fotg210_set_fifo_dir(struct fotg210_ep *ep, u32 epnum, u32 dir_in) in fotg210_set_fifo_dir() argument
114 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_fifo_dir()
122 static void fotg210_set_tfrtype(struct fotg210_ep *ep, u32 epnum, u32 type) in fotg210_set_tfrtype() argument
124 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_tfrtype()
132 static void fotg210_set_mps(struct fotg210_ep *ep, u32 epnum, u32 mps, in fotg210_set_mps() argument
135 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_mps()
145 static int fotg210_config_ep(struct fotg210_ep *ep, in fotg210_config_ep() argument
148 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_config_ep()
150 fotg210_set_fifo_dir(ep, ep->epnum, ep->dir_in); in fotg210_config_ep()
151 fotg210_set_tfrtype(ep, ep->epnum, ep->type); in fotg210_config_ep()
152 fotg210_set_mps(ep, ep->epnum, ep->ep.maxpacket, ep->dir_in); in fotg210_config_ep()
153 fotg210_fifo_ep_mapping(ep, ep->epnum, ep->dir_in); in fotg210_config_ep()
155 fotg210->ep[ep->epnum] = ep; in fotg210_config_ep()
163 struct fotg210_ep *ep; in fotg210_ep_enable() local
165 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_enable()
167 ep->desc = desc; in fotg210_ep_enable()
168 ep->epnum = usb_endpoint_num(desc); in fotg210_ep_enable()
169 ep->type = usb_endpoint_type(desc); in fotg210_ep_enable()
170 ep->dir_in = usb_endpoint_dir_in(desc); in fotg210_ep_enable()
171 ep->ep.maxpacket = usb_endpoint_maxp(desc); in fotg210_ep_enable()
173 return fotg210_config_ep(ep, desc); in fotg210_ep_enable()
178 struct fotg210_ep *ep = fotg210->ep[epnum]; in fotg210_reset_tseq() local
182 reg = (ep->dir_in) ? in fotg210_reset_tseq()
199 static int fotg210_ep_release(struct fotg210_ep *ep) in fotg210_ep_release() argument
201 if (!ep->epnum) in fotg210_ep_release()
203 ep->epnum = 0; in fotg210_ep_release()
204 ep->stall = 0; in fotg210_ep_release()
205 ep->wedged = 0; in fotg210_ep_release()
207 fotg210_reset_tseq(ep->fotg210, ep->epnum); in fotg210_ep_release()
214 struct fotg210_ep *ep; in fotg210_ep_disable() local
220 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_disable()
222 while (!list_empty(&ep->queue)) { in fotg210_ep_disable()
223 req = list_entry(ep->queue.next, in fotg210_ep_disable()
225 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_ep_disable()
226 fotg210_done(ep, req, -ECONNRESET); in fotg210_ep_disable()
227 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_ep_disable()
230 return fotg210_ep_release(ep); in fotg210_ep_disable()
256 static void fotg210_enable_dma(struct fotg210_ep *ep, in fotg210_enable_dma() argument
260 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_enable_dma()
265 value |= DMACPSR1_DMA_LEN(len) | DMACPSR1_DMA_TYPE(ep->dir_in); in fotg210_enable_dma()
270 if (ep->epnum) in fotg210_enable_dma()
271 value |= DMATFNR_ACC_FN(ep->epnum - 1); in fotg210_enable_dma()
290 static void fotg210_disable_dma(struct fotg210_ep *ep) in fotg210_disable_dma() argument
292 iowrite32(DMATFNR_DISDMA, ep->fotg210->reg + FOTG210_DMATFNR); in fotg210_disable_dma()
295 static void fotg210_wait_dma_done(struct fotg210_ep *ep) in fotg210_wait_dma_done() argument
300 value = ioread32(ep->fotg210->reg + FOTG210_DISGR2); in fotg210_wait_dma_done()
307 iowrite32(value, ep->fotg210->reg + FOTG210_DISGR2); in fotg210_wait_dma_done()
311 value = ioread32(ep->fotg210->reg + FOTG210_DMACPSR1); in fotg210_wait_dma_done()
313 iowrite32(value, ep->fotg210->reg + FOTG210_DMACPSR1); in fotg210_wait_dma_done()
316 if (ep->epnum) { in fotg210_wait_dma_done()
317 value = ioread32(ep->fotg210->reg + in fotg210_wait_dma_done()
318 FOTG210_FIBCR(ep->epnum - 1)); in fotg210_wait_dma_done()
320 iowrite32(value, ep->fotg210->reg + in fotg210_wait_dma_done()
321 FOTG210_FIBCR(ep->epnum - 1)); in fotg210_wait_dma_done()
323 value = ioread32(ep->fotg210->reg + FOTG210_DCFESR); in fotg210_wait_dma_done()
325 iowrite32(value, ep->fotg210->reg + FOTG210_DCFESR); in fotg210_wait_dma_done()
329 static void fotg210_start_dma(struct fotg210_ep *ep, in fotg210_start_dma() argument
336 if (ep->epnum) { in fotg210_start_dma()
337 if (ep->dir_in) { in fotg210_start_dma()
342 length = ioread32(ep->fotg210->reg + in fotg210_start_dma()
343 FOTG210_FIBCR(ep->epnum - 1)); in fotg210_start_dma()
348 if (req->req.length - req->req.actual > ep->ep.maxpacket) in fotg210_start_dma()
349 length = ep->ep.maxpacket; in fotg210_start_dma()
355 ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); in fotg210_start_dma()
363 ep->dir_in ? DMA_TO_DEVICE : in fotg210_start_dma()
366 fotg210_enable_dma(ep, d, length); in fotg210_start_dma()
369 fotg210_wait_dma_done(ep); in fotg210_start_dma()
371 fotg210_disable_dma(ep); in fotg210_start_dma()
379 static void fotg210_ep0_queue(struct fotg210_ep *ep, in fotg210_ep0_queue() argument
383 fotg210_done(ep, req, 0); in fotg210_ep0_queue()
386 if (ep->dir_in) { /* if IN */ in fotg210_ep0_queue()
388 fotg210_start_dma(ep, req); in fotg210_ep0_queue()
394 (req->req.actual < ep->ep.maxpacket)) in fotg210_ep0_queue()
395 fotg210_done(ep, req, 0); in fotg210_ep0_queue()
398 fotg210_done(ep, req, 0); in fotg210_ep0_queue()
400 u32 value = ioread32(ep->fotg210->reg + in fotg210_ep0_queue()
404 iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR0); in fotg210_ep0_queue()
412 struct fotg210_ep *ep; in fotg210_ep_queue() local
417 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_queue()
420 if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN) in fotg210_ep_queue()
423 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_ep_queue()
425 if (list_empty(&ep->queue)) in fotg210_ep_queue()
428 list_add_tail(&req->queue, &ep->queue); in fotg210_ep_queue()
433 if (!ep->epnum) /* ep0 */ in fotg210_ep_queue()
434 fotg210_ep0_queue(ep, req); in fotg210_ep_queue()
435 else if (request && !ep->stall) in fotg210_ep_queue()
436 fotg210_enable_fifo_int(ep); in fotg210_ep_queue()
438 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_ep_queue()
445 struct fotg210_ep *ep; in fotg210_ep_dequeue() local
449 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_dequeue()
452 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_ep_dequeue()
453 if (!list_empty(&ep->queue)) in fotg210_ep_dequeue()
454 fotg210_done(ep, req, -ECONNRESET); in fotg210_ep_dequeue()
455 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_ep_dequeue()
460 static void fotg210_set_epnstall(struct fotg210_ep *ep) in fotg210_set_epnstall() argument
462 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_epnstall()
467 if (ep->dir_in) { in fotg210_set_epnstall()
470 } while (!(value & DCFESR_FIFO_EMPTY(ep->epnum - 1))); in fotg210_set_epnstall()
473 reg = (ep->dir_in) ? in fotg210_set_epnstall()
474 fotg210->reg + FOTG210_INEPMPSR(ep->epnum) : in fotg210_set_epnstall()
475 fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum); in fotg210_set_epnstall()
481 static void fotg210_clear_epnstall(struct fotg210_ep *ep) in fotg210_clear_epnstall() argument
483 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_clear_epnstall()
487 reg = (ep->dir_in) ? in fotg210_clear_epnstall()
488 fotg210->reg + FOTG210_INEPMPSR(ep->epnum) : in fotg210_clear_epnstall()
489 fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum); in fotg210_clear_epnstall()
497 struct fotg210_ep *ep; in fotg210_set_halt_and_wedge() local
502 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_set_halt_and_wedge()
504 fotg210 = ep->fotg210; in fotg210_set_halt_and_wedge()
506 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_set_halt_and_wedge()
509 fotg210_set_epnstall(ep); in fotg210_set_halt_and_wedge()
510 ep->stall = 1; in fotg210_set_halt_and_wedge()
512 ep->wedged = 1; in fotg210_set_halt_and_wedge()
514 fotg210_reset_tseq(fotg210, ep->epnum); in fotg210_set_halt_and_wedge()
515 fotg210_clear_epnstall(ep); in fotg210_set_halt_and_wedge()
516 ep->stall = 0; in fotg210_set_halt_and_wedge()
517 ep->wedged = 0; in fotg210_set_halt_and_wedge()
518 if (!list_empty(&ep->queue)) in fotg210_set_halt_and_wedge()
519 fotg210_enable_fifo_int(ep); in fotg210_set_halt_and_wedge()
522 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_set_halt_and_wedge()
671 fotg210_set_epnstall(fotg210->ep[epnum]); in fotg210_set_feature()
686 struct fotg210_ep *ep = in fotg210_clear_feature() local
687 fotg210->ep[ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK]; in fotg210_clear_feature()
698 if (ep->wedged) { in fotg210_clear_feature()
702 if (ep->stall) in fotg210_clear_feature()
703 fotg210_set_halt_and_wedge(&ep->ep, 0, 0); in fotg210_clear_feature()
713 static int fotg210_is_epnstall(struct fotg210_ep *ep) in fotg210_is_epnstall() argument
715 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_is_epnstall()
719 reg = (ep->dir_in) ? in fotg210_is_epnstall()
720 fotg210->reg + FOTG210_INEPMPSR(ep->epnum) : in fotg210_is_epnstall()
721 fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum); in fotg210_is_epnstall()
742 fotg210_is_epnstall(fotg210->ep[epnum]) in fotg210_get_status()
769 fotg210->ep[0]->dir_in = ctrl->bRequestType & USB_DIR_IN; in fotg210_setup_packet()
809 struct fotg210_ep *ep = fotg210->ep[0]; in fotg210_ep0out() local
811 if (!list_empty(&ep->queue) && !ep->dir_in) { in fotg210_ep0out()
814 req = list_first_entry(&ep->queue, in fotg210_ep0out()
818 fotg210_start_dma(ep, req); in fotg210_ep0out()
820 if ((req->req.length - req->req.actual) < ep->ep.maxpacket) in fotg210_ep0out()
821 fotg210_done(ep, req, 0); in fotg210_ep0out()
829 struct fotg210_ep *ep = fotg210->ep[0]; in fotg210_ep0in() local
831 if ((!list_empty(&ep->queue)) && (ep->dir_in)) { in fotg210_ep0in()
834 req = list_entry(ep->queue.next, in fotg210_ep0in()
838 fotg210_start_dma(ep, req); in fotg210_ep0in()
840 if ((req->req.length - req->req.actual) < ep->ep.maxpacket) in fotg210_ep0in()
841 fotg210_done(ep, req, 0); in fotg210_ep0in()
855 static void fotg210_in_fifo_handler(struct fotg210_ep *ep) in fotg210_in_fifo_handler() argument
857 struct fotg210_request *req = list_entry(ep->queue.next, in fotg210_in_fifo_handler()
861 fotg210_start_dma(ep, req); in fotg210_in_fifo_handler()
862 fotg210_done(ep, req, 0); in fotg210_in_fifo_handler()
865 static void fotg210_out_fifo_handler(struct fotg210_ep *ep) in fotg210_out_fifo_handler() argument
867 struct fotg210_request *req = list_entry(ep->queue.next, in fotg210_out_fifo_handler()
870 fotg210_start_dma(ep, req); in fotg210_out_fifo_handler()
874 req->req.actual < ep->ep.maxpacket) in fotg210_out_fifo_handler()
875 fotg210_done(ep, req, 0); in fotg210_out_fifo_handler()
995 fotg210_in_fifo_handler(fotg210->ep[fifo + 1]); in fotg210_irq()
999 fotg210_out_fifo_handler(fotg210->ep[fifo + 1]); in fotg210_irq()
1084 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); in fotg210_udc_remove()
1121 fotg210->ep[i] = _ep[i]; in fotg210_udc_probe()
1144 struct fotg210_ep *ep = fotg210->ep[i]; in fotg210_udc_probe() local
1147 INIT_LIST_HEAD(&fotg210->ep[i]->ep.ep_list); in fotg210_udc_probe()
1148 list_add_tail(&fotg210->ep[i]->ep.ep_list, in fotg210_udc_probe()
1151 ep->fotg210 = fotg210; in fotg210_udc_probe()
1152 INIT_LIST_HEAD(&ep->queue); in fotg210_udc_probe()
1153 ep->ep.name = fotg210_ep_name[i]; in fotg210_udc_probe()
1154 ep->ep.ops = &fotg210_ep_ops; in fotg210_udc_probe()
1155 usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); in fotg210_udc_probe()
1157 usb_ep_set_maxpacket_limit(&fotg210->ep[0]->ep, 0x40); in fotg210_udc_probe()
1158 fotg210->gadget.ep0 = &fotg210->ep[0]->ep; in fotg210_udc_probe()
1161 fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep, in fotg210_udc_probe()
1190 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); in fotg210_udc_probe()