Lines Matching refs:ep
29 static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req) in next_fifo_transaction() argument
35 if (transaction_len > ep->ep.maxpacket) { in next_fifo_transaction()
36 transaction_len = ep->ep.maxpacket; in next_fifo_transaction()
38 } else if (transaction_len == ep->ep.maxpacket && req->req.zero) { in next_fifo_transaction()
43 ep->ep.name, req, transaction_len, in next_fifo_transaction()
46 memcpy(ep->fifo, req->req.buf + req->req.actual, transaction_len); in next_fifo_transaction()
47 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in next_fifo_transaction()
51 static void submit_request(struct usba_ep *ep, struct usba_request *req) in submit_request() argument
54 ep->ep.name, req, req->req.length, req->using_dma); in submit_request()
59 next_fifo_transaction(ep, req); in submit_request()
61 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); in submit_request()
62 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); in submit_request()
64 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in submit_request()
65 usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY); in submit_request()
69 static void submit_next_request(struct usba_ep *ep) in submit_next_request() argument
73 if (list_empty(&ep->queue)) { in submit_next_request()
74 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY | USBA_RX_BK_RDY); in submit_next_request()
78 req = list_entry(ep->queue.next, struct usba_request, queue); in submit_next_request()
80 submit_request(ep, req); in submit_next_request()
83 static void send_status(struct usba_udc *udc, struct usba_ep *ep) in send_status() argument
85 ep->state = STATUS_STAGE_IN; in send_status()
86 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in send_status()
87 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); in send_status()
90 static void receive_data(struct usba_ep *ep) in receive_data() argument
92 struct usba_udc *udc = ep->udc; in receive_data()
98 status = usba_ep_readl(ep, STA); in receive_data()
104 if (list_empty(&ep->queue)) { in receive_data()
105 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in receive_data()
108 req = list_entry(ep->queue.next, in receive_data()
120 memcpy(req->req.buf + req->req.actual, ep->fifo, bytecount); in receive_data()
123 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); in receive_data()
126 DBG(DBG_QUEUE, "%s: request done\n", ep->ep.name); in receive_data()
129 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in receive_data()
131 req->req.complete(&ep->ep, &req->req); in receive_data()
135 status = usba_ep_readl(ep, STA); in receive_data()
138 if (is_complete && ep_is_control(ep)) { in receive_data()
139 send_status(udc, ep); in receive_data()
146 request_complete(struct usba_ep *ep, struct usba_request *req, int status) in request_complete() argument
152 ep->ep.name, req, req->req.status, req->req.actual); in request_complete()
154 req->req.complete(&ep->ep, &req->req); in request_complete()
158 request_complete_list(struct usba_ep *ep, struct list_head *list, int status) in request_complete_list() argument
164 request_complete(ep, req, status); in request_complete_list()
171 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_enable() local
172 struct usba_udc *udc = ep->udc; in usba_ep_enable()
176 DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc); in usba_ep_enable()
181 != ep->index) || in usba_ep_enable()
182 ep->index == 0 || in usba_ep_enable()
185 maxpacket > ep->fifo_size) { in usba_ep_enable()
190 ep->is_isoc = 0; in usba_ep_enable()
191 ep->is_in = 0; in usba_ep_enable()
200 ep->ep.name, ept_cfg, maxpacket); in usba_ep_enable()
203 ep->is_in = 1; in usba_ep_enable()
213 if (!ep->can_isoc) { in usba_ep_enable()
215 ep->ep.name); in usba_ep_enable()
227 ep->is_isoc = 1; in usba_ep_enable()
233 if (nr_trans > 1 && ep->nr_banks == 3) in usba_ep_enable()
249 spin_lock_irqsave(&ep->udc->lock, flags); in usba_ep_enable()
251 ep->desc = desc; in usba_ep_enable()
252 ep->ep.maxpacket = maxpacket; in usba_ep_enable()
254 usba_ep_writel(ep, CFG, ept_cfg); in usba_ep_enable()
255 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); in usba_ep_enable()
259 | USBA_BF(EPT_INT, 1 << ep->index))); in usba_ep_enable()
263 DBG(DBG_HW, "EPT_CFG%d after init: %#08lx\n", ep->index, in usba_ep_enable()
264 (unsigned long)usba_ep_readl(ep, CFG)); in usba_ep_enable()
273 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_disable() local
274 struct usba_udc *udc = ep->udc; in usba_ep_disable()
278 DBG(DBG_GADGET, "ep_disable: %s\n", ep->ep.name); in usba_ep_disable()
282 if (!ep->desc) { in usba_ep_disable()
290 ep->ep.name); in usba_ep_disable()
293 ep->desc = NULL; in usba_ep_disable()
295 list_splice_init(&ep->queue, &req_list); in usba_ep_disable()
296 usba_ep_writel(ep, CFG, 0); in usba_ep_disable()
297 usba_ep_writel(ep, CTL_DIS, USBA_EPT_ENABLE); in usba_ep_disable()
300 ~USBA_BF(EPT_INT, 1 << ep->index)); in usba_ep_disable()
302 request_complete_list(ep, &req_list, -ESHUTDOWN); in usba_ep_disable()
339 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_queue() local
340 struct usba_udc *udc = ep->udc; in usba_ep_queue()
345 ep->ep.name, req, _req->length); in usba_ep_queue()
348 !ep->desc) in usba_ep_queue()
361 if (ep->desc) { in usba_ep_queue()
362 list_add_tail(&req->queue, &ep->queue); in usba_ep_queue()
364 if ((!ep_is_control(ep) && ep->is_in) || in usba_ep_queue()
365 (ep_is_control(ep) && (ep->state == DATA_STAGE_IN || in usba_ep_queue()
366 ep->state == STATUS_STAGE_IN))) in usba_ep_queue()
367 usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY); in usba_ep_queue()
369 usba_ep_writel(ep, CTL_ENB, USBA_RX_BK_RDY); in usba_ep_queue()
380 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_dequeue() local
384 ep->ep.name, req); in usba_ep_dequeue()
392 request_complete(ep, req, -ECONNRESET); in usba_ep_dequeue()
395 submit_next_request(ep); in usba_ep_dequeue()
402 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_set_halt() local
406 DBG(DBG_GADGET, "endpoint %s: %s HALT\n", ep->ep.name, in usba_ep_set_halt()
409 if (!ep->desc) { in usba_ep_set_halt()
411 ep->ep.name); in usba_ep_set_halt()
415 if (ep->is_isoc) { in usba_ep_set_halt()
417 ep->ep.name); in usba_ep_set_halt()
427 if (!list_empty(&ep->queue) || in usba_ep_set_halt()
428 ((value && ep->is_in && (usba_ep_readl(ep, STA) & in usba_ep_set_halt()
433 usba_ep_writel(ep, SET_STA, USBA_FORCE_STALL); in usba_ep_set_halt()
435 usba_ep_writel(ep, CLR_STA, in usba_ep_set_halt()
437 usba_ep_readl(ep, STA); in usba_ep_set_halt()
447 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_fifo_status() local
449 return USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); in usba_ep_fifo_status()
454 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_fifo_flush() local
455 struct usba_udc *udc = ep->udc; in usba_ep_fifo_flush()
457 usba_writel(udc, EPT_RST, 1 << ep->index); in usba_ep_fifo_flush()
534 struct usba_ep *ep; in reset_all_endpoints() local
539 ep = to_usba_ep(udc->gadget.ep0); in reset_all_endpoints()
540 list_for_each_entry_safe(req, tmp_req, &ep->queue, queue) { in reset_all_endpoints()
542 request_complete(ep, req, -ECONNRESET); in reset_all_endpoints()
551 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { in reset_all_endpoints()
552 if (ep->desc) { in reset_all_endpoints()
554 usba_ep_disable(&ep->ep); in reset_all_endpoints()
562 struct usba_ep *ep; in get_ep_by_addr() local
567 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { in get_ep_by_addr()
570 if (!ep->desc) in get_ep_by_addr()
572 bEndpointAddress = ep->desc->bEndpointAddress; in get_ep_by_addr()
577 return ep; in get_ep_by_addr()
584 static inline void set_protocol_stall(struct usba_udc *udc, struct usba_ep *ep) in set_protocol_stall() argument
586 usba_ep_writel(ep, SET_STA, USBA_FORCE_STALL); in set_protocol_stall()
587 ep->state = WAIT_FOR_SETUP; in set_protocol_stall()
590 static inline int is_stalled(struct usba_udc *udc, struct usba_ep *ep) in is_stalled() argument
592 if (usba_ep_readl(ep, STA) & USBA_FORCE_STALL) in is_stalled()
624 struct usba_ep *ep; in do_test_mode() local
648 ep = &udc->usba_ep[0]; in do_test_mode()
651 usba_ep_writel(ep, CFG, in do_test_mode()
656 if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED)) { in do_test_mode()
657 set_protocol_stall(udc, ep); in do_test_mode()
660 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); in do_test_mode()
666 ep = &udc->usba_ep[0]; in do_test_mode()
667 usba_ep_writel(ep, CFG, in do_test_mode()
672 if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED)) { in do_test_mode()
673 set_protocol_stall(udc, ep); in do_test_mode()
676 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); in do_test_mode()
678 memcpy(ep->fifo, test_packet_buffer, in do_test_mode()
680 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in do_test_mode()
714 static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, in handle_ep0_setup() argument
746 ep->state = DATA_STAGE_IN; in handle_ep0_setup()
747 __raw_writew(status, ep->fifo); in handle_ep0_setup()
748 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in handle_ep0_setup()
778 send_status(udc, ep); in handle_ep0_setup()
785 send_status(udc, ep); in handle_ep0_setup()
786 ep->state = STATUS_STAGE_TEST; in handle_ep0_setup()
810 send_status(udc, ep); in handle_ep0_setup()
819 send_status(udc, ep); in handle_ep0_setup()
820 ep->state = STATUS_STAGE_ADDR; in handle_ep0_setup()
834 ep->ep.name, crq->bRequestType, crq->bRequest, in handle_ep0_setup()
837 set_protocol_stall(udc, ep); in handle_ep0_setup()
842 static void usba_control_irq(struct usba_udc *udc, struct usba_ep *ep) in usba_control_irq() argument
849 epstatus = usba_ep_readl(ep, STA); in usba_control_irq()
850 epctrl = usba_ep_readl(ep, CTL); in usba_control_irq()
853 ep->ep.name, ep->state, epstatus, epctrl); in usba_control_irq()
856 if (!list_empty(&ep->queue)) in usba_control_irq()
857 req = list_entry(ep->queue.next, in usba_control_irq()
862 next_fifo_transaction(ep, req); in usba_control_irq()
864 submit_request(ep, req); in usba_control_irq()
867 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); in usba_control_irq()
868 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); in usba_control_irq()
873 usba_ep_writel(ep, CLR_STA, USBA_TX_COMPLETE); in usba_control_irq()
875 switch (ep->state) { in usba_control_irq()
877 usba_ep_writel(ep, CTL_ENB, USBA_RX_BK_RDY); in usba_control_irq()
878 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
879 ep->state = STATUS_STAGE_OUT; in usba_control_irq()
885 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
886 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
891 request_complete(ep, req, 0); in usba_control_irq()
892 submit_next_request(ep); in usba_control_irq()
894 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
895 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
898 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
899 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
901 set_protocol_stall(udc, ep); in usba_control_irq()
905 ep->ep.name, ep->state); in usba_control_irq()
906 set_protocol_stall(udc, ep); in usba_control_irq()
913 switch (ep->state) { in usba_control_irq()
915 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); in usba_control_irq()
916 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in usba_control_irq()
920 request_complete(ep, req, 0); in usba_control_irq()
922 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
926 receive_data(ep); in usba_control_irq()
930 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); in usba_control_irq()
931 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in usba_control_irq()
933 ep->ep.name, ep->state); in usba_control_irq()
934 set_protocol_stall(udc, ep); in usba_control_irq()
948 if (ep->state != WAIT_FOR_SETUP) { in usba_control_irq()
961 if (ep->state == STATUS_STAGE_OUT || in usba_control_irq()
962 ep->state == STATUS_STAGE_IN) { in usba_control_irq()
963 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in usba_control_irq()
969 request_complete(ep, req, status); in usba_control_irq()
973 pkt_len = USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); in usba_control_irq()
978 set_protocol_stall(udc, ep); in usba_control_irq()
982 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo); in usba_control_irq()
983 memcpy(crq.data, ep->fifo, sizeof(crq)); in usba_control_irq()
987 usba_ep_writel(ep, CLR_STA, USBA_RX_SETUP); in usba_control_irq()
996 ep->state = DATA_STAGE_IN; in usba_control_irq()
999 ep->state = DATA_STAGE_OUT; in usba_control_irq()
1001 ep->state = STATUS_STAGE_IN; in usba_control_irq()
1005 if (ep->index == 0) { in usba_control_irq()
1006 ret = handle_ep0_setup(udc, ep, &crq.crq); in usba_control_irq()
1015 le16_to_cpu(crq.crq.wLength), ep->state, ret); in usba_control_irq()
1019 set_protocol_stall(udc, ep); in usba_control_irq()
1024 static void usba_ep_irq(struct usba_udc *udc, struct usba_ep *ep) in usba_ep_irq() argument
1030 epstatus = usba_ep_readl(ep, STA); in usba_ep_irq()
1031 epctrl = usba_ep_readl(ep, CTL); in usba_ep_irq()
1033 DBG(DBG_INT, "%s: interrupt, status: 0x%08x\n", ep->ep.name, epstatus); in usba_ep_irq()
1036 DBG(DBG_BUS, "%s: TX PK ready\n", ep->ep.name); in usba_ep_irq()
1038 if (list_empty(&ep->queue)) { in usba_ep_irq()
1040 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); in usba_ep_irq()
1044 req = list_entry(ep->queue.next, struct usba_request, queue); in usba_ep_irq()
1047 next_fifo_transaction(ep, req); in usba_ep_irq()
1049 submit_request(ep, req); in usba_ep_irq()
1053 submit_next_request(ep); in usba_ep_irq()
1054 request_complete(ep, req, 0); in usba_ep_irq()
1057 epstatus = usba_ep_readl(ep, STA); in usba_ep_irq()
1058 epctrl = usba_ep_readl(ep, CTL); in usba_ep_irq()
1062 DBG(DBG_BUS, "%s: RX data ready\n", ep->ep.name); in usba_ep_irq()
1063 receive_data(ep); in usba_ep_irq()
1267 udc->gadget.ep0 = &eps[0].ep; in usba_udc_pdata()
1270 INIT_LIST_HEAD(&eps[0].ep.ep_list); in usba_udc_pdata()
1273 struct usba_ep *ep = &eps[i]; in usba_udc_pdata() local
1275 ep->ep_regs = udc->regs + USBA_EPT_BASE(i); in usba_udc_pdata()
1276 ep->dma_regs = udc->regs + USBA_DMA_BASE(i); in usba_udc_pdata()
1277 ep->fifo = udc->fifo + USBA_FIFO_BASE(i); in usba_udc_pdata()
1278 ep->ep.ops = &usba_ep_ops; in usba_udc_pdata()
1279 ep->ep.name = pdata->ep[i].name; in usba_udc_pdata()
1280 ep->ep.maxpacket = pdata->ep[i].fifo_size; in usba_udc_pdata()
1281 ep->fifo_size = ep->ep.maxpacket; in usba_udc_pdata()
1282 ep->udc = udc; in usba_udc_pdata()
1283 INIT_LIST_HEAD(&ep->queue); in usba_udc_pdata()
1284 ep->nr_banks = pdata->ep[i].nr_banks; in usba_udc_pdata()
1285 ep->index = pdata->ep[i].index; in usba_udc_pdata()
1286 ep->can_dma = pdata->ep[i].can_dma; in usba_udc_pdata()
1287 ep->can_isoc = pdata->ep[i].can_isoc; in usba_udc_pdata()
1289 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in usba_udc_pdata()