diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/usb/musb/musb_host.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/usb/musb/musb_host.c')
-rw-r--r-- | drivers/usb/musb/musb_host.c | 181 |
1 files changed, 85 insertions, 96 deletions
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 9e65c47cc98b..8b2473fa0f47 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/errno.h> | 41 | #include <linux/errno.h> |
42 | #include <linux/init.h> | 42 | #include <linux/init.h> |
43 | #include <linux/list.h> | 43 | #include <linux/list.h> |
44 | #include <linux/dma-mapping.h> | ||
44 | 45 | ||
45 | #include "musb_core.h" | 46 | #include "musb_core.h" |
46 | #include "musb_host.h" | 47 | #include "musb_host.h" |
@@ -105,6 +106,7 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
105 | */ | 106 | */ |
106 | static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) | 107 | static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) |
107 | { | 108 | { |
109 | struct musb *musb = ep->musb; | ||
108 | void __iomem *epio = ep->regs; | 110 | void __iomem *epio = ep->regs; |
109 | u16 csr; | 111 | u16 csr; |
110 | u16 lastcsr = 0; | 112 | u16 lastcsr = 0; |
@@ -113,7 +115,7 @@ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) | |||
113 | csr = musb_readw(epio, MUSB_TXCSR); | 115 | csr = musb_readw(epio, MUSB_TXCSR); |
114 | while (csr & MUSB_TXCSR_FIFONOTEMPTY) { | 116 | while (csr & MUSB_TXCSR_FIFONOTEMPTY) { |
115 | if (csr != lastcsr) | 117 | if (csr != lastcsr) |
116 | DBG(3, "Host TX FIFONOTEMPTY csr: %02x\n", csr); | 118 | dev_dbg(musb->controller, "Host TX FIFONOTEMPTY csr: %02x\n", csr); |
117 | lastcsr = csr; | 119 | lastcsr = csr; |
118 | csr |= MUSB_TXCSR_FLUSHFIFO; | 120 | csr |= MUSB_TXCSR_FLUSHFIFO; |
119 | musb_writew(epio, MUSB_TXCSR, csr); | 121 | musb_writew(epio, MUSB_TXCSR, csr); |
@@ -239,7 +241,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) | |||
239 | len = urb->transfer_buffer_length - urb->actual_length; | 241 | len = urb->transfer_buffer_length - urb->actual_length; |
240 | } | 242 | } |
241 | 243 | ||
242 | DBG(4, "qh %p urb %p dev%d ep%d%s%s, hw_ep %d, %p/%d\n", | 244 | dev_dbg(musb->controller, "qh %p urb %p dev%d ep%d%s%s, hw_ep %d, %p/%d\n", |
243 | qh, urb, address, qh->epnum, | 245 | qh, urb, address, qh->epnum, |
244 | is_in ? "in" : "out", | 246 | is_in ? "in" : "out", |
245 | ({char *s; switch (qh->type) { | 247 | ({char *s; switch (qh->type) { |
@@ -262,7 +264,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) | |||
262 | switch (qh->type) { | 264 | switch (qh->type) { |
263 | case USB_ENDPOINT_XFER_ISOC: | 265 | case USB_ENDPOINT_XFER_ISOC: |
264 | case USB_ENDPOINT_XFER_INT: | 266 | case USB_ENDPOINT_XFER_INT: |
265 | DBG(3, "check whether there's still time for periodic Tx\n"); | 267 | dev_dbg(musb->controller, "check whether there's still time for periodic Tx\n"); |
266 | frame = musb_readw(mbase, MUSB_FRAME); | 268 | frame = musb_readw(mbase, MUSB_FRAME); |
267 | /* FIXME this doesn't implement that scheduling policy ... | 269 | /* FIXME this doesn't implement that scheduling policy ... |
268 | * or handle framecounter wrapping | 270 | * or handle framecounter wrapping |
@@ -277,7 +279,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) | |||
277 | } else { | 279 | } else { |
278 | qh->frame = urb->start_frame; | 280 | qh->frame = urb->start_frame; |
279 | /* enable SOF interrupt so we can count down */ | 281 | /* enable SOF interrupt so we can count down */ |
280 | DBG(1, "SOF for %d\n", epnum); | 282 | dev_dbg(musb->controller, "SOF for %d\n", epnum); |
281 | #if 1 /* ifndef CONFIG_ARCH_DAVINCI */ | 283 | #if 1 /* ifndef CONFIG_ARCH_DAVINCI */ |
282 | musb_writeb(mbase, MUSB_INTRUSBE, 0xff); | 284 | musb_writeb(mbase, MUSB_INTRUSBE, 0xff); |
283 | #endif | 285 | #endif |
@@ -285,7 +287,7 @@ musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) | |||
285 | break; | 287 | break; |
286 | default: | 288 | default: |
287 | start: | 289 | start: |
288 | DBG(4, "Start TX%d %s\n", epnum, | 290 | dev_dbg(musb->controller, "Start TX%d %s\n", epnum, |
289 | hw_ep->tx_channel ? "dma" : "pio"); | 291 | hw_ep->tx_channel ? "dma" : "pio"); |
290 | 292 | ||
291 | if (!hw_ep->tx_channel) | 293 | if (!hw_ep->tx_channel) |
@@ -300,21 +302,7 @@ static void musb_giveback(struct musb *musb, struct urb *urb, int status) | |||
300 | __releases(musb->lock) | 302 | __releases(musb->lock) |
301 | __acquires(musb->lock) | 303 | __acquires(musb->lock) |
302 | { | 304 | { |
303 | DBG(({ int level; switch (status) { | 305 | dev_dbg(musb->controller, |
304 | case 0: | ||
305 | level = 4; | ||
306 | break; | ||
307 | /* common/boring faults */ | ||
308 | case -EREMOTEIO: | ||
309 | case -ESHUTDOWN: | ||
310 | case -ECONNRESET: | ||
311 | case -EPIPE: | ||
312 | level = 3; | ||
313 | break; | ||
314 | default: | ||
315 | level = 2; | ||
316 | break; | ||
317 | }; level; }), | ||
318 | "complete %p %pF (%d), dev%d ep%d%s, %d/%d\n", | 306 | "complete %p %pF (%d), dev%d ep%d%s, %d/%d\n", |
319 | urb, urb->complete, status, | 307 | urb, urb->complete, status, |
320 | usb_pipedevice(urb->pipe), | 308 | usb_pipedevice(urb->pipe), |
@@ -425,7 +413,7 @@ static void musb_advance_schedule(struct musb *musb, struct urb *urb, | |||
425 | } | 413 | } |
426 | 414 | ||
427 | if (qh != NULL && qh->is_ready) { | 415 | if (qh != NULL && qh->is_ready) { |
428 | DBG(4, "... next ep%d %cX urb %p\n", | 416 | dev_dbg(musb->controller, "... next ep%d %cX urb %p\n", |
429 | hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); | 417 | hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); |
430 | musb_start_urb(musb, is_in, qh); | 418 | musb_start_urb(musb, is_in, qh); |
431 | } | 419 | } |
@@ -470,7 +458,7 @@ musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err) | |||
470 | 458 | ||
471 | /* musb_ep_select(mbase, epnum); */ | 459 | /* musb_ep_select(mbase, epnum); */ |
472 | rx_count = musb_readw(epio, MUSB_RXCOUNT); | 460 | rx_count = musb_readw(epio, MUSB_RXCOUNT); |
473 | DBG(3, "RX%d count %d, buffer %p len %d/%d\n", epnum, rx_count, | 461 | dev_dbg(musb->controller, "RX%d count %d, buffer %p len %d/%d\n", epnum, rx_count, |
474 | urb->transfer_buffer, qh->offset, | 462 | urb->transfer_buffer, qh->offset, |
475 | urb->transfer_buffer_length); | 463 | urb->transfer_buffer_length); |
476 | 464 | ||
@@ -492,7 +480,7 @@ musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err) | |||
492 | status = -EOVERFLOW; | 480 | status = -EOVERFLOW; |
493 | urb->error_count++; | 481 | urb->error_count++; |
494 | } | 482 | } |
495 | DBG(2, "** OVERFLOW %d into %d\n", rx_count, length); | 483 | dev_dbg(musb->controller, "** OVERFLOW %d into %d\n", rx_count, length); |
496 | do_flush = 1; | 484 | do_flush = 1; |
497 | } else | 485 | } else |
498 | length = rx_count; | 486 | length = rx_count; |
@@ -510,7 +498,7 @@ musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err) | |||
510 | if (rx_count > length) { | 498 | if (rx_count > length) { |
511 | if (urb->status == -EINPROGRESS) | 499 | if (urb->status == -EINPROGRESS) |
512 | urb->status = -EOVERFLOW; | 500 | urb->status = -EOVERFLOW; |
513 | DBG(2, "** OVERFLOW %d into %d\n", rx_count, length); | 501 | dev_dbg(musb->controller, "** OVERFLOW %d into %d\n", rx_count, length); |
514 | do_flush = 1; | 502 | do_flush = 1; |
515 | } else | 503 | } else |
516 | length = rx_count; | 504 | length = rx_count; |
@@ -608,7 +596,7 @@ musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep) | |||
608 | /* Set RXMAXP with the FIFO size of the endpoint | 596 | /* Set RXMAXP with the FIFO size of the endpoint |
609 | * to disable double buffer mode. | 597 | * to disable double buffer mode. |
610 | */ | 598 | */ |
611 | if (musb->hwvers < MUSB_HWVERS_2000) | 599 | if (musb->double_buffer_not_ok) |
612 | musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx); | 600 | musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx); |
613 | else | 601 | else |
614 | musb_writew(ep->regs, MUSB_RXMAXP, | 602 | musb_writew(ep->regs, MUSB_RXMAXP, |
@@ -696,7 +684,7 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
696 | struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out); | 684 | struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out); |
697 | u16 packet_sz = qh->maxpacket; | 685 | u16 packet_sz = qh->maxpacket; |
698 | 686 | ||
699 | DBG(3, "%s hw%d urb %p spd%d dev%d ep%d%s " | 687 | dev_dbg(musb->controller, "%s hw%d urb %p spd%d dev%d ep%d%s " |
700 | "h_addr%02x h_port%02x bytes %d\n", | 688 | "h_addr%02x h_port%02x bytes %d\n", |
701 | is_out ? "-->" : "<--", | 689 | is_out ? "-->" : "<--", |
702 | epnum, urb, urb->dev->speed, | 690 | epnum, urb, urb->dev->speed, |
@@ -783,14 +771,13 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
783 | /* protocol/endpoint/interval/NAKlimit */ | 771 | /* protocol/endpoint/interval/NAKlimit */ |
784 | if (epnum) { | 772 | if (epnum) { |
785 | musb_writeb(epio, MUSB_TXTYPE, qh->type_reg); | 773 | musb_writeb(epio, MUSB_TXTYPE, qh->type_reg); |
786 | if (can_bulk_split(musb, qh->type)) | 774 | if (musb->double_buffer_not_ok) |
787 | musb_writew(epio, MUSB_TXMAXP, | 775 | musb_writew(epio, MUSB_TXMAXP, |
788 | packet_sz | 776 | hw_ep->max_packet_sz_tx); |
789 | | ((hw_ep->max_packet_sz_tx / | ||
790 | packet_sz) - 1) << 11); | ||
791 | else | 777 | else |
792 | musb_writew(epio, MUSB_TXMAXP, | 778 | musb_writew(epio, MUSB_TXMAXP, |
793 | packet_sz); | 779 | qh->maxpacket | |
780 | ((qh->hb_mult - 1) << 11)); | ||
794 | musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg); | 781 | musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg); |
795 | } else { | 782 | } else { |
796 | musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg); | 783 | musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg); |
@@ -850,37 +837,32 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
850 | /* kick things off */ | 837 | /* kick things off */ |
851 | 838 | ||
852 | if ((is_cppi_enabled() || tusb_dma_omap()) && dma_channel) { | 839 | if ((is_cppi_enabled() || tusb_dma_omap()) && dma_channel) { |
853 | /* candidate for DMA */ | 840 | /* Candidate for DMA */ |
854 | if (dma_channel) { | 841 | dma_channel->actual_len = 0L; |
855 | dma_channel->actual_len = 0L; | 842 | qh->segsize = len; |
856 | qh->segsize = len; | 843 | |
857 | 844 | /* AUTOREQ is in a DMA register */ | |
858 | /* AUTOREQ is in a DMA register */ | 845 | musb_writew(hw_ep->regs, MUSB_RXCSR, csr); |
859 | musb_writew(hw_ep->regs, MUSB_RXCSR, csr); | 846 | csr = musb_readw(hw_ep->regs, MUSB_RXCSR); |
860 | csr = musb_readw(hw_ep->regs, | 847 | |
861 | MUSB_RXCSR); | 848 | /* |
862 | 849 | * Unless caller treats short RX transfers as | |
863 | /* unless caller treats short rx transfers as | 850 | * errors, we dare not queue multiple transfers. |
864 | * errors, we dare not queue multiple transfers. | 851 | */ |
865 | */ | 852 | dma_ok = dma_controller->channel_program(dma_channel, |
866 | dma_ok = dma_controller->channel_program( | 853 | packet_sz, !(urb->transfer_flags & |
867 | dma_channel, packet_sz, | 854 | URB_SHORT_NOT_OK), |
868 | !(urb->transfer_flags | 855 | urb->transfer_dma + offset, |
869 | & URB_SHORT_NOT_OK), | 856 | qh->segsize); |
870 | urb->transfer_dma + offset, | 857 | if (!dma_ok) { |
871 | qh->segsize); | 858 | dma_controller->channel_release(dma_channel); |
872 | if (!dma_ok) { | 859 | hw_ep->rx_channel = dma_channel = NULL; |
873 | dma_controller->channel_release( | 860 | } else |
874 | dma_channel); | 861 | csr |= MUSB_RXCSR_DMAENAB; |
875 | hw_ep->rx_channel = NULL; | ||
876 | dma_channel = NULL; | ||
877 | } else | ||
878 | csr |= MUSB_RXCSR_DMAENAB; | ||
879 | } | ||
880 | } | 862 | } |
881 | 863 | ||
882 | csr |= MUSB_RXCSR_H_REQPKT; | 864 | csr |= MUSB_RXCSR_H_REQPKT; |
883 | DBG(7, "RXCSR%d := %04x\n", epnum, csr); | 865 | dev_dbg(musb->controller, "RXCSR%d := %04x\n", epnum, csr); |
884 | musb_writew(hw_ep->regs, MUSB_RXCSR, csr); | 866 | musb_writew(hw_ep->regs, MUSB_RXCSR, csr); |
885 | csr = musb_readw(hw_ep->regs, MUSB_RXCSR); | 867 | csr = musb_readw(hw_ep->regs, MUSB_RXCSR); |
886 | } | 868 | } |
@@ -923,15 +905,15 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb) | |||
923 | request = (struct usb_ctrlrequest *) urb->setup_packet; | 905 | request = (struct usb_ctrlrequest *) urb->setup_packet; |
924 | 906 | ||
925 | if (!request->wLength) { | 907 | if (!request->wLength) { |
926 | DBG(4, "start no-DATA\n"); | 908 | dev_dbg(musb->controller, "start no-DATA\n"); |
927 | break; | 909 | break; |
928 | } else if (request->bRequestType & USB_DIR_IN) { | 910 | } else if (request->bRequestType & USB_DIR_IN) { |
929 | DBG(4, "start IN-DATA\n"); | 911 | dev_dbg(musb->controller, "start IN-DATA\n"); |
930 | musb->ep0_stage = MUSB_EP0_IN; | 912 | musb->ep0_stage = MUSB_EP0_IN; |
931 | more = true; | 913 | more = true; |
932 | break; | 914 | break; |
933 | } else { | 915 | } else { |
934 | DBG(4, "start OUT-DATA\n"); | 916 | dev_dbg(musb->controller, "start OUT-DATA\n"); |
935 | musb->ep0_stage = MUSB_EP0_OUT; | 917 | musb->ep0_stage = MUSB_EP0_OUT; |
936 | more = true; | 918 | more = true; |
937 | } | 919 | } |
@@ -943,7 +925,7 @@ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb) | |||
943 | if (fifo_count) { | 925 | if (fifo_count) { |
944 | fifo_dest = (u8 *) (urb->transfer_buffer | 926 | fifo_dest = (u8 *) (urb->transfer_buffer |
945 | + urb->actual_length); | 927 | + urb->actual_length); |
946 | DBG(3, "Sending %d byte%s to ep0 fifo %p\n", | 928 | dev_dbg(musb->controller, "Sending %d byte%s to ep0 fifo %p\n", |
947 | fifo_count, | 929 | fifo_count, |
948 | (fifo_count == 1) ? "" : "s", | 930 | (fifo_count == 1) ? "" : "s", |
949 | fifo_dest); | 931 | fifo_dest); |
@@ -988,7 +970,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb) | |||
988 | ? musb_readb(epio, MUSB_COUNT0) | 970 | ? musb_readb(epio, MUSB_COUNT0) |
989 | : 0; | 971 | : 0; |
990 | 972 | ||
991 | DBG(4, "<== csr0 %04x, qh %p, count %d, urb %p, stage %d\n", | 973 | dev_dbg(musb->controller, "<== csr0 %04x, qh %p, count %d, urb %p, stage %d\n", |
992 | csr, qh, len, urb, musb->ep0_stage); | 974 | csr, qh, len, urb, musb->ep0_stage); |
993 | 975 | ||
994 | /* if we just did status stage, we are done */ | 976 | /* if we just did status stage, we are done */ |
@@ -999,15 +981,15 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb) | |||
999 | 981 | ||
1000 | /* prepare status */ | 982 | /* prepare status */ |
1001 | if (csr & MUSB_CSR0_H_RXSTALL) { | 983 | if (csr & MUSB_CSR0_H_RXSTALL) { |
1002 | DBG(6, "STALLING ENDPOINT\n"); | 984 | dev_dbg(musb->controller, "STALLING ENDPOINT\n"); |
1003 | status = -EPIPE; | 985 | status = -EPIPE; |
1004 | 986 | ||
1005 | } else if (csr & MUSB_CSR0_H_ERROR) { | 987 | } else if (csr & MUSB_CSR0_H_ERROR) { |
1006 | DBG(2, "no response, csr0 %04x\n", csr); | 988 | dev_dbg(musb->controller, "no response, csr0 %04x\n", csr); |
1007 | status = -EPROTO; | 989 | status = -EPROTO; |
1008 | 990 | ||
1009 | } else if (csr & MUSB_CSR0_H_NAKTIMEOUT) { | 991 | } else if (csr & MUSB_CSR0_H_NAKTIMEOUT) { |
1010 | DBG(2, "control NAK timeout\n"); | 992 | dev_dbg(musb->controller, "control NAK timeout\n"); |
1011 | 993 | ||
1012 | /* NOTE: this code path would be a good place to PAUSE a | 994 | /* NOTE: this code path would be a good place to PAUSE a |
1013 | * control transfer, if another one is queued, so that | 995 | * control transfer, if another one is queued, so that |
@@ -1022,7 +1004,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb) | |||
1022 | } | 1004 | } |
1023 | 1005 | ||
1024 | if (status) { | 1006 | if (status) { |
1025 | DBG(6, "aborting\n"); | 1007 | dev_dbg(musb->controller, "aborting\n"); |
1026 | retval = IRQ_HANDLED; | 1008 | retval = IRQ_HANDLED; |
1027 | if (urb) | 1009 | if (urb) |
1028 | urb->status = status; | 1010 | urb->status = status; |
@@ -1072,7 +1054,7 @@ irqreturn_t musb_h_ep0_irq(struct musb *musb) | |||
1072 | /* flag status stage */ | 1054 | /* flag status stage */ |
1073 | musb->ep0_stage = MUSB_EP0_STATUS; | 1055 | musb->ep0_stage = MUSB_EP0_STATUS; |
1074 | 1056 | ||
1075 | DBG(5, "ep0 STATUS, csr %04x\n", csr); | 1057 | dev_dbg(musb->controller, "ep0 STATUS, csr %04x\n", csr); |
1076 | 1058 | ||
1077 | } | 1059 | } |
1078 | musb_writew(epio, MUSB_CSR0, csr); | 1060 | musb_writew(epio, MUSB_CSR0, csr); |
@@ -1119,37 +1101,38 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1119 | u32 status = 0; | 1101 | u32 status = 0; |
1120 | void __iomem *mbase = musb->mregs; | 1102 | void __iomem *mbase = musb->mregs; |
1121 | struct dma_channel *dma; | 1103 | struct dma_channel *dma; |
1104 | bool transfer_pending = false; | ||
1122 | 1105 | ||
1123 | musb_ep_select(mbase, epnum); | 1106 | musb_ep_select(mbase, epnum); |
1124 | tx_csr = musb_readw(epio, MUSB_TXCSR); | 1107 | tx_csr = musb_readw(epio, MUSB_TXCSR); |
1125 | 1108 | ||
1126 | /* with CPPI, DMA sometimes triggers "extra" irqs */ | 1109 | /* with CPPI, DMA sometimes triggers "extra" irqs */ |
1127 | if (!urb) { | 1110 | if (!urb) { |
1128 | DBG(4, "extra TX%d ready, csr %04x\n", epnum, tx_csr); | 1111 | dev_dbg(musb->controller, "extra TX%d ready, csr %04x\n", epnum, tx_csr); |
1129 | return; | 1112 | return; |
1130 | } | 1113 | } |
1131 | 1114 | ||
1132 | pipe = urb->pipe; | 1115 | pipe = urb->pipe; |
1133 | dma = is_dma_capable() ? hw_ep->tx_channel : NULL; | 1116 | dma = is_dma_capable() ? hw_ep->tx_channel : NULL; |
1134 | DBG(4, "OUT/TX%d end, csr %04x%s\n", epnum, tx_csr, | 1117 | dev_dbg(musb->controller, "OUT/TX%d end, csr %04x%s\n", epnum, tx_csr, |
1135 | dma ? ", dma" : ""); | 1118 | dma ? ", dma" : ""); |
1136 | 1119 | ||
1137 | /* check for errors */ | 1120 | /* check for errors */ |
1138 | if (tx_csr & MUSB_TXCSR_H_RXSTALL) { | 1121 | if (tx_csr & MUSB_TXCSR_H_RXSTALL) { |
1139 | /* dma was disabled, fifo flushed */ | 1122 | /* dma was disabled, fifo flushed */ |
1140 | DBG(3, "TX end %d stall\n", epnum); | 1123 | dev_dbg(musb->controller, "TX end %d stall\n", epnum); |
1141 | 1124 | ||
1142 | /* stall; record URB status */ | 1125 | /* stall; record URB status */ |
1143 | status = -EPIPE; | 1126 | status = -EPIPE; |
1144 | 1127 | ||
1145 | } else if (tx_csr & MUSB_TXCSR_H_ERROR) { | 1128 | } else if (tx_csr & MUSB_TXCSR_H_ERROR) { |
1146 | /* (NON-ISO) dma was disabled, fifo flushed */ | 1129 | /* (NON-ISO) dma was disabled, fifo flushed */ |
1147 | DBG(3, "TX 3strikes on ep=%d\n", epnum); | 1130 | dev_dbg(musb->controller, "TX 3strikes on ep=%d\n", epnum); |
1148 | 1131 | ||
1149 | status = -ETIMEDOUT; | 1132 | status = -ETIMEDOUT; |
1150 | 1133 | ||
1151 | } else if (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) { | 1134 | } else if (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) { |
1152 | DBG(6, "TX end=%d device not responding\n", epnum); | 1135 | dev_dbg(musb->controller, "TX end=%d device not responding\n", epnum); |
1153 | 1136 | ||
1154 | /* NOTE: this code path would be a good place to PAUSE a | 1137 | /* NOTE: this code path would be a good place to PAUSE a |
1155 | * transfer, if there's some other (nonperiodic) tx urb | 1138 | * transfer, if there's some other (nonperiodic) tx urb |
@@ -1194,7 +1177,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1194 | 1177 | ||
1195 | /* second cppi case */ | 1178 | /* second cppi case */ |
1196 | if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { | 1179 | if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { |
1197 | DBG(4, "extra TX%d ready, csr %04x\n", epnum, tx_csr); | 1180 | dev_dbg(musb->controller, "extra TX%d ready, csr %04x\n", epnum, tx_csr); |
1198 | return; | 1181 | return; |
1199 | } | 1182 | } |
1200 | 1183 | ||
@@ -1253,7 +1236,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1253 | * FIFO mode too... | 1236 | * FIFO mode too... |
1254 | */ | 1237 | */ |
1255 | if (tx_csr & (MUSB_TXCSR_FIFONOTEMPTY | MUSB_TXCSR_TXPKTRDY)) { | 1238 | if (tx_csr & (MUSB_TXCSR_FIFONOTEMPTY | MUSB_TXCSR_TXPKTRDY)) { |
1256 | DBG(2, "DMA complete but packet still in FIFO, " | 1239 | dev_dbg(musb->controller, "DMA complete but packet still in FIFO, " |
1257 | "CSR %04x\n", tx_csr); | 1240 | "CSR %04x\n", tx_csr); |
1258 | return; | 1241 | return; |
1259 | } | 1242 | } |
@@ -1279,7 +1262,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1279 | offset = d->offset; | 1262 | offset = d->offset; |
1280 | length = d->length; | 1263 | length = d->length; |
1281 | } | 1264 | } |
1282 | } else if (dma) { | 1265 | } else if (dma && urb->transfer_buffer_length == qh->offset) { |
1283 | done = true; | 1266 | done = true; |
1284 | } else { | 1267 | } else { |
1285 | /* see if we need to send more data, or ZLP */ | 1268 | /* see if we need to send more data, or ZLP */ |
@@ -1292,6 +1275,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1292 | if (!done) { | 1275 | if (!done) { |
1293 | offset = qh->offset; | 1276 | offset = qh->offset; |
1294 | length = urb->transfer_buffer_length - offset; | 1277 | length = urb->transfer_buffer_length - offset; |
1278 | transfer_pending = true; | ||
1295 | } | 1279 | } |
1296 | } | 1280 | } |
1297 | } | 1281 | } |
@@ -1311,7 +1295,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1311 | urb->actual_length = qh->offset; | 1295 | urb->actual_length = qh->offset; |
1312 | musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT); | 1296 | musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT); |
1313 | return; | 1297 | return; |
1314 | } else if (usb_pipeisoc(pipe) && dma) { | 1298 | } else if ((usb_pipeisoc(pipe) || transfer_pending) && dma) { |
1315 | if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb, | 1299 | if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb, |
1316 | offset, length)) { | 1300 | offset, length)) { |
1317 | if (is_cppi_enabled() || tusb_dma_omap()) | 1301 | if (is_cppi_enabled() || tusb_dma_omap()) |
@@ -1319,7 +1303,7 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1319 | return; | 1303 | return; |
1320 | } | 1304 | } |
1321 | } else if (tx_csr & MUSB_TXCSR_DMAENAB) { | 1305 | } else if (tx_csr & MUSB_TXCSR_DMAENAB) { |
1322 | DBG(1, "not complete, but DMA enabled?\n"); | 1306 | dev_dbg(musb->controller, "not complete, but DMA enabled?\n"); |
1323 | return; | 1307 | return; |
1324 | } | 1308 | } |
1325 | 1309 | ||
@@ -1332,6 +1316,8 @@ void musb_host_tx(struct musb *musb, u8 epnum) | |||
1332 | */ | 1316 | */ |
1333 | if (length > qh->maxpacket) | 1317 | if (length > qh->maxpacket) |
1334 | length = qh->maxpacket; | 1318 | length = qh->maxpacket; |
1319 | /* Unmap the buffer so that CPU can use it */ | ||
1320 | usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); | ||
1335 | musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); | 1321 | musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); |
1336 | qh->segsize = length; | 1322 | qh->segsize = length; |
1337 | 1323 | ||
@@ -1458,7 +1444,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1458 | * usbtest #11 (unlinks) triggers it regularly, sometimes | 1444 | * usbtest #11 (unlinks) triggers it regularly, sometimes |
1459 | * with fifo full. (Only with DMA??) | 1445 | * with fifo full. (Only with DMA??) |
1460 | */ | 1446 | */ |
1461 | DBG(3, "BOGUS RX%d ready, csr %04x, count %d\n", epnum, val, | 1447 | dev_dbg(musb->controller, "BOGUS RX%d ready, csr %04x, count %d\n", epnum, val, |
1462 | musb_readw(epio, MUSB_RXCOUNT)); | 1448 | musb_readw(epio, MUSB_RXCOUNT)); |
1463 | musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG); | 1449 | musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG); |
1464 | return; | 1450 | return; |
@@ -1466,20 +1452,20 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1466 | 1452 | ||
1467 | pipe = urb->pipe; | 1453 | pipe = urb->pipe; |
1468 | 1454 | ||
1469 | DBG(5, "<== hw %d rxcsr %04x, urb actual %d (+dma %zu)\n", | 1455 | dev_dbg(musb->controller, "<== hw %d rxcsr %04x, urb actual %d (+dma %zu)\n", |
1470 | epnum, rx_csr, urb->actual_length, | 1456 | epnum, rx_csr, urb->actual_length, |
1471 | dma ? dma->actual_len : 0); | 1457 | dma ? dma->actual_len : 0); |
1472 | 1458 | ||
1473 | /* check for errors, concurrent stall & unlink is not really | 1459 | /* check for errors, concurrent stall & unlink is not really |
1474 | * handled yet! */ | 1460 | * handled yet! */ |
1475 | if (rx_csr & MUSB_RXCSR_H_RXSTALL) { | 1461 | if (rx_csr & MUSB_RXCSR_H_RXSTALL) { |
1476 | DBG(3, "RX end %d STALL\n", epnum); | 1462 | dev_dbg(musb->controller, "RX end %d STALL\n", epnum); |
1477 | 1463 | ||
1478 | /* stall; record URB status */ | 1464 | /* stall; record URB status */ |
1479 | status = -EPIPE; | 1465 | status = -EPIPE; |
1480 | 1466 | ||
1481 | } else if (rx_csr & MUSB_RXCSR_H_ERROR) { | 1467 | } else if (rx_csr & MUSB_RXCSR_H_ERROR) { |
1482 | DBG(3, "end %d RX proto error\n", epnum); | 1468 | dev_dbg(musb->controller, "end %d RX proto error\n", epnum); |
1483 | 1469 | ||
1484 | status = -EPROTO; | 1470 | status = -EPROTO; |
1485 | musb_writeb(epio, MUSB_RXINTERVAL, 0); | 1471 | musb_writeb(epio, MUSB_RXINTERVAL, 0); |
@@ -1487,7 +1473,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1487 | } else if (rx_csr & MUSB_RXCSR_DATAERROR) { | 1473 | } else if (rx_csr & MUSB_RXCSR_DATAERROR) { |
1488 | 1474 | ||
1489 | if (USB_ENDPOINT_XFER_ISOC != qh->type) { | 1475 | if (USB_ENDPOINT_XFER_ISOC != qh->type) { |
1490 | DBG(6, "RX end %d NAK timeout\n", epnum); | 1476 | dev_dbg(musb->controller, "RX end %d NAK timeout\n", epnum); |
1491 | 1477 | ||
1492 | /* NOTE: NAKing is *NOT* an error, so we want to | 1478 | /* NOTE: NAKing is *NOT* an error, so we want to |
1493 | * continue. Except ... if there's a request for | 1479 | * continue. Except ... if there's a request for |
@@ -1510,12 +1496,12 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1510 | 1496 | ||
1511 | goto finish; | 1497 | goto finish; |
1512 | } else { | 1498 | } else { |
1513 | DBG(4, "RX end %d ISO data error\n", epnum); | 1499 | dev_dbg(musb->controller, "RX end %d ISO data error\n", epnum); |
1514 | /* packet error reported later */ | 1500 | /* packet error reported later */ |
1515 | iso_err = true; | 1501 | iso_err = true; |
1516 | } | 1502 | } |
1517 | } else if (rx_csr & MUSB_RXCSR_INCOMPRX) { | 1503 | } else if (rx_csr & MUSB_RXCSR_INCOMPRX) { |
1518 | DBG(3, "end %d high bandwidth incomplete ISO packet RX\n", | 1504 | dev_dbg(musb->controller, "end %d high bandwidth incomplete ISO packet RX\n", |
1519 | epnum); | 1505 | epnum); |
1520 | status = -EPROTO; | 1506 | status = -EPROTO; |
1521 | } | 1507 | } |
@@ -1561,7 +1547,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1561 | done = true; | 1547 | done = true; |
1562 | } | 1548 | } |
1563 | 1549 | ||
1564 | DBG(2, "RXCSR%d %04x, reqpkt, len %zu%s\n", epnum, rx_csr, | 1550 | dev_dbg(musb->controller, "RXCSR%d %04x, reqpkt, len %zu%s\n", epnum, rx_csr, |
1565 | xfer_len, dma ? ", dma" : ""); | 1551 | xfer_len, dma ? ", dma" : ""); |
1566 | rx_csr &= ~MUSB_RXCSR_H_REQPKT; | 1552 | rx_csr &= ~MUSB_RXCSR_H_REQPKT; |
1567 | 1553 | ||
@@ -1589,7 +1575,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1589 | /* even if there was an error, we did the dma | 1575 | /* even if there was an error, we did the dma |
1590 | * for iso_frame_desc->length | 1576 | * for iso_frame_desc->length |
1591 | */ | 1577 | */ |
1592 | if (d->status != EILSEQ && d->status != -EOVERFLOW) | 1578 | if (d->status != -EILSEQ && d->status != -EOVERFLOW) |
1593 | d->status = 0; | 1579 | d->status = 0; |
1594 | 1580 | ||
1595 | if (++qh->iso_idx >= urb->number_of_packets) | 1581 | if (++qh->iso_idx >= urb->number_of_packets) |
@@ -1611,7 +1597,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1611 | MUSB_RXCSR_H_WZC_BITS | val); | 1597 | MUSB_RXCSR_H_WZC_BITS | val); |
1612 | } | 1598 | } |
1613 | 1599 | ||
1614 | DBG(4, "ep %d dma %s, rxcsr %04x, rxcount %d\n", epnum, | 1600 | dev_dbg(musb->controller, "ep %d dma %s, rxcsr %04x, rxcount %d\n", epnum, |
1615 | done ? "off" : "reset", | 1601 | done ? "off" : "reset", |
1616 | musb_readw(epio, MUSB_RXCSR), | 1602 | musb_readw(epio, MUSB_RXCSR), |
1617 | musb_readw(epio, MUSB_RXCOUNT)); | 1603 | musb_readw(epio, MUSB_RXCOUNT)); |
@@ -1644,7 +1630,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1644 | 1630 | ||
1645 | rx_count = musb_readw(epio, MUSB_RXCOUNT); | 1631 | rx_count = musb_readw(epio, MUSB_RXCOUNT); |
1646 | 1632 | ||
1647 | DBG(2, "RX%d count %d, buffer 0x%x len %d/%d\n", | 1633 | dev_dbg(musb->controller, "RX%d count %d, buffer 0x%x len %d/%d\n", |
1648 | epnum, rx_count, | 1634 | epnum, rx_count, |
1649 | urb->transfer_dma | 1635 | urb->transfer_dma |
1650 | + urb->actual_length, | 1636 | + urb->actual_length, |
@@ -1668,7 +1654,7 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1668 | d_status = -EOVERFLOW; | 1654 | d_status = -EOVERFLOW; |
1669 | urb->error_count++; | 1655 | urb->error_count++; |
1670 | } | 1656 | } |
1671 | DBG(2, "** OVERFLOW %d into %d\n",\ | 1657 | dev_dbg(musb->controller, "** OVERFLOW %d into %d\n",\ |
1672 | rx_count, d->length); | 1658 | rx_count, d->length); |
1673 | 1659 | ||
1674 | length = d->length; | 1660 | length = d->length; |
@@ -1752,9 +1738,11 @@ void musb_host_rx(struct musb *musb, u8 epnum) | |||
1752 | #endif /* Mentor DMA */ | 1738 | #endif /* Mentor DMA */ |
1753 | 1739 | ||
1754 | if (!dma) { | 1740 | if (!dma) { |
1741 | /* Unmap the buffer so that CPU can use it */ | ||
1742 | usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); | ||
1755 | done = musb_host_packet_rx(musb, urb, | 1743 | done = musb_host_packet_rx(musb, urb, |
1756 | epnum, iso_err); | 1744 | epnum, iso_err); |
1757 | DBG(6, "read %spacket\n", done ? "last " : ""); | 1745 | dev_dbg(musb->controller, "read %spacket\n", done ? "last " : ""); |
1758 | } | 1746 | } |
1759 | } | 1747 | } |
1760 | 1748 | ||
@@ -1875,7 +1863,7 @@ static int musb_schedule( | |||
1875 | idle = 1; | 1863 | idle = 1; |
1876 | qh->mux = 0; | 1864 | qh->mux = 0; |
1877 | hw_ep = musb->endpoints + best_end; | 1865 | hw_ep = musb->endpoints + best_end; |
1878 | DBG(4, "qh %p periodic slot %d\n", qh, best_end); | 1866 | dev_dbg(musb->controller, "qh %p periodic slot %d\n", qh, best_end); |
1879 | success: | 1867 | success: |
1880 | if (head) { | 1868 | if (head) { |
1881 | idle = list_empty(head); | 1869 | idle = list_empty(head); |
@@ -2081,6 +2069,7 @@ done: | |||
2081 | static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) | 2069 | static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) |
2082 | { | 2070 | { |
2083 | struct musb_hw_ep *ep = qh->hw_ep; | 2071 | struct musb_hw_ep *ep = qh->hw_ep; |
2072 | struct musb *musb = ep->musb; | ||
2084 | void __iomem *epio = ep->regs; | 2073 | void __iomem *epio = ep->regs; |
2085 | unsigned hw_end = ep->epnum; | 2074 | unsigned hw_end = ep->epnum; |
2086 | void __iomem *regs = ep->musb->mregs; | 2075 | void __iomem *regs = ep->musb->mregs; |
@@ -2096,7 +2085,7 @@ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) | |||
2096 | dma = is_in ? ep->rx_channel : ep->tx_channel; | 2085 | dma = is_in ? ep->rx_channel : ep->tx_channel; |
2097 | if (dma) { | 2086 | if (dma) { |
2098 | status = ep->musb->dma_controller->channel_abort(dma); | 2087 | status = ep->musb->dma_controller->channel_abort(dma); |
2099 | DBG(status ? 1 : 3, | 2088 | dev_dbg(musb->controller, |
2100 | "abort %cX%d DMA for urb %p --> %d\n", | 2089 | "abort %cX%d DMA for urb %p --> %d\n", |
2101 | is_in ? 'R' : 'T', ep->epnum, | 2090 | is_in ? 'R' : 'T', ep->epnum, |
2102 | urb, status); | 2091 | urb, status); |
@@ -2143,7 +2132,7 @@ static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
2143 | int is_in = usb_pipein(urb->pipe); | 2132 | int is_in = usb_pipein(urb->pipe); |
2144 | int ret; | 2133 | int ret; |
2145 | 2134 | ||
2146 | DBG(4, "urb=%p, dev%d ep%d%s\n", urb, | 2135 | dev_dbg(musb->controller, "urb=%p, dev%d ep%d%s\n", urb, |
2147 | usb_pipedevice(urb->pipe), | 2136 | usb_pipedevice(urb->pipe), |
2148 | usb_pipeendpoint(urb->pipe), | 2137 | usb_pipeendpoint(urb->pipe), |
2149 | is_in ? "in" : "out"); | 2138 | is_in ? "in" : "out"); |
@@ -2298,7 +2287,7 @@ static int musb_bus_suspend(struct usb_hcd *hcd) | |||
2298 | 2287 | ||
2299 | if (musb->is_active) { | 2288 | if (musb->is_active) { |
2300 | WARNING("trying to suspend as %s while active\n", | 2289 | WARNING("trying to suspend as %s while active\n", |
2301 | otg_state_string(musb)); | 2290 | otg_state_string(musb->xceiv->state)); |
2302 | return -EBUSY; | 2291 | return -EBUSY; |
2303 | } else | 2292 | } else |
2304 | return 0; | 2293 | return 0; |