diff options
Diffstat (limited to 'drivers/usb')
252 files changed, 3061 insertions, 9987 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 4c90b510d016..640ae6c6d2d2 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
| @@ -37,6 +37,7 @@ config USB_ARCH_HAS_EHCI | |||
| 37 | default y if ARCH_W90X900 | 37 | default y if ARCH_W90X900 |
| 38 | default y if ARCH_AT91 | 38 | default y if ARCH_AT91 |
| 39 | default y if ARCH_MXC | 39 | default y if ARCH_MXC |
| 40 | default y if ARCH_MXS | ||
| 40 | default y if ARCH_OMAP3 | 41 | default y if ARCH_OMAP3 |
| 41 | default y if ARCH_CNS3XXX | 42 | default y if ARCH_CNS3XXX |
| 42 | default y if ARCH_VT8500 | 43 | default y if ARCH_VT8500 |
diff --git a/drivers/usb/c67x00/c67x00-drv.c b/drivers/usb/c67x00/c67x00-drv.c index 6f3b6e267398..fe815ecd557e 100644 --- a/drivers/usb/c67x00/c67x00-drv.c +++ b/drivers/usb/c67x00/c67x00-drv.c | |||
| @@ -116,7 +116,7 @@ static irqreturn_t c67x00_irq(int irq, void *__dev) | |||
| 116 | 116 | ||
| 117 | /* ------------------------------------------------------------------------- */ | 117 | /* ------------------------------------------------------------------------- */ |
| 118 | 118 | ||
| 119 | static int __devinit c67x00_drv_probe(struct platform_device *pdev) | 119 | static int c67x00_drv_probe(struct platform_device *pdev) |
| 120 | { | 120 | { |
| 121 | struct c67x00_device *c67x00; | 121 | struct c67x00_device *c67x00; |
| 122 | struct c67x00_platform_data *pdata; | 122 | struct c67x00_platform_data *pdata; |
| @@ -191,7 +191,7 @@ static int __devinit c67x00_drv_probe(struct platform_device *pdev) | |||
| 191 | return ret; | 191 | return ret; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | static int __devexit c67x00_drv_remove(struct platform_device *pdev) | 194 | static int c67x00_drv_remove(struct platform_device *pdev) |
| 195 | { | 195 | { |
| 196 | struct c67x00_device *c67x00 = platform_get_drvdata(pdev); | 196 | struct c67x00_device *c67x00 = platform_get_drvdata(pdev); |
| 197 | struct resource *res; | 197 | struct resource *res; |
| @@ -219,7 +219,7 @@ static int __devexit c67x00_drv_remove(struct platform_device *pdev) | |||
| 219 | 219 | ||
| 220 | static struct platform_driver c67x00_driver = { | 220 | static struct platform_driver c67x00_driver = { |
| 221 | .probe = c67x00_drv_probe, | 221 | .probe = c67x00_drv_probe, |
| 222 | .remove = __devexit_p(c67x00_drv_remove), | 222 | .remove = c67x00_drv_remove, |
| 223 | .driver = { | 223 | .driver = { |
| 224 | .owner = THIS_MODULE, | 224 | .owner = THIS_MODULE, |
| 225 | .name = "c67x00", | 225 | .name = "c67x00", |
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/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c index 0f5ca4bea17f..8c291220be7f 100644 --- a/drivers/usb/chipidea/ci13xxx_imx.c +++ b/drivers/usb/chipidea/ci13xxx_imx.c | |||
| @@ -85,7 +85,7 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data); | |||
| 85 | 85 | ||
| 86 | /* End of common functions shared by usbmisc drivers*/ | 86 | /* End of common functions shared by usbmisc drivers*/ |
| 87 | 87 | ||
| 88 | static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = { | 88 | static struct ci13xxx_platform_data ci13xxx_imx_platdata = { |
| 89 | .name = "ci13xxx_imx", | 89 | .name = "ci13xxx_imx", |
| 90 | .flags = CI13XXX_REQUIRE_TRANSCEIVER | | 90 | .flags = CI13XXX_REQUIRE_TRANSCEIVER | |
| 91 | CI13XXX_PULLUP_ON_VBUS | | 91 | CI13XXX_PULLUP_ON_VBUS | |
| @@ -93,7 +93,7 @@ static struct ci13xxx_platform_data ci13xxx_imx_platdata __devinitdata = { | |||
| 93 | .capoffset = DEF_CAPOFFSET, | 93 | .capoffset = DEF_CAPOFFSET, |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | static int __devinit ci13xxx_imx_probe(struct platform_device *pdev) | 96 | static int ci13xxx_imx_probe(struct platform_device *pdev) |
| 97 | { | 97 | { |
| 98 | struct ci13xxx_imx_data *data; | 98 | struct ci13xxx_imx_data *data; |
| 99 | struct platform_device *plat_ci, *phy_pdev; | 99 | struct platform_device *plat_ci, *phy_pdev; |
| @@ -220,7 +220,7 @@ put_np: | |||
| 220 | return ret; | 220 | return ret; |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | static int __devexit ci13xxx_imx_remove(struct platform_device *pdev) | 223 | static int ci13xxx_imx_remove(struct platform_device *pdev) |
| 224 | { | 224 | { |
| 225 | struct ci13xxx_imx_data *data = platform_get_drvdata(pdev); | 225 | struct ci13xxx_imx_data *data = platform_get_drvdata(pdev); |
| 226 | 226 | ||
| @@ -252,7 +252,7 @@ MODULE_DEVICE_TABLE(of, ci13xxx_imx_dt_ids); | |||
| 252 | 252 | ||
| 253 | static struct platform_driver ci13xxx_imx_driver = { | 253 | static struct platform_driver ci13xxx_imx_driver = { |
| 254 | .probe = ci13xxx_imx_probe, | 254 | .probe = ci13xxx_imx_probe, |
| 255 | .remove = __devexit_p(ci13xxx_imx_remove), | 255 | .remove = ci13xxx_imx_remove, |
| 256 | .driver = { | 256 | .driver = { |
| 257 | .name = "imx_usb", | 257 | .name = "imx_usb", |
| 258 | .owner = THIS_MODULE, | 258 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/chipidea/ci13xxx_msm.c b/drivers/usb/chipidea/ci13xxx_msm.c index b01feb3be92e..7d16681fd3d2 100644 --- a/drivers/usb/chipidea/ci13xxx_msm.c +++ b/drivers/usb/chipidea/ci13xxx_msm.c | |||
| @@ -55,7 +55,7 @@ static struct ci13xxx_platform_data ci13xxx_msm_platdata = { | |||
| 55 | .notify_event = ci13xxx_msm_notify_event, | 55 | .notify_event = ci13xxx_msm_notify_event, |
| 56 | }; | 56 | }; |
| 57 | 57 | ||
| 58 | static int __devinit ci13xxx_msm_probe(struct platform_device *pdev) | 58 | static int ci13xxx_msm_probe(struct platform_device *pdev) |
| 59 | { | 59 | { |
| 60 | struct platform_device *plat_ci; | 60 | struct platform_device *plat_ci; |
| 61 | 61 | ||
| @@ -77,7 +77,7 @@ static int __devinit ci13xxx_msm_probe(struct platform_device *pdev) | |||
| 77 | return 0; | 77 | return 0; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static int __devexit ci13xxx_msm_remove(struct platform_device *pdev) | 80 | static int ci13xxx_msm_remove(struct platform_device *pdev) |
| 81 | { | 81 | { |
| 82 | struct platform_device *plat_ci = platform_get_drvdata(pdev); | 82 | struct platform_device *plat_ci = platform_get_drvdata(pdev); |
| 83 | 83 | ||
| @@ -89,7 +89,7 @@ static int __devexit ci13xxx_msm_remove(struct platform_device *pdev) | |||
| 89 | 89 | ||
| 90 | static struct platform_driver ci13xxx_msm_driver = { | 90 | static struct platform_driver ci13xxx_msm_driver = { |
| 91 | .probe = ci13xxx_msm_probe, | 91 | .probe = ci13xxx_msm_probe, |
| 92 | .remove = __devexit_p(ci13xxx_msm_remove), | 92 | .remove = ci13xxx_msm_remove, |
| 93 | .driver = { .name = "msm_hsusb", }, | 93 | .driver = { .name = "msm_hsusb", }, |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
diff --git a/drivers/usb/chipidea/ci13xxx_pci.c b/drivers/usb/chipidea/ci13xxx_pci.c index 918e14971f2b..9b227e39299a 100644 --- a/drivers/usb/chipidea/ci13xxx_pci.c +++ b/drivers/usb/chipidea/ci13xxx_pci.c | |||
| @@ -48,7 +48,7 @@ struct ci13xxx_platform_data penwell_pci_platdata = { | |||
| 48 | * Allocates basic PCI resources for this USB device controller, and then | 48 | * Allocates basic PCI resources for this USB device controller, and then |
| 49 | * invokes the udc_probe() method to start the UDC associated with it | 49 | * invokes the udc_probe() method to start the UDC associated with it |
| 50 | */ | 50 | */ |
| 51 | static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev, | 51 | static int ci13xxx_pci_probe(struct pci_dev *pdev, |
| 52 | const struct pci_device_id *id) | 52 | const struct pci_device_id *id) |
| 53 | { | 53 | { |
| 54 | struct ci13xxx_platform_data *platdata = (void *)id->driver_data; | 54 | struct ci13xxx_platform_data *platdata = (void *)id->driver_data; |
| @@ -107,7 +107,7 @@ static int __devinit ci13xxx_pci_probe(struct pci_dev *pdev, | |||
| 107 | * first invoking the udc_remove() and then releases | 107 | * first invoking the udc_remove() and then releases |
| 108 | * all PCI resources allocated for this USB device controller | 108 | * all PCI resources allocated for this USB device controller |
| 109 | */ | 109 | */ |
| 110 | static void __devexit ci13xxx_pci_remove(struct pci_dev *pdev) | 110 | static void ci13xxx_pci_remove(struct pci_dev *pdev) |
| 111 | { | 111 | { |
| 112 | struct platform_device *plat_ci = pci_get_drvdata(pdev); | 112 | struct platform_device *plat_ci = pci_get_drvdata(pdev); |
| 113 | 113 | ||
| @@ -147,7 +147,7 @@ static struct pci_driver ci13xxx_pci_driver = { | |||
| 147 | .name = UDC_DRIVER_NAME, | 147 | .name = UDC_DRIVER_NAME, |
| 148 | .id_table = ci13xxx_pci_id_table, | 148 | .id_table = ci13xxx_pci_id_table, |
| 149 | .probe = ci13xxx_pci_probe, | 149 | .probe = ci13xxx_pci_probe, |
| 150 | .remove = __devexit_p(ci13xxx_pci_remove), | 150 | .remove = ci13xxx_pci_remove, |
| 151 | }; | 151 | }; |
| 152 | 152 | ||
| 153 | module_pci_driver(ci13xxx_pci_driver); | 153 | module_pci_driver(ci13xxx_pci_driver); |
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index f69d029b4607..aebf695a9344 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
| @@ -385,12 +385,13 @@ EXPORT_SYMBOL_GPL(ci13xxx_add_device); | |||
| 385 | 385 | ||
| 386 | void ci13xxx_remove_device(struct platform_device *pdev) | 386 | void ci13xxx_remove_device(struct platform_device *pdev) |
| 387 | { | 387 | { |
| 388 | int id = pdev->id; | ||
| 388 | platform_device_unregister(pdev); | 389 | platform_device_unregister(pdev); |
| 389 | ida_simple_remove(&ci_ida, pdev->id); | 390 | ida_simple_remove(&ci_ida, id); |
| 390 | } | 391 | } |
| 391 | EXPORT_SYMBOL_GPL(ci13xxx_remove_device); | 392 | EXPORT_SYMBOL_GPL(ci13xxx_remove_device); |
| 392 | 393 | ||
| 393 | static int __devinit ci_hdrc_probe(struct platform_device *pdev) | 394 | static int ci_hdrc_probe(struct platform_device *pdev) |
| 394 | { | 395 | { |
| 395 | struct device *dev = &pdev->dev; | 396 | struct device *dev = &pdev->dev; |
| 396 | struct ci13xxx *ci; | 397 | struct ci13xxx *ci; |
| @@ -508,7 +509,7 @@ rm_wq: | |||
| 508 | return ret; | 509 | return ret; |
| 509 | } | 510 | } |
| 510 | 511 | ||
| 511 | static int __devexit ci_hdrc_remove(struct platform_device *pdev) | 512 | static int ci_hdrc_remove(struct platform_device *pdev) |
| 512 | { | 513 | { |
| 513 | struct ci13xxx *ci = platform_get_drvdata(pdev); | 514 | struct ci13xxx *ci = platform_get_drvdata(pdev); |
| 514 | 515 | ||
| @@ -523,7 +524,7 @@ static int __devexit ci_hdrc_remove(struct platform_device *pdev) | |||
| 523 | 524 | ||
| 524 | static struct platform_driver ci_hdrc_driver = { | 525 | static struct platform_driver ci_hdrc_driver = { |
| 525 | .probe = ci_hdrc_probe, | 526 | .probe = ci_hdrc_probe, |
| 526 | .remove = __devexit_p(ci_hdrc_remove), | 527 | .remove = ci_hdrc_remove, |
| 527 | .driver = { | 528 | .driver = { |
| 528 | .name = "ci_hdrc", | 529 | .name = "ci_hdrc", |
| 529 | }, | 530 | }, |
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..8e9d31277c43 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 | { |
| @@ -129,6 +70,9 @@ static int host_start(struct ci13xxx *ci) | |||
| 129 | else | 70 | else |
| 130 | ci->hcd = hcd; | 71 | ci->hcd = hcd; |
| 131 | 72 | ||
| 73 | if (ci->platdata->flags & CI13XXX_DISABLE_STREAMING) | ||
| 74 | hw_write(ci, OP_USBMODE, USBMODE_CI_SDIS, USBMODE_CI_SDIS); | ||
| 75 | |||
| 132 | return ret; | 76 | return ret; |
| 133 | } | 77 | } |
| 134 | 78 | ||
| @@ -157,5 +101,7 @@ int ci_hdrc_host_init(struct ci13xxx *ci) | |||
| 157 | rdrv->name = "host"; | 101 | rdrv->name = "host"; |
| 158 | ci->roles[CI_ROLE_HOST] = rdrv; | 102 | ci->roles[CI_ROLE_HOST] = rdrv; |
| 159 | 103 | ||
| 104 | ehci_init_driver(&ci_ehci_hc_driver, NULL); | ||
| 105 | |||
| 160 | return 0; | 106 | return 0; |
| 161 | } | 107 | } |
diff --git a/drivers/usb/chipidea/usbmisc_imx6q.c b/drivers/usb/chipidea/usbmisc_imx6q.c index 416e3fc58fd0..845efe29e6b9 100644 --- a/drivers/usb/chipidea/usbmisc_imx6q.c +++ b/drivers/usb/chipidea/usbmisc_imx6q.c | |||
| @@ -82,7 +82,7 @@ static const struct of_device_id usbmisc_imx6q_dt_ids[] = { | |||
| 82 | { /* sentinel */ } | 82 | { /* sentinel */ } |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| 85 | static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev) | 85 | static int usbmisc_imx6q_probe(struct platform_device *pdev) |
| 86 | { | 86 | { |
| 87 | struct resource *res; | 87 | struct resource *res; |
| 88 | struct imx6q_usbmisc *data; | 88 | struct imx6q_usbmisc *data; |
| @@ -127,7 +127,7 @@ static int __devinit usbmisc_imx6q_probe(struct platform_device *pdev) | |||
| 127 | return 0; | 127 | return 0; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev) | 130 | static int usbmisc_imx6q_remove(struct platform_device *pdev) |
| 131 | { | 131 | { |
| 132 | usbmisc_unset_ops(&imx6q_usbmisc_ops); | 132 | usbmisc_unset_ops(&imx6q_usbmisc_ops); |
| 133 | clk_disable_unprepare(usbmisc->clk); | 133 | clk_disable_unprepare(usbmisc->clk); |
| @@ -136,7 +136,7 @@ static int __devexit usbmisc_imx6q_remove(struct platform_device *pdev) | |||
| 136 | 136 | ||
| 137 | static struct platform_driver usbmisc_imx6q_driver = { | 137 | static struct platform_driver usbmisc_imx6q_driver = { |
| 138 | .probe = usbmisc_imx6q_probe, | 138 | .probe = usbmisc_imx6q_probe, |
| 139 | .remove = __devexit_p(usbmisc_imx6q_remove), | 139 | .remove = usbmisc_imx6q_remove, |
| 140 | .driver = { | 140 | .driver = { |
| 141 | .name = "usbmisc_imx6q", | 141 | .name = "usbmisc_imx6q", |
| 142 | .owner = THIS_MODULE, | 142 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 6e49ec6f3adc..2d92cce260d7 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; |
| @@ -1564,6 +1602,9 @@ static const struct usb_device_id acm_ids[] = { | |||
| 1564 | { USB_DEVICE(0x0572, 0x1340), /* Conexant CX93010-2x UCMxx */ | 1602 | { USB_DEVICE(0x0572, 0x1340), /* Conexant CX93010-2x UCMxx */ |
| 1565 | .driver_info = NO_UNION_NORMAL, | 1603 | .driver_info = NO_UNION_NORMAL, |
| 1566 | }, | 1604 | }, |
| 1605 | { USB_DEVICE(0x05f9, 0x4002), /* PSC Scanning, Magellan 800i */ | ||
| 1606 | .driver_info = NO_UNION_NORMAL, | ||
| 1607 | }, | ||
| 1567 | { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */ | 1608 | { USB_DEVICE(0x1bbb, 0x0003), /* Alcatel OT-I650 */ |
| 1568 | .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ | 1609 | .driver_info = NO_UNION_NORMAL, /* reports zero length descriptor */ |
| 1569 | }, | 1610 | }, |
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/driver.c b/drivers/usb/core/driver.c index 6056db7af410..d938b2b99e31 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
| @@ -32,8 +32,6 @@ | |||
| 32 | #include "usb.h" | 32 | #include "usb.h" |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | #ifdef CONFIG_HOTPLUG | ||
| 36 | |||
| 37 | /* | 35 | /* |
| 38 | * Adds a new dynamic USBdevice ID to this driver, | 36 | * Adds a new dynamic USBdevice ID to this driver, |
| 39 | * and cause the driver to probe for all devices again. | 37 | * and cause the driver to probe for all devices again. |
| @@ -194,20 +192,6 @@ static void usb_free_dynids(struct usb_driver *usb_drv) | |||
| 194 | } | 192 | } |
| 195 | spin_unlock(&usb_drv->dynids.lock); | 193 | spin_unlock(&usb_drv->dynids.lock); |
| 196 | } | 194 | } |
| 197 | #else | ||
| 198 | static inline int usb_create_newid_files(struct usb_driver *usb_drv) | ||
| 199 | { | ||
| 200 | return 0; | ||
| 201 | } | ||
| 202 | |||
| 203 | static void usb_remove_newid_files(struct usb_driver *usb_drv) | ||
| 204 | { | ||
| 205 | } | ||
| 206 | |||
| 207 | static inline void usb_free_dynids(struct usb_driver *usb_drv) | ||
| 208 | { | ||
| 209 | } | ||
| 210 | #endif | ||
| 211 | 195 | ||
| 212 | static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf, | 196 | static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf, |
| 213 | struct usb_driver *drv) | 197 | struct usb_driver *drv) |
| @@ -238,7 +222,7 @@ static int usb_probe_device(struct device *dev) | |||
| 238 | /* TODO: Add real matching code */ | 222 | /* TODO: Add real matching code */ |
| 239 | 223 | ||
| 240 | /* The device should always appear to be in use | 224 | /* The device should always appear to be in use |
| 241 | * unless the driver suports autosuspend. | 225 | * unless the driver supports autosuspend. |
| 242 | */ | 226 | */ |
| 243 | if (!udriver->supports_autosuspend) | 227 | if (!udriver->supports_autosuspend) |
| 244 | error = usb_autoresume_device(udev); | 228 | error = usb_autoresume_device(udev); |
| @@ -790,7 +774,6 @@ static int usb_device_match(struct device *dev, struct device_driver *drv) | |||
| 790 | return 0; | 774 | return 0; |
| 791 | } | 775 | } |
| 792 | 776 | ||
| 793 | #ifdef CONFIG_HOTPLUG | ||
| 794 | static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | 777 | static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 795 | { | 778 | { |
| 796 | struct usb_device *usb_dev; | 779 | struct usb_device *usb_dev; |
| @@ -832,14 +815,6 @@ static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
| 832 | return 0; | 815 | return 0; |
| 833 | } | 816 | } |
| 834 | 817 | ||
| 835 | #else | ||
| 836 | |||
| 837 | static int usb_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
| 838 | { | ||
| 839 | return -ENODEV; | ||
| 840 | } | ||
| 841 | #endif /* CONFIG_HOTPLUG */ | ||
| 842 | |||
| 843 | /** | 818 | /** |
| 844 | * usb_register_device_driver - register a USB device (not interface) driver | 819 | * usb_register_device_driver - register a USB device (not interface) driver |
| 845 | * @new_udriver: USB operations for the device driver | 820 | * @new_udriver: USB operations for the device driver |
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..957ed2c41482 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); |
| @@ -876,6 +877,60 @@ static int hub_hub_status(struct usb_hub *hub, | |||
| 876 | return ret; | 877 | return ret; |
| 877 | } | 878 | } |
| 878 | 879 | ||
| 880 | static int hub_set_port_link_state(struct usb_hub *hub, int port1, | ||
| 881 | unsigned int link_status) | ||
| 882 | { | ||
| 883 | return set_port_feature(hub->hdev, | ||
| 884 | port1 | (link_status << 3), | ||
| 885 | USB_PORT_FEAT_LINK_STATE); | ||
| 886 | } | ||
| 887 | |||
| 888 | /* | ||
| 889 | * If USB 3.0 ports are placed into the Disabled state, they will no longer | ||
| 890 | * detect any device connects or disconnects. This is generally not what the | ||
| 891 | * USB core wants, since it expects a disabled port to produce a port status | ||
| 892 | * change event when a new device connects. | ||
| 893 | * | ||
| 894 | * Instead, set the link state to Disabled, wait for the link to settle into | ||
| 895 | * that state, clear any change bits, and then put the port into the RxDetect | ||
| 896 | * state. | ||
| 897 | */ | ||
| 898 | static int hub_usb3_port_disable(struct usb_hub *hub, int port1) | ||
| 899 | { | ||
| 900 | int ret; | ||
| 901 | int total_time; | ||
| 902 | u16 portchange, portstatus; | ||
| 903 | |||
| 904 | if (!hub_is_superspeed(hub->hdev)) | ||
| 905 | return -EINVAL; | ||
| 906 | |||
| 907 | ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); | ||
| 908 | if (ret) { | ||
| 909 | dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", | ||
| 910 | port1, ret); | ||
| 911 | return ret; | ||
| 912 | } | ||
| 913 | |||
| 914 | /* Wait for the link to enter the disabled state. */ | ||
| 915 | for (total_time = 0; ; total_time += HUB_DEBOUNCE_STEP) { | ||
| 916 | ret = hub_port_status(hub, port1, &portstatus, &portchange); | ||
| 917 | if (ret < 0) | ||
| 918 | return ret; | ||
| 919 | |||
| 920 | if ((portstatus & USB_PORT_STAT_LINK_STATE) == | ||
| 921 | USB_SS_PORT_LS_SS_DISABLED) | ||
| 922 | break; | ||
| 923 | if (total_time >= HUB_DEBOUNCE_TIMEOUT) | ||
| 924 | break; | ||
| 925 | msleep(HUB_DEBOUNCE_STEP); | ||
| 926 | } | ||
| 927 | if (total_time >= HUB_DEBOUNCE_TIMEOUT) | ||
| 928 | dev_warn(hub->intfdev, "Could not disable port %d after %d ms\n", | ||
| 929 | port1, total_time); | ||
| 930 | |||
| 931 | return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT); | ||
| 932 | } | ||
| 933 | |||
| 879 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) | 934 | static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) |
| 880 | { | 935 | { |
| 881 | struct usb_device *hdev = hub->hdev; | 936 | struct usb_device *hdev = hub->hdev; |
| @@ -884,8 +939,13 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state) | |||
| 884 | if (hub->ports[port1 - 1]->child && set_state) | 939 | if (hub->ports[port1 - 1]->child && set_state) |
| 885 | usb_set_device_state(hub->ports[port1 - 1]->child, | 940 | usb_set_device_state(hub->ports[port1 - 1]->child, |
| 886 | USB_STATE_NOTATTACHED); | 941 | USB_STATE_NOTATTACHED); |
| 887 | if (!hub->error && !hub_is_superspeed(hub->hdev)) | 942 | if (!hub->error) { |
| 888 | ret = clear_port_feature(hdev, port1, USB_PORT_FEAT_ENABLE); | 943 | if (hub_is_superspeed(hub->hdev)) |
| 944 | ret = hub_usb3_port_disable(hub, port1); | ||
| 945 | else | ||
| 946 | ret = clear_port_feature(hdev, port1, | ||
| 947 | USB_PORT_FEAT_ENABLE); | ||
| 948 | } | ||
| 889 | if (ret) | 949 | if (ret) |
| 890 | dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", | 950 | dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n", |
| 891 | port1, ret); | 951 | port1, ret); |
| @@ -1612,6 +1672,41 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 1612 | desc = intf->cur_altsetting; | 1672 | desc = intf->cur_altsetting; |
| 1613 | hdev = interface_to_usbdev(intf); | 1673 | hdev = interface_to_usbdev(intf); |
| 1614 | 1674 | ||
| 1675 | /* | ||
| 1676 | * Set default autosuspend delay as 0 to speedup bus suspend, | ||
| 1677 | * based on the below considerations: | ||
| 1678 | * | ||
| 1679 | * - Unlike other drivers, the hub driver does not rely on the | ||
| 1680 | * autosuspend delay to provide enough time to handle a wakeup | ||
| 1681 | * event, and the submitted status URB is just to check future | ||
| 1682 | * change on hub downstream ports, so it is safe to do it. | ||
| 1683 | * | ||
| 1684 | * - The patch might cause one or more auto supend/resume for | ||
| 1685 | * below very rare devices when they are plugged into hub | ||
| 1686 | * first time: | ||
| 1687 | * | ||
| 1688 | * devices having trouble initializing, and disconnect | ||
| 1689 | * themselves from the bus and then reconnect a second | ||
| 1690 | * or so later | ||
| 1691 | * | ||
| 1692 | * devices just for downloading firmware, and disconnects | ||
| 1693 | * themselves after completing it | ||
| 1694 | * | ||
| 1695 | * For these quite rare devices, their drivers may change the | ||
| 1696 | * autosuspend delay of their parent hub in the probe() to one | ||
| 1697 | * appropriate value to avoid the subtle problem if someone | ||
| 1698 | * does care it. | ||
| 1699 | * | ||
| 1700 | * - The patch may cause one or more auto suspend/resume on | ||
| 1701 | * hub during running 'lsusb', but it is probably too | ||
| 1702 | * infrequent to worry about. | ||
| 1703 | * | ||
| 1704 | * - Change autosuspend delay of hub can avoid unnecessary auto | ||
| 1705 | * suspend timer for hub, also may decrease power consumption | ||
| 1706 | * of USB bus. | ||
| 1707 | */ | ||
| 1708 | pm_runtime_set_autosuspend_delay(&hdev->dev, 0); | ||
| 1709 | |||
| 1615 | /* Hubs have proper suspend/resume support. */ | 1710 | /* Hubs have proper suspend/resume support. */ |
| 1616 | usb_enable_autosuspend(hdev); | 1711 | usb_enable_autosuspend(hdev); |
| 1617 | 1712 | ||
| @@ -1670,6 +1765,9 @@ descriptor_error: | |||
| 1670 | if (hdev->speed == USB_SPEED_HIGH) | 1765 | if (hdev->speed == USB_SPEED_HIGH) |
| 1671 | highspeed_hubs++; | 1766 | highspeed_hubs++; |
| 1672 | 1767 | ||
| 1768 | if (id->driver_info & HUB_QUIRK_CHECK_PORT_AUTOSUSPEND) | ||
| 1769 | hub->quirk_check_port_auto_suspend = 1; | ||
| 1770 | |||
| 1673 | if (hub_configure(hub, endpoint) >= 0) | 1771 | if (hub_configure(hub, endpoint) >= 0) |
| 1674 | return 0; | 1772 | return 0; |
| 1675 | 1773 | ||
| @@ -2012,7 +2110,7 @@ static void show_string(struct usb_device *udev, char *id, char *string) | |||
| 2012 | { | 2110 | { |
| 2013 | if (!string) | 2111 | if (!string) |
| 2014 | return; | 2112 | return; |
| 2015 | dev_printk(KERN_INFO, &udev->dev, "%s: %s\n", id, string); | 2113 | dev_info(&udev->dev, "%s: %s\n", id, string); |
| 2016 | } | 2114 | } |
| 2017 | 2115 | ||
| 2018 | static void announce_device(struct usb_device *udev) | 2116 | static void announce_device(struct usb_device *udev) |
| @@ -2401,7 +2499,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub) | |||
| 2401 | #define HUB_SHORT_RESET_TIME 10 | 2499 | #define HUB_SHORT_RESET_TIME 10 |
| 2402 | #define HUB_BH_RESET_TIME 50 | 2500 | #define HUB_BH_RESET_TIME 50 |
| 2403 | #define HUB_LONG_RESET_TIME 200 | 2501 | #define HUB_LONG_RESET_TIME 200 |
| 2404 | #define HUB_RESET_TIMEOUT 500 | 2502 | #define HUB_RESET_TIMEOUT 800 |
| 2405 | 2503 | ||
| 2406 | static int hub_port_reset(struct usb_hub *hub, int port1, | 2504 | static int hub_port_reset(struct usb_hub *hub, int port1, |
| 2407 | struct usb_device *udev, unsigned int delay, bool warm); | 2505 | struct usb_device *udev, unsigned int delay, bool warm); |
| @@ -2436,6 +2534,10 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, | |||
| 2436 | if (ret < 0) | 2534 | if (ret < 0) |
| 2437 | return ret; | 2535 | return ret; |
| 2438 | 2536 | ||
| 2537 | /* The port state is unknown until the reset completes. */ | ||
| 2538 | if ((portstatus & USB_PORT_STAT_RESET)) | ||
| 2539 | goto delay; | ||
| 2540 | |||
| 2439 | /* | 2541 | /* |
| 2440 | * Some buggy devices require a warm reset to be issued even | 2542 | * Some buggy devices require a warm reset to be issued even |
| 2441 | * when the port appears not to be connected. | 2543 | * when the port appears not to be connected. |
| @@ -2481,11 +2583,7 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, | |||
| 2481 | if ((portchange & USB_PORT_STAT_C_CONNECTION)) | 2583 | if ((portchange & USB_PORT_STAT_C_CONNECTION)) |
| 2482 | return -ENOTCONN; | 2584 | return -ENOTCONN; |
| 2483 | 2585 | ||
| 2484 | /* if we`ve finished resetting, then break out of | 2586 | if ((portstatus & USB_PORT_STAT_ENABLE)) { |
| 2485 | * the loop | ||
| 2486 | */ | ||
| 2487 | if (!(portstatus & USB_PORT_STAT_RESET) && | ||
| 2488 | (portstatus & USB_PORT_STAT_ENABLE)) { | ||
| 2489 | if (hub_is_wusb(hub)) | 2587 | if (hub_is_wusb(hub)) |
| 2490 | udev->speed = USB_SPEED_WIRELESS; | 2588 | udev->speed = USB_SPEED_WIRELESS; |
| 2491 | else if (hub_is_superspeed(hub->hdev)) | 2589 | else if (hub_is_superspeed(hub->hdev)) |
| @@ -2499,10 +2597,15 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1, | |||
| 2499 | return 0; | 2597 | return 0; |
| 2500 | } | 2598 | } |
| 2501 | } else { | 2599 | } else { |
| 2502 | if (portchange & USB_PORT_STAT_C_BH_RESET) | 2600 | if (!(portstatus & USB_PORT_STAT_CONNECTION) || |
| 2503 | return 0; | 2601 | hub_port_warm_reset_required(hub, |
| 2602 | portstatus)) | ||
| 2603 | return -ENOTCONN; | ||
| 2604 | |||
| 2605 | return 0; | ||
| 2504 | } | 2606 | } |
| 2505 | 2607 | ||
| 2608 | delay: | ||
| 2506 | /* switch to the long delay after two short delay failures */ | 2609 | /* switch to the long delay after two short delay failures */ |
| 2507 | if (delay_time >= 2 * HUB_SHORT_RESET_TIME) | 2610 | if (delay_time >= 2 * HUB_SHORT_RESET_TIME) |
| 2508 | delay = HUB_LONG_RESET_TIME; | 2611 | delay = HUB_LONG_RESET_TIME; |
| @@ -2526,14 +2629,11 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1, | |||
| 2526 | msleep(10 + 40); | 2629 | msleep(10 + 40); |
| 2527 | update_devnum(udev, 0); | 2630 | update_devnum(udev, 0); |
| 2528 | hcd = bus_to_hcd(udev->bus); | 2631 | hcd = bus_to_hcd(udev->bus); |
| 2529 | if (hcd->driver->reset_device) { | 2632 | /* The xHC may think the device is already reset, |
| 2530 | *status = hcd->driver->reset_device(hcd, udev); | 2633 | * so ignore the status. |
| 2531 | if (*status < 0) { | 2634 | */ |
| 2532 | dev_err(&udev->dev, "Cannot reset " | 2635 | if (hcd->driver->reset_device) |
| 2533 | "HCD device state\n"); | 2636 | hcd->driver->reset_device(hcd, udev); |
| 2534 | break; | ||
| 2535 | } | ||
| 2536 | } | ||
| 2537 | } | 2637 | } |
| 2538 | /* FALL THROUGH */ | 2638 | /* FALL THROUGH */ |
| 2539 | case -ENOTCONN: | 2639 | case -ENOTCONN: |
| @@ -2541,16 +2641,16 @@ static void hub_port_finish_reset(struct usb_hub *hub, int port1, | |||
| 2541 | clear_port_feature(hub->hdev, | 2641 | clear_port_feature(hub->hdev, |
| 2542 | port1, USB_PORT_FEAT_C_RESET); | 2642 | port1, USB_PORT_FEAT_C_RESET); |
| 2543 | /* FIXME need disconnect() for NOTATTACHED device */ | 2643 | /* FIXME need disconnect() for NOTATTACHED device */ |
| 2544 | if (warm) { | 2644 | if (hub_is_superspeed(hub->hdev)) { |
| 2545 | clear_port_feature(hub->hdev, port1, | 2645 | clear_port_feature(hub->hdev, port1, |
| 2546 | USB_PORT_FEAT_C_BH_PORT_RESET); | 2646 | USB_PORT_FEAT_C_BH_PORT_RESET); |
| 2547 | clear_port_feature(hub->hdev, port1, | 2647 | clear_port_feature(hub->hdev, port1, |
| 2548 | USB_PORT_FEAT_C_PORT_LINK_STATE); | 2648 | USB_PORT_FEAT_C_PORT_LINK_STATE); |
| 2549 | } else { | 2649 | } |
| 2650 | if (!warm) | ||
| 2550 | usb_set_device_state(udev, *status | 2651 | usb_set_device_state(udev, *status |
| 2551 | ? USB_STATE_NOTATTACHED | 2652 | ? USB_STATE_NOTATTACHED |
| 2552 | : USB_STATE_DEFAULT); | 2653 | : USB_STATE_DEFAULT); |
| 2553 | } | ||
| 2554 | break; | 2654 | break; |
| 2555 | } | 2655 | } |
| 2556 | } | 2656 | } |
| @@ -2879,6 +2979,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) | |||
| 2879 | (PMSG_IS_AUTO(msg) ? "auto-" : ""), | 2979 | (PMSG_IS_AUTO(msg) ? "auto-" : ""), |
| 2880 | udev->do_remote_wakeup); | 2980 | udev->do_remote_wakeup); |
| 2881 | usb_set_device_state(udev, USB_STATE_SUSPENDED); | 2981 | usb_set_device_state(udev, USB_STATE_SUSPENDED); |
| 2982 | udev->port_is_suspended = 1; | ||
| 2882 | msleep(10); | 2983 | msleep(10); |
| 2883 | } | 2984 | } |
| 2884 | usb_mark_last_busy(hub->hdev); | 2985 | usb_mark_last_busy(hub->hdev); |
| @@ -2899,7 +3000,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) | |||
| 2899 | static int finish_port_resume(struct usb_device *udev) | 3000 | static int finish_port_resume(struct usb_device *udev) |
| 2900 | { | 3001 | { |
| 2901 | int status = 0; | 3002 | int status = 0; |
| 2902 | u16 devstatus; | 3003 | u16 devstatus = 0; |
| 2903 | 3004 | ||
| 2904 | /* caller owns the udev device lock */ | 3005 | /* caller owns the udev device lock */ |
| 2905 | dev_dbg(&udev->dev, "%s\n", | 3006 | dev_dbg(&udev->dev, "%s\n", |
| @@ -2944,7 +3045,13 @@ static int finish_port_resume(struct usb_device *udev) | |||
| 2944 | if (status) { | 3045 | if (status) { |
| 2945 | dev_dbg(&udev->dev, "gone after usb resume? status %d\n", | 3046 | dev_dbg(&udev->dev, "gone after usb resume? status %d\n", |
| 2946 | status); | 3047 | status); |
| 2947 | } else if (udev->actconfig) { | 3048 | /* |
| 3049 | * There are a few quirky devices which violate the standard | ||
| 3050 | * by claiming to have remote wakeup enabled after a reset, | ||
| 3051 | * which crash if the feature is cleared, hence check for | ||
| 3052 | * udev->reset_resume | ||
| 3053 | */ | ||
| 3054 | } else if (udev->actconfig && !udev->reset_resume) { | ||
| 2948 | le16_to_cpus(&devstatus); | 3055 | le16_to_cpus(&devstatus); |
| 2949 | if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) { | 3056 | if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) { |
| 2950 | status = usb_control_msg(udev, | 3057 | status = usb_control_msg(udev, |
| @@ -3043,6 +3150,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) | |||
| 3043 | 3150 | ||
| 3044 | SuspendCleared: | 3151 | SuspendCleared: |
| 3045 | if (status == 0) { | 3152 | if (status == 0) { |
| 3153 | udev->port_is_suspended = 0; | ||
| 3046 | if (hub_is_superspeed(hub->hdev)) { | 3154 | if (hub_is_superspeed(hub->hdev)) { |
| 3047 | if (portchange & USB_PORT_STAT_C_LINK_STATE) | 3155 | if (portchange & USB_PORT_STAT_C_LINK_STATE) |
| 3048 | clear_port_feature(hub->hdev, port1, | 3156 | clear_port_feature(hub->hdev, port1, |
| @@ -3126,6 +3234,21 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg) | |||
| 3126 | 3234 | ||
| 3127 | #endif | 3235 | #endif |
| 3128 | 3236 | ||
| 3237 | static int check_ports_changed(struct usb_hub *hub) | ||
| 3238 | { | ||
| 3239 | int port1; | ||
| 3240 | |||
| 3241 | for (port1 = 1; port1 <= hub->hdev->maxchild; ++port1) { | ||
| 3242 | u16 portstatus, portchange; | ||
| 3243 | int status; | ||
| 3244 | |||
| 3245 | status = hub_port_status(hub, port1, &portstatus, &portchange); | ||
| 3246 | if (!status && portchange) | ||
| 3247 | return 1; | ||
| 3248 | } | ||
| 3249 | return 0; | ||
| 3250 | } | ||
| 3251 | |||
| 3129 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | 3252 | static int hub_suspend(struct usb_interface *intf, pm_message_t msg) |
| 3130 | { | 3253 | { |
| 3131 | struct usb_hub *hub = usb_get_intfdata (intf); | 3254 | struct usb_hub *hub = usb_get_intfdata (intf); |
| @@ -3144,6 +3267,16 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
| 3144 | return -EBUSY; | 3267 | return -EBUSY; |
| 3145 | } | 3268 | } |
| 3146 | } | 3269 | } |
| 3270 | |||
| 3271 | if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { | ||
| 3272 | /* check if there are changes pending on hub ports */ | ||
| 3273 | if (check_ports_changed(hub)) { | ||
| 3274 | if (PMSG_IS_AUTO(msg)) | ||
| 3275 | return -EBUSY; | ||
| 3276 | pm_wakeup_event(&hdev->dev, 2000); | ||
| 3277 | } | ||
| 3278 | } | ||
| 3279 | |||
| 3147 | if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { | 3280 | if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { |
| 3148 | /* Enable hub to send remote wakeup for all ports. */ | 3281 | /* Enable hub to send remote wakeup for all ports. */ |
| 3149 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 3282 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
| @@ -3972,6 +4105,9 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1, | |||
| 3972 | if (retval) | 4105 | if (retval) |
| 3973 | goto fail; | 4106 | goto fail; |
| 3974 | 4107 | ||
| 4108 | if (hcd->phy && !hdev->parent) | ||
| 4109 | usb_phy_notify_connect(hcd->phy, udev->speed); | ||
| 4110 | |||
| 3975 | /* | 4111 | /* |
| 3976 | * Some superspeed devices have finished the link training process | 4112 | * Some superspeed devices have finished the link training process |
| 3977 | * and attached to a superspeed hub port, but the device descriptor | 4113 | * and attached to a superspeed hub port, but the device descriptor |
| @@ -4166,8 +4302,12 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
| 4166 | } | 4302 | } |
| 4167 | 4303 | ||
| 4168 | /* Disconnect any existing devices under this port */ | 4304 | /* Disconnect any existing devices under this port */ |
| 4169 | if (udev) | 4305 | if (udev) { |
| 4306 | if (hcd->phy && !hdev->parent && | ||
| 4307 | !(portstatus & USB_PORT_STAT_CONNECTION)) | ||
| 4308 | usb_phy_notify_disconnect(hcd->phy, udev->speed); | ||
| 4170 | usb_disconnect(&hub->ports[port1 - 1]->child); | 4309 | usb_disconnect(&hub->ports[port1 - 1]->child); |
| 4310 | } | ||
| 4171 | clear_bit(port1, hub->change_bits); | 4311 | clear_bit(port1, hub->change_bits); |
| 4172 | 4312 | ||
| 4173 | /* We can forget about a "removed" device when there's a physical | 4313 | /* We can forget about a "removed" device when there's a physical |
| @@ -4190,13 +4330,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1, | |||
| 4190 | } | 4330 | } |
| 4191 | } | 4331 | } |
| 4192 | 4332 | ||
| 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 | 4333 | /* Return now if debouncing failed or nothing is connected or |
| 4201 | * the device was "removed". | 4334 | * the device was "removed". |
| 4202 | */ | 4335 | */ |
| @@ -4572,9 +4705,14 @@ static void hub_events(void) | |||
| 4572 | * SS.Inactive state. | 4705 | * SS.Inactive state. |
| 4573 | */ | 4706 | */ |
| 4574 | if (hub_port_warm_reset_required(hub, portstatus)) { | 4707 | if (hub_port_warm_reset_required(hub, portstatus)) { |
| 4708 | int status; | ||
| 4709 | |||
| 4575 | dev_dbg(hub_dev, "warm reset port %d\n", i); | 4710 | dev_dbg(hub_dev, "warm reset port %d\n", i); |
| 4576 | hub_port_reset(hub, i, NULL, | 4711 | status = hub_port_reset(hub, i, NULL, |
| 4577 | HUB_BH_RESET_TIME, true); | 4712 | HUB_BH_RESET_TIME, true); |
| 4713 | if (status < 0) | ||
| 4714 | hub_port_disable(hub, i, 1); | ||
| 4715 | connect_change = 0; | ||
| 4578 | } | 4716 | } |
| 4579 | 4717 | ||
| 4580 | if (connect_change) | 4718 | if (connect_change) |
| @@ -4648,6 +4786,11 @@ static int hub_thread(void *__unused) | |||
| 4648 | } | 4786 | } |
| 4649 | 4787 | ||
| 4650 | static const struct usb_device_id hub_id_table[] = { | 4788 | static const struct usb_device_id hub_id_table[] = { |
| 4789 | { .match_flags = USB_DEVICE_ID_MATCH_VENDOR | ||
| 4790 | | USB_DEVICE_ID_MATCH_INT_CLASS, | ||
| 4791 | .idVendor = USB_VENDOR_GENESYS_LOGIC, | ||
| 4792 | .bInterfaceClass = USB_CLASS_HUB, | ||
| 4793 | .driver_info = HUB_QUIRK_CHECK_PORT_AUTOSUSPEND}, | ||
| 4651 | { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, | 4794 | { .match_flags = USB_DEVICE_ID_MATCH_DEV_CLASS, |
| 4652 | .bDeviceClass = USB_CLASS_HUB}, | 4795 | .bDeviceClass = USB_CLASS_HUB}, |
| 4653 | { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, | 4796 | { .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS, |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 1ed5afd91e6d..131f73649b60 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -1540,7 +1540,6 @@ static void usb_release_interface(struct device *dev) | |||
| 1540 | kfree(intf); | 1540 | kfree(intf); |
| 1541 | } | 1541 | } |
| 1542 | 1542 | ||
| 1543 | #ifdef CONFIG_HOTPLUG | ||
| 1544 | static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) | 1543 | static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 1545 | { | 1544 | { |
| 1546 | struct usb_device *usb_dev; | 1545 | struct usb_device *usb_dev; |
| @@ -1575,14 +1574,6 @@ static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
| 1575 | return 0; | 1574 | return 0; |
| 1576 | } | 1575 | } |
| 1577 | 1576 | ||
| 1578 | #else | ||
| 1579 | |||
| 1580 | static int usb_if_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
| 1581 | { | ||
| 1582 | return -ENODEV; | ||
| 1583 | } | ||
| 1584 | #endif /* CONFIG_HOTPLUG */ | ||
| 1585 | |||
| 1586 | struct device_type usb_if_device_type = { | 1577 | struct device_type usb_if_device_type = { |
| 1587 | .name = "usb_interface", | 1578 | .name = "usb_interface", |
| 1588 | .release = usb_release_interface, | 1579 | .release = usb_release_interface, |
| @@ -1795,7 +1786,8 @@ free_interfaces: | |||
| 1795 | if (dev->actconfig && usb_disable_lpm(dev)) { | 1786 | if (dev->actconfig && usb_disable_lpm(dev)) { |
| 1796 | dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__); | 1787 | dev_err(&dev->dev, "%s Failed to disable LPM\n.", __func__); |
| 1797 | mutex_unlock(hcd->bandwidth_mutex); | 1788 | mutex_unlock(hcd->bandwidth_mutex); |
| 1798 | return -ENOMEM; | 1789 | ret = -ENOMEM; |
| 1790 | goto free_interfaces; | ||
| 1799 | } | 1791 | } |
| 1800 | ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); | 1792 | ret = usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL); |
| 1801 | if (ret < 0) { | 1793 | if (ret < 0) { |
| @@ -1806,29 +1798,8 @@ free_interfaces: | |||
| 1806 | goto free_interfaces; | 1798 | goto free_interfaces; |
| 1807 | } | 1799 | } |
| 1808 | 1800 | ||
| 1809 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | 1801 | /* |
| 1810 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | 1802 | * 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. | 1803 | * hc/hcd/usbcore interface/endpoint state. |
| 1833 | */ | 1804 | */ |
| 1834 | for (i = 0; i < nintf; ++i) { | 1805 | for (i = 0; i < nintf; ++i) { |
| @@ -1872,6 +1843,35 @@ free_interfaces: | |||
| 1872 | } | 1843 | } |
| 1873 | kfree(new_interfaces); | 1844 | kfree(new_interfaces); |
| 1874 | 1845 | ||
| 1846 | ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), | ||
| 1847 | USB_REQ_SET_CONFIGURATION, 0, configuration, 0, | ||
| 1848 | NULL, 0, USB_CTRL_SET_TIMEOUT); | ||
| 1849 | if (ret < 0 && cp) { | ||
| 1850 | /* | ||
| 1851 | * All the old state is gone, so what else can we do? | ||
| 1852 | * The device is probably useless now anyway. | ||
| 1853 | */ | ||
| 1854 | usb_hcd_alloc_bandwidth(dev, NULL, NULL, NULL); | ||
| 1855 | for (i = 0; i < nintf; ++i) { | ||
| 1856 | usb_disable_interface(dev, cp->interface[i], true); | ||
| 1857 | put_device(&cp->interface[i]->dev); | ||
| 1858 | cp->interface[i] = NULL; | ||
| 1859 | } | ||
| 1860 | cp = NULL; | ||
| 1861 | } | ||
| 1862 | |||
| 1863 | dev->actconfig = cp; | ||
| 1864 | mutex_unlock(hcd->bandwidth_mutex); | ||
| 1865 | |||
| 1866 | if (!cp) { | ||
| 1867 | usb_set_device_state(dev, USB_STATE_ADDRESS); | ||
| 1868 | |||
| 1869 | /* Leave LPM disabled while the device is unconfigured. */ | ||
| 1870 | usb_autosuspend_device(dev); | ||
| 1871 | return ret; | ||
| 1872 | } | ||
| 1873 | usb_set_device_state(dev, USB_STATE_CONFIGURED); | ||
| 1874 | |||
| 1875 | if (cp->string == NULL && | 1875 | if (cp->string == NULL && |
| 1876 | !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) | 1876 | !(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS)) |
| 1877 | cp->string = usb_cache_string(dev, cp->desc.iConfiguration); | 1877 | cp->string = usb_cache_string(dev, cp->desc.iConfiguration); |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index fdefd9c7f7af..3113c1d71442 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
| @@ -43,6 +43,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
| 43 | /* Creative SB Audigy 2 NX */ | 43 | /* Creative SB Audigy 2 NX */ |
| 44 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, | 44 | { USB_DEVICE(0x041e, 0x3020), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 45 | 45 | ||
| 46 | /* Microsoft LifeCam-VX700 v2.0 */ | ||
| 47 | { USB_DEVICE(0x045e, 0x0770), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
| 48 | |||
| 46 | /* Logitech Quickcam Fusion */ | 49 | /* Logitech Quickcam Fusion */ |
| 47 | { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME }, | 50 | { USB_DEVICE(0x046d, 0x08c1), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 48 | 51 | ||
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..f81b92572735 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
| @@ -233,7 +233,6 @@ static void usb_release_dev(struct device *dev) | |||
| 233 | kfree(udev); | 233 | kfree(udev); |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | #ifdef CONFIG_HOTPLUG | ||
| 237 | static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) | 236 | static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) |
| 238 | { | 237 | { |
| 239 | struct usb_device *usb_dev; | 238 | struct usb_device *usb_dev; |
| @@ -249,14 +248,6 @@ static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
| 249 | return 0; | 248 | return 0; |
| 250 | } | 249 | } |
| 251 | 250 | ||
| 252 | #else | ||
| 253 | |||
| 254 | static int usb_dev_uevent(struct device *dev, struct kobj_uevent_env *env) | ||
| 255 | { | ||
| 256 | return -ENODEV; | ||
| 257 | } | ||
| 258 | #endif /* CONFIG_HOTPLUG */ | ||
| 259 | |||
| 260 | #ifdef CONFIG_PM | 251 | #ifdef CONFIG_PM |
| 261 | 252 | ||
| 262 | /* USB device Power-Management thunks. | 253 | /* USB device Power-Management thunks. |
| @@ -370,14 +361,14 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent, | |||
| 370 | struct usb_bus *bus, unsigned port1) | 361 | struct usb_bus *bus, unsigned port1) |
| 371 | { | 362 | { |
| 372 | struct usb_device *dev; | 363 | struct usb_device *dev; |
| 373 | struct usb_hcd *usb_hcd = container_of(bus, struct usb_hcd, self); | 364 | struct usb_hcd *usb_hcd = bus_to_hcd(bus); |
| 374 | unsigned root_hub = 0; | 365 | unsigned root_hub = 0; |
| 375 | 366 | ||
| 376 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 367 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 377 | if (!dev) | 368 | if (!dev) |
| 378 | return NULL; | 369 | return NULL; |
| 379 | 370 | ||
| 380 | if (!usb_get_hcd(bus_to_hcd(bus))) { | 371 | if (!usb_get_hcd(usb_hcd)) { |
| 381 | kfree(dev); | 372 | kfree(dev); |
| 382 | return NULL; | 373 | return NULL; |
| 383 | } | 374 | } |
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..3a4004a620ad 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 | /** |
| @@ -180,12 +140,11 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, | |||
| 180 | * Returns a pointer to the allocated event buffer structure on success | 140 | * Returns a pointer to the allocated event buffer structure on success |
| 181 | * otherwise ERR_PTR(errno). | 141 | * otherwise ERR_PTR(errno). |
| 182 | */ | 142 | */ |
| 183 | static struct dwc3_event_buffer *__devinit | 143 | static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) |
| 184 | dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) | ||
| 185 | { | 144 | { |
| 186 | struct dwc3_event_buffer *evt; | 145 | struct dwc3_event_buffer *evt; |
| 187 | 146 | ||
| 188 | evt = kzalloc(sizeof(*evt), GFP_KERNEL); | 147 | evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); |
| 189 | if (!evt) | 148 | if (!evt) |
| 190 | return ERR_PTR(-ENOMEM); | 149 | return ERR_PTR(-ENOMEM); |
| 191 | 150 | ||
| @@ -193,10 +152,8 @@ dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) | |||
| 193 | evt->length = length; | 152 | evt->length = length; |
| 194 | evt->buf = dma_alloc_coherent(dwc->dev, length, | 153 | evt->buf = dma_alloc_coherent(dwc->dev, length, |
| 195 | &evt->dma, GFP_KERNEL); | 154 | &evt->dma, GFP_KERNEL); |
| 196 | if (!evt->buf) { | 155 | if (!evt->buf) |
| 197 | kfree(evt); | ||
| 198 | return ERR_PTR(-ENOMEM); | 156 | return ERR_PTR(-ENOMEM); |
| 199 | } | ||
| 200 | 157 | ||
| 201 | return evt; | 158 | return evt; |
| 202 | } | 159 | } |
| @@ -215,8 +172,6 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
| 215 | if (evt) | 172 | if (evt) |
| 216 | dwc3_free_one_event_buffer(dwc, evt); | 173 | dwc3_free_one_event_buffer(dwc, evt); |
| 217 | } | 174 | } |
| 218 | |||
| 219 | kfree(dwc->ev_buffs); | ||
| 220 | } | 175 | } |
| 221 | 176 | ||
| 222 | /** | 177 | /** |
| @@ -227,7 +182,7 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
| 227 | * Returns 0 on success otherwise negative errno. In the error case, dwc | 182 | * Returns 0 on success otherwise negative errno. In the error case, dwc |
| 228 | * may contain some buffers allocated but not all which were requested. | 183 | * may contain some buffers allocated but not all which were requested. |
| 229 | */ | 184 | */ |
| 230 | static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | 185 | static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) |
| 231 | { | 186 | { |
| 232 | int num; | 187 | int num; |
| 233 | int i; | 188 | int i; |
| @@ -235,7 +190,8 @@ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | |||
| 235 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); | 190 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); |
| 236 | dwc->num_event_buffers = num; | 191 | dwc->num_event_buffers = num; |
| 237 | 192 | ||
| 238 | dwc->ev_buffs = kzalloc(sizeof(*dwc->ev_buffs) * num, GFP_KERNEL); | 193 | dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, |
| 194 | GFP_KERNEL); | ||
| 239 | if (!dwc->ev_buffs) { | 195 | if (!dwc->ev_buffs) { |
| 240 | dev_err(dwc->dev, "can't allocate event buffers array\n"); | 196 | dev_err(dwc->dev, "can't allocate event buffers array\n"); |
| 241 | return -ENOMEM; | 197 | return -ENOMEM; |
| @@ -303,7 +259,7 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | |||
| 303 | } | 259 | } |
| 304 | } | 260 | } |
| 305 | 261 | ||
| 306 | static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc) | 262 | static void dwc3_cache_hwparams(struct dwc3 *dwc) |
| 307 | { | 263 | { |
| 308 | struct dwc3_hwparams *parms = &dwc->hwparams; | 264 | struct dwc3_hwparams *parms = &dwc->hwparams; |
| 309 | 265 | ||
| @@ -324,7 +280,7 @@ static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc) | |||
| 324 | * | 280 | * |
| 325 | * Returns 0 on success otherwise negative errno. | 281 | * Returns 0 on success otherwise negative errno. |
| 326 | */ | 282 | */ |
| 327 | static int __devinit dwc3_core_init(struct dwc3 *dwc) | 283 | static int dwc3_core_init(struct dwc3 *dwc) |
| 328 | { | 284 | { |
| 329 | unsigned long timeout; | 285 | unsigned long timeout; |
| 330 | u32 reg; | 286 | u32 reg; |
| @@ -358,8 +314,6 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
| 358 | 314 | ||
| 359 | dwc3_core_soft_reset(dwc); | 315 | dwc3_core_soft_reset(dwc); |
| 360 | 316 | ||
| 361 | dwc3_cache_hwparams(dwc); | ||
| 362 | |||
| 363 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | 317 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
| 364 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; | 318 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; |
| 365 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | 319 | reg &= ~DWC3_GCTL_DISSCRAMBLE; |
| @@ -383,24 +337,14 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
| 383 | 337 | ||
| 384 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 338 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
| 385 | 339 | ||
| 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); | 340 | ret = dwc3_event_buffers_setup(dwc); |
| 394 | if (ret) { | 341 | if (ret) { |
| 395 | dev_err(dwc->dev, "failed to setup event buffers\n"); | 342 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
| 396 | goto err1; | 343 | goto err0; |
| 397 | } | 344 | } |
| 398 | 345 | ||
| 399 | return 0; | 346 | return 0; |
| 400 | 347 | ||
| 401 | err1: | ||
| 402 | dwc3_free_event_buffers(dwc); | ||
| 403 | |||
| 404 | err0: | 348 | err0: |
| 405 | return ret; | 349 | return ret; |
| 406 | } | 350 | } |
| @@ -408,16 +352,14 @@ err0: | |||
| 408 | static void dwc3_core_exit(struct dwc3 *dwc) | 352 | static void dwc3_core_exit(struct dwc3 *dwc) |
| 409 | { | 353 | { |
| 410 | dwc3_event_buffers_cleanup(dwc); | 354 | dwc3_event_buffers_cleanup(dwc); |
| 411 | dwc3_free_event_buffers(dwc); | ||
| 412 | 355 | ||
| 413 | usb_phy_shutdown(dwc->usb2_phy); | 356 | usb_phy_shutdown(dwc->usb2_phy); |
| 414 | usb_phy_shutdown(dwc->usb3_phy); | 357 | usb_phy_shutdown(dwc->usb3_phy); |
| 415 | |||
| 416 | } | 358 | } |
| 417 | 359 | ||
| 418 | #define DWC3_ALIGN_MASK (16 - 1) | 360 | #define DWC3_ALIGN_MASK (16 - 1) |
| 419 | 361 | ||
| 420 | static int __devinit dwc3_probe(struct platform_device *pdev) | 362 | static int dwc3_probe(struct platform_device *pdev) |
| 421 | { | 363 | { |
| 422 | struct device_node *node = pdev->dev.of_node; | 364 | struct device_node *node = pdev->dev.of_node; |
| 423 | struct resource *res; | 365 | struct resource *res; |
| @@ -515,10 +457,19 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
| 515 | pm_runtime_get_sync(dev); | 457 | pm_runtime_get_sync(dev); |
| 516 | pm_runtime_forbid(dev); | 458 | pm_runtime_forbid(dev); |
| 517 | 459 | ||
| 460 | dwc3_cache_hwparams(dwc); | ||
| 461 | |||
| 462 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
| 463 | if (ret) { | ||
| 464 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
| 465 | ret = -ENOMEM; | ||
| 466 | goto err0; | ||
| 467 | } | ||
| 468 | |||
| 518 | ret = dwc3_core_init(dwc); | 469 | ret = dwc3_core_init(dwc); |
| 519 | if (ret) { | 470 | if (ret) { |
| 520 | dev_err(dev, "failed to initialize core\n"); | 471 | dev_err(dev, "failed to initialize core\n"); |
| 521 | return ret; | 472 | goto err0; |
| 522 | } | 473 | } |
| 523 | 474 | ||
| 524 | mode = DWC3_MODE(dwc->hwparams.hwparams0); | 475 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
| @@ -590,10 +541,13 @@ err2: | |||
| 590 | err1: | 541 | err1: |
| 591 | dwc3_core_exit(dwc); | 542 | dwc3_core_exit(dwc); |
| 592 | 543 | ||
| 544 | err0: | ||
| 545 | dwc3_free_event_buffers(dwc); | ||
| 546 | |||
| 593 | return ret; | 547 | return ret; |
| 594 | } | 548 | } |
| 595 | 549 | ||
| 596 | static int __devexit dwc3_remove(struct platform_device *pdev) | 550 | static int dwc3_remove(struct platform_device *pdev) |
| 597 | { | 551 | { |
| 598 | struct dwc3 *dwc = platform_get_drvdata(pdev); | 552 | struct dwc3 *dwc = platform_get_drvdata(pdev); |
| 599 | struct resource *res; | 553 | struct resource *res; |
| @@ -628,7 +582,7 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
| 628 | 582 | ||
| 629 | static struct platform_driver dwc3_driver = { | 583 | static struct platform_driver dwc3_driver = { |
| 630 | .probe = dwc3_probe, | 584 | .probe = dwc3_probe, |
| 631 | .remove = __devexit_p(dwc3_remove), | 585 | .remove = dwc3_remove, |
| 632 | .driver = { | 586 | .driver = { |
| 633 | .name = "dwc3", | 587 | .name = "dwc3", |
| 634 | }, | 588 | }, |
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/debugfs.c b/drivers/usb/dwc3/debugfs.c index d4a30f118724..5945aadaa1c9 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | #define dump_register(nm) \ | 56 | #define dump_register(nm) \ |
| 57 | { \ | 57 | { \ |
| 58 | .name = __stringify(nm), \ | 58 | .name = __stringify(nm), \ |
| 59 | .offset = DWC3_ ##nm, \ | 59 | .offset = DWC3_ ##nm - DWC3_GLOBALS_REGS_START, \ |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static const struct debugfs_reg32 dwc3_regs[] = { | 62 | static const struct debugfs_reg32 dwc3_regs[] = { |
| @@ -652,7 +652,7 @@ static const struct file_operations dwc3_link_state_fops = { | |||
| 652 | .release = single_release, | 652 | .release = single_release, |
| 653 | }; | 653 | }; |
| 654 | 654 | ||
| 655 | int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | 655 | int dwc3_debugfs_init(struct dwc3 *dwc) |
| 656 | { | 656 | { |
| 657 | struct dentry *root; | 657 | struct dentry *root; |
| 658 | struct dentry *file; | 658 | struct dentry *file; |
| @@ -703,7 +703,7 @@ err0: | |||
| 703 | return ret; | 703 | return ret; |
| 704 | } | 704 | } |
| 705 | 705 | ||
| 706 | void __devexit dwc3_debugfs_exit(struct dwc3 *dwc) | 706 | void dwc3_debugfs_exit(struct dwc3 *dwc) |
| 707 | { | 707 | { |
| 708 | debugfs_remove_recursive(dwc->root); | 708 | debugfs_remove_recursive(dwc->root); |
| 709 | dwc->root = NULL; | 709 | dwc->root = NULL; |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index ca6597853f90..aae5328ac771 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 | ||
| @@ -33,7 +34,7 @@ struct dwc3_exynos { | |||
| 33 | struct clk *clk; | 34 | struct clk *clk; |
| 34 | }; | 35 | }; |
| 35 | 36 | ||
| 36 | static int __devinit dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | 37 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) |
| 37 | { | 38 | { |
| 38 | struct nop_usb_xceiv_platform_data pdata; | 39 | struct nop_usb_xceiv_platform_data pdata; |
| 39 | struct platform_device *pdev; | 40 | struct platform_device *pdev; |
| @@ -87,14 +88,14 @@ err1: | |||
| 87 | return ret; | 88 | return ret; |
| 88 | } | 89 | } |
| 89 | 90 | ||
| 90 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | 91 | static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); |
| 92 | |||
| 93 | static int 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,35 +160,24 @@ 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: |
| 178 | return ret; | 170 | return ret; |
| 179 | } | 171 | } |
| 180 | 172 | ||
| 181 | static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | 173 | static int 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 = 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..f31867fd2574 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
| @@ -157,7 +157,7 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value) | |||
| 157 | writel(value, base + offset); | 157 | writel(value, base + offset); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | static int __devinit dwc3_omap_register_phys(struct dwc3_omap *omap) | 160 | static int dwc3_omap_register_phys(struct dwc3_omap *omap) |
| 161 | { | 161 | { |
| 162 | struct nop_usb_xceiv_platform_data pdata; | 162 | struct nop_usb_xceiv_platform_data pdata; |
| 163 | struct platform_device *pdev; | 163 | struct platform_device *pdev; |
| @@ -262,7 +262,7 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) | |||
| 262 | return IRQ_HANDLED; | 262 | return IRQ_HANDLED; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | static int __devinit dwc3_omap_probe(struct platform_device *pdev) | 265 | static int dwc3_omap_probe(struct platform_device *pdev) |
| 266 | { | 266 | { |
| 267 | struct dwc3_omap_data *pdata = pdev->dev.platform_data; | 267 | struct dwc3_omap_data *pdata = pdev->dev.platform_data; |
| 268 | struct device_node *node = pdev->dev.of_node; | 268 | struct device_node *node = pdev->dev.of_node; |
| @@ -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,23 +418,16 @@ 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 | ||
| 433 | static int __devexit dwc3_omap_remove(struct platform_device *pdev) | 424 | static int dwc3_omap_remove(struct platform_device *pdev) |
| 434 | { | 425 | { |
| 435 | struct dwc3_omap *omap = platform_get_drvdata(pdev); | 426 | struct dwc3_omap *omap = platform_get_drvdata(pdev); |
| 436 | 427 | ||
| 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 | ||
| @@ -453,7 +441,7 @@ MODULE_DEVICE_TABLE(of, of_dwc3_matach); | |||
| 453 | 441 | ||
| 454 | static struct platform_driver dwc3_omap_driver = { | 442 | static struct platform_driver dwc3_omap_driver = { |
| 455 | .probe = dwc3_omap_probe, | 443 | .probe = dwc3_omap_probe, |
| 456 | .remove = __devexit_p(dwc3_omap_remove), | 444 | .remove = dwc3_omap_remove, |
| 457 | .driver = { | 445 | .driver = { |
| 458 | .name = "omap-dwc3", | 446 | .name = "omap-dwc3", |
| 459 | .of_match_table = of_dwc3_matach, | 447 | .of_match_table = of_dwc3_matach, |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 94f550e37f98..7d70f44567d2 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
| @@ -58,7 +58,7 @@ struct dwc3_pci { | |||
| 58 | struct platform_device *usb3_phy; | 58 | struct platform_device *usb3_phy; |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | static int __devinit dwc3_pci_register_phys(struct dwc3_pci *glue) | 61 | static int dwc3_pci_register_phys(struct dwc3_pci *glue) |
| 62 | { | 62 | { |
| 63 | struct nop_usb_xceiv_platform_data pdata; | 63 | struct nop_usb_xceiv_platform_data pdata; |
| 64 | struct platform_device *pdev; | 64 | struct platform_device *pdev; |
| @@ -112,14 +112,13 @@ err1: | |||
| 112 | return ret; | 112 | return ret; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, | 115 | static int dwc3_pci_probe(struct pci_dev *pci, |
| 116 | const struct pci_device_id *id) | 116 | const struct pci_device_id *id) |
| 117 | { | 117 | { |
| 118 | struct resource res[2]; | 118 | struct resource res[2]; |
| 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,23 +188,18 @@ 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 | ||
| 205 | return ret; | 194 | return ret; |
| 206 | } | 195 | } |
| 207 | 196 | ||
| 208 | static void __devexit dwc3_pci_remove(struct pci_dev *pci) | 197 | static void dwc3_pci_remove(struct pci_dev *pci) |
| 209 | { | 198 | { |
| 210 | struct dwc3_pci *glue = pci_get_drvdata(pci); | 199 | struct dwc3_pci *glue = pci_get_drvdata(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); |
| @@ -230,7 +218,7 @@ static struct pci_driver dwc3_pci_driver = { | |||
| 230 | .name = "dwc3-pci", | 218 | .name = "dwc3-pci", |
| 231 | .id_table = dwc3_pci_id_table, | 219 | .id_table = dwc3_pci_id_table, |
| 232 | .probe = dwc3_pci_probe, | 220 | .probe = dwc3_pci_probe, |
| 233 | .remove = __devexit_p(dwc3_pci_remove), | 221 | .remove = dwc3_pci_remove, |
| 234 | }; | 222 | }; |
| 235 | 223 | ||
| 236 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 224 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 7b7deddf6a52..2e43b332aae8 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
| @@ -1579,7 +1579,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { | |||
| 1579 | 1579 | ||
| 1580 | /* -------------------------------------------------------------------------- */ | 1580 | /* -------------------------------------------------------------------------- */ |
| 1581 | 1581 | ||
| 1582 | static int __devinit dwc3_gadget_init_endpoints(struct dwc3 *dwc) | 1582 | static int dwc3_gadget_init_endpoints(struct dwc3 *dwc) |
| 1583 | { | 1583 | { |
| 1584 | struct dwc3_ep *dep; | 1584 | struct dwc3_ep *dep; |
| 1585 | u8 epnum; | 1585 | u8 epnum; |
| @@ -2374,7 +2374,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
| 2374 | * | 2374 | * |
| 2375 | * Returns 0 on success otherwise negative errno. | 2375 | * Returns 0 on success otherwise negative errno. |
| 2376 | */ | 2376 | */ |
| 2377 | int __devinit dwc3_gadget_init(struct dwc3 *dwc) | 2377 | int dwc3_gadget_init(struct dwc3 *dwc) |
| 2378 | { | 2378 | { |
| 2379 | u32 reg; | 2379 | u32 reg; |
| 2380 | int ret; | 2380 | int ret; |
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/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index fc0ec5e0d58e..d9f6b9372491 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
| @@ -3231,7 +3231,7 @@ static int udc_pci_probe( | |||
| 3231 | } | 3231 | } |
| 3232 | 3232 | ||
| 3233 | if (!pdev->irq) { | 3233 | if (!pdev->irq) { |
| 3234 | dev_err(&dev->pdev->dev, "irq not set\n"); | 3234 | dev_err(&pdev->dev, "irq not set\n"); |
| 3235 | kfree(dev); | 3235 | kfree(dev); |
| 3236 | dev = NULL; | 3236 | dev = NULL; |
| 3237 | retval = -ENODEV; | 3237 | retval = -ENODEV; |
| @@ -3250,7 +3250,7 @@ static int udc_pci_probe( | |||
| 3250 | dev->txfifo = (u32 __iomem *)(dev->virt_addr + UDC_TXFIFO_ADDR); | 3250 | dev->txfifo = (u32 __iomem *)(dev->virt_addr + UDC_TXFIFO_ADDR); |
| 3251 | 3251 | ||
| 3252 | if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { | 3252 | if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { |
| 3253 | dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); | 3253 | dev_dbg(&pdev->dev, "request_irq(%d) fail\n", pdev->irq); |
| 3254 | kfree(dev); | 3254 | kfree(dev); |
| 3255 | dev = NULL; | 3255 | dev = NULL; |
| 3256 | retval = -EBUSY; | 3256 | retval = -EBUSY; |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 89d90b5fb787..f4a21f6f081f 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <linux/usb/gadget.h> | 31 | #include <linux/usb/gadget.h> |
| 32 | #include <linux/of.h> | 32 | #include <linux/of.h> |
| 33 | #include <linux/of_gpio.h> | 33 | #include <linux/of_gpio.h> |
| 34 | #include <linux/platform_data/atmel.h> | ||
| 34 | 35 | ||
| 35 | #include <asm/byteorder.h> | 36 | #include <asm/byteorder.h> |
| 36 | #include <mach/hardware.h> | 37 | #include <mach/hardware.h> |
| @@ -38,7 +39,6 @@ | |||
| 38 | #include <asm/irq.h> | 39 | #include <asm/irq.h> |
| 39 | #include <asm/gpio.h> | 40 | #include <asm/gpio.h> |
| 40 | 41 | ||
| 41 | #include <mach/board.h> | ||
| 42 | #include <mach/cpu.h> | 42 | #include <mach/cpu.h> |
| 43 | #include <mach/at91sam9261_matrix.h> | 43 | #include <mach/at91sam9261_matrix.h> |
| 44 | #include <mach/at91_matrix.h> | 44 | #include <mach/at91_matrix.h> |
| @@ -51,7 +51,7 @@ | |||
| 51 | * full speed USB controllers, including the at91rm9200 (arm920T, with MMU), | 51 | * full speed USB controllers, including the at91rm9200 (arm920T, with MMU), |
| 52 | * at91sam926x (arm926ejs, with MMU), and several no-mmu versions. | 52 | * at91sam926x (arm926ejs, with MMU), and several no-mmu versions. |
| 53 | * | 53 | * |
| 54 | * This driver expects the board has been wired with two GPIOs suppporting | 54 | * This driver expects the board has been wired with two GPIOs supporting |
| 55 | * a VBUS sensing IRQ, and a D+ pullup. (They may be omitted, but the | 55 | * a VBUS sensing IRQ, and a D+ pullup. (They may be omitted, but the |
| 56 | * testing hasn't covered such cases.) | 56 | * testing hasn't covered such cases.) |
| 57 | * | 57 | * |
| @@ -1673,7 +1673,7 @@ static void at91udc_shutdown(struct platform_device *dev) | |||
| 1673 | spin_unlock_irqrestore(&udc->lock, flags); | 1673 | spin_unlock_irqrestore(&udc->lock, flags); |
| 1674 | } | 1674 | } |
| 1675 | 1675 | ||
| 1676 | static void __devinit at91udc_of_init(struct at91_udc *udc, | 1676 | static void at91udc_of_init(struct at91_udc *udc, |
| 1677 | struct device_node *np) | 1677 | struct device_node *np) |
| 1678 | { | 1678 | { |
| 1679 | struct at91_udc_data *board = &udc->board; | 1679 | struct at91_udc_data *board = &udc->board; |
| @@ -1693,7 +1693,7 @@ static void __devinit at91udc_of_init(struct at91_udc *udc, | |||
| 1693 | board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0; | 1693 | board->pullup_active_low = (flags & OF_GPIO_ACTIVE_LOW) ? 1 : 0; |
| 1694 | } | 1694 | } |
| 1695 | 1695 | ||
| 1696 | static int __devinit at91udc_probe(struct platform_device *pdev) | 1696 | static int at91udc_probe(struct platform_device *pdev) |
| 1697 | { | 1697 | { |
| 1698 | struct device *dev = &pdev->dev; | 1698 | struct device *dev = &pdev->dev; |
| 1699 | struct at91_udc *udc; | 1699 | struct at91_udc *udc; |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 9a9bced813ed..a7aed84d98c9 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
| @@ -21,9 +21,9 @@ | |||
| 21 | #include <linux/usb/gadget.h> | 21 | #include <linux/usb/gadget.h> |
| 22 | #include <linux/usb/atmel_usba_udc.h> | 22 | #include <linux/usb/atmel_usba_udc.h> |
| 23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
| 24 | #include <linux/platform_data/atmel.h> | ||
| 24 | 25 | ||
| 25 | #include <asm/gpio.h> | 26 | #include <asm/gpio.h> |
| 26 | #include <mach/board.h> | ||
| 27 | 27 | ||
| 28 | #include "atmel_usba_udc.h" | 28 | #include "atmel_usba_udc.h" |
| 29 | 29 | ||
diff --git a/drivers/usb/gadget/bcm63xx_udc.c b/drivers/usb/gadget/bcm63xx_udc.c index 9ca792224cd4..47a49931361e 100644 --- a/drivers/usb/gadget/bcm63xx_udc.c +++ b/drivers/usb/gadget/bcm63xx_udc.c | |||
| @@ -2323,7 +2323,7 @@ static void bcm63xx_udc_gadget_release(struct device *dev) | |||
| 2323 | * Note that platform data is required, because pd.port_no varies from chip | 2323 | * Note that platform data is required, because pd.port_no varies from chip |
| 2324 | * to chip and is used to switch the correct USB port to device mode. | 2324 | * to chip and is used to switch the correct USB port to device mode. |
| 2325 | */ | 2325 | */ |
| 2326 | static int __devinit bcm63xx_udc_probe(struct platform_device *pdev) | 2326 | static int bcm63xx_udc_probe(struct platform_device *pdev) |
| 2327 | { | 2327 | { |
| 2328 | struct device *dev = &pdev->dev; | 2328 | struct device *dev = &pdev->dev; |
| 2329 | struct bcm63xx_usbd_platform_data *pd = dev->platform_data; | 2329 | struct bcm63xx_usbd_platform_data *pd = dev->platform_data; |
| @@ -2433,7 +2433,7 @@ out_uninit: | |||
| 2433 | * bcm63xx_udc_remove - Remove the device from the system. | 2433 | * bcm63xx_udc_remove - Remove the device from the system. |
| 2434 | * @pdev: Platform device struct from the bcm63xx BSP code. | 2434 | * @pdev: Platform device struct from the bcm63xx BSP code. |
| 2435 | */ | 2435 | */ |
| 2436 | static int __devexit bcm63xx_udc_remove(struct platform_device *pdev) | 2436 | static int bcm63xx_udc_remove(struct platform_device *pdev) |
| 2437 | { | 2437 | { |
| 2438 | struct bcm63xx_udc *udc = platform_get_drvdata(pdev); | 2438 | struct bcm63xx_udc *udc = platform_get_drvdata(pdev); |
| 2439 | 2439 | ||
| @@ -2450,7 +2450,7 @@ static int __devexit bcm63xx_udc_remove(struct platform_device *pdev) | |||
| 2450 | 2450 | ||
| 2451 | static struct platform_driver bcm63xx_udc_driver = { | 2451 | static struct platform_driver bcm63xx_udc_driver = { |
| 2452 | .probe = bcm63xx_udc_probe, | 2452 | .probe = bcm63xx_udc_probe, |
| 2453 | .remove = __devexit_p(bcm63xx_udc_remove), | 2453 | .remove = bcm63xx_udc_remove, |
| 2454 | .driver = { | 2454 | .driver = { |
| 2455 | .name = DRV_MODULE_NAME, | 2455 | .name = DRV_MODULE_NAME, |
| 2456 | .owner = THIS_MODULE, | 2456 | .owner = THIS_MODULE, |
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..8cf0c0f6fa1f 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 */ |
| @@ -126,10 +130,7 @@ static const char ep0name[] = "ep0"; | |||
| 126 | static const char *const ep_name[] = { | 130 | static const char *const ep_name[] = { |
| 127 | ep0name, /* everyone has ep0 */ | 131 | ep0name, /* everyone has ep0 */ |
| 128 | 132 | ||
| 129 | /* act like a net2280: high speed, six configurable endpoints */ | 133 | /* act like a pxa250: fifteen fixed function endpoints */ |
| 130 | "ep-a", "ep-b", "ep-c", "ep-d", "ep-e", "ep-f", | ||
| 131 | |||
| 132 | /* or like pxa250: fifteen fixed function endpoints */ | ||
| 133 | "ep1in-bulk", "ep2out-bulk", "ep3in-iso", "ep4out-iso", "ep5in-int", | 134 | "ep1in-bulk", "ep2out-bulk", "ep3in-iso", "ep4out-iso", "ep5in-int", |
| 134 | "ep6in-bulk", "ep7out-bulk", "ep8in-iso", "ep9out-iso", "ep10in-int", | 135 | "ep6in-bulk", "ep7out-bulk", "ep8in-iso", "ep9out-iso", "ep10in-int", |
| 135 | "ep11in-bulk", "ep12out-bulk", "ep13in-iso", "ep14out-iso", | 136 | "ep11in-bulk", "ep12out-bulk", "ep13in-iso", "ep14out-iso", |
| @@ -137,6 +138,10 @@ static const char *const ep_name[] = { | |||
| 137 | 138 | ||
| 138 | /* or like sa1100: two fixed function endpoints */ | 139 | /* or like sa1100: two fixed function endpoints */ |
| 139 | "ep1out-bulk", "ep2in-bulk", | 140 | "ep1out-bulk", "ep2in-bulk", |
| 141 | |||
| 142 | /* and now some generic EPs so we have enough in multi config */ | ||
| 143 | "ep3out", "ep4in", "ep5out", "ep6out", "ep7in", "ep8out", "ep9in", | ||
| 144 | "ep10out", "ep11out", "ep12in", "ep13out", "ep14in", "ep15out", | ||
| 140 | }; | 145 | }; |
| 141 | #define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name) | 146 | #define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name) |
| 142 | 147 | ||
| @@ -238,8 +243,6 @@ static inline struct dummy *gadget_dev_to_dummy(struct device *dev) | |||
| 238 | return container_of(dev, struct dummy, gadget.dev); | 243 | return container_of(dev, struct dummy, gadget.dev); |
| 239 | } | 244 | } |
| 240 | 245 | ||
| 241 | static struct dummy the_controller; | ||
| 242 | |||
| 243 | /*-------------------------------------------------------------------------*/ | 246 | /*-------------------------------------------------------------------------*/ |
| 244 | 247 | ||
| 245 | /* SLAVE/GADGET SIDE UTILITY ROUTINES */ | 248 | /* SLAVE/GADGET SIDE UTILITY ROUTINES */ |
| @@ -973,9 +976,10 @@ static void init_dummy_udc_hw(struct dummy *dum) | |||
| 973 | 976 | ||
| 974 | static int dummy_udc_probe(struct platform_device *pdev) | 977 | static int dummy_udc_probe(struct platform_device *pdev) |
| 975 | { | 978 | { |
| 976 | struct dummy *dum = &the_controller; | 979 | struct dummy *dum; |
| 977 | int rc; | 980 | int rc; |
| 978 | 981 | ||
| 982 | dum = *((void **)dev_get_platdata(&pdev->dev)); | ||
| 979 | dum->gadget.name = gadget_name; | 983 | dum->gadget.name = gadget_name; |
| 980 | dum->gadget.ops = &dummy_ops; | 984 | dum->gadget.ops = &dummy_ops; |
| 981 | dum->gadget.max_speed = USB_SPEED_SUPER; | 985 | dum->gadget.max_speed = USB_SPEED_SUPER; |
| @@ -2398,10 +2402,13 @@ static int dummy_h_get_frame(struct usb_hcd *hcd) | |||
| 2398 | 2402 | ||
| 2399 | static int dummy_setup(struct usb_hcd *hcd) | 2403 | static int dummy_setup(struct usb_hcd *hcd) |
| 2400 | { | 2404 | { |
| 2405 | struct dummy *dum; | ||
| 2406 | |||
| 2407 | dum = *((void **)dev_get_platdata(hcd->self.controller)); | ||
| 2401 | hcd->self.sg_tablesize = ~0; | 2408 | hcd->self.sg_tablesize = ~0; |
| 2402 | if (usb_hcd_is_primary_hcd(hcd)) { | 2409 | if (usb_hcd_is_primary_hcd(hcd)) { |
| 2403 | the_controller.hs_hcd = hcd_to_dummy_hcd(hcd); | 2410 | dum->hs_hcd = hcd_to_dummy_hcd(hcd); |
| 2404 | the_controller.hs_hcd->dum = &the_controller; | 2411 | dum->hs_hcd->dum = dum; |
| 2405 | /* | 2412 | /* |
| 2406 | * Mark the first roothub as being USB 2.0. | 2413 | * Mark the first roothub as being USB 2.0. |
| 2407 | * The USB 3.0 roothub will be registered later by | 2414 | * The USB 3.0 roothub will be registered later by |
| @@ -2410,8 +2417,8 @@ static int dummy_setup(struct usb_hcd *hcd) | |||
| 2410 | hcd->speed = HCD_USB2; | 2417 | hcd->speed = HCD_USB2; |
| 2411 | hcd->self.root_hub->speed = USB_SPEED_HIGH; | 2418 | hcd->self.root_hub->speed = USB_SPEED_HIGH; |
| 2412 | } else { | 2419 | } else { |
| 2413 | the_controller.ss_hcd = hcd_to_dummy_hcd(hcd); | 2420 | dum->ss_hcd = hcd_to_dummy_hcd(hcd); |
| 2414 | the_controller.ss_hcd->dum = &the_controller; | 2421 | dum->ss_hcd->dum = dum; |
| 2415 | hcd->speed = HCD_USB3; | 2422 | hcd->speed = HCD_USB3; |
| 2416 | hcd->self.root_hub->speed = USB_SPEED_SUPER; | 2423 | hcd->self.root_hub->speed = USB_SPEED_SUPER; |
| 2417 | } | 2424 | } |
| @@ -2524,11 +2531,13 @@ static struct hc_driver dummy_hcd = { | |||
| 2524 | 2531 | ||
| 2525 | static int dummy_hcd_probe(struct platform_device *pdev) | 2532 | static int dummy_hcd_probe(struct platform_device *pdev) |
| 2526 | { | 2533 | { |
| 2534 | struct dummy *dum; | ||
| 2527 | struct usb_hcd *hs_hcd; | 2535 | struct usb_hcd *hs_hcd; |
| 2528 | struct usb_hcd *ss_hcd; | 2536 | struct usb_hcd *ss_hcd; |
| 2529 | int retval; | 2537 | int retval; |
| 2530 | 2538 | ||
| 2531 | dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); | 2539 | dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); |
| 2540 | dum = *((void **)dev_get_platdata(&pdev->dev)); | ||
| 2532 | 2541 | ||
| 2533 | if (!mod_data.is_super_speed) | 2542 | if (!mod_data.is_super_speed) |
| 2534 | dummy_hcd.flags = HCD_USB2; | 2543 | dummy_hcd.flags = HCD_USB2; |
| @@ -2561,7 +2570,7 @@ dealloc_usb2_hcd: | |||
| 2561 | usb_remove_hcd(hs_hcd); | 2570 | usb_remove_hcd(hs_hcd); |
| 2562 | put_usb2_hcd: | 2571 | put_usb2_hcd: |
| 2563 | usb_put_hcd(hs_hcd); | 2572 | usb_put_hcd(hs_hcd); |
| 2564 | the_controller.hs_hcd = the_controller.ss_hcd = NULL; | 2573 | dum->hs_hcd = dum->ss_hcd = NULL; |
| 2565 | return retval; | 2574 | return retval; |
| 2566 | } | 2575 | } |
| 2567 | 2576 | ||
| @@ -2579,8 +2588,8 @@ static int dummy_hcd_remove(struct platform_device *pdev) | |||
| 2579 | usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); | 2588 | usb_remove_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); |
| 2580 | usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); | 2589 | usb_put_hcd(dummy_hcd_to_hcd(dum->hs_hcd)); |
| 2581 | 2590 | ||
| 2582 | the_controller.hs_hcd = NULL; | 2591 | dum->hs_hcd = NULL; |
| 2583 | the_controller.ss_hcd = NULL; | 2592 | dum->ss_hcd = NULL; |
| 2584 | 2593 | ||
| 2585 | return 0; | 2594 | return 0; |
| 2586 | } | 2595 | } |
| @@ -2627,13 +2636,15 @@ static struct platform_driver dummy_hcd_driver = { | |||
| 2627 | }; | 2636 | }; |
| 2628 | 2637 | ||
| 2629 | /*-------------------------------------------------------------------------*/ | 2638 | /*-------------------------------------------------------------------------*/ |
| 2630 | 2639 | #define MAX_NUM_UDC 2 | |
| 2631 | static struct platform_device *the_udc_pdev; | 2640 | static struct platform_device *the_udc_pdev[MAX_NUM_UDC]; |
| 2632 | static struct platform_device *the_hcd_pdev; | 2641 | static struct platform_device *the_hcd_pdev[MAX_NUM_UDC]; |
| 2633 | 2642 | ||
| 2634 | static int __init init(void) | 2643 | static int __init init(void) |
| 2635 | { | 2644 | { |
| 2636 | int retval = -ENOMEM; | 2645 | int retval = -ENOMEM; |
| 2646 | int i; | ||
| 2647 | struct dummy *dum[MAX_NUM_UDC]; | ||
| 2637 | 2648 | ||
| 2638 | if (usb_disabled()) | 2649 | if (usb_disabled()) |
| 2639 | return -ENODEV; | 2650 | return -ENODEV; |
| @@ -2641,65 +2652,129 @@ static int __init init(void) | |||
| 2641 | if (!mod_data.is_high_speed && mod_data.is_super_speed) | 2652 | if (!mod_data.is_high_speed && mod_data.is_super_speed) |
| 2642 | return -EINVAL; | 2653 | return -EINVAL; |
| 2643 | 2654 | ||
| 2644 | the_hcd_pdev = platform_device_alloc(driver_name, -1); | 2655 | if (mod_data.num < 1 || mod_data.num > MAX_NUM_UDC) { |
| 2645 | if (!the_hcd_pdev) | 2656 | pr_err("Number of emulated UDC must be in range of 1…%d\n", |
| 2646 | return retval; | 2657 | MAX_NUM_UDC); |
| 2647 | the_udc_pdev = platform_device_alloc(gadget_name, -1); | 2658 | return -EINVAL; |
| 2648 | if (!the_udc_pdev) | 2659 | } |
| 2649 | goto err_alloc_udc; | 2660 | |
| 2661 | for (i = 0; i < mod_data.num; i++) { | ||
| 2662 | the_hcd_pdev[i] = platform_device_alloc(driver_name, i); | ||
| 2663 | if (!the_hcd_pdev[i]) { | ||
| 2664 | i--; | ||
| 2665 | while (i >= 0) | ||
| 2666 | platform_device_put(the_hcd_pdev[i--]); | ||
| 2667 | return retval; | ||
| 2668 | } | ||
| 2669 | } | ||
| 2670 | for (i = 0; i < mod_data.num; i++) { | ||
| 2671 | the_udc_pdev[i] = platform_device_alloc(gadget_name, i); | ||
| 2672 | if (!the_udc_pdev[i]) { | ||
| 2673 | i--; | ||
| 2674 | while (i >= 0) | ||
| 2675 | platform_device_put(the_udc_pdev[i--]); | ||
| 2676 | goto err_alloc_udc; | ||
| 2677 | } | ||
| 2678 | } | ||
| 2679 | for (i = 0; i < mod_data.num; i++) { | ||
| 2680 | dum[i] = kzalloc(sizeof(struct dummy), GFP_KERNEL); | ||
| 2681 | if (!dum[i]) | ||
| 2682 | goto err_add_pdata; | ||
| 2683 | retval = platform_device_add_data(the_hcd_pdev[i], &dum[i], | ||
| 2684 | sizeof(void *)); | ||
| 2685 | if (retval) | ||
| 2686 | goto err_add_pdata; | ||
| 2687 | retval = platform_device_add_data(the_udc_pdev[i], &dum[i], | ||
| 2688 | sizeof(void *)); | ||
| 2689 | if (retval) | ||
| 2690 | goto err_add_pdata; | ||
| 2691 | } | ||
| 2650 | 2692 | ||
| 2651 | retval = platform_driver_register(&dummy_hcd_driver); | 2693 | retval = platform_driver_register(&dummy_hcd_driver); |
| 2652 | if (retval < 0) | 2694 | if (retval < 0) |
| 2653 | goto err_register_hcd_driver; | 2695 | goto err_add_pdata; |
| 2654 | retval = platform_driver_register(&dummy_udc_driver); | 2696 | retval = platform_driver_register(&dummy_udc_driver); |
| 2655 | if (retval < 0) | 2697 | if (retval < 0) |
| 2656 | goto err_register_udc_driver; | 2698 | goto err_register_udc_driver; |
| 2657 | 2699 | ||
| 2658 | retval = platform_device_add(the_hcd_pdev); | 2700 | for (i = 0; i < mod_data.num; i++) { |
| 2659 | if (retval < 0) | 2701 | retval = platform_device_add(the_hcd_pdev[i]); |
| 2660 | goto err_add_hcd; | 2702 | if (retval < 0) { |
| 2661 | if (!the_controller.hs_hcd || | 2703 | i--; |
| 2662 | (!the_controller.ss_hcd && mod_data.is_super_speed)) { | 2704 | while (i >= 0) |
| 2663 | /* | 2705 | platform_device_del(the_hcd_pdev[i--]); |
| 2664 | * The hcd was added successfully but its probe function failed | 2706 | goto err_add_hcd; |
| 2665 | * for some reason. | 2707 | } |
| 2666 | */ | ||
| 2667 | retval = -EINVAL; | ||
| 2668 | goto err_add_udc; | ||
| 2669 | } | 2708 | } |
| 2670 | retval = platform_device_add(the_udc_pdev); | 2709 | for (i = 0; i < mod_data.num; i++) { |
| 2671 | if (retval < 0) | 2710 | if (!dum[i]->hs_hcd || |
| 2672 | goto err_add_udc; | 2711 | (!dum[i]->ss_hcd && mod_data.is_super_speed)) { |
| 2673 | if (!platform_get_drvdata(the_udc_pdev)) { | 2712 | /* |
| 2674 | /* | 2713 | * The hcd was added successfully but its probe |
| 2675 | * The udc was added successfully but its probe function failed | 2714 | * function failed for some reason. |
| 2676 | * for some reason. | 2715 | */ |
| 2677 | */ | 2716 | retval = -EINVAL; |
| 2678 | retval = -EINVAL; | 2717 | goto err_add_udc; |
| 2679 | goto err_probe_udc; | 2718 | } |
| 2719 | } | ||
| 2720 | |||
| 2721 | for (i = 0; i < mod_data.num; i++) { | ||
| 2722 | retval = platform_device_add(the_udc_pdev[i]); | ||
| 2723 | if (retval < 0) { | ||
| 2724 | i--; | ||
| 2725 | while (i >= 0) | ||
| 2726 | platform_device_del(the_udc_pdev[i]); | ||
| 2727 | goto err_add_udc; | ||
| 2728 | } | ||
| 2729 | } | ||
| 2730 | |||
| 2731 | for (i = 0; i < mod_data.num; i++) { | ||
| 2732 | if (!platform_get_drvdata(the_udc_pdev[i])) { | ||
| 2733 | /* | ||
| 2734 | * The udc was added successfully but its probe | ||
| 2735 | * function failed for some reason. | ||
| 2736 | */ | ||
| 2737 | retval = -EINVAL; | ||
| 2738 | goto err_probe_udc; | ||
| 2739 | } | ||
| 2680 | } | 2740 | } |
| 2681 | return retval; | 2741 | return retval; |
| 2682 | 2742 | ||
| 2683 | err_probe_udc: | 2743 | err_probe_udc: |
| 2684 | platform_device_del(the_udc_pdev); | 2744 | for (i = 0; i < mod_data.num; i++) |
| 2745 | platform_device_del(the_udc_pdev[i]); | ||
| 2685 | err_add_udc: | 2746 | err_add_udc: |
| 2686 | platform_device_del(the_hcd_pdev); | 2747 | for (i = 0; i < mod_data.num; i++) |
| 2748 | platform_device_del(the_hcd_pdev[i]); | ||
| 2687 | err_add_hcd: | 2749 | err_add_hcd: |
| 2688 | platform_driver_unregister(&dummy_udc_driver); | 2750 | platform_driver_unregister(&dummy_udc_driver); |
| 2689 | err_register_udc_driver: | 2751 | err_register_udc_driver: |
| 2690 | platform_driver_unregister(&dummy_hcd_driver); | 2752 | platform_driver_unregister(&dummy_hcd_driver); |
| 2691 | err_register_hcd_driver: | 2753 | err_add_pdata: |
| 2692 | platform_device_put(the_udc_pdev); | 2754 | for (i = 0; i < mod_data.num; i++) |
| 2755 | kfree(dum[i]); | ||
| 2756 | for (i = 0; i < mod_data.num; i++) | ||
| 2757 | platform_device_put(the_udc_pdev[i]); | ||
| 2693 | err_alloc_udc: | 2758 | err_alloc_udc: |
| 2694 | platform_device_put(the_hcd_pdev); | 2759 | for (i = 0; i < mod_data.num; i++) |
| 2760 | platform_device_put(the_hcd_pdev[i]); | ||
| 2695 | return retval; | 2761 | return retval; |
| 2696 | } | 2762 | } |
| 2697 | module_init(init); | 2763 | module_init(init); |
| 2698 | 2764 | ||
| 2699 | static void __exit cleanup(void) | 2765 | static void __exit cleanup(void) |
| 2700 | { | 2766 | { |
| 2701 | platform_device_unregister(the_udc_pdev); | 2767 | int i; |
| 2702 | platform_device_unregister(the_hcd_pdev); | 2768 | |
| 2769 | for (i = 0; i < mod_data.num; i++) { | ||
| 2770 | struct dummy *dum; | ||
| 2771 | |||
| 2772 | dum = *((void **)dev_get_platdata(&the_udc_pdev[i]->dev)); | ||
| 2773 | |||
| 2774 | platform_device_unregister(the_udc_pdev[i]); | ||
| 2775 | platform_device_unregister(the_hcd_pdev[i]); | ||
| 2776 | kfree(dum); | ||
| 2777 | } | ||
| 2703 | platform_driver_unregister(&dummy_udc_driver); | 2778 | platform_driver_unregister(&dummy_udc_driver); |
| 2704 | platform_driver_unregister(&dummy_hcd_driver); | 2779 | platform_driver_unregister(&dummy_hcd_driver); |
| 2705 | } | 2780 | } |
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..d7da258fa3f6 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; |
| @@ -408,7 +402,7 @@ static struct snd_pcm_ops uac2_pcm_ops = { | |||
| 408 | .prepare = uac2_pcm_null, | 402 | .prepare = uac2_pcm_null, |
| 409 | }; | 403 | }; |
| 410 | 404 | ||
| 411 | static int __devinit snd_uac2_probe(struct platform_device *pdev) | 405 | static int snd_uac2_probe(struct platform_device *pdev) |
| 412 | { | 406 | { |
| 413 | struct snd_uac2_chip *uac2 = pdev_to_uac2(pdev); | 407 | struct snd_uac2_chip *uac2 = pdev_to_uac2(pdev); |
| 414 | struct snd_card *card; | 408 | struct snd_card *card; |
| @@ -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_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index b09452d6f33a..ec50f18c8890 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
| @@ -2347,7 +2347,7 @@ static int fsl_qe_stop(struct usb_gadget *gadget, | |||
| 2347 | } | 2347 | } |
| 2348 | 2348 | ||
| 2349 | /* udc structure's alloc and setup, include ep-param alloc */ | 2349 | /* udc structure's alloc and setup, include ep-param alloc */ |
| 2350 | static struct qe_udc __devinit *qe_udc_config(struct platform_device *ofdev) | 2350 | static struct qe_udc *qe_udc_config(struct platform_device *ofdev) |
| 2351 | { | 2351 | { |
| 2352 | struct qe_udc *udc; | 2352 | struct qe_udc *udc; |
| 2353 | struct device_node *np = ofdev->dev.of_node; | 2353 | struct device_node *np = ofdev->dev.of_node; |
| @@ -2402,7 +2402,7 @@ cleanup: | |||
| 2402 | } | 2402 | } |
| 2403 | 2403 | ||
| 2404 | /* USB Controller register init */ | 2404 | /* USB Controller register init */ |
| 2405 | static int __devinit qe_udc_reg_init(struct qe_udc *udc) | 2405 | static int qe_udc_reg_init(struct qe_udc *udc) |
| 2406 | { | 2406 | { |
| 2407 | struct usb_ctlr __iomem *qe_usbregs; | 2407 | struct usb_ctlr __iomem *qe_usbregs; |
| 2408 | qe_usbregs = udc->usb_regs; | 2408 | qe_usbregs = udc->usb_regs; |
| @@ -2420,7 +2420,7 @@ static int __devinit qe_udc_reg_init(struct qe_udc *udc) | |||
| 2420 | return 0; | 2420 | return 0; |
| 2421 | } | 2421 | } |
| 2422 | 2422 | ||
| 2423 | static int __devinit qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) | 2423 | static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) |
| 2424 | { | 2424 | { |
| 2425 | struct qe_ep *ep = &udc->eps[pipe_num]; | 2425 | struct qe_ep *ep = &udc->eps[pipe_num]; |
| 2426 | 2426 | ||
| @@ -2473,7 +2473,7 @@ static void qe_udc_release(struct device *dev) | |||
| 2473 | 2473 | ||
| 2474 | /* Driver probe functions */ | 2474 | /* Driver probe functions */ |
| 2475 | static const struct of_device_id qe_udc_match[]; | 2475 | static const struct of_device_id qe_udc_match[]; |
| 2476 | static int __devinit qe_udc_probe(struct platform_device *ofdev) | 2476 | static int qe_udc_probe(struct platform_device *ofdev) |
| 2477 | { | 2477 | { |
| 2478 | struct qe_udc *udc; | 2478 | struct qe_udc *udc; |
| 2479 | const struct of_device_id *match; | 2479 | const struct of_device_id *match; |
| @@ -2651,7 +2651,7 @@ static int qe_udc_resume(struct platform_device *dev) | |||
| 2651 | } | 2651 | } |
| 2652 | #endif | 2652 | #endif |
| 2653 | 2653 | ||
| 2654 | static int __devexit qe_udc_remove(struct platform_device *ofdev) | 2654 | static int qe_udc_remove(struct platform_device *ofdev) |
| 2655 | { | 2655 | { |
| 2656 | struct qe_udc *udc = dev_get_drvdata(&ofdev->dev); | 2656 | struct qe_udc *udc = dev_get_drvdata(&ofdev->dev); |
| 2657 | struct qe_ep *ep; | 2657 | struct qe_ep *ep; |
| @@ -2710,7 +2710,7 @@ static int __devexit qe_udc_remove(struct platform_device *ofdev) | |||
| 2710 | } | 2710 | } |
| 2711 | 2711 | ||
| 2712 | /*-------------------------------------------------------------------------*/ | 2712 | /*-------------------------------------------------------------------------*/ |
| 2713 | static const struct of_device_id qe_udc_match[] __devinitconst = { | 2713 | static const struct of_device_id qe_udc_match[] = { |
| 2714 | { | 2714 | { |
| 2715 | .compatible = "fsl,mpc8323-qe-usb", | 2715 | .compatible = "fsl,mpc8323-qe-usb", |
| 2716 | .data = (void *)PORT_QE, | 2716 | .data = (void *)PORT_QE, |
| @@ -2735,7 +2735,7 @@ static struct platform_driver udc_driver = { | |||
| 2735 | .of_match_table = qe_udc_match, | 2735 | .of_match_table = qe_udc_match, |
| 2736 | }, | 2736 | }, |
| 2737 | .probe = qe_udc_probe, | 2737 | .probe = qe_udc_probe, |
| 2738 | .remove = __devexit_p(qe_udc_remove), | 2738 | .remove = qe_udc_remove, |
| 2739 | #ifdef CONFIG_PM | 2739 | #ifdef CONFIG_PM |
| 2740 | .suspend = qe_udc_suspend, | 2740 | .suspend = qe_udc_suspend, |
| 2741 | .resume = qe_udc_resume, | 2741 | .resume = qe_udc_resume, |
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/hid.c b/drivers/usb/gadget/hid.c index 74130f6c12c0..c36260ea8bf2 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
| @@ -203,7 +203,7 @@ static int __init hidg_plat_driver_probe(struct platform_device *pdev) | |||
| 203 | return 0; | 203 | return 0; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | static int __devexit hidg_plat_driver_remove(struct platform_device *pdev) | 206 | static int hidg_plat_driver_remove(struct platform_device *pdev) |
| 207 | { | 207 | { |
| 208 | struct hidg_func_node *e, *n; | 208 | struct hidg_func_node *e, *n; |
| 209 | 209 | ||
| @@ -229,7 +229,7 @@ static __refdata struct usb_composite_driver hidg_driver = { | |||
| 229 | }; | 229 | }; |
| 230 | 230 | ||
| 231 | static struct platform_driver hidg_plat_driver = { | 231 | static struct platform_driver hidg_plat_driver = { |
| 232 | .remove = __devexit_p(hidg_plat_driver_remove), | 232 | .remove = hidg_plat_driver_remove, |
| 233 | .driver = { | 233 | .driver = { |
| 234 | .owner = THIS_MODULE, | 234 | .owner = THIS_MODULE, |
| 235 | .name = "hidg", | 235 | .name = "hidg", |
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..dd1c9b1fe528 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; |
| @@ -3352,7 +3352,7 @@ phy_fail: | |||
| 3352 | return retval; | 3352 | return retval; |
| 3353 | } | 3353 | } |
| 3354 | 3354 | ||
| 3355 | static int __devexit lpc32xx_udc_remove(struct platform_device *pdev) | 3355 | static int lpc32xx_udc_remove(struct platform_device *pdev) |
| 3356 | { | 3356 | { |
| 3357 | struct lpc32xx_udc *udc = platform_get_drvdata(pdev); | 3357 | struct lpc32xx_udc *udc = platform_get_drvdata(pdev); |
| 3358 | 3358 | ||
| @@ -3447,7 +3447,7 @@ MODULE_DEVICE_TABLE(of, lpc32xx_udc_of_match); | |||
| 3447 | #endif | 3447 | #endif |
| 3448 | 3448 | ||
| 3449 | static struct platform_driver lpc32xx_udc_driver = { | 3449 | static struct platform_driver lpc32xx_udc_driver = { |
| 3450 | .remove = __devexit_p(lpc32xx_udc_remove), | 3450 | .remove = lpc32xx_udc_remove, |
| 3451 | .shutdown = lpc32xx_udc_shutdown, | 3451 | .shutdown = lpc32xx_udc_shutdown, |
| 3452 | .suspend = lpc32xx_udc_suspend, | 3452 | .suspend = lpc32xx_udc_suspend, |
| 3453 | .resume = lpc32xx_udc_resume, | 3453 | .resume = lpc32xx_udc_resume, |
diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c index 8cfd5b028dbd..b5cea273c957 100644 --- a/drivers/usb/gadget/mv_u3d_core.c +++ b/drivers/usb/gadget/mv_u3d_core.c | |||
| @@ -1763,7 +1763,7 @@ static void mv_u3d_gadget_release(struct device *dev) | |||
| 1763 | dev_dbg(dev, "%s\n", __func__); | 1763 | dev_dbg(dev, "%s\n", __func__); |
| 1764 | } | 1764 | } |
| 1765 | 1765 | ||
| 1766 | static __devexit int mv_u3d_remove(struct platform_device *dev) | 1766 | static int mv_u3d_remove(struct platform_device *dev) |
| 1767 | { | 1767 | { |
| 1768 | struct mv_u3d *u3d = platform_get_drvdata(dev); | 1768 | struct mv_u3d *u3d = platform_get_drvdata(dev); |
| 1769 | 1769 | ||
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c index ea45224f78c8..6e8b1272ebce 100644 --- a/drivers/usb/gadget/mv_udc_core.c +++ b/drivers/usb/gadget/mv_udc_core.c | |||
| @@ -1012,7 +1012,7 @@ static void udc_clock_enable(struct mv_udc *udc) | |||
| 1012 | unsigned int i; | 1012 | unsigned int i; |
| 1013 | 1013 | ||
| 1014 | for (i = 0; i < udc->clknum; i++) | 1014 | for (i = 0; i < udc->clknum; i++) |
| 1015 | clk_enable(udc->clk[i]); | 1015 | clk_prepare_enable(udc->clk[i]); |
| 1016 | } | 1016 | } |
| 1017 | 1017 | ||
| 1018 | static void udc_clock_disable(struct mv_udc *udc) | 1018 | static void udc_clock_disable(struct mv_udc *udc) |
| @@ -1020,7 +1020,7 @@ static void udc_clock_disable(struct mv_udc *udc) | |||
| 1020 | unsigned int i; | 1020 | unsigned int i; |
| 1021 | 1021 | ||
| 1022 | for (i = 0; i < udc->clknum; i++) | 1022 | for (i = 0; i < udc->clknum; i++) |
| 1023 | clk_disable(udc->clk[i]); | 1023 | clk_disable_unprepare(udc->clk[i]); |
| 1024 | } | 1024 | } |
| 1025 | 1025 | ||
| 1026 | static void udc_stop(struct mv_udc *udc) | 1026 | static void udc_stop(struct mv_udc *udc) |
| @@ -2128,7 +2128,7 @@ static void gadget_release(struct device *_dev) | |||
| 2128 | complete(udc->done); | 2128 | complete(udc->done); |
| 2129 | } | 2129 | } |
| 2130 | 2130 | ||
| 2131 | static int __devexit mv_udc_remove(struct platform_device *dev) | 2131 | static int mv_udc_remove(struct platform_device *dev) |
| 2132 | { | 2132 | { |
| 2133 | struct mv_udc *udc = the_controller; | 2133 | struct mv_udc *udc = the_controller; |
| 2134 | int clk_i; | 2134 | int clk_i; |
| @@ -2188,7 +2188,7 @@ static int __devexit mv_udc_remove(struct platform_device *dev) | |||
| 2188 | return 0; | 2188 | return 0; |
| 2189 | } | 2189 | } |
| 2190 | 2190 | ||
| 2191 | static int __devinit mv_udc_probe(struct platform_device *dev) | 2191 | static int mv_udc_probe(struct platform_device *dev) |
| 2192 | { | 2192 | { |
| 2193 | struct mv_usb_platform_data *pdata = dev->dev.platform_data; | 2193 | struct mv_usb_platform_data *pdata = dev->dev.platform_data; |
| 2194 | struct mv_udc *udc; | 2194 | struct mv_udc *udc; |
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c index c009263a47e3..d226058e3b88 100644 --- a/drivers/usb/gadget/net2272.c +++ b/drivers/usb/gadget/net2272.c | |||
| @@ -2193,7 +2193,7 @@ net2272_gadget_release(struct device *_dev) | |||
| 2193 | 2193 | ||
| 2194 | /*---------------------------------------------------------------------------*/ | 2194 | /*---------------------------------------------------------------------------*/ |
| 2195 | 2195 | ||
| 2196 | static void __devexit | 2196 | static void |
| 2197 | net2272_remove(struct net2272 *dev) | 2197 | net2272_remove(struct net2272 *dev) |
| 2198 | { | 2198 | { |
| 2199 | usb_del_gadget_udc(&dev->gadget); | 2199 | usb_del_gadget_udc(&dev->gadget); |
| @@ -2215,8 +2215,7 @@ net2272_remove(struct net2272 *dev) | |||
| 2215 | dev_info(dev->dev, "unbind\n"); | 2215 | dev_info(dev->dev, "unbind\n"); |
| 2216 | } | 2216 | } |
| 2217 | 2217 | ||
| 2218 | static struct net2272 * __devinit | 2218 | static struct net2272 *net2272_probe_init(struct device *dev, unsigned int irq) |
| 2219 | net2272_probe_init(struct device *dev, unsigned int irq) | ||
| 2220 | { | 2219 | { |
| 2221 | struct net2272 *ret; | 2220 | struct net2272 *ret; |
| 2222 | 2221 | ||
| @@ -2246,7 +2245,7 @@ net2272_probe_init(struct device *dev, unsigned int irq) | |||
| 2246 | return ret; | 2245 | return ret; |
| 2247 | } | 2246 | } |
| 2248 | 2247 | ||
| 2249 | static int __devinit | 2248 | static int |
| 2250 | net2272_probe_fin(struct net2272 *dev, unsigned int irqflags) | 2249 | net2272_probe_fin(struct net2272 *dev, unsigned int irqflags) |
| 2251 | { | 2250 | { |
| 2252 | int ret; | 2251 | int ret; |
| @@ -2306,7 +2305,7 @@ err_add_udc: | |||
| 2306 | * don't respond over USB until a gadget driver binds to us | 2305 | * don't respond over USB until a gadget driver binds to us |
| 2307 | */ | 2306 | */ |
| 2308 | 2307 | ||
| 2309 | static int __devinit | 2308 | static int |
| 2310 | net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev) | 2309 | net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev) |
| 2311 | { | 2310 | { |
| 2312 | unsigned long resource, len, tmp; | 2311 | unsigned long resource, len, tmp; |
| @@ -2389,7 +2388,7 @@ net2272_rdk1_probe(struct pci_dev *pdev, struct net2272 *dev) | |||
| 2389 | return ret; | 2388 | return ret; |
| 2390 | } | 2389 | } |
| 2391 | 2390 | ||
| 2392 | static int __devinit | 2391 | static int |
| 2393 | net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev) | 2392 | net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev) |
| 2394 | { | 2393 | { |
| 2395 | unsigned long resource, len; | 2394 | unsigned long resource, len; |
| @@ -2447,7 +2446,7 @@ net2272_rdk2_probe(struct pci_dev *pdev, struct net2272 *dev) | |||
| 2447 | return ret; | 2446 | return ret; |
| 2448 | } | 2447 | } |
| 2449 | 2448 | ||
| 2450 | static int __devinit | 2449 | static int |
| 2451 | net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | 2450 | net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
| 2452 | { | 2451 | { |
| 2453 | struct net2272 *dev; | 2452 | struct net2272 *dev; |
| @@ -2489,7 +2488,7 @@ net2272_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
| 2489 | return ret; | 2488 | return ret; |
| 2490 | } | 2489 | } |
| 2491 | 2490 | ||
| 2492 | static void __devexit | 2491 | static void |
| 2493 | net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev) | 2492 | net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev) |
| 2494 | { | 2493 | { |
| 2495 | int i; | 2494 | int i; |
| @@ -2511,7 +2510,7 @@ net2272_rdk1_remove(struct pci_dev *pdev, struct net2272 *dev) | |||
| 2511 | } | 2510 | } |
| 2512 | } | 2511 | } |
| 2513 | 2512 | ||
| 2514 | static void __devexit | 2513 | static void |
| 2515 | net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev) | 2514 | net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev) |
| 2516 | { | 2515 | { |
| 2517 | int i; | 2516 | int i; |
| @@ -2530,7 +2529,7 @@ net2272_rdk2_remove(struct pci_dev *pdev, struct net2272 *dev) | |||
| 2530 | pci_resource_len(pdev, i)); | 2529 | pci_resource_len(pdev, i)); |
| 2531 | } | 2530 | } |
| 2532 | 2531 | ||
| 2533 | static void __devexit | 2532 | static void |
| 2534 | net2272_pci_remove(struct pci_dev *pdev) | 2533 | net2272_pci_remove(struct pci_dev *pdev) |
| 2535 | { | 2534 | { |
| 2536 | struct net2272 *dev = pci_get_drvdata(pdev); | 2535 | struct net2272 *dev = pci_get_drvdata(pdev); |
| @@ -2549,7 +2548,7 @@ net2272_pci_remove(struct pci_dev *pdev) | |||
| 2549 | } | 2548 | } |
| 2550 | 2549 | ||
| 2551 | /* Table of matching PCI IDs */ | 2550 | /* Table of matching PCI IDs */ |
| 2552 | static struct pci_device_id __devinitdata pci_ids[] = { | 2551 | static struct pci_device_id pci_ids[] = { |
| 2553 | { /* RDK 1 card */ | 2552 | { /* RDK 1 card */ |
| 2554 | .class = ((PCI_CLASS_BRIDGE_OTHER << 8) | 0xfe), | 2553 | .class = ((PCI_CLASS_BRIDGE_OTHER << 8) | 0xfe), |
| 2555 | .class_mask = 0, | 2554 | .class_mask = 0, |
| @@ -2575,7 +2574,7 @@ static struct pci_driver net2272_pci_driver = { | |||
| 2575 | .id_table = pci_ids, | 2574 | .id_table = pci_ids, |
| 2576 | 2575 | ||
| 2577 | .probe = net2272_pci_probe, | 2576 | .probe = net2272_pci_probe, |
| 2578 | .remove = __devexit_p(net2272_pci_remove), | 2577 | .remove = net2272_pci_remove, |
| 2579 | }; | 2578 | }; |
| 2580 | 2579 | ||
| 2581 | static int net2272_pci_register(void) | 2580 | static int net2272_pci_register(void) |
| @@ -2595,7 +2594,7 @@ static inline void net2272_pci_unregister(void) { } | |||
| 2595 | 2594 | ||
| 2596 | /*---------------------------------------------------------------------------*/ | 2595 | /*---------------------------------------------------------------------------*/ |
| 2597 | 2596 | ||
| 2598 | static int __devinit | 2597 | static int |
| 2599 | net2272_plat_probe(struct platform_device *pdev) | 2598 | net2272_plat_probe(struct platform_device *pdev) |
| 2600 | { | 2599 | { |
| 2601 | struct net2272 *dev; | 2600 | struct net2272 *dev; |
| @@ -2661,7 +2660,7 @@ net2272_plat_probe(struct platform_device *pdev) | |||
| 2661 | return ret; | 2660 | return ret; |
| 2662 | } | 2661 | } |
| 2663 | 2662 | ||
| 2664 | static int __devexit | 2663 | static int |
| 2665 | net2272_plat_remove(struct platform_device *pdev) | 2664 | net2272_plat_remove(struct platform_device *pdev) |
| 2666 | { | 2665 | { |
| 2667 | struct net2272 *dev = platform_get_drvdata(pdev); | 2666 | struct net2272 *dev = platform_get_drvdata(pdev); |
| @@ -2678,7 +2677,7 @@ net2272_plat_remove(struct platform_device *pdev) | |||
| 2678 | 2677 | ||
| 2679 | static struct platform_driver net2272_plat_driver = { | 2678 | static struct platform_driver net2272_plat_driver = { |
| 2680 | .probe = net2272_plat_probe, | 2679 | .probe = net2272_plat_probe, |
| 2681 | .remove = __devexit_p(net2272_plat_remove), | 2680 | .remove = net2272_plat_remove, |
| 2682 | .driver = { | 2681 | .driver = { |
| 2683 | .name = driver_name, | 2682 | .name = driver_name, |
| 2684 | .owner = THIS_MODULE, | 2683 | .owner = THIS_MODULE, |
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/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 2a4749c3eb3f..8bfe990caf1a 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
| @@ -44,7 +44,7 @@ | |||
| 44 | #include <asm/unaligned.h> | 44 | #include <asm/unaligned.h> |
| 45 | #include <asm/mach-types.h> | 45 | #include <asm/mach-types.h> |
| 46 | 46 | ||
| 47 | #include <plat/dma.h> | 47 | #include <linux/omap-dma.h> |
| 48 | 48 | ||
| 49 | #include <mach/usb.h> | 49 | #include <mach/usb.h> |
| 50 | 50 | ||
| @@ -61,6 +61,8 @@ | |||
| 61 | #define DRIVER_DESC "OMAP UDC driver" | 61 | #define DRIVER_DESC "OMAP UDC driver" |
| 62 | #define DRIVER_VERSION "4 October 2004" | 62 | #define DRIVER_VERSION "4 October 2004" |
| 63 | 63 | ||
| 64 | #define OMAP_DMA_USB_W2FC_TX0 29 | ||
| 65 | |||
| 64 | /* | 66 | /* |
| 65 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the | 67 | * The OMAP UDC needs _very_ early endpoint setup: before enabling the |
| 66 | * D+ pullup to allow enumeration. That's too early for the gadget | 68 | * D+ pullup to allow enumeration. That's too early for the gadget |
| @@ -2506,7 +2508,7 @@ static inline void remove_proc_file(void) {} | |||
| 2506 | * UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that | 2508 | * UDC_SYSCON_1.CFG_LOCK is set can now work. We won't use that |
| 2507 | * capability yet though. | 2509 | * capability yet though. |
| 2508 | */ | 2510 | */ |
| 2509 | static unsigned __devinit | 2511 | static unsigned |
| 2510 | omap_ep_setup(char *name, u8 addr, u8 type, | 2512 | omap_ep_setup(char *name, u8 addr, u8 type, |
| 2511 | unsigned buf, unsigned maxp, int dbuf) | 2513 | unsigned buf, unsigned maxp, int dbuf) |
| 2512 | { | 2514 | { |
| @@ -2624,7 +2626,7 @@ static void omap_udc_release(struct device *dev) | |||
| 2624 | udc = NULL; | 2626 | udc = NULL; |
| 2625 | } | 2627 | } |
| 2626 | 2628 | ||
| 2627 | static int __devinit | 2629 | static int |
| 2628 | omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) | 2630 | omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) |
| 2629 | { | 2631 | { |
| 2630 | unsigned tmp, buf; | 2632 | unsigned tmp, buf; |
| @@ -2761,7 +2763,7 @@ omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) | |||
| 2761 | return 0; | 2763 | return 0; |
| 2762 | } | 2764 | } |
| 2763 | 2765 | ||
| 2764 | static int __devinit omap_udc_probe(struct platform_device *pdev) | 2766 | static int omap_udc_probe(struct platform_device *pdev) |
| 2765 | { | 2767 | { |
| 2766 | int status = -ENODEV; | 2768 | int status = -ENODEV; |
| 2767 | int hmc; | 2769 | int hmc; |
| @@ -2974,7 +2976,7 @@ cleanup0: | |||
| 2974 | return status; | 2976 | return status; |
| 2975 | } | 2977 | } |
| 2976 | 2978 | ||
| 2977 | static int __devexit omap_udc_remove(struct platform_device *pdev) | 2979 | static int omap_udc_remove(struct platform_device *pdev) |
| 2978 | { | 2980 | { |
| 2979 | DECLARE_COMPLETION_ONSTACK(done); | 2981 | DECLARE_COMPLETION_ONSTACK(done); |
| 2980 | 2982 | ||
| @@ -3060,7 +3062,7 @@ static int omap_udc_resume(struct platform_device *dev) | |||
| 3060 | 3062 | ||
| 3061 | static struct platform_driver udc_driver = { | 3063 | static struct platform_driver udc_driver = { |
| 3062 | .probe = omap_udc_probe, | 3064 | .probe = omap_udc_probe, |
| 3063 | .remove = __devexit_p(omap_udc_remove), | 3065 | .remove = omap_udc_remove, |
| 3064 | .suspend = omap_udc_suspend, | 3066 | .suspend = omap_udc_suspend, |
| 3065 | .resume = omap_udc_resume, | 3067 | .resume = omap_udc_resume, |
| 3066 | .driver = { | 3068 | .driver = { |
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/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 8efbf08c3561..d4ca9f1f7f24 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include <linux/list.h> | 29 | #include <linux/list.h> |
| 30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
| 31 | #include <linux/mm.h> | 31 | #include <linux/mm.h> |
| 32 | #include <linux/platform_data/pxa2xx_udc.h> | ||
| 32 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
| 33 | #include <linux/dma-mapping.h> | 34 | #include <linux/dma-mapping.h> |
| 34 | #include <linux/irq.h> | 35 | #include <linux/irq.h> |
| @@ -59,9 +60,6 @@ | |||
| 59 | #include <mach/lubbock.h> | 60 | #include <mach/lubbock.h> |
| 60 | #endif | 61 | #endif |
| 61 | 62 | ||
| 62 | #include <asm/mach/udc_pxa2xx.h> | ||
| 63 | |||
| 64 | |||
| 65 | /* | 63 | /* |
| 66 | * This driver handles the USB Device Controller (UDC) in Intel's PXA 25x | 64 | * This driver handles the USB Device Controller (UDC) in Intel's PXA 25x |
| 67 | * series processors. The UDC for the IXP 4xx series is very similar. | 65 | * series processors. The UDC for the IXP 4xx series is very similar. |
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/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 6f696ee8b817..439c3f972f8c 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c | |||
| @@ -3072,7 +3072,7 @@ static struct usb_gadget_ops s3c_hsotg_gadget_ops = { | |||
| 3072 | * creation) to give to the gadget driver. Setup the endpoint name, any | 3072 | * creation) to give to the gadget driver. Setup the endpoint name, any |
| 3073 | * direction information and other state that may be required. | 3073 | * direction information and other state that may be required. |
| 3074 | */ | 3074 | */ |
| 3075 | static void __devinit s3c_hsotg_initep(struct s3c_hsotg *hsotg, | 3075 | static void s3c_hsotg_initep(struct s3c_hsotg *hsotg, |
| 3076 | struct s3c_hsotg_ep *hs_ep, | 3076 | struct s3c_hsotg_ep *hs_ep, |
| 3077 | int epnum) | 3077 | int epnum) |
| 3078 | { | 3078 | { |
| @@ -3414,7 +3414,7 @@ static const struct file_operations ep_fops = { | |||
| 3414 | * with the same name as the device itself, in case we end up | 3414 | * with the same name as the device itself, in case we end up |
| 3415 | * with multiple blocks in future systems. | 3415 | * with multiple blocks in future systems. |
| 3416 | */ | 3416 | */ |
| 3417 | static void __devinit s3c_hsotg_create_debug(struct s3c_hsotg *hsotg) | 3417 | static void s3c_hsotg_create_debug(struct s3c_hsotg *hsotg) |
| 3418 | { | 3418 | { |
| 3419 | struct dentry *root; | 3419 | struct dentry *root; |
| 3420 | unsigned epidx; | 3420 | unsigned epidx; |
| @@ -3460,7 +3460,7 @@ static void __devinit s3c_hsotg_create_debug(struct s3c_hsotg *hsotg) | |||
| 3460 | * | 3460 | * |
| 3461 | * Cleanup (remove) the debugfs files for use on module exit. | 3461 | * Cleanup (remove) the debugfs files for use on module exit. |
| 3462 | */ | 3462 | */ |
| 3463 | static void __devexit s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) | 3463 | static void s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) |
| 3464 | { | 3464 | { |
| 3465 | unsigned epidx; | 3465 | unsigned epidx; |
| 3466 | 3466 | ||
| @@ -3477,12 +3477,11 @@ static void __devexit s3c_hsotg_delete_debug(struct s3c_hsotg *hsotg) | |||
| 3477 | /** | 3477 | /** |
| 3478 | * s3c_hsotg_release - release callback for hsotg device | 3478 | * s3c_hsotg_release - release callback for hsotg device |
| 3479 | * @dev: Device to for which release is called | 3479 | * @dev: Device to for which release is called |
| 3480 | * | ||
| 3481 | * Nothing to do as the resource is allocated using devm_ API. | ||
| 3480 | */ | 3482 | */ |
| 3481 | static void s3c_hsotg_release(struct device *dev) | 3483 | static void s3c_hsotg_release(struct device *dev) |
| 3482 | { | 3484 | { |
| 3483 | struct s3c_hsotg *hsotg = dev_get_drvdata(dev); | ||
| 3484 | |||
| 3485 | kfree(hsotg); | ||
| 3486 | } | 3485 | } |
| 3487 | 3486 | ||
| 3488 | /** | 3487 | /** |
| @@ -3490,7 +3489,7 @@ static void s3c_hsotg_release(struct device *dev) | |||
| 3490 | * @pdev: The platform information for the driver | 3489 | * @pdev: The platform information for the driver |
| 3491 | */ | 3490 | */ |
| 3492 | 3491 | ||
| 3493 | static int __devinit s3c_hsotg_probe(struct platform_device *pdev) | 3492 | static int s3c_hsotg_probe(struct platform_device *pdev) |
| 3494 | { | 3493 | { |
| 3495 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; | 3494 | struct s3c_hsotg_plat *plat = pdev->dev.platform_data; |
| 3496 | struct device *dev = &pdev->dev; | 3495 | struct device *dev = &pdev->dev; |
| @@ -3675,7 +3674,7 @@ err_clk: | |||
| 3675 | * s3c_hsotg_remove - remove function for hsotg driver | 3674 | * s3c_hsotg_remove - remove function for hsotg driver |
| 3676 | * @pdev: The platform information for the driver | 3675 | * @pdev: The platform information for the driver |
| 3677 | */ | 3676 | */ |
| 3678 | static int __devexit s3c_hsotg_remove(struct platform_device *pdev) | 3677 | static int s3c_hsotg_remove(struct platform_device *pdev) |
| 3679 | { | 3678 | { |
| 3680 | struct s3c_hsotg *hsotg = platform_get_drvdata(pdev); | 3679 | struct s3c_hsotg *hsotg = platform_get_drvdata(pdev); |
| 3681 | 3680 | ||
| @@ -3708,7 +3707,7 @@ static struct platform_driver s3c_hsotg_driver = { | |||
| 3708 | .owner = THIS_MODULE, | 3707 | .owner = THIS_MODULE, |
| 3709 | }, | 3708 | }, |
| 3710 | .probe = s3c_hsotg_probe, | 3709 | .probe = s3c_hsotg_probe, |
| 3711 | .remove = __devexit_p(s3c_hsotg_remove), | 3710 | .remove = s3c_hsotg_remove, |
| 3712 | .suspend = s3c_hsotg_suspend, | 3711 | .suspend = s3c_hsotg_suspend, |
| 3713 | .resume = s3c_hsotg_resume, | 3712 | .resume = s3c_hsotg_resume, |
| 3714 | }; | 3713 | }; |
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index d8e785d4ad59..52379b11f080 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c | |||
| @@ -1261,7 +1261,7 @@ static struct usb_gadget_ops s3c_hsudc_gadget_ops = { | |||
| 1261 | .vbus_draw = s3c_hsudc_vbus_draw, | 1261 | .vbus_draw = s3c_hsudc_vbus_draw, |
| 1262 | }; | 1262 | }; |
| 1263 | 1263 | ||
| 1264 | static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | 1264 | static int s3c_hsudc_probe(struct platform_device *pdev) |
| 1265 | { | 1265 | { |
| 1266 | struct device *dev = &pdev->dev; | 1266 | struct device *dev = &pdev->dev; |
| 1267 | struct resource *res; | 1267 | struct resource *res; |
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..7cacd6ae818e 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 | ||
| @@ -1794,9 +1794,10 @@ static int tcm_usbg_drop_nexus(struct usbg_tpg *tpg) | |||
| 1794 | tpg->tpg_nexus = NULL; | 1794 | tpg->tpg_nexus = NULL; |
| 1795 | 1795 | ||
| 1796 | kfree(tv_nexus); | 1796 | kfree(tv_nexus); |
| 1797 | ret = 0; | ||
| 1797 | out: | 1798 | out: |
| 1798 | mutex_unlock(&tpg->tpg_mutex); | 1799 | mutex_unlock(&tpg->tpg_mutex); |
| 1799 | return 0; | 1800 | return ret; |
| 1800 | } | 1801 | } |
| 1801 | 1802 | ||
| 1802 | static ssize_t tcm_usbg_tpg_store_nexus( | 1803 | static ssize_t tcm_usbg_tpg_store_nexus( |
| @@ -2139,6 +2140,7 @@ static struct usb_descriptor_header *uasp_fs_function_desc[] = { | |||
| 2139 | (struct usb_descriptor_header *) &uasp_status_pipe_desc, | 2140 | (struct usb_descriptor_header *) &uasp_status_pipe_desc, |
| 2140 | (struct usb_descriptor_header *) &uasp_fs_cmd_desc, | 2141 | (struct usb_descriptor_header *) &uasp_fs_cmd_desc, |
| 2141 | (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, | 2142 | (struct usb_descriptor_header *) &uasp_cmd_pipe_desc, |
| 2143 | NULL, | ||
| 2142 | }; | 2144 | }; |
| 2143 | 2145 | ||
| 2144 | static struct usb_descriptor_header *uasp_hs_function_desc[] = { | 2146 | static struct usb_descriptor_header *uasp_hs_function_desc[] = { |
| @@ -2239,6 +2241,7 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f) | |||
| 2239 | struct usb_gadget *gadget = c->cdev->gadget; | 2241 | struct usb_gadget *gadget = c->cdev->gadget; |
| 2240 | struct usb_ep *ep; | 2242 | struct usb_ep *ep; |
| 2241 | int iface; | 2243 | int iface; |
| 2244 | int ret; | ||
| 2242 | 2245 | ||
| 2243 | iface = usb_interface_id(c, f); | 2246 | iface = usb_interface_id(c, f); |
| 2244 | if (iface < 0) | 2247 | if (iface < 0) |
| @@ -2289,6 +2292,11 @@ static int usbg_bind(struct usb_configuration *c, struct usb_function *f) | |||
| 2289 | uasp_ss_status_desc.bEndpointAddress; | 2292 | uasp_ss_status_desc.bEndpointAddress; |
| 2290 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; | 2293 | uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; |
| 2291 | 2294 | ||
| 2295 | ret = usb_assign_descriptors(f, uasp_fs_function_desc, | ||
| 2296 | uasp_hs_function_desc, uasp_ss_function_desc); | ||
| 2297 | if (ret) | ||
| 2298 | goto ep_fail; | ||
| 2299 | |||
| 2292 | return 0; | 2300 | return 0; |
| 2293 | ep_fail: | 2301 | ep_fail: |
| 2294 | pr_err("Can't claim all required eps\n"); | 2302 | pr_err("Can't claim all required eps\n"); |
| @@ -2304,6 +2312,7 @@ static void usbg_unbind(struct usb_configuration *c, struct usb_function *f) | |||
| 2304 | { | 2312 | { |
| 2305 | struct f_uas *fu = to_f_uas(f); | 2313 | struct f_uas *fu = to_f_uas(f); |
| 2306 | 2314 | ||
| 2315 | usb_free_all_descriptors(f); | ||
| 2307 | kfree(fu); | 2316 | kfree(fu); |
| 2308 | } | 2317 | } |
| 2309 | 2318 | ||
| @@ -2384,9 +2393,6 @@ static int usbg_cfg_bind(struct usb_configuration *c) | |||
| 2384 | if (!fu) | 2393 | if (!fu) |
| 2385 | return -ENOMEM; | 2394 | return -ENOMEM; |
| 2386 | fu->function.name = "Target Function"; | 2395 | 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; | 2396 | fu->function.bind = usbg_bind; |
| 2391 | fu->function.unbind = usbg_unbind; | 2397 | fu->function.unbind = usbg_unbind; |
| 2392 | fu->function.set_alt = usbg_set_alt; | 2398 | fu->function.set_alt = usbg_set_alt; |
diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index f1739526820f..598dcc1212f0 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c | |||
| @@ -887,7 +887,7 @@ static void gs_close(struct tty_struct *tty, struct file *file) | |||
| 887 | pr_debug("gs_close: ttyGS%d (%p,%p) done!\n", | 887 | pr_debug("gs_close: ttyGS%d (%p,%p) done!\n", |
| 888 | port->port_num, tty, file); | 888 | port->port_num, tty, file); |
| 889 | 889 | ||
| 890 | wake_up_interruptible(&port->port.close_wait); | 890 | wake_up(&port->port.close_wait); |
| 891 | exit: | 891 | exit: |
| 892 | spin_unlock_irq(&port->port_lock); | 892 | spin_unlock_irq(&port->port_lock); |
| 893 | } | 893 | } |
| @@ -1145,8 +1145,10 @@ int gserial_setup(struct usb_gadget *g, unsigned count) | |||
| 1145 | 1145 | ||
| 1146 | return status; | 1146 | return status; |
| 1147 | fail: | 1147 | fail: |
| 1148 | while (count--) | 1148 | while (count--) { |
| 1149 | tty_port_destroy(&ports[count].port->port); | ||
| 1149 | kfree(ports[count].port); | 1150 | kfree(ports[count].port); |
| 1151 | } | ||
| 1150 | put_tty_driver(gs_tty_driver); | 1152 | put_tty_driver(gs_tty_driver); |
| 1151 | gs_tty_driver = NULL; | 1153 | gs_tty_driver = NULL; |
| 1152 | return status; | 1154 | return status; |
| @@ -1200,6 +1202,7 @@ void gserial_cleanup(void) | |||
| 1200 | 1202 | ||
| 1201 | WARN_ON(port->port_usb != NULL); | 1203 | WARN_ON(port->port_usb != NULL); |
| 1202 | 1204 | ||
| 1205 | tty_port_destroy(&port->port); | ||
| 1203 | kfree(port); | 1206 | kfree(port); |
| 1204 | } | 1207 | } |
| 1205 | n_ports = 0; | 1208 | n_ports = 0; |
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/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c index 443da21d73ca..df13d425e9c5 100644 --- a/drivers/usb/host/bcma-hcd.c +++ b/drivers/usb/host/bcma-hcd.c | |||
| @@ -54,7 +54,7 @@ static int bcma_wait_bits(struct bcma_device *dev, u16 reg, u32 bitmask, | |||
| 54 | return -ETIMEDOUT; | 54 | return -ETIMEDOUT; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | static void __devinit bcma_hcd_4716wa(struct bcma_device *dev) | 57 | static void bcma_hcd_4716wa(struct bcma_device *dev) |
| 58 | { | 58 | { |
| 59 | #ifdef CONFIG_BCMA_DRIVER_MIPS | 59 | #ifdef CONFIG_BCMA_DRIVER_MIPS |
| 60 | /* Work around for 4716 failures. */ | 60 | /* Work around for 4716 failures. */ |
| @@ -88,7 +88,7 @@ static void __devinit bcma_hcd_4716wa(struct bcma_device *dev) | |||
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ | 90 | /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ |
| 91 | static void __devinit bcma_hcd_init_chip(struct bcma_device *dev) | 91 | static void bcma_hcd_init_chip(struct bcma_device *dev) |
| 92 | { | 92 | { |
| 93 | u32 tmp; | 93 | u32 tmp; |
| 94 | 94 | ||
| @@ -165,8 +165,7 @@ static const struct usb_ehci_pdata ehci_pdata = { | |||
| 165 | static const struct usb_ohci_pdata ohci_pdata = { | 165 | static const struct usb_ohci_pdata ohci_pdata = { |
| 166 | }; | 166 | }; |
| 167 | 167 | ||
| 168 | static struct platform_device * __devinit | 168 | static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr) |
| 169 | bcma_hcd_create_pdev(struct bcma_device *dev, bool ohci, u32 addr) | ||
| 170 | { | 169 | { |
| 171 | struct platform_device *hci_dev; | 170 | struct platform_device *hci_dev; |
| 172 | struct resource hci_res[2]; | 171 | struct resource hci_res[2]; |
| @@ -212,7 +211,7 @@ err_alloc: | |||
| 212 | return ERR_PTR(ret); | 211 | return ERR_PTR(ret); |
| 213 | } | 212 | } |
| 214 | 213 | ||
| 215 | static int __devinit bcma_hcd_probe(struct bcma_device *dev) | 214 | static int bcma_hcd_probe(struct bcma_device *dev) |
| 216 | { | 215 | { |
| 217 | int err; | 216 | int err; |
| 218 | u16 chipid_top; | 217 | u16 chipid_top; |
| @@ -266,7 +265,7 @@ err_free_usb_dev: | |||
| 266 | return err; | 265 | return err; |
| 267 | } | 266 | } |
| 268 | 267 | ||
| 269 | static void __devexit bcma_hcd_remove(struct bcma_device *dev) | 268 | static void bcma_hcd_remove(struct bcma_device *dev) |
| 270 | { | 269 | { |
| 271 | struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev); | 270 | struct bcma_hcd_device *usb_dev = bcma_get_drvdata(dev); |
| 272 | struct platform_device *ohci_dev = usb_dev->ohci_dev; | 271 | struct platform_device *ohci_dev = usb_dev->ohci_dev; |
| @@ -306,7 +305,7 @@ static int bcma_hcd_resume(struct bcma_device *dev) | |||
| 306 | #define bcma_hcd_resume NULL | 305 | #define bcma_hcd_resume NULL |
| 307 | #endif /* CONFIG_PM */ | 306 | #endif /* CONFIG_PM */ |
| 308 | 307 | ||
| 309 | static const struct bcma_device_id bcma_hcd_table[] __devinitconst = { | 308 | static const struct bcma_device_id bcma_hcd_table[] = { |
| 310 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS), | 309 | BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS), |
| 311 | BCMA_CORETABLE_END | 310 | BCMA_CORETABLE_END |
| 312 | }; | 311 | }; |
| @@ -316,7 +315,7 @@ static struct bcma_driver bcma_hcd_driver = { | |||
| 316 | .name = KBUILD_MODNAME, | 315 | .name = KBUILD_MODNAME, |
| 317 | .id_table = bcma_hcd_table, | 316 | .id_table = bcma_hcd_table, |
| 318 | .probe = bcma_hcd_probe, | 317 | .probe = bcma_hcd_probe, |
| 319 | .remove = __devexit_p(bcma_hcd_remove), | 318 | .remove = bcma_hcd_remove, |
| 320 | .shutdown = bcma_hcd_shutdown, | 319 | .shutdown = bcma_hcd_shutdown, |
| 321 | .suspend = bcma_hcd_suspend, | 320 | .suspend = bcma_hcd_suspend, |
| 322 | .resume = bcma_hcd_resume, | 321 | .resume = bcma_hcd_resume, |
diff --git a/drivers/usb/host/ehci-atmel.c b/drivers/usb/host/ehci-atmel.c index 411bb74152eb..27639487f7ac 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 = { |
| @@ -104,7 +97,7 @@ static const struct hc_driver ehci_atmel_hc_driver = { | |||
| 104 | 97 | ||
| 105 | static u64 at91_ehci_dma_mask = DMA_BIT_MASK(32); | 98 | static u64 at91_ehci_dma_mask = DMA_BIT_MASK(32); |
| 106 | 99 | ||
| 107 | static int __devinit ehci_atmel_drv_probe(struct platform_device *pdev) | 100 | static int ehci_atmel_drv_probe(struct platform_device *pdev) |
| 108 | { | 101 | { |
| 109 | struct usb_hcd *hcd; | 102 | struct usb_hcd *hcd; |
| 110 | const struct hc_driver *driver = &ehci_atmel_hc_driver; | 103 | const struct hc_driver *driver = &ehci_atmel_hc_driver; |
| @@ -189,7 +182,7 @@ fail_create_hcd: | |||
| 189 | return retval; | 182 | return retval; |
| 190 | } | 183 | } |
| 191 | 184 | ||
| 192 | static int __devexit ehci_atmel_drv_remove(struct platform_device *pdev) | 185 | static int ehci_atmel_drv_remove(struct platform_device *pdev) |
| 193 | { | 186 | { |
| 194 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 187 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 195 | 188 | ||
| @@ -214,7 +207,7 @@ MODULE_DEVICE_TABLE(of, atmel_ehci_dt_ids); | |||
| 214 | 207 | ||
| 215 | static struct platform_driver ehci_atmel_driver = { | 208 | static struct platform_driver ehci_atmel_driver = { |
| 216 | .probe = ehci_atmel_drv_probe, | 209 | .probe = ehci_atmel_drv_probe, |
| 217 | .remove = __devexit_p(ehci_atmel_drv_remove), | 210 | .remove = ehci_atmel_drv_remove, |
| 218 | .shutdown = usb_hcd_platform_shutdown, | 211 | .shutdown = usb_hcd_platform_shutdown, |
| 219 | .driver = { | 212 | .driver = { |
| 220 | .name = "atmel-ehci", | 213 | .name = "atmel-ehci", |
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..d81d2fcbff18 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
| @@ -230,7 +230,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
| 230 | 230 | ||
| 231 | switch (phy_mode) { | 231 | switch (phy_mode) { |
| 232 | case FSL_USB2_PHY_ULPI: | 232 | case FSL_USB2_PHY_ULPI: |
| 233 | if (pdata->controller_ver) { | 233 | if (pdata->have_sysif_regs && pdata->controller_ver) { |
| 234 | /* controller version 1.6 or above */ | 234 | /* controller version 1.6 or above */ |
| 235 | setbits32(non_ehci + FSL_SOC_USB_CTRL, | 235 | setbits32(non_ehci + FSL_SOC_USB_CTRL, |
| 236 | ULPI_PHY_CLK_SEL); | 236 | ULPI_PHY_CLK_SEL); |
| @@ -251,7 +251,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
| 251 | portsc |= PORT_PTS_PTW; | 251 | portsc |= PORT_PTS_PTW; |
| 252 | /* fall through */ | 252 | /* fall through */ |
| 253 | case FSL_USB2_PHY_UTMI: | 253 | case FSL_USB2_PHY_UTMI: |
| 254 | if (pdata->controller_ver) { | 254 | if (pdata->have_sysif_regs && pdata->controller_ver) { |
| 255 | /* controller version 1.6 or above */ | 255 | /* controller version 1.6 or above */ |
| 256 | setbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN); | 256 | setbits32(non_ehci + FSL_SOC_USB_CTRL, UTMI_PHY_EN); |
| 257 | mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to | 257 | mdelay(FSL_UTMI_PHY_DLY); /* Delay for UTMI PHY CLK to |
| @@ -267,7 +267,8 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
| 267 | break; | 267 | break; |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | if (pdata->controller_ver && (phy_mode == FSL_USB2_PHY_ULPI)) { | 270 | if (pdata->have_sysif_regs && pdata->controller_ver && |
| 271 | (phy_mode == FSL_USB2_PHY_ULPI)) { | ||
| 271 | /* check PHY_CLK_VALID to get phy clk valid */ | 272 | /* check PHY_CLK_VALID to get phy clk valid */ |
| 272 | if (!spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) & | 273 | if (!spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) & |
| 273 | PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0)) { | 274 | PHY_CLK_VALID, FSL_USB_PHY_CLK_TIMEOUT, 0)) { |
| @@ -278,7 +279,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd, | |||
| 278 | 279 | ||
| 279 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); | 280 | ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]); |
| 280 | 281 | ||
| 281 | if (phy_mode != FSL_USB2_PHY_ULPI) | 282 | if (phy_mode != FSL_USB2_PHY_ULPI && pdata->have_sysif_regs) |
| 282 | setbits32(non_ehci + FSL_SOC_USB_CTRL, USB_CTRL_USB_EN); | 283 | setbits32(non_ehci + FSL_SOC_USB_CTRL, USB_CTRL_USB_EN); |
| 283 | 284 | ||
| 284 | return 0; | 285 | return 0; |
| @@ -349,7 +350,6 @@ static int ehci_fsl_reinit(struct ehci_hcd *ehci) | |||
| 349 | { | 350 | { |
| 350 | if (ehci_fsl_usb_setup(ehci)) | 351 | if (ehci_fsl_usb_setup(ehci)) |
| 351 | return -EINVAL; | 352 | return -EINVAL; |
| 352 | ehci_port_power(ehci, 0); | ||
| 353 | 353 | ||
| 354 | return 0; | 354 | return 0; |
| 355 | } | 355 | } |
diff --git a/drivers/usb/host/ehci-grlib.c b/drivers/usb/host/ehci-grlib.c index 3180cb3624d9..1fc89292f5d6 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, |
| @@ -98,7 +82,7 @@ static const struct hc_driver ehci_grlib_hc_driver = { | |||
| 98 | }; | 82 | }; |
| 99 | 83 | ||
| 100 | 84 | ||
| 101 | static int __devinit ehci_hcd_grlib_probe(struct platform_device *op) | 85 | static int ehci_hcd_grlib_probe(struct platform_device *op) |
| 102 | { | 86 | { |
| 103 | struct device_node *dn = op->dev.of_node; | 87 | struct device_node *dn = op->dev.of_node; |
| 104 | struct usb_hcd *hcd; | 88 | struct usb_hcd *hcd; |
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..88a49c87e748 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 | ||
| @@ -174,7 +173,7 @@ put_hcd: | |||
| 174 | return ret; | 173 | return ret; |
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | static int __devexit ehci_msm_remove(struct platform_device *pdev) | 176 | static int ehci_msm_remove(struct platform_device *pdev) |
| 178 | { | 177 | { |
| 179 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 178 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 180 | 179 | ||
| @@ -221,7 +220,7 @@ static const struct dev_pm_ops ehci_msm_dev_pm_ops = { | |||
| 221 | 220 | ||
| 222 | static struct platform_driver ehci_msm_driver = { | 221 | static struct platform_driver ehci_msm_driver = { |
| 223 | .probe = ehci_msm_probe, | 222 | .probe = ehci_msm_probe, |
| 224 | .remove = __devexit_p(ehci_msm_remove), | 223 | .remove = ehci_msm_remove, |
| 225 | .driver = { | 224 | .driver = { |
| 226 | .name = "msm_hsusb_host", | 225 | .name = "msm_hsusb_host", |
| 227 | .pm = &ehci_msm_dev_pm_ops, | 226 | .pm = &ehci_msm_dev_pm_ops, |
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index f7bfc0b898b9..6c56297ea16b 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c | |||
| @@ -43,7 +43,7 @@ static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv) | |||
| 43 | unsigned int i; | 43 | unsigned int i; |
| 44 | 44 | ||
| 45 | for (i = 0; i < ehci_mv->clknum; i++) | 45 | for (i = 0; i < ehci_mv->clknum; i++) |
| 46 | clk_enable(ehci_mv->clk[i]); | 46 | clk_prepare_enable(ehci_mv->clk[i]); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) | 49 | static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) |
| @@ -51,7 +51,7 @@ static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) | |||
| 51 | unsigned int i; | 51 | unsigned int i; |
| 52 | 52 | ||
| 53 | for (i = 0; i < ehci_mv->clknum; i++) | 53 | for (i = 0; i < ehci_mv->clknum; i++) |
| 54 | clk_disable(ehci_mv->clk[i]); | 54 | clk_disable_unprepare(ehci_mv->clk[i]); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) | 57 | static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) |
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 4a08fc0b27c9..ec7f5d2c90de 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include <linux/usb/ulpi.h> | 24 | #include <linux/usb/ulpi.h> |
| 25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 26 | 26 | ||
| 27 | #include <mach/hardware.h> | ||
| 28 | #include <linux/platform_data/usb-ehci-mxc.h> | 27 | #include <linux/platform_data/usb-ehci-mxc.h> |
| 29 | 28 | ||
| 30 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
| @@ -39,17 +38,9 @@ struct ehci_mxc_priv { | |||
| 39 | /* called during probe() after chip reset completes */ | 38 | /* called during probe() after chip reset completes */ |
| 40 | static int ehci_mxc_setup(struct usb_hcd *hcd) | 39 | static int ehci_mxc_setup(struct usb_hcd *hcd) |
| 41 | { | 40 | { |
| 42 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
| 43 | int retval; | ||
| 44 | |||
| 45 | hcd->has_tt = 1; | 41 | hcd->has_tt = 1; |
| 46 | 42 | ||
| 47 | retval = ehci_setup(hcd); | 43 | return ehci_setup(hcd); |
| 48 | if (retval) | ||
| 49 | return retval; | ||
| 50 | |||
| 51 | ehci_port_power(ehci, 0); | ||
| 52 | return 0; | ||
| 53 | } | 44 | } |
| 54 | 45 | ||
| 55 | static const struct hc_driver ehci_mxc_hc_driver = { | 46 | 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..ac17a7c3a0cd 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c | |||
| @@ -39,12 +39,13 @@ | |||
| 39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
| 40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
| 41 | #include <linux/usb/ulpi.h> | 41 | #include <linux/usb/ulpi.h> |
| 42 | #include <plat/usb.h> | ||
| 43 | #include <linux/regulator/consumer.h> | 42 | #include <linux/regulator/consumer.h> |
| 44 | #include <linux/pm_runtime.h> | 43 | #include <linux/pm_runtime.h> |
| 45 | #include <linux/gpio.h> | 44 | #include <linux/gpio.h> |
| 46 | #include <linux/clk.h> | 45 | #include <linux/clk.h> |
| 47 | 46 | ||
| 47 | #include <linux/platform_data/usb-omap.h> | ||
| 48 | |||
| 48 | /* EHCI Register Set */ | 49 | /* EHCI Register Set */ |
| 49 | #define EHCI_INSNREG04 (0xA0) | 50 | #define EHCI_INSNREG04 (0xA0) |
| 50 | #define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5) | 51 | #define EHCI_INSNREG04_DISABLE_UNSUSPEND (1 << 5) |
| @@ -146,9 +147,6 @@ static int omap_ehci_init(struct usb_hcd *hcd) | |||
| 146 | gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); | 147 | gpio_set_value_cansleep(pdata->reset_gpio_port[1], 1); |
| 147 | } | 148 | } |
| 148 | 149 | ||
| 149 | /* root ports should always stay powered */ | ||
| 150 | ehci_port_power(ehci, 1); | ||
| 151 | |||
| 152 | return rc; | 150 | return rc; |
| 153 | } | 151 | } |
| 154 | 152 | ||
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c index 9c2717d66730..914a3ecfb5d3 100644 --- a/drivers/usb/host/ehci-orion.c +++ b/drivers/usb/host/ehci-orion.c | |||
| @@ -14,6 +14,9 @@ | |||
| 14 | #include <linux/mbus.h> | 14 | #include <linux/mbus.h> |
| 15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
| 16 | #include <linux/platform_data/usb-ehci-orion.h> | 16 | #include <linux/platform_data/usb-ehci-orion.h> |
| 17 | #include <linux/of.h> | ||
| 18 | #include <linux/of_device.h> | ||
| 19 | #include <linux/of_irq.h> | ||
| 17 | 20 | ||
| 18 | #define rdl(off) __raw_readl(hcd->regs + (off)) | 21 | #define rdl(off) __raw_readl(hcd->regs + (off)) |
| 19 | #define wrl(off, val) __raw_writel((val), hcd->regs + (off)) | 22 | #define wrl(off, val) __raw_writel((val), hcd->regs + (off)) |
| @@ -101,20 +104,6 @@ static void orion_usb_phy_v1_setup(struct usb_hcd *hcd) | |||
| 101 | wrl(USB_MODE, 0x13); | 104 | wrl(USB_MODE, 0x13); |
| 102 | } | 105 | } |
| 103 | 106 | ||
| 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 = { | 107 | static const struct hc_driver ehci_orion_hc_driver = { |
| 119 | .description = hcd_name, | 108 | .description = hcd_name, |
| 120 | .product_desc = "Marvell Orion EHCI", | 109 | .product_desc = "Marvell Orion EHCI", |
| @@ -129,7 +118,7 @@ static const struct hc_driver ehci_orion_hc_driver = { | |||
| 129 | /* | 118 | /* |
| 130 | * basic lifecycle operations | 119 | * basic lifecycle operations |
| 131 | */ | 120 | */ |
| 132 | .reset = ehci_orion_setup, | 121 | .reset = ehci_setup, |
| 133 | .start = ehci_run, | 122 | .start = ehci_run, |
| 134 | .stop = ehci_stop, | 123 | .stop = ehci_stop, |
| 135 | .shutdown = ehci_shutdown, | 124 | .shutdown = ehci_shutdown, |
| @@ -160,7 +149,7 @@ static const struct hc_driver ehci_orion_hc_driver = { | |||
| 160 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 149 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
| 161 | }; | 150 | }; |
| 162 | 151 | ||
| 163 | static void __devinit | 152 | static void |
| 164 | ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, | 153 | ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, |
| 165 | const struct mbus_dram_target_info *dram) | 154 | const struct mbus_dram_target_info *dram) |
| 166 | { | 155 | { |
| @@ -181,7 +170,9 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, | |||
| 181 | } | 170 | } |
| 182 | } | 171 | } |
| 183 | 172 | ||
| 184 | static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) | 173 | static u64 ehci_orion_dma_mask = DMA_BIT_MASK(32); |
| 174 | |||
| 175 | static int ehci_orion_drv_probe(struct platform_device *pdev) | ||
| 185 | { | 176 | { |
| 186 | struct orion_ehci_data *pd = pdev->dev.platform_data; | 177 | struct orion_ehci_data *pd = pdev->dev.platform_data; |
| 187 | const struct mbus_dram_target_info *dram; | 178 | const struct mbus_dram_target_info *dram; |
| @@ -191,13 +182,17 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) | |||
| 191 | struct clk *clk; | 182 | struct clk *clk; |
| 192 | void __iomem *regs; | 183 | void __iomem *regs; |
| 193 | int irq, err; | 184 | int irq, err; |
| 185 | enum orion_ehci_phy_ver phy_version; | ||
| 194 | 186 | ||
| 195 | if (usb_disabled()) | 187 | if (usb_disabled()) |
| 196 | return -ENODEV; | 188 | return -ENODEV; |
| 197 | 189 | ||
| 198 | pr_debug("Initializing Orion-SoC USB Host Controller\n"); | 190 | pr_debug("Initializing Orion-SoC USB Host Controller\n"); |
| 199 | 191 | ||
| 200 | irq = platform_get_irq(pdev, 0); | 192 | if (pdev->dev.of_node) |
| 193 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | ||
| 194 | else | ||
| 195 | irq = platform_get_irq(pdev, 0); | ||
| 201 | if (irq <= 0) { | 196 | if (irq <= 0) { |
| 202 | dev_err(&pdev->dev, | 197 | dev_err(&pdev->dev, |
| 203 | "Found HC with no IRQ. Check %s setup!\n", | 198 | "Found HC with no IRQ. Check %s setup!\n", |
| @@ -215,6 +210,14 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) | |||
| 215 | goto err1; | 210 | goto err1; |
| 216 | } | 211 | } |
| 217 | 212 | ||
| 213 | /* | ||
| 214 | * Right now device-tree probed devices don't get dma_mask | ||
| 215 | * set. Since shared usb code relies on it, set it here for | ||
| 216 | * now. Once we have dma capability bindings this can go away. | ||
| 217 | */ | ||
| 218 | if (!pdev->dev.dma_mask) | ||
| 219 | pdev->dev.dma_mask = &ehci_orion_dma_mask; | ||
| 220 | |||
| 218 | if (!request_mem_region(res->start, resource_size(res), | 221 | if (!request_mem_region(res->start, resource_size(res), |
| 219 | ehci_orion_hc_driver.description)) { | 222 | ehci_orion_hc_driver.description)) { |
| 220 | dev_dbg(&pdev->dev, "controller already in use\n"); | 223 | dev_dbg(&pdev->dev, "controller already in use\n"); |
| @@ -262,7 +265,12 @@ static int __devinit ehci_orion_drv_probe(struct platform_device *pdev) | |||
| 262 | /* | 265 | /* |
| 263 | * setup Orion USB controller. | 266 | * setup Orion USB controller. |
| 264 | */ | 267 | */ |
| 265 | switch (pd->phy_version) { | 268 | if (pdev->dev.of_node) |
| 269 | phy_version = EHCI_PHY_NA; | ||
| 270 | else | ||
| 271 | phy_version = pd->phy_version; | ||
| 272 | |||
| 273 | switch (phy_version) { | ||
| 266 | case EHCI_PHY_NA: /* dont change USB phy settings */ | 274 | case EHCI_PHY_NA: /* dont change USB phy settings */ |
| 267 | break; | 275 | break; |
| 268 | case EHCI_PHY_ORION: | 276 | case EHCI_PHY_ORION: |
| @@ -317,9 +325,19 @@ static int __exit ehci_orion_drv_remove(struct platform_device *pdev) | |||
| 317 | 325 | ||
| 318 | MODULE_ALIAS("platform:orion-ehci"); | 326 | MODULE_ALIAS("platform:orion-ehci"); |
| 319 | 327 | ||
| 328 | static const struct of_device_id ehci_orion_dt_ids[] = { | ||
| 329 | { .compatible = "marvell,orion-ehci", }, | ||
| 330 | {}, | ||
| 331 | }; | ||
| 332 | MODULE_DEVICE_TABLE(of, ehci_orion_dt_ids); | ||
| 333 | |||
| 320 | static struct platform_driver ehci_orion_driver = { | 334 | static struct platform_driver ehci_orion_driver = { |
| 321 | .probe = ehci_orion_drv_probe, | 335 | .probe = ehci_orion_drv_probe, |
| 322 | .remove = __exit_p(ehci_orion_drv_remove), | 336 | .remove = __exit_p(ehci_orion_drv_remove), |
| 323 | .shutdown = usb_hcd_platform_shutdown, | 337 | .shutdown = usb_hcd_platform_shutdown, |
| 324 | .driver.name = "orion-ehci", | 338 | .driver = { |
| 339 | .name = "orion-ehci", | ||
| 340 | .owner = THIS_MODULE, | ||
| 341 | .of_match_table = of_match_ptr(ehci_orion_dt_ids), | ||
| 342 | }, | ||
| 325 | }; | 343 | }; |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 2cb7d370c4ef..170b9399e09f 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; |
| @@ -192,6 +200,26 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 192 | break; | 200 | break; |
| 193 | } | 201 | } |
| 194 | 202 | ||
| 203 | /* optional debug port, normally in the first BAR */ | ||
| 204 | temp = pci_find_capability(pdev, PCI_CAP_ID_DBG); | ||
| 205 | if (temp) { | ||
| 206 | pci_read_config_dword(pdev, temp, &temp); | ||
| 207 | temp >>= 16; | ||
| 208 | if (((temp >> 13) & 7) == 1) { | ||
| 209 | u32 hcs_params = ehci_readl(ehci, | ||
| 210 | &ehci->caps->hcs_params); | ||
| 211 | |||
| 212 | temp &= 0x1fff; | ||
| 213 | ehci->debug = hcd->regs + temp; | ||
| 214 | temp = ehci_readl(ehci, &ehci->debug->control); | ||
| 215 | ehci_info(ehci, "debug port %d%s\n", | ||
| 216 | HCS_DEBUG_PORT(hcs_params), | ||
| 217 | (temp & DBGP_ENABLED) ? " IN USE" : ""); | ||
| 218 | if (!(temp & DBGP_ENABLED)) | ||
| 219 | ehci->debug = NULL; | ||
| 220 | } | ||
| 221 | } | ||
| 222 | |||
| 195 | retval = ehci_setup(hcd); | 223 | retval = ehci_setup(hcd); |
| 196 | if (retval) | 224 | if (retval) |
| 197 | return retval; | 225 | return retval; |
| @@ -203,11 +231,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 203 | break; | 231 | break; |
| 204 | case PCI_VENDOR_ID_INTEL: | 232 | case PCI_VENDOR_ID_INTEL: |
| 205 | ehci->need_io_watchdog = 0; | 233 | 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; | 234 | break; |
| 212 | case PCI_VENDOR_ID_NVIDIA: | 235 | case PCI_VENDOR_ID_NVIDIA: |
| 213 | switch (pdev->device) { | 236 | switch (pdev->device) { |
| @@ -217,8 +240,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 217 | * devices with PPCD enabled. | 240 | * devices with PPCD enabled. |
| 218 | */ | 241 | */ |
| 219 | case 0x0d9d: | 242 | case 0x0d9d: |
| 220 | ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89"); | 243 | ehci_info(ehci, "disable ppcd for nvidia mcp89\n"); |
| 221 | ehci->has_lpm = 0; | ||
| 222 | ehci->has_ppcd = 0; | 244 | ehci->has_ppcd = 0; |
| 223 | ehci->command &= ~CMD_PPCEE; | 245 | ehci->command &= ~CMD_PPCEE; |
| 224 | break; | 246 | break; |
| @@ -226,25 +248,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 226 | break; | 248 | break; |
| 227 | } | 249 | } |
| 228 | 250 | ||
| 229 | /* optional debug port, normally in the first BAR */ | ||
| 230 | temp = pci_find_capability(pdev, 0x0a); | ||
| 231 | if (temp) { | ||
| 232 | pci_read_config_dword(pdev, temp, &temp); | ||
| 233 | temp >>= 16; | ||
| 234 | if ((temp & (3 << 13)) == (1 << 13)) { | ||
| 235 | temp &= 0x1fff; | ||
| 236 | ehci->debug = hcd->regs + temp; | ||
| 237 | temp = ehci_readl(ehci, &ehci->debug->control); | ||
| 238 | ehci_info(ehci, "debug port %d%s\n", | ||
| 239 | HCS_DEBUG_PORT(ehci->hcs_params), | ||
| 240 | (temp & DBGP_ENABLED) | ||
| 241 | ? " IN USE" | ||
| 242 | : ""); | ||
| 243 | if (!(temp & DBGP_ENABLED)) | ||
| 244 | ehci->debug = NULL; | ||
| 245 | } | ||
| 246 | } | ||
| 247 | |||
| 248 | /* at least the Genesys GL880S needs fixup here */ | 251 | /* at least the Genesys GL880S needs fixup here */ |
| 249 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); | 252 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); |
| 250 | temp &= 0x0f; | 253 | temp &= 0x0f; |
| @@ -304,7 +307,6 @@ static int ehci_pci_setup(struct usb_hcd *hcd) | |||
| 304 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); | 307 | ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); |
| 305 | #endif | 308 | #endif |
| 306 | 309 | ||
| 307 | ehci_port_power(ehci, 1); | ||
| 308 | retval = ehci_pci_reinit(ehci, pdev); | 310 | retval = ehci_pci_reinit(ehci, pdev); |
| 309 | done: | 311 | done: |
| 310 | return retval; | 312 | return retval; |
| @@ -323,18 +325,14 @@ done: | |||
| 323 | * Also they depend on separate root hub suspend/resume. | 325 | * Also they depend on separate root hub suspend/resume. |
| 324 | */ | 326 | */ |
| 325 | 327 | ||
| 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) | 328 | static bool usb_is_intel_switchable_ehci(struct pci_dev *pdev) |
| 332 | { | 329 | { |
| 333 | return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && | 330 | return pdev->class == PCI_CLASS_SERIAL_USB_EHCI && |
| 334 | pdev->vendor == PCI_VENDOR_ID_INTEL && | 331 | pdev->vendor == PCI_VENDOR_ID_INTEL && |
| 335 | (pdev->device == 0x1E26 || | 332 | (pdev->device == 0x1E26 || |
| 336 | pdev->device == 0x8C2D || | 333 | pdev->device == 0x8C2D || |
| 337 | pdev->device == 0x8C26); | 334 | pdev->device == 0x8C26 || |
| 335 | pdev->device == 0x9C26); | ||
| 338 | } | 336 | } |
| 339 | 337 | ||
| 340 | static void ehci_enable_xhci_companion(void) | 338 | static void ehci_enable_xhci_companion(void) |
| @@ -378,76 +376,17 @@ static int ehci_pci_resume(struct usb_hcd *hcd, bool hibernated) | |||
| 378 | (void) ehci_pci_reinit(ehci, pdev); | 376 | (void) ehci_pci_reinit(ehci, pdev); |
| 379 | return 0; | 377 | return 0; |
| 380 | } | 378 | } |
| 381 | #endif | ||
| 382 | 379 | ||
| 383 | static int ehci_update_device(struct usb_hcd *hcd, struct usb_device *udev) | 380 | #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 | 381 | ||
| 399 | static const struct hc_driver ehci_pci_hc_driver = { | 382 | #define ehci_suspend NULL |
| 400 | .description = hcd_name, | 383 | #define ehci_pci_resume NULL |
| 401 | .product_desc = "EHCI Host Controller", | 384 | #endif /* CONFIG_PM */ |
| 402 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
| 403 | 385 | ||
| 404 | /* | 386 | 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 | 387 | ||
| 410 | /* | 388 | static const struct ehci_driver_overrides pci_overrides __initdata = { |
| 411 | * basic lifecycle operations | ||
| 412 | */ | ||
| 413 | .reset = ehci_pci_setup, | 389 | .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 | }; | 390 | }; |
| 452 | 391 | ||
| 453 | /*-------------------------------------------------------------------------*/ | 392 | /*-------------------------------------------------------------------------*/ |
| @@ -480,3 +419,31 @@ static struct pci_driver ehci_pci_driver = { | |||
| 480 | }, | 419 | }, |
| 481 | #endif | 420 | #endif |
| 482 | }; | 421 | }; |
| 422 | |||
| 423 | static int __init ehci_pci_init(void) | ||
| 424 | { | ||
| 425 | if (usb_disabled()) | ||
| 426 | return -ENODEV; | ||
| 427 | |||
| 428 | pr_info("%s: " DRIVER_DESC "\n", hcd_name); | ||
| 429 | |||
| 430 | ehci_init_driver(&ehci_pci_hc_driver, &pci_overrides); | ||
| 431 | |||
| 432 | /* Entries for the PCI suspend/resume callbacks are special */ | ||
| 433 | ehci_pci_hc_driver.pci_suspend = ehci_suspend; | ||
| 434 | ehci_pci_hc_driver.pci_resume = ehci_pci_resume; | ||
| 435 | |||
| 436 | return pci_register_driver(&ehci_pci_driver); | ||
| 437 | } | ||
| 438 | module_init(ehci_pci_init); | ||
| 439 | |||
| 440 | static void __exit ehci_pci_cleanup(void) | ||
| 441 | { | ||
| 442 | pci_unregister_driver(&ehci_pci_driver); | ||
| 443 | } | ||
| 444 | module_exit(ehci_pci_cleanup); | ||
| 445 | |||
| 446 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 447 | MODULE_AUTHOR("David Brownell"); | ||
| 448 | MODULE_AUTHOR("Alan Stern"); | ||
| 449 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 764e0100b6f4..58fa0c90c7c7 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,47 +50,18 @@ 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 ehci_platform_probe(struct platform_device *dev) |
| 82 | { | 65 | { |
| 83 | struct usb_hcd *hcd; | 66 | struct usb_hcd *hcd; |
| 84 | struct resource *res_mem; | 67 | struct resource *res_mem; |
| @@ -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: |
| @@ -153,14 +126,12 @@ err_power: | |||
| 153 | return err; | 126 | return err; |
| 154 | } | 127 | } |
| 155 | 128 | ||
| 156 | static int __devexit ehci_platform_remove(struct platform_device *dev) | 129 | static int ehci_platform_remove(struct platform_device *dev) |
| 157 | { | 130 | { |
| 158 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 131 | struct usb_hcd *hcd = platform_get_drvdata(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 | ||
| @@ -225,7 +196,7 @@ static const struct dev_pm_ops ehci_platform_pm_ops = { | |||
| 225 | static struct platform_driver ehci_platform_driver = { | 196 | static struct platform_driver ehci_platform_driver = { |
| 226 | .id_table = ehci_platform_table, | 197 | .id_table = ehci_platform_table, |
| 227 | .probe = ehci_platform_probe, | 198 | .probe = ehci_platform_probe, |
| 228 | .remove = __devexit_p(ehci_platform_remove), | 199 | .remove = ehci_platform_remove, |
| 229 | .shutdown = usb_hcd_platform_shutdown, | 200 | .shutdown = usb_hcd_platform_shutdown, |
| 230 | .driver = { | 201 | .driver = { |
| 231 | .owner = THIS_MODULE, | 202 | .owner = THIS_MODULE, |
| @@ -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-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c index fa937d05a02b..45aceefd0c2b 100644 --- a/drivers/usb/host/ehci-ppc-of.c +++ b/drivers/usb/host/ehci-ppc-of.c | |||
| @@ -71,7 +71,7 @@ static const struct hc_driver ehci_ppc_of_hc_driver = { | |||
| 71 | * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 | 71 | * Fix: Enable Break Memory Transfer (BMT) in INSNREG3 |
| 72 | */ | 72 | */ |
| 73 | #define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) | 73 | #define PPC440EPX_EHCI0_INSREG_BMT (0x1 << 0) |
| 74 | static int __devinit | 74 | static int |
| 75 | ppc44x_enable_bmt(struct device_node *dn) | 75 | ppc44x_enable_bmt(struct device_node *dn) |
| 76 | { | 76 | { |
| 77 | __iomem u32 *insreg_virt; | 77 | __iomem u32 *insreg_virt; |
| @@ -87,7 +87,7 @@ ppc44x_enable_bmt(struct device_node *dn) | |||
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | 89 | ||
| 90 | static int __devinit ehci_hcd_ppc_of_probe(struct platform_device *op) | 90 | static int ehci_hcd_ppc_of_probe(struct platform_device *op) |
| 91 | { | 91 | { |
| 92 | struct device_node *dn = op->dev.of_node; | 92 | struct device_node *dn = op->dev.of_node; |
| 93 | struct usb_hcd *hcd; | 93 | struct usb_hcd *hcd; |
diff --git a/drivers/usb/host/ehci-ps3.c b/drivers/usb/host/ehci-ps3.c index 45a356e9f138..df5925a4f0db 100644 --- a/drivers/usb/host/ehci-ps3.c +++ b/drivers/usb/host/ehci-ps3.c | |||
| @@ -93,7 +93,7 @@ static const struct hc_driver ps3_ehci_hc_driver = { | |||
| 93 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 93 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | static int __devinit ps3_ehci_probe(struct ps3_system_bus_device *dev) | 96 | static int ps3_ehci_probe(struct ps3_system_bus_device *dev) |
| 97 | { | 97 | { |
| 98 | int result; | 98 | int result; |
| 99 | struct usb_hcd *hcd; | 99 | struct usb_hcd *hcd; |
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..319dcfaa8735 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
| @@ -85,7 +85,7 @@ static void s5p_setup_vbus_gpio(struct platform_device *pdev) | |||
| 85 | 85 | ||
| 86 | static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32); | 86 | static u64 ehci_s5p_dma_mask = DMA_BIT_MASK(32); |
| 87 | 87 | ||
| 88 | static int __devinit s5p_ehci_probe(struct platform_device *pdev) | 88 | static int s5p_ehci_probe(struct platform_device *pdev) |
| 89 | { | 89 | { |
| 90 | struct s5p_ehci_platdata *pdata; | 90 | struct s5p_ehci_platdata *pdata; |
| 91 | struct s5p_ehci_hcd *s5p_ehci; | 91 | struct s5p_ehci_hcd *s5p_ehci; |
| @@ -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,13 +183,13 @@ 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; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | static int __devexit s5p_ehci_remove(struct platform_device *pdev) | 192 | static int s5p_ehci_remove(struct platform_device *pdev) |
| 193 | { | 193 | { |
| 194 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; | 194 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; |
| 195 | struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev); | 195 | struct s5p_ehci_hcd *s5p_ehci = platform_get_drvdata(pdev); |
| @@ -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); |
| @@ -274,7 +274,7 @@ MODULE_DEVICE_TABLE(of, exynos_ehci_match); | |||
| 274 | 274 | ||
| 275 | static struct platform_driver s5p_ehci_driver = { | 275 | static struct platform_driver s5p_ehci_driver = { |
| 276 | .probe = s5p_ehci_probe, | 276 | .probe = s5p_ehci_probe, |
| 277 | .remove = __devexit_p(s5p_ehci_remove), | 277 | .remove = s5p_ehci_remove, |
| 278 | .shutdown = s5p_ehci_shutdown, | 278 | .shutdown = s5p_ehci_shutdown, |
| 279 | .driver = { | 279 | .driver = { |
| 280 | .name = "s5p-ehci", | 280 | .name = "s5p-ehci", |
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..466c1bb5b967 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,17 +194,12 @@ 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 | ||
| 231 | static struct of_device_id spear_ehci_id_table[] __devinitdata = { | 202 | static struct of_device_id spear_ehci_id_table[] = { |
| 232 | { .compatible = "st,spear600-ehci", }, | 203 | { .compatible = "st,spear600-ehci", }, |
| 233 | { }, | 204 | { }, |
| 234 | }; | 205 | }; |
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 6223d1757848..acf17556bd87 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); |
| @@ -811,7 +805,7 @@ static void tegra_ehci_hcd_shutdown(struct platform_device *pdev) | |||
| 811 | hcd->driver->shutdown(hcd); | 805 | hcd->driver->shutdown(hcd); |
| 812 | } | 806 | } |
| 813 | 807 | ||
| 814 | static struct of_device_id tegra_ehci_of_match[] __devinitdata = { | 808 | static struct of_device_id tegra_ehci_of_match[] = { |
| 815 | { .compatible = "nvidia,tegra20-ehci", }, | 809 | { .compatible = "nvidia,tegra20-ehci", }, |
| 816 | { }, | 810 | { }, |
| 817 | }; | 811 | }; |
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..59e0e24c753f 100644 --- a/drivers/usb/host/ehci-w90x900.c +++ b/drivers/usb/host/ehci-w90x900.c | |||
| @@ -13,12 +13,12 @@ | |||
| 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) |
| 20 | 20 | ||
| 21 | static int __devinit usb_w90x900_probe(const struct hc_driver *driver, | 21 | static int usb_w90x900_probe(const struct hc_driver *driver, |
| 22 | struct platform_device *pdev) | 22 | struct platform_device *pdev) |
| 23 | { | 23 | { |
| 24 | struct usb_hcd *hcd; | 24 | struct usb_hcd *hcd; |
| @@ -147,7 +147,7 @@ static const struct hc_driver ehci_w90x900_hc_driver = { | |||
| 147 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 147 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
| 148 | }; | 148 | }; |
| 149 | 149 | ||
| 150 | static int __devinit ehci_w90x900_probe(struct platform_device *pdev) | 150 | static int ehci_w90x900_probe(struct platform_device *pdev) |
| 151 | { | 151 | { |
| 152 | if (usb_disabled()) | 152 | if (usb_disabled()) |
| 153 | return -ENODEV; | 153 | return -ENODEV; |
| @@ -155,7 +155,7 @@ static int __devinit ehci_w90x900_probe(struct platform_device *pdev) | |||
| 155 | return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev); | 155 | return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | static int __devexit ehci_w90x900_remove(struct platform_device *pdev) | 158 | static int ehci_w90x900_remove(struct platform_device *pdev) |
| 159 | { | 159 | { |
| 160 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 160 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 161 | 161 | ||
| @@ -166,7 +166,7 @@ static int __devexit ehci_w90x900_remove(struct platform_device *pdev) | |||
| 166 | 166 | ||
| 167 | static struct platform_driver ehci_hcd_w90x900_driver = { | 167 | static struct platform_driver ehci_hcd_w90x900_driver = { |
| 168 | .probe = ehci_w90x900_probe, | 168 | .probe = ehci_w90x900_probe, |
| 169 | .remove = __devexit_p(ehci_w90x900_remove), | 169 | .remove = ehci_w90x900_remove, |
| 170 | .driver = { | 170 | .driver = { |
| 171 | .name = "w90x900-ehci", | 171 | .name = "w90x900-ehci", |
| 172 | .owner = THIS_MODULE, | 172 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/host/ehci-xilinx-of.c b/drivers/usb/host/ehci-xilinx-of.c index 6a3f921a5d76..4f285e8e404a 100644 --- a/drivers/usb/host/ehci-xilinx-of.c +++ b/drivers/usb/host/ehci-xilinx-of.c | |||
| @@ -125,7 +125,7 @@ static const struct hc_driver ehci_xilinx_of_hc_driver = { | |||
| 125 | * as HS only or HS/FS only, it checks the configuration in the device tree | 125 | * as HS only or HS/FS only, it checks the configuration in the device tree |
| 126 | * entry, and sets an appropriate value for hcd->has_tt. | 126 | * entry, and sets an appropriate value for hcd->has_tt. |
| 127 | */ | 127 | */ |
| 128 | static int __devinit ehci_hcd_xilinx_of_probe(struct platform_device *op) | 128 | static int ehci_hcd_xilinx_of_probe(struct platform_device *op) |
| 129 | { | 129 | { |
| 130 | struct device_node *dn = op->dev.of_node; | 130 | struct device_node *dn = op->dev.of_node; |
| 131 | struct usb_hcd *hcd; | 131 | struct usb_hcd *hcd; |
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/fhci-hcd.c b/drivers/usb/host/fhci-hcd.c index 7da1a26bed2e..0b46542591ff 100644 --- a/drivers/usb/host/fhci-hcd.c +++ b/drivers/usb/host/fhci-hcd.c | |||
| @@ -561,7 +561,7 @@ static const struct hc_driver fhci_driver = { | |||
| 561 | .hub_control = fhci_hub_control, | 561 | .hub_control = fhci_hub_control, |
| 562 | }; | 562 | }; |
| 563 | 563 | ||
| 564 | static int __devinit of_fhci_probe(struct platform_device *ofdev) | 564 | static int of_fhci_probe(struct platform_device *ofdev) |
| 565 | { | 565 | { |
| 566 | struct device *dev = &ofdev->dev; | 566 | struct device *dev = &ofdev->dev; |
| 567 | struct device_node *node = dev->of_node; | 567 | struct device_node *node = dev->of_node; |
| @@ -780,7 +780,7 @@ err_regs: | |||
| 780 | return ret; | 780 | return ret; |
| 781 | } | 781 | } |
| 782 | 782 | ||
| 783 | static int __devexit fhci_remove(struct device *dev) | 783 | static int fhci_remove(struct device *dev) |
| 784 | { | 784 | { |
| 785 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 785 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| 786 | struct fhci_hcd *fhci = hcd_to_fhci(hcd); | 786 | struct fhci_hcd *fhci = hcd_to_fhci(hcd); |
| @@ -803,7 +803,7 @@ static int __devexit fhci_remove(struct device *dev) | |||
| 803 | return 0; | 803 | return 0; |
| 804 | } | 804 | } |
| 805 | 805 | ||
| 806 | static int __devexit of_fhci_remove(struct platform_device *ofdev) | 806 | static int of_fhci_remove(struct platform_device *ofdev) |
| 807 | { | 807 | { |
| 808 | return fhci_remove(&ofdev->dev); | 808 | return fhci_remove(&ofdev->dev); |
| 809 | } | 809 | } |
| @@ -821,7 +821,7 @@ static struct platform_driver of_fhci_driver = { | |||
| 821 | .of_match_table = of_fhci_match, | 821 | .of_match_table = of_fhci_match, |
| 822 | }, | 822 | }, |
| 823 | .probe = of_fhci_probe, | 823 | .probe = of_fhci_probe, |
| 824 | .remove = __devexit_p(of_fhci_remove), | 824 | .remove = of_fhci_remove, |
| 825 | }; | 825 | }; |
| 826 | 826 | ||
| 827 | module_platform_driver(of_fhci_driver); | 827 | module_platform_driver(of_fhci_driver); |
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c index 1e771292383f..11e0b79ff9d5 100644 --- a/drivers/usb/host/fsl-mph-dr-of.c +++ b/drivers/usb/host/fsl-mph-dr-of.c | |||
| @@ -24,7 +24,7 @@ struct fsl_usb2_dev_data { | |||
| 24 | enum fsl_usb2_operating_modes op_mode; /* operating mode */ | 24 | enum fsl_usb2_operating_modes op_mode; /* operating mode */ |
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | struct fsl_usb2_dev_data dr_mode_data[] __devinitdata = { | 27 | struct fsl_usb2_dev_data dr_mode_data[] = { |
| 28 | { | 28 | { |
| 29 | .dr_mode = "host", | 29 | .dr_mode = "host", |
| 30 | .drivers = { "fsl-ehci", NULL, NULL, }, | 30 | .drivers = { "fsl-ehci", NULL, NULL, }, |
| @@ -42,7 +42,7 @@ struct fsl_usb2_dev_data dr_mode_data[] __devinitdata = { | |||
| 42 | }, | 42 | }, |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node *np) | 45 | struct fsl_usb2_dev_data *get_dr_mode_data(struct device_node *np) |
| 46 | { | 46 | { |
| 47 | const unsigned char *prop; | 47 | const unsigned char *prop; |
| 48 | int i; | 48 | int i; |
| @@ -59,7 +59,7 @@ struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node *np) | |||
| 59 | return &dr_mode_data[0]; /* mode not specified, use host */ | 59 | return &dr_mode_data[0]; /* mode not specified, use host */ |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *phy_type) | 62 | static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type) |
| 63 | { | 63 | { |
| 64 | if (!phy_type) | 64 | if (!phy_type) |
| 65 | return FSL_USB2_PHY_NONE; | 65 | return FSL_USB2_PHY_NONE; |
| @@ -75,7 +75,7 @@ static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *phy_type) | |||
| 75 | return FSL_USB2_PHY_NONE; | 75 | return FSL_USB2_PHY_NONE; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | struct platform_device * __devinit fsl_usb2_device_register( | 78 | struct platform_device *fsl_usb2_device_register( |
| 79 | struct platform_device *ofdev, | 79 | struct platform_device *ofdev, |
| 80 | struct fsl_usb2_platform_data *pdata, | 80 | struct fsl_usb2_platform_data *pdata, |
| 81 | const char *name, int id) | 81 | const char *name, int id) |
| @@ -142,6 +142,9 @@ static int usb_get_ver_info(struct device_node *np) | |||
| 142 | return ver; | 142 | return ver; |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | if (of_device_is_compatible(np, "fsl,mpc5121-usb2-dr")) | ||
| 146 | return FSL_USB_VER_OLD; | ||
| 147 | |||
| 145 | if (of_device_is_compatible(np, "fsl-usb2-mph")) { | 148 | if (of_device_is_compatible(np, "fsl-usb2-mph")) { |
| 146 | if (of_device_is_compatible(np, "fsl-usb2-mph-v1.6")) | 149 | if (of_device_is_compatible(np, "fsl-usb2-mph-v1.6")) |
| 147 | ver = FSL_USB_VER_1_6; | 150 | ver = FSL_USB_VER_1_6; |
| @@ -154,7 +157,7 @@ static int usb_get_ver_info(struct device_node *np) | |||
| 154 | return ver; | 157 | return ver; |
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) | 160 | static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) |
| 158 | { | 161 | { |
| 159 | struct device_node *np = ofdev->dev.of_node; | 162 | struct device_node *np = ofdev->dev.of_node; |
| 160 | struct platform_device *usb_dev; | 163 | struct platform_device *usb_dev; |
| @@ -224,13 +227,13 @@ static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev) | |||
| 224 | return 0; | 227 | return 0; |
| 225 | } | 228 | } |
| 226 | 229 | ||
| 227 | static int __devexit __unregister_subdev(struct device *dev, void *d) | 230 | static int __unregister_subdev(struct device *dev, void *d) |
| 228 | { | 231 | { |
| 229 | platform_device_unregister(to_platform_device(dev)); | 232 | platform_device_unregister(to_platform_device(dev)); |
| 230 | return 0; | 233 | return 0; |
| 231 | } | 234 | } |
| 232 | 235 | ||
| 233 | static int __devexit fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev) | 236 | static int fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev) |
| 234 | { | 237 | { |
| 235 | device_for_each_child(&ofdev->dev, NULL, __unregister_subdev); | 238 | device_for_each_child(&ofdev->dev, NULL, __unregister_subdev); |
| 236 | return 0; | 239 | return 0; |
| @@ -336,7 +339,7 @@ static struct platform_driver fsl_usb2_mph_dr_driver = { | |||
| 336 | .of_match_table = fsl_usb2_mph_dr_of_match, | 339 | .of_match_table = fsl_usb2_mph_dr_of_match, |
| 337 | }, | 340 | }, |
| 338 | .probe = fsl_usb2_mph_dr_of_probe, | 341 | .probe = fsl_usb2_mph_dr_of_probe, |
| 339 | .remove = __devexit_p(fsl_usb2_mph_dr_of_remove), | 342 | .remove = fsl_usb2_mph_dr_of_remove, |
| 340 | }; | 343 | }; |
| 341 | 344 | ||
| 342 | module_platform_driver(fsl_usb2_mph_dr_driver); | 345 | module_platform_driver(fsl_usb2_mph_dr_driver); |
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index f19e2690c232..f0ebe8e7c58b 100644 --- a/drivers/usb/host/imx21-hcd.c +++ b/drivers/usb/host/imx21-hcd.c | |||
| @@ -58,6 +58,7 @@ | |||
| 58 | #include <linux/usb.h> | 58 | #include <linux/usb.h> |
| 59 | #include <linux/usb/hcd.h> | 59 | #include <linux/usb/hcd.h> |
| 60 | #include <linux/dma-mapping.h> | 60 | #include <linux/dma-mapping.h> |
| 61 | #include <linux/module.h> | ||
| 61 | 62 | ||
| 62 | #include "imx21-hcd.h" | 63 | #include "imx21-hcd.h" |
| 63 | 64 | ||
| @@ -1680,7 +1681,7 @@ static int imx21_hc_reset(struct usb_hcd *hcd) | |||
| 1680 | return 0; | 1681 | return 0; |
| 1681 | } | 1682 | } |
| 1682 | 1683 | ||
| 1683 | static int __devinit imx21_hc_start(struct usb_hcd *hcd) | 1684 | static int imx21_hc_start(struct usb_hcd *hcd) |
| 1684 | { | 1685 | { |
| 1685 | struct imx21 *imx21 = hcd_to_imx21(hcd); | 1686 | struct imx21 *imx21 = hcd_to_imx21(hcd); |
| 1686 | unsigned long flags; | 1687 | unsigned long flags; |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index 9e65e3091c8a..b64e661618bb 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
| @@ -1557,7 +1557,7 @@ static int isp116x_remove(struct platform_device *pdev) | |||
| 1557 | return 0; | 1557 | return 0; |
| 1558 | } | 1558 | } |
| 1559 | 1559 | ||
| 1560 | static int __devinit isp116x_probe(struct platform_device *pdev) | 1560 | static int isp116x_probe(struct platform_device *pdev) |
| 1561 | { | 1561 | { |
| 1562 | struct usb_hcd *hcd; | 1562 | struct usb_hcd *hcd; |
| 1563 | struct isp116x *isp116x; | 1563 | struct isp116x *isp116x; |
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 256326322cfd..974480c516fa 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c | |||
| @@ -2645,7 +2645,7 @@ static struct hc_driver isp1362_hc_driver = { | |||
| 2645 | 2645 | ||
| 2646 | /*-------------------------------------------------------------------------*/ | 2646 | /*-------------------------------------------------------------------------*/ |
| 2647 | 2647 | ||
| 2648 | static int __devexit isp1362_remove(struct platform_device *pdev) | 2648 | static int isp1362_remove(struct platform_device *pdev) |
| 2649 | { | 2649 | { |
| 2650 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 2650 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 2651 | struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd); | 2651 | struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd); |
| @@ -2680,7 +2680,7 @@ static int __devexit isp1362_remove(struct platform_device *pdev) | |||
| 2680 | return 0; | 2680 | return 0; |
| 2681 | } | 2681 | } |
| 2682 | 2682 | ||
| 2683 | static int __devinit isp1362_probe(struct platform_device *pdev) | 2683 | static int isp1362_probe(struct platform_device *pdev) |
| 2684 | { | 2684 | { |
| 2685 | struct usb_hcd *hcd; | 2685 | struct usb_hcd *hcd; |
| 2686 | struct isp1362_hcd *isp1362_hcd; | 2686 | struct isp1362_hcd *isp1362_hcd; |
| @@ -2856,7 +2856,7 @@ static int isp1362_resume(struct platform_device *pdev) | |||
| 2856 | 2856 | ||
| 2857 | static struct platform_driver isp1362_driver = { | 2857 | static struct platform_driver isp1362_driver = { |
| 2858 | .probe = isp1362_probe, | 2858 | .probe = isp1362_probe, |
| 2859 | .remove = __devexit_p(isp1362_remove), | 2859 | .remove = isp1362_remove, |
| 2860 | 2860 | ||
| 2861 | .suspend = isp1362_suspend, | 2861 | .suspend = isp1362_suspend, |
| 2862 | .resume = isp1362_resume, | 2862 | .resume = isp1362_resume, |
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c index fff114fd5461..bbb791bd7617 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 | ||
| @@ -175,7 +172,7 @@ static struct platform_driver isp1760_of_driver = { | |||
| 175 | #endif | 172 | #endif |
| 176 | 173 | ||
| 177 | #ifdef CONFIG_PCI | 174 | #ifdef CONFIG_PCI |
| 178 | static int __devinit isp1761_pci_probe(struct pci_dev *dev, | 175 | static int isp1761_pci_probe(struct pci_dev *dev, |
| 179 | const struct pci_device_id *id) | 176 | const struct pci_device_id *id) |
| 180 | { | 177 | { |
| 181 | u8 latency, limit; | 178 | u8 latency, limit; |
| @@ -349,7 +346,7 @@ static struct pci_driver isp1761_pci_driver = { | |||
| 349 | }; | 346 | }; |
| 350 | #endif | 347 | #endif |
| 351 | 348 | ||
| 352 | static int __devinit isp1760_plat_probe(struct platform_device *pdev) | 349 | static int isp1760_plat_probe(struct platform_device *pdev) |
| 353 | { | 350 | { |
| 354 | int ret = 0; | 351 | int ret = 0; |
| 355 | struct usb_hcd *hcd; | 352 | struct usb_hcd *hcd; |
| @@ -416,7 +413,7 @@ out: | |||
| 416 | return ret; | 413 | return ret; |
| 417 | } | 414 | } |
| 418 | 415 | ||
| 419 | static int __devexit isp1760_plat_remove(struct platform_device *pdev) | 416 | static int isp1760_plat_remove(struct platform_device *pdev) |
| 420 | { | 417 | { |
| 421 | struct resource *mem_res; | 418 | struct resource *mem_res; |
| 422 | resource_size_t mem_size; | 419 | resource_size_t mem_size; |
| @@ -435,7 +432,7 @@ static int __devexit isp1760_plat_remove(struct platform_device *pdev) | |||
| 435 | 432 | ||
| 436 | static struct platform_driver isp1760_plat_driver = { | 433 | static struct platform_driver isp1760_plat_driver = { |
| 437 | .probe = isp1760_plat_probe, | 434 | .probe = isp1760_plat_probe, |
| 438 | .remove = __devexit_p(isp1760_plat_remove), | 435 | .remove = isp1760_plat_remove, |
| 439 | .driver = { | 436 | .driver = { |
| 440 | .name = "isp1760", | 437 | .name = "isp1760", |
| 441 | }, | 438 | }, |
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c index 0bf72f943b00..a0cb44f0e724 100644 --- a/drivers/usb/host/ohci-at91.c +++ b/drivers/usb/host/ohci-at91.c | |||
| @@ -16,11 +16,11 @@ | |||
| 16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/of_platform.h> | 17 | #include <linux/of_platform.h> |
| 18 | #include <linux/of_gpio.h> | 18 | #include <linux/of_gpio.h> |
| 19 | #include <linux/platform_data/atmel.h> | ||
| 19 | 20 | ||
| 20 | #include <mach/hardware.h> | 21 | #include <mach/hardware.h> |
| 21 | #include <asm/gpio.h> | 22 | #include <asm/gpio.h> |
| 22 | 23 | ||
| 23 | #include <mach/board.h> | ||
| 24 | #include <mach/cpu.h> | 24 | #include <mach/cpu.h> |
| 25 | 25 | ||
| 26 | #ifndef CONFIG_ARCH_AT91 | 26 | #ifndef CONFIG_ARCH_AT91 |
| @@ -94,7 +94,7 @@ static void at91_stop_hc(struct platform_device *pdev) | |||
| 94 | 94 | ||
| 95 | /*-------------------------------------------------------------------------*/ | 95 | /*-------------------------------------------------------------------------*/ |
| 96 | 96 | ||
| 97 | static void __devexit usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *); | 97 | static void usb_hcd_at91_remove (struct usb_hcd *, struct platform_device *); |
| 98 | 98 | ||
| 99 | /* configure so an HC device and id are always provided */ | 99 | /* configure so an HC device and id are always provided */ |
| 100 | /* always called with process context; sleeping is OK */ | 100 | /* always called with process context; sleeping is OK */ |
| @@ -108,7 +108,7 @@ static void __devexit usb_hcd_at91_remove (struct usb_hcd *, struct platform_dev | |||
| 108 | * then invokes the start() method for the HCD associated with it | 108 | * then invokes the start() method for the HCD associated with it |
| 109 | * through the hotplug entry's driver_data. | 109 | * through the hotplug entry's driver_data. |
| 110 | */ | 110 | */ |
| 111 | static int __devinit usb_hcd_at91_probe(const struct hc_driver *driver, | 111 | static int usb_hcd_at91_probe(const struct hc_driver *driver, |
| 112 | struct platform_device *pdev) | 112 | struct platform_device *pdev) |
| 113 | { | 113 | { |
| 114 | int retval; | 114 | int retval; |
| @@ -203,7 +203,7 @@ static int __devinit usb_hcd_at91_probe(const struct hc_driver *driver, | |||
| 203 | * context, "rmmod" or something similar. | 203 | * context, "rmmod" or something similar. |
| 204 | * | 204 | * |
| 205 | */ | 205 | */ |
| 206 | static void __devexit usb_hcd_at91_remove(struct usb_hcd *hcd, | 206 | static void usb_hcd_at91_remove(struct usb_hcd *hcd, |
| 207 | struct platform_device *pdev) | 207 | struct platform_device *pdev) |
| 208 | { | 208 | { |
| 209 | usb_remove_hcd(hcd); | 209 | usb_remove_hcd(hcd); |
| @@ -222,7 +222,7 @@ static void __devexit usb_hcd_at91_remove(struct usb_hcd *hcd, | |||
| 222 | 222 | ||
| 223 | /*-------------------------------------------------------------------------*/ | 223 | /*-------------------------------------------------------------------------*/ |
| 224 | 224 | ||
| 225 | static int __devinit | 225 | static int |
| 226 | ohci_at91_reset (struct usb_hcd *hcd) | 226 | ohci_at91_reset (struct usb_hcd *hcd) |
| 227 | { | 227 | { |
| 228 | struct at91_usbh_data *board = hcd->self.controller->platform_data; | 228 | struct at91_usbh_data *board = hcd->self.controller->platform_data; |
| @@ -236,7 +236,7 @@ ohci_at91_reset (struct usb_hcd *hcd) | |||
| 236 | return 0; | 236 | return 0; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | static int __devinit | 239 | static int |
| 240 | ohci_at91_start (struct usb_hcd *hcd) | 240 | ohci_at91_start (struct usb_hcd *hcd) |
| 241 | { | 241 | { |
| 242 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 242 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| @@ -506,7 +506,7 @@ MODULE_DEVICE_TABLE(of, at91_ohci_dt_ids); | |||
| 506 | 506 | ||
| 507 | static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32); | 507 | static u64 at91_ohci_dma_mask = DMA_BIT_MASK(32); |
| 508 | 508 | ||
| 509 | static int __devinit ohci_at91_of_init(struct platform_device *pdev) | 509 | static int ohci_at91_of_init(struct platform_device *pdev) |
| 510 | { | 510 | { |
| 511 | struct device_node *np = pdev->dev.of_node; | 511 | struct device_node *np = pdev->dev.of_node; |
| 512 | int i, gpio; | 512 | int i, gpio; |
| @@ -548,7 +548,7 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev) | |||
| 548 | return 0; | 548 | return 0; |
| 549 | } | 549 | } |
| 550 | #else | 550 | #else |
| 551 | static int __devinit ohci_at91_of_init(struct platform_device *pdev) | 551 | static int ohci_at91_of_init(struct platform_device *pdev) |
| 552 | { | 552 | { |
| 553 | return 0; | 553 | return 0; |
| 554 | } | 554 | } |
| @@ -556,7 +556,7 @@ static int __devinit ohci_at91_of_init(struct platform_device *pdev) | |||
| 556 | 556 | ||
| 557 | /*-------------------------------------------------------------------------*/ | 557 | /*-------------------------------------------------------------------------*/ |
| 558 | 558 | ||
| 559 | static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev) | 559 | static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) |
| 560 | { | 560 | { |
| 561 | struct at91_usbh_data *pdata; | 561 | struct at91_usbh_data *pdata; |
| 562 | int i; | 562 | int i; |
| @@ -641,7 +641,7 @@ static int __devinit ohci_hcd_at91_drv_probe(struct platform_device *pdev) | |||
| 641 | return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); | 641 | return usb_hcd_at91_probe(&ohci_at91_hc_driver, pdev); |
| 642 | } | 642 | } |
| 643 | 643 | ||
| 644 | static int __devexit ohci_hcd_at91_drv_remove(struct platform_device *pdev) | 644 | static int ohci_hcd_at91_drv_remove(struct platform_device *pdev) |
| 645 | { | 645 | { |
| 646 | struct at91_usbh_data *pdata = pdev->dev.platform_data; | 646 | struct at91_usbh_data *pdata = pdev->dev.platform_data; |
| 647 | int i; | 647 | int i; |
| @@ -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 |
| @@ -717,7 +717,7 @@ MODULE_ALIAS("platform:at91_ohci"); | |||
| 717 | 717 | ||
| 718 | static struct platform_driver ohci_hcd_at91_driver = { | 718 | static struct platform_driver ohci_hcd_at91_driver = { |
| 719 | .probe = ohci_hcd_at91_drv_probe, | 719 | .probe = ohci_hcd_at91_drv_probe, |
| 720 | .remove = __devexit_p(ohci_hcd_at91_drv_remove), | 720 | .remove = ohci_hcd_at91_drv_remove, |
| 721 | .shutdown = usb_hcd_platform_shutdown, | 721 | .shutdown = usb_hcd_platform_shutdown, |
| 722 | .suspend = ohci_hcd_at91_drv_suspend, | 722 | .suspend = ohci_hcd_at91_drv_suspend, |
| 723 | .resume = ohci_hcd_at91_drv_resume, | 723 | .resume = ohci_hcd_at91_drv_resume, |
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..8704e9fa5a80 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
| @@ -107,7 +107,7 @@ static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd, | |||
| 107 | usb_put_hcd(hcd); | 107 | usb_put_hcd(hcd); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | static int __devinit ohci_ep93xx_start(struct usb_hcd *hcd) | 110 | static int ohci_ep93xx_start(struct usb_hcd *hcd) |
| 111 | { | 111 | { |
| 112 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 112 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 113 | int ret; | 113 | int ret; |
| @@ -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..aa3b8844bb9f 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, |
| @@ -74,7 +76,7 @@ static const struct hc_driver exynos_ohci_hc_driver = { | |||
| 74 | 76 | ||
| 75 | static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32); | 77 | static u64 ohci_exynos_dma_mask = DMA_BIT_MASK(32); |
| 76 | 78 | ||
| 77 | static int __devinit exynos_ohci_probe(struct platform_device *pdev) | 79 | static int exynos_ohci_probe(struct platform_device *pdev) |
| 78 | { | 80 | { |
| 79 | struct exynos4_ohci_platdata *pdata; | 81 | struct exynos4_ohci_platdata *pdata; |
| 80 | struct exynos_ohci_hcd *exynos_ohci; | 82 | struct exynos_ohci_hcd *exynos_ohci; |
| @@ -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,15 +169,13 @@ 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; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | static int __devexit exynos_ohci_remove(struct platform_device *pdev) | 178 | static int exynos_ohci_remove(struct platform_device *pdev) |
| 179 | { | 179 | { |
| 180 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; | 180 | struct exynos4_ohci_platdata *pdata = pdev->dev.platform_data; |
| 181 | struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); | 181 | struct exynos_ohci_hcd *exynos_ohci = platform_get_drvdata(pdev); |
| @@ -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 | } |
| @@ -279,7 +275,7 @@ MODULE_DEVICE_TABLE(of, exynos_ohci_match); | |||
| 279 | 275 | ||
| 280 | static struct platform_driver exynos_ohci_driver = { | 276 | static struct platform_driver exynos_ohci_driver = { |
| 281 | .probe = exynos_ohci_probe, | 277 | .probe = exynos_ohci_probe, |
| 282 | .remove = __devexit_p(exynos_ohci_remove), | 278 | .remove = exynos_ohci_remove, |
| 283 | .shutdown = exynos_ohci_shutdown, | 279 | .shutdown = exynos_ohci_shutdown, |
| 284 | .driver = { | 280 | .driver = { |
| 285 | .name = "exynos-ohci", | 281 | .name = "exynos-ohci", |
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-jz4740.c b/drivers/usb/host/ohci-jz4740.c index 931d588c3fb5..8062bb9dea16 100644 --- a/drivers/usb/host/ohci-jz4740.c +++ b/drivers/usb/host/ohci-jz4740.c | |||
| @@ -145,7 +145,7 @@ static const struct hc_driver ohci_jz4740_hc_driver = { | |||
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| 147 | 147 | ||
| 148 | static __devinit int jz4740_ohci_probe(struct platform_device *pdev) | 148 | static int jz4740_ohci_probe(struct platform_device *pdev) |
| 149 | { | 149 | { |
| 150 | int ret; | 150 | int ret; |
| 151 | struct usb_hcd *hcd; | 151 | struct usb_hcd *hcd; |
| @@ -239,7 +239,7 @@ err_free: | |||
| 239 | return ret; | 239 | return ret; |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static __devexit int jz4740_ohci_remove(struct platform_device *pdev) | 242 | static int jz4740_ohci_remove(struct platform_device *pdev) |
| 243 | { | 243 | { |
| 244 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 244 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 245 | struct jz4740_ohci_hcd *jz4740_ohci = hcd_to_jz4740_hcd(hcd); | 245 | struct jz4740_ohci_hcd *jz4740_ohci = hcd_to_jz4740_hcd(hcd); |
| @@ -266,7 +266,7 @@ static __devexit int jz4740_ohci_remove(struct platform_device *pdev) | |||
| 266 | 266 | ||
| 267 | static struct platform_driver ohci_hcd_jz4740_driver = { | 267 | static struct platform_driver ohci_hcd_jz4740_driver = { |
| 268 | .probe = jz4740_ohci_probe, | 268 | .probe = jz4740_ohci_probe, |
| 269 | .remove = __devexit_p(jz4740_ohci_remove), | 269 | .remove = jz4740_ohci_remove, |
| 270 | .driver = { | 270 | .driver = { |
| 271 | .name = "jz4740-ohci", | 271 | .name = "jz4740-ohci", |
| 272 | .owner = THIS_MODULE, | 272 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c index e068f034cb9b..2344040c16d2 100644 --- a/drivers/usb/host/ohci-nxp.c +++ b/drivers/usb/host/ohci-nxp.c | |||
| @@ -147,7 +147,7 @@ static void nxp_stop_hc(void) | |||
| 147 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 147 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | static int __devinit ohci_nxp_start(struct usb_hcd *hcd) | 150 | static int ohci_nxp_start(struct usb_hcd *hcd) |
| 151 | { | 151 | { |
| 152 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 152 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 153 | int ret; | 153 | int ret; |
| @@ -205,7 +205,7 @@ static const struct hc_driver ohci_nxp_hc_driver = { | |||
| 205 | .start_port_reset = ohci_start_port_reset, | 205 | .start_port_reset = ohci_start_port_reset, |
| 206 | }; | 206 | }; |
| 207 | 207 | ||
| 208 | static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) | 208 | static int usb_hcd_nxp_probe(struct platform_device *pdev) |
| 209 | { | 209 | { |
| 210 | struct usb_hcd *hcd = 0; | 210 | struct usb_hcd *hcd = 0; |
| 211 | struct ohci_hcd *ohci; | 211 | struct ohci_hcd *ohci; |
diff --git a/drivers/usb/host/ohci-octeon.c b/drivers/usb/host/ohci-octeon.c index d469bf9b9e54..d44430d009f8 100644 --- a/drivers/usb/host/ohci-octeon.c +++ b/drivers/usb/host/ohci-octeon.c | |||
| @@ -42,7 +42,7 @@ static void ohci_octeon_hw_stop(void) | |||
| 42 | octeon2_usb_clocks_stop(); | 42 | octeon2_usb_clocks_stop(); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | static int __devinit ohci_octeon_start(struct usb_hcd *hcd) | 45 | static int ohci_octeon_start(struct usb_hcd *hcd) |
| 46 | { | 46 | { |
| 47 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 47 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 48 | int ret; | 48 | int ret; |
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index 4531d03503c3..b1d32fb4a7ae 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
| @@ -25,7 +25,6 @@ | |||
| 25 | #include <asm/mach-types.h> | 25 | #include <asm/mach-types.h> |
| 26 | 26 | ||
| 27 | #include <mach/mux.h> | 27 | #include <mach/mux.h> |
| 28 | #include <plat/fpga.h> | ||
| 29 | 28 | ||
| 30 | #include <mach/hardware.h> | 29 | #include <mach/hardware.h> |
| 31 | #include <mach/irqs.h> | 30 | #include <mach/irqs.h> |
| @@ -93,14 +92,14 @@ static int omap_ohci_transceiver_power(int on) | |||
| 93 | { | 92 | { |
| 94 | if (on) { | 93 | if (on) { |
| 95 | if (machine_is_omap_innovator() && cpu_is_omap1510()) | 94 | if (machine_is_omap_innovator() && cpu_is_omap1510()) |
| 96 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 95 | __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL) |
| 97 | | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), | 96 | | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), |
| 98 | INNOVATOR_FPGA_CAM_USB_CONTROL); | 97 | INNOVATOR_FPGA_CAM_USB_CONTROL); |
| 99 | else if (machine_is_omap_osk()) | 98 | else if (machine_is_omap_osk()) |
| 100 | tps65010_set_gpio_out_value(GPIO1, LOW); | 99 | tps65010_set_gpio_out_value(GPIO1, LOW); |
| 101 | } else { | 100 | } else { |
| 102 | if (machine_is_omap_innovator() && cpu_is_omap1510()) | 101 | if (machine_is_omap_innovator() && cpu_is_omap1510()) |
| 103 | fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) | 102 | __raw_writeb(__raw_readb(INNOVATOR_FPGA_CAM_USB_CONTROL) |
| 104 | & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), | 103 | & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), |
| 105 | INNOVATOR_FPGA_CAM_USB_CONTROL); | 104 | INNOVATOR_FPGA_CAM_USB_CONTROL); |
| 106 | else if (machine_is_omap_osk()) | 105 | else if (machine_is_omap_osk()) |
| @@ -530,7 +529,7 @@ static int ohci_omap_resume(struct platform_device *dev) | |||
| 530 | ohci->next_statechange = jiffies; | 529 | ohci->next_statechange = jiffies; |
| 531 | 530 | ||
| 532 | omap_ohci_clock_power(1); | 531 | omap_ohci_clock_power(1); |
| 533 | ohci_finish_controller_resume(hcd); | 532 | ohci_resume(hcd, false); |
| 534 | return 0; | 533 | return 0; |
| 535 | } | 534 | } |
| 536 | 535 | ||
diff --git a/drivers/usb/host/ohci-omap3.c b/drivers/usb/host/ohci-omap3.c index 1b8133b6e451..eb35d9630237 100644 --- a/drivers/usb/host/ohci-omap3.c +++ b/drivers/usb/host/ohci-omap3.c | |||
| @@ -30,7 +30,6 @@ | |||
| 30 | */ | 30 | */ |
| 31 | 31 | ||
| 32 | #include <linux/platform_device.h> | 32 | #include <linux/platform_device.h> |
| 33 | #include <plat/usb.h> | ||
| 34 | #include <linux/pm_runtime.h> | 33 | #include <linux/pm_runtime.h> |
| 35 | 34 | ||
| 36 | /*-------------------------------------------------------------------------*/ | 35 | /*-------------------------------------------------------------------------*/ |
| @@ -125,7 +124,7 @@ static const struct hc_driver ohci_omap3_hc_driver = { | |||
| 125 | * then invokes the start() method for the HCD associated with it | 124 | * then invokes the start() method for the HCD associated with it |
| 126 | * through the hotplug entry's driver_data. | 125 | * through the hotplug entry's driver_data. |
| 127 | */ | 126 | */ |
| 128 | static int __devinit ohci_hcd_omap3_probe(struct platform_device *pdev) | 127 | static int ohci_hcd_omap3_probe(struct platform_device *pdev) |
| 129 | { | 128 | { |
| 130 | struct device *dev = &pdev->dev; | 129 | struct device *dev = &pdev->dev; |
| 131 | struct usb_hcd *hcd = NULL; | 130 | struct usb_hcd *hcd = NULL; |
| @@ -209,7 +208,7 @@ err_io: | |||
| 209 | * the HCD's stop() method. It is always called from a thread | 208 | * the HCD's stop() method. It is always called from a thread |
| 210 | * context, normally "rmmod", "apmd", or something similar. | 209 | * context, normally "rmmod", "apmd", or something similar. |
| 211 | */ | 210 | */ |
| 212 | static int __devexit ohci_hcd_omap3_remove(struct platform_device *pdev) | 211 | static int ohci_hcd_omap3_remove(struct platform_device *pdev) |
| 213 | { | 212 | { |
| 214 | struct device *dev = &pdev->dev; | 213 | struct device *dev = &pdev->dev; |
| 215 | struct usb_hcd *hcd = dev_get_drvdata(dev); | 214 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
| @@ -232,7 +231,7 @@ static void ohci_hcd_omap3_shutdown(struct platform_device *pdev) | |||
| 232 | 231 | ||
| 233 | static struct platform_driver ohci_hcd_omap3_driver = { | 232 | static struct platform_driver ohci_hcd_omap3_driver = { |
| 234 | .probe = ohci_hcd_omap3_probe, | 233 | .probe = ohci_hcd_omap3_probe, |
| 235 | .remove = __devexit_p(ohci_hcd_omap3_remove), | 234 | .remove = ohci_hcd_omap3_remove, |
| 236 | .shutdown = ohci_hcd_omap3_shutdown, | 235 | .shutdown = ohci_hcd_omap3_shutdown, |
| 237 | .driver = { | 236 | .driver = { |
| 238 | .name = "ohci-omap3", | 237 | .name = "ohci-omap3", |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 1843bb68ac7c..951514ef446d 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
| @@ -270,7 +270,7 @@ static int ohci_pci_reset (struct usb_hcd *hcd) | |||
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | 272 | ||
| 273 | static int __devinit ohci_pci_start (struct usb_hcd *hcd) | 273 | static int ohci_pci_start (struct usb_hcd *hcd) |
| 274 | { | 274 | { |
| 275 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 275 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| 276 | int ret; | 276 | int ret; |
| @@ -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..084503b03fcf 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; |
| @@ -79,7 +83,7 @@ static const struct hc_driver ohci_platform_hc_driver = { | |||
| 79 | .start_port_reset = ohci_start_port_reset, | 83 | .start_port_reset = ohci_start_port_reset, |
| 80 | }; | 84 | }; |
| 81 | 85 | ||
| 82 | static int __devinit ohci_platform_probe(struct platform_device *dev) | 86 | static int ohci_platform_probe(struct platform_device *dev) |
| 83 | { | 87 | { |
| 84 | struct usb_hcd *hcd; | 88 | struct usb_hcd *hcd; |
| 85 | struct resource *res_mem; | 89 | struct resource *res_mem; |
| @@ -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: |
| @@ -155,14 +149,12 @@ err_power: | |||
| 155 | return err; | 149 | return err; |
| 156 | } | 150 | } |
| 157 | 151 | ||
| 158 | static int __devexit ohci_platform_remove(struct platform_device *dev) | 152 | static int ohci_platform_remove(struct platform_device *dev) |
| 159 | { | 153 | { |
| 160 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 154 | struct usb_hcd *hcd = platform_get_drvdata(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 | ||
| @@ -222,7 +214,7 @@ static const struct dev_pm_ops ohci_platform_pm_ops = { | |||
| 222 | static struct platform_driver ohci_platform_driver = { | 214 | static struct platform_driver ohci_platform_driver = { |
| 223 | .id_table = ohci_platform_table, | 215 | .id_table = ohci_platform_table, |
| 224 | .probe = ohci_platform_probe, | 216 | .probe = ohci_platform_probe, |
| 225 | .remove = __devexit_p(ohci_platform_remove), | 217 | .remove = ohci_platform_remove, |
| 226 | .shutdown = usb_hcd_platform_shutdown, | 218 | .shutdown = usb_hcd_platform_shutdown, |
| 227 | .driver = { | 219 | .driver = { |
| 228 | .owner = THIS_MODULE, | 220 | .owner = THIS_MODULE, |
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-of.c b/drivers/usb/host/ohci-ppc-of.c index e27d5ae2b9eb..64c2ed9ff95e 100644 --- a/drivers/usb/host/ohci-ppc-of.c +++ b/drivers/usb/host/ohci-ppc-of.c | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | #include <asm/prom.h> | 19 | #include <asm/prom.h> |
| 20 | 20 | ||
| 21 | 21 | ||
| 22 | static int __devinit | 22 | static int |
| 23 | ohci_ppc_of_start(struct usb_hcd *hcd) | 23 | ohci_ppc_of_start(struct usb_hcd *hcd) |
| 24 | { | 24 | { |
| 25 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 25 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| @@ -81,7 +81,7 @@ static const struct hc_driver ohci_ppc_of_hc_driver = { | |||
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | static int __devinit ohci_hcd_ppc_of_probe(struct platform_device *op) | 84 | static int ohci_hcd_ppc_of_probe(struct platform_device *op) |
| 85 | { | 85 | { |
| 86 | struct device_node *dn = op->dev.of_node; | 86 | struct device_node *dn = op->dev.of_node; |
| 87 | struct usb_hcd *hcd; | 87 | struct usb_hcd *hcd; |
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-ps3.c b/drivers/usb/host/ohci-ps3.c index 2ee1d8d713d2..7d35cd9e2862 100644 --- a/drivers/usb/host/ohci-ps3.c +++ b/drivers/usb/host/ohci-ps3.c | |||
| @@ -30,7 +30,7 @@ static int ps3_ohci_hc_reset(struct usb_hcd *hcd) | |||
| 30 | return ohci_init(ohci); | 30 | return ohci_init(ohci); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | static int __devinit ps3_ohci_hc_start(struct usb_hcd *hcd) | 33 | static int ps3_ohci_hc_start(struct usb_hcd *hcd) |
| 34 | { | 34 | { |
| 35 | int result; | 35 | int result; |
| 36 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 36 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| @@ -76,7 +76,7 @@ static const struct hc_driver ps3_ohci_hc_driver = { | |||
| 76 | #endif | 76 | #endif |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | static int __devinit ps3_ohci_probe(struct ps3_system_bus_device *dev) | 79 | static int ps3_ohci_probe(struct ps3_system_bus_device *dev) |
| 80 | { | 80 | { |
| 81 | int result; | 81 | int result; |
| 82 | struct usb_hcd *hcd; | 82 | struct usb_hcd *hcd; |
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 2bf11440b010..efe71f3ca477 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
| @@ -284,7 +284,7 @@ MODULE_DEVICE_TABLE(of, pxa_ohci_dt_ids); | |||
| 284 | 284 | ||
| 285 | static u64 pxa_ohci_dma_mask = DMA_BIT_MASK(32); | 285 | static u64 pxa_ohci_dma_mask = DMA_BIT_MASK(32); |
| 286 | 286 | ||
| 287 | static int __devinit ohci_pxa_of_init(struct platform_device *pdev) | 287 | static int ohci_pxa_of_init(struct platform_device *pdev) |
| 288 | { | 288 | { |
| 289 | struct device_node *np = pdev->dev.of_node; | 289 | struct device_node *np = pdev->dev.of_node; |
| 290 | struct pxaohci_platform_data *pdata; | 290 | struct pxaohci_platform_data *pdata; |
| @@ -330,7 +330,7 @@ static int __devinit ohci_pxa_of_init(struct platform_device *pdev) | |||
| 330 | return 0; | 330 | return 0; |
| 331 | } | 331 | } |
| 332 | #else | 332 | #else |
| 333 | static int __devinit ohci_pxa_of_init(struct platform_device *pdev) | 333 | static int ohci_pxa_of_init(struct platform_device *pdev) |
| 334 | { | 334 | { |
| 335 | return 0; | 335 | return 0; |
| 336 | } | 336 | } |
| @@ -471,7 +471,7 @@ void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) | |||
| 471 | 471 | ||
| 472 | /*-------------------------------------------------------------------------*/ | 472 | /*-------------------------------------------------------------------------*/ |
| 473 | 473 | ||
| 474 | static int __devinit | 474 | static int |
| 475 | ohci_pxa27x_start (struct usb_hcd *hcd) | 475 | ohci_pxa27x_start (struct usb_hcd *hcd) |
| 476 | { | 476 | { |
| 477 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 477 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
| @@ -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..7482cfbe8c5e 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 |
| @@ -1128,6 +1128,25 @@ dl_done_list (struct ohci_hcd *ohci) | |||
| 1128 | 1128 | ||
| 1129 | while (td) { | 1129 | while (td) { |
| 1130 | struct td *td_next = td->next_dl_td; | 1130 | struct td *td_next = td->next_dl_td; |
| 1131 | struct ed *ed = td->ed; | ||
| 1132 | |||
| 1133 | /* | ||
| 1134 | * Some OHCI controllers (NVIDIA for sure, maybe others) | ||
| 1135 | * occasionally forget to add TDs to the done queue. Since | ||
| 1136 | * TDs for a given endpoint are always processed in order, | ||
| 1137 | * if we find a TD on the donelist then all of its | ||
| 1138 | * predecessors must be finished as well. | ||
| 1139 | */ | ||
| 1140 | for (;;) { | ||
| 1141 | struct td *td2; | ||
| 1142 | |||
| 1143 | td2 = list_first_entry(&ed->td_list, struct td, | ||
| 1144 | td_list); | ||
| 1145 | if (td2 == td) | ||
| 1146 | break; | ||
| 1147 | takeback_td(ohci, td2); | ||
| 1148 | } | ||
| 1149 | |||
| 1131 | takeback_td(ohci, td); | 1150 | takeback_td(ohci, td); |
| 1132 | td = td_next; | 1151 | td = td_next; |
| 1133 | } | 1152 | } |
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index 0d2309ca471e..ad0f55269603 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); |
| @@ -474,12 +458,12 @@ static const struct hc_driver ohci_s3c2410_hc_driver = { | |||
| 474 | 458 | ||
| 475 | /* device driver */ | 459 | /* device driver */ |
| 476 | 460 | ||
| 477 | static int __devinit ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev) | 461 | static int ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev) |
| 478 | { | 462 | { |
| 479 | return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); | 463 | return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); |
| 480 | } | 464 | } |
| 481 | 465 | ||
| 482 | static int __devexit ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) | 466 | static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev) |
| 483 | { | 467 | { |
| 484 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 468 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 485 | 469 | ||
| @@ -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 | } |
| @@ -541,7 +524,7 @@ static const struct dev_pm_ops ohci_hcd_s3c2410_pm_ops = { | |||
| 541 | 524 | ||
| 542 | static struct platform_driver ohci_hcd_s3c2410_driver = { | 525 | static struct platform_driver ohci_hcd_s3c2410_driver = { |
| 543 | .probe = ohci_hcd_s3c2410_drv_probe, | 526 | .probe = ohci_hcd_s3c2410_drv_probe, |
| 544 | .remove = __devexit_p(ohci_hcd_s3c2410_drv_remove), | 527 | .remove = ohci_hcd_s3c2410_drv_remove, |
| 545 | .shutdown = usb_hcd_platform_shutdown, | 528 | .shutdown = usb_hcd_platform_shutdown, |
| 546 | .driver = { | 529 | .driver = { |
| 547 | .owner = THIS_MODULE, | 530 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c index b6cc92520924..17b2a7dad77b 100644 --- a/drivers/usb/host/ohci-sa1111.c +++ b/drivers/usb/host/ohci-sa1111.c | |||
| @@ -63,7 +63,7 @@ static int ohci_sa1111_reset(struct usb_hcd *hcd) | |||
| 63 | return ohci_init(ohci); | 63 | return ohci_init(ohci); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | static int __devinit ohci_sa1111_start(struct usb_hcd *hcd) | 66 | static int ohci_sa1111_start(struct usb_hcd *hcd) |
| 67 | { | 67 | { |
| 68 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 68 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 69 | int ret; | 69 | int ret; |
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..9020bf0e2eca 100644 --- a/drivers/usb/host/ohci-spear.c +++ b/drivers/usb/host/ohci-spear.c | |||
| @@ -33,7 +33,7 @@ static void spear_stop_ohci(struct spear_ohci *ohci) | |||
| 33 | clk_disable_unprepare(ohci->clk); | 33 | clk_disable_unprepare(ohci->clk); |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | static int __devinit ohci_spear_start(struct usb_hcd *hcd) | 36 | static int ohci_spear_start(struct usb_hcd *hcd) |
| 37 | { | 37 | { |
| 38 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 38 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| 39 | int ret; | 39 | int ret; |
| @@ -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,12 +211,12 @@ 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 |
| 238 | 218 | ||
| 239 | static struct of_device_id spear_ohci_id_table[] __devinitdata = { | 219 | static struct of_device_id spear_ohci_id_table[] = { |
| 240 | { .compatible = "st,spear600-ohci", }, | 220 | { .compatible = "st,spear600-ohci", }, |
| 241 | { }, | 221 | { }, |
| 242 | }; | 222 | }; |
diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index 60c2b0722f2e..5e3a6deb62b1 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c | |||
| @@ -128,7 +128,8 @@ static void tmio_start_hc(struct platform_device *dev) | |||
| 128 | tmio_iowrite8(2, tmio->ccr + CCR_INTC); | 128 | tmio_iowrite8(2, tmio->ccr + CCR_INTC); |
| 129 | 129 | ||
| 130 | dev_info(&dev->dev, "revision %d @ 0x%08llx, irq %d\n", | 130 | dev_info(&dev->dev, "revision %d @ 0x%08llx, irq %d\n", |
| 131 | tmio_ioread8(tmio->ccr + CCR_REVID), hcd->rsrc_start, hcd->irq); | 131 | tmio_ioread8(tmio->ccr + CCR_REVID), |
| 132 | (u64) hcd->rsrc_start, hcd->irq); | ||
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | static int ohci_tmio_start(struct usb_hcd *hcd) | 135 | static int ohci_tmio_start(struct usb_hcd *hcd) |
| @@ -184,7 +185,7 @@ static const struct hc_driver ohci_tmio_hc_driver = { | |||
| 184 | /*-------------------------------------------------------------------------*/ | 185 | /*-------------------------------------------------------------------------*/ |
| 185 | static struct platform_driver ohci_hcd_tmio_driver; | 186 | static struct platform_driver ohci_hcd_tmio_driver; |
| 186 | 187 | ||
| 187 | static int __devinit ohci_hcd_tmio_drv_probe(struct platform_device *dev) | 188 | static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) |
| 188 | { | 189 | { |
| 189 | const struct mfd_cell *cell = mfd_get_cell(dev); | 190 | const struct mfd_cell *cell = mfd_get_cell(dev); |
| 190 | struct resource *regs = platform_get_resource(dev, IORESOURCE_MEM, 0); | 191 | struct resource *regs = platform_get_resource(dev, IORESOURCE_MEM, 0); |
| @@ -271,7 +272,7 @@ err_usb_create_hcd: | |||
| 271 | return ret; | 272 | return ret; |
| 272 | } | 273 | } |
| 273 | 274 | ||
| 274 | static int __devexit ohci_hcd_tmio_drv_remove(struct platform_device *dev) | 275 | static int ohci_hcd_tmio_drv_remove(struct platform_device *dev) |
| 275 | { | 276 | { |
| 276 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 277 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
| 277 | struct tmio_hcd *tmio = hcd_to_tmio(hcd); | 278 | struct tmio_hcd *tmio = hcd_to_tmio(hcd); |
| @@ -352,7 +353,7 @@ static int ohci_hcd_tmio_drv_resume(struct platform_device *dev) | |||
| 352 | 353 | ||
| 353 | spin_unlock_irqrestore(&tmio->lock, flags); | 354 | spin_unlock_irqrestore(&tmio->lock, flags); |
| 354 | 355 | ||
| 355 | ohci_finish_controller_resume(hcd); | 356 | ohci_resume(hcd, false); |
| 356 | 357 | ||
| 357 | return 0; | 358 | return 0; |
| 358 | } | 359 | } |
| @@ -363,7 +364,7 @@ static int ohci_hcd_tmio_drv_resume(struct platform_device *dev) | |||
| 363 | 364 | ||
| 364 | static struct platform_driver ohci_hcd_tmio_driver = { | 365 | static struct platform_driver ohci_hcd_tmio_driver = { |
| 365 | .probe = ohci_hcd_tmio_drv_probe, | 366 | .probe = ohci_hcd_tmio_drv_probe, |
| 366 | .remove = __devexit_p(ohci_hcd_tmio_drv_remove), | 367 | .remove = ohci_hcd_tmio_drv_remove, |
| 367 | .shutdown = usb_hcd_platform_shutdown, | 368 | .shutdown = usb_hcd_platform_shutdown, |
| 368 | .suspend = ohci_hcd_tmio_drv_suspend, | 369 | .suspend = ohci_hcd_tmio_drv_suspend, |
| 369 | .resume = ohci_hcd_tmio_drv_resume, | 370 | .resume = ohci_hcd_tmio_drv_resume, |
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/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 39f9e4a9a2d3..a3b6d7104ae2 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
| @@ -443,7 +443,7 @@ static inline int io_type_enabled(struct pci_dev *pdev, unsigned int mask) | |||
| 443 | #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) | 443 | #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO) |
| 444 | #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) | 444 | #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY) |
| 445 | 445 | ||
| 446 | static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) | 446 | static void quirk_usb_handoff_uhci(struct pci_dev *pdev) |
| 447 | { | 447 | { |
| 448 | unsigned long base = 0; | 448 | unsigned long base = 0; |
| 449 | int i; | 449 | int i; |
| @@ -461,12 +461,12 @@ static void __devinit quirk_usb_handoff_uhci(struct pci_dev *pdev) | |||
| 461 | uhci_check_and_reset_hc(pdev, base); | 461 | uhci_check_and_reset_hc(pdev, base); |
| 462 | } | 462 | } |
| 463 | 463 | ||
| 464 | static int __devinit mmio_resource_enabled(struct pci_dev *pdev, int idx) | 464 | static int mmio_resource_enabled(struct pci_dev *pdev, int idx) |
| 465 | { | 465 | { |
| 466 | return pci_resource_start(pdev, idx) && mmio_enabled(pdev); | 466 | return pci_resource_start(pdev, idx) && mmio_enabled(pdev); |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | 469 | static void quirk_usb_handoff_ohci(struct pci_dev *pdev) |
| 470 | { | 470 | { |
| 471 | void __iomem *base; | 471 | void __iomem *base; |
| 472 | u32 control; | 472 | u32 control; |
| @@ -533,7 +533,7 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | |||
| 533 | iounmap(base); | 533 | iounmap(base); |
| 534 | } | 534 | } |
| 535 | 535 | ||
| 536 | static const struct dmi_system_id __devinitconst ehci_dmi_nohandoff_table[] = { | 536 | static const struct dmi_system_id ehci_dmi_nohandoff_table[] = { |
| 537 | { | 537 | { |
| 538 | /* Pegatron Lucid (ExoPC) */ | 538 | /* Pegatron Lucid (ExoPC) */ |
| 539 | .matches = { | 539 | .matches = { |
| @@ -558,7 +558,7 @@ static const struct dmi_system_id __devinitconst ehci_dmi_nohandoff_table[] = { | |||
| 558 | { } | 558 | { } |
| 559 | }; | 559 | }; |
| 560 | 560 | ||
| 561 | static void __devinit ehci_bios_handoff(struct pci_dev *pdev, | 561 | static void ehci_bios_handoff(struct pci_dev *pdev, |
| 562 | void __iomem *op_reg_base, | 562 | void __iomem *op_reg_base, |
| 563 | u32 cap, u8 offset) | 563 | u32 cap, u8 offset) |
| 564 | { | 564 | { |
| @@ -626,7 +626,7 @@ static void __devinit ehci_bios_handoff(struct pci_dev *pdev, | |||
| 626 | writel(0, op_reg_base + EHCI_CONFIGFLAG); | 626 | writel(0, op_reg_base + EHCI_CONFIGFLAG); |
| 627 | } | 627 | } |
| 628 | 628 | ||
| 629 | static void __devinit quirk_usb_disable_ehci(struct pci_dev *pdev) | 629 | static void quirk_usb_disable_ehci(struct pci_dev *pdev) |
| 630 | { | 630 | { |
| 631 | void __iomem *base, *op_reg_base; | 631 | void __iomem *base, *op_reg_base; |
| 632 | u32 hcc_params, cap, val; | 632 | u32 hcc_params, cap, val; |
| @@ -723,6 +723,7 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, | |||
| 723 | } | 723 | } |
| 724 | 724 | ||
| 725 | #define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31 | 725 | #define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31 |
| 726 | #define PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI 0x9C31 | ||
| 726 | 727 | ||
| 727 | bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev) | 728 | bool usb_is_intel_ppt_switchable_xhci(struct pci_dev *pdev) |
| 728 | { | 729 | { |
| @@ -736,7 +737,8 @@ bool usb_is_intel_lpt_switchable_xhci(struct pci_dev *pdev) | |||
| 736 | { | 737 | { |
| 737 | return pdev->class == PCI_CLASS_SERIAL_USB_XHCI && | 738 | return pdev->class == PCI_CLASS_SERIAL_USB_XHCI && |
| 738 | pdev->vendor == PCI_VENDOR_ID_INTEL && | 739 | pdev->vendor == PCI_VENDOR_ID_INTEL && |
| 739 | pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI; | 740 | (pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI || |
| 741 | pdev->device == PCI_DEVICE_ID_INTEL_LYNX_POINT_LP_XHCI); | ||
| 740 | } | 742 | } |
| 741 | 743 | ||
| 742 | bool usb_is_intel_switchable_xhci(struct pci_dev *pdev) | 744 | bool usb_is_intel_switchable_xhci(struct pci_dev *pdev) |
| @@ -841,7 +843,7 @@ EXPORT_SYMBOL_GPL(usb_disable_xhci_ports); | |||
| 841 | * and then waits 5 seconds for the BIOS to hand over control. | 843 | * and then waits 5 seconds for the BIOS to hand over control. |
| 842 | * If we timeout, assume the BIOS is broken and take control anyway. | 844 | * If we timeout, assume the BIOS is broken and take control anyway. |
| 843 | */ | 845 | */ |
| 844 | static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev) | 846 | static void quirk_usb_handoff_xhci(struct pci_dev *pdev) |
| 845 | { | 847 | { |
| 846 | void __iomem *base; | 848 | void __iomem *base; |
| 847 | int ext_cap_offset; | 849 | int ext_cap_offset; |
| @@ -941,7 +943,7 @@ hc_init: | |||
| 941 | iounmap(base); | 943 | iounmap(base); |
| 942 | } | 944 | } |
| 943 | 945 | ||
| 944 | static void __devinit quirk_usb_early_handoff(struct pci_dev *pdev) | 946 | static void quirk_usb_early_handoff(struct pci_dev *pdev) |
| 945 | { | 947 | { |
| 946 | /* Skip Netlogic mips SoC's internal PCI USB controller. | 948 | /* Skip Netlogic mips SoC's internal PCI USB controller. |
| 947 | * This device does not need/support EHCI/OHCI handoff | 949 | * This device does not need/support EHCI/OHCI handoff |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index fcc09e5ec0ad..a6fd8f5371df 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 */ |
| @@ -2393,7 +2391,7 @@ static const struct dev_pm_ops r8a66597_dev_pm_ops = { | |||
| 2393 | #define R8A66597_DEV_PM_OPS NULL | 2391 | #define R8A66597_DEV_PM_OPS NULL |
| 2394 | #endif | 2392 | #endif |
| 2395 | 2393 | ||
| 2396 | static int __devexit r8a66597_remove(struct platform_device *pdev) | 2394 | static int r8a66597_remove(struct platform_device *pdev) |
| 2397 | { | 2395 | { |
| 2398 | struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); | 2396 | struct r8a66597 *r8a66597 = dev_get_drvdata(&pdev->dev); |
| 2399 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); | 2397 | struct usb_hcd *hcd = r8a66597_to_hcd(r8a66597); |
| @@ -2407,7 +2405,7 @@ static int __devexit r8a66597_remove(struct platform_device *pdev) | |||
| 2407 | return 0; | 2405 | return 0; |
| 2408 | } | 2406 | } |
| 2409 | 2407 | ||
| 2410 | static int __devinit r8a66597_probe(struct platform_device *pdev) | 2408 | static int r8a66597_probe(struct platform_device *pdev) |
| 2411 | { | 2409 | { |
| 2412 | char clk_name[8]; | 2410 | char clk_name[8]; |
| 2413 | struct resource *res = NULL, *ires; | 2411 | struct resource *res = NULL, *ires; |
| @@ -2534,7 +2532,7 @@ clean_up: | |||
| 2534 | 2532 | ||
| 2535 | static struct platform_driver r8a66597_driver = { | 2533 | static struct platform_driver r8a66597_driver = { |
| 2536 | .probe = r8a66597_probe, | 2534 | .probe = r8a66597_probe, |
| 2537 | .remove = __devexit_p(r8a66597_remove), | 2535 | .remove = r8a66597_remove, |
| 2538 | .driver = { | 2536 | .driver = { |
| 2539 | .name = (char *) hcd_name, | 2537 | .name = (char *) hcd_name, |
| 2540 | .owner = THIS_MODULE, | 2538 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 619b05f42d4f..d62f0404baaa 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
| @@ -1595,7 +1595,7 @@ static struct hc_driver sl811h_hc_driver = { | |||
| 1595 | 1595 | ||
| 1596 | /*-------------------------------------------------------------------------*/ | 1596 | /*-------------------------------------------------------------------------*/ |
| 1597 | 1597 | ||
| 1598 | static int __devexit | 1598 | static int |
| 1599 | sl811h_remove(struct platform_device *dev) | 1599 | sl811h_remove(struct platform_device *dev) |
| 1600 | { | 1600 | { |
| 1601 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 1601 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
| @@ -1618,7 +1618,7 @@ sl811h_remove(struct platform_device *dev) | |||
| 1618 | return 0; | 1618 | return 0; |
| 1619 | } | 1619 | } |
| 1620 | 1620 | ||
| 1621 | static int __devinit | 1621 | static int |
| 1622 | sl811h_probe(struct platform_device *dev) | 1622 | sl811h_probe(struct platform_device *dev) |
| 1623 | { | 1623 | { |
| 1624 | struct usb_hcd *hcd; | 1624 | struct usb_hcd *hcd; |
| @@ -1808,7 +1808,7 @@ sl811h_resume(struct platform_device *dev) | |||
| 1808 | /* this driver is exported so sl811_cs can depend on it */ | 1808 | /* this driver is exported so sl811_cs can depend on it */ |
| 1809 | struct platform_driver sl811h_driver = { | 1809 | struct platform_driver sl811h_driver = { |
| 1810 | .probe = sl811h_probe, | 1810 | .probe = sl811h_probe, |
| 1811 | .remove = __devexit_p(sl811h_remove), | 1811 | .remove = sl811h_remove, |
| 1812 | 1812 | ||
| 1813 | .suspend = sl811h_suspend, | 1813 | .suspend = sl811h_suspend, |
| 1814 | .resume = sl811h_resume, | 1814 | .resume = sl811h_resume, |
diff --git a/drivers/usb/host/ssb-hcd.c b/drivers/usb/host/ssb-hcd.c index c2a29faba076..74af2c6287d2 100644 --- a/drivers/usb/host/ssb-hcd.c +++ b/drivers/usb/host/ssb-hcd.c | |||
| @@ -39,7 +39,7 @@ struct ssb_hcd_device { | |||
| 39 | u32 enable_flags; | 39 | u32 enable_flags; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | static void __devinit ssb_hcd_5354wa(struct ssb_device *dev) | 42 | static void ssb_hcd_5354wa(struct ssb_device *dev) |
| 43 | { | 43 | { |
| 44 | #ifdef CONFIG_SSB_DRIVER_MIPS | 44 | #ifdef CONFIG_SSB_DRIVER_MIPS |
| 45 | /* Work around for 5354 failures */ | 45 | /* Work around for 5354 failures */ |
| @@ -53,7 +53,7 @@ static void __devinit ssb_hcd_5354wa(struct ssb_device *dev) | |||
| 53 | #endif | 53 | #endif |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | static void __devinit ssb_hcd_usb20wa(struct ssb_device *dev) | 56 | static void ssb_hcd_usb20wa(struct ssb_device *dev) |
| 57 | { | 57 | { |
| 58 | if (dev->id.coreid == SSB_DEV_USB20_HOST) { | 58 | if (dev->id.coreid == SSB_DEV_USB20_HOST) { |
| 59 | /* | 59 | /* |
| @@ -80,7 +80,7 @@ static void __devinit ssb_hcd_usb20wa(struct ssb_device *dev) | |||
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ | 82 | /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ |
| 83 | static u32 __devinit ssb_hcd_init_chip(struct ssb_device *dev) | 83 | static u32 ssb_hcd_init_chip(struct ssb_device *dev) |
| 84 | { | 84 | { |
| 85 | u32 flags = 0; | 85 | u32 flags = 0; |
| 86 | 86 | ||
| @@ -101,8 +101,7 @@ static const struct usb_ehci_pdata ehci_pdata = { | |||
| 101 | static const struct usb_ohci_pdata ohci_pdata = { | 101 | static const struct usb_ohci_pdata ohci_pdata = { |
| 102 | }; | 102 | }; |
| 103 | 103 | ||
| 104 | static struct platform_device * __devinit | 104 | static struct platform_device *ssb_hcd_create_pdev(struct ssb_device *dev, bool ohci, u32 addr, u32 len) |
| 105 | ssb_hcd_create_pdev(struct ssb_device *dev, bool ohci, u32 addr, u32 len) | ||
| 106 | { | 105 | { |
| 107 | struct platform_device *hci_dev; | 106 | struct platform_device *hci_dev; |
| 108 | struct resource hci_res[2]; | 107 | struct resource hci_res[2]; |
| @@ -148,7 +147,7 @@ err_alloc: | |||
| 148 | return ERR_PTR(ret); | 147 | return ERR_PTR(ret); |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | static int __devinit ssb_hcd_probe(struct ssb_device *dev, | 150 | static int ssb_hcd_probe(struct ssb_device *dev, |
| 152 | const struct ssb_device_id *id) | 151 | const struct ssb_device_id *id) |
| 153 | { | 152 | { |
| 154 | int err, tmp; | 153 | int err, tmp; |
| @@ -207,7 +206,7 @@ err_free_usb_dev: | |||
| 207 | return err; | 206 | return err; |
| 208 | } | 207 | } |
| 209 | 208 | ||
| 210 | static void __devexit ssb_hcd_remove(struct ssb_device *dev) | 209 | static void ssb_hcd_remove(struct ssb_device *dev) |
| 211 | { | 210 | { |
| 212 | struct ssb_hcd_device *usb_dev = ssb_get_drvdata(dev); | 211 | struct ssb_hcd_device *usb_dev = ssb_get_drvdata(dev); |
| 213 | struct platform_device *ohci_dev = usb_dev->ohci_dev; | 212 | struct platform_device *ohci_dev = usb_dev->ohci_dev; |
| @@ -221,7 +220,7 @@ static void __devexit ssb_hcd_remove(struct ssb_device *dev) | |||
| 221 | ssb_device_disable(dev, 0); | 220 | ssb_device_disable(dev, 0); |
| 222 | } | 221 | } |
| 223 | 222 | ||
| 224 | static void __devexit ssb_hcd_shutdown(struct ssb_device *dev) | 223 | static void ssb_hcd_shutdown(struct ssb_device *dev) |
| 225 | { | 224 | { |
| 226 | ssb_device_disable(dev, 0); | 225 | ssb_device_disable(dev, 0); |
| 227 | } | 226 | } |
| @@ -249,7 +248,7 @@ static int ssb_hcd_resume(struct ssb_device *dev) | |||
| 249 | #define ssb_hcd_resume NULL | 248 | #define ssb_hcd_resume NULL |
| 250 | #endif /* CONFIG_PM */ | 249 | #endif /* CONFIG_PM */ |
| 251 | 250 | ||
| 252 | static const struct ssb_device_id ssb_hcd_table[] __devinitconst = { | 251 | static const struct ssb_device_id ssb_hcd_table[] = { |
| 253 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), | 252 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), |
| 254 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), | 253 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), |
| 255 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), | 254 | SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB20_HOST, SSB_ANY_REV), |
| @@ -261,7 +260,7 @@ static struct ssb_driver ssb_hcd_driver = { | |||
| 261 | .name = KBUILD_MODNAME, | 260 | .name = KBUILD_MODNAME, |
| 262 | .id_table = ssb_hcd_table, | 261 | .id_table = ssb_hcd_table, |
| 263 | .probe = ssb_hcd_probe, | 262 | .probe = ssb_hcd_probe, |
| 264 | .remove = __devexit_p(ssb_hcd_remove), | 263 | .remove = ssb_hcd_remove, |
| 265 | .shutdown = ssb_hcd_shutdown, | 264 | .shutdown = ssb_hcd_shutdown, |
| 266 | .suspend = ssb_hcd_suspend, | 265 | .suspend = ssb_hcd_suspend, |
| 267 | .resume = ssb_hcd_resume, | 266 | .resume = ssb_hcd_resume, |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index dbbd1ba25224..5efdffe32365 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
| @@ -2990,7 +2990,7 @@ static struct hc_driver u132_hc_driver = { | |||
| 2990 | * synchronously - but instead should immediately stop activity to the | 2990 | * synchronously - but instead should immediately stop activity to the |
| 2991 | * device and asynchronously call usb_remove_hcd() | 2991 | * device and asynchronously call usb_remove_hcd() |
| 2992 | */ | 2992 | */ |
| 2993 | static int __devexit u132_remove(struct platform_device *pdev) | 2993 | static int u132_remove(struct platform_device *pdev) |
| 2994 | { | 2994 | { |
| 2995 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 2995 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 2996 | if (hcd) { | 2996 | if (hcd) { |
| @@ -3084,7 +3084,7 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev) | |||
| 3084 | mutex_unlock(&u132->sw_lock); | 3084 | mutex_unlock(&u132->sw_lock); |
| 3085 | } | 3085 | } |
| 3086 | 3086 | ||
| 3087 | static int __devinit u132_probe(struct platform_device *pdev) | 3087 | static int u132_probe(struct platform_device *pdev) |
| 3088 | { | 3088 | { |
| 3089 | struct usb_hcd *hcd; | 3089 | struct usb_hcd *hcd; |
| 3090 | int retval; | 3090 | int retval; |
| @@ -3212,7 +3212,7 @@ static int u132_resume(struct platform_device *pdev) | |||
| 3212 | */ | 3212 | */ |
| 3213 | static struct platform_driver u132_platform_driver = { | 3213 | static struct platform_driver u132_platform_driver = { |
| 3214 | .probe = u132_probe, | 3214 | .probe = u132_probe, |
| 3215 | .remove = __devexit_p(u132_remove), | 3215 | .remove = u132_remove, |
| 3216 | .suspend = u132_suspend, | 3216 | .suspend = u132_suspend, |
| 3217 | .resume = u132_resume, | 3217 | .resume = u132_resume, |
| 3218 | .driver = { | 3218 | .driver = { |
diff --git a/drivers/usb/host/uhci-grlib.c b/drivers/usb/host/uhci-grlib.c index f7a62138e3e0..511bfc46dd78 100644 --- a/drivers/usb/host/uhci-grlib.c +++ b/drivers/usb/host/uhci-grlib.c | |||
| @@ -85,7 +85,7 @@ static const struct hc_driver uhci_grlib_hc_driver = { | |||
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | static int __devinit uhci_hcd_grlib_probe(struct platform_device *op) | 88 | static int uhci_hcd_grlib_probe(struct platform_device *op) |
| 89 | { | 89 | { |
| 90 | struct device_node *dn = op->dev.of_node; | 90 | struct device_node *dn = op->dev.of_node; |
| 91 | struct usb_hcd *hcd; | 91 | struct usb_hcd *hcd; |
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c index 68ebf20e1519..8c4dace4b14a 100644 --- a/drivers/usb/host/uhci-platform.c +++ b/drivers/usb/host/uhci-platform.c | |||
| @@ -62,7 +62,7 @@ static const struct hc_driver uhci_platform_hc_driver = { | |||
| 62 | 62 | ||
| 63 | static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32); | 63 | static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32); |
| 64 | 64 | ||
| 65 | static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) | 65 | static int uhci_hcd_platform_probe(struct platform_device *pdev) |
| 66 | { | 66 | { |
| 67 | struct usb_hcd *hcd; | 67 | struct usb_hcd *hcd; |
| 68 | struct uhci_hcd *uhci; | 68 | struct uhci_hcd *uhci; |
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-hub.c b/drivers/usb/host/xhci-hub.c index a686cf4905bb..68914429482f 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
| @@ -761,12 +761,39 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
| 761 | break; | 761 | break; |
| 762 | case USB_PORT_FEAT_LINK_STATE: | 762 | case USB_PORT_FEAT_LINK_STATE: |
| 763 | temp = xhci_readl(xhci, port_array[wIndex]); | 763 | temp = xhci_readl(xhci, port_array[wIndex]); |
| 764 | |||
| 765 | /* Disable port */ | ||
| 766 | if (link_state == USB_SS_PORT_LS_SS_DISABLED) { | ||
| 767 | xhci_dbg(xhci, "Disable port %d\n", wIndex); | ||
| 768 | temp = xhci_port_state_to_neutral(temp); | ||
| 769 | /* | ||
| 770 | * Clear all change bits, so that we get a new | ||
| 771 | * connection event. | ||
| 772 | */ | ||
| 773 | temp |= PORT_CSC | PORT_PEC | PORT_WRC | | ||
| 774 | PORT_OCC | PORT_RC | PORT_PLC | | ||
| 775 | PORT_CEC; | ||
| 776 | xhci_writel(xhci, temp | PORT_PE, | ||
| 777 | port_array[wIndex]); | ||
| 778 | temp = xhci_readl(xhci, port_array[wIndex]); | ||
| 779 | break; | ||
| 780 | } | ||
| 781 | |||
| 782 | /* Put link in RxDetect (enable port) */ | ||
| 783 | if (link_state == USB_SS_PORT_LS_RX_DETECT) { | ||
| 784 | xhci_dbg(xhci, "Enable port %d\n", wIndex); | ||
| 785 | xhci_set_link_state(xhci, port_array, wIndex, | ||
| 786 | link_state); | ||
| 787 | temp = xhci_readl(xhci, port_array[wIndex]); | ||
| 788 | break; | ||
| 789 | } | ||
| 790 | |||
| 764 | /* Software should not attempt to set | 791 | /* Software should not attempt to set |
| 765 | * port link state above '5' (Rx.Detect) and the port | 792 | * port link state above '3' (U3) and the port |
| 766 | * must be enabled. | 793 | * must be enabled. |
| 767 | */ | 794 | */ |
| 768 | if ((temp & PORT_PE) == 0 || | 795 | if ((temp & PORT_PE) == 0 || |
| 769 | (link_state > USB_SS_PORT_LS_RX_DETECT)) { | 796 | (link_state > USB_SS_PORT_LS_U3)) { |
| 770 | xhci_warn(xhci, "Cannot set link state.\n"); | 797 | xhci_warn(xhci, "Cannot set link state.\n"); |
| 771 | goto error; | 798 | goto error; |
| 772 | } | 799 | } |
| @@ -957,6 +984,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
| 957 | int max_ports; | 984 | int max_ports; |
| 958 | __le32 __iomem **port_array; | 985 | __le32 __iomem **port_array; |
| 959 | struct xhci_bus_state *bus_state; | 986 | struct xhci_bus_state *bus_state; |
| 987 | bool reset_change = false; | ||
| 960 | 988 | ||
| 961 | max_ports = xhci_get_ports(hcd, &port_array); | 989 | max_ports = xhci_get_ports(hcd, &port_array); |
| 962 | bus_state = &xhci->bus_state[hcd_index(hcd)]; | 990 | bus_state = &xhci->bus_state[hcd_index(hcd)]; |
| @@ -988,6 +1016,12 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
| 988 | buf[(i + 1) / 8] |= 1 << (i + 1) % 8; | 1016 | buf[(i + 1) / 8] |= 1 << (i + 1) % 8; |
| 989 | status = 1; | 1017 | status = 1; |
| 990 | } | 1018 | } |
| 1019 | if ((temp & PORT_RC)) | ||
| 1020 | reset_change = true; | ||
| 1021 | } | ||
| 1022 | if (!status && !reset_change) { | ||
| 1023 | xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); | ||
| 1024 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
| 991 | } | 1025 | } |
| 992 | spin_unlock_irqrestore(&xhci->lock, flags); | 1026 | spin_unlock_irqrestore(&xhci->lock, flags); |
| 993 | return status ? retval : 0; | 1027 | return status ? retval : 0; |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 487bc083dead..35616ffbe3ae 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 | ||
| @@ -1245,6 +1250,8 @@ static unsigned int xhci_microframes_to_exponent(struct usb_device *udev, | |||
| 1245 | static unsigned int xhci_parse_microframe_interval(struct usb_device *udev, | 1250 | static unsigned int xhci_parse_microframe_interval(struct usb_device *udev, |
| 1246 | struct usb_host_endpoint *ep) | 1251 | struct usb_host_endpoint *ep) |
| 1247 | { | 1252 | { |
| 1253 | if (ep->desc.bInterval == 0) | ||
| 1254 | return 0; | ||
| 1248 | return xhci_microframes_to_exponent(udev, ep, | 1255 | return xhci_microframes_to_exponent(udev, ep, |
| 1249 | ep->desc.bInterval, 0, 15); | 1256 | ep->desc.bInterval, 0, 15); |
| 1250 | } | 1257 | } |
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..59fb5c677dbe 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, " |
| @@ -1725,6 +1725,15 @@ cleanup: | |||
| 1725 | if (bogus_port_status) | 1725 | if (bogus_port_status) |
| 1726 | return; | 1726 | return; |
| 1727 | 1727 | ||
| 1728 | /* | ||
| 1729 | * xHCI port-status-change events occur when the "or" of all the | ||
| 1730 | * status-change bits in the portsc register changes from 0 to 1. | ||
| 1731 | * New status changes won't cause an event if any other change | ||
| 1732 | * bits are still set. When an event occurs, switch over to | ||
| 1733 | * polling to avoid losing status changes. | ||
| 1734 | */ | ||
| 1735 | xhci_dbg(xhci, "%s: starting port polling.\n", __func__); | ||
| 1736 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
| 1728 | spin_unlock(&xhci->lock); | 1737 | spin_unlock(&xhci->lock); |
| 1729 | /* Pass this up to the core */ | 1738 | /* Pass this up to the core */ |
| 1730 | usb_hcd_poll_rh_status(hcd); | 1739 | usb_hcd_poll_rh_status(hcd); |
| @@ -3071,11 +3080,11 @@ static u32 xhci_td_remainder(unsigned int remainder) | |||
| 3071 | } | 3080 | } |
| 3072 | 3081 | ||
| 3073 | /* | 3082 | /* |
| 3074 | * For xHCI 1.0 host controllers, TD size is the number of packets remaining in | 3083 | * For xHCI 1.0 host controllers, TD size is the number of max packet sized |
| 3075 | * the TD (*not* including this TRB). | 3084 | * packets remaining in the TD (*not* including this TRB). |
| 3076 | * | 3085 | * |
| 3077 | * Total TD packet count = total_packet_count = | 3086 | * Total TD packet count = total_packet_count = |
| 3078 | * roundup(TD size in bytes / wMaxPacketSize) | 3087 | * DIV_ROUND_UP(TD size in bytes / wMaxPacketSize) |
| 3079 | * | 3088 | * |
| 3080 | * Packets transferred up to and including this TRB = packets_transferred = | 3089 | * Packets transferred up to and including this TRB = packets_transferred = |
| 3081 | * rounddown(total bytes transferred including this TRB / wMaxPacketSize) | 3090 | * rounddown(total bytes transferred including this TRB / wMaxPacketSize) |
| @@ -3083,15 +3092,16 @@ static u32 xhci_td_remainder(unsigned int remainder) | |||
| 3083 | * TD size = total_packet_count - packets_transferred | 3092 | * TD size = total_packet_count - packets_transferred |
| 3084 | * | 3093 | * |
| 3085 | * It must fit in bits 21:17, so it can't be bigger than 31. | 3094 | * It must fit in bits 21:17, so it can't be bigger than 31. |
| 3095 | * The last TRB in a TD must have the TD size set to zero. | ||
| 3086 | */ | 3096 | */ |
| 3087 | |||
| 3088 | static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, | 3097 | static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, |
| 3089 | unsigned int total_packet_count, struct urb *urb) | 3098 | unsigned int total_packet_count, struct urb *urb, |
| 3099 | unsigned int num_trbs_left) | ||
| 3090 | { | 3100 | { |
| 3091 | int packets_transferred; | 3101 | int packets_transferred; |
| 3092 | 3102 | ||
| 3093 | /* One TRB with a zero-length data packet. */ | 3103 | /* One TRB with a zero-length data packet. */ |
| 3094 | if (running_total == 0 && trb_buff_len == 0) | 3104 | if (num_trbs_left == 0 || (running_total == 0 && trb_buff_len == 0)) |
| 3095 | return 0; | 3105 | return 0; |
| 3096 | 3106 | ||
| 3097 | /* All the TRB queueing functions don't count the current TRB in | 3107 | /* All the TRB queueing functions don't count the current TRB in |
| @@ -3100,7 +3110,9 @@ static u32 xhci_v1_0_td_remainder(int running_total, int trb_buff_len, | |||
| 3100 | packets_transferred = (running_total + trb_buff_len) / | 3110 | packets_transferred = (running_total + trb_buff_len) / |
| 3101 | usb_endpoint_maxp(&urb->ep->desc); | 3111 | usb_endpoint_maxp(&urb->ep->desc); |
| 3102 | 3112 | ||
| 3103 | return xhci_td_remainder(total_packet_count - packets_transferred); | 3113 | if ((total_packet_count - packets_transferred) > 31) |
| 3114 | return 31 << 17; | ||
| 3115 | return (total_packet_count - packets_transferred) << 17; | ||
| 3104 | } | 3116 | } |
| 3105 | 3117 | ||
| 3106 | static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | 3118 | static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, |
| @@ -3127,7 +3139,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
| 3127 | 3139 | ||
| 3128 | num_trbs = count_sg_trbs_needed(xhci, urb); | 3140 | num_trbs = count_sg_trbs_needed(xhci, urb); |
| 3129 | num_sgs = urb->num_mapped_sgs; | 3141 | num_sgs = urb->num_mapped_sgs; |
| 3130 | total_packet_count = roundup(urb->transfer_buffer_length, | 3142 | total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, |
| 3131 | usb_endpoint_maxp(&urb->ep->desc)); | 3143 | usb_endpoint_maxp(&urb->ep->desc)); |
| 3132 | 3144 | ||
| 3133 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], | 3145 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], |
| @@ -3210,7 +3222,8 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
| 3210 | running_total); | 3222 | running_total); |
| 3211 | } else { | 3223 | } else { |
| 3212 | remainder = xhci_v1_0_td_remainder(running_total, | 3224 | remainder = xhci_v1_0_td_remainder(running_total, |
| 3213 | trb_buff_len, total_packet_count, urb); | 3225 | trb_buff_len, total_packet_count, urb, |
| 3226 | num_trbs - 1); | ||
| 3214 | } | 3227 | } |
| 3215 | length_field = TRB_LEN(trb_buff_len) | | 3228 | length_field = TRB_LEN(trb_buff_len) | |
| 3216 | remainder | | 3229 | remainder | |
| @@ -3318,7 +3331,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
| 3318 | start_cycle = ep_ring->cycle_state; | 3331 | start_cycle = ep_ring->cycle_state; |
| 3319 | 3332 | ||
| 3320 | running_total = 0; | 3333 | running_total = 0; |
| 3321 | total_packet_count = roundup(urb->transfer_buffer_length, | 3334 | total_packet_count = DIV_ROUND_UP(urb->transfer_buffer_length, |
| 3322 | usb_endpoint_maxp(&urb->ep->desc)); | 3335 | usb_endpoint_maxp(&urb->ep->desc)); |
| 3323 | /* How much data is in the first TRB? */ | 3336 | /* How much data is in the first TRB? */ |
| 3324 | addr = (u64) urb->transfer_dma; | 3337 | addr = (u64) urb->transfer_dma; |
| @@ -3364,7 +3377,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
| 3364 | running_total); | 3377 | running_total); |
| 3365 | } else { | 3378 | } else { |
| 3366 | remainder = xhci_v1_0_td_remainder(running_total, | 3379 | remainder = xhci_v1_0_td_remainder(running_total, |
| 3367 | trb_buff_len, total_packet_count, urb); | 3380 | trb_buff_len, total_packet_count, urb, |
| 3381 | num_trbs - 1); | ||
| 3368 | } | 3382 | } |
| 3369 | length_field = TRB_LEN(trb_buff_len) | | 3383 | length_field = TRB_LEN(trb_buff_len) | |
| 3370 | remainder | | 3384 | remainder | |
| @@ -3627,7 +3641,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; | 3641 | addr = start_addr + urb->iso_frame_desc[i].offset; |
| 3628 | td_len = urb->iso_frame_desc[i].length; | 3642 | td_len = urb->iso_frame_desc[i].length; |
| 3629 | td_remain_len = td_len; | 3643 | td_remain_len = td_len; |
| 3630 | total_packet_count = roundup(td_len, | 3644 | total_packet_count = DIV_ROUND_UP(td_len, |
| 3631 | usb_endpoint_maxp(&urb->ep->desc)); | 3645 | usb_endpoint_maxp(&urb->ep->desc)); |
| 3632 | /* A zero-length transfer still involves at least one packet. */ | 3646 | /* A zero-length transfer still involves at least one packet. */ |
| 3633 | if (total_packet_count == 0) | 3647 | if (total_packet_count == 0) |
| @@ -3706,7 +3720,8 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
| 3706 | } else { | 3720 | } else { |
| 3707 | remainder = xhci_v1_0_td_remainder( | 3721 | remainder = xhci_v1_0_td_remainder( |
| 3708 | running_total, trb_buff_len, | 3722 | running_total, trb_buff_len, |
| 3709 | total_packet_count, urb); | 3723 | total_packet_count, urb, |
| 3724 | (trbs_per_td - j - 1)); | ||
| 3710 | } | 3725 | } |
| 3711 | length_field = TRB_LEN(trb_buff_len) | | 3726 | length_field = TRB_LEN(trb_buff_len) | |
| 3712 | remainder | | 3727 | remainder | |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c9e419f29b74..f1f01a834ba7 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,15 @@ 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 | |||
| 887 | /* Don't poll the roothubs on bus suspend. */ | ||
| 888 | xhci_dbg(xhci, "%s: stopping port polling.\n", __func__); | ||
| 889 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
| 890 | del_timer_sync(&hcd->rh_timer); | ||
| 891 | |||
| 883 | spin_lock_irq(&xhci->lock); | 892 | spin_lock_irq(&xhci->lock); |
| 884 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 893 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
| 885 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); | 894 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); |
| @@ -890,7 +899,7 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
| 890 | command = xhci_readl(xhci, &xhci->op_regs->command); | 899 | command = xhci_readl(xhci, &xhci->op_regs->command); |
| 891 | command &= ~CMD_RUN; | 900 | command &= ~CMD_RUN; |
| 892 | xhci_writel(xhci, command, &xhci->op_regs->command); | 901 | xhci_writel(xhci, command, &xhci->op_regs->command); |
| 893 | if (handshake(xhci, &xhci->op_regs->status, | 902 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
| 894 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { | 903 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { |
| 895 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); | 904 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); |
| 896 | spin_unlock_irq(&xhci->lock); | 905 | spin_unlock_irq(&xhci->lock); |
| @@ -905,7 +914,8 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
| 905 | command = xhci_readl(xhci, &xhci->op_regs->command); | 914 | command = xhci_readl(xhci, &xhci->op_regs->command); |
| 906 | command |= CMD_CSS; | 915 | command |= CMD_CSS; |
| 907 | xhci_writel(xhci, command, &xhci->op_regs->command); | 916 | xhci_writel(xhci, command, &xhci->op_regs->command); |
| 908 | if (handshake(xhci, &xhci->op_regs->status, STS_SAVE, 0, 10 * 1000)) { | 917 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
| 918 | STS_SAVE, 0, 10 * 1000)) { | ||
| 909 | xhci_warn(xhci, "WARN: xHC save state timeout\n"); | 919 | xhci_warn(xhci, "WARN: xHC save state timeout\n"); |
| 910 | spin_unlock_irq(&xhci->lock); | 920 | spin_unlock_irq(&xhci->lock); |
| 911 | return -ETIMEDOUT; | 921 | return -ETIMEDOUT; |
| @@ -967,7 +977,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
| 967 | command = xhci_readl(xhci, &xhci->op_regs->command); | 977 | command = xhci_readl(xhci, &xhci->op_regs->command); |
| 968 | command |= CMD_CRS; | 978 | command |= CMD_CRS; |
| 969 | xhci_writel(xhci, command, &xhci->op_regs->command); | 979 | xhci_writel(xhci, command, &xhci->op_regs->command); |
| 970 | if (handshake(xhci, &xhci->op_regs->status, | 980 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
| 971 | STS_RESTORE, 0, 10 * 1000)) { | 981 | STS_RESTORE, 0, 10 * 1000)) { |
| 972 | xhci_warn(xhci, "WARN: xHC restore state timeout\n"); | 982 | xhci_warn(xhci, "WARN: xHC restore state timeout\n"); |
| 973 | spin_unlock_irq(&xhci->lock); | 983 | spin_unlock_irq(&xhci->lock); |
| @@ -1035,7 +1045,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
| 1035 | command = xhci_readl(xhci, &xhci->op_regs->command); | 1045 | command = xhci_readl(xhci, &xhci->op_regs->command); |
| 1036 | command |= CMD_RUN; | 1046 | command |= CMD_RUN; |
| 1037 | xhci_writel(xhci, command, &xhci->op_regs->command); | 1047 | xhci_writel(xhci, command, &xhci->op_regs->command); |
| 1038 | handshake(xhci, &xhci->op_regs->status, STS_HALT, | 1048 | xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT, |
| 1039 | 0, 250 * 1000); | 1049 | 0, 250 * 1000); |
| 1040 | 1050 | ||
| 1041 | /* step 5: walk topology and initialize portsc, | 1051 | /* step 5: walk topology and initialize portsc, |
| @@ -1064,6 +1074,11 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) | |||
| 1064 | if (xhci->quirks & XHCI_COMP_MODE_QUIRK) | 1074 | if (xhci->quirks & XHCI_COMP_MODE_QUIRK) |
| 1065 | compliance_mode_recovery_timer_init(xhci); | 1075 | compliance_mode_recovery_timer_init(xhci); |
| 1066 | 1076 | ||
| 1077 | /* Re-enable port polling. */ | ||
| 1078 | xhci_dbg(xhci, "%s: starting port polling.\n", __func__); | ||
| 1079 | set_bit(HCD_FLAG_POLL_RH, &hcd->flags); | ||
| 1080 | usb_hcd_poll_rh_status(hcd); | ||
| 1081 | |||
| 1067 | return retval; | 1082 | return retval; |
| 1068 | } | 1083 | } |
| 1069 | #endif /* CONFIG_PM */ | 1084 | #endif /* CONFIG_PM */ |
| @@ -2254,7 +2269,7 @@ static bool xhci_is_async_ep(unsigned int ep_type) | |||
| 2254 | 2269 | ||
| 2255 | static bool xhci_is_sync_in_ep(unsigned int ep_type) | 2270 | static bool xhci_is_sync_in_ep(unsigned int ep_type) |
| 2256 | { | 2271 | { |
| 2257 | return (ep_type == ISOC_IN_EP || ep_type != INT_IN_EP); | 2272 | return (ep_type == ISOC_IN_EP || ep_type == INT_IN_EP); |
| 2258 | } | 2273 | } |
| 2259 | 2274 | ||
| 2260 | static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw) | 2275 | static unsigned int xhci_get_ss_bw_consumed(struct xhci_bw_info *ep_bw) |
| @@ -3874,7 +3889,8 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | |||
| 3874 | spin_lock_irqsave(&xhci->lock, flags); | 3889 | spin_lock_irqsave(&xhci->lock, flags); |
| 3875 | 3890 | ||
| 3876 | /* Check L1 Status */ | 3891 | /* Check L1 Status */ |
| 3877 | ret = handshake(xhci, pm_addr, PORT_L1S_MASK, PORT_L1S_SUCCESS, 125); | 3892 | ret = xhci_handshake(xhci, pm_addr, |
| 3893 | PORT_L1S_MASK, PORT_L1S_SUCCESS, 125); | ||
| 3878 | if (ret != -ETIMEDOUT) { | 3894 | if (ret != -ETIMEDOUT) { |
| 3879 | /* enter L1 successfully */ | 3895 | /* enter L1 successfully */ |
| 3880 | temp = xhci_readl(xhci, addr); | 3896 | 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/Kconfig b/drivers/usb/misc/Kconfig index a8f05239350e..fecde69bfa7d 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
| @@ -246,6 +246,7 @@ config USB_YUREX | |||
| 246 | 246 | ||
| 247 | config USB_EZUSB_FX2 | 247 | config USB_EZUSB_FX2 |
| 248 | tristate "Functions for loading firmware on EZUSB chips" | 248 | tristate "Functions for loading firmware on EZUSB chips" |
| 249 | depends on USB | ||
| 249 | help | 250 | help |
| 250 | Say Y here if you need EZUSB device support. | 251 | Say Y here if you need EZUSB device support. |
| 251 | (Cypress FX/FX2/FX2LP microcontrollers) | 252 | (Cypress FX/FX2/FX2LP microcontrollers) |
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..268148de9714 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
| @@ -423,6 +423,9 @@ alloc_sglist(int nents, int max, int vary) | |||
| 423 | unsigned i; | 423 | unsigned i; |
| 424 | unsigned size = max; | 424 | unsigned size = max; |
| 425 | 425 | ||
| 426 | if (max == 0) | ||
| 427 | return NULL; | ||
| 428 | |||
| 426 | sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL); | 429 | sg = kmalloc_array(nents, sizeof *sg, GFP_KERNEL); |
| 427 | if (!sg) | 430 | if (!sg) |
| 428 | return NULL; | 431 | return NULL; |
| @@ -2176,7 +2179,7 @@ usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf) | |||
| 2176 | if (dev->out_pipe == 0 || !param->length || param->sglen < 4) | 2179 | if (dev->out_pipe == 0 || !param->length || param->sglen < 4) |
| 2177 | break; | 2180 | break; |
| 2178 | retval = 0; | 2181 | retval = 0; |
| 2179 | dev_info(&intf->dev, "TEST 17: unlink from %d queues of " | 2182 | dev_info(&intf->dev, "TEST 24: unlink from %d queues of " |
| 2180 | "%d %d-byte writes\n", | 2183 | "%d %d-byte writes\n", |
| 2181 | param->iterations, param->sglen, param->length); | 2184 | param->iterations, param->sglen, param->length); |
| 2182 | for (i = param->iterations; retval == 0 && i > 0; --i) { | 2185 | for (i = param->iterations; retval == 0 && i > 0; --i) { |
| @@ -2386,6 +2389,7 @@ static struct usbtest_info gz_info = { | |||
| 2386 | .name = "Linux gadget zero", | 2389 | .name = "Linux gadget zero", |
| 2387 | .autoconf = 1, | 2390 | .autoconf = 1, |
| 2388 | .ctrl_out = 1, | 2391 | .ctrl_out = 1, |
| 2392 | .iso = 1, | ||
| 2389 | .alt = 0, | 2393 | .alt = 0, |
| 2390 | }; | 2394 | }; |
| 2391 | 2395 | ||
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index c964d6af178b..c107d7cdfa69 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
| @@ -34,8 +34,7 @@ | |||
| 34 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
| 35 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
| 36 | #include <linux/usb/nop-usb-xceiv.h> | 36 | #include <linux/usb/nop-usb-xceiv.h> |
| 37 | 37 | #include <linux/platform_data/usb-omap.h> | |
| 38 | #include <plat/usb.h> | ||
| 39 | 38 | ||
| 40 | #include "musb_core.h" | 39 | #include "musb_core.h" |
| 41 | 40 | ||
| @@ -455,7 +454,7 @@ static const struct musb_platform_ops am35x_ops = { | |||
| 455 | 454 | ||
| 456 | static u64 am35x_dmamask = DMA_BIT_MASK(32); | 455 | static u64 am35x_dmamask = DMA_BIT_MASK(32); |
| 457 | 456 | ||
| 458 | static int __devinit am35x_probe(struct platform_device *pdev) | 457 | static int am35x_probe(struct platform_device *pdev) |
| 459 | { | 458 | { |
| 460 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 459 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 461 | struct platform_device *musb; | 460 | struct platform_device *musb; |
| @@ -465,7 +464,6 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
| 465 | struct clk *clk; | 464 | struct clk *clk; |
| 466 | 465 | ||
| 467 | int ret = -ENOMEM; | 466 | int ret = -ENOMEM; |
| 468 | int musbid; | ||
| 469 | 467 | ||
| 470 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 468 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
| 471 | if (!glue) { | 469 | if (!glue) { |
| @@ -473,18 +471,10 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
| 473 | goto err0; | 471 | goto err0; |
| 474 | } | 472 | } |
| 475 | 473 | ||
| 476 | /* get the musb id */ | 474 | 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) { | 475 | if (!musb) { |
| 486 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 476 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
| 487 | goto err2; | 477 | goto err1; |
| 488 | } | 478 | } |
| 489 | 479 | ||
| 490 | phy_clk = clk_get(&pdev->dev, "fck"); | 480 | phy_clk = clk_get(&pdev->dev, "fck"); |
| @@ -513,7 +503,6 @@ static int __devinit am35x_probe(struct platform_device *pdev) | |||
| 513 | goto err6; | 503 | goto err6; |
| 514 | } | 504 | } |
| 515 | 505 | ||
| 516 | musb->id = musbid; | ||
| 517 | musb->dev.parent = &pdev->dev; | 506 | musb->dev.parent = &pdev->dev; |
| 518 | musb->dev.dma_mask = &am35x_dmamask; | 507 | musb->dev.dma_mask = &am35x_dmamask; |
| 519 | musb->dev.coherent_dma_mask = am35x_dmamask; | 508 | musb->dev.coherent_dma_mask = am35x_dmamask; |
| @@ -563,9 +552,6 @@ err4: | |||
| 563 | err3: | 552 | err3: |
| 564 | platform_device_put(musb); | 553 | platform_device_put(musb); |
| 565 | 554 | ||
| 566 | err2: | ||
| 567 | musb_put_id(&pdev->dev, musbid); | ||
| 568 | |||
| 569 | err1: | 555 | err1: |
| 570 | kfree(glue); | 556 | kfree(glue); |
| 571 | 557 | ||
| @@ -573,13 +559,11 @@ err0: | |||
| 573 | return ret; | 559 | return ret; |
| 574 | } | 560 | } |
| 575 | 561 | ||
| 576 | static int __devexit am35x_remove(struct platform_device *pdev) | 562 | static int am35x_remove(struct platform_device *pdev) |
| 577 | { | 563 | { |
| 578 | struct am35x_glue *glue = platform_get_drvdata(pdev); | 564 | struct am35x_glue *glue = platform_get_drvdata(pdev); |
| 579 | 565 | ||
| 580 | musb_put_id(&pdev->dev, glue->musb->id); | 566 | platform_device_unregister(glue->musb); |
| 581 | platform_device_del(glue->musb); | ||
| 582 | platform_device_put(glue->musb); | ||
| 583 | clk_disable(glue->clk); | 567 | clk_disable(glue->clk); |
| 584 | clk_disable(glue->phy_clk); | 568 | clk_disable(glue->phy_clk); |
| 585 | clk_put(glue->clk); | 569 | clk_put(glue->clk); |
| @@ -644,7 +628,7 @@ static struct dev_pm_ops am35x_pm_ops = { | |||
| 644 | 628 | ||
| 645 | static struct platform_driver am35x_driver = { | 629 | static struct platform_driver am35x_driver = { |
| 646 | .probe = am35x_probe, | 630 | .probe = am35x_probe, |
| 647 | .remove = __devexit_p(am35x_remove), | 631 | .remove = am35x_remove, |
| 648 | .driver = { | 632 | .driver = { |
| 649 | .name = "musb-am35x", | 633 | .name = "musb-am35x", |
| 650 | .pm = DEV_PM_OPS, | 634 | .pm = DEV_PM_OPS, |
| @@ -654,15 +638,4 @@ static struct platform_driver am35x_driver = { | |||
| 654 | MODULE_DESCRIPTION("AM35x MUSB Glue Layer"); | 638 | MODULE_DESCRIPTION("AM35x MUSB Glue Layer"); |
| 655 | MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); | 639 | MODULE_AUTHOR("Ajay Kumar Gupta <ajay.gupta@ti.com>"); |
| 656 | MODULE_LICENSE("GPL v2"); | 640 | MODULE_LICENSE("GPL v2"); |
| 657 | 641 | 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..14dab9f9b3d0 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
| @@ -448,14 +448,13 @@ static const struct musb_platform_ops bfin_ops = { | |||
| 448 | 448 | ||
| 449 | static u64 bfin_dmamask = DMA_BIT_MASK(32); | 449 | static u64 bfin_dmamask = DMA_BIT_MASK(32); |
| 450 | 450 | ||
| 451 | static int __devinit bfin_probe(struct platform_device *pdev) | 451 | static int bfin_probe(struct platform_device *pdev) |
| 452 | { | 452 | { |
| 453 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 453 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 454 | struct platform_device *musb; | 454 | struct platform_device *musb; |
| 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 | ||
| @@ -523,13 +510,11 @@ err0: | |||
| 523 | return ret; | 510 | return ret; |
| 524 | } | 511 | } |
| 525 | 512 | ||
| 526 | static int __devexit bfin_remove(struct platform_device *pdev) | 513 | static int 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..0968dd7a859d 100644 --- a/drivers/usb/musb/cppi_dma.c +++ b/drivers/usb/musb/cppi_dma.c | |||
| @@ -1314,10 +1314,10 @@ 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 *dma_controller_create(struct musb *musb, void __iomem *mregs) |
| 1320 | dma_controller_create(struct musb *musb, void __iomem *mregs) | ||
| 1321 | { | 1321 | { |
| 1322 | struct cppi *controller; | 1322 | struct cppi *controller; |
| 1323 | struct device *dev = musb->controller; | 1323 | struct device *dev = musb->controller; |
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 8bc44b76eec2..97996af2646e 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
| @@ -471,7 +471,7 @@ static const struct musb_platform_ops da8xx_ops = { | |||
| 471 | 471 | ||
| 472 | static u64 da8xx_dmamask = DMA_BIT_MASK(32); | 472 | static u64 da8xx_dmamask = DMA_BIT_MASK(32); |
| 473 | 473 | ||
| 474 | static int __devinit da8xx_probe(struct platform_device *pdev) | 474 | static int da8xx_probe(struct platform_device *pdev) |
| 475 | { | 475 | { |
| 476 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 476 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 477 | struct platform_device *musb; | 477 | struct platform_device *musb; |
| @@ -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 | ||
| @@ -568,13 +555,11 @@ err0: | |||
| 568 | return ret; | 555 | return ret; |
| 569 | } | 556 | } |
| 570 | 557 | ||
| 571 | static int __devexit da8xx_remove(struct platform_device *pdev) | 558 | static int 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); |
| @@ -584,7 +569,7 @@ static int __devexit da8xx_remove(struct platform_device *pdev) | |||
| 584 | 569 | ||
| 585 | static struct platform_driver da8xx_driver = { | 570 | static struct platform_driver da8xx_driver = { |
| 586 | .probe = da8xx_probe, | 571 | .probe = da8xx_probe, |
| 587 | .remove = __devexit_p(da8xx_remove), | 572 | .remove = da8xx_remove, |
| 588 | .driver = { | 573 | .driver = { |
| 589 | .name = "musb-da8xx", | 574 | .name = "musb-da8xx", |
| 590 | }, | 575 | }, |
| @@ -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..b1c01cad28b2 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
| @@ -504,7 +504,7 @@ static const struct musb_platform_ops davinci_ops = { | |||
| 504 | 504 | ||
| 505 | static u64 davinci_dmamask = DMA_BIT_MASK(32); | 505 | static u64 davinci_dmamask = DMA_BIT_MASK(32); |
| 506 | 506 | ||
| 507 | static int __devinit davinci_probe(struct platform_device *pdev) | 507 | static int davinci_probe(struct platform_device *pdev) |
| 508 | { | 508 | { |
| 509 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 509 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 510 | struct platform_device *musb; | 510 | struct platform_device *musb; |
| @@ -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 | ||
| @@ -600,13 +587,11 @@ err0: | |||
| 600 | return ret; | 587 | return ret; |
| 601 | } | 588 | } |
| 602 | 589 | ||
| 603 | static int __devexit davinci_remove(struct platform_device *pdev) | 590 | static int 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); |
| @@ -616,7 +601,7 @@ static int __devexit davinci_remove(struct platform_device *pdev) | |||
| 616 | 601 | ||
| 617 | static struct platform_driver davinci_driver = { | 602 | static struct platform_driver davinci_driver = { |
| 618 | .probe = davinci_probe, | 603 | .probe = davinci_probe, |
| 619 | .remove = __devexit_p(davinci_remove), | 604 | .remove = davinci_remove, |
| 620 | .driver = { | 605 | .driver = { |
| 621 | .name = "musb-davinci", | 606 | .name = "musb-davinci", |
| 622 | }, | 607 | }, |
| @@ -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..fd3486745e64 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 | { |
| @@ -281,7 +251,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) | |||
| 281 | /* best case is 32bit-aligned source address */ | 251 | /* best case is 32bit-aligned source address */ |
| 282 | if ((0x02 & (unsigned long) src) == 0) { | 252 | if ((0x02 & (unsigned long) src) == 0) { |
| 283 | if (len >= 4) { | 253 | if (len >= 4) { |
| 284 | writesl(fifo, src + index, len >> 2); | 254 | iowrite32_rep(fifo, src + index, len >> 2); |
| 285 | index += len & ~0x03; | 255 | index += len & ~0x03; |
| 286 | } | 256 | } |
| 287 | if (len & 0x02) { | 257 | if (len & 0x02) { |
| @@ -290,7 +260,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) | |||
| 290 | } | 260 | } |
| 291 | } else { | 261 | } else { |
| 292 | if (len >= 2) { | 262 | if (len >= 2) { |
| 293 | writesw(fifo, src + index, len >> 1); | 263 | iowrite16_rep(fifo, src + index, len >> 1); |
| 294 | index += len & ~0x01; | 264 | index += len & ~0x01; |
| 295 | } | 265 | } |
| 296 | } | 266 | } |
| @@ -298,7 +268,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) | |||
| 298 | musb_writeb(fifo, 0, src[index]); | 268 | musb_writeb(fifo, 0, src[index]); |
| 299 | } else { | 269 | } else { |
| 300 | /* byte aligned */ | 270 | /* byte aligned */ |
| 301 | writesb(fifo, src, len); | 271 | iowrite8_rep(fifo, src, len); |
| 302 | } | 272 | } |
| 303 | } | 273 | } |
| 304 | 274 | ||
| @@ -324,7 +294,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | |||
| 324 | /* best case is 32bit-aligned destination address */ | 294 | /* best case is 32bit-aligned destination address */ |
| 325 | if ((0x02 & (unsigned long) dst) == 0) { | 295 | if ((0x02 & (unsigned long) dst) == 0) { |
| 326 | if (len >= 4) { | 296 | if (len >= 4) { |
| 327 | readsl(fifo, dst, len >> 2); | 297 | ioread32_rep(fifo, dst, len >> 2); |
| 328 | index = len & ~0x03; | 298 | index = len & ~0x03; |
| 329 | } | 299 | } |
| 330 | if (len & 0x02) { | 300 | if (len & 0x02) { |
| @@ -333,7 +303,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | |||
| 333 | } | 303 | } |
| 334 | } else { | 304 | } else { |
| 335 | if (len >= 2) { | 305 | if (len >= 2) { |
| 336 | readsw(fifo, dst, len >> 1); | 306 | ioread16_rep(fifo, dst, len >> 1); |
| 337 | index = len & ~0x01; | 307 | index = len & ~0x01; |
| 338 | } | 308 | } |
| 339 | } | 309 | } |
| @@ -341,7 +311,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst) | |||
| 341 | dst[index] = musb_readb(fifo, 0); | 311 | dst[index] = musb_readb(fifo, 0); |
| 342 | } else { | 312 | } else { |
| 343 | /* byte aligned */ | 313 | /* byte aligned */ |
| 344 | readsb(fifo, dst, len); | 314 | ioread8_rep(fifo, dst, len); |
| 345 | } | 315 | } |
| 346 | } | 316 | } |
| 347 | #endif | 317 | #endif |
| @@ -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 */ |
| @@ -1062,12 +1040,12 @@ static void musb_shutdown(struct platform_device *pdev) | |||
| 1062 | || defined(CONFIG_USB_MUSB_AM35X_MODULE) \ | 1040 | || defined(CONFIG_USB_MUSB_AM35X_MODULE) \ |
| 1063 | || defined(CONFIG_USB_MUSB_DSPS) \ | 1041 | || defined(CONFIG_USB_MUSB_DSPS) \ |
| 1064 | || defined(CONFIG_USB_MUSB_DSPS_MODULE) | 1042 | || defined(CONFIG_USB_MUSB_DSPS_MODULE) |
| 1065 | static ushort __devinitdata fifo_mode = 4; | 1043 | static ushort fifo_mode = 4; |
| 1066 | #elif defined(CONFIG_USB_MUSB_UX500) \ | 1044 | #elif defined(CONFIG_USB_MUSB_UX500) \ |
| 1067 | || defined(CONFIG_USB_MUSB_UX500_MODULE) | 1045 | || defined(CONFIG_USB_MUSB_UX500_MODULE) |
| 1068 | static ushort __devinitdata fifo_mode = 5; | 1046 | static ushort fifo_mode = 5; |
| 1069 | #else | 1047 | #else |
| 1070 | static ushort __devinitdata fifo_mode = 2; | 1048 | static ushort fifo_mode = 2; |
| 1071 | #endif | 1049 | #endif |
| 1072 | 1050 | ||
| 1073 | /* "modprobe ... fifo_mode=1" etc */ | 1051 | /* "modprobe ... fifo_mode=1" etc */ |
| @@ -1080,7 +1058,7 @@ MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration"); | |||
| 1080 | */ | 1058 | */ |
| 1081 | 1059 | ||
| 1082 | /* mode 0 - fits in 2KB */ | 1060 | /* mode 0 - fits in 2KB */ |
| 1083 | static struct musb_fifo_cfg __devinitdata mode_0_cfg[] = { | 1061 | static struct musb_fifo_cfg mode_0_cfg[] = { |
| 1084 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1062 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
| 1085 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1063 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
| 1086 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, | 1064 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, |
| @@ -1089,7 +1067,7 @@ static struct musb_fifo_cfg __devinitdata mode_0_cfg[] = { | |||
| 1089 | }; | 1067 | }; |
| 1090 | 1068 | ||
| 1091 | /* mode 1 - fits in 4KB */ | 1069 | /* mode 1 - fits in 4KB */ |
| 1092 | static struct musb_fifo_cfg __devinitdata mode_1_cfg[] = { | 1070 | static struct musb_fifo_cfg mode_1_cfg[] = { |
| 1093 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1071 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
| 1094 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1072 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
| 1095 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1073 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
| @@ -1098,7 +1076,7 @@ static struct musb_fifo_cfg __devinitdata mode_1_cfg[] = { | |||
| 1098 | }; | 1076 | }; |
| 1099 | 1077 | ||
| 1100 | /* mode 2 - fits in 4KB */ | 1078 | /* mode 2 - fits in 4KB */ |
| 1101 | static struct musb_fifo_cfg __devinitdata mode_2_cfg[] = { | 1079 | static struct musb_fifo_cfg mode_2_cfg[] = { |
| 1102 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1080 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
| 1103 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1081 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
| 1104 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1082 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
| @@ -1108,7 +1086,7 @@ static struct musb_fifo_cfg __devinitdata mode_2_cfg[] = { | |||
| 1108 | }; | 1086 | }; |
| 1109 | 1087 | ||
| 1110 | /* mode 3 - fits in 4KB */ | 1088 | /* mode 3 - fits in 4KB */ |
| 1111 | static struct musb_fifo_cfg __devinitdata mode_3_cfg[] = { | 1089 | static struct musb_fifo_cfg mode_3_cfg[] = { |
| 1112 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1090 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
| 1113 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1091 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
| 1114 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1092 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
| @@ -1118,7 +1096,7 @@ static struct musb_fifo_cfg __devinitdata mode_3_cfg[] = { | |||
| 1118 | }; | 1096 | }; |
| 1119 | 1097 | ||
| 1120 | /* mode 4 - fits in 16KB */ | 1098 | /* mode 4 - fits in 16KB */ |
| 1121 | static struct musb_fifo_cfg __devinitdata mode_4_cfg[] = { | 1099 | static struct musb_fifo_cfg mode_4_cfg[] = { |
| 1122 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1100 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
| 1123 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1101 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
| 1124 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1102 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
| @@ -1149,7 +1127,7 @@ static struct musb_fifo_cfg __devinitdata mode_4_cfg[] = { | |||
| 1149 | }; | 1127 | }; |
| 1150 | 1128 | ||
| 1151 | /* mode 5 - fits in 8KB */ | 1129 | /* mode 5 - fits in 8KB */ |
| 1152 | static struct musb_fifo_cfg __devinitdata mode_5_cfg[] = { | 1130 | static struct musb_fifo_cfg mode_5_cfg[] = { |
| 1153 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1131 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
| 1154 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1132 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
| 1155 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1133 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
| @@ -1185,7 +1163,7 @@ static struct musb_fifo_cfg __devinitdata mode_5_cfg[] = { | |||
| 1185 | * | 1163 | * |
| 1186 | * returns negative errno or offset for next fifo. | 1164 | * returns negative errno or offset for next fifo. |
| 1187 | */ | 1165 | */ |
| 1188 | static int __devinit | 1166 | static int |
| 1189 | fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, | 1167 | fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, |
| 1190 | const struct musb_fifo_cfg *cfg, u16 offset) | 1168 | const struct musb_fifo_cfg *cfg, u16 offset) |
| 1191 | { | 1169 | { |
| @@ -1256,11 +1234,11 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, | |||
| 1256 | return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); | 1234 | return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); |
| 1257 | } | 1235 | } |
| 1258 | 1236 | ||
| 1259 | static struct musb_fifo_cfg __devinitdata ep0_cfg = { | 1237 | static struct musb_fifo_cfg ep0_cfg = { |
| 1260 | .style = FIFO_RXTX, .maxpacket = 64, | 1238 | .style = FIFO_RXTX, .maxpacket = 64, |
| 1261 | }; | 1239 | }; |
| 1262 | 1240 | ||
| 1263 | static int __devinit ep_config_from_table(struct musb *musb) | 1241 | static int ep_config_from_table(struct musb *musb) |
| 1264 | { | 1242 | { |
| 1265 | const struct musb_fifo_cfg *cfg; | 1243 | const struct musb_fifo_cfg *cfg; |
| 1266 | unsigned i, n; | 1244 | unsigned i, n; |
| @@ -1351,7 +1329,7 @@ done: | |||
| 1351 | * ep_config_from_hw - when MUSB_C_DYNFIFO_DEF is false | 1329 | * ep_config_from_hw - when MUSB_C_DYNFIFO_DEF is false |
| 1352 | * @param musb the controller | 1330 | * @param musb the controller |
| 1353 | */ | 1331 | */ |
| 1354 | static int __devinit ep_config_from_hw(struct musb *musb) | 1332 | static int ep_config_from_hw(struct musb *musb) |
| 1355 | { | 1333 | { |
| 1356 | u8 epnum = 0; | 1334 | u8 epnum = 0; |
| 1357 | struct musb_hw_ep *hw_ep; | 1335 | struct musb_hw_ep *hw_ep; |
| @@ -1398,7 +1376,7 @@ enum { MUSB_CONTROLLER_MHDRC, MUSB_CONTROLLER_HDRC, }; | |||
| 1398 | /* Initialize MUSB (M)HDRC part of the USB hardware subsystem; | 1376 | /* Initialize MUSB (M)HDRC part of the USB hardware subsystem; |
| 1399 | * configure endpoints, or take their config from silicon | 1377 | * configure endpoints, or take their config from silicon |
| 1400 | */ | 1378 | */ |
| 1401 | static int __devinit musb_core_init(u16 musb_type, struct musb *musb) | 1379 | static int musb_core_init(u16 musb_type, struct musb *musb) |
| 1402 | { | 1380 | { |
| 1403 | u8 reg; | 1381 | u8 reg; |
| 1404 | char *type; | 1382 | char *type; |
| @@ -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 | ||
| @@ -1628,7 +1578,7 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
| 1628 | EXPORT_SYMBOL_GPL(musb_interrupt); | 1578 | EXPORT_SYMBOL_GPL(musb_interrupt); |
| 1629 | 1579 | ||
| 1630 | #ifndef CONFIG_MUSB_PIO_ONLY | 1580 | #ifndef CONFIG_MUSB_PIO_ONLY |
| 1631 | static bool __devinitdata use_dma = 1; | 1581 | static bool use_dma = 1; |
| 1632 | 1582 | ||
| 1633 | /* "modprobe ... use_dma=0" etc */ | 1583 | /* "modprobe ... use_dma=0" etc */ |
| 1634 | module_param(use_dma, bool, 0); | 1584 | module_param(use_dma, bool, 0); |
| @@ -1809,8 +1759,7 @@ static void musb_irq_work(struct work_struct *data) | |||
| 1809 | * Init support | 1759 | * Init support |
| 1810 | */ | 1760 | */ |
| 1811 | 1761 | ||
| 1812 | static struct musb *__devinit | 1762 | static struct musb *allocate_instance(struct device *dev, |
| 1813 | allocate_instance(struct device *dev, | ||
| 1814 | struct musb_hdrc_config *config, void __iomem *mbase) | 1763 | struct musb_hdrc_config *config, void __iomem *mbase) |
| 1815 | { | 1764 | { |
| 1816 | struct musb *musb; | 1765 | struct musb *musb; |
| @@ -1885,7 +1834,7 @@ static void musb_free(struct musb *musb) | |||
| 1885 | * @ctrl: virtual address of controller registers, | 1834 | * @ctrl: virtual address of controller registers, |
| 1886 | * not yet corrected for platform-specific offsets | 1835 | * not yet corrected for platform-specific offsets |
| 1887 | */ | 1836 | */ |
| 1888 | static int __devinit | 1837 | static int |
| 1889 | musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | 1838 | musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) |
| 1890 | { | 1839 | { |
| 1891 | int status; | 1840 | int status; |
| @@ -1919,7 +1868,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
| 1919 | musb->ops = plat->platform_ops; | 1868 | musb->ops = plat->platform_ops; |
| 1920 | 1869 | ||
| 1921 | /* The musb_platform_init() call: | 1870 | /* The musb_platform_init() call: |
| 1922 | * - adjusts musb->mregs and musb->isr if needed, | 1871 | * - adjusts musb->mregs |
| 1872 | * - sets the musb->isr | ||
| 1923 | * - may initialize an integrated tranceiver | 1873 | * - may initialize an integrated tranceiver |
| 1924 | * - initializes musb->xceiv, usually by otg_get_phy() | 1874 | * - initializes musb->xceiv, usually by otg_get_phy() |
| 1925 | * - stops powering VBUS | 1875 | * - stops powering VBUS |
| @@ -1929,7 +1879,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
| 1929 | * external/discrete ones in various flavors (twl4030 family, | 1879 | * external/discrete ones in various flavors (twl4030 family, |
| 1930 | * isp1504, non-OTG, etc) mostly hooking up through ULPI. | 1880 | * isp1504, non-OTG, etc) mostly hooking up through ULPI. |
| 1931 | */ | 1881 | */ |
| 1932 | musb->isr = generic_interrupt; | ||
| 1933 | status = musb_platform_init(musb); | 1882 | status = musb_platform_init(musb); |
| 1934 | if (status < 0) | 1883 | if (status < 0) |
| 1935 | goto fail1; | 1884 | goto fail1; |
| @@ -2060,7 +2009,7 @@ fail0: | |||
| 2060 | /* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just | 2009 | /* all implementations (PCI bridge to FPGA, VLYNQ, etc) should just |
| 2061 | * bridge to a platform device; this driver then suffices. | 2010 | * bridge to a platform device; this driver then suffices. |
| 2062 | */ | 2011 | */ |
| 2063 | static int __devinit musb_probe(struct platform_device *pdev) | 2012 | static int musb_probe(struct platform_device *pdev) |
| 2064 | { | 2013 | { |
| 2065 | struct device *dev = &pdev->dev; | 2014 | struct device *dev = &pdev->dev; |
| 2066 | int irq = platform_get_irq_byname(pdev, "mc"); | 2015 | int irq = platform_get_irq_byname(pdev, "mc"); |
| @@ -2085,7 +2034,7 @@ static int __devinit musb_probe(struct platform_device *pdev) | |||
| 2085 | return status; | 2034 | return status; |
| 2086 | } | 2035 | } |
| 2087 | 2036 | ||
| 2088 | static int __devexit musb_remove(struct platform_device *pdev) | 2037 | static int musb_remove(struct platform_device *pdev) |
| 2089 | { | 2038 | { |
| 2090 | struct device *dev = &pdev->dev; | 2039 | struct device *dev = &pdev->dev; |
| 2091 | struct musb *musb = dev_to_musb(dev); | 2040 | struct musb *musb = dev_to_musb(dev); |
| @@ -2120,8 +2069,6 @@ static void musb_save_context(struct musb *musb) | |||
| 2120 | musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); | 2069 | musb->context.testmode = musb_readb(musb_base, MUSB_TESTMODE); |
| 2121 | musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); | 2070 | musb->context.busctl = musb_read_ulpi_buscontrol(musb->mregs); |
| 2122 | musb->context.power = musb_readb(musb_base, MUSB_POWER); | 2071 | 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); | 2072 | musb->context.intrusbe = musb_readb(musb_base, MUSB_INTRUSBE); |
| 2126 | musb->context.index = musb_readb(musb_base, MUSB_INDEX); | 2073 | musb->context.index = musb_readb(musb_base, MUSB_INDEX); |
| 2127 | musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); | 2074 | musb->context.devctl = musb_readb(musb_base, MUSB_DEVCTL); |
| @@ -2194,8 +2141,8 @@ static void musb_restore_context(struct musb *musb) | |||
| 2194 | musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); | 2141 | musb_writeb(musb_base, MUSB_TESTMODE, musb->context.testmode); |
| 2195 | musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); | 2142 | musb_write_ulpi_buscontrol(musb->mregs, musb->context.busctl); |
| 2196 | musb_writeb(musb_base, MUSB_POWER, musb->context.power); | 2143 | musb_writeb(musb_base, MUSB_POWER, musb->context.power); |
| 2197 | musb_writew(musb_base, MUSB_INTRTXE, musb->context.intrtxe); | 2144 | musb_writew(musb_base, MUSB_INTRTXE, musb->intrtxe); |
| 2198 | musb_writew(musb_base, MUSB_INTRRXE, musb->context.intrrxe); | 2145 | musb_writew(musb_base, MUSB_INTRRXE, musb->intrrxe); |
| 2199 | musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); | 2146 | musb_writeb(musb_base, MUSB_INTRUSBE, musb->context.intrusbe); |
| 2200 | musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); | 2147 | musb_writeb(musb_base, MUSB_DEVCTL, musb->context.devctl); |
| 2201 | 2148 | ||
| @@ -2340,7 +2287,7 @@ static struct platform_driver musb_driver = { | |||
| 2340 | .pm = MUSB_DEV_PM_OPS, | 2287 | .pm = MUSB_DEV_PM_OPS, |
| 2341 | }, | 2288 | }, |
| 2342 | .probe = musb_probe, | 2289 | .probe = musb_probe, |
| 2343 | .remove = __devexit_p(musb_remove), | 2290 | .remove = musb_remove, |
| 2344 | .shutdown = musb_shutdown, | 2291 | .shutdown = musb_shutdown, |
| 2345 | }; | 2292 | }; |
| 2346 | 2293 | ||
| @@ -2351,10 +2298,7 @@ static int __init musb_init(void) | |||
| 2351 | if (usb_disabled()) | 2298 | if (usb_disabled()) |
| 2352 | return 0; | 2299 | return 0; |
| 2353 | 2300 | ||
| 2354 | pr_info("%s: version " MUSB_VERSION ", " | 2301 | pr_info("%s: version " MUSB_VERSION ", ?dma?, otg (peripheral+host)\n", |
| 2355 | "?dma?" | ||
| 2356 | ", " | ||
| 2357 | "otg (peripheral+host)", | ||
| 2358 | musb_driver_name); | 2302 | musb_driver_name); |
| 2359 | return platform_driver_register(&musb_driver); | 2303 | return platform_driver_register(&musb_driver); |
| 2360 | } | 2304 | } |
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_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 1d6e8af94c06..4c216790e86b 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c | |||
| @@ -233,7 +233,7 @@ static const struct file_operations musb_test_mode_fops = { | |||
| 233 | .release = single_release, | 233 | .release = single_release, |
| 234 | }; | 234 | }; |
| 235 | 235 | ||
| 236 | int __devinit musb_init_debugfs(struct musb *musb) | 236 | int musb_init_debugfs(struct musb *musb) |
| 237 | { | 237 | { |
| 238 | struct dentry *root; | 238 | struct dentry *root; |
| 239 | struct dentry *file; | 239 | struct dentry *file; |
diff --git a/drivers/usb/musb/musb_dma.h b/drivers/usb/musb/musb_dma.h index 24d39210d4ab..1b6b827b769f 100644 --- a/drivers/usb/musb/musb_dma.h +++ b/drivers/usb/musb/musb_dma.h | |||
| @@ -178,8 +178,7 @@ struct dma_controller { | |||
| 178 | extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); | 178 | extern void musb_dma_completion(struct musb *musb, u8 epnum, u8 transmit); |
| 179 | 179 | ||
| 180 | 180 | ||
| 181 | extern struct dma_controller *__devinit | 181 | extern struct dma_controller *dma_controller_create(struct musb *, void __iomem *); |
| 182 | dma_controller_create(struct musb *, void __iomem *); | ||
| 183 | 182 | ||
| 184 | extern void dma_controller_destroy(struct dma_controller *); | 183 | extern void dma_controller_destroy(struct dma_controller *); |
| 185 | 184 | ||
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index ff5f112053d2..f7d764de6fda 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c | |||
| @@ -38,13 +38,12 @@ | |||
| 38 | #include <linux/pm_runtime.h> | 38 | #include <linux/pm_runtime.h> |
| 39 | #include <linux/module.h> | 39 | #include <linux/module.h> |
| 40 | #include <linux/usb/nop-usb-xceiv.h> | 40 | #include <linux/usb/nop-usb-xceiv.h> |
| 41 | #include <linux/platform_data/usb-omap.h> | ||
| 41 | 42 | ||
| 42 | #include <linux/of.h> | 43 | #include <linux/of.h> |
| 43 | #include <linux/of_device.h> | 44 | #include <linux/of_device.h> |
| 44 | #include <linux/of_address.h> | 45 | #include <linux/of_address.h> |
| 45 | 46 | ||
| 46 | #include <plat/usb.h> | ||
| 47 | |||
| 48 | #include "musb_core.h" | 47 | #include "musb_core.h" |
| 49 | 48 | ||
| 50 | #ifdef CONFIG_OF | 49 | #ifdef CONFIG_OF |
| @@ -124,8 +123,49 @@ struct dsps_glue { | |||
| 124 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ | 123 | const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ |
| 125 | struct timer_list timer[2]; /* otg_workaround timer */ | 124 | struct timer_list timer[2]; /* otg_workaround timer */ |
| 126 | unsigned long last_timer[2]; /* last timer data for each instance */ | 125 | unsigned long last_timer[2]; /* last timer data for each instance */ |
| 126 | u32 __iomem *usb_ctrl[2]; | ||
| 127 | }; | ||
| 128 | |||
| 129 | #define DSPS_AM33XX_CONTROL_MODULE_PHYS_0 0x44e10620 | ||
| 130 | #define DSPS_AM33XX_CONTROL_MODULE_PHYS_1 0x44e10628 | ||
| 131 | |||
| 132 | static const resource_size_t dsps_control_module_phys[] = { | ||
| 133 | DSPS_AM33XX_CONTROL_MODULE_PHYS_0, | ||
| 134 | DSPS_AM33XX_CONTROL_MODULE_PHYS_1, | ||
| 127 | }; | 135 | }; |
| 128 | 136 | ||
| 137 | #define USBPHY_CM_PWRDN (1 << 0) | ||
| 138 | #define USBPHY_OTG_PWRDN (1 << 1) | ||
| 139 | #define USBPHY_OTGVDET_EN (1 << 19) | ||
| 140 | #define USBPHY_OTGSESSEND_EN (1 << 20) | ||
| 141 | |||
| 142 | /** | ||
| 143 | * musb_dsps_phy_control - phy on/off | ||
| 144 | * @glue: struct dsps_glue * | ||
| 145 | * @id: musb instance | ||
| 146 | * @on: flag for phy to be switched on or off | ||
| 147 | * | ||
| 148 | * This is to enable the PHY using usb_ctrl register in system control | ||
| 149 | * module space. | ||
| 150 | * | ||
| 151 | * XXX: This function will be removed once we have a seperate driver for | ||
| 152 | * control module | ||
| 153 | */ | ||
| 154 | static void musb_dsps_phy_control(struct dsps_glue *glue, u8 id, u8 on) | ||
| 155 | { | ||
| 156 | u32 usbphycfg; | ||
| 157 | |||
| 158 | usbphycfg = readl(glue->usb_ctrl[id]); | ||
| 159 | |||
| 160 | if (on) { | ||
| 161 | usbphycfg &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN); | ||
| 162 | usbphycfg |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN; | ||
| 163 | } else { | ||
| 164 | usbphycfg |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN; | ||
| 165 | } | ||
| 166 | |||
| 167 | writel(usbphycfg, glue->usb_ctrl[id]); | ||
| 168 | } | ||
| 129 | /** | 169 | /** |
| 130 | * dsps_musb_enable - enable interrupts | 170 | * dsps_musb_enable - enable interrupts |
| 131 | */ | 171 | */ |
| @@ -296,7 +336,7 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
| 296 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... | 336 | * Also, DRVVBUS pulses for SRP (but not at 5V) ... |
| 297 | */ | 337 | */ |
| 298 | if (usbintr & MUSB_INTR_BABBLE) | 338 | if (usbintr & MUSB_INTR_BABBLE) |
| 299 | pr_info("CAUTION: musb: Babble Interrupt Occured\n"); | 339 | pr_info("CAUTION: musb: Babble Interrupt Occurred\n"); |
| 300 | 340 | ||
| 301 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { | 341 | if (usbintr & ((1 << wrp->drvvbus) << wrp->usb_shift)) { |
| 302 | int drvvbus = dsps_readl(reg_base, wrp->status); | 342 | int drvvbus = dsps_readl(reg_base, wrp->status); |
| @@ -365,11 +405,9 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) | |||
| 365 | static int dsps_musb_init(struct musb *musb) | 405 | static int dsps_musb_init(struct musb *musb) |
| 366 | { | 406 | { |
| 367 | struct device *dev = musb->controller; | 407 | struct device *dev = musb->controller; |
| 368 | struct musb_hdrc_platform_data *plat = dev->platform_data; | ||
| 369 | struct platform_device *pdev = to_platform_device(dev); | 408 | struct platform_device *pdev = to_platform_device(dev); |
| 370 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 409 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
| 371 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 410 | 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; | 411 | void __iomem *reg_base = musb->ctrl_base; |
| 374 | u32 rev, val; | 412 | u32 rev, val; |
| 375 | int status; | 413 | int status; |
| @@ -377,7 +415,8 @@ static int dsps_musb_init(struct musb *musb) | |||
| 377 | /* mentor core register starts at offset of 0x400 from musb base */ | 415 | /* mentor core register starts at offset of 0x400 from musb base */ |
| 378 | musb->mregs += wrp->musb_core_offset; | 416 | musb->mregs += wrp->musb_core_offset; |
| 379 | 417 | ||
| 380 | /* Get the NOP PHY */ | 418 | /* NOP driver needs change if supporting dual instance */ |
| 419 | usb_nop_xceiv_register(); | ||
| 381 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); | 420 | musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); |
| 382 | if (IS_ERR_OR_NULL(musb->xceiv)) | 421 | if (IS_ERR_OR_NULL(musb->xceiv)) |
| 383 | return -ENODEV; | 422 | return -ENODEV; |
| @@ -395,8 +434,7 @@ static int dsps_musb_init(struct musb *musb) | |||
| 395 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); | 434 | dsps_writel(reg_base, wrp->control, (1 << wrp->reset)); |
| 396 | 435 | ||
| 397 | /* Start the on-chip PHY and its PLL. */ | 436 | /* Start the on-chip PHY and its PLL. */ |
| 398 | if (data->set_phy_power) | 437 | musb_dsps_phy_control(glue, pdev->id, 1); |
| 399 | data->set_phy_power(1); | ||
| 400 | 438 | ||
| 401 | musb->isr = dsps_interrupt; | 439 | musb->isr = dsps_interrupt; |
| 402 | 440 | ||
| @@ -418,16 +456,13 @@ err0: | |||
| 418 | static int dsps_musb_exit(struct musb *musb) | 456 | static int dsps_musb_exit(struct musb *musb) |
| 419 | { | 457 | { |
| 420 | struct device *dev = musb->controller; | 458 | 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); | 459 | struct platform_device *pdev = to_platform_device(dev); |
| 424 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); | 460 | struct dsps_glue *glue = dev_get_drvdata(dev->parent); |
| 425 | 461 | ||
| 426 | del_timer_sync(&glue->timer[pdev->id]); | 462 | del_timer_sync(&glue->timer[pdev->id]); |
| 427 | 463 | ||
| 428 | /* Shutdown the on-chip PHY and its PLL. */ | 464 | /* Shutdown the on-chip PHY and its PLL. */ |
| 429 | if (data->set_phy_power) | 465 | musb_dsps_phy_control(glue, pdev->id, 0); |
| 430 | data->set_phy_power(0); | ||
| 431 | 466 | ||
| 432 | /* NOP driver needs change if supporting dual instance */ | 467 | /* NOP driver needs change if supporting dual instance */ |
| 433 | usb_put_phy(musb->xceiv); | 468 | usb_put_phy(musb->xceiv); |
| @@ -448,7 +483,7 @@ static struct musb_platform_ops dsps_ops = { | |||
| 448 | 483 | ||
| 449 | static u64 musb_dmamask = DMA_BIT_MASK(32); | 484 | static u64 musb_dmamask = DMA_BIT_MASK(32); |
| 450 | 485 | ||
| 451 | static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | 486 | static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) |
| 452 | { | 487 | { |
| 453 | struct device *dev = glue->dev; | 488 | struct device *dev = glue->dev; |
| 454 | struct platform_device *pdev = to_platform_device(dev); | 489 | struct platform_device *pdev = to_platform_device(dev); |
| @@ -459,24 +494,33 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
| 459 | struct resource *res; | 494 | struct resource *res; |
| 460 | struct resource resources[2]; | 495 | struct resource resources[2]; |
| 461 | char res_name[11]; | 496 | char res_name[11]; |
| 462 | int ret, musbid; | 497 | int ret; |
| 463 | 498 | ||
| 464 | /* get memory resource */ | 499 | resources[0].start = dsps_control_module_phys[id]; |
| 465 | snprintf(res_name, sizeof(res_name), "musb%d", id); | 500 | resources[0].end = resources[0].start + SZ_4 - 1; |
| 466 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name); | 501 | resources[0].flags = IORESOURCE_MEM; |
| 502 | |||
| 503 | glue->usb_ctrl[id] = devm_request_and_ioremap(&pdev->dev, resources); | ||
| 504 | if (glue->usb_ctrl[id] == NULL) { | ||
| 505 | dev_err(dev, "Failed to obtain usb_ctrl%d memory\n", id); | ||
| 506 | ret = -ENODEV; | ||
| 507 | goto err0; | ||
| 508 | } | ||
| 509 | |||
| 510 | /* first resource is for usbss, so start index from 1 */ | ||
| 511 | res = platform_get_resource(pdev, IORESOURCE_MEM, id + 1); | ||
| 467 | if (!res) { | 512 | if (!res) { |
| 468 | dev_err(dev, "%s get mem resource failed\n", res_name); | 513 | dev_err(dev, "failed to get memory for instance %d\n", id); |
| 469 | ret = -ENODEV; | 514 | ret = -ENODEV; |
| 470 | goto err0; | 515 | goto err0; |
| 471 | } | 516 | } |
| 472 | res->parent = NULL; | 517 | res->parent = NULL; |
| 473 | resources[0] = *res; | 518 | resources[0] = *res; |
| 474 | 519 | ||
| 475 | /* get irq resource */ | 520 | /* first resource is for usbss, so start index from 1 */ |
| 476 | snprintf(res_name, sizeof(res_name), "musb%d-irq", id); | 521 | res = platform_get_resource(pdev, IORESOURCE_IRQ, id + 1); |
| 477 | res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res_name); | ||
| 478 | if (!res) { | 522 | if (!res) { |
| 479 | dev_err(dev, "%s get irq resource failed\n", res_name); | 523 | dev_err(dev, "failed to get irq for instance %d\n", id); |
| 480 | ret = -ENODEV; | 524 | ret = -ENODEV; |
| 481 | goto err0; | 525 | goto err0; |
| 482 | } | 526 | } |
| @@ -484,22 +528,14 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
| 484 | resources[1] = *res; | 528 | resources[1] = *res; |
| 485 | resources[1].name = "mc"; | 529 | resources[1].name = "mc"; |
| 486 | 530 | ||
| 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 */ | 531 | /* allocate the child platform device */ |
| 495 | musb = platform_device_alloc("musb-hdrc", musbid); | 532 | musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); |
| 496 | if (!musb) { | 533 | if (!musb) { |
| 497 | dev_err(dev, "failed to allocate musb device\n"); | 534 | dev_err(dev, "failed to allocate musb device\n"); |
| 498 | ret = -ENOMEM; | 535 | ret = -ENOMEM; |
| 499 | goto err1; | 536 | goto err0; |
| 500 | } | 537 | } |
| 501 | 538 | ||
| 502 | musb->id = musbid; | ||
| 503 | musb->dev.parent = dev; | 539 | musb->dev.parent = dev; |
| 504 | musb->dev.dma_mask = &musb_dmamask; | 540 | musb->dev.dma_mask = &musb_dmamask; |
| 505 | musb->dev.coherent_dma_mask = musb_dmamask; | 541 | musb->dev.coherent_dma_mask = musb_dmamask; |
| @@ -556,20 +592,11 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) | |||
| 556 | 592 | ||
| 557 | err2: | 593 | err2: |
| 558 | platform_device_put(musb); | 594 | platform_device_put(musb); |
| 559 | err1: | ||
| 560 | musb_put_id(dev, musbid); | ||
| 561 | err0: | 595 | err0: |
| 562 | return ret; | 596 | return ret; |
| 563 | } | 597 | } |
| 564 | 598 | ||
| 565 | static void dsps_delete_musb_pdev(struct dsps_glue *glue, u8 id) | 599 | static int dsps_probe(struct platform_device *pdev) |
| 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) | ||
| 573 | { | 600 | { |
| 574 | struct device_node *np = pdev->dev.of_node; | 601 | struct device_node *np = pdev->dev.of_node; |
| 575 | const struct of_device_id *match; | 602 | const struct of_device_id *match; |
| @@ -628,7 +655,7 @@ static int __devinit dsps_probe(struct platform_device *pdev) | |||
| 628 | dev_err(&pdev->dev, "failed to create child pdev\n"); | 655 | dev_err(&pdev->dev, "failed to create child pdev\n"); |
| 629 | /* release resources of previously created instances */ | 656 | /* release resources of previously created instances */ |
| 630 | for (i--; i >= 0 ; i--) | 657 | for (i--; i >= 0 ; i--) |
| 631 | dsps_delete_musb_pdev(glue, i); | 658 | platform_device_unregister(glue->musb[i]); |
| 632 | goto err3; | 659 | goto err3; |
| 633 | } | 660 | } |
| 634 | } | 661 | } |
| @@ -645,7 +672,7 @@ err1: | |||
| 645 | err0: | 672 | err0: |
| 646 | return ret; | 673 | return ret; |
| 647 | } | 674 | } |
| 648 | static int __devexit dsps_remove(struct platform_device *pdev) | 675 | static int dsps_remove(struct platform_device *pdev) |
| 649 | { | 676 | { |
| 650 | struct dsps_glue *glue = platform_get_drvdata(pdev); | 677 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
| 651 | const struct dsps_musb_wrapper *wrp = glue->wrp; | 678 | const struct dsps_musb_wrapper *wrp = glue->wrp; |
| @@ -653,7 +680,7 @@ static int __devexit dsps_remove(struct platform_device *pdev) | |||
| 653 | 680 | ||
| 654 | /* delete the child platform device */ | 681 | /* delete the child platform device */ |
| 655 | for (i = 0; i < wrp->instances ; i++) | 682 | for (i = 0; i < wrp->instances ; i++) |
| 656 | dsps_delete_musb_pdev(glue, i); | 683 | platform_device_unregister(glue->musb[i]); |
| 657 | 684 | ||
| 658 | /* disable usbss clocks */ | 685 | /* disable usbss clocks */ |
| 659 | pm_runtime_put(&pdev->dev); | 686 | pm_runtime_put(&pdev->dev); |
| @@ -666,24 +693,26 @@ static int __devexit dsps_remove(struct platform_device *pdev) | |||
| 666 | #ifdef CONFIG_PM_SLEEP | 693 | #ifdef CONFIG_PM_SLEEP |
| 667 | static int dsps_suspend(struct device *dev) | 694 | static int dsps_suspend(struct device *dev) |
| 668 | { | 695 | { |
| 669 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 696 | struct platform_device *pdev = to_platform_device(dev->parent); |
| 670 | struct omap_musb_board_data *data = plat->board_data; | 697 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
| 698 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
| 699 | int i; | ||
| 671 | 700 | ||
| 672 | /* Shutdown the on-chip PHY and its PLL. */ | 701 | for (i = 0; i < wrp->instances; i++) |
| 673 | if (data->set_phy_power) | 702 | musb_dsps_phy_control(glue, i, 0); |
| 674 | data->set_phy_power(0); | ||
| 675 | 703 | ||
| 676 | return 0; | 704 | return 0; |
| 677 | } | 705 | } |
| 678 | 706 | ||
| 679 | static int dsps_resume(struct device *dev) | 707 | static int dsps_resume(struct device *dev) |
| 680 | { | 708 | { |
| 681 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 709 | struct platform_device *pdev = to_platform_device(dev->parent); |
| 682 | struct omap_musb_board_data *data = plat->board_data; | 710 | struct dsps_glue *glue = platform_get_drvdata(pdev); |
| 711 | const struct dsps_musb_wrapper *wrp = glue->wrp; | ||
| 712 | int i; | ||
| 683 | 713 | ||
| 684 | /* Start the on-chip PHY and its PLL. */ | 714 | for (i = 0; i < wrp->instances; i++) |
| 685 | if (data->set_phy_power) | 715 | musb_dsps_phy_control(glue, i, 1); |
| 686 | data->set_phy_power(1); | ||
| 687 | 716 | ||
| 688 | return 0; | 717 | return 0; |
| 689 | } | 718 | } |
| @@ -691,7 +720,7 @@ static int dsps_resume(struct device *dev) | |||
| 691 | 720 | ||
| 692 | static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume); | 721 | static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume); |
| 693 | 722 | ||
| 694 | static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = { | 723 | static const struct dsps_musb_wrapper ti81xx_driver_data = { |
| 695 | .revision = 0x00, | 724 | .revision = 0x00, |
| 696 | .control = 0x14, | 725 | .control = 0x14, |
| 697 | .status = 0x18, | 726 | .status = 0x18, |
| @@ -719,10 +748,10 @@ static const struct dsps_musb_wrapper ti81xx_driver_data __devinitconst = { | |||
| 719 | .rxep_bitmap = (0xfffe << 16), | 748 | .rxep_bitmap = (0xfffe << 16), |
| 720 | .musb_core_offset = 0x400, | 749 | .musb_core_offset = 0x400, |
| 721 | .poll_seconds = 2, | 750 | .poll_seconds = 2, |
| 722 | .instances = 2, | 751 | .instances = 1, |
| 723 | }; | 752 | }; |
| 724 | 753 | ||
| 725 | static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { | 754 | static const struct platform_device_id musb_dsps_id_table[] = { |
| 726 | { | 755 | { |
| 727 | .name = "musb-ti81xx", | 756 | .name = "musb-ti81xx", |
| 728 | .driver_data = (kernel_ulong_t) &ti81xx_driver_data, | 757 | .driver_data = (kernel_ulong_t) &ti81xx_driver_data, |
| @@ -732,7 +761,7 @@ static const struct platform_device_id musb_dsps_id_table[] __devinitconst = { | |||
| 732 | MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); | 761 | MODULE_DEVICE_TABLE(platform, musb_dsps_id_table); |
| 733 | 762 | ||
| 734 | #ifdef CONFIG_OF | 763 | #ifdef CONFIG_OF |
| 735 | static const struct of_device_id musb_dsps_of_match[] __devinitconst = { | 764 | static const struct of_device_id musb_dsps_of_match[] = { |
| 736 | { .compatible = "ti,musb-am33xx", | 765 | { .compatible = "ti,musb-am33xx", |
| 737 | .data = (void *) &ti81xx_driver_data, }, | 766 | .data = (void *) &ti81xx_driver_data, }, |
| 738 | { }, | 767 | { }, |
| @@ -742,7 +771,7 @@ MODULE_DEVICE_TABLE(of, musb_dsps_of_match); | |||
| 742 | 771 | ||
| 743 | static struct platform_driver dsps_usbss_driver = { | 772 | static struct platform_driver dsps_usbss_driver = { |
| 744 | .probe = dsps_probe, | 773 | .probe = dsps_probe, |
| 745 | .remove = __devexit_p(dsps_remove), | 774 | .remove = dsps_remove, |
| 746 | .driver = { | 775 | .driver = { |
| 747 | .name = "musb-dsps", | 776 | .name = "musb-dsps", |
| 748 | .pm = &dsps_pm_ops, | 777 | .pm = &dsps_pm_ops, |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b6b84dacc791..876787438c2f 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 | ||
| @@ -1792,7 +1787,7 @@ static void musb_gadget_release(struct device *dev) | |||
| 1792 | } | 1787 | } |
| 1793 | 1788 | ||
| 1794 | 1789 | ||
| 1795 | static void __devinit | 1790 | static void |
| 1796 | init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) | 1791 | init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) |
| 1797 | { | 1792 | { |
| 1798 | struct musb_hw_ep *hw_ep = musb->endpoints + epnum; | 1793 | struct musb_hw_ep *hw_ep = musb->endpoints + epnum; |
| @@ -1829,7 +1824,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) | |||
| 1829 | * Initialize the endpoints exposed to peripheral drivers, with backlinks | 1824 | * Initialize the endpoints exposed to peripheral drivers, with backlinks |
| 1830 | * to the rest of the driver state. | 1825 | * to the rest of the driver state. |
| 1831 | */ | 1826 | */ |
| 1832 | static inline void __devinit musb_g_init_endpoints(struct musb *musb) | 1827 | static inline void musb_g_init_endpoints(struct musb *musb) |
| 1833 | { | 1828 | { |
| 1834 | u8 epnum; | 1829 | u8 epnum; |
| 1835 | struct musb_hw_ep *hw_ep; | 1830 | struct musb_hw_ep *hw_ep; |
| @@ -1862,7 +1857,7 @@ static inline void __devinit musb_g_init_endpoints(struct musb *musb) | |||
| 1862 | /* called once during driver setup to initialize and link into | 1857 | /* called once during driver setup to initialize and link into |
| 1863 | * the driver model; memory is zeroed. | 1858 | * the driver model; memory is zeroed. |
| 1864 | */ | 1859 | */ |
| 1865 | int __devinit musb_gadget_setup(struct musb *musb) | 1860 | int musb_gadget_setup(struct musb *musb) |
| 1866 | { | 1861 | { |
| 1867 | int status; | 1862 | int status; |
| 1868 | 1863 | ||
| @@ -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/musb_io.h b/drivers/usb/musb/musb_io.h index 565ad1617832..eebeed78edd6 100644 --- a/drivers/usb/musb/musb_io.h +++ b/drivers/usb/musb/musb_io.h | |||
| @@ -37,27 +37,6 @@ | |||
| 37 | 37 | ||
| 38 | #include <linux/io.h> | 38 | #include <linux/io.h> |
| 39 | 39 | ||
| 40 | #if !defined(CONFIG_ARM) && !defined(CONFIG_SUPERH) \ | ||
| 41 | && !defined(CONFIG_AVR32) && !defined(CONFIG_PPC32) \ | ||
| 42 | && !defined(CONFIG_PPC64) && !defined(CONFIG_BLACKFIN) \ | ||
| 43 | && !defined(CONFIG_MIPS) && !defined(CONFIG_M68K) \ | ||
| 44 | && !defined(CONFIG_XTENSA) | ||
| 45 | static inline void readsl(const void __iomem *addr, void *buf, int len) | ||
| 46 | { insl((unsigned long)addr, buf, len); } | ||
| 47 | static inline void readsw(const void __iomem *addr, void *buf, int len) | ||
| 48 | { insw((unsigned long)addr, buf, len); } | ||
| 49 | static inline void readsb(const void __iomem *addr, void *buf, int len) | ||
| 50 | { insb((unsigned long)addr, buf, len); } | ||
| 51 | |||
| 52 | static inline void writesl(const void __iomem *addr, const void *buf, int len) | ||
| 53 | { outsl((unsigned long)addr, buf, len); } | ||
| 54 | static inline void writesw(const void __iomem *addr, const void *buf, int len) | ||
| 55 | { outsw((unsigned long)addr, buf, len); } | ||
| 56 | static inline void writesb(const void __iomem *addr, const void *buf, int len) | ||
| 57 | { outsb((unsigned long)addr, buf, len); } | ||
| 58 | |||
| 59 | #endif | ||
| 60 | |||
| 61 | #ifndef CONFIG_BLACKFIN | 40 | #ifndef CONFIG_BLACKFIN |
| 62 | 41 | ||
| 63 | /* NOTE: these offsets are all in bytes */ | 42 | /* NOTE: these offsets are all in bytes */ |
diff --git a/drivers/usb/musb/musbhsdma.c b/drivers/usb/musb/musbhsdma.c index 0fc6ca6bc60a..3d1fd52a15a9 100644 --- a/drivers/usb/musb/musbhsdma.c +++ b/drivers/usb/musb/musbhsdma.c | |||
| @@ -380,8 +380,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
| 380 | kfree(controller); | 380 | kfree(controller); |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 383 | struct dma_controller *__devinit | 383 | struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base) |
| 384 | dma_controller_create(struct musb *musb, void __iomem *base) | ||
| 385 | { | 384 | { |
| 386 | struct musb_dma_controller *controller; | 385 | struct musb_dma_controller *controller; |
| 387 | struct device *dev = musb->controller; | 386 | struct device *dev = musb->controller; |
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..da00af460794 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); |
| @@ -468,7 +490,7 @@ static const struct musb_platform_ops omap2430_ops = { | |||
| 468 | 490 | ||
| 469 | static u64 omap2430_dmamask = DMA_BIT_MASK(32); | 491 | static u64 omap2430_dmamask = DMA_BIT_MASK(32); |
| 470 | 492 | ||
| 471 | static int __devinit omap2430_probe(struct platform_device *pdev) | 493 | static int omap2430_probe(struct platform_device *pdev) |
| 472 | { | 494 | { |
| 473 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 495 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 474 | struct omap_musb_board_data *data; | 496 | struct omap_musb_board_data *data; |
| @@ -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,19 +601,15 @@ 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 | } |
| 598 | 607 | ||
| 599 | static int __devexit omap2430_remove(struct platform_device *pdev) | 608 | static int omap2430_remove(struct platform_device *pdev) |
| 600 | { | 609 | { |
| 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; |
| @@ -666,7 +674,7 @@ MODULE_DEVICE_TABLE(of, omap2430_id_table); | |||
| 666 | 674 | ||
| 667 | static struct platform_driver omap2430_driver = { | 675 | static struct platform_driver omap2430_driver = { |
| 668 | .probe = omap2430_probe, | 676 | .probe = omap2430_probe, |
| 669 | .remove = __devexit_p(omap2430_remove), | 677 | .remove = omap2430_remove, |
| 670 | .driver = { | 678 | .driver = { |
| 671 | .name = "musb-omap2430", | 679 | .name = "musb-omap2430", |
| 672 | .pm = DEV_PM_OPS, | 680 | .pm = DEV_PM_OPS, |
diff --git a/drivers/usb/musb/omap2430.h b/drivers/usb/musb/omap2430.h index b85f3973e78c..8ef656659fcb 100644 --- a/drivers/usb/musb/omap2430.h +++ b/drivers/usb/musb/omap2430.h | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | #ifndef __MUSB_OMAP243X_H__ | 10 | #ifndef __MUSB_OMAP243X_H__ |
| 11 | #define __MUSB_OMAP243X_H__ | 11 | #define __MUSB_OMAP243X_H__ |
| 12 | 12 | ||
| 13 | #include <plat/usb.h> | 13 | #include <linux/platform_data/usb-omap.h> |
| 14 | 14 | ||
| 15 | /* | 15 | /* |
| 16 | * OMAP2430-specific definitions | 16 | * OMAP2430-specific definitions |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index dc4d75ea13ad..3969813c217d 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/prefetch.h> | 22 | #include <linux/prefetch.h> |
| 23 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
| 24 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
| 25 | #include <linux/io.h> | ||
| 25 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
| 26 | #include <linux/dma-mapping.h> | 27 | #include <linux/dma-mapping.h> |
| 27 | #include <linux/usb/nop-usb-xceiv.h> | 28 | #include <linux/usb/nop-usb-xceiv.h> |
| @@ -198,7 +199,7 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *buf) | |||
| 198 | /* Best case is 32bit-aligned destination address */ | 199 | /* Best case is 32bit-aligned destination address */ |
| 199 | if ((0x02 & (unsigned long) buf) == 0) { | 200 | if ((0x02 & (unsigned long) buf) == 0) { |
| 200 | if (len >= 4) { | 201 | if (len >= 4) { |
| 201 | writesl(fifo, buf, len >> 2); | 202 | iowrite32_rep(fifo, buf, len >> 2); |
| 202 | buf += (len & ~0x03); | 203 | buf += (len & ~0x03); |
| 203 | len &= 0x03; | 204 | len &= 0x03; |
| 204 | } | 205 | } |
| @@ -245,7 +246,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf) | |||
| 245 | /* Best case is 32bit-aligned destination address */ | 246 | /* Best case is 32bit-aligned destination address */ |
| 246 | if ((0x02 & (unsigned long) buf) == 0) { | 247 | if ((0x02 & (unsigned long) buf) == 0) { |
| 247 | if (len >= 4) { | 248 | if (len >= 4) { |
| 248 | readsl(fifo, buf, len >> 2); | 249 | ioread32_rep(fifo, buf, len >> 2); |
| 249 | buf += (len & ~0x03); | 250 | buf += (len & ~0x03); |
| 250 | len &= 0x03; | 251 | len &= 0x03; |
| 251 | } | 252 | } |
| @@ -1153,14 +1154,13 @@ static const struct musb_platform_ops tusb_ops = { | |||
| 1153 | 1154 | ||
| 1154 | static u64 tusb_dmamask = DMA_BIT_MASK(32); | 1155 | static u64 tusb_dmamask = DMA_BIT_MASK(32); |
| 1155 | 1156 | ||
| 1156 | static int __devinit tusb_probe(struct platform_device *pdev) | 1157 | static int tusb_probe(struct platform_device *pdev) |
| 1157 | { | 1158 | { |
| 1158 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 1159 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 1159 | struct platform_device *musb; | 1160 | struct platform_device *musb; |
| 1160 | struct tusb6010_glue *glue; | 1161 | struct tusb6010_glue *glue; |
| 1161 | 1162 | ||
| 1162 | int ret = -ENOMEM; | 1163 | int ret = -ENOMEM; |
| 1163 | int musbid; | ||
| 1164 | 1164 | ||
| 1165 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 1165 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
| 1166 | if (!glue) { | 1166 | if (!glue) { |
| @@ -1168,21 +1168,12 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
| 1168 | goto err0; | 1168 | goto err0; |
| 1169 | } | 1169 | } |
| 1170 | 1170 | ||
| 1171 | /* get the musb id */ | 1171 | 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) { | 1172 | if (!musb) { |
| 1181 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 1173 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
| 1182 | goto err2; | 1174 | goto err1; |
| 1183 | } | 1175 | } |
| 1184 | 1176 | ||
| 1185 | musb->id = musbid; | ||
| 1186 | musb->dev.parent = &pdev->dev; | 1177 | musb->dev.parent = &pdev->dev; |
| 1187 | musb->dev.dma_mask = &tusb_dmamask; | 1178 | musb->dev.dma_mask = &tusb_dmamask; |
| 1188 | musb->dev.coherent_dma_mask = tusb_dmamask; | 1179 | musb->dev.coherent_dma_mask = tusb_dmamask; |
| @@ -1218,9 +1209,6 @@ static int __devinit tusb_probe(struct platform_device *pdev) | |||
| 1218 | err3: | 1209 | err3: |
| 1219 | platform_device_put(musb); | 1210 | platform_device_put(musb); |
| 1220 | 1211 | ||
| 1221 | err2: | ||
| 1222 | musb_put_id(&pdev->dev, musbid); | ||
| 1223 | |||
| 1224 | err1: | 1212 | err1: |
| 1225 | kfree(glue); | 1213 | kfree(glue); |
| 1226 | 1214 | ||
| @@ -1228,13 +1216,11 @@ err0: | |||
| 1228 | return ret; | 1216 | return ret; |
| 1229 | } | 1217 | } |
| 1230 | 1218 | ||
| 1231 | static int __devexit tusb_remove(struct platform_device *pdev) | 1219 | static int tusb_remove(struct platform_device *pdev) |
| 1232 | { | 1220 | { |
| 1233 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); | 1221 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); |
| 1234 | 1222 | ||
| 1235 | musb_put_id(&pdev->dev, glue->musb->id); | 1223 | platform_device_unregister(glue->musb); |
| 1236 | platform_device_del(glue->musb); | ||
| 1237 | platform_device_put(glue->musb); | ||
| 1238 | kfree(glue); | 1224 | kfree(glue); |
| 1239 | 1225 | ||
| 1240 | return 0; | 1226 | return 0; |
| @@ -1242,7 +1228,7 @@ static int __devexit tusb_remove(struct platform_device *pdev) | |||
| 1242 | 1228 | ||
| 1243 | static struct platform_driver tusb_driver = { | 1229 | static struct platform_driver tusb_driver = { |
| 1244 | .probe = tusb_probe, | 1230 | .probe = tusb_probe, |
| 1245 | .remove = __devexit_p(tusb_remove), | 1231 | .remove = tusb_remove, |
| 1246 | .driver = { | 1232 | .driver = { |
| 1247 | .name = "musb-tusb", | 1233 | .name = "musb-tusb", |
| 1248 | }, | 1234 | }, |
| @@ -1251,15 +1237,4 @@ static struct platform_driver tusb_driver = { | |||
| 1251 | MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); | 1237 | MODULE_DESCRIPTION("TUSB6010 MUSB Glue Layer"); |
| 1252 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 1238 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
| 1253 | MODULE_LICENSE("GPL v2"); | 1239 | MODULE_LICENSE("GPL v2"); |
| 1254 | 1240 | 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/tusb6010_omap.c b/drivers/usb/musb/tusb6010_omap.c index 7a62b95dac24..98df17c984a8 100644 --- a/drivers/usb/musb/tusb6010_omap.c +++ b/drivers/usb/musb/tusb6010_omap.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <plat/dma.h> | 19 | #include <linux/omap-dma.h> |
| 20 | 20 | ||
| 21 | #include "musb_core.h" | 21 | #include "musb_core.h" |
| 22 | #include "tusb6010.h" | 22 | #include "tusb6010.h" |
| @@ -25,6 +25,13 @@ | |||
| 25 | 25 | ||
| 26 | #define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */ | 26 | #define MAX_DMAREQ 5 /* REVISIT: Really 6, but req5 not OK */ |
| 27 | 27 | ||
| 28 | #define OMAP24XX_DMA_EXT_DMAREQ0 2 | ||
| 29 | #define OMAP24XX_DMA_EXT_DMAREQ1 3 | ||
| 30 | #define OMAP242X_DMA_EXT_DMAREQ2 14 | ||
| 31 | #define OMAP242X_DMA_EXT_DMAREQ3 15 | ||
| 32 | #define OMAP242X_DMA_EXT_DMAREQ4 16 | ||
| 33 | #define OMAP242X_DMA_EXT_DMAREQ5 64 | ||
| 34 | |||
| 28 | struct tusb_omap_dma_ch { | 35 | struct tusb_omap_dma_ch { |
| 29 | struct musb *musb; | 36 | struct musb *musb; |
| 30 | void __iomem *tbase; | 37 | void __iomem *tbase; |
| @@ -661,8 +668,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
| 661 | kfree(tusb_dma); | 668 | kfree(tusb_dma); |
| 662 | } | 669 | } |
| 663 | 670 | ||
| 664 | struct dma_controller *__devinit | 671 | struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base) |
| 665 | dma_controller_create(struct musb *musb, void __iomem *base) | ||
| 666 | { | 672 | { |
| 667 | void __iomem *tbase = musb->ctrl_base; | 673 | void __iomem *tbase = musb->ctrl_base; |
| 668 | struct tusb_omap_dma *tusb_dma; | 674 | struct tusb_omap_dma *tusb_dma; |
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index 0e62f504410e..a27ca1a9c994 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 | ||
| @@ -59,13 +81,12 @@ static const struct musb_platform_ops ux500_ops = { | |||
| 59 | .exit = ux500_musb_exit, | 81 | .exit = ux500_musb_exit, |
| 60 | }; | 82 | }; |
| 61 | 83 | ||
| 62 | static int __devinit ux500_probe(struct platform_device *pdev) | 84 | static int ux500_probe(struct platform_device *pdev) |
| 63 | { | 85 | { |
| 64 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 86 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
| 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 | ||
| @@ -154,13 +163,11 @@ err0: | |||
| 154 | return ret; | 163 | return ret; |
| 155 | } | 164 | } |
| 156 | 165 | ||
| 157 | static int __devexit ux500_remove(struct platform_device *pdev) | 166 | static int 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); |
| @@ -209,7 +216,7 @@ static const struct dev_pm_ops ux500_pm_ops = { | |||
| 209 | 216 | ||
| 210 | static struct platform_driver ux500_driver = { | 217 | static struct platform_driver ux500_driver = { |
| 211 | .probe = ux500_probe, | 218 | .probe = ux500_probe, |
| 212 | .remove = __devexit_p(ux500_remove), | 219 | .remove = ux500_remove, |
| 213 | .driver = { | 220 | .driver = { |
| 214 | .name = "musb-ux500", | 221 | .name = "musb-ux500", |
| 215 | .pm = DEV_PM_OPS, | 222 | .pm = DEV_PM_OPS, |
| @@ -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/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index f1059e725ea8..039e567dd3b6 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c | |||
| @@ -364,8 +364,7 @@ void dma_controller_destroy(struct dma_controller *c) | |||
| 364 | kfree(controller); | 364 | kfree(controller); |
| 365 | } | 365 | } |
| 366 | 366 | ||
| 367 | struct dma_controller *__devinit | 367 | struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *base) |
| 368 | dma_controller_create(struct musb *musb, void __iomem *base) | ||
| 369 | { | 368 | { |
| 370 | struct ux500_dma_controller *controller; | 369 | struct ux500_dma_controller *controller; |
| 371 | struct platform_device *pdev = to_platform_device(musb->controller); | 370 | struct platform_device *pdev = to_platform_device(musb->controller); |
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 6223062d5d1b..37962c99ff1e 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
| @@ -110,7 +110,7 @@ config AB8500_USB | |||
| 110 | 110 | ||
| 111 | config FSL_USB2_OTG | 111 | config FSL_USB2_OTG |
| 112 | bool "Freescale USB OTG Transceiver Driver" | 112 | bool "Freescale USB OTG Transceiver Driver" |
| 113 | depends on USB_EHCI_FSL && USB_GADGET_FSL_USB2 && USB_SUSPEND | 113 | depends on USB_EHCI_FSL && USB_FSL_USB2 && USB_SUSPEND |
| 114 | select USB_OTG | 114 | select USB_OTG |
| 115 | select USB_OTG_UTILS | 115 | select USB_OTG_UTILS |
| 116 | help | 116 | help |
diff --git a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c index ae8ad561f083..2d86f26a0183 100644 --- a/drivers/usb/otg/ab8500-usb.c +++ b/drivers/usb/otg/ab8500-usb.c | |||
| @@ -468,7 +468,7 @@ static int ab8500_usb_v2_res_setup(struct platform_device *pdev, | |||
| 468 | return 0; | 468 | return 0; |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | static int __devinit ab8500_usb_probe(struct platform_device *pdev) | 471 | static int ab8500_usb_probe(struct platform_device *pdev) |
| 472 | { | 472 | { |
| 473 | struct ab8500_usb *ab; | 473 | struct ab8500_usb *ab; |
| 474 | struct usb_otg *otg; | 474 | struct usb_otg *otg; |
| @@ -546,7 +546,7 @@ fail0: | |||
| 546 | return err; | 546 | return err; |
| 547 | } | 547 | } |
| 548 | 548 | ||
| 549 | static int __devexit ab8500_usb_remove(struct platform_device *pdev) | 549 | static int ab8500_usb_remove(struct platform_device *pdev) |
| 550 | { | 550 | { |
| 551 | struct ab8500_usb *ab = platform_get_drvdata(pdev); | 551 | struct ab8500_usb *ab = platform_get_drvdata(pdev); |
| 552 | 552 | ||
| @@ -571,7 +571,7 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev) | |||
| 571 | 571 | ||
| 572 | static struct platform_driver ab8500_usb_driver = { | 572 | static struct platform_driver ab8500_usb_driver = { |
| 573 | .probe = ab8500_usb_probe, | 573 | .probe = ab8500_usb_probe, |
| 574 | .remove = __devexit_p(ab8500_usb_remove), | 574 | .remove = ab8500_usb_remove, |
| 575 | .driver = { | 575 | .driver = { |
| 576 | .name = "ab8500-usb", | 576 | .name = "ab8500-usb", |
| 577 | .owner = THIS_MODULE, | 577 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c index c19d1d7173a9..d16adb41eb21 100644 --- a/drivers/usb/otg/fsl_otg.c +++ b/drivers/usb/otg/fsl_otg.c | |||
| @@ -1110,7 +1110,7 @@ static const struct file_operations otg_fops = { | |||
| 1110 | .release = fsl_otg_release, | 1110 | .release = fsl_otg_release, |
| 1111 | }; | 1111 | }; |
| 1112 | 1112 | ||
| 1113 | static int __devinit fsl_otg_probe(struct platform_device *pdev) | 1113 | static int fsl_otg_probe(struct platform_device *pdev) |
| 1114 | { | 1114 | { |
| 1115 | int ret; | 1115 | int ret; |
| 1116 | 1116 | ||
| @@ -1144,7 +1144,7 @@ static int __devinit fsl_otg_probe(struct platform_device *pdev) | |||
| 1144 | return ret; | 1144 | return ret; |
| 1145 | } | 1145 | } |
| 1146 | 1146 | ||
| 1147 | static int __devexit fsl_otg_remove(struct platform_device *pdev) | 1147 | static int fsl_otg_remove(struct platform_device *pdev) |
| 1148 | { | 1148 | { |
| 1149 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 1149 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; |
| 1150 | 1150 | ||
| @@ -1169,7 +1169,7 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev) | |||
| 1169 | 1169 | ||
| 1170 | struct platform_driver fsl_otg_driver = { | 1170 | struct platform_driver fsl_otg_driver = { |
| 1171 | .probe = fsl_otg_probe, | 1171 | .probe = fsl_otg_probe, |
| 1172 | .remove = __devexit_p(fsl_otg_remove), | 1172 | .remove = fsl_otg_remove, |
| 1173 | .driver = { | 1173 | .driver = { |
| 1174 | .name = driver_name, | 1174 | .name = driver_name, |
| 1175 | .owner = THIS_MODULE, | 1175 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c index ceee2119bffa..af9cb11626b2 100644 --- a/drivers/usb/otg/isp1301_omap.c +++ b/drivers/usb/otg/isp1301_omap.c | |||
| @@ -1493,7 +1493,7 @@ isp1301_start_hnp(struct usb_otg *otg) | |||
| 1493 | 1493 | ||
| 1494 | /*-------------------------------------------------------------------------*/ | 1494 | /*-------------------------------------------------------------------------*/ |
| 1495 | 1495 | ||
| 1496 | static int __devinit | 1496 | static int |
| 1497 | isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | 1497 | isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) |
| 1498 | { | 1498 | { |
| 1499 | int status; | 1499 | int status; |
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c index 9f5fc906041a..3b9f0d951132 100644 --- a/drivers/usb/otg/msm_otg.c +++ b/drivers/usb/otg/msm_otg.c | |||
| @@ -1606,7 +1606,7 @@ free_motg: | |||
| 1606 | return ret; | 1606 | return ret; |
| 1607 | } | 1607 | } |
| 1608 | 1608 | ||
| 1609 | static int __devexit msm_otg_remove(struct platform_device *pdev) | 1609 | static int msm_otg_remove(struct platform_device *pdev) |
| 1610 | { | 1610 | { |
| 1611 | struct msm_otg *motg = platform_get_drvdata(pdev); | 1611 | struct msm_otg *motg = platform_get_drvdata(pdev); |
| 1612 | struct usb_phy *phy = &motg->phy; | 1612 | struct usb_phy *phy = &motg->phy; |
| @@ -1746,7 +1746,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = { | |||
| 1746 | #endif | 1746 | #endif |
| 1747 | 1747 | ||
| 1748 | static struct platform_driver msm_otg_driver = { | 1748 | static struct platform_driver msm_otg_driver = { |
| 1749 | .remove = __devexit_p(msm_otg_remove), | 1749 | .remove = msm_otg_remove, |
| 1750 | .driver = { | 1750 | .driver = { |
| 1751 | .name = DRIVER_NAME, | 1751 | .name = DRIVER_NAME, |
| 1752 | .owner = THIS_MODULE, | 1752 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c index 3f124e8f5792..eace975991a8 100644 --- a/drivers/usb/otg/mv_otg.c +++ b/drivers/usb/otg/mv_otg.c | |||
| @@ -240,7 +240,7 @@ static void otg_clock_enable(struct mv_otg *mvotg) | |||
| 240 | unsigned int i; | 240 | unsigned int i; |
| 241 | 241 | ||
| 242 | for (i = 0; i < mvotg->clknum; i++) | 242 | for (i = 0; i < mvotg->clknum; i++) |
| 243 | clk_enable(mvotg->clk[i]); | 243 | clk_prepare_enable(mvotg->clk[i]); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | static void otg_clock_disable(struct mv_otg *mvotg) | 246 | static void otg_clock_disable(struct mv_otg *mvotg) |
| @@ -248,7 +248,7 @@ static void otg_clock_disable(struct mv_otg *mvotg) | |||
| 248 | unsigned int i; | 248 | unsigned int i; |
| 249 | 249 | ||
| 250 | for (i = 0; i < mvotg->clknum; i++) | 250 | for (i = 0; i < mvotg->clknum; i++) |
| 251 | clk_disable(mvotg->clk[i]); | 251 | clk_disable_unprepare(mvotg->clk[i]); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | static int mv_otg_enable_internal(struct mv_otg *mvotg) | 254 | static int mv_otg_enable_internal(struct mv_otg *mvotg) |
| @@ -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..76302720055a 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 | } |
| @@ -176,7 +149,7 @@ static int mxs_phy_probe(struct platform_device *pdev) | |||
| 176 | return 0; | 149 | return 0; |
| 177 | } | 150 | } |
| 178 | 151 | ||
| 179 | static int __devexit mxs_phy_remove(struct platform_device *pdev) | 152 | static int mxs_phy_remove(struct platform_device *pdev) |
| 180 | { | 153 | { |
| 181 | platform_set_drvdata(pdev, NULL); | 154 | platform_set_drvdata(pdev, NULL); |
| 182 | 155 | ||
| @@ -191,7 +164,7 @@ MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids); | |||
| 191 | 164 | ||
| 192 | static struct platform_driver mxs_phy_driver = { | 165 | static struct platform_driver mxs_phy_driver = { |
| 193 | .probe = mxs_phy_probe, | 166 | .probe = mxs_phy_probe, |
| 194 | .remove = __devexit_p(mxs_phy_remove), | 167 | .remove = mxs_phy_remove, |
| 195 | .driver = { | 168 | .driver = { |
| 196 | .name = DRIVER_NAME, | 169 | .name = DRIVER_NAME, |
| 197 | .owner = THIS_MODULE, | 170 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c index e52e35e7adaf..a3ce24b94a73 100644 --- a/drivers/usb/otg/nop-usb-xceiv.c +++ b/drivers/usb/otg/nop-usb-xceiv.c | |||
| @@ -93,7 +93,7 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
| 93 | return 0; | 93 | return 0; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | 96 | static int nop_usb_xceiv_probe(struct platform_device *pdev) |
| 97 | { | 97 | { |
| 98 | struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data; | 98 | struct nop_usb_xceiv_platform_data *pdata = pdev->dev.platform_data; |
| 99 | struct nop_usb_xceiv *nop; | 99 | struct nop_usb_xceiv *nop; |
| @@ -141,7 +141,7 @@ exit: | |||
| 141 | return err; | 141 | return err; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) | 144 | static int nop_usb_xceiv_remove(struct platform_device *pdev) |
| 145 | { | 145 | { |
| 146 | struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); | 146 | struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); |
| 147 | 147 | ||
| @@ -156,7 +156,7 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) | |||
| 156 | 156 | ||
| 157 | static struct platform_driver nop_usb_xceiv_driver = { | 157 | static struct platform_driver nop_usb_xceiv_driver = { |
| 158 | .probe = nop_usb_xceiv_probe, | 158 | .probe = nop_usb_xceiv_probe, |
| 159 | .remove = __devexit_p(nop_usb_xceiv_remove), | 159 | .remove = nop_usb_xceiv_remove, |
| 160 | .driver = { | 160 | .driver = { |
| 161 | .name = "nop_usb_xceiv", | 161 | .name = "nop_usb_xceiv", |
| 162 | .owner = THIS_MODULE, | 162 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index f0d2e7530cfe..0a701938ab53 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 | ||
| @@ -579,7 +575,7 @@ static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) | |||
| 579 | return 0; | 575 | return 0; |
| 580 | } | 576 | } |
| 581 | 577 | ||
| 582 | static int __devinit twl4030_usb_probe(struct platform_device *pdev) | 578 | static int twl4030_usb_probe(struct platform_device *pdev) |
| 583 | { | 579 | { |
| 584 | struct twl4030_usb_data *pdata = pdev->dev.platform_data; | 580 | struct twl4030_usb_data *pdata = pdev->dev.platform_data; |
| 585 | struct twl4030_usb *twl; | 581 | struct twl4030_usb *twl; |
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c index fcadef7864f1..8cd6cf49bdbd 100644 --- a/drivers/usb/otg/twl6030-usb.c +++ b/drivers/usb/otg/twl6030-usb.c | |||
| @@ -310,7 +310,7 @@ static int twl6030_set_vbus(struct phy_companion *comparator, bool enabled) | |||
| 310 | return 0; | 310 | return 0; |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | static int __devinit twl6030_usb_probe(struct platform_device *pdev) | 313 | static int twl6030_usb_probe(struct platform_device *pdev) |
| 314 | { | 314 | { |
| 315 | u32 ret; | 315 | u32 ret; |
| 316 | struct twl6030_usb *twl; | 316 | struct twl6030_usb *twl; |
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig index 63c339b3e676..5de6e7f39f9c 100644 --- a/drivers/usb/phy/Kconfig +++ b/drivers/usb/phy/Kconfig | |||
| @@ -6,6 +6,7 @@ comment "USB Physical Layer drivers" | |||
| 6 | 6 | ||
| 7 | config OMAP_USB2 | 7 | config OMAP_USB2 |
| 8 | tristate "OMAP USB2 PHY Driver" | 8 | tristate "OMAP USB2 PHY Driver" |
| 9 | depends on ARCH_OMAP2PLUS | ||
| 9 | select USB_OTG_UTILS | 10 | select USB_OTG_UTILS |
| 10 | help | 11 | help |
| 11 | Enable this to support the transceiver that is part of SOC. This | 12 | Enable this to support the transceiver that is part of SOC. This |
| @@ -32,3 +33,15 @@ config MV_U3D_PHY | |||
| 32 | help | 33 | help |
| 33 | Enable this to support Marvell USB 3.0 phy controller for Marvell | 34 | Enable this to support Marvell USB 3.0 phy controller for Marvell |
| 34 | SoC. | 35 | SoC. |
| 36 | |||
| 37 | config USB_RCAR_PHY | ||
| 38 | tristate "Renesas R-Car USB phy support" | ||
| 39 | depends on USB || USB_GADGET | ||
| 40 | select USB_OTG_UTILS | ||
| 41 | help | ||
| 42 | Say Y here to add support for the Renesas R-Car USB phy driver. | ||
| 43 | This chip is typically used as USB phy for USB host, gadget. | ||
| 44 | This driver supports: R8A7779 | ||
| 45 | |||
| 46 | To compile this driver as a module, choose M here: the | ||
| 47 | 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/mv_u3d_phy.c b/drivers/usb/phy/mv_u3d_phy.c index 9f1c5d3c60ec..eaddbe3d4304 100644 --- a/drivers/usb/phy/mv_u3d_phy.c +++ b/drivers/usb/phy/mv_u3d_phy.c | |||
| @@ -262,7 +262,7 @@ calstart: | |||
| 262 | return 0; | 262 | return 0; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | static int __devinit mv_u3d_phy_probe(struct platform_device *pdev) | 265 | static int mv_u3d_phy_probe(struct platform_device *pdev) |
| 266 | { | 266 | { |
| 267 | struct mv_u3d_phy *mv_u3d_phy; | 267 | struct mv_u3d_phy *mv_u3d_phy; |
| 268 | struct mv_usb_platform_data *pdata; | 268 | struct mv_usb_platform_data *pdata; |
| @@ -331,7 +331,7 @@ static int __exit mv_u3d_phy_remove(struct platform_device *pdev) | |||
| 331 | 331 | ||
| 332 | static struct platform_driver mv_u3d_phy_driver = { | 332 | static struct platform_driver mv_u3d_phy_driver = { |
| 333 | .probe = mv_u3d_phy_probe, | 333 | .probe = mv_u3d_phy_probe, |
| 334 | .remove = __devexit_p(mv_u3d_phy_remove), | 334 | .remove = mv_u3d_phy_remove, |
| 335 | .driver = { | 335 | .driver = { |
| 336 | .name = "mv-u3d-phy", | 336 | .name = "mv-u3d-phy", |
| 337 | .owner = THIS_MODULE, | 337 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/phy/omap-usb2.c b/drivers/usb/phy/omap-usb2.c index 15ab3d6f2e8c..26ae8f49225c 100644 --- a/drivers/usb/phy/omap-usb2.c +++ b/drivers/usb/phy/omap-usb2.c | |||
| @@ -141,7 +141,7 @@ static int omap_usb2_suspend(struct usb_phy *x, int suspend) | |||
| 141 | return 0; | 141 | return 0; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | static int __devinit omap_usb2_probe(struct platform_device *pdev) | 144 | static int omap_usb2_probe(struct platform_device *pdev) |
| 145 | { | 145 | { |
| 146 | struct omap_usb *phy; | 146 | struct omap_usb *phy; |
| 147 | struct usb_otg *otg; | 147 | struct usb_otg *otg; |
| @@ -199,7 +199,7 @@ static int __devinit omap_usb2_probe(struct platform_device *pdev) | |||
| 199 | return 0; | 199 | return 0; |
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | static int __devexit omap_usb2_remove(struct platform_device *pdev) | 202 | static int omap_usb2_remove(struct platform_device *pdev) |
| 203 | { | 203 | { |
| 204 | struct omap_usb *phy = platform_get_drvdata(pdev); | 204 | struct omap_usb *phy = platform_get_drvdata(pdev); |
| 205 | 205 | ||
| @@ -254,7 +254,7 @@ MODULE_DEVICE_TABLE(of, omap_usb2_id_table); | |||
| 254 | 254 | ||
| 255 | static struct platform_driver omap_usb2_driver = { | 255 | static struct platform_driver omap_usb2_driver = { |
| 256 | .probe = omap_usb2_probe, | 256 | .probe = omap_usb2_probe, |
| 257 | .remove = __devexit_p(omap_usb2_remove), | 257 | .remove = omap_usb2_remove, |
| 258 | .driver = { | 258 | .driver = { |
| 259 | .name = "omap-usb2", | 259 | .name = "omap-usb2", |
| 260 | .owner = THIS_MODULE, | 260 | .owner = THIS_MODULE, |
diff --git a/drivers/usb/phy/rcar-phy.c b/drivers/usb/phy/rcar-phy.c new file mode 100644 index 000000000000..a35681b0c501 --- /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 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 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 = 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..38bce046f4d0 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); |
| @@ -551,7 +556,7 @@ probe_end_pipe_exit: | |||
| 551 | return ret; | 556 | return ret; |
| 552 | } | 557 | } |
| 553 | 558 | ||
| 554 | static int __devexit usbhs_remove(struct platform_device *pdev) | 559 | static int usbhs_remove(struct platform_device *pdev) |
| 555 | { | 560 | { |
| 556 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); | 561 | struct usbhs_priv *priv = usbhs_pdev_to_priv(pdev); |
| 557 | struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; | 562 | struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; |
| @@ -631,7 +636,7 @@ static struct platform_driver renesas_usbhs_driver = { | |||
| 631 | .pm = &usbhsc_pm_ops, | 636 | .pm = &usbhsc_pm_ops, |
| 632 | }, | 637 | }, |
| 633 | .probe = usbhs_probe, | 638 | .probe = usbhs_probe, |
| 634 | .remove = __devexit_p(usbhs_remove), | 639 | .remove = usbhs_remove, |
| 635 | }; | 640 | }; |
| 636 | 641 | ||
| 637 | module_platform_driver(renesas_usbhs_driver); | 642 | module_platform_driver(renesas_usbhs_driver); |
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..f2985cd88021 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
| @@ -545,15 +545,6 @@ static int usbhsg_pipe_disable(struct usbhsg_uep *uep) | |||
| 545 | return 0; | 545 | return 0; |
| 546 | } | 546 | } |
| 547 | 547 | ||
| 548 | static void usbhsg_uep_init(struct usbhsg_gpriv *gpriv) | ||
| 549 | { | ||
| 550 | int i; | ||
| 551 | struct usbhsg_uep *uep; | ||
| 552 | |||
| 553 | usbhsg_for_each_uep_with_dcp(uep, gpriv, i) | ||
| 554 | uep->pipe = NULL; | ||
| 555 | } | ||
| 556 | |||
| 557 | /* | 548 | /* |
| 558 | * | 549 | * |
| 559 | * usb_ep_ops | 550 | * usb_ep_ops |
| @@ -610,7 +601,12 @@ static int usbhsg_ep_disable(struct usb_ep *ep) | |||
| 610 | { | 601 | { |
| 611 | struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); | 602 | struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); |
| 612 | 603 | ||
| 613 | return usbhsg_pipe_disable(uep); | 604 | usbhsg_pipe_disable(uep); |
| 605 | |||
| 606 | uep->pipe->mod_private = NULL; | ||
| 607 | uep->pipe = NULL; | ||
| 608 | |||
| 609 | return 0; | ||
| 614 | } | 610 | } |
| 615 | 611 | ||
| 616 | static struct usb_request *usbhsg_ep_alloc_request(struct usb_ep *ep, | 612 | static struct usb_request *usbhsg_ep_alloc_request(struct usb_ep *ep, |
| @@ -761,9 +757,8 @@ static int usbhsg_try_start(struct usbhs_priv *priv, u32 status) | |||
| 761 | usbhs_pipe_init(priv, | 757 | usbhs_pipe_init(priv, |
| 762 | usbhsg_dma_map_ctrl); | 758 | usbhsg_dma_map_ctrl); |
| 763 | usbhs_fifo_init(priv); | 759 | usbhs_fifo_init(priv); |
| 764 | usbhsg_uep_init(gpriv); | ||
| 765 | 760 | ||
| 766 | /* dcp init */ | 761 | /* dcp init instead of usbhsg_ep_enable() */ |
| 767 | dcp->pipe = usbhs_dcp_malloc(priv); | 762 | dcp->pipe = usbhs_dcp_malloc(priv); |
| 768 | dcp->pipe->mod_private = dcp; | 763 | dcp->pipe->mod_private = dcp; |
| 769 | usbhs_pipe_config_update(dcp->pipe, 0, 0, 64); | 764 | usbhs_pipe_config_update(dcp->pipe, 0, 0, 64); |
| @@ -825,7 +820,7 @@ static int usbhsg_try_stop(struct usbhs_priv *priv, u32 status) | |||
| 825 | usbhs_sys_set_test_mode(priv, 0); | 820 | usbhs_sys_set_test_mode(priv, 0); |
| 826 | usbhs_sys_function_ctrl(priv, 0); | 821 | usbhs_sys_function_ctrl(priv, 0); |
| 827 | 822 | ||
| 828 | usbhsg_pipe_disable(dcp); | 823 | usbhsg_ep_disable(&dcp->ep); |
| 829 | 824 | ||
| 830 | dev_dbg(dev, "stop gadget\n"); | 825 | dev_dbg(dev, "stop gadget\n"); |
| 831 | 826 | ||
| @@ -883,6 +878,16 @@ static int usbhsg_get_frame(struct usb_gadget *gadget) | |||
| 883 | return usbhs_frame_get_num(priv); | 878 | return usbhs_frame_get_num(priv); |
| 884 | } | 879 | } |
| 885 | 880 | ||
| 881 | static int usbhsg_pullup(struct usb_gadget *gadget, int is_on) | ||
| 882 | { | ||
| 883 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | ||
| 884 | struct usbhs_priv *priv = usbhsg_gpriv_to_priv(gpriv); | ||
| 885 | |||
| 886 | usbhs_sys_function_pullup(priv, is_on); | ||
| 887 | |||
| 888 | return 0; | ||
| 889 | } | ||
| 890 | |||
| 886 | static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) | 891 | static int usbhsg_set_selfpowered(struct usb_gadget *gadget, int is_self) |
| 887 | { | 892 | { |
| 888 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); | 893 | struct usbhsg_gpriv *gpriv = usbhsg_gadget_to_gpriv(gadget); |
| @@ -900,6 +905,7 @@ static struct usb_gadget_ops usbhsg_gadget_ops = { | |||
| 900 | .set_selfpowered = usbhsg_set_selfpowered, | 905 | .set_selfpowered = usbhsg_set_selfpowered, |
| 901 | .udc_start = usbhsg_gadget_start, | 906 | .udc_start = usbhsg_gadget_start, |
| 902 | .udc_stop = usbhsg_gadget_stop, | 907 | .udc_stop = usbhsg_gadget_stop, |
| 908 | .pullup = usbhsg_pullup, | ||
| 903 | }; | 909 | }; |
| 904 | 910 | ||
| 905 | static int usbhsg_start(struct usbhs_priv *priv) | 911 | static int usbhsg_start(struct usbhs_priv *priv) |
| @@ -987,6 +993,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
| 987 | */ | 993 | */ |
| 988 | usbhsg_for_each_uep_with_dcp(uep, gpriv, i) { | 994 | usbhsg_for_each_uep_with_dcp(uep, gpriv, i) { |
| 989 | uep->gpriv = gpriv; | 995 | uep->gpriv = gpriv; |
| 996 | uep->pipe = NULL; | ||
| 990 | snprintf(uep->ep_name, EP_NAME_SIZE, "ep%d", i); | 997 | snprintf(uep->ep_name, EP_NAME_SIZE, "ep%d", i); |
| 991 | 998 | ||
| 992 | uep->ep.name = uep->ep_name; | 999 | uep->ep.name = uep->ep_name; |
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c index 069cd765400c..b86815421c8d 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 | ||
| @@ -652,9 +661,10 @@ static void usbhsh_queue_done(struct usbhs_priv *priv, struct usbhs_pkt *pkt) | |||
| 652 | status = -ESHUTDOWN; | 661 | status = -ESHUTDOWN; |
| 653 | 662 | ||
| 654 | urb->actual_length = pkt->actual; | 663 | urb->actual_length = pkt->actual; |
| 655 | usbhsh_ureq_free(hpriv, ureq); | ||
| 656 | 664 | ||
| 657 | usbhsh_endpoint_sequence_save(hpriv, urb, pkt); | 665 | usbhsh_endpoint_sequence_save(hpriv, urb, pkt); |
| 666 | usbhsh_ureq_free(hpriv, ureq); | ||
| 667 | |||
| 658 | usbhsh_pipe_detach(hpriv, usbhsh_ep_to_uep(urb->ep)); | 668 | usbhsh_pipe_detach(hpriv, usbhsh_ep_to_uep(urb->ep)); |
| 659 | 669 | ||
| 660 | usb_hcd_unlink_urb_from_ep(hcd, urb); | 670 | usb_hcd_unlink_urb_from_ep(hcd, urb); |
| @@ -686,9 +696,9 @@ static int usbhsh_queue_push(struct usb_hcd *hcd, | |||
| 686 | } | 696 | } |
| 687 | 697 | ||
| 688 | if (usb_pipein(urb->pipe)) | 698 | if (usb_pipein(urb->pipe)) |
| 689 | pipe->handler = &usbhs_fifo_pio_pop_handler; | 699 | pipe->handler = &usbhs_fifo_dma_pop_handler; |
| 690 | else | 700 | else |
| 691 | pipe->handler = &usbhs_fifo_pio_push_handler; | 701 | pipe->handler = &usbhs_fifo_dma_push_handler; |
| 692 | 702 | ||
| 693 | buf = (void *)(urb->transfer_buffer + urb->actual_length); | 703 | buf = (void *)(urb->transfer_buffer + urb->actual_length); |
| 694 | len = urb->transfer_buffer_length - urb->actual_length; | 704 | len = urb->transfer_buffer_length - urb->actual_length; |
| @@ -921,6 +931,19 @@ static int usbhsh_dcp_queue_push(struct usb_hcd *hcd, | |||
| 921 | */ | 931 | */ |
| 922 | static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | 932 | static int usbhsh_dma_map_ctrl(struct usbhs_pkt *pkt, int map) |
| 923 | { | 933 | { |
| 934 | if (map) { | ||
| 935 | struct usbhsh_request *ureq = usbhsh_pkt_to_ureq(pkt); | ||
| 936 | struct urb *urb = ureq->urb; | ||
| 937 | |||
| 938 | /* it can not use scatter/gather */ | ||
| 939 | if (urb->num_sgs) | ||
| 940 | return -EINVAL; | ||
| 941 | |||
| 942 | pkt->dma = urb->transfer_dma; | ||
| 943 | if (!pkt->dma) | ||
| 944 | return -EINVAL; | ||
| 945 | } | ||
| 946 | |||
| 924 | return 0; | 947 | return 0; |
| 925 | } | 948 | } |
| 926 | 949 | ||
| @@ -946,7 +969,6 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, | |||
| 946 | struct usb_host_endpoint *ep = urb->ep; | 969 | struct usb_host_endpoint *ep = urb->ep; |
| 947 | struct usbhsh_device *new_udev = NULL; | 970 | struct usbhsh_device *new_udev = NULL; |
| 948 | int is_dir_in = usb_pipein(urb->pipe); | 971 | int is_dir_in = usb_pipein(urb->pipe); |
| 949 | int i; | ||
| 950 | int ret; | 972 | int ret; |
| 951 | 973 | ||
| 952 | dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); | 974 | dev_dbg(dev, "%s (%s)\n", __func__, is_dir_in ? "in" : "out"); |
| @@ -992,13 +1014,7 @@ static int usbhsh_urb_enqueue(struct usb_hcd *hcd, | |||
| 992 | * attach pipe to endpoint | 1014 | * attach pipe to endpoint |
| 993 | * see [image of mod_host] | 1015 | * see [image of mod_host] |
| 994 | */ | 1016 | */ |
| 995 | for (i = 0; i < 1024; i++) { | 1017 | 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) { | 1018 | if (ret < 0) { |
| 1003 | dev_err(dev, "pipe attach failed\n"); | 1019 | dev_err(dev, "pipe attach failed\n"); |
| 1004 | goto usbhsh_urb_enqueue_error_free_endpoint; | 1020 | goto usbhsh_urb_enqueue_error_free_endpoint; |
| @@ -1072,8 +1088,6 @@ static void usbhsh_endpoint_disable(struct usb_hcd *hcd, | |||
| 1072 | static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) | 1088 | static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) |
| 1073 | { | 1089 | { |
| 1074 | struct usbhsh_hpriv *hpriv = usbhsh_hcd_to_hpriv(hcd); | 1090 | 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 */ | 1091 | int roothub_id = 1; /* only 1 root hub */ |
| 1078 | 1092 | ||
| 1079 | /* | 1093 | /* |
| @@ -1085,8 +1099,6 @@ static int usbhsh_hub_status_data(struct usb_hcd *hcd, char *buf) | |||
| 1085 | else | 1099 | else |
| 1086 | *buf = 0; | 1100 | *buf = 0; |
| 1087 | 1101 | ||
| 1088 | dev_dbg(dev, "%s (%02x)\n", __func__, *buf); | ||
| 1089 | |||
| 1090 | return !!(*buf); | 1102 | return !!(*buf); |
| 1091 | } | 1103 | } |
| 1092 | 1104 | ||
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/bus.c b/drivers/usb/serial/bus.c index c15f2e7cefc7..37decb13d7eb 100644 --- a/drivers/usb/serial/bus.c +++ b/drivers/usb/serial/bus.c | |||
| @@ -121,7 +121,6 @@ static int usb_serial_device_remove(struct device *dev) | |||
| 121 | return retval; | 121 | return retval; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | #ifdef CONFIG_HOTPLUG | ||
| 125 | static ssize_t store_new_id(struct device_driver *driver, | 124 | static ssize_t store_new_id(struct device_driver *driver, |
| 126 | const char *buf, size_t count) | 125 | const char *buf, size_t count) |
| 127 | { | 126 | { |
| @@ -159,15 +158,6 @@ static void free_dynids(struct usb_serial_driver *drv) | |||
| 159 | spin_unlock(&drv->dynids.lock); | 158 | spin_unlock(&drv->dynids.lock); |
| 160 | } | 159 | } |
| 161 | 160 | ||
| 162 | #else | ||
| 163 | static struct driver_attribute drv_attrs[] = { | ||
| 164 | __ATTR_NULL, | ||
| 165 | }; | ||
| 166 | static inline void free_dynids(struct usb_serial_driver *drv) | ||
| 167 | { | ||
| 168 | } | ||
| 169 | #endif | ||
| 170 | |||
| 171 | struct bus_type usb_serial_bus_type = { | 161 | struct bus_type usb_serial_bus_type = { |
| 172 | .name = "usb-serial", | 162 | .name = "usb-serial", |
| 173 | .match = usb_serial_device_match, | 163 | .match = usb_serial_device_match, |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index eb033fc92a15..f14736f647ff 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 *, |
| @@ -118,6 +113,7 @@ static const struct usb_device_id id_table[] = { | |||
| 118 | { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ | 113 | { USB_DEVICE(0x10C4, 0x8477) }, /* Balluff RFID */ |
| 119 | { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ | 114 | { USB_DEVICE(0x10C4, 0x85EA) }, /* AC-Services IBUS-IF */ |
| 120 | { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ | 115 | { USB_DEVICE(0x10C4, 0x85EB) }, /* AC-Services CIS-IBUS */ |
| 116 | { USB_DEVICE(0x10C4, 0x85F8) }, /* Virtenio Preon32 */ | ||
| 121 | { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */ | 117 | { USB_DEVICE(0x10C4, 0x8664) }, /* AC-Services CAN-IF */ |
| 122 | { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ | 118 | { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ |
| 123 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ | 119 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
| @@ -169,7 +165,7 @@ struct cp210x_serial_private { | |||
| 169 | static struct usb_serial_driver cp210x_device = { | 165 | static struct usb_serial_driver cp210x_device = { |
| 170 | .driver = { | 166 | .driver = { |
| 171 | .owner = THIS_MODULE, | 167 | .owner = THIS_MODULE, |
| 172 | .name = "cp210x", | 168 | .name = "cp210x", |
| 173 | }, | 169 | }, |
| 174 | .id_table = id_table, | 170 | .id_table = id_table, |
| 175 | .num_ports = 1, | 171 | .num_ports = 1, |
| @@ -179,7 +175,7 @@ static struct usb_serial_driver cp210x_device = { | |||
| 179 | .close = cp210x_close, | 175 | .close = cp210x_close, |
| 180 | .break_ctl = cp210x_break_ctl, | 176 | .break_ctl = cp210x_break_ctl, |
| 181 | .set_termios = cp210x_set_termios, | 177 | .set_termios = cp210x_set_termios, |
| 182 | .tiocmget = cp210x_tiocmget, | 178 | .tiocmget = cp210x_tiocmget, |
| 183 | .tiocmset = cp210x_tiocmset, | 179 | .tiocmset = cp210x_tiocmset, |
| 184 | .attach = cp210x_startup, | 180 | .attach = cp210x_startup, |
| 185 | .release = cp210x_release, | 181 | .release = cp210x_release, |
| @@ -281,7 +277,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
| 281 | int result, i, length; | 277 | int result, i, length; |
| 282 | 278 | ||
| 283 | /* Number of integers required to contain the array */ | 279 | /* Number of integers required to contain the array */ |
| 284 | length = (((size - 1) | 3) + 1)/4; | 280 | length = (((size - 1) | 3) + 1) / 4; |
| 285 | 281 | ||
| 286 | buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); | 282 | buf = kcalloc(length, sizeof(__le32), GFP_KERNEL); |
| 287 | if (!buf) { | 283 | if (!buf) { |
| @@ -328,12 +324,11 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
| 328 | int result, i, length; | 324 | int result, i, length; |
| 329 | 325 | ||
| 330 | /* Number of integers required to contain the array */ | 326 | /* Number of integers required to contain the array */ |
| 331 | length = (((size - 1) | 3) + 1)/4; | 327 | length = (((size - 1) | 3) + 1) / 4; |
| 332 | 328 | ||
| 333 | buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); | 329 | buf = kmalloc(length * sizeof(__le32), GFP_KERNEL); |
| 334 | if (!buf) { | 330 | if (!buf) { |
| 335 | dev_err(&port->dev, "%s - out of memory.\n", | 331 | dev_err(&port->dev, "%s - out of memory.\n", __func__); |
| 336 | __func__); | ||
| 337 | return -ENOMEM; | 332 | return -ENOMEM; |
| 338 | } | 333 | } |
| 339 | 334 | ||
| @@ -384,7 +379,8 @@ static inline int cp210x_set_config_single(struct usb_serial_port *port, | |||
| 384 | * cp210x_quantise_baudrate | 379 | * cp210x_quantise_baudrate |
| 385 | * Quantises the baud rate as per AN205 Table 1 | 380 | * Quantises the baud rate as per AN205 Table 1 |
| 386 | */ | 381 | */ |
| 387 | static unsigned int cp210x_quantise_baudrate(unsigned int baud) { | 382 | static unsigned int cp210x_quantise_baudrate(unsigned int baud) |
| 383 | { | ||
| 388 | if (baud <= 300) | 384 | if (baud <= 300) |
| 389 | baud = 300; | 385 | baud = 300; |
| 390 | else if (baud <= 600) baud = 600; | 386 | else if (baud <= 600) baud = 600; |
| @@ -467,9 +463,7 @@ static void cp210x_get_termios(struct tty_struct *tty, | |||
| 467 | cp210x_get_termios_port(tty->driver_data, | 463 | cp210x_get_termios_port(tty->driver_data, |
| 468 | &tty->termios.c_cflag, &baud); | 464 | &tty->termios.c_cflag, &baud); |
| 469 | tty_encode_baud_rate(tty, baud, baud); | 465 | tty_encode_baud_rate(tty, baud, baud); |
| 470 | } | 466 | } else { |
| 471 | |||
| 472 | else { | ||
| 473 | unsigned int cflag; | 467 | unsigned int cflag; |
| 474 | cflag = 0; | 468 | cflag = 0; |
| 475 | cp210x_get_termios_port(port, &cflag, &baud); | 469 | cp210x_get_termios_port(port, &cflag, &baud); |
| @@ -693,8 +687,8 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
| 693 | break;*/ | 687 | break;*/ |
| 694 | default: | 688 | default: |
| 695 | dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); | 689 | dev_dbg(dev, "cp210x driver does not support the number of bits requested, using 8 bit mode\n"); |
| 696 | bits |= BITS_DATA_8; | 690 | bits |= BITS_DATA_8; |
| 697 | break; | 691 | break; |
| 698 | } | 692 | } |
| 699 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 693 | 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"); | 694 | dev_dbg(dev, "Number of data bits requested not supported by device\n"); |
| @@ -767,7 +761,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
| 767 | 761 | ||
| 768 | } | 762 | } |
| 769 | 763 | ||
| 770 | static int cp210x_tiocmset (struct tty_struct *tty, | 764 | static int cp210x_tiocmset(struct tty_struct *tty, |
| 771 | unsigned int set, unsigned int clear) | 765 | unsigned int set, unsigned int clear) |
| 772 | { | 766 | { |
| 773 | struct usb_serial_port *port = tty->driver_data; | 767 | struct usb_serial_port *port = tty->driver_data; |
| @@ -809,7 +803,7 @@ static void cp210x_dtr_rts(struct usb_serial_port *p, int on) | |||
| 809 | cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS); | 803 | cp210x_tiocmset_port(p, 0, TIOCM_DTR|TIOCM_RTS); |
| 810 | } | 804 | } |
| 811 | 805 | ||
| 812 | static int cp210x_tiocmget (struct tty_struct *tty) | 806 | static int cp210x_tiocmget(struct tty_struct *tty) |
| 813 | { | 807 | { |
| 814 | struct usb_serial_port *port = tty->driver_data; | 808 | struct usb_serial_port *port = tty->driver_data; |
| 815 | unsigned int control; | 809 | unsigned int control; |
| @@ -829,7 +823,7 @@ static int cp210x_tiocmget (struct tty_struct *tty) | |||
| 829 | return result; | 823 | return result; |
| 830 | } | 824 | } |
| 831 | 825 | ||
| 832 | static void cp210x_break_ctl (struct tty_struct *tty, int break_state) | 826 | static void cp210x_break_ctl(struct tty_struct *tty, int break_state) |
| 833 | { | 827 | { |
| 834 | struct usb_serial_port *port = tty->driver_data; | 828 | struct usb_serial_port *port = tty->driver_data; |
| 835 | unsigned int state; | 829 | unsigned int state; |
| @@ -874,5 +868,4 @@ static void cp210x_release(struct usb_serial *serial) | |||
| 874 | module_usb_serial_driver(serial_drivers, id_table); | 868 | module_usb_serial_driver(serial_drivers, id_table); |
| 875 | 869 | ||
| 876 | MODULE_DESCRIPTION(DRIVER_DESC); | 870 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 877 | MODULE_VERSION(DRIVER_VERSION); | ||
| 878 | MODULE_LICENSE("GPL"); | 871 | 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..ba68835d06a6 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 | ||
| @@ -192,6 +191,7 @@ static struct usb_device_id id_table_combined [] = { | |||
| 192 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) }, | 191 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) }, |
| 193 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) }, | 192 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) }, |
| 194 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) }, | 193 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) }, |
| 194 | { USB_DEVICE(NEWPORT_VID, NEWPORT_AGILIS_PID) }, | ||
| 195 | { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, | 195 | { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) }, |
| 196 | { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, | 196 | { USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) }, |
| 197 | { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) }, | 197 | { USB_DEVICE(FTDI_VID, FTDI_SPROG_II) }, |
| @@ -875,6 +875,8 @@ static struct usb_device_id id_table_combined [] = { | |||
| 875 | { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID), | 875 | { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID), |
| 876 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 876 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
| 877 | { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) }, | 877 | { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) }, |
| 878 | /* Crucible Devices */ | ||
| 879 | { USB_DEVICE(FTDI_VID, FTDI_CT_COMET_PID) }, | ||
| 878 | { }, /* Optional parameter entry */ | 880 | { }, /* Optional parameter entry */ |
| 879 | { } /* Terminating entry */ | 881 | { } /* Terminating entry */ |
| 880 | }; | 882 | }; |
| @@ -923,6 +925,9 @@ static int ftdi_get_icount(struct tty_struct *tty, | |||
| 923 | static int ftdi_ioctl(struct tty_struct *tty, | 925 | static int ftdi_ioctl(struct tty_struct *tty, |
| 924 | unsigned int cmd, unsigned long arg); | 926 | unsigned int cmd, unsigned long arg); |
| 925 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state); | 927 | static void ftdi_break_ctl(struct tty_struct *tty, int break_state); |
| 928 | static int ftdi_chars_in_buffer(struct tty_struct *tty); | ||
| 929 | static int ftdi_get_modem_status(struct tty_struct *tty, | ||
| 930 | unsigned char status[2]); | ||
| 926 | 931 | ||
| 927 | static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base); | 932 | 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); | 933 | static unsigned short int ftdi_232am_baud_to_divisor(int baud); |
| @@ -957,6 +962,7 @@ static struct usb_serial_driver ftdi_sio_device = { | |||
| 957 | .ioctl = ftdi_ioctl, | 962 | .ioctl = ftdi_ioctl, |
| 958 | .set_termios = ftdi_set_termios, | 963 | .set_termios = ftdi_set_termios, |
| 959 | .break_ctl = ftdi_break_ctl, | 964 | .break_ctl = ftdi_break_ctl, |
| 965 | .chars_in_buffer = ftdi_chars_in_buffer, | ||
| 960 | }; | 966 | }; |
| 961 | 967 | ||
| 962 | static struct usb_serial_driver * const serial_drivers[] = { | 968 | static struct usb_serial_driver * const serial_drivers[] = { |
| @@ -1090,6 +1096,7 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, | |||
| 1090 | __func__, | 1096 | __func__, |
| 1091 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 1097 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
| 1092 | (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); | 1098 | (set & TIOCM_RTS) ? "HIGH" : (clear & TIOCM_RTS) ? "LOW" : "unchanged"); |
| 1099 | rv = usb_translate_errors(rv); | ||
| 1093 | } else { | 1100 | } else { |
| 1094 | dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, | 1101 | dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, |
| 1095 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", | 1102 | (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", |
| @@ -1682,7 +1689,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
| 1682 | 1689 | ||
| 1683 | kref_init(&priv->kref); | 1690 | kref_init(&priv->kref); |
| 1684 | mutex_init(&priv->cfg_lock); | 1691 | mutex_init(&priv->cfg_lock); |
| 1685 | memset(&priv->icount, 0x00, sizeof(priv->icount)); | ||
| 1686 | init_waitqueue_head(&priv->delta_msr_wait); | 1692 | init_waitqueue_head(&priv->delta_msr_wait); |
| 1687 | 1693 | ||
| 1688 | priv->flags = ASYNC_LOW_LATENCY; | 1694 | priv->flags = ASYNC_LOW_LATENCY; |
| @@ -1691,7 +1697,6 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) | |||
| 1691 | if (quirk && quirk->port_probe) | 1697 | if (quirk && quirk->port_probe) |
| 1692 | quirk->port_probe(priv); | 1698 | quirk->port_probe(priv); |
| 1693 | 1699 | ||
| 1694 | priv->port = port; | ||
| 1695 | usb_set_serial_port_data(port, priv); | 1700 | usb_set_serial_port_data(port, priv); |
| 1696 | 1701 | ||
| 1697 | ftdi_determine_type(port); | 1702 | ftdi_determine_type(port); |
| @@ -1781,7 +1786,7 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial) | |||
| 1781 | struct usb_device *udev = serial->dev; | 1786 | struct usb_device *udev = serial->dev; |
| 1782 | 1787 | ||
| 1783 | if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) || | 1788 | if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) || |
| 1784 | (udev->product && !strcmp(udev->product, "BeagleBone/XDS100"))) | 1789 | (udev->product && !strcmp(udev->product, "BeagleBone/XDS100V2"))) |
| 1785 | return ftdi_jtag_probe(serial); | 1790 | return ftdi_jtag_probe(serial); |
| 1786 | 1791 | ||
| 1787 | return 0; | 1792 | return 0; |
| @@ -2089,6 +2094,29 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) | |||
| 2089 | 2094 | ||
| 2090 | } | 2095 | } |
| 2091 | 2096 | ||
| 2097 | static int ftdi_chars_in_buffer(struct tty_struct *tty) | ||
| 2098 | { | ||
| 2099 | struct usb_serial_port *port = tty->driver_data; | ||
| 2100 | int chars; | ||
| 2101 | unsigned char buf[2]; | ||
| 2102 | int ret; | ||
| 2103 | |||
| 2104 | chars = usb_serial_generic_chars_in_buffer(tty); | ||
| 2105 | if (chars) | ||
| 2106 | goto out; | ||
| 2107 | |||
| 2108 | /* Check if hardware buffer is empty. */ | ||
| 2109 | ret = ftdi_get_modem_status(tty, buf); | ||
| 2110 | if (ret == 2) { | ||
| 2111 | if (!(buf[1] & FTDI_RS_TEMT)) | ||
| 2112 | chars = 1; | ||
| 2113 | } | ||
| 2114 | out: | ||
| 2115 | dev_dbg(&port->dev, "%s - %d\n", __func__, chars); | ||
| 2116 | |||
| 2117 | return chars; | ||
| 2118 | } | ||
| 2119 | |||
| 2092 | /* old_termios contains the original termios settings and tty->termios contains | 2120 | /* old_termios contains the original termios settings and tty->termios contains |
| 2093 | * the new setting to be used | 2121 | * the new setting to be used |
| 2094 | * WARNING: set_termios calls this with old_termios in kernel space | 2122 | * WARNING: set_termios calls this with old_termios in kernel space |
| @@ -2272,7 +2300,14 @@ no_c_cflag_changes: | |||
| 2272 | } | 2300 | } |
| 2273 | } | 2301 | } |
| 2274 | 2302 | ||
| 2275 | static int ftdi_tiocmget(struct tty_struct *tty) | 2303 | /* |
| 2304 | * Get modem-control status. | ||
| 2305 | * | ||
| 2306 | * Returns the number of status bytes retrieved (device dependant), or | ||
| 2307 | * negative error code. | ||
| 2308 | */ | ||
| 2309 | static int ftdi_get_modem_status(struct tty_struct *tty, | ||
| 2310 | unsigned char status[2]) | ||
| 2276 | { | 2311 | { |
| 2277 | struct usb_serial_port *port = tty->driver_data; | 2312 | struct usb_serial_port *port = tty->driver_data; |
| 2278 | struct ftdi_private *priv = usb_get_serial_port_data(port); | 2313 | struct ftdi_private *priv = usb_get_serial_port_data(port); |
| @@ -2312,16 +2347,43 @@ static int ftdi_tiocmget(struct tty_struct *tty) | |||
| 2312 | FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, | 2347 | FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE, |
| 2313 | 0, priv->interface, | 2348 | 0, priv->interface, |
| 2314 | buf, len, WDR_TIMEOUT); | 2349 | buf, len, WDR_TIMEOUT); |
| 2315 | if (ret < 0) | 2350 | if (ret < 0) { |
| 2351 | dev_err(&port->dev, "failed to get modem status: %d\n", ret); | ||
| 2352 | ret = usb_translate_errors(ret); | ||
| 2316 | goto out; | 2353 | goto out; |
| 2354 | } | ||
| 2317 | 2355 | ||
| 2318 | ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | | 2356 | status[0] = buf[0]; |
| 2319 | (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | | 2357 | if (ret > 1) |
| 2320 | (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | | 2358 | status[1] = buf[1]; |
| 2321 | (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | | 2359 | else |
| 2322 | priv->last_dtr_rts; | 2360 | status[1] = 0; |
| 2361 | |||
| 2362 | dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0], | ||
| 2363 | status[1]); | ||
| 2323 | out: | 2364 | out: |
| 2324 | kfree(buf); | 2365 | kfree(buf); |
| 2366 | |||
| 2367 | return ret; | ||
| 2368 | } | ||
| 2369 | |||
| 2370 | static int ftdi_tiocmget(struct tty_struct *tty) | ||
| 2371 | { | ||
| 2372 | struct usb_serial_port *port = tty->driver_data; | ||
| 2373 | struct ftdi_private *priv = usb_get_serial_port_data(port); | ||
| 2374 | unsigned char buf[2]; | ||
| 2375 | int ret; | ||
| 2376 | |||
| 2377 | ret = ftdi_get_modem_status(tty, buf); | ||
| 2378 | if (ret < 0) | ||
| 2379 | return ret; | ||
| 2380 | |||
| 2381 | ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) | | ||
| 2382 | (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) | | ||
| 2383 | (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) | | ||
| 2384 | (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0) | | ||
| 2385 | priv->last_dtr_rts; | ||
| 2386 | |||
| 2325 | return ret; | 2387 | return ret; |
| 2326 | } | 2388 | } |
| 2327 | 2389 | ||
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 57c12ef6625e..fa5d56038276 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
| @@ -752,6 +752,12 @@ | |||
| 752 | #define TTI_VID 0x103E /* Vendor Id */ | 752 | #define TTI_VID 0x103E /* Vendor Id */ |
| 753 | #define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */ | 753 | #define TTI_QL355P_PID 0x03E8 /* TTi QL355P power supply */ |
| 754 | 754 | ||
| 755 | /* | ||
| 756 | * Newport Cooperation (www.newport.com) | ||
| 757 | */ | ||
| 758 | #define NEWPORT_VID 0x104D | ||
| 759 | #define NEWPORT_AGILIS_PID 0x3000 | ||
| 760 | |||
| 755 | /* Interbiometrics USB I/O Board */ | 761 | /* Interbiometrics USB I/O Board */ |
| 756 | /* Developed for Interbiometrics by Rudolf Gugler */ | 762 | /* Developed for Interbiometrics by Rudolf Gugler */ |
| 757 | #define INTERBIOMETRICS_VID 0x1209 | 763 | #define INTERBIOMETRICS_VID 0x1209 |
| @@ -1253,3 +1259,9 @@ | |||
| 1253 | * ATI command output: Cinterion MC55i | 1259 | * ATI command output: Cinterion MC55i |
| 1254 | */ | 1260 | */ |
| 1255 | #define FTDI_CINTERION_MC55I_PID 0xA951 | 1261 | #define FTDI_CINTERION_MC55I_PID 0xA951 |
| 1262 | |||
| 1263 | /* | ||
| 1264 | * Product: Comet Caller ID decoder | ||
| 1265 | * Manufacturer: Crucible Technologies | ||
| 1266 | */ | ||
| 1267 | #define FTDI_CT_COMET_PID 0x8e08 | ||
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/opticon.c b/drivers/usb/serial/opticon.c index 6aba731d4864..c6bfb83efb1e 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Opticon USB barcode to serial driver | 2 | * Opticon USB barcode to serial driver |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2011 - 2012 Johan Hovold <jhovold@gmail.com> | ||
| 4 | * Copyright (C) 2011 Martin Jansen <martin.jansen@opticon.com> | 5 | * Copyright (C) 2011 Martin Jansen <martin.jansen@opticon.com> |
| 5 | * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de> | 6 | * Copyright (C) 2008 - 2009 Greg Kroah-Hartman <gregkh@suse.de> |
| 6 | * Copyright (C) 2008 - 2009 Novell Inc. | 7 | * Copyright (C) 2008 - 2009 Novell Inc. |
| @@ -40,114 +41,70 @@ MODULE_DEVICE_TABLE(usb, id_table); | |||
| 40 | 41 | ||
| 41 | /* This structure holds all of the individual device information */ | 42 | /* This structure holds all of the individual device information */ |
| 42 | struct opticon_private { | 43 | struct opticon_private { |
| 43 | struct usb_device *udev; | ||
| 44 | struct usb_serial *serial; | ||
| 45 | struct usb_serial_port *port; | ||
| 46 | unsigned char *bulk_in_buffer; | ||
| 47 | struct urb *bulk_read_urb; | ||
| 48 | int buffer_size; | ||
| 49 | u8 bulk_address; | ||
| 50 | spinlock_t lock; /* protects the following flags */ | 44 | spinlock_t lock; /* protects the following flags */ |
| 51 | bool throttled; | ||
| 52 | bool actually_throttled; | ||
| 53 | bool rts; | 45 | bool rts; |
| 54 | bool cts; | 46 | bool cts; |
| 55 | int outstanding_urbs; | 47 | int outstanding_urbs; |
| 56 | }; | 48 | }; |
| 57 | 49 | ||
| 58 | 50 | ||
| 59 | 51 | static void opticon_process_data_packet(struct usb_serial_port *port, | |
| 60 | static void opticon_read_bulk_callback(struct urb *urb) | 52 | const unsigned char *buf, size_t len) |
| 61 | { | 53 | { |
| 62 | struct opticon_private *priv = urb->context; | ||
| 63 | unsigned char *data = urb->transfer_buffer; | ||
| 64 | struct usb_serial_port *port = priv->port; | ||
| 65 | int status = urb->status; | ||
| 66 | struct tty_struct *tty; | 54 | struct tty_struct *tty; |
| 67 | int result; | 55 | |
| 68 | int data_length; | 56 | tty = tty_port_tty_get(&port->port); |
| 57 | if (!tty) | ||
| 58 | return; | ||
| 59 | |||
| 60 | tty_insert_flip_string(tty, buf, len); | ||
| 61 | tty_flip_buffer_push(tty); | ||
| 62 | tty_kref_put(tty); | ||
| 63 | } | ||
| 64 | |||
| 65 | static void opticon_process_status_packet(struct usb_serial_port *port, | ||
| 66 | const unsigned char *buf, size_t len) | ||
| 67 | { | ||
| 68 | struct opticon_private *priv = usb_get_serial_port_data(port); | ||
| 69 | unsigned long flags; | 69 | unsigned long flags; |
| 70 | 70 | ||
| 71 | switch (status) { | 71 | spin_lock_irqsave(&priv->lock, flags); |
| 72 | case 0: | 72 | if (buf[0] == 0x00) |
| 73 | /* success */ | 73 | priv->cts = false; |
| 74 | break; | 74 | else |
| 75 | case -ECONNRESET: | 75 | priv->cts = true; |
| 76 | case -ENOENT: | 76 | spin_unlock_irqrestore(&priv->lock, flags); |
| 77 | case -ESHUTDOWN: | 77 | } |
| 78 | /* this urb is terminated, clean up */ | 78 | |
| 79 | dev_dbg(&priv->udev->dev, "%s - urb shutting down with status: %d\n", | 79 | static void opticon_process_read_urb(struct urb *urb) |
| 80 | __func__, status); | 80 | { |
| 81 | struct usb_serial_port *port = urb->context; | ||
| 82 | const unsigned char *hdr = urb->transfer_buffer; | ||
| 83 | const unsigned char *data = hdr + 2; | ||
| 84 | size_t data_len = urb->actual_length - 2; | ||
| 85 | |||
| 86 | if (urb->actual_length <= 2) { | ||
| 87 | dev_dbg(&port->dev, "malformed packet received: %d bytes\n", | ||
| 88 | urb->actual_length); | ||
| 81 | return; | 89 | return; |
| 82 | default: | ||
| 83 | dev_dbg(&priv->udev->dev, "%s - nonzero urb status received: %d\n", | ||
| 84 | __func__, status); | ||
| 85 | goto exit; | ||
| 86 | } | 90 | } |
| 87 | 91 | /* | |
| 88 | usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data); | 92 | * Data from the device comes with a 2 byte header: |
| 89 | 93 | * | |
| 90 | if (urb->actual_length > 2) { | 94 | * <0x00><0x00>data... |
| 91 | data_length = urb->actual_length - 2; | 95 | * This is real data to be sent to the tty layer |
| 92 | 96 | * <0x00><0x01>level | |
| 93 | /* | 97 | * This is a CTS level change, the third byte is the CTS |
| 94 | * Data from the device comes with a 2 byte header: | 98 | * value (0 for low, 1 for high). |
| 95 | * | 99 | */ |
| 96 | * <0x00><0x00>data... | 100 | if ((hdr[0] == 0x00) && (hdr[1] == 0x00)) { |
| 97 | * This is real data to be sent to the tty layer | 101 | opticon_process_data_packet(port, data, data_len); |
| 98 | * <0x00><0x01)level | 102 | } else if ((hdr[0] == 0x00) && (hdr[1] == 0x01)) { |
| 99 | * This is a CTS level change, the third byte is the CTS | 103 | opticon_process_status_packet(port, data, data_len); |
| 100 | * value (0 for low, 1 for high). | ||
| 101 | */ | ||
| 102 | if ((data[0] == 0x00) && (data[1] == 0x00)) { | ||
| 103 | /* real data, send it to the tty layer */ | ||
| 104 | tty = tty_port_tty_get(&port->port); | ||
| 105 | if (tty) { | ||
| 106 | tty_insert_flip_string(tty, data + 2, | ||
| 107 | data_length); | ||
| 108 | tty_flip_buffer_push(tty); | ||
| 109 | tty_kref_put(tty); | ||
| 110 | } | ||
| 111 | } else { | ||
| 112 | if ((data[0] == 0x00) && (data[1] == 0x01)) { | ||
| 113 | spin_lock_irqsave(&priv->lock, flags); | ||
| 114 | /* CTS status information package */ | ||
| 115 | if (data[2] == 0x00) | ||
| 116 | priv->cts = false; | ||
| 117 | else | ||
| 118 | priv->cts = true; | ||
| 119 | spin_unlock_irqrestore(&priv->lock, flags); | ||
| 120 | } else { | ||
| 121 | dev_dbg(&priv->udev->dev, | ||
| 122 | "Unknown data packet received from the device:" | ||
| 123 | " %2x %2x\n", | ||
| 124 | data[0], data[1]); | ||
| 125 | } | ||
| 126 | } | ||
| 127 | } else { | 104 | } else { |
| 128 | dev_dbg(&priv->udev->dev, | 105 | dev_dbg(&port->dev, "unknown packet received: %02x %02x\n", |
| 129 | "Improper amount of data received from the device, " | 106 | hdr[0], hdr[1]); |
| 130 | "%d bytes", urb->actual_length); | ||
| 131 | } | 107 | } |
| 132 | |||
| 133 | exit: | ||
| 134 | spin_lock(&priv->lock); | ||
| 135 | |||
| 136 | /* Continue trying to always read if we should */ | ||
| 137 | if (!priv->throttled) { | ||
| 138 | usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev, | ||
| 139 | usb_rcvbulkpipe(priv->udev, | ||
| 140 | priv->bulk_address), | ||
| 141 | priv->bulk_in_buffer, priv->buffer_size, | ||
| 142 | opticon_read_bulk_callback, priv); | ||
| 143 | result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC); | ||
| 144 | if (result) | ||
| 145 | dev_err(&port->dev, | ||
| 146 | "%s - failed resubmitting read urb, error %d\n", | ||
| 147 | __func__, result); | ||
| 148 | } else | ||
| 149 | priv->actually_throttled = true; | ||
| 150 | spin_unlock(&priv->lock); | ||
| 151 | } | 108 | } |
| 152 | 109 | ||
| 153 | static int send_control_msg(struct usb_serial_port *port, u8 requesttype, | 110 | static int send_control_msg(struct usb_serial_port *port, u8 requesttype, |
| @@ -175,52 +132,35 @@ static int send_control_msg(struct usb_serial_port *port, u8 requesttype, | |||
| 175 | 132 | ||
| 176 | static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) | 133 | static int opticon_open(struct tty_struct *tty, struct usb_serial_port *port) |
| 177 | { | 134 | { |
| 178 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 135 | struct opticon_private *priv = usb_get_serial_port_data(port); |
| 179 | unsigned long flags; | 136 | unsigned long flags; |
| 180 | int result = 0; | 137 | int res; |
| 181 | 138 | ||
| 182 | spin_lock_irqsave(&priv->lock, flags); | 139 | spin_lock_irqsave(&priv->lock, flags); |
| 183 | priv->throttled = false; | ||
| 184 | priv->actually_throttled = false; | ||
| 185 | priv->port = port; | ||
| 186 | priv->rts = false; | 140 | priv->rts = false; |
| 187 | spin_unlock_irqrestore(&priv->lock, flags); | 141 | spin_unlock_irqrestore(&priv->lock, flags); |
| 188 | 142 | ||
| 189 | /* Clear RTS line */ | 143 | /* Clear RTS line */ |
| 190 | send_control_msg(port, CONTROL_RTS, 0); | 144 | send_control_msg(port, CONTROL_RTS, 0); |
| 191 | 145 | ||
| 192 | /* Setup the read URB and start reading from the device */ | ||
| 193 | usb_fill_bulk_urb(priv->bulk_read_urb, priv->udev, | ||
| 194 | usb_rcvbulkpipe(priv->udev, | ||
| 195 | priv->bulk_address), | ||
| 196 | priv->bulk_in_buffer, priv->buffer_size, | ||
| 197 | opticon_read_bulk_callback, priv); | ||
| 198 | |||
| 199 | /* clear the halt status of the enpoint */ | 146 | /* clear the halt status of the enpoint */ |
| 200 | usb_clear_halt(priv->udev, priv->bulk_read_urb->pipe); | 147 | usb_clear_halt(port->serial->dev, port->read_urb->pipe); |
| 148 | |||
| 149 | res = usb_serial_generic_open(tty, port); | ||
| 150 | if (!res) | ||
| 151 | return res; | ||
| 201 | 152 | ||
| 202 | result = usb_submit_urb(priv->bulk_read_urb, GFP_KERNEL); | ||
| 203 | if (result) | ||
| 204 | dev_err(&port->dev, | ||
| 205 | "%s - failed resubmitting read urb, error %d\n", | ||
| 206 | __func__, result); | ||
| 207 | /* Request CTS line state, sometimes during opening the current | 153 | /* Request CTS line state, sometimes during opening the current |
| 208 | * CTS state can be missed. */ | 154 | * CTS state can be missed. */ |
| 209 | send_control_msg(port, RESEND_CTS_STATE, 1); | 155 | send_control_msg(port, RESEND_CTS_STATE, 1); |
| 210 | return result; | ||
| 211 | } | ||
| 212 | |||
| 213 | static void opticon_close(struct usb_serial_port *port) | ||
| 214 | { | ||
| 215 | struct opticon_private *priv = usb_get_serial_data(port->serial); | ||
| 216 | 156 | ||
| 217 | /* shutdown our urbs */ | 157 | return res; |
| 218 | usb_kill_urb(priv->bulk_read_urb); | ||
| 219 | } | 158 | } |
| 220 | 159 | ||
| 221 | static void opticon_write_control_callback(struct urb *urb) | 160 | static void opticon_write_control_callback(struct urb *urb) |
| 222 | { | 161 | { |
| 223 | struct opticon_private *priv = urb->context; | 162 | struct usb_serial_port *port = urb->context; |
| 163 | struct opticon_private *priv = usb_get_serial_port_data(port); | ||
| 224 | int status = urb->status; | 164 | int status = urb->status; |
| 225 | unsigned long flags; | 165 | unsigned long flags; |
| 226 | 166 | ||
| @@ -231,20 +171,21 @@ static void opticon_write_control_callback(struct urb *urb) | |||
| 231 | kfree(urb->setup_packet); | 171 | kfree(urb->setup_packet); |
| 232 | 172 | ||
| 233 | if (status) | 173 | if (status) |
| 234 | dev_dbg(&priv->udev->dev, "%s - nonzero write bulk status received: %d\n", | 174 | dev_dbg(&port->dev, |
| 175 | "%s - non-zero urb status received: %d\n", | ||
| 235 | __func__, status); | 176 | __func__, status); |
| 236 | 177 | ||
| 237 | spin_lock_irqsave(&priv->lock, flags); | 178 | spin_lock_irqsave(&priv->lock, flags); |
| 238 | --priv->outstanding_urbs; | 179 | --priv->outstanding_urbs; |
| 239 | spin_unlock_irqrestore(&priv->lock, flags); | 180 | spin_unlock_irqrestore(&priv->lock, flags); |
| 240 | 181 | ||
| 241 | usb_serial_port_softint(priv->port); | 182 | usb_serial_port_softint(port); |
| 242 | } | 183 | } |
| 243 | 184 | ||
| 244 | static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, | 185 | static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, |
| 245 | const unsigned char *buf, int count) | 186 | const unsigned char *buf, int count) |
| 246 | { | 187 | { |
| 247 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 188 | struct opticon_private *priv = usb_get_serial_port_data(port); |
| 248 | struct usb_serial *serial = port->serial; | 189 | struct usb_serial *serial = port->serial; |
| 249 | struct urb *urb; | 190 | struct urb *urb; |
| 250 | unsigned char *buffer; | 191 | unsigned char *buffer; |
| @@ -298,7 +239,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
| 298 | usb_fill_control_urb(urb, serial->dev, | 239 | usb_fill_control_urb(urb, serial->dev, |
| 299 | usb_sndctrlpipe(serial->dev, 0), | 240 | usb_sndctrlpipe(serial->dev, 0), |
| 300 | (unsigned char *)dr, buffer, count, | 241 | (unsigned char *)dr, buffer, count, |
| 301 | opticon_write_control_callback, priv); | 242 | opticon_write_control_callback, port); |
| 302 | 243 | ||
| 303 | /* send it down the pipe */ | 244 | /* send it down the pipe */ |
| 304 | status = usb_submit_urb(urb, GFP_ATOMIC); | 245 | status = usb_submit_urb(urb, GFP_ATOMIC); |
| @@ -331,7 +272,7 @@ error_no_buffer: | |||
| 331 | static int opticon_write_room(struct tty_struct *tty) | 272 | static int opticon_write_room(struct tty_struct *tty) |
| 332 | { | 273 | { |
| 333 | struct usb_serial_port *port = tty->driver_data; | 274 | struct usb_serial_port *port = tty->driver_data; |
| 334 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 275 | struct opticon_private *priv = usb_get_serial_port_data(port); |
| 335 | unsigned long flags; | 276 | unsigned long flags; |
| 336 | 277 | ||
| 337 | /* | 278 | /* |
| @@ -350,44 +291,10 @@ static int opticon_write_room(struct tty_struct *tty) | |||
| 350 | return 2048; | 291 | return 2048; |
| 351 | } | 292 | } |
| 352 | 293 | ||
| 353 | static void opticon_throttle(struct tty_struct *tty) | ||
| 354 | { | ||
| 355 | struct usb_serial_port *port = tty->driver_data; | ||
| 356 | struct opticon_private *priv = usb_get_serial_data(port->serial); | ||
| 357 | unsigned long flags; | ||
| 358 | |||
| 359 | spin_lock_irqsave(&priv->lock, flags); | ||
| 360 | priv->throttled = true; | ||
| 361 | spin_unlock_irqrestore(&priv->lock, flags); | ||
| 362 | } | ||
| 363 | |||
| 364 | |||
| 365 | static void opticon_unthrottle(struct tty_struct *tty) | ||
| 366 | { | ||
| 367 | struct usb_serial_port *port = tty->driver_data; | ||
| 368 | struct opticon_private *priv = usb_get_serial_data(port->serial); | ||
| 369 | unsigned long flags; | ||
| 370 | int result, was_throttled; | ||
| 371 | |||
| 372 | spin_lock_irqsave(&priv->lock, flags); | ||
| 373 | priv->throttled = false; | ||
| 374 | was_throttled = priv->actually_throttled; | ||
| 375 | priv->actually_throttled = false; | ||
| 376 | spin_unlock_irqrestore(&priv->lock, flags); | ||
| 377 | |||
| 378 | if (was_throttled) { | ||
| 379 | result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC); | ||
| 380 | if (result) | ||
| 381 | dev_err(&port->dev, | ||
| 382 | "%s - failed submitting read urb, error %d\n", | ||
| 383 | __func__, result); | ||
| 384 | } | ||
| 385 | } | ||
| 386 | |||
| 387 | static int opticon_tiocmget(struct tty_struct *tty) | 294 | static int opticon_tiocmget(struct tty_struct *tty) |
| 388 | { | 295 | { |
| 389 | struct usb_serial_port *port = tty->driver_data; | 296 | struct usb_serial_port *port = tty->driver_data; |
| 390 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 297 | struct opticon_private *priv = usb_get_serial_port_data(port); |
| 391 | unsigned long flags; | 298 | unsigned long flags; |
| 392 | int result = 0; | 299 | int result = 0; |
| 393 | 300 | ||
| @@ -407,7 +314,7 @@ static int opticon_tiocmset(struct tty_struct *tty, | |||
| 407 | { | 314 | { |
| 408 | struct usb_serial_port *port = tty->driver_data; | 315 | struct usb_serial_port *port = tty->driver_data; |
| 409 | struct usb_serial *serial = port->serial; | 316 | struct usb_serial *serial = port->serial; |
| 410 | struct opticon_private *priv = usb_get_serial_data(port->serial); | 317 | struct opticon_private *priv = usb_get_serial_port_data(port); |
| 411 | unsigned long flags; | 318 | unsigned long flags; |
| 412 | bool rts; | 319 | bool rts; |
| 413 | bool changed = false; | 320 | bool changed = false; |
| @@ -438,7 +345,7 @@ static int opticon_tiocmset(struct tty_struct *tty, | |||
| 438 | return ret; | 345 | return ret; |
| 439 | } | 346 | } |
| 440 | 347 | ||
| 441 | static int get_serial_info(struct opticon_private *priv, | 348 | static int get_serial_info(struct usb_serial_port *port, |
| 442 | struct serial_struct __user *serial) | 349 | struct serial_struct __user *serial) |
| 443 | { | 350 | { |
| 444 | struct serial_struct tmp; | 351 | struct serial_struct tmp; |
| @@ -450,7 +357,7 @@ static int get_serial_info(struct opticon_private *priv, | |||
| 450 | 357 | ||
| 451 | /* fake emulate a 16550 uart to make userspace code happy */ | 358 | /* fake emulate a 16550 uart to make userspace code happy */ |
| 452 | tmp.type = PORT_16550A; | 359 | tmp.type = PORT_16550A; |
| 453 | tmp.line = priv->serial->minor; | 360 | tmp.line = port->serial->minor; |
| 454 | tmp.port = 0; | 361 | tmp.port = 0; |
| 455 | tmp.irq = 0; | 362 | tmp.irq = 0; |
| 456 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; | 363 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; |
| @@ -468,13 +375,12 @@ static int opticon_ioctl(struct tty_struct *tty, | |||
| 468 | unsigned int cmd, unsigned long arg) | 375 | unsigned int cmd, unsigned long arg) |
| 469 | { | 376 | { |
| 470 | struct usb_serial_port *port = tty->driver_data; | 377 | struct usb_serial_port *port = tty->driver_data; |
| 471 | struct opticon_private *priv = usb_get_serial_data(port->serial); | ||
| 472 | 378 | ||
| 473 | dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); | 379 | dev_dbg(&port->dev, "%s - port %d, cmd = 0x%x\n", __func__, port->number, cmd); |
| 474 | 380 | ||
| 475 | switch (cmd) { | 381 | switch (cmd) { |
| 476 | case TIOCGSERIAL: | 382 | case TIOCGSERIAL: |
| 477 | return get_serial_info(priv, | 383 | return get_serial_info(port, |
| 478 | (struct serial_struct __user *)arg); | 384 | (struct serial_struct __user *)arg); |
| 479 | } | 385 | } |
| 480 | 386 | ||
| @@ -483,106 +389,36 @@ static int opticon_ioctl(struct tty_struct *tty, | |||
| 483 | 389 | ||
| 484 | static int opticon_startup(struct usb_serial *serial) | 390 | static int opticon_startup(struct usb_serial *serial) |
| 485 | { | 391 | { |
| 486 | struct opticon_private *priv; | 392 | if (!serial->num_bulk_in) { |
| 487 | struct usb_host_interface *intf; | 393 | dev_err(&serial->dev->dev, "no bulk in endpoint\n"); |
| 488 | int i; | 394 | return -ENODEV; |
| 489 | int retval = -ENOMEM; | ||
| 490 | bool bulk_in_found = false; | ||
| 491 | |||
| 492 | /* create our private serial structure */ | ||
| 493 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); | ||
| 494 | if (priv == NULL) { | ||
| 495 | dev_err(&serial->dev->dev, "%s - Out of memory\n", __func__); | ||
| 496 | return -ENOMEM; | ||
| 497 | } | ||
| 498 | spin_lock_init(&priv->lock); | ||
| 499 | priv->serial = serial; | ||
| 500 | priv->port = serial->port[0]; | ||
| 501 | priv->udev = serial->dev; | ||
| 502 | priv->outstanding_urbs = 0; /* Init the outstanding urbs */ | ||
| 503 | |||
| 504 | /* find our bulk endpoint */ | ||
| 505 | intf = serial->interface->altsetting; | ||
| 506 | for (i = 0; i < intf->desc.bNumEndpoints; ++i) { | ||
| 507 | struct usb_endpoint_descriptor *endpoint; | ||
| 508 | |||
| 509 | endpoint = &intf->endpoint[i].desc; | ||
| 510 | if (!usb_endpoint_is_bulk_in(endpoint)) | ||
| 511 | continue; | ||
| 512 | |||
| 513 | priv->bulk_read_urb = usb_alloc_urb(0, GFP_KERNEL); | ||
| 514 | if (!priv->bulk_read_urb) { | ||
| 515 | dev_err(&priv->udev->dev, "out of memory\n"); | ||
| 516 | goto error; | ||
| 517 | } | ||
| 518 | |||
| 519 | priv->buffer_size = usb_endpoint_maxp(endpoint) * 2; | ||
| 520 | priv->bulk_in_buffer = kmalloc(priv->buffer_size, GFP_KERNEL); | ||
| 521 | if (!priv->bulk_in_buffer) { | ||
| 522 | dev_err(&priv->udev->dev, "out of memory\n"); | ||
| 523 | goto error; | ||
| 524 | } | ||
| 525 | |||
| 526 | priv->bulk_address = endpoint->bEndpointAddress; | ||
| 527 | |||
| 528 | bulk_in_found = true; | ||
| 529 | break; | ||
| 530 | } | ||
| 531 | |||
| 532 | if (!bulk_in_found) { | ||
| 533 | dev_err(&priv->udev->dev, | ||
| 534 | "Error - the proper endpoints were not found!\n"); | ||
| 535 | goto error; | ||
| 536 | } | 395 | } |
| 537 | 396 | ||
| 538 | usb_set_serial_data(serial, priv); | ||
| 539 | return 0; | 397 | return 0; |
| 540 | |||
| 541 | error: | ||
| 542 | usb_free_urb(priv->bulk_read_urb); | ||
| 543 | kfree(priv->bulk_in_buffer); | ||
| 544 | kfree(priv); | ||
| 545 | return retval; | ||
| 546 | } | 398 | } |
| 547 | 399 | ||
| 548 | static void opticon_disconnect(struct usb_serial *serial) | 400 | static int opticon_port_probe(struct usb_serial_port *port) |
| 549 | { | 401 | { |
| 550 | struct opticon_private *priv = usb_get_serial_data(serial); | 402 | struct opticon_private *priv; |
| 551 | |||
| 552 | usb_kill_urb(priv->bulk_read_urb); | ||
| 553 | usb_free_urb(priv->bulk_read_urb); | ||
| 554 | } | ||
| 555 | 403 | ||
| 556 | static void opticon_release(struct usb_serial *serial) | 404 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
| 557 | { | 405 | if (!priv) |
| 558 | struct opticon_private *priv = usb_get_serial_data(serial); | 406 | return -ENOMEM; |
| 559 | 407 | ||
| 560 | kfree(priv->bulk_in_buffer); | 408 | spin_lock_init(&priv->lock); |
| 561 | kfree(priv); | ||
| 562 | } | ||
| 563 | 409 | ||
| 564 | static int opticon_suspend(struct usb_serial *serial, pm_message_t message) | 410 | usb_set_serial_port_data(port, priv); |
| 565 | { | ||
| 566 | struct opticon_private *priv = usb_get_serial_data(serial); | ||
| 567 | 411 | ||
| 568 | usb_kill_urb(priv->bulk_read_urb); | ||
| 569 | return 0; | 412 | return 0; |
| 570 | } | 413 | } |
| 571 | 414 | ||
| 572 | static int opticon_resume(struct usb_serial *serial) | 415 | static int opticon_port_remove(struct usb_serial_port *port) |
| 573 | { | 416 | { |
| 574 | struct opticon_private *priv = usb_get_serial_data(serial); | 417 | struct opticon_private *priv = usb_get_serial_port_data(port); |
| 575 | struct usb_serial_port *port = serial->port[0]; | 418 | |
| 576 | int result; | 419 | kfree(priv); |
| 577 | 420 | ||
| 578 | mutex_lock(&port->port.mutex); | 421 | return 0; |
| 579 | /* This is protected by the port mutex against close/open */ | ||
| 580 | if (test_bit(ASYNCB_INITIALIZED, &port->port.flags)) | ||
| 581 | result = usb_submit_urb(priv->bulk_read_urb, GFP_NOIO); | ||
| 582 | else | ||
| 583 | result = 0; | ||
| 584 | mutex_unlock(&port->port.mutex); | ||
| 585 | return result; | ||
| 586 | } | 422 | } |
| 587 | 423 | ||
| 588 | static struct usb_serial_driver opticon_device = { | 424 | static struct usb_serial_driver opticon_device = { |
| @@ -592,20 +428,19 @@ static struct usb_serial_driver opticon_device = { | |||
| 592 | }, | 428 | }, |
| 593 | .id_table = id_table, | 429 | .id_table = id_table, |
| 594 | .num_ports = 1, | 430 | .num_ports = 1, |
| 431 | .bulk_in_size = 256, | ||
| 595 | .attach = opticon_startup, | 432 | .attach = opticon_startup, |
| 433 | .port_probe = opticon_port_probe, | ||
| 434 | .port_remove = opticon_port_remove, | ||
| 596 | .open = opticon_open, | 435 | .open = opticon_open, |
| 597 | .close = opticon_close, | ||
| 598 | .write = opticon_write, | 436 | .write = opticon_write, |
| 599 | .write_room = opticon_write_room, | 437 | .write_room = opticon_write_room, |
| 600 | .disconnect = opticon_disconnect, | 438 | .throttle = usb_serial_generic_throttle, |
| 601 | .release = opticon_release, | 439 | .unthrottle = usb_serial_generic_unthrottle, |
| 602 | .throttle = opticon_throttle, | ||
| 603 | .unthrottle = opticon_unthrottle, | ||
| 604 | .ioctl = opticon_ioctl, | 440 | .ioctl = opticon_ioctl, |
| 605 | .tiocmget = opticon_tiocmget, | 441 | .tiocmget = opticon_tiocmget, |
| 606 | .tiocmset = opticon_tiocmset, | 442 | .tiocmset = opticon_tiocmset, |
| 607 | .suspend = opticon_suspend, | 443 | .process_read_urb = opticon_process_read_urb, |
| 608 | .resume = opticon_resume, | ||
| 609 | }; | 444 | }; |
| 610 | 445 | ||
| 611 | static struct usb_serial_driver * const serial_drivers[] = { | 446 | static struct usb_serial_driver * const serial_drivers[] = { |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index edc64bb6f457..478adcfcdf26 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 | ||
| @@ -81,6 +80,7 @@ static void option_instat_callback(struct urb *urb); | |||
| 81 | #define OPTION_PRODUCT_GTM380_MODEM 0x7201 | 80 | #define OPTION_PRODUCT_GTM380_MODEM 0x7201 |
| 82 | 81 | ||
| 83 | #define HUAWEI_VENDOR_ID 0x12D1 | 82 | #define HUAWEI_VENDOR_ID 0x12D1 |
| 83 | #define HUAWEI_PRODUCT_E173 0x140C | ||
| 84 | #define HUAWEI_PRODUCT_K4505 0x1464 | 84 | #define HUAWEI_PRODUCT_K4505 0x1464 |
| 85 | #define HUAWEI_PRODUCT_K3765 0x1465 | 85 | #define HUAWEI_PRODUCT_K3765 0x1465 |
| 86 | #define HUAWEI_PRODUCT_K4605 0x14C6 | 86 | #define HUAWEI_PRODUCT_K4605 0x14C6 |
| @@ -288,6 +288,7 @@ static void option_instat_callback(struct urb *urb); | |||
| 288 | #define ALCATEL_VENDOR_ID 0x1bbb | 288 | #define ALCATEL_VENDOR_ID 0x1bbb |
| 289 | #define ALCATEL_PRODUCT_X060S_X200 0x0000 | 289 | #define ALCATEL_PRODUCT_X060S_X200 0x0000 |
| 290 | #define ALCATEL_PRODUCT_X220_X500D 0x0017 | 290 | #define ALCATEL_PRODUCT_X220_X500D 0x0017 |
| 291 | #define ALCATEL_PRODUCT_L100V 0x011e | ||
| 291 | 292 | ||
| 292 | #define PIRELLI_VENDOR_ID 0x1266 | 293 | #define PIRELLI_VENDOR_ID 0x1266 |
| 293 | #define PIRELLI_PRODUCT_C100_1 0x1002 | 294 | #define PIRELLI_PRODUCT_C100_1 0x1002 |
| @@ -429,9 +430,12 @@ static void option_instat_callback(struct urb *urb); | |||
| 429 | #define MEDIATEK_VENDOR_ID 0x0e8d | 430 | #define MEDIATEK_VENDOR_ID 0x0e8d |
| 430 | #define MEDIATEK_PRODUCT_DC_1COM 0x00a0 | 431 | #define MEDIATEK_PRODUCT_DC_1COM 0x00a0 |
| 431 | #define MEDIATEK_PRODUCT_DC_4COM 0x00a5 | 432 | #define MEDIATEK_PRODUCT_DC_4COM 0x00a5 |
| 433 | #define MEDIATEK_PRODUCT_DC_4COM2 0x00a7 | ||
| 432 | #define MEDIATEK_PRODUCT_DC_5COM 0x00a4 | 434 | #define MEDIATEK_PRODUCT_DC_5COM 0x00a4 |
| 433 | #define MEDIATEK_PRODUCT_7208_1COM 0x7101 | 435 | #define MEDIATEK_PRODUCT_7208_1COM 0x7101 |
| 434 | #define MEDIATEK_PRODUCT_7208_2COM 0x7102 | 436 | #define MEDIATEK_PRODUCT_7208_2COM 0x7102 |
| 437 | #define MEDIATEK_PRODUCT_7103_2COM 0x7103 | ||
| 438 | #define MEDIATEK_PRODUCT_7106_2COM 0x7106 | ||
| 435 | #define MEDIATEK_PRODUCT_FP_1COM 0x0003 | 439 | #define MEDIATEK_PRODUCT_FP_1COM 0x0003 |
| 436 | #define MEDIATEK_PRODUCT_FP_2COM 0x0023 | 440 | #define MEDIATEK_PRODUCT_FP_2COM 0x0023 |
| 437 | #define MEDIATEK_PRODUCT_FPDC_1COM 0x0043 | 441 | #define MEDIATEK_PRODUCT_FPDC_1COM 0x0043 |
| @@ -441,6 +445,10 @@ static void option_instat_callback(struct urb *urb); | |||
| 441 | #define CELLIENT_VENDOR_ID 0x2692 | 445 | #define CELLIENT_VENDOR_ID 0x2692 |
| 442 | #define CELLIENT_PRODUCT_MEN200 0x9005 | 446 | #define CELLIENT_PRODUCT_MEN200 0x9005 |
| 443 | 447 | ||
| 448 | /* Hyundai Petatel Inc. products */ | ||
| 449 | #define PETATEL_VENDOR_ID 0x1ff4 | ||
| 450 | #define PETATEL_PRODUCT_NP10T 0x600e | ||
| 451 | |||
| 444 | /* some devices interfaces need special handling due to a number of reasons */ | 452 | /* some devices interfaces need special handling due to a number of reasons */ |
| 445 | enum option_blacklist_reason { | 453 | enum option_blacklist_reason { |
| 446 | OPTION_BLACKLIST_NONE = 0, | 454 | OPTION_BLACKLIST_NONE = 0, |
| @@ -553,6 +561,8 @@ static const struct usb_device_id option_ids[] = { | |||
| 553 | { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) }, | 561 | { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLX) }, |
| 554 | { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) }, | 562 | { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GKE) }, |
| 555 | { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) }, | 563 | { USB_DEVICE(QUANTA_VENDOR_ID, QUANTA_PRODUCT_GLE) }, |
| 564 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff), | ||
| 565 | .driver_info = (kernel_ulong_t) &net_intf1_blacklist }, | ||
| 556 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff), | 566 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff), |
| 557 | .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, | 567 | .driver_info = (kernel_ulong_t) &huawei_cdc12_blacklist }, |
| 558 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff), | 568 | { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff), |
| @@ -741,23 +751,23 @@ static const struct usb_device_id option_ids[] = { | |||
| 741 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, | 751 | { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, |
| 742 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, | 752 | { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, |
| 743 | { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, | 753 | { USB_DEVICE(YISO_VENDOR_ID, YISO_PRODUCT_U893) }, |
| 744 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, | 754 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1, 0xff) }, |
| 745 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, | 755 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2, 0xff) }, |
| 746 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004) }, | 756 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1004, 0xff) }, |
| 747 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005) }, | 757 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1005, 0xff) }, |
| 748 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006) }, | 758 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1006, 0xff) }, |
| 749 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007) }, | 759 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1007, 0xff) }, |
| 750 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008) }, | 760 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1008, 0xff) }, |
| 751 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009) }, | 761 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1009, 0xff) }, |
| 752 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A) }, | 762 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100A, 0xff) }, |
| 753 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B) }, | 763 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100B, 0xff) }, |
| 754 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C) }, | 764 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100C, 0xff) }, |
| 755 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D) }, | 765 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100D, 0xff) }, |
| 756 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E) }, | 766 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100E, 0xff) }, |
| 757 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F) }, | 767 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_100F, 0xff) }, |
| 758 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010) }, | 768 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1010, 0xff) }, |
| 759 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011) }, | 769 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1011, 0xff) }, |
| 760 | { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012) }, | 770 | { USB_DEVICE_INTERFACE_CLASS(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_1012, 0xff) }, |
| 761 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, | 771 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC650) }, |
| 762 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, | 772 | { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, |
| 763 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ | 773 | { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6000)}, /* ZTE AC8700 */ |
| @@ -884,6 +894,10 @@ static const struct usb_device_id option_ids[] = { | |||
| 884 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff), | 894 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff), |
| 885 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, | 895 | .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, |
| 886 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, | 896 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, |
| 897 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0135, 0xff, 0xff, 0xff) }, | ||
| 898 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0136, 0xff, 0xff, 0xff) }, | ||
| 899 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0137, 0xff, 0xff, 0xff) }, | ||
| 900 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0139, 0xff, 0xff, 0xff) }, | ||
| 887 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, | 901 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, |
| 888 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, | 902 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, |
| 889 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) }, | 903 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0144, 0xff, 0xff, 0xff) }, |
| @@ -904,20 +918,35 @@ static const struct usb_device_id option_ids[] = { | |||
| 904 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, | 918 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, |
| 905 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), | 919 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), |
| 906 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 920 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 921 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0189, 0xff, 0xff, 0xff) }, | ||
| 907 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ | 922 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */ |
| 908 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 923 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 924 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0196, 0xff, 0xff, 0xff) }, | ||
| 925 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0197, 0xff, 0xff, 0xff) }, | ||
| 909 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */ | 926 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */ |
| 910 | .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, | 927 | .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, |
| 928 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0200, 0xff, 0xff, 0xff) }, | ||
| 929 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0201, 0xff, 0xff, 0xff) }, | ||
| 930 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0254, 0xff, 0xff, 0xff) }, | ||
| 911 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */ | 931 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */ |
| 912 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, | 932 | .driver_info = (kernel_ulong_t)&net_intf3_blacklist }, |
| 933 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0265, 0xff, 0xff, 0xff) }, | ||
| 934 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0284, 0xff, 0xff, 0xff), /* ZTE MF880 */ | ||
| 935 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
| 936 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0317, 0xff, 0xff, 0xff) }, | ||
| 913 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), | 937 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), |
| 914 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 938 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 939 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0330, 0xff, 0xff, 0xff) }, | ||
| 940 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0395, 0xff, 0xff, 0xff) }, | ||
| 941 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0414, 0xff, 0xff, 0xff) }, | ||
| 942 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0417, 0xff, 0xff, 0xff) }, | ||
| 915 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), | 943 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), |
| 916 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 944 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 917 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), | 945 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), |
| 918 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 946 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 919 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff), | 947 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff), |
| 920 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | 948 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, |
| 949 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1018, 0xff, 0xff, 0xff) }, | ||
| 921 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff), | 950 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff), |
| 922 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | 951 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, |
| 923 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, | 952 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, |
| @@ -1097,6 +1126,10 @@ static const struct usb_device_id option_ids[] = { | |||
| 1097 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, | 1126 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, |
| 1098 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, | 1127 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, |
| 1099 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, | 1128 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, |
| 1129 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1301, 0xff, 0xff, 0xff) }, | ||
| 1130 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1302, 0xff, 0xff, 0xff) }, | ||
| 1131 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1303, 0xff, 0xff, 0xff) }, | ||
| 1132 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1333, 0xff, 0xff, 0xff) }, | ||
| 1100 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff), | 1133 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff), |
| 1101 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | 1134 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, |
| 1102 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), | 1135 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), |
| @@ -1166,6 +1199,8 @@ static const struct usb_device_id option_ids[] = { | |||
| 1166 | .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist | 1199 | .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist |
| 1167 | }, | 1200 | }, |
| 1168 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D) }, | 1201 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D) }, |
| 1202 | { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_L100V), | ||
| 1203 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
| 1169 | { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, | 1204 | { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, |
| 1170 | { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, | 1205 | { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, |
| 1171 | { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), | 1206 | { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), |
| @@ -1174,22 +1209,22 @@ static const struct usb_device_id option_ids[] = { | |||
| 1174 | { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, | 1209 | { USB_DEVICE(LONGCHEER_VENDOR_ID, ZOOM_PRODUCT_4597) }, |
| 1175 | { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, | 1210 | { USB_DEVICE(HAIER_VENDOR_ID, HAIER_PRODUCT_CE100) }, |
| 1176 | /* Pirelli */ | 1211 | /* Pirelli */ |
| 1177 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1)}, | 1212 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_1, 0xff) }, |
| 1178 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2)}, | 1213 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_C100_2, 0xff) }, |
| 1179 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004)}, | 1214 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1004, 0xff) }, |
| 1180 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005)}, | 1215 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1005, 0xff) }, |
| 1181 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006)}, | 1216 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1006, 0xff) }, |
| 1182 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007)}, | 1217 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1007, 0xff) }, |
| 1183 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008)}, | 1218 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1008, 0xff) }, |
| 1184 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009)}, | 1219 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1009, 0xff) }, |
| 1185 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A)}, | 1220 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100A, 0xff) }, |
| 1186 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B) }, | 1221 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100B, 0xff) }, |
| 1187 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C) }, | 1222 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100C, 0xff) }, |
| 1188 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D) }, | 1223 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100D, 0xff) }, |
| 1189 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E) }, | 1224 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100E, 0xff) }, |
| 1190 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F) }, | 1225 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_100F, 0xff) }, |
| 1191 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011)}, | 1226 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1011, 0xff) }, |
| 1192 | { USB_DEVICE(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012)}, | 1227 | { USB_DEVICE_INTERFACE_CLASS(PIRELLI_VENDOR_ID, PIRELLI_PRODUCT_1012, 0xff) }, |
| 1193 | /* Cinterion */ | 1228 | /* Cinterion */ |
| 1194 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, | 1229 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_E) }, |
| 1195 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, | 1230 | { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) }, |
| @@ -1270,7 +1305,12 @@ static const struct usb_device_id option_ids[] = { | |||
| 1270 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_2COM, 0x0a, 0x00, 0x00) }, | 1305 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FP_2COM, 0x0a, 0x00, 0x00) }, |
| 1271 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_1COM, 0x0a, 0x00, 0x00) }, | 1306 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_1COM, 0x0a, 0x00, 0x00) }, |
| 1272 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_2COM, 0x0a, 0x00, 0x00) }, | 1307 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_FPDC_2COM, 0x0a, 0x00, 0x00) }, |
| 1308 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7103_2COM, 0xff, 0x00, 0x00) }, | ||
| 1309 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_7106_2COM, 0x02, 0x02, 0x01) }, | ||
| 1310 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x02, 0x01) }, | ||
| 1311 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, MEDIATEK_PRODUCT_DC_4COM2, 0xff, 0x00, 0x00) }, | ||
| 1273 | { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, | 1312 | { USB_DEVICE(CELLIENT_VENDOR_ID, CELLIENT_PRODUCT_MEN200) }, |
| 1313 | { USB_DEVICE(PETATEL_VENDOR_ID, PETATEL_PRODUCT_NP10T) }, | ||
| 1274 | { } /* Terminating entry */ | 1314 | { } /* Terminating entry */ |
| 1275 | }; | 1315 | }; |
| 1276 | MODULE_DEVICE_TABLE(usb, option_ids); | 1316 | MODULE_DEVICE_TABLE(usb, option_ids); |
| @@ -1350,20 +1390,10 @@ static int option_probe(struct usb_serial *serial, | |||
| 1350 | &serial->interface->cur_altsetting->desc; | 1390 | &serial->interface->cur_altsetting->desc; |
| 1351 | struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; | 1391 | struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; |
| 1352 | 1392 | ||
| 1353 | /* | 1393 | /* Never bind to the CD-Rom emulation interface */ |
| 1354 | * D-Link DWM 652 still exposes CD-Rom emulation interface in modem | 1394 | 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; | 1395 | return -ENODEV; |
| 1361 | 1396 | ||
| 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 | /* | 1397 | /* |
| 1368 | * Don't bind reserved interfaces (like network ones) which often have | 1398 | * Don't bind reserved interfaces (like network ones) which often have |
| 1369 | * the same class/subclass/protocol as the serial interfaces. Look at | 1399 | * the same class/subclass/protocol as the serial interfaces. Look at |
| @@ -1378,9 +1408,9 @@ static int option_probe(struct usb_serial *serial, | |||
| 1378 | * Don't bind network interface on Samsung GT-B3730, it is handled by | 1408 | * Don't bind network interface on Samsung GT-B3730, it is handled by |
| 1379 | * a separate module. | 1409 | * a separate module. |
| 1380 | */ | 1410 | */ |
| 1381 | if (dev_desc->idVendor == SAMSUNG_VENDOR_ID && | 1411 | if (dev_desc->idVendor == cpu_to_le16(SAMSUNG_VENDOR_ID) && |
| 1382 | dev_desc->idProduct == SAMSUNG_PRODUCT_GT_B3730 && | 1412 | dev_desc->idProduct == cpu_to_le16(SAMSUNG_PRODUCT_GT_B3730) && |
| 1383 | iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) | 1413 | iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) |
| 1384 | return -ENODEV; | 1414 | return -ENODEV; |
| 1385 | 1415 | ||
| 1386 | /* Store device id so we can use it during attach. */ | 1416 | /* Store device id so we can use it during attach. */ |
| @@ -1518,5 +1548,4 @@ static int option_send_setup(struct usb_serial_port *port) | |||
| 1518 | 1548 | ||
| 1519 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1549 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 1520 | MODULE_DESCRIPTION(DRIVER_DESC); | 1550 | MODULE_DESCRIPTION(DRIVER_DESC); |
| 1521 | MODULE_VERSION(DRIVER_VERSION); | ||
| 1522 | MODULE_LICENSE("GPL"); | 1551 | 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-serial.c b/drivers/usb/serial/usb-serial.c index 73b8e0569164..64bda135ba7e 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
| @@ -597,6 +597,7 @@ static void port_release(struct device *dev) | |||
| 597 | kfifo_free(&port->write_fifo); | 597 | kfifo_free(&port->write_fifo); |
| 598 | kfree(port->interrupt_in_buffer); | 598 | kfree(port->interrupt_in_buffer); |
| 599 | kfree(port->interrupt_out_buffer); | 599 | kfree(port->interrupt_out_buffer); |
| 600 | tty_port_destroy(&port->port); | ||
| 600 | kfree(port); | 601 | kfree(port); |
| 601 | } | 602 | } |
| 602 | 603 | ||
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/Kconfig b/drivers/usb/storage/Kconfig index 0ae7bb64b5ea..eab04a6b5fbc 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
| @@ -203,7 +203,7 @@ config USB_STORAGE_ENE_UB6250 | |||
| 203 | 203 | ||
| 204 | config USB_UAS | 204 | config USB_UAS |
| 205 | tristate "USB Attached SCSI" | 205 | tristate "USB Attached SCSI" |
| 206 | depends on USB && SCSI | 206 | depends on USB && SCSI && BROKEN |
| 207 | help | 207 | help |
| 208 | The USB Attached SCSI protocol is supported by some USB | 208 | The USB Attached SCSI protocol is supported by some USB |
| 209 | storage devices. It permits higher performance by supporting | 209 | storage devices. It permits higher performance by supporting |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index d36446dd7ae8..6c3586a4c956 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); |
| @@ -883,7 +883,7 @@ static void rts51x_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
| 883 | } else { | 883 | } else { |
| 884 | US_DEBUGP("%s: NOT working scsi, not SS\n", __func__); | 884 | US_DEBUGP("%s: NOT working scsi, not SS\n", __func__); |
| 885 | chip->proto_handler_backup(srb, us); | 885 | chip->proto_handler_backup(srb, us); |
| 886 | /* Check wether card is plugged in */ | 886 | /* Check whether card is plugged in */ |
| 887 | if (srb->cmnd[0] == TEST_UNIT_READY) { | 887 | if (srb->cmnd[0] == TEST_UNIT_READY) { |
| 888 | if (srb->result == SAM_STAT_GOOD) { | 888 | if (srb->result == SAM_STAT_GOOD) { |
| 889 | SET_LUN_READY(chip, srb->device->lun); | 889 | SET_LUN_READY(chip, srb->device->lun); |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 12aa72630aed..31b3e1a61bbd 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
| @@ -925,7 +925,6 @@ int usb_stor_probe1(struct us_data **pus, | |||
| 925 | host->max_cmd_len = 16; | 925 | host->max_cmd_len = 16; |
| 926 | host->sg_tablesize = usb_stor_sg_tablesize(intf); | 926 | host->sg_tablesize = usb_stor_sg_tablesize(intf); |
| 927 | *pus = us = host_to_us(host); | 927 | *pus = us = host_to_us(host); |
| 928 | memset(us, 0, sizeof(struct us_data)); | ||
| 929 | mutex_init(&(us->dev_mutex)); | 928 | mutex_init(&(us->dev_mutex)); |
| 930 | us_set_lock_class(&us->dev_mutex, intf); | 929 | us_set_lock_class(&us->dev_mutex, intf); |
| 931 | init_completion(&us->cmnd_ready); | 930 | init_completion(&us->cmnd_ready); |
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 | * |
