Lines Matching refs:ep

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