• Home
  • Raw
  • Download

Lines Matching refs:ep

28 static void next_fifo_transaction(struct usba_ep *ep, struct usba_request *req)  in next_fifo_transaction()  argument
34 if (transaction_len > ep->ep.maxpacket) { in next_fifo_transaction()
35 transaction_len = ep->ep.maxpacket; in next_fifo_transaction()
37 } else if (transaction_len == ep->ep.maxpacket && req->req.zero) { in next_fifo_transaction()
42 ep->ep.name, req, transaction_len, in next_fifo_transaction()
45 memcpy(ep->fifo, req->req.buf + req->req.actual, transaction_len); in next_fifo_transaction()
46 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in next_fifo_transaction()
50 static void submit_request(struct usba_ep *ep, struct usba_request *req) in submit_request() argument
53 ep->ep.name, req, req->req.length, req->using_dma); in submit_request()
58 next_fifo_transaction(ep, req); in submit_request()
60 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); in submit_request()
61 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); in submit_request()
63 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in submit_request()
64 usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY); in submit_request()
68 static void submit_next_request(struct usba_ep *ep) in submit_next_request() argument
72 if (list_empty(&ep->queue)) { in submit_next_request()
73 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY | USBA_RX_BK_RDY); in submit_next_request()
77 req = list_entry(ep->queue.next, struct usba_request, queue); in submit_next_request()
79 submit_request(ep, req); in submit_next_request()
82 static void send_status(struct usba_udc *udc, struct usba_ep *ep) in send_status() argument
84 ep->state = STATUS_STAGE_IN; in send_status()
85 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in send_status()
86 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); in send_status()
89 static void receive_data(struct usba_ep *ep) in receive_data() argument
91 struct usba_udc *udc = ep->udc; in receive_data()
97 status = usba_ep_readl(ep, STA); in receive_data()
103 if (list_empty(&ep->queue)) { in receive_data()
104 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in receive_data()
107 req = list_entry(ep->queue.next, in receive_data()
119 memcpy(req->req.buf + req->req.actual, ep->fifo, bytecount); in receive_data()
122 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); in receive_data()
125 DBG(DBG_QUEUE, "%s: request done\n", ep->ep.name); in receive_data()
128 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in receive_data()
130 req->req.complete(&ep->ep, &req->req); in receive_data()
134 status = usba_ep_readl(ep, STA); in receive_data()
137 if (is_complete && ep_is_control(ep)) { in receive_data()
138 send_status(udc, ep); in receive_data()
145 request_complete(struct usba_ep *ep, struct usba_request *req, int status) in request_complete() argument
151 ep->ep.name, req, req->req.status, req->req.actual); in request_complete()
153 req->req.complete(&ep->ep, &req->req); in request_complete()
157 request_complete_list(struct usba_ep *ep, struct list_head *list, int status) in request_complete_list() argument
163 request_complete(ep, req, status); in request_complete_list()
170 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_enable() local
171 struct usba_udc *udc = ep->udc; in usba_ep_enable()
175 DBG(DBG_GADGET, "%s: ep_enable: desc=%p\n", ep->ep.name, desc); in usba_ep_enable()
180 != ep->index) || in usba_ep_enable()
181 ep->index == 0 || in usba_ep_enable()
184 maxpacket > ep->fifo_size) { in usba_ep_enable()
189 ep->is_isoc = 0; in usba_ep_enable()
190 ep->is_in = 0; in usba_ep_enable()
199 ep->ep.name, ept_cfg, maxpacket); in usba_ep_enable()
202 ep->is_in = 1; in usba_ep_enable()
212 if (!ep->can_isoc) { in usba_ep_enable()
214 ep->ep.name); in usba_ep_enable()
226 ep->is_isoc = 1; in usba_ep_enable()
232 if (nr_trans > 1 && ep->nr_banks == 3) in usba_ep_enable()
248 spin_lock_irqsave(&ep->udc->lock, flags); in usba_ep_enable()
250 ep->desc = desc; in usba_ep_enable()
251 ep->ep.maxpacket = maxpacket; in usba_ep_enable()
253 usba_ep_writel(ep, CFG, ept_cfg); in usba_ep_enable()
254 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); in usba_ep_enable()
258 | USBA_BF(EPT_INT, 1 << ep->index))); in usba_ep_enable()
262 DBG(DBG_HW, "EPT_CFG%d after init: %#08lx\n", ep->index, in usba_ep_enable()
263 (unsigned long)usba_ep_readl(ep, CFG)); in usba_ep_enable()
272 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_disable() local
273 struct usba_udc *udc = ep->udc; in usba_ep_disable()
277 DBG(DBG_GADGET, "ep_disable: %s\n", ep->ep.name); in usba_ep_disable()
281 if (!ep->desc) { in usba_ep_disable()
289 ep->ep.name); in usba_ep_disable()
292 ep->desc = NULL; in usba_ep_disable()
294 list_splice_init(&ep->queue, &req_list); in usba_ep_disable()
295 usba_ep_writel(ep, CFG, 0); in usba_ep_disable()
296 usba_ep_writel(ep, CTL_DIS, USBA_EPT_ENABLE); in usba_ep_disable()
299 ~USBA_BF(EPT_INT, 1 << ep->index)); in usba_ep_disable()
301 request_complete_list(ep, &req_list, -ESHUTDOWN); in usba_ep_disable()
338 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_queue() local
339 struct usba_udc *udc = ep->udc; in usba_ep_queue()
344 ep->ep.name, req, _req->length); in usba_ep_queue()
347 !ep->desc) in usba_ep_queue()
360 if (ep->desc) { in usba_ep_queue()
361 list_add_tail(&req->queue, &ep->queue); in usba_ep_queue()
363 if ((!ep_is_control(ep) && ep->is_in) || in usba_ep_queue()
364 (ep_is_control(ep) && (ep->state == DATA_STAGE_IN || in usba_ep_queue()
365 ep->state == STATUS_STAGE_IN))) in usba_ep_queue()
366 usba_ep_writel(ep, CTL_ENB, USBA_TX_PK_RDY); in usba_ep_queue()
368 usba_ep_writel(ep, CTL_ENB, USBA_RX_BK_RDY); in usba_ep_queue()
379 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_dequeue() local
383 ep->ep.name, req); in usba_ep_dequeue()
391 request_complete(ep, req, -ECONNRESET); in usba_ep_dequeue()
394 submit_next_request(ep); in usba_ep_dequeue()
401 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_set_halt() local
405 DBG(DBG_GADGET, "endpoint %s: %s HALT\n", ep->ep.name, in usba_ep_set_halt()
408 if (!ep->desc) { in usba_ep_set_halt()
410 ep->ep.name); in usba_ep_set_halt()
414 if (ep->is_isoc) { in usba_ep_set_halt()
416 ep->ep.name); in usba_ep_set_halt()
426 if (!list_empty(&ep->queue) || in usba_ep_set_halt()
427 ((value && ep->is_in && (usba_ep_readl(ep, STA) & in usba_ep_set_halt()
432 usba_ep_writel(ep, SET_STA, USBA_FORCE_STALL); in usba_ep_set_halt()
434 usba_ep_writel(ep, CLR_STA, in usba_ep_set_halt()
436 usba_ep_readl(ep, STA); in usba_ep_set_halt()
446 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_fifo_status() local
448 return USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); in usba_ep_fifo_status()
453 struct usba_ep *ep = to_usba_ep(_ep); in usba_ep_fifo_flush() local
454 struct usba_udc *udc = ep->udc; in usba_ep_fifo_flush()
456 usba_writel(udc, EPT_RST, 1 << ep->index); in usba_ep_fifo_flush()
533 struct usba_ep *ep; in reset_all_endpoints() local
538 ep = to_usba_ep(udc->gadget.ep0); in reset_all_endpoints()
539 list_for_each_entry_safe(req, tmp_req, &ep->queue, queue) { in reset_all_endpoints()
541 request_complete(ep, req, -ECONNRESET); in reset_all_endpoints()
550 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { in reset_all_endpoints()
551 if (ep->desc) { in reset_all_endpoints()
553 usba_ep_disable(&ep->ep); in reset_all_endpoints()
561 struct usba_ep *ep; in get_ep_by_addr() local
566 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { in get_ep_by_addr()
569 if (!ep->desc) in get_ep_by_addr()
571 bEndpointAddress = ep->desc->bEndpointAddress; in get_ep_by_addr()
576 return ep; in get_ep_by_addr()
583 static inline void set_protocol_stall(struct usba_udc *udc, struct usba_ep *ep) in set_protocol_stall() argument
585 usba_ep_writel(ep, SET_STA, USBA_FORCE_STALL); in set_protocol_stall()
586 ep->state = WAIT_FOR_SETUP; in set_protocol_stall()
589 static inline int is_stalled(struct usba_udc *udc, struct usba_ep *ep) in is_stalled() argument
591 if (usba_ep_readl(ep, STA) & USBA_FORCE_STALL) in is_stalled()
623 struct usba_ep *ep; in do_test_mode() local
647 ep = &udc->usba_ep[0]; in do_test_mode()
650 usba_ep_writel(ep, CFG, in do_test_mode()
655 if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED)) { in do_test_mode()
656 set_protocol_stall(udc, ep); in do_test_mode()
659 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); in do_test_mode()
665 ep = &udc->usba_ep[0]; in do_test_mode()
666 usba_ep_writel(ep, CFG, in do_test_mode()
671 if (!(usba_ep_readl(ep, CFG) & USBA_EPT_MAPPED)) { in do_test_mode()
672 set_protocol_stall(udc, ep); in do_test_mode()
675 usba_ep_writel(ep, CTL_ENB, USBA_EPT_ENABLE); in do_test_mode()
677 memcpy(ep->fifo, test_packet_buffer, in do_test_mode()
679 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in do_test_mode()
713 static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, in handle_ep0_setup() argument
745 ep->state = DATA_STAGE_IN; in handle_ep0_setup()
746 __raw_writew(status, ep->fifo); in handle_ep0_setup()
747 usba_ep_writel(ep, SET_STA, USBA_TX_PK_RDY); in handle_ep0_setup()
777 send_status(udc, ep); in handle_ep0_setup()
784 send_status(udc, ep); in handle_ep0_setup()
785 ep->state = STATUS_STAGE_TEST; in handle_ep0_setup()
809 send_status(udc, ep); in handle_ep0_setup()
818 send_status(udc, ep); in handle_ep0_setup()
819 ep->state = STATUS_STAGE_ADDR; in handle_ep0_setup()
833 ep->ep.name, crq->bRequestType, crq->bRequest, in handle_ep0_setup()
836 set_protocol_stall(udc, ep); in handle_ep0_setup()
841 static void usba_control_irq(struct usba_udc *udc, struct usba_ep *ep) in usba_control_irq() argument
848 epstatus = usba_ep_readl(ep, STA); in usba_control_irq()
849 epctrl = usba_ep_readl(ep, CTL); in usba_control_irq()
852 ep->ep.name, ep->state, epstatus, epctrl); in usba_control_irq()
855 if (!list_empty(&ep->queue)) in usba_control_irq()
856 req = list_entry(ep->queue.next, in usba_control_irq()
861 next_fifo_transaction(ep, req); in usba_control_irq()
863 submit_request(ep, req); in usba_control_irq()
866 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); in usba_control_irq()
867 usba_ep_writel(ep, CTL_ENB, USBA_TX_COMPLETE); in usba_control_irq()
872 usba_ep_writel(ep, CLR_STA, USBA_TX_COMPLETE); in usba_control_irq()
874 switch (ep->state) { in usba_control_irq()
876 usba_ep_writel(ep, CTL_ENB, USBA_RX_BK_RDY); in usba_control_irq()
877 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
878 ep->state = STATUS_STAGE_OUT; in usba_control_irq()
884 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
885 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
890 request_complete(ep, req, 0); in usba_control_irq()
891 submit_next_request(ep); in usba_control_irq()
893 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
894 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
897 usba_ep_writel(ep, CTL_DIS, USBA_TX_COMPLETE); in usba_control_irq()
898 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
900 set_protocol_stall(udc, ep); in usba_control_irq()
904 ep->ep.name, ep->state); in usba_control_irq()
905 set_protocol_stall(udc, ep); in usba_control_irq()
912 switch (ep->state) { in usba_control_irq()
914 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); in usba_control_irq()
915 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in usba_control_irq()
919 request_complete(ep, req, 0); in usba_control_irq()
921 ep->state = WAIT_FOR_SETUP; in usba_control_irq()
925 receive_data(ep); in usba_control_irq()
929 usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY); in usba_control_irq()
930 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in usba_control_irq()
932 ep->ep.name, ep->state); in usba_control_irq()
933 set_protocol_stall(udc, ep); in usba_control_irq()
947 if (ep->state != WAIT_FOR_SETUP) { in usba_control_irq()
960 if (ep->state == STATUS_STAGE_OUT || in usba_control_irq()
961 ep->state == STATUS_STAGE_IN) { in usba_control_irq()
962 usba_ep_writel(ep, CTL_DIS, USBA_RX_BK_RDY); in usba_control_irq()
968 request_complete(ep, req, status); in usba_control_irq()
972 pkt_len = USBA_BFEXT(BYTE_COUNT, usba_ep_readl(ep, STA)); in usba_control_irq()
977 set_protocol_stall(udc, ep); in usba_control_irq()
981 DBG(DBG_FIFO, "Copying ctrl request from 0x%p:\n", ep->fifo); in usba_control_irq()
982 memcpy(crq.data, ep->fifo, sizeof(crq)); in usba_control_irq()
986 usba_ep_writel(ep, CLR_STA, USBA_RX_SETUP); in usba_control_irq()
995 ep->state = DATA_STAGE_IN; in usba_control_irq()
998 ep->state = DATA_STAGE_OUT; in usba_control_irq()
1000 ep->state = STATUS_STAGE_IN; in usba_control_irq()
1004 if (ep->index == 0) { in usba_control_irq()
1005 ret = handle_ep0_setup(udc, ep, &crq.crq); in usba_control_irq()
1014 le16_to_cpu(crq.crq.wLength), ep->state, ret); in usba_control_irq()
1018 set_protocol_stall(udc, ep); in usba_control_irq()
1023 static void usba_ep_irq(struct usba_udc *udc, struct usba_ep *ep) in usba_ep_irq() argument
1029 epstatus = usba_ep_readl(ep, STA); in usba_ep_irq()
1030 epctrl = usba_ep_readl(ep, CTL); in usba_ep_irq()
1032 DBG(DBG_INT, "%s: interrupt, status: 0x%08x\n", ep->ep.name, epstatus); in usba_ep_irq()
1035 DBG(DBG_BUS, "%s: TX PK ready\n", ep->ep.name); in usba_ep_irq()
1037 if (list_empty(&ep->queue)) { in usba_ep_irq()
1039 usba_ep_writel(ep, CTL_DIS, USBA_TX_PK_RDY); in usba_ep_irq()
1043 req = list_entry(ep->queue.next, struct usba_request, queue); in usba_ep_irq()
1046 next_fifo_transaction(ep, req); in usba_ep_irq()
1048 submit_request(ep, req); in usba_ep_irq()
1052 submit_next_request(ep); in usba_ep_irq()
1053 request_complete(ep, req, 0); in usba_ep_irq()
1056 epstatus = usba_ep_readl(ep, STA); in usba_ep_irq()
1057 epctrl = usba_ep_readl(ep, CTL); in usba_ep_irq()
1061 DBG(DBG_BUS, "%s: RX data ready\n", ep->ep.name); in usba_ep_irq()
1062 receive_data(ep); in usba_ep_irq()
1266 udc->gadget.ep0 = &eps[0].ep; in usba_udc_pdata()
1269 INIT_LIST_HEAD(&eps[0].ep.ep_list); in usba_udc_pdata()
1272 struct usba_ep *ep = &eps[i]; in usba_udc_pdata() local
1274 ep->ep_regs = udc->regs + USBA_EPT_BASE(i); in usba_udc_pdata()
1275 ep->dma_regs = udc->regs + USBA_DMA_BASE(i); in usba_udc_pdata()
1276 ep->fifo = udc->fifo + USBA_FIFO_BASE(i); in usba_udc_pdata()
1277 ep->ep.ops = &usba_ep_ops; in usba_udc_pdata()
1278 ep->ep.name = pdata->ep[i].name; in usba_udc_pdata()
1279 ep->ep.maxpacket = pdata->ep[i].fifo_size; in usba_udc_pdata()
1280 ep->fifo_size = ep->ep.maxpacket; in usba_udc_pdata()
1281 ep->udc = udc; in usba_udc_pdata()
1282 INIT_LIST_HEAD(&ep->queue); in usba_udc_pdata()
1283 ep->nr_banks = pdata->ep[i].nr_banks; in usba_udc_pdata()
1284 ep->index = pdata->ep[i].index; in usba_udc_pdata()
1285 ep->can_dma = pdata->ep[i].can_dma; in usba_udc_pdata()
1286 ep->can_isoc = pdata->ep[i].can_isoc; in usba_udc_pdata()
1288 list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); in usba_udc_pdata()