diff options
author | Dmitry Torokhov <dtor@insightbb.com> | 2007-02-10 01:26:32 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2007-02-10 01:26:32 -0500 |
commit | b22364c8eec89e6b0c081a237f3b6348df87796f (patch) | |
tree | 233a923281fb640106465d076997ff511efb6edf /drivers/usb/gadget | |
parent | 2c8dc071517ec2843869024dc82be2e246f41064 (diff) | |
parent | 66efc5a7e3061c3597ac43a8bb1026488d57e66b (diff) |
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/at91_udc.c | 259 | ||||
-rw-r--r-- | drivers/usb/gadget/at91_udc.h | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/config.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 7 | ||||
-rw-r--r-- | drivers/usb/gadget/epautoconf.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/ether.c | 148 | ||||
-rw-r--r-- | drivers/usb/gadget/file_storage.c | 51 | ||||
-rw-r--r-- | drivers/usb/gadget/gadget_chips.h | 8 | ||||
-rw-r--r-- | drivers/usb/gadget/gmidi.c | 14 | ||||
-rw-r--r-- | drivers/usb/gadget/goku_udc.c | 14 | ||||
-rw-r--r-- | drivers/usb/gadget/inode.c | 240 | ||||
-rw-r--r-- | drivers/usb/gadget/lh7a40x_udc.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/lh7a40x_udc.h | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/net2280.c | 13 | ||||
-rw-r--r-- | drivers/usb/gadget/omap_udc.c | 260 | ||||
-rw-r--r-- | drivers/usb/gadget/omap_udc.h | 3 | ||||
-rw-r--r-- | drivers/usb/gadget/pxa2xx_udc.c | 9 | ||||
-rw-r--r-- | drivers/usb/gadget/serial.c | 10 | ||||
-rw-r--r-- | drivers/usb/gadget/usbstring.c | 2 | ||||
-rw-r--r-- | drivers/usb/gadget/zero.c | 2 |
20 files changed, 648 insertions, 419 deletions
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 72f3db99ff94..f39050145f1f 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -39,18 +39,20 @@ | |||
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
41 | #include <linux/clk.h> | 41 | #include <linux/clk.h> |
42 | #include <linux/usb_ch9.h> | 42 | #include <linux/usb/ch9.h> |
43 | #include <linux/usb_gadget.h> | 43 | #include <linux/usb_gadget.h> |
44 | 44 | ||
45 | #include <asm/byteorder.h> | 45 | #include <asm/byteorder.h> |
46 | #include <asm/hardware.h> | ||
46 | #include <asm/io.h> | 47 | #include <asm/io.h> |
47 | #include <asm/irq.h> | 48 | #include <asm/irq.h> |
48 | #include <asm/system.h> | 49 | #include <asm/system.h> |
49 | #include <asm/mach-types.h> | 50 | #include <asm/mach-types.h> |
50 | 51 | ||
51 | #include <asm/arch/hardware.h> | ||
52 | #include <asm/arch/gpio.h> | 52 | #include <asm/arch/gpio.h> |
53 | #include <asm/arch/board.h> | 53 | #include <asm/arch/board.h> |
54 | #include <asm/arch/cpu.h> | ||
55 | #include <asm/arch/at91sam9261_matrix.h> | ||
54 | 56 | ||
55 | #include "at91_udc.h" | 57 | #include "at91_udc.h" |
56 | 58 | ||
@@ -78,27 +80,11 @@ | |||
78 | static const char driver_name [] = "at91_udc"; | 80 | static const char driver_name [] = "at91_udc"; |
79 | static const char ep0name[] = "ep0"; | 81 | static const char ep0name[] = "ep0"; |
80 | 82 | ||
81 | /*-------------------------------------------------------------------------*/ | ||
82 | |||
83 | /* | ||
84 | * Read from a UDP register. | ||
85 | */ | ||
86 | static inline unsigned long at91_udp_read(unsigned int reg) | ||
87 | { | ||
88 | void __iomem *udp_base = (void __iomem *)AT91_VA_BASE_UDP; | ||
89 | 83 | ||
90 | return __raw_readl(udp_base + reg); | 84 | #define at91_udp_read(dev, reg) \ |
91 | } | 85 | __raw_readl((dev)->udp_baseaddr + (reg)) |
92 | 86 | #define at91_udp_write(dev, reg, val) \ | |
93 | /* | 87 | __raw_writel((val), (dev)->udp_baseaddr + (reg)) |
94 | * Write to a UDP register. | ||
95 | */ | ||
96 | static inline void at91_udp_write(unsigned int reg, unsigned long value) | ||
97 | { | ||
98 | void __iomem *udp_base = (void __iomem *)AT91_VA_BASE_UDP; | ||
99 | |||
100 | __raw_writel(value, udp_base + reg); | ||
101 | } | ||
102 | 88 | ||
103 | /*-------------------------------------------------------------------------*/ | 89 | /*-------------------------------------------------------------------------*/ |
104 | 90 | ||
@@ -210,13 +196,13 @@ static int proc_udc_show(struct seq_file *s, void *unused) | |||
210 | return 0; | 196 | return 0; |
211 | } | 197 | } |
212 | 198 | ||
213 | tmp = at91_udp_read(AT91_UDP_FRM_NUM); | 199 | tmp = at91_udp_read(udc, AT91_UDP_FRM_NUM); |
214 | seq_printf(s, "frame %05x:%s%s frame=%d\n", tmp, | 200 | seq_printf(s, "frame %05x:%s%s frame=%d\n", tmp, |
215 | (tmp & AT91_UDP_FRM_OK) ? " ok" : "", | 201 | (tmp & AT91_UDP_FRM_OK) ? " ok" : "", |
216 | (tmp & AT91_UDP_FRM_ERR) ? " err" : "", | 202 | (tmp & AT91_UDP_FRM_ERR) ? " err" : "", |
217 | (tmp & AT91_UDP_NUM)); | 203 | (tmp & AT91_UDP_NUM)); |
218 | 204 | ||
219 | tmp = at91_udp_read(AT91_UDP_GLB_STAT); | 205 | tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); |
220 | seq_printf(s, "glbstate %02x:%s" FOURBITS "\n", tmp, | 206 | seq_printf(s, "glbstate %02x:%s" FOURBITS "\n", tmp, |
221 | (tmp & AT91_UDP_RMWUPE) ? " rmwupe" : "", | 207 | (tmp & AT91_UDP_RMWUPE) ? " rmwupe" : "", |
222 | (tmp & AT91_UDP_RSMINPR) ? " rsminpr" : "", | 208 | (tmp & AT91_UDP_RSMINPR) ? " rsminpr" : "", |
@@ -224,13 +210,13 @@ static int proc_udc_show(struct seq_file *s, void *unused) | |||
224 | (tmp & AT91_UDP_CONFG) ? " confg" : "", | 210 | (tmp & AT91_UDP_CONFG) ? " confg" : "", |
225 | (tmp & AT91_UDP_FADDEN) ? " fadden" : ""); | 211 | (tmp & AT91_UDP_FADDEN) ? " fadden" : ""); |
226 | 212 | ||
227 | tmp = at91_udp_read(AT91_UDP_FADDR); | 213 | tmp = at91_udp_read(udc, AT91_UDP_FADDR); |
228 | seq_printf(s, "faddr %03x:%s fadd=%d\n", tmp, | 214 | seq_printf(s, "faddr %03x:%s fadd=%d\n", tmp, |
229 | (tmp & AT91_UDP_FEN) ? " fen" : "", | 215 | (tmp & AT91_UDP_FEN) ? " fen" : "", |
230 | (tmp & AT91_UDP_FADD)); | 216 | (tmp & AT91_UDP_FADD)); |
231 | 217 | ||
232 | proc_irq_show(s, "imr ", at91_udp_read(AT91_UDP_IMR)); | 218 | proc_irq_show(s, "imr ", at91_udp_read(udc, AT91_UDP_IMR)); |
233 | proc_irq_show(s, "isr ", at91_udp_read(AT91_UDP_ISR)); | 219 | proc_irq_show(s, "isr ", at91_udp_read(udc, AT91_UDP_ISR)); |
234 | 220 | ||
235 | if (udc->enabled && udc->vbus) { | 221 | if (udc->enabled && udc->vbus) { |
236 | proc_ep_show(s, &udc->ep[0]); | 222 | proc_ep_show(s, &udc->ep[0]); |
@@ -286,6 +272,7 @@ static inline void remove_debug_file(struct at91_udc *udc) {} | |||
286 | static void done(struct at91_ep *ep, struct at91_request *req, int status) | 272 | static void done(struct at91_ep *ep, struct at91_request *req, int status) |
287 | { | 273 | { |
288 | unsigned stopped = ep->stopped; | 274 | unsigned stopped = ep->stopped; |
275 | struct at91_udc *udc = ep->udc; | ||
289 | 276 | ||
290 | list_del_init(&req->queue); | 277 | list_del_init(&req->queue); |
291 | if (req->req.status == -EINPROGRESS) | 278 | if (req->req.status == -EINPROGRESS) |
@@ -301,7 +288,7 @@ static void done(struct at91_ep *ep, struct at91_request *req, int status) | |||
301 | 288 | ||
302 | /* ep0 is always ready; other endpoints need a non-empty queue */ | 289 | /* ep0 is always ready; other endpoints need a non-empty queue */ |
303 | if (list_empty(&ep->queue) && ep->int_mask != (1 << 0)) | 290 | if (list_empty(&ep->queue) && ep->int_mask != (1 << 0)) |
304 | at91_udp_write(AT91_UDP_IDR, ep->int_mask); | 291 | at91_udp_write(udc, AT91_UDP_IDR, ep->int_mask); |
305 | } | 292 | } |
306 | 293 | ||
307 | /*-------------------------------------------------------------------------*/ | 294 | /*-------------------------------------------------------------------------*/ |
@@ -554,8 +541,8 @@ ok: | |||
554 | * reset/init endpoint fifo. NOTE: leaves fifo_bank alone, | 541 | * reset/init endpoint fifo. NOTE: leaves fifo_bank alone, |
555 | * since endpoint resets don't reset hw pingpong state. | 542 | * since endpoint resets don't reset hw pingpong state. |
556 | */ | 543 | */ |
557 | at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); | 544 | at91_udp_write(dev, AT91_UDP_RST_EP, ep->int_mask); |
558 | at91_udp_write(AT91_UDP_RST_EP, 0); | 545 | at91_udp_write(dev, AT91_UDP_RST_EP, 0); |
559 | 546 | ||
560 | local_irq_restore(flags); | 547 | local_irq_restore(flags); |
561 | return 0; | 548 | return 0; |
@@ -564,6 +551,7 @@ ok: | |||
564 | static int at91_ep_disable (struct usb_ep * _ep) | 551 | static int at91_ep_disable (struct usb_ep * _ep) |
565 | { | 552 | { |
566 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); | 553 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); |
554 | struct at91_udc *udc = ep->udc; | ||
567 | unsigned long flags; | 555 | unsigned long flags; |
568 | 556 | ||
569 | if (ep == &ep->udc->ep[0]) | 557 | if (ep == &ep->udc->ep[0]) |
@@ -579,8 +567,8 @@ static int at91_ep_disable (struct usb_ep * _ep) | |||
579 | 567 | ||
580 | /* reset fifos and endpoint */ | 568 | /* reset fifos and endpoint */ |
581 | if (ep->udc->clocked) { | 569 | if (ep->udc->clocked) { |
582 | at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); | 570 | at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); |
583 | at91_udp_write(AT91_UDP_RST_EP, 0); | 571 | at91_udp_write(udc, AT91_UDP_RST_EP, 0); |
584 | __raw_writel(0, ep->creg); | 572 | __raw_writel(0, ep->creg); |
585 | } | 573 | } |
586 | 574 | ||
@@ -598,7 +586,7 @@ at91_ep_alloc_request(struct usb_ep *_ep, unsigned int gfp_flags) | |||
598 | { | 586 | { |
599 | struct at91_request *req; | 587 | struct at91_request *req; |
600 | 588 | ||
601 | req = kcalloc(1, sizeof (struct at91_request), gfp_flags); | 589 | req = kzalloc(sizeof (struct at91_request), gfp_flags); |
602 | if (!req) | 590 | if (!req) |
603 | return NULL; | 591 | return NULL; |
604 | 592 | ||
@@ -695,10 +683,10 @@ static int at91_ep_queue(struct usb_ep *_ep, | |||
695 | * reconfigures the endpoints. | 683 | * reconfigures the endpoints. |
696 | */ | 684 | */ |
697 | if (dev->wait_for_config_ack) { | 685 | if (dev->wait_for_config_ack) { |
698 | tmp = at91_udp_read(AT91_UDP_GLB_STAT); | 686 | tmp = at91_udp_read(dev, AT91_UDP_GLB_STAT); |
699 | tmp ^= AT91_UDP_CONFG; | 687 | tmp ^= AT91_UDP_CONFG; |
700 | VDBG("toggle config\n"); | 688 | VDBG("toggle config\n"); |
701 | at91_udp_write(AT91_UDP_GLB_STAT, tmp); | 689 | at91_udp_write(dev, AT91_UDP_GLB_STAT, tmp); |
702 | } | 690 | } |
703 | if (req->req.length == 0) { | 691 | if (req->req.length == 0) { |
704 | ep0_in_status: | 692 | ep0_in_status: |
@@ -727,7 +715,7 @@ ep0_in_status: | |||
727 | 715 | ||
728 | if (req && !status) { | 716 | if (req && !status) { |
729 | list_add_tail (&req->queue, &ep->queue); | 717 | list_add_tail (&req->queue, &ep->queue); |
730 | at91_udp_write(AT91_UDP_IER, ep->int_mask); | 718 | at91_udp_write(dev, AT91_UDP_IER, ep->int_mask); |
731 | } | 719 | } |
732 | done: | 720 | done: |
733 | local_irq_restore(flags); | 721 | local_irq_restore(flags); |
@@ -758,6 +746,7 @@ static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
758 | static int at91_ep_set_halt(struct usb_ep *_ep, int value) | 746 | static int at91_ep_set_halt(struct usb_ep *_ep, int value) |
759 | { | 747 | { |
760 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); | 748 | struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); |
749 | struct at91_udc *udc = ep->udc; | ||
761 | u32 __iomem *creg; | 750 | u32 __iomem *creg; |
762 | u32 csr; | 751 | u32 csr; |
763 | unsigned long flags; | 752 | unsigned long flags; |
@@ -785,8 +774,8 @@ static int at91_ep_set_halt(struct usb_ep *_ep, int value) | |||
785 | csr |= AT91_UDP_FORCESTALL; | 774 | csr |= AT91_UDP_FORCESTALL; |
786 | VDBG("halt %s\n", ep->ep.name); | 775 | VDBG("halt %s\n", ep->ep.name); |
787 | } else { | 776 | } else { |
788 | at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); | 777 | at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); |
789 | at91_udp_write(AT91_UDP_RST_EP, 0); | 778 | at91_udp_write(udc, AT91_UDP_RST_EP, 0); |
790 | csr &= ~AT91_UDP_FORCESTALL; | 779 | csr &= ~AT91_UDP_FORCESTALL; |
791 | } | 780 | } |
792 | __raw_writel(csr, creg); | 781 | __raw_writel(csr, creg); |
@@ -813,9 +802,11 @@ static struct usb_ep_ops at91_ep_ops = { | |||
813 | 802 | ||
814 | static int at91_get_frame(struct usb_gadget *gadget) | 803 | static int at91_get_frame(struct usb_gadget *gadget) |
815 | { | 804 | { |
805 | struct at91_udc *udc = to_udc(gadget); | ||
806 | |||
816 | if (!to_udc(gadget)->clocked) | 807 | if (!to_udc(gadget)->clocked) |
817 | return -EINVAL; | 808 | return -EINVAL; |
818 | return at91_udp_read(AT91_UDP_FRM_NUM) & AT91_UDP_NUM; | 809 | return at91_udp_read(udc, AT91_UDP_FRM_NUM) & AT91_UDP_NUM; |
819 | } | 810 | } |
820 | 811 | ||
821 | static int at91_wakeup(struct usb_gadget *gadget) | 812 | static int at91_wakeup(struct usb_gadget *gadget) |
@@ -833,11 +824,11 @@ static int at91_wakeup(struct usb_gadget *gadget) | |||
833 | 824 | ||
834 | /* NOTE: some "early versions" handle ESR differently ... */ | 825 | /* NOTE: some "early versions" handle ESR differently ... */ |
835 | 826 | ||
836 | glbstate = at91_udp_read(AT91_UDP_GLB_STAT); | 827 | glbstate = at91_udp_read(udc, AT91_UDP_GLB_STAT); |
837 | if (!(glbstate & AT91_UDP_ESR)) | 828 | if (!(glbstate & AT91_UDP_ESR)) |
838 | goto done; | 829 | goto done; |
839 | glbstate |= AT91_UDP_ESR; | 830 | glbstate |= AT91_UDP_ESR; |
840 | at91_udp_write(AT91_UDP_GLB_STAT, glbstate); | 831 | at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate); |
841 | 832 | ||
842 | done: | 833 | done: |
843 | local_irq_restore(flags); | 834 | local_irq_restore(flags); |
@@ -861,6 +852,7 @@ static void udc_reinit(struct at91_udc *udc) | |||
861 | ep->stopped = 0; | 852 | ep->stopped = 0; |
862 | ep->fifo_bank = 0; | 853 | ep->fifo_bank = 0; |
863 | ep->ep.maxpacket = ep->maxpacket; | 854 | ep->ep.maxpacket = ep->maxpacket; |
855 | ep->creg = (void __iomem *) udc->udp_baseaddr + AT91_UDP_CSR(i); | ||
864 | // initialiser une queue par endpoint | 856 | // initialiser une queue par endpoint |
865 | INIT_LIST_HEAD(&ep->queue); | 857 | INIT_LIST_HEAD(&ep->queue); |
866 | } | 858 | } |
@@ -915,14 +907,41 @@ static void pullup(struct at91_udc *udc, int is_on) | |||
915 | if (!udc->enabled || !udc->vbus) | 907 | if (!udc->enabled || !udc->vbus) |
916 | is_on = 0; | 908 | is_on = 0; |
917 | DBG("%sactive\n", is_on ? "" : "in"); | 909 | DBG("%sactive\n", is_on ? "" : "in"); |
910 | |||
918 | if (is_on) { | 911 | if (is_on) { |
919 | clk_on(udc); | 912 | clk_on(udc); |
920 | at91_udp_write(AT91_UDP_TXVC, 0); | 913 | at91_udp_write(udc, AT91_UDP_TXVC, 0); |
921 | at91_set_gpio_value(udc->board.pullup_pin, 1); | 914 | if (cpu_is_at91rm9200()) |
922 | } else { | 915 | at91_set_gpio_value(udc->board.pullup_pin, 1); |
916 | else if (cpu_is_at91sam9260()) { | ||
917 | u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); | ||
918 | |||
919 | txvc |= AT91_UDP_TXVC_PUON; | ||
920 | at91_udp_write(udc, AT91_UDP_TXVC, txvc); | ||
921 | } else if (cpu_is_at91sam9261()) { | ||
922 | u32 usbpucr; | ||
923 | |||
924 | usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR); | ||
925 | usbpucr |= AT91_MATRIX_USBPUCR_PUON; | ||
926 | at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr); | ||
927 | } | ||
928 | } else { | ||
923 | stop_activity(udc); | 929 | stop_activity(udc); |
924 | at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); | 930 | at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); |
925 | at91_set_gpio_value(udc->board.pullup_pin, 0); | 931 | if (cpu_is_at91rm9200()) |
932 | at91_set_gpio_value(udc->board.pullup_pin, 0); | ||
933 | else if (cpu_is_at91sam9260()) { | ||
934 | u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC); | ||
935 | |||
936 | txvc &= ~AT91_UDP_TXVC_PUON; | ||
937 | at91_udp_write(udc, AT91_UDP_TXVC, txvc); | ||
938 | } else if (cpu_is_at91sam9261()) { | ||
939 | u32 usbpucr; | ||
940 | |||
941 | usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR); | ||
942 | usbpucr &= ~AT91_MATRIX_USBPUCR_PUON; | ||
943 | at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr); | ||
944 | } | ||
926 | clk_off(udc); | 945 | clk_off(udc); |
927 | } | 946 | } |
928 | } | 947 | } |
@@ -936,7 +955,10 @@ static int at91_vbus_session(struct usb_gadget *gadget, int is_active) | |||
936 | // VDBG("vbus %s\n", is_active ? "on" : "off"); | 955 | // VDBG("vbus %s\n", is_active ? "on" : "off"); |
937 | local_irq_save(flags); | 956 | local_irq_save(flags); |
938 | udc->vbus = (is_active != 0); | 957 | udc->vbus = (is_active != 0); |
939 | pullup(udc, is_active); | 958 | if (udc->driver) |
959 | pullup(udc, is_active); | ||
960 | else | ||
961 | pullup(udc, 0); | ||
940 | local_irq_restore(flags); | 962 | local_irq_restore(flags); |
941 | return 0; | 963 | return 0; |
942 | } | 964 | } |
@@ -1086,7 +1108,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1086 | 1108 | ||
1087 | case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) | 1109 | case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) |
1088 | | USB_REQ_SET_CONFIGURATION: | 1110 | | USB_REQ_SET_CONFIGURATION: |
1089 | tmp = at91_udp_read(AT91_UDP_GLB_STAT) & AT91_UDP_CONFG; | 1111 | tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT) & AT91_UDP_CONFG; |
1090 | if (pkt.r.wValue) | 1112 | if (pkt.r.wValue) |
1091 | udc->wait_for_config_ack = (tmp == 0); | 1113 | udc->wait_for_config_ack = (tmp == 0); |
1092 | else | 1114 | else |
@@ -1103,7 +1125,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1103 | case ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) | 1125 | case ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) |
1104 | | USB_REQ_GET_STATUS: | 1126 | | USB_REQ_GET_STATUS: |
1105 | tmp = (udc->selfpowered << USB_DEVICE_SELF_POWERED); | 1127 | tmp = (udc->selfpowered << USB_DEVICE_SELF_POWERED); |
1106 | if (at91_udp_read(AT91_UDP_GLB_STAT) & AT91_UDP_ESR) | 1128 | if (at91_udp_read(udc, AT91_UDP_GLB_STAT) & AT91_UDP_ESR) |
1107 | tmp |= (1 << USB_DEVICE_REMOTE_WAKEUP); | 1129 | tmp |= (1 << USB_DEVICE_REMOTE_WAKEUP); |
1108 | PACKET("get device status\n"); | 1130 | PACKET("get device status\n"); |
1109 | __raw_writeb(tmp, dreg); | 1131 | __raw_writeb(tmp, dreg); |
@@ -1114,17 +1136,17 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1114 | | USB_REQ_SET_FEATURE: | 1136 | | USB_REQ_SET_FEATURE: |
1115 | if (w_value != USB_DEVICE_REMOTE_WAKEUP) | 1137 | if (w_value != USB_DEVICE_REMOTE_WAKEUP) |
1116 | goto stall; | 1138 | goto stall; |
1117 | tmp = at91_udp_read(AT91_UDP_GLB_STAT); | 1139 | tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); |
1118 | tmp |= AT91_UDP_ESR; | 1140 | tmp |= AT91_UDP_ESR; |
1119 | at91_udp_write(AT91_UDP_GLB_STAT, tmp); | 1141 | at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); |
1120 | goto succeed; | 1142 | goto succeed; |
1121 | case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) | 1143 | case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) |
1122 | | USB_REQ_CLEAR_FEATURE: | 1144 | | USB_REQ_CLEAR_FEATURE: |
1123 | if (w_value != USB_DEVICE_REMOTE_WAKEUP) | 1145 | if (w_value != USB_DEVICE_REMOTE_WAKEUP) |
1124 | goto stall; | 1146 | goto stall; |
1125 | tmp = at91_udp_read(AT91_UDP_GLB_STAT); | 1147 | tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); |
1126 | tmp &= ~AT91_UDP_ESR; | 1148 | tmp &= ~AT91_UDP_ESR; |
1127 | at91_udp_write(AT91_UDP_GLB_STAT, tmp); | 1149 | at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); |
1128 | goto succeed; | 1150 | goto succeed; |
1129 | 1151 | ||
1130 | /* | 1152 | /* |
@@ -1206,8 +1228,8 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1206 | } else if (ep->is_in) | 1228 | } else if (ep->is_in) |
1207 | goto stall; | 1229 | goto stall; |
1208 | 1230 | ||
1209 | at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); | 1231 | at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask); |
1210 | at91_udp_write(AT91_UDP_RST_EP, 0); | 1232 | at91_udp_write(udc, AT91_UDP_RST_EP, 0); |
1211 | tmp = __raw_readl(ep->creg); | 1233 | tmp = __raw_readl(ep->creg); |
1212 | tmp |= CLR_FX; | 1234 | tmp |= CLR_FX; |
1213 | tmp &= ~(SET_FX | AT91_UDP_FORCESTALL); | 1235 | tmp &= ~(SET_FX | AT91_UDP_FORCESTALL); |
@@ -1222,7 +1244,10 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr) | |||
1222 | #undef w_length | 1244 | #undef w_length |
1223 | 1245 | ||
1224 | /* pass request up to the gadget driver */ | 1246 | /* pass request up to the gadget driver */ |
1225 | status = udc->driver->setup(&udc->gadget, &pkt.r); | 1247 | if (udc->driver) |
1248 | status = udc->driver->setup(&udc->gadget, &pkt.r); | ||
1249 | else | ||
1250 | status = -ENODEV; | ||
1226 | if (status < 0) { | 1251 | if (status < 0) { |
1227 | stall: | 1252 | stall: |
1228 | VDBG("req %02x.%02x protocol STALL; stat %d\n", | 1253 | VDBG("req %02x.%02x protocol STALL; stat %d\n", |
@@ -1300,13 +1325,13 @@ static void handle_ep0(struct at91_udc *udc) | |||
1300 | if (udc->wait_for_addr_ack) { | 1325 | if (udc->wait_for_addr_ack) { |
1301 | u32 tmp; | 1326 | u32 tmp; |
1302 | 1327 | ||
1303 | at91_udp_write(AT91_UDP_FADDR, | 1328 | at91_udp_write(udc, AT91_UDP_FADDR, |
1304 | AT91_UDP_FEN | udc->addr); | 1329 | AT91_UDP_FEN | udc->addr); |
1305 | tmp = at91_udp_read(AT91_UDP_GLB_STAT); | 1330 | tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT); |
1306 | tmp &= ~AT91_UDP_FADDEN; | 1331 | tmp &= ~AT91_UDP_FADDEN; |
1307 | if (udc->addr) | 1332 | if (udc->addr) |
1308 | tmp |= AT91_UDP_FADDEN; | 1333 | tmp |= AT91_UDP_FADDEN; |
1309 | at91_udp_write(AT91_UDP_GLB_STAT, tmp); | 1334 | at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp); |
1310 | 1335 | ||
1311 | udc->wait_for_addr_ack = 0; | 1336 | udc->wait_for_addr_ack = 0; |
1312 | VDBG("address %d\n", udc->addr); | 1337 | VDBG("address %d\n", udc->addr); |
@@ -1374,28 +1399,28 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1374 | while (rescans--) { | 1399 | while (rescans--) { |
1375 | u32 status; | 1400 | u32 status; |
1376 | 1401 | ||
1377 | status = at91_udp_read(AT91_UDP_ISR) | 1402 | status = at91_udp_read(udc, AT91_UDP_ISR) |
1378 | & at91_udp_read(AT91_UDP_IMR); | 1403 | & at91_udp_read(udc, AT91_UDP_IMR); |
1379 | if (!status) | 1404 | if (!status) |
1380 | break; | 1405 | break; |
1381 | 1406 | ||
1382 | /* USB reset irq: not maskable */ | 1407 | /* USB reset irq: not maskable */ |
1383 | if (status & AT91_UDP_ENDBUSRES) { | 1408 | if (status & AT91_UDP_ENDBUSRES) { |
1384 | at91_udp_write(AT91_UDP_IDR, ~MINIMUS_INTERRUPTUS); | 1409 | at91_udp_write(udc, AT91_UDP_IDR, ~MINIMUS_INTERRUPTUS); |
1385 | at91_udp_write(AT91_UDP_IER, MINIMUS_INTERRUPTUS); | 1410 | at91_udp_write(udc, AT91_UDP_IER, MINIMUS_INTERRUPTUS); |
1386 | /* Atmel code clears this irq twice */ | 1411 | /* Atmel code clears this irq twice */ |
1387 | at91_udp_write(AT91_UDP_ICR, AT91_UDP_ENDBUSRES); | 1412 | at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_ENDBUSRES); |
1388 | at91_udp_write(AT91_UDP_ICR, AT91_UDP_ENDBUSRES); | 1413 | at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_ENDBUSRES); |
1389 | VDBG("end bus reset\n"); | 1414 | VDBG("end bus reset\n"); |
1390 | udc->addr = 0; | 1415 | udc->addr = 0; |
1391 | stop_activity(udc); | 1416 | stop_activity(udc); |
1392 | 1417 | ||
1393 | /* enable ep0 */ | 1418 | /* enable ep0 */ |
1394 | at91_udp_write(AT91_UDP_CSR(0), | 1419 | at91_udp_write(udc, AT91_UDP_CSR(0), |
1395 | AT91_UDP_EPEDS | AT91_UDP_EPTYPE_CTRL); | 1420 | AT91_UDP_EPEDS | AT91_UDP_EPTYPE_CTRL); |
1396 | udc->gadget.speed = USB_SPEED_FULL; | 1421 | udc->gadget.speed = USB_SPEED_FULL; |
1397 | udc->suspended = 0; | 1422 | udc->suspended = 0; |
1398 | at91_udp_write(AT91_UDP_IER, AT91_UDP_EP(0)); | 1423 | at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_EP(0)); |
1399 | 1424 | ||
1400 | /* | 1425 | /* |
1401 | * NOTE: this driver keeps clocks off unless the | 1426 | * NOTE: this driver keeps clocks off unless the |
@@ -1406,9 +1431,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1406 | 1431 | ||
1407 | /* host initiated suspend (3+ms bus idle) */ | 1432 | /* host initiated suspend (3+ms bus idle) */ |
1408 | } else if (status & AT91_UDP_RXSUSP) { | 1433 | } else if (status & AT91_UDP_RXSUSP) { |
1409 | at91_udp_write(AT91_UDP_IDR, AT91_UDP_RXSUSP); | 1434 | at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXSUSP); |
1410 | at91_udp_write(AT91_UDP_IER, AT91_UDP_RXRSM); | 1435 | at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_RXRSM); |
1411 | at91_udp_write(AT91_UDP_ICR, AT91_UDP_RXSUSP); | 1436 | at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXSUSP); |
1412 | // VDBG("bus suspend\n"); | 1437 | // VDBG("bus suspend\n"); |
1413 | if (udc->suspended) | 1438 | if (udc->suspended) |
1414 | continue; | 1439 | continue; |
@@ -1425,9 +1450,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc) | |||
1425 | 1450 | ||
1426 | /* host initiated resume */ | 1451 | /* host initiated resume */ |
1427 | } else if (status & AT91_UDP_RXRSM) { | 1452 | } else if (status & AT91_UDP_RXRSM) { |
1428 | at91_udp_write(AT91_UDP_IDR, AT91_UDP_RXRSM); | 1453 | at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM); |
1429 | at91_udp_write(AT91_UDP_IER, AT91_UDP_RXSUSP); | 1454 | at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_RXSUSP); |
1430 | at91_udp_write(AT91_UDP_ICR, AT91_UDP_RXRSM); | 1455 | at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM); |
1431 | // VDBG("bus resume\n"); | 1456 | // VDBG("bus resume\n"); |
1432 | if (!udc->suspended) | 1457 | if (!udc->suspended) |
1433 | continue; | 1458 | continue; |
@@ -1485,8 +1510,6 @@ static struct at91_udc controller = { | |||
1485 | }, | 1510 | }, |
1486 | .udc = &controller, | 1511 | .udc = &controller, |
1487 | .maxpacket = 8, | 1512 | .maxpacket = 8, |
1488 | .creg = (void __iomem *)(AT91_VA_BASE_UDP | ||
1489 | + AT91_UDP_CSR(0)), | ||
1490 | .int_mask = 1 << 0, | 1513 | .int_mask = 1 << 0, |
1491 | }, | 1514 | }, |
1492 | .ep[1] = { | 1515 | .ep[1] = { |
@@ -1497,8 +1520,6 @@ static struct at91_udc controller = { | |||
1497 | .udc = &controller, | 1520 | .udc = &controller, |
1498 | .is_pingpong = 1, | 1521 | .is_pingpong = 1, |
1499 | .maxpacket = 64, | 1522 | .maxpacket = 64, |
1500 | .creg = (void __iomem *)(AT91_VA_BASE_UDP | ||
1501 | + AT91_UDP_CSR(1)), | ||
1502 | .int_mask = 1 << 1, | 1523 | .int_mask = 1 << 1, |
1503 | }, | 1524 | }, |
1504 | .ep[2] = { | 1525 | .ep[2] = { |
@@ -1509,8 +1530,6 @@ static struct at91_udc controller = { | |||
1509 | .udc = &controller, | 1530 | .udc = &controller, |
1510 | .is_pingpong = 1, | 1531 | .is_pingpong = 1, |
1511 | .maxpacket = 64, | 1532 | .maxpacket = 64, |
1512 | .creg = (void __iomem *)(AT91_VA_BASE_UDP | ||
1513 | + AT91_UDP_CSR(2)), | ||
1514 | .int_mask = 1 << 2, | 1533 | .int_mask = 1 << 2, |
1515 | }, | 1534 | }, |
1516 | .ep[3] = { | 1535 | .ep[3] = { |
@@ -1521,8 +1540,6 @@ static struct at91_udc controller = { | |||
1521 | }, | 1540 | }, |
1522 | .udc = &controller, | 1541 | .udc = &controller, |
1523 | .maxpacket = 8, | 1542 | .maxpacket = 8, |
1524 | .creg = (void __iomem *)(AT91_VA_BASE_UDP | ||
1525 | + AT91_UDP_CSR(3)), | ||
1526 | .int_mask = 1 << 3, | 1543 | .int_mask = 1 << 3, |
1527 | }, | 1544 | }, |
1528 | .ep[4] = { | 1545 | .ep[4] = { |
@@ -1533,8 +1550,6 @@ static struct at91_udc controller = { | |||
1533 | .udc = &controller, | 1550 | .udc = &controller, |
1534 | .is_pingpong = 1, | 1551 | .is_pingpong = 1, |
1535 | .maxpacket = 256, | 1552 | .maxpacket = 256, |
1536 | .creg = (void __iomem *)(AT91_VA_BASE_UDP | ||
1537 | + AT91_UDP_CSR(4)), | ||
1538 | .int_mask = 1 << 4, | 1553 | .int_mask = 1 << 4, |
1539 | }, | 1554 | }, |
1540 | .ep[5] = { | 1555 | .ep[5] = { |
@@ -1545,8 +1560,6 @@ static struct at91_udc controller = { | |||
1545 | .udc = &controller, | 1560 | .udc = &controller, |
1546 | .is_pingpong = 1, | 1561 | .is_pingpong = 1, |
1547 | .maxpacket = 256, | 1562 | .maxpacket = 256, |
1548 | .creg = (void __iomem *)(AT91_VA_BASE_UDP | ||
1549 | + AT91_UDP_CSR(5)), | ||
1550 | .int_mask = 1 << 5, | 1563 | .int_mask = 1 << 5, |
1551 | }, | 1564 | }, |
1552 | /* ep6 and ep7 are also reserved (custom silicon might use them) */ | 1565 | /* ep6 and ep7 are also reserved (custom silicon might use them) */ |
@@ -1572,9 +1585,8 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
1572 | int retval; | 1585 | int retval; |
1573 | 1586 | ||
1574 | if (!driver | 1587 | if (!driver |
1575 | || driver->speed != USB_SPEED_FULL | 1588 | || driver->speed < USB_SPEED_FULL |
1576 | || !driver->bind | 1589 | || !driver->bind |
1577 | || !driver->unbind | ||
1578 | || !driver->setup) { | 1590 | || !driver->setup) { |
1579 | DBG("bad parameter.\n"); | 1591 | DBG("bad parameter.\n"); |
1580 | return -EINVAL; | 1592 | return -EINVAL; |
@@ -1595,6 +1607,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
1595 | if (retval) { | 1607 | if (retval) { |
1596 | DBG("driver->bind() returned %d\n", retval); | 1608 | DBG("driver->bind() returned %d\n", retval); |
1597 | udc->driver = NULL; | 1609 | udc->driver = NULL; |
1610 | udc->gadget.dev.driver = NULL; | ||
1611 | udc->gadget.dev.driver_data = NULL; | ||
1612 | udc->enabled = 0; | ||
1613 | udc->selfpowered = 0; | ||
1598 | return retval; | 1614 | return retval; |
1599 | } | 1615 | } |
1600 | 1616 | ||
@@ -1611,12 +1627,12 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
1611 | { | 1627 | { |
1612 | struct at91_udc *udc = &controller; | 1628 | struct at91_udc *udc = &controller; |
1613 | 1629 | ||
1614 | if (!driver || driver != udc->driver) | 1630 | if (!driver || driver != udc->driver || !driver->unbind) |
1615 | return -EINVAL; | 1631 | return -EINVAL; |
1616 | 1632 | ||
1617 | local_irq_disable(); | 1633 | local_irq_disable(); |
1618 | udc->enabled = 0; | 1634 | udc->enabled = 0; |
1619 | at91_udp_write(AT91_UDP_IDR, ~0); | 1635 | at91_udp_write(udc, AT91_UDP_IDR, ~0); |
1620 | pullup(udc, 0); | 1636 | pullup(udc, 0); |
1621 | local_irq_enable(); | 1637 | local_irq_enable(); |
1622 | 1638 | ||
@@ -1641,6 +1657,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1641 | struct device *dev = &pdev->dev; | 1657 | struct device *dev = &pdev->dev; |
1642 | struct at91_udc *udc; | 1658 | struct at91_udc *udc; |
1643 | int retval; | 1659 | int retval; |
1660 | struct resource *res; | ||
1644 | 1661 | ||
1645 | if (!dev->platform_data) { | 1662 | if (!dev->platform_data) { |
1646 | /* small (so we copy it) but critical! */ | 1663 | /* small (so we copy it) but critical! */ |
@@ -1658,7 +1675,13 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1658 | return -ENODEV; | 1675 | return -ENODEV; |
1659 | } | 1676 | } |
1660 | 1677 | ||
1661 | if (!request_mem_region(AT91RM9200_BASE_UDP, SZ_16K, driver_name)) { | 1678 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1679 | if (!res) | ||
1680 | return -ENXIO; | ||
1681 | |||
1682 | if (!request_mem_region(res->start, | ||
1683 | res->end - res->start + 1, | ||
1684 | driver_name)) { | ||
1662 | DBG("someone's using UDC memory\n"); | 1685 | DBG("someone's using UDC memory\n"); |
1663 | return -EBUSY; | 1686 | return -EBUSY; |
1664 | } | 1687 | } |
@@ -1668,15 +1691,23 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1668 | udc->gadget.dev.parent = dev; | 1691 | udc->gadget.dev.parent = dev; |
1669 | udc->board = *(struct at91_udc_data *) dev->platform_data; | 1692 | udc->board = *(struct at91_udc_data *) dev->platform_data; |
1670 | udc->pdev = pdev; | 1693 | udc->pdev = pdev; |
1671 | udc_reinit(udc); | ||
1672 | udc->enabled = 0; | 1694 | udc->enabled = 0; |
1673 | 1695 | ||
1696 | udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1); | ||
1697 | if (!udc->udp_baseaddr) { | ||
1698 | release_mem_region(res->start, res->end - res->start + 1); | ||
1699 | return -ENOMEM; | ||
1700 | } | ||
1701 | |||
1702 | udc_reinit(udc); | ||
1703 | |||
1674 | /* get interface and function clocks */ | 1704 | /* get interface and function clocks */ |
1675 | udc->iclk = clk_get(dev, "udc_clk"); | 1705 | udc->iclk = clk_get(dev, "udc_clk"); |
1676 | udc->fclk = clk_get(dev, "udpck"); | 1706 | udc->fclk = clk_get(dev, "udpck"); |
1677 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { | 1707 | if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { |
1678 | DBG("clocks missing\n"); | 1708 | DBG("clocks missing\n"); |
1679 | return -ENODEV; | 1709 | retval = -ENODEV; |
1710 | goto fail0; | ||
1680 | } | 1711 | } |
1681 | 1712 | ||
1682 | retval = device_register(&udc->gadget.dev); | 1713 | retval = device_register(&udc->gadget.dev); |
@@ -1685,8 +1716,10 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1685 | 1716 | ||
1686 | /* don't do anything until we have both gadget driver and VBUS */ | 1717 | /* don't do anything until we have both gadget driver and VBUS */ |
1687 | clk_enable(udc->iclk); | 1718 | clk_enable(udc->iclk); |
1688 | at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); | 1719 | at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); |
1689 | at91_udp_write(AT91_UDP_IDR, 0xffffffff); | 1720 | at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff); |
1721 | /* Clear all pending interrupts - UDP may be used by bootloader. */ | ||
1722 | at91_udp_write(udc, AT91_UDP_ICR, 0xffffffff); | ||
1690 | clk_disable(udc->iclk); | 1723 | clk_disable(udc->iclk); |
1691 | 1724 | ||
1692 | /* request UDC and maybe VBUS irqs */ | 1725 | /* request UDC and maybe VBUS irqs */ |
@@ -1698,6 +1731,11 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1698 | goto fail1; | 1731 | goto fail1; |
1699 | } | 1732 | } |
1700 | if (udc->board.vbus_pin > 0) { | 1733 | if (udc->board.vbus_pin > 0) { |
1734 | /* | ||
1735 | * Get the initial state of VBUS - we cannot expect | ||
1736 | * a pending interrupt. | ||
1737 | */ | ||
1738 | udc->vbus = at91_get_gpio_value(udc->board.vbus_pin); | ||
1701 | if (request_irq(udc->board.vbus_pin, at91_vbus_irq, | 1739 | if (request_irq(udc->board.vbus_pin, at91_vbus_irq, |
1702 | IRQF_DISABLED, driver_name, udc)) { | 1740 | IRQF_DISABLED, driver_name, udc)) { |
1703 | DBG("request vbus irq %d failed\n", | 1741 | DBG("request vbus irq %d failed\n", |
@@ -1720,7 +1758,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev) | |||
1720 | fail1: | 1758 | fail1: |
1721 | device_unregister(&udc->gadget.dev); | 1759 | device_unregister(&udc->gadget.dev); |
1722 | fail0: | 1760 | fail0: |
1723 | release_mem_region(AT91RM9200_BASE_UDP, SZ_16K); | 1761 | release_mem_region(res->start, res->end - res->start + 1); |
1724 | DBG("%s probe failed, %d\n", driver_name, retval); | 1762 | DBG("%s probe failed, %d\n", driver_name, retval); |
1725 | return retval; | 1763 | return retval; |
1726 | } | 1764 | } |
@@ -1728,13 +1766,14 @@ fail0: | |||
1728 | static int __devexit at91udc_remove(struct platform_device *pdev) | 1766 | static int __devexit at91udc_remove(struct platform_device *pdev) |
1729 | { | 1767 | { |
1730 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1768 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1769 | struct resource *res; | ||
1731 | 1770 | ||
1732 | DBG("remove\n"); | 1771 | DBG("remove\n"); |
1733 | 1772 | ||
1734 | pullup(udc, 0); | 1773 | if (udc->driver) |
1774 | return -EBUSY; | ||
1735 | 1775 | ||
1736 | if (udc->driver != 0) | 1776 | pullup(udc, 0); |
1737 | usb_gadget_unregister_driver(udc->driver); | ||
1738 | 1777 | ||
1739 | device_init_wakeup(&pdev->dev, 0); | 1778 | device_init_wakeup(&pdev->dev, 0); |
1740 | remove_debug_file(udc); | 1779 | remove_debug_file(udc); |
@@ -1742,7 +1781,10 @@ static int __devexit at91udc_remove(struct platform_device *pdev) | |||
1742 | free_irq(udc->board.vbus_pin, udc); | 1781 | free_irq(udc->board.vbus_pin, udc); |
1743 | free_irq(udc->udp_irq, udc); | 1782 | free_irq(udc->udp_irq, udc); |
1744 | device_unregister(&udc->gadget.dev); | 1783 | device_unregister(&udc->gadget.dev); |
1745 | release_mem_region(AT91RM9200_BASE_UDP, SZ_16K); | 1784 | |
1785 | iounmap(udc->udp_baseaddr); | ||
1786 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1787 | release_mem_region(res->start, res->end - res->start + 1); | ||
1746 | 1788 | ||
1747 | clk_put(udc->iclk); | 1789 | clk_put(udc->iclk); |
1748 | clk_put(udc->fclk); | 1790 | clk_put(udc->fclk); |
@@ -1765,16 +1807,13 @@ static int at91udc_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1765 | || !wake | 1807 | || !wake |
1766 | || at91_suspend_entering_slow_clock()) { | 1808 | || at91_suspend_entering_slow_clock()) { |
1767 | pullup(udc, 0); | 1809 | pullup(udc, 0); |
1768 | disable_irq_wake(udc->udp_irq); | 1810 | wake = 0; |
1769 | } else | 1811 | } else |
1770 | enable_irq_wake(udc->udp_irq); | 1812 | enable_irq_wake(udc->udp_irq); |
1771 | 1813 | ||
1772 | if (udc->board.vbus_pin > 0) { | 1814 | udc->active_suspend = wake; |
1773 | if (wake) | 1815 | if (udc->board.vbus_pin > 0 && wake) |
1774 | enable_irq_wake(udc->board.vbus_pin); | 1816 | enable_irq_wake(udc->board.vbus_pin); |
1775 | else | ||
1776 | disable_irq_wake(udc->board.vbus_pin); | ||
1777 | } | ||
1778 | return 0; | 1817 | return 0; |
1779 | } | 1818 | } |
1780 | 1819 | ||
@@ -1782,8 +1821,14 @@ static int at91udc_resume(struct platform_device *pdev) | |||
1782 | { | 1821 | { |
1783 | struct at91_udc *udc = platform_get_drvdata(pdev); | 1822 | struct at91_udc *udc = platform_get_drvdata(pdev); |
1784 | 1823 | ||
1824 | if (udc->board.vbus_pin > 0 && udc->active_suspend) | ||
1825 | disable_irq_wake(udc->board.vbus_pin); | ||
1826 | |||
1785 | /* maybe reconnect to host; if so, clocks on */ | 1827 | /* maybe reconnect to host; if so, clocks on */ |
1786 | pullup(udc, 1); | 1828 | if (udc->active_suspend) |
1829 | disable_irq_wake(udc->udp_irq); | ||
1830 | else | ||
1831 | pullup(udc, 1); | ||
1787 | return 0; | 1832 | return 0; |
1788 | } | 1833 | } |
1789 | #else | 1834 | #else |
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h index 882af42e86cc..7e34e2f864f9 100644 --- a/drivers/usb/gadget/at91_udc.h +++ b/drivers/usb/gadget/at91_udc.h | |||
@@ -51,10 +51,10 @@ | |||
51 | #define AT91_UDP_EP(n) (1 << (n)) /* Endpoint Interrupt Status */ | 51 | #define AT91_UDP_EP(n) (1 << (n)) /* Endpoint Interrupt Status */ |
52 | #define AT91_UDP_RXSUSP (1 << 8) /* USB Suspend Interrupt Status */ | 52 | #define AT91_UDP_RXSUSP (1 << 8) /* USB Suspend Interrupt Status */ |
53 | #define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */ | 53 | #define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */ |
54 | #define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status */ | 54 | #define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status [AT91RM9200 only] */ |
55 | #define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */ | 55 | #define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */ |
56 | #define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrpt Status */ | 56 | #define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrpt Status */ |
57 | #define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status */ | 57 | #define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status [AT91RM9200 only] */ |
58 | 58 | ||
59 | #define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */ | 59 | #define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */ |
60 | #define AT91_UDP_RST_EP 0x28 /* Reset Endpoint Register */ | 60 | #define AT91_UDP_RST_EP 0x28 /* Reset Endpoint Register */ |
@@ -84,7 +84,7 @@ | |||
84 | 84 | ||
85 | #define AT91_UDP_TXVC 0x74 /* Transceiver Control Register */ | 85 | #define AT91_UDP_TXVC 0x74 /* Transceiver Control Register */ |
86 | #define AT91_UDP_TXVC_TXVDIS (1 << 8) /* Transceiver Disable */ | 86 | #define AT91_UDP_TXVC_TXVDIS (1 << 8) /* Transceiver Disable */ |
87 | 87 | #define AT91_UDP_TXVC_PUON (1 << 9) /* PullUp On [AT91SAM9260 only] */ | |
88 | 88 | ||
89 | /*-------------------------------------------------------------------------*/ | 89 | /*-------------------------------------------------------------------------*/ |
90 | 90 | ||
@@ -136,11 +136,13 @@ struct at91_udc { | |||
136 | unsigned wait_for_addr_ack:1; | 136 | unsigned wait_for_addr_ack:1; |
137 | unsigned wait_for_config_ack:1; | 137 | unsigned wait_for_config_ack:1; |
138 | unsigned selfpowered:1; | 138 | unsigned selfpowered:1; |
139 | unsigned active_suspend:1; | ||
139 | u8 addr; | 140 | u8 addr; |
140 | struct at91_udc_data board; | 141 | struct at91_udc_data board; |
141 | struct clk *iclk, *fclk; | 142 | struct clk *iclk, *fclk; |
142 | struct platform_device *pdev; | 143 | struct platform_device *pdev; |
143 | struct proc_dir_entry *pde; | 144 | struct proc_dir_entry *pde; |
145 | void __iomem *udp_baseaddr; | ||
144 | int udp_irq; | 146 | int udp_irq; |
145 | }; | 147 | }; |
146 | 148 | ||
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 83b4866df9af..d18901b92cda 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -24,7 +24,7 @@ | |||
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #include <linux/device.h> | 25 | #include <linux/device.h> |
26 | 26 | ||
27 | #include <linux/usb_ch9.h> | 27 | #include <linux/usb/ch9.h> |
28 | #include <linux/usb_gadget.h> | 28 | #include <linux/usb_gadget.h> |
29 | 29 | ||
30 | 30 | ||
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index f1f32d7be5f9..3c2bc075ef4f 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -779,7 +779,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
779 | return -EINVAL; | 779 | return -EINVAL; |
780 | if (dum->driver) | 780 | if (dum->driver) |
781 | return -EBUSY; | 781 | return -EBUSY; |
782 | if (!driver->bind || !driver->unbind || !driver->setup | 782 | if (!driver->bind || !driver->setup |
783 | || driver->speed == USB_SPEED_UNKNOWN) | 783 | || driver->speed == USB_SPEED_UNKNOWN) |
784 | return -EINVAL; | 784 | return -EINVAL; |
785 | 785 | ||
@@ -837,7 +837,8 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
837 | err_bind_driver: | 837 | err_bind_driver: |
838 | driver_unregister (&driver->driver); | 838 | driver_unregister (&driver->driver); |
839 | err_register: | 839 | err_register: |
840 | driver->unbind (&dum->gadget); | 840 | if (driver->unbind) |
841 | driver->unbind (&dum->gadget); | ||
841 | spin_lock_irq (&dum->lock); | 842 | spin_lock_irq (&dum->lock); |
842 | dum->pullup = 0; | 843 | dum->pullup = 0; |
843 | set_link_state (dum); | 844 | set_link_state (dum); |
@@ -857,7 +858,7 @@ usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
857 | 858 | ||
858 | if (!dum) | 859 | if (!dum) |
859 | return -ENODEV; | 860 | return -ENODEV; |
860 | if (!driver || driver != dum->driver) | 861 | if (!driver || driver != dum->driver || !driver->unbind) |
861 | return -EINVAL; | 862 | return -EINVAL; |
862 | 863 | ||
863 | dev_dbg (udc_dev(dum), "unregister gadget driver '%s'\n", | 864 | dev_dbg (udc_dev(dum), "unregister gadget driver '%s'\n", |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 53d584589c26..f28af06905a5 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include <linux/ctype.h> | 27 | #include <linux/ctype.h> |
28 | #include <linux/string.h> | 28 | #include <linux/string.h> |
29 | 29 | ||
30 | #include <linux/usb_ch9.h> | 30 | #include <linux/usb/ch9.h> |
31 | #include <linux/usb_gadget.h> | 31 | #include <linux/usb_gadget.h> |
32 | 32 | ||
33 | #include "gadget_chips.h" | 33 | #include "gadget_chips.h" |
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index d15bf22b9a03..22e3c9443641 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c | |||
@@ -47,7 +47,7 @@ | |||
47 | #include <asm/uaccess.h> | 47 | #include <asm/uaccess.h> |
48 | #include <asm/unaligned.h> | 48 | #include <asm/unaligned.h> |
49 | 49 | ||
50 | #include <linux/usb_ch9.h> | 50 | #include <linux/usb/ch9.h> |
51 | #include <linux/usb/cdc.h> | 51 | #include <linux/usb/cdc.h> |
52 | #include <linux/usb_gadget.h> | 52 | #include <linux/usb_gadget.h> |
53 | 53 | ||
@@ -72,9 +72,18 @@ | |||
72 | * | 72 | * |
73 | * There's some hardware that can't talk CDC. We make that hardware | 73 | * There's some hardware that can't talk CDC. We make that hardware |
74 | * implement a "minimalist" vendor-agnostic CDC core: same framing, but | 74 | * implement a "minimalist" vendor-agnostic CDC core: same framing, but |
75 | * link-level setup only requires activating the configuration. | 75 | * link-level setup only requires activating the configuration. Only the |
76 | * Linux supports it, but other host operating systems may not. | 76 | * endpoint descriptors, and product/vendor IDs, are relevant; no control |
77 | * (This is a subset of CDC Ethernet.) | 77 | * operations are available. Linux supports it, but other host operating |
78 | * systems may not. (This is a subset of CDC Ethernet.) | ||
79 | * | ||
80 | * It turns out that if you add a few descriptors to that "CDC Subset", | ||
81 | * (Windows) host side drivers from MCCI can treat it as one submode of | ||
82 | * a proprietary scheme called "SAFE" ... without needing to know about | ||
83 | * specific product/vendor IDs. So we do that, making it easier to use | ||
84 | * those MS-Windows drivers. Those added descriptors make it resemble a | ||
85 | * CDC MDLM device, but they don't change device behavior at all. (See | ||
86 | * MCCI Engineering report 950198 "SAFE Networking Functions".) | ||
78 | * | 87 | * |
79 | * A third option is also in use. Rather than CDC Ethernet, or something | 88 | * A third option is also in use. Rather than CDC Ethernet, or something |
80 | * simpler, Microsoft pushes their own approach: RNDIS. The published | 89 | * simpler, Microsoft pushes their own approach: RNDIS. The published |
@@ -254,6 +263,10 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); | |||
254 | #define DEV_CONFIG_CDC | 263 | #define DEV_CONFIG_CDC |
255 | #endif | 264 | #endif |
256 | 265 | ||
266 | #ifdef CONFIG_USB_GADGET_S3C2410 | ||
267 | #define DEV_CONFIG_CDC | ||
268 | #endif | ||
269 | |||
257 | #ifdef CONFIG_USB_GADGET_AT91 | 270 | #ifdef CONFIG_USB_GADGET_AT91 |
258 | #define DEV_CONFIG_CDC | 271 | #define DEV_CONFIG_CDC |
259 | #endif | 272 | #endif |
@@ -266,6 +279,10 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); | |||
266 | #define DEV_CONFIG_CDC | 279 | #define DEV_CONFIG_CDC |
267 | #endif | 280 | #endif |
268 | 281 | ||
282 | #ifdef CONFIG_USB_GADGET_HUSB2DEV | ||
283 | #define DEV_CONFIG_CDC | ||
284 | #endif | ||
285 | |||
269 | 286 | ||
270 | /* For CDC-incapable hardware, choose the simple cdc subset. | 287 | /* For CDC-incapable hardware, choose the simple cdc subset. |
271 | * Anything that talks bulk (without notable bugs) can do this. | 288 | * Anything that talks bulk (without notable bugs) can do this. |
@@ -283,9 +300,6 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); | |||
283 | #define DEV_CONFIG_SUBSET | 300 | #define DEV_CONFIG_SUBSET |
284 | #endif | 301 | #endif |
285 | 302 | ||
286 | #ifdef CONFIG_USB_GADGET_S3C2410 | ||
287 | #define DEV_CONFIG_CDC | ||
288 | #endif | ||
289 | 303 | ||
290 | /*-------------------------------------------------------------------------*/ | 304 | /*-------------------------------------------------------------------------*/ |
291 | 305 | ||
@@ -487,8 +501,17 @@ rndis_config = { | |||
487 | * endpoint. Both have a "data" interface and two bulk endpoints. | 501 | * endpoint. Both have a "data" interface and two bulk endpoints. |
488 | * There are also differences in how control requests are handled. | 502 | * There are also differences in how control requests are handled. |
489 | * | 503 | * |
490 | * RNDIS shares a lot with CDC-Ethernet, since it's a variant of | 504 | * RNDIS shares a lot with CDC-Ethernet, since it's a variant of the |
491 | * the CDC-ACM (modem) spec. | 505 | * CDC-ACM (modem) spec. Unfortunately MSFT's RNDIS driver is buggy; it |
506 | * may hang or oops. Since bugfixes (or accurate specs, letting Linux | ||
507 | * work around those bugs) are unlikely to ever come from MSFT, you may | ||
508 | * wish to avoid using RNDIS. | ||
509 | * | ||
510 | * MCCI offers an alternative to RNDIS if you need to connect to Windows | ||
511 | * but have hardware that can't support CDC Ethernet. We add descriptors | ||
512 | * to present the CDC Subset as a (nonconformant) CDC MDLM variant called | ||
513 | * "SAFE". That borrows from both CDC Ethernet and CDC MDLM. You can | ||
514 | * get those drivers from MCCI, or bundled with various products. | ||
492 | */ | 515 | */ |
493 | 516 | ||
494 | #ifdef DEV_CONFIG_CDC | 517 | #ifdef DEV_CONFIG_CDC |
@@ -522,8 +545,6 @@ rndis_control_intf = { | |||
522 | }; | 545 | }; |
523 | #endif | 546 | #endif |
524 | 547 | ||
525 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) | ||
526 | |||
527 | static const struct usb_cdc_header_desc header_desc = { | 548 | static const struct usb_cdc_header_desc header_desc = { |
528 | .bLength = sizeof header_desc, | 549 | .bLength = sizeof header_desc, |
529 | .bDescriptorType = USB_DT_CS_INTERFACE, | 550 | .bDescriptorType = USB_DT_CS_INTERFACE, |
@@ -532,6 +553,8 @@ static const struct usb_cdc_header_desc header_desc = { | |||
532 | .bcdCDC = __constant_cpu_to_le16 (0x0110), | 553 | .bcdCDC = __constant_cpu_to_le16 (0x0110), |
533 | }; | 554 | }; |
534 | 555 | ||
556 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) | ||
557 | |||
535 | static const struct usb_cdc_union_desc union_desc = { | 558 | static const struct usb_cdc_union_desc union_desc = { |
536 | .bLength = sizeof union_desc, | 559 | .bLength = sizeof union_desc, |
537 | .bDescriptorType = USB_DT_CS_INTERFACE, | 560 | .bDescriptorType = USB_DT_CS_INTERFACE, |
@@ -564,7 +587,40 @@ static const struct usb_cdc_acm_descriptor acm_descriptor = { | |||
564 | 587 | ||
565 | #endif | 588 | #endif |
566 | 589 | ||
567 | #ifdef DEV_CONFIG_CDC | 590 | #ifndef DEV_CONFIG_CDC |
591 | |||
592 | /* "SAFE" loosely follows CDC WMC MDLM, violating the spec in various | ||
593 | * ways: data endpoints live in the control interface, there's no data | ||
594 | * interface, and it's not used to talk to a cell phone radio. | ||
595 | */ | ||
596 | |||
597 | static const struct usb_cdc_mdlm_desc mdlm_desc = { | ||
598 | .bLength = sizeof mdlm_desc, | ||
599 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
600 | .bDescriptorSubType = USB_CDC_MDLM_TYPE, | ||
601 | |||
602 | .bcdVersion = __constant_cpu_to_le16(0x0100), | ||
603 | .bGUID = { | ||
604 | 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, | ||
605 | 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, | ||
606 | }, | ||
607 | }; | ||
608 | |||
609 | /* since "usb_cdc_mdlm_detail_desc" is a variable length structure, we | ||
610 | * can't really use its struct. All we do here is say that we're using | ||
611 | * the submode of "SAFE" which directly matches the CDC Subset. | ||
612 | */ | ||
613 | static const u8 mdlm_detail_desc[] = { | ||
614 | 6, | ||
615 | USB_DT_CS_INTERFACE, | ||
616 | USB_CDC_MDLM_DETAIL_TYPE, | ||
617 | |||
618 | 0, /* "SAFE" */ | ||
619 | 0, /* network control capabilities (none) */ | ||
620 | 0, /* network data capabilities ("raw" encapsulation) */ | ||
621 | }; | ||
622 | |||
623 | #endif | ||
568 | 624 | ||
569 | static const struct usb_cdc_ether_desc ether_desc = { | 625 | static const struct usb_cdc_ether_desc ether_desc = { |
570 | .bLength = sizeof ether_desc, | 626 | .bLength = sizeof ether_desc, |
@@ -579,7 +635,6 @@ static const struct usb_cdc_ether_desc ether_desc = { | |||
579 | .bNumberPowerFilters = 0, | 635 | .bNumberPowerFilters = 0, |
580 | }; | 636 | }; |
581 | 637 | ||
582 | #endif | ||
583 | 638 | ||
584 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) | 639 | #if defined(DEV_CONFIG_CDC) || defined(CONFIG_USB_ETH_RNDIS) |
585 | 640 | ||
@@ -672,6 +727,9 @@ rndis_data_intf = { | |||
672 | /* | 727 | /* |
673 | * "Simple" CDC-subset option is a simple vendor-neutral model that most | 728 | * "Simple" CDC-subset option is a simple vendor-neutral model that most |
674 | * full speed controllers can handle: one interface, two bulk endpoints. | 729 | * full speed controllers can handle: one interface, two bulk endpoints. |
730 | * | ||
731 | * To assist host side drivers, we fancy it up a bit, and add descriptors | ||
732 | * so some host side drivers will understand it as a "SAFE" variant. | ||
675 | */ | 733 | */ |
676 | 734 | ||
677 | static const struct usb_interface_descriptor | 735 | static const struct usb_interface_descriptor |
@@ -682,8 +740,8 @@ subset_data_intf = { | |||
682 | .bInterfaceNumber = 0, | 740 | .bInterfaceNumber = 0, |
683 | .bAlternateSetting = 0, | 741 | .bAlternateSetting = 0, |
684 | .bNumEndpoints = 2, | 742 | .bNumEndpoints = 2, |
685 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | 743 | .bInterfaceClass = USB_CLASS_COMM, |
686 | .bInterfaceSubClass = 0, | 744 | .bInterfaceSubClass = USB_CDC_SUBCLASS_MDLM, |
687 | .bInterfaceProtocol = 0, | 745 | .bInterfaceProtocol = 0, |
688 | .iInterface = STRING_DATA, | 746 | .iInterface = STRING_DATA, |
689 | }; | 747 | }; |
@@ -731,10 +789,15 @@ static const struct usb_descriptor_header *fs_eth_function [11] = { | |||
731 | static inline void __init fs_subset_descriptors(void) | 789 | static inline void __init fs_subset_descriptors(void) |
732 | { | 790 | { |
733 | #ifdef DEV_CONFIG_SUBSET | 791 | #ifdef DEV_CONFIG_SUBSET |
792 | /* behavior is "CDC Subset"; extra descriptors say "SAFE" */ | ||
734 | fs_eth_function[1] = (struct usb_descriptor_header *) &subset_data_intf; | 793 | fs_eth_function[1] = (struct usb_descriptor_header *) &subset_data_intf; |
735 | fs_eth_function[2] = (struct usb_descriptor_header *) &fs_source_desc; | 794 | fs_eth_function[2] = (struct usb_descriptor_header *) &header_desc; |
736 | fs_eth_function[3] = (struct usb_descriptor_header *) &fs_sink_desc; | 795 | fs_eth_function[3] = (struct usb_descriptor_header *) &mdlm_desc; |
737 | fs_eth_function[4] = NULL; | 796 | fs_eth_function[4] = (struct usb_descriptor_header *) &mdlm_detail_desc; |
797 | fs_eth_function[5] = (struct usb_descriptor_header *) ðer_desc; | ||
798 | fs_eth_function[6] = (struct usb_descriptor_header *) &fs_source_desc; | ||
799 | fs_eth_function[7] = (struct usb_descriptor_header *) &fs_sink_desc; | ||
800 | fs_eth_function[8] = NULL; | ||
738 | #else | 801 | #else |
739 | fs_eth_function[1] = NULL; | 802 | fs_eth_function[1] = NULL; |
740 | #endif | 803 | #endif |
@@ -828,10 +891,15 @@ static const struct usb_descriptor_header *hs_eth_function [11] = { | |||
828 | static inline void __init hs_subset_descriptors(void) | 891 | static inline void __init hs_subset_descriptors(void) |
829 | { | 892 | { |
830 | #ifdef DEV_CONFIG_SUBSET | 893 | #ifdef DEV_CONFIG_SUBSET |
894 | /* behavior is "CDC Subset"; extra descriptors say "SAFE" */ | ||
831 | hs_eth_function[1] = (struct usb_descriptor_header *) &subset_data_intf; | 895 | hs_eth_function[1] = (struct usb_descriptor_header *) &subset_data_intf; |
832 | hs_eth_function[2] = (struct usb_descriptor_header *) &fs_source_desc; | 896 | hs_eth_function[2] = (struct usb_descriptor_header *) &header_desc; |
833 | hs_eth_function[3] = (struct usb_descriptor_header *) &fs_sink_desc; | 897 | hs_eth_function[3] = (struct usb_descriptor_header *) &mdlm_desc; |
834 | hs_eth_function[4] = NULL; | 898 | hs_eth_function[4] = (struct usb_descriptor_header *) &mdlm_detail_desc; |
899 | hs_eth_function[5] = (struct usb_descriptor_header *) ðer_desc; | ||
900 | hs_eth_function[6] = (struct usb_descriptor_header *) &hs_source_desc; | ||
901 | hs_eth_function[7] = (struct usb_descriptor_header *) &hs_sink_desc; | ||
902 | hs_eth_function[8] = NULL; | ||
835 | #else | 903 | #else |
836 | hs_eth_function[1] = NULL; | 904 | hs_eth_function[1] = NULL; |
837 | #endif | 905 | #endif |
@@ -878,10 +946,8 @@ static char manufacturer [50]; | |||
878 | static char product_desc [40] = DRIVER_DESC; | 946 | static char product_desc [40] = DRIVER_DESC; |
879 | static char serial_number [20]; | 947 | static char serial_number [20]; |
880 | 948 | ||
881 | #ifdef DEV_CONFIG_CDC | ||
882 | /* address that the host will use ... usually assigned at random */ | 949 | /* address that the host will use ... usually assigned at random */ |
883 | static char ethaddr [2 * ETH_ALEN + 1]; | 950 | static char ethaddr [2 * ETH_ALEN + 1]; |
884 | #endif | ||
885 | 951 | ||
886 | /* static strings, in UTF-8 */ | 952 | /* static strings, in UTF-8 */ |
887 | static struct usb_string strings [] = { | 953 | static struct usb_string strings [] = { |
@@ -889,9 +955,9 @@ static struct usb_string strings [] = { | |||
889 | { STRING_PRODUCT, product_desc, }, | 955 | { STRING_PRODUCT, product_desc, }, |
890 | { STRING_SERIALNUMBER, serial_number, }, | 956 | { STRING_SERIALNUMBER, serial_number, }, |
891 | { STRING_DATA, "Ethernet Data", }, | 957 | { STRING_DATA, "Ethernet Data", }, |
958 | { STRING_ETHADDR, ethaddr, }, | ||
892 | #ifdef DEV_CONFIG_CDC | 959 | #ifdef DEV_CONFIG_CDC |
893 | { STRING_CDC, "CDC Ethernet", }, | 960 | { STRING_CDC, "CDC Ethernet", }, |
894 | { STRING_ETHADDR, ethaddr, }, | ||
895 | { STRING_CONTROL, "CDC Communications Control", }, | 961 | { STRING_CONTROL, "CDC Communications Control", }, |
896 | #endif | 962 | #endif |
897 | #ifdef DEV_CONFIG_SUBSET | 963 | #ifdef DEV_CONFIG_SUBSET |
@@ -986,10 +1052,10 @@ set_ether_config (struct eth_dev *dev, gfp_t gfp_flags) | |||
986 | } | 1052 | } |
987 | #endif | 1053 | #endif |
988 | 1054 | ||
989 | dev->in = ep_desc (dev->gadget, &hs_source_desc, &fs_source_desc); | 1055 | dev->in = ep_desc(gadget, &hs_source_desc, &fs_source_desc); |
990 | dev->in_ep->driver_data = dev; | 1056 | dev->in_ep->driver_data = dev; |
991 | 1057 | ||
992 | dev->out = ep_desc (dev->gadget, &hs_sink_desc, &fs_sink_desc); | 1058 | dev->out = ep_desc(gadget, &hs_sink_desc, &fs_sink_desc); |
993 | dev->out_ep->driver_data = dev; | 1059 | dev->out_ep->driver_data = dev; |
994 | 1060 | ||
995 | /* With CDC, the host isn't allowed to use these two data | 1061 | /* With CDC, the host isn't allowed to use these two data |
@@ -2278,10 +2344,10 @@ eth_bind (struct usb_gadget *gadget) | |||
2278 | "RNDIS/%s", driver_desc); | 2344 | "RNDIS/%s", driver_desc); |
2279 | 2345 | ||
2280 | /* CDC subset ... recognized by Linux since 2.4.10, but Windows | 2346 | /* CDC subset ... recognized by Linux since 2.4.10, but Windows |
2281 | * drivers aren't widely available. | 2347 | * drivers aren't widely available. (That may be improved by |
2348 | * supporting one submode of the "SAFE" variant of MDLM.) | ||
2282 | */ | 2349 | */ |
2283 | } else if (!cdc) { | 2350 | } else if (!cdc) { |
2284 | device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC; | ||
2285 | device_desc.idVendor = | 2351 | device_desc.idVendor = |
2286 | __constant_cpu_to_le16(SIMPLE_VENDOR_NUM); | 2352 | __constant_cpu_to_le16(SIMPLE_VENDOR_NUM); |
2287 | device_desc.idProduct = | 2353 | device_desc.idProduct = |
@@ -2352,6 +2418,10 @@ autoconf_fail: | |||
2352 | if (!cdc) { | 2418 | if (!cdc) { |
2353 | eth_config.bNumInterfaces = 1; | 2419 | eth_config.bNumInterfaces = 1; |
2354 | eth_config.iConfiguration = STRING_SUBSET; | 2420 | eth_config.iConfiguration = STRING_SUBSET; |
2421 | |||
2422 | /* use functions to set these up, in case we're built to work | ||
2423 | * with multiple controllers and must override CDC Ethernet. | ||
2424 | */ | ||
2355 | fs_subset_descriptors(); | 2425 | fs_subset_descriptors(); |
2356 | hs_subset_descriptors(); | 2426 | hs_subset_descriptors(); |
2357 | } | 2427 | } |
@@ -2415,22 +2485,20 @@ autoconf_fail: | |||
2415 | 2485 | ||
2416 | /* Module params for these addresses should come from ID proms. | 2486 | /* Module params for these addresses should come from ID proms. |
2417 | * The host side address is used with CDC and RNDIS, and commonly | 2487 | * The host side address is used with CDC and RNDIS, and commonly |
2418 | * ends up in a persistent config database. | 2488 | * ends up in a persistent config database. It's not clear if |
2489 | * host side code for the SAFE thing cares -- its original BLAN | ||
2490 | * thing didn't, Sharp never assigned those addresses on Zaurii. | ||
2419 | */ | 2491 | */ |
2420 | if (get_ether_addr(dev_addr, net->dev_addr)) | 2492 | if (get_ether_addr(dev_addr, net->dev_addr)) |
2421 | dev_warn(&gadget->dev, | 2493 | dev_warn(&gadget->dev, |
2422 | "using random %s ethernet address\n", "self"); | 2494 | "using random %s ethernet address\n", "self"); |
2423 | if (cdc || rndis) { | 2495 | if (get_ether_addr(host_addr, dev->host_mac)) |
2424 | if (get_ether_addr(host_addr, dev->host_mac)) | 2496 | dev_warn(&gadget->dev, |
2425 | dev_warn(&gadget->dev, | 2497 | "using random %s ethernet address\n", "host"); |
2426 | "using random %s ethernet address\n", "host"); | 2498 | snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X", |
2427 | #ifdef DEV_CONFIG_CDC | 2499 | dev->host_mac [0], dev->host_mac [1], |
2428 | snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X", | 2500 | dev->host_mac [2], dev->host_mac [3], |
2429 | dev->host_mac [0], dev->host_mac [1], | 2501 | dev->host_mac [4], dev->host_mac [5]); |
2430 | dev->host_mac [2], dev->host_mac [3], | ||
2431 | dev->host_mac [4], dev->host_mac [5]); | ||
2432 | #endif | ||
2433 | } | ||
2434 | 2502 | ||
2435 | if (rndis) { | 2503 | if (rndis) { |
2436 | status = rndis_init(); | 2504 | status = rndis_init(); |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index c98316ce8384..f04a29a46646 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -253,7 +253,7 @@ | |||
253 | #include <linux/freezer.h> | 253 | #include <linux/freezer.h> |
254 | #include <linux/utsname.h> | 254 | #include <linux/utsname.h> |
255 | 255 | ||
256 | #include <linux/usb_ch9.h> | 256 | #include <linux/usb/ch9.h> |
257 | #include <linux/usb_gadget.h> | 257 | #include <linux/usb_gadget.h> |
258 | 258 | ||
259 | #include "gadget_chips.h" | 259 | #include "gadget_chips.h" |
@@ -1148,7 +1148,7 @@ static int ep0_queue(struct fsg_dev *fsg) | |||
1148 | 1148 | ||
1149 | static void ep0_complete(struct usb_ep *ep, struct usb_request *req) | 1149 | static void ep0_complete(struct usb_ep *ep, struct usb_request *req) |
1150 | { | 1150 | { |
1151 | struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; | 1151 | struct fsg_dev *fsg = ep->driver_data; |
1152 | 1152 | ||
1153 | if (req->actual > 0) | 1153 | if (req->actual > 0) |
1154 | dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual); | 1154 | dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual); |
@@ -1170,8 +1170,8 @@ static void ep0_complete(struct usb_ep *ep, struct usb_request *req) | |||
1170 | 1170 | ||
1171 | static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) | 1171 | static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) |
1172 | { | 1172 | { |
1173 | struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; | 1173 | struct fsg_dev *fsg = ep->driver_data; |
1174 | struct fsg_buffhd *bh = (struct fsg_buffhd *) req->context; | 1174 | struct fsg_buffhd *bh = req->context; |
1175 | 1175 | ||
1176 | if (req->status || req->actual != req->length) | 1176 | if (req->status || req->actual != req->length) |
1177 | DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, | 1177 | DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, |
@@ -1190,8 +1190,8 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) | |||
1190 | 1190 | ||
1191 | static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) | 1191 | static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) |
1192 | { | 1192 | { |
1193 | struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; | 1193 | struct fsg_dev *fsg = ep->driver_data; |
1194 | struct fsg_buffhd *bh = (struct fsg_buffhd *) req->context; | 1194 | struct fsg_buffhd *bh = req->context; |
1195 | 1195 | ||
1196 | dump_msg(fsg, "bulk-out", req->buf, req->actual); | 1196 | dump_msg(fsg, "bulk-out", req->buf, req->actual); |
1197 | if (req->status || req->actual != bh->bulk_out_intended_length) | 1197 | if (req->status || req->actual != bh->bulk_out_intended_length) |
@@ -1214,8 +1214,8 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) | |||
1214 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | 1214 | #ifdef CONFIG_USB_FILE_STORAGE_TEST |
1215 | static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) | 1215 | static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) |
1216 | { | 1216 | { |
1217 | struct fsg_dev *fsg = (struct fsg_dev *) ep->driver_data; | 1217 | struct fsg_dev *fsg = ep->driver_data; |
1218 | struct fsg_buffhd *bh = (struct fsg_buffhd *) req->context; | 1218 | struct fsg_buffhd *bh = req->context; |
1219 | 1219 | ||
1220 | if (req->status || req->actual != req->length) | 1220 | if (req->status || req->actual != req->length) |
1221 | DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, | 1221 | DBG(fsg, "%s --> %d, %u/%u\n", __FUNCTION__, |
@@ -1909,10 +1909,10 @@ static int fsync_sub(struct lun *curlun) | |||
1909 | if (!filp->f_op->fsync) | 1909 | if (!filp->f_op->fsync) |
1910 | return -EINVAL; | 1910 | return -EINVAL; |
1911 | 1911 | ||
1912 | inode = filp->f_dentry->d_inode; | 1912 | inode = filp->f_path.dentry->d_inode; |
1913 | mutex_lock(&inode->i_mutex); | 1913 | mutex_lock(&inode->i_mutex); |
1914 | rc = filemap_fdatawrite(inode->i_mapping); | 1914 | rc = filemap_fdatawrite(inode->i_mapping); |
1915 | err = filp->f_op->fsync(filp, filp->f_dentry, 1); | 1915 | err = filp->f_op->fsync(filp, filp->f_path.dentry, 1); |
1916 | if (!rc) | 1916 | if (!rc) |
1917 | rc = err; | 1917 | rc = err; |
1918 | err = filemap_fdatawait(inode->i_mapping); | 1918 | err = filemap_fdatawait(inode->i_mapping); |
@@ -1950,7 +1950,7 @@ static int do_synchronize_cache(struct fsg_dev *fsg) | |||
1950 | static void invalidate_sub(struct lun *curlun) | 1950 | static void invalidate_sub(struct lun *curlun) |
1951 | { | 1951 | { |
1952 | struct file *filp = curlun->filp; | 1952 | struct file *filp = curlun->filp; |
1953 | struct inode *inode = filp->f_dentry->d_inode; | 1953 | struct inode *inode = filp->f_path.dentry->d_inode; |
1954 | unsigned long rc; | 1954 | unsigned long rc; |
1955 | 1955 | ||
1956 | rc = invalidate_inode_pages(inode->i_mapping); | 1956 | rc = invalidate_inode_pages(inode->i_mapping); |
@@ -2577,7 +2577,7 @@ static int send_status(struct fsg_dev *fsg) | |||
2577 | } | 2577 | } |
2578 | 2578 | ||
2579 | if (transport_is_bbb()) { | 2579 | if (transport_is_bbb()) { |
2580 | struct bulk_cs_wrap *csw = (struct bulk_cs_wrap *) bh->buf; | 2580 | struct bulk_cs_wrap *csw = bh->buf; |
2581 | 2581 | ||
2582 | /* Store and send the Bulk-only CSW */ | 2582 | /* Store and send the Bulk-only CSW */ |
2583 | csw->Signature = __constant_cpu_to_le32(USB_BULK_CS_SIG); | 2583 | csw->Signature = __constant_cpu_to_le32(USB_BULK_CS_SIG); |
@@ -2596,8 +2596,7 @@ static int send_status(struct fsg_dev *fsg) | |||
2596 | return 0; | 2596 | return 0; |
2597 | 2597 | ||
2598 | } else { // USB_PR_CBI | 2598 | } else { // USB_PR_CBI |
2599 | struct interrupt_data *buf = (struct interrupt_data *) | 2599 | struct interrupt_data *buf = bh->buf; |
2600 | bh->buf; | ||
2601 | 2600 | ||
2602 | /* Store and send the Interrupt data. UFI sends the ASC | 2601 | /* Store and send the Interrupt data. UFI sends the ASC |
2603 | * and ASCQ bytes. Everything else sends a Type (which | 2602 | * and ASCQ bytes. Everything else sends a Type (which |
@@ -2982,7 +2981,7 @@ static int do_scsi_command(struct fsg_dev *fsg) | |||
2982 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | 2981 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) |
2983 | { | 2982 | { |
2984 | struct usb_request *req = bh->outreq; | 2983 | struct usb_request *req = bh->outreq; |
2985 | struct bulk_cb_wrap *cbw = (struct bulk_cb_wrap *) req->buf; | 2984 | struct bulk_cb_wrap *cbw = req->buf; |
2986 | 2985 | ||
2987 | /* Was this a real packet? */ | 2986 | /* Was this a real packet? */ |
2988 | if (req->status) | 2987 | if (req->status) |
@@ -3428,7 +3427,7 @@ static void handle_exception(struct fsg_dev *fsg) | |||
3428 | 3427 | ||
3429 | static int fsg_main_thread(void *fsg_) | 3428 | static int fsg_main_thread(void *fsg_) |
3430 | { | 3429 | { |
3431 | struct fsg_dev *fsg = (struct fsg_dev *) fsg_; | 3430 | struct fsg_dev *fsg = fsg_; |
3432 | 3431 | ||
3433 | /* Allow the thread to be killed by a signal, but set the signal mask | 3432 | /* Allow the thread to be killed by a signal, but set the signal mask |
3434 | * to block everything but INT, TERM, KILL, and USR1. */ | 3433 | * to block everything but INT, TERM, KILL, and USR1. */ |
@@ -3526,8 +3525,8 @@ static int open_backing_file(struct lun *curlun, const char *filename) | |||
3526 | if (!(filp->f_mode & FMODE_WRITE)) | 3525 | if (!(filp->f_mode & FMODE_WRITE)) |
3527 | ro = 1; | 3526 | ro = 1; |
3528 | 3527 | ||
3529 | if (filp->f_dentry) | 3528 | if (filp->f_path.dentry) |
3530 | inode = filp->f_dentry->d_inode; | 3529 | inode = filp->f_path.dentry->d_inode; |
3531 | if (inode && S_ISBLK(inode->i_mode)) { | 3530 | if (inode && S_ISBLK(inode->i_mode)) { |
3532 | if (bdev_read_only(inode->i_bdev)) | 3531 | if (bdev_read_only(inode->i_bdev)) |
3533 | ro = 1; | 3532 | ro = 1; |
@@ -3600,13 +3599,13 @@ static ssize_t show_ro(struct device *dev, struct device_attribute *attr, char * | |||
3600 | static ssize_t show_file(struct device *dev, struct device_attribute *attr, char *buf) | 3599 | static ssize_t show_file(struct device *dev, struct device_attribute *attr, char *buf) |
3601 | { | 3600 | { |
3602 | struct lun *curlun = dev_to_lun(dev); | 3601 | struct lun *curlun = dev_to_lun(dev); |
3603 | struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); | 3602 | struct fsg_dev *fsg = dev_get_drvdata(dev); |
3604 | char *p; | 3603 | char *p; |
3605 | ssize_t rc; | 3604 | ssize_t rc; |
3606 | 3605 | ||
3607 | down_read(&fsg->filesem); | 3606 | down_read(&fsg->filesem); |
3608 | if (backing_file_is_open(curlun)) { // Get the complete pathname | 3607 | if (backing_file_is_open(curlun)) { // Get the complete pathname |
3609 | p = d_path(curlun->filp->f_dentry, curlun->filp->f_vfsmnt, | 3608 | p = d_path(curlun->filp->f_path.dentry, curlun->filp->f_path.mnt, |
3610 | buf, PAGE_SIZE - 1); | 3609 | buf, PAGE_SIZE - 1); |
3611 | if (IS_ERR(p)) | 3610 | if (IS_ERR(p)) |
3612 | rc = PTR_ERR(p); | 3611 | rc = PTR_ERR(p); |
@@ -3629,7 +3628,7 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const | |||
3629 | { | 3628 | { |
3630 | ssize_t rc = count; | 3629 | ssize_t rc = count; |
3631 | struct lun *curlun = dev_to_lun(dev); | 3630 | struct lun *curlun = dev_to_lun(dev); |
3632 | struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); | 3631 | struct fsg_dev *fsg = dev_get_drvdata(dev); |
3633 | int i; | 3632 | int i; |
3634 | 3633 | ||
3635 | if (sscanf(buf, "%d", &i) != 1) | 3634 | if (sscanf(buf, "%d", &i) != 1) |
@@ -3652,7 +3651,7 @@ static ssize_t store_ro(struct device *dev, struct device_attribute *attr, const | |||
3652 | static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) | 3651 | static ssize_t store_file(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) |
3653 | { | 3652 | { |
3654 | struct lun *curlun = dev_to_lun(dev); | 3653 | struct lun *curlun = dev_to_lun(dev); |
3655 | struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); | 3654 | struct fsg_dev *fsg = dev_get_drvdata(dev); |
3656 | int rc = 0; | 3655 | int rc = 0; |
3657 | 3656 | ||
3658 | if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) { | 3657 | if (curlun->prevent_medium_removal && backing_file_is_open(curlun)) { |
@@ -3700,7 +3699,7 @@ static void fsg_release(struct kref *ref) | |||
3700 | 3699 | ||
3701 | static void lun_release(struct device *dev) | 3700 | static void lun_release(struct device *dev) |
3702 | { | 3701 | { |
3703 | struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); | 3702 | struct fsg_dev *fsg = dev_get_drvdata(dev); |
3704 | 3703 | ||
3705 | kref_put(&fsg->ref, fsg_release); | 3704 | kref_put(&fsg->ref, fsg_release); |
3706 | } | 3705 | } |
@@ -4030,8 +4029,8 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |||
4030 | if (backing_file_is_open(curlun)) { | 4029 | if (backing_file_is_open(curlun)) { |
4031 | p = NULL; | 4030 | p = NULL; |
4032 | if (pathbuf) { | 4031 | if (pathbuf) { |
4033 | p = d_path(curlun->filp->f_dentry, | 4032 | p = d_path(curlun->filp->f_path.dentry, |
4034 | curlun->filp->f_vfsmnt, | 4033 | curlun->filp->f_path.mnt, |
4035 | pathbuf, PATH_MAX); | 4034 | pathbuf, PATH_MAX); |
4036 | if (IS_ERR(p)) | 4035 | if (IS_ERR(p)) |
4037 | p = NULL; | 4036 | p = NULL; |
@@ -4100,7 +4099,7 @@ static struct usb_gadget_driver fsg_driver = { | |||
4100 | #endif | 4099 | #endif |
4101 | .function = (char *) longname, | 4100 | .function = (char *) longname, |
4102 | .bind = fsg_bind, | 4101 | .bind = fsg_bind, |
4103 | .unbind = __exit_p(fsg_unbind), | 4102 | .unbind = fsg_unbind, |
4104 | .disconnect = fsg_disconnect, | 4103 | .disconnect = fsg_disconnect, |
4105 | .setup = fsg_setup, | 4104 | .setup = fsg_setup, |
4106 | .suspend = fsg_suspend, | 4105 | .suspend = fsg_suspend, |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index aa80f0910720..2e3d6620d216 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h | |||
@@ -75,6 +75,12 @@ | |||
75 | #define gadget_is_pxa27x(g) 0 | 75 | #define gadget_is_pxa27x(g) 0 |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #ifdef CONFIG_USB_GADGET_HUSB2DEV | ||
79 | #define gadget_is_husb2dev(g) !strcmp("husb2_udc", (g)->name) | ||
80 | #else | ||
81 | #define gadget_is_husb2dev(g) 0 | ||
82 | #endif | ||
83 | |||
78 | #ifdef CONFIG_USB_GADGET_S3C2410 | 84 | #ifdef CONFIG_USB_GADGET_S3C2410 |
79 | #define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name) | 85 | #define gadget_is_s3c2410(g) !strcmp("s3c2410_udc", (g)->name) |
80 | #else | 86 | #else |
@@ -169,5 +175,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |||
169 | return 0x16; | 175 | return 0x16; |
170 | else if (gadget_is_mpc8272(gadget)) | 176 | else if (gadget_is_mpc8272(gadget)) |
171 | return 0x17; | 177 | return 0x17; |
178 | else if (gadget_is_husb2dev(gadget)) | ||
179 | return 0x18; | ||
172 | return -ENOENT; | 180 | return -ENOENT; |
173 | } | 181 | } |
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 31351826f2ba..d08a8d0e6427 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <sound/initval.h> | 35 | #include <sound/initval.h> |
36 | #include <sound/rawmidi.h> | 36 | #include <sound/rawmidi.h> |
37 | 37 | ||
38 | #include <linux/usb_ch9.h> | 38 | #include <linux/usb/ch9.h> |
39 | #include <linux/usb_gadget.h> | 39 | #include <linux/usb_gadget.h> |
40 | #include <linux/usb/audio.h> | 40 | #include <linux/usb/audio.h> |
41 | #include <linux/usb/midi.h> | 41 | #include <linux/usb/midi.h> |
@@ -123,7 +123,7 @@ struct gmidi_device { | |||
123 | struct usb_request *req; /* for control responses */ | 123 | struct usb_request *req; /* for control responses */ |
124 | u8 config; | 124 | u8 config; |
125 | struct usb_ep *in_ep, *out_ep; | 125 | struct usb_ep *in_ep, *out_ep; |
126 | struct snd_card *card; | 126 | struct snd_card *card; |
127 | struct snd_rawmidi *rmidi; | 127 | struct snd_rawmidi *rmidi; |
128 | struct snd_rawmidi_substream *in_substream; | 128 | struct snd_rawmidi_substream *in_substream; |
129 | struct snd_rawmidi_substream *out_substream; | 129 | struct snd_rawmidi_substream *out_substream; |
@@ -490,7 +490,7 @@ static void gmidi_complete(struct usb_ep *ep, struct usb_request *req) | |||
490 | int status = req->status; | 490 | int status = req->status; |
491 | 491 | ||
492 | switch (status) { | 492 | switch (status) { |
493 | case 0: /* normal completion */ | 493 | case 0: /* normal completion */ |
494 | if (ep == dev->out_ep) { | 494 | if (ep == dev->out_ep) { |
495 | /* we received stuff. | 495 | /* we received stuff. |
496 | req is queued again, below */ | 496 | req is queued again, below */ |
@@ -505,7 +505,7 @@ static void gmidi_complete(struct usb_ep *ep, struct usb_request *req) | |||
505 | break; | 505 | break; |
506 | 506 | ||
507 | /* this endpoint is normally active while we're configured */ | 507 | /* this endpoint is normally active while we're configured */ |
508 | case -ECONNABORTED: /* hardware forced ep reset */ | 508 | case -ECONNABORTED: /* hardware forced ep reset */ |
509 | case -ECONNRESET: /* request dequeued */ | 509 | case -ECONNRESET: /* request dequeued */ |
510 | case -ESHUTDOWN: /* disconnect from host */ | 510 | case -ESHUTDOWN: /* disconnect from host */ |
511 | VDBG(dev, "%s gone (%d), %d/%d\n", ep->name, status, | 511 | VDBG(dev, "%s gone (%d), %d/%d\n", ep->name, status, |
@@ -656,7 +656,7 @@ gmidi_set_config(struct gmidi_device *dev, unsigned number, gfp_t gfp_flags) | |||
656 | case USB_SPEED_LOW: speed = "low"; break; | 656 | case USB_SPEED_LOW: speed = "low"; break; |
657 | case USB_SPEED_FULL: speed = "full"; break; | 657 | case USB_SPEED_FULL: speed = "full"; break; |
658 | case USB_SPEED_HIGH: speed = "high"; break; | 658 | case USB_SPEED_HIGH: speed = "high"; break; |
659 | default: speed = "?"; break; | 659 | default: speed = "?"; break; |
660 | } | 660 | } |
661 | 661 | ||
662 | dev->config = number; | 662 | dev->config = number; |
@@ -1308,7 +1308,7 @@ static struct usb_gadget_driver gmidi_driver = { | |||
1308 | .speed = USB_SPEED_FULL, | 1308 | .speed = USB_SPEED_FULL, |
1309 | .function = (char *)longname, | 1309 | .function = (char *)longname, |
1310 | .bind = gmidi_bind, | 1310 | .bind = gmidi_bind, |
1311 | .unbind = __exit_p(gmidi_unbind), | 1311 | .unbind = gmidi_unbind, |
1312 | 1312 | ||
1313 | .setup = gmidi_setup, | 1313 | .setup = gmidi_setup, |
1314 | .disconnect = gmidi_disconnect, | 1314 | .disconnect = gmidi_disconnect, |
@@ -1316,7 +1316,7 @@ static struct usb_gadget_driver gmidi_driver = { | |||
1316 | .suspend = gmidi_suspend, | 1316 | .suspend = gmidi_suspend, |
1317 | .resume = gmidi_resume, | 1317 | .resume = gmidi_resume, |
1318 | 1318 | ||
1319 | .driver = { | 1319 | .driver = { |
1320 | .name = (char *)shortname, | 1320 | .name = (char *)shortname, |
1321 | .owner = THIS_MODULE, | 1321 | .owner = THIS_MODULE, |
1322 | }, | 1322 | }, |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 805a9826842d..e873cf488246 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -39,7 +39,7 @@ | |||
39 | #include <linux/interrupt.h> | 39 | #include <linux/interrupt.h> |
40 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
41 | #include <linux/device.h> | 41 | #include <linux/device.h> |
42 | #include <linux/usb_ch9.h> | 42 | #include <linux/usb/ch9.h> |
43 | #include <linux/usb_gadget.h> | 43 | #include <linux/usb_gadget.h> |
44 | 44 | ||
45 | #include <asm/byteorder.h> | 45 | #include <asm/byteorder.h> |
@@ -1432,7 +1432,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1432 | if (!driver | 1432 | if (!driver |
1433 | || driver->speed != USB_SPEED_FULL | 1433 | || driver->speed != USB_SPEED_FULL |
1434 | || !driver->bind | 1434 | || !driver->bind |
1435 | || !driver->unbind | ||
1436 | || !driver->disconnect | 1435 | || !driver->disconnect |
1437 | || !driver->setup) | 1436 | || !driver->setup) |
1438 | return -EINVAL; | 1437 | return -EINVAL; |
@@ -1495,7 +1494,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1495 | 1494 | ||
1496 | if (!dev) | 1495 | if (!dev) |
1497 | return -ENODEV; | 1496 | return -ENODEV; |
1498 | if (!driver || driver != dev->driver) | 1497 | if (!driver || driver != dev->driver || !driver->unbind) |
1499 | return -EINVAL; | 1498 | return -EINVAL; |
1500 | 1499 | ||
1501 | spin_lock_irqsave(&dev->lock, flags); | 1500 | spin_lock_irqsave(&dev->lock, flags); |
@@ -1808,13 +1807,8 @@ static void goku_remove(struct pci_dev *pdev) | |||
1808 | struct goku_udc *dev = pci_get_drvdata(pdev); | 1807 | struct goku_udc *dev = pci_get_drvdata(pdev); |
1809 | 1808 | ||
1810 | DBG(dev, "%s\n", __FUNCTION__); | 1809 | DBG(dev, "%s\n", __FUNCTION__); |
1811 | /* start with the driver above us */ | 1810 | |
1812 | if (dev->driver) { | 1811 | BUG_ON(dev->driver); |
1813 | /* should have been done already by driver model core */ | ||
1814 | WARN(dev, "pci remove, driver '%s' is still registered\n", | ||
1815 | dev->driver->driver.name); | ||
1816 | usb_gadget_unregister_driver(dev->driver); | ||
1817 | } | ||
1818 | 1812 | ||
1819 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 1813 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
1820 | remove_proc_entry(proc_node_name, NULL); | 1814 | remove_proc_entry(proc_node_name, NULL); |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 3fb1044a4db0..34296e79edcf 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -20,7 +20,7 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | 22 | ||
23 | // #define DEBUG /* data to help fault diagnosis */ | 23 | // #define DEBUG /* data to help fault diagnosis */ |
24 | // #define VERBOSE /* extra debug messages (success too) */ | 24 | // #define VERBOSE /* extra debug messages (success too) */ |
25 | 25 | ||
26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -59,11 +59,11 @@ | |||
59 | * may serve as a source of device events, used to handle all control | 59 | * may serve as a source of device events, used to handle all control |
60 | * requests other than basic enumeration. | 60 | * requests other than basic enumeration. |
61 | * | 61 | * |
62 | * - Then either immediately, or after a SET_CONFIGURATION control request, | 62 | * - Then, after a SET_CONFIGURATION control request, ep_config() is |
63 | * ep_config() is called when each /dev/gadget/ep* file is configured | 63 | * called when each /dev/gadget/ep* file is configured (by writing |
64 | * (by writing endpoint descriptors). Afterwards these files are used | 64 | * endpoint descriptors). Afterwards these files are used to write() |
65 | * to write() IN data or to read() OUT data. To halt the endpoint, a | 65 | * IN data or to read() OUT data. To halt the endpoint, a "wrong |
66 | * "wrong direction" request is issued (like reading an IN endpoint). | 66 | * direction" request is issued (like reading an IN endpoint). |
67 | * | 67 | * |
68 | * Unlike "usbfs" the only ioctl()s are for things that are rare, and maybe | 68 | * Unlike "usbfs" the only ioctl()s are for things that are rare, and maybe |
69 | * not possible on all hardware. For example, precise fault handling with | 69 | * not possible on all hardware. For example, precise fault handling with |
@@ -98,16 +98,16 @@ enum ep0_state { | |||
98 | * must always write descriptors to initialize the device, then | 98 | * must always write descriptors to initialize the device, then |
99 | * the device becomes UNCONNECTED until enumeration. | 99 | * the device becomes UNCONNECTED until enumeration. |
100 | */ | 100 | */ |
101 | STATE_OPENED, | 101 | STATE_DEV_OPENED, |
102 | 102 | ||
103 | /* From then on, ep0 fd is in either of two basic modes: | 103 | /* From then on, ep0 fd is in either of two basic modes: |
104 | * - (UN)CONNECTED: read usb_gadgetfs_event(s) from it | 104 | * - (UN)CONNECTED: read usb_gadgetfs_event(s) from it |
105 | * - SETUP: read/write will transfer control data and succeed; | 105 | * - SETUP: read/write will transfer control data and succeed; |
106 | * or if "wrong direction", performs protocol stall | 106 | * or if "wrong direction", performs protocol stall |
107 | */ | 107 | */ |
108 | STATE_UNCONNECTED, | 108 | STATE_DEV_UNCONNECTED, |
109 | STATE_CONNECTED, | 109 | STATE_DEV_CONNECTED, |
110 | STATE_SETUP, | 110 | STATE_DEV_SETUP, |
111 | 111 | ||
112 | /* UNBOUND means the driver closed ep0, so the device won't be | 112 | /* UNBOUND means the driver closed ep0, so the device won't be |
113 | * accessible again (DEV_DISABLED) until all fds are closed. | 113 | * accessible again (DEV_DISABLED) until all fds are closed. |
@@ -121,7 +121,7 @@ enum ep0_state { | |||
121 | struct dev_data { | 121 | struct dev_data { |
122 | spinlock_t lock; | 122 | spinlock_t lock; |
123 | atomic_t count; | 123 | atomic_t count; |
124 | enum ep0_state state; | 124 | enum ep0_state state; /* P: lock */ |
125 | struct usb_gadgetfs_event event [N_EVENT]; | 125 | struct usb_gadgetfs_event event [N_EVENT]; |
126 | unsigned ev_next; | 126 | unsigned ev_next; |
127 | struct fasync_struct *fasync; | 127 | struct fasync_struct *fasync; |
@@ -188,7 +188,6 @@ static struct dev_data *dev_new (void) | |||
188 | enum ep_state { | 188 | enum ep_state { |
189 | STATE_EP_DISABLED = 0, | 189 | STATE_EP_DISABLED = 0, |
190 | STATE_EP_READY, | 190 | STATE_EP_READY, |
191 | STATE_EP_DEFER_ENABLE, | ||
192 | STATE_EP_ENABLED, | 191 | STATE_EP_ENABLED, |
193 | STATE_EP_UNBOUND, | 192 | STATE_EP_UNBOUND, |
194 | }; | 193 | }; |
@@ -313,18 +312,10 @@ nonblock: | |||
313 | 312 | ||
314 | if ((val = down_interruptible (&epdata->lock)) < 0) | 313 | if ((val = down_interruptible (&epdata->lock)) < 0) |
315 | return val; | 314 | return val; |
316 | newstate: | 315 | |
317 | switch (epdata->state) { | 316 | switch (epdata->state) { |
318 | case STATE_EP_ENABLED: | 317 | case STATE_EP_ENABLED: |
319 | break; | 318 | break; |
320 | case STATE_EP_DEFER_ENABLE: | ||
321 | DBG (epdata->dev, "%s wait for host\n", epdata->name); | ||
322 | if ((val = wait_event_interruptible (epdata->wait, | ||
323 | epdata->state != STATE_EP_DEFER_ENABLE | ||
324 | || epdata->dev->state == STATE_DEV_UNBOUND | ||
325 | )) < 0) | ||
326 | goto fail; | ||
327 | goto newstate; | ||
328 | // case STATE_EP_DISABLED: /* "can't happen" */ | 319 | // case STATE_EP_DISABLED: /* "can't happen" */ |
329 | // case STATE_EP_READY: /* "can't happen" */ | 320 | // case STATE_EP_READY: /* "can't happen" */ |
330 | default: /* error! */ | 321 | default: /* error! */ |
@@ -333,7 +324,6 @@ newstate: | |||
333 | // FALLTHROUGH | 324 | // FALLTHROUGH |
334 | case STATE_EP_UNBOUND: /* clean disconnect */ | 325 | case STATE_EP_UNBOUND: /* clean disconnect */ |
335 | val = -ENODEV; | 326 | val = -ENODEV; |
336 | fail: | ||
337 | up (&epdata->lock); | 327 | up (&epdata->lock); |
338 | } | 328 | } |
339 | return val; | 329 | return val; |
@@ -565,29 +555,28 @@ static ssize_t ep_aio_read_retry(struct kiocb *iocb) | |||
565 | ssize_t len, total; | 555 | ssize_t len, total; |
566 | int i; | 556 | int i; |
567 | 557 | ||
568 | /* we "retry" to get the right mm context for this: */ | 558 | /* we "retry" to get the right mm context for this: */ |
569 | 559 | ||
570 | /* copy stuff into user buffers */ | 560 | /* copy stuff into user buffers */ |
571 | total = priv->actual; | 561 | total = priv->actual; |
572 | len = 0; | 562 | len = 0; |
573 | for (i=0; i < priv->nr_segs; i++) { | 563 | for (i=0; i < priv->nr_segs; i++) { |
574 | ssize_t this = min((ssize_t)(priv->iv[i].iov_len), total); | 564 | ssize_t this = min((ssize_t)(priv->iv[i].iov_len), total); |
575 | 565 | ||
576 | if (copy_to_user(priv->iv[i].iov_base, priv->buf, this)) { | 566 | if (copy_to_user(priv->iv[i].iov_base, priv->buf, this)) { |
577 | if (len == 0) | 567 | if (len == 0) |
578 | len = -EFAULT; | 568 | len = -EFAULT; |
579 | break; | 569 | break; |
580 | } | 570 | } |
581 | 571 | ||
582 | total -= this; | 572 | total -= this; |
583 | len += this; | 573 | len += this; |
584 | if (total == 0) | 574 | if (total == 0) |
585 | break; | 575 | break; |
586 | } | 576 | } |
587 | kfree(priv->buf); | 577 | kfree(priv->buf); |
588 | kfree(priv); | 578 | kfree(priv); |
589 | aio_put_req(iocb); | 579 | return len; |
590 | return len; | ||
591 | } | 580 | } |
592 | 581 | ||
593 | static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req) | 582 | static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req) |
@@ -600,18 +589,17 @@ static void ep_aio_complete(struct usb_ep *ep, struct usb_request *req) | |||
600 | spin_lock(&epdata->dev->lock); | 589 | spin_lock(&epdata->dev->lock); |
601 | priv->req = NULL; | 590 | priv->req = NULL; |
602 | priv->epdata = NULL; | 591 | priv->epdata = NULL; |
603 | if (priv->iv == NULL | 592 | |
604 | || unlikely(req->actual == 0) | 593 | /* if this was a write or a read returning no data then we |
605 | || unlikely(kiocbIsCancelled(iocb))) { | 594 | * don't need to copy anything to userspace, so we can |
595 | * complete the aio request immediately. | ||
596 | */ | ||
597 | if (priv->iv == NULL || unlikely(req->actual == 0)) { | ||
606 | kfree(req->buf); | 598 | kfree(req->buf); |
607 | kfree(priv); | 599 | kfree(priv); |
608 | iocb->private = NULL; | 600 | iocb->private = NULL; |
609 | /* aio_complete() reports bytes-transferred _and_ faults */ | 601 | /* aio_complete() reports bytes-transferred _and_ faults */ |
610 | if (unlikely(kiocbIsCancelled(iocb))) | 602 | aio_complete(iocb, req->actual ? req->actual : req->status, |
611 | aio_put_req(iocb); | ||
612 | else | ||
613 | aio_complete(iocb, | ||
614 | req->actual ? req->actual : req->status, | ||
615 | req->status); | 603 | req->status); |
616 | } else { | 604 | } else { |
617 | /* retry() won't report both; so we hide some faults */ | 605 | /* retry() won't report both; so we hide some faults */ |
@@ -636,7 +624,7 @@ ep_aio_rwtail( | |||
636 | size_t len, | 624 | size_t len, |
637 | struct ep_data *epdata, | 625 | struct ep_data *epdata, |
638 | const struct iovec *iv, | 626 | const struct iovec *iv, |
639 | unsigned long nr_segs | 627 | unsigned long nr_segs |
640 | ) | 628 | ) |
641 | { | 629 | { |
642 | struct kiocb_priv *priv; | 630 | struct kiocb_priv *priv; |
@@ -852,9 +840,9 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
852 | break; | 840 | break; |
853 | #endif | 841 | #endif |
854 | default: | 842 | default: |
855 | DBG (data->dev, "unconnected, %s init deferred\n", | 843 | DBG(data->dev, "unconnected, %s init abandoned\n", |
856 | data->name); | 844 | data->name); |
857 | data->state = STATE_EP_DEFER_ENABLE; | 845 | value = -EINVAL; |
858 | } | 846 | } |
859 | if (value == 0) { | 847 | if (value == 0) { |
860 | fd->f_op = &ep_io_operations; | 848 | fd->f_op = &ep_io_operations; |
@@ -943,22 +931,24 @@ static void clean_req (struct usb_ep *ep, struct usb_request *req) | |||
943 | static void ep0_complete (struct usb_ep *ep, struct usb_request *req) | 931 | static void ep0_complete (struct usb_ep *ep, struct usb_request *req) |
944 | { | 932 | { |
945 | struct dev_data *dev = ep->driver_data; | 933 | struct dev_data *dev = ep->driver_data; |
934 | unsigned long flags; | ||
946 | int free = 1; | 935 | int free = 1; |
947 | 936 | ||
948 | /* for control OUT, data must still get to userspace */ | 937 | /* for control OUT, data must still get to userspace */ |
938 | spin_lock_irqsave(&dev->lock, flags); | ||
949 | if (!dev->setup_in) { | 939 | if (!dev->setup_in) { |
950 | dev->setup_out_error = (req->status != 0); | 940 | dev->setup_out_error = (req->status != 0); |
951 | if (!dev->setup_out_error) | 941 | if (!dev->setup_out_error) |
952 | free = 0; | 942 | free = 0; |
953 | dev->setup_out_ready = 1; | 943 | dev->setup_out_ready = 1; |
954 | ep0_readable (dev); | 944 | ep0_readable (dev); |
955 | } else if (dev->state == STATE_SETUP) | 945 | } |
956 | dev->state = STATE_CONNECTED; | ||
957 | 946 | ||
958 | /* clean up as appropriate */ | 947 | /* clean up as appropriate */ |
959 | if (free && req->buf != &dev->rbuf) | 948 | if (free && req->buf != &dev->rbuf) |
960 | clean_req (ep, req); | 949 | clean_req (ep, req); |
961 | req->complete = epio_complete; | 950 | req->complete = epio_complete; |
951 | spin_unlock_irqrestore(&dev->lock, flags); | ||
962 | } | 952 | } |
963 | 953 | ||
964 | static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len) | 954 | static int setup_req (struct usb_ep *ep, struct usb_request *req, u16 len) |
@@ -998,13 +988,13 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
998 | } | 988 | } |
999 | 989 | ||
1000 | /* control DATA stage */ | 990 | /* control DATA stage */ |
1001 | if ((state = dev->state) == STATE_SETUP) { | 991 | if ((state = dev->state) == STATE_DEV_SETUP) { |
1002 | 992 | ||
1003 | if (dev->setup_in) { /* stall IN */ | 993 | if (dev->setup_in) { /* stall IN */ |
1004 | VDEBUG(dev, "ep0in stall\n"); | 994 | VDEBUG(dev, "ep0in stall\n"); |
1005 | (void) usb_ep_set_halt (dev->gadget->ep0); | 995 | (void) usb_ep_set_halt (dev->gadget->ep0); |
1006 | retval = -EL2HLT; | 996 | retval = -EL2HLT; |
1007 | dev->state = STATE_CONNECTED; | 997 | dev->state = STATE_DEV_CONNECTED; |
1008 | 998 | ||
1009 | } else if (len == 0) { /* ack SET_CONFIGURATION etc */ | 999 | } else if (len == 0) { /* ack SET_CONFIGURATION etc */ |
1010 | struct usb_ep *ep = dev->gadget->ep0; | 1000 | struct usb_ep *ep = dev->gadget->ep0; |
@@ -1012,7 +1002,7 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
1012 | 1002 | ||
1013 | if ((retval = setup_req (ep, req, 0)) == 0) | 1003 | if ((retval = setup_req (ep, req, 0)) == 0) |
1014 | retval = usb_ep_queue (ep, req, GFP_ATOMIC); | 1004 | retval = usb_ep_queue (ep, req, GFP_ATOMIC); |
1015 | dev->state = STATE_CONNECTED; | 1005 | dev->state = STATE_DEV_CONNECTED; |
1016 | 1006 | ||
1017 | /* assume that was SET_CONFIGURATION */ | 1007 | /* assume that was SET_CONFIGURATION */ |
1018 | if (dev->current_config) { | 1008 | if (dev->current_config) { |
@@ -1040,6 +1030,13 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
1040 | spin_lock_irq (&dev->lock); | 1030 | spin_lock_irq (&dev->lock); |
1041 | if (retval) | 1031 | if (retval) |
1042 | goto done; | 1032 | goto done; |
1033 | |||
1034 | if (dev->state != STATE_DEV_SETUP) { | ||
1035 | retval = -ECANCELED; | ||
1036 | goto done; | ||
1037 | } | ||
1038 | dev->state = STATE_DEV_CONNECTED; | ||
1039 | |||
1043 | if (dev->setup_out_error) | 1040 | if (dev->setup_out_error) |
1044 | retval = -EIO; | 1041 | retval = -EIO; |
1045 | else { | 1042 | else { |
@@ -1066,39 +1063,36 @@ scan: | |||
1066 | /* return queued events right away */ | 1063 | /* return queued events right away */ |
1067 | if (dev->ev_next != 0) { | 1064 | if (dev->ev_next != 0) { |
1068 | unsigned i, n; | 1065 | unsigned i, n; |
1069 | int tmp = dev->ev_next; | ||
1070 | 1066 | ||
1071 | len = min (len, tmp * sizeof (struct usb_gadgetfs_event)); | ||
1072 | n = len / sizeof (struct usb_gadgetfs_event); | 1067 | n = len / sizeof (struct usb_gadgetfs_event); |
1068 | if (dev->ev_next < n) | ||
1069 | n = dev->ev_next; | ||
1073 | 1070 | ||
1074 | /* ep0 can't deliver events when STATE_SETUP */ | 1071 | /* ep0 i/o has special semantics during STATE_DEV_SETUP */ |
1075 | for (i = 0; i < n; i++) { | 1072 | for (i = 0; i < n; i++) { |
1076 | if (dev->event [i].type == GADGETFS_SETUP) { | 1073 | if (dev->event [i].type == GADGETFS_SETUP) { |
1077 | len = i + 1; | 1074 | dev->state = STATE_DEV_SETUP; |
1078 | len *= sizeof (struct usb_gadgetfs_event); | 1075 | n = i + 1; |
1079 | n = 0; | ||
1080 | break; | 1076 | break; |
1081 | } | 1077 | } |
1082 | } | 1078 | } |
1083 | spin_unlock_irq (&dev->lock); | 1079 | spin_unlock_irq (&dev->lock); |
1080 | len = n * sizeof (struct usb_gadgetfs_event); | ||
1084 | if (copy_to_user (buf, &dev->event, len)) | 1081 | if (copy_to_user (buf, &dev->event, len)) |
1085 | retval = -EFAULT; | 1082 | retval = -EFAULT; |
1086 | else | 1083 | else |
1087 | retval = len; | 1084 | retval = len; |
1088 | if (len > 0) { | 1085 | if (len > 0) { |
1089 | len /= sizeof (struct usb_gadgetfs_event); | ||
1090 | |||
1091 | /* NOTE this doesn't guard against broken drivers; | 1086 | /* NOTE this doesn't guard against broken drivers; |
1092 | * concurrent ep0 readers may lose events. | 1087 | * concurrent ep0 readers may lose events. |
1093 | */ | 1088 | */ |
1094 | spin_lock_irq (&dev->lock); | 1089 | spin_lock_irq (&dev->lock); |
1095 | dev->ev_next -= len; | 1090 | if (dev->ev_next > n) { |
1096 | if (dev->ev_next != 0) | 1091 | memmove(&dev->event[0], &dev->event[n], |
1097 | memmove (&dev->event, &dev->event [len], | ||
1098 | sizeof (struct usb_gadgetfs_event) | 1092 | sizeof (struct usb_gadgetfs_event) |
1099 | * (tmp - len)); | 1093 | * (dev->ev_next - n)); |
1100 | if (n == 0) | 1094 | } |
1101 | dev->state = STATE_SETUP; | 1095 | dev->ev_next -= n; |
1102 | spin_unlock_irq (&dev->lock); | 1096 | spin_unlock_irq (&dev->lock); |
1103 | } | 1097 | } |
1104 | return retval; | 1098 | return retval; |
@@ -1113,8 +1107,8 @@ scan: | |||
1113 | DBG (dev, "fail %s, state %d\n", __FUNCTION__, state); | 1107 | DBG (dev, "fail %s, state %d\n", __FUNCTION__, state); |
1114 | retval = -ESRCH; | 1108 | retval = -ESRCH; |
1115 | break; | 1109 | break; |
1116 | case STATE_UNCONNECTED: | 1110 | case STATE_DEV_UNCONNECTED: |
1117 | case STATE_CONNECTED: | 1111 | case STATE_DEV_CONNECTED: |
1118 | spin_unlock_irq (&dev->lock); | 1112 | spin_unlock_irq (&dev->lock); |
1119 | DBG (dev, "%s wait\n", __FUNCTION__); | 1113 | DBG (dev, "%s wait\n", __FUNCTION__); |
1120 | 1114 | ||
@@ -1141,7 +1135,7 @@ next_event (struct dev_data *dev, enum usb_gadgetfs_event_type type) | |||
1141 | switch (type) { | 1135 | switch (type) { |
1142 | /* these events purge the queue */ | 1136 | /* these events purge the queue */ |
1143 | case GADGETFS_DISCONNECT: | 1137 | case GADGETFS_DISCONNECT: |
1144 | if (dev->state == STATE_SETUP) | 1138 | if (dev->state == STATE_DEV_SETUP) |
1145 | dev->setup_abort = 1; | 1139 | dev->setup_abort = 1; |
1146 | // FALL THROUGH | 1140 | // FALL THROUGH |
1147 | case GADGETFS_CONNECT: | 1141 | case GADGETFS_CONNECT: |
@@ -1153,7 +1147,7 @@ next_event (struct dev_data *dev, enum usb_gadgetfs_event_type type) | |||
1153 | for (i = 0; i != dev->ev_next; i++) { | 1147 | for (i = 0; i != dev->ev_next; i++) { |
1154 | if (dev->event [i].type != type) | 1148 | if (dev->event [i].type != type) |
1155 | continue; | 1149 | continue; |
1156 | DBG (dev, "discard old event %d\n", type); | 1150 | DBG(dev, "discard old event[%d] %d\n", i, type); |
1157 | dev->ev_next--; | 1151 | dev->ev_next--; |
1158 | if (i == dev->ev_next) | 1152 | if (i == dev->ev_next) |
1159 | break; | 1153 | break; |
@@ -1166,9 +1160,9 @@ next_event (struct dev_data *dev, enum usb_gadgetfs_event_type type) | |||
1166 | default: | 1160 | default: |
1167 | BUG (); | 1161 | BUG (); |
1168 | } | 1162 | } |
1163 | VDEBUG(dev, "event[%d] = %d\n", dev->ev_next, type); | ||
1169 | event = &dev->event [dev->ev_next++]; | 1164 | event = &dev->event [dev->ev_next++]; |
1170 | BUG_ON (dev->ev_next > N_EVENT); | 1165 | BUG_ON (dev->ev_next > N_EVENT); |
1171 | VDEBUG (dev, "ev %d, next %d\n", type, dev->ev_next); | ||
1172 | memset (event, 0, sizeof *event); | 1166 | memset (event, 0, sizeof *event); |
1173 | event->type = type; | 1167 | event->type = type; |
1174 | return event; | 1168 | return event; |
@@ -1188,12 +1182,13 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1188 | retval = -EIDRM; | 1182 | retval = -EIDRM; |
1189 | 1183 | ||
1190 | /* data and/or status stage for control request */ | 1184 | /* data and/or status stage for control request */ |
1191 | } else if (dev->state == STATE_SETUP) { | 1185 | } else if (dev->state == STATE_DEV_SETUP) { |
1192 | 1186 | ||
1193 | /* IN DATA+STATUS caller makes len <= wLength */ | 1187 | /* IN DATA+STATUS caller makes len <= wLength */ |
1194 | if (dev->setup_in) { | 1188 | if (dev->setup_in) { |
1195 | retval = setup_req (dev->gadget->ep0, dev->req, len); | 1189 | retval = setup_req (dev->gadget->ep0, dev->req, len); |
1196 | if (retval == 0) { | 1190 | if (retval == 0) { |
1191 | dev->state = STATE_DEV_CONNECTED; | ||
1197 | spin_unlock_irq (&dev->lock); | 1192 | spin_unlock_irq (&dev->lock); |
1198 | if (copy_from_user (dev->req->buf, buf, len)) | 1193 | if (copy_from_user (dev->req->buf, buf, len)) |
1199 | retval = -EFAULT; | 1194 | retval = -EFAULT; |
@@ -1219,7 +1214,7 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1219 | VDEBUG(dev, "ep0out stall\n"); | 1214 | VDEBUG(dev, "ep0out stall\n"); |
1220 | (void) usb_ep_set_halt (dev->gadget->ep0); | 1215 | (void) usb_ep_set_halt (dev->gadget->ep0); |
1221 | retval = -EL2HLT; | 1216 | retval = -EL2HLT; |
1222 | dev->state = STATE_CONNECTED; | 1217 | dev->state = STATE_DEV_CONNECTED; |
1223 | } else { | 1218 | } else { |
1224 | DBG(dev, "bogus ep0out stall!\n"); | 1219 | DBG(dev, "bogus ep0out stall!\n"); |
1225 | } | 1220 | } |
@@ -1261,7 +1256,9 @@ dev_release (struct inode *inode, struct file *fd) | |||
1261 | put_dev (dev); | 1256 | put_dev (dev); |
1262 | 1257 | ||
1263 | /* other endpoints were all decoupled from this device */ | 1258 | /* other endpoints were all decoupled from this device */ |
1259 | spin_lock_irq(&dev->lock); | ||
1264 | dev->state = STATE_DEV_DISABLED; | 1260 | dev->state = STATE_DEV_DISABLED; |
1261 | spin_unlock_irq(&dev->lock); | ||
1265 | return 0; | 1262 | return 0; |
1266 | } | 1263 | } |
1267 | 1264 | ||
@@ -1282,7 +1279,7 @@ ep0_poll (struct file *fd, poll_table *wait) | |||
1282 | goto out; | 1279 | goto out; |
1283 | } | 1280 | } |
1284 | 1281 | ||
1285 | if (dev->state == STATE_SETUP) { | 1282 | if (dev->state == STATE_DEV_SETUP) { |
1286 | if (dev->setup_in || dev->setup_can_stall) | 1283 | if (dev->setup_in || dev->setup_can_stall) |
1287 | mask = POLLOUT; | 1284 | mask = POLLOUT; |
1288 | } else { | 1285 | } else { |
@@ -1392,52 +1389,29 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1392 | 1389 | ||
1393 | spin_lock (&dev->lock); | 1390 | spin_lock (&dev->lock); |
1394 | dev->setup_abort = 0; | 1391 | dev->setup_abort = 0; |
1395 | if (dev->state == STATE_UNCONNECTED) { | 1392 | if (dev->state == STATE_DEV_UNCONNECTED) { |
1396 | struct usb_ep *ep; | ||
1397 | struct ep_data *data; | ||
1398 | |||
1399 | dev->state = STATE_CONNECTED; | ||
1400 | dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket; | ||
1401 | |||
1402 | #ifdef CONFIG_USB_GADGET_DUALSPEED | 1393 | #ifdef CONFIG_USB_GADGET_DUALSPEED |
1403 | if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) { | 1394 | if (gadget->speed == USB_SPEED_HIGH && dev->hs_config == 0) { |
1395 | spin_unlock(&dev->lock); | ||
1404 | ERROR (dev, "no high speed config??\n"); | 1396 | ERROR (dev, "no high speed config??\n"); |
1405 | return -EINVAL; | 1397 | return -EINVAL; |
1406 | } | 1398 | } |
1407 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | 1399 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ |
1408 | 1400 | ||
1401 | dev->state = STATE_DEV_CONNECTED; | ||
1402 | dev->dev->bMaxPacketSize0 = gadget->ep0->maxpacket; | ||
1403 | |||
1409 | INFO (dev, "connected\n"); | 1404 | INFO (dev, "connected\n"); |
1410 | event = next_event (dev, GADGETFS_CONNECT); | 1405 | event = next_event (dev, GADGETFS_CONNECT); |
1411 | event->u.speed = gadget->speed; | 1406 | event->u.speed = gadget->speed; |
1412 | ep0_readable (dev); | 1407 | ep0_readable (dev); |
1413 | 1408 | ||
1414 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { | ||
1415 | data = ep->driver_data; | ||
1416 | /* ... down_trylock (&data->lock) ... */ | ||
1417 | if (data->state != STATE_EP_DEFER_ENABLE) | ||
1418 | continue; | ||
1419 | #ifdef CONFIG_USB_GADGET_DUALSPEED | ||
1420 | if (gadget->speed == USB_SPEED_HIGH) | ||
1421 | value = usb_ep_enable (ep, &data->hs_desc); | ||
1422 | else | ||
1423 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | ||
1424 | value = usb_ep_enable (ep, &data->desc); | ||
1425 | if (value) { | ||
1426 | ERROR (dev, "deferred %s enable --> %d\n", | ||
1427 | data->name, value); | ||
1428 | continue; | ||
1429 | } | ||
1430 | data->state = STATE_EP_ENABLED; | ||
1431 | wake_up (&data->wait); | ||
1432 | DBG (dev, "woke up %s waiters\n", data->name); | ||
1433 | } | ||
1434 | |||
1435 | /* host may have given up waiting for response. we can miss control | 1409 | /* host may have given up waiting for response. we can miss control |
1436 | * requests handled lower down (device/endpoint status and features); | 1410 | * requests handled lower down (device/endpoint status and features); |
1437 | * then ep0_{read,write} will report the wrong status. controller | 1411 | * then ep0_{read,write} will report the wrong status. controller |
1438 | * driver will have aborted pending i/o. | 1412 | * driver will have aborted pending i/o. |
1439 | */ | 1413 | */ |
1440 | } else if (dev->state == STATE_SETUP) | 1414 | } else if (dev->state == STATE_DEV_SETUP) |
1441 | dev->setup_abort = 1; | 1415 | dev->setup_abort = 1; |
1442 | 1416 | ||
1443 | req->buf = dev->rbuf; | 1417 | req->buf = dev->rbuf; |
@@ -1583,7 +1557,7 @@ delegate: | |||
1583 | } | 1557 | } |
1584 | 1558 | ||
1585 | /* proceed with data transfer and status phases? */ | 1559 | /* proceed with data transfer and status phases? */ |
1586 | if (value >= 0 && dev->state != STATE_SETUP) { | 1560 | if (value >= 0 && dev->state != STATE_DEV_SETUP) { |
1587 | req->length = value; | 1561 | req->length = value; |
1588 | req->zero = value < w_length; | 1562 | req->zero = value < w_length; |
1589 | value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC); | 1563 | value = usb_ep_queue (gadget->ep0, req, GFP_ATOMIC); |
@@ -1747,7 +1721,9 @@ gadgetfs_bind (struct usb_gadget *gadget) | |||
1747 | goto enomem; | 1721 | goto enomem; |
1748 | 1722 | ||
1749 | INFO (dev, "bound to %s driver\n", gadget->name); | 1723 | INFO (dev, "bound to %s driver\n", gadget->name); |
1750 | dev->state = STATE_UNCONNECTED; | 1724 | spin_lock_irq(&dev->lock); |
1725 | dev->state = STATE_DEV_UNCONNECTED; | ||
1726 | spin_unlock_irq(&dev->lock); | ||
1751 | get_dev (dev); | 1727 | get_dev (dev); |
1752 | return 0; | 1728 | return 0; |
1753 | 1729 | ||
@@ -1762,11 +1738,9 @@ gadgetfs_disconnect (struct usb_gadget *gadget) | |||
1762 | struct dev_data *dev = get_gadget_data (gadget); | 1738 | struct dev_data *dev = get_gadget_data (gadget); |
1763 | 1739 | ||
1764 | spin_lock (&dev->lock); | 1740 | spin_lock (&dev->lock); |
1765 | if (dev->state == STATE_UNCONNECTED) { | 1741 | if (dev->state == STATE_DEV_UNCONNECTED) |
1766 | DBG (dev, "already unconnected\n"); | ||
1767 | goto exit; | 1742 | goto exit; |
1768 | } | 1743 | dev->state = STATE_DEV_UNCONNECTED; |
1769 | dev->state = STATE_UNCONNECTED; | ||
1770 | 1744 | ||
1771 | INFO (dev, "disconnected\n"); | 1745 | INFO (dev, "disconnected\n"); |
1772 | next_event (dev, GADGETFS_DISCONNECT); | 1746 | next_event (dev, GADGETFS_DISCONNECT); |
@@ -1783,9 +1757,9 @@ gadgetfs_suspend (struct usb_gadget *gadget) | |||
1783 | INFO (dev, "suspended from state %d\n", dev->state); | 1757 | INFO (dev, "suspended from state %d\n", dev->state); |
1784 | spin_lock (&dev->lock); | 1758 | spin_lock (&dev->lock); |
1785 | switch (dev->state) { | 1759 | switch (dev->state) { |
1786 | case STATE_SETUP: // VERY odd... host died?? | 1760 | case STATE_DEV_SETUP: // VERY odd... host died?? |
1787 | case STATE_CONNECTED: | 1761 | case STATE_DEV_CONNECTED: |
1788 | case STATE_UNCONNECTED: | 1762 | case STATE_DEV_UNCONNECTED: |
1789 | next_event (dev, GADGETFS_SUSPEND); | 1763 | next_event (dev, GADGETFS_SUSPEND); |
1790 | ep0_readable (dev); | 1764 | ep0_readable (dev); |
1791 | /* FALLTHROUGH */ | 1765 | /* FALLTHROUGH */ |
@@ -1808,7 +1782,7 @@ static struct usb_gadget_driver gadgetfs_driver = { | |||
1808 | .disconnect = gadgetfs_disconnect, | 1782 | .disconnect = gadgetfs_disconnect, |
1809 | .suspend = gadgetfs_suspend, | 1783 | .suspend = gadgetfs_suspend, |
1810 | 1784 | ||
1811 | .driver = { | 1785 | .driver = { |
1812 | .name = (char *) shortname, | 1786 | .name = (char *) shortname, |
1813 | }, | 1787 | }, |
1814 | }; | 1788 | }; |
@@ -1829,7 +1803,7 @@ static struct usb_gadget_driver probe_driver = { | |||
1829 | .unbind = gadgetfs_nop, | 1803 | .unbind = gadgetfs_nop, |
1830 | .setup = (void *)gadgetfs_nop, | 1804 | .setup = (void *)gadgetfs_nop, |
1831 | .disconnect = gadgetfs_nop, | 1805 | .disconnect = gadgetfs_nop, |
1832 | .driver = { | 1806 | .driver = { |
1833 | .name = "nop", | 1807 | .name = "nop", |
1834 | }, | 1808 | }, |
1835 | }; | 1809 | }; |
@@ -1849,19 +1823,16 @@ static struct usb_gadget_driver probe_driver = { | |||
1849 | * . full/low speed config ... all wTotalLength bytes (with interface, | 1823 | * . full/low speed config ... all wTotalLength bytes (with interface, |
1850 | * class, altsetting, endpoint, and other descriptors) | 1824 | * class, altsetting, endpoint, and other descriptors) |
1851 | * . high speed config ... all descriptors, for high speed operation; | 1825 | * . high speed config ... all descriptors, for high speed operation; |
1852 | * this one's optional except for high-speed hardware | 1826 | * this one's optional except for high-speed hardware |
1853 | * . device descriptor | 1827 | * . device descriptor |
1854 | * | 1828 | * |
1855 | * Endpoints are not yet enabled. Drivers may want to immediately | 1829 | * Endpoints are not yet enabled. Drivers must wait until device |
1856 | * initialize them, using the /dev/gadget/ep* files that are available | 1830 | * configuration and interface altsetting changes create |
1857 | * as soon as the kernel sees the configuration, or they can wait | ||
1858 | * until device configuration and interface altsetting changes create | ||
1859 | * the need to configure (or unconfigure) them. | 1831 | * the need to configure (or unconfigure) them. |
1860 | * | 1832 | * |
1861 | * After initialization, the device stays active for as long as that | 1833 | * After initialization, the device stays active for as long as that |
1862 | * $CHIP file is open. Events may then be read from that descriptor, | 1834 | * $CHIP file is open. Events must then be read from that descriptor, |
1863 | * such as configuration notifications. More complex drivers will handle | 1835 | * such as configuration notifications. |
1864 | * some control requests in user space. | ||
1865 | */ | 1836 | */ |
1866 | 1837 | ||
1867 | static int is_valid_config (struct usb_config_descriptor *config) | 1838 | static int is_valid_config (struct usb_config_descriptor *config) |
@@ -1884,9 +1855,6 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) | |||
1884 | u32 tag; | 1855 | u32 tag; |
1885 | char *kbuf; | 1856 | char *kbuf; |
1886 | 1857 | ||
1887 | if (dev->state != STATE_OPENED) | ||
1888 | return -EEXIST; | ||
1889 | |||
1890 | if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) | 1858 | if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) |
1891 | return -EINVAL; | 1859 | return -EINVAL; |
1892 | 1860 | ||
@@ -1978,13 +1946,15 @@ dev_open (struct inode *inode, struct file *fd) | |||
1978 | struct dev_data *dev = inode->i_private; | 1946 | struct dev_data *dev = inode->i_private; |
1979 | int value = -EBUSY; | 1947 | int value = -EBUSY; |
1980 | 1948 | ||
1949 | spin_lock_irq(&dev->lock); | ||
1981 | if (dev->state == STATE_DEV_DISABLED) { | 1950 | if (dev->state == STATE_DEV_DISABLED) { |
1982 | dev->ev_next = 0; | 1951 | dev->ev_next = 0; |
1983 | dev->state = STATE_OPENED; | 1952 | dev->state = STATE_DEV_OPENED; |
1984 | fd->private_data = dev; | 1953 | fd->private_data = dev; |
1985 | get_dev (dev); | 1954 | get_dev (dev); |
1986 | value = 0; | 1955 | value = 0; |
1987 | } | 1956 | } |
1957 | spin_unlock_irq(&dev->lock); | ||
1988 | return value; | 1958 | return value; |
1989 | } | 1959 | } |
1990 | 1960 | ||
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c index 4a991564a03e..a0a73c08a344 100644 --- a/drivers/usb/gadget/lh7a40x_udc.c +++ b/drivers/usb/gadget/lh7a40x_udc.c | |||
@@ -422,9 +422,10 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
422 | DEBUG("%s: %s\n", __FUNCTION__, driver->driver.name); | 422 | DEBUG("%s: %s\n", __FUNCTION__, driver->driver.name); |
423 | 423 | ||
424 | if (!driver | 424 | if (!driver |
425 | || driver->speed != USB_SPEED_FULL | 425 | || driver->speed != USB_SPEED_FULL |
426 | || !driver->bind | 426 | || !driver->bind |
427 | || !driver->unbind || !driver->disconnect || !driver->setup) | 427 | || !driver->disconnect |
428 | || !driver->setup) | ||
428 | return -EINVAL; | 429 | return -EINVAL; |
429 | if (!dev) | 430 | if (!dev) |
430 | return -ENODEV; | 431 | return -ENODEV; |
@@ -471,7 +472,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
471 | 472 | ||
472 | if (!dev) | 473 | if (!dev) |
473 | return -ENODEV; | 474 | return -ENODEV; |
474 | if (!driver || driver != dev->driver) | 475 | if (!driver || driver != dev->driver || !driver->unbind) |
475 | return -EINVAL; | 476 | return -EINVAL; |
476 | 477 | ||
477 | spin_lock_irqsave(&dev->lock, flags); | 478 | spin_lock_irqsave(&dev->lock, flags); |
@@ -2125,9 +2126,11 @@ static int lh7a40x_udc_remove(struct platform_device *pdev) | |||
2125 | 2126 | ||
2126 | DEBUG("%s: %p\n", __FUNCTION__, pdev); | 2127 | DEBUG("%s: %p\n", __FUNCTION__, pdev); |
2127 | 2128 | ||
2129 | if (dev->driver) | ||
2130 | return -EBUSY; | ||
2131 | |||
2128 | udc_disable(dev); | 2132 | udc_disable(dev); |
2129 | remove_proc_files(); | 2133 | remove_proc_files(); |
2130 | usb_gadget_unregister_driver(dev->driver); | ||
2131 | 2134 | ||
2132 | free_irq(IRQ_USBINTR, dev); | 2135 | free_irq(IRQ_USBINTR, dev); |
2133 | 2136 | ||
diff --git a/drivers/usb/gadget/lh7a40x_udc.h b/drivers/usb/gadget/lh7a40x_udc.h index e3bb78524c88..b3fe197e1eeb 100644 --- a/drivers/usb/gadget/lh7a40x_udc.h +++ b/drivers/usb/gadget/lh7a40x_udc.h | |||
@@ -49,7 +49,7 @@ | |||
49 | #include <asm/unaligned.h> | 49 | #include <asm/unaligned.h> |
50 | #include <asm/hardware.h> | 50 | #include <asm/hardware.h> |
51 | 51 | ||
52 | #include <linux/usb_ch9.h> | 52 | #include <linux/usb/ch9.h> |
53 | #include <linux/usb_gadget.h> | 53 | #include <linux/usb_gadget.h> |
54 | 54 | ||
55 | /* | 55 | /* |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 3024c679e38e..7617ff7bd5ac 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -63,7 +63,7 @@ | |||
63 | #include <linux/interrupt.h> | 63 | #include <linux/interrupt.h> |
64 | #include <linux/moduleparam.h> | 64 | #include <linux/moduleparam.h> |
65 | #include <linux/device.h> | 65 | #include <linux/device.h> |
66 | #include <linux/usb_ch9.h> | 66 | #include <linux/usb/ch9.h> |
67 | #include <linux/usb_gadget.h> | 67 | #include <linux/usb_gadget.h> |
68 | 68 | ||
69 | #include <asm/byteorder.h> | 69 | #include <asm/byteorder.h> |
@@ -2020,7 +2020,6 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
2020 | if (!driver | 2020 | if (!driver |
2021 | || driver->speed != USB_SPEED_HIGH | 2021 | || driver->speed != USB_SPEED_HIGH |
2022 | || !driver->bind | 2022 | || !driver->bind |
2023 | || !driver->unbind | ||
2024 | || !driver->setup) | 2023 | || !driver->setup) |
2025 | return -EINVAL; | 2024 | return -EINVAL; |
2026 | if (!dev) | 2025 | if (!dev) |
@@ -2107,7 +2106,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
2107 | 2106 | ||
2108 | if (!dev) | 2107 | if (!dev) |
2109 | return -ENODEV; | 2108 | return -ENODEV; |
2110 | if (!driver || driver != dev->driver) | 2109 | if (!driver || driver != dev->driver || !driver->unbind) |
2111 | return -EINVAL; | 2110 | return -EINVAL; |
2112 | 2111 | ||
2113 | spin_lock_irqsave (&dev->lock, flags); | 2112 | spin_lock_irqsave (&dev->lock, flags); |
@@ -2803,13 +2802,7 @@ static void net2280_remove (struct pci_dev *pdev) | |||
2803 | { | 2802 | { |
2804 | struct net2280 *dev = pci_get_drvdata (pdev); | 2803 | struct net2280 *dev = pci_get_drvdata (pdev); |
2805 | 2804 | ||
2806 | /* start with the driver above us */ | 2805 | BUG_ON(dev->driver); |
2807 | if (dev->driver) { | ||
2808 | /* should have been done already by driver model core */ | ||
2809 | WARN (dev, "pci remove, driver '%s' is still registered\n", | ||
2810 | dev->driver->driver.name); | ||
2811 | usb_gadget_unregister_driver (dev->driver); | ||
2812 | } | ||
2813 | 2806 | ||
2814 | /* then clean up the resources we allocated during probe() */ | 2807 | /* then clean up the resources we allocated during probe() */ |
2815 | net2280_led_shutdown (dev); | 2808 | net2280_led_shutdown (dev); |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 030d87c28c2f..140104341db4 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -38,10 +38,11 @@ | |||
38 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
39 | #include <linux/moduleparam.h> | 39 | #include <linux/moduleparam.h> |
40 | #include <linux/platform_device.h> | 40 | #include <linux/platform_device.h> |
41 | #include <linux/usb_ch9.h> | 41 | #include <linux/usb/ch9.h> |
42 | #include <linux/usb_gadget.h> | 42 | #include <linux/usb_gadget.h> |
43 | #include <linux/usb/otg.h> | 43 | #include <linux/usb/otg.h> |
44 | #include <linux/dma-mapping.h> | 44 | #include <linux/dma-mapping.h> |
45 | #include <linux/clk.h> | ||
45 | 46 | ||
46 | #include <asm/byteorder.h> | 47 | #include <asm/byteorder.h> |
47 | #include <asm/io.h> | 48 | #include <asm/io.h> |
@@ -60,6 +61,11 @@ | |||
60 | /* bulk DMA seems to be behaving for both IN and OUT */ | 61 | /* bulk DMA seems to be behaving for both IN and OUT */ |
61 | #define USE_DMA | 62 | #define USE_DMA |
62 | 63 | ||
64 | /* FIXME: OMAP2 currently has some problem in DMA mode */ | ||
65 | #ifdef CONFIG_ARCH_OMAP2 | ||
66 | #undef USE_DMA | ||
67 | #endif | ||
68 | |||
63 | /* ISO too */ | 69 | /* ISO too */ |
64 | #define USE_ISO | 70 | #define USE_ISO |
65 | 71 | ||
@@ -99,7 +105,7 @@ static unsigned fifo_mode = 0; | |||
99 | * boot parameter "omap_udc:fifo_mode=42" | 105 | * boot parameter "omap_udc:fifo_mode=42" |
100 | */ | 106 | */ |
101 | module_param (fifo_mode, uint, 0); | 107 | module_param (fifo_mode, uint, 0); |
102 | MODULE_PARM_DESC (fifo_mode, "endpoint setup (0 == default)"); | 108 | MODULE_PARM_DESC (fifo_mode, "endpoint configuration"); |
103 | 109 | ||
104 | #ifdef USE_DMA | 110 | #ifdef USE_DMA |
105 | static unsigned use_dma = 1; | 111 | static unsigned use_dma = 1; |
@@ -122,7 +128,7 @@ static const char driver_desc [] = DRIVER_DESC; | |||
122 | /*-------------------------------------------------------------------------*/ | 128 | /*-------------------------------------------------------------------------*/ |
123 | 129 | ||
124 | /* there's a notion of "current endpoint" for modifying endpoint | 130 | /* there's a notion of "current endpoint" for modifying endpoint |
125 | * state, and PIO access to its FIFO. | 131 | * state, and PIO access to its FIFO. |
126 | */ | 132 | */ |
127 | 133 | ||
128 | static void use_ep(struct omap_ep *ep, u16 select) | 134 | static void use_ep(struct omap_ep *ep, u16 select) |
@@ -391,7 +397,7 @@ done(struct omap_ep *ep, struct omap_req *req, int status) | |||
391 | #define FIFO_EMPTY (UDC_NON_ISO_FIFO_EMPTY | UDC_ISO_FIFO_EMPTY) | 397 | #define FIFO_EMPTY (UDC_NON_ISO_FIFO_EMPTY | UDC_ISO_FIFO_EMPTY) |
392 | #define FIFO_UNREADABLE (UDC_EP_HALTED | FIFO_EMPTY) | 398 | #define FIFO_UNREADABLE (UDC_EP_HALTED | FIFO_EMPTY) |
393 | 399 | ||
394 | static inline int | 400 | static inline int |
395 | write_packet(u8 *buf, struct omap_req *req, unsigned max) | 401 | write_packet(u8 *buf, struct omap_req *req, unsigned max) |
396 | { | 402 | { |
397 | unsigned len; | 403 | unsigned len; |
@@ -456,7 +462,7 @@ static int write_fifo(struct omap_ep *ep, struct omap_req *req) | |||
456 | return is_last; | 462 | return is_last; |
457 | } | 463 | } |
458 | 464 | ||
459 | static inline int | 465 | static inline int |
460 | read_packet(u8 *buf, struct omap_req *req, unsigned avail) | 466 | read_packet(u8 *buf, struct omap_req *req, unsigned avail) |
461 | { | 467 | { |
462 | unsigned len; | 468 | unsigned len; |
@@ -542,9 +548,9 @@ static inline dma_addr_t dma_csac(unsigned lch) | |||
542 | /* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is | 548 | /* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is |
543 | * read before the DMA controller finished disabling the channel. | 549 | * read before the DMA controller finished disabling the channel. |
544 | */ | 550 | */ |
545 | csac = omap_readw(OMAP_DMA_CSAC(lch)); | 551 | csac = OMAP_DMA_CSAC_REG(lch); |
546 | if (csac == 0) | 552 | if (csac == 0) |
547 | csac = omap_readw(OMAP_DMA_CSAC(lch)); | 553 | csac = OMAP_DMA_CSAC_REG(lch); |
548 | return csac; | 554 | return csac; |
549 | } | 555 | } |
550 | 556 | ||
@@ -555,9 +561,9 @@ static inline dma_addr_t dma_cdac(unsigned lch) | |||
555 | /* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is | 561 | /* omap 3.2/3.3 erratum: sometimes 0 is returned if CSAC/CDAC is |
556 | * read before the DMA controller finished disabling the channel. | 562 | * read before the DMA controller finished disabling the channel. |
557 | */ | 563 | */ |
558 | cdac = omap_readw(OMAP_DMA_CDAC(lch)); | 564 | cdac = OMAP_DMA_CDAC_REG(lch); |
559 | if (cdac == 0) | 565 | if (cdac == 0) |
560 | cdac = omap_readw(OMAP_DMA_CDAC(lch)); | 566 | cdac = OMAP_DMA_CDAC_REG(lch); |
561 | return cdac; | 567 | return cdac; |
562 | } | 568 | } |
563 | 569 | ||
@@ -582,7 +588,7 @@ static u16 dma_src_len(struct omap_ep *ep, dma_addr_t start) | |||
582 | } | 588 | } |
583 | 589 | ||
584 | #define DMA_DEST_LAST(x) (cpu_is_omap15xx() \ | 590 | #define DMA_DEST_LAST(x) (cpu_is_omap15xx() \ |
585 | ? omap_readw(OMAP_DMA_CSAC(x)) /* really: CPC */ \ | 591 | ? OMAP_DMA_CSAC_REG(x) /* really: CPC */ \ |
586 | : dma_cdac(x)) | 592 | : dma_cdac(x)) |
587 | 593 | ||
588 | static u16 dma_dest_len(struct omap_ep *ep, dma_addr_t start) | 594 | static u16 dma_dest_len(struct omap_ep *ep, dma_addr_t start) |
@@ -620,17 +626,19 @@ static void next_in_dma(struct omap_ep *ep, struct omap_req *req) | |||
620 | || (cpu_is_omap15xx() && length < ep->maxpacket)) { | 626 | || (cpu_is_omap15xx() && length < ep->maxpacket)) { |
621 | txdma_ctrl = UDC_TXN_EOT | length; | 627 | txdma_ctrl = UDC_TXN_EOT | length; |
622 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, | 628 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S8, |
623 | length, 1, sync_mode); | 629 | length, 1, sync_mode, 0, 0); |
624 | } else { | 630 | } else { |
625 | length = min(length / ep->maxpacket, | 631 | length = min(length / ep->maxpacket, |
626 | (unsigned) UDC_TXN_TSC + 1); | 632 | (unsigned) UDC_TXN_TSC + 1); |
627 | txdma_ctrl = length; | 633 | txdma_ctrl = length; |
628 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, | 634 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, |
629 | ep->ep.maxpacket >> 1, length, sync_mode); | 635 | ep->ep.maxpacket >> 1, length, sync_mode, |
636 | 0, 0); | ||
630 | length *= ep->maxpacket; | 637 | length *= ep->maxpacket; |
631 | } | 638 | } |
632 | omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF, | 639 | omap_set_dma_src_params(ep->lch, OMAP_DMA_PORT_EMIFF, |
633 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual); | 640 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, |
641 | 0, 0); | ||
634 | 642 | ||
635 | omap_start_dma(ep->lch); | 643 | omap_start_dma(ep->lch); |
636 | ep->dma_counter = dma_csac(ep->lch); | 644 | ep->dma_counter = dma_csac(ep->lch); |
@@ -675,9 +683,11 @@ static void next_out_dma(struct omap_ep *ep, struct omap_req *req) | |||
675 | req->dma_bytes = packets * ep->ep.maxpacket; | 683 | req->dma_bytes = packets * ep->ep.maxpacket; |
676 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, | 684 | omap_set_dma_transfer_params(ep->lch, OMAP_DMA_DATA_TYPE_S16, |
677 | ep->ep.maxpacket >> 1, packets, | 685 | ep->ep.maxpacket >> 1, packets, |
678 | OMAP_DMA_SYNC_ELEMENT); | 686 | OMAP_DMA_SYNC_ELEMENT, |
687 | 0, 0); | ||
679 | omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, | 688 | omap_set_dma_dest_params(ep->lch, OMAP_DMA_PORT_EMIFF, |
680 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual); | 689 | OMAP_DMA_AMODE_POST_INC, req->req.dma + req->req.actual, |
690 | 0, 0); | ||
681 | ep->dma_counter = DMA_DEST_LAST(ep->lch); | 691 | ep->dma_counter = DMA_DEST_LAST(ep->lch); |
682 | 692 | ||
683 | UDC_RXDMA_REG(ep->dma_channel) = UDC_RXN_STOP | (packets - 1); | 693 | UDC_RXDMA_REG(ep->dma_channel) = UDC_RXN_STOP | (packets - 1); |
@@ -820,7 +830,8 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
820 | omap_set_dma_dest_params(ep->lch, | 830 | omap_set_dma_dest_params(ep->lch, |
821 | OMAP_DMA_PORT_TIPB, | 831 | OMAP_DMA_PORT_TIPB, |
822 | OMAP_DMA_AMODE_CONSTANT, | 832 | OMAP_DMA_AMODE_CONSTANT, |
823 | (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG)); | 833 | (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG), |
834 | 0, 0); | ||
824 | } | 835 | } |
825 | } else { | 836 | } else { |
826 | status = omap_request_dma(OMAP_DMA_USB_W2FC_RX0 - 1 + channel, | 837 | status = omap_request_dma(OMAP_DMA_USB_W2FC_RX0 - 1 + channel, |
@@ -831,7 +842,8 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
831 | omap_set_dma_src_params(ep->lch, | 842 | omap_set_dma_src_params(ep->lch, |
832 | OMAP_DMA_PORT_TIPB, | 843 | OMAP_DMA_PORT_TIPB, |
833 | OMAP_DMA_AMODE_CONSTANT, | 844 | OMAP_DMA_AMODE_CONSTANT, |
834 | (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG)); | 845 | (unsigned long) io_v2p((u32)&UDC_DATA_DMA_REG), |
846 | 0, 0); | ||
835 | /* EMIFF */ | 847 | /* EMIFF */ |
836 | omap_set_dma_dest_burst_mode(ep->lch, | 848 | omap_set_dma_dest_burst_mode(ep->lch, |
837 | OMAP_DMA_DATA_BURST_4); | 849 | OMAP_DMA_DATA_BURST_4); |
@@ -846,7 +858,7 @@ static void dma_channel_claim(struct omap_ep *ep, unsigned channel) | |||
846 | 858 | ||
847 | /* channel type P: hw synch (fifo) */ | 859 | /* channel type P: hw synch (fifo) */ |
848 | if (!cpu_is_omap15xx()) | 860 | if (!cpu_is_omap15xx()) |
849 | omap_writew(2, OMAP_DMA_LCH_CTRL(ep->lch)); | 861 | OMAP1_DMA_LCH_CTRL_REG(ep->lch) = 2; |
850 | } | 862 | } |
851 | 863 | ||
852 | just_restart: | 864 | just_restart: |
@@ -893,7 +905,7 @@ static void dma_channel_release(struct omap_ep *ep) | |||
893 | else | 905 | else |
894 | req = NULL; | 906 | req = NULL; |
895 | 907 | ||
896 | active = ((1 << 7) & omap_readl(OMAP_DMA_CCR(ep->lch))) != 0; | 908 | active = ((1 << 7) & OMAP_DMA_CCR_REG(ep->lch)) != 0; |
897 | 909 | ||
898 | DBG("%s release %s %cxdma%d %p\n", ep->ep.name, | 910 | DBG("%s release %s %cxdma%d %p\n", ep->ep.name, |
899 | active ? "active" : "idle", | 911 | active ? "active" : "idle", |
@@ -1117,7 +1129,7 @@ static int omap_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
1117 | */ | 1129 | */ |
1118 | dma_channel_release(ep); | 1130 | dma_channel_release(ep); |
1119 | dma_channel_claim(ep, channel); | 1131 | dma_channel_claim(ep, channel); |
1120 | } else | 1132 | } else |
1121 | done(ep, req, -ECONNRESET); | 1133 | done(ep, req, -ECONNRESET); |
1122 | spin_unlock_irqrestore(&ep->udc->lock, flags); | 1134 | spin_unlock_irqrestore(&ep->udc->lock, flags); |
1123 | return 0; | 1135 | return 0; |
@@ -1153,7 +1165,7 @@ static int omap_ep_set_halt(struct usb_ep *_ep, int value) | |||
1153 | 1165 | ||
1154 | /* IN endpoints must already be idle */ | 1166 | /* IN endpoints must already be idle */ |
1155 | if ((ep->bEndpointAddress & USB_DIR_IN) | 1167 | if ((ep->bEndpointAddress & USB_DIR_IN) |
1156 | && !list_empty(&ep->queue)) { | 1168 | && !list_empty(&ep->queue)) { |
1157 | status = -EAGAIN; | 1169 | status = -EAGAIN; |
1158 | goto done; | 1170 | goto done; |
1159 | } | 1171 | } |
@@ -1298,6 +1310,23 @@ static void pullup_disable(struct omap_udc *udc) | |||
1298 | UDC_SYSCON1_REG &= ~UDC_PULLUP_EN; | 1310 | UDC_SYSCON1_REG &= ~UDC_PULLUP_EN; |
1299 | } | 1311 | } |
1300 | 1312 | ||
1313 | static struct omap_udc *udc; | ||
1314 | |||
1315 | static void omap_udc_enable_clock(int enable) | ||
1316 | { | ||
1317 | if (udc == NULL || udc->dc_clk == NULL || udc->hhc_clk == NULL) | ||
1318 | return; | ||
1319 | |||
1320 | if (enable) { | ||
1321 | clk_enable(udc->dc_clk); | ||
1322 | clk_enable(udc->hhc_clk); | ||
1323 | udelay(100); | ||
1324 | } else { | ||
1325 | clk_disable(udc->hhc_clk); | ||
1326 | clk_disable(udc->dc_clk); | ||
1327 | } | ||
1328 | } | ||
1329 | |||
1301 | /* | 1330 | /* |
1302 | * Called by whatever detects VBUS sessions: external transceiver | 1331 | * Called by whatever detects VBUS sessions: external transceiver |
1303 | * driver, or maybe GPIO0 VBUS IRQ. May request 48 MHz clock. | 1332 | * driver, or maybe GPIO0 VBUS IRQ. May request 48 MHz clock. |
@@ -1318,10 +1347,22 @@ static int omap_vbus_session(struct usb_gadget *gadget, int is_active) | |||
1318 | else | 1347 | else |
1319 | FUNC_MUX_CTRL_0_REG &= ~VBUS_CTRL_1510; | 1348 | FUNC_MUX_CTRL_0_REG &= ~VBUS_CTRL_1510; |
1320 | } | 1349 | } |
1350 | if (udc->dc_clk != NULL && is_active) { | ||
1351 | if (!udc->clk_requested) { | ||
1352 | omap_udc_enable_clock(1); | ||
1353 | udc->clk_requested = 1; | ||
1354 | } | ||
1355 | } | ||
1321 | if (can_pullup(udc)) | 1356 | if (can_pullup(udc)) |
1322 | pullup_enable(udc); | 1357 | pullup_enable(udc); |
1323 | else | 1358 | else |
1324 | pullup_disable(udc); | 1359 | pullup_disable(udc); |
1360 | if (udc->dc_clk != NULL && !is_active) { | ||
1361 | if (udc->clk_requested) { | ||
1362 | omap_udc_enable_clock(0); | ||
1363 | udc->clk_requested = 0; | ||
1364 | } | ||
1365 | } | ||
1325 | spin_unlock_irqrestore(&udc->lock, flags); | 1366 | spin_unlock_irqrestore(&udc->lock, flags); |
1326 | return 0; | 1367 | return 0; |
1327 | } | 1368 | } |
@@ -1441,7 +1482,7 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src) | |||
1441 | } | 1482 | } |
1442 | } | 1483 | } |
1443 | 1484 | ||
1444 | /* IN/OUT packets mean we're in the DATA or STATUS stage. | 1485 | /* IN/OUT packets mean we're in the DATA or STATUS stage. |
1445 | * This driver uses only uses protocol stalls (ep0 never halts), | 1486 | * This driver uses only uses protocol stalls (ep0 never halts), |
1446 | * and if we got this far the gadget driver already had a | 1487 | * and if we got this far the gadget driver already had a |
1447 | * chance to stall. Tries to be forgiving of host oddities. | 1488 | * chance to stall. Tries to be forgiving of host oddities. |
@@ -1509,7 +1550,7 @@ static void ep0_irq(struct omap_udc *udc, u16 irq_src) | |||
1509 | } else if (stat == 0) | 1550 | } else if (stat == 0) |
1510 | UDC_CTRL_REG = UDC_SET_FIFO_EN; | 1551 | UDC_CTRL_REG = UDC_SET_FIFO_EN; |
1511 | UDC_EP_NUM_REG = 0; | 1552 | UDC_EP_NUM_REG = 0; |
1512 | 1553 | ||
1513 | /* activate status stage */ | 1554 | /* activate status stage */ |
1514 | if (stat == 1) { | 1555 | if (stat == 1) { |
1515 | done(ep0, req, 0); | 1556 | done(ep0, req, 0); |
@@ -1866,7 +1907,7 @@ static void pio_out_timer(unsigned long _ep) | |||
1866 | 1907 | ||
1867 | spin_lock_irqsave(&ep->udc->lock, flags); | 1908 | spin_lock_irqsave(&ep->udc->lock, flags); |
1868 | if (!list_empty(&ep->queue) && ep->ackwait) { | 1909 | if (!list_empty(&ep->queue) && ep->ackwait) { |
1869 | use_ep(ep, 0); | 1910 | use_ep(ep, UDC_EP_SEL); |
1870 | stat_flg = UDC_STAT_FLG_REG; | 1911 | stat_flg = UDC_STAT_FLG_REG; |
1871 | 1912 | ||
1872 | if ((stat_flg & UDC_ACK) && (!(stat_flg & UDC_FIFO_EN) | 1913 | if ((stat_flg & UDC_ACK) && (!(stat_flg & UDC_FIFO_EN) |
@@ -1876,12 +1917,12 @@ static void pio_out_timer(unsigned long _ep) | |||
1876 | VDBG("%s: lose, %04x\n", ep->ep.name, stat_flg); | 1917 | VDBG("%s: lose, %04x\n", ep->ep.name, stat_flg); |
1877 | req = container_of(ep->queue.next, | 1918 | req = container_of(ep->queue.next, |
1878 | struct omap_req, queue); | 1919 | struct omap_req, queue); |
1879 | UDC_EP_NUM_REG = ep->bEndpointAddress | UDC_EP_SEL; | ||
1880 | (void) read_fifo(ep, req); | 1920 | (void) read_fifo(ep, req); |
1881 | UDC_EP_NUM_REG = ep->bEndpointAddress; | 1921 | UDC_EP_NUM_REG = ep->bEndpointAddress; |
1882 | UDC_CTRL_REG = UDC_SET_FIFO_EN; | 1922 | UDC_CTRL_REG = UDC_SET_FIFO_EN; |
1883 | ep->ackwait = 1 + ep->double_buf; | 1923 | ep->ackwait = 1 + ep->double_buf; |
1884 | } | 1924 | } else |
1925 | deselect_ep(); | ||
1885 | } | 1926 | } |
1886 | mod_timer(&ep->timer, PIO_OUT_TIMEOUT); | 1927 | mod_timer(&ep->timer, PIO_OUT_TIMEOUT); |
1887 | spin_unlock_irqrestore(&ep->udc->lock, flags); | 1928 | spin_unlock_irqrestore(&ep->udc->lock, flags); |
@@ -2028,7 +2069,17 @@ static irqreturn_t omap_udc_iso_irq(int irq, void *_dev) | |||
2028 | 2069 | ||
2029 | /*-------------------------------------------------------------------------*/ | 2070 | /*-------------------------------------------------------------------------*/ |
2030 | 2071 | ||
2031 | static struct omap_udc *udc; | 2072 | static inline int machine_needs_vbus_session(void) |
2073 | { | ||
2074 | return (machine_is_omap_innovator() | ||
2075 | || machine_is_omap_osk() | ||
2076 | || machine_is_omap_apollon() | ||
2077 | #ifndef CONFIG_MACH_OMAP_H4_OTG | ||
2078 | || machine_is_omap_h4() | ||
2079 | #endif | ||
2080 | || machine_is_sx1() | ||
2081 | ); | ||
2082 | } | ||
2032 | 2083 | ||
2033 | int usb_gadget_register_driver (struct usb_gadget_driver *driver) | 2084 | int usb_gadget_register_driver (struct usb_gadget_driver *driver) |
2034 | { | 2085 | { |
@@ -2043,7 +2094,6 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
2043 | // FIXME if otg, check: driver->is_otg | 2094 | // FIXME if otg, check: driver->is_otg |
2044 | || driver->speed < USB_SPEED_FULL | 2095 | || driver->speed < USB_SPEED_FULL |
2045 | || !driver->bind | 2096 | || !driver->bind |
2046 | || !driver->unbind | ||
2047 | || !driver->setup) | 2097 | || !driver->setup) |
2048 | return -EINVAL; | 2098 | return -EINVAL; |
2049 | 2099 | ||
@@ -2071,6 +2121,9 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
2071 | udc->gadget.dev.driver = &driver->driver; | 2121 | udc->gadget.dev.driver = &driver->driver; |
2072 | spin_unlock_irqrestore(&udc->lock, flags); | 2122 | spin_unlock_irqrestore(&udc->lock, flags); |
2073 | 2123 | ||
2124 | if (udc->dc_clk != NULL) | ||
2125 | omap_udc_enable_clock(1); | ||
2126 | |||
2074 | status = driver->bind (&udc->gadget); | 2127 | status = driver->bind (&udc->gadget); |
2075 | if (status) { | 2128 | if (status) { |
2076 | DBG("bind to %s --> %d\n", driver->driver.name, status); | 2129 | DBG("bind to %s --> %d\n", driver->driver.name, status); |
@@ -2087,9 +2140,11 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
2087 | status = otg_set_peripheral(udc->transceiver, &udc->gadget); | 2140 | status = otg_set_peripheral(udc->transceiver, &udc->gadget); |
2088 | if (status < 0) { | 2141 | if (status < 0) { |
2089 | ERR("can't bind to transceiver\n"); | 2142 | ERR("can't bind to transceiver\n"); |
2090 | driver->unbind (&udc->gadget); | 2143 | if (driver->unbind) { |
2091 | udc->gadget.dev.driver = NULL; | 2144 | driver->unbind (&udc->gadget); |
2092 | udc->driver = NULL; | 2145 | udc->gadget.dev.driver = NULL; |
2146 | udc->driver = NULL; | ||
2147 | } | ||
2093 | goto done; | 2148 | goto done; |
2094 | } | 2149 | } |
2095 | } else { | 2150 | } else { |
@@ -2102,10 +2157,12 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver) | |||
2102 | /* boards that don't have VBUS sensing can't autogate 48MHz; | 2157 | /* boards that don't have VBUS sensing can't autogate 48MHz; |
2103 | * can't enter deep sleep while a gadget driver is active. | 2158 | * can't enter deep sleep while a gadget driver is active. |
2104 | */ | 2159 | */ |
2105 | if (machine_is_omap_innovator() || machine_is_omap_osk()) | 2160 | if (machine_needs_vbus_session()) |
2106 | omap_vbus_session(&udc->gadget, 1); | 2161 | omap_vbus_session(&udc->gadget, 1); |
2107 | 2162 | ||
2108 | done: | 2163 | done: |
2164 | if (udc->dc_clk != NULL) | ||
2165 | omap_udc_enable_clock(0); | ||
2109 | return status; | 2166 | return status; |
2110 | } | 2167 | } |
2111 | EXPORT_SYMBOL(usb_gadget_register_driver); | 2168 | EXPORT_SYMBOL(usb_gadget_register_driver); |
@@ -2117,10 +2174,13 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
2117 | 2174 | ||
2118 | if (!udc) | 2175 | if (!udc) |
2119 | return -ENODEV; | 2176 | return -ENODEV; |
2120 | if (!driver || driver != udc->driver) | 2177 | if (!driver || driver != udc->driver || !driver->unbind) |
2121 | return -EINVAL; | 2178 | return -EINVAL; |
2122 | 2179 | ||
2123 | if (machine_is_omap_innovator() || machine_is_omap_osk()) | 2180 | if (udc->dc_clk != NULL) |
2181 | omap_udc_enable_clock(1); | ||
2182 | |||
2183 | if (machine_needs_vbus_session()) | ||
2124 | omap_vbus_session(&udc->gadget, 0); | 2184 | omap_vbus_session(&udc->gadget, 0); |
2125 | 2185 | ||
2126 | if (udc->transceiver) | 2186 | if (udc->transceiver) |
@@ -2136,6 +2196,8 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver) | |||
2136 | udc->gadget.dev.driver = NULL; | 2196 | udc->gadget.dev.driver = NULL; |
2137 | udc->driver = NULL; | 2197 | udc->driver = NULL; |
2138 | 2198 | ||
2199 | if (udc->dc_clk != NULL) | ||
2200 | omap_udc_enable_clock(0); | ||
2139 | DBG("unregistered driver '%s'\n", driver->driver.name); | 2201 | DBG("unregistered driver '%s'\n", driver->driver.name); |
2140 | return status; | 2202 | return status; |
2141 | } | 2203 | } |
@@ -2218,7 +2280,7 @@ static char *trx_mode(unsigned m, int enabled) | |||
2218 | case 0: return enabled ? "*6wire" : "unused"; | 2280 | case 0: return enabled ? "*6wire" : "unused"; |
2219 | case 1: return "4wire"; | 2281 | case 1: return "4wire"; |
2220 | case 2: return "3wire"; | 2282 | case 2: return "3wire"; |
2221 | case 3: return "6wire"; | 2283 | case 3: return "6wire"; |
2222 | default: return "unknown"; | 2284 | default: return "unknown"; |
2223 | } | 2285 | } |
2224 | } | 2286 | } |
@@ -2227,11 +2289,18 @@ static int proc_otg_show(struct seq_file *s) | |||
2227 | { | 2289 | { |
2228 | u32 tmp; | 2290 | u32 tmp; |
2229 | u32 trans; | 2291 | u32 trans; |
2292 | char *ctrl_name; | ||
2230 | 2293 | ||
2231 | tmp = OTG_REV_REG; | 2294 | tmp = OTG_REV_REG; |
2232 | trans = USB_TRANSCEIVER_CTRL_REG; | 2295 | if (cpu_is_omap24xx()) { |
2233 | seq_printf(s, "\nOTG rev %d.%d, transceiver_ctrl %05x\n", | 2296 | ctrl_name = "control_devconf"; |
2234 | tmp >> 4, tmp & 0xf, trans); | 2297 | trans = CONTROL_DEVCONF_REG; |
2298 | } else { | ||
2299 | ctrl_name = "tranceiver_ctrl"; | ||
2300 | trans = USB_TRANSCEIVER_CTRL_REG; | ||
2301 | } | ||
2302 | seq_printf(s, "\nOTG rev %d.%d, %s %05x\n", | ||
2303 | tmp >> 4, tmp & 0xf, ctrl_name, trans); | ||
2235 | tmp = OTG_SYSCON_1_REG; | 2304 | tmp = OTG_SYSCON_1_REG; |
2236 | seq_printf(s, "otg_syscon1 %08x usb2 %s, usb1 %s, usb0 %s," | 2305 | seq_printf(s, "otg_syscon1 %08x usb2 %s, usb1 %s, usb0 %s," |
2237 | FOURBITS "\n", tmp, | 2306 | FOURBITS "\n", tmp, |
@@ -2306,7 +2375,7 @@ static int proc_udc_show(struct seq_file *s, void *_) | |||
2306 | driver_desc, | 2375 | driver_desc, |
2307 | use_dma ? " (dma)" : ""); | 2376 | use_dma ? " (dma)" : ""); |
2308 | 2377 | ||
2309 | tmp = UDC_REV_REG & 0xff; | 2378 | tmp = UDC_REV_REG & 0xff; |
2310 | seq_printf(s, | 2379 | seq_printf(s, |
2311 | "UDC rev %d.%d, fifo mode %d, gadget %s\n" | 2380 | "UDC rev %d.%d, fifo mode %d, gadget %s\n" |
2312 | "hmc %d, transceiver %s\n", | 2381 | "hmc %d, transceiver %s\n", |
@@ -2314,11 +2383,16 @@ static int proc_udc_show(struct seq_file *s, void *_) | |||
2314 | fifo_mode, | 2383 | fifo_mode, |
2315 | udc->driver ? udc->driver->driver.name : "(none)", | 2384 | udc->driver ? udc->driver->driver.name : "(none)", |
2316 | HMC, | 2385 | HMC, |
2317 | udc->transceiver ? udc->transceiver->label : "(none)"); | 2386 | udc->transceiver |
2318 | seq_printf(s, "ULPD control %04x req %04x status %04x\n", | 2387 | ? udc->transceiver->label |
2319 | __REG16(ULPD_CLOCK_CTRL), | 2388 | : ((cpu_is_omap1710() || cpu_is_omap24xx()) |
2320 | __REG16(ULPD_SOFT_REQ), | 2389 | ? "external" : "(none)")); |
2321 | __REG16(ULPD_STATUS_REQ)); | 2390 | if (cpu_class_is_omap1()) { |
2391 | seq_printf(s, "ULPD control %04x req %04x status %04x\n", | ||
2392 | __REG16(ULPD_CLOCK_CTRL), | ||
2393 | __REG16(ULPD_SOFT_REQ), | ||
2394 | __REG16(ULPD_STATUS_REQ)); | ||
2395 | } | ||
2322 | 2396 | ||
2323 | /* OTG controller registers */ | 2397 | /* OTG controller registers */ |
2324 | if (!cpu_is_omap15xx()) | 2398 | if (!cpu_is_omap15xx()) |
@@ -2503,9 +2577,10 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2503 | dbuf = 1; | 2577 | dbuf = 1; |
2504 | } else { | 2578 | } else { |
2505 | /* double-buffering "not supported" on 15xx, | 2579 | /* double-buffering "not supported" on 15xx, |
2506 | * and ignored for PIO-IN on 16xx | 2580 | * and ignored for PIO-IN on newer chips |
2581 | * (for more reliable behavior) | ||
2507 | */ | 2582 | */ |
2508 | if (!use_dma || cpu_is_omap15xx()) | 2583 | if (!use_dma || cpu_is_omap15xx() || cpu_is_omap24xx()) |
2509 | dbuf = 0; | 2584 | dbuf = 0; |
2510 | 2585 | ||
2511 | switch (maxp) { | 2586 | switch (maxp) { |
@@ -2548,7 +2623,7 @@ omap_ep_setup(char *name, u8 addr, u8 type, | |||
2548 | ep->bEndpointAddress = addr; | 2623 | ep->bEndpointAddress = addr; |
2549 | ep->bmAttributes = type; | 2624 | ep->bmAttributes = type; |
2550 | ep->double_buf = dbuf; | 2625 | ep->double_buf = dbuf; |
2551 | ep->udc = udc; | 2626 | ep->udc = udc; |
2552 | 2627 | ||
2553 | ep->ep.name = ep->name; | 2628 | ep->ep.name = ep->name; |
2554 | ep->ep.ops = &omap_ep_ops; | 2629 | ep->ep.ops = &omap_ep_ops; |
@@ -2708,15 +2783,37 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2708 | struct otg_transceiver *xceiv = NULL; | 2783 | struct otg_transceiver *xceiv = NULL; |
2709 | const char *type = NULL; | 2784 | const char *type = NULL; |
2710 | struct omap_usb_config *config = pdev->dev.platform_data; | 2785 | struct omap_usb_config *config = pdev->dev.platform_data; |
2786 | struct clk *dc_clk; | ||
2787 | struct clk *hhc_clk; | ||
2711 | 2788 | ||
2712 | /* NOTE: "knows" the order of the resources! */ | 2789 | /* NOTE: "knows" the order of the resources! */ |
2713 | if (!request_mem_region(pdev->resource[0].start, | 2790 | if (!request_mem_region(pdev->resource[0].start, |
2714 | pdev->resource[0].end - pdev->resource[0].start + 1, | 2791 | pdev->resource[0].end - pdev->resource[0].start + 1, |
2715 | driver_name)) { | 2792 | driver_name)) { |
2716 | DBG("request_mem_region failed\n"); | 2793 | DBG("request_mem_region failed\n"); |
2717 | return -EBUSY; | 2794 | return -EBUSY; |
2718 | } | 2795 | } |
2719 | 2796 | ||
2797 | if (cpu_is_omap16xx()) { | ||
2798 | dc_clk = clk_get(&pdev->dev, "usb_dc_ck"); | ||
2799 | hhc_clk = clk_get(&pdev->dev, "usb_hhc_ck"); | ||
2800 | BUG_ON(IS_ERR(dc_clk) || IS_ERR(hhc_clk)); | ||
2801 | /* can't use omap_udc_enable_clock yet */ | ||
2802 | clk_enable(dc_clk); | ||
2803 | clk_enable(hhc_clk); | ||
2804 | udelay(100); | ||
2805 | } | ||
2806 | |||
2807 | if (cpu_is_omap24xx()) { | ||
2808 | dc_clk = clk_get(&pdev->dev, "usb_fck"); | ||
2809 | hhc_clk = clk_get(&pdev->dev, "usb_l4_ick"); | ||
2810 | BUG_ON(IS_ERR(dc_clk) || IS_ERR(hhc_clk)); | ||
2811 | /* can't use omap_udc_enable_clock yet */ | ||
2812 | clk_enable(dc_clk); | ||
2813 | clk_enable(hhc_clk); | ||
2814 | udelay(100); | ||
2815 | } | ||
2816 | |||
2720 | INFO("OMAP UDC rev %d.%d%s\n", | 2817 | INFO("OMAP UDC rev %d.%d%s\n", |
2721 | UDC_REV_REG >> 4, UDC_REV_REG & 0xf, | 2818 | UDC_REV_REG >> 4, UDC_REV_REG & 0xf, |
2722 | config->otg ? ", Mini-AB" : ""); | 2819 | config->otg ? ", Mini-AB" : ""); |
@@ -2726,7 +2823,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2726 | hmc = HMC_1510; | 2823 | hmc = HMC_1510; |
2727 | type = "(unknown)"; | 2824 | type = "(unknown)"; |
2728 | 2825 | ||
2729 | if (machine_is_omap_innovator()) { | 2826 | if (machine_is_omap_innovator() || machine_is_sx1()) { |
2730 | /* just set up software VBUS detect, and then | 2827 | /* just set up software VBUS detect, and then |
2731 | * later rig it so we always report VBUS. | 2828 | * later rig it so we always report VBUS. |
2732 | * FIXME without really sensing VBUS, we can't | 2829 | * FIXME without really sensing VBUS, we can't |
@@ -2755,6 +2852,15 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2755 | } | 2852 | } |
2756 | 2853 | ||
2757 | hmc = HMC_1610; | 2854 | hmc = HMC_1610; |
2855 | |||
2856 | if (cpu_is_omap24xx()) { | ||
2857 | /* this could be transceiverless in one of the | ||
2858 | * "we don't need to know" modes. | ||
2859 | */ | ||
2860 | type = "external"; | ||
2861 | goto known; | ||
2862 | } | ||
2863 | |||
2758 | switch (hmc) { | 2864 | switch (hmc) { |
2759 | case 0: /* POWERUP DEFAULT == 0 */ | 2865 | case 0: /* POWERUP DEFAULT == 0 */ |
2760 | case 4: | 2866 | case 4: |
@@ -2793,6 +2899,7 @@ bad_on_1710: | |||
2793 | goto cleanup0; | 2899 | goto cleanup0; |
2794 | } | 2900 | } |
2795 | } | 2901 | } |
2902 | known: | ||
2796 | INFO("hmc mode %d, %s transceiver\n", hmc, type); | 2903 | INFO("hmc mode %d, %s transceiver\n", hmc, type); |
2797 | 2904 | ||
2798 | /* a "gadget" abstracts/virtualizes the controller */ | 2905 | /* a "gadget" abstracts/virtualizes the controller */ |
@@ -2817,8 +2924,8 @@ bad_on_1710: | |||
2817 | status = request_irq(pdev->resource[1].start, omap_udc_irq, | 2924 | status = request_irq(pdev->resource[1].start, omap_udc_irq, |
2818 | IRQF_SAMPLE_RANDOM, driver_name, udc); | 2925 | IRQF_SAMPLE_RANDOM, driver_name, udc); |
2819 | if (status != 0) { | 2926 | if (status != 0) { |
2820 | ERR( "can't get irq %ld, err %d\n", | 2927 | ERR("can't get irq %d, err %d\n", |
2821 | pdev->resource[1].start, status); | 2928 | (int) pdev->resource[1].start, status); |
2822 | goto cleanup1; | 2929 | goto cleanup1; |
2823 | } | 2930 | } |
2824 | 2931 | ||
@@ -2826,24 +2933,41 @@ bad_on_1710: | |||
2826 | status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, | 2933 | status = request_irq(pdev->resource[2].start, omap_udc_pio_irq, |
2827 | IRQF_SAMPLE_RANDOM, "omap_udc pio", udc); | 2934 | IRQF_SAMPLE_RANDOM, "omap_udc pio", udc); |
2828 | if (status != 0) { | 2935 | if (status != 0) { |
2829 | ERR( "can't get irq %ld, err %d\n", | 2936 | ERR("can't get irq %d, err %d\n", |
2830 | pdev->resource[2].start, status); | 2937 | (int) pdev->resource[2].start, status); |
2831 | goto cleanup2; | 2938 | goto cleanup2; |
2832 | } | 2939 | } |
2833 | #ifdef USE_ISO | 2940 | #ifdef USE_ISO |
2834 | status = request_irq(pdev->resource[3].start, omap_udc_iso_irq, | 2941 | status = request_irq(pdev->resource[3].start, omap_udc_iso_irq, |
2835 | IRQF_DISABLED, "omap_udc iso", udc); | 2942 | IRQF_DISABLED, "omap_udc iso", udc); |
2836 | if (status != 0) { | 2943 | if (status != 0) { |
2837 | ERR("can't get irq %ld, err %d\n", | 2944 | ERR("can't get irq %d, err %d\n", |
2838 | pdev->resource[3].start, status); | 2945 | (int) pdev->resource[3].start, status); |
2839 | goto cleanup3; | 2946 | goto cleanup3; |
2840 | } | 2947 | } |
2841 | #endif | 2948 | #endif |
2949 | if (cpu_is_omap16xx()) { | ||
2950 | udc->dc_clk = dc_clk; | ||
2951 | udc->hhc_clk = hhc_clk; | ||
2952 | clk_disable(hhc_clk); | ||
2953 | clk_disable(dc_clk); | ||
2954 | } | ||
2955 | |||
2956 | if (cpu_is_omap24xx()) { | ||
2957 | udc->dc_clk = dc_clk; | ||
2958 | udc->hhc_clk = hhc_clk; | ||
2959 | /* FIXME OMAP2 don't release hhc & dc clock */ | ||
2960 | #if 0 | ||
2961 | clk_disable(hhc_clk); | ||
2962 | clk_disable(dc_clk); | ||
2963 | #endif | ||
2964 | } | ||
2842 | 2965 | ||
2843 | create_proc_file(); | 2966 | create_proc_file(); |
2844 | device_add(&udc->gadget.dev); | 2967 | status = device_add(&udc->gadget.dev); |
2845 | return 0; | 2968 | if (!status) |
2846 | 2969 | return status; | |
2970 | /* If fail, fall through */ | ||
2847 | #ifdef USE_ISO | 2971 | #ifdef USE_ISO |
2848 | cleanup3: | 2972 | cleanup3: |
2849 | free_irq(pdev->resource[2].start, udc); | 2973 | free_irq(pdev->resource[2].start, udc); |
@@ -2859,8 +2983,17 @@ cleanup1: | |||
2859 | cleanup0: | 2983 | cleanup0: |
2860 | if (xceiv) | 2984 | if (xceiv) |
2861 | put_device(xceiv->dev); | 2985 | put_device(xceiv->dev); |
2986 | |||
2987 | if (cpu_is_omap16xx() || cpu_is_omap24xx()) { | ||
2988 | clk_disable(hhc_clk); | ||
2989 | clk_disable(dc_clk); | ||
2990 | clk_put(hhc_clk); | ||
2991 | clk_put(dc_clk); | ||
2992 | } | ||
2993 | |||
2862 | release_mem_region(pdev->resource[0].start, | 2994 | release_mem_region(pdev->resource[0].start, |
2863 | pdev->resource[0].end - pdev->resource[0].start + 1); | 2995 | pdev->resource[0].end - pdev->resource[0].start + 1); |
2996 | |||
2864 | return status; | 2997 | return status; |
2865 | } | 2998 | } |
2866 | 2999 | ||
@@ -2870,6 +3003,8 @@ static int __exit omap_udc_remove(struct platform_device *pdev) | |||
2870 | 3003 | ||
2871 | if (!udc) | 3004 | if (!udc) |
2872 | return -ENODEV; | 3005 | return -ENODEV; |
3006 | if (udc->driver) | ||
3007 | return -EBUSY; | ||
2873 | 3008 | ||
2874 | udc->done = &done; | 3009 | udc->done = &done; |
2875 | 3010 | ||
@@ -2888,6 +3023,13 @@ static int __exit omap_udc_remove(struct platform_device *pdev) | |||
2888 | free_irq(pdev->resource[2].start, udc); | 3023 | free_irq(pdev->resource[2].start, udc); |
2889 | free_irq(pdev->resource[1].start, udc); | 3024 | free_irq(pdev->resource[1].start, udc); |
2890 | 3025 | ||
3026 | if (udc->dc_clk) { | ||
3027 | if (udc->clk_requested) | ||
3028 | omap_udc_enable_clock(0); | ||
3029 | clk_put(udc->hhc_clk); | ||
3030 | clk_put(udc->dc_clk); | ||
3031 | } | ||
3032 | |||
2891 | release_mem_region(pdev->resource[0].start, | 3033 | release_mem_region(pdev->resource[0].start, |
2892 | pdev->resource[0].end - pdev->resource[0].start + 1); | 3034 | pdev->resource[0].end - pdev->resource[0].start + 1); |
2893 | 3035 | ||
diff --git a/drivers/usb/gadget/omap_udc.h b/drivers/usb/gadget/omap_udc.h index 652ee4627344..1dc398bb9ab2 100644 --- a/drivers/usb/gadget/omap_udc.h +++ b/drivers/usb/gadget/omap_udc.h | |||
@@ -175,6 +175,9 @@ struct omap_udc { | |||
175 | unsigned ep0_reset_config:1; | 175 | unsigned ep0_reset_config:1; |
176 | unsigned ep0_setup:1; | 176 | unsigned ep0_setup:1; |
177 | struct completion *done; | 177 | struct completion *done; |
178 | struct clk *dc_clk; | ||
179 | struct clk *hhc_clk; | ||
180 | unsigned clk_requested:1; | ||
178 | }; | 181 | }; |
179 | 182 | ||
180 | /*-------------------------------------------------------------------------*/ | 183 | /*-------------------------------------------------------------------------*/ |
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c index 1ed506e95985..0d225369847d 100644 --- a/drivers/usb/gadget/pxa2xx_udc.c +++ b/drivers/usb/gadget/pxa2xx_udc.c | |||
@@ -56,7 +56,7 @@ | |||
56 | #include <asm/arch/pxa-regs.h> | 56 | #include <asm/arch/pxa-regs.h> |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | #include <linux/usb_ch9.h> | 59 | #include <linux/usb/ch9.h> |
60 | #include <linux/usb_gadget.h> | 60 | #include <linux/usb_gadget.h> |
61 | 61 | ||
62 | #include <asm/arch/udc.h> | 62 | #include <asm/arch/udc.h> |
@@ -1623,7 +1623,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) | |||
1623 | if (!driver | 1623 | if (!driver |
1624 | || driver->speed < USB_SPEED_FULL | 1624 | || driver->speed < USB_SPEED_FULL |
1625 | || !driver->bind | 1625 | || !driver->bind |
1626 | || !driver->unbind | ||
1627 | || !driver->disconnect | 1626 | || !driver->disconnect |
1628 | || !driver->setup) | 1627 | || !driver->setup) |
1629 | return -EINVAL; | 1628 | return -EINVAL; |
@@ -1694,7 +1693,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) | |||
1694 | 1693 | ||
1695 | if (!dev) | 1694 | if (!dev) |
1696 | return -ENODEV; | 1695 | return -ENODEV; |
1697 | if (!driver || driver != dev->driver) | 1696 | if (!driver || driver != dev->driver || !driver->unbind) |
1698 | return -EINVAL; | 1697 | return -EINVAL; |
1699 | 1698 | ||
1700 | local_irq_disable(); | 1699 | local_irq_disable(); |
@@ -2638,9 +2637,11 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev) | |||
2638 | { | 2637 | { |
2639 | struct pxa2xx_udc *dev = platform_get_drvdata(pdev); | 2638 | struct pxa2xx_udc *dev = platform_get_drvdata(pdev); |
2640 | 2639 | ||
2640 | if (dev->driver) | ||
2641 | return -EBUSY; | ||
2642 | |||
2641 | udc_disable(dev); | 2643 | udc_disable(dev); |
2642 | remove_proc_files(); | 2644 | remove_proc_files(); |
2643 | usb_gadget_unregister_driver(dev->driver); | ||
2644 | 2645 | ||
2645 | if (dev->got_irq) { | 2646 | if (dev->got_irq) { |
2646 | free_irq(IRQ_USB, dev); | 2647 | free_irq(IRQ_USB, dev); |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 208e55a667ac..6c742a909225 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <asm/unaligned.h> | 43 | #include <asm/unaligned.h> |
44 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
45 | 45 | ||
46 | #include <linux/usb_ch9.h> | 46 | #include <linux/usb/ch9.h> |
47 | #include <linux/usb/cdc.h> | 47 | #include <linux/usb/cdc.h> |
48 | #include <linux/usb_gadget.h> | 48 | #include <linux/usb_gadget.h> |
49 | 49 | ||
@@ -200,7 +200,7 @@ static void gs_unthrottle(struct tty_struct * tty); | |||
200 | static void gs_break(struct tty_struct *tty, int break_state); | 200 | static void gs_break(struct tty_struct *tty, int break_state); |
201 | static int gs_ioctl(struct tty_struct *tty, struct file *file, | 201 | static int gs_ioctl(struct tty_struct *tty, struct file *file, |
202 | unsigned int cmd, unsigned long arg); | 202 | unsigned int cmd, unsigned long arg); |
203 | static void gs_set_termios(struct tty_struct *tty, struct termios *old); | 203 | static void gs_set_termios(struct tty_struct *tty, struct ktermios *old); |
204 | 204 | ||
205 | static int gs_send(struct gs_dev *dev); | 205 | static int gs_send(struct gs_dev *dev); |
206 | static int gs_send_packet(struct gs_dev *dev, char *packet, | 206 | static int gs_send_packet(struct gs_dev *dev, char *packet, |
@@ -296,7 +296,7 @@ static struct usb_gadget_driver gs_gadget_driver = { | |||
296 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ | 296 | #endif /* CONFIG_USB_GADGET_DUALSPEED */ |
297 | .function = GS_LONG_NAME, | 297 | .function = GS_LONG_NAME, |
298 | .bind = gs_bind, | 298 | .bind = gs_bind, |
299 | .unbind = __exit_p(gs_unbind), | 299 | .unbind = gs_unbind, |
300 | .setup = gs_setup, | 300 | .setup = gs_setup, |
301 | .disconnect = gs_disconnect, | 301 | .disconnect = gs_disconnect, |
302 | .driver = { | 302 | .driver = { |
@@ -1077,7 +1077,7 @@ static int gs_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, | |||
1077 | /* | 1077 | /* |
1078 | * gs_set_termios | 1078 | * gs_set_termios |
1079 | */ | 1079 | */ |
1080 | static void gs_set_termios(struct tty_struct *tty, struct termios *old) | 1080 | static void gs_set_termios(struct tty_struct *tty, struct ktermios *old) |
1081 | { | 1081 | { |
1082 | } | 1082 | } |
1083 | 1083 | ||
@@ -2195,7 +2195,7 @@ static struct gs_buf *gs_buf_alloc(unsigned int size, gfp_t kmalloc_flags) | |||
2195 | if (size == 0) | 2195 | if (size == 0) |
2196 | return NULL; | 2196 | return NULL; |
2197 | 2197 | ||
2198 | gb = (struct gs_buf *)kmalloc(sizeof(struct gs_buf), kmalloc_flags); | 2198 | gb = kmalloc(sizeof(struct gs_buf), kmalloc_flags); |
2199 | if (gb == NULL) | 2199 | if (gb == NULL) |
2200 | return NULL; | 2200 | return NULL; |
2201 | 2201 | ||
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index b1735767660b..3459ea6c6c0b 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | 16 | ||
17 | #include <linux/usb_ch9.h> | 17 | #include <linux/usb/ch9.h> |
18 | #include <linux/usb_gadget.h> | 18 | #include <linux/usb_gadget.h> |
19 | 19 | ||
20 | #include <asm/unaligned.h> | 20 | #include <asm/unaligned.h> |
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 40710ea1b490..ebe04e0d2879 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c | |||
@@ -84,7 +84,7 @@ | |||
84 | #include <asm/system.h> | 84 | #include <asm/system.h> |
85 | #include <asm/unaligned.h> | 85 | #include <asm/unaligned.h> |
86 | 86 | ||
87 | #include <linux/usb_ch9.h> | 87 | #include <linux/usb/ch9.h> |
88 | #include <linux/usb_gadget.h> | 88 | #include <linux/usb_gadget.h> |
89 | 89 | ||
90 | #include "gadget_chips.h" | 90 | #include "gadget_chips.h" |