diff options
Diffstat (limited to 'drivers/usb/gadget/ci13xxx_udc.c')
-rw-r--r-- | drivers/usb/gadget/ci13xxx_udc.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 9a0c3979ff43..27e313718422 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c | |||
@@ -182,6 +182,16 @@ static inline int hw_ep_bit(int num, int dir) | |||
182 | return num + (dir ? 16 : 0); | 182 | return num + (dir ? 16 : 0); |
183 | } | 183 | } |
184 | 184 | ||
185 | static int ep_to_bit(int n) | ||
186 | { | ||
187 | int fill = 16 - hw_ep_max / 2; | ||
188 | |||
189 | if (n >= hw_ep_max / 2) | ||
190 | n += fill; | ||
191 | |||
192 | return n; | ||
193 | } | ||
194 | |||
185 | /** | 195 | /** |
186 | * hw_aread: reads from register bitfield | 196 | * hw_aread: reads from register bitfield |
187 | * @addr: address relative to bus map | 197 | * @addr: address relative to bus map |
@@ -440,12 +450,13 @@ static int hw_ep_get_halt(int num, int dir) | |||
440 | /** | 450 | /** |
441 | * hw_test_and_clear_setup_status: test & clear setup status (execute without | 451 | * hw_test_and_clear_setup_status: test & clear setup status (execute without |
442 | * interruption) | 452 | * interruption) |
443 | * @n: bit number (endpoint) | 453 | * @n: endpoint number |
444 | * | 454 | * |
445 | * This function returns setup status | 455 | * This function returns setup status |
446 | */ | 456 | */ |
447 | static int hw_test_and_clear_setup_status(int n) | 457 | static int hw_test_and_clear_setup_status(int n) |
448 | { | 458 | { |
459 | n = ep_to_bit(n); | ||
449 | return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n)); | 460 | return hw_ctest_and_clear(CAP_ENDPTSETUPSTAT, BIT(n)); |
450 | } | 461 | } |
451 | 462 | ||
@@ -641,12 +652,13 @@ static int hw_register_write(u16 addr, u32 data) | |||
641 | /** | 652 | /** |
642 | * hw_test_and_clear_complete: test & clear complete status (execute without | 653 | * hw_test_and_clear_complete: test & clear complete status (execute without |
643 | * interruption) | 654 | * interruption) |
644 | * @n: bit number (endpoint) | 655 | * @n: endpoint number |
645 | * | 656 | * |
646 | * This function returns complete status | 657 | * This function returns complete status |
647 | */ | 658 | */ |
648 | static int hw_test_and_clear_complete(int n) | 659 | static int hw_test_and_clear_complete(int n) |
649 | { | 660 | { |
661 | n = ep_to_bit(n); | ||
650 | return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n)); | 662 | return hw_ctest_and_clear(CAP_ENDPTCOMPLETE, BIT(n)); |
651 | } | 663 | } |
652 | 664 | ||
@@ -754,8 +766,11 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr, | |||
754 | 766 | ||
755 | n += scnprintf(buf + n, PAGE_SIZE - n, "speed = %d\n", | 767 | n += scnprintf(buf + n, PAGE_SIZE - n, "speed = %d\n", |
756 | gadget->speed); | 768 | gadget->speed); |
769 | n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n", | ||
770 | gadget->max_speed); | ||
771 | /* TODO: Scheduled for removal in 3.8. */ | ||
757 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n", | 772 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n", |
758 | gadget->is_dualspeed); | 773 | gadget_is_dualspeed(gadget)); |
759 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", | 774 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", |
760 | gadget->is_otg); | 775 | gadget->is_otg); |
761 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", | 776 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", |
@@ -798,7 +813,7 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr, | |||
798 | n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n", | 813 | n += scnprintf(buf + n, PAGE_SIZE - n, "function = %s\n", |
799 | (driver->function ? driver->function : "")); | 814 | (driver->function ? driver->function : "")); |
800 | n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n", | 815 | n += scnprintf(buf + n, PAGE_SIZE - n, "max speed = %d\n", |
801 | driver->speed); | 816 | driver->max_speed); |
802 | 817 | ||
803 | return n; | 818 | return n; |
804 | } | 819 | } |
@@ -2563,9 +2578,7 @@ static int ci13xxx_start(struct usb_gadget_driver *driver, | |||
2563 | if (driver == NULL || | 2578 | if (driver == NULL || |
2564 | bind == NULL || | 2579 | bind == NULL || |
2565 | driver->setup == NULL || | 2580 | driver->setup == NULL || |
2566 | driver->disconnect == NULL || | 2581 | driver->disconnect == NULL) |
2567 | driver->suspend == NULL || | ||
2568 | driver->resume == NULL) | ||
2569 | return -EINVAL; | 2582 | return -EINVAL; |
2570 | else if (udc == NULL) | 2583 | else if (udc == NULL) |
2571 | return -ENODEV; | 2584 | return -ENODEV; |
@@ -2693,8 +2706,6 @@ static int ci13xxx_stop(struct usb_gadget_driver *driver) | |||
2693 | driver->unbind == NULL || | 2706 | driver->unbind == NULL || |
2694 | driver->setup == NULL || | 2707 | driver->setup == NULL || |
2695 | driver->disconnect == NULL || | 2708 | driver->disconnect == NULL || |
2696 | driver->suspend == NULL || | ||
2697 | driver->resume == NULL || | ||
2698 | driver != udc->driver) | 2709 | driver != udc->driver) |
2699 | return -EINVAL; | 2710 | return -EINVAL; |
2700 | 2711 | ||
@@ -2793,7 +2804,7 @@ static irqreturn_t udc_irq(void) | |||
2793 | isr_statistics.pci++; | 2804 | isr_statistics.pci++; |
2794 | udc->gadget.speed = hw_port_is_high_speed() ? | 2805 | udc->gadget.speed = hw_port_is_high_speed() ? |
2795 | USB_SPEED_HIGH : USB_SPEED_FULL; | 2806 | USB_SPEED_HIGH : USB_SPEED_FULL; |
2796 | if (udc->suspended) { | 2807 | if (udc->suspended && udc->driver->resume) { |
2797 | spin_unlock(udc->lock); | 2808 | spin_unlock(udc->lock); |
2798 | udc->driver->resume(&udc->gadget); | 2809 | udc->driver->resume(&udc->gadget); |
2799 | spin_lock(udc->lock); | 2810 | spin_lock(udc->lock); |
@@ -2807,7 +2818,8 @@ static irqreturn_t udc_irq(void) | |||
2807 | isr_tr_complete_handler(udc); | 2818 | isr_tr_complete_handler(udc); |
2808 | } | 2819 | } |
2809 | if (USBi_SLI & intr) { | 2820 | if (USBi_SLI & intr) { |
2810 | if (udc->gadget.speed != USB_SPEED_UNKNOWN) { | 2821 | if (udc->gadget.speed != USB_SPEED_UNKNOWN && |
2822 | udc->driver->suspend) { | ||
2811 | udc->suspended = 1; | 2823 | udc->suspended = 1; |
2812 | spin_unlock(udc->lock); | 2824 | spin_unlock(udc->lock); |
2813 | udc->driver->suspend(&udc->gadget); | 2825 | udc->driver->suspend(&udc->gadget); |
@@ -2871,7 +2883,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2871 | 2883 | ||
2872 | udc->gadget.ops = &usb_gadget_ops; | 2884 | udc->gadget.ops = &usb_gadget_ops; |
2873 | udc->gadget.speed = USB_SPEED_UNKNOWN; | 2885 | udc->gadget.speed = USB_SPEED_UNKNOWN; |
2874 | udc->gadget.is_dualspeed = 1; | 2886 | udc->gadget.max_speed = USB_SPEED_HIGH; |
2875 | udc->gadget.is_otg = 0; | 2887 | udc->gadget.is_otg = 0; |
2876 | udc->gadget.name = driver->name; | 2888 | udc->gadget.name = driver->name; |
2877 | 2889 | ||