diff options
Diffstat (limited to 'drivers/usb/gadget/omap_udc.c')
-rw-r--r-- | drivers/usb/gadget/omap_udc.c | 403 |
1 files changed, 165 insertions, 238 deletions
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index a460e8c204f4..b26c7d68cc06 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -36,9 +36,9 @@ | |||
36 | #include <linux/dma-mapping.h> | 36 | #include <linux/dma-mapping.h> |
37 | #include <linux/clk.h> | 37 | #include <linux/clk.h> |
38 | #include <linux/prefetch.h> | 38 | #include <linux/prefetch.h> |
39 | #include <linux/io.h> | ||
39 | 40 | ||
40 | #include <asm/byteorder.h> | 41 | #include <asm/byteorder.h> |
41 | #include <asm/io.h> | ||
42 | #include <asm/irq.h> | 42 | #include <asm/irq.h> |
43 | #include <asm/unaligned.h> | 43 | #include <asm/unaligned.h> |
44 | #include <asm/mach-types.h> | 44 | #include <asm/mach-types.h> |
@@ -59,11 +59,6 @@ | |||
59 | #define DRIVER_DESC "OMAP UDC driver" | 59 | #define DRIVER_DESC "OMAP UDC driver" |
60 | #define DRIVER_VERSION "4 October 2004" | 60 | #define DRIVER_VERSION "4 October 2004" |
61 | 61 | ||
62 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
63 | |||
64 | #define OMAP2_DMA_CH(ch) (((ch) - 1) << 1) | ||
65 | #define OMAP24XX_DMA(name, ch) (OMAP24XX_DMA_##name + OMAP2_DMA_CH(ch)) | ||
66 | |||
67 | /* | 62 | /* |
68 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the | 63 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the |
69 | * D+ pullup to allow enumeration. That's too early for the gadget | 64 | * D+ pullup to allow enumeration. That's too early for the gadget |
@@ -87,14 +82,14 @@ | |||
87 | #ifdef USE_ISO | 82 | #ifdef USE_ISO |
88 | static unsigned fifo_mode = 3; | 83 | static unsigned fifo_mode = 3; |
89 | #else | 84 | #else |
90 | static unsigned fifo_mode = 0; | 85 | static unsigned fifo_mode; |
91 | #endif | 86 | #endif |
92 | 87 | ||
93 | /* "modprobe omap_udc fifo_mode=42", or else as a kernel | 88 | /* "modprobe omap_udc fifo_mode=42", or else as a kernel |
94 | * boot parameter "omap_udc:fifo_mode=42" | 89 | * boot parameter "omap_udc:fifo_mode=42" |
95 | */ | 90 | */ |
96 | module_param (fifo_mode, uint, 0); | 91 | module_param(fifo_mode, uint, 0); |
97 | MODULE_PARM_DESC (fifo_mode, "endpoint configuration"); | 92 | MODULE_PARM_DESC(fifo_mode, "endpoint configuration"); |
98 | 93 | ||
99 | #ifdef USE_DMA | 94 | #ifdef USE_DMA |
100 | static bool use_dma = 1; | 95 | static bool use_dma = 1; |
@@ -102,8 +97,8 @@ static bool use_dma = 1; | |||
102 | /* "modprobe omap_udc use_dma=y", or else as a kernel | 97 | /* "modprobe omap_udc use_dma=y", or else as a kernel |
103 | * boot parameter "omap_udc:use_dma=y" | 98 | * boot parameter "omap_udc:use_dma=y" |
104 | */ | 99 | */ |
105 | module_param (use_dma, bool, 0); | 100 | module_param(use_dma, bool, 0); |
106 | MODULE_PARM_DESC (use_dma, "enable/disable DMA"); | 101 | MODULE_PARM_DESC(use_dma, "enable/disable DMA"); |
107 | #else /* !USE_DMA */ | 102 | #else /* !USE_DMA */ |
108 | 103 | ||
109 | /* save a bit of code */ | 104 | /* save a bit of code */ |
@@ -111,8 +106,8 @@ MODULE_PARM_DESC (use_dma, "enable/disable DMA"); | |||
111 | #endif /* !USE_DMA */ | 106 | #endif /* !USE_DMA */ |
112 | 107 | ||
113 | 108 | ||
114 | static const char driver_name [] = "omap_udc"; | 109 | static const char driver_name[] = "omap_udc"; |
115 | static const char driver_desc [] = DRIVER_DESC; | 110 | static const char driver_desc[] = DRIVER_DESC; |
116 | 111 | ||
117 | /*-------------------------------------------------------------------------*/ | 112 | /*-------------------------------------------------------------------------*/ |
118 | 113 | ||
@@ -250,7 +245,7 @@ static int omap_ep_disable(struct usb_ep *_ep) | |||
250 | 245 | ||
251 | spin_lock_irqsave(&ep->udc->lock, flags); | 246 | spin_lock_irqsave(&ep->udc->lock, flags); |
252 | ep->ep.desc = NULL; | 247 | ep->ep.desc = NULL; |
253 | nuke (ep, -ESHUTDOWN); | 248 | nuke(ep, -ESHUTDOWN); |
254 | ep->ep.maxpacket = ep->maxpacket; | 249 | ep->ep.maxpacket = ep->maxpacket; |
255 | ep->has_dma = 0; | 250 | ep->has_dma = 0; |
256 | omap_writew(UDC_SET_HALT, UDC_CTRL); | 251 | omap_writew(UDC_SET_HALT, UDC_CTRL); |
@@ -271,10 +266,11 @@ omap_alloc_request(struct usb_ep *ep, gfp_t gfp_flags) | |||
271 | struct omap_req *req; | 266 | struct omap_req *req; |
272 | 267 | ||
273 | req = kzalloc(sizeof(*req), gfp_flags); | 268 | req = kzalloc(sizeof(*req), gfp_flags); |
274 | if (req) { | 269 | if (!req) |
275 | req->req.dma = DMA_ADDR_INVALID; | 270 | return NULL; |
276 | INIT_LIST_HEAD (&req->queue); | 271 | |
277 | } | 272 | INIT_LIST_HEAD(&req->queue); |
273 | |||
278 | return &req->req; | 274 | return &req->req; |
279 | } | 275 | } |
280 | 276 | ||
@@ -283,8 +279,7 @@ omap_free_request(struct usb_ep *ep, struct usb_request *_req) | |||
283 | { | 279 | { |
284 | struct omap_req *req = container_of(_req, struct omap_req, req); | 280 | struct omap_req *req = container_of(_req, struct omap_req, req); |
285 | 281 | ||
286 | if (_req) | 282 | kfree(req); |
287 | kfree (req); | ||
288 | } | 283 | } |
289 | 284 | ||
290 | /*-------------------------------------------------------------------------*/ | 285 | /*-------------------------------------------------------------------------*/ |
@@ -292,6 +287,7 @@ omap_free_request(struct usb_ep *ep, struct usb_request *_req) | |||
292 | static void | 287 | static void |
293 | done(struct omap_ep *ep, struct omap_req *req, int status) | 288 | done(struct omap_ep *ep, struct omap_req *req, int status) |
294 | { | 289 | { |
290 | struct omap_udc *udc = ep->udc; | ||
295 | unsigned stopped = ep->stopped; | 291 | unsigned stopped = ep->stopped; |
296 | 292 | ||
297 | list_del_init(&req->queue); | 293 | list_del_init(&req->queue); |
@@ -301,22 +297,9 @@ done(struct omap_ep *ep, struct omap_req *req, int status) | |||
301 | else | 297 | else |
302 | status = req->req.status; | 298 | status = req->req.status; |
303 | 299 | ||
304 | if (use_dma && ep->has_dma) { | 300 | if (use_dma && ep->has_dma) |
305 | if (req->mapped) { | 301 | usb_gadget_unmap_request(&udc->gadget, &req->req, |
306 | dma_unmap_single(ep->udc->gadget.dev.parent, | 302 | (ep->bEndpointAddress & USB_DIR_IN)); |
307 | req->req.dma, req->req.length, | ||
308 | (ep->bEndpointAddress & USB_DIR_IN) | ||
309 | ? DMA_TO_DEVICE | ||
310 | : DMA_FROM_DEVICE); | ||
311 | req->req.dma = DMA_ADDR_INVALID; | ||
312 | req->mapped = 0; | ||
313 | } else | ||
314 | dma_sync_single_for_cpu(ep->udc->gadget.dev.parent, | ||
315 | req->req.dma, req->req.length, | ||
316 | (ep->bEndpointAddress & USB_DIR_IN) | ||
317 | ? DMA_TO_DEVICE | ||
318 | : DMA_FROM_DEVICE); | ||
319 | } | ||
320 | 303 | ||
321 | #ifndef USB_TRACE | 304 | #ifndef USB_TRACE |
322 | if (status && status != -ESHUTDOWN) | 305 | if (status && status != -ESHUTDOWN) |
@@ -364,10 +347,10 @@ write_packet(u8 *buf, struct omap_req *req, unsigned max) | |||
364 | return len; | 347 | return len; |
365 | } | 348 | } |
366 | 349 | ||
367 | // FIXME change r/w fifo calling convention | 350 | /* FIXME change r/w fifo calling convention */ |
368 | 351 | ||
369 | 352 | ||
370 | // return: 0 = still running, 1 = completed, negative = errno | 353 | /* return: 0 = still running, 1 = completed, negative = errno */ |
371 | static int write_fifo(struct omap_ep *ep, struct omap_req *req) | 354 | static int write_fifo(struct omap_ep *ep, struct omap_req *req) |
372 | { | 355 | { |
373 | u8 *buf; | 356 | u8 *buf; |
@@ -429,7 +412,7 @@ read_packet(u8 *buf, struct omap_req *req, unsigned avail) | |||
429 | return len; | 412 | return len; |
430 | } | 413 | } |
431 | 414 | ||
432 | // return: 0 = still running, 1 = queue empty, negative = errno | 415 | /* return: 0 = still running, 1 = queue empty, negative = errno */ |
433 | static int read_fifo(struct omap_ep *ep, struct omap_req *req) | 416 | static int read_fifo(struct omap_ep *ep, struct omap_req *req) |
434 | { | 417 | { |
435 | u8 *buf; | 418 | u8 *buf; |
@@ -536,12 +519,8 @@ static void next_in_dma(struct omap_ep *ep, struct omap_req *req) | |||
536 | : OMAP_DMA_SYNC_ELEMENT; | 519 | : OMAP_DMA_SYNC_ELEMENT; |
537 | int dma_trigger = 0; | 520 | int dma_trigger = 0; |
538 | 521 | ||
539 | if (cpu_is_omap24xx()) | ||
540 | dma_trigger = OMAP24XX_DMA(USB_W2FC_TX0, ep->dma_channel); | ||
541 | |||
542 | /* measure length in either bytes or packets */ | 522 | /* measure length in either bytes or packets */ |
543 | if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC) | 523 | if ((cpu_is_omap16xx() && length <= UDC_TXN_TSC) |
544 | || (cpu_is_omap24xx() && length < ep->maxpacket) | ||
545 | || (cpu_is_omap15xx() && length < ep->maxpacket)) { | 524 | || (cpu_is_omap15xx() && length < ep->maxpacket)) { |
546 | txdma_ctrl = UDC_TXN_EOT | length; | 525 | txdma_ctrl = UDC_TXN_EOT | length; |
547 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, | 526 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, |
@@ -600,28 +579,14 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req) | |||
600 | int dma_trigger = 0; | 579 | int dma_trigger = 0; |
601 | u16 w; | 580 | u16 w; |
602 | 581 | ||
603 | if (cpu_is_omap24xx()) | 582 | /* set up this DMA transfer, enable the fifo, start */ |
604 | dma_trigger = OMAP24XX_DMA(USB_W2FC_RX0, ep->dma_channel); | 583 | packets /= ep->ep.maxpacket; |
605 | 584 | packets = min(packets, (unsigned)UDC_RXN_TC + 1); | |
606 | /* NOTE: we filtered out "short reads" before, so we know | 585 | req->dma_bytes = packets * ep->ep.maxpacket; |
607 | * the buffer has only whole numbers of packets. | 586 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, |
608 | * except MODE SELECT(6) sent the 24 bytes data in OMAP24XX DMA mode | 587 | ep->ep.maxpacket >> 1, packets, |
609 | */ | 588 | OMAP_DMA_SYNC_ELEMENT, |
610 | if (cpu_is_omap24xx() && packets < ep->maxpacket) { | 589 | dma_trigger, 0); |
611 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, | ||
612 | packets, 1, OMAP_DMA_SYNC_ELEMENT, | ||
613 | dma_trigger, 0); | ||
614 | req->dma_bytes = packets; | ||
615 | } else { | ||
616 | /* set up this DMA transfer, enable the fifo, start */ | ||
617 | packets /= ep->ep.maxpacket; | ||
618 | packets = min(packets, (unsigned)UDC_RXN_TC + 1); | ||
619 | req->dma_bytes = packets * ep->ep.maxpacket; | ||
620 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, | ||
621 | ep->ep.maxpacket >> 1, packets, | ||
622 | OMAP_DMA_SYNC_ELEMENT, | ||
623 | dma_trigger, 0); | ||
624 | } | ||
625 | omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, | 590 | omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, |
626 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, | 591 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, |
627 | 0, 0); | 592 | 0, 0); |
@@ -683,7 +648,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src) | |||
683 | } | 648 | } |
684 | omap_writew(UDC_TXN_DONE, UDC_IRQ_SRC); | 649 | omap_writew(UDC_TXN_DONE, UDC_IRQ_SRC); |
685 | 650 | ||
686 | if (!list_empty (&ep->queue)) { | 651 | if (!list_empty(&ep->queue)) { |
687 | req = container_of(ep->queue.next, | 652 | req = container_of(ep->queue.next, |
688 | struct omap_req, queue); | 653 | struct omap_req, queue); |
689 | next_in_dma(ep, req); | 654 | next_in_dma(ep, req); |
@@ -702,7 +667,7 @@ static void dma_irq(struct omap_udc *udc, u16 irq_src) | |||
702 | } | 667 | } |
703 | omap_writew(UDC_RXN_EOT, UDC_IRQ_SRC); | 668 | omap_writew(UDC_RXN_EOT, UDC_IRQ_SRC); |
704 | 669 | ||
705 | if (!list_empty (&ep->queue)) { | 670 | if (!list_empty(&ep->queue)) { |
706 | req = container_of(ep->queue.next, | 671 | req = container_of(ep->queue.next, |
707 | struct omap_req, queue); | 672 | struct omap_req, queue); |
708 | next_out_dma(ep, req); | 673 | next_out_dma(ep, req); |
@@ -760,10 +725,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
760 | ep->dma_channel = channel; | 725 | ep->dma_channel = channel; |
761 | 726 | ||
762 | if (is_in) { | 727 | if (is_in) { |
763 | if (cpu_is_omap24xx()) | 728 | dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel; |
764 | dma_channel = OMAP24XX_DMA(USB_W2FC_TX0, channel); | ||
765 | else | ||
766 | dma_channel = OMAP_DMA_USB_W2FC_TX0 - 1 + channel; | ||
767 | status = omap_request_dma(dma_channel, | 729 | status = omap_request_dma(dma_channel, |
768 | ep->ep.name, dma_error, ep, &ep->lch); | 730 | ep->ep.name, dma_error, ep, &ep->lch); |
769 | if (status == 0) { | 731 | if (status == 0) { |
@@ -780,11 +742,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
780 | 0, 0); | 742 | 0, 0); |
781 | } | 743 | } |
782 | } else { | 744 | } else { |
783 | if (cpu_is_omap24xx()) | 745 | dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel; |
784 | dma_channel = OMAP24XX_DMA(USB_W2FC_RX0, channel); | ||
785 | else | ||
786 | dma_channel = OMAP_DMA_USB_W2FC_RX0 - 1 + channel; | ||
787 | |||
788 | status = omap_request_dma(dma_channel, | 746 | status = omap_request_dma(dma_channel, |
789 | ep->ep.name, dma_error, ep, &ep->lch); | 747 | ep->ep.name, dma_error, ep, &ep->lch); |
790 | if (status == 0) { | 748 | if (status == 0) { |
@@ -808,7 +766,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
808 | omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ); | 766 | omap_disable_dma_irq(ep->lch, OMAP_DMA_BLOCK_IRQ); |
809 | 767 | ||
810 | /* channel type P: hw synch (fifo) */ | 768 | /* channel type P: hw synch (fifo) */ |
811 | if (cpu_class_is_omap1() && !cpu_is_omap15xx()) | 769 | if (!cpu_is_omap15xx()) |
812 | omap_set_dma_channel_mode(ep->lch, OMAP_DMA_LCH_P); | 770 | omap_set_dma_channel_mode(ep->lch, OMAP_DMA_LCH_P); |
813 | } | 771 | } |
814 | 772 | ||
@@ -928,13 +886,11 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
928 | 886 | ||
929 | /* this isn't bogus, but OMAP DMA isn't the only hardware to | 887 | /* this isn't bogus, but OMAP DMA isn't the only hardware to |
930 | * have a hard time with partial packet reads... reject it. | 888 | * have a hard time with partial packet reads... reject it. |
931 | * Except OMAP2 can handle the small packets. | ||
932 | */ | 889 | */ |
933 | if (use_dma | 890 | if (use_dma |
934 | && ep->has_dma | 891 | && ep->has_dma |
935 | && ep->bEndpointAddress != 0 | 892 | && ep->bEndpointAddress != 0 |
936 | && (ep->bEndpointAddress & USB_DIR_IN) == 0 | 893 | && (ep->bEndpointAddress & USB_DIR_IN) == 0 |
937 | && !cpu_class_is_omap2() | ||
938 | && (req->req.length % ep->ep.maxpacket) != 0) { | 894 | && (req->req.length % ep->ep.maxpacket) != 0) { |
939 | DBG("%s, no partial packet OUT reads\n", __func__); | 895 | DBG("%s, no partial packet OUT reads\n", __func__); |
940 | return -EMSGSIZE; | 896 | return -EMSGSIZE; |
@@ -944,26 +900,9 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
944 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) | 900 | if (!udc->driver || udc->gadget.speed == USB_SPEED_UNKNOWN) |
945 | return -ESHUTDOWN; | 901 | return -ESHUTDOWN; |
946 | 902 | ||
947 | if (use_dma && ep->has_dma) { | 903 | if (use_dma && ep->has_dma) |
948 | if (req->req.dma == DMA_ADDR_INVALID) { | 904 | usb_gadget_map_request(&udc->gadget, &req->req, |
949 | req->req.dma = dma_map_single( | 905 | (ep->bEndpointAddress & USB_DIR_IN)); |
950 | ep->udc->gadget.dev.parent, | ||
951 | req->req.buf, | ||
952 | req->req.length, | ||
953 | (ep->bEndpointAddress & USB_DIR_IN) | ||
954 | ? DMA_TO_DEVICE | ||
955 | : DMA_FROM_DEVICE); | ||
956 | req->mapped = 1; | ||
957 | } else { | ||
958 | dma_sync_single_for_device( | ||
959 | ep->udc->gadget.dev.parent, | ||
960 | req->req.dma, req->req.length, | ||
961 | (ep->bEndpointAddress & USB_DIR_IN) | ||
962 | ? DMA_TO_DEVICE | ||
963 | : DMA_FROM_DEVICE); | ||
964 | req->mapped = 0; | ||
965 | } | ||
966 | } | ||
967 | 906 | ||
968 | VDBG("%s queue req %p, len %d buf %p\n", | 907 | VDBG("%s queue req %p, len %d buf %p\n", |
969 | ep->ep.name, _req, _req->length, _req->buf); | 908 | ep->ep.name, _req, _req->length, _req->buf); |
@@ -984,7 +923,7 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
984 | int is_in; | 923 | int is_in; |
985 | 924 | ||
986 | if (ep->bEndpointAddress == 0) { | 925 | if (ep->bEndpointAddress == 0) { |
987 | if (!udc->ep0_pending || !list_empty (&ep->queue)) { | 926 | if (!udc->ep0_pending || !list_empty(&ep->queue)) { |
988 | spin_unlock_irqrestore(&udc->lock, flags); | 927 | spin_unlock_irqrestore(&udc->lock, flags); |
989 | return -EL2HLT; | 928 | return -EL2HLT; |
990 | } | 929 | } |
@@ -1011,7 +950,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
1011 | * always an IN ... even for IN transfers, | 950 | * always an IN ... even for IN transfers, |
1012 | * a weird case which seem to stall OMAP. | 951 | * a weird case which seem to stall OMAP. |
1013 | */ | 952 | */ |
1014 | omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); | 953 | omap_writew(UDC_EP_SEL | UDC_EP_DIR, |
954 | UDC_EP_NUM); | ||
1015 | omap_writew(UDC_CLR_EP, UDC_CTRL); | 955 | omap_writew(UDC_CLR_EP, UDC_CTRL); |
1016 | omap_writew(UDC_SET_FIFO_EN, UDC_CTRL); | 956 | omap_writew(UDC_SET_FIFO_EN, UDC_CTRL); |
1017 | omap_writew(UDC_EP_DIR, UDC_EP_NUM); | 957 | omap_writew(UDC_EP_DIR, UDC_EP_NUM); |
@@ -1023,7 +963,8 @@ omap_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
1023 | 963 | ||
1024 | /* non-empty DATA stage */ | 964 | /* non-empty DATA stage */ |
1025 | } else if (is_in) { | 965 | } else if (is_in) { |
1026 | omap_writew(UDC_EP_SEL | UDC_EP_DIR, UDC_EP_NUM); | 966 | omap_writew(UDC_EP_SEL | UDC_EP_DIR, |
967 | UDC_EP_NUM); | ||
1027 | } else { | 968 | } else { |
1028 | if (udc->ep0_setup) | 969 | if (udc->ep0_setup) |
1029 | goto irq_wait; | 970 | goto irq_wait; |
@@ -1071,7 +1012,7 @@ static int omap_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
1071 | spin_lock_irqsave(&ep->udc->lock, flags); | 1012 | spin_lock_irqsave(&ep->udc->lock, flags); |
1072 | 1013 | ||
1073 | /* make sure it's actually queued on this endpoint */ | 1014 | /* make sure it's actually queued on this endpoint */ |
1074 | list_for_each_entry (req, &ep->queue, queue) { | 1015 | list_for_each_entry(req, &ep->queue, queue) { |
1075 | if (&req->req == _req) | 1016 | if (&req->req == _req) |
1076 | break; | 1017 | break; |
1077 | } | 1018 | } |
@@ -1178,8 +1119,8 @@ static struct usb_ep_ops omap_ep_ops = { | |||
1178 | .dequeue = omap_ep_dequeue, | 1119 | .dequeue = omap_ep_dequeue, |
1179 | 1120 | ||
1180 | .set_halt = omap_ep_set_halt, | 1121 | .set_halt = omap_ep_set_halt, |
1181 | // fifo_status ... report bytes in fifo | 1122 | /* fifo_status ... report bytes in fifo */ |
1182 | // fifo_flush ... flush fifo | 1123 | /* fifo_flush ... flush fifo */ |
1183 | }; | 1124 | }; |
1184 | 1125 | ||
1185 | /*-------------------------------------------------------------------------*/ | 1126 | /*-------------------------------------------------------------------------*/ |
@@ -1409,7 +1350,7 @@ static void udc_quiesce(struct omap_udc *udc) | |||
1409 | 1350 | ||
1410 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 1351 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
1411 | nuke(&udc->ep[0], -ESHUTDOWN); | 1352 | nuke(&udc->ep[0], -ESHUTDOWN); |
1412 | list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) | 1353 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) |
1413 | nuke(ep, -ESHUTDOWN); | 1354 | nuke(ep, -ESHUTDOWN); |
1414 | } | 1355 | } |
1415 | 1356 | ||
@@ -1525,7 +1466,8 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src) | |||
1525 | /* read next OUT packet of request, maybe | 1466 | /* read next OUT packet of request, maybe |
1526 | * reactiviting the fifo; stall on errors. | 1467 | * reactiviting the fifo; stall on errors. |
1527 | */ | 1468 | */ |
1528 | if (!req || (stat = read_fifo(ep0, req)) < 0) { | 1469 | stat = read_fifo(ep0, req); |
1470 | if (!req || stat < 0) { | ||
1529 | omap_writew(UDC_STALL_CMD, UDC_SYSCON2); | 1471 | omap_writew(UDC_STALL_CMD, UDC_SYSCON2); |
1530 | udc->ep0_pending = 0; | 1472 | udc->ep0_pending = 0; |
1531 | stat = 0; | 1473 | stat = 0; |
@@ -1658,7 +1600,7 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src) | |||
1658 | /* this has rude side-effects (aborts) and | 1600 | /* this has rude side-effects (aborts) and |
1659 | * can't really work if DMA-IN is active | 1601 | * can't really work if DMA-IN is active |
1660 | */ | 1602 | */ |
1661 | DBG("%s host set_halt, NYET \n", ep->name); | 1603 | DBG("%s host set_halt, NYET\n", ep->name); |
1662 | goto do_stall; | 1604 | goto do_stall; |
1663 | } | 1605 | } |
1664 | use_ep(ep, 0); | 1606 | use_ep(ep, 0); |
@@ -1749,7 +1691,7 @@ delegate: | |||
1749 | */ | 1691 | */ |
1750 | udc->ep0_setup = 1; | 1692 | udc->ep0_setup = 1; |
1751 | spin_unlock(&udc->lock); | 1693 | spin_unlock(&udc->lock); |
1752 | status = udc->driver->setup (&udc->gadget, &u.r); | 1694 | status = udc->driver->setup(&udc->gadget, &u.r); |
1753 | spin_lock(&udc->lock); | 1695 | spin_lock(&udc->lock); |
1754 | udc->ep0_setup = 0; | 1696 | udc->ep0_setup = 0; |
1755 | } | 1697 | } |
@@ -1794,7 +1736,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) | |||
1794 | VDBG("connect\n"); | 1736 | VDBG("connect\n"); |
1795 | if (!udc->transceiver) | 1737 | if (!udc->transceiver) |
1796 | pullup_enable(udc); | 1738 | pullup_enable(udc); |
1797 | // if (driver->connect) call it | 1739 | /* if (driver->connect) call it */ |
1798 | } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { | 1740 | } else if (udc->gadget.speed != USB_SPEED_UNKNOWN) { |
1799 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 1741 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
1800 | if (!udc->transceiver) | 1742 | if (!udc->transceiver) |
@@ -1826,7 +1768,7 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) | |||
1826 | } | 1768 | } |
1827 | if (change & UDC_SUS) { | 1769 | if (change & UDC_SUS) { |
1828 | if (udc->gadget.speed != USB_SPEED_UNKNOWN) { | 1770 | if (udc->gadget.speed != USB_SPEED_UNKNOWN) { |
1829 | // FIXME tell isp1301 to suspend/resume (?) | 1771 | /* FIXME tell isp1301 to suspend/resume (?) */ |
1830 | if (devstat & UDC_SUS) { | 1772 | if (devstat & UDC_SUS) { |
1831 | VDBG("suspend\n"); | 1773 | VDBG("suspend\n"); |
1832 | update_otg(udc); | 1774 | update_otg(udc); |
@@ -2029,7 +1971,7 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev) | |||
2029 | spin_lock_irqsave(&udc->lock, flags); | 1971 | spin_lock_irqsave(&udc->lock, flags); |
2030 | 1972 | ||
2031 | /* handle all non-DMA ISO transfers */ | 1973 | /* handle all non-DMA ISO transfers */ |
2032 | list_for_each_entry (ep, &udc->iso, iso) { | 1974 | list_for_each_entry(ep, &udc->iso, iso) { |
2033 | u16 stat; | 1975 | u16 stat; |
2034 | struct omap_req *req; | 1976 | struct omap_req *req; |
2035 | 1977 | ||
@@ -2088,15 +2030,11 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev) | |||
2088 | 2030 | ||
2089 | static inline int machine_without_vbus_sense(void) | 2031 | static inline int machine_without_vbus_sense(void) |
2090 | { | 2032 | { |
2091 | return (machine_is_omap_innovator() | 2033 | return machine_is_omap_innovator() |
2092 | || machine_is_omap_osk() | 2034 | || machine_is_omap_osk() |
2093 | || machine_is_omap_apollon() | ||
2094 | #ifndef CONFIG_MACH_OMAP_H4_OTG | ||
2095 | || machine_is_omap_h4() | ||
2096 | #endif | ||
2097 | || machine_is_sx1() | 2035 | || machine_is_sx1() |
2098 | || cpu_is_omap7xx() /* No known omap7xx boards with vbus sense */ | 2036 | /* No known omap7xx boards with vbus sense */ |
2099 | ); | 2037 | || cpu_is_omap7xx(); |
2100 | } | 2038 | } |
2101 | 2039 | ||
2102 | static int omap_udc_start(struct usb_gadget_driver *driver, | 2040 | static int omap_udc_start(struct usb_gadget_driver *driver, |
@@ -2110,7 +2048,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2110 | if (!udc) | 2048 | if (!udc) |
2111 | return -ENODEV; | 2049 | return -ENODEV; |
2112 | if (!driver | 2050 | if (!driver |
2113 | // FIXME if otg, check: driver->is_otg | 2051 | /* FIXME if otg, check: driver->is_otg */ |
2114 | || driver->max_speed < USB_SPEED_FULL | 2052 | || driver->max_speed < USB_SPEED_FULL |
2115 | || !bind || !driver->setup) | 2053 | || !bind || !driver->setup) |
2116 | return -EINVAL; | 2054 | return -EINVAL; |
@@ -2122,7 +2060,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2122 | } | 2060 | } |
2123 | 2061 | ||
2124 | /* reset state */ | 2062 | /* reset state */ |
2125 | list_for_each_entry (ep, &udc->gadget.ep_list, ep.ep_list) { | 2063 | list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { |
2126 | ep->irqs = 0; | 2064 | ep->irqs = 0; |
2127 | if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) | 2065 | if (ep->bmAttributes == USB_ENDPOINT_XFER_ISOC) |
2128 | continue; | 2066 | continue; |
@@ -2160,7 +2098,7 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2160 | if (status < 0) { | 2098 | if (status < 0) { |
2161 | ERR("can't bind to transceiver\n"); | 2099 | ERR("can't bind to transceiver\n"); |
2162 | if (driver->unbind) { | 2100 | if (driver->unbind) { |
2163 | driver->unbind (&udc->gadget); | 2101 | driver->unbind(&udc->gadget); |
2164 | udc->gadget.dev.driver = NULL; | 2102 | udc->gadget.dev.driver = NULL; |
2165 | udc->driver = NULL; | 2103 | udc->driver = NULL; |
2166 | } | 2104 | } |
@@ -2168,9 +2106,9 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2168 | } | 2106 | } |
2169 | } else { | 2107 | } else { |
2170 | if (can_pullup(udc)) | 2108 | if (can_pullup(udc)) |
2171 | pullup_enable (udc); | 2109 | pullup_enable(udc); |
2172 | else | 2110 | else |
2173 | pullup_disable (udc); | 2111 | pullup_disable(udc); |
2174 | } | 2112 | } |
2175 | 2113 | ||
2176 | /* boards that don't have VBUS sensing can't autogate 48MHz; | 2114 | /* boards that don't have VBUS sensing can't autogate 48MHz; |
@@ -2229,7 +2167,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) | |||
2229 | static const char proc_filename[] = "driver/udc"; | 2167 | static const char proc_filename[] = "driver/udc"; |
2230 | 2168 | ||
2231 | #define FOURBITS "%s%s%s%s" | 2169 | #define FOURBITS "%s%s%s%s" |
2232 | #define EIGHTBITS FOURBITS FOURBITS | 2170 | #define EIGHTBITS "%s%s%s%s%s%s%s%s" |
2233 | 2171 | ||
2234 | static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) | 2172 | static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) |
2235 | { | 2173 | { |
@@ -2251,12 +2189,21 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) | |||
2251 | "\n%s %s%s%sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n", | 2189 | "\n%s %s%s%sirqs %ld stat %04x " EIGHTBITS FOURBITS "%s\n", |
2252 | ep->name, buf, | 2190 | ep->name, buf, |
2253 | ep->double_buf ? "dbuf " : "", | 2191 | ep->double_buf ? "dbuf " : "", |
2254 | ({char *s; switch(ep->ackwait){ | 2192 | ({ char *s; |
2255 | case 0: s = ""; break; | 2193 | switch (ep->ackwait) { |
2256 | case 1: s = "(ackw) "; break; | 2194 | case 0: |
2257 | case 2: s = "(ackw2) "; break; | 2195 | s = ""; |
2258 | default: s = "(?) "; break; | 2196 | break; |
2259 | } s;}), | 2197 | case 1: |
2198 | s = "(ackw) "; | ||
2199 | break; | ||
2200 | case 2: | ||
2201 | s = "(ackw2) "; | ||
2202 | break; | ||
2203 | default: | ||
2204 | s = "(?) "; | ||
2205 | break; | ||
2206 | } s; }), | ||
2260 | ep->irqs, stat_flg, | 2207 | ep->irqs, stat_flg, |
2261 | (stat_flg & UDC_NO_RXPACKET) ? "no_rxpacket " : "", | 2208 | (stat_flg & UDC_NO_RXPACKET) ? "no_rxpacket " : "", |
2262 | (stat_flg & UDC_MISS_IN) ? "miss_in " : "", | 2209 | (stat_flg & UDC_MISS_IN) ? "miss_in " : "", |
@@ -2272,10 +2219,10 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) | |||
2272 | (stat_flg & UDC_NON_ISO_FIFO_EMPTY) ? "fifo_empty " : "", | 2219 | (stat_flg & UDC_NON_ISO_FIFO_EMPTY) ? "fifo_empty " : "", |
2273 | (stat_flg & UDC_NON_ISO_FIFO_FULL) ? "fifo_full " : ""); | 2220 | (stat_flg & UDC_NON_ISO_FIFO_FULL) ? "fifo_full " : ""); |
2274 | 2221 | ||
2275 | if (list_empty (&ep->queue)) | 2222 | if (list_empty(&ep->queue)) |
2276 | seq_printf(s, "\t(queue empty)\n"); | 2223 | seq_printf(s, "\t(queue empty)\n"); |
2277 | else | 2224 | else |
2278 | list_for_each_entry (req, &ep->queue, queue) { | 2225 | list_for_each_entry(req, &ep->queue, queue) { |
2279 | unsigned length = req->req.actual; | 2226 | unsigned length = req->req.actual; |
2280 | 2227 | ||
2281 | if (use_dma && buf[0]) { | 2228 | if (use_dma && buf[0]) { |
@@ -2293,11 +2240,16 @@ static void proc_ep_show(struct seq_file *s, struct omap_ep *ep) | |||
2293 | static char *trx_mode(unsigned m, int enabled) | 2240 | static char *trx_mode(unsigned m, int enabled) |
2294 | { | 2241 | { |
2295 | switch (m) { | 2242 | switch (m) { |
2296 | case 0: return enabled ? "*6wire" : "unused"; | 2243 | case 0: |
2297 | case 1: return "4wire"; | 2244 | return enabled ? "*6wire" : "unused"; |
2298 | case 2: return "3wire"; | 2245 | case 1: |
2299 | case 3: return "6wire"; | 2246 | return "4wire"; |
2300 | default: return "unknown"; | 2247 | case 2: |
2248 | return "3wire"; | ||
2249 | case 3: | ||
2250 | return "6wire"; | ||
2251 | default: | ||
2252 | return "unknown"; | ||
2301 | } | 2253 | } |
2302 | } | 2254 | } |
2303 | 2255 | ||
@@ -2307,12 +2259,9 @@ static int proc_otg_show(struct seq_file *s) | |||
2307 | u32 trans = 0; | 2259 | u32 trans = 0; |
2308 | char *ctrl_name = "(UNKNOWN)"; | 2260 | char *ctrl_name = "(UNKNOWN)"; |
2309 | 2261 | ||
2310 | /* XXX This needs major revision for OMAP2+ */ | ||
2311 | tmp = omap_readl(OTG_REV); | 2262 | tmp = omap_readl(OTG_REV); |
2312 | if (cpu_class_is_omap1()) { | 2263 | ctrl_name = "tranceiver_ctrl"; |
2313 | ctrl_name = "tranceiver_ctrl"; | 2264 | trans = omap_readw(USB_TRANSCEIVER_CTRL); |
2314 | trans = omap_readw(USB_TRANSCEIVER_CTRL); | ||
2315 | } | ||
2316 | seq_printf(s, "\nOTG rev %d.%d, %s %05x\n", | 2265 | seq_printf(s, "\nOTG rev %d.%d, %s %05x\n", |
2317 | tmp >> 4, tmp & 0xf, ctrl_name, trans); | 2266 | tmp >> 4, tmp & 0xf, ctrl_name, trans); |
2318 | tmp = omap_readw(OTG_SYSCON_1); | 2267 | tmp = omap_readw(OTG_SYSCON_1); |
@@ -2332,7 +2281,7 @@ static int proc_otg_show(struct seq_file *s) | |||
2332 | " b_ase_brst=%d hmc=%d\n", tmp, | 2281 | " b_ase_brst=%d hmc=%d\n", tmp, |
2333 | (tmp & OTG_EN) ? " otg_en" : "", | 2282 | (tmp & OTG_EN) ? " otg_en" : "", |
2334 | (tmp & USBX_SYNCHRO) ? " synchro" : "", | 2283 | (tmp & USBX_SYNCHRO) ? " synchro" : "", |
2335 | // much more SRP stuff | 2284 | /* much more SRP stuff */ |
2336 | (tmp & SRP_DATA) ? " srp_data" : "", | 2285 | (tmp & SRP_DATA) ? " srp_data" : "", |
2337 | (tmp & SRP_VBUS) ? " srp_vbus" : "", | 2286 | (tmp & SRP_VBUS) ? " srp_vbus" : "", |
2338 | (tmp & OTG_PADEN) ? " otg_paden" : "", | 2287 | (tmp & OTG_PADEN) ? " otg_paden" : "", |
@@ -2399,14 +2348,12 @@ static int proc_udc_show(struct seq_file *s, void *_) | |||
2399 | HMC, | 2348 | HMC, |
2400 | udc->transceiver | 2349 | udc->transceiver |
2401 | ? udc->transceiver->label | 2350 | ? udc->transceiver->label |
2402 | : ((cpu_is_omap1710() || cpu_is_omap24xx()) | 2351 | : (cpu_is_omap1710() |
2403 | ? "external" : "(none)")); | 2352 | ? "external" : "(none)")); |
2404 | if (cpu_class_is_omap1()) { | 2353 | seq_printf(s, "ULPD control %04x req %04x status %04x\n", |
2405 | seq_printf(s, "ULPD control %04x req %04x status %04x\n", | 2354 | omap_readw(ULPD_CLOCK_CTRL), |
2406 | omap_readw(ULPD_CLOCK_CTRL), | 2355 | omap_readw(ULPD_SOFT_REQ), |
2407 | omap_readw(ULPD_SOFT_REQ), | 2356 | omap_readw(ULPD_STATUS_REQ)); |
2408 | omap_readw(ULPD_STATUS_REQ)); | ||
2409 | } | ||
2410 | 2357 | ||
2411 | /* OTG controller registers */ | 2358 | /* OTG controller registers */ |
2412 | if (!cpu_is_omap15xx()) | 2359 | if (!cpu_is_omap15xx()) |
@@ -2422,7 +2369,7 @@ static int proc_udc_show(struct seq_file *s, void *_) | |||
2422 | (tmp & UDC_SELF_PWR) ? " self_pwr" : "", | 2369 | (tmp & UDC_SELF_PWR) ? " self_pwr" : "", |
2423 | (tmp & UDC_SOFF_DIS) ? " soff_dis" : "", | 2370 | (tmp & UDC_SOFF_DIS) ? " soff_dis" : "", |
2424 | (tmp & UDC_PULLUP_EN) ? " PULLUP" : ""); | 2371 | (tmp & UDC_PULLUP_EN) ? " PULLUP" : ""); |
2425 | // syscon2 is write-only | 2372 | /* syscon2 is write-only */ |
2426 | 2373 | ||
2427 | /* UDC controller registers */ | 2374 | /* UDC controller registers */ |
2428 | if (!(tmp & UDC_PULLUP_EN)) { | 2375 | if (!(tmp & UDC_PULLUP_EN)) { |
@@ -2506,7 +2453,7 @@ static int proc_udc_show(struct seq_file *s, void *_) | |||
2506 | if (tmp & UDC_ATT) { | 2453 | if (tmp & UDC_ATT) { |
2507 | proc_ep_show(s, &udc->ep[0]); | 2454 | proc_ep_show(s, &udc->ep[0]); |
2508 | if (tmp & UDC_ADD) { | 2455 | if (tmp & UDC_ADD) { |
2509 | list_for_each_entry (ep, &udc->gadget.ep_list, | 2456 | list_for_each_entry(ep, &udc->gadget.ep_list, |
2510 | ep.ep_list) { | 2457 | ep.ep_list) { |
2511 | if (ep->ep.desc) | 2458 | if (ep->ep.desc) |
2512 | proc_ep_show(s, ep); | 2459 | proc_ep_show(s, ep); |
@@ -2557,7 +2504,7 @@ static inline void remove_proc_file(void) {} | |||
2557 | * UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that | 2504 | * UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that |
2558 | * capability yet though. | 2505 | * capability yet though. |
2559 | */ | 2506 | */ |
2560 | static unsigned __init | 2507 | static unsigned __devinit |
2561 | omap_ep_setup(char *name, u8 addr, u8 type, | 2508 | omap_ep_setup(char *name, u8 addr, u8 type, |
2562 | unsigned buf, unsigned maxp, int dbuf) | 2509 | unsigned buf, unsigned maxp, int dbuf) |
2563 | { | 2510 | { |
@@ -2575,14 +2522,29 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2575 | /* chip setup ... bit values are same for IN, OUT */ | 2522 | /* chip setup ... bit values are same for IN, OUT */ |
2576 | if (type == USB_ENDPOINT_XFER_ISOC) { | 2523 | if (type == USB_ENDPOINT_XFER_ISOC) { |
2577 | switch (maxp) { | 2524 | switch (maxp) { |
2578 | case 8: epn_rxtx = 0 << 12; break; | 2525 | case 8: |
2579 | case 16: epn_rxtx = 1 << 12; break; | 2526 | epn_rxtx = 0 << 12; |
2580 | case 32: epn_rxtx = 2 << 12; break; | 2527 | break; |
2581 | case 64: epn_rxtx = 3 << 12; break; | 2528 | case 16: |
2582 | case 128: epn_rxtx = 4 << 12; break; | 2529 | epn_rxtx = 1 << 12; |
2583 | case 256: epn_rxtx = 5 << 12; break; | 2530 | break; |
2584 | case 512: epn_rxtx = 6 << 12; break; | 2531 | case 32: |
2585 | default: BUG(); | 2532 | epn_rxtx = 2 << 12; |
2533 | break; | ||
2534 | case 64: | ||
2535 | epn_rxtx = 3 << 12; | ||
2536 | break; | ||
2537 | case 128: | ||
2538 | epn_rxtx = 4 << 12; | ||
2539 | break; | ||
2540 | case 256: | ||
2541 | epn_rxtx = 5 << 12; | ||
2542 | break; | ||
2543 | case 512: | ||
2544 | epn_rxtx = 6 << 12; | ||
2545 | break; | ||
2546 | default: | ||
2547 | BUG(); | ||
2586 | } | 2548 | } |
2587 | epn_rxtx |= UDC_EPN_RX_ISO; | 2549 | epn_rxtx |= UDC_EPN_RX_ISO; |
2588 | dbuf = 1; | 2550 | dbuf = 1; |
@@ -2591,15 +2553,24 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2591 | * and ignored for PIO-IN on newer chips | 2553 | * and ignored for PIO-IN on newer chips |
2592 | * (for more reliable behavior) | 2554 | * (for more reliable behavior) |
2593 | */ | 2555 | */ |
2594 | if (!use_dma || cpu_is_omap15xx() || cpu_is_omap24xx()) | 2556 | if (!use_dma || cpu_is_omap15xx()) |
2595 | dbuf = 0; | 2557 | dbuf = 0; |
2596 | 2558 | ||
2597 | switch (maxp) { | 2559 | switch (maxp) { |
2598 | case 8: epn_rxtx = 0 << 12; break; | 2560 | case 8: |
2599 | case 16: epn_rxtx = 1 << 12; break; | 2561 | epn_rxtx = 0 << 12; |
2600 | case 32: epn_rxtx = 2 << 12; break; | 2562 | break; |
2601 | case 64: epn_rxtx = 3 << 12; break; | 2563 | case 16: |
2602 | default: BUG(); | 2564 | epn_rxtx = 1 << 12; |
2565 | break; | ||
2566 | case 32: | ||
2567 | epn_rxtx = 2 << 12; | ||
2568 | break; | ||
2569 | case 64: | ||
2570 | epn_rxtx = 3 << 12; | ||
2571 | break; | ||
2572 | default: | ||
2573 | BUG(); | ||
2603 | } | 2574 | } |
2604 | if (dbuf && addr) | 2575 | if (dbuf && addr) |
2605 | epn_rxtx |= UDC_EPN_RX_DB; | 2576 | epn_rxtx |= UDC_EPN_RX_DB; |
@@ -2639,7 +2610,7 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2639 | ep->ep.name = ep->name; | 2610 | ep->ep.name = ep->name; |
2640 | ep->ep.ops = &omap_ep_ops; | 2611 | ep->ep.ops = &omap_ep_ops; |
2641 | ep->ep.maxpacket = ep->maxpacket = maxp; | 2612 | ep->ep.maxpacket = ep->maxpacket = maxp; |
2642 | list_add_tail (&ep->ep.ep_list, &udc->gadget.ep_list); | 2613 | list_add_tail(&ep->ep.ep_list, &udc->gadget.ep_list); |
2643 | 2614 | ||
2644 | return buf; | 2615 | return buf; |
2645 | } | 2616 | } |
@@ -2647,11 +2618,11 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2647 | static void omap_udc_release(struct device *dev) | 2618 | static void omap_udc_release(struct device *dev) |
2648 | { | 2619 | { |
2649 | complete(udc->done); | 2620 | complete(udc->done); |
2650 | kfree (udc); | 2621 | kfree(udc); |
2651 | udc = NULL; | 2622 | udc = NULL; |
2652 | } | 2623 | } |
2653 | 2624 | ||
2654 | static int __init | 2625 | static int __devinit |
2655 | omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) | 2626 | omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) |
2656 | { | 2627 | { |
2657 | unsigned tmp, buf; | 2628 | unsigned tmp, buf; |
@@ -2665,13 +2636,13 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) | |||
2665 | omap_writew(0, UDC_TXDMA_CFG); | 2636 | omap_writew(0, UDC_TXDMA_CFG); |
2666 | 2637 | ||
2667 | /* UDC_PULLUP_EN gates the chip clock */ | 2638 | /* UDC_PULLUP_EN gates the chip clock */ |
2668 | // OTG_SYSCON_1 |= DEV_IDLE_EN; | 2639 | /* OTG_SYSCON_1 |= DEV_IDLE_EN; */ |
2669 | 2640 | ||
2670 | udc = kzalloc(sizeof(*udc), GFP_KERNEL); | 2641 | udc = kzalloc(sizeof(*udc), GFP_KERNEL); |
2671 | if (!udc) | 2642 | if (!udc) |
2672 | return -ENOMEM; | 2643 | return -ENOMEM; |
2673 | 2644 | ||
2674 | spin_lock_init (&udc->lock); | 2645 | spin_lock_init(&udc->lock); |
2675 | 2646 | ||
2676 | udc->gadget.ops = &omap_gadget_ops; | 2647 | udc->gadget.ops = &omap_gadget_ops; |
2677 | udc->gadget.ep0 = &udc->ep[0].ep; | 2648 | udc->gadget.ep0 = &udc->ep[0].ep; |
@@ -2701,13 +2672,13 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) | |||
2701 | omap_writew(0, UDC_EP_TX(tmp)); | 2672 | omap_writew(0, UDC_EP_TX(tmp)); |
2702 | } | 2673 | } |
2703 | 2674 | ||
2704 | #define OMAP_BULK_EP(name,addr) \ | 2675 | #define OMAP_BULK_EP(name, addr) \ |
2705 | buf = omap_ep_setup(name "-bulk", addr, \ | 2676 | buf = omap_ep_setup(name "-bulk", addr, \ |
2706 | USB_ENDPOINT_XFER_BULK, buf, 64, 1); | 2677 | USB_ENDPOINT_XFER_BULK, buf, 64, 1); |
2707 | #define OMAP_INT_EP(name,addr, maxp) \ | 2678 | #define OMAP_INT_EP(name, addr, maxp) \ |
2708 | buf = omap_ep_setup(name "-int", addr, \ | 2679 | buf = omap_ep_setup(name "-int", addr, \ |
2709 | USB_ENDPOINT_XFER_INT, buf, maxp, 0); | 2680 | USB_ENDPOINT_XFER_INT, buf, maxp, 0); |
2710 | #define OMAP_ISO_EP(name,addr, maxp) \ | 2681 | #define OMAP_ISO_EP(name, addr, maxp) \ |
2711 | buf = omap_ep_setup(name "-iso", addr, \ | 2682 | buf = omap_ep_setup(name "-iso", addr, \ |
2712 | USB_ENDPOINT_XFER_ISOC, buf, maxp, 1); | 2683 | USB_ENDPOINT_XFER_ISOC, buf, maxp, 1); |
2713 | 2684 | ||
@@ -2788,15 +2759,18 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) | |||
2788 | return 0; | 2759 | return 0; |
2789 | } | 2760 | } |
2790 | 2761 | ||
2791 | static int __init omap_udc_probe(struct platform_device *pdev) | 2762 | static int __devinit omap_udc_probe(struct platform_device *pdev) |
2792 | { | 2763 | { |
2793 | int status = -ENODEV; | 2764 | int status = -ENODEV; |
2794 | int hmc; | 2765 | int hmc; |
2795 | struct usb_phy *xceiv = NULL; | 2766 | struct usb_phy *xceiv = NULL; |
2796 | const char *type = NULL; | 2767 | const char *type = NULL; |
2797 | struct omap_usb_config *config = pdev->dev.platform_data; | 2768 | struct omap_usb_config *config = pdev->dev.platform_data; |
2798 | struct clk *dc_clk; | 2769 | struct clk *dc_clk = NULL; |
2799 | struct clk *hhc_clk; | 2770 | struct clk *hhc_clk = NULL; |
2771 | |||
2772 | if (cpu_is_omap7xx()) | ||
2773 | use_dma = 0; | ||
2800 | 2774 | ||
2801 | /* NOTE: "knows" the order of the resources! */ | 2775 | /* NOTE: "knows" the order of the resources! */ |
2802 | if (!request_mem_region(pdev->resource[0].start, | 2776 | if (!request_mem_region(pdev->resource[0].start, |
@@ -2816,16 +2790,6 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2816 | udelay(100); | 2790 | udelay(100); |
2817 | } | 2791 | } |
2818 | 2792 | ||
2819 | if (cpu_is_omap24xx()) { | ||
2820 | dc_clk = clk_get(&pdev->dev, "usb_fck"); | ||
2821 | hhc_clk = clk_get(&pdev->dev, "usb_l4_ick"); | ||
2822 | BUG_ON(IS_ERR(dc_clk) || IS_ERR(hhc_clk)); | ||
2823 | /* can't use omap_udc_enable_clock yet */ | ||
2824 | clk_enable(dc_clk); | ||
2825 | clk_enable(hhc_clk); | ||
2826 | udelay(100); | ||
2827 | } | ||
2828 | |||
2829 | if (cpu_is_omap7xx()) { | 2793 | if (cpu_is_omap7xx()) { |
2830 | dc_clk = clk_get(&pdev->dev, "usb_dc_ck"); | 2794 | dc_clk = clk_get(&pdev->dev, "usb_dc_ck"); |
2831 | hhc_clk = clk_get(&pdev->dev, "l3_ocpi_ck"); | 2795 | hhc_clk = clk_get(&pdev->dev, "l3_ocpi_ck"); |
@@ -2875,14 +2839,6 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2875 | 2839 | ||
2876 | hmc = HMC_1610; | 2840 | hmc = HMC_1610; |
2877 | 2841 | ||
2878 | if (cpu_is_omap24xx()) { | ||
2879 | /* this could be transceiverless in one of the | ||
2880 | * "we don't need to know" modes. | ||
2881 | */ | ||
2882 | type = "external"; | ||
2883 | goto known; | ||
2884 | } | ||
2885 | |||
2886 | switch (hmc) { | 2842 | switch (hmc) { |
2887 | case 0: /* POWERUP DEFAULT == 0 */ | 2843 | case 0: /* POWERUP DEFAULT == 0 */ |
2888 | case 4: | 2844 | case 4: |
@@ -2921,16 +2877,16 @@ bad_on_1710: | |||
2921 | goto cleanup0; | 2877 | goto cleanup0; |
2922 | } | 2878 | } |
2923 | } | 2879 | } |
2924 | known: | 2880 | |
2925 | INFO("hmc mode %d, %s transceiver\n", hmc, type); | 2881 | INFO("hmc mode %d, %s transceiver\n", hmc, type); |
2926 | 2882 | ||
2927 | /* a "gadget" abstracts/virtualizes the controller */ | 2883 | /* a "gadget" abstracts/virtualizes the controller */ |
2928 | status = omap_udc_setup(pdev, xceiv); | 2884 | status = omap_udc_setup(pdev, xceiv); |
2929 | if (status) { | 2885 | if (status) |
2930 | goto cleanup0; | 2886 | goto cleanup0; |
2931 | } | 2887 | |
2932 | xceiv = NULL; | 2888 | xceiv = NULL; |
2933 | // "udc" is now valid | 2889 | /* "udc" is now valid */ |
2934 | pullup_disable(udc); | 2890 | pullup_disable(udc); |
2935 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | 2891 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
2936 | udc->gadget.is_otg = (config->otg != 0); | 2892 | udc->gadget.is_otg = (config->otg != 0); |
@@ -2944,7 +2900,7 @@ known: | |||
2944 | 2900 | ||
2945 | /* USB general purpose IRQ: ep0, state changes, dma, etc */ | 2901 | /* USB general purpose IRQ: ep0, state changes, dma, etc */ |
2946 | status = request_irq(pdev->resource[1].start, omap_udc_irq, | 2902 | status = request_irq(pdev->resource[1].start, omap_udc_irq, |
2947 | IRQF_SAMPLE_RANDOM, driver_name, udc); | 2903 | 0, driver_name, udc); |
2948 | if (status != 0) { | 2904 | if (status != 0) { |
2949 | ERR("can't get irq %d, err %d\n", | 2905 | ERR("can't get irq %d, err %d\n", |
2950 | (int) pdev->resource[1].start, status); | 2906 | (int) pdev->resource[1].start, status); |
@@ -2953,7 +2909,7 @@ known: | |||
2953 | 2909 | ||
2954 | /* USB "non-iso" IRQ (PIO for all but ep0) */ | 2910 | /* USB "non-iso" IRQ (PIO for all but ep0) */ |
2955 | status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, | 2911 | status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, |
2956 | IRQF_SAMPLE_RANDOM, "omap_udc pio", udc); | 2912 | 0, "omap_udc pio", udc); |
2957 | if (status != 0) { | 2913 | if (status != 0) { |
2958 | ERR("can't get irq %d, err %d\n", | 2914 | ERR("can't get irq %d, err %d\n", |
2959 | (int) pdev->resource[2].start, status); | 2915 | (int) pdev->resource[2].start, status); |
@@ -2975,16 +2931,6 @@ known: | |||
2975 | clk_disable(dc_clk); | 2931 | clk_disable(dc_clk); |
2976 | } | 2932 | } |
2977 | 2933 | ||
2978 | if (cpu_is_omap24xx()) { | ||
2979 | udc->dc_clk = dc_clk; | ||
2980 | udc->hhc_clk = hhc_clk; | ||
2981 | /* FIXME OMAP2 don't release hhc & dc clock */ | ||
2982 | #if 0 | ||
2983 | clk_disable(hhc_clk); | ||
2984 | clk_disable(dc_clk); | ||
2985 | #endif | ||
2986 | } | ||
2987 | |||
2988 | create_proc_file(); | 2934 | create_proc_file(); |
2989 | status = device_add(&udc->gadget.dev); | 2935 | status = device_add(&udc->gadget.dev); |
2990 | if (status) | 2936 | if (status) |
@@ -3006,14 +2952,14 @@ cleanup2: | |||
3006 | free_irq(pdev->resource[1].start, udc); | 2952 | free_irq(pdev->resource[1].start, udc); |
3007 | 2953 | ||
3008 | cleanup1: | 2954 | cleanup1: |
3009 | kfree (udc); | 2955 | kfree(udc); |
3010 | udc = NULL; | 2956 | udc = NULL; |
3011 | 2957 | ||
3012 | cleanup0: | 2958 | cleanup0: |
3013 | if (xceiv) | 2959 | if (xceiv) |
3014 | usb_put_transceiver(xceiv); | 2960 | usb_put_transceiver(xceiv); |
3015 | 2961 | ||
3016 | if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) { | 2962 | if (cpu_is_omap16xx() || cpu_is_omap7xx()) { |
3017 | clk_disable(hhc_clk); | 2963 | clk_disable(hhc_clk); |
3018 | clk_disable(dc_clk); | 2964 | clk_disable(dc_clk); |
3019 | clk_put(hhc_clk); | 2965 | clk_put(hhc_clk); |
@@ -3026,7 +2972,7 @@ cleanup0: | |||
3026 | return status; | 2972 | return status; |
3027 | } | 2973 | } |
3028 | 2974 | ||
3029 | static int __exit omap_udc_remove(struct platform_device *pdev) | 2975 | static int __devexit omap_udc_remove(struct platform_device *pdev) |
3030 | { | 2976 | { |
3031 | DECLARE_COMPLETION_ONSTACK(done); | 2977 | DECLARE_COMPLETION_ONSTACK(done); |
3032 | 2978 | ||
@@ -3111,7 +3057,8 @@ static int omap_udc_resume(struct platform_device *dev) | |||
3111 | /*-------------------------------------------------------------------------*/ | 3057 | /*-------------------------------------------------------------------------*/ |
3112 | 3058 | ||
3113 | static struct platform_driver udc_driver = { | 3059 | static struct platform_driver udc_driver = { |
3114 | .remove = __exit_p(omap_udc_remove), | 3060 | .probe = omap_udc_probe, |
3061 | .remove = __devexit_p(omap_udc_remove), | ||
3115 | .suspend = omap_udc_suspend, | 3062 | .suspend = omap_udc_suspend, |
3116 | .resume = omap_udc_resume, | 3063 | .resume = omap_udc_resume, |
3117 | .driver = { | 3064 | .driver = { |
@@ -3120,27 +3067,7 @@ static struct platform_driver udc_driver = { | |||
3120 | }, | 3067 | }, |
3121 | }; | 3068 | }; |
3122 | 3069 | ||
3123 | static int __init udc_init(void) | 3070 | module_platform_driver(udc_driver); |
3124 | { | ||
3125 | /* Disable DMA for omap7xx -- it doesn't work right. */ | ||
3126 | if (cpu_is_omap7xx()) | ||
3127 | use_dma = 0; | ||
3128 | |||
3129 | INFO("%s, version: " DRIVER_VERSION | ||
3130 | #ifdef USE_ISO | ||
3131 | " (iso)" | ||
3132 | #endif | ||
3133 | "%s\n", driver_desc, | ||
3134 | use_dma ? " (dma)" : ""); | ||
3135 | return platform_driver_probe(&udc_driver, omap_udc_probe); | ||
3136 | } | ||
3137 | module_init(udc_init); | ||
3138 | |||
3139 | static void __exit udc_exit(void) | ||
3140 | { | ||
3141 | platform_driver_unregister(&udc_driver); | ||
3142 | } | ||
3143 | module_exit(udc_exit); | ||
3144 | 3071 | ||
3145 | MODULE_DESCRIPTION(DRIVER_DESC); | 3072 | MODULE_DESCRIPTION(DRIVER_DESC); |
3146 | MODULE_LICENSE("GPL"); | 3073 | MODULE_LICENSE("GPL"); |