Lines Matching refs:ep
80 static void done(struct qe_ep *ep, struct qe_req *req, int status) in done() argument
82 struct qe_udc *udc = ep->udc; in done()
83 unsigned char stopped = ep->stopped; in done()
100 ep_is_in(ep) in done()
108 ep_is_in(ep) in done()
114 ep->ep.name, &req->req, status, in done()
118 ep->stopped = 1; in done()
121 usb_gadget_giveback_request(&ep->ep, &req->req); in done()
125 ep->stopped = stopped; in done()
131 static void nuke(struct qe_ep *ep, int status) in nuke() argument
134 while (!list_empty(&ep->queue)) { in nuke()
136 req = list_entry(ep->queue.next, struct qe_req, queue); in nuke()
138 done(ep, req, status); in nuke()
146 static int qe_eprx_stall_change(struct qe_ep *ep, int value) in qe_eprx_stall_change() argument
149 u8 epnum = ep->epnum; in qe_eprx_stall_change()
150 struct qe_udc *udc = ep->udc; in qe_eprx_stall_change()
156 else if (ep->dir == USB_DIR_IN) in qe_eprx_stall_change()
163 static int qe_eptx_stall_change(struct qe_ep *ep, int value) in qe_eptx_stall_change() argument
166 u8 epnum = ep->epnum; in qe_eptx_stall_change()
167 struct qe_udc *udc = ep->udc; in qe_eptx_stall_change()
173 else if (ep->dir == USB_DIR_OUT) in qe_eptx_stall_change()
190 static int qe_eprx_nack(struct qe_ep *ep) in qe_eprx_nack() argument
192 u8 epnum = ep->epnum; in qe_eprx_nack()
193 struct qe_udc *udc = ep->udc; in qe_eprx_nack()
195 if (ep->state == EP_STATE_IDLE) { in qe_eprx_nack()
204 ep->state = EP_STATE_NACK; in qe_eprx_nack()
209 static int qe_eprx_normal(struct qe_ep *ep) in qe_eprx_normal() argument
211 struct qe_udc *udc = ep->udc; in qe_eprx_normal()
213 if (ep->state == EP_STATE_NACK) { in qe_eprx_normal()
214 clrsetbits_be16(&udc->usb_regs->usb_usep[ep->epnum], in qe_eprx_normal()
223 ep->state = EP_STATE_IDLE; in qe_eprx_normal()
224 ep->has_data = 0; in qe_eprx_normal()
230 static int qe_ep_cmd_stoptx(struct qe_ep *ep) in qe_ep_cmd_stoptx() argument
232 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_stoptx()
233 cpm_command(CPM_USB_STOP_TX | (ep->epnum << CPM_USB_EP_SHIFT), in qe_ep_cmd_stoptx()
237 ep->epnum, 0); in qe_ep_cmd_stoptx()
242 static int qe_ep_cmd_restarttx(struct qe_ep *ep) in qe_ep_cmd_restarttx() argument
244 if (ep->udc->soc_type == PORT_CPM) in qe_ep_cmd_restarttx()
245 cpm_command(CPM_USB_RESTART_TX | (ep->epnum << in qe_ep_cmd_restarttx()
249 ep->epnum, 0); in qe_ep_cmd_restarttx()
254 static int qe_ep_flushtxfifo(struct qe_ep *ep) in qe_ep_flushtxfifo() argument
256 struct qe_udc *udc = ep->udc; in qe_ep_flushtxfifo()
259 i = (int)ep->epnum; in qe_ep_flushtxfifo()
261 qe_ep_cmd_stoptx(ep); in qe_ep_flushtxfifo()
263 USB_CMD_FLUSH_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); in qe_ep_flushtxfifo()
268 ep->c_txbd = ep->txbase; in qe_ep_flushtxfifo()
269 ep->n_txbd = ep->txbase; in qe_ep_flushtxfifo()
270 qe_ep_cmd_restarttx(ep); in qe_ep_flushtxfifo()
274 static int qe_ep_filltxfifo(struct qe_ep *ep) in qe_ep_filltxfifo() argument
276 struct qe_udc *udc = ep->udc; in qe_ep_filltxfifo()
279 USB_CMD_STR_FIFO | (USB_CMD_EP_MASK & (ep->epnum))); in qe_ep_filltxfifo()
285 struct qe_ep *ep; in qe_epbds_reset() local
290 ep = &udc->eps[pipe_num]; in qe_epbds_reset()
292 if (ep->dir == USB_DIR_OUT) in qe_epbds_reset()
297 bd = ep->rxbase; in qe_epbds_reset()
304 bd = ep->txbase; in qe_epbds_reset()
317 struct qe_ep *ep; in qe_ep_reset() local
320 ep = &udc->eps[pipe_num]; in qe_ep_reset()
324 switch (ep->dir) { in qe_ep_reset()
326 qe_ep_flushtxfifo(ep); in qe_ep_reset()
332 qe_ep_flushtxfifo(ep); in qe_ep_reset()
345 static int qe_ep_toggledata01(struct qe_ep *ep) in qe_ep_toggledata01() argument
347 ep->data01 ^= 0x1; in qe_ep_toggledata01()
353 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_bd_init() local
360 if (ep->dir == USB_DIR_OUT) in qe_ep_bd_init()
379 ep->rxbase = cpm_muram_addr(tmp_addr); in qe_ep_bd_init()
380 ep->txbase = cpm_muram_addr(tmp_addr + (sizeof(struct qe_bd) in qe_ep_bd_init()
382 ep->n_rxbd = ep->rxbase; in qe_ep_bd_init()
383 ep->e_rxbd = ep->rxbase; in qe_ep_bd_init()
384 ep->n_txbd = ep->txbase; in qe_ep_bd_init()
385 ep->c_txbd = ep->txbase; in qe_ep_bd_init()
386 ep->data01 = 0; /* data0 */ in qe_ep_bd_init()
389 bd = ep->rxbase; in qe_ep_bd_init()
398 bd = ep->txbase; in qe_ep_bd_init()
410 static int qe_ep_rxbd_update(struct qe_ep *ep) in qe_ep_rxbd_update() argument
418 if (ep->rxbase == NULL) in qe_ep_rxbd_update()
421 bd = ep->rxbase; in qe_ep_rxbd_update()
423 ep->rxframe = kmalloc(sizeof(*ep->rxframe), GFP_ATOMIC); in qe_ep_rxbd_update()
424 if (ep->rxframe == NULL) { in qe_ep_rxbd_update()
425 dev_err(ep->udc->dev, "malloc rxframe failed\n"); in qe_ep_rxbd_update()
429 qe_frame_init(ep->rxframe); in qe_ep_rxbd_update()
431 if (ep->dir == USB_DIR_OUT) in qe_ep_rxbd_update()
436 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (bdring_len + 1); in qe_ep_rxbd_update()
437 ep->rxbuffer = kzalloc(size, GFP_ATOMIC); in qe_ep_rxbd_update()
438 if (ep->rxbuffer == NULL) { in qe_ep_rxbd_update()
439 dev_err(ep->udc->dev, "malloc rxbuffer failed,size=%d\n", in qe_ep_rxbd_update()
441 kfree(ep->rxframe); in qe_ep_rxbd_update()
445 ep->rxbuf_d = virt_to_phys((void *)ep->rxbuffer); in qe_ep_rxbd_update()
446 if (ep->rxbuf_d == DMA_ADDR_INVALID) { in qe_ep_rxbd_update()
447 ep->rxbuf_d = dma_map_single(ep->udc->gadget.dev.parent, in qe_ep_rxbd_update()
448 ep->rxbuffer, in qe_ep_rxbd_update()
451 ep->rxbufmap = 1; in qe_ep_rxbd_update()
453 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in qe_ep_rxbd_update()
454 ep->rxbuf_d, size, in qe_ep_rxbd_update()
456 ep->rxbufmap = 0; in qe_ep_rxbd_update()
459 size = ep->ep.maxpacket + USB_CRC_SIZE + 2; in qe_ep_rxbd_update()
460 tmp = ep->rxbuf_d; in qe_ep_rxbd_update()
477 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_register_init() local
486 logepnum = (ep->ep.desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); in qe_ep_register_init()
489 switch (ep->ep.desc->bmAttributes & 0x03) { in qe_ep_register_init()
504 switch (ep->dir) { in qe_ep_register_init()
520 tmp = (u16)(ep->ep.maxpacket + USB_CRC_SIZE); in qe_ep_register_init()
532 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_init() local
545 if (strstr(ep->ep.name, "-iso") in qe_ep_init()
546 || strstr(ep->ep.name, "-int")) in qe_ep_init()
567 if (strstr(ep->ep.name, "-iso")) /* bulk is ok */ in qe_ep_init()
583 if (strstr(ep->ep.name, "-bulk") in qe_ep_init()
584 || strstr(ep->ep.name, "-int")) in qe_ep_init()
598 if (strstr(ep->ep.name, "-iso") in qe_ep_init()
599 || strstr(ep->ep.name, "-int")) in qe_ep_init()
639 ep->ep.maxpacket = max; in qe_ep_init()
640 ep->tm = (u8)(desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); in qe_ep_init()
641 ep->ep.desc = desc; in qe_ep_init()
642 ep->stopped = 0; in qe_ep_init()
643 ep->init = 1; in qe_ep_init()
646 ep->dir = USB_DIR_BOTH; in qe_ep_init()
652 ep->dir = USB_DIR_OUT; in qe_ep_init()
655 ep->dir = USB_DIR_IN; in qe_ep_init()
663 if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_OUT)) { in qe_ep_init()
664 reval = qe_ep_rxbd_update(ep); in qe_ep_init()
669 if ((ep->tm == USBP_TM_CTL) || (ep->dir == USB_DIR_IN)) { in qe_ep_init()
670 ep->txframe = kmalloc(sizeof(*ep->txframe), GFP_ATOMIC); in qe_ep_init()
671 if (ep->txframe == NULL) { in qe_ep_init()
675 qe_frame_init(ep->txframe); in qe_ep_init()
686 kfree(ep->rxbuffer); in qe_ep_init()
687 kfree(ep->rxframe); in qe_ep_init()
691 dev_err(udc->dev, "failed to initialize %s\n", ep->ep.name); in qe_ep_init()
713 static void recycle_one_rxbd(struct qe_ep *ep) in recycle_one_rxbd() argument
717 bdstatus = in_be32((u32 __iomem *)ep->e_rxbd); in recycle_one_rxbd()
719 out_be32((u32 __iomem *)ep->e_rxbd, bdstatus); in recycle_one_rxbd()
722 ep->e_rxbd = ep->rxbase; in recycle_one_rxbd()
724 ep->e_rxbd++; in recycle_one_rxbd()
727 static void recycle_rxbds(struct qe_ep *ep, unsigned char stopatnext) in recycle_rxbds() argument
733 nextbd = ep->n_rxbd; in recycle_rxbds()
734 bd = ep->e_rxbd; in recycle_rxbds()
742 bd = ep->rxbase; in recycle_rxbds()
751 ep->e_rxbd = bd; in recycle_rxbds()
754 static void ep_recycle_rxbds(struct qe_ep *ep) in ep_recycle_rxbds() argument
756 struct qe_bd __iomem *bd = ep->n_rxbd; in ep_recycle_rxbds()
758 u8 epnum = ep->epnum; in ep_recycle_rxbds()
759 struct qe_udc *udc = ep->udc; in ep_recycle_rxbds()
763 bd = ep->rxbase + in ep_recycle_rxbds()
770 bd = ep->rxbase; in ep_recycle_rxbds()
774 ep->e_rxbd = bd; in ep_recycle_rxbds()
775 recycle_rxbds(ep, 0); in ep_recycle_rxbds()
776 ep->e_rxbd = ep->n_rxbd; in ep_recycle_rxbds()
778 recycle_rxbds(ep, 1); in ep_recycle_rxbds()
783 if (ep->has_data <= 0 && (!list_empty(&ep->queue))) in ep_recycle_rxbds()
784 qe_eprx_normal(ep); in ep_recycle_rxbds()
786 ep->localnack = 0; in ep_recycle_rxbds()
791 static int qe_ep_rxframe_handle(struct qe_ep *ep);
796 struct qe_ep *ep = &udc->eps[0]; in ep0_setup_handle() local
801 pframe = ep->rxframe; in ep0_setup_handle()
809 ep->data01 = 1; in ep0_setup_handle()
820 struct qe_ep *ep = &udc->eps[0]; in qe_ep0_rx() local
826 pframe = ep->rxframe; in qe_ep0_rx()
828 if (ep->dir == USB_DIR_IN) { in qe_ep0_rx()
833 bd = ep->n_rxbd; in qe_ep0_rx()
866 qe_ep_rxframe_handle(ep); in qe_ep0_rx()
873 recycle_one_rxbd(ep); in qe_ep0_rx()
877 bd = ep->rxbase; in qe_ep0_rx()
886 ep->n_rxbd = bd; in qe_ep0_rx()
891 static int qe_ep_rxframe_handle(struct qe_ep *ep) in qe_ep_rxframe_handle() argument
899 pframe = ep->rxframe; in qe_ep_rxframe_handle()
904 if (framepid != ep->data01) { in qe_ep_rxframe_handle()
905 dev_err(ep->udc->dev, "the data01 error!\n"); in qe_ep_rxframe_handle()
910 if (list_empty(&ep->queue)) { in qe_ep_rxframe_handle()
911 dev_err(ep->udc->dev, "the %s have no requeue!\n", ep->name); in qe_ep_rxframe_handle()
913 req = list_entry(ep->queue.next, struct qe_req, queue); in qe_ep_rxframe_handle()
919 if ((fsize < ep->ep.maxpacket) || in qe_ep_rxframe_handle()
921 if (ep->epnum == 0) in qe_ep_rxframe_handle()
922 ep0_req_complete(ep->udc, req); in qe_ep_rxframe_handle()
924 done(ep, req, 0); in qe_ep_rxframe_handle()
925 if (list_empty(&ep->queue) && ep->epnum != 0) in qe_ep_rxframe_handle()
926 qe_eprx_nack(ep); in qe_ep_rxframe_handle()
931 qe_ep_toggledata01(ep); in qe_ep_rxframe_handle()
939 struct qe_ep *ep; in ep_rx_tasklet() local
949 ep = &udc->eps[i]; in ep_rx_tasklet()
951 if (ep->dir == USB_DIR_IN || ep->enable_tasklet == 0) { in ep_rx_tasklet()
957 pframe = ep->rxframe; in ep_rx_tasklet()
958 bd = ep->n_rxbd; in ep_rx_tasklet()
963 if (list_empty(&ep->queue)) { in ep_rx_tasklet()
964 qe_eprx_nack(ep); in ep_rx_tasklet()
967 ep->has_data); in ep_rx_tasklet()
991 qe_ep_rxframe_handle(ep); in ep_rx_tasklet()
999 ep->has_data--; in ep_rx_tasklet()
1000 if (!(ep->localnack)) in ep_rx_tasklet()
1001 recycle_one_rxbd(ep); in ep_rx_tasklet()
1005 bd = ep->rxbase; in ep_rx_tasklet()
1013 ep->n_rxbd = bd; in ep_rx_tasklet()
1015 if (ep->localnack) in ep_rx_tasklet()
1016 ep_recycle_rxbds(ep); in ep_rx_tasklet()
1018 ep->enable_tasklet = 0; in ep_rx_tasklet()
1024 static int qe_ep_rx(struct qe_ep *ep) in qe_ep_rx() argument
1031 udc = ep->udc; in qe_ep_rx()
1032 pframe = ep->rxframe; in qe_ep_rx()
1034 if (ep->dir == USB_DIR_IN) { in qe_ep_rx()
1039 bd = ep->n_rxbd; in qe_ep_rx()
1041 swoffs = (u16)(bd - ep->rxbase); in qe_ep_rx()
1042 ucoffs = (u16)((in_be16(&udc->ep_param[ep->epnum]->rbptr) - in qe_ep_rx()
1043 in_be16(&udc->ep_param[ep->epnum]->rbase)) >> 3); in qe_ep_rx()
1050 qe_eprx_nack(ep); in qe_ep_rx()
1051 ep->localnack = 1; in qe_ep_rx()
1054 ep->has_data = USB_BDRING_LEN_RX - emptybds; in qe_ep_rx()
1056 if (list_empty(&ep->queue)) { in qe_ep_rx()
1057 qe_eprx_nack(ep); in qe_ep_rx()
1059 ep->has_data); in qe_ep_rx()
1064 ep->enable_tasklet = 1; in qe_ep_rx()
1070 static int qe_ep_tx(struct qe_ep *ep, struct qe_frame *frame) in qe_ep_tx() argument
1072 struct qe_udc *udc = ep->udc; in qe_ep_tx()
1078 if (ep->dir == USB_DIR_OUT) { in qe_ep_tx()
1088 bd = ep->n_txbd; in qe_ep_tx()
1108 if ((ep->epnum == 0) && (udc->ep0_state == DATA_STATE_NEED_ZLP)) in qe_ep_tx()
1109 ep->data01 = 0x1; in qe_ep_tx()
1111 if (ep->data01) { in qe_ep_tx()
1121 qe_ep_filltxfifo(ep); in qe_ep_tx()
1126 qe_ep_toggledata01(ep); in qe_ep_tx()
1128 ep->n_txbd = ep->txbase; in qe_ep_tx()
1130 ep->n_txbd++; in qe_ep_tx()
1142 static int txcomplete(struct qe_ep *ep, unsigned char restart) in txcomplete() argument
1144 if (ep->tx_req != NULL) { in txcomplete()
1145 struct qe_req *req = ep->tx_req; in txcomplete()
1148 last_len = min_t(unsigned, req->req.length - ep->sent, in txcomplete()
1149 ep->ep.maxpacket); in txcomplete()
1152 int asent = ep->last; in txcomplete()
1153 ep->sent += asent; in txcomplete()
1154 ep->last -= asent; in txcomplete()
1156 ep->last = 0; in txcomplete()
1162 (req->req.length % ep->ep.maxpacket) != 0) in txcomplete()
1170 if (((ep->tx_req->req.length - ep->sent) <= 0) && !zlp) { in txcomplete()
1171 done(ep, ep->tx_req, 0); in txcomplete()
1172 ep->tx_req = NULL; in txcomplete()
1173 ep->last = 0; in txcomplete()
1174 ep->sent = 0; in txcomplete()
1179 if (ep->tx_req == NULL) { in txcomplete()
1180 if (!list_empty(&ep->queue)) { in txcomplete()
1181 ep->tx_req = list_entry(ep->queue.next, struct qe_req, in txcomplete()
1183 ep->last = 0; in txcomplete()
1184 ep->sent = 0; in txcomplete()
1192 static int qe_usb_senddata(struct qe_ep *ep, struct qe_frame *frame) in qe_usb_senddata() argument
1198 size = min_t(u32, (ep->tx_req->req.length - ep->sent), in qe_usb_senddata()
1199 ep->ep.maxpacket); in qe_usb_senddata()
1200 buf = (u8 *)ep->tx_req->req.buf + ep->sent; in qe_usb_senddata()
1202 ep->last = size; in qe_usb_senddata()
1203 ep->tx_req->req.actual += size; in qe_usb_senddata()
1208 return qe_ep_tx(ep, frame); in qe_usb_senddata()
1214 static int sendnulldata(struct qe_ep *ep, struct qe_frame *frame, uint infor) in sendnulldata() argument
1216 struct qe_udc *udc = ep->udc; in sendnulldata()
1227 return qe_ep_tx(ep, frame); in sendnulldata()
1230 static int frame_create_tx(struct qe_ep *ep, struct qe_frame *frame) in frame_create_tx() argument
1232 struct qe_req *req = ep->tx_req; in frame_create_tx()
1238 if ((req->req.length - ep->sent) > 0) in frame_create_tx()
1239 reval = qe_usb_senddata(ep, frame); in frame_create_tx()
1241 reval = sendnulldata(ep, frame, 0); in frame_create_tx()
1252 struct qe_ep *ep = &udc->eps[0]; in ep0_prime_status() local
1257 sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); in ep0_prime_status()
1269 struct qe_ep *ep = &udc->eps[0]; in ep0_req_complete() local
1274 done(ep, req, 0); in ep0_req_complete()
1281 done(ep, req, 0); in ep0_req_complete()
1286 done(ep, req, 0); in ep0_req_complete()
1293 done(ep, req, 0); in ep0_req_complete()
1307 static int ep0_txcomplete(struct qe_ep *ep, unsigned char restart) in ep0_txcomplete() argument
1310 struct qe_frame *frame = ep->txframe; in ep0_txcomplete()
1314 ep->udc->ep0_state = WAIT_FOR_SETUP; in ep0_txcomplete()
1316 sendnulldata(ep, ep->txframe, SETUP_STATUS | NO_REQ); in ep0_txcomplete()
1320 tx_req = ep->tx_req; in ep0_txcomplete()
1323 int asent = ep->last; in ep0_txcomplete()
1324 ep->sent += asent; in ep0_txcomplete()
1325 ep->last -= asent; in ep0_txcomplete()
1327 ep->last = 0; in ep0_txcomplete()
1331 if ((ep->tx_req->req.length - ep->sent) <= 0) { in ep0_txcomplete()
1332 ep->tx_req->req.actual = (unsigned int)ep->sent; in ep0_txcomplete()
1333 ep0_req_complete(ep->udc, ep->tx_req); in ep0_txcomplete()
1334 ep->tx_req = NULL; in ep0_txcomplete()
1335 ep->last = 0; in ep0_txcomplete()
1336 ep->sent = 0; in ep0_txcomplete()
1339 dev_vdbg(ep->udc->dev, "the ep0_controller have no req\n"); in ep0_txcomplete()
1345 static int ep0_txframe_handle(struct qe_ep *ep) in ep0_txframe_handle() argument
1348 if (frame_get_status(ep->txframe) & FRAME_ERROR) { in ep0_txframe_handle()
1349 qe_ep_flushtxfifo(ep); in ep0_txframe_handle()
1350 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep0_txframe_handle()
1351 if (frame_get_info(ep->txframe) & PID_DATA0) in ep0_txframe_handle()
1352 ep->data01 = 0; in ep0_txframe_handle()
1354 ep->data01 = 1; in ep0_txframe_handle()
1356 ep0_txcomplete(ep, 1); in ep0_txframe_handle()
1358 ep0_txcomplete(ep, 0); in ep0_txframe_handle()
1360 frame_create_tx(ep, ep->txframe); in ep0_txframe_handle()
1364 static int qe_ep0_txconf(struct qe_ep *ep) in qe_ep0_txconf() argument
1370 bd = ep->c_txbd; in qe_ep0_txconf()
1373 pframe = ep->txframe; in qe_ep0_txconf()
1379 ep->c_txbd = ep->txbase; in qe_ep0_txconf()
1381 ep->c_txbd++; in qe_ep0_txconf()
1383 if (ep->c_txbd == ep->n_txbd) { in qe_ep0_txconf()
1391 ep0_txframe_handle(ep); in qe_ep0_txconf()
1394 bd = ep->c_txbd; in qe_ep0_txconf()
1401 static int ep_txframe_handle(struct qe_ep *ep) in ep_txframe_handle() argument
1403 if (frame_get_status(ep->txframe) & FRAME_ERROR) { in ep_txframe_handle()
1404 qe_ep_flushtxfifo(ep); in ep_txframe_handle()
1405 dev_vdbg(ep->udc->dev, "The EP0 transmit data have error!\n"); in ep_txframe_handle()
1406 if (frame_get_info(ep->txframe) & PID_DATA0) in ep_txframe_handle()
1407 ep->data01 = 0; in ep_txframe_handle()
1409 ep->data01 = 1; in ep_txframe_handle()
1411 txcomplete(ep, 1); in ep_txframe_handle()
1413 txcomplete(ep, 0); in ep_txframe_handle()
1415 frame_create_tx(ep, ep->txframe); /* send the data */ in ep_txframe_handle()
1420 static int qe_ep_txconf(struct qe_ep *ep) in qe_ep_txconf() argument
1427 bd = ep->c_txbd; in qe_ep_txconf()
1430 pframe = ep->txframe; in qe_ep_txconf()
1443 ep->c_txbd = ep->txbase; in qe_ep_txconf()
1445 ep->c_txbd++; in qe_ep_txconf()
1448 ep_txframe_handle(ep); in qe_ep_txconf()
1449 bd = ep->c_txbd; in qe_ep_txconf()
1459 static int ep_req_send(struct qe_ep *ep, struct qe_req *req) in ep_req_send() argument
1463 if (ep->tx_req == NULL) { in ep_req_send()
1464 ep->sent = 0; in ep_req_send()
1465 ep->last = 0; in ep_req_send()
1466 txcomplete(ep, 0); /* can gain a new tx_req */ in ep_req_send()
1467 reval = frame_create_tx(ep, ep->txframe); in ep_req_send()
1473 static int ep_req_rx(struct qe_ep *ep, struct qe_req *req) in ep_req_rx() argument
1475 struct qe_udc *udc = ep->udc; in ep_req_rx()
1484 if (list_empty(&ep->queue)) { in ep_req_rx()
1488 pframe = ep->rxframe; in ep_req_rx()
1490 bd = ep->n_rxbd; in ep_req_rx()
1517 if (framepid != ep->data01) { in ep_req_rx()
1526 if ((fsize < ep->ep.maxpacket) in ep_req_rx()
1530 done(ep, req, 0); in ep_req_rx()
1531 if (list_empty(&ep->queue)) in ep_req_rx()
1532 qe_eprx_nack(ep); in ep_req_rx()
1535 qe_ep_toggledata01(ep); in ep_req_rx()
1544 ep->has_data--; in ep_req_rx()
1548 bd = ep->rxbase; in ep_req_rx()
1556 ep->n_rxbd = bd; in ep_req_rx()
1557 ep_recycle_rxbds(ep); in ep_req_rx()
1563 static int ep_req_receive(struct qe_ep *ep, struct qe_req *req) in ep_req_receive() argument
1565 if (ep->state == EP_STATE_NACK) { in ep_req_receive()
1566 if (ep->has_data <= 0) { in ep_req_receive()
1568 qe_eprx_normal(ep); in ep_req_receive()
1571 ep_req_rx(ep, req); in ep_req_receive()
1589 struct qe_ep *ep; in qe_ep_enable() local
1593 ep = container_of(_ep, struct qe_ep, ep); in qe_ep_enable()
1600 udc = ep->udc; in qe_ep_enable()
1608 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_ep_enable()
1609 dev_dbg(udc->dev, "enable ep%d failed\n", ep->epnum); in qe_ep_enable()
1612 dev_dbg(udc->dev, "enable ep%d successful\n", ep->epnum); in qe_ep_enable()
1619 struct qe_ep *ep; in qe_ep_disable() local
1623 ep = container_of(_ep, struct qe_ep, ep); in qe_ep_disable()
1624 udc = ep->udc; in qe_ep_disable()
1626 if (!_ep || !ep->ep.desc) { in qe_ep_disable()
1627 dev_dbg(udc->dev, "%s not enabled\n", _ep ? ep->ep.name : NULL); in qe_ep_disable()
1633 nuke(ep, -ESHUTDOWN); in qe_ep_disable()
1634 ep->ep.desc = NULL; in qe_ep_disable()
1635 ep->stopped = 1; in qe_ep_disable()
1636 ep->tx_req = NULL; in qe_ep_disable()
1637 qe_ep_reset(udc, ep->epnum); in qe_ep_disable()
1640 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_ep_disable()
1642 if (ep->dir == USB_DIR_OUT) in qe_ep_disable()
1643 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * in qe_ep_disable()
1646 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * in qe_ep_disable()
1649 if (ep->dir != USB_DIR_IN) { in qe_ep_disable()
1650 kfree(ep->rxframe); in qe_ep_disable()
1651 if (ep->rxbufmap) { in qe_ep_disable()
1653 ep->rxbuf_d, size, in qe_ep_disable()
1655 ep->rxbuf_d = DMA_ADDR_INVALID; in qe_ep_disable()
1659 ep->rxbuf_d, size, in qe_ep_disable()
1662 kfree(ep->rxbuffer); in qe_ep_disable()
1665 if (ep->dir != USB_DIR_OUT) in qe_ep_disable()
1666 kfree(ep->txframe); in qe_ep_disable()
1699 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); in __qe_ep_queue() local
1704 udc = ep->udc; in __qe_ep_queue()
1711 if (!_ep || (!ep->ep.desc && ep_index(ep))) { in __qe_ep_queue()
1719 req->ep = ep; in __qe_ep_queue()
1723 req->req.dma = dma_map_single(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1726 ep_is_in(ep) in __qe_ep_queue()
1731 dma_sync_single_for_device(ep->udc->gadget.dev.parent, in __qe_ep_queue()
1733 ep_is_in(ep) in __qe_ep_queue()
1742 list_add_tail(&req->queue, &ep->queue); in __qe_ep_queue()
1744 ep->name, req->req.length); in __qe_ep_queue()
1747 if (ep_is_in(ep)) in __qe_ep_queue()
1748 reval = ep_req_send(ep, req); in __qe_ep_queue()
1751 if (ep_index(ep) == 0 && req->req.length > 0) { in __qe_ep_queue()
1752 if (ep_is_in(ep)) in __qe_ep_queue()
1758 if (ep->dir == USB_DIR_OUT) in __qe_ep_queue()
1759 reval = ep_req_receive(ep, req); in __qe_ep_queue()
1768 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); in qe_ep_queue() local
1769 struct qe_udc *udc = ep->udc; in qe_ep_queue()
1782 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); in qe_ep_dequeue() local
1789 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_dequeue()
1792 list_for_each_entry(req, &ep->queue, queue) { in qe_ep_dequeue()
1798 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1802 done(ep, req, -ECONNRESET); in qe_ep_dequeue()
1804 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_dequeue()
1816 struct qe_ep *ep; in qe_ep_set_halt() local
1821 ep = container_of(_ep, struct qe_ep, ep); in qe_ep_set_halt()
1822 if (!_ep || !ep->ep.desc) { in qe_ep_set_halt()
1827 udc = ep->udc; in qe_ep_set_halt()
1830 if (value && ep_is_in(ep) && !list_empty(&ep->queue)) { in qe_ep_set_halt()
1836 spin_lock_irqsave(&ep->udc->lock, flags); in qe_ep_set_halt()
1837 qe_eptx_stall_change(ep, value); in qe_ep_set_halt()
1838 qe_eprx_stall_change(ep, value); in qe_ep_set_halt()
1839 spin_unlock_irqrestore(&ep->udc->lock, flags); in qe_ep_set_halt()
1841 if (ep->epnum == 0) { in qe_ep_set_halt()
1848 ep->data01 = 0; in qe_ep_set_halt()
1850 dev_vdbg(udc->dev, "%s %s halt stat %d\n", ep->ep.name, in qe_ep_set_halt()
1904 struct qe_ep *ep = &udc->eps[pipe]; in udc_reset_ep_queue() local
1906 nuke(ep, -ECONNRESET); in udc_reset_ep_queue()
1907 ep->tx_req = NULL; in udc_reset_ep_queue()
1952 struct qe_ep *ep; in ch9getstatus() local
1955 ep = &udc->eps[0]; in ch9getstatus()
1970 if (!target_ep->ep.desc) in ch9getstatus()
1987 req = container_of(qe_alloc_request(&ep->ep, GFP_KERNEL), in ch9getstatus()
1999 status = __qe_ep_queue(&ep->ep, &req->req); in ch9getstatus()
2053 struct qe_ep *ep; in setup_received_handle() local
2058 ep = &udc->eps[pipe]; in setup_received_handle()
2061 qe_ep_set_halt(&ep->ep, in setup_received_handle()
2174 struct qe_ep *ep; in tx_irq() local
2183 ep = &udc->eps[i]; in tx_irq()
2184 if (ep && ep->init && (ep->dir != USB_DIR_OUT)) { in tx_irq()
2185 bd = ep->c_txbd; in tx_irq()
2189 if (ep->epnum == 0) in tx_irq()
2190 res = qe_ep0_txconf(ep); in tx_irq()
2192 res = qe_ep_txconf(ep); in tx_irq()
2203 struct qe_ep *ep; in rx_irq() local
2208 ep = &udc->eps[i]; in rx_irq()
2209 if (ep && ep->init && (ep->dir != USB_DIR_IN)) { in rx_irq()
2210 bd = ep->n_rxbd; in rx_irq()
2213 if (ep->epnum == 0) { in rx_irq()
2217 qe_ep_rx(ep); in rx_irq()
2329 list_for_each_entry(loop_ep, &udc->gadget.ep_list, ep.ep_list) in fsl_qe_stop()
2414 struct qe_ep *ep = &udc->eps[pipe_num]; in qe_ep_config() local
2416 ep->udc = udc; in qe_ep_config()
2417 strcpy(ep->name, ep_name[pipe_num]); in qe_ep_config()
2418 ep->ep.name = ep_name[pipe_num]; in qe_ep_config()
2420 ep->ep.ops = &qe_ep_ops; in qe_ep_config()
2421 ep->stopped = 1; in qe_ep_config()
2422 usb_ep_set_maxpacket_limit(&ep->ep, (unsigned short) ~0); in qe_ep_config()
2423 ep->ep.desc = NULL; in qe_ep_config()
2424 ep->dir = 0xff; in qe_ep_config()
2425 ep->epnum = (u8)pipe_num; in qe_ep_config()
2426 ep->sent = 0; in qe_ep_config()
2427 ep->last = 0; in qe_ep_config()
2428 ep->init = 0; in qe_ep_config()
2429 ep->rxframe = NULL; in qe_ep_config()
2430 ep->txframe = NULL; in qe_ep_config()
2431 ep->tx_req = NULL; in qe_ep_config()
2432 ep->state = EP_STATE_IDLE; in qe_ep_config()
2433 ep->has_data = 0; in qe_ep_config()
2436 INIT_LIST_HEAD(&ep->queue); in qe_ep_config()
2440 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in qe_ep_config()
2442 ep->gadget = &udc->gadget; in qe_ep_config()
2470 struct qe_ep *ep; in qe_udc_probe() local
2506 udc->gadget.ep0 = &udc->eps[0].ep; in qe_udc_probe()
2604 ep = &udc->eps[0]; in qe_udc_probe()
2605 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_udc_probe()
2606 kfree(ep->rxframe); in qe_udc_probe()
2607 kfree(ep->rxbuffer); in qe_udc_probe()
2608 kfree(ep->txframe); in qe_udc_probe()
2631 struct qe_ep *ep; in qe_udc_remove() local
2651 ep = &udc->eps[0]; in qe_udc_remove()
2652 cpm_muram_free(cpm_muram_offset(ep->rxbase)); in qe_udc_remove()
2653 size = (ep->ep.maxpacket + USB_CRC_SIZE + 2) * (USB_BDRING_LEN + 1); in qe_udc_remove()
2655 kfree(ep->rxframe); in qe_udc_remove()
2656 if (ep->rxbufmap) { in qe_udc_remove()
2658 ep->rxbuf_d, size, in qe_udc_remove()
2660 ep->rxbuf_d = DMA_ADDR_INVALID; in qe_udc_remove()
2663 ep->rxbuf_d, size, in qe_udc_remove()
2667 kfree(ep->rxbuffer); in qe_udc_remove()
2668 kfree(ep->txframe); in qe_udc_remove()