Lines Matching refs:ep

76 static void done(struct qe_ep *ep, struct qe_req *req, int status)  in done()  argument
78 struct qe_udc *udc = ep->udc; in done()
79 unsigned char stopped = ep->stopped; in done()
96 ep_is_in(ep) in done()
104 ep_is_in(ep) in done()
110 ep->ep.name, &req->req, status, in done()
114 ep->stopped = 1; in done()
117 usb_gadget_giveback_request(&ep->ep, &req->req); in done()
121 ep->stopped = stopped; in done()
127 static void nuke(struct qe_ep *ep, int status) in nuke() argument
130 while (!list_empty(&ep->queue)) { in nuke()
132 req = list_entry(ep->queue.next, struct qe_req, queue); in nuke()
134 done(ep, req, status); in nuke()
142 static int qe_eprx_stall_change(struct qe_ep *ep, int value) in qe_eprx_stall_change() argument
145 u8 epnum = ep->epnum; in qe_eprx_stall_change()
146 struct qe_udc *udc = ep->udc; in qe_eprx_stall_change()
152 else if (ep->dir == USB_DIR_IN) in qe_eprx_stall_change()
159 static int qe_eptx_stall_change(struct qe_ep *ep, int value) in qe_eptx_stall_change() argument
162 u8 epnum = ep->epnum; in qe_eptx_stall_change()
163 struct qe_udc *udc = ep->udc; in qe_eptx_stall_change()
169 else if (ep->dir == USB_DIR_OUT) in qe_eptx_stall_change()
186 static int qe_eprx_nack(struct qe_ep *ep) in qe_eprx_nack() argument
188 u8 epnum = ep->epnum; in qe_eprx_nack()
189 struct qe_udc *udc = ep->udc; in qe_eprx_nack()
191 if (ep->state == EP_STATE_IDLE) { in qe_eprx_nack()
200 ep->state = EP_STATE_NACK; in qe_eprx_nack()
205 static int qe_eprx_normal(struct qe_ep *ep) in qe_eprx_normal() argument
207 struct qe_udc *udc = ep->udc; in qe_eprx_normal()
209 if (ep->state == EP_STATE_NACK) { in qe_eprx_normal()
210 clrsetbits_be16(&udc->usb_regs->usb_usep[ep->epnum], in qe_eprx_normal()
219 ep->state = EP_STATE_IDLE; in qe_eprx_normal()
220 ep->has_data = 0; in qe_eprx_normal()
226 static int qe_ep_cmd_stoptx(struct qe_ep *ep) in qe_ep_cmd_stoptx() argument
228 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_stoptx()
229 cpm_command(CPM_USB_STOP_TX | (ep->epnum << CPM_USB_EP_SHIFT), in qe_ep_cmd_stoptx()
233 ep->epnum, 0); in qe_ep_cmd_stoptx()
238 static int qe_ep_cmd_restarttx(struct qe_ep *ep) in qe_ep_cmd_restarttx() argument
240 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_restarttx()
241 cpm_command(CPM_USB_RESTART_TX | (ep->epnum << in qe_ep_cmd_restarttx()
245 ep->epnum, 0); in qe_ep_cmd_restarttx()
250 static int qe_ep_flushtxfifo(struct qe_ep *ep) in qe_ep_flushtxfifo() argument
252 struct qe_udc *udc = ep->udc; in qe_ep_flushtxfifo()
255 i = (int)ep->epnum; in qe_ep_flushtxfifo()
257 qe_ep_cmd_stoptx(ep); in qe_ep_flushtxfifo()
259 USB_CMD_FLUSH_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); in qe_ep_flushtxfifo()
264 ep->c_txbd = ep->txbase; in qe_ep_flushtxfifo()
265 ep->n_txbd = ep->txbase; in qe_ep_flushtxfifo()
266 qe_ep_cmd_restarttx(ep); in qe_ep_flushtxfifo()
270 static int qe_ep_filltxfifo(struct qe_ep *ep) in qe_ep_filltxfifo() argument
272 struct qe_udc *udc = ep->udc; in qe_ep_filltxfifo()
275 USB_CMD_STR_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); in qe_ep_filltxfifo()
281 struct qe_ep *ep; in qe_epbds_reset() local
286 ep = &udc->eps[pipe_num]; in qe_epbds_reset()
288 if (ep->dir == USB_DIR_OUT) in qe_epbds_reset()
293 bd = ep->rxbase; in qe_epbds_reset()
300 bd = ep->txbase; in qe_epbds_reset()
313 struct qe_ep *ep; in qe_ep_reset() local
316 ep = &udc->eps[pipe_num]; in qe_ep_reset()
320 switch (ep->dir) { in qe_ep_reset()
322 qe_ep_flushtxfifo(ep); in qe_ep_reset()
328 qe_ep_flushtxfifo(ep); in qe_ep_reset()
341 static int qe_ep_toggledata01(struct qe_ep *ep) in qe_ep_toggledata01() argument
343 ep->data01 ^= 0x1; in qe_ep_toggledata01()
349 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_bd_init() local
356 if (ep->dir == USB_DIR_OUT) in qe_ep_bd_init()
375 ep->rxbase = cpm_muram_addr(tmp_addr); in qe_ep_bd_init()
376 ep->txbase = cpm_muram_addr(tmp_addr + (sizeof(struct qe_bd) in qe_ep_bd_init()
378 ep->n_rxbd = ep->rxbase; in qe_ep_bd_init()
379 ep->e_rxbd = ep->rxbase; in qe_ep_bd_init()
380 ep->n_txbd = ep->txbase; in qe_ep_bd_init()
381 ep->c_txbd = ep->txbase; in qe_ep_bd_init()
382 ep->data01 = 0; /* data0 */ in qe_ep_bd_init()
385 bd = ep->rxbase; in qe_ep_bd_init()
394 bd = ep->txbase; in qe_ep_bd_init()
406 static int qe_ep_rxbd_update(struct qe_ep *ep) in qe_ep_rxbd_update() argument
414 if (ep->rxbase == NULL) in qe_ep_rxbd_update()
417 bd = ep->rxbase; in qe_ep_rxbd_update()
419 ep->rxframe = kmalloc(sizeof(*ep->rxframe), GFP_ATOMIC); in qe_ep_rxbd_update()
420 if (!ep->rxframe) in qe_ep_rxbd_update()
423 qe_frame_init(ep->rxframe); in qe_ep_rxbd_update()
425 if (ep->dir == USB_DIR_OUT) in qe_ep_rxbd_update()
430 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (bdring_len + 1); in qe_ep_rxbd_update()
431 ep->rxbuffer = kzalloc(size, GFP_ATOMIC); in qe_ep_rxbd_update()
432 if (!ep->rxbuffer) { in qe_ep_rxbd_update()
433 kfree(ep->rxframe); in qe_ep_rxbd_update()
437 ep->rxbuf_d = virt_to_phys((void *)ep->rxbuffer); in qe_ep_rxbd_update()
438 if (ep->rxbuf_d == DMA_ADDR_INVALID) { in qe_ep_rxbd_update()
439 ep->rxbuf_d = dma_map_single(ep->udc->gadget.dev.parent, in qe_ep_rxbd_update()
440 ep->rxbuffer, in qe_ep_rxbd_update()
443 ep->rxbufmap = 1; in qe_ep_rxbd_update()
445 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in qe_ep_rxbd_update()
446 ep->rxbuf_d, size, in qe_ep_rxbd_update()
448 ep->rxbufmap = 0; in qe_ep_rxbd_update()
451 size = ep->ep.maxpacket + USB_CRC_SIZE + 2; in qe_ep_rxbd_update()
452 tmp = ep->rxbuf_d; in qe_ep_rxbd_update()
469 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_register_init() local
478 logepnum = (ep->ep.desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in qe_ep_register_init()
481 switch (ep->ep.desc->bmAttributes & 0x03) { in qe_ep_register_init()
496 switch (ep->dir) { in qe_ep_register_init()
512 tmp = (u16)(ep->ep.maxpacket + USB_CRC_SIZE); in qe_ep_register_init()
524 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_init() local
537 if (strstr(ep->ep.name, "-iso") in qe_ep_init()
538 || strstr(ep->ep.name, "-int")) in qe_ep_init()
560 if (strstr(ep->ep.name, "-iso")) /* bulk is ok */ in qe_ep_init()
578 if (strstr(ep->ep.name, "-bulk") in qe_ep_init()
579 || strstr(ep->ep.name, "-int")) in qe_ep_init()
595 if (strstr(ep->ep.name, "-iso") in qe_ep_init()
596 || strstr(ep->ep.name, "-int")) in qe_ep_init()
637 ep->ep.maxpacket = max; in qe_ep_init()
638 ep->tm = (u8)(desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); in qe_ep_init()
639 ep->ep.desc = desc; in qe_ep_init()
640 ep->stopped = 0; in qe_ep_init()
641 ep->init = 1; in qe_ep_init()
644 ep->dir = USB_DIR_BOTH; in qe_ep_init()
650 ep->dir = USB_DIR_OUT; in qe_ep_init()
653 ep->dir = USB_DIR_IN; in qe_ep_init()
661 if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_OUT)) { in qe_ep_init()
662 reval = qe_ep_rxbd_update(ep); in qe_ep_init()
667 if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_IN)) { in qe_ep_init()
668 ep->txframe = kmalloc(sizeof(*ep->txframe), GFP_ATOMIC); in qe_ep_init()
669 if (!ep->txframe) in qe_ep_init()
671 qe_frame_init(ep->txframe); in qe_ep_init()
682 kfree(ep->rxbuffer); in qe_ep_init()
683 kfree(ep->rxframe); in qe_ep_init()
687 dev_err(udc->dev, "failed to initialize %s\n", ep->ep.name); in qe_ep_init()
709 static void recycle_one_rxbd(struct qe_ep *ep) in recycle_one_rxbd() argument
713 bdstatus = in_be32((u32 __iomem *)ep->e_rxbd); in recycle_one_rxbd()
715 out_be32((u32 __iomem *)ep->e_rxbd, bdstatus); in recycle_one_rxbd()
718 ep->e_rxbd = ep->rxbase; in recycle_one_rxbd()
720 ep->e_rxbd++; in recycle_one_rxbd()
723 static void recycle_rxbds(struct qe_ep *ep, unsigned char stopatnext) in recycle_rxbds() argument
729 nextbd = ep->n_rxbd; in recycle_rxbds()
730 bd = ep->e_rxbd; in recycle_rxbds()
738 bd = ep->rxbase; in recycle_rxbds()
747 ep->e_rxbd = bd; in recycle_rxbds()
750 static void ep_recycle_rxbds(struct qe_ep *ep) in ep_recycle_rxbds() argument
752 struct qe_bd __iomem *bd = ep->n_rxbd; in ep_recycle_rxbds()
754 u8 epnum = ep->epnum; in ep_recycle_rxbds()
755 struct qe_udc *udc = ep->udc; in ep_recycle_rxbds()
759 bd = ep->rxbase + in ep_recycle_rxbds()
766 bd = ep->rxbase; in ep_recycle_rxbds()
770 ep->e_rxbd = bd; in ep_recycle_rxbds()
771 recycle_rxbds(ep, 0); in ep_recycle_rxbds()
772 ep->e_rxbd = ep->n_rxbd; in ep_recycle_rxbds()
774 recycle_rxbds(ep, 1); in ep_recycle_rxbds()
779 if (ep->has_data <= 0 && (!list_empty(&ep->queue))) in ep_recycle_rxbds()
780 qe_eprx_normal(ep); in ep_recycle_rxbds()
782 ep->localnack = 0; in ep_recycle_rxbds()
787 static int qe_ep_rxframe_handle(struct qe_ep *ep);
792 struct qe_ep *ep = &udc->eps[0]; in ep0_setup_handle() local
797 pframe = ep->rxframe; in ep0_setup_handle()
805 ep->data01 = 1; in ep0_setup_handle()
816 struct qe_ep *ep = &udc->eps[0]; in qe_ep0_rx() local
822 pframe = ep->rxframe; in qe_ep0_rx()
824 if (ep->dir == USB_DIR_IN) { in qe_ep0_rx()
829 bd = ep->n_rxbd; in qe_ep0_rx()
862 qe_ep_rxframe_handle(ep); in qe_ep0_rx()
869 recycle_one_rxbd(ep); in qe_ep0_rx()
873 bd = ep->rxbase; in qe_ep0_rx()
882 ep->n_rxbd = bd; in qe_ep0_rx()
887 static int qe_ep_rxframe_handle(struct qe_ep *ep) in qe_ep_rxframe_handle() argument
895 pframe = ep->rxframe; in qe_ep_rxframe_handle()
900 if (framepid != ep->data01) { in qe_ep_rxframe_handle()
901 dev_err(ep->udc->dev, "the data01 error!\n"); in qe_ep_rxframe_handle()
906 if (list_empty(&ep->queue)) { in qe_ep_rxframe_handle()
907 dev_err(ep->udc->dev, "the %s have no requeue!\n", ep->name); in qe_ep_rxframe_handle()
909 req = list_entry(ep->queue.next, struct qe_req, queue); in qe_ep_rxframe_handle()
915 if ((fsize < ep->ep.maxpacket) || in qe_ep_rxframe_handle()
917 if (ep->epnum == 0) in qe_ep_rxframe_handle()
918 ep0_req_complete(ep->udc, req); in qe_ep_rxframe_handle()
920 done(ep, req, 0); in qe_ep_rxframe_handle()
921 if (list_empty(&ep->queue) && ep->epnum != 0) in qe_ep_rxframe_handle()
922 qe_eprx_nack(ep); in qe_ep_rxframe_handle()
927 qe_ep_toggledata01(ep); in qe_ep_rxframe_handle()
935 struct qe_ep *ep; in ep_rx_tasklet() local
945 ep = &udc->eps[i]; in ep_rx_tasklet()
947 if (ep->dir == USB_DIR_IN || ep->enable_tasklet == 0) { in ep_rx_tasklet()
953 pframe = ep->rxframe; in ep_rx_tasklet()
954 bd = ep->n_rxbd; in ep_rx_tasklet()
959 if (list_empty(&ep->queue)) { in ep_rx_tasklet()
960 qe_eprx_nack(ep); in ep_rx_tasklet()
963 ep->has_data); in ep_rx_tasklet()
987 qe_ep_rxframe_handle(ep); in ep_rx_tasklet()
995 ep->has_data--; in ep_rx_tasklet()
996 if (!(ep->localnack)) in ep_rx_tasklet()
997 recycle_one_rxbd(ep); in ep_rx_tasklet()
1001 bd = ep->rxbase; in ep_rx_tasklet()
1009 ep->n_rxbd = bd; in ep_rx_tasklet()
1011 if (ep->localnack) in ep_rx_tasklet()
1012 ep_recycle_rxbds(ep); in ep_rx_tasklet()
1014 ep->enable_tasklet = 0; in ep_rx_tasklet()
1020 static int qe_ep_rx(struct qe_ep *ep) in qe_ep_rx() argument
1027 udc = ep->udc; in qe_ep_rx()
1028 pframe = ep->rxframe; in qe_ep_rx()
1030 if (ep->dir == USB_DIR_IN) { in qe_ep_rx()
1035 bd = ep->n_rxbd; in qe_ep_rx()
1037 swoffs = (u16)(bd - ep->rxbase); in qe_ep_rx()
1038 ucoffs = (u16)((in_be16(&udc->ep_param[ep->epnum]->rbptr) - in qe_ep_rx()
1039 in_be16(&udc->ep_param[ep->epnum]->rbase)) >> 3); in qe_ep_rx()
1046 qe_eprx_nack(ep); in qe_ep_rx()
1047 ep->localnack = 1; in qe_ep_rx()
1050 ep->has_data = USB_BDRING_LEN_RX - emptybds; in qe_ep_rx()
1052 if (list_empty(&ep->queue)) { in qe_ep_rx()
1053 qe_eprx_nack(ep); in qe_ep_rx()
1055 ep->has_data); in qe_ep_rx()
1060 ep->enable_tasklet = 1; in qe_ep_rx()
1066 static int qe_ep_tx(struct qe_ep *ep, struct qe_frame *frame) in qe_ep_tx() argument
1068 struct qe_udc *udc = ep->udc; in qe_ep_tx()
1074 if (ep->dir == USB_DIR_OUT) { in qe_ep_tx()
1084 bd = ep->n_txbd; in qe_ep_tx()
1104 if ((ep->epnum == 0) && (udc->ep0_state == DATA_STATE_NEED_ZLP)) in qe_ep_tx()
1105 ep->data01 = 0x1; in qe_ep_tx()
1107 if (ep->data01) { in qe_ep_tx()
1117 qe_ep_filltxfifo(ep); in qe_ep_tx()
1122 qe_ep_toggledata01(ep); in qe_ep_tx()
1124 ep->n_txbd = ep->txbase; in qe_ep_tx()
1126 ep->n_txbd++; in qe_ep_tx()
1138 static int txcomplete(struct qe_ep *ep, unsigned char restart) in txcomplete() argument
1140 if (ep->tx_req != NULL) { in txcomplete()
1141 struct qe_req *req = ep->tx_req; in txcomplete()
1144 last_len = min_t(unsigned, req->req.length - ep->sent, in txcomplete()
1145 ep->ep.maxpacket); in txcomplete()
1148 int asent = ep->last; in txcomplete()
1149 ep->sent += asent; in txcomplete()
1150 ep->last -= asent; in txcomplete()
1152 ep->last = 0; in txcomplete()
1158 (req->req.length % ep->ep.maxpacket) != 0) in txcomplete()
1166 if (((ep->tx_req->req.length - ep->sent) <= 0) && !zlp) { in txcomplete()
1167 done(ep, ep->tx_req, 0); in txcomplete()
1168 ep->tx_req = NULL; in txcomplete()
1169 ep->last = 0; in txcomplete()
1170 ep->sent = 0; in txcomplete()
1175 if (ep->tx_req == NULL) { in txcomplete()
1176 if (!list_empty(&ep->queue)) { in txcomplete()
1177 ep->tx_req = list_entry(ep->queue.next, struct qe_req, in txcomplete()
1179 ep->last = 0; in txcomplete()
1180 ep->sent = 0; in txcomplete()
1188 static int qe_usb_senddata(struct qe_ep *ep, struct qe_frame *frame) in qe_usb_senddata() argument
1194 size = min_t(u32, (ep->tx_req->req.length - ep->sent), in qe_usb_senddata()
1195 ep->ep.maxpacket); in qe_usb_senddata()
1196 buf = (u8 *)ep->tx_req->req.buf + ep->sent; in qe_usb_senddata()
1198 ep->last = size; in qe_usb_senddata()
1199 ep->tx_req->req.actual += size; in qe_usb_senddata()
1204 return qe_ep_tx(ep, frame); in qe_usb_senddata()
1210 static int sendnulldata(struct qe_ep *ep, struct qe_frame *frame, uint infor) in sendnulldata() argument
1212 struct qe_udc *udc = ep->udc; in sendnulldata()
1223 return qe_ep_tx(ep, frame); in sendnulldata()
1226 static int frame_create_tx(struct qe_ep *ep, struct qe_frame *frame) in frame_create_tx() argument
1228 struct qe_req *req = ep->tx_req; in frame_create_tx()
1234 if ((req->req.length - ep->sent) > 0) in frame_create_tx()
1235 reval = qe_usb_senddata(ep, frame); in frame_create_tx()
1237 reval = sendnulldata(ep, frame, 0); in frame_create_tx()
1248 struct qe_ep *ep = &udc->eps[0]; in ep0_prime_status() local
1253 sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); in ep0_prime_status()
1265 struct qe_ep *ep = &udc->eps[0]; in ep0_req_complete() local
1270 done(ep, req, 0); in ep0_req_complete()
1277 done(ep, req, 0); in ep0_req_complete()
1282 done(ep, req, 0); in ep0_req_complete()
1289 done(ep, req, 0); in ep0_req_complete()
1303 static int ep0_txcomplete(struct qe_ep *ep, unsigned char restart) in ep0_txcomplete() argument
1306 struct qe_frame *frame = ep->txframe; in ep0_txcomplete()
1310 ep->udc->ep0_state = WAIT_FOR_SETUP; in ep0_txcomplete()
1312 sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); in ep0_txcomplete()
1316 tx_req = ep->tx_req; in ep0_txcomplete()
1319 int asent = ep->last; in ep0_txcomplete()
1320 ep->sent += asent; in ep0_txcomplete()
1321 ep->last -= asent; in ep0_txcomplete()
1323 ep->last = 0; in ep0_txcomplete()
1327 if ((ep->tx_req->req.length - ep->sent) <= 0) { in ep0_txcomplete()
1328 ep->tx_req->req.actual = (unsigned int)ep->sent; in ep0_txcomplete()
1329 ep0_req_complete(ep->udc, ep->tx_req); in ep0_txcomplete()
1330 ep->tx_req = NULL; in ep0_txcomplete()
1331 ep->last = 0; in ep0_txcomplete()
1332 ep->sent = 0; in ep0_txcomplete()
1335 dev_vdbg(ep->udc->dev, "the ep0_controller have no req\n"); in ep0_txcomplete()
1341 static int ep0_txframe_handle(struct qe_ep *ep) in ep0_txframe_handle() argument
1344 if (frame_get_status(ep->txframe) & FRAME_ERROR) { in ep0_txframe_handle()
1345 qe_ep_flushtxfifo(ep); in ep0_txframe_handle()
1346 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep0_txframe_handle()
1347 if (frame_get_info(ep->txframe) & PID_DATA0) in ep0_txframe_handle()
1348 ep->data01 = 0; in ep0_txframe_handle()
1350 ep->data01 = 1; in ep0_txframe_handle()
1352 ep0_txcomplete(ep, 1); in ep0_txframe_handle()
1354 ep0_txcomplete(ep, 0); in ep0_txframe_handle()
1356 frame_create_tx(ep, ep->txframe); in ep0_txframe_handle()
1360 static int qe_ep0_txconf(struct qe_ep *ep) in qe_ep0_txconf() argument
1366 bd = ep->c_txbd; in qe_ep0_txconf()
1369 pframe = ep->txframe; in qe_ep0_txconf()
1375 ep->c_txbd = ep->txbase; in qe_ep0_txconf()
1377 ep->c_txbd++; in qe_ep0_txconf()
1379 if (ep->c_txbd == ep->n_txbd) { in qe_ep0_txconf()
1387 ep0_txframe_handle(ep); in qe_ep0_txconf()
1390 bd = ep->c_txbd; in qe_ep0_txconf()
1397 static int ep_txframe_handle(struct qe_ep *ep) in ep_txframe_handle() argument
1399 if (frame_get_status(ep->txframe) & FRAME_ERROR) { in ep_txframe_handle()
1400 qe_ep_flushtxfifo(ep); in ep_txframe_handle()
1401 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep_txframe_handle()
1402 if (frame_get_info(ep->txframe) & PID_DATA0) in ep_txframe_handle()
1403 ep->data01 = 0; in ep_txframe_handle()
1405 ep->data01 = 1; in ep_txframe_handle()
1407 txcomplete(ep, 1); in ep_txframe_handle()
1409 txcomplete(ep, 0); in ep_txframe_handle()
1411 frame_create_tx(ep, ep->txframe); /* send the data */ in ep_txframe_handle()
1416 static int qe_ep_txconf(struct qe_ep *ep) in qe_ep_txconf() argument
1423 bd = ep->c_txbd; in qe_ep_txconf()
1426 pframe = ep->txframe; in qe_ep_txconf()
1439 ep->c_txbd = ep->txbase; in qe_ep_txconf()
1441 ep->c_txbd++; in qe_ep_txconf()
1444 ep_txframe_handle(ep); in qe_ep_txconf()
1445 bd = ep->c_txbd; in qe_ep_txconf()
1455 static int ep_req_send(struct qe_ep *ep, struct qe_req *req) in ep_req_send() argument
1459 if (ep->tx_req == NULL) { in ep_req_send()
1460 ep->sent = 0; in ep_req_send()
1461 ep->last = 0; in ep_req_send()
1462 txcomplete(ep, 0); /* can gain a new tx_req */ in ep_req_send()
1463 reval = frame_create_tx(ep, ep->txframe); in ep_req_send()
1469 static int ep_req_rx(struct qe_ep *ep, struct qe_req *req) in ep_req_rx() argument
1471 struct qe_udc *udc = ep->udc; in ep_req_rx()
1480 if (list_empty(&ep->queue)) { in ep_req_rx()
1484 pframe = ep->rxframe; in ep_req_rx()
1486 bd = ep->n_rxbd; in ep_req_rx()
1513 if (framepid != ep->data01) { in ep_req_rx()
1522 if ((fsize < ep->ep.maxpacket) in ep_req_rx()
1526 done(ep, req, 0); in ep_req_rx()
1527 if (list_empty(&ep->queue)) in ep_req_rx()
1528 qe_eprx_nack(ep); in ep_req_rx()
1531 qe_ep_toggledata01(ep); in ep_req_rx()
1540 ep->has_data--; in ep_req_rx()
1544 bd = ep->rxbase; in ep_req_rx()
1552 ep->n_rxbd = bd; in ep_req_rx()
1553 ep_recycle_rxbds(ep); in ep_req_rx()
1559 static int ep_req_receive(struct qe_ep *ep, struct qe_req *req) in ep_req_receive() argument
1561 if (ep->state == EP_STATE_NACK) { in ep_req_receive()
1562 if (ep->has_data <= 0) { in ep_req_receive()
1564 qe_eprx_normal(ep); in ep_req_receive()
1567 ep_req_rx(ep, req); in ep_req_receive()
1585 struct qe_ep *ep; in qe_ep_enable() local
1589 ep = container_of(_ep, struct qe_ep, ep); in qe_ep_enable()
1596 udc = ep->udc; in qe_ep_enable()
1604 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_ep_enable()
1605 dev_dbg(udc->dev, "enable ep%d failed\n", ep->epnum); in qe_ep_enable()
1608 dev_dbg(udc->dev, "enable ep%d successful\n", ep->epnum); in qe_ep_enable()
1615 struct qe_ep *ep; in qe_ep_disable() local
1619 ep = container_of(_ep, struct qe_ep, ep); in qe_ep_disable()
1620 udc = ep->udc; in qe_ep_disable()
1622 if (!_ep || !ep->ep.desc) { in qe_ep_disable()
1623 dev_dbg(udc->dev, "%s not enabled\n", _ep ? ep->ep.name : NULL); in qe_ep_disable()
1629 nuke(ep, -ESHUTDOWN); in qe_ep_disable()
1630 ep->ep.desc = NULL; in qe_ep_disable()
1631 ep->stopped = 1; in qe_ep_disable()
1632 ep->tx_req = NULL; in qe_ep_disable()
1633 qe_ep_reset(udc, ep->epnum); in qe_ep_disable()
1636 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_ep_disable()
1638 if (ep->dir == USB_DIR_OUT) in qe_ep_disable()
1639 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * in qe_ep_disable()
1642 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * in qe_ep_disable()
1645 if (ep->dir != USB_DIR_IN) { in qe_ep_disable()
1646 kfree(ep->rxframe); in qe_ep_disable()
1647 if (ep->rxbufmap) { in qe_ep_disable()
1649 ep->rxbuf_d, size, in qe_ep_disable()
1651 ep->rxbuf_d = DMA_ADDR_INVALID; in qe_ep_disable()
1655 ep->rxbuf_d, size, in qe_ep_disable()
1658 kfree(ep->rxbuffer); in qe_ep_disable()
1661 if (ep->dir != USB_DIR_OUT) in qe_ep_disable()
1662 kfree(ep->txframe); in qe_ep_disable()
1695 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); in __qe_ep_queue() local
1700 udc = ep->udc; in __qe_ep_queue()
1707 if (!_ep || (!ep->ep.desc && ep_index(ep))) { in __qe_ep_queue()
1715 req->ep = ep; in __qe_ep_queue()
1719 req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1722 ep_is_in(ep) in __qe_ep_queue()
1727 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1729 ep_is_in(ep) in __qe_ep_queue()
1738 list_add_tail(&req->queue, &ep->queue); in __qe_ep_queue()
1740 ep->name, req->req.length); in __qe_ep_queue()
1743 if (ep_is_in(ep)) in __qe_ep_queue()
1744 reval = ep_req_send(ep, req); in __qe_ep_queue()
1747 if (ep_index(ep) == 0 && req->req.length > 0) { in __qe_ep_queue()
1748 if (ep_is_in(ep)) in __qe_ep_queue()
1754 if (ep->dir == USB_DIR_OUT) in __qe_ep_queue()
1755 reval = ep_req_receive(ep, req); in __qe_ep_queue()
1764 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); in qe_ep_queue() local
1765 struct qe_udc *udc = ep->udc; in qe_ep_queue()
1778 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); in qe_ep_dequeue() local
1785 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_dequeue()
1788 list_for_each_entry(req, &ep->queue, queue) { in qe_ep_dequeue()
1794 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1798 done(ep, req, -ECONNRESET); in qe_ep_dequeue()
1800 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1812 struct qe_ep *ep; in qe_ep_set_halt() local
1817 ep = container_of(_ep, struct qe_ep, ep); in qe_ep_set_halt()
1818 if (!_ep || !ep->ep.desc) { in qe_ep_set_halt()
1823 udc = ep->udc; in qe_ep_set_halt()
1826 if (value && ep_is_in(ep) && !list_empty(&ep->queue)) { in qe_ep_set_halt()
1832 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_set_halt()
1833 qe_eptx_stall_change(ep, value); in qe_ep_set_halt()
1834 qe_eprx_stall_change(ep, value); in qe_ep_set_halt()
1835 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_set_halt()
1837 if (ep->epnum == 0) { in qe_ep_set_halt()
1844 ep->data01 = 0; in qe_ep_set_halt()
1846 dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, in qe_ep_set_halt()
1897 struct qe_ep *ep = &udc->eps[pipe]; in udc_reset_ep_queue() local
1899 nuke(ep, -ECONNRESET); in udc_reset_ep_queue()
1900 ep->tx_req = NULL; in udc_reset_ep_queue()
1945 struct qe_ep *ep; in ch9getstatus() local
1948 ep = &udc->eps[0]; in ch9getstatus()
1963 if (!target_ep->ep.desc) in ch9getstatus()
1980 req = container_of(qe_alloc_request(&ep->ep, GFP_KERNEL), in ch9getstatus()
1992 status = __qe_ep_queue(&ep->ep, &req->req); in ch9getstatus()
2046 struct qe_ep *ep; in setup_received_handle() local
2051 ep = &udc->eps[pipe]; in setup_received_handle()
2054 qe_ep_set_halt(&ep->ep, in setup_received_handle()
2167 struct qe_ep *ep; in tx_irq() local
2176 ep = &udc->eps[i]; in tx_irq()
2177 if (ep && ep->init && (ep->dir != USB_DIR_OUT)) { in tx_irq()
2178 bd = ep->c_txbd; in tx_irq()
2182 if (ep->epnum == 0) in tx_irq()
2183 res = qe_ep0_txconf(ep); in tx_irq()
2185 res = qe_ep_txconf(ep); in tx_irq()
2196 struct qe_ep *ep; in rx_irq() local
2201 ep = &udc->eps[i]; in rx_irq()
2202 if (ep && ep->init && (ep->dir != USB_DIR_IN)) { in rx_irq()
2203 bd = ep->n_rxbd; in rx_irq()
2206 if (ep->epnum == 0) { in rx_irq()
2210 qe_ep_rx(ep); in rx_irq()
2322 list_for_each_entry(loop_ep, &udc->gadget.ep_list, ep.ep_list) in fsl_qe_stop()
2405 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_config() local
2407 ep->udc = udc; in qe_ep_config()
2408 strcpy(ep->name, ep_name[pipe_num]); in qe_ep_config()
2409 ep->ep.name = ep_name[pipe_num]; in qe_ep_config()
2412 ep->ep.caps.type_control = true; in qe_ep_config()
2414 ep->ep.caps.type_iso = true; in qe_ep_config()
2415 ep->ep.caps.type_bulk = true; in qe_ep_config()
2416 ep->ep.caps.type_int = true; in qe_ep_config()
2419 ep->ep.caps.dir_in = true; in qe_ep_config()
2420 ep->ep.caps.dir_out = true; in qe_ep_config()
2422 ep->ep.ops = &qe_ep_ops; in qe_ep_config()
2423 ep->stopped = 1; in qe_ep_config()
2424 usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); in qe_ep_config()
2425 ep->ep.desc = NULL; in qe_ep_config()
2426 ep->dir = 0xff; in qe_ep_config()
2427 ep->epnum = (u8)pipe_num; in qe_ep_config()
2428 ep->sent = 0; in qe_ep_config()
2429 ep->last = 0; in qe_ep_config()
2430 ep->init = 0; in qe_ep_config()
2431 ep->rxframe = NULL; in qe_ep_config()
2432 ep->txframe = NULL; in qe_ep_config()
2433 ep->tx_req = NULL; in qe_ep_config()
2434 ep->state = EP_STATE_IDLE; in qe_ep_config()
2435 ep->has_data = 0; in qe_ep_config()
2438 INIT_LIST_HEAD(&ep->queue); in qe_ep_config()
2442 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in qe_ep_config()
2444 ep->gadget = &udc->gadget; in qe_ep_config()
2472 struct qe_ep *ep; in qe_udc_probe() local
2508 udc->gadget.ep0 = &udc->eps[0].ep; in qe_udc_probe()
2605 ep = &udc->eps[0]; in qe_udc_probe()
2606 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_udc_probe()
2607 kfree(ep->rxframe); in qe_udc_probe()
2608 kfree(ep->rxbuffer); in qe_udc_probe()
2609 kfree(ep->txframe); in qe_udc_probe()
2632 struct qe_ep *ep; in qe_udc_remove() local
2652 ep = &udc->eps[0]; in qe_udc_remove()
2653 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_udc_remove()
2654 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (USB_BDRING_LEN + 1); in qe_udc_remove()
2656 kfree(ep->rxframe); in qe_udc_remove()
2657 if (ep->rxbufmap) { in qe_udc_remove()
2659 ep->rxbuf_d, size, in qe_udc_remove()
2661 ep->rxbuf_d = DMA_ADDR_INVALID; in qe_udc_remove()
2664 ep->rxbuf_d, size, in qe_udc_remove()
2668 kfree(ep->rxbuffer); in qe_udc_remove()
2669 kfree(ep->txframe); in qe_udc_remove()