Lines Matching full:ep

40 static void fotg210_disable_fifo_int(struct fotg210_ep *ep)  in fotg210_disable_fifo_int()  argument
42 u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_disable_fifo_int()
44 if (ep->dir_in) in fotg210_disable_fifo_int()
45 value |= DMISGR1_MF_IN_INT(ep->epnum - 1); in fotg210_disable_fifo_int()
47 value |= DMISGR1_MF_OUTSPK_INT(ep->epnum - 1); in fotg210_disable_fifo_int()
48 iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_disable_fifo_int()
51 static void fotg210_enable_fifo_int(struct fotg210_ep *ep) in fotg210_enable_fifo_int() argument
53 u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_enable_fifo_int()
55 if (ep->dir_in) in fotg210_enable_fifo_int()
56 value &= ~DMISGR1_MF_IN_INT(ep->epnum - 1); in fotg210_enable_fifo_int()
58 value &= ~DMISGR1_MF_OUTSPK_INT(ep->epnum - 1); in fotg210_enable_fifo_int()
59 iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR1); in fotg210_enable_fifo_int()
70 static void fotg210_done(struct fotg210_ep *ep, struct fotg210_request *req, in fotg210_done() argument
76 if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN) in fotg210_done()
81 spin_unlock(&ep->fotg210->lock); in fotg210_done()
82 usb_gadget_giveback_request(&ep->ep, &req->req); in fotg210_done()
83 spin_lock(&ep->fotg210->lock); in fotg210_done()
85 if (ep->epnum) { in fotg210_done()
86 if (list_empty(&ep->queue)) in fotg210_done()
87 fotg210_disable_fifo_int(ep); in fotg210_done()
89 fotg210_set_cxdone(ep->fotg210); in fotg210_done()
93 static void fotg210_fifo_ep_mapping(struct fotg210_ep *ep, u32 epnum, in fotg210_fifo_ep_mapping() argument
96 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_fifo_ep_mapping()
99 /* Driver should map an ep to a fifo and then map the fifo in fotg210_fifo_ep_mapping()
100 * to the ep. What a brain-damaged design! in fotg210_fifo_ep_mapping()
103 /* map a fifo to an ep */ in fotg210_fifo_ep_mapping()
109 /* map the ep to the fifo */ in fotg210_fifo_ep_mapping()
121 static void fotg210_set_fifo_dir(struct fotg210_ep *ep, u32 epnum, u32 dir_in) in fotg210_set_fifo_dir() argument
123 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_fifo_dir()
131 static void fotg210_set_tfrtype(struct fotg210_ep *ep, u32 epnum, u32 type) in fotg210_set_tfrtype() argument
133 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_tfrtype()
141 static void fotg210_set_mps(struct fotg210_ep *ep, u32 epnum, u32 mps, in fotg210_set_mps() argument
144 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_mps()
154 static int fotg210_config_ep(struct fotg210_ep *ep, in fotg210_config_ep() argument
157 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_config_ep()
159 fotg210_set_fifo_dir(ep, ep->epnum, ep->dir_in); in fotg210_config_ep()
160 fotg210_set_tfrtype(ep, ep->epnum, ep->type); in fotg210_config_ep()
161 fotg210_set_mps(ep, ep->epnum, ep->ep.maxpacket, ep->dir_in); in fotg210_config_ep()
162 fotg210_fifo_ep_mapping(ep, ep->epnum, ep->dir_in); in fotg210_config_ep()
164 fotg210->ep[ep->epnum] = ep; in fotg210_config_ep()
172 struct fotg210_ep *ep; in fotg210_ep_enable() local
174 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_enable()
176 ep->desc = desc; in fotg210_ep_enable()
177 ep->epnum = usb_endpoint_num(desc); in fotg210_ep_enable()
178 ep->type = usb_endpoint_type(desc); in fotg210_ep_enable()
179 ep->dir_in = usb_endpoint_dir_in(desc); in fotg210_ep_enable()
180 ep->ep.maxpacket = usb_endpoint_maxp(desc); in fotg210_ep_enable()
182 return fotg210_config_ep(ep, desc); in fotg210_ep_enable()
187 struct fotg210_ep *ep = fotg210->ep[epnum]; in fotg210_reset_tseq() local
191 reg = (ep->dir_in) ? in fotg210_reset_tseq()
208 static int fotg210_ep_release(struct fotg210_ep *ep) in fotg210_ep_release() argument
210 if (!ep->epnum) in fotg210_ep_release()
212 ep->epnum = 0; in fotg210_ep_release()
213 ep->stall = 0; in fotg210_ep_release()
214 ep->wedged = 0; in fotg210_ep_release()
216 fotg210_reset_tseq(ep->fotg210, ep->epnum); in fotg210_ep_release()
223 struct fotg210_ep *ep; in fotg210_ep_disable() local
229 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_disable()
231 while (!list_empty(&ep->queue)) { in fotg210_ep_disable()
232 req = list_entry(ep->queue.next, in fotg210_ep_disable()
234 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_ep_disable()
235 fotg210_done(ep, req, -ECONNRESET); in fotg210_ep_disable()
236 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_ep_disable()
239 return fotg210_ep_release(ep); in fotg210_ep_disable()
265 static void fotg210_enable_dma(struct fotg210_ep *ep, in fotg210_enable_dma() argument
269 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_enable_dma()
274 value |= DMACPSR1_DMA_LEN(len) | DMACPSR1_DMA_TYPE(ep->dir_in); in fotg210_enable_dma()
279 if (ep->epnum) in fotg210_enable_dma()
280 value |= DMATFNR_ACC_FN(ep->epnum - 1); in fotg210_enable_dma()
299 static void fotg210_disable_dma(struct fotg210_ep *ep) in fotg210_disable_dma() argument
301 iowrite32(DMATFNR_DISDMA, ep->fotg210->reg + FOTG210_DMATFNR); in fotg210_disable_dma()
304 static void fotg210_wait_dma_done(struct fotg210_ep *ep) in fotg210_wait_dma_done() argument
309 value = ioread32(ep->fotg210->reg + FOTG210_DISGR2); in fotg210_wait_dma_done()
315 fotg210_ack_int(ep->fotg210, FOTG210_DISGR2, DISGR2_DMA_CMPLT); in fotg210_wait_dma_done()
319 value = ioread32(ep->fotg210->reg + FOTG210_DMACPSR1); in fotg210_wait_dma_done()
321 iowrite32(value, ep->fotg210->reg + FOTG210_DMACPSR1); in fotg210_wait_dma_done()
324 if (ep->epnum) { in fotg210_wait_dma_done()
325 value = ioread32(ep->fotg210->reg + in fotg210_wait_dma_done()
326 FOTG210_FIBCR(ep->epnum - 1)); in fotg210_wait_dma_done()
328 iowrite32(value, ep->fotg210->reg + in fotg210_wait_dma_done()
329 FOTG210_FIBCR(ep->epnum - 1)); in fotg210_wait_dma_done()
331 value = ioread32(ep->fotg210->reg + FOTG210_DCFESR); in fotg210_wait_dma_done()
333 iowrite32(value, ep->fotg210->reg + FOTG210_DCFESR); in fotg210_wait_dma_done()
337 static void fotg210_start_dma(struct fotg210_ep *ep, in fotg210_start_dma() argument
340 struct device *dev = &ep->fotg210->gadget.dev; in fotg210_start_dma()
345 if (ep->epnum) { in fotg210_start_dma()
346 if (ep->dir_in) { in fotg210_start_dma()
351 length = ioread32(ep->fotg210->reg + in fotg210_start_dma()
352 FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX; in fotg210_start_dma()
358 if (req->req.length - req->req.actual > ep->ep.maxpacket) in fotg210_start_dma()
359 length = ep->ep.maxpacket; in fotg210_start_dma()
365 ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); in fotg210_start_dma()
372 fotg210_enable_dma(ep, d, length); in fotg210_start_dma()
375 fotg210_wait_dma_done(ep); in fotg210_start_dma()
377 fotg210_disable_dma(ep); in fotg210_start_dma()
385 static void fotg210_ep0_queue(struct fotg210_ep *ep, in fotg210_ep0_queue() argument
389 fotg210_done(ep, req, 0); in fotg210_ep0_queue()
392 if (ep->dir_in) { /* if IN */ in fotg210_ep0_queue()
393 fotg210_start_dma(ep, req); in fotg210_ep0_queue()
395 fotg210_done(ep, req, 0); in fotg210_ep0_queue()
397 u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR0); in fotg210_ep0_queue()
400 iowrite32(value, ep->fotg210->reg + FOTG210_DMISGR0); in fotg210_ep0_queue()
407 struct fotg210_ep *ep; in fotg210_ep_queue() local
412 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_queue()
415 if (ep->fotg210->gadget.speed == USB_SPEED_UNKNOWN) in fotg210_ep_queue()
418 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_ep_queue()
420 if (list_empty(&ep->queue)) in fotg210_ep_queue()
423 list_add_tail(&req->queue, &ep->queue); in fotg210_ep_queue()
428 if (!ep->epnum) /* ep0 */ in fotg210_ep_queue()
429 fotg210_ep0_queue(ep, req); in fotg210_ep_queue()
430 else if (request && !ep->stall) in fotg210_ep_queue()
431 fotg210_enable_fifo_int(ep); in fotg210_ep_queue()
433 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_ep_queue()
440 struct fotg210_ep *ep; in fotg210_ep_dequeue() local
444 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep_dequeue()
447 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_ep_dequeue()
448 if (!list_empty(&ep->queue)) in fotg210_ep_dequeue()
449 fotg210_done(ep, req, -ECONNRESET); in fotg210_ep_dequeue()
450 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_ep_dequeue()
455 static void fotg210_set_epnstall(struct fotg210_ep *ep) in fotg210_set_epnstall() argument
457 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_set_epnstall()
462 if (ep->dir_in) { in fotg210_set_epnstall()
465 } while (!(value & DCFESR_FIFO_EMPTY(ep->epnum - 1))); in fotg210_set_epnstall()
468 reg = (ep->dir_in) ? in fotg210_set_epnstall()
469 fotg210->reg + FOTG210_INEPMPSR(ep->epnum) : in fotg210_set_epnstall()
470 fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum); in fotg210_set_epnstall()
476 static void fotg210_clear_epnstall(struct fotg210_ep *ep) in fotg210_clear_epnstall() argument
478 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_clear_epnstall()
482 reg = (ep->dir_in) ? in fotg210_clear_epnstall()
483 fotg210->reg + FOTG210_INEPMPSR(ep->epnum) : in fotg210_clear_epnstall()
484 fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum); in fotg210_clear_epnstall()
492 struct fotg210_ep *ep; in fotg210_set_halt_and_wedge() local
496 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_set_halt_and_wedge()
498 fotg210 = ep->fotg210; in fotg210_set_halt_and_wedge()
500 spin_lock_irqsave(&ep->fotg210->lock, flags); in fotg210_set_halt_and_wedge()
503 fotg210_set_epnstall(ep); in fotg210_set_halt_and_wedge()
504 ep->stall = 1; in fotg210_set_halt_and_wedge()
506 ep->wedged = 1; in fotg210_set_halt_and_wedge()
508 fotg210_reset_tseq(fotg210, ep->epnum); in fotg210_set_halt_and_wedge()
509 fotg210_clear_epnstall(ep); in fotg210_set_halt_and_wedge()
510 ep->stall = 0; in fotg210_set_halt_and_wedge()
511 ep->wedged = 0; in fotg210_set_halt_and_wedge()
512 if (!list_empty(&ep->queue)) in fotg210_set_halt_and_wedge()
513 fotg210_enable_fifo_int(ep); in fotg210_set_halt_and_wedge()
516 spin_unlock_irqrestore(&ep->fotg210->lock, flags); in fotg210_set_halt_and_wedge()
665 fotg210_set_epnstall(fotg210->ep[epnum]); in fotg210_set_feature()
680 struct fotg210_ep *ep = in fotg210_clear_feature() local
681 fotg210->ep[ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK]; in fotg210_clear_feature()
692 if (ep->wedged) { in fotg210_clear_feature()
696 if (ep->stall) in fotg210_clear_feature()
697 fotg210_set_halt_and_wedge(&ep->ep, 0, 0); in fotg210_clear_feature()
707 static int fotg210_is_epnstall(struct fotg210_ep *ep) in fotg210_is_epnstall() argument
709 struct fotg210_udc *fotg210 = ep->fotg210; in fotg210_is_epnstall()
713 reg = (ep->dir_in) ? in fotg210_is_epnstall()
714 fotg210->reg + FOTG210_INEPMPSR(ep->epnum) : in fotg210_is_epnstall()
715 fotg210->reg + FOTG210_OUTEPMPSR(ep->epnum); in fotg210_is_epnstall()
723 struct fotg210_ep *ep; in fotg210_ep0_complete() local
726 ep = container_of(_ep, struct fotg210_ep, ep); in fotg210_ep0_complete()
727 fotg210 = ep->fotg210; in fotg210_ep0_complete()
750 cpu_to_le16(fotg210_is_epnstall(fotg210->ep[epnum]) in fotg210_get_status()
777 fotg210->ep[0]->dir_in = ctrl->bRequestType & USB_DIR_IN; in fotg210_setup_packet()
817 struct fotg210_ep *ep = fotg210->ep[0]; in fotg210_ep0out() local
819 if (!list_empty(&ep->queue) && !ep->dir_in) { in fotg210_ep0out()
822 req = list_first_entry(&ep->queue, in fotg210_ep0out()
826 fotg210_start_dma(ep, req); in fotg210_ep0out()
828 if ((req->req.length - req->req.actual) < ep->ep.maxpacket) in fotg210_ep0out()
829 fotg210_done(ep, req, 0); in fotg210_ep0out()
837 struct fotg210_ep *ep = fotg210->ep[0]; in fotg210_ep0in() local
839 if ((!list_empty(&ep->queue)) && (ep->dir_in)) { in fotg210_ep0in()
842 req = list_entry(ep->queue.next, in fotg210_ep0in()
846 fotg210_start_dma(ep, req); in fotg210_ep0in()
849 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()
869 int disgr1 = ioread32(ep->fotg210->reg + FOTG210_DISGR1); in fotg210_out_fifo_handler()
871 fotg210_start_dma(ep, req); in fotg210_out_fifo_handler()
878 (disgr1 & DISGR1_SPK_INT(ep->epnum - 1))) in fotg210_out_fifo_handler()
879 fotg210_done(ep, req, 0); in fotg210_out_fifo_handler()
984 fotg210_in_fifo_handler(fotg210->ep[fifo + 1]); in fotg210_irq()
988 fotg210_out_fifo_handler(fotg210->ep[fifo + 1]); in fotg210_irq()
1164 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); in fotg210_udc_remove()
1166 kfree(fotg210->ep[i]); in fotg210_udc_remove()
1210 fotg210->ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL); in fotg210_udc_probe()
1211 if (!fotg210->ep[i]) in fotg210_udc_probe()
1231 struct fotg210_ep *ep = fotg210->ep[i]; in fotg210_udc_probe() local
1234 INIT_LIST_HEAD(&fotg210->ep[i]->ep.ep_list); in fotg210_udc_probe()
1235 list_add_tail(&fotg210->ep[i]->ep.ep_list, in fotg210_udc_probe()
1238 ep->fotg210 = fotg210; in fotg210_udc_probe()
1239 INIT_LIST_HEAD(&ep->queue); in fotg210_udc_probe()
1240 ep->ep.name = fotg210_ep_name[i]; in fotg210_udc_probe()
1241 ep->ep.ops = &fotg210_ep_ops; in fotg210_udc_probe()
1242 usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); in fotg210_udc_probe()
1245 ep->ep.caps.type_control = true; in fotg210_udc_probe()
1247 ep->ep.caps.type_iso = true; in fotg210_udc_probe()
1248 ep->ep.caps.type_bulk = true; in fotg210_udc_probe()
1249 ep->ep.caps.type_int = true; in fotg210_udc_probe()
1252 ep->ep.caps.dir_in = true; in fotg210_udc_probe()
1253 ep->ep.caps.dir_out = true; in fotg210_udc_probe()
1255 usb_ep_set_maxpacket_limit(&fotg210->ep[0]->ep, 0x40); in fotg210_udc_probe()
1256 fotg210->gadget.ep0 = &fotg210->ep[0]->ep; in fotg210_udc_probe()
1259 fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep, in fotg210_udc_probe()
1294 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req); in fotg210_udc_probe()
1301 kfree(fotg210->ep[i]); in fotg210_udc_probe()