aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/pxa2xx_udc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/pxa2xx_udc.c')
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c473
1 files changed, 72 insertions, 401 deletions
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 84392e835d5f..63b9521c1322 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -24,9 +24,9 @@
24 * 24 *
25 */ 25 */
26 26
27#undef DEBUG
28// #define VERBOSE DBG_VERBOSE 27// #define VERBOSE DBG_VERBOSE
29 28
29#include <linux/device.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/kernel.h> 31#include <linux/kernel.h>
32#include <linux/ioport.h> 32#include <linux/ioport.h>
@@ -46,19 +46,17 @@
46 46
47#include <asm/byteorder.h> 47#include <asm/byteorder.h>
48#include <asm/dma.h> 48#include <asm/dma.h>
49#include <asm/gpio.h>
49#include <asm/io.h> 50#include <asm/io.h>
50#include <asm/system.h> 51#include <asm/system.h>
51#include <asm/mach-types.h> 52#include <asm/mach-types.h>
52#include <asm/unaligned.h> 53#include <asm/unaligned.h>
53#include <asm/hardware.h> 54#include <asm/hardware.h>
54#ifdef CONFIG_ARCH_PXA
55#include <asm/arch/pxa-regs.h>
56#endif
57 55
58#include <linux/usb/ch9.h> 56#include <linux/usb/ch9.h>
59#include <linux/usb_gadget.h> 57#include <linux/usb_gadget.h>
60 58
61#include <asm/arch/udc.h> 59#include <asm/mach/udc_pxa2xx.h>
62 60
63 61
64/* 62/*
@@ -76,9 +74,17 @@
76 * it constrains the sorts of USB configuration change events that work. 74 * it constrains the sorts of USB configuration change events that work.
77 * The errata for these chips are misleading; some "fixed" bugs from 75 * The errata for these chips are misleading; some "fixed" bugs from
78 * pxa250 a0/a1 b0/b1/b2 sure act like they're still there. 76 * pxa250 a0/a1 b0/b1/b2 sure act like they're still there.
77 *
78 * Note that the UDC hardware supports DMA (except on IXP) but that's
79 * not used here. IN-DMA (to host) is simple enough, when the data is
80 * suitably aligned (16 bytes) ... the network stack doesn't do that,
81 * other software can. OUT-DMA is buggy in most chip versions, as well
82 * as poorly designed (data toggle not automatic). So this driver won't
83 * bother using DMA. (Mostly-working IN-DMA support was available in
84 * kernels before 2.6.23, but was never enabled or well tested.)
79 */ 85 */
80 86
81#define DRIVER_VERSION "4-May-2005" 87#define DRIVER_VERSION "30-June-2007"
82#define DRIVER_DESC "PXA 25x USB Device Controller driver" 88#define DRIVER_DESC "PXA 25x USB Device Controller driver"
83 89
84 90
@@ -87,12 +93,9 @@ static const char driver_name [] = "pxa2xx_udc";
87static const char ep0name [] = "ep0"; 93static const char ep0name [] = "ep0";
88 94
89 95
90// #define USE_DMA
91// #define USE_OUT_DMA
92// #define DISABLE_TEST_MODE 96// #define DISABLE_TEST_MODE
93 97
94#ifdef CONFIG_ARCH_IXP4XX 98#ifdef CONFIG_ARCH_IXP4XX
95#undef USE_DMA
96 99
97/* cpu-specific register addresses are compiled in to this code */ 100/* cpu-specific register addresses are compiled in to this code */
98#ifdef CONFIG_ARCH_PXA 101#ifdef CONFIG_ARCH_PXA
@@ -104,25 +107,6 @@ static const char ep0name [] = "ep0";
104#include "pxa2xx_udc.h" 107#include "pxa2xx_udc.h"
105 108
106 109
107#ifdef USE_DMA
108static int use_dma = 1;
109module_param(use_dma, bool, 0);
110MODULE_PARM_DESC (use_dma, "true to use dma");
111
112static void dma_nodesc_handler (int dmach, void *_ep);
113static void kick_dma(struct pxa2xx_ep *ep, struct pxa2xx_request *req);
114
115#ifdef USE_OUT_DMA
116#define DMASTR " (dma support)"
117#else
118#define DMASTR " (dma in)"
119#endif
120
121#else /* !USE_DMA */
122#define DMASTR " (pio only)"
123#undef USE_OUT_DMA
124#endif
125
126#ifdef CONFIG_USB_PXA2XX_SMALL 110#ifdef CONFIG_USB_PXA2XX_SMALL
127#define SIZE_STR " (small)" 111#define SIZE_STR " (small)"
128#else 112#else
@@ -155,7 +139,7 @@ static int is_vbus_present(void)
155 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 139 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
156 140
157 if (mach->gpio_vbus) 141 if (mach->gpio_vbus)
158 return udc_gpio_get(mach->gpio_vbus); 142 return gpio_get_value(mach->gpio_vbus);
159 if (mach->udc_is_connected) 143 if (mach->udc_is_connected)
160 return mach->udc_is_connected(); 144 return mach->udc_is_connected();
161 return 1; 145 return 1;
@@ -167,7 +151,7 @@ static void pullup_off(void)
167 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 151 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
168 152
169 if (mach->gpio_pullup) 153 if (mach->gpio_pullup)
170 udc_gpio_set(mach->gpio_pullup, 0); 154 gpio_set_value(mach->gpio_pullup, 0);
171 else if (mach->udc_command) 155 else if (mach->udc_command)
172 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT); 156 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
173} 157}
@@ -177,7 +161,7 @@ static void pullup_on(void)
177 struct pxa2xx_udc_mach_info *mach = the_controller->mach; 161 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
178 162
179 if (mach->gpio_pullup) 163 if (mach->gpio_pullup)
180 udc_gpio_set(mach->gpio_pullup, 1); 164 gpio_set_value(mach->gpio_pullup, 1);
181 else if (mach->udc_command) 165 else if (mach->udc_command)
182 mach->udc_command(PXA2XX_UDC_CMD_CONNECT); 166 mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
183} 167}
@@ -281,9 +265,8 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
281 } 265 }
282 266
283 ep->desc = desc; 267 ep->desc = desc;
284 ep->dma = -1;
285 ep->stopped = 0; 268 ep->stopped = 0;
286 ep->pio_irqs = ep->dma_irqs = 0; 269 ep->pio_irqs = 0;
287 ep->ep.maxpacket = le16_to_cpu (desc->wMaxPacketSize); 270 ep->ep.maxpacket = le16_to_cpu (desc->wMaxPacketSize);
288 271
289 /* flush fifo (mostly for OUT buffers) */ 272 /* flush fifo (mostly for OUT buffers) */
@@ -291,30 +274,6 @@ static int pxa2xx_ep_enable (struct usb_ep *_ep,
291 274
292 /* ... reset halt state too, if we could ... */ 275 /* ... reset halt state too, if we could ... */
293 276
294#ifdef USE_DMA
295 /* for (some) bulk and ISO endpoints, try to get a DMA channel and
296 * bind it to the endpoint. otherwise use PIO.
297 */
298 switch (ep->bmAttributes) {
299 case USB_ENDPOINT_XFER_ISOC:
300 if (le16_to_cpu(desc->wMaxPacketSize) % 32)
301 break;
302 // fall through
303 case USB_ENDPOINT_XFER_BULK:
304 if (!use_dma || !ep->reg_drcmr)
305 break;
306 ep->dma = pxa_request_dma ((char *)_ep->name,
307 (le16_to_cpu (desc->wMaxPacketSize) > 64)
308 ? DMA_PRIO_MEDIUM /* some iso */
309 : DMA_PRIO_LOW,
310 dma_nodesc_handler, ep);
311 if (ep->dma >= 0) {
312 *ep->reg_drcmr = DRCMR_MAPVLD | ep->dma;
313 DMSG("%s using dma%d\n", _ep->name, ep->dma);
314 }
315 }
316#endif
317
318 DBG(DBG_VERBOSE, "enabled %s\n", _ep->name); 277 DBG(DBG_VERBOSE, "enabled %s\n", _ep->name);
319 return 0; 278 return 0;
320} 279}
@@ -334,14 +293,6 @@ static int pxa2xx_ep_disable (struct usb_ep *_ep)
334 293
335 nuke (ep, -ESHUTDOWN); 294 nuke (ep, -ESHUTDOWN);
336 295
337#ifdef USE_DMA
338 if (ep->dma >= 0) {
339 *ep->reg_drcmr = 0;
340 pxa_free_dma (ep->dma);
341 ep->dma = -1;
342 }
343#endif
344
345 /* flush fifo (mostly for IN buffers) */ 296 /* flush fifo (mostly for IN buffers) */
346 pxa2xx_ep_fifo_flush (_ep); 297 pxa2xx_ep_fifo_flush (_ep);
347 298
@@ -390,35 +341,6 @@ pxa2xx_ep_free_request (struct usb_ep *_ep, struct usb_request *_req)
390 kfree(req); 341 kfree(req);
391} 342}
392 343
393
394/* PXA cache needs flushing with DMA I/O (it's dma-incoherent), but there's
395 * no device-affinity and the heap works perfectly well for i/o buffers.
396 * It wastes much less memory than dma_alloc_coherent() would, and even
397 * prevents cacheline (32 bytes wide) sharing problems.
398 */
399static void *
400pxa2xx_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes,
401 dma_addr_t *dma, gfp_t gfp_flags)
402{
403 char *retval;
404
405 retval = kmalloc (bytes, gfp_flags & ~(__GFP_DMA|__GFP_HIGHMEM));
406 if (retval)
407#ifdef USE_DMA
408 *dma = virt_to_bus (retval);
409#else
410 *dma = (dma_addr_t)~0;
411#endif
412 return retval;
413}
414
415static void
416pxa2xx_ep_free_buffer(struct usb_ep *_ep, void *buf, dma_addr_t dma,
417 unsigned bytes)
418{
419 kfree (buf);
420}
421
422/*-------------------------------------------------------------------------*/ 344/*-------------------------------------------------------------------------*/
423 345
424/* 346/*
@@ -518,18 +440,8 @@ write_fifo (struct pxa2xx_ep *ep, struct pxa2xx_request *req)
518 /* requests complete when all IN data is in the FIFO */ 440 /* requests complete when all IN data is in the FIFO */
519 if (is_last) { 441 if (is_last) {
520 done (ep, req, 0); 442 done (ep, req, 0);
521 if (list_empty(&ep->queue) || unlikely(ep->dma >= 0)) { 443 if (list_empty(&ep->queue))
522 pio_irq_disable (ep->bEndpointAddress); 444 pio_irq_disable (ep->bEndpointAddress);
523#ifdef USE_DMA
524 /* unaligned data and zlps couldn't use dma */
525 if (unlikely(!list_empty(&ep->queue))) {
526 req = list_entry(ep->queue.next,
527 struct pxa2xx_request, queue);
528 kick_dma(ep,req);
529 return 0;
530 }
531#endif
532 }
533 return 1; 445 return 1;
534 } 446 }
535 447
@@ -728,182 +640,6 @@ read_ep0_fifo (struct pxa2xx_ep *ep, struct pxa2xx_request *req)
728 return 0; 640 return 0;
729} 641}
730 642
731#ifdef USE_DMA
732
733#define MAX_IN_DMA ((DCMD_LENGTH + 1) - BULK_FIFO_SIZE)
734
735static void
736start_dma_nodesc(struct pxa2xx_ep *ep, struct pxa2xx_request *req, int is_in)
737{
738 u32 dcmd = req->req.length;
739 u32 buf = req->req.dma;
740 u32 fifo = io_v2p ((u32)ep->reg_uddr);
741
742 /* caller guarantees there's a packet or more remaining
743 * - IN may end with a short packet (TSP set separately),
744 * - OUT is always full length
745 */
746 buf += req->req.actual;
747 dcmd -= req->req.actual;
748 ep->dma_fixup = 0;
749
750 /* no-descriptor mode can be simple for bulk-in, iso-in, iso-out */
751 DCSR(ep->dma) = DCSR_NODESC;
752 if (is_in) {
753 DSADR(ep->dma) = buf;
754 DTADR(ep->dma) = fifo;
755 if (dcmd > MAX_IN_DMA)
756 dcmd = MAX_IN_DMA;
757 else
758 ep->dma_fixup = (dcmd % ep->ep.maxpacket) != 0;
759 dcmd |= DCMD_BURST32 | DCMD_WIDTH1
760 | DCMD_FLOWTRG | DCMD_INCSRCADDR;
761 } else {
762#ifdef USE_OUT_DMA
763 DSADR(ep->dma) = fifo;
764 DTADR(ep->dma) = buf;
765 if (ep->bmAttributes != USB_ENDPOINT_XFER_ISOC)
766 dcmd = ep->ep.maxpacket;
767 dcmd |= DCMD_BURST32 | DCMD_WIDTH1
768 | DCMD_FLOWSRC | DCMD_INCTRGADDR;
769#endif
770 }
771 DCMD(ep->dma) = dcmd;
772 DCSR(ep->dma) = DCSR_RUN | DCSR_NODESC
773 | (unlikely(is_in)
774 ? DCSR_STOPIRQEN /* use dma_nodesc_handler() */
775 : 0); /* use handle_ep() */
776}
777
778static void kick_dma(struct pxa2xx_ep *ep, struct pxa2xx_request *req)
779{
780 int is_in = ep->bEndpointAddress & USB_DIR_IN;
781
782 if (is_in) {
783 /* unaligned tx buffers and zlps only work with PIO */
784 if ((req->req.dma & 0x0f) != 0
785 || unlikely((req->req.length - req->req.actual)
786 == 0)) {
787 pio_irq_enable(ep->bEndpointAddress);
788 if ((*ep->reg_udccs & UDCCS_BI_TFS) != 0)
789 (void) write_fifo(ep, req);
790 } else {
791 start_dma_nodesc(ep, req, USB_DIR_IN);
792 }
793 } else {
794 if ((req->req.length - req->req.actual) < ep->ep.maxpacket) {
795 DMSG("%s short dma read...\n", ep->ep.name);
796 /* we're always set up for pio out */
797 read_fifo (ep, req);
798 } else {
799 *ep->reg_udccs = UDCCS_BO_DME
800 | (*ep->reg_udccs & UDCCS_BO_FST);
801 start_dma_nodesc(ep, req, USB_DIR_OUT);
802 }
803 }
804}
805
806static void cancel_dma(struct pxa2xx_ep *ep)
807{
808 struct pxa2xx_request *req;
809 u32 tmp;
810
811 if (DCSR(ep->dma) == 0 || list_empty(&ep->queue))
812 return;
813
814 DCSR(ep->dma) = 0;
815 while ((DCSR(ep->dma) & DCSR_STOPSTATE) == 0)
816 cpu_relax();
817
818 req = list_entry(ep->queue.next, struct pxa2xx_request, queue);
819 tmp = DCMD(ep->dma) & DCMD_LENGTH;
820 req->req.actual = req->req.length - (tmp & DCMD_LENGTH);
821
822 /* the last tx packet may be incomplete, so flush the fifo.
823 * FIXME correct req.actual if we can
824 */
825 if (ep->bEndpointAddress & USB_DIR_IN)
826 *ep->reg_udccs = UDCCS_BI_FTF;
827}
828
829/* dma channel stopped ... normal tx end (IN), or on error (IN/OUT) */
830static void dma_nodesc_handler(int dmach, void *_ep)
831{
832 struct pxa2xx_ep *ep = _ep;
833 struct pxa2xx_request *req;
834 u32 tmp, completed;
835
836 local_irq_disable();
837
838 req = list_entry(ep->queue.next, struct pxa2xx_request, queue);
839
840 ep->dma_irqs++;
841 ep->dev->stats.irqs++;
842 HEX_DISPLAY(ep->dev->stats.irqs);
843
844 /* ack/clear */
845 tmp = DCSR(ep->dma);
846 DCSR(ep->dma) = tmp;
847 if ((tmp & DCSR_STOPSTATE) == 0
848 || (DDADR(ep->dma) & DDADR_STOP) != 0) {
849 DBG(DBG_VERBOSE, "%s, dcsr %08x ddadr %08x\n",
850 ep->ep.name, DCSR(ep->dma), DDADR(ep->dma));
851 goto done;
852 }
853 DCSR(ep->dma) = 0; /* clear DCSR_STOPSTATE */
854
855 /* update transfer status */
856 completed = tmp & DCSR_BUSERR;
857 if (ep->bEndpointAddress & USB_DIR_IN)
858 tmp = DSADR(ep->dma);
859 else
860 tmp = DTADR(ep->dma);
861 req->req.actual = tmp - req->req.dma;
862
863 /* FIXME seems we sometimes see partial transfers... */
864
865 if (unlikely(completed != 0))
866 req->req.status = -EIO;
867 else if (req->req.actual) {
868 /* these registers have zeroes in low bits; they miscount
869 * some (end-of-transfer) short packets: tx 14 as tx 12
870 */
871 if (ep->dma_fixup)
872 req->req.actual = min(req->req.actual + 3,
873 req->req.length);
874
875 tmp = (req->req.length - req->req.actual);
876 completed = (tmp == 0);
877 if (completed && (ep->bEndpointAddress & USB_DIR_IN)) {
878
879 /* maybe validate final short packet ... */
880 if ((req->req.actual % ep->ep.maxpacket) != 0)
881 *ep->reg_udccs = UDCCS_BI_TSP/*|UDCCS_BI_TPC*/;
882
883 /* ... or zlp, using pio fallback */
884 else if (ep->bmAttributes == USB_ENDPOINT_XFER_BULK
885 && req->req.zero) {
886 DMSG("%s zlp terminate ...\n", ep->ep.name);
887 completed = 0;
888 }
889 }
890 }
891
892 if (likely(completed)) {
893 done(ep, req, 0);
894
895 /* maybe re-activate after completion */
896 if (ep->stopped || list_empty(&ep->queue))
897 goto done;
898 req = list_entry(ep->queue.next, struct pxa2xx_request, queue);
899 }
900 kick_dma(ep, req);
901done:
902 local_irq_enable();
903}
904
905#endif
906
907/*-------------------------------------------------------------------------*/ 643/*-------------------------------------------------------------------------*/
908 644
909static int 645static int
@@ -942,19 +678,8 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
942 (ep->desc->wMaxPacketSize))) 678 (ep->desc->wMaxPacketSize)))
943 return -EMSGSIZE; 679 return -EMSGSIZE;
944 680
945#ifdef USE_DMA
946 // FIXME caller may already have done the dma mapping
947 if (ep->dma >= 0) {
948 _req->dma = dma_map_single(dev->dev,
949 _req->buf, _req->length,
950 ((ep->bEndpointAddress & USB_DIR_IN) != 0)
951 ? DMA_TO_DEVICE
952 : DMA_FROM_DEVICE);
953 }
954#endif
955
956 DBG(DBG_NOISY, "%s queue req %p, len %d buf %p\n", 681 DBG(DBG_NOISY, "%s queue req %p, len %d buf %p\n",
957 _ep->name, _req, _req->length, _req->buf); 682 _ep->name, _req, _req->length, _req->buf);
958 683
959 local_irq_save(flags); 684 local_irq_save(flags);
960 685
@@ -1002,11 +727,6 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1002 local_irq_restore (flags); 727 local_irq_restore (flags);
1003 return -EL2HLT; 728 return -EL2HLT;
1004 } 729 }
1005#ifdef USE_DMA
1006 /* either start dma or prime pio pump */
1007 } else if (ep->dma >= 0) {
1008 kick_dma(ep, req);
1009#endif
1010 /* can the FIFO can satisfy the request immediately? */ 730 /* can the FIFO can satisfy the request immediately? */
1011 } else if ((ep->bEndpointAddress & USB_DIR_IN) != 0) { 731 } else if ((ep->bEndpointAddress & USB_DIR_IN) != 0) {
1012 if ((*ep->reg_udccs & UDCCS_BI_TFS) != 0 732 if ((*ep->reg_udccs & UDCCS_BI_TFS) != 0
@@ -1017,7 +737,7 @@ pxa2xx_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags)
1017 req = NULL; 737 req = NULL;
1018 } 738 }
1019 739
1020 if (likely (req && ep->desc) && ep->dma < 0) 740 if (likely (req && ep->desc))
1021 pio_irq_enable(ep->bEndpointAddress); 741 pio_irq_enable(ep->bEndpointAddress);
1022 } 742 }
1023 743
@@ -1038,10 +758,6 @@ static void nuke(struct pxa2xx_ep *ep, int status)
1038 struct pxa2xx_request *req; 758 struct pxa2xx_request *req;
1039 759
1040 /* called with irqs blocked */ 760 /* called with irqs blocked */
1041#ifdef USE_DMA
1042 if (ep->dma >= 0 && !ep->stopped)
1043 cancel_dma(ep);
1044#endif
1045 while (!list_empty(&ep->queue)) { 761 while (!list_empty(&ep->queue)) {
1046 req = list_entry(ep->queue.next, 762 req = list_entry(ep->queue.next,
1047 struct pxa2xx_request, 763 struct pxa2xx_request,
@@ -1076,19 +792,7 @@ static int pxa2xx_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1076 return -EINVAL; 792 return -EINVAL;
1077 } 793 }
1078 794
1079#ifdef USE_DMA 795 done(ep, req, -ECONNRESET);
1080 if (ep->dma >= 0 && ep->queue.next == &req->queue && !ep->stopped) {
1081 cancel_dma(ep);
1082 done(ep, req, -ECONNRESET);
1083 /* restart i/o */
1084 if (!list_empty(&ep->queue)) {
1085 req = list_entry(ep->queue.next,
1086 struct pxa2xx_request, queue);
1087 kick_dma(ep, req);
1088 }
1089 } else
1090#endif
1091 done(ep, req, -ECONNRESET);
1092 796
1093 local_irq_restore(flags); 797 local_irq_restore(flags);
1094 return 0; 798 return 0;
@@ -1203,9 +907,6 @@ static struct usb_ep_ops pxa2xx_ep_ops = {
1203 .alloc_request = pxa2xx_ep_alloc_request, 907 .alloc_request = pxa2xx_ep_alloc_request,
1204 .free_request = pxa2xx_ep_free_request, 908 .free_request = pxa2xx_ep_free_request,
1205 909
1206 .alloc_buffer = pxa2xx_ep_alloc_buffer,
1207 .free_buffer = pxa2xx_ep_free_buffer,
1208
1209 .queue = pxa2xx_ep_queue, 910 .queue = pxa2xx_ep_queue,
1210 .dequeue = pxa2xx_ep_dequeue, 911 .dequeue = pxa2xx_ep_dequeue,
1211 912
@@ -1325,7 +1026,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
1325 /* basic device status */ 1026 /* basic device status */
1326 t = scnprintf(next, size, DRIVER_DESC "\n" 1027 t = scnprintf(next, size, DRIVER_DESC "\n"
1327 "%s version: %s\nGadget driver: %s\nHost %s\n\n", 1028 "%s version: %s\nGadget driver: %s\nHost %s\n\n",
1328 driver_name, DRIVER_VERSION SIZE_STR DMASTR, 1029 driver_name, DRIVER_VERSION SIZE_STR "(pio)",
1329 dev->driver ? dev->driver->driver.name : "(none)", 1030 dev->driver ? dev->driver->driver.name : "(none)",
1330 is_vbus_present() ? "full speed" : "disconnected"); 1031 is_vbus_present() ? "full speed" : "disconnected");
1331 size -= t; 1032 size -= t;
@@ -1390,7 +1091,6 @@ udc_proc_read(char *page, char **start, off_t off, int count,
1390 for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) { 1091 for (i = 0; i < PXA_UDC_NUM_ENDPOINTS; i++) {
1391 struct pxa2xx_ep *ep = &dev->ep [i]; 1092 struct pxa2xx_ep *ep = &dev->ep [i];
1392 struct pxa2xx_request *req; 1093 struct pxa2xx_request *req;
1393 int t;
1394 1094
1395 if (i != 0) { 1095 if (i != 0) {
1396 const struct usb_endpoint_descriptor *d; 1096 const struct usb_endpoint_descriptor *d;
@@ -1400,10 +1100,9 @@ udc_proc_read(char *page, char **start, off_t off, int count,
1400 continue; 1100 continue;
1401 tmp = *dev->ep [i].reg_udccs; 1101 tmp = *dev->ep [i].reg_udccs;
1402 t = scnprintf(next, size, 1102 t = scnprintf(next, size,
1403 "%s max %d %s udccs %02x irqs %lu/%lu\n", 1103 "%s max %d %s udccs %02x irqs %lu\n",
1404 ep->ep.name, le16_to_cpu (d->wMaxPacketSize), 1104 ep->ep.name, le16_to_cpu (d->wMaxPacketSize),
1405 (ep->dma >= 0) ? "dma" : "pio", tmp, 1105 "pio", tmp, ep->pio_irqs);
1406 ep->pio_irqs, ep->dma_irqs);
1407 /* TODO translate all five groups of udccs bits! */ 1106 /* TODO translate all five groups of udccs bits! */
1408 1107
1409 } else /* ep0 should only have one transfer queued */ 1108 } else /* ep0 should only have one transfer queued */
@@ -1423,19 +1122,7 @@ udc_proc_read(char *page, char **start, off_t off, int count,
1423 continue; 1122 continue;
1424 } 1123 }
1425 list_for_each_entry(req, &ep->queue, queue) { 1124 list_for_each_entry(req, &ep->queue, queue) {
1426#ifdef USE_DMA 1125 t = scnprintf(next, size,
1427 if (ep->dma >= 0 && req->queue.prev == &ep->queue)
1428 t = scnprintf(next, size,
1429 "\treq %p len %d/%d "
1430 "buf %p (dma%d dcmd %08x)\n",
1431 &req->req, req->req.actual,
1432 req->req.length, req->req.buf,
1433 ep->dma, DCMD(ep->dma)
1434 // low 13 bits == bytes-to-go
1435 );
1436 else
1437#endif
1438 t = scnprintf(next, size,
1439 "\treq %p len %d/%d buf %p\n", 1126 "\treq %p len %d/%d buf %p\n",
1440 &req->req, req->req.actual, 1127 &req->req, req->req.actual,
1441 req->req.length, req->req.buf); 1128 req->req.length, req->req.buf);
@@ -1488,7 +1175,6 @@ static void udc_disable(struct pxa2xx_udc *dev)
1488 1175
1489 ep0_idle (dev); 1176 ep0_idle (dev);
1490 dev->gadget.speed = USB_SPEED_UNKNOWN; 1177 dev->gadget.speed = USB_SPEED_UNKNOWN;
1491 LED_CONNECTED_OFF;
1492} 1178}
1493 1179
1494 1180
@@ -1514,7 +1200,7 @@ static void udc_reinit(struct pxa2xx_udc *dev)
1514 ep->desc = NULL; 1200 ep->desc = NULL;
1515 ep->stopped = 0; 1201 ep->stopped = 0;
1516 INIT_LIST_HEAD (&ep->queue); 1202 INIT_LIST_HEAD (&ep->queue);
1517 ep->pio_irqs = ep->dma_irqs = 0; 1203 ep->pio_irqs = 0;
1518 } 1204 }
1519 1205
1520 /* the rest was statically initialized, and is read-only */ 1206 /* the rest was statically initialized, and is read-only */
@@ -1666,7 +1352,6 @@ stop_activity(struct pxa2xx_udc *dev, struct usb_gadget_driver *driver)
1666 del_timer_sync(&dev->timer); 1352 del_timer_sync(&dev->timer);
1667 1353
1668 /* report disconnect; the driver is already quiesced */ 1354 /* report disconnect; the driver is already quiesced */
1669 LED_CONNECTED_OFF;
1670 if (driver) 1355 if (driver)
1671 driver->disconnect(&dev->gadget); 1356 driver->disconnect(&dev->gadget);
1672 1357
@@ -1715,16 +1400,13 @@ lubbock_vbus_irq(int irq, void *_dev)
1715 int vbus; 1400 int vbus;
1716 1401
1717 dev->stats.irqs++; 1402 dev->stats.irqs++;
1718 HEX_DISPLAY(dev->stats.irqs);
1719 switch (irq) { 1403 switch (irq) {
1720 case LUBBOCK_USB_IRQ: 1404 case LUBBOCK_USB_IRQ:
1721 LED_CONNECTED_ON;
1722 vbus = 1; 1405 vbus = 1;
1723 disable_irq(LUBBOCK_USB_IRQ); 1406 disable_irq(LUBBOCK_USB_IRQ);
1724 enable_irq(LUBBOCK_USB_DISC_IRQ); 1407 enable_irq(LUBBOCK_USB_DISC_IRQ);
1725 break; 1408 break;
1726 case LUBBOCK_USB_DISC_IRQ: 1409 case LUBBOCK_USB_DISC_IRQ:
1727 LED_CONNECTED_OFF;
1728 vbus = 0; 1410 vbus = 0;
1729 disable_irq(LUBBOCK_USB_DISC_IRQ); 1411 disable_irq(LUBBOCK_USB_DISC_IRQ);
1730 enable_irq(LUBBOCK_USB_IRQ); 1412 enable_irq(LUBBOCK_USB_IRQ);
@@ -1742,7 +1424,7 @@ lubbock_vbus_irq(int irq, void *_dev)
1742static irqreturn_t udc_vbus_irq(int irq, void *_dev) 1424static irqreturn_t udc_vbus_irq(int irq, void *_dev)
1743{ 1425{
1744 struct pxa2xx_udc *dev = _dev; 1426 struct pxa2xx_udc *dev = _dev;
1745 int vbus = udc_gpio_get(dev->mach->gpio_vbus); 1427 int vbus = gpio_get_value(dev->mach->gpio_vbus);
1746 1428
1747 pxa2xx_udc_vbus_session(&dev->gadget, vbus); 1429 pxa2xx_udc_vbus_session(&dev->gadget, vbus);
1748 return IRQ_HANDLED; 1430 return IRQ_HANDLED;
@@ -2040,18 +1722,6 @@ static void handle_ep(struct pxa2xx_ep *ep)
2040 1722
2041 /* fifos can hold packets, ready for reading... */ 1723 /* fifos can hold packets, ready for reading... */
2042 if (likely(req)) { 1724 if (likely(req)) {
2043#ifdef USE_OUT_DMA
2044// TODO didn't yet debug out-dma. this approach assumes
2045// the worst about short packets and RPC; it might be better.
2046
2047 if (likely(ep->dma >= 0)) {
2048 if (!(udccs & UDCCS_BO_RSP)) {
2049 *ep->reg_udccs = UDCCS_BO_RPC;
2050 ep->dma_irqs++;
2051 return;
2052 }
2053 }
2054#endif
2055 completed = read_fifo(ep, req); 1725 completed = read_fifo(ep, req);
2056 } else 1726 } else
2057 pio_irq_disable (ep->bEndpointAddress); 1727 pio_irq_disable (ep->bEndpointAddress);
@@ -2074,7 +1744,6 @@ pxa2xx_udc_irq(int irq, void *_dev)
2074 int handled; 1744 int handled;
2075 1745
2076 dev->stats.irqs++; 1746 dev->stats.irqs++;
2077 HEX_DISPLAY(dev->stats.irqs);
2078 do { 1747 do {
2079 u32 udccr = UDCCR; 1748 u32 udccr = UDCCR;
2080 1749
@@ -2125,7 +1794,6 @@ pxa2xx_udc_irq(int irq, void *_dev)
2125 } else { 1794 } else {
2126 DBG(DBG_VERBOSE, "USB reset end\n"); 1795 DBG(DBG_VERBOSE, "USB reset end\n");
2127 dev->gadget.speed = USB_SPEED_FULL; 1796 dev->gadget.speed = USB_SPEED_FULL;
2128 LED_CONNECTED_ON;
2129 memset(&dev->stats, 0, sizeof dev->stats); 1797 memset(&dev->stats, 0, sizeof dev->stats);
2130 /* driver and endpoints are still reset */ 1798 /* driver and endpoints are still reset */
2131 } 1799 }
@@ -2217,7 +1885,6 @@ static struct pxa2xx_udc memory = {
2217 .bmAttributes = USB_ENDPOINT_XFER_BULK, 1885 .bmAttributes = USB_ENDPOINT_XFER_BULK,
2218 .reg_udccs = &UDCCS1, 1886 .reg_udccs = &UDCCS1,
2219 .reg_uddr = &UDDR1, 1887 .reg_uddr = &UDDR1,
2220 drcmr (25)
2221 }, 1888 },
2222 .ep[2] = { 1889 .ep[2] = {
2223 .ep = { 1890 .ep = {
@@ -2232,7 +1899,6 @@ static struct pxa2xx_udc memory = {
2232 .reg_udccs = &UDCCS2, 1899 .reg_udccs = &UDCCS2,
2233 .reg_ubcr = &UBCR2, 1900 .reg_ubcr = &UBCR2,
2234 .reg_uddr = &UDDR2, 1901 .reg_uddr = &UDDR2,
2235 drcmr (26)
2236 }, 1902 },
2237#ifndef CONFIG_USB_PXA2XX_SMALL 1903#ifndef CONFIG_USB_PXA2XX_SMALL
2238 .ep[3] = { 1904 .ep[3] = {
@@ -2247,7 +1913,6 @@ static struct pxa2xx_udc memory = {
2247 .bmAttributes = USB_ENDPOINT_XFER_ISOC, 1913 .bmAttributes = USB_ENDPOINT_XFER_ISOC,
2248 .reg_udccs = &UDCCS3, 1914 .reg_udccs = &UDCCS3,
2249 .reg_uddr = &UDDR3, 1915 .reg_uddr = &UDDR3,
2250 drcmr (27)
2251 }, 1916 },
2252 .ep[4] = { 1917 .ep[4] = {
2253 .ep = { 1918 .ep = {
@@ -2262,7 +1927,6 @@ static struct pxa2xx_udc memory = {
2262 .reg_udccs = &UDCCS4, 1927 .reg_udccs = &UDCCS4,
2263 .reg_ubcr = &UBCR4, 1928 .reg_ubcr = &UBCR4,
2264 .reg_uddr = &UDDR4, 1929 .reg_uddr = &UDDR4,
2265 drcmr (28)
2266 }, 1930 },
2267 .ep[5] = { 1931 .ep[5] = {
2268 .ep = { 1932 .ep = {
@@ -2291,7 +1955,6 @@ static struct pxa2xx_udc memory = {
2291 .bmAttributes = USB_ENDPOINT_XFER_BULK, 1955 .bmAttributes = USB_ENDPOINT_XFER_BULK,
2292 .reg_udccs = &UDCCS6, 1956 .reg_udccs = &UDCCS6,
2293 .reg_uddr = &UDDR6, 1957 .reg_uddr = &UDDR6,
2294 drcmr (30)
2295 }, 1958 },
2296 .ep[7] = { 1959 .ep[7] = {
2297 .ep = { 1960 .ep = {
@@ -2306,7 +1969,6 @@ static struct pxa2xx_udc memory = {
2306 .reg_udccs = &UDCCS7, 1969 .reg_udccs = &UDCCS7,
2307 .reg_ubcr = &UBCR7, 1970 .reg_ubcr = &UBCR7,
2308 .reg_uddr = &UDDR7, 1971 .reg_uddr = &UDDR7,
2309 drcmr (31)
2310 }, 1972 },
2311 .ep[8] = { 1973 .ep[8] = {
2312 .ep = { 1974 .ep = {
@@ -2320,7 +1982,6 @@ static struct pxa2xx_udc memory = {
2320 .bmAttributes = USB_ENDPOINT_XFER_ISOC, 1982 .bmAttributes = USB_ENDPOINT_XFER_ISOC,
2321 .reg_udccs = &UDCCS8, 1983 .reg_udccs = &UDCCS8,
2322 .reg_uddr = &UDDR8, 1984 .reg_uddr = &UDDR8,
2323 drcmr (32)
2324 }, 1985 },
2325 .ep[9] = { 1986 .ep[9] = {
2326 .ep = { 1987 .ep = {
@@ -2335,7 +1996,6 @@ static struct pxa2xx_udc memory = {
2335 .reg_udccs = &UDCCS9, 1996 .reg_udccs = &UDCCS9,
2336 .reg_ubcr = &UBCR9, 1997 .reg_ubcr = &UBCR9,
2337 .reg_uddr = &UDDR9, 1998 .reg_uddr = &UDDR9,
2338 drcmr (33)
2339 }, 1999 },
2340 .ep[10] = { 2000 .ep[10] = {
2341 .ep = { 2001 .ep = {
@@ -2364,7 +2024,6 @@ static struct pxa2xx_udc memory = {
2364 .bmAttributes = USB_ENDPOINT_XFER_BULK, 2024 .bmAttributes = USB_ENDPOINT_XFER_BULK,
2365 .reg_udccs = &UDCCS11, 2025 .reg_udccs = &UDCCS11,
2366 .reg_uddr = &UDDR11, 2026 .reg_uddr = &UDDR11,
2367 drcmr (35)
2368 }, 2027 },
2369 .ep[12] = { 2028 .ep[12] = {
2370 .ep = { 2029 .ep = {
@@ -2379,7 +2038,6 @@ static struct pxa2xx_udc memory = {
2379 .reg_udccs = &UDCCS12, 2038 .reg_udccs = &UDCCS12,
2380 .reg_ubcr = &UBCR12, 2039 .reg_ubcr = &UBCR12,
2381 .reg_uddr = &UDDR12, 2040 .reg_uddr = &UDDR12,
2382 drcmr (36)
2383 }, 2041 },
2384 .ep[13] = { 2042 .ep[13] = {
2385 .ep = { 2043 .ep = {
@@ -2393,7 +2051,6 @@ static struct pxa2xx_udc memory = {
2393 .bmAttributes = USB_ENDPOINT_XFER_ISOC, 2051 .bmAttributes = USB_ENDPOINT_XFER_ISOC,
2394 .reg_udccs = &UDCCS13, 2052 .reg_udccs = &UDCCS13,
2395 .reg_uddr = &UDDR13, 2053 .reg_uddr = &UDDR13,
2396 drcmr (37)
2397 }, 2054 },
2398 .ep[14] = { 2055 .ep[14] = {
2399 .ep = { 2056 .ep = {
@@ -2408,7 +2065,6 @@ static struct pxa2xx_udc memory = {
2408 .reg_udccs = &UDCCS14, 2065 .reg_udccs = &UDCCS14,
2409 .reg_ubcr = &UBCR14, 2066 .reg_ubcr = &UBCR14,
2410 .reg_uddr = &UDDR14, 2067 .reg_uddr = &UDDR14,
2411 drcmr (38)
2412 }, 2068 },
2413 .ep[15] = { 2069 .ep[15] = {
2414 .ep = { 2070 .ep = {
@@ -2466,7 +2122,7 @@ static struct pxa2xx_udc memory = {
2466static int __init pxa2xx_udc_probe(struct platform_device *pdev) 2122static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2467{ 2123{
2468 struct pxa2xx_udc *dev = &memory; 2124 struct pxa2xx_udc *dev = &memory;
2469 int retval, out_dma = 1, vbus_irq, irq; 2125 int retval, vbus_irq, irq;
2470 u32 chiprev; 2126 u32 chiprev;
2471 2127
2472 /* insist on Intel/ARM/XScale */ 2128 /* insist on Intel/ARM/XScale */
@@ -2489,7 +2145,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2489 case PXA250_B2: case PXA210_B2: 2145 case PXA250_B2: case PXA210_B2:
2490 case PXA250_B1: case PXA210_B1: 2146 case PXA250_B1: case PXA210_B1:
2491 case PXA250_B0: case PXA210_B0: 2147 case PXA250_B0: case PXA210_B0:
2492 out_dma = 0; 2148 /* OUT-DMA is broken ... */
2493 /* fall through */ 2149 /* fall through */
2494 case PXA250_C0: case PXA210_C0: 2150 case PXA250_C0: case PXA210_C0:
2495 break; 2151 break;
@@ -2498,11 +2154,9 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2498 case IXP425_B0: 2154 case IXP425_B0:
2499 case IXP465_AD: 2155 case IXP465_AD:
2500 dev->has_cfr = 1; 2156 dev->has_cfr = 1;
2501 out_dma = 0;
2502 break; 2157 break;
2503#endif 2158#endif
2504 default: 2159 default:
2505 out_dma = 0;
2506 printk(KERN_ERR "%s: unrecognized processor: %08x\n", 2160 printk(KERN_ERR "%s: unrecognized processor: %08x\n",
2507 driver_name, chiprev); 2161 driver_name, chiprev);
2508 /* iop3xx, ixp4xx, ... */ 2162 /* iop3xx, ixp4xx, ... */
@@ -2513,36 +2167,41 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2513 if (irq < 0) 2167 if (irq < 0)
2514 return -ENODEV; 2168 return -ENODEV;
2515 2169
2516 pr_debug("%s: IRQ %d%s%s%s\n", driver_name, irq, 2170 pr_debug("%s: IRQ %d%s%s\n", driver_name, irq,
2517 dev->has_cfr ? "" : " (!cfr)", 2171 dev->has_cfr ? "" : " (!cfr)",
2518 out_dma ? "" : " (broken dma-out)", 2172 SIZE_STR "(pio)"
2519 SIZE_STR DMASTR
2520 ); 2173 );
2521 2174
2522#ifdef USE_DMA
2523#ifndef USE_OUT_DMA
2524 out_dma = 0;
2525#endif
2526 /* pxa 250 erratum 130 prevents using OUT dma (fixed C0) */
2527 if (!out_dma) {
2528 DMSG("disabled OUT dma\n");
2529 dev->ep[ 2].reg_drcmr = dev->ep[ 4].reg_drcmr = 0;
2530 dev->ep[ 7].reg_drcmr = dev->ep[ 9].reg_drcmr = 0;
2531 dev->ep[12].reg_drcmr = dev->ep[14].reg_drcmr = 0;
2532 }
2533#endif
2534
2535 /* other non-static parts of init */ 2175 /* other non-static parts of init */
2536 dev->dev = &pdev->dev; 2176 dev->dev = &pdev->dev;
2537 dev->mach = pdev->dev.platform_data; 2177 dev->mach = pdev->dev.platform_data;
2178
2538 if (dev->mach->gpio_vbus) { 2179 if (dev->mach->gpio_vbus) {
2539 udc_gpio_init_vbus(dev->mach->gpio_vbus); 2180 if ((retval = gpio_request(dev->mach->gpio_vbus,
2540 vbus_irq = udc_gpio_to_irq(dev->mach->gpio_vbus); 2181 "pxa2xx_udc GPIO VBUS"))) {
2182 dev_dbg(&pdev->dev,
2183 "can't get vbus gpio %d, err: %d\n",
2184 dev->mach->gpio_vbus, retval);
2185 return -EBUSY;
2186 }
2187 gpio_direction_input(dev->mach->gpio_vbus);
2188 vbus_irq = gpio_to_irq(dev->mach->gpio_vbus);
2541 set_irq_type(vbus_irq, IRQT_BOTHEDGE); 2189 set_irq_type(vbus_irq, IRQT_BOTHEDGE);
2542 } else 2190 } else
2543 vbus_irq = 0; 2191 vbus_irq = 0;
2544 if (dev->mach->gpio_pullup) 2192
2545 udc_gpio_init_pullup(dev->mach->gpio_pullup); 2193 if (dev->mach->gpio_pullup) {
2194 if ((retval = gpio_request(dev->mach->gpio_pullup,
2195 "pca2xx_udc GPIO PULLUP"))) {
2196 dev_dbg(&pdev->dev,
2197 "can't get pullup gpio %d, err: %d\n",
2198 dev->mach->gpio_pullup, retval);
2199 if (dev->mach->gpio_vbus)
2200 gpio_free(dev->mach->gpio_vbus);
2201 return -EBUSY;
2202 }
2203 gpio_direction_output(dev->mach->gpio_pullup, 0);
2204 }
2546 2205
2547 init_timer(&dev->timer); 2206 init_timer(&dev->timer);
2548 dev->timer.function = udc_watchdog; 2207 dev->timer.function = udc_watchdog;
@@ -2566,6 +2225,10 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2566 if (retval != 0) { 2225 if (retval != 0) {
2567 printk(KERN_ERR "%s: can't get irq %d, err %d\n", 2226 printk(KERN_ERR "%s: can't get irq %d, err %d\n",
2568 driver_name, irq, retval); 2227 driver_name, irq, retval);
2228 if (dev->mach->gpio_pullup)
2229 gpio_free(dev->mach->gpio_pullup);
2230 if (dev->mach->gpio_vbus)
2231 gpio_free(dev->mach->gpio_vbus);
2569 return -EBUSY; 2232 return -EBUSY;
2570 } 2233 }
2571 dev->got_irq = 1; 2234 dev->got_irq = 1;
@@ -2581,6 +2244,10 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2581 driver_name, LUBBOCK_USB_DISC_IRQ, retval); 2244 driver_name, LUBBOCK_USB_DISC_IRQ, retval);
2582lubbock_fail0: 2245lubbock_fail0:
2583 free_irq(irq, dev); 2246 free_irq(irq, dev);
2247 if (dev->mach->gpio_pullup)
2248 gpio_free(dev->mach->gpio_pullup);
2249 if (dev->mach->gpio_vbus)
2250 gpio_free(dev->mach->gpio_vbus);
2584 return -EBUSY; 2251 return -EBUSY;
2585 } 2252 }
2586 retval = request_irq(LUBBOCK_USB_IRQ, 2253 retval = request_irq(LUBBOCK_USB_IRQ,
@@ -2593,11 +2260,6 @@ lubbock_fail0:
2593 free_irq(LUBBOCK_USB_DISC_IRQ, dev); 2260 free_irq(LUBBOCK_USB_DISC_IRQ, dev);
2594 goto lubbock_fail0; 2261 goto lubbock_fail0;
2595 } 2262 }
2596#ifdef DEBUG
2597 /* with U-Boot (but not BLOB), hex is off by default */
2598 HEX_DISPLAY(dev->stats.irqs);
2599 LUB_DISC_BLNK_LED &= 0xff;
2600#endif
2601 } else 2263 } else
2602#endif 2264#endif
2603 if (vbus_irq) { 2265 if (vbus_irq) {
@@ -2608,6 +2270,10 @@ lubbock_fail0:
2608 printk(KERN_ERR "%s: can't get irq %i, err %d\n", 2270 printk(KERN_ERR "%s: can't get irq %i, err %d\n",
2609 driver_name, vbus_irq, retval); 2271 driver_name, vbus_irq, retval);
2610 free_irq(irq, dev); 2272 free_irq(irq, dev);
2273 if (dev->mach->gpio_pullup)
2274 gpio_free(dev->mach->gpio_pullup);
2275 if (dev->mach->gpio_vbus)
2276 gpio_free(dev->mach->gpio_vbus);
2611 return -EBUSY; 2277 return -EBUSY;
2612 } 2278 }
2613 } 2279 }
@@ -2641,8 +2307,13 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2641 free_irq(LUBBOCK_USB_IRQ, dev); 2307 free_irq(LUBBOCK_USB_IRQ, dev);
2642 } 2308 }
2643#endif 2309#endif
2644 if (dev->mach->gpio_vbus) 2310 if (dev->mach->gpio_vbus) {
2645 free_irq(IRQ_GPIO(dev->mach->gpio_vbus), dev); 2311 free_irq(gpio_to_irq(dev->mach->gpio_vbus), dev);
2312 gpio_free(dev->mach->gpio_vbus);
2313 }
2314 if (dev->mach->gpio_pullup)
2315 gpio_free(dev->mach->gpio_pullup);
2316
2646 platform_set_drvdata(pdev, NULL); 2317 platform_set_drvdata(pdev, NULL);
2647 the_controller = NULL; 2318 the_controller = NULL;
2648 return 0; 2319 return 0;