Lines Matching refs:ep

35 static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req);
36 static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req);
40 static void transfer_complete(struct m66592_ep *ep,
99 INIT_LIST_HEAD(&m66592->ep[0].queue);
208 struct m66592_ep *ep = m66592->pipenum2ep[pipenum];
211 if (ep->use_dma)
214 m66592_mdfy(m66592, pipenum, M66592_CURPIPE, ep->fifosel);
223 m66592_bset(m66592, mbw, ep->fifosel);
300 static void pipe_initialize(struct m66592_ep *ep)
302 struct m66592 *m66592 = ep->m66592;
305 m66592_mdfy(m66592, 0, M66592_CURPIPE, ep->fifosel);
307 m66592_write(m66592, M66592_ACLRM, ep->pipectr);
308 m66592_write(m66592, 0, ep->pipectr);
309 m66592_write(m66592, M66592_SQCLR, ep->pipectr);
310 if (ep->use_dma) {
311 m66592_mdfy(m66592, ep->pipenum, M66592_CURPIPE, ep->fifosel);
320 m66592_bset(m66592, mbw, ep->fifosel);
324 static void m66592_ep_setting(struct m66592 *m66592, struct m66592_ep *ep,
331 ep->use_dma = 1;
332 ep->fifoaddr = M66592_D0FIFO;
333 ep->fifosel = M66592_D0FIFOSEL;
334 ep->fifoctr = M66592_D0FIFOCTR;
335 ep->fifotrn = M66592_D0FIFOTRN;
338 ep->use_dma = 1;
339 ep->fifoaddr = M66592_D1FIFO;
340 ep->fifosel = M66592_D1FIFOSEL;
341 ep->fifoctr = M66592_D1FIFOCTR;
342 ep->fifotrn = M66592_D1FIFOTRN;
344 ep->use_dma = 0;
345 ep->fifoaddr = M66592_CFIFO;
346 ep->fifosel = M66592_CFIFOSEL;
347 ep->fifoctr = M66592_CFIFOCTR;
348 ep->fifotrn = 0;
351 ep->use_dma = 0;
352 ep->fifoaddr = M66592_CFIFO;
353 ep->fifosel = M66592_CFIFOSEL;
354 ep->fifoctr = M66592_CFIFOCTR;
355 ep->fifotrn = 0;
358 ep->pipectr = get_pipectr_addr(pipenum);
359 ep->pipenum = pipenum;
360 ep->ep.maxpacket = usb_endpoint_maxp(desc);
361 m66592->pipenum2ep[pipenum] = ep;
362 m66592->epaddr2ep[desc->bEndpointAddress&USB_ENDPOINT_NUMBER_MASK] = ep;
363 INIT_LIST_HEAD(&ep->queue);
366 static void m66592_ep_release(struct m66592_ep *ep)
368 struct m66592 *m66592 = ep->m66592;
369 u16 pipenum = ep->pipenum;
374 if (ep->use_dma)
376 ep->pipenum = 0;
377 ep->busy = 0;
378 ep->use_dma = 0;
381 static int alloc_pipe_config(struct m66592_ep *ep,
384 struct m66592 *m66592 = ep->m66592;
390 ep->ep.desc = desc;
392 BUG_ON(ep->pipenum);
434 ep->type = info.type;
454 m66592_ep_setting(m66592, ep, desc, info.pipe, dma);
455 pipe_initialize(ep);
460 static int free_pipe_config(struct m66592_ep *ep)
462 struct m66592 *m66592 = ep->m66592;
465 info.pipe = ep->pipenum;
466 info.type = ep->type;
468 m66592_ep_release(ep);
489 m66592->ep[0].internal_ccpl = ccpl;
494 static void start_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
496 struct m66592 *m66592 = ep->m66592;
498 pipe_change(m66592, ep->pipenum);
502 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
504 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
506 transfer_complete(ep, req, 0);
509 irq_ep0_write(ep, req);
513 static void start_packet_write(struct m66592_ep *ep, struct m66592_request *req)
515 struct m66592 *m66592 = ep->m66592;
518 pipe_change(m66592, ep->pipenum);
519 disable_irq_empty(m66592, ep->pipenum);
520 pipe_start(m66592, ep->pipenum);
522 tmp = m66592_read(m66592, ep->fifoctr);
524 pipe_irq_enable(m66592, ep->pipenum);
526 irq_packet_write(ep, req);
529 static void start_packet_read(struct m66592_ep *ep, struct m66592_request *req)
531 struct m66592 *m66592 = ep->m66592;
532 u16 pipenum = ep->pipenum;
534 if (ep->pipenum == 0) {
538 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
542 if (ep->use_dma) {
543 m66592_bset(m66592, M66592_TRCLR, ep->fifosel);
545 m66592_bset(m66592, M66592_TRENB, ep->fifosel);
547 (req->req.length + ep->ep.maxpacket - 1)
548 / ep->ep.maxpacket,
549 ep->fifotrn);
556 static void start_packet(struct m66592_ep *ep, struct m66592_request *req)
558 if (ep->ep.desc->bEndpointAddress & USB_DIR_IN)
559 start_packet_write(ep, req);
561 start_packet_read(ep, req);
564 static void start_ep0(struct m66592_ep *ep, struct m66592_request *req)
568 ctsq = m66592_read(ep->m66592, M66592_INTSTS0) & M66592_CTSQ;
572 start_ep0_write(ep, req);
575 start_packet_read(ep, req);
579 control_end(ep->m66592, 0);
705 static void transfer_complete(struct m66592_ep *ep,
712 if (unlikely(ep->pipenum == 0)) {
713 if (ep->internal_ccpl) {
714 ep->internal_ccpl = 0;
720 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN)
725 if (!list_empty(&ep->queue))
728 spin_unlock(&ep->m66592->lock);
729 usb_gadget_giveback_request(&ep->ep, &req->req);
730 spin_lock(&ep->m66592->lock);
733 req = list_entry(ep->queue.next, struct m66592_request, queue);
734 if (ep->ep.desc)
735 start_packet(ep, req);
739 static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
746 u16 pipenum = ep->pipenum;
747 struct m66592 *m66592 = ep->m66592;
750 m66592_bset(m66592, M66592_ISEL, ep->fifosel);
754 tmp = m66592_read(m66592, ep->fifoctr);
771 m66592_write_fifo(m66592, ep, buf, size);
772 if ((size == 0) || ((size % ep->ep.maxpacket) != 0))
773 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
781 || (size % ep->ep.maxpacket)
792 static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req)
798 u16 pipenum = ep->pipenum;
799 struct m66592 *m66592 = ep->m66592;
802 tmp = m66592_read(m66592, ep->fifoctr);
817 m66592_write_fifo(m66592, ep, buf, size);
819 || ((size % ep->ep.maxpacket) != 0)
820 || ((bufsize != ep->ep.maxpacket)
822 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
829 || (size % ep->ep.maxpacket)
839 static void irq_packet_read(struct m66592_ep *ep, struct m66592_request *req)
845 u16 pipenum = ep->pipenum;
846 struct m66592 *m66592 = ep->m66592;
850 tmp = m66592_read(m66592, ep->fifoctr);
875 || (size % ep->ep.maxpacket)
885 m66592_write(m66592, M66592_BCLR, ep->fifoctr);
887 m66592_read_fifo(m66592, ep->fifoaddr, buf, size);
890 if ((ep->pipenum != 0) && finish)
891 transfer_complete(ep, req, 0);
898 struct m66592_ep *ep;
906 ep = &m66592->ep[0];
907 req = list_entry(ep->queue.next, struct m66592_request, queue);
908 irq_packet_read(ep, req);
914 ep = m66592->pipenum2ep[pipenum];
915 req = list_entry(ep->queue.next,
917 if (ep->ep.desc->bEndpointAddress & USB_DIR_IN)
918 irq_packet_write(ep, req);
920 irq_packet_read(ep, req);
931 struct m66592_ep *ep;
937 ep = &m66592->ep[0];
938 req = list_entry(ep->queue.next, struct m66592_request, queue);
939 irq_ep0_write(ep, req);
950 ep = m66592->pipenum2ep[pipenum];
951 req = list_entry(ep->queue.next,
954 if (!list_empty(&ep->queue))
955 transfer_complete(ep, req, 0);
966 struct m66592_ep *ep;
979 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK];
980 pid = control_reg_get_pid(m66592, ep->pipenum);
1010 struct m66592_ep *ep;
1014 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK];
1015 pipe_stop(m66592, ep->pipenum);
1016 control_reg_sqclr(m66592, ep->pipenum);
1020 req = list_entry(ep->queue.next,
1022 if (ep->busy) {
1023 ep->busy = 0;
1024 if (list_empty(&ep->queue))
1026 start_packet(ep, req);
1027 } else if (!list_empty(&ep->queue))
1028 pipe_start(m66592, ep->pipenum);
1068 struct m66592_ep *ep;
1071 ep = m66592->epaddr2ep[w_index & USB_ENDPOINT_NUMBER_MASK];
1072 pipe_stall(m66592, ep->pipenum);
1166 struct m66592_ep *ep;
1168 ep = &m66592->ep[0];
1169 req = list_entry(ep->queue.next, struct m66592_request, queue);
1170 transfer_complete(ep, req, 0);
1302 struct m66592_ep *ep;
1304 ep = container_of(_ep, struct m66592_ep, ep);
1305 return alloc_pipe_config(ep, desc);
1310 struct m66592_ep *ep;
1314 ep = container_of(_ep, struct m66592_ep, ep);
1315 BUG_ON(!ep);
1317 while (!list_empty(&ep->queue)) {
1318 req = list_entry(ep->queue.next, struct m66592_request, queue);
1319 spin_lock_irqsave(&ep->m66592->lock, flags);
1320 transfer_complete(ep, req, -ECONNRESET);
1321 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1324 pipe_irq_disable(ep->m66592, ep->pipenum);
1325 return free_pipe_config(ep);
1353 struct m66592_ep *ep;
1358 ep = container_of(_ep, struct m66592_ep, ep);
1361 if (ep->m66592->gadget.speed == USB_SPEED_UNKNOWN)
1364 spin_lock_irqsave(&ep->m66592->lock, flags);
1366 if (list_empty(&ep->queue))
1369 list_add_tail(&req->queue, &ep->queue);
1373 if (ep->ep.desc == NULL) /* control */
1374 start_ep0(ep, req);
1376 if (request && !ep->busy)
1377 start_packet(ep, req);
1380 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1387 struct m66592_ep *ep;
1391 ep = container_of(_ep, struct m66592_ep, ep);
1394 spin_lock_irqsave(&ep->m66592->lock, flags);
1395 if (!list_empty(&ep->queue))
1396 transfer_complete(ep, req, -ECONNRESET);
1397 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1404 struct m66592_ep *ep = container_of(_ep, struct m66592_ep, ep);
1408 spin_lock_irqsave(&ep->m66592->lock, flags);
1409 if (!list_empty(&ep->queue)) {
1412 ep->busy = 1;
1413 pipe_stall(ep->m66592, ep->pipenum);
1415 ep->busy = 0;
1416 pipe_stop(ep->m66592, ep->pipenum);
1418 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1424 struct m66592_ep *ep;
1427 ep = container_of(_ep, struct m66592_ep, ep);
1428 spin_lock_irqsave(&ep->m66592->lock, flags);
1429 if (list_empty(&ep->queue) && !ep->busy) {
1430 pipe_stop(ep->m66592, ep->pipenum);
1431 m66592_bclr(ep->m66592, M66592_BCLR, ep->fifoctr);
1433 spin_unlock_irqrestore(&ep->m66592->lock, flags);
1524 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1532 static void nop_completion(struct usb_ep *ep, struct usb_request *r)
1613 m66592->gadget.ep0 = &m66592->ep[0].ep;
1616 struct m66592_ep *ep = &m66592->ep[i];
1619 INIT_LIST_HEAD(&m66592->ep[i].ep.ep_list);
1620 list_add_tail(&m66592->ep[i].ep.ep_list,
1623 ep->m66592 = m66592;
1624 INIT_LIST_HEAD(&ep->queue);
1625 ep->ep.name = m66592_ep_name[i];
1626 ep->ep.ops = &m66592_ep_ops;
1627 usb_ep_set_maxpacket_limit(&ep->ep, 512);
1630 ep->ep.caps.type_control = true;
1632 ep->ep.caps.type_iso = true;
1633 ep->ep.caps.type_bulk = true;
1634 ep->ep.caps.type_int = true;
1637 ep->ep.caps.dir_in = true;
1638 ep->ep.caps.dir_out = true;
1640 usb_ep_set_maxpacket_limit(&m66592->ep[0].ep, 64);
1641 m66592->ep[0].pipenum = 0;
1642 m66592->ep[0].fifoaddr = M66592_CFIFO;
1643 m66592->ep[0].fifosel = M66592_CFIFOSEL;
1644 m66592->ep[0].fifoctr = M66592_CFIFOCTR;
1645 m66592->ep[0].fifotrn = 0;
1646 m66592->ep[0].pipectr = get_pipectr_addr(0);
1647 m66592->pipenum2ep[0] = &m66592->ep[0];
1648 m66592->epaddr2ep[0] = &m66592->ep[0];
1650 m66592->ep0_req = m66592_alloc_request(&m66592->ep[0].ep, GFP_KERNEL);
1667 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);
1679 m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req);