diff options
Diffstat (limited to 'drivers/usb')
180 files changed, 2280 insertions, 9226 deletions
diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig index 1ea932a13685..608a2aeb400c 100644 --- a/drivers/usb/chipidea/Kconfig +++ b/drivers/usb/chipidea/Kconfig | |||
@@ -20,6 +20,7 @@ config USB_CHIPIDEA_UDC | |||
20 | config USB_CHIPIDEA_HOST | 20 | config USB_CHIPIDEA_HOST |
21 | bool "ChipIdea host controller" | 21 | bool "ChipIdea host controller" |
22 | depends on USB=y || USB=USB_CHIPIDEA | 22 | depends on USB=y || USB=USB_CHIPIDEA |
23 | depends on USB_EHCI_HCD | ||
23 | select USB_EHCI_ROOT_HUB_TT | 24 | select USB_EHCI_ROOT_HUB_TT |
24 | help | 25 | help |
25 | Say Y here to enable host controller functionality of the | 26 | Say Y here to enable host controller functionality of the |
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index c6f50a257565..3bc244d2636a 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c | |||
@@ -160,9 +160,6 @@ static ssize_t show_device(struct device *dev, struct device_attribute *attr, | |||
160 | gadget->speed); | 160 | gadget->speed); |
161 | n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n", | 161 | n += scnprintf(buf + n, PAGE_SIZE - n, "max_speed = %d\n", |
162 | gadget->max_speed); | 162 | gadget->max_speed); |
163 | /* TODO: Scheduled for removal in 3.8. */ | ||
164 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_dualspeed = %d\n", | ||
165 | gadget_is_dualspeed(gadget)); | ||
166 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", | 163 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_otg = %d\n", |
167 | gadget->is_otg); | 164 | gadget->is_otg); |
168 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", | 165 | n += scnprintf(buf + n, PAGE_SIZE - n, "is_a_peripheral = %d\n", |
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index ebff9f4f56ec..caecad9213f5 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c | |||
@@ -20,77 +20,18 @@ | |||
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/io.h> | ||
23 | #include <linux/usb.h> | 24 | #include <linux/usb.h> |
24 | #include <linux/usb/hcd.h> | 25 | #include <linux/usb/hcd.h> |
25 | #include <linux/usb/chipidea.h> | 26 | #include <linux/usb/chipidea.h> |
26 | 27 | ||
27 | #define CHIPIDEA_EHCI | 28 | #include "../host/ehci.h" |
28 | #include "../host/ehci-hcd.c" | ||
29 | 29 | ||
30 | #include "ci.h" | 30 | #include "ci.h" |
31 | #include "bits.h" | 31 | #include "bits.h" |
32 | #include "host.h" | 32 | #include "host.h" |
33 | 33 | ||
34 | static int ci_ehci_setup(struct usb_hcd *hcd) | 34 | static struct hc_driver __read_mostly ci_ehci_hc_driver; |
35 | { | ||
36 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
37 | int ret; | ||
38 | |||
39 | hcd->has_tt = 1; | ||
40 | |||
41 | ret = ehci_setup(hcd); | ||
42 | if (ret) | ||
43 | return ret; | ||
44 | |||
45 | ehci_port_power(ehci, 0); | ||
46 | |||
47 | return ret; | ||
48 | } | ||
49 | |||
50 | static const struct hc_driver ci_ehci_hc_driver = { | ||
51 | .description = "ehci_hcd", | ||
52 | .product_desc = "ChipIdea HDRC EHCI", | ||
53 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
54 | |||
55 | /* | ||
56 | * generic hardware linkage | ||
57 | */ | ||
58 | .irq = ehci_irq, | ||
59 | .flags = HCD_MEMORY | HCD_USB2, | ||
60 | |||
61 | /* | ||
62 | * basic lifecycle operations | ||
63 | */ | ||
64 | .reset = ci_ehci_setup, | ||
65 | .start = ehci_run, | ||
66 | .stop = ehci_stop, | ||
67 | .shutdown = ehci_shutdown, | ||
68 | |||
69 | /* | ||
70 | * managing i/o requests and associated device resources | ||
71 | */ | ||
72 | .urb_enqueue = ehci_urb_enqueue, | ||
73 | .urb_dequeue = ehci_urb_dequeue, | ||
74 | .endpoint_disable = ehci_endpoint_disable, | ||
75 | .endpoint_reset = ehci_endpoint_reset, | ||
76 | |||
77 | /* | ||
78 | * scheduling support | ||
79 | */ | ||
80 | .get_frame_number = ehci_get_frame, | ||
81 | |||
82 | /* | ||
83 | * root hub support | ||
84 | */ | ||
85 | .hub_status_data = ehci_hub_status_data, | ||
86 | .hub_control = ehci_hub_control, | ||
87 | .bus_suspend = ehci_bus_suspend, | ||
88 | .bus_resume = ehci_bus_resume, | ||
89 | .relinquish_port = ehci_relinquish_port, | ||
90 | .port_handed_over = ehci_port_handed_over, | ||
91 | |||
92 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
93 | }; | ||
94 | 35 | ||
95 | static irqreturn_t host_irq(struct ci13xxx *ci) | 36 | static irqreturn_t host_irq(struct ci13xxx *ci) |
96 | { | 37 | { |
@@ -157,5 +98,7 @@ int ci_hdrc_host_init(struct ci13xxx *ci) | |||
157 | rdrv->name = "host"; | 98 | rdrv->name = "host"; |
158 | ci->roles[CI_ROLE_HOST] = rdrv; | 99 | ci->roles[CI_ROLE_HOST] = rdrv; |
159 | 100 | ||
101 | ehci_init_driver(&ci_ehci_hc_driver, NULL); | ||
102 | |||
160 | return 0; | 103 | return 0; |
161 | } | 104 | } |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 6e49ec6f3adc..8d809a811e16 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -787,6 +787,10 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info) | |||
787 | tmp.flags = ASYNC_LOW_LATENCY; | 787 | tmp.flags = ASYNC_LOW_LATENCY; |
788 | tmp.xmit_fifo_size = acm->writesize; | 788 | tmp.xmit_fifo_size = acm->writesize; |
789 | tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); | 789 | tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); |
790 | tmp.close_delay = acm->port.close_delay / 10; | ||
791 | tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ? | ||
792 | ASYNC_CLOSING_WAIT_NONE : | ||
793 | acm->port.closing_wait / 10; | ||
790 | 794 | ||
791 | if (copy_to_user(info, &tmp, sizeof(tmp))) | 795 | if (copy_to_user(info, &tmp, sizeof(tmp))) |
792 | return -EFAULT; | 796 | return -EFAULT; |
@@ -794,6 +798,37 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info) | |||
794 | return 0; | 798 | return 0; |
795 | } | 799 | } |
796 | 800 | ||
801 | static int set_serial_info(struct acm *acm, | ||
802 | struct serial_struct __user *newinfo) | ||
803 | { | ||
804 | struct serial_struct new_serial; | ||
805 | unsigned int closing_wait, close_delay; | ||
806 | int retval = 0; | ||
807 | |||
808 | if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) | ||
809 | return -EFAULT; | ||
810 | |||
811 | close_delay = new_serial.close_delay * 10; | ||
812 | closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ? | ||
813 | ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10; | ||
814 | |||
815 | mutex_lock(&acm->port.mutex); | ||
816 | |||
817 | if (!capable(CAP_SYS_ADMIN)) { | ||
818 | if ((close_delay != acm->port.close_delay) || | ||
819 | (closing_wait != acm->port.closing_wait)) | ||
820 | retval = -EPERM; | ||
821 | else | ||
822 | retval = -EOPNOTSUPP; | ||
823 | } else { | ||
824 | acm->port.close_delay = close_delay; | ||
825 | acm->port.closing_wait = closing_wait; | ||
826 | } | ||
827 | |||
828 | mutex_unlock(&acm->port.mutex); | ||
829 | return retval; | ||
830 | } | ||
831 | |||
797 | static int acm_tty_ioctl(struct tty_struct *tty, | 832 | static int acm_tty_ioctl(struct tty_struct *tty, |
798 | unsigned int cmd, unsigned long arg) | 833 | unsigned int cmd, unsigned long arg) |
799 | { | 834 | { |
@@ -804,6 +839,9 @@ static int acm_tty_ioctl(struct tty_struct *tty, | |||
804 | case TIOCGSERIAL: /* gets serial port data */ | 839 | case TIOCGSERIAL: /* gets serial port data */ |
805 | rv = get_serial_info(acm, (struct serial_struct __user *) arg); | 840 | rv = get_serial_info(acm, (struct serial_struct __user *) arg); |
806 | break; | 841 | break; |
842 | case TIOCSSERIAL: | ||
843 | rv = set_serial_info(acm, (struct serial_struct __user *) arg); | ||
844 | break; | ||
807 | } | 845 | } |
808 | 846 | ||
809 | return rv; | 847 | return rv; |
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index f460de31acee..cbacea933b18 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
@@ -591,16 +591,14 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, | |||
591 | 591 | ||
592 | /* Now look at all of this device's children. */ | 592 | /* Now look at all of this device's children. */ |
593 | usb_hub_for_each_child(usbdev, chix, childdev) { | 593 | usb_hub_for_each_child(usbdev, chix, childdev) { |
594 | if (childdev) { | 594 | usb_lock_device(childdev); |
595 | usb_lock_device(childdev); | 595 | ret = usb_device_dump(buffer, nbytes, skip_bytes, |
596 | ret = usb_device_dump(buffer, nbytes, skip_bytes, | 596 | file_offset, childdev, bus, |
597 | file_offset, childdev, bus, | 597 | level + 1, chix - 1, ++cnt); |
598 | level + 1, chix - 1, ++cnt); | 598 | usb_unlock_device(childdev); |
599 | usb_unlock_device(childdev); | 599 | if (ret == -EFAULT) |
600 | if (ret == -EFAULT) | 600 | return total_written; |
601 | return total_written; | 601 | total_written += ret; |
602 | total_written += ret; | ||
603 | } | ||
604 | } | 602 | } |
605 | return total_written; | 603 | return total_written; |
606 | } | 604 | } |
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index 69ecd3c92311..eff2010eb63f 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c | |||
@@ -47,6 +47,9 @@ int usb_choose_configuration(struct usb_device *udev) | |||
47 | int insufficient_power = 0; | 47 | int insufficient_power = 0; |
48 | struct usb_host_config *c, *best; | 48 | struct usb_host_config *c, *best; |
49 | 49 | ||
50 | if (usb_device_is_owned(udev)) | ||
51 | return 0; | ||
52 | |||
50 | best = NULL; | 53 | best = NULL; |
51 | c = udev->config; | 54 | c = udev->config; |
52 | num_configs = udev->descriptor.bNumConfigurations; | 55 | num_configs = udev->descriptor.bNumConfigurations; |
@@ -160,9 +163,7 @@ static int generic_probe(struct usb_device *udev) | |||
160 | /* Choose and set the configuration. This registers the interfaces | 163 | /* Choose and set the configuration. This registers the interfaces |
161 | * with the driver core and lets interface drivers bind to them. | 164 | * with the driver core and lets interface drivers bind to them. |
162 | */ | 165 | */ |
163 | if (usb_device_is_owned(udev)) | 166 | if (udev->authorized == 0) |
164 | ; /* Don't configure if the device is owned */ | ||
165 | else if (udev->authorized == 0) | ||
166 | dev_err(&udev->dev, "Device is not authorized for usage\n"); | 167 | dev_err(&udev->dev, "Device is not authorized for usage\n"); |
167 | else { | 168 | else { |
168 | c = usb_choose_configuration(udev); | 169 | c = usb_choose_configuration(udev); |
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index f034716190ff..4225d5e72131 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -2039,8 +2039,9 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) | |||
2039 | status = hcd->driver->bus_resume(hcd); | 2039 | status = hcd->driver->bus_resume(hcd); |
2040 | clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); | 2040 | clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); |
2041 | if (status == 0) { | 2041 | if (status == 0) { |
2042 | /* TRSMRCY = 10 msec */ | 2042 | struct usb_device *udev; |
2043 | msleep(10); | 2043 | int port1; |
2044 | |||
2044 | spin_lock_irq(&hcd_root_hub_lock); | 2045 | spin_lock_irq(&hcd_root_hub_lock); |
2045 | if (!HCD_DEAD(hcd)) { | 2046 | if (!HCD_DEAD(hcd)) { |
2046 | usb_set_device_state(rhdev, rhdev->actconfig | 2047 | usb_set_device_state(rhdev, rhdev->actconfig |
@@ -2050,6 +2051,20 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) | |||
2050 | hcd->state = HC_STATE_RUNNING; | 2051 | hcd->state = HC_STATE_RUNNING; |
2051 | } | 2052 | } |
2052 | spin_unlock_irq(&hcd_root_hub_lock); | 2053 | spin_unlock_irq(&hcd_root_hub_lock); |
2054 | |||
2055 | /* | ||
2056 | * Check whether any of the enabled ports on the root hub are | ||
2057 | * unsuspended. If they are then a TRSMRCY delay is needed | ||
2058 | * (this is what the USB-2 spec calls a "global resume"). | ||
2059 | * Otherwise we can skip the delay. | ||
2060 | */ | ||
2061 | usb_hub_for_each_child(rhdev, port1, udev) { | ||
2062 | if (udev->state != USB_STATE_NOTATTACHED && | ||
2063 | !udev->port_is_suspended) { | ||
2064 | usleep_range(10000, 11000); /* TRSMRCY */ | ||
2065 | break; | ||
2066 | } | ||
2067 | } | ||
2053 | } else { | 2068 | } else { |
2054 | hcd->state = old_state; | 2069 | hcd->state = old_state; |
2055 | dev_dbg(&rhdev->dev, "bus %s fail, err %d\n", | 2070 | dev_dbg(&rhdev->dev, "bus %s fail, err %d\n", |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 1af04bdeaf0c..a815fd2cc5e7 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -39,6 +39,9 @@ | |||
39 | #endif | 39 | #endif |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #define USB_VENDOR_GENESYS_LOGIC 0x05e3 | ||
43 | #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 | ||
44 | |||
42 | struct usb_port { | 45 | struct usb_port { |
43 | struct usb_device *child; | 46 | struct usb_device *child; |
44 | struct device dev; | 47 | struct device dev; |
@@ -86,6 +89,8 @@ struct usb_hub { | |||
86 | unsigned quiescing:1; | 89 | unsigned quiescing:1; |
87 | unsigned disconnected:1; | 90 | unsigned disconnected:1; |
88 | 91 | ||
92 | unsigned quirk_check_port_auto_suspend:1; | ||
93 | |||
89 | unsigned has_indicators:1; | 94 | unsigned has_indicators:1; |
90 | u8 indicator[USB_MAXCHILDREN]; | 95 | u8 indicator[USB_MAXCHILDREN]; |
91 | struct delayed_work leds; | 96 | struct delayed_work leds; |
@@ -736,7 +741,6 @@ static void hub_tt_work(struct work_struct *work) | |||
736 | struct usb_hub *hub = | 741 | struct usb_hub *hub = |
737 | container_of(work, struct usb_hub, tt.clear_work); | 742 | container_of(work, struct usb_hub, tt.clear_work); |
738 | unsigned long flags; | 743 | unsigned long flags; |
739 | int limit = 100; | ||
740 | 744 | ||
741 | spin_lock_irqsave (&hub->tt.lock, flags); | 745 | spin_lock_irqsave (&hub->tt.lock, flags); |
742 | while (!list_empty(&hub->tt.clear_list)) { | 746 | while (!list_empty(&hub->tt.clear_list)) { |
@@ -746,9 +750,6 @@ static void hub_tt_work(struct work_struct *work) | |||
746 | const struct hc_driver *drv; | 750 | const struct hc_driver *drv; |
747 | int status; | 751 | int status; |
748 | 752 | ||
749 | if (!hub->quiescing && --limit < 0) | ||
750 | break; | ||
751 | |||
752 | next = hub->tt.clear_list.next; | 753 | next = hub->tt.clear_list.next; |
753 | clear = list_entry (next, struct usb_tt_clear, clear_list); | 754 | clear = list_entry (next, struct usb_tt_clear, clear_list); |
754 | list_del (&clear->clear_list); | 755 | list_del (&clear->clear_list); |
@@ -1612,6 +1613,41 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1612 | desc = intf->cur_altsetting; | 1613 | desc = intf->cur_altsetting; |
1613 | hdev = interface_to_usbdev(intf); | 1614 | hdev = interface_to_usbdev(intf); |
1614 | 1615 | ||
1616 | /* | ||
1617 | * Set default autosuspend delay as 0 to speedup bus suspend, | ||
1618 | * based on the below considerations: | ||
1619 | * | ||
1620 | * - Unlike other drivers, the hub driver does not rely on the | ||
1621 | * autosuspend delay to provide enough time to handle a wakeup | ||
1622 | * event, and the submitted status URB is just to check future | ||
1623 | * change on hub downstream ports, so it is safe to do it. | ||
1624 | * | ||
1625 | * - The patch might cause one or more auto supend/resume for | ||
1626 | * below very rare devices when they are plugged into hub | ||
1627 | * first time: | ||
1628 | * | ||
1629 | * devices having trouble initializing, and disconnect | ||
1630 | * themselves from the bus and then reconnect a second | ||
1631 | * or so later | ||
1632 | * | ||
1633 | * devices just for downloading firmware, and disconnects | ||
1634 | * themselves after completing it | ||
1635 | * | ||
1636 | * For these quite rare devices, their drivers may change the | ||
1637 | * autosuspend delay of their parent hub in the probe() to one | ||
1638 | * appropriate value to avoid the subtle problem if someone | ||
1639 | * does care it. | ||
1640 | * | ||
1641 | * - The patch may cause one or more auto suspend/resume on | ||
1642 | * hub during running 'lsusb', but it is probably too | ||
1643 | * infrequent to worry about. | ||
1644 | * | ||
1645 | * - Change autosuspend delay of hub can avoid unnecessary auto | ||
1646 | * suspend timer for hub, also may decrease power consumption | ||
1647 | * of USB bus. | ||
1648 | */ | ||
1649 | pm_runtime_set_autosuspend_delay(&hdev->dev, 0); | ||
1650 | |||
1615 | /* Hubs have proper suspend/resume support. */ | 1651 | /* Hubs have proper suspend/resume support. */ |
1616 | usb_enable_autosuspend(hdev); | 1652 | usb_enable_autosuspend(hdev); |
1617 | 1653 | ||
@@ -1670,6 +1706,9 @@ descriptor_error: | |||
1670 | if (hdev->speed == USB_SPEED_HIGH) | 1706 | if (hdev->speed == USB_SPEED_HIGH) |
1671 | highspeed_hubs++; | 1707 | highspeed_hubs++; |
1672 | 1708 | ||
1709 | if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND) | ||
1710 | hub->quirk_check_port_auto_suspend = 1; | ||
1711 | |||
1673 | if (hub_configure(hub, endpoint) >= 0) | 1712 | if (hub_configure(hub, endpoint) >= 0) |
1674 | return 0; | 1713 | return 0; |
1675 | 1714 | ||
@@ -2012,7 +2051,7 @@ static void show_string(struct usb_device *udev, char *id, char *string) | |||
2012 | { | 2051 | { |
2013 | if (!string) | 2052 | if (!string) |
2014 | return; | 2053 | return; |
2015 | dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); | 2054 | dev_info(&udev->dev, "%s: %s\n", id, string); |
2016 | } | 2055 | } |
2017 | 2056 | ||
2018 | static void announce_device(struct usb_device *udev) | 2057 | static void announce_device(struct usb_device *udev) |
@@ -2879,6 +2918,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) | |||
2879 | (PMSG_IS_AUTO(msg) ? "auto-" : ""), | 2918 | (PMSG_IS_AUTO(msg) ? "auto-" : ""), |
2880 | udev->do_remote_wakeup); | 2919 | udev->do_remote_wakeup); |
2881 | usb_set_device_state(udev, USB_STATE_SUSPENDED); | 2920 | usb_set_device_state(udev, USB_STATE_SUSPENDED); |
2921 | udev->port_is_suspended = 1; | ||
2882 | msleep(10); | 2922 | msleep(10); |
2883 | } | 2923 | } |
2884 | usb_mark_last_busy(hub->hdev); | 2924 | usb_mark_last_busy(hub->hdev); |
@@ -3043,6 +3083,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) | |||
3043 | 3083 | ||
3044 | SuspendCleared: | 3084 | SuspendCleared: |
3045 | if (status == 0) { | 3085 | if (status == 0) { |
3086 | udev->port_is_suspended = 0; | ||
3046 | if (hub_is_superspeed(hub->hdev)) { | 3087 | if (hub_is_superspeed(hub->hdev)) { |
3047 | if (portchange & USB_PORT_STAT_C_LINK_STATE) | 3088 | if (portchange & USB_PORT_STAT_C_LINK_STATE) |
3048 | clear_port_feature(hub->hdev, port1, | 3089 | clear_port_feature(hub->hdev, port1, |
@@ -3126,6 +3167,21 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) | |||
3126 | 3167 | ||
3127 | #endif | 3168 | #endif |
3128 | 3169 | ||
3170 | static int check_ports_changed(struct usb_hub *hub) | ||
3171 | { | ||
3172 | int port1; | ||
3173 | |||
3174 | for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { | ||
3175 | u16 portstatus, portchange; | ||
3176 | int status; | ||
3177 | |||
3178 | status = hub_port_status(hub, port1, &portstatus, &portchange); | ||
3179 | if (!status && portchange) | ||
3180 | return 1; | ||
3181 | } | ||
3182 | return 0; | ||
3183 | } | ||
3184 | |||
3129 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | 3185 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) |
3130 | { | 3186 | { |
3131 | struct usb_hub *hub = usb_get_intfdata (intf); | 3187 | struct usb_hub *hub = usb_get_intfdata (intf); |
@@ -3144,6 +3200,16 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
3144 | return -EBUSY; | 3200 | return -EBUSY; |
3145 | } | 3201 | } |
3146 | } | 3202 | } |
3203 | |||
3204 | if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { | ||
3205 | /* check if there are changes pending on hub ports */ | ||
3206 | if (check_ports_changed(hub)) { | ||
3207 | if (PMSG_IS_AUTO(msg)) | ||
3208 | return -EBUSY; | ||
3209 | pm_wakeup_event(&hdev->dev, 2000); | ||
3210 | } | ||
3211 | } | ||
3212 | |||
3147 | if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { | 3213 | if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { |
3148 | /* Enable hub to send remote wakeup for all ports. */ | 3214 | /* Enable hub to send remote wakeup for all ports. */ |
3149 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 3215 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
@@ -3972,6 +4038,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
3972 | if (retval) | 4038 | if (retval) |
3973 | goto fail; | 4039 | goto fail; |
3974 | 4040 | ||
4041 | if (hcd->phy && !hdev->parent) | ||
4042 | usb_phy_notify_connect(hcd->phy, udev->speed); | ||
4043 | |||
3975 | /* | 4044 | /* |
3976 | * Some superspeed devices have finished the link training process | 4045 | * Some superspeed devices have finished the link training process |
3977 | * and attached to a superspeed hub port, but the device descriptor | 4046 | * and attached to a superspeed hub port, but the device descriptor |
@@ -4166,8 +4235,12 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
4166 | } | 4235 | } |
4167 | 4236 | ||
4168 | /* Disconnect any existing devices under this port */ | 4237 | /* Disconnect any existing devices under this port */ |
4169 | if (udev) | 4238 | if (udev) { |
4239 | if (hcd->phy && !hdev->parent && | ||
4240 | !(portstatus & USB_PORT_STAT_CONNECTION)) | ||
4241 | usb_phy_notify_disconnect(hcd->phy, udev->speed); | ||
4170 | usb_disconnect(&hub->ports[port1 - 1]->child); | 4242 | usb_disconnect(&hub->ports[port1 - 1]->child); |
4243 | } | ||
4171 | clear_bit(port1, hub->change_bits); | 4244 | clear_bit(port1, hub->change_bits); |
4172 | 4245 | ||
4173 | /* We can forget about a "removed" device when there's a physical | 4246 | /* We can forget about a "removed" device when there's a physical |
@@ -4190,13 +4263,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
4190 | } | 4263 | } |
4191 | } | 4264 | } |
4192 | 4265 | ||
4193 | if (hcd->phy && !hdev->parent) { | ||
4194 | if (portstatus & USB_PORT_STAT_CONNECTION) | ||
4195 | usb_phy_notify_connect(hcd->phy, port1); | ||
4196 | else | ||
4197 | usb_phy_notify_disconnect(hcd->phy, port1); | ||
4198 | } | ||
4199 | |||
4200 | /* Return now if debouncing failed or nothing is connected or | 4266 | /* Return now if debouncing failed or nothing is connected or |
4201 | * the device was "removed". | 4267 | * the device was "removed". |
4202 | */ | 4268 | */ |
@@ -4648,6 +4714,11 @@ static int hub_thread(void *__unused) | |||
4648 | } | 4714 | } |
4649 | 4715 | ||
4650 | static const struct usb_device_id hub_id_table[] = { | 4716 | static const struct usb_device_id hub_id_table[] = { |
4717 | { .match_flags = USB_DEVICE_ID_MATCH_VENDOR | ||
4718 | | USB_DEVICE_ID_MATCH_INT_CLASS, | ||
4719 | .idVendor = USB_VENDOR_GENESYS_LOGIC, | ||
4720 | .bInterfaceClass = USB_CLASS_HUB, | ||
4721 | .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND}, | ||
4651 | { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, | 4722 | { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, |
4652 | .bDeviceClass = USB_CLASS_HUB}, | 4723 | .bDeviceClass = USB_CLASS_HUB}, |
4653 | { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, | 4724 | { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 1ed5afd91e6d..a557658f3223 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -1806,29 +1806,8 @@ free_interfaces: | |||
1806 | goto free_interfaces; | 1806 | goto free_interfaces; |
1807 | } | 1807 | } |
1808 | 1808 | ||
1809 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 1809 | /* |
1810 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | 1810 | * Initialize the new interface structures and the |
1811 | NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
1812 | if (ret < 0) { | ||
1813 | /* All the old state is gone, so what else can we do? | ||
1814 | * The device is probably useless now anyway. | ||
1815 | */ | ||
1816 | cp = NULL; | ||
1817 | } | ||
1818 | |||
1819 | dev->actconfig = cp; | ||
1820 | if (!cp) { | ||
1821 | usb_set_device_state(dev, USB_STATE_ADDRESS); | ||
1822 | usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); | ||
1823 | /* Leave LPM disabled while the device is unconfigured. */ | ||
1824 | mutex_unlock(hcd->bandwidth_mutex); | ||
1825 | usb_autosuspend_device(dev); | ||
1826 | goto free_interfaces; | ||
1827 | } | ||
1828 | mutex_unlock(hcd->bandwidth_mutex); | ||
1829 | usb_set_device_state(dev, USB_STATE_CONFIGURED); | ||
1830 | |||
1831 | /* Initialize the new interface structures and the | ||
1832 | * hc/hcd/usbcore interface/endpoint state. | 1811 | * hc/hcd/usbcore interface/endpoint state. |
1833 | */ | 1812 | */ |
1834 | for (i = 0; i < nintf; ++i) { | 1813 | for (i = 0; i < nintf; ++i) { |
@@ -1872,6 +1851,35 @@ free_interfaces: | |||
1872 | } | 1851 | } |
1873 | kfree(new_interfaces); | 1852 | kfree(new_interfaces); |
1874 | 1853 | ||
1854 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
1855 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
1856 | NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
1857 | if (ret < 0 && cp) { | ||
1858 | /* | ||
1859 | * All the old state is gone, so what else can we do? | ||
1860 | * The device is probably useless now anyway. | ||
1861 | */ | ||
1862 | usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); | ||
1863 | for (i = 0; i < nintf; ++i) { | ||
1864 | usb_disable_interface(dev, cp->interface[i], true); | ||
1865 | put_device(&cp->interface[i]->dev); | ||
1866 | cp->interface[i] = NULL; | ||
1867 | } | ||
1868 | cp = NULL; | ||
1869 | } | ||
1870 | |||
1871 | dev->actconfig = cp; | ||
1872 | mutex_unlock(hcd->bandwidth_mutex); | ||
1873 | |||
1874 | if (!cp) { | ||
1875 | usb_set_device_state(dev, USB_STATE_ADDRESS); | ||
1876 | |||
1877 | /* Leave LPM disabled while the device is unconfigured. */ | ||
1878 | usb_autosuspend_device(dev); | ||
1879 | return ret; | ||
1880 | } | ||
1881 | usb_set_device_state(dev, USB_STATE_CONFIGURED); | ||
1882 | |||
1875 | if (cp->string == NULL && | 1883 | if (cp->string == NULL && |
1876 | !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) | 1884 | !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) |
1877 | cp->string = usb_cache_string(dev, cp->desc.iConfiguration); | 1885 | cp->string = usb_cache_string(dev, cp->desc.iConfiguration); |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 9d912bfdcffe..e0d9d948218c 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -214,9 +214,25 @@ EXPORT_SYMBOL_GPL(usb_unanchor_urb); | |||
214 | * urb->interval is modified to reflect the actual transfer period used | 214 | * urb->interval is modified to reflect the actual transfer period used |
215 | * (normally some power of two units). And for isochronous urbs, | 215 | * (normally some power of two units). And for isochronous urbs, |
216 | * urb->start_frame is modified to reflect when the URB's transfers were | 216 | * urb->start_frame is modified to reflect when the URB's transfers were |
217 | * scheduled to start. Not all isochronous transfer scheduling policies | 217 | * scheduled to start. |
218 | * will work, but most host controller drivers should easily handle ISO | 218 | * |
219 | * queues going from now until 10-200 msec into the future. | 219 | * Not all isochronous transfer scheduling policies will work, but most |
220 | * host controller drivers should easily handle ISO queues going from now | ||
221 | * until 10-200 msec into the future. Drivers should try to keep at | ||
222 | * least one or two msec of data in the queue; many controllers require | ||
223 | * that new transfers start at least 1 msec in the future when they are | ||
224 | * added. If the driver is unable to keep up and the queue empties out, | ||
225 | * the behavior for new submissions is governed by the URB_ISO_ASAP flag. | ||
226 | * If the flag is set, or if the queue is idle, then the URB is always | ||
227 | * assigned to the first available (and not yet expired) slot in the | ||
228 | * endpoint's schedule. If the flag is not set and the queue is active | ||
229 | * then the URB is always assigned to the next slot in the schedule | ||
230 | * following the end of the endpoint's previous URB, even if that slot is | ||
231 | * in the past. When a packet is assigned in this way to a slot that has | ||
232 | * already expired, the packet is not transmitted and the corresponding | ||
233 | * usb_iso_packet_descriptor's status field will return -EXDEV. If this | ||
234 | * would happen to all the packets in the URB, submission fails with a | ||
235 | * -EXDEV error code. | ||
220 | * | 236 | * |
221 | * For control endpoints, the synchronous usb_control_msg() call is | 237 | * For control endpoints, the synchronous usb_control_msg() call is |
222 | * often used (in non-interrupt context) instead of this call. | 238 | * often used (in non-interrupt context) instead of this call. |
@@ -305,8 +321,13 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
305 | struct usb_host_endpoint *ep; | 321 | struct usb_host_endpoint *ep; |
306 | int is_out; | 322 | int is_out; |
307 | 323 | ||
308 | if (!urb || urb->hcpriv || !urb->complete) | 324 | if (!urb || !urb->complete) |
309 | return -EINVAL; | 325 | return -EINVAL; |
326 | if (urb->hcpriv) { | ||
327 | WARN_ONCE(1, "URB %p submitted while active\n", urb); | ||
328 | return -EBUSY; | ||
329 | } | ||
330 | |||
310 | dev = urb->dev; | 331 | dev = urb->dev; |
311 | if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED)) | 332 | if ((!dev) || (dev->state < USB_STATE_UNAUTHENTICATED)) |
312 | return -ENODEV; | 333 | return -ENODEV; |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index cd8fb44a3e16..7d3de09a82e4 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -370,14 +370,14 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, | |||
370 | struct usb_bus *bus, unsigned port1) | 370 | struct usb_bus *bus, unsigned port1) |
371 | { | 371 | { |
372 | struct usb_device *dev; | 372 | struct usb_device *dev; |
373 | struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); | 373 | struct usb_hcd *usb_hcd = bus_to_hcd(bus); |
374 | unsigned root_hub = 0; | 374 | unsigned root_hub = 0; |
375 | 375 | ||
376 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 376 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
377 | if (!dev) | 377 | if (!dev) |
378 | return NULL; | 378 | return NULL; |
379 | 379 | ||
380 | if (!usb_get_hcd(bus_to_hcd(bus))) { | 380 | if (!usb_get_hcd(usb_hcd)) { |
381 | kfree(dev); | 381 | kfree(dev); |
382 | return NULL; | 382 | return NULL; |
383 | } | 383 | } |
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index d441fe4c180b..4502648b8171 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
@@ -27,19 +27,7 @@ endif | |||
27 | ## | 27 | ## |
28 | 28 | ||
29 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o | 29 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o |
30 | 30 | obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o | |
31 | ## | ||
32 | # REVISIT Samsung Exynos platform needs the clk API which isn't | ||
33 | # defined on all architectures. If we allow dwc3-exynos.c compile | ||
34 | # always we will fail the linking phase on those architectures | ||
35 | # which don't provide clk api implementation and that's unnaceptable. | ||
36 | # | ||
37 | # When Samsung's platform start supporting pm_runtime, this check | ||
38 | # for HAVE_CLK should be removed. | ||
39 | ## | ||
40 | ifneq ($(CONFIG_HAVE_CLK),) | ||
41 | obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o | ||
42 | endif | ||
43 | 31 | ||
44 | ifneq ($(CONFIG_PCI),) | 32 | ifneq ($(CONFIG_PCI),) |
45 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o | 33 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c14ebc975ba4..516d4007dfce 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); | |||
66 | 66 | ||
67 | /* -------------------------------------------------------------------------- */ | 67 | /* -------------------------------------------------------------------------- */ |
68 | 68 | ||
69 | #define DWC3_DEVS_POSSIBLE 32 | ||
70 | |||
71 | static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
72 | |||
73 | int dwc3_get_device_id(void) | ||
74 | { | ||
75 | int id; | ||
76 | |||
77 | again: | ||
78 | id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
79 | if (id < DWC3_DEVS_POSSIBLE) { | ||
80 | int old; | ||
81 | |||
82 | old = test_and_set_bit(id, dwc3_devs); | ||
83 | if (old) | ||
84 | goto again; | ||
85 | } else { | ||
86 | pr_err("dwc3: no space for new device\n"); | ||
87 | id = -ENOMEM; | ||
88 | } | ||
89 | |||
90 | return id; | ||
91 | } | ||
92 | EXPORT_SYMBOL_GPL(dwc3_get_device_id); | ||
93 | |||
94 | void dwc3_put_device_id(int id) | ||
95 | { | ||
96 | int ret; | ||
97 | |||
98 | if (id < 0) | ||
99 | return; | ||
100 | |||
101 | ret = test_bit(id, dwc3_devs); | ||
102 | WARN(!ret, "dwc3: ID %d not in use\n", id); | ||
103 | smp_mb__before_clear_bit(); | ||
104 | clear_bit(id, dwc3_devs); | ||
105 | } | ||
106 | EXPORT_SYMBOL_GPL(dwc3_put_device_id); | ||
107 | |||
108 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | 69 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) |
109 | { | 70 | { |
110 | u32 reg; | 71 | u32 reg; |
@@ -169,7 +130,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, | |||
169 | struct dwc3_event_buffer *evt) | 130 | struct dwc3_event_buffer *evt) |
170 | { | 131 | { |
171 | dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); | 132 | dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); |
172 | kfree(evt); | ||
173 | } | 133 | } |
174 | 134 | ||
175 | /** | 135 | /** |
@@ -185,7 +145,7 @@ dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) | |||
185 | { | 145 | { |
186 | struct dwc3_event_buffer *evt; | 146 | struct dwc3_event_buffer *evt; |
187 | 147 | ||
188 | evt = kzalloc(sizeof(*evt), GFP_KERNEL); | 148 | evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); |
189 | if (!evt) | 149 | if (!evt) |
190 | return ERR_PTR(-ENOMEM); | 150 | return ERR_PTR(-ENOMEM); |
191 | 151 | ||
@@ -193,10 +153,8 @@ dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) | |||
193 | evt->length = length; | 153 | evt->length = length; |
194 | evt->buf = dma_alloc_coherent(dwc->dev, length, | 154 | evt->buf = dma_alloc_coherent(dwc->dev, length, |
195 | &evt->dma, GFP_KERNEL); | 155 | &evt->dma, GFP_KERNEL); |
196 | if (!evt->buf) { | 156 | if (!evt->buf) |
197 | kfree(evt); | ||
198 | return ERR_PTR(-ENOMEM); | 157 | return ERR_PTR(-ENOMEM); |
199 | } | ||
200 | 158 | ||
201 | return evt; | 159 | return evt; |
202 | } | 160 | } |
@@ -215,8 +173,6 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
215 | if (evt) | 173 | if (evt) |
216 | dwc3_free_one_event_buffer(dwc, evt); | 174 | dwc3_free_one_event_buffer(dwc, evt); |
217 | } | 175 | } |
218 | |||
219 | kfree(dwc->ev_buffs); | ||
220 | } | 176 | } |
221 | 177 | ||
222 | /** | 178 | /** |
@@ -235,7 +191,8 @@ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | |||
235 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); | 191 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); |
236 | dwc->num_event_buffers = num; | 192 | dwc->num_event_buffers = num; |
237 | 193 | ||
238 | dwc->ev_buffs = kzalloc(sizeof(*dwc->ev_buffs) * num, GFP_KERNEL); | 194 | dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, |
195 | GFP_KERNEL); | ||
239 | if (!dwc->ev_buffs) { | 196 | if (!dwc->ev_buffs) { |
240 | dev_err(dwc->dev, "can't allocate event buffers array\n"); | 197 | dev_err(dwc->dev, "can't allocate event buffers array\n"); |
241 | return -ENOMEM; | 198 | return -ENOMEM; |
@@ -358,8 +315,6 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
358 | 315 | ||
359 | dwc3_core_soft_reset(dwc); | 316 | dwc3_core_soft_reset(dwc); |
360 | 317 | ||
361 | dwc3_cache_hwparams(dwc); | ||
362 | |||
363 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | 318 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
364 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; | 319 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; |
365 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | 320 | reg &= ~DWC3_GCTL_DISSCRAMBLE; |
@@ -383,24 +338,14 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
383 | 338 | ||
384 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 339 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
385 | 340 | ||
386 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
387 | if (ret) { | ||
388 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
389 | ret = -ENOMEM; | ||
390 | goto err1; | ||
391 | } | ||
392 | |||
393 | ret = dwc3_event_buffers_setup(dwc); | 341 | ret = dwc3_event_buffers_setup(dwc); |
394 | if (ret) { | 342 | if (ret) { |
395 | dev_err(dwc->dev, "failed to setup event buffers\n"); | 343 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
396 | goto err1; | 344 | goto err0; |
397 | } | 345 | } |
398 | 346 | ||
399 | return 0; | 347 | return 0; |
400 | 348 | ||
401 | err1: | ||
402 | dwc3_free_event_buffers(dwc); | ||
403 | |||
404 | err0: | 349 | err0: |
405 | return ret; | 350 | return ret; |
406 | } | 351 | } |
@@ -408,11 +353,9 @@ err0: | |||
408 | static void dwc3_core_exit(struct dwc3 *dwc) | 353 | static void dwc3_core_exit(struct dwc3 *dwc) |
409 | { | 354 | { |
410 | dwc3_event_buffers_cleanup(dwc); | 355 | dwc3_event_buffers_cleanup(dwc); |
411 | dwc3_free_event_buffers(dwc); | ||
412 | 356 | ||
413 | usb_phy_shutdown(dwc->usb2_phy); | 357 | usb_phy_shutdown(dwc->usb2_phy); |
414 | usb_phy_shutdown(dwc->usb3_phy); | 358 | usb_phy_shutdown(dwc->usb3_phy); |
415 | |||
416 | } | 359 | } |
417 | 360 | ||
418 | #define DWC3_ALIGN_MASK (16 - 1) | 361 | #define DWC3_ALIGN_MASK (16 - 1) |
@@ -515,10 +458,19 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
515 | pm_runtime_get_sync(dev); | 458 | pm_runtime_get_sync(dev); |
516 | pm_runtime_forbid(dev); | 459 | pm_runtime_forbid(dev); |
517 | 460 | ||
461 | dwc3_cache_hwparams(dwc); | ||
462 | |||
463 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
464 | if (ret) { | ||
465 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
466 | ret = -ENOMEM; | ||
467 | goto err0; | ||
468 | } | ||
469 | |||
518 | ret = dwc3_core_init(dwc); | 470 | ret = dwc3_core_init(dwc); |
519 | if (ret) { | 471 | if (ret) { |
520 | dev_err(dev, "failed to initialize core\n"); | 472 | dev_err(dev, "failed to initialize core\n"); |
521 | return ret; | 473 | goto err0; |
522 | } | 474 | } |
523 | 475 | ||
524 | mode = DWC3_MODE(dwc->hwparams.hwparams0); | 476 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
@@ -590,6 +542,9 @@ err2: | |||
590 | err1: | 542 | err1: |
591 | dwc3_core_exit(dwc); | 543 | dwc3_core_exit(dwc); |
592 | 544 | ||
545 | err0: | ||
546 | dwc3_free_event_buffers(dwc); | ||
547 | |||
593 | return ret; | 548 | return ret; |
594 | } | 549 | } |
595 | 550 | ||
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 243affc93431..499956344262 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc); | |||
868 | int dwc3_gadget_init(struct dwc3 *dwc); | 868 | int dwc3_gadget_init(struct dwc3 *dwc); |
869 | void dwc3_gadget_exit(struct dwc3 *dwc); | 869 | void dwc3_gadget_exit(struct dwc3 *dwc); |
870 | 870 | ||
871 | extern int dwc3_get_device_id(void); | ||
872 | extern void dwc3_put_device_id(int id); | ||
873 | |||
874 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ | 871 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index ca6597853f90..dc35c5476f37 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
22 | #include <linux/usb/otg.h> | 22 | #include <linux/usb/otg.h> |
23 | #include <linux/usb/nop-usb-xceiv.h> | 23 | #include <linux/usb/nop-usb-xceiv.h> |
24 | #include <linux/of.h> | ||
24 | 25 | ||
25 | #include "core.h" | 26 | #include "core.h" |
26 | 27 | ||
@@ -87,14 +88,14 @@ err1: | |||
87 | return ret; | 88 | return ret; |
88 | } | 89 | } |
89 | 90 | ||
91 | static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); | ||
92 | |||
90 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | 93 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) |
91 | { | 94 | { |
92 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | ||
93 | struct platform_device *dwc3; | 95 | struct platform_device *dwc3; |
94 | struct dwc3_exynos *exynos; | 96 | struct dwc3_exynos *exynos; |
95 | struct clk *clk; | 97 | struct clk *clk; |
96 | 98 | ||
97 | int devid; | ||
98 | int ret = -ENOMEM; | 99 | int ret = -ENOMEM; |
99 | 100 | ||
100 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); | 101 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); |
@@ -103,11 +104,15 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
103 | goto err0; | 104 | goto err0; |
104 | } | 105 | } |
105 | 106 | ||
106 | platform_set_drvdata(pdev, exynos); | 107 | /* |
108 | * Right now device-tree probed devices don't get dma_mask set. | ||
109 | * Since shared usb code relies on it, set it here for now. | ||
110 | * Once we move to full device tree support this will vanish off. | ||
111 | */ | ||
112 | if (!pdev->dev.dma_mask) | ||
113 | pdev->dev.dma_mask = &dwc3_exynos_dma_mask; | ||
107 | 114 | ||
108 | devid = dwc3_get_device_id(); | 115 | platform_set_drvdata(pdev, exynos); |
109 | if (devid < 0) | ||
110 | goto err1; | ||
111 | 116 | ||
112 | ret = dwc3_exynos_register_phys(exynos); | 117 | ret = dwc3_exynos_register_phys(exynos); |
113 | if (ret) { | 118 | if (ret) { |
@@ -115,10 +120,10 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
115 | goto err1; | 120 | goto err1; |
116 | } | 121 | } |
117 | 122 | ||
118 | dwc3 = platform_device_alloc("dwc3", devid); | 123 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
119 | if (!dwc3) { | 124 | if (!dwc3) { |
120 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 125 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); |
121 | goto err2; | 126 | goto err1; |
122 | } | 127 | } |
123 | 128 | ||
124 | clk = clk_get(&pdev->dev, "usbdrd30"); | 129 | clk = clk_get(&pdev->dev, "usbdrd30"); |
@@ -139,14 +144,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
139 | 144 | ||
140 | clk_enable(exynos->clk); | 145 | clk_enable(exynos->clk); |
141 | 146 | ||
142 | /* PHY initialization */ | ||
143 | if (!pdata) { | ||
144 | dev_dbg(&pdev->dev, "missing platform data\n"); | ||
145 | } else { | ||
146 | if (pdata->phy_init) | ||
147 | pdata->phy_init(pdev, pdata->phy_type); | ||
148 | } | ||
149 | |||
150 | ret = platform_device_add_resources(dwc3, pdev->resource, | 147 | ret = platform_device_add_resources(dwc3, pdev->resource, |
151 | pdev->num_resources); | 148 | pdev->num_resources); |
152 | if (ret) { | 149 | if (ret) { |
@@ -163,15 +160,10 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
163 | return 0; | 160 | return 0; |
164 | 161 | ||
165 | err4: | 162 | err4: |
166 | if (pdata && pdata->phy_exit) | ||
167 | pdata->phy_exit(pdev, pdata->phy_type); | ||
168 | |||
169 | clk_disable(clk); | 163 | clk_disable(clk); |
170 | clk_put(clk); | 164 | clk_put(clk); |
171 | err3: | 165 | err3: |
172 | platform_device_put(dwc3); | 166 | platform_device_put(dwc3); |
173 | err2: | ||
174 | dwc3_put_device_id(devid); | ||
175 | err1: | 167 | err1: |
176 | kfree(exynos); | 168 | kfree(exynos); |
177 | err0: | 169 | err0: |
@@ -181,17 +173,11 @@ err0: | |||
181 | static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | 173 | static int __devexit dwc3_exynos_remove(struct platform_device *pdev) |
182 | { | 174 | { |
183 | struct dwc3_exynos *exynos = platform_get_drvdata(pdev); | 175 | struct dwc3_exynos *exynos = platform_get_drvdata(pdev); |
184 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | ||
185 | 176 | ||
186 | platform_device_unregister(exynos->dwc3); | 177 | platform_device_unregister(exynos->dwc3); |
187 | platform_device_unregister(exynos->usb2_phy); | 178 | platform_device_unregister(exynos->usb2_phy); |
188 | platform_device_unregister(exynos->usb3_phy); | 179 | platform_device_unregister(exynos->usb3_phy); |
189 | 180 | ||
190 | dwc3_put_device_id(exynos->dwc3->id); | ||
191 | |||
192 | if (pdata && pdata->phy_exit) | ||
193 | pdata->phy_exit(pdev, pdata->phy_type); | ||
194 | |||
195 | clk_disable(exynos->clk); | 181 | clk_disable(exynos->clk); |
196 | clk_put(exynos->clk); | 182 | clk_put(exynos->clk); |
197 | 183 | ||
@@ -200,11 +186,20 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | |||
200 | return 0; | 186 | return 0; |
201 | } | 187 | } |
202 | 188 | ||
189 | #ifdef CONFIG_OF | ||
190 | static const struct of_device_id exynos_dwc3_match[] = { | ||
191 | { .compatible = "samsung,exynos-dwc3" }, | ||
192 | {}, | ||
193 | }; | ||
194 | MODULE_DEVICE_TABLE(of, exynos_dwc3_match); | ||
195 | #endif | ||
196 | |||
203 | static struct platform_driver dwc3_exynos_driver = { | 197 | static struct platform_driver dwc3_exynos_driver = { |
204 | .probe = dwc3_exynos_probe, | 198 | .probe = dwc3_exynos_probe, |
205 | .remove = __devexit_p(dwc3_exynos_remove), | 199 | .remove = __devexit_p(dwc3_exynos_remove), |
206 | .driver = { | 200 | .driver = { |
207 | .name = "exynos-dwc3", | 201 | .name = "exynos-dwc3", |
202 | .of_match_table = of_match_ptr(exynos_dwc3_match), | ||
208 | }, | 203 | }, |
209 | }; | 204 | }; |
210 | 205 | ||
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index ee57a10d90d0..900d435f41d1 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
272 | struct resource *res; | 272 | struct resource *res; |
273 | struct device *dev = &pdev->dev; | 273 | struct device *dev = &pdev->dev; |
274 | 274 | ||
275 | int devid; | ||
276 | int size; | 275 | int size; |
277 | int ret = -ENOMEM; | 276 | int ret = -ENOMEM; |
278 | int irq; | 277 | int irq; |
@@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
315 | return ret; | 314 | return ret; |
316 | } | 315 | } |
317 | 316 | ||
318 | devid = dwc3_get_device_id(); | 317 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
319 | if (devid < 0) | ||
320 | return -ENODEV; | ||
321 | |||
322 | dwc3 = platform_device_alloc("dwc3", devid); | ||
323 | if (!dwc3) { | 318 | if (!dwc3) { |
324 | dev_err(dev, "couldn't allocate dwc3 device\n"); | 319 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
325 | goto err1; | 320 | return -ENOMEM; |
326 | } | 321 | } |
327 | 322 | ||
328 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); | 323 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); |
@@ -423,10 +418,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
423 | 418 | ||
424 | err2: | 419 | err2: |
425 | platform_device_put(dwc3); | 420 | platform_device_put(dwc3); |
426 | |||
427 | err1: | ||
428 | dwc3_put_device_id(devid); | ||
429 | |||
430 | return ret; | 421 | return ret; |
431 | } | 422 | } |
432 | 423 | ||
@@ -437,9 +428,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) | |||
437 | platform_device_unregister(omap->dwc3); | 428 | platform_device_unregister(omap->dwc3); |
438 | platform_device_unregister(omap->usb2_phy); | 429 | platform_device_unregister(omap->usb2_phy); |
439 | platform_device_unregister(omap->usb3_phy); | 430 | platform_device_unregister(omap->usb3_phy); |
440 | |||
441 | dwc3_put_device_id(omap->dwc3->id); | ||
442 | |||
443 | return 0; | 431 | return 0; |
444 | } | 432 | } |
445 | 433 | ||
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 94f550e37f98..13962597f3fe 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -119,7 +119,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
119 | struct platform_device *dwc3; | 119 | struct platform_device *dwc3; |
120 | struct dwc3_pci *glue; | 120 | struct dwc3_pci *glue; |
121 | int ret = -ENOMEM; | 121 | int ret = -ENOMEM; |
122 | int devid; | ||
123 | struct device *dev = &pci->dev; | 122 | struct device *dev = &pci->dev; |
124 | 123 | ||
125 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); | 124 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); |
@@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
145 | return ret; | 144 | return ret; |
146 | } | 145 | } |
147 | 146 | ||
148 | devid = dwc3_get_device_id(); | 147 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
149 | if (devid < 0) { | ||
150 | ret = -ENOMEM; | ||
151 | goto err1; | ||
152 | } | ||
153 | |||
154 | dwc3 = platform_device_alloc("dwc3", devid); | ||
155 | if (!dwc3) { | 148 | if (!dwc3) { |
156 | dev_err(dev, "couldn't allocate dwc3 device\n"); | 149 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
157 | ret = -ENOMEM; | 150 | ret = -ENOMEM; |
@@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
172 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); | 165 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); |
173 | if (ret) { | 166 | if (ret) { |
174 | dev_err(dev, "couldn't add resources to dwc3 device\n"); | 167 | dev_err(dev, "couldn't add resources to dwc3 device\n"); |
175 | goto err2; | 168 | goto err1; |
176 | } | 169 | } |
177 | 170 | ||
178 | pci_set_drvdata(pci, glue); | 171 | pci_set_drvdata(pci, glue); |
@@ -195,10 +188,6 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
195 | err3: | 188 | err3: |
196 | pci_set_drvdata(pci, NULL); | 189 | pci_set_drvdata(pci, NULL); |
197 | platform_device_put(dwc3); | 190 | platform_device_put(dwc3); |
198 | |||
199 | err2: | ||
200 | dwc3_put_device_id(devid); | ||
201 | |||
202 | err1: | 191 | err1: |
203 | pci_disable_device(pci); | 192 | pci_disable_device(pci); |
204 | 193 | ||
@@ -211,7 +200,6 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) | |||
211 | 200 | ||
212 | platform_device_unregister(glue->usb2_phy); | 201 | platform_device_unregister(glue->usb2_phy); |
213 | platform_device_unregister(glue->usb3_phy); | 202 | platform_device_unregister(glue->usb3_phy); |
214 | dwc3_put_device_id(glue->dwc3->id); | ||
215 | platform_device_unregister(glue->dwc3); | 203 | platform_device_unregister(glue->dwc3); |
216 | pci_set_drvdata(pci, NULL); | 204 | pci_set_drvdata(pci, NULL); |
217 | pci_disable_device(pci); | 205 | pci_disable_device(pci); |
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index 4bfa78af379c..5e29ddeb4d33 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c | |||
@@ -974,7 +974,7 @@ struct console early_dbgp_console = { | |||
974 | .index = -1, | 974 | .index = -1, |
975 | }; | 975 | }; |
976 | 976 | ||
977 | #if IS_ENABLED(CONFIG_USB_EHCI_HCD) | 977 | #if IS_ENABLED(CONFIG_USB) |
978 | int dbgp_reset_prep(struct usb_hcd *hcd) | 978 | int dbgp_reset_prep(struct usb_hcd *hcd) |
979 | { | 979 | { |
980 | int ret = xen_dbgp_reset_prep(hcd); | 980 | int ret = xen_dbgp_reset_prep(hcd); |
@@ -1008,7 +1008,7 @@ int dbgp_external_startup(struct usb_hcd *hcd) | |||
1008 | return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); | 1008 | return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); |
1009 | } | 1009 | } |
1010 | EXPORT_SYMBOL_GPL(dbgp_external_startup); | 1010 | EXPORT_SYMBOL_GPL(dbgp_external_startup); |
1011 | #endif /* USB_EHCI_HCD */ | 1011 | #endif /* USB */ |
1012 | 1012 | ||
1013 | #ifdef CONFIG_KGDB | 1013 | #ifdef CONFIG_KGDB |
1014 | 1014 | ||
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index e0ff51b89529..14625fd2cecd 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -721,31 +721,6 @@ config USB_FUNCTIONFS_GENERIC | |||
721 | Include a configuration with the Function Filesystem alone with | 721 | Include a configuration with the Function Filesystem alone with |
722 | no Ethernet interface. | 722 | no Ethernet interface. |
723 | 723 | ||
724 | config USB_FILE_STORAGE | ||
725 | tristate "File-backed Storage Gadget (DEPRECATED)" | ||
726 | depends on BLOCK | ||
727 | help | ||
728 | The File-backed Storage Gadget acts as a USB Mass Storage | ||
729 | disk drive. As its storage repository it can use a regular | ||
730 | file or a block device (in much the same way as the "loop" | ||
731 | device driver), specified as a module parameter. | ||
732 | |||
733 | Say "y" to link the driver statically, or "m" to build a | ||
734 | dynamically linked module called "g_file_storage". | ||
735 | |||
736 | NOTE: This driver is deprecated. Its replacement is the | ||
737 | Mass Storage Gadget. | ||
738 | |||
739 | config USB_FILE_STORAGE_TEST | ||
740 | bool "File-backed Storage Gadget testing version" | ||
741 | depends on USB_FILE_STORAGE | ||
742 | default n | ||
743 | help | ||
744 | Say "y" to generate the larger testing version of the | ||
745 | File-backed Storage Gadget, useful for probing the | ||
746 | behavior of USB Mass Storage hosts. Not needed for | ||
747 | normal operation. | ||
748 | |||
749 | config USB_MASS_STORAGE | 724 | config USB_MASS_STORAGE |
750 | tristate "Mass Storage Gadget" | 725 | tristate "Mass Storage Gadget" |
751 | depends on BLOCK | 726 | depends on BLOCK |
@@ -756,8 +731,8 @@ config USB_MASS_STORAGE | |||
756 | device (in much the same way as the "loop" device driver), | 731 | device (in much the same way as the "loop" device driver), |
757 | specified as a module parameter or sysfs option. | 732 | specified as a module parameter or sysfs option. |
758 | 733 | ||
759 | This driver is an updated replacement for the deprecated | 734 | This driver is a replacement for now removed File-backed |
760 | File-backed Storage Gadget (g_file_storage). | 735 | Storage Gadget (g_file_storage). |
761 | 736 | ||
762 | Say "y" to link the driver statically, or "m" to build | 737 | Say "y" to link the driver statically, or "m" to build |
763 | a dynamically linked module called "g_mass_storage". | 738 | a dynamically linked module called "g_mass_storage". |
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 307be5fa824c..8b4acfd92aa3 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile | |||
@@ -44,7 +44,6 @@ g_ether-y := ether.o | |||
44 | g_serial-y := serial.o | 44 | g_serial-y := serial.o |
45 | g_midi-y := gmidi.o | 45 | g_midi-y := gmidi.o |
46 | gadgetfs-y := inode.o | 46 | gadgetfs-y := inode.o |
47 | g_file_storage-y := file_storage.o | ||
48 | g_mass_storage-y := mass_storage.o | 47 | g_mass_storage-y := mass_storage.o |
49 | g_printer-y := printer.o | 48 | g_printer-y := printer.o |
50 | g_cdc-y := cdc2.o | 49 | g_cdc-y := cdc2.o |
@@ -62,7 +61,6 @@ obj-$(CONFIG_USB_AUDIO) += g_audio.o | |||
62 | obj-$(CONFIG_USB_ETH) += g_ether.o | 61 | obj-$(CONFIG_USB_ETH) += g_ether.o |
63 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o | 62 | obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o |
64 | obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o | 63 | obj-$(CONFIG_USB_FUNCTIONFS) += g_ffs.o |
65 | obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o | ||
66 | obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o | 64 | obj-$(CONFIG_USB_MASS_STORAGE) += g_mass_storage.o |
67 | obj-$(CONFIG_USB_G_SERIAL) += g_serial.o | 65 | obj-$(CONFIG_USB_G_SERIAL) += g_serial.o |
68 | obj-$(CONFIG_USB_G_PRINTER) += g_printer.o | 66 | obj-$(CONFIG_USB_G_PRINTER) += g_printer.o |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 957f973dd96a..2a6bfe759c29 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -107,7 +107,7 @@ int config_ep_by_speed(struct usb_gadget *g, | |||
107 | } | 107 | } |
108 | /* else: fall through */ | 108 | /* else: fall through */ |
109 | default: | 109 | default: |
110 | speed_desc = f->descriptors; | 110 | speed_desc = f->fs_descriptors; |
111 | } | 111 | } |
112 | /* find descriptors */ | 112 | /* find descriptors */ |
113 | for_each_ep_desc(speed_desc, d_spd) { | 113 | for_each_ep_desc(speed_desc, d_spd) { |
@@ -200,7 +200,7 @@ int usb_add_function(struct usb_configuration *config, | |||
200 | * as full speed ... it's the function drivers that will need | 200 | * as full speed ... it's the function drivers that will need |
201 | * to avoid bulk and ISO transfers. | 201 | * to avoid bulk and ISO transfers. |
202 | */ | 202 | */ |
203 | if (!config->fullspeed && function->descriptors) | 203 | if (!config->fullspeed && function->fs_descriptors) |
204 | config->fullspeed = true; | 204 | config->fullspeed = true; |
205 | if (!config->highspeed && function->hs_descriptors) | 205 | if (!config->highspeed && function->hs_descriptors) |
206 | config->highspeed = true; | 206 | config->highspeed = true; |
@@ -363,7 +363,7 @@ static int config_buf(struct usb_configuration *config, | |||
363 | descriptors = f->hs_descriptors; | 363 | descriptors = f->hs_descriptors; |
364 | break; | 364 | break; |
365 | default: | 365 | default: |
366 | descriptors = f->descriptors; | 366 | descriptors = f->fs_descriptors; |
367 | } | 367 | } |
368 | 368 | ||
369 | if (!descriptors) | 369 | if (!descriptors) |
@@ -620,7 +620,7 @@ static int set_config(struct usb_composite_dev *cdev, | |||
620 | descriptors = f->hs_descriptors; | 620 | descriptors = f->hs_descriptors; |
621 | break; | 621 | break; |
622 | default: | 622 | default: |
623 | descriptors = f->descriptors; | 623 | descriptors = f->fs_descriptors; |
624 | } | 624 | } |
625 | 625 | ||
626 | for (; *descriptors; ++descriptors) { | 626 | for (; *descriptors; ++descriptors) { |
diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index e3a98929d346..34e12fc52c23 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/usb/ch9.h> | 20 | #include <linux/usb/ch9.h> |
21 | #include <linux/usb/gadget.h> | 21 | #include <linux/usb/gadget.h> |
22 | 22 | #include <linux/usb/composite.h> | |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * usb_descriptor_fillbuf - fill buffer with descriptors | 25 | * usb_descriptor_fillbuf - fill buffer with descriptors |
@@ -158,3 +158,40 @@ usb_copy_descriptors(struct usb_descriptor_header **src) | |||
158 | return ret; | 158 | return ret; |
159 | } | 159 | } |
160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); | 160 | EXPORT_SYMBOL_GPL(usb_copy_descriptors); |
161 | |||
162 | int usb_assign_descriptors(struct usb_function *f, | ||
163 | struct usb_descriptor_header **fs, | ||
164 | struct usb_descriptor_header **hs, | ||
165 | struct usb_descriptor_header **ss) | ||
166 | { | ||
167 | struct usb_gadget *g = f->config->cdev->gadget; | ||
168 | |||
169 | if (fs) { | ||
170 | f->fs_descriptors = usb_copy_descriptors(fs); | ||
171 | if (!f->fs_descriptors) | ||
172 | goto err; | ||
173 | } | ||
174 | if (hs && gadget_is_dualspeed(g)) { | ||
175 | f->hs_descriptors = usb_copy_descriptors(hs); | ||
176 | if (!f->hs_descriptors) | ||
177 | goto err; | ||
178 | } | ||
179 | if (ss && gadget_is_superspeed(g)) { | ||
180 | f->ss_descriptors = usb_copy_descriptors(ss); | ||
181 | if (!f->ss_descriptors) | ||
182 | goto err; | ||
183 | } | ||
184 | return 0; | ||
185 | err: | ||
186 | usb_free_all_descriptors(f); | ||
187 | return -ENOMEM; | ||
188 | } | ||
189 | EXPORT_SYMBOL_GPL(usb_assign_descriptors); | ||
190 | |||
191 | void usb_free_all_descriptors(struct usb_function *f) | ||
192 | { | ||
193 | usb_free_descriptors(f->fs_descriptors); | ||
194 | usb_free_descriptors(f->hs_descriptors); | ||
195 | usb_free_descriptors(f->ss_descriptors); | ||
196 | } | ||
197 | EXPORT_SYMBOL_GPL(usb_free_all_descriptors); | ||
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 0f7541be28f3..95d584dbed13 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -63,16 +63,20 @@ MODULE_LICENSE("GPL"); | |||
63 | struct dummy_hcd_module_parameters { | 63 | struct dummy_hcd_module_parameters { |
64 | bool is_super_speed; | 64 | bool is_super_speed; |
65 | bool is_high_speed; | 65 | bool is_high_speed; |
66 | unsigned int num; | ||
66 | }; | 67 | }; |
67 | 68 | ||
68 | static struct dummy_hcd_module_parameters mod_data = { | 69 | static struct dummy_hcd_module_parameters mod_data = { |
69 | .is_super_speed = false, | 70 | .is_super_speed = false, |
70 | .is_high_speed = true, | 71 | .is_high_speed = true, |
72 | .num = 1, | ||
71 | }; | 73 | }; |
72 | module_param_named(is_super_speed, mod_data.is_super_speed, bool, S_IRUGO); | 74 | module_param_named(is_super_speed, mod_data.is_super_speed, bool, S_IRUGO); |
73 | MODULE_PARM_DESC(is_super_speed, "true to simulate SuperSpeed connection"); | 75 | MODULE_PARM_DESC(is_super_speed, "true to simulate SuperSpeed connection"); |
74 | module_param_named(is_high_speed, mod_data.is_high_speed, bool, S_IRUGO); | 76 | module_param_named(is_high_speed, mod_data.is_high_speed, bool, S_IRUGO); |
75 | MODULE_PARM_DESC(is_high_speed, "true to simulate HighSpeed connection"); | 77 | MODULE_PARM_DESC(is_high_speed, "true to simulate HighSpeed connection"); |
78 | module_param_named(num, mod_data.num, uint, S_IRUGO); | ||
79 | MODULE_PARM_DESC(num, "number of emulated controllers"); | ||
76 | /*-------------------------------------------------------------------------*/ | 80 | /*-------------------------------------------------------------------------*/ |
77 | 81 | ||
78 | /* gadget side driver data structres */ | 82 | /* gadget side driver data structres */ |
@@ -238,8 +242,6 @@ static inline struct dummy *gadget_dev_to_dummy(struct device *dev) | |||
238 | return container_of(dev, struct dummy, gadget.dev); | 242 | return container_of(dev, struct dummy, gadget.dev); |
239 | } | 243 | } |
240 | 244 | ||
241 | static struct dummy the_controller; | ||
242 | |||
243 | /*-------------------------------------------------------------------------*/ | 245 | /*-------------------------------------------------------------------------*/ |
244 | 246 | ||
245 | /* SLAVE/GADGET SIDE UTILITY ROUTINES */ | 247 | /* SLAVE/GADGET SIDE UTILITY ROUTINES */ |
@@ -973,9 +975,10 @@ static void init_dummy_udc_hw(struct dummy *dum) | |||
973 | 975 | ||
974 | static int dummy_udc_probe(struct platform_device *pdev) | 976 | static int dummy_udc_probe(struct platform_device *pdev) |
975 | { | 977 | { |
976 | struct dummy *dum = &the_controller; | 978 | struct dummy *dum; |
977 | int rc; | 979 | int rc; |
978 | 980 | ||
981 | dum = *((void **)dev_get_platdata(&pdev->dev)); | ||
979 | dum->gadget.name = gadget_name; | 982 | dum->gadget.name = gadget_name; |
980 | dum->gadget.ops = &dummy_ops; | 983 | dum->gadget.ops = &dummy_ops; |
981 | dum->gadget.max_speed = USB_SPEED_SUPER; | 984 | dum->gadget.max_speed = USB_SPEED_SUPER; |
@@ -2398,10 +2401,13 @@ static int dummy_h_get_frame(struct usb_hcd *hcd) | |||
2398 | 2401 | ||
2399 | static int dummy_setup(struct usb_hcd *hcd) | 2402 | static int dummy_setup(struct usb_hcd *hcd) |
2400 | { | 2403 | { |
2404 | struct dummy *dum; | ||
2405 | |||
2406 | dum = *((void **)dev_get_platdata(hcd->self.controller)); | ||
2401 | hcd->self.sg_tablesize = ~0; | 2407 | hcd->self.sg_tablesize = ~0; |
2402 | if (usb_hcd_is_primary_hcd(hcd)) { | 2408 | if (usb_hcd_is_primary_hcd(hcd)) { |
2403 | the_controller.hs_hcd = hcd_to_dummy_hcd(hcd); | 2409 | dum->hs_hcd = hcd_to_dummy_hcd(hcd); |
2404 | the_controller.hs_hcd->dum = &the_controller; | 2410 | dum->hs_hcd->dum = dum; |
2405 | /* | 2411 | /* |
2406 | * Mark the first roothub as being USB 2.0. | 2412 | * Mark the first roothub as being USB 2.0. |
2407 | * The USB 3.0 roothub will be registered later by | 2413 | * The USB 3.0 roothub will be registered later by |
@@ -2410,8 +2416,8 @@ static int dummy_setup(struct usb_hcd *hcd) | |||
2410 | hcd->speed = HCD_USB2; | 2416 | hcd->speed = HCD_USB2; |
2411 | hcd->self.root_hub->speed = USB_SPEED_HIGH; | 2417 | hcd->self.root_hub->speed = USB_SPEED_HIGH; |
2412 | } else { | 2418 | } else { |
2413 | the_controller.ss_hcd = hcd_to_dummy_hcd(hcd); | 2419 | dum->ss_hcd = hcd_to_dummy_hcd(hcd); |
2414 | the_controller.ss_hcd->dum = &the_controller; | 2420 | dum->ss_hcd->dum = dum; |
2415 | hcd->speed = HCD_USB3; | 2421 | hcd->speed = HCD_USB3; |
2416 | hcd->self.root_hub->speed = USB_SPEED_SUPER; | 2422 | hcd->self.root_hub->speed = USB_SPEED_SUPER; |
2417 | } | 2423 | } |
@@ -2524,11 +2530,13 @@ static struct hc_driver dummy_hcd = { | |||
2524 | 2530 | ||
2525 | static int dummy_hcd_probe(struct platform_device *pdev) | 2531 | static int dummy_hcd_probe(struct platform_device *pdev) |
2526 | { | 2532 | { |
2533 | struct dummy *dum; | ||
2527 | struct usb_hcd *hs_hcd; | 2534 | struct usb_hcd *hs_hcd; |
2528 | struct usb_hcd *ss_hcd; | 2535 | struct usb_hcd *ss_hcd; |
2529 | int retval; | 2536 | int retval; |
2530 | 2537 | ||
2531 | dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); | 2538 | dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); |
2539 | dum = *((void **)dev_get_platdata(&pdev->dev)); | ||
2532 | 2540 | ||
2533 | if (!mod_data.is_super_speed) | 2541 | if (!mod_data.is_super_speed) |
2534 | dummy_hcd.flags = HCD_USB2; | 2542 | dummy_hcd.flags = HCD_USB2; |
@@ -2561,7 +2569,7 @@ dealloc_usb2_hcd: | |||
2561 | usb_remove_hcd(hs_hcd); | 2569 | usb_remove_hcd(hs_hcd); |
2562 | put_usb2_hcd: | 2570 | put_usb2_hcd: |
2563 | usb_put_hcd(hs_hcd); | 2571 | usb_put_hcd(hs_hcd); |
2564 | the_controller.hs_hcd = the_controller.ss_hcd = NULL; | 2572 | dum->hs_hcd = dum->ss_hcd = NULL; |
2565 | return retval; | 2573 | return retval; |
2566 | } | 2574 | } |
2567 | 2575 | ||
@@ -2579,8 +2587,8 @@ static int dummy_hcd_remove(struct platform_device *pdev) | |||
2579 | usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); | 2587 | usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); |
2580 | usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); | 2588 | usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); |
2581 | 2589 | ||
2582 | the_controller.hs_hcd = NULL; | 2590 | dum->hs_hcd = NULL; |
2583 | the_controller.ss_hcd = NULL; | 2591 | dum->ss_hcd = NULL; |
2584 | 2592 | ||
2585 | return 0; | 2593 | return 0; |
2586 | } | 2594 | } |
@@ -2627,13 +2635,15 @@ static struct platform_driver dummy_hcd_driver = { | |||
2627 | }; | 2635 | }; |
2628 | 2636 | ||
2629 | /*-------------------------------------------------------------------------*/ | 2637 | /*-------------------------------------------------------------------------*/ |
2630 | 2638 | #define MAX_NUM_UDC 2 | |
2631 | static struct platform_device *the_udc_pdev; | 2639 | static struct platform_device *the_udc_pdev[MAX_NUM_UDC]; |
2632 | static struct platform_device *the_hcd_pdev; | 2640 | static struct platform_device *the_hcd_pdev[MAX_NUM_UDC]; |
2633 | 2641 | ||
2634 | static int __init init(void) | 2642 | static int __init init(void) |
2635 | { | 2643 | { |
2636 | int retval = -ENOMEM; | 2644 | int retval = -ENOMEM; |
2645 | int i; | ||
2646 | struct dummy *dum[MAX_NUM_UDC]; | ||
2637 | 2647 | ||
2638 | if (usb_disabled()) | 2648 | if (usb_disabled()) |
2639 | return -ENODEV; | 2649 | return -ENODEV; |
@@ -2641,65 +2651,129 @@ static int __init init(void) | |||
2641 | if (!mod_data.is_high_speed && mod_data.is_super_speed) | 2651 | if (!mod_data.is_high_speed && mod_data.is_super_speed) |
2642 | return -EINVAL; | 2652 | return -EINVAL; |
2643 | 2653 | ||
2644 | the_hcd_pdev = platform_device_alloc(driver_name, -1); | 2654 | if (mod_data.num < 1 || mod_data.num > MAX_NUM_UDC) { |
2645 | if (!the_hcd_pdev) | 2655 | pr_err("Number of emulated UDC must be in range of 1…%d\n", |
2646 | return retval; | 2656 | MAX_NUM_UDC); |
2647 | the_udc_pdev = platform_device_alloc(gadget_name, -1); | 2657 | return -EINVAL; |
2648 | if (!the_udc_pdev) | 2658 | } |
2649 | goto err_alloc_udc; | 2659 | |
2660 | for (i = 0; i < mod_data.num; i++) { | ||
2661 | the_hcd_pdev[i] = platform_device_alloc(driver_name, i); | ||
2662 | if (!the_hcd_pdev[i]) { | ||
2663 | i--; | ||
2664 | while (i >= 0) | ||
2665 | platform_device_put(the_hcd_pdev[i--]); | ||
2666 | return retval; | ||
2667 | } | ||
2668 | } | ||
2669 | for (i = 0; i < mod_data.num; i++) { | ||
2670 | the_udc_pdev[i] = platform_device_alloc(gadget_name, i); | ||
2671 | if (!the_udc_pdev[i]) { | ||
2672 | i--; | ||
2673 | while (i >= 0) | ||
2674 | platform_device_put(the_udc_pdev[i--]); | ||
2675 | goto err_alloc_udc; | ||
2676 | } | ||
2677 | } | ||
2678 | for (i = 0; i < mod_data.num; i++) { | ||
2679 | dum[i] = kzalloc(sizeof(struct dummy), GFP_KERNEL); | ||
2680 | if (!dum[i]) | ||
2681 | goto err_add_pdata; | ||
2682 | retval = platform_device_add_data(the_hcd_pdev[i], &dum[i], | ||
2683 | sizeof(void *)); | ||
2684 | if (retval) | ||
2685 | goto err_add_pdata; | ||
2686 | retval = platform_device_add_data(the_udc_pdev[i], &dum[i], | ||
2687 | sizeof(void *)); | ||
2688 | if (retval) | ||
2689 | goto err_add_pdata; | ||
2690 | } | ||
2650 | 2691 | ||
2651 | retval = platform_driver_register(&dummy_hcd_driver); | 2692 | retval = platform_driver_register(&dummy_hcd_driver); |
2652 | if (retval < 0) | 2693 | if (retval < 0) |
2653 | goto err_register_hcd_driver; | 2694 | goto err_add_pdata; |
2654 | retval = platform_driver_register(&dummy_udc_driver); | 2695 | retval = platform_driver_register(&dummy_udc_driver); |
2655 | if (retval < 0) | 2696 | if (retval < 0) |
2656 | goto err_register_udc_driver; | 2697 | goto err_register_udc_driver; |
2657 | 2698 | ||
2658 | retval = platform_device_add(the_hcd_pdev); | 2699 | for (i = 0; i < mod_data.num; i++) { |
2659 | if (retval < 0) | 2700 | retval = platform_device_add(the_hcd_pdev[i]); |
2660 | goto err_add_hcd; | 2701 | if (retval < 0) { |
2661 | if (!the_controller.hs_hcd || | 2702 | i--; |
2662 | (!the_controller.ss_hcd && mod_data.is_super_speed)) { | 2703 | while (i >= 0) |
2663 | /* | 2704 | platform_device_del(the_hcd_pdev[i--]); |
2664 | * The hcd was added successfully but its probe function failed | 2705 | goto err_add_hcd; |
2665 | * for some reason. | 2706 | } |
2666 | */ | ||
2667 | retval = -EINVAL; | ||
2668 | goto err_add_udc; | ||
2669 | } | 2707 | } |
2670 | retval = platform_device_add(the_udc_pdev); | 2708 | for (i = 0; i < mod_data.num; i++) { |
2671 | if (retval < 0) | 2709 | if (!dum[i]->hs_hcd || |
2672 | goto err_add_udc; | 2710 | (!dum[i]->ss_hcd && mod_data.is_super_speed)) { |
2673 | if (!platform_get_drvdata(the_udc_pdev)) { | 2711 | /* |
2674 | /* | 2712 | * The hcd was added successfully but its probe |
2675 | * The udc was added successfully but its probe function failed | 2713 | * function failed for some reason. |
2676 | * for some reason. | 2714 | */ |
2677 | */ | 2715 | retval = -EINVAL; |
2678 | retval = -EINVAL; | 2716 | goto err_add_udc; |
2679 | goto err_probe_udc; | 2717 | } |
2718 | } | ||
2719 | |||
2720 | for (i = 0; i < mod_data.num; i++) { | ||
2721 | retval = platform_device_add(the_udc_pdev[i]); | ||
2722 | if (retval < 0) { | ||
2723 | i--; | ||
2724 | while (i >= 0) | ||
2725 | platform_device_del(the_udc_pdev[i]); | ||
2726 | goto err_add_udc; | ||
2727 | } | ||
2728 | } | ||
2729 | |||
2730 | for (i = 0; i < mod_data.num; i++) { | ||
2731 | if (!platform_get_drvdata(the_udc_pdev[i])) { | ||
2732 | /* | ||
2733 | * The udc was added successfully but its probe | ||
2734 | * function failed for some reason. | ||
2735 | */ | ||
2736 | retval = -EINVAL; | ||
2737 | goto err_probe_udc; | ||
2738 | } | ||
2680 | } | 2739 | } |
2681 | return retval; | 2740 | return retval; |
2682 | 2741 | ||
2683 | err_probe_udc: | 2742 | err_probe_udc: |
2684 | platform_device_del(the_udc_pdev); | 2743 | for (i = 0; i < mod_data.num; i++) |
2744 | platform_device_del(the_udc_pdev[i]); | ||
2685 | err_add_udc: | 2745 | err_add_udc: |
2686 | platform_device_del(the_hcd_pdev); | 2746 | for (i = 0; i < mod_data.num; i++) |
2747 | platform_device_del(the_hcd_pdev[i]); | ||
2687 | err_add_hcd: | 2748 | err_add_hcd: |
2688 | platform_driver_unregister(&dummy_udc_driver); | 2749 | platform_driver_unregister(&dummy_udc_driver); |
2689 | err_register_udc_driver: | 2750 | err_register_udc_driver: |
2690 | platform_driver_unregister(&dummy_hcd_driver); | 2751 | platform_driver_unregister(&dummy_hcd_driver); |
2691 | err_register_hcd_driver: | 2752 | err_add_pdata: |
2692 | platform_device_put(the_udc_pdev); | 2753 | for (i = 0; i < mod_data.num; i++) |
2754 | kfree(dum[i]); | ||
2755 | for (i = 0; i < mod_data.num; i++) | ||
2756 | platform_device_put(the_udc_pdev[i]); | ||
2693 | err_alloc_udc: | 2757 | err_alloc_udc: |
2694 | platform_device_put(the_hcd_pdev); | 2758 | for (i = 0; i < mod_data.num; i++) |
2759 | platform_device_put(the_hcd_pdev[i]); | ||
2695 | return retval; | 2760 | return retval; |
2696 | } | 2761 | } |
2697 | module_init(init); | 2762 | module_init(init); |
2698 | 2763 | ||
2699 | static void __exit cleanup(void) | 2764 | static void __exit cleanup(void) |
2700 | { | 2765 | { |
2701 | platform_device_unregister(the_udc_pdev); | 2766 | int i; |
2702 | platform_device_unregister(the_hcd_pdev); | 2767 | |
2768 | for (i = 0; i < mod_data.num; i++) { | ||
2769 | struct dummy *dum; | ||
2770 | |||
2771 | dum = *((void **)dev_get_platdata(&the_udc_pdev[i]->dev)); | ||
2772 | |||
2773 | platform_device_unregister(the_udc_pdev[i]); | ||
2774 | platform_device_unregister(the_hcd_pdev[i]); | ||
2775 | kfree(dum); | ||
2776 | } | ||
2703 | platform_driver_unregister(&dummy_udc_driver); | 2777 | platform_driver_unregister(&dummy_udc_driver); |
2704 | platform_driver_unregister(&dummy_hcd_driver); | 2778 | platform_driver_unregister(&dummy_hcd_driver); |
2705 | } | 2779 | } |
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index d672250a61fa..549174466c21 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -87,7 +87,7 @@ static inline struct f_acm *port_to_acm(struct gserial *p) | |||
87 | 87 | ||
88 | /* notification endpoint uses smallish and infrequent fixed-size messages */ | 88 | /* notification endpoint uses smallish and infrequent fixed-size messages */ |
89 | 89 | ||
90 | #define GS_LOG2_NOTIFY_INTERVAL 5 /* 1 << 5 == 32 msec */ | 90 | #define GS_NOTIFY_INTERVAL_MS 32 |
91 | #define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */ | 91 | #define GS_NOTIFY_MAXPACKET 10 /* notification + 2 bytes */ |
92 | 92 | ||
93 | /* interface and class descriptors: */ | 93 | /* interface and class descriptors: */ |
@@ -167,7 +167,7 @@ static struct usb_endpoint_descriptor acm_fs_notify_desc = { | |||
167 | .bEndpointAddress = USB_DIR_IN, | 167 | .bEndpointAddress = USB_DIR_IN, |
168 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 168 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
169 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), | 169 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), |
170 | .bInterval = 1 << GS_LOG2_NOTIFY_INTERVAL, | 170 | .bInterval = GS_NOTIFY_INTERVAL_MS, |
171 | }; | 171 | }; |
172 | 172 | ||
173 | static struct usb_endpoint_descriptor acm_fs_in_desc = { | 173 | static struct usb_endpoint_descriptor acm_fs_in_desc = { |
@@ -199,14 +199,13 @@ static struct usb_descriptor_header *acm_fs_function[] = { | |||
199 | }; | 199 | }; |
200 | 200 | ||
201 | /* high speed support: */ | 201 | /* high speed support: */ |
202 | |||
203 | static struct usb_endpoint_descriptor acm_hs_notify_desc = { | 202 | static struct usb_endpoint_descriptor acm_hs_notify_desc = { |
204 | .bLength = USB_DT_ENDPOINT_SIZE, | 203 | .bLength = USB_DT_ENDPOINT_SIZE, |
205 | .bDescriptorType = USB_DT_ENDPOINT, | 204 | .bDescriptorType = USB_DT_ENDPOINT, |
206 | .bEndpointAddress = USB_DIR_IN, | 205 | .bEndpointAddress = USB_DIR_IN, |
207 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 206 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
208 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), | 207 | .wMaxPacketSize = cpu_to_le16(GS_NOTIFY_MAXPACKET), |
209 | .bInterval = GS_LOG2_NOTIFY_INTERVAL+4, | 208 | .bInterval = USB_MS_TO_HS_INTERVAL(GS_NOTIFY_INTERVAL_MS), |
210 | }; | 209 | }; |
211 | 210 | ||
212 | static struct usb_endpoint_descriptor acm_hs_in_desc = { | 211 | static struct usb_endpoint_descriptor acm_hs_in_desc = { |
@@ -659,37 +658,22 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) | |||
659 | acm->notify_req->complete = acm_cdc_notify_complete; | 658 | acm->notify_req->complete = acm_cdc_notify_complete; |
660 | acm->notify_req->context = acm; | 659 | acm->notify_req->context = acm; |
661 | 660 | ||
662 | /* copy descriptors */ | ||
663 | f->descriptors = usb_copy_descriptors(acm_fs_function); | ||
664 | if (!f->descriptors) | ||
665 | goto fail; | ||
666 | |||
667 | /* support all relevant hardware speeds... we expect that when | 661 | /* support all relevant hardware speeds... we expect that when |
668 | * hardware is dual speed, all bulk-capable endpoints work at | 662 | * hardware is dual speed, all bulk-capable endpoints work at |
669 | * both speeds | 663 | * both speeds |
670 | */ | 664 | */ |
671 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 665 | acm_hs_in_desc.bEndpointAddress = acm_fs_in_desc.bEndpointAddress; |
672 | acm_hs_in_desc.bEndpointAddress = | 666 | acm_hs_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress; |
673 | acm_fs_in_desc.bEndpointAddress; | 667 | acm_hs_notify_desc.bEndpointAddress = |
674 | acm_hs_out_desc.bEndpointAddress = | 668 | acm_fs_notify_desc.bEndpointAddress; |
675 | acm_fs_out_desc.bEndpointAddress; | 669 | |
676 | acm_hs_notify_desc.bEndpointAddress = | 670 | acm_ss_in_desc.bEndpointAddress = acm_fs_in_desc.bEndpointAddress; |
677 | acm_fs_notify_desc.bEndpointAddress; | 671 | acm_ss_out_desc.bEndpointAddress = acm_fs_out_desc.bEndpointAddress; |
678 | 672 | ||
679 | /* copy descriptors */ | 673 | status = usb_assign_descriptors(f, acm_fs_function, acm_hs_function, |
680 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); | 674 | acm_ss_function); |
681 | } | 675 | if (status) |
682 | if (gadget_is_superspeed(c->cdev->gadget)) { | 676 | goto fail; |
683 | acm_ss_in_desc.bEndpointAddress = | ||
684 | acm_fs_in_desc.bEndpointAddress; | ||
685 | acm_ss_out_desc.bEndpointAddress = | ||
686 | acm_fs_out_desc.bEndpointAddress; | ||
687 | |||
688 | /* copy descriptors, and track endpoint copies */ | ||
689 | f->ss_descriptors = usb_copy_descriptors(acm_ss_function); | ||
690 | if (!f->ss_descriptors) | ||
691 | goto fail; | ||
692 | } | ||
693 | 677 | ||
694 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", | 678 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", |
695 | acm->port_num, | 679 | acm->port_num, |
@@ -721,11 +705,8 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
721 | { | 705 | { |
722 | struct f_acm *acm = func_to_acm(f); | 706 | struct f_acm *acm = func_to_acm(f); |
723 | 707 | ||
724 | if (gadget_is_dualspeed(c->cdev->gadget)) | 708 | acm_string_defs[0].id = 0; |
725 | usb_free_descriptors(f->hs_descriptors); | 709 | usb_free_all_descriptors(f); |
726 | if (gadget_is_superspeed(c->cdev->gadget)) | ||
727 | usb_free_descriptors(f->ss_descriptors); | ||
728 | usb_free_descriptors(f->descriptors); | ||
729 | gs_free_req(acm->notify, acm->notify_req); | 710 | gs_free_req(acm->notify, acm->notify_req); |
730 | kfree(acm); | 711 | kfree(acm); |
731 | } | 712 | } |
@@ -762,27 +743,15 @@ int acm_bind_config(struct usb_configuration *c, u8 port_num) | |||
762 | */ | 743 | */ |
763 | 744 | ||
764 | /* maybe allocate device-global string IDs, and patch descriptors */ | 745 | /* maybe allocate device-global string IDs, and patch descriptors */ |
765 | if (acm_string_defs[ACM_CTRL_IDX].id == 0) { | 746 | if (acm_string_defs[0].id == 0) { |
766 | status = usb_string_id(c->cdev); | 747 | status = usb_string_ids_tab(c->cdev, acm_string_defs); |
767 | if (status < 0) | 748 | if (status < 0) |
768 | return status; | 749 | return status; |
769 | acm_string_defs[ACM_CTRL_IDX].id = status; | 750 | acm_control_interface_desc.iInterface = |
770 | 751 | acm_string_defs[ACM_CTRL_IDX].id; | |
771 | acm_control_interface_desc.iInterface = status; | 752 | acm_data_interface_desc.iInterface = |
772 | 753 | acm_string_defs[ACM_DATA_IDX].id; | |
773 | status = usb_string_id(c->cdev); | 754 | acm_iad_descriptor.iFunction = acm_string_defs[ACM_IAD_IDX].id; |
774 | if (status < 0) | ||
775 | return status; | ||
776 | acm_string_defs[ACM_DATA_IDX].id = status; | ||
777 | |||
778 | acm_data_interface_desc.iInterface = status; | ||
779 | |||
780 | status = usb_string_id(c->cdev); | ||
781 | if (status < 0) | ||
782 | return status; | ||
783 | acm_string_defs[ACM_IAD_IDX].id = status; | ||
784 | |||
785 | acm_iad_descriptor.iFunction = status; | ||
786 | } | 755 | } |
787 | 756 | ||
788 | /* allocate and initialize one new instance */ | 757 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 95bc94f8e570..83420a310fb7 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -91,7 +91,7 @@ static inline unsigned ecm_bitrate(struct usb_gadget *g) | |||
91 | * encapsulated commands (vendor-specific, using control-OUT). | 91 | * encapsulated commands (vendor-specific, using control-OUT). |
92 | */ | 92 | */ |
93 | 93 | ||
94 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 94 | #define ECM_STATUS_INTERVAL_MS 32 |
95 | #define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ | 95 | #define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ |
96 | 96 | ||
97 | 97 | ||
@@ -192,7 +192,7 @@ static struct usb_endpoint_descriptor fs_ecm_notify_desc = { | |||
192 | .bEndpointAddress = USB_DIR_IN, | 192 | .bEndpointAddress = USB_DIR_IN, |
193 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 193 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
194 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), | 194 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), |
195 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 195 | .bInterval = ECM_STATUS_INTERVAL_MS, |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static struct usb_endpoint_descriptor fs_ecm_in_desc = { | 198 | static struct usb_endpoint_descriptor fs_ecm_in_desc = { |
@@ -239,7 +239,7 @@ static struct usb_endpoint_descriptor hs_ecm_notify_desc = { | |||
239 | .bEndpointAddress = USB_DIR_IN, | 239 | .bEndpointAddress = USB_DIR_IN, |
240 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 240 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
241 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), | 241 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), |
242 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 242 | .bInterval = USB_MS_TO_HS_INTERVAL(ECM_STATUS_INTERVAL_MS), |
243 | }; | 243 | }; |
244 | 244 | ||
245 | static struct usb_endpoint_descriptor hs_ecm_in_desc = { | 245 | static struct usb_endpoint_descriptor hs_ecm_in_desc = { |
@@ -288,7 +288,7 @@ static struct usb_endpoint_descriptor ss_ecm_notify_desc = { | |||
288 | .bEndpointAddress = USB_DIR_IN, | 288 | .bEndpointAddress = USB_DIR_IN, |
289 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 289 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
290 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), | 290 | .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT), |
291 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 291 | .bInterval = USB_MS_TO_HS_INTERVAL(ECM_STATUS_INTERVAL_MS), |
292 | }; | 292 | }; |
293 | 293 | ||
294 | static struct usb_ss_ep_comp_descriptor ss_ecm_intr_comp_desc = { | 294 | static struct usb_ss_ep_comp_descriptor ss_ecm_intr_comp_desc = { |
@@ -330,6 +330,7 @@ static struct usb_ss_ep_comp_descriptor ss_ecm_bulk_comp_desc = { | |||
330 | 330 | ||
331 | static struct usb_descriptor_header *ecm_ss_function[] = { | 331 | static struct usb_descriptor_header *ecm_ss_function[] = { |
332 | /* CDC ECM control descriptors */ | 332 | /* CDC ECM control descriptors */ |
333 | (struct usb_descriptor_header *) &ecm_iad_descriptor, | ||
333 | (struct usb_descriptor_header *) &ecm_control_intf, | 334 | (struct usb_descriptor_header *) &ecm_control_intf, |
334 | (struct usb_descriptor_header *) &ecm_header_desc, | 335 | (struct usb_descriptor_header *) &ecm_header_desc, |
335 | (struct usb_descriptor_header *) &ecm_union_desc, | 336 | (struct usb_descriptor_header *) &ecm_union_desc, |
@@ -353,7 +354,7 @@ static struct usb_descriptor_header *ecm_ss_function[] = { | |||
353 | 354 | ||
354 | static struct usb_string ecm_string_defs[] = { | 355 | static struct usb_string ecm_string_defs[] = { |
355 | [0].s = "CDC Ethernet Control Model (ECM)", | 356 | [0].s = "CDC Ethernet Control Model (ECM)", |
356 | [1].s = NULL /* DYNAMIC */, | 357 | [1].s = "", |
357 | [2].s = "CDC Ethernet Data", | 358 | [2].s = "CDC Ethernet Data", |
358 | [3].s = "CDC ECM", | 359 | [3].s = "CDC ECM", |
359 | { } /* end of list */ | 360 | { } /* end of list */ |
@@ -742,42 +743,24 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
742 | ecm->notify_req->context = ecm; | 743 | ecm->notify_req->context = ecm; |
743 | ecm->notify_req->complete = ecm_notify_complete; | 744 | ecm->notify_req->complete = ecm_notify_complete; |
744 | 745 | ||
745 | /* copy descriptors, and track endpoint copies */ | ||
746 | f->descriptors = usb_copy_descriptors(ecm_fs_function); | ||
747 | if (!f->descriptors) | ||
748 | goto fail; | ||
749 | |||
750 | /* support all relevant hardware speeds... we expect that when | 746 | /* support all relevant hardware speeds... we expect that when |
751 | * hardware is dual speed, all bulk-capable endpoints work at | 747 | * hardware is dual speed, all bulk-capable endpoints work at |
752 | * both speeds | 748 | * both speeds |
753 | */ | 749 | */ |
754 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 750 | hs_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress; |
755 | hs_ecm_in_desc.bEndpointAddress = | 751 | hs_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress; |
756 | fs_ecm_in_desc.bEndpointAddress; | 752 | hs_ecm_notify_desc.bEndpointAddress = |
757 | hs_ecm_out_desc.bEndpointAddress = | 753 | fs_ecm_notify_desc.bEndpointAddress; |
758 | fs_ecm_out_desc.bEndpointAddress; | 754 | |
759 | hs_ecm_notify_desc.bEndpointAddress = | 755 | ss_ecm_in_desc.bEndpointAddress = fs_ecm_in_desc.bEndpointAddress; |
760 | fs_ecm_notify_desc.bEndpointAddress; | 756 | ss_ecm_out_desc.bEndpointAddress = fs_ecm_out_desc.bEndpointAddress; |
761 | 757 | ss_ecm_notify_desc.bEndpointAddress = | |
762 | /* copy descriptors, and track endpoint copies */ | 758 | fs_ecm_notify_desc.bEndpointAddress; |
763 | f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); | 759 | |
764 | if (!f->hs_descriptors) | 760 | status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function, |
765 | goto fail; | 761 | ecm_ss_function); |
766 | } | 762 | if (status) |
767 | 763 | goto fail; | |
768 | if (gadget_is_superspeed(c->cdev->gadget)) { | ||
769 | ss_ecm_in_desc.bEndpointAddress = | ||
770 | fs_ecm_in_desc.bEndpointAddress; | ||
771 | ss_ecm_out_desc.bEndpointAddress = | ||
772 | fs_ecm_out_desc.bEndpointAddress; | ||
773 | ss_ecm_notify_desc.bEndpointAddress = | ||
774 | fs_ecm_notify_desc.bEndpointAddress; | ||
775 | |||
776 | /* copy descriptors, and track endpoint copies */ | ||
777 | f->ss_descriptors = usb_copy_descriptors(ecm_ss_function); | ||
778 | if (!f->ss_descriptors) | ||
779 | goto fail; | ||
780 | } | ||
781 | 764 | ||
782 | /* NOTE: all that is done without knowing or caring about | 765 | /* NOTE: all that is done without knowing or caring about |
783 | * the network link ... which is unavailable to this code | 766 | * the network link ... which is unavailable to this code |
@@ -795,11 +778,6 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
795 | return 0; | 778 | return 0; |
796 | 779 | ||
797 | fail: | 780 | fail: |
798 | if (f->descriptors) | ||
799 | usb_free_descriptors(f->descriptors); | ||
800 | if (f->hs_descriptors) | ||
801 | usb_free_descriptors(f->hs_descriptors); | ||
802 | |||
803 | if (ecm->notify_req) { | 781 | if (ecm->notify_req) { |
804 | kfree(ecm->notify_req->buf); | 782 | kfree(ecm->notify_req->buf); |
805 | usb_ep_free_request(ecm->notify, ecm->notify_req); | 783 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
@@ -808,9 +786,9 @@ fail: | |||
808 | /* we might as well release our claims on endpoints */ | 786 | /* we might as well release our claims on endpoints */ |
809 | if (ecm->notify) | 787 | if (ecm->notify) |
810 | ecm->notify->driver_data = NULL; | 788 | ecm->notify->driver_data = NULL; |
811 | if (ecm->port.out_ep->desc) | 789 | if (ecm->port.out_ep) |
812 | ecm->port.out_ep->driver_data = NULL; | 790 | ecm->port.out_ep->driver_data = NULL; |
813 | if (ecm->port.in_ep->desc) | 791 | if (ecm->port.in_ep) |
814 | ecm->port.in_ep->driver_data = NULL; | 792 | ecm->port.in_ep->driver_data = NULL; |
815 | 793 | ||
816 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); | 794 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); |
@@ -825,16 +803,11 @@ ecm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
825 | 803 | ||
826 | DBG(c->cdev, "ecm unbind\n"); | 804 | DBG(c->cdev, "ecm unbind\n"); |
827 | 805 | ||
828 | if (gadget_is_superspeed(c->cdev->gadget)) | 806 | ecm_string_defs[0].id = 0; |
829 | usb_free_descriptors(f->ss_descriptors); | 807 | usb_free_all_descriptors(f); |
830 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
831 | usb_free_descriptors(f->hs_descriptors); | ||
832 | usb_free_descriptors(f->descriptors); | ||
833 | 808 | ||
834 | kfree(ecm->notify_req->buf); | 809 | kfree(ecm->notify_req->buf); |
835 | usb_ep_free_request(ecm->notify, ecm->notify_req); | 810 | usb_ep_free_request(ecm->notify, ecm->notify_req); |
836 | |||
837 | ecm_string_defs[1].s = NULL; | ||
838 | kfree(ecm); | 811 | kfree(ecm); |
839 | } | 812 | } |
840 | 813 | ||
@@ -859,36 +832,15 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
859 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) | 832 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) |
860 | return -EINVAL; | 833 | return -EINVAL; |
861 | 834 | ||
862 | /* maybe allocate device-global string IDs */ | ||
863 | if (ecm_string_defs[0].id == 0) { | 835 | if (ecm_string_defs[0].id == 0) { |
864 | 836 | status = usb_string_ids_tab(c->cdev, ecm_string_defs); | |
865 | /* control interface label */ | 837 | if (status) |
866 | status = usb_string_id(c->cdev); | ||
867 | if (status < 0) | ||
868 | return status; | ||
869 | ecm_string_defs[0].id = status; | ||
870 | ecm_control_intf.iInterface = status; | ||
871 | |||
872 | /* data interface label */ | ||
873 | status = usb_string_id(c->cdev); | ||
874 | if (status < 0) | ||
875 | return status; | 838 | return status; |
876 | ecm_string_defs[2].id = status; | ||
877 | ecm_data_intf.iInterface = status; | ||
878 | 839 | ||
879 | /* MAC address */ | 840 | ecm_control_intf.iInterface = ecm_string_defs[0].id; |
880 | status = usb_string_id(c->cdev); | 841 | ecm_data_intf.iInterface = ecm_string_defs[2].id; |
881 | if (status < 0) | 842 | ecm_desc.iMACAddress = ecm_string_defs[1].id; |
882 | return status; | 843 | ecm_iad_descriptor.iFunction = ecm_string_defs[3].id; |
883 | ecm_string_defs[1].id = status; | ||
884 | ecm_desc.iMACAddress = status; | ||
885 | |||
886 | /* IAD label */ | ||
887 | status = usb_string_id(c->cdev); | ||
888 | if (status < 0) | ||
889 | return status; | ||
890 | ecm_string_defs[3].id = status; | ||
891 | ecm_iad_descriptor.iFunction = status; | ||
892 | } | 844 | } |
893 | 845 | ||
894 | /* allocate and initialize one new instance */ | 846 | /* allocate and initialize one new instance */ |
@@ -913,9 +865,7 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
913 | ecm->port.func.disable = ecm_disable; | 865 | ecm->port.func.disable = ecm_disable; |
914 | 866 | ||
915 | status = usb_add_function(c, &ecm->port.func); | 867 | status = usb_add_function(c, &ecm->port.func); |
916 | if (status) { | 868 | if (status) |
917 | ecm_string_defs[1].s = NULL; | ||
918 | kfree(ecm); | 869 | kfree(ecm); |
919 | } | ||
920 | return status; | 870 | return status; |
921 | } | 871 | } |
diff --git a/drivers/usb/gadget/f_eem.c b/drivers/usb/gadget/f_eem.c index 1a7b2dd7d408..cf0ebee85563 100644 --- a/drivers/usb/gadget/f_eem.c +++ b/drivers/usb/gadget/f_eem.c | |||
@@ -274,38 +274,20 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
274 | 274 | ||
275 | status = -ENOMEM; | 275 | status = -ENOMEM; |
276 | 276 | ||
277 | /* copy descriptors, and track endpoint copies */ | ||
278 | f->descriptors = usb_copy_descriptors(eem_fs_function); | ||
279 | if (!f->descriptors) | ||
280 | goto fail; | ||
281 | |||
282 | /* support all relevant hardware speeds... we expect that when | 277 | /* support all relevant hardware speeds... we expect that when |
283 | * hardware is dual speed, all bulk-capable endpoints work at | 278 | * hardware is dual speed, all bulk-capable endpoints work at |
284 | * both speeds | 279 | * both speeds |
285 | */ | 280 | */ |
286 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 281 | eem_hs_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress; |
287 | eem_hs_in_desc.bEndpointAddress = | 282 | eem_hs_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
288 | eem_fs_in_desc.bEndpointAddress; | ||
289 | eem_hs_out_desc.bEndpointAddress = | ||
290 | eem_fs_out_desc.bEndpointAddress; | ||
291 | |||
292 | /* copy descriptors, and track endpoint copies */ | ||
293 | f->hs_descriptors = usb_copy_descriptors(eem_hs_function); | ||
294 | if (!f->hs_descriptors) | ||
295 | goto fail; | ||
296 | } | ||
297 | 283 | ||
298 | if (gadget_is_superspeed(c->cdev->gadget)) { | 284 | eem_ss_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress; |
299 | eem_ss_in_desc.bEndpointAddress = | 285 | eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; |
300 | eem_fs_in_desc.bEndpointAddress; | ||
301 | eem_ss_out_desc.bEndpointAddress = | ||
302 | eem_fs_out_desc.bEndpointAddress; | ||
303 | 286 | ||
304 | /* copy descriptors, and track endpoint copies */ | 287 | status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function, |
305 | f->ss_descriptors = usb_copy_descriptors(eem_ss_function); | 288 | eem_ss_function); |
306 | if (!f->ss_descriptors) | 289 | if (status) |
307 | goto fail; | 290 | goto fail; |
308 | } | ||
309 | 291 | ||
310 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", | 292 | DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", |
311 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | 293 | gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -314,15 +296,10 @@ eem_bind(struct usb_configuration *c, struct usb_function *f) | |||
314 | return 0; | 296 | return 0; |
315 | 297 | ||
316 | fail: | 298 | fail: |
317 | if (f->descriptors) | 299 | usb_free_all_descriptors(f); |
318 | usb_free_descriptors(f->descriptors); | 300 | if (eem->port.out_ep) |
319 | if (f->hs_descriptors) | ||
320 | usb_free_descriptors(f->hs_descriptors); | ||
321 | |||
322 | /* we might as well release our claims on endpoints */ | ||
323 | if (eem->port.out_ep->desc) | ||
324 | eem->port.out_ep->driver_data = NULL; | 301 | eem->port.out_ep->driver_data = NULL; |
325 | if (eem->port.in_ep->desc) | 302 | if (eem->port.in_ep) |
326 | eem->port.in_ep->driver_data = NULL; | 303 | eem->port.in_ep->driver_data = NULL; |
327 | 304 | ||
328 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); | 305 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); |
@@ -337,11 +314,7 @@ eem_unbind(struct usb_configuration *c, struct usb_function *f) | |||
337 | 314 | ||
338 | DBG(c->cdev, "eem unbind\n"); | 315 | DBG(c->cdev, "eem unbind\n"); |
339 | 316 | ||
340 | if (gadget_is_superspeed(c->cdev->gadget)) | 317 | usb_free_all_descriptors(f); |
341 | usb_free_descriptors(f->ss_descriptors); | ||
342 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
343 | usb_free_descriptors(f->hs_descriptors); | ||
344 | usb_free_descriptors(f->descriptors); | ||
345 | kfree(eem); | 318 | kfree(eem); |
346 | } | 319 | } |
347 | 320 | ||
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 64c4ec10d1fc..4a6961c517f2 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -2097,7 +2097,7 @@ static int __ffs_func_bind_do_descs(enum ffs_entity_type type, u8 *valuep, | |||
2097 | if (isHS) | 2097 | if (isHS) |
2098 | func->function.hs_descriptors[(long)valuep] = desc; | 2098 | func->function.hs_descriptors[(long)valuep] = desc; |
2099 | else | 2099 | else |
2100 | func->function.descriptors[(long)valuep] = desc; | 2100 | func->function.fs_descriptors[(long)valuep] = desc; |
2101 | 2101 | ||
2102 | if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) | 2102 | if (!desc || desc->bDescriptorType != USB_DT_ENDPOINT) |
2103 | return 0; | 2103 | return 0; |
@@ -2249,7 +2249,7 @@ static int ffs_func_bind(struct usb_configuration *c, | |||
2249 | * numbers without worrying that it may be described later on. | 2249 | * numbers without worrying that it may be described later on. |
2250 | */ | 2250 | */ |
2251 | if (likely(full)) { | 2251 | if (likely(full)) { |
2252 | func->function.descriptors = data->fs_descs; | 2252 | func->function.fs_descriptors = data->fs_descs; |
2253 | ret = ffs_do_descs(ffs->fs_descs_count, | 2253 | ret = ffs_do_descs(ffs->fs_descs_count, |
2254 | data->raw_descs, | 2254 | data->raw_descs, |
2255 | sizeof data->raw_descs, | 2255 | sizeof data->raw_descs, |
diff --git a/drivers/usb/gadget/f_hid.c b/drivers/usb/gadget/f_hid.c index 511e527178e2..6e69a8e8d22a 100644 --- a/drivers/usb/gadget/f_hid.c +++ b/drivers/usb/gadget/f_hid.c | |||
@@ -573,7 +573,6 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
573 | goto fail; | 573 | goto fail; |
574 | hidg_interface_desc.bInterfaceNumber = status; | 574 | hidg_interface_desc.bInterfaceNumber = status; |
575 | 575 | ||
576 | |||
577 | /* allocate instance-specific endpoints */ | 576 | /* allocate instance-specific endpoints */ |
578 | status = -ENODEV; | 577 | status = -ENODEV; |
579 | ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_in_ep_desc); | 578 | ep = usb_ep_autoconfig(c->cdev->gadget, &hidg_fs_in_ep_desc); |
@@ -609,20 +608,15 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) | |||
609 | hidg_desc.desc[0].wDescriptorLength = | 608 | hidg_desc.desc[0].wDescriptorLength = |
610 | cpu_to_le16(hidg->report_desc_length); | 609 | cpu_to_le16(hidg->report_desc_length); |
611 | 610 | ||
612 | /* copy descriptors */ | 611 | hidg_hs_in_ep_desc.bEndpointAddress = |
613 | f->descriptors = usb_copy_descriptors(hidg_fs_descriptors); | 612 | hidg_fs_in_ep_desc.bEndpointAddress; |
614 | if (!f->descriptors) | 613 | hidg_hs_out_ep_desc.bEndpointAddress = |
615 | goto fail; | 614 | hidg_fs_out_ep_desc.bEndpointAddress; |
616 | 615 | ||
617 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 616 | status = usb_assign_descriptors(f, hidg_fs_descriptors, |
618 | hidg_hs_in_ep_desc.bEndpointAddress = | 617 | hidg_hs_descriptors, NULL); |
619 | hidg_fs_in_ep_desc.bEndpointAddress; | 618 | if (status) |
620 | hidg_hs_out_ep_desc.bEndpointAddress = | 619 | goto fail; |
621 | hidg_fs_out_ep_desc.bEndpointAddress; | ||
622 | f->hs_descriptors = usb_copy_descriptors(hidg_hs_descriptors); | ||
623 | if (!f->hs_descriptors) | ||
624 | goto fail; | ||
625 | } | ||
626 | 620 | ||
627 | mutex_init(&hidg->lock); | 621 | mutex_init(&hidg->lock); |
628 | spin_lock_init(&hidg->spinlock); | 622 | spin_lock_init(&hidg->spinlock); |
@@ -649,9 +643,7 @@ fail: | |||
649 | usb_ep_free_request(hidg->in_ep, hidg->req); | 643 | usb_ep_free_request(hidg->in_ep, hidg->req); |
650 | } | 644 | } |
651 | 645 | ||
652 | usb_free_descriptors(f->hs_descriptors); | 646 | usb_free_all_descriptors(f); |
653 | usb_free_descriptors(f->descriptors); | ||
654 | |||
655 | return status; | 647 | return status; |
656 | } | 648 | } |
657 | 649 | ||
@@ -668,9 +660,7 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
668 | kfree(hidg->req->buf); | 660 | kfree(hidg->req->buf); |
669 | usb_ep_free_request(hidg->in_ep, hidg->req); | 661 | usb_ep_free_request(hidg->in_ep, hidg->req); |
670 | 662 | ||
671 | /* free descriptors copies */ | 663 | usb_free_all_descriptors(f); |
672 | usb_free_descriptors(f->hs_descriptors); | ||
673 | usb_free_descriptors(f->descriptors); | ||
674 | 664 | ||
675 | kfree(hidg->report_desc); | 665 | kfree(hidg->report_desc); |
676 | kfree(hidg); | 666 | kfree(hidg); |
diff --git a/drivers/usb/gadget/f_loopback.c b/drivers/usb/gadget/f_loopback.c index 7275706caeb0..bb39cb2bb3a3 100644 --- a/drivers/usb/gadget/f_loopback.c +++ b/drivers/usb/gadget/f_loopback.c | |||
@@ -177,6 +177,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f) | |||
177 | struct usb_composite_dev *cdev = c->cdev; | 177 | struct usb_composite_dev *cdev = c->cdev; |
178 | struct f_loopback *loop = func_to_loop(f); | 178 | struct f_loopback *loop = func_to_loop(f); |
179 | int id; | 179 | int id; |
180 | int ret; | ||
180 | 181 | ||
181 | /* allocate interface ID(s) */ | 182 | /* allocate interface ID(s) */ |
182 | id = usb_interface_id(c, f); | 183 | id = usb_interface_id(c, f); |
@@ -201,22 +202,19 @@ autoconf_fail: | |||
201 | loop->out_ep->driver_data = cdev; /* claim */ | 202 | loop->out_ep->driver_data = cdev; /* claim */ |
202 | 203 | ||
203 | /* support high speed hardware */ | 204 | /* support high speed hardware */ |
204 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 205 | hs_loop_source_desc.bEndpointAddress = |
205 | hs_loop_source_desc.bEndpointAddress = | 206 | fs_loop_source_desc.bEndpointAddress; |
206 | fs_loop_source_desc.bEndpointAddress; | 207 | hs_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress; |
207 | hs_loop_sink_desc.bEndpointAddress = | ||
208 | fs_loop_sink_desc.bEndpointAddress; | ||
209 | f->hs_descriptors = hs_loopback_descs; | ||
210 | } | ||
211 | 208 | ||
212 | /* support super speed hardware */ | 209 | /* support super speed hardware */ |
213 | if (gadget_is_superspeed(c->cdev->gadget)) { | 210 | ss_loop_source_desc.bEndpointAddress = |
214 | ss_loop_source_desc.bEndpointAddress = | 211 | fs_loop_source_desc.bEndpointAddress; |
215 | fs_loop_source_desc.bEndpointAddress; | 212 | ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress; |
216 | ss_loop_sink_desc.bEndpointAddress = | 213 | |
217 | fs_loop_sink_desc.bEndpointAddress; | 214 | ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs, |
218 | f->ss_descriptors = ss_loopback_descs; | 215 | ss_loopback_descs); |
219 | } | 216 | if (ret) |
217 | return ret; | ||
220 | 218 | ||
221 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", | 219 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", |
222 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : | 220 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -228,6 +226,7 @@ autoconf_fail: | |||
228 | static void | 226 | static void |
229 | loopback_unbind(struct usb_configuration *c, struct usb_function *f) | 227 | loopback_unbind(struct usb_configuration *c, struct usb_function *f) |
230 | { | 228 | { |
229 | usb_free_all_descriptors(f); | ||
231 | kfree(func_to_loop(f)); | 230 | kfree(func_to_loop(f)); |
232 | } | 231 | } |
233 | 232 | ||
@@ -379,7 +378,6 @@ static int __init loopback_bind_config(struct usb_configuration *c) | |||
379 | return -ENOMEM; | 378 | return -ENOMEM; |
380 | 379 | ||
381 | loop->function.name = "loopback"; | 380 | loop->function.name = "loopback"; |
382 | loop->function.descriptors = fs_loopback_descs; | ||
383 | loop->function.bind = loopback_bind; | 381 | loop->function.bind = loopback_bind; |
384 | loop->function.unbind = loopback_unbind; | 382 | loop->function.unbind = loopback_unbind; |
385 | loop->function.set_alt = loopback_set_alt; | 383 | loop->function.set_alt = loopback_set_alt; |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 3a7668bde3ef..5d027b3e1ef0 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -228,10 +228,6 @@ | |||
228 | 228 | ||
229 | static const char fsg_string_interface[] = "Mass Storage"; | 229 | static const char fsg_string_interface[] = "Mass Storage"; |
230 | 230 | ||
231 | #define FSG_NO_DEVICE_STRINGS 1 | ||
232 | #define FSG_NO_OTG 1 | ||
233 | #define FSG_NO_INTR_EP 1 | ||
234 | |||
235 | #include "storage_common.c" | 231 | #include "storage_common.c" |
236 | 232 | ||
237 | 233 | ||
@@ -2904,9 +2900,7 @@ static void fsg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
2904 | } | 2900 | } |
2905 | 2901 | ||
2906 | fsg_common_put(common); | 2902 | fsg_common_put(common); |
2907 | usb_free_descriptors(fsg->function.descriptors); | 2903 | usb_free_all_descriptors(&fsg->function); |
2908 | usb_free_descriptors(fsg->function.hs_descriptors); | ||
2909 | usb_free_descriptors(fsg->function.ss_descriptors); | ||
2910 | kfree(fsg); | 2904 | kfree(fsg); |
2911 | } | 2905 | } |
2912 | 2906 | ||
@@ -2916,6 +2910,8 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2916 | struct usb_gadget *gadget = c->cdev->gadget; | 2910 | struct usb_gadget *gadget = c->cdev->gadget; |
2917 | int i; | 2911 | int i; |
2918 | struct usb_ep *ep; | 2912 | struct usb_ep *ep; |
2913 | unsigned max_burst; | ||
2914 | int ret; | ||
2919 | 2915 | ||
2920 | fsg->gadget = gadget; | 2916 | fsg->gadget = gadget; |
2921 | 2917 | ||
@@ -2939,45 +2935,27 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2939 | ep->driver_data = fsg->common; /* claim the endpoint */ | 2935 | ep->driver_data = fsg->common; /* claim the endpoint */ |
2940 | fsg->bulk_out = ep; | 2936 | fsg->bulk_out = ep; |
2941 | 2937 | ||
2942 | /* Copy descriptors */ | 2938 | /* Assume endpoint addresses are the same for both speeds */ |
2943 | f->descriptors = usb_copy_descriptors(fsg_fs_function); | 2939 | fsg_hs_bulk_in_desc.bEndpointAddress = |
2944 | if (unlikely(!f->descriptors)) | 2940 | fsg_fs_bulk_in_desc.bEndpointAddress; |
2945 | return -ENOMEM; | 2941 | fsg_hs_bulk_out_desc.bEndpointAddress = |
2946 | 2942 | fsg_fs_bulk_out_desc.bEndpointAddress; | |
2947 | if (gadget_is_dualspeed(gadget)) { | ||
2948 | /* Assume endpoint addresses are the same for both speeds */ | ||
2949 | fsg_hs_bulk_in_desc.bEndpointAddress = | ||
2950 | fsg_fs_bulk_in_desc.bEndpointAddress; | ||
2951 | fsg_hs_bulk_out_desc.bEndpointAddress = | ||
2952 | fsg_fs_bulk_out_desc.bEndpointAddress; | ||
2953 | f->hs_descriptors = usb_copy_descriptors(fsg_hs_function); | ||
2954 | if (unlikely(!f->hs_descriptors)) { | ||
2955 | usb_free_descriptors(f->descriptors); | ||
2956 | return -ENOMEM; | ||
2957 | } | ||
2958 | } | ||
2959 | |||
2960 | if (gadget_is_superspeed(gadget)) { | ||
2961 | unsigned max_burst; | ||
2962 | 2943 | ||
2963 | /* Calculate bMaxBurst, we know packet size is 1024 */ | 2944 | /* Calculate bMaxBurst, we know packet size is 1024 */ |
2964 | max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15); | 2945 | max_burst = min_t(unsigned, FSG_BUFLEN / 1024, 15); |
2965 | 2946 | ||
2966 | fsg_ss_bulk_in_desc.bEndpointAddress = | 2947 | fsg_ss_bulk_in_desc.bEndpointAddress = |
2967 | fsg_fs_bulk_in_desc.bEndpointAddress; | 2948 | fsg_fs_bulk_in_desc.bEndpointAddress; |
2968 | fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; | 2949 | fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; |
2969 | 2950 | ||
2970 | fsg_ss_bulk_out_desc.bEndpointAddress = | 2951 | fsg_ss_bulk_out_desc.bEndpointAddress = |
2971 | fsg_fs_bulk_out_desc.bEndpointAddress; | 2952 | fsg_fs_bulk_out_desc.bEndpointAddress; |
2972 | fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; | 2953 | fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; |
2973 | 2954 | ||
2974 | f->ss_descriptors = usb_copy_descriptors(fsg_ss_function); | 2955 | ret = usb_assign_descriptors(f, fsg_fs_function, fsg_hs_function, |
2975 | if (unlikely(!f->ss_descriptors)) { | 2956 | fsg_ss_function); |
2976 | usb_free_descriptors(f->hs_descriptors); | 2957 | if (ret) |
2977 | usb_free_descriptors(f->descriptors); | 2958 | goto autoconf_fail; |
2978 | return -ENOMEM; | ||
2979 | } | ||
2980 | } | ||
2981 | 2959 | ||
2982 | return 0; | 2960 | return 0; |
2983 | 2961 | ||
@@ -2986,7 +2964,6 @@ autoconf_fail: | |||
2986 | return -ENOTSUPP; | 2964 | return -ENOTSUPP; |
2987 | } | 2965 | } |
2988 | 2966 | ||
2989 | |||
2990 | /****************************** ADD FUNCTION ******************************/ | 2967 | /****************************** ADD FUNCTION ******************************/ |
2991 | 2968 | ||
2992 | static struct usb_gadget_strings *fsg_strings_array[] = { | 2969 | static struct usb_gadget_strings *fsg_strings_array[] = { |
diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c index 8ed1259fe80d..263e721c2694 100644 --- a/drivers/usb/gadget/f_midi.c +++ b/drivers/usb/gadget/f_midi.c | |||
@@ -414,7 +414,7 @@ static void f_midi_unbind(struct usb_configuration *c, struct usb_function *f) | |||
414 | kfree(midi->id); | 414 | kfree(midi->id); |
415 | midi->id = NULL; | 415 | midi->id = NULL; |
416 | 416 | ||
417 | usb_free_descriptors(f->descriptors); | 417 | usb_free_all_descriptors(f); |
418 | kfree(midi); | 418 | kfree(midi); |
419 | } | 419 | } |
420 | 420 | ||
@@ -881,19 +881,25 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
881 | * both speeds | 881 | * both speeds |
882 | */ | 882 | */ |
883 | /* copy descriptors, and track endpoint copies */ | 883 | /* copy descriptors, and track endpoint copies */ |
884 | f->fs_descriptors = usb_copy_descriptors(midi_function); | ||
885 | if (!f->fs_descriptors) | ||
886 | goto fail_f_midi; | ||
887 | |||
884 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 888 | if (gadget_is_dualspeed(c->cdev->gadget)) { |
885 | c->highspeed = true; | ||
886 | bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); | 889 | bulk_in_desc.wMaxPacketSize = cpu_to_le16(512); |
887 | bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); | 890 | bulk_out_desc.wMaxPacketSize = cpu_to_le16(512); |
888 | f->hs_descriptors = usb_copy_descriptors(midi_function); | 891 | f->hs_descriptors = usb_copy_descriptors(midi_function); |
889 | } else { | 892 | if (!f->hs_descriptors) |
890 | f->descriptors = usb_copy_descriptors(midi_function); | 893 | goto fail_f_midi; |
891 | } | 894 | } |
892 | 895 | ||
893 | kfree(midi_function); | 896 | kfree(midi_function); |
894 | 897 | ||
895 | return 0; | 898 | return 0; |
896 | 899 | ||
900 | fail_f_midi: | ||
901 | kfree(midi_function); | ||
902 | usb_free_descriptors(f->hs_descriptors); | ||
897 | fail: | 903 | fail: |
898 | /* we might as well release our claims on endpoints */ | 904 | /* we might as well release our claims on endpoints */ |
899 | if (midi->out_ep) | 905 | if (midi->out_ep) |
diff --git a/drivers/usb/gadget/f_ncm.c b/drivers/usb/gadget/f_ncm.c index b651b529c67f..6c8362f937be 100644 --- a/drivers/usb/gadget/f_ncm.c +++ b/drivers/usb/gadget/f_ncm.c | |||
@@ -102,7 +102,7 @@ static inline unsigned ncm_bitrate(struct usb_gadget *g) | |||
102 | USB_CDC_NCM_NTB32_SUPPORTED) | 102 | USB_CDC_NCM_NTB32_SUPPORTED) |
103 | 103 | ||
104 | static struct usb_cdc_ncm_ntb_parameters ntb_parameters = { | 104 | static struct usb_cdc_ncm_ntb_parameters ntb_parameters = { |
105 | .wLength = sizeof ntb_parameters, | 105 | .wLength = cpu_to_le16(sizeof(ntb_parameters)), |
106 | .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED), | 106 | .bmNtbFormatsSupported = cpu_to_le16(FORMATS_SUPPORTED), |
107 | .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE), | 107 | .dwNtbInMaxSize = cpu_to_le32(NTB_DEFAULT_IN_SIZE), |
108 | .wNdpInDivisor = cpu_to_le16(4), | 108 | .wNdpInDivisor = cpu_to_le16(4), |
@@ -121,7 +121,7 @@ static struct usb_cdc_ncm_ntb_parameters ntb_parameters = { | |||
121 | * waste less bandwidth. | 121 | * waste less bandwidth. |
122 | */ | 122 | */ |
123 | 123 | ||
124 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 124 | #define NCM_STATUS_INTERVAL_MS 32 |
125 | #define NCM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ | 125 | #define NCM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ |
126 | 126 | ||
127 | static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = { | 127 | static struct usb_interface_assoc_descriptor ncm_iad_desc __initdata = { |
@@ -230,7 +230,7 @@ static struct usb_endpoint_descriptor fs_ncm_notify_desc __initdata = { | |||
230 | .bEndpointAddress = USB_DIR_IN, | 230 | .bEndpointAddress = USB_DIR_IN, |
231 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 231 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
232 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), | 232 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), |
233 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 233 | .bInterval = NCM_STATUS_INTERVAL_MS, |
234 | }; | 234 | }; |
235 | 235 | ||
236 | static struct usb_endpoint_descriptor fs_ncm_in_desc __initdata = { | 236 | static struct usb_endpoint_descriptor fs_ncm_in_desc __initdata = { |
@@ -275,7 +275,7 @@ static struct usb_endpoint_descriptor hs_ncm_notify_desc __initdata = { | |||
275 | .bEndpointAddress = USB_DIR_IN, | 275 | .bEndpointAddress = USB_DIR_IN, |
276 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 276 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
277 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), | 277 | .wMaxPacketSize = cpu_to_le16(NCM_STATUS_BYTECOUNT), |
278 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 278 | .bInterval = USB_MS_TO_HS_INTERVAL(NCM_STATUS_INTERVAL_MS), |
279 | }; | 279 | }; |
280 | static struct usb_endpoint_descriptor hs_ncm_in_desc __initdata = { | 280 | static struct usb_endpoint_descriptor hs_ncm_in_desc __initdata = { |
281 | .bLength = USB_DT_ENDPOINT_SIZE, | 281 | .bLength = USB_DT_ENDPOINT_SIZE, |
@@ -321,7 +321,7 @@ static struct usb_descriptor_header *ncm_hs_function[] __initdata = { | |||
321 | 321 | ||
322 | static struct usb_string ncm_string_defs[] = { | 322 | static struct usb_string ncm_string_defs[] = { |
323 | [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)", | 323 | [STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)", |
324 | [STRING_MAC_IDX].s = NULL /* DYNAMIC */, | 324 | [STRING_MAC_IDX].s = "", |
325 | [STRING_DATA_IDX].s = "CDC Network Data", | 325 | [STRING_DATA_IDX].s = "CDC Network Data", |
326 | [STRING_IAD_IDX].s = "CDC NCM", | 326 | [STRING_IAD_IDX].s = "CDC NCM", |
327 | { } /* end of list */ | 327 | { } /* end of list */ |
@@ -869,15 +869,19 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, | |||
869 | struct sk_buff *skb2; | 869 | struct sk_buff *skb2; |
870 | int ncb_len = 0; | 870 | int ncb_len = 0; |
871 | __le16 *tmp; | 871 | __le16 *tmp; |
872 | int div = ntb_parameters.wNdpInDivisor; | 872 | int div; |
873 | int rem = ntb_parameters.wNdpInPayloadRemainder; | 873 | int rem; |
874 | int pad; | 874 | int pad; |
875 | int ndp_align = ntb_parameters.wNdpInAlignment; | 875 | int ndp_align; |
876 | int ndp_pad; | 876 | int ndp_pad; |
877 | unsigned max_size = ncm->port.fixed_in_len; | 877 | unsigned max_size = ncm->port.fixed_in_len; |
878 | struct ndp_parser_opts *opts = ncm->parser_opts; | 878 | struct ndp_parser_opts *opts = ncm->parser_opts; |
879 | unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; | 879 | unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; |
880 | 880 | ||
881 | div = le16_to_cpu(ntb_parameters.wNdpInDivisor); | ||
882 | rem = le16_to_cpu(ntb_parameters.wNdpInPayloadRemainder); | ||
883 | ndp_align = le16_to_cpu(ntb_parameters.wNdpInAlignment); | ||
884 | |||
881 | ncb_len += opts->nth_size; | 885 | ncb_len += opts->nth_size; |
882 | ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len; | 886 | ndp_pad = ALIGN(ncb_len, ndp_align) - ncb_len; |
883 | ncb_len += ndp_pad; | 887 | ncb_len += ndp_pad; |
@@ -1208,30 +1212,18 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1208 | ncm->notify_req->context = ncm; | 1212 | ncm->notify_req->context = ncm; |
1209 | ncm->notify_req->complete = ncm_notify_complete; | 1213 | ncm->notify_req->complete = ncm_notify_complete; |
1210 | 1214 | ||
1211 | /* copy descriptors, and track endpoint copies */ | ||
1212 | f->descriptors = usb_copy_descriptors(ncm_fs_function); | ||
1213 | if (!f->descriptors) | ||
1214 | goto fail; | ||
1215 | |||
1216 | /* | 1215 | /* |
1217 | * support all relevant hardware speeds... we expect that when | 1216 | * support all relevant hardware speeds... we expect that when |
1218 | * hardware is dual speed, all bulk-capable endpoints work at | 1217 | * hardware is dual speed, all bulk-capable endpoints work at |
1219 | * both speeds | 1218 | * both speeds |
1220 | */ | 1219 | */ |
1221 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 1220 | hs_ncm_in_desc.bEndpointAddress = fs_ncm_in_desc.bEndpointAddress; |
1222 | hs_ncm_in_desc.bEndpointAddress = | 1221 | hs_ncm_out_desc.bEndpointAddress = fs_ncm_out_desc.bEndpointAddress; |
1223 | fs_ncm_in_desc.bEndpointAddress; | 1222 | hs_ncm_notify_desc.bEndpointAddress = |
1224 | hs_ncm_out_desc.bEndpointAddress = | 1223 | fs_ncm_notify_desc.bEndpointAddress; |
1225 | fs_ncm_out_desc.bEndpointAddress; | ||
1226 | hs_ncm_notify_desc.bEndpointAddress = | ||
1227 | fs_ncm_notify_desc.bEndpointAddress; | ||
1228 | |||
1229 | /* copy descriptors, and track endpoint copies */ | ||
1230 | f->hs_descriptors = usb_copy_descriptors(ncm_hs_function); | ||
1231 | if (!f->hs_descriptors) | ||
1232 | goto fail; | ||
1233 | } | ||
1234 | 1224 | ||
1225 | status = usb_assign_descriptors(f, ncm_fs_function, ncm_hs_function, | ||
1226 | NULL); | ||
1235 | /* | 1227 | /* |
1236 | * NOTE: all that is done without knowing or caring about | 1228 | * NOTE: all that is done without knowing or caring about |
1237 | * the network link ... which is unavailable to this code | 1229 | * the network link ... which is unavailable to this code |
@@ -1248,9 +1240,7 @@ ncm_bind(struct usb_configuration *c, struct usb_function *f) | |||
1248 | return 0; | 1240 | return 0; |
1249 | 1241 | ||
1250 | fail: | 1242 | fail: |
1251 | if (f->descriptors) | 1243 | usb_free_all_descriptors(f); |
1252 | usb_free_descriptors(f->descriptors); | ||
1253 | |||
1254 | if (ncm->notify_req) { | 1244 | if (ncm->notify_req) { |
1255 | kfree(ncm->notify_req->buf); | 1245 | kfree(ncm->notify_req->buf); |
1256 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1246 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
@@ -1259,9 +1249,9 @@ fail: | |||
1259 | /* we might as well release our claims on endpoints */ | 1249 | /* we might as well release our claims on endpoints */ |
1260 | if (ncm->notify) | 1250 | if (ncm->notify) |
1261 | ncm->notify->driver_data = NULL; | 1251 | ncm->notify->driver_data = NULL; |
1262 | if (ncm->port.out_ep->desc) | 1252 | if (ncm->port.out_ep) |
1263 | ncm->port.out_ep->driver_data = NULL; | 1253 | ncm->port.out_ep->driver_data = NULL; |
1264 | if (ncm->port.in_ep->desc) | 1254 | if (ncm->port.in_ep) |
1265 | ncm->port.in_ep->driver_data = NULL; | 1255 | ncm->port.in_ep->driver_data = NULL; |
1266 | 1256 | ||
1267 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); | 1257 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); |
@@ -1276,14 +1266,12 @@ ncm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
1276 | 1266 | ||
1277 | DBG(c->cdev, "ncm unbind\n"); | 1267 | DBG(c->cdev, "ncm unbind\n"); |
1278 | 1268 | ||
1279 | if (gadget_is_dualspeed(c->cdev->gadget)) | 1269 | ncm_string_defs[0].id = 0; |
1280 | usb_free_descriptors(f->hs_descriptors); | 1270 | usb_free_all_descriptors(f); |
1281 | usb_free_descriptors(f->descriptors); | ||
1282 | 1271 | ||
1283 | kfree(ncm->notify_req->buf); | 1272 | kfree(ncm->notify_req->buf); |
1284 | usb_ep_free_request(ncm->notify, ncm->notify_req); | 1273 | usb_ep_free_request(ncm->notify, ncm->notify_req); |
1285 | 1274 | ||
1286 | ncm_string_defs[1].s = NULL; | ||
1287 | kfree(ncm); | 1275 | kfree(ncm); |
1288 | } | 1276 | } |
1289 | 1277 | ||
@@ -1307,37 +1295,19 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1307 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) | 1295 | if (!can_support_ecm(c->cdev->gadget) || !ethaddr) |
1308 | return -EINVAL; | 1296 | return -EINVAL; |
1309 | 1297 | ||
1310 | /* maybe allocate device-global string IDs */ | ||
1311 | if (ncm_string_defs[0].id == 0) { | 1298 | if (ncm_string_defs[0].id == 0) { |
1312 | 1299 | status = usb_string_ids_tab(c->cdev, ncm_string_defs); | |
1313 | /* control interface label */ | ||
1314 | status = usb_string_id(c->cdev); | ||
1315 | if (status < 0) | 1300 | if (status < 0) |
1316 | return status; | 1301 | return status; |
1317 | ncm_string_defs[STRING_CTRL_IDX].id = status; | 1302 | ncm_control_intf.iInterface = |
1318 | ncm_control_intf.iInterface = status; | 1303 | ncm_string_defs[STRING_CTRL_IDX].id; |
1319 | 1304 | ||
1320 | /* data interface label */ | 1305 | status = ncm_string_defs[STRING_DATA_IDX].id; |
1321 | status = usb_string_id(c->cdev); | ||
1322 | if (status < 0) | ||
1323 | return status; | ||
1324 | ncm_string_defs[STRING_DATA_IDX].id = status; | ||
1325 | ncm_data_nop_intf.iInterface = status; | 1306 | ncm_data_nop_intf.iInterface = status; |
1326 | ncm_data_intf.iInterface = status; | 1307 | ncm_data_intf.iInterface = status; |
1327 | 1308 | ||
1328 | /* MAC address */ | 1309 | ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id; |
1329 | status = usb_string_id(c->cdev); | 1310 | ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id; |
1330 | if (status < 0) | ||
1331 | return status; | ||
1332 | ncm_string_defs[STRING_MAC_IDX].id = status; | ||
1333 | ecm_desc.iMACAddress = status; | ||
1334 | |||
1335 | /* IAD */ | ||
1336 | status = usb_string_id(c->cdev); | ||
1337 | if (status < 0) | ||
1338 | return status; | ||
1339 | ncm_string_defs[STRING_IAD_IDX].id = status; | ||
1340 | ncm_iad_desc.iFunction = status; | ||
1341 | } | 1311 | } |
1342 | 1312 | ||
1343 | /* allocate and initialize one new instance */ | 1313 | /* allocate and initialize one new instance */ |
@@ -1347,7 +1317,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1347 | 1317 | ||
1348 | /* export host's Ethernet address in CDC format */ | 1318 | /* export host's Ethernet address in CDC format */ |
1349 | snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); | 1319 | snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr); |
1350 | ncm_string_defs[1].s = ncm->ethaddr; | 1320 | ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr; |
1351 | 1321 | ||
1352 | spin_lock_init(&ncm->lock); | 1322 | spin_lock_init(&ncm->lock); |
1353 | ncm_reset_values(ncm); | 1323 | ncm_reset_values(ncm); |
@@ -1367,9 +1337,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
1367 | ncm->port.unwrap = ncm_unwrap_ntb; | 1337 | ncm->port.unwrap = ncm_unwrap_ntb; |
1368 | 1338 | ||
1369 | status = usb_add_function(c, &ncm->port.func); | 1339 | status = usb_add_function(c, &ncm->port.func); |
1370 | if (status) { | 1340 | if (status) |
1371 | ncm_string_defs[1].s = NULL; | ||
1372 | kfree(ncm); | 1341 | kfree(ncm); |
1373 | } | ||
1374 | return status; | 1342 | return status; |
1375 | } | 1343 | } |
diff --git a/drivers/usb/gadget/f_obex.c b/drivers/usb/gadget/f_obex.c index 5f400f66aa9b..d8dd8782768c 100644 --- a/drivers/usb/gadget/f_obex.c +++ b/drivers/usb/gadget/f_obex.c | |||
@@ -331,23 +331,19 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
331 | obex->port.out = ep; | 331 | obex->port.out = ep; |
332 | ep->driver_data = cdev; /* claim */ | 332 | ep->driver_data = cdev; /* claim */ |
333 | 333 | ||
334 | /* copy descriptors, and track endpoint copies */ | ||
335 | f->descriptors = usb_copy_descriptors(fs_function); | ||
336 | |||
337 | /* support all relevant hardware speeds... we expect that when | 334 | /* support all relevant hardware speeds... we expect that when |
338 | * hardware is dual speed, all bulk-capable endpoints work at | 335 | * hardware is dual speed, all bulk-capable endpoints work at |
339 | * both speeds | 336 | * both speeds |
340 | */ | 337 | */ |
341 | if (gadget_is_dualspeed(c->cdev->gadget)) { | ||
342 | 338 | ||
343 | obex_hs_ep_in_desc.bEndpointAddress = | 339 | obex_hs_ep_in_desc.bEndpointAddress = |
344 | obex_fs_ep_in_desc.bEndpointAddress; | 340 | obex_fs_ep_in_desc.bEndpointAddress; |
345 | obex_hs_ep_out_desc.bEndpointAddress = | 341 | obex_hs_ep_out_desc.bEndpointAddress = |
346 | obex_fs_ep_out_desc.bEndpointAddress; | 342 | obex_fs_ep_out_desc.bEndpointAddress; |
347 | 343 | ||
348 | /* copy descriptors, and track endpoint copies */ | 344 | status = usb_assign_descriptors(f, fs_function, hs_function, NULL); |
349 | f->hs_descriptors = usb_copy_descriptors(hs_function); | 345 | if (status) |
350 | } | 346 | goto fail; |
351 | 347 | ||
352 | /* Avoid letting this gadget enumerate until the userspace | 348 | /* Avoid letting this gadget enumerate until the userspace |
353 | * OBEX server is active. | 349 | * OBEX server is active. |
@@ -368,6 +364,7 @@ obex_bind(struct usb_configuration *c, struct usb_function *f) | |||
368 | return 0; | 364 | return 0; |
369 | 365 | ||
370 | fail: | 366 | fail: |
367 | usb_free_all_descriptors(f); | ||
371 | /* we might as well release our claims on endpoints */ | 368 | /* we might as well release our claims on endpoints */ |
372 | if (obex->port.out) | 369 | if (obex->port.out) |
373 | obex->port.out->driver_data = NULL; | 370 | obex->port.out->driver_data = NULL; |
@@ -382,9 +379,8 @@ fail: | |||
382 | static void | 379 | static void |
383 | obex_unbind(struct usb_configuration *c, struct usb_function *f) | 380 | obex_unbind(struct usb_configuration *c, struct usb_function *f) |
384 | { | 381 | { |
385 | if (gadget_is_dualspeed(c->cdev->gadget)) | 382 | obex_string_defs[OBEX_CTRL_IDX].id = 0; |
386 | usb_free_descriptors(f->hs_descriptors); | 383 | usb_free_all_descriptors(f); |
387 | usb_free_descriptors(f->descriptors); | ||
388 | kfree(func_to_obex(f)); | 384 | kfree(func_to_obex(f)); |
389 | } | 385 | } |
390 | 386 | ||
@@ -423,22 +419,16 @@ int __init obex_bind_config(struct usb_configuration *c, u8 port_num) | |||
423 | if (!can_support_obex(c)) | 419 | if (!can_support_obex(c)) |
424 | return -EINVAL; | 420 | return -EINVAL; |
425 | 421 | ||
426 | /* maybe allocate device-global string IDs, and patch descriptors */ | ||
427 | if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { | 422 | if (obex_string_defs[OBEX_CTRL_IDX].id == 0) { |
428 | status = usb_string_id(c->cdev); | 423 | status = usb_string_ids_tab(c->cdev, obex_string_defs); |
429 | if (status < 0) | ||
430 | return status; | ||
431 | obex_string_defs[OBEX_CTRL_IDX].id = status; | ||
432 | |||
433 | obex_control_intf.iInterface = status; | ||
434 | |||
435 | status = usb_string_id(c->cdev); | ||
436 | if (status < 0) | 424 | if (status < 0) |
437 | return status; | 425 | return status; |
438 | obex_string_defs[OBEX_DATA_IDX].id = status; | 426 | obex_control_intf.iInterface = |
427 | obex_string_defs[OBEX_CTRL_IDX].id; | ||
439 | 428 | ||
440 | obex_data_nop_intf.iInterface = | 429 | status = obex_string_defs[OBEX_DATA_IDX].id; |
441 | obex_data_intf.iInterface = status; | 430 | obex_data_nop_intf.iInterface = status; |
431 | obex_data_intf.iInterface = status; | ||
442 | } | 432 | } |
443 | 433 | ||
444 | /* allocate and initialize one new instance */ | 434 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c index 8ee9268fe253..b21ab558b6c0 100644 --- a/drivers/usb/gadget/f_phonet.c +++ b/drivers/usb/gadget/f_phonet.c | |||
@@ -515,14 +515,14 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f) | |||
515 | fp->in_ep = ep; | 515 | fp->in_ep = ep; |
516 | ep->driver_data = fp; /* Claim */ | 516 | ep->driver_data = fp; /* Claim */ |
517 | 517 | ||
518 | pn_hs_sink_desc.bEndpointAddress = | 518 | pn_hs_sink_desc.bEndpointAddress = pn_fs_sink_desc.bEndpointAddress; |
519 | pn_fs_sink_desc.bEndpointAddress; | 519 | pn_hs_source_desc.bEndpointAddress = pn_fs_source_desc.bEndpointAddress; |
520 | pn_hs_source_desc.bEndpointAddress = | ||
521 | pn_fs_source_desc.bEndpointAddress; | ||
522 | 520 | ||
523 | /* Do not try to bind Phonet twice... */ | 521 | /* Do not try to bind Phonet twice... */ |
524 | fp->function.descriptors = fs_pn_function; | 522 | status = usb_assign_descriptors(f, fs_pn_function, hs_pn_function, |
525 | fp->function.hs_descriptors = hs_pn_function; | 523 | NULL); |
524 | if (status) | ||
525 | goto err; | ||
526 | 526 | ||
527 | /* Incoming USB requests */ | 527 | /* Incoming USB requests */ |
528 | status = -ENOMEM; | 528 | status = -ENOMEM; |
@@ -531,7 +531,7 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f) | |||
531 | 531 | ||
532 | req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL); | 532 | req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL); |
533 | if (!req) | 533 | if (!req) |
534 | goto err; | 534 | goto err_req; |
535 | 535 | ||
536 | req->complete = pn_rx_complete; | 536 | req->complete = pn_rx_complete; |
537 | fp->out_reqv[i] = req; | 537 | fp->out_reqv[i] = req; |
@@ -540,14 +540,18 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f) | |||
540 | /* Outgoing USB requests */ | 540 | /* Outgoing USB requests */ |
541 | fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL); | 541 | fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL); |
542 | if (!fp->in_req) | 542 | if (!fp->in_req) |
543 | goto err; | 543 | goto err_req; |
544 | 544 | ||
545 | INFO(cdev, "USB CDC Phonet function\n"); | 545 | INFO(cdev, "USB CDC Phonet function\n"); |
546 | INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name, | 546 | INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name, |
547 | fp->out_ep->name, fp->in_ep->name); | 547 | fp->out_ep->name, fp->in_ep->name); |
548 | return 0; | 548 | return 0; |
549 | 549 | ||
550 | err_req: | ||
551 | for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++) | ||
552 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); | ||
550 | err: | 553 | err: |
554 | usb_free_all_descriptors(f); | ||
551 | if (fp->out_ep) | 555 | if (fp->out_ep) |
552 | fp->out_ep->driver_data = NULL; | 556 | fp->out_ep->driver_data = NULL; |
553 | if (fp->in_ep) | 557 | if (fp->in_ep) |
@@ -569,6 +573,7 @@ pn_unbind(struct usb_configuration *c, struct usb_function *f) | |||
569 | if (fp->out_reqv[i]) | 573 | if (fp->out_reqv[i]) |
570 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); | 574 | usb_ep_free_request(fp->out_ep, fp->out_reqv[i]); |
571 | 575 | ||
576 | usb_free_all_descriptors(f); | ||
572 | kfree(fp); | 577 | kfree(fp); |
573 | } | 578 | } |
574 | 579 | ||
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index b1681e45aca7..71beeb833558 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c | |||
@@ -101,7 +101,7 @@ static unsigned int bitrate(struct usb_gadget *g) | |||
101 | /* | 101 | /* |
102 | */ | 102 | */ |
103 | 103 | ||
104 | #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ | 104 | #define RNDIS_STATUS_INTERVAL_MS 32 |
105 | #define STATUS_BYTECOUNT 8 /* 8 bytes data */ | 105 | #define STATUS_BYTECOUNT 8 /* 8 bytes data */ |
106 | 106 | ||
107 | 107 | ||
@@ -190,7 +190,7 @@ static struct usb_endpoint_descriptor fs_notify_desc = { | |||
190 | .bEndpointAddress = USB_DIR_IN, | 190 | .bEndpointAddress = USB_DIR_IN, |
191 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 191 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
192 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), | 192 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), |
193 | .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, | 193 | .bInterval = RNDIS_STATUS_INTERVAL_MS, |
194 | }; | 194 | }; |
195 | 195 | ||
196 | static struct usb_endpoint_descriptor fs_in_desc = { | 196 | static struct usb_endpoint_descriptor fs_in_desc = { |
@@ -236,7 +236,7 @@ static struct usb_endpoint_descriptor hs_notify_desc = { | |||
236 | .bEndpointAddress = USB_DIR_IN, | 236 | .bEndpointAddress = USB_DIR_IN, |
237 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 237 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
238 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), | 238 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), |
239 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 239 | .bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS) |
240 | }; | 240 | }; |
241 | 241 | ||
242 | static struct usb_endpoint_descriptor hs_in_desc = { | 242 | static struct usb_endpoint_descriptor hs_in_desc = { |
@@ -284,7 +284,7 @@ static struct usb_endpoint_descriptor ss_notify_desc = { | |||
284 | .bEndpointAddress = USB_DIR_IN, | 284 | .bEndpointAddress = USB_DIR_IN, |
285 | .bmAttributes = USB_ENDPOINT_XFER_INT, | 285 | .bmAttributes = USB_ENDPOINT_XFER_INT, |
286 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), | 286 | .wMaxPacketSize = cpu_to_le16(STATUS_BYTECOUNT), |
287 | .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, | 287 | .bInterval = USB_MS_TO_HS_INTERVAL(RNDIS_STATUS_INTERVAL_MS) |
288 | }; | 288 | }; |
289 | 289 | ||
290 | static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = { | 290 | static struct usb_ss_ep_comp_descriptor ss_intr_comp_desc = { |
@@ -722,42 +722,22 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
722 | rndis->notify_req->context = rndis; | 722 | rndis->notify_req->context = rndis; |
723 | rndis->notify_req->complete = rndis_response_complete; | 723 | rndis->notify_req->complete = rndis_response_complete; |
724 | 724 | ||
725 | /* copy descriptors, and track endpoint copies */ | ||
726 | f->descriptors = usb_copy_descriptors(eth_fs_function); | ||
727 | if (!f->descriptors) | ||
728 | goto fail; | ||
729 | |||
730 | /* support all relevant hardware speeds... we expect that when | 725 | /* support all relevant hardware speeds... we expect that when |
731 | * hardware is dual speed, all bulk-capable endpoints work at | 726 | * hardware is dual speed, all bulk-capable endpoints work at |
732 | * both speeds | 727 | * both speeds |
733 | */ | 728 | */ |
734 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 729 | hs_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress; |
735 | hs_in_desc.bEndpointAddress = | 730 | hs_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress; |
736 | fs_in_desc.bEndpointAddress; | 731 | hs_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress; |
737 | hs_out_desc.bEndpointAddress = | ||
738 | fs_out_desc.bEndpointAddress; | ||
739 | hs_notify_desc.bEndpointAddress = | ||
740 | fs_notify_desc.bEndpointAddress; | ||
741 | |||
742 | /* copy descriptors, and track endpoint copies */ | ||
743 | f->hs_descriptors = usb_copy_descriptors(eth_hs_function); | ||
744 | if (!f->hs_descriptors) | ||
745 | goto fail; | ||
746 | } | ||
747 | 732 | ||
748 | if (gadget_is_superspeed(c->cdev->gadget)) { | 733 | ss_in_desc.bEndpointAddress = fs_in_desc.bEndpointAddress; |
749 | ss_in_desc.bEndpointAddress = | 734 | ss_out_desc.bEndpointAddress = fs_out_desc.bEndpointAddress; |
750 | fs_in_desc.bEndpointAddress; | 735 | ss_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress; |
751 | ss_out_desc.bEndpointAddress = | 736 | |
752 | fs_out_desc.bEndpointAddress; | 737 | status = usb_assign_descriptors(f, eth_fs_function, eth_hs_function, |
753 | ss_notify_desc.bEndpointAddress = | 738 | eth_ss_function); |
754 | fs_notify_desc.bEndpointAddress; | 739 | if (status) |
755 | 740 | goto fail; | |
756 | /* copy descriptors, and track endpoint copies */ | ||
757 | f->ss_descriptors = usb_copy_descriptors(eth_ss_function); | ||
758 | if (!f->ss_descriptors) | ||
759 | goto fail; | ||
760 | } | ||
761 | 741 | ||
762 | rndis->port.open = rndis_open; | 742 | rndis->port.open = rndis_open; |
763 | rndis->port.close = rndis_close; | 743 | rndis->port.close = rndis_close; |
@@ -788,12 +768,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) | |||
788 | return 0; | 768 | return 0; |
789 | 769 | ||
790 | fail: | 770 | fail: |
791 | if (gadget_is_superspeed(c->cdev->gadget) && f->ss_descriptors) | 771 | usb_free_all_descriptors(f); |
792 | usb_free_descriptors(f->ss_descriptors); | ||
793 | if (gadget_is_dualspeed(c->cdev->gadget) && f->hs_descriptors) | ||
794 | usb_free_descriptors(f->hs_descriptors); | ||
795 | if (f->descriptors) | ||
796 | usb_free_descriptors(f->descriptors); | ||
797 | 772 | ||
798 | if (rndis->notify_req) { | 773 | if (rndis->notify_req) { |
799 | kfree(rndis->notify_req->buf); | 774 | kfree(rndis->notify_req->buf); |
@@ -803,9 +778,9 @@ fail: | |||
803 | /* we might as well release our claims on endpoints */ | 778 | /* we might as well release our claims on endpoints */ |
804 | if (rndis->notify) | 779 | if (rndis->notify) |
805 | rndis->notify->driver_data = NULL; | 780 | rndis->notify->driver_data = NULL; |
806 | if (rndis->port.out_ep->desc) | 781 | if (rndis->port.out_ep) |
807 | rndis->port.out_ep->driver_data = NULL; | 782 | rndis->port.out_ep->driver_data = NULL; |
808 | if (rndis->port.in_ep->desc) | 783 | if (rndis->port.in_ep) |
809 | rndis->port.in_ep->driver_data = NULL; | 784 | rndis->port.in_ep->driver_data = NULL; |
810 | 785 | ||
811 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); | 786 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); |
@@ -820,13 +795,9 @@ rndis_unbind(struct usb_configuration *c, struct usb_function *f) | |||
820 | 795 | ||
821 | rndis_deregister(rndis->config); | 796 | rndis_deregister(rndis->config); |
822 | rndis_exit(); | 797 | rndis_exit(); |
823 | rndis_string_defs[0].id = 0; | ||
824 | 798 | ||
825 | if (gadget_is_superspeed(c->cdev->gadget)) | 799 | rndis_string_defs[0].id = 0; |
826 | usb_free_descriptors(f->ss_descriptors); | 800 | usb_free_all_descriptors(f); |
827 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
828 | usb_free_descriptors(f->hs_descriptors); | ||
829 | usb_free_descriptors(f->descriptors); | ||
830 | 801 | ||
831 | kfree(rndis->notify_req->buf); | 802 | kfree(rndis->notify_req->buf); |
832 | usb_ep_free_request(rndis->notify, rndis->notify_req); | 803 | usb_ep_free_request(rndis->notify, rndis->notify_req); |
@@ -851,34 +822,19 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], | |||
851 | if (!can_support_rndis(c) || !ethaddr) | 822 | if (!can_support_rndis(c) || !ethaddr) |
852 | return -EINVAL; | 823 | return -EINVAL; |
853 | 824 | ||
854 | /* maybe allocate device-global string IDs */ | ||
855 | if (rndis_string_defs[0].id == 0) { | 825 | if (rndis_string_defs[0].id == 0) { |
856 | |||
857 | /* ... and setup RNDIS itself */ | 826 | /* ... and setup RNDIS itself */ |
858 | status = rndis_init(); | 827 | status = rndis_init(); |
859 | if (status < 0) | 828 | if (status < 0) |
860 | return status; | 829 | return status; |
861 | 830 | ||
862 | /* control interface label */ | 831 | status = usb_string_ids_tab(c->cdev, rndis_string_defs); |
863 | status = usb_string_id(c->cdev); | 832 | if (status) |
864 | if (status < 0) | ||
865 | return status; | 833 | return status; |
866 | rndis_string_defs[0].id = status; | ||
867 | rndis_control_intf.iInterface = status; | ||
868 | 834 | ||
869 | /* data interface label */ | 835 | rndis_control_intf.iInterface = rndis_string_defs[0].id; |
870 | status = usb_string_id(c->cdev); | 836 | rndis_data_intf.iInterface = rndis_string_defs[1].id; |
871 | if (status < 0) | 837 | rndis_iad_descriptor.iFunction = rndis_string_defs[2].id; |
872 | return status; | ||
873 | rndis_string_defs[1].id = status; | ||
874 | rndis_data_intf.iInterface = status; | ||
875 | |||
876 | /* IAD iFunction label */ | ||
877 | status = usb_string_id(c->cdev); | ||
878 | if (status < 0) | ||
879 | return status; | ||
880 | rndis_string_defs[2].id = status; | ||
881 | rndis_iad_descriptor.iFunction = status; | ||
882 | } | 838 | } |
883 | 839 | ||
884 | /* allocate and initialize one new instance */ | 840 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c index 07197d63d9b1..98fa7795df5f 100644 --- a/drivers/usb/gadget/f_serial.c +++ b/drivers/usb/gadget/f_serial.c | |||
@@ -213,34 +213,20 @@ gser_bind(struct usb_configuration *c, struct usb_function *f) | |||
213 | gser->port.out = ep; | 213 | gser->port.out = ep; |
214 | ep->driver_data = cdev; /* claim */ | 214 | ep->driver_data = cdev; /* claim */ |
215 | 215 | ||
216 | /* copy descriptors, and track endpoint copies */ | ||
217 | f->descriptors = usb_copy_descriptors(gser_fs_function); | ||
218 | |||
219 | /* support all relevant hardware speeds... we expect that when | 216 | /* support all relevant hardware speeds... we expect that when |
220 | * hardware is dual speed, all bulk-capable endpoints work at | 217 | * hardware is dual speed, all bulk-capable endpoints work at |
221 | * both speeds | 218 | * both speeds |
222 | */ | 219 | */ |
223 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 220 | gser_hs_in_desc.bEndpointAddress = gser_fs_in_desc.bEndpointAddress; |
224 | gser_hs_in_desc.bEndpointAddress = | 221 | gser_hs_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress; |
225 | gser_fs_in_desc.bEndpointAddress; | ||
226 | gser_hs_out_desc.bEndpointAddress = | ||
227 | gser_fs_out_desc.bEndpointAddress; | ||
228 | |||
229 | /* copy descriptors, and track endpoint copies */ | ||
230 | f->hs_descriptors = usb_copy_descriptors(gser_hs_function); | ||
231 | } | ||
232 | if (gadget_is_superspeed(c->cdev->gadget)) { | ||
233 | gser_ss_in_desc.bEndpointAddress = | ||
234 | gser_fs_in_desc.bEndpointAddress; | ||
235 | gser_ss_out_desc.bEndpointAddress = | ||
236 | gser_fs_out_desc.bEndpointAddress; | ||
237 | |||
238 | /* copy descriptors, and track endpoint copies */ | ||
239 | f->ss_descriptors = usb_copy_descriptors(gser_ss_function); | ||
240 | if (!f->ss_descriptors) | ||
241 | goto fail; | ||
242 | } | ||
243 | 222 | ||
223 | gser_ss_in_desc.bEndpointAddress = gser_fs_in_desc.bEndpointAddress; | ||
224 | gser_ss_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress; | ||
225 | |||
226 | status = usb_assign_descriptors(f, gser_fs_function, gser_hs_function, | ||
227 | gser_ss_function); | ||
228 | if (status) | ||
229 | goto fail; | ||
244 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", | 230 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", |
245 | gser->port_num, | 231 | gser->port_num, |
246 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | 232 | gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -263,11 +249,7 @@ fail: | |||
263 | static void | 249 | static void |
264 | gser_unbind(struct usb_configuration *c, struct usb_function *f) | 250 | gser_unbind(struct usb_configuration *c, struct usb_function *f) |
265 | { | 251 | { |
266 | if (gadget_is_dualspeed(c->cdev->gadget)) | 252 | usb_free_all_descriptors(f); |
267 | usb_free_descriptors(f->hs_descriptors); | ||
268 | if (gadget_is_superspeed(c->cdev->gadget)) | ||
269 | usb_free_descriptors(f->ss_descriptors); | ||
270 | usb_free_descriptors(f->descriptors); | ||
271 | kfree(func_to_gser(f)); | 253 | kfree(func_to_gser(f)); |
272 | } | 254 | } |
273 | 255 | ||
diff --git a/drivers/usb/gadget/f_sourcesink.c b/drivers/usb/gadget/f_sourcesink.c index 3c126fde6e7e..102d49beb9df 100644 --- a/drivers/usb/gadget/f_sourcesink.c +++ b/drivers/usb/gadget/f_sourcesink.c | |||
@@ -319,6 +319,7 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f) | |||
319 | struct usb_composite_dev *cdev = c->cdev; | 319 | struct usb_composite_dev *cdev = c->cdev; |
320 | struct f_sourcesink *ss = func_to_ss(f); | 320 | struct f_sourcesink *ss = func_to_ss(f); |
321 | int id; | 321 | int id; |
322 | int ret; | ||
322 | 323 | ||
323 | /* allocate interface ID(s) */ | 324 | /* allocate interface ID(s) */ |
324 | id = usb_interface_id(c, f); | 325 | id = usb_interface_id(c, f); |
@@ -387,64 +388,57 @@ no_iso: | |||
387 | isoc_maxpacket = 1024; | 388 | isoc_maxpacket = 1024; |
388 | 389 | ||
389 | /* support high speed hardware */ | 390 | /* support high speed hardware */ |
390 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 391 | hs_source_desc.bEndpointAddress = fs_source_desc.bEndpointAddress; |
391 | hs_source_desc.bEndpointAddress = | 392 | hs_sink_desc.bEndpointAddress = fs_sink_desc.bEndpointAddress; |
392 | fs_source_desc.bEndpointAddress; | ||
393 | hs_sink_desc.bEndpointAddress = | ||
394 | fs_sink_desc.bEndpointAddress; | ||
395 | 393 | ||
396 | /* | 394 | /* |
397 | * Fill in the HS isoc descriptors from the module parameters. | 395 | * Fill in the HS isoc descriptors from the module parameters. |
398 | * We assume that the user knows what they are doing and won't | 396 | * We assume that the user knows what they are doing and won't |
399 | * give parameters that their UDC doesn't support. | 397 | * give parameters that their UDC doesn't support. |
400 | */ | 398 | */ |
401 | hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; | 399 | hs_iso_source_desc.wMaxPacketSize = isoc_maxpacket; |
402 | hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; | 400 | hs_iso_source_desc.wMaxPacketSize |= isoc_mult << 11; |
403 | hs_iso_source_desc.bInterval = isoc_interval; | 401 | hs_iso_source_desc.bInterval = isoc_interval; |
404 | hs_iso_source_desc.bEndpointAddress = | 402 | hs_iso_source_desc.bEndpointAddress = |
405 | fs_iso_source_desc.bEndpointAddress; | 403 | fs_iso_source_desc.bEndpointAddress; |
406 | 404 | ||
407 | hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; | 405 | hs_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; |
408 | hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11; | 406 | hs_iso_sink_desc.wMaxPacketSize |= isoc_mult << 11; |
409 | hs_iso_sink_desc.bInterval = isoc_interval; | 407 | hs_iso_sink_desc.bInterval = isoc_interval; |
410 | hs_iso_sink_desc.bEndpointAddress = | 408 | hs_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
411 | fs_iso_sink_desc.bEndpointAddress; | ||
412 | |||
413 | f->hs_descriptors = hs_source_sink_descs; | ||
414 | } | ||
415 | 409 | ||
416 | /* support super speed hardware */ | 410 | /* support super speed hardware */ |
417 | if (gadget_is_superspeed(c->cdev->gadget)) { | 411 | ss_source_desc.bEndpointAddress = |
418 | ss_source_desc.bEndpointAddress = | 412 | fs_source_desc.bEndpointAddress; |
419 | fs_source_desc.bEndpointAddress; | 413 | ss_sink_desc.bEndpointAddress = |
420 | ss_sink_desc.bEndpointAddress = | 414 | fs_sink_desc.bEndpointAddress; |
421 | fs_sink_desc.bEndpointAddress; | ||
422 | 415 | ||
423 | /* | 416 | /* |
424 | * Fill in the SS isoc descriptors from the module parameters. | 417 | * Fill in the SS isoc descriptors from the module parameters. |
425 | * We assume that the user knows what they are doing and won't | 418 | * We assume that the user knows what they are doing and won't |
426 | * give parameters that their UDC doesn't support. | 419 | * give parameters that their UDC doesn't support. |
427 | */ | 420 | */ |
428 | ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; | 421 | ss_iso_source_desc.wMaxPacketSize = isoc_maxpacket; |
429 | ss_iso_source_desc.bInterval = isoc_interval; | 422 | ss_iso_source_desc.bInterval = isoc_interval; |
430 | ss_iso_source_comp_desc.bmAttributes = isoc_mult; | 423 | ss_iso_source_comp_desc.bmAttributes = isoc_mult; |
431 | ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst; | 424 | ss_iso_source_comp_desc.bMaxBurst = isoc_maxburst; |
432 | ss_iso_source_comp_desc.wBytesPerInterval = | 425 | ss_iso_source_comp_desc.wBytesPerInterval = |
433 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); | 426 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); |
434 | ss_iso_source_desc.bEndpointAddress = | 427 | ss_iso_source_desc.bEndpointAddress = |
435 | fs_iso_source_desc.bEndpointAddress; | 428 | fs_iso_source_desc.bEndpointAddress; |
436 | 429 | ||
437 | ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; | 430 | ss_iso_sink_desc.wMaxPacketSize = isoc_maxpacket; |
438 | ss_iso_sink_desc.bInterval = isoc_interval; | 431 | ss_iso_sink_desc.bInterval = isoc_interval; |
439 | ss_iso_sink_comp_desc.bmAttributes = isoc_mult; | 432 | ss_iso_sink_comp_desc.bmAttributes = isoc_mult; |
440 | ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst; | 433 | ss_iso_sink_comp_desc.bMaxBurst = isoc_maxburst; |
441 | ss_iso_sink_comp_desc.wBytesPerInterval = | 434 | ss_iso_sink_comp_desc.wBytesPerInterval = |
442 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); | 435 | isoc_maxpacket * (isoc_mult + 1) * (isoc_maxburst + 1); |
443 | ss_iso_sink_desc.bEndpointAddress = | 436 | ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; |
444 | fs_iso_sink_desc.bEndpointAddress; | 437 | |
445 | 438 | ret = usb_assign_descriptors(f, fs_source_sink_descs, | |
446 | f->ss_descriptors = ss_source_sink_descs; | 439 | hs_source_sink_descs, ss_source_sink_descs); |
447 | } | 440 | if (ret) |
441 | return ret; | ||
448 | 442 | ||
449 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", | 443 | DBG(cdev, "%s speed %s: IN/%s, OUT/%s, ISO-IN/%s, ISO-OUT/%s\n", |
450 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : | 444 | (gadget_is_superspeed(c->cdev->gadget) ? "super" : |
@@ -458,6 +452,7 @@ no_iso: | |||
458 | static void | 452 | static void |
459 | sourcesink_unbind(struct usb_configuration *c, struct usb_function *f) | 453 | sourcesink_unbind(struct usb_configuration *c, struct usb_function *f) |
460 | { | 454 | { |
455 | usb_free_all_descriptors(f); | ||
461 | kfree(func_to_ss(f)); | 456 | kfree(func_to_ss(f)); |
462 | } | 457 | } |
463 | 458 | ||
@@ -773,7 +768,6 @@ static int __init sourcesink_bind_config(struct usb_configuration *c) | |||
773 | return -ENOMEM; | 768 | return -ENOMEM; |
774 | 769 | ||
775 | ss->function.name = "source/sink"; | 770 | ss->function.name = "source/sink"; |
776 | ss->function.descriptors = fs_source_sink_descs; | ||
777 | ss->function.bind = sourcesink_bind; | 771 | ss->function.bind = sourcesink_bind; |
778 | ss->function.unbind = sourcesink_unbind; | 772 | ss->function.unbind = sourcesink_unbind; |
779 | ss->function.set_alt = sourcesink_set_alt; | 773 | ss->function.set_alt = sourcesink_set_alt; |
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index 4060c0bd9785..f172bd152fbb 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -236,7 +236,7 @@ static struct usb_descriptor_header *ss_eth_function[] = { | |||
236 | 236 | ||
237 | static struct usb_string geth_string_defs[] = { | 237 | static struct usb_string geth_string_defs[] = { |
238 | [0].s = "CDC Ethernet Subset/SAFE", | 238 | [0].s = "CDC Ethernet Subset/SAFE", |
239 | [1].s = NULL /* DYNAMIC */, | 239 | [1].s = "", |
240 | { } /* end of list */ | 240 | { } /* end of list */ |
241 | }; | 241 | }; |
242 | 242 | ||
@@ -319,38 +319,22 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
319 | geth->port.out_ep = ep; | 319 | geth->port.out_ep = ep; |
320 | ep->driver_data = cdev; /* claim */ | 320 | ep->driver_data = cdev; /* claim */ |
321 | 321 | ||
322 | /* copy descriptors, and track endpoint copies */ | ||
323 | f->descriptors = usb_copy_descriptors(fs_eth_function); | ||
324 | if (!f->descriptors) | ||
325 | goto fail; | ||
326 | |||
327 | /* support all relevant hardware speeds... we expect that when | 322 | /* support all relevant hardware speeds... we expect that when |
328 | * hardware is dual speed, all bulk-capable endpoints work at | 323 | * hardware is dual speed, all bulk-capable endpoints work at |
329 | * both speeds | 324 | * both speeds |
330 | */ | 325 | */ |
331 | if (gadget_is_dualspeed(c->cdev->gadget)) { | 326 | hs_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress; |
332 | hs_subset_in_desc.bEndpointAddress = | 327 | hs_subset_out_desc.bEndpointAddress = |
333 | fs_subset_in_desc.bEndpointAddress; | 328 | fs_subset_out_desc.bEndpointAddress; |
334 | hs_subset_out_desc.bEndpointAddress = | ||
335 | fs_subset_out_desc.bEndpointAddress; | ||
336 | |||
337 | /* copy descriptors, and track endpoint copies */ | ||
338 | f->hs_descriptors = usb_copy_descriptors(hs_eth_function); | ||
339 | if (!f->hs_descriptors) | ||
340 | goto fail; | ||
341 | } | ||
342 | 329 | ||
343 | if (gadget_is_superspeed(c->cdev->gadget)) { | 330 | ss_subset_in_desc.bEndpointAddress = fs_subset_in_desc.bEndpointAddress; |
344 | ss_subset_in_desc.bEndpointAddress = | 331 | ss_subset_out_desc.bEndpointAddress = |
345 | fs_subset_in_desc.bEndpointAddress; | 332 | fs_subset_out_desc.bEndpointAddress; |
346 | ss_subset_out_desc.bEndpointAddress = | ||
347 | fs_subset_out_desc.bEndpointAddress; | ||
348 | 333 | ||
349 | /* copy descriptors, and track endpoint copies */ | 334 | status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function, |
350 | f->ss_descriptors = usb_copy_descriptors(ss_eth_function); | 335 | ss_eth_function); |
351 | if (!f->ss_descriptors) | 336 | if (status) |
352 | goto fail; | 337 | goto fail; |
353 | } | ||
354 | 338 | ||
355 | /* NOTE: all that is done without knowing or caring about | 339 | /* NOTE: all that is done without knowing or caring about |
356 | * the network link ... which is unavailable to this code | 340 | * the network link ... which is unavailable to this code |
@@ -364,15 +348,11 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) | |||
364 | return 0; | 348 | return 0; |
365 | 349 | ||
366 | fail: | 350 | fail: |
367 | if (f->descriptors) | 351 | usb_free_all_descriptors(f); |
368 | usb_free_descriptors(f->descriptors); | ||
369 | if (f->hs_descriptors) | ||
370 | usb_free_descriptors(f->hs_descriptors); | ||
371 | |||
372 | /* we might as well release our claims on endpoints */ | 352 | /* we might as well release our claims on endpoints */ |
373 | if (geth->port.out_ep->desc) | 353 | if (geth->port.out_ep) |
374 | geth->port.out_ep->driver_data = NULL; | 354 | geth->port.out_ep->driver_data = NULL; |
375 | if (geth->port.in_ep->desc) | 355 | if (geth->port.in_ep) |
376 | geth->port.in_ep->driver_data = NULL; | 356 | geth->port.in_ep->driver_data = NULL; |
377 | 357 | ||
378 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); | 358 | ERROR(cdev, "%s: can't bind, err %d\n", f->name, status); |
@@ -383,12 +363,8 @@ fail: | |||
383 | static void | 363 | static void |
384 | geth_unbind(struct usb_configuration *c, struct usb_function *f) | 364 | geth_unbind(struct usb_configuration *c, struct usb_function *f) |
385 | { | 365 | { |
386 | if (gadget_is_superspeed(c->cdev->gadget)) | 366 | geth_string_defs[0].id = 0; |
387 | usb_free_descriptors(f->ss_descriptors); | 367 | usb_free_all_descriptors(f); |
388 | if (gadget_is_dualspeed(c->cdev->gadget)) | ||
389 | usb_free_descriptors(f->hs_descriptors); | ||
390 | usb_free_descriptors(f->descriptors); | ||
391 | geth_string_defs[1].s = NULL; | ||
392 | kfree(func_to_geth(f)); | 368 | kfree(func_to_geth(f)); |
393 | } | 369 | } |
394 | 370 | ||
@@ -414,20 +390,11 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
414 | 390 | ||
415 | /* maybe allocate device-global string IDs */ | 391 | /* maybe allocate device-global string IDs */ |
416 | if (geth_string_defs[0].id == 0) { | 392 | if (geth_string_defs[0].id == 0) { |
417 | 393 | status = usb_string_ids_tab(c->cdev, geth_string_defs); | |
418 | /* interface label */ | ||
419 | status = usb_string_id(c->cdev); | ||
420 | if (status < 0) | 394 | if (status < 0) |
421 | return status; | 395 | return status; |
422 | geth_string_defs[0].id = status; | 396 | subset_data_intf.iInterface = geth_string_defs[0].id; |
423 | subset_data_intf.iInterface = status; | 397 | ether_desc.iMACAddress = geth_string_defs[1].id; |
424 | |||
425 | /* MAC address */ | ||
426 | status = usb_string_id(c->cdev); | ||
427 | if (status < 0) | ||
428 | return status; | ||
429 | geth_string_defs[1].id = status; | ||
430 | ether_desc.iMACAddress = status; | ||
431 | } | 398 | } |
432 | 399 | ||
433 | /* allocate and initialize one new instance */ | 400 | /* allocate and initialize one new instance */ |
@@ -449,9 +416,7 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
449 | geth->port.func.disable = geth_disable; | 416 | geth->port.func.disable = geth_disable; |
450 | 417 | ||
451 | status = usb_add_function(c, &geth->port.func); | 418 | status = usb_add_function(c, &geth->port.func); |
452 | if (status) { | 419 | if (status) |
453 | geth_string_defs[1].s = NULL; | ||
454 | kfree(geth); | 420 | kfree(geth); |
455 | } | ||
456 | return status; | 421 | return status; |
457 | } | 422 | } |
diff --git a/drivers/usb/gadget/f_uac1.c b/drivers/usb/gadget/f_uac1.c index 1a5dcd5565e3..f570e667a640 100644 --- a/drivers/usb/gadget/f_uac1.c +++ b/drivers/usb/gadget/f_uac1.c | |||
@@ -630,7 +630,7 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f) | |||
630 | struct usb_composite_dev *cdev = c->cdev; | 630 | struct usb_composite_dev *cdev = c->cdev; |
631 | struct f_audio *audio = func_to_audio(f); | 631 | struct f_audio *audio = func_to_audio(f); |
632 | int status; | 632 | int status; |
633 | struct usb_ep *ep; | 633 | struct usb_ep *ep = NULL; |
634 | 634 | ||
635 | f_audio_build_desc(audio); | 635 | f_audio_build_desc(audio); |
636 | 636 | ||
@@ -659,22 +659,14 @@ f_audio_bind(struct usb_configuration *c, struct usb_function *f) | |||
659 | status = -ENOMEM; | 659 | status = -ENOMEM; |
660 | 660 | ||
661 | /* copy descriptors, and track endpoint copies */ | 661 | /* copy descriptors, and track endpoint copies */ |
662 | f->descriptors = usb_copy_descriptors(f_audio_desc); | 662 | status = usb_assign_descriptors(f, f_audio_desc, f_audio_desc, NULL); |
663 | 663 | if (status) | |
664 | /* | 664 | goto fail; |
665 | * support all relevant hardware speeds... we expect that when | ||
666 | * hardware is dual speed, all bulk-capable endpoints work at | ||
667 | * both speeds | ||
668 | */ | ||
669 | if (gadget_is_dualspeed(c->cdev->gadget)) { | ||
670 | c->highspeed = true; | ||
671 | f->hs_descriptors = usb_copy_descriptors(f_audio_desc); | ||
672 | } | ||
673 | |||
674 | return 0; | 665 | return 0; |
675 | 666 | ||
676 | fail: | 667 | fail: |
677 | 668 | if (ep) | |
669 | ep->driver_data = NULL; | ||
678 | return status; | 670 | return status; |
679 | } | 671 | } |
680 | 672 | ||
@@ -683,8 +675,7 @@ f_audio_unbind(struct usb_configuration *c, struct usb_function *f) | |||
683 | { | 675 | { |
684 | struct f_audio *audio = func_to_audio(f); | 676 | struct f_audio *audio = func_to_audio(f); |
685 | 677 | ||
686 | usb_free_descriptors(f->descriptors); | 678 | usb_free_all_descriptors(f); |
687 | usb_free_descriptors(f->hs_descriptors); | ||
688 | kfree(audio); | 679 | kfree(audio); |
689 | } | 680 | } |
690 | 681 | ||
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c index d3c6cffccb72..91396a1683eb 100644 --- a/drivers/usb/gadget/f_uac2.c +++ b/drivers/usb/gadget/f_uac2.c | |||
@@ -50,13 +50,6 @@ static int c_ssize = 2; | |||
50 | module_param(c_ssize, uint, S_IRUGO); | 50 | module_param(c_ssize, uint, S_IRUGO); |
51 | MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); | 51 | MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); |
52 | 52 | ||
53 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
54 | |||
55 | #define ALT_SET(x, a) do {(x) &= ~0xff; (x) |= (a); } while (0) | ||
56 | #define ALT_GET(x) ((x) & 0xff) | ||
57 | #define INTF_SET(x, i) do {(x) &= 0xff; (x) |= ((i) << 8); } while (0) | ||
58 | #define INTF_GET(x) ((x >> 8) & 0xff) | ||
59 | |||
60 | /* Keep everyone on toes */ | 53 | /* Keep everyone on toes */ |
61 | #define USB_XFERS 2 | 54 | #define USB_XFERS 2 |
62 | 55 | ||
@@ -144,8 +137,9 @@ static struct snd_pcm_hardware uac2_pcm_hardware = { | |||
144 | }; | 137 | }; |
145 | 138 | ||
146 | struct audio_dev { | 139 | struct audio_dev { |
147 | /* Currently active {Interface[15:8] | AltSettings[7:0]} */ | 140 | u8 ac_intf, ac_alt; |
148 | __u16 ac_alt, as_out_alt, as_in_alt; | 141 | u8 as_out_intf, as_out_alt; |
142 | u8 as_in_intf, as_in_alt; | ||
149 | 143 | ||
150 | struct usb_ep *in_ep, *out_ep; | 144 | struct usb_ep *in_ep, *out_ep; |
151 | struct usb_function func; | 145 | struct usb_function func; |
@@ -526,32 +520,22 @@ enum { | |||
526 | STR_AS_IN_ALT1, | 520 | STR_AS_IN_ALT1, |
527 | }; | 521 | }; |
528 | 522 | ||
529 | static const char ifassoc[] = "Source/Sink"; | ||
530 | static const char ifctrl[] = "Topology Control"; | ||
531 | static char clksrc_in[8]; | 523 | static char clksrc_in[8]; |
532 | static char clksrc_out[8]; | 524 | static char clksrc_out[8]; |
533 | static const char usb_it[] = "USBH Out"; | ||
534 | static const char io_it[] = "USBD Out"; | ||
535 | static const char usb_ot[] = "USBH In"; | ||
536 | static const char io_ot[] = "USBD In"; | ||
537 | static const char out_alt0[] = "Playback Inactive"; | ||
538 | static const char out_alt1[] = "Playback Active"; | ||
539 | static const char in_alt0[] = "Capture Inactive"; | ||
540 | static const char in_alt1[] = "Capture Active"; | ||
541 | 525 | ||
542 | static struct usb_string strings_fn[] = { | 526 | static struct usb_string strings_fn[] = { |
543 | [STR_ASSOC].s = ifassoc, | 527 | [STR_ASSOC].s = "Source/Sink", |
544 | [STR_IF_CTRL].s = ifctrl, | 528 | [STR_IF_CTRL].s = "Topology Control", |
545 | [STR_CLKSRC_IN].s = clksrc_in, | 529 | [STR_CLKSRC_IN].s = clksrc_in, |
546 | [STR_CLKSRC_OUT].s = clksrc_out, | 530 | [STR_CLKSRC_OUT].s = clksrc_out, |
547 | [STR_USB_IT].s = usb_it, | 531 | [STR_USB_IT].s = "USBH Out", |
548 | [STR_IO_IT].s = io_it, | 532 | [STR_IO_IT].s = "USBD Out", |
549 | [STR_USB_OT].s = usb_ot, | 533 | [STR_USB_OT].s = "USBH In", |
550 | [STR_IO_OT].s = io_ot, | 534 | [STR_IO_OT].s = "USBD In", |
551 | [STR_AS_OUT_ALT0].s = out_alt0, | 535 | [STR_AS_OUT_ALT0].s = "Playback Inactive", |
552 | [STR_AS_OUT_ALT1].s = out_alt1, | 536 | [STR_AS_OUT_ALT1].s = "Playback Active", |
553 | [STR_AS_IN_ALT0].s = in_alt0, | 537 | [STR_AS_IN_ALT0].s = "Capture Inactive", |
554 | [STR_AS_IN_ALT1].s = in_alt1, | 538 | [STR_AS_IN_ALT1].s = "Capture Active", |
555 | { }, | 539 | { }, |
556 | }; | 540 | }; |
557 | 541 | ||
@@ -952,8 +936,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
952 | return ret; | 936 | return ret; |
953 | } | 937 | } |
954 | std_ac_if_desc.bInterfaceNumber = ret; | 938 | std_ac_if_desc.bInterfaceNumber = ret; |
955 | ALT_SET(agdev->ac_alt, 0); | 939 | agdev->ac_intf = ret; |
956 | INTF_SET(agdev->ac_alt, ret); | 940 | agdev->ac_alt = 0; |
957 | 941 | ||
958 | ret = usb_interface_id(cfg, fn); | 942 | ret = usb_interface_id(cfg, fn); |
959 | if (ret < 0) { | 943 | if (ret < 0) { |
@@ -963,8 +947,8 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
963 | } | 947 | } |
964 | std_as_out_if0_desc.bInterfaceNumber = ret; | 948 | std_as_out_if0_desc.bInterfaceNumber = ret; |
965 | std_as_out_if1_desc.bInterfaceNumber = ret; | 949 | std_as_out_if1_desc.bInterfaceNumber = ret; |
966 | ALT_SET(agdev->as_out_alt, 0); | 950 | agdev->as_out_intf = ret; |
967 | INTF_SET(agdev->as_out_alt, ret); | 951 | agdev->as_out_alt = 0; |
968 | 952 | ||
969 | ret = usb_interface_id(cfg, fn); | 953 | ret = usb_interface_id(cfg, fn); |
970 | if (ret < 0) { | 954 | if (ret < 0) { |
@@ -974,19 +958,23 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
974 | } | 958 | } |
975 | std_as_in_if0_desc.bInterfaceNumber = ret; | 959 | std_as_in_if0_desc.bInterfaceNumber = ret; |
976 | std_as_in_if1_desc.bInterfaceNumber = ret; | 960 | std_as_in_if1_desc.bInterfaceNumber = ret; |
977 | ALT_SET(agdev->as_in_alt, 0); | 961 | agdev->as_in_intf = ret; |
978 | INTF_SET(agdev->as_in_alt, ret); | 962 | agdev->as_in_alt = 0; |
979 | 963 | ||
980 | agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); | 964 | agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); |
981 | if (!agdev->out_ep) | 965 | if (!agdev->out_ep) { |
982 | dev_err(&uac2->pdev.dev, | 966 | dev_err(&uac2->pdev.dev, |
983 | "%s:%d Error!\n", __func__, __LINE__); | 967 | "%s:%d Error!\n", __func__, __LINE__); |
968 | goto err; | ||
969 | } | ||
984 | agdev->out_ep->driver_data = agdev; | 970 | agdev->out_ep->driver_data = agdev; |
985 | 971 | ||
986 | agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc); | 972 | agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc); |
987 | if (!agdev->in_ep) | 973 | if (!agdev->in_ep) { |
988 | dev_err(&uac2->pdev.dev, | 974 | dev_err(&uac2->pdev.dev, |
989 | "%s:%d Error!\n", __func__, __LINE__); | 975 | "%s:%d Error!\n", __func__, __LINE__); |
976 | goto err; | ||
977 | } | ||
990 | agdev->in_ep->driver_data = agdev; | 978 | agdev->in_ep->driver_data = agdev; |
991 | 979 | ||
992 | hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; | 980 | hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; |
@@ -994,9 +982,9 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
994 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; | 982 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; |
995 | hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; | 983 | hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; |
996 | 984 | ||
997 | fn->descriptors = usb_copy_descriptors(fs_audio_desc); | 985 | ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL); |
998 | if (gadget_is_dualspeed(gadget)) | 986 | if (ret) |
999 | fn->hs_descriptors = usb_copy_descriptors(hs_audio_desc); | 987 | goto err; |
1000 | 988 | ||
1001 | prm = &agdev->uac2.c_prm; | 989 | prm = &agdev->uac2.c_prm; |
1002 | prm->max_psize = hs_epout_desc.wMaxPacketSize; | 990 | prm->max_psize = hs_epout_desc.wMaxPacketSize; |
@@ -1005,6 +993,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1005 | prm->max_psize = 0; | 993 | prm->max_psize = 0; |
1006 | dev_err(&uac2->pdev.dev, | 994 | dev_err(&uac2->pdev.dev, |
1007 | "%s:%d Error!\n", __func__, __LINE__); | 995 | "%s:%d Error!\n", __func__, __LINE__); |
996 | goto err; | ||
1008 | } | 997 | } |
1009 | 998 | ||
1010 | prm = &agdev->uac2.p_prm; | 999 | prm = &agdev->uac2.p_prm; |
@@ -1014,17 +1003,28 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1014 | prm->max_psize = 0; | 1003 | prm->max_psize = 0; |
1015 | dev_err(&uac2->pdev.dev, | 1004 | dev_err(&uac2->pdev.dev, |
1016 | "%s:%d Error!\n", __func__, __LINE__); | 1005 | "%s:%d Error!\n", __func__, __LINE__); |
1006 | goto err; | ||
1017 | } | 1007 | } |
1018 | 1008 | ||
1019 | return alsa_uac2_init(agdev); | 1009 | ret = alsa_uac2_init(agdev); |
1010 | if (ret) | ||
1011 | goto err; | ||
1012 | return 0; | ||
1013 | err: | ||
1014 | kfree(agdev->uac2.p_prm.rbuf); | ||
1015 | kfree(agdev->uac2.c_prm.rbuf); | ||
1016 | usb_free_all_descriptors(fn); | ||
1017 | if (agdev->in_ep) | ||
1018 | agdev->in_ep->driver_data = NULL; | ||
1019 | if (agdev->out_ep) | ||
1020 | agdev->out_ep->driver_data = NULL; | ||
1021 | return -EINVAL; | ||
1020 | } | 1022 | } |
1021 | 1023 | ||
1022 | static void | 1024 | static void |
1023 | afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) | 1025 | afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) |
1024 | { | 1026 | { |
1025 | struct audio_dev *agdev = func_to_agdev(fn); | 1027 | struct audio_dev *agdev = func_to_agdev(fn); |
1026 | struct usb_composite_dev *cdev = cfg->cdev; | ||
1027 | struct usb_gadget *gadget = cdev->gadget; | ||
1028 | struct uac2_rtd_params *prm; | 1028 | struct uac2_rtd_params *prm; |
1029 | 1029 | ||
1030 | alsa_uac2_exit(agdev); | 1030 | alsa_uac2_exit(agdev); |
@@ -1034,10 +1034,7 @@ afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) | |||
1034 | 1034 | ||
1035 | prm = &agdev->uac2.c_prm; | 1035 | prm = &agdev->uac2.c_prm; |
1036 | kfree(prm->rbuf); | 1036 | kfree(prm->rbuf); |
1037 | 1037 | usb_free_all_descriptors(fn); | |
1038 | if (gadget_is_dualspeed(gadget)) | ||
1039 | usb_free_descriptors(fn->hs_descriptors); | ||
1040 | usb_free_descriptors(fn->descriptors); | ||
1041 | 1038 | ||
1042 | if (agdev->in_ep) | 1039 | if (agdev->in_ep) |
1043 | agdev->in_ep->driver_data = NULL; | 1040 | agdev->in_ep->driver_data = NULL; |
@@ -1064,7 +1061,7 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) | |||
1064 | return -EINVAL; | 1061 | return -EINVAL; |
1065 | } | 1062 | } |
1066 | 1063 | ||
1067 | if (intf == INTF_GET(agdev->ac_alt)) { | 1064 | if (intf == agdev->ac_intf) { |
1068 | /* Control I/f has only 1 AltSetting - 0 */ | 1065 | /* Control I/f has only 1 AltSetting - 0 */ |
1069 | if (alt) { | 1066 | if (alt) { |
1070 | dev_err(&uac2->pdev.dev, | 1067 | dev_err(&uac2->pdev.dev, |
@@ -1074,16 +1071,16 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) | |||
1074 | return 0; | 1071 | return 0; |
1075 | } | 1072 | } |
1076 | 1073 | ||
1077 | if (intf == INTF_GET(agdev->as_out_alt)) { | 1074 | if (intf == agdev->as_out_intf) { |
1078 | ep = agdev->out_ep; | 1075 | ep = agdev->out_ep; |
1079 | prm = &uac2->c_prm; | 1076 | prm = &uac2->c_prm; |
1080 | config_ep_by_speed(gadget, fn, ep); | 1077 | config_ep_by_speed(gadget, fn, ep); |
1081 | ALT_SET(agdev->as_out_alt, alt); | 1078 | agdev->as_out_alt = alt; |
1082 | } else if (intf == INTF_GET(agdev->as_in_alt)) { | 1079 | } else if (intf == agdev->as_in_intf) { |
1083 | ep = agdev->in_ep; | 1080 | ep = agdev->in_ep; |
1084 | prm = &uac2->p_prm; | 1081 | prm = &uac2->p_prm; |
1085 | config_ep_by_speed(gadget, fn, ep); | 1082 | config_ep_by_speed(gadget, fn, ep); |
1086 | ALT_SET(agdev->as_in_alt, alt); | 1083 | agdev->as_in_alt = alt; |
1087 | } else { | 1084 | } else { |
1088 | dev_err(&uac2->pdev.dev, | 1085 | dev_err(&uac2->pdev.dev, |
1089 | "%s:%d Error!\n", __func__, __LINE__); | 1086 | "%s:%d Error!\n", __func__, __LINE__); |
@@ -1117,7 +1114,6 @@ afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) | |||
1117 | prm->ureq[i].pp = prm; | 1114 | prm->ureq[i].pp = prm; |
1118 | 1115 | ||
1119 | req->zero = 0; | 1116 | req->zero = 0; |
1120 | req->dma = DMA_ADDR_INVALID; | ||
1121 | req->context = &prm->ureq[i]; | 1117 | req->context = &prm->ureq[i]; |
1122 | req->length = prm->max_psize; | 1118 | req->length = prm->max_psize; |
1123 | req->complete = agdev_iso_complete; | 1119 | req->complete = agdev_iso_complete; |
@@ -1136,12 +1132,12 @@ afunc_get_alt(struct usb_function *fn, unsigned intf) | |||
1136 | struct audio_dev *agdev = func_to_agdev(fn); | 1132 | struct audio_dev *agdev = func_to_agdev(fn); |
1137 | struct snd_uac2_chip *uac2 = &agdev->uac2; | 1133 | struct snd_uac2_chip *uac2 = &agdev->uac2; |
1138 | 1134 | ||
1139 | if (intf == INTF_GET(agdev->ac_alt)) | 1135 | if (intf == agdev->ac_intf) |
1140 | return ALT_GET(agdev->ac_alt); | 1136 | return agdev->ac_alt; |
1141 | else if (intf == INTF_GET(agdev->as_out_alt)) | 1137 | else if (intf == agdev->as_out_intf) |
1142 | return ALT_GET(agdev->as_out_alt); | 1138 | return agdev->as_out_alt; |
1143 | else if (intf == INTF_GET(agdev->as_in_alt)) | 1139 | else if (intf == agdev->as_in_intf) |
1144 | return ALT_GET(agdev->as_in_alt); | 1140 | return agdev->as_in_alt; |
1145 | else | 1141 | else |
1146 | dev_err(&uac2->pdev.dev, | 1142 | dev_err(&uac2->pdev.dev, |
1147 | "%s:%d Invalid Interface %d!\n", | 1143 | "%s:%d Invalid Interface %d!\n", |
@@ -1157,10 +1153,10 @@ afunc_disable(struct usb_function *fn) | |||
1157 | struct snd_uac2_chip *uac2 = &agdev->uac2; | 1153 | struct snd_uac2_chip *uac2 = &agdev->uac2; |
1158 | 1154 | ||
1159 | free_ep(&uac2->p_prm, agdev->in_ep); | 1155 | free_ep(&uac2->p_prm, agdev->in_ep); |
1160 | ALT_SET(agdev->as_in_alt, 0); | 1156 | agdev->as_in_alt = 0; |
1161 | 1157 | ||
1162 | free_ep(&uac2->c_prm, agdev->out_ep); | 1158 | free_ep(&uac2->c_prm, agdev->out_ep); |
1163 | ALT_SET(agdev->as_out_alt, 0); | 1159 | agdev->as_out_alt = 0; |
1164 | } | 1160 | } |
1165 | 1161 | ||
1166 | static int | 1162 | static int |
@@ -1267,7 +1263,7 @@ setup_rq_inf(struct usb_function *fn, const struct usb_ctrlrequest *cr) | |||
1267 | u16 w_index = le16_to_cpu(cr->wIndex); | 1263 | u16 w_index = le16_to_cpu(cr->wIndex); |
1268 | u8 intf = w_index & 0xff; | 1264 | u8 intf = w_index & 0xff; |
1269 | 1265 | ||
1270 | if (intf != INTF_GET(agdev->ac_alt)) { | 1266 | if (intf != agdev->ac_intf) { |
1271 | dev_err(&uac2->pdev.dev, | 1267 | dev_err(&uac2->pdev.dev, |
1272 | "%s:%d Error!\n", __func__, __LINE__); | 1268 | "%s:%d Error!\n", __func__, __LINE__); |
1273 | return -EOPNOTSUPP; | 1269 | return -EOPNOTSUPP; |
@@ -1316,7 +1312,7 @@ afunc_setup(struct usb_function *fn, const struct usb_ctrlrequest *cr) | |||
1316 | 1312 | ||
1317 | static int audio_bind_config(struct usb_configuration *cfg) | 1313 | static int audio_bind_config(struct usb_configuration *cfg) |
1318 | { | 1314 | { |
1319 | int id, res; | 1315 | int res; |
1320 | 1316 | ||
1321 | agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); | 1317 | agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); |
1322 | if (agdev_g == NULL) { | 1318 | if (agdev_g == NULL) { |
@@ -1324,89 +1320,21 @@ static int audio_bind_config(struct usb_configuration *cfg) | |||
1324 | return -ENOMEM; | 1320 | return -ENOMEM; |
1325 | } | 1321 | } |
1326 | 1322 | ||
1327 | id = usb_string_id(cfg->cdev); | 1323 | res = usb_string_ids_tab(cfg->cdev, strings_fn); |
1328 | if (id < 0) | 1324 | if (res) |
1329 | return id; | 1325 | return res; |
1330 | 1326 | iad_desc.iFunction = strings_fn[STR_ASSOC].id; | |
1331 | strings_fn[STR_ASSOC].id = id; | 1327 | std_ac_if_desc.iInterface = strings_fn[STR_IF_CTRL].id; |
1332 | iad_desc.iFunction = id, | 1328 | in_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_IN].id; |
1333 | 1329 | out_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_OUT].id; | |
1334 | id = usb_string_id(cfg->cdev); | 1330 | usb_out_it_desc.iTerminal = strings_fn[STR_USB_IT].id; |
1335 | if (id < 0) | 1331 | io_in_it_desc.iTerminal = strings_fn[STR_IO_IT].id; |
1336 | return id; | 1332 | usb_in_ot_desc.iTerminal = strings_fn[STR_USB_OT].id; |
1337 | 1333 | io_out_ot_desc.iTerminal = strings_fn[STR_IO_OT].id; | |
1338 | strings_fn[STR_IF_CTRL].id = id; | 1334 | std_as_out_if0_desc.iInterface = strings_fn[STR_AS_OUT_ALT0].id; |
1339 | std_ac_if_desc.iInterface = id, | 1335 | std_as_out_if1_desc.iInterface = strings_fn[STR_AS_OUT_ALT1].id; |
1340 | 1336 | std_as_in_if0_desc.iInterface = strings_fn[STR_AS_IN_ALT0].id; | |
1341 | id = usb_string_id(cfg->cdev); | 1337 | std_as_in_if1_desc.iInterface = strings_fn[STR_AS_IN_ALT1].id; |
1342 | if (id < 0) | ||
1343 | return id; | ||
1344 | |||
1345 | strings_fn[STR_CLKSRC_IN].id = id; | ||
1346 | in_clk_src_desc.iClockSource = id, | ||
1347 | |||
1348 | id = usb_string_id(cfg->cdev); | ||
1349 | if (id < 0) | ||
1350 | return id; | ||
1351 | |||
1352 | strings_fn[STR_CLKSRC_OUT].id = id; | ||
1353 | out_clk_src_desc.iClockSource = id, | ||
1354 | |||
1355 | id = usb_string_id(cfg->cdev); | ||
1356 | if (id < 0) | ||
1357 | return id; | ||
1358 | |||
1359 | strings_fn[STR_USB_IT].id = id; | ||
1360 | usb_out_it_desc.iTerminal = id, | ||
1361 | |||
1362 | id = usb_string_id(cfg->cdev); | ||
1363 | if (id < 0) | ||
1364 | return id; | ||
1365 | |||
1366 | strings_fn[STR_IO_IT].id = id; | ||
1367 | io_in_it_desc.iTerminal = id; | ||
1368 | |||
1369 | id = usb_string_id(cfg->cdev); | ||
1370 | if (id < 0) | ||
1371 | return id; | ||
1372 | |||
1373 | strings_fn[STR_USB_OT].id = id; | ||
1374 | usb_in_ot_desc.iTerminal = id; | ||
1375 | |||
1376 | id = usb_string_id(cfg->cdev); | ||
1377 | if (id < 0) | ||
1378 | return id; | ||
1379 | |||
1380 | strings_fn[STR_IO_OT].id = id; | ||
1381 | io_out_ot_desc.iTerminal = id; | ||
1382 | |||
1383 | id = usb_string_id(cfg->cdev); | ||
1384 | if (id < 0) | ||
1385 | return id; | ||
1386 | |||
1387 | strings_fn[STR_AS_OUT_ALT0].id = id; | ||
1388 | std_as_out_if0_desc.iInterface = id; | ||
1389 | |||
1390 | id = usb_string_id(cfg->cdev); | ||
1391 | if (id < 0) | ||
1392 | return id; | ||
1393 | |||
1394 | strings_fn[STR_AS_OUT_ALT1].id = id; | ||
1395 | std_as_out_if1_desc.iInterface = id; | ||
1396 | |||
1397 | id = usb_string_id(cfg->cdev); | ||
1398 | if (id < 0) | ||
1399 | return id; | ||
1400 | |||
1401 | strings_fn[STR_AS_IN_ALT0].id = id; | ||
1402 | std_as_in_if0_desc.iInterface = id; | ||
1403 | |||
1404 | id = usb_string_id(cfg->cdev); | ||
1405 | if (id < 0) | ||
1406 | return id; | ||
1407 | |||
1408 | strings_fn[STR_AS_IN_ALT1].id = id; | ||
1409 | std_as_in_if1_desc.iInterface = id; | ||
1410 | 1338 | ||
1411 | agdev_g->func.name = "uac2_func"; | 1339 | agdev_g->func.name = "uac2_func"; |
1412 | agdev_g->func.strings = fn_strings; | 1340 | agdev_g->func.strings = fn_strings; |
diff --git a/drivers/usb/gadget/f_uvc.c b/drivers/usb/gadget/f_uvc.c index 2a8bf0655c60..5b629876941b 100644 --- a/drivers/usb/gadget/f_uvc.c +++ b/drivers/usb/gadget/f_uvc.c | |||
@@ -417,7 +417,6 @@ uvc_register_video(struct uvc_device *uvc) | |||
417 | return -ENOMEM; | 417 | return -ENOMEM; |
418 | 418 | ||
419 | video->parent = &cdev->gadget->dev; | 419 | video->parent = &cdev->gadget->dev; |
420 | video->minor = -1; | ||
421 | video->fops = &uvc_v4l2_fops; | 420 | video->fops = &uvc_v4l2_fops; |
422 | video->release = video_device_release; | 421 | video->release = video_device_release; |
423 | strncpy(video->name, cdev->gadget->name, sizeof(video->name)); | 422 | strncpy(video->name, cdev->gadget->name, sizeof(video->name)); |
@@ -577,27 +576,15 @@ uvc_function_unbind(struct usb_configuration *c, struct usb_function *f) | |||
577 | 576 | ||
578 | INFO(cdev, "uvc_function_unbind\n"); | 577 | INFO(cdev, "uvc_function_unbind\n"); |
579 | 578 | ||
580 | if (uvc->vdev) { | 579 | video_unregister_device(uvc->vdev); |
581 | if (uvc->vdev->minor == -1) | 580 | uvc->control_ep->driver_data = NULL; |
582 | video_device_release(uvc->vdev); | 581 | uvc->video.ep->driver_data = NULL; |
583 | else | ||
584 | video_unregister_device(uvc->vdev); | ||
585 | uvc->vdev = NULL; | ||
586 | } | ||
587 | 582 | ||
588 | if (uvc->control_ep) | 583 | uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = 0; |
589 | uvc->control_ep->driver_data = NULL; | 584 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); |
590 | if (uvc->video.ep) | 585 | kfree(uvc->control_buf); |
591 | uvc->video.ep->driver_data = NULL; | ||
592 | |||
593 | if (uvc->control_req) { | ||
594 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); | ||
595 | kfree(uvc->control_buf); | ||
596 | } | ||
597 | 586 | ||
598 | kfree(f->descriptors); | 587 | usb_free_all_descriptors(f); |
599 | kfree(f->hs_descriptors); | ||
600 | kfree(f->ss_descriptors); | ||
601 | 588 | ||
602 | kfree(uvc); | 589 | kfree(uvc); |
603 | } | 590 | } |
@@ -663,49 +650,40 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) | |||
663 | /* sanity check the streaming endpoint module parameters */ | 650 | /* sanity check the streaming endpoint module parameters */ |
664 | if (streaming_maxpacket > 1024) | 651 | if (streaming_maxpacket > 1024) |
665 | streaming_maxpacket = 1024; | 652 | streaming_maxpacket = 1024; |
653 | /* | ||
654 | * Fill in the HS descriptors from the module parameters for the Video | ||
655 | * Streaming endpoint. | ||
656 | * NOTE: We assume that the user knows what they are doing and won't | ||
657 | * give parameters that their UDC doesn't support. | ||
658 | */ | ||
659 | uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket; | ||
660 | uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11; | ||
661 | uvc_hs_streaming_ep.bInterval = streaming_interval; | ||
662 | uvc_hs_streaming_ep.bEndpointAddress = | ||
663 | uvc_fs_streaming_ep.bEndpointAddress; | ||
666 | 664 | ||
667 | /* Copy descriptors for FS. */ | 665 | /* |
668 | f->descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); | 666 | * Fill in the SS descriptors from the module parameters for the Video |
669 | 667 | * Streaming endpoint. | |
670 | /* support high speed hardware */ | 668 | * NOTE: We assume that the user knows what they are doing and won't |
671 | if (gadget_is_dualspeed(cdev->gadget)) { | 669 | * give parameters that their UDC doesn't support. |
672 | /* | 670 | */ |
673 | * Fill in the HS descriptors from the module parameters for the | 671 | uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket; |
674 | * Video Streaming endpoint. | 672 | uvc_ss_streaming_ep.bInterval = streaming_interval; |
675 | * NOTE: We assume that the user knows what they are doing and | 673 | uvc_ss_streaming_comp.bmAttributes = streaming_mult; |
676 | * won't give parameters that their UDC doesn't support. | 674 | uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst; |
677 | */ | 675 | uvc_ss_streaming_comp.wBytesPerInterval = |
678 | uvc_hs_streaming_ep.wMaxPacketSize = streaming_maxpacket; | 676 | streaming_maxpacket * (streaming_mult + 1) * |
679 | uvc_hs_streaming_ep.wMaxPacketSize |= streaming_mult << 11; | 677 | (streaming_maxburst + 1); |
680 | uvc_hs_streaming_ep.bInterval = streaming_interval; | 678 | uvc_ss_streaming_ep.bEndpointAddress = |
681 | uvc_hs_streaming_ep.bEndpointAddress = | 679 | uvc_fs_streaming_ep.bEndpointAddress; |
682 | uvc_fs_streaming_ep.bEndpointAddress; | ||
683 | |||
684 | /* Copy descriptors. */ | ||
685 | f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); | ||
686 | } | ||
687 | 680 | ||
688 | /* support super speed hardware */ | 681 | /* Copy descriptors */ |
689 | if (gadget_is_superspeed(c->cdev->gadget)) { | 682 | f->fs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_FULL); |
690 | /* | 683 | if (gadget_is_dualspeed(cdev->gadget)) |
691 | * Fill in the SS descriptors from the module parameters for the | 684 | f->hs_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_HIGH); |
692 | * Video Streaming endpoint. | 685 | if (gadget_is_superspeed(c->cdev->gadget)) |
693 | * NOTE: We assume that the user knows what they are doing and | ||
694 | * won't give parameters that their UDC doesn't support. | ||
695 | */ | ||
696 | uvc_ss_streaming_ep.wMaxPacketSize = streaming_maxpacket; | ||
697 | uvc_ss_streaming_ep.bInterval = streaming_interval; | ||
698 | uvc_ss_streaming_comp.bmAttributes = streaming_mult; | ||
699 | uvc_ss_streaming_comp.bMaxBurst = streaming_maxburst; | ||
700 | uvc_ss_streaming_comp.wBytesPerInterval = | ||
701 | streaming_maxpacket * (streaming_mult + 1) * | ||
702 | (streaming_maxburst + 1); | ||
703 | uvc_ss_streaming_ep.bEndpointAddress = | ||
704 | uvc_fs_streaming_ep.bEndpointAddress; | ||
705 | |||
706 | /* Copy descriptors. */ | ||
707 | f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); | 686 | f->ss_descriptors = uvc_copy_descriptors(uvc, USB_SPEED_SUPER); |
708 | } | ||
709 | 687 | ||
710 | /* Preallocate control endpoint request. */ | 688 | /* Preallocate control endpoint request. */ |
711 | uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); | 689 | uvc->control_req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL); |
@@ -740,7 +718,20 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) | |||
740 | return 0; | 718 | return 0; |
741 | 719 | ||
742 | error: | 720 | error: |
743 | uvc_function_unbind(c, f); | 721 | if (uvc->vdev) |
722 | video_device_release(uvc->vdev); | ||
723 | |||
724 | if (uvc->control_ep) | ||
725 | uvc->control_ep->driver_data = NULL; | ||
726 | if (uvc->video.ep) | ||
727 | uvc->video.ep->driver_data = NULL; | ||
728 | |||
729 | if (uvc->control_req) { | ||
730 | usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); | ||
731 | kfree(uvc->control_buf); | ||
732 | } | ||
733 | |||
734 | usb_free_all_descriptors(f); | ||
744 | return ret; | 735 | return ret; |
745 | } | 736 | } |
746 | 737 | ||
@@ -808,25 +799,16 @@ uvc_bind_config(struct usb_configuration *c, | |||
808 | uvc->desc.hs_streaming = hs_streaming; | 799 | uvc->desc.hs_streaming = hs_streaming; |
809 | uvc->desc.ss_streaming = ss_streaming; | 800 | uvc->desc.ss_streaming = ss_streaming; |
810 | 801 | ||
811 | /* maybe allocate device-global string IDs, and patch descriptors */ | 802 | /* Allocate string descriptor numbers. */ |
812 | if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) { | 803 | if (uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id == 0) { |
813 | /* Allocate string descriptor numbers. */ | 804 | ret = usb_string_ids_tab(c->cdev, uvc_en_us_strings); |
814 | ret = usb_string_id(c->cdev); | 805 | if (ret) |
815 | if (ret < 0) | ||
816 | goto error; | ||
817 | uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id = ret; | ||
818 | uvc_iad.iFunction = ret; | ||
819 | |||
820 | ret = usb_string_id(c->cdev); | ||
821 | if (ret < 0) | ||
822 | goto error; | ||
823 | uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id = ret; | ||
824 | uvc_control_intf.iInterface = ret; | ||
825 | |||
826 | ret = usb_string_id(c->cdev); | ||
827 | if (ret < 0) | ||
828 | goto error; | 806 | goto error; |
829 | uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id = ret; | 807 | uvc_iad.iFunction = |
808 | uvc_en_us_strings[UVC_STRING_ASSOCIATION_IDX].id; | ||
809 | uvc_control_intf.iInterface = | ||
810 | uvc_en_us_strings[UVC_STRING_CONTROL_IDX].id; | ||
811 | ret = uvc_en_us_strings[UVC_STRING_STREAMING_IDX].id; | ||
830 | uvc_streaming_intf_alt0.iInterface = ret; | 812 | uvc_streaming_intf_alt0.iInterface = ret; |
831 | uvc_streaming_intf_alt1.iInterface = ret; | 813 | uvc_streaming_intf_alt1.iInterface = ret; |
832 | } | 814 | } |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c deleted file mode 100644 index 3f7d640b6758..000000000000 --- a/drivers/usb/gadget/file_storage.c +++ /dev/null | |||
@@ -1,3656 +0,0 @@ | |||
1 | /* | ||
2 | * file_storage.c -- File-backed USB Storage Gadget, for USB development | ||
3 | * | ||
4 | * Copyright (C) 2003-2008 Alan Stern | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions, and the following disclaimer, | ||
12 | * without modification. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. The names of the above-listed copyright holders may not be used | ||
17 | * to endorse or promote products derived from this software without | ||
18 | * specific prior written permission. | ||
19 | * | ||
20 | * ALTERNATIVELY, this software may be distributed under the terms of the | ||
21 | * GNU General Public License ("GPL") as published by the Free Software | ||
22 | * Foundation, either version 2 of that License or (at your option) any | ||
23 | * later version. | ||
24 | * | ||
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
26 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
27 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
29 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
30 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
31 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | */ | ||
37 | |||
38 | |||
39 | /* | ||
40 | * The File-backed Storage Gadget acts as a USB Mass Storage device, | ||
41 | * appearing to the host as a disk drive or as a CD-ROM drive. In addition | ||
42 | * to providing an example of a genuinely useful gadget driver for a USB | ||
43 | * device, it also illustrates a technique of double-buffering for increased | ||
44 | * throughput. Last but not least, it gives an easy way to probe the | ||
45 | * behavior of the Mass Storage drivers in a USB host. | ||
46 | * | ||
47 | * Backing storage is provided by a regular file or a block device, specified | ||
48 | * by the "file" module parameter. Access can be limited to read-only by | ||
49 | * setting the optional "ro" module parameter. (For CD-ROM emulation, | ||
50 | * access is always read-only.) The gadget will indicate that it has | ||
51 | * removable media if the optional "removable" module parameter is set. | ||
52 | * | ||
53 | * The gadget supports the Control-Bulk (CB), Control-Bulk-Interrupt (CBI), | ||
54 | * and Bulk-Only (also known as Bulk-Bulk-Bulk or BBB) transports, selected | ||
55 | * by the optional "transport" module parameter. It also supports the | ||
56 | * following protocols: RBC (0x01), ATAPI or SFF-8020i (0x02), QIC-157 (0c03), | ||
57 | * UFI (0x04), SFF-8070i (0x05), and transparent SCSI (0x06), selected by | ||
58 | * the optional "protocol" module parameter. In addition, the default | ||
59 | * Vendor ID, Product ID, release number and serial number can be overridden. | ||
60 | * | ||
61 | * There is support for multiple logical units (LUNs), each of which has | ||
62 | * its own backing file. The number of LUNs can be set using the optional | ||
63 | * "luns" module parameter (anywhere from 1 to 8), and the corresponding | ||
64 | * files are specified using comma-separated lists for "file" and "ro". | ||
65 | * The default number of LUNs is taken from the number of "file" elements; | ||
66 | * it is 1 if "file" is not given. If "removable" is not set then a backing | ||
67 | * file must be specified for each LUN. If it is set, then an unspecified | ||
68 | * or empty backing filename means the LUN's medium is not loaded. Ideally | ||
69 | * each LUN would be settable independently as a disk drive or a CD-ROM | ||
70 | * drive, but currently all LUNs have to be the same type. The CD-ROM | ||
71 | * emulation includes a single data track and no audio tracks; hence there | ||
72 | * need be only one backing file per LUN. | ||
73 | * | ||
74 | * Requirements are modest; only a bulk-in and a bulk-out endpoint are | ||
75 | * needed (an interrupt-out endpoint is also needed for CBI). The memory | ||
76 | * requirement amounts to two 16K buffers, size configurable by a parameter. | ||
77 | * Support is included for both full-speed and high-speed operation. | ||
78 | * | ||
79 | * Note that the driver is slightly non-portable in that it assumes a | ||
80 | * single memory/DMA buffer will be useable for bulk-in, bulk-out, and | ||
81 | * interrupt-in endpoints. With most device controllers this isn't an | ||
82 | * issue, but there may be some with hardware restrictions that prevent | ||
83 | * a buffer from being used by more than one endpoint. | ||
84 | * | ||
85 | * Module options: | ||
86 | * | ||
87 | * file=filename[,filename...] | ||
88 | * Required if "removable" is not set, names of | ||
89 | * the files or block devices used for | ||
90 | * backing storage | ||
91 | * serial=HHHH... Required serial number (string of hex chars) | ||
92 | * ro=b[,b...] Default false, booleans for read-only access | ||
93 | * removable Default false, boolean for removable media | ||
94 | * luns=N Default N = number of filenames, number of | ||
95 | * LUNs to support | ||
96 | * nofua=b[,b...] Default false, booleans for ignore FUA flag | ||
97 | * in SCSI WRITE(10,12) commands | ||
98 | * stall Default determined according to the type of | ||
99 | * USB device controller (usually true), | ||
100 | * boolean to permit the driver to halt | ||
101 | * bulk endpoints | ||
102 | * cdrom Default false, boolean for whether to emulate | ||
103 | * a CD-ROM drive | ||
104 | * transport=XXX Default BBB, transport name (CB, CBI, or BBB) | ||
105 | * protocol=YYY Default SCSI, protocol name (RBC, 8020 or | ||
106 | * ATAPI, QIC, UFI, 8070, or SCSI; | ||
107 | * also 1 - 6) | ||
108 | * vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID | ||
109 | * product=0xPPPP Default 0xa4a5 (FSG), USB Product ID | ||
110 | * release=0xRRRR Override the USB release number (bcdDevice) | ||
111 | * buflen=N Default N=16384, buffer size used (will be | ||
112 | * rounded down to a multiple of | ||
113 | * PAGE_CACHE_SIZE) | ||
114 | * | ||
115 | * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "serial", "ro", | ||
116 | * "removable", "luns", "nofua", "stall", and "cdrom" options are available; | ||
117 | * default values are used for everything else. | ||
118 | * | ||
119 | * The pathnames of the backing files and the ro settings are available in | ||
120 | * the attribute files "file", "nofua", and "ro" in the lun<n> subdirectory of | ||
121 | * the gadget's sysfs directory. If the "removable" option is set, writing to | ||
122 | * these files will simulate ejecting/loading the medium (writing an empty | ||
123 | * line means eject) and adjusting a write-enable tab. Changes to the ro | ||
124 | * setting are not allowed when the medium is loaded or if CD-ROM emulation | ||
125 | * is being used. | ||
126 | * | ||
127 | * This gadget driver is heavily based on "Gadget Zero" by David Brownell. | ||
128 | * The driver's SCSI command interface was based on the "Information | ||
129 | * technology - Small Computer System Interface - 2" document from | ||
130 | * X3T9.2 Project 375D, Revision 10L, 7-SEP-93, available at | ||
131 | * <http://www.t10.org/ftp/t10/drafts/s2/s2-r10l.pdf>. The single exception | ||
132 | * is opcode 0x23 (READ FORMAT CAPACITIES), which was based on the | ||
133 | * "Universal Serial Bus Mass Storage Class UFI Command Specification" | ||
134 | * document, Revision 1.0, December 14, 1998, available at | ||
135 | * <http://www.usb.org/developers/devclass_docs/usbmass-ufi10.pdf>. | ||
136 | */ | ||
137 | |||
138 | |||
139 | /* | ||
140 | * Driver Design | ||
141 | * | ||
142 | * The FSG driver is fairly straightforward. There is a main kernel | ||
143 | * thread that handles most of the work. Interrupt routines field | ||
144 | * callbacks from the controller driver: bulk- and interrupt-request | ||
145 | * completion notifications, endpoint-0 events, and disconnect events. | ||
146 | * Completion events are passed to the main thread by wakeup calls. Many | ||
147 | * ep0 requests are handled at interrupt time, but SetInterface, | ||
148 | * SetConfiguration, and device reset requests are forwarded to the | ||
149 | * thread in the form of "exceptions" using SIGUSR1 signals (since they | ||
150 | * should interrupt any ongoing file I/O operations). | ||
151 | * | ||
152 | * The thread's main routine implements the standard command/data/status | ||
153 | * parts of a SCSI interaction. It and its subroutines are full of tests | ||
154 | * for pending signals/exceptions -- all this polling is necessary since | ||
155 | * the kernel has no setjmp/longjmp equivalents. (Maybe this is an | ||
156 | * indication that the driver really wants to be running in userspace.) | ||
157 | * An important point is that so long as the thread is alive it keeps an | ||
158 | * open reference to the backing file. This will prevent unmounting | ||
159 | * the backing file's underlying filesystem and could cause problems | ||
160 | * during system shutdown, for example. To prevent such problems, the | ||
161 | * thread catches INT, TERM, and KILL signals and converts them into | ||
162 | * an EXIT exception. | ||
163 | * | ||
164 | * In normal operation the main thread is started during the gadget's | ||
165 | * fsg_bind() callback and stopped during fsg_unbind(). But it can also | ||
166 | * exit when it receives a signal, and there's no point leaving the | ||
167 | * gadget running when the thread is dead. So just before the thread | ||
168 | * exits, it deregisters the gadget driver. This makes things a little | ||
169 | * tricky: The driver is deregistered at two places, and the exiting | ||
170 | * thread can indirectly call fsg_unbind() which in turn can tell the | ||
171 | * thread to exit. The first problem is resolved through the use of the | ||
172 | * REGISTERED atomic bitflag; the driver will only be deregistered once. | ||
173 | * The second problem is resolved by having fsg_unbind() check | ||
174 | * fsg->state; it won't try to stop the thread if the state is already | ||
175 | * FSG_STATE_TERMINATED. | ||
176 | * | ||
177 | * To provide maximum throughput, the driver uses a circular pipeline of | ||
178 | * buffer heads (struct fsg_buffhd). In principle the pipeline can be | ||
179 | * arbitrarily long; in practice the benefits don't justify having more | ||
180 | * than 2 stages (i.e., double buffering). But it helps to think of the | ||
181 | * pipeline as being a long one. Each buffer head contains a bulk-in and | ||
182 | * a bulk-out request pointer (since the buffer can be used for both | ||
183 | * output and input -- directions always are given from the host's | ||
184 | * point of view) as well as a pointer to the buffer and various state | ||
185 | * variables. | ||
186 | * | ||
187 | * Use of the pipeline follows a simple protocol. There is a variable | ||
188 | * (fsg->next_buffhd_to_fill) that points to the next buffer head to use. | ||
189 | * At any time that buffer head may still be in use from an earlier | ||
190 | * request, so each buffer head has a state variable indicating whether | ||
191 | * it is EMPTY, FULL, or BUSY. Typical use involves waiting for the | ||
192 | * buffer head to be EMPTY, filling the buffer either by file I/O or by | ||
193 | * USB I/O (during which the buffer head is BUSY), and marking the buffer | ||
194 | * head FULL when the I/O is complete. Then the buffer will be emptied | ||
195 | * (again possibly by USB I/O, during which it is marked BUSY) and | ||
196 | * finally marked EMPTY again (possibly by a completion routine). | ||
197 | * | ||
198 | * A module parameter tells the driver to avoid stalling the bulk | ||
199 | * endpoints wherever the transport specification allows. This is | ||
200 | * necessary for some UDCs like the SuperH, which cannot reliably clear a | ||
201 | * halt on a bulk endpoint. However, under certain circumstances the | ||
202 | * Bulk-only specification requires a stall. In such cases the driver | ||
203 | * will halt the endpoint and set a flag indicating that it should clear | ||
204 | * the halt in software during the next device reset. Hopefully this | ||
205 | * will permit everything to work correctly. Furthermore, although the | ||
206 | * specification allows the bulk-out endpoint to halt when the host sends | ||
207 | * too much data, implementing this would cause an unavoidable race. | ||
208 | * The driver will always use the "no-stall" approach for OUT transfers. | ||
209 | * | ||
210 | * One subtle point concerns sending status-stage responses for ep0 | ||
211 | * requests. Some of these requests, such as device reset, can involve | ||
212 | * interrupting an ongoing file I/O operation, which might take an | ||
213 | * arbitrarily long time. During that delay the host might give up on | ||
214 | * the original ep0 request and issue a new one. When that happens the | ||
215 | * driver should not notify the host about completion of the original | ||
216 | * request, as the host will no longer be waiting for it. So the driver | ||
217 | * assigns to each ep0 request a unique tag, and it keeps track of the | ||
218 | * tag value of the request associated with a long-running exception | ||
219 | * (device-reset, interface-change, or configuration-change). When the | ||
220 | * exception handler is finished, the status-stage response is submitted | ||
221 | * only if the current ep0 request tag is equal to the exception request | ||
222 | * tag. Thus only the most recently received ep0 request will get a | ||
223 | * status-stage response. | ||
224 | * | ||
225 | * Warning: This driver source file is too long. It ought to be split up | ||
226 | * into a header file plus about 3 separate .c files, to handle the details | ||
227 | * of the Gadget, USB Mass Storage, and SCSI protocols. | ||
228 | */ | ||
229 | |||
230 | |||
231 | /* #define VERBOSE_DEBUG */ | ||
232 | /* #define DUMP_MSGS */ | ||
233 | |||
234 | |||
235 | #include <linux/blkdev.h> | ||
236 | #include <linux/completion.h> | ||
237 | #include <linux/dcache.h> | ||
238 | #include <linux/delay.h> | ||
239 | #include <linux/device.h> | ||
240 | #include <linux/fcntl.h> | ||
241 | #include <linux/file.h> | ||
242 | #include <linux/fs.h> | ||
243 | #include <linux/kref.h> | ||
244 | #include <linux/kthread.h> | ||
245 | #include <linux/limits.h> | ||
246 | #include <linux/module.h> | ||
247 | #include <linux/rwsem.h> | ||
248 | #include <linux/slab.h> | ||
249 | #include <linux/spinlock.h> | ||
250 | #include <linux/string.h> | ||
251 | #include <linux/freezer.h> | ||
252 | #include <linux/utsname.h> | ||
253 | |||
254 | #include <linux/usb/composite.h> | ||
255 | #include <linux/usb/ch9.h> | ||
256 | #include <linux/usb/gadget.h> | ||
257 | |||
258 | #include "gadget_chips.h" | ||
259 | |||
260 | #define DRIVER_DESC "File-backed Storage Gadget" | ||
261 | #define DRIVER_NAME "g_file_storage" | ||
262 | #define DRIVER_VERSION "1 September 2010" | ||
263 | |||
264 | static char fsg_string_manufacturer[64]; | ||
265 | static const char fsg_string_product[] = DRIVER_DESC; | ||
266 | static const char fsg_string_config[] = "Self-powered"; | ||
267 | static const char fsg_string_interface[] = "Mass Storage"; | ||
268 | |||
269 | |||
270 | #include "storage_common.c" | ||
271 | |||
272 | |||
273 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
274 | MODULE_AUTHOR("Alan Stern"); | ||
275 | MODULE_LICENSE("Dual BSD/GPL"); | ||
276 | |||
277 | /* | ||
278 | * This driver assumes self-powered hardware and has no way for users to | ||
279 | * trigger remote wakeup. It uses autoconfiguration to select endpoints | ||
280 | * and endpoint addresses. | ||
281 | */ | ||
282 | |||
283 | |||
284 | /*-------------------------------------------------------------------------*/ | ||
285 | |||
286 | |||
287 | /* Encapsulate the module parameter settings */ | ||
288 | |||
289 | static struct { | ||
290 | char *file[FSG_MAX_LUNS]; | ||
291 | char *serial; | ||
292 | bool ro[FSG_MAX_LUNS]; | ||
293 | bool nofua[FSG_MAX_LUNS]; | ||
294 | unsigned int num_filenames; | ||
295 | unsigned int num_ros; | ||
296 | unsigned int num_nofuas; | ||
297 | unsigned int nluns; | ||
298 | |||
299 | bool removable; | ||
300 | bool can_stall; | ||
301 | bool cdrom; | ||
302 | |||
303 | char *transport_parm; | ||
304 | char *protocol_parm; | ||
305 | unsigned short vendor; | ||
306 | unsigned short product; | ||
307 | unsigned short release; | ||
308 | unsigned int buflen; | ||
309 | |||
310 | int transport_type; | ||
311 | char *transport_name; | ||
312 | int protocol_type; | ||
313 | char *protocol_name; | ||
314 | |||
315 | } mod_data = { // Default values | ||
316 | .transport_parm = "BBB", | ||
317 | .protocol_parm = "SCSI", | ||
318 | .removable = 0, | ||
319 | .can_stall = 1, | ||
320 | .cdrom = 0, | ||
321 | .vendor = FSG_VENDOR_ID, | ||
322 | .product = FSG_PRODUCT_ID, | ||
323 | .release = 0xffff, // Use controller chip type | ||
324 | .buflen = 16384, | ||
325 | }; | ||
326 | |||
327 | |||
328 | module_param_array_named(file, mod_data.file, charp, &mod_data.num_filenames, | ||
329 | S_IRUGO); | ||
330 | MODULE_PARM_DESC(file, "names of backing files or devices"); | ||
331 | |||
332 | module_param_named(serial, mod_data.serial, charp, S_IRUGO); | ||
333 | MODULE_PARM_DESC(serial, "USB serial number"); | ||
334 | |||
335 | module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO); | ||
336 | MODULE_PARM_DESC(ro, "true to force read-only"); | ||
337 | |||
338 | module_param_array_named(nofua, mod_data.nofua, bool, &mod_data.num_nofuas, | ||
339 | S_IRUGO); | ||
340 | MODULE_PARM_DESC(nofua, "true to ignore SCSI WRITE(10,12) FUA bit"); | ||
341 | |||
342 | module_param_named(luns, mod_data.nluns, uint, S_IRUGO); | ||
343 | MODULE_PARM_DESC(luns, "number of LUNs"); | ||
344 | |||
345 | module_param_named(removable, mod_data.removable, bool, S_IRUGO); | ||
346 | MODULE_PARM_DESC(removable, "true to simulate removable media"); | ||
347 | |||
348 | module_param_named(stall, mod_data.can_stall, bool, S_IRUGO); | ||
349 | MODULE_PARM_DESC(stall, "false to prevent bulk stalls"); | ||
350 | |||
351 | module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO); | ||
352 | MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk"); | ||
353 | |||
354 | /* In the non-TEST version, only the module parameters listed above | ||
355 | * are available. */ | ||
356 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | ||
357 | |||
358 | module_param_named(transport, mod_data.transport_parm, charp, S_IRUGO); | ||
359 | MODULE_PARM_DESC(transport, "type of transport (BBB, CBI, or CB)"); | ||
360 | |||
361 | module_param_named(protocol, mod_data.protocol_parm, charp, S_IRUGO); | ||
362 | MODULE_PARM_DESC(protocol, "type of protocol (RBC, 8020, QIC, UFI, " | ||
363 | "8070, or SCSI)"); | ||
364 | |||
365 | module_param_named(vendor, mod_data.vendor, ushort, S_IRUGO); | ||
366 | MODULE_PARM_DESC(vendor, "USB Vendor ID"); | ||
367 | |||
368 | module_param_named(product, mod_data.product, ushort, S_IRUGO); | ||
369 | MODULE_PARM_DESC(product, "USB Product ID"); | ||
370 | |||
371 | module_param_named(release, mod_data.release, ushort, S_IRUGO); | ||
372 | MODULE_PARM_DESC(release, "USB release number"); | ||
373 | |||
374 | module_param_named(buflen, mod_data.buflen, uint, S_IRUGO); | ||
375 | MODULE_PARM_DESC(buflen, "I/O buffer size"); | ||
376 | |||
377 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ | ||
378 | |||
379 | |||
380 | /* | ||
381 | * These definitions will permit the compiler to avoid generating code for | ||
382 | * parts of the driver that aren't used in the non-TEST version. Even gcc | ||
383 | * can recognize when a test of a constant expression yields a dead code | ||
384 | * path. | ||
385 | */ | ||
386 | |||
387 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | ||
388 | |||
389 | #define transport_is_bbb() (mod_data.transport_type == USB_PR_BULK) | ||
390 | #define transport_is_cbi() (mod_data.transport_type == USB_PR_CBI) | ||
391 | #define protocol_is_scsi() (mod_data.protocol_type == USB_SC_SCSI) | ||
392 | |||
393 | #else | ||
394 | |||
395 | #define transport_is_bbb() 1 | ||
396 | #define transport_is_cbi() 0 | ||
397 | #define protocol_is_scsi() 1 | ||
398 | |||
399 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ | ||
400 | |||
401 | |||
402 | /*-------------------------------------------------------------------------*/ | ||
403 | |||
404 | |||
405 | struct fsg_dev { | ||
406 | /* lock protects: state, all the req_busy's, and cbbuf_cmnd */ | ||
407 | spinlock_t lock; | ||
408 | struct usb_gadget *gadget; | ||
409 | |||
410 | /* filesem protects: backing files in use */ | ||
411 | struct rw_semaphore filesem; | ||
412 | |||
413 | /* reference counting: wait until all LUNs are released */ | ||
414 | struct kref ref; | ||
415 | |||
416 | struct usb_ep *ep0; // Handy copy of gadget->ep0 | ||
417 | struct usb_request *ep0req; // For control responses | ||
418 | unsigned int ep0_req_tag; | ||
419 | const char *ep0req_name; | ||
420 | |||
421 | struct usb_request *intreq; // For interrupt responses | ||
422 | int intreq_busy; | ||
423 | struct fsg_buffhd *intr_buffhd; | ||
424 | |||
425 | unsigned int bulk_out_maxpacket; | ||
426 | enum fsg_state state; // For exception handling | ||
427 | unsigned int exception_req_tag; | ||
428 | |||
429 | u8 config, new_config; | ||
430 | |||
431 | unsigned int running : 1; | ||
432 | unsigned int bulk_in_enabled : 1; | ||
433 | unsigned int bulk_out_enabled : 1; | ||
434 | unsigned int intr_in_enabled : 1; | ||
435 | unsigned int phase_error : 1; | ||
436 | unsigned int short_packet_received : 1; | ||
437 | unsigned int bad_lun_okay : 1; | ||
438 | |||
439 | unsigned long atomic_bitflags; | ||
440 | #define REGISTERED 0 | ||
441 | #define IGNORE_BULK_OUT 1 | ||
442 | #define SUSPENDED 2 | ||
443 | |||
444 | struct usb_ep *bulk_in; | ||
445 | struct usb_ep *bulk_out; | ||
446 | struct usb_ep *intr_in; | ||
447 | |||
448 | struct fsg_buffhd *next_buffhd_to_fill; | ||
449 | struct fsg_buffhd *next_buffhd_to_drain; | ||
450 | |||
451 | int thread_wakeup_needed; | ||
452 | struct completion thread_notifier; | ||
453 | struct task_struct *thread_task; | ||
454 | |||
455 | int cmnd_size; | ||
456 | u8 cmnd[MAX_COMMAND_SIZE]; | ||
457 | enum data_direction data_dir; | ||
458 | u32 data_size; | ||
459 | u32 data_size_from_cmnd; | ||
460 | u32 tag; | ||
461 | unsigned int lun; | ||
462 | u32 residue; | ||
463 | u32 usb_amount_left; | ||
464 | |||
465 | /* The CB protocol offers no way for a host to know when a command | ||
466 | * has completed. As a result the next command may arrive early, | ||
467 | * and we will still have to handle it. For that reason we need | ||
468 | * a buffer to store new commands when using CB (or CBI, which | ||
469 | * does not oblige a host to wait for command completion either). */ | ||
470 | int cbbuf_cmnd_size; | ||
471 | u8 cbbuf_cmnd[MAX_COMMAND_SIZE]; | ||
472 | |||
473 | unsigned int nluns; | ||
474 | struct fsg_lun *luns; | ||
475 | struct fsg_lun *curlun; | ||
476 | /* Must be the last entry */ | ||
477 | struct fsg_buffhd buffhds[]; | ||
478 | }; | ||
479 | |||
480 | typedef void (*fsg_routine_t)(struct fsg_dev *); | ||
481 | |||
482 | static int exception_in_progress(struct fsg_dev *fsg) | ||
483 | { | ||
484 | return (fsg->state > FSG_STATE_IDLE); | ||
485 | } | ||
486 | |||
487 | /* Make bulk-out requests be divisible by the maxpacket size */ | ||
488 | static void set_bulk_out_req_length(struct fsg_dev *fsg, | ||
489 | struct fsg_buffhd *bh, unsigned int length) | ||
490 | { | ||
491 | unsigned int rem; | ||
492 | |||
493 | bh->bulk_out_intended_length = length; | ||
494 | rem = length % fsg->bulk_out_maxpacket; | ||
495 | if (rem > 0) | ||
496 | length += fsg->bulk_out_maxpacket - rem; | ||
497 | bh->outreq->length = length; | ||
498 | } | ||
499 | |||
500 | static struct fsg_dev *the_fsg; | ||
501 | static struct usb_gadget_driver fsg_driver; | ||
502 | |||
503 | |||
504 | /*-------------------------------------------------------------------------*/ | ||
505 | |||
506 | static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep) | ||
507 | { | ||
508 | const char *name; | ||
509 | |||
510 | if (ep == fsg->bulk_in) | ||
511 | name = "bulk-in"; | ||
512 | else if (ep == fsg->bulk_out) | ||
513 | name = "bulk-out"; | ||
514 | else | ||
515 | name = ep->name; | ||
516 | DBG(fsg, "%s set halt\n", name); | ||
517 | return usb_ep_set_halt(ep); | ||
518 | } | ||
519 | |||
520 | |||
521 | /*-------------------------------------------------------------------------*/ | ||
522 | |||
523 | /* | ||
524 | * DESCRIPTORS ... most are static, but strings and (full) configuration | ||
525 | * descriptors are built on demand. Also the (static) config and interface | ||
526 | * descriptors are adjusted during fsg_bind(). | ||
527 | */ | ||
528 | |||
529 | /* There is only one configuration. */ | ||
530 | #define CONFIG_VALUE 1 | ||
531 | |||
532 | static struct usb_device_descriptor | ||
533 | device_desc = { | ||
534 | .bLength = sizeof device_desc, | ||
535 | .bDescriptorType = USB_DT_DEVICE, | ||
536 | |||
537 | .bcdUSB = cpu_to_le16(0x0200), | ||
538 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | ||
539 | |||
540 | /* The next three values can be overridden by module parameters */ | ||
541 | .idVendor = cpu_to_le16(FSG_VENDOR_ID), | ||
542 | .idProduct = cpu_to_le16(FSG_PRODUCT_ID), | ||
543 | .bcdDevice = cpu_to_le16(0xffff), | ||
544 | |||
545 | .iManufacturer = FSG_STRING_MANUFACTURER, | ||
546 | .iProduct = FSG_STRING_PRODUCT, | ||
547 | .iSerialNumber = FSG_STRING_SERIAL, | ||
548 | .bNumConfigurations = 1, | ||
549 | }; | ||
550 | |||
551 | static struct usb_config_descriptor | ||
552 | config_desc = { | ||
553 | .bLength = sizeof config_desc, | ||
554 | .bDescriptorType = USB_DT_CONFIG, | ||
555 | |||
556 | /* wTotalLength computed by usb_gadget_config_buf() */ | ||
557 | .bNumInterfaces = 1, | ||
558 | .bConfigurationValue = CONFIG_VALUE, | ||
559 | .iConfiguration = FSG_STRING_CONFIG, | ||
560 | .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, | ||
561 | .bMaxPower = CONFIG_USB_GADGET_VBUS_DRAW / 2, | ||
562 | }; | ||
563 | |||
564 | |||
565 | static struct usb_qualifier_descriptor | ||
566 | dev_qualifier = { | ||
567 | .bLength = sizeof dev_qualifier, | ||
568 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, | ||
569 | |||
570 | .bcdUSB = cpu_to_le16(0x0200), | ||
571 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | ||
572 | |||
573 | .bNumConfigurations = 1, | ||
574 | }; | ||
575 | |||
576 | static int populate_bos(struct fsg_dev *fsg, u8 *buf) | ||
577 | { | ||
578 | memcpy(buf, &fsg_bos_desc, USB_DT_BOS_SIZE); | ||
579 | buf += USB_DT_BOS_SIZE; | ||
580 | |||
581 | memcpy(buf, &fsg_ext_cap_desc, USB_DT_USB_EXT_CAP_SIZE); | ||
582 | buf += USB_DT_USB_EXT_CAP_SIZE; | ||
583 | |||
584 | memcpy(buf, &fsg_ss_cap_desc, USB_DT_USB_SS_CAP_SIZE); | ||
585 | |||
586 | return USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE | ||
587 | + USB_DT_USB_EXT_CAP_SIZE; | ||
588 | } | ||
589 | |||
590 | /* | ||
591 | * Config descriptors must agree with the code that sets configurations | ||
592 | * and with code managing interfaces and their altsettings. They must | ||
593 | * also handle different speeds and other-speed requests. | ||
594 | */ | ||
595 | static int populate_config_buf(struct usb_gadget *gadget, | ||
596 | u8 *buf, u8 type, unsigned index) | ||
597 | { | ||
598 | enum usb_device_speed speed = gadget->speed; | ||
599 | int len; | ||
600 | const struct usb_descriptor_header **function; | ||
601 | |||
602 | if (index > 0) | ||
603 | return -EINVAL; | ||
604 | |||
605 | if (gadget_is_dualspeed(gadget) && type == USB_DT_OTHER_SPEED_CONFIG) | ||
606 | speed = (USB_SPEED_FULL + USB_SPEED_HIGH) - speed; | ||
607 | function = gadget_is_dualspeed(gadget) && speed == USB_SPEED_HIGH | ||
608 | ? (const struct usb_descriptor_header **)fsg_hs_function | ||
609 | : (const struct usb_descriptor_header **)fsg_fs_function; | ||
610 | |||
611 | /* for now, don't advertise srp-only devices */ | ||
612 | if (!gadget_is_otg(gadget)) | ||
613 | function++; | ||
614 | |||
615 | len = usb_gadget_config_buf(&config_desc, buf, EP0_BUFSIZE, function); | ||
616 | ((struct usb_config_descriptor *) buf)->bDescriptorType = type; | ||
617 | return len; | ||
618 | } | ||
619 | |||
620 | |||
621 | /*-------------------------------------------------------------------------*/ | ||
622 | |||
623 | /* These routines may be called in process context or in_irq */ | ||
624 | |||
625 | /* Caller must hold fsg->lock */ | ||
626 | static void wakeup_thread(struct fsg_dev *fsg) | ||
627 | { | ||
628 | /* Tell the main thread that something has happened */ | ||
629 | fsg->thread_wakeup_needed = 1; | ||
630 | if (fsg->thread_task) | ||
631 | wake_up_process(fsg->thread_task); | ||
632 | } | ||
633 | |||
634 | |||
635 | static void raise_exception(struct fsg_dev *fsg, enum fsg_state new_state) | ||
636 | { | ||
637 | unsigned long flags; | ||
638 | |||
639 | /* Do nothing if a higher-priority exception is already in progress. | ||
640 | * If a lower-or-equal priority exception is in progress, preempt it | ||
641 | * and notify the main thread by sending it a signal. */ | ||
642 | spin_lock_irqsave(&fsg->lock, flags); | ||
643 | if (fsg->state <= new_state) { | ||
644 | fsg->exception_req_tag = fsg->ep0_req_tag; | ||
645 | fsg->state = new_state; | ||
646 | if (fsg->thread_task) | ||
647 | send_sig_info(SIGUSR1, SEND_SIG_FORCED, | ||
648 | fsg->thread_task); | ||
649 | } | ||
650 | spin_unlock_irqrestore(&fsg->lock, flags); | ||
651 | } | ||
652 | |||
653 | |||
654 | /*-------------------------------------------------------------------------*/ | ||
655 | |||
656 | /* The disconnect callback and ep0 routines. These always run in_irq, | ||
657 | * except that ep0_queue() is called in the main thread to acknowledge | ||
658 | * completion of various requests: set config, set interface, and | ||
659 | * Bulk-only device reset. */ | ||
660 | |||
661 | static void fsg_disconnect(struct usb_gadget *gadget) | ||
662 | { | ||
663 | struct fsg_dev *fsg = get_gadget_data(gadget); | ||
664 | |||
665 | DBG(fsg, "disconnect or port reset\n"); | ||
666 | raise_exception(fsg, FSG_STATE_DISCONNECT); | ||
667 | } | ||
668 | |||
669 | |||
670 | static int ep0_queue(struct fsg_dev *fsg) | ||
671 | { | ||
672 | int rc; | ||
673 | |||
674 | rc = usb_ep_queue(fsg->ep0, fsg->ep0req, GFP_ATOMIC); | ||
675 | if (rc != 0 && rc != -ESHUTDOWN) { | ||
676 | |||
677 | /* We can't do much more than wait for a reset */ | ||
678 | WARNING(fsg, "error in submission: %s --> %d\n", | ||
679 | fsg->ep0->name, rc); | ||
680 | } | ||
681 | return rc; | ||
682 | } | ||
683 | |||
684 | static void ep0_complete(struct usb_ep *ep, struct usb_request *req) | ||
685 | { | ||
686 | struct fsg_dev *fsg = ep->driver_data; | ||
687 | |||
688 | if (req->actual > 0) | ||
689 | dump_msg(fsg, fsg->ep0req_name, req->buf, req->actual); | ||
690 | if (req->status || req->actual != req->length) | ||
691 | DBG(fsg, "%s --> %d, %u/%u\n", __func__, | ||
692 | req->status, req->actual, req->length); | ||
693 | if (req->status == -ECONNRESET) // Request was cancelled | ||
694 | usb_ep_fifo_flush(ep); | ||
695 | |||
696 | if (req->status == 0 && req->context) | ||
697 | ((fsg_routine_t) (req->context))(fsg); | ||
698 | } | ||
699 | |||
700 | |||
701 | /*-------------------------------------------------------------------------*/ | ||
702 | |||
703 | /* Bulk and interrupt endpoint completion handlers. | ||
704 | * These always run in_irq. */ | ||
705 | |||
706 | static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req) | ||
707 | { | ||
708 | struct fsg_dev *fsg = ep->driver_data; | ||
709 | struct fsg_buffhd *bh = req->context; | ||
710 | |||
711 | if (req->status || req->actual != req->length) | ||
712 | DBG(fsg, "%s --> %d, %u/%u\n", __func__, | ||
713 | req->status, req->actual, req->length); | ||
714 | if (req->status == -ECONNRESET) // Request was cancelled | ||
715 | usb_ep_fifo_flush(ep); | ||
716 | |||
717 | /* Hold the lock while we update the request and buffer states */ | ||
718 | smp_wmb(); | ||
719 | spin_lock(&fsg->lock); | ||
720 | bh->inreq_busy = 0; | ||
721 | bh->state = BUF_STATE_EMPTY; | ||
722 | wakeup_thread(fsg); | ||
723 | spin_unlock(&fsg->lock); | ||
724 | } | ||
725 | |||
726 | static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) | ||
727 | { | ||
728 | struct fsg_dev *fsg = ep->driver_data; | ||
729 | struct fsg_buffhd *bh = req->context; | ||
730 | |||
731 | dump_msg(fsg, "bulk-out", req->buf, req->actual); | ||
732 | if (req->status || req->actual != bh->bulk_out_intended_length) | ||
733 | DBG(fsg, "%s --> %d, %u/%u\n", __func__, | ||
734 | req->status, req->actual, | ||
735 | bh->bulk_out_intended_length); | ||
736 | if (req->status == -ECONNRESET) // Request was cancelled | ||
737 | usb_ep_fifo_flush(ep); | ||
738 | |||
739 | /* Hold the lock while we update the request and buffer states */ | ||
740 | smp_wmb(); | ||
741 | spin_lock(&fsg->lock); | ||
742 | bh->outreq_busy = 0; | ||
743 | bh->state = BUF_STATE_FULL; | ||
744 | wakeup_thread(fsg); | ||
745 | spin_unlock(&fsg->lock); | ||
746 | } | ||
747 | |||
748 | |||
749 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | ||
750 | static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) | ||
751 | { | ||
752 | struct fsg_dev *fsg = ep->driver_data; | ||
753 | struct fsg_buffhd *bh = req->context; | ||
754 | |||
755 | if (req->status || req->actual != req->length) | ||
756 | DBG(fsg, "%s --> %d, %u/%u\n", __func__, | ||
757 | req->status, req->actual, req->length); | ||
758 | if (req->status == -ECONNRESET) // Request was cancelled | ||
759 | usb_ep_fifo_flush(ep); | ||
760 | |||
761 | /* Hold the lock while we update the request and buffer states */ | ||
762 | smp_wmb(); | ||
763 | spin_lock(&fsg->lock); | ||
764 | fsg->intreq_busy = 0; | ||
765 | bh->state = BUF_STATE_EMPTY; | ||
766 | wakeup_thread(fsg); | ||
767 | spin_unlock(&fsg->lock); | ||
768 | } | ||
769 | |||
770 | #else | ||
771 | static void intr_in_complete(struct usb_ep *ep, struct usb_request *req) | ||
772 | {} | ||
773 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ | ||
774 | |||
775 | |||
776 | /*-------------------------------------------------------------------------*/ | ||
777 | |||
778 | /* Ep0 class-specific handlers. These always run in_irq. */ | ||
779 | |||
780 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | ||
781 | static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
782 | { | ||
783 | struct usb_request *req = fsg->ep0req; | ||
784 | static u8 cbi_reset_cmnd[6] = { | ||
785 | SEND_DIAGNOSTIC, 4, 0xff, 0xff, 0xff, 0xff}; | ||
786 | |||
787 | /* Error in command transfer? */ | ||
788 | if (req->status || req->length != req->actual || | ||
789 | req->actual < 6 || req->actual > MAX_COMMAND_SIZE) { | ||
790 | |||
791 | /* Not all controllers allow a protocol stall after | ||
792 | * receiving control-out data, but we'll try anyway. */ | ||
793 | fsg_set_halt(fsg, fsg->ep0); | ||
794 | return; // Wait for reset | ||
795 | } | ||
796 | |||
797 | /* Is it the special reset command? */ | ||
798 | if (req->actual >= sizeof cbi_reset_cmnd && | ||
799 | memcmp(req->buf, cbi_reset_cmnd, | ||
800 | sizeof cbi_reset_cmnd) == 0) { | ||
801 | |||
802 | /* Raise an exception to stop the current operation | ||
803 | * and reinitialize our state. */ | ||
804 | DBG(fsg, "cbi reset request\n"); | ||
805 | raise_exception(fsg, FSG_STATE_RESET); | ||
806 | return; | ||
807 | } | ||
808 | |||
809 | VDBG(fsg, "CB[I] accept device-specific command\n"); | ||
810 | spin_lock(&fsg->lock); | ||
811 | |||
812 | /* Save the command for later */ | ||
813 | if (fsg->cbbuf_cmnd_size) | ||
814 | WARNING(fsg, "CB[I] overwriting previous command\n"); | ||
815 | fsg->cbbuf_cmnd_size = req->actual; | ||
816 | memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size); | ||
817 | |||
818 | wakeup_thread(fsg); | ||
819 | spin_unlock(&fsg->lock); | ||
820 | } | ||
821 | |||
822 | #else | ||
823 | static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
824 | {} | ||
825 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ | ||
826 | |||
827 | |||
828 | static int class_setup_req(struct fsg_dev *fsg, | ||
829 | const struct usb_ctrlrequest *ctrl) | ||
830 | { | ||
831 | struct usb_request *req = fsg->ep0req; | ||
832 | int value = -EOPNOTSUPP; | ||
833 | u16 w_index = le16_to_cpu(ctrl->wIndex); | ||
834 | u16 w_value = le16_to_cpu(ctrl->wValue); | ||
835 | u16 w_length = le16_to_cpu(ctrl->wLength); | ||
836 | |||
837 | if (!fsg->config) | ||
838 | return value; | ||
839 | |||
840 | /* Handle Bulk-only class-specific requests */ | ||
841 | if (transport_is_bbb()) { | ||
842 | switch (ctrl->bRequest) { | ||
843 | |||
844 | case US_BULK_RESET_REQUEST: | ||
845 | if (ctrl->bRequestType != (USB_DIR_OUT | | ||
846 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | ||
847 | break; | ||
848 | if (w_index != 0 || w_value != 0 || w_length != 0) { | ||
849 | value = -EDOM; | ||
850 | break; | ||
851 | } | ||
852 | |||
853 | /* Raise an exception to stop the current operation | ||
854 | * and reinitialize our state. */ | ||
855 | DBG(fsg, "bulk reset request\n"); | ||
856 | raise_exception(fsg, FSG_STATE_RESET); | ||
857 | value = DELAYED_STATUS; | ||
858 | break; | ||
859 | |||
860 | case US_BULK_GET_MAX_LUN: | ||
861 | if (ctrl->bRequestType != (USB_DIR_IN | | ||
862 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | ||
863 | break; | ||
864 | if (w_index != 0 || w_value != 0 || w_length != 1) { | ||
865 | value = -EDOM; | ||
866 | break; | ||
867 | } | ||
868 | VDBG(fsg, "get max LUN\n"); | ||
869 | *(u8 *) req->buf = fsg->nluns - 1; | ||
870 | value = 1; | ||
871 | break; | ||
872 | } | ||
873 | } | ||
874 | |||
875 | /* Handle CBI class-specific requests */ | ||
876 | else { | ||
877 | switch (ctrl->bRequest) { | ||
878 | |||
879 | case USB_CBI_ADSC_REQUEST: | ||
880 | if (ctrl->bRequestType != (USB_DIR_OUT | | ||
881 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | ||
882 | break; | ||
883 | if (w_index != 0 || w_value != 0) { | ||
884 | value = -EDOM; | ||
885 | break; | ||
886 | } | ||
887 | if (w_length > MAX_COMMAND_SIZE) { | ||
888 | value = -EOVERFLOW; | ||
889 | break; | ||
890 | } | ||
891 | value = w_length; | ||
892 | fsg->ep0req->context = received_cbi_adsc; | ||
893 | break; | ||
894 | } | ||
895 | } | ||
896 | |||
897 | if (value == -EOPNOTSUPP) | ||
898 | VDBG(fsg, | ||
899 | "unknown class-specific control req " | ||
900 | "%02x.%02x v%04x i%04x l%u\n", | ||
901 | ctrl->bRequestType, ctrl->bRequest, | ||
902 | le16_to_cpu(ctrl->wValue), w_index, w_length); | ||
903 | return value; | ||
904 | } | ||
905 | |||
906 | |||
907 | /*-------------------------------------------------------------------------*/ | ||
908 | |||
909 | /* Ep0 standard request handlers. These always run in_irq. */ | ||
910 | |||
911 | static int standard_setup_req(struct fsg_dev *fsg, | ||
912 | const struct usb_ctrlrequest *ctrl) | ||
913 | { | ||
914 | struct usb_request *req = fsg->ep0req; | ||
915 | int value = -EOPNOTSUPP; | ||
916 | u16 w_index = le16_to_cpu(ctrl->wIndex); | ||
917 | u16 w_value = le16_to_cpu(ctrl->wValue); | ||
918 | |||
919 | /* Usually this just stores reply data in the pre-allocated ep0 buffer, | ||
920 | * but config change events will also reconfigure hardware. */ | ||
921 | switch (ctrl->bRequest) { | ||
922 | |||
923 | case USB_REQ_GET_DESCRIPTOR: | ||
924 | if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD | | ||
925 | USB_RECIP_DEVICE)) | ||
926 | break; | ||
927 | switch (w_value >> 8) { | ||
928 | |||
929 | case USB_DT_DEVICE: | ||
930 | VDBG(fsg, "get device descriptor\n"); | ||
931 | device_desc.bMaxPacketSize0 = fsg->ep0->maxpacket; | ||
932 | value = sizeof device_desc; | ||
933 | memcpy(req->buf, &device_desc, value); | ||
934 | break; | ||
935 | case USB_DT_DEVICE_QUALIFIER: | ||
936 | VDBG(fsg, "get device qualifier\n"); | ||
937 | if (!gadget_is_dualspeed(fsg->gadget) || | ||
938 | fsg->gadget->speed == USB_SPEED_SUPER) | ||
939 | break; | ||
940 | /* | ||
941 | * Assume ep0 uses the same maxpacket value for both | ||
942 | * speeds | ||
943 | */ | ||
944 | dev_qualifier.bMaxPacketSize0 = fsg->ep0->maxpacket; | ||
945 | value = sizeof dev_qualifier; | ||
946 | memcpy(req->buf, &dev_qualifier, value); | ||
947 | break; | ||
948 | |||
949 | case USB_DT_OTHER_SPEED_CONFIG: | ||
950 | VDBG(fsg, "get other-speed config descriptor\n"); | ||
951 | if (!gadget_is_dualspeed(fsg->gadget) || | ||
952 | fsg->gadget->speed == USB_SPEED_SUPER) | ||
953 | break; | ||
954 | goto get_config; | ||
955 | case USB_DT_CONFIG: | ||
956 | VDBG(fsg, "get configuration descriptor\n"); | ||
957 | get_config: | ||
958 | value = populate_config_buf(fsg->gadget, | ||
959 | req->buf, | ||
960 | w_value >> 8, | ||
961 | w_value & 0xff); | ||
962 | break; | ||
963 | |||
964 | case USB_DT_STRING: | ||
965 | VDBG(fsg, "get string descriptor\n"); | ||
966 | |||
967 | /* wIndex == language code */ | ||
968 | value = usb_gadget_get_string(&fsg_stringtab, | ||
969 | w_value & 0xff, req->buf); | ||
970 | break; | ||
971 | |||
972 | case USB_DT_BOS: | ||
973 | VDBG(fsg, "get bos descriptor\n"); | ||
974 | |||
975 | if (gadget_is_superspeed(fsg->gadget)) | ||
976 | value = populate_bos(fsg, req->buf); | ||
977 | break; | ||
978 | } | ||
979 | |||
980 | break; | ||
981 | |||
982 | /* One config, two speeds */ | ||
983 | case USB_REQ_SET_CONFIGURATION: | ||
984 | if (ctrl->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD | | ||
985 | USB_RECIP_DEVICE)) | ||
986 | break; | ||
987 | VDBG(fsg, "set configuration\n"); | ||
988 | if (w_value == CONFIG_VALUE || w_value == 0) { | ||
989 | fsg->new_config = w_value; | ||
990 | |||
991 | /* Raise an exception to wipe out previous transaction | ||
992 | * state (queued bufs, etc) and set the new config. */ | ||
993 | raise_exception(fsg, FSG_STATE_CONFIG_CHANGE); | ||
994 | value = DELAYED_STATUS; | ||
995 | } | ||
996 | break; | ||
997 | case USB_REQ_GET_CONFIGURATION: | ||
998 | if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD | | ||
999 | USB_RECIP_DEVICE)) | ||
1000 | break; | ||
1001 | VDBG(fsg, "get configuration\n"); | ||
1002 | *(u8 *) req->buf = fsg->config; | ||
1003 | value = 1; | ||
1004 | break; | ||
1005 | |||
1006 | case USB_REQ_SET_INTERFACE: | ||
1007 | if (ctrl->bRequestType != (USB_DIR_OUT| USB_TYPE_STANDARD | | ||
1008 | USB_RECIP_INTERFACE)) | ||
1009 | break; | ||
1010 | if (fsg->config && w_index == 0) { | ||
1011 | |||
1012 | /* Raise an exception to wipe out previous transaction | ||
1013 | * state (queued bufs, etc) and install the new | ||
1014 | * interface altsetting. */ | ||
1015 | raise_exception(fsg, FSG_STATE_INTERFACE_CHANGE); | ||
1016 | value = DELAYED_STATUS; | ||
1017 | } | ||
1018 | break; | ||
1019 | case USB_REQ_GET_INTERFACE: | ||
1020 | if (ctrl->bRequestType != (USB_DIR_IN | USB_TYPE_STANDARD | | ||
1021 | USB_RECIP_INTERFACE)) | ||
1022 | break; | ||
1023 | if (!fsg->config) | ||
1024 | break; | ||
1025 | if (w_index != 0) { | ||
1026 | value = -EDOM; | ||
1027 | break; | ||
1028 | } | ||
1029 | VDBG(fsg, "get interface\n"); | ||
1030 | *(u8 *) req->buf = 0; | ||
1031 | value = 1; | ||
1032 | break; | ||
1033 | |||
1034 | default: | ||
1035 | VDBG(fsg, | ||
1036 | "unknown control req %02x.%02x v%04x i%04x l%u\n", | ||
1037 | ctrl->bRequestType, ctrl->bRequest, | ||
1038 | w_value, w_index, le16_to_cpu(ctrl->wLength)); | ||
1039 | } | ||
1040 | |||
1041 | return value; | ||
1042 | } | ||
1043 | |||
1044 | |||
1045 | static int fsg_setup(struct usb_gadget *gadget, | ||
1046 | const struct usb_ctrlrequest *ctrl) | ||
1047 | { | ||
1048 | struct fsg_dev *fsg = get_gadget_data(gadget); | ||
1049 | int rc; | ||
1050 | int w_length = le16_to_cpu(ctrl->wLength); | ||
1051 | |||
1052 | ++fsg->ep0_req_tag; // Record arrival of a new request | ||
1053 | fsg->ep0req->context = NULL; | ||
1054 | fsg->ep0req->length = 0; | ||
1055 | dump_msg(fsg, "ep0-setup", (u8 *) ctrl, sizeof(*ctrl)); | ||
1056 | |||
1057 | if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) | ||
1058 | rc = class_setup_req(fsg, ctrl); | ||
1059 | else | ||
1060 | rc = standard_setup_req(fsg, ctrl); | ||
1061 | |||
1062 | /* Respond with data/status or defer until later? */ | ||
1063 | if (rc >= 0 && rc != DELAYED_STATUS) { | ||
1064 | rc = min(rc, w_length); | ||
1065 | fsg->ep0req->length = rc; | ||
1066 | fsg->ep0req->zero = rc < w_length; | ||
1067 | fsg->ep0req_name = (ctrl->bRequestType & USB_DIR_IN ? | ||
1068 | "ep0-in" : "ep0-out"); | ||
1069 | rc = ep0_queue(fsg); | ||
1070 | } | ||
1071 | |||
1072 | /* Device either stalls (rc < 0) or reports success */ | ||
1073 | return rc; | ||
1074 | } | ||
1075 | |||
1076 | |||
1077 | /*-------------------------------------------------------------------------*/ | ||
1078 | |||
1079 | /* All the following routines run in process context */ | ||
1080 | |||
1081 | |||
1082 | /* Use this for bulk or interrupt transfers, not ep0 */ | ||
1083 | static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, | ||
1084 | struct usb_request *req, int *pbusy, | ||
1085 | enum fsg_buffer_state *state) | ||
1086 | { | ||
1087 | int rc; | ||
1088 | |||
1089 | if (ep == fsg->bulk_in) | ||
1090 | dump_msg(fsg, "bulk-in", req->buf, req->length); | ||
1091 | else if (ep == fsg->intr_in) | ||
1092 | dump_msg(fsg, "intr-in", req->buf, req->length); | ||
1093 | |||
1094 | spin_lock_irq(&fsg->lock); | ||
1095 | *pbusy = 1; | ||
1096 | *state = BUF_STATE_BUSY; | ||
1097 | spin_unlock_irq(&fsg->lock); | ||
1098 | rc = usb_ep_queue(ep, req, GFP_KERNEL); | ||
1099 | if (rc != 0) { | ||
1100 | *pbusy = 0; | ||
1101 | *state = BUF_STATE_EMPTY; | ||
1102 | |||
1103 | /* We can't do much more than wait for a reset */ | ||
1104 | |||
1105 | /* Note: currently the net2280 driver fails zero-length | ||
1106 | * submissions if DMA is enabled. */ | ||
1107 | if (rc != -ESHUTDOWN && !(rc == -EOPNOTSUPP && | ||
1108 | req->length == 0)) | ||
1109 | WARNING(fsg, "error in submission: %s --> %d\n", | ||
1110 | ep->name, rc); | ||
1111 | } | ||
1112 | } | ||
1113 | |||
1114 | |||
1115 | static int sleep_thread(struct fsg_dev *fsg) | ||
1116 | { | ||
1117 | int rc = 0; | ||
1118 | |||
1119 | /* Wait until a signal arrives or we are woken up */ | ||
1120 | for (;;) { | ||
1121 | try_to_freeze(); | ||
1122 | set_current_state(TASK_INTERRUPTIBLE); | ||
1123 | if (signal_pending(current)) { | ||
1124 | rc = -EINTR; | ||
1125 | break; | ||
1126 | } | ||
1127 | if (fsg->thread_wakeup_needed) | ||
1128 | break; | ||
1129 | schedule(); | ||
1130 | } | ||
1131 | __set_current_state(TASK_RUNNING); | ||
1132 | fsg->thread_wakeup_needed = 0; | ||
1133 | return rc; | ||
1134 | } | ||
1135 | |||
1136 | |||
1137 | /*-------------------------------------------------------------------------*/ | ||
1138 | |||
1139 | static int do_read(struct fsg_dev *fsg) | ||
1140 | { | ||
1141 | struct fsg_lun *curlun = fsg->curlun; | ||
1142 | u32 lba; | ||
1143 | struct fsg_buffhd *bh; | ||
1144 | int rc; | ||
1145 | u32 amount_left; | ||
1146 | loff_t file_offset, file_offset_tmp; | ||
1147 | unsigned int amount; | ||
1148 | ssize_t nread; | ||
1149 | |||
1150 | /* Get the starting Logical Block Address and check that it's | ||
1151 | * not too big */ | ||
1152 | if (fsg->cmnd[0] == READ_6) | ||
1153 | lba = get_unaligned_be24(&fsg->cmnd[1]); | ||
1154 | else { | ||
1155 | lba = get_unaligned_be32(&fsg->cmnd[2]); | ||
1156 | |||
1157 | /* We allow DPO (Disable Page Out = don't save data in the | ||
1158 | * cache) and FUA (Force Unit Access = don't read from the | ||
1159 | * cache), but we don't implement them. */ | ||
1160 | if ((fsg->cmnd[1] & ~0x18) != 0) { | ||
1161 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1162 | return -EINVAL; | ||
1163 | } | ||
1164 | } | ||
1165 | if (lba >= curlun->num_sectors) { | ||
1166 | curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1167 | return -EINVAL; | ||
1168 | } | ||
1169 | file_offset = ((loff_t) lba) << curlun->blkbits; | ||
1170 | |||
1171 | /* Carry out the file reads */ | ||
1172 | amount_left = fsg->data_size_from_cmnd; | ||
1173 | if (unlikely(amount_left == 0)) | ||
1174 | return -EIO; // No default reply | ||
1175 | |||
1176 | for (;;) { | ||
1177 | |||
1178 | /* Figure out how much we need to read: | ||
1179 | * Try to read the remaining amount. | ||
1180 | * But don't read more than the buffer size. | ||
1181 | * And don't try to read past the end of the file. | ||
1182 | */ | ||
1183 | amount = min((unsigned int) amount_left, mod_data.buflen); | ||
1184 | amount = min((loff_t) amount, | ||
1185 | curlun->file_length - file_offset); | ||
1186 | |||
1187 | /* Wait for the next buffer to become available */ | ||
1188 | bh = fsg->next_buffhd_to_fill; | ||
1189 | while (bh->state != BUF_STATE_EMPTY) { | ||
1190 | rc = sleep_thread(fsg); | ||
1191 | if (rc) | ||
1192 | return rc; | ||
1193 | } | ||
1194 | |||
1195 | /* If we were asked to read past the end of file, | ||
1196 | * end with an empty buffer. */ | ||
1197 | if (amount == 0) { | ||
1198 | curlun->sense_data = | ||
1199 | SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1200 | curlun->sense_data_info = file_offset >> curlun->blkbits; | ||
1201 | curlun->info_valid = 1; | ||
1202 | bh->inreq->length = 0; | ||
1203 | bh->state = BUF_STATE_FULL; | ||
1204 | break; | ||
1205 | } | ||
1206 | |||
1207 | /* Perform the read */ | ||
1208 | file_offset_tmp = file_offset; | ||
1209 | nread = vfs_read(curlun->filp, | ||
1210 | (char __user *) bh->buf, | ||
1211 | amount, &file_offset_tmp); | ||
1212 | VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, | ||
1213 | (unsigned long long) file_offset, | ||
1214 | (int) nread); | ||
1215 | if (signal_pending(current)) | ||
1216 | return -EINTR; | ||
1217 | |||
1218 | if (nread < 0) { | ||
1219 | LDBG(curlun, "error in file read: %d\n", | ||
1220 | (int) nread); | ||
1221 | nread = 0; | ||
1222 | } else if (nread < amount) { | ||
1223 | LDBG(curlun, "partial file read: %d/%u\n", | ||
1224 | (int) nread, amount); | ||
1225 | nread = round_down(nread, curlun->blksize); | ||
1226 | } | ||
1227 | file_offset += nread; | ||
1228 | amount_left -= nread; | ||
1229 | fsg->residue -= nread; | ||
1230 | |||
1231 | /* Except at the end of the transfer, nread will be | ||
1232 | * equal to the buffer size, which is divisible by the | ||
1233 | * bulk-in maxpacket size. | ||
1234 | */ | ||
1235 | bh->inreq->length = nread; | ||
1236 | bh->state = BUF_STATE_FULL; | ||
1237 | |||
1238 | /* If an error occurred, report it and its position */ | ||
1239 | if (nread < amount) { | ||
1240 | curlun->sense_data = SS_UNRECOVERED_READ_ERROR; | ||
1241 | curlun->sense_data_info = file_offset >> curlun->blkbits; | ||
1242 | curlun->info_valid = 1; | ||
1243 | break; | ||
1244 | } | ||
1245 | |||
1246 | if (amount_left == 0) | ||
1247 | break; // No more left to read | ||
1248 | |||
1249 | /* Send this buffer and go read some more */ | ||
1250 | bh->inreq->zero = 0; | ||
1251 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
1252 | &bh->inreq_busy, &bh->state); | ||
1253 | fsg->next_buffhd_to_fill = bh->next; | ||
1254 | } | ||
1255 | |||
1256 | return -EIO; // No default reply | ||
1257 | } | ||
1258 | |||
1259 | |||
1260 | /*-------------------------------------------------------------------------*/ | ||
1261 | |||
1262 | static int do_write(struct fsg_dev *fsg) | ||
1263 | { | ||
1264 | struct fsg_lun *curlun = fsg->curlun; | ||
1265 | u32 lba; | ||
1266 | struct fsg_buffhd *bh; | ||
1267 | int get_some_more; | ||
1268 | u32 amount_left_to_req, amount_left_to_write; | ||
1269 | loff_t usb_offset, file_offset, file_offset_tmp; | ||
1270 | unsigned int amount; | ||
1271 | ssize_t nwritten; | ||
1272 | int rc; | ||
1273 | |||
1274 | if (curlun->ro) { | ||
1275 | curlun->sense_data = SS_WRITE_PROTECTED; | ||
1276 | return -EINVAL; | ||
1277 | } | ||
1278 | spin_lock(&curlun->filp->f_lock); | ||
1279 | curlun->filp->f_flags &= ~O_SYNC; // Default is not to wait | ||
1280 | spin_unlock(&curlun->filp->f_lock); | ||
1281 | |||
1282 | /* Get the starting Logical Block Address and check that it's | ||
1283 | * not too big */ | ||
1284 | if (fsg->cmnd[0] == WRITE_6) | ||
1285 | lba = get_unaligned_be24(&fsg->cmnd[1]); | ||
1286 | else { | ||
1287 | lba = get_unaligned_be32(&fsg->cmnd[2]); | ||
1288 | |||
1289 | /* We allow DPO (Disable Page Out = don't save data in the | ||
1290 | * cache) and FUA (Force Unit Access = write directly to the | ||
1291 | * medium). We don't implement DPO; we implement FUA by | ||
1292 | * performing synchronous output. */ | ||
1293 | if ((fsg->cmnd[1] & ~0x18) != 0) { | ||
1294 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1295 | return -EINVAL; | ||
1296 | } | ||
1297 | /* FUA */ | ||
1298 | if (!curlun->nofua && (fsg->cmnd[1] & 0x08)) { | ||
1299 | spin_lock(&curlun->filp->f_lock); | ||
1300 | curlun->filp->f_flags |= O_DSYNC; | ||
1301 | spin_unlock(&curlun->filp->f_lock); | ||
1302 | } | ||
1303 | } | ||
1304 | if (lba >= curlun->num_sectors) { | ||
1305 | curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1306 | return -EINVAL; | ||
1307 | } | ||
1308 | |||
1309 | /* Carry out the file writes */ | ||
1310 | get_some_more = 1; | ||
1311 | file_offset = usb_offset = ((loff_t) lba) << curlun->blkbits; | ||
1312 | amount_left_to_req = amount_left_to_write = fsg->data_size_from_cmnd; | ||
1313 | |||
1314 | while (amount_left_to_write > 0) { | ||
1315 | |||
1316 | /* Queue a request for more data from the host */ | ||
1317 | bh = fsg->next_buffhd_to_fill; | ||
1318 | if (bh->state == BUF_STATE_EMPTY && get_some_more) { | ||
1319 | |||
1320 | /* Figure out how much we want to get: | ||
1321 | * Try to get the remaining amount, | ||
1322 | * but not more than the buffer size. | ||
1323 | */ | ||
1324 | amount = min(amount_left_to_req, mod_data.buflen); | ||
1325 | |||
1326 | /* Beyond the end of the backing file? */ | ||
1327 | if (usb_offset >= curlun->file_length) { | ||
1328 | get_some_more = 0; | ||
1329 | curlun->sense_data = | ||
1330 | SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1331 | curlun->sense_data_info = usb_offset >> curlun->blkbits; | ||
1332 | curlun->info_valid = 1; | ||
1333 | continue; | ||
1334 | } | ||
1335 | |||
1336 | /* Get the next buffer */ | ||
1337 | usb_offset += amount; | ||
1338 | fsg->usb_amount_left -= amount; | ||
1339 | amount_left_to_req -= amount; | ||
1340 | if (amount_left_to_req == 0) | ||
1341 | get_some_more = 0; | ||
1342 | |||
1343 | /* Except at the end of the transfer, amount will be | ||
1344 | * equal to the buffer size, which is divisible by | ||
1345 | * the bulk-out maxpacket size. | ||
1346 | */ | ||
1347 | set_bulk_out_req_length(fsg, bh, amount); | ||
1348 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | ||
1349 | &bh->outreq_busy, &bh->state); | ||
1350 | fsg->next_buffhd_to_fill = bh->next; | ||
1351 | continue; | ||
1352 | } | ||
1353 | |||
1354 | /* Write the received data to the backing file */ | ||
1355 | bh = fsg->next_buffhd_to_drain; | ||
1356 | if (bh->state == BUF_STATE_EMPTY && !get_some_more) | ||
1357 | break; // We stopped early | ||
1358 | if (bh->state == BUF_STATE_FULL) { | ||
1359 | smp_rmb(); | ||
1360 | fsg->next_buffhd_to_drain = bh->next; | ||
1361 | bh->state = BUF_STATE_EMPTY; | ||
1362 | |||
1363 | /* Did something go wrong with the transfer? */ | ||
1364 | if (bh->outreq->status != 0) { | ||
1365 | curlun->sense_data = SS_COMMUNICATION_FAILURE; | ||
1366 | curlun->sense_data_info = file_offset >> curlun->blkbits; | ||
1367 | curlun->info_valid = 1; | ||
1368 | break; | ||
1369 | } | ||
1370 | |||
1371 | amount = bh->outreq->actual; | ||
1372 | if (curlun->file_length - file_offset < amount) { | ||
1373 | LERROR(curlun, | ||
1374 | "write %u @ %llu beyond end %llu\n", | ||
1375 | amount, (unsigned long long) file_offset, | ||
1376 | (unsigned long long) curlun->file_length); | ||
1377 | amount = curlun->file_length - file_offset; | ||
1378 | } | ||
1379 | |||
1380 | /* Don't accept excess data. The spec doesn't say | ||
1381 | * what to do in this case. We'll ignore the error. | ||
1382 | */ | ||
1383 | amount = min(amount, bh->bulk_out_intended_length); | ||
1384 | |||
1385 | /* Don't write a partial block */ | ||
1386 | amount = round_down(amount, curlun->blksize); | ||
1387 | if (amount == 0) | ||
1388 | goto empty_write; | ||
1389 | |||
1390 | /* Perform the write */ | ||
1391 | file_offset_tmp = file_offset; | ||
1392 | nwritten = vfs_write(curlun->filp, | ||
1393 | (char __user *) bh->buf, | ||
1394 | amount, &file_offset_tmp); | ||
1395 | VLDBG(curlun, "file write %u @ %llu -> %d\n", amount, | ||
1396 | (unsigned long long) file_offset, | ||
1397 | (int) nwritten); | ||
1398 | if (signal_pending(current)) | ||
1399 | return -EINTR; // Interrupted! | ||
1400 | |||
1401 | if (nwritten < 0) { | ||
1402 | LDBG(curlun, "error in file write: %d\n", | ||
1403 | (int) nwritten); | ||
1404 | nwritten = 0; | ||
1405 | } else if (nwritten < amount) { | ||
1406 | LDBG(curlun, "partial file write: %d/%u\n", | ||
1407 | (int) nwritten, amount); | ||
1408 | nwritten = round_down(nwritten, curlun->blksize); | ||
1409 | } | ||
1410 | file_offset += nwritten; | ||
1411 | amount_left_to_write -= nwritten; | ||
1412 | fsg->residue -= nwritten; | ||
1413 | |||
1414 | /* If an error occurred, report it and its position */ | ||
1415 | if (nwritten < amount) { | ||
1416 | curlun->sense_data = SS_WRITE_ERROR; | ||
1417 | curlun->sense_data_info = file_offset >> curlun->blkbits; | ||
1418 | curlun->info_valid = 1; | ||
1419 | break; | ||
1420 | } | ||
1421 | |||
1422 | empty_write: | ||
1423 | /* Did the host decide to stop early? */ | ||
1424 | if (bh->outreq->actual < bh->bulk_out_intended_length) { | ||
1425 | fsg->short_packet_received = 1; | ||
1426 | break; | ||
1427 | } | ||
1428 | continue; | ||
1429 | } | ||
1430 | |||
1431 | /* Wait for something to happen */ | ||
1432 | rc = sleep_thread(fsg); | ||
1433 | if (rc) | ||
1434 | return rc; | ||
1435 | } | ||
1436 | |||
1437 | return -EIO; // No default reply | ||
1438 | } | ||
1439 | |||
1440 | |||
1441 | /*-------------------------------------------------------------------------*/ | ||
1442 | |||
1443 | static int do_synchronize_cache(struct fsg_dev *fsg) | ||
1444 | { | ||
1445 | struct fsg_lun *curlun = fsg->curlun; | ||
1446 | int rc; | ||
1447 | |||
1448 | /* We ignore the requested LBA and write out all file's | ||
1449 | * dirty data buffers. */ | ||
1450 | rc = fsg_lun_fsync_sub(curlun); | ||
1451 | if (rc) | ||
1452 | curlun->sense_data = SS_WRITE_ERROR; | ||
1453 | return 0; | ||
1454 | } | ||
1455 | |||
1456 | |||
1457 | /*-------------------------------------------------------------------------*/ | ||
1458 | |||
1459 | static void invalidate_sub(struct fsg_lun *curlun) | ||
1460 | { | ||
1461 | struct file *filp = curlun->filp; | ||
1462 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
1463 | unsigned long rc; | ||
1464 | |||
1465 | rc = invalidate_mapping_pages(inode->i_mapping, 0, -1); | ||
1466 | VLDBG(curlun, "invalidate_mapping_pages -> %ld\n", rc); | ||
1467 | } | ||
1468 | |||
1469 | static int do_verify(struct fsg_dev *fsg) | ||
1470 | { | ||
1471 | struct fsg_lun *curlun = fsg->curlun; | ||
1472 | u32 lba; | ||
1473 | u32 verification_length; | ||
1474 | struct fsg_buffhd *bh = fsg->next_buffhd_to_fill; | ||
1475 | loff_t file_offset, file_offset_tmp; | ||
1476 | u32 amount_left; | ||
1477 | unsigned int amount; | ||
1478 | ssize_t nread; | ||
1479 | |||
1480 | /* Get the starting Logical Block Address and check that it's | ||
1481 | * not too big */ | ||
1482 | lba = get_unaligned_be32(&fsg->cmnd[2]); | ||
1483 | if (lba >= curlun->num_sectors) { | ||
1484 | curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1485 | return -EINVAL; | ||
1486 | } | ||
1487 | |||
1488 | /* We allow DPO (Disable Page Out = don't save data in the | ||
1489 | * cache) but we don't implement it. */ | ||
1490 | if ((fsg->cmnd[1] & ~0x10) != 0) { | ||
1491 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1492 | return -EINVAL; | ||
1493 | } | ||
1494 | |||
1495 | verification_length = get_unaligned_be16(&fsg->cmnd[7]); | ||
1496 | if (unlikely(verification_length == 0)) | ||
1497 | return -EIO; // No default reply | ||
1498 | |||
1499 | /* Prepare to carry out the file verify */ | ||
1500 | amount_left = verification_length << curlun->blkbits; | ||
1501 | file_offset = ((loff_t) lba) << curlun->blkbits; | ||
1502 | |||
1503 | /* Write out all the dirty buffers before invalidating them */ | ||
1504 | fsg_lun_fsync_sub(curlun); | ||
1505 | if (signal_pending(current)) | ||
1506 | return -EINTR; | ||
1507 | |||
1508 | invalidate_sub(curlun); | ||
1509 | if (signal_pending(current)) | ||
1510 | return -EINTR; | ||
1511 | |||
1512 | /* Just try to read the requested blocks */ | ||
1513 | while (amount_left > 0) { | ||
1514 | |||
1515 | /* Figure out how much we need to read: | ||
1516 | * Try to read the remaining amount, but not more than | ||
1517 | * the buffer size. | ||
1518 | * And don't try to read past the end of the file. | ||
1519 | */ | ||
1520 | amount = min((unsigned int) amount_left, mod_data.buflen); | ||
1521 | amount = min((loff_t) amount, | ||
1522 | curlun->file_length - file_offset); | ||
1523 | if (amount == 0) { | ||
1524 | curlun->sense_data = | ||
1525 | SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1526 | curlun->sense_data_info = file_offset >> curlun->blkbits; | ||
1527 | curlun->info_valid = 1; | ||
1528 | break; | ||
1529 | } | ||
1530 | |||
1531 | /* Perform the read */ | ||
1532 | file_offset_tmp = file_offset; | ||
1533 | nread = vfs_read(curlun->filp, | ||
1534 | (char __user *) bh->buf, | ||
1535 | amount, &file_offset_tmp); | ||
1536 | VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, | ||
1537 | (unsigned long long) file_offset, | ||
1538 | (int) nread); | ||
1539 | if (signal_pending(current)) | ||
1540 | return -EINTR; | ||
1541 | |||
1542 | if (nread < 0) { | ||
1543 | LDBG(curlun, "error in file verify: %d\n", | ||
1544 | (int) nread); | ||
1545 | nread = 0; | ||
1546 | } else if (nread < amount) { | ||
1547 | LDBG(curlun, "partial file verify: %d/%u\n", | ||
1548 | (int) nread, amount); | ||
1549 | nread = round_down(nread, curlun->blksize); | ||
1550 | } | ||
1551 | if (nread == 0) { | ||
1552 | curlun->sense_data = SS_UNRECOVERED_READ_ERROR; | ||
1553 | curlun->sense_data_info = file_offset >> curlun->blkbits; | ||
1554 | curlun->info_valid = 1; | ||
1555 | break; | ||
1556 | } | ||
1557 | file_offset += nread; | ||
1558 | amount_left -= nread; | ||
1559 | } | ||
1560 | return 0; | ||
1561 | } | ||
1562 | |||
1563 | |||
1564 | /*-------------------------------------------------------------------------*/ | ||
1565 | |||
1566 | static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1567 | { | ||
1568 | u8 *buf = (u8 *) bh->buf; | ||
1569 | |||
1570 | static char vendor_id[] = "Linux "; | ||
1571 | static char product_disk_id[] = "File-Stor Gadget"; | ||
1572 | static char product_cdrom_id[] = "File-CD Gadget "; | ||
1573 | |||
1574 | if (!fsg->curlun) { // Unsupported LUNs are okay | ||
1575 | fsg->bad_lun_okay = 1; | ||
1576 | memset(buf, 0, 36); | ||
1577 | buf[0] = 0x7f; // Unsupported, no device-type | ||
1578 | buf[4] = 31; // Additional length | ||
1579 | return 36; | ||
1580 | } | ||
1581 | |||
1582 | memset(buf, 0, 8); | ||
1583 | buf[0] = (mod_data.cdrom ? TYPE_ROM : TYPE_DISK); | ||
1584 | if (mod_data.removable) | ||
1585 | buf[1] = 0x80; | ||
1586 | buf[2] = 2; // ANSI SCSI level 2 | ||
1587 | buf[3] = 2; // SCSI-2 INQUIRY data format | ||
1588 | buf[4] = 31; // Additional length | ||
1589 | // No special options | ||
1590 | sprintf(buf + 8, "%-8s%-16s%04x", vendor_id, | ||
1591 | (mod_data.cdrom ? product_cdrom_id : | ||
1592 | product_disk_id), | ||
1593 | mod_data.release); | ||
1594 | return 36; | ||
1595 | } | ||
1596 | |||
1597 | |||
1598 | static int do_request_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1599 | { | ||
1600 | struct fsg_lun *curlun = fsg->curlun; | ||
1601 | u8 *buf = (u8 *) bh->buf; | ||
1602 | u32 sd, sdinfo; | ||
1603 | int valid; | ||
1604 | |||
1605 | /* | ||
1606 | * From the SCSI-2 spec., section 7.9 (Unit attention condition): | ||
1607 | * | ||
1608 | * If a REQUEST SENSE command is received from an initiator | ||
1609 | * with a pending unit attention condition (before the target | ||
1610 | * generates the contingent allegiance condition), then the | ||
1611 | * target shall either: | ||
1612 | * a) report any pending sense data and preserve the unit | ||
1613 | * attention condition on the logical unit, or, | ||
1614 | * b) report the unit attention condition, may discard any | ||
1615 | * pending sense data, and clear the unit attention | ||
1616 | * condition on the logical unit for that initiator. | ||
1617 | * | ||
1618 | * FSG normally uses option a); enable this code to use option b). | ||
1619 | */ | ||
1620 | #if 0 | ||
1621 | if (curlun && curlun->unit_attention_data != SS_NO_SENSE) { | ||
1622 | curlun->sense_data = curlun->unit_attention_data; | ||
1623 | curlun->unit_attention_data = SS_NO_SENSE; | ||
1624 | } | ||
1625 | #endif | ||
1626 | |||
1627 | if (!curlun) { // Unsupported LUNs are okay | ||
1628 | fsg->bad_lun_okay = 1; | ||
1629 | sd = SS_LOGICAL_UNIT_NOT_SUPPORTED; | ||
1630 | sdinfo = 0; | ||
1631 | valid = 0; | ||
1632 | } else { | ||
1633 | sd = curlun->sense_data; | ||
1634 | sdinfo = curlun->sense_data_info; | ||
1635 | valid = curlun->info_valid << 7; | ||
1636 | curlun->sense_data = SS_NO_SENSE; | ||
1637 | curlun->sense_data_info = 0; | ||
1638 | curlun->info_valid = 0; | ||
1639 | } | ||
1640 | |||
1641 | memset(buf, 0, 18); | ||
1642 | buf[0] = valid | 0x70; // Valid, current error | ||
1643 | buf[2] = SK(sd); | ||
1644 | put_unaligned_be32(sdinfo, &buf[3]); /* Sense information */ | ||
1645 | buf[7] = 18 - 8; // Additional sense length | ||
1646 | buf[12] = ASC(sd); | ||
1647 | buf[13] = ASCQ(sd); | ||
1648 | return 18; | ||
1649 | } | ||
1650 | |||
1651 | |||
1652 | static int do_read_capacity(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1653 | { | ||
1654 | struct fsg_lun *curlun = fsg->curlun; | ||
1655 | u32 lba = get_unaligned_be32(&fsg->cmnd[2]); | ||
1656 | int pmi = fsg->cmnd[8]; | ||
1657 | u8 *buf = (u8 *) bh->buf; | ||
1658 | |||
1659 | /* Check the PMI and LBA fields */ | ||
1660 | if (pmi > 1 || (pmi == 0 && lba != 0)) { | ||
1661 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1662 | return -EINVAL; | ||
1663 | } | ||
1664 | |||
1665 | put_unaligned_be32(curlun->num_sectors - 1, &buf[0]); | ||
1666 | /* Max logical block */ | ||
1667 | put_unaligned_be32(curlun->blksize, &buf[4]); /* Block length */ | ||
1668 | return 8; | ||
1669 | } | ||
1670 | |||
1671 | |||
1672 | static int do_read_header(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1673 | { | ||
1674 | struct fsg_lun *curlun = fsg->curlun; | ||
1675 | int msf = fsg->cmnd[1] & 0x02; | ||
1676 | u32 lba = get_unaligned_be32(&fsg->cmnd[2]); | ||
1677 | u8 *buf = (u8 *) bh->buf; | ||
1678 | |||
1679 | if ((fsg->cmnd[1] & ~0x02) != 0) { /* Mask away MSF */ | ||
1680 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1681 | return -EINVAL; | ||
1682 | } | ||
1683 | if (lba >= curlun->num_sectors) { | ||
1684 | curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | ||
1685 | return -EINVAL; | ||
1686 | } | ||
1687 | |||
1688 | memset(buf, 0, 8); | ||
1689 | buf[0] = 0x01; /* 2048 bytes of user data, rest is EC */ | ||
1690 | store_cdrom_address(&buf[4], msf, lba); | ||
1691 | return 8; | ||
1692 | } | ||
1693 | |||
1694 | |||
1695 | static int do_read_toc(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1696 | { | ||
1697 | struct fsg_lun *curlun = fsg->curlun; | ||
1698 | int msf = fsg->cmnd[1] & 0x02; | ||
1699 | int start_track = fsg->cmnd[6]; | ||
1700 | u8 *buf = (u8 *) bh->buf; | ||
1701 | |||
1702 | if ((fsg->cmnd[1] & ~0x02) != 0 || /* Mask away MSF */ | ||
1703 | start_track > 1) { | ||
1704 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1705 | return -EINVAL; | ||
1706 | } | ||
1707 | |||
1708 | memset(buf, 0, 20); | ||
1709 | buf[1] = (20-2); /* TOC data length */ | ||
1710 | buf[2] = 1; /* First track number */ | ||
1711 | buf[3] = 1; /* Last track number */ | ||
1712 | buf[5] = 0x16; /* Data track, copying allowed */ | ||
1713 | buf[6] = 0x01; /* Only track is number 1 */ | ||
1714 | store_cdrom_address(&buf[8], msf, 0); | ||
1715 | |||
1716 | buf[13] = 0x16; /* Lead-out track is data */ | ||
1717 | buf[14] = 0xAA; /* Lead-out track number */ | ||
1718 | store_cdrom_address(&buf[16], msf, curlun->num_sectors); | ||
1719 | return 20; | ||
1720 | } | ||
1721 | |||
1722 | |||
1723 | static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1724 | { | ||
1725 | struct fsg_lun *curlun = fsg->curlun; | ||
1726 | int mscmnd = fsg->cmnd[0]; | ||
1727 | u8 *buf = (u8 *) bh->buf; | ||
1728 | u8 *buf0 = buf; | ||
1729 | int pc, page_code; | ||
1730 | int changeable_values, all_pages; | ||
1731 | int valid_page = 0; | ||
1732 | int len, limit; | ||
1733 | |||
1734 | if ((fsg->cmnd[1] & ~0x08) != 0) { // Mask away DBD | ||
1735 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1736 | return -EINVAL; | ||
1737 | } | ||
1738 | pc = fsg->cmnd[2] >> 6; | ||
1739 | page_code = fsg->cmnd[2] & 0x3f; | ||
1740 | if (pc == 3) { | ||
1741 | curlun->sense_data = SS_SAVING_PARAMETERS_NOT_SUPPORTED; | ||
1742 | return -EINVAL; | ||
1743 | } | ||
1744 | changeable_values = (pc == 1); | ||
1745 | all_pages = (page_code == 0x3f); | ||
1746 | |||
1747 | /* Write the mode parameter header. Fixed values are: default | ||
1748 | * medium type, no cache control (DPOFUA), and no block descriptors. | ||
1749 | * The only variable value is the WriteProtect bit. We will fill in | ||
1750 | * the mode data length later. */ | ||
1751 | memset(buf, 0, 8); | ||
1752 | if (mscmnd == MODE_SENSE) { | ||
1753 | buf[2] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA | ||
1754 | buf += 4; | ||
1755 | limit = 255; | ||
1756 | } else { // MODE_SENSE_10 | ||
1757 | buf[3] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA | ||
1758 | buf += 8; | ||
1759 | limit = 65535; // Should really be mod_data.buflen | ||
1760 | } | ||
1761 | |||
1762 | /* No block descriptors */ | ||
1763 | |||
1764 | /* The mode pages, in numerical order. The only page we support | ||
1765 | * is the Caching page. */ | ||
1766 | if (page_code == 0x08 || all_pages) { | ||
1767 | valid_page = 1; | ||
1768 | buf[0] = 0x08; // Page code | ||
1769 | buf[1] = 10; // Page length | ||
1770 | memset(buf+2, 0, 10); // None of the fields are changeable | ||
1771 | |||
1772 | if (!changeable_values) { | ||
1773 | buf[2] = 0x04; // Write cache enable, | ||
1774 | // Read cache not disabled | ||
1775 | // No cache retention priorities | ||
1776 | put_unaligned_be16(0xffff, &buf[4]); | ||
1777 | /* Don't disable prefetch */ | ||
1778 | /* Minimum prefetch = 0 */ | ||
1779 | put_unaligned_be16(0xffff, &buf[8]); | ||
1780 | /* Maximum prefetch */ | ||
1781 | put_unaligned_be16(0xffff, &buf[10]); | ||
1782 | /* Maximum prefetch ceiling */ | ||
1783 | } | ||
1784 | buf += 12; | ||
1785 | } | ||
1786 | |||
1787 | /* Check that a valid page was requested and the mode data length | ||
1788 | * isn't too long. */ | ||
1789 | len = buf - buf0; | ||
1790 | if (!valid_page || len > limit) { | ||
1791 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1792 | return -EINVAL; | ||
1793 | } | ||
1794 | |||
1795 | /* Store the mode data length */ | ||
1796 | if (mscmnd == MODE_SENSE) | ||
1797 | buf0[0] = len - 1; | ||
1798 | else | ||
1799 | put_unaligned_be16(len - 2, buf0); | ||
1800 | return len; | ||
1801 | } | ||
1802 | |||
1803 | |||
1804 | static int do_start_stop(struct fsg_dev *fsg) | ||
1805 | { | ||
1806 | struct fsg_lun *curlun = fsg->curlun; | ||
1807 | int loej, start; | ||
1808 | |||
1809 | if (!mod_data.removable) { | ||
1810 | curlun->sense_data = SS_INVALID_COMMAND; | ||
1811 | return -EINVAL; | ||
1812 | } | ||
1813 | |||
1814 | // int immed = fsg->cmnd[1] & 0x01; | ||
1815 | loej = fsg->cmnd[4] & 0x02; | ||
1816 | start = fsg->cmnd[4] & 0x01; | ||
1817 | |||
1818 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | ||
1819 | if ((fsg->cmnd[1] & ~0x01) != 0 || // Mask away Immed | ||
1820 | (fsg->cmnd[4] & ~0x03) != 0) { // Mask LoEj, Start | ||
1821 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1822 | return -EINVAL; | ||
1823 | } | ||
1824 | |||
1825 | if (!start) { | ||
1826 | |||
1827 | /* Are we allowed to unload the media? */ | ||
1828 | if (curlun->prevent_medium_removal) { | ||
1829 | LDBG(curlun, "unload attempt prevented\n"); | ||
1830 | curlun->sense_data = SS_MEDIUM_REMOVAL_PREVENTED; | ||
1831 | return -EINVAL; | ||
1832 | } | ||
1833 | if (loej) { // Simulate an unload/eject | ||
1834 | up_read(&fsg->filesem); | ||
1835 | down_write(&fsg->filesem); | ||
1836 | fsg_lun_close(curlun); | ||
1837 | up_write(&fsg->filesem); | ||
1838 | down_read(&fsg->filesem); | ||
1839 | } | ||
1840 | } else { | ||
1841 | |||
1842 | /* Our emulation doesn't support mounting; the medium is | ||
1843 | * available for use as soon as it is loaded. */ | ||
1844 | if (!fsg_lun_is_open(curlun)) { | ||
1845 | curlun->sense_data = SS_MEDIUM_NOT_PRESENT; | ||
1846 | return -EINVAL; | ||
1847 | } | ||
1848 | } | ||
1849 | #endif | ||
1850 | return 0; | ||
1851 | } | ||
1852 | |||
1853 | |||
1854 | static int do_prevent_allow(struct fsg_dev *fsg) | ||
1855 | { | ||
1856 | struct fsg_lun *curlun = fsg->curlun; | ||
1857 | int prevent; | ||
1858 | |||
1859 | if (!mod_data.removable) { | ||
1860 | curlun->sense_data = SS_INVALID_COMMAND; | ||
1861 | return -EINVAL; | ||
1862 | } | ||
1863 | |||
1864 | prevent = fsg->cmnd[4] & 0x01; | ||
1865 | if ((fsg->cmnd[4] & ~0x01) != 0) { // Mask away Prevent | ||
1866 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
1867 | return -EINVAL; | ||
1868 | } | ||
1869 | |||
1870 | if (curlun->prevent_medium_removal && !prevent) | ||
1871 | fsg_lun_fsync_sub(curlun); | ||
1872 | curlun->prevent_medium_removal = prevent; | ||
1873 | return 0; | ||
1874 | } | ||
1875 | |||
1876 | |||
1877 | static int do_read_format_capacities(struct fsg_dev *fsg, | ||
1878 | struct fsg_buffhd *bh) | ||
1879 | { | ||
1880 | struct fsg_lun *curlun = fsg->curlun; | ||
1881 | u8 *buf = (u8 *) bh->buf; | ||
1882 | |||
1883 | buf[0] = buf[1] = buf[2] = 0; | ||
1884 | buf[3] = 8; // Only the Current/Maximum Capacity Descriptor | ||
1885 | buf += 4; | ||
1886 | |||
1887 | put_unaligned_be32(curlun->num_sectors, &buf[0]); | ||
1888 | /* Number of blocks */ | ||
1889 | put_unaligned_be32(curlun->blksize, &buf[4]); /* Block length */ | ||
1890 | buf[4] = 0x02; /* Current capacity */ | ||
1891 | return 12; | ||
1892 | } | ||
1893 | |||
1894 | |||
1895 | static int do_mode_select(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
1896 | { | ||
1897 | struct fsg_lun *curlun = fsg->curlun; | ||
1898 | |||
1899 | /* We don't support MODE SELECT */ | ||
1900 | curlun->sense_data = SS_INVALID_COMMAND; | ||
1901 | return -EINVAL; | ||
1902 | } | ||
1903 | |||
1904 | |||
1905 | /*-------------------------------------------------------------------------*/ | ||
1906 | |||
1907 | static int halt_bulk_in_endpoint(struct fsg_dev *fsg) | ||
1908 | { | ||
1909 | int rc; | ||
1910 | |||
1911 | rc = fsg_set_halt(fsg, fsg->bulk_in); | ||
1912 | if (rc == -EAGAIN) | ||
1913 | VDBG(fsg, "delayed bulk-in endpoint halt\n"); | ||
1914 | while (rc != 0) { | ||
1915 | if (rc != -EAGAIN) { | ||
1916 | WARNING(fsg, "usb_ep_set_halt -> %d\n", rc); | ||
1917 | rc = 0; | ||
1918 | break; | ||
1919 | } | ||
1920 | |||
1921 | /* Wait for a short time and then try again */ | ||
1922 | if (msleep_interruptible(100) != 0) | ||
1923 | return -EINTR; | ||
1924 | rc = usb_ep_set_halt(fsg->bulk_in); | ||
1925 | } | ||
1926 | return rc; | ||
1927 | } | ||
1928 | |||
1929 | static int wedge_bulk_in_endpoint(struct fsg_dev *fsg) | ||
1930 | { | ||
1931 | int rc; | ||
1932 | |||
1933 | DBG(fsg, "bulk-in set wedge\n"); | ||
1934 | rc = usb_ep_set_wedge(fsg->bulk_in); | ||
1935 | if (rc == -EAGAIN) | ||
1936 | VDBG(fsg, "delayed bulk-in endpoint wedge\n"); | ||
1937 | while (rc != 0) { | ||
1938 | if (rc != -EAGAIN) { | ||
1939 | WARNING(fsg, "usb_ep_set_wedge -> %d\n", rc); | ||
1940 | rc = 0; | ||
1941 | break; | ||
1942 | } | ||
1943 | |||
1944 | /* Wait for a short time and then try again */ | ||
1945 | if (msleep_interruptible(100) != 0) | ||
1946 | return -EINTR; | ||
1947 | rc = usb_ep_set_wedge(fsg->bulk_in); | ||
1948 | } | ||
1949 | return rc; | ||
1950 | } | ||
1951 | |||
1952 | static int throw_away_data(struct fsg_dev *fsg) | ||
1953 | { | ||
1954 | struct fsg_buffhd *bh; | ||
1955 | u32 amount; | ||
1956 | int rc; | ||
1957 | |||
1958 | while ((bh = fsg->next_buffhd_to_drain)->state != BUF_STATE_EMPTY || | ||
1959 | fsg->usb_amount_left > 0) { | ||
1960 | |||
1961 | /* Throw away the data in a filled buffer */ | ||
1962 | if (bh->state == BUF_STATE_FULL) { | ||
1963 | smp_rmb(); | ||
1964 | bh->state = BUF_STATE_EMPTY; | ||
1965 | fsg->next_buffhd_to_drain = bh->next; | ||
1966 | |||
1967 | /* A short packet or an error ends everything */ | ||
1968 | if (bh->outreq->actual < bh->bulk_out_intended_length || | ||
1969 | bh->outreq->status != 0) { | ||
1970 | raise_exception(fsg, FSG_STATE_ABORT_BULK_OUT); | ||
1971 | return -EINTR; | ||
1972 | } | ||
1973 | continue; | ||
1974 | } | ||
1975 | |||
1976 | /* Try to submit another request if we need one */ | ||
1977 | bh = fsg->next_buffhd_to_fill; | ||
1978 | if (bh->state == BUF_STATE_EMPTY && fsg->usb_amount_left > 0) { | ||
1979 | amount = min(fsg->usb_amount_left, | ||
1980 | (u32) mod_data.buflen); | ||
1981 | |||
1982 | /* Except at the end of the transfer, amount will be | ||
1983 | * equal to the buffer size, which is divisible by | ||
1984 | * the bulk-out maxpacket size. | ||
1985 | */ | ||
1986 | set_bulk_out_req_length(fsg, bh, amount); | ||
1987 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | ||
1988 | &bh->outreq_busy, &bh->state); | ||
1989 | fsg->next_buffhd_to_fill = bh->next; | ||
1990 | fsg->usb_amount_left -= amount; | ||
1991 | continue; | ||
1992 | } | ||
1993 | |||
1994 | /* Otherwise wait for something to happen */ | ||
1995 | rc = sleep_thread(fsg); | ||
1996 | if (rc) | ||
1997 | return rc; | ||
1998 | } | ||
1999 | return 0; | ||
2000 | } | ||
2001 | |||
2002 | |||
2003 | static int finish_reply(struct fsg_dev *fsg) | ||
2004 | { | ||
2005 | struct fsg_buffhd *bh = fsg->next_buffhd_to_fill; | ||
2006 | int rc = 0; | ||
2007 | |||
2008 | switch (fsg->data_dir) { | ||
2009 | case DATA_DIR_NONE: | ||
2010 | break; // Nothing to send | ||
2011 | |||
2012 | /* If we don't know whether the host wants to read or write, | ||
2013 | * this must be CB or CBI with an unknown command. We mustn't | ||
2014 | * try to send or receive any data. So stall both bulk pipes | ||
2015 | * if we can and wait for a reset. */ | ||
2016 | case DATA_DIR_UNKNOWN: | ||
2017 | if (mod_data.can_stall) { | ||
2018 | fsg_set_halt(fsg, fsg->bulk_out); | ||
2019 | rc = halt_bulk_in_endpoint(fsg); | ||
2020 | } | ||
2021 | break; | ||
2022 | |||
2023 | /* All but the last buffer of data must have already been sent */ | ||
2024 | case DATA_DIR_TO_HOST: | ||
2025 | if (fsg->data_size == 0) | ||
2026 | ; // Nothing to send | ||
2027 | |||
2028 | /* If there's no residue, simply send the last buffer */ | ||
2029 | else if (fsg->residue == 0) { | ||
2030 | bh->inreq->zero = 0; | ||
2031 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
2032 | &bh->inreq_busy, &bh->state); | ||
2033 | fsg->next_buffhd_to_fill = bh->next; | ||
2034 | } | ||
2035 | |||
2036 | /* There is a residue. For CB and CBI, simply mark the end | ||
2037 | * of the data with a short packet. However, if we are | ||
2038 | * allowed to stall, there was no data at all (residue == | ||
2039 | * data_size), and the command failed (invalid LUN or | ||
2040 | * sense data is set), then halt the bulk-in endpoint | ||
2041 | * instead. */ | ||
2042 | else if (!transport_is_bbb()) { | ||
2043 | if (mod_data.can_stall && | ||
2044 | fsg->residue == fsg->data_size && | ||
2045 | (!fsg->curlun || fsg->curlun->sense_data != SS_NO_SENSE)) { | ||
2046 | bh->state = BUF_STATE_EMPTY; | ||
2047 | rc = halt_bulk_in_endpoint(fsg); | ||
2048 | } else { | ||
2049 | bh->inreq->zero = 1; | ||
2050 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
2051 | &bh->inreq_busy, &bh->state); | ||
2052 | fsg->next_buffhd_to_fill = bh->next; | ||
2053 | } | ||
2054 | } | ||
2055 | |||
2056 | /* | ||
2057 | * For Bulk-only, mark the end of the data with a short | ||
2058 | * packet. If we are allowed to stall, halt the bulk-in | ||
2059 | * endpoint. (Note: This violates the Bulk-Only Transport | ||
2060 | * specification, which requires us to pad the data if we | ||
2061 | * don't halt the endpoint. Presumably nobody will mind.) | ||
2062 | */ | ||
2063 | else { | ||
2064 | bh->inreq->zero = 1; | ||
2065 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
2066 | &bh->inreq_busy, &bh->state); | ||
2067 | fsg->next_buffhd_to_fill = bh->next; | ||
2068 | if (mod_data.can_stall) | ||
2069 | rc = halt_bulk_in_endpoint(fsg); | ||
2070 | } | ||
2071 | break; | ||
2072 | |||
2073 | /* We have processed all we want from the data the host has sent. | ||
2074 | * There may still be outstanding bulk-out requests. */ | ||
2075 | case DATA_DIR_FROM_HOST: | ||
2076 | if (fsg->residue == 0) | ||
2077 | ; // Nothing to receive | ||
2078 | |||
2079 | /* Did the host stop sending unexpectedly early? */ | ||
2080 | else if (fsg->short_packet_received) { | ||
2081 | raise_exception(fsg, FSG_STATE_ABORT_BULK_OUT); | ||
2082 | rc = -EINTR; | ||
2083 | } | ||
2084 | |||
2085 | /* We haven't processed all the incoming data. Even though | ||
2086 | * we may be allowed to stall, doing so would cause a race. | ||
2087 | * The controller may already have ACK'ed all the remaining | ||
2088 | * bulk-out packets, in which case the host wouldn't see a | ||
2089 | * STALL. Not realizing the endpoint was halted, it wouldn't | ||
2090 | * clear the halt -- leading to problems later on. */ | ||
2091 | #if 0 | ||
2092 | else if (mod_data.can_stall) { | ||
2093 | fsg_set_halt(fsg, fsg->bulk_out); | ||
2094 | raise_exception(fsg, FSG_STATE_ABORT_BULK_OUT); | ||
2095 | rc = -EINTR; | ||
2096 | } | ||
2097 | #endif | ||
2098 | |||
2099 | /* We can't stall. Read in the excess data and throw it | ||
2100 | * all away. */ | ||
2101 | else | ||
2102 | rc = throw_away_data(fsg); | ||
2103 | break; | ||
2104 | } | ||
2105 | return rc; | ||
2106 | } | ||
2107 | |||
2108 | |||
2109 | static int send_status(struct fsg_dev *fsg) | ||
2110 | { | ||
2111 | struct fsg_lun *curlun = fsg->curlun; | ||
2112 | struct fsg_buffhd *bh; | ||
2113 | int rc; | ||
2114 | u8 status = US_BULK_STAT_OK; | ||
2115 | u32 sd, sdinfo = 0; | ||
2116 | |||
2117 | /* Wait for the next buffer to become available */ | ||
2118 | bh = fsg->next_buffhd_to_fill; | ||
2119 | while (bh->state != BUF_STATE_EMPTY) { | ||
2120 | rc = sleep_thread(fsg); | ||
2121 | if (rc) | ||
2122 | return rc; | ||
2123 | } | ||
2124 | |||
2125 | if (curlun) { | ||
2126 | sd = curlun->sense_data; | ||
2127 | sdinfo = curlun->sense_data_info; | ||
2128 | } else if (fsg->bad_lun_okay) | ||
2129 | sd = SS_NO_SENSE; | ||
2130 | else | ||
2131 | sd = SS_LOGICAL_UNIT_NOT_SUPPORTED; | ||
2132 | |||
2133 | if (fsg->phase_error) { | ||
2134 | DBG(fsg, "sending phase-error status\n"); | ||
2135 | status = US_BULK_STAT_PHASE; | ||
2136 | sd = SS_INVALID_COMMAND; | ||
2137 | } else if (sd != SS_NO_SENSE) { | ||
2138 | DBG(fsg, "sending command-failure status\n"); | ||
2139 | status = US_BULK_STAT_FAIL; | ||
2140 | VDBG(fsg, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" | ||
2141 | " info x%x\n", | ||
2142 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); | ||
2143 | } | ||
2144 | |||
2145 | if (transport_is_bbb()) { | ||
2146 | struct bulk_cs_wrap *csw = bh->buf; | ||
2147 | |||
2148 | /* Store and send the Bulk-only CSW */ | ||
2149 | csw->Signature = cpu_to_le32(US_BULK_CS_SIGN); | ||
2150 | csw->Tag = fsg->tag; | ||
2151 | csw->Residue = cpu_to_le32(fsg->residue); | ||
2152 | csw->Status = status; | ||
2153 | |||
2154 | bh->inreq->length = US_BULK_CS_WRAP_LEN; | ||
2155 | bh->inreq->zero = 0; | ||
2156 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | ||
2157 | &bh->inreq_busy, &bh->state); | ||
2158 | |||
2159 | } else if (mod_data.transport_type == USB_PR_CB) { | ||
2160 | |||
2161 | /* Control-Bulk transport has no status phase! */ | ||
2162 | return 0; | ||
2163 | |||
2164 | } else { // USB_PR_CBI | ||
2165 | struct interrupt_data *buf = bh->buf; | ||
2166 | |||
2167 | /* Store and send the Interrupt data. UFI sends the ASC | ||
2168 | * and ASCQ bytes. Everything else sends a Type (which | ||
2169 | * is always 0) and the status Value. */ | ||
2170 | if (mod_data.protocol_type == USB_SC_UFI) { | ||
2171 | buf->bType = ASC(sd); | ||
2172 | buf->bValue = ASCQ(sd); | ||
2173 | } else { | ||
2174 | buf->bType = 0; | ||
2175 | buf->bValue = status; | ||
2176 | } | ||
2177 | fsg->intreq->length = CBI_INTERRUPT_DATA_LEN; | ||
2178 | |||
2179 | fsg->intr_buffhd = bh; // Point to the right buffhd | ||
2180 | fsg->intreq->buf = bh->inreq->buf; | ||
2181 | fsg->intreq->context = bh; | ||
2182 | start_transfer(fsg, fsg->intr_in, fsg->intreq, | ||
2183 | &fsg->intreq_busy, &bh->state); | ||
2184 | } | ||
2185 | |||
2186 | fsg->next_buffhd_to_fill = bh->next; | ||
2187 | return 0; | ||
2188 | } | ||
2189 | |||
2190 | |||
2191 | /*-------------------------------------------------------------------------*/ | ||
2192 | |||
2193 | /* Check whether the command is properly formed and whether its data size | ||
2194 | * and direction agree with the values we already have. */ | ||
2195 | static int check_command(struct fsg_dev *fsg, int cmnd_size, | ||
2196 | enum data_direction data_dir, unsigned int mask, | ||
2197 | int needs_medium, const char *name) | ||
2198 | { | ||
2199 | int i; | ||
2200 | int lun = fsg->cmnd[1] >> 5; | ||
2201 | static const char dirletter[4] = {'u', 'o', 'i', 'n'}; | ||
2202 | char hdlen[20]; | ||
2203 | struct fsg_lun *curlun; | ||
2204 | |||
2205 | /* Adjust the expected cmnd_size for protocol encapsulation padding. | ||
2206 | * Transparent SCSI doesn't pad. */ | ||
2207 | if (protocol_is_scsi()) | ||
2208 | ; | ||
2209 | |||
2210 | /* There's some disagreement as to whether RBC pads commands or not. | ||
2211 | * We'll play it safe and accept either form. */ | ||
2212 | else if (mod_data.protocol_type == USB_SC_RBC) { | ||
2213 | if (fsg->cmnd_size == 12) | ||
2214 | cmnd_size = 12; | ||
2215 | |||
2216 | /* All the other protocols pad to 12 bytes */ | ||
2217 | } else | ||
2218 | cmnd_size = 12; | ||
2219 | |||
2220 | hdlen[0] = 0; | ||
2221 | if (fsg->data_dir != DATA_DIR_UNKNOWN) | ||
2222 | sprintf(hdlen, ", H%c=%u", dirletter[(int) fsg->data_dir], | ||
2223 | fsg->data_size); | ||
2224 | VDBG(fsg, "SCSI command: %s; Dc=%d, D%c=%u; Hc=%d%s\n", | ||
2225 | name, cmnd_size, dirletter[(int) data_dir], | ||
2226 | fsg->data_size_from_cmnd, fsg->cmnd_size, hdlen); | ||
2227 | |||
2228 | /* We can't reply at all until we know the correct data direction | ||
2229 | * and size. */ | ||
2230 | if (fsg->data_size_from_cmnd == 0) | ||
2231 | data_dir = DATA_DIR_NONE; | ||
2232 | if (fsg->data_dir == DATA_DIR_UNKNOWN) { // CB or CBI | ||
2233 | fsg->data_dir = data_dir; | ||
2234 | fsg->data_size = fsg->data_size_from_cmnd; | ||
2235 | |||
2236 | } else { // Bulk-only | ||
2237 | if (fsg->data_size < fsg->data_size_from_cmnd) { | ||
2238 | |||
2239 | /* Host data size < Device data size is a phase error. | ||
2240 | * Carry out the command, but only transfer as much | ||
2241 | * as we are allowed. */ | ||
2242 | fsg->data_size_from_cmnd = fsg->data_size; | ||
2243 | fsg->phase_error = 1; | ||
2244 | } | ||
2245 | } | ||
2246 | fsg->residue = fsg->usb_amount_left = fsg->data_size; | ||
2247 | |||
2248 | /* Conflicting data directions is a phase error */ | ||
2249 | if (fsg->data_dir != data_dir && fsg->data_size_from_cmnd > 0) { | ||
2250 | fsg->phase_error = 1; | ||
2251 | return -EINVAL; | ||
2252 | } | ||
2253 | |||
2254 | /* Verify the length of the command itself */ | ||
2255 | if (cmnd_size != fsg->cmnd_size) { | ||
2256 | |||
2257 | /* Special case workaround: There are plenty of buggy SCSI | ||
2258 | * implementations. Many have issues with cbw->Length | ||
2259 | * field passing a wrong command size. For those cases we | ||
2260 | * always try to work around the problem by using the length | ||
2261 | * sent by the host side provided it is at least as large | ||
2262 | * as the correct command length. | ||
2263 | * Examples of such cases would be MS-Windows, which issues | ||
2264 | * REQUEST SENSE with cbw->Length == 12 where it should | ||
2265 | * be 6, and xbox360 issuing INQUIRY, TEST UNIT READY and | ||
2266 | * REQUEST SENSE with cbw->Length == 10 where it should | ||
2267 | * be 6 as well. | ||
2268 | */ | ||
2269 | if (cmnd_size <= fsg->cmnd_size) { | ||
2270 | DBG(fsg, "%s is buggy! Expected length %d " | ||
2271 | "but we got %d\n", name, | ||
2272 | cmnd_size, fsg->cmnd_size); | ||
2273 | cmnd_size = fsg->cmnd_size; | ||
2274 | } else { | ||
2275 | fsg->phase_error = 1; | ||
2276 | return -EINVAL; | ||
2277 | } | ||
2278 | } | ||
2279 | |||
2280 | /* Check that the LUN values are consistent */ | ||
2281 | if (transport_is_bbb()) { | ||
2282 | if (fsg->lun != lun) | ||
2283 | DBG(fsg, "using LUN %d from CBW, " | ||
2284 | "not LUN %d from CDB\n", | ||
2285 | fsg->lun, lun); | ||
2286 | } | ||
2287 | |||
2288 | /* Check the LUN */ | ||
2289 | curlun = fsg->curlun; | ||
2290 | if (curlun) { | ||
2291 | if (fsg->cmnd[0] != REQUEST_SENSE) { | ||
2292 | curlun->sense_data = SS_NO_SENSE; | ||
2293 | curlun->sense_data_info = 0; | ||
2294 | curlun->info_valid = 0; | ||
2295 | } | ||
2296 | } else { | ||
2297 | fsg->bad_lun_okay = 0; | ||
2298 | |||
2299 | /* INQUIRY and REQUEST SENSE commands are explicitly allowed | ||
2300 | * to use unsupported LUNs; all others may not. */ | ||
2301 | if (fsg->cmnd[0] != INQUIRY && | ||
2302 | fsg->cmnd[0] != REQUEST_SENSE) { | ||
2303 | DBG(fsg, "unsupported LUN %d\n", fsg->lun); | ||
2304 | return -EINVAL; | ||
2305 | } | ||
2306 | } | ||
2307 | |||
2308 | /* If a unit attention condition exists, only INQUIRY and | ||
2309 | * REQUEST SENSE commands are allowed; anything else must fail. */ | ||
2310 | if (curlun && curlun->unit_attention_data != SS_NO_SENSE && | ||
2311 | fsg->cmnd[0] != INQUIRY && | ||
2312 | fsg->cmnd[0] != REQUEST_SENSE) { | ||
2313 | curlun->sense_data = curlun->unit_attention_data; | ||
2314 | curlun->unit_attention_data = SS_NO_SENSE; | ||
2315 | return -EINVAL; | ||
2316 | } | ||
2317 | |||
2318 | /* Check that only command bytes listed in the mask are non-zero */ | ||
2319 | fsg->cmnd[1] &= 0x1f; // Mask away the LUN | ||
2320 | for (i = 1; i < cmnd_size; ++i) { | ||
2321 | if (fsg->cmnd[i] && !(mask & (1 << i))) { | ||
2322 | if (curlun) | ||
2323 | curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | ||
2324 | return -EINVAL; | ||
2325 | } | ||
2326 | } | ||
2327 | |||
2328 | /* If the medium isn't mounted and the command needs to access | ||
2329 | * it, return an error. */ | ||
2330 | if (curlun && !fsg_lun_is_open(curlun) && needs_medium) { | ||
2331 | curlun->sense_data = SS_MEDIUM_NOT_PRESENT; | ||
2332 | return -EINVAL; | ||
2333 | } | ||
2334 | |||
2335 | return 0; | ||
2336 | } | ||
2337 | |||
2338 | /* wrapper of check_command for data size in blocks handling */ | ||
2339 | static int check_command_size_in_blocks(struct fsg_dev *fsg, int cmnd_size, | ||
2340 | enum data_direction data_dir, unsigned int mask, | ||
2341 | int needs_medium, const char *name) | ||
2342 | { | ||
2343 | if (fsg->curlun) | ||
2344 | fsg->data_size_from_cmnd <<= fsg->curlun->blkbits; | ||
2345 | return check_command(fsg, cmnd_size, data_dir, | ||
2346 | mask, needs_medium, name); | ||
2347 | } | ||
2348 | |||
2349 | static int do_scsi_command(struct fsg_dev *fsg) | ||
2350 | { | ||
2351 | struct fsg_buffhd *bh; | ||
2352 | int rc; | ||
2353 | int reply = -EINVAL; | ||
2354 | int i; | ||
2355 | static char unknown[16]; | ||
2356 | |||
2357 | dump_cdb(fsg); | ||
2358 | |||
2359 | /* Wait for the next buffer to become available for data or status */ | ||
2360 | bh = fsg->next_buffhd_to_drain = fsg->next_buffhd_to_fill; | ||
2361 | while (bh->state != BUF_STATE_EMPTY) { | ||
2362 | rc = sleep_thread(fsg); | ||
2363 | if (rc) | ||
2364 | return rc; | ||
2365 | } | ||
2366 | fsg->phase_error = 0; | ||
2367 | fsg->short_packet_received = 0; | ||
2368 | |||
2369 | down_read(&fsg->filesem); // We're using the backing file | ||
2370 | switch (fsg->cmnd[0]) { | ||
2371 | |||
2372 | case INQUIRY: | ||
2373 | fsg->data_size_from_cmnd = fsg->cmnd[4]; | ||
2374 | if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, | ||
2375 | (1<<4), 0, | ||
2376 | "INQUIRY")) == 0) | ||
2377 | reply = do_inquiry(fsg, bh); | ||
2378 | break; | ||
2379 | |||
2380 | case MODE_SELECT: | ||
2381 | fsg->data_size_from_cmnd = fsg->cmnd[4]; | ||
2382 | if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST, | ||
2383 | (1<<1) | (1<<4), 0, | ||
2384 | "MODE SELECT(6)")) == 0) | ||
2385 | reply = do_mode_select(fsg, bh); | ||
2386 | break; | ||
2387 | |||
2388 | case MODE_SELECT_10: | ||
2389 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2390 | if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST, | ||
2391 | (1<<1) | (3<<7), 0, | ||
2392 | "MODE SELECT(10)")) == 0) | ||
2393 | reply = do_mode_select(fsg, bh); | ||
2394 | break; | ||
2395 | |||
2396 | case MODE_SENSE: | ||
2397 | fsg->data_size_from_cmnd = fsg->cmnd[4]; | ||
2398 | if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, | ||
2399 | (1<<1) | (1<<2) | (1<<4), 0, | ||
2400 | "MODE SENSE(6)")) == 0) | ||
2401 | reply = do_mode_sense(fsg, bh); | ||
2402 | break; | ||
2403 | |||
2404 | case MODE_SENSE_10: | ||
2405 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2406 | if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, | ||
2407 | (1<<1) | (1<<2) | (3<<7), 0, | ||
2408 | "MODE SENSE(10)")) == 0) | ||
2409 | reply = do_mode_sense(fsg, bh); | ||
2410 | break; | ||
2411 | |||
2412 | case ALLOW_MEDIUM_REMOVAL: | ||
2413 | fsg->data_size_from_cmnd = 0; | ||
2414 | if ((reply = check_command(fsg, 6, DATA_DIR_NONE, | ||
2415 | (1<<4), 0, | ||
2416 | "PREVENT-ALLOW MEDIUM REMOVAL")) == 0) | ||
2417 | reply = do_prevent_allow(fsg); | ||
2418 | break; | ||
2419 | |||
2420 | case READ_6: | ||
2421 | i = fsg->cmnd[4]; | ||
2422 | fsg->data_size_from_cmnd = (i == 0) ? 256 : i; | ||
2423 | if ((reply = check_command_size_in_blocks(fsg, 6, | ||
2424 | DATA_DIR_TO_HOST, | ||
2425 | (7<<1) | (1<<4), 1, | ||
2426 | "READ(6)")) == 0) | ||
2427 | reply = do_read(fsg); | ||
2428 | break; | ||
2429 | |||
2430 | case READ_10: | ||
2431 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2432 | if ((reply = check_command_size_in_blocks(fsg, 10, | ||
2433 | DATA_DIR_TO_HOST, | ||
2434 | (1<<1) | (0xf<<2) | (3<<7), 1, | ||
2435 | "READ(10)")) == 0) | ||
2436 | reply = do_read(fsg); | ||
2437 | break; | ||
2438 | |||
2439 | case READ_12: | ||
2440 | fsg->data_size_from_cmnd = get_unaligned_be32(&fsg->cmnd[6]); | ||
2441 | if ((reply = check_command_size_in_blocks(fsg, 12, | ||
2442 | DATA_DIR_TO_HOST, | ||
2443 | (1<<1) | (0xf<<2) | (0xf<<6), 1, | ||
2444 | "READ(12)")) == 0) | ||
2445 | reply = do_read(fsg); | ||
2446 | break; | ||
2447 | |||
2448 | case READ_CAPACITY: | ||
2449 | fsg->data_size_from_cmnd = 8; | ||
2450 | if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, | ||
2451 | (0xf<<2) | (1<<8), 1, | ||
2452 | "READ CAPACITY")) == 0) | ||
2453 | reply = do_read_capacity(fsg, bh); | ||
2454 | break; | ||
2455 | |||
2456 | case READ_HEADER: | ||
2457 | if (!mod_data.cdrom) | ||
2458 | goto unknown_cmnd; | ||
2459 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2460 | if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, | ||
2461 | (3<<7) | (0x1f<<1), 1, | ||
2462 | "READ HEADER")) == 0) | ||
2463 | reply = do_read_header(fsg, bh); | ||
2464 | break; | ||
2465 | |||
2466 | case READ_TOC: | ||
2467 | if (!mod_data.cdrom) | ||
2468 | goto unknown_cmnd; | ||
2469 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2470 | if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, | ||
2471 | (7<<6) | (1<<1), 1, | ||
2472 | "READ TOC")) == 0) | ||
2473 | reply = do_read_toc(fsg, bh); | ||
2474 | break; | ||
2475 | |||
2476 | case READ_FORMAT_CAPACITIES: | ||
2477 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2478 | if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST, | ||
2479 | (3<<7), 1, | ||
2480 | "READ FORMAT CAPACITIES")) == 0) | ||
2481 | reply = do_read_format_capacities(fsg, bh); | ||
2482 | break; | ||
2483 | |||
2484 | case REQUEST_SENSE: | ||
2485 | fsg->data_size_from_cmnd = fsg->cmnd[4]; | ||
2486 | if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST, | ||
2487 | (1<<4), 0, | ||
2488 | "REQUEST SENSE")) == 0) | ||
2489 | reply = do_request_sense(fsg, bh); | ||
2490 | break; | ||
2491 | |||
2492 | case START_STOP: | ||
2493 | fsg->data_size_from_cmnd = 0; | ||
2494 | if ((reply = check_command(fsg, 6, DATA_DIR_NONE, | ||
2495 | (1<<1) | (1<<4), 0, | ||
2496 | "START-STOP UNIT")) == 0) | ||
2497 | reply = do_start_stop(fsg); | ||
2498 | break; | ||
2499 | |||
2500 | case SYNCHRONIZE_CACHE: | ||
2501 | fsg->data_size_from_cmnd = 0; | ||
2502 | if ((reply = check_command(fsg, 10, DATA_DIR_NONE, | ||
2503 | (0xf<<2) | (3<<7), 1, | ||
2504 | "SYNCHRONIZE CACHE")) == 0) | ||
2505 | reply = do_synchronize_cache(fsg); | ||
2506 | break; | ||
2507 | |||
2508 | case TEST_UNIT_READY: | ||
2509 | fsg->data_size_from_cmnd = 0; | ||
2510 | reply = check_command(fsg, 6, DATA_DIR_NONE, | ||
2511 | 0, 1, | ||
2512 | "TEST UNIT READY"); | ||
2513 | break; | ||
2514 | |||
2515 | /* Although optional, this command is used by MS-Windows. We | ||
2516 | * support a minimal version: BytChk must be 0. */ | ||
2517 | case VERIFY: | ||
2518 | fsg->data_size_from_cmnd = 0; | ||
2519 | if ((reply = check_command(fsg, 10, DATA_DIR_NONE, | ||
2520 | (1<<1) | (0xf<<2) | (3<<7), 1, | ||
2521 | "VERIFY")) == 0) | ||
2522 | reply = do_verify(fsg); | ||
2523 | break; | ||
2524 | |||
2525 | case WRITE_6: | ||
2526 | i = fsg->cmnd[4]; | ||
2527 | fsg->data_size_from_cmnd = (i == 0) ? 256 : i; | ||
2528 | if ((reply = check_command_size_in_blocks(fsg, 6, | ||
2529 | DATA_DIR_FROM_HOST, | ||
2530 | (7<<1) | (1<<4), 1, | ||
2531 | "WRITE(6)")) == 0) | ||
2532 | reply = do_write(fsg); | ||
2533 | break; | ||
2534 | |||
2535 | case WRITE_10: | ||
2536 | fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]); | ||
2537 | if ((reply = check_command_size_in_blocks(fsg, 10, | ||
2538 | DATA_DIR_FROM_HOST, | ||
2539 | (1<<1) | (0xf<<2) | (3<<7), 1, | ||
2540 | "WRITE(10)")) == 0) | ||
2541 | reply = do_write(fsg); | ||
2542 | break; | ||
2543 | |||
2544 | case WRITE_12: | ||
2545 | fsg->data_size_from_cmnd = get_unaligned_be32(&fsg->cmnd[6]); | ||
2546 | if ((reply = check_command_size_in_blocks(fsg, 12, | ||
2547 | DATA_DIR_FROM_HOST, | ||
2548 | (1<<1) | (0xf<<2) | (0xf<<6), 1, | ||
2549 | "WRITE(12)")) == 0) | ||
2550 | reply = do_write(fsg); | ||
2551 | break; | ||
2552 | |||
2553 | /* Some mandatory commands that we recognize but don't implement. | ||
2554 | * They don't mean much in this setting. It's left as an exercise | ||
2555 | * for anyone interested to implement RESERVE and RELEASE in terms | ||
2556 | * of Posix locks. */ | ||
2557 | case FORMAT_UNIT: | ||
2558 | case RELEASE: | ||
2559 | case RESERVE: | ||
2560 | case SEND_DIAGNOSTIC: | ||
2561 | // Fall through | ||
2562 | |||
2563 | default: | ||
2564 | unknown_cmnd: | ||
2565 | fsg->data_size_from_cmnd = 0; | ||
2566 | sprintf(unknown, "Unknown x%02x", fsg->cmnd[0]); | ||
2567 | if ((reply = check_command(fsg, fsg->cmnd_size, | ||
2568 | DATA_DIR_UNKNOWN, ~0, 0, unknown)) == 0) { | ||
2569 | fsg->curlun->sense_data = SS_INVALID_COMMAND; | ||
2570 | reply = -EINVAL; | ||
2571 | } | ||
2572 | break; | ||
2573 | } | ||
2574 | up_read(&fsg->filesem); | ||
2575 | |||
2576 | if (reply == -EINTR || signal_pending(current)) | ||
2577 | return -EINTR; | ||
2578 | |||
2579 | /* Set up the single reply buffer for finish_reply() */ | ||
2580 | if (reply == -EINVAL) | ||
2581 | reply = 0; // Error reply length | ||
2582 | if (reply >= 0 && fsg->data_dir == DATA_DIR_TO_HOST) { | ||
2583 | reply = min((u32) reply, fsg->data_size_from_cmnd); | ||
2584 | bh->inreq->length = reply; | ||
2585 | bh->state = BUF_STATE_FULL; | ||
2586 | fsg->residue -= reply; | ||
2587 | } // Otherwise it's already set | ||
2588 | |||
2589 | return 0; | ||
2590 | } | ||
2591 | |||
2592 | |||
2593 | /*-------------------------------------------------------------------------*/ | ||
2594 | |||
2595 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | ||
2596 | { | ||
2597 | struct usb_request *req = bh->outreq; | ||
2598 | struct bulk_cb_wrap *cbw = req->buf; | ||
2599 | |||
2600 | /* Was this a real packet? Should it be ignored? */ | ||
2601 | if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) | ||
2602 | return -EINVAL; | ||
2603 | |||
2604 | /* Is the CBW valid? */ | ||
2605 | if (req->actual != US_BULK_CB_WRAP_LEN || | ||
2606 | cbw->Signature != cpu_to_le32( | ||
2607 | US_BULK_CB_SIGN)) { | ||
2608 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", | ||
2609 | req->actual, | ||
2610 | le32_to_cpu(cbw->Signature)); | ||
2611 | |||
2612 | /* The Bulk-only spec says we MUST stall the IN endpoint | ||
2613 | * (6.6.1), so it's unavoidable. It also says we must | ||
2614 | * retain this state until the next reset, but there's | ||
2615 | * no way to tell the controller driver it should ignore | ||
2616 | * Clear-Feature(HALT) requests. | ||
2617 | * | ||
2618 | * We aren't required to halt the OUT endpoint; instead | ||
2619 | * we can simply accept and discard any data received | ||
2620 | * until the next reset. */ | ||
2621 | wedge_bulk_in_endpoint(fsg); | ||
2622 | set_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); | ||
2623 | return -EINVAL; | ||
2624 | } | ||
2625 | |||
2626 | /* Is the CBW meaningful? */ | ||
2627 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN || | ||
2628 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { | ||
2629 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " | ||
2630 | "cmdlen %u\n", | ||
2631 | cbw->Lun, cbw->Flags, cbw->Length); | ||
2632 | |||
2633 | /* We can do anything we want here, so let's stall the | ||
2634 | * bulk pipes if we are allowed to. */ | ||
2635 | if (mod_data.can_stall) { | ||
2636 | fsg_set_halt(fsg, fsg->bulk_out); | ||
2637 | halt_bulk_in_endpoint(fsg); | ||
2638 | } | ||
2639 | return -EINVAL; | ||
2640 | } | ||
2641 | |||
2642 | /* Save the command for later */ | ||
2643 | fsg->cmnd_size = cbw->Length; | ||
2644 | memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size); | ||
2645 | if (cbw->Flags & US_BULK_FLAG_IN) | ||
2646 | fsg->data_dir = DATA_DIR_TO_HOST; | ||
2647 | else | ||
2648 | fsg->data_dir = DATA_DIR_FROM_HOST; | ||
2649 | fsg->data_size = le32_to_cpu(cbw->DataTransferLength); | ||
2650 | if (fsg->data_size == 0) | ||
2651 | fsg->data_dir = DATA_DIR_NONE; | ||
2652 | fsg->lun = cbw->Lun; | ||
2653 | fsg->tag = cbw->Tag; | ||
2654 | return 0; | ||
2655 | } | ||
2656 | |||
2657 | |||
2658 | static int get_next_command(struct fsg_dev *fsg) | ||
2659 | { | ||
2660 | struct fsg_buffhd *bh; | ||
2661 | int rc = 0; | ||
2662 | |||
2663 | if (transport_is_bbb()) { | ||
2664 | |||
2665 | /* Wait for the next buffer to become available */ | ||
2666 | bh = fsg->next_buffhd_to_fill; | ||
2667 | while (bh->state != BUF_STATE_EMPTY) { | ||
2668 | rc = sleep_thread(fsg); | ||
2669 | if (rc) | ||
2670 | return rc; | ||
2671 | } | ||
2672 | |||
2673 | /* Queue a request to read a Bulk-only CBW */ | ||
2674 | set_bulk_out_req_length(fsg, bh, US_BULK_CB_WRAP_LEN); | ||
2675 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | ||
2676 | &bh->outreq_busy, &bh->state); | ||
2677 | |||
2678 | /* We will drain the buffer in software, which means we | ||
2679 | * can reuse it for the next filling. No need to advance | ||
2680 | * next_buffhd_to_fill. */ | ||
2681 | |||
2682 | /* Wait for the CBW to arrive */ | ||
2683 | while (bh->state != BUF_STATE_FULL) { | ||
2684 | rc = sleep_thread(fsg); | ||
2685 | if (rc) | ||
2686 | return rc; | ||
2687 | } | ||
2688 | smp_rmb(); | ||
2689 | rc = received_cbw(fsg, bh); | ||
2690 | bh->state = BUF_STATE_EMPTY; | ||
2691 | |||
2692 | } else { // USB_PR_CB or USB_PR_CBI | ||
2693 | |||
2694 | /* Wait for the next command to arrive */ | ||
2695 | while (fsg->cbbuf_cmnd_size == 0) { | ||
2696 | rc = sleep_thread(fsg); | ||
2697 | if (rc) | ||
2698 | return rc; | ||
2699 | } | ||
2700 | |||
2701 | /* Is the previous status interrupt request still busy? | ||
2702 | * The host is allowed to skip reading the status, | ||
2703 | * so we must cancel it. */ | ||
2704 | if (fsg->intreq_busy) | ||
2705 | usb_ep_dequeue(fsg->intr_in, fsg->intreq); | ||
2706 | |||
2707 | /* Copy the command and mark the buffer empty */ | ||
2708 | fsg->data_dir = DATA_DIR_UNKNOWN; | ||
2709 | spin_lock_irq(&fsg->lock); | ||
2710 | fsg->cmnd_size = fsg->cbbuf_cmnd_size; | ||
2711 | memcpy(fsg->cmnd, fsg->cbbuf_cmnd, fsg->cmnd_size); | ||
2712 | fsg->cbbuf_cmnd_size = 0; | ||
2713 | spin_unlock_irq(&fsg->lock); | ||
2714 | |||
2715 | /* Use LUN from the command */ | ||
2716 | fsg->lun = fsg->cmnd[1] >> 5; | ||
2717 | } | ||
2718 | |||
2719 | /* Update current lun */ | ||
2720 | if (fsg->lun >= 0 && fsg->lun < fsg->nluns) | ||
2721 | fsg->curlun = &fsg->luns[fsg->lun]; | ||
2722 | else | ||
2723 | fsg->curlun = NULL; | ||
2724 | |||
2725 | return rc; | ||
2726 | } | ||
2727 | |||
2728 | |||
2729 | /*-------------------------------------------------------------------------*/ | ||
2730 | |||
2731 | static int enable_endpoint(struct fsg_dev *fsg, struct usb_ep *ep, | ||
2732 | const struct usb_endpoint_descriptor *d) | ||
2733 | { | ||
2734 | int rc; | ||
2735 | |||
2736 | ep->driver_data = fsg; | ||
2737 | ep->desc = d; | ||
2738 | rc = usb_ep_enable(ep); | ||
2739 | if (rc) | ||
2740 | ERROR(fsg, "can't enable %s, result %d\n", ep->name, rc); | ||
2741 | return rc; | ||
2742 | } | ||
2743 | |||
2744 | static int alloc_request(struct fsg_dev *fsg, struct usb_ep *ep, | ||
2745 | struct usb_request **preq) | ||
2746 | { | ||
2747 | *preq = usb_ep_alloc_request(ep, GFP_ATOMIC); | ||
2748 | if (*preq) | ||
2749 | return 0; | ||
2750 | ERROR(fsg, "can't allocate request for %s\n", ep->name); | ||
2751 | return -ENOMEM; | ||
2752 | } | ||
2753 | |||
2754 | /* | ||
2755 | * Reset interface setting and re-init endpoint state (toggle etc). | ||
2756 | * Call with altsetting < 0 to disable the interface. The only other | ||
2757 | * available altsetting is 0, which enables the interface. | ||
2758 | */ | ||
2759 | static int do_set_interface(struct fsg_dev *fsg, int altsetting) | ||
2760 | { | ||
2761 | int rc = 0; | ||
2762 | int i; | ||
2763 | const struct usb_endpoint_descriptor *d; | ||
2764 | |||
2765 | if (fsg->running) | ||
2766 | DBG(fsg, "reset interface\n"); | ||
2767 | |||
2768 | reset: | ||
2769 | /* Deallocate the requests */ | ||
2770 | for (i = 0; i < fsg_num_buffers; ++i) { | ||
2771 | struct fsg_buffhd *bh = &fsg->buffhds[i]; | ||
2772 | |||
2773 | if (bh->inreq) { | ||
2774 | usb_ep_free_request(fsg->bulk_in, bh->inreq); | ||
2775 | bh->inreq = NULL; | ||
2776 | } | ||
2777 | if (bh->outreq) { | ||
2778 | usb_ep_free_request(fsg->bulk_out, bh->outreq); | ||
2779 | bh->outreq = NULL; | ||
2780 | } | ||
2781 | } | ||
2782 | if (fsg->intreq) { | ||
2783 | usb_ep_free_request(fsg->intr_in, fsg->intreq); | ||
2784 | fsg->intreq = NULL; | ||
2785 | } | ||
2786 | |||
2787 | /* Disable the endpoints */ | ||
2788 | if (fsg->bulk_in_enabled) { | ||
2789 | usb_ep_disable(fsg->bulk_in); | ||
2790 | fsg->bulk_in_enabled = 0; | ||
2791 | } | ||
2792 | if (fsg->bulk_out_enabled) { | ||
2793 | usb_ep_disable(fsg->bulk_out); | ||
2794 | fsg->bulk_out_enabled = 0; | ||
2795 | } | ||
2796 | if (fsg->intr_in_enabled) { | ||
2797 | usb_ep_disable(fsg->intr_in); | ||
2798 | fsg->intr_in_enabled = 0; | ||
2799 | } | ||
2800 | |||
2801 | fsg->running = 0; | ||
2802 | if (altsetting < 0 || rc != 0) | ||
2803 | return rc; | ||
2804 | |||
2805 | DBG(fsg, "set interface %d\n", altsetting); | ||
2806 | |||
2807 | /* Enable the endpoints */ | ||
2808 | d = fsg_ep_desc(fsg->gadget, | ||
2809 | &fsg_fs_bulk_in_desc, &fsg_hs_bulk_in_desc, | ||
2810 | &fsg_ss_bulk_in_desc); | ||
2811 | if ((rc = enable_endpoint(fsg, fsg->bulk_in, d)) != 0) | ||
2812 | goto reset; | ||
2813 | fsg->bulk_in_enabled = 1; | ||
2814 | |||
2815 | d = fsg_ep_desc(fsg->gadget, | ||
2816 | &fsg_fs_bulk_out_desc, &fsg_hs_bulk_out_desc, | ||
2817 | &fsg_ss_bulk_out_desc); | ||
2818 | if ((rc = enable_endpoint(fsg, fsg->bulk_out, d)) != 0) | ||
2819 | goto reset; | ||
2820 | fsg->bulk_out_enabled = 1; | ||
2821 | fsg->bulk_out_maxpacket = usb_endpoint_maxp(d); | ||
2822 | clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags); | ||
2823 | |||
2824 | if (transport_is_cbi()) { | ||
2825 | d = fsg_ep_desc(fsg->gadget, | ||
2826 | &fsg_fs_intr_in_desc, &fsg_hs_intr_in_desc, | ||
2827 | &fsg_ss_intr_in_desc); | ||
2828 | if ((rc = enable_endpoint(fsg, fsg->intr_in, d)) != 0) | ||
2829 | goto reset; | ||
2830 | fsg->intr_in_enabled = 1; | ||
2831 | } | ||
2832 | |||
2833 | /* Allocate the requests */ | ||
2834 | for (i = 0; i < fsg_num_buffers; ++i) { | ||
2835 | struct fsg_buffhd *bh = &fsg->buffhds[i]; | ||
2836 | |||
2837 | if ((rc = alloc_request(fsg, fsg->bulk_in, &bh->inreq)) != 0) | ||
2838 | goto reset; | ||
2839 | if ((rc = alloc_request(fsg, fsg->bulk_out, &bh->outreq)) != 0) | ||
2840 | goto reset; | ||
2841 | bh->inreq->buf = bh->outreq->buf = bh->buf; | ||
2842 | bh->inreq->context = bh->outreq->context = bh; | ||
2843 | bh->inreq->complete = bulk_in_complete; | ||
2844 | bh->outreq->complete = bulk_out_complete; | ||
2845 | } | ||
2846 | if (transport_is_cbi()) { | ||
2847 | if ((rc = alloc_request(fsg, fsg->intr_in, &fsg->intreq)) != 0) | ||
2848 | goto reset; | ||
2849 | fsg->intreq->complete = intr_in_complete; | ||
2850 | } | ||
2851 | |||
2852 | fsg->running = 1; | ||
2853 | for (i = 0; i < fsg->nluns; ++i) | ||
2854 | fsg->luns[i].unit_attention_data = SS_RESET_OCCURRED; | ||
2855 | return rc; | ||
2856 | } | ||
2857 | |||
2858 | |||
2859 | /* | ||
2860 | * Change our operational configuration. This code must agree with the code | ||
2861 | * that returns config descriptors, and with interface altsetting code. | ||
2862 | * | ||
2863 | * It's also responsible for power management interactions. Some | ||
2864 | * configurations might not work with our current power sources. | ||
2865 | * For now we just assume the gadget is always self-powered. | ||
2866 | */ | ||
2867 | static int do_set_config(struct fsg_dev *fsg, u8 new_config) | ||
2868 | { | ||
2869 | int rc = 0; | ||
2870 | |||
2871 | /* Disable the single interface */ | ||
2872 | if (fsg->config != 0) { | ||
2873 | DBG(fsg, "reset config\n"); | ||
2874 | fsg->config = 0; | ||
2875 | rc = do_set_interface(fsg, -1); | ||
2876 | } | ||
2877 | |||
2878 | /* Enable the interface */ | ||
2879 | if (new_config != 0) { | ||
2880 | fsg->config = new_config; | ||
2881 | if ((rc = do_set_interface(fsg, 0)) != 0) | ||
2882 | fsg->config = 0; // Reset on errors | ||
2883 | else | ||
2884 | INFO(fsg, "%s config #%d\n", | ||
2885 | usb_speed_string(fsg->gadget->speed), | ||
2886 | fsg->config); | ||
2887 | } | ||
2888 | return rc; | ||
2889 | } | ||
2890 | |||
2891 | |||
2892 | /*-------------------------------------------------------------------------*/ | ||
2893 | |||
2894 | static void handle_exception(struct fsg_dev *fsg) | ||
2895 | { | ||
2896 | siginfo_t info; | ||
2897 | int sig; | ||
2898 | int i; | ||
2899 | int num_active; | ||
2900 | struct fsg_buffhd *bh; | ||
2901 | enum fsg_state old_state; | ||
2902 | u8 new_config; | ||
2903 | struct fsg_lun *curlun; | ||
2904 | unsigned int exception_req_tag; | ||
2905 | int rc; | ||
2906 | |||
2907 | /* Clear the existing signals. Anything but SIGUSR1 is converted | ||
2908 | * into a high-priority EXIT exception. */ | ||
2909 | for (;;) { | ||
2910 | sig = dequeue_signal_lock(current, ¤t->blocked, &info); | ||
2911 | if (!sig) | ||
2912 | break; | ||
2913 | if (sig != SIGUSR1) { | ||
2914 | if (fsg->state < FSG_STATE_EXIT) | ||
2915 | DBG(fsg, "Main thread exiting on signal\n"); | ||
2916 | raise_exception(fsg, FSG_STATE_EXIT); | ||
2917 | } | ||
2918 | } | ||
2919 | |||
2920 | /* Cancel all the pending transfers */ | ||
2921 | if (fsg->intreq_busy) | ||
2922 | usb_ep_dequeue(fsg->intr_in, fsg->intreq); | ||
2923 | for (i = 0; i < fsg_num_buffers; ++i) { | ||
2924 | bh = &fsg->buffhds[i]; | ||
2925 | if (bh->inreq_busy) | ||
2926 | usb_ep_dequeue(fsg->bulk_in, bh->inreq); | ||
2927 | if (bh->outreq_busy) | ||
2928 | usb_ep_dequeue(fsg->bulk_out, bh->outreq); | ||
2929 | } | ||
2930 | |||
2931 | /* Wait until everything is idle */ | ||
2932 | for (;;) { | ||
2933 | num_active = fsg->intreq_busy; | ||
2934 | for (i = 0; i < fsg_num_buffers; ++i) { | ||
2935 | bh = &fsg->buffhds[i]; | ||
2936 | num_active += bh->inreq_busy + bh->outreq_busy; | ||
2937 | } | ||
2938 | if (num_active == 0) | ||
2939 | break; | ||
2940 | if (sleep_thread(fsg)) | ||
2941 | return; | ||
2942 | } | ||
2943 | |||
2944 | /* Clear out the controller's fifos */ | ||
2945 | if (fsg->bulk_in_enabled) | ||
2946 | usb_ep_fifo_flush(fsg->bulk_in); | ||
2947 | if (fsg->bulk_out_enabled) | ||
2948 | usb_ep_fifo_flush(fsg->bulk_out); | ||
2949 | if (fsg->intr_in_enabled) | ||
2950 | usb_ep_fifo_flush(fsg->intr_in); | ||
2951 | |||
2952 | /* Reset the I/O buffer states and pointers, the SCSI | ||
2953 | * state, and the exception. Then invoke the handler. */ | ||
2954 | spin_lock_irq(&fsg->lock); | ||
2955 | |||
2956 | for (i = 0; i < fsg_num_buffers; ++i) { | ||
2957 | bh = &fsg->buffhds[i]; | ||
2958 | bh->state = BUF_STATE_EMPTY; | ||
2959 | } | ||
2960 | fsg->next_buffhd_to_fill = fsg->next_buffhd_to_drain = | ||
2961 | &fsg->buffhds[0]; | ||
2962 | |||
2963 | exception_req_tag = fsg->exception_req_tag; | ||
2964 | new_config = fsg->new_config; | ||
2965 | old_state = fsg->state; | ||
2966 | |||
2967 | if (old_state == FSG_STATE_ABORT_BULK_OUT) | ||
2968 | fsg->state = FSG_STATE_STATUS_PHASE; | ||
2969 | else { | ||
2970 | for (i = 0; i < fsg->nluns; ++i) { | ||
2971 | curlun = &fsg->luns[i]; | ||
2972 | curlun->prevent_medium_removal = 0; | ||
2973 | curlun->sense_data = curlun->unit_attention_data = | ||
2974 | SS_NO_SENSE; | ||
2975 | curlun->sense_data_info = 0; | ||
2976 | curlun->info_valid = 0; | ||
2977 | } | ||
2978 | fsg->state = FSG_STATE_IDLE; | ||
2979 | } | ||
2980 | spin_unlock_irq(&fsg->lock); | ||
2981 | |||
2982 | /* Carry out any extra actions required for the exception */ | ||
2983 | switch (old_state) { | ||
2984 | default: | ||
2985 | break; | ||
2986 | |||
2987 | case FSG_STATE_ABORT_BULK_OUT: | ||
2988 | send_status(fsg); | ||
2989 | spin_lock_irq(&fsg->lock); | ||
2990 | if (fsg->state == FSG_STATE_STATUS_PHASE) | ||
2991 | fsg->state = FSG_STATE_IDLE; | ||
2992 | spin_unlock_irq(&fsg->lock); | ||
2993 | break; | ||
2994 | |||
2995 | case FSG_STATE_RESET: | ||
2996 | /* In case we were forced against our will to halt a | ||
2997 | * bulk endpoint, clear the halt now. (The SuperH UDC | ||
2998 | * requires this.) */ | ||
2999 | if (test_and_clear_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) | ||
3000 | usb_ep_clear_halt(fsg->bulk_in); | ||
3001 | |||
3002 | if (transport_is_bbb()) { | ||
3003 | if (fsg->ep0_req_tag == exception_req_tag) | ||
3004 | ep0_queue(fsg); // Complete the status stage | ||
3005 | |||
3006 | } else if (transport_is_cbi()) | ||
3007 | send_status(fsg); // Status by interrupt pipe | ||
3008 | |||
3009 | /* Technically this should go here, but it would only be | ||
3010 | * a waste of time. Ditto for the INTERFACE_CHANGE and | ||
3011 | * CONFIG_CHANGE cases. */ | ||
3012 | // for (i = 0; i < fsg->nluns; ++i) | ||
3013 | // fsg->luns[i].unit_attention_data = SS_RESET_OCCURRED; | ||
3014 | break; | ||
3015 | |||
3016 | case FSG_STATE_INTERFACE_CHANGE: | ||
3017 | rc = do_set_interface(fsg, 0); | ||
3018 | if (fsg->ep0_req_tag != exception_req_tag) | ||
3019 | break; | ||
3020 | if (rc != 0) // STALL on errors | ||
3021 | fsg_set_halt(fsg, fsg->ep0); | ||
3022 | else // Complete the status stage | ||
3023 | ep0_queue(fsg); | ||
3024 | break; | ||
3025 | |||
3026 | case FSG_STATE_CONFIG_CHANGE: | ||
3027 | rc = do_set_config(fsg, new_config); | ||
3028 | if (fsg->ep0_req_tag != exception_req_tag) | ||
3029 | break; | ||
3030 | if (rc != 0) // STALL on errors | ||
3031 | fsg_set_halt(fsg, fsg->ep0); | ||
3032 | else // Complete the status stage | ||
3033 | ep0_queue(fsg); | ||
3034 | break; | ||
3035 | |||
3036 | case FSG_STATE_DISCONNECT: | ||
3037 | for (i = 0; i < fsg->nluns; ++i) | ||
3038 | fsg_lun_fsync_sub(fsg->luns + i); | ||
3039 | do_set_config(fsg, 0); // Unconfigured state | ||
3040 | break; | ||
3041 | |||
3042 | case FSG_STATE_EXIT: | ||
3043 | case FSG_STATE_TERMINATED: | ||
3044 | do_set_config(fsg, 0); // Free resources | ||
3045 | spin_lock_irq(&fsg->lock); | ||
3046 | fsg->state = FSG_STATE_TERMINATED; // Stop the thread | ||
3047 | spin_unlock_irq(&fsg->lock); | ||
3048 | break; | ||
3049 | } | ||
3050 | } | ||
3051 | |||
3052 | |||
3053 | /*-------------------------------------------------------------------------*/ | ||
3054 | |||
3055 | static int fsg_main_thread(void *fsg_) | ||
3056 | { | ||
3057 | struct fsg_dev *fsg = fsg_; | ||
3058 | |||
3059 | /* Allow the thread to be killed by a signal, but set the signal mask | ||
3060 | * to block everything but INT, TERM, KILL, and USR1. */ | ||
3061 | allow_signal(SIGINT); | ||
3062 | allow_signal(SIGTERM); | ||
3063 | allow_signal(SIGKILL); | ||
3064 | allow_signal(SIGUSR1); | ||
3065 | |||
3066 | /* Allow the thread to be frozen */ | ||
3067 | set_freezable(); | ||
3068 | |||
3069 | /* Arrange for userspace references to be interpreted as kernel | ||
3070 | * pointers. That way we can pass a kernel pointer to a routine | ||
3071 | * that expects a __user pointer and it will work okay. */ | ||
3072 | set_fs(get_ds()); | ||
3073 | |||
3074 | /* The main loop */ | ||
3075 | while (fsg->state != FSG_STATE_TERMINATED) { | ||
3076 | if (exception_in_progress(fsg) || signal_pending(current)) { | ||
3077 | handle_exception(fsg); | ||
3078 | continue; | ||
3079 | } | ||
3080 | |||
3081 | if (!fsg->running) { | ||
3082 | sleep_thread(fsg); | ||
3083 | continue; | ||
3084 | } | ||
3085 | |||
3086 | if (get_next_command(fsg)) | ||
3087 | continue; | ||
3088 | |||
3089 | spin_lock_irq(&fsg->lock); | ||
3090 | if (!exception_in_progress(fsg)) | ||
3091 | fsg->state = FSG_STATE_DATA_PHASE; | ||
3092 | spin_unlock_irq(&fsg->lock); | ||
3093 | |||
3094 | if (do_scsi_command(fsg) || finish_reply(fsg)) | ||
3095 | continue; | ||
3096 | |||
3097 | spin_lock_irq(&fsg->lock); | ||
3098 | if (!exception_in_progress(fsg)) | ||
3099 | fsg->state = FSG_STATE_STATUS_PHASE; | ||
3100 | spin_unlock_irq(&fsg->lock); | ||
3101 | |||
3102 | if (send_status(fsg)) | ||
3103 | continue; | ||
3104 | |||
3105 | spin_lock_irq(&fsg->lock); | ||
3106 | if (!exception_in_progress(fsg)) | ||
3107 | fsg->state = FSG_STATE_IDLE; | ||
3108 | spin_unlock_irq(&fsg->lock); | ||
3109 | } | ||
3110 | |||
3111 | spin_lock_irq(&fsg->lock); | ||
3112 | fsg->thread_task = NULL; | ||
3113 | spin_unlock_irq(&fsg->lock); | ||
3114 | |||
3115 | /* If we are exiting because of a signal, unregister the | ||
3116 | * gadget driver. */ | ||
3117 | if (test_and_clear_bit(REGISTERED, &fsg->atomic_bitflags)) | ||
3118 | usb_gadget_unregister_driver(&fsg_driver); | ||
3119 | |||
3120 | /* Let the unbind and cleanup routines know the thread has exited */ | ||
3121 | complete_and_exit(&fsg->thread_notifier, 0); | ||
3122 | } | ||
3123 | |||
3124 | |||
3125 | /*-------------------------------------------------------------------------*/ | ||
3126 | |||
3127 | |||
3128 | /* The write permissions and store_xxx pointers are set in fsg_bind() */ | ||
3129 | static DEVICE_ATTR(ro, 0444, fsg_show_ro, NULL); | ||
3130 | static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, NULL); | ||
3131 | static DEVICE_ATTR(file, 0444, fsg_show_file, NULL); | ||
3132 | |||
3133 | |||
3134 | /*-------------------------------------------------------------------------*/ | ||
3135 | |||
3136 | static void fsg_release(struct kref *ref) | ||
3137 | { | ||
3138 | struct fsg_dev *fsg = container_of(ref, struct fsg_dev, ref); | ||
3139 | |||
3140 | kfree(fsg->luns); | ||
3141 | kfree(fsg); | ||
3142 | } | ||
3143 | |||
3144 | static void lun_release(struct device *dev) | ||
3145 | { | ||
3146 | struct rw_semaphore *filesem = dev_get_drvdata(dev); | ||
3147 | struct fsg_dev *fsg = | ||
3148 | container_of(filesem, struct fsg_dev, filesem); | ||
3149 | |||
3150 | kref_put(&fsg->ref, fsg_release); | ||
3151 | } | ||
3152 | |||
3153 | static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget) | ||
3154 | { | ||
3155 | struct fsg_dev *fsg = get_gadget_data(gadget); | ||
3156 | int i; | ||
3157 | struct fsg_lun *curlun; | ||
3158 | struct usb_request *req = fsg->ep0req; | ||
3159 | |||
3160 | DBG(fsg, "unbind\n"); | ||
3161 | clear_bit(REGISTERED, &fsg->atomic_bitflags); | ||
3162 | |||
3163 | /* If the thread isn't already dead, tell it to exit now */ | ||
3164 | if (fsg->state != FSG_STATE_TERMINATED) { | ||
3165 | raise_exception(fsg, FSG_STATE_EXIT); | ||
3166 | wait_for_completion(&fsg->thread_notifier); | ||
3167 | |||
3168 | /* The cleanup routine waits for this completion also */ | ||
3169 | complete(&fsg->thread_notifier); | ||
3170 | } | ||
3171 | |||
3172 | /* Unregister the sysfs attribute files and the LUNs */ | ||
3173 | for (i = 0; i < fsg->nluns; ++i) { | ||
3174 | curlun = &fsg->luns[i]; | ||
3175 | if (curlun->registered) { | ||
3176 | device_remove_file(&curlun->dev, &dev_attr_nofua); | ||
3177 | device_remove_file(&curlun->dev, &dev_attr_ro); | ||
3178 | device_remove_file(&curlun->dev, &dev_attr_file); | ||
3179 | fsg_lun_close(curlun); | ||
3180 | device_unregister(&curlun->dev); | ||
3181 | curlun->registered = 0; | ||
3182 | } | ||
3183 | } | ||
3184 | |||
3185 | /* Free the data buffers */ | ||
3186 | for (i = 0; i < fsg_num_buffers; ++i) | ||
3187 | kfree(fsg->buffhds[i].buf); | ||
3188 | |||
3189 | /* Free the request and buffer for endpoint 0 */ | ||
3190 | if (req) { | ||
3191 | kfree(req->buf); | ||
3192 | usb_ep_free_request(fsg->ep0, req); | ||
3193 | } | ||
3194 | |||
3195 | set_gadget_data(gadget, NULL); | ||
3196 | } | ||
3197 | |||
3198 | |||
3199 | static int __init check_parameters(struct fsg_dev *fsg) | ||
3200 | { | ||
3201 | int prot; | ||
3202 | |||
3203 | /* Store the default values */ | ||
3204 | mod_data.transport_type = USB_PR_BULK; | ||
3205 | mod_data.transport_name = "Bulk-only"; | ||
3206 | mod_data.protocol_type = USB_SC_SCSI; | ||
3207 | mod_data.protocol_name = "Transparent SCSI"; | ||
3208 | |||
3209 | /* Some peripheral controllers are known not to be able to | ||
3210 | * halt bulk endpoints correctly. If one of them is present, | ||
3211 | * disable stalls. | ||
3212 | */ | ||
3213 | if (gadget_is_at91(fsg->gadget)) | ||
3214 | mod_data.can_stall = 0; | ||
3215 | |||
3216 | if (mod_data.release == 0xffff) | ||
3217 | mod_data.release = get_default_bcdDevice(); | ||
3218 | |||
3219 | prot = simple_strtol(mod_data.protocol_parm, NULL, 0); | ||
3220 | |||
3221 | #ifdef CONFIG_USB_FILE_STORAGE_TEST | ||
3222 | if (strnicmp(mod_data.transport_parm, "BBB", 10) == 0) { | ||
3223 | ; // Use default setting | ||
3224 | } else if (strnicmp(mod_data.transport_parm, "CB", 10) == 0) { | ||
3225 | mod_data.transport_type = USB_PR_CB; | ||
3226 | mod_data.transport_name = "Control-Bulk"; | ||
3227 | } else if (strnicmp(mod_data.transport_parm, "CBI", 10) == 0) { | ||
3228 | mod_data.transport_type = USB_PR_CBI; | ||
3229 | mod_data.transport_name = "Control-Bulk-Interrupt"; | ||
3230 | } else { | ||
3231 | ERROR(fsg, "invalid transport: %s\n", mod_data.transport_parm); | ||
3232 | return -EINVAL; | ||
3233 | } | ||
3234 | |||
3235 | if (strnicmp(mod_data.protocol_parm, "SCSI", 10) == 0 || | ||
3236 | prot == USB_SC_SCSI) { | ||
3237 | ; // Use default setting | ||
3238 | } else if (strnicmp(mod_data.protocol_parm, "RBC", 10) == 0 || | ||
3239 | prot == USB_SC_RBC) { | ||
3240 | mod_data.protocol_type = USB_SC_RBC; | ||
3241 | mod_data.protocol_name = "RBC"; | ||
3242 | } else if (strnicmp(mod_data.protocol_parm, "8020", 4) == 0 || | ||
3243 | strnicmp(mod_data.protocol_parm, "ATAPI", 10) == 0 || | ||
3244 | prot == USB_SC_8020) { | ||
3245 | mod_data.protocol_type = USB_SC_8020; | ||
3246 | mod_data.protocol_name = "8020i (ATAPI)"; | ||
3247 | } else if (strnicmp(mod_data.protocol_parm, "QIC", 3) == 0 || | ||
3248 | prot == USB_SC_QIC) { | ||
3249 | mod_data.protocol_type = USB_SC_QIC; | ||
3250 | mod_data.protocol_name = "QIC-157"; | ||
3251 | } else if (strnicmp(mod_data.protocol_parm, "UFI", 10) == 0 || | ||
3252 | prot == USB_SC_UFI) { | ||
3253 | mod_data.protocol_type = USB_SC_UFI; | ||
3254 | mod_data.protocol_name = "UFI"; | ||
3255 | } else if (strnicmp(mod_data.protocol_parm, "8070", 4) == 0 || | ||
3256 | prot == USB_SC_8070) { | ||
3257 | mod_data.protocol_type = USB_SC_8070; | ||
3258 | mod_data.protocol_name = "8070i"; | ||
3259 | } else { | ||
3260 | ERROR(fsg, "invalid protocol: %s\n", mod_data.protocol_parm); | ||
3261 | return -EINVAL; | ||
3262 | } | ||
3263 | |||
3264 | mod_data.buflen &= PAGE_CACHE_MASK; | ||
3265 | if (mod_data.buflen <= 0) { | ||
3266 | ERROR(fsg, "invalid buflen\n"); | ||
3267 | return -ETOOSMALL; | ||
3268 | } | ||
3269 | |||
3270 | #endif /* CONFIG_USB_FILE_STORAGE_TEST */ | ||
3271 | |||
3272 | /* Serial string handling. | ||
3273 | * On a real device, the serial string would be loaded | ||
3274 | * from permanent storage. */ | ||
3275 | if (mod_data.serial) { | ||
3276 | const char *ch; | ||
3277 | unsigned len = 0; | ||
3278 | |||
3279 | /* Sanity check : | ||
3280 | * The CB[I] specification limits the serial string to | ||
3281 | * 12 uppercase hexadecimal characters. | ||
3282 | * BBB need at least 12 uppercase hexadecimal characters, | ||
3283 | * with a maximum of 126. */ | ||
3284 | for (ch = mod_data.serial; *ch; ++ch) { | ||
3285 | ++len; | ||
3286 | if ((*ch < '0' || *ch > '9') && | ||
3287 | (*ch < 'A' || *ch > 'F')) { /* not uppercase hex */ | ||
3288 | WARNING(fsg, | ||
3289 | "Invalid serial string character: %c\n", | ||
3290 | *ch); | ||
3291 | goto no_serial; | ||
3292 | } | ||
3293 | } | ||
3294 | if (len > 126 || | ||
3295 | (mod_data.transport_type == USB_PR_BULK && len < 12) || | ||
3296 | (mod_data.transport_type != USB_PR_BULK && len > 12)) { | ||
3297 | WARNING(fsg, "Invalid serial string length!\n"); | ||
3298 | goto no_serial; | ||
3299 | } | ||
3300 | fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial; | ||
3301 | } else { | ||
3302 | WARNING(fsg, "No serial-number string provided!\n"); | ||
3303 | no_serial: | ||
3304 | device_desc.iSerialNumber = 0; | ||
3305 | } | ||
3306 | |||
3307 | return 0; | ||
3308 | } | ||
3309 | |||
3310 | |||
3311 | static int __init fsg_bind(struct usb_gadget *gadget, | ||
3312 | struct usb_gadget_driver *driver) | ||
3313 | { | ||
3314 | struct fsg_dev *fsg = the_fsg; | ||
3315 | int rc; | ||
3316 | int i; | ||
3317 | struct fsg_lun *curlun; | ||
3318 | struct usb_ep *ep; | ||
3319 | struct usb_request *req; | ||
3320 | char *pathbuf, *p; | ||
3321 | |||
3322 | fsg->gadget = gadget; | ||
3323 | set_gadget_data(gadget, fsg); | ||
3324 | fsg->ep0 = gadget->ep0; | ||
3325 | fsg->ep0->driver_data = fsg; | ||
3326 | |||
3327 | if ((rc = check_parameters(fsg)) != 0) | ||
3328 | goto out; | ||
3329 | |||
3330 | if (mod_data.removable) { // Enable the store_xxx attributes | ||
3331 | dev_attr_file.attr.mode = 0644; | ||
3332 | dev_attr_file.store = fsg_store_file; | ||
3333 | if (!mod_data.cdrom) { | ||
3334 | dev_attr_ro.attr.mode = 0644; | ||
3335 | dev_attr_ro.store = fsg_store_ro; | ||
3336 | } | ||
3337 | } | ||
3338 | |||
3339 | /* Only for removable media? */ | ||
3340 | dev_attr_nofua.attr.mode = 0644; | ||
3341 | dev_attr_nofua.store = fsg_store_nofua; | ||
3342 | |||
3343 | /* Find out how many LUNs there should be */ | ||
3344 | i = mod_data.nluns; | ||
3345 | if (i == 0) | ||
3346 | i = max(mod_data.num_filenames, 1u); | ||
3347 | if (i > FSG_MAX_LUNS) { | ||
3348 | ERROR(fsg, "invalid number of LUNs: %d\n", i); | ||
3349 | rc = -EINVAL; | ||
3350 | goto out; | ||
3351 | } | ||
3352 | |||
3353 | /* Create the LUNs, open their backing files, and register the | ||
3354 | * LUN devices in sysfs. */ | ||
3355 | fsg->luns = kzalloc(i * sizeof(struct fsg_lun), GFP_KERNEL); | ||
3356 | if (!fsg->luns) { | ||
3357 | rc = -ENOMEM; | ||
3358 | goto out; | ||
3359 | } | ||
3360 | fsg->nluns = i; | ||
3361 | |||
3362 | for (i = 0; i < fsg->nluns; ++i) { | ||
3363 | curlun = &fsg->luns[i]; | ||
3364 | curlun->cdrom = !!mod_data.cdrom; | ||
3365 | curlun->ro = mod_data.cdrom || mod_data.ro[i]; | ||
3366 | curlun->initially_ro = curlun->ro; | ||
3367 | curlun->removable = mod_data.removable; | ||
3368 | curlun->nofua = mod_data.nofua[i]; | ||
3369 | curlun->dev.release = lun_release; | ||
3370 | curlun->dev.parent = &gadget->dev; | ||
3371 | curlun->dev.driver = &fsg_driver.driver; | ||
3372 | dev_set_drvdata(&curlun->dev, &fsg->filesem); | ||
3373 | dev_set_name(&curlun->dev,"%s-lun%d", | ||
3374 | dev_name(&gadget->dev), i); | ||
3375 | |||
3376 | kref_get(&fsg->ref); | ||
3377 | rc = device_register(&curlun->dev); | ||
3378 | if (rc) { | ||
3379 | INFO(fsg, "failed to register LUN%d: %d\n", i, rc); | ||
3380 | put_device(&curlun->dev); | ||
3381 | goto out; | ||
3382 | } | ||
3383 | curlun->registered = 1; | ||
3384 | |||
3385 | rc = device_create_file(&curlun->dev, &dev_attr_ro); | ||
3386 | if (rc) | ||
3387 | goto out; | ||
3388 | rc = device_create_file(&curlun->dev, &dev_attr_nofua); | ||
3389 | if (rc) | ||
3390 | goto out; | ||
3391 | rc = device_create_file(&curlun->dev, &dev_attr_file); | ||
3392 | if (rc) | ||
3393 | goto out; | ||
3394 | |||
3395 | if (mod_data.file[i] && *mod_data.file[i]) { | ||
3396 | rc = fsg_lun_open(curlun, mod_data.file[i]); | ||
3397 | if (rc) | ||
3398 | goto out; | ||
3399 | } else if (!mod_data.removable) { | ||
3400 | ERROR(fsg, "no file given for LUN%d\n", i); | ||
3401 | rc = -EINVAL; | ||
3402 | goto out; | ||
3403 | } | ||
3404 | } | ||
3405 | |||
3406 | /* Find all the endpoints we will use */ | ||
3407 | usb_ep_autoconfig_reset(gadget); | ||
3408 | ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_in_desc); | ||
3409 | if (!ep) | ||
3410 | goto autoconf_fail; | ||
3411 | ep->driver_data = fsg; // claim the endpoint | ||
3412 | fsg->bulk_in = ep; | ||
3413 | |||
3414 | ep = usb_ep_autoconfig(gadget, &fsg_fs_bulk_out_desc); | ||
3415 | if (!ep) | ||
3416 | goto autoconf_fail; | ||
3417 | ep->driver_data = fsg; // claim the endpoint | ||
3418 | fsg->bulk_out = ep; | ||
3419 | |||
3420 | if (transport_is_cbi()) { | ||
3421 | ep = usb_ep_autoconfig(gadget, &fsg_fs_intr_in_desc); | ||
3422 | if (!ep) | ||
3423 | goto autoconf_fail; | ||
3424 | ep->driver_data = fsg; // claim the endpoint | ||
3425 | fsg->intr_in = ep; | ||
3426 | } | ||
3427 | |||
3428 | /* Fix up the descriptors */ | ||
3429 | device_desc.idVendor = cpu_to_le16(mod_data.vendor); | ||
3430 | device_desc.idProduct = cpu_to_le16(mod_data.product); | ||
3431 | device_desc.bcdDevice = cpu_to_le16(mod_data.release); | ||
3432 | |||
3433 | i = (transport_is_cbi() ? 3 : 2); // Number of endpoints | ||
3434 | fsg_intf_desc.bNumEndpoints = i; | ||
3435 | fsg_intf_desc.bInterfaceSubClass = mod_data.protocol_type; | ||
3436 | fsg_intf_desc.bInterfaceProtocol = mod_data.transport_type; | ||
3437 | fsg_fs_function[i + FSG_FS_FUNCTION_PRE_EP_ENTRIES] = NULL; | ||
3438 | |||
3439 | if (gadget_is_dualspeed(gadget)) { | ||
3440 | fsg_hs_function[i + FSG_HS_FUNCTION_PRE_EP_ENTRIES] = NULL; | ||
3441 | |||
3442 | /* Assume endpoint addresses are the same for both speeds */ | ||
3443 | fsg_hs_bulk_in_desc.bEndpointAddress = | ||
3444 | fsg_fs_bulk_in_desc.bEndpointAddress; | ||
3445 | fsg_hs_bulk_out_desc.bEndpointAddress = | ||
3446 | fsg_fs_bulk_out_desc.bEndpointAddress; | ||
3447 | fsg_hs_intr_in_desc.bEndpointAddress = | ||
3448 | fsg_fs_intr_in_desc.bEndpointAddress; | ||
3449 | } | ||
3450 | |||
3451 | if (gadget_is_superspeed(gadget)) { | ||
3452 | unsigned max_burst; | ||
3453 | |||
3454 | fsg_ss_function[i + FSG_SS_FUNCTION_PRE_EP_ENTRIES] = NULL; | ||
3455 | |||
3456 | /* Calculate bMaxBurst, we know packet size is 1024 */ | ||
3457 | max_burst = min_t(unsigned, mod_data.buflen / 1024, 15); | ||
3458 | |||
3459 | /* Assume endpoint addresses are the same for both speeds */ | ||
3460 | fsg_ss_bulk_in_desc.bEndpointAddress = | ||
3461 | fsg_fs_bulk_in_desc.bEndpointAddress; | ||
3462 | fsg_ss_bulk_in_comp_desc.bMaxBurst = max_burst; | ||
3463 | |||
3464 | fsg_ss_bulk_out_desc.bEndpointAddress = | ||
3465 | fsg_fs_bulk_out_desc.bEndpointAddress; | ||
3466 | fsg_ss_bulk_out_comp_desc.bMaxBurst = max_burst; | ||
3467 | } | ||
3468 | |||
3469 | if (gadget_is_otg(gadget)) | ||
3470 | fsg_otg_desc.bmAttributes |= USB_OTG_HNP; | ||
3471 | |||
3472 | rc = -ENOMEM; | ||
3473 | |||
3474 | /* Allocate the request and buffer for endpoint 0 */ | ||
3475 | fsg->ep0req = req = usb_ep_alloc_request(fsg->ep0, GFP_KERNEL); | ||
3476 | if (!req) | ||
3477 | goto out; | ||
3478 | req->buf = kmalloc(EP0_BUFSIZE, GFP_KERNEL); | ||
3479 | if (!req->buf) | ||
3480 | goto out; | ||
3481 | req->complete = ep0_complete; | ||
3482 | |||
3483 | /* Allocate the data buffers */ | ||
3484 | for (i = 0; i < fsg_num_buffers; ++i) { | ||
3485 | struct fsg_buffhd *bh = &fsg->buffhds[i]; | ||
3486 | |||
3487 | /* Allocate for the bulk-in endpoint. We assume that | ||
3488 | * the buffer will also work with the bulk-out (and | ||
3489 | * interrupt-in) endpoint. */ | ||
3490 | bh->buf = kmalloc(mod_data.buflen, GFP_KERNEL); | ||
3491 | if (!bh->buf) | ||
3492 | goto out; | ||
3493 | bh->next = bh + 1; | ||
3494 | } | ||
3495 | fsg->buffhds[fsg_num_buffers - 1].next = &fsg->buffhds[0]; | ||
3496 | |||
3497 | /* This should reflect the actual gadget power source */ | ||
3498 | usb_gadget_set_selfpowered(gadget); | ||
3499 | |||
3500 | snprintf(fsg_string_manufacturer, sizeof fsg_string_manufacturer, | ||
3501 | "%s %s with %s", | ||
3502 | init_utsname()->sysname, init_utsname()->release, | ||
3503 | gadget->name); | ||
3504 | |||
3505 | fsg->thread_task = kthread_create(fsg_main_thread, fsg, | ||
3506 | "file-storage-gadget"); | ||
3507 | if (IS_ERR(fsg->thread_task)) { | ||
3508 | rc = PTR_ERR(fsg->thread_task); | ||
3509 | goto out; | ||
3510 | } | ||
3511 | |||
3512 | INFO(fsg, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); | ||
3513 | INFO(fsg, "NOTE: This driver is deprecated. " | ||
3514 | "Consider using g_mass_storage instead.\n"); | ||
3515 | INFO(fsg, "Number of LUNs=%d\n", fsg->nluns); | ||
3516 | |||
3517 | pathbuf = kmalloc(PATH_MAX, GFP_KERNEL); | ||
3518 | for (i = 0; i < fsg->nluns; ++i) { | ||
3519 | curlun = &fsg->luns[i]; | ||
3520 | if (fsg_lun_is_open(curlun)) { | ||
3521 | p = NULL; | ||
3522 | if (pathbuf) { | ||
3523 | p = d_path(&curlun->filp->f_path, | ||
3524 | pathbuf, PATH_MAX); | ||
3525 | if (IS_ERR(p)) | ||
3526 | p = NULL; | ||
3527 | } | ||
3528 | LINFO(curlun, "ro=%d, nofua=%d, file: %s\n", | ||
3529 | curlun->ro, curlun->nofua, (p ? p : "(error)")); | ||
3530 | } | ||
3531 | } | ||
3532 | kfree(pathbuf); | ||
3533 | |||
3534 | DBG(fsg, "transport=%s (x%02x)\n", | ||
3535 | mod_data.transport_name, mod_data.transport_type); | ||
3536 | DBG(fsg, "protocol=%s (x%02x)\n", | ||
3537 | mod_data.protocol_name, mod_data.protocol_type); | ||
3538 | DBG(fsg, "VendorID=x%04x, ProductID=x%04x, Release=x%04x\n", | ||
3539 | mod_data.vendor, mod_data.product, mod_data.release); | ||
3540 | DBG(fsg, "removable=%d, stall=%d, cdrom=%d, buflen=%u\n", | ||
3541 | mod_data.removable, mod_data.can_stall, | ||
3542 | mod_data.cdrom, mod_data.buflen); | ||
3543 | DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task)); | ||
3544 | |||
3545 | set_bit(REGISTERED, &fsg->atomic_bitflags); | ||
3546 | |||
3547 | /* Tell the thread to start working */ | ||
3548 | wake_up_process(fsg->thread_task); | ||
3549 | return 0; | ||
3550 | |||
3551 | autoconf_fail: | ||
3552 | ERROR(fsg, "unable to autoconfigure all endpoints\n"); | ||
3553 | rc = -ENOTSUPP; | ||
3554 | |||
3555 | out: | ||
3556 | fsg->state = FSG_STATE_TERMINATED; // The thread is dead | ||
3557 | fsg_unbind(gadget); | ||
3558 | complete(&fsg->thread_notifier); | ||
3559 | return rc; | ||
3560 | } | ||
3561 | |||
3562 | |||
3563 | /*-------------------------------------------------------------------------*/ | ||
3564 | |||
3565 | static void fsg_suspend(struct usb_gadget *gadget) | ||
3566 | { | ||
3567 | struct fsg_dev *fsg = get_gadget_data(gadget); | ||
3568 | |||
3569 | DBG(fsg, "suspend\n"); | ||
3570 | set_bit(SUSPENDED, &fsg->atomic_bitflags); | ||
3571 | } | ||
3572 | |||
3573 | static void fsg_resume(struct usb_gadget *gadget) | ||
3574 | { | ||
3575 | struct fsg_dev *fsg = get_gadget_data(gadget); | ||
3576 | |||
3577 | DBG(fsg, "resume\n"); | ||
3578 | clear_bit(SUSPENDED, &fsg->atomic_bitflags); | ||
3579 | } | ||
3580 | |||
3581 | |||
3582 | /*-------------------------------------------------------------------------*/ | ||
3583 | |||
3584 | static __refdata struct usb_gadget_driver fsg_driver = { | ||
3585 | .max_speed = USB_SPEED_SUPER, | ||
3586 | .function = (char *) fsg_string_product, | ||
3587 | .bind = fsg_bind, | ||
3588 | .unbind = fsg_unbind, | ||
3589 | .disconnect = fsg_disconnect, | ||
3590 | .setup = fsg_setup, | ||
3591 | .suspend = fsg_suspend, | ||
3592 | .resume = fsg_resume, | ||
3593 | |||
3594 | .driver = { | ||
3595 | .name = DRIVER_NAME, | ||
3596 | .owner = THIS_MODULE, | ||
3597 | // .release = ... | ||
3598 | // .suspend = ... | ||
3599 | // .resume = ... | ||
3600 | }, | ||
3601 | }; | ||
3602 | |||
3603 | |||
3604 | static int __init fsg_alloc(void) | ||
3605 | { | ||
3606 | struct fsg_dev *fsg; | ||
3607 | |||
3608 | fsg = kzalloc(sizeof *fsg + | ||
3609 | fsg_num_buffers * sizeof *(fsg->buffhds), GFP_KERNEL); | ||
3610 | |||
3611 | if (!fsg) | ||
3612 | return -ENOMEM; | ||
3613 | spin_lock_init(&fsg->lock); | ||
3614 | init_rwsem(&fsg->filesem); | ||
3615 | kref_init(&fsg->ref); | ||
3616 | init_completion(&fsg->thread_notifier); | ||
3617 | |||
3618 | the_fsg = fsg; | ||
3619 | return 0; | ||
3620 | } | ||
3621 | |||
3622 | |||
3623 | static int __init fsg_init(void) | ||
3624 | { | ||
3625 | int rc; | ||
3626 | struct fsg_dev *fsg; | ||
3627 | |||
3628 | rc = fsg_num_buffers_validate(); | ||
3629 | if (rc != 0) | ||
3630 | return rc; | ||
3631 | |||
3632 | if ((rc = fsg_alloc()) != 0) | ||
3633 | return rc; | ||
3634 | fsg = the_fsg; | ||
3635 | rc = usb_gadget_probe_driver(&fsg_driver); | ||
3636 | if (rc != 0) | ||
3637 | kref_put(&fsg->ref, fsg_release); | ||
3638 | return rc; | ||
3639 | } | ||
3640 | module_init(fsg_init); | ||
3641 | |||
3642 | |||
3643 | static void __exit fsg_cleanup(void) | ||
3644 | { | ||
3645 | struct fsg_dev *fsg = the_fsg; | ||
3646 | |||
3647 | /* Unregister the driver iff the thread hasn't already done so */ | ||
3648 | if (test_and_clear_bit(REGISTERED, &fsg->atomic_bitflags)) | ||
3649 | usb_gadget_unregister_driver(&fsg_driver); | ||
3650 | |||
3651 | /* Wait for the thread to finish up */ | ||
3652 | wait_for_completion(&fsg->thread_notifier); | ||
3653 | |||
3654 | kref_put(&fsg->ref, fsg_release); | ||
3655 | } | ||
3656 | module_exit(fsg_cleanup); | ||
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index 6ae70cba0c4a..c19f7f13790b 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
@@ -2126,7 +2126,7 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count, | |||
2126 | 2126 | ||
2127 | tmp_reg = fsl_readl(&dr_regs->usbintr); | 2127 | tmp_reg = fsl_readl(&dr_regs->usbintr); |
2128 | t = scnprintf(next, size, | 2128 | t = scnprintf(next, size, |
2129 | "USB Intrrupt Enable Reg:\n" | 2129 | "USB Interrupt Enable Reg:\n" |
2130 | "Sleep Enable: %d SOF Received Enable: %d " | 2130 | "Sleep Enable: %d SOF Received Enable: %d " |
2131 | "Reset Enable: %d\n" | 2131 | "Reset Enable: %d\n" |
2132 | "System Error Enable: %d " | 2132 | "System Error Enable: %d " |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 76494cabf4e4..8ac840f25ba9 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -76,7 +76,6 @@ MODULE_LICENSE ("GPL"); | |||
76 | /*----------------------------------------------------------------------*/ | 76 | /*----------------------------------------------------------------------*/ |
77 | 77 | ||
78 | #define GADGETFS_MAGIC 0xaee71ee7 | 78 | #define GADGETFS_MAGIC 0xaee71ee7 |
79 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | ||
80 | 79 | ||
81 | /* /dev/gadget/$CHIP represents ep0 and the whole device */ | 80 | /* /dev/gadget/$CHIP represents ep0 and the whole device */ |
82 | enum ep0_state { | 81 | enum ep0_state { |
@@ -918,7 +917,6 @@ static void clean_req (struct usb_ep *ep, struct usb_request *req) | |||
918 | if (req->buf != dev->rbuf) { | 917 | if (req->buf != dev->rbuf) { |
919 | kfree(req->buf); | 918 | kfree(req->buf); |
920 | req->buf = dev->rbuf; | 919 | req->buf = dev->rbuf; |
921 | req->dma = DMA_ADDR_INVALID; | ||
922 | } | 920 | } |
923 | req->complete = epio_complete; | 921 | req->complete = epio_complete; |
924 | dev->setup_out_ready = 0; | 922 | dev->setup_out_ready = 0; |
@@ -1408,7 +1406,6 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) | |||
1408 | dev->setup_abort = 1; | 1406 | dev->setup_abort = 1; |
1409 | 1407 | ||
1410 | req->buf = dev->rbuf; | 1408 | req->buf = dev->rbuf; |
1411 | req->dma = DMA_ADDR_INVALID; | ||
1412 | req->context = NULL; | 1409 | req->context = NULL; |
1413 | value = -EOPNOTSUPP; | 1410 | value = -EOPNOTSUPP; |
1414 | switch (ctrl->bRequest) { | 1411 | switch (ctrl->bRequest) { |
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c index 21a9861dabf0..d1cf1f4db16a 100644 --- a/drivers/usb/gadget/lpc32xx_udc.c +++ b/drivers/usb/gadget/lpc32xx_udc.c | |||
@@ -2399,7 +2399,7 @@ static void udc_handle_ep0_setup(struct lpc32xx_udc *udc) | |||
2399 | 2399 | ||
2400 | if (i < 0) { | 2400 | if (i < 0) { |
2401 | /* setup processing failed, force stall */ | 2401 | /* setup processing failed, force stall */ |
2402 | dev_err(udc->dev, | 2402 | dev_dbg(udc->dev, |
2403 | "req %02x.%02x protocol STALL; stat %d\n", | 2403 | "req %02x.%02x protocol STALL; stat %d\n", |
2404 | reqtype, req, i); | 2404 | reqtype, req, i); |
2405 | udc->ep0state = WAIT_FOR_SETUP; | 2405 | udc->ep0state = WAIT_FOR_SETUP; |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index ac335af154ba..708c0b55dcc8 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -9,7 +9,7 @@ | |||
9 | * CODE STATUS HIGHLIGHTS | 9 | * CODE STATUS HIGHLIGHTS |
10 | * | 10 | * |
11 | * This driver should work well with most "gadget" drivers, including | 11 | * This driver should work well with most "gadget" drivers, including |
12 | * the File Storage, Serial, and Ethernet/RNDIS gadget drivers | 12 | * the Mass Storage, Serial, and Ethernet/RNDIS gadget drivers |
13 | * as well as Gadget Zero and Gadgetfs. | 13 | * as well as Gadget Zero and Gadgetfs. |
14 | * | 14 | * |
15 | * DMA is enabled by default. Drivers using transfer queues might use | 15 | * DMA is enabled by default. Drivers using transfer queues might use |
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index e156e3f26727..35bcc83d1e04 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -983,8 +983,10 @@ static int __init printer_func_bind(struct usb_configuration *c, | |||
983 | { | 983 | { |
984 | struct printer_dev *dev = container_of(f, struct printer_dev, function); | 984 | struct printer_dev *dev = container_of(f, struct printer_dev, function); |
985 | struct usb_composite_dev *cdev = c->cdev; | 985 | struct usb_composite_dev *cdev = c->cdev; |
986 | struct usb_ep *in_ep, *out_ep; | 986 | struct usb_ep *in_ep; |
987 | struct usb_ep *out_ep = NULL; | ||
987 | int id; | 988 | int id; |
989 | int ret; | ||
988 | 990 | ||
989 | id = usb_interface_id(c, f); | 991 | id = usb_interface_id(c, f); |
990 | if (id < 0) | 992 | if (id < 0) |
@@ -1010,6 +1012,11 @@ autoconf_fail: | |||
1010 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; | 1012 | hs_ep_in_desc.bEndpointAddress = fs_ep_in_desc.bEndpointAddress; |
1011 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; | 1013 | hs_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; |
1012 | 1014 | ||
1015 | ret = usb_assign_descriptors(f, fs_printer_function, | ||
1016 | hs_printer_function, NULL); | ||
1017 | if (ret) | ||
1018 | return ret; | ||
1019 | |||
1013 | dev->in_ep = in_ep; | 1020 | dev->in_ep = in_ep; |
1014 | dev->out_ep = out_ep; | 1021 | dev->out_ep = out_ep; |
1015 | return 0; | 1022 | return 0; |
@@ -1018,6 +1025,7 @@ autoconf_fail: | |||
1018 | static void printer_func_unbind(struct usb_configuration *c, | 1025 | static void printer_func_unbind(struct usb_configuration *c, |
1019 | struct usb_function *f) | 1026 | struct usb_function *f) |
1020 | { | 1027 | { |
1028 | usb_free_all_descriptors(f); | ||
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | static int printer_func_set_alt(struct usb_function *f, | 1031 | static int printer_func_set_alt(struct usb_function *f, |
@@ -1110,8 +1118,6 @@ static int __init printer_bind_config(struct usb_configuration *c) | |||
1110 | dev = &usb_printer_gadget; | 1118 | dev = &usb_printer_gadget; |
1111 | 1119 | ||
1112 | dev->function.name = shortname; | 1120 | dev->function.name = shortname; |
1113 | dev->function.descriptors = fs_printer_function; | ||
1114 | dev->function.hs_descriptors = hs_printer_function; | ||
1115 | dev->function.bind = printer_func_bind; | 1121 | dev->function.bind = printer_func_bind; |
1116 | dev->function.setup = printer_func_setup; | 1122 | dev->function.setup = printer_func_setup; |
1117 | dev->function.unbind = printer_func_unbind; | 1123 | dev->function.unbind = printer_func_unbind; |
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index a1d268c6f2cc..79d81a4b2344 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h | |||
@@ -418,7 +418,7 @@ struct udc_stats { | |||
418 | * @irq: udc irq | 418 | * @irq: udc irq |
419 | * @clk: udc clock | 419 | * @clk: udc clock |
420 | * @usb_gadget: udc gadget structure | 420 | * @usb_gadget: udc gadget structure |
421 | * @driver: bound gadget (zero, g_ether, g_file_storage, ...) | 421 | * @driver: bound gadget (zero, g_ether, g_mass_storage, ...) |
422 | * @dev: device | 422 | * @dev: device |
423 | * @mach: machine info, used to activate specific GPIO | 423 | * @mach: machine info, used to activate specific GPIO |
424 | * @transceiver: external transceiver to handle vbus sense and D+ pullup | 424 | * @transceiver: external transceiver to handle vbus sense and D+ pullup |
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 8d9bcd8207c8..0e3ae43454a2 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -11,30 +11,10 @@ | |||
11 | * (at your option) any later version. | 11 | * (at your option) any later version. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | |||
15 | /* | 14 | /* |
16 | * This file requires the following identifiers used in USB strings to | 15 | * This file requires the following identifiers used in USB strings to |
17 | * be defined (each of type pointer to char): | 16 | * be defined (each of type pointer to char): |
18 | * - fsg_string_manufacturer -- name of the manufacturer | ||
19 | * - fsg_string_product -- name of the product | ||
20 | * - fsg_string_config -- name of the configuration | ||
21 | * - fsg_string_interface -- name of the interface | 17 | * - fsg_string_interface -- name of the interface |
22 | * The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS | ||
23 | * macro is defined prior to including this file. | ||
24 | */ | ||
25 | |||
26 | /* | ||
27 | * When FSG_NO_INTR_EP is defined fsg_fs_intr_in_desc and | ||
28 | * fsg_hs_intr_in_desc objects as well as | ||
29 | * FSG_FS_FUNCTION_PRE_EP_ENTRIES and FSG_HS_FUNCTION_PRE_EP_ENTRIES | ||
30 | * macros are not defined. | ||
31 | * | ||
32 | * When FSG_NO_DEVICE_STRINGS is defined FSG_STRING_MANUFACTURER, | ||
33 | * FSG_STRING_PRODUCT, FSG_STRING_SERIAL and FSG_STRING_CONFIG are not | ||
34 | * defined (as well as corresponding entries in string tables are | ||
35 | * missing) and FSG_STRING_INTERFACE has value of zero. | ||
36 | * | ||
37 | * When FSG_NO_OTG is defined fsg_otg_desc won't be defined. | ||
38 | */ | 18 | */ |
39 | 19 | ||
40 | /* | 20 | /* |
@@ -78,34 +58,6 @@ | |||
78 | #define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) | 58 | #define LWARN(lun, fmt, args...) dev_warn(&(lun)->dev, fmt, ## args) |
79 | #define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) | 59 | #define LINFO(lun, fmt, args...) dev_info(&(lun)->dev, fmt, ## args) |
80 | 60 | ||
81 | /* | ||
82 | * Keep those macros in sync with those in | ||
83 | * include/linux/usb/composite.h or else GCC will complain. If they | ||
84 | * are identical (the same names of arguments, white spaces in the | ||
85 | * same places) GCC will allow redefinition otherwise (even if some | ||
86 | * white space is removed or added) warning will be issued. | ||
87 | * | ||
88 | * Those macros are needed here because File Storage Gadget does not | ||
89 | * include the composite.h header. For composite gadgets those macros | ||
90 | * are redundant since composite.h is included any way. | ||
91 | * | ||
92 | * One could check whether those macros are already defined (which | ||
93 | * would indicate composite.h had been included) or not (which would | ||
94 | * indicate we were in FSG) but this is not done because a warning is | ||
95 | * desired if definitions here differ from the ones in composite.h. | ||
96 | * | ||
97 | * We want the definitions to match and be the same in File Storage | ||
98 | * Gadget as well as Mass Storage Function (and so composite gadgets | ||
99 | * using MSF). If someone changes them in composite.h it will produce | ||
100 | * a warning in this file when building MSF. | ||
101 | */ | ||
102 | #define DBG(d, fmt, args...) dev_dbg(&(d)->gadget->dev , fmt , ## args) | ||
103 | #define VDBG(d, fmt, args...) dev_vdbg(&(d)->gadget->dev , fmt , ## args) | ||
104 | #define ERROR(d, fmt, args...) dev_err(&(d)->gadget->dev , fmt , ## args) | ||
105 | #define WARNING(d, fmt, args...) dev_warn(&(d)->gadget->dev , fmt , ## args) | ||
106 | #define INFO(d, fmt, args...) dev_info(&(d)->gadget->dev , fmt , ## args) | ||
107 | |||
108 | |||
109 | 61 | ||
110 | #ifdef DUMP_MSGS | 62 | #ifdef DUMP_MSGS |
111 | 63 | ||
@@ -203,9 +155,12 @@ struct fsg_lun { | |||
203 | struct device dev; | 155 | struct device dev; |
204 | }; | 156 | }; |
205 | 157 | ||
206 | #define fsg_lun_is_open(curlun) ((curlun)->filp != NULL) | 158 | static inline bool fsg_lun_is_open(struct fsg_lun *curlun) |
159 | { | ||
160 | return curlun->filp != NULL; | ||
161 | } | ||
207 | 162 | ||
208 | static struct fsg_lun *fsg_lun_from_dev(struct device *dev) | 163 | static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev) |
209 | { | 164 | { |
210 | return container_of(dev, struct fsg_lun, dev); | 165 | return container_of(dev, struct fsg_lun, dev); |
211 | } | 166 | } |
@@ -308,26 +263,10 @@ static inline u32 get_unaligned_be24(u8 *buf) | |||
308 | 263 | ||
309 | 264 | ||
310 | enum { | 265 | enum { |
311 | #ifndef FSG_NO_DEVICE_STRINGS | ||
312 | FSG_STRING_MANUFACTURER = 1, | ||
313 | FSG_STRING_PRODUCT, | ||
314 | FSG_STRING_SERIAL, | ||
315 | FSG_STRING_CONFIG, | ||
316 | #endif | ||
317 | FSG_STRING_INTERFACE | 266 | FSG_STRING_INTERFACE |
318 | }; | 267 | }; |
319 | 268 | ||
320 | 269 | ||
321 | #ifndef FSG_NO_OTG | ||
322 | static struct usb_otg_descriptor | ||
323 | fsg_otg_desc = { | ||
324 | .bLength = sizeof fsg_otg_desc, | ||
325 | .bDescriptorType = USB_DT_OTG, | ||
326 | |||
327 | .bmAttributes = USB_OTG_SRP, | ||
328 | }; | ||
329 | #endif | ||
330 | |||
331 | /* There is only one interface. */ | 270 | /* There is only one interface. */ |
332 | 271 | ||
333 | static struct usb_interface_descriptor | 272 | static struct usb_interface_descriptor |
@@ -367,37 +306,10 @@ fsg_fs_bulk_out_desc = { | |||
367 | /* wMaxPacketSize set by autoconfiguration */ | 306 | /* wMaxPacketSize set by autoconfiguration */ |
368 | }; | 307 | }; |
369 | 308 | ||
370 | #ifndef FSG_NO_INTR_EP | ||
371 | |||
372 | static struct usb_endpoint_descriptor | ||
373 | fsg_fs_intr_in_desc = { | ||
374 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
375 | .bDescriptorType = USB_DT_ENDPOINT, | ||
376 | |||
377 | .bEndpointAddress = USB_DIR_IN, | ||
378 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
379 | .wMaxPacketSize = cpu_to_le16(2), | ||
380 | .bInterval = 32, /* frames -> 32 ms */ | ||
381 | }; | ||
382 | |||
383 | #ifndef FSG_NO_OTG | ||
384 | # define FSG_FS_FUNCTION_PRE_EP_ENTRIES 2 | ||
385 | #else | ||
386 | # define FSG_FS_FUNCTION_PRE_EP_ENTRIES 1 | ||
387 | #endif | ||
388 | |||
389 | #endif | ||
390 | |||
391 | static struct usb_descriptor_header *fsg_fs_function[] = { | 309 | static struct usb_descriptor_header *fsg_fs_function[] = { |
392 | #ifndef FSG_NO_OTG | ||
393 | (struct usb_descriptor_header *) &fsg_otg_desc, | ||
394 | #endif | ||
395 | (struct usb_descriptor_header *) &fsg_intf_desc, | 310 | (struct usb_descriptor_header *) &fsg_intf_desc, |
396 | (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc, | 311 | (struct usb_descriptor_header *) &fsg_fs_bulk_in_desc, |
397 | (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc, | 312 | (struct usb_descriptor_header *) &fsg_fs_bulk_out_desc, |
398 | #ifndef FSG_NO_INTR_EP | ||
399 | (struct usb_descriptor_header *) &fsg_fs_intr_in_desc, | ||
400 | #endif | ||
401 | NULL, | 313 | NULL, |
402 | }; | 314 | }; |
403 | 315 | ||
@@ -431,37 +343,11 @@ fsg_hs_bulk_out_desc = { | |||
431 | .bInterval = 1, /* NAK every 1 uframe */ | 343 | .bInterval = 1, /* NAK every 1 uframe */ |
432 | }; | 344 | }; |
433 | 345 | ||
434 | #ifndef FSG_NO_INTR_EP | ||
435 | |||
436 | static struct usb_endpoint_descriptor | ||
437 | fsg_hs_intr_in_desc = { | ||
438 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
439 | .bDescriptorType = USB_DT_ENDPOINT, | ||
440 | |||
441 | /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */ | ||
442 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
443 | .wMaxPacketSize = cpu_to_le16(2), | ||
444 | .bInterval = 9, /* 2**(9-1) = 256 uframes -> 32 ms */ | ||
445 | }; | ||
446 | |||
447 | #ifndef FSG_NO_OTG | ||
448 | # define FSG_HS_FUNCTION_PRE_EP_ENTRIES 2 | ||
449 | #else | ||
450 | # define FSG_HS_FUNCTION_PRE_EP_ENTRIES 1 | ||
451 | #endif | ||
452 | |||
453 | #endif | ||
454 | 346 | ||
455 | static struct usb_descriptor_header *fsg_hs_function[] = { | 347 | static struct usb_descriptor_header *fsg_hs_function[] = { |
456 | #ifndef FSG_NO_OTG | ||
457 | (struct usb_descriptor_header *) &fsg_otg_desc, | ||
458 | #endif | ||
459 | (struct usb_descriptor_header *) &fsg_intf_desc, | 348 | (struct usb_descriptor_header *) &fsg_intf_desc, |
460 | (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc, | 349 | (struct usb_descriptor_header *) &fsg_hs_bulk_in_desc, |
461 | (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc, | 350 | (struct usb_descriptor_header *) &fsg_hs_bulk_out_desc, |
462 | #ifndef FSG_NO_INTR_EP | ||
463 | (struct usb_descriptor_header *) &fsg_hs_intr_in_desc, | ||
464 | #endif | ||
465 | NULL, | 351 | NULL, |
466 | }; | 352 | }; |
467 | 353 | ||
@@ -499,34 +385,6 @@ static struct usb_ss_ep_comp_descriptor fsg_ss_bulk_out_comp_desc = { | |||
499 | /*.bMaxBurst = DYNAMIC, */ | 385 | /*.bMaxBurst = DYNAMIC, */ |
500 | }; | 386 | }; |
501 | 387 | ||
502 | #ifndef FSG_NO_INTR_EP | ||
503 | |||
504 | static struct usb_endpoint_descriptor | ||
505 | fsg_ss_intr_in_desc = { | ||
506 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
507 | .bDescriptorType = USB_DT_ENDPOINT, | ||
508 | |||
509 | /* bEndpointAddress copied from fs_intr_in_desc during fsg_bind() */ | ||
510 | .bmAttributes = USB_ENDPOINT_XFER_INT, | ||
511 | .wMaxPacketSize = cpu_to_le16(2), | ||
512 | .bInterval = 9, /* 2**(9-1) = 256 uframes -> 32 ms */ | ||
513 | }; | ||
514 | |||
515 | static struct usb_ss_ep_comp_descriptor fsg_ss_intr_in_comp_desc = { | ||
516 | .bLength = sizeof(fsg_ss_bulk_in_comp_desc), | ||
517 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, | ||
518 | |||
519 | .wBytesPerInterval = cpu_to_le16(2), | ||
520 | }; | ||
521 | |||
522 | #ifndef FSG_NO_OTG | ||
523 | # define FSG_SS_FUNCTION_PRE_EP_ENTRIES 2 | ||
524 | #else | ||
525 | # define FSG_SS_FUNCTION_PRE_EP_ENTRIES 1 | ||
526 | #endif | ||
527 | |||
528 | #endif | ||
529 | |||
530 | static __maybe_unused struct usb_ext_cap_descriptor fsg_ext_cap_desc = { | 388 | static __maybe_unused struct usb_ext_cap_descriptor fsg_ext_cap_desc = { |
531 | .bLength = USB_DT_USB_EXT_CAP_SIZE, | 389 | .bLength = USB_DT_USB_EXT_CAP_SIZE, |
532 | .bDescriptorType = USB_DT_DEVICE_CAPABILITY, | 390 | .bDescriptorType = USB_DT_DEVICE_CAPABILITY, |
@@ -563,18 +421,11 @@ static __maybe_unused struct usb_bos_descriptor fsg_bos_desc = { | |||
563 | }; | 421 | }; |
564 | 422 | ||
565 | static struct usb_descriptor_header *fsg_ss_function[] = { | 423 | static struct usb_descriptor_header *fsg_ss_function[] = { |
566 | #ifndef FSG_NO_OTG | ||
567 | (struct usb_descriptor_header *) &fsg_otg_desc, | ||
568 | #endif | ||
569 | (struct usb_descriptor_header *) &fsg_intf_desc, | 424 | (struct usb_descriptor_header *) &fsg_intf_desc, |
570 | (struct usb_descriptor_header *) &fsg_ss_bulk_in_desc, | 425 | (struct usb_descriptor_header *) &fsg_ss_bulk_in_desc, |
571 | (struct usb_descriptor_header *) &fsg_ss_bulk_in_comp_desc, | 426 | (struct usb_descriptor_header *) &fsg_ss_bulk_in_comp_desc, |
572 | (struct usb_descriptor_header *) &fsg_ss_bulk_out_desc, | 427 | (struct usb_descriptor_header *) &fsg_ss_bulk_out_desc, |
573 | (struct usb_descriptor_header *) &fsg_ss_bulk_out_comp_desc, | 428 | (struct usb_descriptor_header *) &fsg_ss_bulk_out_comp_desc, |
574 | #ifndef FSG_NO_INTR_EP | ||
575 | (struct usb_descriptor_header *) &fsg_ss_intr_in_desc, | ||
576 | (struct usb_descriptor_header *) &fsg_ss_intr_in_comp_desc, | ||
577 | #endif | ||
578 | NULL, | 429 | NULL, |
579 | }; | 430 | }; |
580 | 431 | ||
@@ -594,12 +445,6 @@ fsg_ep_desc(struct usb_gadget *g, struct usb_endpoint_descriptor *fs, | |||
594 | 445 | ||
595 | /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ | 446 | /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ |
596 | static struct usb_string fsg_strings[] = { | 447 | static struct usb_string fsg_strings[] = { |
597 | #ifndef FSG_NO_DEVICE_STRINGS | ||
598 | {FSG_STRING_MANUFACTURER, fsg_string_manufacturer}, | ||
599 | {FSG_STRING_PRODUCT, fsg_string_product}, | ||
600 | {FSG_STRING_SERIAL, ""}, | ||
601 | {FSG_STRING_CONFIG, fsg_string_config}, | ||
602 | #endif | ||
603 | {FSG_STRING_INTERFACE, fsg_string_interface}, | 448 | {FSG_STRING_INTERFACE, fsg_string_interface}, |
604 | {} | 449 | {} |
605 | }; | 450 | }; |
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 97e68b38cfdf..4f7f76f00c74 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c | |||
@@ -1384,7 +1384,7 @@ static struct se_node_acl *usbg_alloc_fabric_acl(struct se_portal_group *se_tpg) | |||
1384 | 1384 | ||
1385 | nacl = kzalloc(sizeof(struct usbg_nacl), GFP_KERNEL); | 1385 | nacl = kzalloc(sizeof(struct usbg_nacl), GFP_KERNEL); |
1386 | if (!nacl) { | 1386 | if (!nacl) { |
1387 | printk(KERN_ERR "Unable to alocate struct usbg_nacl\n"); | 1387 | printk(KERN_ERR "Unable to allocate struct usbg_nacl\n"); |
1388 | return NULL; | 1388 | return NULL; |
1389 | } | 1389 | } |
1390 | 1390 | ||
@@ -2139,6 +2139,7 @@ static struct usb_descriptor_header *uasp_fs_function_desc[] = { | |||
2139 | (struct usb_descriptor_header *) &uasp_status_pipe_desc, | 2139 | (struct usb_descriptor_header *) &uasp_status_pipe_desc, |
2140 | (struct usb_descriptor_header *) &uasp_fs_cmd_desc, | 2140 | (struct usb_descriptor_header *) &uasp_fs_cmd_desc, |
2141 | (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, | 2141 | (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, |
2142 | NULL, | ||
2142 | }; | 2143 | }; |
2143 | 2144 | ||
2144 | static struct usb_descriptor_header *uasp_hs_function_desc[] = { | 2145 | static struct usb_descriptor_header *uasp_hs_function_desc[] = { |
@@ -2239,6 +2240,7 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2239 | struct usb_gadget *gadget = c->cdev->gadget; | 2240 | struct usb_gadget *gadget = c->cdev->gadget; |
2240 | struct usb_ep *ep; | 2241 | struct usb_ep *ep; |
2241 | int iface; | 2242 | int iface; |
2243 | int ret; | ||
2242 | 2244 | ||
2243 | iface = usb_interface_id(c, f); | 2245 | iface = usb_interface_id(c, f); |
2244 | if (iface < 0) | 2246 | if (iface < 0) |
@@ -2289,6 +2291,11 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f) | |||
2289 | uasp_ss_status_desc.bEndpointAddress; | 2291 | uasp_ss_status_desc.bEndpointAddress; |
2290 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; | 2292 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; |
2291 | 2293 | ||
2294 | ret = usb_assign_descriptors(f, uasp_fs_function_desc, | ||
2295 | uasp_hs_function_desc, uasp_ss_function_desc); | ||
2296 | if (ret) | ||
2297 | goto ep_fail; | ||
2298 | |||
2292 | return 0; | 2299 | return 0; |
2293 | ep_fail: | 2300 | ep_fail: |
2294 | pr_err("Can't claim all required eps\n"); | 2301 | pr_err("Can't claim all required eps\n"); |
@@ -2304,6 +2311,7 @@ static void usbg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
2304 | { | 2311 | { |
2305 | struct f_uas *fu = to_f_uas(f); | 2312 | struct f_uas *fu = to_f_uas(f); |
2306 | 2313 | ||
2314 | usb_free_all_descriptors(f); | ||
2307 | kfree(fu); | 2315 | kfree(fu); |
2308 | } | 2316 | } |
2309 | 2317 | ||
@@ -2384,9 +2392,6 @@ static int usbg_cfg_bind(struct usb_configuration *c) | |||
2384 | if (!fu) | 2392 | if (!fu) |
2385 | return -ENOMEM; | 2393 | return -ENOMEM; |
2386 | fu->function.name = "Target Function"; | 2394 | fu->function.name = "Target Function"; |
2387 | fu->function.descriptors = uasp_fs_function_desc; | ||
2388 | fu->function.hs_descriptors = uasp_hs_function_desc; | ||
2389 | fu->function.ss_descriptors = uasp_ss_function_desc; | ||
2390 | fu->function.bind = usbg_bind; | 2395 | fu->function.bind = usbg_bind; |
2391 | fu->function.unbind = usbg_unbind; | 2396 | fu->function.unbind = usbg_unbind; |
2392 | fu->function.set_alt = usbg_set_alt; | 2397 | fu->function.set_alt = usbg_set_alt; |
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index f3cd9690b101..4d90a800063c 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
@@ -439,16 +439,6 @@ static DEVICE_ATTR(name, S_IRUSR, usb_udc_##param##_show, NULL) | |||
439 | static USB_UDC_SPEED_ATTR(current_speed, speed); | 439 | static USB_UDC_SPEED_ATTR(current_speed, speed); |
440 | static USB_UDC_SPEED_ATTR(maximum_speed, max_speed); | 440 | static USB_UDC_SPEED_ATTR(maximum_speed, max_speed); |
441 | 441 | ||
442 | /* TODO: Scheduled for removal in 3.8. */ | ||
443 | static ssize_t usb_udc_is_dualspeed_show(struct device *dev, | ||
444 | struct device_attribute *attr, char *buf) | ||
445 | { | ||
446 | struct usb_udc *udc = container_of(dev, struct usb_udc, dev); | ||
447 | return snprintf(buf, PAGE_SIZE, "%d\n", | ||
448 | gadget_is_dualspeed(udc->gadget)); | ||
449 | } | ||
450 | static DEVICE_ATTR(is_dualspeed, S_IRUSR, usb_udc_is_dualspeed_show, NULL); | ||
451 | |||
452 | #define USB_UDC_ATTR(name) \ | 442 | #define USB_UDC_ATTR(name) \ |
453 | ssize_t usb_udc_##name##_show(struct device *dev, \ | 443 | ssize_t usb_udc_##name##_show(struct device *dev, \ |
454 | struct device_attribute *attr, char *buf) \ | 444 | struct device_attribute *attr, char *buf) \ |
@@ -472,7 +462,6 @@ static struct attribute *usb_udc_attrs[] = { | |||
472 | &dev_attr_current_speed.attr, | 462 | &dev_attr_current_speed.attr, |
473 | &dev_attr_maximum_speed.attr, | 463 | &dev_attr_maximum_speed.attr, |
474 | 464 | ||
475 | &dev_attr_is_dualspeed.attr, | ||
476 | &dev_attr_is_otg.attr, | 465 | &dev_attr_is_otg.attr, |
477 | &dev_attr_is_a_peripheral.attr, | 466 | &dev_attr_is_a_peripheral.attr, |
478 | &dev_attr_b_hnp_enable.attr, | 467 | &dev_attr_b_hnp_enable.attr, |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 3f1431d37e1c..d6bb128ce21e 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -95,6 +95,11 @@ config USB_EHCI_TT_NEWSCHED | |||
95 | 95 | ||
96 | If unsure, say Y. | 96 | If unsure, say Y. |
97 | 97 | ||
98 | config USB_EHCI_PCI | ||
99 | tristate | ||
100 | depends on USB_EHCI_HCD && PCI | ||
101 | default y | ||
102 | |||
98 | config USB_EHCI_HCD_PMC_MSP | 103 | config USB_EHCI_HCD_PMC_MSP |
99 | tristate "EHCI support for on-chip PMC MSP71xx USB controller" | 104 | tristate "EHCI support for on-chip PMC MSP71xx USB controller" |
100 | depends on USB_EHCI_HCD && MSP_HAS_USB | 105 | depends on USB_EHCI_HCD && MSP_HAS_USB |
@@ -215,9 +220,13 @@ config USB_W90X900_EHCI | |||
215 | Enables support for the W90X900 USB controller | 220 | Enables support for the W90X900 USB controller |
216 | 221 | ||
217 | config USB_CNS3XXX_EHCI | 222 | config USB_CNS3XXX_EHCI |
218 | bool "Cavium CNS3XXX EHCI Module" | 223 | bool "Cavium CNS3XXX EHCI Module (DEPRECATED)" |
219 | depends on USB_EHCI_HCD && ARCH_CNS3XXX | 224 | depends on USB_EHCI_HCD && ARCH_CNS3XXX |
225 | select USB_EHCI_HCD_PLATFORM | ||
220 | ---help--- | 226 | ---help--- |
227 | This option is deprecated now and the driver was removed, use | ||
228 | USB_EHCI_HCD_PLATFORM instead. | ||
229 | |||
221 | Enable support for the CNS3XXX SOC's on-chip EHCI controller. | 230 | Enable support for the CNS3XXX SOC's on-chip EHCI controller. |
222 | It is needed for high-speed (480Mbit/sec) USB 2.0 device | 231 | It is needed for high-speed (480Mbit/sec) USB 2.0 device |
223 | support. | 232 | support. |
@@ -333,16 +342,6 @@ config USB_OHCI_ATH79 | |||
333 | Enables support for the built-in OHCI controller present on the | 342 | Enables support for the built-in OHCI controller present on the |
334 | Atheros AR71XX/AR7240 SoCs. | 343 | Atheros AR71XX/AR7240 SoCs. |
335 | 344 | ||
336 | config USB_OHCI_HCD_PPC_SOC | ||
337 | bool "OHCI support for on-chip PPC USB controller" | ||
338 | depends on USB_OHCI_HCD && (STB03xxx || PPC_MPC52xx) | ||
339 | default y | ||
340 | select USB_OHCI_BIG_ENDIAN_DESC | ||
341 | select USB_OHCI_BIG_ENDIAN_MMIO | ||
342 | ---help--- | ||
343 | Enables support for the USB controller on the MPC52xx or | ||
344 | STB03xxx processor chip. If unsure, say Y. | ||
345 | |||
346 | config USB_OHCI_HCD_PPC_OF_BE | 345 | config USB_OHCI_HCD_PPC_OF_BE |
347 | bool "OHCI support for OF platform bus (big endian)" | 346 | bool "OHCI support for OF platform bus (big endian)" |
348 | depends on USB_OHCI_HCD && PPC_OF | 347 | depends on USB_OHCI_HCD && PPC_OF |
@@ -393,9 +392,13 @@ config USB_OHCI_HCD_SSB | |||
393 | If unsure, say N. | 392 | If unsure, say N. |
394 | 393 | ||
395 | config USB_OHCI_SH | 394 | config USB_OHCI_SH |
396 | bool "OHCI support for SuperH USB controller" | 395 | bool "OHCI support for SuperH USB controller (DEPRECATED)" |
397 | depends on USB_OHCI_HCD && SUPERH | 396 | depends on USB_OHCI_HCD && SUPERH |
397 | select USB_OHCI_HCD_PLATFORM | ||
398 | ---help--- | 398 | ---help--- |
399 | This option is deprecated now and the driver was removed, use | ||
400 | USB_OHCI_HCD_PLATFORM instead. | ||
401 | |||
399 | Enables support for the on-chip OHCI controller on the SuperH. | 402 | Enables support for the on-chip OHCI controller on the SuperH. |
400 | If you use the PCI OHCI controller, this option is not necessary. | 403 | If you use the PCI OHCI controller, this option is not necessary. |
401 | 404 | ||
@@ -406,9 +409,13 @@ config USB_OHCI_EXYNOS | |||
406 | Enable support for the Samsung Exynos SOC's on-chip OHCI controller. | 409 | Enable support for the Samsung Exynos SOC's on-chip OHCI controller. |
407 | 410 | ||
408 | config USB_CNS3XXX_OHCI | 411 | config USB_CNS3XXX_OHCI |
409 | bool "Cavium CNS3XXX OHCI Module" | 412 | bool "Cavium CNS3XXX OHCI Module (DEPRECATED)" |
410 | depends on USB_OHCI_HCD && ARCH_CNS3XXX | 413 | depends on USB_OHCI_HCD && ARCH_CNS3XXX |
414 | select USB_OHCI_HCD_PLATFORM | ||
411 | ---help--- | 415 | ---help--- |
416 | This option is deprecated now and the driver was removed, use | ||
417 | USB_OHCI_HCD_PLATFORM instead. | ||
418 | |||
412 | Enable support for the CNS3XXX SOC's on-chip OHCI controller. | 419 | Enable support for the CNS3XXX SOC's on-chip OHCI controller. |
413 | It is needed for low-speed USB 1.0 device support. | 420 | It is needed for low-speed USB 1.0 device support. |
414 | 421 | ||
@@ -423,7 +430,7 @@ config USB_OHCI_HCD_PLATFORM | |||
423 | If unsure, say N. | 430 | If unsure, say N. |
424 | 431 | ||
425 | config USB_EHCI_HCD_PLATFORM | 432 | config USB_EHCI_HCD_PLATFORM |
426 | bool "Generic EHCI driver for a platform device" | 433 | tristate "Generic EHCI driver for a platform device" |
427 | depends on USB_EHCI_HCD | 434 | depends on USB_EHCI_HCD |
428 | default n | 435 | default n |
429 | ---help--- | 436 | ---help--- |
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 9e0a89ced15c..1eb4c3006e9e 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -24,6 +24,9 @@ obj-$(CONFIG_USB_WHCI_HCD) += whci/ | |||
24 | obj-$(CONFIG_PCI) += pci-quirks.o | 24 | obj-$(CONFIG_PCI) += pci-quirks.o |
25 | 25 | ||
26 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o | 26 | obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o |
27 | obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o | ||
28 | obj-$(CONFIG_USB_EHCI_HCD_PLATFORM) += ehci-platform.o | ||
29 | |||
27 | obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o | 30 | obj-$(CONFIG_USB_OXU210HP_HCD) += oxu210hp-hcd.o |
28 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o | 31 | obj-$(CONFIG_USB_ISP116X_HCD) += isp116x-hcd.o |
29 | obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o | 32 | obj-$(CONFIG_USB_ISP1362_HCD) += isp1362-hcd.o |
@@ -40,6 +43,5 @@ obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o | |||
40 | obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o | 43 | obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o |
41 | obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o | 44 | obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o |
42 | obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o | 45 | obj-$(CONFIG_USB_OCTEON2_COMMON) += octeon2-common.o |
43 | obj-$(CONFIG_MIPS_ALCHEMY) += alchemy-common.o | ||
44 | obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o | 46 | obj-$(CONFIG_USB_HCD_BCMA) += bcma-hcd.o |
45 | obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o | 47 | obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o |
diff --git a/drivers/usb/host/alchemy-common.c b/drivers/usb/host/alchemy-common.c deleted file mode 100644 index 936af8359fb2..000000000000 --- a/drivers/usb/host/alchemy-common.c +++ /dev/null | |||
@@ -1,614 +0,0 @@ | |||
1 | /* | ||
2 | * USB block power/access management abstraction. | ||
3 | * | ||
4 | * Au1000+: The OHCI block control register is at the far end of the OHCI memory | ||
5 | * area. Au1550 has OHCI on different base address. No need to handle | ||
6 | * UDC here. | ||
7 | * Au1200: one register to control access and clocks to O/EHCI, UDC and OTG | ||
8 | * as well as the PHY for EHCI and UDC. | ||
9 | * | ||
10 | */ | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/spinlock.h> | ||
16 | #include <linux/syscore_ops.h> | ||
17 | #include <asm/mach-au1x00/au1000.h> | ||
18 | |||
19 | /* control register offsets */ | ||
20 | #define AU1000_OHCICFG 0x7fffc | ||
21 | #define AU1550_OHCICFG 0x07ffc | ||
22 | #define AU1200_USBCFG 0x04 | ||
23 | |||
24 | /* Au1000 USB block config bits */ | ||
25 | #define USBHEN_RD (1 << 4) /* OHCI reset-done indicator */ | ||
26 | #define USBHEN_CE (1 << 3) /* OHCI block clock enable */ | ||
27 | #define USBHEN_E (1 << 2) /* OHCI block enable */ | ||
28 | #define USBHEN_C (1 << 1) /* OHCI block coherency bit */ | ||
29 | #define USBHEN_BE (1 << 0) /* OHCI Big-Endian */ | ||
30 | |||
31 | /* Au1200 USB config bits */ | ||
32 | #define USBCFG_PFEN (1 << 31) /* prefetch enable (undoc) */ | ||
33 | #define USBCFG_RDCOMB (1 << 30) /* read combining (undoc) */ | ||
34 | #define USBCFG_UNKNOWN (5 << 20) /* unknown, leave this way */ | ||
35 | #define USBCFG_SSD (1 << 23) /* serial short detect en */ | ||
36 | #define USBCFG_PPE (1 << 19) /* HS PHY PLL */ | ||
37 | #define USBCFG_UCE (1 << 18) /* UDC clock enable */ | ||
38 | #define USBCFG_ECE (1 << 17) /* EHCI clock enable */ | ||
39 | #define USBCFG_OCE (1 << 16) /* OHCI clock enable */ | ||
40 | #define USBCFG_FLA(x) (((x) & 0x3f) << 8) | ||
41 | #define USBCFG_UCAM (1 << 7) /* coherent access (undoc) */ | ||
42 | #define USBCFG_GME (1 << 6) /* OTG mem access */ | ||
43 | #define USBCFG_DBE (1 << 5) /* UDC busmaster enable */ | ||
44 | #define USBCFG_DME (1 << 4) /* UDC mem enable */ | ||
45 | #define USBCFG_EBE (1 << 3) /* EHCI busmaster enable */ | ||
46 | #define USBCFG_EME (1 << 2) /* EHCI mem enable */ | ||
47 | #define USBCFG_OBE (1 << 1) /* OHCI busmaster enable */ | ||
48 | #define USBCFG_OME (1 << 0) /* OHCI mem enable */ | ||
49 | #define USBCFG_INIT_AU1200 (USBCFG_PFEN | USBCFG_RDCOMB | USBCFG_UNKNOWN |\ | ||
50 | USBCFG_SSD | USBCFG_FLA(0x20) | USBCFG_UCAM | \ | ||
51 | USBCFG_GME | USBCFG_DBE | USBCFG_DME | \ | ||
52 | USBCFG_EBE | USBCFG_EME | USBCFG_OBE | \ | ||
53 | USBCFG_OME) | ||
54 | |||
55 | /* Au1300 USB config registers */ | ||
56 | #define USB_DWC_CTRL1 0x00 | ||
57 | #define USB_DWC_CTRL2 0x04 | ||
58 | #define USB_VBUS_TIMER 0x10 | ||
59 | #define USB_SBUS_CTRL 0x14 | ||
60 | #define USB_MSR_ERR 0x18 | ||
61 | #define USB_DWC_CTRL3 0x1C | ||
62 | #define USB_DWC_CTRL4 0x20 | ||
63 | #define USB_OTG_STATUS 0x28 | ||
64 | #define USB_DWC_CTRL5 0x2C | ||
65 | #define USB_DWC_CTRL6 0x30 | ||
66 | #define USB_DWC_CTRL7 0x34 | ||
67 | #define USB_PHY_STATUS 0xC0 | ||
68 | #define USB_INT_STATUS 0xC4 | ||
69 | #define USB_INT_ENABLE 0xC8 | ||
70 | |||
71 | #define USB_DWC_CTRL1_OTGD 0x04 /* set to DISable OTG */ | ||
72 | #define USB_DWC_CTRL1_HSTRS 0x02 /* set to ENable EHCI */ | ||
73 | #define USB_DWC_CTRL1_DCRS 0x01 /* set to ENable UDC */ | ||
74 | |||
75 | #define USB_DWC_CTRL2_PHY1RS 0x04 /* set to enable PHY1 */ | ||
76 | #define USB_DWC_CTRL2_PHY0RS 0x02 /* set to enable PHY0 */ | ||
77 | #define USB_DWC_CTRL2_PHYRS 0x01 /* set to enable PHY */ | ||
78 | |||
79 | #define USB_DWC_CTRL3_OHCI1_CKEN (1 << 19) | ||
80 | #define USB_DWC_CTRL3_OHCI0_CKEN (1 << 18) | ||
81 | #define USB_DWC_CTRL3_EHCI0_CKEN (1 << 17) | ||
82 | #define USB_DWC_CTRL3_OTG0_CKEN (1 << 16) | ||
83 | |||
84 | #define USB_SBUS_CTRL_SBCA 0x04 /* coherent access */ | ||
85 | |||
86 | #define USB_INTEN_FORCE 0x20 | ||
87 | #define USB_INTEN_PHY 0x10 | ||
88 | #define USB_INTEN_UDC 0x08 | ||
89 | #define USB_INTEN_EHCI 0x04 | ||
90 | #define USB_INTEN_OHCI1 0x02 | ||
91 | #define USB_INTEN_OHCI0 0x01 | ||
92 | |||
93 | static DEFINE_SPINLOCK(alchemy_usb_lock); | ||
94 | |||
95 | static inline void __au1300_usb_phyctl(void __iomem *base, int enable) | ||
96 | { | ||
97 | unsigned long r, s; | ||
98 | |||
99 | r = __raw_readl(base + USB_DWC_CTRL2); | ||
100 | s = __raw_readl(base + USB_DWC_CTRL3); | ||
101 | |||
102 | s &= USB_DWC_CTRL3_OHCI1_CKEN | USB_DWC_CTRL3_OHCI0_CKEN | | ||
103 | USB_DWC_CTRL3_EHCI0_CKEN | USB_DWC_CTRL3_OTG0_CKEN; | ||
104 | |||
105 | if (enable) { | ||
106 | /* simply enable all PHYs */ | ||
107 | r |= USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS | | ||
108 | USB_DWC_CTRL2_PHYRS; | ||
109 | __raw_writel(r, base + USB_DWC_CTRL2); | ||
110 | wmb(); | ||
111 | } else if (!s) { | ||
112 | /* no USB block active, do disable all PHYs */ | ||
113 | r &= ~(USB_DWC_CTRL2_PHY1RS | USB_DWC_CTRL2_PHY0RS | | ||
114 | USB_DWC_CTRL2_PHYRS); | ||
115 | __raw_writel(r, base + USB_DWC_CTRL2); | ||
116 | wmb(); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | static inline void __au1300_ohci_control(void __iomem *base, int enable, int id) | ||
121 | { | ||
122 | unsigned long r; | ||
123 | |||
124 | if (enable) { | ||
125 | __raw_writel(1, base + USB_DWC_CTRL7); /* start OHCI clock */ | ||
126 | wmb(); | ||
127 | |||
128 | r = __raw_readl(base + USB_DWC_CTRL3); /* enable OHCI block */ | ||
129 | r |= (id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN | ||
130 | : USB_DWC_CTRL3_OHCI1_CKEN; | ||
131 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
132 | wmb(); | ||
133 | |||
134 | __au1300_usb_phyctl(base, enable); /* power up the PHYs */ | ||
135 | |||
136 | r = __raw_readl(base + USB_INT_ENABLE); | ||
137 | r |= (id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1; | ||
138 | __raw_writel(r, base + USB_INT_ENABLE); | ||
139 | wmb(); | ||
140 | |||
141 | /* reset the OHCI start clock bit */ | ||
142 | __raw_writel(0, base + USB_DWC_CTRL7); | ||
143 | wmb(); | ||
144 | } else { | ||
145 | r = __raw_readl(base + USB_INT_ENABLE); | ||
146 | r &= ~((id == 0) ? USB_INTEN_OHCI0 : USB_INTEN_OHCI1); | ||
147 | __raw_writel(r, base + USB_INT_ENABLE); | ||
148 | wmb(); | ||
149 | |||
150 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
151 | r &= ~((id == 0) ? USB_DWC_CTRL3_OHCI0_CKEN | ||
152 | : USB_DWC_CTRL3_OHCI1_CKEN); | ||
153 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
154 | wmb(); | ||
155 | |||
156 | __au1300_usb_phyctl(base, enable); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | static inline void __au1300_ehci_control(void __iomem *base, int enable) | ||
161 | { | ||
162 | unsigned long r; | ||
163 | |||
164 | if (enable) { | ||
165 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
166 | r |= USB_DWC_CTRL3_EHCI0_CKEN; | ||
167 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
168 | wmb(); | ||
169 | |||
170 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
171 | r |= USB_DWC_CTRL1_HSTRS; | ||
172 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
173 | wmb(); | ||
174 | |||
175 | __au1300_usb_phyctl(base, enable); | ||
176 | |||
177 | r = __raw_readl(base + USB_INT_ENABLE); | ||
178 | r |= USB_INTEN_EHCI; | ||
179 | __raw_writel(r, base + USB_INT_ENABLE); | ||
180 | wmb(); | ||
181 | } else { | ||
182 | r = __raw_readl(base + USB_INT_ENABLE); | ||
183 | r &= ~USB_INTEN_EHCI; | ||
184 | __raw_writel(r, base + USB_INT_ENABLE); | ||
185 | wmb(); | ||
186 | |||
187 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
188 | r &= ~USB_DWC_CTRL1_HSTRS; | ||
189 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
190 | wmb(); | ||
191 | |||
192 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
193 | r &= ~USB_DWC_CTRL3_EHCI0_CKEN; | ||
194 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
195 | wmb(); | ||
196 | |||
197 | __au1300_usb_phyctl(base, enable); | ||
198 | } | ||
199 | } | ||
200 | |||
201 | static inline void __au1300_udc_control(void __iomem *base, int enable) | ||
202 | { | ||
203 | unsigned long r; | ||
204 | |||
205 | if (enable) { | ||
206 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
207 | r |= USB_DWC_CTRL1_DCRS; | ||
208 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
209 | wmb(); | ||
210 | |||
211 | __au1300_usb_phyctl(base, enable); | ||
212 | |||
213 | r = __raw_readl(base + USB_INT_ENABLE); | ||
214 | r |= USB_INTEN_UDC; | ||
215 | __raw_writel(r, base + USB_INT_ENABLE); | ||
216 | wmb(); | ||
217 | } else { | ||
218 | r = __raw_readl(base + USB_INT_ENABLE); | ||
219 | r &= ~USB_INTEN_UDC; | ||
220 | __raw_writel(r, base + USB_INT_ENABLE); | ||
221 | wmb(); | ||
222 | |||
223 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
224 | r &= ~USB_DWC_CTRL1_DCRS; | ||
225 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
226 | wmb(); | ||
227 | |||
228 | __au1300_usb_phyctl(base, enable); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | static inline void __au1300_otg_control(void __iomem *base, int enable) | ||
233 | { | ||
234 | unsigned long r; | ||
235 | if (enable) { | ||
236 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
237 | r |= USB_DWC_CTRL3_OTG0_CKEN; | ||
238 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
239 | wmb(); | ||
240 | |||
241 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
242 | r &= ~USB_DWC_CTRL1_OTGD; | ||
243 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
244 | wmb(); | ||
245 | |||
246 | __au1300_usb_phyctl(base, enable); | ||
247 | } else { | ||
248 | r = __raw_readl(base + USB_DWC_CTRL1); | ||
249 | r |= USB_DWC_CTRL1_OTGD; | ||
250 | __raw_writel(r, base + USB_DWC_CTRL1); | ||
251 | wmb(); | ||
252 | |||
253 | r = __raw_readl(base + USB_DWC_CTRL3); | ||
254 | r &= ~USB_DWC_CTRL3_OTG0_CKEN; | ||
255 | __raw_writel(r, base + USB_DWC_CTRL3); | ||
256 | wmb(); | ||
257 | |||
258 | __au1300_usb_phyctl(base, enable); | ||
259 | } | ||
260 | } | ||
261 | |||
262 | static inline int au1300_usb_control(int block, int enable) | ||
263 | { | ||
264 | void __iomem *base = | ||
265 | (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR); | ||
266 | int ret = 0; | ||
267 | |||
268 | switch (block) { | ||
269 | case ALCHEMY_USB_OHCI0: | ||
270 | __au1300_ohci_control(base, enable, 0); | ||
271 | break; | ||
272 | case ALCHEMY_USB_OHCI1: | ||
273 | __au1300_ohci_control(base, enable, 1); | ||
274 | break; | ||
275 | case ALCHEMY_USB_EHCI0: | ||
276 | __au1300_ehci_control(base, enable); | ||
277 | break; | ||
278 | case ALCHEMY_USB_UDC0: | ||
279 | __au1300_udc_control(base, enable); | ||
280 | break; | ||
281 | case ALCHEMY_USB_OTG0: | ||
282 | __au1300_otg_control(base, enable); | ||
283 | break; | ||
284 | default: | ||
285 | ret = -ENODEV; | ||
286 | } | ||
287 | return ret; | ||
288 | } | ||
289 | |||
290 | static inline void au1300_usb_init(void) | ||
291 | { | ||
292 | void __iomem *base = | ||
293 | (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR); | ||
294 | |||
295 | /* set some sane defaults. Note: we don't fiddle with DWC_CTRL4 | ||
296 | * here at all: Port 2 routing (EHCI or UDC) must be set either | ||
297 | * by boot firmware or platform init code; I can't autodetect | ||
298 | * a sane setting. | ||
299 | */ | ||
300 | __raw_writel(0, base + USB_INT_ENABLE); /* disable all USB irqs */ | ||
301 | wmb(); | ||
302 | __raw_writel(0, base + USB_DWC_CTRL3); /* disable all clocks */ | ||
303 | wmb(); | ||
304 | __raw_writel(~0, base + USB_MSR_ERR); /* clear all errors */ | ||
305 | wmb(); | ||
306 | __raw_writel(~0, base + USB_INT_STATUS); /* clear int status */ | ||
307 | wmb(); | ||
308 | /* set coherent access bit */ | ||
309 | __raw_writel(USB_SBUS_CTRL_SBCA, base + USB_SBUS_CTRL); | ||
310 | wmb(); | ||
311 | } | ||
312 | |||
313 | static inline void __au1200_ohci_control(void __iomem *base, int enable) | ||
314 | { | ||
315 | unsigned long r = __raw_readl(base + AU1200_USBCFG); | ||
316 | if (enable) { | ||
317 | __raw_writel(r | USBCFG_OCE, base + AU1200_USBCFG); | ||
318 | wmb(); | ||
319 | udelay(2000); | ||
320 | } else { | ||
321 | __raw_writel(r & ~USBCFG_OCE, base + AU1200_USBCFG); | ||
322 | wmb(); | ||
323 | udelay(1000); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | static inline void __au1200_ehci_control(void __iomem *base, int enable) | ||
328 | { | ||
329 | unsigned long r = __raw_readl(base + AU1200_USBCFG); | ||
330 | if (enable) { | ||
331 | __raw_writel(r | USBCFG_ECE | USBCFG_PPE, base + AU1200_USBCFG); | ||
332 | wmb(); | ||
333 | udelay(1000); | ||
334 | } else { | ||
335 | if (!(r & USBCFG_UCE)) /* UDC also off? */ | ||
336 | r &= ~USBCFG_PPE; /* yes: disable HS PHY PLL */ | ||
337 | __raw_writel(r & ~USBCFG_ECE, base + AU1200_USBCFG); | ||
338 | wmb(); | ||
339 | udelay(1000); | ||
340 | } | ||
341 | } | ||
342 | |||
343 | static inline void __au1200_udc_control(void __iomem *base, int enable) | ||
344 | { | ||
345 | unsigned long r = __raw_readl(base + AU1200_USBCFG); | ||
346 | if (enable) { | ||
347 | __raw_writel(r | USBCFG_UCE | USBCFG_PPE, base + AU1200_USBCFG); | ||
348 | wmb(); | ||
349 | } else { | ||
350 | if (!(r & USBCFG_ECE)) /* EHCI also off? */ | ||
351 | r &= ~USBCFG_PPE; /* yes: disable HS PHY PLL */ | ||
352 | __raw_writel(r & ~USBCFG_UCE, base + AU1200_USBCFG); | ||
353 | wmb(); | ||
354 | } | ||
355 | } | ||
356 | |||
357 | static inline int au1200_coherency_bug(void) | ||
358 | { | ||
359 | #if defined(CONFIG_DMA_COHERENT) | ||
360 | /* Au1200 AB USB does not support coherent memory */ | ||
361 | if (!(read_c0_prid() & 0xff)) { | ||
362 | printk(KERN_INFO "Au1200 USB: this is chip revision AB !!\n"); | ||
363 | printk(KERN_INFO "Au1200 USB: update your board or re-configure" | ||
364 | " the kernel\n"); | ||
365 | return -ENODEV; | ||
366 | } | ||
367 | #endif | ||
368 | return 0; | ||
369 | } | ||
370 | |||
371 | static inline int au1200_usb_control(int block, int enable) | ||
372 | { | ||
373 | void __iomem *base = | ||
374 | (void __iomem *)KSEG1ADDR(AU1200_USB_CTL_PHYS_ADDR); | ||
375 | int ret = 0; | ||
376 | |||
377 | switch (block) { | ||
378 | case ALCHEMY_USB_OHCI0: | ||
379 | ret = au1200_coherency_bug(); | ||
380 | if (ret && enable) | ||
381 | goto out; | ||
382 | __au1200_ohci_control(base, enable); | ||
383 | break; | ||
384 | case ALCHEMY_USB_UDC0: | ||
385 | __au1200_udc_control(base, enable); | ||
386 | break; | ||
387 | case ALCHEMY_USB_EHCI0: | ||
388 | ret = au1200_coherency_bug(); | ||
389 | if (ret && enable) | ||
390 | goto out; | ||
391 | __au1200_ehci_control(base, enable); | ||
392 | break; | ||
393 | default: | ||
394 | ret = -ENODEV; | ||
395 | } | ||
396 | out: | ||
397 | return ret; | ||
398 | } | ||
399 | |||
400 | |||
401 | /* initialize USB block(s) to a known working state */ | ||
402 | static inline void au1200_usb_init(void) | ||
403 | { | ||
404 | void __iomem *base = | ||
405 | (void __iomem *)KSEG1ADDR(AU1200_USB_CTL_PHYS_ADDR); | ||
406 | __raw_writel(USBCFG_INIT_AU1200, base + AU1200_USBCFG); | ||
407 | wmb(); | ||
408 | udelay(1000); | ||
409 | } | ||
410 | |||
411 | static inline void au1000_usb_init(unsigned long rb, int reg) | ||
412 | { | ||
413 | void __iomem *base = (void __iomem *)KSEG1ADDR(rb + reg); | ||
414 | unsigned long r = __raw_readl(base); | ||
415 | |||
416 | #if defined(__BIG_ENDIAN) | ||
417 | r |= USBHEN_BE; | ||
418 | #endif | ||
419 | r |= USBHEN_C; | ||
420 | |||
421 | __raw_writel(r, base); | ||
422 | wmb(); | ||
423 | udelay(1000); | ||
424 | } | ||
425 | |||
426 | |||
427 | static inline void __au1xx0_ohci_control(int enable, unsigned long rb, int creg) | ||
428 | { | ||
429 | void __iomem *base = (void __iomem *)KSEG1ADDR(rb); | ||
430 | unsigned long r = __raw_readl(base + creg); | ||
431 | |||
432 | if (enable) { | ||
433 | __raw_writel(r | USBHEN_CE, base + creg); | ||
434 | wmb(); | ||
435 | udelay(1000); | ||
436 | __raw_writel(r | USBHEN_CE | USBHEN_E, base + creg); | ||
437 | wmb(); | ||
438 | udelay(1000); | ||
439 | |||
440 | /* wait for reset complete (read reg twice: au1500 erratum) */ | ||
441 | while (__raw_readl(base + creg), | ||
442 | !(__raw_readl(base + creg) & USBHEN_RD)) | ||
443 | udelay(1000); | ||
444 | } else { | ||
445 | __raw_writel(r & ~(USBHEN_CE | USBHEN_E), base + creg); | ||
446 | wmb(); | ||
447 | } | ||
448 | } | ||
449 | |||
450 | static inline int au1000_usb_control(int block, int enable, unsigned long rb, | ||
451 | int creg) | ||
452 | { | ||
453 | int ret = 0; | ||
454 | |||
455 | switch (block) { | ||
456 | case ALCHEMY_USB_OHCI0: | ||
457 | __au1xx0_ohci_control(enable, rb, creg); | ||
458 | break; | ||
459 | default: | ||
460 | ret = -ENODEV; | ||
461 | } | ||
462 | return ret; | ||
463 | } | ||
464 | |||
465 | /* | ||
466 | * alchemy_usb_control - control Alchemy on-chip USB blocks | ||
467 | * @block: USB block to target | ||
468 | * @enable: set 1 to enable a block, 0 to disable | ||
469 | */ | ||
470 | int alchemy_usb_control(int block, int enable) | ||
471 | { | ||
472 | unsigned long flags; | ||
473 | int ret; | ||
474 | |||
475 | spin_lock_irqsave(&alchemy_usb_lock, flags); | ||
476 | switch (alchemy_get_cputype()) { | ||
477 | case ALCHEMY_CPU_AU1000: | ||
478 | case ALCHEMY_CPU_AU1500: | ||
479 | case ALCHEMY_CPU_AU1100: | ||
480 | ret = au1000_usb_control(block, enable, | ||
481 | AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG); | ||
482 | break; | ||
483 | case ALCHEMY_CPU_AU1550: | ||
484 | ret = au1000_usb_control(block, enable, | ||
485 | AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG); | ||
486 | break; | ||
487 | case ALCHEMY_CPU_AU1200: | ||
488 | ret = au1200_usb_control(block, enable); | ||
489 | break; | ||
490 | case ALCHEMY_CPU_AU1300: | ||
491 | ret = au1300_usb_control(block, enable); | ||
492 | break; | ||
493 | default: | ||
494 | ret = -ENODEV; | ||
495 | } | ||
496 | spin_unlock_irqrestore(&alchemy_usb_lock, flags); | ||
497 | return ret; | ||
498 | } | ||
499 | EXPORT_SYMBOL_GPL(alchemy_usb_control); | ||
500 | |||
501 | |||
502 | static unsigned long alchemy_usb_pmdata[2]; | ||
503 | |||
504 | static void au1000_usb_pm(unsigned long br, int creg, int susp) | ||
505 | { | ||
506 | void __iomem *base = (void __iomem *)KSEG1ADDR(br); | ||
507 | |||
508 | if (susp) { | ||
509 | alchemy_usb_pmdata[0] = __raw_readl(base + creg); | ||
510 | /* There appears to be some undocumented reset register.... */ | ||
511 | __raw_writel(0, base + 0x04); | ||
512 | wmb(); | ||
513 | __raw_writel(0, base + creg); | ||
514 | wmb(); | ||
515 | } else { | ||
516 | __raw_writel(alchemy_usb_pmdata[0], base + creg); | ||
517 | wmb(); | ||
518 | } | ||
519 | } | ||
520 | |||
521 | static void au1200_usb_pm(int susp) | ||
522 | { | ||
523 | void __iomem *base = | ||
524 | (void __iomem *)KSEG1ADDR(AU1200_USB_OTG_PHYS_ADDR); | ||
525 | if (susp) { | ||
526 | /* save OTG_CAP/MUX registers which indicate port routing */ | ||
527 | /* FIXME: write an OTG driver to do that */ | ||
528 | alchemy_usb_pmdata[0] = __raw_readl(base + 0x00); | ||
529 | alchemy_usb_pmdata[1] = __raw_readl(base + 0x04); | ||
530 | } else { | ||
531 | /* restore access to all MMIO areas */ | ||
532 | au1200_usb_init(); | ||
533 | |||
534 | /* restore OTG_CAP/MUX registers */ | ||
535 | __raw_writel(alchemy_usb_pmdata[0], base + 0x00); | ||
536 | __raw_writel(alchemy_usb_pmdata[1], base + 0x04); | ||
537 | wmb(); | ||
538 | } | ||
539 | } | ||
540 | |||
541 | static void au1300_usb_pm(int susp) | ||
542 | { | ||
543 | void __iomem *base = | ||
544 | (void __iomem *)KSEG1ADDR(AU1300_USB_CTL_PHYS_ADDR); | ||
545 | /* remember Port2 routing */ | ||
546 | if (susp) { | ||
547 | alchemy_usb_pmdata[0] = __raw_readl(base + USB_DWC_CTRL4); | ||
548 | } else { | ||
549 | au1300_usb_init(); | ||
550 | __raw_writel(alchemy_usb_pmdata[0], base + USB_DWC_CTRL4); | ||
551 | wmb(); | ||
552 | } | ||
553 | } | ||
554 | |||
555 | static void alchemy_usb_pm(int susp) | ||
556 | { | ||
557 | switch (alchemy_get_cputype()) { | ||
558 | case ALCHEMY_CPU_AU1000: | ||
559 | case ALCHEMY_CPU_AU1500: | ||
560 | case ALCHEMY_CPU_AU1100: | ||
561 | au1000_usb_pm(AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG, susp); | ||
562 | break; | ||
563 | case ALCHEMY_CPU_AU1550: | ||
564 | au1000_usb_pm(AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG, susp); | ||
565 | break; | ||
566 | case ALCHEMY_CPU_AU1200: | ||
567 | au1200_usb_pm(susp); | ||
568 | break; | ||
569 | case ALCHEMY_CPU_AU1300: | ||
570 | au1300_usb_pm(susp); | ||
571 | break; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | static int alchemy_usb_suspend(void) | ||
576 | { | ||
577 | alchemy_usb_pm(1); | ||
578 | return 0; | ||
579 | } | ||
580 | |||
581 | static void alchemy_usb_resume(void) | ||
582 | { | ||
583 | alchemy_usb_pm(0); | ||
584 | } | ||
585 | |||
586 | static struct syscore_ops alchemy_usb_pm_ops = { | ||
587 | .suspend = alchemy_usb_suspend, | ||
588 | .resume = alchemy_usb_resume, | ||
589 | }; | ||
590 | |||
591 | static int __init alchemy_usb_init(void) | ||
592 | { | ||
593 | switch (alchemy_get_cputype()) { | ||
594 | case ALCHEMY_CPU_AU1000: | ||
595 | case ALCHEMY_CPU_AU1500: | ||
596 | case ALCHEMY_CPU_AU1100: | ||
597 | au1000_usb_init(AU1000_USB_OHCI_PHYS_ADDR, AU1000_OHCICFG); | ||
598 | break; | ||
599 | case ALCHEMY_CPU_AU1550: | ||
600 | au1000_usb_init(AU1550_USB_OHCI_PHYS_ADDR, AU1550_OHCICFG); | ||
601 | break; | ||
602 | case ALCHEMY_CPU_AU1200: | ||
603 | au1200_usb_init(); | ||
604 | break; | ||
605 | case ALCHEMY_CPU_AU1300: | ||
606 | au1300_usb_init(); | ||
607 | break; | ||
608 | } | ||
609 | |||
610 | register_syscore_ops(&alchemy_usb_pm_ops); | ||
611 | |||
612 | return 0; | ||
613 | } | ||
614 | arch_initcall(alchemy_usb_init); | ||
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 411bb74152eb..d23321ec0e46 100644 --- a/drivers/usb/host/ehci-atmel.c +++ b/drivers/usb/host/ehci-atmel.c | |||
@@ -53,18 +53,11 @@ static void atmel_stop_ehci(struct platform_device *pdev) | |||
53 | static int ehci_atmel_setup(struct usb_hcd *hcd) | 53 | static int ehci_atmel_setup(struct usb_hcd *hcd) |
54 | { | 54 | { |
55 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 55 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
56 | int retval; | ||
57 | 56 | ||
58 | /* registers start at offset 0x0 */ | 57 | /* registers start at offset 0x0 */ |
59 | ehci->caps = hcd->regs; | 58 | ehci->caps = hcd->regs; |
60 | 59 | ||
61 | retval = ehci_setup(hcd); | 60 | return ehci_setup(hcd); |
62 | if (retval) | ||
63 | return retval; | ||
64 | |||
65 | ehci_port_power(ehci, 0); | ||
66 | |||
67 | return retval; | ||
68 | } | 61 | } |
69 | 62 | ||
70 | static const struct hc_driver ehci_atmel_hc_driver = { | 63 | static const struct hc_driver ehci_atmel_hc_driver = { |
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c deleted file mode 100644 index 65c945eb4144..000000000000 --- a/drivers/usb/host/ehci-au1xxx.c +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* | ||
2 | * EHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * Bus Glue for AMD Alchemy Au1xxx | ||
5 | * | ||
6 | * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org> | ||
7 | * | ||
8 | * Modified for AMD Alchemy Au1200 EHC | ||
9 | * by K.Boge <karsten.boge@amd.com> | ||
10 | * | ||
11 | * This file is licenced under the GPL. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | #include <asm/mach-au1x00/au1000.h> | ||
16 | |||
17 | |||
18 | extern int usb_disabled(void); | ||
19 | |||
20 | static int au1xxx_ehci_setup(struct usb_hcd *hcd) | ||
21 | { | ||
22 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
23 | int ret; | ||
24 | |||
25 | ehci->caps = hcd->regs; | ||
26 | ret = ehci_setup(hcd); | ||
27 | |||
28 | ehci->need_io_watchdog = 0; | ||
29 | return ret; | ||
30 | } | ||
31 | |||
32 | static const struct hc_driver ehci_au1xxx_hc_driver = { | ||
33 | .description = hcd_name, | ||
34 | .product_desc = "Au1xxx EHCI", | ||
35 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
36 | |||
37 | /* | ||
38 | * generic hardware linkage | ||
39 | */ | ||
40 | .irq = ehci_irq, | ||
41 | .flags = HCD_MEMORY | HCD_USB2, | ||
42 | |||
43 | /* | ||
44 | * basic lifecycle operations | ||
45 | * | ||
46 | * FIXME -- ehci_init() doesn't do enough here. | ||
47 | * See ehci-ppc-soc for a complete implementation. | ||
48 | */ | ||
49 | .reset = au1xxx_ehci_setup, | ||
50 | .start = ehci_run, | ||
51 | .stop = ehci_stop, | ||
52 | .shutdown = ehci_shutdown, | ||
53 | |||
54 | /* | ||
55 | * managing i/o requests and associated device resources | ||
56 | */ | ||
57 | .urb_enqueue = ehci_urb_enqueue, | ||
58 | .urb_dequeue = ehci_urb_dequeue, | ||
59 | .endpoint_disable = ehci_endpoint_disable, | ||
60 | .endpoint_reset = ehci_endpoint_reset, | ||
61 | |||
62 | /* | ||
63 | * scheduling support | ||
64 | */ | ||
65 | .get_frame_number = ehci_get_frame, | ||
66 | |||
67 | /* | ||
68 | * root hub support | ||
69 | */ | ||
70 | .hub_status_data = ehci_hub_status_data, | ||
71 | .hub_control = ehci_hub_control, | ||
72 | .bus_suspend = ehci_bus_suspend, | ||
73 | .bus_resume = ehci_bus_resume, | ||
74 | .relinquish_port = ehci_relinquish_port, | ||
75 | .port_handed_over = ehci_port_handed_over, | ||
76 | |||
77 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
78 | }; | ||
79 | |||
80 | static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | ||
81 | { | ||
82 | struct usb_hcd *hcd; | ||
83 | struct resource *res; | ||
84 | int ret; | ||
85 | |||
86 | if (usb_disabled()) | ||
87 | return -ENODEV; | ||
88 | |||
89 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { | ||
90 | pr_debug("resource[1] is not IORESOURCE_IRQ"); | ||
91 | return -ENOMEM; | ||
92 | } | ||
93 | hcd = usb_create_hcd(&ehci_au1xxx_hc_driver, &pdev->dev, "Au1xxx"); | ||
94 | if (!hcd) | ||
95 | return -ENOMEM; | ||
96 | |||
97 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
98 | hcd->rsrc_start = res->start; | ||
99 | hcd->rsrc_len = resource_size(res); | ||
100 | |||
101 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); | ||
102 | if (!hcd->regs) { | ||
103 | pr_debug("devm_request_and_ioremap failed"); | ||
104 | ret = -ENOMEM; | ||
105 | goto err1; | ||
106 | } | ||
107 | |||
108 | if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) { | ||
109 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); | ||
110 | ret = -ENODEV; | ||
111 | goto err1; | ||
112 | } | ||
113 | |||
114 | ret = usb_add_hcd(hcd, pdev->resource[1].start, | ||
115 | IRQF_SHARED); | ||
116 | if (ret == 0) { | ||
117 | platform_set_drvdata(pdev, hcd); | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); | ||
122 | err1: | ||
123 | usb_put_hcd(hcd); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev) | ||
128 | { | ||
129 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
130 | |||
131 | usb_remove_hcd(hcd); | ||
132 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); | ||
133 | usb_put_hcd(hcd); | ||
134 | platform_set_drvdata(pdev, NULL); | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | #ifdef CONFIG_PM | ||
140 | static int ehci_hcd_au1xxx_drv_suspend(struct device *dev) | ||
141 | { | ||
142 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
143 | bool do_wakeup = device_may_wakeup(dev); | ||
144 | int rc; | ||
145 | |||
146 | rc = ehci_suspend(hcd, do_wakeup); | ||
147 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); | ||
148 | |||
149 | return rc; | ||
150 | } | ||
151 | |||
152 | static int ehci_hcd_au1xxx_drv_resume(struct device *dev) | ||
153 | { | ||
154 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
155 | |||
156 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 1); | ||
157 | ehci_resume(hcd, false); | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static const struct dev_pm_ops au1xxx_ehci_pmops = { | ||
163 | .suspend = ehci_hcd_au1xxx_drv_suspend, | ||
164 | .resume = ehci_hcd_au1xxx_drv_resume, | ||
165 | }; | ||
166 | |||
167 | #define AU1XXX_EHCI_PMOPS &au1xxx_ehci_pmops | ||
168 | |||
169 | #else | ||
170 | #define AU1XXX_EHCI_PMOPS NULL | ||
171 | #endif | ||
172 | |||
173 | static struct platform_driver ehci_hcd_au1xxx_driver = { | ||
174 | .probe = ehci_hcd_au1xxx_drv_probe, | ||
175 | .remove = ehci_hcd_au1xxx_drv_remove, | ||
176 | .shutdown = usb_hcd_platform_shutdown, | ||
177 | .driver = { | ||
178 | .name = "au1xxx-ehci", | ||
179 | .owner = THIS_MODULE, | ||
180 | .pm = AU1XXX_EHCI_PMOPS, | ||
181 | } | ||
182 | }; | ||
183 | |||
184 | MODULE_ALIAS("platform:au1xxx-ehci"); | ||
diff --git a/drivers/usb/host/ehci-cns3xxx.c b/drivers/usb/host/ehci-cns3xxx.c deleted file mode 100644 index d91708d2e729..000000000000 --- a/drivers/usb/host/ehci-cns3xxx.c +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cavium Networks | ||
3 | * | ||
4 | * This file is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License, Version 2, as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/platform_device.h> | ||
10 | #include <linux/atomic.h> | ||
11 | #include <mach/cns3xxx.h> | ||
12 | #include <mach/pm.h> | ||
13 | |||
14 | static int cns3xxx_ehci_init(struct usb_hcd *hcd) | ||
15 | { | ||
16 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
17 | int retval; | ||
18 | |||
19 | /* | ||
20 | * EHCI and OHCI share the same clock and power, | ||
21 | * resetting twice would cause the 1st controller been reset. | ||
22 | * Therefore only do power up at the first up device, and | ||
23 | * power down at the last down device. | ||
24 | * | ||
25 | * Set USB AHB INCR length to 16 | ||
26 | */ | ||
27 | if (atomic_inc_return(&usb_pwr_ref) == 1) { | ||
28 | cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB); | ||
29 | cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST); | ||
30 | cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST); | ||
31 | __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)), | ||
32 | MISC_CHIP_CONFIG_REG); | ||
33 | } | ||
34 | |||
35 | ehci->caps = hcd->regs; | ||
36 | |||
37 | hcd->has_tt = 0; | ||
38 | |||
39 | retval = ehci_setup(hcd); | ||
40 | if (retval) | ||
41 | return retval; | ||
42 | |||
43 | ehci_port_power(ehci, 0); | ||
44 | |||
45 | return retval; | ||
46 | } | ||
47 | |||
48 | static const struct hc_driver cns3xxx_ehci_hc_driver = { | ||
49 | .description = hcd_name, | ||
50 | .product_desc = "CNS3XXX EHCI Host Controller", | ||
51 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
52 | .irq = ehci_irq, | ||
53 | .flags = HCD_MEMORY | HCD_USB2, | ||
54 | .reset = cns3xxx_ehci_init, | ||
55 | .start = ehci_run, | ||
56 | .stop = ehci_stop, | ||
57 | .shutdown = ehci_shutdown, | ||
58 | .urb_enqueue = ehci_urb_enqueue, | ||
59 | .urb_dequeue = ehci_urb_dequeue, | ||
60 | .endpoint_disable = ehci_endpoint_disable, | ||
61 | .endpoint_reset = ehci_endpoint_reset, | ||
62 | .get_frame_number = ehci_get_frame, | ||
63 | .hub_status_data = ehci_hub_status_data, | ||
64 | .hub_control = ehci_hub_control, | ||
65 | #ifdef CONFIG_PM | ||
66 | .bus_suspend = ehci_bus_suspend, | ||
67 | .bus_resume = ehci_bus_resume, | ||
68 | #endif | ||
69 | .relinquish_port = ehci_relinquish_port, | ||
70 | .port_handed_over = ehci_port_handed_over, | ||
71 | |||
72 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
73 | }; | ||
74 | |||
75 | static int cns3xxx_ehci_probe(struct platform_device *pdev) | ||
76 | { | ||
77 | struct device *dev = &pdev->dev; | ||
78 | struct usb_hcd *hcd; | ||
79 | const struct hc_driver *driver = &cns3xxx_ehci_hc_driver; | ||
80 | struct resource *res; | ||
81 | int irq; | ||
82 | int retval; | ||
83 | |||
84 | if (usb_disabled()) | ||
85 | return -ENODEV; | ||
86 | |||
87 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
88 | if (!res) { | ||
89 | dev_err(dev, "Found HC with no IRQ.\n"); | ||
90 | return -ENODEV; | ||
91 | } | ||
92 | irq = res->start; | ||
93 | |||
94 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | ||
95 | if (!hcd) | ||
96 | return -ENOMEM; | ||
97 | |||
98 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
99 | if (!res) { | ||
100 | dev_err(dev, "Found HC with no register addr.\n"); | ||
101 | retval = -ENODEV; | ||
102 | goto err1; | ||
103 | } | ||
104 | |||
105 | hcd->rsrc_start = res->start; | ||
106 | hcd->rsrc_len = resource_size(res); | ||
107 | |||
108 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); | ||
109 | if (hcd->regs == NULL) { | ||
110 | dev_dbg(dev, "error mapping memory\n"); | ||
111 | retval = -EFAULT; | ||
112 | goto err1; | ||
113 | } | ||
114 | |||
115 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
116 | if (retval == 0) | ||
117 | return retval; | ||
118 | |||
119 | err1: | ||
120 | usb_put_hcd(hcd); | ||
121 | |||
122 | return retval; | ||
123 | } | ||
124 | |||
125 | static int cns3xxx_ehci_remove(struct platform_device *pdev) | ||
126 | { | ||
127 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
128 | |||
129 | usb_remove_hcd(hcd); | ||
130 | |||
131 | /* | ||
132 | * EHCI and OHCI share the same clock and power, | ||
133 | * resetting twice would cause the 1st controller been reset. | ||
134 | * Therefore only do power up at the first up device, and | ||
135 | * power down at the last down device. | ||
136 | */ | ||
137 | if (atomic_dec_return(&usb_pwr_ref) == 0) | ||
138 | cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST); | ||
139 | |||
140 | usb_put_hcd(hcd); | ||
141 | |||
142 | platform_set_drvdata(pdev, NULL); | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
147 | MODULE_ALIAS("platform:cns3xxx-ehci"); | ||
148 | |||
149 | static struct platform_driver cns3xxx_ehci_driver = { | ||
150 | .probe = cns3xxx_ehci_probe, | ||
151 | .remove = cns3xxx_ehci_remove, | ||
152 | .driver = { | ||
153 | .name = "cns3xxx-ehci", | ||
154 | }, | ||
155 | }; | ||
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index 1599806e3d47..70b496dc18a0 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -18,21 +18,6 @@ | |||
18 | 18 | ||
19 | /* this file is part of ehci-hcd.c */ | 19 | /* this file is part of ehci-hcd.c */ |
20 | 20 | ||
21 | #define ehci_dbg(ehci, fmt, args...) \ | ||
22 | dev_dbg (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) | ||
23 | #define ehci_err(ehci, fmt, args...) \ | ||
24 | dev_err (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) | ||
25 | #define ehci_info(ehci, fmt, args...) \ | ||
26 | dev_info (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) | ||
27 | #define ehci_warn(ehci, fmt, args...) \ | ||
28 | dev_warn (ehci_to_hcd(ehci)->self.controller , fmt , ## args ) | ||
29 | |||
30 | #ifdef VERBOSE_DEBUG | ||
31 | # define ehci_vdbg ehci_dbg | ||
32 | #else | ||
33 | static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {} | ||
34 | #endif | ||
35 | |||
36 | #ifdef DEBUG | 21 | #ifdef DEBUG |
37 | 22 | ||
38 | /* check the values in the HCSPARAMS register | 23 | /* check the values in the HCSPARAMS register |
@@ -352,11 +337,6 @@ static int debug_async_open(struct inode *, struct file *); | |||
352 | static int debug_periodic_open(struct inode *, struct file *); | 337 | static int debug_periodic_open(struct inode *, struct file *); |
353 | static int debug_registers_open(struct inode *, struct file *); | 338 | static int debug_registers_open(struct inode *, struct file *); |
354 | static int debug_async_open(struct inode *, struct file *); | 339 | static int debug_async_open(struct inode *, struct file *); |
355 | static ssize_t debug_lpm_read(struct file *file, char __user *user_buf, | ||
356 | size_t count, loff_t *ppos); | ||
357 | static ssize_t debug_lpm_write(struct file *file, const char __user *buffer, | ||
358 | size_t count, loff_t *ppos); | ||
359 | static int debug_lpm_close(struct inode *inode, struct file *file); | ||
360 | 340 | ||
361 | static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); | 341 | static ssize_t debug_output(struct file*, char __user*, size_t, loff_t*); |
362 | static int debug_close(struct inode *, struct file *); | 342 | static int debug_close(struct inode *, struct file *); |
@@ -382,14 +362,6 @@ static const struct file_operations debug_registers_fops = { | |||
382 | .release = debug_close, | 362 | .release = debug_close, |
383 | .llseek = default_llseek, | 363 | .llseek = default_llseek, |
384 | }; | 364 | }; |
385 | static const struct file_operations debug_lpm_fops = { | ||
386 | .owner = THIS_MODULE, | ||
387 | .open = simple_open, | ||
388 | .read = debug_lpm_read, | ||
389 | .write = debug_lpm_write, | ||
390 | .release = debug_lpm_close, | ||
391 | .llseek = noop_llseek, | ||
392 | }; | ||
393 | 365 | ||
394 | static struct dentry *ehci_debug_root; | 366 | static struct dentry *ehci_debug_root; |
395 | 367 | ||
@@ -971,86 +943,6 @@ static int debug_registers_open(struct inode *inode, struct file *file) | |||
971 | return file->private_data ? 0 : -ENOMEM; | 943 | return file->private_data ? 0 : -ENOMEM; |
972 | } | 944 | } |
973 | 945 | ||
974 | static int debug_lpm_close(struct inode *inode, struct file *file) | ||
975 | { | ||
976 | return 0; | ||
977 | } | ||
978 | |||
979 | static ssize_t debug_lpm_read(struct file *file, char __user *user_buf, | ||
980 | size_t count, loff_t *ppos) | ||
981 | { | ||
982 | /* TODO: show lpm stats */ | ||
983 | return 0; | ||
984 | } | ||
985 | |||
986 | static ssize_t debug_lpm_write(struct file *file, const char __user *user_buf, | ||
987 | size_t count, loff_t *ppos) | ||
988 | { | ||
989 | struct usb_hcd *hcd; | ||
990 | struct ehci_hcd *ehci; | ||
991 | char buf[50]; | ||
992 | size_t len; | ||
993 | u32 temp; | ||
994 | unsigned long port; | ||
995 | u32 __iomem *portsc ; | ||
996 | u32 params; | ||
997 | |||
998 | hcd = bus_to_hcd(file->private_data); | ||
999 | ehci = hcd_to_ehci(hcd); | ||
1000 | |||
1001 | len = min(count, sizeof(buf) - 1); | ||
1002 | if (copy_from_user(buf, user_buf, len)) | ||
1003 | return -EFAULT; | ||
1004 | buf[len] = '\0'; | ||
1005 | if (len > 0 && buf[len - 1] == '\n') | ||
1006 | buf[len - 1] = '\0'; | ||
1007 | |||
1008 | if (strncmp(buf, "enable", 5) == 0) { | ||
1009 | if (strict_strtoul(buf + 7, 10, &port)) | ||
1010 | return -EINVAL; | ||
1011 | params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
1012 | if (port > HCS_N_PORTS(params)) { | ||
1013 | ehci_dbg(ehci, "ERR: LPM on bad port %lu\n", port); | ||
1014 | return -ENODEV; | ||
1015 | } | ||
1016 | portsc = &ehci->regs->port_status[port-1]; | ||
1017 | temp = ehci_readl(ehci, portsc); | ||
1018 | if (!(temp & PORT_DEV_ADDR)) { | ||
1019 | ehci_dbg(ehci, "LPM: no device attached\n"); | ||
1020 | return -ENODEV; | ||
1021 | } | ||
1022 | temp |= PORT_LPM; | ||
1023 | ehci_writel(ehci, temp, portsc); | ||
1024 | printk(KERN_INFO "force enable LPM for port %lu\n", port); | ||
1025 | } else if (strncmp(buf, "hird=", 5) == 0) { | ||
1026 | unsigned long hird; | ||
1027 | if (strict_strtoul(buf + 5, 16, &hird)) | ||
1028 | return -EINVAL; | ||
1029 | printk(KERN_INFO "setting hird %s %lu\n", buf + 6, hird); | ||
1030 | ehci->command = (ehci->command & ~CMD_HIRD) | (hird << 24); | ||
1031 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | ||
1032 | } else if (strncmp(buf, "disable", 7) == 0) { | ||
1033 | if (strict_strtoul(buf + 8, 10, &port)) | ||
1034 | return -EINVAL; | ||
1035 | params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
1036 | if (port > HCS_N_PORTS(params)) { | ||
1037 | ehci_dbg(ehci, "ERR: LPM off bad port %lu\n", port); | ||
1038 | return -ENODEV; | ||
1039 | } | ||
1040 | portsc = &ehci->regs->port_status[port-1]; | ||
1041 | temp = ehci_readl(ehci, portsc); | ||
1042 | if (!(temp & PORT_DEV_ADDR)) { | ||
1043 | ehci_dbg(ehci, "ERR: no device attached\n"); | ||
1044 | return -ENODEV; | ||
1045 | } | ||
1046 | temp &= ~PORT_LPM; | ||
1047 | ehci_writel(ehci, temp, portsc); | ||
1048 | printk(KERN_INFO "disabled LPM for port %lu\n", port); | ||
1049 | } else | ||
1050 | return -EOPNOTSUPP; | ||
1051 | return count; | ||
1052 | } | ||
1053 | |||
1054 | static inline void create_debug_files (struct ehci_hcd *ehci) | 946 | static inline void create_debug_files (struct ehci_hcd *ehci) |
1055 | { | 947 | { |
1056 | struct usb_bus *bus = &ehci_to_hcd(ehci)->self; | 948 | struct usb_bus *bus = &ehci_to_hcd(ehci)->self; |
@@ -1071,10 +963,6 @@ static inline void create_debug_files (struct ehci_hcd *ehci) | |||
1071 | &debug_registers_fops)) | 963 | &debug_registers_fops)) |
1072 | goto file_error; | 964 | goto file_error; |
1073 | 965 | ||
1074 | if (!debugfs_create_file("lpm", S_IRUGO|S_IWUSR, ehci->debug_dir, bus, | ||
1075 | &debug_lpm_fops)) | ||
1076 | goto file_error; | ||
1077 | |||
1078 | return; | 966 | return; |
1079 | 967 | ||
1080 | file_error: | 968 | file_error: |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index 0d2f35ca93f1..fd9b5424b860 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -349,7 +349,6 @@ static int ehci_fsl_reinit(struct ehci_hcd *ehci) | |||
349 | { | 349 | { |
350 | if (ehci_fsl_usb_setup(ehci)) | 350 | if (ehci_fsl_usb_setup(ehci)) |
351 | return -EINVAL; | 351 | return -EINVAL; |
352 | ehci_port_power(ehci, 0); | ||
353 | 352 | ||
354 | return 0; | 353 | return 0; |
355 | } | 354 | } |
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c index 3180cb3624d9..da4269550fba 100644 --- a/drivers/usb/host/ehci-grlib.c +++ b/drivers/usb/host/ehci-grlib.c | |||
@@ -34,22 +34,6 @@ | |||
34 | 34 | ||
35 | #define GRUSBHC_HCIVERSION 0x0100 /* Known value of cap. reg. HCIVERSION */ | 35 | #define GRUSBHC_HCIVERSION 0x0100 /* Known value of cap. reg. HCIVERSION */ |
36 | 36 | ||
37 | /* called during probe() after chip reset completes */ | ||
38 | static int ehci_grlib_setup(struct usb_hcd *hcd) | ||
39 | { | ||
40 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
41 | int retval; | ||
42 | |||
43 | retval = ehci_setup(hcd); | ||
44 | if (retval) | ||
45 | return retval; | ||
46 | |||
47 | ehci_port_power(ehci, 1); | ||
48 | |||
49 | return retval; | ||
50 | } | ||
51 | |||
52 | |||
53 | static const struct hc_driver ehci_grlib_hc_driver = { | 37 | static const struct hc_driver ehci_grlib_hc_driver = { |
54 | .description = hcd_name, | 38 | .description = hcd_name, |
55 | .product_desc = "GRLIB GRUSBHC EHCI", | 39 | .product_desc = "GRLIB GRUSBHC EHCI", |
@@ -64,7 +48,7 @@ static const struct hc_driver ehci_grlib_hc_driver = { | |||
64 | /* | 48 | /* |
65 | * basic lifecycle operations | 49 | * basic lifecycle operations |
66 | */ | 50 | */ |
67 | .reset = ehci_grlib_setup, | 51 | .reset = ehci_setup, |
68 | .start = ehci_run, | 52 | .start = ehci_run, |
69 | .stop = ehci_stop, | 53 | .stop = ehci_stop, |
70 | .shutdown = ehci_shutdown, | 54 | .shutdown = ehci_shutdown, |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 6bf6c42481e8..c97503bb0b0e 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -39,7 +39,6 @@ | |||
39 | #include <linux/dma-mapping.h> | 39 | #include <linux/dma-mapping.h> |
40 | #include <linux/debugfs.h> | 40 | #include <linux/debugfs.h> |
41 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
42 | #include <linux/uaccess.h> | ||
43 | 42 | ||
44 | #include <asm/byteorder.h> | 43 | #include <asm/byteorder.h> |
45 | #include <asm/io.h> | 44 | #include <asm/io.h> |
@@ -108,19 +107,39 @@ static bool ignore_oc = 0; | |||
108 | module_param (ignore_oc, bool, S_IRUGO); | 107 | module_param (ignore_oc, bool, S_IRUGO); |
109 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); | 108 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); |
110 | 109 | ||
111 | /* for link power management(LPM) feature */ | ||
112 | static unsigned int hird; | ||
113 | module_param(hird, int, S_IRUGO); | ||
114 | MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us"); | ||
115 | |||
116 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) | 110 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) |
117 | 111 | ||
118 | /*-------------------------------------------------------------------------*/ | 112 | /*-------------------------------------------------------------------------*/ |
119 | 113 | ||
120 | #include "ehci.h" | 114 | #include "ehci.h" |
121 | #include "ehci-dbg.c" | ||
122 | #include "pci-quirks.h" | 115 | #include "pci-quirks.h" |
123 | 116 | ||
117 | /* | ||
118 | * The MosChip MCS9990 controller updates its microframe counter | ||
119 | * a little before the frame counter, and occasionally we will read | ||
120 | * the invalid intermediate value. Avoid problems by checking the | ||
121 | * microframe number (the low-order 3 bits); if they are 0 then | ||
122 | * re-read the register to get the correct value. | ||
123 | */ | ||
124 | static unsigned ehci_moschip_read_frame_index(struct ehci_hcd *ehci) | ||
125 | { | ||
126 | unsigned uf; | ||
127 | |||
128 | uf = ehci_readl(ehci, &ehci->regs->frame_index); | ||
129 | if (unlikely((uf & 7) == 0)) | ||
130 | uf = ehci_readl(ehci, &ehci->regs->frame_index); | ||
131 | return uf; | ||
132 | } | ||
133 | |||
134 | static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci) | ||
135 | { | ||
136 | if (ehci->frame_index_bug) | ||
137 | return ehci_moschip_read_frame_index(ehci); | ||
138 | return ehci_readl(ehci, &ehci->regs->frame_index); | ||
139 | } | ||
140 | |||
141 | #include "ehci-dbg.c" | ||
142 | |||
124 | /*-------------------------------------------------------------------------*/ | 143 | /*-------------------------------------------------------------------------*/ |
125 | 144 | ||
126 | /* | 145 | /* |
@@ -293,7 +312,6 @@ static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); | |||
293 | 312 | ||
294 | #include "ehci-timer.c" | 313 | #include "ehci-timer.c" |
295 | #include "ehci-hub.c" | 314 | #include "ehci-hub.c" |
296 | #include "ehci-lpm.c" | ||
297 | #include "ehci-mem.c" | 315 | #include "ehci-mem.c" |
298 | #include "ehci-q.c" | 316 | #include "ehci-q.c" |
299 | #include "ehci-sched.c" | 317 | #include "ehci-sched.c" |
@@ -353,24 +371,6 @@ static void ehci_shutdown(struct usb_hcd *hcd) | |||
353 | hrtimer_cancel(&ehci->hrtimer); | 371 | hrtimer_cancel(&ehci->hrtimer); |
354 | } | 372 | } |
355 | 373 | ||
356 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | ||
357 | { | ||
358 | unsigned port; | ||
359 | |||
360 | if (!HCS_PPC (ehci->hcs_params)) | ||
361 | return; | ||
362 | |||
363 | ehci_dbg (ehci, "...power%s ports...\n", is_on ? "up" : "down"); | ||
364 | for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) | ||
365 | (void) ehci_hub_control(ehci_to_hcd(ehci), | ||
366 | is_on ? SetPortFeature : ClearPortFeature, | ||
367 | USB_PORT_FEAT_POWER, | ||
368 | port--, NULL, 0); | ||
369 | /* Flush those writes */ | ||
370 | ehci_readl(ehci, &ehci->regs->command); | ||
371 | msleep(20); | ||
372 | } | ||
373 | |||
374 | /*-------------------------------------------------------------------------*/ | 374 | /*-------------------------------------------------------------------------*/ |
375 | 375 | ||
376 | /* | 376 | /* |
@@ -503,7 +503,7 @@ static int ehci_init(struct usb_hcd *hcd) | |||
503 | 503 | ||
504 | /* controllers may cache some of the periodic schedule ... */ | 504 | /* controllers may cache some of the periodic schedule ... */ |
505 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache | 505 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache |
506 | ehci->i_thresh = 2 + 8; | 506 | ehci->i_thresh = 0; |
507 | else // N microframes cached | 507 | else // N microframes cached |
508 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); | 508 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); |
509 | 509 | ||
@@ -555,17 +555,6 @@ static int ehci_init(struct usb_hcd *hcd) | |||
555 | temp &= ~(3 << 2); | 555 | temp &= ~(3 << 2); |
556 | temp |= (EHCI_TUNE_FLS << 2); | 556 | temp |= (EHCI_TUNE_FLS << 2); |
557 | } | 557 | } |
558 | if (HCC_LPM(hcc_params)) { | ||
559 | /* support link power management EHCI 1.1 addendum */ | ||
560 | ehci_dbg(ehci, "support lpm\n"); | ||
561 | ehci->has_lpm = 1; | ||
562 | if (hird > 0xf) { | ||
563 | ehci_dbg(ehci, "hird %d invalid, use default 0", | ||
564 | hird); | ||
565 | hird = 0; | ||
566 | } | ||
567 | temp |= hird << 24; | ||
568 | } | ||
569 | ehci->command = temp; | 558 | ehci->command = temp; |
570 | 559 | ||
571 | /* Accept arbitrarily long scatter-gather lists */ | 560 | /* Accept arbitrarily long scatter-gather lists */ |
@@ -660,7 +649,7 @@ static int ehci_run (struct usb_hcd *hcd) | |||
660 | return 0; | 649 | return 0; |
661 | } | 650 | } |
662 | 651 | ||
663 | static int ehci_setup(struct usb_hcd *hcd) | 652 | int ehci_setup(struct usb_hcd *hcd) |
664 | { | 653 | { |
665 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 654 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
666 | int retval; | 655 | int retval; |
@@ -691,6 +680,7 @@ static int ehci_setup(struct usb_hcd *hcd) | |||
691 | 680 | ||
692 | return 0; | 681 | return 0; |
693 | } | 682 | } |
683 | EXPORT_SYMBOL_GPL(ehci_setup); | ||
694 | 684 | ||
695 | /*-------------------------------------------------------------------------*/ | 685 | /*-------------------------------------------------------------------------*/ |
696 | 686 | ||
@@ -1096,7 +1086,7 @@ static int ehci_get_frame (struct usb_hcd *hcd) | |||
1096 | 1086 | ||
1097 | /* These routines handle the generic parts of controller suspend/resume */ | 1087 | /* These routines handle the generic parts of controller suspend/resume */ |
1098 | 1088 | ||
1099 | static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) | 1089 | int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) |
1100 | { | 1090 | { |
1101 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1091 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1102 | 1092 | ||
@@ -1119,9 +1109,10 @@ static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) | |||
1119 | 1109 | ||
1120 | return 0; | 1110 | return 0; |
1121 | } | 1111 | } |
1112 | EXPORT_SYMBOL_GPL(ehci_suspend); | ||
1122 | 1113 | ||
1123 | /* Returns 0 if power was preserved, 1 if power was lost */ | 1114 | /* Returns 0 if power was preserved, 1 if power was lost */ |
1124 | static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) | 1115 | int ehci_resume(struct usb_hcd *hcd, bool hibernated) |
1125 | { | 1116 | { |
1126 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1117 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1127 | 1118 | ||
@@ -1177,33 +1168,83 @@ static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) | |||
1177 | ehci->rh_state = EHCI_RH_SUSPENDED; | 1168 | ehci->rh_state = EHCI_RH_SUSPENDED; |
1178 | spin_unlock_irq(&ehci->lock); | 1169 | spin_unlock_irq(&ehci->lock); |
1179 | 1170 | ||
1180 | /* here we "know" root ports should always stay powered */ | ||
1181 | ehci_port_power(ehci, 1); | ||
1182 | |||
1183 | return 1; | 1171 | return 1; |
1184 | } | 1172 | } |
1173 | EXPORT_SYMBOL_GPL(ehci_resume); | ||
1185 | 1174 | ||
1186 | #endif | 1175 | #endif |
1187 | 1176 | ||
1188 | /*-------------------------------------------------------------------------*/ | 1177 | /*-------------------------------------------------------------------------*/ |
1189 | 1178 | ||
1190 | /* | 1179 | /* |
1191 | * The EHCI in ChipIdea HDRC cannot be a separate module or device, | 1180 | * Generic structure: This gets copied for platform drivers so that |
1192 | * because its registers (and irq) are shared between host/gadget/otg | 1181 | * individual entries can be overridden as needed. |
1193 | * functions and in order to facilitate role switching we cannot | ||
1194 | * give the ehci driver exclusive access to those. | ||
1195 | */ | 1182 | */ |
1196 | #ifndef CHIPIDEA_EHCI | 1183 | |
1184 | static const struct hc_driver ehci_hc_driver = { | ||
1185 | .description = hcd_name, | ||
1186 | .product_desc = "EHCI Host Controller", | ||
1187 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
1188 | |||
1189 | /* | ||
1190 | * generic hardware linkage | ||
1191 | */ | ||
1192 | .irq = ehci_irq, | ||
1193 | .flags = HCD_MEMORY | HCD_USB2, | ||
1194 | |||
1195 | /* | ||
1196 | * basic lifecycle operations | ||
1197 | */ | ||
1198 | .reset = ehci_setup, | ||
1199 | .start = ehci_run, | ||
1200 | .stop = ehci_stop, | ||
1201 | .shutdown = ehci_shutdown, | ||
1202 | |||
1203 | /* | ||
1204 | * managing i/o requests and associated device resources | ||
1205 | */ | ||
1206 | .urb_enqueue = ehci_urb_enqueue, | ||
1207 | .urb_dequeue = ehci_urb_dequeue, | ||
1208 | .endpoint_disable = ehci_endpoint_disable, | ||
1209 | .endpoint_reset = ehci_endpoint_reset, | ||
1210 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
1211 | |||
1212 | /* | ||
1213 | * scheduling support | ||
1214 | */ | ||
1215 | .get_frame_number = ehci_get_frame, | ||
1216 | |||
1217 | /* | ||
1218 | * root hub support | ||
1219 | */ | ||
1220 | .hub_status_data = ehci_hub_status_data, | ||
1221 | .hub_control = ehci_hub_control, | ||
1222 | .bus_suspend = ehci_bus_suspend, | ||
1223 | .bus_resume = ehci_bus_resume, | ||
1224 | .relinquish_port = ehci_relinquish_port, | ||
1225 | .port_handed_over = ehci_port_handed_over, | ||
1226 | }; | ||
1227 | |||
1228 | void ehci_init_driver(struct hc_driver *drv, | ||
1229 | const struct ehci_driver_overrides *over) | ||
1230 | { | ||
1231 | /* Copy the generic table to drv and then apply the overrides */ | ||
1232 | *drv = ehci_hc_driver; | ||
1233 | |||
1234 | if (over) { | ||
1235 | drv->hcd_priv_size += over->extra_priv_size; | ||
1236 | if (over->reset) | ||
1237 | drv->reset = over->reset; | ||
1238 | } | ||
1239 | } | ||
1240 | EXPORT_SYMBOL_GPL(ehci_init_driver); | ||
1241 | |||
1242 | /*-------------------------------------------------------------------------*/ | ||
1197 | 1243 | ||
1198 | MODULE_DESCRIPTION(DRIVER_DESC); | 1244 | MODULE_DESCRIPTION(DRIVER_DESC); |
1199 | MODULE_AUTHOR (DRIVER_AUTHOR); | 1245 | MODULE_AUTHOR (DRIVER_AUTHOR); |
1200 | MODULE_LICENSE ("GPL"); | 1246 | MODULE_LICENSE ("GPL"); |
1201 | 1247 | ||
1202 | #ifdef CONFIG_PCI | ||
1203 | #include "ehci-pci.c" | ||
1204 | #define PCI_DRIVER ehci_pci_driver | ||
1205 | #endif | ||
1206 | |||
1207 | #ifdef CONFIG_USB_EHCI_FSL | 1248 | #ifdef CONFIG_USB_EHCI_FSL |
1208 | #include "ehci-fsl.c" | 1249 | #include "ehci-fsl.c" |
1209 | #define PLATFORM_DRIVER ehci_fsl_driver | 1250 | #define PLATFORM_DRIVER ehci_fsl_driver |
@@ -1219,11 +1260,6 @@ MODULE_LICENSE ("GPL"); | |||
1219 | #define PLATFORM_DRIVER ehci_hcd_sh_driver | 1260 | #define PLATFORM_DRIVER ehci_hcd_sh_driver |
1220 | #endif | 1261 | #endif |
1221 | 1262 | ||
1222 | #ifdef CONFIG_MIPS_ALCHEMY | ||
1223 | #include "ehci-au1xxx.c" | ||
1224 | #define PLATFORM_DRIVER ehci_hcd_au1xxx_driver | ||
1225 | #endif | ||
1226 | |||
1227 | #ifdef CONFIG_USB_EHCI_HCD_OMAP | 1263 | #ifdef CONFIG_USB_EHCI_HCD_OMAP |
1228 | #include "ehci-omap.c" | 1264 | #include "ehci-omap.c" |
1229 | #define PLATFORM_DRIVER ehci_hcd_omap_driver | 1265 | #define PLATFORM_DRIVER ehci_hcd_omap_driver |
@@ -1249,11 +1285,6 @@ MODULE_LICENSE ("GPL"); | |||
1249 | #define PLATFORM_DRIVER ehci_orion_driver | 1285 | #define PLATFORM_DRIVER ehci_orion_driver |
1250 | #endif | 1286 | #endif |
1251 | 1287 | ||
1252 | #ifdef CONFIG_ARCH_IXP4XX | ||
1253 | #include "ehci-ixp4xx.c" | ||
1254 | #define PLATFORM_DRIVER ixp4xx_ehci_driver | ||
1255 | #endif | ||
1256 | |||
1257 | #ifdef CONFIG_USB_W90X900_EHCI | 1288 | #ifdef CONFIG_USB_W90X900_EHCI |
1258 | #include "ehci-w90x900.c" | 1289 | #include "ehci-w90x900.c" |
1259 | #define PLATFORM_DRIVER ehci_hcd_w90x900_driver | 1290 | #define PLATFORM_DRIVER ehci_hcd_w90x900_driver |
@@ -1269,11 +1300,6 @@ MODULE_LICENSE ("GPL"); | |||
1269 | #define PLATFORM_DRIVER ehci_octeon_driver | 1300 | #define PLATFORM_DRIVER ehci_octeon_driver |
1270 | #endif | 1301 | #endif |
1271 | 1302 | ||
1272 | #ifdef CONFIG_USB_CNS3XXX_EHCI | ||
1273 | #include "ehci-cns3xxx.c" | ||
1274 | #define PLATFORM_DRIVER cns3xxx_ehci_driver | ||
1275 | #endif | ||
1276 | |||
1277 | #ifdef CONFIG_ARCH_VT8500 | 1303 | #ifdef CONFIG_ARCH_VT8500 |
1278 | #include "ehci-vt8500.c" | 1304 | #include "ehci-vt8500.c" |
1279 | #define PLATFORM_DRIVER vt8500_ehci_driver | 1305 | #define PLATFORM_DRIVER vt8500_ehci_driver |
@@ -1314,34 +1340,23 @@ MODULE_LICENSE ("GPL"); | |||
1314 | #define PLATFORM_DRIVER ehci_grlib_driver | 1340 | #define PLATFORM_DRIVER ehci_grlib_driver |
1315 | #endif | 1341 | #endif |
1316 | 1342 | ||
1317 | #ifdef CONFIG_CPU_XLR | ||
1318 | #include "ehci-xls.c" | ||
1319 | #define PLATFORM_DRIVER ehci_xls_driver | ||
1320 | #endif | ||
1321 | |||
1322 | #ifdef CONFIG_USB_EHCI_MV | 1343 | #ifdef CONFIG_USB_EHCI_MV |
1323 | #include "ehci-mv.c" | 1344 | #include "ehci-mv.c" |
1324 | #define PLATFORM_DRIVER ehci_mv_driver | 1345 | #define PLATFORM_DRIVER ehci_mv_driver |
1325 | #endif | 1346 | #endif |
1326 | 1347 | ||
1327 | #ifdef CONFIG_MACH_LOONGSON1 | ||
1328 | #include "ehci-ls1x.c" | ||
1329 | #define PLATFORM_DRIVER ehci_ls1x_driver | ||
1330 | #endif | ||
1331 | |||
1332 | #ifdef CONFIG_MIPS_SEAD3 | 1348 | #ifdef CONFIG_MIPS_SEAD3 |
1333 | #include "ehci-sead3.c" | 1349 | #include "ehci-sead3.c" |
1334 | #define PLATFORM_DRIVER ehci_hcd_sead3_driver | 1350 | #define PLATFORM_DRIVER ehci_hcd_sead3_driver |
1335 | #endif | 1351 | #endif |
1336 | 1352 | ||
1337 | #ifdef CONFIG_USB_EHCI_HCD_PLATFORM | 1353 | #if !IS_ENABLED(CONFIG_USB_EHCI_PCI) && \ |
1338 | #include "ehci-platform.c" | 1354 | !IS_ENABLED(CONFIG_USB_EHCI_HCD_PLATFORM) && \ |
1339 | #define PLATFORM_DRIVER ehci_platform_driver | 1355 | !defined(CONFIG_USB_CHIPIDEA_HOST) && \ |
1340 | #endif | 1356 | !defined(PLATFORM_DRIVER) && \ |
1341 | 1357 | !defined(PS3_SYSTEM_BUS_DRIVER) && \ | |
1342 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1358 | !defined(OF_PLATFORM_DRIVER) && \ |
1343 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ | 1359 | !defined(XILINX_OF_PLATFORM_DRIVER) |
1344 | !defined(XILINX_OF_PLATFORM_DRIVER) | ||
1345 | #error "missing bus glue for ehci-hcd" | 1360 | #error "missing bus glue for ehci-hcd" |
1346 | #endif | 1361 | #endif |
1347 | 1362 | ||
@@ -1378,12 +1393,6 @@ static int __init ehci_hcd_init(void) | |||
1378 | goto clean0; | 1393 | goto clean0; |
1379 | #endif | 1394 | #endif |
1380 | 1395 | ||
1381 | #ifdef PCI_DRIVER | ||
1382 | retval = pci_register_driver(&PCI_DRIVER); | ||
1383 | if (retval < 0) | ||
1384 | goto clean1; | ||
1385 | #endif | ||
1386 | |||
1387 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1396 | #ifdef PS3_SYSTEM_BUS_DRIVER |
1388 | retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); | 1397 | retval = ps3_ehci_driver_register(&PS3_SYSTEM_BUS_DRIVER); |
1389 | if (retval < 0) | 1398 | if (retval < 0) |
@@ -1415,10 +1424,6 @@ clean3: | |||
1415 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); | 1424 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); |
1416 | clean2: | 1425 | clean2: |
1417 | #endif | 1426 | #endif |
1418 | #ifdef PCI_DRIVER | ||
1419 | pci_unregister_driver(&PCI_DRIVER); | ||
1420 | clean1: | ||
1421 | #endif | ||
1422 | #ifdef PLATFORM_DRIVER | 1427 | #ifdef PLATFORM_DRIVER |
1423 | platform_driver_unregister(&PLATFORM_DRIVER); | 1428 | platform_driver_unregister(&PLATFORM_DRIVER); |
1424 | clean0: | 1429 | clean0: |
@@ -1444,9 +1449,6 @@ static void __exit ehci_hcd_cleanup(void) | |||
1444 | #ifdef PLATFORM_DRIVER | 1449 | #ifdef PLATFORM_DRIVER |
1445 | platform_driver_unregister(&PLATFORM_DRIVER); | 1450 | platform_driver_unregister(&PLATFORM_DRIVER); |
1446 | #endif | 1451 | #endif |
1447 | #ifdef PCI_DRIVER | ||
1448 | pci_unregister_driver(&PCI_DRIVER); | ||
1449 | #endif | ||
1450 | #ifdef PS3_SYSTEM_BUS_DRIVER | 1452 | #ifdef PS3_SYSTEM_BUS_DRIVER |
1451 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); | 1453 | ps3_ehci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER); |
1452 | #endif | 1454 | #endif |
@@ -1456,5 +1458,3 @@ static void __exit ehci_hcd_cleanup(void) | |||
1456 | clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); | 1458 | clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded); |
1457 | } | 1459 | } |
1458 | module_exit(ehci_hcd_cleanup); | 1460 | module_exit(ehci_hcd_cleanup); |
1459 | |||
1460 | #endif /* CHIPIDEA_EHCI */ | ||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 914ce9370e70..4ccb97c0678f 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -56,6 +56,19 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) | |||
56 | if (!ehci->owned_ports) | 56 | if (!ehci->owned_ports) |
57 | return; | 57 | return; |
58 | 58 | ||
59 | /* Make sure the ports are powered */ | ||
60 | port = HCS_N_PORTS(ehci->hcs_params); | ||
61 | while (port--) { | ||
62 | if (test_bit(port, &ehci->owned_ports)) { | ||
63 | reg = &ehci->regs->port_status[port]; | ||
64 | status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS; | ||
65 | if (!(status & PORT_POWER)) { | ||
66 | status |= PORT_POWER; | ||
67 | ehci_writel(ehci, status, reg); | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | |||
59 | /* Give the connections some time to appear */ | 72 | /* Give the connections some time to appear */ |
60 | msleep(20); | 73 | msleep(20); |
61 | 74 | ||
@@ -384,11 +397,24 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
384 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | 397 | ehci_writel(ehci, ehci->command, &ehci->regs->command); |
385 | ehci->rh_state = EHCI_RH_RUNNING; | 398 | ehci->rh_state = EHCI_RH_RUNNING; |
386 | 399 | ||
387 | /* Some controller/firmware combinations need a delay during which | 400 | /* |
388 | * they set up the port statuses. See Bugzilla #8190. */ | 401 | * According to Bugzilla #8190, the port status for some controllers |
389 | spin_unlock_irq(&ehci->lock); | 402 | * will be wrong without a delay. At their wrong status, the port |
390 | msleep(8); | 403 | * is enabled, but not suspended neither resumed. |
391 | spin_lock_irq(&ehci->lock); | 404 | */ |
405 | i = HCS_N_PORTS(ehci->hcs_params); | ||
406 | while (i--) { | ||
407 | temp = ehci_readl(ehci, &ehci->regs->port_status[i]); | ||
408 | if ((temp & PORT_PE) && | ||
409 | !(temp & (PORT_SUSPEND | PORT_RESUME))) { | ||
410 | ehci_dbg(ehci, "Port status(0x%x) is wrong\n", temp); | ||
411 | spin_unlock_irq(&ehci->lock); | ||
412 | msleep(8); | ||
413 | spin_lock_irq(&ehci->lock); | ||
414 | break; | ||
415 | } | ||
416 | } | ||
417 | |||
392 | if (ehci->shutdown) | 418 | if (ehci->shutdown) |
393 | goto shutdown; | 419 | goto shutdown; |
394 | 420 | ||
@@ -764,11 +790,6 @@ static int ehci_hub_control ( | |||
764 | status_reg); | 790 | status_reg); |
765 | break; | 791 | break; |
766 | case USB_PORT_FEAT_C_CONNECTION: | 792 | case USB_PORT_FEAT_C_CONNECTION: |
767 | if (ehci->has_lpm) { | ||
768 | /* clear PORTSC bits on disconnect */ | ||
769 | temp &= ~PORT_LPM; | ||
770 | temp &= ~PORT_DEV_ADDR; | ||
771 | } | ||
772 | ehci_writel(ehci, temp | PORT_CSC, status_reg); | 793 | ehci_writel(ehci, temp | PORT_CSC, status_reg); |
773 | break; | 794 | break; |
774 | case USB_PORT_FEAT_C_OVER_CURRENT: | 795 | case USB_PORT_FEAT_C_OVER_CURRENT: |
@@ -1088,8 +1109,7 @@ error_exit: | |||
1088 | return retval; | 1109 | return retval; |
1089 | } | 1110 | } |
1090 | 1111 | ||
1091 | static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, | 1112 | static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) |
1092 | int portnum) | ||
1093 | { | 1113 | { |
1094 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1114 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1095 | 1115 | ||
@@ -1098,8 +1118,7 @@ static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, | |||
1098 | set_owner(ehci, --portnum, PORT_OWNER); | 1118 | set_owner(ehci, --portnum, PORT_OWNER); |
1099 | } | 1119 | } |
1100 | 1120 | ||
1101 | static int __maybe_unused ehci_port_handed_over(struct usb_hcd *hcd, | 1121 | static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum) |
1102 | int portnum) | ||
1103 | { | 1122 | { |
1104 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1123 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1105 | u32 __iomem *reg; | 1124 | u32 __iomem *reg; |
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c deleted file mode 100644 index f224c0a48bed..000000000000 --- a/drivers/usb/host/ehci-ixp4xx.c +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
1 | /* | ||
2 | * IXP4XX EHCI Host Controller Driver | ||
3 | * | ||
4 | * Author: Vladimir Barinov <vbarinov@embeddedalley.com> | ||
5 | * | ||
6 | * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> | ||
7 | * | ||
8 | * 2007 (c) MontaVista Software, Inc. This file is licensed under | ||
9 | * the terms of the GNU General Public License version 2. This program | ||
10 | * is licensed "as is" without any warranty of any kind, whether express | ||
11 | * or implied. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | |||
16 | static int ixp4xx_ehci_init(struct usb_hcd *hcd) | ||
17 | { | ||
18 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
19 | int retval = 0; | ||
20 | |||
21 | ehci->big_endian_desc = 1; | ||
22 | ehci->big_endian_mmio = 1; | ||
23 | |||
24 | ehci->caps = hcd->regs + 0x100; | ||
25 | |||
26 | hcd->has_tt = 1; | ||
27 | |||
28 | retval = ehci_setup(hcd); | ||
29 | if (retval) | ||
30 | return retval; | ||
31 | |||
32 | ehci_port_power(ehci, 0); | ||
33 | |||
34 | return retval; | ||
35 | } | ||
36 | |||
37 | static const struct hc_driver ixp4xx_ehci_hc_driver = { | ||
38 | .description = hcd_name, | ||
39 | .product_desc = "IXP4XX EHCI Host Controller", | ||
40 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
41 | .irq = ehci_irq, | ||
42 | .flags = HCD_MEMORY | HCD_USB2, | ||
43 | .reset = ixp4xx_ehci_init, | ||
44 | .start = ehci_run, | ||
45 | .stop = ehci_stop, | ||
46 | .shutdown = ehci_shutdown, | ||
47 | .urb_enqueue = ehci_urb_enqueue, | ||
48 | .urb_dequeue = ehci_urb_dequeue, | ||
49 | .endpoint_disable = ehci_endpoint_disable, | ||
50 | .endpoint_reset = ehci_endpoint_reset, | ||
51 | .get_frame_number = ehci_get_frame, | ||
52 | .hub_status_data = ehci_hub_status_data, | ||
53 | .hub_control = ehci_hub_control, | ||
54 | #if defined(CONFIG_PM) | ||
55 | .bus_suspend = ehci_bus_suspend, | ||
56 | .bus_resume = ehci_bus_resume, | ||
57 | #endif | ||
58 | .relinquish_port = ehci_relinquish_port, | ||
59 | .port_handed_over = ehci_port_handed_over, | ||
60 | |||
61 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
62 | }; | ||
63 | |||
64 | static int ixp4xx_ehci_probe(struct platform_device *pdev) | ||
65 | { | ||
66 | struct usb_hcd *hcd; | ||
67 | const struct hc_driver *driver = &ixp4xx_ehci_hc_driver; | ||
68 | struct resource *res; | ||
69 | int irq; | ||
70 | int retval; | ||
71 | |||
72 | if (usb_disabled()) | ||
73 | return -ENODEV; | ||
74 | |||
75 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
76 | if (!res) { | ||
77 | dev_err(&pdev->dev, | ||
78 | "Found HC with no IRQ. Check %s setup!\n", | ||
79 | dev_name(&pdev->dev)); | ||
80 | return -ENODEV; | ||
81 | } | ||
82 | irq = res->start; | ||
83 | |||
84 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | ||
85 | if (!hcd) { | ||
86 | retval = -ENOMEM; | ||
87 | goto fail_create_hcd; | ||
88 | } | ||
89 | |||
90 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
91 | if (!res) { | ||
92 | dev_err(&pdev->dev, | ||
93 | "Found HC with no register addr. Check %s setup!\n", | ||
94 | dev_name(&pdev->dev)); | ||
95 | retval = -ENODEV; | ||
96 | goto fail_request_resource; | ||
97 | } | ||
98 | hcd->rsrc_start = res->start; | ||
99 | hcd->rsrc_len = resource_size(res); | ||
100 | |||
101 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); | ||
102 | if (hcd->regs == NULL) { | ||
103 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
104 | retval = -EFAULT; | ||
105 | goto fail_request_resource; | ||
106 | } | ||
107 | |||
108 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
109 | if (retval) | ||
110 | goto fail_request_resource; | ||
111 | |||
112 | return retval; | ||
113 | |||
114 | fail_request_resource: | ||
115 | usb_put_hcd(hcd); | ||
116 | fail_create_hcd: | ||
117 | dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval); | ||
118 | return retval; | ||
119 | } | ||
120 | |||
121 | static int ixp4xx_ehci_remove(struct platform_device *pdev) | ||
122 | { | ||
123 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
124 | |||
125 | usb_remove_hcd(hcd); | ||
126 | usb_put_hcd(hcd); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | MODULE_ALIAS("platform:ixp4xx-ehci"); | ||
132 | |||
133 | static struct platform_driver ixp4xx_ehci_driver = { | ||
134 | .probe = ixp4xx_ehci_probe, | ||
135 | .remove = ixp4xx_ehci_remove, | ||
136 | .driver = { | ||
137 | .name = "ixp4xx-ehci", | ||
138 | }, | ||
139 | }; | ||
diff --git a/drivers/usb/host/ehci-lpm.c b/drivers/usb/host/ehci-lpm.c deleted file mode 100644 index 2111627a19de..000000000000 --- a/drivers/usb/host/ehci-lpm.c +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | /* ehci-lpm.c EHCI HCD LPM support code | ||
2 | * Copyright (c) 2008 - 2010, Intel Corporation. | ||
3 | * Author: Jacob Pan <jacob.jun.pan@intel.com> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | */ | ||
18 | |||
19 | /* this file is part of ehci-hcd.c */ | ||
20 | static int __maybe_unused ehci_lpm_set_da(struct ehci_hcd *ehci, | ||
21 | int dev_addr, int port_num) | ||
22 | { | ||
23 | u32 __iomem portsc; | ||
24 | |||
25 | ehci_dbg(ehci, "set dev address %d for port %d\n", dev_addr, port_num); | ||
26 | if (port_num > HCS_N_PORTS(ehci->hcs_params)) { | ||
27 | ehci_dbg(ehci, "invalid port number %d\n", port_num); | ||
28 | return -ENODEV; | ||
29 | } | ||
30 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_num-1]); | ||
31 | portsc &= ~PORT_DEV_ADDR; | ||
32 | portsc |= dev_addr<<25; | ||
33 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_num-1]); | ||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * this function is used to check if the device support LPM | ||
39 | * if yes, mark the PORTSC register with PORT_LPM bit | ||
40 | */ | ||
41 | static int __maybe_unused ehci_lpm_check(struct ehci_hcd *ehci, int port) | ||
42 | { | ||
43 | u32 __iomem *portsc ; | ||
44 | u32 val32; | ||
45 | int retval; | ||
46 | |||
47 | portsc = &ehci->regs->port_status[port-1]; | ||
48 | val32 = ehci_readl(ehci, portsc); | ||
49 | if (!(val32 & PORT_DEV_ADDR)) { | ||
50 | ehci_dbg(ehci, "LPM: no device attached\n"); | ||
51 | return -ENODEV; | ||
52 | } | ||
53 | val32 |= PORT_LPM; | ||
54 | ehci_writel(ehci, val32, portsc); | ||
55 | msleep(5); | ||
56 | val32 |= PORT_SUSPEND; | ||
57 | ehci_dbg(ehci, "Sending LPM 0x%08x to port %d\n", val32, port); | ||
58 | ehci_writel(ehci, val32, portsc); | ||
59 | /* wait for ACK */ | ||
60 | msleep(10); | ||
61 | retval = handshake(ehci, &ehci->regs->port_status[port-1], PORT_SSTS, | ||
62 | PORTSC_SUSPEND_STS_ACK, 125); | ||
63 | dbg_port(ehci, "LPM", port, val32); | ||
64 | if (retval != -ETIMEDOUT) { | ||
65 | ehci_dbg(ehci, "LPM: device ACK for LPM\n"); | ||
66 | val32 |= PORT_LPM; | ||
67 | /* | ||
68 | * now device should be in L1 sleep, let's wake up the device | ||
69 | * so that we can complete enumeration. | ||
70 | */ | ||
71 | ehci_writel(ehci, val32, portsc); | ||
72 | msleep(10); | ||
73 | val32 |= PORT_RESUME; | ||
74 | ehci_writel(ehci, val32, portsc); | ||
75 | } else { | ||
76 | ehci_dbg(ehci, "LPM: device does not ACK, disable LPM %d\n", | ||
77 | retval); | ||
78 | val32 &= ~PORT_LPM; | ||
79 | retval = -ETIMEDOUT; | ||
80 | ehci_writel(ehci, val32, portsc); | ||
81 | } | ||
82 | |||
83 | return retval; | ||
84 | } | ||
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c deleted file mode 100644 index aa0f328922df..000000000000 --- a/drivers/usb/host/ehci-ls1x.c +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | /* | ||
2 | * Bus Glue for Loongson LS1X built-in EHCI controller. | ||
3 | * | ||
4 | * Copyright (c) 2012 Zhang, Keguang <keguang.zhang@gmail.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License version 2 as published | ||
8 | * by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | |||
12 | #include <linux/platform_device.h> | ||
13 | |||
14 | static int ehci_ls1x_reset(struct usb_hcd *hcd) | ||
15 | { | ||
16 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
17 | int ret; | ||
18 | |||
19 | ehci->caps = hcd->regs; | ||
20 | |||
21 | ret = ehci_setup(hcd); | ||
22 | if (ret) | ||
23 | return ret; | ||
24 | |||
25 | ehci_port_power(ehci, 0); | ||
26 | |||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | static const struct hc_driver ehci_ls1x_hc_driver = { | ||
31 | .description = hcd_name, | ||
32 | .product_desc = "LOONGSON1 EHCI", | ||
33 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
34 | |||
35 | /* | ||
36 | * generic hardware linkage | ||
37 | */ | ||
38 | .irq = ehci_irq, | ||
39 | .flags = HCD_MEMORY | HCD_USB2, | ||
40 | |||
41 | /* | ||
42 | * basic lifecycle operations | ||
43 | */ | ||
44 | .reset = ehci_ls1x_reset, | ||
45 | .start = ehci_run, | ||
46 | .stop = ehci_stop, | ||
47 | .shutdown = ehci_shutdown, | ||
48 | |||
49 | /* | ||
50 | * managing i/o requests and associated device resources | ||
51 | */ | ||
52 | .urb_enqueue = ehci_urb_enqueue, | ||
53 | .urb_dequeue = ehci_urb_dequeue, | ||
54 | .endpoint_disable = ehci_endpoint_disable, | ||
55 | .endpoint_reset = ehci_endpoint_reset, | ||
56 | |||
57 | /* | ||
58 | * scheduling support | ||
59 | */ | ||
60 | .get_frame_number = ehci_get_frame, | ||
61 | |||
62 | /* | ||
63 | * root hub support | ||
64 | */ | ||
65 | .hub_status_data = ehci_hub_status_data, | ||
66 | .hub_control = ehci_hub_control, | ||
67 | .relinquish_port = ehci_relinquish_port, | ||
68 | .port_handed_over = ehci_port_handed_over, | ||
69 | |||
70 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
71 | }; | ||
72 | |||
73 | static int ehci_hcd_ls1x_probe(struct platform_device *pdev) | ||
74 | { | ||
75 | struct usb_hcd *hcd; | ||
76 | struct resource *res; | ||
77 | int irq; | ||
78 | int ret; | ||
79 | |||
80 | pr_debug("initializing loongson1 ehci USB Controller\n"); | ||
81 | |||
82 | if (usb_disabled()) | ||
83 | return -ENODEV; | ||
84 | |||
85 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
86 | if (!res) { | ||
87 | dev_err(&pdev->dev, | ||
88 | "Found HC with no IRQ. Check %s setup!\n", | ||
89 | dev_name(&pdev->dev)); | ||
90 | return -ENODEV; | ||
91 | } | ||
92 | irq = res->start; | ||
93 | |||
94 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
95 | if (!res) { | ||
96 | dev_err(&pdev->dev, | ||
97 | "Found HC with no register addr. Check %s setup!\n", | ||
98 | dev_name(&pdev->dev)); | ||
99 | return -ENODEV; | ||
100 | } | ||
101 | |||
102 | hcd = usb_create_hcd(&ehci_ls1x_hc_driver, &pdev->dev, | ||
103 | dev_name(&pdev->dev)); | ||
104 | if (!hcd) | ||
105 | return -ENOMEM; | ||
106 | hcd->rsrc_start = res->start; | ||
107 | hcd->rsrc_len = resource_size(res); | ||
108 | |||
109 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); | ||
110 | if (hcd->regs == NULL) { | ||
111 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
112 | ret = -EFAULT; | ||
113 | goto err_put_hcd; | ||
114 | } | ||
115 | |||
116 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | ||
117 | if (ret) | ||
118 | goto err_put_hcd; | ||
119 | |||
120 | return ret; | ||
121 | |||
122 | err_put_hcd: | ||
123 | usb_put_hcd(hcd); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | static int ehci_hcd_ls1x_remove(struct platform_device *pdev) | ||
128 | { | ||
129 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
130 | |||
131 | usb_remove_hcd(hcd); | ||
132 | usb_put_hcd(hcd); | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static struct platform_driver ehci_ls1x_driver = { | ||
138 | .probe = ehci_hcd_ls1x_probe, | ||
139 | .remove = ehci_hcd_ls1x_remove, | ||
140 | .shutdown = usb_hcd_platform_shutdown, | ||
141 | .driver = { | ||
142 | .name = "ls1x-ehci", | ||
143 | .owner = THIS_MODULE, | ||
144 | }, | ||
145 | }; | ||
146 | |||
147 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ls1x-ehci"); | ||
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 4af4dc5b618c..7fa1ba4de789 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -53,7 +53,6 @@ static int ehci_msm_reset(struct usb_hcd *hcd) | |||
53 | /* Disable streaming mode and select host mode */ | 53 | /* Disable streaming mode and select host mode */ |
54 | writel(0x13, USB_USBMODE); | 54 | writel(0x13, USB_USBMODE); |
55 | 55 | ||
56 | ehci_port_power(ehci, 1); | ||
57 | return 0; | 56 | return 0; |
58 | } | 57 | } |
59 | 58 | ||
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 4a08fc0b27c9..8804f74689d7 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
@@ -39,17 +39,9 @@ struct ehci_mxc_priv { | |||
39 | /* called during probe() after chip reset completes */ | 39 | /* called during probe() after chip reset completes */ |
40 | static int ehci_mxc_setup(struct usb_hcd *hcd) | 40 | static int ehci_mxc_setup(struct usb_hcd *hcd) |
41 | { | 41 | { |
42 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
43 | int retval; | ||
44 | |||
45 | hcd->has_tt = 1; | 42 | hcd->has_tt = 1; |
46 | 43 | ||
47 | retval = ehci_setup(hcd); | 44 | return ehci_setup(hcd); |
48 | if (retval) | ||
49 | return retval; | ||
50 | |||
51 | ehci_port_power(ehci, 0); | ||
52 | return 0; | ||
53 | } | 45 | } |
54 | 46 | ||
55 | static const struct hc_driver ehci_mxc_hc_driver = { | 47 | static const struct hc_driver ehci_mxc_hc_driver = { |
diff --git a/drivers/usb/host/ehci-octeon.c b/drivers/usb/host/ehci-octeon.c index ba26957abf46..a89750fff4ff 100644 --- a/drivers/usb/host/ehci-octeon.c +++ b/drivers/usb/host/ehci-octeon.c | |||
@@ -159,9 +159,6 @@ static int ehci_octeon_drv_probe(struct platform_device *pdev) | |||
159 | 159 | ||
160 | platform_set_drvdata(pdev, hcd); | 160 | platform_set_drvdata(pdev, hcd); |
161 | 161 | ||
162 | /* root ports should always stay powered */ | ||
163 | ehci_port_power(ehci, 1); | ||
164 | |||
165 | return 0; | 162 | return 0; |
166 | err3: | 163 | err3: |
167 | ehci_octeon_stop(); | 164 | ehci_octeon_stop(); |
diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index d7fe287d0678..44e7d0f638e8 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
@@ -146,9 +146,6 @@ static int omap_ehci_init(struct usb_hcd *hcd) | |||
146 | gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); | 146 | gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); |
147 | } | 147 | } |
148 | 148 | ||
149 | /* root ports should always stay powered */ | ||
150 | ehci_port_power(ehci, 1); | ||
151 | |||
152 | return rc; | 149 | return rc; |
153 | } | 150 | } |
154 | 151 | ||
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c index 9c2717d66730..96da679becef 100644 --- a/drivers/usb/host/ehci-orion.c +++ b/drivers/usb/host/ehci-orion.c | |||
@@ -101,20 +101,6 @@ static void orion_usb_phy_v1_setup(struct usb_hcd *hcd) | |||
101 | wrl(USB_MODE, 0x13); | 101 | wrl(USB_MODE, 0x13); |
102 | } | 102 | } |
103 | 103 | ||
104 | static int ehci_orion_setup(struct usb_hcd *hcd) | ||
105 | { | ||
106 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
107 | int retval; | ||
108 | |||
109 | retval = ehci_setup(hcd); | ||
110 | if (retval) | ||
111 | return retval; | ||
112 | |||
113 | ehci_port_power(ehci, 0); | ||
114 | |||
115 | return retval; | ||
116 | } | ||
117 | |||
118 | static const struct hc_driver ehci_orion_hc_driver = { | 104 | static const struct hc_driver ehci_orion_hc_driver = { |
119 | .description = hcd_name, | 105 | .description = hcd_name, |
120 | .product_desc = "Marvell Orion EHCI", | 106 | .product_desc = "Marvell Orion EHCI", |
@@ -129,7 +115,7 @@ static const struct hc_driver ehci_orion_hc_driver = { | |||
129 | /* | 115 | /* |
130 | * basic lifecycle operations | 116 | * basic lifecycle operations |
131 | */ | 117 | */ |
132 | .reset = ehci_orion_setup, | 118 | .reset = ehci_setup, |
133 | .start = ehci_run, | 119 | .start = ehci_run, |
134 | .stop = ehci_stop, | 120 | .stop = ehci_stop, |
135 | .shutdown = ehci_shutdown, | 121 | .shutdown = ehci_shutdown, |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 2cb7d370c4ef..3fb76ca61848 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -18,9 +18,18 @@ | |||
18 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 18 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef CONFIG_PCI | 21 | #include <linux/kernel.h> |
22 | #error "This file is PCI bus glue. CONFIG_PCI must be defined." | 22 | #include <linux/module.h> |
23 | #endif | 23 | #include <linux/pci.h> |
24 | #include <linux/usb.h> | ||
25 | #include <linux/usb/hcd.h> | ||
26 | |||
27 | #include "ehci.h" | ||
28 | #include "pci-quirks.h" | ||
29 | |||
30 | #define DRIVER_DESC "EHCI PCI platform driver" | ||
31 | |||
32 | static const char hcd_name[] = "ehci-pci"; | ||
24 | 33 | ||
25 | /* defined here to avoid adding to pci_ids.h for single instance use */ | 34 | /* defined here to avoid adding to pci_ids.h for single instance use */ |
26 | #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 | 35 | #define PCI_DEVICE_ID_INTEL_CE4100_USB 0x2e70 |
@@ -103,7 +112,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
103 | } | 112 | } |
104 | break; | 113 | break; |
105 | case PCI_VENDOR_ID_INTEL: | 114 | case PCI_VENDOR_ID_INTEL: |
106 | ehci->fs_i_thresh = 1; | ||
107 | if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) | 115 | if (pdev->device == PCI_DEVICE_ID_INTEL_CE4100_USB) |
108 | hcd->has_tt = 1; | 116 | hcd->has_tt = 1; |
109 | break; | 117 | break; |
@@ -203,11 +211,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
203 | break; | 211 | break; |
204 | case PCI_VENDOR_ID_INTEL: | 212 | case PCI_VENDOR_ID_INTEL: |
205 | ehci->need_io_watchdog = 0; | 213 | ehci->need_io_watchdog = 0; |
206 | if (pdev->device == 0x0806 || pdev->device == 0x0811 | ||
207 | || pdev->device == 0x0829) { | ||
208 | ehci_info(ehci, "disable lpm for langwell/penwell\n"); | ||
209 | ehci->has_lpm = 0; | ||
210 | } | ||
211 | break; | 214 | break; |
212 | case PCI_VENDOR_ID_NVIDIA: | 215 | case PCI_VENDOR_ID_NVIDIA: |
213 | switch (pdev->device) { | 216 | switch (pdev->device) { |
@@ -217,8 +220,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
217 | * devices with PPCD enabled. | 220 | * devices with PPCD enabled. |
218 | */ | 221 | */ |
219 | case 0x0d9d: | 222 | case 0x0d9d: |
220 | ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89"); | 223 | ehci_info(ehci, "disable ppcd for nvidia mcp89\n"); |
221 | ehci->has_lpm = 0; | ||
222 | ehci->has_ppcd = 0; | 224 | ehci->has_ppcd = 0; |
223 | ehci->command &= ~CMD_PPCEE; | 225 | ehci->command &= ~CMD_PPCEE; |
224 | break; | 226 | break; |
@@ -304,7 +306,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
304 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); | 306 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); |
305 | #endif | 307 | #endif |
306 | 308 | ||
307 | ehci_port_power(ehci, 1); | ||
308 | retval = ehci_pci_reinit(ehci, pdev); | 309 | retval = ehci_pci_reinit(ehci, pdev); |
309 | done: | 310 | done: |
310 | return retval; | 311 | return retval; |
@@ -323,11 +324,6 @@ done: | |||
323 | * Also they depend on separate root hub suspend/resume. | 324 | * Also they depend on separate root hub suspend/resume. |
324 | */ | 325 | */ |
325 | 326 | ||
326 | static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) | ||
327 | { | ||
328 | return ehci_suspend(hcd, do_wakeup); | ||
329 | } | ||
330 | |||
331 | static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) | 327 | static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) |
332 | { | 328 | { |
333 | return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && | 329 | return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && |
@@ -378,76 +374,17 @@ static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
378 | (void) ehci_pci_reinit(ehci, pdev); | 374 | (void) ehci_pci_reinit(ehci, pdev); |
379 | return 0; | 375 | return 0; |
380 | } | 376 | } |
381 | #endif | ||
382 | 377 | ||
383 | static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) | 378 | #else |
384 | { | ||
385 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
386 | int rc = 0; | ||
387 | |||
388 | if (!udev->parent) /* udev is root hub itself, impossible */ | ||
389 | rc = -1; | ||
390 | /* we only support lpm device connected to root hub yet */ | ||
391 | if (ehci->has_lpm && !udev->parent->parent) { | ||
392 | rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum); | ||
393 | if (!rc) | ||
394 | rc = ehci_lpm_check(ehci, udev->portnum); | ||
395 | } | ||
396 | return rc; | ||
397 | } | ||
398 | 379 | ||
399 | static const struct hc_driver ehci_pci_hc_driver = { | 380 | #define ehci_suspend NULL |
400 | .description = hcd_name, | 381 | #define ehci_pci_resume NULL |
401 | .product_desc = "EHCI Host Controller", | 382 | #endif /* CONFIG_PM */ |
402 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
403 | 383 | ||
404 | /* | 384 | static struct hc_driver __read_mostly ehci_pci_hc_driver; |
405 | * generic hardware linkage | ||
406 | */ | ||
407 | .irq = ehci_irq, | ||
408 | .flags = HCD_MEMORY | HCD_USB2, | ||
409 | 385 | ||
410 | /* | 386 | static const struct ehci_driver_overrides pci_overrides __initdata = { |
411 | * basic lifecycle operations | ||
412 | */ | ||
413 | .reset = ehci_pci_setup, | 387 | .reset = ehci_pci_setup, |
414 | .start = ehci_run, | ||
415 | #ifdef CONFIG_PM | ||
416 | .pci_suspend = ehci_pci_suspend, | ||
417 | .pci_resume = ehci_pci_resume, | ||
418 | #endif | ||
419 | .stop = ehci_stop, | ||
420 | .shutdown = ehci_shutdown, | ||
421 | |||
422 | /* | ||
423 | * managing i/o requests and associated device resources | ||
424 | */ | ||
425 | .urb_enqueue = ehci_urb_enqueue, | ||
426 | .urb_dequeue = ehci_urb_dequeue, | ||
427 | .endpoint_disable = ehci_endpoint_disable, | ||
428 | .endpoint_reset = ehci_endpoint_reset, | ||
429 | |||
430 | /* | ||
431 | * scheduling support | ||
432 | */ | ||
433 | .get_frame_number = ehci_get_frame, | ||
434 | |||
435 | /* | ||
436 | * root hub support | ||
437 | */ | ||
438 | .hub_status_data = ehci_hub_status_data, | ||
439 | .hub_control = ehci_hub_control, | ||
440 | .bus_suspend = ehci_bus_suspend, | ||
441 | .bus_resume = ehci_bus_resume, | ||
442 | .relinquish_port = ehci_relinquish_port, | ||
443 | .port_handed_over = ehci_port_handed_over, | ||
444 | |||
445 | /* | ||
446 | * call back when device connected and addressed | ||
447 | */ | ||
448 | .update_device = ehci_update_device, | ||
449 | |||
450 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
451 | }; | 388 | }; |
452 | 389 | ||
453 | /*-------------------------------------------------------------------------*/ | 390 | /*-------------------------------------------------------------------------*/ |
@@ -480,3 +417,31 @@ static struct pci_driver ehci_pci_driver = { | |||
480 | }, | 417 | }, |
481 | #endif | 418 | #endif |
482 | }; | 419 | }; |
420 | |||
421 | static int __init ehci_pci_init(void) | ||
422 | { | ||
423 | if (usb_disabled()) | ||
424 | return -ENODEV; | ||
425 | |||
426 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
427 | |||
428 | ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides); | ||
429 | |||
430 | /* Entries for the PCI suspend/resume callbacks are special */ | ||
431 | ehci_pci_hc_driver.pci_suspend = ehci_suspend; | ||
432 | ehci_pci_hc_driver.pci_resume = ehci_pci_resume; | ||
433 | |||
434 | return pci_register_driver(&ehci_pci_driver); | ||
435 | } | ||
436 | module_init(ehci_pci_init); | ||
437 | |||
438 | static void __exit ehci_pci_cleanup(void) | ||
439 | { | ||
440 | pci_unregister_driver(&ehci_pci_driver); | ||
441 | } | ||
442 | module_exit(ehci_pci_cleanup); | ||
443 | |||
444 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
445 | MODULE_AUTHOR("David Brownell"); | ||
446 | MODULE_AUTHOR("Alan Stern"); | ||
447 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 764e0100b6f4..f14c542b142f 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -18,9 +18,21 @@ | |||
18 | * | 18 | * |
19 | * Licensed under the GNU/GPL. See COPYING for details. | 19 | * Licensed under the GNU/GPL. See COPYING for details. |
20 | */ | 20 | */ |
21 | #include <linux/kernel.h> | ||
22 | #include <linux/hrtimer.h> | ||
23 | #include <linux/io.h> | ||
24 | #include <linux/module.h> | ||
21 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/usb.h> | ||
27 | #include <linux/usb/hcd.h> | ||
22 | #include <linux/usb/ehci_pdriver.h> | 28 | #include <linux/usb/ehci_pdriver.h> |
23 | 29 | ||
30 | #include "ehci.h" | ||
31 | |||
32 | #define DRIVER_DESC "EHCI generic platform driver" | ||
33 | |||
34 | static const char hcd_name[] = "ehci-platform"; | ||
35 | |||
24 | static int ehci_platform_reset(struct usb_hcd *hcd) | 36 | static int ehci_platform_reset(struct usb_hcd *hcd) |
25 | { | 37 | { |
26 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | 38 | struct platform_device *pdev = to_platform_device(hcd->self.controller); |
@@ -38,44 +50,15 @@ static int ehci_platform_reset(struct usb_hcd *hcd) | |||
38 | if (retval) | 50 | if (retval) |
39 | return retval; | 51 | return retval; |
40 | 52 | ||
41 | if (pdata->port_power_on) | 53 | if (pdata->no_io_watchdog) |
42 | ehci_port_power(ehci, 1); | 54 | ehci->need_io_watchdog = 0; |
43 | if (pdata->port_power_off) | ||
44 | ehci_port_power(ehci, 0); | ||
45 | |||
46 | return 0; | 55 | return 0; |
47 | } | 56 | } |
48 | 57 | ||
49 | static const struct hc_driver ehci_platform_hc_driver = { | 58 | static struct hc_driver __read_mostly ehci_platform_hc_driver; |
50 | .description = hcd_name, | ||
51 | .product_desc = "Generic Platform EHCI Controller", | ||
52 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
53 | |||
54 | .irq = ehci_irq, | ||
55 | .flags = HCD_MEMORY | HCD_USB2, | ||
56 | |||
57 | .reset = ehci_platform_reset, | ||
58 | .start = ehci_run, | ||
59 | .stop = ehci_stop, | ||
60 | .shutdown = ehci_shutdown, | ||
61 | |||
62 | .urb_enqueue = ehci_urb_enqueue, | ||
63 | .urb_dequeue = ehci_urb_dequeue, | ||
64 | .endpoint_disable = ehci_endpoint_disable, | ||
65 | .endpoint_reset = ehci_endpoint_reset, | ||
66 | 59 | ||
67 | .get_frame_number = ehci_get_frame, | 60 | static const struct ehci_driver_overrides platform_overrides __initdata = { |
68 | 61 | .reset = ehci_platform_reset, | |
69 | .hub_status_data = ehci_hub_status_data, | ||
70 | .hub_control = ehci_hub_control, | ||
71 | #if defined(CONFIG_PM) | ||
72 | .bus_suspend = ehci_bus_suspend, | ||
73 | .bus_resume = ehci_bus_resume, | ||
74 | #endif | ||
75 | .relinquish_port = ehci_relinquish_port, | ||
76 | .port_handed_over = ehci_port_handed_over, | ||
77 | |||
78 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
79 | }; | 62 | }; |
80 | 63 | ||
81 | static int __devinit ehci_platform_probe(struct platform_device *dev) | 64 | static int __devinit ehci_platform_probe(struct platform_device *dev) |
@@ -96,12 +79,12 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
96 | 79 | ||
97 | irq = platform_get_irq(dev, 0); | 80 | irq = platform_get_irq(dev, 0); |
98 | if (irq < 0) { | 81 | if (irq < 0) { |
99 | pr_err("no irq provided"); | 82 | dev_err(&dev->dev, "no irq provided"); |
100 | return irq; | 83 | return irq; |
101 | } | 84 | } |
102 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | 85 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); |
103 | if (!res_mem) { | 86 | if (!res_mem) { |
104 | pr_err("no memory recourse provided"); | 87 | dev_err(&dev->dev, "no memory resource provided"); |
105 | return -ENXIO; | 88 | return -ENXIO; |
106 | } | 89 | } |
107 | 90 | ||
@@ -121,29 +104,19 @@ static int __devinit ehci_platform_probe(struct platform_device *dev) | |||
121 | hcd->rsrc_start = res_mem->start; | 104 | hcd->rsrc_start = res_mem->start; |
122 | hcd->rsrc_len = resource_size(res_mem); | 105 | hcd->rsrc_len = resource_size(res_mem); |
123 | 106 | ||
124 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 107 | hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem); |
125 | pr_err("controller already in use"); | ||
126 | err = -EBUSY; | ||
127 | goto err_put_hcd; | ||
128 | } | ||
129 | |||
130 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
131 | if (!hcd->regs) { | 108 | if (!hcd->regs) { |
132 | err = -ENOMEM; | 109 | err = -ENOMEM; |
133 | goto err_release_region; | 110 | goto err_put_hcd; |
134 | } | 111 | } |
135 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 112 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
136 | if (err) | 113 | if (err) |
137 | goto err_iounmap; | 114 | goto err_put_hcd; |
138 | 115 | ||
139 | platform_set_drvdata(dev, hcd); | 116 | platform_set_drvdata(dev, hcd); |
140 | 117 | ||
141 | return err; | 118 | return err; |
142 | 119 | ||
143 | err_iounmap: | ||
144 | iounmap(hcd->regs); | ||
145 | err_release_region: | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | err_put_hcd: | 120 | err_put_hcd: |
148 | usb_put_hcd(hcd); | 121 | usb_put_hcd(hcd); |
149 | err_power: | 122 | err_power: |
@@ -159,8 +132,6 @@ static int __devexit ehci_platform_remove(struct platform_device *dev) | |||
159 | struct usb_ehci_pdata *pdata = dev->dev.platform_data; | 132 | struct usb_ehci_pdata *pdata = dev->dev.platform_data; |
160 | 133 | ||
161 | usb_remove_hcd(hcd); | 134 | usb_remove_hcd(hcd); |
162 | iounmap(hcd->regs); | ||
163 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
164 | usb_put_hcd(hcd); | 135 | usb_put_hcd(hcd); |
165 | platform_set_drvdata(dev, NULL); | 136 | platform_set_drvdata(dev, NULL); |
166 | 137 | ||
@@ -233,3 +204,26 @@ static struct platform_driver ehci_platform_driver = { | |||
233 | .pm = &ehci_platform_pm_ops, | 204 | .pm = &ehci_platform_pm_ops, |
234 | } | 205 | } |
235 | }; | 206 | }; |
207 | |||
208 | static int __init ehci_platform_init(void) | ||
209 | { | ||
210 | if (usb_disabled()) | ||
211 | return -ENODEV; | ||
212 | |||
213 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
214 | |||
215 | ehci_init_driver(&ehci_platform_hc_driver, &platform_overrides); | ||
216 | return platform_driver_register(&ehci_platform_driver); | ||
217 | } | ||
218 | module_init(ehci_platform_init); | ||
219 | |||
220 | static void __exit ehci_platform_cleanup(void) | ||
221 | { | ||
222 | platform_driver_unregister(&ehci_platform_driver); | ||
223 | } | ||
224 | module_exit(ehci_platform_cleanup); | ||
225 | |||
226 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
227 | MODULE_AUTHOR("Hauke Mehrtens"); | ||
228 | MODULE_AUTHOR("Alan Stern"); | ||
229 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/host/ehci-pmcmsp.c b/drivers/usb/host/ehci-pmcmsp.c index 087aee2a904f..363890ee41d2 100644 --- a/drivers/usb/host/ehci-pmcmsp.c +++ b/drivers/usb/host/ehci-pmcmsp.c | |||
@@ -90,7 +90,6 @@ static int ehci_msp_setup(struct usb_hcd *hcd) | |||
90 | return retval; | 90 | return retval; |
91 | 91 | ||
92 | usb_hcd_tdi_set_mode(ehci); | 92 | usb_hcd_tdi_set_mode(ehci); |
93 | ehci_port_power(ehci, 0); | ||
94 | 93 | ||
95 | return retval; | 94 | return retval; |
96 | } | 95 | } |
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 4b66374bdc8e..3d989028c836 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -264,15 +264,9 @@ ehci_urb_done(struct ehci_hcd *ehci, struct urb *urb, int status) | |||
264 | __releases(ehci->lock) | 264 | __releases(ehci->lock) |
265 | __acquires(ehci->lock) | 265 | __acquires(ehci->lock) |
266 | { | 266 | { |
267 | if (likely (urb->hcpriv != NULL)) { | 267 | if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) { |
268 | struct ehci_qh *qh = (struct ehci_qh *) urb->hcpriv; | 268 | /* ... update hc-wide periodic stats */ |
269 | 269 | ehci_to_hcd(ehci)->self.bandwidth_int_reqs--; | |
270 | /* S-mask in a QH means it's an interrupt urb */ | ||
271 | if ((qh->hw->hw_info2 & cpu_to_hc32(ehci, QH_SMASK)) != 0) { | ||
272 | |||
273 | /* ... update hc-wide periodic stats (for usbfs) */ | ||
274 | ehci_to_hcd(ehci)->self.bandwidth_int_reqs--; | ||
275 | } | ||
276 | } | 270 | } |
277 | 271 | ||
278 | if (unlikely(urb->unlinked)) { | 272 | if (unlikely(urb->unlinked)) { |
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 85b74be202eb..abc178d21fe4 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
@@ -136,7 +136,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
136 | goto fail_clk; | 136 | goto fail_clk; |
137 | } | 137 | } |
138 | 138 | ||
139 | err = clk_enable(s5p_ehci->clk); | 139 | err = clk_prepare_enable(s5p_ehci->clk); |
140 | if (err) | 140 | if (err) |
141 | goto fail_clk; | 141 | goto fail_clk; |
142 | 142 | ||
@@ -183,7 +183,7 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
183 | return 0; | 183 | return 0; |
184 | 184 | ||
185 | fail_io: | 185 | fail_io: |
186 | clk_disable(s5p_ehci->clk); | 186 | clk_disable_unprepare(s5p_ehci->clk); |
187 | fail_clk: | 187 | fail_clk: |
188 | usb_put_hcd(hcd); | 188 | usb_put_hcd(hcd); |
189 | return err; | 189 | return err; |
@@ -200,7 +200,7 @@ static int __devexit s5p_ehci_remove(struct platform_device *pdev) | |||
200 | if (pdata && pdata->phy_exit) | 200 | if (pdata && pdata->phy_exit) |
201 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | 201 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); |
202 | 202 | ||
203 | clk_disable(s5p_ehci->clk); | 203 | clk_disable_unprepare(s5p_ehci->clk); |
204 | 204 | ||
205 | usb_put_hcd(hcd); | 205 | usb_put_hcd(hcd); |
206 | 206 | ||
@@ -231,7 +231,7 @@ static int s5p_ehci_suspend(struct device *dev) | |||
231 | if (pdata && pdata->phy_exit) | 231 | if (pdata && pdata->phy_exit) |
232 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | 232 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); |
233 | 233 | ||
234 | clk_disable(s5p_ehci->clk); | 234 | clk_disable_unprepare(s5p_ehci->clk); |
235 | 235 | ||
236 | return rc; | 236 | return rc; |
237 | } | 237 | } |
@@ -243,7 +243,7 @@ static int s5p_ehci_resume(struct device *dev) | |||
243 | struct platform_device *pdev = to_platform_device(dev); | 243 | struct platform_device *pdev = to_platform_device(dev); |
244 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; | 244 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; |
245 | 245 | ||
246 | clk_enable(s5p_ehci->clk); | 246 | clk_prepare_enable(s5p_ehci->clk); |
247 | 247 | ||
248 | if (pdata && pdata->phy_init) | 248 | if (pdata && pdata->phy_init) |
249 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | 249 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 7cf3da7babf0..69ebee73c0c1 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -36,29 +36,6 @@ | |||
36 | 36 | ||
37 | static int ehci_get_frame (struct usb_hcd *hcd); | 37 | static int ehci_get_frame (struct usb_hcd *hcd); |
38 | 38 | ||
39 | #ifdef CONFIG_PCI | ||
40 | |||
41 | static unsigned ehci_read_frame_index(struct ehci_hcd *ehci) | ||
42 | { | ||
43 | unsigned uf; | ||
44 | |||
45 | /* | ||
46 | * The MosChip MCS9990 controller updates its microframe counter | ||
47 | * a little before the frame counter, and occasionally we will read | ||
48 | * the invalid intermediate value. Avoid problems by checking the | ||
49 | * microframe number (the low-order 3 bits); if they are 0 then | ||
50 | * re-read the register to get the correct value. | ||
51 | */ | ||
52 | uf = ehci_readl(ehci, &ehci->regs->frame_index); | ||
53 | if (unlikely(ehci->frame_index_bug && ((uf & 7) == 0))) | ||
54 | uf = ehci_readl(ehci, &ehci->regs->frame_index); | ||
55 | return uf; | ||
56 | } | ||
57 | |||
58 | #endif | ||
59 | |||
60 | /*-------------------------------------------------------------------------*/ | ||
61 | |||
62 | /* | 39 | /* |
63 | * periodic_next_shadow - return "next" pointer on shadow list | 40 | * periodic_next_shadow - return "next" pointer on shadow list |
64 | * @periodic: host pointer to qh/itd/sitd | 41 | * @periodic: host pointer to qh/itd/sitd |
@@ -1361,7 +1338,7 @@ sitd_slot_ok ( | |||
1361 | * given EHCI_TUNE_FLS and the slop). Or, write a smarter scheduler! | 1338 | * given EHCI_TUNE_FLS and the slop). Or, write a smarter scheduler! |
1362 | */ | 1339 | */ |
1363 | 1340 | ||
1364 | #define SCHEDULE_SLOP 80 /* microframes */ | 1341 | #define SCHEDULING_DELAY 40 /* microframes */ |
1365 | 1342 | ||
1366 | static int | 1343 | static int |
1367 | iso_stream_schedule ( | 1344 | iso_stream_schedule ( |
@@ -1370,7 +1347,7 @@ iso_stream_schedule ( | |||
1370 | struct ehci_iso_stream *stream | 1347 | struct ehci_iso_stream *stream |
1371 | ) | 1348 | ) |
1372 | { | 1349 | { |
1373 | u32 now, next, start, period, span; | 1350 | u32 now, base, next, start, period, span; |
1374 | int status; | 1351 | int status; |
1375 | unsigned mod = ehci->periodic_size << 3; | 1352 | unsigned mod = ehci->periodic_size << 3; |
1376 | struct ehci_iso_sched *sched = urb->hcpriv; | 1353 | struct ehci_iso_sched *sched = urb->hcpriv; |
@@ -1382,62 +1359,72 @@ iso_stream_schedule ( | |||
1382 | span <<= 3; | 1359 | span <<= 3; |
1383 | } | 1360 | } |
1384 | 1361 | ||
1385 | if (span > mod - SCHEDULE_SLOP) { | ||
1386 | ehci_dbg (ehci, "iso request %p too long\n", urb); | ||
1387 | status = -EFBIG; | ||
1388 | goto fail; | ||
1389 | } | ||
1390 | |||
1391 | now = ehci_read_frame_index(ehci) & (mod - 1); | 1362 | now = ehci_read_frame_index(ehci) & (mod - 1); |
1392 | 1363 | ||
1393 | /* Typical case: reuse current schedule, stream is still active. | 1364 | /* Typical case: reuse current schedule, stream is still active. |
1394 | * Hopefully there are no gaps from the host falling behind | 1365 | * Hopefully there are no gaps from the host falling behind |
1395 | * (irq delays etc), but if there are we'll take the next | 1366 | * (irq delays etc). If there are, the behavior depends on |
1396 | * slot in the schedule, implicitly assuming URB_ISO_ASAP. | 1367 | * whether URB_ISO_ASAP is set. |
1397 | */ | 1368 | */ |
1398 | if (likely (!list_empty (&stream->td_list))) { | 1369 | if (likely (!list_empty (&stream->td_list))) { |
1399 | u32 excess; | ||
1400 | 1370 | ||
1401 | /* For high speed devices, allow scheduling within the | 1371 | /* Take the isochronous scheduling threshold into account */ |
1402 | * isochronous scheduling threshold. For full speed devices | 1372 | if (ehci->i_thresh) |
1403 | * and Intel PCI-based controllers, don't (work around for | 1373 | next = now + ehci->i_thresh; /* uframe cache */ |
1404 | * Intel ICH9 bug). | ||
1405 | */ | ||
1406 | if (!stream->highspeed && ehci->fs_i_thresh) | ||
1407 | next = now + ehci->i_thresh; | ||
1408 | else | 1374 | else |
1409 | next = now; | 1375 | next = (now + 2 + 7) & ~0x07; /* full frame cache */ |
1410 | 1376 | ||
1411 | /* Fell behind (by up to twice the slop amount)? | 1377 | /* |
1412 | * We decide based on the time of the last currently-scheduled | 1378 | * Use ehci->last_iso_frame as the base. There can't be any |
1413 | * slot, not the time of the next available slot. | 1379 | * TDs scheduled for earlier than that. |
1414 | */ | 1380 | */ |
1415 | excess = (stream->next_uframe - period - next) & (mod - 1); | 1381 | base = ehci->last_iso_frame << 3; |
1416 | if (excess >= mod - 2 * SCHEDULE_SLOP) | 1382 | next = (next - base) & (mod - 1); |
1417 | start = next + excess - mod + period * | 1383 | start = (stream->next_uframe - base) & (mod - 1); |
1418 | DIV_ROUND_UP(mod - excess, period); | 1384 | |
1419 | else | 1385 | /* Is the schedule already full? */ |
1420 | start = next + excess + period; | 1386 | if (unlikely(start < period)) { |
1421 | if (start - now >= mod) { | 1387 | ehci_dbg(ehci, "iso sched full %p (%u-%u < %u mod %u)\n", |
1422 | ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", | 1388 | urb, stream->next_uframe, base, |
1423 | urb, start - now - period, period, | 1389 | period, mod); |
1424 | mod); | 1390 | status = -ENOSPC; |
1425 | status = -EFBIG; | ||
1426 | goto fail; | 1391 | goto fail; |
1427 | } | 1392 | } |
1393 | |||
1394 | /* Behind the scheduling threshold? */ | ||
1395 | if (unlikely(start < next)) { | ||
1396 | |||
1397 | /* USB_ISO_ASAP: Round up to the first available slot */ | ||
1398 | if (urb->transfer_flags & URB_ISO_ASAP) | ||
1399 | start += (next - start + period - 1) & -period; | ||
1400 | |||
1401 | /* | ||
1402 | * Not ASAP: Use the next slot in the stream. If | ||
1403 | * the entire URB falls before the threshold, fail. | ||
1404 | */ | ||
1405 | else if (start + span - period < next) { | ||
1406 | ehci_dbg(ehci, "iso urb late %p (%u+%u < %u)\n", | ||
1407 | urb, start + base, | ||
1408 | span - period, next + base); | ||
1409 | status = -EXDEV; | ||
1410 | goto fail; | ||
1411 | } | ||
1412 | } | ||
1413 | |||
1414 | start += base; | ||
1428 | } | 1415 | } |
1429 | 1416 | ||
1430 | /* need to schedule; when's the next (u)frame we could start? | 1417 | /* need to schedule; when's the next (u)frame we could start? |
1431 | * this is bigger than ehci->i_thresh allows; scheduling itself | 1418 | * this is bigger than ehci->i_thresh allows; scheduling itself |
1432 | * isn't free, the slop should handle reasonably slow cpus. it | 1419 | * isn't free, the delay should handle reasonably slow cpus. it |
1433 | * can also help high bandwidth if the dma and irq loads don't | 1420 | * can also help high bandwidth if the dma and irq loads don't |
1434 | * jump until after the queue is primed. | 1421 | * jump until after the queue is primed. |
1435 | */ | 1422 | */ |
1436 | else { | 1423 | else { |
1437 | int done = 0; | 1424 | int done = 0; |
1438 | start = SCHEDULE_SLOP + (now & ~0x07); | ||
1439 | 1425 | ||
1440 | /* NOTE: assumes URB_ISO_ASAP, to limit complexity/bugs */ | 1426 | base = now & ~0x07; |
1427 | start = base + SCHEDULING_DELAY; | ||
1441 | 1428 | ||
1442 | /* find a uframe slot with enough bandwidth. | 1429 | /* find a uframe slot with enough bandwidth. |
1443 | * Early uframes are more precious because full-speed | 1430 | * Early uframes are more precious because full-speed |
@@ -1464,19 +1451,16 @@ iso_stream_schedule ( | |||
1464 | 1451 | ||
1465 | /* no room in the schedule */ | 1452 | /* no room in the schedule */ |
1466 | if (!done) { | 1453 | if (!done) { |
1467 | ehci_dbg(ehci, "iso resched full %p (now %d max %d)\n", | 1454 | ehci_dbg(ehci, "iso sched full %p", urb); |
1468 | urb, now, now + mod); | ||
1469 | status = -ENOSPC; | 1455 | status = -ENOSPC; |
1470 | goto fail; | 1456 | goto fail; |
1471 | } | 1457 | } |
1472 | } | 1458 | } |
1473 | 1459 | ||
1474 | /* Tried to schedule too far into the future? */ | 1460 | /* Tried to schedule too far into the future? */ |
1475 | if (unlikely(start - now + span - period | 1461 | if (unlikely(start - base + span - period >= mod)) { |
1476 | >= mod - 2 * SCHEDULE_SLOP)) { | 1462 | ehci_dbg(ehci, "request %p would overflow (%u+%u >= %u)\n", |
1477 | ehci_dbg(ehci, "request %p would overflow (%d+%d >= %d)\n", | 1463 | urb, start - base, span - period, mod); |
1478 | urb, start - now, span - period, | ||
1479 | mod - 2 * SCHEDULE_SLOP); | ||
1480 | status = -EFBIG; | 1464 | status = -EFBIG; |
1481 | goto fail; | 1465 | goto fail; |
1482 | } | 1466 | } |
@@ -1490,7 +1474,7 @@ iso_stream_schedule ( | |||
1490 | 1474 | ||
1491 | /* Make sure scan_isoc() sees these */ | 1475 | /* Make sure scan_isoc() sees these */ |
1492 | if (ehci->isoc_count == 0) | 1476 | if (ehci->isoc_count == 0) |
1493 | ehci->next_frame = now >> 3; | 1477 | ehci->last_iso_frame = now >> 3; |
1494 | return 0; | 1478 | return 0; |
1495 | 1479 | ||
1496 | fail: | 1480 | fail: |
@@ -1646,7 +1630,7 @@ static void itd_link_urb( | |||
1646 | 1630 | ||
1647 | /* don't need that schedule data any more */ | 1631 | /* don't need that schedule data any more */ |
1648 | iso_sched_free (stream, iso_sched); | 1632 | iso_sched_free (stream, iso_sched); |
1649 | urb->hcpriv = NULL; | 1633 | urb->hcpriv = stream; |
1650 | 1634 | ||
1651 | ++ehci->isoc_count; | 1635 | ++ehci->isoc_count; |
1652 | enable_periodic(ehci); | 1636 | enable_periodic(ehci); |
@@ -1708,7 +1692,7 @@ static bool itd_complete(struct ehci_hcd *ehci, struct ehci_itd *itd) | |||
1708 | urb->actual_length += desc->actual_length; | 1692 | urb->actual_length += desc->actual_length; |
1709 | } else { | 1693 | } else { |
1710 | /* URB was too late */ | 1694 | /* URB was too late */ |
1711 | desc->status = -EXDEV; | 1695 | urb->error_count++; |
1712 | } | 1696 | } |
1713 | } | 1697 | } |
1714 | 1698 | ||
@@ -2045,7 +2029,7 @@ static void sitd_link_urb( | |||
2045 | 2029 | ||
2046 | /* don't need that schedule data any more */ | 2030 | /* don't need that schedule data any more */ |
2047 | iso_sched_free (stream, sched); | 2031 | iso_sched_free (stream, sched); |
2048 | urb->hcpriv = NULL; | 2032 | urb->hcpriv = stream; |
2049 | 2033 | ||
2050 | ++ehci->isoc_count; | 2034 | ++ehci->isoc_count; |
2051 | enable_periodic(ehci); | 2035 | enable_periodic(ehci); |
@@ -2081,7 +2065,7 @@ static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd) | |||
2081 | t = hc32_to_cpup(ehci, &sitd->hw_results); | 2065 | t = hc32_to_cpup(ehci, &sitd->hw_results); |
2082 | 2066 | ||
2083 | /* report transfer status */ | 2067 | /* report transfer status */ |
2084 | if (t & SITD_ERRS) { | 2068 | if (unlikely(t & SITD_ERRS)) { |
2085 | urb->error_count++; | 2069 | urb->error_count++; |
2086 | if (t & SITD_STS_DBE) | 2070 | if (t & SITD_STS_DBE) |
2087 | desc->status = usb_pipein (urb->pipe) | 2071 | desc->status = usb_pipein (urb->pipe) |
@@ -2091,6 +2075,9 @@ static bool sitd_complete(struct ehci_hcd *ehci, struct ehci_sitd *sitd) | |||
2091 | desc->status = -EOVERFLOW; | 2075 | desc->status = -EOVERFLOW; |
2092 | else /* XACT, MMF, etc */ | 2076 | else /* XACT, MMF, etc */ |
2093 | desc->status = -EPROTO; | 2077 | desc->status = -EPROTO; |
2078 | } else if (unlikely(t & SITD_STS_ACTIVE)) { | ||
2079 | /* URB was too late */ | ||
2080 | urb->error_count++; | ||
2094 | } else { | 2081 | } else { |
2095 | desc->status = 0; | 2082 | desc->status = 0; |
2096 | desc->actual_length = desc->length - SITD_LENGTH(t); | 2083 | desc->actual_length = desc->length - SITD_LENGTH(t); |
@@ -2220,16 +2207,16 @@ static void scan_isoc(struct ehci_hcd *ehci) | |||
2220 | now_frame = (uf >> 3) & fmask; | 2207 | now_frame = (uf >> 3) & fmask; |
2221 | live = true; | 2208 | live = true; |
2222 | } else { | 2209 | } else { |
2223 | now_frame = (ehci->next_frame - 1) & fmask; | 2210 | now_frame = (ehci->last_iso_frame - 1) & fmask; |
2224 | live = false; | 2211 | live = false; |
2225 | } | 2212 | } |
2226 | ehci->now_frame = now_frame; | 2213 | ehci->now_frame = now_frame; |
2227 | 2214 | ||
2228 | frame = ehci->next_frame; | ||
2229 | for (;;) { | 2215 | for (;;) { |
2230 | union ehci_shadow q, *q_p; | 2216 | union ehci_shadow q, *q_p; |
2231 | __hc32 type, *hw_p; | 2217 | __hc32 type, *hw_p; |
2232 | 2218 | ||
2219 | frame = ehci->last_iso_frame; | ||
2233 | restart: | 2220 | restart: |
2234 | /* scan each element in frame's queue for completions */ | 2221 | /* scan each element in frame's queue for completions */ |
2235 | q_p = &ehci->pshadow [frame]; | 2222 | q_p = &ehci->pshadow [frame]; |
@@ -2334,7 +2321,6 @@ restart: | |||
2334 | /* Stop when we have reached the current frame */ | 2321 | /* Stop when we have reached the current frame */ |
2335 | if (frame == now_frame) | 2322 | if (frame == now_frame) |
2336 | break; | 2323 | break; |
2337 | frame = (frame + 1) & fmask; | 2324 | ehci->last_iso_frame = (frame + 1) & fmask; |
2338 | } | 2325 | } |
2339 | ehci->next_frame = now_frame; | ||
2340 | } | 2326 | } |
diff --git a/drivers/usb/host/ehci-sh.c b/drivers/usb/host/ehci-sh.c index 6081e1ed3ac9..0c90a24fa989 100644 --- a/drivers/usb/host/ehci-sh.c +++ b/drivers/usb/host/ehci-sh.c | |||
@@ -21,17 +21,10 @@ struct ehci_sh_priv { | |||
21 | static int ehci_sh_reset(struct usb_hcd *hcd) | 21 | static int ehci_sh_reset(struct usb_hcd *hcd) |
22 | { | 22 | { |
23 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 23 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
24 | int ret; | ||
25 | 24 | ||
26 | ehci->caps = hcd->regs; | 25 | ehci->caps = hcd->regs; |
27 | 26 | ||
28 | ret = ehci_setup(hcd); | 27 | return ehci_setup(hcd); |
29 | if (unlikely(ret)) | ||
30 | return ret; | ||
31 | |||
32 | ehci_port_power(ehci, 0); | ||
33 | |||
34 | return ret; | ||
35 | } | 28 | } |
36 | 29 | ||
37 | static const struct hc_driver ehci_sh_hc_driver = { | 30 | static const struct hc_driver ehci_sh_hc_driver = { |
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index c718a065e154..3fadff8f8d30 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c | |||
@@ -37,18 +37,11 @@ static void spear_stop_ehci(struct spear_ehci *ehci) | |||
37 | static int ehci_spear_setup(struct usb_hcd *hcd) | 37 | static int ehci_spear_setup(struct usb_hcd *hcd) |
38 | { | 38 | { |
39 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 39 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
40 | int retval = 0; | ||
41 | 40 | ||
42 | /* registers start at offset 0x0 */ | 41 | /* registers start at offset 0x0 */ |
43 | ehci->caps = hcd->regs; | 42 | ehci->caps = hcd->regs; |
44 | 43 | ||
45 | retval = ehci_setup(hcd); | 44 | return ehci_setup(hcd); |
46 | if (retval) | ||
47 | return retval; | ||
48 | |||
49 | ehci_port_power(ehci, 0); | ||
50 | |||
51 | return retval; | ||
52 | } | 45 | } |
53 | 46 | ||
54 | static const struct hc_driver ehci_spear_hc_driver = { | 47 | static const struct hc_driver ehci_spear_hc_driver = { |
@@ -116,8 +109,6 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
116 | struct clk *usbh_clk; | 109 | struct clk *usbh_clk; |
117 | const struct hc_driver *driver = &ehci_spear_hc_driver; | 110 | const struct hc_driver *driver = &ehci_spear_hc_driver; |
118 | int irq, retval; | 111 | int irq, retval; |
119 | char clk_name[20] = "usbh_clk"; | ||
120 | static int instance = -1; | ||
121 | 112 | ||
122 | if (usb_disabled()) | 113 | if (usb_disabled()) |
123 | return -ENODEV; | 114 | return -ENODEV; |
@@ -125,7 +116,7 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
125 | irq = platform_get_irq(pdev, 0); | 116 | irq = platform_get_irq(pdev, 0); |
126 | if (irq < 0) { | 117 | if (irq < 0) { |
127 | retval = irq; | 118 | retval = irq; |
128 | goto fail_irq_get; | 119 | goto fail; |
129 | } | 120 | } |
130 | 121 | ||
131 | /* | 122 | /* |
@@ -136,47 +127,38 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
136 | if (!pdev->dev.dma_mask) | 127 | if (!pdev->dev.dma_mask) |
137 | pdev->dev.dma_mask = &spear_ehci_dma_mask; | 128 | pdev->dev.dma_mask = &spear_ehci_dma_mask; |
138 | 129 | ||
139 | /* | 130 | usbh_clk = devm_clk_get(&pdev->dev, NULL); |
140 | * Increment the device instance, when probing via device-tree | ||
141 | */ | ||
142 | if (pdev->id < 0) | ||
143 | instance++; | ||
144 | else | ||
145 | instance = pdev->id; | ||
146 | sprintf(clk_name, "usbh.%01d_clk", instance); | ||
147 | |||
148 | usbh_clk = clk_get(NULL, clk_name); | ||
149 | if (IS_ERR(usbh_clk)) { | 131 | if (IS_ERR(usbh_clk)) { |
150 | dev_err(&pdev->dev, "Error getting interface clock\n"); | 132 | dev_err(&pdev->dev, "Error getting interface clock\n"); |
151 | retval = PTR_ERR(usbh_clk); | 133 | retval = PTR_ERR(usbh_clk); |
152 | goto fail_get_usbh_clk; | 134 | goto fail; |
153 | } | 135 | } |
154 | 136 | ||
155 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | 137 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); |
156 | if (!hcd) { | 138 | if (!hcd) { |
157 | retval = -ENOMEM; | 139 | retval = -ENOMEM; |
158 | goto fail_create_hcd; | 140 | goto fail; |
159 | } | 141 | } |
160 | 142 | ||
161 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
162 | if (!res) { | 144 | if (!res) { |
163 | retval = -ENODEV; | 145 | retval = -ENODEV; |
164 | goto fail_request_resource; | 146 | goto err_put_hcd; |
165 | } | 147 | } |
166 | 148 | ||
167 | hcd->rsrc_start = res->start; | 149 | hcd->rsrc_start = res->start; |
168 | hcd->rsrc_len = resource_size(res); | 150 | hcd->rsrc_len = resource_size(res); |
169 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | 151 | if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len, |
170 | driver->description)) { | 152 | driver->description)) { |
171 | retval = -EBUSY; | 153 | retval = -EBUSY; |
172 | goto fail_request_resource; | 154 | goto err_put_hcd; |
173 | } | 155 | } |
174 | 156 | ||
175 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 157 | hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len); |
176 | if (hcd->regs == NULL) { | 158 | if (hcd->regs == NULL) { |
177 | dev_dbg(&pdev->dev, "error mapping memory\n"); | 159 | dev_dbg(&pdev->dev, "error mapping memory\n"); |
178 | retval = -ENOMEM; | 160 | retval = -ENOMEM; |
179 | goto fail_ioremap; | 161 | goto err_put_hcd; |
180 | } | 162 | } |
181 | 163 | ||
182 | ehci = (struct spear_ehci *)hcd_to_ehci(hcd); | 164 | ehci = (struct spear_ehci *)hcd_to_ehci(hcd); |
@@ -185,21 +167,15 @@ static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | |||
185 | spear_start_ehci(ehci); | 167 | spear_start_ehci(ehci); |
186 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | 168 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); |
187 | if (retval) | 169 | if (retval) |
188 | goto fail_add_hcd; | 170 | goto err_stop_ehci; |
189 | 171 | ||
190 | return retval; | 172 | return retval; |
191 | 173 | ||
192 | fail_add_hcd: | 174 | err_stop_ehci: |
193 | spear_stop_ehci(ehci); | 175 | spear_stop_ehci(ehci); |
194 | iounmap(hcd->regs); | 176 | err_put_hcd: |
195 | fail_ioremap: | ||
196 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
197 | fail_request_resource: | ||
198 | usb_put_hcd(hcd); | 177 | usb_put_hcd(hcd); |
199 | fail_create_hcd: | 178 | fail: |
200 | clk_put(usbh_clk); | ||
201 | fail_get_usbh_clk: | ||
202 | fail_irq_get: | ||
203 | dev_err(&pdev->dev, "init fail, %d\n", retval); | 179 | dev_err(&pdev->dev, "init fail, %d\n", retval); |
204 | 180 | ||
205 | return retval ; | 181 | return retval ; |
@@ -218,13 +194,8 @@ static int spear_ehci_hcd_drv_remove(struct platform_device *pdev) | |||
218 | 194 | ||
219 | if (ehci_p->clk) | 195 | if (ehci_p->clk) |
220 | spear_stop_ehci(ehci_p); | 196 | spear_stop_ehci(ehci_p); |
221 | iounmap(hcd->regs); | ||
222 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
223 | usb_put_hcd(hcd); | 197 | usb_put_hcd(hcd); |
224 | 198 | ||
225 | if (ehci_p->clk) | ||
226 | clk_put(ehci_p->clk); | ||
227 | |||
228 | return 0; | 199 | return 0; |
229 | } | 200 | } |
230 | 201 | ||
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 6223d1757848..ef0a6ef7875b 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -28,7 +28,10 @@ | |||
28 | #include <linux/pm_runtime.h> | 28 | #include <linux/pm_runtime.h> |
29 | 29 | ||
30 | #include <linux/usb/tegra_usb_phy.h> | 30 | #include <linux/usb/tegra_usb_phy.h> |
31 | #include <mach/iomap.h> | 31 | |
32 | #define TEGRA_USB_BASE 0xC5000000 | ||
33 | #define TEGRA_USB2_BASE 0xC5004000 | ||
34 | #define TEGRA_USB3_BASE 0xC5008000 | ||
32 | 35 | ||
33 | #define TEGRA_USB_DMA_ALIGN 32 | 36 | #define TEGRA_USB_DMA_ALIGN 32 |
34 | 37 | ||
@@ -277,7 +280,6 @@ static void tegra_ehci_shutdown(struct usb_hcd *hcd) | |||
277 | static int tegra_ehci_setup(struct usb_hcd *hcd) | 280 | static int tegra_ehci_setup(struct usb_hcd *hcd) |
278 | { | 281 | { |
279 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 282 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
280 | int retval; | ||
281 | 283 | ||
282 | /* EHCI registers start at offset 0x100 */ | 284 | /* EHCI registers start at offset 0x100 */ |
283 | ehci->caps = hcd->regs + 0x100; | 285 | ehci->caps = hcd->regs + 0x100; |
@@ -285,12 +287,7 @@ static int tegra_ehci_setup(struct usb_hcd *hcd) | |||
285 | /* switch to host mode */ | 287 | /* switch to host mode */ |
286 | hcd->has_tt = 1; | 288 | hcd->has_tt = 1; |
287 | 289 | ||
288 | retval = ehci_setup(hcd); | 290 | return ehci_setup(hcd); |
289 | if (retval) | ||
290 | return retval; | ||
291 | |||
292 | ehci_port_power(ehci, 1); | ||
293 | return retval; | ||
294 | } | 291 | } |
295 | 292 | ||
296 | struct dma_aligned_buffer { | 293 | struct dma_aligned_buffer { |
@@ -778,9 +775,6 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
778 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | 775 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); |
779 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | 776 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); |
780 | 777 | ||
781 | if (tegra == NULL || hcd == NULL) | ||
782 | return -EINVAL; | ||
783 | |||
784 | pm_runtime_get_sync(&pdev->dev); | 778 | pm_runtime_get_sync(&pdev->dev); |
785 | pm_runtime_disable(&pdev->dev); | 779 | pm_runtime_disable(&pdev->dev); |
786 | pm_runtime_put_noidle(&pdev->dev); | 780 | pm_runtime_put_noidle(&pdev->dev); |
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c index d3c9a3e397b9..11695d5b9d86 100644 --- a/drivers/usb/host/ehci-vt8500.c +++ b/drivers/usb/host/ehci-vt8500.c | |||
@@ -19,22 +19,6 @@ | |||
19 | #include <linux/of.h> | 19 | #include <linux/of.h> |
20 | #include <linux/platform_device.h> | 20 | #include <linux/platform_device.h> |
21 | 21 | ||
22 | static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) | ||
23 | { | ||
24 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
25 | int rc = 0; | ||
26 | |||
27 | if (!udev->parent) /* udev is root hub itself, impossible */ | ||
28 | rc = -1; | ||
29 | /* we only support lpm device connected to root hub yet */ | ||
30 | if (ehci->has_lpm && !udev->parent->parent) { | ||
31 | rc = ehci_lpm_set_da(ehci, udev->devnum, udev->portnum); | ||
32 | if (!rc) | ||
33 | rc = ehci_lpm_check(ehci, udev->portnum); | ||
34 | } | ||
35 | return rc; | ||
36 | } | ||
37 | |||
38 | static const struct hc_driver vt8500_ehci_hc_driver = { | 22 | static const struct hc_driver vt8500_ehci_hc_driver = { |
39 | .description = hcd_name, | 23 | .description = hcd_name, |
40 | .product_desc = "VT8500 EHCI", | 24 | .product_desc = "VT8500 EHCI", |
@@ -77,11 +61,6 @@ static const struct hc_driver vt8500_ehci_hc_driver = { | |||
77 | .relinquish_port = ehci_relinquish_port, | 61 | .relinquish_port = ehci_relinquish_port, |
78 | .port_handed_over = ehci_port_handed_over, | 62 | .port_handed_over = ehci_port_handed_over, |
79 | 63 | ||
80 | /* | ||
81 | * call back when device connected and addressed | ||
82 | */ | ||
83 | .update_device = ehci_update_device, | ||
84 | |||
85 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 64 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
86 | }; | 65 | }; |
87 | 66 | ||
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c index ec598082c14b..fdd7c4873cf2 100644 --- a/drivers/usb/host/ehci-w90x900.c +++ b/drivers/usb/host/ehci-w90x900.c | |||
@@ -13,7 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | 15 | ||
16 | /*ebable phy0 and phy1 for w90p910*/ | 16 | /* enable phy0 and phy1 for w90p910 */ |
17 | #define ENPHY (0x01<<8) | 17 | #define ENPHY (0x01<<8) |
18 | #define PHY0_CTR (0xA4) | 18 | #define PHY0_CTR (0xA4) |
19 | #define PHY1_CTR (0xA8) | 19 | #define PHY1_CTR (0xA8) |
diff --git a/drivers/usb/host/ehci-xls.c b/drivers/usb/host/ehci-xls.c deleted file mode 100644 index 8dc6a22d90b8..000000000000 --- a/drivers/usb/host/ehci-xls.c +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | /* | ||
2 | * EHCI HCD for Netlogic XLS processors. | ||
3 | * | ||
4 | * (C) Copyright 2011 Netlogic Microsystems Inc. | ||
5 | * | ||
6 | * Based on various ehci-*.c drivers | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | |||
15 | static int ehci_xls_setup(struct usb_hcd *hcd) | ||
16 | { | ||
17 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
18 | |||
19 | ehci->caps = hcd->regs; | ||
20 | |||
21 | return ehci_setup(hcd); | ||
22 | } | ||
23 | |||
24 | int ehci_xls_probe_internal(const struct hc_driver *driver, | ||
25 | struct platform_device *pdev) | ||
26 | { | ||
27 | struct usb_hcd *hcd; | ||
28 | struct resource *res; | ||
29 | int retval, irq; | ||
30 | |||
31 | /* Get our IRQ from an earlier registered Platform Resource */ | ||
32 | irq = platform_get_irq(pdev, 0); | ||
33 | if (irq < 0) { | ||
34 | dev_err(&pdev->dev, "Found HC with no IRQ. Check %s setup!\n", | ||
35 | dev_name(&pdev->dev)); | ||
36 | return -ENODEV; | ||
37 | } | ||
38 | |||
39 | /* Get our Memory Handle */ | ||
40 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
41 | if (!res) { | ||
42 | dev_err(&pdev->dev, "Error: MMIO Handle %s setup!\n", | ||
43 | dev_name(&pdev->dev)); | ||
44 | return -ENODEV; | ||
45 | } | ||
46 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | ||
47 | if (!hcd) { | ||
48 | retval = -ENOMEM; | ||
49 | goto err1; | ||
50 | } | ||
51 | |||
52 | hcd->rsrc_start = res->start; | ||
53 | hcd->rsrc_len = resource_size(res); | ||
54 | |||
55 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
56 | driver->description)) { | ||
57 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
58 | retval = -EBUSY; | ||
59 | goto err2; | ||
60 | } | ||
61 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
62 | |||
63 | if (hcd->regs == NULL) { | ||
64 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
65 | retval = -EFAULT; | ||
66 | goto err3; | ||
67 | } | ||
68 | |||
69 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
70 | if (retval != 0) | ||
71 | goto err4; | ||
72 | return retval; | ||
73 | |||
74 | err4: | ||
75 | iounmap(hcd->regs); | ||
76 | err3: | ||
77 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
78 | err2: | ||
79 | usb_put_hcd(hcd); | ||
80 | err1: | ||
81 | dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), | ||
82 | retval); | ||
83 | return retval; | ||
84 | } | ||
85 | |||
86 | static struct hc_driver ehci_xls_hc_driver = { | ||
87 | .description = hcd_name, | ||
88 | .product_desc = "XLS EHCI Host Controller", | ||
89 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
90 | .irq = ehci_irq, | ||
91 | .flags = HCD_USB2 | HCD_MEMORY, | ||
92 | .reset = ehci_xls_setup, | ||
93 | .start = ehci_run, | ||
94 | .stop = ehci_stop, | ||
95 | .shutdown = ehci_shutdown, | ||
96 | |||
97 | .urb_enqueue = ehci_urb_enqueue, | ||
98 | .urb_dequeue = ehci_urb_dequeue, | ||
99 | .endpoint_disable = ehci_endpoint_disable, | ||
100 | .endpoint_reset = ehci_endpoint_reset, | ||
101 | |||
102 | .get_frame_number = ehci_get_frame, | ||
103 | |||
104 | .hub_status_data = ehci_hub_status_data, | ||
105 | .hub_control = ehci_hub_control, | ||
106 | .bus_suspend = ehci_bus_suspend, | ||
107 | .bus_resume = ehci_bus_resume, | ||
108 | .relinquish_port = ehci_relinquish_port, | ||
109 | .port_handed_over = ehci_port_handed_over, | ||
110 | |||
111 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
112 | }; | ||
113 | |||
114 | static int ehci_xls_probe(struct platform_device *pdev) | ||
115 | { | ||
116 | if (usb_disabled()) | ||
117 | return -ENODEV; | ||
118 | |||
119 | return ehci_xls_probe_internal(&ehci_xls_hc_driver, pdev); | ||
120 | } | ||
121 | |||
122 | static int ehci_xls_remove(struct platform_device *pdev) | ||
123 | { | ||
124 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
125 | |||
126 | usb_remove_hcd(hcd); | ||
127 | iounmap(hcd->regs); | ||
128 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
129 | usb_put_hcd(hcd); | ||
130 | return 0; | ||
131 | } | ||
132 | |||
133 | MODULE_ALIAS("ehci-xls"); | ||
134 | |||
135 | static struct platform_driver ehci_xls_driver = { | ||
136 | .probe = ehci_xls_probe, | ||
137 | .remove = ehci_xls_remove, | ||
138 | .shutdown = usb_hcd_platform_shutdown, | ||
139 | .driver = { | ||
140 | .name = "ehci-xls", | ||
141 | }, | ||
142 | }; | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index da07d98f7d1d..9dadc7118d68 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -143,7 +143,7 @@ struct ehci_hcd { /* one per controller */ | |||
143 | struct ehci_qh *intr_unlink_last; | 143 | struct ehci_qh *intr_unlink_last; |
144 | unsigned intr_unlink_cycle; | 144 | unsigned intr_unlink_cycle; |
145 | unsigned now_frame; /* frame from HC hardware */ | 145 | unsigned now_frame; /* frame from HC hardware */ |
146 | unsigned next_frame; /* scan periodic, start here */ | 146 | unsigned last_iso_frame; /* last frame scanned for iso */ |
147 | unsigned intr_count; /* intr activity count */ | 147 | unsigned intr_count; /* intr activity count */ |
148 | unsigned isoc_count; /* isoc activity count */ | 148 | unsigned isoc_count; /* isoc activity count */ |
149 | unsigned periodic_count; /* periodic activity count */ | 149 | unsigned periodic_count; /* periodic activity count */ |
@@ -193,7 +193,6 @@ struct ehci_hcd { /* one per controller */ | |||
193 | unsigned has_amcc_usb23:1; | 193 | unsigned has_amcc_usb23:1; |
194 | unsigned need_io_watchdog:1; | 194 | unsigned need_io_watchdog:1; |
195 | unsigned amd_pll_fix:1; | 195 | unsigned amd_pll_fix:1; |
196 | unsigned fs_i_thresh:1; /* Intel iso scheduling */ | ||
197 | unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/ | 196 | unsigned use_dummy_qh:1; /* AMD Frame List table quirk*/ |
198 | unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ | 197 | unsigned has_synopsys_hc_bug:1; /* Synopsys HC */ |
199 | unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ | 198 | unsigned frame_index_bug:1; /* MosChip (AKA NetMos) */ |
@@ -207,7 +206,6 @@ struct ehci_hcd { /* one per controller */ | |||
207 | #define OHCI_HCCTRL_LEN 0x4 | 206 | #define OHCI_HCCTRL_LEN 0x4 |
208 | __hc32 *ohci_hcctrl_reg; | 207 | __hc32 *ohci_hcctrl_reg; |
209 | unsigned has_hostpc:1; | 208 | unsigned has_hostpc:1; |
210 | unsigned has_lpm:1; /* support link power management */ | ||
211 | unsigned has_ppcd:1; /* support per-port change bits */ | 209 | unsigned has_ppcd:1; /* support per-port change bits */ |
212 | u8 sbrn; /* packed release number */ | 210 | u8 sbrn; /* packed release number */ |
213 | 211 | ||
@@ -762,26 +760,41 @@ static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci, const __hc32 *x) | |||
762 | 760 | ||
763 | /*-------------------------------------------------------------------------*/ | 761 | /*-------------------------------------------------------------------------*/ |
764 | 762 | ||
765 | #ifdef CONFIG_PCI | 763 | #define ehci_dbg(ehci, fmt, args...) \ |
766 | 764 | dev_dbg(ehci_to_hcd(ehci)->self.controller , fmt , ## args) | |
767 | /* For working around the MosChip frame-index-register bug */ | 765 | #define ehci_err(ehci, fmt, args...) \ |
768 | static unsigned ehci_read_frame_index(struct ehci_hcd *ehci); | 766 | dev_err(ehci_to_hcd(ehci)->self.controller , fmt , ## args) |
769 | 767 | #define ehci_info(ehci, fmt, args...) \ | |
768 | dev_info(ehci_to_hcd(ehci)->self.controller , fmt , ## args) | ||
769 | #define ehci_warn(ehci, fmt, args...) \ | ||
770 | dev_warn(ehci_to_hcd(ehci)->self.controller , fmt , ## args) | ||
771 | |||
772 | #ifdef VERBOSE_DEBUG | ||
773 | # define ehci_vdbg ehci_dbg | ||
770 | #else | 774 | #else |
771 | 775 | static inline void ehci_vdbg(struct ehci_hcd *ehci, ...) {} | |
772 | static inline unsigned ehci_read_frame_index(struct ehci_hcd *ehci) | ||
773 | { | ||
774 | return ehci_readl(ehci, &ehci->regs->frame_index); | ||
775 | } | ||
776 | |||
777 | #endif | 776 | #endif |
778 | 777 | ||
779 | /*-------------------------------------------------------------------------*/ | ||
780 | |||
781 | #ifndef DEBUG | 778 | #ifndef DEBUG |
782 | #define STUB_DEBUG_FILES | 779 | #define STUB_DEBUG_FILES |
783 | #endif /* DEBUG */ | 780 | #endif /* DEBUG */ |
784 | 781 | ||
785 | /*-------------------------------------------------------------------------*/ | 782 | /*-------------------------------------------------------------------------*/ |
786 | 783 | ||
784 | /* Declarations of things exported for use by ehci platform drivers */ | ||
785 | |||
786 | struct ehci_driver_overrides { | ||
787 | size_t extra_priv_size; | ||
788 | int (*reset)(struct usb_hcd *hcd); | ||
789 | }; | ||
790 | |||
791 | extern void ehci_init_driver(struct hc_driver *drv, | ||
792 | const struct ehci_driver_overrides *over); | ||
793 | extern int ehci_setup(struct usb_hcd *hcd); | ||
794 | |||
795 | #ifdef CONFIG_PM | ||
796 | extern int ehci_suspend(struct usb_hcd *hcd, bool do_wakeup); | ||
797 | extern int ehci_resume(struct usb_hcd *hcd, bool hibernated); | ||
798 | #endif /* CONFIG_PM */ | ||
799 | |||
787 | #endif /* __LINUX_EHCI_HCD_H */ | 800 | #endif /* __LINUX_EHCI_HCD_H */ |
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index fff114fd5461..958379f9de79 100644 --- a/drivers/usb/host/isp1760-if.c +++ b/drivers/usb/host/isp1760-if.c | |||
@@ -43,7 +43,6 @@ static int of_isp1760_probe(struct platform_device *dev) | |||
43 | struct device_node *dp = dev->dev.of_node; | 43 | struct device_node *dp = dev->dev.of_node; |
44 | struct resource *res; | 44 | struct resource *res; |
45 | struct resource memory; | 45 | struct resource memory; |
46 | struct of_irq oirq; | ||
47 | int virq; | 46 | int virq; |
48 | resource_size_t res_len; | 47 | resource_size_t res_len; |
49 | int ret; | 48 | int ret; |
@@ -69,14 +68,12 @@ static int of_isp1760_probe(struct platform_device *dev) | |||
69 | goto free_data; | 68 | goto free_data; |
70 | } | 69 | } |
71 | 70 | ||
72 | if (of_irq_map_one(dp, 0, &oirq)) { | 71 | virq = irq_of_parse_and_map(dp, 0); |
72 | if (!virq) { | ||
73 | ret = -ENODEV; | 73 | ret = -ENODEV; |
74 | goto release_reg; | 74 | goto release_reg; |
75 | } | 75 | } |
76 | 76 | ||
77 | virq = irq_create_of_mapping(oirq.controller, oirq.specifier, | ||
78 | oirq.size); | ||
79 | |||
80 | if (of_device_is_compatible(dp, "nxp,usb-isp1761")) | 77 | if (of_device_is_compatible(dp, "nxp,usb-isp1761")) |
81 | devflags |= ISP1760_FLAG_ISP1761; | 78 | devflags |= ISP1760_FLAG_ISP1761; |
82 | 79 | ||
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 0bf72f943b00..908d84af1dd7 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
@@ -705,7 +705,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev) | |||
705 | if (!clocked) | 705 | if (!clocked) |
706 | at91_start_clock(); | 706 | at91_start_clock(); |
707 | 707 | ||
708 | ohci_finish_controller_resume(hcd); | 708 | ohci_resume(hcd, false); |
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
711 | #else | 711 | #else |
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c deleted file mode 100644 index c611699b4aa6..000000000000 --- a/drivers/usb/host/ohci-au1xxx.c +++ /dev/null | |||
@@ -1,234 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | ||
5 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> | ||
6 | * (C) Copyright 2002 Hewlett-Packard Company | ||
7 | * | ||
8 | * Bus Glue for AMD Alchemy Au1xxx | ||
9 | * | ||
10 | * Written by Christopher Hoover <ch@hpl.hp.com> | ||
11 | * Based on fragments of previous driver by Russell King et al. | ||
12 | * | ||
13 | * Modified for LH7A404 from ohci-sa1111.c | ||
14 | * by Durgesh Pattamatta <pattamattad@sharpsec.com> | ||
15 | * Modified for AMD Alchemy Au1xxx | ||
16 | * by Matt Porter <mporter@kernel.crashing.org> | ||
17 | * | ||
18 | * This file is licenced under the GPL. | ||
19 | */ | ||
20 | |||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/signal.h> | ||
23 | |||
24 | #include <asm/mach-au1x00/au1000.h> | ||
25 | |||
26 | |||
27 | extern int usb_disabled(void); | ||
28 | |||
29 | static int __devinit ohci_au1xxx_start(struct usb_hcd *hcd) | ||
30 | { | ||
31 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
32 | int ret; | ||
33 | |||
34 | ohci_dbg(ohci, "ohci_au1xxx_start, ohci:%p", ohci); | ||
35 | |||
36 | if ((ret = ohci_init(ohci)) < 0) | ||
37 | return ret; | ||
38 | |||
39 | if ((ret = ohci_run(ohci)) < 0) { | ||
40 | dev_err(hcd->self.controller, "can't start %s", | ||
41 | hcd->self.bus_name); | ||
42 | ohci_stop(hcd); | ||
43 | return ret; | ||
44 | } | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static const struct hc_driver ohci_au1xxx_hc_driver = { | ||
50 | .description = hcd_name, | ||
51 | .product_desc = "Au1xxx OHCI", | ||
52 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
53 | |||
54 | /* | ||
55 | * generic hardware linkage | ||
56 | */ | ||
57 | .irq = ohci_irq, | ||
58 | .flags = HCD_USB11 | HCD_MEMORY, | ||
59 | |||
60 | /* | ||
61 | * basic lifecycle operations | ||
62 | */ | ||
63 | .start = ohci_au1xxx_start, | ||
64 | .stop = ohci_stop, | ||
65 | .shutdown = ohci_shutdown, | ||
66 | |||
67 | /* | ||
68 | * managing i/o requests and associated device resources | ||
69 | */ | ||
70 | .urb_enqueue = ohci_urb_enqueue, | ||
71 | .urb_dequeue = ohci_urb_dequeue, | ||
72 | .endpoint_disable = ohci_endpoint_disable, | ||
73 | |||
74 | /* | ||
75 | * scheduling support | ||
76 | */ | ||
77 | .get_frame_number = ohci_get_frame, | ||
78 | |||
79 | /* | ||
80 | * root hub support | ||
81 | */ | ||
82 | .hub_status_data = ohci_hub_status_data, | ||
83 | .hub_control = ohci_hub_control, | ||
84 | #ifdef CONFIG_PM | ||
85 | .bus_suspend = ohci_bus_suspend, | ||
86 | .bus_resume = ohci_bus_resume, | ||
87 | #endif | ||
88 | .start_port_reset = ohci_start_port_reset, | ||
89 | }; | ||
90 | |||
91 | static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | ||
92 | { | ||
93 | int ret, unit; | ||
94 | struct usb_hcd *hcd; | ||
95 | |||
96 | if (usb_disabled()) | ||
97 | return -ENODEV; | ||
98 | |||
99 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { | ||
100 | pr_debug("resource[1] is not IORESOURCE_IRQ\n"); | ||
101 | return -ENOMEM; | ||
102 | } | ||
103 | |||
104 | hcd = usb_create_hcd(&ohci_au1xxx_hc_driver, &pdev->dev, "au1xxx"); | ||
105 | if (!hcd) | ||
106 | return -ENOMEM; | ||
107 | |||
108 | hcd->rsrc_start = pdev->resource[0].start; | ||
109 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | ||
110 | |||
111 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
112 | pr_debug("request_mem_region failed\n"); | ||
113 | ret = -EBUSY; | ||
114 | goto err1; | ||
115 | } | ||
116 | |||
117 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
118 | if (!hcd->regs) { | ||
119 | pr_debug("ioremap failed\n"); | ||
120 | ret = -ENOMEM; | ||
121 | goto err2; | ||
122 | } | ||
123 | |||
124 | unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ? | ||
125 | ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0; | ||
126 | if (alchemy_usb_control(unit, 1)) { | ||
127 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); | ||
128 | ret = -ENODEV; | ||
129 | goto err3; | ||
130 | } | ||
131 | |||
132 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
133 | |||
134 | ret = usb_add_hcd(hcd, pdev->resource[1].start, | ||
135 | IRQF_SHARED); | ||
136 | if (ret == 0) { | ||
137 | platform_set_drvdata(pdev, hcd); | ||
138 | return ret; | ||
139 | } | ||
140 | |||
141 | alchemy_usb_control(unit, 0); | ||
142 | err3: | ||
143 | iounmap(hcd->regs); | ||
144 | err2: | ||
145 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
146 | err1: | ||
147 | usb_put_hcd(hcd); | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev) | ||
152 | { | ||
153 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
154 | int unit; | ||
155 | |||
156 | unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ? | ||
157 | ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0; | ||
158 | usb_remove_hcd(hcd); | ||
159 | alchemy_usb_control(unit, 0); | ||
160 | iounmap(hcd->regs); | ||
161 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
162 | usb_put_hcd(hcd); | ||
163 | platform_set_drvdata(pdev, NULL); | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | #ifdef CONFIG_PM | ||
169 | static int ohci_hcd_au1xxx_drv_suspend(struct device *dev) | ||
170 | { | ||
171 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
172 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
173 | unsigned long flags; | ||
174 | int rc; | ||
175 | |||
176 | rc = 0; | ||
177 | |||
178 | /* Root hub was already suspended. Disable irq emission and | ||
179 | * mark HW unaccessible, bail out if RH has been resumed. Use | ||
180 | * the spinlock to properly synchronize with possible pending | ||
181 | * RH suspend or resume activity. | ||
182 | */ | ||
183 | spin_lock_irqsave(&ohci->lock, flags); | ||
184 | if (ohci->rh_state != OHCI_RH_SUSPENDED) { | ||
185 | rc = -EINVAL; | ||
186 | goto bail; | ||
187 | } | ||
188 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | ||
189 | (void)ohci_readl(ohci, &ohci->regs->intrdisable); | ||
190 | |||
191 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
192 | |||
193 | alchemy_usb_control(ALCHEMY_USB_OHCI0, 0); | ||
194 | bail: | ||
195 | spin_unlock_irqrestore(&ohci->lock, flags); | ||
196 | |||
197 | return rc; | ||
198 | } | ||
199 | |||
200 | static int ohci_hcd_au1xxx_drv_resume(struct device *dev) | ||
201 | { | ||
202 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
203 | |||
204 | alchemy_usb_control(ALCHEMY_USB_OHCI0, 1); | ||
205 | |||
206 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
207 | ohci_finish_controller_resume(hcd); | ||
208 | |||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | static const struct dev_pm_ops au1xxx_ohci_pmops = { | ||
213 | .suspend = ohci_hcd_au1xxx_drv_suspend, | ||
214 | .resume = ohci_hcd_au1xxx_drv_resume, | ||
215 | }; | ||
216 | |||
217 | #define AU1XXX_OHCI_PMOPS &au1xxx_ohci_pmops | ||
218 | |||
219 | #else | ||
220 | #define AU1XXX_OHCI_PMOPS NULL | ||
221 | #endif | ||
222 | |||
223 | static struct platform_driver ohci_hcd_au1xxx_driver = { | ||
224 | .probe = ohci_hcd_au1xxx_drv_probe, | ||
225 | .remove = ohci_hcd_au1xxx_drv_remove, | ||
226 | .shutdown = usb_hcd_platform_shutdown, | ||
227 | .driver = { | ||
228 | .name = "au1xxx-ohci", | ||
229 | .owner = THIS_MODULE, | ||
230 | .pm = AU1XXX_OHCI_PMOPS, | ||
231 | }, | ||
232 | }; | ||
233 | |||
234 | MODULE_ALIAS("platform:au1xxx-ohci"); | ||
diff --git a/drivers/usb/host/ohci-cns3xxx.c b/drivers/usb/host/ohci-cns3xxx.c deleted file mode 100644 index 2c9f233047be..000000000000 --- a/drivers/usb/host/ohci-cns3xxx.c +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Cavium Networks | ||
3 | * | ||
4 | * This file is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License, Version 2, as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/platform_device.h> | ||
10 | #include <linux/atomic.h> | ||
11 | #include <mach/cns3xxx.h> | ||
12 | #include <mach/pm.h> | ||
13 | |||
14 | static int __devinit | ||
15 | cns3xxx_ohci_start(struct usb_hcd *hcd) | ||
16 | { | ||
17 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
18 | int ret; | ||
19 | |||
20 | /* | ||
21 | * EHCI and OHCI share the same clock and power, | ||
22 | * resetting twice would cause the 1st controller been reset. | ||
23 | * Therefore only do power up at the first up device, and | ||
24 | * power down at the last down device. | ||
25 | * | ||
26 | * Set USB AHB INCR length to 16 | ||
27 | */ | ||
28 | if (atomic_inc_return(&usb_pwr_ref) == 1) { | ||
29 | cns3xxx_pwr_power_up(1 << PM_PLL_HM_PD_CTRL_REG_OFFSET_PLL_USB); | ||
30 | cns3xxx_pwr_clk_en(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST); | ||
31 | cns3xxx_pwr_soft_rst(1 << PM_SOFT_RST_REG_OFFST_USB_HOST); | ||
32 | __raw_writel((__raw_readl(MISC_CHIP_CONFIG_REG) | (0X2 << 24)), | ||
33 | MISC_CHIP_CONFIG_REG); | ||
34 | } | ||
35 | |||
36 | ret = ohci_init(ohci); | ||
37 | if (ret < 0) | ||
38 | return ret; | ||
39 | |||
40 | ohci->num_ports = 1; | ||
41 | |||
42 | ret = ohci_run(ohci); | ||
43 | if (ret < 0) { | ||
44 | dev_err(hcd->self.controller, "can't start %s\n", | ||
45 | hcd->self.bus_name); | ||
46 | ohci_stop(hcd); | ||
47 | return ret; | ||
48 | } | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | static const struct hc_driver cns3xxx_ohci_hc_driver = { | ||
53 | .description = hcd_name, | ||
54 | .product_desc = "CNS3XXX OHCI Host controller", | ||
55 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
56 | .irq = ohci_irq, | ||
57 | .flags = HCD_USB11 | HCD_MEMORY, | ||
58 | .start = cns3xxx_ohci_start, | ||
59 | .stop = ohci_stop, | ||
60 | .shutdown = ohci_shutdown, | ||
61 | .urb_enqueue = ohci_urb_enqueue, | ||
62 | .urb_dequeue = ohci_urb_dequeue, | ||
63 | .endpoint_disable = ohci_endpoint_disable, | ||
64 | .get_frame_number = ohci_get_frame, | ||
65 | .hub_status_data = ohci_hub_status_data, | ||
66 | .hub_control = ohci_hub_control, | ||
67 | #ifdef CONFIG_PM | ||
68 | .bus_suspend = ohci_bus_suspend, | ||
69 | .bus_resume = ohci_bus_resume, | ||
70 | #endif | ||
71 | .start_port_reset = ohci_start_port_reset, | ||
72 | }; | ||
73 | |||
74 | static int cns3xxx_ohci_probe(struct platform_device *pdev) | ||
75 | { | ||
76 | struct device *dev = &pdev->dev; | ||
77 | struct usb_hcd *hcd; | ||
78 | const struct hc_driver *driver = &cns3xxx_ohci_hc_driver; | ||
79 | struct resource *res; | ||
80 | int irq; | ||
81 | int retval; | ||
82 | |||
83 | if (usb_disabled()) | ||
84 | return -ENODEV; | ||
85 | |||
86 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
87 | if (!res) { | ||
88 | dev_err(dev, "Found HC with no IRQ.\n"); | ||
89 | return -ENODEV; | ||
90 | } | ||
91 | irq = res->start; | ||
92 | |||
93 | hcd = usb_create_hcd(driver, dev, dev_name(dev)); | ||
94 | if (!hcd) | ||
95 | return -ENOMEM; | ||
96 | |||
97 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
98 | if (!res) { | ||
99 | dev_err(dev, "Found HC with no register addr.\n"); | ||
100 | retval = -ENODEV; | ||
101 | goto err1; | ||
102 | } | ||
103 | hcd->rsrc_start = res->start; | ||
104 | hcd->rsrc_len = resource_size(res); | ||
105 | |||
106 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
107 | driver->description)) { | ||
108 | dev_dbg(dev, "controller already in use\n"); | ||
109 | retval = -EBUSY; | ||
110 | goto err1; | ||
111 | } | ||
112 | |||
113 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
114 | if (!hcd->regs) { | ||
115 | dev_dbg(dev, "error mapping memory\n"); | ||
116 | retval = -EFAULT; | ||
117 | goto err2; | ||
118 | } | ||
119 | |||
120 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
121 | |||
122 | retval = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
123 | if (retval == 0) | ||
124 | return retval; | ||
125 | |||
126 | iounmap(hcd->regs); | ||
127 | err2: | ||
128 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
129 | err1: | ||
130 | usb_put_hcd(hcd); | ||
131 | return retval; | ||
132 | } | ||
133 | |||
134 | static int cns3xxx_ohci_remove(struct platform_device *pdev) | ||
135 | { | ||
136 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
137 | |||
138 | usb_remove_hcd(hcd); | ||
139 | iounmap(hcd->regs); | ||
140 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
141 | |||
142 | /* | ||
143 | * EHCI and OHCI share the same clock and power, | ||
144 | * resetting twice would cause the 1st controller been reset. | ||
145 | * Therefore only do power up at the first up device, and | ||
146 | * power down at the last down device. | ||
147 | */ | ||
148 | if (atomic_dec_return(&usb_pwr_ref) == 0) | ||
149 | cns3xxx_pwr_clk_dis(1 << PM_CLK_GATE_REG_OFFSET_USB_HOST); | ||
150 | |||
151 | usb_put_hcd(hcd); | ||
152 | |||
153 | platform_set_drvdata(pdev, NULL); | ||
154 | |||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | MODULE_ALIAS("platform:cns3xxx-ohci"); | ||
159 | |||
160 | static struct platform_driver ohci_hcd_cns3xxx_driver = { | ||
161 | .probe = cns3xxx_ohci_probe, | ||
162 | .remove = cns3xxx_ohci_remove, | ||
163 | .driver = { | ||
164 | .name = "cns3xxx-ohci", | ||
165 | }, | ||
166 | }; | ||
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index dbfbd1dfd2e2..a982f04ed787 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
@@ -194,7 +194,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) | |||
194 | 194 | ||
195 | ep93xx_start_hc(&pdev->dev); | 195 | ep93xx_start_hc(&pdev->dev); |
196 | 196 | ||
197 | ohci_finish_controller_resume(hcd); | 197 | ohci_resume(hcd, false); |
198 | return 0; | 198 | return 0; |
199 | } | 199 | } |
200 | #endif | 200 | #endif |
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 20a50081f922..6a30fc5bec93 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c | |||
@@ -23,6 +23,11 @@ struct exynos_ohci_hcd { | |||
23 | struct clk *clk; | 23 | struct clk *clk; |
24 | }; | 24 | }; |
25 | 25 | ||
26 | static int ohci_exynos_reset(struct usb_hcd *hcd) | ||
27 | { | ||
28 | return ohci_init(hcd_to_ohci(hcd)); | ||
29 | } | ||
30 | |||
26 | static int ohci_exynos_start(struct usb_hcd *hcd) | 31 | static int ohci_exynos_start(struct usb_hcd *hcd) |
27 | { | 32 | { |
28 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 33 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
@@ -30,10 +35,6 @@ static int ohci_exynos_start(struct usb_hcd *hcd) | |||
30 | 35 | ||
31 | ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci); | 36 | ohci_dbg(ohci, "ohci_exynos_start, ohci:%p", ohci); |
32 | 37 | ||
33 | ret = ohci_init(ohci); | ||
34 | if (ret < 0) | ||
35 | return ret; | ||
36 | |||
37 | ret = ohci_run(ohci); | 38 | ret = ohci_run(ohci); |
38 | if (ret < 0) { | 39 | if (ret < 0) { |
39 | dev_err(hcd->self.controller, "can't start %s\n", | 40 | dev_err(hcd->self.controller, "can't start %s\n", |
@@ -53,6 +54,7 @@ static const struct hc_driver exynos_ohci_hc_driver = { | |||
53 | .irq = ohci_irq, | 54 | .irq = ohci_irq, |
54 | .flags = HCD_MEMORY|HCD_USB11, | 55 | .flags = HCD_MEMORY|HCD_USB11, |
55 | 56 | ||
57 | .reset = ohci_exynos_reset, | ||
56 | .start = ohci_exynos_start, | 58 | .start = ohci_exynos_start, |
57 | .stop = ohci_stop, | 59 | .stop = ohci_stop, |
58 | .shutdown = ohci_shutdown, | 60 | .shutdown = ohci_shutdown, |
@@ -115,7 +117,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev) | |||
115 | } | 117 | } |
116 | 118 | ||
117 | exynos_ohci->hcd = hcd; | 119 | exynos_ohci->hcd = hcd; |
118 | exynos_ohci->clk = clk_get(&pdev->dev, "usbhost"); | 120 | exynos_ohci->clk = devm_clk_get(&pdev->dev, "usbhost"); |
119 | 121 | ||
120 | if (IS_ERR(exynos_ohci->clk)) { | 122 | if (IS_ERR(exynos_ohci->clk)) { |
121 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); | 123 | dev_err(&pdev->dev, "Failed to get usbhost clock\n"); |
@@ -123,9 +125,9 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev) | |||
123 | goto fail_clk; | 125 | goto fail_clk; |
124 | } | 126 | } |
125 | 127 | ||
126 | err = clk_enable(exynos_ohci->clk); | 128 | err = clk_prepare_enable(exynos_ohci->clk); |
127 | if (err) | 129 | if (err) |
128 | goto fail_clken; | 130 | goto fail_clk; |
129 | 131 | ||
130 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 132 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
131 | if (!res) { | 133 | if (!res) { |
@@ -167,9 +169,7 @@ static int __devinit exynos_ohci_probe(struct platform_device *pdev) | |||
167 | return 0; | 169 | return 0; |
168 | 170 | ||
169 | fail_io: | 171 | fail_io: |
170 | clk_disable(exynos_ohci->clk); | 172 | clk_disable_unprepare(exynos_ohci->clk); |
171 | fail_clken: | ||
172 | clk_put(exynos_ohci->clk); | ||
173 | fail_clk: | 173 | fail_clk: |
174 | usb_put_hcd(hcd); | 174 | usb_put_hcd(hcd); |
175 | return err; | 175 | return err; |
@@ -186,8 +186,7 @@ static int __devexit exynos_ohci_remove(struct platform_device *pdev) | |||
186 | if (pdata && pdata->phy_exit) | 186 | if (pdata && pdata->phy_exit) |
187 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | 187 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); |
188 | 188 | ||
189 | clk_disable(exynos_ohci->clk); | 189 | clk_disable_unprepare(exynos_ohci->clk); |
190 | clk_put(exynos_ohci->clk); | ||
191 | 190 | ||
192 | usb_put_hcd(hcd); | 191 | usb_put_hcd(hcd); |
193 | 192 | ||
@@ -232,7 +231,7 @@ static int exynos_ohci_suspend(struct device *dev) | |||
232 | if (pdata && pdata->phy_exit) | 231 | if (pdata && pdata->phy_exit) |
233 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | 232 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); |
234 | 233 | ||
235 | clk_disable(exynos_ohci->clk); | 234 | clk_disable_unprepare(exynos_ohci->clk); |
236 | 235 | ||
237 | fail: | 236 | fail: |
238 | spin_unlock_irqrestore(&ohci->lock, flags); | 237 | spin_unlock_irqrestore(&ohci->lock, flags); |
@@ -247,15 +246,12 @@ static int exynos_ohci_resume(struct device *dev) | |||
247 | struct platform_device *pdev = to_platform_device(dev); | 246 | struct platform_device *pdev = to_platform_device(dev); |
248 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; | 247 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; |
249 | 248 | ||
250 | clk_enable(exynos_ohci->clk); | 249 | clk_prepare_enable(exynos_ohci->clk); |
251 | 250 | ||
252 | if (pdata && pdata->phy_init) | 251 | if (pdata && pdata->phy_init) |
253 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | 252 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); |
254 | 253 | ||
255 | /* Mark hardware accessible again as we are out of D3 state by now */ | 254 | ohci_resume(hcd, false); |
256 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
257 | |||
258 | ohci_finish_controller_resume(hcd); | ||
259 | 255 | ||
260 | return 0; | 256 | return 0; |
261 | } | 257 | } |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 4a1d64d92338..180a2b01db56 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -231,13 +231,41 @@ static int ohci_urb_enqueue ( | |||
231 | frame &= ~(ed->interval - 1); | 231 | frame &= ~(ed->interval - 1); |
232 | frame |= ed->branch; | 232 | frame |= ed->branch; |
233 | urb->start_frame = frame; | 233 | urb->start_frame = frame; |
234 | } | ||
235 | } else if (ed->type == PIPE_ISOCHRONOUS) { | ||
236 | u16 next = ohci_frame_no(ohci) + 2; | ||
237 | u16 frame = ed->last_iso + ed->interval; | ||
238 | |||
239 | /* Behind the scheduling threshold? */ | ||
240 | if (unlikely(tick_before(frame, next))) { | ||
234 | 241 | ||
235 | /* yes, only URB_ISO_ASAP is supported, and | 242 | /* USB_ISO_ASAP: Round up to the first available slot */ |
236 | * urb->start_frame is never used as input. | 243 | if (urb->transfer_flags & URB_ISO_ASAP) |
244 | frame += (next - frame + ed->interval - 1) & | ||
245 | -ed->interval; | ||
246 | |||
247 | /* | ||
248 | * Not ASAP: Use the next slot in the stream. If | ||
249 | * the entire URB falls before the threshold, fail. | ||
237 | */ | 250 | */ |
251 | else if (tick_before(frame + ed->interval * | ||
252 | (urb->number_of_packets - 1), next)) { | ||
253 | retval = -EXDEV; | ||
254 | usb_hcd_unlink_urb_from_ep(hcd, urb); | ||
255 | goto fail; | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | * Some OHCI hardware doesn't handle late TDs | ||
260 | * correctly. After retiring them it proceeds to | ||
261 | * the next ED instead of the next TD. Therefore | ||
262 | * we have to omit the late TDs entirely. | ||
263 | */ | ||
264 | urb_priv->td_cnt = DIV_ROUND_UP(next - frame, | ||
265 | ed->interval); | ||
238 | } | 266 | } |
239 | } else if (ed->type == PIPE_ISOCHRONOUS) | 267 | urb->start_frame = frame; |
240 | urb->start_frame = ed->last_iso + ed->interval; | 268 | } |
241 | 269 | ||
242 | /* fill the TDs and link them to the ed; and | 270 | /* fill the TDs and link them to the ed; and |
243 | * enable that part of the schedule, if needed | 271 | * enable that part of the schedule, if needed |
@@ -983,6 +1011,79 @@ static int ohci_restart (struct ohci_hcd *ohci) | |||
983 | 1011 | ||
984 | #endif | 1012 | #endif |
985 | 1013 | ||
1014 | #ifdef CONFIG_PM | ||
1015 | |||
1016 | static int __maybe_unused ohci_suspend(struct usb_hcd *hcd, bool do_wakeup) | ||
1017 | { | ||
1018 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
1019 | unsigned long flags; | ||
1020 | |||
1021 | /* Disable irq emission and mark HW unaccessible. Use | ||
1022 | * the spinlock to properly synchronize with possible pending | ||
1023 | * RH suspend or resume activity. | ||
1024 | */ | ||
1025 | spin_lock_irqsave (&ohci->lock, flags); | ||
1026 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | ||
1027 | (void)ohci_readl(ohci, &ohci->regs->intrdisable); | ||
1028 | |||
1029 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
1030 | spin_unlock_irqrestore (&ohci->lock, flags); | ||
1031 | |||
1032 | return 0; | ||
1033 | } | ||
1034 | |||
1035 | |||
1036 | static int __maybe_unused ohci_resume(struct usb_hcd *hcd, bool hibernated) | ||
1037 | { | ||
1038 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
1039 | int port; | ||
1040 | bool need_reinit = false; | ||
1041 | |||
1042 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
1043 | |||
1044 | /* Make sure resume from hibernation re-enumerates everything */ | ||
1045 | if (hibernated) | ||
1046 | ohci_usb_reset(ohci); | ||
1047 | |||
1048 | /* See if the controller is already running or has been reset */ | ||
1049 | ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); | ||
1050 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { | ||
1051 | need_reinit = true; | ||
1052 | } else { | ||
1053 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
1054 | case OHCI_USB_OPER: | ||
1055 | case OHCI_USB_RESET: | ||
1056 | need_reinit = true; | ||
1057 | } | ||
1058 | } | ||
1059 | |||
1060 | /* If needed, reinitialize and suspend the root hub */ | ||
1061 | if (need_reinit) { | ||
1062 | spin_lock_irq(&ohci->lock); | ||
1063 | ohci_rh_resume(ohci); | ||
1064 | ohci_rh_suspend(ohci, 0); | ||
1065 | spin_unlock_irq(&ohci->lock); | ||
1066 | } | ||
1067 | |||
1068 | /* Normally just turn on port power and enable interrupts */ | ||
1069 | else { | ||
1070 | ohci_dbg(ohci, "powerup ports\n"); | ||
1071 | for (port = 0; port < ohci->num_ports; port++) | ||
1072 | ohci_writel(ohci, RH_PS_PPS, | ||
1073 | &ohci->regs->roothub.portstatus[port]); | ||
1074 | |||
1075 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); | ||
1076 | ohci_readl(ohci, &ohci->regs->intrenable); | ||
1077 | msleep(20); | ||
1078 | } | ||
1079 | |||
1080 | usb_hcd_resume_root_hub(hcd); | ||
1081 | |||
1082 | return 0; | ||
1083 | } | ||
1084 | |||
1085 | #endif | ||
1086 | |||
986 | /*-------------------------------------------------------------------------*/ | 1087 | /*-------------------------------------------------------------------------*/ |
987 | 1088 | ||
988 | MODULE_AUTHOR (DRIVER_AUTHOR); | 1089 | MODULE_AUTHOR (DRIVER_AUTHOR); |
@@ -1029,21 +1130,6 @@ MODULE_LICENSE ("GPL"); | |||
1029 | #define PLATFORM_DRIVER ohci_hcd_ep93xx_driver | 1130 | #define PLATFORM_DRIVER ohci_hcd_ep93xx_driver |
1030 | #endif | 1131 | #endif |
1031 | 1132 | ||
1032 | #ifdef CONFIG_MIPS_ALCHEMY | ||
1033 | #include "ohci-au1xxx.c" | ||
1034 | #define PLATFORM_DRIVER ohci_hcd_au1xxx_driver | ||
1035 | #endif | ||
1036 | |||
1037 | #ifdef CONFIG_PNX8550 | ||
1038 | #include "ohci-pnx8550.c" | ||
1039 | #define PLATFORM_DRIVER ohci_hcd_pnx8550_driver | ||
1040 | #endif | ||
1041 | |||
1042 | #ifdef CONFIG_USB_OHCI_HCD_PPC_SOC | ||
1043 | #include "ohci-ppc-soc.c" | ||
1044 | #define PLATFORM_DRIVER ohci_hcd_ppc_soc_driver | ||
1045 | #endif | ||
1046 | |||
1047 | #ifdef CONFIG_ARCH_AT91 | 1133 | #ifdef CONFIG_ARCH_AT91 |
1048 | #include "ohci-at91.c" | 1134 | #include "ohci-at91.c" |
1049 | #define PLATFORM_DRIVER ohci_hcd_at91_driver | 1135 | #define PLATFORM_DRIVER ohci_hcd_at91_driver |
@@ -1059,11 +1145,6 @@ MODULE_LICENSE ("GPL"); | |||
1059 | #define PLATFORM_DRIVER ohci_hcd_da8xx_driver | 1145 | #define PLATFORM_DRIVER ohci_hcd_da8xx_driver |
1060 | #endif | 1146 | #endif |
1061 | 1147 | ||
1062 | #ifdef CONFIG_USB_OHCI_SH | ||
1063 | #include "ohci-sh.c" | ||
1064 | #define PLATFORM_DRIVER ohci_hcd_sh_driver | ||
1065 | #endif | ||
1066 | |||
1067 | 1148 | ||
1068 | #ifdef CONFIG_USB_OHCI_HCD_PPC_OF | 1149 | #ifdef CONFIG_USB_OHCI_HCD_PPC_OF |
1069 | #include "ohci-ppc-of.c" | 1150 | #include "ohci-ppc-of.c" |
@@ -1105,16 +1186,6 @@ MODULE_LICENSE ("GPL"); | |||
1105 | #define PLATFORM_DRIVER ohci_hcd_tilegx_driver | 1186 | #define PLATFORM_DRIVER ohci_hcd_tilegx_driver |
1106 | #endif | 1187 | #endif |
1107 | 1188 | ||
1108 | #ifdef CONFIG_USB_CNS3XXX_OHCI | ||
1109 | #include "ohci-cns3xxx.c" | ||
1110 | #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver | ||
1111 | #endif | ||
1112 | |||
1113 | #ifdef CONFIG_CPU_XLR | ||
1114 | #include "ohci-xls.c" | ||
1115 | #define PLATFORM_DRIVER ohci_xls_driver | ||
1116 | #endif | ||
1117 | |||
1118 | #ifdef CONFIG_USB_OHCI_HCD_PLATFORM | 1189 | #ifdef CONFIG_USB_OHCI_HCD_PLATFORM |
1119 | #include "ohci-platform.c" | 1190 | #include "ohci-platform.c" |
1120 | #define PLATFORM_DRIVER ohci_platform_driver | 1191 | #define PLATFORM_DRIVER ohci_platform_driver |
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 2f3619eefefa..db09dae7b557 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -316,48 +316,6 @@ static int ohci_bus_resume (struct usb_hcd *hcd) | |||
316 | return rc; | 316 | return rc; |
317 | } | 317 | } |
318 | 318 | ||
319 | /* Carry out the final steps of resuming the controller device */ | ||
320 | static void __maybe_unused ohci_finish_controller_resume(struct usb_hcd *hcd) | ||
321 | { | ||
322 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
323 | int port; | ||
324 | bool need_reinit = false; | ||
325 | |||
326 | /* See if the controller is already running or has been reset */ | ||
327 | ohci->hc_control = ohci_readl(ohci, &ohci->regs->control); | ||
328 | if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { | ||
329 | need_reinit = true; | ||
330 | } else { | ||
331 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
332 | case OHCI_USB_OPER: | ||
333 | case OHCI_USB_RESET: | ||
334 | need_reinit = true; | ||
335 | } | ||
336 | } | ||
337 | |||
338 | /* If needed, reinitialize and suspend the root hub */ | ||
339 | if (need_reinit) { | ||
340 | spin_lock_irq(&ohci->lock); | ||
341 | ohci_rh_resume(ohci); | ||
342 | ohci_rh_suspend(ohci, 0); | ||
343 | spin_unlock_irq(&ohci->lock); | ||
344 | } | ||
345 | |||
346 | /* Normally just turn on port power and enable interrupts */ | ||
347 | else { | ||
348 | ohci_dbg(ohci, "powerup ports\n"); | ||
349 | for (port = 0; port < ohci->num_ports; port++) | ||
350 | ohci_writel(ohci, RH_PS_PPS, | ||
351 | &ohci->regs->roothub.portstatus[port]); | ||
352 | |||
353 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrenable); | ||
354 | ohci_readl(ohci, &ohci->regs->intrenable); | ||
355 | msleep(20); | ||
356 | } | ||
357 | |||
358 | usb_hcd_resume_root_hub(hcd); | ||
359 | } | ||
360 | |||
361 | /* Carry out polling-, autostop-, and autoresume-related state changes */ | 319 | /* Carry out polling-, autostop-, and autoresume-related state changes */ |
362 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | 320 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, |
363 | int any_connected, int rhsc_status) | 321 | int any_connected, int rhsc_status) |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 4531d03503c3..733c77c36355 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -530,7 +530,7 @@ static int ohci_omap_resume(struct platform_device *dev) | |||
530 | ohci->next_statechange = jiffies; | 530 | ohci->next_statechange = jiffies; |
531 | 531 | ||
532 | omap_ohci_clock_power(1); | 532 | omap_ohci_clock_power(1); |
533 | ohci_finish_controller_resume(hcd); | 533 | ohci_resume(hcd, false); |
534 | return 0; | 534 | return 0; |
535 | } | 535 | } |
536 | 536 | ||
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 1843bb68ac7c..6afa7dc4e4c3 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -296,49 +296,6 @@ static int __devinit ohci_pci_start (struct usb_hcd *hcd) | |||
296 | return ret; | 296 | return ret; |
297 | } | 297 | } |
298 | 298 | ||
299 | #ifdef CONFIG_PM | ||
300 | |||
301 | static int ohci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) | ||
302 | { | ||
303 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
304 | unsigned long flags; | ||
305 | int rc = 0; | ||
306 | |||
307 | /* Root hub was already suspended. Disable irq emission and | ||
308 | * mark HW unaccessible, bail out if RH has been resumed. Use | ||
309 | * the spinlock to properly synchronize with possible pending | ||
310 | * RH suspend or resume activity. | ||
311 | */ | ||
312 | spin_lock_irqsave (&ohci->lock, flags); | ||
313 | if (ohci->rh_state != OHCI_RH_SUSPENDED) { | ||
314 | rc = -EINVAL; | ||
315 | goto bail; | ||
316 | } | ||
317 | ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | ||
318 | (void)ohci_readl(ohci, &ohci->regs->intrdisable); | ||
319 | |||
320 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
321 | bail: | ||
322 | spin_unlock_irqrestore (&ohci->lock, flags); | ||
323 | |||
324 | return rc; | ||
325 | } | ||
326 | |||
327 | |||
328 | static int ohci_pci_resume(struct usb_hcd *hcd, bool hibernated) | ||
329 | { | ||
330 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
331 | |||
332 | /* Make sure resume from hibernation re-enumerates everything */ | ||
333 | if (hibernated) | ||
334 | ohci_usb_reset(hcd_to_ohci(hcd)); | ||
335 | |||
336 | ohci_finish_controller_resume(hcd); | ||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | #endif /* CONFIG_PM */ | ||
341 | |||
342 | 299 | ||
343 | /*-------------------------------------------------------------------------*/ | 300 | /*-------------------------------------------------------------------------*/ |
344 | 301 | ||
@@ -362,8 +319,8 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
362 | .shutdown = ohci_shutdown, | 319 | .shutdown = ohci_shutdown, |
363 | 320 | ||
364 | #ifdef CONFIG_PM | 321 | #ifdef CONFIG_PM |
365 | .pci_suspend = ohci_pci_suspend, | 322 | .pci_suspend = ohci_suspend, |
366 | .pci_resume = ohci_pci_resume, | 323 | .pci_resume = ohci_resume, |
367 | #endif | 324 | #endif |
368 | 325 | ||
369 | /* | 326 | /* |
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index e24ec9f79164..bda4e0bb8ab3 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c | |||
@@ -31,6 +31,10 @@ static int ohci_platform_reset(struct usb_hcd *hcd) | |||
31 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | 31 | ohci->flags |= OHCI_QUIRK_FRAME_NO; |
32 | 32 | ||
33 | ohci_hcd_init(ohci); | 33 | ohci_hcd_init(ohci); |
34 | |||
35 | if (pdata->num_ports) | ||
36 | ohci->num_ports = pdata->num_ports; | ||
37 | |||
34 | err = ohci_init(ohci); | 38 | err = ohci_init(ohci); |
35 | 39 | ||
36 | return err; | 40 | return err; |
@@ -97,13 +101,13 @@ static int __devinit ohci_platform_probe(struct platform_device *dev) | |||
97 | 101 | ||
98 | irq = platform_get_irq(dev, 0); | 102 | irq = platform_get_irq(dev, 0); |
99 | if (irq < 0) { | 103 | if (irq < 0) { |
100 | pr_err("no irq provided"); | 104 | dev_err(&dev->dev, "no irq provided"); |
101 | return irq; | 105 | return irq; |
102 | } | 106 | } |
103 | 107 | ||
104 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | 108 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); |
105 | if (!res_mem) { | 109 | if (!res_mem) { |
106 | pr_err("no memory recourse provided"); | 110 | dev_err(&dev->dev, "no memory resource provided"); |
107 | return -ENXIO; | 111 | return -ENXIO; |
108 | } | 112 | } |
109 | 113 | ||
@@ -123,29 +127,19 @@ static int __devinit ohci_platform_probe(struct platform_device *dev) | |||
123 | hcd->rsrc_start = res_mem->start; | 127 | hcd->rsrc_start = res_mem->start; |
124 | hcd->rsrc_len = resource_size(res_mem); | 128 | hcd->rsrc_len = resource_size(res_mem); |
125 | 129 | ||
126 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 130 | hcd->regs = devm_request_and_ioremap(&dev->dev, res_mem); |
127 | pr_err("controller already in use"); | ||
128 | err = -EBUSY; | ||
129 | goto err_put_hcd; | ||
130 | } | ||
131 | |||
132 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
133 | if (!hcd->regs) { | 131 | if (!hcd->regs) { |
134 | err = -ENOMEM; | 132 | err = -ENOMEM; |
135 | goto err_release_region; | 133 | goto err_put_hcd; |
136 | } | 134 | } |
137 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 135 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
138 | if (err) | 136 | if (err) |
139 | goto err_iounmap; | 137 | goto err_put_hcd; |
140 | 138 | ||
141 | platform_set_drvdata(dev, hcd); | 139 | platform_set_drvdata(dev, hcd); |
142 | 140 | ||
143 | return err; | 141 | return err; |
144 | 142 | ||
145 | err_iounmap: | ||
146 | iounmap(hcd->regs); | ||
147 | err_release_region: | ||
148 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
149 | err_put_hcd: | 143 | err_put_hcd: |
150 | usb_put_hcd(hcd); | 144 | usb_put_hcd(hcd); |
151 | err_power: | 145 | err_power: |
@@ -161,8 +155,6 @@ static int __devexit ohci_platform_remove(struct platform_device *dev) | |||
161 | struct usb_ohci_pdata *pdata = dev->dev.platform_data; | 155 | struct usb_ohci_pdata *pdata = dev->dev.platform_data; |
162 | 156 | ||
163 | usb_remove_hcd(hcd); | 157 | usb_remove_hcd(hcd); |
164 | iounmap(hcd->regs); | ||
165 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
166 | usb_put_hcd(hcd); | 158 | usb_put_hcd(hcd); |
167 | platform_set_drvdata(dev, NULL); | 159 | platform_set_drvdata(dev, NULL); |
168 | 160 | ||
@@ -199,7 +191,7 @@ static int ohci_platform_resume(struct device *dev) | |||
199 | return err; | 191 | return err; |
200 | } | 192 | } |
201 | 193 | ||
202 | ohci_finish_controller_resume(hcd); | 194 | ohci_resume(hcd, false); |
203 | return 0; | 195 | return 0; |
204 | } | 196 | } |
205 | 197 | ||
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c deleted file mode 100644 index 148d27d6a67c..000000000000 --- a/drivers/usb/host/ohci-pnx8550.c +++ /dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | ||
5 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> | ||
6 | * (C) Copyright 2002 Hewlett-Packard Company | ||
7 | * (C) Copyright 2005 Embedded Alley Solutions, Inc. | ||
8 | * | ||
9 | * Bus Glue for PNX8550 | ||
10 | * | ||
11 | * Written by Christopher Hoover <ch@hpl.hp.com> | ||
12 | * Based on fragments of previous driver by Russell King et al. | ||
13 | * | ||
14 | * Modified for LH7A404 from ohci-sa1111.c | ||
15 | * by Durgesh Pattamatta <pattamattad@sharpsec.com> | ||
16 | * | ||
17 | * Modified for PNX8550 from ohci-sa1111.c and sa-omap.c | ||
18 | * by Vitaly Wool <vitalywool@gmail.com> | ||
19 | * | ||
20 | * This file is licenced under the GPL. | ||
21 | */ | ||
22 | |||
23 | #include <linux/device.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <asm/mach-pnx8550/usb.h> | ||
26 | #include <asm/mach-pnx8550/int.h> | ||
27 | #include <asm/mach-pnx8550/pci.h> | ||
28 | |||
29 | #ifndef CONFIG_PNX8550 | ||
30 | #error "This file is PNX8550 bus glue. CONFIG_PNX8550 must be defined." | ||
31 | #endif | ||
32 | |||
33 | extern int usb_disabled(void); | ||
34 | |||
35 | /*-------------------------------------------------------------------------*/ | ||
36 | |||
37 | static void pnx8550_start_hc(struct platform_device *dev) | ||
38 | { | ||
39 | /* | ||
40 | * Set register CLK48CTL to enable and 48MHz | ||
41 | */ | ||
42 | outl(0x00000003, PCI_BASE | 0x0004770c); | ||
43 | |||
44 | /* | ||
45 | * Set register CLK12CTL to enable and 48MHz | ||
46 | */ | ||
47 | outl(0x00000003, PCI_BASE | 0x00047710); | ||
48 | |||
49 | udelay(100); | ||
50 | } | ||
51 | |||
52 | static void pnx8550_stop_hc(struct platform_device *dev) | ||
53 | { | ||
54 | udelay(10); | ||
55 | } | ||
56 | |||
57 | |||
58 | /*-------------------------------------------------------------------------*/ | ||
59 | |||
60 | /* configure so an HC device and id are always provided */ | ||
61 | /* always called with process context; sleeping is OK */ | ||
62 | |||
63 | |||
64 | /** | ||
65 | * usb_hcd_pnx8550_probe - initialize pnx8550-based HCDs | ||
66 | * Context: !in_interrupt() | ||
67 | * | ||
68 | * Allocates basic resources for this USB host controller, and | ||
69 | * then invokes the start() method for the HCD associated with it | ||
70 | * through the hotplug entry's driver_data. | ||
71 | * | ||
72 | */ | ||
73 | int usb_hcd_pnx8550_probe (const struct hc_driver *driver, | ||
74 | struct platform_device *dev) | ||
75 | { | ||
76 | int retval; | ||
77 | struct usb_hcd *hcd; | ||
78 | |||
79 | if (dev->resource[0].flags != IORESOURCE_MEM || | ||
80 | dev->resource[1].flags != IORESOURCE_IRQ) { | ||
81 | dev_err (&dev->dev,"invalid resource type\n"); | ||
82 | return -ENOMEM; | ||
83 | } | ||
84 | |||
85 | hcd = usb_create_hcd (driver, &dev->dev, "pnx8550"); | ||
86 | if (!hcd) | ||
87 | return -ENOMEM; | ||
88 | hcd->rsrc_start = dev->resource[0].start; | ||
89 | hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; | ||
90 | |||
91 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
92 | dev_err(&dev->dev, "request_mem_region [0x%08llx, 0x%08llx] " | ||
93 | "failed\n", hcd->rsrc_start, hcd->rsrc_len); | ||
94 | retval = -EBUSY; | ||
95 | goto err1; | ||
96 | } | ||
97 | |||
98 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
99 | if (!hcd->regs) { | ||
100 | dev_err(&dev->dev, "ioremap [[0x%08llx, 0x%08llx] failed\n", | ||
101 | hcd->rsrc_start, hcd->rsrc_len); | ||
102 | retval = -ENOMEM; | ||
103 | goto err2; | ||
104 | } | ||
105 | |||
106 | pnx8550_start_hc(dev); | ||
107 | |||
108 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
109 | |||
110 | retval = usb_add_hcd(hcd, dev->resource[1].start, 0); | ||
111 | if (retval == 0) | ||
112 | return retval; | ||
113 | |||
114 | pnx8550_stop_hc(dev); | ||
115 | iounmap(hcd->regs); | ||
116 | err2: | ||
117 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
118 | err1: | ||
119 | usb_put_hcd(hcd); | ||
120 | return retval; | ||
121 | } | ||
122 | |||
123 | |||
124 | /* may be called without controller electrically present */ | ||
125 | /* may be called with controller, bus, and devices active */ | ||
126 | |||
127 | /** | ||
128 | * usb_hcd_pnx8550_remove - shutdown processing for pnx8550-based HCDs | ||
129 | * @dev: USB Host Controller being removed | ||
130 | * Context: !in_interrupt() | ||
131 | * | ||
132 | * Reverses the effect of usb_hcd_pnx8550_probe(), first invoking | ||
133 | * the HCD's stop() method. It is always called from a thread | ||
134 | * context, normally "rmmod", "apmd", or something similar. | ||
135 | * | ||
136 | */ | ||
137 | void usb_hcd_pnx8550_remove (struct usb_hcd *hcd, struct platform_device *dev) | ||
138 | { | ||
139 | usb_remove_hcd(hcd); | ||
140 | pnx8550_stop_hc(dev); | ||
141 | iounmap(hcd->regs); | ||
142 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
143 | usb_put_hcd(hcd); | ||
144 | } | ||
145 | |||
146 | /*-------------------------------------------------------------------------*/ | ||
147 | |||
148 | static int __devinit | ||
149 | ohci_pnx8550_start (struct usb_hcd *hcd) | ||
150 | { | ||
151 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | ||
152 | int ret; | ||
153 | |||
154 | ohci_dbg (ohci, "ohci_pnx8550_start, ohci:%p", ohci); | ||
155 | |||
156 | if ((ret = ohci_init(ohci)) < 0) | ||
157 | return ret; | ||
158 | |||
159 | if ((ret = ohci_run (ohci)) < 0) { | ||
160 | dev_err(hcd->self.controller, "can't start %s", | ||
161 | hcd->self.bus_name); | ||
162 | ohci_stop (hcd); | ||
163 | return ret; | ||
164 | } | ||
165 | |||
166 | return 0; | ||
167 | } | ||
168 | |||
169 | /*-------------------------------------------------------------------------*/ | ||
170 | |||
171 | static const struct hc_driver ohci_pnx8550_hc_driver = { | ||
172 | .description = hcd_name, | ||
173 | .product_desc = "PNX8550 OHCI", | ||
174 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
175 | |||
176 | /* | ||
177 | * generic hardware linkage | ||
178 | */ | ||
179 | .irq = ohci_irq, | ||
180 | .flags = HCD_USB11 | HCD_MEMORY, | ||
181 | |||
182 | /* | ||
183 | * basic lifecycle operations | ||
184 | */ | ||
185 | .start = ohci_pnx8550_start, | ||
186 | .stop = ohci_stop, | ||
187 | |||
188 | /* | ||
189 | * managing i/o requests and associated device resources | ||
190 | */ | ||
191 | .urb_enqueue = ohci_urb_enqueue, | ||
192 | .urb_dequeue = ohci_urb_dequeue, | ||
193 | .endpoint_disable = ohci_endpoint_disable, | ||
194 | |||
195 | /* | ||
196 | * scheduling support | ||
197 | */ | ||
198 | .get_frame_number = ohci_get_frame, | ||
199 | |||
200 | /* | ||
201 | * root hub support | ||
202 | */ | ||
203 | .hub_status_data = ohci_hub_status_data, | ||
204 | .hub_control = ohci_hub_control, | ||
205 | #ifdef CONFIG_PM | ||
206 | .bus_suspend = ohci_bus_suspend, | ||
207 | .bus_resume = ohci_bus_resume, | ||
208 | #endif | ||
209 | .start_port_reset = ohci_start_port_reset, | ||
210 | }; | ||
211 | |||
212 | /*-------------------------------------------------------------------------*/ | ||
213 | |||
214 | static int ohci_hcd_pnx8550_drv_probe(struct platform_device *pdev) | ||
215 | { | ||
216 | int ret; | ||
217 | |||
218 | if (usb_disabled()) | ||
219 | return -ENODEV; | ||
220 | |||
221 | ret = usb_hcd_pnx8550_probe(&ohci_pnx8550_hc_driver, pdev); | ||
222 | return ret; | ||
223 | } | ||
224 | |||
225 | static int ohci_hcd_pnx8550_drv_remove(struct platform_device *pdev) | ||
226 | { | ||
227 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
228 | |||
229 | usb_hcd_pnx8550_remove(hcd, pdev); | ||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | MODULE_ALIAS("platform:pnx8550-ohci"); | ||
234 | |||
235 | static struct platform_driver ohci_hcd_pnx8550_driver = { | ||
236 | .driver = { | ||
237 | .name = "pnx8550-ohci", | ||
238 | .owner = THIS_MODULE, | ||
239 | }, | ||
240 | .probe = ohci_hcd_pnx8550_drv_probe, | ||
241 | .remove = ohci_hcd_pnx8550_drv_remove, | ||
242 | }; | ||
243 | |||
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c deleted file mode 100644 index 185c39ed81b7..000000000000 --- a/drivers/usb/host/ohci-ppc-soc.c +++ /dev/null | |||
@@ -1,216 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> | ||
5 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> | ||
6 | * (C) Copyright 2002 Hewlett-Packard Company | ||
7 | * (C) Copyright 2003-2005 MontaVista Software Inc. | ||
8 | * | ||
9 | * Bus Glue for PPC On-Chip OHCI driver | ||
10 | * Tested on Freescale MPC5200 and IBM STB04xxx | ||
11 | * | ||
12 | * Modified by Dale Farnsworth <dale@farnsworth.org> from ohci-sa1111.c | ||
13 | * | ||
14 | * This file is licenced under the GPL. | ||
15 | */ | ||
16 | |||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/signal.h> | ||
19 | |||
20 | /* configure so an HC device and id are always provided */ | ||
21 | /* always called with process context; sleeping is OK */ | ||
22 | |||
23 | /** | ||
24 | * usb_hcd_ppc_soc_probe - initialize On-Chip HCDs | ||
25 | * Context: !in_interrupt() | ||
26 | * | ||
27 | * Allocates basic resources for this USB host controller. | ||
28 | * | ||
29 | * Store this function in the HCD's struct pci_driver as probe(). | ||
30 | */ | ||
31 | static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver, | ||
32 | struct platform_device *pdev) | ||
33 | { | ||
34 | int retval; | ||
35 | struct usb_hcd *hcd; | ||
36 | struct ohci_hcd *ohci; | ||
37 | struct resource *res; | ||
38 | int irq; | ||
39 | |||
40 | pr_debug("initializing PPC-SOC USB Controller\n"); | ||
41 | |||
42 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
43 | if (!res) { | ||
44 | pr_debug("%s: no irq\n", __FILE__); | ||
45 | return -ENODEV; | ||
46 | } | ||
47 | irq = res->start; | ||
48 | |||
49 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
50 | if (!res) { | ||
51 | pr_debug("%s: no reg addr\n", __FILE__); | ||
52 | return -ENODEV; | ||
53 | } | ||
54 | |||
55 | hcd = usb_create_hcd(driver, &pdev->dev, "PPC-SOC USB"); | ||
56 | if (!hcd) | ||
57 | return -ENOMEM; | ||
58 | hcd->rsrc_start = res->start; | ||
59 | hcd->rsrc_len = resource_size(res); | ||
60 | |||
61 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
62 | pr_debug("%s: request_mem_region failed\n", __FILE__); | ||
63 | retval = -EBUSY; | ||
64 | goto err1; | ||
65 | } | ||
66 | |||
67 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
68 | if (!hcd->regs) { | ||
69 | pr_debug("%s: ioremap failed\n", __FILE__); | ||
70 | retval = -ENOMEM; | ||
71 | goto err2; | ||
72 | } | ||
73 | |||
74 | ohci = hcd_to_ohci(hcd); | ||
75 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; | ||
76 | |||
77 | #ifdef CONFIG_PPC_MPC52xx | ||
78 | /* MPC52xx doesn't need frame_no shift */ | ||
79 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | ||
80 | #endif | ||
81 | ohci_hcd_init(ohci); | ||
82 | |||
83 | retval = usb_add_hcd(hcd, irq, 0); | ||
84 | if (retval == 0) | ||
85 | return retval; | ||
86 | |||
87 | pr_debug("Removing PPC-SOC USB Controller\n"); | ||
88 | |||
89 | iounmap(hcd->regs); | ||
90 | err2: | ||
91 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
92 | err1: | ||
93 | usb_put_hcd(hcd); | ||
94 | return retval; | ||
95 | } | ||
96 | |||
97 | |||
98 | /* may be called without controller electrically present */ | ||
99 | /* may be called with controller, bus, and devices active */ | ||
100 | |||
101 | /** | ||
102 | * usb_hcd_ppc_soc_remove - shutdown processing for On-Chip HCDs | ||
103 | * @pdev: USB Host Controller being removed | ||
104 | * Context: !in_interrupt() | ||
105 | * | ||
106 | * Reverses the effect of usb_hcd_ppc_soc_probe(). | ||
107 | * It is always called from a thread | ||
108 | * context, normally "rmmod", "apmd", or something similar. | ||
109 | * | ||
110 | */ | ||
111 | static void usb_hcd_ppc_soc_remove(struct usb_hcd *hcd, | ||
112 | struct platform_device *pdev) | ||
113 | { | ||
114 | usb_remove_hcd(hcd); | ||
115 | |||
116 | pr_debug("stopping PPC-SOC USB Controller\n"); | ||
117 | |||
118 | iounmap(hcd->regs); | ||
119 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
120 | usb_put_hcd(hcd); | ||
121 | } | ||
122 | |||
123 | static int __devinit | ||
124 | ohci_ppc_soc_start(struct usb_hcd *hcd) | ||
125 | { | ||
126 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
127 | int ret; | ||
128 | |||
129 | if ((ret = ohci_init(ohci)) < 0) | ||
130 | return ret; | ||
131 | |||
132 | if ((ret = ohci_run(ohci)) < 0) { | ||
133 | dev_err(hcd->self.controller, "can't start %s\n", | ||
134 | hcd->self.bus_name); | ||
135 | ohci_stop(hcd); | ||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static const struct hc_driver ohci_ppc_soc_hc_driver = { | ||
143 | .description = hcd_name, | ||
144 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
145 | |||
146 | /* | ||
147 | * generic hardware linkage | ||
148 | */ | ||
149 | .irq = ohci_irq, | ||
150 | .flags = HCD_USB11 | HCD_MEMORY, | ||
151 | |||
152 | /* | ||
153 | * basic lifecycle operations | ||
154 | */ | ||
155 | .start = ohci_ppc_soc_start, | ||
156 | .stop = ohci_stop, | ||
157 | .shutdown = ohci_shutdown, | ||
158 | |||
159 | /* | ||
160 | * managing i/o requests and associated device resources | ||
161 | */ | ||
162 | .urb_enqueue = ohci_urb_enqueue, | ||
163 | .urb_dequeue = ohci_urb_dequeue, | ||
164 | .endpoint_disable = ohci_endpoint_disable, | ||
165 | |||
166 | /* | ||
167 | * scheduling support | ||
168 | */ | ||
169 | .get_frame_number = ohci_get_frame, | ||
170 | |||
171 | /* | ||
172 | * root hub support | ||
173 | */ | ||
174 | .hub_status_data = ohci_hub_status_data, | ||
175 | .hub_control = ohci_hub_control, | ||
176 | #ifdef CONFIG_PM | ||
177 | .bus_suspend = ohci_bus_suspend, | ||
178 | .bus_resume = ohci_bus_resume, | ||
179 | #endif | ||
180 | .start_port_reset = ohci_start_port_reset, | ||
181 | }; | ||
182 | |||
183 | static int ohci_hcd_ppc_soc_drv_probe(struct platform_device *pdev) | ||
184 | { | ||
185 | int ret; | ||
186 | |||
187 | if (usb_disabled()) | ||
188 | return -ENODEV; | ||
189 | |||
190 | ret = usb_hcd_ppc_soc_probe(&ohci_ppc_soc_hc_driver, pdev); | ||
191 | return ret; | ||
192 | } | ||
193 | |||
194 | static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev) | ||
195 | { | ||
196 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
197 | |||
198 | usb_hcd_ppc_soc_remove(hcd, pdev); | ||
199 | return 0; | ||
200 | } | ||
201 | |||
202 | static struct platform_driver ohci_hcd_ppc_soc_driver = { | ||
203 | .probe = ohci_hcd_ppc_soc_drv_probe, | ||
204 | .remove = ohci_hcd_ppc_soc_drv_remove, | ||
205 | .shutdown = usb_hcd_platform_shutdown, | ||
206 | #ifdef CONFIG_PM | ||
207 | /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ | ||
208 | /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ | ||
209 | #endif | ||
210 | .driver = { | ||
211 | .name = "ppc-soc-ohci", | ||
212 | .owner = THIS_MODULE, | ||
213 | }, | ||
214 | }; | ||
215 | |||
216 | MODULE_ALIAS("platform:ppc-soc-ohci"); | ||
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 2bf11440b010..156d289d3bb5 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -591,7 +591,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct device *dev) | |||
591 | /* Select Power Management Mode */ | 591 | /* Select Power Management Mode */ |
592 | pxa27x_ohci_select_pmm(ohci, inf->port_mode); | 592 | pxa27x_ohci_select_pmm(ohci, inf->port_mode); |
593 | 593 | ||
594 | ohci_finish_controller_resume(hcd); | 594 | ohci_resume(hcd, false); |
595 | return 0; | 595 | return 0; |
596 | } | 596 | } |
597 | 597 | ||
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c index c5a1ea9145fa..177a213790d4 100644 --- a/drivers/usb/host/ohci-q.c +++ b/drivers/usb/host/ohci-q.c | |||
@@ -596,7 +596,6 @@ static void td_submit_urb ( | |||
596 | urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); | 596 | urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); |
597 | } | 597 | } |
598 | 598 | ||
599 | urb_priv->td_cnt = 0; | ||
600 | list_add (&urb_priv->pending, &ohci->pending); | 599 | list_add (&urb_priv->pending, &ohci->pending); |
601 | 600 | ||
602 | if (data_len) | 601 | if (data_len) |
@@ -672,7 +671,8 @@ static void td_submit_urb ( | |||
672 | * we could often reduce the number of TDs here. | 671 | * we could often reduce the number of TDs here. |
673 | */ | 672 | */ |
674 | case PIPE_ISOCHRONOUS: | 673 | case PIPE_ISOCHRONOUS: |
675 | for (cnt = 0; cnt < urb->number_of_packets; cnt++) { | 674 | for (cnt = urb_priv->td_cnt; cnt < urb->number_of_packets; |
675 | cnt++) { | ||
676 | int frame = urb->start_frame; | 676 | int frame = urb->start_frame; |
677 | 677 | ||
678 | // FIXME scheduling should handle frame counter | 678 | // FIXME scheduling should handle frame counter |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index 0d2309ca471e..e84190f25c6b 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c | |||
@@ -323,8 +323,6 @@ usb_hcd_s3c2410_remove(struct usb_hcd *hcd, struct platform_device *dev) | |||
323 | { | 323 | { |
324 | usb_remove_hcd(hcd); | 324 | usb_remove_hcd(hcd); |
325 | s3c2410_stop_hc(dev); | 325 | s3c2410_stop_hc(dev); |
326 | iounmap(hcd->regs); | ||
327 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
328 | usb_put_hcd(hcd); | 326 | usb_put_hcd(hcd); |
329 | } | 327 | } |
330 | 328 | ||
@@ -353,35 +351,29 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver, | |||
353 | hcd->rsrc_start = dev->resource[0].start; | 351 | hcd->rsrc_start = dev->resource[0].start; |
354 | hcd->rsrc_len = resource_size(&dev->resource[0]); | 352 | hcd->rsrc_len = resource_size(&dev->resource[0]); |
355 | 353 | ||
356 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 354 | hcd->regs = devm_request_and_ioremap(&dev->dev, &dev->resource[0]); |
357 | dev_err(&dev->dev, "request_mem_region failed\n"); | 355 | if (!hcd->regs) { |
358 | retval = -EBUSY; | 356 | dev_err(&dev->dev, "devm_request_and_ioremap failed\n"); |
357 | retval = -ENOMEM; | ||
359 | goto err_put; | 358 | goto err_put; |
360 | } | 359 | } |
361 | 360 | ||
362 | clk = clk_get(&dev->dev, "usb-host"); | 361 | clk = devm_clk_get(&dev->dev, "usb-host"); |
363 | if (IS_ERR(clk)) { | 362 | if (IS_ERR(clk)) { |
364 | dev_err(&dev->dev, "cannot get usb-host clock\n"); | 363 | dev_err(&dev->dev, "cannot get usb-host clock\n"); |
365 | retval = PTR_ERR(clk); | 364 | retval = PTR_ERR(clk); |
366 | goto err_mem; | 365 | goto err_put; |
367 | } | 366 | } |
368 | 367 | ||
369 | usb_clk = clk_get(&dev->dev, "usb-bus-host"); | 368 | usb_clk = devm_clk_get(&dev->dev, "usb-bus-host"); |
370 | if (IS_ERR(usb_clk)) { | 369 | if (IS_ERR(usb_clk)) { |
371 | dev_err(&dev->dev, "cannot get usb-bus-host clock\n"); | 370 | dev_err(&dev->dev, "cannot get usb-bus-host clock\n"); |
372 | retval = PTR_ERR(usb_clk); | 371 | retval = PTR_ERR(usb_clk); |
373 | goto err_clk; | 372 | goto err_put; |
374 | } | 373 | } |
375 | 374 | ||
376 | s3c2410_start_hc(dev, hcd); | 375 | s3c2410_start_hc(dev, hcd); |
377 | 376 | ||
378 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
379 | if (!hcd->regs) { | ||
380 | dev_err(&dev->dev, "ioremap failed\n"); | ||
381 | retval = -ENOMEM; | ||
382 | goto err_ioremap; | ||
383 | } | ||
384 | |||
385 | ohci_hcd_init(hcd_to_ohci(hcd)); | 377 | ohci_hcd_init(hcd_to_ohci(hcd)); |
386 | 378 | ||
387 | retval = usb_add_hcd(hcd, dev->resource[1].start, 0); | 379 | retval = usb_add_hcd(hcd, dev->resource[1].start, 0); |
@@ -392,14 +384,6 @@ static int usb_hcd_s3c2410_probe(const struct hc_driver *driver, | |||
392 | 384 | ||
393 | err_ioremap: | 385 | err_ioremap: |
394 | s3c2410_stop_hc(dev); | 386 | s3c2410_stop_hc(dev); |
395 | iounmap(hcd->regs); | ||
396 | clk_put(usb_clk); | ||
397 | |||
398 | err_clk: | ||
399 | clk_put(clk); | ||
400 | |||
401 | err_mem: | ||
402 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
403 | 387 | ||
404 | err_put: | 388 | err_put: |
405 | usb_put_hcd(hcd); | 389 | usb_put_hcd(hcd); |
@@ -524,8 +508,7 @@ static int ohci_hcd_s3c2410_drv_resume(struct device *dev) | |||
524 | 508 | ||
525 | s3c2410_start_hc(pdev, hcd); | 509 | s3c2410_start_hc(pdev, hcd); |
526 | 510 | ||
527 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 511 | ohci_resume(hcd, false); |
528 | ohci_finish_controller_resume(hcd); | ||
529 | 512 | ||
530 | return 0; | 513 | return 0; |
531 | } | 514 | } |
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c deleted file mode 100644 index 76a20c278362..000000000000 --- a/drivers/usb/host/ohci-sh.c +++ /dev/null | |||
@@ -1,141 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * Copyright (C) 2008 Renesas Solutions Corp. | ||
5 | * | ||
6 | * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; version 2 of the License. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/platform_device.h> | ||
24 | |||
25 | static int ohci_sh_start(struct usb_hcd *hcd) | ||
26 | { | ||
27 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
28 | |||
29 | ohci_hcd_init(ohci); | ||
30 | ohci_init(ohci); | ||
31 | ohci_run(ohci); | ||
32 | return 0; | ||
33 | } | ||
34 | |||
35 | static const struct hc_driver ohci_sh_hc_driver = { | ||
36 | .description = hcd_name, | ||
37 | .product_desc = "SuperH OHCI", | ||
38 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
39 | |||
40 | /* | ||
41 | * generic hardware linkage | ||
42 | */ | ||
43 | .irq = ohci_irq, | ||
44 | .flags = HCD_USB11 | HCD_MEMORY, | ||
45 | |||
46 | /* | ||
47 | * basic lifecycle operations | ||
48 | */ | ||
49 | .start = ohci_sh_start, | ||
50 | .stop = ohci_stop, | ||
51 | .shutdown = ohci_shutdown, | ||
52 | |||
53 | /* | ||
54 | * managing i/o requests and associated device resources | ||
55 | */ | ||
56 | .urb_enqueue = ohci_urb_enqueue, | ||
57 | .urb_dequeue = ohci_urb_dequeue, | ||
58 | .endpoint_disable = ohci_endpoint_disable, | ||
59 | |||
60 | /* | ||
61 | * scheduling support | ||
62 | */ | ||
63 | .get_frame_number = ohci_get_frame, | ||
64 | |||
65 | /* | ||
66 | * root hub support | ||
67 | */ | ||
68 | .hub_status_data = ohci_hub_status_data, | ||
69 | .hub_control = ohci_hub_control, | ||
70 | #ifdef CONFIG_PM | ||
71 | .bus_suspend = ohci_bus_suspend, | ||
72 | .bus_resume = ohci_bus_resume, | ||
73 | #endif | ||
74 | .start_port_reset = ohci_start_port_reset, | ||
75 | }; | ||
76 | |||
77 | /*-------------------------------------------------------------------------*/ | ||
78 | |||
79 | static int ohci_hcd_sh_probe(struct platform_device *pdev) | ||
80 | { | ||
81 | struct resource *res = NULL; | ||
82 | struct usb_hcd *hcd = NULL; | ||
83 | int irq = -1; | ||
84 | int ret; | ||
85 | |||
86 | if (usb_disabled()) | ||
87 | return -ENODEV; | ||
88 | |||
89 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
90 | if (!res) { | ||
91 | dev_err(&pdev->dev, "platform_get_resource error.\n"); | ||
92 | return -ENODEV; | ||
93 | } | ||
94 | |||
95 | irq = platform_get_irq(pdev, 0); | ||
96 | if (irq < 0) { | ||
97 | dev_err(&pdev->dev, "platform_get_irq error.\n"); | ||
98 | return -ENODEV; | ||
99 | } | ||
100 | |||
101 | /* initialize hcd */ | ||
102 | hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name); | ||
103 | if (!hcd) { | ||
104 | dev_err(&pdev->dev, "Failed to create hcd\n"); | ||
105 | return -ENOMEM; | ||
106 | } | ||
107 | |||
108 | hcd->regs = (void __iomem *)res->start; | ||
109 | hcd->rsrc_start = res->start; | ||
110 | hcd->rsrc_len = resource_size(res); | ||
111 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
112 | if (ret != 0) { | ||
113 | dev_err(&pdev->dev, "Failed to add hcd\n"); | ||
114 | usb_put_hcd(hcd); | ||
115 | return ret; | ||
116 | } | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | static int ohci_hcd_sh_remove(struct platform_device *pdev) | ||
122 | { | ||
123 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
124 | |||
125 | usb_remove_hcd(hcd); | ||
126 | usb_put_hcd(hcd); | ||
127 | |||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static struct platform_driver ohci_hcd_sh_driver = { | ||
132 | .probe = ohci_hcd_sh_probe, | ||
133 | .remove = ohci_hcd_sh_remove, | ||
134 | .shutdown = usb_hcd_platform_shutdown, | ||
135 | .driver = { | ||
136 | .name = "sh_ohci", | ||
137 | .owner = THIS_MODULE, | ||
138 | }, | ||
139 | }; | ||
140 | |||
141 | MODULE_ALIAS("platform:sh_ohci"); | ||
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c index 5596ac2ba1ca..3b5b908fd47b 100644 --- a/drivers/usb/host/ohci-sm501.c +++ b/drivers/usb/host/ohci-sm501.c | |||
@@ -238,7 +238,7 @@ static int ohci_sm501_resume(struct platform_device *pdev) | |||
238 | ohci->next_statechange = jiffies; | 238 | ohci->next_statechange = jiffies; |
239 | 239 | ||
240 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); | 240 | sm501_unit_power(dev->parent, SM501_GATE_USB_HOST, 1); |
241 | ohci_finish_controller_resume(hcd); | 241 | ohci_resume(hcd, false); |
242 | return 0; | 242 | return 0; |
243 | } | 243 | } |
244 | #else | 244 | #else |
diff --git a/drivers/usb/host/ohci-spear.c b/drivers/usb/host/ohci-spear.c index fc7305ee3c9c..c69725d9f0cd 100644 --- a/drivers/usb/host/ohci-spear.c +++ b/drivers/usb/host/ohci-spear.c | |||
@@ -101,13 +101,11 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev) | |||
101 | struct spear_ohci *ohci_p; | 101 | struct spear_ohci *ohci_p; |
102 | struct resource *res; | 102 | struct resource *res; |
103 | int retval, irq; | 103 | int retval, irq; |
104 | char clk_name[20] = "usbh_clk"; | ||
105 | static int instance = -1; | ||
106 | 104 | ||
107 | irq = platform_get_irq(pdev, 0); | 105 | irq = platform_get_irq(pdev, 0); |
108 | if (irq < 0) { | 106 | if (irq < 0) { |
109 | retval = irq; | 107 | retval = irq; |
110 | goto fail_irq_get; | 108 | goto fail; |
111 | } | 109 | } |
112 | 110 | ||
113 | /* | 111 | /* |
@@ -118,47 +116,39 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev) | |||
118 | if (!pdev->dev.dma_mask) | 116 | if (!pdev->dev.dma_mask) |
119 | pdev->dev.dma_mask = &spear_ohci_dma_mask; | 117 | pdev->dev.dma_mask = &spear_ohci_dma_mask; |
120 | 118 | ||
121 | /* | 119 | usbh_clk = devm_clk_get(&pdev->dev, NULL); |
122 | * Increment the device instance, when probing via device-tree | ||
123 | */ | ||
124 | if (pdev->id < 0) | ||
125 | instance++; | ||
126 | else | ||
127 | instance = pdev->id; | ||
128 | sprintf(clk_name, "usbh.%01d_clk", instance); | ||
129 | |||
130 | usbh_clk = clk_get(NULL, clk_name); | ||
131 | if (IS_ERR(usbh_clk)) { | 120 | if (IS_ERR(usbh_clk)) { |
132 | dev_err(&pdev->dev, "Error getting interface clock\n"); | 121 | dev_err(&pdev->dev, "Error getting interface clock\n"); |
133 | retval = PTR_ERR(usbh_clk); | 122 | retval = PTR_ERR(usbh_clk); |
134 | goto fail_get_usbh_clk; | 123 | goto fail; |
135 | } | 124 | } |
136 | 125 | ||
137 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | 126 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); |
138 | if (!hcd) { | 127 | if (!hcd) { |
139 | retval = -ENOMEM; | 128 | retval = -ENOMEM; |
140 | goto fail_create_hcd; | 129 | goto fail; |
141 | } | 130 | } |
142 | 131 | ||
143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 132 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
144 | if (!res) { | 133 | if (!res) { |
145 | retval = -ENODEV; | 134 | retval = -ENODEV; |
146 | goto fail_request_resource; | 135 | goto err_put_hcd; |
147 | } | 136 | } |
148 | 137 | ||
149 | hcd->rsrc_start = pdev->resource[0].start; | 138 | hcd->rsrc_start = pdev->resource[0].start; |
150 | hcd->rsrc_len = resource_size(res); | 139 | hcd->rsrc_len = resource_size(res); |
151 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | 140 | if (!devm_request_mem_region(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len, |
141 | hcd_name)) { | ||
152 | dev_dbg(&pdev->dev, "request_mem_region failed\n"); | 142 | dev_dbg(&pdev->dev, "request_mem_region failed\n"); |
153 | retval = -EBUSY; | 143 | retval = -EBUSY; |
154 | goto fail_request_resource; | 144 | goto err_put_hcd; |
155 | } | 145 | } |
156 | 146 | ||
157 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | 147 | hcd->regs = devm_ioremap(&pdev->dev, hcd->rsrc_start, hcd->rsrc_len); |
158 | if (!hcd->regs) { | 148 | if (!hcd->regs) { |
159 | dev_dbg(&pdev->dev, "ioremap failed\n"); | 149 | dev_dbg(&pdev->dev, "ioremap failed\n"); |
160 | retval = -ENOMEM; | 150 | retval = -ENOMEM; |
161 | goto fail_ioremap; | 151 | goto err_put_hcd; |
162 | } | 152 | } |
163 | 153 | ||
164 | ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd); | 154 | ohci_p = (struct spear_ohci *)hcd_to_ohci(hcd); |
@@ -171,15 +161,9 @@ static int spear_ohci_hcd_drv_probe(struct platform_device *pdev) | |||
171 | return retval; | 161 | return retval; |
172 | 162 | ||
173 | spear_stop_ohci(ohci_p); | 163 | spear_stop_ohci(ohci_p); |
174 | iounmap(hcd->regs); | 164 | err_put_hcd: |
175 | fail_ioremap: | ||
176 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
177 | fail_request_resource: | ||
178 | usb_put_hcd(hcd); | 165 | usb_put_hcd(hcd); |
179 | fail_create_hcd: | 166 | fail: |
180 | clk_put(usbh_clk); | ||
181 | fail_get_usbh_clk: | ||
182 | fail_irq_get: | ||
183 | dev_err(&pdev->dev, "init fail, %d\n", retval); | 167 | dev_err(&pdev->dev, "init fail, %d\n", retval); |
184 | 168 | ||
185 | return retval; | 169 | return retval; |
@@ -194,12 +178,8 @@ static int spear_ohci_hcd_drv_remove(struct platform_device *pdev) | |||
194 | if (ohci_p->clk) | 178 | if (ohci_p->clk) |
195 | spear_stop_ohci(ohci_p); | 179 | spear_stop_ohci(ohci_p); |
196 | 180 | ||
197 | iounmap(hcd->regs); | ||
198 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
199 | usb_put_hcd(hcd); | 181 | usb_put_hcd(hcd); |
200 | 182 | ||
201 | if (ohci_p->clk) | ||
202 | clk_put(ohci_p->clk); | ||
203 | platform_set_drvdata(pdev, NULL); | 183 | platform_set_drvdata(pdev, NULL); |
204 | return 0; | 184 | return 0; |
205 | } | 185 | } |
@@ -231,7 +211,7 @@ static int spear_ohci_hcd_drv_resume(struct platform_device *dev) | |||
231 | ohci->next_statechange = jiffies; | 211 | ohci->next_statechange = jiffies; |
232 | 212 | ||
233 | spear_start_ohci(ohci_p); | 213 | spear_start_ohci(ohci_p); |
234 | ohci_finish_controller_resume(hcd); | 214 | ohci_resume(hcd, false); |
235 | return 0; | 215 | return 0; |
236 | } | 216 | } |
237 | #endif | 217 | #endif |
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index 60c2b0722f2e..2c9ab8f126d4 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c | |||
@@ -352,7 +352,7 @@ static int ohci_hcd_tmio_drv_resume(struct platform_device *dev) | |||
352 | 352 | ||
353 | spin_unlock_irqrestore(&tmio->lock, flags); | 353 | spin_unlock_irqrestore(&tmio->lock, flags); |
354 | 354 | ||
355 | ohci_finish_controller_resume(hcd); | 355 | ohci_resume(hcd, false); |
356 | 356 | ||
357 | return 0; | 357 | return 0; |
358 | } | 358 | } |
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c deleted file mode 100644 index 41e378f17c66..000000000000 --- a/drivers/usb/host/ohci-xls.c +++ /dev/null | |||
@@ -1,152 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD for Netlogic XLS processors. | ||
3 | * | ||
4 | * (C) Copyright 2011 Netlogic Microsystems Inc. | ||
5 | * | ||
6 | * Based on ohci-au1xxx.c, and other Linux OHCI drivers. | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/signal.h> | ||
15 | |||
16 | static int ohci_xls_probe_internal(const struct hc_driver *driver, | ||
17 | struct platform_device *dev) | ||
18 | { | ||
19 | struct resource *res; | ||
20 | struct usb_hcd *hcd; | ||
21 | int retval, irq; | ||
22 | |||
23 | /* Get our IRQ from an earlier registered Platform Resource */ | ||
24 | irq = platform_get_irq(dev, 0); | ||
25 | if (irq < 0) { | ||
26 | dev_err(&dev->dev, "Found HC with no IRQ\n"); | ||
27 | return -ENODEV; | ||
28 | } | ||
29 | |||
30 | /* Get our Memory Handle */ | ||
31 | res = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
32 | if (!res) { | ||
33 | dev_err(&dev->dev, "MMIO Handle incorrect!\n"); | ||
34 | return -ENODEV; | ||
35 | } | ||
36 | |||
37 | hcd = usb_create_hcd(driver, &dev->dev, "XLS"); | ||
38 | if (!hcd) { | ||
39 | retval = -ENOMEM; | ||
40 | goto err1; | ||
41 | } | ||
42 | hcd->rsrc_start = res->start; | ||
43 | hcd->rsrc_len = resource_size(res); | ||
44 | |||
45 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
46 | driver->description)) { | ||
47 | dev_dbg(&dev->dev, "Controller already in use\n"); | ||
48 | retval = -EBUSY; | ||
49 | goto err2; | ||
50 | } | ||
51 | |||
52 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
53 | if (hcd->regs == NULL) { | ||
54 | dev_dbg(&dev->dev, "error mapping memory\n"); | ||
55 | retval = -EFAULT; | ||
56 | goto err3; | ||
57 | } | ||
58 | |||
59 | retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | ||
60 | if (retval != 0) | ||
61 | goto err4; | ||
62 | return retval; | ||
63 | |||
64 | err4: | ||
65 | iounmap(hcd->regs); | ||
66 | err3: | ||
67 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
68 | err2: | ||
69 | usb_put_hcd(hcd); | ||
70 | err1: | ||
71 | dev_err(&dev->dev, "init fail, %d\n", retval); | ||
72 | return retval; | ||
73 | } | ||
74 | |||
75 | static int ohci_xls_reset(struct usb_hcd *hcd) | ||
76 | { | ||
77 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
78 | |||
79 | ohci_hcd_init(ohci); | ||
80 | return ohci_init(ohci); | ||
81 | } | ||
82 | |||
83 | static int __devinit ohci_xls_start(struct usb_hcd *hcd) | ||
84 | { | ||
85 | struct ohci_hcd *ohci; | ||
86 | int ret; | ||
87 | |||
88 | ohci = hcd_to_ohci(hcd); | ||
89 | ret = ohci_run(ohci); | ||
90 | if (ret < 0) { | ||
91 | dev_err(hcd->self.controller, "can't start %s\n", | ||
92 | hcd->self.bus_name); | ||
93 | ohci_stop(hcd); | ||
94 | return ret; | ||
95 | } | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static struct hc_driver ohci_xls_hc_driver = { | ||
100 | .description = hcd_name, | ||
101 | .product_desc = "XLS OHCI Host Controller", | ||
102 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
103 | .irq = ohci_irq, | ||
104 | .flags = HCD_MEMORY | HCD_USB11, | ||
105 | .reset = ohci_xls_reset, | ||
106 | .start = ohci_xls_start, | ||
107 | .stop = ohci_stop, | ||
108 | .shutdown = ohci_shutdown, | ||
109 | .urb_enqueue = ohci_urb_enqueue, | ||
110 | .urb_dequeue = ohci_urb_dequeue, | ||
111 | .endpoint_disable = ohci_endpoint_disable, | ||
112 | .get_frame_number = ohci_get_frame, | ||
113 | .hub_status_data = ohci_hub_status_data, | ||
114 | .hub_control = ohci_hub_control, | ||
115 | #ifdef CONFIG_PM | ||
116 | .bus_suspend = ohci_bus_suspend, | ||
117 | .bus_resume = ohci_bus_resume, | ||
118 | #endif | ||
119 | .start_port_reset = ohci_start_port_reset, | ||
120 | }; | ||
121 | |||
122 | static int ohci_xls_probe(struct platform_device *dev) | ||
123 | { | ||
124 | int ret; | ||
125 | |||
126 | pr_debug("In ohci_xls_probe"); | ||
127 | if (usb_disabled()) | ||
128 | return -ENODEV; | ||
129 | ret = ohci_xls_probe_internal(&ohci_xls_hc_driver, dev); | ||
130 | return ret; | ||
131 | } | ||
132 | |||
133 | static int ohci_xls_remove(struct platform_device *dev) | ||
134 | { | ||
135 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
136 | |||
137 | usb_remove_hcd(hcd); | ||
138 | iounmap(hcd->regs); | ||
139 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
140 | usb_put_hcd(hcd); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static struct platform_driver ohci_xls_driver = { | ||
145 | .probe = ohci_xls_probe, | ||
146 | .remove = ohci_xls_remove, | ||
147 | .shutdown = usb_hcd_platform_shutdown, | ||
148 | .driver = { | ||
149 | .name = "ohci-xls-0", | ||
150 | .owner = THIS_MODULE, | ||
151 | }, | ||
152 | }; | ||
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index fcc09e5ec0ad..b3eea0ba97a9 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -2036,10 +2036,8 @@ static void collect_usb_address_map(struct usb_device *udev, unsigned long *map) | |||
2036 | udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) | 2036 | udev->parent->descriptor.bDeviceClass == USB_CLASS_HUB) |
2037 | map[udev->devnum/32] |= (1 << (udev->devnum % 32)); | 2037 | map[udev->devnum/32] |= (1 << (udev->devnum % 32)); |
2038 | 2038 | ||
2039 | usb_hub_for_each_child(udev, chix, childdev) { | 2039 | usb_hub_for_each_child(udev, chix, childdev) |
2040 | if (childdev) | 2040 | collect_usb_address_map(childdev, map); |
2041 | collect_usb_address_map(childdev, map); | ||
2042 | } | ||
2043 | } | 2041 | } |
2044 | 2042 | ||
2045 | /* this function must be called with interrupt disabled */ | 2043 | /* this function must be called with interrupt disabled */ |
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c index d2c6f5ac4626..15921fd55048 100644 --- a/drivers/usb/host/uhci-q.c +++ b/drivers/usb/host/uhci-q.c | |||
@@ -1256,7 +1256,8 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1256 | struct uhci_qh *qh) | 1256 | struct uhci_qh *qh) |
1257 | { | 1257 | { |
1258 | struct uhci_td *td = NULL; /* Since urb->number_of_packets > 0 */ | 1258 | struct uhci_td *td = NULL; /* Since urb->number_of_packets > 0 */ |
1259 | int i, frame; | 1259 | int i; |
1260 | unsigned frame, next; | ||
1260 | unsigned long destination, status; | 1261 | unsigned long destination, status; |
1261 | struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; | 1262 | struct urb_priv *urbp = (struct urb_priv *) urb->hcpriv; |
1262 | 1263 | ||
@@ -1265,37 +1266,29 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1265 | urb->number_of_packets >= UHCI_NUMFRAMES) | 1266 | urb->number_of_packets >= UHCI_NUMFRAMES) |
1266 | return -EFBIG; | 1267 | return -EFBIG; |
1267 | 1268 | ||
1269 | uhci_get_current_frame_number(uhci); | ||
1270 | |||
1268 | /* Check the period and figure out the starting frame number */ | 1271 | /* Check the period and figure out the starting frame number */ |
1269 | if (!qh->bandwidth_reserved) { | 1272 | if (!qh->bandwidth_reserved) { |
1270 | qh->period = urb->interval; | 1273 | qh->period = urb->interval; |
1271 | if (urb->transfer_flags & URB_ISO_ASAP) { | 1274 | qh->phase = -1; /* Find the best phase */ |
1272 | qh->phase = -1; /* Find the best phase */ | 1275 | i = uhci_check_bandwidth(uhci, qh); |
1273 | i = uhci_check_bandwidth(uhci, qh); | 1276 | if (i) |
1274 | if (i) | 1277 | return i; |
1275 | return i; | 1278 | |
1276 | 1279 | /* Allow a little time to allocate the TDs */ | |
1277 | /* Allow a little time to allocate the TDs */ | 1280 | next = uhci->frame_number + 10; |
1278 | uhci_get_current_frame_number(uhci); | 1281 | frame = qh->phase; |
1279 | frame = uhci->frame_number + 10; | 1282 | |
1280 | 1283 | /* Round up to the first available slot */ | |
1281 | /* Move forward to the first frame having the | 1284 | frame += (next - frame + qh->period - 1) & -qh->period; |
1282 | * correct phase */ | ||
1283 | urb->start_frame = frame + ((qh->phase - frame) & | ||
1284 | (qh->period - 1)); | ||
1285 | } else { | ||
1286 | i = urb->start_frame - uhci->last_iso_frame; | ||
1287 | if (i <= 0 || i >= UHCI_NUMFRAMES) | ||
1288 | return -EINVAL; | ||
1289 | qh->phase = urb->start_frame & (qh->period - 1); | ||
1290 | i = uhci_check_bandwidth(uhci, qh); | ||
1291 | if (i) | ||
1292 | return i; | ||
1293 | } | ||
1294 | 1285 | ||
1295 | } else if (qh->period != urb->interval) { | 1286 | } else if (qh->period != urb->interval) { |
1296 | return -EINVAL; /* Can't change the period */ | 1287 | return -EINVAL; /* Can't change the period */ |
1297 | 1288 | ||
1298 | } else { | 1289 | } else { |
1290 | next = uhci->frame_number + 2; | ||
1291 | |||
1299 | /* Find the next unused frame */ | 1292 | /* Find the next unused frame */ |
1300 | if (list_empty(&qh->queue)) { | 1293 | if (list_empty(&qh->queue)) { |
1301 | frame = qh->iso_frame; | 1294 | frame = qh->iso_frame; |
@@ -1308,25 +1301,31 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb, | |||
1308 | lurb->number_of_packets * | 1301 | lurb->number_of_packets * |
1309 | lurb->interval; | 1302 | lurb->interval; |
1310 | } | 1303 | } |
1311 | if (urb->transfer_flags & URB_ISO_ASAP) { | 1304 | |
1312 | /* Skip some frames if necessary to insure | 1305 | /* Fell behind? */ |
1313 | * the start frame is in the future. | 1306 | if (uhci_frame_before_eq(frame, next)) { |
1307 | |||
1308 | /* USB_ISO_ASAP: Round up to the first available slot */ | ||
1309 | if (urb->transfer_flags & URB_ISO_ASAP) | ||
1310 | frame += (next - frame + qh->period - 1) & | ||
1311 | -qh->period; | ||
1312 | |||
1313 | /* | ||
1314 | * Not ASAP: Use the next slot in the stream. If | ||
1315 | * the entire URB falls before the threshold, fail. | ||
1314 | */ | 1316 | */ |
1315 | uhci_get_current_frame_number(uhci); | 1317 | else if (!uhci_frame_before_eq(next, |
1316 | if (uhci_frame_before_eq(frame, uhci->frame_number)) { | 1318 | frame + (urb->number_of_packets - 1) * |
1317 | frame = uhci->frame_number + 1; | 1319 | qh->period)) |
1318 | frame += ((qh->phase - frame) & | 1320 | return -EXDEV; |
1319 | (qh->period - 1)); | 1321 | } |
1320 | } | ||
1321 | } /* Otherwise pick up where the last URB leaves off */ | ||
1322 | urb->start_frame = frame; | ||
1323 | } | 1322 | } |
1324 | 1323 | ||
1325 | /* Make sure we won't have to go too far into the future */ | 1324 | /* Make sure we won't have to go too far into the future */ |
1326 | if (uhci_frame_before_eq(uhci->last_iso_frame + UHCI_NUMFRAMES, | 1325 | if (uhci_frame_before_eq(uhci->last_iso_frame + UHCI_NUMFRAMES, |
1327 | urb->start_frame + urb->number_of_packets * | 1326 | frame + urb->number_of_packets * urb->interval)) |
1328 | urb->interval)) | ||
1329 | return -EFBIG; | 1327 | return -EFBIG; |
1328 | urb->start_frame = frame; | ||
1330 | 1329 | ||
1331 | status = TD_CTRL_ACTIVE | TD_CTRL_IOS; | 1330 | status = TD_CTRL_ACTIVE | TD_CTRL_IOS; |
1332 | destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); | 1331 | destination = (urb->pipe & PIPE_DEVEP_MASK) | usb_packetid(urb->pipe); |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 487bc083dead..fb51c7085ad0 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -205,7 +205,12 @@ static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, | |||
205 | 205 | ||
206 | next = xhci_segment_alloc(xhci, cycle_state, flags); | 206 | next = xhci_segment_alloc(xhci, cycle_state, flags); |
207 | if (!next) { | 207 | if (!next) { |
208 | xhci_free_segments_for_ring(xhci, *first); | 208 | prev = *first; |
209 | while (prev) { | ||
210 | next = prev->next; | ||
211 | xhci_segment_free(xhci, prev); | ||
212 | prev = next; | ||
213 | } | ||
209 | return -ENOMEM; | 214 | return -ENOMEM; |
210 | } | 215 | } |
211 | xhci_link_segments(xhci, prev, next, type); | 216 | xhci_link_segments(xhci, prev, next, type); |
@@ -258,7 +263,7 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | |||
258 | return ring; | 263 | return ring; |
259 | 264 | ||
260 | fail: | 265 | fail: |
261 | xhci_ring_free(xhci, ring); | 266 | kfree(ring); |
262 | return NULL; | 267 | return NULL; |
263 | } | 268 | } |
264 | 269 | ||
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 8345d7c23061..af259e0ec172 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -29,6 +29,7 @@ | |||
29 | /* Device for a quirk */ | 29 | /* Device for a quirk */ |
30 | #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 | 30 | #define PCI_VENDOR_ID_FRESCO_LOGIC 0x1b73 |
31 | #define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 | 31 | #define PCI_DEVICE_ID_FRESCO_LOGIC_PDK 0x1000 |
32 | #define PCI_DEVICE_ID_FRESCO_LOGIC_FL1400 0x1400 | ||
32 | 33 | ||
33 | #define PCI_VENDOR_ID_ETRON 0x1b6f | 34 | #define PCI_VENDOR_ID_ETRON 0x1b6f |
34 | #define PCI_DEVICE_ID_ASROCK_P67 0x7023 | 35 | #define PCI_DEVICE_ID_ASROCK_P67 0x7023 |
@@ -58,8 +59,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
58 | 59 | ||
59 | /* Look for vendor-specific quirks */ | 60 | /* Look for vendor-specific quirks */ |
60 | if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && | 61 | if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC && |
61 | pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK) { | 62 | (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK || |
62 | if (pdev->revision == 0x0) { | 63 | pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) { |
64 | if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK && | ||
65 | pdev->revision == 0x0) { | ||
63 | xhci->quirks |= XHCI_RESET_EP_QUIRK; | 66 | xhci->quirks |= XHCI_RESET_EP_QUIRK; |
64 | xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" | 67 | xhci_dbg(xhci, "QUIRK: Fresco Logic xHC needs configure" |
65 | " endpoint cmd after reset endpoint\n"); | 68 | " endpoint cmd after reset endpoint\n"); |
@@ -218,15 +221,8 @@ static void xhci_pci_remove(struct pci_dev *dev) | |||
218 | static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) | 221 | static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup) |
219 | { | 222 | { |
220 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | 223 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); |
221 | int retval = 0; | ||
222 | 224 | ||
223 | if (hcd->state != HC_STATE_SUSPENDED || | 225 | return xhci_suspend(xhci); |
224 | xhci->shared_hcd->state != HC_STATE_SUSPENDED) | ||
225 | return -EINVAL; | ||
226 | |||
227 | retval = xhci_suspend(xhci); | ||
228 | |||
229 | return retval; | ||
230 | } | 226 | } |
231 | 227 | ||
232 | static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) | 228 | static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 4e1a8946b8d1..cbb44b7b9d65 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -318,7 +318,7 @@ static int xhci_abort_cmd_ring(struct xhci_hcd *xhci) | |||
318 | * seconds), then it should assume that the there are | 318 | * seconds), then it should assume that the there are |
319 | * larger problems with the xHC and assert HCRST. | 319 | * larger problems with the xHC and assert HCRST. |
320 | */ | 320 | */ |
321 | ret = handshake(xhci, &xhci->op_regs->cmd_ring, | 321 | ret = xhci_handshake(xhci, &xhci->op_regs->cmd_ring, |
322 | CMD_RING_RUNNING, 0, 5 * 1000 * 1000); | 322 | CMD_RING_RUNNING, 0, 5 * 1000 * 1000); |
323 | if (ret < 0) { | 323 | if (ret < 0) { |
324 | xhci_err(xhci, "Stopped the command ring failed, " | 324 | xhci_err(xhci, "Stopped the command ring failed, " |
@@ -3071,11 +3071,11 @@ static u32 xhci_td_remainder(unsigned int remainder) | |||
3071 | } | 3071 | } |
3072 | 3072 | ||
3073 | /* | 3073 | /* |
3074 | * For xHCI 1.0 host controllers, TD size is the number of packets remaining in | 3074 | * For xHCI 1.0 host controllers, TD size is the number of max packet sized |
3075 | * the TD (*not* including this TRB). | 3075 | * packets remaining in the TD (*not* including this TRB). |
3076 | * | 3076 | * |
3077 | * Total TD packet count = total_packet_count = | 3077 | * Total TD packet count = total_packet_count = |
3078 | * roundup(TD size in bytes / wMaxPacketSize) | 3078 | * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) |
3079 | * | 3079 | * |
3080 | * Packets transferred up to and including this TRB = packets_transferred = | 3080 | * Packets transferred up to and including this TRB = packets_transferred = |
3081 | * rounddown(total bytes transferred including this TRB / wMaxPacketSize) | 3081 | * rounddown(total bytes transferred including this TRB / wMaxPacketSize) |
@@ -3083,15 +3083,16 @@ static u32 xhci_td_remainder(unsigned int remainder) | |||
3083 | * TD size = total_packet_count - packets_transferred | 3083 | * TD size = total_packet_count - packets_transferred |
3084 | * | 3084 | * |
3085 | * It must fit in bits 21:17, so it can't be bigger than 31. | 3085 | * It must fit in bits 21:17, so it can't be bigger than 31. |
3086 | * The last TRB in a TD must have the TD size set to zero. | ||
3086 | */ | 3087 | */ |
3087 | |||
3088 | static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, | 3088 | static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, |
3089 | unsigned int total_packet_count, struct urb *urb) | 3089 | unsigned int total_packet_count, struct urb *urb, |
3090 | unsigned int num_trbs_left) | ||
3090 | { | 3091 | { |
3091 | int packets_transferred; | 3092 | int packets_transferred; |
3092 | 3093 | ||
3093 | /* One TRB with a zero-length data packet. */ | 3094 | /* One TRB with a zero-length data packet. */ |
3094 | if (running_total == 0 && trb_buff_len == 0) | 3095 | if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0)) |
3095 | return 0; | 3096 | return 0; |
3096 | 3097 | ||
3097 | /* All the TRB queueing functions don't count the current TRB in | 3098 | /* All the TRB queueing functions don't count the current TRB in |
@@ -3100,7 +3101,9 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, | |||
3100 | packets_transferred = (running_total + trb_buff_len) / | 3101 | packets_transferred = (running_total + trb_buff_len) / |
3101 | usb_endpoint_maxp(&urb->ep->desc); | 3102 | usb_endpoint_maxp(&urb->ep->desc); |
3102 | 3103 | ||
3103 | return xhci_td_remainder(total_packet_count - packets_transferred); | 3104 | if ((total_packet_count - packets_transferred) > 31) |
3105 | return 31 << 17; | ||
3106 | return (total_packet_count - packets_transferred) << 17; | ||
3104 | } | 3107 | } |
3105 | 3108 | ||
3106 | static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | 3109 | static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, |
@@ -3127,7 +3130,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3127 | 3130 | ||
3128 | num_trbs = count_sg_trbs_needed(xhci, urb); | 3131 | num_trbs = count_sg_trbs_needed(xhci, urb); |
3129 | num_sgs = urb->num_mapped_sgs; | 3132 | num_sgs = urb->num_mapped_sgs; |
3130 | total_packet_count = roundup(urb->transfer_buffer_length, | 3133 | total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, |
3131 | usb_endpoint_maxp(&urb->ep->desc)); | 3134 | usb_endpoint_maxp(&urb->ep->desc)); |
3132 | 3135 | ||
3133 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], | 3136 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], |
@@ -3210,7 +3213,8 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3210 | running_total); | 3213 | running_total); |
3211 | } else { | 3214 | } else { |
3212 | remainder = xhci_v1_0_td_remainder(running_total, | 3215 | remainder = xhci_v1_0_td_remainder(running_total, |
3213 | trb_buff_len, total_packet_count, urb); | 3216 | trb_buff_len, total_packet_count, urb, |
3217 | num_trbs - 1); | ||
3214 | } | 3218 | } |
3215 | length_field = TRB_LEN(trb_buff_len) | | 3219 | length_field = TRB_LEN(trb_buff_len) | |
3216 | remainder | | 3220 | remainder | |
@@ -3318,7 +3322,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3318 | start_cycle = ep_ring->cycle_state; | 3322 | start_cycle = ep_ring->cycle_state; |
3319 | 3323 | ||
3320 | running_total = 0; | 3324 | running_total = 0; |
3321 | total_packet_count = roundup(urb->transfer_buffer_length, | 3325 | total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, |
3322 | usb_endpoint_maxp(&urb->ep->desc)); | 3326 | usb_endpoint_maxp(&urb->ep->desc)); |
3323 | /* How much data is in the first TRB? */ | 3327 | /* How much data is in the first TRB? */ |
3324 | addr = (u64) urb->transfer_dma; | 3328 | addr = (u64) urb->transfer_dma; |
@@ -3364,7 +3368,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3364 | running_total); | 3368 | running_total); |
3365 | } else { | 3369 | } else { |
3366 | remainder = xhci_v1_0_td_remainder(running_total, | 3370 | remainder = xhci_v1_0_td_remainder(running_total, |
3367 | trb_buff_len, total_packet_count, urb); | 3371 | trb_buff_len, total_packet_count, urb, |
3372 | num_trbs - 1); | ||
3368 | } | 3373 | } |
3369 | length_field = TRB_LEN(trb_buff_len) | | 3374 | length_field = TRB_LEN(trb_buff_len) | |
3370 | remainder | | 3375 | remainder | |
@@ -3627,7 +3632,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3627 | addr = start_addr + urb->iso_frame_desc[i].offset; | 3632 | addr = start_addr + urb->iso_frame_desc[i].offset; |
3628 | td_len = urb->iso_frame_desc[i].length; | 3633 | td_len = urb->iso_frame_desc[i].length; |
3629 | td_remain_len = td_len; | 3634 | td_remain_len = td_len; |
3630 | total_packet_count = roundup(td_len, | 3635 | total_packet_count = DIV_ROUND_UP(td_len, |
3631 | usb_endpoint_maxp(&urb->ep->desc)); | 3636 | usb_endpoint_maxp(&urb->ep->desc)); |
3632 | /* A zero-length transfer still involves at least one packet. */ | 3637 | /* A zero-length transfer still involves at least one packet. */ |
3633 | if (total_packet_count == 0) | 3638 | if (total_packet_count == 0) |
@@ -3706,7 +3711,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3706 | } else { | 3711 | } else { |
3707 | remainder = xhci_v1_0_td_remainder( | 3712 | remainder = xhci_v1_0_td_remainder( |
3708 | running_total, trb_buff_len, | 3713 | running_total, trb_buff_len, |
3709 | total_packet_count, urb); | 3714 | total_packet_count, urb, |
3715 | (trbs_per_td - j - 1)); | ||
3710 | } | 3716 | } |
3711 | length_field = TRB_LEN(trb_buff_len) | | 3717 | length_field = TRB_LEN(trb_buff_len) | |
3712 | remainder | | 3718 | remainder | |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c9e419f29b74..5c72c431bab1 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB"); | |||
40 | 40 | ||
41 | /* TODO: copied from ehci-hcd.c - can this be refactored? */ | 41 | /* TODO: copied from ehci-hcd.c - can this be refactored? */ |
42 | /* | 42 | /* |
43 | * handshake - spin reading hc until handshake completes or fails | 43 | * xhci_handshake - spin reading hc until handshake completes or fails |
44 | * @ptr: address of hc register to be read | 44 | * @ptr: address of hc register to be read |
45 | * @mask: bits to look at in result of read | 45 | * @mask: bits to look at in result of read |
46 | * @done: value of those bits when handshake succeeds | 46 | * @done: value of those bits when handshake succeeds |
@@ -52,7 +52,7 @@ MODULE_PARM_DESC(link_quirk, "Don't clear the chain bit on a link TRB"); | |||
52 | * handshake done). There are two failure modes: "usec" have passed (major | 52 | * handshake done). There are two failure modes: "usec" have passed (major |
53 | * hardware flakeout), or the register reads as all-ones (hardware removed). | 53 | * hardware flakeout), or the register reads as all-ones (hardware removed). |
54 | */ | 54 | */ |
55 | int handshake(struct xhci_hcd *xhci, void __iomem *ptr, | 55 | int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, |
56 | u32 mask, u32 done, int usec) | 56 | u32 mask, u32 done, int usec) |
57 | { | 57 | { |
58 | u32 result; | 58 | u32 result; |
@@ -103,7 +103,7 @@ int xhci_halt(struct xhci_hcd *xhci) | |||
103 | xhci_dbg(xhci, "// Halt the HC\n"); | 103 | xhci_dbg(xhci, "// Halt the HC\n"); |
104 | xhci_quiesce(xhci); | 104 | xhci_quiesce(xhci); |
105 | 105 | ||
106 | ret = handshake(xhci, &xhci->op_regs->status, | 106 | ret = xhci_handshake(xhci, &xhci->op_regs->status, |
107 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); | 107 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC); |
108 | if (!ret) { | 108 | if (!ret) { |
109 | xhci->xhc_state |= XHCI_STATE_HALTED; | 109 | xhci->xhc_state |= XHCI_STATE_HALTED; |
@@ -132,7 +132,7 @@ static int xhci_start(struct xhci_hcd *xhci) | |||
132 | * Wait for the HCHalted Status bit to be 0 to indicate the host is | 132 | * Wait for the HCHalted Status bit to be 0 to indicate the host is |
133 | * running. | 133 | * running. |
134 | */ | 134 | */ |
135 | ret = handshake(xhci, &xhci->op_regs->status, | 135 | ret = xhci_handshake(xhci, &xhci->op_regs->status, |
136 | STS_HALT, 0, XHCI_MAX_HALT_USEC); | 136 | STS_HALT, 0, XHCI_MAX_HALT_USEC); |
137 | if (ret == -ETIMEDOUT) | 137 | if (ret == -ETIMEDOUT) |
138 | xhci_err(xhci, "Host took too long to start, " | 138 | xhci_err(xhci, "Host took too long to start, " |
@@ -167,7 +167,7 @@ int xhci_reset(struct xhci_hcd *xhci) | |||
167 | command |= CMD_RESET; | 167 | command |= CMD_RESET; |
168 | xhci_writel(xhci, command, &xhci->op_regs->command); | 168 | xhci_writel(xhci, command, &xhci->op_regs->command); |
169 | 169 | ||
170 | ret = handshake(xhci, &xhci->op_regs->command, | 170 | ret = xhci_handshake(xhci, &xhci->op_regs->command, |
171 | CMD_RESET, 0, 10 * 1000 * 1000); | 171 | CMD_RESET, 0, 10 * 1000 * 1000); |
172 | if (ret) | 172 | if (ret) |
173 | return ret; | 173 | return ret; |
@@ -177,7 +177,7 @@ int xhci_reset(struct xhci_hcd *xhci) | |||
177 | * xHCI cannot write to any doorbells or operational registers other | 177 | * xHCI cannot write to any doorbells or operational registers other |
178 | * than status until the "Controller Not Ready" flag is cleared. | 178 | * than status until the "Controller Not Ready" flag is cleared. |
179 | */ | 179 | */ |
180 | ret = handshake(xhci, &xhci->op_regs->status, | 180 | ret = xhci_handshake(xhci, &xhci->op_regs->status, |
181 | STS_CNR, 0, 10 * 1000 * 1000); | 181 | STS_CNR, 0, 10 * 1000 * 1000); |
182 | 182 | ||
183 | for (i = 0; i < 2; ++i) { | 183 | for (i = 0; i < 2; ++i) { |
@@ -480,7 +480,7 @@ static bool compliance_mode_recovery_timer_quirk_check(void) | |||
480 | if (strstr(dmi_product_name, "Z420") || | 480 | if (strstr(dmi_product_name, "Z420") || |
481 | strstr(dmi_product_name, "Z620") || | 481 | strstr(dmi_product_name, "Z620") || |
482 | strstr(dmi_product_name, "Z820") || | 482 | strstr(dmi_product_name, "Z820") || |
483 | strstr(dmi_product_name, "Z1")) | 483 | strstr(dmi_product_name, "Z1 Workstation")) |
484 | return true; | 484 | return true; |
485 | 485 | ||
486 | return false; | 486 | return false; |
@@ -880,6 +880,10 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
880 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 880 | struct usb_hcd *hcd = xhci_to_hcd(xhci); |
881 | u32 command; | 881 | u32 command; |
882 | 882 | ||
883 | if (hcd->state != HC_STATE_SUSPENDED || | ||
884 | xhci->shared_hcd->state != HC_STATE_SUSPENDED) | ||
885 | return -EINVAL; | ||
886 | |||
883 | spin_lock_irq(&xhci->lock); | 887 | spin_lock_irq(&xhci->lock); |
884 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 888 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
885 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); | 889 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); |
@@ -890,7 +894,7 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
890 | command = xhci_readl(xhci, &xhci->op_regs->command); | 894 | command = xhci_readl(xhci, &xhci->op_regs->command); |
891 | command &= ~CMD_RUN; | 895 | command &= ~CMD_RUN; |
892 | xhci_writel(xhci, command, &xhci->op_regs->command); | 896 | xhci_writel(xhci, command, &xhci->op_regs->command); |
893 | if (handshake(xhci, &xhci->op_regs->status, | 897 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
894 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { | 898 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { |
895 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); | 899 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); |
896 | spin_unlock_irq(&xhci->lock); | 900 | spin_unlock_irq(&xhci->lock); |
@@ -905,7 +909,8 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
905 | command = xhci_readl(xhci, &xhci->op_regs->command); | 909 | command = xhci_readl(xhci, &xhci->op_regs->command); |
906 | command |= CMD_CSS; | 910 | command |= CMD_CSS; |
907 | xhci_writel(xhci, command, &xhci->op_regs->command); | 911 | xhci_writel(xhci, command, &xhci->op_regs->command); |
908 | if (handshake(xhci, &xhci->op_regs->status, STS_SAVE, 0, 10 * 1000)) { | 912 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
913 | STS_SAVE, 0, 10 * 1000)) { | ||
909 | xhci_warn(xhci, "WARN: xHC save state timeout\n"); | 914 | xhci_warn(xhci, "WARN: xHC save state timeout\n"); |
910 | spin_unlock_irq(&xhci->lock); | 915 | spin_unlock_irq(&xhci->lock); |
911 | return -ETIMEDOUT; | 916 | return -ETIMEDOUT; |
@@ -967,7 +972,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
967 | command = xhci_readl(xhci, &xhci->op_regs->command); | 972 | command = xhci_readl(xhci, &xhci->op_regs->command); |
968 | command |= CMD_CRS; | 973 | command |= CMD_CRS; |
969 | xhci_writel(xhci, command, &xhci->op_regs->command); | 974 | xhci_writel(xhci, command, &xhci->op_regs->command); |
970 | if (handshake(xhci, &xhci->op_regs->status, | 975 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
971 | STS_RESTORE, 0, 10 * 1000)) { | 976 | STS_RESTORE, 0, 10 * 1000)) { |
972 | xhci_warn(xhci, "WARN: xHC restore state timeout\n"); | 977 | xhci_warn(xhci, "WARN: xHC restore state timeout\n"); |
973 | spin_unlock_irq(&xhci->lock); | 978 | spin_unlock_irq(&xhci->lock); |
@@ -1035,7 +1040,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
1035 | command = xhci_readl(xhci, &xhci->op_regs->command); | 1040 | command = xhci_readl(xhci, &xhci->op_regs->command); |
1036 | command |= CMD_RUN; | 1041 | command |= CMD_RUN; |
1037 | xhci_writel(xhci, command, &xhci->op_regs->command); | 1042 | xhci_writel(xhci, command, &xhci->op_regs->command); |
1038 | handshake(xhci, &xhci->op_regs->status, STS_HALT, | 1043 | xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT, |
1039 | 0, 250 * 1000); | 1044 | 0, 250 * 1000); |
1040 | 1045 | ||
1041 | /* step 5: walk topology and initialize portsc, | 1046 | /* step 5: walk topology and initialize portsc, |
@@ -2254,7 +2259,7 @@ static bool xhci_is_async_ep(unsigned int ep_type) | |||
2254 | 2259 | ||
2255 | static bool xhci_is_sync_in_ep(unsigned int ep_type) | 2260 | static bool xhci_is_sync_in_ep(unsigned int ep_type) |
2256 | { | 2261 | { |
2257 | return (ep_type == ISOC_IN_EP || ep_type != INT_IN_EP); | 2262 | return (ep_type == ISOC_IN_EP || ep_type == INT_IN_EP); |
2258 | } | 2263 | } |
2259 | 2264 | ||
2260 | static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw) | 2265 | static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw) |
@@ -3874,7 +3879,8 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | |||
3874 | spin_lock_irqsave(&xhci->lock, flags); | 3879 | spin_lock_irqsave(&xhci->lock, flags); |
3875 | 3880 | ||
3876 | /* Check L1 Status */ | 3881 | /* Check L1 Status */ |
3877 | ret = handshake(xhci, pm_addr, PORT_L1S_MASK, PORT_L1S_SUCCESS, 125); | 3882 | ret = xhci_handshake(xhci, pm_addr, |
3883 | PORT_L1S_MASK, PORT_L1S_SUCCESS, 125); | ||
3878 | if (ret != -ETIMEDOUT) { | 3884 | if (ret != -ETIMEDOUT) { |
3879 | /* enter L1 successfully */ | 3885 | /* enter L1 successfully */ |
3880 | temp = xhci_readl(xhci, addr); | 3886 | temp = xhci_readl(xhci, addr); |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 53df4e70ca07..f791bd0aee6c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1720,7 +1720,7 @@ static inline void xhci_unregister_plat(void) | |||
1720 | 1720 | ||
1721 | /* xHCI host controller glue */ | 1721 | /* xHCI host controller glue */ |
1722 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); | 1722 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); |
1723 | int handshake(struct xhci_hcd *xhci, void __iomem *ptr, | 1723 | int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr, |
1724 | u32 mask, u32 done, int usec); | 1724 | u32 mask, u32 done, int usec); |
1725 | void xhci_quiesce(struct xhci_hcd *xhci); | 1725 | void xhci_quiesce(struct xhci_hcd *xhci); |
1726 | int xhci_halt(struct xhci_hcd *xhci); | 1726 | int xhci_halt(struct xhci_hcd *xhci); |
diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c index 6589268a6515..e712afed947c 100644 --- a/drivers/usb/misc/ezusb.c +++ b/drivers/usb/misc/ezusb.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
16 | #include <linux/firmware.h> | 16 | #include <linux/firmware.h> |
17 | #include <linux/ihex.h> | 17 | #include <linux/ihex.h> |
18 | #include <linux/usb/ezusb.h> | ||
18 | 19 | ||
19 | struct ezusb_fx_type { | 20 | struct ezusb_fx_type { |
20 | /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ | 21 | /* EZ-USB Control and Status Register. Bit 0 controls 8051 reset */ |
@@ -22,21 +23,16 @@ struct ezusb_fx_type { | |||
22 | unsigned short max_internal_adress; | 23 | unsigned short max_internal_adress; |
23 | }; | 24 | }; |
24 | 25 | ||
25 | struct ezusb_fx_type ezusb_fx1 = { | 26 | static struct ezusb_fx_type ezusb_fx1 = { |
26 | .cpucs_reg = 0x7F92, | 27 | .cpucs_reg = 0x7F92, |
27 | .max_internal_adress = 0x1B3F, | 28 | .max_internal_adress = 0x1B3F, |
28 | }; | 29 | }; |
29 | 30 | ||
30 | struct ezusb_fx_type ezusb_fx2 = { | ||
31 | .cpucs_reg = 0xE600, | ||
32 | .max_internal_adress = 0x3FFF, | ||
33 | }; | ||
34 | |||
35 | /* Commands for writing to memory */ | 31 | /* Commands for writing to memory */ |
36 | #define WRITE_INT_RAM 0xA0 | 32 | #define WRITE_INT_RAM 0xA0 |
37 | #define WRITE_EXT_RAM 0xA3 | 33 | #define WRITE_EXT_RAM 0xA3 |
38 | 34 | ||
39 | int ezusb_writememory(struct usb_device *dev, int address, | 35 | static int ezusb_writememory(struct usb_device *dev, int address, |
40 | unsigned char *data, int length, __u8 request) | 36 | unsigned char *data, int length, __u8 request) |
41 | { | 37 | { |
42 | int result; | 38 | int result; |
@@ -58,10 +54,9 @@ int ezusb_writememory(struct usb_device *dev, int address, | |||
58 | kfree(transfer_buffer); | 54 | kfree(transfer_buffer); |
59 | return result; | 55 | return result; |
60 | } | 56 | } |
61 | EXPORT_SYMBOL_GPL(ezusb_writememory); | ||
62 | 57 | ||
63 | int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg, | 58 | static int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg, |
64 | unsigned char reset_bit) | 59 | unsigned char reset_bit) |
65 | { | 60 | { |
66 | int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM); | 61 | int response = ezusb_writememory(dev, cpucs_reg, &reset_bit, 1, WRITE_INT_RAM); |
67 | if (response < 0) | 62 | if (response < 0) |
@@ -76,12 +71,6 @@ int ezusb_fx1_set_reset(struct usb_device *dev, unsigned char reset_bit) | |||
76 | } | 71 | } |
77 | EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset); | 72 | EXPORT_SYMBOL_GPL(ezusb_fx1_set_reset); |
78 | 73 | ||
79 | int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit) | ||
80 | { | ||
81 | return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit); | ||
82 | } | ||
83 | EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset); | ||
84 | |||
85 | static int ezusb_ihex_firmware_download(struct usb_device *dev, | 74 | static int ezusb_ihex_firmware_download(struct usb_device *dev, |
86 | struct ezusb_fx_type fx, | 75 | struct ezusb_fx_type fx, |
87 | const char *firmware_path) | 76 | const char *firmware_path) |
@@ -151,11 +140,28 @@ int ezusb_fx1_ihex_firmware_download(struct usb_device *dev, | |||
151 | } | 140 | } |
152 | EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download); | 141 | EXPORT_SYMBOL_GPL(ezusb_fx1_ihex_firmware_download); |
153 | 142 | ||
143 | #if 0 | ||
144 | /* | ||
145 | * Once someone one needs these fx2 functions, uncomment them | ||
146 | * and add them to ezusb.h and all should be good. | ||
147 | */ | ||
148 | static struct ezusb_fx_type ezusb_fx2 = { | ||
149 | .cpucs_reg = 0xE600, | ||
150 | .max_internal_adress = 0x3FFF, | ||
151 | }; | ||
152 | |||
153 | int ezusb_fx2_set_reset(struct usb_device *dev, unsigned char reset_bit) | ||
154 | { | ||
155 | return ezusb_set_reset(dev, ezusb_fx2.cpucs_reg, reset_bit); | ||
156 | } | ||
157 | EXPORT_SYMBOL_GPL(ezusb_fx2_set_reset); | ||
158 | |||
154 | int ezusb_fx2_ihex_firmware_download(struct usb_device *dev, | 159 | int ezusb_fx2_ihex_firmware_download(struct usb_device *dev, |
155 | const char *firmware_path) | 160 | const char *firmware_path) |
156 | { | 161 | { |
157 | return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path); | 162 | return ezusb_ihex_firmware_download(dev, ezusb_fx2, firmware_path); |
158 | } | 163 | } |
159 | EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download); | 164 | EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download); |
165 | #endif | ||
160 | 166 | ||
161 | MODULE_LICENSE("GPL"); | 167 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 055b84adedac..f10bd970d50a 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -2386,6 +2386,7 @@ static struct usbtest_info gz_info = { | |||
2386 | .name = "Linux gadget zero", | 2386 | .name = "Linux gadget zero", |
2387 | .autoconf = 1, | 2387 | .autoconf = 1, |
2388 | .ctrl_out = 1, | 2388 | .ctrl_out = 1, |
2389 | .iso = 1, | ||
2389 | .alt = 0, | 2390 | .alt = 0, |
2390 | }; | 2391 | }; |
2391 | 2392 | ||
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index c964d6af178b..3baccf765418 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -465,7 +465,6 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
465 | struct clk *clk; | 465 | struct clk *clk; |
466 | 466 | ||
467 | int ret = -ENOMEM; | 467 | int ret = -ENOMEM; |
468 | int musbid; | ||
469 | 468 | ||
470 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 469 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
471 | if (!glue) { | 470 | if (!glue) { |
@@ -473,18 +472,10 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
473 | goto err0; | 472 | goto err0; |
474 | } | 473 | } |
475 | 474 | ||
476 | /* get the musb id */ | 475 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
477 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
478 | if (musbid < 0) { | ||
479 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
480 | ret = -ENOMEM; | ||
481 | goto err1; | ||
482 | } | ||
483 | |||
484 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
485 | if (!musb) { | 476 | if (!musb) { |
486 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 477 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
487 | goto err2; | 478 | goto err1; |
488 | } | 479 | } |
489 | 480 | ||
490 | phy_clk = clk_get(&pdev->dev, "fck"); | 481 | phy_clk = clk_get(&pdev->dev, "fck"); |
@@ -513,7 +504,6 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
513 | goto err6; | 504 | goto err6; |
514 | } | 505 | } |
515 | 506 | ||
516 | musb->id = musbid; | ||
517 | musb->dev.parent = &pdev->dev; | 507 | musb->dev.parent = &pdev->dev; |
518 | musb->dev.dma_mask = &am35x_dmamask; | 508 | musb->dev.dma_mask = &am35x_dmamask; |
519 | musb->dev.coherent_dma_mask = am35x_dmamask; | 509 | musb->dev.coherent_dma_mask = am35x_dmamask; |
@@ -563,9 +553,6 @@ err4: | |||
563 | err3: | 553 | err3: |
564 | platform_device_put(musb); | 554 | platform_device_put(musb); |
565 | 555 | ||
566 | err2: | ||
567 | musb_put_id(&pdev->dev, musbid); | ||
568 | |||
569 | err1: | 556 | err1: |
570 | kfree(glue); | 557 | kfree(glue); |
571 | 558 | ||
@@ -577,9 +564,7 @@ static int __devexit am35x_remove(struct platform_device *pdev) | |||
577 | { | 564 | { |
578 | struct am35x_glue *glue = platform_get_drvdata(pdev); | 565 | struct am35x_glue *glue = platform_get_drvdata(pdev); |
579 | 566 | ||
580 | musb_put_id(&pdev->dev, glue->musb->id); | 567 | platform_device_unregister(glue->musb); |
581 | platform_device_del(glue->musb); | ||
582 | platform_device_put(glue->musb); | ||
583 | clk_disable(glue->clk); | 568 | clk_disable(glue->clk); |
584 | clk_disable(glue->phy_clk); | 569 | clk_disable(glue->phy_clk); |
585 | clk_put(glue->clk); | 570 | clk_put(glue->clk); |
@@ -654,15 +639,4 @@ static struct platform_driver am35x_driver = { | |||
654 | MODULE_DESCRIPTION("AM35x MUSB Glue Layer"); | 639 | MODULE_DESCRIPTION("AM35x MUSB Glue Layer"); |
655 | MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); | 640 | MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); |
656 | MODULE_LICENSE("GPL v2"); | 641 | MODULE_LICENSE("GPL v2"); |
657 | 642 | module_platform_driver(am35x_driver); | |
658 | static int __init am35x_init(void) | ||
659 | { | ||
660 | return platform_driver_register(&am35x_driver); | ||
661 | } | ||
662 | module_init(am35x_init); | ||
663 | |||
664 | static void __exit am35x_exit(void) | ||
665 | { | ||
666 | platform_driver_unregister(&am35x_driver); | ||
667 | } | ||
668 | module_exit(am35x_exit); | ||
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index e8cff9bb9d23..7e4d60a41728 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -455,7 +455,6 @@ static int __devinit bfin_probe(struct platform_device *pdev) | |||
455 | struct bfin_glue *glue; | 455 | struct bfin_glue *glue; |
456 | 456 | ||
457 | int ret = -ENOMEM; | 457 | int ret = -ENOMEM; |
458 | int musbid; | ||
459 | 458 | ||
460 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 459 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
461 | if (!glue) { | 460 | if (!glue) { |
@@ -463,21 +462,12 @@ static int __devinit bfin_probe(struct platform_device *pdev) | |||
463 | goto err0; | 462 | goto err0; |
464 | } | 463 | } |
465 | 464 | ||
466 | /* get the musb id */ | 465 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
467 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
468 | if (musbid < 0) { | ||
469 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
470 | ret = -ENOMEM; | ||
471 | goto err1; | ||
472 | } | ||
473 | |||
474 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
475 | if (!musb) { | 466 | if (!musb) { |
476 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 467 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
477 | goto err2; | 468 | goto err1; |
478 | } | 469 | } |
479 | 470 | ||
480 | musb->id = musbid; | ||
481 | musb->dev.parent = &pdev->dev; | 471 | musb->dev.parent = &pdev->dev; |
482 | musb->dev.dma_mask = &bfin_dmamask; | 472 | musb->dev.dma_mask = &bfin_dmamask; |
483 | musb->dev.coherent_dma_mask = bfin_dmamask; | 473 | musb->dev.coherent_dma_mask = bfin_dmamask; |
@@ -513,9 +503,6 @@ static int __devinit bfin_probe(struct platform_device *pdev) | |||
513 | err3: | 503 | err3: |
514 | platform_device_put(musb); | 504 | platform_device_put(musb); |
515 | 505 | ||
516 | err2: | ||
517 | musb_put_id(&pdev->dev, musbid); | ||
518 | |||
519 | err1: | 506 | err1: |
520 | kfree(glue); | 507 | kfree(glue); |
521 | 508 | ||
@@ -527,9 +514,7 @@ static int __devexit bfin_remove(struct platform_device *pdev) | |||
527 | { | 514 | { |
528 | struct bfin_glue *glue = platform_get_drvdata(pdev); | 515 | struct bfin_glue *glue = platform_get_drvdata(pdev); |
529 | 516 | ||
530 | musb_put_id(&pdev->dev, glue->musb->id); | 517 | platform_device_unregister(glue->musb); |
531 | platform_device_del(glue->musb); | ||
532 | platform_device_put(glue->musb); | ||
533 | kfree(glue); | 518 | kfree(glue); |
534 | 519 | ||
535 | return 0; | 520 | return 0; |
@@ -585,15 +570,4 @@ static struct platform_driver bfin_driver = { | |||
585 | MODULE_DESCRIPTION("Blackfin MUSB Glue Layer"); | 570 | MODULE_DESCRIPTION("Blackfin MUSB Glue Layer"); |
586 | MODULE_AUTHOR("Bryan Wy <cooloney@kernel.org>"); | 571 | MODULE_AUTHOR("Bryan Wy <cooloney@kernel.org>"); |
587 | MODULE_LICENSE("GPL v2"); | 572 | MODULE_LICENSE("GPL v2"); |
588 | 573 | module_platform_driver(bfin_driver); | |
589 | static int __init bfin_init(void) | ||
590 | { | ||
591 | return platform_driver_register(&bfin_driver); | ||
592 | } | ||
593 | module_init(bfin_init); | ||
594 | |||
595 | static void __exit bfin_exit(void) | ||
596 | { | ||
597 | platform_driver_unregister(&bfin_driver); | ||
598 | } | ||
599 | module_exit(bfin_exit); | ||
diff --git a/drivers/usb/musb/cppi_dma.c b/drivers/usb/musb/cppi_dma.c index e19da82b4782..3a6c2fd1f913 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c | |||
@@ -1314,6 +1314,7 @@ irqreturn_t cppi_interrupt(int irq, void *dev_id) | |||
1314 | 1314 | ||
1315 | return IRQ_HANDLED; | 1315 | return IRQ_HANDLED; |
1316 | } | 1316 | } |
1317 | EXPORT_SYMBOL_GPL(cppi_interrupt); | ||
1317 | 1318 | ||
1318 | /* Instantiate a software object representing a DMA controller. */ | 1319 | /* Instantiate a software object representing a DMA controller. */ |
1319 | struct dma_controller *__devinit | 1320 | struct dma_controller *__devinit |
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 8bc44b76eec2..67b8ae704e9a 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -480,7 +480,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev) | |||
480 | struct clk *clk; | 480 | struct clk *clk; |
481 | 481 | ||
482 | int ret = -ENOMEM; | 482 | int ret = -ENOMEM; |
483 | int musbid; | ||
484 | 483 | ||
485 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 484 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
486 | if (!glue) { | 485 | if (!glue) { |
@@ -488,18 +487,10 @@ static int __devinit da8xx_probe(struct platform_device *pdev) | |||
488 | goto err0; | 487 | goto err0; |
489 | } | 488 | } |
490 | 489 | ||
491 | /* get the musb id */ | 490 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
492 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
493 | if (musbid < 0) { | ||
494 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
495 | ret = -ENOMEM; | ||
496 | goto err1; | ||
497 | } | ||
498 | |||
499 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
500 | if (!musb) { | 491 | if (!musb) { |
501 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 492 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
502 | goto err2; | 493 | goto err1; |
503 | } | 494 | } |
504 | 495 | ||
505 | clk = clk_get(&pdev->dev, "usb20"); | 496 | clk = clk_get(&pdev->dev, "usb20"); |
@@ -515,7 +506,6 @@ static int __devinit da8xx_probe(struct platform_device *pdev) | |||
515 | goto err4; | 506 | goto err4; |
516 | } | 507 | } |
517 | 508 | ||
518 | musb->id = musbid; | ||
519 | musb->dev.parent = &pdev->dev; | 509 | musb->dev.parent = &pdev->dev; |
520 | musb->dev.dma_mask = &da8xx_dmamask; | 510 | musb->dev.dma_mask = &da8xx_dmamask; |
521 | musb->dev.coherent_dma_mask = da8xx_dmamask; | 511 | musb->dev.coherent_dma_mask = da8xx_dmamask; |
@@ -558,9 +548,6 @@ err4: | |||
558 | err3: | 548 | err3: |
559 | platform_device_put(musb); | 549 | platform_device_put(musb); |
560 | 550 | ||
561 | err2: | ||
562 | musb_put_id(&pdev->dev, musbid); | ||
563 | |||
564 | err1: | 551 | err1: |
565 | kfree(glue); | 552 | kfree(glue); |
566 | 553 | ||
@@ -572,9 +559,7 @@ static int __devexit da8xx_remove(struct platform_device *pdev) | |||
572 | { | 559 | { |
573 | struct da8xx_glue *glue = platform_get_drvdata(pdev); | 560 | struct da8xx_glue *glue = platform_get_drvdata(pdev); |
574 | 561 | ||
575 | musb_put_id(&pdev->dev, glue->musb->id); | 562 | platform_device_unregister(glue->musb); |
576 | platform_device_del(glue->musb); | ||
577 | platform_device_put(glue->musb); | ||
578 | clk_disable(glue->clk); | 563 | clk_disable(glue->clk); |
579 | clk_put(glue->clk); | 564 | clk_put(glue->clk); |
580 | kfree(glue); | 565 | kfree(glue); |
@@ -593,15 +578,4 @@ static struct platform_driver da8xx_driver = { | |||
593 | MODULE_DESCRIPTION("DA8xx/OMAP-L1x MUSB Glue Layer"); | 578 | MODULE_DESCRIPTION("DA8xx/OMAP-L1x MUSB Glue Layer"); |
594 | MODULE_AUTHOR("Sergei Shtylyov <sshtylyov@ru.mvista.com>"); | 579 | MODULE_AUTHOR("Sergei Shtylyov <sshtylyov@ru.mvista.com>"); |
595 | MODULE_LICENSE("GPL v2"); | 580 | MODULE_LICENSE("GPL v2"); |
596 | 581 | module_platform_driver(da8xx_driver); | |
597 | static int __init da8xx_init(void) | ||
598 | { | ||
599 | return platform_driver_register(&da8xx_driver); | ||
600 | } | ||
601 | module_init(da8xx_init); | ||
602 | |||
603 | static void __exit da8xx_exit(void) | ||
604 | { | ||
605 | platform_driver_unregister(&da8xx_driver); | ||
606 | } | ||
607 | module_exit(da8xx_exit); | ||
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 606bfd00cde6..b3c0a943950c 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -512,7 +512,6 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
512 | struct clk *clk; | 512 | struct clk *clk; |
513 | 513 | ||
514 | int ret = -ENOMEM; | 514 | int ret = -ENOMEM; |
515 | int musbid; | ||
516 | 515 | ||
517 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 516 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
518 | if (!glue) { | 517 | if (!glue) { |
@@ -520,18 +519,10 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
520 | goto err0; | 519 | goto err0; |
521 | } | 520 | } |
522 | 521 | ||
523 | /* get the musb id */ | 522 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
524 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
525 | if (musbid < 0) { | ||
526 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
527 | ret = -ENOMEM; | ||
528 | goto err1; | ||
529 | } | ||
530 | |||
531 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
532 | if (!musb) { | 523 | if (!musb) { |
533 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 524 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
534 | goto err2; | 525 | goto err1; |
535 | } | 526 | } |
536 | 527 | ||
537 | clk = clk_get(&pdev->dev, "usb"); | 528 | clk = clk_get(&pdev->dev, "usb"); |
@@ -547,7 +538,6 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
547 | goto err4; | 538 | goto err4; |
548 | } | 539 | } |
549 | 540 | ||
550 | musb->id = musbid; | ||
551 | musb->dev.parent = &pdev->dev; | 541 | musb->dev.parent = &pdev->dev; |
552 | musb->dev.dma_mask = &davinci_dmamask; | 542 | musb->dev.dma_mask = &davinci_dmamask; |
553 | musb->dev.coherent_dma_mask = davinci_dmamask; | 543 | musb->dev.coherent_dma_mask = davinci_dmamask; |
@@ -590,9 +580,6 @@ err4: | |||
590 | err3: | 580 | err3: |
591 | platform_device_put(musb); | 581 | platform_device_put(musb); |
592 | 582 | ||
593 | err2: | ||
594 | musb_put_id(&pdev->dev, musbid); | ||
595 | |||
596 | err1: | 583 | err1: |
597 | kfree(glue); | 584 | kfree(glue); |
598 | 585 | ||
@@ -604,9 +591,7 @@ static int __devexit davinci_remove(struct platform_device *pdev) | |||
604 | { | 591 | { |
605 | struct davinci_glue *glue = platform_get_drvdata(pdev); | 592 | struct davinci_glue *glue = platform_get_drvdata(pdev); |
606 | 593 | ||
607 | musb_put_id(&pdev->dev, glue->musb->id); | 594 | platform_device_unregister(glue->musb); |
608 | platform_device_del(glue->musb); | ||
609 | platform_device_put(glue->musb); | ||
610 | clk_disable(glue->clk); | 595 | clk_disable(glue->clk); |
611 | clk_put(glue->clk); | 596 | clk_put(glue->clk); |
612 | kfree(glue); | 597 | kfree(glue); |
@@ -625,15 +610,4 @@ static struct platform_driver davinci_driver = { | |||
625 | MODULE_DESCRIPTION("DaVinci MUSB Glue Layer"); | 610 | MODULE_DESCRIPTION("DaVinci MUSB Glue Layer"); |
626 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 611 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
627 | MODULE_LICENSE("GPL v2"); | 612 | MODULE_LICENSE("GPL v2"); |
628 | 613 | module_platform_driver(davinci_driver); | |
629 | static int __init davinci_init(void) | ||
630 | { | ||
631 | return platform_driver_register(&davinci_driver); | ||
632 | } | ||
633 | module_init(davinci_init); | ||
634 | |||
635 | static void __exit davinci_exit(void) | ||
636 | { | ||
637 | platform_driver_unregister(&davinci_driver); | ||
638 | } | ||
639 | module_exit(davinci_exit); | ||
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index bb56a0e8b23b..774d8154a286 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -116,7 +116,6 @@ | |||
116 | 116 | ||
117 | #define MUSB_DRIVER_NAME "musb-hdrc" | 117 | #define MUSB_DRIVER_NAME "musb-hdrc" |
118 | const char musb_driver_name[] = MUSB_DRIVER_NAME; | 118 | const char musb_driver_name[] = MUSB_DRIVER_NAME; |
119 | static DEFINE_IDA(musb_ida); | ||
120 | 119 | ||
121 | MODULE_DESCRIPTION(DRIVER_INFO); | 120 | MODULE_DESCRIPTION(DRIVER_INFO); |
122 | MODULE_AUTHOR(DRIVER_AUTHOR); | 121 | MODULE_AUTHOR(DRIVER_AUTHOR); |
@@ -133,35 +132,6 @@ static inline struct musb *dev_to_musb(struct device *dev) | |||
133 | 132 | ||
134 | /*-------------------------------------------------------------------------*/ | 133 | /*-------------------------------------------------------------------------*/ |
135 | 134 | ||
136 | int musb_get_id(struct device *dev, gfp_t gfp_mask) | ||
137 | { | ||
138 | int ret; | ||
139 | int id; | ||
140 | |||
141 | ret = ida_pre_get(&musb_ida, gfp_mask); | ||
142 | if (!ret) { | ||
143 | dev_err(dev, "failed to reserve resource for id\n"); | ||
144 | return -ENOMEM; | ||
145 | } | ||
146 | |||
147 | ret = ida_get_new(&musb_ida, &id); | ||
148 | if (ret < 0) { | ||
149 | dev_err(dev, "failed to allocate a new id\n"); | ||
150 | return ret; | ||
151 | } | ||
152 | |||
153 | return id; | ||
154 | } | ||
155 | EXPORT_SYMBOL_GPL(musb_get_id); | ||
156 | |||
157 | void musb_put_id(struct device *dev, int id) | ||
158 | { | ||
159 | |||
160 | dev_dbg(dev, "removing id %d\n", id); | ||
161 | ida_remove(&musb_ida, id); | ||
162 | } | ||
163 | EXPORT_SYMBOL_GPL(musb_put_id); | ||
164 | |||
165 | #ifndef CONFIG_BLACKFIN | 135 | #ifndef CONFIG_BLACKFIN |
166 | static int musb_ulpi_read(struct usb_phy *phy, u32 offset) | 136 | static int musb_ulpi_read(struct usb_phy *phy, u32 offset) |
167 | { | 137 | { |
@@ -467,12 +437,12 @@ void musb_hnp_stop(struct musb *musb) | |||
467 | */ | 437 | */ |
468 | 438 | ||
469 | static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | 439 | static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, |
470 | u8 devctl, u8 power) | 440 | u8 devctl) |
471 | { | 441 | { |
472 | struct usb_otg *otg = musb->xceiv->otg; | 442 | struct usb_otg *otg = musb->xceiv->otg; |
473 | irqreturn_t handled = IRQ_NONE; | 443 | irqreturn_t handled = IRQ_NONE; |
474 | 444 | ||
475 | dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl, | 445 | dev_dbg(musb->controller, "<== DevCtl=%02x, int_usb=0x%x\n", devctl, |
476 | int_usb); | 446 | int_usb); |
477 | 447 | ||
478 | /* in host mode, the peripheral may issue remote wakeup. | 448 | /* in host mode, the peripheral may issue remote wakeup. |
@@ -485,6 +455,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
485 | 455 | ||
486 | if (devctl & MUSB_DEVCTL_HM) { | 456 | if (devctl & MUSB_DEVCTL_HM) { |
487 | void __iomem *mbase = musb->mregs; | 457 | void __iomem *mbase = musb->mregs; |
458 | u8 power; | ||
488 | 459 | ||
489 | switch (musb->xceiv->state) { | 460 | switch (musb->xceiv->state) { |
490 | case OTG_STATE_A_SUSPEND: | 461 | case OTG_STATE_A_SUSPEND: |
@@ -492,6 +463,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
492 | * will stop RESUME signaling | 463 | * will stop RESUME signaling |
493 | */ | 464 | */ |
494 | 465 | ||
466 | power = musb_readb(musb->mregs, MUSB_POWER); | ||
495 | if (power & MUSB_POWER_SUSPENDM) { | 467 | if (power & MUSB_POWER_SUSPENDM) { |
496 | /* spurious */ | 468 | /* spurious */ |
497 | musb->int_usb &= ~MUSB_INTR_SUSPEND; | 469 | musb->int_usb &= ~MUSB_INTR_SUSPEND; |
@@ -655,8 +627,8 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
655 | } | 627 | } |
656 | 628 | ||
657 | if (int_usb & MUSB_INTR_SUSPEND) { | 629 | if (int_usb & MUSB_INTR_SUSPEND) { |
658 | dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x power %02x\n", | 630 | dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x\n", |
659 | otg_state_string(musb->xceiv->state), devctl, power); | 631 | otg_state_string(musb->xceiv->state), devctl); |
660 | handled = IRQ_HANDLED; | 632 | handled = IRQ_HANDLED; |
661 | 633 | ||
662 | switch (musb->xceiv->state) { | 634 | switch (musb->xceiv->state) { |
@@ -722,8 +694,10 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
722 | if (is_peripheral_active(musb)) { | 694 | if (is_peripheral_active(musb)) { |
723 | /* REVISIT HNP; just force disconnect */ | 695 | /* REVISIT HNP; just force disconnect */ |
724 | } | 696 | } |
725 | musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask); | 697 | musb->intrtxe = musb->epmask; |
726 | musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe); | 698 | musb_writew(musb->mregs, MUSB_INTRTXE, musb->intrtxe); |
699 | musb->intrrxe = musb->epmask & 0xfffe; | ||
700 | musb_writew(musb->mregs, MUSB_INTRRXE, musb->intrrxe); | ||
727 | musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); | 701 | musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); |
728 | musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED | 702 | musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED |
729 | |USB_PORT_STAT_HIGH_SPEED | 703 | |USB_PORT_STAT_HIGH_SPEED |
@@ -944,8 +918,10 @@ void musb_start(struct musb *musb) | |||
944 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); | 918 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); |
945 | 919 | ||
946 | /* Set INT enable registers, enable interrupts */ | 920 | /* Set INT enable registers, enable interrupts */ |
947 | musb_writew(regs, MUSB_INTRTXE, musb->epmask); | 921 | musb->intrtxe = musb->epmask; |
948 | musb_writew(regs, MUSB_INTRRXE, musb->epmask & 0xfffe); | 922 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); |
923 | musb->intrrxe = musb->epmask & 0xfffe; | ||
924 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
949 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | 925 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); |
950 | 926 | ||
951 | musb_writeb(regs, MUSB_TESTMODE, 0); | 927 | musb_writeb(regs, MUSB_TESTMODE, 0); |
@@ -983,7 +959,9 @@ static void musb_generic_disable(struct musb *musb) | |||
983 | 959 | ||
984 | /* disable interrupts */ | 960 | /* disable interrupts */ |
985 | musb_writeb(mbase, MUSB_INTRUSBE, 0); | 961 | musb_writeb(mbase, MUSB_INTRUSBE, 0); |
962 | musb->intrtxe = 0; | ||
986 | musb_writew(mbase, MUSB_INTRTXE, 0); | 963 | musb_writew(mbase, MUSB_INTRTXE, 0); |
964 | musb->intrrxe = 0; | ||
987 | musb_writew(mbase, MUSB_INTRRXE, 0); | 965 | musb_writew(mbase, MUSB_INTRRXE, 0); |
988 | 966 | ||
989 | /* off */ | 967 | /* off */ |
@@ -1523,33 +1501,6 @@ static int __devinit musb_core_init(u16 musb_type, struct musb *musb) | |||
1523 | 1501 | ||
1524 | /*-------------------------------------------------------------------------*/ | 1502 | /*-------------------------------------------------------------------------*/ |
1525 | 1503 | ||
1526 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) || \ | ||
1527 | defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_ARCH_U8500) | ||
1528 | |||
1529 | static irqreturn_t generic_interrupt(int irq, void *__hci) | ||
1530 | { | ||
1531 | unsigned long flags; | ||
1532 | irqreturn_t retval = IRQ_NONE; | ||
1533 | struct musb *musb = __hci; | ||
1534 | |||
1535 | spin_lock_irqsave(&musb->lock, flags); | ||
1536 | |||
1537 | musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); | ||
1538 | musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); | ||
1539 | musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); | ||
1540 | |||
1541 | if (musb->int_usb || musb->int_tx || musb->int_rx) | ||
1542 | retval = musb_interrupt(musb); | ||
1543 | |||
1544 | spin_unlock_irqrestore(&musb->lock, flags); | ||
1545 | |||
1546 | return retval; | ||
1547 | } | ||
1548 | |||
1549 | #else | ||
1550 | #define generic_interrupt NULL | ||
1551 | #endif | ||
1552 | |||
1553 | /* | 1504 | /* |
1554 | * handle all the irqs defined by the HDRC core. for now we expect: other | 1505 | * handle all the irqs defined by the HDRC core. for now we expect: other |
1555 | * irq sources (phy, dma, etc) will be handled first, musb->int_* values | 1506 | * irq sources (phy, dma, etc) will be handled first, musb->int_* values |
@@ -1560,12 +1511,11 @@ static irqreturn_t generic_interrupt(int irq, void *__hci) | |||
1560 | irqreturn_t musb_interrupt(struct musb *musb) | 1511 | irqreturn_t musb_interrupt(struct musb *musb) |
1561 | { | 1512 | { |
1562 | irqreturn_t retval = IRQ_NONE; | 1513 | irqreturn_t retval = IRQ_NONE; |
1563 | u8 devctl, power; | 1514 | u8 devctl; |
1564 | int ep_num; | 1515 | int ep_num; |
1565 | u32 reg; | 1516 | u32 reg; |
1566 | 1517 | ||
1567 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 1518 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
1568 | power = musb_readb(musb->mregs, MUSB_POWER); | ||
1569 | 1519 | ||
1570 | dev_dbg(musb->controller, "** IRQ %s usb%04x tx%04x rx%04x\n", | 1520 | dev_dbg(musb->controller, "** IRQ %s usb%04x tx%04x rx%04x\n", |
1571 | (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", | 1521 | (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", |
@@ -1576,7 +1526,7 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
1576 | */ | 1526 | */ |
1577 | if (musb->int_usb) | 1527 | if (musb->int_usb) |
1578 | retval |= musb_stage0_irq(musb, musb->int_usb, | 1528 | retval |= musb_stage0_irq(musb, musb->int_usb, |
1579 | devctl, power); | 1529 | devctl); |
1580 | 1530 | ||
1581 | /* "stage 1" is handling endpoint irqs */ | 1531 | /* "stage 1" is handling endpoint irqs */ |
1582 | 1532 | ||
@@ -1919,7 +1869,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1919 | musb->ops = plat->platform_ops; | 1869 | musb->ops = plat->platform_ops; |
1920 | 1870 | ||
1921 | /* The musb_platform_init() call: | 1871 | /* The musb_platform_init() call: |
1922 | * - adjusts musb->mregs and musb->isr if needed, | 1872 | * - adjusts musb->mregs |
1873 | * - sets the musb->isr | ||
1923 | * - may initialize an integrated tranceiver | 1874 | * - may initialize an integrated tranceiver |
1924 | * - initializes musb->xceiv, usually by otg_get_phy() | 1875 | * - initializes musb->xceiv, usually by otg_get_phy() |
1925 | * - stops powering VBUS | 1876 | * - stops powering VBUS |
@@ -1929,7 +1880,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1929 | * external/discrete ones in various flavors (twl4030 family, | 1880 | * external/discrete ones in various flavors (twl4030 family, |
1930 | * isp1504, non-OTG, etc) mostly hooking up through ULPI. | 1881 | * isp1504, non-OTG, etc) mostly hooking up through ULPI. |
1931 | */ | 1882 | */ |
1932 | musb->isr = generic_interrupt; | ||
1933 | status = musb_platform_init(musb); | 1883 | status = musb_platform_init(musb); |
1934 | if (status < 0) | 1884 | if (status < 0) |
1935 | goto fail1; | 1885 | goto fail1; |
@@ -2120,8 +2070,6 @@ static void musb_save_context(struct musb *musb) | |||
2120 | musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); | 2070 | musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); |
2121 | musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); | 2071 | musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); |
2122 | musb->context.power = musb_readb(musb_base, MUSB_POWER); | 2072 | musb->context.power = musb_readb(musb_base, MUSB_POWER); |
2123 | musb->context.intrtxe = musb_readw(musb_base, MUSB_INTRTXE); | ||
2124 | musb->context.intrrxe = musb_readw(musb_base, MUSB_INTRRXE); | ||
2125 | musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); | 2073 | musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); |
2126 | musb->context.index = musb_readb(musb_base, MUSB_INDEX); | 2074 | musb->context.index = musb_readb(musb_base, MUSB_INDEX); |
2127 | musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); | 2075 | musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); |
@@ -2194,8 +2142,8 @@ static void musb_restore_context(struct musb *musb) | |||
2194 | musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); | 2142 | musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); |
2195 | musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); | 2143 | musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); |
2196 | musb_writeb(musb_base, MUSB_POWER, musb->context.power); | 2144 | musb_writeb(musb_base, MUSB_POWER, musb->context.power); |
2197 | musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe); | 2145 | musb_writew(musb_base, MUSB_INTRTXE, musb->intrtxe); |
2198 | musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe); | 2146 | musb_writew(musb_base, MUSB_INTRRXE, musb->intrrxe); |
2199 | musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); | 2147 | musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); |
2200 | musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); | 2148 | musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); |
2201 | 2149 | ||
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index c158aacd6de8..7fb4819a6f11 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -288,7 +288,6 @@ struct musb_csr_regs { | |||
288 | struct musb_context_registers { | 288 | struct musb_context_registers { |
289 | 289 | ||
290 | u8 power; | 290 | u8 power; |
291 | u16 intrtxe, intrrxe; | ||
292 | u8 intrusbe; | 291 | u8 intrusbe; |
293 | u16 frame; | 292 | u16 frame; |
294 | u8 index, testmode; | 293 | u8 index, testmode; |
@@ -313,6 +312,8 @@ struct musb { | |||
313 | struct work_struct irq_work; | 312 | struct work_struct irq_work; |
314 | u16 hwvers; | 313 | u16 hwvers; |
315 | 314 | ||
315 | u16 intrrxe; | ||
316 | u16 intrtxe; | ||
316 | /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ | 317 | /* this hub status bit is reserved by USB 2.0 and not seen by usbcore */ |
317 | #define MUSB_PORT_STAT_RESUME (1 << 31) | 318 | #define MUSB_PORT_STAT_RESUME (1 << 31) |
318 | 319 | ||
@@ -521,8 +522,6 @@ extern const char musb_driver_name[]; | |||
521 | 522 | ||
522 | extern void musb_start(struct musb *musb); | 523 | extern void musb_start(struct musb *musb); |
523 | extern void musb_stop(struct musb *musb); | 524 | extern void musb_stop(struct musb *musb); |
524 | extern int musb_get_id(struct device *dev, gfp_t gfp_mask); | ||
525 | extern void musb_put_id(struct device *dev, int id); | ||
526 | 525 | ||
527 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); | 526 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); |
528 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); | 527 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); |
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index ff5f112053d2..b108473e4d5f 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
@@ -124,8 +124,44 @@ struct dsps_glue { | |||
124 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ | 124 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ |
125 | struct timer_list timer[2]; /* otg_workaround timer */ | 125 | struct timer_list timer[2]; /* otg_workaround timer */ |
126 | unsigned long last_timer[2]; /* last timer data for each instance */ | 126 | unsigned long last_timer[2]; /* last timer data for each instance */ |
127 | u32 __iomem *usb_ctrl[2]; | ||
127 | }; | 128 | }; |
128 | 129 | ||
130 | #define DSPS_AM33XX_CONTROL_MODULE_PHYS_0 0x44e10620 | ||
131 | #define DSPS_AM33XX_CONTROL_MODULE_PHYS_1 0x44e10628 | ||
132 | |||
133 | static const resource_size_t dsps_control_module_phys[] = { | ||
134 | DSPS_AM33XX_CONTROL_MODULE_PHYS_0, | ||
135 | DSPS_AM33XX_CONTROL_MODULE_PHYS_1, | ||
136 | }; | ||
137 | |||
138 | /** | ||
139 | * musb_dsps_phy_control - phy on/off | ||
140 | * @glue: struct dsps_glue * | ||
141 | * @id: musb instance | ||
142 | * @on: flag for phy to be switched on or off | ||
143 | * | ||
144 | * This is to enable the PHY using usb_ctrl register in system control | ||
145 | * module space. | ||
146 | * | ||
147 | * XXX: This function will be removed once we have a seperate driver for | ||
148 | * control module | ||
149 | */ | ||
150 | static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on) | ||
151 | { | ||
152 | u32 usbphycfg; | ||
153 | |||
154 | usbphycfg = readl(glue->usb_ctrl[id]); | ||
155 | |||
156 | if (on) { | ||
157 | usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN); | ||
158 | usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN; | ||
159 | } else { | ||
160 | usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN; | ||
161 | } | ||
162 | |||
163 | writel(usbphycfg, glue->usb_ctrl[id]); | ||
164 | } | ||
129 | /** | 165 | /** |
130 | * dsps_musb_enable - enable interrupts | 166 | * dsps_musb_enable - enable interrupts |
131 | */ | 167 | */ |
@@ -296,7 +332,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
296 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... | 332 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... |
297 | */ | 333 | */ |
298 | if (usbintr & MUSB_INTR_BABBLE) | 334 | if (usbintr & MUSB_INTR_BABBLE) |
299 | pr_info("CAUTION: musb: Babble Interrupt Occured\n"); | 335 | pr_info("CAUTION: musb: Babble Interrupt Occurred\n"); |
300 | 336 | ||
301 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { | 337 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { |
302 | int drvvbus = dsps_readl(reg_base, wrp->status); | 338 | int drvvbus = dsps_readl(reg_base, wrp->status); |
@@ -365,11 +401,9 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
365 | static int dsps_musb_init(struct musb *musb) | 401 | static int dsps_musb_init(struct musb *musb) |
366 | { | 402 | { |
367 | struct device *dev = musb->controller; | 403 | struct device *dev = musb->controller; |
368 | struct musb_hdrc_platform_data *plat = dev->platform_data; | ||
369 | struct platform_device *pdev = to_platform_device(dev); | 404 | struct platform_device *pdev = to_platform_device(dev); |
370 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 405 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
371 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 406 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
372 | struct omap_musb_board_data *data = plat->board_data; | ||
373 | void __iomem *reg_base = musb->ctrl_base; | 407 | void __iomem *reg_base = musb->ctrl_base; |
374 | u32 rev, val; | 408 | u32 rev, val; |
375 | int status; | 409 | int status; |
@@ -377,7 +411,8 @@ static int dsps_musb_init(struct musb *musb) | |||
377 | /* mentor core register starts at offset of 0x400 from musb base */ | 411 | /* mentor core register starts at offset of 0x400 from musb base */ |
378 | musb->mregs += wrp->musb_core_offset; | 412 | musb->mregs += wrp->musb_core_offset; |
379 | 413 | ||
380 | /* Get the NOP PHY */ | 414 | /* NOP driver needs change if supporting dual instance */ |
415 | usb_nop_xceiv_register(); | ||
381 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); | 416 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); |
382 | if (IS_ERR_OR_NULL(musb->xceiv)) | 417 | if (IS_ERR_OR_NULL(musb->xceiv)) |
383 | return -ENODEV; | 418 | return -ENODEV; |
@@ -395,8 +430,7 @@ static int dsps_musb_init(struct musb *musb) | |||
395 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); | 430 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); |
396 | 431 | ||
397 | /* Start the on-chip PHY and its PLL. */ | 432 | /* Start the on-chip PHY and its PLL. */ |
398 | if (data->set_phy_power) | 433 | musb_dsps_phy_control(glue, pdev->id, 1); |
399 | data->set_phy_power(1); | ||
400 | 434 | ||
401 | musb->isr = dsps_interrupt; | 435 | musb->isr = dsps_interrupt; |
402 | 436 | ||
@@ -418,16 +452,13 @@ err0: | |||
418 | static int dsps_musb_exit(struct musb *musb) | 452 | static int dsps_musb_exit(struct musb *musb) |
419 | { | 453 | { |
420 | struct device *dev = musb->controller; | 454 | struct device *dev = musb->controller; |
421 | struct musb_hdrc_platform_data *plat = dev->platform_data; | ||
422 | struct omap_musb_board_data *data = plat->board_data; | ||
423 | struct platform_device *pdev = to_platform_device(dev); | 455 | struct platform_device *pdev = to_platform_device(dev); |
424 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 456 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
425 | 457 | ||
426 | del_timer_sync(&glue->timer[pdev->id]); | 458 | del_timer_sync(&glue->timer[pdev->id]); |
427 | 459 | ||
428 | /* Shutdown the on-chip PHY and its PLL. */ | 460 | /* Shutdown the on-chip PHY and its PLL. */ |
429 | if (data->set_phy_power) | 461 | musb_dsps_phy_control(glue, pdev->id, 0); |
430 | data->set_phy_power(0); | ||
431 | 462 | ||
432 | /* NOP driver needs change if supporting dual instance */ | 463 | /* NOP driver needs change if supporting dual instance */ |
433 | usb_put_phy(musb->xceiv); | 464 | usb_put_phy(musb->xceiv); |
@@ -459,24 +490,33 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
459 | struct resource *res; | 490 | struct resource *res; |
460 | struct resource resources[2]; | 491 | struct resource resources[2]; |
461 | char res_name[11]; | 492 | char res_name[11]; |
462 | int ret, musbid; | 493 | int ret; |
463 | 494 | ||
464 | /* get memory resource */ | 495 | resources[0].start = dsps_control_module_phys[id]; |
465 | snprintf(res_name, sizeof(res_name), "musb%d", id); | 496 | resources[0].end = resources[0].start + SZ_4 - 1; |
466 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name); | 497 | resources[0].flags = IORESOURCE_MEM; |
498 | |||
499 | glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, resources); | ||
500 | if (glue->usb_ctrl[id] == NULL) { | ||
501 | dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id); | ||
502 | ret = -ENODEV; | ||
503 | goto err0; | ||
504 | } | ||
505 | |||
506 | /* first resource is for usbss, so start index from 1 */ | ||
507 | res = platform_get_resource(pdev, IORESOURCE_MEM, id + 1); | ||
467 | if (!res) { | 508 | if (!res) { |
468 | dev_err(dev, "%s get mem resource failed\n", res_name); | 509 | dev_err(dev, "failed to get memory for instance %d\n", id); |
469 | ret = -ENODEV; | 510 | ret = -ENODEV; |
470 | goto err0; | 511 | goto err0; |
471 | } | 512 | } |
472 | res->parent = NULL; | 513 | res->parent = NULL; |
473 | resources[0] = *res; | 514 | resources[0] = *res; |
474 | 515 | ||
475 | /* get irq resource */ | 516 | /* first resource is for usbss, so start index from 1 */ |
476 | snprintf(res_name, sizeof(res_name), "musb%d-irq", id); | 517 | res = platform_get_resource(pdev, IORESOURCE_IRQ, id + 1); |
477 | res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res_name); | ||
478 | if (!res) { | 518 | if (!res) { |
479 | dev_err(dev, "%s get irq resource failed\n", res_name); | 519 | dev_err(dev, "failed to get irq for instance %d\n", id); |
480 | ret = -ENODEV; | 520 | ret = -ENODEV; |
481 | goto err0; | 521 | goto err0; |
482 | } | 522 | } |
@@ -484,22 +524,14 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
484 | resources[1] = *res; | 524 | resources[1] = *res; |
485 | resources[1].name = "mc"; | 525 | resources[1].name = "mc"; |
486 | 526 | ||
487 | /* get the musb id */ | ||
488 | musbid = musb_get_id(dev, GFP_KERNEL); | ||
489 | if (musbid < 0) { | ||
490 | dev_err(dev, "failed to allocate musb id\n"); | ||
491 | ret = -ENOMEM; | ||
492 | goto err0; | ||
493 | } | ||
494 | /* allocate the child platform device */ | 527 | /* allocate the child platform device */ |
495 | musb = platform_device_alloc("musb-hdrc", musbid); | 528 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
496 | if (!musb) { | 529 | if (!musb) { |
497 | dev_err(dev, "failed to allocate musb device\n"); | 530 | dev_err(dev, "failed to allocate musb device\n"); |
498 | ret = -ENOMEM; | 531 | ret = -ENOMEM; |
499 | goto err1; | 532 | goto err0; |
500 | } | 533 | } |
501 | 534 | ||
502 | musb->id = musbid; | ||
503 | musb->dev.parent = dev; | 535 | musb->dev.parent = dev; |
504 | musb->dev.dma_mask = &musb_dmamask; | 536 | musb->dev.dma_mask = &musb_dmamask; |
505 | musb->dev.coherent_dma_mask = musb_dmamask; | 537 | musb->dev.coherent_dma_mask = musb_dmamask; |
@@ -556,19 +588,10 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
556 | 588 | ||
557 | err2: | 589 | err2: |
558 | platform_device_put(musb); | 590 | platform_device_put(musb); |
559 | err1: | ||
560 | musb_put_id(dev, musbid); | ||
561 | err0: | 591 | err0: |
562 | return ret; | 592 | return ret; |
563 | } | 593 | } |
564 | 594 | ||
565 | static void dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id) | ||
566 | { | ||
567 | musb_put_id(glue->dev, glue->musb[id]->id); | ||
568 | platform_device_del(glue->musb[id]); | ||
569 | platform_device_put(glue->musb[id]); | ||
570 | } | ||
571 | |||
572 | static int __devinit dsps_probe(struct platform_device *pdev) | 595 | static int __devinit dsps_probe(struct platform_device *pdev) |
573 | { | 596 | { |
574 | struct device_node *np = pdev->dev.of_node; | 597 | struct device_node *np = pdev->dev.of_node; |
@@ -628,7 +651,7 @@ static int __devinit dsps_probe(struct platform_device *pdev) | |||
628 | dev_err(&pdev->dev, "failed to create child pdev\n"); | 651 | dev_err(&pdev->dev, "failed to create child pdev\n"); |
629 | /* release resources of previously created instances */ | 652 | /* release resources of previously created instances */ |
630 | for (i--; i >= 0 ; i--) | 653 | for (i--; i >= 0 ; i--) |
631 | dsps_delete_musb_pdev(glue, i); | 654 | platform_device_unregister(glue->musb[i]); |
632 | goto err3; | 655 | goto err3; |
633 | } | 656 | } |
634 | } | 657 | } |
@@ -653,7 +676,7 @@ static int __devexit dsps_remove(struct platform_device *pdev) | |||
653 | 676 | ||
654 | /* delete the child platform device */ | 677 | /* delete the child platform device */ |
655 | for (i = 0; i < wrp->instances ; i++) | 678 | for (i = 0; i < wrp->instances ; i++) |
656 | dsps_delete_musb_pdev(glue, i); | 679 | platform_device_unregister(glue->musb[i]); |
657 | 680 | ||
658 | /* disable usbss clocks */ | 681 | /* disable usbss clocks */ |
659 | pm_runtime_put(&pdev->dev); | 682 | pm_runtime_put(&pdev->dev); |
@@ -666,24 +689,26 @@ static int __devexit dsps_remove(struct platform_device *pdev) | |||
666 | #ifdef CONFIG_PM_SLEEP | 689 | #ifdef CONFIG_PM_SLEEP |
667 | static int dsps_suspend(struct device *dev) | 690 | static int dsps_suspend(struct device *dev) |
668 | { | 691 | { |
669 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 692 | struct platform_device *pdev = to_platform_device(dev->parent); |
670 | struct omap_musb_board_data *data = plat->board_data; | 693 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
694 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
695 | int i; | ||
671 | 696 | ||
672 | /* Shutdown the on-chip PHY and its PLL. */ | 697 | for (i = 0; i < wrp->instances; i++) |
673 | if (data->set_phy_power) | 698 | musb_dsps_phy_control(glue, i, 0); |
674 | data->set_phy_power(0); | ||
675 | 699 | ||
676 | return 0; | 700 | return 0; |
677 | } | 701 | } |
678 | 702 | ||
679 | static int dsps_resume(struct device *dev) | 703 | static int dsps_resume(struct device *dev) |
680 | { | 704 | { |
681 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 705 | struct platform_device *pdev = to_platform_device(dev->parent); |
682 | struct omap_musb_board_data *data = plat->board_data; | 706 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
707 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
708 | int i; | ||
683 | 709 | ||
684 | /* Start the on-chip PHY and its PLL. */ | 710 | for (i = 0; i < wrp->instances; i++) |
685 | if (data->set_phy_power) | 711 | musb_dsps_phy_control(glue, i, 1); |
686 | data->set_phy_power(1); | ||
687 | 712 | ||
688 | return 0; | 713 | return 0; |
689 | } | 714 | } |
@@ -719,7 +744,7 @@ static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = { | |||
719 | .rxep_bitmap = (0xfffe << 16), | 744 | .rxep_bitmap = (0xfffe << 16), |
720 | .musb_core_offset = 0x400, | 745 | .musb_core_offset = 0x400, |
721 | .poll_seconds = 2, | 746 | .poll_seconds = 2, |
722 | .instances = 2, | 747 | .instances = 1, |
723 | }; | 748 | }; |
724 | 749 | ||
725 | static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { | 750 | static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b6b84dacc791..4f23b12a3ae7 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -1090,7 +1090,6 @@ static int musb_gadget_enable(struct usb_ep *ep, | |||
1090 | */ | 1090 | */ |
1091 | musb_ep_select(mbase, epnum); | 1091 | musb_ep_select(mbase, epnum); |
1092 | if (usb_endpoint_dir_in(desc)) { | 1092 | if (usb_endpoint_dir_in(desc)) { |
1093 | u16 int_txe = musb_readw(mbase, MUSB_INTRTXE); | ||
1094 | 1093 | ||
1095 | if (hw_ep->is_shared_fifo) | 1094 | if (hw_ep->is_shared_fifo) |
1096 | musb_ep->is_in = 1; | 1095 | musb_ep->is_in = 1; |
@@ -1102,8 +1101,8 @@ static int musb_gadget_enable(struct usb_ep *ep, | |||
1102 | goto fail; | 1101 | goto fail; |
1103 | } | 1102 | } |
1104 | 1103 | ||
1105 | int_txe |= (1 << epnum); | 1104 | musb->intrtxe |= (1 << epnum); |
1106 | musb_writew(mbase, MUSB_INTRTXE, int_txe); | 1105 | musb_writew(mbase, MUSB_INTRTXE, musb->intrtxe); |
1107 | 1106 | ||
1108 | /* REVISIT if can_bulk_split(), use by updating "tmp"; | 1107 | /* REVISIT if can_bulk_split(), use by updating "tmp"; |
1109 | * likewise high bandwidth periodic tx | 1108 | * likewise high bandwidth periodic tx |
@@ -1130,7 +1129,6 @@ static int musb_gadget_enable(struct usb_ep *ep, | |||
1130 | musb_writew(regs, MUSB_TXCSR, csr); | 1129 | musb_writew(regs, MUSB_TXCSR, csr); |
1131 | 1130 | ||
1132 | } else { | 1131 | } else { |
1133 | u16 int_rxe = musb_readw(mbase, MUSB_INTRRXE); | ||
1134 | 1132 | ||
1135 | if (hw_ep->is_shared_fifo) | 1133 | if (hw_ep->is_shared_fifo) |
1136 | musb_ep->is_in = 0; | 1134 | musb_ep->is_in = 0; |
@@ -1142,8 +1140,8 @@ static int musb_gadget_enable(struct usb_ep *ep, | |||
1142 | goto fail; | 1140 | goto fail; |
1143 | } | 1141 | } |
1144 | 1142 | ||
1145 | int_rxe |= (1 << epnum); | 1143 | musb->intrrxe |= (1 << epnum); |
1146 | musb_writew(mbase, MUSB_INTRRXE, int_rxe); | 1144 | musb_writew(mbase, MUSB_INTRRXE, musb->intrrxe); |
1147 | 1145 | ||
1148 | /* REVISIT if can_bulk_combine() use by updating "tmp" | 1146 | /* REVISIT if can_bulk_combine() use by updating "tmp" |
1149 | * likewise high bandwidth periodic rx | 1147 | * likewise high bandwidth periodic rx |
@@ -1231,14 +1229,12 @@ static int musb_gadget_disable(struct usb_ep *ep) | |||
1231 | 1229 | ||
1232 | /* zero the endpoint sizes */ | 1230 | /* zero the endpoint sizes */ |
1233 | if (musb_ep->is_in) { | 1231 | if (musb_ep->is_in) { |
1234 | u16 int_txe = musb_readw(musb->mregs, MUSB_INTRTXE); | 1232 | musb->intrtxe &= ~(1 << epnum); |
1235 | int_txe &= ~(1 << epnum); | 1233 | musb_writew(musb->mregs, MUSB_INTRTXE, musb->intrtxe); |
1236 | musb_writew(musb->mregs, MUSB_INTRTXE, int_txe); | ||
1237 | musb_writew(epio, MUSB_TXMAXP, 0); | 1234 | musb_writew(epio, MUSB_TXMAXP, 0); |
1238 | } else { | 1235 | } else { |
1239 | u16 int_rxe = musb_readw(musb->mregs, MUSB_INTRRXE); | 1236 | musb->intrrxe &= ~(1 << epnum); |
1240 | int_rxe &= ~(1 << epnum); | 1237 | musb_writew(musb->mregs, MUSB_INTRRXE, musb->intrrxe); |
1241 | musb_writew(musb->mregs, MUSB_INTRRXE, int_rxe); | ||
1242 | musb_writew(epio, MUSB_RXMAXP, 0); | 1238 | musb_writew(epio, MUSB_RXMAXP, 0); |
1243 | } | 1239 | } |
1244 | 1240 | ||
@@ -1554,7 +1550,7 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep) | |||
1554 | void __iomem *epio = musb->endpoints[epnum].regs; | 1550 | void __iomem *epio = musb->endpoints[epnum].regs; |
1555 | void __iomem *mbase; | 1551 | void __iomem *mbase; |
1556 | unsigned long flags; | 1552 | unsigned long flags; |
1557 | u16 csr, int_txe; | 1553 | u16 csr; |
1558 | 1554 | ||
1559 | mbase = musb->mregs; | 1555 | mbase = musb->mregs; |
1560 | 1556 | ||
@@ -1562,8 +1558,7 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep) | |||
1562 | musb_ep_select(mbase, (u8) epnum); | 1558 | musb_ep_select(mbase, (u8) epnum); |
1563 | 1559 | ||
1564 | /* disable interrupts */ | 1560 | /* disable interrupts */ |
1565 | int_txe = musb_readw(mbase, MUSB_INTRTXE); | 1561 | musb_writew(mbase, MUSB_INTRTXE, musb->intrtxe & ~(1 << epnum)); |
1566 | musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum)); | ||
1567 | 1562 | ||
1568 | if (musb_ep->is_in) { | 1563 | if (musb_ep->is_in) { |
1569 | csr = musb_readw(epio, MUSB_TXCSR); | 1564 | csr = musb_readw(epio, MUSB_TXCSR); |
@@ -1587,7 +1582,7 @@ static void musb_gadget_fifo_flush(struct usb_ep *ep) | |||
1587 | } | 1582 | } |
1588 | 1583 | ||
1589 | /* re-enable interrupt */ | 1584 | /* re-enable interrupt */ |
1590 | musb_writew(mbase, MUSB_INTRTXE, int_txe); | 1585 | musb_writew(mbase, MUSB_INTRTXE, musb->intrtxe); |
1591 | spin_unlock_irqrestore(&musb->lock, flags); | 1586 | spin_unlock_irqrestore(&musb->lock, flags); |
1592 | } | 1587 | } |
1593 | 1588 | ||
@@ -2176,10 +2171,9 @@ __acquires(musb->lock) | |||
2176 | u8 devctl = musb_readb(mbase, MUSB_DEVCTL); | 2171 | u8 devctl = musb_readb(mbase, MUSB_DEVCTL); |
2177 | u8 power; | 2172 | u8 power; |
2178 | 2173 | ||
2179 | dev_dbg(musb->controller, "<== %s addr=%x driver '%s'\n", | 2174 | dev_dbg(musb->controller, "<== %s driver '%s'\n", |
2180 | (devctl & MUSB_DEVCTL_BDEVICE) | 2175 | (devctl & MUSB_DEVCTL_BDEVICE) |
2181 | ? "B-Device" : "A-Device", | 2176 | ? "B-Device" : "A-Device", |
2182 | musb_readb(mbase, MUSB_FADDR), | ||
2183 | musb->gadget_driver | 2177 | musb->gadget_driver |
2184 | ? musb->gadget_driver->driver.name | 2178 | ? musb->gadget_driver->driver.name |
2185 | : NULL | 2179 | : NULL |
diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index e40d7647caf1..c9c1ac4e075f 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c | |||
@@ -673,10 +673,8 @@ irqreturn_t musb_g_ep0_irq(struct musb *musb) | |||
673 | csr = musb_readw(regs, MUSB_CSR0); | 673 | csr = musb_readw(regs, MUSB_CSR0); |
674 | len = musb_readb(regs, MUSB_COUNT0); | 674 | len = musb_readb(regs, MUSB_COUNT0); |
675 | 675 | ||
676 | dev_dbg(musb->controller, "csr %04x, count %d, myaddr %d, ep0stage %s\n", | 676 | dev_dbg(musb->controller, "csr %04x, count %d, ep0stage %s\n", |
677 | csr, len, | 677 | csr, len, decode_ep0stage(musb->ep0_state)); |
678 | musb_readb(mbase, MUSB_FADDR), | ||
679 | decode_ep0stage(musb->ep0_state)); | ||
680 | 678 | ||
681 | if (csr & MUSB_CSR0_P_DATAEND) { | 679 | if (csr & MUSB_CSR0_P_DATAEND) { |
682 | /* | 680 | /* |
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 3df6a76b851d..e9f0fd9ddd2d 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c | |||
@@ -740,7 +740,7 @@ static void musb_ep_program(struct musb *musb, u8 epnum, | |||
740 | csr = musb_readw(epio, MUSB_TXCSR); | 740 | csr = musb_readw(epio, MUSB_TXCSR); |
741 | 741 | ||
742 | /* disable interrupt in case we flush */ | 742 | /* disable interrupt in case we flush */ |
743 | int_txe = musb_readw(mbase, MUSB_INTRTXE); | 743 | int_txe = musb->intrtxe; |
744 | musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum)); | 744 | musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum)); |
745 | 745 | ||
746 | /* general endpoint setup */ | 746 | /* general endpoint setup */ |
diff --git a/drivers/usb/musb/musbhsdma.h b/drivers/usb/musb/musbhsdma.h index 320fd4afb93f..f7b13fd25257 100644 --- a/drivers/usb/musb/musbhsdma.h +++ b/drivers/usb/musb/musbhsdma.h | |||
@@ -31,10 +31,6 @@ | |||
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430) | ||
35 | #include "omap2430.h" | ||
36 | #endif | ||
37 | |||
38 | #ifndef CONFIG_BLACKFIN | 34 | #ifndef CONFIG_BLACKFIN |
39 | 35 | ||
40 | #define MUSB_HSDMA_BASE 0x200 | 36 | #define MUSB_HSDMA_BASE 0x200 |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index a538fe17a966..32f531e7a2e6 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -333,6 +333,26 @@ static void omap_musb_mailbox_work(struct work_struct *mailbox_work) | |||
333 | omap_musb_set_mailbox(glue); | 333 | omap_musb_set_mailbox(glue); |
334 | } | 334 | } |
335 | 335 | ||
336 | static irqreturn_t omap2430_musb_interrupt(int irq, void *__hci) | ||
337 | { | ||
338 | unsigned long flags; | ||
339 | irqreturn_t retval = IRQ_NONE; | ||
340 | struct musb *musb = __hci; | ||
341 | |||
342 | spin_lock_irqsave(&musb->lock, flags); | ||
343 | |||
344 | musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); | ||
345 | musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); | ||
346 | musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); | ||
347 | |||
348 | if (musb->int_usb || musb->int_tx || musb->int_rx) | ||
349 | retval = musb_interrupt(musb); | ||
350 | |||
351 | spin_unlock_irqrestore(&musb->lock, flags); | ||
352 | |||
353 | return retval; | ||
354 | } | ||
355 | |||
336 | static int omap2430_musb_init(struct musb *musb) | 356 | static int omap2430_musb_init(struct musb *musb) |
337 | { | 357 | { |
338 | u32 l; | 358 | u32 l; |
@@ -352,6 +372,8 @@ static int omap2430_musb_init(struct musb *musb) | |||
352 | return -ENODEV; | 372 | return -ENODEV; |
353 | } | 373 | } |
354 | 374 | ||
375 | musb->isr = omap2430_musb_interrupt; | ||
376 | |||
355 | status = pm_runtime_get_sync(dev); | 377 | status = pm_runtime_get_sync(dev); |
356 | if (status < 0) { | 378 | if (status < 0) { |
357 | dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); | 379 | dev_err(dev, "pm_runtime_get_sync FAILED %d\n", status); |
@@ -478,7 +500,6 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
478 | struct musb_hdrc_config *config; | 500 | struct musb_hdrc_config *config; |
479 | struct resource *res; | 501 | struct resource *res; |
480 | int ret = -ENOMEM; | 502 | int ret = -ENOMEM; |
481 | int musbid; | ||
482 | 503 | ||
483 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); | 504 | glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); |
484 | if (!glue) { | 505 | if (!glue) { |
@@ -486,21 +507,12 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
486 | goto err0; | 507 | goto err0; |
487 | } | 508 | } |
488 | 509 | ||
489 | /* get the musb id */ | 510 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
490 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
491 | if (musbid < 0) { | ||
492 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
493 | ret = -ENOMEM; | ||
494 | goto err0; | ||
495 | } | ||
496 | |||
497 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
498 | if (!musb) { | 511 | if (!musb) { |
499 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 512 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
500 | goto err1; | 513 | goto err0; |
501 | } | 514 | } |
502 | 515 | ||
503 | musb->id = musbid; | ||
504 | musb->dev.parent = &pdev->dev; | 516 | musb->dev.parent = &pdev->dev; |
505 | musb->dev.dma_mask = &omap2430_dmamask; | 517 | musb->dev.dma_mask = &omap2430_dmamask; |
506 | musb->dev.coherent_dma_mask = omap2430_dmamask; | 518 | musb->dev.coherent_dma_mask = omap2430_dmamask; |
@@ -521,7 +533,7 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
521 | dev_err(&pdev->dev, | 533 | dev_err(&pdev->dev, |
522 | "failed to allocate musb platfrom data\n"); | 534 | "failed to allocate musb platfrom data\n"); |
523 | ret = -ENOMEM; | 535 | ret = -ENOMEM; |
524 | goto err1; | 536 | goto err2; |
525 | } | 537 | } |
526 | 538 | ||
527 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); | 539 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
@@ -529,14 +541,14 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
529 | dev_err(&pdev->dev, | 541 | dev_err(&pdev->dev, |
530 | "failed to allocate musb board data\n"); | 542 | "failed to allocate musb board data\n"); |
531 | ret = -ENOMEM; | 543 | ret = -ENOMEM; |
532 | goto err1; | 544 | goto err2; |
533 | } | 545 | } |
534 | 546 | ||
535 | config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); | 547 | config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); |
536 | if (!data) { | 548 | if (!data) { |
537 | dev_err(&pdev->dev, | 549 | dev_err(&pdev->dev, |
538 | "failed to allocate musb hdrc config\n"); | 550 | "failed to allocate musb hdrc config\n"); |
539 | goto err1; | 551 | goto err2; |
540 | } | 552 | } |
541 | 553 | ||
542 | of_property_read_u32(np, "mode", (u32 *)&pdata->mode); | 554 | of_property_read_u32(np, "mode", (u32 *)&pdata->mode); |
@@ -589,9 +601,6 @@ static int __devinit omap2430_probe(struct platform_device *pdev) | |||
589 | err2: | 601 | err2: |
590 | platform_device_put(musb); | 602 | platform_device_put(musb); |
591 | 603 | ||
592 | err1: | ||
593 | musb_put_id(&pdev->dev, musbid); | ||
594 | |||
595 | err0: | 604 | err0: |
596 | return ret; | 605 | return ret; |
597 | } | 606 | } |
@@ -601,7 +610,6 @@ static int __devexit omap2430_remove(struct platform_device *pdev) | |||
601 | struct omap2430_glue *glue = platform_get_drvdata(pdev); | 610 | struct omap2430_glue *glue = platform_get_drvdata(pdev); |
602 | 611 | ||
603 | cancel_work_sync(&glue->omap_musb_mailbox_work); | 612 | cancel_work_sync(&glue->omap_musb_mailbox_work); |
604 | musb_put_id(&pdev->dev, glue->musb->id); | ||
605 | platform_device_unregister(glue->musb); | 613 | platform_device_unregister(glue->musb); |
606 | 614 | ||
607 | return 0; | 615 | return 0; |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index dc4d75ea13ad..812719b683d1 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -1160,7 +1160,6 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
1160 | struct tusb6010_glue *glue; | 1160 | struct tusb6010_glue *glue; |
1161 | 1161 | ||
1162 | int ret = -ENOMEM; | 1162 | int ret = -ENOMEM; |
1163 | int musbid; | ||
1164 | 1163 | ||
1165 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 1164 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
1166 | if (!glue) { | 1165 | if (!glue) { |
@@ -1168,21 +1167,12 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
1168 | goto err0; | 1167 | goto err0; |
1169 | } | 1168 | } |
1170 | 1169 | ||
1171 | /* get the musb id */ | 1170 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
1172 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
1173 | if (musbid < 0) { | ||
1174 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
1175 | ret = -ENOMEM; | ||
1176 | goto err1; | ||
1177 | } | ||
1178 | |||
1179 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
1180 | if (!musb) { | 1171 | if (!musb) { |
1181 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 1172 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
1182 | goto err2; | 1173 | goto err1; |
1183 | } | 1174 | } |
1184 | 1175 | ||
1185 | musb->id = musbid; | ||
1186 | musb->dev.parent = &pdev->dev; | 1176 | musb->dev.parent = &pdev->dev; |
1187 | musb->dev.dma_mask = &tusb_dmamask; | 1177 | musb->dev.dma_mask = &tusb_dmamask; |
1188 | musb->dev.coherent_dma_mask = tusb_dmamask; | 1178 | musb->dev.coherent_dma_mask = tusb_dmamask; |
@@ -1218,9 +1208,6 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
1218 | err3: | 1208 | err3: |
1219 | platform_device_put(musb); | 1209 | platform_device_put(musb); |
1220 | 1210 | ||
1221 | err2: | ||
1222 | musb_put_id(&pdev->dev, musbid); | ||
1223 | |||
1224 | err1: | 1211 | err1: |
1225 | kfree(glue); | 1212 | kfree(glue); |
1226 | 1213 | ||
@@ -1232,9 +1219,7 @@ static int __devexit tusb_remove(struct platform_device *pdev) | |||
1232 | { | 1219 | { |
1233 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); | 1220 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); |
1234 | 1221 | ||
1235 | musb_put_id(&pdev->dev, glue->musb->id); | 1222 | platform_device_unregister(glue->musb); |
1236 | platform_device_del(glue->musb); | ||
1237 | platform_device_put(glue->musb); | ||
1238 | kfree(glue); | 1223 | kfree(glue); |
1239 | 1224 | ||
1240 | return 0; | 1225 | return 0; |
@@ -1251,15 +1236,4 @@ static struct platform_driver tusb_driver = { | |||
1251 | MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); | 1236 | MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); |
1252 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 1237 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
1253 | MODULE_LICENSE("GPL v2"); | 1238 | MODULE_LICENSE("GPL v2"); |
1254 | 1239 | module_platform_driver(tusb_driver); | |
1255 | static int __init tusb_init(void) | ||
1256 | { | ||
1257 | return platform_driver_register(&tusb_driver); | ||
1258 | } | ||
1259 | module_init(tusb_init); | ||
1260 | |||
1261 | static void __exit tusb_exit(void) | ||
1262 | { | ||
1263 | platform_driver_unregister(&tusb_driver); | ||
1264 | } | ||
1265 | module_exit(tusb_exit); | ||
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index 0e62f504410e..286f1be6594a 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c | |||
@@ -36,6 +36,26 @@ struct ux500_glue { | |||
36 | }; | 36 | }; |
37 | #define glue_to_musb(g) platform_get_drvdata(g->musb) | 37 | #define glue_to_musb(g) platform_get_drvdata(g->musb) |
38 | 38 | ||
39 | static irqreturn_t ux500_musb_interrupt(int irq, void *__hci) | ||
40 | { | ||
41 | unsigned long flags; | ||
42 | irqreturn_t retval = IRQ_NONE; | ||
43 | struct musb *musb = __hci; | ||
44 | |||
45 | spin_lock_irqsave(&musb->lock, flags); | ||
46 | |||
47 | musb->int_usb = musb_readb(musb->mregs, MUSB_INTRUSB); | ||
48 | musb->int_tx = musb_readw(musb->mregs, MUSB_INTRTX); | ||
49 | musb->int_rx = musb_readw(musb->mregs, MUSB_INTRRX); | ||
50 | |||
51 | if (musb->int_usb || musb->int_tx || musb->int_rx) | ||
52 | retval = musb_interrupt(musb); | ||
53 | |||
54 | spin_unlock_irqrestore(&musb->lock, flags); | ||
55 | |||
56 | return retval; | ||
57 | } | ||
58 | |||
39 | static int ux500_musb_init(struct musb *musb) | 59 | static int ux500_musb_init(struct musb *musb) |
40 | { | 60 | { |
41 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); | 61 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); |
@@ -44,6 +64,8 @@ static int ux500_musb_init(struct musb *musb) | |||
44 | return -ENODEV; | 64 | return -ENODEV; |
45 | } | 65 | } |
46 | 66 | ||
67 | musb->isr = ux500_musb_interrupt; | ||
68 | |||
47 | return 0; | 69 | return 0; |
48 | } | 70 | } |
49 | 71 | ||
@@ -65,7 +87,6 @@ static int __devinit ux500_probe(struct platform_device *pdev) | |||
65 | struct platform_device *musb; | 87 | struct platform_device *musb; |
66 | struct ux500_glue *glue; | 88 | struct ux500_glue *glue; |
67 | struct clk *clk; | 89 | struct clk *clk; |
68 | int musbid; | ||
69 | int ret = -ENOMEM; | 90 | int ret = -ENOMEM; |
70 | 91 | ||
71 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 92 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
@@ -74,18 +95,10 @@ static int __devinit ux500_probe(struct platform_device *pdev) | |||
74 | goto err0; | 95 | goto err0; |
75 | } | 96 | } |
76 | 97 | ||
77 | /* get the musb id */ | 98 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
78 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
79 | if (musbid < 0) { | ||
80 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
81 | ret = -ENOMEM; | ||
82 | goto err1; | ||
83 | } | ||
84 | |||
85 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
86 | if (!musb) { | 99 | if (!musb) { |
87 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 100 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
88 | goto err2; | 101 | goto err1; |
89 | } | 102 | } |
90 | 103 | ||
91 | clk = clk_get(&pdev->dev, "usb"); | 104 | clk = clk_get(&pdev->dev, "usb"); |
@@ -101,7 +114,6 @@ static int __devinit ux500_probe(struct platform_device *pdev) | |||
101 | goto err4; | 114 | goto err4; |
102 | } | 115 | } |
103 | 116 | ||
104 | musb->id = musbid; | ||
105 | musb->dev.parent = &pdev->dev; | 117 | musb->dev.parent = &pdev->dev; |
106 | musb->dev.dma_mask = pdev->dev.dma_mask; | 118 | musb->dev.dma_mask = pdev->dev.dma_mask; |
107 | musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; | 119 | musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; |
@@ -144,9 +156,6 @@ err4: | |||
144 | err3: | 156 | err3: |
145 | platform_device_put(musb); | 157 | platform_device_put(musb); |
146 | 158 | ||
147 | err2: | ||
148 | musb_put_id(&pdev->dev, musbid); | ||
149 | |||
150 | err1: | 159 | err1: |
151 | kfree(glue); | 160 | kfree(glue); |
152 | 161 | ||
@@ -158,9 +167,7 @@ static int __devexit ux500_remove(struct platform_device *pdev) | |||
158 | { | 167 | { |
159 | struct ux500_glue *glue = platform_get_drvdata(pdev); | 168 | struct ux500_glue *glue = platform_get_drvdata(pdev); |
160 | 169 | ||
161 | musb_put_id(&pdev->dev, glue->musb->id); | 170 | platform_device_unregister(glue->musb); |
162 | platform_device_del(glue->musb); | ||
163 | platform_device_put(glue->musb); | ||
164 | clk_disable(glue->clk); | 171 | clk_disable(glue->clk); |
165 | clk_put(glue->clk); | 172 | clk_put(glue->clk); |
166 | kfree(glue); | 173 | kfree(glue); |
@@ -219,15 +226,4 @@ static struct platform_driver ux500_driver = { | |||
219 | MODULE_DESCRIPTION("UX500 MUSB Glue Layer"); | 226 | MODULE_DESCRIPTION("UX500 MUSB Glue Layer"); |
220 | MODULE_AUTHOR("Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>"); | 227 | MODULE_AUTHOR("Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>"); |
221 | MODULE_LICENSE("GPL v2"); | 228 | MODULE_LICENSE("GPL v2"); |
222 | 229 | module_platform_driver(ux500_driver); | |
223 | static int __init ux500_init(void) | ||
224 | { | ||
225 | return platform_driver_register(&ux500_driver); | ||
226 | } | ||
227 | module_init(ux500_init); | ||
228 | |||
229 | static void __exit ux500_exit(void) | ||
230 | { | ||
231 | platform_driver_unregister(&ux500_driver); | ||
232 | } | ||
233 | module_exit(ux500_exit); | ||
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c index 3f124e8f5792..1dd57504186d 100644 --- a/drivers/usb/otg/mv_otg.c +++ b/drivers/usb/otg/mv_otg.c | |||
@@ -958,16 +958,4 @@ static struct platform_driver mv_otg_driver = { | |||
958 | .resume = mv_otg_resume, | 958 | .resume = mv_otg_resume, |
959 | #endif | 959 | #endif |
960 | }; | 960 | }; |
961 | 961 | module_platform_driver(mv_otg_driver); | |
962 | static int __init mv_otg_init(void) | ||
963 | { | ||
964 | return platform_driver_register(&mv_otg_driver); | ||
965 | } | ||
966 | |||
967 | static void __exit mv_otg_exit(void) | ||
968 | { | ||
969 | platform_driver_unregister(&mv_otg_driver); | ||
970 | } | ||
971 | |||
972 | module_init(mv_otg_init); | ||
973 | module_exit(mv_otg_exit); | ||
diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c index 88db976647cf..9a3caeecc508 100644 --- a/drivers/usb/otg/mxs-phy.c +++ b/drivers/usb/otg/mxs-phy.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/workqueue.h> | ||
24 | 23 | ||
25 | #define DRIVER_NAME "mxs_phy" | 24 | #define DRIVER_NAME "mxs_phy" |
26 | 25 | ||
@@ -35,16 +34,9 @@ | |||
35 | #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) | 34 | #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14) |
36 | #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) | 35 | #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1) |
37 | 36 | ||
38 | /* | ||
39 | * Amount of delay in miliseconds to safely enable ENHOSTDISCONDETECT bit | ||
40 | * so that connection and reset processing can be completed for the root hub. | ||
41 | */ | ||
42 | #define MXY_PHY_ENHOSTDISCONDETECT_DELAY 250 | ||
43 | |||
44 | struct mxs_phy { | 37 | struct mxs_phy { |
45 | struct usb_phy phy; | 38 | struct usb_phy phy; |
46 | struct clk *clk; | 39 | struct clk *clk; |
47 | struct delayed_work enhostdiscondetect_work; | ||
48 | }; | 40 | }; |
49 | 41 | ||
50 | #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) | 42 | #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) |
@@ -70,7 +62,6 @@ static int mxs_phy_init(struct usb_phy *phy) | |||
70 | 62 | ||
71 | clk_prepare_enable(mxs_phy->clk); | 63 | clk_prepare_enable(mxs_phy->clk); |
72 | mxs_phy_hw_init(mxs_phy); | 64 | mxs_phy_hw_init(mxs_phy); |
73 | INIT_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, NULL); | ||
74 | 65 | ||
75 | return 0; | 66 | return 0; |
76 | } | 67 | } |
@@ -85,46 +76,28 @@ static void mxs_phy_shutdown(struct usb_phy *phy) | |||
85 | clk_disable_unprepare(mxs_phy->clk); | 76 | clk_disable_unprepare(mxs_phy->clk); |
86 | } | 77 | } |
87 | 78 | ||
88 | static void mxs_phy_enhostdiscondetect_delay(struct work_struct *ws) | 79 | static int mxs_phy_on_connect(struct usb_phy *phy, |
80 | enum usb_device_speed speed) | ||
89 | { | 81 | { |
90 | struct mxs_phy *mxs_phy = container_of(ws, struct mxs_phy, | 82 | dev_dbg(phy->dev, "%s speed device has connected\n", |
91 | enhostdiscondetect_work.work); | 83 | (speed == USB_SPEED_HIGH) ? "high" : "non-high"); |
92 | |||
93 | /* Enable HOSTDISCONDETECT after delay. */ | ||
94 | dev_dbg(mxs_phy->phy.dev, "Setting ENHOSTDISCONDETECT\n"); | ||
95 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, | ||
96 | mxs_phy->phy.io_priv + HW_USBPHY_CTRL_SET); | ||
97 | } | ||
98 | |||
99 | static int mxs_phy_on_connect(struct usb_phy *phy, int port) | ||
100 | { | ||
101 | struct mxs_phy *mxs_phy = to_mxs_phy(phy); | ||
102 | |||
103 | dev_dbg(phy->dev, "Connect on port %d\n", port); | ||
104 | |||
105 | mxs_phy_hw_init(mxs_phy); | ||
106 | 84 | ||
107 | /* | 85 | if (speed == USB_SPEED_HIGH) |
108 | * Delay enabling ENHOSTDISCONDETECT so that connection and | 86 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, |
109 | * reset processing can be completed for the root hub. | 87 | phy->io_priv + HW_USBPHY_CTRL_SET); |
110 | */ | ||
111 | dev_dbg(phy->dev, "Delaying setting ENHOSTDISCONDETECT\n"); | ||
112 | PREPARE_DELAYED_WORK(&mxs_phy->enhostdiscondetect_work, | ||
113 | mxs_phy_enhostdiscondetect_delay); | ||
114 | schedule_delayed_work(&mxs_phy->enhostdiscondetect_work, | ||
115 | msecs_to_jiffies(MXY_PHY_ENHOSTDISCONDETECT_DELAY)); | ||
116 | 88 | ||
117 | return 0; | 89 | return 0; |
118 | } | 90 | } |
119 | 91 | ||
120 | static int mxs_phy_on_disconnect(struct usb_phy *phy, int port) | 92 | static int mxs_phy_on_disconnect(struct usb_phy *phy, |
93 | enum usb_device_speed speed) | ||
121 | { | 94 | { |
122 | dev_dbg(phy->dev, "Disconnect on port %d\n", port); | 95 | dev_dbg(phy->dev, "%s speed device has disconnected\n", |
96 | (speed == USB_SPEED_HIGH) ? "high" : "non-high"); | ||
123 | 97 | ||
124 | /* No need to delay before clearing ENHOSTDISCONDETECT. */ | 98 | if (speed == USB_SPEED_HIGH) |
125 | dev_dbg(phy->dev, "Clearing ENHOSTDISCONDETECT\n"); | 99 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, |
126 | writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT, | 100 | phy->io_priv + HW_USBPHY_CTRL_CLR); |
127 | phy->io_priv + HW_USBPHY_CTRL_CLR); | ||
128 | 101 | ||
129 | return 0; | 102 | return 0; |
130 | } | 103 | } |
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index f0d2e7530cfe..11b2a1203d40 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c | |||
@@ -123,10 +123,10 @@ | |||
123 | #define PHY_CLK_CTRL_STS 0xFF | 123 | #define PHY_CLK_CTRL_STS 0xFF |
124 | #define PHY_DPLL_CLK (1 << 0) | 124 | #define PHY_DPLL_CLK (1 << 0) |
125 | 125 | ||
126 | /* In module TWL4030_MODULE_PM_MASTER */ | 126 | /* In module TWL_MODULE_PM_MASTER */ |
127 | #define STS_HW_CONDITIONS 0x0F | 127 | #define STS_HW_CONDITIONS 0x0F |
128 | 128 | ||
129 | /* In module TWL4030_MODULE_PM_RECEIVER */ | 129 | /* In module TWL_MODULE_PM_RECEIVER */ |
130 | #define VUSB_DEDICATED1 0x7D | 130 | #define VUSB_DEDICATED1 0x7D |
131 | #define VUSB_DEDICATED2 0x7E | 131 | #define VUSB_DEDICATED2 0x7E |
132 | #define VUSB1V5_DEV_GRP 0x71 | 132 | #define VUSB1V5_DEV_GRP 0x71 |
@@ -195,14 +195,14 @@ static int twl4030_i2c_write_u8_verify(struct twl4030_usb *twl, | |||
195 | } | 195 | } |
196 | 196 | ||
197 | #define twl4030_usb_write_verify(twl, address, data) \ | 197 | #define twl4030_usb_write_verify(twl, address, data) \ |
198 | twl4030_i2c_write_u8_verify(twl, TWL4030_MODULE_USB, (data), (address)) | 198 | twl4030_i2c_write_u8_verify(twl, TWL_MODULE_USB, (data), (address)) |
199 | 199 | ||
200 | static inline int twl4030_usb_write(struct twl4030_usb *twl, | 200 | static inline int twl4030_usb_write(struct twl4030_usb *twl, |
201 | u8 address, u8 data) | 201 | u8 address, u8 data) |
202 | { | 202 | { |
203 | int ret = 0; | 203 | int ret = 0; |
204 | 204 | ||
205 | ret = twl_i2c_write_u8(TWL4030_MODULE_USB, data, address); | 205 | ret = twl_i2c_write_u8(TWL_MODULE_USB, data, address); |
206 | if (ret < 0) | 206 | if (ret < 0) |
207 | dev_dbg(twl->dev, | 207 | dev_dbg(twl->dev, |
208 | "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); | 208 | "TWL4030:USB:Write[0x%x] Error %d\n", address, ret); |
@@ -227,7 +227,7 @@ static inline int twl4030_readb(struct twl4030_usb *twl, u8 module, u8 address) | |||
227 | 227 | ||
228 | static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) | 228 | static inline int twl4030_usb_read(struct twl4030_usb *twl, u8 address) |
229 | { | 229 | { |
230 | return twl4030_readb(twl, TWL4030_MODULE_USB, address); | 230 | return twl4030_readb(twl, TWL_MODULE_USB, address); |
231 | } | 231 | } |
232 | 232 | ||
233 | /*-------------------------------------------------------------------------*/ | 233 | /*-------------------------------------------------------------------------*/ |
@@ -264,8 +264,7 @@ static enum omap_musb_vbus_id_status | |||
264 | * signal is active, the OTG module is activated, and | 264 | * signal is active, the OTG module is activated, and |
265 | * its interrupt may be raised (may wake the system). | 265 | * its interrupt may be raised (may wake the system). |
266 | */ | 266 | */ |
267 | status = twl4030_readb(twl, TWL4030_MODULE_PM_MASTER, | 267 | status = twl4030_readb(twl, TWL_MODULE_PM_MASTER, STS_HW_CONDITIONS); |
268 | STS_HW_CONDITIONS); | ||
269 | if (status < 0) | 268 | if (status < 0) |
270 | dev_err(twl->dev, "USB link status err %d\n", status); | 269 | dev_err(twl->dev, "USB link status err %d\n", status); |
271 | else if (status & (BIT(7) | BIT(2))) { | 270 | else if (status & (BIT(7) | BIT(2))) { |
@@ -372,8 +371,7 @@ static void twl4030_phy_power(struct twl4030_usb *twl, int on) | |||
372 | * SLEEP. We work around this by clearing the bit after usv3v1 | 371 | * SLEEP. We work around this by clearing the bit after usv3v1 |
373 | * is re-activated. This ensures that VUSB3V1 is really active. | 372 | * is re-activated. This ensures that VUSB3V1 is really active. |
374 | */ | 373 | */ |
375 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, | 374 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2); |
376 | VUSB_DEDICATED2); | ||
377 | regulator_enable(twl->usb1v5); | 375 | regulator_enable(twl->usb1v5); |
378 | __twl4030_phy_power(twl, 1); | 376 | __twl4030_phy_power(twl, 1); |
379 | twl4030_usb_write(twl, PHY_CLK_CTRL, | 377 | twl4030_usb_write(twl, PHY_CLK_CTRL, |
@@ -419,50 +417,48 @@ static void twl4030_phy_resume(struct twl4030_usb *twl) | |||
419 | static int twl4030_usb_ldo_init(struct twl4030_usb *twl) | 417 | static int twl4030_usb_ldo_init(struct twl4030_usb *twl) |
420 | { | 418 | { |
421 | /* Enable writing to power configuration registers */ | 419 | /* Enable writing to power configuration registers */ |
422 | twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, | 420 | twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG1, |
423 | TWL4030_PM_MASTER_KEY_CFG1, | 421 | TWL4030_PM_MASTER_PROTECT_KEY); |
424 | TWL4030_PM_MASTER_PROTECT_KEY); | ||
425 | 422 | ||
426 | twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, | 423 | twl_i2c_write_u8(TWL_MODULE_PM_MASTER, TWL4030_PM_MASTER_KEY_CFG2, |
427 | TWL4030_PM_MASTER_KEY_CFG2, | 424 | TWL4030_PM_MASTER_PROTECT_KEY); |
428 | TWL4030_PM_MASTER_PROTECT_KEY); | ||
429 | 425 | ||
430 | /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/ | 426 | /* Keep VUSB3V1 LDO in sleep state until VBUS/ID change detected*/ |
431 | /*twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ | 427 | /*twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB_DEDICATED2);*/ |
432 | 428 | ||
433 | /* input to VUSB3V1 LDO is from VBAT, not VBUS */ | 429 | /* input to VUSB3V1 LDO is from VBAT, not VBUS */ |
434 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); | 430 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0x14, VUSB_DEDICATED1); |
435 | 431 | ||
436 | /* Initialize 3.1V regulator */ | 432 | /* Initialize 3.1V regulator */ |
437 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); | 433 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_DEV_GRP); |
438 | 434 | ||
439 | twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); | 435 | twl->usb3v1 = regulator_get(twl->dev, "usb3v1"); |
440 | if (IS_ERR(twl->usb3v1)) | 436 | if (IS_ERR(twl->usb3v1)) |
441 | return -ENODEV; | 437 | return -ENODEV; |
442 | 438 | ||
443 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); | 439 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB3V1_TYPE); |
444 | 440 | ||
445 | /* Initialize 1.5V regulator */ | 441 | /* Initialize 1.5V regulator */ |
446 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); | 442 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_DEV_GRP); |
447 | 443 | ||
448 | twl->usb1v5 = regulator_get(twl->dev, "usb1v5"); | 444 | twl->usb1v5 = regulator_get(twl->dev, "usb1v5"); |
449 | if (IS_ERR(twl->usb1v5)) | 445 | if (IS_ERR(twl->usb1v5)) |
450 | goto fail1; | 446 | goto fail1; |
451 | 447 | ||
452 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); | 448 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V5_TYPE); |
453 | 449 | ||
454 | /* Initialize 1.8V regulator */ | 450 | /* Initialize 1.8V regulator */ |
455 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP); | 451 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_DEV_GRP); |
456 | 452 | ||
457 | twl->usb1v8 = regulator_get(twl->dev, "usb1v8"); | 453 | twl->usb1v8 = regulator_get(twl->dev, "usb1v8"); |
458 | if (IS_ERR(twl->usb1v8)) | 454 | if (IS_ERR(twl->usb1v8)) |
459 | goto fail2; | 455 | goto fail2; |
460 | 456 | ||
461 | twl_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); | 457 | twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, 0, VUSB1V8_TYPE); |
462 | 458 | ||
463 | /* disable access to power configuration registers */ | 459 | /* disable access to power configuration registers */ |
464 | twl_i2c_write_u8(TWL4030_MODULE_PM_MASTER, 0, | 460 | twl_i2c_write_u8(TWL_MODULE_PM_MASTER, 0, |
465 | TWL4030_PM_MASTER_PROTECT_KEY); | 461 | TWL4030_PM_MASTER_PROTECT_KEY); |
466 | 462 | ||
467 | return 0; | 463 | return 0; |
468 | 464 | ||
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 63c339b3e676..7eb73c561bd2 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig | |||
@@ -32,3 +32,15 @@ config MV_U3D_PHY | |||
32 | help | 32 | help |
33 | Enable this to support Marvell USB 3.0 phy controller for Marvell | 33 | Enable this to support Marvell USB 3.0 phy controller for Marvell |
34 | SoC. | 34 | SoC. |
35 | |||
36 | config USB_RCAR_PHY | ||
37 | tristate "Renesas R-Car USB phy support" | ||
38 | depends on USB || USB_GADGET | ||
39 | select USB_OTG_UTILS | ||
40 | help | ||
41 | Say Y here to add support for the Renesas R-Car USB phy driver. | ||
42 | This chip is typically used as USB phy for USB host, gadget. | ||
43 | This driver supports: R8A7779 | ||
44 | |||
45 | To compile this driver as a module, choose M here: the | ||
46 | module will be called rcar-phy. | ||
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile index b069f29f1225..1a579a860a03 100644 --- a/drivers/usb/phy/Makefile +++ b/drivers/usb/phy/Makefile | |||
@@ -8,3 +8,4 @@ obj-$(CONFIG_OMAP_USB2) += omap-usb2.o | |||
8 | obj-$(CONFIG_USB_ISP1301) += isp1301.o | 8 | obj-$(CONFIG_USB_ISP1301) += isp1301.o |
9 | obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o | 9 | obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o |
10 | obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o | 10 | obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o |
11 | obj-$(CONFIG_USB_RCAR_PHY) += rcar-phy.o | ||
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c new file mode 100644 index 000000000000..792f505d630c --- /dev/null +++ b/drivers/usb/phy/rcar-phy.c | |||
@@ -0,0 +1,220 @@ | |||
1 | /* | ||
2 | * Renesas R-Car USB phy driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Renesas Solutions Corp. | ||
5 | * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/delay.h> | ||
13 | #include <linux/io.h> | ||
14 | #include <linux/usb/otg.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/spinlock.h> | ||
17 | #include <linux/module.h> | ||
18 | |||
19 | /* USBH common register */ | ||
20 | #define USBPCTRL0 0x0800 | ||
21 | #define USBPCTRL1 0x0804 | ||
22 | #define USBST 0x0808 | ||
23 | #define USBEH0 0x080C | ||
24 | #define USBOH0 0x081C | ||
25 | #define USBCTL0 0x0858 | ||
26 | #define EIIBC1 0x0094 | ||
27 | #define EIIBC2 0x009C | ||
28 | |||
29 | /* USBPCTRL1 */ | ||
30 | #define PHY_RST (1 << 2) | ||
31 | #define PLL_ENB (1 << 1) | ||
32 | #define PHY_ENB (1 << 0) | ||
33 | |||
34 | /* USBST */ | ||
35 | #define ST_ACT (1 << 31) | ||
36 | #define ST_PLL (1 << 30) | ||
37 | |||
38 | struct rcar_usb_phy_priv { | ||
39 | struct usb_phy phy; | ||
40 | spinlock_t lock; | ||
41 | |||
42 | void __iomem *reg0; | ||
43 | void __iomem *reg1; | ||
44 | int counter; | ||
45 | }; | ||
46 | |||
47 | #define usb_phy_to_priv(p) container_of(p, struct rcar_usb_phy_priv, phy) | ||
48 | |||
49 | |||
50 | /* | ||
51 | * USB initial/install operation. | ||
52 | * | ||
53 | * This function setup USB phy. | ||
54 | * The used value and setting order came from | ||
55 | * [USB :: Initial setting] on datasheet. | ||
56 | */ | ||
57 | static int rcar_usb_phy_init(struct usb_phy *phy) | ||
58 | { | ||
59 | struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy); | ||
60 | struct device *dev = phy->dev; | ||
61 | void __iomem *reg0 = priv->reg0; | ||
62 | void __iomem *reg1 = priv->reg1; | ||
63 | int i; | ||
64 | u32 val; | ||
65 | unsigned long flags; | ||
66 | |||
67 | spin_lock_irqsave(&priv->lock, flags); | ||
68 | if (priv->counter++ == 0) { | ||
69 | |||
70 | /* | ||
71 | * USB phy start-up | ||
72 | */ | ||
73 | |||
74 | /* (1) USB-PHY standby release */ | ||
75 | iowrite32(PHY_ENB, (reg0 + USBPCTRL1)); | ||
76 | |||
77 | /* (2) start USB-PHY internal PLL */ | ||
78 | iowrite32(PHY_ENB | PLL_ENB, (reg0 + USBPCTRL1)); | ||
79 | |||
80 | /* (3) USB module status check */ | ||
81 | for (i = 0; i < 1024; i++) { | ||
82 | udelay(10); | ||
83 | val = ioread32(reg0 + USBST); | ||
84 | if (val == (ST_ACT | ST_PLL)) | ||
85 | break; | ||
86 | } | ||
87 | |||
88 | if (val != (ST_ACT | ST_PLL)) { | ||
89 | dev_err(dev, "USB phy not ready\n"); | ||
90 | goto phy_init_end; | ||
91 | } | ||
92 | |||
93 | /* (4) USB-PHY reset clear */ | ||
94 | iowrite32(PHY_ENB | PLL_ENB | PHY_RST, (reg0 + USBPCTRL1)); | ||
95 | |||
96 | /* set platform specific port settings */ | ||
97 | iowrite32(0x00000000, (reg0 + USBPCTRL0)); | ||
98 | |||
99 | /* | ||
100 | * EHCI IP internal buffer setting | ||
101 | * EHCI IP internal buffer enable | ||
102 | * | ||
103 | * These are recommended value of a datasheet | ||
104 | * see [USB :: EHCI internal buffer setting] | ||
105 | */ | ||
106 | iowrite32(0x00ff0040, (reg0 + EIIBC1)); | ||
107 | iowrite32(0x00ff0040, (reg1 + EIIBC1)); | ||
108 | |||
109 | iowrite32(0x00000001, (reg0 + EIIBC2)); | ||
110 | iowrite32(0x00000001, (reg1 + EIIBC2)); | ||
111 | |||
112 | /* | ||
113 | * Bus alignment settings | ||
114 | */ | ||
115 | |||
116 | /* (1) EHCI bus alignment (little endian) */ | ||
117 | iowrite32(0x00000000, (reg0 + USBEH0)); | ||
118 | |||
119 | /* (1) OHCI bus alignment (little endian) */ | ||
120 | iowrite32(0x00000000, (reg0 + USBOH0)); | ||
121 | } | ||
122 | |||
123 | phy_init_end: | ||
124 | spin_unlock_irqrestore(&priv->lock, flags); | ||
125 | |||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static void rcar_usb_phy_shutdown(struct usb_phy *phy) | ||
130 | { | ||
131 | struct rcar_usb_phy_priv *priv = usb_phy_to_priv(phy); | ||
132 | void __iomem *reg0 = priv->reg0; | ||
133 | unsigned long flags; | ||
134 | |||
135 | spin_lock_irqsave(&priv->lock, flags); | ||
136 | |||
137 | if (priv->counter-- == 1) { /* last user */ | ||
138 | iowrite32(0x00000000, (reg0 + USBPCTRL0)); | ||
139 | iowrite32(0x00000000, (reg0 + USBPCTRL1)); | ||
140 | } | ||
141 | |||
142 | spin_unlock_irqrestore(&priv->lock, flags); | ||
143 | } | ||
144 | |||
145 | static int __devinit rcar_usb_phy_probe(struct platform_device *pdev) | ||
146 | { | ||
147 | struct rcar_usb_phy_priv *priv; | ||
148 | struct resource *res0, *res1; | ||
149 | struct device *dev = &pdev->dev; | ||
150 | void __iomem *reg0, *reg1; | ||
151 | int ret; | ||
152 | |||
153 | res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
154 | res1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
155 | if (!res0 || !res1) { | ||
156 | dev_err(dev, "Not enough platform resources\n"); | ||
157 | return -EINVAL; | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * CAUTION | ||
162 | * | ||
163 | * Because this phy address is also mapped under OHCI/EHCI address area, | ||
164 | * this driver can't use devm_request_and_ioremap(dev, res) here | ||
165 | */ | ||
166 | reg0 = devm_ioremap_nocache(dev, res0->start, resource_size(res0)); | ||
167 | reg1 = devm_ioremap_nocache(dev, res1->start, resource_size(res1)); | ||
168 | if (!reg0 || !reg1) { | ||
169 | dev_err(dev, "ioremap error\n"); | ||
170 | return -ENOMEM; | ||
171 | } | ||
172 | |||
173 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
174 | if (!priv) { | ||
175 | dev_err(dev, "priv data allocation error\n"); | ||
176 | return -ENOMEM; | ||
177 | } | ||
178 | |||
179 | priv->reg0 = reg0; | ||
180 | priv->reg1 = reg1; | ||
181 | priv->counter = 0; | ||
182 | priv->phy.dev = dev; | ||
183 | priv->phy.label = dev_name(dev); | ||
184 | priv->phy.init = rcar_usb_phy_init; | ||
185 | priv->phy.shutdown = rcar_usb_phy_shutdown; | ||
186 | spin_lock_init(&priv->lock); | ||
187 | |||
188 | ret = usb_add_phy(&priv->phy, USB_PHY_TYPE_USB2); | ||
189 | if (ret < 0) { | ||
190 | dev_err(dev, "usb phy addition error\n"); | ||
191 | return ret; | ||
192 | } | ||
193 | |||
194 | platform_set_drvdata(pdev, priv); | ||
195 | |||
196 | return ret; | ||
197 | } | ||
198 | |||
199 | static int __devexit rcar_usb_phy_remove(struct platform_device *pdev) | ||
200 | { | ||
201 | struct rcar_usb_phy_priv *priv = platform_get_drvdata(pdev); | ||
202 | |||
203 | usb_remove_phy(&priv->phy); | ||
204 | |||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | static struct platform_driver rcar_usb_phy_driver = { | ||
209 | .driver = { | ||
210 | .name = "rcar_usb_phy", | ||
211 | }, | ||
212 | .probe = rcar_usb_phy_probe, | ||
213 | .remove = __devexit_p(rcar_usb_phy_remove), | ||
214 | }; | ||
215 | |||
216 | module_platform_driver(rcar_usb_phy_driver); | ||
217 | |||
218 | MODULE_LICENSE("GPL v2"); | ||
219 | MODULE_DESCRIPTION("Renesas R-Car USB phy"); | ||
220 | MODULE_AUTHOR("Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>"); | ||
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c index 987116f9efcd..9d13c81754e0 100644 --- a/drivers/usb/phy/tegra_usb_phy.c +++ b/drivers/usb/phy/tegra_usb_phy.c | |||
@@ -29,7 +29,9 @@ | |||
29 | #include <linux/usb/ulpi.h> | 29 | #include <linux/usb/ulpi.h> |
30 | #include <asm/mach-types.h> | 30 | #include <asm/mach-types.h> |
31 | #include <linux/usb/tegra_usb_phy.h> | 31 | #include <linux/usb/tegra_usb_phy.h> |
32 | #include <mach/iomap.h> | 32 | |
33 | #define TEGRA_USB_BASE 0xC5000000 | ||
34 | #define TEGRA_USB_SIZE SZ_16K | ||
33 | 35 | ||
34 | #define ULPI_VIEWPORT 0x170 | 36 | #define ULPI_VIEWPORT 0x170 |
35 | 37 | ||
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index 072edc1cc55f..3bf922ab045e 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -132,6 +132,11 @@ void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable) | |||
132 | usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); | 132 | usbhs_bset(priv, SYSCFG, mask, enable ? val : 0); |
133 | } | 133 | } |
134 | 134 | ||
135 | void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable) | ||
136 | { | ||
137 | usbhs_bset(priv, SYSCFG, DPRPU, enable ? DPRPU : 0); | ||
138 | } | ||
139 | |||
135 | void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode) | 140 | void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode) |
136 | { | 141 | { |
137 | usbhs_write(priv, TESTMODE, mode); | 142 | usbhs_write(priv, TESTMODE, mode); |
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index dddf40a59ded..c69dd2fba360 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h | |||
@@ -285,6 +285,7 @@ void usbhs_bset(struct usbhs_priv *priv, u32 reg, u16 mask, u16 data); | |||
285 | */ | 285 | */ |
286 | void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable); | 286 | void usbhs_sys_host_ctrl(struct usbhs_priv *priv, int enable); |
287 | void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); | 287 | void usbhs_sys_function_ctrl(struct usbhs_priv *priv, int enable); |
288 | void usbhs_sys_function_pullup(struct usbhs_priv *priv, int enable); | ||
288 | void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode); | 289 | void usbhs_sys_set_test_mode(struct usbhs_priv *priv, u16 mode); |
289 | 290 | ||
290 | /* | 291 | /* |
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index c021b202c0f3..9538f0feafe2 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c | |||
@@ -163,7 +163,7 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type) | |||
163 | func = pkt->handler->dma_done; | 163 | func = pkt->handler->dma_done; |
164 | break; | 164 | break; |
165 | default: | 165 | default: |
166 | dev_err(dev, "unknown pkt hander\n"); | 166 | dev_err(dev, "unknown pkt handler\n"); |
167 | goto __usbhs_pkt_handler_end; | 167 | goto __usbhs_pkt_handler_end; |
168 | } | 168 | } |
169 | 169 | ||
@@ -192,8 +192,8 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe) | |||
192 | /* | 192 | /* |
193 | * irq enable/disable function | 193 | * irq enable/disable function |
194 | */ | 194 | */ |
195 | #define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, bempsts, e) | 195 | #define usbhsf_irq_empty_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_bempsts, e) |
196 | #define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, brdysts, e) | 196 | #define usbhsf_irq_ready_ctrl(p, e) usbhsf_irq_callback_ctrl(p, irq_brdysts, e) |
197 | #define usbhsf_irq_callback_ctrl(pipe, status, enable) \ | 197 | #define usbhsf_irq_callback_ctrl(pipe, status, enable) \ |
198 | ({ \ | 198 | ({ \ |
199 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \ | 199 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); \ |
@@ -202,9 +202,9 @@ void usbhs_pkt_start(struct usbhs_pipe *pipe) | |||
202 | if (!mod) \ | 202 | if (!mod) \ |
203 | return; \ | 203 | return; \ |
204 | if (enable) \ | 204 | if (enable) \ |
205 | mod->irq_##status |= status; \ | 205 | mod->status |= status; \ |
206 | else \ | 206 | else \ |
207 | mod->irq_##status &= ~status; \ | 207 | mod->status &= ~status; \ |
208 | usbhs_irq_callback_update(priv, mod); \ | 208 | usbhs_irq_callback_update(priv, mod); \ |
209 | }) | 209 | }) |
210 | 210 | ||
@@ -488,6 +488,8 @@ static int usbhsf_pio_try_push(struct usbhs_pkt *pkt, int *is_done) | |||
488 | usbhs_pipe_data_sequence(pipe, pkt->sequence); | 488 | usbhs_pipe_data_sequence(pipe, pkt->sequence); |
489 | pkt->sequence = -1; /* -1 sequence will be ignored */ | 489 | pkt->sequence = -1; /* -1 sequence will be ignored */ |
490 | 490 | ||
491 | usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length); | ||
492 | |||
491 | ret = usbhsf_fifo_select(pipe, fifo, 1); | 493 | ret = usbhsf_fifo_select(pipe, fifo, 1); |
492 | if (ret < 0) | 494 | if (ret < 0) |
493 | return 0; | 495 | return 0; |
@@ -594,6 +596,7 @@ static int usbhsf_prepare_pop(struct usbhs_pkt *pkt, int *is_done) | |||
594 | usbhs_pipe_data_sequence(pipe, pkt->sequence); | 596 | usbhs_pipe_data_sequence(pipe, pkt->sequence); |
595 | pkt->sequence = -1; /* -1 sequence will be ignored */ | 597 | pkt->sequence = -1; /* -1 sequence will be ignored */ |
596 | 598 | ||
599 | usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->length); | ||
597 | usbhs_pipe_enable(pipe); | 600 | usbhs_pipe_enable(pipe); |
598 | usbhsf_rx_irq_ctrl(pipe, 1); | 601 | usbhsf_rx_irq_ctrl(pipe, 1); |
599 | 602 | ||
@@ -795,6 +798,7 @@ static void xfer_work(struct work_struct *work) | |||
795 | dev_dbg(dev, " %s %d (%d/ %d)\n", | 798 | dev_dbg(dev, " %s %d (%d/ %d)\n", |
796 | fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero); | 799 | fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero); |
797 | 800 | ||
801 | usbhs_pipe_set_trans_count_if_bulk(pipe, pkt->trans); | ||
798 | usbhs_pipe_enable(pipe); | 802 | usbhs_pipe_enable(pipe); |
799 | usbhsf_dma_start(pipe, fifo); | 803 | usbhsf_dma_start(pipe, fifo); |
800 | dma_async_issue_pending(chan); | 804 | dma_async_issue_pending(chan); |
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 61933a90e5bf..6a030b931a3b 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
@@ -151,7 +151,7 @@ int usbhs_mod_probe(struct usbhs_priv *priv) | |||
151 | goto mod_init_host_err; | 151 | goto mod_init_host_err; |
152 | 152 | ||
153 | /* irq settings */ | 153 | /* irq settings */ |
154 | ret = request_irq(priv->irq, usbhs_interrupt, | 154 | ret = devm_request_irq(dev, priv->irq, usbhs_interrupt, |
155 | priv->irqflags, dev_name(dev), priv); | 155 | priv->irqflags, dev_name(dev), priv); |
156 | if (ret) { | 156 | if (ret) { |
157 | dev_err(dev, "irq request err\n"); | 157 | dev_err(dev, "irq request err\n"); |
@@ -172,7 +172,6 @@ void usbhs_mod_remove(struct usbhs_priv *priv) | |||
172 | { | 172 | { |
173 | usbhs_mod_host_remove(priv); | 173 | usbhs_mod_host_remove(priv); |
174 | usbhs_mod_gadget_remove(priv); | 174 | usbhs_mod_gadget_remove(priv); |
175 | free_irq(priv->irq, priv); | ||
176 | } | 175 | } |
177 | 176 | ||
178 | /* | 177 | /* |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 28478ce26c34..dd41f61893ef 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -883,6 +883,16 @@ static int usbhsg_get_frame(struct usb_gadget *gadget) | |||
883 | return usbhs_frame_get_num(priv); | 883 | return usbhs_frame_get_num(priv); |
884 | } | 884 | } |
885 | 885 | ||
886 | static int usbhsg_pullup(struct usb_gadget *gadget, int is_on) | ||
887 | { | ||
888 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | ||
889 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); | ||
890 | |||
891 | usbhs_sys_function_pullup(priv, is_on); | ||
892 | |||
893 | return 0; | ||
894 | } | ||
895 | |||
886 | static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) | 896 | static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) |
887 | { | 897 | { |
888 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | 898 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); |
@@ -900,6 +910,7 @@ static struct usb_gadget_ops usbhsg_gadget_ops = { | |||
900 | .set_selfpowered = usbhsg_set_selfpowered, | 910 | .set_selfpowered = usbhsg_set_selfpowered, |
901 | .udc_start = usbhsg_gadget_start, | 911 | .udc_start = usbhsg_gadget_start, |
902 | .udc_stop = usbhsg_gadget_stop, | 912 | .udc_stop = usbhsg_gadget_stop, |
913 | .pullup = usbhsg_pullup, | ||
903 | }; | 914 | }; |
904 | 915 | ||
905 | static int usbhsg_start(struct usbhs_priv *priv) | 916 | static int usbhsg_start(struct usbhs_priv *priv) |
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 069cd765400c..3d3cd6ca2689 100644 --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c | |||
@@ -85,6 +85,7 @@ struct usbhsh_ep { | |||
85 | struct usbhsh_device *udev; /* attached udev */ | 85 | struct usbhsh_device *udev; /* attached udev */ |
86 | struct usb_host_endpoint *ep; | 86 | struct usb_host_endpoint *ep; |
87 | struct list_head ep_list; /* list to usbhsh_device */ | 87 | struct list_head ep_list; /* list to usbhsh_device */ |
88 | unsigned int counter; /* pipe attach counter */ | ||
88 | }; | 89 | }; |
89 | 90 | ||
90 | #define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */ | 91 | #define USBHSH_DEVICE_MAX 10 /* see DEVADDn / DCPMAXP / PIPEMAXP */ |
@@ -271,8 +272,12 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv, | |||
271 | /******************** spin lock ********************/ | 272 | /******************** spin lock ********************/ |
272 | usbhs_lock(priv, flags); | 273 | usbhs_lock(priv, flags); |
273 | 274 | ||
274 | if (unlikely(usbhsh_uep_to_pipe(uep))) { | 275 | /* |
275 | dev_err(dev, "uep already has pipe\n"); | 276 | * if uep has been attached to pipe, |
277 | * reuse it | ||
278 | */ | ||
279 | if (usbhsh_uep_to_pipe(uep)) { | ||
280 | ret = 0; | ||
276 | goto usbhsh_pipe_attach_done; | 281 | goto usbhsh_pipe_attach_done; |
277 | } | 282 | } |
278 | 283 | ||
@@ -320,6 +325,9 @@ static int usbhsh_pipe_attach(struct usbhsh_hpriv *hpriv, | |||
320 | } | 325 | } |
321 | 326 | ||
322 | usbhsh_pipe_attach_done: | 327 | usbhsh_pipe_attach_done: |
328 | if (0 == ret) | ||
329 | uep->counter++; | ||
330 | |||
323 | usbhs_unlock(priv, flags); | 331 | usbhs_unlock(priv, flags); |
324 | /******************** spin unlock ******************/ | 332 | /******************** spin unlock ******************/ |
325 | 333 | ||
@@ -346,7 +354,7 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv, | |||
346 | 354 | ||
347 | if (unlikely(!pipe)) { | 355 | if (unlikely(!pipe)) { |
348 | dev_err(dev, "uep doens't have pipe\n"); | 356 | dev_err(dev, "uep doens't have pipe\n"); |
349 | } else { | 357 | } else if (1 == uep->counter--) { /* last user */ |
350 | struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); | 358 | struct usb_host_endpoint *ep = usbhsh_uep_to_ep(uep); |
351 | struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); | 359 | struct usbhsh_device *udev = usbhsh_uep_to_udev(uep); |
352 | 360 | ||
@@ -391,6 +399,7 @@ static int usbhsh_endpoint_attach(struct usbhsh_hpriv *hpriv, | |||
391 | /* | 399 | /* |
392 | * init endpoint | 400 | * init endpoint |
393 | */ | 401 | */ |
402 | uep->counter = 0; | ||
394 | INIT_LIST_HEAD(&uep->ep_list); | 403 | INIT_LIST_HEAD(&uep->ep_list); |
395 | list_add_tail(&uep->ep_list, &udev->ep_list_head); | 404 | list_add_tail(&uep->ep_list, &udev->ep_list_head); |
396 | 405 | ||
@@ -686,9 +695,9 @@ static int usbhsh_queue_push(struct usb_hcd *hcd, | |||
686 | } | 695 | } |
687 | 696 | ||
688 | if (usb_pipein(urb->pipe)) | 697 | if (usb_pipein(urb->pipe)) |
689 | pipe->handler = &usbhs_fifo_pio_pop_handler; | 698 | pipe->handler = &usbhs_fifo_dma_pop_handler; |
690 | else | 699 | else |
691 | pipe->handler = &usbhs_fifo_pio_push_handler; | 700 | pipe->handler = &usbhs_fifo_dma_push_handler; |
692 | 701 | ||
693 | buf = (void *)(urb->transfer_buffer + urb->actual_length); | 702 | buf = (void *)(urb->transfer_buffer + urb->actual_length); |
694 | len = urb->transfer_buffer_length - urb->actual_length; | 703 | len = urb->transfer_buffer_length - urb->actual_length; |
@@ -921,6 +930,19 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, | |||
921 | */ | 930 | */ |
922 | static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | 931 | static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) |
923 | { | 932 | { |
933 | if (map) { | ||
934 | struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); | ||
935 | struct urb *urb = ureq->urb; | ||
936 | |||
937 | /* it can not use scatter/gather */ | ||
938 | if (urb->num_sgs) | ||
939 | return -EINVAL; | ||
940 | |||
941 | pkt->dma = urb->transfer_dma; | ||
942 | if (!pkt->dma) | ||
943 | return -EINVAL; | ||
944 | } | ||
945 | |||
924 | return 0; | 946 | return 0; |
925 | } | 947 | } |
926 | 948 | ||
@@ -946,7 +968,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, | |||
946 | struct usb_host_endpoint *ep = urb->ep; | 968 | struct usb_host_endpoint *ep = urb->ep; |
947 | struct usbhsh_device *new_udev = NULL; | 969 | struct usbhsh_device *new_udev = NULL; |
948 | int is_dir_in = usb_pipein(urb->pipe); | 970 | int is_dir_in = usb_pipein(urb->pipe); |
949 | int i; | ||
950 | int ret; | 971 | int ret; |
951 | 972 | ||
952 | dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); | 973 | dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); |
@@ -992,13 +1013,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, | |||
992 | * attach pipe to endpoint | 1013 | * attach pipe to endpoint |
993 | * see [image of mod_host] | 1014 | * see [image of mod_host] |
994 | */ | 1015 | */ |
995 | for (i = 0; i < 1024; i++) { | 1016 | ret = usbhsh_pipe_attach(hpriv, urb); |
996 | ret = usbhsh_pipe_attach(hpriv, urb); | ||
997 | if (ret < 0) | ||
998 | msleep(100); | ||
999 | else | ||
1000 | break; | ||
1001 | } | ||
1002 | if (ret < 0) { | 1017 | if (ret < 0) { |
1003 | dev_err(dev, "pipe attach failed\n"); | 1018 | dev_err(dev, "pipe attach failed\n"); |
1004 | goto usbhsh_urb_enqueue_error_free_endpoint; | 1019 | goto usbhsh_urb_enqueue_error_free_endpoint; |
@@ -1072,8 +1087,6 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd, | |||
1072 | static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) | 1087 | static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) |
1073 | { | 1088 | { |
1074 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); | 1089 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); |
1075 | struct usbhs_priv *priv = usbhsh_hpriv_to_priv(hpriv); | ||
1076 | struct device *dev = usbhs_priv_to_dev(priv); | ||
1077 | int roothub_id = 1; /* only 1 root hub */ | 1090 | int roothub_id = 1; /* only 1 root hub */ |
1078 | 1091 | ||
1079 | /* | 1092 | /* |
@@ -1085,8 +1098,6 @@ static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
1085 | else | 1098 | else |
1086 | *buf = 0; | 1099 | *buf = 0; |
1087 | 1100 | ||
1088 | dev_dbg(dev, "%s (%02x)\n", __func__, *buf); | ||
1089 | |||
1090 | return !!(*buf); | 1101 | return !!(*buf); |
1091 | } | 1102 | } |
1092 | 1103 | ||
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 122526cfd32b..7926e1c700f1 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c | |||
@@ -93,6 +93,82 @@ static void usbhsp_pipe_cfg_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | /* | 95 | /* |
96 | * PIPEnTRN/PIPEnTRE functions | ||
97 | */ | ||
98 | static void usbhsp_pipe_trn_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | ||
99 | { | ||
100 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | ||
101 | struct device *dev = usbhs_priv_to_dev(priv); | ||
102 | int num = usbhs_pipe_number(pipe); | ||
103 | u16 reg; | ||
104 | |||
105 | /* | ||
106 | * It is impossible to calculate address, | ||
107 | * since PIPEnTRN addresses were mapped randomly. | ||
108 | */ | ||
109 | #define CASE_PIPExTRN(a) \ | ||
110 | case 0x ## a: \ | ||
111 | reg = PIPE ## a ## TRN; \ | ||
112 | break; | ||
113 | |||
114 | switch (num) { | ||
115 | CASE_PIPExTRN(1); | ||
116 | CASE_PIPExTRN(2); | ||
117 | CASE_PIPExTRN(3); | ||
118 | CASE_PIPExTRN(4); | ||
119 | CASE_PIPExTRN(5); | ||
120 | CASE_PIPExTRN(B); | ||
121 | CASE_PIPExTRN(C); | ||
122 | CASE_PIPExTRN(D); | ||
123 | CASE_PIPExTRN(E); | ||
124 | CASE_PIPExTRN(F); | ||
125 | CASE_PIPExTRN(9); | ||
126 | CASE_PIPExTRN(A); | ||
127 | default: | ||
128 | dev_err(dev, "unknown pipe (%d)\n", num); | ||
129 | return; | ||
130 | } | ||
131 | __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); | ||
132 | } | ||
133 | |||
134 | static void usbhsp_pipe_tre_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | ||
135 | { | ||
136 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | ||
137 | struct device *dev = usbhs_priv_to_dev(priv); | ||
138 | int num = usbhs_pipe_number(pipe); | ||
139 | u16 reg; | ||
140 | |||
141 | /* | ||
142 | * It is impossible to calculate address, | ||
143 | * since PIPEnTRE addresses were mapped randomly. | ||
144 | */ | ||
145 | #define CASE_PIPExTRE(a) \ | ||
146 | case 0x ## a: \ | ||
147 | reg = PIPE ## a ## TRE; \ | ||
148 | break; | ||
149 | |||
150 | switch (num) { | ||
151 | CASE_PIPExTRE(1); | ||
152 | CASE_PIPExTRE(2); | ||
153 | CASE_PIPExTRE(3); | ||
154 | CASE_PIPExTRE(4); | ||
155 | CASE_PIPExTRE(5); | ||
156 | CASE_PIPExTRE(B); | ||
157 | CASE_PIPExTRE(C); | ||
158 | CASE_PIPExTRE(D); | ||
159 | CASE_PIPExTRE(E); | ||
160 | CASE_PIPExTRE(F); | ||
161 | CASE_PIPExTRE(9); | ||
162 | CASE_PIPExTRE(A); | ||
163 | default: | ||
164 | dev_err(dev, "unknown pipe (%d)\n", num); | ||
165 | return; | ||
166 | } | ||
167 | |||
168 | __usbhsp_pipe_xxx_set(pipe, 0, reg, mask, val); | ||
169 | } | ||
170 | |||
171 | /* | ||
96 | * PIPEBUF | 172 | * PIPEBUF |
97 | */ | 173 | */ |
98 | static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val) | 174 | static void usbhsp_pipe_buf_set(struct usbhs_pipe *pipe, u16 mask, u16 val) |
@@ -264,6 +340,31 @@ int usbhs_pipe_is_stall(struct usbhs_pipe *pipe) | |||
264 | return (int)(pid == PID_STALL10 || pid == PID_STALL11); | 340 | return (int)(pid == PID_STALL10 || pid == PID_STALL11); |
265 | } | 341 | } |
266 | 342 | ||
343 | void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len) | ||
344 | { | ||
345 | if (!usbhs_pipe_type_is(pipe, USB_ENDPOINT_XFER_BULK)) | ||
346 | return; | ||
347 | |||
348 | /* | ||
349 | * clear and disable transfer counter for IN/OUT pipe | ||
350 | */ | ||
351 | usbhsp_pipe_tre_set(pipe, TRCLR | TRENB, TRCLR); | ||
352 | |||
353 | /* | ||
354 | * Only IN direction bulk pipe can use transfer count. | ||
355 | * Without using this function, | ||
356 | * received data will break if it was large data size. | ||
357 | * see PIPEnTRN/PIPEnTRE for detail | ||
358 | */ | ||
359 | if (usbhs_pipe_is_dir_in(pipe)) { | ||
360 | int maxp = usbhs_pipe_get_maxpacket(pipe); | ||
361 | |||
362 | usbhsp_pipe_trn_set(pipe, 0xffff, DIV_ROUND_UP(len, maxp)); | ||
363 | usbhsp_pipe_tre_set(pipe, TRENB, TRENB); /* enable */ | ||
364 | } | ||
365 | } | ||
366 | |||
367 | |||
267 | /* | 368 | /* |
268 | * pipe setup | 369 | * pipe setup |
269 | */ | 370 | */ |
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h index 3d80c7b1fd1b..b476fde955bf 100644 --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h | |||
@@ -88,6 +88,7 @@ void usbhs_pipe_enable(struct usbhs_pipe *pipe); | |||
88 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); | 88 | void usbhs_pipe_disable(struct usbhs_pipe *pipe); |
89 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); | 89 | void usbhs_pipe_stall(struct usbhs_pipe *pipe); |
90 | int usbhs_pipe_is_stall(struct usbhs_pipe *pipe); | 90 | int usbhs_pipe_is_stall(struct usbhs_pipe *pipe); |
91 | void usbhs_pipe_set_trans_count_if_bulk(struct usbhs_pipe *pipe, int len); | ||
91 | void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); | 92 | void usbhs_pipe_select_fifo(struct usbhs_pipe *pipe, struct usbhs_fifo *fifo); |
92 | void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, | 93 | void usbhs_pipe_config_update(struct usbhs_pipe *pipe, u16 devsel, |
93 | u16 epnum, u16 maxp); | 94 | u16 epnum, u16 maxp); |
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 54e1bb6372e7..6d110a3bc7e7 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -68,10 +68,6 @@ | |||
68 | #define THROTTLED 0x01 | 68 | #define THROTTLED 0x01 |
69 | #define ACTUALLY_THROTTLED 0x02 | 69 | #define ACTUALLY_THROTTLED 0x02 |
70 | 70 | ||
71 | /* | ||
72 | * Version Information | ||
73 | */ | ||
74 | #define DRIVER_VERSION "v2.0" | ||
75 | #define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>, Johan Hovold <jhovold@gmail.com>" | 71 | #define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>, Johan Hovold <jhovold@gmail.com>" |
76 | #define DRIVER_DESC "AIRcable USB Driver" | 72 | #define DRIVER_DESC "AIRcable USB Driver" |
77 | 73 | ||
@@ -192,5 +188,4 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
192 | 188 | ||
193 | MODULE_AUTHOR(DRIVER_AUTHOR); | 189 | MODULE_AUTHOR(DRIVER_AUTHOR); |
194 | MODULE_DESCRIPTION(DRIVER_DESC); | 190 | MODULE_DESCRIPTION(DRIVER_DESC); |
195 | MODULE_VERSION(DRIVER_VERSION); | ||
196 | MODULE_LICENSE("GPL"); | 191 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index bd50a8a41a0f..a88882c0e237 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -37,11 +37,6 @@ | |||
37 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | 39 | ||
40 | /* | ||
41 | * Version information | ||
42 | */ | ||
43 | |||
44 | #define DRIVER_VERSION "v0.7" | ||
45 | #define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" | 40 | #define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" |
46 | #define DRIVER_DESC "USB ARK3116 serial/IrDA driver" | 41 | #define DRIVER_DESC "USB ARK3116 serial/IrDA driver" |
47 | #define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" | 42 | #define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index ea29556f0d72..b72a4c166705 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -37,10 +37,6 @@ | |||
37 | #include <linux/usb/serial.h> | 37 | #include <linux/usb/serial.h> |
38 | #include "belkin_sa.h" | 38 | #include "belkin_sa.h" |
39 | 39 | ||
40 | /* | ||
41 | * Version Information | ||
42 | */ | ||
43 | #define DRIVER_VERSION "v1.3" | ||
44 | #define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>" | 40 | #define DRIVER_AUTHOR "William Greathouse <wgreathouse@smva.com>" |
45 | #define DRIVER_DESC "USB Belkin Serial converter driver" | 41 | #define DRIVER_DESC "USB Belkin Serial converter driver" |
46 | 42 | ||
@@ -509,5 +505,4 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
509 | 505 | ||
510 | MODULE_AUTHOR(DRIVER_AUTHOR); | 506 | MODULE_AUTHOR(DRIVER_AUTHOR); |
511 | MODULE_DESCRIPTION(DRIVER_DESC); | 507 | MODULE_DESCRIPTION(DRIVER_DESC); |
512 | MODULE_VERSION(DRIVER_VERSION); | ||
513 | MODULE_LICENSE("GPL"); | 508 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index eb033fc92a15..2858d8a9eac8 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -24,10 +24,6 @@ | |||
24 | #include <linux/uaccess.h> | 24 | #include <linux/uaccess.h> |
25 | #include <linux/usb/serial.h> | 25 | #include <linux/usb/serial.h> |
26 | 26 | ||
27 | /* | ||
28 | * Version Information | ||
29 | */ | ||
30 | #define DRIVER_VERSION "v0.09" | ||
31 | #define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver" | 27 | #define DRIVER_DESC "Silicon Labs CP210x RS232 serial adaptor driver" |
32 | 28 | ||
33 | /* | 29 | /* |
@@ -35,8 +31,7 @@ | |||
35 | */ | 31 | */ |
36 | static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *); | 32 | static int cp210x_open(struct tty_struct *tty, struct usb_serial_port *); |
37 | static void cp210x_close(struct usb_serial_port *); | 33 | static void cp210x_close(struct usb_serial_port *); |
38 | static void cp210x_get_termios(struct tty_struct *, | 34 | static void cp210x_get_termios(struct tty_struct *, struct usb_serial_port *); |
39 | struct usb_serial_port *port); | ||
40 | static void cp210x_get_termios_port(struct usb_serial_port *port, | 35 | static void cp210x_get_termios_port(struct usb_serial_port *port, |
41 | unsigned int *cflagp, unsigned int *baudp); | 36 | unsigned int *cflagp, unsigned int *baudp); |
42 | static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, | 37 | static void cp210x_change_speed(struct tty_struct *, struct usb_serial_port *, |
@@ -169,7 +164,7 @@ struct cp210x_serial_private { | |||
169 | static struct usb_serial_driver cp210x_device = { | 164 | static struct usb_serial_driver cp210x_device = { |
170 | .driver = { | 165 | .driver = { |
171 | .owner = THIS_MODULE, | 166 | .owner = THIS_MODULE, |
172 | .name = "cp210x", | 167 | .name = "cp210x", |
173 | }, | 168 | }, |
174 | .id_table = id_table, | 169 | .id_table = id_table, |
175 | .num_ports = 1, | 170 | .num_ports = 1, |
@@ -179,7 +174,7 @@ static struct usb_serial_driver cp210x_device = { | |||
179 | .close = cp210x_close, | 174 | .close = cp210x_close, |
180 | .break_ctl = cp210x_break_ctl, | 175 | .break_ctl = cp210x_break_ctl, |
181 | .set_termios = cp210x_set_termios, | 176 | .set_termios = cp210x_set_termios, |
182 | .tiocmget = cp210x_tiocmget, | 177 | .tiocmget = cp210x_tiocmget, |
183 | .tiocmset = cp210x_tiocmset, | 178 | .tiocmset = cp210x_tiocmset, |
184 | .attach = cp210x_startup, | 179 | .attach = cp210x_startup, |
185 | .release = cp210x_release, | 180 | .release = cp210x_release, |
@@ -281,7 +276,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
281 | int result, i, length; | 276 | int result, i, length; |
282 | 277 | ||
283 | /* Number of integers required to contain the array */ | 278 | /* Number of integers required to contain the array */ |
284 | length = (((size - 1) | 3) + 1)/4; | 279 | length = (((size - 1) | 3) + 1) / 4; |
285 | 280 | ||
286 | buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); | 281 | buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); |
287 | if (!buf) { | 282 | if (!buf) { |
@@ -328,12 +323,11 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
328 | int result, i, length; | 323 | int result, i, length; |
329 | 324 | ||
330 | /* Number of integers required to contain the array */ | 325 | /* Number of integers required to contain the array */ |
331 | length = (((size - 1) | 3) + 1)/4; | 326 | length = (((size - 1) | 3) + 1) / 4; |
332 | 327 | ||
333 | buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); | 328 | buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); |
334 | if (!buf) { | 329 | if (!buf) { |
335 | dev_err(&port->dev, "%s - out of memory.\n", | 330 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
336 | __func__); | ||
337 | return -ENOMEM; | 331 | return -ENOMEM; |
338 | } | 332 | } |
339 | 333 | ||
@@ -384,7 +378,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port, | |||
384 | * cp210x_quantise_baudrate | 378 | * cp210x_quantise_baudrate |
385 | * Quantises the baud rate as per AN205 Table 1 | 379 | * Quantises the baud rate as per AN205 Table 1 |
386 | */ | 380 | */ |
387 | static unsigned int cp210x_quantise_baudrate(unsigned int baud) { | 381 | static unsigned int cp210x_quantise_baudrate(unsigned int baud) |
382 | { | ||
388 | if (baud <= 300) | 383 | if (baud <= 300) |
389 | baud = 300; | 384 | baud = 300; |
390 | else if (baud <= 600) baud = 600; | 385 | else if (baud <= 600) baud = 600; |
@@ -467,9 +462,7 @@ static void cp210x_get_termios(struct tty_struct *tty, | |||
467 | cp210x_get_termios_port(tty->driver_data, | 462 | cp210x_get_termios_port(tty->driver_data, |
468 | &tty->termios.c_cflag, &baud); | 463 | &tty->termios.c_cflag, &baud); |
469 | tty_encode_baud_rate(tty, baud, baud); | 464 | tty_encode_baud_rate(tty, baud, baud); |
470 | } | 465 | } else { |
471 | |||
472 | else { | ||
473 | unsigned int cflag; | 466 | unsigned int cflag; |
474 | cflag = 0; | 467 | cflag = 0; |
475 | cp210x_get_termios_port(port, &cflag, &baud); | 468 | cp210x_get_termios_port(port, &cflag, &baud); |
@@ -693,8 +686,8 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
693 | break;*/ | 686 | break;*/ |
694 | default: | 687 | default: |
695 | dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); | 688 | dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); |
696 | bits |= BITS_DATA_8; | 689 | bits |= BITS_DATA_8; |
697 | break; | 690 | break; |
698 | } | 691 | } |
699 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 692 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
700 | dev_dbg(dev, "Number of data bits requested not supported by device\n"); | 693 | dev_dbg(dev, "Number of data bits requested not supported by device\n"); |
@@ -767,7 +760,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
767 | 760 | ||
768 | } | 761 | } |
769 | 762 | ||
770 | static int cp210x_tiocmset (struct tty_struct *tty, | 763 | static int cp210x_tiocmset(struct tty_struct *tty, |
771 | unsigned int set, unsigned int clear) | 764 | unsigned int set, unsigned int clear) |
772 | { | 765 | { |
773 | struct usb_serial_port *port = tty->driver_data; | 766 | struct usb_serial_port *port = tty->driver_data; |
@@ -809,7 +802,7 @@ static void cp210x_dtr_rts(struct usb_serial_port *p, int on) | |||
809 | cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS); | 802 | cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS); |
810 | } | 803 | } |
811 | 804 | ||
812 | static int cp210x_tiocmget (struct tty_struct *tty) | 805 | static int cp210x_tiocmget(struct tty_struct *tty) |
813 | { | 806 | { |
814 | struct usb_serial_port *port = tty->driver_data; | 807 | struct usb_serial_port *port = tty->driver_data; |
815 | unsigned int control; | 808 | unsigned int control; |
@@ -829,7 +822,7 @@ static int cp210x_tiocmget (struct tty_struct *tty) | |||
829 | return result; | 822 | return result; |
830 | } | 823 | } |
831 | 824 | ||
832 | static void cp210x_break_ctl (struct tty_struct *tty, int break_state) | 825 | static void cp210x_break_ctl(struct tty_struct *tty, int break_state) |
833 | { | 826 | { |
834 | struct usb_serial_port *port = tty->driver_data; | 827 | struct usb_serial_port *port = tty->driver_data; |
835 | unsigned int state; | 828 | unsigned int state; |
@@ -874,5 +867,4 @@ static void cp210x_release(struct usb_serial *serial) | |||
874 | module_usb_serial_driver(serial_drivers, id_table); | 867 | module_usb_serial_driver(serial_drivers, id_table); |
875 | 868 | ||
876 | MODULE_DESCRIPTION(DRIVER_DESC); | 869 | MODULE_DESCRIPTION(DRIVER_DESC); |
877 | MODULE_VERSION(DRIVER_VERSION); | ||
878 | MODULE_LICENSE("GPL"); | 870 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 4ee77dcbe690..69a4fa1cee25 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -43,10 +43,6 @@ | |||
43 | 43 | ||
44 | #define CYBERJACK_LOCAL_BUF_SIZE 32 | 44 | #define CYBERJACK_LOCAL_BUF_SIZE 32 |
45 | 45 | ||
46 | /* | ||
47 | * Version Information | ||
48 | */ | ||
49 | #define DRIVER_VERSION "v1.01" | ||
50 | #define DRIVER_AUTHOR "Matthias Bruestle" | 46 | #define DRIVER_AUTHOR "Matthias Bruestle" |
51 | #define DRIVER_DESC "REINER SCT cyberJack pinpad/e-com USB Chipcard Reader Driver" | 47 | #define DRIVER_DESC "REINER SCT cyberJack pinpad/e-com USB Chipcard Reader Driver" |
52 | 48 | ||
@@ -441,5 +437,4 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
441 | 437 | ||
442 | MODULE_AUTHOR(DRIVER_AUTHOR); | 438 | MODULE_AUTHOR(DRIVER_AUTHOR); |
443 | MODULE_DESCRIPTION(DRIVER_DESC); | 439 | MODULE_DESCRIPTION(DRIVER_DESC); |
444 | MODULE_VERSION(DRIVER_VERSION); | ||
445 | MODULE_LICENSE("GPL"); | 440 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index f0da1279c114..fd8c35fd452e 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -50,10 +50,6 @@ static bool stats; | |||
50 | static int interval; | 50 | static int interval; |
51 | static bool unstable_bauds; | 51 | static bool unstable_bauds; |
52 | 52 | ||
53 | /* | ||
54 | * Version Information | ||
55 | */ | ||
56 | #define DRIVER_VERSION "v1.10" | ||
57 | #define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>" | 53 | #define DRIVER_AUTHOR "Lonnie Mendez <dignome@gmail.com>, Neil Whelchel <koyama@firstlight.net>" |
58 | #define DRIVER_DESC "Cypress USB to Serial Driver" | 54 | #define DRIVER_DESC "Cypress USB to Serial Driver" |
59 | 55 | ||
@@ -1303,7 +1299,6 @@ module_usb_serial_driver(serial_drivers, id_table_combined); | |||
1303 | 1299 | ||
1304 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1300 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1305 | MODULE_DESCRIPTION(DRIVER_DESC); | 1301 | MODULE_DESCRIPTION(DRIVER_DESC); |
1306 | MODULE_VERSION(DRIVER_VERSION); | ||
1307 | MODULE_LICENSE("GPL"); | 1302 | MODULE_LICENSE("GPL"); |
1308 | 1303 | ||
1309 | module_param(stats, bool, S_IRUGO | S_IWUSR); | 1304 | module_param(stats, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index b50fa1c6d885..45d4af62967f 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -32,10 +32,6 @@ | |||
32 | 32 | ||
33 | /* Defines */ | 33 | /* Defines */ |
34 | 34 | ||
35 | /* | ||
36 | * Version Information | ||
37 | */ | ||
38 | #define DRIVER_VERSION "v1.80.1.2" | ||
39 | #define DRIVER_AUTHOR "Peter Berger <pberger@brimson.com>, Al Borchers <borchers@steinerpoint.com>" | 35 | #define DRIVER_AUTHOR "Peter Berger <pberger@brimson.com>, Al Borchers <borchers@steinerpoint.com>" |
40 | #define DRIVER_DESC "Digi AccelePort USB-2/USB-4 Serial Converter driver" | 36 | #define DRIVER_DESC "Digi AccelePort USB-2/USB-4 Serial Converter driver" |
41 | 37 | ||
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index 43ede4a1e12c..0f658618db13 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -28,10 +28,6 @@ | |||
28 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
29 | #include <linux/usb/serial.h> | 29 | #include <linux/usb/serial.h> |
30 | 30 | ||
31 | /* | ||
32 | * Version Information | ||
33 | */ | ||
34 | #define DRIVER_VERSION "v1.3" | ||
35 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>" | 31 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Gary Brubaker <xavyer@ix.netcom.com>" |
36 | #define DRIVER_DESC "USB Empeg Mark I/II Driver" | 32 | #define DRIVER_DESC "USB Empeg Mark I/II Driver" |
37 | 33 | ||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index be845873e23d..8c3379b52f24 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -73,7 +73,6 @@ struct ftdi_private { | |||
73 | char prev_status; /* Used for TIOCMIWAIT */ | 73 | char prev_status; /* Used for TIOCMIWAIT */ |
74 | bool dev_gone; /* Used to abort TIOCMIWAIT */ | 74 | bool dev_gone; /* Used to abort TIOCMIWAIT */ |
75 | char transmit_empty; /* If transmitter is empty or not */ | 75 | char transmit_empty; /* If transmitter is empty or not */ |
76 | struct usb_serial_port *port; | ||
77 | __u16 interface; /* FT2232C, FT2232H or FT4232H port interface | 76 | __u16 interface; /* FT2232C, FT2232H or FT4232H port interface |
78 | (0 for FT232/245) */ | 77 | (0 for FT232/245) */ |
79 | 78 | ||
@@ -923,6 +922,9 @@ static int ftdi_get_icount(struct tty_struct *tty, | |||
923 | static int ftdi_ioctl(struct tty_struct *tty, | 922 | static int ftdi_ioctl(struct tty_struct *tty, |
924 | unsigned int cmd, unsigned long arg); | 923 | unsigned int cmd, unsigned long arg); |
925 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state); | 924 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state); |
925 | static int ftdi_chars_in_buffer(struct tty_struct *tty); | ||
926 | static int ftdi_get_modem_status(struct tty_struct *tty, | ||
927 | unsigned char status[2]); | ||
926 | 928 | ||
927 | static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); | 929 | static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); |
928 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); | 930 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); |
@@ -957,6 +959,7 @@ static struct usb_serial_driver ftdi_sio_device = { | |||
957 | .ioctl = ftdi_ioctl, | 959 | .ioctl = ftdi_ioctl, |
958 | .set_termios = ftdi_set_termios, | 960 | .set_termios = ftdi_set_termios, |
959 | .break_ctl = ftdi_break_ctl, | 961 | .break_ctl = ftdi_break_ctl, |
962 | .chars_in_buffer = ftdi_chars_in_buffer, | ||
960 | }; | 963 | }; |
961 | 964 | ||
962 | static struct usb_serial_driver * const serial_drivers[] = { | 965 | static struct usb_serial_driver * const serial_drivers[] = { |
@@ -1090,6 +1093,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, | |||
1090 | __func__, | 1093 | __func__, |
1091 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 1094 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
1092 | (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); | 1095 | (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); |
1096 | rv = usb_translate_errors(rv); | ||
1093 | } else { | 1097 | } else { |
1094 | dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, | 1098 | dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, |
1095 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 1099 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
@@ -1682,7 +1686,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
1682 | 1686 | ||
1683 | kref_init(&priv->kref); | 1687 | kref_init(&priv->kref); |
1684 | mutex_init(&priv->cfg_lock); | 1688 | mutex_init(&priv->cfg_lock); |
1685 | memset(&priv->icount, 0x00, sizeof(priv->icount)); | ||
1686 | init_waitqueue_head(&priv->delta_msr_wait); | 1689 | init_waitqueue_head(&priv->delta_msr_wait); |
1687 | 1690 | ||
1688 | priv->flags = ASYNC_LOW_LATENCY; | 1691 | priv->flags = ASYNC_LOW_LATENCY; |
@@ -1691,7 +1694,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
1691 | if (quirk && quirk->port_probe) | 1694 | if (quirk && quirk->port_probe) |
1692 | quirk->port_probe(priv); | 1695 | quirk->port_probe(priv); |
1693 | 1696 | ||
1694 | priv->port = port; | ||
1695 | usb_set_serial_port_data(port, priv); | 1697 | usb_set_serial_port_data(port, priv); |
1696 | 1698 | ||
1697 | ftdi_determine_type(port); | 1699 | ftdi_determine_type(port); |
@@ -2089,6 +2091,29 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | |||
2089 | 2091 | ||
2090 | } | 2092 | } |
2091 | 2093 | ||
2094 | static int ftdi_chars_in_buffer(struct tty_struct *tty) | ||
2095 | { | ||
2096 | struct usb_serial_port *port = tty->driver_data; | ||
2097 | int chars; | ||
2098 | unsigned char buf[2]; | ||
2099 | int ret; | ||
2100 | |||
2101 | chars = usb_serial_generic_chars_in_buffer(tty); | ||
2102 | if (chars) | ||
2103 | goto out; | ||
2104 | |||
2105 | /* Check if hardware buffer is empty. */ | ||
2106 | ret = ftdi_get_modem_status(tty, buf); | ||
2107 | if (ret == 2) { | ||
2108 | if (!(buf[1] & FTDI_RS_TEMT)) | ||
2109 | chars = 1; | ||
2110 | } | ||
2111 | out: | ||
2112 | dev_dbg(&port->dev, "%s - %d\n", __func__, chars); | ||
2113 | |||
2114 | return chars; | ||
2115 | } | ||
2116 | |||
2092 | /* old_termios contains the original termios settings and tty->termios contains | 2117 | /* old_termios contains the original termios settings and tty->termios contains |
2093 | * the new setting to be used | 2118 | * the new setting to be used |
2094 | * WARNING: set_termios calls this with old_termios in kernel space | 2119 | * WARNING: set_termios calls this with old_termios in kernel space |
@@ -2272,7 +2297,14 @@ no_c_cflag_changes: | |||
2272 | } | 2297 | } |
2273 | } | 2298 | } |
2274 | 2299 | ||
2275 | static int ftdi_tiocmget(struct tty_struct *tty) | 2300 | /* |
2301 | * Get modem-control status. | ||
2302 | * | ||
2303 | * Returns the number of status bytes retrieved (device dependant), or | ||
2304 | * negative error code. | ||
2305 | */ | ||
2306 | static int ftdi_get_modem_status(struct tty_struct *tty, | ||
2307 | unsigned char status[2]) | ||
2276 | { | 2308 | { |
2277 | struct usb_serial_port *port = tty->driver_data; | 2309 | struct usb_serial_port *port = tty->driver_data; |
2278 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2310 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
@@ -2312,16 +2344,43 @@ static int ftdi_tiocmget(struct tty_struct *tty) | |||
2312 | FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, | 2344 | FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, |
2313 | 0, priv->interface, | 2345 | 0, priv->interface, |
2314 | buf, len, WDR_TIMEOUT); | 2346 | buf, len, WDR_TIMEOUT); |
2315 | if (ret < 0) | 2347 | if (ret < 0) { |
2348 | dev_err(&port->dev, "failed to get modem status: %d\n", ret); | ||
2349 | ret = usb_translate_errors(ret); | ||
2316 | goto out; | 2350 | goto out; |
2351 | } | ||
2317 | 2352 | ||
2318 | ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | | 2353 | status[0] = buf[0]; |
2319 | (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | | 2354 | if (ret > 1) |
2320 | (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | | 2355 | status[1] = buf[1]; |
2321 | (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | | 2356 | else |
2322 | priv->last_dtr_rts; | 2357 | status[1] = 0; |
2358 | |||
2359 | dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0], | ||
2360 | status[1]); | ||
2323 | out: | 2361 | out: |
2324 | kfree(buf); | 2362 | kfree(buf); |
2363 | |||
2364 | return ret; | ||
2365 | } | ||
2366 | |||
2367 | static int ftdi_tiocmget(struct tty_struct *tty) | ||
2368 | { | ||
2369 | struct usb_serial_port *port = tty->driver_data; | ||
2370 | struct ftdi_private *priv = usb_get_serial_port_data(port); | ||
2371 | unsigned char buf[2]; | ||
2372 | int ret; | ||
2373 | |||
2374 | ret = ftdi_get_modem_status(tty, buf); | ||
2375 | if (ret < 0) | ||
2376 | return ret; | ||
2377 | |||
2378 | ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | | ||
2379 | (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | | ||
2380 | (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | | ||
2381 | (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | | ||
2382 | priv->last_dtr_rts; | ||
2383 | |||
2325 | return ret; | 2384 | return ret; |
2326 | } | 2385 | } |
2327 | 2386 | ||
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index 296612153ea2..2ea70a631996 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -262,6 +262,7 @@ int usb_serial_generic_chars_in_buffer(struct tty_struct *tty) | |||
262 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); | 262 | dev_dbg(&port->dev, "%s - returns %d\n", __func__, chars); |
263 | return chars; | 263 | return chars; |
264 | } | 264 | } |
265 | EXPORT_SYMBOL_GPL(usb_serial_generic_chars_in_buffer); | ||
265 | 266 | ||
266 | static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, | 267 | static int usb_serial_generic_submit_read_urb(struct usb_serial_port *port, |
267 | int index, gfp_t mem_flags) | 268 | int index, gfp_t mem_flags) |
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index 0bbaf21a9d1e..2cba60d90c79 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c | |||
@@ -20,10 +20,6 @@ | |||
20 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
21 | #include <linux/usb/serial.h> | 21 | #include <linux/usb/serial.h> |
22 | 22 | ||
23 | /* | ||
24 | * Version Information | ||
25 | */ | ||
26 | #define DRIVER_VERSION "v1.00" | ||
27 | #define DRIVER_DESC "HP4x (48/49) Generic Serial driver" | 23 | #define DRIVER_DESC "HP4x (48/49) Generic Serial driver" |
28 | 24 | ||
29 | #define HP_VENDOR_ID 0x03f0 | 25 | #define HP_VENDOR_ID 0x03f0 |
@@ -52,5 +48,4 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
52 | module_usb_serial_driver(serial_drivers, id_table); | 48 | module_usb_serial_driver(serial_drivers, id_table); |
53 | 49 | ||
54 | MODULE_DESCRIPTION(DRIVER_DESC); | 50 | MODULE_DESCRIPTION(DRIVER_DESC); |
55 | MODULE_VERSION(DRIVER_VERSION); | ||
56 | MODULE_LICENSE("GPL"); | 51 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 5acc0d13864a..7b770c7f8b11 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -51,10 +51,6 @@ | |||
51 | #include "io_ionsp.h" /* info for the iosp messages */ | 51 | #include "io_ionsp.h" /* info for the iosp messages */ |
52 | #include "io_16654.h" /* 16654 UART defines */ | 52 | #include "io_16654.h" /* 16654 UART defines */ |
53 | 53 | ||
54 | /* | ||
55 | * Version Information | ||
56 | */ | ||
57 | #define DRIVER_VERSION "v2.7" | ||
58 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" | 54 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" |
59 | #define DRIVER_DESC "Edgeport USB Serial Driver" | 55 | #define DRIVER_DESC "Edgeport USB Serial Driver" |
60 | 56 | ||
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 60023c2d2a31..58184f3de686 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -40,10 +40,6 @@ | |||
40 | #include "io_usbvend.h" | 40 | #include "io_usbvend.h" |
41 | #include "io_ti.h" | 41 | #include "io_ti.h" |
42 | 42 | ||
43 | /* | ||
44 | * Version Information | ||
45 | */ | ||
46 | #define DRIVER_VERSION "v0.7mode043006" | ||
47 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" | 43 | #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com> and David Iacovelli" |
48 | #define DRIVER_DESC "Edgeport USB Serial Driver" | 44 | #define DRIVER_DESC "Edgeport USB Serial Driver" |
49 | 45 | ||
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 1068bf22e27e..76c9a847da5d 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -25,11 +25,6 @@ | |||
25 | 25 | ||
26 | #define KP_RETRIES 100 | 26 | #define KP_RETRIES 100 |
27 | 27 | ||
28 | /* | ||
29 | * Version Information | ||
30 | */ | ||
31 | |||
32 | #define DRIVER_VERSION "v1.0" | ||
33 | #define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" | 28 | #define DRIVER_AUTHOR "Ganesh Varadarajan <ganesh@veritas.com>" |
34 | #define DRIVER_DESC "USB PocketPC PDA driver" | 29 | #define DRIVER_DESC "USB PocketPC PDA driver" |
35 | 30 | ||
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 4264821a3b34..155eab14b30e 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -49,10 +49,6 @@ | |||
49 | #include <linux/uaccess.h> | 49 | #include <linux/uaccess.h> |
50 | #include "usb-wwan.h" | 50 | #include "usb-wwan.h" |
51 | 51 | ||
52 | /* | ||
53 | * Version Information | ||
54 | */ | ||
55 | #define DRIVER_VERSION "v0.4" | ||
56 | #define DRIVER_AUTHOR "Roelf Diedericks" | 52 | #define DRIVER_AUTHOR "Roelf Diedericks" |
57 | #define DRIVER_DESC "IPWireless tty driver" | 53 | #define DRIVER_DESC "IPWireless tty driver" |
58 | 54 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index cd5533e81de7..1e1fbed65ef2 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -32,10 +32,6 @@ | |||
32 | #include "iuu_phoenix.h" | 32 | #include "iuu_phoenix.h" |
33 | #include <linux/random.h> | 33 | #include <linux/random.h> |
34 | 34 | ||
35 | /* | ||
36 | * Version Information | ||
37 | */ | ||
38 | #define DRIVER_VERSION "v0.12" | ||
39 | #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" | 35 | #define DRIVER_DESC "Infinity USB Unlimited Phoenix driver" |
40 | 36 | ||
41 | static const struct usb_device_id id_table[] = { | 37 | static const struct usb_device_id id_table[] = { |
@@ -1164,7 +1160,7 @@ static ssize_t store_vcc_mode(struct device *dev, | |||
1164 | struct iuu_private *priv = usb_get_serial_port_data(port); | 1160 | struct iuu_private *priv = usb_get_serial_port_data(port); |
1165 | unsigned long v; | 1161 | unsigned long v; |
1166 | 1162 | ||
1167 | if (strict_strtoul(buf, 10, &v)) { | 1163 | if (kstrtoul(buf, 10, &v)) { |
1168 | dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n", | 1164 | dev_err(dev, "%s - vcc_mode: %s is not a unsigned long\n", |
1169 | __func__, buf); | 1165 | __func__, buf); |
1170 | goto fail_store_vcc_mode; | 1166 | goto fail_store_vcc_mode; |
@@ -1232,8 +1228,6 @@ MODULE_AUTHOR("Alain Degreffe eczema@ecze.com"); | |||
1232 | MODULE_DESCRIPTION(DRIVER_DESC); | 1228 | MODULE_DESCRIPTION(DRIVER_DESC); |
1233 | MODULE_LICENSE("GPL"); | 1229 | MODULE_LICENSE("GPL"); |
1234 | 1230 | ||
1235 | MODULE_VERSION(DRIVER_VERSION); | ||
1236 | |||
1237 | module_param(xmas, bool, S_IRUGO | S_IWUSR); | 1231 | module_param(xmas, bool, S_IRUGO | S_IWUSR); |
1238 | MODULE_PARM_DESC(xmas, "Xmas colors enabled or not"); | 1232 | MODULE_PARM_DESC(xmas, "Xmas colors enabled or not"); |
1239 | 1233 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index cff8dd5b462d..97bc49f68efd 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -44,10 +44,6 @@ | |||
44 | #include <linux/usb/ezusb.h> | 44 | #include <linux/usb/ezusb.h> |
45 | #include "keyspan.h" | 45 | #include "keyspan.h" |
46 | 46 | ||
47 | /* | ||
48 | * Version Information | ||
49 | */ | ||
50 | #define DRIVER_VERSION "v1.1.5" | ||
51 | #define DRIVER_AUTHOR "Hugh Blemings <hugh@misc.nu" | 47 | #define DRIVER_AUTHOR "Hugh Blemings <hugh@misc.nu" |
52 | #define DRIVER_DESC "Keyspan USB to Serial Converter Driver" | 48 | #define DRIVER_DESC "Keyspan USB to Serial Converter Driver" |
53 | 49 | ||
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index bb87e29c4ac2..41b01092af07 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -42,10 +42,6 @@ | |||
42 | #undef XIRCOM | 42 | #undef XIRCOM |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | /* | ||
46 | * Version Information | ||
47 | */ | ||
48 | #define DRIVER_VERSION "v1.1" | ||
49 | #define DRIVER_AUTHOR "Brian Warner <warner@lothar.com>" | 45 | #define DRIVER_AUTHOR "Brian Warner <warner@lothar.com>" |
50 | #define DRIVER_DESC "USB Keyspan PDA Converter driver" | 46 | #define DRIVER_DESC "USB Keyspan PDA Converter driver" |
51 | 47 | ||
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 1f4517864cd2..fc9e14a1e9b3 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -49,10 +49,6 @@ | |||
49 | #include <linux/usb/serial.h> | 49 | #include <linux/usb/serial.h> |
50 | #include "kl5kusb105.h" | 50 | #include "kl5kusb105.h" |
51 | 51 | ||
52 | /* | ||
53 | * Version Information | ||
54 | */ | ||
55 | #define DRIVER_VERSION "v0.4" | ||
56 | #define DRIVER_AUTHOR "Utz-Uwe Haus <haus@uuhaus.de>, Johan Hovold <jhovold@gmail.com>" | 52 | #define DRIVER_AUTHOR "Utz-Uwe Haus <haus@uuhaus.de>, Johan Hovold <jhovold@gmail.com>" |
57 | #define DRIVER_DESC "KLSI KL5KUSB105 chipset USB->Serial Converter driver" | 53 | #define DRIVER_DESC "KLSI KL5KUSB105 chipset USB->Serial Converter driver" |
58 | 54 | ||
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index c9ca7a5b12e0..b747ba615d0b 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -38,8 +38,6 @@ | |||
38 | #include <linux/ioctl.h> | 38 | #include <linux/ioctl.h> |
39 | #include "kobil_sct.h" | 39 | #include "kobil_sct.h" |
40 | 40 | ||
41 | /* Version Information */ | ||
42 | #define DRIVER_VERSION "21/05/2004" | ||
43 | #define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" | 41 | #define DRIVER_AUTHOR "KOBIL Systems GmbH - http://www.kobil.com" |
44 | #define DRIVER_DESC "KOBIL USB Smart Card Terminal Driver (experimental)" | 42 | #define DRIVER_DESC "KOBIL USB Smart Card Terminal Driver (experimental)" |
45 | 43 | ||
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 8a2081004107..b6911757c855 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -38,10 +38,6 @@ | |||
38 | #include <linux/ioctl.h> | 38 | #include <linux/ioctl.h> |
39 | #include "mct_u232.h" | 39 | #include "mct_u232.h" |
40 | 40 | ||
41 | /* | ||
42 | * Version Information | ||
43 | */ | ||
44 | #define DRIVER_VERSION "z2.1" /* Linux in-kernel version */ | ||
45 | #define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" | 41 | #define DRIVER_AUTHOR "Wolfgang Grandegger <wolfgang@ces.ch>" |
46 | #define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" | 42 | #define DRIVER_DESC "Magic Control Technology USB-RS232 converter driver" |
47 | 43 | ||
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c index 6f29c74eb769..3d258448c29a 100644 --- a/drivers/usb/serial/metro-usb.c +++ b/drivers/usb/serial/metro-usb.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include <linux/uaccess.h> | 20 | #include <linux/uaccess.h> |
21 | #include <linux/usb/serial.h> | 21 | #include <linux/usb/serial.h> |
22 | 22 | ||
23 | /* Version Information */ | ||
24 | #define DRIVER_VERSION "v1.2.0.0" | ||
25 | #define DRIVER_DESC "Metrologic Instruments Inc. - USB-POS driver" | 23 | #define DRIVER_DESC "Metrologic Instruments Inc. - USB-POS driver" |
26 | 24 | ||
27 | /* Product information. */ | 25 | /* Product information. */ |
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 75267421aad8..f57a6b1fe787 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -36,10 +36,6 @@ | |||
36 | #include <linux/uaccess.h> | 36 | #include <linux/uaccess.h> |
37 | #include <linux/parport.h> | 37 | #include <linux/parport.h> |
38 | 38 | ||
39 | /* | ||
40 | * Version Information | ||
41 | */ | ||
42 | #define DRIVER_VERSION "2.1" | ||
43 | #define DRIVER_AUTHOR "Aspire Communications pvt Ltd." | 39 | #define DRIVER_AUTHOR "Aspire Communications pvt Ltd." |
44 | #define DRIVER_DESC "Moschip USB Serial Driver" | 40 | #define DRIVER_DESC "Moschip USB Serial Driver" |
45 | 41 | ||
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 1cf3375ec1af..66d9e088d9d9 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -35,10 +35,6 @@ | |||
35 | #include <linux/usb/serial.h> | 35 | #include <linux/usb/serial.h> |
36 | #include <linux/uaccess.h> | 36 | #include <linux/uaccess.h> |
37 | 37 | ||
38 | /* | ||
39 | * Version Information | ||
40 | */ | ||
41 | #define DRIVER_VERSION "1.3.2" | ||
42 | #define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver" | 38 | #define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver" |
43 | 39 | ||
44 | /* | 40 | /* |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 9ab73d295774..7818af931a48 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -23,10 +23,6 @@ | |||
23 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
24 | #include <linux/usb/serial.h> | 24 | #include <linux/usb/serial.h> |
25 | 25 | ||
26 | /* | ||
27 | * Version Information | ||
28 | */ | ||
29 | #define DRIVER_VERSION "v1.1" | ||
30 | #define DRIVER_AUTHOR "Alessandro Zummo" | 26 | #define DRIVER_AUTHOR "Alessandro Zummo" |
31 | #define DRIVER_DESC "USB ZyXEL omni.net LCD PLUS Driver" | 27 | #define DRIVER_DESC "USB ZyXEL omni.net LCD PLUS Driver" |
32 | 28 | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index edc64bb6f457..ed660564f0c5 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -28,7 +28,6 @@ | |||
28 | device features. | 28 | device features. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #define DRIVER_VERSION "v0.7.2" | ||
32 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" | 31 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" |
33 | #define DRIVER_DESC "USB Driver for GSM modems" | 32 | #define DRIVER_DESC "USB Driver for GSM modems" |
34 | 33 | ||
@@ -741,23 +740,23 @@ static const struct usb_device_id option_ids[] = { | |||
741 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, | 740 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, |
742 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, | 741 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
743 | { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, | 742 | { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, |
744 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 743 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1, 0xff) }, |
745 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 744 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2, 0xff) }, |
746 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, | 745 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004, 0xff) }, |
747 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005) }, | 746 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005, 0xff) }, |
748 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006) }, | 747 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006, 0xff) }, |
749 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007) }, | 748 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007, 0xff) }, |
750 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008) }, | 749 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008, 0xff) }, |
751 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009) }, | 750 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009, 0xff) }, |
752 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A) }, | 751 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A, 0xff) }, |
753 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B) }, | 752 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B, 0xff) }, |
754 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C) }, | 753 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C, 0xff) }, |
755 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D) }, | 754 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D, 0xff) }, |
756 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E) }, | 755 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E, 0xff) }, |
757 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F) }, | 756 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F, 0xff) }, |
758 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010) }, | 757 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010, 0xff) }, |
759 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011) }, | 758 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011, 0xff) }, |
760 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012) }, | 759 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) }, |
761 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, | 760 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, |
762 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | 761 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
763 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ | 762 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ |
@@ -1174,22 +1173,22 @@ static const struct usb_device_id option_ids[] = { | |||
1174 | { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, | 1173 | { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, |
1175 | { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, | 1174 | { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, |
1176 | /* Pirelli */ | 1175 | /* Pirelli */ |
1177 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)}, | 1176 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) }, |
1178 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)}, | 1177 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) }, |
1179 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)}, | 1178 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004, 0xff) }, |
1180 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)}, | 1179 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005, 0xff) }, |
1181 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)}, | 1180 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006, 0xff) }, |
1182 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)}, | 1181 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007, 0xff) }, |
1183 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)}, | 1182 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008, 0xff) }, |
1184 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)}, | 1183 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009, 0xff) }, |
1185 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)}, | 1184 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A, 0xff) }, |
1186 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) }, | 1185 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B, 0xff) }, |
1187 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) }, | 1186 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C, 0xff) }, |
1188 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) }, | 1187 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D, 0xff) }, |
1189 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) }, | 1188 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E, 0xff) }, |
1190 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) }, | 1189 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F, 0xff) }, |
1191 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)}, | 1190 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011, 0xff) }, |
1192 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)}, | 1191 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012, 0xff) }, |
1193 | /* Cinterion */ | 1192 | /* Cinterion */ |
1194 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, | 1193 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, |
1195 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, | 1194 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, |
@@ -1350,20 +1349,10 @@ static int option_probe(struct usb_serial *serial, | |||
1350 | &serial->interface->cur_altsetting->desc; | 1349 | &serial->interface->cur_altsetting->desc; |
1351 | struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; | 1350 | struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; |
1352 | 1351 | ||
1353 | /* | 1352 | /* Never bind to the CD-Rom emulation interface */ |
1354 | * D-Link DWM 652 still exposes CD-Rom emulation interface in modem | 1353 | if (iface_desc->bInterfaceClass == 0x08) |
1355 | * mode. | ||
1356 | */ | ||
1357 | if (dev_desc->idVendor == DLINK_VENDOR_ID && | ||
1358 | dev_desc->idProduct == DLINK_PRODUCT_DWM_652 && | ||
1359 | iface_desc->bInterfaceClass == 0x08) | ||
1360 | return -ENODEV; | 1354 | return -ENODEV; |
1361 | 1355 | ||
1362 | /* Bandrich modem and AT command interface is 0xff */ | ||
1363 | if ((dev_desc->idVendor == BANDRICH_VENDOR_ID || | ||
1364 | dev_desc->idVendor == PIRELLI_VENDOR_ID) && | ||
1365 | iface_desc->bInterfaceClass != 0xff) | ||
1366 | return -ENODEV; | ||
1367 | /* | 1356 | /* |
1368 | * Don't bind reserved interfaces (like network ones) which often have | 1357 | * Don't bind reserved interfaces (like network ones) which often have |
1369 | * the same class/subclass/protocol as the serial interfaces. Look at | 1358 | * the same class/subclass/protocol as the serial interfaces. Look at |
@@ -1378,9 +1367,9 @@ static int option_probe(struct usb_serial *serial, | |||
1378 | * Don't bind network interface on Samsung GT-B3730, it is handled by | 1367 | * Don't bind network interface on Samsung GT-B3730, it is handled by |
1379 | * a separate module. | 1368 | * a separate module. |
1380 | */ | 1369 | */ |
1381 | if (dev_desc->idVendor == SAMSUNG_VENDOR_ID && | 1370 | if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) && |
1382 | dev_desc->idProduct == SAMSUNG_PRODUCT_GT_B3730 && | 1371 | dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) && |
1383 | iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) | 1372 | iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) |
1384 | return -ENODEV; | 1373 | return -ENODEV; |
1385 | 1374 | ||
1386 | /* Store device id so we can use it during attach. */ | 1375 | /* Store device id so we can use it during attach. */ |
@@ -1518,5 +1507,4 @@ static int option_send_setup(struct usb_serial_port *port) | |||
1518 | 1507 | ||
1519 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1508 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1520 | MODULE_DESCRIPTION(DRIVER_DESC); | 1509 | MODULE_DESCRIPTION(DRIVER_DESC); |
1521 | MODULE_VERSION(DRIVER_VERSION); | ||
1522 | MODULE_LICENSE("GPL"); | 1510 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index cee9a52ca891..d217fd6ee43f 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -57,7 +57,6 @@ | |||
57 | #define OTI6858_DESCRIPTION \ | 57 | #define OTI6858_DESCRIPTION \ |
58 | "Ours Technology Inc. OTi-6858 USB to serial adapter driver" | 58 | "Ours Technology Inc. OTi-6858 USB to serial adapter driver" |
59 | #define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>" | 59 | #define OTI6858_AUTHOR "Tomasz Michal Lukaszewski <FIXME@FIXME>" |
60 | #define OTI6858_VERSION "0.2" | ||
61 | 60 | ||
62 | static const struct usb_device_id id_table[] = { | 61 | static const struct usb_device_id id_table[] = { |
63 | { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) }, | 62 | { USB_DEVICE(OTI6858_VENDOR_ID, OTI6858_PRODUCT_ID) }, |
@@ -899,5 +898,4 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
899 | 898 | ||
900 | MODULE_DESCRIPTION(OTI6858_DESCRIPTION); | 899 | MODULE_DESCRIPTION(OTI6858_DESCRIPTION); |
901 | MODULE_AUTHOR(OTI6858_AUTHOR); | 900 | MODULE_AUTHOR(OTI6858_AUTHOR); |
902 | MODULE_VERSION(OTI6858_VERSION); | ||
903 | MODULE_LICENSE("GPL"); | 901 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c index ffcfc962ab10..d152be97d041 100644 --- a/drivers/usb/serial/quatech2.c +++ b/drivers/usb/serial/quatech2.c | |||
@@ -65,8 +65,6 @@ | |||
65 | #define QT2_WRITE_BUFFER_SIZE 512 /* size of write buffer */ | 65 | #define QT2_WRITE_BUFFER_SIZE 512 /* size of write buffer */ |
66 | #define QT2_WRITE_CONTROL_SIZE 5 /* control bytes used for a write */ | 66 | #define QT2_WRITE_CONTROL_SIZE 5 /* control bytes used for a write */ |
67 | 67 | ||
68 | /* Version Information */ | ||
69 | #define DRIVER_VERSION "v0.1" | ||
70 | #define DRIVER_DESC "Quatech 2nd gen USB to Serial Driver" | 68 | #define DRIVER_DESC "Quatech 2nd gen USB to Serial Driver" |
71 | 69 | ||
72 | #define USB_VENDOR_ID_QUATECH 0x061d | 70 | #define USB_VENDOR_ID_QUATECH 0x061d |
diff --git a/drivers/usb/serial/siemens_mpi.c b/drivers/usb/serial/siemens_mpi.c index e4a1787cdbac..a76b1ae54a2a 100644 --- a/drivers/usb/serial/siemens_mpi.c +++ b/drivers/usb/serial/siemens_mpi.c | |||
@@ -16,8 +16,6 @@ | |||
16 | #include <linux/usb.h> | 16 | #include <linux/usb.h> |
17 | #include <linux/usb/serial.h> | 17 | #include <linux/usb/serial.h> |
18 | 18 | ||
19 | /* Version Information */ | ||
20 | #define DRIVER_VERSION "Version 0.1 09/26/2005" | ||
21 | #define DRIVER_AUTHOR "Thomas Hergenhahn@web.de http://libnodave.sf.net" | 19 | #define DRIVER_AUTHOR "Thomas Hergenhahn@web.de http://libnodave.sf.net" |
22 | #define DRIVER_DESC "Driver for Siemens USB/MPI adapter" | 20 | #define DRIVER_DESC "Driver for Siemens USB/MPI adapter" |
23 | 21 | ||
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index 270860f6bb2a..af06f2f5f38b 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -18,7 +18,7 @@ | |||
18 | */ | 18 | */ |
19 | /* Uncomment to log function calls */ | 19 | /* Uncomment to log function calls */ |
20 | /* #define DEBUG */ | 20 | /* #define DEBUG */ |
21 | #define DRIVER_VERSION "v.1.7.16" | 21 | |
22 | #define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer" | 22 | #define DRIVER_AUTHOR "Kevin Lloyd, Elina Pasheva, Matthew Safar, Rory Filer" |
23 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" | 23 | #define DRIVER_DESC "USB Driver for Sierra Wireless USB modems" |
24 | 24 | ||
@@ -1078,7 +1078,6 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
1078 | 1078 | ||
1079 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1079 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1080 | MODULE_DESCRIPTION(DRIVER_DESC); | 1080 | MODULE_DESCRIPTION(DRIVER_DESC); |
1081 | MODULE_VERSION(DRIVER_VERSION); | ||
1082 | MODULE_LICENSE("GPL"); | 1081 | MODULE_LICENSE("GPL"); |
1083 | 1082 | ||
1084 | module_param(nmea, bool, S_IRUGO | S_IWUSR); | 1083 | module_param(nmea, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index 769c137f8975..a42536af1256 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -28,9 +28,6 @@ | |||
28 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
29 | #include <linux/usb/serial.h> | 29 | #include <linux/usb/serial.h> |
30 | 30 | ||
31 | |||
32 | /* Version Information */ | ||
33 | #define DRIVER_VERSION "v0.10" | ||
34 | #define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" | 31 | #define DRIVER_DESC "SPCP8x5 USB to serial adaptor driver" |
35 | 32 | ||
36 | #define SPCP8x5_007_VID 0x04FC | 33 | #define SPCP8x5_007_VID 0x04FC |
@@ -651,5 +648,4 @@ static struct usb_serial_driver * const serial_drivers[] = { | |||
651 | module_usb_serial_driver(serial_drivers, id_table); | 648 | module_usb_serial_driver(serial_drivers, id_table); |
652 | 649 | ||
653 | MODULE_DESCRIPTION(DRIVER_DESC); | 650 | MODULE_DESCRIPTION(DRIVER_DESC); |
654 | MODULE_VERSION(DRIVER_VERSION); | ||
655 | MODULE_LICENSE("GPL"); | 651 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 868d1e6852e2..4543ea350229 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c | |||
@@ -46,8 +46,6 @@ | |||
46 | #define FULLPWRBIT 0x00000080 | 46 | #define FULLPWRBIT 0x00000080 |
47 | #define NEXT_BOARD_POWER_BIT 0x00000004 | 47 | #define NEXT_BOARD_POWER_BIT 0x00000004 |
48 | 48 | ||
49 | /* Version Information */ | ||
50 | #define DRIVER_VERSION "v0.1" | ||
51 | #define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" | 49 | #define DRIVER_DESC "Quatech SSU-100 USB to Serial Driver" |
52 | 50 | ||
53 | #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ | 51 | #define USB_VENDOR_ID_QUATECH 0x061d /* Quatech VID */ |
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c index a3e9c095f0d8..01c94aada56c 100644 --- a/drivers/usb/serial/usb_wwan.c +++ b/drivers/usb/serial/usb_wwan.c | |||
@@ -19,7 +19,6 @@ | |||
19 | - controlling the baud rate doesn't make sense | 19 | - controlling the baud rate doesn't make sense |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #define DRIVER_VERSION "v0.7.2" | ||
23 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" | 22 | #define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" |
24 | #define DRIVER_DESC "USB Driver for GSM modems" | 23 | #define DRIVER_DESC "USB Driver for GSM modems" |
25 | 24 | ||
@@ -710,5 +709,4 @@ EXPORT_SYMBOL(usb_wwan_resume); | |||
710 | 709 | ||
711 | MODULE_AUTHOR(DRIVER_AUTHOR); | 710 | MODULE_AUTHOR(DRIVER_AUTHOR); |
712 | MODULE_DESCRIPTION(DRIVER_DESC); | 711 | MODULE_DESCRIPTION(DRIVER_DESC); |
713 | MODULE_VERSION(DRIVER_VERSION); | ||
714 | MODULE_LICENSE("GPL"); | 712 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/vivopay-serial.c b/drivers/usb/serial/vivopay-serial.c index 0c0aa876c209..6299526ff8c3 100644 --- a/drivers/usb/serial/vivopay-serial.c +++ b/drivers/usb/serial/vivopay-serial.c | |||
@@ -10,8 +10,6 @@ | |||
10 | #include <linux/usb.h> | 10 | #include <linux/usb.h> |
11 | #include <linux/usb/serial.h> | 11 | #include <linux/usb/serial.h> |
12 | 12 | ||
13 | |||
14 | #define DRIVER_VERSION "v1.0" | ||
15 | #define DRIVER_DESC "ViVOpay USB Serial Driver" | 13 | #define DRIVER_DESC "ViVOpay USB Serial Driver" |
16 | 14 | ||
17 | #define VIVOPAY_VENDOR_ID 0x1d5f | 15 | #define VIVOPAY_VENDOR_ID 0x1d5f |
@@ -42,5 +40,4 @@ module_usb_serial_driver(serial_drivers, id_table); | |||
42 | 40 | ||
43 | MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>"); | 41 | MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>"); |
44 | MODULE_DESCRIPTION(DRIVER_DESC); | 42 | MODULE_DESCRIPTION(DRIVER_DESC); |
45 | MODULE_VERSION(DRIVER_VERSION); | ||
46 | MODULE_LICENSE("GPL"); | 43 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index d36446dd7ae8..ea5f2586fbdd 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c | |||
@@ -455,7 +455,7 @@ static int rts51x_check_status(struct us_data *us, u8 lun) | |||
455 | u8 buf[16]; | 455 | u8 buf[16]; |
456 | 456 | ||
457 | retval = rts51x_read_status(us, lun, buf, 16, &(chip->status_len)); | 457 | retval = rts51x_read_status(us, lun, buf, 16, &(chip->status_len)); |
458 | if (retval < 0) | 458 | if (retval != STATUS_SUCCESS) |
459 | return -EIO; | 459 | return -EIO; |
460 | 460 | ||
461 | US_DEBUGP("chip->status_len = %d\n", chip->status_len); | 461 | US_DEBUGP("chip->status_len = %d\n", chip->status_len); |
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 0616f235bd6b..ce310170829f 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
@@ -105,20 +105,15 @@ static int skel_open(struct inode *inode, struct file *file) | |||
105 | goto exit; | 105 | goto exit; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* increment our usage count for the device */ | ||
109 | kref_get(&dev->kref); | ||
110 | |||
111 | /* lock the device to allow correctly handling errors | ||
112 | * in resumption */ | ||
113 | mutex_lock(&dev->io_mutex); | ||
114 | |||
115 | retval = usb_autopm_get_interface(interface); | 108 | retval = usb_autopm_get_interface(interface); |
116 | if (retval) | 109 | if (retval) |
117 | goto out_err; | 110 | goto exit; |
111 | |||
112 | /* increment our usage count for the device */ | ||
113 | kref_get(&dev->kref); | ||
118 | 114 | ||
119 | /* save our object in the file's private structure */ | 115 | /* save our object in the file's private structure */ |
120 | file->private_data = dev; | 116 | file->private_data = dev; |
121 | mutex_unlock(&dev->io_mutex); | ||
122 | 117 | ||
123 | exit: | 118 | exit: |
124 | return retval; | 119 | return retval; |
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c index 231009af65a3..1d365316960c 100644 --- a/drivers/usb/wusbcore/devconnect.c +++ b/drivers/usb/wusbcore/devconnect.c | |||
@@ -847,19 +847,6 @@ static void wusb_dev_bos_rm(struct wusb_dev *wusb_dev) | |||
847 | wusb_dev->wusb_cap_descr = NULL; | 847 | wusb_dev->wusb_cap_descr = NULL; |
848 | }; | 848 | }; |
849 | 849 | ||
850 | static struct usb_wireless_cap_descriptor wusb_cap_descr_default = { | ||
851 | .bLength = sizeof(wusb_cap_descr_default), | ||
852 | .bDescriptorType = USB_DT_DEVICE_CAPABILITY, | ||
853 | .bDevCapabilityType = USB_CAP_TYPE_WIRELESS_USB, | ||
854 | |||
855 | .bmAttributes = USB_WIRELESS_BEACON_NONE, | ||
856 | .wPHYRates = cpu_to_le16(USB_WIRELESS_PHY_53), | ||
857 | .bmTFITXPowerInfo = 0, | ||
858 | .bmFFITXPowerInfo = 0, | ||
859 | .bmBandGroup = cpu_to_le16(0x0001), /* WUSB1.0[7.4.1] bottom */ | ||
860 | .bReserved = 0 | ||
861 | }; | ||
862 | |||
863 | /* | 850 | /* |
864 | * USB stack's device addition Notifier Callback | 851 | * USB stack's device addition Notifier Callback |
865 | * | 852 | * |