diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-20 14:26:30 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-20 14:26:30 -0400 |
commit | ed378a52dabf77b406b447fd3238f83ea24b71fa (patch) | |
tree | 07e1a7ec2d1c08767ee81b9910f5912b80502632 | |
parent | 843ec558f91b8e8fdb6efc908f2c0506407cc750 (diff) | |
parent | 11207b6fe05438b2e87a26435cd98db3d55e6fa7 (diff) |
Merge tag 'usb-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB merge for 3.4-rc1 from Greg KH:
"Here's the big USB merge for the 3.4-rc1 merge window.
Lots of gadget driver reworks here, driver updates, xhci changes, some
new drivers added, usb-serial core reworking to fix some bugs, and
other various minor things.
There are some patches touching arch code, but they have all been
acked by the various arch maintainers."
* tag 'usb-3.3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (302 commits)
net: qmi_wwan: add support for ZTE MF820D
USB: option: add ZTE MF820D
usb: gadget: f_fs: Remove lock is held before freeing checks
USB: option: make interface blacklist work again
usb/ub: deprecate & schedule for removal the "Low Performance USB Block" driver
USB: ohci-pxa27x: add clk_prepare/clk_unprepare calls
USB: use generic platform driver on ath79
USB: EHCI: Add a generic platform device driver
USB: OHCI: Add a generic platform device driver
USB: ftdi_sio: new PID: LUMEL PD12
USB: ftdi_sio: add support for FT-X series devices
USB: serial: mos7840: Fixed MCS7820 device attach problem
usb: Don't make USB_ARCH_HAS_{XHCI,OHCI,EHCI} depend on USB_SUPPORT.
usb gadget: fix a section mismatch when compiling g_ffs with CONFIG_USB_FUNCTIONFS_ETH
USB: ohci-nxp: Remove i2c_write(), use smbus
USB: ohci-nxp: Support for LPC32xx
USB: ohci-nxp: Rename symbols from pnx4008 to nxp
USB: OHCI-HCD: Rename ohci-pnx4008 to ohci-nxp
usb: gadget: Kconfig: fix typo for 'different'
usb: dwc3: pci: fix another failure path in dwc3_pci_probe()
...
269 files changed, 9689 insertions, 5607 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index b4f548792e32..7c22a532fdfb 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb | |||
@@ -182,3 +182,14 @@ Description: | |||
182 | USB2 hardware LPM is enabled for the device. Developer can | 182 | USB2 hardware LPM is enabled for the device. Developer can |
183 | write y/Y/1 or n/N/0 to the file to enable/disable the | 183 | write y/Y/1 or n/N/0 to the file to enable/disable the |
184 | feature. | 184 | feature. |
185 | |||
186 | What: /sys/bus/usb/devices/.../removable | ||
187 | Date: February 2012 | ||
188 | Contact: Matthew Garrett <mjg@redhat.com> | ||
189 | Description: | ||
190 | Some information about whether a given USB device is | ||
191 | physically fixed to the platform can be inferred from a | ||
192 | combination of hub decriptor bits and platform-specific data | ||
193 | such as ACPI. This file will read either "removable" or | ||
194 | "fixed" if the information is available, and "unknown" | ||
195 | otherwise. \ No newline at end of file | ||
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index a0ffac029a0d..d5dc80f30352 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -524,3 +524,14 @@ Files: arch/arm/mach-at91/at91cap9.c | |||
524 | Why: The code is not actively maintained and platforms are now hard to find. | 524 | Why: The code is not actively maintained and platforms are now hard to find. |
525 | Who: Nicolas Ferre <nicolas.ferre@atmel.com> | 525 | Who: Nicolas Ferre <nicolas.ferre@atmel.com> |
526 | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 526 | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
527 | |||
528 | ---------------------------- | ||
529 | |||
530 | What: Low Performance USB Block driver ("CONFIG_BLK_DEV_UB") | ||
531 | When: 3.6 | ||
532 | Why: This driver provides support for USB storage devices like "USB | ||
533 | sticks". As of now, it is deactivated in Debian, Fedora and | ||
534 | Ubuntu. All current users can switch over to usb-storage | ||
535 | (CONFIG_USB_STORAGE) which only drawback is the additional SCSI | ||
536 | stack. | ||
537 | Who: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> | ||
diff --git a/Documentation/i2c/instantiating-devices b/Documentation/i2c/instantiating-devices index 9edb75d8c9b9..abf63615ee05 100644 --- a/Documentation/i2c/instantiating-devices +++ b/Documentation/i2c/instantiating-devices | |||
@@ -87,11 +87,11 @@ it may have different addresses from one board to the next (manufacturer | |||
87 | changing its design without notice). In this case, you can call | 87 | changing its design without notice). In this case, you can call |
88 | i2c_new_probed_device() instead of i2c_new_device(). | 88 | i2c_new_probed_device() instead of i2c_new_device(). |
89 | 89 | ||
90 | Example (from the pnx4008 OHCI driver): | 90 | Example (from the nxp OHCI driver): |
91 | 91 | ||
92 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; | 92 | static const unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END }; |
93 | 93 | ||
94 | static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | 94 | static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) |
95 | { | 95 | { |
96 | (...) | 96 | (...) |
97 | struct i2c_adapter *i2c_adap; | 97 | struct i2c_adapter *i2c_adap; |
@@ -100,7 +100,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
100 | (...) | 100 | (...) |
101 | i2c_adap = i2c_get_adapter(2); | 101 | i2c_adap = i2c_get_adapter(2); |
102 | memset(&i2c_info, 0, sizeof(struct i2c_board_info)); | 102 | memset(&i2c_info, 0, sizeof(struct i2c_board_info)); |
103 | strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE); | 103 | strlcpy(i2c_info.type, "isp1301_nxp", I2C_NAME_SIZE); |
104 | isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, | 104 | isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, |
105 | normal_i2c, NULL); | 105 | normal_i2c, NULL); |
106 | i2c_put_adapter(i2c_adap); | 106 | i2c_put_adapter(i2c_adap); |
diff --git a/arch/arm/mach-imx/mx31moboard-devboard.c b/arch/arm/mach-imx/mx31moboard-devboard.c index 0aa25364360d..cc285e507286 100644 --- a/arch/arm/mach-imx/mx31moboard-devboard.c +++ b/arch/arm/mach-imx/mx31moboard-devboard.c | |||
@@ -158,7 +158,7 @@ static int devboard_usbh1_hw_init(struct platform_device *pdev) | |||
158 | #define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B) | 158 | #define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B) |
159 | #define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE) | 159 | #define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE) |
160 | 160 | ||
161 | static int devboard_isp1105_init(struct otg_transceiver *otg) | 161 | static int devboard_isp1105_init(struct usb_phy *otg) |
162 | { | 162 | { |
163 | int ret = gpio_request(USBH1_MODE, "usbh1-mode"); | 163 | int ret = gpio_request(USBH1_MODE, "usbh1-mode"); |
164 | if (ret) | 164 | if (ret) |
@@ -177,7 +177,7 @@ static int devboard_isp1105_init(struct otg_transceiver *otg) | |||
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | static int devboard_isp1105_set_vbus(struct otg_transceiver *otg, bool on) | 180 | static int devboard_isp1105_set_vbus(struct usb_otg *otg, bool on) |
181 | { | 181 | { |
182 | if (on) | 182 | if (on) |
183 | gpio_set_value(USBH1_VBUSEN_B, 0); | 183 | gpio_set_value(USBH1_VBUSEN_B, 0); |
@@ -194,18 +194,24 @@ static struct mxc_usbh_platform_data usbh1_pdata __initdata = { | |||
194 | 194 | ||
195 | static int __init devboard_usbh1_init(void) | 195 | static int __init devboard_usbh1_init(void) |
196 | { | 196 | { |
197 | struct otg_transceiver *otg; | 197 | struct usb_phy *phy; |
198 | struct platform_device *pdev; | 198 | struct platform_device *pdev; |
199 | 199 | ||
200 | otg = kzalloc(sizeof(*otg), GFP_KERNEL); | 200 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); |
201 | if (!otg) | 201 | if (!phy) |
202 | return -ENOMEM; | 202 | return -ENOMEM; |
203 | 203 | ||
204 | otg->label = "ISP1105"; | 204 | phy->otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL); |
205 | otg->init = devboard_isp1105_init; | 205 | if (!phy->otg) { |
206 | otg->set_vbus = devboard_isp1105_set_vbus; | 206 | kfree(phy); |
207 | return -ENOMEM; | ||
208 | } | ||
209 | |||
210 | phy->label = "ISP1105"; | ||
211 | phy->init = devboard_isp1105_init; | ||
212 | phy->otg->set_vbus = devboard_isp1105_set_vbus; | ||
207 | 213 | ||
208 | usbh1_pdata.otg = otg; | 214 | usbh1_pdata.otg = phy; |
209 | 215 | ||
210 | pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata); | 216 | pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata); |
211 | if (IS_ERR(pdev)) | 217 | if (IS_ERR(pdev)) |
diff --git a/arch/arm/mach-imx/mx31moboard-marxbot.c b/arch/arm/mach-imx/mx31moboard-marxbot.c index bb639cbda4e5..135c90e3a45f 100644 --- a/arch/arm/mach-imx/mx31moboard-marxbot.c +++ b/arch/arm/mach-imx/mx31moboard-marxbot.c | |||
@@ -272,7 +272,7 @@ static int marxbot_usbh1_hw_init(struct platform_device *pdev) | |||
272 | #define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B) | 272 | #define USBH1_VBUSEN_B IOMUX_TO_GPIO(MX31_PIN_NFRE_B) |
273 | #define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE) | 273 | #define USBH1_MODE IOMUX_TO_GPIO(MX31_PIN_NFALE) |
274 | 274 | ||
275 | static int marxbot_isp1105_init(struct otg_transceiver *otg) | 275 | static int marxbot_isp1105_init(struct usb_phy *otg) |
276 | { | 276 | { |
277 | int ret = gpio_request(USBH1_MODE, "usbh1-mode"); | 277 | int ret = gpio_request(USBH1_MODE, "usbh1-mode"); |
278 | if (ret) | 278 | if (ret) |
@@ -291,7 +291,7 @@ static int marxbot_isp1105_init(struct otg_transceiver *otg) | |||
291 | } | 291 | } |
292 | 292 | ||
293 | 293 | ||
294 | static int marxbot_isp1105_set_vbus(struct otg_transceiver *otg, bool on) | 294 | static int marxbot_isp1105_set_vbus(struct usb_otg *otg, bool on) |
295 | { | 295 | { |
296 | if (on) | 296 | if (on) |
297 | gpio_set_value(USBH1_VBUSEN_B, 0); | 297 | gpio_set_value(USBH1_VBUSEN_B, 0); |
@@ -308,18 +308,24 @@ static struct mxc_usbh_platform_data usbh1_pdata __initdata = { | |||
308 | 308 | ||
309 | static int __init marxbot_usbh1_init(void) | 309 | static int __init marxbot_usbh1_init(void) |
310 | { | 310 | { |
311 | struct otg_transceiver *otg; | 311 | struct usb_phy *phy; |
312 | struct platform_device *pdev; | 312 | struct platform_device *pdev; |
313 | 313 | ||
314 | otg = kzalloc(sizeof(*otg), GFP_KERNEL); | 314 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); |
315 | if (!otg) | 315 | if (!phy) |
316 | return -ENOMEM; | 316 | return -ENOMEM; |
317 | 317 | ||
318 | otg->label = "ISP1105"; | 318 | phy->otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL); |
319 | otg->init = marxbot_isp1105_init; | 319 | if (!phy->otg) { |
320 | otg->set_vbus = marxbot_isp1105_set_vbus; | 320 | kfree(phy); |
321 | return -ENOMEM; | ||
322 | } | ||
323 | |||
324 | phy->label = "ISP1105"; | ||
325 | phy->init = marxbot_isp1105_init; | ||
326 | phy->otg->set_vbus = marxbot_isp1105_set_vbus; | ||
321 | 327 | ||
322 | usbh1_pdata.otg = otg; | 328 | usbh1_pdata.otg = phy; |
323 | 329 | ||
324 | pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata); | 330 | pdev = imx31_add_mxc_ehci_hs(1, &usbh1_pdata); |
325 | if (IS_ERR(pdev)) | 331 | if (IS_ERR(pdev)) |
diff --git a/arch/arm/mach-pxa/pxa3xx-ulpi.c b/arch/arm/mach-pxa/pxa3xx-ulpi.c index e28dfb88827f..5ead6d480c6d 100644 --- a/arch/arm/mach-pxa/pxa3xx-ulpi.c +++ b/arch/arm/mach-pxa/pxa3xx-ulpi.c | |||
@@ -33,7 +33,7 @@ struct pxa3xx_u2d_ulpi { | |||
33 | struct clk *clk; | 33 | struct clk *clk; |
34 | void __iomem *mmio_base; | 34 | void __iomem *mmio_base; |
35 | 35 | ||
36 | struct otg_transceiver *otg; | 36 | struct usb_phy *otg; |
37 | unsigned int ulpi_mode; | 37 | unsigned int ulpi_mode; |
38 | }; | 38 | }; |
39 | 39 | ||
@@ -79,7 +79,7 @@ static int pxa310_ulpi_poll(void) | |||
79 | return -ETIMEDOUT; | 79 | return -ETIMEDOUT; |
80 | } | 80 | } |
81 | 81 | ||
82 | static int pxa310_ulpi_read(struct otg_transceiver *otg, u32 reg) | 82 | static int pxa310_ulpi_read(struct usb_phy *otg, u32 reg) |
83 | { | 83 | { |
84 | int err; | 84 | int err; |
85 | 85 | ||
@@ -98,7 +98,7 @@ static int pxa310_ulpi_read(struct otg_transceiver *otg, u32 reg) | |||
98 | return u2d_readl(U2DOTGUCR) & U2DOTGUCR_RDATA; | 98 | return u2d_readl(U2DOTGUCR) & U2DOTGUCR_RDATA; |
99 | } | 99 | } |
100 | 100 | ||
101 | static int pxa310_ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | 101 | static int pxa310_ulpi_write(struct usb_phy *otg, u32 val, u32 reg) |
102 | { | 102 | { |
103 | if (pxa310_ulpi_get_phymode() != SYNCH) { | 103 | if (pxa310_ulpi_get_phymode() != SYNCH) { |
104 | pr_warning("%s: PHY is not in SYNCH mode!\n", __func__); | 104 | pr_warning("%s: PHY is not in SYNCH mode!\n", __func__); |
@@ -111,7 +111,7 @@ static int pxa310_ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | |||
111 | return pxa310_ulpi_poll(); | 111 | return pxa310_ulpi_poll(); |
112 | } | 112 | } |
113 | 113 | ||
114 | struct otg_io_access_ops pxa310_ulpi_access_ops = { | 114 | struct usb_phy_io_ops pxa310_ulpi_access_ops = { |
115 | .read = pxa310_ulpi_read, | 115 | .read = pxa310_ulpi_read, |
116 | .write = pxa310_ulpi_write, | 116 | .write = pxa310_ulpi_write, |
117 | }; | 117 | }; |
@@ -139,19 +139,19 @@ static int pxa310_start_otg_host_transcvr(struct usb_bus *host) | |||
139 | 139 | ||
140 | pxa310_otg_transceiver_rtsm(); | 140 | pxa310_otg_transceiver_rtsm(); |
141 | 141 | ||
142 | err = otg_init(u2d->otg); | 142 | err = usb_phy_init(u2d->otg); |
143 | if (err) { | 143 | if (err) { |
144 | pr_err("OTG transceiver init failed"); | 144 | pr_err("OTG transceiver init failed"); |
145 | return err; | 145 | return err; |
146 | } | 146 | } |
147 | 147 | ||
148 | err = otg_set_vbus(u2d->otg, 1); | 148 | err = otg_set_vbus(u2d->otg->otg, 1); |
149 | if (err) { | 149 | if (err) { |
150 | pr_err("OTG transceiver VBUS set failed"); | 150 | pr_err("OTG transceiver VBUS set failed"); |
151 | return err; | 151 | return err; |
152 | } | 152 | } |
153 | 153 | ||
154 | err = otg_set_host(u2d->otg, host); | 154 | err = otg_set_host(u2d->otg->otg, host); |
155 | if (err) | 155 | if (err) |
156 | pr_err("OTG transceiver Host mode set failed"); | 156 | pr_err("OTG transceiver Host mode set failed"); |
157 | 157 | ||
@@ -189,9 +189,9 @@ static void pxa310_stop_otg_hc(void) | |||
189 | { | 189 | { |
190 | pxa310_otg_transceiver_rtsm(); | 190 | pxa310_otg_transceiver_rtsm(); |
191 | 191 | ||
192 | otg_set_host(u2d->otg, NULL); | 192 | otg_set_host(u2d->otg->otg, NULL); |
193 | otg_set_vbus(u2d->otg, 0); | 193 | otg_set_vbus(u2d->otg->otg, 0); |
194 | otg_shutdown(u2d->otg); | 194 | usb_phy_shutdown(u2d->otg); |
195 | } | 195 | } |
196 | 196 | ||
197 | static void pxa310_u2d_setup_otg_hc(void) | 197 | static void pxa310_u2d_setup_otg_hc(void) |
diff --git a/arch/arm/mach-tegra/include/mach/usb_phy.h b/arch/arm/mach-tegra/include/mach/usb_phy.h index d4b8f9e298a8..de1a0f602b28 100644 --- a/arch/arm/mach-tegra/include/mach/usb_phy.h +++ b/arch/arm/mach-tegra/include/mach/usb_phy.h | |||
@@ -58,7 +58,7 @@ struct tegra_usb_phy { | |||
58 | struct clk *pad_clk; | 58 | struct clk *pad_clk; |
59 | enum tegra_usb_phy_mode mode; | 59 | enum tegra_usb_phy_mode mode; |
60 | void *config; | 60 | void *config; |
61 | struct otg_transceiver *ulpi; | 61 | struct usb_phy *ulpi; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | struct tegra_usb_phy *tegra_usb_phy_open(int instance, void __iomem *regs, | 64 | struct tegra_usb_phy *tegra_usb_phy_open(int instance, void __iomem *regs, |
diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c index 37576a721aeb..ad321f9e2bb8 100644 --- a/arch/arm/mach-tegra/usb_phy.c +++ b/arch/arm/mach-tegra/usb_phy.c | |||
@@ -608,13 +608,13 @@ static int ulpi_phy_power_on(struct tegra_usb_phy *phy) | |||
608 | writel(val, base + ULPI_TIMING_CTRL_1); | 608 | writel(val, base + ULPI_TIMING_CTRL_1); |
609 | 609 | ||
610 | /* Fix VbusInvalid due to floating VBUS */ | 610 | /* Fix VbusInvalid due to floating VBUS */ |
611 | ret = otg_io_write(phy->ulpi, 0x40, 0x08); | 611 | ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08); |
612 | if (ret) { | 612 | if (ret) { |
613 | pr_err("%s: ulpi write failed\n", __func__); | 613 | pr_err("%s: ulpi write failed\n", __func__); |
614 | return ret; | 614 | return ret; |
615 | } | 615 | } |
616 | 616 | ||
617 | ret = otg_io_write(phy->ulpi, 0x80, 0x0B); | 617 | ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B); |
618 | if (ret) { | 618 | if (ret) { |
619 | pr_err("%s: ulpi write failed\n", __func__); | 619 | pr_err("%s: ulpi write failed\n", __func__); |
620 | return ret; | 620 | return ret; |
diff --git a/arch/arm/plat-mxc/include/mach/mxc_ehci.h b/arch/arm/plat-mxc/include/mach/mxc_ehci.h index 2c159dc2398b..9ffd1bbe615f 100644 --- a/arch/arm/plat-mxc/include/mach/mxc_ehci.h +++ b/arch/arm/plat-mxc/include/mach/mxc_ehci.h | |||
@@ -44,7 +44,7 @@ struct mxc_usbh_platform_data { | |||
44 | int (*exit)(struct platform_device *pdev); | 44 | int (*exit)(struct platform_device *pdev); |
45 | 45 | ||
46 | unsigned int portsc; | 46 | unsigned int portsc; |
47 | struct otg_transceiver *otg; | 47 | struct usb_phy *otg; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | int mx51_initialize_usb_hw(int port, unsigned int flags); | 50 | int mx51_initialize_usb_hw(int port, unsigned int flags); |
diff --git a/arch/arm/plat-mxc/include/mach/ulpi.h b/arch/arm/plat-mxc/include/mach/ulpi.h index f9161c96d7bd..42bdaca6d7d9 100644 --- a/arch/arm/plat-mxc/include/mach/ulpi.h +++ b/arch/arm/plat-mxc/include/mach/ulpi.h | |||
@@ -2,15 +2,15 @@ | |||
2 | #define __MACH_ULPI_H | 2 | #define __MACH_ULPI_H |
3 | 3 | ||
4 | #ifdef CONFIG_USB_ULPI | 4 | #ifdef CONFIG_USB_ULPI |
5 | struct otg_transceiver *imx_otg_ulpi_create(unsigned int flags); | 5 | struct usb_phy *imx_otg_ulpi_create(unsigned int flags); |
6 | #else | 6 | #else |
7 | static inline struct otg_transceiver *imx_otg_ulpi_create(unsigned int flags) | 7 | static inline struct usb_phy *imx_otg_ulpi_create(unsigned int flags) |
8 | { | 8 | { |
9 | return NULL; | 9 | return NULL; |
10 | } | 10 | } |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | extern struct otg_io_access_ops mxc_ulpi_access_ops; | 13 | extern struct usb_phy_io_ops mxc_ulpi_access_ops; |
14 | 14 | ||
15 | #endif /* __MACH_ULPI_H */ | 15 | #endif /* __MACH_ULPI_H */ |
16 | 16 | ||
diff --git a/arch/arm/plat-mxc/ulpi.c b/arch/arm/plat-mxc/ulpi.c index 477e45bea1be..d2963427184f 100644 --- a/arch/arm/plat-mxc/ulpi.c +++ b/arch/arm/plat-mxc/ulpi.c | |||
@@ -58,7 +58,7 @@ static int ulpi_poll(void __iomem *view, u32 bit) | |||
58 | return -ETIMEDOUT; | 58 | return -ETIMEDOUT; |
59 | } | 59 | } |
60 | 60 | ||
61 | static int ulpi_read(struct otg_transceiver *otg, u32 reg) | 61 | static int ulpi_read(struct usb_phy *otg, u32 reg) |
62 | { | 62 | { |
63 | int ret; | 63 | int ret; |
64 | void __iomem *view = otg->io_priv; | 64 | void __iomem *view = otg->io_priv; |
@@ -84,7 +84,7 @@ static int ulpi_read(struct otg_transceiver *otg, u32 reg) | |||
84 | return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK; | 84 | return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK; |
85 | } | 85 | } |
86 | 86 | ||
87 | static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | 87 | static int ulpi_write(struct usb_phy *otg, u32 val, u32 reg) |
88 | { | 88 | { |
89 | int ret; | 89 | int ret; |
90 | void __iomem *view = otg->io_priv; | 90 | void __iomem *view = otg->io_priv; |
@@ -106,13 +106,13 @@ static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | |||
106 | return ulpi_poll(view, ULPIVW_RUN); | 106 | return ulpi_poll(view, ULPIVW_RUN); |
107 | } | 107 | } |
108 | 108 | ||
109 | struct otg_io_access_ops mxc_ulpi_access_ops = { | 109 | struct usb_phy_io_ops mxc_ulpi_access_ops = { |
110 | .read = ulpi_read, | 110 | .read = ulpi_read, |
111 | .write = ulpi_write, | 111 | .write = ulpi_write, |
112 | }; | 112 | }; |
113 | EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops); | 113 | EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops); |
114 | 114 | ||
115 | struct otg_transceiver *imx_otg_ulpi_create(unsigned int flags) | 115 | struct usb_phy *imx_otg_ulpi_create(unsigned int flags) |
116 | { | 116 | { |
117 | return otg_ulpi_create(&mxc_ulpi_access_ops, flags); | 117 | return otg_ulpi_create(&mxc_ulpi_access_ops, flags); |
118 | } | 118 | } |
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c index 002d6d2afe04..36e9570e7bc4 100644 --- a/arch/mips/ath79/dev-usb.c +++ b/arch/mips/ath79/dev-usb.c | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/irq.h> | 17 | #include <linux/irq.h> |
18 | #include <linux/dma-mapping.h> | 18 | #include <linux/dma-mapping.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/usb/ehci_pdriver.h> | ||
21 | #include <linux/usb/ohci_pdriver.h> | ||
20 | 22 | ||
21 | #include <asm/mach-ath79/ath79.h> | 23 | #include <asm/mach-ath79/ath79.h> |
22 | #include <asm/mach-ath79/ar71xx_regs.h> | 24 | #include <asm/mach-ath79/ar71xx_regs.h> |
@@ -36,14 +38,19 @@ static struct resource ath79_ohci_resources[] = { | |||
36 | }; | 38 | }; |
37 | 39 | ||
38 | static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32); | 40 | static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32); |
41 | |||
42 | static struct usb_ohci_pdata ath79_ohci_pdata = { | ||
43 | }; | ||
44 | |||
39 | static struct platform_device ath79_ohci_device = { | 45 | static struct platform_device ath79_ohci_device = { |
40 | .name = "ath79-ohci", | 46 | .name = "ohci-platform", |
41 | .id = -1, | 47 | .id = -1, |
42 | .resource = ath79_ohci_resources, | 48 | .resource = ath79_ohci_resources, |
43 | .num_resources = ARRAY_SIZE(ath79_ohci_resources), | 49 | .num_resources = ARRAY_SIZE(ath79_ohci_resources), |
44 | .dev = { | 50 | .dev = { |
45 | .dma_mask = &ath79_ohci_dmamask, | 51 | .dma_mask = &ath79_ohci_dmamask, |
46 | .coherent_dma_mask = DMA_BIT_MASK(32), | 52 | .coherent_dma_mask = DMA_BIT_MASK(32), |
53 | .platform_data = &ath79_ohci_pdata, | ||
47 | }, | 54 | }, |
48 | }; | 55 | }; |
49 | 56 | ||
@@ -60,8 +67,20 @@ static struct resource ath79_ehci_resources[] = { | |||
60 | }; | 67 | }; |
61 | 68 | ||
62 | static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32); | 69 | static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32); |
70 | |||
71 | static struct usb_ehci_pdata ath79_ehci_pdata_v1 = { | ||
72 | .has_synopsys_hc_bug = 1, | ||
73 | .port_power_off = 1, | ||
74 | }; | ||
75 | |||
76 | static struct usb_ehci_pdata ath79_ehci_pdata_v2 = { | ||
77 | .caps_offset = 0x100, | ||
78 | .has_tt = 1, | ||
79 | .port_power_off = 1, | ||
80 | }; | ||
81 | |||
63 | static struct platform_device ath79_ehci_device = { | 82 | static struct platform_device ath79_ehci_device = { |
64 | .name = "ath79-ehci", | 83 | .name = "ehci-platform", |
65 | .id = -1, | 84 | .id = -1, |
66 | .resource = ath79_ehci_resources, | 85 | .resource = ath79_ehci_resources, |
67 | .num_resources = ARRAY_SIZE(ath79_ehci_resources), | 86 | .num_resources = ARRAY_SIZE(ath79_ehci_resources), |
@@ -101,7 +120,7 @@ static void __init ath79_usb_setup(void) | |||
101 | 120 | ||
102 | ath79_ehci_resources[0].start = AR71XX_EHCI_BASE; | 121 | ath79_ehci_resources[0].start = AR71XX_EHCI_BASE; |
103 | ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1; | 122 | ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1; |
104 | ath79_ehci_device.name = "ar71xx-ehci"; | 123 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1; |
105 | platform_device_register(&ath79_ehci_device); | 124 | platform_device_register(&ath79_ehci_device); |
106 | } | 125 | } |
107 | 126 | ||
@@ -142,7 +161,7 @@ static void __init ar724x_usb_setup(void) | |||
142 | 161 | ||
143 | ath79_ehci_resources[0].start = AR724X_EHCI_BASE; | 162 | ath79_ehci_resources[0].start = AR724X_EHCI_BASE; |
144 | ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1; | 163 | ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1; |
145 | ath79_ehci_device.name = "ar724x-ehci"; | 164 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; |
146 | platform_device_register(&ath79_ehci_device); | 165 | platform_device_register(&ath79_ehci_device); |
147 | } | 166 | } |
148 | 167 | ||
@@ -159,7 +178,7 @@ static void __init ar913x_usb_setup(void) | |||
159 | 178 | ||
160 | ath79_ehci_resources[0].start = AR913X_EHCI_BASE; | 179 | ath79_ehci_resources[0].start = AR913X_EHCI_BASE; |
161 | ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1; | 180 | ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1; |
162 | ath79_ehci_device.name = "ar913x-ehci"; | 181 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; |
163 | platform_device_register(&ath79_ehci_device); | 182 | platform_device_register(&ath79_ehci_device); |
164 | } | 183 | } |
165 | 184 | ||
@@ -176,7 +195,7 @@ static void __init ar933x_usb_setup(void) | |||
176 | 195 | ||
177 | ath79_ehci_resources[0].start = AR933X_EHCI_BASE; | 196 | ath79_ehci_resources[0].start = AR933X_EHCI_BASE; |
178 | ath79_ehci_resources[0].end = AR933X_EHCI_BASE + AR933X_EHCI_SIZE - 1; | 197 | ath79_ehci_resources[0].end = AR933X_EHCI_BASE + AR933X_EHCI_SIZE - 1; |
179 | ath79_ehci_device.name = "ar933x-ehci"; | 198 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; |
180 | platform_device_register(&ath79_ehci_device); | 199 | platform_device_register(&ath79_ehci_device); |
181 | } | 200 | } |
182 | 201 | ||
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 4e4c8a4a5fd3..a796407123c7 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig | |||
@@ -354,7 +354,7 @@ config BLK_DEV_SX8 | |||
354 | Use devices /dev/sx8/$N and /dev/sx8/$Np$M. | 354 | Use devices /dev/sx8/$N and /dev/sx8/$Np$M. |
355 | 355 | ||
356 | config BLK_DEV_UB | 356 | config BLK_DEV_UB |
357 | tristate "Low Performance USB Block driver" | 357 | tristate "Low Performance USB Block driver (deprecated)" |
358 | depends on USB | 358 | depends on USB |
359 | help | 359 | help |
360 | This driver supports certain USB attached storage devices | 360 | This driver supports certain USB attached storage devices |
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index 7333b9e44411..fcec0225ac76 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -119,43 +119,6 @@ | |||
119 | 119 | ||
120 | /* | 120 | /* |
121 | */ | 121 | */ |
122 | |||
123 | /* command block wrapper */ | ||
124 | struct bulk_cb_wrap { | ||
125 | __le32 Signature; /* contains 'USBC' */ | ||
126 | u32 Tag; /* unique per command id */ | ||
127 | __le32 DataTransferLength; /* size of data */ | ||
128 | u8 Flags; /* direction in bit 0 */ | ||
129 | u8 Lun; /* LUN */ | ||
130 | u8 Length; /* of of the CDB */ | ||
131 | u8 CDB[UB_MAX_CDB_SIZE]; /* max command */ | ||
132 | }; | ||
133 | |||
134 | #define US_BULK_CB_WRAP_LEN 31 | ||
135 | #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */ | ||
136 | #define US_BULK_FLAG_IN 1 | ||
137 | #define US_BULK_FLAG_OUT 0 | ||
138 | |||
139 | /* command status wrapper */ | ||
140 | struct bulk_cs_wrap { | ||
141 | __le32 Signature; /* should = 'USBS' */ | ||
142 | u32 Tag; /* same as original command */ | ||
143 | __le32 Residue; /* amount not transferred */ | ||
144 | u8 Status; /* see below */ | ||
145 | }; | ||
146 | |||
147 | #define US_BULK_CS_WRAP_LEN 13 | ||
148 | #define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */ | ||
149 | #define US_BULK_STAT_OK 0 | ||
150 | #define US_BULK_STAT_FAIL 1 | ||
151 | #define US_BULK_STAT_PHASE 2 | ||
152 | |||
153 | /* bulk-only class specific requests */ | ||
154 | #define US_BULK_RESET_REQUEST 0xff | ||
155 | #define US_BULK_GET_MAX_LUN 0xfe | ||
156 | |||
157 | /* | ||
158 | */ | ||
159 | struct ub_dev; | 122 | struct ub_dev; |
160 | 123 | ||
161 | #define UB_MAX_REQ_SG 9 /* cdrecord requires 32KB and maybe a header */ | 124 | #define UB_MAX_REQ_SG 9 /* cdrecord requires 32KB and maybe a header */ |
@@ -2477,6 +2440,8 @@ static int __init ub_init(void) | |||
2477 | int rc; | 2440 | int rc; |
2478 | int i; | 2441 | int i; |
2479 | 2442 | ||
2443 | pr_info("'Low Performance USB Block' driver is deprecated. " | ||
2444 | "Please switch to usb-storage\n"); | ||
2480 | for (i = 0; i < UB_QLOCK_NUM; i++) | 2445 | for (i = 0; i < UB_QLOCK_NUM; i++) |
2481 | spin_lock_init(&ub_qlockv[i]); | 2446 | spin_lock_init(&ub_qlockv[i]); |
2482 | 2447 | ||
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig index 233576127934..4bad899fb38f 100644 --- a/drivers/net/usb/Kconfig +++ b/drivers/net/usb/Kconfig | |||
@@ -398,6 +398,27 @@ config USB_NET_KALMIA | |||
398 | To compile this driver as a module, choose M here: the | 398 | To compile this driver as a module, choose M here: the |
399 | module will be called kalmia. | 399 | module will be called kalmia. |
400 | 400 | ||
401 | config USB_NET_QMI_WWAN | ||
402 | tristate "QMI WWAN driver for Qualcomm MSM based 3G and LTE modems" | ||
403 | depends on USB_USBNET | ||
404 | help | ||
405 | Support WWAN LTE/3G devices based on Qualcomm Mobile Data Modem | ||
406 | (MDM) chipsets. Examples of such devices are | ||
407 | * Huawei E392/E398 | ||
408 | |||
409 | This driver will only drive the ethernet part of the chips. | ||
410 | The devices require additional configuration to be usable. | ||
411 | Multiple management interfaces with linux drivers are | ||
412 | available: | ||
413 | |||
414 | * option: AT commands on /dev/ttyUSBx | ||
415 | * cdc-wdm: Qualcomm MSM Interface (QMI) protocol on /dev/cdc-wdmx | ||
416 | |||
417 | A modem manager with support for QMI is recommended. | ||
418 | |||
419 | To compile this driver as a module, choose M here: the | ||
420 | module will be called qmi_wwan. | ||
421 | |||
401 | config USB_HSO | 422 | config USB_HSO |
402 | tristate "Option USB High Speed Mobile Devices" | 423 | tristate "Option USB High Speed Mobile Devices" |
403 | depends on USB && RFKILL | 424 | depends on USB && RFKILL |
@@ -461,4 +482,5 @@ config USB_VL600 | |||
461 | 482 | ||
462 | http://ubuntuforums.org/showpost.php?p=10589647&postcount=17 | 483 | http://ubuntuforums.org/showpost.php?p=10589647&postcount=17 |
463 | 484 | ||
485 | |||
464 | endmenu | 486 | endmenu |
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile index c203fa21f6b1..a2e2d72c52a0 100644 --- a/drivers/net/usb/Makefile +++ b/drivers/net/usb/Makefile | |||
@@ -29,4 +29,5 @@ obj-$(CONFIG_USB_SIERRA_NET) += sierra_net.o | |||
29 | obj-$(CONFIG_USB_NET_CX82310_ETH) += cx82310_eth.o | 29 | obj-$(CONFIG_USB_NET_CX82310_ETH) += cx82310_eth.o |
30 | obj-$(CONFIG_USB_NET_CDC_NCM) += cdc_ncm.o | 30 | obj-$(CONFIG_USB_NET_CDC_NCM) += cdc_ncm.o |
31 | obj-$(CONFIG_USB_VL600) += lg-vl600.o | 31 | obj-$(CONFIG_USB_VL600) += lg-vl600.o |
32 | obj-$(CONFIG_USB_NET_QMI_WWAN) += qmi_wwan.o | ||
32 | 33 | ||
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c new file mode 100644 index 000000000000..aac68f5195c0 --- /dev/null +++ b/drivers/net/usb/qmi_wwan.c | |||
@@ -0,0 +1,478 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * version 2 as published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/netdevice.h> | ||
11 | #include <linux/ethtool.h> | ||
12 | #include <linux/mii.h> | ||
13 | #include <linux/usb.h> | ||
14 | #include <linux/usb/cdc.h> | ||
15 | #include <linux/usb/usbnet.h> | ||
16 | #include <linux/usb/cdc-wdm.h> | ||
17 | |||
18 | /* The name of the CDC Device Management driver */ | ||
19 | #define DM_DRIVER "cdc_wdm" | ||
20 | |||
21 | /* | ||
22 | * This driver supports wwan (3G/LTE/?) devices using a vendor | ||
23 | * specific management protocol called Qualcomm MSM Interface (QMI) - | ||
24 | * in addition to the more common AT commands over serial interface | ||
25 | * management | ||
26 | * | ||
27 | * QMI is wrapped in CDC, using CDC encapsulated commands on the | ||
28 | * control ("master") interface of a two-interface CDC Union | ||
29 | * resembling standard CDC ECM. The devices do not use the control | ||
30 | * interface for any other CDC messages. Most likely because the | ||
31 | * management protocol is used in place of the standard CDC | ||
32 | * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE | ||
33 | * | ||
34 | * Handling a protocol like QMI is out of the scope for any driver. | ||
35 | * It can be exported as a character device using the cdc-wdm driver, | ||
36 | * which will enable userspace applications ("modem managers") to | ||
37 | * handle it. This may be required to use the network interface | ||
38 | * provided by the driver. | ||
39 | * | ||
40 | * These devices may alternatively/additionally be configured using AT | ||
41 | * commands on any of the serial interfaces driven by the option driver | ||
42 | * | ||
43 | * This driver binds only to the data ("slave") interface to enable | ||
44 | * the cdc-wdm driver to bind to the control interface. It still | ||
45 | * parses the CDC functional descriptors on the control interface to | ||
46 | * a) verify that this is indeed a handled interface (CDC Union | ||
47 | * header lists it as slave) | ||
48 | * b) get MAC address and other ethernet config from the CDC Ethernet | ||
49 | * header | ||
50 | * c) enable user bind requests against the control interface, which | ||
51 | * is the common way to bind to CDC Ethernet Control Model type | ||
52 | * interfaces | ||
53 | * d) provide a hint to the user about which interface is the | ||
54 | * corresponding management interface | ||
55 | */ | ||
56 | |||
57 | static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) | ||
58 | { | ||
59 | int status = -1; | ||
60 | struct usb_interface *control = NULL; | ||
61 | u8 *buf = intf->cur_altsetting->extra; | ||
62 | int len = intf->cur_altsetting->extralen; | ||
63 | struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc; | ||
64 | struct usb_cdc_union_desc *cdc_union = NULL; | ||
65 | struct usb_cdc_ether_desc *cdc_ether = NULL; | ||
66 | u32 required = 1 << USB_CDC_HEADER_TYPE | 1 << USB_CDC_UNION_TYPE; | ||
67 | u32 found = 0; | ||
68 | atomic_t *pmcount = (void *)&dev->data[1]; | ||
69 | |||
70 | atomic_set(pmcount, 0); | ||
71 | |||
72 | /* | ||
73 | * assume a data interface has no additional descriptors and | ||
74 | * that the control and data interface are numbered | ||
75 | * consecutively - this holds for the Huawei device at least | ||
76 | */ | ||
77 | if (len == 0 && desc->bInterfaceNumber > 0) { | ||
78 | control = usb_ifnum_to_if(dev->udev, desc->bInterfaceNumber - 1); | ||
79 | if (!control) | ||
80 | goto err; | ||
81 | |||
82 | buf = control->cur_altsetting->extra; | ||
83 | len = control->cur_altsetting->extralen; | ||
84 | dev_dbg(&intf->dev, "guessing \"control\" => %s, \"data\" => this\n", | ||
85 | dev_name(&control->dev)); | ||
86 | } | ||
87 | |||
88 | while (len > 3) { | ||
89 | struct usb_descriptor_header *h = (void *)buf; | ||
90 | |||
91 | /* ignore any misplaced descriptors */ | ||
92 | if (h->bDescriptorType != USB_DT_CS_INTERFACE) | ||
93 | goto next_desc; | ||
94 | |||
95 | /* buf[2] is CDC descriptor subtype */ | ||
96 | switch (buf[2]) { | ||
97 | case USB_CDC_HEADER_TYPE: | ||
98 | if (found & 1 << USB_CDC_HEADER_TYPE) { | ||
99 | dev_dbg(&intf->dev, "extra CDC header\n"); | ||
100 | goto err; | ||
101 | } | ||
102 | if (h->bLength != sizeof(struct usb_cdc_header_desc)) { | ||
103 | dev_dbg(&intf->dev, "CDC header len %u\n", h->bLength); | ||
104 | goto err; | ||
105 | } | ||
106 | break; | ||
107 | case USB_CDC_UNION_TYPE: | ||
108 | if (found & 1 << USB_CDC_UNION_TYPE) { | ||
109 | dev_dbg(&intf->dev, "extra CDC union\n"); | ||
110 | goto err; | ||
111 | } | ||
112 | if (h->bLength != sizeof(struct usb_cdc_union_desc)) { | ||
113 | dev_dbg(&intf->dev, "CDC union len %u\n", h->bLength); | ||
114 | goto err; | ||
115 | } | ||
116 | cdc_union = (struct usb_cdc_union_desc *)buf; | ||
117 | break; | ||
118 | case USB_CDC_ETHERNET_TYPE: | ||
119 | if (found & 1 << USB_CDC_ETHERNET_TYPE) { | ||
120 | dev_dbg(&intf->dev, "extra CDC ether\n"); | ||
121 | goto err; | ||
122 | } | ||
123 | if (h->bLength != sizeof(struct usb_cdc_ether_desc)) { | ||
124 | dev_dbg(&intf->dev, "CDC ether len %u\n", h->bLength); | ||
125 | goto err; | ||
126 | } | ||
127 | cdc_ether = (struct usb_cdc_ether_desc *)buf; | ||
128 | break; | ||
129 | } | ||
130 | |||
131 | /* | ||
132 | * Remember which CDC functional descriptors we've seen. Works | ||
133 | * for all types we care about, of which USB_CDC_ETHERNET_TYPE | ||
134 | * (0x0f) is the highest numbered | ||
135 | */ | ||
136 | if (buf[2] < 32) | ||
137 | found |= 1 << buf[2]; | ||
138 | |||
139 | next_desc: | ||
140 | len -= h->bLength; | ||
141 | buf += h->bLength; | ||
142 | } | ||
143 | |||
144 | /* did we find all the required ones? */ | ||
145 | if ((found & required) != required) { | ||
146 | dev_err(&intf->dev, "CDC functional descriptors missing\n"); | ||
147 | goto err; | ||
148 | } | ||
149 | |||
150 | /* give the user a helpful hint if trying to bind to the wrong interface */ | ||
151 | if (cdc_union && desc->bInterfaceNumber == cdc_union->bMasterInterface0) { | ||
152 | dev_err(&intf->dev, "leaving \"control\" interface for " DM_DRIVER " - try binding to %s instead!\n", | ||
153 | dev_name(&usb_ifnum_to_if(dev->udev, cdc_union->bSlaveInterface0)->dev)); | ||
154 | goto err; | ||
155 | } | ||
156 | |||
157 | /* errors aren't fatal - we can live with the dynamic address */ | ||
158 | if (cdc_ether) { | ||
159 | dev->hard_mtu = le16_to_cpu(cdc_ether->wMaxSegmentSize); | ||
160 | usbnet_get_ethernet_addr(dev, cdc_ether->iMACAddress); | ||
161 | } | ||
162 | |||
163 | /* success! point the user to the management interface */ | ||
164 | if (control) | ||
165 | dev_info(&intf->dev, "Use \"" DM_DRIVER "\" for QMI interface %s\n", | ||
166 | dev_name(&control->dev)); | ||
167 | |||
168 | /* XXX: add a sysfs symlink somewhere to help management applications find it? */ | ||
169 | |||
170 | /* collect bulk endpoints now that we know intf == "data" interface */ | ||
171 | status = usbnet_get_endpoints(dev, intf); | ||
172 | |||
173 | err: | ||
174 | return status; | ||
175 | } | ||
176 | |||
177 | /* using a counter to merge subdriver requests with our own into a combined state */ | ||
178 | static int qmi_wwan_manage_power(struct usbnet *dev, int on) | ||
179 | { | ||
180 | atomic_t *pmcount = (void *)&dev->data[1]; | ||
181 | int rv = 0; | ||
182 | |||
183 | dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, atomic_read(pmcount), on); | ||
184 | |||
185 | if ((on && atomic_add_return(1, pmcount) == 1) || (!on && atomic_dec_and_test(pmcount))) { | ||
186 | /* need autopm_get/put here to ensure the usbcore sees the new value */ | ||
187 | rv = usb_autopm_get_interface(dev->intf); | ||
188 | if (rv < 0) | ||
189 | goto err; | ||
190 | dev->intf->needs_remote_wakeup = on; | ||
191 | usb_autopm_put_interface(dev->intf); | ||
192 | } | ||
193 | err: | ||
194 | return rv; | ||
195 | } | ||
196 | |||
197 | static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on) | ||
198 | { | ||
199 | struct usbnet *dev = usb_get_intfdata(intf); | ||
200 | return qmi_wwan_manage_power(dev, on); | ||
201 | } | ||
202 | |||
203 | /* Some devices combine the "control" and "data" functions into a | ||
204 | * single interface with all three endpoints: interrupt + bulk in and | ||
205 | * out | ||
206 | * | ||
207 | * Setting up cdc-wdm as a subdriver owning the interrupt endpoint | ||
208 | * will let it provide userspace access to the encapsulated QMI | ||
209 | * protocol without interfering with the usbnet operations. | ||
210 | */ | ||
211 | static int qmi_wwan_bind_shared(struct usbnet *dev, struct usb_interface *intf) | ||
212 | { | ||
213 | int rv; | ||
214 | struct usb_driver *subdriver = NULL; | ||
215 | atomic_t *pmcount = (void *)&dev->data[1]; | ||
216 | |||
217 | /* ZTE makes devices where the interface descriptors and endpoint | ||
218 | * configurations of two or more interfaces are identical, even | ||
219 | * though the functions are completely different. If set, then | ||
220 | * driver_info->data is a bitmap of acceptable interface numbers | ||
221 | * allowing us to bind to one such interface without binding to | ||
222 | * all of them | ||
223 | */ | ||
224 | if (dev->driver_info->data && | ||
225 | !test_bit(intf->cur_altsetting->desc.bInterfaceNumber, &dev->driver_info->data)) { | ||
226 | dev_info(&intf->dev, "not on our whitelist - ignored"); | ||
227 | rv = -ENODEV; | ||
228 | goto err; | ||
229 | } | ||
230 | |||
231 | atomic_set(pmcount, 0); | ||
232 | |||
233 | /* collect all three endpoints */ | ||
234 | rv = usbnet_get_endpoints(dev, intf); | ||
235 | if (rv < 0) | ||
236 | goto err; | ||
237 | |||
238 | /* require interrupt endpoint for subdriver */ | ||
239 | if (!dev->status) { | ||
240 | rv = -EINVAL; | ||
241 | goto err; | ||
242 | } | ||
243 | |||
244 | subdriver = usb_cdc_wdm_register(intf, &dev->status->desc, 512, &qmi_wwan_cdc_wdm_manage_power); | ||
245 | if (IS_ERR(subdriver)) { | ||
246 | rv = PTR_ERR(subdriver); | ||
247 | goto err; | ||
248 | } | ||
249 | |||
250 | /* can't let usbnet use the interrupt endpoint */ | ||
251 | dev->status = NULL; | ||
252 | |||
253 | /* save subdriver struct for suspend/resume wrappers */ | ||
254 | dev->data[0] = (unsigned long)subdriver; | ||
255 | |||
256 | err: | ||
257 | return rv; | ||
258 | } | ||
259 | |||
260 | /* Gobi devices uses identical class/protocol codes for all interfaces regardless | ||
261 | * of function. Some of these are CDC ACM like and have the exact same endpoints | ||
262 | * we are looking for. This leaves two possible strategies for identifying the | ||
263 | * correct interface: | ||
264 | * a) hardcoding interface number, or | ||
265 | * b) use the fact that the wwan interface is the only one lacking additional | ||
266 | * (CDC functional) descriptors | ||
267 | * | ||
268 | * Let's see if we can get away with the generic b) solution. | ||
269 | */ | ||
270 | static int qmi_wwan_bind_gobi(struct usbnet *dev, struct usb_interface *intf) | ||
271 | { | ||
272 | int rv = -EINVAL; | ||
273 | |||
274 | /* ignore any interface with additional descriptors */ | ||
275 | if (intf->cur_altsetting->extralen) | ||
276 | goto err; | ||
277 | |||
278 | rv = qmi_wwan_bind_shared(dev, intf); | ||
279 | err: | ||
280 | return rv; | ||
281 | } | ||
282 | |||
283 | static void qmi_wwan_unbind_shared(struct usbnet *dev, struct usb_interface *intf) | ||
284 | { | ||
285 | struct usb_driver *subdriver = (void *)dev->data[0]; | ||
286 | |||
287 | if (subdriver && subdriver->disconnect) | ||
288 | subdriver->disconnect(intf); | ||
289 | |||
290 | dev->data[0] = (unsigned long)NULL; | ||
291 | } | ||
292 | |||
293 | /* suspend/resume wrappers calling both usbnet and the cdc-wdm | ||
294 | * subdriver if present. | ||
295 | * | ||
296 | * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide | ||
297 | * wrappers for those without adding usbnet reset support first. | ||
298 | */ | ||
299 | static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message) | ||
300 | { | ||
301 | struct usbnet *dev = usb_get_intfdata(intf); | ||
302 | struct usb_driver *subdriver = (void *)dev->data[0]; | ||
303 | int ret; | ||
304 | |||
305 | ret = usbnet_suspend(intf, message); | ||
306 | if (ret < 0) | ||
307 | goto err; | ||
308 | |||
309 | if (subdriver && subdriver->suspend) | ||
310 | ret = subdriver->suspend(intf, message); | ||
311 | if (ret < 0) | ||
312 | usbnet_resume(intf); | ||
313 | err: | ||
314 | return ret; | ||
315 | } | ||
316 | |||
317 | static int qmi_wwan_resume(struct usb_interface *intf) | ||
318 | { | ||
319 | struct usbnet *dev = usb_get_intfdata(intf); | ||
320 | struct usb_driver *subdriver = (void *)dev->data[0]; | ||
321 | int ret = 0; | ||
322 | |||
323 | if (subdriver && subdriver->resume) | ||
324 | ret = subdriver->resume(intf); | ||
325 | if (ret < 0) | ||
326 | goto err; | ||
327 | ret = usbnet_resume(intf); | ||
328 | if (ret < 0 && subdriver && subdriver->resume && subdriver->suspend) | ||
329 | subdriver->suspend(intf, PMSG_SUSPEND); | ||
330 | err: | ||
331 | return ret; | ||
332 | } | ||
333 | |||
334 | |||
335 | static const struct driver_info qmi_wwan_info = { | ||
336 | .description = "QMI speaking wwan device", | ||
337 | .flags = FLAG_WWAN, | ||
338 | .bind = qmi_wwan_bind, | ||
339 | .manage_power = qmi_wwan_manage_power, | ||
340 | }; | ||
341 | |||
342 | static const struct driver_info qmi_wwan_shared = { | ||
343 | .description = "QMI speaking wwan device with combined interface", | ||
344 | .flags = FLAG_WWAN, | ||
345 | .bind = qmi_wwan_bind_shared, | ||
346 | .unbind = qmi_wwan_unbind_shared, | ||
347 | .manage_power = qmi_wwan_manage_power, | ||
348 | }; | ||
349 | |||
350 | static const struct driver_info qmi_wwan_gobi = { | ||
351 | .description = "Qualcomm Gobi wwan/QMI device", | ||
352 | .flags = FLAG_WWAN, | ||
353 | .bind = qmi_wwan_bind_gobi, | ||
354 | .unbind = qmi_wwan_unbind_shared, | ||
355 | .manage_power = qmi_wwan_manage_power, | ||
356 | }; | ||
357 | |||
358 | /* ZTE suck at making USB descriptors */ | ||
359 | static const struct driver_info qmi_wwan_force_int4 = { | ||
360 | .description = "Qualcomm Gobi wwan/QMI device", | ||
361 | .flags = FLAG_WWAN, | ||
362 | .bind = qmi_wwan_bind_gobi, | ||
363 | .unbind = qmi_wwan_unbind_shared, | ||
364 | .manage_power = qmi_wwan_manage_power, | ||
365 | .data = BIT(4), /* interface whitelist bitmap */ | ||
366 | }; | ||
367 | |||
368 | |||
369 | #define HUAWEI_VENDOR_ID 0x12D1 | ||
370 | #define QMI_GOBI_DEVICE(vend, prod) \ | ||
371 | USB_DEVICE(vend, prod), \ | ||
372 | .driver_info = (unsigned long)&qmi_wwan_gobi | ||
373 | |||
374 | static const struct usb_device_id products[] = { | ||
375 | { /* Huawei E392, E398 and possibly others sharing both device id and more... */ | ||
376 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, | ||
377 | .idVendor = HUAWEI_VENDOR_ID, | ||
378 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
379 | .bInterfaceSubClass = 1, | ||
380 | .bInterfaceProtocol = 8, /* NOTE: This is the *slave* interface of the CDC Union! */ | ||
381 | .driver_info = (unsigned long)&qmi_wwan_info, | ||
382 | }, | ||
383 | { /* Huawei E392, E398 and possibly others in "Windows mode" | ||
384 | * using a combined control and data interface without any CDC | ||
385 | * functional descriptors | ||
386 | */ | ||
387 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, | ||
388 | .idVendor = HUAWEI_VENDOR_ID, | ||
389 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
390 | .bInterfaceSubClass = 1, | ||
391 | .bInterfaceProtocol = 17, | ||
392 | .driver_info = (unsigned long)&qmi_wwan_shared, | ||
393 | }, | ||
394 | { /* Pantech UML290 */ | ||
395 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, | ||
396 | .idVendor = 0x106c, | ||
397 | .idProduct = 0x3718, | ||
398 | .bInterfaceClass = 0xff, | ||
399 | .bInterfaceSubClass = 0xf0, | ||
400 | .bInterfaceProtocol = 0xff, | ||
401 | .driver_info = (unsigned long)&qmi_wwan_shared, | ||
402 | }, | ||
403 | { /* ZTE MF820D */ | ||
404 | .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO, | ||
405 | .idVendor = 0x19d2, | ||
406 | .idProduct = 0x0167, | ||
407 | .bInterfaceClass = 0xff, | ||
408 | .bInterfaceSubClass = 0xff, | ||
409 | .bInterfaceProtocol = 0xff, | ||
410 | .driver_info = (unsigned long)&qmi_wwan_force_int4, | ||
411 | }, | ||
412 | {QMI_GOBI_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ | ||
413 | {QMI_GOBI_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ | ||
414 | {QMI_GOBI_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */ | ||
415 | {QMI_GOBI_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */ | ||
416 | {QMI_GOBI_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */ | ||
417 | {QMI_GOBI_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */ | ||
418 | {QMI_GOBI_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */ | ||
419 | {QMI_GOBI_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */ | ||
420 | {QMI_GOBI_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */ | ||
421 | {QMI_GOBI_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */ | ||
422 | {QMI_GOBI_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */ | ||
423 | {QMI_GOBI_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */ | ||
424 | {QMI_GOBI_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */ | ||
425 | {QMI_GOBI_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */ | ||
426 | {QMI_GOBI_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */ | ||
427 | {QMI_GOBI_DEVICE(0x05c6, 0x920b)}, /* Generic Gobi 2000 Modem device */ | ||
428 | {QMI_GOBI_DEVICE(0x05c6, 0x9225)}, /* Sony Gobi 2000 Modem device (N0279, VU730) */ | ||
429 | {QMI_GOBI_DEVICE(0x05c6, 0x9245)}, /* Samsung Gobi 2000 Modem device (VL176) */ | ||
430 | {QMI_GOBI_DEVICE(0x03f0, 0x251d)}, /* HP Gobi 2000 Modem device (VP412) */ | ||
431 | {QMI_GOBI_DEVICE(0x05c6, 0x9215)}, /* Acer Gobi 2000 Modem device (VP413) */ | ||
432 | {QMI_GOBI_DEVICE(0x05c6, 0x9265)}, /* Asus Gobi 2000 Modem device (VR305) */ | ||
433 | {QMI_GOBI_DEVICE(0x05c6, 0x9235)}, /* Top Global Gobi 2000 Modem device (VR306) */ | ||
434 | {QMI_GOBI_DEVICE(0x05c6, 0x9275)}, /* iRex Technologies Gobi 2000 Modem device (VR307) */ | ||
435 | {QMI_GOBI_DEVICE(0x1199, 0x9001)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
436 | {QMI_GOBI_DEVICE(0x1199, 0x9002)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
437 | {QMI_GOBI_DEVICE(0x1199, 0x9003)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
438 | {QMI_GOBI_DEVICE(0x1199, 0x9004)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
439 | {QMI_GOBI_DEVICE(0x1199, 0x9005)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
440 | {QMI_GOBI_DEVICE(0x1199, 0x9006)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
441 | {QMI_GOBI_DEVICE(0x1199, 0x9007)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
442 | {QMI_GOBI_DEVICE(0x1199, 0x9008)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
443 | {QMI_GOBI_DEVICE(0x1199, 0x9009)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
444 | {QMI_GOBI_DEVICE(0x1199, 0x900a)}, /* Sierra Wireless Gobi 2000 Modem device (VT773) */ | ||
445 | {QMI_GOBI_DEVICE(0x1199, 0x9011)}, /* Sierra Wireless Gobi 2000 Modem device (MC8305) */ | ||
446 | {QMI_GOBI_DEVICE(0x16d8, 0x8002)}, /* CMDTech Gobi 2000 Modem device (VU922) */ | ||
447 | {QMI_GOBI_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */ | ||
448 | {QMI_GOBI_DEVICE(0x1199, 0x9013)}, /* Sierra Wireless Gobi 3000 Modem device (MC8355) */ | ||
449 | { } /* END */ | ||
450 | }; | ||
451 | MODULE_DEVICE_TABLE(usb, products); | ||
452 | |||
453 | static struct usb_driver qmi_wwan_driver = { | ||
454 | .name = "qmi_wwan", | ||
455 | .id_table = products, | ||
456 | .probe = usbnet_probe, | ||
457 | .disconnect = usbnet_disconnect, | ||
458 | .suspend = qmi_wwan_suspend, | ||
459 | .resume = qmi_wwan_resume, | ||
460 | .reset_resume = qmi_wwan_resume, | ||
461 | .supports_autosuspend = 1, | ||
462 | }; | ||
463 | |||
464 | static int __init qmi_wwan_init(void) | ||
465 | { | ||
466 | return usb_register(&qmi_wwan_driver); | ||
467 | } | ||
468 | module_init(qmi_wwan_init); | ||
469 | |||
470 | static void __exit qmi_wwan_exit(void) | ||
471 | { | ||
472 | usb_deregister(&qmi_wwan_driver); | ||
473 | } | ||
474 | module_exit(qmi_wwan_exit); | ||
475 | |||
476 | MODULE_AUTHOR("Bjørn Mork <bjorn@mork.no>"); | ||
477 | MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver"); | ||
478 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c index b806667b59ae..1289a5f790a1 100644 --- a/drivers/power/isp1704_charger.c +++ b/drivers/power/isp1704_charger.c | |||
@@ -56,7 +56,7 @@ static u16 isp170x_id[] = { | |||
56 | struct isp1704_charger { | 56 | struct isp1704_charger { |
57 | struct device *dev; | 57 | struct device *dev; |
58 | struct power_supply psy; | 58 | struct power_supply psy; |
59 | struct otg_transceiver *otg; | 59 | struct usb_phy *phy; |
60 | struct notifier_block nb; | 60 | struct notifier_block nb; |
61 | struct work_struct work; | 61 | struct work_struct work; |
62 | 62 | ||
@@ -71,6 +71,16 @@ struct isp1704_charger { | |||
71 | unsigned max_power; | 71 | unsigned max_power; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static inline int isp1704_read(struct isp1704_charger *isp, u32 reg) | ||
75 | { | ||
76 | return usb_phy_io_read(isp->phy, reg); | ||
77 | } | ||
78 | |||
79 | static inline int isp1704_write(struct isp1704_charger *isp, u32 val, u32 reg) | ||
80 | { | ||
81 | return usb_phy_io_write(isp->phy, val, reg); | ||
82 | } | ||
83 | |||
74 | /* | 84 | /* |
75 | * Disable/enable the power from the isp1704 if a function for it | 85 | * Disable/enable the power from the isp1704 if a function for it |
76 | * has been provided with platform data. | 86 | * has been provided with platform data. |
@@ -97,31 +107,31 @@ static inline int isp1704_charger_type(struct isp1704_charger *isp) | |||
97 | u8 otg_ctrl; | 107 | u8 otg_ctrl; |
98 | int type = POWER_SUPPLY_TYPE_USB_DCP; | 108 | int type = POWER_SUPPLY_TYPE_USB_DCP; |
99 | 109 | ||
100 | func_ctrl = otg_io_read(isp->otg, ULPI_FUNC_CTRL); | 110 | func_ctrl = isp1704_read(isp, ULPI_FUNC_CTRL); |
101 | otg_ctrl = otg_io_read(isp->otg, ULPI_OTG_CTRL); | 111 | otg_ctrl = isp1704_read(isp, ULPI_OTG_CTRL); |
102 | 112 | ||
103 | /* disable pulldowns */ | 113 | /* disable pulldowns */ |
104 | reg = ULPI_OTG_CTRL_DM_PULLDOWN | ULPI_OTG_CTRL_DP_PULLDOWN; | 114 | reg = ULPI_OTG_CTRL_DM_PULLDOWN | ULPI_OTG_CTRL_DP_PULLDOWN; |
105 | otg_io_write(isp->otg, ULPI_CLR(ULPI_OTG_CTRL), reg); | 115 | isp1704_write(isp, ULPI_CLR(ULPI_OTG_CTRL), reg); |
106 | 116 | ||
107 | /* full speed */ | 117 | /* full speed */ |
108 | otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), | 118 | isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL), |
109 | ULPI_FUNC_CTRL_XCVRSEL_MASK); | 119 | ULPI_FUNC_CTRL_XCVRSEL_MASK); |
110 | otg_io_write(isp->otg, ULPI_SET(ULPI_FUNC_CTRL), | 120 | isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL), |
111 | ULPI_FUNC_CTRL_FULL_SPEED); | 121 | ULPI_FUNC_CTRL_FULL_SPEED); |
112 | 122 | ||
113 | /* Enable strong pull-up on DP (1.5K) and reset */ | 123 | /* Enable strong pull-up on DP (1.5K) and reset */ |
114 | reg = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET; | 124 | reg = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET; |
115 | otg_io_write(isp->otg, ULPI_SET(ULPI_FUNC_CTRL), reg); | 125 | isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL), reg); |
116 | usleep_range(1000, 2000); | 126 | usleep_range(1000, 2000); |
117 | 127 | ||
118 | reg = otg_io_read(isp->otg, ULPI_DEBUG); | 128 | reg = isp1704_read(isp, ULPI_DEBUG); |
119 | if ((reg & 3) != 3) | 129 | if ((reg & 3) != 3) |
120 | type = POWER_SUPPLY_TYPE_USB_CDP; | 130 | type = POWER_SUPPLY_TYPE_USB_CDP; |
121 | 131 | ||
122 | /* recover original state */ | 132 | /* recover original state */ |
123 | otg_io_write(isp->otg, ULPI_FUNC_CTRL, func_ctrl); | 133 | isp1704_write(isp, ULPI_FUNC_CTRL, func_ctrl); |
124 | otg_io_write(isp->otg, ULPI_OTG_CTRL, otg_ctrl); | 134 | isp1704_write(isp, ULPI_OTG_CTRL, otg_ctrl); |
125 | 135 | ||
126 | return type; | 136 | return type; |
127 | } | 137 | } |
@@ -136,28 +146,28 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp) | |||
136 | u8 r; | 146 | u8 r; |
137 | 147 | ||
138 | /* Reset the transceiver */ | 148 | /* Reset the transceiver */ |
139 | r = otg_io_read(isp->otg, ULPI_FUNC_CTRL); | 149 | r = isp1704_read(isp, ULPI_FUNC_CTRL); |
140 | r |= ULPI_FUNC_CTRL_RESET; | 150 | r |= ULPI_FUNC_CTRL_RESET; |
141 | otg_io_write(isp->otg, ULPI_FUNC_CTRL, r); | 151 | isp1704_write(isp, ULPI_FUNC_CTRL, r); |
142 | usleep_range(1000, 2000); | 152 | usleep_range(1000, 2000); |
143 | 153 | ||
144 | /* Set normal mode */ | 154 | /* Set normal mode */ |
145 | r &= ~(ULPI_FUNC_CTRL_RESET | ULPI_FUNC_CTRL_OPMODE_MASK); | 155 | r &= ~(ULPI_FUNC_CTRL_RESET | ULPI_FUNC_CTRL_OPMODE_MASK); |
146 | otg_io_write(isp->otg, ULPI_FUNC_CTRL, r); | 156 | isp1704_write(isp, ULPI_FUNC_CTRL, r); |
147 | 157 | ||
148 | /* Clear the DP and DM pull-down bits */ | 158 | /* Clear the DP and DM pull-down bits */ |
149 | r = ULPI_OTG_CTRL_DP_PULLDOWN | ULPI_OTG_CTRL_DM_PULLDOWN; | 159 | r = ULPI_OTG_CTRL_DP_PULLDOWN | ULPI_OTG_CTRL_DM_PULLDOWN; |
150 | otg_io_write(isp->otg, ULPI_CLR(ULPI_OTG_CTRL), r); | 160 | isp1704_write(isp, ULPI_CLR(ULPI_OTG_CTRL), r); |
151 | 161 | ||
152 | /* Enable strong pull-up on DP (1.5K) and reset */ | 162 | /* Enable strong pull-up on DP (1.5K) and reset */ |
153 | r = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET; | 163 | r = ULPI_FUNC_CTRL_TERMSELECT | ULPI_FUNC_CTRL_RESET; |
154 | otg_io_write(isp->otg, ULPI_SET(ULPI_FUNC_CTRL), r); | 164 | isp1704_write(isp, ULPI_SET(ULPI_FUNC_CTRL), r); |
155 | usleep_range(1000, 2000); | 165 | usleep_range(1000, 2000); |
156 | 166 | ||
157 | /* Read the line state */ | 167 | /* Read the line state */ |
158 | if (!otg_io_read(isp->otg, ULPI_DEBUG)) { | 168 | if (!isp1704_read(isp, ULPI_DEBUG)) { |
159 | /* Disable strong pull-up on DP (1.5K) */ | 169 | /* Disable strong pull-up on DP (1.5K) */ |
160 | otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), | 170 | isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL), |
161 | ULPI_FUNC_CTRL_TERMSELECT); | 171 | ULPI_FUNC_CTRL_TERMSELECT); |
162 | return 1; | 172 | return 1; |
163 | } | 173 | } |
@@ -165,23 +175,23 @@ static inline int isp1704_charger_verify(struct isp1704_charger *isp) | |||
165 | /* Is it a charger or PS/2 connection */ | 175 | /* Is it a charger or PS/2 connection */ |
166 | 176 | ||
167 | /* Enable weak pull-up resistor on DP */ | 177 | /* Enable weak pull-up resistor on DP */ |
168 | otg_io_write(isp->otg, ULPI_SET(ISP1704_PWR_CTRL), | 178 | isp1704_write(isp, ULPI_SET(ISP1704_PWR_CTRL), |
169 | ISP1704_PWR_CTRL_DP_WKPU_EN); | 179 | ISP1704_PWR_CTRL_DP_WKPU_EN); |
170 | 180 | ||
171 | /* Disable strong pull-up on DP (1.5K) */ | 181 | /* Disable strong pull-up on DP (1.5K) */ |
172 | otg_io_write(isp->otg, ULPI_CLR(ULPI_FUNC_CTRL), | 182 | isp1704_write(isp, ULPI_CLR(ULPI_FUNC_CTRL), |
173 | ULPI_FUNC_CTRL_TERMSELECT); | 183 | ULPI_FUNC_CTRL_TERMSELECT); |
174 | 184 | ||
175 | /* Enable weak pull-down resistor on DM */ | 185 | /* Enable weak pull-down resistor on DM */ |
176 | otg_io_write(isp->otg, ULPI_SET(ULPI_OTG_CTRL), | 186 | isp1704_write(isp, ULPI_SET(ULPI_OTG_CTRL), |
177 | ULPI_OTG_CTRL_DM_PULLDOWN); | 187 | ULPI_OTG_CTRL_DM_PULLDOWN); |
178 | 188 | ||
179 | /* It's a charger if the line states are clear */ | 189 | /* It's a charger if the line states are clear */ |
180 | if (!(otg_io_read(isp->otg, ULPI_DEBUG))) | 190 | if (!(isp1704_read(isp, ULPI_DEBUG))) |
181 | ret = 1; | 191 | ret = 1; |
182 | 192 | ||
183 | /* Disable weak pull-up resistor on DP */ | 193 | /* Disable weak pull-up resistor on DP */ |
184 | otg_io_write(isp->otg, ULPI_CLR(ISP1704_PWR_CTRL), | 194 | isp1704_write(isp, ULPI_CLR(ISP1704_PWR_CTRL), |
185 | ISP1704_PWR_CTRL_DP_WKPU_EN); | 195 | ISP1704_PWR_CTRL_DP_WKPU_EN); |
186 | 196 | ||
187 | return ret; | 197 | return ret; |
@@ -193,14 +203,14 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) | |||
193 | u8 pwr_ctrl; | 203 | u8 pwr_ctrl; |
194 | int ret = 0; | 204 | int ret = 0; |
195 | 205 | ||
196 | pwr_ctrl = otg_io_read(isp->otg, ISP1704_PWR_CTRL); | 206 | pwr_ctrl = isp1704_read(isp, ISP1704_PWR_CTRL); |
197 | 207 | ||
198 | /* set SW control bit in PWR_CTRL register */ | 208 | /* set SW control bit in PWR_CTRL register */ |
199 | otg_io_write(isp->otg, ISP1704_PWR_CTRL, | 209 | isp1704_write(isp, ISP1704_PWR_CTRL, |
200 | ISP1704_PWR_CTRL_SWCTRL); | 210 | ISP1704_PWR_CTRL_SWCTRL); |
201 | 211 | ||
202 | /* enable manual charger detection */ | 212 | /* enable manual charger detection */ |
203 | otg_io_write(isp->otg, ULPI_SET(ISP1704_PWR_CTRL), | 213 | isp1704_write(isp, ULPI_SET(ISP1704_PWR_CTRL), |
204 | ISP1704_PWR_CTRL_SWCTRL | 214 | ISP1704_PWR_CTRL_SWCTRL |
205 | | ISP1704_PWR_CTRL_DPVSRC_EN); | 215 | | ISP1704_PWR_CTRL_DPVSRC_EN); |
206 | usleep_range(1000, 2000); | 216 | usleep_range(1000, 2000); |
@@ -208,7 +218,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) | |||
208 | timeout = jiffies + msecs_to_jiffies(300); | 218 | timeout = jiffies + msecs_to_jiffies(300); |
209 | do { | 219 | do { |
210 | /* Check if there is a charger */ | 220 | /* Check if there is a charger */ |
211 | if (otg_io_read(isp->otg, ISP1704_PWR_CTRL) | 221 | if (isp1704_read(isp, ISP1704_PWR_CTRL) |
212 | & ISP1704_PWR_CTRL_VDAT_DET) { | 222 | & ISP1704_PWR_CTRL_VDAT_DET) { |
213 | ret = isp1704_charger_verify(isp); | 223 | ret = isp1704_charger_verify(isp); |
214 | break; | 224 | break; |
@@ -216,7 +226,7 @@ static inline int isp1704_charger_detect(struct isp1704_charger *isp) | |||
216 | } while (!time_after(jiffies, timeout) && isp->online); | 226 | } while (!time_after(jiffies, timeout) && isp->online); |
217 | 227 | ||
218 | /* recover original state */ | 228 | /* recover original state */ |
219 | otg_io_write(isp->otg, ISP1704_PWR_CTRL, pwr_ctrl); | 229 | isp1704_write(isp, ISP1704_PWR_CTRL, pwr_ctrl); |
220 | 230 | ||
221 | return ret; | 231 | return ret; |
222 | } | 232 | } |
@@ -264,8 +274,8 @@ static void isp1704_charger_work(struct work_struct *data) | |||
264 | case POWER_SUPPLY_TYPE_USB: | 274 | case POWER_SUPPLY_TYPE_USB: |
265 | default: | 275 | default: |
266 | /* enable data pullups */ | 276 | /* enable data pullups */ |
267 | if (isp->otg->gadget) | 277 | if (isp->phy->otg->gadget) |
268 | usb_gadget_connect(isp->otg->gadget); | 278 | usb_gadget_connect(isp->phy->otg->gadget); |
269 | } | 279 | } |
270 | break; | 280 | break; |
271 | case USB_EVENT_NONE: | 281 | case USB_EVENT_NONE: |
@@ -283,8 +293,8 @@ static void isp1704_charger_work(struct work_struct *data) | |||
283 | * chargers. The pullups may be enabled elsewhere, so this can | 293 | * chargers. The pullups may be enabled elsewhere, so this can |
284 | * not be the final solution. | 294 | * not be the final solution. |
285 | */ | 295 | */ |
286 | if (isp->otg->gadget) | 296 | if (isp->phy->otg->gadget) |
287 | usb_gadget_disconnect(isp->otg->gadget); | 297 | usb_gadget_disconnect(isp->phy->otg->gadget); |
288 | 298 | ||
289 | isp1704_charger_set_power(isp, 0); | 299 | isp1704_charger_set_power(isp, 0); |
290 | break; | 300 | break; |
@@ -364,11 +374,11 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) | |||
364 | int ret = -ENODEV; | 374 | int ret = -ENODEV; |
365 | 375 | ||
366 | /* Test ULPI interface */ | 376 | /* Test ULPI interface */ |
367 | ret = otg_io_write(isp->otg, ULPI_SCRATCH, 0xaa); | 377 | ret = isp1704_write(isp, ULPI_SCRATCH, 0xaa); |
368 | if (ret < 0) | 378 | if (ret < 0) |
369 | return ret; | 379 | return ret; |
370 | 380 | ||
371 | ret = otg_io_read(isp->otg, ULPI_SCRATCH); | 381 | ret = isp1704_read(isp, ULPI_SCRATCH); |
372 | if (ret < 0) | 382 | if (ret < 0) |
373 | return ret; | 383 | return ret; |
374 | 384 | ||
@@ -376,13 +386,13 @@ static inline int isp1704_test_ulpi(struct isp1704_charger *isp) | |||
376 | return -ENODEV; | 386 | return -ENODEV; |
377 | 387 | ||
378 | /* Verify the product and vendor id matches */ | 388 | /* Verify the product and vendor id matches */ |
379 | vendor = otg_io_read(isp->otg, ULPI_VENDOR_ID_LOW); | 389 | vendor = isp1704_read(isp, ULPI_VENDOR_ID_LOW); |
380 | vendor |= otg_io_read(isp->otg, ULPI_VENDOR_ID_HIGH) << 8; | 390 | vendor |= isp1704_read(isp, ULPI_VENDOR_ID_HIGH) << 8; |
381 | if (vendor != NXP_VENDOR_ID) | 391 | if (vendor != NXP_VENDOR_ID) |
382 | return -ENODEV; | 392 | return -ENODEV; |
383 | 393 | ||
384 | product = otg_io_read(isp->otg, ULPI_PRODUCT_ID_LOW); | 394 | product = isp1704_read(isp, ULPI_PRODUCT_ID_LOW); |
385 | product |= otg_io_read(isp->otg, ULPI_PRODUCT_ID_HIGH) << 8; | 395 | product |= isp1704_read(isp, ULPI_PRODUCT_ID_HIGH) << 8; |
386 | 396 | ||
387 | for (i = 0; i < ARRAY_SIZE(isp170x_id); i++) { | 397 | for (i = 0; i < ARRAY_SIZE(isp170x_id); i++) { |
388 | if (product == isp170x_id[i]) { | 398 | if (product == isp170x_id[i]) { |
@@ -405,8 +415,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) | |||
405 | if (!isp) | 415 | if (!isp) |
406 | return -ENOMEM; | 416 | return -ENOMEM; |
407 | 417 | ||
408 | isp->otg = otg_get_transceiver(); | 418 | isp->phy = usb_get_transceiver(); |
409 | if (!isp->otg) | 419 | if (!isp->phy) |
410 | goto fail0; | 420 | goto fail0; |
411 | 421 | ||
412 | isp->dev = &pdev->dev; | 422 | isp->dev = &pdev->dev; |
@@ -429,14 +439,14 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) | |||
429 | goto fail1; | 439 | goto fail1; |
430 | 440 | ||
431 | /* | 441 | /* |
432 | * REVISIT: using work in order to allow the otg notifications to be | 442 | * REVISIT: using work in order to allow the usb notifications to be |
433 | * made atomically in the future. | 443 | * made atomically in the future. |
434 | */ | 444 | */ |
435 | INIT_WORK(&isp->work, isp1704_charger_work); | 445 | INIT_WORK(&isp->work, isp1704_charger_work); |
436 | 446 | ||
437 | isp->nb.notifier_call = isp1704_notifier_call; | 447 | isp->nb.notifier_call = isp1704_notifier_call; |
438 | 448 | ||
439 | ret = otg_register_notifier(isp->otg, &isp->nb); | 449 | ret = usb_register_notifier(isp->phy, &isp->nb); |
440 | if (ret) | 450 | if (ret) |
441 | goto fail2; | 451 | goto fail2; |
442 | 452 | ||
@@ -449,13 +459,13 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) | |||
449 | * enumerated. The charger driver should be always loaded before any | 459 | * enumerated. The charger driver should be always loaded before any |
450 | * gadget is loaded. | 460 | * gadget is loaded. |
451 | */ | 461 | */ |
452 | if (isp->otg->gadget) | 462 | if (isp->phy->otg->gadget) |
453 | usb_gadget_disconnect(isp->otg->gadget); | 463 | usb_gadget_disconnect(isp->phy->otg->gadget); |
454 | 464 | ||
455 | /* Detect charger if VBUS is valid (the cable was already plugged). */ | 465 | /* Detect charger if VBUS is valid (the cable was already plugged). */ |
456 | ret = otg_io_read(isp->otg, ULPI_USB_INT_STS); | 466 | ret = isp1704_read(isp, ULPI_USB_INT_STS); |
457 | isp1704_charger_set_power(isp, 0); | 467 | isp1704_charger_set_power(isp, 0); |
458 | if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) { | 468 | if ((ret & ULPI_INT_VBUS_VALID) && !isp->phy->otg->default_a) { |
459 | isp->event = USB_EVENT_VBUS; | 469 | isp->event = USB_EVENT_VBUS; |
460 | schedule_work(&isp->work); | 470 | schedule_work(&isp->work); |
461 | } | 471 | } |
@@ -464,7 +474,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev) | |||
464 | fail2: | 474 | fail2: |
465 | power_supply_unregister(&isp->psy); | 475 | power_supply_unregister(&isp->psy); |
466 | fail1: | 476 | fail1: |
467 | otg_put_transceiver(isp->otg); | 477 | usb_put_transceiver(isp->phy); |
468 | fail0: | 478 | fail0: |
469 | kfree(isp); | 479 | kfree(isp); |
470 | 480 | ||
@@ -477,9 +487,9 @@ static int __devexit isp1704_charger_remove(struct platform_device *pdev) | |||
477 | { | 487 | { |
478 | struct isp1704_charger *isp = platform_get_drvdata(pdev); | 488 | struct isp1704_charger *isp = platform_get_drvdata(pdev); |
479 | 489 | ||
480 | otg_unregister_notifier(isp->otg, &isp->nb); | 490 | usb_unregister_notifier(isp->phy, &isp->nb); |
481 | power_supply_unregister(&isp->psy); | 491 | power_supply_unregister(&isp->psy); |
482 | otg_put_transceiver(isp->otg); | 492 | usb_put_transceiver(isp->phy); |
483 | isp1704_charger_set_power(isp, 0); | 493 | isp1704_charger_set_power(isp, 0); |
484 | kfree(isp); | 494 | kfree(isp); |
485 | 495 | ||
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c index fd49689738af..214468f4444a 100644 --- a/drivers/power/pda_power.c +++ b/drivers/power/pda_power.c | |||
@@ -40,7 +40,7 @@ static struct timer_list polling_timer; | |||
40 | static int polling; | 40 | static int polling; |
41 | 41 | ||
42 | #ifdef CONFIG_USB_OTG_UTILS | 42 | #ifdef CONFIG_USB_OTG_UTILS |
43 | static struct otg_transceiver *transceiver; | 43 | static struct usb_phy *transceiver; |
44 | static struct notifier_block otg_nb; | 44 | static struct notifier_block otg_nb; |
45 | #endif | 45 | #endif |
46 | 46 | ||
@@ -321,7 +321,7 @@ static int pda_power_probe(struct platform_device *pdev) | |||
321 | } | 321 | } |
322 | 322 | ||
323 | #ifdef CONFIG_USB_OTG_UTILS | 323 | #ifdef CONFIG_USB_OTG_UTILS |
324 | transceiver = otg_get_transceiver(); | 324 | transceiver = usb_get_transceiver(); |
325 | if (transceiver && !pdata->is_usb_online) { | 325 | if (transceiver && !pdata->is_usb_online) { |
326 | pdata->is_usb_online = otg_is_usb_online; | 326 | pdata->is_usb_online = otg_is_usb_online; |
327 | } | 327 | } |
@@ -375,7 +375,7 @@ static int pda_power_probe(struct platform_device *pdev) | |||
375 | #ifdef CONFIG_USB_OTG_UTILS | 375 | #ifdef CONFIG_USB_OTG_UTILS |
376 | if (transceiver && pdata->use_otg_notifier) { | 376 | if (transceiver && pdata->use_otg_notifier) { |
377 | otg_nb.notifier_call = otg_handle_notification; | 377 | otg_nb.notifier_call = otg_handle_notification; |
378 | ret = otg_register_notifier(transceiver, &otg_nb); | 378 | ret = usb_register_notifier(transceiver, &otg_nb); |
379 | if (ret) { | 379 | if (ret) { |
380 | dev_err(dev, "failure to register otg notifier\n"); | 380 | dev_err(dev, "failure to register otg notifier\n"); |
381 | goto otg_reg_notifier_failed; | 381 | goto otg_reg_notifier_failed; |
@@ -409,7 +409,7 @@ usb_supply_failed: | |||
409 | free_irq(ac_irq->start, &pda_psy_ac); | 409 | free_irq(ac_irq->start, &pda_psy_ac); |
410 | #ifdef CONFIG_USB_OTG_UTILS | 410 | #ifdef CONFIG_USB_OTG_UTILS |
411 | if (transceiver) | 411 | if (transceiver) |
412 | otg_put_transceiver(transceiver); | 412 | usb_put_transceiver(transceiver); |
413 | #endif | 413 | #endif |
414 | ac_irq_failed: | 414 | ac_irq_failed: |
415 | if (pdata->is_ac_online) | 415 | if (pdata->is_ac_online) |
@@ -444,7 +444,7 @@ static int pda_power_remove(struct platform_device *pdev) | |||
444 | power_supply_unregister(&pda_psy_ac); | 444 | power_supply_unregister(&pda_psy_ac); |
445 | #ifdef CONFIG_USB_OTG_UTILS | 445 | #ifdef CONFIG_USB_OTG_UTILS |
446 | if (transceiver) | 446 | if (transceiver) |
447 | otg_put_transceiver(transceiver); | 447 | usb_put_transceiver(transceiver); |
448 | #endif | 448 | #endif |
449 | if (ac_draw) { | 449 | if (ac_draw) { |
450 | regulator_put(ac_draw); | 450 | regulator_put(ac_draw); |
diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c index 54b9198fa576..fdad850c77d3 100644 --- a/drivers/power/twl4030_charger.c +++ b/drivers/power/twl4030_charger.c | |||
@@ -69,8 +69,8 @@ struct twl4030_bci { | |||
69 | struct device *dev; | 69 | struct device *dev; |
70 | struct power_supply ac; | 70 | struct power_supply ac; |
71 | struct power_supply usb; | 71 | struct power_supply usb; |
72 | struct otg_transceiver *transceiver; | 72 | struct usb_phy *transceiver; |
73 | struct notifier_block otg_nb; | 73 | struct notifier_block usb_nb; |
74 | struct work_struct work; | 74 | struct work_struct work; |
75 | int irq_chg; | 75 | int irq_chg; |
76 | int irq_bci; | 76 | int irq_bci; |
@@ -279,7 +279,7 @@ static void twl4030_bci_usb_work(struct work_struct *data) | |||
279 | static int twl4030_bci_usb_ncb(struct notifier_block *nb, unsigned long val, | 279 | static int twl4030_bci_usb_ncb(struct notifier_block *nb, unsigned long val, |
280 | void *priv) | 280 | void *priv) |
281 | { | 281 | { |
282 | struct twl4030_bci *bci = container_of(nb, struct twl4030_bci, otg_nb); | 282 | struct twl4030_bci *bci = container_of(nb, struct twl4030_bci, usb_nb); |
283 | 283 | ||
284 | dev_dbg(bci->dev, "OTG notify %lu\n", val); | 284 | dev_dbg(bci->dev, "OTG notify %lu\n", val); |
285 | 285 | ||
@@ -479,10 +479,10 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) | |||
479 | 479 | ||
480 | INIT_WORK(&bci->work, twl4030_bci_usb_work); | 480 | INIT_WORK(&bci->work, twl4030_bci_usb_work); |
481 | 481 | ||
482 | bci->transceiver = otg_get_transceiver(); | 482 | bci->transceiver = usb_get_transceiver(); |
483 | if (bci->transceiver != NULL) { | 483 | if (bci->transceiver != NULL) { |
484 | bci->otg_nb.notifier_call = twl4030_bci_usb_ncb; | 484 | bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; |
485 | otg_register_notifier(bci->transceiver, &bci->otg_nb); | 485 | usb_register_notifier(bci->transceiver, &bci->usb_nb); |
486 | } | 486 | } |
487 | 487 | ||
488 | /* Enable interrupts now. */ | 488 | /* Enable interrupts now. */ |
@@ -508,8 +508,8 @@ static int __init twl4030_bci_probe(struct platform_device *pdev) | |||
508 | 508 | ||
509 | fail_unmask_interrupts: | 509 | fail_unmask_interrupts: |
510 | if (bci->transceiver != NULL) { | 510 | if (bci->transceiver != NULL) { |
511 | otg_unregister_notifier(bci->transceiver, &bci->otg_nb); | 511 | usb_unregister_notifier(bci->transceiver, &bci->usb_nb); |
512 | otg_put_transceiver(bci->transceiver); | 512 | usb_put_transceiver(bci->transceiver); |
513 | } | 513 | } |
514 | free_irq(bci->irq_bci, bci); | 514 | free_irq(bci->irq_bci, bci); |
515 | fail_bci_irq: | 515 | fail_bci_irq: |
@@ -539,8 +539,8 @@ static int __exit twl4030_bci_remove(struct platform_device *pdev) | |||
539 | TWL4030_INTERRUPTS_BCIIMR2A); | 539 | TWL4030_INTERRUPTS_BCIIMR2A); |
540 | 540 | ||
541 | if (bci->transceiver != NULL) { | 541 | if (bci->transceiver != NULL) { |
542 | otg_unregister_notifier(bci->transceiver, &bci->otg_nb); | 542 | usb_unregister_notifier(bci->transceiver, &bci->usb_nb); |
543 | otg_put_transceiver(bci->transceiver); | 543 | usb_put_transceiver(bci->transceiver); |
544 | } | 544 | } |
545 | free_irq(bci->irq_bci, bci); | 545 | free_irq(bci->irq_bci, bci); |
546 | free_irq(bci->irq_chg, bci); | 546 | free_irq(bci->irq_chg, bci); |
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 29c4c0480976..01b03744f1f9 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c | |||
@@ -1295,6 +1295,7 @@ EXPORT_SYMBOL(int_to_scsilun); | |||
1295 | * LUNs even if it's older than SCSI-3. | 1295 | * LUNs even if it's older than SCSI-3. |
1296 | * If BLIST_NOREPORTLUN is set, return 1 always. | 1296 | * If BLIST_NOREPORTLUN is set, return 1 always. |
1297 | * If BLIST_NOLUN is set, return 0 always. | 1297 | * If BLIST_NOLUN is set, return 0 always. |
1298 | * If starget->no_report_luns is set, return 1 always. | ||
1298 | * | 1299 | * |
1299 | * Return: | 1300 | * Return: |
1300 | * 0: scan completed (or no memory, so further scanning is futile) | 1301 | * 0: scan completed (or no memory, so further scanning is futile) |
@@ -1321,6 +1322,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, | |||
1321 | * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. | 1322 | * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. |
1322 | * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does | 1323 | * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does |
1323 | * support more than 8 LUNs. | 1324 | * support more than 8 LUNs. |
1325 | * Don't attempt if the target doesn't support REPORT LUNS. | ||
1324 | */ | 1326 | */ |
1325 | if (bflags & BLIST_NOREPORTLUN) | 1327 | if (bflags & BLIST_NOREPORTLUN) |
1326 | return 1; | 1328 | return 1; |
@@ -1332,6 +1334,8 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags, | |||
1332 | return 1; | 1334 | return 1; |
1333 | if (bflags & BLIST_NOLUN) | 1335 | if (bflags & BLIST_NOLUN) |
1334 | return 0; | 1336 | return 0; |
1337 | if (starget->no_report_luns) | ||
1338 | return 1; | ||
1335 | 1339 | ||
1336 | if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { | 1340 | if (!(sdev = scsi_device_lookup_by_target(starget, 0))) { |
1337 | sdev = scsi_alloc_sdev(starget, 0, NULL); | 1341 | sdev = scsi_alloc_sdev(starget, 0, NULL); |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index c691fb50e6cb..d173b90b25e9 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -2349,7 +2349,7 @@ static int sd_try_extended_inquiry(struct scsi_device *sdp) | |||
2349 | * some USB ones crash on receiving them, and the pages | 2349 | * some USB ones crash on receiving them, and the pages |
2350 | * we currently ask for are for SPC-3 and beyond | 2350 | * we currently ask for are for SPC-3 and beyond |
2351 | */ | 2351 | */ |
2352 | if (sdp->scsi_level > SCSI_SPC_2) | 2352 | if (sdp->scsi_level > SCSI_SPC_2 && !sdp->skip_vpd_pages) |
2353 | return 1; | 2353 | return 1; |
2354 | return 0; | 2354 | return 0; |
2355 | } | 2355 | } |
diff --git a/drivers/staging/keucr/transport.h b/drivers/staging/keucr/transport.h index 4ae57d0145b2..2a11a98375d7 100644 --- a/drivers/staging/keucr/transport.h +++ b/drivers/staging/keucr/transport.h | |||
@@ -3,43 +3,6 @@ | |||
3 | 3 | ||
4 | #include <linux/blkdev.h> | 4 | #include <linux/blkdev.h> |
5 | 5 | ||
6 | /* Bulk only data structures */ | ||
7 | |||
8 | /* command block wrapper */ | ||
9 | struct bulk_cb_wrap { | ||
10 | __le32 Signature; /* contains 'USBC' */ | ||
11 | __u32 Tag; /* unique per command id */ | ||
12 | __le32 DataTransferLength; /* size of data */ | ||
13 | __u8 Flags; /* direction in bit 0 */ | ||
14 | __u8 Lun; /* LUN normally 0 */ | ||
15 | __u8 Length; /* of of the CDB */ | ||
16 | __u8 CDB[16]; /* max command */ | ||
17 | }; | ||
18 | |||
19 | #define US_BULK_CB_WRAP_LEN 31 | ||
20 | #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */ | ||
21 | #define US_BULK_FLAG_IN 1 | ||
22 | #define US_BULK_FLAG_OUT 0 | ||
23 | |||
24 | /* command status wrapper */ | ||
25 | struct bulk_cs_wrap { | ||
26 | __le32 Signature; /* should = 'USBS' */ | ||
27 | __u32 Tag; /* same as original command */ | ||
28 | __le32 Residue; /* amount not transferred */ | ||
29 | __u8 Status; /* see below */ | ||
30 | __u8 Filler[18]; | ||
31 | }; | ||
32 | |||
33 | #define US_BULK_CS_WRAP_LEN 13 | ||
34 | #define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */ | ||
35 | #define US_BULK_STAT_OK 0 | ||
36 | #define US_BULK_STAT_FAIL 1 | ||
37 | #define US_BULK_STAT_PHASE 2 | ||
38 | |||
39 | /* bulk-only class specific requests */ | ||
40 | #define US_BULK_RESET_REQUEST 0xff | ||
41 | #define US_BULK_GET_MAX_LUN 0xfe | ||
42 | |||
43 | /* usb_stor_bulk_transfer_xxx() return codes, in order of severity */ | 6 | /* usb_stor_bulk_transfer_xxx() return codes, in order of severity */ |
44 | #define USB_STOR_XFER_GOOD 0 /* good transfer */ | 7 | #define USB_STOR_XFER_GOOD 0 /* good transfer */ |
45 | #define USB_STOR_XFER_SHORT 1 /* transferred less than expected */ | 8 | #define USB_STOR_XFER_SHORT 1 /* transferred less than expected */ |
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c index 897a3a99c794..bb977e00cc86 100644 --- a/drivers/staging/quatech_usb2/quatech_usb2.c +++ b/drivers/staging/quatech_usb2/quatech_usb2.c | |||
@@ -135,7 +135,6 @@ static struct usb_driver quausb2_usb_driver = { | |||
135 | .probe = usb_serial_probe, | 135 | .probe = usb_serial_probe, |
136 | .disconnect = usb_serial_disconnect, | 136 | .disconnect = usb_serial_disconnect, |
137 | .id_table = quausb2_id_table, | 137 | .id_table = quausb2_id_table, |
138 | .no_dynamic_id = 1, | ||
139 | }; | 138 | }; |
140 | 139 | ||
141 | /** | 140 | /** |
@@ -1942,7 +1941,6 @@ static struct usb_serial_driver quatech2_device = { | |||
1942 | .name = "quatech_usb2", | 1941 | .name = "quatech_usb2", |
1943 | }, | 1942 | }, |
1944 | .description = DRIVER_DESC, | 1943 | .description = DRIVER_DESC, |
1945 | .usb_driver = &quausb2_usb_driver, | ||
1946 | .id_table = quausb2_id_table, | 1944 | .id_table = quausb2_id_table, |
1947 | .num_ports = 8, | 1945 | .num_ports = 8, |
1948 | .open = qt2_open, | 1946 | .open = qt2_open, |
@@ -1964,41 +1962,11 @@ static struct usb_serial_driver quatech2_device = { | |||
1964 | .write_bulk_callback = qt2_write_bulk_callback, | 1962 | .write_bulk_callback = qt2_write_bulk_callback, |
1965 | }; | 1963 | }; |
1966 | 1964 | ||
1967 | static int __init quausb2_usb_init(void) | 1965 | static struct usb_serial_driver * const serial_drivers[] = { |
1968 | { | 1966 | &quatech2_device, NULL |
1969 | int retval; | 1967 | }; |
1970 | |||
1971 | dbg("%s\n", __func__); | ||
1972 | |||
1973 | /* register with usb-serial */ | ||
1974 | retval = usb_serial_register(&quatech2_device); | ||
1975 | |||
1976 | if (retval) | ||
1977 | goto failed_usb_serial_register; | ||
1978 | |||
1979 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1980 | DRIVER_DESC "\n"); | ||
1981 | |||
1982 | /* register with usb */ | ||
1983 | |||
1984 | retval = usb_register(&quausb2_usb_driver); | ||
1985 | if (retval == 0) | ||
1986 | return 0; | ||
1987 | |||
1988 | /* if we're here, usb_register() failed */ | ||
1989 | usb_serial_deregister(&quatech2_device); | ||
1990 | failed_usb_serial_register: | ||
1991 | return retval; | ||
1992 | } | ||
1993 | |||
1994 | static void __exit quausb2_usb_exit(void) | ||
1995 | { | ||
1996 | usb_deregister(&quausb2_usb_driver); | ||
1997 | usb_serial_deregister(&quatech2_device); | ||
1998 | } | ||
1999 | 1968 | ||
2000 | module_init(quausb2_usb_init); | 1969 | module_usb_serial_driver(quausb2_usb_driver, serial_drivers); |
2001 | module_exit(quausb2_usb_exit); | ||
2002 | 1970 | ||
2003 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1971 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2004 | MODULE_DESCRIPTION(DRIVER_DESC); | 1972 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 1c5780f1571b..ae1d815e2a53 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c | |||
@@ -200,7 +200,6 @@ static struct usb_driver serqt_usb_driver = { | |||
200 | .probe = usb_serial_probe, | 200 | .probe = usb_serial_probe, |
201 | .disconnect = usb_serial_disconnect, | 201 | .disconnect = usb_serial_disconnect, |
202 | .id_table = serqt_id_table, | 202 | .id_table = serqt_id_table, |
203 | .no_dynamic_id = 1, | ||
204 | }; | 203 | }; |
205 | 204 | ||
206 | static int port_paranoia_check(struct usb_serial_port *port, | 205 | static int port_paranoia_check(struct usb_serial_port *port, |
@@ -1590,7 +1589,6 @@ static struct usb_serial_driver quatech_device = { | |||
1590 | .name = "serqt", | 1589 | .name = "serqt", |
1591 | }, | 1590 | }, |
1592 | .description = DRIVER_DESC, | 1591 | .description = DRIVER_DESC, |
1593 | .usb_driver = &serqt_usb_driver, | ||
1594 | .id_table = serqt_id_table, | 1592 | .id_table = serqt_id_table, |
1595 | .num_ports = 8, | 1593 | .num_ports = 8, |
1596 | .open = qt_open, | 1594 | .open = qt_open, |
@@ -1610,41 +1608,11 @@ static struct usb_serial_driver quatech_device = { | |||
1610 | .release = qt_release, | 1608 | .release = qt_release, |
1611 | }; | 1609 | }; |
1612 | 1610 | ||
1613 | static int __init serqt_usb_init(void) | 1611 | static struct usb_serial_driver * const serial_drivers[] = { |
1614 | { | 1612 | &quatech_device, NULL |
1615 | int retval; | 1613 | }; |
1616 | |||
1617 | dbg("%s\n", __func__); | ||
1618 | |||
1619 | /* register with usb-serial */ | ||
1620 | retval = usb_serial_register(&quatech_device); | ||
1621 | |||
1622 | if (retval) | ||
1623 | goto failed_usb_serial_register; | ||
1624 | |||
1625 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1626 | DRIVER_DESC "\n"); | ||
1627 | |||
1628 | /* register with usb */ | ||
1629 | |||
1630 | retval = usb_register(&serqt_usb_driver); | ||
1631 | if (retval == 0) | ||
1632 | return 0; | ||
1633 | |||
1634 | /* if we're here, usb_register() failed */ | ||
1635 | usb_serial_deregister(&quatech_device); | ||
1636 | failed_usb_serial_register: | ||
1637 | return retval; | ||
1638 | } | ||
1639 | |||
1640 | static void __exit serqt_usb_exit(void) | ||
1641 | { | ||
1642 | usb_deregister(&serqt_usb_driver); | ||
1643 | usb_serial_deregister(&quatech_device); | ||
1644 | } | ||
1645 | 1614 | ||
1646 | module_init(serqt_usb_init); | 1615 | module_usb_serial_driver(serqt_usb_driver, serial_drivers); |
1647 | module_exit(serqt_usb_exit); | ||
1648 | 1616 | ||
1649 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1617 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1650 | MODULE_DESCRIPTION(DRIVER_DESC); | 1618 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig index 75823a1abeb6..e4405e088589 100644 --- a/drivers/usb/Kconfig +++ b/drivers/usb/Kconfig | |||
@@ -10,27 +10,6 @@ menuconfig USB_SUPPORT | |||
10 | This option adds core support for Universal Serial Bus (USB). | 10 | This option adds core support for Universal Serial Bus (USB). |
11 | You will also need drivers from the following menu to make use of it. | 11 | You will also need drivers from the following menu to make use of it. |
12 | 12 | ||
13 | if USB_SUPPORT | ||
14 | |||
15 | config USB_COMMON | ||
16 | tristate | ||
17 | default y | ||
18 | depends on USB || USB_GADGET | ||
19 | |||
20 | # Host-side USB depends on having a host controller | ||
21 | # NOTE: dummy_hcd is always an option, but it's ignored here ... | ||
22 | # NOTE: SL-811 option should be board-specific ... | ||
23 | config USB_ARCH_HAS_HCD | ||
24 | boolean | ||
25 | default y if USB_ARCH_HAS_OHCI | ||
26 | default y if USB_ARCH_HAS_EHCI | ||
27 | default y if USB_ARCH_HAS_XHCI | ||
28 | default y if PCMCIA && !M32R # sl811_cs | ||
29 | default y if ARM # SL-811 | ||
30 | default y if BLACKFIN # SL-811 | ||
31 | default y if SUPERH # r8a66597-hcd | ||
32 | default PCI | ||
33 | |||
34 | # many non-PCI SOC chips embed OHCI | 13 | # many non-PCI SOC chips embed OHCI |
35 | config USB_ARCH_HAS_OHCI | 14 | config USB_ARCH_HAS_OHCI |
36 | boolean | 15 | boolean |
@@ -76,6 +55,7 @@ config USB_ARCH_HAS_EHCI | |||
76 | default y if MICROBLAZE | 55 | default y if MICROBLAZE |
77 | default y if SPARC_LEON | 56 | default y if SPARC_LEON |
78 | default y if ARCH_MMP | 57 | default y if ARCH_MMP |
58 | default y if MACH_LOONGSON1 | ||
79 | default PCI | 59 | default PCI |
80 | 60 | ||
81 | # some non-PCI HCDs implement xHCI | 61 | # some non-PCI HCDs implement xHCI |
@@ -83,6 +63,27 @@ config USB_ARCH_HAS_XHCI | |||
83 | boolean | 63 | boolean |
84 | default PCI | 64 | default PCI |
85 | 65 | ||
66 | if USB_SUPPORT | ||
67 | |||
68 | config USB_COMMON | ||
69 | tristate | ||
70 | default y | ||
71 | depends on USB || USB_GADGET | ||
72 | |||
73 | # Host-side USB depends on having a host controller | ||
74 | # NOTE: dummy_hcd is always an option, but it's ignored here ... | ||
75 | # NOTE: SL-811 option should be board-specific ... | ||
76 | config USB_ARCH_HAS_HCD | ||
77 | boolean | ||
78 | default y if USB_ARCH_HAS_OHCI | ||
79 | default y if USB_ARCH_HAS_EHCI | ||
80 | default y if USB_ARCH_HAS_XHCI | ||
81 | default y if PCMCIA && !M32R # sl811_cs | ||
82 | default y if ARM # SL-811 | ||
83 | default y if BLACKFIN # SL-811 | ||
84 | default y if SUPERH # r8a66597-hcd | ||
85 | default PCI | ||
86 | |||
86 | # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. | 87 | # ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. |
87 | config USB | 88 | config USB |
88 | tristate "Support for Host-side USB" | 89 | tristate "Support for Host-side USB" |
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 6bb8472155c6..b32ccb461019 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/serial.h> | 39 | #include <linux/serial.h> |
40 | #include <linux/tty_driver.h> | 40 | #include <linux/tty_driver.h> |
41 | #include <linux/tty_flip.h> | 41 | #include <linux/tty_flip.h> |
42 | #include <linux/serial.h> | ||
42 | #include <linux/module.h> | 43 | #include <linux/module.h> |
43 | #include <linux/mutex.h> | 44 | #include <linux/mutex.h> |
44 | #include <linux/uaccess.h> | 45 | #include <linux/uaccess.h> |
@@ -768,10 +769,37 @@ static int acm_tty_tiocmset(struct tty_struct *tty, | |||
768 | return acm_set_control(acm, acm->ctrlout = newctrl); | 769 | return acm_set_control(acm, acm->ctrlout = newctrl); |
769 | } | 770 | } |
770 | 771 | ||
772 | static int get_serial_info(struct acm *acm, struct serial_struct __user *info) | ||
773 | { | ||
774 | struct serial_struct tmp; | ||
775 | |||
776 | if (!info) | ||
777 | return -EINVAL; | ||
778 | |||
779 | memset(&tmp, 0, sizeof(tmp)); | ||
780 | tmp.flags = ASYNC_LOW_LATENCY; | ||
781 | tmp.xmit_fifo_size = acm->writesize; | ||
782 | tmp.baud_base = le32_to_cpu(acm->line.dwDTERate); | ||
783 | |||
784 | if (copy_to_user(info, &tmp, sizeof(tmp))) | ||
785 | return -EFAULT; | ||
786 | else | ||
787 | return 0; | ||
788 | } | ||
789 | |||
771 | static int acm_tty_ioctl(struct tty_struct *tty, | 790 | static int acm_tty_ioctl(struct tty_struct *tty, |
772 | unsigned int cmd, unsigned long arg) | 791 | unsigned int cmd, unsigned long arg) |
773 | { | 792 | { |
774 | return -ENOIOCTLCMD; | 793 | struct acm *acm = tty->driver_data; |
794 | int rv = -ENOIOCTLCMD; | ||
795 | |||
796 | switch (cmd) { | ||
797 | case TIOCGSERIAL: /* gets serial port data */ | ||
798 | rv = get_serial_info(acm, (struct serial_struct __user *) arg); | ||
799 | break; | ||
800 | } | ||
801 | |||
802 | return rv; | ||
775 | } | 803 | } |
776 | 804 | ||
777 | static const __u32 acm_tty_speed[] = { | 805 | static const __u32 acm_tty_speed[] = { |
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index d2b3cffca3f7..c6f6560d436c 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/usb/cdc.h> | 23 | #include <linux/usb/cdc.h> |
24 | #include <asm/byteorder.h> | 24 | #include <asm/byteorder.h> |
25 | #include <asm/unaligned.h> | 25 | #include <asm/unaligned.h> |
26 | #include <linux/usb/cdc-wdm.h> | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * Version Information | 29 | * Version Information |
@@ -31,6 +32,8 @@ | |||
31 | #define DRIVER_AUTHOR "Oliver Neukum" | 32 | #define DRIVER_AUTHOR "Oliver Neukum" |
32 | #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" | 33 | #define DRIVER_DESC "USB Abstract Control Model driver for USB WCM Device Management" |
33 | 34 | ||
35 | #define HUAWEI_VENDOR_ID 0x12D1 | ||
36 | |||
34 | static const struct usb_device_id wdm_ids[] = { | 37 | static const struct usb_device_id wdm_ids[] = { |
35 | { | 38 | { |
36 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | | 39 | .match_flags = USB_DEVICE_ID_MATCH_INT_CLASS | |
@@ -38,6 +41,20 @@ static const struct usb_device_id wdm_ids[] = { | |||
38 | .bInterfaceClass = USB_CLASS_COMM, | 41 | .bInterfaceClass = USB_CLASS_COMM, |
39 | .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM | 42 | .bInterfaceSubClass = USB_CDC_SUBCLASS_DMM |
40 | }, | 43 | }, |
44 | { | ||
45 | /* | ||
46 | * Huawei E392, E398 and possibly other Qualcomm based modems | ||
47 | * embed the Qualcomm QMI protocol inside CDC on CDC ECM like | ||
48 | * control interfaces. Userspace access to this is required | ||
49 | * to configure the accompanying data interface | ||
50 | */ | ||
51 | .match_flags = USB_DEVICE_ID_MATCH_VENDOR | | ||
52 | USB_DEVICE_ID_MATCH_INT_INFO, | ||
53 | .idVendor = HUAWEI_VENDOR_ID, | ||
54 | .bInterfaceClass = USB_CLASS_VENDOR_SPEC, | ||
55 | .bInterfaceSubClass = 1, | ||
56 | .bInterfaceProtocol = 9, /* NOTE: CDC ECM control interface! */ | ||
57 | }, | ||
41 | { } | 58 | { } |
42 | }; | 59 | }; |
43 | 60 | ||
@@ -54,6 +71,7 @@ MODULE_DEVICE_TABLE (usb, wdm_ids); | |||
54 | #define WDM_POLL_RUNNING 6 | 71 | #define WDM_POLL_RUNNING 6 |
55 | #define WDM_RESPONDING 7 | 72 | #define WDM_RESPONDING 7 |
56 | #define WDM_SUSPENDING 8 | 73 | #define WDM_SUSPENDING 8 |
74 | #define WDM_RESETTING 9 | ||
57 | 75 | ||
58 | #define WDM_MAX 16 | 76 | #define WDM_MAX 16 |
59 | 77 | ||
@@ -61,6 +79,8 @@ MODULE_DEVICE_TABLE (usb, wdm_ids); | |||
61 | #define WDM_DEFAULT_BUFSIZE 256 | 79 | #define WDM_DEFAULT_BUFSIZE 256 |
62 | 80 | ||
63 | static DEFINE_MUTEX(wdm_mutex); | 81 | static DEFINE_MUTEX(wdm_mutex); |
82 | static DEFINE_SPINLOCK(wdm_device_list_lock); | ||
83 | static LIST_HEAD(wdm_device_list); | ||
64 | 84 | ||
65 | /* --- method tables --- */ | 85 | /* --- method tables --- */ |
66 | 86 | ||
@@ -82,7 +102,6 @@ struct wdm_device { | |||
82 | u16 bufsize; | 102 | u16 bufsize; |
83 | u16 wMaxCommand; | 103 | u16 wMaxCommand; |
84 | u16 wMaxPacketSize; | 104 | u16 wMaxPacketSize; |
85 | u16 bMaxPacketSize0; | ||
86 | __le16 inum; | 105 | __le16 inum; |
87 | int reslength; | 106 | int reslength; |
88 | int length; | 107 | int length; |
@@ -96,10 +115,40 @@ struct wdm_device { | |||
96 | struct work_struct rxwork; | 115 | struct work_struct rxwork; |
97 | int werr; | 116 | int werr; |
98 | int rerr; | 117 | int rerr; |
118 | |||
119 | struct list_head device_list; | ||
120 | int (*manage_power)(struct usb_interface *, int); | ||
99 | }; | 121 | }; |
100 | 122 | ||
101 | static struct usb_driver wdm_driver; | 123 | static struct usb_driver wdm_driver; |
102 | 124 | ||
125 | /* return intfdata if we own the interface, else look up intf in the list */ | ||
126 | static struct wdm_device *wdm_find_device(struct usb_interface *intf) | ||
127 | { | ||
128 | struct wdm_device *desc = NULL; | ||
129 | |||
130 | spin_lock(&wdm_device_list_lock); | ||
131 | list_for_each_entry(desc, &wdm_device_list, device_list) | ||
132 | if (desc->intf == intf) | ||
133 | break; | ||
134 | spin_unlock(&wdm_device_list_lock); | ||
135 | |||
136 | return desc; | ||
137 | } | ||
138 | |||
139 | static struct wdm_device *wdm_find_device_by_minor(int minor) | ||
140 | { | ||
141 | struct wdm_device *desc = NULL; | ||
142 | |||
143 | spin_lock(&wdm_device_list_lock); | ||
144 | list_for_each_entry(desc, &wdm_device_list, device_list) | ||
145 | if (desc->intf->minor == minor) | ||
146 | break; | ||
147 | spin_unlock(&wdm_device_list_lock); | ||
148 | |||
149 | return desc; | ||
150 | } | ||
151 | |||
103 | /* --- callbacks --- */ | 152 | /* --- callbacks --- */ |
104 | static void wdm_out_callback(struct urb *urb) | 153 | static void wdm_out_callback(struct urb *urb) |
105 | { | 154 | { |
@@ -162,11 +211,9 @@ static void wdm_int_callback(struct urb *urb) | |||
162 | int rv = 0; | 211 | int rv = 0; |
163 | int status = urb->status; | 212 | int status = urb->status; |
164 | struct wdm_device *desc; | 213 | struct wdm_device *desc; |
165 | struct usb_ctrlrequest *req; | ||
166 | struct usb_cdc_notification *dr; | 214 | struct usb_cdc_notification *dr; |
167 | 215 | ||
168 | desc = urb->context; | 216 | desc = urb->context; |
169 | req = desc->irq; | ||
170 | dr = (struct usb_cdc_notification *)desc->sbuf; | 217 | dr = (struct usb_cdc_notification *)desc->sbuf; |
171 | 218 | ||
172 | if (status) { | 219 | if (status) { |
@@ -213,24 +260,6 @@ static void wdm_int_callback(struct urb *urb) | |||
213 | goto exit; | 260 | goto exit; |
214 | } | 261 | } |
215 | 262 | ||
216 | req->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); | ||
217 | req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; | ||
218 | req->wValue = 0; | ||
219 | req->wIndex = desc->inum; | ||
220 | req->wLength = cpu_to_le16(desc->wMaxCommand); | ||
221 | |||
222 | usb_fill_control_urb( | ||
223 | desc->response, | ||
224 | interface_to_usbdev(desc->intf), | ||
225 | /* using common endpoint 0 */ | ||
226 | usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0), | ||
227 | (unsigned char *)req, | ||
228 | desc->inbuf, | ||
229 | desc->wMaxCommand, | ||
230 | wdm_in_callback, | ||
231 | desc | ||
232 | ); | ||
233 | desc->response->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
234 | spin_lock(&desc->iuspin); | 263 | spin_lock(&desc->iuspin); |
235 | clear_bit(WDM_READ, &desc->flags); | 264 | clear_bit(WDM_READ, &desc->flags); |
236 | set_bit(WDM_RESPONDING, &desc->flags); | 265 | set_bit(WDM_RESPONDING, &desc->flags); |
@@ -279,14 +308,11 @@ static void free_urbs(struct wdm_device *desc) | |||
279 | 308 | ||
280 | static void cleanup(struct wdm_device *desc) | 309 | static void cleanup(struct wdm_device *desc) |
281 | { | 310 | { |
282 | usb_free_coherent(interface_to_usbdev(desc->intf), | 311 | spin_lock(&wdm_device_list_lock); |
283 | desc->wMaxPacketSize, | 312 | list_del(&desc->device_list); |
284 | desc->sbuf, | 313 | spin_unlock(&wdm_device_list_lock); |
285 | desc->validity->transfer_dma); | 314 | kfree(desc->sbuf); |
286 | usb_free_coherent(interface_to_usbdev(desc->intf), | 315 | kfree(desc->inbuf); |
287 | desc->bMaxPacketSize0, | ||
288 | desc->inbuf, | ||
289 | desc->response->transfer_dma); | ||
290 | kfree(desc->orq); | 316 | kfree(desc->orq); |
291 | kfree(desc->irq); | 317 | kfree(desc->irq); |
292 | kfree(desc->ubuf); | 318 | kfree(desc->ubuf); |
@@ -351,6 +377,10 @@ static ssize_t wdm_write | |||
351 | else | 377 | else |
352 | if (test_bit(WDM_IN_USE, &desc->flags)) | 378 | if (test_bit(WDM_IN_USE, &desc->flags)) |
353 | r = -EAGAIN; | 379 | r = -EAGAIN; |
380 | |||
381 | if (test_bit(WDM_RESETTING, &desc->flags)) | ||
382 | r = -EIO; | ||
383 | |||
354 | if (r < 0) { | 384 | if (r < 0) { |
355 | kfree(buf); | 385 | kfree(buf); |
356 | goto out; | 386 | goto out; |
@@ -397,7 +427,7 @@ outnl: | |||
397 | static ssize_t wdm_read | 427 | static ssize_t wdm_read |
398 | (struct file *file, char __user *buffer, size_t count, loff_t *ppos) | 428 | (struct file *file, char __user *buffer, size_t count, loff_t *ppos) |
399 | { | 429 | { |
400 | int rv, cntr = 0; | 430 | int rv, cntr; |
401 | int i = 0; | 431 | int i = 0; |
402 | struct wdm_device *desc = file->private_data; | 432 | struct wdm_device *desc = file->private_data; |
403 | 433 | ||
@@ -406,7 +436,8 @@ static ssize_t wdm_read | |||
406 | if (rv < 0) | 436 | if (rv < 0) |
407 | return -ERESTARTSYS; | 437 | return -ERESTARTSYS; |
408 | 438 | ||
409 | if (desc->length == 0) { | 439 | cntr = ACCESS_ONCE(desc->length); |
440 | if (cntr == 0) { | ||
410 | desc->read = 0; | 441 | desc->read = 0; |
411 | retry: | 442 | retry: |
412 | if (test_bit(WDM_DISCONNECTING, &desc->flags)) { | 443 | if (test_bit(WDM_DISCONNECTING, &desc->flags)) { |
@@ -430,6 +461,10 @@ retry: | |||
430 | rv = -ENODEV; | 461 | rv = -ENODEV; |
431 | goto err; | 462 | goto err; |
432 | } | 463 | } |
464 | if (test_bit(WDM_RESETTING, &desc->flags)) { | ||
465 | rv = -EIO; | ||
466 | goto err; | ||
467 | } | ||
433 | usb_mark_last_busy(interface_to_usbdev(desc->intf)); | 468 | usb_mark_last_busy(interface_to_usbdev(desc->intf)); |
434 | if (rv < 0) { | 469 | if (rv < 0) { |
435 | rv = -ERESTARTSYS; | 470 | rv = -ERESTARTSYS; |
@@ -456,26 +491,30 @@ retry: | |||
456 | spin_unlock_irq(&desc->iuspin); | 491 | spin_unlock_irq(&desc->iuspin); |
457 | goto retry; | 492 | goto retry; |
458 | } | 493 | } |
459 | clear_bit(WDM_READ, &desc->flags); | 494 | cntr = desc->length; |
460 | spin_unlock_irq(&desc->iuspin); | 495 | spin_unlock_irq(&desc->iuspin); |
461 | } | 496 | } |
462 | 497 | ||
463 | cntr = count > desc->length ? desc->length : count; | 498 | if (cntr > count) |
499 | cntr = count; | ||
464 | rv = copy_to_user(buffer, desc->ubuf, cntr); | 500 | rv = copy_to_user(buffer, desc->ubuf, cntr); |
465 | if (rv > 0) { | 501 | if (rv > 0) { |
466 | rv = -EFAULT; | 502 | rv = -EFAULT; |
467 | goto err; | 503 | goto err; |
468 | } | 504 | } |
469 | 505 | ||
506 | spin_lock_irq(&desc->iuspin); | ||
507 | |||
470 | for (i = 0; i < desc->length - cntr; i++) | 508 | for (i = 0; i < desc->length - cntr; i++) |
471 | desc->ubuf[i] = desc->ubuf[i + cntr]; | 509 | desc->ubuf[i] = desc->ubuf[i + cntr]; |
472 | 510 | ||
473 | spin_lock_irq(&desc->iuspin); | ||
474 | desc->length -= cntr; | 511 | desc->length -= cntr; |
475 | spin_unlock_irq(&desc->iuspin); | ||
476 | /* in case we had outstanding data */ | 512 | /* in case we had outstanding data */ |
477 | if (!desc->length) | 513 | if (!desc->length) |
478 | clear_bit(WDM_READ, &desc->flags); | 514 | clear_bit(WDM_READ, &desc->flags); |
515 | |||
516 | spin_unlock_irq(&desc->iuspin); | ||
517 | |||
479 | rv = cntr; | 518 | rv = cntr; |
480 | 519 | ||
481 | err: | 520 | err: |
@@ -529,11 +568,11 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
529 | struct wdm_device *desc; | 568 | struct wdm_device *desc; |
530 | 569 | ||
531 | mutex_lock(&wdm_mutex); | 570 | mutex_lock(&wdm_mutex); |
532 | intf = usb_find_interface(&wdm_driver, minor); | 571 | desc = wdm_find_device_by_minor(minor); |
533 | if (!intf) | 572 | if (!desc) |
534 | goto out; | 573 | goto out; |
535 | 574 | ||
536 | desc = usb_get_intfdata(intf); | 575 | intf = desc->intf; |
537 | if (test_bit(WDM_DISCONNECTING, &desc->flags)) | 576 | if (test_bit(WDM_DISCONNECTING, &desc->flags)) |
538 | goto out; | 577 | goto out; |
539 | file->private_data = desc; | 578 | file->private_data = desc; |
@@ -543,7 +582,6 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
543 | dev_err(&desc->intf->dev, "Error autopm - %d\n", rv); | 582 | dev_err(&desc->intf->dev, "Error autopm - %d\n", rv); |
544 | goto out; | 583 | goto out; |
545 | } | 584 | } |
546 | intf->needs_remote_wakeup = 1; | ||
547 | 585 | ||
548 | /* using write lock to protect desc->count */ | 586 | /* using write lock to protect desc->count */ |
549 | mutex_lock(&desc->wlock); | 587 | mutex_lock(&desc->wlock); |
@@ -560,6 +598,8 @@ static int wdm_open(struct inode *inode, struct file *file) | |||
560 | rv = 0; | 598 | rv = 0; |
561 | } | 599 | } |
562 | mutex_unlock(&desc->wlock); | 600 | mutex_unlock(&desc->wlock); |
601 | if (desc->count == 1) | ||
602 | desc->manage_power(intf, 1); | ||
563 | usb_autopm_put_interface(desc->intf); | 603 | usb_autopm_put_interface(desc->intf); |
564 | out: | 604 | out: |
565 | mutex_unlock(&wdm_mutex); | 605 | mutex_unlock(&wdm_mutex); |
@@ -581,7 +621,7 @@ static int wdm_release(struct inode *inode, struct file *file) | |||
581 | dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); | 621 | dev_dbg(&desc->intf->dev, "wdm_release: cleanup"); |
582 | kill_urbs(desc); | 622 | kill_urbs(desc); |
583 | if (!test_bit(WDM_DISCONNECTING, &desc->flags)) | 623 | if (!test_bit(WDM_DISCONNECTING, &desc->flags)) |
584 | desc->intf->needs_remote_wakeup = 0; | 624 | desc->manage_power(desc->intf, 0); |
585 | } | 625 | } |
586 | mutex_unlock(&wdm_mutex); | 626 | mutex_unlock(&wdm_mutex); |
587 | return 0; | 627 | return 0; |
@@ -628,71 +668,31 @@ static void wdm_rxwork(struct work_struct *work) | |||
628 | 668 | ||
629 | /* --- hotplug --- */ | 669 | /* --- hotplug --- */ |
630 | 670 | ||
631 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | 671 | static int wdm_create(struct usb_interface *intf, struct usb_endpoint_descriptor *ep, |
672 | u16 bufsize, int (*manage_power)(struct usb_interface *, int)) | ||
632 | { | 673 | { |
633 | int rv = -EINVAL; | 674 | int rv = -ENOMEM; |
634 | struct usb_device *udev = interface_to_usbdev(intf); | ||
635 | struct wdm_device *desc; | 675 | struct wdm_device *desc; |
636 | struct usb_host_interface *iface; | ||
637 | struct usb_endpoint_descriptor *ep; | ||
638 | struct usb_cdc_dmm_desc *dmhd; | ||
639 | u8 *buffer = intf->altsetting->extra; | ||
640 | int buflen = intf->altsetting->extralen; | ||
641 | u16 maxcom = WDM_DEFAULT_BUFSIZE; | ||
642 | |||
643 | if (!buffer) | ||
644 | goto out; | ||
645 | 676 | ||
646 | while (buflen > 2) { | ||
647 | if (buffer [1] != USB_DT_CS_INTERFACE) { | ||
648 | dev_err(&intf->dev, "skipping garbage\n"); | ||
649 | goto next_desc; | ||
650 | } | ||
651 | |||
652 | switch (buffer [2]) { | ||
653 | case USB_CDC_HEADER_TYPE: | ||
654 | break; | ||
655 | case USB_CDC_DMM_TYPE: | ||
656 | dmhd = (struct usb_cdc_dmm_desc *)buffer; | ||
657 | maxcom = le16_to_cpu(dmhd->wMaxCommand); | ||
658 | dev_dbg(&intf->dev, | ||
659 | "Finding maximum buffer length: %d", maxcom); | ||
660 | break; | ||
661 | default: | ||
662 | dev_err(&intf->dev, | ||
663 | "Ignoring extra header, type %d, length %d\n", | ||
664 | buffer[2], buffer[0]); | ||
665 | break; | ||
666 | } | ||
667 | next_desc: | ||
668 | buflen -= buffer[0]; | ||
669 | buffer += buffer[0]; | ||
670 | } | ||
671 | |||
672 | rv = -ENOMEM; | ||
673 | desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); | 677 | desc = kzalloc(sizeof(struct wdm_device), GFP_KERNEL); |
674 | if (!desc) | 678 | if (!desc) |
675 | goto out; | 679 | goto out; |
680 | INIT_LIST_HEAD(&desc->device_list); | ||
676 | mutex_init(&desc->rlock); | 681 | mutex_init(&desc->rlock); |
677 | mutex_init(&desc->wlock); | 682 | mutex_init(&desc->wlock); |
678 | spin_lock_init(&desc->iuspin); | 683 | spin_lock_init(&desc->iuspin); |
679 | init_waitqueue_head(&desc->wait); | 684 | init_waitqueue_head(&desc->wait); |
680 | desc->wMaxCommand = maxcom; | 685 | desc->wMaxCommand = bufsize; |
681 | /* this will be expanded and needed in hardware endianness */ | 686 | /* this will be expanded and needed in hardware endianness */ |
682 | desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber); | 687 | desc->inum = cpu_to_le16((u16)intf->cur_altsetting->desc.bInterfaceNumber); |
683 | desc->intf = intf; | 688 | desc->intf = intf; |
684 | INIT_WORK(&desc->rxwork, wdm_rxwork); | 689 | INIT_WORK(&desc->rxwork, wdm_rxwork); |
685 | 690 | ||
686 | rv = -EINVAL; | 691 | rv = -EINVAL; |
687 | iface = intf->cur_altsetting; | 692 | if (!usb_endpoint_is_int_in(ep)) |
688 | if (iface->desc.bNumEndpoints != 1) | ||
689 | goto err; | ||
690 | ep = &iface->endpoint[0].desc; | ||
691 | if (!ep || !usb_endpoint_is_int_in(ep)) | ||
692 | goto err; | 693 | goto err; |
693 | 694 | ||
694 | desc->wMaxPacketSize = usb_endpoint_maxp(ep); | 695 | desc->wMaxPacketSize = usb_endpoint_maxp(ep); |
695 | desc->bMaxPacketSize0 = udev->descriptor.bMaxPacketSize0; | ||
696 | 696 | ||
697 | desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); | 697 | desc->orq = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL); |
698 | if (!desc->orq) | 698 | if (!desc->orq) |
@@ -717,19 +717,13 @@ next_desc: | |||
717 | if (!desc->ubuf) | 717 | if (!desc->ubuf) |
718 | goto err; | 718 | goto err; |
719 | 719 | ||
720 | desc->sbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 720 | desc->sbuf = kmalloc(desc->wMaxPacketSize, GFP_KERNEL); |
721 | desc->wMaxPacketSize, | ||
722 | GFP_KERNEL, | ||
723 | &desc->validity->transfer_dma); | ||
724 | if (!desc->sbuf) | 721 | if (!desc->sbuf) |
725 | goto err; | 722 | goto err; |
726 | 723 | ||
727 | desc->inbuf = usb_alloc_coherent(interface_to_usbdev(intf), | 724 | desc->inbuf = kmalloc(desc->wMaxCommand, GFP_KERNEL); |
728 | desc->wMaxCommand, | ||
729 | GFP_KERNEL, | ||
730 | &desc->response->transfer_dma); | ||
731 | if (!desc->inbuf) | 725 | if (!desc->inbuf) |
732 | goto err2; | 726 | goto err; |
733 | 727 | ||
734 | usb_fill_int_urb( | 728 | usb_fill_int_urb( |
735 | desc->validity, | 729 | desc->validity, |
@@ -741,45 +735,149 @@ next_desc: | |||
741 | desc, | 735 | desc, |
742 | ep->bInterval | 736 | ep->bInterval |
743 | ); | 737 | ); |
744 | desc->validity->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | ||
745 | 738 | ||
746 | usb_set_intfdata(intf, desc); | 739 | desc->irq->bRequestType = (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE); |
740 | desc->irq->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; | ||
741 | desc->irq->wValue = 0; | ||
742 | desc->irq->wIndex = desc->inum; | ||
743 | desc->irq->wLength = cpu_to_le16(desc->wMaxCommand); | ||
744 | |||
745 | usb_fill_control_urb( | ||
746 | desc->response, | ||
747 | interface_to_usbdev(intf), | ||
748 | /* using common endpoint 0 */ | ||
749 | usb_rcvctrlpipe(interface_to_usbdev(desc->intf), 0), | ||
750 | (unsigned char *)desc->irq, | ||
751 | desc->inbuf, | ||
752 | desc->wMaxCommand, | ||
753 | wdm_in_callback, | ||
754 | desc | ||
755 | ); | ||
756 | |||
757 | desc->manage_power = manage_power; | ||
758 | |||
759 | spin_lock(&wdm_device_list_lock); | ||
760 | list_add(&desc->device_list, &wdm_device_list); | ||
761 | spin_unlock(&wdm_device_list_lock); | ||
762 | |||
747 | rv = usb_register_dev(intf, &wdm_class); | 763 | rv = usb_register_dev(intf, &wdm_class); |
748 | if (rv < 0) | 764 | if (rv < 0) |
749 | goto err3; | 765 | goto err; |
750 | else | 766 | else |
751 | dev_info(&intf->dev, "cdc-wdm%d: USB WDM device\n", | 767 | dev_info(&intf->dev, "%s: USB WDM device\n", dev_name(intf->usb_dev)); |
752 | intf->minor - WDM_MINOR_BASE); | ||
753 | out: | 768 | out: |
754 | return rv; | 769 | return rv; |
755 | err3: | ||
756 | usb_set_intfdata(intf, NULL); | ||
757 | usb_free_coherent(interface_to_usbdev(desc->intf), | ||
758 | desc->bMaxPacketSize0, | ||
759 | desc->inbuf, | ||
760 | desc->response->transfer_dma); | ||
761 | err2: | ||
762 | usb_free_coherent(interface_to_usbdev(desc->intf), | ||
763 | desc->wMaxPacketSize, | ||
764 | desc->sbuf, | ||
765 | desc->validity->transfer_dma); | ||
766 | err: | 770 | err: |
767 | free_urbs(desc); | 771 | cleanup(desc); |
768 | kfree(desc->ubuf); | 772 | return rv; |
769 | kfree(desc->orq); | 773 | } |
770 | kfree(desc->irq); | 774 | |
771 | kfree(desc); | 775 | static int wdm_manage_power(struct usb_interface *intf, int on) |
776 | { | ||
777 | /* need autopm_get/put here to ensure the usbcore sees the new value */ | ||
778 | int rv = usb_autopm_get_interface(intf); | ||
779 | if (rv < 0) | ||
780 | goto err; | ||
781 | |||
782 | intf->needs_remote_wakeup = on; | ||
783 | usb_autopm_put_interface(intf); | ||
784 | err: | ||
785 | return rv; | ||
786 | } | ||
787 | |||
788 | static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id) | ||
789 | { | ||
790 | int rv = -EINVAL; | ||
791 | struct usb_host_interface *iface; | ||
792 | struct usb_endpoint_descriptor *ep; | ||
793 | struct usb_cdc_dmm_desc *dmhd; | ||
794 | u8 *buffer = intf->altsetting->extra; | ||
795 | int buflen = intf->altsetting->extralen; | ||
796 | u16 maxcom = WDM_DEFAULT_BUFSIZE; | ||
797 | |||
798 | if (!buffer) | ||
799 | goto err; | ||
800 | while (buflen > 2) { | ||
801 | if (buffer[1] != USB_DT_CS_INTERFACE) { | ||
802 | dev_err(&intf->dev, "skipping garbage\n"); | ||
803 | goto next_desc; | ||
804 | } | ||
805 | |||
806 | switch (buffer[2]) { | ||
807 | case USB_CDC_HEADER_TYPE: | ||
808 | break; | ||
809 | case USB_CDC_DMM_TYPE: | ||
810 | dmhd = (struct usb_cdc_dmm_desc *)buffer; | ||
811 | maxcom = le16_to_cpu(dmhd->wMaxCommand); | ||
812 | dev_dbg(&intf->dev, | ||
813 | "Finding maximum buffer length: %d", maxcom); | ||
814 | break; | ||
815 | default: | ||
816 | dev_err(&intf->dev, | ||
817 | "Ignoring extra header, type %d, length %d\n", | ||
818 | buffer[2], buffer[0]); | ||
819 | break; | ||
820 | } | ||
821 | next_desc: | ||
822 | buflen -= buffer[0]; | ||
823 | buffer += buffer[0]; | ||
824 | } | ||
825 | |||
826 | iface = intf->cur_altsetting; | ||
827 | if (iface->desc.bNumEndpoints != 1) | ||
828 | goto err; | ||
829 | ep = &iface->endpoint[0].desc; | ||
830 | |||
831 | rv = wdm_create(intf, ep, maxcom, &wdm_manage_power); | ||
832 | |||
833 | err: | ||
772 | return rv; | 834 | return rv; |
773 | } | 835 | } |
774 | 836 | ||
837 | /** | ||
838 | * usb_cdc_wdm_register - register a WDM subdriver | ||
839 | * @intf: usb interface the subdriver will associate with | ||
840 | * @ep: interrupt endpoint to monitor for notifications | ||
841 | * @bufsize: maximum message size to support for read/write | ||
842 | * | ||
843 | * Create WDM usb class character device and associate it with intf | ||
844 | * without binding, allowing another driver to manage the interface. | ||
845 | * | ||
846 | * The subdriver will manage the given interrupt endpoint exclusively | ||
847 | * and will issue control requests referring to the given intf. It | ||
848 | * will otherwise avoid interferring, and in particular not do | ||
849 | * usb_set_intfdata/usb_get_intfdata on intf. | ||
850 | * | ||
851 | * The return value is a pointer to the subdriver's struct usb_driver. | ||
852 | * The registering driver is responsible for calling this subdriver's | ||
853 | * disconnect, suspend, resume, pre_reset and post_reset methods from | ||
854 | * its own. | ||
855 | */ | ||
856 | struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf, | ||
857 | struct usb_endpoint_descriptor *ep, | ||
858 | int bufsize, | ||
859 | int (*manage_power)(struct usb_interface *, int)) | ||
860 | { | ||
861 | int rv = -EINVAL; | ||
862 | |||
863 | rv = wdm_create(intf, ep, bufsize, manage_power); | ||
864 | if (rv < 0) | ||
865 | goto err; | ||
866 | |||
867 | return &wdm_driver; | ||
868 | err: | ||
869 | return ERR_PTR(rv); | ||
870 | } | ||
871 | EXPORT_SYMBOL(usb_cdc_wdm_register); | ||
872 | |||
775 | static void wdm_disconnect(struct usb_interface *intf) | 873 | static void wdm_disconnect(struct usb_interface *intf) |
776 | { | 874 | { |
777 | struct wdm_device *desc; | 875 | struct wdm_device *desc; |
778 | unsigned long flags; | 876 | unsigned long flags; |
779 | 877 | ||
780 | usb_deregister_dev(intf, &wdm_class); | 878 | usb_deregister_dev(intf, &wdm_class); |
879 | desc = wdm_find_device(intf); | ||
781 | mutex_lock(&wdm_mutex); | 880 | mutex_lock(&wdm_mutex); |
782 | desc = usb_get_intfdata(intf); | ||
783 | 881 | ||
784 | /* the spinlock makes sure no new urbs are generated in the callbacks */ | 882 | /* the spinlock makes sure no new urbs are generated in the callbacks */ |
785 | spin_lock_irqsave(&desc->iuspin, flags); | 883 | spin_lock_irqsave(&desc->iuspin, flags); |
@@ -803,7 +901,7 @@ static void wdm_disconnect(struct usb_interface *intf) | |||
803 | #ifdef CONFIG_PM | 901 | #ifdef CONFIG_PM |
804 | static int wdm_suspend(struct usb_interface *intf, pm_message_t message) | 902 | static int wdm_suspend(struct usb_interface *intf, pm_message_t message) |
805 | { | 903 | { |
806 | struct wdm_device *desc = usb_get_intfdata(intf); | 904 | struct wdm_device *desc = wdm_find_device(intf); |
807 | int rv = 0; | 905 | int rv = 0; |
808 | 906 | ||
809 | dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); | 907 | dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); |
@@ -853,7 +951,7 @@ static int recover_from_urb_loss(struct wdm_device *desc) | |||
853 | #ifdef CONFIG_PM | 951 | #ifdef CONFIG_PM |
854 | static int wdm_resume(struct usb_interface *intf) | 952 | static int wdm_resume(struct usb_interface *intf) |
855 | { | 953 | { |
856 | struct wdm_device *desc = usb_get_intfdata(intf); | 954 | struct wdm_device *desc = wdm_find_device(intf); |
857 | int rv; | 955 | int rv; |
858 | 956 | ||
859 | dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor); | 957 | dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor); |
@@ -867,11 +965,7 @@ static int wdm_resume(struct usb_interface *intf) | |||
867 | 965 | ||
868 | static int wdm_pre_reset(struct usb_interface *intf) | 966 | static int wdm_pre_reset(struct usb_interface *intf) |
869 | { | 967 | { |
870 | struct wdm_device *desc = usb_get_intfdata(intf); | 968 | struct wdm_device *desc = wdm_find_device(intf); |
871 | |||
872 | mutex_lock(&desc->rlock); | ||
873 | mutex_lock(&desc->wlock); | ||
874 | kill_urbs(desc); | ||
875 | 969 | ||
876 | /* | 970 | /* |
877 | * we notify everybody using poll of | 971 | * we notify everybody using poll of |
@@ -880,17 +974,25 @@ static int wdm_pre_reset(struct usb_interface *intf) | |||
880 | * message from the device is lost | 974 | * message from the device is lost |
881 | */ | 975 | */ |
882 | spin_lock_irq(&desc->iuspin); | 976 | spin_lock_irq(&desc->iuspin); |
977 | set_bit(WDM_RESETTING, &desc->flags); /* inform read/write */ | ||
978 | set_bit(WDM_READ, &desc->flags); /* unblock read */ | ||
979 | clear_bit(WDM_IN_USE, &desc->flags); /* unblock write */ | ||
883 | desc->rerr = -EINTR; | 980 | desc->rerr = -EINTR; |
884 | spin_unlock_irq(&desc->iuspin); | 981 | spin_unlock_irq(&desc->iuspin); |
885 | wake_up_all(&desc->wait); | 982 | wake_up_all(&desc->wait); |
983 | mutex_lock(&desc->rlock); | ||
984 | mutex_lock(&desc->wlock); | ||
985 | kill_urbs(desc); | ||
986 | cancel_work_sync(&desc->rxwork); | ||
886 | return 0; | 987 | return 0; |
887 | } | 988 | } |
888 | 989 | ||
889 | static int wdm_post_reset(struct usb_interface *intf) | 990 | static int wdm_post_reset(struct usb_interface *intf) |
890 | { | 991 | { |
891 | struct wdm_device *desc = usb_get_intfdata(intf); | 992 | struct wdm_device *desc = wdm_find_device(intf); |
892 | int rv; | 993 | int rv; |
893 | 994 | ||
995 | clear_bit(WDM_RESETTING, &desc->flags); | ||
894 | rv = recover_from_urb_loss(desc); | 996 | rv = recover_from_urb_loss(desc); |
895 | mutex_unlock(&desc->wlock); | 997 | mutex_unlock(&desc->wlock); |
896 | mutex_unlock(&desc->rlock); | 998 | mutex_unlock(&desc->rlock); |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 4fee024ecc9b..f8e2d6d52e5c 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -934,13 +934,8 @@ void usb_rebind_intf(struct usb_interface *intf) | |||
934 | int rc; | 934 | int rc; |
935 | 935 | ||
936 | /* Delayed unbind of an existing driver */ | 936 | /* Delayed unbind of an existing driver */ |
937 | if (intf->dev.driver) { | 937 | if (intf->dev.driver) |
938 | struct usb_driver *driver = | 938 | usb_forced_unbind_intf(intf); |
939 | to_usb_driver(intf->dev.driver); | ||
940 | |||
941 | dev_dbg(&intf->dev, "forced unbind\n"); | ||
942 | usb_driver_release_interface(driver, intf); | ||
943 | } | ||
944 | 939 | ||
945 | /* Try to rebind the interface */ | 940 | /* Try to rebind the interface */ |
946 | if (!intf->dev.power.is_prepared) { | 941 | if (!intf->dev.power.is_prepared) { |
@@ -953,15 +948,13 @@ void usb_rebind_intf(struct usb_interface *intf) | |||
953 | 948 | ||
954 | #ifdef CONFIG_PM | 949 | #ifdef CONFIG_PM |
955 | 950 | ||
956 | #define DO_UNBIND 0 | 951 | /* Unbind drivers for @udev's interfaces that don't support suspend/resume |
957 | #define DO_REBIND 1 | 952 | * There is no check for reset_resume here because it can be determined |
958 | 953 | * only during resume whether reset_resume is needed. | |
959 | /* Unbind drivers for @udev's interfaces that don't support suspend/resume, | ||
960 | * or rebind interfaces that have been unbound, according to @action. | ||
961 | * | 954 | * |
962 | * The caller must hold @udev's device lock. | 955 | * The caller must hold @udev's device lock. |
963 | */ | 956 | */ |
964 | static void do_unbind_rebind(struct usb_device *udev, int action) | 957 | static void unbind_no_pm_drivers_interfaces(struct usb_device *udev) |
965 | { | 958 | { |
966 | struct usb_host_config *config; | 959 | struct usb_host_config *config; |
967 | int i; | 960 | int i; |
@@ -972,23 +965,53 @@ static void do_unbind_rebind(struct usb_device *udev, int action) | |||
972 | if (config) { | 965 | if (config) { |
973 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | 966 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { |
974 | intf = config->interface[i]; | 967 | intf = config->interface[i]; |
975 | switch (action) { | 968 | |
976 | case DO_UNBIND: | 969 | if (intf->dev.driver) { |
977 | if (intf->dev.driver) { | 970 | drv = to_usb_driver(intf->dev.driver); |
978 | drv = to_usb_driver(intf->dev.driver); | 971 | if (!drv->suspend || !drv->resume) |
979 | if (!drv->suspend || !drv->resume) | 972 | usb_forced_unbind_intf(intf); |
980 | usb_forced_unbind_intf(intf); | ||
981 | } | ||
982 | break; | ||
983 | case DO_REBIND: | ||
984 | if (intf->needs_binding) | ||
985 | usb_rebind_intf(intf); | ||
986 | break; | ||
987 | } | 973 | } |
988 | } | 974 | } |
989 | } | 975 | } |
990 | } | 976 | } |
991 | 977 | ||
978 | /* Unbind drivers for @udev's interfaces that failed to support reset-resume. | ||
979 | * These interfaces have the needs_binding flag set by usb_resume_interface(). | ||
980 | * | ||
981 | * The caller must hold @udev's device lock. | ||
982 | */ | ||
983 | static void unbind_no_reset_resume_drivers_interfaces(struct usb_device *udev) | ||
984 | { | ||
985 | struct usb_host_config *config; | ||
986 | int i; | ||
987 | struct usb_interface *intf; | ||
988 | |||
989 | config = udev->actconfig; | ||
990 | if (config) { | ||
991 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | ||
992 | intf = config->interface[i]; | ||
993 | if (intf->dev.driver && intf->needs_binding) | ||
994 | usb_forced_unbind_intf(intf); | ||
995 | } | ||
996 | } | ||
997 | } | ||
998 | |||
999 | static void do_rebind_interfaces(struct usb_device *udev) | ||
1000 | { | ||
1001 | struct usb_host_config *config; | ||
1002 | int i; | ||
1003 | struct usb_interface *intf; | ||
1004 | |||
1005 | config = udev->actconfig; | ||
1006 | if (config) { | ||
1007 | for (i = 0; i < config->desc.bNumInterfaces; ++i) { | ||
1008 | intf = config->interface[i]; | ||
1009 | if (intf->needs_binding) | ||
1010 | usb_rebind_intf(intf); | ||
1011 | } | ||
1012 | } | ||
1013 | } | ||
1014 | |||
992 | static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) | 1015 | static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) |
993 | { | 1016 | { |
994 | struct usb_device_driver *udriver; | 1017 | struct usb_device_driver *udriver; |
@@ -1278,35 +1301,48 @@ int usb_suspend(struct device *dev, pm_message_t msg) | |||
1278 | { | 1301 | { |
1279 | struct usb_device *udev = to_usb_device(dev); | 1302 | struct usb_device *udev = to_usb_device(dev); |
1280 | 1303 | ||
1281 | do_unbind_rebind(udev, DO_UNBIND); | 1304 | unbind_no_pm_drivers_interfaces(udev); |
1305 | |||
1306 | /* From now on we are sure all drivers support suspend/resume | ||
1307 | * but not necessarily reset_resume() | ||
1308 | * so we may still need to unbind and rebind upon resume | ||
1309 | */ | ||
1282 | choose_wakeup(udev, msg); | 1310 | choose_wakeup(udev, msg); |
1283 | return usb_suspend_both(udev, msg); | 1311 | return usb_suspend_both(udev, msg); |
1284 | } | 1312 | } |
1285 | 1313 | ||
1286 | /* The device lock is held by the PM core */ | 1314 | /* The device lock is held by the PM core */ |
1315 | int usb_resume_complete(struct device *dev) | ||
1316 | { | ||
1317 | struct usb_device *udev = to_usb_device(dev); | ||
1318 | |||
1319 | /* For PM complete calls, all we do is rebind interfaces | ||
1320 | * whose needs_binding flag is set | ||
1321 | */ | ||
1322 | if (udev->state != USB_STATE_NOTATTACHED) | ||
1323 | do_rebind_interfaces(udev); | ||
1324 | return 0; | ||
1325 | } | ||
1326 | |||
1327 | /* The device lock is held by the PM core */ | ||
1287 | int usb_resume(struct device *dev, pm_message_t msg) | 1328 | int usb_resume(struct device *dev, pm_message_t msg) |
1288 | { | 1329 | { |
1289 | struct usb_device *udev = to_usb_device(dev); | 1330 | struct usb_device *udev = to_usb_device(dev); |
1290 | int status; | 1331 | int status; |
1291 | 1332 | ||
1292 | /* For PM complete calls, all we do is rebind interfaces */ | 1333 | /* For all calls, take the device back to full power and |
1293 | if (msg.event == PM_EVENT_ON) { | ||
1294 | if (udev->state != USB_STATE_NOTATTACHED) | ||
1295 | do_unbind_rebind(udev, DO_REBIND); | ||
1296 | status = 0; | ||
1297 | |||
1298 | /* For all other calls, take the device back to full power and | ||
1299 | * tell the PM core in case it was autosuspended previously. | 1334 | * tell the PM core in case it was autosuspended previously. |
1300 | * Unbind the interfaces that will need rebinding later. | 1335 | * Unbind the interfaces that will need rebinding later, |
1336 | * because they fail to support reset_resume. | ||
1337 | * (This can't be done in usb_resume_interface() | ||
1338 | * above because it doesn't own the right set of locks.) | ||
1301 | */ | 1339 | */ |
1302 | } else { | 1340 | status = usb_resume_both(udev, msg); |
1303 | status = usb_resume_both(udev, msg); | 1341 | if (status == 0) { |
1304 | if (status == 0) { | 1342 | pm_runtime_disable(dev); |
1305 | pm_runtime_disable(dev); | 1343 | pm_runtime_set_active(dev); |
1306 | pm_runtime_set_active(dev); | 1344 | pm_runtime_enable(dev); |
1307 | pm_runtime_enable(dev); | 1345 | unbind_no_reset_resume_drivers_interfaces(udev); |
1308 | do_unbind_rebind(udev, DO_REBIND); | ||
1309 | } | ||
1310 | } | 1346 | } |
1311 | 1347 | ||
1312 | /* Avoid PM error messages for devices disconnected while suspended | 1348 | /* Avoid PM error messages for devices disconnected while suspended |
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 81e2c0d9c17d..622b4a48e732 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -380,6 +380,7 @@ static int check_root_hub_suspended(struct device *dev) | |||
380 | return 0; | 380 | return 0; |
381 | } | 381 | } |
382 | 382 | ||
383 | #if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME) | ||
383 | static int suspend_common(struct device *dev, bool do_wakeup) | 384 | static int suspend_common(struct device *dev, bool do_wakeup) |
384 | { | 385 | { |
385 | struct pci_dev *pci_dev = to_pci_dev(dev); | 386 | struct pci_dev *pci_dev = to_pci_dev(dev); |
@@ -471,6 +472,7 @@ static int resume_common(struct device *dev, int event) | |||
471 | } | 472 | } |
472 | return retval; | 473 | return retval; |
473 | } | 474 | } |
475 | #endif /* SLEEP || RUNTIME */ | ||
474 | 476 | ||
475 | #ifdef CONFIG_PM_SLEEP | 477 | #ifdef CONFIG_PM_SLEEP |
476 | 478 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index e1282328fc27..9d7fc9a39933 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -2352,7 +2352,7 @@ static int usb_hcd_request_irqs(struct usb_hcd *hcd, | |||
2352 | "io mem" : "io base", | 2352 | "io mem" : "io base", |
2353 | (unsigned long long)hcd->rsrc_start); | 2353 | (unsigned long long)hcd->rsrc_start); |
2354 | } else { | 2354 | } else { |
2355 | hcd->irq = -1; | 2355 | hcd->irq = 0; |
2356 | if (hcd->rsrc_start) | 2356 | if (hcd->rsrc_start) |
2357 | dev_info(hcd->self.controller, "%s 0x%08llx\n", | 2357 | dev_info(hcd->self.controller, "%s 0x%08llx\n", |
2358 | (hcd->driver->flags & HCD_MEMORY) ? | 2358 | (hcd->driver->flags & HCD_MEMORY) ? |
@@ -2508,7 +2508,7 @@ err_register_root_hub: | |||
2508 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); | 2508 | clear_bit(HCD_FLAG_POLL_RH, &hcd->flags); |
2509 | del_timer_sync(&hcd->rh_timer); | 2509 | del_timer_sync(&hcd->rh_timer); |
2510 | err_hcd_driver_start: | 2510 | err_hcd_driver_start: |
2511 | if (usb_hcd_is_primary_hcd(hcd) && hcd->irq >= 0) | 2511 | if (usb_hcd_is_primary_hcd(hcd) && hcd->irq > 0) |
2512 | free_irq(irqnum, hcd); | 2512 | free_irq(irqnum, hcd); |
2513 | err_request_irq: | 2513 | err_request_irq: |
2514 | err_hcd_driver_setup: | 2514 | err_hcd_driver_setup: |
@@ -2573,7 +2573,7 @@ void usb_remove_hcd(struct usb_hcd *hcd) | |||
2573 | del_timer_sync(&hcd->rh_timer); | 2573 | del_timer_sync(&hcd->rh_timer); |
2574 | 2574 | ||
2575 | if (usb_hcd_is_primary_hcd(hcd)) { | 2575 | if (usb_hcd_is_primary_hcd(hcd)) { |
2576 | if (hcd->irq >= 0) | 2576 | if (hcd->irq > 0) |
2577 | free_irq(hcd->irq, hcd); | 2577 | free_irq(hcd->irq, hcd); |
2578 | } | 2578 | } |
2579 | 2579 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 265c2f675d04..28664eb7f555 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -62,6 +62,8 @@ struct usb_hub { | |||
62 | resumed */ | 62 | resumed */ |
63 | unsigned long removed_bits[1]; /* ports with a "removed" | 63 | unsigned long removed_bits[1]; /* ports with a "removed" |
64 | device present */ | 64 | device present */ |
65 | unsigned long wakeup_bits[1]; /* ports that have signaled | ||
66 | remote wakeup */ | ||
65 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ | 67 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ |
66 | #error event_bits[] is too short! | 68 | #error event_bits[] is too short! |
67 | #endif | 69 | #endif |
@@ -411,6 +413,29 @@ void usb_kick_khubd(struct usb_device *hdev) | |||
411 | kick_khubd(hub); | 413 | kick_khubd(hub); |
412 | } | 414 | } |
413 | 415 | ||
416 | /* | ||
417 | * Let the USB core know that a USB 3.0 device has sent a Function Wake Device | ||
418 | * Notification, which indicates it had initiated remote wakeup. | ||
419 | * | ||
420 | * USB 3.0 hubs do not report the port link state change from U3 to U0 when the | ||
421 | * device initiates resume, so the USB core will not receive notice of the | ||
422 | * resume through the normal hub interrupt URB. | ||
423 | */ | ||
424 | void usb_wakeup_notification(struct usb_device *hdev, | ||
425 | unsigned int portnum) | ||
426 | { | ||
427 | struct usb_hub *hub; | ||
428 | |||
429 | if (!hdev) | ||
430 | return; | ||
431 | |||
432 | hub = hdev_to_hub(hdev); | ||
433 | if (hub) { | ||
434 | set_bit(portnum, hub->wakeup_bits); | ||
435 | kick_khubd(hub); | ||
436 | } | ||
437 | } | ||
438 | EXPORT_SYMBOL_GPL(usb_wakeup_notification); | ||
414 | 439 | ||
415 | /* completion function, fires on port status changes and various faults */ | 440 | /* completion function, fires on port status changes and various faults */ |
416 | static void hub_irq(struct urb *urb) | 441 | static void hub_irq(struct urb *urb) |
@@ -823,12 +848,6 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
823 | clear_port_feature(hub->hdev, port1, | 848 | clear_port_feature(hub->hdev, port1, |
824 | USB_PORT_FEAT_C_ENABLE); | 849 | USB_PORT_FEAT_C_ENABLE); |
825 | } | 850 | } |
826 | if (portchange & USB_PORT_STAT_C_LINK_STATE) { | ||
827 | need_debounce_delay = true; | ||
828 | clear_port_feature(hub->hdev, port1, | ||
829 | USB_PORT_FEAT_C_PORT_LINK_STATE); | ||
830 | } | ||
831 | |||
832 | if ((portchange & USB_PORT_STAT_C_BH_RESET) && | 851 | if ((portchange & USB_PORT_STAT_C_BH_RESET) && |
833 | hub_is_superspeed(hub->hdev)) { | 852 | hub_is_superspeed(hub->hdev)) { |
834 | need_debounce_delay = true; | 853 | need_debounce_delay = true; |
@@ -850,12 +869,19 @@ static void hub_activate(struct usb_hub *hub, enum hub_activation_type type) | |||
850 | set_bit(port1, hub->change_bits); | 869 | set_bit(port1, hub->change_bits); |
851 | 870 | ||
852 | } else if (portstatus & USB_PORT_STAT_ENABLE) { | 871 | } else if (portstatus & USB_PORT_STAT_ENABLE) { |
872 | bool port_resumed = (portstatus & | ||
873 | USB_PORT_STAT_LINK_STATE) == | ||
874 | USB_SS_PORT_LS_U0; | ||
853 | /* The power session apparently survived the resume. | 875 | /* The power session apparently survived the resume. |
854 | * If there was an overcurrent or suspend change | 876 | * If there was an overcurrent or suspend change |
855 | * (i.e., remote wakeup request), have khubd | 877 | * (i.e., remote wakeup request), have khubd |
856 | * take care of it. | 878 | * take care of it. Look at the port link state |
879 | * for USB 3.0 hubs, since they don't have a suspend | ||
880 | * change bit, and they don't set the port link change | ||
881 | * bit on device-initiated resume. | ||
857 | */ | 882 | */ |
858 | if (portchange) | 883 | if (portchange || (hub_is_superspeed(hub->hdev) && |
884 | port_resumed)) | ||
859 | set_bit(port1, hub->change_bits); | 885 | set_bit(port1, hub->change_bits); |
860 | 886 | ||
861 | } else if (udev->persist_enabled) { | 887 | } else if (udev->persist_enabled) { |
@@ -1021,8 +1047,10 @@ static int hub_configure(struct usb_hub *hub, | |||
1021 | dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, | 1047 | dev_info (hub_dev, "%d port%s detected\n", hdev->maxchild, |
1022 | (hdev->maxchild == 1) ? "" : "s"); | 1048 | (hdev->maxchild == 1) ? "" : "s"); |
1023 | 1049 | ||
1050 | hdev->children = kzalloc(hdev->maxchild * | ||
1051 | sizeof(struct usb_device *), GFP_KERNEL); | ||
1024 | hub->port_owners = kzalloc(hdev->maxchild * sizeof(void *), GFP_KERNEL); | 1052 | hub->port_owners = kzalloc(hdev->maxchild * sizeof(void *), GFP_KERNEL); |
1025 | if (!hub->port_owners) { | 1053 | if (!hdev->children || !hub->port_owners) { |
1026 | ret = -ENOMEM; | 1054 | ret = -ENOMEM; |
1027 | goto fail; | 1055 | goto fail; |
1028 | } | 1056 | } |
@@ -1253,7 +1281,8 @@ static unsigned highspeed_hubs; | |||
1253 | 1281 | ||
1254 | static void hub_disconnect(struct usb_interface *intf) | 1282 | static void hub_disconnect(struct usb_interface *intf) |
1255 | { | 1283 | { |
1256 | struct usb_hub *hub = usb_get_intfdata (intf); | 1284 | struct usb_hub *hub = usb_get_intfdata(intf); |
1285 | struct usb_device *hdev = interface_to_usbdev(intf); | ||
1257 | 1286 | ||
1258 | /* Take the hub off the event list and don't let it be added again */ | 1287 | /* Take the hub off the event list and don't let it be added again */ |
1259 | spin_lock_irq(&hub_event_lock); | 1288 | spin_lock_irq(&hub_event_lock); |
@@ -1275,6 +1304,7 @@ static void hub_disconnect(struct usb_interface *intf) | |||
1275 | highspeed_hubs--; | 1304 | highspeed_hubs--; |
1276 | 1305 | ||
1277 | usb_free_urb(hub->urb); | 1306 | usb_free_urb(hub->urb); |
1307 | kfree(hdev->children); | ||
1278 | kfree(hub->port_owners); | 1308 | kfree(hub->port_owners); |
1279 | kfree(hub->descriptor); | 1309 | kfree(hub->descriptor); |
1280 | kfree(hub->status); | 1310 | kfree(hub->status); |
@@ -1293,14 +1323,8 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
1293 | desc = intf->cur_altsetting; | 1323 | desc = intf->cur_altsetting; |
1294 | hdev = interface_to_usbdev(intf); | 1324 | hdev = interface_to_usbdev(intf); |
1295 | 1325 | ||
1296 | /* Hubs have proper suspend/resume support. USB 3.0 device suspend is | 1326 | /* Hubs have proper suspend/resume support. */ |
1297 | * different from USB 2.0/1.1 device suspend, and unfortunately we | 1327 | usb_enable_autosuspend(hdev); |
1298 | * don't support it yet. So leave autosuspend disabled for USB 3.0 | ||
1299 | * external hubs for now. Enable autosuspend for USB 3.0 roothubs, | ||
1300 | * since that isn't a "real" hub. | ||
1301 | */ | ||
1302 | if (!hub_is_superspeed(hdev) || !hdev->parent) | ||
1303 | usb_enable_autosuspend(hdev); | ||
1304 | 1328 | ||
1305 | if (hdev->level == MAX_TOPO_LEVEL) { | 1329 | if (hdev->level == MAX_TOPO_LEVEL) { |
1306 | dev_err(&intf->dev, | 1330 | dev_err(&intf->dev, |
@@ -1656,7 +1680,7 @@ void usb_disconnect(struct usb_device **pdev) | |||
1656 | usb_lock_device(udev); | 1680 | usb_lock_device(udev); |
1657 | 1681 | ||
1658 | /* Free up all the children before we remove this device */ | 1682 | /* Free up all the children before we remove this device */ |
1659 | for (i = 0; i < USB_MAXCHILDREN; i++) { | 1683 | for (i = 0; i < udev->maxchild; i++) { |
1660 | if (udev->children[i]) | 1684 | if (udev->children[i]) |
1661 | usb_disconnect(&udev->children[i]); | 1685 | usb_disconnect(&udev->children[i]); |
1662 | } | 1686 | } |
@@ -1842,6 +1866,37 @@ fail: | |||
1842 | return err; | 1866 | return err; |
1843 | } | 1867 | } |
1844 | 1868 | ||
1869 | static void set_usb_port_removable(struct usb_device *udev) | ||
1870 | { | ||
1871 | struct usb_device *hdev = udev->parent; | ||
1872 | struct usb_hub *hub; | ||
1873 | u8 port = udev->portnum; | ||
1874 | u16 wHubCharacteristics; | ||
1875 | bool removable = true; | ||
1876 | |||
1877 | if (!hdev) | ||
1878 | return; | ||
1879 | |||
1880 | hub = hdev_to_hub(udev->parent); | ||
1881 | |||
1882 | wHubCharacteristics = le16_to_cpu(hub->descriptor->wHubCharacteristics); | ||
1883 | |||
1884 | if (!(wHubCharacteristics & HUB_CHAR_COMPOUND)) | ||
1885 | return; | ||
1886 | |||
1887 | if (hub_is_superspeed(hdev)) { | ||
1888 | if (hub->descriptor->u.ss.DeviceRemovable & (1 << port)) | ||
1889 | removable = false; | ||
1890 | } else { | ||
1891 | if (hub->descriptor->u.hs.DeviceRemovable[port / 8] & (1 << (port % 8))) | ||
1892 | removable = false; | ||
1893 | } | ||
1894 | |||
1895 | if (removable) | ||
1896 | udev->removable = USB_DEVICE_REMOVABLE; | ||
1897 | else | ||
1898 | udev->removable = USB_DEVICE_FIXED; | ||
1899 | } | ||
1845 | 1900 | ||
1846 | /** | 1901 | /** |
1847 | * usb_new_device - perform initial device setup (usbcore-internal) | 1902 | * usb_new_device - perform initial device setup (usbcore-internal) |
@@ -1900,6 +1955,15 @@ int usb_new_device(struct usb_device *udev) | |||
1900 | announce_device(udev); | 1955 | announce_device(udev); |
1901 | 1956 | ||
1902 | device_enable_async_suspend(&udev->dev); | 1957 | device_enable_async_suspend(&udev->dev); |
1958 | |||
1959 | /* | ||
1960 | * check whether the hub marks this port as non-removable. Do it | ||
1961 | * now so that platform-specific data can override it in | ||
1962 | * device_add() | ||
1963 | */ | ||
1964 | if (udev->parent) | ||
1965 | set_usb_port_removable(udev); | ||
1966 | |||
1903 | /* Register the device. The device driver is responsible | 1967 | /* Register the device. The device driver is responsible |
1904 | * for configuring the device and invoking the add-device | 1968 | * for configuring the device and invoking the add-device |
1905 | * notifier chain (used by usbfs and possibly others). | 1969 | * notifier chain (used by usbfs and possibly others). |
@@ -2385,11 +2449,27 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) | |||
2385 | * we don't explicitly enable it here. | 2449 | * we don't explicitly enable it here. |
2386 | */ | 2450 | */ |
2387 | if (udev->do_remote_wakeup) { | 2451 | if (udev->do_remote_wakeup) { |
2388 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | 2452 | if (!hub_is_superspeed(hub->hdev)) { |
2389 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, | 2453 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), |
2390 | USB_DEVICE_REMOTE_WAKEUP, 0, | 2454 | USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, |
2391 | NULL, 0, | 2455 | USB_DEVICE_REMOTE_WAKEUP, 0, |
2392 | USB_CTRL_SET_TIMEOUT); | 2456 | NULL, 0, |
2457 | USB_CTRL_SET_TIMEOUT); | ||
2458 | } else { | ||
2459 | /* Assume there's only one function on the USB 3.0 | ||
2460 | * device and enable remote wake for the first | ||
2461 | * interface. FIXME if the interface association | ||
2462 | * descriptor shows there's more than one function. | ||
2463 | */ | ||
2464 | status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), | ||
2465 | USB_REQ_SET_FEATURE, | ||
2466 | USB_RECIP_INTERFACE, | ||
2467 | USB_INTRF_FUNC_SUSPEND, | ||
2468 | USB_INTRF_FUNC_SUSPEND_RW | | ||
2469 | USB_INTRF_FUNC_SUSPEND_LP, | ||
2470 | NULL, 0, | ||
2471 | USB_CTRL_SET_TIMEOUT); | ||
2472 | } | ||
2393 | if (status) { | 2473 | if (status) { |
2394 | dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", | 2474 | dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", |
2395 | status); | 2475 | status); |
@@ -2679,6 +2759,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
2679 | struct usb_hub *hub = usb_get_intfdata (intf); | 2759 | struct usb_hub *hub = usb_get_intfdata (intf); |
2680 | struct usb_device *hdev = hub->hdev; | 2760 | struct usb_device *hdev = hub->hdev; |
2681 | unsigned port1; | 2761 | unsigned port1; |
2762 | int status; | ||
2682 | 2763 | ||
2683 | /* Warn if children aren't already suspended */ | 2764 | /* Warn if children aren't already suspended */ |
2684 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | 2765 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { |
@@ -2691,6 +2772,17 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
2691 | return -EBUSY; | 2772 | return -EBUSY; |
2692 | } | 2773 | } |
2693 | } | 2774 | } |
2775 | if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) { | ||
2776 | /* Enable hub to send remote wakeup for all ports. */ | ||
2777 | for (port1 = 1; port1 <= hdev->maxchild; port1++) { | ||
2778 | status = set_port_feature(hdev, | ||
2779 | port1 | | ||
2780 | USB_PORT_FEAT_REMOTE_WAKE_CONNECT | | ||
2781 | USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT | | ||
2782 | USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT, | ||
2783 | USB_PORT_FEAT_REMOTE_WAKE_MASK); | ||
2784 | } | ||
2785 | } | ||
2694 | 2786 | ||
2695 | dev_dbg(&intf->dev, "%s\n", __func__); | 2787 | dev_dbg(&intf->dev, "%s\n", __func__); |
2696 | 2788 | ||
@@ -3424,6 +3516,46 @@ done: | |||
3424 | hcd->driver->relinquish_port(hcd, port1); | 3516 | hcd->driver->relinquish_port(hcd, port1); |
3425 | } | 3517 | } |
3426 | 3518 | ||
3519 | /* Returns 1 if there was a remote wakeup and a connect status change. */ | ||
3520 | static int hub_handle_remote_wakeup(struct usb_hub *hub, unsigned int port, | ||
3521 | u16 portstatus, u16 portchange) | ||
3522 | { | ||
3523 | struct usb_device *hdev; | ||
3524 | struct usb_device *udev; | ||
3525 | int connect_change = 0; | ||
3526 | int ret; | ||
3527 | |||
3528 | hdev = hub->hdev; | ||
3529 | udev = hdev->children[port-1]; | ||
3530 | if (!hub_is_superspeed(hdev)) { | ||
3531 | if (!(portchange & USB_PORT_STAT_C_SUSPEND)) | ||
3532 | return 0; | ||
3533 | clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); | ||
3534 | } else { | ||
3535 | if (!udev || udev->state != USB_STATE_SUSPENDED || | ||
3536 | (portstatus & USB_PORT_STAT_LINK_STATE) != | ||
3537 | USB_SS_PORT_LS_U0) | ||
3538 | return 0; | ||
3539 | } | ||
3540 | |||
3541 | if (udev) { | ||
3542 | /* TRSMRCY = 10 msec */ | ||
3543 | msleep(10); | ||
3544 | |||
3545 | usb_lock_device(udev); | ||
3546 | ret = usb_remote_wakeup(udev); | ||
3547 | usb_unlock_device(udev); | ||
3548 | if (ret < 0) | ||
3549 | connect_change = 1; | ||
3550 | } else { | ||
3551 | ret = -ENODEV; | ||
3552 | hub_port_disable(hub, port, 1); | ||
3553 | } | ||
3554 | dev_dbg(hub->intfdev, "resume on port %d, status %d\n", | ||
3555 | port, ret); | ||
3556 | return connect_change; | ||
3557 | } | ||
3558 | |||
3427 | static void hub_events(void) | 3559 | static void hub_events(void) |
3428 | { | 3560 | { |
3429 | struct list_head *tmp; | 3561 | struct list_head *tmp; |
@@ -3436,7 +3568,7 @@ static void hub_events(void) | |||
3436 | u16 portstatus; | 3568 | u16 portstatus; |
3437 | u16 portchange; | 3569 | u16 portchange; |
3438 | int i, ret; | 3570 | int i, ret; |
3439 | int connect_change; | 3571 | int connect_change, wakeup_change; |
3440 | 3572 | ||
3441 | /* | 3573 | /* |
3442 | * We restart the list every time to avoid a deadlock with | 3574 | * We restart the list every time to avoid a deadlock with |
@@ -3515,8 +3647,9 @@ static void hub_events(void) | |||
3515 | if (test_bit(i, hub->busy_bits)) | 3647 | if (test_bit(i, hub->busy_bits)) |
3516 | continue; | 3648 | continue; |
3517 | connect_change = test_bit(i, hub->change_bits); | 3649 | connect_change = test_bit(i, hub->change_bits); |
3650 | wakeup_change = test_and_clear_bit(i, hub->wakeup_bits); | ||
3518 | if (!test_and_clear_bit(i, hub->event_bits) && | 3651 | if (!test_and_clear_bit(i, hub->event_bits) && |
3519 | !connect_change) | 3652 | !connect_change && !wakeup_change) |
3520 | continue; | 3653 | continue; |
3521 | 3654 | ||
3522 | ret = hub_port_status(hub, i, | 3655 | ret = hub_port_status(hub, i, |
@@ -3557,31 +3690,10 @@ static void hub_events(void) | |||
3557 | } | 3690 | } |
3558 | } | 3691 | } |
3559 | 3692 | ||
3560 | if (portchange & USB_PORT_STAT_C_SUSPEND) { | 3693 | if (hub_handle_remote_wakeup(hub, i, |
3561 | struct usb_device *udev; | 3694 | portstatus, portchange)) |
3695 | connect_change = 1; | ||
3562 | 3696 | ||
3563 | clear_port_feature(hdev, i, | ||
3564 | USB_PORT_FEAT_C_SUSPEND); | ||
3565 | udev = hdev->children[i-1]; | ||
3566 | if (udev) { | ||
3567 | /* TRSMRCY = 10 msec */ | ||
3568 | msleep(10); | ||
3569 | |||
3570 | usb_lock_device(udev); | ||
3571 | ret = usb_remote_wakeup(hdev-> | ||
3572 | children[i-1]); | ||
3573 | usb_unlock_device(udev); | ||
3574 | if (ret < 0) | ||
3575 | connect_change = 1; | ||
3576 | } else { | ||
3577 | ret = -ENODEV; | ||
3578 | hub_port_disable(hub, i, 1); | ||
3579 | } | ||
3580 | dev_dbg (hub_dev, | ||
3581 | "resume on port %d, status %d\n", | ||
3582 | i, ret); | ||
3583 | } | ||
3584 | |||
3585 | if (portchange & USB_PORT_STAT_C_OVERCURRENT) { | 3697 | if (portchange & USB_PORT_STAT_C_OVERCURRENT) { |
3586 | u16 status = 0; | 3698 | u16 status = 0; |
3587 | u16 unused; | 3699 | u16 unused; |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 9e491ca2e5c4..566d9f94f735 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -230,6 +230,28 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf) | |||
230 | } | 230 | } |
231 | static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL); | 231 | static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL); |
232 | 232 | ||
233 | static ssize_t | ||
234 | show_removable(struct device *dev, struct device_attribute *attr, char *buf) | ||
235 | { | ||
236 | struct usb_device *udev; | ||
237 | char *state; | ||
238 | |||
239 | udev = to_usb_device(dev); | ||
240 | |||
241 | switch (udev->removable) { | ||
242 | case USB_DEVICE_REMOVABLE: | ||
243 | state = "removable"; | ||
244 | break; | ||
245 | case USB_DEVICE_FIXED: | ||
246 | state = "fixed"; | ||
247 | break; | ||
248 | default: | ||
249 | state = "unknown"; | ||
250 | } | ||
251 | |||
252 | return sprintf(buf, "%s\n", state); | ||
253 | } | ||
254 | static DEVICE_ATTR(removable, S_IRUGO, show_removable, NULL); | ||
233 | 255 | ||
234 | #ifdef CONFIG_PM | 256 | #ifdef CONFIG_PM |
235 | 257 | ||
@@ -626,6 +648,7 @@ static struct attribute *dev_attrs[] = { | |||
626 | &dev_attr_avoid_reset_quirk.attr, | 648 | &dev_attr_avoid_reset_quirk.attr, |
627 | &dev_attr_authorized.attr, | 649 | &dev_attr_authorized.attr, |
628 | &dev_attr_remove.attr, | 650 | &dev_attr_remove.attr, |
651 | &dev_attr_removable.attr, | ||
629 | NULL, | 652 | NULL, |
630 | }; | 653 | }; |
631 | static struct attribute_group dev_attr_grp = { | 654 | static struct attribute_group dev_attr_grp = { |
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 909625b91eb3..7239a73c1b8c 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -403,20 +403,17 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
403 | * cause problems in HCDs if they get it wrong. | 403 | * cause problems in HCDs if they get it wrong. |
404 | */ | 404 | */ |
405 | { | 405 | { |
406 | unsigned int orig_flags = urb->transfer_flags; | ||
407 | unsigned int allowed; | 406 | unsigned int allowed; |
408 | static int pipetypes[4] = { | 407 | static int pipetypes[4] = { |
409 | PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT | 408 | PIPE_CONTROL, PIPE_ISOCHRONOUS, PIPE_BULK, PIPE_INTERRUPT |
410 | }; | 409 | }; |
411 | 410 | ||
412 | /* Check that the pipe's type matches the endpoint's type */ | 411 | /* Check that the pipe's type matches the endpoint's type */ |
413 | if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) { | 412 | if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) |
414 | dev_err(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", | 413 | dev_WARN(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n", |
415 | usb_pipetype(urb->pipe), pipetypes[xfertype]); | 414 | usb_pipetype(urb->pipe), pipetypes[xfertype]); |
416 | return -EPIPE; /* The most suitable error code :-) */ | ||
417 | } | ||
418 | 415 | ||
419 | /* enforce simple/standard policy */ | 416 | /* Check against a simple/standard policy */ |
420 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | | 417 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | |
421 | URB_FREE_BUFFER); | 418 | URB_FREE_BUFFER); |
422 | switch (xfertype) { | 419 | switch (xfertype) { |
@@ -435,14 +432,12 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
435 | allowed |= URB_ISO_ASAP; | 432 | allowed |= URB_ISO_ASAP; |
436 | break; | 433 | break; |
437 | } | 434 | } |
438 | urb->transfer_flags &= allowed; | 435 | allowed &= urb->transfer_flags; |
439 | 436 | ||
440 | /* fail if submitter gave bogus flags */ | 437 | /* warn if submitter gave bogus flags */ |
441 | if (urb->transfer_flags != orig_flags) { | 438 | if (allowed != urb->transfer_flags) |
442 | dev_err(&dev->dev, "BOGUS urb flags, %x --> %x\n", | 439 | dev_WARN(&dev->dev, "BOGUS urb flags, %x --> %x\n", |
443 | orig_flags, urb->transfer_flags); | 440 | urb->transfer_flags, allowed); |
444 | return -EINVAL; | ||
445 | } | ||
446 | } | 441 | } |
447 | #endif | 442 | #endif |
448 | /* | 443 | /* |
@@ -532,10 +527,13 @@ EXPORT_SYMBOL_GPL(usb_submit_urb); | |||
532 | * a driver's I/O routines to insure that all URB-related activity has | 527 | * a driver's I/O routines to insure that all URB-related activity has |
533 | * completed before it returns. | 528 | * completed before it returns. |
534 | * | 529 | * |
535 | * This request is always asynchronous. Success is indicated by | 530 | * This request is asynchronous, however the HCD might call the ->complete() |
536 | * returning -EINPROGRESS, at which time the URB will probably not yet | 531 | * callback during unlink. Therefore when drivers call usb_unlink_urb(), they |
537 | * have been given back to the device driver. When it is eventually | 532 | * must not hold any locks that may be taken by the completion function. |
538 | * called, the completion function will see @urb->status == -ECONNRESET. | 533 | * Success is indicated by returning -EINPROGRESS, at which time the URB will |
534 | * probably not yet have been given back to the device driver. When it is | ||
535 | * eventually called, the completion function will see @urb->status == | ||
536 | * -ECONNRESET. | ||
539 | * Failure is indicated by usb_unlink_urb() returning any other value. | 537 | * Failure is indicated by usb_unlink_urb() returning any other value. |
540 | * Unlinking will fail when @urb is not currently "linked" (i.e., it was | 538 | * Unlinking will fail when @urb is not currently "linked" (i.e., it was |
541 | * never submitted, or it was unlinked before, or the hardware is already | 539 | * never submitted, or it was unlinked before, or the hardware is already |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 8ca9f994a280..c74ba7bbc748 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -274,7 +274,7 @@ static int usb_dev_prepare(struct device *dev) | |||
274 | static void usb_dev_complete(struct device *dev) | 274 | static void usb_dev_complete(struct device *dev) |
275 | { | 275 | { |
276 | /* Currently used only for rebinding interfaces */ | 276 | /* Currently used only for rebinding interfaces */ |
277 | usb_resume(dev, PMSG_ON); /* FIXME: change to PMSG_COMPLETE */ | 277 | usb_resume_complete(dev); |
278 | } | 278 | } |
279 | 279 | ||
280 | static int usb_dev_suspend(struct device *dev) | 280 | static int usb_dev_suspend(struct device *dev) |
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 45e8479c377d..71648dcbe438 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -56,6 +56,7 @@ extern void usb_major_cleanup(void); | |||
56 | 56 | ||
57 | extern int usb_suspend(struct device *dev, pm_message_t msg); | 57 | extern int usb_suspend(struct device *dev, pm_message_t msg); |
58 | extern int usb_resume(struct device *dev, pm_message_t msg); | 58 | extern int usb_resume(struct device *dev, pm_message_t msg); |
59 | extern int usb_resume_complete(struct device *dev); | ||
59 | 60 | ||
60 | extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); | 61 | extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg); |
61 | extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); | 62 | extern int usb_port_resume(struct usb_device *dev, pm_message_t msg); |
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 900ae74357f1..d441fe4c180b 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
@@ -28,6 +28,19 @@ endif | |||
28 | 28 | ||
29 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o | 29 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o |
30 | 30 | ||
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 | ifneq ($(CONFIG_PCI),) | 44 | ifneq ($(CONFIG_PCI),) |
32 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o | 45 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o |
33 | endif | 46 | endif |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 7c9df630dbe4..7bd815a507e8 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -48,10 +48,10 @@ | |||
48 | #include <linux/list.h> | 48 | #include <linux/list.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/dma-mapping.h> | 50 | #include <linux/dma-mapping.h> |
51 | #include <linux/of.h> | ||
51 | 52 | ||
52 | #include <linux/usb/ch9.h> | 53 | #include <linux/usb/ch9.h> |
53 | #include <linux/usb/gadget.h> | 54 | #include <linux/usb/gadget.h> |
54 | #include <linux/module.h> | ||
55 | 55 | ||
56 | #include "core.h" | 56 | #include "core.h" |
57 | #include "gadget.h" | 57 | #include "gadget.h" |
@@ -86,7 +86,7 @@ again: | |||
86 | id = -ENOMEM; | 86 | id = -ENOMEM; |
87 | } | 87 | } |
88 | 88 | ||
89 | return 0; | 89 | return id; |
90 | } | 90 | } |
91 | EXPORT_SYMBOL_GPL(dwc3_get_device_id); | 91 | EXPORT_SYMBOL_GPL(dwc3_get_device_id); |
92 | 92 | ||
@@ -167,11 +167,11 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, | |||
167 | } | 167 | } |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * dwc3_alloc_one_event_buffer - Allocated one event buffer structure | 170 | * dwc3_alloc_one_event_buffer - Allocates one event buffer structure |
171 | * @dwc: Pointer to our controller context structure | 171 | * @dwc: Pointer to our controller context structure |
172 | * @length: size of the event buffer | 172 | * @length: size of the event buffer |
173 | * | 173 | * |
174 | * Returns a pointer to the allocated event buffer structure on succes | 174 | * Returns a pointer to the allocated event buffer structure on success |
175 | * otherwise ERR_PTR(errno). | 175 | * otherwise ERR_PTR(errno). |
176 | */ | 176 | */ |
177 | static struct dwc3_event_buffer *__devinit | 177 | static struct dwc3_event_buffer *__devinit |
@@ -215,10 +215,10 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
215 | 215 | ||
216 | /** | 216 | /** |
217 | * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length | 217 | * dwc3_alloc_event_buffers - Allocates @num event buffers of size @length |
218 | * @dwc: Pointer to out controller context structure | 218 | * @dwc: pointer to our controller context structure |
219 | * @length: size of event buffer | 219 | * @length: size of event buffer |
220 | * | 220 | * |
221 | * Returns 0 on success otherwise negative errno. In error the case, dwc | 221 | * Returns 0 on success otherwise negative errno. In the error case, dwc |
222 | * may contain some buffers allocated but not all which were requested. | 222 | * may contain some buffers allocated but not all which were requested. |
223 | */ | 223 | */ |
224 | static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | 224 | static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) |
@@ -251,7 +251,7 @@ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | |||
251 | 251 | ||
252 | /** | 252 | /** |
253 | * dwc3_event_buffers_setup - setup our allocated event buffers | 253 | * dwc3_event_buffers_setup - setup our allocated event buffers |
254 | * @dwc: Pointer to out controller context structure | 254 | * @dwc: pointer to our controller context structure |
255 | * | 255 | * |
256 | * Returns 0 on success otherwise negative errno. | 256 | * Returns 0 on success otherwise negative errno. |
257 | */ | 257 | */ |
@@ -350,7 +350,7 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
350 | dwc3_cache_hwparams(dwc); | 350 | dwc3_cache_hwparams(dwc); |
351 | 351 | ||
352 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | 352 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
353 | reg &= ~DWC3_GCTL_SCALEDOWN(3); | 353 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; |
354 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | 354 | reg &= ~DWC3_GCTL_DISSCRAMBLE; |
355 | 355 | ||
356 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { | 356 | switch (DWC3_GHWPARAMS1_EN_PWROPT(dwc->hwparams.hwparams1)) { |
@@ -363,9 +363,9 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
363 | 363 | ||
364 | /* | 364 | /* |
365 | * WORKAROUND: DWC3 revisions <1.90a have a bug | 365 | * WORKAROUND: DWC3 revisions <1.90a have a bug |
366 | * when The device fails to connect at SuperSpeed | 366 | * where the device can fail to connect at SuperSpeed |
367 | * and falls back to high-speed mode which causes | 367 | * and falls back to high-speed mode which causes |
368 | * the device to enter in a Connect/Disconnect loop | 368 | * the device to enter a Connect/Disconnect loop |
369 | */ | 369 | */ |
370 | if (dwc->revision < DWC3_REVISION_190A) | 370 | if (dwc->revision < DWC3_REVISION_190A) |
371 | reg |= DWC3_GCTL_U2RSTECN; | 371 | reg |= DWC3_GCTL_U2RSTECN; |
@@ -404,8 +404,10 @@ static void dwc3_core_exit(struct dwc3 *dwc) | |||
404 | 404 | ||
405 | static int __devinit dwc3_probe(struct platform_device *pdev) | 405 | static int __devinit dwc3_probe(struct platform_device *pdev) |
406 | { | 406 | { |
407 | struct device_node *node = pdev->dev.of_node; | ||
407 | struct resource *res; | 408 | struct resource *res; |
408 | struct dwc3 *dwc; | 409 | struct dwc3 *dwc; |
410 | struct device *dev = &pdev->dev; | ||
409 | 411 | ||
410 | int ret = -ENOMEM; | 412 | int ret = -ENOMEM; |
411 | int irq; | 413 | int irq; |
@@ -415,39 +417,39 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
415 | 417 | ||
416 | u8 mode; | 418 | u8 mode; |
417 | 419 | ||
418 | mem = kzalloc(sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); | 420 | mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); |
419 | if (!mem) { | 421 | if (!mem) { |
420 | dev_err(&pdev->dev, "not enough memory\n"); | 422 | dev_err(dev, "not enough memory\n"); |
421 | goto err0; | 423 | return -ENOMEM; |
422 | } | 424 | } |
423 | dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); | 425 | dwc = PTR_ALIGN(mem, DWC3_ALIGN_MASK + 1); |
424 | dwc->mem = mem; | 426 | dwc->mem = mem; |
425 | 427 | ||
426 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 428 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
427 | if (!res) { | 429 | if (!res) { |
428 | dev_err(&pdev->dev, "missing resource\n"); | 430 | dev_err(dev, "missing resource\n"); |
429 | goto err1; | 431 | return -ENODEV; |
430 | } | 432 | } |
431 | 433 | ||
432 | dwc->res = res; | 434 | dwc->res = res; |
433 | 435 | ||
434 | res = request_mem_region(res->start, resource_size(res), | 436 | res = devm_request_mem_region(dev, res->start, resource_size(res), |
435 | dev_name(&pdev->dev)); | 437 | dev_name(dev)); |
436 | if (!res) { | 438 | if (!res) { |
437 | dev_err(&pdev->dev, "can't request mem region\n"); | 439 | dev_err(dev, "can't request mem region\n"); |
438 | goto err1; | 440 | return -ENOMEM; |
439 | } | 441 | } |
440 | 442 | ||
441 | regs = ioremap(res->start, resource_size(res)); | 443 | regs = devm_ioremap(dev, res->start, resource_size(res)); |
442 | if (!regs) { | 444 | if (!regs) { |
443 | dev_err(&pdev->dev, "ioremap failed\n"); | 445 | dev_err(dev, "ioremap failed\n"); |
444 | goto err2; | 446 | return -ENOMEM; |
445 | } | 447 | } |
446 | 448 | ||
447 | irq = platform_get_irq(pdev, 0); | 449 | irq = platform_get_irq(pdev, 0); |
448 | if (irq < 0) { | 450 | if (irq < 0) { |
449 | dev_err(&pdev->dev, "missing IRQ\n"); | 451 | dev_err(dev, "missing IRQ\n"); |
450 | goto err3; | 452 | return -ENODEV; |
451 | } | 453 | } |
452 | 454 | ||
453 | spin_lock_init(&dwc->lock); | 455 | spin_lock_init(&dwc->lock); |
@@ -455,7 +457,7 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
455 | 457 | ||
456 | dwc->regs = regs; | 458 | dwc->regs = regs; |
457 | dwc->regs_size = resource_size(res); | 459 | dwc->regs_size = resource_size(res); |
458 | dwc->dev = &pdev->dev; | 460 | dwc->dev = dev; |
459 | dwc->irq = irq; | 461 | dwc->irq = irq; |
460 | 462 | ||
461 | if (!strncmp("super", maximum_speed, 5)) | 463 | if (!strncmp("super", maximum_speed, 5)) |
@@ -469,14 +471,17 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
469 | else | 471 | else |
470 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | 472 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; |
471 | 473 | ||
472 | pm_runtime_enable(&pdev->dev); | 474 | if (of_get_property(node, "tx-fifo-resize", NULL)) |
473 | pm_runtime_get_sync(&pdev->dev); | 475 | dwc->needs_fifo_resize = true; |
474 | pm_runtime_forbid(&pdev->dev); | 476 | |
477 | pm_runtime_enable(dev); | ||
478 | pm_runtime_get_sync(dev); | ||
479 | pm_runtime_forbid(dev); | ||
475 | 480 | ||
476 | ret = dwc3_core_init(dwc); | 481 | ret = dwc3_core_init(dwc); |
477 | if (ret) { | 482 | if (ret) { |
478 | dev_err(&pdev->dev, "failed to initialize core\n"); | 483 | dev_err(dev, "failed to initialize core\n"); |
479 | goto err3; | 484 | return ret; |
480 | } | 485 | } |
481 | 486 | ||
482 | mode = DWC3_MODE(dwc->hwparams.hwparams0); | 487 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
@@ -486,49 +491,49 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
486 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); | 491 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); |
487 | ret = dwc3_gadget_init(dwc); | 492 | ret = dwc3_gadget_init(dwc); |
488 | if (ret) { | 493 | if (ret) { |
489 | dev_err(&pdev->dev, "failed to initialize gadget\n"); | 494 | dev_err(dev, "failed to initialize gadget\n"); |
490 | goto err4; | 495 | goto err1; |
491 | } | 496 | } |
492 | break; | 497 | break; |
493 | case DWC3_MODE_HOST: | 498 | case DWC3_MODE_HOST: |
494 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); | 499 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); |
495 | ret = dwc3_host_init(dwc); | 500 | ret = dwc3_host_init(dwc); |
496 | if (ret) { | 501 | if (ret) { |
497 | dev_err(&pdev->dev, "failed to initialize host\n"); | 502 | dev_err(dev, "failed to initialize host\n"); |
498 | goto err4; | 503 | goto err1; |
499 | } | 504 | } |
500 | break; | 505 | break; |
501 | case DWC3_MODE_DRD: | 506 | case DWC3_MODE_DRD: |
502 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); | 507 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); |
503 | ret = dwc3_host_init(dwc); | 508 | ret = dwc3_host_init(dwc); |
504 | if (ret) { | 509 | if (ret) { |
505 | dev_err(&pdev->dev, "failed to initialize host\n"); | 510 | dev_err(dev, "failed to initialize host\n"); |
506 | goto err4; | 511 | goto err1; |
507 | } | 512 | } |
508 | 513 | ||
509 | ret = dwc3_gadget_init(dwc); | 514 | ret = dwc3_gadget_init(dwc); |
510 | if (ret) { | 515 | if (ret) { |
511 | dev_err(&pdev->dev, "failed to initialize gadget\n"); | 516 | dev_err(dev, "failed to initialize gadget\n"); |
512 | goto err4; | 517 | goto err1; |
513 | } | 518 | } |
514 | break; | 519 | break; |
515 | default: | 520 | default: |
516 | dev_err(&pdev->dev, "Unsupported mode of operation %d\n", mode); | 521 | dev_err(dev, "Unsupported mode of operation %d\n", mode); |
517 | goto err4; | 522 | goto err1; |
518 | } | 523 | } |
519 | dwc->mode = mode; | 524 | dwc->mode = mode; |
520 | 525 | ||
521 | ret = dwc3_debugfs_init(dwc); | 526 | ret = dwc3_debugfs_init(dwc); |
522 | if (ret) { | 527 | if (ret) { |
523 | dev_err(&pdev->dev, "failed to initialize debugfs\n"); | 528 | dev_err(dev, "failed to initialize debugfs\n"); |
524 | goto err5; | 529 | goto err2; |
525 | } | 530 | } |
526 | 531 | ||
527 | pm_runtime_allow(&pdev->dev); | 532 | pm_runtime_allow(dev); |
528 | 533 | ||
529 | return 0; | 534 | return 0; |
530 | 535 | ||
531 | err5: | 536 | err2: |
532 | switch (mode) { | 537 | switch (mode) { |
533 | case DWC3_MODE_DEVICE: | 538 | case DWC3_MODE_DEVICE: |
534 | dwc3_gadget_exit(dwc); | 539 | dwc3_gadget_exit(dwc); |
@@ -545,19 +550,9 @@ err5: | |||
545 | break; | 550 | break; |
546 | } | 551 | } |
547 | 552 | ||
548 | err4: | ||
549 | dwc3_core_exit(dwc); | ||
550 | |||
551 | err3: | ||
552 | iounmap(regs); | ||
553 | |||
554 | err2: | ||
555 | release_mem_region(res->start, resource_size(res)); | ||
556 | |||
557 | err1: | 553 | err1: |
558 | kfree(dwc->mem); | 554 | dwc3_core_exit(dwc); |
559 | 555 | ||
560 | err0: | ||
561 | return ret; | 556 | return ret; |
562 | } | 557 | } |
563 | 558 | ||
@@ -590,9 +585,6 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
590 | } | 585 | } |
591 | 586 | ||
592 | dwc3_core_exit(dwc); | 587 | dwc3_core_exit(dwc); |
593 | release_mem_region(res->start, resource_size(res)); | ||
594 | iounmap(dwc->regs); | ||
595 | kfree(dwc->mem); | ||
596 | 588 | ||
597 | return 0; | 589 | return 0; |
598 | } | 590 | } |
@@ -605,19 +597,9 @@ static struct platform_driver dwc3_driver = { | |||
605 | }, | 597 | }, |
606 | }; | 598 | }; |
607 | 599 | ||
600 | module_platform_driver(dwc3_driver); | ||
601 | |||
608 | MODULE_ALIAS("platform:dwc3"); | 602 | MODULE_ALIAS("platform:dwc3"); |
609 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 603 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
610 | MODULE_LICENSE("Dual BSD/GPL"); | 604 | MODULE_LICENSE("Dual BSD/GPL"); |
611 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); | 605 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); |
612 | |||
613 | static int __devinit dwc3_init(void) | ||
614 | { | ||
615 | return platform_driver_register(&dwc3_driver); | ||
616 | } | ||
617 | module_init(dwc3_init); | ||
618 | |||
619 | static void __exit dwc3_exit(void) | ||
620 | { | ||
621 | platform_driver_unregister(&dwc3_driver); | ||
622 | } | ||
623 | module_exit(dwc3_exit); | ||
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 9e57f8e9bf17..6c7945b4cad3 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -145,22 +145,23 @@ | |||
145 | /* Bit fields */ | 145 | /* Bit fields */ |
146 | 146 | ||
147 | /* Global Configuration Register */ | 147 | /* Global Configuration Register */ |
148 | #define DWC3_GCTL_PWRDNSCALE(n) (n << 19) | 148 | #define DWC3_GCTL_PWRDNSCALE(n) ((n) << 19) |
149 | #define DWC3_GCTL_U2RSTECN (1 << 16) | 149 | #define DWC3_GCTL_U2RSTECN (1 << 16) |
150 | #define DWC3_GCTL_RAMCLKSEL(x) ((x & DWC3_GCTL_CLK_MASK) << 6) | 150 | #define DWC3_GCTL_RAMCLKSEL(x) (((x) & DWC3_GCTL_CLK_MASK) << 6) |
151 | #define DWC3_GCTL_CLK_BUS (0) | 151 | #define DWC3_GCTL_CLK_BUS (0) |
152 | #define DWC3_GCTL_CLK_PIPE (1) | 152 | #define DWC3_GCTL_CLK_PIPE (1) |
153 | #define DWC3_GCTL_CLK_PIPEHALF (2) | 153 | #define DWC3_GCTL_CLK_PIPEHALF (2) |
154 | #define DWC3_GCTL_CLK_MASK (3) | 154 | #define DWC3_GCTL_CLK_MASK (3) |
155 | 155 | ||
156 | #define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12) | 156 | #define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12) |
157 | #define DWC3_GCTL_PRTCAPDIR(n) (n << 12) | 157 | #define DWC3_GCTL_PRTCAPDIR(n) ((n) << 12) |
158 | #define DWC3_GCTL_PRTCAP_HOST 1 | 158 | #define DWC3_GCTL_PRTCAP_HOST 1 |
159 | #define DWC3_GCTL_PRTCAP_DEVICE 2 | 159 | #define DWC3_GCTL_PRTCAP_DEVICE 2 |
160 | #define DWC3_GCTL_PRTCAP_OTG 3 | 160 | #define DWC3_GCTL_PRTCAP_OTG 3 |
161 | 161 | ||
162 | #define DWC3_GCTL_CORESOFTRESET (1 << 11) | 162 | #define DWC3_GCTL_CORESOFTRESET (1 << 11) |
163 | #define DWC3_GCTL_SCALEDOWN(n) (n << 4) | 163 | #define DWC3_GCTL_SCALEDOWN(n) ((n) << 4) |
164 | #define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3) | ||
164 | #define DWC3_GCTL_DISSCRAMBLE (1 << 3) | 165 | #define DWC3_GCTL_DISSCRAMBLE (1 << 3) |
165 | #define DWC3_GCTL_DSBLCLKGTNG (1 << 0) | 166 | #define DWC3_GCTL_DSBLCLKGTNG (1 << 0) |
166 | 167 | ||
@@ -172,8 +173,12 @@ | |||
172 | #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31) | 173 | #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31) |
173 | #define DWC3_GUSB3PIPECTL_SUSPHY (1 << 17) | 174 | #define DWC3_GUSB3PIPECTL_SUSPHY (1 << 17) |
174 | 175 | ||
176 | /* Global TX Fifo Size Register */ | ||
177 | #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff) | ||
178 | #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000) | ||
179 | |||
175 | /* Global HWPARAMS1 Register */ | 180 | /* Global HWPARAMS1 Register */ |
176 | #define DWC3_GHWPARAMS1_EN_PWROPT(n) ((n & (3 << 24)) >> 24) | 181 | #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24) |
177 | #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0 | 182 | #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0 |
178 | #define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1 | 183 | #define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1 |
179 | 184 | ||
@@ -198,6 +203,15 @@ | |||
198 | 203 | ||
199 | #define DWC3_DCTL_APPL1RES (1 << 23) | 204 | #define DWC3_DCTL_APPL1RES (1 << 23) |
200 | 205 | ||
206 | #define DWC3_DCTL_TRGTULST_MASK (0x0f << 17) | ||
207 | #define DWC3_DCTL_TRGTULST(n) ((n) << 17) | ||
208 | |||
209 | #define DWC3_DCTL_TRGTULST_U2 (DWC3_DCTL_TRGTULST(2)) | ||
210 | #define DWC3_DCTL_TRGTULST_U3 (DWC3_DCTL_TRGTULST(3)) | ||
211 | #define DWC3_DCTL_TRGTULST_SS_DIS (DWC3_DCTL_TRGTULST(4)) | ||
212 | #define DWC3_DCTL_TRGTULST_RX_DET (DWC3_DCTL_TRGTULST(5)) | ||
213 | #define DWC3_DCTL_TRGTULST_SS_INACT (DWC3_DCTL_TRGTULST(6)) | ||
214 | |||
201 | #define DWC3_DCTL_INITU2ENA (1 << 12) | 215 | #define DWC3_DCTL_INITU2ENA (1 << 12) |
202 | #define DWC3_DCTL_ACCEPTU2ENA (1 << 11) | 216 | #define DWC3_DCTL_ACCEPTU2ENA (1 << 11) |
203 | #define DWC3_DCTL_INITU1ENA (1 << 10) | 217 | #define DWC3_DCTL_INITU1ENA (1 << 10) |
@@ -260,10 +274,10 @@ | |||
260 | 274 | ||
261 | /* Device Endpoint Command Register */ | 275 | /* Device Endpoint Command Register */ |
262 | #define DWC3_DEPCMD_PARAM_SHIFT 16 | 276 | #define DWC3_DEPCMD_PARAM_SHIFT 16 |
263 | #define DWC3_DEPCMD_PARAM(x) (x << DWC3_DEPCMD_PARAM_SHIFT) | 277 | #define DWC3_DEPCMD_PARAM(x) ((x) << DWC3_DEPCMD_PARAM_SHIFT) |
264 | #define DWC3_DEPCMD_GET_RSC_IDX(x) ((x >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) | 278 | #define DWC3_DEPCMD_GET_RSC_IDX(x) (((x) >> DWC3_DEPCMD_PARAM_SHIFT) & 0x7f) |
265 | #define DWC3_DEPCMD_STATUS_MASK (0x0f << 12) | 279 | #define DWC3_DEPCMD_STATUS_MASK (0x0f << 12) |
266 | #define DWC3_DEPCMD_STATUS(x) ((x & DWC3_DEPCMD_STATUS_MASK) >> 12) | 280 | #define DWC3_DEPCMD_STATUS(x) (((x) & DWC3_DEPCMD_STATUS_MASK) >> 12) |
267 | #define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11) | 281 | #define DWC3_DEPCMD_HIPRI_FORCERM (1 << 11) |
268 | #define DWC3_DEPCMD_CMDACT (1 << 10) | 282 | #define DWC3_DEPCMD_CMDACT (1 << 10) |
269 | #define DWC3_DEPCMD_CMDIOC (1 << 8) | 283 | #define DWC3_DEPCMD_CMDIOC (1 << 8) |
@@ -288,7 +302,7 @@ | |||
288 | 302 | ||
289 | /* Structures */ | 303 | /* Structures */ |
290 | 304 | ||
291 | struct dwc3_trb_hw; | 305 | struct dwc3_trb; |
292 | 306 | ||
293 | /** | 307 | /** |
294 | * struct dwc3_event_buffer - Software event buffer representation | 308 | * struct dwc3_event_buffer - Software event buffer representation |
@@ -343,7 +357,7 @@ struct dwc3_ep { | |||
343 | struct list_head request_list; | 357 | struct list_head request_list; |
344 | struct list_head req_queued; | 358 | struct list_head req_queued; |
345 | 359 | ||
346 | struct dwc3_trb_hw *trb_pool; | 360 | struct dwc3_trb *trb_pool; |
347 | dma_addr_t trb_pool_dma; | 361 | dma_addr_t trb_pool_dma; |
348 | u32 free_slot; | 362 | u32 free_slot; |
349 | u32 busy_slot; | 363 | u32 busy_slot; |
@@ -418,102 +432,49 @@ enum dwc3_device_state { | |||
418 | DWC3_CONFIGURED_STATE, | 432 | DWC3_CONFIGURED_STATE, |
419 | }; | 433 | }; |
420 | 434 | ||
421 | /** | 435 | /* TRB Length, PCM and Status */ |
422 | * struct dwc3_trb - transfer request block | 436 | #define DWC3_TRB_SIZE_MASK (0x00ffffff) |
423 | * @bpl: lower 32bit of the buffer | 437 | #define DWC3_TRB_SIZE_LENGTH(n) ((n) & DWC3_TRB_SIZE_MASK) |
424 | * @bph: higher 32bit of the buffer | 438 | #define DWC3_TRB_SIZE_PCM1(n) (((n) & 0x03) << 24) |
425 | * @length: buffer size (up to 16mb - 1) | 439 | #define DWC3_TRB_SIZE_TRBSTS(n) (((n) & (0x0f << 28) >> 28)) |
426 | * @pcm1: packet count m1 | 440 | |
427 | * @trbsts: trb status | 441 | #define DWC3_TRBSTS_OK 0 |
428 | * 0 = ok | 442 | #define DWC3_TRBSTS_MISSED_ISOC 1 |
429 | * 1 = missed isoc | 443 | #define DWC3_TRBSTS_SETUP_PENDING 2 |
430 | * 2 = setup pending | 444 | |
431 | * @hwo: hardware owner of descriptor | 445 | /* TRB Control */ |
432 | * @lst: last trb | 446 | #define DWC3_TRB_CTRL_HWO (1 << 0) |
433 | * @chn: chain buffers | 447 | #define DWC3_TRB_CTRL_LST (1 << 1) |
434 | * @csp: continue on short packets (only supported on isoc eps) | 448 | #define DWC3_TRB_CTRL_CHN (1 << 2) |
435 | * @trbctl: trb control | 449 | #define DWC3_TRB_CTRL_CSP (1 << 3) |
436 | * 1 = normal | 450 | #define DWC3_TRB_CTRL_TRBCTL(n) (((n) & 0x3f) << 4) |
437 | * 2 = control-setup | 451 | #define DWC3_TRB_CTRL_ISP_IMI (1 << 10) |
438 | * 3 = control-status-2 | 452 | #define DWC3_TRB_CTRL_IOC (1 << 11) |
439 | * 4 = control-status-3 | 453 | #define DWC3_TRB_CTRL_SID_SOFN(n) (((n) & 0xffff) << 14) |
440 | * 5 = control-data (first trb of data stage) | 454 | |
441 | * 6 = isochronous-first (first trb of service interval) | 455 | #define DWC3_TRBCTL_NORMAL DWC3_TRB_CTRL_TRBCTL(1) |
442 | * 7 = isochronous | 456 | #define DWC3_TRBCTL_CONTROL_SETUP DWC3_TRB_CTRL_TRBCTL(2) |
443 | * 8 = link trb | 457 | #define DWC3_TRBCTL_CONTROL_STATUS2 DWC3_TRB_CTRL_TRBCTL(3) |
444 | * others = reserved | 458 | #define DWC3_TRBCTL_CONTROL_STATUS3 DWC3_TRB_CTRL_TRBCTL(4) |
445 | * @isp_imi: interrupt on short packet / interrupt on missed isoc | 459 | #define DWC3_TRBCTL_CONTROL_DATA DWC3_TRB_CTRL_TRBCTL(5) |
446 | * @ioc: interrupt on complete | 460 | #define DWC3_TRBCTL_ISOCHRONOUS_FIRST DWC3_TRB_CTRL_TRBCTL(6) |
447 | * @sid_sofn: Stream ID / SOF Number | 461 | #define DWC3_TRBCTL_ISOCHRONOUS DWC3_TRB_CTRL_TRBCTL(7) |
448 | */ | 462 | #define DWC3_TRBCTL_LINK_TRB DWC3_TRB_CTRL_TRBCTL(8) |
449 | struct dwc3_trb { | ||
450 | u64 bplh; | ||
451 | |||
452 | union { | ||
453 | struct { | ||
454 | u32 length:24; | ||
455 | u32 pcm1:2; | ||
456 | u32 reserved27_26:2; | ||
457 | u32 trbsts:4; | ||
458 | #define DWC3_TRB_STS_OKAY 0 | ||
459 | #define DWC3_TRB_STS_MISSED_ISOC 1 | ||
460 | #define DWC3_TRB_STS_SETUP_PENDING 2 | ||
461 | }; | ||
462 | u32 len_pcm; | ||
463 | }; | ||
464 | |||
465 | union { | ||
466 | struct { | ||
467 | u32 hwo:1; | ||
468 | u32 lst:1; | ||
469 | u32 chn:1; | ||
470 | u32 csp:1; | ||
471 | u32 trbctl:6; | ||
472 | u32 isp_imi:1; | ||
473 | u32 ioc:1; | ||
474 | u32 reserved13_12:2; | ||
475 | u32 sid_sofn:16; | ||
476 | u32 reserved31_30:2; | ||
477 | }; | ||
478 | u32 control; | ||
479 | }; | ||
480 | } __packed; | ||
481 | 463 | ||
482 | /** | 464 | /** |
483 | * struct dwc3_trb_hw - transfer request block (hw format) | 465 | * struct dwc3_trb - transfer request block (hw format) |
484 | * @bpl: DW0-3 | 466 | * @bpl: DW0-3 |
485 | * @bph: DW4-7 | 467 | * @bph: DW4-7 |
486 | * @size: DW8-B | 468 | * @size: DW8-B |
487 | * @trl: DWC-F | 469 | * @trl: DWC-F |
488 | */ | 470 | */ |
489 | struct dwc3_trb_hw { | 471 | struct dwc3_trb { |
490 | __le32 bpl; | 472 | u32 bpl; |
491 | __le32 bph; | 473 | u32 bph; |
492 | __le32 size; | 474 | u32 size; |
493 | __le32 ctrl; | 475 | u32 ctrl; |
494 | } __packed; | 476 | } __packed; |
495 | 477 | ||
496 | static inline void dwc3_trb_to_hw(struct dwc3_trb *nat, struct dwc3_trb_hw *hw) | ||
497 | { | ||
498 | hw->bpl = cpu_to_le32(lower_32_bits(nat->bplh)); | ||
499 | hw->bph = cpu_to_le32(upper_32_bits(nat->bplh)); | ||
500 | hw->size = cpu_to_le32p(&nat->len_pcm); | ||
501 | /* HWO is written last */ | ||
502 | hw->ctrl = cpu_to_le32p(&nat->control); | ||
503 | } | ||
504 | |||
505 | static inline void dwc3_trb_to_nat(struct dwc3_trb_hw *hw, struct dwc3_trb *nat) | ||
506 | { | ||
507 | u64 bplh; | ||
508 | |||
509 | bplh = le32_to_cpup(&hw->bpl); | ||
510 | bplh |= (u64) le32_to_cpup(&hw->bph) << 32; | ||
511 | nat->bplh = bplh; | ||
512 | |||
513 | nat->len_pcm = le32_to_cpup(&hw->size); | ||
514 | nat->control = le32_to_cpup(&hw->ctrl); | ||
515 | } | ||
516 | |||
517 | /** | 478 | /** |
518 | * dwc3_hwparams - copy of HWPARAMS registers | 479 | * dwc3_hwparams - copy of HWPARAMS registers |
519 | * @hwparams0 - GHWPARAMS0 | 480 | * @hwparams0 - GHWPARAMS0 |
@@ -546,8 +507,13 @@ struct dwc3_hwparams { | |||
546 | #define DWC3_MODE_DRD 2 | 507 | #define DWC3_MODE_DRD 2 |
547 | #define DWC3_MODE_HUB 3 | 508 | #define DWC3_MODE_HUB 3 |
548 | 509 | ||
510 | #define DWC3_MDWIDTH(n) (((n) & 0xff00) >> 8) | ||
511 | |||
549 | /* HWPARAMS1 */ | 512 | /* HWPARAMS1 */ |
550 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) | 513 | #define DWC3_NUM_INT(n) (((n) & (0x3f << 15)) >> 15) |
514 | |||
515 | /* HWPARAMS7 */ | ||
516 | #define DWC3_RAM1_DEPTH(n) ((n) & 0xffff) | ||
551 | 517 | ||
552 | struct dwc3_request { | 518 | struct dwc3_request { |
553 | struct usb_request request; | 519 | struct usb_request request; |
@@ -555,7 +521,7 @@ struct dwc3_request { | |||
555 | struct dwc3_ep *dep; | 521 | struct dwc3_ep *dep; |
556 | 522 | ||
557 | u8 epnum; | 523 | u8 epnum; |
558 | struct dwc3_trb_hw *trb; | 524 | struct dwc3_trb *trb; |
559 | dma_addr_t trb_dma; | 525 | dma_addr_t trb_dma; |
560 | 526 | ||
561 | unsigned direction:1; | 527 | unsigned direction:1; |
@@ -572,7 +538,6 @@ struct dwc3_request { | |||
572 | * @ctrl_req_addr: dma address of ctrl_req | 538 | * @ctrl_req_addr: dma address of ctrl_req |
573 | * @ep0_trb: dma address of ep0_trb | 539 | * @ep0_trb: dma address of ep0_trb |
574 | * @ep0_usb_req: dummy req used while handling STD USB requests | 540 | * @ep0_usb_req: dummy req used while handling STD USB requests |
575 | * @setup_buf_addr: dma address of setup_buf | ||
576 | * @ep0_bounce_addr: dma address of ep0_bounce | 541 | * @ep0_bounce_addr: dma address of ep0_bounce |
577 | * @lock: for synchronizing | 542 | * @lock: for synchronizing |
578 | * @dev: pointer to our struct device | 543 | * @dev: pointer to our struct device |
@@ -594,6 +559,8 @@ struct dwc3_request { | |||
594 | * @ep0_expect_in: true when we expect a DATA IN transfer | 559 | * @ep0_expect_in: true when we expect a DATA IN transfer |
595 | * @start_config_issued: true when StartConfig command has been issued | 560 | * @start_config_issued: true when StartConfig command has been issued |
596 | * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround | 561 | * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround |
562 | * @needs_fifo_resize: not all users might want fifo resizing, flag it | ||
563 | * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. | ||
597 | * @ep0_next_event: hold the next expected event | 564 | * @ep0_next_event: hold the next expected event |
598 | * @ep0state: state of endpoint zero | 565 | * @ep0state: state of endpoint zero |
599 | * @link_state: link state | 566 | * @link_state: link state |
@@ -604,12 +571,11 @@ struct dwc3_request { | |||
604 | */ | 571 | */ |
605 | struct dwc3 { | 572 | struct dwc3 { |
606 | struct usb_ctrlrequest *ctrl_req; | 573 | struct usb_ctrlrequest *ctrl_req; |
607 | struct dwc3_trb_hw *ep0_trb; | 574 | struct dwc3_trb *ep0_trb; |
608 | void *ep0_bounce; | 575 | void *ep0_bounce; |
609 | u8 *setup_buf; | 576 | u8 *setup_buf; |
610 | dma_addr_t ctrl_req_addr; | 577 | dma_addr_t ctrl_req_addr; |
611 | dma_addr_t ep0_trb_addr; | 578 | dma_addr_t ep0_trb_addr; |
612 | dma_addr_t setup_buf_addr; | ||
613 | dma_addr_t ep0_bounce_addr; | 579 | dma_addr_t ep0_bounce_addr; |
614 | struct dwc3_request ep0_usb_req; | 580 | struct dwc3_request ep0_usb_req; |
615 | /* device lock */ | 581 | /* device lock */ |
@@ -651,6 +617,8 @@ struct dwc3 { | |||
651 | unsigned start_config_issued:1; | 617 | unsigned start_config_issued:1; |
652 | unsigned setup_packet_pending:1; | 618 | unsigned setup_packet_pending:1; |
653 | unsigned delayed_status:1; | 619 | unsigned delayed_status:1; |
620 | unsigned needs_fifo_resize:1; | ||
621 | unsigned resize_fifos:1; | ||
654 | 622 | ||
655 | enum dwc3_ep0_next ep0_next_event; | 623 | enum dwc3_ep0_next ep0_next_event; |
656 | enum dwc3_ep0_state ep0state; | 624 | enum dwc3_ep0_state ep0state; |
@@ -662,23 +630,13 @@ struct dwc3 { | |||
662 | 630 | ||
663 | struct dwc3_hwparams hwparams; | 631 | struct dwc3_hwparams hwparams; |
664 | struct dentry *root; | 632 | struct dentry *root; |
633 | |||
634 | u8 test_mode; | ||
635 | u8 test_mode_nr; | ||
665 | }; | 636 | }; |
666 | 637 | ||
667 | /* -------------------------------------------------------------------------- */ | 638 | /* -------------------------------------------------------------------------- */ |
668 | 639 | ||
669 | #define DWC3_TRBSTS_OK 0 | ||
670 | #define DWC3_TRBSTS_MISSED_ISOC 1 | ||
671 | #define DWC3_TRBSTS_SETUP_PENDING 2 | ||
672 | |||
673 | #define DWC3_TRBCTL_NORMAL 1 | ||
674 | #define DWC3_TRBCTL_CONTROL_SETUP 2 | ||
675 | #define DWC3_TRBCTL_CONTROL_STATUS2 3 | ||
676 | #define DWC3_TRBCTL_CONTROL_STATUS3 4 | ||
677 | #define DWC3_TRBCTL_CONTROL_DATA 5 | ||
678 | #define DWC3_TRBCTL_ISOCHRONOUS_FIRST 6 | ||
679 | #define DWC3_TRBCTL_ISOCHRONOUS 7 | ||
680 | #define DWC3_TRBCTL_LINK_TRB 8 | ||
681 | |||
682 | /* -------------------------------------------------------------------------- */ | 640 | /* -------------------------------------------------------------------------- */ |
683 | 641 | ||
684 | struct dwc3_event_type { | 642 | struct dwc3_event_type { |
@@ -719,9 +677,14 @@ struct dwc3_event_depevt { | |||
719 | u32 endpoint_event:4; | 677 | u32 endpoint_event:4; |
720 | u32 reserved11_10:2; | 678 | u32 reserved11_10:2; |
721 | u32 status:4; | 679 | u32 status:4; |
722 | #define DEPEVT_STATUS_BUSERR (1 << 0) | 680 | |
723 | #define DEPEVT_STATUS_SHORT (1 << 1) | 681 | /* Within XferNotReady */ |
724 | #define DEPEVT_STATUS_IOC (1 << 2) | 682 | #define DEPEVT_STATUS_TRANSFER_ACTIVE (1 << 3) |
683 | |||
684 | /* Within XferComplete */ | ||
685 | #define DEPEVT_STATUS_BUSERR (1 << 0) | ||
686 | #define DEPEVT_STATUS_SHORT (1 << 1) | ||
687 | #define DEPEVT_STATUS_IOC (1 << 2) | ||
725 | #define DEPEVT_STATUS_LST (1 << 3) | 688 | #define DEPEVT_STATUS_LST (1 << 3) |
726 | 689 | ||
727 | /* Stream event only */ | 690 | /* Stream event only */ |
@@ -807,6 +770,7 @@ union dwc3_event { | |||
807 | 770 | ||
808 | /* prototypes */ | 771 | /* prototypes */ |
809 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode); | 772 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode); |
773 | int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc); | ||
810 | 774 | ||
811 | int dwc3_host_init(struct dwc3 *dwc); | 775 | int dwc3_host_init(struct dwc3 *dwc); |
812 | void dwc3_host_exit(struct dwc3 *dwc); | 776 | void dwc3_host_exit(struct dwc3 *dwc); |
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 433c97c15fc5..d4a30f118724 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
@@ -46,6 +46,8 @@ | |||
46 | #include <linux/delay.h> | 46 | #include <linux/delay.h> |
47 | #include <linux/uaccess.h> | 47 | #include <linux/uaccess.h> |
48 | 48 | ||
49 | #include <linux/usb/ch9.h> | ||
50 | |||
49 | #include "core.h" | 51 | #include "core.h" |
50 | #include "gadget.h" | 52 | #include "gadget.h" |
51 | #include "io.h" | 53 | #include "io.h" |
@@ -464,6 +466,192 @@ static const struct file_operations dwc3_mode_fops = { | |||
464 | .release = single_release, | 466 | .release = single_release, |
465 | }; | 467 | }; |
466 | 468 | ||
469 | static int dwc3_testmode_show(struct seq_file *s, void *unused) | ||
470 | { | ||
471 | struct dwc3 *dwc = s->private; | ||
472 | unsigned long flags; | ||
473 | u32 reg; | ||
474 | |||
475 | spin_lock_irqsave(&dwc->lock, flags); | ||
476 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | ||
477 | reg &= DWC3_DCTL_TSTCTRL_MASK; | ||
478 | reg >>= 1; | ||
479 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
480 | |||
481 | switch (reg) { | ||
482 | case 0: | ||
483 | seq_printf(s, "no test\n"); | ||
484 | break; | ||
485 | case TEST_J: | ||
486 | seq_printf(s, "test_j\n"); | ||
487 | break; | ||
488 | case TEST_K: | ||
489 | seq_printf(s, "test_k\n"); | ||
490 | break; | ||
491 | case TEST_SE0_NAK: | ||
492 | seq_printf(s, "test_se0_nak\n"); | ||
493 | break; | ||
494 | case TEST_PACKET: | ||
495 | seq_printf(s, "test_packet\n"); | ||
496 | break; | ||
497 | case TEST_FORCE_EN: | ||
498 | seq_printf(s, "test_force_enable\n"); | ||
499 | break; | ||
500 | default: | ||
501 | seq_printf(s, "UNKNOWN %d\n", reg); | ||
502 | } | ||
503 | |||
504 | return 0; | ||
505 | } | ||
506 | |||
507 | static int dwc3_testmode_open(struct inode *inode, struct file *file) | ||
508 | { | ||
509 | return single_open(file, dwc3_testmode_show, inode->i_private); | ||
510 | } | ||
511 | |||
512 | static ssize_t dwc3_testmode_write(struct file *file, | ||
513 | const char __user *ubuf, size_t count, loff_t *ppos) | ||
514 | { | ||
515 | struct seq_file *s = file->private_data; | ||
516 | struct dwc3 *dwc = s->private; | ||
517 | unsigned long flags; | ||
518 | u32 testmode = 0; | ||
519 | char buf[32]; | ||
520 | |||
521 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | ||
522 | return -EFAULT; | ||
523 | |||
524 | if (!strncmp(buf, "test_j", 6)) | ||
525 | testmode = TEST_J; | ||
526 | else if (!strncmp(buf, "test_k", 6)) | ||
527 | testmode = TEST_K; | ||
528 | else if (!strncmp(buf, "test_se0_nak", 12)) | ||
529 | testmode = TEST_SE0_NAK; | ||
530 | else if (!strncmp(buf, "test_packet", 11)) | ||
531 | testmode = TEST_PACKET; | ||
532 | else if (!strncmp(buf, "test_force_enable", 17)) | ||
533 | testmode = TEST_FORCE_EN; | ||
534 | else | ||
535 | testmode = 0; | ||
536 | |||
537 | spin_lock_irqsave(&dwc->lock, flags); | ||
538 | dwc3_gadget_set_test_mode(dwc, testmode); | ||
539 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
540 | |||
541 | return count; | ||
542 | } | ||
543 | |||
544 | static const struct file_operations dwc3_testmode_fops = { | ||
545 | .open = dwc3_testmode_open, | ||
546 | .write = dwc3_testmode_write, | ||
547 | .read = seq_read, | ||
548 | .llseek = seq_lseek, | ||
549 | .release = single_release, | ||
550 | }; | ||
551 | |||
552 | static int dwc3_link_state_show(struct seq_file *s, void *unused) | ||
553 | { | ||
554 | struct dwc3 *dwc = s->private; | ||
555 | unsigned long flags; | ||
556 | enum dwc3_link_state state; | ||
557 | u32 reg; | ||
558 | |||
559 | spin_lock_irqsave(&dwc->lock, flags); | ||
560 | reg = dwc3_readl(dwc->regs, DWC3_DSTS); | ||
561 | state = DWC3_DSTS_USBLNKST(reg); | ||
562 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
563 | |||
564 | switch (state) { | ||
565 | case DWC3_LINK_STATE_U0: | ||
566 | seq_printf(s, "U0\n"); | ||
567 | break; | ||
568 | case DWC3_LINK_STATE_U1: | ||
569 | seq_printf(s, "U1\n"); | ||
570 | break; | ||
571 | case DWC3_LINK_STATE_U2: | ||
572 | seq_printf(s, "U2\n"); | ||
573 | break; | ||
574 | case DWC3_LINK_STATE_U3: | ||
575 | seq_printf(s, "U3\n"); | ||
576 | break; | ||
577 | case DWC3_LINK_STATE_SS_DIS: | ||
578 | seq_printf(s, "SS.Disabled\n"); | ||
579 | break; | ||
580 | case DWC3_LINK_STATE_RX_DET: | ||
581 | seq_printf(s, "Rx.Detect\n"); | ||
582 | break; | ||
583 | case DWC3_LINK_STATE_SS_INACT: | ||
584 | seq_printf(s, "SS.Inactive\n"); | ||
585 | break; | ||
586 | case DWC3_LINK_STATE_POLL: | ||
587 | seq_printf(s, "Poll\n"); | ||
588 | break; | ||
589 | case DWC3_LINK_STATE_RECOV: | ||
590 | seq_printf(s, "Recovery\n"); | ||
591 | break; | ||
592 | case DWC3_LINK_STATE_HRESET: | ||
593 | seq_printf(s, "HRESET\n"); | ||
594 | break; | ||
595 | case DWC3_LINK_STATE_CMPLY: | ||
596 | seq_printf(s, "Compliance\n"); | ||
597 | break; | ||
598 | case DWC3_LINK_STATE_LPBK: | ||
599 | seq_printf(s, "Loopback\n"); | ||
600 | break; | ||
601 | default: | ||
602 | seq_printf(s, "UNKNOWN %d\n", reg); | ||
603 | } | ||
604 | |||
605 | return 0; | ||
606 | } | ||
607 | |||
608 | static int dwc3_link_state_open(struct inode *inode, struct file *file) | ||
609 | { | ||
610 | return single_open(file, dwc3_link_state_show, inode->i_private); | ||
611 | } | ||
612 | |||
613 | static ssize_t dwc3_link_state_write(struct file *file, | ||
614 | const char __user *ubuf, size_t count, loff_t *ppos) | ||
615 | { | ||
616 | struct seq_file *s = file->private_data; | ||
617 | struct dwc3 *dwc = s->private; | ||
618 | unsigned long flags; | ||
619 | enum dwc3_link_state state = 0; | ||
620 | char buf[32]; | ||
621 | |||
622 | if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) | ||
623 | return -EFAULT; | ||
624 | |||
625 | if (!strncmp(buf, "SS.Disabled", 11)) | ||
626 | state = DWC3_LINK_STATE_SS_DIS; | ||
627 | else if (!strncmp(buf, "Rx.Detect", 9)) | ||
628 | state = DWC3_LINK_STATE_RX_DET; | ||
629 | else if (!strncmp(buf, "SS.Inactive", 11)) | ||
630 | state = DWC3_LINK_STATE_SS_INACT; | ||
631 | else if (!strncmp(buf, "Recovery", 8)) | ||
632 | state = DWC3_LINK_STATE_RECOV; | ||
633 | else if (!strncmp(buf, "Compliance", 10)) | ||
634 | state = DWC3_LINK_STATE_CMPLY; | ||
635 | else if (!strncmp(buf, "Loopback", 8)) | ||
636 | state = DWC3_LINK_STATE_LPBK; | ||
637 | else | ||
638 | return -EINVAL; | ||
639 | |||
640 | spin_lock_irqsave(&dwc->lock, flags); | ||
641 | dwc3_gadget_set_link_state(dwc, state); | ||
642 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
643 | |||
644 | return count; | ||
645 | } | ||
646 | |||
647 | static const struct file_operations dwc3_link_state_fops = { | ||
648 | .open = dwc3_link_state_open, | ||
649 | .write = dwc3_link_state_write, | ||
650 | .read = seq_read, | ||
651 | .llseek = seq_lseek, | ||
652 | .release = single_release, | ||
653 | }; | ||
654 | |||
467 | int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | 655 | int __devinit dwc3_debugfs_init(struct dwc3 *dwc) |
468 | { | 656 | { |
469 | struct dentry *root; | 657 | struct dentry *root; |
@@ -471,8 +659,8 @@ int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | |||
471 | int ret; | 659 | int ret; |
472 | 660 | ||
473 | root = debugfs_create_dir(dev_name(dwc->dev), NULL); | 661 | root = debugfs_create_dir(dev_name(dwc->dev), NULL); |
474 | if (IS_ERR(root)) { | 662 | if (!root) { |
475 | ret = PTR_ERR(root); | 663 | ret = -ENOMEM; |
476 | goto err0; | 664 | goto err0; |
477 | } | 665 | } |
478 | 666 | ||
@@ -480,15 +668,29 @@ int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | |||
480 | 668 | ||
481 | file = debugfs_create_file("regdump", S_IRUGO, root, dwc, | 669 | file = debugfs_create_file("regdump", S_IRUGO, root, dwc, |
482 | &dwc3_regdump_fops); | 670 | &dwc3_regdump_fops); |
483 | if (IS_ERR(file)) { | 671 | if (!file) { |
484 | ret = PTR_ERR(file); | 672 | ret = -ENOMEM; |
485 | goto err1; | 673 | goto err1; |
486 | } | 674 | } |
487 | 675 | ||
488 | file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, | 676 | file = debugfs_create_file("mode", S_IRUGO | S_IWUSR, root, |
489 | dwc, &dwc3_mode_fops); | 677 | dwc, &dwc3_mode_fops); |
490 | if (IS_ERR(file)) { | 678 | if (!file) { |
491 | ret = PTR_ERR(file); | 679 | ret = -ENOMEM; |
680 | goto err1; | ||
681 | } | ||
682 | |||
683 | file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, root, | ||
684 | dwc, &dwc3_testmode_fops); | ||
685 | if (!file) { | ||
686 | ret = -ENOMEM; | ||
687 | goto err1; | ||
688 | } | ||
689 | |||
690 | file = debugfs_create_file("link_state", S_IRUGO | S_IWUSR, root, | ||
691 | dwc, &dwc3_link_state_fops); | ||
692 | if (!file) { | ||
693 | ret = -ENOMEM; | ||
492 | goto err1; | 694 | goto err1; |
493 | } | 695 | } |
494 | 696 | ||
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c new file mode 100644 index 000000000000..d19030198086 --- /dev/null +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /** | ||
2 | * dwc3-exynos.c - Samsung EXYNOS DWC3 Specific Glue layer | ||
3 | * | ||
4 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. | ||
5 | * http://www.samsung.com | ||
6 | * | ||
7 | * Author: Anton Tikhomirov <av.tikhomirov@samsung.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | */ | ||
14 | |||
15 | #include <linux/module.h> | ||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/platform_device.h> | ||
19 | #include <linux/platform_data/dwc3-exynos.h> | ||
20 | #include <linux/dma-mapping.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/clk.h> | ||
23 | |||
24 | #include "core.h" | ||
25 | |||
26 | struct dwc3_exynos { | ||
27 | struct platform_device *dwc3; | ||
28 | struct device *dev; | ||
29 | |||
30 | struct clk *clk; | ||
31 | }; | ||
32 | |||
33 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | ||
34 | { | ||
35 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | ||
36 | struct platform_device *dwc3; | ||
37 | struct dwc3_exynos *exynos; | ||
38 | struct clk *clk; | ||
39 | |||
40 | int devid; | ||
41 | int ret = -ENOMEM; | ||
42 | |||
43 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); | ||
44 | if (!exynos) { | ||
45 | dev_err(&pdev->dev, "not enough memory\n"); | ||
46 | goto err0; | ||
47 | } | ||
48 | |||
49 | platform_set_drvdata(pdev, exynos); | ||
50 | |||
51 | devid = dwc3_get_device_id(); | ||
52 | if (devid < 0) | ||
53 | goto err1; | ||
54 | |||
55 | dwc3 = platform_device_alloc("dwc3", devid); | ||
56 | if (!dwc3) { | ||
57 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | ||
58 | goto err2; | ||
59 | } | ||
60 | |||
61 | clk = clk_get(&pdev->dev, "usbdrd30"); | ||
62 | if (IS_ERR(clk)) { | ||
63 | dev_err(&pdev->dev, "couldn't get clock\n"); | ||
64 | ret = -EINVAL; | ||
65 | goto err3; | ||
66 | } | ||
67 | |||
68 | dma_set_coherent_mask(&dwc3->dev, pdev->dev.coherent_dma_mask); | ||
69 | |||
70 | dwc3->dev.parent = &pdev->dev; | ||
71 | dwc3->dev.dma_mask = pdev->dev.dma_mask; | ||
72 | dwc3->dev.dma_parms = pdev->dev.dma_parms; | ||
73 | exynos->dwc3 = dwc3; | ||
74 | exynos->dev = &pdev->dev; | ||
75 | exynos->clk = clk; | ||
76 | |||
77 | clk_enable(exynos->clk); | ||
78 | |||
79 | /* PHY initialization */ | ||
80 | if (!pdata) { | ||
81 | dev_dbg(&pdev->dev, "missing platform data\n"); | ||
82 | } else { | ||
83 | if (pdata->phy_init) | ||
84 | pdata->phy_init(pdev, pdata->phy_type); | ||
85 | } | ||
86 | |||
87 | ret = platform_device_add_resources(dwc3, pdev->resource, | ||
88 | pdev->num_resources); | ||
89 | if (ret) { | ||
90 | dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n"); | ||
91 | goto err4; | ||
92 | } | ||
93 | |||
94 | ret = platform_device_add(dwc3); | ||
95 | if (ret) { | ||
96 | dev_err(&pdev->dev, "failed to register dwc3 device\n"); | ||
97 | goto err4; | ||
98 | } | ||
99 | |||
100 | return 0; | ||
101 | |||
102 | err4: | ||
103 | if (pdata && pdata->phy_exit) | ||
104 | pdata->phy_exit(pdev, pdata->phy_type); | ||
105 | |||
106 | clk_disable(clk); | ||
107 | clk_put(clk); | ||
108 | err3: | ||
109 | platform_device_put(dwc3); | ||
110 | err2: | ||
111 | dwc3_put_device_id(devid); | ||
112 | err1: | ||
113 | kfree(exynos); | ||
114 | err0: | ||
115 | return ret; | ||
116 | } | ||
117 | |||
118 | static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | ||
119 | { | ||
120 | struct dwc3_exynos *exynos = platform_get_drvdata(pdev); | ||
121 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | ||
122 | |||
123 | platform_device_unregister(exynos->dwc3); | ||
124 | |||
125 | dwc3_put_device_id(exynos->dwc3->id); | ||
126 | |||
127 | if (pdata && pdata->phy_exit) | ||
128 | pdata->phy_exit(pdev, pdata->phy_type); | ||
129 | |||
130 | clk_disable(exynos->clk); | ||
131 | clk_put(exynos->clk); | ||
132 | |||
133 | kfree(exynos); | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static struct platform_driver dwc3_exynos_driver = { | ||
139 | .probe = dwc3_exynos_probe, | ||
140 | .remove = __devexit_p(dwc3_exynos_remove), | ||
141 | .driver = { | ||
142 | .name = "exynos-dwc3", | ||
143 | }, | ||
144 | }; | ||
145 | |||
146 | module_platform_driver(dwc3_exynos_driver); | ||
147 | |||
148 | MODULE_ALIAS("platform:exynos-dwc3"); | ||
149 | MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>"); | ||
150 | MODULE_LICENSE("GPL"); | ||
151 | MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer"); | ||
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 3274ac8f1200..d7d9c0ec9515 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/dma-mapping.h> | 46 | #include <linux/dma-mapping.h> |
47 | #include <linux/ioport.h> | 47 | #include <linux/ioport.h> |
48 | #include <linux/io.h> | 48 | #include <linux/io.h> |
49 | #include <linux/module.h> | 49 | #include <linux/of.h> |
50 | 50 | ||
51 | #include "core.h" | 51 | #include "core.h" |
52 | #include "io.h" | 52 | #include "io.h" |
@@ -197,91 +197,99 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) | |||
197 | static int __devinit dwc3_omap_probe(struct platform_device *pdev) | 197 | static int __devinit dwc3_omap_probe(struct platform_device *pdev) |
198 | { | 198 | { |
199 | struct dwc3_omap_data *pdata = pdev->dev.platform_data; | 199 | struct dwc3_omap_data *pdata = pdev->dev.platform_data; |
200 | struct device_node *node = pdev->dev.of_node; | ||
201 | |||
200 | struct platform_device *dwc3; | 202 | struct platform_device *dwc3; |
201 | struct dwc3_omap *omap; | 203 | struct dwc3_omap *omap; |
202 | struct resource *res; | 204 | struct resource *res; |
205 | struct device *dev = &pdev->dev; | ||
203 | 206 | ||
204 | int devid; | 207 | int devid; |
208 | int size; | ||
205 | int ret = -ENOMEM; | 209 | int ret = -ENOMEM; |
206 | int irq; | 210 | int irq; |
207 | 211 | ||
212 | const u32 *utmi_mode; | ||
208 | u32 reg; | 213 | u32 reg; |
209 | 214 | ||
210 | void __iomem *base; | 215 | void __iomem *base; |
211 | void *context; | 216 | void *context; |
212 | 217 | ||
213 | omap = kzalloc(sizeof(*omap), GFP_KERNEL); | 218 | omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL); |
214 | if (!omap) { | 219 | if (!omap) { |
215 | dev_err(&pdev->dev, "not enough memory\n"); | 220 | dev_err(dev, "not enough memory\n"); |
216 | goto err0; | 221 | return -ENOMEM; |
217 | } | 222 | } |
218 | 223 | ||
219 | platform_set_drvdata(pdev, omap); | 224 | platform_set_drvdata(pdev, omap); |
220 | 225 | ||
221 | irq = platform_get_irq(pdev, 1); | 226 | irq = platform_get_irq(pdev, 1); |
222 | if (irq < 0) { | 227 | if (irq < 0) { |
223 | dev_err(&pdev->dev, "missing IRQ resource\n"); | 228 | dev_err(dev, "missing IRQ resource\n"); |
224 | ret = -EINVAL; | 229 | return -EINVAL; |
225 | goto err1; | ||
226 | } | 230 | } |
227 | 231 | ||
228 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 232 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
229 | if (!res) { | 233 | if (!res) { |
230 | dev_err(&pdev->dev, "missing memory base resource\n"); | 234 | dev_err(dev, "missing memory base resource\n"); |
231 | ret = -EINVAL; | 235 | return -EINVAL; |
232 | goto err1; | ||
233 | } | 236 | } |
234 | 237 | ||
235 | base = ioremap_nocache(res->start, resource_size(res)); | 238 | base = devm_ioremap_nocache(dev, res->start, resource_size(res)); |
236 | if (!base) { | 239 | if (!base) { |
237 | dev_err(&pdev->dev, "ioremap failed\n"); | 240 | dev_err(dev, "ioremap failed\n"); |
238 | goto err1; | 241 | return -ENOMEM; |
239 | } | 242 | } |
240 | 243 | ||
241 | devid = dwc3_get_device_id(); | 244 | devid = dwc3_get_device_id(); |
242 | if (devid < 0) | 245 | if (devid < 0) |
243 | goto err2; | 246 | return -ENODEV; |
244 | 247 | ||
245 | dwc3 = platform_device_alloc("dwc3", devid); | 248 | dwc3 = platform_device_alloc("dwc3", devid); |
246 | if (!dwc3) { | 249 | if (!dwc3) { |
247 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 250 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
248 | goto err3; | 251 | goto err1; |
249 | } | 252 | } |
250 | 253 | ||
251 | context = kzalloc(resource_size(res), GFP_KERNEL); | 254 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); |
252 | if (!context) { | 255 | if (!context) { |
253 | dev_err(&pdev->dev, "couldn't allocate dwc3 context memory\n"); | 256 | dev_err(dev, "couldn't allocate dwc3 context memory\n"); |
254 | goto err4; | 257 | goto err2; |
255 | } | 258 | } |
256 | 259 | ||
257 | spin_lock_init(&omap->lock); | 260 | spin_lock_init(&omap->lock); |
258 | dma_set_coherent_mask(&dwc3->dev, pdev->dev.coherent_dma_mask); | 261 | dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask); |
259 | 262 | ||
260 | dwc3->dev.parent = &pdev->dev; | 263 | dwc3->dev.parent = dev; |
261 | dwc3->dev.dma_mask = pdev->dev.dma_mask; | 264 | dwc3->dev.dma_mask = dev->dma_mask; |
262 | dwc3->dev.dma_parms = pdev->dev.dma_parms; | 265 | dwc3->dev.dma_parms = dev->dma_parms; |
263 | omap->resource_size = resource_size(res); | 266 | omap->resource_size = resource_size(res); |
264 | omap->context = context; | 267 | omap->context = context; |
265 | omap->dev = &pdev->dev; | 268 | omap->dev = dev; |
266 | omap->irq = irq; | 269 | omap->irq = irq; |
267 | omap->base = base; | 270 | omap->base = base; |
268 | omap->dwc3 = dwc3; | 271 | omap->dwc3 = dwc3; |
269 | 272 | ||
270 | reg = dwc3_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS); | 273 | reg = dwc3_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS); |
271 | 274 | ||
272 | if (!pdata) { | 275 | utmi_mode = of_get_property(node, "utmi-mode", &size); |
273 | dev_dbg(&pdev->dev, "missing platform data\n"); | 276 | if (utmi_mode && size == sizeof(*utmi_mode)) { |
277 | reg |= *utmi_mode; | ||
274 | } else { | 278 | } else { |
275 | switch (pdata->utmi_mode) { | 279 | if (!pdata) { |
276 | case DWC3_OMAP_UTMI_MODE_SW: | 280 | dev_dbg(dev, "missing platform data\n"); |
277 | reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE; | 281 | } else { |
278 | break; | 282 | switch (pdata->utmi_mode) { |
279 | case DWC3_OMAP_UTMI_MODE_HW: | 283 | case DWC3_OMAP_UTMI_MODE_SW: |
280 | reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE; | 284 | reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE; |
281 | break; | 285 | break; |
282 | default: | 286 | case DWC3_OMAP_UTMI_MODE_HW: |
283 | dev_dbg(&pdev->dev, "UNKNOWN utmi mode %d\n", | 287 | reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE; |
284 | pdata->utmi_mode); | 288 | break; |
289 | default: | ||
290 | dev_dbg(dev, "UNKNOWN utmi mode %d\n", | ||
291 | pdata->utmi_mode); | ||
292 | } | ||
285 | } | 293 | } |
286 | } | 294 | } |
287 | 295 | ||
@@ -300,12 +308,12 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
300 | 308 | ||
301 | dwc3_writel(omap->base, USBOTGSS_SYSCONFIG, reg); | 309 | dwc3_writel(omap->base, USBOTGSS_SYSCONFIG, reg); |
302 | 310 | ||
303 | ret = request_irq(omap->irq, dwc3_omap_interrupt, 0, | 311 | ret = devm_request_irq(dev, omap->irq, dwc3_omap_interrupt, 0, |
304 | "dwc3-omap", omap); | 312 | "dwc3-omap", omap); |
305 | if (ret) { | 313 | if (ret) { |
306 | dev_err(&pdev->dev, "failed to request IRQ #%d --> %d\n", | 314 | dev_err(dev, "failed to request IRQ #%d --> %d\n", |
307 | omap->irq, ret); | 315 | omap->irq, ret); |
308 | goto err5; | 316 | goto err2; |
309 | } | 317 | } |
310 | 318 | ||
311 | /* enable all IRQs */ | 319 | /* enable all IRQs */ |
@@ -327,37 +335,24 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
327 | ret = platform_device_add_resources(dwc3, pdev->resource, | 335 | ret = platform_device_add_resources(dwc3, pdev->resource, |
328 | pdev->num_resources); | 336 | pdev->num_resources); |
329 | if (ret) { | 337 | if (ret) { |
330 | dev_err(&pdev->dev, "couldn't add resources to dwc3 device\n"); | 338 | dev_err(dev, "couldn't add resources to dwc3 device\n"); |
331 | goto err6; | 339 | goto err2; |
332 | } | 340 | } |
333 | 341 | ||
334 | ret = platform_device_add(dwc3); | 342 | ret = platform_device_add(dwc3); |
335 | if (ret) { | 343 | if (ret) { |
336 | dev_err(&pdev->dev, "failed to register dwc3 device\n"); | 344 | dev_err(dev, "failed to register dwc3 device\n"); |
337 | goto err6; | 345 | goto err2; |
338 | } | 346 | } |
339 | 347 | ||
340 | return 0; | 348 | return 0; |
341 | 349 | ||
342 | err6: | ||
343 | free_irq(omap->irq, omap); | ||
344 | |||
345 | err5: | ||
346 | kfree(omap->context); | ||
347 | |||
348 | err4: | ||
349 | platform_device_put(dwc3); | ||
350 | |||
351 | err3: | ||
352 | dwc3_put_device_id(devid); | ||
353 | |||
354 | err2: | 350 | err2: |
355 | iounmap(base); | 351 | platform_device_put(dwc3); |
356 | 352 | ||
357 | err1: | 353 | err1: |
358 | kfree(omap); | 354 | dwc3_put_device_id(devid); |
359 | 355 | ||
360 | err0: | ||
361 | return ret; | 356 | return ret; |
362 | } | 357 | } |
363 | 358 | ||
@@ -368,11 +363,6 @@ static int __devexit dwc3_omap_remove(struct platform_device *pdev) | |||
368 | platform_device_unregister(omap->dwc3); | 363 | platform_device_unregister(omap->dwc3); |
369 | 364 | ||
370 | dwc3_put_device_id(omap->dwc3->id); | 365 | dwc3_put_device_id(omap->dwc3->id); |
371 | free_irq(omap->irq, omap); | ||
372 | iounmap(omap->base); | ||
373 | |||
374 | kfree(omap->context); | ||
375 | kfree(omap); | ||
376 | 366 | ||
377 | return 0; | 367 | return 0; |
378 | } | 368 | } |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index c68e4270457a..a9ca9adba391 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -61,32 +61,36 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
61 | struct dwc3_pci *glue; | 61 | struct dwc3_pci *glue; |
62 | int ret = -ENOMEM; | 62 | int ret = -ENOMEM; |
63 | int devid; | 63 | int devid; |
64 | struct device *dev = &pci->dev; | ||
64 | 65 | ||
65 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 66 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); |
66 | if (!glue) { | 67 | if (!glue) { |
67 | dev_err(&pci->dev, "not enough memory\n"); | 68 | dev_err(dev, "not enough memory\n"); |
68 | goto err0; | 69 | return -ENOMEM; |
69 | } | 70 | } |
70 | 71 | ||
71 | glue->dev = &pci->dev; | 72 | glue->dev = dev; |
72 | 73 | ||
73 | ret = pci_enable_device(pci); | 74 | ret = pci_enable_device(pci); |
74 | if (ret) { | 75 | if (ret) { |
75 | dev_err(&pci->dev, "failed to enable pci device\n"); | 76 | dev_err(dev, "failed to enable pci device\n"); |
76 | goto err1; | 77 | return -ENODEV; |
77 | } | 78 | } |
78 | 79 | ||
79 | pci_set_power_state(pci, PCI_D0); | 80 | pci_set_power_state(pci, PCI_D0); |
80 | pci_set_master(pci); | 81 | pci_set_master(pci); |
81 | 82 | ||
82 | devid = dwc3_get_device_id(); | 83 | devid = dwc3_get_device_id(); |
83 | if (devid < 0) | 84 | if (devid < 0) { |
84 | goto err2; | 85 | ret = -ENOMEM; |
86 | goto err1; | ||
87 | } | ||
85 | 88 | ||
86 | dwc3 = platform_device_alloc("dwc3", devid); | 89 | dwc3 = platform_device_alloc("dwc3", devid); |
87 | if (!dwc3) { | 90 | if (!dwc3) { |
88 | dev_err(&pci->dev, "couldn't allocate dwc3 device\n"); | 91 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
89 | goto err3; | 92 | ret = -ENOMEM; |
93 | goto err1; | ||
90 | } | 94 | } |
91 | 95 | ||
92 | memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res)); | 96 | memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res)); |
@@ -102,41 +106,37 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
102 | 106 | ||
103 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); | 107 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); |
104 | if (ret) { | 108 | if (ret) { |
105 | dev_err(&pci->dev, "couldn't add resources to dwc3 device\n"); | 109 | dev_err(dev, "couldn't add resources to dwc3 device\n"); |
106 | goto err4; | 110 | goto err2; |
107 | } | 111 | } |
108 | 112 | ||
109 | pci_set_drvdata(pci, glue); | 113 | pci_set_drvdata(pci, glue); |
110 | 114 | ||
111 | dma_set_coherent_mask(&dwc3->dev, pci->dev.coherent_dma_mask); | 115 | dma_set_coherent_mask(&dwc3->dev, dev->coherent_dma_mask); |
112 | 116 | ||
113 | dwc3->dev.dma_mask = pci->dev.dma_mask; | 117 | dwc3->dev.dma_mask = dev->dma_mask; |
114 | dwc3->dev.dma_parms = pci->dev.dma_parms; | 118 | dwc3->dev.dma_parms = dev->dma_parms; |
115 | dwc3->dev.parent = &pci->dev; | 119 | dwc3->dev.parent = dev; |
116 | glue->dwc3 = dwc3; | 120 | glue->dwc3 = dwc3; |
117 | 121 | ||
118 | ret = platform_device_add(dwc3); | 122 | ret = platform_device_add(dwc3); |
119 | if (ret) { | 123 | if (ret) { |
120 | dev_err(&pci->dev, "failed to register dwc3 device\n"); | 124 | dev_err(dev, "failed to register dwc3 device\n"); |
121 | goto err4; | 125 | goto err3; |
122 | } | 126 | } |
123 | 127 | ||
124 | return 0; | 128 | return 0; |
125 | 129 | ||
126 | err4: | 130 | err3: |
127 | pci_set_drvdata(pci, NULL); | 131 | pci_set_drvdata(pci, NULL); |
128 | platform_device_put(dwc3); | 132 | platform_device_put(dwc3); |
129 | 133 | ||
130 | err3: | ||
131 | dwc3_put_device_id(devid); | ||
132 | |||
133 | err2: | 134 | err2: |
134 | pci_disable_device(pci); | 135 | dwc3_put_device_id(devid); |
135 | 136 | ||
136 | err1: | 137 | err1: |
137 | kfree(glue); | 138 | pci_disable_device(pci); |
138 | 139 | ||
139 | err0: | ||
140 | return ret; | 140 | return ret; |
141 | } | 141 | } |
142 | 142 | ||
@@ -148,7 +148,6 @@ static void __devexit dwc3_pci_remove(struct pci_dev *pci) | |||
148 | platform_device_unregister(glue->dwc3); | 148 | platform_device_unregister(glue->dwc3); |
149 | pci_set_drvdata(pci, NULL); | 149 | pci_set_drvdata(pci, NULL); |
150 | pci_disable_device(pci); | 150 | pci_disable_device(pci); |
151 | kfree(glue); | ||
152 | } | 151 | } |
153 | 152 | ||
154 | static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { | 153 | static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index c8df1dd967ef..25910e251c04 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -76,8 +76,7 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
76 | u32 len, u32 type) | 76 | u32 len, u32 type) |
77 | { | 77 | { |
78 | struct dwc3_gadget_ep_cmd_params params; | 78 | struct dwc3_gadget_ep_cmd_params params; |
79 | struct dwc3_trb_hw *trb_hw; | 79 | struct dwc3_trb *trb; |
80 | struct dwc3_trb trb; | ||
81 | struct dwc3_ep *dep; | 80 | struct dwc3_ep *dep; |
82 | 81 | ||
83 | int ret; | 82 | int ret; |
@@ -88,19 +87,17 @@ static int dwc3_ep0_start_trans(struct dwc3 *dwc, u8 epnum, dma_addr_t buf_dma, | |||
88 | return 0; | 87 | return 0; |
89 | } | 88 | } |
90 | 89 | ||
91 | trb_hw = dwc->ep0_trb; | 90 | trb = dwc->ep0_trb; |
92 | memset(&trb, 0, sizeof(trb)); | ||
93 | 91 | ||
94 | trb.trbctl = type; | 92 | trb->bpl = lower_32_bits(buf_dma); |
95 | trb.bplh = buf_dma; | 93 | trb->bph = upper_32_bits(buf_dma); |
96 | trb.length = len; | 94 | trb->size = len; |
95 | trb->ctrl = type; | ||
97 | 96 | ||
98 | trb.hwo = 1; | 97 | trb->ctrl |= (DWC3_TRB_CTRL_HWO |
99 | trb.lst = 1; | 98 | | DWC3_TRB_CTRL_LST |
100 | trb.ioc = 1; | 99 | | DWC3_TRB_CTRL_IOC |
101 | trb.isp_imi = 1; | 100 | | DWC3_TRB_CTRL_ISP_IMI); |
102 | |||
103 | dwc3_trb_to_hw(&trb, trb_hw); | ||
104 | 101 | ||
105 | memset(¶ms, 0, sizeof(params)); | 102 | memset(¶ms, 0, sizeof(params)); |
106 | params.param0 = upper_32_bits(dwc->ep0_trb_addr); | 103 | params.param0 = upper_32_bits(dwc->ep0_trb_addr); |
@@ -302,7 +299,7 @@ static int dwc3_ep0_handle_status(struct dwc3 *dwc, | |||
302 | dep = dwc->eps[0]; | 299 | dep = dwc->eps[0]; |
303 | dwc->ep0_usb_req.dep = dep; | 300 | dwc->ep0_usb_req.dep = dep; |
304 | dwc->ep0_usb_req.request.length = sizeof(*response_pkt); | 301 | dwc->ep0_usb_req.request.length = sizeof(*response_pkt); |
305 | dwc->ep0_usb_req.request.dma = dwc->setup_buf_addr; | 302 | dwc->ep0_usb_req.request.buf = dwc->setup_buf; |
306 | dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl; | 303 | dwc->ep0_usb_req.request.complete = dwc3_ep0_status_cmpl; |
307 | 304 | ||
308 | return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req); | 305 | return __dwc3_gadget_ep0_queue(dep, &dwc->ep0_usb_req); |
@@ -315,9 +312,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc, | |||
315 | u32 recip; | 312 | u32 recip; |
316 | u32 wValue; | 313 | u32 wValue; |
317 | u32 wIndex; | 314 | u32 wIndex; |
318 | u32 reg; | ||
319 | int ret; | 315 | int ret; |
320 | u32 mode; | ||
321 | 316 | ||
322 | wValue = le16_to_cpu(ctrl->wValue); | 317 | wValue = le16_to_cpu(ctrl->wValue); |
323 | wIndex = le16_to_cpu(ctrl->wIndex); | 318 | wIndex = le16_to_cpu(ctrl->wIndex); |
@@ -356,25 +351,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc, | |||
356 | if (!set) | 351 | if (!set) |
357 | return -EINVAL; | 352 | return -EINVAL; |
358 | 353 | ||
359 | mode = wIndex >> 8; | 354 | dwc->test_mode_nr = wIndex >> 8; |
360 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 355 | dwc->test_mode = true; |
361 | reg &= ~DWC3_DCTL_TSTCTRL_MASK; | ||
362 | |||
363 | switch (mode) { | ||
364 | case TEST_J: | ||
365 | case TEST_K: | ||
366 | case TEST_SE0_NAK: | ||
367 | case TEST_PACKET: | ||
368 | case TEST_FORCE_EN: | ||
369 | reg |= mode << 1; | ||
370 | break; | ||
371 | default: | ||
372 | return -EINVAL; | ||
373 | } | ||
374 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | ||
375 | break; | ||
376 | default: | ||
377 | return -EINVAL; | ||
378 | } | 356 | } |
379 | break; | 357 | break; |
380 | 358 | ||
@@ -396,7 +374,7 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc, | |||
396 | case USB_RECIP_ENDPOINT: | 374 | case USB_RECIP_ENDPOINT: |
397 | switch (wValue) { | 375 | switch (wValue) { |
398 | case USB_ENDPOINT_HALT: | 376 | case USB_ENDPOINT_HALT: |
399 | dep = dwc3_wIndex_to_dep(dwc, wIndex); | 377 | dep = dwc3_wIndex_to_dep(dwc, wIndex); |
400 | if (!dep) | 378 | if (!dep) |
401 | return -EINVAL; | 379 | return -EINVAL; |
402 | ret = __dwc3_gadget_ep_set_halt(dep, set); | 380 | ret = __dwc3_gadget_ep_set_halt(dep, set); |
@@ -470,8 +448,11 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
470 | case DWC3_ADDRESS_STATE: | 448 | case DWC3_ADDRESS_STATE: |
471 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 449 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
472 | /* if the cfg matches and the cfg is non zero */ | 450 | /* if the cfg matches and the cfg is non zero */ |
473 | if (!ret && cfg) | 451 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { |
474 | dwc->dev_state = DWC3_CONFIGURED_STATE; | 452 | dwc->dev_state = DWC3_CONFIGURED_STATE; |
453 | dwc->resize_fifos = true; | ||
454 | dev_dbg(dwc->dev, "resize fifos flag SET\n"); | ||
455 | } | ||
475 | break; | 456 | break; |
476 | 457 | ||
477 | case DWC3_CONFIGURED_STATE: | 458 | case DWC3_CONFIGURED_STATE: |
@@ -560,9 +541,10 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
560 | { | 541 | { |
561 | struct dwc3_request *r = NULL; | 542 | struct dwc3_request *r = NULL; |
562 | struct usb_request *ur; | 543 | struct usb_request *ur; |
563 | struct dwc3_trb trb; | 544 | struct dwc3_trb *trb; |
564 | struct dwc3_ep *ep0; | 545 | struct dwc3_ep *ep0; |
565 | u32 transferred; | 546 | u32 transferred; |
547 | u32 length; | ||
566 | u8 epnum; | 548 | u8 epnum; |
567 | 549 | ||
568 | epnum = event->endpoint_number; | 550 | epnum = event->endpoint_number; |
@@ -573,16 +555,16 @@ static void dwc3_ep0_complete_data(struct dwc3 *dwc, | |||
573 | r = next_request(&ep0->request_list); | 555 | r = next_request(&ep0->request_list); |
574 | ur = &r->request; | 556 | ur = &r->request; |
575 | 557 | ||
576 | dwc3_trb_to_nat(dwc->ep0_trb, &trb); | 558 | trb = dwc->ep0_trb; |
559 | length = trb->size & DWC3_TRB_SIZE_MASK; | ||
577 | 560 | ||
578 | if (dwc->ep0_bounced) { | 561 | if (dwc->ep0_bounced) { |
579 | |||
580 | transferred = min_t(u32, ur->length, | 562 | transferred = min_t(u32, ur->length, |
581 | ep0->endpoint.maxpacket - trb.length); | 563 | ep0->endpoint.maxpacket - length); |
582 | memcpy(ur->buf, dwc->ep0_bounce, transferred); | 564 | memcpy(ur->buf, dwc->ep0_bounce, transferred); |
583 | dwc->ep0_bounced = false; | 565 | dwc->ep0_bounced = false; |
584 | } else { | 566 | } else { |
585 | transferred = ur->length - trb.length; | 567 | transferred = ur->length - length; |
586 | ur->actual += transferred; | 568 | ur->actual += transferred; |
587 | } | 569 | } |
588 | 570 | ||
@@ -614,6 +596,17 @@ static void dwc3_ep0_complete_req(struct dwc3 *dwc, | |||
614 | dwc3_gadget_giveback(dep, r, 0); | 596 | dwc3_gadget_giveback(dep, r, 0); |
615 | } | 597 | } |
616 | 598 | ||
599 | if (dwc->test_mode) { | ||
600 | int ret; | ||
601 | |||
602 | ret = dwc3_gadget_set_test_mode(dwc, dwc->test_mode_nr); | ||
603 | if (ret < 0) { | ||
604 | dev_dbg(dwc->dev, "Invalid Test #%d\n", | ||
605 | dwc->test_mode_nr); | ||
606 | dwc3_ep0_stall_and_restart(dwc); | ||
607 | } | ||
608 | } | ||
609 | |||
617 | dwc->ep0state = EP0_SETUP_PHASE; | 610 | dwc->ep0state = EP0_SETUP_PHASE; |
618 | dwc3_ep0_out_start(dwc); | 611 | dwc3_ep0_out_start(dwc); |
619 | } | 612 | } |
@@ -624,6 +617,7 @@ static void dwc3_ep0_xfer_complete(struct dwc3 *dwc, | |||
624 | struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; | 617 | struct dwc3_ep *dep = dwc->eps[event->endpoint_number]; |
625 | 618 | ||
626 | dep->flags &= ~DWC3_EP_BUSY; | 619 | dep->flags &= ~DWC3_EP_BUSY; |
620 | dep->res_trans_idx = 0; | ||
627 | dwc->setup_packet_pending = false; | 621 | dwc->setup_packet_pending = false; |
628 | 622 | ||
629 | switch (dwc->ep0state) { | 623 | switch (dwc->ep0state) { |
@@ -679,7 +673,12 @@ static void dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
679 | DWC3_TRBCTL_CONTROL_DATA); | 673 | DWC3_TRBCTL_CONTROL_DATA); |
680 | } else if ((req->request.length % dep->endpoint.maxpacket) | 674 | } else if ((req->request.length % dep->endpoint.maxpacket) |
681 | && (event->endpoint_number == 0)) { | 675 | && (event->endpoint_number == 0)) { |
682 | dwc3_map_buffer_to_dma(req); | 676 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, |
677 | event->endpoint_number); | ||
678 | if (ret) { | ||
679 | dev_dbg(dwc->dev, "failed to map request\n"); | ||
680 | return; | ||
681 | } | ||
683 | 682 | ||
684 | WARN_ON(req->request.length > dep->endpoint.maxpacket); | 683 | WARN_ON(req->request.length > dep->endpoint.maxpacket); |
685 | 684 | ||
@@ -694,7 +693,12 @@ static void dwc3_ep0_do_control_data(struct dwc3 *dwc, | |||
694 | dwc->ep0_bounce_addr, dep->endpoint.maxpacket, | 693 | dwc->ep0_bounce_addr, dep->endpoint.maxpacket, |
695 | DWC3_TRBCTL_CONTROL_DATA); | 694 | DWC3_TRBCTL_CONTROL_DATA); |
696 | } else { | 695 | } else { |
697 | dwc3_map_buffer_to_dma(req); | 696 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, |
697 | event->endpoint_number); | ||
698 | if (ret) { | ||
699 | dev_dbg(dwc->dev, "failed to map request\n"); | ||
700 | return; | ||
701 | } | ||
698 | 702 | ||
699 | ret = dwc3_ep0_start_trans(dwc, event->endpoint_number, | 703 | ret = dwc3_ep0_start_trans(dwc, event->endpoint_number, |
700 | req->request.dma, req->request.length, | 704 | req->request.dma, req->request.length, |
@@ -720,6 +724,12 @@ static void dwc3_ep0_do_control_status(struct dwc3 *dwc, u32 epnum) | |||
720 | { | 724 | { |
721 | struct dwc3_ep *dep = dwc->eps[epnum]; | 725 | struct dwc3_ep *dep = dwc->eps[epnum]; |
722 | 726 | ||
727 | if (dwc->resize_fifos) { | ||
728 | dev_dbg(dwc->dev, "starting to resize fifos\n"); | ||
729 | dwc3_gadget_resize_tx_fifos(dwc); | ||
730 | dwc->resize_fifos = 0; | ||
731 | } | ||
732 | |||
723 | WARN_ON(dwc3_ep0_start_control_status(dep)); | 733 | WARN_ON(dwc3_ep0_start_control_status(dep)); |
724 | } | 734 | } |
725 | 735 | ||
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 064b6e2cd411..5255fe975ea1 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -54,68 +54,162 @@ | |||
54 | #include "gadget.h" | 54 | #include "gadget.h" |
55 | #include "io.h" | 55 | #include "io.h" |
56 | 56 | ||
57 | #define DMA_ADDR_INVALID (~(dma_addr_t)0) | 57 | /** |
58 | 58 | * dwc3_gadget_set_test_mode - Enables USB2 Test Modes | |
59 | void dwc3_map_buffer_to_dma(struct dwc3_request *req) | 59 | * @dwc: pointer to our context structure |
60 | * @mode: the mode to set (J, K SE0 NAK, Force Enable) | ||
61 | * | ||
62 | * Caller should take care of locking. This function will | ||
63 | * return 0 on success or -EINVAL if wrong Test Selector | ||
64 | * is passed | ||
65 | */ | ||
66 | int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode) | ||
60 | { | 67 | { |
61 | struct dwc3 *dwc = req->dep->dwc; | 68 | u32 reg; |
62 | 69 | ||
63 | if (req->request.length == 0) { | 70 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
64 | /* req->request.dma = dwc->setup_buf_addr; */ | 71 | reg &= ~DWC3_DCTL_TSTCTRL_MASK; |
65 | return; | 72 | |
73 | switch (mode) { | ||
74 | case TEST_J: | ||
75 | case TEST_K: | ||
76 | case TEST_SE0_NAK: | ||
77 | case TEST_PACKET: | ||
78 | case TEST_FORCE_EN: | ||
79 | reg |= mode << 1; | ||
80 | break; | ||
81 | default: | ||
82 | return -EINVAL; | ||
66 | } | 83 | } |
67 | 84 | ||
68 | if (req->request.num_sgs) { | 85 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
69 | int mapped; | ||
70 | 86 | ||
71 | mapped = dma_map_sg(dwc->dev, req->request.sg, | 87 | return 0; |
72 | req->request.num_sgs, | 88 | } |
73 | req->direction ? DMA_TO_DEVICE | ||
74 | : DMA_FROM_DEVICE); | ||
75 | if (mapped < 0) { | ||
76 | dev_err(dwc->dev, "failed to map SGs\n"); | ||
77 | return; | ||
78 | } | ||
79 | 89 | ||
80 | req->request.num_mapped_sgs = mapped; | 90 | /** |
81 | return; | 91 | * dwc3_gadget_set_link_state - Sets USB Link to a particular State |
82 | } | 92 | * @dwc: pointer to our context structure |
93 | * @state: the state to put link into | ||
94 | * | ||
95 | * Caller should take care of locking. This function will | ||
96 | * return 0 on success or -ETIMEDOUT. | ||
97 | */ | ||
98 | int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state) | ||
99 | { | ||
100 | int retries = 10000; | ||
101 | u32 reg; | ||
102 | |||
103 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | ||
104 | reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; | ||
83 | 105 | ||
84 | if (req->request.dma == DMA_ADDR_INVALID) { | 106 | /* set requested state */ |
85 | req->request.dma = dma_map_single(dwc->dev, req->request.buf, | 107 | reg |= DWC3_DCTL_ULSTCHNGREQ(state); |
86 | req->request.length, req->direction | 108 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
87 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 109 | |
88 | req->mapped = true; | 110 | /* wait for a change in DSTS */ |
111 | while (--retries) { | ||
112 | reg = dwc3_readl(dwc->regs, DWC3_DSTS); | ||
113 | |||
114 | if (DWC3_DSTS_USBLNKST(reg) == state) | ||
115 | return 0; | ||
116 | |||
117 | udelay(5); | ||
89 | } | 118 | } |
119 | |||
120 | dev_vdbg(dwc->dev, "link state change request timed out\n"); | ||
121 | |||
122 | return -ETIMEDOUT; | ||
90 | } | 123 | } |
91 | 124 | ||
92 | void dwc3_unmap_buffer_from_dma(struct dwc3_request *req) | 125 | /** |
126 | * dwc3_gadget_resize_tx_fifos - reallocate fifo spaces for current use-case | ||
127 | * @dwc: pointer to our context structure | ||
128 | * | ||
129 | * This function will a best effort FIFO allocation in order | ||
130 | * to improve FIFO usage and throughput, while still allowing | ||
131 | * us to enable as many endpoints as possible. | ||
132 | * | ||
133 | * Keep in mind that this operation will be highly dependent | ||
134 | * on the configured size for RAM1 - which contains TxFifo -, | ||
135 | * the amount of endpoints enabled on coreConsultant tool, and | ||
136 | * the width of the Master Bus. | ||
137 | * | ||
138 | * In the ideal world, we would always be able to satisfy the | ||
139 | * following equation: | ||
140 | * | ||
141 | * ((512 + 2 * MDWIDTH-Bytes) + (Number of IN Endpoints - 1) * \ | ||
142 | * (3 * (1024 + MDWIDTH-Bytes) + MDWIDTH-Bytes)) / MDWIDTH-Bytes | ||
143 | * | ||
144 | * Unfortunately, due to many variables that's not always the case. | ||
145 | */ | ||
146 | int dwc3_gadget_resize_tx_fifos(struct dwc3 *dwc) | ||
93 | { | 147 | { |
94 | struct dwc3 *dwc = req->dep->dwc; | 148 | int last_fifo_depth = 0; |
149 | int ram1_depth; | ||
150 | int fifo_size; | ||
151 | int mdwidth; | ||
152 | int num; | ||
95 | 153 | ||
96 | if (req->request.length == 0) { | 154 | if (!dwc->needs_fifo_resize) |
97 | req->request.dma = DMA_ADDR_INVALID; | 155 | return 0; |
98 | return; | ||
99 | } | ||
100 | 156 | ||
101 | if (req->request.num_mapped_sgs) { | 157 | ram1_depth = DWC3_RAM1_DEPTH(dwc->hwparams.hwparams7); |
102 | req->request.dma = DMA_ADDR_INVALID; | 158 | mdwidth = DWC3_MDWIDTH(dwc->hwparams.hwparams0); |
103 | dma_unmap_sg(dwc->dev, req->request.sg, | ||
104 | req->request.num_mapped_sgs, | ||
105 | req->direction ? DMA_TO_DEVICE | ||
106 | : DMA_FROM_DEVICE); | ||
107 | 159 | ||
108 | req->request.num_mapped_sgs = 0; | 160 | /* MDWIDTH is represented in bits, we need it in bytes */ |
109 | return; | 161 | mdwidth >>= 3; |
110 | } | 162 | |
163 | /* | ||
164 | * FIXME For now we will only allocate 1 wMaxPacketSize space | ||
165 | * for each enabled endpoint, later patches will come to | ||
166 | * improve this algorithm so that we better use the internal | ||
167 | * FIFO space | ||
168 | */ | ||
169 | for (num = 0; num < DWC3_ENDPOINTS_NUM; num++) { | ||
170 | struct dwc3_ep *dep = dwc->eps[num]; | ||
171 | int fifo_number = dep->number >> 1; | ||
172 | int mult = 1; | ||
173 | int tmp; | ||
174 | |||
175 | if (!(dep->number & 1)) | ||
176 | continue; | ||
177 | |||
178 | if (!(dep->flags & DWC3_EP_ENABLED)) | ||
179 | continue; | ||
180 | |||
181 | if (usb_endpoint_xfer_bulk(dep->desc) | ||
182 | || usb_endpoint_xfer_isoc(dep->desc)) | ||
183 | mult = 3; | ||
184 | |||
185 | /* | ||
186 | * REVISIT: the following assumes we will always have enough | ||
187 | * space available on the FIFO RAM for all possible use cases. | ||
188 | * Make sure that's true somehow and change FIFO allocation | ||
189 | * accordingly. | ||
190 | * | ||
191 | * If we have Bulk or Isochronous endpoints, we want | ||
192 | * them to be able to be very, very fast. So we're giving | ||
193 | * those endpoints a fifo_size which is enough for 3 full | ||
194 | * packets | ||
195 | */ | ||
196 | tmp = mult * (dep->endpoint.maxpacket + mdwidth); | ||
197 | tmp += mdwidth; | ||
198 | |||
199 | fifo_size = DIV_ROUND_UP(tmp, mdwidth); | ||
200 | |||
201 | fifo_size |= (last_fifo_depth << 16); | ||
202 | |||
203 | dev_vdbg(dwc->dev, "%s: Fifo Addr %04x Size %d\n", | ||
204 | dep->name, last_fifo_depth, fifo_size & 0xffff); | ||
205 | |||
206 | dwc3_writel(dwc->regs, DWC3_GTXFIFOSIZ(fifo_number), | ||
207 | fifo_size); | ||
111 | 208 | ||
112 | if (req->mapped) { | 209 | last_fifo_depth += (fifo_size & 0xffff); |
113 | dma_unmap_single(dwc->dev, req->request.dma, | ||
114 | req->request.length, req->direction | ||
115 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
116 | req->mapped = 0; | ||
117 | req->request.dma = DMA_ADDR_INVALID; | ||
118 | } | 210 | } |
211 | |||
212 | return 0; | ||
119 | } | 213 | } |
120 | 214 | ||
121 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | 215 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, |
@@ -144,14 +238,15 @@ void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | |||
144 | if (req->request.status == -EINPROGRESS) | 238 | if (req->request.status == -EINPROGRESS) |
145 | req->request.status = status; | 239 | req->request.status = status; |
146 | 240 | ||
147 | dwc3_unmap_buffer_from_dma(req); | 241 | usb_gadget_unmap_request(&dwc->gadget, &req->request, |
242 | req->direction); | ||
148 | 243 | ||
149 | dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n", | 244 | dev_dbg(dwc->dev, "request %p from %s completed %d/%d ===> %d\n", |
150 | req, dep->name, req->request.actual, | 245 | req, dep->name, req->request.actual, |
151 | req->request.length, status); | 246 | req->request.length, status); |
152 | 247 | ||
153 | spin_unlock(&dwc->lock); | 248 | spin_unlock(&dwc->lock); |
154 | req->request.complete(&req->dep->endpoint, &req->request); | 249 | req->request.complete(&dep->endpoint, &req->request); |
155 | spin_lock(&dwc->lock); | 250 | spin_lock(&dwc->lock); |
156 | } | 251 | } |
157 | 252 | ||
@@ -219,7 +314,7 @@ int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | |||
219 | } | 314 | } |
220 | 315 | ||
221 | static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep, | 316 | static dma_addr_t dwc3_trb_dma_offset(struct dwc3_ep *dep, |
222 | struct dwc3_trb_hw *trb) | 317 | struct dwc3_trb *trb) |
223 | { | 318 | { |
224 | u32 offset = (char *) trb - (char *) dep->trb_pool; | 319 | u32 offset = (char *) trb - (char *) dep->trb_pool; |
225 | 320 | ||
@@ -368,9 +463,8 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
368 | return ret; | 463 | return ret; |
369 | 464 | ||
370 | if (!(dep->flags & DWC3_EP_ENABLED)) { | 465 | if (!(dep->flags & DWC3_EP_ENABLED)) { |
371 | struct dwc3_trb_hw *trb_st_hw; | 466 | struct dwc3_trb *trb_st_hw; |
372 | struct dwc3_trb_hw *trb_link_hw; | 467 | struct dwc3_trb *trb_link; |
373 | struct dwc3_trb trb_link; | ||
374 | 468 | ||
375 | ret = dwc3_gadget_set_xfer_resource(dwc, dep); | 469 | ret = dwc3_gadget_set_xfer_resource(dwc, dep); |
376 | if (ret) | 470 | if (ret) |
@@ -390,15 +484,15 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
390 | 484 | ||
391 | memset(&trb_link, 0, sizeof(trb_link)); | 485 | memset(&trb_link, 0, sizeof(trb_link)); |
392 | 486 | ||
393 | /* Link TRB for ISOC. The HWO but is never reset */ | 487 | /* Link TRB for ISOC. The HWO bit is never reset */ |
394 | trb_st_hw = &dep->trb_pool[0]; | 488 | trb_st_hw = &dep->trb_pool[0]; |
395 | 489 | ||
396 | trb_link.bplh = dwc3_trb_dma_offset(dep, trb_st_hw); | 490 | trb_link = &dep->trb_pool[DWC3_TRB_NUM - 1]; |
397 | trb_link.trbctl = DWC3_TRBCTL_LINK_TRB; | ||
398 | trb_link.hwo = true; | ||
399 | 491 | ||
400 | trb_link_hw = &dep->trb_pool[DWC3_TRB_NUM - 1]; | 492 | trb_link->bpl = lower_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); |
401 | dwc3_trb_to_hw(&trb_link, trb_link_hw); | 493 | trb_link->bph = upper_32_bits(dwc3_trb_dma_offset(dep, trb_st_hw)); |
494 | trb_link->ctrl |= DWC3_TRBCTL_LINK_TRB; | ||
495 | trb_link->ctrl |= DWC3_TRB_CTRL_HWO; | ||
402 | } | 496 | } |
403 | 497 | ||
404 | return 0; | 498 | return 0; |
@@ -440,6 +534,7 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) | |||
440 | 534 | ||
441 | dep->stream_capable = false; | 535 | dep->stream_capable = false; |
442 | dep->desc = NULL; | 536 | dep->desc = NULL; |
537 | dep->endpoint.desc = NULL; | ||
443 | dep->comp_desc = NULL; | 538 | dep->comp_desc = NULL; |
444 | dep->type = 0; | 539 | dep->type = 0; |
445 | dep->flags = 0; | 540 | dep->flags = 0; |
@@ -485,16 +580,16 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
485 | 580 | ||
486 | switch (usb_endpoint_type(desc)) { | 581 | switch (usb_endpoint_type(desc)) { |
487 | case USB_ENDPOINT_XFER_CONTROL: | 582 | case USB_ENDPOINT_XFER_CONTROL: |
488 | strncat(dep->name, "-control", sizeof(dep->name)); | 583 | strlcat(dep->name, "-control", sizeof(dep->name)); |
489 | break; | 584 | break; |
490 | case USB_ENDPOINT_XFER_ISOC: | 585 | case USB_ENDPOINT_XFER_ISOC: |
491 | strncat(dep->name, "-isoc", sizeof(dep->name)); | 586 | strlcat(dep->name, "-isoc", sizeof(dep->name)); |
492 | break; | 587 | break; |
493 | case USB_ENDPOINT_XFER_BULK: | 588 | case USB_ENDPOINT_XFER_BULK: |
494 | strncat(dep->name, "-bulk", sizeof(dep->name)); | 589 | strlcat(dep->name, "-bulk", sizeof(dep->name)); |
495 | break; | 590 | break; |
496 | case USB_ENDPOINT_XFER_INT: | 591 | case USB_ENDPOINT_XFER_INT: |
497 | strncat(dep->name, "-int", sizeof(dep->name)); | 592 | strlcat(dep->name, "-int", sizeof(dep->name)); |
498 | break; | 593 | break; |
499 | default: | 594 | default: |
500 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); | 595 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); |
@@ -562,7 +657,6 @@ static struct usb_request *dwc3_gadget_ep_alloc_request(struct usb_ep *ep, | |||
562 | 657 | ||
563 | req->epnum = dep->number; | 658 | req->epnum = dep->number; |
564 | req->dep = dep; | 659 | req->dep = dep; |
565 | req->request.dma = DMA_ADDR_INVALID; | ||
566 | 660 | ||
567 | return &req->request; | 661 | return &req->request; |
568 | } | 662 | } |
@@ -585,8 +679,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
585 | unsigned length, unsigned last, unsigned chain) | 679 | unsigned length, unsigned last, unsigned chain) |
586 | { | 680 | { |
587 | struct dwc3 *dwc = dep->dwc; | 681 | struct dwc3 *dwc = dep->dwc; |
588 | struct dwc3_trb_hw *trb_hw; | 682 | struct dwc3_trb *trb; |
589 | struct dwc3_trb trb; | ||
590 | 683 | ||
591 | unsigned int cur_slot; | 684 | unsigned int cur_slot; |
592 | 685 | ||
@@ -595,7 +688,7 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
595 | length, last ? " last" : "", | 688 | length, last ? " last" : "", |
596 | chain ? " chain" : ""); | 689 | chain ? " chain" : ""); |
597 | 690 | ||
598 | trb_hw = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK]; | 691 | trb = &dep->trb_pool[dep->free_slot & DWC3_TRB_MASK]; |
599 | cur_slot = dep->free_slot; | 692 | cur_slot = dep->free_slot; |
600 | dep->free_slot++; | 693 | dep->free_slot++; |
601 | 694 | ||
@@ -604,40 +697,32 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
604 | usb_endpoint_xfer_isoc(dep->desc)) | 697 | usb_endpoint_xfer_isoc(dep->desc)) |
605 | return; | 698 | return; |
606 | 699 | ||
607 | memset(&trb, 0, sizeof(trb)); | ||
608 | if (!req->trb) { | 700 | if (!req->trb) { |
609 | dwc3_gadget_move_request_queued(req); | 701 | dwc3_gadget_move_request_queued(req); |
610 | req->trb = trb_hw; | 702 | req->trb = trb; |
611 | req->trb_dma = dwc3_trb_dma_offset(dep, trb_hw); | 703 | req->trb_dma = dwc3_trb_dma_offset(dep, trb); |
612 | } | 704 | } |
613 | 705 | ||
614 | if (usb_endpoint_xfer_isoc(dep->desc)) { | 706 | trb->size = DWC3_TRB_SIZE_LENGTH(length); |
615 | trb.isp_imi = true; | 707 | trb->bpl = lower_32_bits(dma); |
616 | trb.csp = true; | 708 | trb->bph = upper_32_bits(dma); |
617 | } else { | ||
618 | trb.chn = chain; | ||
619 | trb.lst = last; | ||
620 | } | ||
621 | |||
622 | if (usb_endpoint_xfer_bulk(dep->desc) && dep->stream_capable) | ||
623 | trb.sid_sofn = req->request.stream_id; | ||
624 | 709 | ||
625 | switch (usb_endpoint_type(dep->desc)) { | 710 | switch (usb_endpoint_type(dep->desc)) { |
626 | case USB_ENDPOINT_XFER_CONTROL: | 711 | case USB_ENDPOINT_XFER_CONTROL: |
627 | trb.trbctl = DWC3_TRBCTL_CONTROL_SETUP; | 712 | trb->ctrl = DWC3_TRBCTL_CONTROL_SETUP; |
628 | break; | 713 | break; |
629 | 714 | ||
630 | case USB_ENDPOINT_XFER_ISOC: | 715 | case USB_ENDPOINT_XFER_ISOC: |
631 | trb.trbctl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; | 716 | trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; |
632 | 717 | ||
633 | /* IOC every DWC3_TRB_NUM / 4 so we can refill */ | 718 | /* IOC every DWC3_TRB_NUM / 4 so we can refill */ |
634 | if (!(cur_slot % (DWC3_TRB_NUM / 4))) | 719 | if (!(cur_slot % (DWC3_TRB_NUM / 4))) |
635 | trb.ioc = last; | 720 | trb->ctrl |= DWC3_TRB_CTRL_IOC; |
636 | break; | 721 | break; |
637 | 722 | ||
638 | case USB_ENDPOINT_XFER_BULK: | 723 | case USB_ENDPOINT_XFER_BULK: |
639 | case USB_ENDPOINT_XFER_INT: | 724 | case USB_ENDPOINT_XFER_INT: |
640 | trb.trbctl = DWC3_TRBCTL_NORMAL; | 725 | trb->ctrl = DWC3_TRBCTL_NORMAL; |
641 | break; | 726 | break; |
642 | default: | 727 | default: |
643 | /* | 728 | /* |
@@ -647,11 +732,21 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
647 | BUG(); | 732 | BUG(); |
648 | } | 733 | } |
649 | 734 | ||
650 | trb.length = length; | 735 | if (usb_endpoint_xfer_isoc(dep->desc)) { |
651 | trb.bplh = dma; | 736 | trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI; |
652 | trb.hwo = true; | 737 | trb->ctrl |= DWC3_TRB_CTRL_CSP; |
738 | } else { | ||
739 | if (chain) | ||
740 | trb->ctrl |= DWC3_TRB_CTRL_CHN; | ||
741 | |||
742 | if (last) | ||
743 | trb->ctrl |= DWC3_TRB_CTRL_LST; | ||
744 | } | ||
653 | 745 | ||
654 | dwc3_trb_to_hw(&trb, trb_hw); | 746 | if (usb_endpoint_xfer_bulk(dep->desc) && dep->stream_capable) |
747 | trb->ctrl |= DWC3_TRB_CTRL_SID_SOFN(req->request.stream_id); | ||
748 | |||
749 | trb->ctrl |= DWC3_TRB_CTRL_HWO; | ||
655 | } | 750 | } |
656 | 751 | ||
657 | /* | 752 | /* |
@@ -659,14 +754,15 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, | |||
659 | * @dep: endpoint for which requests are being prepared | 754 | * @dep: endpoint for which requests are being prepared |
660 | * @starting: true if the endpoint is idle and no requests are queued. | 755 | * @starting: true if the endpoint is idle and no requests are queued. |
661 | * | 756 | * |
662 | * The functions goes through the requests list and setups TRBs for the | 757 | * The function goes through the requests list and sets up TRBs for the |
663 | * transfers. The functions returns once there are not more TRBs available or | 758 | * transfers. The function returns once there are no more TRBs available or |
664 | * it run out of requests. | 759 | * it runs out of requests. |
665 | */ | 760 | */ |
666 | static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | 761 | static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) |
667 | { | 762 | { |
668 | struct dwc3_request *req, *n; | 763 | struct dwc3_request *req, *n; |
669 | u32 trbs_left; | 764 | u32 trbs_left; |
765 | u32 max; | ||
670 | unsigned int last_one = 0; | 766 | unsigned int last_one = 0; |
671 | 767 | ||
672 | BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); | 768 | BUILD_BUG_ON_NOT_POWER_OF_2(DWC3_TRB_NUM); |
@@ -674,9 +770,16 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | |||
674 | /* the first request must not be queued */ | 770 | /* the first request must not be queued */ |
675 | trbs_left = (dep->busy_slot - dep->free_slot) & DWC3_TRB_MASK; | 771 | trbs_left = (dep->busy_slot - dep->free_slot) & DWC3_TRB_MASK; |
676 | 772 | ||
773 | /* Can't wrap around on a non-isoc EP since there's no link TRB */ | ||
774 | if (!usb_endpoint_xfer_isoc(dep->desc)) { | ||
775 | max = DWC3_TRB_NUM - (dep->free_slot & DWC3_TRB_MASK); | ||
776 | if (trbs_left > max) | ||
777 | trbs_left = max; | ||
778 | } | ||
779 | |||
677 | /* | 780 | /* |
678 | * if busy & slot are equal than it is either full or empty. If we are | 781 | * If busy & slot are equal than it is either full or empty. If we are |
679 | * starting to proceed requests then we are empty. Otherwise we ar | 782 | * starting to process requests then we are empty. Otherwise we are |
680 | * full and don't do anything | 783 | * full and don't do anything |
681 | */ | 784 | */ |
682 | if (!trbs_left) { | 785 | if (!trbs_left) { |
@@ -687,7 +790,7 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | |||
687 | * In case we start from scratch, we queue the ISOC requests | 790 | * In case we start from scratch, we queue the ISOC requests |
688 | * starting from slot 1. This is done because we use ring | 791 | * starting from slot 1. This is done because we use ring |
689 | * buffer and have no LST bit to stop us. Instead, we place | 792 | * buffer and have no LST bit to stop us. Instead, we place |
690 | * IOC bit TRB_NUM/4. We try to avoid to having an interrupt | 793 | * IOC bit every TRB_NUM/4. We try to avoid having an interrupt |
691 | * after the first request so we start at slot 1 and have | 794 | * after the first request so we start at slot 1 and have |
692 | * 7 requests proceed before we hit the first IOC. | 795 | * 7 requests proceed before we hit the first IOC. |
693 | * Other transfer types don't use the ring buffer and are | 796 | * Other transfer types don't use the ring buffer and are |
@@ -723,8 +826,8 @@ static void dwc3_prepare_trbs(struct dwc3_ep *dep, bool starting) | |||
723 | length = sg_dma_len(s); | 826 | length = sg_dma_len(s); |
724 | dma = sg_dma_address(s); | 827 | dma = sg_dma_address(s); |
725 | 828 | ||
726 | if (i == (request->num_mapped_sgs - 1) | 829 | if (i == (request->num_mapped_sgs - 1) || |
727 | || sg_is_last(s)) { | 830 | sg_is_last(s)) { |
728 | last_one = true; | 831 | last_one = true; |
729 | chain = false; | 832 | chain = false; |
730 | } | 833 | } |
@@ -792,8 +895,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | |||
792 | dwc3_prepare_trbs(dep, start_new); | 895 | dwc3_prepare_trbs(dep, start_new); |
793 | 896 | ||
794 | /* | 897 | /* |
795 | * req points to the first request where HWO changed | 898 | * req points to the first request where HWO changed from 0 to 1 |
796 | * from 0 to 1 | ||
797 | */ | 899 | */ |
798 | req = next_request(&dep->req_queued); | 900 | req = next_request(&dep->req_queued); |
799 | } | 901 | } |
@@ -819,9 +921,10 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | |||
819 | /* | 921 | /* |
820 | * FIXME we need to iterate over the list of requests | 922 | * FIXME we need to iterate over the list of requests |
821 | * here and stop, unmap, free and del each of the linked | 923 | * here and stop, unmap, free and del each of the linked |
822 | * requests instead of we do now. | 924 | * requests instead of what we do now. |
823 | */ | 925 | */ |
824 | dwc3_unmap_buffer_from_dma(req); | 926 | usb_gadget_unmap_request(&dwc->gadget, &req->request, |
927 | req->direction); | ||
825 | list_del(&req->list); | 928 | list_del(&req->list); |
826 | return ret; | 929 | return ret; |
827 | } | 930 | } |
@@ -837,6 +940,9 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep, u16 cmd_param, | |||
837 | 940 | ||
838 | static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | 941 | static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) |
839 | { | 942 | { |
943 | struct dwc3 *dwc = dep->dwc; | ||
944 | int ret; | ||
945 | |||
840 | req->request.actual = 0; | 946 | req->request.actual = 0; |
841 | req->request.status = -EINPROGRESS; | 947 | req->request.status = -EINPROGRESS; |
842 | req->direction = dep->direction; | 948 | req->direction = dep->direction; |
@@ -852,9 +958,13 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
852 | * particular token from the Host side. | 958 | * particular token from the Host side. |
853 | * | 959 | * |
854 | * This will also avoid Host cancelling URBs due to too | 960 | * This will also avoid Host cancelling URBs due to too |
855 | * many NACKs. | 961 | * many NAKs. |
856 | */ | 962 | */ |
857 | dwc3_map_buffer_to_dma(req); | 963 | ret = usb_gadget_map_request(&dwc->gadget, &req->request, |
964 | dep->direction); | ||
965 | if (ret) | ||
966 | return ret; | ||
967 | |||
858 | list_add_tail(&req->list, &dep->request_list); | 968 | list_add_tail(&req->list, &dep->request_list); |
859 | 969 | ||
860 | /* | 970 | /* |
@@ -874,11 +984,11 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req) | |||
874 | int start_trans; | 984 | int start_trans; |
875 | 985 | ||
876 | start_trans = 1; | 986 | start_trans = 1; |
877 | if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && | 987 | if (usb_endpoint_xfer_isoc(dep->desc) && |
878 | dep->flags & DWC3_EP_BUSY) | 988 | (dep->flags & DWC3_EP_BUSY)) |
879 | start_trans = 0; | 989 | start_trans = 0; |
880 | 990 | ||
881 | ret = __dwc3_gadget_kick_transfer(dep, 0, start_trans); | 991 | ret = __dwc3_gadget_kick_transfer(dep, 0, start_trans); |
882 | if (ret && ret != -EBUSY) { | 992 | if (ret && ret != -EBUSY) { |
883 | struct dwc3 *dwc = dep->dwc; | 993 | struct dwc3 *dwc = dep->dwc; |
884 | 994 | ||
@@ -1031,8 +1141,12 @@ out: | |||
1031 | static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep) | 1141 | static int dwc3_gadget_ep_set_wedge(struct usb_ep *ep) |
1032 | { | 1142 | { |
1033 | struct dwc3_ep *dep = to_dwc3_ep(ep); | 1143 | struct dwc3_ep *dep = to_dwc3_ep(ep); |
1144 | struct dwc3 *dwc = dep->dwc; | ||
1145 | unsigned long flags; | ||
1034 | 1146 | ||
1147 | spin_lock_irqsave(&dwc->lock, flags); | ||
1035 | dep->flags |= DWC3_EP_WEDGE; | 1148 | dep->flags |= DWC3_EP_WEDGE; |
1149 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
1036 | 1150 | ||
1037 | return dwc3_gadget_ep_set_halt(ep, 1); | 1151 | return dwc3_gadget_ep_set_halt(ep, 1); |
1038 | } | 1152 | } |
@@ -1122,26 +1236,20 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) | |||
1122 | goto out; | 1236 | goto out; |
1123 | } | 1237 | } |
1124 | 1238 | ||
1125 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 1239 | ret = dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV); |
1126 | 1240 | if (ret < 0) { | |
1127 | /* | 1241 | dev_err(dwc->dev, "failed to put link in Recovery\n"); |
1128 | * Switch link state to Recovery. In HS/FS/LS this means | 1242 | goto out; |
1129 | * RemoteWakeup Request | 1243 | } |
1130 | */ | ||
1131 | reg |= DWC3_DCTL_ULSTCHNG_RECOVERY; | ||
1132 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | ||
1133 | |||
1134 | /* wait for at least 2000us */ | ||
1135 | usleep_range(2000, 2500); | ||
1136 | 1244 | ||
1137 | /* write zeroes to Link Change Request */ | 1245 | /* write zeroes to Link Change Request */ |
1138 | reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; | 1246 | reg &= ~DWC3_DCTL_ULSTCHNGREQ_MASK; |
1139 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | 1247 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
1140 | 1248 | ||
1141 | /* pool until Link State change to ON */ | 1249 | /* poll until Link State changes to ON */ |
1142 | timeout = jiffies + msecs_to_jiffies(100); | 1250 | timeout = jiffies + msecs_to_jiffies(100); |
1143 | 1251 | ||
1144 | while (!(time_after(jiffies, timeout))) { | 1252 | while (!time_after(jiffies, timeout)) { |
1145 | reg = dwc3_readl(dwc->regs, DWC3_DSTS); | 1253 | reg = dwc3_readl(dwc->regs, DWC3_DSTS); |
1146 | 1254 | ||
1147 | /* in HS, means ON */ | 1255 | /* in HS, means ON */ |
@@ -1164,8 +1272,11 @@ static int dwc3_gadget_set_selfpowered(struct usb_gadget *g, | |||
1164 | int is_selfpowered) | 1272 | int is_selfpowered) |
1165 | { | 1273 | { |
1166 | struct dwc3 *dwc = gadget_to_dwc(g); | 1274 | struct dwc3 *dwc = gadget_to_dwc(g); |
1275 | unsigned long flags; | ||
1167 | 1276 | ||
1277 | spin_lock_irqsave(&dwc->lock, flags); | ||
1168 | dwc->is_selfpowered = !!is_selfpowered; | 1278 | dwc->is_selfpowered = !!is_selfpowered; |
1279 | spin_unlock_irqrestore(&dwc->lock, flags); | ||
1169 | 1280 | ||
1170 | return 0; | 1281 | return 0; |
1171 | } | 1282 | } |
@@ -1176,10 +1287,13 @@ static void dwc3_gadget_run_stop(struct dwc3 *dwc, int is_on) | |||
1176 | u32 timeout = 500; | 1287 | u32 timeout = 500; |
1177 | 1288 | ||
1178 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 1289 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
1179 | if (is_on) | 1290 | if (is_on) { |
1180 | reg |= DWC3_DCTL_RUN_STOP; | 1291 | reg &= ~DWC3_DCTL_TRGTULST_MASK; |
1181 | else | 1292 | reg |= (DWC3_DCTL_RUN_STOP |
1293 | | DWC3_DCTL_TRGTULST_RX_DET); | ||
1294 | } else { | ||
1182 | reg &= ~DWC3_DCTL_RUN_STOP; | 1295 | reg &= ~DWC3_DCTL_RUN_STOP; |
1296 | } | ||
1183 | 1297 | ||
1184 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | 1298 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
1185 | 1299 | ||
@@ -1386,7 +1500,7 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1386 | const struct dwc3_event_depevt *event, int status) | 1500 | const struct dwc3_event_depevt *event, int status) |
1387 | { | 1501 | { |
1388 | struct dwc3_request *req; | 1502 | struct dwc3_request *req; |
1389 | struct dwc3_trb trb; | 1503 | struct dwc3_trb *trb; |
1390 | unsigned int count; | 1504 | unsigned int count; |
1391 | unsigned int s_pkt = 0; | 1505 | unsigned int s_pkt = 0; |
1392 | 1506 | ||
@@ -1397,20 +1511,20 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1397 | return 1; | 1511 | return 1; |
1398 | } | 1512 | } |
1399 | 1513 | ||
1400 | dwc3_trb_to_nat(req->trb, &trb); | 1514 | trb = req->trb; |
1401 | 1515 | ||
1402 | if (trb.hwo && status != -ESHUTDOWN) | 1516 | if ((trb->ctrl & DWC3_TRB_CTRL_HWO) && status != -ESHUTDOWN) |
1403 | /* | 1517 | /* |
1404 | * We continue despite the error. There is not much we | 1518 | * We continue despite the error. There is not much we |
1405 | * can do. If we don't clean in up we loop for ever. If | 1519 | * can do. If we don't clean it up we loop forever. If |
1406 | * we skip the TRB than it gets overwritten reused after | 1520 | * we skip the TRB then it gets overwritten after a |
1407 | * a while since we use them in a ring buffer. a BUG() | 1521 | * while since we use them in a ring buffer. A BUG() |
1408 | * would help. Lets hope that if this occures, someone | 1522 | * would help. Lets hope that if this occurs, someone |
1409 | * fixes the root cause instead of looking away :) | 1523 | * fixes the root cause instead of looking away :) |
1410 | */ | 1524 | */ |
1411 | dev_err(dwc->dev, "%s's TRB (%p) still owned by HW\n", | 1525 | dev_err(dwc->dev, "%s's TRB (%p) still owned by HW\n", |
1412 | dep->name, req->trb); | 1526 | dep->name, req->trb); |
1413 | count = trb.length; | 1527 | count = trb->size & DWC3_TRB_SIZE_MASK; |
1414 | 1528 | ||
1415 | if (dep->direction) { | 1529 | if (dep->direction) { |
1416 | if (count) { | 1530 | if (count) { |
@@ -1434,13 +1548,16 @@ static int dwc3_cleanup_done_reqs(struct dwc3 *dwc, struct dwc3_ep *dep, | |||
1434 | dwc3_gadget_giveback(dep, req, status); | 1548 | dwc3_gadget_giveback(dep, req, status); |
1435 | if (s_pkt) | 1549 | if (s_pkt) |
1436 | break; | 1550 | break; |
1437 | if ((event->status & DEPEVT_STATUS_LST) && trb.lst) | 1551 | if ((event->status & DEPEVT_STATUS_LST) && |
1552 | (trb->ctrl & DWC3_TRB_CTRL_LST)) | ||
1438 | break; | 1553 | break; |
1439 | if ((event->status & DEPEVT_STATUS_IOC) && trb.ioc) | 1554 | if ((event->status & DEPEVT_STATUS_IOC) && |
1555 | (trb->ctrl & DWC3_TRB_CTRL_IOC)) | ||
1440 | break; | 1556 | break; |
1441 | } while (1); | 1557 | } while (1); |
1442 | 1558 | ||
1443 | if ((event->status & DEPEVT_STATUS_IOC) && trb.ioc) | 1559 | if ((event->status & DEPEVT_STATUS_IOC) && |
1560 | (trb->ctrl & DWC3_TRB_CTRL_IOC)) | ||
1444 | return 0; | 1561 | return 0; |
1445 | return 1; | 1562 | return 1; |
1446 | } | 1563 | } |
@@ -1455,11 +1572,9 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, | |||
1455 | if (event->status & DEPEVT_STATUS_BUSERR) | 1572 | if (event->status & DEPEVT_STATUS_BUSERR) |
1456 | status = -ECONNRESET; | 1573 | status = -ECONNRESET; |
1457 | 1574 | ||
1458 | clean_busy = dwc3_cleanup_done_reqs(dwc, dep, event, status); | 1575 | clean_busy = dwc3_cleanup_done_reqs(dwc, dep, event, status); |
1459 | if (clean_busy) { | 1576 | if (clean_busy) |
1460 | dep->flags &= ~DWC3_EP_BUSY; | 1577 | dep->flags &= ~DWC3_EP_BUSY; |
1461 | dep->res_trans_idx = 0; | ||
1462 | } | ||
1463 | 1578 | ||
1464 | /* | 1579 | /* |
1465 | * WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround. | 1580 | * WORKAROUND: This is the 2nd half of U1/U2 -> U0 workaround. |
@@ -1490,7 +1605,7 @@ static void dwc3_endpoint_transfer_complete(struct dwc3 *dwc, | |||
1490 | static void dwc3_gadget_start_isoc(struct dwc3 *dwc, | 1605 | static void dwc3_gadget_start_isoc(struct dwc3 *dwc, |
1491 | struct dwc3_ep *dep, const struct dwc3_event_depevt *event) | 1606 | struct dwc3_ep *dep, const struct dwc3_event_depevt *event) |
1492 | { | 1607 | { |
1493 | u32 uf; | 1608 | u32 uf, mask; |
1494 | 1609 | ||
1495 | if (list_empty(&dep->request_list)) { | 1610 | if (list_empty(&dep->request_list)) { |
1496 | dev_vdbg(dwc->dev, "ISOC ep %s run out for requests.\n", | 1611 | dev_vdbg(dwc->dev, "ISOC ep %s run out for requests.\n", |
@@ -1498,16 +1613,10 @@ static void dwc3_gadget_start_isoc(struct dwc3 *dwc, | |||
1498 | return; | 1613 | return; |
1499 | } | 1614 | } |
1500 | 1615 | ||
1501 | if (event->parameters) { | 1616 | mask = ~(dep->interval - 1); |
1502 | u32 mask; | 1617 | uf = event->parameters & mask; |
1503 | 1618 | /* 4 micro frames in the future */ | |
1504 | mask = ~(dep->interval - 1); | 1619 | uf += dep->interval * 4; |
1505 | uf = event->parameters & mask; | ||
1506 | /* 4 micro frames in the future */ | ||
1507 | uf += dep->interval * 4; | ||
1508 | } else { | ||
1509 | uf = 0; | ||
1510 | } | ||
1511 | 1620 | ||
1512 | __dwc3_gadget_kick_transfer(dep, uf, 1); | 1621 | __dwc3_gadget_kick_transfer(dep, uf, 1); |
1513 | } | 1622 | } |
@@ -1519,8 +1628,8 @@ static void dwc3_process_ep_cmd_complete(struct dwc3_ep *dep, | |||
1519 | struct dwc3_event_depevt mod_ev = *event; | 1628 | struct dwc3_event_depevt mod_ev = *event; |
1520 | 1629 | ||
1521 | /* | 1630 | /* |
1522 | * We were asked to remove one requests. It is possible that this | 1631 | * We were asked to remove one request. It is possible that this |
1523 | * request and a few other were started together and have the same | 1632 | * request and a few others were started together and have the same |
1524 | * transfer index. Since we stopped the complete endpoint we don't | 1633 | * transfer index. Since we stopped the complete endpoint we don't |
1525 | * know how many requests were already completed (and not yet) | 1634 | * know how many requests were already completed (and not yet) |
1526 | * reported and how could be done (later). We purge them all until | 1635 | * reported and how could be done (later). We purge them all until |
@@ -1529,7 +1638,7 @@ static void dwc3_process_ep_cmd_complete(struct dwc3_ep *dep, | |||
1529 | mod_ev.status = DEPEVT_STATUS_LST; | 1638 | mod_ev.status = DEPEVT_STATUS_LST; |
1530 | dwc3_cleanup_done_reqs(dwc, dep, &mod_ev, -ESHUTDOWN); | 1639 | dwc3_cleanup_done_reqs(dwc, dep, &mod_ev, -ESHUTDOWN); |
1531 | dep->flags &= ~DWC3_EP_BUSY; | 1640 | dep->flags &= ~DWC3_EP_BUSY; |
1532 | /* pending requets are ignored and are queued on XferNotReady */ | 1641 | /* pending requests are ignored and are queued on XferNotReady */ |
1533 | } | 1642 | } |
1534 | 1643 | ||
1535 | static void dwc3_ep_cmd_compl(struct dwc3_ep *dep, | 1644 | static void dwc3_ep_cmd_compl(struct dwc3_ep *dep, |
@@ -1570,6 +1679,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, | |||
1570 | 1679 | ||
1571 | switch (event->endpoint_event) { | 1680 | switch (event->endpoint_event) { |
1572 | case DWC3_DEPEVT_XFERCOMPLETE: | 1681 | case DWC3_DEPEVT_XFERCOMPLETE: |
1682 | dep->res_trans_idx = 0; | ||
1683 | |||
1573 | if (usb_endpoint_xfer_isoc(dep->desc)) { | 1684 | if (usb_endpoint_xfer_isoc(dep->desc)) { |
1574 | dev_dbg(dwc->dev, "%s is an Isochronous endpoint\n", | 1685 | dev_dbg(dwc->dev, "%s is an Isochronous endpoint\n", |
1575 | dep->name); | 1686 | dep->name); |
@@ -1594,7 +1705,8 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, | |||
1594 | int ret; | 1705 | int ret; |
1595 | 1706 | ||
1596 | dev_vdbg(dwc->dev, "%s: reason %s\n", | 1707 | dev_vdbg(dwc->dev, "%s: reason %s\n", |
1597 | dep->name, event->status | 1708 | dep->name, event->status & |
1709 | DEPEVT_STATUS_TRANSFER_ACTIVE | ||
1598 | ? "Transfer Active" | 1710 | ? "Transfer Active" |
1599 | : "Transfer Not Active"); | 1711 | : "Transfer Not Active"); |
1600 | 1712 | ||
@@ -1805,6 +1917,7 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | |||
1805 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); | 1917 | reg = dwc3_readl(dwc->regs, DWC3_DCTL); |
1806 | reg &= ~DWC3_DCTL_TSTCTRL_MASK; | 1918 | reg &= ~DWC3_DCTL_TSTCTRL_MASK; |
1807 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | 1919 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
1920 | dwc->test_mode = false; | ||
1808 | 1921 | ||
1809 | dwc3_stop_active_transfers(dwc); | 1922 | dwc3_stop_active_transfers(dwc); |
1810 | dwc3_clear_stall_all_ep(dwc); | 1923 | dwc3_clear_stall_all_ep(dwc); |
@@ -2082,7 +2195,8 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | |||
2082 | while (left > 0) { | 2195 | while (left > 0) { |
2083 | union dwc3_event event; | 2196 | union dwc3_event event; |
2084 | 2197 | ||
2085 | memcpy(&event.raw, (evt->buf + evt->lpos), sizeof(event.raw)); | 2198 | event.raw = *(u32 *) (evt->buf + evt->lpos); |
2199 | |||
2086 | dwc3_process_event_entry(dwc, &event); | 2200 | dwc3_process_event_entry(dwc, &event); |
2087 | /* | 2201 | /* |
2088 | * XXX we wrap around correctly to the next entry as almost all | 2202 | * XXX we wrap around correctly to the next entry as almost all |
@@ -2123,7 +2237,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
2123 | 2237 | ||
2124 | /** | 2238 | /** |
2125 | * dwc3_gadget_init - Initializes gadget related registers | 2239 | * dwc3_gadget_init - Initializes gadget related registers |
2126 | * @dwc: Pointer to out controller context structure | 2240 | * @dwc: pointer to our controller context structure |
2127 | * | 2241 | * |
2128 | * Returns 0 on success otherwise negative errno. | 2242 | * Returns 0 on success otherwise negative errno. |
2129 | */ | 2243 | */ |
@@ -2149,9 +2263,8 @@ int __devinit dwc3_gadget_init(struct dwc3 *dwc) | |||
2149 | goto err1; | 2263 | goto err1; |
2150 | } | 2264 | } |
2151 | 2265 | ||
2152 | dwc->setup_buf = dma_alloc_coherent(dwc->dev, | 2266 | dwc->setup_buf = kzalloc(sizeof(*dwc->setup_buf) * 2, |
2153 | sizeof(*dwc->setup_buf) * 2, | 2267 | GFP_KERNEL); |
2154 | &dwc->setup_buf_addr, GFP_KERNEL); | ||
2155 | if (!dwc->setup_buf) { | 2268 | if (!dwc->setup_buf) { |
2156 | dev_err(dwc->dev, "failed to allocate setup buffer\n"); | 2269 | dev_err(dwc->dev, "failed to allocate setup buffer\n"); |
2157 | ret = -ENOMEM; | 2270 | ret = -ENOMEM; |
@@ -2242,8 +2355,7 @@ err4: | |||
2242 | dwc->ep0_bounce_addr); | 2355 | dwc->ep0_bounce_addr); |
2243 | 2356 | ||
2244 | err3: | 2357 | err3: |
2245 | dma_free_coherent(dwc->dev, sizeof(*dwc->setup_buf) * 2, | 2358 | kfree(dwc->setup_buf); |
2246 | dwc->setup_buf, dwc->setup_buf_addr); | ||
2247 | 2359 | ||
2248 | err2: | 2360 | err2: |
2249 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), | 2361 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), |
@@ -2272,8 +2384,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc) | |||
2272 | dma_free_coherent(dwc->dev, 512, dwc->ep0_bounce, | 2384 | dma_free_coherent(dwc->dev, 512, dwc->ep0_bounce, |
2273 | dwc->ep0_bounce_addr); | 2385 | dwc->ep0_bounce_addr); |
2274 | 2386 | ||
2275 | dma_free_coherent(dwc->dev, sizeof(*dwc->setup_buf) * 2, | 2387 | kfree(dwc->setup_buf); |
2276 | dwc->setup_buf, dwc->setup_buf_addr); | ||
2277 | 2388 | ||
2278 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), | 2389 | dma_free_coherent(dwc->dev, sizeof(*dwc->ep0_trb), |
2279 | dwc->ep0_trb, dwc->ep0_trb_addr); | 2390 | dwc->ep0_trb, dwc->ep0_trb_addr); |
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index d97f467d41cc..a8600084348c 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h | |||
@@ -100,6 +100,9 @@ static inline void dwc3_gadget_move_request_queued(struct dwc3_request *req) | |||
100 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, | 100 | void dwc3_gadget_giveback(struct dwc3_ep *dep, struct dwc3_request *req, |
101 | int status); | 101 | int status); |
102 | 102 | ||
103 | int dwc3_gadget_set_test_mode(struct dwc3 *dwc, int mode); | ||
104 | int dwc3_gadget_set_link_state(struct dwc3 *dwc, enum dwc3_link_state state); | ||
105 | |||
103 | void dwc3_ep0_interrupt(struct dwc3 *dwc, | 106 | void dwc3_ep0_interrupt(struct dwc3 *dwc, |
104 | const struct dwc3_event_depevt *event); | 107 | const struct dwc3_event_depevt *event); |
105 | void dwc3_ep0_out_start(struct dwc3 *dwc); | 108 | void dwc3_ep0_out_start(struct dwc3 *dwc); |
@@ -108,8 +111,6 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request, | |||
108 | int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); | 111 | int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value); |
109 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, | 112 | int dwc3_send_gadget_ep_cmd(struct dwc3 *dwc, unsigned ep, |
110 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params); | 113 | unsigned cmd, struct dwc3_gadget_ep_cmd_params *params); |
111 | void dwc3_map_buffer_to_dma(struct dwc3_request *req); | ||
112 | void dwc3_unmap_buffer_from_dma(struct dwc3_request *req); | ||
113 | 114 | ||
114 | /** | 115 | /** |
115 | * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW | 116 | * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW |
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 7cfe211b6c37..b108d18fd40d 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c | |||
@@ -53,7 +53,7 @@ int dwc3_host_init(struct dwc3 *dwc) | |||
53 | struct platform_device *xhci; | 53 | struct platform_device *xhci; |
54 | int ret; | 54 | int ret; |
55 | 55 | ||
56 | xhci = platform_device_alloc("xhci", -1); | 56 | xhci = platform_device_alloc("xhci-hcd", -1); |
57 | if (!xhci) { | 57 | if (!xhci) { |
58 | dev_err(dwc->dev, "couldn't allocate xHCI device\n"); | 58 | dev_err(dwc->dev, "couldn't allocate xHCI device\n"); |
59 | ret = -ENOMEM; | 59 | ret = -ENOMEM; |
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7ecb68a67411..c14a3972953a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -599,16 +599,29 @@ config USB_AUDIO | |||
599 | depends on SND | 599 | depends on SND |
600 | select SND_PCM | 600 | select SND_PCM |
601 | help | 601 | help |
602 | Gadget Audio is compatible with USB Audio Class specification 1.0. | 602 | This Gadget Audio driver is compatible with USB Audio Class |
603 | It will include at least one AudioControl interface, zero or more | 603 | specification 2.0. It implements 1 AudioControl interface, |
604 | AudioStream interface and zero or more MIDIStream interface. | 604 | 1 AudioStreaming Interface each for USB-OUT and USB-IN. |
605 | 605 | Number of channels, sample rate and sample size can be | |
606 | Gadget Audio will use on-board ALSA (CONFIG_SND) audio card to | 606 | specified as module parameters. |
607 | playback or capture audio stream. | 607 | This driver doesn't expect any real Audio codec to be present |
608 | on the device - the audio streams are simply sinked to and | ||
609 | sourced from a virtual ALSA sound card created. The user-space | ||
610 | application may choose to do whatever it wants with the data | ||
611 | received from the USB Host and choose to provide whatever it | ||
612 | wants as audio data to the USB Host. | ||
608 | 613 | ||
609 | Say "y" to link the driver statically, or "m" to build a | 614 | Say "y" to link the driver statically, or "m" to build a |
610 | dynamically linked module called "g_audio". | 615 | dynamically linked module called "g_audio". |
611 | 616 | ||
617 | config GADGET_UAC1 | ||
618 | bool "UAC 1.0 (Legacy)" | ||
619 | depends on USB_AUDIO | ||
620 | help | ||
621 | If you instead want older UAC Spec-1.0 driver that also has audio | ||
622 | paths hardwired to the Audio codec chip on-board and doesn't work | ||
623 | without one. | ||
624 | |||
612 | config USB_ETH | 625 | config USB_ETH |
613 | tristate "Ethernet Gadget (with CDC Ethernet support)" | 626 | tristate "Ethernet Gadget (with CDC Ethernet support)" |
614 | depends on NET | 627 | depends on NET |
@@ -685,7 +698,7 @@ config USB_G_NCM | |||
685 | help | 698 | help |
686 | This driver implements USB CDC NCM subclass standard. NCM is | 699 | This driver implements USB CDC NCM subclass standard. NCM is |
687 | an advanced protocol for Ethernet encapsulation, allows grouping | 700 | an advanced protocol for Ethernet encapsulation, allows grouping |
688 | of several ethernet frames into one USB transfer and diffferent | 701 | of several ethernet frames into one USB transfer and different |
689 | alignment possibilities. | 702 | alignment possibilities. |
690 | 703 | ||
691 | Say "y" to link the driver statically, or "m" to build a | 704 | Say "y" to link the driver statically, or "m" to build a |
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index c16ff55a74e8..2204a4c68d85 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | /* Driver strings */ | 30 | /* Driver strings */ |
31 | #define UDC_MOD_DESCRIPTION "AMD 5536 UDC - USB Device Controller" | 31 | #define UDC_MOD_DESCRIPTION "AMD 5536 UDC - USB Device Controller" |
32 | #define UDC_DRIVER_VERSION_STRING "01.00.0206 - $Revision: #3 $" | 32 | #define UDC_DRIVER_VERSION_STRING "01.00.0206" |
33 | 33 | ||
34 | /* system */ | 34 | /* system */ |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
@@ -140,7 +140,7 @@ static DECLARE_TASKLET(disconnect_tasklet, udc_tasklet_disconnect, | |||
140 | 140 | ||
141 | /* endpoint names used for print */ | 141 | /* endpoint names used for print */ |
142 | static const char ep0_string[] = "ep0in"; | 142 | static const char ep0_string[] = "ep0in"; |
143 | static const char *ep_string[] = { | 143 | static const char *const ep_string[] = { |
144 | ep0_string, | 144 | ep0_string, |
145 | "ep1in-int", "ep2in-bulk", "ep3in-bulk", "ep4in-bulk", "ep5in-bulk", | 145 | "ep1in-int", "ep2in-bulk", "ep3in-bulk", "ep4in-bulk", "ep5in-bulk", |
146 | "ep6in-bulk", "ep7in-bulk", "ep8in-bulk", "ep9in-bulk", "ep10in-bulk", | 146 | "ep6in-bulk", "ep7in-bulk", "ep8in-bulk", "ep9in-bulk", "ep10in-bulk", |
@@ -204,9 +204,8 @@ static void print_regs(struct udc *dev) | |||
204 | DBG(dev, "DMA mode = BF (buffer fill mode)\n"); | 204 | DBG(dev, "DMA mode = BF (buffer fill mode)\n"); |
205 | dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "BF"); | 205 | dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "BF"); |
206 | } | 206 | } |
207 | if (!use_dma) { | 207 | if (!use_dma) |
208 | dev_info(&dev->pdev->dev, "FIFO mode\n"); | 208 | dev_info(&dev->pdev->dev, "FIFO mode\n"); |
209 | } | ||
210 | DBG(dev, "-------------------------------------------------------\n"); | 209 | DBG(dev, "-------------------------------------------------------\n"); |
211 | } | 210 | } |
212 | 211 | ||
@@ -445,6 +444,7 @@ static void ep_init(struct udc_regs __iomem *regs, struct udc_ep *ep) | |||
445 | 444 | ||
446 | VDBG(ep->dev, "ep-%d reset\n", ep->num); | 445 | VDBG(ep->dev, "ep-%d reset\n", ep->num); |
447 | ep->desc = NULL; | 446 | ep->desc = NULL; |
447 | ep->ep.desc = NULL; | ||
448 | ep->ep.ops = &udc_ep_ops; | 448 | ep->ep.ops = &udc_ep_ops; |
449 | INIT_LIST_HEAD(&ep->queue); | 449 | INIT_LIST_HEAD(&ep->queue); |
450 | 450 | ||
@@ -569,9 +569,8 @@ udc_free_request(struct usb_ep *usbep, struct usb_request *usbreq) | |||
569 | VDBG(ep->dev, "req->td_data=%p\n", req->td_data); | 569 | VDBG(ep->dev, "req->td_data=%p\n", req->td_data); |
570 | 570 | ||
571 | /* free dma chain if created */ | 571 | /* free dma chain if created */ |
572 | if (req->chain_len > 1) { | 572 | if (req->chain_len > 1) |
573 | udc_free_dma_chain(ep->dev, req); | 573 | udc_free_dma_chain(ep->dev, req); |
574 | } | ||
575 | 574 | ||
576 | pci_pool_free(ep->dev->data_requests, req->td_data, | 575 | pci_pool_free(ep->dev->data_requests, req->td_data, |
577 | req->td_phys); | 576 | req->td_phys); |
@@ -639,9 +638,8 @@ udc_txfifo_write(struct udc_ep *ep, struct usb_request *req) | |||
639 | bytes = remaining; | 638 | bytes = remaining; |
640 | 639 | ||
641 | /* dwords first */ | 640 | /* dwords first */ |
642 | for (i = 0; i < bytes / UDC_DWORD_BYTES; i++) { | 641 | for (i = 0; i < bytes / UDC_DWORD_BYTES; i++) |
643 | writel(*(buf + i), ep->txfifo); | 642 | writel(*(buf + i), ep->txfifo); |
644 | } | ||
645 | 643 | ||
646 | /* remaining bytes must be written by byte access */ | 644 | /* remaining bytes must be written by byte access */ |
647 | for (j = 0; j < bytes % UDC_DWORD_BYTES; j++) { | 645 | for (j = 0; j < bytes % UDC_DWORD_BYTES; j++) { |
@@ -660,9 +658,8 @@ static int udc_rxfifo_read_dwords(struct udc *dev, u32 *buf, int dwords) | |||
660 | 658 | ||
661 | VDBG(dev, "udc_read_dwords(): %d dwords\n", dwords); | 659 | VDBG(dev, "udc_read_dwords(): %d dwords\n", dwords); |
662 | 660 | ||
663 | for (i = 0; i < dwords; i++) { | 661 | for (i = 0; i < dwords; i++) |
664 | *(buf + i) = readl(dev->rxfifo); | 662 | *(buf + i) = readl(dev->rxfifo); |
665 | } | ||
666 | return 0; | 663 | return 0; |
667 | } | 664 | } |
668 | 665 | ||
@@ -675,9 +672,8 @@ static int udc_rxfifo_read_bytes(struct udc *dev, u8 *buf, int bytes) | |||
675 | VDBG(dev, "udc_read_bytes(): %d bytes\n", bytes); | 672 | VDBG(dev, "udc_read_bytes(): %d bytes\n", bytes); |
676 | 673 | ||
677 | /* dwords first */ | 674 | /* dwords first */ |
678 | for (i = 0; i < bytes / UDC_DWORD_BYTES; i++) { | 675 | for (i = 0; i < bytes / UDC_DWORD_BYTES; i++) |
679 | *((u32 *)(buf + (i<<2))) = readl(dev->rxfifo); | 676 | *((u32 *)(buf + (i<<2))) = readl(dev->rxfifo); |
680 | } | ||
681 | 677 | ||
682 | /* remaining bytes must be read by byte access */ | 678 | /* remaining bytes must be read by byte access */ |
683 | if (bytes % UDC_DWORD_BYTES) { | 679 | if (bytes % UDC_DWORD_BYTES) { |
@@ -831,20 +827,8 @@ __acquires(ep->dev->lock) | |||
831 | 827 | ||
832 | dev = ep->dev; | 828 | dev = ep->dev; |
833 | /* unmap DMA */ | 829 | /* unmap DMA */ |
834 | if (req->dma_mapping) { | 830 | if (ep->dma) |
835 | if (ep->in) | 831 | usb_gadget_unmap_request(&dev->gadget, &req->req, ep->in); |
836 | pci_unmap_single(dev->pdev, | ||
837 | req->req.dma, | ||
838 | req->req.length, | ||
839 | PCI_DMA_TODEVICE); | ||
840 | else | ||
841 | pci_unmap_single(dev->pdev, | ||
842 | req->req.dma, | ||
843 | req->req.length, | ||
844 | PCI_DMA_FROMDEVICE); | ||
845 | req->dma_mapping = 0; | ||
846 | req->req.dma = DMA_DONT_USE; | ||
847 | } | ||
848 | 832 | ||
849 | halted = ep->halted; | 833 | halted = ep->halted; |
850 | ep->halted = 1; | 834 | ep->halted = 1; |
@@ -897,9 +881,8 @@ static struct udc_data_dma *udc_get_last_dma_desc(struct udc_request *req) | |||
897 | struct udc_data_dma *td; | 881 | struct udc_data_dma *td; |
898 | 882 | ||
899 | td = req->td_data; | 883 | td = req->td_data; |
900 | while (td && !(td->status & AMD_BIT(UDC_DMA_IN_STS_L))) { | 884 | while (td && !(td->status & AMD_BIT(UDC_DMA_IN_STS_L))) |
901 | td = phys_to_virt(td->next); | 885 | td = phys_to_virt(td->next); |
902 | } | ||
903 | 886 | ||
904 | return td; | 887 | return td; |
905 | 888 | ||
@@ -949,21 +932,18 @@ static int udc_create_dma_chain( | |||
949 | dma_addr = DMA_DONT_USE; | 932 | dma_addr = DMA_DONT_USE; |
950 | 933 | ||
951 | /* unset L bit in first desc for OUT */ | 934 | /* unset L bit in first desc for OUT */ |
952 | if (!ep->in) { | 935 | if (!ep->in) |
953 | req->td_data->status &= AMD_CLEAR_BIT(UDC_DMA_IN_STS_L); | 936 | req->td_data->status &= AMD_CLEAR_BIT(UDC_DMA_IN_STS_L); |
954 | } | ||
955 | 937 | ||
956 | /* alloc only new desc's if not already available */ | 938 | /* alloc only new desc's if not already available */ |
957 | len = req->req.length / ep->ep.maxpacket; | 939 | len = req->req.length / ep->ep.maxpacket; |
958 | if (req->req.length % ep->ep.maxpacket) { | 940 | if (req->req.length % ep->ep.maxpacket) |
959 | len++; | 941 | len++; |
960 | } | ||
961 | 942 | ||
962 | if (len > req->chain_len) { | 943 | if (len > req->chain_len) { |
963 | /* shorter chain already allocated before */ | 944 | /* shorter chain already allocated before */ |
964 | if (req->chain_len > 1) { | 945 | if (req->chain_len > 1) |
965 | udc_free_dma_chain(ep->dev, req); | 946 | udc_free_dma_chain(ep->dev, req); |
966 | } | ||
967 | req->chain_len = len; | 947 | req->chain_len = len; |
968 | create_new_chain = 1; | 948 | create_new_chain = 1; |
969 | } | 949 | } |
@@ -1006,11 +986,12 @@ static int udc_create_dma_chain( | |||
1006 | 986 | ||
1007 | /* link td and assign tx bytes */ | 987 | /* link td and assign tx bytes */ |
1008 | if (i == buf_len) { | 988 | if (i == buf_len) { |
1009 | if (create_new_chain) { | 989 | if (create_new_chain) |
1010 | req->td_data->next = dma_addr; | 990 | req->td_data->next = dma_addr; |
1011 | } else { | 991 | /* |
1012 | /* req->td_data->next = virt_to_phys(td); */ | 992 | else |
1013 | } | 993 | req->td_data->next = virt_to_phys(td); |
994 | */ | ||
1014 | /* write tx bytes */ | 995 | /* write tx bytes */ |
1015 | if (ep->in) { | 996 | if (ep->in) { |
1016 | /* first desc */ | 997 | /* first desc */ |
@@ -1024,11 +1005,12 @@ static int udc_create_dma_chain( | |||
1024 | UDC_DMA_IN_STS_TXBYTES); | 1005 | UDC_DMA_IN_STS_TXBYTES); |
1025 | } | 1006 | } |
1026 | } else { | 1007 | } else { |
1027 | if (create_new_chain) { | 1008 | if (create_new_chain) |
1028 | last->next = dma_addr; | 1009 | last->next = dma_addr; |
1029 | } else { | 1010 | /* |
1030 | /* last->next = virt_to_phys(td); */ | 1011 | else |
1031 | } | 1012 | last->next = virt_to_phys(td); |
1013 | */ | ||
1032 | if (ep->in) { | 1014 | if (ep->in) { |
1033 | /* write tx bytes */ | 1015 | /* write tx bytes */ |
1034 | td->status = AMD_ADDBITS(td->status, | 1016 | td->status = AMD_ADDBITS(td->status, |
@@ -1095,20 +1077,11 @@ udc_queue(struct usb_ep *usbep, struct usb_request *usbreq, gfp_t gfp) | |||
1095 | return -ESHUTDOWN; | 1077 | return -ESHUTDOWN; |
1096 | 1078 | ||
1097 | /* map dma (usually done before) */ | 1079 | /* map dma (usually done before) */ |
1098 | if (ep->dma && usbreq->length != 0 | 1080 | if (ep->dma) { |
1099 | && (usbreq->dma == DMA_DONT_USE || usbreq->dma == 0)) { | ||
1100 | VDBG(dev, "DMA map req %p\n", req); | 1081 | VDBG(dev, "DMA map req %p\n", req); |
1101 | if (ep->in) | 1082 | retval = usb_gadget_map_request(&udc->gadget, usbreq, ep->in); |
1102 | usbreq->dma = pci_map_single(dev->pdev, | 1083 | if (retval) |
1103 | usbreq->buf, | 1084 | return retval; |
1104 | usbreq->length, | ||
1105 | PCI_DMA_TODEVICE); | ||
1106 | else | ||
1107 | usbreq->dma = pci_map_single(dev->pdev, | ||
1108 | usbreq->buf, | ||
1109 | usbreq->length, | ||
1110 | PCI_DMA_FROMDEVICE); | ||
1111 | req->dma_mapping = 1; | ||
1112 | } | 1085 | } |
1113 | 1086 | ||
1114 | VDBG(dev, "%s queue req %p, len %d req->td_data=%p buf %p\n", | 1087 | VDBG(dev, "%s queue req %p, len %d req->td_data=%p buf %p\n", |
@@ -1479,11 +1452,10 @@ static int startup_registers(struct udc *dev) | |||
1479 | 1452 | ||
1480 | /* program speed */ | 1453 | /* program speed */ |
1481 | tmp = readl(&dev->regs->cfg); | 1454 | tmp = readl(&dev->regs->cfg); |
1482 | if (use_fullspeed) { | 1455 | if (use_fullspeed) |
1483 | tmp = AMD_ADDBITS(tmp, UDC_DEVCFG_SPD_FS, UDC_DEVCFG_SPD); | 1456 | tmp = AMD_ADDBITS(tmp, UDC_DEVCFG_SPD_FS, UDC_DEVCFG_SPD); |
1484 | } else { | 1457 | else |
1485 | tmp = AMD_ADDBITS(tmp, UDC_DEVCFG_SPD_HS, UDC_DEVCFG_SPD); | 1458 | tmp = AMD_ADDBITS(tmp, UDC_DEVCFG_SPD_HS, UDC_DEVCFG_SPD); |
1486 | } | ||
1487 | writel(tmp, &dev->regs->cfg); | 1459 | writel(tmp, &dev->regs->cfg); |
1488 | 1460 | ||
1489 | return 0; | 1461 | return 0; |
@@ -1504,9 +1476,8 @@ static void udc_basic_init(struct udc *dev) | |||
1504 | mod_timer(&udc_timer, jiffies - 1); | 1476 | mod_timer(&udc_timer, jiffies - 1); |
1505 | } | 1477 | } |
1506 | /* stop poll stall timer */ | 1478 | /* stop poll stall timer */ |
1507 | if (timer_pending(&udc_pollstall_timer)) { | 1479 | if (timer_pending(&udc_pollstall_timer)) |
1508 | mod_timer(&udc_pollstall_timer, jiffies - 1); | 1480 | mod_timer(&udc_pollstall_timer, jiffies - 1); |
1509 | } | ||
1510 | /* disable DMA */ | 1481 | /* disable DMA */ |
1511 | tmp = readl(&dev->regs->ctl); | 1482 | tmp = readl(&dev->regs->ctl); |
1512 | tmp &= AMD_UNMASK_BIT(UDC_DEVCTL_RDE); | 1483 | tmp &= AMD_UNMASK_BIT(UDC_DEVCTL_RDE); |
@@ -1540,11 +1511,10 @@ static void udc_setup_endpoints(struct udc *dev) | |||
1540 | /* read enum speed */ | 1511 | /* read enum speed */ |
1541 | tmp = readl(&dev->regs->sts); | 1512 | tmp = readl(&dev->regs->sts); |
1542 | tmp = AMD_GETBITS(tmp, UDC_DEVSTS_ENUM_SPEED); | 1513 | tmp = AMD_GETBITS(tmp, UDC_DEVSTS_ENUM_SPEED); |
1543 | if (tmp == UDC_DEVSTS_ENUM_SPEED_HIGH) { | 1514 | if (tmp == UDC_DEVSTS_ENUM_SPEED_HIGH) |
1544 | dev->gadget.speed = USB_SPEED_HIGH; | 1515 | dev->gadget.speed = USB_SPEED_HIGH; |
1545 | } else if (tmp == UDC_DEVSTS_ENUM_SPEED_FULL) { | 1516 | else if (tmp == UDC_DEVSTS_ENUM_SPEED_FULL) |
1546 | dev->gadget.speed = USB_SPEED_FULL; | 1517 | dev->gadget.speed = USB_SPEED_FULL; |
1547 | } | ||
1548 | 1518 | ||
1549 | /* set basic ep parameters */ | 1519 | /* set basic ep parameters */ |
1550 | for (tmp = 0; tmp < UDC_EP_NUM; tmp++) { | 1520 | for (tmp = 0; tmp < UDC_EP_NUM; tmp++) { |
@@ -1570,9 +1540,8 @@ static void udc_setup_endpoints(struct udc *dev) | |||
1570 | * disabling ep interrupts when ENUM interrupt occurs but ep is | 1540 | * disabling ep interrupts when ENUM interrupt occurs but ep is |
1571 | * not enabled by gadget driver | 1541 | * not enabled by gadget driver |
1572 | */ | 1542 | */ |
1573 | if (!ep->desc) { | 1543 | if (!ep->desc) |
1574 | ep_init(dev->regs, ep); | 1544 | ep_init(dev->regs, ep); |
1575 | } | ||
1576 | 1545 | ||
1577 | if (use_dma) { | 1546 | if (use_dma) { |
1578 | /* | 1547 | /* |
@@ -1670,9 +1639,8 @@ static void udc_tasklet_disconnect(unsigned long par) | |||
1670 | spin_lock(&dev->lock); | 1639 | spin_lock(&dev->lock); |
1671 | 1640 | ||
1672 | /* empty queues */ | 1641 | /* empty queues */ |
1673 | for (tmp = 0; tmp < UDC_EP_NUM; tmp++) { | 1642 | for (tmp = 0; tmp < UDC_EP_NUM; tmp++) |
1674 | empty_req_queue(&dev->ep[tmp]); | 1643 | empty_req_queue(&dev->ep[tmp]); |
1675 | } | ||
1676 | 1644 | ||
1677 | } | 1645 | } |
1678 | 1646 | ||
@@ -1746,9 +1714,8 @@ static void udc_timer_function(unsigned long v) | |||
1746 | * open the fifo | 1714 | * open the fifo |
1747 | */ | 1715 | */ |
1748 | udc_timer.expires = jiffies + HZ/UDC_RDE_TIMER_DIV; | 1716 | udc_timer.expires = jiffies + HZ/UDC_RDE_TIMER_DIV; |
1749 | if (!stop_timer) { | 1717 | if (!stop_timer) |
1750 | add_timer(&udc_timer); | 1718 | add_timer(&udc_timer); |
1751 | } | ||
1752 | } else { | 1719 | } else { |
1753 | /* | 1720 | /* |
1754 | * fifo contains data now, setup timer for opening | 1721 | * fifo contains data now, setup timer for opening |
@@ -1760,9 +1727,8 @@ static void udc_timer_function(unsigned long v) | |||
1760 | set_rde++; | 1727 | set_rde++; |
1761 | /* debug: lhadmot_timer_start = 221070 */ | 1728 | /* debug: lhadmot_timer_start = 221070 */ |
1762 | udc_timer.expires = jiffies + HZ*UDC_RDE_TIMER_SECONDS; | 1729 | udc_timer.expires = jiffies + HZ*UDC_RDE_TIMER_SECONDS; |
1763 | if (!stop_timer) { | 1730 | if (!stop_timer) |
1764 | add_timer(&udc_timer); | 1731 | add_timer(&udc_timer); |
1765 | } | ||
1766 | } | 1732 | } |
1767 | 1733 | ||
1768 | } else | 1734 | } else |
@@ -1907,19 +1873,17 @@ static void activate_control_endpoints(struct udc *dev) | |||
1907 | mod_timer(&udc_timer, jiffies - 1); | 1873 | mod_timer(&udc_timer, jiffies - 1); |
1908 | } | 1874 | } |
1909 | /* stop pollstall timer */ | 1875 | /* stop pollstall timer */ |
1910 | if (timer_pending(&udc_pollstall_timer)) { | 1876 | if (timer_pending(&udc_pollstall_timer)) |
1911 | mod_timer(&udc_pollstall_timer, jiffies - 1); | 1877 | mod_timer(&udc_pollstall_timer, jiffies - 1); |
1912 | } | ||
1913 | /* enable DMA */ | 1878 | /* enable DMA */ |
1914 | tmp = readl(&dev->regs->ctl); | 1879 | tmp = readl(&dev->regs->ctl); |
1915 | tmp |= AMD_BIT(UDC_DEVCTL_MODE) | 1880 | tmp |= AMD_BIT(UDC_DEVCTL_MODE) |
1916 | | AMD_BIT(UDC_DEVCTL_RDE) | 1881 | | AMD_BIT(UDC_DEVCTL_RDE) |
1917 | | AMD_BIT(UDC_DEVCTL_TDE); | 1882 | | AMD_BIT(UDC_DEVCTL_TDE); |
1918 | if (use_dma_bufferfill_mode) { | 1883 | if (use_dma_bufferfill_mode) |
1919 | tmp |= AMD_BIT(UDC_DEVCTL_BF); | 1884 | tmp |= AMD_BIT(UDC_DEVCTL_BF); |
1920 | } else if (use_dma_ppb_du) { | 1885 | else if (use_dma_ppb_du) |
1921 | tmp |= AMD_BIT(UDC_DEVCTL_DU); | 1886 | tmp |= AMD_BIT(UDC_DEVCTL_DU); |
1922 | } | ||
1923 | writel(tmp, &dev->regs->ctl); | 1887 | writel(tmp, &dev->regs->ctl); |
1924 | } | 1888 | } |
1925 | 1889 | ||
@@ -2104,9 +2068,8 @@ static void udc_ep0_set_rde(struct udc *dev) | |||
2104 | udc_timer.expires = | 2068 | udc_timer.expires = |
2105 | jiffies + HZ/UDC_RDE_TIMER_DIV; | 2069 | jiffies + HZ/UDC_RDE_TIMER_DIV; |
2106 | set_rde = 1; | 2070 | set_rde = 1; |
2107 | if (!stop_timer) { | 2071 | if (!stop_timer) |
2108 | add_timer(&udc_timer); | 2072 | add_timer(&udc_timer); |
2109 | } | ||
2110 | } | 2073 | } |
2111 | } | 2074 | } |
2112 | } | 2075 | } |
@@ -2131,7 +2094,7 @@ static irqreturn_t udc_data_out_isr(struct udc *dev, int ep_ix) | |||
2131 | if (use_dma) { | 2094 | if (use_dma) { |
2132 | /* BNA event ? */ | 2095 | /* BNA event ? */ |
2133 | if (tmp & AMD_BIT(UDC_EPSTS_BNA)) { | 2096 | if (tmp & AMD_BIT(UDC_EPSTS_BNA)) { |
2134 | DBG(dev, "BNA ep%dout occurred - DESPTR = %x \n", | 2097 | DBG(dev, "BNA ep%dout occurred - DESPTR = %x\n", |
2135 | ep->num, readl(&ep->regs->desptr)); | 2098 | ep->num, readl(&ep->regs->desptr)); |
2136 | /* clear BNA */ | 2099 | /* clear BNA */ |
2137 | writel(tmp | AMD_BIT(UDC_EPSTS_BNA), &ep->regs->sts); | 2100 | writel(tmp | AMD_BIT(UDC_EPSTS_BNA), &ep->regs->sts); |
@@ -2294,9 +2257,8 @@ static irqreturn_t udc_data_out_isr(struct udc *dev, int ep_ix) | |||
2294 | jiffies | 2257 | jiffies |
2295 | + HZ*UDC_RDE_TIMER_SECONDS; | 2258 | + HZ*UDC_RDE_TIMER_SECONDS; |
2296 | set_rde = 1; | 2259 | set_rde = 1; |
2297 | if (!stop_timer) { | 2260 | if (!stop_timer) |
2298 | add_timer(&udc_timer); | 2261 | add_timer(&udc_timer); |
2299 | } | ||
2300 | } | 2262 | } |
2301 | if (ep->num != UDC_EP0OUT_IX) | 2263 | if (ep->num != UDC_EP0OUT_IX) |
2302 | dev->data_ep_queued = 0; | 2264 | dev->data_ep_queued = 0; |
@@ -2318,9 +2280,8 @@ static irqreturn_t udc_data_out_isr(struct udc *dev, int ep_ix) | |||
2318 | /* check pending CNAKS */ | 2280 | /* check pending CNAKS */ |
2319 | if (cnak_pending) { | 2281 | if (cnak_pending) { |
2320 | /* CNAk processing when rxfifo empty only */ | 2282 | /* CNAk processing when rxfifo empty only */ |
2321 | if (readl(&dev->regs->sts) & AMD_BIT(UDC_DEVSTS_RXFIFO_EMPTY)) { | 2283 | if (readl(&dev->regs->sts) & AMD_BIT(UDC_DEVSTS_RXFIFO_EMPTY)) |
2322 | udc_process_cnak_queue(dev); | 2284 | udc_process_cnak_queue(dev); |
2323 | } | ||
2324 | } | 2285 | } |
2325 | 2286 | ||
2326 | /* clear OUT bits in ep status */ | 2287 | /* clear OUT bits in ep status */ |
@@ -2348,7 +2309,7 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix) | |||
2348 | /* BNA ? */ | 2309 | /* BNA ? */ |
2349 | if (epsts & AMD_BIT(UDC_EPSTS_BNA)) { | 2310 | if (epsts & AMD_BIT(UDC_EPSTS_BNA)) { |
2350 | dev_err(&dev->pdev->dev, | 2311 | dev_err(&dev->pdev->dev, |
2351 | "BNA ep%din occurred - DESPTR = %08lx \n", | 2312 | "BNA ep%din occurred - DESPTR = %08lx\n", |
2352 | ep->num, | 2313 | ep->num, |
2353 | (unsigned long) readl(&ep->regs->desptr)); | 2314 | (unsigned long) readl(&ep->regs->desptr)); |
2354 | 2315 | ||
@@ -2361,7 +2322,7 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix) | |||
2361 | /* HE event ? */ | 2322 | /* HE event ? */ |
2362 | if (epsts & AMD_BIT(UDC_EPSTS_HE)) { | 2323 | if (epsts & AMD_BIT(UDC_EPSTS_HE)) { |
2363 | dev_err(&dev->pdev->dev, | 2324 | dev_err(&dev->pdev->dev, |
2364 | "HE ep%dn occurred - DESPTR = %08lx \n", | 2325 | "HE ep%dn occurred - DESPTR = %08lx\n", |
2365 | ep->num, (unsigned long) readl(&ep->regs->desptr)); | 2326 | ep->num, (unsigned long) readl(&ep->regs->desptr)); |
2366 | 2327 | ||
2367 | /* clear HE */ | 2328 | /* clear HE */ |
@@ -2427,9 +2388,9 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix) | |||
2427 | /* write fifo */ | 2388 | /* write fifo */ |
2428 | udc_txfifo_write(ep, &req->req); | 2389 | udc_txfifo_write(ep, &req->req); |
2429 | len = req->req.length - req->req.actual; | 2390 | len = req->req.length - req->req.actual; |
2430 | if (len > ep->ep.maxpacket) | 2391 | if (len > ep->ep.maxpacket) |
2431 | len = ep->ep.maxpacket; | 2392 | len = ep->ep.maxpacket; |
2432 | req->req.actual += len; | 2393 | req->req.actual += len; |
2433 | if (req->req.actual == req->req.length | 2394 | if (req->req.actual == req->req.length |
2434 | || (len != ep->ep.maxpacket)) { | 2395 | || (len != ep->ep.maxpacket)) { |
2435 | /* complete req */ | 2396 | /* complete req */ |
@@ -2581,9 +2542,8 @@ __acquires(dev->lock) | |||
2581 | if (!timer_pending(&udc_timer)) { | 2542 | if (!timer_pending(&udc_timer)) { |
2582 | udc_timer.expires = jiffies + | 2543 | udc_timer.expires = jiffies + |
2583 | HZ/UDC_RDE_TIMER_DIV; | 2544 | HZ/UDC_RDE_TIMER_DIV; |
2584 | if (!stop_timer) { | 2545 | if (!stop_timer) |
2585 | add_timer(&udc_timer); | 2546 | add_timer(&udc_timer); |
2586 | } | ||
2587 | } | 2547 | } |
2588 | } | 2548 | } |
2589 | 2549 | ||
@@ -2697,9 +2657,8 @@ __acquires(dev->lock) | |||
2697 | /* check pending CNAKS */ | 2657 | /* check pending CNAKS */ |
2698 | if (cnak_pending) { | 2658 | if (cnak_pending) { |
2699 | /* CNAk processing when rxfifo empty only */ | 2659 | /* CNAk processing when rxfifo empty only */ |
2700 | if (readl(&dev->regs->sts) & AMD_BIT(UDC_DEVSTS_RXFIFO_EMPTY)) { | 2660 | if (readl(&dev->regs->sts) & AMD_BIT(UDC_DEVSTS_RXFIFO_EMPTY)) |
2701 | udc_process_cnak_queue(dev); | 2661 | udc_process_cnak_queue(dev); |
2702 | } | ||
2703 | } | 2662 | } |
2704 | 2663 | ||
2705 | finished: | 2664 | finished: |
@@ -2723,7 +2682,7 @@ static irqreturn_t udc_control_in_isr(struct udc *dev) | |||
2723 | tmp = readl(&dev->ep[UDC_EP0IN_IX].regs->sts); | 2682 | tmp = readl(&dev->ep[UDC_EP0IN_IX].regs->sts); |
2724 | /* DMA completion */ | 2683 | /* DMA completion */ |
2725 | if (tmp & AMD_BIT(UDC_EPSTS_TDC)) { | 2684 | if (tmp & AMD_BIT(UDC_EPSTS_TDC)) { |
2726 | VDBG(dev, "isr: TDC clear \n"); | 2685 | VDBG(dev, "isr: TDC clear\n"); |
2727 | ret_val = IRQ_HANDLED; | 2686 | ret_val = IRQ_HANDLED; |
2728 | 2687 | ||
2729 | /* clear TDC bit */ | 2688 | /* clear TDC bit */ |
@@ -3426,7 +3385,7 @@ static int udc_remote_wakeup(struct udc *dev) | |||
3426 | } | 3385 | } |
3427 | 3386 | ||
3428 | /* PCI device parameters */ | 3387 | /* PCI device parameters */ |
3429 | static const struct pci_device_id pci_id[] = { | 3388 | static DEFINE_PCI_DEVICE_TABLE(pci_id) = { |
3430 | { | 3389 | { |
3431 | PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x2096), | 3390 | PCI_DEVICE(PCI_VENDOR_ID_AMD, 0x2096), |
3432 | .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, | 3391 | .class = (PCI_CLASS_SERIAL_USB << 8) | 0xfe, |
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 143a7256b598..15a8cdb2ded5 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -29,7 +29,6 @@ | |||
29 | #include <linux/clk.h> | 29 | #include <linux/clk.h> |
30 | #include <linux/usb/ch9.h> | 30 | #include <linux/usb/ch9.h> |
31 | #include <linux/usb/gadget.h> | 31 | #include <linux/usb/gadget.h> |
32 | #include <linux/prefetch.h> | ||
33 | 32 | ||
34 | #include <asm/byteorder.h> | 33 | #include <asm/byteorder.h> |
35 | #include <mach/hardware.h> | 34 | #include <mach/hardware.h> |
@@ -558,6 +557,7 @@ static int at91_ep_disable (struct usb_ep * _ep) | |||
558 | 557 | ||
559 | /* restore the endpoint's pristine config */ | 558 | /* restore the endpoint's pristine config */ |
560 | ep->desc = NULL; | 559 | ep->desc = NULL; |
560 | ep->ep.desc = NULL; | ||
561 | ep->ep.maxpacket = ep->maxpacket; | 561 | ep->ep.maxpacket = ep->maxpacket; |
562 | 562 | ||
563 | /* reset fifos and endpoint */ | 563 | /* reset fifos and endpoint */ |
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index e2fb6d583bd9..5e10f651ad63 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c | |||
@@ -659,6 +659,7 @@ static int usba_ep_disable(struct usb_ep *_ep) | |||
659 | return -EINVAL; | 659 | return -EINVAL; |
660 | } | 660 | } |
661 | ep->desc = NULL; | 661 | ep->desc = NULL; |
662 | ep->ep.desc = NULL; | ||
662 | 663 | ||
663 | list_splice_init(&ep->queue, &req_list); | 664 | list_splice_init(&ep->queue, &req_list); |
664 | if (ep->can_dma) { | 665 | if (ep->can_dma) { |
diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index 9d89ae4765a9..98899244860e 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c | |||
@@ -14,10 +14,8 @@ | |||
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/utsname.h> | 15 | #include <linux/utsname.h> |
16 | 16 | ||
17 | #include "u_audio.h" | ||
18 | |||
19 | #define DRIVER_DESC "Linux USB Audio Gadget" | 17 | #define DRIVER_DESC "Linux USB Audio Gadget" |
20 | #define DRIVER_VERSION "Dec 18, 2008" | 18 | #define DRIVER_VERSION "Feb 2, 2012" |
21 | 19 | ||
22 | /*-------------------------------------------------------------------------*/ | 20 | /*-------------------------------------------------------------------------*/ |
23 | 21 | ||
@@ -33,8 +31,36 @@ | |||
33 | #include "config.c" | 31 | #include "config.c" |
34 | #include "epautoconf.c" | 32 | #include "epautoconf.c" |
35 | 33 | ||
36 | #include "u_audio.c" | 34 | /* string IDs are assigned dynamically */ |
37 | #include "f_audio.c" | 35 | |
36 | #define STRING_MANUFACTURER_IDX 0 | ||
37 | #define STRING_PRODUCT_IDX 1 | ||
38 | |||
39 | static char manufacturer[50]; | ||
40 | |||
41 | static struct usb_string strings_dev[] = { | ||
42 | [STRING_MANUFACTURER_IDX].s = manufacturer, | ||
43 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | ||
44 | { } /* end of list */ | ||
45 | }; | ||
46 | |||
47 | static struct usb_gadget_strings stringtab_dev = { | ||
48 | .language = 0x0409, /* en-us */ | ||
49 | .strings = strings_dev, | ||
50 | }; | ||
51 | |||
52 | static struct usb_gadget_strings *audio_strings[] = { | ||
53 | &stringtab_dev, | ||
54 | NULL, | ||
55 | }; | ||
56 | |||
57 | #ifdef CONFIG_GADGET_UAC1 | ||
58 | #include "u_uac1.h" | ||
59 | #include "u_uac1.c" | ||
60 | #include "f_uac1.c" | ||
61 | #else | ||
62 | #include "f_uac2.c" | ||
63 | #endif | ||
38 | 64 | ||
39 | /*-------------------------------------------------------------------------*/ | 65 | /*-------------------------------------------------------------------------*/ |
40 | 66 | ||
@@ -54,9 +80,15 @@ static struct usb_device_descriptor device_desc = { | |||
54 | 80 | ||
55 | .bcdUSB = __constant_cpu_to_le16(0x200), | 81 | .bcdUSB = __constant_cpu_to_le16(0x200), |
56 | 82 | ||
83 | #ifdef CONFIG_GADGET_UAC1 | ||
57 | .bDeviceClass = USB_CLASS_PER_INTERFACE, | 84 | .bDeviceClass = USB_CLASS_PER_INTERFACE, |
58 | .bDeviceSubClass = 0, | 85 | .bDeviceSubClass = 0, |
59 | .bDeviceProtocol = 0, | 86 | .bDeviceProtocol = 0, |
87 | #else | ||
88 | .bDeviceClass = USB_CLASS_MISC, | ||
89 | .bDeviceSubClass = 0x02, | ||
90 | .bDeviceProtocol = 0x01, | ||
91 | #endif | ||
60 | /* .bMaxPacketSize0 = f(hardware) */ | 92 | /* .bMaxPacketSize0 = f(hardware) */ |
61 | 93 | ||
62 | /* Vendor and product id defaults change according to what configs | 94 | /* Vendor and product id defaults change according to what configs |
@@ -108,6 +140,9 @@ static struct usb_configuration audio_config_driver = { | |||
108 | .bConfigurationValue = 1, | 140 | .bConfigurationValue = 1, |
109 | /* .iConfiguration = DYNAMIC */ | 141 | /* .iConfiguration = DYNAMIC */ |
110 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, | 142 | .bmAttributes = USB_CONFIG_ATT_SELFPOWER, |
143 | #ifndef CONFIG_GADGET_UAC1 | ||
144 | .unbind = uac2_unbind_config, | ||
145 | #endif | ||
111 | }; | 146 | }; |
112 | 147 | ||
113 | /*-------------------------------------------------------------------------*/ | 148 | /*-------------------------------------------------------------------------*/ |
@@ -157,7 +192,9 @@ fail: | |||
157 | 192 | ||
158 | static int __exit audio_unbind(struct usb_composite_dev *cdev) | 193 | static int __exit audio_unbind(struct usb_composite_dev *cdev) |
159 | { | 194 | { |
195 | #ifdef CONFIG_GADGET_UAC1 | ||
160 | gaudio_cleanup(); | 196 | gaudio_cleanup(); |
197 | #endif | ||
161 | return 0; | 198 | return 0; |
162 | } | 199 | } |
163 | 200 | ||
diff --git a/drivers/usb/gadget/ci13xxx_msm.c b/drivers/usb/gadget/ci13xxx_msm.c index 1fc612914c52..d07e44c05e9b 100644 --- a/drivers/usb/gadget/ci13xxx_msm.c +++ b/drivers/usb/gadget/ci13xxx_msm.c | |||
@@ -37,10 +37,10 @@ static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event) | |||
37 | * Put the transceiver in non-driving mode. Otherwise host | 37 | * Put the transceiver in non-driving mode. Otherwise host |
38 | * may not detect soft-disconnection. | 38 | * may not detect soft-disconnection. |
39 | */ | 39 | */ |
40 | val = otg_io_read(udc->transceiver, ULPI_FUNC_CTRL); | 40 | val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL); |
41 | val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; | 41 | val &= ~ULPI_FUNC_CTRL_OPMODE_MASK; |
42 | val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | 42 | val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; |
43 | otg_io_write(udc->transceiver, val, ULPI_FUNC_CTRL); | 43 | usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL); |
44 | break; | 44 | break; |
45 | default: | 45 | default: |
46 | dev_dbg(dev, "unknown ci13xxx_udc event\n"); | 46 | dev_dbg(dev, "unknown ci13xxx_udc event\n"); |
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c index 27e313718422..243ef1adf969 100644 --- a/drivers/usb/gadget/ci13xxx_udc.c +++ b/drivers/usb/gadget/ci13xxx_udc.c | |||
@@ -2181,6 +2181,7 @@ static int ep_disable(struct usb_ep *ep) | |||
2181 | } while (mEp->dir != direction); | 2181 | } while (mEp->dir != direction); |
2182 | 2182 | ||
2183 | mEp->desc = NULL; | 2183 | mEp->desc = NULL; |
2184 | mEp->ep.desc = NULL; | ||
2184 | 2185 | ||
2185 | spin_unlock_irqrestore(mEp->lock, flags); | 2186 | spin_unlock_irqrestore(mEp->lock, flags); |
2186 | return retval; | 2187 | return retval; |
@@ -2537,7 +2538,7 @@ static int ci13xxx_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
2537 | struct ci13xxx *udc = container_of(_gadget, struct ci13xxx, gadget); | 2538 | struct ci13xxx *udc = container_of(_gadget, struct ci13xxx, gadget); |
2538 | 2539 | ||
2539 | if (udc->transceiver) | 2540 | if (udc->transceiver) |
2540 | return otg_set_power(udc->transceiver, mA); | 2541 | return usb_phy_set_power(udc->transceiver, mA); |
2541 | return -ENOTSUPP; | 2542 | return -ENOTSUPP; |
2542 | } | 2543 | } |
2543 | 2544 | ||
@@ -2900,7 +2901,7 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2900 | if (retval < 0) | 2901 | if (retval < 0) |
2901 | goto free_udc; | 2902 | goto free_udc; |
2902 | 2903 | ||
2903 | udc->transceiver = otg_get_transceiver(); | 2904 | udc->transceiver = usb_get_transceiver(); |
2904 | 2905 | ||
2905 | if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) { | 2906 | if (udc->udc_driver->flags & CI13XXX_REQUIRE_TRANSCEIVER) { |
2906 | if (udc->transceiver == NULL) { | 2907 | if (udc->transceiver == NULL) { |
@@ -2928,7 +2929,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2928 | goto unreg_device; | 2929 | goto unreg_device; |
2929 | 2930 | ||
2930 | if (udc->transceiver) { | 2931 | if (udc->transceiver) { |
2931 | retval = otg_set_peripheral(udc->transceiver, &udc->gadget); | 2932 | retval = otg_set_peripheral(udc->transceiver->otg, |
2933 | &udc->gadget); | ||
2932 | if (retval) | 2934 | if (retval) |
2933 | goto remove_dbg; | 2935 | goto remove_dbg; |
2934 | } | 2936 | } |
@@ -2945,8 +2947,8 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev, | |||
2945 | 2947 | ||
2946 | remove_trans: | 2948 | remove_trans: |
2947 | if (udc->transceiver) { | 2949 | if (udc->transceiver) { |
2948 | otg_set_peripheral(udc->transceiver, &udc->gadget); | 2950 | otg_set_peripheral(udc->transceiver->otg, &udc->gadget); |
2949 | otg_put_transceiver(udc->transceiver); | 2951 | usb_put_transceiver(udc->transceiver); |
2950 | } | 2952 | } |
2951 | 2953 | ||
2952 | err("error = %i", retval); | 2954 | err("error = %i", retval); |
@@ -2958,7 +2960,7 @@ unreg_device: | |||
2958 | device_unregister(&udc->gadget.dev); | 2960 | device_unregister(&udc->gadget.dev); |
2959 | put_transceiver: | 2961 | put_transceiver: |
2960 | if (udc->transceiver) | 2962 | if (udc->transceiver) |
2961 | otg_put_transceiver(udc->transceiver); | 2963 | usb_put_transceiver(udc->transceiver); |
2962 | free_udc: | 2964 | free_udc: |
2963 | kfree(udc); | 2965 | kfree(udc); |
2964 | _udc = NULL; | 2966 | _udc = NULL; |
@@ -2981,8 +2983,8 @@ static void udc_remove(void) | |||
2981 | usb_del_gadget_udc(&udc->gadget); | 2983 | usb_del_gadget_udc(&udc->gadget); |
2982 | 2984 | ||
2983 | if (udc->transceiver) { | 2985 | if (udc->transceiver) { |
2984 | otg_set_peripheral(udc->transceiver, &udc->gadget); | 2986 | otg_set_peripheral(udc->transceiver->otg, &udc->gadget); |
2985 | otg_put_transceiver(udc->transceiver); | 2987 | usb_put_transceiver(udc->transceiver); |
2986 | } | 2988 | } |
2987 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES | 2989 | #ifdef CONFIG_USB_GADGET_DEBUG_FILES |
2988 | dbg_remove_files(&udc->gadget.dev); | 2990 | dbg_remove_files(&udc->gadget.dev); |
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h index f4871e1fac59..0d31af56c989 100644 --- a/drivers/usb/gadget/ci13xxx_udc.h +++ b/drivers/usb/gadget/ci13xxx_udc.h | |||
@@ -136,7 +136,7 @@ struct ci13xxx { | |||
136 | struct usb_gadget_driver *driver; /* 3rd party gadget driver */ | 136 | struct usb_gadget_driver *driver; /* 3rd party gadget driver */ |
137 | struct ci13xxx_udc_driver *udc_driver; /* device controller driver */ | 137 | struct ci13xxx_udc_driver *udc_driver; /* device controller driver */ |
138 | int vbus_active; /* is VBUS active */ | 138 | int vbus_active; /* is VBUS active */ |
139 | struct otg_transceiver *transceiver; /* Transceiver struct */ | 139 | struct usb_phy *transceiver; /* Transceiver struct */ |
140 | }; | 140 | }; |
141 | 141 | ||
142 | /****************************************************************************** | 142 | /****************************************************************************** |
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index db815c2da7ed..e1cd56c5e2a8 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -39,27 +39,27 @@ | |||
39 | #include <linux/usb.h> | 39 | #include <linux/usb.h> |
40 | #include <linux/usb/gadget.h> | 40 | #include <linux/usb/gadget.h> |
41 | #include <linux/usb/hcd.h> | 41 | #include <linux/usb/hcd.h> |
42 | #include <linux/scatterlist.h> | ||
42 | 43 | ||
43 | #include <asm/byteorder.h> | 44 | #include <asm/byteorder.h> |
44 | #include <asm/io.h> | 45 | #include <linux/io.h> |
45 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
46 | #include <asm/system.h> | 47 | #include <asm/system.h> |
47 | #include <asm/unaligned.h> | 48 | #include <asm/unaligned.h> |
48 | 49 | ||
49 | |||
50 | #define DRIVER_DESC "USB Host+Gadget Emulator" | 50 | #define DRIVER_DESC "USB Host+Gadget Emulator" |
51 | #define DRIVER_VERSION "02 May 2005" | 51 | #define DRIVER_VERSION "02 May 2005" |
52 | 52 | ||
53 | #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ | 53 | #define POWER_BUDGET 500 /* in mA; use 8 for low-power port testing */ |
54 | 54 | ||
55 | static const char driver_name [] = "dummy_hcd"; | 55 | static const char driver_name[] = "dummy_hcd"; |
56 | static const char driver_desc [] = "USB Host+Gadget Emulator"; | 56 | static const char driver_desc[] = "USB Host+Gadget Emulator"; |
57 | 57 | ||
58 | static const char gadget_name [] = "dummy_udc"; | 58 | static const char gadget_name[] = "dummy_udc"; |
59 | 59 | ||
60 | MODULE_DESCRIPTION (DRIVER_DESC); | 60 | MODULE_DESCRIPTION(DRIVER_DESC); |
61 | MODULE_AUTHOR ("David Brownell"); | 61 | MODULE_AUTHOR("David Brownell"); |
62 | MODULE_LICENSE ("GPL"); | 62 | MODULE_LICENSE("GPL"); |
63 | 63 | ||
64 | struct dummy_hcd_module_parameters { | 64 | struct dummy_hcd_module_parameters { |
65 | bool is_super_speed; | 65 | bool is_super_speed; |
@@ -83,10 +83,11 @@ struct dummy_ep { | |||
83 | struct usb_gadget *gadget; | 83 | struct usb_gadget *gadget; |
84 | const struct usb_endpoint_descriptor *desc; | 84 | const struct usb_endpoint_descriptor *desc; |
85 | struct usb_ep ep; | 85 | struct usb_ep ep; |
86 | unsigned halted : 1; | 86 | unsigned halted:1; |
87 | unsigned wedged : 1; | 87 | unsigned wedged:1; |
88 | unsigned already_seen : 1; | 88 | unsigned already_seen:1; |
89 | unsigned setup_stage : 1; | 89 | unsigned setup_stage:1; |
90 | unsigned stream_en:1; | ||
90 | }; | 91 | }; |
91 | 92 | ||
92 | struct dummy_request { | 93 | struct dummy_request { |
@@ -94,15 +95,15 @@ struct dummy_request { | |||
94 | struct usb_request req; | 95 | struct usb_request req; |
95 | }; | 96 | }; |
96 | 97 | ||
97 | static inline struct dummy_ep *usb_ep_to_dummy_ep (struct usb_ep *_ep) | 98 | static inline struct dummy_ep *usb_ep_to_dummy_ep(struct usb_ep *_ep) |
98 | { | 99 | { |
99 | return container_of (_ep, struct dummy_ep, ep); | 100 | return container_of(_ep, struct dummy_ep, ep); |
100 | } | 101 | } |
101 | 102 | ||
102 | static inline struct dummy_request *usb_request_to_dummy_request | 103 | static inline struct dummy_request *usb_request_to_dummy_request |
103 | (struct usb_request *_req) | 104 | (struct usb_request *_req) |
104 | { | 105 | { |
105 | return container_of (_req, struct dummy_request, req); | 106 | return container_of(_req, struct dummy_request, req); |
106 | } | 107 | } |
107 | 108 | ||
108 | /*-------------------------------------------------------------------------*/ | 109 | /*-------------------------------------------------------------------------*/ |
@@ -121,9 +122,9 @@ static inline struct dummy_request *usb_request_to_dummy_request | |||
121 | * configurations, illegal or unsupported packet lengths, and so on. | 122 | * configurations, illegal or unsupported packet lengths, and so on. |
122 | */ | 123 | */ |
123 | 124 | ||
124 | static const char ep0name [] = "ep0"; | 125 | static const char ep0name[] = "ep0"; |
125 | 126 | ||
126 | static const char *const ep_name [] = { | 127 | static const char *const ep_name[] = { |
127 | ep0name, /* everyone has ep0 */ | 128 | ep0name, /* everyone has ep0 */ |
128 | 129 | ||
129 | /* act like a net2280: high speed, six configurable endpoints */ | 130 | /* act like a net2280: high speed, six configurable endpoints */ |
@@ -147,6 +148,8 @@ static const char *const ep_name [] = { | |||
147 | struct urbp { | 148 | struct urbp { |
148 | struct urb *urb; | 149 | struct urb *urb; |
149 | struct list_head urbp_list; | 150 | struct list_head urbp_list; |
151 | struct sg_mapping_iter miter; | ||
152 | u32 miter_started; | ||
150 | }; | 153 | }; |
151 | 154 | ||
152 | 155 | ||
@@ -166,6 +169,8 @@ struct dummy_hcd { | |||
166 | 169 | ||
167 | struct usb_device *udev; | 170 | struct usb_device *udev; |
168 | struct list_head urbp_list; | 171 | struct list_head urbp_list; |
172 | u32 stream_en_ep; | ||
173 | u8 num_stream[30 / 2]; | ||
169 | 174 | ||
170 | unsigned active:1; | 175 | unsigned active:1; |
171 | unsigned old_active:1; | 176 | unsigned old_active:1; |
@@ -178,12 +183,12 @@ struct dummy { | |||
178 | /* | 183 | /* |
179 | * SLAVE/GADGET side support | 184 | * SLAVE/GADGET side support |
180 | */ | 185 | */ |
181 | struct dummy_ep ep [DUMMY_ENDPOINTS]; | 186 | struct dummy_ep ep[DUMMY_ENDPOINTS]; |
182 | int address; | 187 | int address; |
183 | struct usb_gadget gadget; | 188 | struct usb_gadget gadget; |
184 | struct usb_gadget_driver *driver; | 189 | struct usb_gadget_driver *driver; |
185 | struct dummy_request fifo_req; | 190 | struct dummy_request fifo_req; |
186 | u8 fifo_buf [FIFO_SIZE]; | 191 | u8 fifo_buf[FIFO_SIZE]; |
187 | u16 devstatus; | 192 | u16 devstatus; |
188 | unsigned udc_suspended:1; | 193 | unsigned udc_suspended:1; |
189 | unsigned pullup:1; | 194 | unsigned pullup:1; |
@@ -210,14 +215,14 @@ static inline struct device *dummy_dev(struct dummy_hcd *dum) | |||
210 | return dummy_hcd_to_hcd(dum)->self.controller; | 215 | return dummy_hcd_to_hcd(dum)->self.controller; |
211 | } | 216 | } |
212 | 217 | ||
213 | static inline struct device *udc_dev (struct dummy *dum) | 218 | static inline struct device *udc_dev(struct dummy *dum) |
214 | { | 219 | { |
215 | return dum->gadget.dev.parent; | 220 | return dum->gadget.dev.parent; |
216 | } | 221 | } |
217 | 222 | ||
218 | static inline struct dummy *ep_to_dummy (struct dummy_ep *ep) | 223 | static inline struct dummy *ep_to_dummy(struct dummy_ep *ep) |
219 | { | 224 | { |
220 | return container_of (ep->gadget, struct dummy, gadget); | 225 | return container_of(ep->gadget, struct dummy, gadget); |
221 | } | 226 | } |
222 | 227 | ||
223 | static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget) | 228 | static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget) |
@@ -229,9 +234,9 @@ static inline struct dummy_hcd *gadget_to_dummy_hcd(struct usb_gadget *gadget) | |||
229 | return dum->hs_hcd; | 234 | return dum->hs_hcd; |
230 | } | 235 | } |
231 | 236 | ||
232 | static inline struct dummy *gadget_dev_to_dummy (struct device *dev) | 237 | static inline struct dummy *gadget_dev_to_dummy(struct device *dev) |
233 | { | 238 | { |
234 | return container_of (dev, struct dummy, gadget.dev); | 239 | return container_of(dev, struct dummy, gadget.dev); |
235 | } | 240 | } |
236 | 241 | ||
237 | static struct dummy the_controller; | 242 | static struct dummy the_controller; |
@@ -241,24 +246,23 @@ static struct dummy the_controller; | |||
241 | /* SLAVE/GADGET SIDE UTILITY ROUTINES */ | 246 | /* SLAVE/GADGET SIDE UTILITY ROUTINES */ |
242 | 247 | ||
243 | /* called with spinlock held */ | 248 | /* called with spinlock held */ |
244 | static void nuke (struct dummy *dum, struct dummy_ep *ep) | 249 | static void nuke(struct dummy *dum, struct dummy_ep *ep) |
245 | { | 250 | { |
246 | while (!list_empty (&ep->queue)) { | 251 | while (!list_empty(&ep->queue)) { |
247 | struct dummy_request *req; | 252 | struct dummy_request *req; |
248 | 253 | ||
249 | req = list_entry (ep->queue.next, struct dummy_request, queue); | 254 | req = list_entry(ep->queue.next, struct dummy_request, queue); |
250 | list_del_init (&req->queue); | 255 | list_del_init(&req->queue); |
251 | req->req.status = -ESHUTDOWN; | 256 | req->req.status = -ESHUTDOWN; |
252 | 257 | ||
253 | spin_unlock (&dum->lock); | 258 | spin_unlock(&dum->lock); |
254 | req->req.complete (&ep->ep, &req->req); | 259 | req->req.complete(&ep->ep, &req->req); |
255 | spin_lock (&dum->lock); | 260 | spin_lock(&dum->lock); |
256 | } | 261 | } |
257 | } | 262 | } |
258 | 263 | ||
259 | /* caller must hold lock */ | 264 | /* caller must hold lock */ |
260 | static void | 265 | static void stop_activity(struct dummy *dum) |
261 | stop_activity (struct dummy *dum) | ||
262 | { | 266 | { |
263 | struct dummy_ep *ep; | 267 | struct dummy_ep *ep; |
264 | 268 | ||
@@ -268,8 +272,8 @@ stop_activity (struct dummy *dum) | |||
268 | /* The timer is left running so that outstanding URBs can fail */ | 272 | /* The timer is left running so that outstanding URBs can fail */ |
269 | 273 | ||
270 | /* nuke any pending requests first, so driver i/o is quiesced */ | 274 | /* nuke any pending requests first, so driver i/o is quiesced */ |
271 | list_for_each_entry (ep, &dum->gadget.ep_list, ep.ep_list) | 275 | list_for_each_entry(ep, &dum->gadget.ep_list, ep.ep_list) |
272 | nuke (dum, ep); | 276 | nuke(dum, ep); |
273 | 277 | ||
274 | /* driver now does any non-usb quiescing necessary */ | 278 | /* driver now does any non-usb quiescing necessary */ |
275 | } | 279 | } |
@@ -404,8 +408,8 @@ static void set_link_state(struct dummy_hcd *dum_hcd) | |||
404 | #define is_enabled(dum) \ | 408 | #define is_enabled(dum) \ |
405 | (dum->port_status & USB_PORT_STAT_ENABLE) | 409 | (dum->port_status & USB_PORT_STAT_ENABLE) |
406 | 410 | ||
407 | static int | 411 | static int dummy_enable(struct usb_ep *_ep, |
408 | dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | 412 | const struct usb_endpoint_descriptor *desc) |
409 | { | 413 | { |
410 | struct dummy *dum; | 414 | struct dummy *dum; |
411 | struct dummy_hcd *dum_hcd; | 415 | struct dummy_hcd *dum_hcd; |
@@ -413,11 +417,11 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
413 | unsigned max; | 417 | unsigned max; |
414 | int retval; | 418 | int retval; |
415 | 419 | ||
416 | ep = usb_ep_to_dummy_ep (_ep); | 420 | ep = usb_ep_to_dummy_ep(_ep); |
417 | if (!_ep || !desc || ep->desc || _ep->name == ep0name | 421 | if (!_ep || !desc || ep->desc || _ep->name == ep0name |
418 | || desc->bDescriptorType != USB_DT_ENDPOINT) | 422 | || desc->bDescriptorType != USB_DT_ENDPOINT) |
419 | return -EINVAL; | 423 | return -EINVAL; |
420 | dum = ep_to_dummy (ep); | 424 | dum = ep_to_dummy(ep); |
421 | if (!dum->driver) | 425 | if (!dum->driver) |
422 | return -ESHUTDOWN; | 426 | return -ESHUTDOWN; |
423 | 427 | ||
@@ -441,10 +445,10 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
441 | * especially for "ep9out" style fixed function ones.) | 445 | * especially for "ep9out" style fixed function ones.) |
442 | */ | 446 | */ |
443 | retval = -EINVAL; | 447 | retval = -EINVAL; |
444 | switch (desc->bmAttributes & 0x03) { | 448 | switch (usb_endpoint_type(desc)) { |
445 | case USB_ENDPOINT_XFER_BULK: | 449 | case USB_ENDPOINT_XFER_BULK: |
446 | if (strstr (ep->ep.name, "-iso") | 450 | if (strstr(ep->ep.name, "-iso") |
447 | || strstr (ep->ep.name, "-int")) { | 451 | || strstr(ep->ep.name, "-int")) { |
448 | goto done; | 452 | goto done; |
449 | } | 453 | } |
450 | switch (dum->gadget.speed) { | 454 | switch (dum->gadget.speed) { |
@@ -466,7 +470,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
466 | } | 470 | } |
467 | break; | 471 | break; |
468 | case USB_ENDPOINT_XFER_INT: | 472 | case USB_ENDPOINT_XFER_INT: |
469 | if (strstr (ep->ep.name, "-iso")) /* bulk is ok */ | 473 | if (strstr(ep->ep.name, "-iso")) /* bulk is ok */ |
470 | goto done; | 474 | goto done; |
471 | /* real hardware might not handle all packet sizes */ | 475 | /* real hardware might not handle all packet sizes */ |
472 | switch (dum->gadget.speed) { | 476 | switch (dum->gadget.speed) { |
@@ -486,8 +490,8 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
486 | } | 490 | } |
487 | break; | 491 | break; |
488 | case USB_ENDPOINT_XFER_ISOC: | 492 | case USB_ENDPOINT_XFER_ISOC: |
489 | if (strstr (ep->ep.name, "-bulk") | 493 | if (strstr(ep->ep.name, "-bulk") |
490 | || strstr (ep->ep.name, "-int")) | 494 | || strstr(ep->ep.name, "-int")) |
491 | goto done; | 495 | goto done; |
492 | /* real hardware might not handle all packet sizes */ | 496 | /* real hardware might not handle all packet sizes */ |
493 | switch (dum->gadget.speed) { | 497 | switch (dum->gadget.speed) { |
@@ -510,14 +514,22 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
510 | } | 514 | } |
511 | 515 | ||
512 | _ep->maxpacket = max; | 516 | _ep->maxpacket = max; |
517 | if (usb_ss_max_streams(_ep->comp_desc)) { | ||
518 | if (!usb_endpoint_xfer_bulk(desc)) { | ||
519 | dev_err(udc_dev(dum), "Can't enable stream support on " | ||
520 | "non-bulk ep %s\n", _ep->name); | ||
521 | return -EINVAL; | ||
522 | } | ||
523 | ep->stream_en = 1; | ||
524 | } | ||
513 | ep->desc = desc; | 525 | ep->desc = desc; |
514 | 526 | ||
515 | dev_dbg (udc_dev(dum), "enabled %s (ep%d%s-%s) maxpacket %d\n", | 527 | dev_dbg(udc_dev(dum), "enabled %s (ep%d%s-%s) maxpacket %d stream %s\n", |
516 | _ep->name, | 528 | _ep->name, |
517 | desc->bEndpointAddress & 0x0f, | 529 | desc->bEndpointAddress & 0x0f, |
518 | (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", | 530 | (desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out", |
519 | ({ char *val; | 531 | ({ char *val; |
520 | switch (desc->bmAttributes & 0x03) { | 532 | switch (usb_endpoint_type(desc)) { |
521 | case USB_ENDPOINT_XFER_BULK: | 533 | case USB_ENDPOINT_XFER_BULK: |
522 | val = "bulk"; | 534 | val = "bulk"; |
523 | break; | 535 | break; |
@@ -531,7 +543,7 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
531 | val = "ctrl"; | 543 | val = "ctrl"; |
532 | break; | 544 | break; |
533 | }; val; }), | 545 | }; val; }), |
534 | max); | 546 | max, ep->stream_en ? "enabled" : "disabled"); |
535 | 547 | ||
536 | /* at this point real hardware should be NAKing transfers | 548 | /* at this point real hardware should be NAKing transfers |
537 | * to that endpoint, until a buffer is queued to it. | 549 | * to that endpoint, until a buffer is queued to it. |
@@ -542,67 +554,67 @@ done: | |||
542 | return retval; | 554 | return retval; |
543 | } | 555 | } |
544 | 556 | ||
545 | static int dummy_disable (struct usb_ep *_ep) | 557 | static int dummy_disable(struct usb_ep *_ep) |
546 | { | 558 | { |
547 | struct dummy_ep *ep; | 559 | struct dummy_ep *ep; |
548 | struct dummy *dum; | 560 | struct dummy *dum; |
549 | unsigned long flags; | 561 | unsigned long flags; |
550 | int retval; | 562 | int retval; |
551 | 563 | ||
552 | ep = usb_ep_to_dummy_ep (_ep); | 564 | ep = usb_ep_to_dummy_ep(_ep); |
553 | if (!_ep || !ep->desc || _ep->name == ep0name) | 565 | if (!_ep || !ep->desc || _ep->name == ep0name) |
554 | return -EINVAL; | 566 | return -EINVAL; |
555 | dum = ep_to_dummy (ep); | 567 | dum = ep_to_dummy(ep); |
556 | 568 | ||
557 | spin_lock_irqsave (&dum->lock, flags); | 569 | spin_lock_irqsave(&dum->lock, flags); |
558 | ep->desc = NULL; | 570 | ep->desc = NULL; |
571 | ep->stream_en = 0; | ||
559 | retval = 0; | 572 | retval = 0; |
560 | nuke (dum, ep); | 573 | nuke(dum, ep); |
561 | spin_unlock_irqrestore (&dum->lock, flags); | 574 | spin_unlock_irqrestore(&dum->lock, flags); |
562 | 575 | ||
563 | dev_dbg (udc_dev(dum), "disabled %s\n", _ep->name); | 576 | dev_dbg(udc_dev(dum), "disabled %s\n", _ep->name); |
564 | return retval; | 577 | return retval; |
565 | } | 578 | } |
566 | 579 | ||
567 | static struct usb_request * | 580 | static struct usb_request *dummy_alloc_request(struct usb_ep *_ep, |
568 | dummy_alloc_request (struct usb_ep *_ep, gfp_t mem_flags) | 581 | gfp_t mem_flags) |
569 | { | 582 | { |
570 | struct dummy_ep *ep; | 583 | struct dummy_ep *ep; |
571 | struct dummy_request *req; | 584 | struct dummy_request *req; |
572 | 585 | ||
573 | if (!_ep) | 586 | if (!_ep) |
574 | return NULL; | 587 | return NULL; |
575 | ep = usb_ep_to_dummy_ep (_ep); | 588 | ep = usb_ep_to_dummy_ep(_ep); |
576 | 589 | ||
577 | req = kzalloc(sizeof(*req), mem_flags); | 590 | req = kzalloc(sizeof(*req), mem_flags); |
578 | if (!req) | 591 | if (!req) |
579 | return NULL; | 592 | return NULL; |
580 | INIT_LIST_HEAD (&req->queue); | 593 | INIT_LIST_HEAD(&req->queue); |
581 | return &req->req; | 594 | return &req->req; |
582 | } | 595 | } |
583 | 596 | ||
584 | static void | 597 | static void dummy_free_request(struct usb_ep *_ep, struct usb_request *_req) |
585 | dummy_free_request (struct usb_ep *_ep, struct usb_request *_req) | ||
586 | { | 598 | { |
587 | struct dummy_ep *ep; | 599 | struct dummy_ep *ep; |
588 | struct dummy_request *req; | 600 | struct dummy_request *req; |
589 | 601 | ||
590 | ep = usb_ep_to_dummy_ep (_ep); | 602 | if (!_ep || !_req) |
591 | if (!ep || !_req || (!ep->desc && _ep->name != ep0name)) | 603 | return; |
604 | ep = usb_ep_to_dummy_ep(_ep); | ||
605 | if (!ep->desc && _ep->name != ep0name) | ||
592 | return; | 606 | return; |
593 | 607 | ||
594 | req = usb_request_to_dummy_request (_req); | 608 | req = usb_request_to_dummy_request(_req); |
595 | WARN_ON (!list_empty (&req->queue)); | 609 | WARN_ON(!list_empty(&req->queue)); |
596 | kfree (req); | 610 | kfree(req); |
597 | } | 611 | } |
598 | 612 | ||
599 | static void | 613 | static void fifo_complete(struct usb_ep *ep, struct usb_request *req) |
600 | fifo_complete (struct usb_ep *ep, struct usb_request *req) | ||
601 | { | 614 | { |
602 | } | 615 | } |
603 | 616 | ||
604 | static int | 617 | static int dummy_queue(struct usb_ep *_ep, struct usb_request *_req, |
605 | dummy_queue (struct usb_ep *_ep, struct usb_request *_req, | ||
606 | gfp_t mem_flags) | 618 | gfp_t mem_flags) |
607 | { | 619 | { |
608 | struct dummy_ep *ep; | 620 | struct dummy_ep *ep; |
@@ -611,49 +623,48 @@ dummy_queue (struct usb_ep *_ep, struct usb_request *_req, | |||
611 | struct dummy_hcd *dum_hcd; | 623 | struct dummy_hcd *dum_hcd; |
612 | unsigned long flags; | 624 | unsigned long flags; |
613 | 625 | ||
614 | req = usb_request_to_dummy_request (_req); | 626 | req = usb_request_to_dummy_request(_req); |
615 | if (!_req || !list_empty (&req->queue) || !_req->complete) | 627 | if (!_req || !list_empty(&req->queue) || !_req->complete) |
616 | return -EINVAL; | 628 | return -EINVAL; |
617 | 629 | ||
618 | ep = usb_ep_to_dummy_ep (_ep); | 630 | ep = usb_ep_to_dummy_ep(_ep); |
619 | if (!_ep || (!ep->desc && _ep->name != ep0name)) | 631 | if (!_ep || (!ep->desc && _ep->name != ep0name)) |
620 | return -EINVAL; | 632 | return -EINVAL; |
621 | 633 | ||
622 | dum = ep_to_dummy (ep); | 634 | dum = ep_to_dummy(ep); |
623 | dum_hcd = gadget_to_dummy_hcd(&dum->gadget); | 635 | dum_hcd = gadget_to_dummy_hcd(&dum->gadget); |
624 | if (!dum->driver || !is_enabled(dum_hcd)) | 636 | if (!dum->driver || !is_enabled(dum_hcd)) |
625 | return -ESHUTDOWN; | 637 | return -ESHUTDOWN; |
626 | 638 | ||
627 | #if 0 | 639 | #if 0 |
628 | dev_dbg (udc_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n", | 640 | dev_dbg(udc_dev(dum), "ep %p queue req %p to %s, len %d buf %p\n", |
629 | ep, _req, _ep->name, _req->length, _req->buf); | 641 | ep, _req, _ep->name, _req->length, _req->buf); |
630 | #endif | 642 | #endif |
631 | |||
632 | _req->status = -EINPROGRESS; | 643 | _req->status = -EINPROGRESS; |
633 | _req->actual = 0; | 644 | _req->actual = 0; |
634 | spin_lock_irqsave (&dum->lock, flags); | 645 | spin_lock_irqsave(&dum->lock, flags); |
635 | 646 | ||
636 | /* implement an emulated single-request FIFO */ | 647 | /* implement an emulated single-request FIFO */ |
637 | if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && | 648 | if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && |
638 | list_empty (&dum->fifo_req.queue) && | 649 | list_empty(&dum->fifo_req.queue) && |
639 | list_empty (&ep->queue) && | 650 | list_empty(&ep->queue) && |
640 | _req->length <= FIFO_SIZE) { | 651 | _req->length <= FIFO_SIZE) { |
641 | req = &dum->fifo_req; | 652 | req = &dum->fifo_req; |
642 | req->req = *_req; | 653 | req->req = *_req; |
643 | req->req.buf = dum->fifo_buf; | 654 | req->req.buf = dum->fifo_buf; |
644 | memcpy (dum->fifo_buf, _req->buf, _req->length); | 655 | memcpy(dum->fifo_buf, _req->buf, _req->length); |
645 | req->req.context = dum; | 656 | req->req.context = dum; |
646 | req->req.complete = fifo_complete; | 657 | req->req.complete = fifo_complete; |
647 | 658 | ||
648 | list_add_tail(&req->queue, &ep->queue); | 659 | list_add_tail(&req->queue, &ep->queue); |
649 | spin_unlock (&dum->lock); | 660 | spin_unlock(&dum->lock); |
650 | _req->actual = _req->length; | 661 | _req->actual = _req->length; |
651 | _req->status = 0; | 662 | _req->status = 0; |
652 | _req->complete (_ep, _req); | 663 | _req->complete(_ep, _req); |
653 | spin_lock (&dum->lock); | 664 | spin_lock(&dum->lock); |
654 | } else | 665 | } else |
655 | list_add_tail(&req->queue, &ep->queue); | 666 | list_add_tail(&req->queue, &ep->queue); |
656 | spin_unlock_irqrestore (&dum->lock, flags); | 667 | spin_unlock_irqrestore(&dum->lock, flags); |
657 | 668 | ||
658 | /* real hardware would likely enable transfers here, in case | 669 | /* real hardware would likely enable transfers here, in case |
659 | * it'd been left NAKing. | 670 | * it'd been left NAKing. |
@@ -661,7 +672,7 @@ dummy_queue (struct usb_ep *_ep, struct usb_request *_req, | |||
661 | return 0; | 672 | return 0; |
662 | } | 673 | } |
663 | 674 | ||
664 | static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req) | 675 | static int dummy_dequeue(struct usb_ep *_ep, struct usb_request *_req) |
665 | { | 676 | { |
666 | struct dummy_ep *ep; | 677 | struct dummy_ep *ep; |
667 | struct dummy *dum; | 678 | struct dummy *dum; |
@@ -671,31 +682,31 @@ static int dummy_dequeue (struct usb_ep *_ep, struct usb_request *_req) | |||
671 | 682 | ||
672 | if (!_ep || !_req) | 683 | if (!_ep || !_req) |
673 | return retval; | 684 | return retval; |
674 | ep = usb_ep_to_dummy_ep (_ep); | 685 | ep = usb_ep_to_dummy_ep(_ep); |
675 | dum = ep_to_dummy (ep); | 686 | dum = ep_to_dummy(ep); |
676 | 687 | ||
677 | if (!dum->driver) | 688 | if (!dum->driver) |
678 | return -ESHUTDOWN; | 689 | return -ESHUTDOWN; |
679 | 690 | ||
680 | local_irq_save (flags); | 691 | local_irq_save(flags); |
681 | spin_lock (&dum->lock); | 692 | spin_lock(&dum->lock); |
682 | list_for_each_entry (req, &ep->queue, queue) { | 693 | list_for_each_entry(req, &ep->queue, queue) { |
683 | if (&req->req == _req) { | 694 | if (&req->req == _req) { |
684 | list_del_init (&req->queue); | 695 | list_del_init(&req->queue); |
685 | _req->status = -ECONNRESET; | 696 | _req->status = -ECONNRESET; |
686 | retval = 0; | 697 | retval = 0; |
687 | break; | 698 | break; |
688 | } | 699 | } |
689 | } | 700 | } |
690 | spin_unlock (&dum->lock); | 701 | spin_unlock(&dum->lock); |
691 | 702 | ||
692 | if (retval == 0) { | 703 | if (retval == 0) { |
693 | dev_dbg (udc_dev(dum), | 704 | dev_dbg(udc_dev(dum), |
694 | "dequeued req %p from %s, len %d buf %p\n", | 705 | "dequeued req %p from %s, len %d buf %p\n", |
695 | req, _ep->name, _req->length, _req->buf); | 706 | req, _ep->name, _req->length, _req->buf); |
696 | _req->complete (_ep, _req); | 707 | _req->complete(_ep, _req); |
697 | } | 708 | } |
698 | local_irq_restore (flags); | 709 | local_irq_restore(flags); |
699 | return retval; | 710 | return retval; |
700 | } | 711 | } |
701 | 712 | ||
@@ -707,14 +718,14 @@ dummy_set_halt_and_wedge(struct usb_ep *_ep, int value, int wedged) | |||
707 | 718 | ||
708 | if (!_ep) | 719 | if (!_ep) |
709 | return -EINVAL; | 720 | return -EINVAL; |
710 | ep = usb_ep_to_dummy_ep (_ep); | 721 | ep = usb_ep_to_dummy_ep(_ep); |
711 | dum = ep_to_dummy (ep); | 722 | dum = ep_to_dummy(ep); |
712 | if (!dum->driver) | 723 | if (!dum->driver) |
713 | return -ESHUTDOWN; | 724 | return -ESHUTDOWN; |
714 | if (!value) | 725 | if (!value) |
715 | ep->halted = ep->wedged = 0; | 726 | ep->halted = ep->wedged = 0; |
716 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && | 727 | else if (ep->desc && (ep->desc->bEndpointAddress & USB_DIR_IN) && |
717 | !list_empty (&ep->queue)) | 728 | !list_empty(&ep->queue)) |
718 | return -EAGAIN; | 729 | return -EAGAIN; |
719 | else { | 730 | else { |
720 | ep->halted = 1; | 731 | ep->halted = 1; |
@@ -755,15 +766,15 @@ static const struct usb_ep_ops dummy_ep_ops = { | |||
755 | /*-------------------------------------------------------------------------*/ | 766 | /*-------------------------------------------------------------------------*/ |
756 | 767 | ||
757 | /* there are both host and device side versions of this call ... */ | 768 | /* there are both host and device side versions of this call ... */ |
758 | static int dummy_g_get_frame (struct usb_gadget *_gadget) | 769 | static int dummy_g_get_frame(struct usb_gadget *_gadget) |
759 | { | 770 | { |
760 | struct timeval tv; | 771 | struct timeval tv; |
761 | 772 | ||
762 | do_gettimeofday (&tv); | 773 | do_gettimeofday(&tv); |
763 | return tv.tv_usec / 1000; | 774 | return tv.tv_usec / 1000; |
764 | } | 775 | } |
765 | 776 | ||
766 | static int dummy_wakeup (struct usb_gadget *_gadget) | 777 | static int dummy_wakeup(struct usb_gadget *_gadget) |
767 | { | 778 | { |
768 | struct dummy_hcd *dum_hcd; | 779 | struct dummy_hcd *dum_hcd; |
769 | 780 | ||
@@ -786,11 +797,11 @@ static int dummy_wakeup (struct usb_gadget *_gadget) | |||
786 | return 0; | 797 | return 0; |
787 | } | 798 | } |
788 | 799 | ||
789 | static int dummy_set_selfpowered (struct usb_gadget *_gadget, int value) | 800 | static int dummy_set_selfpowered(struct usb_gadget *_gadget, int value) |
790 | { | 801 | { |
791 | struct dummy *dum; | 802 | struct dummy *dum; |
792 | 803 | ||
793 | dum = (gadget_to_dummy_hcd(_gadget))->dum; | 804 | dum = gadget_to_dummy_hcd(_gadget)->dum; |
794 | if (value) | 805 | if (value) |
795 | dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED); | 806 | dum->devstatus |= (1 << USB_DEVICE_SELF_POWERED); |
796 | else | 807 | else |
@@ -798,22 +809,15 @@ static int dummy_set_selfpowered (struct usb_gadget *_gadget, int value) | |||
798 | return 0; | 809 | return 0; |
799 | } | 810 | } |
800 | 811 | ||
801 | static void dummy_udc_udpate_ep0(struct dummy *dum) | 812 | static void dummy_udc_update_ep0(struct dummy *dum) |
802 | { | 813 | { |
803 | u32 i; | 814 | if (dum->gadget.speed == USB_SPEED_SUPER) |
804 | |||
805 | if (dum->gadget.speed == USB_SPEED_SUPER) { | ||
806 | for (i = 0; i < DUMMY_ENDPOINTS; i++) | ||
807 | dum->ep[i].ep.max_streams = 0x10; | ||
808 | dum->ep[0].ep.maxpacket = 9; | 815 | dum->ep[0].ep.maxpacket = 9; |
809 | } else { | 816 | else |
810 | for (i = 0; i < DUMMY_ENDPOINTS; i++) | ||
811 | dum->ep[i].ep.max_streams = 0; | ||
812 | dum->ep[0].ep.maxpacket = 64; | 817 | dum->ep[0].ep.maxpacket = 64; |
813 | } | ||
814 | } | 818 | } |
815 | 819 | ||
816 | static int dummy_pullup (struct usb_gadget *_gadget, int value) | 820 | static int dummy_pullup(struct usb_gadget *_gadget, int value) |
817 | { | 821 | { |
818 | struct dummy_hcd *dum_hcd; | 822 | struct dummy_hcd *dum_hcd; |
819 | struct dummy *dum; | 823 | struct dummy *dum; |
@@ -829,7 +833,7 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value) | |||
829 | dum->driver->max_speed); | 833 | dum->driver->max_speed); |
830 | else | 834 | else |
831 | dum->gadget.speed = USB_SPEED_FULL; | 835 | dum->gadget.speed = USB_SPEED_FULL; |
832 | dummy_udc_udpate_ep0(dum); | 836 | dummy_udc_update_ep0(dum); |
833 | 837 | ||
834 | if (dum->gadget.speed < dum->driver->max_speed) | 838 | if (dum->gadget.speed < dum->driver->max_speed) |
835 | dev_dbg(udc_dev(dum), "This device can perform faster" | 839 | dev_dbg(udc_dev(dum), "This device can perform faster" |
@@ -838,10 +842,10 @@ static int dummy_pullup (struct usb_gadget *_gadget, int value) | |||
838 | } | 842 | } |
839 | dum_hcd = gadget_to_dummy_hcd(_gadget); | 843 | dum_hcd = gadget_to_dummy_hcd(_gadget); |
840 | 844 | ||
841 | spin_lock_irqsave (&dum->lock, flags); | 845 | spin_lock_irqsave(&dum->lock, flags); |
842 | dum->pullup = (value != 0); | 846 | dum->pullup = (value != 0); |
843 | set_link_state(dum_hcd); | 847 | set_link_state(dum_hcd); |
844 | spin_unlock_irqrestore (&dum->lock, flags); | 848 | spin_unlock_irqrestore(&dum->lock, flags); |
845 | 849 | ||
846 | usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd)); | 850 | usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd)); |
847 | return 0; | 851 | return 0; |
@@ -864,16 +868,16 @@ static const struct usb_gadget_ops dummy_ops = { | |||
864 | /*-------------------------------------------------------------------------*/ | 868 | /*-------------------------------------------------------------------------*/ |
865 | 869 | ||
866 | /* "function" sysfs attribute */ | 870 | /* "function" sysfs attribute */ |
867 | static ssize_t | 871 | static ssize_t show_function(struct device *dev, struct device_attribute *attr, |
868 | show_function (struct device *dev, struct device_attribute *attr, char *buf) | 872 | char *buf) |
869 | { | 873 | { |
870 | struct dummy *dum = gadget_dev_to_dummy (dev); | 874 | struct dummy *dum = gadget_dev_to_dummy(dev); |
871 | 875 | ||
872 | if (!dum->driver || !dum->driver->function) | 876 | if (!dum->driver || !dum->driver->function) |
873 | return 0; | 877 | return 0; |
874 | return scnprintf (buf, PAGE_SIZE, "%s\n", dum->driver->function); | 878 | return scnprintf(buf, PAGE_SIZE, "%s\n", dum->driver->function); |
875 | } | 879 | } |
876 | static DEVICE_ATTR (function, S_IRUGO, show_function, NULL); | 880 | static DEVICE_ATTR(function, S_IRUGO, show_function, NULL); |
877 | 881 | ||
878 | /*-------------------------------------------------------------------------*/ | 882 | /*-------------------------------------------------------------------------*/ |
879 | 883 | ||
@@ -908,7 +912,7 @@ static int dummy_udc_start(struct usb_gadget *g, | |||
908 | dum->devstatus = 0; | 912 | dum->devstatus = 0; |
909 | 913 | ||
910 | dum->driver = driver; | 914 | dum->driver = driver; |
911 | dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n", | 915 | dev_dbg(udc_dev(dum), "binding gadget driver '%s'\n", |
912 | driver->driver.name); | 916 | driver->driver.name); |
913 | return 0; | 917 | return 0; |
914 | } | 918 | } |
@@ -919,7 +923,7 @@ static int dummy_udc_stop(struct usb_gadget *g, | |||
919 | struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); | 923 | struct dummy_hcd *dum_hcd = gadget_to_dummy_hcd(g); |
920 | struct dummy *dum = dum_hcd->dum; | 924 | struct dummy *dum = dum_hcd->dum; |
921 | 925 | ||
922 | dev_dbg (udc_dev(dum), "unregister gadget driver '%s'\n", | 926 | dev_dbg(udc_dev(dum), "unregister gadget driver '%s'\n", |
923 | driver->driver.name); | 927 | driver->driver.name); |
924 | 928 | ||
925 | dum->driver = NULL; | 929 | dum->driver = NULL; |
@@ -932,8 +936,7 @@ static int dummy_udc_stop(struct usb_gadget *g, | |||
932 | 936 | ||
933 | /* The gadget structure is stored inside the hcd structure and will be | 937 | /* The gadget structure is stored inside the hcd structure and will be |
934 | * released along with it. */ | 938 | * released along with it. */ |
935 | static void | 939 | static void dummy_gadget_release(struct device *dev) |
936 | dummy_gadget_release (struct device *dev) | ||
937 | { | 940 | { |
938 | return; | 941 | return; |
939 | } | 942 | } |
@@ -954,6 +957,7 @@ static void init_dummy_udc_hw(struct dummy *dum) | |||
954 | ep->halted = ep->wedged = ep->already_seen = | 957 | ep->halted = ep->wedged = ep->already_seen = |
955 | ep->setup_stage = 0; | 958 | ep->setup_stage = 0; |
956 | ep->ep.maxpacket = ~0; | 959 | ep->ep.maxpacket = ~0; |
960 | ep->ep.max_streams = 16; | ||
957 | ep->last_io = jiffies; | 961 | ep->last_io = jiffies; |
958 | ep->gadget = &dum->gadget; | 962 | ep->gadget = &dum->gadget; |
959 | ep->desc = NULL; | 963 | ep->desc = NULL; |
@@ -969,7 +973,7 @@ static void init_dummy_udc_hw(struct dummy *dum) | |||
969 | #endif | 973 | #endif |
970 | } | 974 | } |
971 | 975 | ||
972 | static int dummy_udc_probe (struct platform_device *pdev) | 976 | static int dummy_udc_probe(struct platform_device *pdev) |
973 | { | 977 | { |
974 | struct dummy *dum = &the_controller; | 978 | struct dummy *dum = &the_controller; |
975 | int rc; | 979 | int rc; |
@@ -981,7 +985,7 @@ static int dummy_udc_probe (struct platform_device *pdev) | |||
981 | dev_set_name(&dum->gadget.dev, "gadget"); | 985 | dev_set_name(&dum->gadget.dev, "gadget"); |
982 | dum->gadget.dev.parent = &pdev->dev; | 986 | dum->gadget.dev.parent = &pdev->dev; |
983 | dum->gadget.dev.release = dummy_gadget_release; | 987 | dum->gadget.dev.release = dummy_gadget_release; |
984 | rc = device_register (&dum->gadget.dev); | 988 | rc = device_register(&dum->gadget.dev); |
985 | if (rc < 0) { | 989 | if (rc < 0) { |
986 | put_device(&dum->gadget.dev); | 990 | put_device(&dum->gadget.dev); |
987 | return rc; | 991 | return rc; |
@@ -993,7 +997,7 @@ static int dummy_udc_probe (struct platform_device *pdev) | |||
993 | if (rc < 0) | 997 | if (rc < 0) |
994 | goto err_udc; | 998 | goto err_udc; |
995 | 999 | ||
996 | rc = device_create_file (&dum->gadget.dev, &dev_attr_function); | 1000 | rc = device_create_file(&dum->gadget.dev, &dev_attr_function); |
997 | if (rc < 0) | 1001 | if (rc < 0) |
998 | goto err_dev; | 1002 | goto err_dev; |
999 | platform_set_drvdata(pdev, dum); | 1003 | platform_set_drvdata(pdev, dum); |
@@ -1006,14 +1010,14 @@ err_udc: | |||
1006 | return rc; | 1010 | return rc; |
1007 | } | 1011 | } |
1008 | 1012 | ||
1009 | static int dummy_udc_remove (struct platform_device *pdev) | 1013 | static int dummy_udc_remove(struct platform_device *pdev) |
1010 | { | 1014 | { |
1011 | struct dummy *dum = platform_get_drvdata (pdev); | 1015 | struct dummy *dum = platform_get_drvdata(pdev); |
1012 | 1016 | ||
1013 | usb_del_gadget_udc(&dum->gadget); | 1017 | usb_del_gadget_udc(&dum->gadget); |
1014 | platform_set_drvdata (pdev, NULL); | 1018 | platform_set_drvdata(pdev, NULL); |
1015 | device_remove_file (&dum->gadget.dev, &dev_attr_function); | 1019 | device_remove_file(&dum->gadget.dev, &dev_attr_function); |
1016 | device_unregister (&dum->gadget.dev); | 1020 | device_unregister(&dum->gadget.dev); |
1017 | return 0; | 1021 | return 0; |
1018 | } | 1022 | } |
1019 | 1023 | ||
@@ -1061,6 +1065,16 @@ static struct platform_driver dummy_udc_driver = { | |||
1061 | 1065 | ||
1062 | /*-------------------------------------------------------------------------*/ | 1066 | /*-------------------------------------------------------------------------*/ |
1063 | 1067 | ||
1068 | static unsigned int dummy_get_ep_idx(const struct usb_endpoint_descriptor *desc) | ||
1069 | { | ||
1070 | unsigned int index; | ||
1071 | |||
1072 | index = usb_endpoint_num(desc) << 1; | ||
1073 | if (usb_endpoint_dir_in(desc)) | ||
1074 | index |= 1; | ||
1075 | return index; | ||
1076 | } | ||
1077 | |||
1064 | /* MASTER/HOST SIDE DRIVER | 1078 | /* MASTER/HOST SIDE DRIVER |
1065 | * | 1079 | * |
1066 | * this uses the hcd framework to hook up to host side drivers. | 1080 | * this uses the hcd framework to hook up to host side drivers. |
@@ -1073,7 +1087,82 @@ static struct platform_driver dummy_udc_driver = { | |||
1073 | * usb 2.0 rules. | 1087 | * usb 2.0 rules. |
1074 | */ | 1088 | */ |
1075 | 1089 | ||
1076 | static int dummy_urb_enqueue ( | 1090 | static int dummy_ep_stream_en(struct dummy_hcd *dum_hcd, struct urb *urb) |
1091 | { | ||
1092 | const struct usb_endpoint_descriptor *desc = &urb->ep->desc; | ||
1093 | u32 index; | ||
1094 | |||
1095 | if (!usb_endpoint_xfer_bulk(desc)) | ||
1096 | return 0; | ||
1097 | |||
1098 | index = dummy_get_ep_idx(desc); | ||
1099 | return (1 << index) & dum_hcd->stream_en_ep; | ||
1100 | } | ||
1101 | |||
1102 | /* | ||
1103 | * The max stream number is saved as a nibble so for the 30 possible endpoints | ||
1104 | * we only 15 bytes of memory. Therefore we are limited to max 16 streams (0 | ||
1105 | * means we use only 1 stream). The maximum according to the spec is 16bit so | ||
1106 | * if the 16 stream limit is about to go, the array size should be incremented | ||
1107 | * to 30 elements of type u16. | ||
1108 | */ | ||
1109 | static int get_max_streams_for_pipe(struct dummy_hcd *dum_hcd, | ||
1110 | unsigned int pipe) | ||
1111 | { | ||
1112 | int max_streams; | ||
1113 | |||
1114 | max_streams = dum_hcd->num_stream[usb_pipeendpoint(pipe)]; | ||
1115 | if (usb_pipeout(pipe)) | ||
1116 | max_streams >>= 4; | ||
1117 | else | ||
1118 | max_streams &= 0xf; | ||
1119 | max_streams++; | ||
1120 | return max_streams; | ||
1121 | } | ||
1122 | |||
1123 | static void set_max_streams_for_pipe(struct dummy_hcd *dum_hcd, | ||
1124 | unsigned int pipe, unsigned int streams) | ||
1125 | { | ||
1126 | int max_streams; | ||
1127 | |||
1128 | streams--; | ||
1129 | max_streams = dum_hcd->num_stream[usb_pipeendpoint(pipe)]; | ||
1130 | if (usb_pipeout(pipe)) { | ||
1131 | streams <<= 4; | ||
1132 | max_streams &= 0xf; | ||
1133 | } else { | ||
1134 | max_streams &= 0xf0; | ||
1135 | } | ||
1136 | max_streams |= streams; | ||
1137 | dum_hcd->num_stream[usb_pipeendpoint(pipe)] = max_streams; | ||
1138 | } | ||
1139 | |||
1140 | static int dummy_validate_stream(struct dummy_hcd *dum_hcd, struct urb *urb) | ||
1141 | { | ||
1142 | unsigned int max_streams; | ||
1143 | int enabled; | ||
1144 | |||
1145 | enabled = dummy_ep_stream_en(dum_hcd, urb); | ||
1146 | if (!urb->stream_id) { | ||
1147 | if (enabled) | ||
1148 | return -EINVAL; | ||
1149 | return 0; | ||
1150 | } | ||
1151 | if (!enabled) | ||
1152 | return -EINVAL; | ||
1153 | |||
1154 | max_streams = get_max_streams_for_pipe(dum_hcd, | ||
1155 | usb_pipeendpoint(urb->pipe)); | ||
1156 | if (urb->stream_id > max_streams) { | ||
1157 | dev_err(dummy_dev(dum_hcd), "Stream id %d is out of range.\n", | ||
1158 | urb->stream_id); | ||
1159 | BUG(); | ||
1160 | return -EINVAL; | ||
1161 | } | ||
1162 | return 0; | ||
1163 | } | ||
1164 | |||
1165 | static int dummy_urb_enqueue( | ||
1077 | struct usb_hcd *hcd, | 1166 | struct usb_hcd *hcd, |
1078 | struct urb *urb, | 1167 | struct urb *urb, |
1079 | gfp_t mem_flags | 1168 | gfp_t mem_flags |
@@ -1083,16 +1172,21 @@ static int dummy_urb_enqueue ( | |||
1083 | unsigned long flags; | 1172 | unsigned long flags; |
1084 | int rc; | 1173 | int rc; |
1085 | 1174 | ||
1086 | if (!urb->transfer_buffer && urb->transfer_buffer_length) | 1175 | urbp = kmalloc(sizeof *urbp, mem_flags); |
1087 | return -EINVAL; | ||
1088 | |||
1089 | urbp = kmalloc (sizeof *urbp, mem_flags); | ||
1090 | if (!urbp) | 1176 | if (!urbp) |
1091 | return -ENOMEM; | 1177 | return -ENOMEM; |
1092 | urbp->urb = urb; | 1178 | urbp->urb = urb; |
1179 | urbp->miter_started = 0; | ||
1093 | 1180 | ||
1094 | dum_hcd = hcd_to_dummy_hcd(hcd); | 1181 | dum_hcd = hcd_to_dummy_hcd(hcd); |
1095 | spin_lock_irqsave(&dum_hcd->dum->lock, flags); | 1182 | spin_lock_irqsave(&dum_hcd->dum->lock, flags); |
1183 | |||
1184 | rc = dummy_validate_stream(dum_hcd, urb); | ||
1185 | if (rc) { | ||
1186 | kfree(urbp); | ||
1187 | goto done; | ||
1188 | } | ||
1189 | |||
1096 | rc = usb_hcd_link_urb_to_ep(hcd, urb); | 1190 | rc = usb_hcd_link_urb_to_ep(hcd, urb); |
1097 | if (rc) { | 1191 | if (rc) { |
1098 | kfree(urbp); | 1192 | kfree(urbp); |
@@ -1107,7 +1201,7 @@ static int dummy_urb_enqueue ( | |||
1107 | 1201 | ||
1108 | list_add_tail(&urbp->urbp_list, &dum_hcd->urbp_list); | 1202 | list_add_tail(&urbp->urbp_list, &dum_hcd->urbp_list); |
1109 | urb->hcpriv = urbp; | 1203 | urb->hcpriv = urbp; |
1110 | if (usb_pipetype (urb->pipe) == PIPE_CONTROL) | 1204 | if (usb_pipetype(urb->pipe) == PIPE_CONTROL) |
1111 | urb->error_count = 1; /* mark as a new urb */ | 1205 | urb->error_count = 1; /* mark as a new urb */ |
1112 | 1206 | ||
1113 | /* kick the scheduler, it'll do the rest */ | 1207 | /* kick the scheduler, it'll do the rest */ |
@@ -1139,20 +1233,91 @@ static int dummy_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1139 | return rc; | 1233 | return rc; |
1140 | } | 1234 | } |
1141 | 1235 | ||
1236 | static int dummy_perform_transfer(struct urb *urb, struct dummy_request *req, | ||
1237 | u32 len) | ||
1238 | { | ||
1239 | void *ubuf, *rbuf; | ||
1240 | struct urbp *urbp = urb->hcpriv; | ||
1241 | int to_host; | ||
1242 | struct sg_mapping_iter *miter = &urbp->miter; | ||
1243 | u32 trans = 0; | ||
1244 | u32 this_sg; | ||
1245 | bool next_sg; | ||
1246 | |||
1247 | to_host = usb_pipein(urb->pipe); | ||
1248 | rbuf = req->req.buf + req->req.actual; | ||
1249 | |||
1250 | if (!urb->num_sgs) { | ||
1251 | ubuf = urb->transfer_buffer + urb->actual_length; | ||
1252 | if (to_host) | ||
1253 | memcpy(ubuf, rbuf, len); | ||
1254 | else | ||
1255 | memcpy(rbuf, ubuf, len); | ||
1256 | return len; | ||
1257 | } | ||
1258 | |||
1259 | if (!urbp->miter_started) { | ||
1260 | u32 flags = SG_MITER_ATOMIC; | ||
1261 | |||
1262 | if (to_host) | ||
1263 | flags |= SG_MITER_TO_SG; | ||
1264 | else | ||
1265 | flags |= SG_MITER_FROM_SG; | ||
1266 | |||
1267 | sg_miter_start(miter, urb->sg, urb->num_sgs, flags); | ||
1268 | urbp->miter_started = 1; | ||
1269 | } | ||
1270 | next_sg = sg_miter_next(miter); | ||
1271 | if (next_sg == false) { | ||
1272 | WARN_ON_ONCE(1); | ||
1273 | return -EINVAL; | ||
1274 | } | ||
1275 | do { | ||
1276 | ubuf = miter->addr; | ||
1277 | this_sg = min_t(u32, len, miter->length); | ||
1278 | miter->consumed = this_sg; | ||
1279 | trans += this_sg; | ||
1280 | |||
1281 | if (to_host) | ||
1282 | memcpy(ubuf, rbuf, this_sg); | ||
1283 | else | ||
1284 | memcpy(rbuf, ubuf, this_sg); | ||
1285 | len -= this_sg; | ||
1286 | |||
1287 | if (!len) | ||
1288 | break; | ||
1289 | next_sg = sg_miter_next(miter); | ||
1290 | if (next_sg == false) { | ||
1291 | WARN_ON_ONCE(1); | ||
1292 | return -EINVAL; | ||
1293 | } | ||
1294 | |||
1295 | rbuf += this_sg; | ||
1296 | } while (1); | ||
1297 | |||
1298 | sg_miter_stop(miter); | ||
1299 | return trans; | ||
1300 | } | ||
1301 | |||
1142 | /* transfer up to a frame's worth; caller must own lock */ | 1302 | /* transfer up to a frame's worth; caller must own lock */ |
1143 | static int | 1303 | static int transfer(struct dummy_hcd *dum_hcd, struct urb *urb, |
1144 | transfer(struct dummy *dum, struct urb *urb, struct dummy_ep *ep, int limit, | 1304 | struct dummy_ep *ep, int limit, int *status) |
1145 | int *status) | ||
1146 | { | 1305 | { |
1306 | struct dummy *dum = dum_hcd->dum; | ||
1147 | struct dummy_request *req; | 1307 | struct dummy_request *req; |
1148 | 1308 | ||
1149 | top: | 1309 | top: |
1150 | /* if there's no request queued, the device is NAKing; return */ | 1310 | /* if there's no request queued, the device is NAKing; return */ |
1151 | list_for_each_entry (req, &ep->queue, queue) { | 1311 | list_for_each_entry(req, &ep->queue, queue) { |
1152 | unsigned host_len, dev_len, len; | 1312 | unsigned host_len, dev_len, len; |
1153 | int is_short, to_host; | 1313 | int is_short, to_host; |
1154 | int rescan = 0; | 1314 | int rescan = 0; |
1155 | 1315 | ||
1316 | if (dummy_ep_stream_en(dum_hcd, urb)) { | ||
1317 | if ((urb->stream_id != req->req.stream_id)) | ||
1318 | continue; | ||
1319 | } | ||
1320 | |||
1156 | /* 1..N packets of ep->ep.maxpacket each ... the last one | 1321 | /* 1..N packets of ep->ep.maxpacket each ... the last one |
1157 | * may be short (including zero length). | 1322 | * may be short (including zero length). |
1158 | * | 1323 | * |
@@ -1162,20 +1327,18 @@ top: | |||
1162 | */ | 1327 | */ |
1163 | host_len = urb->transfer_buffer_length - urb->actual_length; | 1328 | host_len = urb->transfer_buffer_length - urb->actual_length; |
1164 | dev_len = req->req.length - req->req.actual; | 1329 | dev_len = req->req.length - req->req.actual; |
1165 | len = min (host_len, dev_len); | 1330 | len = min(host_len, dev_len); |
1166 | 1331 | ||
1167 | /* FIXME update emulated data toggle too */ | 1332 | /* FIXME update emulated data toggle too */ |
1168 | 1333 | ||
1169 | to_host = usb_pipein (urb->pipe); | 1334 | to_host = usb_pipein(urb->pipe); |
1170 | if (unlikely (len == 0)) | 1335 | if (unlikely(len == 0)) |
1171 | is_short = 1; | 1336 | is_short = 1; |
1172 | else { | 1337 | else { |
1173 | char *ubuf, *rbuf; | ||
1174 | |||
1175 | /* not enough bandwidth left? */ | 1338 | /* not enough bandwidth left? */ |
1176 | if (limit < ep->ep.maxpacket && limit < len) | 1339 | if (limit < ep->ep.maxpacket && limit < len) |
1177 | break; | 1340 | break; |
1178 | len = min (len, (unsigned) limit); | 1341 | len = min_t(unsigned, len, limit); |
1179 | if (len == 0) | 1342 | if (len == 0) |
1180 | break; | 1343 | break; |
1181 | 1344 | ||
@@ -1186,18 +1349,16 @@ top: | |||
1186 | } | 1349 | } |
1187 | is_short = (len % ep->ep.maxpacket) != 0; | 1350 | is_short = (len % ep->ep.maxpacket) != 0; |
1188 | 1351 | ||
1189 | /* else transfer packet(s) */ | 1352 | len = dummy_perform_transfer(urb, req, len); |
1190 | ubuf = urb->transfer_buffer + urb->actual_length; | ||
1191 | rbuf = req->req.buf + req->req.actual; | ||
1192 | if (to_host) | ||
1193 | memcpy (ubuf, rbuf, len); | ||
1194 | else | ||
1195 | memcpy (rbuf, ubuf, len); | ||
1196 | ep->last_io = jiffies; | ||
1197 | 1353 | ||
1198 | limit -= len; | 1354 | ep->last_io = jiffies; |
1199 | urb->actual_length += len; | 1355 | if ((int)len < 0) { |
1200 | req->req.actual += len; | 1356 | req->req.status = len; |
1357 | } else { | ||
1358 | limit -= len; | ||
1359 | urb->actual_length += len; | ||
1360 | req->req.actual += len; | ||
1361 | } | ||
1201 | } | 1362 | } |
1202 | 1363 | ||
1203 | /* short packets terminate, maybe with overflow/underflow. | 1364 | /* short packets terminate, maybe with overflow/underflow. |
@@ -1238,11 +1399,11 @@ top: | |||
1238 | 1399 | ||
1239 | /* device side completion --> continuable */ | 1400 | /* device side completion --> continuable */ |
1240 | if (req->req.status != -EINPROGRESS) { | 1401 | if (req->req.status != -EINPROGRESS) { |
1241 | list_del_init (&req->queue); | 1402 | list_del_init(&req->queue); |
1242 | 1403 | ||
1243 | spin_unlock (&dum->lock); | 1404 | spin_unlock(&dum->lock); |
1244 | req->req.complete (&ep->ep, &req->req); | 1405 | req->req.complete(&ep->ep, &req->req); |
1245 | spin_lock (&dum->lock); | 1406 | spin_lock(&dum->lock); |
1246 | 1407 | ||
1247 | /* requests might have been unlinked... */ | 1408 | /* requests might have been unlinked... */ |
1248 | rescan = 1; | 1409 | rescan = 1; |
@@ -1259,7 +1420,7 @@ top: | |||
1259 | return limit; | 1420 | return limit; |
1260 | } | 1421 | } |
1261 | 1422 | ||
1262 | static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep) | 1423 | static int periodic_bytes(struct dummy *dum, struct dummy_ep *ep) |
1263 | { | 1424 | { |
1264 | int limit = ep->ep.maxpacket; | 1425 | int limit = ep->ep.maxpacket; |
1265 | 1426 | ||
@@ -1273,7 +1434,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep) | |||
1273 | limit += limit * tmp; | 1434 | limit += limit * tmp; |
1274 | } | 1435 | } |
1275 | if (dum->gadget.speed == USB_SPEED_SUPER) { | 1436 | if (dum->gadget.speed == USB_SPEED_SUPER) { |
1276 | switch (ep->desc->bmAttributes & 0x03) { | 1437 | switch (usb_endpoint_type(ep->desc)) { |
1277 | case USB_ENDPOINT_XFER_ISOC: | 1438 | case USB_ENDPOINT_XFER_ISOC: |
1278 | /* Sec. 4.4.8.2 USB3.0 Spec */ | 1439 | /* Sec. 4.4.8.2 USB3.0 Spec */ |
1279 | limit = 3 * 16 * 1024 * 8; | 1440 | limit = 3 * 16 * 1024 * 8; |
@@ -1295,7 +1456,7 @@ static int periodic_bytes (struct dummy *dum, struct dummy_ep *ep) | |||
1295 | USB_PORT_STAT_SUSPEND)) \ | 1456 | USB_PORT_STAT_SUSPEND)) \ |
1296 | == (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) | 1457 | == (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) |
1297 | 1458 | ||
1298 | static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address) | 1459 | static struct dummy_ep *find_endpoint(struct dummy *dum, u8 address) |
1299 | { | 1460 | { |
1300 | int i; | 1461 | int i; |
1301 | 1462 | ||
@@ -1303,9 +1464,9 @@ static struct dummy_ep *find_endpoint (struct dummy *dum, u8 address) | |||
1303 | dum->ss_hcd : dum->hs_hcd))) | 1464 | dum->ss_hcd : dum->hs_hcd))) |
1304 | return NULL; | 1465 | return NULL; |
1305 | if ((address & ~USB_DIR_IN) == 0) | 1466 | if ((address & ~USB_DIR_IN) == 0) |
1306 | return &dum->ep [0]; | 1467 | return &dum->ep[0]; |
1307 | for (i = 1; i < DUMMY_ENDPOINTS; i++) { | 1468 | for (i = 1; i < DUMMY_ENDPOINTS; i++) { |
1308 | struct dummy_ep *ep = &dum->ep [i]; | 1469 | struct dummy_ep *ep = &dum->ep[i]; |
1309 | 1470 | ||
1310 | if (!ep->desc) | 1471 | if (!ep->desc) |
1311 | continue; | 1472 | continue; |
@@ -1535,19 +1696,19 @@ static void dummy_timer(unsigned long _dum_hcd) | |||
1535 | /* FIXME if HZ != 1000 this will probably misbehave ... */ | 1696 | /* FIXME if HZ != 1000 this will probably misbehave ... */ |
1536 | 1697 | ||
1537 | /* look at each urb queued by the host side driver */ | 1698 | /* look at each urb queued by the host side driver */ |
1538 | spin_lock_irqsave (&dum->lock, flags); | 1699 | spin_lock_irqsave(&dum->lock, flags); |
1539 | 1700 | ||
1540 | if (!dum_hcd->udev) { | 1701 | if (!dum_hcd->udev) { |
1541 | dev_err(dummy_dev(dum_hcd), | 1702 | dev_err(dummy_dev(dum_hcd), |
1542 | "timer fired with no URBs pending?\n"); | 1703 | "timer fired with no URBs pending?\n"); |
1543 | spin_unlock_irqrestore (&dum->lock, flags); | 1704 | spin_unlock_irqrestore(&dum->lock, flags); |
1544 | return; | 1705 | return; |
1545 | } | 1706 | } |
1546 | 1707 | ||
1547 | for (i = 0; i < DUMMY_ENDPOINTS; i++) { | 1708 | for (i = 0; i < DUMMY_ENDPOINTS; i++) { |
1548 | if (!ep_name [i]) | 1709 | if (!ep_name[i]) |
1549 | break; | 1710 | break; |
1550 | dum->ep [i].already_seen = 0; | 1711 | dum->ep[i].already_seen = 0; |
1551 | } | 1712 | } |
1552 | 1713 | ||
1553 | restart: | 1714 | restart: |
@@ -1564,7 +1725,7 @@ restart: | |||
1564 | goto return_urb; | 1725 | goto return_urb; |
1565 | else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) | 1726 | else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) |
1566 | continue; | 1727 | continue; |
1567 | type = usb_pipetype (urb->pipe); | 1728 | type = usb_pipetype(urb->pipe); |
1568 | 1729 | ||
1569 | /* used up this frame's non-periodic bandwidth? | 1730 | /* used up this frame's non-periodic bandwidth? |
1570 | * FIXME there's infinite bandwidth for control and | 1731 | * FIXME there's infinite bandwidth for control and |
@@ -1575,7 +1736,7 @@ restart: | |||
1575 | 1736 | ||
1576 | /* find the gadget's ep for this request (if configured) */ | 1737 | /* find the gadget's ep for this request (if configured) */ |
1577 | address = usb_pipeendpoint (urb->pipe); | 1738 | address = usb_pipeendpoint (urb->pipe); |
1578 | if (usb_pipein (urb->pipe)) | 1739 | if (usb_pipein(urb->pipe)) |
1579 | address |= USB_DIR_IN; | 1740 | address |= USB_DIR_IN; |
1580 | ep = find_endpoint(dum, address); | 1741 | ep = find_endpoint(dum, address); |
1581 | if (!ep) { | 1742 | if (!ep) { |
@@ -1590,7 +1751,7 @@ restart: | |||
1590 | if (ep->already_seen) | 1751 | if (ep->already_seen) |
1591 | continue; | 1752 | continue; |
1592 | ep->already_seen = 1; | 1753 | ep->already_seen = 1; |
1593 | if (ep == &dum->ep [0] && urb->error_count) { | 1754 | if (ep == &dum->ep[0] && urb->error_count) { |
1594 | ep->setup_stage = 1; /* a new urb */ | 1755 | ep->setup_stage = 1; /* a new urb */ |
1595 | urb->error_count = 0; | 1756 | urb->error_count = 0; |
1596 | } | 1757 | } |
@@ -1604,21 +1765,21 @@ restart: | |||
1604 | /* FIXME make sure both ends agree on maxpacket */ | 1765 | /* FIXME make sure both ends agree on maxpacket */ |
1605 | 1766 | ||
1606 | /* handle control requests */ | 1767 | /* handle control requests */ |
1607 | if (ep == &dum->ep [0] && ep->setup_stage) { | 1768 | if (ep == &dum->ep[0] && ep->setup_stage) { |
1608 | struct usb_ctrlrequest setup; | 1769 | struct usb_ctrlrequest setup; |
1609 | int value = 1; | 1770 | int value = 1; |
1610 | 1771 | ||
1611 | setup = *(struct usb_ctrlrequest*) urb->setup_packet; | 1772 | setup = *(struct usb_ctrlrequest *) urb->setup_packet; |
1612 | /* paranoia, in case of stale queued data */ | 1773 | /* paranoia, in case of stale queued data */ |
1613 | list_for_each_entry (req, &ep->queue, queue) { | 1774 | list_for_each_entry(req, &ep->queue, queue) { |
1614 | list_del_init (&req->queue); | 1775 | list_del_init(&req->queue); |
1615 | req->req.status = -EOVERFLOW; | 1776 | req->req.status = -EOVERFLOW; |
1616 | dev_dbg (udc_dev(dum), "stale req = %p\n", | 1777 | dev_dbg(udc_dev(dum), "stale req = %p\n", |
1617 | req); | 1778 | req); |
1618 | 1779 | ||
1619 | spin_unlock (&dum->lock); | 1780 | spin_unlock(&dum->lock); |
1620 | req->req.complete (&ep->ep, &req->req); | 1781 | req->req.complete(&ep->ep, &req->req); |
1621 | spin_lock (&dum->lock); | 1782 | spin_lock(&dum->lock); |
1622 | ep->already_seen = 0; | 1783 | ep->already_seen = 0; |
1623 | goto restart; | 1784 | goto restart; |
1624 | } | 1785 | } |
@@ -1638,10 +1799,10 @@ restart: | |||
1638 | * until setup() returns; no reentrancy issues etc. | 1799 | * until setup() returns; no reentrancy issues etc. |
1639 | */ | 1800 | */ |
1640 | if (value > 0) { | 1801 | if (value > 0) { |
1641 | spin_unlock (&dum->lock); | 1802 | spin_unlock(&dum->lock); |
1642 | value = dum->driver->setup (&dum->gadget, | 1803 | value = dum->driver->setup(&dum->gadget, |
1643 | &setup); | 1804 | &setup); |
1644 | spin_lock (&dum->lock); | 1805 | spin_lock(&dum->lock); |
1645 | 1806 | ||
1646 | if (value >= 0) { | 1807 | if (value >= 0) { |
1647 | /* no delays (max 64KB data stage) */ | 1808 | /* no delays (max 64KB data stage) */ |
@@ -1653,7 +1814,7 @@ restart: | |||
1653 | 1814 | ||
1654 | if (value < 0) { | 1815 | if (value < 0) { |
1655 | if (value != -EOPNOTSUPP) | 1816 | if (value != -EOPNOTSUPP) |
1656 | dev_dbg (udc_dev(dum), | 1817 | dev_dbg(udc_dev(dum), |
1657 | "setup --> %d\n", | 1818 | "setup --> %d\n", |
1658 | value); | 1819 | value); |
1659 | status = -EPIPE; | 1820 | status = -EPIPE; |
@@ -1665,14 +1826,14 @@ restart: | |||
1665 | 1826 | ||
1666 | /* non-control requests */ | 1827 | /* non-control requests */ |
1667 | limit = total; | 1828 | limit = total; |
1668 | switch (usb_pipetype (urb->pipe)) { | 1829 | switch (usb_pipetype(urb->pipe)) { |
1669 | case PIPE_ISOCHRONOUS: | 1830 | case PIPE_ISOCHRONOUS: |
1670 | /* FIXME is it urb->interval since the last xfer? | 1831 | /* FIXME is it urb->interval since the last xfer? |
1671 | * use urb->iso_frame_desc[i]. | 1832 | * use urb->iso_frame_desc[i]. |
1672 | * complete whether or not ep has requests queued. | 1833 | * complete whether or not ep has requests queued. |
1673 | * report random errors, to debug drivers. | 1834 | * report random errors, to debug drivers. |
1674 | */ | 1835 | */ |
1675 | limit = max (limit, periodic_bytes (dum, ep)); | 1836 | limit = max(limit, periodic_bytes(dum, ep)); |
1676 | status = -ENOSYS; | 1837 | status = -ENOSYS; |
1677 | break; | 1838 | break; |
1678 | 1839 | ||
@@ -1680,14 +1841,13 @@ restart: | |||
1680 | /* FIXME is it urb->interval since the last xfer? | 1841 | /* FIXME is it urb->interval since the last xfer? |
1681 | * this almost certainly polls too fast. | 1842 | * this almost certainly polls too fast. |
1682 | */ | 1843 | */ |
1683 | limit = max (limit, periodic_bytes (dum, ep)); | 1844 | limit = max(limit, periodic_bytes(dum, ep)); |
1684 | /* FALLTHROUGH */ | 1845 | /* FALLTHROUGH */ |
1685 | 1846 | ||
1686 | // case PIPE_BULK: case PIPE_CONTROL: | ||
1687 | default: | 1847 | default: |
1688 | treat_control_like_bulk: | 1848 | treat_control_like_bulk: |
1689 | ep->last_io = jiffies; | 1849 | ep->last_io = jiffies; |
1690 | total = transfer(dum, urb, ep, limit, &status); | 1850 | total = transfer(dum_hcd, urb, ep, limit, &status); |
1691 | break; | 1851 | break; |
1692 | } | 1852 | } |
1693 | 1853 | ||
@@ -1696,15 +1856,15 @@ restart: | |||
1696 | continue; | 1856 | continue; |
1697 | 1857 | ||
1698 | return_urb: | 1858 | return_urb: |
1699 | list_del (&urbp->urbp_list); | 1859 | list_del(&urbp->urbp_list); |
1700 | kfree (urbp); | 1860 | kfree(urbp); |
1701 | if (ep) | 1861 | if (ep) |
1702 | ep->already_seen = ep->setup_stage = 0; | 1862 | ep->already_seen = ep->setup_stage = 0; |
1703 | 1863 | ||
1704 | usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb); | 1864 | usb_hcd_unlink_urb_from_ep(dummy_hcd_to_hcd(dum_hcd), urb); |
1705 | spin_unlock (&dum->lock); | 1865 | spin_unlock(&dum->lock); |
1706 | usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status); | 1866 | usb_hcd_giveback_urb(dummy_hcd_to_hcd(dum_hcd), urb, status); |
1707 | spin_lock (&dum->lock); | 1867 | spin_lock(&dum->lock); |
1708 | 1868 | ||
1709 | goto restart; | 1869 | goto restart; |
1710 | } | 1870 | } |
@@ -1717,7 +1877,7 @@ return_urb: | |||
1717 | mod_timer(&dum_hcd->timer, jiffies + msecs_to_jiffies(1)); | 1877 | mod_timer(&dum_hcd->timer, jiffies + msecs_to_jiffies(1)); |
1718 | } | 1878 | } |
1719 | 1879 | ||
1720 | spin_unlock_irqrestore (&dum->lock, flags); | 1880 | spin_unlock_irqrestore(&dum->lock, flags); |
1721 | } | 1881 | } |
1722 | 1882 | ||
1723 | /*-------------------------------------------------------------------------*/ | 1883 | /*-------------------------------------------------------------------------*/ |
@@ -1729,7 +1889,7 @@ return_urb: | |||
1729 | | USB_PORT_STAT_C_OVERCURRENT \ | 1889 | | USB_PORT_STAT_C_OVERCURRENT \ |
1730 | | USB_PORT_STAT_C_RESET) << 16) | 1890 | | USB_PORT_STAT_C_RESET) << 16) |
1731 | 1891 | ||
1732 | static int dummy_hub_status (struct usb_hcd *hcd, char *buf) | 1892 | static int dummy_hub_status(struct usb_hcd *hcd, char *buf) |
1733 | { | 1893 | { |
1734 | struct dummy_hcd *dum_hcd; | 1894 | struct dummy_hcd *dum_hcd; |
1735 | unsigned long flags; | 1895 | unsigned long flags; |
@@ -1753,7 +1913,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf) | |||
1753 | dum_hcd->port_status); | 1913 | dum_hcd->port_status); |
1754 | retval = 1; | 1914 | retval = 1; |
1755 | if (dum_hcd->rh_state == DUMMY_RH_SUSPENDED) | 1915 | if (dum_hcd->rh_state == DUMMY_RH_SUSPENDED) |
1756 | usb_hcd_resume_root_hub (hcd); | 1916 | usb_hcd_resume_root_hub(hcd); |
1757 | } | 1917 | } |
1758 | done: | 1918 | done: |
1759 | spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); | 1919 | spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); |
@@ -1772,10 +1932,9 @@ ss_hub_descriptor(struct usb_hub_descriptor *desc) | |||
1772 | desc->u.ss.DeviceRemovable = 0xffff; | 1932 | desc->u.ss.DeviceRemovable = 0xffff; |
1773 | } | 1933 | } |
1774 | 1934 | ||
1775 | static inline void | 1935 | static inline void hub_descriptor(struct usb_hub_descriptor *desc) |
1776 | hub_descriptor (struct usb_hub_descriptor *desc) | ||
1777 | { | 1936 | { |
1778 | memset (desc, 0, sizeof *desc); | 1937 | memset(desc, 0, sizeof *desc); |
1779 | desc->bDescriptorType = 0x29; | 1938 | desc->bDescriptorType = 0x29; |
1780 | desc->bDescLength = 9; | 1939 | desc->bDescLength = 9; |
1781 | desc->wHubCharacteristics = cpu_to_le16(0x0001); | 1940 | desc->wHubCharacteristics = cpu_to_le16(0x0001); |
@@ -1784,7 +1943,7 @@ hub_descriptor (struct usb_hub_descriptor *desc) | |||
1784 | desc->u.hs.DeviceRemovable[1] = 0xff; | 1943 | desc->u.hs.DeviceRemovable[1] = 0xff; |
1785 | } | 1944 | } |
1786 | 1945 | ||
1787 | static int dummy_hub_control ( | 1946 | static int dummy_hub_control( |
1788 | struct usb_hcd *hcd, | 1947 | struct usb_hcd *hcd, |
1789 | u16 typeReq, | 1948 | u16 typeReq, |
1790 | u16 wValue, | 1949 | u16 wValue, |
@@ -1852,7 +2011,7 @@ static int dummy_hub_control ( | |||
1852 | hub_descriptor((struct usb_hub_descriptor *) buf); | 2011 | hub_descriptor((struct usb_hub_descriptor *) buf); |
1853 | break; | 2012 | break; |
1854 | case GetHubStatus: | 2013 | case GetHubStatus: |
1855 | *(__le32 *) buf = cpu_to_le32 (0); | 2014 | *(__le32 *) buf = cpu_to_le32(0); |
1856 | break; | 2015 | break; |
1857 | case GetPortStatus: | 2016 | case GetPortStatus: |
1858 | if (wIndex != 1) | 2017 | if (wIndex != 1) |
@@ -1894,8 +2053,8 @@ static int dummy_hub_control ( | |||
1894 | } | 2053 | } |
1895 | } | 2054 | } |
1896 | set_link_state(dum_hcd); | 2055 | set_link_state(dum_hcd); |
1897 | ((__le16 *) buf)[0] = cpu_to_le16 (dum_hcd->port_status); | 2056 | ((__le16 *) buf)[0] = cpu_to_le16(dum_hcd->port_status); |
1898 | ((__le16 *) buf)[1] = cpu_to_le16 (dum_hcd->port_status >> 16); | 2057 | ((__le16 *) buf)[1] = cpu_to_le16(dum_hcd->port_status >> 16); |
1899 | break; | 2058 | break; |
1900 | case SetHubFeature: | 2059 | case SetHubFeature: |
1901 | retval = -EPIPE; | 2060 | retval = -EPIPE; |
@@ -2029,15 +2188,15 @@ error: | |||
2029 | spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); | 2188 | spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); |
2030 | 2189 | ||
2031 | if ((dum_hcd->port_status & PORT_C_MASK) != 0) | 2190 | if ((dum_hcd->port_status & PORT_C_MASK) != 0) |
2032 | usb_hcd_poll_rh_status (hcd); | 2191 | usb_hcd_poll_rh_status(hcd); |
2033 | return retval; | 2192 | return retval; |
2034 | } | 2193 | } |
2035 | 2194 | ||
2036 | static int dummy_bus_suspend (struct usb_hcd *hcd) | 2195 | static int dummy_bus_suspend(struct usb_hcd *hcd) |
2037 | { | 2196 | { |
2038 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); | 2197 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); |
2039 | 2198 | ||
2040 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); | 2199 | dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); |
2041 | 2200 | ||
2042 | spin_lock_irq(&dum_hcd->dum->lock); | 2201 | spin_lock_irq(&dum_hcd->dum->lock); |
2043 | dum_hcd->rh_state = DUMMY_RH_SUSPENDED; | 2202 | dum_hcd->rh_state = DUMMY_RH_SUSPENDED; |
@@ -2047,12 +2206,12 @@ static int dummy_bus_suspend (struct usb_hcd *hcd) | |||
2047 | return 0; | 2206 | return 0; |
2048 | } | 2207 | } |
2049 | 2208 | ||
2050 | static int dummy_bus_resume (struct usb_hcd *hcd) | 2209 | static int dummy_bus_resume(struct usb_hcd *hcd) |
2051 | { | 2210 | { |
2052 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); | 2211 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); |
2053 | int rc = 0; | 2212 | int rc = 0; |
2054 | 2213 | ||
2055 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); | 2214 | dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); |
2056 | 2215 | ||
2057 | spin_lock_irq(&dum_hcd->dum->lock); | 2216 | spin_lock_irq(&dum_hcd->dum->lock); |
2058 | if (!HCD_HW_ACCESSIBLE(hcd)) { | 2217 | if (!HCD_HW_ACCESSIBLE(hcd)) { |
@@ -2070,55 +2229,54 @@ static int dummy_bus_resume (struct usb_hcd *hcd) | |||
2070 | 2229 | ||
2071 | /*-------------------------------------------------------------------------*/ | 2230 | /*-------------------------------------------------------------------------*/ |
2072 | 2231 | ||
2073 | static inline ssize_t | 2232 | static inline ssize_t show_urb(char *buf, size_t size, struct urb *urb) |
2074 | show_urb (char *buf, size_t size, struct urb *urb) | ||
2075 | { | 2233 | { |
2076 | int ep = usb_pipeendpoint (urb->pipe); | 2234 | int ep = usb_pipeendpoint(urb->pipe); |
2077 | 2235 | ||
2078 | return snprintf (buf, size, | 2236 | return snprintf(buf, size, |
2079 | "urb/%p %s ep%d%s%s len %d/%d\n", | 2237 | "urb/%p %s ep%d%s%s len %d/%d\n", |
2080 | urb, | 2238 | urb, |
2081 | ({ char *s; | 2239 | ({ char *s; |
2082 | switch (urb->dev->speed) { | 2240 | switch (urb->dev->speed) { |
2083 | case USB_SPEED_LOW: | 2241 | case USB_SPEED_LOW: |
2084 | s = "ls"; | 2242 | s = "ls"; |
2085 | break; | 2243 | break; |
2086 | case USB_SPEED_FULL: | 2244 | case USB_SPEED_FULL: |
2087 | s = "fs"; | 2245 | s = "fs"; |
2088 | break; | 2246 | break; |
2089 | case USB_SPEED_HIGH: | 2247 | case USB_SPEED_HIGH: |
2090 | s = "hs"; | 2248 | s = "hs"; |
2091 | break; | 2249 | break; |
2092 | case USB_SPEED_SUPER: | 2250 | case USB_SPEED_SUPER: |
2093 | s = "ss"; | 2251 | s = "ss"; |
2094 | break; | 2252 | break; |
2095 | default: | 2253 | default: |
2096 | s = "?"; | 2254 | s = "?"; |
2097 | break; | 2255 | break; |
2098 | }; s; }), | 2256 | }; s; }), |
2099 | ep, ep ? (usb_pipein (urb->pipe) ? "in" : "out") : "", | 2257 | ep, ep ? (usb_pipein(urb->pipe) ? "in" : "out") : "", |
2100 | ({ char *s; \ | 2258 | ({ char *s; \ |
2101 | switch (usb_pipetype (urb->pipe)) { \ | 2259 | switch (usb_pipetype(urb->pipe)) { \ |
2102 | case PIPE_CONTROL: \ | 2260 | case PIPE_CONTROL: \ |
2103 | s = ""; \ | 2261 | s = ""; \ |
2104 | break; \ | 2262 | break; \ |
2105 | case PIPE_BULK: \ | 2263 | case PIPE_BULK: \ |
2106 | s = "-bulk"; \ | 2264 | s = "-bulk"; \ |
2107 | break; \ | 2265 | break; \ |
2108 | case PIPE_INTERRUPT: \ | 2266 | case PIPE_INTERRUPT: \ |
2109 | s = "-int"; \ | 2267 | s = "-int"; \ |
2110 | break; \ | 2268 | break; \ |
2111 | default: \ | 2269 | default: \ |
2112 | s = "-iso"; \ | 2270 | s = "-iso"; \ |
2113 | break; \ | 2271 | break; \ |
2114 | }; s;}), | 2272 | }; s; }), |
2115 | urb->actual_length, urb->transfer_buffer_length); | 2273 | urb->actual_length, urb->transfer_buffer_length); |
2116 | } | 2274 | } |
2117 | 2275 | ||
2118 | static ssize_t | 2276 | static ssize_t show_urbs(struct device *dev, struct device_attribute *attr, |
2119 | show_urbs (struct device *dev, struct device_attribute *attr, char *buf) | 2277 | char *buf) |
2120 | { | 2278 | { |
2121 | struct usb_hcd *hcd = dev_get_drvdata (dev); | 2279 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
2122 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); | 2280 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); |
2123 | struct urbp *urbp; | 2281 | struct urbp *urbp; |
2124 | size_t size = 0; | 2282 | size_t size = 0; |
@@ -2128,7 +2286,7 @@ show_urbs (struct device *dev, struct device_attribute *attr, char *buf) | |||
2128 | list_for_each_entry(urbp, &dum_hcd->urbp_list, urbp_list) { | 2286 | list_for_each_entry(urbp, &dum_hcd->urbp_list, urbp_list) { |
2129 | size_t temp; | 2287 | size_t temp; |
2130 | 2288 | ||
2131 | temp = show_urb (buf, PAGE_SIZE - size, urbp->urb); | 2289 | temp = show_urb(buf, PAGE_SIZE - size, urbp->urb); |
2132 | buf += temp; | 2290 | buf += temp; |
2133 | size += temp; | 2291 | size += temp; |
2134 | } | 2292 | } |
@@ -2136,7 +2294,7 @@ show_urbs (struct device *dev, struct device_attribute *attr, char *buf) | |||
2136 | 2294 | ||
2137 | return size; | 2295 | return size; |
2138 | } | 2296 | } |
2139 | static DEVICE_ATTR (urbs, S_IRUGO, show_urbs, NULL); | 2297 | static DEVICE_ATTR(urbs, S_IRUGO, show_urbs, NULL); |
2140 | 2298 | ||
2141 | static int dummy_start_ss(struct dummy_hcd *dum_hcd) | 2299 | static int dummy_start_ss(struct dummy_hcd *dum_hcd) |
2142 | { | 2300 | { |
@@ -2144,6 +2302,7 @@ static int dummy_start_ss(struct dummy_hcd *dum_hcd) | |||
2144 | dum_hcd->timer.function = dummy_timer; | 2302 | dum_hcd->timer.function = dummy_timer; |
2145 | dum_hcd->timer.data = (unsigned long)dum_hcd; | 2303 | dum_hcd->timer.data = (unsigned long)dum_hcd; |
2146 | dum_hcd->rh_state = DUMMY_RH_RUNNING; | 2304 | dum_hcd->rh_state = DUMMY_RH_RUNNING; |
2305 | dum_hcd->stream_en_ep = 0; | ||
2147 | INIT_LIST_HEAD(&dum_hcd->urbp_list); | 2306 | INIT_LIST_HEAD(&dum_hcd->urbp_list); |
2148 | dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET; | 2307 | dummy_hcd_to_hcd(dum_hcd)->power_budget = POWER_BUDGET; |
2149 | dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING; | 2308 | dummy_hcd_to_hcd(dum_hcd)->state = HC_STATE_RUNNING; |
@@ -2189,11 +2348,11 @@ static int dummy_start(struct usb_hcd *hcd) | |||
2189 | return device_create_file(dummy_dev(dum_hcd), &dev_attr_urbs); | 2348 | return device_create_file(dummy_dev(dum_hcd), &dev_attr_urbs); |
2190 | } | 2349 | } |
2191 | 2350 | ||
2192 | static void dummy_stop (struct usb_hcd *hcd) | 2351 | static void dummy_stop(struct usb_hcd *hcd) |
2193 | { | 2352 | { |
2194 | struct dummy *dum; | 2353 | struct dummy *dum; |
2195 | 2354 | ||
2196 | dum = (hcd_to_dummy_hcd(hcd))->dum; | 2355 | dum = hcd_to_dummy_hcd(hcd)->dum; |
2197 | device_remove_file(dummy_dev(hcd_to_dummy_hcd(hcd)), &dev_attr_urbs); | 2356 | device_remove_file(dummy_dev(hcd_to_dummy_hcd(hcd)), &dev_attr_urbs); |
2198 | usb_gadget_unregister_driver(dum->driver); | 2357 | usb_gadget_unregister_driver(dum->driver); |
2199 | dev_info(dummy_dev(hcd_to_dummy_hcd(hcd)), "stopped\n"); | 2358 | dev_info(dummy_dev(hcd_to_dummy_hcd(hcd)), "stopped\n"); |
@@ -2201,13 +2360,14 @@ static void dummy_stop (struct usb_hcd *hcd) | |||
2201 | 2360 | ||
2202 | /*-------------------------------------------------------------------------*/ | 2361 | /*-------------------------------------------------------------------------*/ |
2203 | 2362 | ||
2204 | static int dummy_h_get_frame (struct usb_hcd *hcd) | 2363 | static int dummy_h_get_frame(struct usb_hcd *hcd) |
2205 | { | 2364 | { |
2206 | return dummy_g_get_frame (NULL); | 2365 | return dummy_g_get_frame(NULL); |
2207 | } | 2366 | } |
2208 | 2367 | ||
2209 | static int dummy_setup(struct usb_hcd *hcd) | 2368 | static int dummy_setup(struct usb_hcd *hcd) |
2210 | { | 2369 | { |
2370 | hcd->self.sg_tablesize = ~0; | ||
2211 | if (usb_hcd_is_primary_hcd(hcd)) { | 2371 | if (usb_hcd_is_primary_hcd(hcd)) { |
2212 | the_controller.hs_hcd = hcd_to_dummy_hcd(hcd); | 2372 | the_controller.hs_hcd = hcd_to_dummy_hcd(hcd); |
2213 | the_controller.hs_hcd->dum = &the_controller; | 2373 | the_controller.hs_hcd->dum = &the_controller; |
@@ -2228,27 +2388,82 @@ static int dummy_setup(struct usb_hcd *hcd) | |||
2228 | } | 2388 | } |
2229 | 2389 | ||
2230 | /* Change a group of bulk endpoints to support multiple stream IDs */ | 2390 | /* Change a group of bulk endpoints to support multiple stream IDs */ |
2231 | int dummy_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev, | 2391 | static int dummy_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev, |
2232 | struct usb_host_endpoint **eps, unsigned int num_eps, | 2392 | struct usb_host_endpoint **eps, unsigned int num_eps, |
2233 | unsigned int num_streams, gfp_t mem_flags) | 2393 | unsigned int num_streams, gfp_t mem_flags) |
2234 | { | 2394 | { |
2235 | if (hcd->speed != HCD_USB3) | 2395 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); |
2236 | dev_dbg(dummy_dev(hcd_to_dummy_hcd(hcd)), | 2396 | unsigned long flags; |
2237 | "%s() - ERROR! Not supported for USB2.0 roothub\n", | 2397 | int max_stream; |
2238 | __func__); | 2398 | int ret_streams = num_streams; |
2239 | return 0; | 2399 | unsigned int index; |
2400 | unsigned int i; | ||
2401 | |||
2402 | if (!num_eps) | ||
2403 | return -EINVAL; | ||
2404 | |||
2405 | spin_lock_irqsave(&dum_hcd->dum->lock, flags); | ||
2406 | for (i = 0; i < num_eps; i++) { | ||
2407 | index = dummy_get_ep_idx(&eps[i]->desc); | ||
2408 | if ((1 << index) & dum_hcd->stream_en_ep) { | ||
2409 | ret_streams = -EINVAL; | ||
2410 | goto out; | ||
2411 | } | ||
2412 | max_stream = usb_ss_max_streams(&eps[i]->ss_ep_comp); | ||
2413 | if (!max_stream) { | ||
2414 | ret_streams = -EINVAL; | ||
2415 | goto out; | ||
2416 | } | ||
2417 | if (max_stream < ret_streams) { | ||
2418 | dev_dbg(dummy_dev(dum_hcd), "Ep 0x%x only supports %u " | ||
2419 | "stream IDs.\n", | ||
2420 | eps[i]->desc.bEndpointAddress, | ||
2421 | max_stream); | ||
2422 | ret_streams = max_stream; | ||
2423 | } | ||
2424 | } | ||
2425 | |||
2426 | for (i = 0; i < num_eps; i++) { | ||
2427 | index = dummy_get_ep_idx(&eps[i]->desc); | ||
2428 | dum_hcd->stream_en_ep |= 1 << index; | ||
2429 | set_max_streams_for_pipe(dum_hcd, | ||
2430 | usb_endpoint_num(&eps[i]->desc), ret_streams); | ||
2431 | } | ||
2432 | out: | ||
2433 | spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); | ||
2434 | return ret_streams; | ||
2240 | } | 2435 | } |
2241 | 2436 | ||
2242 | /* Reverts a group of bulk endpoints back to not using stream IDs. */ | 2437 | /* Reverts a group of bulk endpoints back to not using stream IDs. */ |
2243 | int dummy_free_streams(struct usb_hcd *hcd, struct usb_device *udev, | 2438 | static int dummy_free_streams(struct usb_hcd *hcd, struct usb_device *udev, |
2244 | struct usb_host_endpoint **eps, unsigned int num_eps, | 2439 | struct usb_host_endpoint **eps, unsigned int num_eps, |
2245 | gfp_t mem_flags) | 2440 | gfp_t mem_flags) |
2246 | { | 2441 | { |
2247 | if (hcd->speed != HCD_USB3) | 2442 | struct dummy_hcd *dum_hcd = hcd_to_dummy_hcd(hcd); |
2248 | dev_dbg(dummy_dev(hcd_to_dummy_hcd(hcd)), | 2443 | unsigned long flags; |
2249 | "%s() - ERROR! Not supported for USB2.0 roothub\n", | 2444 | int ret; |
2250 | __func__); | 2445 | unsigned int index; |
2251 | return 0; | 2446 | unsigned int i; |
2447 | |||
2448 | spin_lock_irqsave(&dum_hcd->dum->lock, flags); | ||
2449 | for (i = 0; i < num_eps; i++) { | ||
2450 | index = dummy_get_ep_idx(&eps[i]->desc); | ||
2451 | if (!((1 << index) & dum_hcd->stream_en_ep)) { | ||
2452 | ret = -EINVAL; | ||
2453 | goto out; | ||
2454 | } | ||
2455 | } | ||
2456 | |||
2457 | for (i = 0; i < num_eps; i++) { | ||
2458 | index = dummy_get_ep_idx(&eps[i]->desc); | ||
2459 | dum_hcd->stream_en_ep &= ~(1 << index); | ||
2460 | set_max_streams_for_pipe(dum_hcd, | ||
2461 | usb_endpoint_num(&eps[i]->desc), 0); | ||
2462 | } | ||
2463 | ret = 0; | ||
2464 | out: | ||
2465 | spin_unlock_irqrestore(&dum_hcd->dum->lock, flags); | ||
2466 | return ret; | ||
2252 | } | 2467 | } |
2253 | 2468 | ||
2254 | static struct hc_driver dummy_hcd = { | 2469 | static struct hc_driver dummy_hcd = { |
@@ -2262,13 +2477,13 @@ static struct hc_driver dummy_hcd = { | |||
2262 | .start = dummy_start, | 2477 | .start = dummy_start, |
2263 | .stop = dummy_stop, | 2478 | .stop = dummy_stop, |
2264 | 2479 | ||
2265 | .urb_enqueue = dummy_urb_enqueue, | 2480 | .urb_enqueue = dummy_urb_enqueue, |
2266 | .urb_dequeue = dummy_urb_dequeue, | 2481 | .urb_dequeue = dummy_urb_dequeue, |
2267 | 2482 | ||
2268 | .get_frame_number = dummy_h_get_frame, | 2483 | .get_frame_number = dummy_h_get_frame, |
2269 | 2484 | ||
2270 | .hub_status_data = dummy_hub_status, | 2485 | .hub_status_data = dummy_hub_status, |
2271 | .hub_control = dummy_hub_control, | 2486 | .hub_control = dummy_hub_control, |
2272 | .bus_suspend = dummy_bus_suspend, | 2487 | .bus_suspend = dummy_bus_suspend, |
2273 | .bus_resume = dummy_bus_resume, | 2488 | .bus_resume = dummy_bus_resume, |
2274 | 2489 | ||
@@ -2323,7 +2538,7 @@ static int dummy_hcd_remove(struct platform_device *pdev) | |||
2323 | { | 2538 | { |
2324 | struct dummy *dum; | 2539 | struct dummy *dum; |
2325 | 2540 | ||
2326 | dum = (hcd_to_dummy_hcd(platform_get_drvdata(pdev)))->dum; | 2541 | dum = hcd_to_dummy_hcd(platform_get_drvdata(pdev))->dum; |
2327 | 2542 | ||
2328 | if (dum->ss_hcd) { | 2543 | if (dum->ss_hcd) { |
2329 | usb_remove_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); | 2544 | usb_remove_hcd(dummy_hcd_to_hcd(dum->ss_hcd)); |
@@ -2339,15 +2554,15 @@ static int dummy_hcd_remove(struct platform_device *pdev) | |||
2339 | return 0; | 2554 | return 0; |
2340 | } | 2555 | } |
2341 | 2556 | ||
2342 | static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) | 2557 | static int dummy_hcd_suspend(struct platform_device *pdev, pm_message_t state) |
2343 | { | 2558 | { |
2344 | struct usb_hcd *hcd; | 2559 | struct usb_hcd *hcd; |
2345 | struct dummy_hcd *dum_hcd; | 2560 | struct dummy_hcd *dum_hcd; |
2346 | int rc = 0; | 2561 | int rc = 0; |
2347 | 2562 | ||
2348 | dev_dbg (&pdev->dev, "%s\n", __func__); | 2563 | dev_dbg(&pdev->dev, "%s\n", __func__); |
2349 | 2564 | ||
2350 | hcd = platform_get_drvdata (pdev); | 2565 | hcd = platform_get_drvdata(pdev); |
2351 | dum_hcd = hcd_to_dummy_hcd(hcd); | 2566 | dum_hcd = hcd_to_dummy_hcd(hcd); |
2352 | if (dum_hcd->rh_state == DUMMY_RH_RUNNING) { | 2567 | if (dum_hcd->rh_state == DUMMY_RH_RUNNING) { |
2353 | dev_warn(&pdev->dev, "Root hub isn't suspended!\n"); | 2568 | dev_warn(&pdev->dev, "Root hub isn't suspended!\n"); |
@@ -2357,15 +2572,15 @@ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) | |||
2357 | return rc; | 2572 | return rc; |
2358 | } | 2573 | } |
2359 | 2574 | ||
2360 | static int dummy_hcd_resume (struct platform_device *pdev) | 2575 | static int dummy_hcd_resume(struct platform_device *pdev) |
2361 | { | 2576 | { |
2362 | struct usb_hcd *hcd; | 2577 | struct usb_hcd *hcd; |
2363 | 2578 | ||
2364 | dev_dbg (&pdev->dev, "%s\n", __func__); | 2579 | dev_dbg(&pdev->dev, "%s\n", __func__); |
2365 | 2580 | ||
2366 | hcd = platform_get_drvdata (pdev); | 2581 | hcd = platform_get_drvdata(pdev); |
2367 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 2582 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
2368 | usb_hcd_poll_rh_status (hcd); | 2583 | usb_hcd_poll_rh_status(hcd); |
2369 | return 0; | 2584 | return 0; |
2370 | } | 2585 | } |
2371 | 2586 | ||
@@ -2385,11 +2600,11 @@ static struct platform_driver dummy_hcd_driver = { | |||
2385 | static struct platform_device *the_udc_pdev; | 2600 | static struct platform_device *the_udc_pdev; |
2386 | static struct platform_device *the_hcd_pdev; | 2601 | static struct platform_device *the_hcd_pdev; |
2387 | 2602 | ||
2388 | static int __init init (void) | 2603 | static int __init init(void) |
2389 | { | 2604 | { |
2390 | int retval = -ENOMEM; | 2605 | int retval = -ENOMEM; |
2391 | 2606 | ||
2392 | if (usb_disabled ()) | 2607 | if (usb_disabled()) |
2393 | return -ENODEV; | 2608 | return -ENODEV; |
2394 | 2609 | ||
2395 | if (!mod_data.is_high_speed && mod_data.is_super_speed) | 2610 | if (!mod_data.is_high_speed && mod_data.is_super_speed) |
@@ -2448,13 +2663,13 @@ err_alloc_udc: | |||
2448 | platform_device_put(the_hcd_pdev); | 2663 | platform_device_put(the_hcd_pdev); |
2449 | return retval; | 2664 | return retval; |
2450 | } | 2665 | } |
2451 | module_init (init); | 2666 | module_init(init); |
2452 | 2667 | ||
2453 | static void __exit cleanup (void) | 2668 | static void __exit cleanup(void) |
2454 | { | 2669 | { |
2455 | platform_device_unregister(the_udc_pdev); | 2670 | platform_device_unregister(the_udc_pdev); |
2456 | platform_device_unregister(the_hcd_pdev); | 2671 | platform_device_unregister(the_hcd_pdev); |
2457 | platform_driver_unregister(&dummy_udc_driver); | 2672 | platform_driver_unregister(&dummy_udc_driver); |
2458 | platform_driver_unregister(&dummy_hcd_driver); | 2673 | platform_driver_unregister(&dummy_hcd_driver); |
2459 | } | 2674 | } |
2460 | module_exit (cleanup); | 2675 | module_exit(cleanup); |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index e0e6375ef5dd..51f3d42f5a64 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c | |||
@@ -275,24 +275,24 @@ struct usb_ep *usb_ep_autoconfig_ss( | |||
275 | /* ep-e, ep-f are PIO with only 64 byte fifos */ | 275 | /* ep-e, ep-f are PIO with only 64 byte fifos */ |
276 | ep = find_ep (gadget, "ep-e"); | 276 | ep = find_ep (gadget, "ep-e"); |
277 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | 277 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) |
278 | return ep; | 278 | goto found_ep; |
279 | ep = find_ep (gadget, "ep-f"); | 279 | ep = find_ep (gadget, "ep-f"); |
280 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | 280 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) |
281 | return ep; | 281 | goto found_ep; |
282 | 282 | ||
283 | } else if (gadget_is_goku (gadget)) { | 283 | } else if (gadget_is_goku (gadget)) { |
284 | if (USB_ENDPOINT_XFER_INT == type) { | 284 | if (USB_ENDPOINT_XFER_INT == type) { |
285 | /* single buffering is enough */ | 285 | /* single buffering is enough */ |
286 | ep = find_ep(gadget, "ep3-bulk"); | 286 | ep = find_ep(gadget, "ep3-bulk"); |
287 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | 287 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) |
288 | return ep; | 288 | goto found_ep; |
289 | } else if (USB_ENDPOINT_XFER_BULK == type | 289 | } else if (USB_ENDPOINT_XFER_BULK == type |
290 | && (USB_DIR_IN & desc->bEndpointAddress)) { | 290 | && (USB_DIR_IN & desc->bEndpointAddress)) { |
291 | /* DMA may be available */ | 291 | /* DMA may be available */ |
292 | ep = find_ep(gadget, "ep2-bulk"); | 292 | ep = find_ep(gadget, "ep2-bulk"); |
293 | if (ep && ep_matches(gadget, ep, desc, | 293 | if (ep && ep_matches(gadget, ep, desc, |
294 | ep_comp)) | 294 | ep_comp)) |
295 | return ep; | 295 | goto found_ep; |
296 | } | 296 | } |
297 | 297 | ||
298 | #ifdef CONFIG_BLACKFIN | 298 | #ifdef CONFIG_BLACKFIN |
@@ -311,18 +311,22 @@ struct usb_ep *usb_ep_autoconfig_ss( | |||
311 | } else | 311 | } else |
312 | ep = NULL; | 312 | ep = NULL; |
313 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) | 313 | if (ep && ep_matches(gadget, ep, desc, ep_comp)) |
314 | return ep; | 314 | goto found_ep; |
315 | #endif | 315 | #endif |
316 | } | 316 | } |
317 | 317 | ||
318 | /* Second, look at endpoints until an unclaimed one looks usable */ | 318 | /* Second, look at endpoints until an unclaimed one looks usable */ |
319 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { | 319 | list_for_each_entry (ep, &gadget->ep_list, ep_list) { |
320 | if (ep_matches(gadget, ep, desc, ep_comp)) | 320 | if (ep_matches(gadget, ep, desc, ep_comp)) |
321 | return ep; | 321 | goto found_ep; |
322 | } | 322 | } |
323 | 323 | ||
324 | /* Fail */ | 324 | /* Fail */ |
325 | return NULL; | 325 | return NULL; |
326 | found_ep: | ||
327 | ep->desc = NULL; | ||
328 | ep->comp_desc = NULL; | ||
329 | return ep; | ||
326 | } | 330 | } |
327 | 331 | ||
328 | /** | 332 | /** |
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c index 3f8849339ade..d672250a61fa 100644 --- a/drivers/usb/gadget/f_acm.c +++ b/drivers/usb/gadget/f_acm.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (C) 2008 by David Brownell | 5 | * Copyright (C) 2008 by David Brownell |
6 | * Copyright (C) 2008 by Nokia Corporation | 6 | * Copyright (C) 2008 by Nokia Corporation |
7 | * Copyright (C) 2009 by Samsung Electronics | 7 | * Copyright (C) 2009 by Samsung Electronics |
8 | * Author: Michal Nazarewicz (m.nazarewicz@samsung.com) | 8 | * Author: Michal Nazarewicz (mina86@mina86.com) |
9 | * | 9 | * |
10 | * This software is distributed under the terms of the GNU General | 10 | * This software is distributed under the terms of the GNU General |
11 | * Public License ("GPL") as published by the Free Software Foundation, | 11 | * Public License ("GPL") as published by the Free Software Foundation, |
@@ -237,6 +237,42 @@ static struct usb_descriptor_header *acm_hs_function[] = { | |||
237 | NULL, | 237 | NULL, |
238 | }; | 238 | }; |
239 | 239 | ||
240 | static struct usb_endpoint_descriptor acm_ss_in_desc = { | ||
241 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
242 | .bDescriptorType = USB_DT_ENDPOINT, | ||
243 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
244 | .wMaxPacketSize = cpu_to_le16(1024), | ||
245 | }; | ||
246 | |||
247 | static struct usb_endpoint_descriptor acm_ss_out_desc = { | ||
248 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
249 | .bDescriptorType = USB_DT_ENDPOINT, | ||
250 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
251 | .wMaxPacketSize = cpu_to_le16(1024), | ||
252 | }; | ||
253 | |||
254 | static struct usb_ss_ep_comp_descriptor acm_ss_bulk_comp_desc = { | ||
255 | .bLength = sizeof acm_ss_bulk_comp_desc, | ||
256 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, | ||
257 | }; | ||
258 | |||
259 | static struct usb_descriptor_header *acm_ss_function[] = { | ||
260 | (struct usb_descriptor_header *) &acm_iad_descriptor, | ||
261 | (struct usb_descriptor_header *) &acm_control_interface_desc, | ||
262 | (struct usb_descriptor_header *) &acm_header_desc, | ||
263 | (struct usb_descriptor_header *) &acm_call_mgmt_descriptor, | ||
264 | (struct usb_descriptor_header *) &acm_descriptor, | ||
265 | (struct usb_descriptor_header *) &acm_union_desc, | ||
266 | (struct usb_descriptor_header *) &acm_hs_notify_desc, | ||
267 | (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, | ||
268 | (struct usb_descriptor_header *) &acm_data_interface_desc, | ||
269 | (struct usb_descriptor_header *) &acm_ss_in_desc, | ||
270 | (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, | ||
271 | (struct usb_descriptor_header *) &acm_ss_out_desc, | ||
272 | (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, | ||
273 | NULL, | ||
274 | }; | ||
275 | |||
240 | /* string descriptors: */ | 276 | /* string descriptors: */ |
241 | 277 | ||
242 | #define ACM_CTRL_IDX 0 | 278 | #define ACM_CTRL_IDX 0 |
@@ -643,9 +679,21 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) | |||
643 | /* copy descriptors */ | 679 | /* copy descriptors */ |
644 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); | 680 | f->hs_descriptors = usb_copy_descriptors(acm_hs_function); |
645 | } | 681 | } |
682 | if (gadget_is_superspeed(c->cdev->gadget)) { | ||
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 | } | ||
646 | 693 | ||
647 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", | 694 | DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", |
648 | acm->port_num, | 695 | acm->port_num, |
696 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | ||
649 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", | 697 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", |
650 | acm->port.in->name, acm->port.out->name, | 698 | acm->port.in->name, acm->port.out->name, |
651 | acm->notify->name); | 699 | acm->notify->name); |
@@ -675,6 +723,8 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f) | |||
675 | 723 | ||
676 | if (gadget_is_dualspeed(c->cdev->gadget)) | 724 | if (gadget_is_dualspeed(c->cdev->gadget)) |
677 | usb_free_descriptors(f->hs_descriptors); | 725 | usb_free_descriptors(f->hs_descriptors); |
726 | if (gadget_is_superspeed(c->cdev->gadget)) | ||
727 | usb_free_descriptors(f->ss_descriptors); | ||
678 | usb_free_descriptors(f->descriptors); | 728 | usb_free_descriptors(f->descriptors); |
679 | gs_free_req(acm->notify, acm->notify_req); | 729 | gs_free_req(acm->notify, acm->notify_req); |
680 | kfree(acm); | 730 | kfree(acm); |
diff --git a/drivers/usb/gadget/f_ecm.c b/drivers/usb/gadget/f_ecm.c index 11c07cb7d337..30b908f2a53d 100644 --- a/drivers/usb/gadget/f_ecm.c +++ b/drivers/usb/gadget/f_ecm.c | |||
@@ -97,6 +97,20 @@ static inline unsigned ecm_bitrate(struct usb_gadget *g) | |||
97 | 97 | ||
98 | /* interface descriptor: */ | 98 | /* interface descriptor: */ |
99 | 99 | ||
100 | static struct usb_interface_assoc_descriptor | ||
101 | ecm_iad_descriptor = { | ||
102 | .bLength = sizeof ecm_iad_descriptor, | ||
103 | .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, | ||
104 | |||
105 | /* .bFirstInterface = DYNAMIC, */ | ||
106 | .bInterfaceCount = 2, /* control + data */ | ||
107 | .bFunctionClass = USB_CLASS_COMM, | ||
108 | .bFunctionSubClass = USB_CDC_SUBCLASS_ETHERNET, | ||
109 | .bFunctionProtocol = USB_CDC_PROTO_NONE, | ||
110 | /* .iFunction = DYNAMIC */ | ||
111 | }; | ||
112 | |||
113 | |||
100 | static struct usb_interface_descriptor ecm_control_intf = { | 114 | static struct usb_interface_descriptor ecm_control_intf = { |
101 | .bLength = sizeof ecm_control_intf, | 115 | .bLength = sizeof ecm_control_intf, |
102 | .bDescriptorType = USB_DT_INTERFACE, | 116 | .bDescriptorType = USB_DT_INTERFACE, |
@@ -199,6 +213,7 @@ static struct usb_endpoint_descriptor fs_ecm_out_desc = { | |||
199 | 213 | ||
200 | static struct usb_descriptor_header *ecm_fs_function[] = { | 214 | static struct usb_descriptor_header *ecm_fs_function[] = { |
201 | /* CDC ECM control descriptors */ | 215 | /* CDC ECM control descriptors */ |
216 | (struct usb_descriptor_header *) &ecm_iad_descriptor, | ||
202 | (struct usb_descriptor_header *) &ecm_control_intf, | 217 | (struct usb_descriptor_header *) &ecm_control_intf, |
203 | (struct usb_descriptor_header *) &ecm_header_desc, | 218 | (struct usb_descriptor_header *) &ecm_header_desc, |
204 | (struct usb_descriptor_header *) &ecm_union_desc, | 219 | (struct usb_descriptor_header *) &ecm_union_desc, |
@@ -247,6 +262,7 @@ static struct usb_endpoint_descriptor hs_ecm_out_desc = { | |||
247 | 262 | ||
248 | static struct usb_descriptor_header *ecm_hs_function[] = { | 263 | static struct usb_descriptor_header *ecm_hs_function[] = { |
249 | /* CDC ECM control descriptors */ | 264 | /* CDC ECM control descriptors */ |
265 | (struct usb_descriptor_header *) &ecm_iad_descriptor, | ||
250 | (struct usb_descriptor_header *) &ecm_control_intf, | 266 | (struct usb_descriptor_header *) &ecm_control_intf, |
251 | (struct usb_descriptor_header *) &ecm_header_desc, | 267 | (struct usb_descriptor_header *) &ecm_header_desc, |
252 | (struct usb_descriptor_header *) &ecm_union_desc, | 268 | (struct usb_descriptor_header *) &ecm_union_desc, |
@@ -339,6 +355,7 @@ static struct usb_string ecm_string_defs[] = { | |||
339 | [0].s = "CDC Ethernet Control Model (ECM)", | 355 | [0].s = "CDC Ethernet Control Model (ECM)", |
340 | [1].s = NULL /* DYNAMIC */, | 356 | [1].s = NULL /* DYNAMIC */, |
341 | [2].s = "CDC Ethernet Data", | 357 | [2].s = "CDC Ethernet Data", |
358 | [3].s = "CDC ECM", | ||
342 | { } /* end of list */ | 359 | { } /* end of list */ |
343 | }; | 360 | }; |
344 | 361 | ||
@@ -674,6 +691,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) | |||
674 | if (status < 0) | 691 | if (status < 0) |
675 | goto fail; | 692 | goto fail; |
676 | ecm->ctrl_id = status; | 693 | ecm->ctrl_id = status; |
694 | ecm_iad_descriptor.bFirstInterface = status; | ||
677 | 695 | ||
678 | ecm_control_intf.bInterfaceNumber = status; | 696 | ecm_control_intf.bInterfaceNumber = status; |
679 | ecm_union_desc.bMasterInterface0 = status; | 697 | ecm_union_desc.bMasterInterface0 = status; |
@@ -864,6 +882,13 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | |||
864 | return status; | 882 | return status; |
865 | ecm_string_defs[1].id = status; | 883 | ecm_string_defs[1].id = status; |
866 | ecm_desc.iMACAddress = 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; | ||
867 | } | 892 | } |
868 | 893 | ||
869 | /* allocate and initialize one new instance */ | 894 | /* allocate and initialize one new instance */ |
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index f63dc6c150d2..7f445ec723bc 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * f_fs.c -- user mode file system API for USB composite function controllers | 2 | * f_fs.c -- user mode file system API for USB composite function controllers |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Samsung Electronics | 4 | * Copyright (C) 2010 Samsung Electronics |
5 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 5 | * Author: Michal Nazarewicz <mina86@mina86.com> |
6 | * | 6 | * |
7 | * Based on inode.c (GadgetFS) which was: | 7 | * Based on inode.c (GadgetFS) which was: |
8 | * Copyright (C) 2003-2004 David Brownell | 8 | * Copyright (C) 2003-2004 David Brownell |
@@ -1258,9 +1258,7 @@ static void ffs_data_put(struct ffs_data *ffs) | |||
1258 | if (unlikely(atomic_dec_and_test(&ffs->ref))) { | 1258 | if (unlikely(atomic_dec_and_test(&ffs->ref))) { |
1259 | pr_info("%s(): freeing\n", __func__); | 1259 | pr_info("%s(): freeing\n", __func__); |
1260 | ffs_data_clear(ffs); | 1260 | ffs_data_clear(ffs); |
1261 | BUG_ON(mutex_is_locked(&ffs->mutex) || | 1261 | BUG_ON(waitqueue_active(&ffs->ev.waitq) || |
1262 | spin_is_locked(&ffs->ev.waitq.lock) || | ||
1263 | waitqueue_active(&ffs->ev.waitq) || | ||
1264 | waitqueue_active(&ffs->ep0req_completion.wait)); | 1262 | waitqueue_active(&ffs->ep0req_completion.wait)); |
1265 | kfree(ffs); | 1263 | kfree(ffs); |
1266 | } | 1264 | } |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index ee8ceec01560..a371e966425f 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2003-2008 Alan Stern | 4 | * Copyright (C) 2003-2008 Alan Stern |
5 | * Copyright (C) 2009 Samsung Electronics | 5 | * Copyright (C) 2009 Samsung Electronics |
6 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 6 | * Author: Michal Nazarewicz <mina86@mina86.com> |
7 | * All rights reserved. | 7 | * All rights reserved. |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without |
@@ -304,7 +304,6 @@ | |||
304 | 304 | ||
305 | static const char fsg_string_interface[] = "Mass Storage"; | 305 | static const char fsg_string_interface[] = "Mass Storage"; |
306 | 306 | ||
307 | #define FSG_NO_INTR_EP 1 | ||
308 | #define FSG_NO_DEVICE_STRINGS 1 | 307 | #define FSG_NO_DEVICE_STRINGS 1 |
309 | #define FSG_NO_OTG 1 | 308 | #define FSG_NO_OTG 1 |
310 | #define FSG_NO_INTR_EP 1 | 309 | #define FSG_NO_INTR_EP 1 |
@@ -620,7 +619,7 @@ static int fsg_setup(struct usb_function *f, | |||
620 | 619 | ||
621 | switch (ctrl->bRequest) { | 620 | switch (ctrl->bRequest) { |
622 | 621 | ||
623 | case USB_BULK_RESET_REQUEST: | 622 | case US_BULK_RESET_REQUEST: |
624 | if (ctrl->bRequestType != | 623 | if (ctrl->bRequestType != |
625 | (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 624 | (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
626 | break; | 625 | break; |
@@ -636,7 +635,7 @@ static int fsg_setup(struct usb_function *f, | |||
636 | raise_exception(fsg->common, FSG_STATE_RESET); | 635 | raise_exception(fsg->common, FSG_STATE_RESET); |
637 | return DELAYED_STATUS; | 636 | return DELAYED_STATUS; |
638 | 637 | ||
639 | case USB_BULK_GET_MAX_LUN_REQUEST: | 638 | case US_BULK_GET_MAX_LUN: |
640 | if (ctrl->bRequestType != | 639 | if (ctrl->bRequestType != |
641 | (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 640 | (USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
642 | break; | 641 | break; |
@@ -1742,7 +1741,7 @@ static int send_status(struct fsg_common *common) | |||
1742 | struct fsg_buffhd *bh; | 1741 | struct fsg_buffhd *bh; |
1743 | struct bulk_cs_wrap *csw; | 1742 | struct bulk_cs_wrap *csw; |
1744 | int rc; | 1743 | int rc; |
1745 | u8 status = USB_STATUS_PASS; | 1744 | u8 status = US_BULK_STAT_OK; |
1746 | u32 sd, sdinfo = 0; | 1745 | u32 sd, sdinfo = 0; |
1747 | 1746 | ||
1748 | /* Wait for the next buffer to become available */ | 1747 | /* Wait for the next buffer to become available */ |
@@ -1763,11 +1762,11 @@ static int send_status(struct fsg_common *common) | |||
1763 | 1762 | ||
1764 | if (common->phase_error) { | 1763 | if (common->phase_error) { |
1765 | DBG(common, "sending phase-error status\n"); | 1764 | DBG(common, "sending phase-error status\n"); |
1766 | status = USB_STATUS_PHASE_ERROR; | 1765 | status = US_BULK_STAT_PHASE; |
1767 | sd = SS_INVALID_COMMAND; | 1766 | sd = SS_INVALID_COMMAND; |
1768 | } else if (sd != SS_NO_SENSE) { | 1767 | } else if (sd != SS_NO_SENSE) { |
1769 | DBG(common, "sending command-failure status\n"); | 1768 | DBG(common, "sending command-failure status\n"); |
1770 | status = USB_STATUS_FAIL; | 1769 | status = US_BULK_STAT_FAIL; |
1771 | VDBG(common, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" | 1770 | VDBG(common, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" |
1772 | " info x%x\n", | 1771 | " info x%x\n", |
1773 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); | 1772 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); |
@@ -1776,12 +1775,12 @@ static int send_status(struct fsg_common *common) | |||
1776 | /* Store and send the Bulk-only CSW */ | 1775 | /* Store and send the Bulk-only CSW */ |
1777 | csw = (void *)bh->buf; | 1776 | csw = (void *)bh->buf; |
1778 | 1777 | ||
1779 | csw->Signature = cpu_to_le32(USB_BULK_CS_SIG); | 1778 | csw->Signature = cpu_to_le32(US_BULK_CS_SIGN); |
1780 | csw->Tag = common->tag; | 1779 | csw->Tag = common->tag; |
1781 | csw->Residue = cpu_to_le32(common->residue); | 1780 | csw->Residue = cpu_to_le32(common->residue); |
1782 | csw->Status = status; | 1781 | csw->Status = status; |
1783 | 1782 | ||
1784 | bh->inreq->length = USB_BULK_CS_WRAP_LEN; | 1783 | bh->inreq->length = US_BULK_CS_WRAP_LEN; |
1785 | bh->inreq->zero = 0; | 1784 | bh->inreq->zero = 0; |
1786 | if (!start_in_transfer(common, bh)) | 1785 | if (!start_in_transfer(common, bh)) |
1787 | /* Don't know what to do if common->fsg is NULL */ | 1786 | /* Don't know what to do if common->fsg is NULL */ |
@@ -2221,7 +2220,7 @@ unknown_cmnd: | |||
2221 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | 2220 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) |
2222 | { | 2221 | { |
2223 | struct usb_request *req = bh->outreq; | 2222 | struct usb_request *req = bh->outreq; |
2224 | struct fsg_bulk_cb_wrap *cbw = req->buf; | 2223 | struct bulk_cb_wrap *cbw = req->buf; |
2225 | struct fsg_common *common = fsg->common; | 2224 | struct fsg_common *common = fsg->common; |
2226 | 2225 | ||
2227 | /* Was this a real packet? Should it be ignored? */ | 2226 | /* Was this a real packet? Should it be ignored? */ |
@@ -2229,9 +2228,9 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2229 | return -EINVAL; | 2228 | return -EINVAL; |
2230 | 2229 | ||
2231 | /* Is the CBW valid? */ | 2230 | /* Is the CBW valid? */ |
2232 | if (req->actual != USB_BULK_CB_WRAP_LEN || | 2231 | if (req->actual != US_BULK_CB_WRAP_LEN || |
2233 | cbw->Signature != cpu_to_le32( | 2232 | cbw->Signature != cpu_to_le32( |
2234 | USB_BULK_CB_SIG)) { | 2233 | US_BULK_CB_SIGN)) { |
2235 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", | 2234 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", |
2236 | req->actual, | 2235 | req->actual, |
2237 | le32_to_cpu(cbw->Signature)); | 2236 | le32_to_cpu(cbw->Signature)); |
@@ -2253,7 +2252,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2253 | } | 2252 | } |
2254 | 2253 | ||
2255 | /* Is the CBW meaningful? */ | 2254 | /* Is the CBW meaningful? */ |
2256 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~USB_BULK_IN_FLAG || | 2255 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN || |
2257 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { | 2256 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { |
2258 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " | 2257 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " |
2259 | "cmdlen %u\n", | 2258 | "cmdlen %u\n", |
@@ -2273,7 +2272,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2273 | /* Save the command for later */ | 2272 | /* Save the command for later */ |
2274 | common->cmnd_size = cbw->Length; | 2273 | common->cmnd_size = cbw->Length; |
2275 | memcpy(common->cmnd, cbw->CDB, common->cmnd_size); | 2274 | memcpy(common->cmnd, cbw->CDB, common->cmnd_size); |
2276 | if (cbw->Flags & USB_BULK_IN_FLAG) | 2275 | if (cbw->Flags & US_BULK_FLAG_IN) |
2277 | common->data_dir = DATA_DIR_TO_HOST; | 2276 | common->data_dir = DATA_DIR_TO_HOST; |
2278 | else | 2277 | else |
2279 | common->data_dir = DATA_DIR_FROM_HOST; | 2278 | common->data_dir = DATA_DIR_FROM_HOST; |
@@ -2303,7 +2302,7 @@ static int get_next_command(struct fsg_common *common) | |||
2303 | } | 2302 | } |
2304 | 2303 | ||
2305 | /* Queue a request to read a Bulk-only CBW */ | 2304 | /* Queue a request to read a Bulk-only CBW */ |
2306 | set_bulk_out_req_length(common, bh, USB_BULK_CB_WRAP_LEN); | 2305 | set_bulk_out_req_length(common, bh, US_BULK_CB_WRAP_LEN); |
2307 | if (!start_out_transfer(common, bh)) | 2306 | if (!start_out_transfer(common, bh)) |
2308 | /* Don't know what to do if common->fsg is NULL */ | 2307 | /* Don't know what to do if common->fsg is NULL */ |
2309 | return -EIO; | 2308 | return -EIO; |
diff --git a/drivers/usb/gadget/f_midi.c b/drivers/usb/gadget/f_midi.c index 3797b3d6c622..2f7e8f2930cc 100644 --- a/drivers/usb/gadget/f_midi.c +++ b/drivers/usb/gadget/f_midi.c | |||
@@ -780,7 +780,7 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f) | |||
780 | midi->out_ep->driver_data = cdev; /* claim */ | 780 | midi->out_ep->driver_data = cdev; /* claim */ |
781 | 781 | ||
782 | /* allocate temporary function list */ | 782 | /* allocate temporary function list */ |
783 | midi_function = kcalloc((MAX_PORTS * 4) + 9, sizeof(midi_function), | 783 | midi_function = kcalloc((MAX_PORTS * 4) + 9, sizeof(*midi_function), |
784 | GFP_KERNEL); | 784 | GFP_KERNEL); |
785 | if (!midi_function) { | 785 | if (!midi_function) { |
786 | status = -ENOMEM; | 786 | status = -ENOMEM; |
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c index 704d1d94f72a..7b1cf18df5e3 100644 --- a/drivers/usb/gadget/f_rndis.c +++ b/drivers/usb/gadget/f_rndis.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger | 5 | * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger |
6 | * Copyright (C) 2008 Nokia Corporation | 6 | * Copyright (C) 2008 Nokia Corporation |
7 | * Copyright (C) 2009 Samsung Electronics | 7 | * Copyright (C) 2009 Samsung Electronics |
8 | * Author: Michal Nazarewicz (m.nazarewicz@samsung.com) | 8 | * Author: Michal Nazarewicz (mina86@mina86.com) |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/usb/gadget/f_serial.c b/drivers/usb/gadget/f_serial.c index cf33a8d0fd5d..07197d63d9b1 100644 --- a/drivers/usb/gadget/f_serial.c +++ b/drivers/usb/gadget/f_serial.c | |||
@@ -99,6 +99,34 @@ static struct usb_descriptor_header *gser_hs_function[] __initdata = { | |||
99 | NULL, | 99 | NULL, |
100 | }; | 100 | }; |
101 | 101 | ||
102 | static struct usb_endpoint_descriptor gser_ss_in_desc __initdata = { | ||
103 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
104 | .bDescriptorType = USB_DT_ENDPOINT, | ||
105 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
106 | .wMaxPacketSize = cpu_to_le16(1024), | ||
107 | }; | ||
108 | |||
109 | static struct usb_endpoint_descriptor gser_ss_out_desc __initdata = { | ||
110 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
111 | .bDescriptorType = USB_DT_ENDPOINT, | ||
112 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | ||
113 | .wMaxPacketSize = cpu_to_le16(1024), | ||
114 | }; | ||
115 | |||
116 | static struct usb_ss_ep_comp_descriptor gser_ss_bulk_comp_desc __initdata = { | ||
117 | .bLength = sizeof gser_ss_bulk_comp_desc, | ||
118 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, | ||
119 | }; | ||
120 | |||
121 | static struct usb_descriptor_header *gser_ss_function[] __initdata = { | ||
122 | (struct usb_descriptor_header *) &gser_interface_desc, | ||
123 | (struct usb_descriptor_header *) &gser_ss_in_desc, | ||
124 | (struct usb_descriptor_header *) &gser_ss_bulk_comp_desc, | ||
125 | (struct usb_descriptor_header *) &gser_ss_out_desc, | ||
126 | (struct usb_descriptor_header *) &gser_ss_bulk_comp_desc, | ||
127 | NULL, | ||
128 | }; | ||
129 | |||
102 | /* string descriptors: */ | 130 | /* string descriptors: */ |
103 | 131 | ||
104 | static struct usb_string gser_string_defs[] = { | 132 | static struct usb_string gser_string_defs[] = { |
@@ -201,9 +229,21 @@ gser_bind(struct usb_configuration *c, struct usb_function *f) | |||
201 | /* copy descriptors, and track endpoint copies */ | 229 | /* copy descriptors, and track endpoint copies */ |
202 | f->hs_descriptors = usb_copy_descriptors(gser_hs_function); | 230 | f->hs_descriptors = usb_copy_descriptors(gser_hs_function); |
203 | } | 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 | } | ||
204 | 243 | ||
205 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", | 244 | DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", |
206 | gser->port_num, | 245 | gser->port_num, |
246 | gadget_is_superspeed(c->cdev->gadget) ? "super" : | ||
207 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", | 247 | gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", |
208 | gser->port.in->name, gser->port.out->name); | 248 | gser->port.in->name, gser->port.out->name); |
209 | return 0; | 249 | return 0; |
@@ -225,6 +265,8 @@ gser_unbind(struct usb_configuration *c, struct usb_function *f) | |||
225 | { | 265 | { |
226 | if (gadget_is_dualspeed(c->cdev->gadget)) | 266 | if (gadget_is_dualspeed(c->cdev->gadget)) |
227 | usb_free_descriptors(f->hs_descriptors); | 267 | usb_free_descriptors(f->hs_descriptors); |
268 | if (gadget_is_superspeed(c->cdev->gadget)) | ||
269 | usb_free_descriptors(f->ss_descriptors); | ||
228 | usb_free_descriptors(f->descriptors); | 270 | usb_free_descriptors(f->descriptors); |
229 | kfree(func_to_gser(f)); | 271 | kfree(func_to_gser(f)); |
230 | } | 272 | } |
diff --git a/drivers/usb/gadget/f_subset.c b/drivers/usb/gadget/f_subset.c index c1540648125a..21ab474aca07 100644 --- a/drivers/usb/gadget/f_subset.c +++ b/drivers/usb/gadget/f_subset.c | |||
@@ -74,7 +74,7 @@ static inline struct f_gether *func_to_geth(struct usb_function *f) | |||
74 | 74 | ||
75 | /* interface descriptor: */ | 75 | /* interface descriptor: */ |
76 | 76 | ||
77 | static struct usb_interface_descriptor subset_data_intf __initdata = { | 77 | static struct usb_interface_descriptor subset_data_intf = { |
78 | .bLength = sizeof subset_data_intf, | 78 | .bLength = sizeof subset_data_intf, |
79 | .bDescriptorType = USB_DT_INTERFACE, | 79 | .bDescriptorType = USB_DT_INTERFACE, |
80 | 80 | ||
@@ -87,7 +87,7 @@ static struct usb_interface_descriptor subset_data_intf __initdata = { | |||
87 | /* .iInterface = DYNAMIC */ | 87 | /* .iInterface = DYNAMIC */ |
88 | }; | 88 | }; |
89 | 89 | ||
90 | static struct usb_cdc_header_desc mdlm_header_desc __initdata = { | 90 | static struct usb_cdc_header_desc mdlm_header_desc = { |
91 | .bLength = sizeof mdlm_header_desc, | 91 | .bLength = sizeof mdlm_header_desc, |
92 | .bDescriptorType = USB_DT_CS_INTERFACE, | 92 | .bDescriptorType = USB_DT_CS_INTERFACE, |
93 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, | 93 | .bDescriptorSubType = USB_CDC_HEADER_TYPE, |
@@ -95,7 +95,7 @@ static struct usb_cdc_header_desc mdlm_header_desc __initdata = { | |||
95 | .bcdCDC = cpu_to_le16(0x0110), | 95 | .bcdCDC = cpu_to_le16(0x0110), |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static struct usb_cdc_mdlm_desc mdlm_desc __initdata = { | 98 | static struct usb_cdc_mdlm_desc mdlm_desc = { |
99 | .bLength = sizeof mdlm_desc, | 99 | .bLength = sizeof mdlm_desc, |
100 | .bDescriptorType = USB_DT_CS_INTERFACE, | 100 | .bDescriptorType = USB_DT_CS_INTERFACE, |
101 | .bDescriptorSubType = USB_CDC_MDLM_TYPE, | 101 | .bDescriptorSubType = USB_CDC_MDLM_TYPE, |
@@ -111,7 +111,7 @@ static struct usb_cdc_mdlm_desc mdlm_desc __initdata = { | |||
111 | * can't really use its struct. All we do here is say that we're using | 111 | * can't really use its struct. All we do here is say that we're using |
112 | * the submode of "SAFE" which directly matches the CDC Subset. | 112 | * the submode of "SAFE" which directly matches the CDC Subset. |
113 | */ | 113 | */ |
114 | static u8 mdlm_detail_desc[] __initdata = { | 114 | static u8 mdlm_detail_desc[] = { |
115 | 6, | 115 | 6, |
116 | USB_DT_CS_INTERFACE, | 116 | USB_DT_CS_INTERFACE, |
117 | USB_CDC_MDLM_DETAIL_TYPE, | 117 | USB_CDC_MDLM_DETAIL_TYPE, |
@@ -121,7 +121,7 @@ static u8 mdlm_detail_desc[] __initdata = { | |||
121 | 0, /* network data capabilities ("raw" encapsulation) */ | 121 | 0, /* network data capabilities ("raw" encapsulation) */ |
122 | }; | 122 | }; |
123 | 123 | ||
124 | static struct usb_cdc_ether_desc ether_desc __initdata = { | 124 | static struct usb_cdc_ether_desc ether_desc = { |
125 | .bLength = sizeof ether_desc, | 125 | .bLength = sizeof ether_desc, |
126 | .bDescriptorType = USB_DT_CS_INTERFACE, | 126 | .bDescriptorType = USB_DT_CS_INTERFACE, |
127 | .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, | 127 | .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, |
@@ -136,7 +136,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = { | |||
136 | 136 | ||
137 | /* full speed support: */ | 137 | /* full speed support: */ |
138 | 138 | ||
139 | static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = { | 139 | static struct usb_endpoint_descriptor fs_subset_in_desc = { |
140 | .bLength = USB_DT_ENDPOINT_SIZE, | 140 | .bLength = USB_DT_ENDPOINT_SIZE, |
141 | .bDescriptorType = USB_DT_ENDPOINT, | 141 | .bDescriptorType = USB_DT_ENDPOINT, |
142 | 142 | ||
@@ -144,7 +144,7 @@ static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = { | |||
144 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 144 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
145 | }; | 145 | }; |
146 | 146 | ||
147 | static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = { | 147 | static struct usb_endpoint_descriptor fs_subset_out_desc = { |
148 | .bLength = USB_DT_ENDPOINT_SIZE, | 148 | .bLength = USB_DT_ENDPOINT_SIZE, |
149 | .bDescriptorType = USB_DT_ENDPOINT, | 149 | .bDescriptorType = USB_DT_ENDPOINT, |
150 | 150 | ||
@@ -152,7 +152,7 @@ static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = { | |||
152 | .bmAttributes = USB_ENDPOINT_XFER_BULK, | 152 | .bmAttributes = USB_ENDPOINT_XFER_BULK, |
153 | }; | 153 | }; |
154 | 154 | ||
155 | static struct usb_descriptor_header *fs_eth_function[] __initdata = { | 155 | static struct usb_descriptor_header *fs_eth_function[] = { |
156 | (struct usb_descriptor_header *) &subset_data_intf, | 156 | (struct usb_descriptor_header *) &subset_data_intf, |
157 | (struct usb_descriptor_header *) &mdlm_header_desc, | 157 | (struct usb_descriptor_header *) &mdlm_header_desc, |
158 | (struct usb_descriptor_header *) &mdlm_desc, | 158 | (struct usb_descriptor_header *) &mdlm_desc, |
@@ -165,7 +165,7 @@ static struct usb_descriptor_header *fs_eth_function[] __initdata = { | |||
165 | 165 | ||
166 | /* high speed support: */ | 166 | /* high speed support: */ |
167 | 167 | ||
168 | static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = { | 168 | static struct usb_endpoint_descriptor hs_subset_in_desc = { |
169 | .bLength = USB_DT_ENDPOINT_SIZE, | 169 | .bLength = USB_DT_ENDPOINT_SIZE, |
170 | .bDescriptorType = USB_DT_ENDPOINT, | 170 | .bDescriptorType = USB_DT_ENDPOINT, |
171 | 171 | ||
@@ -173,7 +173,7 @@ static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = { | |||
173 | .wMaxPacketSize = cpu_to_le16(512), | 173 | .wMaxPacketSize = cpu_to_le16(512), |
174 | }; | 174 | }; |
175 | 175 | ||
176 | static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { | 176 | static struct usb_endpoint_descriptor hs_subset_out_desc = { |
177 | .bLength = USB_DT_ENDPOINT_SIZE, | 177 | .bLength = USB_DT_ENDPOINT_SIZE, |
178 | .bDescriptorType = USB_DT_ENDPOINT, | 178 | .bDescriptorType = USB_DT_ENDPOINT, |
179 | 179 | ||
@@ -181,7 +181,7 @@ static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { | |||
181 | .wMaxPacketSize = cpu_to_le16(512), | 181 | .wMaxPacketSize = cpu_to_le16(512), |
182 | }; | 182 | }; |
183 | 183 | ||
184 | static struct usb_descriptor_header *hs_eth_function[] __initdata = { | 184 | static struct usb_descriptor_header *hs_eth_function[] = { |
185 | (struct usb_descriptor_header *) &subset_data_intf, | 185 | (struct usb_descriptor_header *) &subset_data_intf, |
186 | (struct usb_descriptor_header *) &mdlm_header_desc, | 186 | (struct usb_descriptor_header *) &mdlm_header_desc, |
187 | (struct usb_descriptor_header *) &mdlm_desc, | 187 | (struct usb_descriptor_header *) &mdlm_desc, |
@@ -194,7 +194,7 @@ static struct usb_descriptor_header *hs_eth_function[] __initdata = { | |||
194 | 194 | ||
195 | /* super speed support: */ | 195 | /* super speed support: */ |
196 | 196 | ||
197 | static struct usb_endpoint_descriptor ss_subset_in_desc __initdata = { | 197 | static struct usb_endpoint_descriptor ss_subset_in_desc = { |
198 | .bLength = USB_DT_ENDPOINT_SIZE, | 198 | .bLength = USB_DT_ENDPOINT_SIZE, |
199 | .bDescriptorType = USB_DT_ENDPOINT, | 199 | .bDescriptorType = USB_DT_ENDPOINT, |
200 | 200 | ||
@@ -202,7 +202,7 @@ static struct usb_endpoint_descriptor ss_subset_in_desc __initdata = { | |||
202 | .wMaxPacketSize = cpu_to_le16(1024), | 202 | .wMaxPacketSize = cpu_to_le16(1024), |
203 | }; | 203 | }; |
204 | 204 | ||
205 | static struct usb_endpoint_descriptor ss_subset_out_desc __initdata = { | 205 | static struct usb_endpoint_descriptor ss_subset_out_desc = { |
206 | .bLength = USB_DT_ENDPOINT_SIZE, | 206 | .bLength = USB_DT_ENDPOINT_SIZE, |
207 | .bDescriptorType = USB_DT_ENDPOINT, | 207 | .bDescriptorType = USB_DT_ENDPOINT, |
208 | 208 | ||
@@ -210,7 +210,7 @@ static struct usb_endpoint_descriptor ss_subset_out_desc __initdata = { | |||
210 | .wMaxPacketSize = cpu_to_le16(1024), | 210 | .wMaxPacketSize = cpu_to_le16(1024), |
211 | }; | 211 | }; |
212 | 212 | ||
213 | static struct usb_ss_ep_comp_descriptor ss_subset_bulk_comp_desc __initdata = { | 213 | static struct usb_ss_ep_comp_descriptor ss_subset_bulk_comp_desc = { |
214 | .bLength = sizeof ss_subset_bulk_comp_desc, | 214 | .bLength = sizeof ss_subset_bulk_comp_desc, |
215 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, | 215 | .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, |
216 | 216 | ||
@@ -219,7 +219,7 @@ static struct usb_ss_ep_comp_descriptor ss_subset_bulk_comp_desc __initdata = { | |||
219 | /* .bmAttributes = 0, */ | 219 | /* .bmAttributes = 0, */ |
220 | }; | 220 | }; |
221 | 221 | ||
222 | static struct usb_descriptor_header *ss_eth_function[] __initdata = { | 222 | static struct usb_descriptor_header *ss_eth_function[] = { |
223 | (struct usb_descriptor_header *) &subset_data_intf, | 223 | (struct usb_descriptor_header *) &subset_data_intf, |
224 | (struct usb_descriptor_header *) &mdlm_header_desc, | 224 | (struct usb_descriptor_header *) &mdlm_header_desc, |
225 | (struct usb_descriptor_header *) &mdlm_desc, | 225 | (struct usb_descriptor_header *) &mdlm_desc, |
@@ -290,7 +290,7 @@ static void geth_disable(struct usb_function *f) | |||
290 | 290 | ||
291 | /* serial function driver setup/binding */ | 291 | /* serial function driver setup/binding */ |
292 | 292 | ||
293 | static int __init | 293 | static int |
294 | geth_bind(struct usb_configuration *c, struct usb_function *f) | 294 | geth_bind(struct usb_configuration *c, struct usb_function *f) |
295 | { | 295 | { |
296 | struct usb_composite_dev *cdev = c->cdev; | 296 | struct usb_composite_dev *cdev = c->cdev; |
@@ -404,7 +404,7 @@ geth_unbind(struct usb_configuration *c, struct usb_function *f) | |||
404 | * Caller must have called @gether_setup(). Caller is also responsible | 404 | * Caller must have called @gether_setup(). Caller is also responsible |
405 | * for calling @gether_cleanup() before module unload. | 405 | * for calling @gether_cleanup() before module unload. |
406 | */ | 406 | */ |
407 | int __init geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) | 407 | int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) |
408 | { | 408 | { |
409 | struct f_gether *geth; | 409 | struct f_gether *geth; |
410 | int status; | 410 | int status; |
diff --git a/drivers/usb/gadget/f_audio.c b/drivers/usb/gadget/f_uac1.c index ec7ffcd0d0cd..1a5dcd5565e3 100644 --- a/drivers/usb/gadget/f_audio.c +++ b/drivers/usb/gadget/f_uac1.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/atomic.h> | 15 | #include <linux/atomic.h> |
16 | 16 | ||
17 | #include "u_audio.h" | 17 | #include "u_uac1.h" |
18 | 18 | ||
19 | #define OUT_EP_MAX_PACKET_SIZE 200 | 19 | #define OUT_EP_MAX_PACKET_SIZE 200 |
20 | static int req_buf_size = OUT_EP_MAX_PACKET_SIZE; | 20 | static int req_buf_size = OUT_EP_MAX_PACKET_SIZE; |
@@ -216,29 +216,6 @@ static struct usb_descriptor_header *f_audio_desc[] __initdata = { | |||
216 | NULL, | 216 | NULL, |
217 | }; | 217 | }; |
218 | 218 | ||
219 | /* string IDs are assigned dynamically */ | ||
220 | |||
221 | #define STRING_MANUFACTURER_IDX 0 | ||
222 | #define STRING_PRODUCT_IDX 1 | ||
223 | |||
224 | static char manufacturer[50]; | ||
225 | |||
226 | static struct usb_string strings_dev[] = { | ||
227 | [STRING_MANUFACTURER_IDX].s = manufacturer, | ||
228 | [STRING_PRODUCT_IDX].s = DRIVER_DESC, | ||
229 | { } /* end of list */ | ||
230 | }; | ||
231 | |||
232 | static struct usb_gadget_strings stringtab_dev = { | ||
233 | .language = 0x0409, /* en-us */ | ||
234 | .strings = strings_dev, | ||
235 | }; | ||
236 | |||
237 | static struct usb_gadget_strings *audio_strings[] = { | ||
238 | &stringtab_dev, | ||
239 | NULL, | ||
240 | }; | ||
241 | |||
242 | /* | 219 | /* |
243 | * This function is an ALSA sound card following USB Audio Class Spec 1.0. | 220 | * This function is an ALSA sound card following USB Audio Class Spec 1.0. |
244 | */ | 221 | */ |
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c new file mode 100644 index 000000000000..e7cc4de93e33 --- /dev/null +++ b/drivers/usb/gadget/f_uac2.c | |||
@@ -0,0 +1,1449 @@ | |||
1 | /* | ||
2 | * f_uac2.c -- USB Audio Class 2.0 Function | ||
3 | * | ||
4 | * Copyright (C) 2011 | ||
5 | * Yadwinder Singh (yadi.brar01@gmail.com) | ||
6 | * Jaswinder Singh (jaswinder.singh@linaro.org) | ||
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; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/usb/audio.h> | ||
15 | #include <linux/usb/audio-v2.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/module.h> | ||
18 | |||
19 | #include <sound/core.h> | ||
20 | #include <sound/pcm.h> | ||
21 | #include <sound/pcm_params.h> | ||
22 | |||
23 | /* Playback(USB-IN) Default Stereo - Fl/Fr */ | ||
24 | static int p_chmask = 0x3; | ||
25 | module_param(p_chmask, uint, S_IRUGO); | ||
26 | MODULE_PARM_DESC(p_chmask, "Playback Channel Mask"); | ||
27 | |||
28 | /* Playback Default 48 KHz */ | ||
29 | static int p_srate = 48000; | ||
30 | module_param(p_srate, uint, S_IRUGO); | ||
31 | MODULE_PARM_DESC(p_srate, "Playback Sampling Rate"); | ||
32 | |||
33 | /* Playback Default 16bits/sample */ | ||
34 | static int p_ssize = 2; | ||
35 | module_param(p_ssize, uint, S_IRUGO); | ||
36 | MODULE_PARM_DESC(p_ssize, "Playback Sample Size(bytes)"); | ||
37 | |||
38 | /* Capture(USB-OUT) Default Stereo - Fl/Fr */ | ||
39 | static int c_chmask = 0x3; | ||
40 | module_param(c_chmask, uint, S_IRUGO); | ||
41 | MODULE_PARM_DESC(c_chmask, "Capture Channel Mask"); | ||
42 | |||
43 | /* Capture Default 64 KHz */ | ||
44 | static int c_srate = 64000; | ||
45 | module_param(c_srate, uint, S_IRUGO); | ||
46 | MODULE_PARM_DESC(c_srate, "Capture Sampling Rate"); | ||
47 | |||
48 | /* Capture Default 16bits/sample */ | ||
49 | static int c_ssize = 2; | ||
50 | module_param(c_ssize, uint, S_IRUGO); | ||
51 | MODULE_PARM_DESC(c_ssize, "Capture Sample Size(bytes)"); | ||
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 */ | ||
61 | #define USB_XFERS 2 | ||
62 | |||
63 | /* | ||
64 | * The driver implements a simple UAC_2 topology. | ||
65 | * USB-OUT -> IT_1 -> OT_3 -> ALSA_Capture | ||
66 | * ALSA_Playback -> IT_2 -> OT_4 -> USB-IN | ||
67 | * Capture and Playback sampling rates are independently | ||
68 | * controlled by two clock sources : | ||
69 | * CLK_5 := c_srate, and CLK_6 := p_srate | ||
70 | */ | ||
71 | #define USB_OUT_IT_ID 1 | ||
72 | #define IO_IN_IT_ID 2 | ||
73 | #define IO_OUT_OT_ID 3 | ||
74 | #define USB_IN_OT_ID 4 | ||
75 | #define USB_OUT_CLK_ID 5 | ||
76 | #define USB_IN_CLK_ID 6 | ||
77 | |||
78 | #define CONTROL_ABSENT 0 | ||
79 | #define CONTROL_RDONLY 1 | ||
80 | #define CONTROL_RDWR 3 | ||
81 | |||
82 | #define CLK_FREQ_CTRL 0 | ||
83 | #define CLK_VLD_CTRL 2 | ||
84 | |||
85 | #define COPY_CTRL 0 | ||
86 | #define CONN_CTRL 2 | ||
87 | #define OVRLD_CTRL 4 | ||
88 | #define CLSTR_CTRL 6 | ||
89 | #define UNFLW_CTRL 8 | ||
90 | #define OVFLW_CTRL 10 | ||
91 | |||
92 | const char *uac2_name = "snd_uac2"; | ||
93 | |||
94 | struct uac2_req { | ||
95 | struct uac2_rtd_params *pp; /* parent param */ | ||
96 | struct usb_request *req; | ||
97 | }; | ||
98 | |||
99 | struct uac2_rtd_params { | ||
100 | bool ep_enabled; /* if the ep is enabled */ | ||
101 | /* Size of the ring buffer */ | ||
102 | size_t dma_bytes; | ||
103 | unsigned char *dma_area; | ||
104 | |||
105 | struct snd_pcm_substream *ss; | ||
106 | |||
107 | /* Ring buffer */ | ||
108 | ssize_t hw_ptr; | ||
109 | |||
110 | void *rbuf; | ||
111 | |||
112 | size_t period_size; | ||
113 | |||
114 | unsigned max_psize; | ||
115 | struct uac2_req ureq[USB_XFERS]; | ||
116 | |||
117 | spinlock_t lock; | ||
118 | }; | ||
119 | |||
120 | struct snd_uac2_chip { | ||
121 | struct platform_device pdev; | ||
122 | struct platform_driver pdrv; | ||
123 | |||
124 | struct uac2_rtd_params p_prm; | ||
125 | struct uac2_rtd_params c_prm; | ||
126 | |||
127 | struct snd_card *card; | ||
128 | struct snd_pcm *pcm; | ||
129 | }; | ||
130 | |||
131 | #define BUFF_SIZE_MAX (PAGE_SIZE * 16) | ||
132 | #define PRD_SIZE_MAX PAGE_SIZE | ||
133 | #define MIN_PERIODS 4 | ||
134 | |||
135 | static struct snd_pcm_hardware uac2_pcm_hardware = { | ||
136 | .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | ||
137 | | SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | ||
138 | | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME, | ||
139 | .rates = SNDRV_PCM_RATE_CONTINUOUS, | ||
140 | .periods_max = BUFF_SIZE_MAX / PRD_SIZE_MAX, | ||
141 | .buffer_bytes_max = BUFF_SIZE_MAX, | ||
142 | .period_bytes_max = PRD_SIZE_MAX, | ||
143 | .periods_min = MIN_PERIODS, | ||
144 | }; | ||
145 | |||
146 | struct audio_dev { | ||
147 | /* Currently active {Interface[15:8] | AltSettings[7:0]} */ | ||
148 | __u16 ac_alt, as_out_alt, as_in_alt; | ||
149 | |||
150 | struct usb_ep *in_ep, *out_ep; | ||
151 | struct usb_function func; | ||
152 | |||
153 | /* The ALSA Sound Card it represents on the USB-Client side */ | ||
154 | struct snd_uac2_chip uac2; | ||
155 | }; | ||
156 | |||
157 | static struct audio_dev *agdev_g; | ||
158 | |||
159 | static inline | ||
160 | struct audio_dev *func_to_agdev(struct usb_function *f) | ||
161 | { | ||
162 | return container_of(f, struct audio_dev, func); | ||
163 | } | ||
164 | |||
165 | static inline | ||
166 | struct audio_dev *uac2_to_agdev(struct snd_uac2_chip *u) | ||
167 | { | ||
168 | return container_of(u, struct audio_dev, uac2); | ||
169 | } | ||
170 | |||
171 | static inline | ||
172 | struct snd_uac2_chip *pdev_to_uac2(struct platform_device *p) | ||
173 | { | ||
174 | return container_of(p, struct snd_uac2_chip, pdev); | ||
175 | } | ||
176 | |||
177 | static inline | ||
178 | struct snd_uac2_chip *prm_to_uac2(struct uac2_rtd_params *r) | ||
179 | { | ||
180 | struct snd_uac2_chip *uac2 = container_of(r, | ||
181 | struct snd_uac2_chip, c_prm); | ||
182 | |||
183 | if (&uac2->c_prm != r) | ||
184 | uac2 = container_of(r, struct snd_uac2_chip, p_prm); | ||
185 | |||
186 | return uac2; | ||
187 | } | ||
188 | |||
189 | static inline | ||
190 | uint num_channels(uint chanmask) | ||
191 | { | ||
192 | uint num = 0; | ||
193 | |||
194 | while (chanmask) { | ||
195 | num += (chanmask & 1); | ||
196 | chanmask >>= 1; | ||
197 | } | ||
198 | |||
199 | return num; | ||
200 | } | ||
201 | |||
202 | static void | ||
203 | agdev_iso_complete(struct usb_ep *ep, struct usb_request *req) | ||
204 | { | ||
205 | unsigned pending; | ||
206 | unsigned long flags; | ||
207 | bool update_alsa = false; | ||
208 | unsigned char *src, *dst; | ||
209 | int status = req->status; | ||
210 | struct uac2_req *ur = req->context; | ||
211 | struct snd_pcm_substream *substream; | ||
212 | struct uac2_rtd_params *prm = ur->pp; | ||
213 | struct snd_uac2_chip *uac2 = prm_to_uac2(prm); | ||
214 | |||
215 | /* i/f shutting down */ | ||
216 | if (!prm->ep_enabled) | ||
217 | return; | ||
218 | |||
219 | /* | ||
220 | * We can't really do much about bad xfers. | ||
221 | * Afterall, the ISOCH xfers could fail legitimately. | ||
222 | */ | ||
223 | if (status) | ||
224 | pr_debug("%s: iso_complete status(%d) %d/%d\n", | ||
225 | __func__, status, req->actual, req->length); | ||
226 | |||
227 | substream = prm->ss; | ||
228 | |||
229 | /* Do nothing if ALSA isn't active */ | ||
230 | if (!substream) | ||
231 | goto exit; | ||
232 | |||
233 | spin_lock_irqsave(&prm->lock, flags); | ||
234 | |||
235 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
236 | src = prm->dma_area + prm->hw_ptr; | ||
237 | req->actual = req->length; | ||
238 | dst = req->buf; | ||
239 | } else { | ||
240 | dst = prm->dma_area + prm->hw_ptr; | ||
241 | src = req->buf; | ||
242 | } | ||
243 | |||
244 | pending = prm->hw_ptr % prm->period_size; | ||
245 | pending += req->actual; | ||
246 | if (pending >= prm->period_size) | ||
247 | update_alsa = true; | ||
248 | |||
249 | prm->hw_ptr = (prm->hw_ptr + req->actual) % prm->dma_bytes; | ||
250 | |||
251 | spin_unlock_irqrestore(&prm->lock, flags); | ||
252 | |||
253 | /* Pack USB load in ALSA ring buffer */ | ||
254 | memcpy(dst, src, req->actual); | ||
255 | exit: | ||
256 | if (usb_ep_queue(ep, req, GFP_ATOMIC)) | ||
257 | dev_err(&uac2->pdev.dev, "%d Error!\n", __LINE__); | ||
258 | |||
259 | if (update_alsa) | ||
260 | snd_pcm_period_elapsed(substream); | ||
261 | |||
262 | return; | ||
263 | } | ||
264 | |||
265 | static int | ||
266 | uac2_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | ||
267 | { | ||
268 | struct snd_uac2_chip *uac2 = snd_pcm_substream_chip(substream); | ||
269 | struct audio_dev *agdev = uac2_to_agdev(uac2); | ||
270 | struct uac2_rtd_params *prm; | ||
271 | unsigned long flags; | ||
272 | struct usb_ep *ep; | ||
273 | int err = 0; | ||
274 | |||
275 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
276 | ep = agdev->in_ep; | ||
277 | prm = &uac2->p_prm; | ||
278 | } else { | ||
279 | ep = agdev->out_ep; | ||
280 | prm = &uac2->c_prm; | ||
281 | } | ||
282 | |||
283 | spin_lock_irqsave(&prm->lock, flags); | ||
284 | |||
285 | /* Reset */ | ||
286 | prm->hw_ptr = 0; | ||
287 | |||
288 | switch (cmd) { | ||
289 | case SNDRV_PCM_TRIGGER_START: | ||
290 | case SNDRV_PCM_TRIGGER_RESUME: | ||
291 | prm->ss = substream; | ||
292 | break; | ||
293 | case SNDRV_PCM_TRIGGER_STOP: | ||
294 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
295 | prm->ss = NULL; | ||
296 | break; | ||
297 | default: | ||
298 | err = -EINVAL; | ||
299 | } | ||
300 | |||
301 | spin_unlock_irqrestore(&prm->lock, flags); | ||
302 | |||
303 | /* Clear buffer after Play stops */ | ||
304 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && !prm->ss) | ||
305 | memset(prm->rbuf, 0, prm->max_psize * USB_XFERS); | ||
306 | |||
307 | return err; | ||
308 | } | ||
309 | |||
310 | static snd_pcm_uframes_t uac2_pcm_pointer(struct snd_pcm_substream *substream) | ||
311 | { | ||
312 | struct snd_uac2_chip *uac2 = snd_pcm_substream_chip(substream); | ||
313 | struct uac2_rtd_params *prm; | ||
314 | |||
315 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
316 | prm = &uac2->p_prm; | ||
317 | else | ||
318 | prm = &uac2->c_prm; | ||
319 | |||
320 | return bytes_to_frames(substream->runtime, prm->hw_ptr); | ||
321 | } | ||
322 | |||
323 | static int uac2_pcm_hw_params(struct snd_pcm_substream *substream, | ||
324 | struct snd_pcm_hw_params *hw_params) | ||
325 | { | ||
326 | struct snd_uac2_chip *uac2 = snd_pcm_substream_chip(substream); | ||
327 | struct uac2_rtd_params *prm; | ||
328 | int err; | ||
329 | |||
330 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
331 | prm = &uac2->p_prm; | ||
332 | else | ||
333 | prm = &uac2->c_prm; | ||
334 | |||
335 | err = snd_pcm_lib_malloc_pages(substream, | ||
336 | params_buffer_bytes(hw_params)); | ||
337 | if (err >= 0) { | ||
338 | prm->dma_bytes = substream->runtime->dma_bytes; | ||
339 | prm->dma_area = substream->runtime->dma_area; | ||
340 | prm->period_size = params_period_bytes(hw_params); | ||
341 | } | ||
342 | |||
343 | return err; | ||
344 | } | ||
345 | |||
346 | static int uac2_pcm_hw_free(struct snd_pcm_substream *substream) | ||
347 | { | ||
348 | struct snd_uac2_chip *uac2 = snd_pcm_substream_chip(substream); | ||
349 | struct uac2_rtd_params *prm; | ||
350 | |||
351 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
352 | prm = &uac2->p_prm; | ||
353 | else | ||
354 | prm = &uac2->c_prm; | ||
355 | |||
356 | prm->dma_area = NULL; | ||
357 | prm->dma_bytes = 0; | ||
358 | prm->period_size = 0; | ||
359 | |||
360 | return snd_pcm_lib_free_pages(substream); | ||
361 | } | ||
362 | |||
363 | static int uac2_pcm_open(struct snd_pcm_substream *substream) | ||
364 | { | ||
365 | struct snd_uac2_chip *uac2 = snd_pcm_substream_chip(substream); | ||
366 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
367 | |||
368 | runtime->hw = uac2_pcm_hardware; | ||
369 | |||
370 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
371 | spin_lock_init(&uac2->p_prm.lock); | ||
372 | runtime->hw.rate_min = p_srate; | ||
373 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; /* ! p_ssize ! */ | ||
374 | runtime->hw.channels_min = num_channels(p_chmask); | ||
375 | runtime->hw.period_bytes_min = 2 * uac2->p_prm.max_psize | ||
376 | / runtime->hw.periods_min; | ||
377 | } else { | ||
378 | spin_lock_init(&uac2->c_prm.lock); | ||
379 | runtime->hw.rate_min = c_srate; | ||
380 | runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; /* ! c_ssize ! */ | ||
381 | runtime->hw.channels_min = num_channels(c_chmask); | ||
382 | runtime->hw.period_bytes_min = 2 * uac2->c_prm.max_psize | ||
383 | / runtime->hw.periods_min; | ||
384 | } | ||
385 | |||
386 | runtime->hw.rate_max = runtime->hw.rate_min; | ||
387 | runtime->hw.channels_max = runtime->hw.channels_min; | ||
388 | |||
389 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | ||
390 | |||
391 | return 0; | ||
392 | } | ||
393 | |||
394 | /* ALSA cries without these function pointers */ | ||
395 | static int uac2_pcm_null(struct snd_pcm_substream *substream) | ||
396 | { | ||
397 | return 0; | ||
398 | } | ||
399 | |||
400 | static struct snd_pcm_ops uac2_pcm_ops = { | ||
401 | .open = uac2_pcm_open, | ||
402 | .close = uac2_pcm_null, | ||
403 | .ioctl = snd_pcm_lib_ioctl, | ||
404 | .hw_params = uac2_pcm_hw_params, | ||
405 | .hw_free = uac2_pcm_hw_free, | ||
406 | .trigger = uac2_pcm_trigger, | ||
407 | .pointer = uac2_pcm_pointer, | ||
408 | .prepare = uac2_pcm_null, | ||
409 | }; | ||
410 | |||
411 | static int __devinit snd_uac2_probe(struct platform_device *pdev) | ||
412 | { | ||
413 | struct snd_uac2_chip *uac2 = pdev_to_uac2(pdev); | ||
414 | struct snd_card *card; | ||
415 | struct snd_pcm *pcm; | ||
416 | int err; | ||
417 | |||
418 | /* Choose any slot, with no id */ | ||
419 | err = snd_card_create(-1, NULL, THIS_MODULE, 0, &card); | ||
420 | if (err < 0) | ||
421 | return err; | ||
422 | |||
423 | uac2->card = card; | ||
424 | |||
425 | /* | ||
426 | * Create first PCM device | ||
427 | * Create a substream only for non-zero channel streams | ||
428 | */ | ||
429 | err = snd_pcm_new(uac2->card, "UAC2 PCM", 0, | ||
430 | p_chmask ? 1 : 0, c_chmask ? 1 : 0, &pcm); | ||
431 | if (err < 0) | ||
432 | goto snd_fail; | ||
433 | |||
434 | strcpy(pcm->name, "UAC2 PCM"); | ||
435 | pcm->private_data = uac2; | ||
436 | |||
437 | uac2->pcm = pcm; | ||
438 | |||
439 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &uac2_pcm_ops); | ||
440 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &uac2_pcm_ops); | ||
441 | |||
442 | strcpy(card->driver, "UAC2_Gadget"); | ||
443 | strcpy(card->shortname, "UAC2_Gadget"); | ||
444 | sprintf(card->longname, "UAC2_Gadget %i", pdev->id); | ||
445 | |||
446 | snd_card_set_dev(card, &pdev->dev); | ||
447 | |||
448 | snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, | ||
449 | snd_dma_continuous_data(GFP_KERNEL), 0, BUFF_SIZE_MAX); | ||
450 | |||
451 | err = snd_card_register(card); | ||
452 | if (!err) { | ||
453 | platform_set_drvdata(pdev, card); | ||
454 | return 0; | ||
455 | } | ||
456 | |||
457 | snd_fail: | ||
458 | snd_card_free(card); | ||
459 | |||
460 | uac2->pcm = NULL; | ||
461 | uac2->card = NULL; | ||
462 | |||
463 | return err; | ||
464 | } | ||
465 | |||
466 | static int __devexit snd_uac2_remove(struct platform_device *pdev) | ||
467 | { | ||
468 | struct snd_card *card = platform_get_drvdata(pdev); | ||
469 | |||
470 | platform_set_drvdata(pdev, NULL); | ||
471 | |||
472 | if (card) | ||
473 | return snd_card_free(card); | ||
474 | |||
475 | return 0; | ||
476 | } | ||
477 | |||
478 | static int alsa_uac2_init(struct audio_dev *agdev) | ||
479 | { | ||
480 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
481 | int err; | ||
482 | |||
483 | uac2->pdrv.probe = snd_uac2_probe; | ||
484 | uac2->pdrv.remove = snd_uac2_remove; | ||
485 | uac2->pdrv.driver.name = uac2_name; | ||
486 | |||
487 | uac2->pdev.id = 0; | ||
488 | uac2->pdev.name = uac2_name; | ||
489 | |||
490 | /* Register snd_uac2 driver */ | ||
491 | err = platform_driver_register(&uac2->pdrv); | ||
492 | if (err) | ||
493 | return err; | ||
494 | |||
495 | /* Register snd_uac2 device */ | ||
496 | err = platform_device_register(&uac2->pdev); | ||
497 | if (err) | ||
498 | platform_driver_unregister(&uac2->pdrv); | ||
499 | |||
500 | return err; | ||
501 | } | ||
502 | |||
503 | static void alsa_uac2_exit(struct audio_dev *agdev) | ||
504 | { | ||
505 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
506 | |||
507 | platform_driver_unregister(&uac2->pdrv); | ||
508 | platform_device_unregister(&uac2->pdev); | ||
509 | } | ||
510 | |||
511 | |||
512 | /* --------- USB Function Interface ------------- */ | ||
513 | |||
514 | enum { | ||
515 | STR_ASSOC, | ||
516 | STR_IF_CTRL, | ||
517 | STR_CLKSRC_IN, | ||
518 | STR_CLKSRC_OUT, | ||
519 | STR_USB_IT, | ||
520 | STR_IO_IT, | ||
521 | STR_USB_OT, | ||
522 | STR_IO_OT, | ||
523 | STR_AS_OUT_ALT0, | ||
524 | STR_AS_OUT_ALT1, | ||
525 | STR_AS_IN_ALT0, | ||
526 | STR_AS_IN_ALT1, | ||
527 | }; | ||
528 | |||
529 | static const char ifassoc[] = "Source/Sink"; | ||
530 | static const char ifctrl[] = "Topology Control"; | ||
531 | static char clksrc_in[8]; | ||
532 | 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 | |||
542 | static struct usb_string strings_fn[] = { | ||
543 | [STR_ASSOC].s = ifassoc, | ||
544 | [STR_IF_CTRL].s = ifctrl, | ||
545 | [STR_CLKSRC_IN].s = clksrc_in, | ||
546 | [STR_CLKSRC_OUT].s = clksrc_out, | ||
547 | [STR_USB_IT].s = usb_it, | ||
548 | [STR_IO_IT].s = io_it, | ||
549 | [STR_USB_OT].s = usb_ot, | ||
550 | [STR_IO_OT].s = io_ot, | ||
551 | [STR_AS_OUT_ALT0].s = out_alt0, | ||
552 | [STR_AS_OUT_ALT1].s = out_alt1, | ||
553 | [STR_AS_IN_ALT0].s = in_alt0, | ||
554 | [STR_AS_IN_ALT1].s = in_alt1, | ||
555 | { }, | ||
556 | }; | ||
557 | |||
558 | static struct usb_gadget_strings str_fn = { | ||
559 | .language = 0x0409, /* en-us */ | ||
560 | .strings = strings_fn, | ||
561 | }; | ||
562 | |||
563 | static struct usb_gadget_strings *fn_strings[] = { | ||
564 | &str_fn, | ||
565 | NULL, | ||
566 | }; | ||
567 | |||
568 | static struct usb_qualifier_descriptor devqual_desc = { | ||
569 | .bLength = sizeof devqual_desc, | ||
570 | .bDescriptorType = USB_DT_DEVICE_QUALIFIER, | ||
571 | |||
572 | .bcdUSB = cpu_to_le16(0x200), | ||
573 | .bDeviceClass = USB_CLASS_MISC, | ||
574 | .bDeviceSubClass = 0x02, | ||
575 | .bDeviceProtocol = 0x01, | ||
576 | .bNumConfigurations = 1, | ||
577 | .bRESERVED = 0, | ||
578 | }; | ||
579 | |||
580 | static struct usb_interface_assoc_descriptor iad_desc = { | ||
581 | .bLength = sizeof iad_desc, | ||
582 | .bDescriptorType = USB_DT_INTERFACE_ASSOCIATION, | ||
583 | |||
584 | .bFirstInterface = 0, | ||
585 | .bInterfaceCount = 3, | ||
586 | .bFunctionClass = USB_CLASS_AUDIO, | ||
587 | .bFunctionSubClass = UAC2_FUNCTION_SUBCLASS_UNDEFINED, | ||
588 | .bFunctionProtocol = UAC_VERSION_2, | ||
589 | }; | ||
590 | |||
591 | /* Audio Control Interface */ | ||
592 | static struct usb_interface_descriptor std_ac_if_desc = { | ||
593 | .bLength = sizeof std_ac_if_desc, | ||
594 | .bDescriptorType = USB_DT_INTERFACE, | ||
595 | |||
596 | .bAlternateSetting = 0, | ||
597 | .bNumEndpoints = 0, | ||
598 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
599 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, | ||
600 | .bInterfaceProtocol = UAC_VERSION_2, | ||
601 | }; | ||
602 | |||
603 | /* Clock source for IN traffic */ | ||
604 | struct uac_clock_source_descriptor in_clk_src_desc = { | ||
605 | .bLength = sizeof in_clk_src_desc, | ||
606 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
607 | |||
608 | .bDescriptorSubtype = UAC2_CLOCK_SOURCE, | ||
609 | .bClockID = USB_IN_CLK_ID, | ||
610 | .bmAttributes = UAC_CLOCK_SOURCE_TYPE_INT_FIXED, | ||
611 | .bmControls = (CONTROL_RDONLY << CLK_FREQ_CTRL), | ||
612 | .bAssocTerminal = 0, | ||
613 | }; | ||
614 | |||
615 | /* Clock source for OUT traffic */ | ||
616 | struct uac_clock_source_descriptor out_clk_src_desc = { | ||
617 | .bLength = sizeof out_clk_src_desc, | ||
618 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
619 | |||
620 | .bDescriptorSubtype = UAC2_CLOCK_SOURCE, | ||
621 | .bClockID = USB_OUT_CLK_ID, | ||
622 | .bmAttributes = UAC_CLOCK_SOURCE_TYPE_INT_FIXED, | ||
623 | .bmControls = (CONTROL_RDONLY << CLK_FREQ_CTRL), | ||
624 | .bAssocTerminal = 0, | ||
625 | }; | ||
626 | |||
627 | /* Input Terminal for USB_OUT */ | ||
628 | struct uac2_input_terminal_descriptor usb_out_it_desc = { | ||
629 | .bLength = sizeof usb_out_it_desc, | ||
630 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
631 | |||
632 | .bDescriptorSubtype = UAC_INPUT_TERMINAL, | ||
633 | .bTerminalID = USB_OUT_IT_ID, | ||
634 | .wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING), | ||
635 | .bAssocTerminal = 0, | ||
636 | .bCSourceID = USB_OUT_CLK_ID, | ||
637 | .iChannelNames = 0, | ||
638 | .bmControls = (CONTROL_RDWR << COPY_CTRL), | ||
639 | }; | ||
640 | |||
641 | /* Input Terminal for I/O-In */ | ||
642 | struct uac2_input_terminal_descriptor io_in_it_desc = { | ||
643 | .bLength = sizeof io_in_it_desc, | ||
644 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
645 | |||
646 | .bDescriptorSubtype = UAC_INPUT_TERMINAL, | ||
647 | .bTerminalID = IO_IN_IT_ID, | ||
648 | .wTerminalType = cpu_to_le16(UAC_INPUT_TERMINAL_UNDEFINED), | ||
649 | .bAssocTerminal = 0, | ||
650 | .bCSourceID = USB_IN_CLK_ID, | ||
651 | .iChannelNames = 0, | ||
652 | .bmControls = (CONTROL_RDWR << COPY_CTRL), | ||
653 | }; | ||
654 | |||
655 | /* Ouput Terminal for USB_IN */ | ||
656 | struct uac2_output_terminal_descriptor usb_in_ot_desc = { | ||
657 | .bLength = sizeof usb_in_ot_desc, | ||
658 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
659 | |||
660 | .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, | ||
661 | .bTerminalID = USB_IN_OT_ID, | ||
662 | .wTerminalType = cpu_to_le16(UAC_TERMINAL_STREAMING), | ||
663 | .bAssocTerminal = 0, | ||
664 | .bSourceID = IO_IN_IT_ID, | ||
665 | .bCSourceID = USB_IN_CLK_ID, | ||
666 | .bmControls = (CONTROL_RDWR << COPY_CTRL), | ||
667 | }; | ||
668 | |||
669 | /* Ouput Terminal for I/O-Out */ | ||
670 | struct uac2_output_terminal_descriptor io_out_ot_desc = { | ||
671 | .bLength = sizeof io_out_ot_desc, | ||
672 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
673 | |||
674 | .bDescriptorSubtype = UAC_OUTPUT_TERMINAL, | ||
675 | .bTerminalID = IO_OUT_OT_ID, | ||
676 | .wTerminalType = cpu_to_le16(UAC_OUTPUT_TERMINAL_UNDEFINED), | ||
677 | .bAssocTerminal = 0, | ||
678 | .bSourceID = USB_OUT_IT_ID, | ||
679 | .bCSourceID = USB_OUT_CLK_ID, | ||
680 | .bmControls = (CONTROL_RDWR << COPY_CTRL), | ||
681 | }; | ||
682 | |||
683 | struct uac2_ac_header_descriptor ac_hdr_desc = { | ||
684 | .bLength = sizeof ac_hdr_desc, | ||
685 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
686 | |||
687 | .bDescriptorSubtype = UAC_MS_HEADER, | ||
688 | .bcdADC = cpu_to_le16(0x200), | ||
689 | .bCategory = UAC2_FUNCTION_IO_BOX, | ||
690 | .wTotalLength = sizeof in_clk_src_desc + sizeof out_clk_src_desc | ||
691 | + sizeof usb_out_it_desc + sizeof io_in_it_desc | ||
692 | + sizeof usb_in_ot_desc + sizeof io_out_ot_desc, | ||
693 | .bmControls = 0, | ||
694 | }; | ||
695 | |||
696 | /* Audio Streaming OUT Interface - Alt0 */ | ||
697 | static struct usb_interface_descriptor std_as_out_if0_desc = { | ||
698 | .bLength = sizeof std_as_out_if0_desc, | ||
699 | .bDescriptorType = USB_DT_INTERFACE, | ||
700 | |||
701 | .bAlternateSetting = 0, | ||
702 | .bNumEndpoints = 0, | ||
703 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
704 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOSTREAMING, | ||
705 | .bInterfaceProtocol = UAC_VERSION_2, | ||
706 | }; | ||
707 | |||
708 | /* Audio Streaming OUT Interface - Alt1 */ | ||
709 | static struct usb_interface_descriptor std_as_out_if1_desc = { | ||
710 | .bLength = sizeof std_as_out_if1_desc, | ||
711 | .bDescriptorType = USB_DT_INTERFACE, | ||
712 | |||
713 | .bAlternateSetting = 1, | ||
714 | .bNumEndpoints = 1, | ||
715 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
716 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOSTREAMING, | ||
717 | .bInterfaceProtocol = UAC_VERSION_2, | ||
718 | }; | ||
719 | |||
720 | /* Audio Stream OUT Intface Desc */ | ||
721 | struct uac2_as_header_descriptor as_out_hdr_desc = { | ||
722 | .bLength = sizeof as_out_hdr_desc, | ||
723 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
724 | |||
725 | .bDescriptorSubtype = UAC_AS_GENERAL, | ||
726 | .bTerminalLink = USB_OUT_IT_ID, | ||
727 | .bmControls = 0, | ||
728 | .bFormatType = UAC_FORMAT_TYPE_I, | ||
729 | .bmFormats = cpu_to_le32(UAC_FORMAT_TYPE_I_PCM), | ||
730 | .iChannelNames = 0, | ||
731 | }; | ||
732 | |||
733 | /* Audio USB_OUT Format */ | ||
734 | struct uac2_format_type_i_descriptor as_out_fmt1_desc = { | ||
735 | .bLength = sizeof as_out_fmt1_desc, | ||
736 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
737 | .bDescriptorSubtype = UAC_FORMAT_TYPE, | ||
738 | .bFormatType = UAC_FORMAT_TYPE_I, | ||
739 | }; | ||
740 | |||
741 | /* STD AS ISO OUT Endpoint */ | ||
742 | struct usb_endpoint_descriptor fs_epout_desc = { | ||
743 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
744 | .bDescriptorType = USB_DT_ENDPOINT, | ||
745 | |||
746 | .bEndpointAddress = USB_DIR_OUT, | ||
747 | .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, | ||
748 | .bInterval = 1, | ||
749 | }; | ||
750 | |||
751 | struct usb_endpoint_descriptor hs_epout_desc = { | ||
752 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
753 | .bDescriptorType = USB_DT_ENDPOINT, | ||
754 | |||
755 | .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, | ||
756 | .bInterval = 4, | ||
757 | }; | ||
758 | |||
759 | /* CS AS ISO OUT Endpoint */ | ||
760 | static struct uac2_iso_endpoint_descriptor as_iso_out_desc = { | ||
761 | .bLength = sizeof as_iso_out_desc, | ||
762 | .bDescriptorType = USB_DT_CS_ENDPOINT, | ||
763 | |||
764 | .bDescriptorSubtype = UAC_EP_GENERAL, | ||
765 | .bmAttributes = 0, | ||
766 | .bmControls = 0, | ||
767 | .bLockDelayUnits = 0, | ||
768 | .wLockDelay = 0, | ||
769 | }; | ||
770 | |||
771 | /* Audio Streaming IN Interface - Alt0 */ | ||
772 | static struct usb_interface_descriptor std_as_in_if0_desc = { | ||
773 | .bLength = sizeof std_as_in_if0_desc, | ||
774 | .bDescriptorType = USB_DT_INTERFACE, | ||
775 | |||
776 | .bAlternateSetting = 0, | ||
777 | .bNumEndpoints = 0, | ||
778 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
779 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOSTREAMING, | ||
780 | .bInterfaceProtocol = UAC_VERSION_2, | ||
781 | }; | ||
782 | |||
783 | /* Audio Streaming IN Interface - Alt1 */ | ||
784 | static struct usb_interface_descriptor std_as_in_if1_desc = { | ||
785 | .bLength = sizeof std_as_in_if1_desc, | ||
786 | .bDescriptorType = USB_DT_INTERFACE, | ||
787 | |||
788 | .bAlternateSetting = 1, | ||
789 | .bNumEndpoints = 1, | ||
790 | .bInterfaceClass = USB_CLASS_AUDIO, | ||
791 | .bInterfaceSubClass = USB_SUBCLASS_AUDIOSTREAMING, | ||
792 | .bInterfaceProtocol = UAC_VERSION_2, | ||
793 | }; | ||
794 | |||
795 | /* Audio Stream IN Intface Desc */ | ||
796 | struct uac2_as_header_descriptor as_in_hdr_desc = { | ||
797 | .bLength = sizeof as_in_hdr_desc, | ||
798 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
799 | |||
800 | .bDescriptorSubtype = UAC_AS_GENERAL, | ||
801 | .bTerminalLink = USB_IN_OT_ID, | ||
802 | .bmControls = 0, | ||
803 | .bFormatType = UAC_FORMAT_TYPE_I, | ||
804 | .bmFormats = cpu_to_le32(UAC_FORMAT_TYPE_I_PCM), | ||
805 | .iChannelNames = 0, | ||
806 | }; | ||
807 | |||
808 | /* Audio USB_IN Format */ | ||
809 | struct uac2_format_type_i_descriptor as_in_fmt1_desc = { | ||
810 | .bLength = sizeof as_in_fmt1_desc, | ||
811 | .bDescriptorType = USB_DT_CS_INTERFACE, | ||
812 | .bDescriptorSubtype = UAC_FORMAT_TYPE, | ||
813 | .bFormatType = UAC_FORMAT_TYPE_I, | ||
814 | }; | ||
815 | |||
816 | /* STD AS ISO IN Endpoint */ | ||
817 | struct usb_endpoint_descriptor fs_epin_desc = { | ||
818 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
819 | .bDescriptorType = USB_DT_ENDPOINT, | ||
820 | |||
821 | .bEndpointAddress = USB_DIR_IN, | ||
822 | .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, | ||
823 | .bInterval = 1, | ||
824 | }; | ||
825 | |||
826 | struct usb_endpoint_descriptor hs_epin_desc = { | ||
827 | .bLength = USB_DT_ENDPOINT_SIZE, | ||
828 | .bDescriptorType = USB_DT_ENDPOINT, | ||
829 | |||
830 | .bmAttributes = USB_ENDPOINT_XFER_ISOC | USB_ENDPOINT_SYNC_ASYNC, | ||
831 | .bInterval = 4, | ||
832 | }; | ||
833 | |||
834 | /* CS AS ISO IN Endpoint */ | ||
835 | static struct uac2_iso_endpoint_descriptor as_iso_in_desc = { | ||
836 | .bLength = sizeof as_iso_in_desc, | ||
837 | .bDescriptorType = USB_DT_CS_ENDPOINT, | ||
838 | |||
839 | .bDescriptorSubtype = UAC_EP_GENERAL, | ||
840 | .bmAttributes = 0, | ||
841 | .bmControls = 0, | ||
842 | .bLockDelayUnits = 0, | ||
843 | .wLockDelay = 0, | ||
844 | }; | ||
845 | |||
846 | static struct usb_descriptor_header *fs_audio_desc[] = { | ||
847 | (struct usb_descriptor_header *)&iad_desc, | ||
848 | (struct usb_descriptor_header *)&std_ac_if_desc, | ||
849 | |||
850 | (struct usb_descriptor_header *)&ac_hdr_desc, | ||
851 | (struct usb_descriptor_header *)&in_clk_src_desc, | ||
852 | (struct usb_descriptor_header *)&out_clk_src_desc, | ||
853 | (struct usb_descriptor_header *)&usb_out_it_desc, | ||
854 | (struct usb_descriptor_header *)&io_in_it_desc, | ||
855 | (struct usb_descriptor_header *)&usb_in_ot_desc, | ||
856 | (struct usb_descriptor_header *)&io_out_ot_desc, | ||
857 | |||
858 | (struct usb_descriptor_header *)&std_as_out_if0_desc, | ||
859 | (struct usb_descriptor_header *)&std_as_out_if1_desc, | ||
860 | |||
861 | (struct usb_descriptor_header *)&as_out_hdr_desc, | ||
862 | (struct usb_descriptor_header *)&as_out_fmt1_desc, | ||
863 | (struct usb_descriptor_header *)&fs_epout_desc, | ||
864 | (struct usb_descriptor_header *)&as_iso_out_desc, | ||
865 | |||
866 | (struct usb_descriptor_header *)&std_as_in_if0_desc, | ||
867 | (struct usb_descriptor_header *)&std_as_in_if1_desc, | ||
868 | |||
869 | (struct usb_descriptor_header *)&as_in_hdr_desc, | ||
870 | (struct usb_descriptor_header *)&as_in_fmt1_desc, | ||
871 | (struct usb_descriptor_header *)&fs_epin_desc, | ||
872 | (struct usb_descriptor_header *)&as_iso_in_desc, | ||
873 | NULL, | ||
874 | }; | ||
875 | |||
876 | static struct usb_descriptor_header *hs_audio_desc[] = { | ||
877 | (struct usb_descriptor_header *)&iad_desc, | ||
878 | (struct usb_descriptor_header *)&std_ac_if_desc, | ||
879 | |||
880 | (struct usb_descriptor_header *)&ac_hdr_desc, | ||
881 | (struct usb_descriptor_header *)&in_clk_src_desc, | ||
882 | (struct usb_descriptor_header *)&out_clk_src_desc, | ||
883 | (struct usb_descriptor_header *)&usb_out_it_desc, | ||
884 | (struct usb_descriptor_header *)&io_in_it_desc, | ||
885 | (struct usb_descriptor_header *)&usb_in_ot_desc, | ||
886 | (struct usb_descriptor_header *)&io_out_ot_desc, | ||
887 | |||
888 | (struct usb_descriptor_header *)&std_as_out_if0_desc, | ||
889 | (struct usb_descriptor_header *)&std_as_out_if1_desc, | ||
890 | |||
891 | (struct usb_descriptor_header *)&as_out_hdr_desc, | ||
892 | (struct usb_descriptor_header *)&as_out_fmt1_desc, | ||
893 | (struct usb_descriptor_header *)&hs_epout_desc, | ||
894 | (struct usb_descriptor_header *)&as_iso_out_desc, | ||
895 | |||
896 | (struct usb_descriptor_header *)&std_as_in_if0_desc, | ||
897 | (struct usb_descriptor_header *)&std_as_in_if1_desc, | ||
898 | |||
899 | (struct usb_descriptor_header *)&as_in_hdr_desc, | ||
900 | (struct usb_descriptor_header *)&as_in_fmt1_desc, | ||
901 | (struct usb_descriptor_header *)&hs_epin_desc, | ||
902 | (struct usb_descriptor_header *)&as_iso_in_desc, | ||
903 | NULL, | ||
904 | }; | ||
905 | |||
906 | struct cntrl_cur_lay3 { | ||
907 | __u32 dCUR; | ||
908 | }; | ||
909 | |||
910 | struct cntrl_range_lay3 { | ||
911 | __u16 wNumSubRanges; | ||
912 | __u32 dMIN; | ||
913 | __u32 dMAX; | ||
914 | __u32 dRES; | ||
915 | } __packed; | ||
916 | |||
917 | static inline void | ||
918 | free_ep(struct uac2_rtd_params *prm, struct usb_ep *ep) | ||
919 | { | ||
920 | struct snd_uac2_chip *uac2 = prm_to_uac2(prm); | ||
921 | int i; | ||
922 | |||
923 | prm->ep_enabled = false; | ||
924 | |||
925 | for (i = 0; i < USB_XFERS; i++) { | ||
926 | if (prm->ureq[i].req) { | ||
927 | usb_ep_dequeue(ep, prm->ureq[i].req); | ||
928 | usb_ep_free_request(ep, prm->ureq[i].req); | ||
929 | prm->ureq[i].req = NULL; | ||
930 | } | ||
931 | } | ||
932 | |||
933 | if (usb_ep_disable(ep)) | ||
934 | dev_err(&uac2->pdev.dev, | ||
935 | "%s:%d Error!\n", __func__, __LINE__); | ||
936 | } | ||
937 | |||
938 | static int __init | ||
939 | afunc_bind(struct usb_configuration *cfg, struct usb_function *fn) | ||
940 | { | ||
941 | struct audio_dev *agdev = func_to_agdev(fn); | ||
942 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
943 | struct usb_composite_dev *cdev = cfg->cdev; | ||
944 | struct usb_gadget *gadget = cdev->gadget; | ||
945 | struct uac2_rtd_params *prm; | ||
946 | int ret; | ||
947 | |||
948 | ret = usb_interface_id(cfg, fn); | ||
949 | if (ret < 0) { | ||
950 | dev_err(&uac2->pdev.dev, | ||
951 | "%s:%d Error!\n", __func__, __LINE__); | ||
952 | return ret; | ||
953 | } | ||
954 | std_ac_if_desc.bInterfaceNumber = ret; | ||
955 | ALT_SET(agdev->ac_alt, 0); | ||
956 | INTF_SET(agdev->ac_alt, ret); | ||
957 | |||
958 | ret = usb_interface_id(cfg, fn); | ||
959 | if (ret < 0) { | ||
960 | dev_err(&uac2->pdev.dev, | ||
961 | "%s:%d Error!\n", __func__, __LINE__); | ||
962 | return ret; | ||
963 | } | ||
964 | std_as_out_if0_desc.bInterfaceNumber = ret; | ||
965 | std_as_out_if1_desc.bInterfaceNumber = ret; | ||
966 | ALT_SET(agdev->as_out_alt, 0); | ||
967 | INTF_SET(agdev->as_out_alt, ret); | ||
968 | |||
969 | ret = usb_interface_id(cfg, fn); | ||
970 | if (ret < 0) { | ||
971 | dev_err(&uac2->pdev.dev, | ||
972 | "%s:%d Error!\n", __func__, __LINE__); | ||
973 | return ret; | ||
974 | } | ||
975 | std_as_in_if0_desc.bInterfaceNumber = ret; | ||
976 | std_as_in_if1_desc.bInterfaceNumber = ret; | ||
977 | ALT_SET(agdev->as_in_alt, 0); | ||
978 | INTF_SET(agdev->as_in_alt, ret); | ||
979 | |||
980 | agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc); | ||
981 | if (!agdev->out_ep) | ||
982 | dev_err(&uac2->pdev.dev, | ||
983 | "%s:%d Error!\n", __func__, __LINE__); | ||
984 | agdev->out_ep->driver_data = agdev; | ||
985 | |||
986 | agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc); | ||
987 | if (!agdev->in_ep) | ||
988 | dev_err(&uac2->pdev.dev, | ||
989 | "%s:%d Error!\n", __func__, __LINE__); | ||
990 | agdev->in_ep->driver_data = agdev; | ||
991 | |||
992 | hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress; | ||
993 | hs_epout_desc.wMaxPacketSize = fs_epout_desc.wMaxPacketSize; | ||
994 | hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress; | ||
995 | hs_epin_desc.wMaxPacketSize = fs_epin_desc.wMaxPacketSize; | ||
996 | |||
997 | fn->descriptors = usb_copy_descriptors(fs_audio_desc); | ||
998 | if (gadget_is_dualspeed(gadget)) | ||
999 | fn->hs_descriptors = usb_copy_descriptors(hs_audio_desc); | ||
1000 | |||
1001 | prm = &agdev->uac2.c_prm; | ||
1002 | prm->max_psize = hs_epout_desc.wMaxPacketSize; | ||
1003 | prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); | ||
1004 | if (!prm->rbuf) { | ||
1005 | prm->max_psize = 0; | ||
1006 | dev_err(&uac2->pdev.dev, | ||
1007 | "%s:%d Error!\n", __func__, __LINE__); | ||
1008 | } | ||
1009 | |||
1010 | prm = &agdev->uac2.p_prm; | ||
1011 | prm->max_psize = hs_epin_desc.wMaxPacketSize; | ||
1012 | prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL); | ||
1013 | if (!prm->rbuf) { | ||
1014 | prm->max_psize = 0; | ||
1015 | dev_err(&uac2->pdev.dev, | ||
1016 | "%s:%d Error!\n", __func__, __LINE__); | ||
1017 | } | ||
1018 | |||
1019 | return alsa_uac2_init(agdev); | ||
1020 | } | ||
1021 | |||
1022 | static void | ||
1023 | afunc_unbind(struct usb_configuration *cfg, struct usb_function *fn) | ||
1024 | { | ||
1025 | 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; | ||
1029 | |||
1030 | alsa_uac2_exit(agdev); | ||
1031 | |||
1032 | prm = &agdev->uac2.p_prm; | ||
1033 | kfree(prm->rbuf); | ||
1034 | |||
1035 | prm = &agdev->uac2.c_prm; | ||
1036 | kfree(prm->rbuf); | ||
1037 | |||
1038 | if (gadget_is_dualspeed(gadget)) | ||
1039 | usb_free_descriptors(fn->hs_descriptors); | ||
1040 | usb_free_descriptors(fn->descriptors); | ||
1041 | |||
1042 | if (agdev->in_ep) | ||
1043 | agdev->in_ep->driver_data = NULL; | ||
1044 | if (agdev->out_ep) | ||
1045 | agdev->out_ep->driver_data = NULL; | ||
1046 | } | ||
1047 | |||
1048 | static int | ||
1049 | afunc_set_alt(struct usb_function *fn, unsigned intf, unsigned alt) | ||
1050 | { | ||
1051 | struct usb_composite_dev *cdev = fn->config->cdev; | ||
1052 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1053 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1054 | struct usb_gadget *gadget = cdev->gadget; | ||
1055 | struct usb_request *req; | ||
1056 | struct usb_ep *ep; | ||
1057 | struct uac2_rtd_params *prm; | ||
1058 | int i; | ||
1059 | |||
1060 | /* No i/f has more than 2 alt settings */ | ||
1061 | if (alt > 1) { | ||
1062 | dev_err(&uac2->pdev.dev, | ||
1063 | "%s:%d Error!\n", __func__, __LINE__); | ||
1064 | return -EINVAL; | ||
1065 | } | ||
1066 | |||
1067 | if (intf == INTF_GET(agdev->ac_alt)) { | ||
1068 | /* Control I/f has only 1 AltSetting - 0 */ | ||
1069 | if (alt) { | ||
1070 | dev_err(&uac2->pdev.dev, | ||
1071 | "%s:%d Error!\n", __func__, __LINE__); | ||
1072 | return -EINVAL; | ||
1073 | } | ||
1074 | return 0; | ||
1075 | } | ||
1076 | |||
1077 | if (intf == INTF_GET(agdev->as_out_alt)) { | ||
1078 | ep = agdev->out_ep; | ||
1079 | prm = &uac2->c_prm; | ||
1080 | config_ep_by_speed(gadget, fn, ep); | ||
1081 | ALT_SET(agdev->as_out_alt, alt); | ||
1082 | } else if (intf == INTF_GET(agdev->as_in_alt)) { | ||
1083 | ep = agdev->in_ep; | ||
1084 | prm = &uac2->p_prm; | ||
1085 | config_ep_by_speed(gadget, fn, ep); | ||
1086 | ALT_SET(agdev->as_in_alt, alt); | ||
1087 | } else { | ||
1088 | dev_err(&uac2->pdev.dev, | ||
1089 | "%s:%d Error!\n", __func__, __LINE__); | ||
1090 | return -EINVAL; | ||
1091 | } | ||
1092 | |||
1093 | if (alt == 0) { | ||
1094 | free_ep(prm, ep); | ||
1095 | return 0; | ||
1096 | } | ||
1097 | |||
1098 | prm->ep_enabled = true; | ||
1099 | usb_ep_enable(ep); | ||
1100 | |||
1101 | for (i = 0; i < USB_XFERS; i++) { | ||
1102 | if (prm->ureq[i].req) { | ||
1103 | if (usb_ep_queue(ep, prm->ureq[i].req, GFP_ATOMIC)) | ||
1104 | dev_err(&uac2->pdev.dev, "%d Error!\n", | ||
1105 | __LINE__); | ||
1106 | continue; | ||
1107 | } | ||
1108 | |||
1109 | req = usb_ep_alloc_request(ep, GFP_ATOMIC); | ||
1110 | if (req == NULL) { | ||
1111 | dev_err(&uac2->pdev.dev, | ||
1112 | "%s:%d Error!\n", __func__, __LINE__); | ||
1113 | return -EINVAL; | ||
1114 | } | ||
1115 | |||
1116 | prm->ureq[i].req = req; | ||
1117 | prm->ureq[i].pp = prm; | ||
1118 | |||
1119 | req->zero = 0; | ||
1120 | req->dma = DMA_ADDR_INVALID; | ||
1121 | req->context = &prm->ureq[i]; | ||
1122 | req->length = prm->max_psize; | ||
1123 | req->complete = agdev_iso_complete; | ||
1124 | req->buf = prm->rbuf + i * req->length; | ||
1125 | |||
1126 | if (usb_ep_queue(ep, req, GFP_ATOMIC)) | ||
1127 | dev_err(&uac2->pdev.dev, "%d Error!\n", __LINE__); | ||
1128 | } | ||
1129 | |||
1130 | return 0; | ||
1131 | } | ||
1132 | |||
1133 | static int | ||
1134 | afunc_get_alt(struct usb_function *fn, unsigned intf) | ||
1135 | { | ||
1136 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1137 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1138 | |||
1139 | if (intf == INTF_GET(agdev->ac_alt)) | ||
1140 | return ALT_GET(agdev->ac_alt); | ||
1141 | else if (intf == INTF_GET(agdev->as_out_alt)) | ||
1142 | return ALT_GET(agdev->as_out_alt); | ||
1143 | else if (intf == INTF_GET(agdev->as_in_alt)) | ||
1144 | return ALT_GET(agdev->as_in_alt); | ||
1145 | else | ||
1146 | dev_err(&uac2->pdev.dev, | ||
1147 | "%s:%d Invalid Interface %d!\n", | ||
1148 | __func__, __LINE__, intf); | ||
1149 | |||
1150 | return -EINVAL; | ||
1151 | } | ||
1152 | |||
1153 | static void | ||
1154 | afunc_disable(struct usb_function *fn) | ||
1155 | { | ||
1156 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1157 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1158 | |||
1159 | free_ep(&uac2->p_prm, agdev->in_ep); | ||
1160 | ALT_SET(agdev->as_in_alt, 0); | ||
1161 | |||
1162 | free_ep(&uac2->c_prm, agdev->out_ep); | ||
1163 | ALT_SET(agdev->as_out_alt, 0); | ||
1164 | } | ||
1165 | |||
1166 | static int | ||
1167 | in_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr) | ||
1168 | { | ||
1169 | struct usb_request *req = fn->config->cdev->req; | ||
1170 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1171 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1172 | u16 w_length = le16_to_cpu(cr->wLength); | ||
1173 | u16 w_index = le16_to_cpu(cr->wIndex); | ||
1174 | u16 w_value = le16_to_cpu(cr->wValue); | ||
1175 | u8 entity_id = (w_index >> 8) & 0xff; | ||
1176 | u8 control_selector = w_value >> 8; | ||
1177 | int value = -EOPNOTSUPP; | ||
1178 | |||
1179 | if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { | ||
1180 | struct cntrl_cur_lay3 c; | ||
1181 | |||
1182 | if (entity_id == USB_IN_CLK_ID) | ||
1183 | c.dCUR = p_srate; | ||
1184 | else if (entity_id == USB_OUT_CLK_ID) | ||
1185 | c.dCUR = c_srate; | ||
1186 | |||
1187 | value = min_t(unsigned, w_length, sizeof c); | ||
1188 | memcpy(req->buf, &c, value); | ||
1189 | } else if (control_selector == UAC2_CS_CONTROL_CLOCK_VALID) { | ||
1190 | *(u8 *)req->buf = 1; | ||
1191 | value = min_t(unsigned, w_length, 1); | ||
1192 | } else { | ||
1193 | dev_err(&uac2->pdev.dev, | ||
1194 | "%s:%d control_selector=%d TODO!\n", | ||
1195 | __func__, __LINE__, control_selector); | ||
1196 | } | ||
1197 | |||
1198 | return value; | ||
1199 | } | ||
1200 | |||
1201 | static int | ||
1202 | in_rq_range(struct usb_function *fn, const struct usb_ctrlrequest *cr) | ||
1203 | { | ||
1204 | struct usb_request *req = fn->config->cdev->req; | ||
1205 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1206 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1207 | u16 w_length = le16_to_cpu(cr->wLength); | ||
1208 | u16 w_index = le16_to_cpu(cr->wIndex); | ||
1209 | u16 w_value = le16_to_cpu(cr->wValue); | ||
1210 | u8 entity_id = (w_index >> 8) & 0xff; | ||
1211 | u8 control_selector = w_value >> 8; | ||
1212 | struct cntrl_range_lay3 r; | ||
1213 | int value = -EOPNOTSUPP; | ||
1214 | |||
1215 | if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) { | ||
1216 | if (entity_id == USB_IN_CLK_ID) | ||
1217 | r.dMIN = p_srate; | ||
1218 | else if (entity_id == USB_OUT_CLK_ID) | ||
1219 | r.dMIN = c_srate; | ||
1220 | else | ||
1221 | return -EOPNOTSUPP; | ||
1222 | |||
1223 | r.dMAX = r.dMIN; | ||
1224 | r.dRES = 0; | ||
1225 | r.wNumSubRanges = 1; | ||
1226 | |||
1227 | value = min_t(unsigned, w_length, sizeof r); | ||
1228 | memcpy(req->buf, &r, value); | ||
1229 | } else { | ||
1230 | dev_err(&uac2->pdev.dev, | ||
1231 | "%s:%d control_selector=%d TODO!\n", | ||
1232 | __func__, __LINE__, control_selector); | ||
1233 | } | ||
1234 | |||
1235 | return value; | ||
1236 | } | ||
1237 | |||
1238 | static int | ||
1239 | ac_rq_in(struct usb_function *fn, const struct usb_ctrlrequest *cr) | ||
1240 | { | ||
1241 | if (cr->bRequest == UAC2_CS_CUR) | ||
1242 | return in_rq_cur(fn, cr); | ||
1243 | else if (cr->bRequest == UAC2_CS_RANGE) | ||
1244 | return in_rq_range(fn, cr); | ||
1245 | else | ||
1246 | return -EOPNOTSUPP; | ||
1247 | } | ||
1248 | |||
1249 | static int | ||
1250 | out_rq_cur(struct usb_function *fn, const struct usb_ctrlrequest *cr) | ||
1251 | { | ||
1252 | u16 w_length = le16_to_cpu(cr->wLength); | ||
1253 | u16 w_value = le16_to_cpu(cr->wValue); | ||
1254 | u8 control_selector = w_value >> 8; | ||
1255 | |||
1256 | if (control_selector == UAC2_CS_CONTROL_SAM_FREQ) | ||
1257 | return w_length; | ||
1258 | |||
1259 | return -EOPNOTSUPP; | ||
1260 | } | ||
1261 | |||
1262 | static int | ||
1263 | setup_rq_inf(struct usb_function *fn, const struct usb_ctrlrequest *cr) | ||
1264 | { | ||
1265 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1266 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1267 | u16 w_index = le16_to_cpu(cr->wIndex); | ||
1268 | u8 intf = w_index & 0xff; | ||
1269 | |||
1270 | if (intf != INTF_GET(agdev->ac_alt)) { | ||
1271 | dev_err(&uac2->pdev.dev, | ||
1272 | "%s:%d Error!\n", __func__, __LINE__); | ||
1273 | return -EOPNOTSUPP; | ||
1274 | } | ||
1275 | |||
1276 | if (cr->bRequestType & USB_DIR_IN) | ||
1277 | return ac_rq_in(fn, cr); | ||
1278 | else if (cr->bRequest == UAC2_CS_CUR) | ||
1279 | return out_rq_cur(fn, cr); | ||
1280 | |||
1281 | return -EOPNOTSUPP; | ||
1282 | } | ||
1283 | |||
1284 | static int | ||
1285 | afunc_setup(struct usb_function *fn, const struct usb_ctrlrequest *cr) | ||
1286 | { | ||
1287 | struct usb_composite_dev *cdev = fn->config->cdev; | ||
1288 | struct audio_dev *agdev = func_to_agdev(fn); | ||
1289 | struct snd_uac2_chip *uac2 = &agdev->uac2; | ||
1290 | struct usb_request *req = cdev->req; | ||
1291 | u16 w_length = le16_to_cpu(cr->wLength); | ||
1292 | int value = -EOPNOTSUPP; | ||
1293 | |||
1294 | /* Only Class specific requests are supposed to reach here */ | ||
1295 | if ((cr->bRequestType & USB_TYPE_MASK) != USB_TYPE_CLASS) | ||
1296 | return -EOPNOTSUPP; | ||
1297 | |||
1298 | if ((cr->bRequestType & USB_RECIP_MASK) == USB_RECIP_INTERFACE) | ||
1299 | value = setup_rq_inf(fn, cr); | ||
1300 | else | ||
1301 | dev_err(&uac2->pdev.dev, "%s:%d Error!\n", __func__, __LINE__); | ||
1302 | |||
1303 | if (value >= 0) { | ||
1304 | req->length = value; | ||
1305 | req->zero = value < w_length; | ||
1306 | value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC); | ||
1307 | if (value < 0) { | ||
1308 | dev_err(&uac2->pdev.dev, | ||
1309 | "%s:%d Error!\n", __func__, __LINE__); | ||
1310 | req->status = 0; | ||
1311 | } | ||
1312 | } | ||
1313 | |||
1314 | return value; | ||
1315 | } | ||
1316 | |||
1317 | static int audio_bind_config(struct usb_configuration *cfg) | ||
1318 | { | ||
1319 | int id, res; | ||
1320 | |||
1321 | agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL); | ||
1322 | if (agdev_g == NULL) { | ||
1323 | printk(KERN_ERR "Unable to allocate audio gadget\n"); | ||
1324 | return -ENOMEM; | ||
1325 | } | ||
1326 | |||
1327 | id = usb_string_id(cfg->cdev); | ||
1328 | if (id < 0) | ||
1329 | return id; | ||
1330 | |||
1331 | strings_fn[STR_ASSOC].id = id; | ||
1332 | iad_desc.iFunction = id, | ||
1333 | |||
1334 | id = usb_string_id(cfg->cdev); | ||
1335 | if (id < 0) | ||
1336 | return id; | ||
1337 | |||
1338 | strings_fn[STR_IF_CTRL].id = id; | ||
1339 | std_ac_if_desc.iInterface = id, | ||
1340 | |||
1341 | id = usb_string_id(cfg->cdev); | ||
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 | |||
1411 | agdev_g->func.name = "uac2_func"; | ||
1412 | agdev_g->func.strings = fn_strings; | ||
1413 | agdev_g->func.bind = afunc_bind; | ||
1414 | agdev_g->func.unbind = afunc_unbind; | ||
1415 | agdev_g->func.set_alt = afunc_set_alt; | ||
1416 | agdev_g->func.get_alt = afunc_get_alt; | ||
1417 | agdev_g->func.disable = afunc_disable; | ||
1418 | agdev_g->func.setup = afunc_setup; | ||
1419 | |||
1420 | /* Initialize the configurable parameters */ | ||
1421 | usb_out_it_desc.bNrChannels = num_channels(c_chmask); | ||
1422 | usb_out_it_desc.bmChannelConfig = cpu_to_le32(c_chmask); | ||
1423 | io_in_it_desc.bNrChannels = num_channels(p_chmask); | ||
1424 | io_in_it_desc.bmChannelConfig = cpu_to_le32(p_chmask); | ||
1425 | as_out_hdr_desc.bNrChannels = num_channels(c_chmask); | ||
1426 | as_out_hdr_desc.bmChannelConfig = cpu_to_le32(c_chmask); | ||
1427 | as_in_hdr_desc.bNrChannels = num_channels(p_chmask); | ||
1428 | as_in_hdr_desc.bmChannelConfig = cpu_to_le32(p_chmask); | ||
1429 | as_out_fmt1_desc.bSubslotSize = c_ssize; | ||
1430 | as_out_fmt1_desc.bBitResolution = c_ssize * 8; | ||
1431 | as_in_fmt1_desc.bSubslotSize = p_ssize; | ||
1432 | as_in_fmt1_desc.bBitResolution = p_ssize * 8; | ||
1433 | |||
1434 | snprintf(clksrc_in, sizeof(clksrc_in), "%uHz", p_srate); | ||
1435 | snprintf(clksrc_out, sizeof(clksrc_out), "%uHz", c_srate); | ||
1436 | |||
1437 | res = usb_add_function(cfg, &agdev_g->func); | ||
1438 | if (res < 0) | ||
1439 | kfree(agdev_g); | ||
1440 | |||
1441 | return res; | ||
1442 | } | ||
1443 | |||
1444 | static void | ||
1445 | uac2_unbind_config(struct usb_configuration *cfg) | ||
1446 | { | ||
1447 | kfree(agdev_g); | ||
1448 | agdev_g = NULL; | ||
1449 | } | ||
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index 47766f0e7caa..4fac56927741 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c | |||
@@ -855,7 +855,7 @@ static int class_setup_req(struct fsg_dev *fsg, | |||
855 | if (transport_is_bbb()) { | 855 | if (transport_is_bbb()) { |
856 | switch (ctrl->bRequest) { | 856 | switch (ctrl->bRequest) { |
857 | 857 | ||
858 | case USB_BULK_RESET_REQUEST: | 858 | case US_BULK_RESET_REQUEST: |
859 | if (ctrl->bRequestType != (USB_DIR_OUT | | 859 | if (ctrl->bRequestType != (USB_DIR_OUT | |
860 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 860 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
861 | break; | 861 | break; |
@@ -871,7 +871,7 @@ static int class_setup_req(struct fsg_dev *fsg, | |||
871 | value = DELAYED_STATUS; | 871 | value = DELAYED_STATUS; |
872 | break; | 872 | break; |
873 | 873 | ||
874 | case USB_BULK_GET_MAX_LUN_REQUEST: | 874 | case US_BULK_GET_MAX_LUN: |
875 | if (ctrl->bRequestType != (USB_DIR_IN | | 875 | if (ctrl->bRequestType != (USB_DIR_IN | |
876 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) | 876 | USB_TYPE_CLASS | USB_RECIP_INTERFACE)) |
877 | break; | 877 | break; |
@@ -2125,7 +2125,7 @@ static int send_status(struct fsg_dev *fsg) | |||
2125 | struct fsg_lun *curlun = fsg->curlun; | 2125 | struct fsg_lun *curlun = fsg->curlun; |
2126 | struct fsg_buffhd *bh; | 2126 | struct fsg_buffhd *bh; |
2127 | int rc; | 2127 | int rc; |
2128 | u8 status = USB_STATUS_PASS; | 2128 | u8 status = US_BULK_STAT_OK; |
2129 | u32 sd, sdinfo = 0; | 2129 | u32 sd, sdinfo = 0; |
2130 | 2130 | ||
2131 | /* Wait for the next buffer to become available */ | 2131 | /* Wait for the next buffer to become available */ |
@@ -2146,11 +2146,11 @@ static int send_status(struct fsg_dev *fsg) | |||
2146 | 2146 | ||
2147 | if (fsg->phase_error) { | 2147 | if (fsg->phase_error) { |
2148 | DBG(fsg, "sending phase-error status\n"); | 2148 | DBG(fsg, "sending phase-error status\n"); |
2149 | status = USB_STATUS_PHASE_ERROR; | 2149 | status = US_BULK_STAT_PHASE; |
2150 | sd = SS_INVALID_COMMAND; | 2150 | sd = SS_INVALID_COMMAND; |
2151 | } else if (sd != SS_NO_SENSE) { | 2151 | } else if (sd != SS_NO_SENSE) { |
2152 | DBG(fsg, "sending command-failure status\n"); | 2152 | DBG(fsg, "sending command-failure status\n"); |
2153 | status = USB_STATUS_FAIL; | 2153 | status = US_BULK_STAT_FAIL; |
2154 | VDBG(fsg, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" | 2154 | VDBG(fsg, " sense data: SK x%02x, ASC x%02x, ASCQ x%02x;" |
2155 | " info x%x\n", | 2155 | " info x%x\n", |
2156 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); | 2156 | SK(sd), ASC(sd), ASCQ(sd), sdinfo); |
@@ -2160,12 +2160,12 @@ static int send_status(struct fsg_dev *fsg) | |||
2160 | struct bulk_cs_wrap *csw = bh->buf; | 2160 | struct bulk_cs_wrap *csw = bh->buf; |
2161 | 2161 | ||
2162 | /* Store and send the Bulk-only CSW */ | 2162 | /* Store and send the Bulk-only CSW */ |
2163 | csw->Signature = cpu_to_le32(USB_BULK_CS_SIG); | 2163 | csw->Signature = cpu_to_le32(US_BULK_CS_SIGN); |
2164 | csw->Tag = fsg->tag; | 2164 | csw->Tag = fsg->tag; |
2165 | csw->Residue = cpu_to_le32(fsg->residue); | 2165 | csw->Residue = cpu_to_le32(fsg->residue); |
2166 | csw->Status = status; | 2166 | csw->Status = status; |
2167 | 2167 | ||
2168 | bh->inreq->length = USB_BULK_CS_WRAP_LEN; | 2168 | bh->inreq->length = US_BULK_CS_WRAP_LEN; |
2169 | bh->inreq->zero = 0; | 2169 | bh->inreq->zero = 0; |
2170 | start_transfer(fsg, fsg->bulk_in, bh->inreq, | 2170 | start_transfer(fsg, fsg->bulk_in, bh->inreq, |
2171 | &bh->inreq_busy, &bh->state); | 2171 | &bh->inreq_busy, &bh->state); |
@@ -2609,16 +2609,16 @@ static int do_scsi_command(struct fsg_dev *fsg) | |||
2609 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | 2609 | static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) |
2610 | { | 2610 | { |
2611 | struct usb_request *req = bh->outreq; | 2611 | struct usb_request *req = bh->outreq; |
2612 | struct fsg_bulk_cb_wrap *cbw = req->buf; | 2612 | struct bulk_cb_wrap *cbw = req->buf; |
2613 | 2613 | ||
2614 | /* Was this a real packet? Should it be ignored? */ | 2614 | /* Was this a real packet? Should it be ignored? */ |
2615 | if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) | 2615 | if (req->status || test_bit(IGNORE_BULK_OUT, &fsg->atomic_bitflags)) |
2616 | return -EINVAL; | 2616 | return -EINVAL; |
2617 | 2617 | ||
2618 | /* Is the CBW valid? */ | 2618 | /* Is the CBW valid? */ |
2619 | if (req->actual != USB_BULK_CB_WRAP_LEN || | 2619 | if (req->actual != US_BULK_CB_WRAP_LEN || |
2620 | cbw->Signature != cpu_to_le32( | 2620 | cbw->Signature != cpu_to_le32( |
2621 | USB_BULK_CB_SIG)) { | 2621 | US_BULK_CB_SIGN)) { |
2622 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", | 2622 | DBG(fsg, "invalid CBW: len %u sig 0x%x\n", |
2623 | req->actual, | 2623 | req->actual, |
2624 | le32_to_cpu(cbw->Signature)); | 2624 | le32_to_cpu(cbw->Signature)); |
@@ -2638,7 +2638,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2638 | } | 2638 | } |
2639 | 2639 | ||
2640 | /* Is the CBW meaningful? */ | 2640 | /* Is the CBW meaningful? */ |
2641 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~USB_BULK_IN_FLAG || | 2641 | if (cbw->Lun >= FSG_MAX_LUNS || cbw->Flags & ~US_BULK_FLAG_IN || |
2642 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { | 2642 | cbw->Length <= 0 || cbw->Length > MAX_COMMAND_SIZE) { |
2643 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " | 2643 | DBG(fsg, "non-meaningful CBW: lun = %u, flags = 0x%x, " |
2644 | "cmdlen %u\n", | 2644 | "cmdlen %u\n", |
@@ -2656,7 +2656,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) | |||
2656 | /* Save the command for later */ | 2656 | /* Save the command for later */ |
2657 | fsg->cmnd_size = cbw->Length; | 2657 | fsg->cmnd_size = cbw->Length; |
2658 | memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size); | 2658 | memcpy(fsg->cmnd, cbw->CDB, fsg->cmnd_size); |
2659 | if (cbw->Flags & USB_BULK_IN_FLAG) | 2659 | if (cbw->Flags & US_BULK_FLAG_IN) |
2660 | fsg->data_dir = DATA_DIR_TO_HOST; | 2660 | fsg->data_dir = DATA_DIR_TO_HOST; |
2661 | else | 2661 | else |
2662 | fsg->data_dir = DATA_DIR_FROM_HOST; | 2662 | fsg->data_dir = DATA_DIR_FROM_HOST; |
@@ -2685,7 +2685,7 @@ static int get_next_command(struct fsg_dev *fsg) | |||
2685 | } | 2685 | } |
2686 | 2686 | ||
2687 | /* Queue a request to read a Bulk-only CBW */ | 2687 | /* Queue a request to read a Bulk-only CBW */ |
2688 | set_bulk_out_req_length(fsg, bh, USB_BULK_CB_WRAP_LEN); | 2688 | set_bulk_out_req_length(fsg, bh, US_BULK_CB_WRAP_LEN); |
2689 | start_transfer(fsg, fsg->bulk_out, bh->outreq, | 2689 | start_transfer(fsg, fsg->bulk_out, bh->outreq, |
2690 | &bh->outreq_busy, &bh->state); | 2690 | &bh->outreq_busy, &bh->state); |
2691 | 2691 | ||
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c index b95697c03d07..877a2c46672b 100644 --- a/drivers/usb/gadget/fsl_qe_udc.c +++ b/drivers/usb/gadget/fsl_qe_udc.c | |||
@@ -1638,6 +1638,7 @@ static int qe_ep_disable(struct usb_ep *_ep) | |||
1638 | /* Nuke all pending requests (does flush) */ | 1638 | /* Nuke all pending requests (does flush) */ |
1639 | nuke(ep, -ESHUTDOWN); | 1639 | nuke(ep, -ESHUTDOWN); |
1640 | ep->desc = NULL; | 1640 | ep->desc = NULL; |
1641 | ep->ep.desc = NULL; | ||
1641 | ep->stopped = 1; | 1642 | ep->stopped = 1; |
1642 | ep->tx_req = NULL; | 1643 | ep->tx_req = NULL; |
1643 | qe_ep_reset(udc, ep->epnum); | 1644 | qe_ep_reset(udc, ep->epnum); |
diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index b04712f19f1e..b30e21fdbb1b 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c | |||
@@ -659,6 +659,7 @@ static int fsl_ep_disable(struct usb_ep *_ep) | |||
659 | nuke(ep, -ESHUTDOWN); | 659 | nuke(ep, -ESHUTDOWN); |
660 | 660 | ||
661 | ep->desc = NULL; | 661 | ep->desc = NULL; |
662 | ep->ep.desc = NULL; | ||
662 | ep->stopped = 1; | 663 | ep->stopped = 1; |
663 | spin_unlock_irqrestore(&udc->lock, flags); | 664 | spin_unlock_irqrestore(&udc->lock, flags); |
664 | 665 | ||
@@ -768,7 +769,7 @@ static void fsl_queue_td(struct fsl_ep *ep, struct fsl_req *req) | |||
768 | * @is_last: return flag if it is the last dTD of the request | 769 | * @is_last: return flag if it is the last dTD of the request |
769 | * return: pointer to the built dTD */ | 770 | * return: pointer to the built dTD */ |
770 | static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, | 771 | static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, |
771 | dma_addr_t *dma, int *is_last) | 772 | dma_addr_t *dma, int *is_last, gfp_t gfp_flags) |
772 | { | 773 | { |
773 | u32 swap_temp; | 774 | u32 swap_temp; |
774 | struct ep_td_struct *dtd; | 775 | struct ep_td_struct *dtd; |
@@ -777,7 +778,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, | |||
777 | *length = min(req->req.length - req->req.actual, | 778 | *length = min(req->req.length - req->req.actual, |
778 | (unsigned)EP_MAX_LENGTH_TRANSFER); | 779 | (unsigned)EP_MAX_LENGTH_TRANSFER); |
779 | 780 | ||
780 | dtd = dma_pool_alloc(udc_controller->td_pool, GFP_KERNEL, dma); | 781 | dtd = dma_pool_alloc(udc_controller->td_pool, gfp_flags, dma); |
781 | if (dtd == NULL) | 782 | if (dtd == NULL) |
782 | return dtd; | 783 | return dtd; |
783 | 784 | ||
@@ -827,7 +828,7 @@ static struct ep_td_struct *fsl_build_dtd(struct fsl_req *req, unsigned *length, | |||
827 | } | 828 | } |
828 | 829 | ||
829 | /* Generate dtd chain for a request */ | 830 | /* Generate dtd chain for a request */ |
830 | static int fsl_req_to_dtd(struct fsl_req *req) | 831 | static int fsl_req_to_dtd(struct fsl_req *req, gfp_t gfp_flags) |
831 | { | 832 | { |
832 | unsigned count; | 833 | unsigned count; |
833 | int is_last; | 834 | int is_last; |
@@ -836,7 +837,7 @@ static int fsl_req_to_dtd(struct fsl_req *req) | |||
836 | dma_addr_t dma; | 837 | dma_addr_t dma; |
837 | 838 | ||
838 | do { | 839 | do { |
839 | dtd = fsl_build_dtd(req, &count, &dma, &is_last); | 840 | dtd = fsl_build_dtd(req, &count, &dma, &is_last, gfp_flags); |
840 | if (dtd == NULL) | 841 | if (dtd == NULL) |
841 | return -ENOMEM; | 842 | return -ENOMEM; |
842 | 843 | ||
@@ -910,13 +911,11 @@ fsl_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
910 | req->req.actual = 0; | 911 | req->req.actual = 0; |
911 | req->dtd_count = 0; | 912 | req->dtd_count = 0; |
912 | 913 | ||
913 | spin_lock_irqsave(&udc->lock, flags); | ||
914 | |||
915 | /* build dtds and push them to device queue */ | 914 | /* build dtds and push them to device queue */ |
916 | if (!fsl_req_to_dtd(req)) { | 915 | if (!fsl_req_to_dtd(req, gfp_flags)) { |
916 | spin_lock_irqsave(&udc->lock, flags); | ||
917 | fsl_queue_td(ep, req); | 917 | fsl_queue_td(ep, req); |
918 | } else { | 918 | } else { |
919 | spin_unlock_irqrestore(&udc->lock, flags); | ||
920 | return -ENOMEM; | 919 | return -ENOMEM; |
921 | } | 920 | } |
922 | 921 | ||
@@ -1217,7 +1216,7 @@ static int fsl_vbus_draw(struct usb_gadget *gadget, unsigned mA) | |||
1217 | 1216 | ||
1218 | udc = container_of(gadget, struct fsl_udc, gadget); | 1217 | udc = container_of(gadget, struct fsl_udc, gadget); |
1219 | if (udc->transceiver) | 1218 | if (udc->transceiver) |
1220 | return otg_set_power(udc->transceiver, mA); | 1219 | return usb_phy_set_power(udc->transceiver, mA); |
1221 | return -ENOTSUPP; | 1220 | return -ENOTSUPP; |
1222 | } | 1221 | } |
1223 | 1222 | ||
@@ -1295,7 +1294,7 @@ static int ep0_prime_status(struct fsl_udc *udc, int direction) | |||
1295 | ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 1294 | ep_is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); |
1296 | req->mapped = 1; | 1295 | req->mapped = 1; |
1297 | 1296 | ||
1298 | if (fsl_req_to_dtd(req) == 0) | 1297 | if (fsl_req_to_dtd(req, GFP_ATOMIC) == 0) |
1299 | fsl_queue_td(ep, req); | 1298 | fsl_queue_td(ep, req); |
1300 | else | 1299 | else |
1301 | return -ENOMEM; | 1300 | return -ENOMEM; |
@@ -1379,7 +1378,7 @@ static void ch9getstatus(struct fsl_udc *udc, u8 request_type, u16 value, | |||
1379 | req->mapped = 1; | 1378 | req->mapped = 1; |
1380 | 1379 | ||
1381 | /* prime the data phase */ | 1380 | /* prime the data phase */ |
1382 | if ((fsl_req_to_dtd(req) == 0)) | 1381 | if ((fsl_req_to_dtd(req, GFP_ATOMIC) == 0)) |
1383 | fsl_queue_td(ep, req); | 1382 | fsl_queue_td(ep, req); |
1384 | else /* no mem */ | 1383 | else /* no mem */ |
1385 | goto stall; | 1384 | goto stall; |
@@ -1966,7 +1965,8 @@ static int fsl_start(struct usb_gadget_driver *driver, | |||
1966 | 1965 | ||
1967 | /* connect to bus through transceiver */ | 1966 | /* connect to bus through transceiver */ |
1968 | if (udc_controller->transceiver) { | 1967 | if (udc_controller->transceiver) { |
1969 | retval = otg_set_peripheral(udc_controller->transceiver, | 1968 | retval = otg_set_peripheral( |
1969 | udc_controller->transceiver->otg, | ||
1970 | &udc_controller->gadget); | 1970 | &udc_controller->gadget); |
1971 | if (retval < 0) { | 1971 | if (retval < 0) { |
1972 | ERR("can't bind to transceiver\n"); | 1972 | ERR("can't bind to transceiver\n"); |
@@ -2006,7 +2006,7 @@ static int fsl_stop(struct usb_gadget_driver *driver) | |||
2006 | return -EINVAL; | 2006 | return -EINVAL; |
2007 | 2007 | ||
2008 | if (udc_controller->transceiver) | 2008 | if (udc_controller->transceiver) |
2009 | otg_set_peripheral(udc_controller->transceiver, NULL); | 2009 | otg_set_peripheral(udc_controller->transceiver->otg, NULL); |
2010 | 2010 | ||
2011 | /* stop DR, disable intr */ | 2011 | /* stop DR, disable intr */ |
2012 | dr_controller_stop(udc_controller); | 2012 | dr_controller_stop(udc_controller); |
@@ -2430,7 +2430,7 @@ static int __init fsl_udc_probe(struct platform_device *pdev) | |||
2430 | 2430 | ||
2431 | #ifdef CONFIG_USB_OTG | 2431 | #ifdef CONFIG_USB_OTG |
2432 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { | 2432 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { |
2433 | udc_controller->transceiver = otg_get_transceiver(); | 2433 | udc_controller->transceiver = usb_get_transceiver(); |
2434 | if (!udc_controller->transceiver) { | 2434 | if (!udc_controller->transceiver) { |
2435 | ERR("Can't find OTG driver!\n"); | 2435 | ERR("Can't find OTG driver!\n"); |
2436 | ret = -ENODEV; | 2436 | ret = -ENODEV; |
diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index f781f5dec417..e651469fd39b 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h | |||
@@ -471,7 +471,7 @@ struct fsl_udc { | |||
471 | 471 | ||
472 | struct usb_ctrlrequest local_setup_buff; | 472 | struct usb_ctrlrequest local_setup_buff; |
473 | spinlock_t lock; | 473 | spinlock_t lock; |
474 | struct otg_transceiver *transceiver; | 474 | struct usb_phy *transceiver; |
475 | unsigned softconnect:1; | 475 | unsigned softconnect:1; |
476 | unsigned vbus_active:1; | 476 | unsigned vbus_active:1; |
477 | unsigned stopped:1; | 477 | unsigned stopped:1; |
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index 0519d77915ec..331cd6729d3c 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * g_ffs.c -- user mode file system API for USB composite function controllers | 2 | * g_ffs.c -- user mode file system API for USB composite function controllers |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Samsung Electronics | 4 | * Copyright (C) 2010 Samsung Electronics |
5 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 5 | * Author: Michal Nazarewicz <mina86@mina86.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c index 5af70fcce139..e1dfd32dc805 100644 --- a/drivers/usb/gadget/goku_udc.c +++ b/drivers/usb/gadget/goku_udc.c | |||
@@ -235,6 +235,7 @@ static void ep_reset(struct goku_udc_regs __iomem *regs, struct goku_ep *ep) | |||
235 | 235 | ||
236 | ep->ep.maxpacket = MAX_FIFO_SIZE; | 236 | ep->ep.maxpacket = MAX_FIFO_SIZE; |
237 | ep->desc = NULL; | 237 | ep->desc = NULL; |
238 | ep->ep.desc = NULL; | ||
238 | ep->stopped = 1; | 239 | ep->stopped = 1; |
239 | ep->irqs = 0; | 240 | ep->irqs = 0; |
240 | ep->dma = 0; | 241 | ep->dma = 0; |
@@ -310,12 +311,9 @@ done(struct goku_ep *ep, struct goku_request *req, int status) | |||
310 | status = req->req.status; | 311 | status = req->req.status; |
311 | 312 | ||
312 | dev = ep->dev; | 313 | dev = ep->dev; |
313 | if (req->mapped) { | 314 | |
314 | pci_unmap_single(dev->pdev, req->req.dma, req->req.length, | 315 | if (ep->dma) |
315 | ep->is_in ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | 316 | usb_gadget_unmap_request(&dev->gadget, &req->req, ep->is_in); |
316 | req->req.dma = DMA_ADDR_INVALID; | ||
317 | req->mapped = 0; | ||
318 | } | ||
319 | 317 | ||
320 | #ifndef USB_TRACE | 318 | #ifndef USB_TRACE |
321 | if (status && status != -ESHUTDOWN) | 319 | if (status && status != -ESHUTDOWN) |
@@ -736,10 +734,11 @@ goku_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
736 | return -EBUSY; | 734 | return -EBUSY; |
737 | 735 | ||
738 | /* set up dma mapping in case the caller didn't */ | 736 | /* set up dma mapping in case the caller didn't */ |
739 | if (ep->dma && _req->dma == DMA_ADDR_INVALID) { | 737 | if (ep->dma) { |
740 | _req->dma = pci_map_single(dev->pdev, _req->buf, _req->length, | 738 | status = usb_gadget_map_request(&dev->gadget, &req->req, |
741 | ep->is_in ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | 739 | ep->is_in); |
742 | req->mapped = 1; | 740 | if (status) |
741 | return status; | ||
743 | } | 742 | } |
744 | 743 | ||
745 | #ifdef USB_TRACE | 744 | #ifdef USB_TRACE |
diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index f888c3ede860..3493adf064f5 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c | |||
@@ -60,9 +60,9 @@ static struct usb_device_descriptor device_desc = { | |||
60 | /* .bDeviceClass = USB_CLASS_COMM, */ | 60 | /* .bDeviceClass = USB_CLASS_COMM, */ |
61 | /* .bDeviceSubClass = 0, */ | 61 | /* .bDeviceSubClass = 0, */ |
62 | /* .bDeviceProtocol = 0, */ | 62 | /* .bDeviceProtocol = 0, */ |
63 | .bDeviceClass = 0xEF, | 63 | .bDeviceClass = USB_CLASS_PER_INTERFACE, |
64 | .bDeviceSubClass = 2, | 64 | .bDeviceSubClass = 0, |
65 | .bDeviceProtocol = 1, | 65 | .bDeviceProtocol = 0, |
66 | /* .bMaxPacketSize0 = f(hardware) */ | 66 | /* .bMaxPacketSize0 = f(hardware) */ |
67 | 67 | ||
68 | /* Vendor and product id can be overridden by module parameters. */ | 68 | /* Vendor and product id can be overridden by module parameters. */ |
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index ae04266dba1b..4f18a0e46070 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -1043,6 +1043,8 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) | |||
1043 | // FIXME don't call this with the spinlock held ... | 1043 | // FIXME don't call this with the spinlock held ... |
1044 | if (copy_to_user (buf, dev->req->buf, len)) | 1044 | if (copy_to_user (buf, dev->req->buf, len)) |
1045 | retval = -EFAULT; | 1045 | retval = -EFAULT; |
1046 | else | ||
1047 | retval = len; | ||
1046 | clean_req (dev->gadget->ep0, dev->req); | 1048 | clean_req (dev->gadget->ep0, dev->req); |
1047 | /* NOTE userspace can't yet choose to stall */ | 1049 | /* NOTE userspace can't yet choose to stall */ |
1048 | } | 1050 | } |
diff --git a/drivers/usb/gadget/langwell_udc.c b/drivers/usb/gadget/langwell_udc.c index e2293c1588ee..edd52d963f14 100644 --- a/drivers/usb/gadget/langwell_udc.c +++ b/drivers/usb/gadget/langwell_udc.c | |||
@@ -401,16 +401,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req, | |||
401 | dma_pool_free(dev->dtd_pool, curr_dtd, curr_dtd->dtd_dma); | 401 | dma_pool_free(dev->dtd_pool, curr_dtd, curr_dtd->dtd_dma); |
402 | } | 402 | } |
403 | 403 | ||
404 | if (req->mapped) { | 404 | usb_gadget_unmap_request(&dev->gadget, &req->req, is_in(ep)); |
405 | dma_unmap_single(&dev->pdev->dev, | ||
406 | req->req.dma, req->req.length, | ||
407 | is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | ||
408 | req->req.dma = DMA_ADDR_INVALID; | ||
409 | req->mapped = 0; | ||
410 | } else | ||
411 | dma_sync_single_for_cpu(&dev->pdev->dev, req->req.dma, | ||
412 | req->req.length, | ||
413 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
414 | 405 | ||
415 | if (status != -ESHUTDOWN) | 406 | if (status != -ESHUTDOWN) |
416 | dev_dbg(&dev->pdev->dev, | 407 | dev_dbg(&dev->pdev->dev, |
@@ -487,6 +478,7 @@ static int langwell_ep_disable(struct usb_ep *_ep) | |||
487 | nuke(ep, -ESHUTDOWN); | 478 | nuke(ep, -ESHUTDOWN); |
488 | 479 | ||
489 | ep->desc = NULL; | 480 | ep->desc = NULL; |
481 | ep->ep.desc = NULL; | ||
490 | ep->stopped = 1; | 482 | ep->stopped = 1; |
491 | 483 | ||
492 | spin_unlock_irqrestore(&dev->lock, flags); | 484 | spin_unlock_irqrestore(&dev->lock, flags); |
@@ -749,7 +741,8 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
749 | struct langwell_ep *ep; | 741 | struct langwell_ep *ep; |
750 | struct langwell_udc *dev; | 742 | struct langwell_udc *dev; |
751 | unsigned long flags; | 743 | unsigned long flags; |
752 | int is_iso = 0, zlflag = 0; | 744 | int is_iso = 0; |
745 | int ret; | ||
753 | 746 | ||
754 | /* always require a cpu-view buffer */ | 747 | /* always require a cpu-view buffer */ |
755 | req = container_of(_req, struct langwell_request, req); | 748 | req = container_of(_req, struct langwell_request, req); |
@@ -776,33 +769,10 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
776 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) | 769 | if (unlikely(!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)) |
777 | return -ESHUTDOWN; | 770 | return -ESHUTDOWN; |
778 | 771 | ||
779 | /* set up dma mapping in case the caller didn't */ | 772 | /* set up dma mapping */ |
780 | if (_req->dma == DMA_ADDR_INVALID) { | 773 | ret = usb_gadget_map_request(&dev->gadget, &req->req, is_in(ep)); |
781 | /* WORKAROUND: WARN_ON(size == 0) */ | 774 | if (ret) |
782 | if (_req->length == 0) { | 775 | return ret; |
783 | dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n"); | ||
784 | zlflag = 1; | ||
785 | _req->length++; | ||
786 | } | ||
787 | |||
788 | _req->dma = dma_map_single(&dev->pdev->dev, | ||
789 | _req->buf, _req->length, | ||
790 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
791 | if (zlflag && (_req->length == 1)) { | ||
792 | dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n"); | ||
793 | zlflag = 0; | ||
794 | _req->length = 0; | ||
795 | } | ||
796 | |||
797 | req->mapped = 1; | ||
798 | dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n"); | ||
799 | } else { | ||
800 | dma_sync_single_for_device(&dev->pdev->dev, | ||
801 | _req->dma, _req->length, | ||
802 | is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
803 | req->mapped = 0; | ||
804 | dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n"); | ||
805 | } | ||
806 | 776 | ||
807 | dev_dbg(&dev->pdev->dev, | 777 | dev_dbg(&dev->pdev->dev, |
808 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", | 778 | "%s queue req %p, len %u, buf %p, dma 0x%08x\n", |
@@ -1261,9 +1231,9 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
1261 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); | 1231 | dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__); |
1262 | 1232 | ||
1263 | if (dev->transceiver) { | 1233 | if (dev->transceiver) { |
1264 | dev_vdbg(&dev->pdev->dev, "otg_set_power\n"); | 1234 | dev_vdbg(&dev->pdev->dev, "usb_phy_set_power\n"); |
1265 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | 1235 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
1266 | return otg_set_power(dev->transceiver, mA); | 1236 | return usb_phy_set_power(dev->transceiver, mA); |
1267 | } | 1237 | } |
1268 | 1238 | ||
1269 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); | 1239 | dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__); |
@@ -1906,7 +1876,7 @@ static int langwell_stop(struct usb_gadget *g, | |||
1906 | 1876 | ||
1907 | /* unbind OTG transceiver */ | 1877 | /* unbind OTG transceiver */ |
1908 | if (dev->transceiver) | 1878 | if (dev->transceiver) |
1909 | (void)otg_set_peripheral(dev->transceiver, 0); | 1879 | (void)otg_set_peripheral(dev->transceiver->otg, 0); |
1910 | 1880 | ||
1911 | /* disable interrupt and set controller to stop state */ | 1881 | /* disable interrupt and set controller to stop state */ |
1912 | langwell_udc_stop(dev); | 1882 | langwell_udc_stop(dev); |
diff --git a/drivers/usb/gadget/langwell_udc.h b/drivers/usb/gadget/langwell_udc.h index d6e78accaffe..8c8087abb481 100644 --- a/drivers/usb/gadget/langwell_udc.h +++ b/drivers/usb/gadget/langwell_udc.h | |||
@@ -162,7 +162,7 @@ struct langwell_udc { | |||
162 | spinlock_t lock; /* device lock */ | 162 | spinlock_t lock; /* device lock */ |
163 | struct langwell_ep *ep; | 163 | struct langwell_ep *ep; |
164 | struct usb_gadget_driver *driver; | 164 | struct usb_gadget_driver *driver; |
165 | struct otg_transceiver *transceiver; | 165 | struct usb_phy *transceiver; |
166 | u8 dev_addr; | 166 | u8 dev_addr; |
167 | u32 usb_state; | 167 | u32 usb_state; |
168 | u32 resume_state; | 168 | u32 resume_state; |
diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index e24f72f82a47..1f376eba31f6 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2003-2008 Alan Stern | 4 | * Copyright (C) 2003-2008 Alan Stern |
5 | * Copyright (C) 2009 Samsung Electronics | 5 | * Copyright (C) 2009 Samsung Electronics |
6 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 6 | * Author: Michal Nazarewicz <mina86@mina86.com> |
7 | * All rights reserved. | 7 | * All rights reserved. |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 7e7f515b8b19..c37fb33a3d1b 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (C) 2008 David Brownell | 4 | * Copyright (C) 2008 David Brownell |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
6 | * Copyright (C) 2009 Samsung Electronics | 6 | * Copyright (C) 2009 Samsung Electronics |
7 | * Author: Michal Nazarewicz (m.nazarewicz@samsung.com) | 7 | * Author: Michal Nazarewicz (mina86@mina86.com) |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by | 10 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/usb/gadget/mv_udc.h b/drivers/usb/gadget/mv_udc.h index 34aadfae723d..e2be9519abbe 100644 --- a/drivers/usb/gadget/mv_udc.h +++ b/drivers/usb/gadget/mv_udc.h | |||
@@ -217,7 +217,7 @@ struct mv_udc { | |||
217 | struct work_struct vbus_work; | 217 | struct work_struct vbus_work; |
218 | struct workqueue_struct *qwork; | 218 | struct workqueue_struct *qwork; |
219 | 219 | ||
220 | struct otg_transceiver *transceiver; | 220 | struct usb_phy *transceiver; |
221 | 221 | ||
222 | struct mv_usb_platform_data *pdata; | 222 | struct mv_usb_platform_data *pdata; |
223 | 223 | ||
diff --git a/drivers/usb/gadget/mv_udc_core.c b/drivers/usb/gadget/mv_udc_core.c index f97e737d26f7..19bbe80c2f8c 100644 --- a/drivers/usb/gadget/mv_udc_core.c +++ b/drivers/usb/gadget/mv_udc_core.c | |||
@@ -608,6 +608,7 @@ static int mv_ep_disable(struct usb_ep *_ep) | |||
608 | nuke(ep, -ESHUTDOWN); | 608 | nuke(ep, -ESHUTDOWN); |
609 | 609 | ||
610 | ep->desc = NULL; | 610 | ep->desc = NULL; |
611 | ep->ep.desc = NULL; | ||
611 | ep->stopped = 1; | 612 | ep->stopped = 1; |
612 | 613 | ||
613 | spin_unlock_irqrestore(&udc->lock, flags); | 614 | spin_unlock_irqrestore(&udc->lock, flags); |
@@ -771,8 +772,7 @@ mv_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
771 | udc->ep0_state = DATA_STATE_XMIT; | 772 | udc->ep0_state = DATA_STATE_XMIT; |
772 | 773 | ||
773 | /* irq handler advances the queue */ | 774 | /* irq handler advances the queue */ |
774 | if (req != NULL) | 775 | list_add_tail(&req->queue, &ep->queue); |
775 | list_add_tail(&req->queue, &ep->queue); | ||
776 | spin_unlock_irqrestore(&udc->lock, flags); | 776 | spin_unlock_irqrestore(&udc->lock, flags); |
777 | 777 | ||
778 | return 0; | 778 | return 0; |
@@ -1384,7 +1384,8 @@ static int mv_udc_start(struct usb_gadget_driver *driver, | |||
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | if (udc->transceiver) { | 1386 | if (udc->transceiver) { |
1387 | retval = otg_set_peripheral(udc->transceiver, &udc->gadget); | 1387 | retval = otg_set_peripheral(udc->transceiver->otg, |
1388 | &udc->gadget); | ||
1388 | if (retval) { | 1389 | if (retval) { |
1389 | dev_err(&udc->dev->dev, | 1390 | dev_err(&udc->dev->dev, |
1390 | "unable to register peripheral to otg\n"); | 1391 | "unable to register peripheral to otg\n"); |
@@ -2181,7 +2182,7 @@ static int __devinit mv_udc_probe(struct platform_device *dev) | |||
2181 | 2182 | ||
2182 | #ifdef CONFIG_USB_OTG_UTILS | 2183 | #ifdef CONFIG_USB_OTG_UTILS |
2183 | if (pdata->mode == MV_USB_MODE_OTG) | 2184 | if (pdata->mode == MV_USB_MODE_OTG) |
2184 | udc->transceiver = otg_get_transceiver(); | 2185 | udc->transceiver = usb_get_transceiver(); |
2185 | #endif | 2186 | #endif |
2186 | 2187 | ||
2187 | udc->clknum = pdata->clknum; | 2188 | udc->clknum = pdata->clknum; |
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c index 7322d293213e..01ae56f47174 100644 --- a/drivers/usb/gadget/net2272.c +++ b/drivers/usb/gadget/net2272.c | |||
@@ -385,12 +385,9 @@ net2272_done(struct net2272_ep *ep, struct net2272_request *req, int status) | |||
385 | status = req->req.status; | 385 | status = req->req.status; |
386 | 386 | ||
387 | dev = ep->dev; | 387 | dev = ep->dev; |
388 | if (use_dma && req->mapped) { | 388 | if (use_dma && ep->dma) |
389 | dma_unmap_single(dev->dev, req->req.dma, req->req.length, | 389 | usb_gadget_unmap_request(&dev->gadget, &req->req, |
390 | ep->is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 390 | ep->is_in); |
391 | req->req.dma = DMA_ADDR_INVALID; | ||
392 | req->mapped = 0; | ||
393 | } | ||
394 | 391 | ||
395 | if (status && status != -ESHUTDOWN) | 392 | if (status && status != -ESHUTDOWN) |
396 | dev_vdbg(dev->dev, "complete %s req %p stat %d len %u/%u buf %p\n", | 393 | dev_vdbg(dev->dev, "complete %s req %p stat %d len %u/%u buf %p\n", |
@@ -850,10 +847,11 @@ net2272_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
850 | return -ESHUTDOWN; | 847 | return -ESHUTDOWN; |
851 | 848 | ||
852 | /* set up dma mapping in case the caller didn't */ | 849 | /* set up dma mapping in case the caller didn't */ |
853 | if (use_dma && ep->dma && _req->dma == DMA_ADDR_INVALID) { | 850 | if (use_dma && ep->dma) { |
854 | _req->dma = dma_map_single(dev->dev, _req->buf, _req->length, | 851 | status = usb_gadget_map_request(&dev->gadget, _req, |
855 | ep->is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | 852 | ep->is_in); |
856 | req->mapped = 1; | 853 | if (status) |
854 | return status; | ||
857 | } | 855 | } |
858 | 856 | ||
859 | dev_vdbg(dev->dev, "%s queue req %p, len %d buf %p dma %08llx %s\n", | 857 | dev_vdbg(dev->dev, "%s queue req %p, len %d buf %p dma %08llx %s\n", |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index cdedd1336745..a5ccabc37f30 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -806,12 +806,8 @@ done (struct net2280_ep *ep, struct net2280_request *req, int status) | |||
806 | status = req->req.status; | 806 | status = req->req.status; |
807 | 807 | ||
808 | dev = ep->dev; | 808 | dev = ep->dev; |
809 | if (req->mapped) { | 809 | if (ep->dma) |
810 | pci_unmap_single (dev->pdev, req->req.dma, req->req.length, | 810 | usb_gadget_unmap_request(&dev->gadget, &req->req, ep->is_in); |
811 | ep->is_in ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | ||
812 | req->req.dma = DMA_ADDR_INVALID; | ||
813 | req->mapped = 0; | ||
814 | } | ||
815 | 811 | ||
816 | if (status && status != -ESHUTDOWN) | 812 | if (status && status != -ESHUTDOWN) |
817 | VDEBUG (dev, "complete %s req %p stat %d len %u/%u\n", | 813 | VDEBUG (dev, "complete %s req %p stat %d len %u/%u\n", |
@@ -857,10 +853,13 @@ net2280_queue (struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags) | |||
857 | return -EOPNOTSUPP; | 853 | return -EOPNOTSUPP; |
858 | 854 | ||
859 | /* set up dma mapping in case the caller didn't */ | 855 | /* set up dma mapping in case the caller didn't */ |
860 | if (ep->dma && _req->dma == DMA_ADDR_INVALID) { | 856 | if (ep->dma) { |
861 | _req->dma = pci_map_single (dev->pdev, _req->buf, _req->length, | 857 | int ret; |
862 | ep->is_in ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); | 858 | |
863 | req->mapped = 1; | 859 | ret = usb_gadget_map_request(&dev->gadget, _req, |
860 | ep->is_in); | ||
861 | if (ret) | ||
862 | return ret; | ||
864 | } | 863 | } |
865 | 864 | ||
866 | #if 0 | 865 | #if 0 |
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c index 576cd8578b45..b44830df593e 100644 --- a/drivers/usb/gadget/omap_udc.c +++ b/drivers/usb/gadget/omap_udc.c | |||
@@ -251,6 +251,7 @@ static int omap_ep_disable(struct usb_ep *_ep) | |||
251 | 251 | ||
252 | spin_lock_irqsave(&ep->udc->lock, flags); | 252 | spin_lock_irqsave(&ep->udc->lock, flags); |
253 | ep->desc = NULL; | 253 | ep->desc = NULL; |
254 | ep->ep.desc = NULL; | ||
254 | nuke (ep, -ESHUTDOWN); | 255 | nuke (ep, -ESHUTDOWN); |
255 | ep->ep.maxpacket = ep->maxpacket; | 256 | ep->ep.maxpacket = ep->maxpacket; |
256 | ep->has_dma = 0; | 257 | ep->has_dma = 0; |
@@ -1213,7 +1214,7 @@ static int omap_wakeup(struct usb_gadget *gadget) | |||
1213 | /* NOTE: non-OTG systems may use SRP TOO... */ | 1214 | /* NOTE: non-OTG systems may use SRP TOO... */ |
1214 | } else if (!(udc->devstat & UDC_ATT)) { | 1215 | } else if (!(udc->devstat & UDC_ATT)) { |
1215 | if (udc->transceiver) | 1216 | if (udc->transceiver) |
1216 | retval = otg_start_srp(udc->transceiver); | 1217 | retval = otg_start_srp(udc->transceiver->otg); |
1217 | } | 1218 | } |
1218 | spin_unlock_irqrestore(&udc->lock, flags); | 1219 | spin_unlock_irqrestore(&udc->lock, flags); |
1219 | 1220 | ||
@@ -1345,7 +1346,7 @@ static int omap_vbus_draw(struct usb_gadget *gadget, unsigned mA) | |||
1345 | 1346 | ||
1346 | udc = container_of(gadget, struct omap_udc, gadget); | 1347 | udc = container_of(gadget, struct omap_udc, gadget); |
1347 | if (udc->transceiver) | 1348 | if (udc->transceiver) |
1348 | return otg_set_power(udc->transceiver, mA); | 1349 | return usb_phy_set_power(udc->transceiver, mA); |
1349 | return -EOPNOTSUPP; | 1350 | return -EOPNOTSUPP; |
1350 | } | 1351 | } |
1351 | 1352 | ||
@@ -1839,11 +1840,13 @@ static void devstate_irq(struct omap_udc *udc, u16 irq_src) | |||
1839 | spin_lock(&udc->lock); | 1840 | spin_lock(&udc->lock); |
1840 | } | 1841 | } |
1841 | if (udc->transceiver) | 1842 | if (udc->transceiver) |
1842 | otg_set_suspend(udc->transceiver, 1); | 1843 | usb_phy_set_suspend( |
1844 | udc->transceiver, 1); | ||
1843 | } else { | 1845 | } else { |
1844 | VDBG("resume\n"); | 1846 | VDBG("resume\n"); |
1845 | if (udc->transceiver) | 1847 | if (udc->transceiver) |
1846 | otg_set_suspend(udc->transceiver, 0); | 1848 | usb_phy_set_suspend( |
1849 | udc->transceiver, 0); | ||
1847 | if (udc->gadget.speed == USB_SPEED_FULL | 1850 | if (udc->gadget.speed == USB_SPEED_FULL |
1848 | && udc->driver->resume) { | 1851 | && udc->driver->resume) { |
1849 | spin_unlock(&udc->lock); | 1852 | spin_unlock(&udc->lock); |
@@ -2154,7 +2157,8 @@ static int omap_udc_start(struct usb_gadget_driver *driver, | |||
2154 | 2157 | ||
2155 | /* connect to bus through transceiver */ | 2158 | /* connect to bus through transceiver */ |
2156 | if (udc->transceiver) { | 2159 | if (udc->transceiver) { |
2157 | status = otg_set_peripheral(udc->transceiver, &udc->gadget); | 2160 | status = otg_set_peripheral(udc->transceiver->otg, |
2161 | &udc->gadget); | ||
2158 | if (status < 0) { | 2162 | if (status < 0) { |
2159 | ERR("can't bind to transceiver\n"); | 2163 | ERR("can't bind to transceiver\n"); |
2160 | if (driver->unbind) { | 2164 | if (driver->unbind) { |
@@ -2200,7 +2204,7 @@ static int omap_udc_stop(struct usb_gadget_driver *driver) | |||
2200 | omap_vbus_session(&udc->gadget, 0); | 2204 | omap_vbus_session(&udc->gadget, 0); |
2201 | 2205 | ||
2202 | if (udc->transceiver) | 2206 | if (udc->transceiver) |
2203 | (void) otg_set_peripheral(udc->transceiver, NULL); | 2207 | (void) otg_set_peripheral(udc->transceiver->otg, NULL); |
2204 | else | 2208 | else |
2205 | pullup_disable(udc); | 2209 | pullup_disable(udc); |
2206 | 2210 | ||
@@ -2650,7 +2654,7 @@ static void omap_udc_release(struct device *dev) | |||
2650 | } | 2654 | } |
2651 | 2655 | ||
2652 | static int __init | 2656 | static int __init |
2653 | omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv) | 2657 | omap_udc_setup(struct platform_device *odev, struct usb_phy *xceiv) |
2654 | { | 2658 | { |
2655 | unsigned tmp, buf; | 2659 | unsigned tmp, buf; |
2656 | 2660 | ||
@@ -2790,7 +2794,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2790 | { | 2794 | { |
2791 | int status = -ENODEV; | 2795 | int status = -ENODEV; |
2792 | int hmc; | 2796 | int hmc; |
2793 | struct otg_transceiver *xceiv = NULL; | 2797 | struct usb_phy *xceiv = NULL; |
2794 | const char *type = NULL; | 2798 | const char *type = NULL; |
2795 | struct omap_usb_config *config = pdev->dev.platform_data; | 2799 | struct omap_usb_config *config = pdev->dev.platform_data; |
2796 | struct clk *dc_clk; | 2800 | struct clk *dc_clk; |
@@ -2863,7 +2867,7 @@ static int __init omap_udc_probe(struct platform_device *pdev) | |||
2863 | * use it. Except for OTG, we don't _need_ to talk to one; | 2867 | * use it. Except for OTG, we don't _need_ to talk to one; |
2864 | * but not having one probably means no VBUS detection. | 2868 | * but not having one probably means no VBUS detection. |
2865 | */ | 2869 | */ |
2866 | xceiv = otg_get_transceiver(); | 2870 | xceiv = usb_get_transceiver(); |
2867 | if (xceiv) | 2871 | if (xceiv) |
2868 | type = xceiv->label; | 2872 | type = xceiv->label; |
2869 | else if (config->otg) { | 2873 | else if (config->otg) { |
@@ -3009,7 +3013,7 @@ cleanup1: | |||
3009 | 3013 | ||
3010 | cleanup0: | 3014 | cleanup0: |
3011 | if (xceiv) | 3015 | if (xceiv) |
3012 | otg_put_transceiver(xceiv); | 3016 | usb_put_transceiver(xceiv); |
3013 | 3017 | ||
3014 | if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) { | 3018 | if (cpu_is_omap16xx() || cpu_is_omap24xx() || cpu_is_omap7xx()) { |
3015 | clk_disable(hhc_clk); | 3019 | clk_disable(hhc_clk); |
@@ -3039,7 +3043,7 @@ static int __exit omap_udc_remove(struct platform_device *pdev) | |||
3039 | 3043 | ||
3040 | pullup_disable(udc); | 3044 | pullup_disable(udc); |
3041 | if (udc->transceiver) { | 3045 | if (udc->transceiver) { |
3042 | otg_put_transceiver(udc->transceiver); | 3046 | usb_put_transceiver(udc->transceiver); |
3043 | udc->transceiver = NULL; | 3047 | udc->transceiver = NULL; |
3044 | } | 3048 | } |
3045 | omap_writew(0, UDC_SYSCON1); | 3049 | omap_writew(0, UDC_SYSCON1); |
diff --git a/drivers/usb/gadget/omap_udc.h b/drivers/usb/gadget/omap_udc.h index 29edc51b6b22..59d3b2213cb1 100644 --- a/drivers/usb/gadget/omap_udc.h +++ b/drivers/usb/gadget/omap_udc.h | |||
@@ -164,7 +164,7 @@ struct omap_udc { | |||
164 | struct omap_ep ep[32]; | 164 | struct omap_ep ep[32]; |
165 | u16 devstat; | 165 | u16 devstat; |
166 | u16 clr_halt; | 166 | u16 clr_halt; |
167 | struct otg_transceiver *transceiver; | 167 | struct usb_phy *transceiver; |
168 | struct list_head iso; | 168 | struct list_head iso; |
169 | unsigned softconnect:1; | 169 | unsigned softconnect:1; |
170 | unsigned vbus_active:1; | 170 | unsigned vbus_active:1; |
diff --git a/drivers/usb/gadget/pch_udc.c b/drivers/usb/gadget/pch_udc.c index a3fcaae4bc2a..65307064a6fd 100644 --- a/drivers/usb/gadget/pch_udc.c +++ b/drivers/usb/gadget/pch_udc.c | |||
@@ -15,6 +15,14 @@ | |||
15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
16 | #include <linux/usb/ch9.h> | 16 | #include <linux/usb/ch9.h> |
17 | #include <linux/usb/gadget.h> | 17 | #include <linux/usb/gadget.h> |
18 | #include <linux/gpio.h> | ||
19 | #include <linux/irq.h> | ||
20 | |||
21 | /* GPIO port for VBUS detecting */ | ||
22 | static int vbus_gpio_port = -1; /* GPIO port number (-1:Not used) */ | ||
23 | |||
24 | #define PCH_VBUS_PERIOD 3000 /* VBUS polling period (msec) */ | ||
25 | #define PCH_VBUS_INTERVAL 10 /* VBUS polling interval (msec) */ | ||
18 | 26 | ||
19 | /* Address offset of Registers */ | 27 | /* Address offset of Registers */ |
20 | #define UDC_EP_REG_SHIFT 0x20 /* Offset to next EP */ | 28 | #define UDC_EP_REG_SHIFT 0x20 /* Offset to next EP */ |
@@ -296,6 +304,21 @@ struct pch_udc_ep { | |||
296 | }; | 304 | }; |
297 | 305 | ||
298 | /** | 306 | /** |
307 | * struct pch_vbus_gpio_data - Structure holding GPIO informaton | ||
308 | * for detecting VBUS | ||
309 | * @port: gpio port number | ||
310 | * @intr: gpio interrupt number | ||
311 | * @irq_work_fall Structure for WorkQueue | ||
312 | * @irq_work_rise Structure for WorkQueue | ||
313 | */ | ||
314 | struct pch_vbus_gpio_data { | ||
315 | int port; | ||
316 | int intr; | ||
317 | struct work_struct irq_work_fall; | ||
318 | struct work_struct irq_work_rise; | ||
319 | }; | ||
320 | |||
321 | /** | ||
299 | * struct pch_udc_dev - Structure holding complete information | 322 | * struct pch_udc_dev - Structure holding complete information |
300 | * of the PCH USB device | 323 | * of the PCH USB device |
301 | * @gadget: gadget driver data | 324 | * @gadget: gadget driver data |
@@ -311,6 +334,7 @@ struct pch_udc_ep { | |||
311 | * @registered: driver regsitered with system | 334 | * @registered: driver regsitered with system |
312 | * @suspended: driver in suspended state | 335 | * @suspended: driver in suspended state |
313 | * @connected: gadget driver associated | 336 | * @connected: gadget driver associated |
337 | * @vbus_session: required vbus_session state | ||
314 | * @set_cfg_not_acked: pending acknowledgement 4 setup | 338 | * @set_cfg_not_acked: pending acknowledgement 4 setup |
315 | * @waiting_zlp_ack: pending acknowledgement 4 ZLP | 339 | * @waiting_zlp_ack: pending acknowledgement 4 ZLP |
316 | * @data_requests: DMA pool for data requests | 340 | * @data_requests: DMA pool for data requests |
@@ -322,6 +346,7 @@ struct pch_udc_ep { | |||
322 | * @base_addr: for mapped device memory | 346 | * @base_addr: for mapped device memory |
323 | * @irq: IRQ line for the device | 347 | * @irq: IRQ line for the device |
324 | * @cfg_data: current cfg, intf, and alt in use | 348 | * @cfg_data: current cfg, intf, and alt in use |
349 | * @vbus_gpio: GPIO informaton for detecting VBUS | ||
325 | */ | 350 | */ |
326 | struct pch_udc_dev { | 351 | struct pch_udc_dev { |
327 | struct usb_gadget gadget; | 352 | struct usb_gadget gadget; |
@@ -337,6 +362,7 @@ struct pch_udc_dev { | |||
337 | registered:1, | 362 | registered:1, |
338 | suspended:1, | 363 | suspended:1, |
339 | connected:1, | 364 | connected:1, |
365 | vbus_session:1, | ||
340 | set_cfg_not_acked:1, | 366 | set_cfg_not_acked:1, |
341 | waiting_zlp_ack:1; | 367 | waiting_zlp_ack:1; |
342 | struct pci_pool *data_requests; | 368 | struct pci_pool *data_requests; |
@@ -347,7 +373,8 @@ struct pch_udc_dev { | |||
347 | unsigned long phys_addr; | 373 | unsigned long phys_addr; |
348 | void __iomem *base_addr; | 374 | void __iomem *base_addr; |
349 | unsigned irq; | 375 | unsigned irq; |
350 | struct pch_udc_cfg_data cfg_data; | 376 | struct pch_udc_cfg_data cfg_data; |
377 | struct pch_vbus_gpio_data vbus_gpio; | ||
351 | }; | 378 | }; |
352 | 379 | ||
353 | #define PCH_UDC_PCI_BAR 1 | 380 | #define PCH_UDC_PCI_BAR 1 |
@@ -554,6 +581,29 @@ static void pch_udc_clear_disconnect(struct pch_udc_dev *dev) | |||
554 | } | 581 | } |
555 | 582 | ||
556 | /** | 583 | /** |
584 | * pch_udc_reconnect() - This API initializes usb device controller, | ||
585 | * and clear the disconnect status. | ||
586 | * @dev: Reference to pch_udc_regs structure | ||
587 | */ | ||
588 | static void pch_udc_init(struct pch_udc_dev *dev); | ||
589 | static void pch_udc_reconnect(struct pch_udc_dev *dev) | ||
590 | { | ||
591 | pch_udc_init(dev); | ||
592 | |||
593 | /* enable device interrupts */ | ||
594 | /* pch_udc_enable_interrupts() */ | ||
595 | pch_udc_bit_clr(dev, UDC_DEVIRQMSK_ADDR, | ||
596 | UDC_DEVINT_UR | UDC_DEVINT_ENUM); | ||
597 | |||
598 | /* Clear the disconnect */ | ||
599 | pch_udc_bit_set(dev, UDC_DEVCTL_ADDR, UDC_DEVCTL_RES); | ||
600 | pch_udc_bit_clr(dev, UDC_DEVCTL_ADDR, UDC_DEVCTL_SD); | ||
601 | mdelay(1); | ||
602 | /* Resume USB signalling */ | ||
603 | pch_udc_bit_clr(dev, UDC_DEVCTL_ADDR, UDC_DEVCTL_RES); | ||
604 | } | ||
605 | |||
606 | /** | ||
557 | * pch_udc_vbus_session() - set or clearr the disconnect status. | 607 | * pch_udc_vbus_session() - set or clearr the disconnect status. |
558 | * @dev: Reference to pch_udc_regs structure | 608 | * @dev: Reference to pch_udc_regs structure |
559 | * @is_active: Parameter specifying the action | 609 | * @is_active: Parameter specifying the action |
@@ -563,10 +613,18 @@ static void pch_udc_clear_disconnect(struct pch_udc_dev *dev) | |||
563 | static inline void pch_udc_vbus_session(struct pch_udc_dev *dev, | 613 | static inline void pch_udc_vbus_session(struct pch_udc_dev *dev, |
564 | int is_active) | 614 | int is_active) |
565 | { | 615 | { |
566 | if (is_active) | 616 | if (is_active) { |
567 | pch_udc_clear_disconnect(dev); | 617 | pch_udc_reconnect(dev); |
568 | else | 618 | dev->vbus_session = 1; |
619 | } else { | ||
620 | if (dev->driver && dev->driver->disconnect) { | ||
621 | spin_unlock(&dev->lock); | ||
622 | dev->driver->disconnect(&dev->gadget); | ||
623 | spin_lock(&dev->lock); | ||
624 | } | ||
569 | pch_udc_set_disconnect(dev); | 625 | pch_udc_set_disconnect(dev); |
626 | dev->vbus_session = 0; | ||
627 | } | ||
570 | } | 628 | } |
571 | 629 | ||
572 | /** | 630 | /** |
@@ -1126,7 +1184,17 @@ static int pch_udc_pcd_pullup(struct usb_gadget *gadget, int is_on) | |||
1126 | if (!gadget) | 1184 | if (!gadget) |
1127 | return -EINVAL; | 1185 | return -EINVAL; |
1128 | dev = container_of(gadget, struct pch_udc_dev, gadget); | 1186 | dev = container_of(gadget, struct pch_udc_dev, gadget); |
1129 | pch_udc_vbus_session(dev, is_on); | 1187 | if (is_on) { |
1188 | pch_udc_reconnect(dev); | ||
1189 | } else { | ||
1190 | if (dev->driver && dev->driver->disconnect) { | ||
1191 | spin_unlock(&dev->lock); | ||
1192 | dev->driver->disconnect(&dev->gadget); | ||
1193 | spin_lock(&dev->lock); | ||
1194 | } | ||
1195 | pch_udc_set_disconnect(dev); | ||
1196 | } | ||
1197 | |||
1130 | return 0; | 1198 | return 0; |
1131 | } | 1199 | } |
1132 | 1200 | ||
@@ -1183,6 +1251,188 @@ static const struct usb_gadget_ops pch_udc_ops = { | |||
1183 | }; | 1251 | }; |
1184 | 1252 | ||
1185 | /** | 1253 | /** |
1254 | * pch_vbus_gpio_get_value() - This API gets value of GPIO port as VBUS status. | ||
1255 | * @dev: Reference to the driver structure | ||
1256 | * | ||
1257 | * Return value: | ||
1258 | * 1: VBUS is high | ||
1259 | * 0: VBUS is low | ||
1260 | * -1: It is not enable to detect VBUS using GPIO | ||
1261 | */ | ||
1262 | static int pch_vbus_gpio_get_value(struct pch_udc_dev *dev) | ||
1263 | { | ||
1264 | int vbus = 0; | ||
1265 | |||
1266 | if (dev->vbus_gpio.port) | ||
1267 | vbus = gpio_get_value(dev->vbus_gpio.port) ? 1 : 0; | ||
1268 | else | ||
1269 | vbus = -1; | ||
1270 | |||
1271 | return vbus; | ||
1272 | } | ||
1273 | |||
1274 | /** | ||
1275 | * pch_vbus_gpio_work_fall() - This API keeps watch on VBUS becoming Low. | ||
1276 | * If VBUS is Low, disconnect is processed | ||
1277 | * @irq_work: Structure for WorkQueue | ||
1278 | * | ||
1279 | */ | ||
1280 | static void pch_vbus_gpio_work_fall(struct work_struct *irq_work) | ||
1281 | { | ||
1282 | struct pch_vbus_gpio_data *vbus_gpio = container_of(irq_work, | ||
1283 | struct pch_vbus_gpio_data, irq_work_fall); | ||
1284 | struct pch_udc_dev *dev = | ||
1285 | container_of(vbus_gpio, struct pch_udc_dev, vbus_gpio); | ||
1286 | int vbus_saved = -1; | ||
1287 | int vbus; | ||
1288 | int count; | ||
1289 | |||
1290 | if (!dev->vbus_gpio.port) | ||
1291 | return; | ||
1292 | |||
1293 | for (count = 0; count < (PCH_VBUS_PERIOD / PCH_VBUS_INTERVAL); | ||
1294 | count++) { | ||
1295 | vbus = pch_vbus_gpio_get_value(dev); | ||
1296 | |||
1297 | if ((vbus_saved == vbus) && (vbus == 0)) { | ||
1298 | dev_dbg(&dev->pdev->dev, "VBUS fell"); | ||
1299 | if (dev->driver | ||
1300 | && dev->driver->disconnect) { | ||
1301 | dev->driver->disconnect( | ||
1302 | &dev->gadget); | ||
1303 | } | ||
1304 | if (dev->vbus_gpio.intr) | ||
1305 | pch_udc_init(dev); | ||
1306 | else | ||
1307 | pch_udc_reconnect(dev); | ||
1308 | return; | ||
1309 | } | ||
1310 | vbus_saved = vbus; | ||
1311 | mdelay(PCH_VBUS_INTERVAL); | ||
1312 | } | ||
1313 | } | ||
1314 | |||
1315 | /** | ||
1316 | * pch_vbus_gpio_work_rise() - This API checks VBUS is High. | ||
1317 | * If VBUS is High, connect is processed | ||
1318 | * @irq_work: Structure for WorkQueue | ||
1319 | * | ||
1320 | */ | ||
1321 | static void pch_vbus_gpio_work_rise(struct work_struct *irq_work) | ||
1322 | { | ||
1323 | struct pch_vbus_gpio_data *vbus_gpio = container_of(irq_work, | ||
1324 | struct pch_vbus_gpio_data, irq_work_rise); | ||
1325 | struct pch_udc_dev *dev = | ||
1326 | container_of(vbus_gpio, struct pch_udc_dev, vbus_gpio); | ||
1327 | int vbus; | ||
1328 | |||
1329 | if (!dev->vbus_gpio.port) | ||
1330 | return; | ||
1331 | |||
1332 | mdelay(PCH_VBUS_INTERVAL); | ||
1333 | vbus = pch_vbus_gpio_get_value(dev); | ||
1334 | |||
1335 | if (vbus == 1) { | ||
1336 | dev_dbg(&dev->pdev->dev, "VBUS rose"); | ||
1337 | pch_udc_reconnect(dev); | ||
1338 | return; | ||
1339 | } | ||
1340 | } | ||
1341 | |||
1342 | /** | ||
1343 | * pch_vbus_gpio_irq() - IRQ handler for GPIO intrerrupt for changing VBUS | ||
1344 | * @irq: Interrupt request number | ||
1345 | * @dev: Reference to the device structure | ||
1346 | * | ||
1347 | * Return codes: | ||
1348 | * 0: Success | ||
1349 | * -EINVAL: GPIO port is invalid or can't be initialized. | ||
1350 | */ | ||
1351 | static irqreturn_t pch_vbus_gpio_irq(int irq, void *data) | ||
1352 | { | ||
1353 | struct pch_udc_dev *dev = (struct pch_udc_dev *)data; | ||
1354 | |||
1355 | if (!dev->vbus_gpio.port || !dev->vbus_gpio.intr) | ||
1356 | return IRQ_NONE; | ||
1357 | |||
1358 | if (pch_vbus_gpio_get_value(dev)) | ||
1359 | schedule_work(&dev->vbus_gpio.irq_work_rise); | ||
1360 | else | ||
1361 | schedule_work(&dev->vbus_gpio.irq_work_fall); | ||
1362 | |||
1363 | return IRQ_HANDLED; | ||
1364 | } | ||
1365 | |||
1366 | /** | ||
1367 | * pch_vbus_gpio_init() - This API initializes GPIO port detecting VBUS. | ||
1368 | * @dev: Reference to the driver structure | ||
1369 | * @vbus_gpio Number of GPIO port to detect gpio | ||
1370 | * | ||
1371 | * Return codes: | ||
1372 | * 0: Success | ||
1373 | * -EINVAL: GPIO port is invalid or can't be initialized. | ||
1374 | */ | ||
1375 | static int pch_vbus_gpio_init(struct pch_udc_dev *dev, int vbus_gpio_port) | ||
1376 | { | ||
1377 | int err; | ||
1378 | int irq_num = 0; | ||
1379 | |||
1380 | dev->vbus_gpio.port = 0; | ||
1381 | dev->vbus_gpio.intr = 0; | ||
1382 | |||
1383 | if (vbus_gpio_port <= -1) | ||
1384 | return -EINVAL; | ||
1385 | |||
1386 | err = gpio_is_valid(vbus_gpio_port); | ||
1387 | if (!err) { | ||
1388 | pr_err("%s: gpio port %d is invalid\n", | ||
1389 | __func__, vbus_gpio_port); | ||
1390 | return -EINVAL; | ||
1391 | } | ||
1392 | |||
1393 | err = gpio_request(vbus_gpio_port, "pch_vbus"); | ||
1394 | if (err) { | ||
1395 | pr_err("%s: can't request gpio port %d, err: %d\n", | ||
1396 | __func__, vbus_gpio_port, err); | ||
1397 | return -EINVAL; | ||
1398 | } | ||
1399 | |||
1400 | dev->vbus_gpio.port = vbus_gpio_port; | ||
1401 | gpio_direction_input(vbus_gpio_port); | ||
1402 | INIT_WORK(&dev->vbus_gpio.irq_work_fall, pch_vbus_gpio_work_fall); | ||
1403 | |||
1404 | irq_num = gpio_to_irq(vbus_gpio_port); | ||
1405 | if (irq_num > 0) { | ||
1406 | irq_set_irq_type(irq_num, IRQ_TYPE_EDGE_BOTH); | ||
1407 | err = request_irq(irq_num, pch_vbus_gpio_irq, 0, | ||
1408 | "vbus_detect", dev); | ||
1409 | if (!err) { | ||
1410 | dev->vbus_gpio.intr = irq_num; | ||
1411 | INIT_WORK(&dev->vbus_gpio.irq_work_rise, | ||
1412 | pch_vbus_gpio_work_rise); | ||
1413 | } else { | ||
1414 | pr_err("%s: can't request irq %d, err: %d\n", | ||
1415 | __func__, irq_num, err); | ||
1416 | } | ||
1417 | } | ||
1418 | |||
1419 | return 0; | ||
1420 | } | ||
1421 | |||
1422 | /** | ||
1423 | * pch_vbus_gpio_free() - This API frees resources of GPIO port | ||
1424 | * @dev: Reference to the driver structure | ||
1425 | */ | ||
1426 | static void pch_vbus_gpio_free(struct pch_udc_dev *dev) | ||
1427 | { | ||
1428 | if (dev->vbus_gpio.intr) | ||
1429 | free_irq(dev->vbus_gpio.intr, dev); | ||
1430 | |||
1431 | if (dev->vbus_gpio.port) | ||
1432 | gpio_free(dev->vbus_gpio.port); | ||
1433 | } | ||
1434 | |||
1435 | /** | ||
1186 | * complete_req() - This API is invoked from the driver when processing | 1436 | * complete_req() - This API is invoked from the driver when processing |
1187 | * of a request is complete | 1437 | * of a request is complete |
1188 | * @ep: Reference to the endpoint structure | 1438 | * @ep: Reference to the endpoint structure |
@@ -1493,6 +1743,7 @@ static int pch_udc_pcd_ep_disable(struct usb_ep *usbep) | |||
1493 | pch_udc_ep_disable(ep); | 1743 | pch_udc_ep_disable(ep); |
1494 | pch_udc_disable_ep_interrupts(ep->dev, PCH_UDC_EPINT(ep->in, ep->num)); | 1744 | pch_udc_disable_ep_interrupts(ep->dev, PCH_UDC_EPINT(ep->in, ep->num)); |
1495 | ep->desc = NULL; | 1745 | ep->desc = NULL; |
1746 | ep->ep.desc = NULL; | ||
1496 | INIT_LIST_HEAD(&ep->queue); | 1747 | INIT_LIST_HEAD(&ep->queue); |
1497 | spin_unlock_irqrestore(&ep->dev->lock, iflags); | 1748 | spin_unlock_irqrestore(&ep->dev->lock, iflags); |
1498 | return 0; | 1749 | return 0; |
@@ -2335,8 +2586,11 @@ static void pch_udc_svc_ur_interrupt(struct pch_udc_dev *dev) | |||
2335 | /* Complete request queue */ | 2586 | /* Complete request queue */ |
2336 | empty_req_queue(ep); | 2587 | empty_req_queue(ep); |
2337 | } | 2588 | } |
2338 | if (dev->driver && dev->driver->disconnect) | 2589 | if (dev->driver && dev->driver->disconnect) { |
2590 | spin_unlock(&dev->lock); | ||
2339 | dev->driver->disconnect(&dev->gadget); | 2591 | dev->driver->disconnect(&dev->gadget); |
2592 | spin_lock(&dev->lock); | ||
2593 | } | ||
2340 | } | 2594 | } |
2341 | 2595 | ||
2342 | /** | 2596 | /** |
@@ -2371,6 +2625,11 @@ static void pch_udc_svc_enum_interrupt(struct pch_udc_dev *dev) | |||
2371 | pch_udc_set_dma(dev, DMA_DIR_TX); | 2625 | pch_udc_set_dma(dev, DMA_DIR_TX); |
2372 | pch_udc_set_dma(dev, DMA_DIR_RX); | 2626 | pch_udc_set_dma(dev, DMA_DIR_RX); |
2373 | pch_udc_ep_set_rrdy(&(dev->ep[UDC_EP0OUT_IDX])); | 2627 | pch_udc_ep_set_rrdy(&(dev->ep[UDC_EP0OUT_IDX])); |
2628 | |||
2629 | /* enable device interrupts */ | ||
2630 | pch_udc_enable_interrupts(dev, UDC_DEVINT_UR | UDC_DEVINT_US | | ||
2631 | UDC_DEVINT_ES | UDC_DEVINT_ENUM | | ||
2632 | UDC_DEVINT_SI | UDC_DEVINT_SC); | ||
2374 | } | 2633 | } |
2375 | 2634 | ||
2376 | /** | 2635 | /** |
@@ -2459,12 +2718,18 @@ static void pch_udc_svc_cfg_interrupt(struct pch_udc_dev *dev) | |||
2459 | */ | 2718 | */ |
2460 | static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr) | 2719 | static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr) |
2461 | { | 2720 | { |
2721 | int vbus; | ||
2722 | |||
2462 | /* USB Reset Interrupt */ | 2723 | /* USB Reset Interrupt */ |
2463 | if (dev_intr & UDC_DEVINT_UR) | 2724 | if (dev_intr & UDC_DEVINT_UR) { |
2464 | pch_udc_svc_ur_interrupt(dev); | 2725 | pch_udc_svc_ur_interrupt(dev); |
2726 | dev_dbg(&dev->pdev->dev, "USB_RESET\n"); | ||
2727 | } | ||
2465 | /* Enumeration Done Interrupt */ | 2728 | /* Enumeration Done Interrupt */ |
2466 | if (dev_intr & UDC_DEVINT_ENUM) | 2729 | if (dev_intr & UDC_DEVINT_ENUM) { |
2467 | pch_udc_svc_enum_interrupt(dev); | 2730 | pch_udc_svc_enum_interrupt(dev); |
2731 | dev_dbg(&dev->pdev->dev, "USB_ENUM\n"); | ||
2732 | } | ||
2468 | /* Set Interface Interrupt */ | 2733 | /* Set Interface Interrupt */ |
2469 | if (dev_intr & UDC_DEVINT_SI) | 2734 | if (dev_intr & UDC_DEVINT_SI) |
2470 | pch_udc_svc_intf_interrupt(dev); | 2735 | pch_udc_svc_intf_interrupt(dev); |
@@ -2472,8 +2737,30 @@ static void pch_udc_dev_isr(struct pch_udc_dev *dev, u32 dev_intr) | |||
2472 | if (dev_intr & UDC_DEVINT_SC) | 2737 | if (dev_intr & UDC_DEVINT_SC) |
2473 | pch_udc_svc_cfg_interrupt(dev); | 2738 | pch_udc_svc_cfg_interrupt(dev); |
2474 | /* USB Suspend interrupt */ | 2739 | /* USB Suspend interrupt */ |
2475 | if (dev_intr & UDC_DEVINT_US) | 2740 | if (dev_intr & UDC_DEVINT_US) { |
2741 | if (dev->driver | ||
2742 | && dev->driver->suspend) { | ||
2743 | spin_unlock(&dev->lock); | ||
2744 | dev->driver->suspend(&dev->gadget); | ||
2745 | spin_lock(&dev->lock); | ||
2746 | } | ||
2747 | |||
2748 | vbus = pch_vbus_gpio_get_value(dev); | ||
2749 | if ((dev->vbus_session == 0) | ||
2750 | && (vbus != 1)) { | ||
2751 | if (dev->driver && dev->driver->disconnect) { | ||
2752 | spin_unlock(&dev->lock); | ||
2753 | dev->driver->disconnect(&dev->gadget); | ||
2754 | spin_lock(&dev->lock); | ||
2755 | } | ||
2756 | pch_udc_reconnect(dev); | ||
2757 | } else if ((dev->vbus_session == 0) | ||
2758 | && (vbus == 1) | ||
2759 | && !dev->vbus_gpio.intr) | ||
2760 | schedule_work(&dev->vbus_gpio.irq_work_fall); | ||
2761 | |||
2476 | dev_dbg(&dev->pdev->dev, "USB_SUSPEND\n"); | 2762 | dev_dbg(&dev->pdev->dev, "USB_SUSPEND\n"); |
2763 | } | ||
2477 | /* Clear the SOF interrupt, if enabled */ | 2764 | /* Clear the SOF interrupt, if enabled */ |
2478 | if (dev_intr & UDC_DEVINT_SOF) | 2765 | if (dev_intr & UDC_DEVINT_SOF) |
2479 | dev_dbg(&dev->pdev->dev, "SOF\n"); | 2766 | dev_dbg(&dev->pdev->dev, "SOF\n"); |
@@ -2499,6 +2786,14 @@ static irqreturn_t pch_udc_isr(int irq, void *pdev) | |||
2499 | dev_intr = pch_udc_read_device_interrupts(dev); | 2786 | dev_intr = pch_udc_read_device_interrupts(dev); |
2500 | ep_intr = pch_udc_read_ep_interrupts(dev); | 2787 | ep_intr = pch_udc_read_ep_interrupts(dev); |
2501 | 2788 | ||
2789 | /* For a hot plug, this find that the controller is hung up. */ | ||
2790 | if (dev_intr == ep_intr) | ||
2791 | if (dev_intr == pch_udc_readl(dev, UDC_DEVCFG_ADDR)) { | ||
2792 | dev_dbg(&dev->pdev->dev, "UDC: Hung up\n"); | ||
2793 | /* The controller is reset */ | ||
2794 | pch_udc_writel(dev, UDC_SRST, UDC_SRST_ADDR); | ||
2795 | return IRQ_HANDLED; | ||
2796 | } | ||
2502 | if (dev_intr) | 2797 | if (dev_intr) |
2503 | /* Clear device interrupts */ | 2798 | /* Clear device interrupts */ |
2504 | pch_udc_write_device_interrupts(dev, dev_intr); | 2799 | pch_udc_write_device_interrupts(dev, dev_intr); |
@@ -2625,6 +2920,7 @@ static int pch_udc_pcd_init(struct pch_udc_dev *dev) | |||
2625 | { | 2920 | { |
2626 | pch_udc_init(dev); | 2921 | pch_udc_init(dev); |
2627 | pch_udc_pcd_reinit(dev); | 2922 | pch_udc_pcd_reinit(dev); |
2923 | pch_vbus_gpio_init(dev, vbus_gpio_port); | ||
2628 | return 0; | 2924 | return 0; |
2629 | } | 2925 | } |
2630 | 2926 | ||
@@ -2725,7 +3021,8 @@ static int pch_udc_start(struct usb_gadget_driver *driver, | |||
2725 | pch_udc_setup_ep0(dev); | 3021 | pch_udc_setup_ep0(dev); |
2726 | 3022 | ||
2727 | /* clear SD */ | 3023 | /* clear SD */ |
2728 | pch_udc_clear_disconnect(dev); | 3024 | if ((pch_vbus_gpio_get_value(dev) != 0) || !dev->vbus_gpio.intr) |
3025 | pch_udc_clear_disconnect(dev); | ||
2729 | 3026 | ||
2730 | dev->connected = 1; | 3027 | dev->connected = 1; |
2731 | return 0; | 3028 | return 0; |
@@ -2803,6 +3100,8 @@ static void pch_udc_remove(struct pci_dev *pdev) | |||
2803 | UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE); | 3100 | UDC_EP0OUT_BUFF_SIZE * 4, DMA_FROM_DEVICE); |
2804 | kfree(dev->ep0out_buf); | 3101 | kfree(dev->ep0out_buf); |
2805 | 3102 | ||
3103 | pch_vbus_gpio_free(dev); | ||
3104 | |||
2806 | pch_udc_exit(dev); | 3105 | pch_udc_exit(dev); |
2807 | 3106 | ||
2808 | if (dev->irq_registered) | 3107 | if (dev->irq_registered) |
@@ -2912,8 +3211,10 @@ static int pch_udc_probe(struct pci_dev *pdev, | |||
2912 | } | 3211 | } |
2913 | pch_udc = dev; | 3212 | pch_udc = dev; |
2914 | /* initialize the hardware */ | 3213 | /* initialize the hardware */ |
2915 | if (pch_udc_pcd_init(dev)) | 3214 | if (pch_udc_pcd_init(dev)) { |
3215 | retval = -ENODEV; | ||
2916 | goto finished; | 3216 | goto finished; |
3217 | } | ||
2917 | if (request_irq(pdev->irq, pch_udc_isr, IRQF_SHARED, KBUILD_MODNAME, | 3218 | if (request_irq(pdev->irq, pch_udc_isr, IRQF_SHARED, KBUILD_MODNAME, |
2918 | dev)) { | 3219 | dev)) { |
2919 | dev_err(&pdev->dev, "%s: request_irq(%d) fail\n", __func__, | 3220 | dev_err(&pdev->dev, "%s: request_irq(%d) fail\n", __func__, |
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index dd470635f4f7..1b33634f2736 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c | |||
@@ -283,6 +283,7 @@ static int pxa25x_ep_disable (struct usb_ep *_ep) | |||
283 | pxa25x_ep_fifo_flush (_ep); | 283 | pxa25x_ep_fifo_flush (_ep); |
284 | 284 | ||
285 | ep->desc = NULL; | 285 | ep->desc = NULL; |
286 | ep->ep.desc = NULL; | ||
286 | ep->stopped = 1; | 287 | ep->stopped = 1; |
287 | 288 | ||
288 | local_irq_restore(flags); | 289 | local_irq_restore(flags); |
@@ -995,7 +996,7 @@ static int pxa25x_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
995 | udc = container_of(_gadget, struct pxa25x_udc, gadget); | 996 | udc = container_of(_gadget, struct pxa25x_udc, gadget); |
996 | 997 | ||
997 | if (udc->transceiver) | 998 | if (udc->transceiver) |
998 | return otg_set_power(udc->transceiver, mA); | 999 | return usb_phy_set_power(udc->transceiver, mA); |
999 | return -EOPNOTSUPP; | 1000 | return -EOPNOTSUPP; |
1000 | } | 1001 | } |
1001 | 1002 | ||
@@ -1192,6 +1193,7 @@ static void udc_reinit(struct pxa25x_udc *dev) | |||
1192 | list_add_tail (&ep->ep.ep_list, &dev->gadget.ep_list); | 1193 | list_add_tail (&ep->ep.ep_list, &dev->gadget.ep_list); |
1193 | 1194 | ||
1194 | ep->desc = NULL; | 1195 | ep->desc = NULL; |
1196 | ep->ep.desc = NULL; | ||
1195 | ep->stopped = 0; | 1197 | ep->stopped = 0; |
1196 | INIT_LIST_HEAD (&ep->queue); | 1198 | INIT_LIST_HEAD (&ep->queue); |
1197 | ep->pio_irqs = 0; | 1199 | ep->pio_irqs = 0; |
@@ -1301,7 +1303,8 @@ fail: | |||
1301 | 1303 | ||
1302 | /* connect to bus through transceiver */ | 1304 | /* connect to bus through transceiver */ |
1303 | if (dev->transceiver) { | 1305 | if (dev->transceiver) { |
1304 | retval = otg_set_peripheral(dev->transceiver, &dev->gadget); | 1306 | retval = otg_set_peripheral(dev->transceiver->otg, |
1307 | &dev->gadget); | ||
1305 | if (retval) { | 1308 | if (retval) { |
1306 | DMSG("can't bind to transceiver\n"); | 1309 | DMSG("can't bind to transceiver\n"); |
1307 | if (driver->unbind) | 1310 | if (driver->unbind) |
@@ -1360,7 +1363,7 @@ static int pxa25x_stop(struct usb_gadget_driver *driver) | |||
1360 | local_irq_enable(); | 1363 | local_irq_enable(); |
1361 | 1364 | ||
1362 | if (dev->transceiver) | 1365 | if (dev->transceiver) |
1363 | (void) otg_set_peripheral(dev->transceiver, NULL); | 1366 | (void) otg_set_peripheral(dev->transceiver->otg, NULL); |
1364 | 1367 | ||
1365 | driver->unbind(&dev->gadget); | 1368 | driver->unbind(&dev->gadget); |
1366 | dev->gadget.dev.driver = NULL; | 1369 | dev->gadget.dev.driver = NULL; |
@@ -2159,7 +2162,7 @@ static int __init pxa25x_udc_probe(struct platform_device *pdev) | |||
2159 | dev->dev = &pdev->dev; | 2162 | dev->dev = &pdev->dev; |
2160 | dev->mach = pdev->dev.platform_data; | 2163 | dev->mach = pdev->dev.platform_data; |
2161 | 2164 | ||
2162 | dev->transceiver = otg_get_transceiver(); | 2165 | dev->transceiver = usb_get_transceiver(); |
2163 | 2166 | ||
2164 | if (gpio_is_valid(dev->mach->gpio_pullup)) { | 2167 | if (gpio_is_valid(dev->mach->gpio_pullup)) { |
2165 | if ((retval = gpio_request(dev->mach->gpio_pullup, | 2168 | if ((retval = gpio_request(dev->mach->gpio_pullup, |
@@ -2238,7 +2241,7 @@ lubbock_fail0: | |||
2238 | gpio_free(dev->mach->gpio_pullup); | 2241 | gpio_free(dev->mach->gpio_pullup); |
2239 | err_gpio_pullup: | 2242 | err_gpio_pullup: |
2240 | if (dev->transceiver) { | 2243 | if (dev->transceiver) { |
2241 | otg_put_transceiver(dev->transceiver); | 2244 | usb_put_transceiver(dev->transceiver); |
2242 | dev->transceiver = NULL; | 2245 | dev->transceiver = NULL; |
2243 | } | 2246 | } |
2244 | clk_put(dev->clk); | 2247 | clk_put(dev->clk); |
@@ -2280,7 +2283,7 @@ static int __exit pxa25x_udc_remove(struct platform_device *pdev) | |||
2280 | clk_put(dev->clk); | 2283 | clk_put(dev->clk); |
2281 | 2284 | ||
2282 | if (dev->transceiver) { | 2285 | if (dev->transceiver) { |
2283 | otg_put_transceiver(dev->transceiver); | 2286 | usb_put_transceiver(dev->transceiver); |
2284 | dev->transceiver = NULL; | 2287 | dev->transceiver = NULL; |
2285 | } | 2288 | } |
2286 | 2289 | ||
diff --git a/drivers/usb/gadget/pxa25x_udc.h b/drivers/usb/gadget/pxa25x_udc.h index 8eaf4e43726b..893e917f048e 100644 --- a/drivers/usb/gadget/pxa25x_udc.h +++ b/drivers/usb/gadget/pxa25x_udc.h | |||
@@ -119,7 +119,7 @@ struct pxa25x_udc { | |||
119 | struct device *dev; | 119 | struct device *dev; |
120 | struct clk *clk; | 120 | struct clk *clk; |
121 | struct pxa2xx_udc_mach_info *mach; | 121 | struct pxa2xx_udc_mach_info *mach; |
122 | struct otg_transceiver *transceiver; | 122 | struct usb_phy *transceiver; |
123 | u64 dma_mask; | 123 | u64 dma_mask; |
124 | struct pxa25x_ep ep [PXA_UDC_NUM_ENDPOINTS]; | 124 | struct pxa25x_ep ep [PXA_UDC_NUM_ENDPOINTS]; |
125 | 125 | ||
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c index f4c44eb806c3..98acb3ab9e17 100644 --- a/drivers/usb/gadget/pxa27x_udc.c +++ b/drivers/usb/gadget/pxa27x_udc.c | |||
@@ -1666,7 +1666,7 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, unsigned mA) | |||
1666 | 1666 | ||
1667 | udc = to_gadget_udc(_gadget); | 1667 | udc = to_gadget_udc(_gadget); |
1668 | if (udc->transceiver) | 1668 | if (udc->transceiver) |
1669 | return otg_set_power(udc->transceiver, mA); | 1669 | return usb_phy_set_power(udc->transceiver, mA); |
1670 | return -EOPNOTSUPP; | 1670 | return -EOPNOTSUPP; |
1671 | } | 1671 | } |
1672 | 1672 | ||
@@ -1835,7 +1835,8 @@ static int pxa27x_udc_start(struct usb_gadget_driver *driver, | |||
1835 | driver->driver.name); | 1835 | driver->driver.name); |
1836 | 1836 | ||
1837 | if (udc->transceiver) { | 1837 | if (udc->transceiver) { |
1838 | retval = otg_set_peripheral(udc->transceiver, &udc->gadget); | 1838 | retval = otg_set_peripheral(udc->transceiver->otg, |
1839 | &udc->gadget); | ||
1839 | if (retval) { | 1840 | if (retval) { |
1840 | dev_err(udc->dev, "can't bind to transceiver\n"); | 1841 | dev_err(udc->dev, "can't bind to transceiver\n"); |
1841 | goto transceiver_fail; | 1842 | goto transceiver_fail; |
@@ -1908,7 +1909,7 @@ static int pxa27x_udc_stop(struct usb_gadget_driver *driver) | |||
1908 | driver->driver.name); | 1909 | driver->driver.name); |
1909 | 1910 | ||
1910 | if (udc->transceiver) | 1911 | if (udc->transceiver) |
1911 | return otg_set_peripheral(udc->transceiver, NULL); | 1912 | return otg_set_peripheral(udc->transceiver->otg, NULL); |
1912 | return 0; | 1913 | return 0; |
1913 | } | 1914 | } |
1914 | 1915 | ||
@@ -2463,7 +2464,7 @@ static int __init pxa_udc_probe(struct platform_device *pdev) | |||
2463 | 2464 | ||
2464 | udc->dev = &pdev->dev; | 2465 | udc->dev = &pdev->dev; |
2465 | udc->mach = pdev->dev.platform_data; | 2466 | udc->mach = pdev->dev.platform_data; |
2466 | udc->transceiver = otg_get_transceiver(); | 2467 | udc->transceiver = usb_get_transceiver(); |
2467 | 2468 | ||
2468 | gpio = udc->mach->gpio_pullup; | 2469 | gpio = udc->mach->gpio_pullup; |
2469 | if (gpio_is_valid(gpio)) { | 2470 | if (gpio_is_valid(gpio)) { |
@@ -2542,7 +2543,7 @@ static int __exit pxa_udc_remove(struct platform_device *_dev) | |||
2542 | if (gpio_is_valid(gpio)) | 2543 | if (gpio_is_valid(gpio)) |
2543 | gpio_free(gpio); | 2544 | gpio_free(gpio); |
2544 | 2545 | ||
2545 | otg_put_transceiver(udc->transceiver); | 2546 | usb_put_transceiver(udc->transceiver); |
2546 | 2547 | ||
2547 | udc->transceiver = NULL; | 2548 | udc->transceiver = NULL; |
2548 | platform_set_drvdata(_dev, NULL); | 2549 | platform_set_drvdata(_dev, NULL); |
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h index 7f4e8f424e80..a1d268c6f2cc 100644 --- a/drivers/usb/gadget/pxa27x_udc.h +++ b/drivers/usb/gadget/pxa27x_udc.h | |||
@@ -447,7 +447,7 @@ struct pxa_udc { | |||
447 | struct usb_gadget_driver *driver; | 447 | struct usb_gadget_driver *driver; |
448 | struct device *dev; | 448 | struct device *dev; |
449 | struct pxa2xx_udc_mach_info *mach; | 449 | struct pxa2xx_udc_mach_info *mach; |
450 | struct otg_transceiver *transceiver; | 450 | struct usb_phy *transceiver; |
451 | 451 | ||
452 | enum ep0_state ep0state; | 452 | enum ep0_state ep0state; |
453 | struct udc_stats stats; | 453 | struct udc_stats stats; |
diff --git a/drivers/usb/gadget/r8a66597-udc.c b/drivers/usb/gadget/r8a66597-udc.c index f5b8d215e1d5..c4401e7dd3a6 100644 --- a/drivers/usb/gadget/r8a66597-udc.c +++ b/drivers/usb/gadget/r8a66597-udc.c | |||
@@ -663,11 +663,7 @@ static int sudmac_alloc_channel(struct r8a66597 *r8a66597, | |||
663 | ep->fifoctr = D0FIFOCTR; | 663 | ep->fifoctr = D0FIFOCTR; |
664 | 664 | ||
665 | /* dma mapping */ | 665 | /* dma mapping */ |
666 | req->req.dma = dma_map_single(r8a66597_to_dev(ep->r8a66597), | 666 | return usb_gadget_map_request(&r8a66597->gadget, &req->req, dma->dir); |
667 | req->req.buf, req->req.length, | ||
668 | dma->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
669 | |||
670 | return 0; | ||
671 | } | 667 | } |
672 | 668 | ||
673 | static void sudmac_free_channel(struct r8a66597 *r8a66597, | 669 | static void sudmac_free_channel(struct r8a66597 *r8a66597, |
@@ -677,9 +673,7 @@ static void sudmac_free_channel(struct r8a66597 *r8a66597, | |||
677 | if (!r8a66597_is_sudmac(r8a66597)) | 673 | if (!r8a66597_is_sudmac(r8a66597)) |
678 | return; | 674 | return; |
679 | 675 | ||
680 | dma_unmap_single(r8a66597_to_dev(ep->r8a66597), | 676 | usb_gadget_unmap_request(&r8a66597->gadget, &req->req, ep->dma->dir); |
681 | req->req.dma, req->req.length, | ||
682 | ep->dma->dir ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
683 | 677 | ||
684 | r8a66597_bclr(r8a66597, DREQE, ep->fifosel); | 678 | r8a66597_bclr(r8a66597, DREQE, ep->fifosel); |
685 | r8a66597_change_curpipe(r8a66597, 0, 0, ep->fifosel); | 679 | r8a66597_change_curpipe(r8a66597, 0, 0, ep->fifosel); |
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index df8661d266cb..cef9b82ff911 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/prefetch.h> | 30 | #include <linux/prefetch.h> |
31 | #include <linux/platform_data/s3c-hsudc.h> | 31 | #include <linux/platform_data/s3c-hsudc.h> |
32 | #include <linux/regulator/consumer.h> | 32 | #include <linux/regulator/consumer.h> |
33 | #include <linux/pm_runtime.h> | ||
33 | 34 | ||
34 | #include <mach/regs-s3c2443-clock.h> | 35 | #include <mach/regs-s3c2443-clock.h> |
35 | 36 | ||
@@ -145,7 +146,7 @@ struct s3c_hsudc { | |||
145 | struct usb_gadget_driver *driver; | 146 | struct usb_gadget_driver *driver; |
146 | struct device *dev; | 147 | struct device *dev; |
147 | struct s3c24xx_hsudc_platdata *pd; | 148 | struct s3c24xx_hsudc_platdata *pd; |
148 | struct otg_transceiver *transceiver; | 149 | struct usb_phy *transceiver; |
149 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; | 150 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; |
150 | spinlock_t lock; | 151 | spinlock_t lock; |
151 | void __iomem *regs; | 152 | void __iomem *regs; |
@@ -759,7 +760,7 @@ static int s3c_hsudc_ep_enable(struct usb_ep *_ep, | |||
759 | unsigned long flags; | 760 | unsigned long flags; |
760 | u32 ecr = 0; | 761 | u32 ecr = 0; |
761 | 762 | ||
762 | hsep = container_of(_ep, struct s3c_hsudc_ep, ep); | 763 | hsep = our_ep(_ep); |
763 | if (!_ep || !desc || hsep->desc || _ep->name == ep0name | 764 | if (!_ep || !desc || hsep->desc || _ep->name == ep0name |
764 | || desc->bDescriptorType != USB_DT_ENDPOINT | 765 | || desc->bDescriptorType != USB_DT_ENDPOINT |
765 | || hsep->bEndpointAddress != desc->bEndpointAddress | 766 | || hsep->bEndpointAddress != desc->bEndpointAddress |
@@ -816,6 +817,7 @@ static int s3c_hsudc_ep_disable(struct usb_ep *_ep) | |||
816 | s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); | 817 | s3c_hsudc_nuke_ep(hsep, -ESHUTDOWN); |
817 | 818 | ||
818 | hsep->desc = 0; | 819 | hsep->desc = 0; |
820 | hsep->ep.desc = NULL; | ||
819 | hsep->stopped = 1; | 821 | hsep->stopped = 1; |
820 | 822 | ||
821 | spin_unlock_irqrestore(&hsudc->lock, flags); | 823 | spin_unlock_irqrestore(&hsudc->lock, flags); |
@@ -853,7 +855,7 @@ static void s3c_hsudc_free_request(struct usb_ep *ep, struct usb_request *_req) | |||
853 | { | 855 | { |
854 | struct s3c_hsudc_req *hsreq; | 856 | struct s3c_hsudc_req *hsreq; |
855 | 857 | ||
856 | hsreq = container_of(_req, struct s3c_hsudc_req, req); | 858 | hsreq = our_req(_req); |
857 | WARN_ON(!list_empty(&hsreq->queue)); | 859 | WARN_ON(!list_empty(&hsreq->queue)); |
858 | kfree(hsreq); | 860 | kfree(hsreq); |
859 | } | 861 | } |
@@ -876,12 +878,12 @@ static int s3c_hsudc_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
876 | u32 offset; | 878 | u32 offset; |
877 | u32 csr; | 879 | u32 csr; |
878 | 880 | ||
879 | hsreq = container_of(_req, struct s3c_hsudc_req, req); | 881 | hsreq = our_req(_req); |
880 | if ((!_req || !_req->complete || !_req->buf || | 882 | if ((!_req || !_req->complete || !_req->buf || |
881 | !list_empty(&hsreq->queue))) | 883 | !list_empty(&hsreq->queue))) |
882 | return -EINVAL; | 884 | return -EINVAL; |
883 | 885 | ||
884 | hsep = container_of(_ep, struct s3c_hsudc_ep, ep); | 886 | hsep = our_ep(_ep); |
885 | hsudc = hsep->dev; | 887 | hsudc = hsep->dev; |
886 | if (!hsudc->driver || hsudc->gadget.speed == USB_SPEED_UNKNOWN) | 888 | if (!hsudc->driver || hsudc->gadget.speed == USB_SPEED_UNKNOWN) |
887 | return -ESHUTDOWN; | 889 | return -ESHUTDOWN; |
@@ -935,7 +937,7 @@ static int s3c_hsudc_dequeue(struct usb_ep *_ep, struct usb_request *_req) | |||
935 | struct s3c_hsudc_req *hsreq; | 937 | struct s3c_hsudc_req *hsreq; |
936 | unsigned long flags; | 938 | unsigned long flags; |
937 | 939 | ||
938 | hsep = container_of(_ep, struct s3c_hsudc_ep, ep); | 940 | hsep = our_ep(_ep); |
939 | if (!_ep || hsep->ep.name == ep0name) | 941 | if (!_ep || hsep->ep.name == ep0name) |
940 | return -EINVAL; | 942 | return -EINVAL; |
941 | 943 | ||
@@ -1005,6 +1007,7 @@ static void s3c_hsudc_initep(struct s3c_hsudc *hsudc, | |||
1005 | hsep->ep.ops = &s3c_hsudc_ep_ops; | 1007 | hsep->ep.ops = &s3c_hsudc_ep_ops; |
1006 | hsep->fifo = hsudc->regs + S3C_BR(epnum); | 1008 | hsep->fifo = hsudc->regs + S3C_BR(epnum); |
1007 | hsep->desc = 0; | 1009 | hsep->desc = 0; |
1010 | hsep->ep.desc = NULL; | ||
1008 | hsep->stopped = 0; | 1011 | hsep->stopped = 0; |
1009 | hsep->wedge = 0; | 1012 | hsep->wedge = 0; |
1010 | 1013 | ||
@@ -1166,7 +1169,8 @@ static int s3c_hsudc_start(struct usb_gadget *gadget, | |||
1166 | 1169 | ||
1167 | /* connect to bus through transceiver */ | 1170 | /* connect to bus through transceiver */ |
1168 | if (hsudc->transceiver) { | 1171 | if (hsudc->transceiver) { |
1169 | ret = otg_set_peripheral(hsudc->transceiver, &hsudc->gadget); | 1172 | ret = otg_set_peripheral(hsudc->transceiver->otg, |
1173 | &hsudc->gadget); | ||
1170 | if (ret) { | 1174 | if (ret) { |
1171 | dev_err(hsudc->dev, "%s: can't bind to transceiver\n", | 1175 | dev_err(hsudc->dev, "%s: can't bind to transceiver\n", |
1172 | hsudc->gadget.name); | 1176 | hsudc->gadget.name); |
@@ -1178,6 +1182,9 @@ static int s3c_hsudc_start(struct usb_gadget *gadget, | |||
1178 | dev_info(hsudc->dev, "bound driver %s\n", driver->driver.name); | 1182 | dev_info(hsudc->dev, "bound driver %s\n", driver->driver.name); |
1179 | 1183 | ||
1180 | s3c_hsudc_reconfig(hsudc); | 1184 | s3c_hsudc_reconfig(hsudc); |
1185 | |||
1186 | pm_runtime_get_sync(hsudc->dev); | ||
1187 | |||
1181 | s3c_hsudc_init_phy(); | 1188 | s3c_hsudc_init_phy(); |
1182 | if (hsudc->pd->gpio_init) | 1189 | if (hsudc->pd->gpio_init) |
1183 | hsudc->pd->gpio_init(); | 1190 | hsudc->pd->gpio_init(); |
@@ -1208,13 +1215,16 @@ static int s3c_hsudc_stop(struct usb_gadget *gadget, | |||
1208 | hsudc->gadget.dev.driver = NULL; | 1215 | hsudc->gadget.dev.driver = NULL; |
1209 | hsudc->gadget.speed = USB_SPEED_UNKNOWN; | 1216 | hsudc->gadget.speed = USB_SPEED_UNKNOWN; |
1210 | s3c_hsudc_uninit_phy(); | 1217 | s3c_hsudc_uninit_phy(); |
1218 | |||
1219 | pm_runtime_put(hsudc->dev); | ||
1220 | |||
1211 | if (hsudc->pd->gpio_uninit) | 1221 | if (hsudc->pd->gpio_uninit) |
1212 | hsudc->pd->gpio_uninit(); | 1222 | hsudc->pd->gpio_uninit(); |
1213 | s3c_hsudc_stop_activity(hsudc); | 1223 | s3c_hsudc_stop_activity(hsudc); |
1214 | spin_unlock_irqrestore(&hsudc->lock, flags); | 1224 | spin_unlock_irqrestore(&hsudc->lock, flags); |
1215 | 1225 | ||
1216 | if (hsudc->transceiver) | 1226 | if (hsudc->transceiver) |
1217 | (void) otg_set_peripheral(hsudc->transceiver, NULL); | 1227 | (void) otg_set_peripheral(hsudc->transceiver->otg, NULL); |
1218 | 1228 | ||
1219 | disable_irq(hsudc->irq); | 1229 | disable_irq(hsudc->irq); |
1220 | 1230 | ||
@@ -1243,7 +1253,7 @@ static int s3c_hsudc_vbus_draw(struct usb_gadget *gadget, unsigned mA) | |||
1243 | return -ENODEV; | 1253 | return -ENODEV; |
1244 | 1254 | ||
1245 | if (hsudc->transceiver) | 1255 | if (hsudc->transceiver) |
1246 | return otg_set_power(hsudc->transceiver, mA); | 1256 | return usb_phy_set_power(hsudc->transceiver, mA); |
1247 | 1257 | ||
1248 | return -EOPNOTSUPP; | 1258 | return -EOPNOTSUPP; |
1249 | } | 1259 | } |
@@ -1275,7 +1285,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1275 | hsudc->dev = dev; | 1285 | hsudc->dev = dev; |
1276 | hsudc->pd = pdev->dev.platform_data; | 1286 | hsudc->pd = pdev->dev.platform_data; |
1277 | 1287 | ||
1278 | hsudc->transceiver = otg_get_transceiver(); | 1288 | hsudc->transceiver = usb_get_transceiver(); |
1279 | 1289 | ||
1280 | for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++) | 1290 | for (i = 0; i < ARRAY_SIZE(hsudc->supplies); i++) |
1281 | hsudc->supplies[i].supply = s3c_hsudc_supply_names[i]; | 1291 | hsudc->supplies[i].supply = s3c_hsudc_supply_names[i]; |
@@ -1362,6 +1372,8 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1362 | if (ret) | 1372 | if (ret) |
1363 | goto err_add_udc; | 1373 | goto err_add_udc; |
1364 | 1374 | ||
1375 | pm_runtime_enable(dev); | ||
1376 | |||
1365 | return 0; | 1377 | return 0; |
1366 | err_add_udc: | 1378 | err_add_udc: |
1367 | device_unregister(&hsudc->gadget.dev); | 1379 | device_unregister(&hsudc->gadget.dev); |
@@ -1377,7 +1389,7 @@ err_remap: | |||
1377 | release_mem_region(res->start, resource_size(res)); | 1389 | release_mem_region(res->start, resource_size(res)); |
1378 | err_res: | 1390 | err_res: |
1379 | if (hsudc->transceiver) | 1391 | if (hsudc->transceiver) |
1380 | otg_put_transceiver(hsudc->transceiver); | 1392 | usb_put_transceiver(hsudc->transceiver); |
1381 | 1393 | ||
1382 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); | 1394 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); |
1383 | err_supplies: | 1395 | err_supplies: |
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 3f87cb9344bb..ab9c65e2c1d5 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c | |||
@@ -1148,6 +1148,7 @@ static int s3c2410_udc_ep_disable(struct usb_ep *_ep) | |||
1148 | dprintk(DEBUG_NORMAL, "ep_disable: %s\n", _ep->name); | 1148 | dprintk(DEBUG_NORMAL, "ep_disable: %s\n", _ep->name); |
1149 | 1149 | ||
1150 | ep->desc = NULL; | 1150 | ep->desc = NULL; |
1151 | ep->ep.desc = NULL; | ||
1151 | ep->halted = 1; | 1152 | ep->halted = 1; |
1152 | 1153 | ||
1153 | s3c2410_udc_nuke (ep->dev, ep, -ESHUTDOWN); | 1154 | s3c2410_udc_nuke (ep->dev, ep, -ESHUTDOWN); |
@@ -1630,6 +1631,7 @@ static void s3c2410_udc_reinit(struct s3c2410_udc *dev) | |||
1630 | 1631 | ||
1631 | ep->dev = dev; | 1632 | ep->dev = dev; |
1632 | ep->desc = NULL; | 1633 | ep->desc = NULL; |
1634 | ep->ep.desc = NULL; | ||
1633 | ep->halted = 0; | 1635 | ep->halted = 0; |
1634 | INIT_LIST_HEAD (&ep->queue); | 1636 | INIT_LIST_HEAD (&ep->queue); |
1635 | } | 1637 | } |
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index ad9e5b2df642..665c07422c26 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c | |||
@@ -242,7 +242,7 @@ static struct usb_composite_driver gserial_driver = { | |||
242 | .name = "g_serial", | 242 | .name = "g_serial", |
243 | .dev = &device_desc, | 243 | .dev = &device_desc, |
244 | .strings = dev_strings, | 244 | .strings = dev_strings, |
245 | .max_speed = USB_SPEED_HIGH, | 245 | .max_speed = USB_SPEED_SUPER, |
246 | }; | 246 | }; |
247 | 247 | ||
248 | static int __init init(void) | 248 | static int __init init(void) |
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 85ea14e2545e..8081ca3a70a2 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2003-2008 Alan Stern | 4 | * Copyright (C) 2003-2008 Alan Stern |
5 | * Copyeight (C) 2009 Samsung Electronics | 5 | * Copyeight (C) 2009 Samsung Electronics |
6 | * Author: Michal Nazarewicz (m.nazarewicz@samsung.com) | 6 | * Author: Michal Nazarewicz (mina86@mina86.com) |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 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 | 9 | * it under the terms of the GNU General Public License as published by |
@@ -145,48 +145,8 @@ | |||
145 | 145 | ||
146 | #endif /* DUMP_MSGS */ | 146 | #endif /* DUMP_MSGS */ |
147 | 147 | ||
148 | |||
149 | |||
150 | |||
151 | |||
152 | /*-------------------------------------------------------------------------*/ | 148 | /*-------------------------------------------------------------------------*/ |
153 | 149 | ||
154 | /* Bulk-only data structures */ | ||
155 | |||
156 | /* Command Block Wrapper */ | ||
157 | struct fsg_bulk_cb_wrap { | ||
158 | __le32 Signature; /* Contains 'USBC' */ | ||
159 | u32 Tag; /* Unique per command id */ | ||
160 | __le32 DataTransferLength; /* Size of the data */ | ||
161 | u8 Flags; /* Direction in bit 7 */ | ||
162 | u8 Lun; /* LUN (normally 0) */ | ||
163 | u8 Length; /* Of the CDB, <= MAX_COMMAND_SIZE */ | ||
164 | u8 CDB[16]; /* Command Data Block */ | ||
165 | }; | ||
166 | |||
167 | #define USB_BULK_CB_WRAP_LEN 31 | ||
168 | #define USB_BULK_CB_SIG 0x43425355 /* Spells out USBC */ | ||
169 | #define USB_BULK_IN_FLAG 0x80 | ||
170 | |||
171 | /* Command Status Wrapper */ | ||
172 | struct bulk_cs_wrap { | ||
173 | __le32 Signature; /* Should = 'USBS' */ | ||
174 | u32 Tag; /* Same as original command */ | ||
175 | __le32 Residue; /* Amount not transferred */ | ||
176 | u8 Status; /* See below */ | ||
177 | }; | ||
178 | |||
179 | #define USB_BULK_CS_WRAP_LEN 13 | ||
180 | #define USB_BULK_CS_SIG 0x53425355 /* Spells out 'USBS' */ | ||
181 | #define USB_STATUS_PASS 0 | ||
182 | #define USB_STATUS_FAIL 1 | ||
183 | #define USB_STATUS_PHASE_ERROR 2 | ||
184 | |||
185 | /* Bulk-only class specific requests */ | ||
186 | #define USB_BULK_RESET_REQUEST 0xff | ||
187 | #define USB_BULK_GET_MAX_LUN_REQUEST 0xfe | ||
188 | |||
189 | |||
190 | /* CBI Interrupt data structure */ | 150 | /* CBI Interrupt data structure */ |
191 | struct interrupt_data { | 151 | struct interrupt_data { |
192 | u8 bType; | 152 | u8 bType; |
diff --git a/drivers/usb/gadget/u_audio.c b/drivers/usb/gadget/u_uac1.c index 59ffe1ecf1c9..af9898982059 100644 --- a/drivers/usb/gadget/u_audio.c +++ b/drivers/usb/gadget/u_uac1.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * u_audio.c -- ALSA audio utilities for Gadget stack | 2 | * u_uac1.c -- ALSA audio utilities for Gadget stack |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org> | 4 | * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org> |
5 | * Copyright (C) 2008 Analog Devices, Inc | 5 | * Copyright (C) 2008 Analog Devices, Inc |
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/random.h> | 17 | #include <linux/random.h> |
18 | #include <linux/syscalls.h> | 18 | #include <linux/syscalls.h> |
19 | 19 | ||
20 | #include "u_audio.h" | 20 | #include "u_uac1.h" |
21 | 21 | ||
22 | /* | 22 | /* |
23 | * This component encapsulates the ALSA devices for USB audio gadget | 23 | * This component encapsulates the ALSA devices for USB audio gadget |
diff --git a/drivers/usb/gadget/u_audio.h b/drivers/usb/gadget/u_uac1.h index 08ffce3298e6..18c2e729faf6 100644 --- a/drivers/usb/gadget/u_audio.h +++ b/drivers/usb/gadget/u_uac1.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * u_audio.h -- interface to USB gadget "ALSA AUDIO" utilities | 2 | * u_uac1.h -- interface to USB gadget "ALSA AUDIO" utilities |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org> | 4 | * Copyright (C) 2008 Bryan Wu <cooloney@kernel.org> |
5 | * Copyright (C) 2008 Analog Devices, Inc | 5 | * Copyright (C) 2008 Analog Devices, Inc |
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 0b0d12ccc487..56da49f31d6c 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/list.h> | 23 | #include <linux/list.h> |
24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/dma-mapping.h> | ||
25 | 26 | ||
26 | #include <linux/usb/ch9.h> | 27 | #include <linux/usb/ch9.h> |
27 | #include <linux/usb/gadget.h> | 28 | #include <linux/usb/gadget.h> |
@@ -49,6 +50,57 @@ static DEFINE_MUTEX(udc_lock); | |||
49 | 50 | ||
50 | /* ------------------------------------------------------------------------- */ | 51 | /* ------------------------------------------------------------------------- */ |
51 | 52 | ||
53 | int usb_gadget_map_request(struct usb_gadget *gadget, | ||
54 | struct usb_request *req, int is_in) | ||
55 | { | ||
56 | if (req->length == 0) | ||
57 | return 0; | ||
58 | |||
59 | if (req->num_sgs) { | ||
60 | int mapped; | ||
61 | |||
62 | mapped = dma_map_sg(&gadget->dev, req->sg, req->num_sgs, | ||
63 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
64 | if (mapped == 0) { | ||
65 | dev_err(&gadget->dev, "failed to map SGs\n"); | ||
66 | return -EFAULT; | ||
67 | } | ||
68 | |||
69 | req->num_mapped_sgs = mapped; | ||
70 | } else { | ||
71 | req->dma = dma_map_single(&gadget->dev, req->buf, req->length, | ||
72 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
73 | |||
74 | if (dma_mapping_error(&gadget->dev, req->dma)) { | ||
75 | dev_err(&gadget->dev, "failed to map buffer\n"); | ||
76 | return -EFAULT; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(usb_gadget_map_request); | ||
83 | |||
84 | void usb_gadget_unmap_request(struct usb_gadget *gadget, | ||
85 | struct usb_request *req, int is_in) | ||
86 | { | ||
87 | if (req->length == 0) | ||
88 | return; | ||
89 | |||
90 | if (req->num_mapped_sgs) { | ||
91 | dma_unmap_sg(&gadget->dev, req->sg, req->num_mapped_sgs, | ||
92 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
93 | |||
94 | req->num_mapped_sgs = 0; | ||
95 | } else { | ||
96 | dma_unmap_single(&gadget->dev, req->dma, req->length, | ||
97 | is_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
98 | } | ||
99 | } | ||
100 | EXPORT_SYMBOL_GPL(usb_gadget_unmap_request); | ||
101 | |||
102 | /* ------------------------------------------------------------------------- */ | ||
103 | |||
52 | /** | 104 | /** |
53 | * usb_gadget_start - tells usb device controller to start up | 105 | * usb_gadget_start - tells usb device controller to start up |
54 | * @gadget: The gadget we want to get started | 106 | * @gadget: The gadget we want to get started |
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 353cdd488b93..f788eb86707c 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -27,6 +27,10 @@ config USB_XHCI_HCD | |||
27 | To compile this driver as a module, choose M here: the | 27 | To compile this driver as a module, choose M here: the |
28 | module will be called xhci-hcd. | 28 | module will be called xhci-hcd. |
29 | 29 | ||
30 | config USB_XHCI_PLATFORM | ||
31 | tristate | ||
32 | depends on USB_XHCI_HCD | ||
33 | |||
30 | config USB_XHCI_HCD_DEBUGGING | 34 | config USB_XHCI_HCD_DEBUGGING |
31 | bool "Debugging for the xHCI host controller" | 35 | bool "Debugging for the xHCI host controller" |
32 | depends on USB_XHCI_HCD | 36 | depends on USB_XHCI_HCD |
@@ -196,7 +200,7 @@ config USB_EHCI_S5P | |||
196 | 200 | ||
197 | config USB_EHCI_MV | 201 | config USB_EHCI_MV |
198 | bool "EHCI support for Marvell on-chip controller" | 202 | bool "EHCI support for Marvell on-chip controller" |
199 | depends on USB_EHCI_HCD | 203 | depends on USB_EHCI_HCD && (ARCH_PXA || ARCH_MMP) |
200 | select USB_EHCI_ROOT_HUB_TT | 204 | select USB_EHCI_ROOT_HUB_TT |
201 | ---help--- | 205 | ---help--- |
202 | Enables support for Marvell (including PXA and MMP series) on-chip | 206 | Enables support for Marvell (including PXA and MMP series) on-chip |
@@ -218,11 +222,15 @@ config USB_CNS3XXX_EHCI | |||
218 | support. | 222 | support. |
219 | 223 | ||
220 | config USB_EHCI_ATH79 | 224 | config USB_EHCI_ATH79 |
221 | bool "EHCI support for AR7XXX/AR9XXX SoCs" | 225 | bool "EHCI support for AR7XXX/AR9XXX SoCs (DEPRECATED)" |
222 | depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X) | 226 | depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X) |
223 | select USB_EHCI_ROOT_HUB_TT | 227 | select USB_EHCI_ROOT_HUB_TT |
228 | select USB_EHCI_HCD_PLATFORM | ||
224 | default y | 229 | default y |
225 | ---help--- | 230 | ---help--- |
231 | This option is deprecated now and the driver was removed, use | ||
232 | USB_EHCI_HCD_PLATFORM instead. | ||
233 | |||
226 | Enables support for the built-in EHCI controller present | 234 | Enables support for the built-in EHCI controller present |
227 | on the Atheros AR7XXX/AR9XXX SoCs. | 235 | on the Atheros AR7XXX/AR9XXX SoCs. |
228 | 236 | ||
@@ -312,10 +320,14 @@ config USB_OHCI_HCD_OMAP3 | |||
312 | OMAP3 and later chips. | 320 | OMAP3 and later chips. |
313 | 321 | ||
314 | config USB_OHCI_ATH79 | 322 | config USB_OHCI_ATH79 |
315 | bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs" | 323 | bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs (DEPRECATED)" |
316 | depends on USB_OHCI_HCD && (SOC_AR71XX || SOC_AR724X) | 324 | depends on USB_OHCI_HCD && (SOC_AR71XX || SOC_AR724X) |
325 | select USB_OHCI_HCD_PLATFORM | ||
317 | default y | 326 | default y |
318 | help | 327 | help |
328 | This option is deprecated now and the driver was removed, use | ||
329 | USB_OHCI_HCD_PLATFORM instead. | ||
330 | |||
319 | Enables support for the built-in OHCI controller present on the | 331 | Enables support for the built-in OHCI controller present on the |
320 | Atheros AR71XX/AR7240 SoCs. | 332 | Atheros AR71XX/AR7240 SoCs. |
321 | 333 | ||
@@ -393,6 +405,26 @@ config USB_CNS3XXX_OHCI | |||
393 | Enable support for the CNS3XXX SOC's on-chip OHCI controller. | 405 | Enable support for the CNS3XXX SOC's on-chip OHCI controller. |
394 | It is needed for low-speed USB 1.0 device support. | 406 | It is needed for low-speed USB 1.0 device support. |
395 | 407 | ||
408 | config USB_OHCI_HCD_PLATFORM | ||
409 | bool "Generic OHCI driver for a platform device" | ||
410 | depends on USB_OHCI_HCD && EXPERIMENTAL | ||
411 | default n | ||
412 | ---help--- | ||
413 | Adds an OHCI host driver for a generic platform device, which | ||
414 | provieds a memory space and an irq. | ||
415 | |||
416 | If unsure, say N. | ||
417 | |||
418 | config USB_EHCI_HCD_PLATFORM | ||
419 | bool "Generic EHCI driver for a platform device" | ||
420 | depends on USB_EHCI_HCD && EXPERIMENTAL | ||
421 | default n | ||
422 | ---help--- | ||
423 | Adds an EHCI host driver for a generic platform device, which | ||
424 | provieds a memory space and an irq. | ||
425 | |||
426 | If unsure, say N. | ||
427 | |||
396 | config USB_OHCI_BIG_ENDIAN_DESC | 428 | config USB_OHCI_BIG_ENDIAN_DESC |
397 | bool | 429 | bool |
398 | depends on USB_OHCI_HCD | 430 | depends on USB_OHCI_HCD |
@@ -606,10 +638,3 @@ config USB_OCTEON_OHCI | |||
606 | config USB_OCTEON2_COMMON | 638 | config USB_OCTEON2_COMMON |
607 | bool | 639 | bool |
608 | default y if USB_OCTEON_EHCI || USB_OCTEON_OHCI | 640 | default y if USB_OCTEON_EHCI || USB_OCTEON_OHCI |
609 | |||
610 | config USB_PXA168_EHCI | ||
611 | bool "Marvell PXA168 on-chip EHCI HCD support" | ||
612 | depends on USB_EHCI_HCD && ARCH_MMP | ||
613 | help | ||
614 | Enable support for Marvell PXA168 SoC's on-chip EHCI | ||
615 | host controller | ||
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index 7ca290fcb070..0982bcc140bd 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile | |||
@@ -15,6 +15,10 @@ xhci-hcd-y := xhci.o xhci-mem.o | |||
15 | xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o | 15 | xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o |
16 | xhci-hcd-$(CONFIG_PCI) += xhci-pci.o | 16 | xhci-hcd-$(CONFIG_PCI) += xhci-pci.o |
17 | 17 | ||
18 | ifneq ($(CONFIG_USB_XHCI_PLATFORM), ) | ||
19 | xhci-hcd-y += xhci-plat.o | ||
20 | endif | ||
21 | |||
18 | obj-$(CONFIG_USB_WHCI_HCD) += whci/ | 22 | obj-$(CONFIG_USB_WHCI_HCD) += whci/ |
19 | 23 | ||
20 | obj-$(CONFIG_PCI) += pci-quirks.o | 24 | obj-$(CONFIG_PCI) += pci-quirks.o |
diff --git a/drivers/usb/host/ehci-ath79.c b/drivers/usb/host/ehci-ath79.c deleted file mode 100644 index f1424f9bc363..000000000000 --- a/drivers/usb/host/ehci-ath79.c +++ /dev/null | |||
@@ -1,208 +0,0 @@ | |||
1 | /* | ||
2 | * Bus Glue for Atheros AR7XXX/AR9XXX built-in EHCI controller. | ||
3 | * | ||
4 | * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> | ||
5 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> | ||
6 | * | ||
7 | * Parts of this file are based on Atheros' 2.6.15 BSP | ||
8 | * Copyright (C) 2007 Atheros Communications, Inc. | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify it | ||
11 | * under the terms of the GNU General Public License version 2 as published | ||
12 | * by the Free Software Foundation. | ||
13 | */ | ||
14 | |||
15 | #include <linux/platform_device.h> | ||
16 | |||
17 | enum { | ||
18 | EHCI_ATH79_IP_V1 = 0, | ||
19 | EHCI_ATH79_IP_V2, | ||
20 | }; | ||
21 | |||
22 | static const struct platform_device_id ehci_ath79_id_table[] = { | ||
23 | { | ||
24 | .name = "ar71xx-ehci", | ||
25 | .driver_data = EHCI_ATH79_IP_V1, | ||
26 | }, | ||
27 | { | ||
28 | .name = "ar724x-ehci", | ||
29 | .driver_data = EHCI_ATH79_IP_V2, | ||
30 | }, | ||
31 | { | ||
32 | .name = "ar913x-ehci", | ||
33 | .driver_data = EHCI_ATH79_IP_V2, | ||
34 | }, | ||
35 | { | ||
36 | .name = "ar933x-ehci", | ||
37 | .driver_data = EHCI_ATH79_IP_V2, | ||
38 | }, | ||
39 | { | ||
40 | /* terminating entry */ | ||
41 | }, | ||
42 | }; | ||
43 | |||
44 | MODULE_DEVICE_TABLE(platform, ehci_ath79_id_table); | ||
45 | |||
46 | static int ehci_ath79_init(struct usb_hcd *hcd) | ||
47 | { | ||
48 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
49 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | ||
50 | const struct platform_device_id *id; | ||
51 | int ret; | ||
52 | |||
53 | id = platform_get_device_id(pdev); | ||
54 | if (!id) { | ||
55 | dev_err(hcd->self.controller, "missing device id\n"); | ||
56 | return -EINVAL; | ||
57 | } | ||
58 | |||
59 | switch (id->driver_data) { | ||
60 | case EHCI_ATH79_IP_V1: | ||
61 | ehci->has_synopsys_hc_bug = 1; | ||
62 | |||
63 | ehci->caps = hcd->regs; | ||
64 | ehci->regs = hcd->regs + | ||
65 | HC_LENGTH(ehci, | ||
66 | ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
67 | break; | ||
68 | |||
69 | case EHCI_ATH79_IP_V2: | ||
70 | hcd->has_tt = 1; | ||
71 | |||
72 | ehci->caps = hcd->regs + 0x100; | ||
73 | ehci->regs = hcd->regs + 0x100 + | ||
74 | HC_LENGTH(ehci, | ||
75 | ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
76 | break; | ||
77 | |||
78 | default: | ||
79 | BUG(); | ||
80 | } | ||
81 | |||
82 | dbg_hcs_params(ehci, "reset"); | ||
83 | dbg_hcc_params(ehci, "reset"); | ||
84 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
85 | ehci->sbrn = 0x20; | ||
86 | |||
87 | ehci_reset(ehci); | ||
88 | |||
89 | ret = ehci_init(hcd); | ||
90 | if (ret) | ||
91 | return ret; | ||
92 | |||
93 | ehci_port_power(ehci, 0); | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static const struct hc_driver ehci_ath79_hc_driver = { | ||
99 | .description = hcd_name, | ||
100 | .product_desc = "Atheros built-in EHCI controller", | ||
101 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
102 | .irq = ehci_irq, | ||
103 | .flags = HCD_MEMORY | HCD_USB2, | ||
104 | |||
105 | .reset = ehci_ath79_init, | ||
106 | .start = ehci_run, | ||
107 | .stop = ehci_stop, | ||
108 | .shutdown = ehci_shutdown, | ||
109 | |||
110 | .urb_enqueue = ehci_urb_enqueue, | ||
111 | .urb_dequeue = ehci_urb_dequeue, | ||
112 | .endpoint_disable = ehci_endpoint_disable, | ||
113 | .endpoint_reset = ehci_endpoint_reset, | ||
114 | |||
115 | .get_frame_number = ehci_get_frame, | ||
116 | |||
117 | .hub_status_data = ehci_hub_status_data, | ||
118 | .hub_control = ehci_hub_control, | ||
119 | |||
120 | .relinquish_port = ehci_relinquish_port, | ||
121 | .port_handed_over = ehci_port_handed_over, | ||
122 | |||
123 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
124 | }; | ||
125 | |||
126 | static int ehci_ath79_probe(struct platform_device *pdev) | ||
127 | { | ||
128 | struct usb_hcd *hcd; | ||
129 | struct resource *res; | ||
130 | int irq; | ||
131 | int ret; | ||
132 | |||
133 | if (usb_disabled()) | ||
134 | return -ENODEV; | ||
135 | |||
136 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
137 | if (!res) { | ||
138 | dev_dbg(&pdev->dev, "no IRQ specified\n"); | ||
139 | return -ENODEV; | ||
140 | } | ||
141 | irq = res->start; | ||
142 | |||
143 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
144 | if (!res) { | ||
145 | dev_dbg(&pdev->dev, "no base address specified\n"); | ||
146 | return -ENODEV; | ||
147 | } | ||
148 | |||
149 | hcd = usb_create_hcd(&ehci_ath79_hc_driver, &pdev->dev, | ||
150 | dev_name(&pdev->dev)); | ||
151 | if (!hcd) | ||
152 | return -ENOMEM; | ||
153 | |||
154 | hcd->rsrc_start = res->start; | ||
155 | hcd->rsrc_len = resource_size(res); | ||
156 | |||
157 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
158 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
159 | ret = -EBUSY; | ||
160 | goto err_put_hcd; | ||
161 | } | ||
162 | |||
163 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
164 | if (!hcd->regs) { | ||
165 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
166 | ret = -EFAULT; | ||
167 | goto err_release_region; | ||
168 | } | ||
169 | |||
170 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
171 | if (ret) | ||
172 | goto err_iounmap; | ||
173 | |||
174 | return 0; | ||
175 | |||
176 | err_iounmap: | ||
177 | iounmap(hcd->regs); | ||
178 | |||
179 | err_release_region: | ||
180 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
181 | err_put_hcd: | ||
182 | usb_put_hcd(hcd); | ||
183 | return ret; | ||
184 | } | ||
185 | |||
186 | static int ehci_ath79_remove(struct platform_device *pdev) | ||
187 | { | ||
188 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
189 | |||
190 | usb_remove_hcd(hcd); | ||
191 | iounmap(hcd->regs); | ||
192 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
193 | usb_put_hcd(hcd); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static struct platform_driver ehci_ath79_driver = { | ||
199 | .probe = ehci_ath79_probe, | ||
200 | .remove = ehci_ath79_remove, | ||
201 | .id_table = ehci_ath79_id_table, | ||
202 | .driver = { | ||
203 | .owner = THIS_MODULE, | ||
204 | .name = "ath79-ehci", | ||
205 | } | ||
206 | }; | ||
207 | |||
208 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ath79-ehci"); | ||
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c index d6d74d2e09f4..fd9109d7eb0e 100644 --- a/drivers/usb/host/ehci-dbg.c +++ b/drivers/usb/host/ehci-dbg.c | |||
@@ -107,7 +107,7 @@ static void dbg_hcc_params (struct ehci_hcd *ehci, char *label) | |||
107 | HCC_PER_PORT_CHANGE_EVENT(params) ? " ppce" : "", | 107 | HCC_PER_PORT_CHANGE_EVENT(params) ? " ppce" : "", |
108 | HCC_HW_PREFETCH(params) ? " hw prefetch" : "", | 108 | HCC_HW_PREFETCH(params) ? " hw prefetch" : "", |
109 | HCC_32FRAME_PERIODIC_LIST(params) ? | 109 | HCC_32FRAME_PERIODIC_LIST(params) ? |
110 | " 32 peridic list" : ""); | 110 | " 32 periodic list" : ""); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | #else | 113 | #else |
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c index b556a72264d1..3e7345172e03 100644 --- a/drivers/usb/host/ehci-fsl.c +++ b/drivers/usb/host/ehci-fsl.c | |||
@@ -142,12 +142,12 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver, | |||
142 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { | 142 | if (pdata->operating_mode == FSL_USB2_DR_OTG) { |
143 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 143 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
144 | 144 | ||
145 | ehci->transceiver = otg_get_transceiver(); | 145 | ehci->transceiver = usb_get_transceiver(); |
146 | dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", | 146 | dev_dbg(&pdev->dev, "hcd=0x%p ehci=0x%p, transceiver=0x%p\n", |
147 | hcd, ehci, ehci->transceiver); | 147 | hcd, ehci, ehci->transceiver); |
148 | 148 | ||
149 | if (ehci->transceiver) { | 149 | if (ehci->transceiver) { |
150 | retval = otg_set_host(ehci->transceiver, | 150 | retval = otg_set_host(ehci->transceiver->otg, |
151 | &ehci_to_hcd(ehci)->self); | 151 | &ehci_to_hcd(ehci)->self); |
152 | if (retval) { | 152 | if (retval) { |
153 | if (ehci->transceiver) | 153 | if (ehci->transceiver) |
@@ -194,7 +194,7 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd, | |||
194 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 194 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
195 | 195 | ||
196 | if (ehci->transceiver) { | 196 | if (ehci->transceiver) { |
197 | otg_set_host(ehci->transceiver, NULL); | 197 | otg_set_host(ehci->transceiver->otg, NULL); |
198 | put_device(ehci->transceiver->dev); | 198 | put_device(ehci->transceiver->dev); |
199 | } | 199 | } |
200 | 200 | ||
@@ -216,6 +216,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci, | |||
216 | unsigned int port_offset) | 216 | unsigned int port_offset) |
217 | { | 217 | { |
218 | u32 portsc; | 218 | u32 portsc; |
219 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | ||
220 | void __iomem *non_ehci = hcd->regs; | ||
219 | 221 | ||
220 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); | 222 | portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); |
221 | portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW); | 223 | portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW); |
@@ -231,6 +233,8 @@ static void ehci_fsl_setup_phy(struct ehci_hcd *ehci, | |||
231 | portsc |= PORT_PTS_PTW; | 233 | portsc |= PORT_PTS_PTW; |
232 | /* fall through */ | 234 | /* fall through */ |
233 | case FSL_USB2_PHY_UTMI: | 235 | case FSL_USB2_PHY_UTMI: |
236 | /* enable UTMI PHY */ | ||
237 | setbits32(non_ehci + FSL_SOC_USB_CTRL, CTRL_UTMI_PHY_EN); | ||
234 | portsc |= PORT_PTS_UTMI; | 238 | portsc |= PORT_PTS_UTMI; |
235 | break; | 239 | break; |
236 | case FSL_USB2_PHY_NONE: | 240 | case FSL_USB2_PHY_NONE: |
@@ -252,21 +256,18 @@ static void ehci_fsl_usb_setup(struct ehci_hcd *ehci) | |||
252 | if (pdata->have_sysif_regs) { | 256 | if (pdata->have_sysif_regs) { |
253 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); | 257 | temp = in_be32(non_ehci + FSL_SOC_USB_CTRL); |
254 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004); | 258 | out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004); |
255 | out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b); | ||
256 | } | ||
257 | 259 | ||
258 | #if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) | 260 | /* |
259 | /* | 261 | * Turn on cache snooping hardware, since some PowerPC platforms |
260 | * Turn on cache snooping hardware, since some PowerPC platforms | 262 | * wholly rely on hardware to deal with cache coherent |
261 | * wholly rely on hardware to deal with cache coherent | 263 | */ |
262 | */ | ||
263 | 264 | ||
264 | /* Setup Snooping for all the 4GB space */ | 265 | /* Setup Snooping for all the 4GB space */ |
265 | /* SNOOP1 starts from 0x0, size 2G */ | 266 | /* SNOOP1 starts from 0x0, size 2G */ |
266 | out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB); | 267 | out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0 | SNOOP_SIZE_2GB); |
267 | /* SNOOP2 starts from 0x80000000, size 2G */ | 268 | /* SNOOP2 starts from 0x80000000, size 2G */ |
268 | out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB); | 269 | out_be32(non_ehci + FSL_SOC_USB_SNOOP2, 0x80000000 | SNOOP_SIZE_2GB); |
269 | #endif | 270 | } |
270 | 271 | ||
271 | if ((pdata->operating_mode == FSL_USB2_DR_HOST) || | 272 | if ((pdata->operating_mode == FSL_USB2_DR_HOST) || |
272 | (pdata->operating_mode == FSL_USB2_DR_OTG)) | 273 | (pdata->operating_mode == FSL_USB2_DR_OTG)) |
@@ -316,7 +317,9 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) | |||
316 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 317 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
317 | int retval; | 318 | int retval; |
318 | struct fsl_usb2_platform_data *pdata; | 319 | struct fsl_usb2_platform_data *pdata; |
320 | struct device *dev; | ||
319 | 321 | ||
322 | dev = hcd->self.controller; | ||
320 | pdata = hcd->self.controller->platform_data; | 323 | pdata = hcd->self.controller->platform_data; |
321 | ehci->big_endian_desc = pdata->big_endian_desc; | 324 | ehci->big_endian_desc = pdata->big_endian_desc; |
322 | ehci->big_endian_mmio = pdata->big_endian_mmio; | 325 | ehci->big_endian_mmio = pdata->big_endian_mmio; |
@@ -346,6 +349,16 @@ static int ehci_fsl_setup(struct usb_hcd *hcd) | |||
346 | 349 | ||
347 | ehci_reset(ehci); | 350 | ehci_reset(ehci); |
348 | 351 | ||
352 | if (of_device_is_compatible(dev->parent->of_node, | ||
353 | "fsl,mpc5121-usb2-dr")) { | ||
354 | /* | ||
355 | * set SBUSCFG:AHBBRST so that control msgs don't | ||
356 | * fail when doing heavy PATA writes. | ||
357 | */ | ||
358 | ehci_writel(ehci, SBUSCFG_INCR8, | ||
359 | hcd->regs + FSL_SOC_USB_SBUSCFG); | ||
360 | } | ||
361 | |||
349 | retval = ehci_fsl_reinit(ehci); | 362 | retval = ehci_fsl_reinit(ehci); |
350 | return retval; | 363 | return retval; |
351 | } | 364 | } |
@@ -469,6 +482,8 @@ static int ehci_fsl_mpc512x_drv_resume(struct device *dev) | |||
469 | ehci_writel(ehci, ISIPHYCTRL_PXE | ISIPHYCTRL_PHYE, | 482 | ehci_writel(ehci, ISIPHYCTRL_PXE | ISIPHYCTRL_PHYE, |
470 | hcd->regs + FSL_SOC_USB_ISIPHYCTRL); | 483 | hcd->regs + FSL_SOC_USB_ISIPHYCTRL); |
471 | 484 | ||
485 | ehci_writel(ehci, SBUSCFG_INCR8, hcd->regs + FSL_SOC_USB_SBUSCFG); | ||
486 | |||
472 | /* restore EHCI registers */ | 487 | /* restore EHCI registers */ |
473 | ehci_writel(ehci, pdata->pm_command, &ehci->regs->command); | 488 | ehci_writel(ehci, pdata->pm_command, &ehci->regs->command); |
474 | ehci_writel(ehci, pdata->pm_intr_enable, &ehci->regs->intr_enable); | 489 | ehci_writel(ehci, pdata->pm_intr_enable, &ehci->regs->intr_enable); |
diff --git a/drivers/usb/host/ehci-fsl.h b/drivers/usb/host/ehci-fsl.h index 491806221165..863fb0c080d7 100644 --- a/drivers/usb/host/ehci-fsl.h +++ b/drivers/usb/host/ehci-fsl.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #define _EHCI_FSL_H | 19 | #define _EHCI_FSL_H |
20 | 20 | ||
21 | /* offsets for the non-ehci registers in the FSL SOC USB controller */ | 21 | /* offsets for the non-ehci registers in the FSL SOC USB controller */ |
22 | #define FSL_SOC_USB_SBUSCFG 0x90 | ||
23 | #define SBUSCFG_INCR8 0x02 /* INCR8, specified */ | ||
22 | #define FSL_SOC_USB_ULPIVP 0x170 | 24 | #define FSL_SOC_USB_ULPIVP 0x170 |
23 | #define FSL_SOC_USB_PORTSC1 0x184 | 25 | #define FSL_SOC_USB_PORTSC1 0x184 |
24 | #define PORT_PTS_MSK (3<<30) | 26 | #define PORT_PTS_MSK (3<<30) |
@@ -45,5 +47,7 @@ | |||
45 | #define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */ | 47 | #define FSL_SOC_USB_PRICTRL 0x40c /* NOTE: big-endian */ |
46 | #define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */ | 48 | #define FSL_SOC_USB_SICTRL 0x410 /* NOTE: big-endian */ |
47 | #define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */ | 49 | #define FSL_SOC_USB_CTRL 0x500 /* NOTE: big-endian */ |
50 | #define CTRL_UTMI_PHY_EN (1<<9) | ||
51 | #define CTRL_PHY_CLK_VALID (1 << 17) | ||
48 | #define SNOOP_SIZE_2GB 0x1e | 52 | #define SNOOP_SIZE_2GB 0x1e |
49 | #endif /* _EHCI_FSL_H */ | 53 | #endif /* _EHCI_FSL_H */ |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index a007a9fe0f87..aede6374e4b6 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -1351,21 +1351,11 @@ MODULE_LICENSE ("GPL"); | |||
1351 | #define PLATFORM_DRIVER s5p_ehci_driver | 1351 | #define PLATFORM_DRIVER s5p_ehci_driver |
1352 | #endif | 1352 | #endif |
1353 | 1353 | ||
1354 | #ifdef CONFIG_USB_EHCI_ATH79 | ||
1355 | #include "ehci-ath79.c" | ||
1356 | #define PLATFORM_DRIVER ehci_ath79_driver | ||
1357 | #endif | ||
1358 | |||
1359 | #ifdef CONFIG_SPARC_LEON | 1354 | #ifdef CONFIG_SPARC_LEON |
1360 | #include "ehci-grlib.c" | 1355 | #include "ehci-grlib.c" |
1361 | #define PLATFORM_DRIVER ehci_grlib_driver | 1356 | #define PLATFORM_DRIVER ehci_grlib_driver |
1362 | #endif | 1357 | #endif |
1363 | 1358 | ||
1364 | #ifdef CONFIG_USB_PXA168_EHCI | ||
1365 | #include "ehci-pxa168.c" | ||
1366 | #define PLATFORM_DRIVER ehci_pxa168_driver | ||
1367 | #endif | ||
1368 | |||
1369 | #ifdef CONFIG_CPU_XLR | 1359 | #ifdef CONFIG_CPU_XLR |
1370 | #include "ehci-xls.c" | 1360 | #include "ehci-xls.c" |
1371 | #define PLATFORM_DRIVER ehci_xls_driver | 1361 | #define PLATFORM_DRIVER ehci_xls_driver |
@@ -1376,6 +1366,16 @@ MODULE_LICENSE ("GPL"); | |||
1376 | #define PLATFORM_DRIVER ehci_mv_driver | 1366 | #define PLATFORM_DRIVER ehci_mv_driver |
1377 | #endif | 1367 | #endif |
1378 | 1368 | ||
1369 | #ifdef CONFIG_MACH_LOONGSON1 | ||
1370 | #include "ehci-ls1x.c" | ||
1371 | #define PLATFORM_DRIVER ehci_ls1x_driver | ||
1372 | #endif | ||
1373 | |||
1374 | #ifdef CONFIG_USB_EHCI_HCD_PLATFORM | ||
1375 | #include "ehci-platform.c" | ||
1376 | #define PLATFORM_DRIVER ehci_platform_driver | ||
1377 | #endif | ||
1378 | |||
1379 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1379 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1380 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ | 1380 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ |
1381 | !defined(XILINX_OF_PLATFORM_DRIVER) | 1381 | !defined(XILINX_OF_PLATFORM_DRIVER) |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 77bbb2357e47..256fbd42e48c 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -107,7 +107,7 @@ static void ehci_handover_companion_ports(struct ehci_hcd *ehci) | |||
107 | ehci->owned_ports = 0; | 107 | ehci->owned_ports = 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static int ehci_port_change(struct ehci_hcd *ehci) | 110 | static int __maybe_unused ehci_port_change(struct ehci_hcd *ehci) |
111 | { | 111 | { |
112 | int i = HCS_N_PORTS(ehci->hcs_params); | 112 | int i = HCS_N_PORTS(ehci->hcs_params); |
113 | 113 | ||
@@ -727,7 +727,7 @@ static int ehci_hub_control ( | |||
727 | #ifdef CONFIG_USB_OTG | 727 | #ifdef CONFIG_USB_OTG |
728 | if ((hcd->self.otg_port == (wIndex + 1)) | 728 | if ((hcd->self.otg_port == (wIndex + 1)) |
729 | && hcd->self.b_hnp_enable) { | 729 | && hcd->self.b_hnp_enable) { |
730 | otg_start_hnp(ehci->transceiver); | 730 | otg_start_hnp(ehci->transceiver->otg); |
731 | break; | 731 | break; |
732 | } | 732 | } |
733 | #endif | 733 | #endif |
@@ -1076,7 +1076,8 @@ error_exit: | |||
1076 | return retval; | 1076 | return retval; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | 1079 | static void __maybe_unused ehci_relinquish_port(struct usb_hcd *hcd, |
1080 | int portnum) | ||
1080 | { | 1081 | { |
1081 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1082 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1082 | 1083 | ||
@@ -1085,7 +1086,8 @@ static void ehci_relinquish_port(struct usb_hcd *hcd, int portnum) | |||
1085 | set_owner(ehci, --portnum, PORT_OWNER); | 1086 | set_owner(ehci, --portnum, PORT_OWNER); |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | static int ehci_port_handed_over(struct usb_hcd *hcd, int portnum) | 1089 | static int __maybe_unused ehci_port_handed_over(struct usb_hcd *hcd, |
1090 | int portnum) | ||
1089 | { | 1091 | { |
1090 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 1092 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
1091 | u32 __iomem *reg; | 1093 | u32 __iomem *reg; |
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c new file mode 100644 index 000000000000..a283e59709d6 --- /dev/null +++ b/drivers/usb/host/ehci-ls1x.c | |||
@@ -0,0 +1,159 @@ | |||
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 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
110 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
111 | ret = -EBUSY; | ||
112 | goto err_put_hcd; | ||
113 | } | ||
114 | |||
115 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
116 | if (hcd->regs == NULL) { | ||
117 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
118 | ret = -EFAULT; | ||
119 | goto err_release_region; | ||
120 | } | ||
121 | |||
122 | ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); | ||
123 | if (ret) | ||
124 | goto err_iounmap; | ||
125 | |||
126 | return ret; | ||
127 | |||
128 | err_iounmap: | ||
129 | iounmap(hcd->regs); | ||
130 | err_release_region: | ||
131 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
132 | err_put_hcd: | ||
133 | usb_put_hcd(hcd); | ||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | static int ehci_hcd_ls1x_remove(struct platform_device *pdev) | ||
138 | { | ||
139 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
140 | |||
141 | usb_remove_hcd(hcd); | ||
142 | iounmap(hcd->regs); | ||
143 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
144 | usb_put_hcd(hcd); | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | static struct platform_driver ehci_ls1x_driver = { | ||
150 | .probe = ehci_hcd_ls1x_probe, | ||
151 | .remove = ehci_hcd_ls1x_remove, | ||
152 | .shutdown = usb_hcd_platform_shutdown, | ||
153 | .driver = { | ||
154 | .name = "ls1x-ehci", | ||
155 | .owner = THIS_MODULE, | ||
156 | }, | ||
157 | }; | ||
158 | |||
159 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ls1x-ehci"); | ||
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index 592d5f76803e..9803a55fd5f4 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -32,7 +32,7 @@ | |||
32 | 32 | ||
33 | #define MSM_USB_BASE (hcd->regs) | 33 | #define MSM_USB_BASE (hcd->regs) |
34 | 34 | ||
35 | static struct otg_transceiver *otg; | 35 | static struct usb_phy *phy; |
36 | 36 | ||
37 | static int ehci_msm_reset(struct usb_hcd *hcd) | 37 | static int ehci_msm_reset(struct usb_hcd *hcd) |
38 | { | 38 | { |
@@ -145,14 +145,14 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
145 | * powering up VBUS, mapping of registers address space and power | 145 | * powering up VBUS, mapping of registers address space and power |
146 | * management. | 146 | * management. |
147 | */ | 147 | */ |
148 | otg = otg_get_transceiver(); | 148 | phy = usb_get_transceiver(); |
149 | if (!otg) { | 149 | if (!phy) { |
150 | dev_err(&pdev->dev, "unable to find transceiver\n"); | 150 | dev_err(&pdev->dev, "unable to find transceiver\n"); |
151 | ret = -ENODEV; | 151 | ret = -ENODEV; |
152 | goto unmap; | 152 | goto unmap; |
153 | } | 153 | } |
154 | 154 | ||
155 | ret = otg_set_host(otg, &hcd->self); | 155 | ret = otg_set_host(phy->otg, &hcd->self); |
156 | if (ret < 0) { | 156 | if (ret < 0) { |
157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); | 157 | dev_err(&pdev->dev, "unable to register with transceiver\n"); |
158 | goto put_transceiver; | 158 | goto put_transceiver; |
@@ -169,7 +169,7 @@ static int ehci_msm_probe(struct platform_device *pdev) | |||
169 | return 0; | 169 | return 0; |
170 | 170 | ||
171 | put_transceiver: | 171 | put_transceiver: |
172 | otg_put_transceiver(otg); | 172 | usb_put_transceiver(phy); |
173 | unmap: | 173 | unmap: |
174 | iounmap(hcd->regs); | 174 | iounmap(hcd->regs); |
175 | put_hcd: | 175 | put_hcd: |
@@ -186,8 +186,8 @@ static int __devexit ehci_msm_remove(struct platform_device *pdev) | |||
186 | pm_runtime_disable(&pdev->dev); | 186 | pm_runtime_disable(&pdev->dev); |
187 | pm_runtime_set_suspended(&pdev->dev); | 187 | pm_runtime_set_suspended(&pdev->dev); |
188 | 188 | ||
189 | otg_set_host(otg, NULL); | 189 | otg_set_host(phy->otg, NULL); |
190 | otg_put_transceiver(otg); | 190 | usb_put_transceiver(phy); |
191 | 191 | ||
192 | usb_put_hcd(hcd); | 192 | usb_put_hcd(hcd); |
193 | 193 | ||
diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index 52a604fb9321..a936bbcff8f4 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c | |||
@@ -28,7 +28,7 @@ struct ehci_hcd_mv { | |||
28 | void __iomem *cap_regs; | 28 | void __iomem *cap_regs; |
29 | void __iomem *op_regs; | 29 | void __iomem *op_regs; |
30 | 30 | ||
31 | struct otg_transceiver *otg; | 31 | struct usb_phy *otg; |
32 | 32 | ||
33 | struct mv_usb_platform_data *pdata; | 33 | struct mv_usb_platform_data *pdata; |
34 | 34 | ||
@@ -253,7 +253,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
253 | ehci_mv->mode = pdata->mode; | 253 | ehci_mv->mode = pdata->mode; |
254 | if (ehci_mv->mode == MV_USB_MODE_OTG) { | 254 | if (ehci_mv->mode == MV_USB_MODE_OTG) { |
255 | #ifdef CONFIG_USB_OTG_UTILS | 255 | #ifdef CONFIG_USB_OTG_UTILS |
256 | ehci_mv->otg = otg_get_transceiver(); | 256 | ehci_mv->otg = usb_get_transceiver(); |
257 | if (!ehci_mv->otg) { | 257 | if (!ehci_mv->otg) { |
258 | dev_err(&pdev->dev, | 258 | dev_err(&pdev->dev, |
259 | "unable to find transceiver\n"); | 259 | "unable to find transceiver\n"); |
@@ -261,7 +261,7 @@ static int mv_ehci_probe(struct platform_device *pdev) | |||
261 | goto err_disable_clk; | 261 | goto err_disable_clk; |
262 | } | 262 | } |
263 | 263 | ||
264 | retval = otg_set_host(ehci_mv->otg, &hcd->self); | 264 | retval = otg_set_host(ehci_mv->otg->otg, &hcd->self); |
265 | if (retval < 0) { | 265 | if (retval < 0) { |
266 | dev_err(&pdev->dev, | 266 | dev_err(&pdev->dev, |
267 | "unable to register with transceiver\n"); | 267 | "unable to register with transceiver\n"); |
@@ -303,7 +303,7 @@ err_set_vbus: | |||
303 | #ifdef CONFIG_USB_OTG_UTILS | 303 | #ifdef CONFIG_USB_OTG_UTILS |
304 | err_put_transceiver: | 304 | err_put_transceiver: |
305 | if (ehci_mv->otg) | 305 | if (ehci_mv->otg) |
306 | otg_put_transceiver(ehci_mv->otg); | 306 | usb_put_transceiver(ehci_mv->otg); |
307 | #endif | 307 | #endif |
308 | err_disable_clk: | 308 | err_disable_clk: |
309 | mv_ehci_disable(ehci_mv); | 309 | mv_ehci_disable(ehci_mv); |
@@ -332,8 +332,8 @@ static int mv_ehci_remove(struct platform_device *pdev) | |||
332 | usb_remove_hcd(hcd); | 332 | usb_remove_hcd(hcd); |
333 | 333 | ||
334 | if (ehci_mv->otg) { | 334 | if (ehci_mv->otg) { |
335 | otg_set_host(ehci_mv->otg, NULL); | 335 | otg_set_host(ehci_mv->otg->otg, NULL); |
336 | otg_put_transceiver(ehci_mv->otg); | 336 | usb_put_transceiver(ehci_mv->otg); |
337 | } | 337 | } |
338 | 338 | ||
339 | if (ehci_mv->mode == MV_USB_MODE_HOST) { | 339 | if (ehci_mv->mode == MV_USB_MODE_HOST) { |
diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c index 55978fcfa4b2..a797d51ecbe8 100644 --- a/drivers/usb/host/ehci-mxc.c +++ b/drivers/usb/host/ehci-mxc.c | |||
@@ -220,13 +220,13 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
220 | /* Initialize the transceiver */ | 220 | /* Initialize the transceiver */ |
221 | if (pdata->otg) { | 221 | if (pdata->otg) { |
222 | pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; | 222 | pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET; |
223 | ret = otg_init(pdata->otg); | 223 | ret = usb_phy_init(pdata->otg); |
224 | if (ret) { | 224 | if (ret) { |
225 | dev_err(dev, "unable to init transceiver, probably missing\n"); | 225 | dev_err(dev, "unable to init transceiver, probably missing\n"); |
226 | ret = -ENODEV; | 226 | ret = -ENODEV; |
227 | goto err_add; | 227 | goto err_add; |
228 | } | 228 | } |
229 | ret = otg_set_vbus(pdata->otg, 1); | 229 | ret = otg_set_vbus(pdata->otg->otg, 1); |
230 | if (ret) { | 230 | if (ret) { |
231 | dev_err(dev, "unable to enable vbus on transceiver\n"); | 231 | dev_err(dev, "unable to enable vbus on transceiver\n"); |
232 | goto err_add; | 232 | goto err_add; |
@@ -247,9 +247,11 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev) | |||
247 | * It's in violation of USB specs | 247 | * It's in violation of USB specs |
248 | */ | 248 | */ |
249 | if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) { | 249 | if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) { |
250 | flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL); | 250 | flags = usb_phy_io_read(pdata->otg, |
251 | ULPI_OTG_CTRL); | ||
251 | flags |= ULPI_OTG_CTRL_CHRGVBUS; | 252 | flags |= ULPI_OTG_CTRL_CHRGVBUS; |
252 | ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL); | 253 | ret = usb_phy_io_write(pdata->otg, flags, |
254 | ULPI_OTG_CTRL); | ||
253 | if (ret) { | 255 | if (ret) { |
254 | dev_err(dev, "unable to set CHRVBUS\n"); | 256 | dev_err(dev, "unable to set CHRVBUS\n"); |
255 | goto err_add; | 257 | goto err_add; |
@@ -297,7 +299,7 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev) | |||
297 | pdata->exit(pdev); | 299 | pdata->exit(pdev); |
298 | 300 | ||
299 | if (pdata->otg) | 301 | if (pdata->otg) |
300 | otg_shutdown(pdata->otg); | 302 | usb_phy_shutdown(pdata->otg); |
301 | 303 | ||
302 | usb_remove_hcd(hcd); | 304 | usb_remove_hcd(hcd); |
303 | iounmap(hcd->regs); | 305 | iounmap(hcd->regs); |
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c new file mode 100644 index 000000000000..d238b4e24bb6 --- /dev/null +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * Generic platform ehci driver | ||
3 | * | ||
4 | * Copyright 2007 Steven Brown <sbrown@cortland.com> | ||
5 | * Copyright 2010-2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
6 | * | ||
7 | * Derived from the ohci-ssb driver | ||
8 | * Copyright 2007 Michael Buesch <m@bues.ch> | ||
9 | * | ||
10 | * Derived from the EHCI-PCI driver | ||
11 | * Copyright (c) 2000-2004 by David Brownell | ||
12 | * | ||
13 | * Derived from the ohci-pci driver | ||
14 | * Copyright 1999 Roman Weissgaerber | ||
15 | * Copyright 2000-2002 David Brownell | ||
16 | * Copyright 1999 Linus Torvalds | ||
17 | * Copyright 1999 Gregory P. Smith | ||
18 | * | ||
19 | * Licensed under the GNU/GPL. See COPYING for details. | ||
20 | */ | ||
21 | #include <linux/platform_device.h> | ||
22 | #include <linux/usb/ehci_pdriver.h> | ||
23 | |||
24 | static int ehci_platform_reset(struct usb_hcd *hcd) | ||
25 | { | ||
26 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | ||
27 | struct usb_ehci_pdata *pdata = pdev->dev.platform_data; | ||
28 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
29 | int retval; | ||
30 | |||
31 | hcd->has_tt = pdata->has_tt; | ||
32 | ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug; | ||
33 | ehci->big_endian_desc = pdata->big_endian_desc; | ||
34 | ehci->big_endian_mmio = pdata->big_endian_mmio; | ||
35 | |||
36 | ehci->caps = hcd->regs + pdata->caps_offset; | ||
37 | retval = ehci_setup(hcd); | ||
38 | if (retval) | ||
39 | return retval; | ||
40 | |||
41 | if (pdata->port_power_on) | ||
42 | ehci_port_power(ehci, 1); | ||
43 | if (pdata->port_power_off) | ||
44 | ehci_port_power(ehci, 0); | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static const struct hc_driver 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 | |||
67 | .get_frame_number = ehci_get_frame, | ||
68 | |||
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 | .update_device = ehci_update_device, | ||
79 | |||
80 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
81 | }; | ||
82 | |||
83 | static int __devinit ehci_platform_probe(struct platform_device *dev) | ||
84 | { | ||
85 | struct usb_hcd *hcd; | ||
86 | struct resource *res_mem; | ||
87 | int irq; | ||
88 | int err = -ENOMEM; | ||
89 | |||
90 | BUG_ON(!dev->dev.platform_data); | ||
91 | |||
92 | if (usb_disabled()) | ||
93 | return -ENODEV; | ||
94 | |||
95 | irq = platform_get_irq(dev, 0); | ||
96 | if (irq < 0) { | ||
97 | pr_err("no irq provieded"); | ||
98 | return irq; | ||
99 | } | ||
100 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
101 | if (!res_mem) { | ||
102 | pr_err("no memory recourse provieded"); | ||
103 | return -ENXIO; | ||
104 | } | ||
105 | |||
106 | hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, | ||
107 | dev_name(&dev->dev)); | ||
108 | if (!hcd) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | hcd->rsrc_start = res_mem->start; | ||
112 | hcd->rsrc_len = resource_size(res_mem); | ||
113 | |||
114 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
115 | pr_err("controller already in use"); | ||
116 | err = -EBUSY; | ||
117 | goto err_put_hcd; | ||
118 | } | ||
119 | |||
120 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
121 | if (!hcd->regs) | ||
122 | goto err_release_region; | ||
123 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
124 | if (err) | ||
125 | goto err_iounmap; | ||
126 | |||
127 | platform_set_drvdata(dev, hcd); | ||
128 | |||
129 | return err; | ||
130 | |||
131 | err_iounmap: | ||
132 | iounmap(hcd->regs); | ||
133 | err_release_region: | ||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
135 | err_put_hcd: | ||
136 | usb_put_hcd(hcd); | ||
137 | return err; | ||
138 | } | ||
139 | |||
140 | static int __devexit ehci_platform_remove(struct platform_device *dev) | ||
141 | { | ||
142 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
143 | |||
144 | usb_remove_hcd(hcd); | ||
145 | iounmap(hcd->regs); | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | usb_put_hcd(hcd); | ||
148 | platform_set_drvdata(dev, NULL); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | #ifdef CONFIG_PM | ||
154 | |||
155 | static int ehci_platform_suspend(struct device *dev) | ||
156 | { | ||
157 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
158 | bool wakeup = device_may_wakeup(dev); | ||
159 | |||
160 | ehci_prepare_ports_for_controller_suspend(hcd_to_ehci(hcd), wakeup); | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static int ehci_platform_resume(struct device *dev) | ||
165 | { | ||
166 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
167 | |||
168 | ehci_prepare_ports_for_controller_resume(hcd_to_ehci(hcd)); | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | #else /* !CONFIG_PM */ | ||
173 | #define ehci_platform_suspend NULL | ||
174 | #define ehci_platform_resume NULL | ||
175 | #endif /* CONFIG_PM */ | ||
176 | |||
177 | static const struct platform_device_id ehci_platform_table[] = { | ||
178 | { "ehci-platform", 0 }, | ||
179 | { } | ||
180 | }; | ||
181 | MODULE_DEVICE_TABLE(platform, ehci_platform_table); | ||
182 | |||
183 | static const struct dev_pm_ops ehci_platform_pm_ops = { | ||
184 | .suspend = ehci_platform_suspend, | ||
185 | .resume = ehci_platform_resume, | ||
186 | }; | ||
187 | |||
188 | static struct platform_driver ehci_platform_driver = { | ||
189 | .id_table = ehci_platform_table, | ||
190 | .probe = ehci_platform_probe, | ||
191 | .remove = __devexit_p(ehci_platform_remove), | ||
192 | .shutdown = usb_hcd_platform_shutdown, | ||
193 | .driver = { | ||
194 | .owner = THIS_MODULE, | ||
195 | .name = "ehci-platform", | ||
196 | .pm = &ehci_platform_pm_ops, | ||
197 | } | ||
198 | }; | ||
diff --git a/drivers/usb/host/ehci-pxa168.c b/drivers/usb/host/ehci-pxa168.c deleted file mode 100644 index 8d0e7a22e711..000000000000 --- a/drivers/usb/host/ehci-pxa168.c +++ /dev/null | |||
@@ -1,363 +0,0 @@ | |||
1 | /* | ||
2 | * drivers/usb/host/ehci-pxa168.c | ||
3 | * | ||
4 | * Tanmay Upadhyay <tanmay.upadhyay@einfochips.com> | ||
5 | * | ||
6 | * Based on drivers/usb/host/ehci-orion.c | ||
7 | * | ||
8 | * This file is licensed under the terms of the GNU General Public | ||
9 | * License version 2. This program is licensed "as is" without any | ||
10 | * warranty of any kind, whether express or implied. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <mach/pxa168.h> | ||
18 | |||
19 | #define USB_PHY_CTRL_REG 0x4 | ||
20 | #define USB_PHY_PLL_REG 0x8 | ||
21 | #define USB_PHY_TX_REG 0xc | ||
22 | |||
23 | #define FBDIV_SHIFT 4 | ||
24 | |||
25 | #define ICP_SHIFT 12 | ||
26 | #define ICP_15 2 | ||
27 | #define ICP_20 3 | ||
28 | #define ICP_25 4 | ||
29 | |||
30 | #define KVCO_SHIFT 15 | ||
31 | |||
32 | #define PLLCALI12_SHIFT 25 | ||
33 | #define CALI12_VDD 0 | ||
34 | #define CALI12_09 1 | ||
35 | #define CALI12_10 2 | ||
36 | #define CALI12_11 3 | ||
37 | |||
38 | #define PLLVDD12_SHIFT 27 | ||
39 | #define VDD12_VDD 0 | ||
40 | #define VDD12_10 1 | ||
41 | #define VDD12_11 2 | ||
42 | #define VDD12_12 3 | ||
43 | |||
44 | #define PLLVDD18_SHIFT 29 | ||
45 | #define VDD18_19 0 | ||
46 | #define VDD18_20 1 | ||
47 | #define VDD18_21 2 | ||
48 | #define VDD18_22 3 | ||
49 | |||
50 | |||
51 | #define PLL_READY (1 << 23) | ||
52 | #define VCOCAL_START (1 << 21) | ||
53 | #define REG_RCAL_START (1 << 12) | ||
54 | |||
55 | struct pxa168_usb_drv_data { | ||
56 | struct ehci_hcd ehci; | ||
57 | struct clk *pxa168_usb_clk; | ||
58 | struct resource *usb_phy_res; | ||
59 | void __iomem *usb_phy_reg_base; | ||
60 | }; | ||
61 | |||
62 | static int ehci_pxa168_setup(struct usb_hcd *hcd) | ||
63 | { | ||
64 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
65 | int retval; | ||
66 | |||
67 | ehci_reset(ehci); | ||
68 | retval = ehci_halt(ehci); | ||
69 | if (retval) | ||
70 | return retval; | ||
71 | |||
72 | /* | ||
73 | * data structure init | ||
74 | */ | ||
75 | retval = ehci_init(hcd); | ||
76 | if (retval) | ||
77 | return retval; | ||
78 | |||
79 | hcd->has_tt = 1; | ||
80 | |||
81 | ehci_port_power(ehci, 0); | ||
82 | |||
83 | return retval; | ||
84 | } | ||
85 | |||
86 | static const struct hc_driver ehci_pxa168_hc_driver = { | ||
87 | .description = hcd_name, | ||
88 | .product_desc = "Marvell PXA168 EHCI", | ||
89 | .hcd_priv_size = sizeof(struct pxa168_usb_drv_data), | ||
90 | |||
91 | /* | ||
92 | * generic hardware linkage | ||
93 | */ | ||
94 | .irq = ehci_irq, | ||
95 | .flags = HCD_MEMORY | HCD_USB2, | ||
96 | |||
97 | /* | ||
98 | * basic lifecycle operations | ||
99 | */ | ||
100 | .reset = ehci_pxa168_setup, | ||
101 | .start = ehci_run, | ||
102 | .stop = ehci_stop, | ||
103 | .shutdown = ehci_shutdown, | ||
104 | |||
105 | /* | ||
106 | * managing i/o requests and associated device resources | ||
107 | */ | ||
108 | .urb_enqueue = ehci_urb_enqueue, | ||
109 | .urb_dequeue = ehci_urb_dequeue, | ||
110 | .endpoint_disable = ehci_endpoint_disable, | ||
111 | .endpoint_reset = ehci_endpoint_reset, | ||
112 | |||
113 | /* | ||
114 | * scheduling support | ||
115 | */ | ||
116 | .get_frame_number = ehci_get_frame, | ||
117 | |||
118 | /* | ||
119 | * root hub support | ||
120 | */ | ||
121 | .hub_status_data = ehci_hub_status_data, | ||
122 | .hub_control = ehci_hub_control, | ||
123 | .bus_suspend = ehci_bus_suspend, | ||
124 | .bus_resume = ehci_bus_resume, | ||
125 | .relinquish_port = ehci_relinquish_port, | ||
126 | .port_handed_over = ehci_port_handed_over, | ||
127 | |||
128 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | ||
129 | }; | ||
130 | |||
131 | static int pxa168_usb_phy_init(struct platform_device *pdev) | ||
132 | { | ||
133 | struct resource *res; | ||
134 | void __iomem *usb_phy_reg_base; | ||
135 | struct pxa168_usb_pdata *pdata; | ||
136 | struct pxa168_usb_drv_data *drv_data; | ||
137 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
138 | unsigned long reg_val; | ||
139 | int pll_retry_cont = 10000, err = 0; | ||
140 | |||
141 | drv_data = (struct pxa168_usb_drv_data *)hcd->hcd_priv; | ||
142 | pdata = (struct pxa168_usb_pdata *)pdev->dev.platform_data; | ||
143 | |||
144 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
145 | if (!res) { | ||
146 | dev_err(&pdev->dev, | ||
147 | "Found HC with no PHY register addr. Check %s setup!\n", | ||
148 | dev_name(&pdev->dev)); | ||
149 | return -ENODEV; | ||
150 | } | ||
151 | |||
152 | if (!request_mem_region(res->start, resource_size(res), | ||
153 | ehci_pxa168_hc_driver.description)) { | ||
154 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
155 | return -EBUSY; | ||
156 | } | ||
157 | |||
158 | usb_phy_reg_base = ioremap(res->start, resource_size(res)); | ||
159 | if (usb_phy_reg_base == NULL) { | ||
160 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
161 | err = -EFAULT; | ||
162 | goto err1; | ||
163 | } | ||
164 | drv_data->usb_phy_reg_base = usb_phy_reg_base; | ||
165 | drv_data->usb_phy_res = res; | ||
166 | |||
167 | /* If someone wants to init USB phy in board specific way */ | ||
168 | if (pdata && pdata->phy_init) | ||
169 | return pdata->phy_init(usb_phy_reg_base); | ||
170 | |||
171 | /* Power up the PHY and PLL */ | ||
172 | writel(readl(usb_phy_reg_base + USB_PHY_CTRL_REG) | 0x3, | ||
173 | usb_phy_reg_base + USB_PHY_CTRL_REG); | ||
174 | |||
175 | /* Configure PHY PLL */ | ||
176 | reg_val = readl(usb_phy_reg_base + USB_PHY_PLL_REG) & ~(0x7e03ffff); | ||
177 | reg_val |= (VDD18_22 << PLLVDD18_SHIFT | VDD12_12 << PLLVDD12_SHIFT | | ||
178 | CALI12_11 << PLLCALI12_SHIFT | 3 << KVCO_SHIFT | | ||
179 | ICP_15 << ICP_SHIFT | 0xee << FBDIV_SHIFT | 0xb); | ||
180 | writel(reg_val, usb_phy_reg_base + USB_PHY_PLL_REG); | ||
181 | |||
182 | /* Make sure PHY PLL is ready */ | ||
183 | while (!(readl(usb_phy_reg_base + USB_PHY_PLL_REG) & PLL_READY)) { | ||
184 | if (!(pll_retry_cont--)) { | ||
185 | dev_dbg(&pdev->dev, "USB PHY PLL not ready\n"); | ||
186 | err = -EIO; | ||
187 | goto err2; | ||
188 | } | ||
189 | } | ||
190 | |||
191 | /* Toggle VCOCAL_START bit of U2PLL for PLL calibration */ | ||
192 | udelay(200); | ||
193 | writel(readl(usb_phy_reg_base + USB_PHY_PLL_REG) | VCOCAL_START, | ||
194 | usb_phy_reg_base + USB_PHY_PLL_REG); | ||
195 | udelay(40); | ||
196 | writel(readl(usb_phy_reg_base + USB_PHY_PLL_REG) & ~VCOCAL_START, | ||
197 | usb_phy_reg_base + USB_PHY_PLL_REG); | ||
198 | |||
199 | /* Toggle REG_RCAL_START bit of U2PTX for impedance calibration */ | ||
200 | udelay(400); | ||
201 | writel(readl(usb_phy_reg_base + USB_PHY_TX_REG) | REG_RCAL_START, | ||
202 | usb_phy_reg_base + USB_PHY_TX_REG); | ||
203 | udelay(40); | ||
204 | writel(readl(usb_phy_reg_base + USB_PHY_TX_REG) & ~REG_RCAL_START, | ||
205 | usb_phy_reg_base + USB_PHY_TX_REG); | ||
206 | |||
207 | /* Make sure PHY PLL is ready again */ | ||
208 | pll_retry_cont = 0; | ||
209 | while (!(readl(usb_phy_reg_base + USB_PHY_PLL_REG) & PLL_READY)) { | ||
210 | if (!(pll_retry_cont--)) { | ||
211 | dev_dbg(&pdev->dev, "USB PHY PLL not ready\n"); | ||
212 | err = -EIO; | ||
213 | goto err2; | ||
214 | } | ||
215 | } | ||
216 | |||
217 | return 0; | ||
218 | err2: | ||
219 | iounmap(usb_phy_reg_base); | ||
220 | err1: | ||
221 | release_mem_region(res->start, resource_size(res)); | ||
222 | return err; | ||
223 | } | ||
224 | |||
225 | static int __devinit ehci_pxa168_drv_probe(struct platform_device *pdev) | ||
226 | { | ||
227 | struct resource *res; | ||
228 | struct usb_hcd *hcd; | ||
229 | struct ehci_hcd *ehci; | ||
230 | struct pxa168_usb_drv_data *drv_data; | ||
231 | void __iomem *regs; | ||
232 | int irq, err = 0; | ||
233 | |||
234 | if (usb_disabled()) | ||
235 | return -ENODEV; | ||
236 | |||
237 | pr_debug("Initializing pxa168-SoC USB Host Controller\n"); | ||
238 | |||
239 | irq = platform_get_irq(pdev, 0); | ||
240 | if (irq <= 0) { | ||
241 | dev_err(&pdev->dev, | ||
242 | "Found HC with no IRQ. Check %s setup!\n", | ||
243 | dev_name(&pdev->dev)); | ||
244 | err = -ENODEV; | ||
245 | goto err1; | ||
246 | } | ||
247 | |||
248 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
249 | if (!res) { | ||
250 | dev_err(&pdev->dev, | ||
251 | "Found HC with no register addr. Check %s setup!\n", | ||
252 | dev_name(&pdev->dev)); | ||
253 | err = -ENODEV; | ||
254 | goto err1; | ||
255 | } | ||
256 | |||
257 | if (!request_mem_region(res->start, resource_size(res), | ||
258 | ehci_pxa168_hc_driver.description)) { | ||
259 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
260 | err = -EBUSY; | ||
261 | goto err1; | ||
262 | } | ||
263 | |||
264 | regs = ioremap(res->start, resource_size(res)); | ||
265 | if (regs == NULL) { | ||
266 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
267 | err = -EFAULT; | ||
268 | goto err2; | ||
269 | } | ||
270 | |||
271 | hcd = usb_create_hcd(&ehci_pxa168_hc_driver, | ||
272 | &pdev->dev, dev_name(&pdev->dev)); | ||
273 | if (!hcd) { | ||
274 | err = -ENOMEM; | ||
275 | goto err3; | ||
276 | } | ||
277 | |||
278 | drv_data = (struct pxa168_usb_drv_data *)hcd->hcd_priv; | ||
279 | |||
280 | /* Enable USB clock */ | ||
281 | drv_data->pxa168_usb_clk = clk_get(&pdev->dev, "PXA168-USBCLK"); | ||
282 | if (IS_ERR(drv_data->pxa168_usb_clk)) { | ||
283 | dev_err(&pdev->dev, "Couldn't get USB clock\n"); | ||
284 | err = PTR_ERR(drv_data->pxa168_usb_clk); | ||
285 | goto err4; | ||
286 | } | ||
287 | clk_enable(drv_data->pxa168_usb_clk); | ||
288 | |||
289 | err = pxa168_usb_phy_init(pdev); | ||
290 | if (err) { | ||
291 | dev_err(&pdev->dev, "USB PHY initialization failed\n"); | ||
292 | goto err5; | ||
293 | } | ||
294 | |||
295 | hcd->rsrc_start = res->start; | ||
296 | hcd->rsrc_len = resource_size(res); | ||
297 | hcd->regs = regs; | ||
298 | |||
299 | ehci = hcd_to_ehci(hcd); | ||
300 | ehci->caps = hcd->regs + 0x100; | ||
301 | ehci->regs = hcd->regs + 0x100 + | ||
302 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
303 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
304 | hcd->has_tt = 1; | ||
305 | ehci->sbrn = 0x20; | ||
306 | |||
307 | err = usb_add_hcd(hcd, irq, IRQF_SHARED | IRQF_DISABLED); | ||
308 | if (err) | ||
309 | goto err5; | ||
310 | |||
311 | return 0; | ||
312 | |||
313 | err5: | ||
314 | clk_disable(drv_data->pxa168_usb_clk); | ||
315 | clk_put(drv_data->pxa168_usb_clk); | ||
316 | err4: | ||
317 | usb_put_hcd(hcd); | ||
318 | err3: | ||
319 | iounmap(regs); | ||
320 | err2: | ||
321 | release_mem_region(res->start, resource_size(res)); | ||
322 | err1: | ||
323 | dev_err(&pdev->dev, "init %s fail, %d\n", | ||
324 | dev_name(&pdev->dev), err); | ||
325 | |||
326 | return err; | ||
327 | } | ||
328 | |||
329 | static int __exit ehci_pxa168_drv_remove(struct platform_device *pdev) | ||
330 | { | ||
331 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
332 | struct pxa168_usb_drv_data *drv_data = | ||
333 | (struct pxa168_usb_drv_data *)hcd->hcd_priv; | ||
334 | |||
335 | usb_remove_hcd(hcd); | ||
336 | |||
337 | /* Power down PHY & PLL */ | ||
338 | writel(readl(drv_data->usb_phy_reg_base + USB_PHY_CTRL_REG) & (~0x3), | ||
339 | drv_data->usb_phy_reg_base + USB_PHY_CTRL_REG); | ||
340 | |||
341 | clk_disable(drv_data->pxa168_usb_clk); | ||
342 | clk_put(drv_data->pxa168_usb_clk); | ||
343 | |||
344 | iounmap(hcd->regs); | ||
345 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
346 | |||
347 | iounmap(drv_data->usb_phy_reg_base); | ||
348 | release_mem_region(drv_data->usb_phy_res->start, | ||
349 | resource_size(drv_data->usb_phy_res)); | ||
350 | |||
351 | usb_put_hcd(hcd); | ||
352 | |||
353 | return 0; | ||
354 | } | ||
355 | |||
356 | MODULE_ALIAS("platform:pxa168-ehci"); | ||
357 | |||
358 | static struct platform_driver ehci_pxa168_driver = { | ||
359 | .probe = ehci_pxa168_drv_probe, | ||
360 | .remove = __exit_p(ehci_pxa168_drv_remove), | ||
361 | .shutdown = usb_hcd_platform_shutdown, | ||
362 | .driver.name = "pxa168-ehci", | ||
363 | }; | ||
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index 293f7412992e..f098e2a291a0 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
@@ -17,6 +17,15 @@ | |||
17 | #include <plat/ehci.h> | 17 | #include <plat/ehci.h> |
18 | #include <plat/usb-phy.h> | 18 | #include <plat/usb-phy.h> |
19 | 19 | ||
20 | #define EHCI_INSNREG00(base) (base + 0x90) | ||
21 | #define EHCI_INSNREG00_ENA_INCR16 (0x1 << 25) | ||
22 | #define EHCI_INSNREG00_ENA_INCR8 (0x1 << 24) | ||
23 | #define EHCI_INSNREG00_ENA_INCR4 (0x1 << 23) | ||
24 | #define EHCI_INSNREG00_ENA_INCRX_ALIGN (0x1 << 22) | ||
25 | #define EHCI_INSNREG00_ENABLE_DMA_BURST \ | ||
26 | (EHCI_INSNREG00_ENA_INCR16 | EHCI_INSNREG00_ENA_INCR8 | \ | ||
27 | EHCI_INSNREG00_ENA_INCR4 | EHCI_INSNREG00_ENA_INCRX_ALIGN) | ||
28 | |||
20 | struct s5p_ehci_hcd { | 29 | struct s5p_ehci_hcd { |
21 | struct device *dev; | 30 | struct device *dev; |
22 | struct usb_hcd *hcd; | 31 | struct usb_hcd *hcd; |
@@ -128,6 +137,9 @@ static int __devinit s5p_ehci_probe(struct platform_device *pdev) | |||
128 | ehci->regs = hcd->regs + | 137 | ehci->regs = hcd->regs + |
129 | HC_LENGTH(ehci, readl(&ehci->caps->hc_capbase)); | 138 | HC_LENGTH(ehci, readl(&ehci->caps->hc_capbase)); |
130 | 139 | ||
140 | /* DMA burst Enable */ | ||
141 | writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); | ||
142 | |||
131 | dbg_hcs_params(ehci, "reset"); | 143 | dbg_hcs_params(ehci, "reset"); |
132 | dbg_hcc_params(ehci, "reset"); | 144 | dbg_hcc_params(ehci, "reset"); |
133 | 145 | ||
@@ -234,6 +246,9 @@ static int s5p_ehci_resume(struct device *dev) | |||
234 | if (pdata && pdata->phy_init) | 246 | if (pdata && pdata->phy_init) |
235 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | 247 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); |
236 | 248 | ||
249 | /* DMA burst Enable */ | ||
250 | writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); | ||
251 | |||
237 | if (time_before(jiffies, ehci->next_statechange)) | 252 | if (time_before(jiffies, ehci->next_statechange)) |
238 | msleep(100); | 253 | msleep(100); |
239 | 254 | ||
diff --git a/drivers/usb/host/ehci-spear.c b/drivers/usb/host/ehci-spear.c index b115b0b76e33..6e928559169c 100644 --- a/drivers/usb/host/ehci-spear.c +++ b/drivers/usb/host/ehci-spear.c | |||
@@ -11,8 +11,10 @@ | |||
11 | * more details. | 11 | * more details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/clk.h> | 14 | #include <linux/clk.h> |
15 | #include <linux/jiffies.h> | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/pm.h> | ||
16 | 18 | ||
17 | struct spear_ehci { | 19 | struct spear_ehci { |
18 | struct ehci_hcd ehci; | 20 | struct ehci_hcd ehci; |
@@ -90,6 +92,82 @@ static const struct hc_driver ehci_spear_hc_driver = { | |||
90 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 92 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
91 | }; | 93 | }; |
92 | 94 | ||
95 | #ifdef CONFIG_PM | ||
96 | static int ehci_spear_drv_suspend(struct device *dev) | ||
97 | { | ||
98 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
99 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
100 | unsigned long flags; | ||
101 | int rc = 0; | ||
102 | |||
103 | if (time_before(jiffies, ehci->next_statechange)) | ||
104 | msleep(10); | ||
105 | |||
106 | /* | ||
107 | * Root hub was already suspended. Disable irq emission and mark HW | ||
108 | * unaccessible. The PM and USB cores make sure that the root hub is | ||
109 | * either suspended or stopped. | ||
110 | */ | ||
111 | spin_lock_irqsave(&ehci->lock, flags); | ||
112 | ehci_prepare_ports_for_controller_suspend(ehci, device_may_wakeup(dev)); | ||
113 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | ||
114 | ehci_readl(ehci, &ehci->regs->intr_enable); | ||
115 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
116 | |||
117 | return rc; | ||
118 | } | ||
119 | |||
120 | static int ehci_spear_drv_resume(struct device *dev) | ||
121 | { | ||
122 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
123 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
124 | |||
125 | if (time_before(jiffies, ehci->next_statechange)) | ||
126 | msleep(100); | ||
127 | |||
128 | if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { | ||
129 | int mask = INTR_MASK; | ||
130 | |||
131 | ehci_prepare_ports_for_controller_resume(ehci); | ||
132 | |||
133 | if (!hcd->self.root_hub->do_remote_wakeup) | ||
134 | mask &= ~STS_PCD; | ||
135 | |||
136 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); | ||
137 | ehci_readl(ehci, &ehci->regs->intr_enable); | ||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | usb_root_hub_lost_power(hcd->self.root_hub); | ||
142 | |||
143 | /* | ||
144 | * Else reset, to cope with power loss or flush-to-storage style | ||
145 | * "resume" having let BIOS kick in during reboot. | ||
146 | */ | ||
147 | ehci_halt(ehci); | ||
148 | ehci_reset(ehci); | ||
149 | |||
150 | /* emptying the schedule aborts any urbs */ | ||
151 | spin_lock_irq(&ehci->lock); | ||
152 | if (ehci->reclaim) | ||
153 | end_unlink_async(ehci); | ||
154 | |||
155 | ehci_work(ehci); | ||
156 | spin_unlock_irq(&ehci->lock); | ||
157 | |||
158 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | ||
159 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); | ||
160 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ | ||
161 | |||
162 | /* here we "know" root ports should always stay powered */ | ||
163 | ehci_port_power(ehci, 1); | ||
164 | return 0; | ||
165 | } | ||
166 | #endif /* CONFIG_PM */ | ||
167 | |||
168 | static SIMPLE_DEV_PM_OPS(ehci_spear_pm_ops, ehci_spear_drv_suspend, | ||
169 | ehci_spear_drv_resume); | ||
170 | |||
93 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) | 171 | static int spear_ehci_hcd_drv_probe(struct platform_device *pdev) |
94 | { | 172 | { |
95 | struct usb_hcd *hcd ; | 173 | struct usb_hcd *hcd ; |
@@ -205,7 +283,8 @@ static struct platform_driver spear_ehci_hcd_driver = { | |||
205 | .shutdown = usb_hcd_platform_shutdown, | 283 | .shutdown = usb_hcd_platform_shutdown, |
206 | .driver = { | 284 | .driver = { |
207 | .name = "spear-ehci", | 285 | .name = "spear-ehci", |
208 | .bus = &platform_bus_type | 286 | .bus = &platform_bus_type, |
287 | .pm = &ehci_spear_pm_ops, | ||
209 | } | 288 | } |
210 | }; | 289 | }; |
211 | 290 | ||
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index dbc7fe8ca9e7..3de48a2d7955 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -35,7 +35,7 @@ struct tegra_ehci_hcd { | |||
35 | struct tegra_usb_phy *phy; | 35 | struct tegra_usb_phy *phy; |
36 | struct clk *clk; | 36 | struct clk *clk; |
37 | struct clk *emc_clk; | 37 | struct clk *emc_clk; |
38 | struct otg_transceiver *transceiver; | 38 | struct usb_phy *transceiver; |
39 | int host_resumed; | 39 | int host_resumed; |
40 | int bus_suspended; | 40 | int bus_suspended; |
41 | int port_resuming; | 41 | int port_resuming; |
@@ -733,9 +733,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
733 | 733 | ||
734 | #ifdef CONFIG_USB_OTG_UTILS | 734 | #ifdef CONFIG_USB_OTG_UTILS |
735 | if (pdata->operating_mode == TEGRA_USB_OTG) { | 735 | if (pdata->operating_mode == TEGRA_USB_OTG) { |
736 | tegra->transceiver = otg_get_transceiver(); | 736 | tegra->transceiver = usb_get_transceiver(); |
737 | if (tegra->transceiver) | 737 | if (tegra->transceiver) |
738 | otg_set_host(tegra->transceiver, &hcd->self); | 738 | otg_set_host(tegra->transceiver->otg, &hcd->self); |
739 | } | 739 | } |
740 | #endif | 740 | #endif |
741 | 741 | ||
@@ -750,8 +750,8 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
750 | fail: | 750 | fail: |
751 | #ifdef CONFIG_USB_OTG_UTILS | 751 | #ifdef CONFIG_USB_OTG_UTILS |
752 | if (tegra->transceiver) { | 752 | if (tegra->transceiver) { |
753 | otg_set_host(tegra->transceiver, NULL); | 753 | otg_set_host(tegra->transceiver->otg, NULL); |
754 | otg_put_transceiver(tegra->transceiver); | 754 | usb_put_transceiver(tegra->transceiver); |
755 | } | 755 | } |
756 | #endif | 756 | #endif |
757 | tegra_usb_phy_close(tegra->phy); | 757 | tegra_usb_phy_close(tegra->phy); |
@@ -808,8 +808,8 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
808 | 808 | ||
809 | #ifdef CONFIG_USB_OTG_UTILS | 809 | #ifdef CONFIG_USB_OTG_UTILS |
810 | if (tegra->transceiver) { | 810 | if (tegra->transceiver) { |
811 | otg_set_host(tegra->transceiver, NULL); | 811 | otg_set_host(tegra->transceiver->otg, NULL); |
812 | otg_put_transceiver(tegra->transceiver); | 812 | usb_put_transceiver(tegra->transceiver); |
813 | } | 813 | } |
814 | #endif | 814 | #endif |
815 | 815 | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index 0a5fda73b3f2..8f9acbc96fde 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -176,7 +176,7 @@ struct ehci_hcd { /* one per controller */ | |||
176 | /* | 176 | /* |
177 | * OTG controllers and transceivers need software interaction | 177 | * OTG controllers and transceivers need software interaction |
178 | */ | 178 | */ |
179 | struct otg_transceiver *transceiver; | 179 | struct usb_phy *transceiver; |
180 | }; | 180 | }; |
181 | 181 | ||
182 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ | 182 | /* convert between an HCD pointer and the corresponding EHCI_HCD */ |
diff --git a/drivers/usb/host/fsl-mph-dr-of.c b/drivers/usb/host/fsl-mph-dr-of.c index 7916e56a725e..ab333ac6071d 100644 --- a/drivers/usb/host/fsl-mph-dr-of.c +++ b/drivers/usb/host/fsl-mph-dr-of.c | |||
@@ -94,7 +94,6 @@ struct platform_device * __devinit fsl_usb2_device_register( | |||
94 | pdev->dev.parent = &ofdev->dev; | 94 | pdev->dev.parent = &ofdev->dev; |
95 | 95 | ||
96 | pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; | 96 | pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask; |
97 | pdev->dev.dma_mask = &pdev->archdata.dma_mask; | ||
98 | *pdev->dev.dma_mask = *ofdev->dev.dma_mask; | 97 | *pdev->dev.dma_mask = *ofdev->dev.dma_mask; |
99 | 98 | ||
100 | retval = platform_device_add_data(pdev, pdata, sizeof(*pdata)); | 99 | retval = platform_device_add_data(pdev, pdata, sizeof(*pdata)); |
diff --git a/drivers/usb/host/imx21-dbg.c b/drivers/usb/host/imx21-dbg.c index 6d7533427163..ec98ecee3517 100644 --- a/drivers/usb/host/imx21-dbg.c +++ b/drivers/usb/host/imx21-dbg.c | |||
@@ -239,7 +239,7 @@ static int debug_status_show(struct seq_file *s, void *v) | |||
239 | "ETDs allocated: %d/%d (max=%d)\n" | 239 | "ETDs allocated: %d/%d (max=%d)\n" |
240 | "ETDs in use sw: %d\n" | 240 | "ETDs in use sw: %d\n" |
241 | "ETDs in use hw: %d\n" | 241 | "ETDs in use hw: %d\n" |
242 | "DMEM alocated: %d/%d (max=%d)\n" | 242 | "DMEM allocated: %d/%d (max=%d)\n" |
243 | "DMEM blocks: %d\n" | 243 | "DMEM blocks: %d\n" |
244 | "Queued waiting for ETD: %d\n" | 244 | "Queued waiting for ETD: %d\n" |
245 | "Queued waiting for DMEM: %d\n", | 245 | "Queued waiting for DMEM: %d\n", |
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c index d91e5f211a76..924880087a74 100644 --- a/drivers/usb/host/isp116x-hcd.c +++ b/drivers/usb/host/isp116x-hcd.c | |||
@@ -1569,6 +1569,9 @@ static int __devinit isp116x_probe(struct platform_device *pdev) | |||
1569 | int ret = 0; | 1569 | int ret = 0; |
1570 | unsigned long irqflags; | 1570 | unsigned long irqflags; |
1571 | 1571 | ||
1572 | if (usb_disabled()) | ||
1573 | return -ENODEV; | ||
1574 | |||
1572 | if (pdev->num_resources < 3) { | 1575 | if (pdev->num_resources < 3) { |
1573 | ret = -ENODEV; | 1576 | ret = -ENODEV; |
1574 | goto err1; | 1577 | goto err1; |
@@ -1708,22 +1711,4 @@ static struct platform_driver isp116x_driver = { | |||
1708 | }, | 1711 | }, |
1709 | }; | 1712 | }; |
1710 | 1713 | ||
1711 | /*-----------------------------------------------------------------*/ | 1714 | module_platform_driver(isp116x_driver); |
1712 | |||
1713 | static int __init isp116x_init(void) | ||
1714 | { | ||
1715 | if (usb_disabled()) | ||
1716 | return -ENODEV; | ||
1717 | |||
1718 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); | ||
1719 | return platform_driver_register(&isp116x_driver); | ||
1720 | } | ||
1721 | |||
1722 | module_init(isp116x_init); | ||
1723 | |||
1724 | static void __exit isp116x_cleanup(void) | ||
1725 | { | ||
1726 | platform_driver_unregister(&isp116x_driver); | ||
1727 | } | ||
1728 | |||
1729 | module_exit(isp116x_cleanup); | ||
diff --git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index e5fd8aa57af1..9e63cdf1ab75 100644 --- a/drivers/usb/host/isp1362-hcd.c +++ b/drivers/usb/host/isp1362-hcd.c | |||
@@ -2693,6 +2693,9 @@ static int __devinit isp1362_probe(struct platform_device *pdev) | |||
2693 | struct resource *irq_res; | 2693 | struct resource *irq_res; |
2694 | unsigned int irq_flags = 0; | 2694 | unsigned int irq_flags = 0; |
2695 | 2695 | ||
2696 | if (usb_disabled()) | ||
2697 | return -ENODEV; | ||
2698 | |||
2696 | /* basic sanity checks first. board-specific init logic should | 2699 | /* basic sanity checks first. board-specific init logic should |
2697 | * have initialized this the three resources and probably board | 2700 | * have initialized this the three resources and probably board |
2698 | * specific platform_data. we don't probe for IRQs, and do only | 2701 | * specific platform_data. we don't probe for IRQs, and do only |
@@ -2864,19 +2867,4 @@ static struct platform_driver isp1362_driver = { | |||
2864 | }, | 2867 | }, |
2865 | }; | 2868 | }; |
2866 | 2869 | ||
2867 | /*-------------------------------------------------------------------------*/ | 2870 | module_platform_driver(isp1362_driver); |
2868 | |||
2869 | static int __init isp1362_init(void) | ||
2870 | { | ||
2871 | if (usb_disabled()) | ||
2872 | return -ENODEV; | ||
2873 | pr_info("driver %s, %s\n", hcd_name, DRIVER_VERSION); | ||
2874 | return platform_driver_register(&isp1362_driver); | ||
2875 | } | ||
2876 | module_init(isp1362_init); | ||
2877 | |||
2878 | static void __exit isp1362_cleanup(void) | ||
2879 | { | ||
2880 | platform_driver_unregister(&isp1362_driver); | ||
2881 | } | ||
2882 | module_exit(isp1362_cleanup); | ||
diff --git a/drivers/usb/host/ohci-ath79.c b/drivers/usb/host/ohci-ath79.c deleted file mode 100644 index 18d574d6958b..000000000000 --- a/drivers/usb/host/ohci-ath79.c +++ /dev/null | |||
@@ -1,151 +0,0 @@ | |||
1 | /* | ||
2 | * OHCI HCD (Host Controller Driver) for USB. | ||
3 | * | ||
4 | * Bus Glue for Atheros AR71XX/AR724X built-in OHCI controller. | ||
5 | * | ||
6 | * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> | ||
7 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> | ||
8 | * | ||
9 | * Parts of this file are based on Atheros' 2.6.15 BSP | ||
10 | * Copyright (C) 2007 Atheros Communications, Inc. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 as published | ||
14 | * by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/platform_device.h> | ||
18 | |||
19 | static int __devinit ohci_ath79_start(struct usb_hcd *hcd) | ||
20 | { | ||
21 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
22 | int ret; | ||
23 | |||
24 | ret = ohci_init(ohci); | ||
25 | if (ret < 0) | ||
26 | return ret; | ||
27 | |||
28 | ret = ohci_run(ohci); | ||
29 | if (ret < 0) | ||
30 | goto err; | ||
31 | |||
32 | return 0; | ||
33 | |||
34 | err: | ||
35 | ohci_stop(hcd); | ||
36 | return ret; | ||
37 | } | ||
38 | |||
39 | static const struct hc_driver ohci_ath79_hc_driver = { | ||
40 | .description = hcd_name, | ||
41 | .product_desc = "Atheros built-in OHCI controller", | ||
42 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
43 | |||
44 | .irq = ohci_irq, | ||
45 | .flags = HCD_USB11 | HCD_MEMORY, | ||
46 | |||
47 | .start = ohci_ath79_start, | ||
48 | .stop = ohci_stop, | ||
49 | .shutdown = ohci_shutdown, | ||
50 | |||
51 | .urb_enqueue = ohci_urb_enqueue, | ||
52 | .urb_dequeue = ohci_urb_dequeue, | ||
53 | .endpoint_disable = ohci_endpoint_disable, | ||
54 | |||
55 | /* | ||
56 | * scheduling support | ||
57 | */ | ||
58 | .get_frame_number = ohci_get_frame, | ||
59 | |||
60 | /* | ||
61 | * root hub support | ||
62 | */ | ||
63 | .hub_status_data = ohci_hub_status_data, | ||
64 | .hub_control = ohci_hub_control, | ||
65 | .start_port_reset = ohci_start_port_reset, | ||
66 | }; | ||
67 | |||
68 | static int ohci_ath79_probe(struct platform_device *pdev) | ||
69 | { | ||
70 | struct usb_hcd *hcd; | ||
71 | struct resource *res; | ||
72 | int irq; | ||
73 | int ret; | ||
74 | |||
75 | if (usb_disabled()) | ||
76 | return -ENODEV; | ||
77 | |||
78 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | ||
79 | if (!res) { | ||
80 | dev_dbg(&pdev->dev, "no IRQ specified\n"); | ||
81 | return -ENODEV; | ||
82 | } | ||
83 | irq = res->start; | ||
84 | |||
85 | hcd = usb_create_hcd(&ohci_ath79_hc_driver, &pdev->dev, | ||
86 | dev_name(&pdev->dev)); | ||
87 | if (!hcd) | ||
88 | return -ENOMEM; | ||
89 | |||
90 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
91 | if (!res) { | ||
92 | dev_dbg(&pdev->dev, "no base address specified\n"); | ||
93 | ret = -ENODEV; | ||
94 | goto err_put_hcd; | ||
95 | } | ||
96 | hcd->rsrc_start = res->start; | ||
97 | hcd->rsrc_len = resource_size(res); | ||
98 | |||
99 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
100 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
101 | ret = -EBUSY; | ||
102 | goto err_put_hcd; | ||
103 | } | ||
104 | |||
105 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
106 | if (!hcd->regs) { | ||
107 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
108 | ret = -EFAULT; | ||
109 | goto err_release_region; | ||
110 | } | ||
111 | |||
112 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
113 | |||
114 | ret = usb_add_hcd(hcd, irq, 0); | ||
115 | if (ret) | ||
116 | goto err_stop_hcd; | ||
117 | |||
118 | return 0; | ||
119 | |||
120 | err_stop_hcd: | ||
121 | iounmap(hcd->regs); | ||
122 | err_release_region: | ||
123 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
124 | err_put_hcd: | ||
125 | usb_put_hcd(hcd); | ||
126 | return ret; | ||
127 | } | ||
128 | |||
129 | static int ohci_ath79_remove(struct platform_device *pdev) | ||
130 | { | ||
131 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | ||
132 | |||
133 | usb_remove_hcd(hcd); | ||
134 | iounmap(hcd->regs); | ||
135 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
136 | usb_put_hcd(hcd); | ||
137 | |||
138 | return 0; | ||
139 | } | ||
140 | |||
141 | static struct platform_driver ohci_hcd_ath79_driver = { | ||
142 | .probe = ohci_ath79_probe, | ||
143 | .remove = ohci_ath79_remove, | ||
144 | .shutdown = usb_hcd_platform_shutdown, | ||
145 | .driver = { | ||
146 | .name = "ath79-ohci", | ||
147 | .owner = THIS_MODULE, | ||
148 | }, | ||
149 | }; | ||
150 | |||
151 | MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ath79-ohci"); | ||
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 55aa35aa3d7b..37bb20ebb6fc 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c | |||
@@ -212,12 +212,10 @@ static int exynos_ohci_suspend(struct device *dev) | |||
212 | * mark HW unaccessible, bail out if RH has been resumed. Use | 212 | * mark HW unaccessible, bail out if RH has been resumed. Use |
213 | * the spinlock to properly synchronize with possible pending | 213 | * the spinlock to properly synchronize with possible pending |
214 | * RH suspend or resume activity. | 214 | * RH suspend or resume activity. |
215 | * | ||
216 | * This is still racy as hcd->state is manipulated outside of | ||
217 | * any locks =P But that will be a different fix. | ||
218 | */ | 215 | */ |
219 | spin_lock_irqsave(&ohci->lock, flags); | 216 | spin_lock_irqsave(&ohci->lock, flags); |
220 | if (hcd->state != HC_STATE_SUSPENDED && hcd->state != HC_STATE_HALT) { | 217 | if (ohci->rh_state != OHCI_RH_SUSPENDED && |
218 | ohci->rh_state != OHCI_RH_HALTED) { | ||
221 | rc = -EINVAL; | 219 | rc = -EINVAL; |
222 | goto fail; | 220 | goto fail; |
223 | } | 221 | } |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 34b9edd86651..cd5e382db89c 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -899,7 +899,7 @@ static void ohci_stop (struct usb_hcd *hcd) | |||
899 | ohci_usb_reset (ohci); | 899 | ohci_usb_reset (ohci); |
900 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); | 900 | ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); |
901 | free_irq(hcd->irq, hcd); | 901 | free_irq(hcd->irq, hcd); |
902 | hcd->irq = -1; | 902 | hcd->irq = 0; |
903 | 903 | ||
904 | if (quirk_zfmicro(ohci)) | 904 | if (quirk_zfmicro(ohci)) |
905 | del_timer(&ohci->unlink_watchdog); | 905 | del_timer(&ohci->unlink_watchdog); |
@@ -1050,9 +1050,9 @@ MODULE_LICENSE ("GPL"); | |||
1050 | #define PLATFORM_DRIVER ohci_hcd_at91_driver | 1050 | #define PLATFORM_DRIVER ohci_hcd_at91_driver |
1051 | #endif | 1051 | #endif |
1052 | 1052 | ||
1053 | #ifdef CONFIG_ARCH_PNX4008 | 1053 | #if defined(CONFIG_ARCH_PNX4008) || defined(CONFIG_ARCH_LPC32XX) |
1054 | #include "ohci-pnx4008.c" | 1054 | #include "ohci-nxp.c" |
1055 | #define PLATFORM_DRIVER usb_hcd_pnx4008_driver | 1055 | #define PLATFORM_DRIVER usb_hcd_nxp_driver |
1056 | #endif | 1056 | #endif |
1057 | 1057 | ||
1058 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX | 1058 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
@@ -1111,16 +1111,16 @@ MODULE_LICENSE ("GPL"); | |||
1111 | #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver | 1111 | #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver |
1112 | #endif | 1112 | #endif |
1113 | 1113 | ||
1114 | #ifdef CONFIG_USB_OHCI_ATH79 | ||
1115 | #include "ohci-ath79.c" | ||
1116 | #define PLATFORM_DRIVER ohci_hcd_ath79_driver | ||
1117 | #endif | ||
1118 | |||
1119 | #ifdef CONFIG_CPU_XLR | 1114 | #ifdef CONFIG_CPU_XLR |
1120 | #include "ohci-xls.c" | 1115 | #include "ohci-xls.c" |
1121 | #define PLATFORM_DRIVER ohci_xls_driver | 1116 | #define PLATFORM_DRIVER ohci_xls_driver |
1122 | #endif | 1117 | #endif |
1123 | 1118 | ||
1119 | #ifdef CONFIG_USB_OHCI_HCD_PLATFORM | ||
1120 | #include "ohci-platform.c" | ||
1121 | #define PLATFORM_DRIVER ohci_platform_driver | ||
1122 | #endif | ||
1123 | |||
1124 | #if !defined(PCI_DRIVER) && \ | 1124 | #if !defined(PCI_DRIVER) && \ |
1125 | !defined(PLATFORM_DRIVER) && \ | 1125 | !defined(PLATFORM_DRIVER) && \ |
1126 | !defined(OMAP1_PLATFORM_DRIVER) && \ | 1126 | !defined(OMAP1_PLATFORM_DRIVER) && \ |
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-nxp.c index 0013db7bdf92..6618de1d881d 100644 --- a/drivers/usb/host/ohci-pnx4008.c +++ b/drivers/usb/host/ohci-nxp.c | |||
@@ -1,7 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/usb/host/ohci-pnx4008.c | 2 | * driver for NXP USB Host devices |
3 | * | 3 | * |
4 | * driver for Philips PNX4008 USB Host | 4 | * Currently supported OHCI host devices: |
5 | * - Philips PNX4008 | ||
6 | * - NXP LPC32xx | ||
5 | * | 7 | * |
6 | * Authors: Dmitry Chigirev <source@mvista.com> | 8 | * Authors: Dmitry Chigirev <source@mvista.com> |
7 | * Vitaly Wool <vitalywool@gmail.com> | 9 | * Vitaly Wool <vitalywool@gmail.com> |
@@ -22,20 +24,24 @@ | |||
22 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
23 | 25 | ||
24 | #include <mach/hardware.h> | 26 | #include <mach/hardware.h> |
27 | #include <asm/mach-types.h> | ||
25 | #include <asm/io.h> | 28 | #include <asm/io.h> |
26 | 29 | ||
27 | #include <mach/platform.h> | 30 | #include <mach/platform.h> |
28 | #include <mach/irqs.h> | 31 | #include <mach/irqs.h> |
29 | #include <asm/gpio.h> | 32 | #include <asm/gpio.h> |
30 | 33 | ||
31 | #define USB_CTRL IO_ADDRESS(PNX4008_PWRMAN_BASE + 0x64) | 34 | #define USB_CONFIG_BASE 0x31020000 |
35 | #define PWRMAN_BASE 0x40004000 | ||
36 | |||
37 | #define USB_CTRL IO_ADDRESS(PWRMAN_BASE + 0x64) | ||
32 | 38 | ||
33 | /* USB_CTRL bit defines */ | 39 | /* USB_CTRL bit defines */ |
34 | #define USB_SLAVE_HCLK_EN (1 << 24) | 40 | #define USB_SLAVE_HCLK_EN (1 << 24) |
35 | #define USB_HOST_NEED_CLK_EN (1 << 21) | 41 | #define USB_HOST_NEED_CLK_EN (1 << 21) |
36 | 42 | ||
37 | #define USB_OTG_CLK_CTRL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF4) | 43 | #define USB_OTG_CLK_CTRL IO_ADDRESS(USB_CONFIG_BASE + 0xFF4) |
38 | #define USB_OTG_CLK_STAT IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF8) | 44 | #define USB_OTG_CLK_STAT IO_ADDRESS(USB_CONFIG_BASE + 0xFF8) |
39 | 45 | ||
40 | /* USB_OTG_CLK_CTRL bit defines */ | 46 | /* USB_OTG_CLK_CTRL bit defines */ |
41 | #define AHB_M_CLOCK_ON (1 << 4) | 47 | #define AHB_M_CLOCK_ON (1 << 4) |
@@ -44,7 +50,7 @@ | |||
44 | #define DEV_CLOCK_ON (1 << 1) | 50 | #define DEV_CLOCK_ON (1 << 1) |
45 | #define HOST_CLOCK_ON (1 << 0) | 51 | #define HOST_CLOCK_ON (1 << 0) |
46 | 52 | ||
47 | #define USB_OTG_STAT_CONTROL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0x110) | 53 | #define USB_OTG_STAT_CONTROL IO_ADDRESS(USB_CONFIG_BASE + 0x110) |
48 | 54 | ||
49 | /* USB_OTG_STAT_CONTROL bit defines */ | 55 | /* USB_OTG_STAT_CONTROL bit defines */ |
50 | #define TRANSPARENT_I2C_EN (1 << 7) | 56 | #define TRANSPARENT_I2C_EN (1 << 7) |
@@ -98,6 +104,15 @@ | |||
98 | #define ISP1301_I2C_INTERRUPT_RISING 0xE | 104 | #define ISP1301_I2C_INTERRUPT_RISING 0xE |
99 | #define ISP1301_I2C_REG_CLEAR_ADDR 1 | 105 | #define ISP1301_I2C_REG_CLEAR_ADDR 1 |
100 | 106 | ||
107 | /* On LPC32xx, those are undefined */ | ||
108 | #ifndef start_int_set_falling_edge | ||
109 | #define start_int_set_falling_edge(irq) | ||
110 | #define start_int_set_rising_edge(irq) | ||
111 | #define start_int_ack(irq) | ||
112 | #define start_int_mask(irq) | ||
113 | #define start_int_umask(irq) | ||
114 | #endif | ||
115 | |||
101 | static struct i2c_driver isp1301_driver; | 116 | static struct i2c_driver isp1301_driver; |
102 | static struct i2c_client *isp1301_i2c_client; | 117 | static struct i2c_client *isp1301_i2c_client; |
103 | 118 | ||
@@ -121,73 +136,129 @@ static int isp1301_remove(struct i2c_client *client) | |||
121 | } | 136 | } |
122 | 137 | ||
123 | static const struct i2c_device_id isp1301_id[] = { | 138 | static const struct i2c_device_id isp1301_id[] = { |
124 | { "isp1301_pnx", 0 }, | 139 | { "isp1301_nxp", 0 }, |
125 | { } | 140 | { } |
126 | }; | 141 | }; |
127 | 142 | ||
128 | static struct i2c_driver isp1301_driver = { | 143 | static struct i2c_driver isp1301_driver = { |
129 | .driver = { | 144 | .driver = { |
130 | .name = "isp1301_pnx", | 145 | .name = "isp1301_nxp", |
131 | }, | 146 | }, |
132 | .probe = isp1301_probe, | 147 | .probe = isp1301_probe, |
133 | .remove = isp1301_remove, | 148 | .remove = isp1301_remove, |
134 | .id_table = isp1301_id, | 149 | .id_table = isp1301_id, |
135 | }; | 150 | }; |
136 | 151 | ||
137 | static void i2c_write(u8 buf, u8 subaddr) | 152 | static void isp1301_configure_pnx4008(void) |
138 | { | ||
139 | char tmpbuf[2]; | ||
140 | |||
141 | tmpbuf[0] = subaddr; /*register number */ | ||
142 | tmpbuf[1] = buf; /*register data */ | ||
143 | i2c_master_send(isp1301_i2c_client, &tmpbuf[0], 2); | ||
144 | } | ||
145 | |||
146 | static void isp1301_configure(void) | ||
147 | { | 153 | { |
148 | /* PNX4008 only supports DAT_SE0 USB mode */ | 154 | /* PNX4008 only supports DAT_SE0 USB mode */ |
149 | /* PNX4008 R2A requires setting the MAX603 to output 3.6V */ | 155 | /* PNX4008 R2A requires setting the MAX603 to output 3.6V */ |
150 | /* Power up externel charge-pump */ | 156 | /* Power up externel charge-pump */ |
151 | 157 | ||
152 | i2c_write(MC1_DAT_SE0 | MC1_SPEED_REG, ISP1301_I2C_MODE_CONTROL_1); | 158 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
153 | i2c_write(~(MC1_DAT_SE0 | MC1_SPEED_REG), | 159 | ISP1301_I2C_MODE_CONTROL_1, MC1_DAT_SE0 | MC1_SPEED_REG); |
154 | ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | 160 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
155 | i2c_write(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL, | 161 | ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR, |
156 | ISP1301_I2C_MODE_CONTROL_2); | 162 | ~(MC1_DAT_SE0 | MC1_SPEED_REG)); |
157 | i2c_write(~(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL), | 163 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
158 | ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR); | 164 | ISP1301_I2C_MODE_CONTROL_2, |
159 | i2c_write(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN, | 165 | MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL); |
160 | ISP1301_I2C_OTG_CONTROL_1); | 166 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
161 | i2c_write(~(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN), | 167 | ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR, |
162 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | 168 | ~(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL)); |
163 | i2c_write(0xFF, | 169 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
164 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR); | 170 | ISP1301_I2C_OTG_CONTROL_1, OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN); |
165 | i2c_write(0xFF, | 171 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
166 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR); | 172 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR, |
167 | i2c_write(0xFF, | 173 | ~(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN)); |
168 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR); | 174 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
175 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR, 0xFF); | ||
176 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
177 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR, | ||
178 | 0xFF); | ||
179 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
180 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR, | ||
181 | 0xFF); | ||
182 | } | ||
169 | 183 | ||
184 | static void isp1301_configure_lpc32xx(void) | ||
185 | { | ||
186 | /* LPC32XX only supports DAT_SE0 USB mode */ | ||
187 | /* This sequence is important */ | ||
188 | |||
189 | /* Disable transparent UART mode first */ | ||
190 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
191 | (ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
192 | MC1_UART_EN); | ||
193 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
194 | (ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
195 | ~MC1_SPEED_REG); | ||
196 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
197 | ISP1301_I2C_MODE_CONTROL_1, MC1_SPEED_REG); | ||
198 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
199 | (ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
200 | ~0); | ||
201 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
202 | ISP1301_I2C_MODE_CONTROL_2, | ||
203 | (MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL)); | ||
204 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
205 | (ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), ~0); | ||
206 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
207 | ISP1301_I2C_MODE_CONTROL_1, MC1_DAT_SE0); | ||
208 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
209 | ISP1301_I2C_OTG_CONTROL_1, | ||
210 | (OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN)); | ||
211 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
212 | (ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR), | ||
213 | (OTG1_DM_PULLUP | OTG1_DP_PULLUP)); | ||
214 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
215 | ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR, ~0); | ||
216 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
217 | ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR, | ||
218 | ~0); | ||
219 | i2c_smbus_write_byte_data(isp1301_i2c_client, | ||
220 | ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR, ~0); | ||
221 | |||
222 | /* Enable usb_need_clk clock after transceiver is initialized */ | ||
223 | __raw_writel((__raw_readl(USB_CTRL) | (1 << 22)), USB_CTRL); | ||
224 | |||
225 | printk(KERN_INFO "ISP1301 Vendor ID : 0x%04x\n", | ||
226 | i2c_smbus_read_word_data(isp1301_i2c_client, 0x00)); | ||
227 | printk(KERN_INFO "ISP1301 Product ID : 0x%04x\n", | ||
228 | i2c_smbus_read_word_data(isp1301_i2c_client, 0x02)); | ||
229 | printk(KERN_INFO "ISP1301 Version ID : 0x%04x\n", | ||
230 | i2c_smbus_read_word_data(isp1301_i2c_client, 0x14)); | ||
231 | } | ||
232 | |||
233 | static void isp1301_configure(void) | ||
234 | { | ||
235 | if (machine_is_pnx4008()) | ||
236 | isp1301_configure_pnx4008(); | ||
237 | else | ||
238 | isp1301_configure_lpc32xx(); | ||
170 | } | 239 | } |
171 | 240 | ||
172 | static inline void isp1301_vbus_on(void) | 241 | static inline void isp1301_vbus_on(void) |
173 | { | 242 | { |
174 | i2c_write(OTG1_VBUS_DRV, ISP1301_I2C_OTG_CONTROL_1); | 243 | i2c_smbus_write_byte_data(isp1301_i2c_client, ISP1301_I2C_OTG_CONTROL_1, |
244 | OTG1_VBUS_DRV); | ||
175 | } | 245 | } |
176 | 246 | ||
177 | static inline void isp1301_vbus_off(void) | 247 | static inline void isp1301_vbus_off(void) |
178 | { | 248 | { |
179 | i2c_write(OTG1_VBUS_DRV, | 249 | i2c_smbus_write_byte_data(isp1301_i2c_client, |
180 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR); | 250 | ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR, |
251 | OTG1_VBUS_DRV); | ||
181 | } | 252 | } |
182 | 253 | ||
183 | static void pnx4008_start_hc(void) | 254 | static void nxp_start_hc(void) |
184 | { | 255 | { |
185 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; | 256 | unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN; |
186 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 257 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
187 | isp1301_vbus_on(); | 258 | isp1301_vbus_on(); |
188 | } | 259 | } |
189 | 260 | ||
190 | static void pnx4008_stop_hc(void) | 261 | static void nxp_stop_hc(void) |
191 | { | 262 | { |
192 | unsigned long tmp; | 263 | unsigned long tmp; |
193 | isp1301_vbus_off(); | 264 | isp1301_vbus_off(); |
@@ -195,7 +266,7 @@ static void pnx4008_stop_hc(void) | |||
195 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); | 266 | __raw_writel(tmp, USB_OTG_STAT_CONTROL); |
196 | } | 267 | } |
197 | 268 | ||
198 | static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd) | 269 | static int __devinit ohci_nxp_start(struct usb_hcd *hcd) |
199 | { | 270 | { |
200 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 271 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
201 | int ret; | 272 | int ret; |
@@ -211,9 +282,9 @@ static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd) | |||
211 | return 0; | 282 | return 0; |
212 | } | 283 | } |
213 | 284 | ||
214 | static const struct hc_driver ohci_pnx4008_hc_driver = { | 285 | static const struct hc_driver ohci_nxp_hc_driver = { |
215 | .description = hcd_name, | 286 | .description = hcd_name, |
216 | .product_desc = "pnx4008 OHCI", | 287 | .product_desc = "nxp OHCI", |
217 | 288 | ||
218 | /* | 289 | /* |
219 | * generic hardware linkage | 290 | * generic hardware linkage |
@@ -225,7 +296,7 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
225 | /* | 296 | /* |
226 | * basic lifecycle operations | 297 | * basic lifecycle operations |
227 | */ | 298 | */ |
228 | .start = ohci_pnx4008_start, | 299 | .start = ohci_nxp_start, |
229 | .stop = ohci_stop, | 300 | .stop = ohci_stop, |
230 | .shutdown = ohci_shutdown, | 301 | .shutdown = ohci_shutdown, |
231 | 302 | ||
@@ -255,54 +326,58 @@ static const struct hc_driver ohci_pnx4008_hc_driver = { | |||
255 | 326 | ||
256 | #define USB_CLOCK_MASK (AHB_M_CLOCK_ON| OTG_CLOCK_ON | HOST_CLOCK_ON | I2C_CLOCK_ON) | 327 | #define USB_CLOCK_MASK (AHB_M_CLOCK_ON| OTG_CLOCK_ON | HOST_CLOCK_ON | I2C_CLOCK_ON) |
257 | 328 | ||
258 | static void pnx4008_set_usb_bits(void) | 329 | static void nxp_set_usb_bits(void) |
259 | { | 330 | { |
260 | start_int_set_falling_edge(SE_USB_OTG_ATX_INT_N); | 331 | if (machine_is_pnx4008()) { |
261 | start_int_ack(SE_USB_OTG_ATX_INT_N); | 332 | start_int_set_falling_edge(SE_USB_OTG_ATX_INT_N); |
262 | start_int_umask(SE_USB_OTG_ATX_INT_N); | 333 | start_int_ack(SE_USB_OTG_ATX_INT_N); |
263 | 334 | start_int_umask(SE_USB_OTG_ATX_INT_N); | |
264 | start_int_set_rising_edge(SE_USB_OTG_TIMER_INT); | 335 | |
265 | start_int_ack(SE_USB_OTG_TIMER_INT); | 336 | start_int_set_rising_edge(SE_USB_OTG_TIMER_INT); |
266 | start_int_umask(SE_USB_OTG_TIMER_INT); | 337 | start_int_ack(SE_USB_OTG_TIMER_INT); |
267 | 338 | start_int_umask(SE_USB_OTG_TIMER_INT); | |
268 | start_int_set_rising_edge(SE_USB_I2C_INT); | 339 | |
269 | start_int_ack(SE_USB_I2C_INT); | 340 | start_int_set_rising_edge(SE_USB_I2C_INT); |
270 | start_int_umask(SE_USB_I2C_INT); | 341 | start_int_ack(SE_USB_I2C_INT); |
271 | 342 | start_int_umask(SE_USB_I2C_INT); | |
272 | start_int_set_rising_edge(SE_USB_INT); | 343 | |
273 | start_int_ack(SE_USB_INT); | 344 | start_int_set_rising_edge(SE_USB_INT); |
274 | start_int_umask(SE_USB_INT); | 345 | start_int_ack(SE_USB_INT); |
275 | 346 | start_int_umask(SE_USB_INT); | |
276 | start_int_set_rising_edge(SE_USB_NEED_CLK_INT); | 347 | |
277 | start_int_ack(SE_USB_NEED_CLK_INT); | 348 | start_int_set_rising_edge(SE_USB_NEED_CLK_INT); |
278 | start_int_umask(SE_USB_NEED_CLK_INT); | 349 | start_int_ack(SE_USB_NEED_CLK_INT); |
279 | 350 | start_int_umask(SE_USB_NEED_CLK_INT); | |
280 | start_int_set_rising_edge(SE_USB_AHB_NEED_CLK_INT); | 351 | |
281 | start_int_ack(SE_USB_AHB_NEED_CLK_INT); | 352 | start_int_set_rising_edge(SE_USB_AHB_NEED_CLK_INT); |
282 | start_int_umask(SE_USB_AHB_NEED_CLK_INT); | 353 | start_int_ack(SE_USB_AHB_NEED_CLK_INT); |
354 | start_int_umask(SE_USB_AHB_NEED_CLK_INT); | ||
355 | } | ||
283 | } | 356 | } |
284 | 357 | ||
285 | static void pnx4008_unset_usb_bits(void) | 358 | static void nxp_unset_usb_bits(void) |
286 | { | 359 | { |
287 | start_int_mask(SE_USB_OTG_ATX_INT_N); | 360 | if (machine_is_pnx4008()) { |
288 | start_int_mask(SE_USB_OTG_TIMER_INT); | 361 | start_int_mask(SE_USB_OTG_ATX_INT_N); |
289 | start_int_mask(SE_USB_I2C_INT); | 362 | start_int_mask(SE_USB_OTG_TIMER_INT); |
290 | start_int_mask(SE_USB_INT); | 363 | start_int_mask(SE_USB_I2C_INT); |
291 | start_int_mask(SE_USB_NEED_CLK_INT); | 364 | start_int_mask(SE_USB_INT); |
292 | start_int_mask(SE_USB_AHB_NEED_CLK_INT); | 365 | start_int_mask(SE_USB_NEED_CLK_INT); |
366 | start_int_mask(SE_USB_AHB_NEED_CLK_INT); | ||
367 | } | ||
293 | } | 368 | } |
294 | 369 | ||
295 | static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | 370 | static int __devinit usb_hcd_nxp_probe(struct platform_device *pdev) |
296 | { | 371 | { |
297 | struct usb_hcd *hcd = 0; | 372 | struct usb_hcd *hcd = 0; |
298 | struct ohci_hcd *ohci; | 373 | struct ohci_hcd *ohci; |
299 | const struct hc_driver *driver = &ohci_pnx4008_hc_driver; | 374 | const struct hc_driver *driver = &ohci_nxp_hc_driver; |
300 | struct i2c_adapter *i2c_adap; | 375 | struct i2c_adapter *i2c_adap; |
301 | struct i2c_board_info i2c_info; | 376 | struct i2c_board_info i2c_info; |
302 | 377 | ||
303 | int ret = 0, irq; | 378 | int ret = 0, irq; |
304 | 379 | ||
305 | dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (pnx4008)\n", hcd_name); | 380 | dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (nxp)\n", hcd_name); |
306 | if (usb_disabled()) { | 381 | if (usb_disabled()) { |
307 | err("USB is disabled"); | 382 | err("USB is disabled"); |
308 | ret = -ENODEV; | 383 | ret = -ENODEV; |
@@ -327,7 +402,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
327 | } | 402 | } |
328 | i2c_adap = i2c_get_adapter(2); | 403 | i2c_adap = i2c_get_adapter(2); |
329 | memset(&i2c_info, 0, sizeof(struct i2c_board_info)); | 404 | memset(&i2c_info, 0, sizeof(struct i2c_board_info)); |
330 | strlcpy(i2c_info.type, "isp1301_pnx", I2C_NAME_SIZE); | 405 | strlcpy(i2c_info.type, "isp1301_nxp", I2C_NAME_SIZE); |
331 | isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, | 406 | isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, |
332 | normal_i2c, NULL); | 407 | normal_i2c, NULL); |
333 | i2c_put_adapter(i2c_adap); | 408 | i2c_put_adapter(i2c_adap); |
@@ -375,7 +450,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
375 | } | 450 | } |
376 | 451 | ||
377 | /* Set all USB bits in the Start Enable register */ | 452 | /* Set all USB bits in the Start Enable register */ |
378 | pnx4008_set_usb_bits(); | 453 | nxp_set_usb_bits(); |
379 | 454 | ||
380 | hcd->rsrc_start = pdev->resource[0].start; | 455 | hcd->rsrc_start = pdev->resource[0].start; |
381 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; | 456 | hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; |
@@ -392,7 +467,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
392 | goto out4; | 467 | goto out4; |
393 | } | 468 | } |
394 | 469 | ||
395 | pnx4008_start_hc(); | 470 | nxp_start_hc(); |
396 | platform_set_drvdata(pdev, hcd); | 471 | platform_set_drvdata(pdev, hcd); |
397 | ohci = hcd_to_ohci(hcd); | 472 | ohci = hcd_to_ohci(hcd); |
398 | ohci_hcd_init(ohci); | 473 | ohci_hcd_init(ohci); |
@@ -402,9 +477,9 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev) | |||
402 | if (ret == 0) | 477 | if (ret == 0) |
403 | return ret; | 478 | return ret; |
404 | 479 | ||
405 | pnx4008_stop_hc(); | 480 | nxp_stop_hc(); |
406 | out4: | 481 | out4: |
407 | pnx4008_unset_usb_bits(); | 482 | nxp_unset_usb_bits(); |
408 | usb_put_hcd(hcd); | 483 | usb_put_hcd(hcd); |
409 | out3: | 484 | out3: |
410 | clk_disable(usb_clk); | 485 | clk_disable(usb_clk); |
@@ -419,15 +494,15 @@ out: | |||
419 | return ret; | 494 | return ret; |
420 | } | 495 | } |
421 | 496 | ||
422 | static int usb_hcd_pnx4008_remove(struct platform_device *pdev) | 497 | static int usb_hcd_nxp_remove(struct platform_device *pdev) |
423 | { | 498 | { |
424 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 499 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
425 | 500 | ||
426 | usb_remove_hcd(hcd); | 501 | usb_remove_hcd(hcd); |
427 | pnx4008_stop_hc(); | 502 | nxp_stop_hc(); |
428 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | 503 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
429 | usb_put_hcd(hcd); | 504 | usb_put_hcd(hcd); |
430 | pnx4008_unset_usb_bits(); | 505 | nxp_unset_usb_bits(); |
431 | clk_disable(usb_clk); | 506 | clk_disable(usb_clk); |
432 | clk_put(usb_clk); | 507 | clk_put(usb_clk); |
433 | i2c_unregister_device(isp1301_i2c_client); | 508 | i2c_unregister_device(isp1301_i2c_client); |
@@ -442,12 +517,12 @@ static int usb_hcd_pnx4008_remove(struct platform_device *pdev) | |||
442 | /* work with hotplug and coldplug */ | 517 | /* work with hotplug and coldplug */ |
443 | MODULE_ALIAS("platform:usb-ohci"); | 518 | MODULE_ALIAS("platform:usb-ohci"); |
444 | 519 | ||
445 | static struct platform_driver usb_hcd_pnx4008_driver = { | 520 | static struct platform_driver usb_hcd_nxp_driver = { |
446 | .driver = { | 521 | .driver = { |
447 | .name = "usb-ohci", | 522 | .name = "usb-ohci", |
448 | .owner = THIS_MODULE, | 523 | .owner = THIS_MODULE, |
449 | }, | 524 | }, |
450 | .probe = usb_hcd_pnx4008_probe, | 525 | .probe = usb_hcd_nxp_probe, |
451 | .remove = usb_hcd_pnx4008_remove, | 526 | .remove = usb_hcd_nxp_remove, |
452 | }; | 527 | }; |
453 | 528 | ||
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index db3968656d21..96451e41ee8a 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c | |||
@@ -171,7 +171,7 @@ static void start_hnp(struct ohci_hcd *ohci) | |||
171 | unsigned long flags; | 171 | unsigned long flags; |
172 | u32 l; | 172 | u32 l; |
173 | 173 | ||
174 | otg_start_hnp(ohci->transceiver); | 174 | otg_start_hnp(ohci->transceiver->otg); |
175 | 175 | ||
176 | local_irq_save(flags); | 176 | local_irq_save(flags); |
177 | ohci->transceiver->state = OTG_STATE_A_SUSPEND; | 177 | ohci->transceiver->state = OTG_STATE_A_SUSPEND; |
@@ -210,9 +210,9 @@ static int ohci_omap_init(struct usb_hcd *hcd) | |||
210 | 210 | ||
211 | #ifdef CONFIG_USB_OTG | 211 | #ifdef CONFIG_USB_OTG |
212 | if (need_transceiver) { | 212 | if (need_transceiver) { |
213 | ohci->transceiver = otg_get_transceiver(); | 213 | ohci->transceiver = usb_get_transceiver(); |
214 | if (ohci->transceiver) { | 214 | if (ohci->transceiver) { |
215 | int status = otg_set_host(ohci->transceiver, | 215 | int status = otg_set_host(ohci->transceiver->otg, |
216 | &ohci_to_hcd(ohci)->self); | 216 | &ohci_to_hcd(ohci)->self); |
217 | dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", | 217 | dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n", |
218 | ohci->transceiver->label, status); | 218 | ohci->transceiver->label, status); |
@@ -404,7 +404,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) | |||
404 | 404 | ||
405 | usb_remove_hcd(hcd); | 405 | usb_remove_hcd(hcd); |
406 | if (ohci->transceiver) { | 406 | if (ohci->transceiver) { |
407 | (void) otg_set_host(ohci->transceiver, 0); | 407 | (void) otg_set_host(ohci->transceiver->otg, 0); |
408 | put_device(ohci->transceiver->dev); | 408 | put_device(ohci->transceiver->dev); |
409 | } | 409 | } |
410 | if (machine_is_omap_osk()) | 410 | if (machine_is_omap_osk()) |
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c new file mode 100644 index 000000000000..ec5c6791c8b4 --- /dev/null +++ b/drivers/usb/host/ohci-platform.c | |||
@@ -0,0 +1,194 @@ | |||
1 | /* | ||
2 | * Generic platform ohci driver | ||
3 | * | ||
4 | * Copyright 2007 Michael Buesch <m@bues.ch> | ||
5 | * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
6 | * | ||
7 | * Derived from the OCHI-SSB driver | ||
8 | * Derived from the OHCI-PCI driver | ||
9 | * Copyright 1999 Roman Weissgaerber | ||
10 | * Copyright 2000-2002 David Brownell | ||
11 | * Copyright 1999 Linus Torvalds | ||
12 | * Copyright 1999 Gregory P. Smith | ||
13 | * | ||
14 | * Licensed under the GNU/GPL. See COPYING for details. | ||
15 | */ | ||
16 | #include <linux/platform_device.h> | ||
17 | #include <linux/usb/ohci_pdriver.h> | ||
18 | |||
19 | static int ohci_platform_reset(struct usb_hcd *hcd) | ||
20 | { | ||
21 | struct platform_device *pdev = to_platform_device(hcd->self.controller); | ||
22 | struct usb_ohci_pdata *pdata = pdev->dev.platform_data; | ||
23 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
24 | int err; | ||
25 | |||
26 | if (pdata->big_endian_desc) | ||
27 | ohci->flags |= OHCI_QUIRK_BE_DESC; | ||
28 | if (pdata->big_endian_mmio) | ||
29 | ohci->flags |= OHCI_QUIRK_BE_MMIO; | ||
30 | if (pdata->no_big_frame_no) | ||
31 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | ||
32 | |||
33 | ohci_hcd_init(ohci); | ||
34 | err = ohci_init(ohci); | ||
35 | |||
36 | return err; | ||
37 | } | ||
38 | |||
39 | static int ohci_platform_start(struct usb_hcd *hcd) | ||
40 | { | ||
41 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | ||
42 | int err; | ||
43 | |||
44 | err = ohci_run(ohci); | ||
45 | if (err < 0) { | ||
46 | ohci_err(ohci, "can't start\n"); | ||
47 | ohci_stop(hcd); | ||
48 | } | ||
49 | |||
50 | return err; | ||
51 | } | ||
52 | |||
53 | static const struct hc_driver ohci_platform_hc_driver = { | ||
54 | .description = hcd_name, | ||
55 | .product_desc = "Generic Platform OHCI Controller", | ||
56 | .hcd_priv_size = sizeof(struct ohci_hcd), | ||
57 | |||
58 | .irq = ohci_irq, | ||
59 | .flags = HCD_MEMORY | HCD_USB11, | ||
60 | |||
61 | .reset = ohci_platform_reset, | ||
62 | .start = ohci_platform_start, | ||
63 | .stop = ohci_stop, | ||
64 | .shutdown = ohci_shutdown, | ||
65 | |||
66 | .urb_enqueue = ohci_urb_enqueue, | ||
67 | .urb_dequeue = ohci_urb_dequeue, | ||
68 | .endpoint_disable = ohci_endpoint_disable, | ||
69 | |||
70 | .get_frame_number = ohci_get_frame, | ||
71 | |||
72 | .hub_status_data = ohci_hub_status_data, | ||
73 | .hub_control = ohci_hub_control, | ||
74 | #ifdef CONFIG_PM | ||
75 | .bus_suspend = ohci_bus_suspend, | ||
76 | .bus_resume = ohci_bus_resume, | ||
77 | #endif | ||
78 | |||
79 | .start_port_reset = ohci_start_port_reset, | ||
80 | }; | ||
81 | |||
82 | static int __devinit ohci_platform_probe(struct platform_device *dev) | ||
83 | { | ||
84 | struct usb_hcd *hcd; | ||
85 | struct resource *res_mem; | ||
86 | int irq; | ||
87 | int err = -ENOMEM; | ||
88 | |||
89 | BUG_ON(!dev->dev.platform_data); | ||
90 | |||
91 | if (usb_disabled()) | ||
92 | return -ENODEV; | ||
93 | |||
94 | irq = platform_get_irq(dev, 0); | ||
95 | if (irq < 0) { | ||
96 | pr_err("no irq provieded"); | ||
97 | return irq; | ||
98 | } | ||
99 | |||
100 | res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0); | ||
101 | if (!res_mem) { | ||
102 | pr_err("no memory recourse provieded"); | ||
103 | return -ENXIO; | ||
104 | } | ||
105 | |||
106 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, | ||
107 | dev_name(&dev->dev)); | ||
108 | if (!hcd) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | hcd->rsrc_start = res_mem->start; | ||
112 | hcd->rsrc_len = resource_size(res_mem); | ||
113 | |||
114 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { | ||
115 | pr_err("controller already in use"); | ||
116 | err = -EBUSY; | ||
117 | goto err_put_hcd; | ||
118 | } | ||
119 | |||
120 | hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len); | ||
121 | if (!hcd->regs) | ||
122 | goto err_release_region; | ||
123 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
124 | if (err) | ||
125 | goto err_iounmap; | ||
126 | |||
127 | platform_set_drvdata(dev, hcd); | ||
128 | |||
129 | return err; | ||
130 | |||
131 | err_iounmap: | ||
132 | iounmap(hcd->regs); | ||
133 | err_release_region: | ||
134 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
135 | err_put_hcd: | ||
136 | usb_put_hcd(hcd); | ||
137 | return err; | ||
138 | } | ||
139 | |||
140 | static int __devexit ohci_platform_remove(struct platform_device *dev) | ||
141 | { | ||
142 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
143 | |||
144 | usb_remove_hcd(hcd); | ||
145 | iounmap(hcd->regs); | ||
146 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
147 | usb_put_hcd(hcd); | ||
148 | platform_set_drvdata(dev, NULL); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | #ifdef CONFIG_PM | ||
154 | |||
155 | static int ohci_platform_suspend(struct device *dev) | ||
156 | { | ||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | static int ohci_platform_resume(struct device *dev) | ||
161 | { | ||
162 | struct usb_hcd *hcd = dev_get_drvdata(dev); | ||
163 | |||
164 | ohci_finish_controller_resume(hcd); | ||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | #else /* !CONFIG_PM */ | ||
169 | #define ohci_platform_suspend NULL | ||
170 | #define ohci_platform_resume NULL | ||
171 | #endif /* CONFIG_PM */ | ||
172 | |||
173 | static const struct platform_device_id ohci_platform_table[] = { | ||
174 | { "ohci-platform", 0 }, | ||
175 | { } | ||
176 | }; | ||
177 | MODULE_DEVICE_TABLE(platform, ohci_platform_table); | ||
178 | |||
179 | static const struct dev_pm_ops ohci_platform_pm_ops = { | ||
180 | .suspend = ohci_platform_suspend, | ||
181 | .resume = ohci_platform_resume, | ||
182 | }; | ||
183 | |||
184 | static struct platform_driver ohci_platform_driver = { | ||
185 | .id_table = ohci_platform_table, | ||
186 | .probe = ohci_platform_probe, | ||
187 | .remove = __devexit_p(ohci_platform_remove), | ||
188 | .shutdown = usb_hcd_platform_shutdown, | ||
189 | .driver = { | ||
190 | .owner = THIS_MODULE, | ||
191 | .name = "ohci-platform", | ||
192 | .pm = &ohci_platform_pm_ops, | ||
193 | } | ||
194 | }; | ||
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c index 6313e4439f37..c31b2815be1c 100644 --- a/drivers/usb/host/ohci-pxa27x.c +++ b/drivers/usb/host/ohci-pxa27x.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/signal.h> | 23 | #include <linux/signal.h> |
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <mach/hardware.h> | ||
26 | #include <mach/ohci.h> | 27 | #include <mach/ohci.h> |
27 | #include <mach/pxa3xx-u2d.h> | 28 | #include <mach/pxa3xx-u2d.h> |
28 | 29 | ||
@@ -218,7 +219,7 @@ static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev) | |||
218 | 219 | ||
219 | inf = dev->platform_data; | 220 | inf = dev->platform_data; |
220 | 221 | ||
221 | clk_enable(ohci->clk); | 222 | clk_prepare_enable(ohci->clk); |
222 | 223 | ||
223 | pxa27x_reset_hc(ohci); | 224 | pxa27x_reset_hc(ohci); |
224 | 225 | ||
@@ -268,7 +269,7 @@ static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev) | |||
268 | __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS); | 269 | __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS); |
269 | udelay(10); | 270 | udelay(10); |
270 | 271 | ||
271 | clk_disable(ohci->clk); | 272 | clk_disable_unprepare(ohci->clk); |
272 | } | 273 | } |
273 | 274 | ||
274 | 275 | ||
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h index 8ff6f7ea96fd..1b19aea25a2b 100644 --- a/drivers/usb/host/ohci.h +++ b/drivers/usb/host/ohci.h | |||
@@ -376,7 +376,7 @@ struct ohci_hcd { | |||
376 | * OTG controllers and transceivers need software interaction; | 376 | * OTG controllers and transceivers need software interaction; |
377 | * other external transceivers should be software-transparent | 377 | * other external transceivers should be software-transparent |
378 | */ | 378 | */ |
379 | struct otg_transceiver *transceiver; | 379 | struct usb_phy *transceiver; |
380 | void (*start_hnp)(struct ohci_hcd *ohci); | 380 | void (*start_hnp)(struct ohci_hcd *ohci); |
381 | 381 | ||
382 | /* | 382 | /* |
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index e84ca1928dbf..2bf1320dc9c3 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -2428,6 +2428,9 @@ static int __devinit r8a66597_probe(struct platform_device *pdev) | |||
2428 | int i; | 2428 | int i; |
2429 | unsigned long irq_trigger; | 2429 | unsigned long irq_trigger; |
2430 | 2430 | ||
2431 | if (usb_disabled()) | ||
2432 | return -ENODEV; | ||
2433 | |||
2431 | if (pdev->dev.dma_mask) { | 2434 | if (pdev->dev.dma_mask) { |
2432 | ret = -EINVAL; | 2435 | ret = -EINVAL; |
2433 | dev_err(&pdev->dev, "dma not supported\n"); | 2436 | dev_err(&pdev->dev, "dma not supported\n"); |
@@ -2552,20 +2555,4 @@ static struct platform_driver r8a66597_driver = { | |||
2552 | }, | 2555 | }, |
2553 | }; | 2556 | }; |
2554 | 2557 | ||
2555 | static int __init r8a66597_init(void) | 2558 | module_platform_driver(r8a66597_driver); |
2556 | { | ||
2557 | if (usb_disabled()) | ||
2558 | return -ENODEV; | ||
2559 | |||
2560 | printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name, | ||
2561 | DRIVER_VERSION); | ||
2562 | return platform_driver_register(&r8a66597_driver); | ||
2563 | } | ||
2564 | module_init(r8a66597_init); | ||
2565 | |||
2566 | static void __exit r8a66597_cleanup(void) | ||
2567 | { | ||
2568 | platform_driver_unregister(&r8a66597_driver); | ||
2569 | } | ||
2570 | module_exit(r8a66597_cleanup); | ||
2571 | |||
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index 961d6638d8f9..2a2cce2d2fa7 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c | |||
@@ -1632,6 +1632,9 @@ sl811h_probe(struct platform_device *dev) | |||
1632 | u8 tmp, ioaddr = 0; | 1632 | u8 tmp, ioaddr = 0; |
1633 | unsigned long irqflags; | 1633 | unsigned long irqflags; |
1634 | 1634 | ||
1635 | if (usb_disabled()) | ||
1636 | return -ENODEV; | ||
1637 | |||
1635 | /* basic sanity checks first. board-specific init logic should | 1638 | /* basic sanity checks first. board-specific init logic should |
1636 | * have initialized these three resources and probably board | 1639 | * have initialized these three resources and probably board |
1637 | * specific platform_data. we don't probe for IRQs, and do only | 1640 | * specific platform_data. we don't probe for IRQs, and do only |
@@ -1817,20 +1820,4 @@ struct platform_driver sl811h_driver = { | |||
1817 | }; | 1820 | }; |
1818 | EXPORT_SYMBOL(sl811h_driver); | 1821 | EXPORT_SYMBOL(sl811h_driver); |
1819 | 1822 | ||
1820 | /*-------------------------------------------------------------------------*/ | 1823 | module_platform_driver(sl811h_driver); |
1821 | |||
1822 | static int __init sl811h_init(void) | ||
1823 | { | ||
1824 | if (usb_disabled()) | ||
1825 | return -ENODEV; | ||
1826 | |||
1827 | INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); | ||
1828 | return platform_driver_register(&sl811h_driver); | ||
1829 | } | ||
1830 | module_init(sl811h_init); | ||
1831 | |||
1832 | static void __exit sl811h_cleanup(void) | ||
1833 | { | ||
1834 | platform_driver_unregister(&sl811h_driver); | ||
1835 | } | ||
1836 | module_exit(sl811h_cleanup); | ||
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index 6b5eb1017e2c..e37dea87bb56 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -565,6 +565,9 @@ static int uhci_start(struct usb_hcd *hcd) | |||
565 | struct dentry __maybe_unused *dentry; | 565 | struct dentry __maybe_unused *dentry; |
566 | 566 | ||
567 | hcd->uses_new_polling = 1; | 567 | hcd->uses_new_polling = 1; |
568 | /* Accept arbitrarily long scatter-gather lists */ | ||
569 | if (!(hcd->driver->flags & HCD_LOCAL_MEM)) | ||
570 | hcd->self.sg_tablesize = ~0; | ||
568 | 571 | ||
569 | spin_lock_init(&uhci->lock); | 572 | spin_lock_init(&uhci->lock); |
570 | setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout, | 573 | setup_timer(&uhci->fsbr_timer, uhci_fsbr_timeout, |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 557b6f32db86..673ad120c43e 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -422,6 +422,32 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array, | |||
422 | xhci_writel(xhci, temp, port_array[port_id]); | 422 | xhci_writel(xhci, temp, port_array[port_id]); |
423 | } | 423 | } |
424 | 424 | ||
425 | void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, | ||
426 | __le32 __iomem **port_array, int port_id, u16 wake_mask) | ||
427 | { | ||
428 | u32 temp; | ||
429 | |||
430 | temp = xhci_readl(xhci, port_array[port_id]); | ||
431 | temp = xhci_port_state_to_neutral(temp); | ||
432 | |||
433 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_CONNECT) | ||
434 | temp |= PORT_WKCONN_E; | ||
435 | else | ||
436 | temp &= ~PORT_WKCONN_E; | ||
437 | |||
438 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT) | ||
439 | temp |= PORT_WKDISC_E; | ||
440 | else | ||
441 | temp &= ~PORT_WKDISC_E; | ||
442 | |||
443 | if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT) | ||
444 | temp |= PORT_WKOC_E; | ||
445 | else | ||
446 | temp &= ~PORT_WKOC_E; | ||
447 | |||
448 | xhci_writel(xhci, temp, port_array[port_id]); | ||
449 | } | ||
450 | |||
425 | /* Test and clear port RWC bit */ | 451 | /* Test and clear port RWC bit */ |
426 | void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, | 452 | void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, |
427 | int port_id, u32 port_bit) | 453 | int port_id, u32 port_bit) |
@@ -448,6 +474,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
448 | int slot_id; | 474 | int slot_id; |
449 | struct xhci_bus_state *bus_state; | 475 | struct xhci_bus_state *bus_state; |
450 | u16 link_state = 0; | 476 | u16 link_state = 0; |
477 | u16 wake_mask = 0; | ||
451 | 478 | ||
452 | max_ports = xhci_get_ports(hcd, &port_array); | 479 | max_ports = xhci_get_ports(hcd, &port_array); |
453 | bus_state = &xhci->bus_state[hcd_index(hcd)]; | 480 | bus_state = &xhci->bus_state[hcd_index(hcd)]; |
@@ -593,6 +620,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
593 | case SetPortFeature: | 620 | case SetPortFeature: |
594 | if (wValue == USB_PORT_FEAT_LINK_STATE) | 621 | if (wValue == USB_PORT_FEAT_LINK_STATE) |
595 | link_state = (wIndex & 0xff00) >> 3; | 622 | link_state = (wIndex & 0xff00) >> 3; |
623 | if (wValue == USB_PORT_FEAT_REMOTE_WAKE_MASK) | ||
624 | wake_mask = wIndex & 0xff00; | ||
596 | wIndex &= 0xff; | 625 | wIndex &= 0xff; |
597 | if (!wIndex || wIndex > max_ports) | 626 | if (!wIndex || wIndex > max_ports) |
598 | goto error; | 627 | goto error; |
@@ -703,6 +732,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
703 | temp = xhci_readl(xhci, port_array[wIndex]); | 732 | temp = xhci_readl(xhci, port_array[wIndex]); |
704 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); | 733 | xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); |
705 | break; | 734 | break; |
735 | case USB_PORT_FEAT_REMOTE_WAKE_MASK: | ||
736 | xhci_set_remote_wake_mask(xhci, port_array, | ||
737 | wIndex, wake_mask); | ||
738 | temp = xhci_readl(xhci, port_array[wIndex]); | ||
739 | xhci_dbg(xhci, "set port remote wake mask, " | ||
740 | "actual port %d status = 0x%x\n", | ||
741 | wIndex, temp); | ||
742 | break; | ||
706 | case USB_PORT_FEAT_BH_PORT_RESET: | 743 | case USB_PORT_FEAT_BH_PORT_RESET: |
707 | temp |= PORT_WR; | 744 | temp |= PORT_WR; |
708 | xhci_writel(xhci, temp, port_array[wIndex]); | 745 | xhci_writel(xhci, temp, port_array[wIndex]); |
@@ -883,6 +920,10 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
883 | t2 |= PORT_LINK_STROBE | XDEV_U3; | 920 | t2 |= PORT_LINK_STROBE | XDEV_U3; |
884 | set_bit(port_index, &bus_state->bus_suspended); | 921 | set_bit(port_index, &bus_state->bus_suspended); |
885 | } | 922 | } |
923 | /* USB core sets remote wake mask for USB 3.0 hubs, | ||
924 | * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND | ||
925 | * is enabled, so also enable remote wake here. | ||
926 | */ | ||
886 | if (hcd->self.root_hub->do_remote_wakeup) { | 927 | if (hcd->self.root_hub->do_remote_wakeup) { |
887 | if (t1 & PORT_CONNECT) { | 928 | if (t1 & PORT_CONNECT) { |
888 | t2 |= PORT_WKOC_E | PORT_WKDISC_E; | 929 | t2 |= PORT_WKOC_E | PORT_WKDISC_E; |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 383fc857491c..cae4c6f2845a 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -34,10 +34,12 @@ | |||
34 | * Section 4.11.1.1: | 34 | * Section 4.11.1.1: |
35 | * "All components of all Command and Transfer TRBs shall be initialized to '0'" | 35 | * "All components of all Command and Transfer TRBs shall be initialized to '0'" |
36 | */ | 36 | */ |
37 | static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flags) | 37 | static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, |
38 | unsigned int cycle_state, gfp_t flags) | ||
38 | { | 39 | { |
39 | struct xhci_segment *seg; | 40 | struct xhci_segment *seg; |
40 | dma_addr_t dma; | 41 | dma_addr_t dma; |
42 | int i; | ||
41 | 43 | ||
42 | seg = kzalloc(sizeof *seg, flags); | 44 | seg = kzalloc(sizeof *seg, flags); |
43 | if (!seg) | 45 | if (!seg) |
@@ -50,6 +52,11 @@ static struct xhci_segment *xhci_segment_alloc(struct xhci_hcd *xhci, gfp_t flag | |||
50 | } | 52 | } |
51 | 53 | ||
52 | memset(seg->trbs, 0, SEGMENT_SIZE); | 54 | memset(seg->trbs, 0, SEGMENT_SIZE); |
55 | /* If the cycle state is 0, set the cycle bit to 1 for all the TRBs */ | ||
56 | if (cycle_state == 0) { | ||
57 | for (i = 0; i < TRBS_PER_SEGMENT; i++) | ||
58 | seg->trbs[i].link.control |= TRB_CYCLE; | ||
59 | } | ||
53 | seg->dma = dma; | 60 | seg->dma = dma; |
54 | seg->next = NULL; | 61 | seg->next = NULL; |
55 | 62 | ||
@@ -65,6 +72,20 @@ static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) | |||
65 | kfree(seg); | 72 | kfree(seg); |
66 | } | 73 | } |
67 | 74 | ||
75 | static void xhci_free_segments_for_ring(struct xhci_hcd *xhci, | ||
76 | struct xhci_segment *first) | ||
77 | { | ||
78 | struct xhci_segment *seg; | ||
79 | |||
80 | seg = first->next; | ||
81 | while (seg != first) { | ||
82 | struct xhci_segment *next = seg->next; | ||
83 | xhci_segment_free(xhci, seg); | ||
84 | seg = next; | ||
85 | } | ||
86 | xhci_segment_free(xhci, first); | ||
87 | } | ||
88 | |||
68 | /* | 89 | /* |
69 | * Make the prev segment point to the next segment. | 90 | * Make the prev segment point to the next segment. |
70 | * | 91 | * |
@@ -73,14 +94,14 @@ static void xhci_segment_free(struct xhci_hcd *xhci, struct xhci_segment *seg) | |||
73 | * related flags, such as End TRB, Toggle Cycle, and no snoop. | 94 | * related flags, such as End TRB, Toggle Cycle, and no snoop. |
74 | */ | 95 | */ |
75 | static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, | 96 | static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, |
76 | struct xhci_segment *next, bool link_trbs, bool isoc) | 97 | struct xhci_segment *next, enum xhci_ring_type type) |
77 | { | 98 | { |
78 | u32 val; | 99 | u32 val; |
79 | 100 | ||
80 | if (!prev || !next) | 101 | if (!prev || !next) |
81 | return; | 102 | return; |
82 | prev->next = next; | 103 | prev->next = next; |
83 | if (link_trbs) { | 104 | if (type != TYPE_EVENT) { |
84 | prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = | 105 | prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = |
85 | cpu_to_le64(next->dma); | 106 | cpu_to_le64(next->dma); |
86 | 107 | ||
@@ -91,35 +112,55 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, | |||
91 | /* Always set the chain bit with 0.95 hardware */ | 112 | /* Always set the chain bit with 0.95 hardware */ |
92 | /* Set chain bit for isoc rings on AMD 0.96 host */ | 113 | /* Set chain bit for isoc rings on AMD 0.96 host */ |
93 | if (xhci_link_trb_quirk(xhci) || | 114 | if (xhci_link_trb_quirk(xhci) || |
94 | (isoc && (xhci->quirks & XHCI_AMD_0x96_HOST))) | 115 | (type == TYPE_ISOC && |
116 | (xhci->quirks & XHCI_AMD_0x96_HOST))) | ||
95 | val |= TRB_CHAIN; | 117 | val |= TRB_CHAIN; |
96 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); | 118 | prev->trbs[TRBS_PER_SEGMENT-1].link.control = cpu_to_le32(val); |
97 | } | 119 | } |
98 | } | 120 | } |
99 | 121 | ||
122 | /* | ||
123 | * Link the ring to the new segments. | ||
124 | * Set Toggle Cycle for the new ring if needed. | ||
125 | */ | ||
126 | static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, | ||
127 | struct xhci_segment *first, struct xhci_segment *last, | ||
128 | unsigned int num_segs) | ||
129 | { | ||
130 | struct xhci_segment *next; | ||
131 | |||
132 | if (!ring || !first || !last) | ||
133 | return; | ||
134 | |||
135 | next = ring->enq_seg->next; | ||
136 | xhci_link_segments(xhci, ring->enq_seg, first, ring->type); | ||
137 | xhci_link_segments(xhci, last, next, ring->type); | ||
138 | ring->num_segs += num_segs; | ||
139 | ring->num_trbs_free += (TRBS_PER_SEGMENT - 1) * num_segs; | ||
140 | |||
141 | if (ring->type != TYPE_EVENT && ring->enq_seg == ring->last_seg) { | ||
142 | ring->last_seg->trbs[TRBS_PER_SEGMENT-1].link.control | ||
143 | &= ~cpu_to_le32(LINK_TOGGLE); | ||
144 | last->trbs[TRBS_PER_SEGMENT-1].link.control | ||
145 | |= cpu_to_le32(LINK_TOGGLE); | ||
146 | ring->last_seg = last; | ||
147 | } | ||
148 | } | ||
149 | |||
100 | /* XXX: Do we need the hcd structure in all these functions? */ | 150 | /* XXX: Do we need the hcd structure in all these functions? */ |
101 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) | 151 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) |
102 | { | 152 | { |
103 | struct xhci_segment *seg; | ||
104 | struct xhci_segment *first_seg; | ||
105 | |||
106 | if (!ring) | 153 | if (!ring) |
107 | return; | 154 | return; |
108 | if (ring->first_seg) { | 155 | |
109 | first_seg = ring->first_seg; | 156 | if (ring->first_seg) |
110 | seg = first_seg->next; | 157 | xhci_free_segments_for_ring(xhci, ring->first_seg); |
111 | while (seg != first_seg) { | 158 | |
112 | struct xhci_segment *next = seg->next; | ||
113 | xhci_segment_free(xhci, seg); | ||
114 | seg = next; | ||
115 | } | ||
116 | xhci_segment_free(xhci, first_seg); | ||
117 | ring->first_seg = NULL; | ||
118 | } | ||
119 | kfree(ring); | 159 | kfree(ring); |
120 | } | 160 | } |
121 | 161 | ||
122 | static void xhci_initialize_ring_info(struct xhci_ring *ring) | 162 | static void xhci_initialize_ring_info(struct xhci_ring *ring, |
163 | unsigned int cycle_state) | ||
123 | { | 164 | { |
124 | /* The ring is empty, so the enqueue pointer == dequeue pointer */ | 165 | /* The ring is empty, so the enqueue pointer == dequeue pointer */ |
125 | ring->enqueue = ring->first_seg->trbs; | 166 | ring->enqueue = ring->first_seg->trbs; |
@@ -129,11 +170,53 @@ static void xhci_initialize_ring_info(struct xhci_ring *ring) | |||
129 | /* The ring is initialized to 0. The producer must write 1 to the cycle | 170 | /* The ring is initialized to 0. The producer must write 1 to the cycle |
130 | * bit to handover ownership of the TRB, so PCS = 1. The consumer must | 171 | * bit to handover ownership of the TRB, so PCS = 1. The consumer must |
131 | * compare CCS to the cycle bit to check ownership, so CCS = 1. | 172 | * compare CCS to the cycle bit to check ownership, so CCS = 1. |
173 | * | ||
174 | * New rings are initialized with cycle state equal to 1; if we are | ||
175 | * handling ring expansion, set the cycle state equal to the old ring. | ||
132 | */ | 176 | */ |
133 | ring->cycle_state = 1; | 177 | ring->cycle_state = cycle_state; |
134 | /* Not necessary for new rings, but needed for re-initialized rings */ | 178 | /* Not necessary for new rings, but needed for re-initialized rings */ |
135 | ring->enq_updates = 0; | 179 | ring->enq_updates = 0; |
136 | ring->deq_updates = 0; | 180 | ring->deq_updates = 0; |
181 | |||
182 | /* | ||
183 | * Each segment has a link TRB, and leave an extra TRB for SW | ||
184 | * accounting purpose | ||
185 | */ | ||
186 | ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; | ||
187 | } | ||
188 | |||
189 | /* Allocate segments and link them for a ring */ | ||
190 | static int xhci_alloc_segments_for_ring(struct xhci_hcd *xhci, | ||
191 | struct xhci_segment **first, struct xhci_segment **last, | ||
192 | unsigned int num_segs, unsigned int cycle_state, | ||
193 | enum xhci_ring_type type, gfp_t flags) | ||
194 | { | ||
195 | struct xhci_segment *prev; | ||
196 | |||
197 | prev = xhci_segment_alloc(xhci, cycle_state, flags); | ||
198 | if (!prev) | ||
199 | return -ENOMEM; | ||
200 | num_segs--; | ||
201 | |||
202 | *first = prev; | ||
203 | while (num_segs > 0) { | ||
204 | struct xhci_segment *next; | ||
205 | |||
206 | next = xhci_segment_alloc(xhci, cycle_state, flags); | ||
207 | if (!next) { | ||
208 | xhci_free_segments_for_ring(xhci, *first); | ||
209 | return -ENOMEM; | ||
210 | } | ||
211 | xhci_link_segments(xhci, prev, next, type); | ||
212 | |||
213 | prev = next; | ||
214 | num_segs--; | ||
215 | } | ||
216 | xhci_link_segments(xhci, prev, *first, type); | ||
217 | *last = prev; | ||
218 | |||
219 | return 0; | ||
137 | } | 220 | } |
138 | 221 | ||
139 | /** | 222 | /** |
@@ -144,44 +227,34 @@ static void xhci_initialize_ring_info(struct xhci_ring *ring) | |||
144 | * See section 4.9.1 and figures 15 and 16. | 227 | * See section 4.9.1 and figures 15 and 16. |
145 | */ | 228 | */ |
146 | static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | 229 | static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, |
147 | unsigned int num_segs, bool link_trbs, bool isoc, gfp_t flags) | 230 | unsigned int num_segs, unsigned int cycle_state, |
231 | enum xhci_ring_type type, gfp_t flags) | ||
148 | { | 232 | { |
149 | struct xhci_ring *ring; | 233 | struct xhci_ring *ring; |
150 | struct xhci_segment *prev; | 234 | int ret; |
151 | 235 | ||
152 | ring = kzalloc(sizeof *(ring), flags); | 236 | ring = kzalloc(sizeof *(ring), flags); |
153 | if (!ring) | 237 | if (!ring) |
154 | return NULL; | 238 | return NULL; |
155 | 239 | ||
240 | ring->num_segs = num_segs; | ||
156 | INIT_LIST_HEAD(&ring->td_list); | 241 | INIT_LIST_HEAD(&ring->td_list); |
242 | ring->type = type; | ||
157 | if (num_segs == 0) | 243 | if (num_segs == 0) |
158 | return ring; | 244 | return ring; |
159 | 245 | ||
160 | ring->first_seg = xhci_segment_alloc(xhci, flags); | 246 | ret = xhci_alloc_segments_for_ring(xhci, &ring->first_seg, |
161 | if (!ring->first_seg) | 247 | &ring->last_seg, num_segs, cycle_state, type, flags); |
248 | if (ret) | ||
162 | goto fail; | 249 | goto fail; |
163 | num_segs--; | ||
164 | 250 | ||
165 | prev = ring->first_seg; | 251 | /* Only event ring does not use link TRB */ |
166 | while (num_segs > 0) { | 252 | if (type != TYPE_EVENT) { |
167 | struct xhci_segment *next; | ||
168 | |||
169 | next = xhci_segment_alloc(xhci, flags); | ||
170 | if (!next) | ||
171 | goto fail; | ||
172 | xhci_link_segments(xhci, prev, next, link_trbs, isoc); | ||
173 | |||
174 | prev = next; | ||
175 | num_segs--; | ||
176 | } | ||
177 | xhci_link_segments(xhci, prev, ring->first_seg, link_trbs, isoc); | ||
178 | |||
179 | if (link_trbs) { | ||
180 | /* See section 4.9.2.1 and 6.4.4.1 */ | 253 | /* See section 4.9.2.1 and 6.4.4.1 */ |
181 | prev->trbs[TRBS_PER_SEGMENT-1].link.control |= | 254 | ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= |
182 | cpu_to_le32(LINK_TOGGLE); | 255 | cpu_to_le32(LINK_TOGGLE); |
183 | } | 256 | } |
184 | xhci_initialize_ring_info(ring); | 257 | xhci_initialize_ring_info(ring, cycle_state); |
185 | return ring; | 258 | return ring; |
186 | 259 | ||
187 | fail: | 260 | fail: |
@@ -217,23 +290,64 @@ void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, | |||
217 | * pointers to the beginning of the ring. | 290 | * pointers to the beginning of the ring. |
218 | */ | 291 | */ |
219 | static void xhci_reinit_cached_ring(struct xhci_hcd *xhci, | 292 | static void xhci_reinit_cached_ring(struct xhci_hcd *xhci, |
220 | struct xhci_ring *ring, bool isoc) | 293 | struct xhci_ring *ring, unsigned int cycle_state, |
294 | enum xhci_ring_type type) | ||
221 | { | 295 | { |
222 | struct xhci_segment *seg = ring->first_seg; | 296 | struct xhci_segment *seg = ring->first_seg; |
297 | int i; | ||
298 | |||
223 | do { | 299 | do { |
224 | memset(seg->trbs, 0, | 300 | memset(seg->trbs, 0, |
225 | sizeof(union xhci_trb)*TRBS_PER_SEGMENT); | 301 | sizeof(union xhci_trb)*TRBS_PER_SEGMENT); |
302 | if (cycle_state == 0) { | ||
303 | for (i = 0; i < TRBS_PER_SEGMENT; i++) | ||
304 | seg->trbs[i].link.control |= TRB_CYCLE; | ||
305 | } | ||
226 | /* All endpoint rings have link TRBs */ | 306 | /* All endpoint rings have link TRBs */ |
227 | xhci_link_segments(xhci, seg, seg->next, 1, isoc); | 307 | xhci_link_segments(xhci, seg, seg->next, type); |
228 | seg = seg->next; | 308 | seg = seg->next; |
229 | } while (seg != ring->first_seg); | 309 | } while (seg != ring->first_seg); |
230 | xhci_initialize_ring_info(ring); | 310 | ring->type = type; |
311 | xhci_initialize_ring_info(ring, cycle_state); | ||
231 | /* td list should be empty since all URBs have been cancelled, | 312 | /* td list should be empty since all URBs have been cancelled, |
232 | * but just in case... | 313 | * but just in case... |
233 | */ | 314 | */ |
234 | INIT_LIST_HEAD(&ring->td_list); | 315 | INIT_LIST_HEAD(&ring->td_list); |
235 | } | 316 | } |
236 | 317 | ||
318 | /* | ||
319 | * Expand an existing ring. | ||
320 | * Look for a cached ring or allocate a new ring which has same segment numbers | ||
321 | * and link the two rings. | ||
322 | */ | ||
323 | int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, | ||
324 | unsigned int num_trbs, gfp_t flags) | ||
325 | { | ||
326 | struct xhci_segment *first; | ||
327 | struct xhci_segment *last; | ||
328 | unsigned int num_segs; | ||
329 | unsigned int num_segs_needed; | ||
330 | int ret; | ||
331 | |||
332 | num_segs_needed = (num_trbs + (TRBS_PER_SEGMENT - 1) - 1) / | ||
333 | (TRBS_PER_SEGMENT - 1); | ||
334 | |||
335 | /* Allocate number of segments we needed, or double the ring size */ | ||
336 | num_segs = ring->num_segs > num_segs_needed ? | ||
337 | ring->num_segs : num_segs_needed; | ||
338 | |||
339 | ret = xhci_alloc_segments_for_ring(xhci, &first, &last, | ||
340 | num_segs, ring->cycle_state, ring->type, flags); | ||
341 | if (ret) | ||
342 | return -ENOMEM; | ||
343 | |||
344 | xhci_link_rings(xhci, ring, first, last, num_segs); | ||
345 | xhci_dbg(xhci, "ring expansion succeed, now has %d segments\n", | ||
346 | ring->num_segs); | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
237 | #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) | 351 | #define CTX_SIZE(_hcc) (HCC_64BYTE_CONTEXT(_hcc) ? 64 : 32) |
238 | 352 | ||
239 | static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, | 353 | static struct xhci_container_ctx *xhci_alloc_container_ctx(struct xhci_hcd *xhci, |
@@ -528,7 +642,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
528 | */ | 642 | */ |
529 | for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { | 643 | for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { |
530 | stream_info->stream_rings[cur_stream] = | 644 | stream_info->stream_rings[cur_stream] = |
531 | xhci_ring_alloc(xhci, 1, true, false, mem_flags); | 645 | xhci_ring_alloc(xhci, 2, 1, TYPE_STREAM, mem_flags); |
532 | cur_ring = stream_info->stream_rings[cur_stream]; | 646 | cur_ring = stream_info->stream_rings[cur_stream]; |
533 | if (!cur_ring) | 647 | if (!cur_ring) |
534 | goto cleanup_rings; | 648 | goto cleanup_rings; |
@@ -862,7 +976,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, | |||
862 | } | 976 | } |
863 | 977 | ||
864 | /* Allocate endpoint 0 ring */ | 978 | /* Allocate endpoint 0 ring */ |
865 | dev->eps[0].ring = xhci_ring_alloc(xhci, 1, true, false, flags); | 979 | dev->eps[0].ring = xhci_ring_alloc(xhci, 2, 1, TYPE_CTRL, flags); |
866 | if (!dev->eps[0].ring) | 980 | if (!dev->eps[0].ring) |
867 | goto fail; | 981 | goto fail; |
868 | 982 | ||
@@ -1300,24 +1414,16 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, | |||
1300 | struct xhci_ring *ep_ring; | 1414 | struct xhci_ring *ep_ring; |
1301 | unsigned int max_packet; | 1415 | unsigned int max_packet; |
1302 | unsigned int max_burst; | 1416 | unsigned int max_burst; |
1417 | enum xhci_ring_type type; | ||
1303 | u32 max_esit_payload; | 1418 | u32 max_esit_payload; |
1304 | 1419 | ||
1305 | ep_index = xhci_get_endpoint_index(&ep->desc); | 1420 | ep_index = xhci_get_endpoint_index(&ep->desc); |
1306 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); | 1421 | ep_ctx = xhci_get_ep_ctx(xhci, virt_dev->in_ctx, ep_index); |
1307 | 1422 | ||
1423 | type = usb_endpoint_type(&ep->desc); | ||
1308 | /* Set up the endpoint ring */ | 1424 | /* Set up the endpoint ring */ |
1309 | /* | 1425 | virt_dev->eps[ep_index].new_ring = |
1310 | * Isochronous endpoint ring needs bigger size because one isoc URB | 1426 | xhci_ring_alloc(xhci, 2, 1, type, mem_flags); |
1311 | * carries multiple packets and it will insert multiple tds to the | ||
1312 | * ring. | ||
1313 | * This should be replaced with dynamic ring resizing in the future. | ||
1314 | */ | ||
1315 | if (usb_endpoint_xfer_isoc(&ep->desc)) | ||
1316 | virt_dev->eps[ep_index].new_ring = | ||
1317 | xhci_ring_alloc(xhci, 8, true, true, mem_flags); | ||
1318 | else | ||
1319 | virt_dev->eps[ep_index].new_ring = | ||
1320 | xhci_ring_alloc(xhci, 1, true, false, mem_flags); | ||
1321 | if (!virt_dev->eps[ep_index].new_ring) { | 1427 | if (!virt_dev->eps[ep_index].new_ring) { |
1322 | /* Attempt to use the ring cache */ | 1428 | /* Attempt to use the ring cache */ |
1323 | if (virt_dev->num_rings_cached == 0) | 1429 | if (virt_dev->num_rings_cached == 0) |
@@ -1327,7 +1433,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, | |||
1327 | virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL; | 1433 | virt_dev->ring_cache[virt_dev->num_rings_cached] = NULL; |
1328 | virt_dev->num_rings_cached--; | 1434 | virt_dev->num_rings_cached--; |
1329 | xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring, | 1435 | xhci_reinit_cached_ring(xhci, virt_dev->eps[ep_index].new_ring, |
1330 | usb_endpoint_xfer_isoc(&ep->desc) ? true : false); | 1436 | 1, type); |
1331 | } | 1437 | } |
1332 | virt_dev->eps[ep_index].skip = false; | 1438 | virt_dev->eps[ep_index].skip = false; |
1333 | ep_ring = virt_dev->eps[ep_index].new_ring; | 1439 | ep_ring = virt_dev->eps[ep_index].new_ring; |
@@ -2157,7 +2263,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2157 | unsigned int val, val2; | 2263 | unsigned int val, val2; |
2158 | u64 val_64; | 2264 | u64 val_64; |
2159 | struct xhci_segment *seg; | 2265 | struct xhci_segment *seg; |
2160 | u32 page_size; | 2266 | u32 page_size, temp; |
2161 | int i; | 2267 | int i; |
2162 | 2268 | ||
2163 | page_size = xhci_readl(xhci, &xhci->op_regs->page_size); | 2269 | page_size = xhci_readl(xhci, &xhci->op_regs->page_size); |
@@ -2235,7 +2341,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2235 | goto fail; | 2341 | goto fail; |
2236 | 2342 | ||
2237 | /* Set up the command ring to have one segments for now. */ | 2343 | /* Set up the command ring to have one segments for now. */ |
2238 | xhci->cmd_ring = xhci_ring_alloc(xhci, 1, true, false, flags); | 2344 | xhci->cmd_ring = xhci_ring_alloc(xhci, 1, 1, TYPE_COMMAND, flags); |
2239 | if (!xhci->cmd_ring) | 2345 | if (!xhci->cmd_ring) |
2240 | goto fail; | 2346 | goto fail; |
2241 | xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); | 2347 | xhci_dbg(xhci, "Allocated command ring at %p\n", xhci->cmd_ring); |
@@ -2266,7 +2372,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2266 | * the event ring segment table (ERST). Section 4.9.3. | 2372 | * the event ring segment table (ERST). Section 4.9.3. |
2267 | */ | 2373 | */ |
2268 | xhci_dbg(xhci, "// Allocating event ring\n"); | 2374 | xhci_dbg(xhci, "// Allocating event ring\n"); |
2269 | xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, false, false, | 2375 | xhci->event_ring = xhci_ring_alloc(xhci, ERST_NUM_SEGS, 1, TYPE_EVENT, |
2270 | flags); | 2376 | flags); |
2271 | if (!xhci->event_ring) | 2377 | if (!xhci->event_ring) |
2272 | goto fail; | 2378 | goto fail; |
@@ -2340,6 +2446,15 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2340 | 2446 | ||
2341 | INIT_LIST_HEAD(&xhci->lpm_failed_devs); | 2447 | INIT_LIST_HEAD(&xhci->lpm_failed_devs); |
2342 | 2448 | ||
2449 | /* Enable USB 3.0 device notifications for function remote wake, which | ||
2450 | * is necessary for allowing USB 3.0 devices to do remote wakeup from | ||
2451 | * U3 (device suspend). | ||
2452 | */ | ||
2453 | temp = xhci_readl(xhci, &xhci->op_regs->dev_notification); | ||
2454 | temp &= ~DEV_NOTE_MASK; | ||
2455 | temp |= DEV_NOTE_FWAKE; | ||
2456 | xhci_writel(xhci, temp, &xhci->op_regs->dev_notification); | ||
2457 | |||
2343 | return 0; | 2458 | return 0; |
2344 | 2459 | ||
2345 | fail: | 2460 | fail: |
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c new file mode 100644 index 000000000000..689bc18b051d --- /dev/null +++ b/drivers/usb/host/xhci-plat.c | |||
@@ -0,0 +1,205 @@ | |||
1 | /* | ||
2 | * xhci-plat.c - xHCI host controller driver platform Bus Glue. | ||
3 | * | ||
4 | * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> | ||
6 | * | ||
7 | * A lot of code borrowed from the Linux xHCI driver. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * version 2 as published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/slab.h> | ||
17 | |||
18 | #include "xhci.h" | ||
19 | |||
20 | static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) | ||
21 | { | ||
22 | /* | ||
23 | * As of now platform drivers don't provide MSI support so we ensure | ||
24 | * here that the generic code does not try to make a pci_dev from our | ||
25 | * dev struct in order to setup MSI | ||
26 | */ | ||
27 | xhci->quirks |= XHCI_BROKEN_MSI; | ||
28 | } | ||
29 | |||
30 | /* called during probe() after chip reset completes */ | ||
31 | static int xhci_plat_setup(struct usb_hcd *hcd) | ||
32 | { | ||
33 | return xhci_gen_setup(hcd, xhci_plat_quirks); | ||
34 | } | ||
35 | |||
36 | static const struct hc_driver xhci_plat_xhci_driver = { | ||
37 | .description = "xhci-hcd", | ||
38 | .product_desc = "xHCI Host Controller", | ||
39 | .hcd_priv_size = sizeof(struct xhci_hcd *), | ||
40 | |||
41 | /* | ||
42 | * generic hardware linkage | ||
43 | */ | ||
44 | .irq = xhci_irq, | ||
45 | .flags = HCD_MEMORY | HCD_USB3 | HCD_SHARED, | ||
46 | |||
47 | /* | ||
48 | * basic lifecycle operations | ||
49 | */ | ||
50 | .reset = xhci_plat_setup, | ||
51 | .start = xhci_run, | ||
52 | .stop = xhci_stop, | ||
53 | .shutdown = xhci_shutdown, | ||
54 | |||
55 | /* | ||
56 | * managing i/o requests and associated device resources | ||
57 | */ | ||
58 | .urb_enqueue = xhci_urb_enqueue, | ||
59 | .urb_dequeue = xhci_urb_dequeue, | ||
60 | .alloc_dev = xhci_alloc_dev, | ||
61 | .free_dev = xhci_free_dev, | ||
62 | .alloc_streams = xhci_alloc_streams, | ||
63 | .free_streams = xhci_free_streams, | ||
64 | .add_endpoint = xhci_add_endpoint, | ||
65 | .drop_endpoint = xhci_drop_endpoint, | ||
66 | .endpoint_reset = xhci_endpoint_reset, | ||
67 | .check_bandwidth = xhci_check_bandwidth, | ||
68 | .reset_bandwidth = xhci_reset_bandwidth, | ||
69 | .address_device = xhci_address_device, | ||
70 | .update_hub_device = xhci_update_hub_device, | ||
71 | .reset_device = xhci_discover_or_reset_device, | ||
72 | |||
73 | /* | ||
74 | * scheduling support | ||
75 | */ | ||
76 | .get_frame_number = xhci_get_frame, | ||
77 | |||
78 | /* Root hub support */ | ||
79 | .hub_control = xhci_hub_control, | ||
80 | .hub_status_data = xhci_hub_status_data, | ||
81 | .bus_suspend = xhci_bus_suspend, | ||
82 | .bus_resume = xhci_bus_resume, | ||
83 | }; | ||
84 | |||
85 | static int xhci_plat_probe(struct platform_device *pdev) | ||
86 | { | ||
87 | const struct hc_driver *driver; | ||
88 | struct xhci_hcd *xhci; | ||
89 | struct resource *res; | ||
90 | struct usb_hcd *hcd; | ||
91 | int ret; | ||
92 | int irq; | ||
93 | |||
94 | if (usb_disabled()) | ||
95 | return -ENODEV; | ||
96 | |||
97 | driver = &xhci_plat_xhci_driver; | ||
98 | |||
99 | irq = platform_get_irq(pdev, 0); | ||
100 | if (irq < 0) | ||
101 | return -ENODEV; | ||
102 | |||
103 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
104 | if (!res) | ||
105 | return -ENODEV; | ||
106 | |||
107 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | ||
108 | if (!hcd) | ||
109 | return -ENOMEM; | ||
110 | |||
111 | hcd->rsrc_start = res->start; | ||
112 | hcd->rsrc_len = resource_size(res); | ||
113 | |||
114 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, | ||
115 | driver->description)) { | ||
116 | dev_dbg(&pdev->dev, "controller already in use\n"); | ||
117 | ret = -EBUSY; | ||
118 | goto put_hcd; | ||
119 | } | ||
120 | |||
121 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); | ||
122 | if (!hcd->regs) { | ||
123 | dev_dbg(&pdev->dev, "error mapping memory\n"); | ||
124 | ret = -EFAULT; | ||
125 | goto release_mem_region; | ||
126 | } | ||
127 | |||
128 | ret = usb_add_hcd(hcd, irq, IRQF_SHARED); | ||
129 | if (ret) | ||
130 | goto unmap_registers; | ||
131 | |||
132 | /* USB 2.0 roothub is stored in the platform_device now. */ | ||
133 | hcd = dev_get_drvdata(&pdev->dev); | ||
134 | xhci = hcd_to_xhci(hcd); | ||
135 | xhci->shared_hcd = usb_create_shared_hcd(driver, &pdev->dev, | ||
136 | dev_name(&pdev->dev), hcd); | ||
137 | if (!xhci->shared_hcd) { | ||
138 | ret = -ENOMEM; | ||
139 | goto dealloc_usb2_hcd; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) | ||
144 | * is called by usb_add_hcd(). | ||
145 | */ | ||
146 | *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci; | ||
147 | |||
148 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); | ||
149 | if (ret) | ||
150 | goto put_usb3_hcd; | ||
151 | |||
152 | return 0; | ||
153 | |||
154 | put_usb3_hcd: | ||
155 | usb_put_hcd(xhci->shared_hcd); | ||
156 | |||
157 | dealloc_usb2_hcd: | ||
158 | usb_remove_hcd(hcd); | ||
159 | |||
160 | unmap_registers: | ||
161 | iounmap(hcd->regs); | ||
162 | |||
163 | release_mem_region: | ||
164 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); | ||
165 | |||
166 | put_hcd: | ||
167 | usb_put_hcd(hcd); | ||
168 | |||
169 | return ret; | ||
170 | } | ||
171 | |||
172 | static int xhci_plat_remove(struct platform_device *dev) | ||
173 | { | ||
174 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
175 | struct xhci_hcd *xhci = hcd_to_xhci(hcd); | ||
176 | |||
177 | usb_remove_hcd(xhci->shared_hcd); | ||
178 | usb_put_hcd(xhci->shared_hcd); | ||
179 | |||
180 | usb_remove_hcd(hcd); | ||
181 | iounmap(hcd->regs); | ||
182 | usb_put_hcd(hcd); | ||
183 | kfree(xhci); | ||
184 | |||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | static struct platform_driver usb_xhci_driver = { | ||
189 | .probe = xhci_plat_probe, | ||
190 | .remove = xhci_plat_remove, | ||
191 | .driver = { | ||
192 | .name = "xhci-hcd", | ||
193 | }, | ||
194 | }; | ||
195 | MODULE_ALIAS("platform:xhci-hcd"); | ||
196 | |||
197 | int xhci_register_plat(void) | ||
198 | { | ||
199 | return platform_driver_register(&usb_xhci_driver); | ||
200 | } | ||
201 | |||
202 | void xhci_unregister_plat(void) | ||
203 | { | ||
204 | platform_driver_unregister(&usb_xhci_driver); | ||
205 | } | ||
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index b62037bff688..6bd9d53062eb 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -143,17 +143,25 @@ static void next_trb(struct xhci_hcd *xhci, | |||
143 | * See Cycle bit rules. SW is the consumer for the event ring only. | 143 | * See Cycle bit rules. SW is the consumer for the event ring only. |
144 | * Don't make a ring full of link TRBs. That would be dumb and this would loop. | 144 | * Don't make a ring full of link TRBs. That would be dumb and this would loop. |
145 | */ | 145 | */ |
146 | static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer) | 146 | static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring) |
147 | { | 147 | { |
148 | union xhci_trb *next = ++(ring->dequeue); | 148 | union xhci_trb *next; |
149 | unsigned long long addr; | 149 | unsigned long long addr; |
150 | 150 | ||
151 | ring->deq_updates++; | 151 | ring->deq_updates++; |
152 | |||
153 | /* If this is not event ring, there is one more usable TRB */ | ||
154 | if (ring->type != TYPE_EVENT && | ||
155 | !last_trb(xhci, ring, ring->deq_seg, ring->dequeue)) | ||
156 | ring->num_trbs_free++; | ||
157 | next = ++(ring->dequeue); | ||
158 | |||
152 | /* Update the dequeue pointer further if that was a link TRB or we're at | 159 | /* Update the dequeue pointer further if that was a link TRB or we're at |
153 | * the end of an event ring segment (which doesn't have link TRBS) | 160 | * the end of an event ring segment (which doesn't have link TRBS) |
154 | */ | 161 | */ |
155 | while (last_trb(xhci, ring, ring->deq_seg, next)) { | 162 | while (last_trb(xhci, ring, ring->deq_seg, next)) { |
156 | if (consumer && last_trb_on_last_seg(xhci, ring, ring->deq_seg, next)) { | 163 | if (ring->type == TYPE_EVENT && last_trb_on_last_seg(xhci, |
164 | ring, ring->deq_seg, next)) { | ||
157 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 165 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
158 | } | 166 | } |
159 | ring->deq_seg = ring->deq_seg->next; | 167 | ring->deq_seg = ring->deq_seg->next; |
@@ -181,13 +189,17 @@ static void inc_deq(struct xhci_hcd *xhci, struct xhci_ring *ring, bool consumer | |||
181 | * prepare_transfer()? | 189 | * prepare_transfer()? |
182 | */ | 190 | */ |
183 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | 191 | static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, |
184 | bool consumer, bool more_trbs_coming, bool isoc) | 192 | bool more_trbs_coming) |
185 | { | 193 | { |
186 | u32 chain; | 194 | u32 chain; |
187 | union xhci_trb *next; | 195 | union xhci_trb *next; |
188 | unsigned long long addr; | 196 | unsigned long long addr; |
189 | 197 | ||
190 | chain = le32_to_cpu(ring->enqueue->generic.field[3]) & TRB_CHAIN; | 198 | chain = le32_to_cpu(ring->enqueue->generic.field[3]) & TRB_CHAIN; |
199 | /* If this is not event ring, there is one less usable TRB */ | ||
200 | if (ring->type != TYPE_EVENT && | ||
201 | !last_trb(xhci, ring, ring->enq_seg, ring->enqueue)) | ||
202 | ring->num_trbs_free--; | ||
191 | next = ++(ring->enqueue); | 203 | next = ++(ring->enqueue); |
192 | 204 | ||
193 | ring->enq_updates++; | 205 | ring->enq_updates++; |
@@ -195,35 +207,35 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
195 | * the end of an event ring segment (which doesn't have link TRBS) | 207 | * the end of an event ring segment (which doesn't have link TRBS) |
196 | */ | 208 | */ |
197 | while (last_trb(xhci, ring, ring->enq_seg, next)) { | 209 | while (last_trb(xhci, ring, ring->enq_seg, next)) { |
198 | if (!consumer) { | 210 | if (ring->type != TYPE_EVENT) { |
199 | if (ring != xhci->event_ring) { | 211 | /* |
200 | /* | 212 | * If the caller doesn't plan on enqueueing more |
201 | * If the caller doesn't plan on enqueueing more | 213 | * TDs before ringing the doorbell, then we |
202 | * TDs before ringing the doorbell, then we | 214 | * don't want to give the link TRB to the |
203 | * don't want to give the link TRB to the | 215 | * hardware just yet. We'll give the link TRB |
204 | * hardware just yet. We'll give the link TRB | 216 | * back in prepare_ring() just before we enqueue |
205 | * back in prepare_ring() just before we enqueue | 217 | * the TD at the top of the ring. |
206 | * the TD at the top of the ring. | 218 | */ |
207 | */ | 219 | if (!chain && !more_trbs_coming) |
208 | if (!chain && !more_trbs_coming) | 220 | break; |
209 | break; | ||
210 | 221 | ||
211 | /* If we're not dealing with 0.95 hardware or | 222 | /* If we're not dealing with 0.95 hardware or |
212 | * isoc rings on AMD 0.96 host, | 223 | * isoc rings on AMD 0.96 host, |
213 | * carry over the chain bit of the previous TRB | 224 | * carry over the chain bit of the previous TRB |
214 | * (which may mean the chain bit is cleared). | 225 | * (which may mean the chain bit is cleared). |
215 | */ | 226 | */ |
216 | if (!(isoc && (xhci->quirks & XHCI_AMD_0x96_HOST)) | 227 | if (!(ring->type == TYPE_ISOC && |
228 | (xhci->quirks & XHCI_AMD_0x96_HOST)) | ||
217 | && !xhci_link_trb_quirk(xhci)) { | 229 | && !xhci_link_trb_quirk(xhci)) { |
218 | next->link.control &= | 230 | next->link.control &= |
219 | cpu_to_le32(~TRB_CHAIN); | 231 | cpu_to_le32(~TRB_CHAIN); |
220 | next->link.control |= | 232 | next->link.control |= |
221 | cpu_to_le32(chain); | 233 | cpu_to_le32(chain); |
222 | } | ||
223 | /* Give this link TRB to the hardware */ | ||
224 | wmb(); | ||
225 | next->link.control ^= cpu_to_le32(TRB_CYCLE); | ||
226 | } | 234 | } |
235 | /* Give this link TRB to the hardware */ | ||
236 | wmb(); | ||
237 | next->link.control ^= cpu_to_le32(TRB_CYCLE); | ||
238 | |||
227 | /* Toggle the cycle bit after the last ring segment. */ | 239 | /* Toggle the cycle bit after the last ring segment. */ |
228 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { | 240 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { |
229 | ring->cycle_state = (ring->cycle_state ? 0 : 1); | 241 | ring->cycle_state = (ring->cycle_state ? 0 : 1); |
@@ -237,55 +249,23 @@ static void inc_enq(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
237 | } | 249 | } |
238 | 250 | ||
239 | /* | 251 | /* |
240 | * Check to see if there's room to enqueue num_trbs on the ring. See rules | 252 | * Check to see if there's room to enqueue num_trbs on the ring and make sure |
241 | * above. | 253 | * enqueue pointer will not advance into dequeue segment. See rules above. |
242 | * FIXME: this would be simpler and faster if we just kept track of the number | ||
243 | * of free TRBs in a ring. | ||
244 | */ | 254 | */ |
245 | static int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, | 255 | static inline int room_on_ring(struct xhci_hcd *xhci, struct xhci_ring *ring, |
246 | unsigned int num_trbs) | 256 | unsigned int num_trbs) |
247 | { | 257 | { |
248 | int i; | 258 | int num_trbs_in_deq_seg; |
249 | union xhci_trb *enq = ring->enqueue; | 259 | |
250 | struct xhci_segment *enq_seg = ring->enq_seg; | 260 | if (ring->num_trbs_free < num_trbs) |
251 | struct xhci_segment *cur_seg; | 261 | return 0; |
252 | unsigned int left_on_ring; | 262 | |
253 | 263 | if (ring->type != TYPE_COMMAND && ring->type != TYPE_EVENT) { | |
254 | /* If we are currently pointing to a link TRB, advance the | 264 | num_trbs_in_deq_seg = ring->dequeue - ring->deq_seg->trbs; |
255 | * enqueue pointer before checking for space */ | 265 | if (ring->num_trbs_free < num_trbs + num_trbs_in_deq_seg) |
256 | while (last_trb(xhci, ring, enq_seg, enq)) { | ||
257 | enq_seg = enq_seg->next; | ||
258 | enq = enq_seg->trbs; | ||
259 | } | ||
260 | |||
261 | /* Check if ring is empty */ | ||
262 | if (enq == ring->dequeue) { | ||
263 | /* Can't use link trbs */ | ||
264 | left_on_ring = TRBS_PER_SEGMENT - 1; | ||
265 | for (cur_seg = enq_seg->next; cur_seg != enq_seg; | ||
266 | cur_seg = cur_seg->next) | ||
267 | left_on_ring += TRBS_PER_SEGMENT - 1; | ||
268 | |||
269 | /* Always need one TRB free in the ring. */ | ||
270 | left_on_ring -= 1; | ||
271 | if (num_trbs > left_on_ring) { | ||
272 | xhci_warn(xhci, "Not enough room on ring; " | ||
273 | "need %u TRBs, %u TRBs left\n", | ||
274 | num_trbs, left_on_ring); | ||
275 | return 0; | ||
276 | } | ||
277 | return 1; | ||
278 | } | ||
279 | /* Make sure there's an extra empty TRB available */ | ||
280 | for (i = 0; i <= num_trbs; ++i) { | ||
281 | if (enq == ring->dequeue) | ||
282 | return 0; | 266 | return 0; |
283 | enq++; | ||
284 | while (last_trb(xhci, ring, enq_seg, enq)) { | ||
285 | enq_seg = enq_seg->next; | ||
286 | enq = enq_seg->trbs; | ||
287 | } | ||
288 | } | 267 | } |
268 | |||
289 | return 1; | 269 | return 1; |
290 | } | 270 | } |
291 | 271 | ||
@@ -892,6 +872,43 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
892 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); | 872 | xhci_dbg(xhci, "xHCI host controller is dead.\n"); |
893 | } | 873 | } |
894 | 874 | ||
875 | |||
876 | static void update_ring_for_set_deq_completion(struct xhci_hcd *xhci, | ||
877 | struct xhci_virt_device *dev, | ||
878 | struct xhci_ring *ep_ring, | ||
879 | unsigned int ep_index) | ||
880 | { | ||
881 | union xhci_trb *dequeue_temp; | ||
882 | int num_trbs_free_temp; | ||
883 | bool revert = false; | ||
884 | |||
885 | num_trbs_free_temp = ep_ring->num_trbs_free; | ||
886 | dequeue_temp = ep_ring->dequeue; | ||
887 | |||
888 | while (ep_ring->dequeue != dev->eps[ep_index].queued_deq_ptr) { | ||
889 | /* We have more usable TRBs */ | ||
890 | ep_ring->num_trbs_free++; | ||
891 | ep_ring->dequeue++; | ||
892 | if (last_trb(xhci, ep_ring, ep_ring->deq_seg, | ||
893 | ep_ring->dequeue)) { | ||
894 | if (ep_ring->dequeue == | ||
895 | dev->eps[ep_index].queued_deq_ptr) | ||
896 | break; | ||
897 | ep_ring->deq_seg = ep_ring->deq_seg->next; | ||
898 | ep_ring->dequeue = ep_ring->deq_seg->trbs; | ||
899 | } | ||
900 | if (ep_ring->dequeue == dequeue_temp) { | ||
901 | revert = true; | ||
902 | break; | ||
903 | } | ||
904 | } | ||
905 | |||
906 | if (revert) { | ||
907 | xhci_dbg(xhci, "Unable to find new dequeue pointer\n"); | ||
908 | ep_ring->num_trbs_free = num_trbs_free_temp; | ||
909 | } | ||
910 | } | ||
911 | |||
895 | /* | 912 | /* |
896 | * When we get a completion for a Set Transfer Ring Dequeue Pointer command, | 913 | * When we get a completion for a Set Transfer Ring Dequeue Pointer command, |
897 | * we need to clear the set deq pending flag in the endpoint ring state, so that | 914 | * we need to clear the set deq pending flag in the endpoint ring state, so that |
@@ -973,8 +990,8 @@ static void handle_set_deq_completion(struct xhci_hcd *xhci, | |||
973 | /* Update the ring's dequeue segment and dequeue pointer | 990 | /* Update the ring's dequeue segment and dequeue pointer |
974 | * to reflect the new position. | 991 | * to reflect the new position. |
975 | */ | 992 | */ |
976 | ep_ring->deq_seg = dev->eps[ep_index].queued_deq_seg; | 993 | update_ring_for_set_deq_completion(xhci, dev, |
977 | ep_ring->dequeue = dev->eps[ep_index].queued_deq_ptr; | 994 | ep_ring, ep_index); |
978 | } else { | 995 | } else { |
979 | xhci_warn(xhci, "Mismatch between completed Set TR Deq " | 996 | xhci_warn(xhci, "Mismatch between completed Set TR Deq " |
980 | "Ptr command & xHCI internal state.\n"); | 997 | "Ptr command & xHCI internal state.\n"); |
@@ -1185,7 +1202,7 @@ bandwidth_change: | |||
1185 | xhci->error_bitmask |= 1 << 6; | 1202 | xhci->error_bitmask |= 1 << 6; |
1186 | break; | 1203 | break; |
1187 | } | 1204 | } |
1188 | inc_deq(xhci, xhci->cmd_ring, false); | 1205 | inc_deq(xhci, xhci->cmd_ring); |
1189 | } | 1206 | } |
1190 | 1207 | ||
1191 | static void handle_vendor_event(struct xhci_hcd *xhci, | 1208 | static void handle_vendor_event(struct xhci_hcd *xhci, |
@@ -1237,6 +1254,26 @@ static unsigned int find_faked_portnum_from_hw_portnum(struct usb_hcd *hcd, | |||
1237 | return num_similar_speed_ports; | 1254 | return num_similar_speed_ports; |
1238 | } | 1255 | } |
1239 | 1256 | ||
1257 | static void handle_device_notification(struct xhci_hcd *xhci, | ||
1258 | union xhci_trb *event) | ||
1259 | { | ||
1260 | u32 slot_id; | ||
1261 | struct usb_device *udev; | ||
1262 | |||
1263 | slot_id = TRB_TO_SLOT_ID(event->generic.field[3]); | ||
1264 | if (!xhci->devs[slot_id]) { | ||
1265 | xhci_warn(xhci, "Device Notification event for " | ||
1266 | "unused slot %u\n", slot_id); | ||
1267 | return; | ||
1268 | } | ||
1269 | |||
1270 | xhci_dbg(xhci, "Device Wake Notification event for slot ID %u\n", | ||
1271 | slot_id); | ||
1272 | udev = xhci->devs[slot_id]->udev; | ||
1273 | if (udev && udev->parent) | ||
1274 | usb_wakeup_notification(udev->parent, udev->portnum); | ||
1275 | } | ||
1276 | |||
1240 | static void handle_port_status(struct xhci_hcd *xhci, | 1277 | static void handle_port_status(struct xhci_hcd *xhci, |
1241 | union xhci_trb *event) | 1278 | union xhci_trb *event) |
1242 | { | 1279 | { |
@@ -1321,20 +1358,21 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1321 | } | 1358 | } |
1322 | 1359 | ||
1323 | if (DEV_SUPERSPEED(temp)) { | 1360 | if (DEV_SUPERSPEED(temp)) { |
1324 | xhci_dbg(xhci, "resume SS port %d\n", port_id); | 1361 | xhci_dbg(xhci, "remote wake SS port %d\n", port_id); |
1362 | /* Set a flag to say the port signaled remote wakeup, | ||
1363 | * so we can tell the difference between the end of | ||
1364 | * device and host initiated resume. | ||
1365 | */ | ||
1366 | bus_state->port_remote_wakeup |= 1 << faked_port_index; | ||
1367 | xhci_test_and_clear_bit(xhci, port_array, | ||
1368 | faked_port_index, PORT_PLC); | ||
1325 | xhci_set_link_state(xhci, port_array, faked_port_index, | 1369 | xhci_set_link_state(xhci, port_array, faked_port_index, |
1326 | XDEV_U0); | 1370 | XDEV_U0); |
1327 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | 1371 | /* Need to wait until the next link state change |
1328 | faked_port_index + 1); | 1372 | * indicates the device is actually in U0. |
1329 | if (!slot_id) { | 1373 | */ |
1330 | xhci_dbg(xhci, "slot_id is zero\n"); | 1374 | bogus_port_status = true; |
1331 | goto cleanup; | 1375 | goto cleanup; |
1332 | } | ||
1333 | xhci_ring_device(xhci, slot_id); | ||
1334 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | ||
1335 | /* Clear PORT_PLC */ | ||
1336 | xhci_test_and_clear_bit(xhci, port_array, | ||
1337 | faked_port_index, PORT_PLC); | ||
1338 | } else { | 1376 | } else { |
1339 | xhci_dbg(xhci, "resume HS port %d\n", port_id); | 1377 | xhci_dbg(xhci, "resume HS port %d\n", port_id); |
1340 | bus_state->resume_done[faked_port_index] = jiffies + | 1378 | bus_state->resume_done[faked_port_index] = jiffies + |
@@ -1345,13 +1383,39 @@ static void handle_port_status(struct xhci_hcd *xhci, | |||
1345 | } | 1383 | } |
1346 | } | 1384 | } |
1347 | 1385 | ||
1386 | if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_U0 && | ||
1387 | DEV_SUPERSPEED(temp)) { | ||
1388 | xhci_dbg(xhci, "resume SS port %d finished\n", port_id); | ||
1389 | /* We've just brought the device into U0 through either the | ||
1390 | * Resume state after a device remote wakeup, or through the | ||
1391 | * U3Exit state after a host-initiated resume. If it's a device | ||
1392 | * initiated remote wake, don't pass up the link state change, | ||
1393 | * so the roothub behavior is consistent with external | ||
1394 | * USB 3.0 hub behavior. | ||
1395 | */ | ||
1396 | slot_id = xhci_find_slot_id_by_port(hcd, xhci, | ||
1397 | faked_port_index + 1); | ||
1398 | if (slot_id && xhci->devs[slot_id]) | ||
1399 | xhci_ring_device(xhci, slot_id); | ||
1400 | if (bus_state->port_remote_wakeup && (1 << faked_port_index)) { | ||
1401 | bus_state->port_remote_wakeup &= | ||
1402 | ~(1 << faked_port_index); | ||
1403 | xhci_test_and_clear_bit(xhci, port_array, | ||
1404 | faked_port_index, PORT_PLC); | ||
1405 | usb_wakeup_notification(hcd->self.root_hub, | ||
1406 | faked_port_index + 1); | ||
1407 | bogus_port_status = true; | ||
1408 | goto cleanup; | ||
1409 | } | ||
1410 | } | ||
1411 | |||
1348 | if (hcd->speed != HCD_USB3) | 1412 | if (hcd->speed != HCD_USB3) |
1349 | xhci_test_and_clear_bit(xhci, port_array, faked_port_index, | 1413 | xhci_test_and_clear_bit(xhci, port_array, faked_port_index, |
1350 | PORT_PLC); | 1414 | PORT_PLC); |
1351 | 1415 | ||
1352 | cleanup: | 1416 | cleanup: |
1353 | /* Update event ring dequeue pointer before dropping the lock */ | 1417 | /* Update event ring dequeue pointer before dropping the lock */ |
1354 | inc_deq(xhci, xhci->event_ring, true); | 1418 | inc_deq(xhci, xhci->event_ring); |
1355 | 1419 | ||
1356 | /* Don't make the USB core poll the roothub if we got a bad port status | 1420 | /* Don't make the USB core poll the roothub if we got a bad port status |
1357 | * change event. Besides, at that point we can't tell which roothub | 1421 | * change event. Besides, at that point we can't tell which roothub |
@@ -1546,8 +1610,8 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1546 | } else { | 1610 | } else { |
1547 | /* Update ring dequeue pointer */ | 1611 | /* Update ring dequeue pointer */ |
1548 | while (ep_ring->dequeue != td->last_trb) | 1612 | while (ep_ring->dequeue != td->last_trb) |
1549 | inc_deq(xhci, ep_ring, false); | 1613 | inc_deq(xhci, ep_ring); |
1550 | inc_deq(xhci, ep_ring, false); | 1614 | inc_deq(xhci, ep_ring); |
1551 | } | 1615 | } |
1552 | 1616 | ||
1553 | td_cleanup: | 1617 | td_cleanup: |
@@ -1795,8 +1859,8 @@ static int skip_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1795 | 1859 | ||
1796 | /* Update ring dequeue pointer */ | 1860 | /* Update ring dequeue pointer */ |
1797 | while (ep_ring->dequeue != td->last_trb) | 1861 | while (ep_ring->dequeue != td->last_trb) |
1798 | inc_deq(xhci, ep_ring, false); | 1862 | inc_deq(xhci, ep_ring); |
1799 | inc_deq(xhci, ep_ring, false); | 1863 | inc_deq(xhci, ep_ring); |
1800 | 1864 | ||
1801 | return finish_td(xhci, td, NULL, event, ep, status, true); | 1865 | return finish_td(xhci, td, NULL, event, ep, status, true); |
1802 | } | 1866 | } |
@@ -2183,7 +2247,7 @@ cleanup: | |||
2183 | * Will roll back to continue process missed tds. | 2247 | * Will roll back to continue process missed tds. |
2184 | */ | 2248 | */ |
2185 | if (trb_comp_code == COMP_MISSED_INT || !ep->skip) { | 2249 | if (trb_comp_code == COMP_MISSED_INT || !ep->skip) { |
2186 | inc_deq(xhci, xhci->event_ring, true); | 2250 | inc_deq(xhci, xhci->event_ring); |
2187 | } | 2251 | } |
2188 | 2252 | ||
2189 | if (ret) { | 2253 | if (ret) { |
@@ -2277,6 +2341,9 @@ static int xhci_handle_event(struct xhci_hcd *xhci) | |||
2277 | else | 2341 | else |
2278 | update_ptrs = 0; | 2342 | update_ptrs = 0; |
2279 | break; | 2343 | break; |
2344 | case TRB_TYPE(TRB_DEV_NOTE): | ||
2345 | handle_device_notification(xhci, event); | ||
2346 | break; | ||
2280 | default: | 2347 | default: |
2281 | if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >= | 2348 | if ((le32_to_cpu(event->event_cmd.flags) & TRB_TYPE_BITMASK) >= |
2282 | TRB_TYPE(48)) | 2349 | TRB_TYPE(48)) |
@@ -2295,7 +2362,7 @@ static int xhci_handle_event(struct xhci_hcd *xhci) | |||
2295 | 2362 | ||
2296 | if (update_ptrs) | 2363 | if (update_ptrs) |
2297 | /* Update SW event ring dequeue pointer */ | 2364 | /* Update SW event ring dequeue pointer */ |
2298 | inc_deq(xhci, xhci->event_ring, true); | 2365 | inc_deq(xhci, xhci->event_ring); |
2299 | 2366 | ||
2300 | /* Are there more items on the event ring? Caller will call us again to | 2367 | /* Are there more items on the event ring? Caller will call us again to |
2301 | * check. | 2368 | * check. |
@@ -2346,7 +2413,7 @@ hw_died: | |||
2346 | /* FIXME when MSI-X is supported and there are multiple vectors */ | 2413 | /* FIXME when MSI-X is supported and there are multiple vectors */ |
2347 | /* Clear the MSI-X event interrupt status */ | 2414 | /* Clear the MSI-X event interrupt status */ |
2348 | 2415 | ||
2349 | if (hcd->irq != -1) { | 2416 | if (hcd->irq) { |
2350 | u32 irq_pending; | 2417 | u32 irq_pending; |
2351 | /* Acknowledge the PCI interrupt */ | 2418 | /* Acknowledge the PCI interrupt */ |
2352 | irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); | 2419 | irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending); |
@@ -2411,7 +2478,7 @@ irqreturn_t xhci_msi_irq(int irq, struct usb_hcd *hcd) | |||
2411 | * prepare_transfer()? | 2478 | * prepare_transfer()? |
2412 | */ | 2479 | */ |
2413 | static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | 2480 | static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, |
2414 | bool consumer, bool more_trbs_coming, bool isoc, | 2481 | bool more_trbs_coming, |
2415 | u32 field1, u32 field2, u32 field3, u32 field4) | 2482 | u32 field1, u32 field2, u32 field3, u32 field4) |
2416 | { | 2483 | { |
2417 | struct xhci_generic_trb *trb; | 2484 | struct xhci_generic_trb *trb; |
@@ -2421,7 +2488,7 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
2421 | trb->field[1] = cpu_to_le32(field2); | 2488 | trb->field[1] = cpu_to_le32(field2); |
2422 | trb->field[2] = cpu_to_le32(field3); | 2489 | trb->field[2] = cpu_to_le32(field3); |
2423 | trb->field[3] = cpu_to_le32(field4); | 2490 | trb->field[3] = cpu_to_le32(field4); |
2424 | inc_enq(xhci, ring, consumer, more_trbs_coming, isoc); | 2491 | inc_enq(xhci, ring, more_trbs_coming); |
2425 | } | 2492 | } |
2426 | 2493 | ||
2427 | /* | 2494 | /* |
@@ -2429,8 +2496,10 @@ static void queue_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
2429 | * FIXME allocate segments if the ring is full. | 2496 | * FIXME allocate segments if the ring is full. |
2430 | */ | 2497 | */ |
2431 | static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | 2498 | static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, |
2432 | u32 ep_state, unsigned int num_trbs, bool isoc, gfp_t mem_flags) | 2499 | u32 ep_state, unsigned int num_trbs, gfp_t mem_flags) |
2433 | { | 2500 | { |
2501 | unsigned int num_trbs_needed; | ||
2502 | |||
2434 | /* Make sure the endpoint has been added to xHC schedule */ | 2503 | /* Make sure the endpoint has been added to xHC schedule */ |
2435 | switch (ep_state) { | 2504 | switch (ep_state) { |
2436 | case EP_STATE_DISABLED: | 2505 | case EP_STATE_DISABLED: |
@@ -2458,11 +2527,25 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2458 | */ | 2527 | */ |
2459 | return -EINVAL; | 2528 | return -EINVAL; |
2460 | } | 2529 | } |
2461 | if (!room_on_ring(xhci, ep_ring, num_trbs)) { | 2530 | |
2462 | /* FIXME allocate more room */ | 2531 | while (1) { |
2463 | xhci_err(xhci, "ERROR no room on ep ring\n"); | 2532 | if (room_on_ring(xhci, ep_ring, num_trbs)) |
2464 | return -ENOMEM; | 2533 | break; |
2465 | } | 2534 | |
2535 | if (ep_ring == xhci->cmd_ring) { | ||
2536 | xhci_err(xhci, "Do not support expand command ring\n"); | ||
2537 | return -ENOMEM; | ||
2538 | } | ||
2539 | |||
2540 | xhci_dbg(xhci, "ERROR no room on ep ring, " | ||
2541 | "try ring expansion\n"); | ||
2542 | num_trbs_needed = num_trbs - ep_ring->num_trbs_free; | ||
2543 | if (xhci_ring_expansion(xhci, ep_ring, num_trbs_needed, | ||
2544 | mem_flags)) { | ||
2545 | xhci_err(xhci, "Ring expansion failed\n"); | ||
2546 | return -ENOMEM; | ||
2547 | } | ||
2548 | }; | ||
2466 | 2549 | ||
2467 | if (enqueue_is_link_trb(ep_ring)) { | 2550 | if (enqueue_is_link_trb(ep_ring)) { |
2468 | struct xhci_ring *ring = ep_ring; | 2551 | struct xhci_ring *ring = ep_ring; |
@@ -2474,8 +2557,9 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2474 | /* If we're not dealing with 0.95 hardware or isoc rings | 2557 | /* If we're not dealing with 0.95 hardware or isoc rings |
2475 | * on AMD 0.96 host, clear the chain bit. | 2558 | * on AMD 0.96 host, clear the chain bit. |
2476 | */ | 2559 | */ |
2477 | if (!xhci_link_trb_quirk(xhci) && !(isoc && | 2560 | if (!xhci_link_trb_quirk(xhci) && |
2478 | (xhci->quirks & XHCI_AMD_0x96_HOST))) | 2561 | !(ring->type == TYPE_ISOC && |
2562 | (xhci->quirks & XHCI_AMD_0x96_HOST))) | ||
2479 | next->link.control &= cpu_to_le32(~TRB_CHAIN); | 2563 | next->link.control &= cpu_to_le32(~TRB_CHAIN); |
2480 | else | 2564 | else |
2481 | next->link.control |= cpu_to_le32(TRB_CHAIN); | 2565 | next->link.control |= cpu_to_le32(TRB_CHAIN); |
@@ -2503,7 +2587,6 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
2503 | unsigned int num_trbs, | 2587 | unsigned int num_trbs, |
2504 | struct urb *urb, | 2588 | struct urb *urb, |
2505 | unsigned int td_index, | 2589 | unsigned int td_index, |
2506 | bool isoc, | ||
2507 | gfp_t mem_flags) | 2590 | gfp_t mem_flags) |
2508 | { | 2591 | { |
2509 | int ret; | 2592 | int ret; |
@@ -2521,7 +2604,7 @@ static int prepare_transfer(struct xhci_hcd *xhci, | |||
2521 | 2604 | ||
2522 | ret = prepare_ring(xhci, ep_ring, | 2605 | ret = prepare_ring(xhci, ep_ring, |
2523 | le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, | 2606 | le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, |
2524 | num_trbs, isoc, mem_flags); | 2607 | num_trbs, mem_flags); |
2525 | if (ret) | 2608 | if (ret) |
2526 | return ret; | 2609 | return ret; |
2527 | 2610 | ||
@@ -2731,7 +2814,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2731 | 2814 | ||
2732 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], | 2815 | trb_buff_len = prepare_transfer(xhci, xhci->devs[slot_id], |
2733 | ep_index, urb->stream_id, | 2816 | ep_index, urb->stream_id, |
2734 | num_trbs, urb, 0, false, mem_flags); | 2817 | num_trbs, urb, 0, mem_flags); |
2735 | if (trb_buff_len < 0) | 2818 | if (trb_buff_len < 0) |
2736 | return trb_buff_len; | 2819 | return trb_buff_len; |
2737 | 2820 | ||
@@ -2819,7 +2902,7 @@ static int queue_bulk_sg_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2819 | more_trbs_coming = true; | 2902 | more_trbs_coming = true; |
2820 | else | 2903 | else |
2821 | more_trbs_coming = false; | 2904 | more_trbs_coming = false; |
2822 | queue_trb(xhci, ep_ring, false, more_trbs_coming, false, | 2905 | queue_trb(xhci, ep_ring, more_trbs_coming, |
2823 | lower_32_bits(addr), | 2906 | lower_32_bits(addr), |
2824 | upper_32_bits(addr), | 2907 | upper_32_bits(addr), |
2825 | length_field, | 2908 | length_field, |
@@ -2901,7 +2984,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2901 | 2984 | ||
2902 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 2985 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
2903 | ep_index, urb->stream_id, | 2986 | ep_index, urb->stream_id, |
2904 | num_trbs, urb, 0, false, mem_flags); | 2987 | num_trbs, urb, 0, mem_flags); |
2905 | if (ret < 0) | 2988 | if (ret < 0) |
2906 | return ret; | 2989 | return ret; |
2907 | 2990 | ||
@@ -2973,7 +3056,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
2973 | more_trbs_coming = true; | 3056 | more_trbs_coming = true; |
2974 | else | 3057 | else |
2975 | more_trbs_coming = false; | 3058 | more_trbs_coming = false; |
2976 | queue_trb(xhci, ep_ring, false, more_trbs_coming, false, | 3059 | queue_trb(xhci, ep_ring, more_trbs_coming, |
2977 | lower_32_bits(addr), | 3060 | lower_32_bits(addr), |
2978 | upper_32_bits(addr), | 3061 | upper_32_bits(addr), |
2979 | length_field, | 3062 | length_field, |
@@ -3030,7 +3113,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3030 | num_trbs++; | 3113 | num_trbs++; |
3031 | ret = prepare_transfer(xhci, xhci->devs[slot_id], | 3114 | ret = prepare_transfer(xhci, xhci->devs[slot_id], |
3032 | ep_index, urb->stream_id, | 3115 | ep_index, urb->stream_id, |
3033 | num_trbs, urb, 0, false, mem_flags); | 3116 | num_trbs, urb, 0, mem_flags); |
3034 | if (ret < 0) | 3117 | if (ret < 0) |
3035 | return ret; | 3118 | return ret; |
3036 | 3119 | ||
@@ -3063,7 +3146,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3063 | } | 3146 | } |
3064 | } | 3147 | } |
3065 | 3148 | ||
3066 | queue_trb(xhci, ep_ring, false, true, false, | 3149 | queue_trb(xhci, ep_ring, true, |
3067 | setup->bRequestType | setup->bRequest << 8 | le16_to_cpu(setup->wValue) << 16, | 3150 | setup->bRequestType | setup->bRequest << 8 | le16_to_cpu(setup->wValue) << 16, |
3068 | le16_to_cpu(setup->wIndex) | le16_to_cpu(setup->wLength) << 16, | 3151 | le16_to_cpu(setup->wIndex) | le16_to_cpu(setup->wLength) << 16, |
3069 | TRB_LEN(8) | TRB_INTR_TARGET(0), | 3152 | TRB_LEN(8) | TRB_INTR_TARGET(0), |
@@ -3083,7 +3166,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3083 | if (urb->transfer_buffer_length > 0) { | 3166 | if (urb->transfer_buffer_length > 0) { |
3084 | if (setup->bRequestType & USB_DIR_IN) | 3167 | if (setup->bRequestType & USB_DIR_IN) |
3085 | field |= TRB_DIR_IN; | 3168 | field |= TRB_DIR_IN; |
3086 | queue_trb(xhci, ep_ring, false, true, false, | 3169 | queue_trb(xhci, ep_ring, true, |
3087 | lower_32_bits(urb->transfer_dma), | 3170 | lower_32_bits(urb->transfer_dma), |
3088 | upper_32_bits(urb->transfer_dma), | 3171 | upper_32_bits(urb->transfer_dma), |
3089 | length_field, | 3172 | length_field, |
@@ -3099,7 +3182,7 @@ int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3099 | field = 0; | 3182 | field = 0; |
3100 | else | 3183 | else |
3101 | field = TRB_DIR_IN; | 3184 | field = TRB_DIR_IN; |
3102 | queue_trb(xhci, ep_ring, false, false, false, | 3185 | queue_trb(xhci, ep_ring, false, |
3103 | 0, | 3186 | 0, |
3104 | 0, | 3187 | 0, |
3105 | TRB_INTR_TARGET(0), | 3188 | TRB_INTR_TARGET(0), |
@@ -3239,8 +3322,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3239 | trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); | 3322 | trbs_per_td = count_isoc_trbs_needed(xhci, urb, i); |
3240 | 3323 | ||
3241 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, | 3324 | ret = prepare_transfer(xhci, xhci->devs[slot_id], ep_index, |
3242 | urb->stream_id, trbs_per_td, urb, i, true, | 3325 | urb->stream_id, trbs_per_td, urb, i, mem_flags); |
3243 | mem_flags); | ||
3244 | if (ret < 0) { | 3326 | if (ret < 0) { |
3245 | if (i == 0) | 3327 | if (i == 0) |
3246 | return ret; | 3328 | return ret; |
@@ -3310,7 +3392,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3310 | remainder | | 3392 | remainder | |
3311 | TRB_INTR_TARGET(0); | 3393 | TRB_INTR_TARGET(0); |
3312 | 3394 | ||
3313 | queue_trb(xhci, ep_ring, false, more_trbs_coming, true, | 3395 | queue_trb(xhci, ep_ring, more_trbs_coming, |
3314 | lower_32_bits(addr), | 3396 | lower_32_bits(addr), |
3315 | upper_32_bits(addr), | 3397 | upper_32_bits(addr), |
3316 | length_field, | 3398 | length_field, |
@@ -3357,6 +3439,7 @@ cleanup: | |||
3357 | ep_ring->enqueue = urb_priv->td[0]->first_trb; | 3439 | ep_ring->enqueue = urb_priv->td[0]->first_trb; |
3358 | ep_ring->enq_seg = urb_priv->td[0]->start_seg; | 3440 | ep_ring->enq_seg = urb_priv->td[0]->start_seg; |
3359 | ep_ring->cycle_state = start_cycle; | 3441 | ep_ring->cycle_state = start_cycle; |
3442 | ep_ring->num_trbs_free = ep_ring->num_trbs_free_temp; | ||
3360 | usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); | 3443 | usb_hcd_unlink_urb_from_ep(bus_to_hcd(urb->dev->bus), urb); |
3361 | return ret; | 3444 | return ret; |
3362 | } | 3445 | } |
@@ -3393,7 +3476,7 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3393 | * Do not insert any td of the urb to the ring if the check failed. | 3476 | * Do not insert any td of the urb to the ring if the check failed. |
3394 | */ | 3477 | */ |
3395 | ret = prepare_ring(xhci, ep_ring, le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, | 3478 | ret = prepare_ring(xhci, ep_ring, le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK, |
3396 | num_trbs, true, mem_flags); | 3479 | num_trbs, mem_flags); |
3397 | if (ret) | 3480 | if (ret) |
3398 | return ret; | 3481 | return ret; |
3399 | 3482 | ||
@@ -3429,6 +3512,8 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags, | |||
3429 | urb->dev->speed == USB_SPEED_FULL) | 3512 | urb->dev->speed == USB_SPEED_FULL) |
3430 | urb->interval /= 8; | 3513 | urb->interval /= 8; |
3431 | } | 3514 | } |
3515 | ep_ring->num_trbs_free_temp = ep_ring->num_trbs_free; | ||
3516 | |||
3432 | return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); | 3517 | return xhci_queue_isoc_tx(xhci, GFP_ATOMIC, urb, slot_id, ep_index); |
3433 | } | 3518 | } |
3434 | 3519 | ||
@@ -3452,7 +3537,7 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, | |||
3452 | reserved_trbs++; | 3537 | reserved_trbs++; |
3453 | 3538 | ||
3454 | ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING, | 3539 | ret = prepare_ring(xhci, xhci->cmd_ring, EP_STATE_RUNNING, |
3455 | reserved_trbs, false, GFP_ATOMIC); | 3540 | reserved_trbs, GFP_ATOMIC); |
3456 | if (ret < 0) { | 3541 | if (ret < 0) { |
3457 | xhci_err(xhci, "ERR: No room for command on command ring\n"); | 3542 | xhci_err(xhci, "ERR: No room for command on command ring\n"); |
3458 | if (command_must_succeed) | 3543 | if (command_must_succeed) |
@@ -3460,8 +3545,8 @@ static int queue_command(struct xhci_hcd *xhci, u32 field1, u32 field2, | |||
3460 | "unfailable commands failed.\n"); | 3545 | "unfailable commands failed.\n"); |
3461 | return ret; | 3546 | return ret; |
3462 | } | 3547 | } |
3463 | queue_trb(xhci, xhci->cmd_ring, false, false, false, field1, field2, | 3548 | queue_trb(xhci, xhci->cmd_ring, false, field1, field2, field3, |
3464 | field3, field4 | xhci->cmd_ring->cycle_state); | 3549 | field4 | xhci->cmd_ring->cycle_state); |
3465 | return 0; | 3550 | return 0; |
3466 | } | 3551 | } |
3467 | 3552 | ||
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c939f5fdef9e..e1963d4a430f 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -224,13 +224,13 @@ static void xhci_free_irq(struct xhci_hcd *xhci) | |||
224 | int ret; | 224 | int ret; |
225 | 225 | ||
226 | /* return if using legacy interrupt */ | 226 | /* return if using legacy interrupt */ |
227 | if (xhci_to_hcd(xhci)->irq >= 0) | 227 | if (xhci_to_hcd(xhci)->irq > 0) |
228 | return; | 228 | return; |
229 | 229 | ||
230 | ret = xhci_free_msi(xhci); | 230 | ret = xhci_free_msi(xhci); |
231 | if (!ret) | 231 | if (!ret) |
232 | return; | 232 | return; |
233 | if (pdev->irq >= 0) | 233 | if (pdev->irq > 0) |
234 | free_irq(pdev->irq, xhci_to_hcd(xhci)); | 234 | free_irq(pdev->irq, xhci_to_hcd(xhci)); |
235 | 235 | ||
236 | return; | 236 | return; |
@@ -341,7 +341,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) | |||
341 | /* unregister the legacy interrupt */ | 341 | /* unregister the legacy interrupt */ |
342 | if (hcd->irq) | 342 | if (hcd->irq) |
343 | free_irq(hcd->irq, hcd); | 343 | free_irq(hcd->irq, hcd); |
344 | hcd->irq = -1; | 344 | hcd->irq = 0; |
345 | 345 | ||
346 | ret = xhci_setup_msix(xhci); | 346 | ret = xhci_setup_msix(xhci); |
347 | if (ret) | 347 | if (ret) |
@@ -349,7 +349,7 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) | |||
349 | ret = xhci_setup_msi(xhci); | 349 | ret = xhci_setup_msi(xhci); |
350 | 350 | ||
351 | if (!ret) | 351 | if (!ret) |
352 | /* hcd->irq is -1, we have MSI */ | 352 | /* hcd->irq is 0, we have MSI */ |
353 | return 0; | 353 | return 0; |
354 | 354 | ||
355 | if (!pdev->irq) { | 355 | if (!pdev->irq) { |
@@ -729,6 +729,7 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) | |||
729 | ring->enq_seg = ring->deq_seg; | 729 | ring->enq_seg = ring->deq_seg; |
730 | ring->enqueue = ring->dequeue; | 730 | ring->enqueue = ring->dequeue; |
731 | 731 | ||
732 | ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1; | ||
732 | /* | 733 | /* |
733 | * Ring is now zeroed, so the HW should look for change of ownership | 734 | * Ring is now zeroed, so the HW should look for change of ownership |
734 | * when the cycle bit is set to 1. | 735 | * when the cycle bit is set to 1. |
@@ -3614,26 +3615,38 @@ static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000, | |||
3614 | 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000}; | 3615 | 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000}; |
3615 | 3616 | ||
3616 | /* Calculate HIRD/BESL for USB2 PORTPMSC*/ | 3617 | /* Calculate HIRD/BESL for USB2 PORTPMSC*/ |
3617 | static int xhci_calculate_hird_besl(int u2del, bool use_besl) | 3618 | static int xhci_calculate_hird_besl(struct xhci_hcd *xhci, |
3619 | struct usb_device *udev) | ||
3618 | { | 3620 | { |
3619 | int hird; | 3621 | int u2del, besl, besl_host; |
3622 | int besl_device = 0; | ||
3623 | u32 field; | ||
3624 | |||
3625 | u2del = HCS_U2_LATENCY(xhci->hcs_params3); | ||
3626 | field = le32_to_cpu(udev->bos->ext_cap->bmAttributes); | ||
3620 | 3627 | ||
3621 | if (use_besl) { | 3628 | if (field & USB_BESL_SUPPORT) { |
3622 | for (hird = 0; hird < 16; hird++) { | 3629 | for (besl_host = 0; besl_host < 16; besl_host++) { |
3623 | if (xhci_besl_encoding[hird] >= u2del) | 3630 | if (xhci_besl_encoding[besl_host] >= u2del) |
3624 | break; | 3631 | break; |
3625 | } | 3632 | } |
3633 | /* Use baseline BESL value as default */ | ||
3634 | if (field & USB_BESL_BASELINE_VALID) | ||
3635 | besl_device = USB_GET_BESL_BASELINE(field); | ||
3636 | else if (field & USB_BESL_DEEP_VALID) | ||
3637 | besl_device = USB_GET_BESL_DEEP(field); | ||
3626 | } else { | 3638 | } else { |
3627 | if (u2del <= 50) | 3639 | if (u2del <= 50) |
3628 | hird = 0; | 3640 | besl_host = 0; |
3629 | else | 3641 | else |
3630 | hird = (u2del - 51) / 75 + 1; | 3642 | besl_host = (u2del - 51) / 75 + 1; |
3631 | |||
3632 | if (hird > 15) | ||
3633 | hird = 15; | ||
3634 | } | 3643 | } |
3635 | 3644 | ||
3636 | return hird; | 3645 | besl = besl_host + besl_device; |
3646 | if (besl > 15) | ||
3647 | besl = 15; | ||
3648 | |||
3649 | return besl; | ||
3637 | } | 3650 | } |
3638 | 3651 | ||
3639 | static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | 3652 | static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, |
@@ -3646,7 +3659,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | |||
3646 | u32 temp, dev_id; | 3659 | u32 temp, dev_id; |
3647 | unsigned int port_num; | 3660 | unsigned int port_num; |
3648 | unsigned long flags; | 3661 | unsigned long flags; |
3649 | int u2del, hird; | 3662 | int hird; |
3650 | int ret; | 3663 | int ret; |
3651 | 3664 | ||
3652 | if (hcd->speed == HCD_USB3 || !xhci->sw_lpm_support || | 3665 | if (hcd->speed == HCD_USB3 || !xhci->sw_lpm_support || |
@@ -3692,12 +3705,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd *hcd, | |||
3692 | * HIRD or BESL shoule be used. See USB2.0 LPM errata. | 3705 | * HIRD or BESL shoule be used. See USB2.0 LPM errata. |
3693 | */ | 3706 | */ |
3694 | pm_addr = port_array[port_num] + 1; | 3707 | pm_addr = port_array[port_num] + 1; |
3695 | u2del = HCS_U2_LATENCY(xhci->hcs_params3); | 3708 | hird = xhci_calculate_hird_besl(xhci, udev); |
3696 | if (le32_to_cpu(udev->bos->ext_cap->bmAttributes) & (1 << 2)) | ||
3697 | hird = xhci_calculate_hird_besl(u2del, 1); | ||
3698 | else | ||
3699 | hird = xhci_calculate_hird_besl(u2del, 0); | ||
3700 | |||
3701 | temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird); | 3709 | temp = PORT_L1DS(udev->slot_id) | PORT_HIRD(hird); |
3702 | xhci_writel(xhci, temp, pm_addr); | 3710 | xhci_writel(xhci, temp, pm_addr); |
3703 | 3711 | ||
@@ -3776,7 +3784,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, | |||
3776 | u32 temp; | 3784 | u32 temp; |
3777 | unsigned int port_num; | 3785 | unsigned int port_num; |
3778 | unsigned long flags; | 3786 | unsigned long flags; |
3779 | int u2del, hird; | 3787 | int hird; |
3780 | 3788 | ||
3781 | if (hcd->speed == HCD_USB3 || !xhci->hw_lpm_support || | 3789 | if (hcd->speed == HCD_USB3 || !xhci->hw_lpm_support || |
3782 | !udev->lpm_capable) | 3790 | !udev->lpm_capable) |
@@ -3799,11 +3807,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, | |||
3799 | xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", | 3807 | xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", |
3800 | enable ? "enable" : "disable", port_num); | 3808 | enable ? "enable" : "disable", port_num); |
3801 | 3809 | ||
3802 | u2del = HCS_U2_LATENCY(xhci->hcs_params3); | 3810 | hird = xhci_calculate_hird_besl(xhci, udev); |
3803 | if (le32_to_cpu(udev->bos->ext_cap->bmAttributes) & (1 << 2)) | ||
3804 | hird = xhci_calculate_hird_besl(u2del, 1); | ||
3805 | else | ||
3806 | hird = xhci_calculate_hird_besl(u2del, 0); | ||
3807 | 3811 | ||
3808 | if (enable) { | 3812 | if (enable) { |
3809 | temp &= ~PORT_HIRD_MASK; | 3813 | temp &= ~PORT_HIRD_MASK; |
@@ -3964,7 +3968,8 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) | |||
3964 | int retval; | 3968 | int retval; |
3965 | u32 temp; | 3969 | u32 temp; |
3966 | 3970 | ||
3967 | hcd->self.sg_tablesize = TRBS_PER_SEGMENT - 2; | 3971 | /* Accept arbitrarily long scatter-gather lists */ |
3972 | hcd->self.sg_tablesize = ~0; | ||
3968 | 3973 | ||
3969 | if (usb_hcd_is_primary_hcd(hcd)) { | 3974 | if (usb_hcd_is_primary_hcd(hcd)) { |
3970 | xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL); | 3975 | xhci = kzalloc(sizeof(struct xhci_hcd), GFP_KERNEL); |
@@ -4059,6 +4064,11 @@ static int __init xhci_hcd_init(void) | |||
4059 | printk(KERN_DEBUG "Problem registering PCI driver."); | 4064 | printk(KERN_DEBUG "Problem registering PCI driver."); |
4060 | return retval; | 4065 | return retval; |
4061 | } | 4066 | } |
4067 | retval = xhci_register_plat(); | ||
4068 | if (retval < 0) { | ||
4069 | printk(KERN_DEBUG "Problem registering platform driver."); | ||
4070 | goto unreg_pci; | ||
4071 | } | ||
4062 | /* | 4072 | /* |
4063 | * Check the compiler generated sizes of structures that must be laid | 4073 | * Check the compiler generated sizes of structures that must be laid |
4064 | * out in specific ways for hardware access. | 4074 | * out in specific ways for hardware access. |
@@ -4078,11 +4088,15 @@ static int __init xhci_hcd_init(void) | |||
4078 | BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); | 4088 | BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8); |
4079 | BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8); | 4089 | BUILD_BUG_ON(sizeof(struct xhci_doorbell_array) != 256*32/8); |
4080 | return 0; | 4090 | return 0; |
4091 | unreg_pci: | ||
4092 | xhci_unregister_pci(); | ||
4093 | return retval; | ||
4081 | } | 4094 | } |
4082 | module_init(xhci_hcd_init); | 4095 | module_init(xhci_hcd_init); |
4083 | 4096 | ||
4084 | static void __exit xhci_hcd_cleanup(void) | 4097 | static void __exit xhci_hcd_cleanup(void) |
4085 | { | 4098 | { |
4086 | xhci_unregister_pci(); | 4099 | xhci_unregister_pci(); |
4100 | xhci_unregister_plat(); | ||
4087 | } | 4101 | } |
4088 | module_exit(xhci_hcd_cleanup); | 4102 | module_exit(xhci_hcd_cleanup); |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index fb99c8379142..91074fdab3eb 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1223,10 +1223,7 @@ union xhci_trb { | |||
1223 | /* Allow two commands + a link TRB, along with any reserved command TRBs */ | 1223 | /* Allow two commands + a link TRB, along with any reserved command TRBs */ |
1224 | #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) | 1224 | #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) |
1225 | #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) | 1225 | #define SEGMENT_SIZE (TRBS_PER_SEGMENT*16) |
1226 | /* SEGMENT_SHIFT should be log2(SEGMENT_SIZE). | 1226 | #define SEGMENT_SHIFT (__ffs(SEGMENT_SIZE)) |
1227 | * Change this if you change TRBS_PER_SEGMENT! | ||
1228 | */ | ||
1229 | #define SEGMENT_SHIFT 10 | ||
1230 | /* TRB buffer pointers can't cross 64KB boundaries */ | 1227 | /* TRB buffer pointers can't cross 64KB boundaries */ |
1231 | #define TRB_MAX_BUFF_SHIFT 16 | 1228 | #define TRB_MAX_BUFF_SHIFT 16 |
1232 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) | 1229 | #define TRB_MAX_BUFF_SIZE (1 << TRB_MAX_BUFF_SHIFT) |
@@ -1253,8 +1250,19 @@ struct xhci_dequeue_state { | |||
1253 | int new_cycle_state; | 1250 | int new_cycle_state; |
1254 | }; | 1251 | }; |
1255 | 1252 | ||
1253 | enum xhci_ring_type { | ||
1254 | TYPE_CTRL = 0, | ||
1255 | TYPE_ISOC, | ||
1256 | TYPE_BULK, | ||
1257 | TYPE_INTR, | ||
1258 | TYPE_STREAM, | ||
1259 | TYPE_COMMAND, | ||
1260 | TYPE_EVENT, | ||
1261 | }; | ||
1262 | |||
1256 | struct xhci_ring { | 1263 | struct xhci_ring { |
1257 | struct xhci_segment *first_seg; | 1264 | struct xhci_segment *first_seg; |
1265 | struct xhci_segment *last_seg; | ||
1258 | union xhci_trb *enqueue; | 1266 | union xhci_trb *enqueue; |
1259 | struct xhci_segment *enq_seg; | 1267 | struct xhci_segment *enq_seg; |
1260 | unsigned int enq_updates; | 1268 | unsigned int enq_updates; |
@@ -1269,6 +1277,10 @@ struct xhci_ring { | |||
1269 | */ | 1277 | */ |
1270 | u32 cycle_state; | 1278 | u32 cycle_state; |
1271 | unsigned int stream_id; | 1279 | unsigned int stream_id; |
1280 | unsigned int num_segs; | ||
1281 | unsigned int num_trbs_free; | ||
1282 | unsigned int num_trbs_free_temp; | ||
1283 | enum xhci_ring_type type; | ||
1272 | bool last_td_was_short; | 1284 | bool last_td_was_short; |
1273 | }; | 1285 | }; |
1274 | 1286 | ||
@@ -1344,6 +1356,7 @@ struct xhci_bus_state { | |||
1344 | /* ports suspend status arrays - max 31 ports for USB2, 15 for USB3 */ | 1356 | /* ports suspend status arrays - max 31 ports for USB2, 15 for USB3 */ |
1345 | u32 port_c_suspend; | 1357 | u32 port_c_suspend; |
1346 | u32 suspended_ports; | 1358 | u32 suspended_ports; |
1359 | u32 port_remote_wakeup; | ||
1347 | unsigned long resume_done[USB_MAXCHILDREN]; | 1360 | unsigned long resume_done[USB_MAXCHILDREN]; |
1348 | }; | 1361 | }; |
1349 | 1362 | ||
@@ -1609,6 +1622,8 @@ int xhci_endpoint_init(struct xhci_hcd *xhci, struct xhci_virt_device *virt_dev, | |||
1609 | struct usb_device *udev, struct usb_host_endpoint *ep, | 1622 | struct usb_device *udev, struct usb_host_endpoint *ep, |
1610 | gfp_t mem_flags); | 1623 | gfp_t mem_flags); |
1611 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); | 1624 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring); |
1625 | int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, | ||
1626 | unsigned int num_trbs, gfp_t flags); | ||
1612 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, | 1627 | void xhci_free_or_cache_endpoint_ring(struct xhci_hcd *xhci, |
1613 | struct xhci_virt_device *virt_dev, | 1628 | struct xhci_virt_device *virt_dev, |
1614 | unsigned int ep_index); | 1629 | unsigned int ep_index); |
@@ -1648,6 +1663,17 @@ static inline int xhci_register_pci(void) { return 0; } | |||
1648 | static inline void xhci_unregister_pci(void) {} | 1663 | static inline void xhci_unregister_pci(void) {} |
1649 | #endif | 1664 | #endif |
1650 | 1665 | ||
1666 | #if defined(CONFIG_USB_XHCI_PLATFORM) \ | ||
1667 | || defined(CONFIG_USB_XHCI_PLATFORM_MODULE) | ||
1668 | int xhci_register_plat(void); | ||
1669 | void xhci_unregister_plat(void); | ||
1670 | #else | ||
1671 | static inline int xhci_register_plat(void) | ||
1672 | { return 0; } | ||
1673 | static inline void xhci_unregister_plat(void) | ||
1674 | { } | ||
1675 | #endif | ||
1676 | |||
1651 | /* xHCI host controller glue */ | 1677 | /* xHCI host controller glue */ |
1652 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); | 1678 | typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *); |
1653 | void xhci_quiesce(struct xhci_hcd *xhci); | 1679 | void xhci_quiesce(struct xhci_hcd *xhci); |
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index e233d2b7d335..9f3eda91ea4d 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c | |||
@@ -226,6 +226,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) | |||
226 | struct device *dev = musb->controller; | 226 | struct device *dev = musb->controller; |
227 | struct musb_hdrc_platform_data *plat = dev->platform_data; | 227 | struct musb_hdrc_platform_data *plat = dev->platform_data; |
228 | struct omap_musb_board_data *data = plat->board_data; | 228 | struct omap_musb_board_data *data = plat->board_data; |
229 | struct usb_otg *otg = musb->xceiv->otg; | ||
229 | unsigned long flags; | 230 | unsigned long flags; |
230 | irqreturn_t ret = IRQ_NONE; | 231 | irqreturn_t ret = IRQ_NONE; |
231 | u32 epintr, usbintr; | 232 | u32 epintr, usbintr; |
@@ -289,14 +290,14 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) | |||
289 | WARNING("VBUS error workaround (delay coming)\n"); | 290 | WARNING("VBUS error workaround (delay coming)\n"); |
290 | } else if (is_host_enabled(musb) && drvvbus) { | 291 | } else if (is_host_enabled(musb) && drvvbus) { |
291 | MUSB_HST_MODE(musb); | 292 | MUSB_HST_MODE(musb); |
292 | musb->xceiv->default_a = 1; | 293 | otg->default_a = 1; |
293 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 294 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
294 | portstate(musb->port1_status |= USB_PORT_STAT_POWER); | 295 | portstate(musb->port1_status |= USB_PORT_STAT_POWER); |
295 | del_timer(&otg_workaround); | 296 | del_timer(&otg_workaround); |
296 | } else { | 297 | } else { |
297 | musb->is_active = 0; | 298 | musb->is_active = 0; |
298 | MUSB_DEV_MODE(musb); | 299 | MUSB_DEV_MODE(musb); |
299 | musb->xceiv->default_a = 0; | 300 | otg->default_a = 0; |
300 | musb->xceiv->state = OTG_STATE_B_IDLE; | 301 | musb->xceiv->state = OTG_STATE_B_IDLE; |
301 | portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); | 302 | portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); |
302 | } | 303 | } |
@@ -363,7 +364,7 @@ static int am35x_musb_init(struct musb *musb) | |||
363 | return -ENODEV; | 364 | return -ENODEV; |
364 | 365 | ||
365 | usb_nop_xceiv_register(); | 366 | usb_nop_xceiv_register(); |
366 | musb->xceiv = otg_get_transceiver(); | 367 | musb->xceiv = usb_get_transceiver(); |
367 | if (!musb->xceiv) | 368 | if (!musb->xceiv) |
368 | return -ENODEV; | 369 | return -ENODEV; |
369 | 370 | ||
@@ -405,7 +406,7 @@ static int am35x_musb_exit(struct musb *musb) | |||
405 | if (data->set_phy_power) | 406 | if (data->set_phy_power) |
406 | data->set_phy_power(0); | 407 | data->set_phy_power(0); |
407 | 408 | ||
408 | otg_put_transceiver(musb->xceiv); | 409 | usb_put_transceiver(musb->xceiv); |
409 | usb_nop_xceiv_unregister(); | 410 | usb_nop_xceiv_unregister(); |
410 | 411 | ||
411 | return 0; | 412 | return 0; |
@@ -456,7 +457,7 @@ static const struct musb_platform_ops am35x_ops = { | |||
456 | 457 | ||
457 | static u64 am35x_dmamask = DMA_BIT_MASK(32); | 458 | static u64 am35x_dmamask = DMA_BIT_MASK(32); |
458 | 459 | ||
459 | static int __init am35x_probe(struct platform_device *pdev) | 460 | static int __devinit am35x_probe(struct platform_device *pdev) |
460 | { | 461 | { |
461 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 462 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
462 | struct platform_device *musb; | 463 | struct platform_device *musb; |
@@ -561,7 +562,7 @@ err0: | |||
561 | return ret; | 562 | return ret; |
562 | } | 563 | } |
563 | 564 | ||
564 | static int __exit am35x_remove(struct platform_device *pdev) | 565 | static int __devexit am35x_remove(struct platform_device *pdev) |
565 | { | 566 | { |
566 | struct am35x_glue *glue = platform_get_drvdata(pdev); | 567 | struct am35x_glue *glue = platform_get_drvdata(pdev); |
567 | 568 | ||
@@ -630,7 +631,8 @@ static struct dev_pm_ops am35x_pm_ops = { | |||
630 | #endif | 631 | #endif |
631 | 632 | ||
632 | static struct platform_driver am35x_driver = { | 633 | static struct platform_driver am35x_driver = { |
633 | .remove = __exit_p(am35x_remove), | 634 | .probe = am35x_probe, |
635 | .remove = __devexit_p(am35x_remove), | ||
634 | .driver = { | 636 | .driver = { |
635 | .name = "musb-am35x", | 637 | .name = "musb-am35x", |
636 | .pm = DEV_PM_OPS, | 638 | .pm = DEV_PM_OPS, |
@@ -643,9 +645,9 @@ MODULE_LICENSE("GPL v2"); | |||
643 | 645 | ||
644 | static int __init am35x_init(void) | 646 | static int __init am35x_init(void) |
645 | { | 647 | { |
646 | return platform_driver_probe(&am35x_driver, am35x_probe); | 648 | return platform_driver_register(&am35x_driver); |
647 | } | 649 | } |
648 | subsys_initcall(am35x_init); | 650 | module_init(am35x_init); |
649 | 651 | ||
650 | static void __exit am35x_exit(void) | 652 | static void __exit am35x_exit(void) |
651 | { | 653 | { |
diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 5e7cfba5b079..a087ed6c3be9 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c | |||
@@ -317,7 +317,7 @@ static void bfin_musb_set_vbus(struct musb *musb, int is_on) | |||
317 | musb_readb(musb->mregs, MUSB_DEVCTL)); | 317 | musb_readb(musb->mregs, MUSB_DEVCTL)); |
318 | } | 318 | } |
319 | 319 | ||
320 | static int bfin_musb_set_power(struct otg_transceiver *x, unsigned mA) | 320 | static int bfin_musb_set_power(struct usb_phy *x, unsigned mA) |
321 | { | 321 | { |
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
@@ -415,7 +415,7 @@ static int bfin_musb_init(struct musb *musb) | |||
415 | gpio_direction_output(musb->config->gpio_vrsel, 0); | 415 | gpio_direction_output(musb->config->gpio_vrsel, 0); |
416 | 416 | ||
417 | usb_nop_xceiv_register(); | 417 | usb_nop_xceiv_register(); |
418 | musb->xceiv = otg_get_transceiver(); | 418 | musb->xceiv = usb_get_transceiver(); |
419 | if (!musb->xceiv) { | 419 | if (!musb->xceiv) { |
420 | gpio_free(musb->config->gpio_vrsel); | 420 | gpio_free(musb->config->gpio_vrsel); |
421 | return -ENODEV; | 421 | return -ENODEV; |
@@ -440,7 +440,7 @@ static int bfin_musb_exit(struct musb *musb) | |||
440 | { | 440 | { |
441 | gpio_free(musb->config->gpio_vrsel); | 441 | gpio_free(musb->config->gpio_vrsel); |
442 | 442 | ||
443 | otg_put_transceiver(musb->xceiv); | 443 | usb_put_transceiver(musb->xceiv); |
444 | usb_nop_xceiv_unregister(); | 444 | usb_nop_xceiv_unregister(); |
445 | return 0; | 445 | return 0; |
446 | } | 446 | } |
@@ -463,7 +463,7 @@ static const struct musb_platform_ops bfin_ops = { | |||
463 | 463 | ||
464 | static u64 bfin_dmamask = DMA_BIT_MASK(32); | 464 | static u64 bfin_dmamask = DMA_BIT_MASK(32); |
465 | 465 | ||
466 | static int __init bfin_probe(struct platform_device *pdev) | 466 | static int __devinit bfin_probe(struct platform_device *pdev) |
467 | { | 467 | { |
468 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 468 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
469 | struct platform_device *musb; | 469 | struct platform_device *musb; |
@@ -525,7 +525,7 @@ err0: | |||
525 | return ret; | 525 | return ret; |
526 | } | 526 | } |
527 | 527 | ||
528 | static int __exit bfin_remove(struct platform_device *pdev) | 528 | static int __devexit bfin_remove(struct platform_device *pdev) |
529 | { | 529 | { |
530 | struct bfin_glue *glue = platform_get_drvdata(pdev); | 530 | struct bfin_glue *glue = platform_get_drvdata(pdev); |
531 | 531 | ||
@@ -575,6 +575,7 @@ static struct dev_pm_ops bfin_pm_ops = { | |||
575 | #endif | 575 | #endif |
576 | 576 | ||
577 | static struct platform_driver bfin_driver = { | 577 | static struct platform_driver bfin_driver = { |
578 | .probe = bfin_probe, | ||
578 | .remove = __exit_p(bfin_remove), | 579 | .remove = __exit_p(bfin_remove), |
579 | .driver = { | 580 | .driver = { |
580 | .name = "musb-blackfin", | 581 | .name = "musb-blackfin", |
@@ -588,9 +589,9 @@ MODULE_LICENSE("GPL v2"); | |||
588 | 589 | ||
589 | static int __init bfin_init(void) | 590 | static int __init bfin_init(void) |
590 | { | 591 | { |
591 | return platform_driver_probe(&bfin_driver, bfin_probe); | 592 | return platform_driver_register(&bfin_driver); |
592 | } | 593 | } |
593 | subsys_initcall(bfin_init); | 594 | module_init(bfin_init); |
594 | 595 | ||
595 | static void __exit bfin_exit(void) | 596 | static void __exit bfin_exit(void) |
596 | { | 597 | { |
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 2613bfdb09b6..8bd9566f3fbb 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c | |||
@@ -294,6 +294,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) | |||
294 | { | 294 | { |
295 | struct musb *musb = hci; | 295 | struct musb *musb = hci; |
296 | void __iomem *reg_base = musb->ctrl_base; | 296 | void __iomem *reg_base = musb->ctrl_base; |
297 | struct usb_otg *otg = musb->xceiv->otg; | ||
297 | unsigned long flags; | 298 | unsigned long flags; |
298 | irqreturn_t ret = IRQ_NONE; | 299 | irqreturn_t ret = IRQ_NONE; |
299 | u32 status; | 300 | u32 status; |
@@ -351,14 +352,14 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) | |||
351 | WARNING("VBUS error workaround (delay coming)\n"); | 352 | WARNING("VBUS error workaround (delay coming)\n"); |
352 | } else if (is_host_enabled(musb) && drvvbus) { | 353 | } else if (is_host_enabled(musb) && drvvbus) { |
353 | MUSB_HST_MODE(musb); | 354 | MUSB_HST_MODE(musb); |
354 | musb->xceiv->default_a = 1; | 355 | otg->default_a = 1; |
355 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 356 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
356 | portstate(musb->port1_status |= USB_PORT_STAT_POWER); | 357 | portstate(musb->port1_status |= USB_PORT_STAT_POWER); |
357 | del_timer(&otg_workaround); | 358 | del_timer(&otg_workaround); |
358 | } else { | 359 | } else { |
359 | musb->is_active = 0; | 360 | musb->is_active = 0; |
360 | MUSB_DEV_MODE(musb); | 361 | MUSB_DEV_MODE(musb); |
361 | musb->xceiv->default_a = 0; | 362 | otg->default_a = 0; |
362 | musb->xceiv->state = OTG_STATE_B_IDLE; | 363 | musb->xceiv->state = OTG_STATE_B_IDLE; |
363 | portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); | 364 | portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); |
364 | } | 365 | } |
@@ -424,7 +425,7 @@ static int da8xx_musb_init(struct musb *musb) | |||
424 | goto fail; | 425 | goto fail; |
425 | 426 | ||
426 | usb_nop_xceiv_register(); | 427 | usb_nop_xceiv_register(); |
427 | musb->xceiv = otg_get_transceiver(); | 428 | musb->xceiv = usb_get_transceiver(); |
428 | if (!musb->xceiv) | 429 | if (!musb->xceiv) |
429 | goto fail; | 430 | goto fail; |
430 | 431 | ||
@@ -457,7 +458,7 @@ static int da8xx_musb_exit(struct musb *musb) | |||
457 | 458 | ||
458 | phy_off(); | 459 | phy_off(); |
459 | 460 | ||
460 | otg_put_transceiver(musb->xceiv); | 461 | usb_put_transceiver(musb->xceiv); |
461 | usb_nop_xceiv_unregister(); | 462 | usb_nop_xceiv_unregister(); |
462 | 463 | ||
463 | return 0; | 464 | return 0; |
@@ -478,7 +479,7 @@ static const struct musb_platform_ops da8xx_ops = { | |||
478 | 479 | ||
479 | static u64 da8xx_dmamask = DMA_BIT_MASK(32); | 480 | static u64 da8xx_dmamask = DMA_BIT_MASK(32); |
480 | 481 | ||
481 | static int __init da8xx_probe(struct platform_device *pdev) | 482 | static int __devinit da8xx_probe(struct platform_device *pdev) |
482 | { | 483 | { |
483 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 484 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
484 | struct platform_device *musb; | 485 | struct platform_device *musb; |
@@ -562,7 +563,7 @@ err0: | |||
562 | return ret; | 563 | return ret; |
563 | } | 564 | } |
564 | 565 | ||
565 | static int __exit da8xx_remove(struct platform_device *pdev) | 566 | static int __devexit da8xx_remove(struct platform_device *pdev) |
566 | { | 567 | { |
567 | struct da8xx_glue *glue = platform_get_drvdata(pdev); | 568 | struct da8xx_glue *glue = platform_get_drvdata(pdev); |
568 | 569 | ||
@@ -576,7 +577,8 @@ static int __exit da8xx_remove(struct platform_device *pdev) | |||
576 | } | 577 | } |
577 | 578 | ||
578 | static struct platform_driver da8xx_driver = { | 579 | static struct platform_driver da8xx_driver = { |
579 | .remove = __exit_p(da8xx_remove), | 580 | .probe = da8xx_probe, |
581 | .remove = __devexit_p(da8xx_remove), | ||
580 | .driver = { | 582 | .driver = { |
581 | .name = "musb-da8xx", | 583 | .name = "musb-da8xx", |
582 | }, | 584 | }, |
@@ -588,9 +590,9 @@ MODULE_LICENSE("GPL v2"); | |||
588 | 590 | ||
589 | static int __init da8xx_init(void) | 591 | static int __init da8xx_init(void) |
590 | { | 592 | { |
591 | return platform_driver_probe(&da8xx_driver, da8xx_probe); | 593 | return platform_driver_register(&da8xx_driver); |
592 | } | 594 | } |
593 | subsys_initcall(da8xx_init); | 595 | module_init(da8xx_init); |
594 | 596 | ||
595 | static void __exit da8xx_exit(void) | 597 | static void __exit da8xx_exit(void) |
596 | { | 598 | { |
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 7c569f51212a..97ab975fa442 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -265,6 +265,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
265 | unsigned long flags; | 265 | unsigned long flags; |
266 | irqreturn_t retval = IRQ_NONE; | 266 | irqreturn_t retval = IRQ_NONE; |
267 | struct musb *musb = __hci; | 267 | struct musb *musb = __hci; |
268 | struct usb_otg *otg = musb->xceiv->otg; | ||
268 | void __iomem *tibase = musb->ctrl_base; | 269 | void __iomem *tibase = musb->ctrl_base; |
269 | struct cppi *cppi; | 270 | struct cppi *cppi; |
270 | u32 tmp; | 271 | u32 tmp; |
@@ -331,14 +332,14 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
331 | WARNING("VBUS error workaround (delay coming)\n"); | 332 | WARNING("VBUS error workaround (delay coming)\n"); |
332 | } else if (is_host_enabled(musb) && drvvbus) { | 333 | } else if (is_host_enabled(musb) && drvvbus) { |
333 | MUSB_HST_MODE(musb); | 334 | MUSB_HST_MODE(musb); |
334 | musb->xceiv->default_a = 1; | 335 | otg->default_a = 1; |
335 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 336 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
336 | portstate(musb->port1_status |= USB_PORT_STAT_POWER); | 337 | portstate(musb->port1_status |= USB_PORT_STAT_POWER); |
337 | del_timer(&otg_workaround); | 338 | del_timer(&otg_workaround); |
338 | } else { | 339 | } else { |
339 | musb->is_active = 0; | 340 | musb->is_active = 0; |
340 | MUSB_DEV_MODE(musb); | 341 | MUSB_DEV_MODE(musb); |
341 | musb->xceiv->default_a = 0; | 342 | otg->default_a = 0; |
342 | musb->xceiv->state = OTG_STATE_B_IDLE; | 343 | musb->xceiv->state = OTG_STATE_B_IDLE; |
343 | portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); | 344 | portstate(musb->port1_status &= ~USB_PORT_STAT_POWER); |
344 | } | 345 | } |
@@ -383,7 +384,7 @@ static int davinci_musb_init(struct musb *musb) | |||
383 | u32 revision; | 384 | u32 revision; |
384 | 385 | ||
385 | usb_nop_xceiv_register(); | 386 | usb_nop_xceiv_register(); |
386 | musb->xceiv = otg_get_transceiver(); | 387 | musb->xceiv = usb_get_transceiver(); |
387 | if (!musb->xceiv) | 388 | if (!musb->xceiv) |
388 | return -ENODEV; | 389 | return -ENODEV; |
389 | 390 | ||
@@ -442,7 +443,7 @@ static int davinci_musb_init(struct musb *musb) | |||
442 | return 0; | 443 | return 0; |
443 | 444 | ||
444 | fail: | 445 | fail: |
445 | otg_put_transceiver(musb->xceiv); | 446 | usb_put_transceiver(musb->xceiv); |
446 | usb_nop_xceiv_unregister(); | 447 | usb_nop_xceiv_unregister(); |
447 | return -ENODEV; | 448 | return -ENODEV; |
448 | } | 449 | } |
@@ -464,7 +465,7 @@ static int davinci_musb_exit(struct musb *musb) | |||
464 | davinci_musb_source_power(musb, 0 /*off*/, 1); | 465 | davinci_musb_source_power(musb, 0 /*off*/, 1); |
465 | 466 | ||
466 | /* delay, to avoid problems with module reload */ | 467 | /* delay, to avoid problems with module reload */ |
467 | if (is_host_enabled(musb) && musb->xceiv->default_a) { | 468 | if (is_host_enabled(musb) && musb->xceiv->otg->default_a) { |
468 | int maxdelay = 30; | 469 | int maxdelay = 30; |
469 | u8 devctl, warn = 0; | 470 | u8 devctl, warn = 0; |
470 | 471 | ||
@@ -491,7 +492,7 @@ static int davinci_musb_exit(struct musb *musb) | |||
491 | 492 | ||
492 | phy_off(); | 493 | phy_off(); |
493 | 494 | ||
494 | otg_put_transceiver(musb->xceiv); | 495 | usb_put_transceiver(musb->xceiv); |
495 | usb_nop_xceiv_unregister(); | 496 | usb_nop_xceiv_unregister(); |
496 | 497 | ||
497 | return 0; | 498 | return 0; |
@@ -511,7 +512,7 @@ static const struct musb_platform_ops davinci_ops = { | |||
511 | 512 | ||
512 | static u64 davinci_dmamask = DMA_BIT_MASK(32); | 513 | static u64 davinci_dmamask = DMA_BIT_MASK(32); |
513 | 514 | ||
514 | static int __init davinci_probe(struct platform_device *pdev) | 515 | static int __devinit davinci_probe(struct platform_device *pdev) |
515 | { | 516 | { |
516 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 517 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
517 | struct platform_device *musb; | 518 | struct platform_device *musb; |
@@ -594,7 +595,7 @@ err0: | |||
594 | return ret; | 595 | return ret; |
595 | } | 596 | } |
596 | 597 | ||
597 | static int __exit davinci_remove(struct platform_device *pdev) | 598 | static int __devexit davinci_remove(struct platform_device *pdev) |
598 | { | 599 | { |
599 | struct davinci_glue *glue = platform_get_drvdata(pdev); | 600 | struct davinci_glue *glue = platform_get_drvdata(pdev); |
600 | 601 | ||
@@ -608,7 +609,8 @@ static int __exit davinci_remove(struct platform_device *pdev) | |||
608 | } | 609 | } |
609 | 610 | ||
610 | static struct platform_driver davinci_driver = { | 611 | static struct platform_driver davinci_driver = { |
611 | .remove = __exit_p(davinci_remove), | 612 | .probe = davinci_probe, |
613 | .remove = __devexit_p(davinci_remove), | ||
612 | .driver = { | 614 | .driver = { |
613 | .name = "musb-davinci", | 615 | .name = "musb-davinci", |
614 | }, | 616 | }, |
@@ -620,9 +622,9 @@ MODULE_LICENSE("GPL v2"); | |||
620 | 622 | ||
621 | static int __init davinci_init(void) | 623 | static int __init davinci_init(void) |
622 | { | 624 | { |
623 | return platform_driver_probe(&davinci_driver, davinci_probe); | 625 | return platform_driver_register(&davinci_driver); |
624 | } | 626 | } |
625 | subsys_initcall(davinci_init); | 627 | module_init(davinci_init); |
626 | 628 | ||
627 | static void __exit davinci_exit(void) | 629 | static void __exit davinci_exit(void) |
628 | { | 630 | { |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 3d11cf64ebd1..0f8b82918a40 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
@@ -131,9 +131,9 @@ static inline struct musb *dev_to_musb(struct device *dev) | |||
131 | /*-------------------------------------------------------------------------*/ | 131 | /*-------------------------------------------------------------------------*/ |
132 | 132 | ||
133 | #ifndef CONFIG_BLACKFIN | 133 | #ifndef CONFIG_BLACKFIN |
134 | static int musb_ulpi_read(struct otg_transceiver *otg, u32 offset) | 134 | static int musb_ulpi_read(struct usb_phy *phy, u32 offset) |
135 | { | 135 | { |
136 | void __iomem *addr = otg->io_priv; | 136 | void __iomem *addr = phy->io_priv; |
137 | int i = 0; | 137 | int i = 0; |
138 | u8 r; | 138 | u8 r; |
139 | u8 power; | 139 | u8 power; |
@@ -165,10 +165,9 @@ static int musb_ulpi_read(struct otg_transceiver *otg, u32 offset) | |||
165 | return musb_readb(addr, MUSB_ULPI_REG_DATA); | 165 | return musb_readb(addr, MUSB_ULPI_REG_DATA); |
166 | } | 166 | } |
167 | 167 | ||
168 | static int musb_ulpi_write(struct otg_transceiver *otg, | 168 | static int musb_ulpi_write(struct usb_phy *phy, u32 offset, u32 data) |
169 | u32 offset, u32 data) | ||
170 | { | 169 | { |
171 | void __iomem *addr = otg->io_priv; | 170 | void __iomem *addr = phy->io_priv; |
172 | int i = 0; | 171 | int i = 0; |
173 | u8 r = 0; | 172 | u8 r = 0; |
174 | u8 power; | 173 | u8 power; |
@@ -200,7 +199,7 @@ static int musb_ulpi_write(struct otg_transceiver *otg, | |||
200 | #define musb_ulpi_write NULL | 199 | #define musb_ulpi_write NULL |
201 | #endif | 200 | #endif |
202 | 201 | ||
203 | static struct otg_io_access_ops musb_ulpi_access = { | 202 | static struct usb_phy_io_ops musb_ulpi_access = { |
204 | .read = musb_ulpi_read, | 203 | .read = musb_ulpi_read, |
205 | .write = musb_ulpi_write, | 204 | .write = musb_ulpi_write, |
206 | }; | 205 | }; |
@@ -414,6 +413,7 @@ void musb_hnp_stop(struct musb *musb) | |||
414 | static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | 413 | static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, |
415 | u8 devctl, u8 power) | 414 | u8 devctl, u8 power) |
416 | { | 415 | { |
416 | struct usb_otg *otg = musb->xceiv->otg; | ||
417 | irqreturn_t handled = IRQ_NONE; | 417 | irqreturn_t handled = IRQ_NONE; |
418 | 418 | ||
419 | dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl, | 419 | dev_dbg(musb->controller, "<== Power=%02x, DevCtl=%02x, int_usb=0x%x\n", power, devctl, |
@@ -626,7 +626,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
626 | case OTG_STATE_B_PERIPHERAL: | 626 | case OTG_STATE_B_PERIPHERAL: |
627 | musb_g_suspend(musb); | 627 | musb_g_suspend(musb); |
628 | musb->is_active = is_otg_enabled(musb) | 628 | musb->is_active = is_otg_enabled(musb) |
629 | && musb->xceiv->gadget->b_hnp_enable; | 629 | && otg->gadget->b_hnp_enable; |
630 | if (musb->is_active) { | 630 | if (musb->is_active) { |
631 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; | 631 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; |
632 | dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); | 632 | dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); |
@@ -643,7 +643,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, | |||
643 | case OTG_STATE_A_HOST: | 643 | case OTG_STATE_A_HOST: |
644 | musb->xceiv->state = OTG_STATE_A_SUSPEND; | 644 | musb->xceiv->state = OTG_STATE_A_SUSPEND; |
645 | musb->is_active = is_otg_enabled(musb) | 645 | musb->is_active = is_otg_enabled(musb) |
646 | && musb->xceiv->host->b_hnp_enable; | 646 | && otg->host->b_hnp_enable; |
647 | break; | 647 | break; |
648 | case OTG_STATE_B_HOST: | 648 | case OTG_STATE_B_HOST: |
649 | /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ | 649 | /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */ |
@@ -1017,12 +1017,12 @@ static void musb_shutdown(struct platform_device *pdev) | |||
1017 | || defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE) \ | 1017 | || defined(CONFIG_USB_MUSB_OMAP2PLUS_MODULE) \ |
1018 | || defined(CONFIG_USB_MUSB_AM35X) \ | 1018 | || defined(CONFIG_USB_MUSB_AM35X) \ |
1019 | || defined(CONFIG_USB_MUSB_AM35X_MODULE) | 1019 | || defined(CONFIG_USB_MUSB_AM35X_MODULE) |
1020 | static ushort __initdata fifo_mode = 4; | 1020 | static ushort __devinitdata fifo_mode = 4; |
1021 | #elif defined(CONFIG_USB_MUSB_UX500) \ | 1021 | #elif defined(CONFIG_USB_MUSB_UX500) \ |
1022 | || defined(CONFIG_USB_MUSB_UX500_MODULE) | 1022 | || defined(CONFIG_USB_MUSB_UX500_MODULE) |
1023 | static ushort __initdata fifo_mode = 5; | 1023 | static ushort __devinitdata fifo_mode = 5; |
1024 | #else | 1024 | #else |
1025 | static ushort __initdata fifo_mode = 2; | 1025 | static ushort __devinitdata fifo_mode = 2; |
1026 | #endif | 1026 | #endif |
1027 | 1027 | ||
1028 | /* "modprobe ... fifo_mode=1" etc */ | 1028 | /* "modprobe ... fifo_mode=1" etc */ |
@@ -1035,7 +1035,7 @@ MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration"); | |||
1035 | */ | 1035 | */ |
1036 | 1036 | ||
1037 | /* mode 0 - fits in 2KB */ | 1037 | /* mode 0 - fits in 2KB */ |
1038 | static struct musb_fifo_cfg __initdata mode_0_cfg[] = { | 1038 | static struct musb_fifo_cfg __devinitdata mode_0_cfg[] = { |
1039 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1039 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
1040 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1040 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
1041 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, | 1041 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, }, |
@@ -1044,7 +1044,7 @@ static struct musb_fifo_cfg __initdata mode_0_cfg[] = { | |||
1044 | }; | 1044 | }; |
1045 | 1045 | ||
1046 | /* mode 1 - fits in 4KB */ | 1046 | /* mode 1 - fits in 4KB */ |
1047 | static struct musb_fifo_cfg __initdata mode_1_cfg[] = { | 1047 | static struct musb_fifo_cfg __devinitdata mode_1_cfg[] = { |
1048 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1048 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
1049 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1049 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
1050 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1050 | { .hw_ep_num = 2, .style = FIFO_RXTX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
@@ -1053,7 +1053,7 @@ static struct musb_fifo_cfg __initdata mode_1_cfg[] = { | |||
1053 | }; | 1053 | }; |
1054 | 1054 | ||
1055 | /* mode 2 - fits in 4KB */ | 1055 | /* mode 2 - fits in 4KB */ |
1056 | static struct musb_fifo_cfg __initdata mode_2_cfg[] = { | 1056 | static struct musb_fifo_cfg __devinitdata mode_2_cfg[] = { |
1057 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1057 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
1058 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1058 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
1059 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1059 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
@@ -1063,7 +1063,7 @@ static struct musb_fifo_cfg __initdata mode_2_cfg[] = { | |||
1063 | }; | 1063 | }; |
1064 | 1064 | ||
1065 | /* mode 3 - fits in 4KB */ | 1065 | /* mode 3 - fits in 4KB */ |
1066 | static struct musb_fifo_cfg __initdata mode_3_cfg[] = { | 1066 | static struct musb_fifo_cfg __devinitdata mode_3_cfg[] = { |
1067 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1067 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
1068 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, | 1068 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, .mode = BUF_DOUBLE, }, |
1069 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1069 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
@@ -1073,7 +1073,7 @@ static struct musb_fifo_cfg __initdata mode_3_cfg[] = { | |||
1073 | }; | 1073 | }; |
1074 | 1074 | ||
1075 | /* mode 4 - fits in 16KB */ | 1075 | /* mode 4 - fits in 16KB */ |
1076 | static struct musb_fifo_cfg __initdata mode_4_cfg[] = { | 1076 | static struct musb_fifo_cfg __devinitdata mode_4_cfg[] = { |
1077 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1077 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
1078 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1078 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
1079 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1079 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
@@ -1104,7 +1104,7 @@ static struct musb_fifo_cfg __initdata mode_4_cfg[] = { | |||
1104 | }; | 1104 | }; |
1105 | 1105 | ||
1106 | /* mode 5 - fits in 8KB */ | 1106 | /* mode 5 - fits in 8KB */ |
1107 | static struct musb_fifo_cfg __initdata mode_5_cfg[] = { | 1107 | static struct musb_fifo_cfg __devinitdata mode_5_cfg[] = { |
1108 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, | 1108 | { .hw_ep_num = 1, .style = FIFO_TX, .maxpacket = 512, }, |
1109 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, | 1109 | { .hw_ep_num = 1, .style = FIFO_RX, .maxpacket = 512, }, |
1110 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, | 1110 | { .hw_ep_num = 2, .style = FIFO_TX, .maxpacket = 512, }, |
@@ -1140,7 +1140,7 @@ static struct musb_fifo_cfg __initdata mode_5_cfg[] = { | |||
1140 | * | 1140 | * |
1141 | * returns negative errno or offset for next fifo. | 1141 | * returns negative errno or offset for next fifo. |
1142 | */ | 1142 | */ |
1143 | static int __init | 1143 | static int __devinit |
1144 | fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, | 1144 | fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, |
1145 | const struct musb_fifo_cfg *cfg, u16 offset) | 1145 | const struct musb_fifo_cfg *cfg, u16 offset) |
1146 | { | 1146 | { |
@@ -1211,11 +1211,11 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, | |||
1211 | return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); | 1211 | return offset + (maxpacket << ((c_size & MUSB_FIFOSZ_DPB) ? 1 : 0)); |
1212 | } | 1212 | } |
1213 | 1213 | ||
1214 | static struct musb_fifo_cfg __initdata ep0_cfg = { | 1214 | static struct musb_fifo_cfg __devinitdata ep0_cfg = { |
1215 | .style = FIFO_RXTX, .maxpacket = 64, | 1215 | .style = FIFO_RXTX, .maxpacket = 64, |
1216 | }; | 1216 | }; |
1217 | 1217 | ||
1218 | static int __init ep_config_from_table(struct musb *musb) | 1218 | static int __devinit ep_config_from_table(struct musb *musb) |
1219 | { | 1219 | { |
1220 | const struct musb_fifo_cfg *cfg; | 1220 | const struct musb_fifo_cfg *cfg; |
1221 | unsigned i, n; | 1221 | unsigned i, n; |
@@ -1306,7 +1306,7 @@ done: | |||
1306 | * ep_config_from_hw - when MUSB_C_DYNFIFO_DEF is false | 1306 | * ep_config_from_hw - when MUSB_C_DYNFIFO_DEF is false |
1307 | * @param musb the controller | 1307 | * @param musb the controller |
1308 | */ | 1308 | */ |
1309 | static int __init ep_config_from_hw(struct musb *musb) | 1309 | static int __devinit ep_config_from_hw(struct musb *musb) |
1310 | { | 1310 | { |
1311 | u8 epnum = 0; | 1311 | u8 epnum = 0; |
1312 | struct musb_hw_ep *hw_ep; | 1312 | struct musb_hw_ep *hw_ep; |
@@ -1353,7 +1353,7 @@ enum { MUSB_CONTROLLER_MHDRC, MUSB_CONTROLLER_HDRC, }; | |||
1353 | /* Initialize MUSB (M)HDRC part of the USB hardware subsystem; | 1353 | /* Initialize MUSB (M)HDRC part of the USB hardware subsystem; |
1354 | * configure endpoints, or take their config from silicon | 1354 | * configure endpoints, or take their config from silicon |
1355 | */ | 1355 | */ |
1356 | static int __init musb_core_init(u16 musb_type, struct musb *musb) | 1356 | static int __devinit musb_core_init(u16 musb_type, struct musb *musb) |
1357 | { | 1357 | { |
1358 | u8 reg; | 1358 | u8 reg; |
1359 | char *type; | 1359 | char *type; |
@@ -1589,7 +1589,7 @@ irqreturn_t musb_interrupt(struct musb *musb) | |||
1589 | EXPORT_SYMBOL_GPL(musb_interrupt); | 1589 | EXPORT_SYMBOL_GPL(musb_interrupt); |
1590 | 1590 | ||
1591 | #ifndef CONFIG_MUSB_PIO_ONLY | 1591 | #ifndef CONFIG_MUSB_PIO_ONLY |
1592 | static bool __initdata use_dma = 1; | 1592 | static bool __devinitdata use_dma = 1; |
1593 | 1593 | ||
1594 | /* "modprobe ... use_dma=0" etc */ | 1594 | /* "modprobe ... use_dma=0" etc */ |
1595 | module_param(use_dma, bool, 0); | 1595 | module_param(use_dma, bool, 0); |
@@ -1777,7 +1777,7 @@ static void musb_irq_work(struct work_struct *data) | |||
1777 | * Init support | 1777 | * Init support |
1778 | */ | 1778 | */ |
1779 | 1779 | ||
1780 | static struct musb *__init | 1780 | static struct musb *__devinit |
1781 | allocate_instance(struct device *dev, | 1781 | allocate_instance(struct device *dev, |
1782 | struct musb_hdrc_config *config, void __iomem *mbase) | 1782 | struct musb_hdrc_config *config, void __iomem *mbase) |
1783 | { | 1783 | { |
@@ -1853,7 +1853,7 @@ static void musb_free(struct musb *musb) | |||
1853 | * @mregs: virtual address of controller registers, | 1853 | * @mregs: virtual address of controller registers, |
1854 | * not yet corrected for platform-specific offsets | 1854 | * not yet corrected for platform-specific offsets |
1855 | */ | 1855 | */ |
1856 | static int __init | 1856 | static int __devinit |
1857 | musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | 1857 | musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) |
1858 | { | 1858 | { |
1859 | int status; | 1859 | int status; |
@@ -1961,11 +1961,11 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1961 | if (is_host_enabled(musb)) { | 1961 | if (is_host_enabled(musb)) { |
1962 | struct usb_hcd *hcd = musb_to_hcd(musb); | 1962 | struct usb_hcd *hcd = musb_to_hcd(musb); |
1963 | 1963 | ||
1964 | otg_set_host(musb->xceiv, &hcd->self); | 1964 | otg_set_host(musb->xceiv->otg, &hcd->self); |
1965 | 1965 | ||
1966 | if (is_otg_enabled(musb)) | 1966 | if (is_otg_enabled(musb)) |
1967 | hcd->self.otg_port = 1; | 1967 | hcd->self.otg_port = 1; |
1968 | musb->xceiv->host = &hcd->self; | 1968 | musb->xceiv->otg->host = &hcd->self; |
1969 | hcd->power_budget = 2 * (plat->power ? : 250); | 1969 | hcd->power_budget = 2 * (plat->power ? : 250); |
1970 | 1970 | ||
1971 | /* program PHY to use external vBus if required */ | 1971 | /* program PHY to use external vBus if required */ |
@@ -1984,10 +1984,10 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1984 | struct usb_hcd *hcd = musb_to_hcd(musb); | 1984 | struct usb_hcd *hcd = musb_to_hcd(musb); |
1985 | 1985 | ||
1986 | MUSB_HST_MODE(musb); | 1986 | MUSB_HST_MODE(musb); |
1987 | musb->xceiv->default_a = 1; | 1987 | musb->xceiv->otg->default_a = 1; |
1988 | musb->xceiv->state = OTG_STATE_A_IDLE; | 1988 | musb->xceiv->state = OTG_STATE_A_IDLE; |
1989 | 1989 | ||
1990 | status = usb_add_hcd(musb_to_hcd(musb), -1, 0); | 1990 | status = usb_add_hcd(musb_to_hcd(musb), 0, 0); |
1991 | 1991 | ||
1992 | hcd->self.uses_pio_for_control = 1; | 1992 | hcd->self.uses_pio_for_control = 1; |
1993 | dev_dbg(musb->controller, "%s mode, status %d, devctl %02x %c\n", | 1993 | dev_dbg(musb->controller, "%s mode, status %d, devctl %02x %c\n", |
@@ -1999,7 +1999,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) | |||
1999 | 1999 | ||
2000 | } else /* peripheral is enabled */ { | 2000 | } else /* peripheral is enabled */ { |
2001 | MUSB_DEV_MODE(musb); | 2001 | MUSB_DEV_MODE(musb); |
2002 | musb->xceiv->default_a = 0; | 2002 | musb->xceiv->otg->default_a = 0; |
2003 | musb->xceiv->state = OTG_STATE_B_IDLE; | 2003 | musb->xceiv->state = OTG_STATE_B_IDLE; |
2004 | 2004 | ||
2005 | status = musb_gadget_setup(musb); | 2005 | status = musb_gadget_setup(musb); |
@@ -2073,7 +2073,7 @@ fail0: | |||
2073 | static u64 *orig_dma_mask; | 2073 | static u64 *orig_dma_mask; |
2074 | #endif | 2074 | #endif |
2075 | 2075 | ||
2076 | static int __init musb_probe(struct platform_device *pdev) | 2076 | static int __devinit musb_probe(struct platform_device *pdev) |
2077 | { | 2077 | { |
2078 | struct device *dev = &pdev->dev; | 2078 | struct device *dev = &pdev->dev; |
2079 | int irq = platform_get_irq_byname(pdev, "mc"); | 2079 | int irq = platform_get_irq_byname(pdev, "mc"); |
@@ -2102,7 +2102,7 @@ static int __init musb_probe(struct platform_device *pdev) | |||
2102 | return status; | 2102 | return status; |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | static int __exit musb_remove(struct platform_device *pdev) | 2105 | static int __devexit musb_remove(struct platform_device *pdev) |
2106 | { | 2106 | { |
2107 | struct musb *musb = dev_to_musb(&pdev->dev); | 2107 | struct musb *musb = dev_to_musb(&pdev->dev); |
2108 | void __iomem *ctrl_base = musb->ctrl_base; | 2108 | void __iomem *ctrl_base = musb->ctrl_base; |
@@ -2112,11 +2112,9 @@ static int __exit musb_remove(struct platform_device *pdev) | |||
2112 | * - Peripheral mode: peripheral is deactivated (or never-activated) | 2112 | * - Peripheral mode: peripheral is deactivated (or never-activated) |
2113 | * - OTG mode: both roles are deactivated (or never-activated) | 2113 | * - OTG mode: both roles are deactivated (or never-activated) |
2114 | */ | 2114 | */ |
2115 | pm_runtime_get_sync(musb->controller); | ||
2116 | musb_exit_debugfs(musb); | 2115 | musb_exit_debugfs(musb); |
2117 | musb_shutdown(pdev); | 2116 | musb_shutdown(pdev); |
2118 | 2117 | ||
2119 | pm_runtime_put(musb->controller); | ||
2120 | musb_free(musb); | 2118 | musb_free(musb); |
2121 | iounmap(ctrl_base); | 2119 | iounmap(ctrl_base); |
2122 | device_init_wakeup(&pdev->dev, 0); | 2120 | device_init_wakeup(&pdev->dev, 0); |
@@ -2364,7 +2362,8 @@ static struct platform_driver musb_driver = { | |||
2364 | .owner = THIS_MODULE, | 2362 | .owner = THIS_MODULE, |
2365 | .pm = MUSB_DEV_PM_OPS, | 2363 | .pm = MUSB_DEV_PM_OPS, |
2366 | }, | 2364 | }, |
2367 | .remove = __exit_p(musb_remove), | 2365 | .probe = musb_probe, |
2366 | .remove = __devexit_p(musb_remove), | ||
2368 | .shutdown = musb_shutdown, | 2367 | .shutdown = musb_shutdown, |
2369 | }; | 2368 | }; |
2370 | 2369 | ||
@@ -2380,13 +2379,9 @@ static int __init musb_init(void) | |||
2380 | ", " | 2379 | ", " |
2381 | "otg (peripheral+host)", | 2380 | "otg (peripheral+host)", |
2382 | musb_driver_name); | 2381 | musb_driver_name); |
2383 | return platform_driver_probe(&musb_driver, musb_probe); | 2382 | return platform_driver_register(&musb_driver); |
2384 | } | 2383 | } |
2385 | 2384 | module_init(musb_init); | |
2386 | /* make us init after usbcore and i2c (transceivers, regulators, etc) | ||
2387 | * and before usb gadget and host-side drivers start to register | ||
2388 | */ | ||
2389 | fs_initcall(musb_init); | ||
2390 | 2385 | ||
2391 | static void __exit musb_cleanup(void) | 2386 | static void __exit musb_cleanup(void) |
2392 | { | 2387 | { |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 3d28fb8a2dc9..93de517a32a0 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
@@ -372,7 +372,7 @@ struct musb { | |||
372 | u16 int_rx; | 372 | u16 int_rx; |
373 | u16 int_tx; | 373 | u16 int_tx; |
374 | 374 | ||
375 | struct otg_transceiver *xceiv; | 375 | struct usb_phy *xceiv; |
376 | u8 xceiv_event; | 376 | u8 xceiv_event; |
377 | 377 | ||
378 | int nIrq; | 378 | int nIrq; |
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c index 13d9af9bf920..40a37c91cc10 100644 --- a/drivers/usb/musb/musb_debugfs.c +++ b/drivers/usb/musb/musb_debugfs.c | |||
@@ -235,29 +235,29 @@ static const struct file_operations musb_test_mode_fops = { | |||
235 | .release = single_release, | 235 | .release = single_release, |
236 | }; | 236 | }; |
237 | 237 | ||
238 | int __init musb_init_debugfs(struct musb *musb) | 238 | int __devinit musb_init_debugfs(struct musb *musb) |
239 | { | 239 | { |
240 | struct dentry *root; | 240 | struct dentry *root; |
241 | struct dentry *file; | 241 | struct dentry *file; |
242 | int ret; | 242 | int ret; |
243 | 243 | ||
244 | root = debugfs_create_dir("musb", NULL); | 244 | root = debugfs_create_dir("musb", NULL); |
245 | if (IS_ERR(root)) { | 245 | if (!root) { |
246 | ret = PTR_ERR(root); | 246 | ret = -ENOMEM; |
247 | goto err0; | 247 | goto err0; |
248 | } | 248 | } |
249 | 249 | ||
250 | file = debugfs_create_file("regdump", S_IRUGO, root, musb, | 250 | file = debugfs_create_file("regdump", S_IRUGO, root, musb, |
251 | &musb_regdump_fops); | 251 | &musb_regdump_fops); |
252 | if (IS_ERR(file)) { | 252 | if (!file) { |
253 | ret = PTR_ERR(file); | 253 | ret = -ENOMEM; |
254 | goto err1; | 254 | goto err1; |
255 | } | 255 | } |
256 | 256 | ||
257 | file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, | 257 | file = debugfs_create_file("testmode", S_IRUGO | S_IWUSR, |
258 | root, musb, &musb_test_mode_fops); | 258 | root, musb, &musb_test_mode_fops); |
259 | if (IS_ERR(file)) { | 259 | if (!file) { |
260 | ret = PTR_ERR(file); | 260 | ret = -ENOMEM; |
261 | goto err1; | 261 | goto err1; |
262 | } | 262 | } |
263 | 263 | ||
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index ac3d2eec20fe..f42c29b11f71 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
@@ -574,6 +574,15 @@ void musb_g_tx(struct musb *musb, u8 epnum) | |||
574 | 574 | ||
575 | if (request->actual == request->length) { | 575 | if (request->actual == request->length) { |
576 | musb_g_giveback(musb_ep, request, 0); | 576 | musb_g_giveback(musb_ep, request, 0); |
577 | /* | ||
578 | * In the giveback function the MUSB lock is | ||
579 | * released and acquired after sometime. During | ||
580 | * this time period the INDEX register could get | ||
581 | * changed by the gadget_queue function especially | ||
582 | * on SMP systems. Reselect the INDEX to be sure | ||
583 | * we are reading/modifying the right registers | ||
584 | */ | ||
585 | musb_ep_select(mbase, epnum); | ||
577 | req = musb_ep->desc ? next_request(musb_ep) : NULL; | 586 | req = musb_ep->desc ? next_request(musb_ep) : NULL; |
578 | if (!req) { | 587 | if (!req) { |
579 | dev_dbg(musb->controller, "%s idle now\n", | 588 | dev_dbg(musb->controller, "%s idle now\n", |
@@ -983,6 +992,15 @@ void musb_g_rx(struct musb *musb, u8 epnum) | |||
983 | } | 992 | } |
984 | #endif | 993 | #endif |
985 | musb_g_giveback(musb_ep, request, 0); | 994 | musb_g_giveback(musb_ep, request, 0); |
995 | /* | ||
996 | * In the giveback function the MUSB lock is | ||
997 | * released and acquired after sometime. During | ||
998 | * this time period the INDEX register could get | ||
999 | * changed by the gadget_queue function especially | ||
1000 | * on SMP systems. Reselect the INDEX to be sure | ||
1001 | * we are reading/modifying the right registers | ||
1002 | */ | ||
1003 | musb_ep_select(mbase, epnum); | ||
986 | 1004 | ||
987 | req = next_request(musb_ep); | 1005 | req = next_request(musb_ep); |
988 | if (!req) | 1006 | if (!req) |
@@ -1624,7 +1642,7 @@ static int musb_gadget_wakeup(struct usb_gadget *gadget) | |||
1624 | } | 1642 | } |
1625 | 1643 | ||
1626 | spin_unlock_irqrestore(&musb->lock, flags); | 1644 | spin_unlock_irqrestore(&musb->lock, flags); |
1627 | otg_start_srp(musb->xceiv); | 1645 | otg_start_srp(musb->xceiv->otg); |
1628 | spin_lock_irqsave(&musb->lock, flags); | 1646 | spin_lock_irqsave(&musb->lock, flags); |
1629 | 1647 | ||
1630 | /* Block idling for at least 1s */ | 1648 | /* Block idling for at least 1s */ |
@@ -1703,7 +1721,7 @@ static int musb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA) | |||
1703 | 1721 | ||
1704 | if (!musb->xceiv->set_power) | 1722 | if (!musb->xceiv->set_power) |
1705 | return -EOPNOTSUPP; | 1723 | return -EOPNOTSUPP; |
1706 | return otg_set_power(musb->xceiv, mA); | 1724 | return usb_phy_set_power(musb->xceiv, mA); |
1707 | } | 1725 | } |
1708 | 1726 | ||
1709 | static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) | 1727 | static int musb_gadget_pullup(struct usb_gadget *gadget, int is_on) |
@@ -1762,7 +1780,7 @@ static void musb_gadget_release(struct device *dev) | |||
1762 | } | 1780 | } |
1763 | 1781 | ||
1764 | 1782 | ||
1765 | static void __init | 1783 | static void __devinit |
1766 | init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) | 1784 | init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) |
1767 | { | 1785 | { |
1768 | struct musb_hw_ep *hw_ep = musb->endpoints + epnum; | 1786 | struct musb_hw_ep *hw_ep = musb->endpoints + epnum; |
@@ -1799,7 +1817,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) | |||
1799 | * Initialize the endpoints exposed to peripheral drivers, with backlinks | 1817 | * Initialize the endpoints exposed to peripheral drivers, with backlinks |
1800 | * to the rest of the driver state. | 1818 | * to the rest of the driver state. |
1801 | */ | 1819 | */ |
1802 | static inline void __init musb_g_init_endpoints(struct musb *musb) | 1820 | static inline void __devinit musb_g_init_endpoints(struct musb *musb) |
1803 | { | 1821 | { |
1804 | u8 epnum; | 1822 | u8 epnum; |
1805 | struct musb_hw_ep *hw_ep; | 1823 | struct musb_hw_ep *hw_ep; |
@@ -1832,7 +1850,7 @@ static inline void __init musb_g_init_endpoints(struct musb *musb) | |||
1832 | /* called once during driver setup to initialize and link into | 1850 | /* called once during driver setup to initialize and link into |
1833 | * the driver model; memory is zeroed. | 1851 | * the driver model; memory is zeroed. |
1834 | */ | 1852 | */ |
1835 | int __init musb_gadget_setup(struct musb *musb) | 1853 | int __devinit musb_gadget_setup(struct musb *musb) |
1836 | { | 1854 | { |
1837 | int status; | 1855 | int status; |
1838 | 1856 | ||
@@ -1898,6 +1916,7 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1898 | struct usb_gadget_driver *driver) | 1916 | struct usb_gadget_driver *driver) |
1899 | { | 1917 | { |
1900 | struct musb *musb = gadget_to_musb(g); | 1918 | struct musb *musb = gadget_to_musb(g); |
1919 | struct usb_otg *otg = musb->xceiv->otg; | ||
1901 | unsigned long flags; | 1920 | unsigned long flags; |
1902 | int retval = -EINVAL; | 1921 | int retval = -EINVAL; |
1903 | 1922 | ||
@@ -1914,7 +1933,7 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1914 | spin_lock_irqsave(&musb->lock, flags); | 1933 | spin_lock_irqsave(&musb->lock, flags); |
1915 | musb->is_active = 1; | 1934 | musb->is_active = 1; |
1916 | 1935 | ||
1917 | otg_set_peripheral(musb->xceiv, &musb->g); | 1936 | otg_set_peripheral(otg, &musb->g); |
1918 | musb->xceiv->state = OTG_STATE_B_IDLE; | 1937 | musb->xceiv->state = OTG_STATE_B_IDLE; |
1919 | 1938 | ||
1920 | /* | 1939 | /* |
@@ -1938,15 +1957,15 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
1938 | * handles power budgeting ... this way also | 1957 | * handles power budgeting ... this way also |
1939 | * ensures HdrcStart is indirectly called. | 1958 | * ensures HdrcStart is indirectly called. |
1940 | */ | 1959 | */ |
1941 | retval = usb_add_hcd(musb_to_hcd(musb), -1, 0); | 1960 | retval = usb_add_hcd(musb_to_hcd(musb), 0, 0); |
1942 | if (retval < 0) { | 1961 | if (retval < 0) { |
1943 | dev_dbg(musb->controller, "add_hcd failed, %d\n", retval); | 1962 | dev_dbg(musb->controller, "add_hcd failed, %d\n", retval); |
1944 | goto err2; | 1963 | goto err2; |
1945 | } | 1964 | } |
1946 | 1965 | ||
1947 | if ((musb->xceiv->last_event == USB_EVENT_ID) | 1966 | if ((musb->xceiv->last_event == USB_EVENT_ID) |
1948 | && musb->xceiv->set_vbus) | 1967 | && otg->set_vbus) |
1949 | otg_set_vbus(musb->xceiv, 1); | 1968 | otg_set_vbus(otg, 1); |
1950 | 1969 | ||
1951 | hcd->self.uses_pio_for_control = 1; | 1970 | hcd->self.uses_pio_for_control = 1; |
1952 | } | 1971 | } |
@@ -2028,7 +2047,7 @@ static int musb_gadget_stop(struct usb_gadget *g, | |||
2028 | 2047 | ||
2029 | musb->xceiv->state = OTG_STATE_UNDEFINED; | 2048 | musb->xceiv->state = OTG_STATE_UNDEFINED; |
2030 | stop_activity(musb, driver); | 2049 | stop_activity(musb, driver); |
2031 | otg_set_peripheral(musb->xceiv, NULL); | 2050 | otg_set_peripheral(musb->xceiv->otg, NULL); |
2032 | 2051 | ||
2033 | dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); | 2052 | dev_dbg(musb->controller, "unregistering driver %s\n", driver->function); |
2034 | 2053 | ||
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index e9f80adc45a4..22ec3e379980 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
@@ -47,6 +47,7 @@ | |||
47 | 47 | ||
48 | static void musb_port_suspend(struct musb *musb, bool do_suspend) | 48 | static void musb_port_suspend(struct musb *musb, bool do_suspend) |
49 | { | 49 | { |
50 | struct usb_otg *otg = musb->xceiv->otg; | ||
50 | u8 power; | 51 | u8 power; |
51 | void __iomem *mbase = musb->mregs; | 52 | void __iomem *mbase = musb->mregs; |
52 | 53 | ||
@@ -81,7 +82,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) | |||
81 | case OTG_STATE_A_HOST: | 82 | case OTG_STATE_A_HOST: |
82 | musb->xceiv->state = OTG_STATE_A_SUSPEND; | 83 | musb->xceiv->state = OTG_STATE_A_SUSPEND; |
83 | musb->is_active = is_otg_enabled(musb) | 84 | musb->is_active = is_otg_enabled(musb) |
84 | && musb->xceiv->host->b_hnp_enable; | 85 | && otg->host->b_hnp_enable; |
85 | if (musb->is_active) | 86 | if (musb->is_active) |
86 | mod_timer(&musb->otg_timer, jiffies | 87 | mod_timer(&musb->otg_timer, jiffies |
87 | + msecs_to_jiffies( | 88 | + msecs_to_jiffies( |
@@ -91,7 +92,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) | |||
91 | case OTG_STATE_B_HOST: | 92 | case OTG_STATE_B_HOST: |
92 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; | 93 | musb->xceiv->state = OTG_STATE_B_WAIT_ACON; |
93 | musb->is_active = is_otg_enabled(musb) | 94 | musb->is_active = is_otg_enabled(musb) |
94 | && musb->xceiv->host->b_hnp_enable; | 95 | && otg->host->b_hnp_enable; |
95 | musb_platform_try_idle(musb, 0); | 96 | musb_platform_try_idle(musb, 0); |
96 | break; | 97 | break; |
97 | default: | 98 | default: |
@@ -179,6 +180,8 @@ static void musb_port_reset(struct musb *musb, bool do_reset) | |||
179 | 180 | ||
180 | void musb_root_disconnect(struct musb *musb) | 181 | void musb_root_disconnect(struct musb *musb) |
181 | { | 182 | { |
183 | struct usb_otg *otg = musb->xceiv->otg; | ||
184 | |||
182 | musb->port1_status = USB_PORT_STAT_POWER | 185 | musb->port1_status = USB_PORT_STAT_POWER |
183 | | (USB_PORT_STAT_C_CONNECTION << 16); | 186 | | (USB_PORT_STAT_C_CONNECTION << 16); |
184 | 187 | ||
@@ -188,7 +191,7 @@ void musb_root_disconnect(struct musb *musb) | |||
188 | switch (musb->xceiv->state) { | 191 | switch (musb->xceiv->state) { |
189 | case OTG_STATE_A_SUSPEND: | 192 | case OTG_STATE_A_SUSPEND: |
190 | if (is_otg_enabled(musb) | 193 | if (is_otg_enabled(musb) |
191 | && musb->xceiv->host->b_hnp_enable) { | 194 | && otg->host->b_hnp_enable) { |
192 | musb->xceiv->state = OTG_STATE_A_PERIPHERAL; | 195 | musb->xceiv->state = OTG_STATE_A_PERIPHERAL; |
193 | musb->g.is_a_peripheral = 1; | 196 | musb->g.is_a_peripheral = 1; |
194 | break; | 197 | break; |
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index df719eae3b03..2ae0bb309994 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c | |||
@@ -132,6 +132,7 @@ static void omap2430_musb_try_idle(struct musb *musb, unsigned long timeout) | |||
132 | 132 | ||
133 | static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | 133 | static void omap2430_musb_set_vbus(struct musb *musb, int is_on) |
134 | { | 134 | { |
135 | struct usb_otg *otg = musb->xceiv->otg; | ||
135 | u8 devctl; | 136 | u8 devctl; |
136 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); | 137 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); |
137 | int ret = 1; | 138 | int ret = 1; |
@@ -163,11 +164,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | |||
163 | } | 164 | } |
164 | } | 165 | } |
165 | 166 | ||
166 | if (ret && musb->xceiv->set_vbus) | 167 | if (ret && otg->set_vbus) |
167 | otg_set_vbus(musb->xceiv, 1); | 168 | otg_set_vbus(otg, 1); |
168 | } else { | 169 | } else { |
169 | musb->is_active = 1; | 170 | musb->is_active = 1; |
170 | musb->xceiv->default_a = 1; | 171 | otg->default_a = 1; |
171 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 172 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
172 | devctl |= MUSB_DEVCTL_SESSION; | 173 | devctl |= MUSB_DEVCTL_SESSION; |
173 | MUSB_HST_MODE(musb); | 174 | MUSB_HST_MODE(musb); |
@@ -179,7 +180,7 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) | |||
179 | * jumping right to B_IDLE... | 180 | * jumping right to B_IDLE... |
180 | */ | 181 | */ |
181 | 182 | ||
182 | musb->xceiv->default_a = 0; | 183 | otg->default_a = 0; |
183 | musb->xceiv->state = OTG_STATE_B_IDLE; | 184 | musb->xceiv->state = OTG_STATE_B_IDLE; |
184 | devctl &= ~MUSB_DEVCTL_SESSION; | 185 | devctl &= ~MUSB_DEVCTL_SESSION; |
185 | 186 | ||
@@ -246,7 +247,7 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work) | |||
246 | 247 | ||
247 | if (!is_otg_enabled(musb) || musb->gadget_driver) { | 248 | if (!is_otg_enabled(musb) || musb->gadget_driver) { |
248 | pm_runtime_get_sync(musb->controller); | 249 | pm_runtime_get_sync(musb->controller); |
249 | otg_init(musb->xceiv); | 250 | usb_phy_init(musb->xceiv); |
250 | omap2430_musb_set_vbus(musb, 1); | 251 | omap2430_musb_set_vbus(musb, 1); |
251 | } | 252 | } |
252 | break; | 253 | break; |
@@ -256,7 +257,7 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work) | |||
256 | 257 | ||
257 | if (musb->gadget_driver) | 258 | if (musb->gadget_driver) |
258 | pm_runtime_get_sync(musb->controller); | 259 | pm_runtime_get_sync(musb->controller); |
259 | otg_init(musb->xceiv); | 260 | usb_phy_init(musb->xceiv); |
260 | break; | 261 | break; |
261 | 262 | ||
262 | case USB_EVENT_NONE: | 263 | case USB_EVENT_NONE: |
@@ -269,10 +270,10 @@ static void musb_otg_notifier_work(struct work_struct *data_notifier_work) | |||
269 | } | 270 | } |
270 | 271 | ||
271 | if (data->interface_type == MUSB_INTERFACE_UTMI) { | 272 | if (data->interface_type == MUSB_INTERFACE_UTMI) { |
272 | if (musb->xceiv->set_vbus) | 273 | if (musb->xceiv->otg->set_vbus) |
273 | otg_set_vbus(musb->xceiv, 0); | 274 | otg_set_vbus(musb->xceiv->otg, 0); |
274 | } | 275 | } |
275 | otg_shutdown(musb->xceiv); | 276 | usb_phy_shutdown(musb->xceiv); |
276 | break; | 277 | break; |
277 | default: | 278 | default: |
278 | dev_dbg(musb->controller, "ID float\n"); | 279 | dev_dbg(musb->controller, "ID float\n"); |
@@ -290,7 +291,7 @@ static int omap2430_musb_init(struct musb *musb) | |||
290 | * up through ULPI. TWL4030-family PMICs include one, | 291 | * up through ULPI. TWL4030-family PMICs include one, |
291 | * which needs a driver, drivers aren't always needed. | 292 | * which needs a driver, drivers aren't always needed. |
292 | */ | 293 | */ |
293 | musb->xceiv = otg_get_transceiver(); | 294 | musb->xceiv = usb_get_transceiver(); |
294 | if (!musb->xceiv) { | 295 | if (!musb->xceiv) { |
295 | pr_err("HS USB OTG: no transceiver configured\n"); | 296 | pr_err("HS USB OTG: no transceiver configured\n"); |
296 | return -ENODEV; | 297 | return -ENODEV; |
@@ -325,7 +326,7 @@ static int omap2430_musb_init(struct musb *musb) | |||
325 | musb_readl(musb->mregs, OTG_SIMENABLE)); | 326 | musb_readl(musb->mregs, OTG_SIMENABLE)); |
326 | 327 | ||
327 | musb->nb.notifier_call = musb_otg_notifications; | 328 | musb->nb.notifier_call = musb_otg_notifications; |
328 | status = otg_register_notifier(musb->xceiv, &musb->nb); | 329 | status = usb_register_notifier(musb->xceiv, &musb->nb); |
329 | 330 | ||
330 | if (status) | 331 | if (status) |
331 | dev_dbg(musb->controller, "notification register failed\n"); | 332 | dev_dbg(musb->controller, "notification register failed\n"); |
@@ -349,7 +350,7 @@ static void omap2430_musb_enable(struct musb *musb) | |||
349 | switch (musb->xceiv->last_event) { | 350 | switch (musb->xceiv->last_event) { |
350 | 351 | ||
351 | case USB_EVENT_ID: | 352 | case USB_EVENT_ID: |
352 | otg_init(musb->xceiv); | 353 | usb_phy_init(musb->xceiv); |
353 | if (data->interface_type != MUSB_INTERFACE_UTMI) | 354 | if (data->interface_type != MUSB_INTERFACE_UTMI) |
354 | break; | 355 | break; |
355 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); | 356 | devctl = musb_readb(musb->mregs, MUSB_DEVCTL); |
@@ -368,7 +369,7 @@ static void omap2430_musb_enable(struct musb *musb) | |||
368 | break; | 369 | break; |
369 | 370 | ||
370 | case USB_EVENT_VBUS: | 371 | case USB_EVENT_VBUS: |
371 | otg_init(musb->xceiv); | 372 | usb_phy_init(musb->xceiv); |
372 | break; | 373 | break; |
373 | 374 | ||
374 | default: | 375 | default: |
@@ -379,7 +380,7 @@ static void omap2430_musb_enable(struct musb *musb) | |||
379 | static void omap2430_musb_disable(struct musb *musb) | 380 | static void omap2430_musb_disable(struct musb *musb) |
380 | { | 381 | { |
381 | if (musb->xceiv->last_event) | 382 | if (musb->xceiv->last_event) |
382 | otg_shutdown(musb->xceiv); | 383 | usb_phy_shutdown(musb->xceiv); |
383 | } | 384 | } |
384 | 385 | ||
385 | static int omap2430_musb_exit(struct musb *musb) | 386 | static int omap2430_musb_exit(struct musb *musb) |
@@ -388,7 +389,7 @@ static int omap2430_musb_exit(struct musb *musb) | |||
388 | cancel_work_sync(&musb->otg_notifier_work); | 389 | cancel_work_sync(&musb->otg_notifier_work); |
389 | 390 | ||
390 | omap2430_low_level_exit(musb); | 391 | omap2430_low_level_exit(musb); |
391 | otg_put_transceiver(musb->xceiv); | 392 | usb_put_transceiver(musb->xceiv); |
392 | 393 | ||
393 | return 0; | 394 | return 0; |
394 | } | 395 | } |
@@ -408,7 +409,7 @@ static const struct musb_platform_ops omap2430_ops = { | |||
408 | 409 | ||
409 | static u64 omap2430_dmamask = DMA_BIT_MASK(32); | 410 | static u64 omap2430_dmamask = DMA_BIT_MASK(32); |
410 | 411 | ||
411 | static int __init omap2430_probe(struct platform_device *pdev) | 412 | static int __devinit omap2430_probe(struct platform_device *pdev) |
412 | { | 413 | { |
413 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 414 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
414 | struct platform_device *musb; | 415 | struct platform_device *musb; |
@@ -471,7 +472,7 @@ err0: | |||
471 | return ret; | 472 | return ret; |
472 | } | 473 | } |
473 | 474 | ||
474 | static int __exit omap2430_remove(struct platform_device *pdev) | 475 | static int __devexit omap2430_remove(struct platform_device *pdev) |
475 | { | 476 | { |
476 | struct omap2430_glue *glue = platform_get_drvdata(pdev); | 477 | struct omap2430_glue *glue = platform_get_drvdata(pdev); |
477 | 478 | ||
@@ -494,7 +495,7 @@ static int omap2430_runtime_suspend(struct device *dev) | |||
494 | OTG_INTERFSEL); | 495 | OTG_INTERFSEL); |
495 | 496 | ||
496 | omap2430_low_level_exit(musb); | 497 | omap2430_low_level_exit(musb); |
497 | otg_set_suspend(musb->xceiv, 1); | 498 | usb_phy_set_suspend(musb->xceiv, 1); |
498 | 499 | ||
499 | return 0; | 500 | return 0; |
500 | } | 501 | } |
@@ -508,7 +509,7 @@ static int omap2430_runtime_resume(struct device *dev) | |||
508 | musb_writel(musb->mregs, OTG_INTERFSEL, | 509 | musb_writel(musb->mregs, OTG_INTERFSEL, |
509 | musb->context.otg_interfsel); | 510 | musb->context.otg_interfsel); |
510 | 511 | ||
511 | otg_set_suspend(musb->xceiv, 0); | 512 | usb_phy_set_suspend(musb->xceiv, 0); |
512 | 513 | ||
513 | return 0; | 514 | return 0; |
514 | } | 515 | } |
@@ -524,7 +525,8 @@ static struct dev_pm_ops omap2430_pm_ops = { | |||
524 | #endif | 525 | #endif |
525 | 526 | ||
526 | static struct platform_driver omap2430_driver = { | 527 | static struct platform_driver omap2430_driver = { |
527 | .remove = __exit_p(omap2430_remove), | 528 | .probe = omap2430_probe, |
529 | .remove = __devexit_p(omap2430_remove), | ||
528 | .driver = { | 530 | .driver = { |
529 | .name = "musb-omap2430", | 531 | .name = "musb-omap2430", |
530 | .pm = DEV_PM_OPS, | 532 | .pm = DEV_PM_OPS, |
@@ -537,9 +539,9 @@ MODULE_LICENSE("GPL v2"); | |||
537 | 539 | ||
538 | static int __init omap2430_init(void) | 540 | static int __init omap2430_init(void) |
539 | { | 541 | { |
540 | return platform_driver_probe(&omap2430_driver, omap2430_probe); | 542 | return platform_driver_register(&omap2430_driver); |
541 | } | 543 | } |
542 | subsys_initcall(omap2430_init); | 544 | module_init(omap2430_init); |
543 | 545 | ||
544 | static void __exit omap2430_exit(void) | 546 | static void __exit omap2430_exit(void) |
545 | { | 547 | { |
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index 1f405616e6cd..de1355946a83 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c | |||
@@ -277,7 +277,7 @@ static struct musb *the_musb; | |||
277 | * mode), or low power Default-B sessions, something else supplies power. | 277 | * mode), or low power Default-B sessions, something else supplies power. |
278 | * Caller must take care of locking. | 278 | * Caller must take care of locking. |
279 | */ | 279 | */ |
280 | static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) | 280 | static int tusb_draw_power(struct usb_phy *x, unsigned mA) |
281 | { | 281 | { |
282 | struct musb *musb = the_musb; | 282 | struct musb *musb = the_musb; |
283 | void __iomem *tbase = musb->ctrl_base; | 283 | void __iomem *tbase = musb->ctrl_base; |
@@ -293,7 +293,7 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) | |||
293 | * The actual current usage would be very board-specific. For now, | 293 | * The actual current usage would be very board-specific. For now, |
294 | * it's simpler to just use an aggregate (also board-specific). | 294 | * it's simpler to just use an aggregate (also board-specific). |
295 | */ | 295 | */ |
296 | if (x->default_a || mA < (musb->min_power << 1)) | 296 | if (x->otg->default_a || mA < (musb->min_power << 1)) |
297 | mA = 0; | 297 | mA = 0; |
298 | 298 | ||
299 | reg = musb_readl(tbase, TUSB_PRCM_MNGMT); | 299 | reg = musb_readl(tbase, TUSB_PRCM_MNGMT); |
@@ -510,6 +510,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) | |||
510 | void __iomem *tbase = musb->ctrl_base; | 510 | void __iomem *tbase = musb->ctrl_base; |
511 | u32 conf, prcm, timer; | 511 | u32 conf, prcm, timer; |
512 | u8 devctl; | 512 | u8 devctl; |
513 | struct usb_otg *otg = musb->xceiv->otg; | ||
513 | 514 | ||
514 | /* HDRC controls CPEN, but beware current surges during device | 515 | /* HDRC controls CPEN, but beware current surges during device |
515 | * connect. They can trigger transient overcurrent conditions | 516 | * connect. They can trigger transient overcurrent conditions |
@@ -522,7 +523,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) | |||
522 | 523 | ||
523 | if (is_on) { | 524 | if (is_on) { |
524 | timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); | 525 | timer = OTG_TIMER_MS(OTG_TIME_A_WAIT_VRISE); |
525 | musb->xceiv->default_a = 1; | 526 | otg->default_a = 1; |
526 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 527 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
527 | devctl |= MUSB_DEVCTL_SESSION; | 528 | devctl |= MUSB_DEVCTL_SESSION; |
528 | 529 | ||
@@ -548,11 +549,11 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) | |||
548 | musb->xceiv->state = OTG_STATE_A_IDLE; | 549 | musb->xceiv->state = OTG_STATE_A_IDLE; |
549 | } | 550 | } |
550 | musb->is_active = 0; | 551 | musb->is_active = 0; |
551 | musb->xceiv->default_a = 1; | 552 | otg->default_a = 1; |
552 | MUSB_HST_MODE(musb); | 553 | MUSB_HST_MODE(musb); |
553 | } else { | 554 | } else { |
554 | musb->is_active = 0; | 555 | musb->is_active = 0; |
555 | musb->xceiv->default_a = 0; | 556 | otg->default_a = 0; |
556 | musb->xceiv->state = OTG_STATE_B_IDLE; | 557 | musb->xceiv->state = OTG_STATE_B_IDLE; |
557 | MUSB_DEV_MODE(musb); | 558 | MUSB_DEV_MODE(musb); |
558 | } | 559 | } |
@@ -644,6 +645,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
644 | { | 645 | { |
645 | u32 otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); | 646 | u32 otg_stat = musb_readl(tbase, TUSB_DEV_OTG_STAT); |
646 | unsigned long idle_timeout = 0; | 647 | unsigned long idle_timeout = 0; |
648 | struct usb_otg *otg = musb->xceiv->otg; | ||
647 | 649 | ||
648 | /* ID pin */ | 650 | /* ID pin */ |
649 | if ((int_src & TUSB_INT_SRC_ID_STATUS_CHNG)) { | 651 | if ((int_src & TUSB_INT_SRC_ID_STATUS_CHNG)) { |
@@ -654,7 +656,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
654 | else | 656 | else |
655 | default_a = is_host_enabled(musb); | 657 | default_a = is_host_enabled(musb); |
656 | dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B'); | 658 | dev_dbg(musb->controller, "Default-%c\n", default_a ? 'A' : 'B'); |
657 | musb->xceiv->default_a = default_a; | 659 | otg->default_a = default_a; |
658 | tusb_musb_set_vbus(musb, default_a); | 660 | tusb_musb_set_vbus(musb, default_a); |
659 | 661 | ||
660 | /* Don't allow idling immediately */ | 662 | /* Don't allow idling immediately */ |
@@ -666,7 +668,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | |||
666 | if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) { | 668 | if (int_src & TUSB_INT_SRC_VBUS_SENSE_CHNG) { |
667 | 669 | ||
668 | /* B-dev state machine: no vbus ~= disconnect */ | 670 | /* B-dev state machine: no vbus ~= disconnect */ |
669 | if ((is_otg_enabled(musb) && !musb->xceiv->default_a) | 671 | if ((is_otg_enabled(musb) && !otg->default_a) |
670 | || !is_host_enabled(musb)) { | 672 | || !is_host_enabled(musb)) { |
671 | /* ? musb_root_disconnect(musb); */ | 673 | /* ? musb_root_disconnect(musb); */ |
672 | musb->port1_status &= | 674 | musb->port1_status &= |
@@ -1076,7 +1078,7 @@ static int tusb_musb_init(struct musb *musb) | |||
1076 | int ret; | 1078 | int ret; |
1077 | 1079 | ||
1078 | usb_nop_xceiv_register(); | 1080 | usb_nop_xceiv_register(); |
1079 | musb->xceiv = otg_get_transceiver(); | 1081 | musb->xceiv = usb_get_transceiver(); |
1080 | if (!musb->xceiv) | 1082 | if (!musb->xceiv) |
1081 | return -ENODEV; | 1083 | return -ENODEV; |
1082 | 1084 | ||
@@ -1128,7 +1130,7 @@ done: | |||
1128 | if (sync) | 1130 | if (sync) |
1129 | iounmap(sync); | 1131 | iounmap(sync); |
1130 | 1132 | ||
1131 | otg_put_transceiver(musb->xceiv); | 1133 | usb_put_transceiver(musb->xceiv); |
1132 | usb_nop_xceiv_unregister(); | 1134 | usb_nop_xceiv_unregister(); |
1133 | } | 1135 | } |
1134 | return ret; | 1136 | return ret; |
@@ -1144,7 +1146,7 @@ static int tusb_musb_exit(struct musb *musb) | |||
1144 | 1146 | ||
1145 | iounmap(musb->sync_va); | 1147 | iounmap(musb->sync_va); |
1146 | 1148 | ||
1147 | otg_put_transceiver(musb->xceiv); | 1149 | usb_put_transceiver(musb->xceiv); |
1148 | usb_nop_xceiv_unregister(); | 1150 | usb_nop_xceiv_unregister(); |
1149 | return 0; | 1151 | return 0; |
1150 | } | 1152 | } |
@@ -1165,7 +1167,7 @@ static const struct musb_platform_ops tusb_ops = { | |||
1165 | 1167 | ||
1166 | static u64 tusb_dmamask = DMA_BIT_MASK(32); | 1168 | static u64 tusb_dmamask = DMA_BIT_MASK(32); |
1167 | 1169 | ||
1168 | static int __init tusb_probe(struct platform_device *pdev) | 1170 | static int __devinit tusb_probe(struct platform_device *pdev) |
1169 | { | 1171 | { |
1170 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 1172 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
1171 | struct platform_device *musb; | 1173 | struct platform_device *musb; |
@@ -1227,7 +1229,7 @@ err0: | |||
1227 | return ret; | 1229 | return ret; |
1228 | } | 1230 | } |
1229 | 1231 | ||
1230 | static int __exit tusb_remove(struct platform_device *pdev) | 1232 | static int __devexit tusb_remove(struct platform_device *pdev) |
1231 | { | 1233 | { |
1232 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); | 1234 | struct tusb6010_glue *glue = platform_get_drvdata(pdev); |
1233 | 1235 | ||
@@ -1239,7 +1241,8 @@ static int __exit tusb_remove(struct platform_device *pdev) | |||
1239 | } | 1241 | } |
1240 | 1242 | ||
1241 | static struct platform_driver tusb_driver = { | 1243 | static struct platform_driver tusb_driver = { |
1242 | .remove = __exit_p(tusb_remove), | 1244 | .probe = tusb_probe, |
1245 | .remove = __devexit_p(tusb_remove), | ||
1243 | .driver = { | 1246 | .driver = { |
1244 | .name = "musb-tusb", | 1247 | .name = "musb-tusb", |
1245 | }, | 1248 | }, |
@@ -1251,9 +1254,9 @@ MODULE_LICENSE("GPL v2"); | |||
1251 | 1254 | ||
1252 | static int __init tusb_init(void) | 1255 | static int __init tusb_init(void) |
1253 | { | 1256 | { |
1254 | return platform_driver_probe(&tusb_driver, tusb_probe); | 1257 | return platform_driver_register(&tusb_driver); |
1255 | } | 1258 | } |
1256 | subsys_initcall(tusb_init); | 1259 | module_init(tusb_init); |
1257 | 1260 | ||
1258 | static void __exit tusb_exit(void) | 1261 | static void __exit tusb_exit(void) |
1259 | { | 1262 | { |
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index f7e04bf34a13..aa09dd417b94 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c | |||
@@ -37,7 +37,7 @@ struct ux500_glue { | |||
37 | 37 | ||
38 | static int ux500_musb_init(struct musb *musb) | 38 | static int ux500_musb_init(struct musb *musb) |
39 | { | 39 | { |
40 | musb->xceiv = otg_get_transceiver(); | 40 | musb->xceiv = usb_get_transceiver(); |
41 | if (!musb->xceiv) { | 41 | if (!musb->xceiv) { |
42 | pr_err("HS USB OTG: no transceiver configured\n"); | 42 | pr_err("HS USB OTG: no transceiver configured\n"); |
43 | return -ENODEV; | 43 | return -ENODEV; |
@@ -48,7 +48,7 @@ static int ux500_musb_init(struct musb *musb) | |||
48 | 48 | ||
49 | static int ux500_musb_exit(struct musb *musb) | 49 | static int ux500_musb_exit(struct musb *musb) |
50 | { | 50 | { |
51 | otg_put_transceiver(musb->xceiv); | 51 | usb_put_transceiver(musb->xceiv); |
52 | 52 | ||
53 | return 0; | 53 | return 0; |
54 | } | 54 | } |
@@ -58,7 +58,7 @@ static const struct musb_platform_ops ux500_ops = { | |||
58 | .exit = ux500_musb_exit, | 58 | .exit = ux500_musb_exit, |
59 | }; | 59 | }; |
60 | 60 | ||
61 | static int __init ux500_probe(struct platform_device *pdev) | 61 | static int __devinit ux500_probe(struct platform_device *pdev) |
62 | { | 62 | { |
63 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; | 63 | struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; |
64 | struct platform_device *musb; | 64 | struct platform_device *musb; |
@@ -141,7 +141,7 @@ err0: | |||
141 | return ret; | 141 | return ret; |
142 | } | 142 | } |
143 | 143 | ||
144 | static int __exit ux500_remove(struct platform_device *pdev) | 144 | static int __devexit ux500_remove(struct platform_device *pdev) |
145 | { | 145 | { |
146 | struct ux500_glue *glue = platform_get_drvdata(pdev); | 146 | struct ux500_glue *glue = platform_get_drvdata(pdev); |
147 | 147 | ||
@@ -160,7 +160,7 @@ static int ux500_suspend(struct device *dev) | |||
160 | struct ux500_glue *glue = dev_get_drvdata(dev); | 160 | struct ux500_glue *glue = dev_get_drvdata(dev); |
161 | struct musb *musb = glue_to_musb(glue); | 161 | struct musb *musb = glue_to_musb(glue); |
162 | 162 | ||
163 | otg_set_suspend(musb->xceiv, 1); | 163 | usb_phy_set_suspend(musb->xceiv, 1); |
164 | clk_disable(glue->clk); | 164 | clk_disable(glue->clk); |
165 | 165 | ||
166 | return 0; | 166 | return 0; |
@@ -178,7 +178,7 @@ static int ux500_resume(struct device *dev) | |||
178 | return ret; | 178 | return ret; |
179 | } | 179 | } |
180 | 180 | ||
181 | otg_set_suspend(musb->xceiv, 0); | 181 | usb_phy_set_suspend(musb->xceiv, 0); |
182 | 182 | ||
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
@@ -194,7 +194,8 @@ static const struct dev_pm_ops ux500_pm_ops = { | |||
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | static struct platform_driver ux500_driver = { | 196 | static struct platform_driver ux500_driver = { |
197 | .remove = __exit_p(ux500_remove), | 197 | .probe = ux500_probe, |
198 | .remove = __devexit_p(ux500_remove), | ||
198 | .driver = { | 199 | .driver = { |
199 | .name = "musb-ux500", | 200 | .name = "musb-ux500", |
200 | .pm = DEV_PM_OPS, | 201 | .pm = DEV_PM_OPS, |
@@ -207,9 +208,9 @@ MODULE_LICENSE("GPL v2"); | |||
207 | 208 | ||
208 | static int __init ux500_init(void) | 209 | static int __init ux500_init(void) |
209 | { | 210 | { |
210 | return platform_driver_probe(&ux500_driver, ux500_probe); | 211 | return platform_driver_register(&ux500_driver); |
211 | } | 212 | } |
212 | subsys_initcall(ux500_init); | 213 | module_init(ux500_init); |
213 | 214 | ||
214 | static void __exit ux500_exit(void) | 215 | static void __exit ux500_exit(void) |
215 | { | 216 | { |
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig index 735ef4c2339a..5c87db06b598 100644 --- a/drivers/usb/otg/Kconfig +++ b/drivers/usb/otg/Kconfig | |||
@@ -23,7 +23,7 @@ config USB_GPIO_VBUS | |||
23 | select USB_OTG_UTILS | 23 | select USB_OTG_UTILS |
24 | help | 24 | help |
25 | Provides simple GPIO VBUS sensing for controllers with an | 25 | Provides simple GPIO VBUS sensing for controllers with an |
26 | internal transceiver via the otg_transceiver interface, and | 26 | internal transceiver via the usb_phy interface, and |
27 | optionally control of a D+ pullup GPIO as well as a VBUS | 27 | optionally control of a D+ pullup GPIO as well as a VBUS |
28 | current limit regulator. | 28 | current limit regulator. |
29 | 29 | ||
diff --git a/drivers/usb/otg/ab8500-usb.c b/drivers/usb/otg/ab8500-usb.c index 74fe6e62e0f7..a84af677dc59 100644 --- a/drivers/usb/otg/ab8500-usb.c +++ b/drivers/usb/otg/ab8500-usb.c | |||
@@ -68,7 +68,7 @@ enum ab8500_usb_link_status { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | struct ab8500_usb { | 70 | struct ab8500_usb { |
71 | struct otg_transceiver otg; | 71 | struct usb_phy phy; |
72 | struct device *dev; | 72 | struct device *dev; |
73 | int irq_num_id_rise; | 73 | int irq_num_id_rise; |
74 | int irq_num_id_fall; | 74 | int irq_num_id_fall; |
@@ -82,9 +82,9 @@ struct ab8500_usb { | |||
82 | int rev; | 82 | int rev; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | static inline struct ab8500_usb *xceiv_to_ab(struct otg_transceiver *x) | 85 | static inline struct ab8500_usb *phy_to_ab(struct usb_phy *x) |
86 | { | 86 | { |
87 | return container_of(x, struct ab8500_usb, otg); | 87 | return container_of(x, struct ab8500_usb, phy); |
88 | } | 88 | } |
89 | 89 | ||
90 | static void ab8500_usb_wd_workaround(struct ab8500_usb *ab) | 90 | static void ab8500_usb_wd_workaround(struct ab8500_usb *ab) |
@@ -153,7 +153,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) | |||
153 | u8 reg; | 153 | u8 reg; |
154 | enum ab8500_usb_link_status lsts; | 154 | enum ab8500_usb_link_status lsts; |
155 | void *v = NULL; | 155 | void *v = NULL; |
156 | enum usb_xceiv_events event; | 156 | enum usb_phy_events event; |
157 | 157 | ||
158 | abx500_get_register_interruptible(ab->dev, | 158 | abx500_get_register_interruptible(ab->dev, |
159 | AB8500_USB, | 159 | AB8500_USB, |
@@ -169,8 +169,8 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) | |||
169 | /* TODO: Disable regulators. */ | 169 | /* TODO: Disable regulators. */ |
170 | ab8500_usb_host_phy_dis(ab); | 170 | ab8500_usb_host_phy_dis(ab); |
171 | ab8500_usb_peri_phy_dis(ab); | 171 | ab8500_usb_peri_phy_dis(ab); |
172 | ab->otg.state = OTG_STATE_B_IDLE; | 172 | ab->phy.state = OTG_STATE_B_IDLE; |
173 | ab->otg.default_a = false; | 173 | ab->phy.otg->default_a = false; |
174 | ab->vbus_draw = 0; | 174 | ab->vbus_draw = 0; |
175 | event = USB_EVENT_NONE; | 175 | event = USB_EVENT_NONE; |
176 | break; | 176 | break; |
@@ -181,22 +181,22 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) | |||
181 | case USB_LINK_HOST_CHG_NM: | 181 | case USB_LINK_HOST_CHG_NM: |
182 | case USB_LINK_HOST_CHG_HS: | 182 | case USB_LINK_HOST_CHG_HS: |
183 | case USB_LINK_HOST_CHG_HS_CHIRP: | 183 | case USB_LINK_HOST_CHG_HS_CHIRP: |
184 | if (ab->otg.gadget) { | 184 | if (ab->phy.otg->gadget) { |
185 | /* TODO: Enable regulators. */ | 185 | /* TODO: Enable regulators. */ |
186 | ab8500_usb_peri_phy_en(ab); | 186 | ab8500_usb_peri_phy_en(ab); |
187 | v = ab->otg.gadget; | 187 | v = ab->phy.otg->gadget; |
188 | } | 188 | } |
189 | event = USB_EVENT_VBUS; | 189 | event = USB_EVENT_VBUS; |
190 | break; | 190 | break; |
191 | 191 | ||
192 | case USB_LINK_HM_IDGND: | 192 | case USB_LINK_HM_IDGND: |
193 | if (ab->otg.host) { | 193 | if (ab->phy.otg->host) { |
194 | /* TODO: Enable regulators. */ | 194 | /* TODO: Enable regulators. */ |
195 | ab8500_usb_host_phy_en(ab); | 195 | ab8500_usb_host_phy_en(ab); |
196 | v = ab->otg.host; | 196 | v = ab->phy.otg->host; |
197 | } | 197 | } |
198 | ab->otg.state = OTG_STATE_A_IDLE; | 198 | ab->phy.state = OTG_STATE_A_IDLE; |
199 | ab->otg.default_a = true; | 199 | ab->phy.otg->default_a = true; |
200 | event = USB_EVENT_ID; | 200 | event = USB_EVENT_ID; |
201 | break; | 201 | break; |
202 | 202 | ||
@@ -212,7 +212,7 @@ static int ab8500_usb_link_status_update(struct ab8500_usb *ab) | |||
212 | break; | 212 | break; |
213 | } | 213 | } |
214 | 214 | ||
215 | atomic_notifier_call_chain(&ab->otg.notifier, event, v); | 215 | atomic_notifier_call_chain(&ab->phy.notifier, event, v); |
216 | 216 | ||
217 | return 0; | 217 | return 0; |
218 | } | 218 | } |
@@ -262,27 +262,27 @@ static void ab8500_usb_phy_disable_work(struct work_struct *work) | |||
262 | struct ab8500_usb *ab = container_of(work, struct ab8500_usb, | 262 | struct ab8500_usb *ab = container_of(work, struct ab8500_usb, |
263 | phy_dis_work); | 263 | phy_dis_work); |
264 | 264 | ||
265 | if (!ab->otg.host) | 265 | if (!ab->phy.otg->host) |
266 | ab8500_usb_host_phy_dis(ab); | 266 | ab8500_usb_host_phy_dis(ab); |
267 | 267 | ||
268 | if (!ab->otg.gadget) | 268 | if (!ab->phy.otg->gadget) |
269 | ab8500_usb_peri_phy_dis(ab); | 269 | ab8500_usb_peri_phy_dis(ab); |
270 | } | 270 | } |
271 | 271 | ||
272 | static int ab8500_usb_set_power(struct otg_transceiver *otg, unsigned mA) | 272 | static int ab8500_usb_set_power(struct usb_phy *phy, unsigned mA) |
273 | { | 273 | { |
274 | struct ab8500_usb *ab; | 274 | struct ab8500_usb *ab; |
275 | 275 | ||
276 | if (!otg) | 276 | if (!phy) |
277 | return -ENODEV; | 277 | return -ENODEV; |
278 | 278 | ||
279 | ab = xceiv_to_ab(otg); | 279 | ab = phy_to_ab(phy); |
280 | 280 | ||
281 | ab->vbus_draw = mA; | 281 | ab->vbus_draw = mA; |
282 | 282 | ||
283 | if (mA) | 283 | if (mA) |
284 | atomic_notifier_call_chain(&ab->otg.notifier, | 284 | atomic_notifier_call_chain(&ab->phy.notifier, |
285 | USB_EVENT_ENUMERATED, ab->otg.gadget); | 285 | USB_EVENT_ENUMERATED, ab->phy.otg->gadget); |
286 | return 0; | 286 | return 0; |
287 | } | 287 | } |
288 | 288 | ||
@@ -290,21 +290,21 @@ static int ab8500_usb_set_power(struct otg_transceiver *otg, unsigned mA) | |||
290 | * ab->vbus_draw. | 290 | * ab->vbus_draw. |
291 | */ | 291 | */ |
292 | 292 | ||
293 | static int ab8500_usb_set_suspend(struct otg_transceiver *x, int suspend) | 293 | static int ab8500_usb_set_suspend(struct usb_phy *x, int suspend) |
294 | { | 294 | { |
295 | /* TODO */ | 295 | /* TODO */ |
296 | return 0; | 296 | return 0; |
297 | } | 297 | } |
298 | 298 | ||
299 | static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, | 299 | static int ab8500_usb_set_peripheral(struct usb_otg *otg, |
300 | struct usb_gadget *gadget) | 300 | struct usb_gadget *gadget) |
301 | { | 301 | { |
302 | struct ab8500_usb *ab; | 302 | struct ab8500_usb *ab; |
303 | 303 | ||
304 | if (!otg) | 304 | if (!otg) |
305 | return -ENODEV; | 305 | return -ENODEV; |
306 | 306 | ||
307 | ab = xceiv_to_ab(otg); | 307 | ab = phy_to_ab(otg->phy); |
308 | 308 | ||
309 | /* Some drivers call this function in atomic context. | 309 | /* Some drivers call this function in atomic context. |
310 | * Do not update ab8500 registers directly till this | 310 | * Do not update ab8500 registers directly till this |
@@ -313,11 +313,11 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, | |||
313 | 313 | ||
314 | if (!gadget) { | 314 | if (!gadget) { |
315 | /* TODO: Disable regulators. */ | 315 | /* TODO: Disable regulators. */ |
316 | ab->otg.gadget = NULL; | 316 | otg->gadget = NULL; |
317 | schedule_work(&ab->phy_dis_work); | 317 | schedule_work(&ab->phy_dis_work); |
318 | } else { | 318 | } else { |
319 | ab->otg.gadget = gadget; | 319 | otg->gadget = gadget; |
320 | ab->otg.state = OTG_STATE_B_IDLE; | 320 | otg->phy->state = OTG_STATE_B_IDLE; |
321 | 321 | ||
322 | /* Phy will not be enabled if cable is already | 322 | /* Phy will not be enabled if cable is already |
323 | * plugged-in. Schedule to enable phy. | 323 | * plugged-in. Schedule to enable phy. |
@@ -329,15 +329,14 @@ static int ab8500_usb_set_peripheral(struct otg_transceiver *otg, | |||
329 | return 0; | 329 | return 0; |
330 | } | 330 | } |
331 | 331 | ||
332 | static int ab8500_usb_set_host(struct otg_transceiver *otg, | 332 | static int ab8500_usb_set_host(struct usb_otg *otg, struct usb_bus *host) |
333 | struct usb_bus *host) | ||
334 | { | 333 | { |
335 | struct ab8500_usb *ab; | 334 | struct ab8500_usb *ab; |
336 | 335 | ||
337 | if (!otg) | 336 | if (!otg) |
338 | return -ENODEV; | 337 | return -ENODEV; |
339 | 338 | ||
340 | ab = xceiv_to_ab(otg); | 339 | ab = phy_to_ab(otg->phy); |
341 | 340 | ||
342 | /* Some drivers call this function in atomic context. | 341 | /* Some drivers call this function in atomic context. |
343 | * Do not update ab8500 registers directly till this | 342 | * Do not update ab8500 registers directly till this |
@@ -346,10 +345,10 @@ static int ab8500_usb_set_host(struct otg_transceiver *otg, | |||
346 | 345 | ||
347 | if (!host) { | 346 | if (!host) { |
348 | /* TODO: Disable regulators. */ | 347 | /* TODO: Disable regulators. */ |
349 | ab->otg.host = NULL; | 348 | otg->host = NULL; |
350 | schedule_work(&ab->phy_dis_work); | 349 | schedule_work(&ab->phy_dis_work); |
351 | } else { | 350 | } else { |
352 | ab->otg.host = host; | 351 | otg->host = host; |
353 | /* Phy will not be enabled if cable is already | 352 | /* Phy will not be enabled if cable is already |
354 | * plugged-in. Schedule to enable phy. | 353 | * plugged-in. Schedule to enable phy. |
355 | * Use same delay to avoid any race condition. | 354 | * Use same delay to avoid any race condition. |
@@ -472,6 +471,7 @@ static int ab8500_usb_v2_res_setup(struct platform_device *pdev, | |||
472 | static int __devinit ab8500_usb_probe(struct platform_device *pdev) | 471 | static int __devinit ab8500_usb_probe(struct platform_device *pdev) |
473 | { | 472 | { |
474 | struct ab8500_usb *ab; | 473 | struct ab8500_usb *ab; |
474 | struct usb_otg *otg; | ||
475 | int err; | 475 | int err; |
476 | int rev; | 476 | int rev; |
477 | 477 | ||
@@ -488,19 +488,28 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev) | |||
488 | if (!ab) | 488 | if (!ab) |
489 | return -ENOMEM; | 489 | return -ENOMEM; |
490 | 490 | ||
491 | otg = kzalloc(sizeof *otg, GFP_KERNEL); | ||
492 | if (!otg) { | ||
493 | kfree(ab); | ||
494 | return -ENOMEM; | ||
495 | } | ||
496 | |||
491 | ab->dev = &pdev->dev; | 497 | ab->dev = &pdev->dev; |
492 | ab->rev = rev; | 498 | ab->rev = rev; |
493 | ab->otg.dev = ab->dev; | 499 | ab->phy.dev = ab->dev; |
494 | ab->otg.label = "ab8500"; | 500 | ab->phy.otg = otg; |
495 | ab->otg.state = OTG_STATE_UNDEFINED; | 501 | ab->phy.label = "ab8500"; |
496 | ab->otg.set_host = ab8500_usb_set_host; | 502 | ab->phy.set_suspend = ab8500_usb_set_suspend; |
497 | ab->otg.set_peripheral = ab8500_usb_set_peripheral; | 503 | ab->phy.set_power = ab8500_usb_set_power; |
498 | ab->otg.set_suspend = ab8500_usb_set_suspend; | 504 | ab->phy.state = OTG_STATE_UNDEFINED; |
499 | ab->otg.set_power = ab8500_usb_set_power; | 505 | |
506 | otg->phy = &ab->phy; | ||
507 | otg->set_host = ab8500_usb_set_host; | ||
508 | otg->set_peripheral = ab8500_usb_set_peripheral; | ||
500 | 509 | ||
501 | platform_set_drvdata(pdev, ab); | 510 | platform_set_drvdata(pdev, ab); |
502 | 511 | ||
503 | ATOMIC_INIT_NOTIFIER_HEAD(&ab->otg.notifier); | 512 | ATOMIC_INIT_NOTIFIER_HEAD(&ab->phy.notifier); |
504 | 513 | ||
505 | /* v1: Wait for link status to become stable. | 514 | /* v1: Wait for link status to become stable. |
506 | * all: Updates form set_host and set_peripheral as they are atomic. | 515 | * all: Updates form set_host and set_peripheral as they are atomic. |
@@ -520,7 +529,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev) | |||
520 | if (err < 0) | 529 | if (err < 0) |
521 | goto fail0; | 530 | goto fail0; |
522 | 531 | ||
523 | err = otg_set_transceiver(&ab->otg); | 532 | err = usb_set_transceiver(&ab->phy); |
524 | if (err) { | 533 | if (err) { |
525 | dev_err(&pdev->dev, "Can't register transceiver\n"); | 534 | dev_err(&pdev->dev, "Can't register transceiver\n"); |
526 | goto fail1; | 535 | goto fail1; |
@@ -532,6 +541,7 @@ static int __devinit ab8500_usb_probe(struct platform_device *pdev) | |||
532 | fail1: | 541 | fail1: |
533 | ab8500_usb_irq_free(ab); | 542 | ab8500_usb_irq_free(ab); |
534 | fail0: | 543 | fail0: |
544 | kfree(otg); | ||
535 | kfree(ab); | 545 | kfree(ab); |
536 | return err; | 546 | return err; |
537 | } | 547 | } |
@@ -546,13 +556,14 @@ static int __devexit ab8500_usb_remove(struct platform_device *pdev) | |||
546 | 556 | ||
547 | cancel_work_sync(&ab->phy_dis_work); | 557 | cancel_work_sync(&ab->phy_dis_work); |
548 | 558 | ||
549 | otg_set_transceiver(NULL); | 559 | usb_set_transceiver(NULL); |
550 | 560 | ||
551 | ab8500_usb_host_phy_dis(ab); | 561 | ab8500_usb_host_phy_dis(ab); |
552 | ab8500_usb_peri_phy_dis(ab); | 562 | ab8500_usb_peri_phy_dis(ab); |
553 | 563 | ||
554 | platform_set_drvdata(pdev, NULL); | 564 | platform_set_drvdata(pdev, NULL); |
555 | 565 | ||
566 | kfree(ab->phy.otg); | ||
556 | kfree(ab); | 567 | kfree(ab); |
557 | 568 | ||
558 | return 0; | 569 | return 0; |
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c index a190850d2d3b..be4a63e8302f 100644 --- a/drivers/usb/otg/fsl_otg.c +++ b/drivers/usb/otg/fsl_otg.c | |||
@@ -275,7 +275,7 @@ void b_srp_end(unsigned long foo) | |||
275 | fsl_otg_dischrg_vbus(0); | 275 | fsl_otg_dischrg_vbus(0); |
276 | srp_wait_done = 1; | 276 | srp_wait_done = 1; |
277 | 277 | ||
278 | if ((fsl_otg_dev->otg.state == OTG_STATE_B_SRP_INIT) && | 278 | if ((fsl_otg_dev->phy.state == OTG_STATE_B_SRP_INIT) && |
279 | fsl_otg_dev->fsm.b_sess_vld) | 279 | fsl_otg_dev->fsm.b_sess_vld) |
280 | fsl_otg_dev->fsm.b_srp_done = 1; | 280 | fsl_otg_dev->fsm.b_srp_done = 1; |
281 | } | 281 | } |
@@ -288,7 +288,7 @@ void b_srp_end(unsigned long foo) | |||
288 | void a_wait_enum(unsigned long foo) | 288 | void a_wait_enum(unsigned long foo) |
289 | { | 289 | { |
290 | VDBG("a_wait_enum timeout\n"); | 290 | VDBG("a_wait_enum timeout\n"); |
291 | if (!fsl_otg_dev->otg.host->b_hnp_enable) | 291 | if (!fsl_otg_dev->phy.otg->host->b_hnp_enable) |
292 | fsl_otg_add_timer(a_wait_enum_tmr); | 292 | fsl_otg_add_timer(a_wait_enum_tmr); |
293 | else | 293 | else |
294 | otg_statemachine(&fsl_otg_dev->fsm); | 294 | otg_statemachine(&fsl_otg_dev->fsm); |
@@ -452,14 +452,14 @@ void otg_reset_controller(void) | |||
452 | /* Call suspend/resume routines in host driver */ | 452 | /* Call suspend/resume routines in host driver */ |
453 | int fsl_otg_start_host(struct otg_fsm *fsm, int on) | 453 | int fsl_otg_start_host(struct otg_fsm *fsm, int on) |
454 | { | 454 | { |
455 | struct otg_transceiver *xceiv = fsm->transceiver; | 455 | struct usb_otg *otg = fsm->otg; |
456 | struct device *dev; | 456 | struct device *dev; |
457 | struct fsl_otg *otg_dev = container_of(xceiv, struct fsl_otg, otg); | 457 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
458 | u32 retval = 0; | 458 | u32 retval = 0; |
459 | 459 | ||
460 | if (!xceiv->host) | 460 | if (!otg->host) |
461 | return -ENODEV; | 461 | return -ENODEV; |
462 | dev = xceiv->host->controller; | 462 | dev = otg->host->controller; |
463 | 463 | ||
464 | /* | 464 | /* |
465 | * Update a_vbus_vld state as a_vbus_vld int is disabled | 465 | * Update a_vbus_vld state as a_vbus_vld int is disabled |
@@ -518,14 +518,14 @@ end: | |||
518 | */ | 518 | */ |
519 | int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) | 519 | int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) |
520 | { | 520 | { |
521 | struct otg_transceiver *xceiv = fsm->transceiver; | 521 | struct usb_otg *otg = fsm->otg; |
522 | struct device *dev; | 522 | struct device *dev; |
523 | 523 | ||
524 | if (!xceiv->gadget || !xceiv->gadget->dev.parent) | 524 | if (!otg->gadget || !otg->gadget->dev.parent) |
525 | return -ENODEV; | 525 | return -ENODEV; |
526 | 526 | ||
527 | VDBG("gadget %s\n", on ? "on" : "off"); | 527 | VDBG("gadget %s\n", on ? "on" : "off"); |
528 | dev = xceiv->gadget->dev.parent; | 528 | dev = otg->gadget->dev.parent; |
529 | 529 | ||
530 | if (on) { | 530 | if (on) { |
531 | if (dev->driver->resume) | 531 | if (dev->driver->resume) |
@@ -542,14 +542,14 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on) | |||
542 | * Called by initialization code of host driver. Register host controller | 542 | * Called by initialization code of host driver. Register host controller |
543 | * to the OTG. Suspend host for OTG role detection. | 543 | * to the OTG. Suspend host for OTG role detection. |
544 | */ | 544 | */ |
545 | static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) | 545 | static int fsl_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
546 | { | 546 | { |
547 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 547 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
548 | 548 | ||
549 | if (!otg_p || otg_dev != fsl_otg_dev) | 549 | if (!otg || otg_dev != fsl_otg_dev) |
550 | return -ENODEV; | 550 | return -ENODEV; |
551 | 551 | ||
552 | otg_p->host = host; | 552 | otg->host = host; |
553 | 553 | ||
554 | otg_dev->fsm.a_bus_drop = 0; | 554 | otg_dev->fsm.a_bus_drop = 0; |
555 | otg_dev->fsm.a_bus_req = 1; | 555 | otg_dev->fsm.a_bus_req = 1; |
@@ -557,8 +557,8 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) | |||
557 | if (host) { | 557 | if (host) { |
558 | VDBG("host off......\n"); | 558 | VDBG("host off......\n"); |
559 | 559 | ||
560 | otg_p->host->otg_port = fsl_otg_initdata.otg_port; | 560 | otg->host->otg_port = fsl_otg_initdata.otg_port; |
561 | otg_p->host->is_b_host = otg_dev->fsm.id; | 561 | otg->host->is_b_host = otg_dev->fsm.id; |
562 | /* | 562 | /* |
563 | * must leave time for khubd to finish its thing | 563 | * must leave time for khubd to finish its thing |
564 | * before yanking the host driver out from under it, | 564 | * before yanking the host driver out from under it, |
@@ -574,7 +574,7 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) | |||
574 | /* Mini-A cable connected */ | 574 | /* Mini-A cable connected */ |
575 | struct otg_fsm *fsm = &otg_dev->fsm; | 575 | struct otg_fsm *fsm = &otg_dev->fsm; |
576 | 576 | ||
577 | otg_p->state = OTG_STATE_UNDEFINED; | 577 | otg->phy->state = OTG_STATE_UNDEFINED; |
578 | fsm->protocol = PROTO_UNDEF; | 578 | fsm->protocol = PROTO_UNDEF; |
579 | } | 579 | } |
580 | } | 580 | } |
@@ -587,29 +587,29 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host) | |||
587 | } | 587 | } |
588 | 588 | ||
589 | /* Called by initialization code of udc. Register udc to OTG. */ | 589 | /* Called by initialization code of udc. Register udc to OTG. */ |
590 | static int fsl_otg_set_peripheral(struct otg_transceiver *otg_p, | 590 | static int fsl_otg_set_peripheral(struct usb_otg *otg, |
591 | struct usb_gadget *gadget) | 591 | struct usb_gadget *gadget) |
592 | { | 592 | { |
593 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 593 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
594 | 594 | ||
595 | VDBG("otg_dev 0x%x\n", (int)otg_dev); | 595 | VDBG("otg_dev 0x%x\n", (int)otg_dev); |
596 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); | 596 | VDBG("fsl_otg_dev 0x%x\n", (int)fsl_otg_dev); |
597 | 597 | ||
598 | if (!otg_p || otg_dev != fsl_otg_dev) | 598 | if (!otg || otg_dev != fsl_otg_dev) |
599 | return -ENODEV; | 599 | return -ENODEV; |
600 | 600 | ||
601 | if (!gadget) { | 601 | if (!gadget) { |
602 | if (!otg_dev->otg.default_a) | 602 | if (!otg->default_a) |
603 | otg_p->gadget->ops->vbus_draw(otg_p->gadget, 0); | 603 | otg->gadget->ops->vbus_draw(otg->gadget, 0); |
604 | usb_gadget_vbus_disconnect(otg_dev->otg.gadget); | 604 | usb_gadget_vbus_disconnect(otg->gadget); |
605 | otg_dev->otg.gadget = 0; | 605 | otg->gadget = 0; |
606 | otg_dev->fsm.b_bus_req = 0; | 606 | otg_dev->fsm.b_bus_req = 0; |
607 | otg_statemachine(&otg_dev->fsm); | 607 | otg_statemachine(&otg_dev->fsm); |
608 | return 0; | 608 | return 0; |
609 | } | 609 | } |
610 | 610 | ||
611 | otg_p->gadget = gadget; | 611 | otg->gadget = gadget; |
612 | otg_p->gadget->is_a_peripheral = !otg_dev->fsm.id; | 612 | otg->gadget->is_a_peripheral = !otg_dev->fsm.id; |
613 | 613 | ||
614 | otg_dev->fsm.b_bus_req = 1; | 614 | otg_dev->fsm.b_bus_req = 1; |
615 | 615 | ||
@@ -625,11 +625,11 @@ static int fsl_otg_set_peripheral(struct otg_transceiver *otg_p, | |||
625 | } | 625 | } |
626 | 626 | ||
627 | /* Set OTG port power, only for B-device */ | 627 | /* Set OTG port power, only for B-device */ |
628 | static int fsl_otg_set_power(struct otg_transceiver *otg_p, unsigned mA) | 628 | static int fsl_otg_set_power(struct usb_phy *phy, unsigned mA) |
629 | { | 629 | { |
630 | if (!fsl_otg_dev) | 630 | if (!fsl_otg_dev) |
631 | return -ENODEV; | 631 | return -ENODEV; |
632 | if (otg_p->state == OTG_STATE_B_PERIPHERAL) | 632 | if (phy->state == OTG_STATE_B_PERIPHERAL) |
633 | pr_info("FSL OTG: Draw %d mA\n", mA); | 633 | pr_info("FSL OTG: Draw %d mA\n", mA); |
634 | 634 | ||
635 | return 0; | 635 | return 0; |
@@ -658,12 +658,12 @@ static void fsl_otg_event(struct work_struct *work) | |||
658 | } | 658 | } |
659 | 659 | ||
660 | /* B-device start SRP */ | 660 | /* B-device start SRP */ |
661 | static int fsl_otg_start_srp(struct otg_transceiver *otg_p) | 661 | static int fsl_otg_start_srp(struct usb_otg *otg) |
662 | { | 662 | { |
663 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 663 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
664 | 664 | ||
665 | if (!otg_p || otg_dev != fsl_otg_dev | 665 | if (!otg || otg_dev != fsl_otg_dev |
666 | || otg_p->state != OTG_STATE_B_IDLE) | 666 | || otg->phy->state != OTG_STATE_B_IDLE) |
667 | return -ENODEV; | 667 | return -ENODEV; |
668 | 668 | ||
669 | otg_dev->fsm.b_bus_req = 1; | 669 | otg_dev->fsm.b_bus_req = 1; |
@@ -673,11 +673,11 @@ static int fsl_otg_start_srp(struct otg_transceiver *otg_p) | |||
673 | } | 673 | } |
674 | 674 | ||
675 | /* A_host suspend will call this function to start hnp */ | 675 | /* A_host suspend will call this function to start hnp */ |
676 | static int fsl_otg_start_hnp(struct otg_transceiver *otg_p) | 676 | static int fsl_otg_start_hnp(struct usb_otg *otg) |
677 | { | 677 | { |
678 | struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg); | 678 | struct fsl_otg *otg_dev = container_of(otg->phy, struct fsl_otg, phy); |
679 | 679 | ||
680 | if (!otg_p || otg_dev != fsl_otg_dev) | 680 | if (!otg || otg_dev != fsl_otg_dev) |
681 | return -ENODEV; | 681 | return -ENODEV; |
682 | 682 | ||
683 | DBG("start_hnp...n"); | 683 | DBG("start_hnp...n"); |
@@ -698,7 +698,7 @@ static int fsl_otg_start_hnp(struct otg_transceiver *otg_p) | |||
698 | irqreturn_t fsl_otg_isr(int irq, void *dev_id) | 698 | irqreturn_t fsl_otg_isr(int irq, void *dev_id) |
699 | { | 699 | { |
700 | struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm; | 700 | struct otg_fsm *fsm = &((struct fsl_otg *)dev_id)->fsm; |
701 | struct otg_transceiver *otg = &((struct fsl_otg *)dev_id)->otg; | 701 | struct usb_otg *otg = ((struct fsl_otg *)dev_id)->phy.otg; |
702 | u32 otg_int_src, otg_sc; | 702 | u32 otg_int_src, otg_sc; |
703 | 703 | ||
704 | otg_sc = fsl_readl(&usb_dr_regs->otgsc); | 704 | otg_sc = fsl_readl(&usb_dr_regs->otgsc); |
@@ -774,6 +774,12 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
774 | if (!fsl_otg_tc) | 774 | if (!fsl_otg_tc) |
775 | return -ENOMEM; | 775 | return -ENOMEM; |
776 | 776 | ||
777 | fsl_otg_tc->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL); | ||
778 | if (!fsl_otg_tc->phy.otg) { | ||
779 | kfree(fsl_otg_tc); | ||
780 | return -ENOMEM; | ||
781 | } | ||
782 | |||
777 | INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event); | 783 | INIT_DELAYED_WORK(&fsl_otg_tc->otg_event, fsl_otg_event); |
778 | 784 | ||
779 | INIT_LIST_HEAD(&active_timers); | 785 | INIT_LIST_HEAD(&active_timers); |
@@ -788,17 +794,19 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
788 | fsl_otg_tc->fsm.ops = &fsl_otg_ops; | 794 | fsl_otg_tc->fsm.ops = &fsl_otg_ops; |
789 | 795 | ||
790 | /* initialize the otg structure */ | 796 | /* initialize the otg structure */ |
791 | fsl_otg_tc->otg.label = DRIVER_DESC; | 797 | fsl_otg_tc->phy.label = DRIVER_DESC; |
792 | fsl_otg_tc->otg.set_host = fsl_otg_set_host; | 798 | fsl_otg_tc->phy.set_power = fsl_otg_set_power; |
793 | fsl_otg_tc->otg.set_peripheral = fsl_otg_set_peripheral; | 799 | |
794 | fsl_otg_tc->otg.set_power = fsl_otg_set_power; | 800 | fsl_otg_tc->phy.otg->phy = &fsl_otg_tc->phy; |
795 | fsl_otg_tc->otg.start_hnp = fsl_otg_start_hnp; | 801 | fsl_otg_tc->phy.otg->set_host = fsl_otg_set_host; |
796 | fsl_otg_tc->otg.start_srp = fsl_otg_start_srp; | 802 | fsl_otg_tc->phy.otg->set_peripheral = fsl_otg_set_peripheral; |
803 | fsl_otg_tc->phy.otg->start_hnp = fsl_otg_start_hnp; | ||
804 | fsl_otg_tc->phy.otg->start_srp = fsl_otg_start_srp; | ||
797 | 805 | ||
798 | fsl_otg_dev = fsl_otg_tc; | 806 | fsl_otg_dev = fsl_otg_tc; |
799 | 807 | ||
800 | /* Store the otg transceiver */ | 808 | /* Store the otg transceiver */ |
801 | status = otg_set_transceiver(&fsl_otg_tc->otg); | 809 | status = usb_set_transceiver(&fsl_otg_tc->phy); |
802 | if (status) { | 810 | if (status) { |
803 | pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n"); | 811 | pr_warn(FSL_OTG_NAME ": unable to register OTG transceiver.\n"); |
804 | goto err; | 812 | goto err; |
@@ -807,6 +815,7 @@ static int fsl_otg_conf(struct platform_device *pdev) | |||
807 | return 0; | 815 | return 0; |
808 | err: | 816 | err: |
809 | fsl_otg_uninit_timers(); | 817 | fsl_otg_uninit_timers(); |
818 | kfree(fsl_otg_tc->phy.otg); | ||
810 | kfree(fsl_otg_tc); | 819 | kfree(fsl_otg_tc); |
811 | return status; | 820 | return status; |
812 | } | 821 | } |
@@ -815,19 +824,19 @@ err: | |||
815 | int usb_otg_start(struct platform_device *pdev) | 824 | int usb_otg_start(struct platform_device *pdev) |
816 | { | 825 | { |
817 | struct fsl_otg *p_otg; | 826 | struct fsl_otg *p_otg; |
818 | struct otg_transceiver *otg_trans = otg_get_transceiver(); | 827 | struct usb_phy *otg_trans = usb_get_transceiver(); |
819 | struct otg_fsm *fsm; | 828 | struct otg_fsm *fsm; |
820 | int status; | 829 | int status; |
821 | struct resource *res; | 830 | struct resource *res; |
822 | u32 temp; | 831 | u32 temp; |
823 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 832 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; |
824 | 833 | ||
825 | p_otg = container_of(otg_trans, struct fsl_otg, otg); | 834 | p_otg = container_of(otg_trans, struct fsl_otg, phy); |
826 | fsm = &p_otg->fsm; | 835 | fsm = &p_otg->fsm; |
827 | 836 | ||
828 | /* Initialize the state machine structure with default values */ | 837 | /* Initialize the state machine structure with default values */ |
829 | SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED); | 838 | SET_OTG_STATE(otg_trans, OTG_STATE_UNDEFINED); |
830 | fsm->transceiver = &p_otg->otg; | 839 | fsm->otg = p_otg->phy.otg; |
831 | 840 | ||
832 | /* We don't require predefined MEM/IRQ resource index */ | 841 | /* We don't require predefined MEM/IRQ resource index */ |
833 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 842 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
@@ -857,9 +866,10 @@ int usb_otg_start(struct platform_device *pdev) | |||
857 | status = request_irq(p_otg->irq, fsl_otg_isr, | 866 | status = request_irq(p_otg->irq, fsl_otg_isr, |
858 | IRQF_SHARED, driver_name, p_otg); | 867 | IRQF_SHARED, driver_name, p_otg); |
859 | if (status) { | 868 | if (status) { |
860 | dev_dbg(p_otg->otg.dev, "can't get IRQ %d, error %d\n", | 869 | dev_dbg(p_otg->phy.dev, "can't get IRQ %d, error %d\n", |
861 | p_otg->irq, status); | 870 | p_otg->irq, status); |
862 | iounmap(p_otg->dr_mem_map); | 871 | iounmap(p_otg->dr_mem_map); |
872 | kfree(p_otg->phy.otg); | ||
863 | kfree(p_otg); | 873 | kfree(p_otg); |
864 | return status; | 874 | return status; |
865 | } | 875 | } |
@@ -919,10 +929,10 @@ int usb_otg_start(struct platform_device *pdev) | |||
919 | * Also: record initial state of ID pin | 929 | * Also: record initial state of ID pin |
920 | */ | 930 | */ |
921 | if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { | 931 | if (fsl_readl(&p_otg->dr_mem_map->otgsc) & OTGSC_STS_USB_ID) { |
922 | p_otg->otg.state = OTG_STATE_UNDEFINED; | 932 | p_otg->phy.state = OTG_STATE_UNDEFINED; |
923 | p_otg->fsm.id = 1; | 933 | p_otg->fsm.id = 1; |
924 | } else { | 934 | } else { |
925 | p_otg->otg.state = OTG_STATE_A_IDLE; | 935 | p_otg->phy.state = OTG_STATE_A_IDLE; |
926 | p_otg->fsm.id = 0; | 936 | p_otg->fsm.id = 0; |
927 | } | 937 | } |
928 | 938 | ||
@@ -978,7 +988,7 @@ static int show_fsl_usb2_otg_state(struct device *dev, | |||
978 | /* State */ | 988 | /* State */ |
979 | t = scnprintf(next, size, | 989 | t = scnprintf(next, size, |
980 | "OTG state: %s\n\n", | 990 | "OTG state: %s\n\n", |
981 | otg_state_string(fsl_otg_dev->otg.state)); | 991 | otg_state_string(fsl_otg_dev->phy.state)); |
982 | size -= t; | 992 | size -= t; |
983 | next += t; | 993 | next += t; |
984 | 994 | ||
@@ -1124,12 +1134,13 @@ static int __devexit fsl_otg_remove(struct platform_device *pdev) | |||
1124 | { | 1134 | { |
1125 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; | 1135 | struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; |
1126 | 1136 | ||
1127 | otg_set_transceiver(NULL); | 1137 | usb_set_transceiver(NULL); |
1128 | free_irq(fsl_otg_dev->irq, fsl_otg_dev); | 1138 | free_irq(fsl_otg_dev->irq, fsl_otg_dev); |
1129 | 1139 | ||
1130 | iounmap((void *)usb_dr_regs); | 1140 | iounmap((void *)usb_dr_regs); |
1131 | 1141 | ||
1132 | fsl_otg_uninit_timers(); | 1142 | fsl_otg_uninit_timers(); |
1143 | kfree(fsl_otg_dev->phy.otg); | ||
1133 | kfree(fsl_otg_dev); | 1144 | kfree(fsl_otg_dev); |
1134 | 1145 | ||
1135 | device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); | 1146 | device_remove_file(&pdev->dev, &dev_attr_fsl_usb2_otg_state); |
diff --git a/drivers/usb/otg/fsl_otg.h b/drivers/usb/otg/fsl_otg.h index 3f8ef731aac9..ca266280895d 100644 --- a/drivers/usb/otg/fsl_otg.h +++ b/drivers/usb/otg/fsl_otg.h | |||
@@ -369,7 +369,7 @@ inline struct fsl_otg_timer *otg_timer_initializer | |||
369 | } | 369 | } |
370 | 370 | ||
371 | struct fsl_otg { | 371 | struct fsl_otg { |
372 | struct otg_transceiver otg; | 372 | struct usb_phy phy; |
373 | struct otg_fsm fsm; | 373 | struct otg_fsm fsm; |
374 | struct usb_dr_mmap *dr_mem_map; | 374 | struct usb_dr_mmap *dr_mem_map; |
375 | struct delayed_work otg_event; | 375 | struct delayed_work otg_event; |
diff --git a/drivers/usb/otg/gpio_vbus.c b/drivers/usb/otg/gpio_vbus.c index fb644c107ded..3ece43a2e4c1 100644 --- a/drivers/usb/otg/gpio_vbus.c +++ b/drivers/usb/otg/gpio_vbus.c | |||
@@ -32,7 +32,7 @@ | |||
32 | * Needs to be loaded before the UDC driver that will use it. | 32 | * Needs to be loaded before the UDC driver that will use it. |
33 | */ | 33 | */ |
34 | struct gpio_vbus_data { | 34 | struct gpio_vbus_data { |
35 | struct otg_transceiver otg; | 35 | struct usb_phy phy; |
36 | struct device *dev; | 36 | struct device *dev; |
37 | struct regulator *vbus_draw; | 37 | struct regulator *vbus_draw; |
38 | int vbus_draw_enabled; | 38 | int vbus_draw_enabled; |
@@ -98,7 +98,7 @@ static void gpio_vbus_work(struct work_struct *work) | |||
98 | struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; | 98 | struct gpio_vbus_mach_info *pdata = gpio_vbus->dev->platform_data; |
99 | int gpio; | 99 | int gpio; |
100 | 100 | ||
101 | if (!gpio_vbus->otg.gadget) | 101 | if (!gpio_vbus->phy.otg->gadget) |
102 | return; | 102 | return; |
103 | 103 | ||
104 | /* Peripheral controllers which manage the pullup themselves won't have | 104 | /* Peripheral controllers which manage the pullup themselves won't have |
@@ -108,8 +108,8 @@ static void gpio_vbus_work(struct work_struct *work) | |||
108 | */ | 108 | */ |
109 | gpio = pdata->gpio_pullup; | 109 | gpio = pdata->gpio_pullup; |
110 | if (is_vbus_powered(pdata)) { | 110 | if (is_vbus_powered(pdata)) { |
111 | gpio_vbus->otg.state = OTG_STATE_B_PERIPHERAL; | 111 | gpio_vbus->phy.state = OTG_STATE_B_PERIPHERAL; |
112 | usb_gadget_vbus_connect(gpio_vbus->otg.gadget); | 112 | usb_gadget_vbus_connect(gpio_vbus->phy.otg->gadget); |
113 | 113 | ||
114 | /* drawing a "unit load" is *always* OK, except for OTG */ | 114 | /* drawing a "unit load" is *always* OK, except for OTG */ |
115 | set_vbus_draw(gpio_vbus, 100); | 115 | set_vbus_draw(gpio_vbus, 100); |
@@ -124,8 +124,8 @@ static void gpio_vbus_work(struct work_struct *work) | |||
124 | 124 | ||
125 | set_vbus_draw(gpio_vbus, 0); | 125 | set_vbus_draw(gpio_vbus, 0); |
126 | 126 | ||
127 | usb_gadget_vbus_disconnect(gpio_vbus->otg.gadget); | 127 | usb_gadget_vbus_disconnect(gpio_vbus->phy.otg->gadget); |
128 | gpio_vbus->otg.state = OTG_STATE_B_IDLE; | 128 | gpio_vbus->phy.state = OTG_STATE_B_IDLE; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
@@ -135,12 +135,13 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data) | |||
135 | struct platform_device *pdev = data; | 135 | struct platform_device *pdev = data; |
136 | struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; | 136 | struct gpio_vbus_mach_info *pdata = pdev->dev.platform_data; |
137 | struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); | 137 | struct gpio_vbus_data *gpio_vbus = platform_get_drvdata(pdev); |
138 | struct usb_otg *otg = gpio_vbus->phy.otg; | ||
138 | 139 | ||
139 | dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n", | 140 | dev_dbg(&pdev->dev, "VBUS %s (gadget: %s)\n", |
140 | is_vbus_powered(pdata) ? "supplied" : "inactive", | 141 | is_vbus_powered(pdata) ? "supplied" : "inactive", |
141 | gpio_vbus->otg.gadget ? gpio_vbus->otg.gadget->name : "none"); | 142 | otg->gadget ? otg->gadget->name : "none"); |
142 | 143 | ||
143 | if (gpio_vbus->otg.gadget) | 144 | if (otg->gadget) |
144 | schedule_work(&gpio_vbus->work); | 145 | schedule_work(&gpio_vbus->work); |
145 | 146 | ||
146 | return IRQ_HANDLED; | 147 | return IRQ_HANDLED; |
@@ -149,15 +150,15 @@ static irqreturn_t gpio_vbus_irq(int irq, void *data) | |||
149 | /* OTG transceiver interface */ | 150 | /* OTG transceiver interface */ |
150 | 151 | ||
151 | /* bind/unbind the peripheral controller */ | 152 | /* bind/unbind the peripheral controller */ |
152 | static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, | 153 | static int gpio_vbus_set_peripheral(struct usb_otg *otg, |
153 | struct usb_gadget *gadget) | 154 | struct usb_gadget *gadget) |
154 | { | 155 | { |
155 | struct gpio_vbus_data *gpio_vbus; | 156 | struct gpio_vbus_data *gpio_vbus; |
156 | struct gpio_vbus_mach_info *pdata; | 157 | struct gpio_vbus_mach_info *pdata; |
157 | struct platform_device *pdev; | 158 | struct platform_device *pdev; |
158 | int gpio, irq; | 159 | int gpio, irq; |
159 | 160 | ||
160 | gpio_vbus = container_of(otg, struct gpio_vbus_data, otg); | 161 | gpio_vbus = container_of(otg->phy, struct gpio_vbus_data, phy); |
161 | pdev = to_platform_device(gpio_vbus->dev); | 162 | pdev = to_platform_device(gpio_vbus->dev); |
162 | pdata = gpio_vbus->dev->platform_data; | 163 | pdata = gpio_vbus->dev->platform_data; |
163 | irq = gpio_to_irq(pdata->gpio_vbus); | 164 | irq = gpio_to_irq(pdata->gpio_vbus); |
@@ -174,7 +175,7 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, | |||
174 | set_vbus_draw(gpio_vbus, 0); | 175 | set_vbus_draw(gpio_vbus, 0); |
175 | 176 | ||
176 | usb_gadget_vbus_disconnect(otg->gadget); | 177 | usb_gadget_vbus_disconnect(otg->gadget); |
177 | otg->state = OTG_STATE_UNDEFINED; | 178 | otg->phy->state = OTG_STATE_UNDEFINED; |
178 | 179 | ||
179 | otg->gadget = NULL; | 180 | otg->gadget = NULL; |
180 | return 0; | 181 | return 0; |
@@ -189,23 +190,23 @@ static int gpio_vbus_set_peripheral(struct otg_transceiver *otg, | |||
189 | } | 190 | } |
190 | 191 | ||
191 | /* effective for B devices, ignored for A-peripheral */ | 192 | /* effective for B devices, ignored for A-peripheral */ |
192 | static int gpio_vbus_set_power(struct otg_transceiver *otg, unsigned mA) | 193 | static int gpio_vbus_set_power(struct usb_phy *phy, unsigned mA) |
193 | { | 194 | { |
194 | struct gpio_vbus_data *gpio_vbus; | 195 | struct gpio_vbus_data *gpio_vbus; |
195 | 196 | ||
196 | gpio_vbus = container_of(otg, struct gpio_vbus_data, otg); | 197 | gpio_vbus = container_of(phy, struct gpio_vbus_data, phy); |
197 | 198 | ||
198 | if (otg->state == OTG_STATE_B_PERIPHERAL) | 199 | if (phy->state == OTG_STATE_B_PERIPHERAL) |
199 | set_vbus_draw(gpio_vbus, mA); | 200 | set_vbus_draw(gpio_vbus, mA); |
200 | return 0; | 201 | return 0; |
201 | } | 202 | } |
202 | 203 | ||
203 | /* for non-OTG B devices: set/clear transceiver suspend mode */ | 204 | /* for non-OTG B devices: set/clear transceiver suspend mode */ |
204 | static int gpio_vbus_set_suspend(struct otg_transceiver *otg, int suspend) | 205 | static int gpio_vbus_set_suspend(struct usb_phy *phy, int suspend) |
205 | { | 206 | { |
206 | struct gpio_vbus_data *gpio_vbus; | 207 | struct gpio_vbus_data *gpio_vbus; |
207 | 208 | ||
208 | gpio_vbus = container_of(otg, struct gpio_vbus_data, otg); | 209 | gpio_vbus = container_of(phy, struct gpio_vbus_data, phy); |
209 | 210 | ||
210 | /* draw max 0 mA from vbus in suspend mode; or the previously | 211 | /* draw max 0 mA from vbus in suspend mode; or the previously |
211 | * recorded amount of current if not suspended | 212 | * recorded amount of current if not suspended |
@@ -213,7 +214,7 @@ static int gpio_vbus_set_suspend(struct otg_transceiver *otg, int suspend) | |||
213 | * NOTE: high powered configs (mA > 100) may draw up to 2.5 mA | 214 | * NOTE: high powered configs (mA > 100) may draw up to 2.5 mA |
214 | * if they're wake-enabled ... we don't handle that yet. | 215 | * if they're wake-enabled ... we don't handle that yet. |
215 | */ | 216 | */ |
216 | return gpio_vbus_set_power(otg, suspend ? 0 : gpio_vbus->mA); | 217 | return gpio_vbus_set_power(phy, suspend ? 0 : gpio_vbus->mA); |
217 | } | 218 | } |
218 | 219 | ||
219 | /* platform driver interface */ | 220 | /* platform driver interface */ |
@@ -233,13 +234,21 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) | |||
233 | if (!gpio_vbus) | 234 | if (!gpio_vbus) |
234 | return -ENOMEM; | 235 | return -ENOMEM; |
235 | 236 | ||
237 | gpio_vbus->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL); | ||
238 | if (!gpio_vbus->phy.otg) { | ||
239 | kfree(gpio_vbus); | ||
240 | return -ENOMEM; | ||
241 | } | ||
242 | |||
236 | platform_set_drvdata(pdev, gpio_vbus); | 243 | platform_set_drvdata(pdev, gpio_vbus); |
237 | gpio_vbus->dev = &pdev->dev; | 244 | gpio_vbus->dev = &pdev->dev; |
238 | gpio_vbus->otg.label = "gpio-vbus"; | 245 | gpio_vbus->phy.label = "gpio-vbus"; |
239 | gpio_vbus->otg.state = OTG_STATE_UNDEFINED; | 246 | gpio_vbus->phy.set_power = gpio_vbus_set_power; |
240 | gpio_vbus->otg.set_peripheral = gpio_vbus_set_peripheral; | 247 | gpio_vbus->phy.set_suspend = gpio_vbus_set_suspend; |
241 | gpio_vbus->otg.set_power = gpio_vbus_set_power; | 248 | gpio_vbus->phy.state = OTG_STATE_UNDEFINED; |
242 | gpio_vbus->otg.set_suspend = gpio_vbus_set_suspend; | 249 | |
250 | gpio_vbus->phy.otg->phy = &gpio_vbus->phy; | ||
251 | gpio_vbus->phy.otg->set_peripheral = gpio_vbus_set_peripheral; | ||
243 | 252 | ||
244 | err = gpio_request(gpio, "vbus_detect"); | 253 | err = gpio_request(gpio, "vbus_detect"); |
245 | if (err) { | 254 | if (err) { |
@@ -288,7 +297,7 @@ static int __init gpio_vbus_probe(struct platform_device *pdev) | |||
288 | } | 297 | } |
289 | 298 | ||
290 | /* only active when a gadget is registered */ | 299 | /* only active when a gadget is registered */ |
291 | err = otg_set_transceiver(&gpio_vbus->otg); | 300 | err = usb_set_transceiver(&gpio_vbus->phy); |
292 | if (err) { | 301 | if (err) { |
293 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", | 302 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", |
294 | err); | 303 | err); |
@@ -304,6 +313,7 @@ err_irq: | |||
304 | gpio_free(pdata->gpio_vbus); | 313 | gpio_free(pdata->gpio_vbus); |
305 | err_gpio: | 314 | err_gpio: |
306 | platform_set_drvdata(pdev, NULL); | 315 | platform_set_drvdata(pdev, NULL); |
316 | kfree(gpio_vbus->phy.otg); | ||
307 | kfree(gpio_vbus); | 317 | kfree(gpio_vbus); |
308 | return err; | 318 | return err; |
309 | } | 319 | } |
@@ -316,13 +326,14 @@ static int __exit gpio_vbus_remove(struct platform_device *pdev) | |||
316 | 326 | ||
317 | regulator_put(gpio_vbus->vbus_draw); | 327 | regulator_put(gpio_vbus->vbus_draw); |
318 | 328 | ||
319 | otg_set_transceiver(NULL); | 329 | usb_set_transceiver(NULL); |
320 | 330 | ||
321 | free_irq(gpio_to_irq(gpio), &pdev->dev); | 331 | free_irq(gpio_to_irq(gpio), &pdev->dev); |
322 | if (gpio_is_valid(pdata->gpio_pullup)) | 332 | if (gpio_is_valid(pdata->gpio_pullup)) |
323 | gpio_free(pdata->gpio_pullup); | 333 | gpio_free(pdata->gpio_pullup); |
324 | gpio_free(gpio); | 334 | gpio_free(gpio); |
325 | platform_set_drvdata(pdev, NULL); | 335 | platform_set_drvdata(pdev, NULL); |
336 | kfree(gpio_vbus->phy.otg); | ||
326 | kfree(gpio_vbus); | 337 | kfree(gpio_vbus); |
327 | 338 | ||
328 | return 0; | 339 | return 0; |
diff --git a/drivers/usb/otg/isp1301_omap.c b/drivers/usb/otg/isp1301_omap.c index 8c86787c2f09..70cf5d7bca48 100644 --- a/drivers/usb/otg/isp1301_omap.c +++ b/drivers/usb/otg/isp1301_omap.c | |||
@@ -52,7 +52,7 @@ MODULE_DESCRIPTION("ISP1301 USB OTG Transceiver Driver"); | |||
52 | MODULE_LICENSE("GPL"); | 52 | MODULE_LICENSE("GPL"); |
53 | 53 | ||
54 | struct isp1301 { | 54 | struct isp1301 { |
55 | struct otg_transceiver otg; | 55 | struct usb_phy phy; |
56 | struct i2c_client *client; | 56 | struct i2c_client *client; |
57 | void (*i2c_release)(struct device *dev); | 57 | void (*i2c_release)(struct device *dev); |
58 | 58 | ||
@@ -236,7 +236,7 @@ isp1301_clear_bits(struct isp1301 *isp, u8 reg, u8 bits) | |||
236 | 236 | ||
237 | static inline const char *state_name(struct isp1301 *isp) | 237 | static inline const char *state_name(struct isp1301 *isp) |
238 | { | 238 | { |
239 | return otg_state_string(isp->otg.state); | 239 | return otg_state_string(isp->phy.state); |
240 | } | 240 | } |
241 | 241 | ||
242 | /*-------------------------------------------------------------------------*/ | 242 | /*-------------------------------------------------------------------------*/ |
@@ -251,7 +251,7 @@ static inline const char *state_name(struct isp1301 *isp) | |||
251 | 251 | ||
252 | static void power_down(struct isp1301 *isp) | 252 | static void power_down(struct isp1301 *isp) |
253 | { | 253 | { |
254 | isp->otg.state = OTG_STATE_UNDEFINED; | 254 | isp->phy.state = OTG_STATE_UNDEFINED; |
255 | 255 | ||
256 | // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); | 256 | // isp1301_set_bits(isp, ISP1301_MODE_CONTROL_2, MC2_GLOBAL_PWR_DN); |
257 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); | 257 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_SUSPEND); |
@@ -280,13 +280,13 @@ static int host_suspend(struct isp1301 *isp) | |||
280 | #else | 280 | #else |
281 | struct device *dev; | 281 | struct device *dev; |
282 | 282 | ||
283 | if (!isp->otg.host) | 283 | if (!isp->phy.otg->host) |
284 | return -ENODEV; | 284 | return -ENODEV; |
285 | 285 | ||
286 | /* Currently ASSUMES only the OTG port matters; | 286 | /* Currently ASSUMES only the OTG port matters; |
287 | * other ports could be active... | 287 | * other ports could be active... |
288 | */ | 288 | */ |
289 | dev = isp->otg.host->controller; | 289 | dev = isp->phy.otg->host->controller; |
290 | return dev->driver->suspend(dev, 3, 0); | 290 | return dev->driver->suspend(dev, 3, 0); |
291 | #endif | 291 | #endif |
292 | } | 292 | } |
@@ -298,20 +298,20 @@ static int host_resume(struct isp1301 *isp) | |||
298 | #else | 298 | #else |
299 | struct device *dev; | 299 | struct device *dev; |
300 | 300 | ||
301 | if (!isp->otg.host) | 301 | if (!isp->phy.otg->host) |
302 | return -ENODEV; | 302 | return -ENODEV; |
303 | 303 | ||
304 | dev = isp->otg.host->controller; | 304 | dev = isp->phy.otg->host->controller; |
305 | return dev->driver->resume(dev, 0); | 305 | return dev->driver->resume(dev, 0); |
306 | #endif | 306 | #endif |
307 | } | 307 | } |
308 | 308 | ||
309 | static int gadget_suspend(struct isp1301 *isp) | 309 | static int gadget_suspend(struct isp1301 *isp) |
310 | { | 310 | { |
311 | isp->otg.gadget->b_hnp_enable = 0; | 311 | isp->phy.otg->gadget->b_hnp_enable = 0; |
312 | isp->otg.gadget->a_hnp_support = 0; | 312 | isp->phy.otg->gadget->a_hnp_support = 0; |
313 | isp->otg.gadget->a_alt_hnp_support = 0; | 313 | isp->phy.otg->gadget->a_alt_hnp_support = 0; |
314 | return usb_gadget_vbus_disconnect(isp->otg.gadget); | 314 | return usb_gadget_vbus_disconnect(isp->phy.otg->gadget); |
315 | } | 315 | } |
316 | 316 | ||
317 | /*-------------------------------------------------------------------------*/ | 317 | /*-------------------------------------------------------------------------*/ |
@@ -341,19 +341,19 @@ static void a_idle(struct isp1301 *isp, const char *tag) | |||
341 | { | 341 | { |
342 | u32 l; | 342 | u32 l; |
343 | 343 | ||
344 | if (isp->otg.state == OTG_STATE_A_IDLE) | 344 | if (isp->phy.state == OTG_STATE_A_IDLE) |
345 | return; | 345 | return; |
346 | 346 | ||
347 | isp->otg.default_a = 1; | 347 | isp->phy.otg->default_a = 1; |
348 | if (isp->otg.host) { | 348 | if (isp->phy.otg->host) { |
349 | isp->otg.host->is_b_host = 0; | 349 | isp->phy.otg->host->is_b_host = 0; |
350 | host_suspend(isp); | 350 | host_suspend(isp); |
351 | } | 351 | } |
352 | if (isp->otg.gadget) { | 352 | if (isp->phy.otg->gadget) { |
353 | isp->otg.gadget->is_a_peripheral = 1; | 353 | isp->phy.otg->gadget->is_a_peripheral = 1; |
354 | gadget_suspend(isp); | 354 | gadget_suspend(isp); |
355 | } | 355 | } |
356 | isp->otg.state = OTG_STATE_A_IDLE; | 356 | isp->phy.state = OTG_STATE_A_IDLE; |
357 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 357 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
358 | omap_writel(l, OTG_CTRL); | 358 | omap_writel(l, OTG_CTRL); |
359 | isp->last_otg_ctrl = l; | 359 | isp->last_otg_ctrl = l; |
@@ -365,19 +365,19 @@ static void b_idle(struct isp1301 *isp, const char *tag) | |||
365 | { | 365 | { |
366 | u32 l; | 366 | u32 l; |
367 | 367 | ||
368 | if (isp->otg.state == OTG_STATE_B_IDLE) | 368 | if (isp->phy.state == OTG_STATE_B_IDLE) |
369 | return; | 369 | return; |
370 | 370 | ||
371 | isp->otg.default_a = 0; | 371 | isp->phy.otg->default_a = 0; |
372 | if (isp->otg.host) { | 372 | if (isp->phy.otg->host) { |
373 | isp->otg.host->is_b_host = 1; | 373 | isp->phy.otg->host->is_b_host = 1; |
374 | host_suspend(isp); | 374 | host_suspend(isp); |
375 | } | 375 | } |
376 | if (isp->otg.gadget) { | 376 | if (isp->phy.otg->gadget) { |
377 | isp->otg.gadget->is_a_peripheral = 0; | 377 | isp->phy.otg->gadget->is_a_peripheral = 0; |
378 | gadget_suspend(isp); | 378 | gadget_suspend(isp); |
379 | } | 379 | } |
380 | isp->otg.state = OTG_STATE_B_IDLE; | 380 | isp->phy.state = OTG_STATE_B_IDLE; |
381 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 381 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
382 | omap_writel(l, OTG_CTRL); | 382 | omap_writel(l, OTG_CTRL); |
383 | isp->last_otg_ctrl = l; | 383 | isp->last_otg_ctrl = l; |
@@ -478,7 +478,7 @@ static void check_state(struct isp1301 *isp, const char *tag) | |||
478 | default: | 478 | default: |
479 | break; | 479 | break; |
480 | } | 480 | } |
481 | if (isp->otg.state == state && !extra) | 481 | if (isp->phy.state == state && !extra) |
482 | return; | 482 | return; |
483 | pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, | 483 | pr_debug("otg: %s FSM %s/%02x, %s, %06x\n", tag, |
484 | otg_state_string(state), fsm, state_name(isp), | 484 | otg_state_string(state), fsm, state_name(isp), |
@@ -502,22 +502,23 @@ static void update_otg1(struct isp1301 *isp, u8 int_src) | |||
502 | 502 | ||
503 | if (int_src & INTR_SESS_VLD) | 503 | if (int_src & INTR_SESS_VLD) |
504 | otg_ctrl |= OTG_ASESSVLD; | 504 | otg_ctrl |= OTG_ASESSVLD; |
505 | else if (isp->otg.state == OTG_STATE_A_WAIT_VFALL) { | 505 | else if (isp->phy.state == OTG_STATE_A_WAIT_VFALL) { |
506 | a_idle(isp, "vfall"); | 506 | a_idle(isp, "vfall"); |
507 | otg_ctrl &= ~OTG_CTRL_BITS; | 507 | otg_ctrl &= ~OTG_CTRL_BITS; |
508 | } | 508 | } |
509 | if (int_src & INTR_VBUS_VLD) | 509 | if (int_src & INTR_VBUS_VLD) |
510 | otg_ctrl |= OTG_VBUSVLD; | 510 | otg_ctrl |= OTG_VBUSVLD; |
511 | if (int_src & INTR_ID_GND) { /* default-A */ | 511 | if (int_src & INTR_ID_GND) { /* default-A */ |
512 | if (isp->otg.state == OTG_STATE_B_IDLE | 512 | if (isp->phy.state == OTG_STATE_B_IDLE |
513 | || isp->otg.state == OTG_STATE_UNDEFINED) { | 513 | || isp->phy.state |
514 | == OTG_STATE_UNDEFINED) { | ||
514 | a_idle(isp, "init"); | 515 | a_idle(isp, "init"); |
515 | return; | 516 | return; |
516 | } | 517 | } |
517 | } else { /* default-B */ | 518 | } else { /* default-B */ |
518 | otg_ctrl |= OTG_ID; | 519 | otg_ctrl |= OTG_ID; |
519 | if (isp->otg.state == OTG_STATE_A_IDLE | 520 | if (isp->phy.state == OTG_STATE_A_IDLE |
520 | || isp->otg.state == OTG_STATE_UNDEFINED) { | 521 | || isp->phy.state == OTG_STATE_UNDEFINED) { |
521 | b_idle(isp, "init"); | 522 | b_idle(isp, "init"); |
522 | return; | 523 | return; |
523 | } | 524 | } |
@@ -551,14 +552,14 @@ static void otg_update_isp(struct isp1301 *isp) | |||
551 | isp->last_otg_ctrl = otg_ctrl; | 552 | isp->last_otg_ctrl = otg_ctrl; |
552 | otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; | 553 | otg_ctrl = otg_ctrl & OTG_XCEIV_INPUTS; |
553 | 554 | ||
554 | switch (isp->otg.state) { | 555 | switch (isp->phy.state) { |
555 | case OTG_STATE_B_IDLE: | 556 | case OTG_STATE_B_IDLE: |
556 | case OTG_STATE_B_PERIPHERAL: | 557 | case OTG_STATE_B_PERIPHERAL: |
557 | case OTG_STATE_B_SRP_INIT: | 558 | case OTG_STATE_B_SRP_INIT: |
558 | if (!(otg_ctrl & OTG_PULLUP)) { | 559 | if (!(otg_ctrl & OTG_PULLUP)) { |
559 | // if (otg_ctrl & OTG_B_HNPEN) { | 560 | // if (otg_ctrl & OTG_B_HNPEN) { |
560 | if (isp->otg.gadget->b_hnp_enable) { | 561 | if (isp->phy.otg->gadget->b_hnp_enable) { |
561 | isp->otg.state = OTG_STATE_B_WAIT_ACON; | 562 | isp->phy.state = OTG_STATE_B_WAIT_ACON; |
562 | pr_debug(" --> b_wait_acon\n"); | 563 | pr_debug(" --> b_wait_acon\n"); |
563 | } | 564 | } |
564 | goto pulldown; | 565 | goto pulldown; |
@@ -585,10 +586,10 @@ pulldown: | |||
585 | else clr |= ISP; \ | 586 | else clr |= ISP; \ |
586 | } while (0) | 587 | } while (0) |
587 | 588 | ||
588 | if (!(isp->otg.host)) | 589 | if (!(isp->phy.otg->host)) |
589 | otg_ctrl &= ~OTG_DRV_VBUS; | 590 | otg_ctrl &= ~OTG_DRV_VBUS; |
590 | 591 | ||
591 | switch (isp->otg.state) { | 592 | switch (isp->phy.state) { |
592 | case OTG_STATE_A_SUSPEND: | 593 | case OTG_STATE_A_SUSPEND: |
593 | if (otg_ctrl & OTG_DRV_VBUS) { | 594 | if (otg_ctrl & OTG_DRV_VBUS) { |
594 | set |= OTG1_VBUS_DRV; | 595 | set |= OTG1_VBUS_DRV; |
@@ -599,7 +600,7 @@ pulldown: | |||
599 | 600 | ||
600 | /* FALLTHROUGH */ | 601 | /* FALLTHROUGH */ |
601 | case OTG_STATE_A_VBUS_ERR: | 602 | case OTG_STATE_A_VBUS_ERR: |
602 | isp->otg.state = OTG_STATE_A_WAIT_VFALL; | 603 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; |
603 | pr_debug(" --> a_wait_vfall\n"); | 604 | pr_debug(" --> a_wait_vfall\n"); |
604 | /* FALLTHROUGH */ | 605 | /* FALLTHROUGH */ |
605 | case OTG_STATE_A_WAIT_VFALL: | 606 | case OTG_STATE_A_WAIT_VFALL: |
@@ -608,7 +609,7 @@ pulldown: | |||
608 | break; | 609 | break; |
609 | case OTG_STATE_A_IDLE: | 610 | case OTG_STATE_A_IDLE: |
610 | if (otg_ctrl & OTG_DRV_VBUS) { | 611 | if (otg_ctrl & OTG_DRV_VBUS) { |
611 | isp->otg.state = OTG_STATE_A_WAIT_VRISE; | 612 | isp->phy.state = OTG_STATE_A_WAIT_VRISE; |
612 | pr_debug(" --> a_wait_vrise\n"); | 613 | pr_debug(" --> a_wait_vrise\n"); |
613 | } | 614 | } |
614 | /* FALLTHROUGH */ | 615 | /* FALLTHROUGH */ |
@@ -628,17 +629,17 @@ pulldown: | |||
628 | if (otg_change & OTG_PULLUP) { | 629 | if (otg_change & OTG_PULLUP) { |
629 | u32 l; | 630 | u32 l; |
630 | 631 | ||
631 | switch (isp->otg.state) { | 632 | switch (isp->phy.state) { |
632 | case OTG_STATE_B_IDLE: | 633 | case OTG_STATE_B_IDLE: |
633 | if (clr & OTG1_DP_PULLUP) | 634 | if (clr & OTG1_DP_PULLUP) |
634 | break; | 635 | break; |
635 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 636 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
636 | pr_debug(" --> b_peripheral\n"); | 637 | pr_debug(" --> b_peripheral\n"); |
637 | break; | 638 | break; |
638 | case OTG_STATE_A_SUSPEND: | 639 | case OTG_STATE_A_SUSPEND: |
639 | if (clr & OTG1_DP_PULLUP) | 640 | if (clr & OTG1_DP_PULLUP) |
640 | break; | 641 | break; |
641 | isp->otg.state = OTG_STATE_A_PERIPHERAL; | 642 | isp->phy.state = OTG_STATE_A_PERIPHERAL; |
642 | pr_debug(" --> a_peripheral\n"); | 643 | pr_debug(" --> a_peripheral\n"); |
643 | break; | 644 | break; |
644 | default: | 645 | default: |
@@ -659,6 +660,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
659 | u32 otg_ctrl; | 660 | u32 otg_ctrl; |
660 | int ret = IRQ_NONE; | 661 | int ret = IRQ_NONE; |
661 | struct isp1301 *isp = _isp; | 662 | struct isp1301 *isp = _isp; |
663 | struct usb_otg *otg = isp->phy.otg; | ||
662 | 664 | ||
663 | /* update ISP1301 transceiver from OTG controller */ | 665 | /* update ISP1301 transceiver from OTG controller */ |
664 | if (otg_irq & OPRT_CHG) { | 666 | if (otg_irq & OPRT_CHG) { |
@@ -675,7 +677,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
675 | * remote wakeup (SRP, normal) using their own timer | 677 | * remote wakeup (SRP, normal) using their own timer |
676 | * to give "check cable and A-device" messages. | 678 | * to give "check cable and A-device" messages. |
677 | */ | 679 | */ |
678 | if (isp->otg.state == OTG_STATE_B_SRP_INIT) | 680 | if (isp->phy.state == OTG_STATE_B_SRP_INIT) |
679 | b_idle(isp, "srp_timeout"); | 681 | b_idle(isp, "srp_timeout"); |
680 | 682 | ||
681 | omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); | 683 | omap_writew(B_SRP_TMROUT, OTG_IRQ_SRC); |
@@ -693,7 +695,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
693 | omap_writel(otg_ctrl, OTG_CTRL); | 695 | omap_writel(otg_ctrl, OTG_CTRL); |
694 | 696 | ||
695 | /* subset of b_peripheral()... */ | 697 | /* subset of b_peripheral()... */ |
696 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 698 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
697 | pr_debug(" --> b_peripheral\n"); | 699 | pr_debug(" --> b_peripheral\n"); |
698 | 700 | ||
699 | omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); | 701 | omap_writew(B_HNP_FAIL, OTG_IRQ_SRC); |
@@ -705,9 +707,9 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
705 | state_name(isp), omap_readl(OTG_CTRL)); | 707 | state_name(isp), omap_readl(OTG_CTRL)); |
706 | 708 | ||
707 | isp1301_defer_work(isp, WORK_UPDATE_OTG); | 709 | isp1301_defer_work(isp, WORK_UPDATE_OTG); |
708 | switch (isp->otg.state) { | 710 | switch (isp->phy.state) { |
709 | case OTG_STATE_A_IDLE: | 711 | case OTG_STATE_A_IDLE: |
710 | if (!isp->otg.host) | 712 | if (!otg->host) |
711 | break; | 713 | break; |
712 | isp1301_defer_work(isp, WORK_HOST_RESUME); | 714 | isp1301_defer_work(isp, WORK_HOST_RESUME); |
713 | otg_ctrl = omap_readl(OTG_CTRL); | 715 | otg_ctrl = omap_readl(OTG_CTRL); |
@@ -736,7 +738,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
736 | otg_ctrl |= OTG_BUSDROP; | 738 | otg_ctrl |= OTG_BUSDROP; |
737 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; | 739 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; |
738 | omap_writel(otg_ctrl, OTG_CTRL); | 740 | omap_writel(otg_ctrl, OTG_CTRL); |
739 | isp->otg.state = OTG_STATE_A_WAIT_VFALL; | 741 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; |
740 | 742 | ||
741 | omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); | 743 | omap_writew(A_REQ_TMROUT, OTG_IRQ_SRC); |
742 | ret = IRQ_HANDLED; | 744 | ret = IRQ_HANDLED; |
@@ -750,7 +752,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
750 | otg_ctrl |= OTG_BUSDROP; | 752 | otg_ctrl |= OTG_BUSDROP; |
751 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; | 753 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK & ~OTG_XCEIV_INPUTS; |
752 | omap_writel(otg_ctrl, OTG_CTRL); | 754 | omap_writel(otg_ctrl, OTG_CTRL); |
753 | isp->otg.state = OTG_STATE_A_VBUS_ERR; | 755 | isp->phy.state = OTG_STATE_A_VBUS_ERR; |
754 | 756 | ||
755 | omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); | 757 | omap_writew(A_VBUS_ERR, OTG_IRQ_SRC); |
756 | ret = IRQ_HANDLED; | 758 | ret = IRQ_HANDLED; |
@@ -771,7 +773,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
771 | 773 | ||
772 | /* role is peripheral */ | 774 | /* role is peripheral */ |
773 | if (otg_ctrl & OTG_DRIVER_SEL) { | 775 | if (otg_ctrl & OTG_DRIVER_SEL) { |
774 | switch (isp->otg.state) { | 776 | switch (isp->phy.state) { |
775 | case OTG_STATE_A_IDLE: | 777 | case OTG_STATE_A_IDLE: |
776 | b_idle(isp, __func__); | 778 | b_idle(isp, __func__); |
777 | break; | 779 | break; |
@@ -787,19 +789,19 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
787 | omap_writel(otg_ctrl | OTG_A_BUSREQ, OTG_CTRL); | 789 | omap_writel(otg_ctrl | OTG_A_BUSREQ, OTG_CTRL); |
788 | } | 790 | } |
789 | 791 | ||
790 | if (isp->otg.host) { | 792 | if (otg->host) { |
791 | switch (isp->otg.state) { | 793 | switch (isp->phy.state) { |
792 | case OTG_STATE_B_WAIT_ACON: | 794 | case OTG_STATE_B_WAIT_ACON: |
793 | isp->otg.state = OTG_STATE_B_HOST; | 795 | isp->phy.state = OTG_STATE_B_HOST; |
794 | pr_debug(" --> b_host\n"); | 796 | pr_debug(" --> b_host\n"); |
795 | kick = 1; | 797 | kick = 1; |
796 | break; | 798 | break; |
797 | case OTG_STATE_A_WAIT_BCON: | 799 | case OTG_STATE_A_WAIT_BCON: |
798 | isp->otg.state = OTG_STATE_A_HOST; | 800 | isp->phy.state = OTG_STATE_A_HOST; |
799 | pr_debug(" --> a_host\n"); | 801 | pr_debug(" --> a_host\n"); |
800 | break; | 802 | break; |
801 | case OTG_STATE_A_PERIPHERAL: | 803 | case OTG_STATE_A_PERIPHERAL: |
802 | isp->otg.state = OTG_STATE_A_WAIT_BCON; | 804 | isp->phy.state = OTG_STATE_A_WAIT_BCON; |
803 | pr_debug(" --> a_wait_bcon\n"); | 805 | pr_debug(" --> a_wait_bcon\n"); |
804 | break; | 806 | break; |
805 | default: | 807 | default: |
@@ -813,8 +815,7 @@ static irqreturn_t omap_otg_irq(int irq, void *_isp) | |||
813 | ret = IRQ_HANDLED; | 815 | ret = IRQ_HANDLED; |
814 | 816 | ||
815 | if (kick) | 817 | if (kick) |
816 | usb_bus_start_enum(isp->otg.host, | 818 | usb_bus_start_enum(otg->host, otg->host->otg_port); |
817 | isp->otg.host->otg_port); | ||
818 | } | 819 | } |
819 | 820 | ||
820 | check_state(isp, __func__); | 821 | check_state(isp, __func__); |
@@ -930,7 +931,7 @@ static void b_peripheral(struct isp1301 *isp) | |||
930 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; | 931 | l = omap_readl(OTG_CTRL) & OTG_XCEIV_OUTPUTS; |
931 | omap_writel(l, OTG_CTRL); | 932 | omap_writel(l, OTG_CTRL); |
932 | 933 | ||
933 | usb_gadget_vbus_connect(isp->otg.gadget); | 934 | usb_gadget_vbus_connect(isp->phy.otg->gadget); |
934 | 935 | ||
935 | #ifdef CONFIG_USB_OTG | 936 | #ifdef CONFIG_USB_OTG |
936 | enable_vbus_draw(isp, 8); | 937 | enable_vbus_draw(isp, 8); |
@@ -940,7 +941,7 @@ static void b_peripheral(struct isp1301 *isp) | |||
940 | /* UDC driver just set OTG_BSESSVLD */ | 941 | /* UDC driver just set OTG_BSESSVLD */ |
941 | isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); | 942 | isp1301_set_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLUP); |
942 | isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); | 943 | isp1301_clear_bits(isp, ISP1301_OTG_CONTROL_1, OTG1_DP_PULLDOWN); |
943 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 944 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
944 | pr_debug(" --> b_peripheral\n"); | 945 | pr_debug(" --> b_peripheral\n"); |
945 | dump_regs(isp, "2periph"); | 946 | dump_regs(isp, "2periph"); |
946 | #endif | 947 | #endif |
@@ -948,8 +949,9 @@ static void b_peripheral(struct isp1301 *isp) | |||
948 | 949 | ||
949 | static void isp_update_otg(struct isp1301 *isp, u8 stat) | 950 | static void isp_update_otg(struct isp1301 *isp, u8 stat) |
950 | { | 951 | { |
952 | struct usb_otg *otg = isp->phy.otg; | ||
951 | u8 isp_stat, isp_bstat; | 953 | u8 isp_stat, isp_bstat; |
952 | enum usb_otg_state state = isp->otg.state; | 954 | enum usb_otg_state state = isp->phy.state; |
953 | 955 | ||
954 | if (stat & INTR_BDIS_ACON) | 956 | if (stat & INTR_BDIS_ACON) |
955 | pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); | 957 | pr_debug("OTG: BDIS_ACON, %s\n", state_name(isp)); |
@@ -957,7 +959,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
957 | /* start certain state transitions right away */ | 959 | /* start certain state transitions right away */ |
958 | isp_stat = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE); | 960 | isp_stat = isp1301_get_u8(isp, ISP1301_INTERRUPT_SOURCE); |
959 | if (isp_stat & INTR_ID_GND) { | 961 | if (isp_stat & INTR_ID_GND) { |
960 | if (isp->otg.default_a) { | 962 | if (otg->default_a) { |
961 | switch (state) { | 963 | switch (state) { |
962 | case OTG_STATE_B_IDLE: | 964 | case OTG_STATE_B_IDLE: |
963 | a_idle(isp, "idle"); | 965 | a_idle(isp, "idle"); |
@@ -972,7 +974,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
972 | * when HNP is used. | 974 | * when HNP is used. |
973 | */ | 975 | */ |
974 | if (isp_stat & INTR_VBUS_VLD) | 976 | if (isp_stat & INTR_VBUS_VLD) |
975 | isp->otg.state = OTG_STATE_A_HOST; | 977 | isp->phy.state = OTG_STATE_A_HOST; |
976 | break; | 978 | break; |
977 | case OTG_STATE_A_WAIT_VFALL: | 979 | case OTG_STATE_A_WAIT_VFALL: |
978 | if (!(isp_stat & INTR_SESS_VLD)) | 980 | if (!(isp_stat & INTR_SESS_VLD)) |
@@ -980,7 +982,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
980 | break; | 982 | break; |
981 | default: | 983 | default: |
982 | if (!(isp_stat & INTR_VBUS_VLD)) | 984 | if (!(isp_stat & INTR_VBUS_VLD)) |
983 | isp->otg.state = OTG_STATE_A_VBUS_ERR; | 985 | isp->phy.state = OTG_STATE_A_VBUS_ERR; |
984 | break; | 986 | break; |
985 | } | 987 | } |
986 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); | 988 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); |
@@ -989,14 +991,14 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
989 | case OTG_STATE_B_PERIPHERAL: | 991 | case OTG_STATE_B_PERIPHERAL: |
990 | case OTG_STATE_B_HOST: | 992 | case OTG_STATE_B_HOST: |
991 | case OTG_STATE_B_WAIT_ACON: | 993 | case OTG_STATE_B_WAIT_ACON: |
992 | usb_gadget_vbus_disconnect(isp->otg.gadget); | 994 | usb_gadget_vbus_disconnect(otg->gadget); |
993 | break; | 995 | break; |
994 | default: | 996 | default: |
995 | break; | 997 | break; |
996 | } | 998 | } |
997 | if (state != OTG_STATE_A_IDLE) | 999 | if (state != OTG_STATE_A_IDLE) |
998 | a_idle(isp, "id"); | 1000 | a_idle(isp, "id"); |
999 | if (isp->otg.host && state == OTG_STATE_A_IDLE) | 1001 | if (otg->host && state == OTG_STATE_A_IDLE) |
1000 | isp1301_defer_work(isp, WORK_HOST_RESUME); | 1002 | isp1301_defer_work(isp, WORK_HOST_RESUME); |
1001 | isp_bstat = 0; | 1003 | isp_bstat = 0; |
1002 | } | 1004 | } |
@@ -1006,10 +1008,10 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1006 | /* if user unplugged mini-A end of cable, | 1008 | /* if user unplugged mini-A end of cable, |
1007 | * don't bypass A_WAIT_VFALL. | 1009 | * don't bypass A_WAIT_VFALL. |
1008 | */ | 1010 | */ |
1009 | if (isp->otg.default_a) { | 1011 | if (otg->default_a) { |
1010 | switch (state) { | 1012 | switch (state) { |
1011 | default: | 1013 | default: |
1012 | isp->otg.state = OTG_STATE_A_WAIT_VFALL; | 1014 | isp->phy.state = OTG_STATE_A_WAIT_VFALL; |
1013 | break; | 1015 | break; |
1014 | case OTG_STATE_A_WAIT_VFALL: | 1016 | case OTG_STATE_A_WAIT_VFALL: |
1015 | state = OTG_STATE_A_IDLE; | 1017 | state = OTG_STATE_A_IDLE; |
@@ -1022,7 +1024,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1022 | host_suspend(isp); | 1024 | host_suspend(isp); |
1023 | isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, | 1025 | isp1301_clear_bits(isp, ISP1301_MODE_CONTROL_1, |
1024 | MC1_BDIS_ACON_EN); | 1026 | MC1_BDIS_ACON_EN); |
1025 | isp->otg.state = OTG_STATE_B_IDLE; | 1027 | isp->phy.state = OTG_STATE_B_IDLE; |
1026 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; | 1028 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; |
1027 | l &= ~OTG_CTRL_BITS; | 1029 | l &= ~OTG_CTRL_BITS; |
1028 | omap_writel(l, OTG_CTRL); | 1030 | omap_writel(l, OTG_CTRL); |
@@ -1033,7 +1035,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1033 | } | 1035 | } |
1034 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); | 1036 | isp_bstat = isp1301_get_u8(isp, ISP1301_OTG_STATUS); |
1035 | 1037 | ||
1036 | switch (isp->otg.state) { | 1038 | switch (isp->phy.state) { |
1037 | case OTG_STATE_B_PERIPHERAL: | 1039 | case OTG_STATE_B_PERIPHERAL: |
1038 | case OTG_STATE_B_WAIT_ACON: | 1040 | case OTG_STATE_B_WAIT_ACON: |
1039 | case OTG_STATE_B_HOST: | 1041 | case OTG_STATE_B_HOST: |
@@ -1055,7 +1057,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1055 | omap_writel(l, OTG_CTRL); | 1057 | omap_writel(l, OTG_CTRL); |
1056 | /* FALLTHROUGH */ | 1058 | /* FALLTHROUGH */ |
1057 | case OTG_STATE_B_IDLE: | 1059 | case OTG_STATE_B_IDLE: |
1058 | if (isp->otg.gadget && (isp_bstat & OTG_B_SESS_VLD)) { | 1060 | if (otg->gadget && (isp_bstat & OTG_B_SESS_VLD)) { |
1059 | #ifdef CONFIG_USB_OTG | 1061 | #ifdef CONFIG_USB_OTG |
1060 | update_otg1(isp, isp_stat); | 1062 | update_otg1(isp, isp_stat); |
1061 | update_otg2(isp, isp_bstat); | 1063 | update_otg2(isp, isp_bstat); |
@@ -1073,7 +1075,7 @@ static void isp_update_otg(struct isp1301 *isp, u8 stat) | |||
1073 | } | 1075 | } |
1074 | } | 1076 | } |
1075 | 1077 | ||
1076 | if (state != isp->otg.state) | 1078 | if (state != isp->phy.state) |
1077 | pr_debug(" isp, %s -> %s\n", | 1079 | pr_debug(" isp, %s -> %s\n", |
1078 | otg_state_string(state), state_name(isp)); | 1080 | otg_state_string(state), state_name(isp)); |
1079 | 1081 | ||
@@ -1131,10 +1133,10 @@ isp1301_work(struct work_struct *work) | |||
1131 | * skip A_WAIT_VRISE; hc transitions invisibly | 1133 | * skip A_WAIT_VRISE; hc transitions invisibly |
1132 | * skip A_WAIT_BCON; same. | 1134 | * skip A_WAIT_BCON; same. |
1133 | */ | 1135 | */ |
1134 | switch (isp->otg.state) { | 1136 | switch (isp->phy.state) { |
1135 | case OTG_STATE_A_WAIT_BCON: | 1137 | case OTG_STATE_A_WAIT_BCON: |
1136 | case OTG_STATE_A_WAIT_VRISE: | 1138 | case OTG_STATE_A_WAIT_VRISE: |
1137 | isp->otg.state = OTG_STATE_A_HOST; | 1139 | isp->phy.state = OTG_STATE_A_HOST; |
1138 | pr_debug(" --> a_host\n"); | 1140 | pr_debug(" --> a_host\n"); |
1139 | otg_ctrl = omap_readl(OTG_CTRL); | 1141 | otg_ctrl = omap_readl(OTG_CTRL); |
1140 | otg_ctrl |= OTG_A_BUSREQ; | 1142 | otg_ctrl |= OTG_A_BUSREQ; |
@@ -1143,7 +1145,7 @@ isp1301_work(struct work_struct *work) | |||
1143 | omap_writel(otg_ctrl, OTG_CTRL); | 1145 | omap_writel(otg_ctrl, OTG_CTRL); |
1144 | break; | 1146 | break; |
1145 | case OTG_STATE_B_WAIT_ACON: | 1147 | case OTG_STATE_B_WAIT_ACON: |
1146 | isp->otg.state = OTG_STATE_B_HOST; | 1148 | isp->phy.state = OTG_STATE_B_HOST; |
1147 | pr_debug(" --> b_host (acon)\n"); | 1149 | pr_debug(" --> b_host (acon)\n"); |
1148 | break; | 1150 | break; |
1149 | case OTG_STATE_B_HOST: | 1151 | case OTG_STATE_B_HOST: |
@@ -1204,6 +1206,7 @@ static void isp1301_release(struct device *dev) | |||
1204 | /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ | 1206 | /* ugly -- i2c hijacks our memory hook to wait_for_completion() */ |
1205 | if (isp->i2c_release) | 1207 | if (isp->i2c_release) |
1206 | isp->i2c_release(dev); | 1208 | isp->i2c_release(dev); |
1209 | kfree(isp->phy.otg); | ||
1207 | kfree (isp); | 1210 | kfree (isp); |
1208 | } | 1211 | } |
1209 | 1212 | ||
@@ -1274,9 +1277,9 @@ static int isp1301_otg_enable(struct isp1301 *isp) | |||
1274 | 1277 | ||
1275 | /* add or disable the host device+driver */ | 1278 | /* add or disable the host device+driver */ |
1276 | static int | 1279 | static int |
1277 | isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | 1280 | isp1301_set_host(struct usb_otg *otg, struct usb_bus *host) |
1278 | { | 1281 | { |
1279 | struct isp1301 *isp = container_of(otg, struct isp1301, otg); | 1282 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1280 | 1283 | ||
1281 | if (!otg || isp != the_transceiver) | 1284 | if (!otg || isp != the_transceiver) |
1282 | return -ENODEV; | 1285 | return -ENODEV; |
@@ -1284,21 +1287,21 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1284 | if (!host) { | 1287 | if (!host) { |
1285 | omap_writew(0, OTG_IRQ_EN); | 1288 | omap_writew(0, OTG_IRQ_EN); |
1286 | power_down(isp); | 1289 | power_down(isp); |
1287 | isp->otg.host = NULL; | 1290 | otg->host = NULL; |
1288 | return 0; | 1291 | return 0; |
1289 | } | 1292 | } |
1290 | 1293 | ||
1291 | #ifdef CONFIG_USB_OTG | 1294 | #ifdef CONFIG_USB_OTG |
1292 | isp->otg.host = host; | 1295 | otg->host = host; |
1293 | dev_dbg(&isp->client->dev, "registered host\n"); | 1296 | dev_dbg(&isp->client->dev, "registered host\n"); |
1294 | host_suspend(isp); | 1297 | host_suspend(isp); |
1295 | if (isp->otg.gadget) | 1298 | if (otg->gadget) |
1296 | return isp1301_otg_enable(isp); | 1299 | return isp1301_otg_enable(isp); |
1297 | return 0; | 1300 | return 0; |
1298 | 1301 | ||
1299 | #elif !defined(CONFIG_USB_GADGET_OMAP) | 1302 | #elif !defined(CONFIG_USB_GADGET_OMAP) |
1300 | // FIXME update its refcount | 1303 | // FIXME update its refcount |
1301 | isp->otg.host = host; | 1304 | otg->host = host; |
1302 | 1305 | ||
1303 | power_up(isp); | 1306 | power_up(isp); |
1304 | 1307 | ||
@@ -1330,9 +1333,9 @@ isp1301_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
1330 | } | 1333 | } |
1331 | 1334 | ||
1332 | static int | 1335 | static int |
1333 | isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | 1336 | isp1301_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) |
1334 | { | 1337 | { |
1335 | struct isp1301 *isp = container_of(otg, struct isp1301, otg); | 1338 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1336 | #ifndef CONFIG_USB_OTG | 1339 | #ifndef CONFIG_USB_OTG |
1337 | u32 l; | 1340 | u32 l; |
1338 | #endif | 1341 | #endif |
@@ -1342,24 +1345,24 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1342 | 1345 | ||
1343 | if (!gadget) { | 1346 | if (!gadget) { |
1344 | omap_writew(0, OTG_IRQ_EN); | 1347 | omap_writew(0, OTG_IRQ_EN); |
1345 | if (!isp->otg.default_a) | 1348 | if (!otg->default_a) |
1346 | enable_vbus_draw(isp, 0); | 1349 | enable_vbus_draw(isp, 0); |
1347 | usb_gadget_vbus_disconnect(isp->otg.gadget); | 1350 | usb_gadget_vbus_disconnect(otg->gadget); |
1348 | isp->otg.gadget = NULL; | 1351 | otg->gadget = NULL; |
1349 | power_down(isp); | 1352 | power_down(isp); |
1350 | return 0; | 1353 | return 0; |
1351 | } | 1354 | } |
1352 | 1355 | ||
1353 | #ifdef CONFIG_USB_OTG | 1356 | #ifdef CONFIG_USB_OTG |
1354 | isp->otg.gadget = gadget; | 1357 | otg->gadget = gadget; |
1355 | dev_dbg(&isp->client->dev, "registered gadget\n"); | 1358 | dev_dbg(&isp->client->dev, "registered gadget\n"); |
1356 | /* gadget driver may be suspended until vbus_connect () */ | 1359 | /* gadget driver may be suspended until vbus_connect () */ |
1357 | if (isp->otg.host) | 1360 | if (otg->host) |
1358 | return isp1301_otg_enable(isp); | 1361 | return isp1301_otg_enable(isp); |
1359 | return 0; | 1362 | return 0; |
1360 | 1363 | ||
1361 | #elif !defined(CONFIG_USB_OHCI_HCD) && !defined(CONFIG_USB_OHCI_HCD_MODULE) | 1364 | #elif !defined(CONFIG_USB_OHCI_HCD) && !defined(CONFIG_USB_OHCI_HCD_MODULE) |
1362 | isp->otg.gadget = gadget; | 1365 | otg->gadget = gadget; |
1363 | // FIXME update its refcount | 1366 | // FIXME update its refcount |
1364 | 1367 | ||
1365 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; | 1368 | l = omap_readl(OTG_CTRL) & OTG_CTRL_MASK; |
@@ -1368,7 +1371,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1368 | omap_writel(l, OTG_CTRL); | 1371 | omap_writel(l, OTG_CTRL); |
1369 | 1372 | ||
1370 | power_up(isp); | 1373 | power_up(isp); |
1371 | isp->otg.state = OTG_STATE_B_IDLE; | 1374 | isp->phy.state = OTG_STATE_B_IDLE; |
1372 | 1375 | ||
1373 | if (machine_is_omap_h2() || machine_is_omap_h3()) | 1376 | if (machine_is_omap_h2() || machine_is_omap_h3()) |
1374 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); | 1377 | isp1301_set_bits(isp, ISP1301_MODE_CONTROL_1, MC1_DAT_SE0); |
@@ -1399,7 +1402,7 @@ isp1301_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *gadget) | |||
1399 | /*-------------------------------------------------------------------------*/ | 1402 | /*-------------------------------------------------------------------------*/ |
1400 | 1403 | ||
1401 | static int | 1404 | static int |
1402 | isp1301_set_power(struct otg_transceiver *dev, unsigned mA) | 1405 | isp1301_set_power(struct usb_phy *dev, unsigned mA) |
1403 | { | 1406 | { |
1404 | if (!the_transceiver) | 1407 | if (!the_transceiver) |
1405 | return -ENODEV; | 1408 | return -ENODEV; |
@@ -1409,13 +1412,13 @@ isp1301_set_power(struct otg_transceiver *dev, unsigned mA) | |||
1409 | } | 1412 | } |
1410 | 1413 | ||
1411 | static int | 1414 | static int |
1412 | isp1301_start_srp(struct otg_transceiver *dev) | 1415 | isp1301_start_srp(struct usb_otg *otg) |
1413 | { | 1416 | { |
1414 | struct isp1301 *isp = container_of(dev, struct isp1301, otg); | 1417 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1415 | u32 otg_ctrl; | 1418 | u32 otg_ctrl; |
1416 | 1419 | ||
1417 | if (!dev || isp != the_transceiver | 1420 | if (!otg || isp != the_transceiver |
1418 | || isp->otg.state != OTG_STATE_B_IDLE) | 1421 | || isp->phy.state != OTG_STATE_B_IDLE) |
1419 | return -ENODEV; | 1422 | return -ENODEV; |
1420 | 1423 | ||
1421 | otg_ctrl = omap_readl(OTG_CTRL); | 1424 | otg_ctrl = omap_readl(OTG_CTRL); |
@@ -1425,7 +1428,7 @@ isp1301_start_srp(struct otg_transceiver *dev) | |||
1425 | otg_ctrl |= OTG_B_BUSREQ; | 1428 | otg_ctrl |= OTG_B_BUSREQ; |
1426 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; | 1429 | otg_ctrl &= ~OTG_A_BUSREQ & OTG_CTRL_MASK; |
1427 | omap_writel(otg_ctrl, OTG_CTRL); | 1430 | omap_writel(otg_ctrl, OTG_CTRL); |
1428 | isp->otg.state = OTG_STATE_B_SRP_INIT; | 1431 | isp->phy.state = OTG_STATE_B_SRP_INIT; |
1429 | 1432 | ||
1430 | pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), | 1433 | pr_debug("otg: SRP, %s ... %06x\n", state_name(isp), |
1431 | omap_readl(OTG_CTRL)); | 1434 | omap_readl(OTG_CTRL)); |
@@ -1436,27 +1439,26 @@ isp1301_start_srp(struct otg_transceiver *dev) | |||
1436 | } | 1439 | } |
1437 | 1440 | ||
1438 | static int | 1441 | static int |
1439 | isp1301_start_hnp(struct otg_transceiver *dev) | 1442 | isp1301_start_hnp(struct usb_otg *otg) |
1440 | { | 1443 | { |
1441 | #ifdef CONFIG_USB_OTG | 1444 | #ifdef CONFIG_USB_OTG |
1442 | struct isp1301 *isp = container_of(dev, struct isp1301, otg); | 1445 | struct isp1301 *isp = container_of(otg->phy, struct isp1301, phy); |
1443 | u32 l; | 1446 | u32 l; |
1444 | 1447 | ||
1445 | if (!dev || isp != the_transceiver) | 1448 | if (!otg || isp != the_transceiver) |
1446 | return -ENODEV; | 1449 | return -ENODEV; |
1447 | if (isp->otg.default_a && (isp->otg.host == NULL | 1450 | if (otg->default_a && (otg->host == NULL || !otg->host->b_hnp_enable)) |
1448 | || !isp->otg.host->b_hnp_enable)) | ||
1449 | return -ENOTCONN; | 1451 | return -ENOTCONN; |
1450 | if (!isp->otg.default_a && (isp->otg.gadget == NULL | 1452 | if (!otg->default_a && (otg->gadget == NULL |
1451 | || !isp->otg.gadget->b_hnp_enable)) | 1453 | || !otg->gadget->b_hnp_enable)) |
1452 | return -ENOTCONN; | 1454 | return -ENOTCONN; |
1453 | 1455 | ||
1454 | /* We want hardware to manage most HNP protocol timings. | 1456 | /* We want hardware to manage most HNP protocol timings. |
1455 | * So do this part as early as possible... | 1457 | * So do this part as early as possible... |
1456 | */ | 1458 | */ |
1457 | switch (isp->otg.state) { | 1459 | switch (isp->phy.state) { |
1458 | case OTG_STATE_B_HOST: | 1460 | case OTG_STATE_B_HOST: |
1459 | isp->otg.state = OTG_STATE_B_PERIPHERAL; | 1461 | isp->phy.state = OTG_STATE_B_PERIPHERAL; |
1460 | /* caller will suspend next */ | 1462 | /* caller will suspend next */ |
1461 | break; | 1463 | break; |
1462 | case OTG_STATE_A_HOST: | 1464 | case OTG_STATE_A_HOST: |
@@ -1466,7 +1468,7 @@ isp1301_start_hnp(struct otg_transceiver *dev) | |||
1466 | MC1_BDIS_ACON_EN); | 1468 | MC1_BDIS_ACON_EN); |
1467 | #endif | 1469 | #endif |
1468 | /* caller must suspend then clear A_BUSREQ */ | 1470 | /* caller must suspend then clear A_BUSREQ */ |
1469 | usb_gadget_vbus_connect(isp->otg.gadget); | 1471 | usb_gadget_vbus_connect(otg->gadget); |
1470 | l = omap_readl(OTG_CTRL); | 1472 | l = omap_readl(OTG_CTRL); |
1471 | l |= OTG_A_SETB_HNPEN; | 1473 | l |= OTG_A_SETB_HNPEN; |
1472 | omap_writel(l, OTG_CTRL); | 1474 | omap_writel(l, OTG_CTRL); |
@@ -1503,6 +1505,12 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1503 | if (!isp) | 1505 | if (!isp) |
1504 | return 0; | 1506 | return 0; |
1505 | 1507 | ||
1508 | isp->phy.otg = kzalloc(sizeof *isp->phy.otg, GFP_KERNEL); | ||
1509 | if (!isp->phy.otg) { | ||
1510 | kfree(isp); | ||
1511 | return 0; | ||
1512 | } | ||
1513 | |||
1506 | INIT_WORK(&isp->work, isp1301_work); | 1514 | INIT_WORK(&isp->work, isp1301_work); |
1507 | init_timer(&isp->timer); | 1515 | init_timer(&isp->timer); |
1508 | isp->timer.function = isp1301_timer; | 1516 | isp->timer.function = isp1301_timer; |
@@ -1576,14 +1584,15 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1576 | goto fail; | 1584 | goto fail; |
1577 | } | 1585 | } |
1578 | 1586 | ||
1579 | isp->otg.dev = &i2c->dev; | 1587 | isp->phy.dev = &i2c->dev; |
1580 | isp->otg.label = DRIVER_NAME; | 1588 | isp->phy.label = DRIVER_NAME; |
1589 | isp->phy.set_power = isp1301_set_power, | ||
1581 | 1590 | ||
1582 | isp->otg.set_host = isp1301_set_host, | 1591 | isp->phy.otg->phy = &isp->phy; |
1583 | isp->otg.set_peripheral = isp1301_set_peripheral, | 1592 | isp->phy.otg->set_host = isp1301_set_host, |
1584 | isp->otg.set_power = isp1301_set_power, | 1593 | isp->phy.otg->set_peripheral = isp1301_set_peripheral, |
1585 | isp->otg.start_srp = isp1301_start_srp, | 1594 | isp->phy.otg->start_srp = isp1301_start_srp, |
1586 | isp->otg.start_hnp = isp1301_start_hnp, | 1595 | isp->phy.otg->start_hnp = isp1301_start_hnp, |
1587 | 1596 | ||
1588 | enable_vbus_draw(isp, 0); | 1597 | enable_vbus_draw(isp, 0); |
1589 | power_down(isp); | 1598 | power_down(isp); |
@@ -1601,7 +1610,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1601 | dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES); | 1610 | dev_dbg(&i2c->dev, "scheduled timer, %d min\n", TIMER_MINUTES); |
1602 | #endif | 1611 | #endif |
1603 | 1612 | ||
1604 | status = otg_set_transceiver(&isp->otg); | 1613 | status = usb_set_transceiver(&isp->phy); |
1605 | if (status < 0) | 1614 | if (status < 0) |
1606 | dev_err(&i2c->dev, "can't register transceiver, %d\n", | 1615 | dev_err(&i2c->dev, "can't register transceiver, %d\n", |
1607 | status); | 1616 | status); |
@@ -1609,6 +1618,7 @@ isp1301_probe(struct i2c_client *i2c, const struct i2c_device_id *id) | |||
1609 | return 0; | 1618 | return 0; |
1610 | 1619 | ||
1611 | fail: | 1620 | fail: |
1621 | kfree(isp->phy.otg); | ||
1612 | kfree(isp); | 1622 | kfree(isp); |
1613 | return -ENODEV; | 1623 | return -ENODEV; |
1614 | } | 1624 | } |
@@ -1639,7 +1649,7 @@ subsys_initcall(isp_init); | |||
1639 | static void __exit isp_exit(void) | 1649 | static void __exit isp_exit(void) |
1640 | { | 1650 | { |
1641 | if (the_transceiver) | 1651 | if (the_transceiver) |
1642 | otg_set_transceiver(NULL); | 1652 | usb_set_transceiver(NULL); |
1643 | i2c_del_driver(&isp1301_driver); | 1653 | i2c_del_driver(&isp1301_driver); |
1644 | } | 1654 | } |
1645 | module_exit(isp_exit); | 1655 | module_exit(isp_exit); |
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c index b276f8fcdeba..1d0347c247d1 100644 --- a/drivers/usb/otg/msm_otg.c +++ b/drivers/usb/otg/msm_otg.c | |||
@@ -69,9 +69,9 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) | |||
69 | int ret = 0; | 69 | int ret = 0; |
70 | 70 | ||
71 | if (init) { | 71 | if (init) { |
72 | hsusb_vddcx = regulator_get(motg->otg.dev, "HSUSB_VDDCX"); | 72 | hsusb_vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX"); |
73 | if (IS_ERR(hsusb_vddcx)) { | 73 | if (IS_ERR(hsusb_vddcx)) { |
74 | dev_err(motg->otg.dev, "unable to get hsusb vddcx\n"); | 74 | dev_err(motg->phy.dev, "unable to get hsusb vddcx\n"); |
75 | return PTR_ERR(hsusb_vddcx); | 75 | return PTR_ERR(hsusb_vddcx); |
76 | } | 76 | } |
77 | 77 | ||
@@ -79,7 +79,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) | |||
79 | USB_PHY_VDD_DIG_VOL_MIN, | 79 | USB_PHY_VDD_DIG_VOL_MIN, |
80 | USB_PHY_VDD_DIG_VOL_MAX); | 80 | USB_PHY_VDD_DIG_VOL_MAX); |
81 | if (ret) { | 81 | if (ret) { |
82 | dev_err(motg->otg.dev, "unable to set the voltage " | 82 | dev_err(motg->phy.dev, "unable to set the voltage " |
83 | "for hsusb vddcx\n"); | 83 | "for hsusb vddcx\n"); |
84 | regulator_put(hsusb_vddcx); | 84 | regulator_put(hsusb_vddcx); |
85 | return ret; | 85 | return ret; |
@@ -87,18 +87,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init) | |||
87 | 87 | ||
88 | ret = regulator_enable(hsusb_vddcx); | 88 | ret = regulator_enable(hsusb_vddcx); |
89 | if (ret) { | 89 | if (ret) { |
90 | dev_err(motg->otg.dev, "unable to enable hsusb vddcx\n"); | 90 | dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n"); |
91 | regulator_put(hsusb_vddcx); | 91 | regulator_put(hsusb_vddcx); |
92 | } | 92 | } |
93 | } else { | 93 | } else { |
94 | ret = regulator_set_voltage(hsusb_vddcx, 0, | 94 | ret = regulator_set_voltage(hsusb_vddcx, 0, |
95 | USB_PHY_VDD_DIG_VOL_MAX); | 95 | USB_PHY_VDD_DIG_VOL_MAX); |
96 | if (ret) | 96 | if (ret) |
97 | dev_err(motg->otg.dev, "unable to set the voltage " | 97 | dev_err(motg->phy.dev, "unable to set the voltage " |
98 | "for hsusb vddcx\n"); | 98 | "for hsusb vddcx\n"); |
99 | ret = regulator_disable(hsusb_vddcx); | 99 | ret = regulator_disable(hsusb_vddcx); |
100 | if (ret) | 100 | if (ret) |
101 | dev_err(motg->otg.dev, "unable to disable hsusb vddcx\n"); | 101 | dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n"); |
102 | 102 | ||
103 | regulator_put(hsusb_vddcx); | 103 | regulator_put(hsusb_vddcx); |
104 | } | 104 | } |
@@ -111,40 +111,40 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init) | |||
111 | int rc = 0; | 111 | int rc = 0; |
112 | 112 | ||
113 | if (init) { | 113 | if (init) { |
114 | hsusb_3p3 = regulator_get(motg->otg.dev, "HSUSB_3p3"); | 114 | hsusb_3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3"); |
115 | if (IS_ERR(hsusb_3p3)) { | 115 | if (IS_ERR(hsusb_3p3)) { |
116 | dev_err(motg->otg.dev, "unable to get hsusb 3p3\n"); | 116 | dev_err(motg->phy.dev, "unable to get hsusb 3p3\n"); |
117 | return PTR_ERR(hsusb_3p3); | 117 | return PTR_ERR(hsusb_3p3); |
118 | } | 118 | } |
119 | 119 | ||
120 | rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN, | 120 | rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN, |
121 | USB_PHY_3P3_VOL_MAX); | 121 | USB_PHY_3P3_VOL_MAX); |
122 | if (rc) { | 122 | if (rc) { |
123 | dev_err(motg->otg.dev, "unable to set voltage level " | 123 | dev_err(motg->phy.dev, "unable to set voltage level " |
124 | "for hsusb 3p3\n"); | 124 | "for hsusb 3p3\n"); |
125 | goto put_3p3; | 125 | goto put_3p3; |
126 | } | 126 | } |
127 | rc = regulator_enable(hsusb_3p3); | 127 | rc = regulator_enable(hsusb_3p3); |
128 | if (rc) { | 128 | if (rc) { |
129 | dev_err(motg->otg.dev, "unable to enable the hsusb 3p3\n"); | 129 | dev_err(motg->phy.dev, "unable to enable the hsusb 3p3\n"); |
130 | goto put_3p3; | 130 | goto put_3p3; |
131 | } | 131 | } |
132 | hsusb_1p8 = regulator_get(motg->otg.dev, "HSUSB_1p8"); | 132 | hsusb_1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8"); |
133 | if (IS_ERR(hsusb_1p8)) { | 133 | if (IS_ERR(hsusb_1p8)) { |
134 | dev_err(motg->otg.dev, "unable to get hsusb 1p8\n"); | 134 | dev_err(motg->phy.dev, "unable to get hsusb 1p8\n"); |
135 | rc = PTR_ERR(hsusb_1p8); | 135 | rc = PTR_ERR(hsusb_1p8); |
136 | goto disable_3p3; | 136 | goto disable_3p3; |
137 | } | 137 | } |
138 | rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN, | 138 | rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN, |
139 | USB_PHY_1P8_VOL_MAX); | 139 | USB_PHY_1P8_VOL_MAX); |
140 | if (rc) { | 140 | if (rc) { |
141 | dev_err(motg->otg.dev, "unable to set voltage level " | 141 | dev_err(motg->phy.dev, "unable to set voltage level " |
142 | "for hsusb 1p8\n"); | 142 | "for hsusb 1p8\n"); |
143 | goto put_1p8; | 143 | goto put_1p8; |
144 | } | 144 | } |
145 | rc = regulator_enable(hsusb_1p8); | 145 | rc = regulator_enable(hsusb_1p8); |
146 | if (rc) { | 146 | if (rc) { |
147 | dev_err(motg->otg.dev, "unable to enable the hsusb 1p8\n"); | 147 | dev_err(motg->phy.dev, "unable to enable the hsusb 1p8\n"); |
148 | goto put_1p8; | 148 | goto put_1p8; |
149 | } | 149 | } |
150 | 150 | ||
@@ -235,9 +235,9 @@ static int msm_hsusb_ldo_set_mode(int on) | |||
235 | return ret < 0 ? ret : 0; | 235 | return ret < 0 ? ret : 0; |
236 | } | 236 | } |
237 | 237 | ||
238 | static int ulpi_read(struct otg_transceiver *otg, u32 reg) | 238 | static int ulpi_read(struct usb_phy *phy, u32 reg) |
239 | { | 239 | { |
240 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 240 | struct msm_otg *motg = container_of(phy, struct msm_otg, phy); |
241 | int cnt = 0; | 241 | int cnt = 0; |
242 | 242 | ||
243 | /* initiate read operation */ | 243 | /* initiate read operation */ |
@@ -253,16 +253,16 @@ static int ulpi_read(struct otg_transceiver *otg, u32 reg) | |||
253 | } | 253 | } |
254 | 254 | ||
255 | if (cnt >= ULPI_IO_TIMEOUT_USEC) { | 255 | if (cnt >= ULPI_IO_TIMEOUT_USEC) { |
256 | dev_err(otg->dev, "ulpi_read: timeout %08x\n", | 256 | dev_err(phy->dev, "ulpi_read: timeout %08x\n", |
257 | readl(USB_ULPI_VIEWPORT)); | 257 | readl(USB_ULPI_VIEWPORT)); |
258 | return -ETIMEDOUT; | 258 | return -ETIMEDOUT; |
259 | } | 259 | } |
260 | return ULPI_DATA_READ(readl(USB_ULPI_VIEWPORT)); | 260 | return ULPI_DATA_READ(readl(USB_ULPI_VIEWPORT)); |
261 | } | 261 | } |
262 | 262 | ||
263 | static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | 263 | static int ulpi_write(struct usb_phy *phy, u32 val, u32 reg) |
264 | { | 264 | { |
265 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 265 | struct msm_otg *motg = container_of(phy, struct msm_otg, phy); |
266 | int cnt = 0; | 266 | int cnt = 0; |
267 | 267 | ||
268 | /* initiate write operation */ | 268 | /* initiate write operation */ |
@@ -279,13 +279,13 @@ static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | |||
279 | } | 279 | } |
280 | 280 | ||
281 | if (cnt >= ULPI_IO_TIMEOUT_USEC) { | 281 | if (cnt >= ULPI_IO_TIMEOUT_USEC) { |
282 | dev_err(otg->dev, "ulpi_write: timeout\n"); | 282 | dev_err(phy->dev, "ulpi_write: timeout\n"); |
283 | return -ETIMEDOUT; | 283 | return -ETIMEDOUT; |
284 | } | 284 | } |
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | static struct otg_io_access_ops msm_otg_io_ops = { | 288 | static struct usb_phy_io_ops msm_otg_io_ops = { |
289 | .read = ulpi_read, | 289 | .read = ulpi_read, |
290 | .write = ulpi_write, | 290 | .write = ulpi_write, |
291 | }; | 291 | }; |
@@ -299,9 +299,9 @@ static void ulpi_init(struct msm_otg *motg) | |||
299 | return; | 299 | return; |
300 | 300 | ||
301 | while (seq[0] >= 0) { | 301 | while (seq[0] >= 0) { |
302 | dev_vdbg(motg->otg.dev, "ulpi: write 0x%02x to 0x%02x\n", | 302 | dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n", |
303 | seq[0], seq[1]); | 303 | seq[0], seq[1]); |
304 | ulpi_write(&motg->otg, seq[0], seq[1]); | 304 | ulpi_write(&motg->phy, seq[0], seq[1]); |
305 | seq += 2; | 305 | seq += 2; |
306 | } | 306 | } |
307 | } | 307 | } |
@@ -313,11 +313,11 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert) | |||
313 | if (assert) { | 313 | if (assert) { |
314 | ret = clk_reset(motg->clk, CLK_RESET_ASSERT); | 314 | ret = clk_reset(motg->clk, CLK_RESET_ASSERT); |
315 | if (ret) | 315 | if (ret) |
316 | dev_err(motg->otg.dev, "usb hs_clk assert failed\n"); | 316 | dev_err(motg->phy.dev, "usb hs_clk assert failed\n"); |
317 | } else { | 317 | } else { |
318 | ret = clk_reset(motg->clk, CLK_RESET_DEASSERT); | 318 | ret = clk_reset(motg->clk, CLK_RESET_DEASSERT); |
319 | if (ret) | 319 | if (ret) |
320 | dev_err(motg->otg.dev, "usb hs_clk deassert failed\n"); | 320 | dev_err(motg->phy.dev, "usb hs_clk deassert failed\n"); |
321 | } | 321 | } |
322 | return ret; | 322 | return ret; |
323 | } | 323 | } |
@@ -328,13 +328,13 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg) | |||
328 | 328 | ||
329 | ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT); | 329 | ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT); |
330 | if (ret) { | 330 | if (ret) { |
331 | dev_err(motg->otg.dev, "usb phy clk assert failed\n"); | 331 | dev_err(motg->phy.dev, "usb phy clk assert failed\n"); |
332 | return ret; | 332 | return ret; |
333 | } | 333 | } |
334 | usleep_range(10000, 12000); | 334 | usleep_range(10000, 12000); |
335 | ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT); | 335 | ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT); |
336 | if (ret) | 336 | if (ret) |
337 | dev_err(motg->otg.dev, "usb phy clk deassert failed\n"); | 337 | dev_err(motg->phy.dev, "usb phy clk deassert failed\n"); |
338 | return ret; | 338 | return ret; |
339 | } | 339 | } |
340 | 340 | ||
@@ -358,7 +358,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg) | |||
358 | writel(val | PORTSC_PTS_ULPI, USB_PORTSC); | 358 | writel(val | PORTSC_PTS_ULPI, USB_PORTSC); |
359 | 359 | ||
360 | for (retries = 3; retries > 0; retries--) { | 360 | for (retries = 3; retries > 0; retries--) { |
361 | ret = ulpi_write(&motg->otg, ULPI_FUNC_CTRL_SUSPENDM, | 361 | ret = ulpi_write(&motg->phy, ULPI_FUNC_CTRL_SUSPENDM, |
362 | ULPI_CLR(ULPI_FUNC_CTRL)); | 362 | ULPI_CLR(ULPI_FUNC_CTRL)); |
363 | if (!ret) | 363 | if (!ret) |
364 | break; | 364 | break; |
@@ -375,7 +375,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg) | |||
375 | return ret; | 375 | return ret; |
376 | 376 | ||
377 | for (retries = 3; retries > 0; retries--) { | 377 | for (retries = 3; retries > 0; retries--) { |
378 | ret = ulpi_read(&motg->otg, ULPI_DEBUG); | 378 | ret = ulpi_read(&motg->phy, ULPI_DEBUG); |
379 | if (ret != -ETIMEDOUT) | 379 | if (ret != -ETIMEDOUT) |
380 | break; | 380 | break; |
381 | ret = msm_otg_phy_clk_reset(motg); | 381 | ret = msm_otg_phy_clk_reset(motg); |
@@ -385,14 +385,14 @@ static int msm_otg_phy_reset(struct msm_otg *motg) | |||
385 | if (!retries) | 385 | if (!retries) |
386 | return -ETIMEDOUT; | 386 | return -ETIMEDOUT; |
387 | 387 | ||
388 | dev_info(motg->otg.dev, "phy_reset: success\n"); | 388 | dev_info(motg->phy.dev, "phy_reset: success\n"); |
389 | return 0; | 389 | return 0; |
390 | } | 390 | } |
391 | 391 | ||
392 | #define LINK_RESET_TIMEOUT_USEC (250 * 1000) | 392 | #define LINK_RESET_TIMEOUT_USEC (250 * 1000) |
393 | static int msm_otg_reset(struct otg_transceiver *otg) | 393 | static int msm_otg_reset(struct usb_phy *phy) |
394 | { | 394 | { |
395 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 395 | struct msm_otg *motg = container_of(phy, struct msm_otg, phy); |
396 | struct msm_otg_platform_data *pdata = motg->pdata; | 396 | struct msm_otg_platform_data *pdata = motg->pdata; |
397 | int cnt = 0; | 397 | int cnt = 0; |
398 | int ret; | 398 | int ret; |
@@ -401,7 +401,7 @@ static int msm_otg_reset(struct otg_transceiver *otg) | |||
401 | 401 | ||
402 | ret = msm_otg_phy_reset(motg); | 402 | ret = msm_otg_phy_reset(motg); |
403 | if (ret) { | 403 | if (ret) { |
404 | dev_err(otg->dev, "phy_reset failed\n"); | 404 | dev_err(phy->dev, "phy_reset failed\n"); |
405 | return ret; | 405 | return ret; |
406 | } | 406 | } |
407 | 407 | ||
@@ -435,8 +435,8 @@ static int msm_otg_reset(struct otg_transceiver *otg) | |||
435 | val |= OTGSC_BSVIE; | 435 | val |= OTGSC_BSVIE; |
436 | } | 436 | } |
437 | writel(val, USB_OTGSC); | 437 | writel(val, USB_OTGSC); |
438 | ulpi_write(otg, ulpi_val, ULPI_USB_INT_EN_RISE); | 438 | ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_RISE); |
439 | ulpi_write(otg, ulpi_val, ULPI_USB_INT_EN_FALL); | 439 | ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL); |
440 | } | 440 | } |
441 | 441 | ||
442 | return 0; | 442 | return 0; |
@@ -448,8 +448,8 @@ static int msm_otg_reset(struct otg_transceiver *otg) | |||
448 | #ifdef CONFIG_PM_SLEEP | 448 | #ifdef CONFIG_PM_SLEEP |
449 | static int msm_otg_suspend(struct msm_otg *motg) | 449 | static int msm_otg_suspend(struct msm_otg *motg) |
450 | { | 450 | { |
451 | struct otg_transceiver *otg = &motg->otg; | 451 | struct usb_phy *phy = &motg->phy; |
452 | struct usb_bus *bus = otg->host; | 452 | struct usb_bus *bus = phy->otg->host; |
453 | struct msm_otg_platform_data *pdata = motg->pdata; | 453 | struct msm_otg_platform_data *pdata = motg->pdata; |
454 | int cnt = 0; | 454 | int cnt = 0; |
455 | 455 | ||
@@ -475,10 +475,10 @@ static int msm_otg_suspend(struct msm_otg *motg) | |||
475 | */ | 475 | */ |
476 | 476 | ||
477 | if (motg->pdata->phy_type == CI_45NM_INTEGRATED_PHY) { | 477 | if (motg->pdata->phy_type == CI_45NM_INTEGRATED_PHY) { |
478 | ulpi_read(otg, 0x14); | 478 | ulpi_read(phy, 0x14); |
479 | if (pdata->otg_control == OTG_PHY_CONTROL) | 479 | if (pdata->otg_control == OTG_PHY_CONTROL) |
480 | ulpi_write(otg, 0x01, 0x30); | 480 | ulpi_write(phy, 0x01, 0x30); |
481 | ulpi_write(otg, 0x08, 0x09); | 481 | ulpi_write(phy, 0x08, 0x09); |
482 | } | 482 | } |
483 | 483 | ||
484 | /* | 484 | /* |
@@ -495,8 +495,8 @@ static int msm_otg_suspend(struct msm_otg *motg) | |||
495 | } | 495 | } |
496 | 496 | ||
497 | if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) { | 497 | if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) { |
498 | dev_err(otg->dev, "Unable to suspend PHY\n"); | 498 | dev_err(phy->dev, "Unable to suspend PHY\n"); |
499 | msm_otg_reset(otg); | 499 | msm_otg_reset(phy); |
500 | enable_irq(motg->irq); | 500 | enable_irq(motg->irq); |
501 | return -ETIMEDOUT; | 501 | return -ETIMEDOUT; |
502 | } | 502 | } |
@@ -528,7 +528,7 @@ static int msm_otg_suspend(struct msm_otg *motg) | |||
528 | msm_hsusb_config_vddcx(0); | 528 | msm_hsusb_config_vddcx(0); |
529 | } | 529 | } |
530 | 530 | ||
531 | if (device_may_wakeup(otg->dev)) | 531 | if (device_may_wakeup(phy->dev)) |
532 | enable_irq_wake(motg->irq); | 532 | enable_irq_wake(motg->irq); |
533 | if (bus) | 533 | if (bus) |
534 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags); | 534 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags); |
@@ -536,15 +536,15 @@ static int msm_otg_suspend(struct msm_otg *motg) | |||
536 | atomic_set(&motg->in_lpm, 1); | 536 | atomic_set(&motg->in_lpm, 1); |
537 | enable_irq(motg->irq); | 537 | enable_irq(motg->irq); |
538 | 538 | ||
539 | dev_info(otg->dev, "USB in low power mode\n"); | 539 | dev_info(phy->dev, "USB in low power mode\n"); |
540 | 540 | ||
541 | return 0; | 541 | return 0; |
542 | } | 542 | } |
543 | 543 | ||
544 | static int msm_otg_resume(struct msm_otg *motg) | 544 | static int msm_otg_resume(struct msm_otg *motg) |
545 | { | 545 | { |
546 | struct otg_transceiver *otg = &motg->otg; | 546 | struct usb_phy *phy = &motg->phy; |
547 | struct usb_bus *bus = otg->host; | 547 | struct usb_bus *bus = phy->otg->host; |
548 | int cnt = 0; | 548 | int cnt = 0; |
549 | unsigned temp; | 549 | unsigned temp; |
550 | 550 | ||
@@ -592,13 +592,13 @@ static int msm_otg_resume(struct msm_otg *motg) | |||
592 | * PHY. USB state can not be restored. Re-insertion | 592 | * PHY. USB state can not be restored. Re-insertion |
593 | * of USB cable is the only way to get USB working. | 593 | * of USB cable is the only way to get USB working. |
594 | */ | 594 | */ |
595 | dev_err(otg->dev, "Unable to resume USB." | 595 | dev_err(phy->dev, "Unable to resume USB." |
596 | "Re-plugin the cable\n"); | 596 | "Re-plugin the cable\n"); |
597 | msm_otg_reset(otg); | 597 | msm_otg_reset(phy); |
598 | } | 598 | } |
599 | 599 | ||
600 | skip_phy_resume: | 600 | skip_phy_resume: |
601 | if (device_may_wakeup(otg->dev)) | 601 | if (device_may_wakeup(phy->dev)) |
602 | disable_irq_wake(motg->irq); | 602 | disable_irq_wake(motg->irq); |
603 | if (bus) | 603 | if (bus) |
604 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags); | 604 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags); |
@@ -607,11 +607,11 @@ skip_phy_resume: | |||
607 | 607 | ||
608 | if (motg->async_int) { | 608 | if (motg->async_int) { |
609 | motg->async_int = 0; | 609 | motg->async_int = 0; |
610 | pm_runtime_put(otg->dev); | 610 | pm_runtime_put(phy->dev); |
611 | enable_irq(motg->irq); | 611 | enable_irq(motg->irq); |
612 | } | 612 | } |
613 | 613 | ||
614 | dev_info(otg->dev, "USB exited from low power mode\n"); | 614 | dev_info(phy->dev, "USB exited from low power mode\n"); |
615 | 615 | ||
616 | return 0; | 616 | return 0; |
617 | } | 617 | } |
@@ -623,13 +623,13 @@ static void msm_otg_notify_charger(struct msm_otg *motg, unsigned mA) | |||
623 | return; | 623 | return; |
624 | 624 | ||
625 | /* TODO: Notify PMIC about available current */ | 625 | /* TODO: Notify PMIC about available current */ |
626 | dev_info(motg->otg.dev, "Avail curr from USB = %u\n", mA); | 626 | dev_info(motg->phy.dev, "Avail curr from USB = %u\n", mA); |
627 | motg->cur_power = mA; | 627 | motg->cur_power = mA; |
628 | } | 628 | } |
629 | 629 | ||
630 | static int msm_otg_set_power(struct otg_transceiver *otg, unsigned mA) | 630 | static int msm_otg_set_power(struct usb_phy *phy, unsigned mA) |
631 | { | 631 | { |
632 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 632 | struct msm_otg *motg = container_of(phy, struct msm_otg, phy); |
633 | 633 | ||
634 | /* | 634 | /* |
635 | * Gadget driver uses set_power method to notify about the | 635 | * Gadget driver uses set_power method to notify about the |
@@ -644,19 +644,19 @@ static int msm_otg_set_power(struct otg_transceiver *otg, unsigned mA) | |||
644 | return 0; | 644 | return 0; |
645 | } | 645 | } |
646 | 646 | ||
647 | static void msm_otg_start_host(struct otg_transceiver *otg, int on) | 647 | static void msm_otg_start_host(struct usb_phy *phy, int on) |
648 | { | 648 | { |
649 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 649 | struct msm_otg *motg = container_of(phy, struct msm_otg, phy); |
650 | struct msm_otg_platform_data *pdata = motg->pdata; | 650 | struct msm_otg_platform_data *pdata = motg->pdata; |
651 | struct usb_hcd *hcd; | 651 | struct usb_hcd *hcd; |
652 | 652 | ||
653 | if (!otg->host) | 653 | if (!phy->otg->host) |
654 | return; | 654 | return; |
655 | 655 | ||
656 | hcd = bus_to_hcd(otg->host); | 656 | hcd = bus_to_hcd(phy->otg->host); |
657 | 657 | ||
658 | if (on) { | 658 | if (on) { |
659 | dev_dbg(otg->dev, "host on\n"); | 659 | dev_dbg(phy->dev, "host on\n"); |
660 | 660 | ||
661 | if (pdata->vbus_power) | 661 | if (pdata->vbus_power) |
662 | pdata->vbus_power(1); | 662 | pdata->vbus_power(1); |
@@ -671,7 +671,7 @@ static void msm_otg_start_host(struct otg_transceiver *otg, int on) | |||
671 | usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); | 671 | usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); |
672 | #endif | 672 | #endif |
673 | } else { | 673 | } else { |
674 | dev_dbg(otg->dev, "host off\n"); | 674 | dev_dbg(phy->dev, "host off\n"); |
675 | 675 | ||
676 | #ifdef CONFIG_USB | 676 | #ifdef CONFIG_USB |
677 | usb_remove_hcd(hcd); | 677 | usb_remove_hcd(hcd); |
@@ -683,9 +683,9 @@ static void msm_otg_start_host(struct otg_transceiver *otg, int on) | |||
683 | } | 683 | } |
684 | } | 684 | } |
685 | 685 | ||
686 | static int msm_otg_set_host(struct otg_transceiver *otg, struct usb_bus *host) | 686 | static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
687 | { | 687 | { |
688 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 688 | struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy); |
689 | struct usb_hcd *hcd; | 689 | struct usb_hcd *hcd; |
690 | 690 | ||
691 | /* | 691 | /* |
@@ -693,16 +693,16 @@ static int msm_otg_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
693 | * only peripheral configuration. | 693 | * only peripheral configuration. |
694 | */ | 694 | */ |
695 | if (motg->pdata->mode == USB_PERIPHERAL) { | 695 | if (motg->pdata->mode == USB_PERIPHERAL) { |
696 | dev_info(otg->dev, "Host mode is not supported\n"); | 696 | dev_info(otg->phy->dev, "Host mode is not supported\n"); |
697 | return -ENODEV; | 697 | return -ENODEV; |
698 | } | 698 | } |
699 | 699 | ||
700 | if (!host) { | 700 | if (!host) { |
701 | if (otg->state == OTG_STATE_A_HOST) { | 701 | if (otg->phy->state == OTG_STATE_A_HOST) { |
702 | pm_runtime_get_sync(otg->dev); | 702 | pm_runtime_get_sync(otg->phy->dev); |
703 | msm_otg_start_host(otg, 0); | 703 | msm_otg_start_host(otg->phy, 0); |
704 | otg->host = NULL; | 704 | otg->host = NULL; |
705 | otg->state = OTG_STATE_UNDEFINED; | 705 | otg->phy->state = OTG_STATE_UNDEFINED; |
706 | schedule_work(&motg->sm_work); | 706 | schedule_work(&motg->sm_work); |
707 | } else { | 707 | } else { |
708 | otg->host = NULL; | 708 | otg->host = NULL; |
@@ -715,30 +715,30 @@ static int msm_otg_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
715 | hcd->power_budget = motg->pdata->power_budget; | 715 | hcd->power_budget = motg->pdata->power_budget; |
716 | 716 | ||
717 | otg->host = host; | 717 | otg->host = host; |
718 | dev_dbg(otg->dev, "host driver registered w/ tranceiver\n"); | 718 | dev_dbg(otg->phy->dev, "host driver registered w/ tranceiver\n"); |
719 | 719 | ||
720 | /* | 720 | /* |
721 | * Kick the state machine work, if peripheral is not supported | 721 | * Kick the state machine work, if peripheral is not supported |
722 | * or peripheral is already registered with us. | 722 | * or peripheral is already registered with us. |
723 | */ | 723 | */ |
724 | if (motg->pdata->mode == USB_HOST || otg->gadget) { | 724 | if (motg->pdata->mode == USB_HOST || otg->gadget) { |
725 | pm_runtime_get_sync(otg->dev); | 725 | pm_runtime_get_sync(otg->phy->dev); |
726 | schedule_work(&motg->sm_work); | 726 | schedule_work(&motg->sm_work); |
727 | } | 727 | } |
728 | 728 | ||
729 | return 0; | 729 | return 0; |
730 | } | 730 | } |
731 | 731 | ||
732 | static void msm_otg_start_peripheral(struct otg_transceiver *otg, int on) | 732 | static void msm_otg_start_peripheral(struct usb_phy *phy, int on) |
733 | { | 733 | { |
734 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 734 | struct msm_otg *motg = container_of(phy, struct msm_otg, phy); |
735 | struct msm_otg_platform_data *pdata = motg->pdata; | 735 | struct msm_otg_platform_data *pdata = motg->pdata; |
736 | 736 | ||
737 | if (!otg->gadget) | 737 | if (!phy->otg->gadget) |
738 | return; | 738 | return; |
739 | 739 | ||
740 | if (on) { | 740 | if (on) { |
741 | dev_dbg(otg->dev, "gadget on\n"); | 741 | dev_dbg(phy->dev, "gadget on\n"); |
742 | /* | 742 | /* |
743 | * Some boards have a switch cotrolled by gpio | 743 | * Some boards have a switch cotrolled by gpio |
744 | * to enable/disable internal HUB. Disable internal | 744 | * to enable/disable internal HUB. Disable internal |
@@ -746,36 +746,36 @@ static void msm_otg_start_peripheral(struct otg_transceiver *otg, int on) | |||
746 | */ | 746 | */ |
747 | if (pdata->setup_gpio) | 747 | if (pdata->setup_gpio) |
748 | pdata->setup_gpio(OTG_STATE_B_PERIPHERAL); | 748 | pdata->setup_gpio(OTG_STATE_B_PERIPHERAL); |
749 | usb_gadget_vbus_connect(otg->gadget); | 749 | usb_gadget_vbus_connect(phy->otg->gadget); |
750 | } else { | 750 | } else { |
751 | dev_dbg(otg->dev, "gadget off\n"); | 751 | dev_dbg(phy->dev, "gadget off\n"); |
752 | usb_gadget_vbus_disconnect(otg->gadget); | 752 | usb_gadget_vbus_disconnect(phy->otg->gadget); |
753 | if (pdata->setup_gpio) | 753 | if (pdata->setup_gpio) |
754 | pdata->setup_gpio(OTG_STATE_UNDEFINED); | 754 | pdata->setup_gpio(OTG_STATE_UNDEFINED); |
755 | } | 755 | } |
756 | 756 | ||
757 | } | 757 | } |
758 | 758 | ||
759 | static int msm_otg_set_peripheral(struct otg_transceiver *otg, | 759 | static int msm_otg_set_peripheral(struct usb_otg *otg, |
760 | struct usb_gadget *gadget) | 760 | struct usb_gadget *gadget) |
761 | { | 761 | { |
762 | struct msm_otg *motg = container_of(otg, struct msm_otg, otg); | 762 | struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy); |
763 | 763 | ||
764 | /* | 764 | /* |
765 | * Fail peripheral registration if this board can support | 765 | * Fail peripheral registration if this board can support |
766 | * only host configuration. | 766 | * only host configuration. |
767 | */ | 767 | */ |
768 | if (motg->pdata->mode == USB_HOST) { | 768 | if (motg->pdata->mode == USB_HOST) { |
769 | dev_info(otg->dev, "Peripheral mode is not supported\n"); | 769 | dev_info(otg->phy->dev, "Peripheral mode is not supported\n"); |
770 | return -ENODEV; | 770 | return -ENODEV; |
771 | } | 771 | } |
772 | 772 | ||
773 | if (!gadget) { | 773 | if (!gadget) { |
774 | if (otg->state == OTG_STATE_B_PERIPHERAL) { | 774 | if (otg->phy->state == OTG_STATE_B_PERIPHERAL) { |
775 | pm_runtime_get_sync(otg->dev); | 775 | pm_runtime_get_sync(otg->phy->dev); |
776 | msm_otg_start_peripheral(otg, 0); | 776 | msm_otg_start_peripheral(otg->phy, 0); |
777 | otg->gadget = NULL; | 777 | otg->gadget = NULL; |
778 | otg->state = OTG_STATE_UNDEFINED; | 778 | otg->phy->state = OTG_STATE_UNDEFINED; |
779 | schedule_work(&motg->sm_work); | 779 | schedule_work(&motg->sm_work); |
780 | } else { | 780 | } else { |
781 | otg->gadget = NULL; | 781 | otg->gadget = NULL; |
@@ -784,14 +784,14 @@ static int msm_otg_set_peripheral(struct otg_transceiver *otg, | |||
784 | return 0; | 784 | return 0; |
785 | } | 785 | } |
786 | otg->gadget = gadget; | 786 | otg->gadget = gadget; |
787 | dev_dbg(otg->dev, "peripheral driver registered w/ tranceiver\n"); | 787 | dev_dbg(otg->phy->dev, "peripheral driver registered w/ tranceiver\n"); |
788 | 788 | ||
789 | /* | 789 | /* |
790 | * Kick the state machine work, if host is not supported | 790 | * Kick the state machine work, if host is not supported |
791 | * or host is already registered with us. | 791 | * or host is already registered with us. |
792 | */ | 792 | */ |
793 | if (motg->pdata->mode == USB_PERIPHERAL || otg->host) { | 793 | if (motg->pdata->mode == USB_PERIPHERAL || otg->host) { |
794 | pm_runtime_get_sync(otg->dev); | 794 | pm_runtime_get_sync(otg->phy->dev); |
795 | schedule_work(&motg->sm_work); | 795 | schedule_work(&motg->sm_work); |
796 | } | 796 | } |
797 | 797 | ||
@@ -800,17 +800,17 @@ static int msm_otg_set_peripheral(struct otg_transceiver *otg, | |||
800 | 800 | ||
801 | static bool msm_chg_check_secondary_det(struct msm_otg *motg) | 801 | static bool msm_chg_check_secondary_det(struct msm_otg *motg) |
802 | { | 802 | { |
803 | struct otg_transceiver *otg = &motg->otg; | 803 | struct usb_phy *phy = &motg->phy; |
804 | u32 chg_det; | 804 | u32 chg_det; |
805 | bool ret = false; | 805 | bool ret = false; |
806 | 806 | ||
807 | switch (motg->pdata->phy_type) { | 807 | switch (motg->pdata->phy_type) { |
808 | case CI_45NM_INTEGRATED_PHY: | 808 | case CI_45NM_INTEGRATED_PHY: |
809 | chg_det = ulpi_read(otg, 0x34); | 809 | chg_det = ulpi_read(phy, 0x34); |
810 | ret = chg_det & (1 << 4); | 810 | ret = chg_det & (1 << 4); |
811 | break; | 811 | break; |
812 | case SNPS_28NM_INTEGRATED_PHY: | 812 | case SNPS_28NM_INTEGRATED_PHY: |
813 | chg_det = ulpi_read(otg, 0x87); | 813 | chg_det = ulpi_read(phy, 0x87); |
814 | ret = chg_det & 1; | 814 | ret = chg_det & 1; |
815 | break; | 815 | break; |
816 | default: | 816 | default: |
@@ -821,38 +821,38 @@ static bool msm_chg_check_secondary_det(struct msm_otg *motg) | |||
821 | 821 | ||
822 | static void msm_chg_enable_secondary_det(struct msm_otg *motg) | 822 | static void msm_chg_enable_secondary_det(struct msm_otg *motg) |
823 | { | 823 | { |
824 | struct otg_transceiver *otg = &motg->otg; | 824 | struct usb_phy *phy = &motg->phy; |
825 | u32 chg_det; | 825 | u32 chg_det; |
826 | 826 | ||
827 | switch (motg->pdata->phy_type) { | 827 | switch (motg->pdata->phy_type) { |
828 | case CI_45NM_INTEGRATED_PHY: | 828 | case CI_45NM_INTEGRATED_PHY: |
829 | chg_det = ulpi_read(otg, 0x34); | 829 | chg_det = ulpi_read(phy, 0x34); |
830 | /* Turn off charger block */ | 830 | /* Turn off charger block */ |
831 | chg_det |= ~(1 << 1); | 831 | chg_det |= ~(1 << 1); |
832 | ulpi_write(otg, chg_det, 0x34); | 832 | ulpi_write(phy, chg_det, 0x34); |
833 | udelay(20); | 833 | udelay(20); |
834 | /* control chg block via ULPI */ | 834 | /* control chg block via ULPI */ |
835 | chg_det &= ~(1 << 3); | 835 | chg_det &= ~(1 << 3); |
836 | ulpi_write(otg, chg_det, 0x34); | 836 | ulpi_write(phy, chg_det, 0x34); |
837 | /* put it in host mode for enabling D- source */ | 837 | /* put it in host mode for enabling D- source */ |
838 | chg_det &= ~(1 << 2); | 838 | chg_det &= ~(1 << 2); |
839 | ulpi_write(otg, chg_det, 0x34); | 839 | ulpi_write(phy, chg_det, 0x34); |
840 | /* Turn on chg detect block */ | 840 | /* Turn on chg detect block */ |
841 | chg_det &= ~(1 << 1); | 841 | chg_det &= ~(1 << 1); |
842 | ulpi_write(otg, chg_det, 0x34); | 842 | ulpi_write(phy, chg_det, 0x34); |
843 | udelay(20); | 843 | udelay(20); |
844 | /* enable chg detection */ | 844 | /* enable chg detection */ |
845 | chg_det &= ~(1 << 0); | 845 | chg_det &= ~(1 << 0); |
846 | ulpi_write(otg, chg_det, 0x34); | 846 | ulpi_write(phy, chg_det, 0x34); |
847 | break; | 847 | break; |
848 | case SNPS_28NM_INTEGRATED_PHY: | 848 | case SNPS_28NM_INTEGRATED_PHY: |
849 | /* | 849 | /* |
850 | * Configure DM as current source, DP as current sink | 850 | * Configure DM as current source, DP as current sink |
851 | * and enable battery charging comparators. | 851 | * and enable battery charging comparators. |
852 | */ | 852 | */ |
853 | ulpi_write(otg, 0x8, 0x85); | 853 | ulpi_write(phy, 0x8, 0x85); |
854 | ulpi_write(otg, 0x2, 0x85); | 854 | ulpi_write(phy, 0x2, 0x85); |
855 | ulpi_write(otg, 0x1, 0x85); | 855 | ulpi_write(phy, 0x1, 0x85); |
856 | break; | 856 | break; |
857 | default: | 857 | default: |
858 | break; | 858 | break; |
@@ -861,17 +861,17 @@ static void msm_chg_enable_secondary_det(struct msm_otg *motg) | |||
861 | 861 | ||
862 | static bool msm_chg_check_primary_det(struct msm_otg *motg) | 862 | static bool msm_chg_check_primary_det(struct msm_otg *motg) |
863 | { | 863 | { |
864 | struct otg_transceiver *otg = &motg->otg; | 864 | struct usb_phy *phy = &motg->phy; |
865 | u32 chg_det; | 865 | u32 chg_det; |
866 | bool ret = false; | 866 | bool ret = false; |
867 | 867 | ||
868 | switch (motg->pdata->phy_type) { | 868 | switch (motg->pdata->phy_type) { |
869 | case CI_45NM_INTEGRATED_PHY: | 869 | case CI_45NM_INTEGRATED_PHY: |
870 | chg_det = ulpi_read(otg, 0x34); | 870 | chg_det = ulpi_read(phy, 0x34); |
871 | ret = chg_det & (1 << 4); | 871 | ret = chg_det & (1 << 4); |
872 | break; | 872 | break; |
873 | case SNPS_28NM_INTEGRATED_PHY: | 873 | case SNPS_28NM_INTEGRATED_PHY: |
874 | chg_det = ulpi_read(otg, 0x87); | 874 | chg_det = ulpi_read(phy, 0x87); |
875 | ret = chg_det & 1; | 875 | ret = chg_det & 1; |
876 | break; | 876 | break; |
877 | default: | 877 | default: |
@@ -882,23 +882,23 @@ static bool msm_chg_check_primary_det(struct msm_otg *motg) | |||
882 | 882 | ||
883 | static void msm_chg_enable_primary_det(struct msm_otg *motg) | 883 | static void msm_chg_enable_primary_det(struct msm_otg *motg) |
884 | { | 884 | { |
885 | struct otg_transceiver *otg = &motg->otg; | 885 | struct usb_phy *phy = &motg->phy; |
886 | u32 chg_det; | 886 | u32 chg_det; |
887 | 887 | ||
888 | switch (motg->pdata->phy_type) { | 888 | switch (motg->pdata->phy_type) { |
889 | case CI_45NM_INTEGRATED_PHY: | 889 | case CI_45NM_INTEGRATED_PHY: |
890 | chg_det = ulpi_read(otg, 0x34); | 890 | chg_det = ulpi_read(phy, 0x34); |
891 | /* enable chg detection */ | 891 | /* enable chg detection */ |
892 | chg_det &= ~(1 << 0); | 892 | chg_det &= ~(1 << 0); |
893 | ulpi_write(otg, chg_det, 0x34); | 893 | ulpi_write(phy, chg_det, 0x34); |
894 | break; | 894 | break; |
895 | case SNPS_28NM_INTEGRATED_PHY: | 895 | case SNPS_28NM_INTEGRATED_PHY: |
896 | /* | 896 | /* |
897 | * Configure DP as current source, DM as current sink | 897 | * Configure DP as current source, DM as current sink |
898 | * and enable battery charging comparators. | 898 | * and enable battery charging comparators. |
899 | */ | 899 | */ |
900 | ulpi_write(otg, 0x2, 0x85); | 900 | ulpi_write(phy, 0x2, 0x85); |
901 | ulpi_write(otg, 0x1, 0x85); | 901 | ulpi_write(phy, 0x1, 0x85); |
902 | break; | 902 | break; |
903 | default: | 903 | default: |
904 | break; | 904 | break; |
@@ -907,17 +907,17 @@ static void msm_chg_enable_primary_det(struct msm_otg *motg) | |||
907 | 907 | ||
908 | static bool msm_chg_check_dcd(struct msm_otg *motg) | 908 | static bool msm_chg_check_dcd(struct msm_otg *motg) |
909 | { | 909 | { |
910 | struct otg_transceiver *otg = &motg->otg; | 910 | struct usb_phy *phy = &motg->phy; |
911 | u32 line_state; | 911 | u32 line_state; |
912 | bool ret = false; | 912 | bool ret = false; |
913 | 913 | ||
914 | switch (motg->pdata->phy_type) { | 914 | switch (motg->pdata->phy_type) { |
915 | case CI_45NM_INTEGRATED_PHY: | 915 | case CI_45NM_INTEGRATED_PHY: |
916 | line_state = ulpi_read(otg, 0x15); | 916 | line_state = ulpi_read(phy, 0x15); |
917 | ret = !(line_state & 1); | 917 | ret = !(line_state & 1); |
918 | break; | 918 | break; |
919 | case SNPS_28NM_INTEGRATED_PHY: | 919 | case SNPS_28NM_INTEGRATED_PHY: |
920 | line_state = ulpi_read(otg, 0x87); | 920 | line_state = ulpi_read(phy, 0x87); |
921 | ret = line_state & 2; | 921 | ret = line_state & 2; |
922 | break; | 922 | break; |
923 | default: | 923 | default: |
@@ -928,17 +928,17 @@ static bool msm_chg_check_dcd(struct msm_otg *motg) | |||
928 | 928 | ||
929 | static void msm_chg_disable_dcd(struct msm_otg *motg) | 929 | static void msm_chg_disable_dcd(struct msm_otg *motg) |
930 | { | 930 | { |
931 | struct otg_transceiver *otg = &motg->otg; | 931 | struct usb_phy *phy = &motg->phy; |
932 | u32 chg_det; | 932 | u32 chg_det; |
933 | 933 | ||
934 | switch (motg->pdata->phy_type) { | 934 | switch (motg->pdata->phy_type) { |
935 | case CI_45NM_INTEGRATED_PHY: | 935 | case CI_45NM_INTEGRATED_PHY: |
936 | chg_det = ulpi_read(otg, 0x34); | 936 | chg_det = ulpi_read(phy, 0x34); |
937 | chg_det &= ~(1 << 5); | 937 | chg_det &= ~(1 << 5); |
938 | ulpi_write(otg, chg_det, 0x34); | 938 | ulpi_write(phy, chg_det, 0x34); |
939 | break; | 939 | break; |
940 | case SNPS_28NM_INTEGRATED_PHY: | 940 | case SNPS_28NM_INTEGRATED_PHY: |
941 | ulpi_write(otg, 0x10, 0x86); | 941 | ulpi_write(phy, 0x10, 0x86); |
942 | break; | 942 | break; |
943 | default: | 943 | default: |
944 | break; | 944 | break; |
@@ -947,19 +947,19 @@ static void msm_chg_disable_dcd(struct msm_otg *motg) | |||
947 | 947 | ||
948 | static void msm_chg_enable_dcd(struct msm_otg *motg) | 948 | static void msm_chg_enable_dcd(struct msm_otg *motg) |
949 | { | 949 | { |
950 | struct otg_transceiver *otg = &motg->otg; | 950 | struct usb_phy *phy = &motg->phy; |
951 | u32 chg_det; | 951 | u32 chg_det; |
952 | 952 | ||
953 | switch (motg->pdata->phy_type) { | 953 | switch (motg->pdata->phy_type) { |
954 | case CI_45NM_INTEGRATED_PHY: | 954 | case CI_45NM_INTEGRATED_PHY: |
955 | chg_det = ulpi_read(otg, 0x34); | 955 | chg_det = ulpi_read(phy, 0x34); |
956 | /* Turn on D+ current source */ | 956 | /* Turn on D+ current source */ |
957 | chg_det |= (1 << 5); | 957 | chg_det |= (1 << 5); |
958 | ulpi_write(otg, chg_det, 0x34); | 958 | ulpi_write(phy, chg_det, 0x34); |
959 | break; | 959 | break; |
960 | case SNPS_28NM_INTEGRATED_PHY: | 960 | case SNPS_28NM_INTEGRATED_PHY: |
961 | /* Data contact detection enable */ | 961 | /* Data contact detection enable */ |
962 | ulpi_write(otg, 0x10, 0x85); | 962 | ulpi_write(phy, 0x10, 0x85); |
963 | break; | 963 | break; |
964 | default: | 964 | default: |
965 | break; | 965 | break; |
@@ -968,32 +968,32 @@ static void msm_chg_enable_dcd(struct msm_otg *motg) | |||
968 | 968 | ||
969 | static void msm_chg_block_on(struct msm_otg *motg) | 969 | static void msm_chg_block_on(struct msm_otg *motg) |
970 | { | 970 | { |
971 | struct otg_transceiver *otg = &motg->otg; | 971 | struct usb_phy *phy = &motg->phy; |
972 | u32 func_ctrl, chg_det; | 972 | u32 func_ctrl, chg_det; |
973 | 973 | ||
974 | /* put the controller in non-driving mode */ | 974 | /* put the controller in non-driving mode */ |
975 | func_ctrl = ulpi_read(otg, ULPI_FUNC_CTRL); | 975 | func_ctrl = ulpi_read(phy, ULPI_FUNC_CTRL); |
976 | func_ctrl &= ~ULPI_FUNC_CTRL_OPMODE_MASK; | 976 | func_ctrl &= ~ULPI_FUNC_CTRL_OPMODE_MASK; |
977 | func_ctrl |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | 977 | func_ctrl |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; |
978 | ulpi_write(otg, func_ctrl, ULPI_FUNC_CTRL); | 978 | ulpi_write(phy, func_ctrl, ULPI_FUNC_CTRL); |
979 | 979 | ||
980 | switch (motg->pdata->phy_type) { | 980 | switch (motg->pdata->phy_type) { |
981 | case CI_45NM_INTEGRATED_PHY: | 981 | case CI_45NM_INTEGRATED_PHY: |
982 | chg_det = ulpi_read(otg, 0x34); | 982 | chg_det = ulpi_read(phy, 0x34); |
983 | /* control chg block via ULPI */ | 983 | /* control chg block via ULPI */ |
984 | chg_det &= ~(1 << 3); | 984 | chg_det &= ~(1 << 3); |
985 | ulpi_write(otg, chg_det, 0x34); | 985 | ulpi_write(phy, chg_det, 0x34); |
986 | /* Turn on chg detect block */ | 986 | /* Turn on chg detect block */ |
987 | chg_det &= ~(1 << 1); | 987 | chg_det &= ~(1 << 1); |
988 | ulpi_write(otg, chg_det, 0x34); | 988 | ulpi_write(phy, chg_det, 0x34); |
989 | udelay(20); | 989 | udelay(20); |
990 | break; | 990 | break; |
991 | case SNPS_28NM_INTEGRATED_PHY: | 991 | case SNPS_28NM_INTEGRATED_PHY: |
992 | /* Clear charger detecting control bits */ | 992 | /* Clear charger detecting control bits */ |
993 | ulpi_write(otg, 0x3F, 0x86); | 993 | ulpi_write(phy, 0x3F, 0x86); |
994 | /* Clear alt interrupt latch and enable bits */ | 994 | /* Clear alt interrupt latch and enable bits */ |
995 | ulpi_write(otg, 0x1F, 0x92); | 995 | ulpi_write(phy, 0x1F, 0x92); |
996 | ulpi_write(otg, 0x1F, 0x95); | 996 | ulpi_write(phy, 0x1F, 0x95); |
997 | udelay(100); | 997 | udelay(100); |
998 | break; | 998 | break; |
999 | default: | 999 | default: |
@@ -1003,32 +1003,32 @@ static void msm_chg_block_on(struct msm_otg *motg) | |||
1003 | 1003 | ||
1004 | static void msm_chg_block_off(struct msm_otg *motg) | 1004 | static void msm_chg_block_off(struct msm_otg *motg) |
1005 | { | 1005 | { |
1006 | struct otg_transceiver *otg = &motg->otg; | 1006 | struct usb_phy *phy = &motg->phy; |
1007 | u32 func_ctrl, chg_det; | 1007 | u32 func_ctrl, chg_det; |
1008 | 1008 | ||
1009 | switch (motg->pdata->phy_type) { | 1009 | switch (motg->pdata->phy_type) { |
1010 | case CI_45NM_INTEGRATED_PHY: | 1010 | case CI_45NM_INTEGRATED_PHY: |
1011 | chg_det = ulpi_read(otg, 0x34); | 1011 | chg_det = ulpi_read(phy, 0x34); |
1012 | /* Turn off charger block */ | 1012 | /* Turn off charger block */ |
1013 | chg_det |= ~(1 << 1); | 1013 | chg_det |= ~(1 << 1); |
1014 | ulpi_write(otg, chg_det, 0x34); | 1014 | ulpi_write(phy, chg_det, 0x34); |
1015 | break; | 1015 | break; |
1016 | case SNPS_28NM_INTEGRATED_PHY: | 1016 | case SNPS_28NM_INTEGRATED_PHY: |
1017 | /* Clear charger detecting control bits */ | 1017 | /* Clear charger detecting control bits */ |
1018 | ulpi_write(otg, 0x3F, 0x86); | 1018 | ulpi_write(phy, 0x3F, 0x86); |
1019 | /* Clear alt interrupt latch and enable bits */ | 1019 | /* Clear alt interrupt latch and enable bits */ |
1020 | ulpi_write(otg, 0x1F, 0x92); | 1020 | ulpi_write(phy, 0x1F, 0x92); |
1021 | ulpi_write(otg, 0x1F, 0x95); | 1021 | ulpi_write(phy, 0x1F, 0x95); |
1022 | break; | 1022 | break; |
1023 | default: | 1023 | default: |
1024 | break; | 1024 | break; |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | /* put the controller in normal mode */ | 1027 | /* put the controller in normal mode */ |
1028 | func_ctrl = ulpi_read(otg, ULPI_FUNC_CTRL); | 1028 | func_ctrl = ulpi_read(phy, ULPI_FUNC_CTRL); |
1029 | func_ctrl &= ~ULPI_FUNC_CTRL_OPMODE_MASK; | 1029 | func_ctrl &= ~ULPI_FUNC_CTRL_OPMODE_MASK; |
1030 | func_ctrl |= ULPI_FUNC_CTRL_OPMODE_NORMAL; | 1030 | func_ctrl |= ULPI_FUNC_CTRL_OPMODE_NORMAL; |
1031 | ulpi_write(otg, func_ctrl, ULPI_FUNC_CTRL); | 1031 | ulpi_write(phy, func_ctrl, ULPI_FUNC_CTRL); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | #define MSM_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */ | 1034 | #define MSM_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */ |
@@ -1038,14 +1038,14 @@ static void msm_chg_block_off(struct msm_otg *motg) | |||
1038 | static void msm_chg_detect_work(struct work_struct *w) | 1038 | static void msm_chg_detect_work(struct work_struct *w) |
1039 | { | 1039 | { |
1040 | struct msm_otg *motg = container_of(w, struct msm_otg, chg_work.work); | 1040 | struct msm_otg *motg = container_of(w, struct msm_otg, chg_work.work); |
1041 | struct otg_transceiver *otg = &motg->otg; | 1041 | struct usb_phy *phy = &motg->phy; |
1042 | bool is_dcd, tmout, vout; | 1042 | bool is_dcd, tmout, vout; |
1043 | unsigned long delay; | 1043 | unsigned long delay; |
1044 | 1044 | ||
1045 | dev_dbg(otg->dev, "chg detection work\n"); | 1045 | dev_dbg(phy->dev, "chg detection work\n"); |
1046 | switch (motg->chg_state) { | 1046 | switch (motg->chg_state) { |
1047 | case USB_CHG_STATE_UNDEFINED: | 1047 | case USB_CHG_STATE_UNDEFINED: |
1048 | pm_runtime_get_sync(otg->dev); | 1048 | pm_runtime_get_sync(phy->dev); |
1049 | msm_chg_block_on(motg); | 1049 | msm_chg_block_on(motg); |
1050 | msm_chg_enable_dcd(motg); | 1050 | msm_chg_enable_dcd(motg); |
1051 | motg->chg_state = USB_CHG_STATE_WAIT_FOR_DCD; | 1051 | motg->chg_state = USB_CHG_STATE_WAIT_FOR_DCD; |
@@ -1088,7 +1088,7 @@ static void msm_chg_detect_work(struct work_struct *w) | |||
1088 | motg->chg_state = USB_CHG_STATE_DETECTED; | 1088 | motg->chg_state = USB_CHG_STATE_DETECTED; |
1089 | case USB_CHG_STATE_DETECTED: | 1089 | case USB_CHG_STATE_DETECTED: |
1090 | msm_chg_block_off(motg); | 1090 | msm_chg_block_off(motg); |
1091 | dev_dbg(otg->dev, "charger = %d\n", motg->chg_type); | 1091 | dev_dbg(phy->dev, "charger = %d\n", motg->chg_type); |
1092 | schedule_work(&motg->sm_work); | 1092 | schedule_work(&motg->sm_work); |
1093 | return; | 1093 | return; |
1094 | default: | 1094 | default: |
@@ -1152,22 +1152,22 @@ static void msm_otg_init_sm(struct msm_otg *motg) | |||
1152 | static void msm_otg_sm_work(struct work_struct *w) | 1152 | static void msm_otg_sm_work(struct work_struct *w) |
1153 | { | 1153 | { |
1154 | struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); | 1154 | struct msm_otg *motg = container_of(w, struct msm_otg, sm_work); |
1155 | struct otg_transceiver *otg = &motg->otg; | 1155 | struct usb_otg *otg = motg->phy.otg; |
1156 | 1156 | ||
1157 | switch (otg->state) { | 1157 | switch (otg->phy->state) { |
1158 | case OTG_STATE_UNDEFINED: | 1158 | case OTG_STATE_UNDEFINED: |
1159 | dev_dbg(otg->dev, "OTG_STATE_UNDEFINED state\n"); | 1159 | dev_dbg(otg->phy->dev, "OTG_STATE_UNDEFINED state\n"); |
1160 | msm_otg_reset(otg); | 1160 | msm_otg_reset(otg->phy); |
1161 | msm_otg_init_sm(motg); | 1161 | msm_otg_init_sm(motg); |
1162 | otg->state = OTG_STATE_B_IDLE; | 1162 | otg->phy->state = OTG_STATE_B_IDLE; |
1163 | /* FALL THROUGH */ | 1163 | /* FALL THROUGH */ |
1164 | case OTG_STATE_B_IDLE: | 1164 | case OTG_STATE_B_IDLE: |
1165 | dev_dbg(otg->dev, "OTG_STATE_B_IDLE state\n"); | 1165 | dev_dbg(otg->phy->dev, "OTG_STATE_B_IDLE state\n"); |
1166 | if (!test_bit(ID, &motg->inputs) && otg->host) { | 1166 | if (!test_bit(ID, &motg->inputs) && otg->host) { |
1167 | /* disable BSV bit */ | 1167 | /* disable BSV bit */ |
1168 | writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); | 1168 | writel(readl(USB_OTGSC) & ~OTGSC_BSVIE, USB_OTGSC); |
1169 | msm_otg_start_host(otg, 1); | 1169 | msm_otg_start_host(otg->phy, 1); |
1170 | otg->state = OTG_STATE_A_HOST; | 1170 | otg->phy->state = OTG_STATE_A_HOST; |
1171 | } else if (test_bit(B_SESS_VLD, &motg->inputs)) { | 1171 | } else if (test_bit(B_SESS_VLD, &motg->inputs)) { |
1172 | switch (motg->chg_state) { | 1172 | switch (motg->chg_state) { |
1173 | case USB_CHG_STATE_UNDEFINED: | 1173 | case USB_CHG_STATE_UNDEFINED: |
@@ -1182,13 +1182,15 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1182 | case USB_CDP_CHARGER: | 1182 | case USB_CDP_CHARGER: |
1183 | msm_otg_notify_charger(motg, | 1183 | msm_otg_notify_charger(motg, |
1184 | IDEV_CHG_MAX); | 1184 | IDEV_CHG_MAX); |
1185 | msm_otg_start_peripheral(otg, 1); | 1185 | msm_otg_start_peripheral(otg->phy, 1); |
1186 | otg->state = OTG_STATE_B_PERIPHERAL; | 1186 | otg->phy->state |
1187 | = OTG_STATE_B_PERIPHERAL; | ||
1187 | break; | 1188 | break; |
1188 | case USB_SDP_CHARGER: | 1189 | case USB_SDP_CHARGER: |
1189 | msm_otg_notify_charger(motg, IUNIT); | 1190 | msm_otg_notify_charger(motg, IUNIT); |
1190 | msm_otg_start_peripheral(otg, 1); | 1191 | msm_otg_start_peripheral(otg->phy, 1); |
1191 | otg->state = OTG_STATE_B_PERIPHERAL; | 1192 | otg->phy->state |
1193 | = OTG_STATE_B_PERIPHERAL; | ||
1192 | break; | 1194 | break; |
1193 | default: | 1195 | default: |
1194 | break; | 1196 | break; |
@@ -1204,34 +1206,34 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1204 | * is incremented in charger detection work. | 1206 | * is incremented in charger detection work. |
1205 | */ | 1207 | */ |
1206 | if (cancel_delayed_work_sync(&motg->chg_work)) { | 1208 | if (cancel_delayed_work_sync(&motg->chg_work)) { |
1207 | pm_runtime_put_sync(otg->dev); | 1209 | pm_runtime_put_sync(otg->phy->dev); |
1208 | msm_otg_reset(otg); | 1210 | msm_otg_reset(otg->phy); |
1209 | } | 1211 | } |
1210 | msm_otg_notify_charger(motg, 0); | 1212 | msm_otg_notify_charger(motg, 0); |
1211 | motg->chg_state = USB_CHG_STATE_UNDEFINED; | 1213 | motg->chg_state = USB_CHG_STATE_UNDEFINED; |
1212 | motg->chg_type = USB_INVALID_CHARGER; | 1214 | motg->chg_type = USB_INVALID_CHARGER; |
1213 | } | 1215 | } |
1214 | pm_runtime_put_sync(otg->dev); | 1216 | pm_runtime_put_sync(otg->phy->dev); |
1215 | break; | 1217 | break; |
1216 | case OTG_STATE_B_PERIPHERAL: | 1218 | case OTG_STATE_B_PERIPHERAL: |
1217 | dev_dbg(otg->dev, "OTG_STATE_B_PERIPHERAL state\n"); | 1219 | dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n"); |
1218 | if (!test_bit(B_SESS_VLD, &motg->inputs) || | 1220 | if (!test_bit(B_SESS_VLD, &motg->inputs) || |
1219 | !test_bit(ID, &motg->inputs)) { | 1221 | !test_bit(ID, &motg->inputs)) { |
1220 | msm_otg_notify_charger(motg, 0); | 1222 | msm_otg_notify_charger(motg, 0); |
1221 | msm_otg_start_peripheral(otg, 0); | 1223 | msm_otg_start_peripheral(otg->phy, 0); |
1222 | motg->chg_state = USB_CHG_STATE_UNDEFINED; | 1224 | motg->chg_state = USB_CHG_STATE_UNDEFINED; |
1223 | motg->chg_type = USB_INVALID_CHARGER; | 1225 | motg->chg_type = USB_INVALID_CHARGER; |
1224 | otg->state = OTG_STATE_B_IDLE; | 1226 | otg->phy->state = OTG_STATE_B_IDLE; |
1225 | msm_otg_reset(otg); | 1227 | msm_otg_reset(otg->phy); |
1226 | schedule_work(w); | 1228 | schedule_work(w); |
1227 | } | 1229 | } |
1228 | break; | 1230 | break; |
1229 | case OTG_STATE_A_HOST: | 1231 | case OTG_STATE_A_HOST: |
1230 | dev_dbg(otg->dev, "OTG_STATE_A_HOST state\n"); | 1232 | dev_dbg(otg->phy->dev, "OTG_STATE_A_HOST state\n"); |
1231 | if (test_bit(ID, &motg->inputs)) { | 1233 | if (test_bit(ID, &motg->inputs)) { |
1232 | msm_otg_start_host(otg, 0); | 1234 | msm_otg_start_host(otg->phy, 0); |
1233 | otg->state = OTG_STATE_B_IDLE; | 1235 | otg->phy->state = OTG_STATE_B_IDLE; |
1234 | msm_otg_reset(otg); | 1236 | msm_otg_reset(otg->phy); |
1235 | schedule_work(w); | 1237 | schedule_work(w); |
1236 | } | 1238 | } |
1237 | break; | 1239 | break; |
@@ -1243,13 +1245,13 @@ static void msm_otg_sm_work(struct work_struct *w) | |||
1243 | static irqreturn_t msm_otg_irq(int irq, void *data) | 1245 | static irqreturn_t msm_otg_irq(int irq, void *data) |
1244 | { | 1246 | { |
1245 | struct msm_otg *motg = data; | 1247 | struct msm_otg *motg = data; |
1246 | struct otg_transceiver *otg = &motg->otg; | 1248 | struct usb_phy *phy = &motg->phy; |
1247 | u32 otgsc = 0; | 1249 | u32 otgsc = 0; |
1248 | 1250 | ||
1249 | if (atomic_read(&motg->in_lpm)) { | 1251 | if (atomic_read(&motg->in_lpm)) { |
1250 | disable_irq_nosync(irq); | 1252 | disable_irq_nosync(irq); |
1251 | motg->async_int = 1; | 1253 | motg->async_int = 1; |
1252 | pm_runtime_get(otg->dev); | 1254 | pm_runtime_get(phy->dev); |
1253 | return IRQ_HANDLED; | 1255 | return IRQ_HANDLED; |
1254 | } | 1256 | } |
1255 | 1257 | ||
@@ -1262,15 +1264,15 @@ static irqreturn_t msm_otg_irq(int irq, void *data) | |||
1262 | set_bit(ID, &motg->inputs); | 1264 | set_bit(ID, &motg->inputs); |
1263 | else | 1265 | else |
1264 | clear_bit(ID, &motg->inputs); | 1266 | clear_bit(ID, &motg->inputs); |
1265 | dev_dbg(otg->dev, "ID set/clear\n"); | 1267 | dev_dbg(phy->dev, "ID set/clear\n"); |
1266 | pm_runtime_get_noresume(otg->dev); | 1268 | pm_runtime_get_noresume(phy->dev); |
1267 | } else if ((otgsc & OTGSC_BSVIS) && (otgsc & OTGSC_BSVIE)) { | 1269 | } else if ((otgsc & OTGSC_BSVIS) && (otgsc & OTGSC_BSVIE)) { |
1268 | if (otgsc & OTGSC_BSV) | 1270 | if (otgsc & OTGSC_BSV) |
1269 | set_bit(B_SESS_VLD, &motg->inputs); | 1271 | set_bit(B_SESS_VLD, &motg->inputs); |
1270 | else | 1272 | else |
1271 | clear_bit(B_SESS_VLD, &motg->inputs); | 1273 | clear_bit(B_SESS_VLD, &motg->inputs); |
1272 | dev_dbg(otg->dev, "BSV set/clear\n"); | 1274 | dev_dbg(phy->dev, "BSV set/clear\n"); |
1273 | pm_runtime_get_noresume(otg->dev); | 1275 | pm_runtime_get_noresume(phy->dev); |
1274 | } | 1276 | } |
1275 | 1277 | ||
1276 | writel(otgsc, USB_OTGSC); | 1278 | writel(otgsc, USB_OTGSC); |
@@ -1281,9 +1283,9 @@ static irqreturn_t msm_otg_irq(int irq, void *data) | |||
1281 | static int msm_otg_mode_show(struct seq_file *s, void *unused) | 1283 | static int msm_otg_mode_show(struct seq_file *s, void *unused) |
1282 | { | 1284 | { |
1283 | struct msm_otg *motg = s->private; | 1285 | struct msm_otg *motg = s->private; |
1284 | struct otg_transceiver *otg = &motg->otg; | 1286 | struct usb_otg *otg = motg->phy.otg; |
1285 | 1287 | ||
1286 | switch (otg->state) { | 1288 | switch (otg->phy->state) { |
1287 | case OTG_STATE_A_HOST: | 1289 | case OTG_STATE_A_HOST: |
1288 | seq_printf(s, "host\n"); | 1290 | seq_printf(s, "host\n"); |
1289 | break; | 1291 | break; |
@@ -1309,7 +1311,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1309 | struct seq_file *s = file->private_data; | 1311 | struct seq_file *s = file->private_data; |
1310 | struct msm_otg *motg = s->private; | 1312 | struct msm_otg *motg = s->private; |
1311 | char buf[16]; | 1313 | char buf[16]; |
1312 | struct otg_transceiver *otg = &motg->otg; | 1314 | struct usb_otg *otg = motg->phy.otg; |
1313 | int status = count; | 1315 | int status = count; |
1314 | enum usb_mode_type req_mode; | 1316 | enum usb_mode_type req_mode; |
1315 | 1317 | ||
@@ -1333,7 +1335,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1333 | 1335 | ||
1334 | switch (req_mode) { | 1336 | switch (req_mode) { |
1335 | case USB_NONE: | 1337 | case USB_NONE: |
1336 | switch (otg->state) { | 1338 | switch (otg->phy->state) { |
1337 | case OTG_STATE_A_HOST: | 1339 | case OTG_STATE_A_HOST: |
1338 | case OTG_STATE_B_PERIPHERAL: | 1340 | case OTG_STATE_B_PERIPHERAL: |
1339 | set_bit(ID, &motg->inputs); | 1341 | set_bit(ID, &motg->inputs); |
@@ -1344,7 +1346,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1344 | } | 1346 | } |
1345 | break; | 1347 | break; |
1346 | case USB_PERIPHERAL: | 1348 | case USB_PERIPHERAL: |
1347 | switch (otg->state) { | 1349 | switch (otg->phy->state) { |
1348 | case OTG_STATE_B_IDLE: | 1350 | case OTG_STATE_B_IDLE: |
1349 | case OTG_STATE_A_HOST: | 1351 | case OTG_STATE_A_HOST: |
1350 | set_bit(ID, &motg->inputs); | 1352 | set_bit(ID, &motg->inputs); |
@@ -1355,7 +1357,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1355 | } | 1357 | } |
1356 | break; | 1358 | break; |
1357 | case USB_HOST: | 1359 | case USB_HOST: |
1358 | switch (otg->state) { | 1360 | switch (otg->phy->state) { |
1359 | case OTG_STATE_B_IDLE: | 1361 | case OTG_STATE_B_IDLE: |
1360 | case OTG_STATE_B_PERIPHERAL: | 1362 | case OTG_STATE_B_PERIPHERAL: |
1361 | clear_bit(ID, &motg->inputs); | 1363 | clear_bit(ID, &motg->inputs); |
@@ -1368,7 +1370,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf, | |||
1368 | goto out; | 1370 | goto out; |
1369 | } | 1371 | } |
1370 | 1372 | ||
1371 | pm_runtime_get_sync(otg->dev); | 1373 | pm_runtime_get_sync(otg->phy->dev); |
1372 | schedule_work(&motg->sm_work); | 1374 | schedule_work(&motg->sm_work); |
1373 | out: | 1375 | out: |
1374 | return status; | 1376 | return status; |
@@ -1414,7 +1416,7 @@ static int __init msm_otg_probe(struct platform_device *pdev) | |||
1414 | int ret = 0; | 1416 | int ret = 0; |
1415 | struct resource *res; | 1417 | struct resource *res; |
1416 | struct msm_otg *motg; | 1418 | struct msm_otg *motg; |
1417 | struct otg_transceiver *otg; | 1419 | struct usb_phy *phy; |
1418 | 1420 | ||
1419 | dev_info(&pdev->dev, "msm_otg probe\n"); | 1421 | dev_info(&pdev->dev, "msm_otg probe\n"); |
1420 | if (!pdev->dev.platform_data) { | 1422 | if (!pdev->dev.platform_data) { |
@@ -1428,9 +1430,15 @@ static int __init msm_otg_probe(struct platform_device *pdev) | |||
1428 | return -ENOMEM; | 1430 | return -ENOMEM; |
1429 | } | 1431 | } |
1430 | 1432 | ||
1433 | motg->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL); | ||
1434 | if (!motg->phy.otg) { | ||
1435 | dev_err(&pdev->dev, "unable to allocate msm_otg\n"); | ||
1436 | return -ENOMEM; | ||
1437 | } | ||
1438 | |||
1431 | motg->pdata = pdev->dev.platform_data; | 1439 | motg->pdata = pdev->dev.platform_data; |
1432 | otg = &motg->otg; | 1440 | phy = &motg->phy; |
1433 | otg->dev = &pdev->dev; | 1441 | phy->dev = &pdev->dev; |
1434 | 1442 | ||
1435 | motg->phy_reset_clk = clk_get(&pdev->dev, "usb_phy_clk"); | 1443 | motg->phy_reset_clk = clk_get(&pdev->dev, "usb_phy_clk"); |
1436 | if (IS_ERR(motg->phy_reset_clk)) { | 1444 | if (IS_ERR(motg->phy_reset_clk)) { |
@@ -1538,16 +1546,18 @@ static int __init msm_otg_probe(struct platform_device *pdev) | |||
1538 | goto disable_clks; | 1546 | goto disable_clks; |
1539 | } | 1547 | } |
1540 | 1548 | ||
1541 | otg->init = msm_otg_reset; | 1549 | phy->init = msm_otg_reset; |
1542 | otg->set_host = msm_otg_set_host; | 1550 | phy->set_power = msm_otg_set_power; |
1543 | otg->set_peripheral = msm_otg_set_peripheral; | 1551 | |
1544 | otg->set_power = msm_otg_set_power; | 1552 | phy->io_ops = &msm_otg_io_ops; |
1545 | 1553 | ||
1546 | otg->io_ops = &msm_otg_io_ops; | 1554 | phy->otg->phy = &motg->phy; |
1555 | phy->otg->set_host = msm_otg_set_host; | ||
1556 | phy->otg->set_peripheral = msm_otg_set_peripheral; | ||
1547 | 1557 | ||
1548 | ret = otg_set_transceiver(&motg->otg); | 1558 | ret = usb_set_transceiver(&motg->phy); |
1549 | if (ret) { | 1559 | if (ret) { |
1550 | dev_err(&pdev->dev, "otg_set_transceiver failed\n"); | 1560 | dev_err(&pdev->dev, "usb_set_transceiver failed\n"); |
1551 | goto free_irq; | 1561 | goto free_irq; |
1552 | } | 1562 | } |
1553 | 1563 | ||
@@ -1591,6 +1601,7 @@ put_clk: | |||
1591 | put_phy_reset_clk: | 1601 | put_phy_reset_clk: |
1592 | clk_put(motg->phy_reset_clk); | 1602 | clk_put(motg->phy_reset_clk); |
1593 | free_motg: | 1603 | free_motg: |
1604 | kfree(motg->phy.otg); | ||
1594 | kfree(motg); | 1605 | kfree(motg); |
1595 | return ret; | 1606 | return ret; |
1596 | } | 1607 | } |
@@ -1598,10 +1609,10 @@ free_motg: | |||
1598 | static int __devexit msm_otg_remove(struct platform_device *pdev) | 1609 | static int __devexit msm_otg_remove(struct platform_device *pdev) |
1599 | { | 1610 | { |
1600 | struct msm_otg *motg = platform_get_drvdata(pdev); | 1611 | struct msm_otg *motg = platform_get_drvdata(pdev); |
1601 | struct otg_transceiver *otg = &motg->otg; | 1612 | struct usb_phy *phy = &motg->phy; |
1602 | int cnt = 0; | 1613 | int cnt = 0; |
1603 | 1614 | ||
1604 | if (otg->host || otg->gadget) | 1615 | if (phy->otg->host || phy->otg->gadget) |
1605 | return -EBUSY; | 1616 | return -EBUSY; |
1606 | 1617 | ||
1607 | msm_otg_debugfs_cleanup(); | 1618 | msm_otg_debugfs_cleanup(); |
@@ -1613,14 +1624,14 @@ static int __devexit msm_otg_remove(struct platform_device *pdev) | |||
1613 | device_init_wakeup(&pdev->dev, 0); | 1624 | device_init_wakeup(&pdev->dev, 0); |
1614 | pm_runtime_disable(&pdev->dev); | 1625 | pm_runtime_disable(&pdev->dev); |
1615 | 1626 | ||
1616 | otg_set_transceiver(NULL); | 1627 | usb_set_transceiver(NULL); |
1617 | free_irq(motg->irq, motg); | 1628 | free_irq(motg->irq, motg); |
1618 | 1629 | ||
1619 | /* | 1630 | /* |
1620 | * Put PHY in low power mode. | 1631 | * Put PHY in low power mode. |
1621 | */ | 1632 | */ |
1622 | ulpi_read(otg, 0x14); | 1633 | ulpi_read(phy, 0x14); |
1623 | ulpi_write(otg, 0x08, 0x09); | 1634 | ulpi_write(phy, 0x08, 0x09); |
1624 | 1635 | ||
1625 | writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC); | 1636 | writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC); |
1626 | while (cnt < PHY_SUSPEND_TIMEOUT_USEC) { | 1637 | while (cnt < PHY_SUSPEND_TIMEOUT_USEC) { |
@@ -1630,7 +1641,7 @@ static int __devexit msm_otg_remove(struct platform_device *pdev) | |||
1630 | cnt++; | 1641 | cnt++; |
1631 | } | 1642 | } |
1632 | if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) | 1643 | if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) |
1633 | dev_err(otg->dev, "Unable to suspend PHY\n"); | 1644 | dev_err(phy->dev, "Unable to suspend PHY\n"); |
1634 | 1645 | ||
1635 | clk_disable(motg->pclk); | 1646 | clk_disable(motg->pclk); |
1636 | clk_disable(motg->clk); | 1647 | clk_disable(motg->clk); |
@@ -1651,6 +1662,7 @@ static int __devexit msm_otg_remove(struct platform_device *pdev) | |||
1651 | if (motg->core_clk) | 1662 | if (motg->core_clk) |
1652 | clk_put(motg->core_clk); | 1663 | clk_put(motg->core_clk); |
1653 | 1664 | ||
1665 | kfree(motg->phy.otg); | ||
1654 | kfree(motg); | 1666 | kfree(motg); |
1655 | 1667 | ||
1656 | return 0; | 1668 | return 0; |
@@ -1660,7 +1672,7 @@ static int __devexit msm_otg_remove(struct platform_device *pdev) | |||
1660 | static int msm_otg_runtime_idle(struct device *dev) | 1672 | static int msm_otg_runtime_idle(struct device *dev) |
1661 | { | 1673 | { |
1662 | struct msm_otg *motg = dev_get_drvdata(dev); | 1674 | struct msm_otg *motg = dev_get_drvdata(dev); |
1663 | struct otg_transceiver *otg = &motg->otg; | 1675 | struct usb_otg *otg = motg->phy.otg; |
1664 | 1676 | ||
1665 | dev_dbg(dev, "OTG runtime idle\n"); | 1677 | dev_dbg(dev, "OTG runtime idle\n"); |
1666 | 1678 | ||
@@ -1670,7 +1682,7 @@ static int msm_otg_runtime_idle(struct device *dev) | |||
1670 | * This 1 sec delay also prevents entering into LPM immediately | 1682 | * This 1 sec delay also prevents entering into LPM immediately |
1671 | * after asynchronous interrupt. | 1683 | * after asynchronous interrupt. |
1672 | */ | 1684 | */ |
1673 | if (otg->state != OTG_STATE_UNDEFINED) | 1685 | if (otg->phy->state != OTG_STATE_UNDEFINED) |
1674 | pm_schedule_suspend(dev, 1000); | 1686 | pm_schedule_suspend(dev, 1000); |
1675 | 1687 | ||
1676 | return -EAGAIN; | 1688 | return -EAGAIN; |
diff --git a/drivers/usb/otg/mv_otg.c b/drivers/usb/otg/mv_otg.c index b5fbe1452ab0..6cc6c3ffbb83 100644 --- a/drivers/usb/otg/mv_otg.c +++ b/drivers/usb/otg/mv_otg.c | |||
@@ -55,16 +55,16 @@ static char *state_string[] = { | |||
55 | "a_vbus_err" | 55 | "a_vbus_err" |
56 | }; | 56 | }; |
57 | 57 | ||
58 | static int mv_otg_set_vbus(struct otg_transceiver *otg, bool on) | 58 | static int mv_otg_set_vbus(struct usb_otg *otg, bool on) |
59 | { | 59 | { |
60 | struct mv_otg *mvotg = container_of(otg, struct mv_otg, otg); | 60 | struct mv_otg *mvotg = container_of(otg->phy, struct mv_otg, phy); |
61 | if (mvotg->pdata->set_vbus == NULL) | 61 | if (mvotg->pdata->set_vbus == NULL) |
62 | return -ENODEV; | 62 | return -ENODEV; |
63 | 63 | ||
64 | return mvotg->pdata->set_vbus(on); | 64 | return mvotg->pdata->set_vbus(on); |
65 | } | 65 | } |
66 | 66 | ||
67 | static int mv_otg_set_host(struct otg_transceiver *otg, | 67 | static int mv_otg_set_host(struct usb_otg *otg, |
68 | struct usb_bus *host) | 68 | struct usb_bus *host) |
69 | { | 69 | { |
70 | otg->host = host; | 70 | otg->host = host; |
@@ -72,7 +72,7 @@ static int mv_otg_set_host(struct otg_transceiver *otg, | |||
72 | return 0; | 72 | return 0; |
73 | } | 73 | } |
74 | 74 | ||
75 | static int mv_otg_set_peripheral(struct otg_transceiver *otg, | 75 | static int mv_otg_set_peripheral(struct usb_otg *otg, |
76 | struct usb_gadget *gadget) | 76 | struct usb_gadget *gadget) |
77 | { | 77 | { |
78 | otg->gadget = gadget; | 78 | otg->gadget = gadget; |
@@ -203,7 +203,7 @@ static void mv_otg_init_irq(struct mv_otg *mvotg) | |||
203 | static void mv_otg_start_host(struct mv_otg *mvotg, int on) | 203 | static void mv_otg_start_host(struct mv_otg *mvotg, int on) |
204 | { | 204 | { |
205 | #ifdef CONFIG_USB | 205 | #ifdef CONFIG_USB |
206 | struct otg_transceiver *otg = &mvotg->otg; | 206 | struct usb_otg *otg = mvotg->phy.otg; |
207 | struct usb_hcd *hcd; | 207 | struct usb_hcd *hcd; |
208 | 208 | ||
209 | if (!otg->host) | 209 | if (!otg->host) |
@@ -222,12 +222,12 @@ static void mv_otg_start_host(struct mv_otg *mvotg, int on) | |||
222 | 222 | ||
223 | static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) | 223 | static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on) |
224 | { | 224 | { |
225 | struct otg_transceiver *otg = &mvotg->otg; | 225 | struct usb_otg *otg = mvotg->phy.otg; |
226 | 226 | ||
227 | if (!otg->gadget) | 227 | if (!otg->gadget) |
228 | return; | 228 | return; |
229 | 229 | ||
230 | dev_info(otg->dev, "gadget %s\n", on ? "on" : "off"); | 230 | dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off"); |
231 | 231 | ||
232 | if (on) | 232 | if (on) |
233 | usb_gadget_vbus_connect(otg->gadget); | 233 | usb_gadget_vbus_connect(otg->gadget); |
@@ -343,69 +343,69 @@ static void mv_otg_update_inputs(struct mv_otg *mvotg) | |||
343 | static void mv_otg_update_state(struct mv_otg *mvotg) | 343 | static void mv_otg_update_state(struct mv_otg *mvotg) |
344 | { | 344 | { |
345 | struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; | 345 | struct mv_otg_ctrl *otg_ctrl = &mvotg->otg_ctrl; |
346 | struct otg_transceiver *otg = &mvotg->otg; | 346 | struct usb_phy *phy = &mvotg->phy; |
347 | int old_state = otg->state; | 347 | int old_state = phy->state; |
348 | 348 | ||
349 | switch (old_state) { | 349 | switch (old_state) { |
350 | case OTG_STATE_UNDEFINED: | 350 | case OTG_STATE_UNDEFINED: |
351 | otg->state = OTG_STATE_B_IDLE; | 351 | phy->state = OTG_STATE_B_IDLE; |
352 | /* FALL THROUGH */ | 352 | /* FALL THROUGH */ |
353 | case OTG_STATE_B_IDLE: | 353 | case OTG_STATE_B_IDLE: |
354 | if (otg_ctrl->id == 0) | 354 | if (otg_ctrl->id == 0) |
355 | otg->state = OTG_STATE_A_IDLE; | 355 | phy->state = OTG_STATE_A_IDLE; |
356 | else if (otg_ctrl->b_sess_vld) | 356 | else if (otg_ctrl->b_sess_vld) |
357 | otg->state = OTG_STATE_B_PERIPHERAL; | 357 | phy->state = OTG_STATE_B_PERIPHERAL; |
358 | break; | 358 | break; |
359 | case OTG_STATE_B_PERIPHERAL: | 359 | case OTG_STATE_B_PERIPHERAL: |
360 | if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) | 360 | if (!otg_ctrl->b_sess_vld || otg_ctrl->id == 0) |
361 | otg->state = OTG_STATE_B_IDLE; | 361 | phy->state = OTG_STATE_B_IDLE; |
362 | break; | 362 | break; |
363 | case OTG_STATE_A_IDLE: | 363 | case OTG_STATE_A_IDLE: |
364 | if (otg_ctrl->id) | 364 | if (otg_ctrl->id) |
365 | otg->state = OTG_STATE_B_IDLE; | 365 | phy->state = OTG_STATE_B_IDLE; |
366 | else if (!(otg_ctrl->a_bus_drop) && | 366 | else if (!(otg_ctrl->a_bus_drop) && |
367 | (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) | 367 | (otg_ctrl->a_bus_req || otg_ctrl->a_srp_det)) |
368 | otg->state = OTG_STATE_A_WAIT_VRISE; | 368 | phy->state = OTG_STATE_A_WAIT_VRISE; |
369 | break; | 369 | break; |
370 | case OTG_STATE_A_WAIT_VRISE: | 370 | case OTG_STATE_A_WAIT_VRISE: |
371 | if (otg_ctrl->a_vbus_vld) | 371 | if (otg_ctrl->a_vbus_vld) |
372 | otg->state = OTG_STATE_A_WAIT_BCON; | 372 | phy->state = OTG_STATE_A_WAIT_BCON; |
373 | break; | 373 | break; |
374 | case OTG_STATE_A_WAIT_BCON: | 374 | case OTG_STATE_A_WAIT_BCON: |
375 | if (otg_ctrl->id || otg_ctrl->a_bus_drop | 375 | if (otg_ctrl->id || otg_ctrl->a_bus_drop |
376 | || otg_ctrl->a_wait_bcon_timeout) { | 376 | || otg_ctrl->a_wait_bcon_timeout) { |
377 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | 377 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); |
378 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | 378 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; |
379 | otg->state = OTG_STATE_A_WAIT_VFALL; | 379 | phy->state = OTG_STATE_A_WAIT_VFALL; |
380 | otg_ctrl->a_bus_req = 0; | 380 | otg_ctrl->a_bus_req = 0; |
381 | } else if (!otg_ctrl->a_vbus_vld) { | 381 | } else if (!otg_ctrl->a_vbus_vld) { |
382 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | 382 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); |
383 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | 383 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; |
384 | otg->state = OTG_STATE_A_VBUS_ERR; | 384 | phy->state = OTG_STATE_A_VBUS_ERR; |
385 | } else if (otg_ctrl->b_conn) { | 385 | } else if (otg_ctrl->b_conn) { |
386 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); | 386 | mv_otg_cancel_timer(mvotg, A_WAIT_BCON_TIMER); |
387 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; | 387 | mvotg->otg_ctrl.a_wait_bcon_timeout = 0; |
388 | otg->state = OTG_STATE_A_HOST; | 388 | phy->state = OTG_STATE_A_HOST; |
389 | } | 389 | } |
390 | break; | 390 | break; |
391 | case OTG_STATE_A_HOST: | 391 | case OTG_STATE_A_HOST: |
392 | if (otg_ctrl->id || !otg_ctrl->b_conn | 392 | if (otg_ctrl->id || !otg_ctrl->b_conn |
393 | || otg_ctrl->a_bus_drop) | 393 | || otg_ctrl->a_bus_drop) |
394 | otg->state = OTG_STATE_A_WAIT_BCON; | 394 | phy->state = OTG_STATE_A_WAIT_BCON; |
395 | else if (!otg_ctrl->a_vbus_vld) | 395 | else if (!otg_ctrl->a_vbus_vld) |
396 | otg->state = OTG_STATE_A_VBUS_ERR; | 396 | phy->state = OTG_STATE_A_VBUS_ERR; |
397 | break; | 397 | break; |
398 | case OTG_STATE_A_WAIT_VFALL: | 398 | case OTG_STATE_A_WAIT_VFALL: |
399 | if (otg_ctrl->id | 399 | if (otg_ctrl->id |
400 | || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) | 400 | || (!otg_ctrl->b_conn && otg_ctrl->a_sess_vld) |
401 | || otg_ctrl->a_bus_req) | 401 | || otg_ctrl->a_bus_req) |
402 | otg->state = OTG_STATE_A_IDLE; | 402 | phy->state = OTG_STATE_A_IDLE; |
403 | break; | 403 | break; |
404 | case OTG_STATE_A_VBUS_ERR: | 404 | case OTG_STATE_A_VBUS_ERR: |
405 | if (otg_ctrl->id || otg_ctrl->a_clr_err | 405 | if (otg_ctrl->id || otg_ctrl->a_clr_err |
406 | || otg_ctrl->a_bus_drop) { | 406 | || otg_ctrl->a_bus_drop) { |
407 | otg_ctrl->a_clr_err = 0; | 407 | otg_ctrl->a_clr_err = 0; |
408 | otg->state = OTG_STATE_A_WAIT_VFALL; | 408 | phy->state = OTG_STATE_A_WAIT_VFALL; |
409 | } | 409 | } |
410 | break; | 410 | break; |
411 | default: | 411 | default: |
@@ -416,15 +416,17 @@ static void mv_otg_update_state(struct mv_otg *mvotg) | |||
416 | static void mv_otg_work(struct work_struct *work) | 416 | static void mv_otg_work(struct work_struct *work) |
417 | { | 417 | { |
418 | struct mv_otg *mvotg; | 418 | struct mv_otg *mvotg; |
419 | struct otg_transceiver *otg; | 419 | struct usb_phy *phy; |
420 | struct usb_otg *otg; | ||
420 | int old_state; | 421 | int old_state; |
421 | 422 | ||
422 | mvotg = container_of((struct delayed_work *)work, struct mv_otg, work); | 423 | mvotg = container_of((struct delayed_work *)work, struct mv_otg, work); |
423 | 424 | ||
424 | run: | 425 | run: |
425 | /* work queue is single thread, or we need spin_lock to protect */ | 426 | /* work queue is single thread, or we need spin_lock to protect */ |
426 | otg = &mvotg->otg; | 427 | phy = &mvotg->phy; |
427 | old_state = otg->state; | 428 | otg = phy->otg; |
429 | old_state = phy->state; | ||
428 | 430 | ||
429 | if (!mvotg->active) | 431 | if (!mvotg->active) |
430 | return; | 432 | return; |
@@ -432,14 +434,14 @@ run: | |||
432 | mv_otg_update_inputs(mvotg); | 434 | mv_otg_update_inputs(mvotg); |
433 | mv_otg_update_state(mvotg); | 435 | mv_otg_update_state(mvotg); |
434 | 436 | ||
435 | if (old_state != otg->state) { | 437 | if (old_state != phy->state) { |
436 | dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", | 438 | dev_info(&mvotg->pdev->dev, "change from state %s to %s\n", |
437 | state_string[old_state], | 439 | state_string[old_state], |
438 | state_string[otg->state]); | 440 | state_string[phy->state]); |
439 | 441 | ||
440 | switch (otg->state) { | 442 | switch (phy->state) { |
441 | case OTG_STATE_B_IDLE: | 443 | case OTG_STATE_B_IDLE: |
442 | mvotg->otg.default_a = 0; | 444 | otg->default_a = 0; |
443 | if (old_state == OTG_STATE_B_PERIPHERAL) | 445 | if (old_state == OTG_STATE_B_PERIPHERAL) |
444 | mv_otg_start_periphrals(mvotg, 0); | 446 | mv_otg_start_periphrals(mvotg, 0); |
445 | mv_otg_reset(mvotg); | 447 | mv_otg_reset(mvotg); |
@@ -450,14 +452,14 @@ run: | |||
450 | mv_otg_start_periphrals(mvotg, 1); | 452 | mv_otg_start_periphrals(mvotg, 1); |
451 | break; | 453 | break; |
452 | case OTG_STATE_A_IDLE: | 454 | case OTG_STATE_A_IDLE: |
453 | mvotg->otg.default_a = 1; | 455 | otg->default_a = 1; |
454 | mv_otg_enable(mvotg); | 456 | mv_otg_enable(mvotg); |
455 | if (old_state == OTG_STATE_A_WAIT_VFALL) | 457 | if (old_state == OTG_STATE_A_WAIT_VFALL) |
456 | mv_otg_start_host(mvotg, 0); | 458 | mv_otg_start_host(mvotg, 0); |
457 | mv_otg_reset(mvotg); | 459 | mv_otg_reset(mvotg); |
458 | break; | 460 | break; |
459 | case OTG_STATE_A_WAIT_VRISE: | 461 | case OTG_STATE_A_WAIT_VRISE: |
460 | mv_otg_set_vbus(&mvotg->otg, 1); | 462 | mv_otg_set_vbus(otg, 1); |
461 | break; | 463 | break; |
462 | case OTG_STATE_A_WAIT_BCON: | 464 | case OTG_STATE_A_WAIT_BCON: |
463 | if (old_state != OTG_STATE_A_HOST) | 465 | if (old_state != OTG_STATE_A_HOST) |
@@ -479,7 +481,7 @@ run: | |||
479 | * here. In fact, it need host driver to notify us. | 481 | * here. In fact, it need host driver to notify us. |
480 | */ | 482 | */ |
481 | mvotg->otg_ctrl.b_conn = 0; | 483 | mvotg->otg_ctrl.b_conn = 0; |
482 | mv_otg_set_vbus(&mvotg->otg, 0); | 484 | mv_otg_set_vbus(otg, 0); |
483 | break; | 485 | break; |
484 | case OTG_STATE_A_VBUS_ERR: | 486 | case OTG_STATE_A_VBUS_ERR: |
485 | break; | 487 | break; |
@@ -548,8 +550,8 @@ set_a_bus_req(struct device *dev, struct device_attribute *attr, | |||
548 | return -1; | 550 | return -1; |
549 | 551 | ||
550 | /* We will use this interface to change to A device */ | 552 | /* We will use this interface to change to A device */ |
551 | if (mvotg->otg.state != OTG_STATE_B_IDLE | 553 | if (mvotg->phy.state != OTG_STATE_B_IDLE |
552 | && mvotg->otg.state != OTG_STATE_A_IDLE) | 554 | && mvotg->phy.state != OTG_STATE_A_IDLE) |
553 | return -1; | 555 | return -1; |
554 | 556 | ||
555 | /* The clock may disabled and we need to set irq for ID detected */ | 557 | /* The clock may disabled and we need to set irq for ID detected */ |
@@ -579,7 +581,7 @@ set_a_clr_err(struct device *dev, struct device_attribute *attr, | |||
579 | const char *buf, size_t count) | 581 | const char *buf, size_t count) |
580 | { | 582 | { |
581 | struct mv_otg *mvotg = dev_get_drvdata(dev); | 583 | struct mv_otg *mvotg = dev_get_drvdata(dev); |
582 | if (!mvotg->otg.default_a) | 584 | if (!mvotg->phy.otg->default_a) |
583 | return -1; | 585 | return -1; |
584 | 586 | ||
585 | if (count > 2) | 587 | if (count > 2) |
@@ -615,7 +617,7 @@ set_a_bus_drop(struct device *dev, struct device_attribute *attr, | |||
615 | const char *buf, size_t count) | 617 | const char *buf, size_t count) |
616 | { | 618 | { |
617 | struct mv_otg *mvotg = dev_get_drvdata(dev); | 619 | struct mv_otg *mvotg = dev_get_drvdata(dev); |
618 | if (!mvotg->otg.default_a) | 620 | if (!mvotg->phy.otg->default_a) |
619 | return -1; | 621 | return -1; |
620 | 622 | ||
621 | if (count > 2) | 623 | if (count > 2) |
@@ -688,9 +690,10 @@ int mv_otg_remove(struct platform_device *pdev) | |||
688 | for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++) | 690 | for (clk_i = 0; clk_i <= mvotg->clknum; clk_i++) |
689 | clk_put(mvotg->clk[clk_i]); | 691 | clk_put(mvotg->clk[clk_i]); |
690 | 692 | ||
691 | otg_set_transceiver(NULL); | 693 | usb_set_transceiver(NULL); |
692 | platform_set_drvdata(pdev, NULL); | 694 | platform_set_drvdata(pdev, NULL); |
693 | 695 | ||
696 | kfree(mvotg->phy.otg); | ||
694 | kfree(mvotg); | 697 | kfree(mvotg); |
695 | 698 | ||
696 | return 0; | 699 | return 0; |
@@ -700,6 +703,7 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
700 | { | 703 | { |
701 | struct mv_usb_platform_data *pdata = pdev->dev.platform_data; | 704 | struct mv_usb_platform_data *pdata = pdev->dev.platform_data; |
702 | struct mv_otg *mvotg; | 705 | struct mv_otg *mvotg; |
706 | struct usb_otg *otg; | ||
703 | struct resource *r; | 707 | struct resource *r; |
704 | int retval = 0, clk_i, i; | 708 | int retval = 0, clk_i, i; |
705 | size_t size; | 709 | size_t size; |
@@ -716,6 +720,12 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
716 | return -ENOMEM; | 720 | return -ENOMEM; |
717 | } | 721 | } |
718 | 722 | ||
723 | otg = kzalloc(sizeof *otg, GFP_KERNEL); | ||
724 | if (!otg) { | ||
725 | kfree(mvotg); | ||
726 | return -ENOMEM; | ||
727 | } | ||
728 | |||
719 | platform_set_drvdata(pdev, mvotg); | 729 | platform_set_drvdata(pdev, mvotg); |
720 | 730 | ||
721 | mvotg->pdev = pdev; | 731 | mvotg->pdev = pdev; |
@@ -741,12 +751,15 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
741 | 751 | ||
742 | /* OTG common part */ | 752 | /* OTG common part */ |
743 | mvotg->pdev = pdev; | 753 | mvotg->pdev = pdev; |
744 | mvotg->otg.dev = &pdev->dev; | 754 | mvotg->phy.dev = &pdev->dev; |
745 | mvotg->otg.label = driver_name; | 755 | mvotg->phy.otg = otg; |
746 | mvotg->otg.set_host = mv_otg_set_host; | 756 | mvotg->phy.label = driver_name; |
747 | mvotg->otg.set_peripheral = mv_otg_set_peripheral; | 757 | mvotg->phy.state = OTG_STATE_UNDEFINED; |
748 | mvotg->otg.set_vbus = mv_otg_set_vbus; | 758 | |
749 | mvotg->otg.state = OTG_STATE_UNDEFINED; | 759 | otg->phy = &mvotg->phy; |
760 | otg->set_host = mv_otg_set_host; | ||
761 | otg->set_peripheral = mv_otg_set_peripheral; | ||
762 | otg->set_vbus = mv_otg_set_vbus; | ||
750 | 763 | ||
751 | for (i = 0; i < OTG_TIMER_NUM; i++) | 764 | for (i = 0; i < OTG_TIMER_NUM; i++) |
752 | init_timer(&mvotg->otg_ctrl.timer[i]); | 765 | init_timer(&mvotg->otg_ctrl.timer[i]); |
@@ -840,7 +853,7 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
840 | goto err_disable_clk; | 853 | goto err_disable_clk; |
841 | } | 854 | } |
842 | 855 | ||
843 | retval = otg_set_transceiver(&mvotg->otg); | 856 | retval = usb_set_transceiver(&mvotg->phy); |
844 | if (retval < 0) { | 857 | if (retval < 0) { |
845 | dev_err(&pdev->dev, "can't register transceiver, %d\n", | 858 | dev_err(&pdev->dev, "can't register transceiver, %d\n", |
846 | retval); | 859 | retval); |
@@ -867,7 +880,7 @@ static int mv_otg_probe(struct platform_device *pdev) | |||
867 | return 0; | 880 | return 0; |
868 | 881 | ||
869 | err_set_transceiver: | 882 | err_set_transceiver: |
870 | otg_set_transceiver(NULL); | 883 | usb_set_transceiver(NULL); |
871 | err_free_irq: | 884 | err_free_irq: |
872 | free_irq(mvotg->irq, mvotg); | 885 | free_irq(mvotg->irq, mvotg); |
873 | err_disable_clk: | 886 | err_disable_clk: |
@@ -888,6 +901,7 @@ err_put_clk: | |||
888 | clk_put(mvotg->clk[clk_i]); | 901 | clk_put(mvotg->clk[clk_i]); |
889 | 902 | ||
890 | platform_set_drvdata(pdev, NULL); | 903 | platform_set_drvdata(pdev, NULL); |
904 | kfree(otg); | ||
891 | kfree(mvotg); | 905 | kfree(mvotg); |
892 | 906 | ||
893 | return retval; | 907 | return retval; |
@@ -898,10 +912,10 @@ static int mv_otg_suspend(struct platform_device *pdev, pm_message_t state) | |||
898 | { | 912 | { |
899 | struct mv_otg *mvotg = platform_get_drvdata(pdev); | 913 | struct mv_otg *mvotg = platform_get_drvdata(pdev); |
900 | 914 | ||
901 | if (mvotg->otg.state != OTG_STATE_B_IDLE) { | 915 | if (mvotg->phy.state != OTG_STATE_B_IDLE) { |
902 | dev_info(&pdev->dev, | 916 | dev_info(&pdev->dev, |
903 | "OTG state is not B_IDLE, it is %d!\n", | 917 | "OTG state is not B_IDLE, it is %d!\n", |
904 | mvotg->otg.state); | 918 | mvotg->phy.state); |
905 | return -EAGAIN; | 919 | return -EAGAIN; |
906 | } | 920 | } |
907 | 921 | ||
diff --git a/drivers/usb/otg/mv_otg.h b/drivers/usb/otg/mv_otg.h index be6ca1437645..8a9e351b36ba 100644 --- a/drivers/usb/otg/mv_otg.h +++ b/drivers/usb/otg/mv_otg.h | |||
@@ -136,7 +136,7 @@ struct mv_otg_regs { | |||
136 | }; | 136 | }; |
137 | 137 | ||
138 | struct mv_otg { | 138 | struct mv_otg { |
139 | struct otg_transceiver otg; | 139 | struct usb_phy phy; |
140 | struct mv_otg_ctrl otg_ctrl; | 140 | struct mv_otg_ctrl otg_ctrl; |
141 | 141 | ||
142 | /* base address */ | 142 | /* base address */ |
diff --git a/drivers/usb/otg/nop-usb-xceiv.c b/drivers/usb/otg/nop-usb-xceiv.c index c1e360046435..58b26df6afd1 100644 --- a/drivers/usb/otg/nop-usb-xceiv.c +++ b/drivers/usb/otg/nop-usb-xceiv.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
34 | 34 | ||
35 | struct nop_usb_xceiv { | 35 | struct nop_usb_xceiv { |
36 | struct otg_transceiver otg; | 36 | struct usb_phy phy; |
37 | struct device *dev; | 37 | struct device *dev; |
38 | }; | 38 | }; |
39 | 39 | ||
@@ -58,51 +58,37 @@ void usb_nop_xceiv_unregister(void) | |||
58 | } | 58 | } |
59 | EXPORT_SYMBOL(usb_nop_xceiv_unregister); | 59 | EXPORT_SYMBOL(usb_nop_xceiv_unregister); |
60 | 60 | ||
61 | static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x) | 61 | static int nop_set_suspend(struct usb_phy *x, int suspend) |
62 | { | ||
63 | return container_of(x, struct nop_usb_xceiv, otg); | ||
64 | } | ||
65 | |||
66 | static int nop_set_suspend(struct otg_transceiver *x, int suspend) | ||
67 | { | 62 | { |
68 | return 0; | 63 | return 0; |
69 | } | 64 | } |
70 | 65 | ||
71 | static int nop_set_peripheral(struct otg_transceiver *x, | 66 | static int nop_set_peripheral(struct usb_otg *otg, struct usb_gadget *gadget) |
72 | struct usb_gadget *gadget) | ||
73 | { | 67 | { |
74 | struct nop_usb_xceiv *nop; | 68 | if (!otg) |
75 | |||
76 | if (!x) | ||
77 | return -ENODEV; | 69 | return -ENODEV; |
78 | 70 | ||
79 | nop = xceiv_to_nop(x); | ||
80 | |||
81 | if (!gadget) { | 71 | if (!gadget) { |
82 | nop->otg.gadget = NULL; | 72 | otg->gadget = NULL; |
83 | return -ENODEV; | 73 | return -ENODEV; |
84 | } | 74 | } |
85 | 75 | ||
86 | nop->otg.gadget = gadget; | 76 | otg->gadget = gadget; |
87 | nop->otg.state = OTG_STATE_B_IDLE; | 77 | otg->phy->state = OTG_STATE_B_IDLE; |
88 | return 0; | 78 | return 0; |
89 | } | 79 | } |
90 | 80 | ||
91 | static int nop_set_host(struct otg_transceiver *x, struct usb_bus *host) | 81 | static int nop_set_host(struct usb_otg *otg, struct usb_bus *host) |
92 | { | 82 | { |
93 | struct nop_usb_xceiv *nop; | 83 | if (!otg) |
94 | |||
95 | if (!x) | ||
96 | return -ENODEV; | 84 | return -ENODEV; |
97 | 85 | ||
98 | nop = xceiv_to_nop(x); | ||
99 | |||
100 | if (!host) { | 86 | if (!host) { |
101 | nop->otg.host = NULL; | 87 | otg->host = NULL; |
102 | return -ENODEV; | 88 | return -ENODEV; |
103 | } | 89 | } |
104 | 90 | ||
105 | nop->otg.host = host; | 91 | otg->host = host; |
106 | return 0; | 92 | return 0; |
107 | } | 93 | } |
108 | 94 | ||
@@ -115,15 +101,23 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | |||
115 | if (!nop) | 101 | if (!nop) |
116 | return -ENOMEM; | 102 | return -ENOMEM; |
117 | 103 | ||
104 | nop->phy.otg = kzalloc(sizeof *nop->phy.otg, GFP_KERNEL); | ||
105 | if (!nop->phy.otg) { | ||
106 | kfree(nop); | ||
107 | return -ENOMEM; | ||
108 | } | ||
109 | |||
118 | nop->dev = &pdev->dev; | 110 | nop->dev = &pdev->dev; |
119 | nop->otg.dev = nop->dev; | 111 | nop->phy.dev = nop->dev; |
120 | nop->otg.label = "nop-xceiv"; | 112 | nop->phy.label = "nop-xceiv"; |
121 | nop->otg.state = OTG_STATE_UNDEFINED; | 113 | nop->phy.set_suspend = nop_set_suspend; |
122 | nop->otg.set_host = nop_set_host; | 114 | nop->phy.state = OTG_STATE_UNDEFINED; |
123 | nop->otg.set_peripheral = nop_set_peripheral; | 115 | |
124 | nop->otg.set_suspend = nop_set_suspend; | 116 | nop->phy.otg->phy = &nop->phy; |
125 | 117 | nop->phy.otg->set_host = nop_set_host; | |
126 | err = otg_set_transceiver(&nop->otg); | 118 | nop->phy.otg->set_peripheral = nop_set_peripheral; |
119 | |||
120 | err = usb_set_transceiver(&nop->phy); | ||
127 | if (err) { | 121 | if (err) { |
128 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", | 122 | dev_err(&pdev->dev, "can't register transceiver, err: %d\n", |
129 | err); | 123 | err); |
@@ -132,10 +126,11 @@ static int __devinit nop_usb_xceiv_probe(struct platform_device *pdev) | |||
132 | 126 | ||
133 | platform_set_drvdata(pdev, nop); | 127 | platform_set_drvdata(pdev, nop); |
134 | 128 | ||
135 | ATOMIC_INIT_NOTIFIER_HEAD(&nop->otg.notifier); | 129 | ATOMIC_INIT_NOTIFIER_HEAD(&nop->phy.notifier); |
136 | 130 | ||
137 | return 0; | 131 | return 0; |
138 | exit: | 132 | exit: |
133 | kfree(nop->phy.otg); | ||
139 | kfree(nop); | 134 | kfree(nop); |
140 | return err; | 135 | return err; |
141 | } | 136 | } |
@@ -144,9 +139,10 @@ static int __devexit nop_usb_xceiv_remove(struct platform_device *pdev) | |||
144 | { | 139 | { |
145 | struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); | 140 | struct nop_usb_xceiv *nop = platform_get_drvdata(pdev); |
146 | 141 | ||
147 | otg_set_transceiver(NULL); | 142 | usb_set_transceiver(NULL); |
148 | 143 | ||
149 | platform_set_drvdata(pdev, NULL); | 144 | platform_set_drvdata(pdev, NULL); |
145 | kfree(nop->phy.otg); | ||
150 | kfree(nop); | 146 | kfree(nop); |
151 | 147 | ||
152 | return 0; | 148 | return 0; |
diff --git a/drivers/usb/otg/otg.c b/drivers/usb/otg/otg.c index 307c27bc51eb..801e597a1541 100644 --- a/drivers/usb/otg/otg.c +++ b/drivers/usb/otg/otg.c | |||
@@ -15,56 +15,56 @@ | |||
15 | 15 | ||
16 | #include <linux/usb/otg.h> | 16 | #include <linux/usb/otg.h> |
17 | 17 | ||
18 | static struct otg_transceiver *xceiv; | 18 | static struct usb_phy *phy; |
19 | 19 | ||
20 | /** | 20 | /** |
21 | * otg_get_transceiver - find the (single) OTG transceiver | 21 | * usb_get_transceiver - find the (single) USB transceiver |
22 | * | 22 | * |
23 | * Returns the transceiver driver, after getting a refcount to it; or | 23 | * Returns the transceiver driver, after getting a refcount to it; or |
24 | * null if there is no such transceiver. The caller is responsible for | 24 | * null if there is no such transceiver. The caller is responsible for |
25 | * calling otg_put_transceiver() to release that count. | 25 | * calling usb_put_transceiver() to release that count. |
26 | * | 26 | * |
27 | * For use by USB host and peripheral drivers. | 27 | * For use by USB host and peripheral drivers. |
28 | */ | 28 | */ |
29 | struct otg_transceiver *otg_get_transceiver(void) | 29 | struct usb_phy *usb_get_transceiver(void) |
30 | { | 30 | { |
31 | if (xceiv) | 31 | if (phy) |
32 | get_device(xceiv->dev); | 32 | get_device(phy->dev); |
33 | return xceiv; | 33 | return phy; |
34 | } | 34 | } |
35 | EXPORT_SYMBOL(otg_get_transceiver); | 35 | EXPORT_SYMBOL(usb_get_transceiver); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * otg_put_transceiver - release the (single) OTG transceiver | 38 | * usb_put_transceiver - release the (single) USB transceiver |
39 | * @x: the transceiver returned by otg_get_transceiver() | 39 | * @x: the transceiver returned by usb_get_transceiver() |
40 | * | 40 | * |
41 | * Releases a refcount the caller received from otg_get_transceiver(). | 41 | * Releases a refcount the caller received from usb_get_transceiver(). |
42 | * | 42 | * |
43 | * For use by USB host and peripheral drivers. | 43 | * For use by USB host and peripheral drivers. |
44 | */ | 44 | */ |
45 | void otg_put_transceiver(struct otg_transceiver *x) | 45 | void usb_put_transceiver(struct usb_phy *x) |
46 | { | 46 | { |
47 | if (x) | 47 | if (x) |
48 | put_device(x->dev); | 48 | put_device(x->dev); |
49 | } | 49 | } |
50 | EXPORT_SYMBOL(otg_put_transceiver); | 50 | EXPORT_SYMBOL(usb_put_transceiver); |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * otg_set_transceiver - declare the (single) OTG transceiver | 53 | * usb_set_transceiver - declare the (single) USB transceiver |
54 | * @x: the USB OTG transceiver to be used; or NULL | 54 | * @x: the USB transceiver to be used; or NULL |
55 | * | 55 | * |
56 | * This call is exclusively for use by transceiver drivers, which | 56 | * This call is exclusively for use by transceiver drivers, which |
57 | * coordinate the activities of drivers for host and peripheral | 57 | * coordinate the activities of drivers for host and peripheral |
58 | * controllers, and in some cases for VBUS current regulation. | 58 | * controllers, and in some cases for VBUS current regulation. |
59 | */ | 59 | */ |
60 | int otg_set_transceiver(struct otg_transceiver *x) | 60 | int usb_set_transceiver(struct usb_phy *x) |
61 | { | 61 | { |
62 | if (xceiv && x) | 62 | if (phy && x) |
63 | return -EBUSY; | 63 | return -EBUSY; |
64 | xceiv = x; | 64 | phy = x; |
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
67 | EXPORT_SYMBOL(otg_set_transceiver); | 67 | EXPORT_SYMBOL(usb_set_transceiver); |
68 | 68 | ||
69 | const char *otg_state_string(enum usb_otg_state state) | 69 | const char *otg_state_string(enum usb_otg_state state) |
70 | { | 70 | { |
diff --git a/drivers/usb/otg/otg_fsm.c b/drivers/usb/otg/otg_fsm.c index 09117387d2a4..ade131a8ae5e 100644 --- a/drivers/usb/otg/otg_fsm.c +++ b/drivers/usb/otg/otg_fsm.c | |||
@@ -117,10 +117,10 @@ void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) | |||
117 | int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | 117 | int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) |
118 | { | 118 | { |
119 | state_changed = 1; | 119 | state_changed = 1; |
120 | if (fsm->transceiver->state == new_state) | 120 | if (fsm->otg->phy->state == new_state) |
121 | return 0; | 121 | return 0; |
122 | VDBG("Set state: %s\n", otg_state_string(new_state)); | 122 | VDBG("Set state: %s\n", otg_state_string(new_state)); |
123 | otg_leave_state(fsm, fsm->transceiver->state); | 123 | otg_leave_state(fsm, fsm->otg->phy->state); |
124 | switch (new_state) { | 124 | switch (new_state) { |
125 | case OTG_STATE_B_IDLE: | 125 | case OTG_STATE_B_IDLE: |
126 | otg_drv_vbus(fsm, 0); | 126 | otg_drv_vbus(fsm, 0); |
@@ -155,8 +155,8 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
155 | otg_loc_conn(fsm, 0); | 155 | otg_loc_conn(fsm, 0); |
156 | otg_loc_sof(fsm, 1); | 156 | otg_loc_sof(fsm, 1); |
157 | otg_set_protocol(fsm, PROTO_HOST); | 157 | otg_set_protocol(fsm, PROTO_HOST); |
158 | usb_bus_start_enum(fsm->transceiver->host, | 158 | usb_bus_start_enum(fsm->otg->host, |
159 | fsm->transceiver->host->otg_port); | 159 | fsm->otg->host->otg_port); |
160 | break; | 160 | break; |
161 | case OTG_STATE_A_IDLE: | 161 | case OTG_STATE_A_IDLE: |
162 | otg_drv_vbus(fsm, 0); | 162 | otg_drv_vbus(fsm, 0); |
@@ -221,7 +221,7 @@ int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) | |||
221 | break; | 221 | break; |
222 | } | 222 | } |
223 | 223 | ||
224 | fsm->transceiver->state = new_state; | 224 | fsm->otg->phy->state = new_state; |
225 | return 0; | 225 | return 0; |
226 | } | 226 | } |
227 | 227 | ||
@@ -233,7 +233,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
233 | 233 | ||
234 | spin_lock_irqsave(&fsm->lock, flags); | 234 | spin_lock_irqsave(&fsm->lock, flags); |
235 | 235 | ||
236 | state = fsm->transceiver->state; | 236 | state = fsm->otg->phy->state; |
237 | state_changed = 0; | 237 | state_changed = 0; |
238 | /* State machine state change judgement */ | 238 | /* State machine state change judgement */ |
239 | 239 | ||
@@ -248,7 +248,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
248 | case OTG_STATE_B_IDLE: | 248 | case OTG_STATE_B_IDLE: |
249 | if (!fsm->id) | 249 | if (!fsm->id) |
250 | otg_set_state(fsm, OTG_STATE_A_IDLE); | 250 | otg_set_state(fsm, OTG_STATE_A_IDLE); |
251 | else if (fsm->b_sess_vld && fsm->transceiver->gadget) | 251 | else if (fsm->b_sess_vld && fsm->otg->gadget) |
252 | otg_set_state(fsm, OTG_STATE_B_PERIPHERAL); | 252 | otg_set_state(fsm, OTG_STATE_B_PERIPHERAL); |
253 | else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp) | 253 | else if (fsm->b_bus_req && fsm->b_sess_end && fsm->b_se0_srp) |
254 | otg_set_state(fsm, OTG_STATE_B_SRP_INIT); | 254 | otg_set_state(fsm, OTG_STATE_B_SRP_INIT); |
@@ -260,7 +260,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
260 | case OTG_STATE_B_PERIPHERAL: | 260 | case OTG_STATE_B_PERIPHERAL: |
261 | if (!fsm->id || !fsm->b_sess_vld) | 261 | if (!fsm->id || !fsm->b_sess_vld) |
262 | otg_set_state(fsm, OTG_STATE_B_IDLE); | 262 | otg_set_state(fsm, OTG_STATE_B_IDLE); |
263 | else if (fsm->b_bus_req && fsm->transceiver-> | 263 | else if (fsm->b_bus_req && fsm->otg-> |
264 | gadget->b_hnp_enable && fsm->a_bus_suspend) | 264 | gadget->b_hnp_enable && fsm->a_bus_suspend) |
265 | otg_set_state(fsm, OTG_STATE_B_WAIT_ACON); | 265 | otg_set_state(fsm, OTG_STATE_B_WAIT_ACON); |
266 | break; | 266 | break; |
@@ -302,7 +302,7 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
302 | break; | 302 | break; |
303 | case OTG_STATE_A_HOST: | 303 | case OTG_STATE_A_HOST: |
304 | if ((!fsm->a_bus_req || fsm->a_suspend_req) && | 304 | if ((!fsm->a_bus_req || fsm->a_suspend_req) && |
305 | fsm->transceiver->host->b_hnp_enable) | 305 | fsm->otg->host->b_hnp_enable) |
306 | otg_set_state(fsm, OTG_STATE_A_SUSPEND); | 306 | otg_set_state(fsm, OTG_STATE_A_SUSPEND); |
307 | else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop) | 307 | else if (fsm->id || !fsm->b_conn || fsm->a_bus_drop) |
308 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); | 308 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); |
@@ -310,9 +310,9 @@ int otg_statemachine(struct otg_fsm *fsm) | |||
310 | otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); | 310 | otg_set_state(fsm, OTG_STATE_A_VBUS_ERR); |
311 | break; | 311 | break; |
312 | case OTG_STATE_A_SUSPEND: | 312 | case OTG_STATE_A_SUSPEND: |
313 | if (!fsm->b_conn && fsm->transceiver->host->b_hnp_enable) | 313 | if (!fsm->b_conn && fsm->otg->host->b_hnp_enable) |
314 | otg_set_state(fsm, OTG_STATE_A_PERIPHERAL); | 314 | otg_set_state(fsm, OTG_STATE_A_PERIPHERAL); |
315 | else if (!fsm->b_conn && !fsm->transceiver->host->b_hnp_enable) | 315 | else if (!fsm->b_conn && !fsm->otg->host->b_hnp_enable) |
316 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); | 316 | otg_set_state(fsm, OTG_STATE_A_WAIT_BCON); |
317 | else if (fsm->a_bus_req || fsm->b_bus_resume) | 317 | else if (fsm->a_bus_req || fsm->b_bus_resume) |
318 | otg_set_state(fsm, OTG_STATE_A_HOST); | 318 | otg_set_state(fsm, OTG_STATE_A_HOST); |
diff --git a/drivers/usb/otg/otg_fsm.h b/drivers/usb/otg/otg_fsm.h index 0cecf1d593a0..c30a2e1d9e46 100644 --- a/drivers/usb/otg/otg_fsm.h +++ b/drivers/usb/otg/otg_fsm.h | |||
@@ -82,7 +82,7 @@ struct otg_fsm { | |||
82 | int loc_sof; | 82 | int loc_sof; |
83 | 83 | ||
84 | struct otg_fsm_ops *ops; | 84 | struct otg_fsm_ops *ops; |
85 | struct otg_transceiver *transceiver; | 85 | struct usb_otg *otg; |
86 | 86 | ||
87 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ | 87 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ |
88 | int protocol; | 88 | int protocol; |
diff --git a/drivers/usb/otg/twl4030-usb.c b/drivers/usb/otg/twl4030-usb.c index 14f66c358629..c4a86da858e2 100644 --- a/drivers/usb/otg/twl4030-usb.c +++ b/drivers/usb/otg/twl4030-usb.c | |||
@@ -144,7 +144,7 @@ | |||
144 | #define GPIO_USB_4PIN_ULPI_2430C (3 << 0) | 144 | #define GPIO_USB_4PIN_ULPI_2430C (3 << 0) |
145 | 145 | ||
146 | struct twl4030_usb { | 146 | struct twl4030_usb { |
147 | struct otg_transceiver otg; | 147 | struct usb_phy phy; |
148 | struct device *dev; | 148 | struct device *dev; |
149 | 149 | ||
150 | /* TWL4030 internal USB regulator supplies */ | 150 | /* TWL4030 internal USB regulator supplies */ |
@@ -166,7 +166,7 @@ struct twl4030_usb { | |||
166 | }; | 166 | }; |
167 | 167 | ||
168 | /* internal define on top of container_of */ | 168 | /* internal define on top of container_of */ |
169 | #define xceiv_to_twl(x) container_of((x), struct twl4030_usb, otg) | 169 | #define phy_to_twl(x) container_of((x), struct twl4030_usb, phy) |
170 | 170 | ||
171 | /*-------------------------------------------------------------------------*/ | 171 | /*-------------------------------------------------------------------------*/ |
172 | 172 | ||
@@ -246,10 +246,11 @@ twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits) | |||
246 | 246 | ||
247 | /*-------------------------------------------------------------------------*/ | 247 | /*-------------------------------------------------------------------------*/ |
248 | 248 | ||
249 | static enum usb_xceiv_events twl4030_usb_linkstat(struct twl4030_usb *twl) | 249 | static enum usb_phy_events twl4030_usb_linkstat(struct twl4030_usb *twl) |
250 | { | 250 | { |
251 | int status; | 251 | int status; |
252 | int linkstat = USB_EVENT_NONE; | 252 | int linkstat = USB_EVENT_NONE; |
253 | struct usb_otg *otg = twl->phy.otg; | ||
253 | 254 | ||
254 | twl->vbus_supplied = false; | 255 | twl->vbus_supplied = false; |
255 | 256 | ||
@@ -281,7 +282,7 @@ static enum usb_xceiv_events twl4030_usb_linkstat(struct twl4030_usb *twl) | |||
281 | dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n", | 282 | dev_dbg(twl->dev, "HW_CONDITIONS 0x%02x/%d; link %d\n", |
282 | status, status, linkstat); | 283 | status, status, linkstat); |
283 | 284 | ||
284 | twl->otg.last_event = linkstat; | 285 | twl->phy.last_event = linkstat; |
285 | 286 | ||
286 | /* REVISIT this assumes host and peripheral controllers | 287 | /* REVISIT this assumes host and peripheral controllers |
287 | * are registered, and that both are active... | 288 | * are registered, and that both are active... |
@@ -290,11 +291,11 @@ static enum usb_xceiv_events twl4030_usb_linkstat(struct twl4030_usb *twl) | |||
290 | spin_lock_irq(&twl->lock); | 291 | spin_lock_irq(&twl->lock); |
291 | twl->linkstat = linkstat; | 292 | twl->linkstat = linkstat; |
292 | if (linkstat == USB_EVENT_ID) { | 293 | if (linkstat == USB_EVENT_ID) { |
293 | twl->otg.default_a = true; | 294 | otg->default_a = true; |
294 | twl->otg.state = OTG_STATE_A_IDLE; | 295 | twl->phy.state = OTG_STATE_A_IDLE; |
295 | } else { | 296 | } else { |
296 | twl->otg.default_a = false; | 297 | otg->default_a = false; |
297 | twl->otg.state = OTG_STATE_B_IDLE; | 298 | twl->phy.state = OTG_STATE_B_IDLE; |
298 | } | 299 | } |
299 | spin_unlock_irq(&twl->lock); | 300 | spin_unlock_irq(&twl->lock); |
300 | 301 | ||
@@ -520,8 +521,8 @@ static irqreturn_t twl4030_usb_irq(int irq, void *_twl) | |||
520 | else | 521 | else |
521 | twl4030_phy_resume(twl); | 522 | twl4030_phy_resume(twl); |
522 | 523 | ||
523 | atomic_notifier_call_chain(&twl->otg.notifier, status, | 524 | atomic_notifier_call_chain(&twl->phy.notifier, status, |
524 | twl->otg.gadget); | 525 | twl->phy.otg->gadget); |
525 | } | 526 | } |
526 | sysfs_notify(&twl->dev->kobj, NULL, "vbus"); | 527 | sysfs_notify(&twl->dev->kobj, NULL, "vbus"); |
527 | 528 | ||
@@ -542,15 +543,15 @@ static void twl4030_usb_phy_init(struct twl4030_usb *twl) | |||
542 | twl->asleep = 0; | 543 | twl->asleep = 0; |
543 | } | 544 | } |
544 | 545 | ||
545 | atomic_notifier_call_chain(&twl->otg.notifier, status, | 546 | atomic_notifier_call_chain(&twl->phy.notifier, status, |
546 | twl->otg.gadget); | 547 | twl->phy.otg->gadget); |
547 | } | 548 | } |
548 | sysfs_notify(&twl->dev->kobj, NULL, "vbus"); | 549 | sysfs_notify(&twl->dev->kobj, NULL, "vbus"); |
549 | } | 550 | } |
550 | 551 | ||
551 | static int twl4030_set_suspend(struct otg_transceiver *x, int suspend) | 552 | static int twl4030_set_suspend(struct usb_phy *x, int suspend) |
552 | { | 553 | { |
553 | struct twl4030_usb *twl = xceiv_to_twl(x); | 554 | struct twl4030_usb *twl = phy_to_twl(x); |
554 | 555 | ||
555 | if (suspend) | 556 | if (suspend) |
556 | twl4030_phy_suspend(twl, 1); | 557 | twl4030_phy_suspend(twl, 1); |
@@ -560,33 +561,27 @@ static int twl4030_set_suspend(struct otg_transceiver *x, int suspend) | |||
560 | return 0; | 561 | return 0; |
561 | } | 562 | } |
562 | 563 | ||
563 | static int twl4030_set_peripheral(struct otg_transceiver *x, | 564 | static int twl4030_set_peripheral(struct usb_otg *otg, |
564 | struct usb_gadget *gadget) | 565 | struct usb_gadget *gadget) |
565 | { | 566 | { |
566 | struct twl4030_usb *twl; | 567 | if (!otg) |
567 | |||
568 | if (!x) | ||
569 | return -ENODEV; | 568 | return -ENODEV; |
570 | 569 | ||
571 | twl = xceiv_to_twl(x); | 570 | otg->gadget = gadget; |
572 | twl->otg.gadget = gadget; | ||
573 | if (!gadget) | 571 | if (!gadget) |
574 | twl->otg.state = OTG_STATE_UNDEFINED; | 572 | otg->phy->state = OTG_STATE_UNDEFINED; |
575 | 573 | ||
576 | return 0; | 574 | return 0; |
577 | } | 575 | } |
578 | 576 | ||
579 | static int twl4030_set_host(struct otg_transceiver *x, struct usb_bus *host) | 577 | static int twl4030_set_host(struct usb_otg *otg, struct usb_bus *host) |
580 | { | 578 | { |
581 | struct twl4030_usb *twl; | 579 | if (!otg) |
582 | |||
583 | if (!x) | ||
584 | return -ENODEV; | 580 | return -ENODEV; |
585 | 581 | ||
586 | twl = xceiv_to_twl(x); | 582 | otg->host = host; |
587 | twl->otg.host = host; | ||
588 | if (!host) | 583 | if (!host) |
589 | twl->otg.state = OTG_STATE_UNDEFINED; | 584 | otg->phy->state = OTG_STATE_UNDEFINED; |
590 | 585 | ||
591 | return 0; | 586 | return 0; |
592 | } | 587 | } |
@@ -596,6 +591,7 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
596 | struct twl4030_usb_data *pdata = pdev->dev.platform_data; | 591 | struct twl4030_usb_data *pdata = pdev->dev.platform_data; |
597 | struct twl4030_usb *twl; | 592 | struct twl4030_usb *twl; |
598 | int status, err; | 593 | int status, err; |
594 | struct usb_otg *otg; | ||
599 | 595 | ||
600 | if (!pdata) { | 596 | if (!pdata) { |
601 | dev_dbg(&pdev->dev, "platform_data not available\n"); | 597 | dev_dbg(&pdev->dev, "platform_data not available\n"); |
@@ -606,16 +602,26 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
606 | if (!twl) | 602 | if (!twl) |
607 | return -ENOMEM; | 603 | return -ENOMEM; |
608 | 604 | ||
605 | otg = kzalloc(sizeof *otg, GFP_KERNEL); | ||
606 | if (!otg) { | ||
607 | kfree(twl); | ||
608 | return -ENOMEM; | ||
609 | } | ||
610 | |||
609 | twl->dev = &pdev->dev; | 611 | twl->dev = &pdev->dev; |
610 | twl->irq = platform_get_irq(pdev, 0); | 612 | twl->irq = platform_get_irq(pdev, 0); |
611 | twl->otg.dev = twl->dev; | ||
612 | twl->otg.label = "twl4030"; | ||
613 | twl->otg.set_host = twl4030_set_host; | ||
614 | twl->otg.set_peripheral = twl4030_set_peripheral; | ||
615 | twl->otg.set_suspend = twl4030_set_suspend; | ||
616 | twl->usb_mode = pdata->usb_mode; | 613 | twl->usb_mode = pdata->usb_mode; |
617 | twl->vbus_supplied = false; | 614 | twl->vbus_supplied = false; |
618 | twl->asleep = 1; | 615 | twl->asleep = 1; |
616 | |||
617 | twl->phy.dev = twl->dev; | ||
618 | twl->phy.label = "twl4030"; | ||
619 | twl->phy.otg = otg; | ||
620 | twl->phy.set_suspend = twl4030_set_suspend; | ||
621 | |||
622 | otg->phy = &twl->phy; | ||
623 | otg->set_host = twl4030_set_host; | ||
624 | otg->set_peripheral = twl4030_set_peripheral; | ||
619 | 625 | ||
620 | /* init spinlock for workqueue */ | 626 | /* init spinlock for workqueue */ |
621 | spin_lock_init(&twl->lock); | 627 | spin_lock_init(&twl->lock); |
@@ -623,16 +629,17 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
623 | err = twl4030_usb_ldo_init(twl); | 629 | err = twl4030_usb_ldo_init(twl); |
624 | if (err) { | 630 | if (err) { |
625 | dev_err(&pdev->dev, "ldo init failed\n"); | 631 | dev_err(&pdev->dev, "ldo init failed\n"); |
632 | kfree(otg); | ||
626 | kfree(twl); | 633 | kfree(twl); |
627 | return err; | 634 | return err; |
628 | } | 635 | } |
629 | otg_set_transceiver(&twl->otg); | 636 | usb_set_transceiver(&twl->phy); |
630 | 637 | ||
631 | platform_set_drvdata(pdev, twl); | 638 | platform_set_drvdata(pdev, twl); |
632 | if (device_create_file(&pdev->dev, &dev_attr_vbus)) | 639 | if (device_create_file(&pdev->dev, &dev_attr_vbus)) |
633 | dev_warn(&pdev->dev, "could not create sysfs file\n"); | 640 | dev_warn(&pdev->dev, "could not create sysfs file\n"); |
634 | 641 | ||
635 | ATOMIC_INIT_NOTIFIER_HEAD(&twl->otg.notifier); | 642 | ATOMIC_INIT_NOTIFIER_HEAD(&twl->phy.notifier); |
636 | 643 | ||
637 | /* Our job is to use irqs and status from the power module | 644 | /* Our job is to use irqs and status from the power module |
638 | * to keep the transceiver disabled when nothing's connected. | 645 | * to keep the transceiver disabled when nothing's connected. |
@@ -649,6 +656,7 @@ static int __devinit twl4030_usb_probe(struct platform_device *pdev) | |||
649 | if (status < 0) { | 656 | if (status < 0) { |
650 | dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", | 657 | dev_dbg(&pdev->dev, "can't get IRQ %d, err %d\n", |
651 | twl->irq, status); | 658 | twl->irq, status); |
659 | kfree(otg); | ||
652 | kfree(twl); | 660 | kfree(twl); |
653 | return status; | 661 | return status; |
654 | } | 662 | } |
@@ -693,6 +701,7 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev) | |||
693 | regulator_put(twl->usb1v8); | 701 | regulator_put(twl->usb1v8); |
694 | regulator_put(twl->usb3v1); | 702 | regulator_put(twl->usb3v1); |
695 | 703 | ||
704 | kfree(twl->phy.otg); | ||
696 | kfree(twl); | 705 | kfree(twl); |
697 | 706 | ||
698 | return 0; | 707 | return 0; |
diff --git a/drivers/usb/otg/twl6030-usb.c b/drivers/usb/otg/twl6030-usb.c index ed2b26cfe814..e3fa387ca81e 100644 --- a/drivers/usb/otg/twl6030-usb.c +++ b/drivers/usb/otg/twl6030-usb.c | |||
@@ -87,7 +87,7 @@ | |||
87 | #define VBUS_DET BIT(2) | 87 | #define VBUS_DET BIT(2) |
88 | 88 | ||
89 | struct twl6030_usb { | 89 | struct twl6030_usb { |
90 | struct otg_transceiver otg; | 90 | struct usb_phy phy; |
91 | struct device *dev; | 91 | struct device *dev; |
92 | 92 | ||
93 | /* for vbus reporting with irqs disabled */ | 93 | /* for vbus reporting with irqs disabled */ |
@@ -107,7 +107,7 @@ struct twl6030_usb { | |||
107 | unsigned long features; | 107 | unsigned long features; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | #define xceiv_to_twl(x) container_of((x), struct twl6030_usb, otg) | 110 | #define phy_to_twl(x) container_of((x), struct twl6030_usb, phy) |
111 | 111 | ||
112 | /*-------------------------------------------------------------------------*/ | 112 | /*-------------------------------------------------------------------------*/ |
113 | 113 | ||
@@ -137,13 +137,13 @@ static inline u8 twl6030_readb(struct twl6030_usb *twl, u8 module, u8 address) | |||
137 | return ret; | 137 | return ret; |
138 | } | 138 | } |
139 | 139 | ||
140 | static int twl6030_phy_init(struct otg_transceiver *x) | 140 | static int twl6030_phy_init(struct usb_phy *x) |
141 | { | 141 | { |
142 | struct twl6030_usb *twl; | 142 | struct twl6030_usb *twl; |
143 | struct device *dev; | 143 | struct device *dev; |
144 | struct twl4030_usb_data *pdata; | 144 | struct twl4030_usb_data *pdata; |
145 | 145 | ||
146 | twl = xceiv_to_twl(x); | 146 | twl = phy_to_twl(x); |
147 | dev = twl->dev; | 147 | dev = twl->dev; |
148 | pdata = dev->platform_data; | 148 | pdata = dev->platform_data; |
149 | 149 | ||
@@ -155,21 +155,21 @@ static int twl6030_phy_init(struct otg_transceiver *x) | |||
155 | return 0; | 155 | return 0; |
156 | } | 156 | } |
157 | 157 | ||
158 | static void twl6030_phy_shutdown(struct otg_transceiver *x) | 158 | static void twl6030_phy_shutdown(struct usb_phy *x) |
159 | { | 159 | { |
160 | struct twl6030_usb *twl; | 160 | struct twl6030_usb *twl; |
161 | struct device *dev; | 161 | struct device *dev; |
162 | struct twl4030_usb_data *pdata; | 162 | struct twl4030_usb_data *pdata; |
163 | 163 | ||
164 | twl = xceiv_to_twl(x); | 164 | twl = phy_to_twl(x); |
165 | dev = twl->dev; | 165 | dev = twl->dev; |
166 | pdata = dev->platform_data; | 166 | pdata = dev->platform_data; |
167 | pdata->phy_power(twl->dev, 0, 0); | 167 | pdata->phy_power(twl->dev, 0, 0); |
168 | } | 168 | } |
169 | 169 | ||
170 | static int twl6030_phy_suspend(struct otg_transceiver *x, int suspend) | 170 | static int twl6030_phy_suspend(struct usb_phy *x, int suspend) |
171 | { | 171 | { |
172 | struct twl6030_usb *twl = xceiv_to_twl(x); | 172 | struct twl6030_usb *twl = phy_to_twl(x); |
173 | struct device *dev = twl->dev; | 173 | struct device *dev = twl->dev; |
174 | struct twl4030_usb_data *pdata = dev->platform_data; | 174 | struct twl4030_usb_data *pdata = dev->platform_data; |
175 | 175 | ||
@@ -178,9 +178,9 @@ static int twl6030_phy_suspend(struct otg_transceiver *x, int suspend) | |||
178 | return 0; | 178 | return 0; |
179 | } | 179 | } |
180 | 180 | ||
181 | static int twl6030_start_srp(struct otg_transceiver *x) | 181 | static int twl6030_start_srp(struct usb_otg *otg) |
182 | { | 182 | { |
183 | struct twl6030_usb *twl = xceiv_to_twl(x); | 183 | struct twl6030_usb *twl = phy_to_twl(otg->phy); |
184 | 184 | ||
185 | twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); | 185 | twl6030_writeb(twl, TWL_MODULE_USB, 0x24, USB_VBUS_CTRL_SET); |
186 | twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); | 186 | twl6030_writeb(twl, TWL_MODULE_USB, 0x84, USB_VBUS_CTRL_SET); |
@@ -256,6 +256,7 @@ static DEVICE_ATTR(vbus, 0444, twl6030_usb_vbus_show, NULL); | |||
256 | static irqreturn_t twl6030_usb_irq(int irq, void *_twl) | 256 | static irqreturn_t twl6030_usb_irq(int irq, void *_twl) |
257 | { | 257 | { |
258 | struct twl6030_usb *twl = _twl; | 258 | struct twl6030_usb *twl = _twl; |
259 | struct usb_otg *otg = twl->phy.otg; | ||
259 | int status; | 260 | int status; |
260 | u8 vbus_state, hw_state; | 261 | u8 vbus_state, hw_state; |
261 | 262 | ||
@@ -268,18 +269,18 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl) | |||
268 | regulator_enable(twl->usb3v3); | 269 | regulator_enable(twl->usb3v3); |
269 | twl->asleep = 1; | 270 | twl->asleep = 1; |
270 | status = USB_EVENT_VBUS; | 271 | status = USB_EVENT_VBUS; |
271 | twl->otg.default_a = false; | 272 | otg->default_a = false; |
272 | twl->otg.state = OTG_STATE_B_IDLE; | 273 | twl->phy.state = OTG_STATE_B_IDLE; |
273 | twl->linkstat = status; | 274 | twl->linkstat = status; |
274 | twl->otg.last_event = status; | 275 | twl->phy.last_event = status; |
275 | atomic_notifier_call_chain(&twl->otg.notifier, | 276 | atomic_notifier_call_chain(&twl->phy.notifier, |
276 | status, twl->otg.gadget); | 277 | status, otg->gadget); |
277 | } else { | 278 | } else { |
278 | status = USB_EVENT_NONE; | 279 | status = USB_EVENT_NONE; |
279 | twl->linkstat = status; | 280 | twl->linkstat = status; |
280 | twl->otg.last_event = status; | 281 | twl->phy.last_event = status; |
281 | atomic_notifier_call_chain(&twl->otg.notifier, | 282 | atomic_notifier_call_chain(&twl->phy.notifier, |
282 | status, twl->otg.gadget); | 283 | status, otg->gadget); |
283 | if (twl->asleep) { | 284 | if (twl->asleep) { |
284 | regulator_disable(twl->usb3v3); | 285 | regulator_disable(twl->usb3v3); |
285 | twl->asleep = 0; | 286 | twl->asleep = 0; |
@@ -294,6 +295,7 @@ static irqreturn_t twl6030_usb_irq(int irq, void *_twl) | |||
294 | static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl) | 295 | static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl) |
295 | { | 296 | { |
296 | struct twl6030_usb *twl = _twl; | 297 | struct twl6030_usb *twl = _twl; |
298 | struct usb_otg *otg = twl->phy.otg; | ||
297 | int status = USB_EVENT_NONE; | 299 | int status = USB_EVENT_NONE; |
298 | u8 hw_state; | 300 | u8 hw_state; |
299 | 301 | ||
@@ -307,12 +309,12 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl) | |||
307 | twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, | 309 | twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, |
308 | 0x10); | 310 | 0x10); |
309 | status = USB_EVENT_ID; | 311 | status = USB_EVENT_ID; |
310 | twl->otg.default_a = true; | 312 | otg->default_a = true; |
311 | twl->otg.state = OTG_STATE_A_IDLE; | 313 | twl->phy.state = OTG_STATE_A_IDLE; |
312 | twl->linkstat = status; | 314 | twl->linkstat = status; |
313 | twl->otg.last_event = status; | 315 | twl->phy.last_event = status; |
314 | atomic_notifier_call_chain(&twl->otg.notifier, status, | 316 | atomic_notifier_call_chain(&twl->phy.notifier, status, |
315 | twl->otg.gadget); | 317 | otg->gadget); |
316 | } else { | 318 | } else { |
317 | twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, | 319 | twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_CLR, |
318 | 0x10); | 320 | 0x10); |
@@ -324,25 +326,22 @@ static irqreturn_t twl6030_usbotg_irq(int irq, void *_twl) | |||
324 | return IRQ_HANDLED; | 326 | return IRQ_HANDLED; |
325 | } | 327 | } |
326 | 328 | ||
327 | static int twl6030_set_peripheral(struct otg_transceiver *x, | 329 | static int twl6030_set_peripheral(struct usb_otg *otg, |
328 | struct usb_gadget *gadget) | 330 | struct usb_gadget *gadget) |
329 | { | 331 | { |
330 | struct twl6030_usb *twl; | 332 | if (!otg) |
331 | |||
332 | if (!x) | ||
333 | return -ENODEV; | 333 | return -ENODEV; |
334 | 334 | ||
335 | twl = xceiv_to_twl(x); | 335 | otg->gadget = gadget; |
336 | twl->otg.gadget = gadget; | ||
337 | if (!gadget) | 336 | if (!gadget) |
338 | twl->otg.state = OTG_STATE_UNDEFINED; | 337 | otg->phy->state = OTG_STATE_UNDEFINED; |
339 | 338 | ||
340 | return 0; | 339 | return 0; |
341 | } | 340 | } |
342 | 341 | ||
343 | static int twl6030_enable_irq(struct otg_transceiver *x) | 342 | static int twl6030_enable_irq(struct usb_phy *x) |
344 | { | 343 | { |
345 | struct twl6030_usb *twl = xceiv_to_twl(x); | 344 | struct twl6030_usb *twl = phy_to_twl(x); |
346 | 345 | ||
347 | twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, 0x1); | 346 | twl6030_writeb(twl, TWL_MODULE_USB, USB_ID_INT_EN_HI_SET, 0x1); |
348 | twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); | 347 | twl6030_interrupt_unmask(0x05, REG_INT_MSK_LINE_C); |
@@ -376,9 +375,9 @@ static void otg_set_vbus_work(struct work_struct *data) | |||
376 | CHARGERUSB_CTRL1); | 375 | CHARGERUSB_CTRL1); |
377 | } | 376 | } |
378 | 377 | ||
379 | static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled) | 378 | static int twl6030_set_vbus(struct usb_otg *otg, bool enabled) |
380 | { | 379 | { |
381 | struct twl6030_usb *twl = xceiv_to_twl(x); | 380 | struct twl6030_usb *twl = phy_to_twl(otg->phy); |
382 | 381 | ||
383 | twl->vbus_enable = enabled; | 382 | twl->vbus_enable = enabled; |
384 | schedule_work(&twl->set_vbus_work); | 383 | schedule_work(&twl->set_vbus_work); |
@@ -386,17 +385,14 @@ static int twl6030_set_vbus(struct otg_transceiver *x, bool enabled) | |||
386 | return 0; | 385 | return 0; |
387 | } | 386 | } |
388 | 387 | ||
389 | static int twl6030_set_host(struct otg_transceiver *x, struct usb_bus *host) | 388 | static int twl6030_set_host(struct usb_otg *otg, struct usb_bus *host) |
390 | { | 389 | { |
391 | struct twl6030_usb *twl; | 390 | if (!otg) |
392 | |||
393 | if (!x) | ||
394 | return -ENODEV; | 391 | return -ENODEV; |
395 | 392 | ||
396 | twl = xceiv_to_twl(x); | 393 | otg->host = host; |
397 | twl->otg.host = host; | ||
398 | if (!host) | 394 | if (!host) |
399 | twl->otg.state = OTG_STATE_UNDEFINED; | 395 | otg->phy->state = OTG_STATE_UNDEFINED; |
400 | return 0; | 396 | return 0; |
401 | } | 397 | } |
402 | 398 | ||
@@ -405,6 +401,7 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
405 | struct twl6030_usb *twl; | 401 | struct twl6030_usb *twl; |
406 | int status, err; | 402 | int status, err; |
407 | struct twl4030_usb_data *pdata; | 403 | struct twl4030_usb_data *pdata; |
404 | struct usb_otg *otg; | ||
408 | struct device *dev = &pdev->dev; | 405 | struct device *dev = &pdev->dev; |
409 | pdata = dev->platform_data; | 406 | pdata = dev->platform_data; |
410 | 407 | ||
@@ -412,19 +409,29 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
412 | if (!twl) | 409 | if (!twl) |
413 | return -ENOMEM; | 410 | return -ENOMEM; |
414 | 411 | ||
412 | otg = kzalloc(sizeof *otg, GFP_KERNEL); | ||
413 | if (!otg) { | ||
414 | kfree(twl); | ||
415 | return -ENOMEM; | ||
416 | } | ||
417 | |||
415 | twl->dev = &pdev->dev; | 418 | twl->dev = &pdev->dev; |
416 | twl->irq1 = platform_get_irq(pdev, 0); | 419 | twl->irq1 = platform_get_irq(pdev, 0); |
417 | twl->irq2 = platform_get_irq(pdev, 1); | 420 | twl->irq2 = platform_get_irq(pdev, 1); |
418 | twl->features = pdata->features; | 421 | twl->features = pdata->features; |
419 | twl->otg.dev = twl->dev; | 422 | |
420 | twl->otg.label = "twl6030"; | 423 | twl->phy.dev = twl->dev; |
421 | twl->otg.set_host = twl6030_set_host; | 424 | twl->phy.label = "twl6030"; |
422 | twl->otg.set_peripheral = twl6030_set_peripheral; | 425 | twl->phy.otg = otg; |
423 | twl->otg.set_vbus = twl6030_set_vbus; | 426 | twl->phy.init = twl6030_phy_init; |
424 | twl->otg.init = twl6030_phy_init; | 427 | twl->phy.shutdown = twl6030_phy_shutdown; |
425 | twl->otg.shutdown = twl6030_phy_shutdown; | 428 | twl->phy.set_suspend = twl6030_phy_suspend; |
426 | twl->otg.set_suspend = twl6030_phy_suspend; | 429 | |
427 | twl->otg.start_srp = twl6030_start_srp; | 430 | otg->phy = &twl->phy; |
431 | otg->set_host = twl6030_set_host; | ||
432 | otg->set_peripheral = twl6030_set_peripheral; | ||
433 | otg->set_vbus = twl6030_set_vbus; | ||
434 | otg->start_srp = twl6030_start_srp; | ||
428 | 435 | ||
429 | /* init spinlock for workqueue */ | 436 | /* init spinlock for workqueue */ |
430 | spin_lock_init(&twl->lock); | 437 | spin_lock_init(&twl->lock); |
@@ -432,16 +439,17 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
432 | err = twl6030_usb_ldo_init(twl); | 439 | err = twl6030_usb_ldo_init(twl); |
433 | if (err) { | 440 | if (err) { |
434 | dev_err(&pdev->dev, "ldo init failed\n"); | 441 | dev_err(&pdev->dev, "ldo init failed\n"); |
442 | kfree(otg); | ||
435 | kfree(twl); | 443 | kfree(twl); |
436 | return err; | 444 | return err; |
437 | } | 445 | } |
438 | otg_set_transceiver(&twl->otg); | 446 | usb_set_transceiver(&twl->phy); |
439 | 447 | ||
440 | platform_set_drvdata(pdev, twl); | 448 | platform_set_drvdata(pdev, twl); |
441 | if (device_create_file(&pdev->dev, &dev_attr_vbus)) | 449 | if (device_create_file(&pdev->dev, &dev_attr_vbus)) |
442 | dev_warn(&pdev->dev, "could not create sysfs file\n"); | 450 | dev_warn(&pdev->dev, "could not create sysfs file\n"); |
443 | 451 | ||
444 | ATOMIC_INIT_NOTIFIER_HEAD(&twl->otg.notifier); | 452 | ATOMIC_INIT_NOTIFIER_HEAD(&twl->phy.notifier); |
445 | 453 | ||
446 | INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); | 454 | INIT_WORK(&twl->set_vbus_work, otg_set_vbus_work); |
447 | 455 | ||
@@ -453,6 +461,7 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
453 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", | 461 | dev_err(&pdev->dev, "can't get IRQ %d, err %d\n", |
454 | twl->irq1, status); | 462 | twl->irq1, status); |
455 | device_remove_file(twl->dev, &dev_attr_vbus); | 463 | device_remove_file(twl->dev, &dev_attr_vbus); |
464 | kfree(otg); | ||
456 | kfree(twl); | 465 | kfree(twl); |
457 | return status; | 466 | return status; |
458 | } | 467 | } |
@@ -465,14 +474,15 @@ static int __devinit twl6030_usb_probe(struct platform_device *pdev) | |||
465 | twl->irq2, status); | 474 | twl->irq2, status); |
466 | free_irq(twl->irq1, twl); | 475 | free_irq(twl->irq1, twl); |
467 | device_remove_file(twl->dev, &dev_attr_vbus); | 476 | device_remove_file(twl->dev, &dev_attr_vbus); |
477 | kfree(otg); | ||
468 | kfree(twl); | 478 | kfree(twl); |
469 | return status; | 479 | return status; |
470 | } | 480 | } |
471 | 481 | ||
472 | twl->asleep = 0; | 482 | twl->asleep = 0; |
473 | pdata->phy_init(dev); | 483 | pdata->phy_init(dev); |
474 | twl6030_phy_suspend(&twl->otg, 0); | 484 | twl6030_phy_suspend(&twl->phy, 0); |
475 | twl6030_enable_irq(&twl->otg); | 485 | twl6030_enable_irq(&twl->phy); |
476 | dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); | 486 | dev_info(&pdev->dev, "Initialized TWL6030 USB module\n"); |
477 | 487 | ||
478 | return 0; | 488 | return 0; |
@@ -496,6 +506,7 @@ static int __exit twl6030_usb_remove(struct platform_device *pdev) | |||
496 | pdata->phy_exit(twl->dev); | 506 | pdata->phy_exit(twl->dev); |
497 | device_remove_file(twl->dev, &dev_attr_vbus); | 507 | device_remove_file(twl->dev, &dev_attr_vbus); |
498 | cancel_work_sync(&twl->set_vbus_work); | 508 | cancel_work_sync(&twl->set_vbus_work); |
509 | kfree(twl->phy.otg); | ||
499 | kfree(twl); | 510 | kfree(twl); |
500 | 511 | ||
501 | return 0; | 512 | return 0; |
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index 0b0466728fdc..217339dd7a90 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c | |||
@@ -49,31 +49,31 @@ static struct ulpi_info ulpi_ids[] = { | |||
49 | ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"), | 49 | ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB331x"), |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static int ulpi_set_otg_flags(struct otg_transceiver *otg) | 52 | static int ulpi_set_otg_flags(struct usb_phy *phy) |
53 | { | 53 | { |
54 | unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN | | 54 | unsigned int flags = ULPI_OTG_CTRL_DP_PULLDOWN | |
55 | ULPI_OTG_CTRL_DM_PULLDOWN; | 55 | ULPI_OTG_CTRL_DM_PULLDOWN; |
56 | 56 | ||
57 | if (otg->flags & ULPI_OTG_ID_PULLUP) | 57 | if (phy->flags & ULPI_OTG_ID_PULLUP) |
58 | flags |= ULPI_OTG_CTRL_ID_PULLUP; | 58 | flags |= ULPI_OTG_CTRL_ID_PULLUP; |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * ULPI Specification rev.1.1 default | 61 | * ULPI Specification rev.1.1 default |
62 | * for Dp/DmPulldown is enabled. | 62 | * for Dp/DmPulldown is enabled. |
63 | */ | 63 | */ |
64 | if (otg->flags & ULPI_OTG_DP_PULLDOWN_DIS) | 64 | if (phy->flags & ULPI_OTG_DP_PULLDOWN_DIS) |
65 | flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN; | 65 | flags &= ~ULPI_OTG_CTRL_DP_PULLDOWN; |
66 | 66 | ||
67 | if (otg->flags & ULPI_OTG_DM_PULLDOWN_DIS) | 67 | if (phy->flags & ULPI_OTG_DM_PULLDOWN_DIS) |
68 | flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN; | 68 | flags &= ~ULPI_OTG_CTRL_DM_PULLDOWN; |
69 | 69 | ||
70 | if (otg->flags & ULPI_OTG_EXTVBUSIND) | 70 | if (phy->flags & ULPI_OTG_EXTVBUSIND) |
71 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; | 71 | flags |= ULPI_OTG_CTRL_EXTVBUSIND; |
72 | 72 | ||
73 | return otg_io_write(otg, flags, ULPI_OTG_CTRL); | 73 | return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); |
74 | } | 74 | } |
75 | 75 | ||
76 | static int ulpi_set_fc_flags(struct otg_transceiver *otg) | 76 | static int ulpi_set_fc_flags(struct usb_phy *phy) |
77 | { | 77 | { |
78 | unsigned int flags = 0; | 78 | unsigned int flags = 0; |
79 | 79 | ||
@@ -81,27 +81,27 @@ static int ulpi_set_fc_flags(struct otg_transceiver *otg) | |||
81 | * ULPI Specification rev.1.1 default | 81 | * ULPI Specification rev.1.1 default |
82 | * for XcvrSelect is Full Speed. | 82 | * for XcvrSelect is Full Speed. |
83 | */ | 83 | */ |
84 | if (otg->flags & ULPI_FC_HS) | 84 | if (phy->flags & ULPI_FC_HS) |
85 | flags |= ULPI_FUNC_CTRL_HIGH_SPEED; | 85 | flags |= ULPI_FUNC_CTRL_HIGH_SPEED; |
86 | else if (otg->flags & ULPI_FC_LS) | 86 | else if (phy->flags & ULPI_FC_LS) |
87 | flags |= ULPI_FUNC_CTRL_LOW_SPEED; | 87 | flags |= ULPI_FUNC_CTRL_LOW_SPEED; |
88 | else if (otg->flags & ULPI_FC_FS4LS) | 88 | else if (phy->flags & ULPI_FC_FS4LS) |
89 | flags |= ULPI_FUNC_CTRL_FS4LS; | 89 | flags |= ULPI_FUNC_CTRL_FS4LS; |
90 | else | 90 | else |
91 | flags |= ULPI_FUNC_CTRL_FULL_SPEED; | 91 | flags |= ULPI_FUNC_CTRL_FULL_SPEED; |
92 | 92 | ||
93 | if (otg->flags & ULPI_FC_TERMSEL) | 93 | if (phy->flags & ULPI_FC_TERMSEL) |
94 | flags |= ULPI_FUNC_CTRL_TERMSELECT; | 94 | flags |= ULPI_FUNC_CTRL_TERMSELECT; |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * ULPI Specification rev.1.1 default | 97 | * ULPI Specification rev.1.1 default |
98 | * for OpMode is Normal Operation. | 98 | * for OpMode is Normal Operation. |
99 | */ | 99 | */ |
100 | if (otg->flags & ULPI_FC_OP_NODRV) | 100 | if (phy->flags & ULPI_FC_OP_NODRV) |
101 | flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; | 101 | flags |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING; |
102 | else if (otg->flags & ULPI_FC_OP_DIS_NRZI) | 102 | else if (phy->flags & ULPI_FC_OP_DIS_NRZI) |
103 | flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI; | 103 | flags |= ULPI_FUNC_CTRL_OPMODE_DISABLE_NRZI; |
104 | else if (otg->flags & ULPI_FC_OP_NSYNC_NEOP) | 104 | else if (phy->flags & ULPI_FC_OP_NSYNC_NEOP) |
105 | flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP; | 105 | flags |= ULPI_FUNC_CTRL_OPMODE_NOSYNC_NOEOP; |
106 | else | 106 | else |
107 | flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL; | 107 | flags |= ULPI_FUNC_CTRL_OPMODE_NORMAL; |
@@ -112,54 +112,54 @@ static int ulpi_set_fc_flags(struct otg_transceiver *otg) | |||
112 | */ | 112 | */ |
113 | flags |= ULPI_FUNC_CTRL_SUSPENDM; | 113 | flags |= ULPI_FUNC_CTRL_SUSPENDM; |
114 | 114 | ||
115 | return otg_io_write(otg, flags, ULPI_FUNC_CTRL); | 115 | return usb_phy_io_write(phy, flags, ULPI_FUNC_CTRL); |
116 | } | 116 | } |
117 | 117 | ||
118 | static int ulpi_set_ic_flags(struct otg_transceiver *otg) | 118 | static int ulpi_set_ic_flags(struct usb_phy *phy) |
119 | { | 119 | { |
120 | unsigned int flags = 0; | 120 | unsigned int flags = 0; |
121 | 121 | ||
122 | if (otg->flags & ULPI_IC_AUTORESUME) | 122 | if (phy->flags & ULPI_IC_AUTORESUME) |
123 | flags |= ULPI_IFC_CTRL_AUTORESUME; | 123 | flags |= ULPI_IFC_CTRL_AUTORESUME; |
124 | 124 | ||
125 | if (otg->flags & ULPI_IC_EXTVBUS_INDINV) | 125 | if (phy->flags & ULPI_IC_EXTVBUS_INDINV) |
126 | flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS; | 126 | flags |= ULPI_IFC_CTRL_EXTERNAL_VBUS; |
127 | 127 | ||
128 | if (otg->flags & ULPI_IC_IND_PASSTHRU) | 128 | if (phy->flags & ULPI_IC_IND_PASSTHRU) |
129 | flags |= ULPI_IFC_CTRL_PASSTHRU; | 129 | flags |= ULPI_IFC_CTRL_PASSTHRU; |
130 | 130 | ||
131 | if (otg->flags & ULPI_IC_PROTECT_DIS) | 131 | if (phy->flags & ULPI_IC_PROTECT_DIS) |
132 | flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE; | 132 | flags |= ULPI_IFC_CTRL_PROTECT_IFC_DISABLE; |
133 | 133 | ||
134 | return otg_io_write(otg, flags, ULPI_IFC_CTRL); | 134 | return usb_phy_io_write(phy, flags, ULPI_IFC_CTRL); |
135 | } | 135 | } |
136 | 136 | ||
137 | static int ulpi_set_flags(struct otg_transceiver *otg) | 137 | static int ulpi_set_flags(struct usb_phy *phy) |
138 | { | 138 | { |
139 | int ret; | 139 | int ret; |
140 | 140 | ||
141 | ret = ulpi_set_otg_flags(otg); | 141 | ret = ulpi_set_otg_flags(phy); |
142 | if (ret) | 142 | if (ret) |
143 | return ret; | 143 | return ret; |
144 | 144 | ||
145 | ret = ulpi_set_ic_flags(otg); | 145 | ret = ulpi_set_ic_flags(phy); |
146 | if (ret) | 146 | if (ret) |
147 | return ret; | 147 | return ret; |
148 | 148 | ||
149 | return ulpi_set_fc_flags(otg); | 149 | return ulpi_set_fc_flags(phy); |
150 | } | 150 | } |
151 | 151 | ||
152 | static int ulpi_check_integrity(struct otg_transceiver *otg) | 152 | static int ulpi_check_integrity(struct usb_phy *phy) |
153 | { | 153 | { |
154 | int ret, i; | 154 | int ret, i; |
155 | unsigned int val = 0x55; | 155 | unsigned int val = 0x55; |
156 | 156 | ||
157 | for (i = 0; i < 2; i++) { | 157 | for (i = 0; i < 2; i++) { |
158 | ret = otg_io_write(otg, val, ULPI_SCRATCH); | 158 | ret = usb_phy_io_write(phy, val, ULPI_SCRATCH); |
159 | if (ret < 0) | 159 | if (ret < 0) |
160 | return ret; | 160 | return ret; |
161 | 161 | ||
162 | ret = otg_io_read(otg, ULPI_SCRATCH); | 162 | ret = usb_phy_io_read(phy, ULPI_SCRATCH); |
163 | if (ret < 0) | 163 | if (ret < 0) |
164 | return ret; | 164 | return ret; |
165 | 165 | ||
@@ -175,13 +175,13 @@ static int ulpi_check_integrity(struct otg_transceiver *otg) | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | static int ulpi_init(struct otg_transceiver *otg) | 178 | static int ulpi_init(struct usb_phy *phy) |
179 | { | 179 | { |
180 | int i, vid, pid, ret; | 180 | int i, vid, pid, ret; |
181 | u32 ulpi_id = 0; | 181 | u32 ulpi_id = 0; |
182 | 182 | ||
183 | for (i = 0; i < 4; i++) { | 183 | for (i = 0; i < 4; i++) { |
184 | ret = otg_io_read(otg, ULPI_PRODUCT_ID_HIGH - i); | 184 | ret = usb_phy_io_read(phy, ULPI_PRODUCT_ID_HIGH - i); |
185 | if (ret < 0) | 185 | if (ret < 0) |
186 | return ret; | 186 | return ret; |
187 | ulpi_id = (ulpi_id << 8) | ret; | 187 | ulpi_id = (ulpi_id << 8) | ret; |
@@ -199,16 +199,17 @@ static int ulpi_init(struct otg_transceiver *otg) | |||
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | ret = ulpi_check_integrity(otg); | 202 | ret = ulpi_check_integrity(phy); |
203 | if (ret) | 203 | if (ret) |
204 | return ret; | 204 | return ret; |
205 | 205 | ||
206 | return ulpi_set_flags(otg); | 206 | return ulpi_set_flags(phy); |
207 | } | 207 | } |
208 | 208 | ||
209 | static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) | 209 | static int ulpi_set_host(struct usb_otg *otg, struct usb_bus *host) |
210 | { | 210 | { |
211 | unsigned int flags = otg_io_read(otg, ULPI_IFC_CTRL); | 211 | struct usb_phy *phy = otg->phy; |
212 | unsigned int flags = usb_phy_io_read(phy, ULPI_IFC_CTRL); | ||
212 | 213 | ||
213 | if (!host) { | 214 | if (!host) { |
214 | otg->host = NULL; | 215 | otg->host = NULL; |
@@ -221,51 +222,62 @@ static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) | |||
221 | ULPI_IFC_CTRL_3_PIN_SERIAL_MODE | | 222 | ULPI_IFC_CTRL_3_PIN_SERIAL_MODE | |
222 | ULPI_IFC_CTRL_CARKITMODE); | 223 | ULPI_IFC_CTRL_CARKITMODE); |
223 | 224 | ||
224 | if (otg->flags & ULPI_IC_6PIN_SERIAL) | 225 | if (phy->flags & ULPI_IC_6PIN_SERIAL) |
225 | flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE; | 226 | flags |= ULPI_IFC_CTRL_6_PIN_SERIAL_MODE; |
226 | else if (otg->flags & ULPI_IC_3PIN_SERIAL) | 227 | else if (phy->flags & ULPI_IC_3PIN_SERIAL) |
227 | flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE; | 228 | flags |= ULPI_IFC_CTRL_3_PIN_SERIAL_MODE; |
228 | else if (otg->flags & ULPI_IC_CARKIT) | 229 | else if (phy->flags & ULPI_IC_CARKIT) |
229 | flags |= ULPI_IFC_CTRL_CARKITMODE; | 230 | flags |= ULPI_IFC_CTRL_CARKITMODE; |
230 | 231 | ||
231 | return otg_io_write(otg, flags, ULPI_IFC_CTRL); | 232 | return usb_phy_io_write(phy, flags, ULPI_IFC_CTRL); |
232 | } | 233 | } |
233 | 234 | ||
234 | static int ulpi_set_vbus(struct otg_transceiver *otg, bool on) | 235 | static int ulpi_set_vbus(struct usb_otg *otg, bool on) |
235 | { | 236 | { |
236 | unsigned int flags = otg_io_read(otg, ULPI_OTG_CTRL); | 237 | struct usb_phy *phy = otg->phy; |
238 | unsigned int flags = usb_phy_io_read(phy, ULPI_OTG_CTRL); | ||
237 | 239 | ||
238 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); | 240 | flags &= ~(ULPI_OTG_CTRL_DRVVBUS | ULPI_OTG_CTRL_DRVVBUS_EXT); |
239 | 241 | ||
240 | if (on) { | 242 | if (on) { |
241 | if (otg->flags & ULPI_OTG_DRVVBUS) | 243 | if (phy->flags & ULPI_OTG_DRVVBUS) |
242 | flags |= ULPI_OTG_CTRL_DRVVBUS; | 244 | flags |= ULPI_OTG_CTRL_DRVVBUS; |
243 | 245 | ||
244 | if (otg->flags & ULPI_OTG_DRVVBUS_EXT) | 246 | if (phy->flags & ULPI_OTG_DRVVBUS_EXT) |
245 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; | 247 | flags |= ULPI_OTG_CTRL_DRVVBUS_EXT; |
246 | } | 248 | } |
247 | 249 | ||
248 | return otg_io_write(otg, flags, ULPI_OTG_CTRL); | 250 | return usb_phy_io_write(phy, flags, ULPI_OTG_CTRL); |
249 | } | 251 | } |
250 | 252 | ||
251 | struct otg_transceiver * | 253 | struct usb_phy * |
252 | otg_ulpi_create(struct otg_io_access_ops *ops, | 254 | otg_ulpi_create(struct usb_phy_io_ops *ops, |
253 | unsigned int flags) | 255 | unsigned int flags) |
254 | { | 256 | { |
255 | struct otg_transceiver *otg; | 257 | struct usb_phy *phy; |
258 | struct usb_otg *otg; | ||
259 | |||
260 | phy = kzalloc(sizeof(*phy), GFP_KERNEL); | ||
261 | if (!phy) | ||
262 | return NULL; | ||
256 | 263 | ||
257 | otg = kzalloc(sizeof(*otg), GFP_KERNEL); | 264 | otg = kzalloc(sizeof(*otg), GFP_KERNEL); |
258 | if (!otg) | 265 | if (!otg) { |
266 | kfree(phy); | ||
259 | return NULL; | 267 | return NULL; |
268 | } | ||
269 | |||
270 | phy->label = "ULPI"; | ||
271 | phy->flags = flags; | ||
272 | phy->io_ops = ops; | ||
273 | phy->otg = otg; | ||
274 | phy->init = ulpi_init; | ||
260 | 275 | ||
261 | otg->label = "ULPI"; | 276 | otg->phy = phy; |
262 | otg->flags = flags; | ||
263 | otg->io_ops = ops; | ||
264 | otg->init = ulpi_init; | ||
265 | otg->set_host = ulpi_set_host; | 277 | otg->set_host = ulpi_set_host; |
266 | otg->set_vbus = ulpi_set_vbus; | 278 | otg->set_vbus = ulpi_set_vbus; |
267 | 279 | ||
268 | return otg; | 280 | return phy; |
269 | } | 281 | } |
270 | EXPORT_SYMBOL_GPL(otg_ulpi_create); | 282 | EXPORT_SYMBOL_GPL(otg_ulpi_create); |
271 | 283 | ||
diff --git a/drivers/usb/otg/ulpi_viewport.c b/drivers/usb/otg/ulpi_viewport.c index e9a37f90994f..c5ba7e5423fc 100644 --- a/drivers/usb/otg/ulpi_viewport.c +++ b/drivers/usb/otg/ulpi_viewport.c | |||
@@ -40,7 +40,7 @@ static int ulpi_viewport_wait(void __iomem *view, u32 mask) | |||
40 | return -ETIMEDOUT; | 40 | return -ETIMEDOUT; |
41 | } | 41 | } |
42 | 42 | ||
43 | static int ulpi_viewport_read(struct otg_transceiver *otg, u32 reg) | 43 | static int ulpi_viewport_read(struct usb_phy *otg, u32 reg) |
44 | { | 44 | { |
45 | int ret; | 45 | int ret; |
46 | void __iomem *view = otg->io_priv; | 46 | void __iomem *view = otg->io_priv; |
@@ -58,7 +58,7 @@ static int ulpi_viewport_read(struct otg_transceiver *otg, u32 reg) | |||
58 | return ULPI_VIEW_DATA_READ(readl(view)); | 58 | return ULPI_VIEW_DATA_READ(readl(view)); |
59 | } | 59 | } |
60 | 60 | ||
61 | static int ulpi_viewport_write(struct otg_transceiver *otg, u32 val, u32 reg) | 61 | static int ulpi_viewport_write(struct usb_phy *otg, u32 val, u32 reg) |
62 | { | 62 | { |
63 | int ret; | 63 | int ret; |
64 | void __iomem *view = otg->io_priv; | 64 | void __iomem *view = otg->io_priv; |
@@ -74,7 +74,7 @@ static int ulpi_viewport_write(struct otg_transceiver *otg, u32 val, u32 reg) | |||
74 | return ulpi_viewport_wait(view, ULPI_VIEW_RUN); | 74 | return ulpi_viewport_wait(view, ULPI_VIEW_RUN); |
75 | } | 75 | } |
76 | 76 | ||
77 | struct otg_io_access_ops ulpi_viewport_access_ops = { | 77 | struct usb_phy_io_ops ulpi_viewport_access_ops = { |
78 | .read = ulpi_viewport_read, | 78 | .read = ulpi_viewport_read, |
79 | .write = ulpi_viewport_write, | 79 | .write = ulpi_viewport_write, |
80 | }; | 80 | }; |
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c index e9a5b1d2615e..a165490bae48 100644 --- a/drivers/usb/renesas_usbhs/common.c +++ b/drivers/usb/renesas_usbhs/common.c | |||
@@ -413,8 +413,7 @@ static int usbhs_probe(struct platform_device *pdev) | |||
413 | struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; | 413 | struct renesas_usbhs_platform_info *info = pdev->dev.platform_data; |
414 | struct renesas_usbhs_driver_callback *dfunc; | 414 | struct renesas_usbhs_driver_callback *dfunc; |
415 | struct usbhs_priv *priv; | 415 | struct usbhs_priv *priv; |
416 | struct resource *res; | 416 | struct resource *res, *irq_res; |
417 | unsigned int irq; | ||
418 | int ret; | 417 | int ret; |
419 | 418 | ||
420 | /* check platform information */ | 419 | /* check platform information */ |
@@ -426,8 +425,8 @@ static int usbhs_probe(struct platform_device *pdev) | |||
426 | 425 | ||
427 | /* platform data */ | 426 | /* platform data */ |
428 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 427 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
429 | irq = platform_get_irq(pdev, 0); | 428 | irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
430 | if (!res || (int)irq <= 0) { | 429 | if (!res || !irq_res) { |
431 | dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n"); | 430 | dev_err(&pdev->dev, "Not enough Renesas USB platform resources.\n"); |
432 | return -ENODEV; | 431 | return -ENODEV; |
433 | } | 432 | } |
@@ -476,7 +475,9 @@ static int usbhs_probe(struct platform_device *pdev) | |||
476 | /* | 475 | /* |
477 | * priv settings | 476 | * priv settings |
478 | */ | 477 | */ |
479 | priv->irq = irq; | 478 | priv->irq = irq_res->start; |
479 | if (irq_res->flags & IORESOURCE_IRQ_SHAREABLE) | ||
480 | priv->irqflags = IRQF_SHARED; | ||
480 | priv->pdev = pdev; | 481 | priv->pdev = pdev; |
481 | INIT_DELAYED_WORK(&priv->notify_hotplug_work, usbhsc_notify_hotplug); | 482 | INIT_DELAYED_WORK(&priv->notify_hotplug_work, usbhsc_notify_hotplug); |
482 | spin_lock_init(usbhs_priv_to_lock(priv)); | 483 | spin_lock_init(usbhs_priv_to_lock(priv)); |
diff --git a/drivers/usb/renesas_usbhs/common.h b/drivers/usb/renesas_usbhs/common.h index d79b3e27db95..3f3ccd358753 100644 --- a/drivers/usb/renesas_usbhs/common.h +++ b/drivers/usb/renesas_usbhs/common.h | |||
@@ -242,6 +242,7 @@ struct usbhs_priv { | |||
242 | 242 | ||
243 | void __iomem *base; | 243 | void __iomem *base; |
244 | unsigned int irq; | 244 | unsigned int irq; |
245 | unsigned long irqflags; | ||
245 | 246 | ||
246 | struct renesas_usbhs_platform_callback pfunc; | 247 | struct renesas_usbhs_platform_callback pfunc; |
247 | struct renesas_usbhs_driver_param dparam; | 248 | struct renesas_usbhs_driver_param dparam; |
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index 72339bd6fcab..3648c82a17fe 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo)) | 23 | #define usbhsf_get_cfifo(p) (&((p)->fifo_info.cfifo)) |
24 | #define usbhsf_get_d0fifo(p) (&((p)->fifo_info.d0fifo)) | 24 | #define usbhsf_get_d0fifo(p) (&((p)->fifo_info.d0fifo)) |
25 | #define usbhsf_get_d1fifo(p) (&((p)->fifo_info.d1fifo)) | 25 | #define usbhsf_get_d1fifo(p) (&((p)->fifo_info.d1fifo)) |
26 | #define usbhsf_is_cfifo(p, f) (usbhsf_get_cfifo(p) == f) | ||
26 | 27 | ||
27 | #define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */ | 28 | #define usbhsf_fifo_is_busy(f) ((f)->pipe) /* see usbhs_pipe_select_fifo */ |
28 | 29 | ||
@@ -75,8 +76,7 @@ void usbhs_pkt_push(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt, | |||
75 | pipe->handler = &usbhsf_null_handler; | 76 | pipe->handler = &usbhsf_null_handler; |
76 | } | 77 | } |
77 | 78 | ||
78 | list_del_init(&pkt->node); | 79 | list_move_tail(&pkt->node, &pipe->list); |
79 | list_add_tail(&pkt->node, &pipe->list); | ||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * each pkt must hold own handler. | 82 | * each pkt must hold own handler. |
@@ -106,7 +106,7 @@ static struct usbhs_pkt *__usbhsf_pkt_get(struct usbhs_pipe *pipe) | |||
106 | if (list_empty(&pipe->list)) | 106 | if (list_empty(&pipe->list)) |
107 | return NULL; | 107 | return NULL; |
108 | 108 | ||
109 | return list_entry(pipe->list.next, struct usbhs_pkt, node); | 109 | return list_first_entry(&pipe->list, struct usbhs_pkt, node); |
110 | } | 110 | } |
111 | 111 | ||
112 | struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt) | 112 | struct usbhs_pkt *usbhs_pkt_pop(struct usbhs_pipe *pipe, struct usbhs_pkt *pkt) |
@@ -305,7 +305,10 @@ static int usbhsf_fifo_select(struct usbhs_pipe *pipe, | |||
305 | } | 305 | } |
306 | 306 | ||
307 | /* "base" will be used below */ | 307 | /* "base" will be used below */ |
308 | usbhs_write(priv, fifo->sel, base | MBW_32); | 308 | if (usbhs_get_dparam(priv, has_sudmac) && !usbhsf_is_cfifo(priv, fifo)) |
309 | usbhs_write(priv, fifo->sel, base); | ||
310 | else | ||
311 | usbhs_write(priv, fifo->sel, base | MBW_32); | ||
309 | 312 | ||
310 | /* check ISEL and CURPIPE value */ | 313 | /* check ISEL and CURPIPE value */ |
311 | while (timeout--) { | 314 | while (timeout--) { |
@@ -762,9 +765,9 @@ static int __usbhsf_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | |||
762 | } | 765 | } |
763 | 766 | ||
764 | static void usbhsf_dma_complete(void *arg); | 767 | static void usbhsf_dma_complete(void *arg); |
765 | static void usbhsf_dma_prepare_tasklet(unsigned long data) | 768 | static void xfer_work(struct work_struct *work) |
766 | { | 769 | { |
767 | struct usbhs_pkt *pkt = (struct usbhs_pkt *)data; | 770 | struct usbhs_pkt *pkt = container_of(work, struct usbhs_pkt, work); |
768 | struct usbhs_pipe *pipe = pkt->pipe; | 771 | struct usbhs_pipe *pipe = pkt->pipe; |
769 | struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe); | 772 | struct usbhs_fifo *fifo = usbhs_pipe_to_fifo(pipe); |
770 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); | 773 | struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); |
@@ -844,11 +847,8 @@ static int usbhsf_dma_prepare_push(struct usbhs_pkt *pkt, int *is_done) | |||
844 | 847 | ||
845 | pkt->trans = len; | 848 | pkt->trans = len; |
846 | 849 | ||
847 | tasklet_init(&fifo->tasklet, | 850 | INIT_WORK(&pkt->work, xfer_work); |
848 | usbhsf_dma_prepare_tasklet, | 851 | schedule_work(&pkt->work); |
849 | (unsigned long)pkt); | ||
850 | |||
851 | tasklet_schedule(&fifo->tasklet); | ||
852 | 852 | ||
853 | return 0; | 853 | return 0; |
854 | 854 | ||
@@ -938,11 +938,8 @@ static int usbhsf_dma_try_pop(struct usbhs_pkt *pkt, int *is_done) | |||
938 | 938 | ||
939 | pkt->trans = len; | 939 | pkt->trans = len; |
940 | 940 | ||
941 | tasklet_init(&fifo->tasklet, | 941 | INIT_WORK(&pkt->work, xfer_work); |
942 | usbhsf_dma_prepare_tasklet, | 942 | schedule_work(&pkt->work); |
943 | (unsigned long)pkt); | ||
944 | |||
945 | tasklet_schedule(&fifo->tasklet); | ||
946 | 943 | ||
947 | return 0; | 944 | return 0; |
948 | 945 | ||
diff --git a/drivers/usb/renesas_usbhs/fifo.h b/drivers/usb/renesas_usbhs/fifo.h index f68609c0f489..c31731a843d1 100644 --- a/drivers/usb/renesas_usbhs/fifo.h +++ b/drivers/usb/renesas_usbhs/fifo.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/interrupt.h> | 20 | #include <linux/interrupt.h> |
21 | #include <linux/sh_dma.h> | 21 | #include <linux/sh_dma.h> |
22 | #include <linux/workqueue.h> | ||
22 | #include <asm/dma.h> | 23 | #include <asm/dma.h> |
23 | #include "pipe.h" | 24 | #include "pipe.h" |
24 | 25 | ||
@@ -31,7 +32,6 @@ struct usbhs_fifo { | |||
31 | u32 ctr; /* xFIFOCTR */ | 32 | u32 ctr; /* xFIFOCTR */ |
32 | 33 | ||
33 | struct usbhs_pipe *pipe; | 34 | struct usbhs_pipe *pipe; |
34 | struct tasklet_struct tasklet; | ||
35 | 35 | ||
36 | struct dma_chan *tx_chan; | 36 | struct dma_chan *tx_chan; |
37 | struct dma_chan *rx_chan; | 37 | struct dma_chan *rx_chan; |
@@ -53,6 +53,7 @@ struct usbhs_pkt { | |||
53 | struct usbhs_pkt_handle *handler; | 53 | struct usbhs_pkt_handle *handler; |
54 | void (*done)(struct usbhs_priv *priv, | 54 | void (*done)(struct usbhs_priv *priv, |
55 | struct usbhs_pkt *pkt); | 55 | struct usbhs_pkt *pkt); |
56 | struct work_struct work; | ||
56 | dma_addr_t dma; | 57 | dma_addr_t dma; |
57 | void *buf; | 58 | void *buf; |
58 | int length; | 59 | int length; |
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c index 1b97fb12694b..0871e816df45 100644 --- a/drivers/usb/renesas_usbhs/mod.c +++ b/drivers/usb/renesas_usbhs/mod.c | |||
@@ -152,7 +152,7 @@ int usbhs_mod_probe(struct usbhs_priv *priv) | |||
152 | 152 | ||
153 | /* irq settings */ | 153 | /* irq settings */ |
154 | ret = request_irq(priv->irq, usbhs_interrupt, | 154 | ret = request_irq(priv->irq, usbhs_interrupt, |
155 | 0, 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"); |
158 | goto mod_init_gadget_err; | 158 | goto mod_init_gadget_err; |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 7542aa94a462..00bd2a5e0362 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
@@ -165,69 +165,32 @@ static void usbhsg_queue_push(struct usbhsg_uep *uep, | |||
165 | /* | 165 | /* |
166 | * dma map/unmap | 166 | * dma map/unmap |
167 | */ | 167 | */ |
168 | static int usbhsg_dma_map(struct device *dev, | 168 | static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, int map) |
169 | struct usbhs_pkt *pkt, | ||
170 | enum dma_data_direction dir) | ||
171 | { | ||
172 | struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt); | ||
173 | struct usb_request *req = &ureq->req; | ||
174 | |||
175 | if (pkt->dma != DMA_ADDR_INVALID) { | ||
176 | dev_err(dev, "dma is already mapped\n"); | ||
177 | return -EIO; | ||
178 | } | ||
179 | |||
180 | if (req->dma == DMA_ADDR_INVALID) { | ||
181 | pkt->dma = dma_map_single(dev, pkt->buf, pkt->length, dir); | ||
182 | } else { | ||
183 | dma_sync_single_for_device(dev, req->dma, req->length, dir); | ||
184 | pkt->dma = req->dma; | ||
185 | } | ||
186 | |||
187 | if (dma_mapping_error(dev, pkt->dma)) { | ||
188 | dev_err(dev, "dma mapping error %llx\n", (u64)pkt->dma); | ||
189 | return -EIO; | ||
190 | } | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static int usbhsg_dma_unmap(struct device *dev, | ||
196 | struct usbhs_pkt *pkt, | ||
197 | enum dma_data_direction dir) | ||
198 | { | 169 | { |
199 | struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt); | 170 | struct usbhsg_request *ureq = usbhsg_pkt_to_ureq(pkt); |
200 | struct usb_request *req = &ureq->req; | 171 | struct usb_request *req = &ureq->req; |
201 | |||
202 | if (pkt->dma == DMA_ADDR_INVALID) { | ||
203 | dev_err(dev, "dma is not mapped\n"); | ||
204 | return -EIO; | ||
205 | } | ||
206 | |||
207 | if (req->dma == DMA_ADDR_INVALID) | ||
208 | dma_unmap_single(dev, pkt->dma, pkt->length, dir); | ||
209 | else | ||
210 | dma_sync_single_for_cpu(dev, req->dma, req->length, dir); | ||
211 | |||
212 | pkt->dma = DMA_ADDR_INVALID; | ||
213 | |||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | static int usbhsg_dma_map_ctrl(struct usbhs_pkt *pkt, int map) | ||
218 | { | ||
219 | struct usbhs_pipe *pipe = pkt->pipe; | 172 | struct usbhs_pipe *pipe = pkt->pipe; |
220 | struct usbhsg_uep *uep = usbhsg_pipe_to_uep(pipe); | 173 | struct usbhsg_uep *uep = usbhsg_pipe_to_uep(pipe); |
221 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); | 174 | struct usbhsg_gpriv *gpriv = usbhsg_uep_to_gpriv(uep); |
222 | struct device *dev = usbhsg_gpriv_to_dev(gpriv); | ||
223 | enum dma_data_direction dir; | 175 | enum dma_data_direction dir; |
176 | int ret = 0; | ||
224 | 177 | ||
225 | dir = usbhs_pipe_is_dir_in(pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; | 178 | dir = usbhs_pipe_is_dir_host(pipe); |
226 | 179 | ||
227 | if (map) | 180 | if (map) { |
228 | return usbhsg_dma_map(dev, pkt, dir); | 181 | /* it can not use scatter/gather */ |
229 | else | 182 | WARN_ON(req->num_sgs); |
230 | return usbhsg_dma_unmap(dev, pkt, dir); | 183 | |
184 | ret = usb_gadget_map_request(&gpriv->gadget, req, dir); | ||
185 | if (ret < 0) | ||
186 | return ret; | ||
187 | |||
188 | pkt->dma = req->dma; | ||
189 | } else { | ||
190 | usb_gadget_unmap_request(&gpriv->gadget, req, dir); | ||
191 | } | ||
192 | |||
193 | return ret; | ||
231 | } | 194 | } |
232 | 195 | ||
233 | /* | 196 | /* |
@@ -657,8 +620,6 @@ static struct usb_request *usbhsg_ep_alloc_request(struct usb_ep *ep, | |||
657 | 620 | ||
658 | usbhs_pkt_init(usbhsg_ureq_to_pkt(ureq)); | 621 | usbhs_pkt_init(usbhsg_ureq_to_pkt(ureq)); |
659 | 622 | ||
660 | ureq->req.dma = DMA_ADDR_INVALID; | ||
661 | |||
662 | return &ureq->req; | 623 | return &ureq->req; |
663 | } | 624 | } |
664 | 625 | ||
@@ -941,6 +902,11 @@ static int usbhsg_stop(struct usbhs_priv *priv) | |||
941 | return usbhsg_try_stop(priv, USBHSG_STATUS_STARTED); | 902 | return usbhsg_try_stop(priv, USBHSG_STATUS_STARTED); |
942 | } | 903 | } |
943 | 904 | ||
905 | static void usbhs_mod_gadget_release(struct device *pdev) | ||
906 | { | ||
907 | /* do nothing */ | ||
908 | } | ||
909 | |||
944 | int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | 910 | int usbhs_mod_gadget_probe(struct usbhs_priv *priv) |
945 | { | 911 | { |
946 | struct usbhsg_gpriv *gpriv; | 912 | struct usbhsg_gpriv *gpriv; |
@@ -989,6 +955,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
989 | */ | 955 | */ |
990 | dev_set_name(&gpriv->gadget.dev, "gadget"); | 956 | dev_set_name(&gpriv->gadget.dev, "gadget"); |
991 | gpriv->gadget.dev.parent = dev; | 957 | gpriv->gadget.dev.parent = dev; |
958 | gpriv->gadget.dev.release = usbhs_mod_gadget_release; | ||
992 | gpriv->gadget.name = "renesas_usbhs_udc"; | 959 | gpriv->gadget.name = "renesas_usbhs_udc"; |
993 | gpriv->gadget.ops = &usbhsg_gadget_ops; | 960 | gpriv->gadget.ops = &usbhsg_gadget_ops; |
994 | gpriv->gadget.max_speed = USB_SPEED_HIGH; | 961 | gpriv->gadget.max_speed = USB_SPEED_HIGH; |
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig index 677f577c0243..7141d6599060 100644 --- a/drivers/usb/serial/Kconfig +++ b/drivers/usb/serial/Kconfig | |||
@@ -238,6 +238,15 @@ config USB_SERIAL_EDGEPORT_TI | |||
238 | To compile this driver as a module, choose M here: the | 238 | To compile this driver as a module, choose M here: the |
239 | module will be called io_ti. | 239 | module will be called io_ti. |
240 | 240 | ||
241 | config USB_SERIAL_F81232 | ||
242 | tristate "USB Fintek F81232 Single Port Serial Driver" | ||
243 | help | ||
244 | Say Y here if you want to use the Fintek F81232 single | ||
245 | port usb to serial adapter. | ||
246 | |||
247 | To compile this driver as a module, choose M here: the | ||
248 | module will be called f81232. | ||
249 | |||
241 | config USB_SERIAL_GARMIN | 250 | config USB_SERIAL_GARMIN |
242 | tristate "USB Garmin GPS driver" | 251 | tristate "USB Garmin GPS driver" |
243 | help | 252 | help |
@@ -417,6 +426,14 @@ config USB_SERIAL_MCT_U232 | |||
417 | To compile this driver as a module, choose M here: the | 426 | To compile this driver as a module, choose M here: the |
418 | module will be called mct_u232. | 427 | module will be called mct_u232. |
419 | 428 | ||
429 | config USB_SERIAL_METRO | ||
430 | tristate "USB Metrologic Instruments USB-POS Barcode Scanner Driver" | ||
431 | ---help--- | ||
432 | Say Y here if you want to use a USB POS Metrologic barcode scanner. | ||
433 | |||
434 | To compile this driver as a module, choose M here: the | ||
435 | module will be called metro-usb. | ||
436 | |||
420 | config USB_SERIAL_MOS7720 | 437 | config USB_SERIAL_MOS7720 |
421 | tristate "USB Moschip 7720 Serial Driver" | 438 | tristate "USB Moschip 7720 Serial Driver" |
422 | ---help--- | 439 | ---help--- |
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile index 9e536eefb32c..07f198ee0486 100644 --- a/drivers/usb/serial/Makefile +++ b/drivers/usb/serial/Makefile | |||
@@ -23,6 +23,7 @@ obj-$(CONFIG_USB_SERIAL_DIGI_ACCELEPORT) += digi_acceleport.o | |||
23 | obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o | 23 | obj-$(CONFIG_USB_SERIAL_EDGEPORT) += io_edgeport.o |
24 | obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o | 24 | obj-$(CONFIG_USB_SERIAL_EDGEPORT_TI) += io_ti.o |
25 | obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o | 25 | obj-$(CONFIG_USB_SERIAL_EMPEG) += empeg.o |
26 | obj-$(CONFIG_USB_SERIAL_F81232) += f81232.o | ||
26 | obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o | 27 | obj-$(CONFIG_USB_SERIAL_FTDI_SIO) += ftdi_sio.o |
27 | obj-$(CONFIG_USB_SERIAL_FUNSOFT) += funsoft.o | 28 | obj-$(CONFIG_USB_SERIAL_FUNSOFT) += funsoft.o |
28 | obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o | 29 | obj-$(CONFIG_USB_SERIAL_GARMIN) += garmin_gps.o |
@@ -36,6 +37,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o | |||
36 | obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o | 37 | obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o |
37 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o | 38 | obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o |
38 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o | 39 | obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o |
40 | obj-$(CONFIG_USB_SERIAL_METRO) += metro-usb.o | ||
39 | obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o | 41 | obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o |
40 | obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o | 42 | obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o |
41 | obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o | 43 | obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o |
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c index 123bf9155339..eec4fb9a35c1 100644 --- a/drivers/usb/serial/aircable.c +++ b/drivers/usb/serial/aircable.c | |||
@@ -175,7 +175,6 @@ static struct usb_driver aircable_driver = { | |||
175 | .probe = usb_serial_probe, | 175 | .probe = usb_serial_probe, |
176 | .disconnect = usb_serial_disconnect, | 176 | .disconnect = usb_serial_disconnect, |
177 | .id_table = id_table, | 177 | .id_table = id_table, |
178 | .no_dynamic_id = 1, | ||
179 | }; | 178 | }; |
180 | 179 | ||
181 | static struct usb_serial_driver aircable_device = { | 180 | static struct usb_serial_driver aircable_device = { |
@@ -183,7 +182,6 @@ static struct usb_serial_driver aircable_device = { | |||
183 | .owner = THIS_MODULE, | 182 | .owner = THIS_MODULE, |
184 | .name = "aircable", | 183 | .name = "aircable", |
185 | }, | 184 | }, |
186 | .usb_driver = &aircable_driver, | ||
187 | .id_table = id_table, | 185 | .id_table = id_table, |
188 | .num_ports = 1, | 186 | .num_ports = 1, |
189 | .bulk_out_size = HCI_COMPLETE_FRAME, | 187 | .bulk_out_size = HCI_COMPLETE_FRAME, |
@@ -194,36 +192,16 @@ static struct usb_serial_driver aircable_device = { | |||
194 | .unthrottle = usb_serial_generic_unthrottle, | 192 | .unthrottle = usb_serial_generic_unthrottle, |
195 | }; | 193 | }; |
196 | 194 | ||
197 | static int __init aircable_init(void) | 195 | static struct usb_serial_driver * const serial_drivers[] = { |
198 | { | 196 | &aircable_device, NULL |
199 | int retval; | 197 | }; |
200 | retval = usb_serial_register(&aircable_device); | ||
201 | if (retval) | ||
202 | goto failed_serial_register; | ||
203 | retval = usb_register(&aircable_driver); | ||
204 | if (retval) | ||
205 | goto failed_usb_register; | ||
206 | return 0; | ||
207 | |||
208 | failed_usb_register: | ||
209 | usb_serial_deregister(&aircable_device); | ||
210 | failed_serial_register: | ||
211 | return retval; | ||
212 | } | ||
213 | 198 | ||
214 | static void __exit aircable_exit(void) | 199 | module_usb_serial_driver(aircable_driver, serial_drivers); |
215 | { | ||
216 | usb_deregister(&aircable_driver); | ||
217 | usb_serial_deregister(&aircable_device); | ||
218 | } | ||
219 | 200 | ||
220 | MODULE_AUTHOR(DRIVER_AUTHOR); | 201 | MODULE_AUTHOR(DRIVER_AUTHOR); |
221 | MODULE_DESCRIPTION(DRIVER_DESC); | 202 | MODULE_DESCRIPTION(DRIVER_DESC); |
222 | MODULE_VERSION(DRIVER_VERSION); | 203 | MODULE_VERSION(DRIVER_VERSION); |
223 | MODULE_LICENSE("GPL"); | 204 | MODULE_LICENSE("GPL"); |
224 | 205 | ||
225 | module_init(aircable_init); | ||
226 | module_exit(aircable_exit); | ||
227 | |||
228 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 206 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
229 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 207 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 69328dcfd91a..f99f47100dd8 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c | |||
@@ -719,7 +719,6 @@ static struct usb_driver ark3116_driver = { | |||
719 | .probe = usb_serial_probe, | 719 | .probe = usb_serial_probe, |
720 | .disconnect = usb_serial_disconnect, | 720 | .disconnect = usb_serial_disconnect, |
721 | .id_table = id_table, | 721 | .id_table = id_table, |
722 | .no_dynamic_id = 1, | ||
723 | }; | 722 | }; |
724 | 723 | ||
725 | static struct usb_serial_driver ark3116_device = { | 724 | static struct usb_serial_driver ark3116_device = { |
@@ -728,7 +727,6 @@ static struct usb_serial_driver ark3116_device = { | |||
728 | .name = "ark3116", | 727 | .name = "ark3116", |
729 | }, | 728 | }, |
730 | .id_table = id_table, | 729 | .id_table = id_table, |
731 | .usb_driver = &ark3116_driver, | ||
732 | .num_ports = 1, | 730 | .num_ports = 1, |
733 | .attach = ark3116_attach, | 731 | .attach = ark3116_attach, |
734 | .release = ark3116_release, | 732 | .release = ark3116_release, |
@@ -745,32 +743,12 @@ static struct usb_serial_driver ark3116_device = { | |||
745 | .process_read_urb = ark3116_process_read_urb, | 743 | .process_read_urb = ark3116_process_read_urb, |
746 | }; | 744 | }; |
747 | 745 | ||
748 | static int __init ark3116_init(void) | 746 | static struct usb_serial_driver * const serial_drivers[] = { |
749 | { | 747 | &ark3116_device, NULL |
750 | int retval; | 748 | }; |
751 | |||
752 | retval = usb_serial_register(&ark3116_device); | ||
753 | if (retval) | ||
754 | return retval; | ||
755 | retval = usb_register(&ark3116_driver); | ||
756 | if (retval == 0) { | ||
757 | printk(KERN_INFO "%s:" | ||
758 | DRIVER_VERSION ":" | ||
759 | DRIVER_DESC "\n", | ||
760 | KBUILD_MODNAME); | ||
761 | } else | ||
762 | usb_serial_deregister(&ark3116_device); | ||
763 | return retval; | ||
764 | } | ||
765 | 749 | ||
766 | static void __exit ark3116_exit(void) | 750 | module_usb_serial_driver(ark3116_driver, serial_drivers); |
767 | { | ||
768 | usb_deregister(&ark3116_driver); | ||
769 | usb_serial_deregister(&ark3116_device); | ||
770 | } | ||
771 | 751 | ||
772 | module_init(ark3116_init); | ||
773 | module_exit(ark3116_exit); | ||
774 | MODULE_LICENSE("GPL"); | 752 | MODULE_LICENSE("GPL"); |
775 | 753 | ||
776 | MODULE_AUTHOR(DRIVER_AUTHOR); | 754 | MODULE_AUTHOR(DRIVER_AUTHOR); |
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 29ffeb6279c7..a52e0d2cec31 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c | |||
@@ -78,7 +78,6 @@ static struct usb_driver belkin_driver = { | |||
78 | .probe = usb_serial_probe, | 78 | .probe = usb_serial_probe, |
79 | .disconnect = usb_serial_disconnect, | 79 | .disconnect = usb_serial_disconnect, |
80 | .id_table = id_table_combined, | 80 | .id_table = id_table_combined, |
81 | .no_dynamic_id = 1, | ||
82 | }; | 81 | }; |
83 | 82 | ||
84 | /* All of the device info needed for the serial converters */ | 83 | /* All of the device info needed for the serial converters */ |
@@ -88,7 +87,6 @@ static struct usb_serial_driver belkin_device = { | |||
88 | .name = "belkin", | 87 | .name = "belkin", |
89 | }, | 88 | }, |
90 | .description = "Belkin / Peracom / GoHubs USB Serial Adapter", | 89 | .description = "Belkin / Peracom / GoHubs USB Serial Adapter", |
91 | .usb_driver = &belkin_driver, | ||
92 | .id_table = id_table_combined, | 90 | .id_table = id_table_combined, |
93 | .num_ports = 1, | 91 | .num_ports = 1, |
94 | .open = belkin_sa_open, | 92 | .open = belkin_sa_open, |
@@ -103,6 +101,10 @@ static struct usb_serial_driver belkin_device = { | |||
103 | .release = belkin_sa_release, | 101 | .release = belkin_sa_release, |
104 | }; | 102 | }; |
105 | 103 | ||
104 | static struct usb_serial_driver * const serial_drivers[] = { | ||
105 | &belkin_device, NULL | ||
106 | }; | ||
107 | |||
106 | struct belkin_sa_private { | 108 | struct belkin_sa_private { |
107 | spinlock_t lock; | 109 | spinlock_t lock; |
108 | unsigned long control_state; | 110 | unsigned long control_state; |
@@ -522,34 +524,7 @@ exit: | |||
522 | return retval; | 524 | return retval; |
523 | } | 525 | } |
524 | 526 | ||
525 | 527 | module_usb_serial_driver(belkin_driver, serial_drivers); | |
526 | static int __init belkin_sa_init(void) | ||
527 | { | ||
528 | int retval; | ||
529 | retval = usb_serial_register(&belkin_device); | ||
530 | if (retval) | ||
531 | goto failed_usb_serial_register; | ||
532 | retval = usb_register(&belkin_driver); | ||
533 | if (retval) | ||
534 | goto failed_usb_register; | ||
535 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
536 | DRIVER_DESC "\n"); | ||
537 | return 0; | ||
538 | failed_usb_register: | ||
539 | usb_serial_deregister(&belkin_device); | ||
540 | failed_usb_serial_register: | ||
541 | return retval; | ||
542 | } | ||
543 | |||
544 | static void __exit belkin_sa_exit (void) | ||
545 | { | ||
546 | usb_deregister(&belkin_driver); | ||
547 | usb_serial_deregister(&belkin_device); | ||
548 | } | ||
549 | |||
550 | |||
551 | module_init(belkin_sa_init); | ||
552 | module_exit(belkin_sa_exit); | ||
553 | 528 | ||
554 | MODULE_AUTHOR(DRIVER_AUTHOR); | 529 | MODULE_AUTHOR(DRIVER_AUTHOR); |
555 | MODULE_DESCRIPTION(DRIVER_DESC); | 530 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index 5e53cc59e652..aaab32db31d0 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c | |||
@@ -625,7 +625,6 @@ static struct usb_driver ch341_driver = { | |||
625 | .resume = usb_serial_resume, | 625 | .resume = usb_serial_resume, |
626 | .reset_resume = ch341_reset_resume, | 626 | .reset_resume = ch341_reset_resume, |
627 | .id_table = id_table, | 627 | .id_table = id_table, |
628 | .no_dynamic_id = 1, | ||
629 | .supports_autosuspend = 1, | 628 | .supports_autosuspend = 1, |
630 | }; | 629 | }; |
631 | 630 | ||
@@ -635,7 +634,6 @@ static struct usb_serial_driver ch341_device = { | |||
635 | .name = "ch341-uart", | 634 | .name = "ch341-uart", |
636 | }, | 635 | }, |
637 | .id_table = id_table, | 636 | .id_table = id_table, |
638 | .usb_driver = &ch341_driver, | ||
639 | .num_ports = 1, | 637 | .num_ports = 1, |
640 | .open = ch341_open, | 638 | .open = ch341_open, |
641 | .dtr_rts = ch341_dtr_rts, | 639 | .dtr_rts = ch341_dtr_rts, |
@@ -650,30 +648,13 @@ static struct usb_serial_driver ch341_device = { | |||
650 | .attach = ch341_attach, | 648 | .attach = ch341_attach, |
651 | }; | 649 | }; |
652 | 650 | ||
653 | static int __init ch341_init(void) | 651 | static struct usb_serial_driver * const serial_drivers[] = { |
654 | { | 652 | &ch341_device, NULL |
655 | int retval; | 653 | }; |
656 | |||
657 | retval = usb_serial_register(&ch341_device); | ||
658 | if (retval) | ||
659 | return retval; | ||
660 | retval = usb_register(&ch341_driver); | ||
661 | if (retval) | ||
662 | usb_serial_deregister(&ch341_device); | ||
663 | return retval; | ||
664 | } | ||
665 | 654 | ||
666 | static void __exit ch341_exit(void) | 655 | module_usb_serial_driver(ch341_driver, serial_drivers); |
667 | { | ||
668 | usb_deregister(&ch341_driver); | ||
669 | usb_serial_deregister(&ch341_device); | ||
670 | } | ||
671 | 656 | ||
672 | module_init(ch341_init); | ||
673 | module_exit(ch341_exit); | ||
674 | MODULE_LICENSE("GPL"); | 657 | MODULE_LICENSE("GPL"); |
675 | 658 | ||
676 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 659 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
677 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 660 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
678 | |||
679 | /* EOF ch341.c */ | ||
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 08a5575724cd..0310e2df59f5 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -49,6 +49,7 @@ static int cp210x_tiocmset_port(struct usb_serial_port *port, | |||
49 | unsigned int, unsigned int); | 49 | unsigned int, unsigned int); |
50 | static void cp210x_break_ctl(struct tty_struct *, int); | 50 | static void cp210x_break_ctl(struct tty_struct *, int); |
51 | static int cp210x_startup(struct usb_serial *); | 51 | static int cp210x_startup(struct usb_serial *); |
52 | static void cp210x_release(struct usb_serial *); | ||
52 | static void cp210x_dtr_rts(struct usb_serial_port *p, int on); | 53 | static void cp210x_dtr_rts(struct usb_serial_port *p, int on); |
53 | 54 | ||
54 | static bool debug; | 55 | static bool debug; |
@@ -121,6 +122,8 @@ static const struct usb_device_id id_table[] = { | |||
121 | { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ | 122 | { USB_DEVICE(0x10C4, 0x8665) }, /* AC-Services OBD-IF */ |
122 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ | 123 | { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ |
123 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ | 124 | { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ |
125 | { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ | ||
126 | { USB_DEVICE(0x10C4, 0xEA80) }, /* Silicon Labs factory default */ | ||
124 | { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */ | 127 | { USB_DEVICE(0x10C4, 0xEA71) }, /* Infinity GPS-MIC-1 Radio Monophone */ |
125 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ | 128 | { USB_DEVICE(0x10C4, 0xF001) }, /* Elan Digital Systems USBscope50 */ |
126 | { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */ | 129 | { USB_DEVICE(0x10C4, 0xF002) }, /* Elan Digital Systems USBwave12 */ |
@@ -149,12 +152,15 @@ static const struct usb_device_id id_table[] = { | |||
149 | 152 | ||
150 | MODULE_DEVICE_TABLE(usb, id_table); | 153 | MODULE_DEVICE_TABLE(usb, id_table); |
151 | 154 | ||
155 | struct cp210x_port_private { | ||
156 | __u8 bInterfaceNumber; | ||
157 | }; | ||
158 | |||
152 | static struct usb_driver cp210x_driver = { | 159 | static struct usb_driver cp210x_driver = { |
153 | .name = "cp210x", | 160 | .name = "cp210x", |
154 | .probe = usb_serial_probe, | 161 | .probe = usb_serial_probe, |
155 | .disconnect = usb_serial_disconnect, | 162 | .disconnect = usb_serial_disconnect, |
156 | .id_table = id_table, | 163 | .id_table = id_table, |
157 | .no_dynamic_id = 1, | ||
158 | }; | 164 | }; |
159 | 165 | ||
160 | static struct usb_serial_driver cp210x_device = { | 166 | static struct usb_serial_driver cp210x_device = { |
@@ -162,7 +168,6 @@ static struct usb_serial_driver cp210x_device = { | |||
162 | .owner = THIS_MODULE, | 168 | .owner = THIS_MODULE, |
163 | .name = "cp210x", | 169 | .name = "cp210x", |
164 | }, | 170 | }, |
165 | .usb_driver = &cp210x_driver, | ||
166 | .id_table = id_table, | 171 | .id_table = id_table, |
167 | .num_ports = 1, | 172 | .num_ports = 1, |
168 | .bulk_in_size = 256, | 173 | .bulk_in_size = 256, |
@@ -174,9 +179,14 @@ static struct usb_serial_driver cp210x_device = { | |||
174 | .tiocmget = cp210x_tiocmget, | 179 | .tiocmget = cp210x_tiocmget, |
175 | .tiocmset = cp210x_tiocmset, | 180 | .tiocmset = cp210x_tiocmset, |
176 | .attach = cp210x_startup, | 181 | .attach = cp210x_startup, |
182 | .release = cp210x_release, | ||
177 | .dtr_rts = cp210x_dtr_rts | 183 | .dtr_rts = cp210x_dtr_rts |
178 | }; | 184 | }; |
179 | 185 | ||
186 | static struct usb_serial_driver * const serial_drivers[] = { | ||
187 | &cp210x_device, NULL | ||
188 | }; | ||
189 | |||
180 | /* Config request types */ | 190 | /* Config request types */ |
181 | #define REQTYPE_HOST_TO_DEVICE 0x41 | 191 | #define REQTYPE_HOST_TO_DEVICE 0x41 |
182 | #define REQTYPE_DEVICE_TO_HOST 0xc1 | 192 | #define REQTYPE_DEVICE_TO_HOST 0xc1 |
@@ -261,6 +271,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
261 | unsigned int *data, int size) | 271 | unsigned int *data, int size) |
262 | { | 272 | { |
263 | struct usb_serial *serial = port->serial; | 273 | struct usb_serial *serial = port->serial; |
274 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); | ||
264 | __le32 *buf; | 275 | __le32 *buf; |
265 | int result, i, length; | 276 | int result, i, length; |
266 | 277 | ||
@@ -276,7 +287,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
276 | /* Issue the request, attempting to read 'size' bytes */ | 287 | /* Issue the request, attempting to read 'size' bytes */ |
277 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 288 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
278 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, | 289 | request, REQTYPE_DEVICE_TO_HOST, 0x0000, |
279 | 0, buf, size, 300); | 290 | port_priv->bInterfaceNumber, buf, size, 300); |
280 | 291 | ||
281 | /* Convert data into an array of integers */ | 292 | /* Convert data into an array of integers */ |
282 | for (i = 0; i < length; i++) | 293 | for (i = 0; i < length; i++) |
@@ -286,7 +297,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
286 | 297 | ||
287 | if (result != size) { | 298 | if (result != size) { |
288 | dbg("%s - Unable to send config request, " | 299 | dbg("%s - Unable to send config request, " |
289 | "request=0x%x size=%d result=%d\n", | 300 | "request=0x%x size=%d result=%d", |
290 | __func__, request, size, result); | 301 | __func__, request, size, result); |
291 | if (result > 0) | 302 | if (result > 0) |
292 | result = -EPROTO; | 303 | result = -EPROTO; |
@@ -307,6 +318,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
307 | unsigned int *data, int size) | 318 | unsigned int *data, int size) |
308 | { | 319 | { |
309 | struct usb_serial *serial = port->serial; | 320 | struct usb_serial *serial = port->serial; |
321 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); | ||
310 | __le32 *buf; | 322 | __le32 *buf; |
311 | int result, i, length; | 323 | int result, i, length; |
312 | 324 | ||
@@ -328,19 +340,19 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
328 | result = usb_control_msg(serial->dev, | 340 | result = usb_control_msg(serial->dev, |
329 | usb_sndctrlpipe(serial->dev, 0), | 341 | usb_sndctrlpipe(serial->dev, 0), |
330 | request, REQTYPE_HOST_TO_DEVICE, 0x0000, | 342 | request, REQTYPE_HOST_TO_DEVICE, 0x0000, |
331 | 0, buf, size, 300); | 343 | port_priv->bInterfaceNumber, buf, size, 300); |
332 | } else { | 344 | } else { |
333 | result = usb_control_msg(serial->dev, | 345 | result = usb_control_msg(serial->dev, |
334 | usb_sndctrlpipe(serial->dev, 0), | 346 | usb_sndctrlpipe(serial->dev, 0), |
335 | request, REQTYPE_HOST_TO_DEVICE, data[0], | 347 | request, REQTYPE_HOST_TO_DEVICE, data[0], |
336 | 0, NULL, 0, 300); | 348 | port_priv->bInterfaceNumber, NULL, 0, 300); |
337 | } | 349 | } |
338 | 350 | ||
339 | kfree(buf); | 351 | kfree(buf); |
340 | 352 | ||
341 | if ((size > 2 && result != size) || result < 0) { | 353 | if ((size > 2 && result != size) || result < 0) { |
342 | dbg("%s - Unable to send request, " | 354 | dbg("%s - Unable to send request, " |
343 | "request=0x%x size=%d result=%d\n", | 355 | "request=0x%x size=%d result=%d", |
344 | __func__, request, size, result); | 356 | __func__, request, size, result); |
345 | if (result > 0) | 357 | if (result > 0) |
346 | result = -EPROTO; | 358 | result = -EPROTO; |
@@ -683,13 +695,13 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
683 | default: | 695 | default: |
684 | dbg("cp210x driver does not " | 696 | dbg("cp210x driver does not " |
685 | "support the number of bits requested," | 697 | "support the number of bits requested," |
686 | " using 8 bit mode\n"); | 698 | " using 8 bit mode"); |
687 | bits |= BITS_DATA_8; | 699 | bits |= BITS_DATA_8; |
688 | break; | 700 | break; |
689 | } | 701 | } |
690 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 702 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
691 | dbg("Number of data bits requested " | 703 | dbg("Number of data bits requested " |
692 | "not supported by device\n"); | 704 | "not supported by device"); |
693 | } | 705 | } |
694 | 706 | ||
695 | if ((cflag & (PARENB|PARODD|CMSPAR)) != | 707 | if ((cflag & (PARENB|PARODD|CMSPAR)) != |
@@ -716,8 +728,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
716 | } | 728 | } |
717 | } | 729 | } |
718 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 730 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
719 | dbg("Parity mode not supported " | 731 | dbg("Parity mode not supported by device"); |
720 | "by device\n"); | ||
721 | } | 732 | } |
722 | 733 | ||
723 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { | 734 | if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { |
@@ -732,7 +743,7 @@ static void cp210x_set_termios(struct tty_struct *tty, | |||
732 | } | 743 | } |
733 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) | 744 | if (cp210x_set_config(port, CP210X_SET_LINE_CTL, &bits, 2)) |
734 | dbg("Number of stop bits requested " | 745 | dbg("Number of stop bits requested " |
735 | "not supported by device\n"); | 746 | "not supported by device"); |
736 | } | 747 | } |
737 | 748 | ||
738 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { | 749 | if ((cflag & CRTSCTS) != (old_cflag & CRTSCTS)) { |
@@ -844,40 +855,40 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state) | |||
844 | 855 | ||
845 | static int cp210x_startup(struct usb_serial *serial) | 856 | static int cp210x_startup(struct usb_serial *serial) |
846 | { | 857 | { |
858 | struct cp210x_port_private *port_priv; | ||
859 | int i; | ||
860 | |||
847 | /* cp210x buffers behave strangely unless device is reset */ | 861 | /* cp210x buffers behave strangely unless device is reset */ |
848 | usb_reset_device(serial->dev); | 862 | usb_reset_device(serial->dev); |
849 | return 0; | ||
850 | } | ||
851 | 863 | ||
852 | static int __init cp210x_init(void) | 864 | for (i = 0; i < serial->num_ports; i++) { |
853 | { | 865 | port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL); |
854 | int retval; | 866 | if (!port_priv) |
867 | return -ENOMEM; | ||
855 | 868 | ||
856 | retval = usb_serial_register(&cp210x_device); | 869 | memset(port_priv, 0x00, sizeof(*port_priv)); |
857 | if (retval) | 870 | port_priv->bInterfaceNumber = |
858 | return retval; /* Failed to register */ | 871 | serial->interface->cur_altsetting->desc.bInterfaceNumber; |
859 | 872 | ||
860 | retval = usb_register(&cp210x_driver); | 873 | usb_set_serial_port_data(serial->port[i], port_priv); |
861 | if (retval) { | ||
862 | /* Failed to register */ | ||
863 | usb_serial_deregister(&cp210x_device); | ||
864 | return retval; | ||
865 | } | 874 | } |
866 | 875 | ||
867 | /* Success */ | ||
868 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
869 | DRIVER_DESC "\n"); | ||
870 | return 0; | 876 | return 0; |
871 | } | 877 | } |
872 | 878 | ||
873 | static void __exit cp210x_exit(void) | 879 | static void cp210x_release(struct usb_serial *serial) |
874 | { | 880 | { |
875 | usb_deregister(&cp210x_driver); | 881 | struct cp210x_port_private *port_priv; |
876 | usb_serial_deregister(&cp210x_device); | 882 | int i; |
883 | |||
884 | for (i = 0; i < serial->num_ports; i++) { | ||
885 | port_priv = usb_get_serial_port_data(serial->port[i]); | ||
886 | kfree(port_priv); | ||
887 | usb_set_serial_port_data(serial->port[i], NULL); | ||
888 | } | ||
877 | } | 889 | } |
878 | 890 | ||
879 | module_init(cp210x_init); | 891 | module_usb_serial_driver(cp210x_driver, serial_drivers); |
880 | module_exit(cp210x_exit); | ||
881 | 892 | ||
882 | MODULE_DESCRIPTION(DRIVER_DESC); | 893 | MODULE_DESCRIPTION(DRIVER_DESC); |
883 | MODULE_VERSION(DRIVER_VERSION); | 894 | MODULE_VERSION(DRIVER_VERSION); |
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 6bc3802a581a..d39b9418f2fb 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c | |||
@@ -82,7 +82,6 @@ static struct usb_driver cyberjack_driver = { | |||
82 | .probe = usb_serial_probe, | 82 | .probe = usb_serial_probe, |
83 | .disconnect = usb_serial_disconnect, | 83 | .disconnect = usb_serial_disconnect, |
84 | .id_table = id_table, | 84 | .id_table = id_table, |
85 | .no_dynamic_id = 1, | ||
86 | }; | 85 | }; |
87 | 86 | ||
88 | static struct usb_serial_driver cyberjack_device = { | 87 | static struct usb_serial_driver cyberjack_device = { |
@@ -91,7 +90,6 @@ static struct usb_serial_driver cyberjack_device = { | |||
91 | .name = "cyberjack", | 90 | .name = "cyberjack", |
92 | }, | 91 | }, |
93 | .description = "Reiner SCT Cyberjack USB card reader", | 92 | .description = "Reiner SCT Cyberjack USB card reader", |
94 | .usb_driver = &cyberjack_driver, | ||
95 | .id_table = id_table, | 93 | .id_table = id_table, |
96 | .num_ports = 1, | 94 | .num_ports = 1, |
97 | .attach = cyberjack_startup, | 95 | .attach = cyberjack_startup, |
@@ -106,6 +104,10 @@ static struct usb_serial_driver cyberjack_device = { | |||
106 | .write_bulk_callback = cyberjack_write_bulk_callback, | 104 | .write_bulk_callback = cyberjack_write_bulk_callback, |
107 | }; | 105 | }; |
108 | 106 | ||
107 | static struct usb_serial_driver * const serial_drivers[] = { | ||
108 | &cyberjack_device, NULL | ||
109 | }; | ||
110 | |||
109 | struct cyberjack_private { | 111 | struct cyberjack_private { |
110 | spinlock_t lock; /* Lock for SMP */ | 112 | spinlock_t lock; /* Lock for SMP */ |
111 | short rdtodo; /* Bytes still to read */ | 113 | short rdtodo; /* Bytes still to read */ |
@@ -473,35 +475,7 @@ exit: | |||
473 | usb_serial_port_softint(port); | 475 | usb_serial_port_softint(port); |
474 | } | 476 | } |
475 | 477 | ||
476 | static int __init cyberjack_init(void) | 478 | module_usb_serial_driver(cyberjack_driver, serial_drivers); |
477 | { | ||
478 | int retval; | ||
479 | retval = usb_serial_register(&cyberjack_device); | ||
480 | if (retval) | ||
481 | goto failed_usb_serial_register; | ||
482 | retval = usb_register(&cyberjack_driver); | ||
483 | if (retval) | ||
484 | goto failed_usb_register; | ||
485 | |||
486 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION " " | ||
487 | DRIVER_AUTHOR "\n"); | ||
488 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | ||
489 | |||
490 | return 0; | ||
491 | failed_usb_register: | ||
492 | usb_serial_deregister(&cyberjack_device); | ||
493 | failed_usb_serial_register: | ||
494 | return retval; | ||
495 | } | ||
496 | |||
497 | static void __exit cyberjack_exit(void) | ||
498 | { | ||
499 | usb_deregister(&cyberjack_driver); | ||
500 | usb_serial_deregister(&cyberjack_device); | ||
501 | } | ||
502 | |||
503 | module_init(cyberjack_init); | ||
504 | module_exit(cyberjack_exit); | ||
505 | 479 | ||
506 | MODULE_AUTHOR(DRIVER_AUTHOR); | 480 | MODULE_AUTHOR(DRIVER_AUTHOR); |
507 | MODULE_DESCRIPTION(DRIVER_DESC); | 481 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index 3bdeafa29c24..afc886c75d2f 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c | |||
@@ -94,7 +94,6 @@ static struct usb_driver cypress_driver = { | |||
94 | .probe = usb_serial_probe, | 94 | .probe = usb_serial_probe, |
95 | .disconnect = usb_serial_disconnect, | 95 | .disconnect = usb_serial_disconnect, |
96 | .id_table = id_table_combined, | 96 | .id_table = id_table_combined, |
97 | .no_dynamic_id = 1, | ||
98 | }; | 97 | }; |
99 | 98 | ||
100 | enum packet_format { | 99 | enum packet_format { |
@@ -163,7 +162,6 @@ static struct usb_serial_driver cypress_earthmate_device = { | |||
163 | .name = "earthmate", | 162 | .name = "earthmate", |
164 | }, | 163 | }, |
165 | .description = "DeLorme Earthmate USB", | 164 | .description = "DeLorme Earthmate USB", |
166 | .usb_driver = &cypress_driver, | ||
167 | .id_table = id_table_earthmate, | 165 | .id_table = id_table_earthmate, |
168 | .num_ports = 1, | 166 | .num_ports = 1, |
169 | .attach = cypress_earthmate_startup, | 167 | .attach = cypress_earthmate_startup, |
@@ -190,7 +188,6 @@ static struct usb_serial_driver cypress_hidcom_device = { | |||
190 | .name = "cyphidcom", | 188 | .name = "cyphidcom", |
191 | }, | 189 | }, |
192 | .description = "HID->COM RS232 Adapter", | 190 | .description = "HID->COM RS232 Adapter", |
193 | .usb_driver = &cypress_driver, | ||
194 | .id_table = id_table_cyphidcomrs232, | 191 | .id_table = id_table_cyphidcomrs232, |
195 | .num_ports = 1, | 192 | .num_ports = 1, |
196 | .attach = cypress_hidcom_startup, | 193 | .attach = cypress_hidcom_startup, |
@@ -217,7 +214,6 @@ static struct usb_serial_driver cypress_ca42v2_device = { | |||
217 | .name = "nokiaca42v2", | 214 | .name = "nokiaca42v2", |
218 | }, | 215 | }, |
219 | .description = "Nokia CA-42 V2 Adapter", | 216 | .description = "Nokia CA-42 V2 Adapter", |
220 | .usb_driver = &cypress_driver, | ||
221 | .id_table = id_table_nokiaca42v2, | 217 | .id_table = id_table_nokiaca42v2, |
222 | .num_ports = 1, | 218 | .num_ports = 1, |
223 | .attach = cypress_ca42v2_startup, | 219 | .attach = cypress_ca42v2_startup, |
@@ -238,6 +234,11 @@ static struct usb_serial_driver cypress_ca42v2_device = { | |||
238 | .write_int_callback = cypress_write_int_callback, | 234 | .write_int_callback = cypress_write_int_callback, |
239 | }; | 235 | }; |
240 | 236 | ||
237 | static struct usb_serial_driver * const serial_drivers[] = { | ||
238 | &cypress_earthmate_device, &cypress_hidcom_device, | ||
239 | &cypress_ca42v2_device, NULL | ||
240 | }; | ||
241 | |||
241 | /***************************************************************************** | 242 | /***************************************************************************** |
242 | * Cypress serial helper functions | 243 | * Cypress serial helper functions |
243 | *****************************************************************************/ | 244 | *****************************************************************************/ |
@@ -800,7 +801,7 @@ send: | |||
800 | cypress_write_int_callback, port, priv->write_urb_interval); | 801 | cypress_write_int_callback, port, priv->write_urb_interval); |
801 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); | 802 | result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); |
802 | if (result) { | 803 | if (result) { |
803 | dev_err(&port->dev, | 804 | dev_err_console(port, |
804 | "%s - failed submitting write urb, error %d\n", | 805 | "%s - failed submitting write urb, error %d\n", |
805 | __func__, result); | 806 | __func__, result); |
806 | priv->write_urb_in_use = 0; | 807 | priv->write_urb_in_use = 0; |
@@ -1345,58 +1346,7 @@ static void cypress_write_int_callback(struct urb *urb) | |||
1345 | cypress_send(port); | 1346 | cypress_send(port); |
1346 | } | 1347 | } |
1347 | 1348 | ||
1348 | 1349 | module_usb_serial_driver(cypress_driver, serial_drivers); | |
1349 | /***************************************************************************** | ||
1350 | * Module functions | ||
1351 | *****************************************************************************/ | ||
1352 | |||
1353 | static int __init cypress_init(void) | ||
1354 | { | ||
1355 | int retval; | ||
1356 | |||
1357 | dbg("%s", __func__); | ||
1358 | |||
1359 | retval = usb_serial_register(&cypress_earthmate_device); | ||
1360 | if (retval) | ||
1361 | goto failed_em_register; | ||
1362 | retval = usb_serial_register(&cypress_hidcom_device); | ||
1363 | if (retval) | ||
1364 | goto failed_hidcom_register; | ||
1365 | retval = usb_serial_register(&cypress_ca42v2_device); | ||
1366 | if (retval) | ||
1367 | goto failed_ca42v2_register; | ||
1368 | retval = usb_register(&cypress_driver); | ||
1369 | if (retval) | ||
1370 | goto failed_usb_register; | ||
1371 | |||
1372 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1373 | DRIVER_DESC "\n"); | ||
1374 | return 0; | ||
1375 | |||
1376 | failed_usb_register: | ||
1377 | usb_serial_deregister(&cypress_ca42v2_device); | ||
1378 | failed_ca42v2_register: | ||
1379 | usb_serial_deregister(&cypress_hidcom_device); | ||
1380 | failed_hidcom_register: | ||
1381 | usb_serial_deregister(&cypress_earthmate_device); | ||
1382 | failed_em_register: | ||
1383 | return retval; | ||
1384 | } | ||
1385 | |||
1386 | |||
1387 | static void __exit cypress_exit(void) | ||
1388 | { | ||
1389 | dbg("%s", __func__); | ||
1390 | |||
1391 | usb_deregister(&cypress_driver); | ||
1392 | usb_serial_deregister(&cypress_earthmate_device); | ||
1393 | usb_serial_deregister(&cypress_hidcom_device); | ||
1394 | usb_serial_deregister(&cypress_ca42v2_device); | ||
1395 | } | ||
1396 | |||
1397 | |||
1398 | module_init(cypress_init); | ||
1399 | module_exit(cypress_exit); | ||
1400 | 1350 | ||
1401 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1351 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1402 | MODULE_DESCRIPTION(DRIVER_DESC); | 1352 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c index b23bebd721a1..999f91bf70de 100644 --- a/drivers/usb/serial/digi_acceleport.c +++ b/drivers/usb/serial/digi_acceleport.c | |||
@@ -276,7 +276,6 @@ static struct usb_driver digi_driver = { | |||
276 | .probe = usb_serial_probe, | 276 | .probe = usb_serial_probe, |
277 | .disconnect = usb_serial_disconnect, | 277 | .disconnect = usb_serial_disconnect, |
278 | .id_table = id_table_combined, | 278 | .id_table = id_table_combined, |
279 | .no_dynamic_id = 1, | ||
280 | }; | 279 | }; |
281 | 280 | ||
282 | 281 | ||
@@ -288,7 +287,6 @@ static struct usb_serial_driver digi_acceleport_2_device = { | |||
288 | .name = "digi_2", | 287 | .name = "digi_2", |
289 | }, | 288 | }, |
290 | .description = "Digi 2 port USB adapter", | 289 | .description = "Digi 2 port USB adapter", |
291 | .usb_driver = &digi_driver, | ||
292 | .id_table = id_table_2, | 290 | .id_table = id_table_2, |
293 | .num_ports = 3, | 291 | .num_ports = 3, |
294 | .open = digi_open, | 292 | .open = digi_open, |
@@ -316,7 +314,6 @@ static struct usb_serial_driver digi_acceleport_4_device = { | |||
316 | .name = "digi_4", | 314 | .name = "digi_4", |
317 | }, | 315 | }, |
318 | .description = "Digi 4 port USB adapter", | 316 | .description = "Digi 4 port USB adapter", |
319 | .usb_driver = &digi_driver, | ||
320 | .id_table = id_table_4, | 317 | .id_table = id_table_4, |
321 | .num_ports = 4, | 318 | .num_ports = 4, |
322 | .open = digi_open, | 319 | .open = digi_open, |
@@ -337,6 +334,9 @@ static struct usb_serial_driver digi_acceleport_4_device = { | |||
337 | .release = digi_release, | 334 | .release = digi_release, |
338 | }; | 335 | }; |
339 | 336 | ||
337 | static struct usb_serial_driver * const serial_drivers[] = { | ||
338 | &digi_acceleport_2_device, &digi_acceleport_4_device, NULL | ||
339 | }; | ||
340 | 340 | ||
341 | /* Functions */ | 341 | /* Functions */ |
342 | 342 | ||
@@ -995,7 +995,7 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
995 | /* return length of new data written, or error */ | 995 | /* return length of new data written, or error */ |
996 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); | 996 | spin_unlock_irqrestore(&priv->dp_port_lock, flags); |
997 | if (ret < 0) | 997 | if (ret < 0) |
998 | dev_err(&port->dev, | 998 | dev_err_console(port, |
999 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | 999 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
1000 | __func__, ret, priv->dp_port_num); | 1000 | __func__, ret, priv->dp_port_num); |
1001 | dbg("digi_write: returning %d", ret); | 1001 | dbg("digi_write: returning %d", ret); |
@@ -1065,7 +1065,7 @@ static void digi_write_bulk_callback(struct urb *urb) | |||
1065 | 1065 | ||
1066 | spin_unlock(&priv->dp_port_lock); | 1066 | spin_unlock(&priv->dp_port_lock); |
1067 | if (ret && ret != -EPERM) | 1067 | if (ret && ret != -EPERM) |
1068 | dev_err(&port->dev, | 1068 | dev_err_console(port, |
1069 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", | 1069 | "%s: usb_submit_urb failed, ret=%d, port=%d\n", |
1070 | __func__, ret, priv->dp_port_num); | 1070 | __func__, ret, priv->dp_port_num); |
1071 | } | 1071 | } |
@@ -1580,40 +1580,7 @@ static int digi_read_oob_callback(struct urb *urb) | |||
1580 | 1580 | ||
1581 | } | 1581 | } |
1582 | 1582 | ||
1583 | static int __init digi_init(void) | 1583 | module_usb_serial_driver(digi_driver, serial_drivers); |
1584 | { | ||
1585 | int retval; | ||
1586 | retval = usb_serial_register(&digi_acceleport_2_device); | ||
1587 | if (retval) | ||
1588 | goto failed_acceleport_2_device; | ||
1589 | retval = usb_serial_register(&digi_acceleport_4_device); | ||
1590 | if (retval) | ||
1591 | goto failed_acceleport_4_device; | ||
1592 | retval = usb_register(&digi_driver); | ||
1593 | if (retval) | ||
1594 | goto failed_usb_register; | ||
1595 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1596 | DRIVER_DESC "\n"); | ||
1597 | return 0; | ||
1598 | failed_usb_register: | ||
1599 | usb_serial_deregister(&digi_acceleport_4_device); | ||
1600 | failed_acceleport_4_device: | ||
1601 | usb_serial_deregister(&digi_acceleport_2_device); | ||
1602 | failed_acceleport_2_device: | ||
1603 | return retval; | ||
1604 | } | ||
1605 | |||
1606 | static void __exit digi_exit (void) | ||
1607 | { | ||
1608 | usb_deregister(&digi_driver); | ||
1609 | usb_serial_deregister(&digi_acceleport_2_device); | ||
1610 | usb_serial_deregister(&digi_acceleport_4_device); | ||
1611 | } | ||
1612 | |||
1613 | |||
1614 | module_init(digi_init); | ||
1615 | module_exit(digi_exit); | ||
1616 | |||
1617 | 1584 | ||
1618 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1585 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1619 | MODULE_DESCRIPTION(DRIVER_DESC); | 1586 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c index aced6817bf95..5b99fc09e327 100644 --- a/drivers/usb/serial/empeg.c +++ b/drivers/usb/serial/empeg.c | |||
@@ -56,7 +56,6 @@ static struct usb_driver empeg_driver = { | |||
56 | .probe = usb_serial_probe, | 56 | .probe = usb_serial_probe, |
57 | .disconnect = usb_serial_disconnect, | 57 | .disconnect = usb_serial_disconnect, |
58 | .id_table = id_table, | 58 | .id_table = id_table, |
59 | .no_dynamic_id = 1, | ||
60 | }; | 59 | }; |
61 | 60 | ||
62 | static struct usb_serial_driver empeg_device = { | 61 | static struct usb_serial_driver empeg_device = { |
@@ -65,7 +64,6 @@ static struct usb_serial_driver empeg_device = { | |||
65 | .name = "empeg", | 64 | .name = "empeg", |
66 | }, | 65 | }, |
67 | .id_table = id_table, | 66 | .id_table = id_table, |
68 | .usb_driver = &empeg_driver, | ||
69 | .num_ports = 1, | 67 | .num_ports = 1, |
70 | .bulk_out_size = 256, | 68 | .bulk_out_size = 256, |
71 | .throttle = usb_serial_generic_throttle, | 69 | .throttle = usb_serial_generic_throttle, |
@@ -74,6 +72,10 @@ static struct usb_serial_driver empeg_device = { | |||
74 | .init_termios = empeg_init_termios, | 72 | .init_termios = empeg_init_termios, |
75 | }; | 73 | }; |
76 | 74 | ||
75 | static struct usb_serial_driver * const serial_drivers[] = { | ||
76 | &empeg_device, NULL | ||
77 | }; | ||
78 | |||
77 | static int empeg_startup(struct usb_serial *serial) | 79 | static int empeg_startup(struct usb_serial *serial) |
78 | { | 80 | { |
79 | int r; | 81 | int r; |
@@ -136,33 +138,7 @@ static void empeg_init_termios(struct tty_struct *tty) | |||
136 | tty_encode_baud_rate(tty, 115200, 115200); | 138 | tty_encode_baud_rate(tty, 115200, 115200); |
137 | } | 139 | } |
138 | 140 | ||
139 | static int __init empeg_init(void) | 141 | module_usb_serial_driver(empeg_driver, serial_drivers); |
140 | { | ||
141 | int retval; | ||
142 | |||
143 | retval = usb_serial_register(&empeg_device); | ||
144 | if (retval) | ||
145 | return retval; | ||
146 | retval = usb_register(&empeg_driver); | ||
147 | if (retval) { | ||
148 | usb_serial_deregister(&empeg_device); | ||
149 | return retval; | ||
150 | } | ||
151 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
152 | DRIVER_DESC "\n"); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static void __exit empeg_exit(void) | ||
158 | { | ||
159 | usb_deregister(&empeg_driver); | ||
160 | usb_serial_deregister(&empeg_device); | ||
161 | } | ||
162 | |||
163 | |||
164 | module_init(empeg_init); | ||
165 | module_exit(empeg_exit); | ||
166 | 142 | ||
167 | MODULE_AUTHOR(DRIVER_AUTHOR); | 143 | MODULE_AUTHOR(DRIVER_AUTHOR); |
168 | MODULE_DESCRIPTION(DRIVER_DESC); | 144 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c new file mode 100644 index 000000000000..88c0b1963920 --- /dev/null +++ b/drivers/usb/serial/f81232.c | |||
@@ -0,0 +1,405 @@ | |||
1 | /* | ||
2 | * Fintek F81232 USB to serial adaptor driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Greg Kroah-Hartman (gregkh@linuxfoundation.org) | ||
5 | * Copyright (C) 2012 Linux Foundation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License version 2 as published by | ||
9 | * the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/slab.h> | ||
17 | #include <linux/tty.h> | ||
18 | #include <linux/tty_driver.h> | ||
19 | #include <linux/tty_flip.h> | ||
20 | #include <linux/serial.h> | ||
21 | #include <linux/module.h> | ||
22 | #include <linux/moduleparam.h> | ||
23 | #include <linux/spinlock.h> | ||
24 | #include <linux/uaccess.h> | ||
25 | #include <linux/usb.h> | ||
26 | #include <linux/usb/serial.h> | ||
27 | |||
28 | static bool debug; | ||
29 | |||
30 | static const struct usb_device_id id_table[] = { | ||
31 | { USB_DEVICE(0x1934, 0x0706) }, | ||
32 | { } /* Terminating entry */ | ||
33 | }; | ||
34 | MODULE_DEVICE_TABLE(usb, id_table); | ||
35 | |||
36 | #define CONTROL_DTR 0x01 | ||
37 | #define CONTROL_RTS 0x02 | ||
38 | |||
39 | #define UART_STATE 0x08 | ||
40 | #define UART_STATE_TRANSIENT_MASK 0x74 | ||
41 | #define UART_DCD 0x01 | ||
42 | #define UART_DSR 0x02 | ||
43 | #define UART_BREAK_ERROR 0x04 | ||
44 | #define UART_RING 0x08 | ||
45 | #define UART_FRAME_ERROR 0x10 | ||
46 | #define UART_PARITY_ERROR 0x20 | ||
47 | #define UART_OVERRUN_ERROR 0x40 | ||
48 | #define UART_CTS 0x80 | ||
49 | |||
50 | struct f81232_private { | ||
51 | spinlock_t lock; | ||
52 | wait_queue_head_t delta_msr_wait; | ||
53 | u8 line_control; | ||
54 | u8 line_status; | ||
55 | }; | ||
56 | |||
57 | static void f81232_update_line_status(struct usb_serial_port *port, | ||
58 | unsigned char *data, | ||
59 | unsigned int actual_length) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | static void f81232_read_int_callback(struct urb *urb) | ||
64 | { | ||
65 | struct usb_serial_port *port = urb->context; | ||
66 | unsigned char *data = urb->transfer_buffer; | ||
67 | unsigned int actual_length = urb->actual_length; | ||
68 | int status = urb->status; | ||
69 | int retval; | ||
70 | |||
71 | dbg("%s (%d)", __func__, port->number); | ||
72 | |||
73 | switch (status) { | ||
74 | case 0: | ||
75 | /* success */ | ||
76 | break; | ||
77 | case -ECONNRESET: | ||
78 | case -ENOENT: | ||
79 | case -ESHUTDOWN: | ||
80 | /* this urb is terminated, clean up */ | ||
81 | dbg("%s - urb shutting down with status: %d", __func__, | ||
82 | status); | ||
83 | return; | ||
84 | default: | ||
85 | dbg("%s - nonzero urb status received: %d", __func__, | ||
86 | status); | ||
87 | goto exit; | ||
88 | } | ||
89 | |||
90 | usb_serial_debug_data(debug, &port->dev, __func__, | ||
91 | urb->actual_length, urb->transfer_buffer); | ||
92 | |||
93 | f81232_update_line_status(port, data, actual_length); | ||
94 | |||
95 | exit: | ||
96 | retval = usb_submit_urb(urb, GFP_ATOMIC); | ||
97 | if (retval) | ||
98 | dev_err(&urb->dev->dev, | ||
99 | "%s - usb_submit_urb failed with result %d\n", | ||
100 | __func__, retval); | ||
101 | } | ||
102 | |||
103 | static void f81232_process_read_urb(struct urb *urb) | ||
104 | { | ||
105 | struct usb_serial_port *port = urb->context; | ||
106 | struct f81232_private *priv = usb_get_serial_port_data(port); | ||
107 | struct tty_struct *tty; | ||
108 | unsigned char *data = urb->transfer_buffer; | ||
109 | char tty_flag = TTY_NORMAL; | ||
110 | unsigned long flags; | ||
111 | u8 line_status; | ||
112 | int i; | ||
113 | |||
114 | /* update line status */ | ||
115 | spin_lock_irqsave(&priv->lock, flags); | ||
116 | line_status = priv->line_status; | ||
117 | priv->line_status &= ~UART_STATE_TRANSIENT_MASK; | ||
118 | spin_unlock_irqrestore(&priv->lock, flags); | ||
119 | wake_up_interruptible(&priv->delta_msr_wait); | ||
120 | |||
121 | if (!urb->actual_length) | ||
122 | return; | ||
123 | |||
124 | tty = tty_port_tty_get(&port->port); | ||
125 | if (!tty) | ||
126 | return; | ||
127 | |||
128 | /* break takes precedence over parity, */ | ||
129 | /* which takes precedence over framing errors */ | ||
130 | if (line_status & UART_BREAK_ERROR) | ||
131 | tty_flag = TTY_BREAK; | ||
132 | else if (line_status & UART_PARITY_ERROR) | ||
133 | tty_flag = TTY_PARITY; | ||
134 | else if (line_status & UART_FRAME_ERROR) | ||
135 | tty_flag = TTY_FRAME; | ||
136 | dbg("%s - tty_flag = %d", __func__, tty_flag); | ||
137 | |||
138 | /* overrun is special, not associated with a char */ | ||
139 | if (line_status & UART_OVERRUN_ERROR) | ||
140 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
141 | |||
142 | if (port->port.console && port->sysrq) { | ||
143 | for (i = 0; i < urb->actual_length; ++i) | ||
144 | if (!usb_serial_handle_sysrq_char(port, data[i])) | ||
145 | tty_insert_flip_char(tty, data[i], tty_flag); | ||
146 | } else { | ||
147 | tty_insert_flip_string_fixed_flag(tty, data, tty_flag, | ||
148 | urb->actual_length); | ||
149 | } | ||
150 | |||
151 | tty_flip_buffer_push(tty); | ||
152 | tty_kref_put(tty); | ||
153 | } | ||
154 | |||
155 | static int set_control_lines(struct usb_device *dev, u8 value) | ||
156 | { | ||
157 | /* FIXME - Stubbed out for now */ | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static void f81232_break_ctl(struct tty_struct *tty, int break_state) | ||
162 | { | ||
163 | /* FIXME - Stubbed out for now */ | ||
164 | |||
165 | /* | ||
166 | * break_state = -1 to turn on break, and 0 to turn off break | ||
167 | * see drivers/char/tty_io.c to see it used. | ||
168 | * last_set_data_urb_value NEVER has the break bit set in it. | ||
169 | */ | ||
170 | } | ||
171 | |||
172 | static void f81232_set_termios(struct tty_struct *tty, | ||
173 | struct usb_serial_port *port, struct ktermios *old_termios) | ||
174 | { | ||
175 | /* FIXME - Stubbed out for now */ | ||
176 | |||
177 | /* Don't change anything if nothing has changed */ | ||
178 | if (!tty_termios_hw_change(tty->termios, old_termios)) | ||
179 | return; | ||
180 | |||
181 | /* Do the real work here... */ | ||
182 | } | ||
183 | |||
184 | static int f81232_tiocmget(struct tty_struct *tty) | ||
185 | { | ||
186 | /* FIXME - Stubbed out for now */ | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static int f81232_tiocmset(struct tty_struct *tty, | ||
191 | unsigned int set, unsigned int clear) | ||
192 | { | ||
193 | /* FIXME - Stubbed out for now */ | ||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port) | ||
198 | { | ||
199 | struct ktermios tmp_termios; | ||
200 | int result; | ||
201 | |||
202 | /* Setup termios */ | ||
203 | if (tty) | ||
204 | f81232_set_termios(tty, port, &tmp_termios); | ||
205 | |||
206 | dbg("%s - submitting interrupt urb", __func__); | ||
207 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | ||
208 | if (result) { | ||
209 | dev_err(&port->dev, "%s - failed submitting interrupt urb," | ||
210 | " error %d\n", __func__, result); | ||
211 | return result; | ||
212 | } | ||
213 | |||
214 | result = usb_serial_generic_open(tty, port); | ||
215 | if (result) { | ||
216 | usb_kill_urb(port->interrupt_in_urb); | ||
217 | return result; | ||
218 | } | ||
219 | |||
220 | port->port.drain_delay = 256; | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static void f81232_close(struct usb_serial_port *port) | ||
225 | { | ||
226 | usb_serial_generic_close(port); | ||
227 | usb_kill_urb(port->interrupt_in_urb); | ||
228 | } | ||
229 | |||
230 | static void f81232_dtr_rts(struct usb_serial_port *port, int on) | ||
231 | { | ||
232 | struct f81232_private *priv = usb_get_serial_port_data(port); | ||
233 | unsigned long flags; | ||
234 | u8 control; | ||
235 | |||
236 | spin_lock_irqsave(&priv->lock, flags); | ||
237 | /* Change DTR and RTS */ | ||
238 | if (on) | ||
239 | priv->line_control |= (CONTROL_DTR | CONTROL_RTS); | ||
240 | else | ||
241 | priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); | ||
242 | control = priv->line_control; | ||
243 | spin_unlock_irqrestore(&priv->lock, flags); | ||
244 | set_control_lines(port->serial->dev, control); | ||
245 | } | ||
246 | |||
247 | static int f81232_carrier_raised(struct usb_serial_port *port) | ||
248 | { | ||
249 | struct f81232_private *priv = usb_get_serial_port_data(port); | ||
250 | if (priv->line_status & UART_DCD) | ||
251 | return 1; | ||
252 | return 0; | ||
253 | } | ||
254 | |||
255 | static int wait_modem_info(struct usb_serial_port *port, unsigned int arg) | ||
256 | { | ||
257 | struct f81232_private *priv = usb_get_serial_port_data(port); | ||
258 | unsigned long flags; | ||
259 | unsigned int prevstatus; | ||
260 | unsigned int status; | ||
261 | unsigned int changed; | ||
262 | |||
263 | spin_lock_irqsave(&priv->lock, flags); | ||
264 | prevstatus = priv->line_status; | ||
265 | spin_unlock_irqrestore(&priv->lock, flags); | ||
266 | |||
267 | while (1) { | ||
268 | interruptible_sleep_on(&priv->delta_msr_wait); | ||
269 | /* see if a signal did it */ | ||
270 | if (signal_pending(current)) | ||
271 | return -ERESTARTSYS; | ||
272 | |||
273 | spin_lock_irqsave(&priv->lock, flags); | ||
274 | status = priv->line_status; | ||
275 | spin_unlock_irqrestore(&priv->lock, flags); | ||
276 | |||
277 | changed = prevstatus ^ status; | ||
278 | |||
279 | if (((arg & TIOCM_RNG) && (changed & UART_RING)) || | ||
280 | ((arg & TIOCM_DSR) && (changed & UART_DSR)) || | ||
281 | ((arg & TIOCM_CD) && (changed & UART_DCD)) || | ||
282 | ((arg & TIOCM_CTS) && (changed & UART_CTS))) { | ||
283 | return 0; | ||
284 | } | ||
285 | prevstatus = status; | ||
286 | } | ||
287 | /* NOTREACHED */ | ||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | static int f81232_ioctl(struct tty_struct *tty, | ||
292 | unsigned int cmd, unsigned long arg) | ||
293 | { | ||
294 | struct serial_struct ser; | ||
295 | struct usb_serial_port *port = tty->driver_data; | ||
296 | dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd); | ||
297 | |||
298 | switch (cmd) { | ||
299 | case TIOCGSERIAL: | ||
300 | memset(&ser, 0, sizeof ser); | ||
301 | ser.type = PORT_16654; | ||
302 | ser.line = port->serial->minor; | ||
303 | ser.port = port->number; | ||
304 | ser.baud_base = 460800; | ||
305 | |||
306 | if (copy_to_user((void __user *)arg, &ser, sizeof ser)) | ||
307 | return -EFAULT; | ||
308 | |||
309 | return 0; | ||
310 | |||
311 | case TIOCMIWAIT: | ||
312 | dbg("%s (%d) TIOCMIWAIT", __func__, port->number); | ||
313 | return wait_modem_info(port, arg); | ||
314 | default: | ||
315 | dbg("%s not supported = 0x%04x", __func__, cmd); | ||
316 | break; | ||
317 | } | ||
318 | return -ENOIOCTLCMD; | ||
319 | } | ||
320 | |||
321 | static int f81232_startup(struct usb_serial *serial) | ||
322 | { | ||
323 | struct f81232_private *priv; | ||
324 | int i; | ||
325 | |||
326 | for (i = 0; i < serial->num_ports; ++i) { | ||
327 | priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL); | ||
328 | if (!priv) | ||
329 | goto cleanup; | ||
330 | spin_lock_init(&priv->lock); | ||
331 | init_waitqueue_head(&priv->delta_msr_wait); | ||
332 | usb_set_serial_port_data(serial->port[i], priv); | ||
333 | } | ||
334 | return 0; | ||
335 | |||
336 | cleanup: | ||
337 | for (--i; i >= 0; --i) { | ||
338 | priv = usb_get_serial_port_data(serial->port[i]); | ||
339 | kfree(priv); | ||
340 | usb_set_serial_port_data(serial->port[i], NULL); | ||
341 | } | ||
342 | return -ENOMEM; | ||
343 | } | ||
344 | |||
345 | static void f81232_release(struct usb_serial *serial) | ||
346 | { | ||
347 | int i; | ||
348 | struct f81232_private *priv; | ||
349 | |||
350 | for (i = 0; i < serial->num_ports; ++i) { | ||
351 | priv = usb_get_serial_port_data(serial->port[i]); | ||
352 | kfree(priv); | ||
353 | } | ||
354 | } | ||
355 | |||
356 | static struct usb_driver f81232_driver = { | ||
357 | .name = "f81232", | ||
358 | .probe = usb_serial_probe, | ||
359 | .disconnect = usb_serial_disconnect, | ||
360 | .id_table = id_table, | ||
361 | .suspend = usb_serial_suspend, | ||
362 | .resume = usb_serial_resume, | ||
363 | .no_dynamic_id = 1, | ||
364 | .supports_autosuspend = 1, | ||
365 | }; | ||
366 | |||
367 | static struct usb_serial_driver f81232_device = { | ||
368 | .driver = { | ||
369 | .owner = THIS_MODULE, | ||
370 | .name = "f81232", | ||
371 | }, | ||
372 | .id_table = id_table, | ||
373 | .usb_driver = &f81232_driver, | ||
374 | .num_ports = 1, | ||
375 | .bulk_in_size = 256, | ||
376 | .bulk_out_size = 256, | ||
377 | .open = f81232_open, | ||
378 | .close = f81232_close, | ||
379 | .dtr_rts = f81232_dtr_rts, | ||
380 | .carrier_raised = f81232_carrier_raised, | ||
381 | .ioctl = f81232_ioctl, | ||
382 | .break_ctl = f81232_break_ctl, | ||
383 | .set_termios = f81232_set_termios, | ||
384 | .tiocmget = f81232_tiocmget, | ||
385 | .tiocmset = f81232_tiocmset, | ||
386 | .process_read_urb = f81232_process_read_urb, | ||
387 | .read_int_callback = f81232_read_int_callback, | ||
388 | .attach = f81232_startup, | ||
389 | .release = f81232_release, | ||
390 | }; | ||
391 | |||
392 | static struct usb_serial_driver * const serial_drivers[] = { | ||
393 | &f81232_device, | ||
394 | NULL, | ||
395 | }; | ||
396 | |||
397 | module_usb_serial_driver(f81232_driver, serial_drivers); | ||
398 | |||
399 | MODULE_DESCRIPTION("Fintek F81232 USB to serial adaptor driver"); | ||
400 | MODULE_AUTHOR("Greg Kroah-Hartman <gregkh@linuxfoundation.org"); | ||
401 | MODULE_LICENSE("GPL v2"); | ||
402 | |||
403 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
404 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | ||
405 | |||
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index f770415305f8..7c229d304684 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -188,6 +188,7 @@ static struct usb_device_id id_table_combined [] = { | |||
188 | .driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk }, | 188 | .driver_info = (kernel_ulong_t)&ftdi_8u2232c_quirk }, |
189 | { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, | 189 | { USB_DEVICE(FTDI_VID, FTDI_4232H_PID) }, |
190 | { USB_DEVICE(FTDI_VID, FTDI_232H_PID) }, | 190 | { USB_DEVICE(FTDI_VID, FTDI_232H_PID) }, |
191 | { USB_DEVICE(FTDI_VID, FTDI_FTX_PID) }, | ||
191 | { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, | 192 | { USB_DEVICE(FTDI_VID, FTDI_MICRO_CHAMELEON_PID) }, |
192 | { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, | 193 | { USB_DEVICE(FTDI_VID, FTDI_RELAIS_PID) }, |
193 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, | 194 | { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_PID) }, |
@@ -536,6 +537,10 @@ static struct usb_device_id id_table_combined [] = { | |||
536 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_6_PID) }, | 537 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_6_PID) }, |
537 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_7_PID) }, | 538 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_7_PID) }, |
538 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) }, | 539 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803_8_PID) }, |
540 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_1_PID) }, | ||
541 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_2_PID) }, | ||
542 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_3_PID) }, | ||
543 | { USB_DEVICE(SEALEVEL_VID, SEALEVEL_2803R_4_PID) }, | ||
539 | { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) }, | 544 | { USB_DEVICE(IDTECH_VID, IDTECH_IDT1221U_PID) }, |
540 | { USB_DEVICE(OCT_VID, OCT_US101_PID) }, | 545 | { USB_DEVICE(OCT_VID, OCT_US101_PID) }, |
541 | { USB_DEVICE(OCT_VID, OCT_DK201_PID) }, | 546 | { USB_DEVICE(OCT_VID, OCT_DK201_PID) }, |
@@ -797,7 +802,7 @@ static struct usb_device_id id_table_combined [] = { | |||
797 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 802 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
798 | { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), | 803 | { USB_DEVICE(ADI_VID, ADI_GNICEPLUS_PID), |
799 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 804 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
800 | { USB_DEVICE(HORNBY_VID, HORNBY_ELITE_PID) }, | 805 | { USB_DEVICE(MICROCHIP_VID, MICROCHIP_USB_BOARD_PID) }, |
801 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, | 806 | { USB_DEVICE(JETI_VID, JETI_SPC1201_PID) }, |
802 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), | 807 | { USB_DEVICE(MARVELL_VID, MARVELL_SHEEVAPLUG_PID), |
803 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | 808 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, |
@@ -846,6 +851,9 @@ static struct usb_device_id id_table_combined [] = { | |||
846 | { USB_DEVICE(ST_VID, ST_STMCLT1030_PID), | 851 | { USB_DEVICE(ST_VID, ST_STMCLT1030_PID), |
847 | .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, | 852 | .driver_info = (kernel_ulong_t)&ftdi_stmclite_quirk }, |
848 | { USB_DEVICE(FTDI_VID, FTDI_RF_R106) }, | 853 | { USB_DEVICE(FTDI_VID, FTDI_RF_R106) }, |
854 | { USB_DEVICE(FTDI_VID, FTDI_DISTORTEC_JTAG_LOCK_PICK_PID), | ||
855 | .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, | ||
856 | { USB_DEVICE(FTDI_VID, FTDI_LUMEL_PD12_PID) }, | ||
849 | { }, /* Optional parameter entry */ | 857 | { }, /* Optional parameter entry */ |
850 | { } /* Terminating entry */ | 858 | { } /* Terminating entry */ |
851 | }; | 859 | }; |
@@ -857,7 +865,6 @@ static struct usb_driver ftdi_driver = { | |||
857 | .probe = usb_serial_probe, | 865 | .probe = usb_serial_probe, |
858 | .disconnect = usb_serial_disconnect, | 866 | .disconnect = usb_serial_disconnect, |
859 | .id_table = id_table_combined, | 867 | .id_table = id_table_combined, |
860 | .no_dynamic_id = 1, | ||
861 | }; | 868 | }; |
862 | 869 | ||
863 | static const char *ftdi_chip_name[] = { | 870 | static const char *ftdi_chip_name[] = { |
@@ -868,7 +875,8 @@ static const char *ftdi_chip_name[] = { | |||
868 | [FT232RL] = "FT232RL", | 875 | [FT232RL] = "FT232RL", |
869 | [FT2232H] = "FT2232H", | 876 | [FT2232H] = "FT2232H", |
870 | [FT4232H] = "FT4232H", | 877 | [FT4232H] = "FT4232H", |
871 | [FT232H] = "FT232H" | 878 | [FT232H] = "FT232H", |
879 | [FTX] = "FT-X" | ||
872 | }; | 880 | }; |
873 | 881 | ||
874 | 882 | ||
@@ -915,7 +923,6 @@ static struct usb_serial_driver ftdi_sio_device = { | |||
915 | .name = "ftdi_sio", | 923 | .name = "ftdi_sio", |
916 | }, | 924 | }, |
917 | .description = "FTDI USB Serial Device", | 925 | .description = "FTDI USB Serial Device", |
918 | .usb_driver = &ftdi_driver, | ||
919 | .id_table = id_table_combined, | 926 | .id_table = id_table_combined, |
920 | .num_ports = 1, | 927 | .num_ports = 1, |
921 | .bulk_in_size = 512, | 928 | .bulk_in_size = 512, |
@@ -938,6 +945,10 @@ static struct usb_serial_driver ftdi_sio_device = { | |||
938 | .break_ctl = ftdi_break_ctl, | 945 | .break_ctl = ftdi_break_ctl, |
939 | }; | 946 | }; |
940 | 947 | ||
948 | static struct usb_serial_driver * const serial_drivers[] = { | ||
949 | &ftdi_sio_device, NULL | ||
950 | }; | ||
951 | |||
941 | 952 | ||
942 | #define WDR_TIMEOUT 5000 /* default urb timeout */ | 953 | #define WDR_TIMEOUT 5000 /* default urb timeout */ |
943 | #define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */ | 954 | #define WDR_SHORT_TIMEOUT 1000 /* shorter urb timeout */ |
@@ -1169,7 +1180,8 @@ static __u32 get_ftdi_divisor(struct tty_struct *tty, | |||
1169 | break; | 1180 | break; |
1170 | case FT232BM: /* FT232BM chip */ | 1181 | case FT232BM: /* FT232BM chip */ |
1171 | case FT2232C: /* FT2232C chip */ | 1182 | case FT2232C: /* FT2232C chip */ |
1172 | case FT232RL: | 1183 | case FT232RL: /* FT232RL chip */ |
1184 | case FTX: /* FT-X series */ | ||
1173 | if (baud <= 3000000) { | 1185 | if (baud <= 3000000) { |
1174 | __u16 product_id = le16_to_cpu( | 1186 | __u16 product_id = le16_to_cpu( |
1175 | port->serial->dev->descriptor.idProduct); | 1187 | port->serial->dev->descriptor.idProduct); |
@@ -1458,10 +1470,14 @@ static void ftdi_determine_type(struct usb_serial_port *port) | |||
1458 | } else if (version < 0x900) { | 1470 | } else if (version < 0x900) { |
1459 | /* Assume it's an FT232RL */ | 1471 | /* Assume it's an FT232RL */ |
1460 | priv->chip_type = FT232RL; | 1472 | priv->chip_type = FT232RL; |
1461 | } else { | 1473 | } else if (version < 0x1000) { |
1462 | /* Assume it's an FT232H */ | 1474 | /* Assume it's an FT232H */ |
1463 | priv->chip_type = FT232H; | 1475 | priv->chip_type = FT232H; |
1476 | } else { | ||
1477 | /* Assume it's an FT-X series device */ | ||
1478 | priv->chip_type = FTX; | ||
1464 | } | 1479 | } |
1480 | |||
1465 | dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); | 1481 | dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); |
1466 | } | 1482 | } |
1467 | 1483 | ||
@@ -1589,7 +1605,8 @@ static int create_sysfs_attrs(struct usb_serial_port *port) | |||
1589 | priv->chip_type == FT232RL || | 1605 | priv->chip_type == FT232RL || |
1590 | priv->chip_type == FT2232H || | 1606 | priv->chip_type == FT2232H || |
1591 | priv->chip_type == FT4232H || | 1607 | priv->chip_type == FT4232H || |
1592 | priv->chip_type == FT232H)) { | 1608 | priv->chip_type == FT232H || |
1609 | priv->chip_type == FTX)) { | ||
1593 | retval = device_create_file(&port->dev, | 1610 | retval = device_create_file(&port->dev, |
1594 | &dev_attr_latency_timer); | 1611 | &dev_attr_latency_timer); |
1595 | } | 1612 | } |
@@ -1611,7 +1628,8 @@ static void remove_sysfs_attrs(struct usb_serial_port *port) | |||
1611 | priv->chip_type == FT232RL || | 1628 | priv->chip_type == FT232RL || |
1612 | priv->chip_type == FT2232H || | 1629 | priv->chip_type == FT2232H || |
1613 | priv->chip_type == FT4232H || | 1630 | priv->chip_type == FT4232H || |
1614 | priv->chip_type == FT232H) { | 1631 | priv->chip_type == FT232H || |
1632 | priv->chip_type == FTX) { | ||
1615 | device_remove_file(&port->dev, &dev_attr_latency_timer); | 1633 | device_remove_file(&port->dev, &dev_attr_latency_timer); |
1616 | } | 1634 | } |
1617 | } | 1635 | } |
@@ -1763,7 +1781,8 @@ static int ftdi_8u2232c_probe(struct usb_serial *serial) | |||
1763 | 1781 | ||
1764 | dbg("%s", __func__); | 1782 | dbg("%s", __func__); |
1765 | 1783 | ||
1766 | if (strcmp(udev->manufacturer, "CALAO Systems") == 0) | 1784 | if ((udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) || |
1785 | (udev->product && !strcmp(udev->product, "BeagleBone/XDS100"))) | ||
1767 | return ftdi_jtag_probe(serial); | 1786 | return ftdi_jtag_probe(serial); |
1768 | 1787 | ||
1769 | return 0; | 1788 | return 0; |
@@ -2288,6 +2307,7 @@ static int ftdi_tiocmget(struct tty_struct *tty) | |||
2288 | case FT2232H: | 2307 | case FT2232H: |
2289 | case FT4232H: | 2308 | case FT4232H: |
2290 | case FT232H: | 2309 | case FT232H: |
2310 | case FTX: | ||
2291 | len = 2; | 2311 | len = 2; |
2292 | break; | 2312 | break; |
2293 | default: | 2313 | default: |
@@ -2420,19 +2440,10 @@ static int __init ftdi_init(void) | |||
2420 | id_table_combined[i].idVendor = vendor; | 2440 | id_table_combined[i].idVendor = vendor; |
2421 | id_table_combined[i].idProduct = product; | 2441 | id_table_combined[i].idProduct = product; |
2422 | } | 2442 | } |
2423 | retval = usb_serial_register(&ftdi_sio_device); | 2443 | retval = usb_serial_register_drivers(&ftdi_driver, serial_drivers); |
2424 | if (retval) | 2444 | if (retval == 0) |
2425 | goto failed_sio_register; | 2445 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
2426 | retval = usb_register(&ftdi_driver); | 2446 | DRIVER_DESC "\n"); |
2427 | if (retval) | ||
2428 | goto failed_usb_register; | ||
2429 | |||
2430 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
2431 | DRIVER_DESC "\n"); | ||
2432 | return 0; | ||
2433 | failed_usb_register: | ||
2434 | usb_serial_deregister(&ftdi_sio_device); | ||
2435 | failed_sio_register: | ||
2436 | return retval; | 2447 | return retval; |
2437 | } | 2448 | } |
2438 | 2449 | ||
@@ -2440,8 +2451,7 @@ static void __exit ftdi_exit(void) | |||
2440 | { | 2451 | { |
2441 | dbg("%s", __func__); | 2452 | dbg("%s", __func__); |
2442 | 2453 | ||
2443 | usb_deregister(&ftdi_driver); | 2454 | usb_serial_deregister_drivers(&ftdi_driver, serial_drivers); |
2444 | usb_serial_deregister(&ftdi_sio_device); | ||
2445 | } | 2455 | } |
2446 | 2456 | ||
2447 | 2457 | ||
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 19584faa86f9..ed58c6fa8dbe 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -157,7 +157,8 @@ enum ftdi_chip_type { | |||
157 | FT232RL = 5, | 157 | FT232RL = 5, |
158 | FT2232H = 6, | 158 | FT2232H = 6, |
159 | FT4232H = 7, | 159 | FT4232H = 7, |
160 | FT232H = 8 | 160 | FT232H = 8, |
161 | FTX = 9, | ||
161 | }; | 162 | }; |
162 | 163 | ||
163 | enum ftdi_sio_baudrate { | 164 | enum ftdi_sio_baudrate { |
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 6f6058f0db1b..0838baf892f3 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
@@ -23,12 +23,15 @@ | |||
23 | #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ | 23 | #define FTDI_8U2232C_PID 0x6010 /* Dual channel device */ |
24 | #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ | 24 | #define FTDI_4232H_PID 0x6011 /* Quad channel hi-speed device */ |
25 | #define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */ | 25 | #define FTDI_232H_PID 0x6014 /* Single channel hi-speed device */ |
26 | #define FTDI_FTX_PID 0x6015 /* FT-X series (FT201X, FT230X, FT231X, etc) */ | ||
26 | #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ | 27 | #define FTDI_SIO_PID 0x8372 /* Product Id SIO application of 8U100AX */ |
27 | #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ | 28 | #define FTDI_232RL_PID 0xFBFA /* Product ID for FT232RL */ |
28 | 29 | ||
29 | 30 | ||
30 | /*** third-party PIDs (using FTDI_VID) ***/ | 31 | /*** third-party PIDs (using FTDI_VID) ***/ |
31 | 32 | ||
33 | #define FTDI_LUMEL_PD12_PID 0x6002 | ||
34 | |||
32 | /* | 35 | /* |
33 | * Marvell OpenRD Base, Client | 36 | * Marvell OpenRD Base, Client |
34 | * http://www.open-rd.org | 37 | * http://www.open-rd.org |
@@ -97,6 +100,8 @@ | |||
97 | #define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */ | 100 | #define FTDI_TACTRIX_OPENPORT_13S_PID 0xCC49 /* OpenPort 1.3 Subaru */ |
98 | #define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */ | 101 | #define FTDI_TACTRIX_OPENPORT_13U_PID 0xCC4A /* OpenPort 1.3 Universal */ |
99 | 102 | ||
103 | #define FTDI_DISTORTEC_JTAG_LOCK_PICK_PID 0xCFF8 | ||
104 | |||
100 | /* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */ | 105 | /* SCS HF Radio Modems PID's (http://www.scs-ptc.com) */ |
101 | /* the VID is the standard ftdi vid (FTDI_VID) */ | 106 | /* the VID is the standard ftdi vid (FTDI_VID) */ |
102 | #define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */ | 107 | #define FTDI_SCS_DEVICE_0_PID 0xD010 /* SCS PTC-IIusb */ |
@@ -532,10 +537,14 @@ | |||
532 | #define ADI_GNICEPLUS_PID 0xF001 | 537 | #define ADI_GNICEPLUS_PID 0xF001 |
533 | 538 | ||
534 | /* | 539 | /* |
535 | * Hornby Elite | 540 | * Microchip Technology, Inc. |
541 | * | ||
542 | * MICROCHIP_VID (0x04D8) and MICROCHIP_USB_BOARD_PID (0x000A) are also used by: | ||
543 | * Hornby Elite - Digital Command Control Console | ||
544 | * http://www.hornby.com/hornby-dcc/controllers/ | ||
536 | */ | 545 | */ |
537 | #define HORNBY_VID 0x04D8 | 546 | #define MICROCHIP_VID 0x04D8 |
538 | #define HORNBY_ELITE_PID 0x000A | 547 | #define MICROCHIP_USB_BOARD_PID 0x000A /* CDC RS-232 Emulation Demo */ |
539 | 548 | ||
540 | /* | 549 | /* |
541 | * RATOC REX-USB60F | 550 | * RATOC REX-USB60F |
@@ -680,6 +689,10 @@ | |||
680 | #define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */ | 689 | #define SEALEVEL_2803_6_PID 0X2863 /* SeaLINK+8 (2803) Port 6 */ |
681 | #define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */ | 690 | #define SEALEVEL_2803_7_PID 0X2873 /* SeaLINK+8 (2803) Port 7 */ |
682 | #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */ | 691 | #define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */ |
692 | #define SEALEVEL_2803R_1_PID 0Xa02a /* SeaLINK+8 (2803-ROHS) Port 1+2 */ | ||
693 | #define SEALEVEL_2803R_2_PID 0Xa02b /* SeaLINK+8 (2803-ROHS) Port 3+4 */ | ||
694 | #define SEALEVEL_2803R_3_PID 0Xa02c /* SeaLINK+8 (2803-ROHS) Port 5+6 */ | ||
695 | #define SEALEVEL_2803R_4_PID 0Xa02d /* SeaLINK+8 (2803-ROHS) Port 7+8 */ | ||
683 | 696 | ||
684 | /* | 697 | /* |
685 | * JETI SPECTROMETER SPECBOS 1201 | 698 | * JETI SPECTROMETER SPECBOS 1201 |
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c index 5d4b099dcf8b..4577b3607922 100644 --- a/drivers/usb/serial/funsoft.c +++ b/drivers/usb/serial/funsoft.c | |||
@@ -29,7 +29,6 @@ static struct usb_driver funsoft_driver = { | |||
29 | .probe = usb_serial_probe, | 29 | .probe = usb_serial_probe, |
30 | .disconnect = usb_serial_disconnect, | 30 | .disconnect = usb_serial_disconnect, |
31 | .id_table = id_table, | 31 | .id_table = id_table, |
32 | .no_dynamic_id = 1, | ||
33 | }; | 32 | }; |
34 | 33 | ||
35 | static struct usb_serial_driver funsoft_device = { | 34 | static struct usb_serial_driver funsoft_device = { |
@@ -38,31 +37,15 @@ static struct usb_serial_driver funsoft_device = { | |||
38 | .name = "funsoft", | 37 | .name = "funsoft", |
39 | }, | 38 | }, |
40 | .id_table = id_table, | 39 | .id_table = id_table, |
41 | .usb_driver = &funsoft_driver, | ||
42 | .num_ports = 1, | 40 | .num_ports = 1, |
43 | }; | 41 | }; |
44 | 42 | ||
45 | static int __init funsoft_init(void) | 43 | static struct usb_serial_driver * const serial_drivers[] = { |
46 | { | 44 | &funsoft_device, NULL |
47 | int retval; | 45 | }; |
48 | |||
49 | retval = usb_serial_register(&funsoft_device); | ||
50 | if (retval) | ||
51 | return retval; | ||
52 | retval = usb_register(&funsoft_driver); | ||
53 | if (retval) | ||
54 | usb_serial_deregister(&funsoft_device); | ||
55 | return retval; | ||
56 | } | ||
57 | 46 | ||
58 | static void __exit funsoft_exit(void) | 47 | module_usb_serial_driver(funsoft_driver, serial_drivers); |
59 | { | ||
60 | usb_deregister(&funsoft_driver); | ||
61 | usb_serial_deregister(&funsoft_device); | ||
62 | } | ||
63 | 48 | ||
64 | module_init(funsoft_init); | ||
65 | module_exit(funsoft_exit); | ||
66 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
67 | 50 | ||
68 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 51 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c index 21343378c322..e8eb6347bf3a 100644 --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c | |||
@@ -224,7 +224,6 @@ static struct usb_driver garmin_driver = { | |||
224 | .probe = usb_serial_probe, | 224 | .probe = usb_serial_probe, |
225 | .disconnect = usb_serial_disconnect, | 225 | .disconnect = usb_serial_disconnect, |
226 | .id_table = id_table, | 226 | .id_table = id_table, |
227 | .no_dynamic_id = 1, | ||
228 | }; | 227 | }; |
229 | 228 | ||
230 | 229 | ||
@@ -1497,7 +1496,6 @@ static struct usb_serial_driver garmin_device = { | |||
1497 | .name = "garmin_gps", | 1496 | .name = "garmin_gps", |
1498 | }, | 1497 | }, |
1499 | .description = "Garmin GPS usb/tty", | 1498 | .description = "Garmin GPS usb/tty", |
1500 | .usb_driver = &garmin_driver, | ||
1501 | .id_table = id_table, | 1499 | .id_table = id_table, |
1502 | .num_ports = 1, | 1500 | .num_ports = 1, |
1503 | .open = garmin_open, | 1501 | .open = garmin_open, |
@@ -1514,40 +1512,11 @@ static struct usb_serial_driver garmin_device = { | |||
1514 | .read_int_callback = garmin_read_int_callback, | 1512 | .read_int_callback = garmin_read_int_callback, |
1515 | }; | 1513 | }; |
1516 | 1514 | ||
1515 | static struct usb_serial_driver * const serial_drivers[] = { | ||
1516 | &garmin_device, NULL | ||
1517 | }; | ||
1517 | 1518 | ||
1518 | 1519 | module_usb_serial_driver(garmin_driver, serial_drivers); | |
1519 | static int __init garmin_init(void) | ||
1520 | { | ||
1521 | int retval; | ||
1522 | |||
1523 | retval = usb_serial_register(&garmin_device); | ||
1524 | if (retval) | ||
1525 | goto failed_garmin_register; | ||
1526 | retval = usb_register(&garmin_driver); | ||
1527 | if (retval) | ||
1528 | goto failed_usb_register; | ||
1529 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1530 | DRIVER_DESC "\n"); | ||
1531 | |||
1532 | return 0; | ||
1533 | failed_usb_register: | ||
1534 | usb_serial_deregister(&garmin_device); | ||
1535 | failed_garmin_register: | ||
1536 | return retval; | ||
1537 | } | ||
1538 | |||
1539 | |||
1540 | static void __exit garmin_exit(void) | ||
1541 | { | ||
1542 | usb_deregister(&garmin_driver); | ||
1543 | usb_serial_deregister(&garmin_device); | ||
1544 | } | ||
1545 | |||
1546 | |||
1547 | |||
1548 | |||
1549 | module_init(garmin_init); | ||
1550 | module_exit(garmin_exit); | ||
1551 | 1520 | ||
1552 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1521 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1553 | MODULE_DESCRIPTION(DRIVER_DESC); | 1522 | MODULE_DESCRIPTION(DRIVER_DESC); |
@@ -1557,4 +1526,3 @@ module_param(debug, bool, S_IWUSR | S_IRUGO); | |||
1557 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 1526 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
1558 | module_param(initial_mode, int, S_IRUGO); | 1527 | module_param(initial_mode, int, S_IRUGO); |
1559 | MODULE_PARM_DESC(initial_mode, "Initial mode"); | 1528 | MODULE_PARM_DESC(initial_mode, "Initial mode"); |
1560 | |||
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c index f7403576f99f..664deb63807c 100644 --- a/drivers/usb/serial/generic.c +++ b/drivers/usb/serial/generic.c | |||
@@ -54,7 +54,6 @@ static struct usb_driver generic_driver = { | |||
54 | .probe = generic_probe, | 54 | .probe = generic_probe, |
55 | .disconnect = usb_serial_disconnect, | 55 | .disconnect = usb_serial_disconnect, |
56 | .id_table = generic_serial_ids, | 56 | .id_table = generic_serial_ids, |
57 | .no_dynamic_id = 1, | ||
58 | }; | 57 | }; |
59 | 58 | ||
60 | /* All of the device info needed for the Generic Serial Converter */ | 59 | /* All of the device info needed for the Generic Serial Converter */ |
@@ -64,7 +63,6 @@ struct usb_serial_driver usb_serial_generic_device = { | |||
64 | .name = "generic", | 63 | .name = "generic", |
65 | }, | 64 | }, |
66 | .id_table = generic_device_ids, | 65 | .id_table = generic_device_ids, |
67 | .usb_driver = &generic_driver, | ||
68 | .num_ports = 1, | 66 | .num_ports = 1, |
69 | .disconnect = usb_serial_generic_disconnect, | 67 | .disconnect = usb_serial_generic_disconnect, |
70 | .release = usb_serial_generic_release, | 68 | .release = usb_serial_generic_release, |
@@ -73,6 +71,10 @@ struct usb_serial_driver usb_serial_generic_device = { | |||
73 | .resume = usb_serial_generic_resume, | 71 | .resume = usb_serial_generic_resume, |
74 | }; | 72 | }; |
75 | 73 | ||
74 | static struct usb_serial_driver * const serial_drivers[] = { | ||
75 | &usb_serial_generic_device, NULL | ||
76 | }; | ||
77 | |||
76 | static int generic_probe(struct usb_interface *interface, | 78 | static int generic_probe(struct usb_interface *interface, |
77 | const struct usb_device_id *id) | 79 | const struct usb_device_id *id) |
78 | { | 80 | { |
@@ -97,13 +99,7 @@ int usb_serial_generic_register(int _debug) | |||
97 | USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; | 99 | USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT; |
98 | 100 | ||
99 | /* register our generic driver with ourselves */ | 101 | /* register our generic driver with ourselves */ |
100 | retval = usb_serial_register(&usb_serial_generic_device); | 102 | retval = usb_serial_register_drivers(&generic_driver, serial_drivers); |
101 | if (retval) | ||
102 | goto exit; | ||
103 | retval = usb_register(&generic_driver); | ||
104 | if (retval) | ||
105 | usb_serial_deregister(&usb_serial_generic_device); | ||
106 | exit: | ||
107 | #endif | 103 | #endif |
108 | return retval; | 104 | return retval; |
109 | } | 105 | } |
@@ -112,8 +108,7 @@ void usb_serial_generic_deregister(void) | |||
112 | { | 108 | { |
113 | #ifdef CONFIG_USB_SERIAL_GENERIC | 109 | #ifdef CONFIG_USB_SERIAL_GENERIC |
114 | /* remove our generic driver */ | 110 | /* remove our generic driver */ |
115 | usb_deregister(&generic_driver); | 111 | usb_serial_deregister_drivers(&generic_driver, serial_drivers); |
116 | usb_serial_deregister(&usb_serial_generic_device); | ||
117 | #endif | 112 | #endif |
118 | } | 113 | } |
119 | 114 | ||
@@ -217,7 +212,7 @@ retry: | |||
217 | clear_bit(i, &port->write_urbs_free); | 212 | clear_bit(i, &port->write_urbs_free); |
218 | result = usb_submit_urb(urb, GFP_ATOMIC); | 213 | result = usb_submit_urb(urb, GFP_ATOMIC); |
219 | if (result) { | 214 | if (result) { |
220 | dev_err(&port->dev, "%s - error submitting urb: %d\n", | 215 | dev_err_console(port, "%s - error submitting urb: %d\n", |
221 | __func__, result); | 216 | __func__, result); |
222 | set_bit(i, &port->write_urbs_free); | 217 | set_bit(i, &port->write_urbs_free); |
223 | spin_lock_irqsave(&port->lock, flags); | 218 | spin_lock_irqsave(&port->lock, flags); |
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c index 809379159b0e..2563e788c9b3 100644 --- a/drivers/usb/serial/hp4x.c +++ b/drivers/usb/serial/hp4x.c | |||
@@ -41,7 +41,6 @@ static struct usb_driver hp49gp_driver = { | |||
41 | .probe = usb_serial_probe, | 41 | .probe = usb_serial_probe, |
42 | .disconnect = usb_serial_disconnect, | 42 | .disconnect = usb_serial_disconnect, |
43 | .id_table = id_table, | 43 | .id_table = id_table, |
44 | .no_dynamic_id = 1, | ||
45 | }; | 44 | }; |
46 | 45 | ||
47 | static struct usb_serial_driver hp49gp_device = { | 46 | static struct usb_serial_driver hp49gp_device = { |
@@ -50,36 +49,14 @@ static struct usb_serial_driver hp49gp_device = { | |||
50 | .name = "hp4X", | 49 | .name = "hp4X", |
51 | }, | 50 | }, |
52 | .id_table = id_table, | 51 | .id_table = id_table, |
53 | .usb_driver = &hp49gp_driver, | ||
54 | .num_ports = 1, | 52 | .num_ports = 1, |
55 | }; | 53 | }; |
56 | 54 | ||
57 | static int __init hp49gp_init(void) | 55 | static struct usb_serial_driver * const serial_drivers[] = { |
58 | { | 56 | &hp49gp_device, NULL |
59 | int retval; | 57 | }; |
60 | retval = usb_serial_register(&hp49gp_device); | ||
61 | if (retval) | ||
62 | goto failed_usb_serial_register; | ||
63 | retval = usb_register(&hp49gp_driver); | ||
64 | if (retval) | ||
65 | goto failed_usb_register; | ||
66 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
67 | DRIVER_DESC "\n"); | ||
68 | return 0; | ||
69 | failed_usb_register: | ||
70 | usb_serial_deregister(&hp49gp_device); | ||
71 | failed_usb_serial_register: | ||
72 | return retval; | ||
73 | } | ||
74 | |||
75 | static void __exit hp49gp_exit(void) | ||
76 | { | ||
77 | usb_deregister(&hp49gp_driver); | ||
78 | usb_serial_deregister(&hp49gp_device); | ||
79 | } | ||
80 | 58 | ||
81 | module_init(hp49gp_init); | 59 | module_usb_serial_driver(hp49gp_driver, serial_drivers); |
82 | module_exit(hp49gp_exit); | ||
83 | 60 | ||
84 | MODULE_DESCRIPTION(DRIVER_DESC); | 61 | MODULE_DESCRIPTION(DRIVER_DESC); |
85 | MODULE_VERSION(DRIVER_VERSION); | 62 | MODULE_VERSION(DRIVER_VERSION); |
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index 0497575e4799..323e87235711 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c | |||
@@ -193,7 +193,8 @@ static const struct divisor_table_entry divisor_table[] = { | |||
193 | /* local variables */ | 193 | /* local variables */ |
194 | static bool debug; | 194 | static bool debug; |
195 | 195 | ||
196 | static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */ | 196 | /* Number of outstanding Command Write Urbs */ |
197 | static atomic_t CmdUrbs = ATOMIC_INIT(0); | ||
197 | 198 | ||
198 | 199 | ||
199 | /* local function prototypes */ | 200 | /* local function prototypes */ |
@@ -1286,7 +1287,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1286 | count = fifo->count; | 1287 | count = fifo->count; |
1287 | buffer = kmalloc(count+2, GFP_ATOMIC); | 1288 | buffer = kmalloc(count+2, GFP_ATOMIC); |
1288 | if (buffer == NULL) { | 1289 | if (buffer == NULL) { |
1289 | dev_err(&edge_port->port->dev, | 1290 | dev_err_console(edge_port->port, |
1290 | "%s - no more kernel memory...\n", __func__); | 1291 | "%s - no more kernel memory...\n", __func__); |
1291 | edge_port->write_in_progress = false; | 1292 | edge_port->write_in_progress = false; |
1292 | goto exit_send; | 1293 | goto exit_send; |
@@ -1331,7 +1332,7 @@ static void send_more_port_data(struct edgeport_serial *edge_serial, | |||
1331 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1332 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1332 | if (status) { | 1333 | if (status) { |
1333 | /* something went wrong */ | 1334 | /* something went wrong */ |
1334 | dev_err(&edge_port->port->dev, | 1335 | dev_err_console(edge_port->port, |
1335 | "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", | 1336 | "%s - usb_submit_urb(write bulk) failed, status = %d, data lost\n", |
1336 | __func__, status); | 1337 | __func__, status); |
1337 | edge_port->write_in_progress = false; | 1338 | edge_port->write_in_progress = false; |
@@ -3180,65 +3181,8 @@ static void edge_release(struct usb_serial *serial) | |||
3180 | kfree(edge_serial); | 3181 | kfree(edge_serial); |
3181 | } | 3182 | } |
3182 | 3183 | ||
3184 | module_usb_serial_driver(io_driver, serial_drivers); | ||
3183 | 3185 | ||
3184 | /**************************************************************************** | ||
3185 | * edgeport_init | ||
3186 | * This is called by the module subsystem, or on startup to initialize us | ||
3187 | ****************************************************************************/ | ||
3188 | static int __init edgeport_init(void) | ||
3189 | { | ||
3190 | int retval; | ||
3191 | |||
3192 | retval = usb_serial_register(&edgeport_2port_device); | ||
3193 | if (retval) | ||
3194 | goto failed_2port_device_register; | ||
3195 | retval = usb_serial_register(&edgeport_4port_device); | ||
3196 | if (retval) | ||
3197 | goto failed_4port_device_register; | ||
3198 | retval = usb_serial_register(&edgeport_8port_device); | ||
3199 | if (retval) | ||
3200 | goto failed_8port_device_register; | ||
3201 | retval = usb_serial_register(&epic_device); | ||
3202 | if (retval) | ||
3203 | goto failed_epic_device_register; | ||
3204 | retval = usb_register(&io_driver); | ||
3205 | if (retval) | ||
3206 | goto failed_usb_register; | ||
3207 | atomic_set(&CmdUrbs, 0); | ||
3208 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
3209 | DRIVER_DESC "\n"); | ||
3210 | return 0; | ||
3211 | |||
3212 | failed_usb_register: | ||
3213 | usb_serial_deregister(&epic_device); | ||
3214 | failed_epic_device_register: | ||
3215 | usb_serial_deregister(&edgeport_8port_device); | ||
3216 | failed_8port_device_register: | ||
3217 | usb_serial_deregister(&edgeport_4port_device); | ||
3218 | failed_4port_device_register: | ||
3219 | usb_serial_deregister(&edgeport_2port_device); | ||
3220 | failed_2port_device_register: | ||
3221 | return retval; | ||
3222 | } | ||
3223 | |||
3224 | |||
3225 | /**************************************************************************** | ||
3226 | * edgeport_exit | ||
3227 | * Called when the driver is about to be unloaded. | ||
3228 | ****************************************************************************/ | ||
3229 | static void __exit edgeport_exit (void) | ||
3230 | { | ||
3231 | usb_deregister(&io_driver); | ||
3232 | usb_serial_deregister(&edgeport_2port_device); | ||
3233 | usb_serial_deregister(&edgeport_4port_device); | ||
3234 | usb_serial_deregister(&edgeport_8port_device); | ||
3235 | usb_serial_deregister(&epic_device); | ||
3236 | } | ||
3237 | |||
3238 | module_init(edgeport_init); | ||
3239 | module_exit(edgeport_exit); | ||
3240 | |||
3241 | /* Module information */ | ||
3242 | MODULE_AUTHOR(DRIVER_AUTHOR); | 3186 | MODULE_AUTHOR(DRIVER_AUTHOR); |
3243 | MODULE_DESCRIPTION(DRIVER_DESC); | 3187 | MODULE_DESCRIPTION(DRIVER_DESC); |
3244 | MODULE_LICENSE("GPL"); | 3188 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h index 178b22eb32b1..d0e7c9affb6f 100644 --- a/drivers/usb/serial/io_tables.h +++ b/drivers/usb/serial/io_tables.h | |||
@@ -100,7 +100,6 @@ static struct usb_driver io_driver = { | |||
100 | .probe = usb_serial_probe, | 100 | .probe = usb_serial_probe, |
101 | .disconnect = usb_serial_disconnect, | 101 | .disconnect = usb_serial_disconnect, |
102 | .id_table = id_table_combined, | 102 | .id_table = id_table_combined, |
103 | .no_dynamic_id = 1, | ||
104 | }; | 103 | }; |
105 | 104 | ||
106 | static struct usb_serial_driver edgeport_2port_device = { | 105 | static struct usb_serial_driver edgeport_2port_device = { |
@@ -109,7 +108,6 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
109 | .name = "edgeport_2", | 108 | .name = "edgeport_2", |
110 | }, | 109 | }, |
111 | .description = "Edgeport 2 port adapter", | 110 | .description = "Edgeport 2 port adapter", |
112 | .usb_driver = &io_driver, | ||
113 | .id_table = edgeport_2port_id_table, | 111 | .id_table = edgeport_2port_id_table, |
114 | .num_ports = 2, | 112 | .num_ports = 2, |
115 | .open = edge_open, | 113 | .open = edge_open, |
@@ -139,7 +137,6 @@ static struct usb_serial_driver edgeport_4port_device = { | |||
139 | .name = "edgeport_4", | 137 | .name = "edgeport_4", |
140 | }, | 138 | }, |
141 | .description = "Edgeport 4 port adapter", | 139 | .description = "Edgeport 4 port adapter", |
142 | .usb_driver = &io_driver, | ||
143 | .id_table = edgeport_4port_id_table, | 140 | .id_table = edgeport_4port_id_table, |
144 | .num_ports = 4, | 141 | .num_ports = 4, |
145 | .open = edge_open, | 142 | .open = edge_open, |
@@ -169,7 +166,6 @@ static struct usb_serial_driver edgeport_8port_device = { | |||
169 | .name = "edgeport_8", | 166 | .name = "edgeport_8", |
170 | }, | 167 | }, |
171 | .description = "Edgeport 8 port adapter", | 168 | .description = "Edgeport 8 port adapter", |
172 | .usb_driver = &io_driver, | ||
173 | .id_table = edgeport_8port_id_table, | 169 | .id_table = edgeport_8port_id_table, |
174 | .num_ports = 8, | 170 | .num_ports = 8, |
175 | .open = edge_open, | 171 | .open = edge_open, |
@@ -199,7 +195,6 @@ static struct usb_serial_driver epic_device = { | |||
199 | .name = "epic", | 195 | .name = "epic", |
200 | }, | 196 | }, |
201 | .description = "EPiC device", | 197 | .description = "EPiC device", |
202 | .usb_driver = &io_driver, | ||
203 | .id_table = Epic_port_id_table, | 198 | .id_table = Epic_port_id_table, |
204 | .num_ports = 1, | 199 | .num_ports = 1, |
205 | .open = edge_open, | 200 | .open = edge_open, |
@@ -223,5 +218,10 @@ static struct usb_serial_driver epic_device = { | |||
223 | .write_bulk_callback = edge_bulk_out_data_callback, | 218 | .write_bulk_callback = edge_bulk_out_data_callback, |
224 | }; | 219 | }; |
225 | 220 | ||
221 | static struct usb_serial_driver * const serial_drivers[] = { | ||
222 | &edgeport_2port_device, &edgeport_4port_device, | ||
223 | &edgeport_8port_device, &epic_device, NULL | ||
224 | }; | ||
225 | |||
226 | #endif | 226 | #endif |
227 | 227 | ||
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index 5818bfc3261e..40a95a7fe383 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c | |||
@@ -202,7 +202,6 @@ static struct usb_driver io_driver = { | |||
202 | .probe = usb_serial_probe, | 202 | .probe = usb_serial_probe, |
203 | .disconnect = usb_serial_disconnect, | 203 | .disconnect = usb_serial_disconnect, |
204 | .id_table = id_table_combined, | 204 | .id_table = id_table_combined, |
205 | .no_dynamic_id = 1, | ||
206 | }; | 205 | }; |
207 | 206 | ||
208 | 207 | ||
@@ -1817,7 +1816,7 @@ static void edge_bulk_out_callback(struct urb *urb) | |||
1817 | __func__, status); | 1816 | __func__, status); |
1818 | return; | 1817 | return; |
1819 | default: | 1818 | default: |
1820 | dev_err(&urb->dev->dev, "%s - nonzero write bulk status " | 1819 | dev_err_console(port, "%s - nonzero write bulk status " |
1821 | "received: %d\n", __func__, status); | 1820 | "received: %d\n", __func__, status); |
1822 | } | 1821 | } |
1823 | 1822 | ||
@@ -2111,7 +2110,7 @@ static void edge_send(struct tty_struct *tty) | |||
2111 | /* send the data out the bulk port */ | 2110 | /* send the data out the bulk port */ |
2112 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 2111 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
2113 | if (result) { | 2112 | if (result) { |
2114 | dev_err(&port->dev, | 2113 | dev_err_console(port, |
2115 | "%s - failed submitting write urb, error %d\n", | 2114 | "%s - failed submitting write urb, error %d\n", |
2116 | __func__, result); | 2115 | __func__, result); |
2117 | edge_port->ep_write_urb_in_use = 0; | 2116 | edge_port->ep_write_urb_in_use = 0; |
@@ -2725,7 +2724,6 @@ static struct usb_serial_driver edgeport_1port_device = { | |||
2725 | .name = "edgeport_ti_1", | 2724 | .name = "edgeport_ti_1", |
2726 | }, | 2725 | }, |
2727 | .description = "Edgeport TI 1 port adapter", | 2726 | .description = "Edgeport TI 1 port adapter", |
2728 | .usb_driver = &io_driver, | ||
2729 | .id_table = edgeport_1port_id_table, | 2727 | .id_table = edgeport_1port_id_table, |
2730 | .num_ports = 1, | 2728 | .num_ports = 1, |
2731 | .open = edge_open, | 2729 | .open = edge_open, |
@@ -2757,7 +2755,6 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
2757 | .name = "edgeport_ti_2", | 2755 | .name = "edgeport_ti_2", |
2758 | }, | 2756 | }, |
2759 | .description = "Edgeport TI 2 port adapter", | 2757 | .description = "Edgeport TI 2 port adapter", |
2760 | .usb_driver = &io_driver, | ||
2761 | .id_table = edgeport_2port_id_table, | 2758 | .id_table = edgeport_2port_id_table, |
2762 | .num_ports = 2, | 2759 | .num_ports = 2, |
2763 | .open = edge_open, | 2760 | .open = edge_open, |
@@ -2782,41 +2779,12 @@ static struct usb_serial_driver edgeport_2port_device = { | |||
2782 | .write_bulk_callback = edge_bulk_out_callback, | 2779 | .write_bulk_callback = edge_bulk_out_callback, |
2783 | }; | 2780 | }; |
2784 | 2781 | ||
2782 | static struct usb_serial_driver * const serial_drivers[] = { | ||
2783 | &edgeport_1port_device, &edgeport_2port_device, NULL | ||
2784 | }; | ||
2785 | 2785 | ||
2786 | static int __init edgeport_init(void) | 2786 | module_usb_serial_driver(io_driver, serial_drivers); |
2787 | { | ||
2788 | int retval; | ||
2789 | retval = usb_serial_register(&edgeport_1port_device); | ||
2790 | if (retval) | ||
2791 | goto failed_1port_device_register; | ||
2792 | retval = usb_serial_register(&edgeport_2port_device); | ||
2793 | if (retval) | ||
2794 | goto failed_2port_device_register; | ||
2795 | retval = usb_register(&io_driver); | ||
2796 | if (retval) | ||
2797 | goto failed_usb_register; | ||
2798 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
2799 | DRIVER_DESC "\n"); | ||
2800 | return 0; | ||
2801 | failed_usb_register: | ||
2802 | usb_serial_deregister(&edgeport_2port_device); | ||
2803 | failed_2port_device_register: | ||
2804 | usb_serial_deregister(&edgeport_1port_device); | ||
2805 | failed_1port_device_register: | ||
2806 | return retval; | ||
2807 | } | ||
2808 | |||
2809 | static void __exit edgeport_exit(void) | ||
2810 | { | ||
2811 | usb_deregister(&io_driver); | ||
2812 | usb_serial_deregister(&edgeport_1port_device); | ||
2813 | usb_serial_deregister(&edgeport_2port_device); | ||
2814 | } | ||
2815 | |||
2816 | module_init(edgeport_init); | ||
2817 | module_exit(edgeport_exit); | ||
2818 | 2787 | ||
2819 | /* Module information */ | ||
2820 | MODULE_AUTHOR(DRIVER_AUTHOR); | 2788 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2821 | MODULE_DESCRIPTION(DRIVER_DESC); | 2789 | MODULE_DESCRIPTION(DRIVER_DESC); |
2822 | MODULE_LICENSE("GPL"); | 2790 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index 06053a920dd8..10c02b8b5664 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c | |||
@@ -510,7 +510,6 @@ static struct usb_driver ipaq_driver = { | |||
510 | .probe = usb_serial_probe, | 510 | .probe = usb_serial_probe, |
511 | .disconnect = usb_serial_disconnect, | 511 | .disconnect = usb_serial_disconnect, |
512 | .id_table = ipaq_id_table, | 512 | .id_table = ipaq_id_table, |
513 | .no_dynamic_id = 1, | ||
514 | }; | 513 | }; |
515 | 514 | ||
516 | 515 | ||
@@ -521,7 +520,6 @@ static struct usb_serial_driver ipaq_device = { | |||
521 | .name = "ipaq", | 520 | .name = "ipaq", |
522 | }, | 521 | }, |
523 | .description = "PocketPC PDA", | 522 | .description = "PocketPC PDA", |
524 | .usb_driver = &ipaq_driver, | ||
525 | .id_table = ipaq_id_table, | 523 | .id_table = ipaq_id_table, |
526 | .bulk_in_size = 256, | 524 | .bulk_in_size = 256, |
527 | .bulk_out_size = 256, | 525 | .bulk_out_size = 256, |
@@ -530,6 +528,10 @@ static struct usb_serial_driver ipaq_device = { | |||
530 | .calc_num_ports = ipaq_calc_num_ports, | 528 | .calc_num_ports = ipaq_calc_num_ports, |
531 | }; | 529 | }; |
532 | 530 | ||
531 | static struct usb_serial_driver * const serial_drivers[] = { | ||
532 | &ipaq_device, NULL | ||
533 | }; | ||
534 | |||
533 | static int ipaq_open(struct tty_struct *tty, | 535 | static int ipaq_open(struct tty_struct *tty, |
534 | struct usb_serial_port *port) | 536 | struct usb_serial_port *port) |
535 | { | 537 | { |
@@ -624,30 +626,22 @@ static int ipaq_startup(struct usb_serial *serial) | |||
624 | static int __init ipaq_init(void) | 626 | static int __init ipaq_init(void) |
625 | { | 627 | { |
626 | int retval; | 628 | int retval; |
627 | retval = usb_serial_register(&ipaq_device); | 629 | |
628 | if (retval) | ||
629 | goto failed_usb_serial_register; | ||
630 | if (vendor) { | 630 | if (vendor) { |
631 | ipaq_id_table[0].idVendor = vendor; | 631 | ipaq_id_table[0].idVendor = vendor; |
632 | ipaq_id_table[0].idProduct = product; | 632 | ipaq_id_table[0].idProduct = product; |
633 | } | 633 | } |
634 | retval = usb_register(&ipaq_driver); | 634 | |
635 | if (retval) | 635 | retval = usb_serial_register_drivers(&ipaq_driver, serial_drivers); |
636 | goto failed_usb_register; | 636 | if (retval == 0) |
637 | 637 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | |
638 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | 638 | DRIVER_DESC "\n"); |
639 | DRIVER_DESC "\n"); | ||
640 | return 0; | ||
641 | failed_usb_register: | ||
642 | usb_serial_deregister(&ipaq_device); | ||
643 | failed_usb_serial_register: | ||
644 | return retval; | 639 | return retval; |
645 | } | 640 | } |
646 | 641 | ||
647 | static void __exit ipaq_exit(void) | 642 | static void __exit ipaq_exit(void) |
648 | { | 643 | { |
649 | usb_deregister(&ipaq_driver); | 644 | usb_serial_deregister_drivers(&ipaq_driver, serial_drivers); |
650 | usb_serial_deregister(&ipaq_device); | ||
651 | } | 645 | } |
652 | 646 | ||
653 | 647 | ||
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index 6f9356f3f99e..76a06406e26a 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c | |||
@@ -144,7 +144,6 @@ static struct usb_driver usb_ipw_driver = { | |||
144 | .probe = usb_serial_probe, | 144 | .probe = usb_serial_probe, |
145 | .disconnect = usb_serial_disconnect, | 145 | .disconnect = usb_serial_disconnect, |
146 | .id_table = usb_ipw_ids, | 146 | .id_table = usb_ipw_ids, |
147 | .no_dynamic_id = 1, | ||
148 | }; | 147 | }; |
149 | 148 | ||
150 | static bool debug; | 149 | static bool debug; |
@@ -318,7 +317,6 @@ static struct usb_serial_driver ipw_device = { | |||
318 | .name = "ipw", | 317 | .name = "ipw", |
319 | }, | 318 | }, |
320 | .description = "IPWireless converter", | 319 | .description = "IPWireless converter", |
321 | .usb_driver = &usb_ipw_driver, | ||
322 | .id_table = usb_ipw_ids, | 320 | .id_table = usb_ipw_ids, |
323 | .num_ports = 1, | 321 | .num_ports = 1, |
324 | .disconnect = usb_wwan_disconnect, | 322 | .disconnect = usb_wwan_disconnect, |
@@ -331,33 +329,11 @@ static struct usb_serial_driver ipw_device = { | |||
331 | .write = usb_wwan_write, | 329 | .write = usb_wwan_write, |
332 | }; | 330 | }; |
333 | 331 | ||
332 | static struct usb_serial_driver * const serial_drivers[] = { | ||
333 | &ipw_device, NULL | ||
334 | }; | ||
334 | 335 | ||
335 | 336 | module_usb_serial_driver(usb_ipw_driver, serial_drivers); | |
336 | static int __init usb_ipw_init(void) | ||
337 | { | ||
338 | int retval; | ||
339 | |||
340 | retval = usb_serial_register(&ipw_device); | ||
341 | if (retval) | ||
342 | return retval; | ||
343 | retval = usb_register(&usb_ipw_driver); | ||
344 | if (retval) { | ||
345 | usb_serial_deregister(&ipw_device); | ||
346 | return retval; | ||
347 | } | ||
348 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
349 | DRIVER_DESC "\n"); | ||
350 | return 0; | ||
351 | } | ||
352 | |||
353 | static void __exit usb_ipw_exit(void) | ||
354 | { | ||
355 | usb_deregister(&usb_ipw_driver); | ||
356 | usb_serial_deregister(&ipw_device); | ||
357 | } | ||
358 | |||
359 | module_init(usb_ipw_init); | ||
360 | module_exit(usb_ipw_exit); | ||
361 | 337 | ||
362 | /* Module information */ | 338 | /* Module information */ |
363 | MODULE_AUTHOR(DRIVER_AUTHOR); | 339 | MODULE_AUTHOR(DRIVER_AUTHOR); |
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c index 84a396e83671..84965cd65c76 100644 --- a/drivers/usb/serial/ir-usb.c +++ b/drivers/usb/serial/ir-usb.c | |||
@@ -82,7 +82,6 @@ static struct usb_driver ir_driver = { | |||
82 | .probe = usb_serial_probe, | 82 | .probe = usb_serial_probe, |
83 | .disconnect = usb_serial_disconnect, | 83 | .disconnect = usb_serial_disconnect, |
84 | .id_table = ir_id_table, | 84 | .id_table = ir_id_table, |
85 | .no_dynamic_id = 1, | ||
86 | }; | 85 | }; |
87 | 86 | ||
88 | static struct usb_serial_driver ir_device = { | 87 | static struct usb_serial_driver ir_device = { |
@@ -91,7 +90,6 @@ static struct usb_serial_driver ir_device = { | |||
91 | .name = "ir-usb", | 90 | .name = "ir-usb", |
92 | }, | 91 | }, |
93 | .description = "IR Dongle", | 92 | .description = "IR Dongle", |
94 | .usb_driver = &ir_driver, | ||
95 | .id_table = ir_id_table, | 93 | .id_table = ir_id_table, |
96 | .num_ports = 1, | 94 | .num_ports = 1, |
97 | .set_termios = ir_set_termios, | 95 | .set_termios = ir_set_termios, |
@@ -101,6 +99,10 @@ static struct usb_serial_driver ir_device = { | |||
101 | .process_read_urb = ir_process_read_urb, | 99 | .process_read_urb = ir_process_read_urb, |
102 | }; | 100 | }; |
103 | 101 | ||
102 | static struct usb_serial_driver * const serial_drivers[] = { | ||
103 | &ir_device, NULL | ||
104 | }; | ||
105 | |||
104 | static inline void irda_usb_dump_class_desc(struct usb_irda_cs_descriptor *desc) | 106 | static inline void irda_usb_dump_class_desc(struct usb_irda_cs_descriptor *desc) |
105 | { | 107 | { |
106 | dbg("bLength=%x", desc->bLength); | 108 | dbg("bLength=%x", desc->bLength); |
@@ -445,30 +447,16 @@ static int __init ir_init(void) | |||
445 | ir_device.bulk_out_size = buffer_size; | 447 | ir_device.bulk_out_size = buffer_size; |
446 | } | 448 | } |
447 | 449 | ||
448 | retval = usb_serial_register(&ir_device); | 450 | retval = usb_serial_register_drivers(&ir_driver, serial_drivers); |
449 | if (retval) | 451 | if (retval == 0) |
450 | goto failed_usb_serial_register; | 452 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
451 | 453 | DRIVER_DESC "\n"); | |
452 | retval = usb_register(&ir_driver); | ||
453 | if (retval) | ||
454 | goto failed_usb_register; | ||
455 | |||
456 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
457 | DRIVER_DESC "\n"); | ||
458 | |||
459 | return 0; | ||
460 | |||
461 | failed_usb_register: | ||
462 | usb_serial_deregister(&ir_device); | ||
463 | |||
464 | failed_usb_serial_register: | ||
465 | return retval; | 454 | return retval; |
466 | } | 455 | } |
467 | 456 | ||
468 | static void __exit ir_exit(void) | 457 | static void __exit ir_exit(void) |
469 | { | 458 | { |
470 | usb_deregister(&ir_driver); | 459 | usb_serial_deregister_drivers(&ir_driver, serial_drivers); |
471 | usb_serial_deregister(&ir_device); | ||
472 | } | 460 | } |
473 | 461 | ||
474 | 462 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 3077a4436976..f2192d527db0 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -56,7 +56,6 @@ static struct usb_driver iuu_driver = { | |||
56 | .probe = usb_serial_probe, | 56 | .probe = usb_serial_probe, |
57 | .disconnect = usb_serial_disconnect, | 57 | .disconnect = usb_serial_disconnect, |
58 | .id_table = id_table, | 58 | .id_table = id_table, |
59 | .no_dynamic_id = 1, | ||
60 | }; | 59 | }; |
61 | 60 | ||
62 | /* turbo parameter */ | 61 | /* turbo parameter */ |
@@ -1274,7 +1273,6 @@ static struct usb_serial_driver iuu_device = { | |||
1274 | .name = "iuu_phoenix", | 1273 | .name = "iuu_phoenix", |
1275 | }, | 1274 | }, |
1276 | .id_table = id_table, | 1275 | .id_table = id_table, |
1277 | .usb_driver = &iuu_driver, | ||
1278 | .num_ports = 1, | 1276 | .num_ports = 1, |
1279 | .bulk_in_size = 512, | 1277 | .bulk_in_size = 512, |
1280 | .bulk_out_size = 512, | 1278 | .bulk_out_size = 512, |
@@ -1292,32 +1290,11 @@ static struct usb_serial_driver iuu_device = { | |||
1292 | .release = iuu_release, | 1290 | .release = iuu_release, |
1293 | }; | 1291 | }; |
1294 | 1292 | ||
1295 | static int __init iuu_init(void) | 1293 | static struct usb_serial_driver * const serial_drivers[] = { |
1296 | { | 1294 | &iuu_device, NULL |
1297 | int retval; | 1295 | }; |
1298 | retval = usb_serial_register(&iuu_device); | ||
1299 | if (retval) | ||
1300 | goto failed_usb_serial_register; | ||
1301 | retval = usb_register(&iuu_driver); | ||
1302 | if (retval) | ||
1303 | goto failed_usb_register; | ||
1304 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1305 | DRIVER_DESC "\n"); | ||
1306 | return 0; | ||
1307 | failed_usb_register: | ||
1308 | usb_serial_deregister(&iuu_device); | ||
1309 | failed_usb_serial_register: | ||
1310 | return retval; | ||
1311 | } | ||
1312 | |||
1313 | static void __exit iuu_exit(void) | ||
1314 | { | ||
1315 | usb_deregister(&iuu_driver); | ||
1316 | usb_serial_deregister(&iuu_device); | ||
1317 | } | ||
1318 | 1296 | ||
1319 | module_init(iuu_init); | 1297 | module_usb_serial_driver(iuu_driver, serial_drivers); |
1320 | module_exit(iuu_exit); | ||
1321 | 1298 | ||
1322 | MODULE_AUTHOR("Alain Degreffe eczema@ecze.com"); | 1299 | MODULE_AUTHOR("Alain Degreffe eczema@ecze.com"); |
1323 | 1300 | ||
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c index 4cc36c761801..a39ddd1b0dca 100644 --- a/drivers/usb/serial/keyspan.c +++ b/drivers/usb/serial/keyspan.c | |||
@@ -130,53 +130,7 @@ struct keyspan_port_private { | |||
130 | #include "keyspan_usa67msg.h" | 130 | #include "keyspan_usa67msg.h" |
131 | 131 | ||
132 | 132 | ||
133 | /* Functions used by new usb-serial code. */ | 133 | module_usb_serial_driver(keyspan_driver, serial_drivers); |
134 | static int __init keyspan_init(void) | ||
135 | { | ||
136 | int retval; | ||
137 | retval = usb_serial_register(&keyspan_pre_device); | ||
138 | if (retval) | ||
139 | goto failed_pre_device_register; | ||
140 | retval = usb_serial_register(&keyspan_1port_device); | ||
141 | if (retval) | ||
142 | goto failed_1port_device_register; | ||
143 | retval = usb_serial_register(&keyspan_2port_device); | ||
144 | if (retval) | ||
145 | goto failed_2port_device_register; | ||
146 | retval = usb_serial_register(&keyspan_4port_device); | ||
147 | if (retval) | ||
148 | goto failed_4port_device_register; | ||
149 | retval = usb_register(&keyspan_driver); | ||
150 | if (retval) | ||
151 | goto failed_usb_register; | ||
152 | |||
153 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
154 | DRIVER_DESC "\n"); | ||
155 | |||
156 | return 0; | ||
157 | failed_usb_register: | ||
158 | usb_serial_deregister(&keyspan_4port_device); | ||
159 | failed_4port_device_register: | ||
160 | usb_serial_deregister(&keyspan_2port_device); | ||
161 | failed_2port_device_register: | ||
162 | usb_serial_deregister(&keyspan_1port_device); | ||
163 | failed_1port_device_register: | ||
164 | usb_serial_deregister(&keyspan_pre_device); | ||
165 | failed_pre_device_register: | ||
166 | return retval; | ||
167 | } | ||
168 | |||
169 | static void __exit keyspan_exit(void) | ||
170 | { | ||
171 | usb_deregister(&keyspan_driver); | ||
172 | usb_serial_deregister(&keyspan_pre_device); | ||
173 | usb_serial_deregister(&keyspan_1port_device); | ||
174 | usb_serial_deregister(&keyspan_2port_device); | ||
175 | usb_serial_deregister(&keyspan_4port_device); | ||
176 | } | ||
177 | |||
178 | module_init(keyspan_init); | ||
179 | module_exit(keyspan_exit); | ||
180 | 134 | ||
181 | static void keyspan_break_ctl(struct tty_struct *tty, int break_state) | 135 | static void keyspan_break_ctl(struct tty_struct *tty, int break_state) |
182 | { | 136 | { |
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h index 13fa1d1cc900..622853c9e384 100644 --- a/drivers/usb/serial/keyspan.h +++ b/drivers/usb/serial/keyspan.h | |||
@@ -492,7 +492,6 @@ static struct usb_driver keyspan_driver = { | |||
492 | .probe = usb_serial_probe, | 492 | .probe = usb_serial_probe, |
493 | .disconnect = usb_serial_disconnect, | 493 | .disconnect = usb_serial_disconnect, |
494 | .id_table = keyspan_ids_combined, | 494 | .id_table = keyspan_ids_combined, |
495 | .no_dynamic_id = 1, | ||
496 | }; | 495 | }; |
497 | 496 | ||
498 | /* usb_device_id table for the pre-firmware download keyspan devices */ | 497 | /* usb_device_id table for the pre-firmware download keyspan devices */ |
@@ -545,7 +544,6 @@ static struct usb_serial_driver keyspan_pre_device = { | |||
545 | .name = "keyspan_no_firm", | 544 | .name = "keyspan_no_firm", |
546 | }, | 545 | }, |
547 | .description = "Keyspan - (without firmware)", | 546 | .description = "Keyspan - (without firmware)", |
548 | .usb_driver = &keyspan_driver, | ||
549 | .id_table = keyspan_pre_ids, | 547 | .id_table = keyspan_pre_ids, |
550 | .num_ports = 1, | 548 | .num_ports = 1, |
551 | .attach = keyspan_fake_startup, | 549 | .attach = keyspan_fake_startup, |
@@ -557,7 +555,6 @@ static struct usb_serial_driver keyspan_1port_device = { | |||
557 | .name = "keyspan_1", | 555 | .name = "keyspan_1", |
558 | }, | 556 | }, |
559 | .description = "Keyspan 1 port adapter", | 557 | .description = "Keyspan 1 port adapter", |
560 | .usb_driver = &keyspan_driver, | ||
561 | .id_table = keyspan_1port_ids, | 558 | .id_table = keyspan_1port_ids, |
562 | .num_ports = 1, | 559 | .num_ports = 1, |
563 | .open = keyspan_open, | 560 | .open = keyspan_open, |
@@ -580,7 +577,6 @@ static struct usb_serial_driver keyspan_2port_device = { | |||
580 | .name = "keyspan_2", | 577 | .name = "keyspan_2", |
581 | }, | 578 | }, |
582 | .description = "Keyspan 2 port adapter", | 579 | .description = "Keyspan 2 port adapter", |
583 | .usb_driver = &keyspan_driver, | ||
584 | .id_table = keyspan_2port_ids, | 580 | .id_table = keyspan_2port_ids, |
585 | .num_ports = 2, | 581 | .num_ports = 2, |
586 | .open = keyspan_open, | 582 | .open = keyspan_open, |
@@ -603,7 +599,6 @@ static struct usb_serial_driver keyspan_4port_device = { | |||
603 | .name = "keyspan_4", | 599 | .name = "keyspan_4", |
604 | }, | 600 | }, |
605 | .description = "Keyspan 4 port adapter", | 601 | .description = "Keyspan 4 port adapter", |
606 | .usb_driver = &keyspan_driver, | ||
607 | .id_table = keyspan_4port_ids, | 602 | .id_table = keyspan_4port_ids, |
608 | .num_ports = 4, | 603 | .num_ports = 4, |
609 | .open = keyspan_open, | 604 | .open = keyspan_open, |
@@ -620,4 +615,9 @@ static struct usb_serial_driver keyspan_4port_device = { | |||
620 | .release = keyspan_release, | 615 | .release = keyspan_release, |
621 | }; | 616 | }; |
622 | 617 | ||
618 | static struct usb_serial_driver * const serial_drivers[] = { | ||
619 | &keyspan_pre_device, &keyspan_1port_device, | ||
620 | &keyspan_2port_device, &keyspan_4port_device, NULL | ||
621 | }; | ||
622 | |||
623 | #endif | 623 | #endif |
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index 7c62a7048302..693bcdfcb3d5 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c | |||
@@ -91,7 +91,6 @@ static struct usb_driver keyspan_pda_driver = { | |||
91 | .probe = usb_serial_probe, | 91 | .probe = usb_serial_probe, |
92 | .disconnect = usb_serial_disconnect, | 92 | .disconnect = usb_serial_disconnect, |
93 | .id_table = id_table_combined, | 93 | .id_table = id_table_combined, |
94 | .no_dynamic_id = 1, | ||
95 | }; | 94 | }; |
96 | 95 | ||
97 | static const struct usb_device_id id_table_std[] = { | 96 | static const struct usb_device_id id_table_std[] = { |
@@ -779,7 +778,6 @@ static struct usb_serial_driver keyspan_pda_fake_device = { | |||
779 | .name = "keyspan_pda_pre", | 778 | .name = "keyspan_pda_pre", |
780 | }, | 779 | }, |
781 | .description = "Keyspan PDA - (prerenumeration)", | 780 | .description = "Keyspan PDA - (prerenumeration)", |
782 | .usb_driver = &keyspan_pda_driver, | ||
783 | .id_table = id_table_fake, | 781 | .id_table = id_table_fake, |
784 | .num_ports = 1, | 782 | .num_ports = 1, |
785 | .attach = keyspan_pda_fake_startup, | 783 | .attach = keyspan_pda_fake_startup, |
@@ -793,7 +791,6 @@ static struct usb_serial_driver xircom_pgs_fake_device = { | |||
793 | .name = "xircom_no_firm", | 791 | .name = "xircom_no_firm", |
794 | }, | 792 | }, |
795 | .description = "Xircom / Entregra PGS - (prerenumeration)", | 793 | .description = "Xircom / Entregra PGS - (prerenumeration)", |
796 | .usb_driver = &keyspan_pda_driver, | ||
797 | .id_table = id_table_fake_xircom, | 794 | .id_table = id_table_fake_xircom, |
798 | .num_ports = 1, | 795 | .num_ports = 1, |
799 | .attach = keyspan_pda_fake_startup, | 796 | .attach = keyspan_pda_fake_startup, |
@@ -806,7 +803,6 @@ static struct usb_serial_driver keyspan_pda_device = { | |||
806 | .name = "keyspan_pda", | 803 | .name = "keyspan_pda", |
807 | }, | 804 | }, |
808 | .description = "Keyspan PDA", | 805 | .description = "Keyspan PDA", |
809 | .usb_driver = &keyspan_pda_driver, | ||
810 | .id_table = id_table_std, | 806 | .id_table = id_table_std, |
811 | .num_ports = 1, | 807 | .num_ports = 1, |
812 | .dtr_rts = keyspan_pda_dtr_rts, | 808 | .dtr_rts = keyspan_pda_dtr_rts, |
@@ -827,61 +823,18 @@ static struct usb_serial_driver keyspan_pda_device = { | |||
827 | .release = keyspan_pda_release, | 823 | .release = keyspan_pda_release, |
828 | }; | 824 | }; |
829 | 825 | ||
830 | 826 | static struct usb_serial_driver * const serial_drivers[] = { | |
831 | static int __init keyspan_pda_init(void) | 827 | &keyspan_pda_device, |
832 | { | ||
833 | int retval; | ||
834 | retval = usb_serial_register(&keyspan_pda_device); | ||
835 | if (retval) | ||
836 | goto failed_pda_register; | ||
837 | #ifdef KEYSPAN | 828 | #ifdef KEYSPAN |
838 | retval = usb_serial_register(&keyspan_pda_fake_device); | 829 | &keyspan_pda_fake_device, |
839 | if (retval) | ||
840 | goto failed_pda_fake_register; | ||
841 | #endif | 830 | #endif |
842 | #ifdef XIRCOM | 831 | #ifdef XIRCOM |
843 | retval = usb_serial_register(&xircom_pgs_fake_device); | 832 | &xircom_pgs_fake_device, |
844 | if (retval) | ||
845 | goto failed_xircom_register; | ||
846 | #endif | ||
847 | retval = usb_register(&keyspan_pda_driver); | ||
848 | if (retval) | ||
849 | goto failed_usb_register; | ||
850 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
851 | DRIVER_DESC "\n"); | ||
852 | return 0; | ||
853 | failed_usb_register: | ||
854 | #ifdef XIRCOM | ||
855 | usb_serial_deregister(&xircom_pgs_fake_device); | ||
856 | failed_xircom_register: | ||
857 | #endif /* XIRCOM */ | ||
858 | #ifdef KEYSPAN | ||
859 | usb_serial_deregister(&keyspan_pda_fake_device); | ||
860 | #endif | ||
861 | #ifdef KEYSPAN | ||
862 | failed_pda_fake_register: | ||
863 | #endif | 833 | #endif |
864 | usb_serial_deregister(&keyspan_pda_device); | 834 | NULL |
865 | failed_pda_register: | 835 | }; |
866 | return retval; | ||
867 | } | ||
868 | |||
869 | |||
870 | static void __exit keyspan_pda_exit(void) | ||
871 | { | ||
872 | usb_deregister(&keyspan_pda_driver); | ||
873 | usb_serial_deregister(&keyspan_pda_device); | ||
874 | #ifdef KEYSPAN | ||
875 | usb_serial_deregister(&keyspan_pda_fake_device); | ||
876 | #endif | ||
877 | #ifdef XIRCOM | ||
878 | usb_serial_deregister(&xircom_pgs_fake_device); | ||
879 | #endif | ||
880 | } | ||
881 | |||
882 | 836 | ||
883 | module_init(keyspan_pda_init); | 837 | module_usb_serial_driver(keyspan_pda_driver, serial_drivers); |
884 | module_exit(keyspan_pda_exit); | ||
885 | 838 | ||
886 | MODULE_AUTHOR(DRIVER_AUTHOR); | 839 | MODULE_AUTHOR(DRIVER_AUTHOR); |
887 | MODULE_DESCRIPTION(DRIVER_DESC); | 840 | MODULE_DESCRIPTION(DRIVER_DESC); |
@@ -889,4 +842,3 @@ MODULE_LICENSE("GPL"); | |||
889 | 842 | ||
890 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 843 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
891 | MODULE_PARM_DESC(debug, "Debug enabled or not"); | 844 | MODULE_PARM_DESC(debug, "Debug enabled or not"); |
892 | |||
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index fc064e1442ca..10f05407e535 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c | |||
@@ -91,7 +91,6 @@ static struct usb_driver kl5kusb105d_driver = { | |||
91 | .probe = usb_serial_probe, | 91 | .probe = usb_serial_probe, |
92 | .disconnect = usb_serial_disconnect, | 92 | .disconnect = usb_serial_disconnect, |
93 | .id_table = id_table, | 93 | .id_table = id_table, |
94 | .no_dynamic_id = 1, | ||
95 | }; | 94 | }; |
96 | 95 | ||
97 | static struct usb_serial_driver kl5kusb105d_device = { | 96 | static struct usb_serial_driver kl5kusb105d_device = { |
@@ -100,7 +99,6 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
100 | .name = "kl5kusb105d", | 99 | .name = "kl5kusb105d", |
101 | }, | 100 | }, |
102 | .description = "KL5KUSB105D / PalmConnect", | 101 | .description = "KL5KUSB105D / PalmConnect", |
103 | .usb_driver = &kl5kusb105d_driver, | ||
104 | .id_table = id_table, | 102 | .id_table = id_table, |
105 | .num_ports = 1, | 103 | .num_ports = 1, |
106 | .bulk_out_size = 64, | 104 | .bulk_out_size = 64, |
@@ -118,6 +116,10 @@ static struct usb_serial_driver kl5kusb105d_device = { | |||
118 | .prepare_write_buffer = klsi_105_prepare_write_buffer, | 116 | .prepare_write_buffer = klsi_105_prepare_write_buffer, |
119 | }; | 117 | }; |
120 | 118 | ||
119 | static struct usb_serial_driver * const serial_drivers[] = { | ||
120 | &kl5kusb105d_device, NULL | ||
121 | }; | ||
122 | |||
121 | struct klsi_105_port_settings { | 123 | struct klsi_105_port_settings { |
122 | __u8 pktlen; /* always 5, it seems */ | 124 | __u8 pktlen; /* always 5, it seems */ |
123 | __u8 baudrate; | 125 | __u8 baudrate; |
@@ -690,40 +692,11 @@ static int klsi_105_tiocmset(struct tty_struct *tty, | |||
690 | return retval; | 692 | return retval; |
691 | } | 693 | } |
692 | 694 | ||
693 | 695 | module_usb_serial_driver(kl5kusb105d_driver, serial_drivers); | |
694 | static int __init klsi_105_init(void) | ||
695 | { | ||
696 | int retval; | ||
697 | retval = usb_serial_register(&kl5kusb105d_device); | ||
698 | if (retval) | ||
699 | goto failed_usb_serial_register; | ||
700 | retval = usb_register(&kl5kusb105d_driver); | ||
701 | if (retval) | ||
702 | goto failed_usb_register; | ||
703 | |||
704 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
705 | DRIVER_DESC "\n"); | ||
706 | return 0; | ||
707 | failed_usb_register: | ||
708 | usb_serial_deregister(&kl5kusb105d_device); | ||
709 | failed_usb_serial_register: | ||
710 | return retval; | ||
711 | } | ||
712 | |||
713 | static void __exit klsi_105_exit(void) | ||
714 | { | ||
715 | usb_deregister(&kl5kusb105d_driver); | ||
716 | usb_serial_deregister(&kl5kusb105d_device); | ||
717 | } | ||
718 | |||
719 | |||
720 | module_init(klsi_105_init); | ||
721 | module_exit(klsi_105_exit); | ||
722 | 696 | ||
723 | MODULE_AUTHOR(DRIVER_AUTHOR); | 697 | MODULE_AUTHOR(DRIVER_AUTHOR); |
724 | MODULE_DESCRIPTION(DRIVER_DESC); | 698 | MODULE_DESCRIPTION(DRIVER_DESC); |
725 | MODULE_LICENSE("GPL"); | 699 | MODULE_LICENSE("GPL"); |
726 | 700 | ||
727 | |||
728 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 701 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
729 | MODULE_PARM_DESC(debug, "enable extensive debugging messages"); | 702 | MODULE_PARM_DESC(debug, "enable extensive debugging messages"); |
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c index a92a3efb507b..4a9a75eb9b95 100644 --- a/drivers/usb/serial/kobil_sct.c +++ b/drivers/usb/serial/kobil_sct.c | |||
@@ -90,7 +90,6 @@ static struct usb_driver kobil_driver = { | |||
90 | .probe = usb_serial_probe, | 90 | .probe = usb_serial_probe, |
91 | .disconnect = usb_serial_disconnect, | 91 | .disconnect = usb_serial_disconnect, |
92 | .id_table = id_table, | 92 | .id_table = id_table, |
93 | .no_dynamic_id = 1, | ||
94 | }; | 93 | }; |
95 | 94 | ||
96 | 95 | ||
@@ -100,7 +99,6 @@ static struct usb_serial_driver kobil_device = { | |||
100 | .name = "kobil", | 99 | .name = "kobil", |
101 | }, | 100 | }, |
102 | .description = "KOBIL USB smart card terminal", | 101 | .description = "KOBIL USB smart card terminal", |
103 | .usb_driver = &kobil_driver, | ||
104 | .id_table = id_table, | 102 | .id_table = id_table, |
105 | .num_ports = 1, | 103 | .num_ports = 1, |
106 | .attach = kobil_startup, | 104 | .attach = kobil_startup, |
@@ -117,6 +115,9 @@ static struct usb_serial_driver kobil_device = { | |||
117 | .read_int_callback = kobil_read_int_callback, | 115 | .read_int_callback = kobil_read_int_callback, |
118 | }; | 116 | }; |
119 | 117 | ||
118 | static struct usb_serial_driver * const serial_drivers[] = { | ||
119 | &kobil_device, NULL | ||
120 | }; | ||
120 | 121 | ||
121 | struct kobil_private { | 122 | struct kobil_private { |
122 | int write_int_endpoint_address; | 123 | int write_int_endpoint_address; |
@@ -682,35 +683,7 @@ static int kobil_ioctl(struct tty_struct *tty, | |||
682 | } | 683 | } |
683 | } | 684 | } |
684 | 685 | ||
685 | static int __init kobil_init(void) | 686 | module_usb_serial_driver(kobil_driver, serial_drivers); |
686 | { | ||
687 | int retval; | ||
688 | retval = usb_serial_register(&kobil_device); | ||
689 | if (retval) | ||
690 | goto failed_usb_serial_register; | ||
691 | retval = usb_register(&kobil_driver); | ||
692 | if (retval) | ||
693 | goto failed_usb_register; | ||
694 | |||
695 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
696 | DRIVER_DESC "\n"); | ||
697 | |||
698 | return 0; | ||
699 | failed_usb_register: | ||
700 | usb_serial_deregister(&kobil_device); | ||
701 | failed_usb_serial_register: | ||
702 | return retval; | ||
703 | } | ||
704 | |||
705 | |||
706 | static void __exit kobil_exit(void) | ||
707 | { | ||
708 | usb_deregister(&kobil_driver); | ||
709 | usb_serial_deregister(&kobil_device); | ||
710 | } | ||
711 | |||
712 | module_init(kobil_init); | ||
713 | module_exit(kobil_exit); | ||
714 | 687 | ||
715 | MODULE_AUTHOR(DRIVER_AUTHOR); | 688 | MODULE_AUTHOR(DRIVER_AUTHOR); |
716 | MODULE_DESCRIPTION(DRIVER_DESC); | 689 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c index 27fa9c8a77b0..6edd26130e25 100644 --- a/drivers/usb/serial/mct_u232.c +++ b/drivers/usb/serial/mct_u232.c | |||
@@ -88,7 +88,6 @@ static struct usb_driver mct_u232_driver = { | |||
88 | .probe = usb_serial_probe, | 88 | .probe = usb_serial_probe, |
89 | .disconnect = usb_serial_disconnect, | 89 | .disconnect = usb_serial_disconnect, |
90 | .id_table = id_table_combined, | 90 | .id_table = id_table_combined, |
91 | .no_dynamic_id = 1, | ||
92 | }; | 91 | }; |
93 | 92 | ||
94 | static struct usb_serial_driver mct_u232_device = { | 93 | static struct usb_serial_driver mct_u232_device = { |
@@ -97,7 +96,6 @@ static struct usb_serial_driver mct_u232_device = { | |||
97 | .name = "mct_u232", | 96 | .name = "mct_u232", |
98 | }, | 97 | }, |
99 | .description = "MCT U232", | 98 | .description = "MCT U232", |
100 | .usb_driver = &mct_u232_driver, | ||
101 | .id_table = id_table_combined, | 99 | .id_table = id_table_combined, |
102 | .num_ports = 1, | 100 | .num_ports = 1, |
103 | .open = mct_u232_open, | 101 | .open = mct_u232_open, |
@@ -116,6 +114,10 @@ static struct usb_serial_driver mct_u232_device = { | |||
116 | .get_icount = mct_u232_get_icount, | 114 | .get_icount = mct_u232_get_icount, |
117 | }; | 115 | }; |
118 | 116 | ||
117 | static struct usb_serial_driver * const serial_drivers[] = { | ||
118 | &mct_u232_device, NULL | ||
119 | }; | ||
120 | |||
119 | struct mct_u232_private { | 121 | struct mct_u232_private { |
120 | spinlock_t lock; | 122 | spinlock_t lock; |
121 | unsigned int control_state; /* Modem Line Setting (TIOCM) */ | 123 | unsigned int control_state; /* Modem Line Setting (TIOCM) */ |
@@ -904,33 +906,7 @@ static int mct_u232_get_icount(struct tty_struct *tty, | |||
904 | return 0; | 906 | return 0; |
905 | } | 907 | } |
906 | 908 | ||
907 | static int __init mct_u232_init(void) | 909 | module_usb_serial_driver(mct_u232_driver, serial_drivers); |
908 | { | ||
909 | int retval; | ||
910 | retval = usb_serial_register(&mct_u232_device); | ||
911 | if (retval) | ||
912 | goto failed_usb_serial_register; | ||
913 | retval = usb_register(&mct_u232_driver); | ||
914 | if (retval) | ||
915 | goto failed_usb_register; | ||
916 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
917 | DRIVER_DESC "\n"); | ||
918 | return 0; | ||
919 | failed_usb_register: | ||
920 | usb_serial_deregister(&mct_u232_device); | ||
921 | failed_usb_serial_register: | ||
922 | return retval; | ||
923 | } | ||
924 | |||
925 | |||
926 | static void __exit mct_u232_exit(void) | ||
927 | { | ||
928 | usb_deregister(&mct_u232_driver); | ||
929 | usb_serial_deregister(&mct_u232_device); | ||
930 | } | ||
931 | |||
932 | module_init(mct_u232_init); | ||
933 | module_exit(mct_u232_exit); | ||
934 | 910 | ||
935 | MODULE_AUTHOR(DRIVER_AUTHOR); | 911 | MODULE_AUTHOR(DRIVER_AUTHOR); |
936 | MODULE_DESCRIPTION(DRIVER_DESC); | 912 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c new file mode 100644 index 000000000000..6e1622f2a297 --- /dev/null +++ b/drivers/usb/serial/metro-usb.c | |||
@@ -0,0 +1,402 @@ | |||
1 | /* | ||
2 | Some of this code is credited to Linux USB open source files that are | ||
3 | distributed with Linux. | ||
4 | |||
5 | Copyright: 2007 Metrologic Instruments. All rights reserved. | ||
6 | Copyright: 2011 Azimut Ltd. <http://azimutrzn.ru/> | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/init.h> | ||
11 | #include <linux/tty.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/usb.h> | ||
14 | #include <linux/errno.h> | ||
15 | #include <linux/slab.h> | ||
16 | #include <linux/tty_driver.h> | ||
17 | #include <linux/tty_flip.h> | ||
18 | #include <linux/moduleparam.h> | ||
19 | #include <linux/spinlock.h> | ||
20 | #include <linux/errno.h> | ||
21 | #include <linux/uaccess.h> | ||
22 | #include <linux/usb/serial.h> | ||
23 | |||
24 | /* Version Information */ | ||
25 | #define DRIVER_VERSION "v1.2.0.0" | ||
26 | #define DRIVER_DESC "Metrologic Instruments Inc. - USB-POS driver" | ||
27 | |||
28 | /* Product information. */ | ||
29 | #define FOCUS_VENDOR_ID 0x0C2E | ||
30 | #define FOCUS_PRODUCT_ID 0x0720 | ||
31 | #define FOCUS_PRODUCT_ID_UNI 0x0710 | ||
32 | |||
33 | #define METROUSB_SET_REQUEST_TYPE 0x40 | ||
34 | #define METROUSB_SET_MODEM_CTRL_REQUEST 10 | ||
35 | #define METROUSB_SET_BREAK_REQUEST 0x40 | ||
36 | #define METROUSB_MCR_NONE 0x08 /* Deactivate DTR and RTS. */ | ||
37 | #define METROUSB_MCR_RTS 0x0a /* Activate RTS. */ | ||
38 | #define METROUSB_MCR_DTR 0x09 /* Activate DTR. */ | ||
39 | #define WDR_TIMEOUT 5000 /* default urb timeout. */ | ||
40 | |||
41 | /* Private data structure. */ | ||
42 | struct metrousb_private { | ||
43 | spinlock_t lock; | ||
44 | int throttled; | ||
45 | unsigned long control_state; | ||
46 | }; | ||
47 | |||
48 | /* Device table list. */ | ||
49 | static struct usb_device_id id_table[] = { | ||
50 | { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID) }, | ||
51 | { USB_DEVICE(FOCUS_VENDOR_ID, FOCUS_PRODUCT_ID_UNI) }, | ||
52 | { }, /* Terminating entry. */ | ||
53 | }; | ||
54 | MODULE_DEVICE_TABLE(usb, id_table); | ||
55 | |||
56 | /* Input parameter constants. */ | ||
57 | static bool debug; | ||
58 | |||
59 | static void metrousb_read_int_callback(struct urb *urb) | ||
60 | { | ||
61 | struct usb_serial_port *port = urb->context; | ||
62 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | ||
63 | struct tty_struct *tty; | ||
64 | unsigned char *data = urb->transfer_buffer; | ||
65 | int throttled = 0; | ||
66 | int result = 0; | ||
67 | unsigned long flags = 0; | ||
68 | |||
69 | dev_dbg(&port->dev, "%s\n", __func__); | ||
70 | |||
71 | switch (urb->status) { | ||
72 | case 0: | ||
73 | /* Success status, read from the port. */ | ||
74 | break; | ||
75 | case -ECONNRESET: | ||
76 | case -ENOENT: | ||
77 | case -ESHUTDOWN: | ||
78 | /* urb has been terminated. */ | ||
79 | dev_dbg(&port->dev, | ||
80 | "%s - urb shutting down, error code=%d\n", | ||
81 | __func__, result); | ||
82 | return; | ||
83 | default: | ||
84 | dev_dbg(&port->dev, | ||
85 | "%s - non-zero urb received, error code=%d\n", | ||
86 | __func__, result); | ||
87 | goto exit; | ||
88 | } | ||
89 | |||
90 | |||
91 | /* Set the data read from the usb port into the serial port buffer. */ | ||
92 | tty = tty_port_tty_get(&port->port); | ||
93 | if (!tty) { | ||
94 | dev_dbg(&port->dev, "%s - bad tty pointer - exiting\n", | ||
95 | __func__); | ||
96 | return; | ||
97 | } | ||
98 | |||
99 | if (tty && urb->actual_length) { | ||
100 | /* Loop through the data copying each byte to the tty layer. */ | ||
101 | tty_insert_flip_string(tty, data, urb->actual_length); | ||
102 | |||
103 | /* Force the data to the tty layer. */ | ||
104 | tty_flip_buffer_push(tty); | ||
105 | } | ||
106 | tty_kref_put(tty); | ||
107 | |||
108 | /* Set any port variables. */ | ||
109 | spin_lock_irqsave(&metro_priv->lock, flags); | ||
110 | throttled = metro_priv->throttled; | ||
111 | spin_unlock_irqrestore(&metro_priv->lock, flags); | ||
112 | |||
113 | /* Continue trying to read if set. */ | ||
114 | if (!throttled) { | ||
115 | usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, | ||
116 | usb_rcvintpipe(port->serial->dev, port->interrupt_in_endpointAddress), | ||
117 | port->interrupt_in_urb->transfer_buffer, | ||
118 | port->interrupt_in_urb->transfer_buffer_length, | ||
119 | metrousb_read_int_callback, port, 1); | ||
120 | |||
121 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | ||
122 | |||
123 | if (result) | ||
124 | dev_dbg(&port->dev, | ||
125 | "%s - failed submitting interrupt in urb, error code=%d\n", | ||
126 | __func__, result); | ||
127 | } | ||
128 | return; | ||
129 | |||
130 | exit: | ||
131 | /* Try to resubmit the urb. */ | ||
132 | result = usb_submit_urb(urb, GFP_ATOMIC); | ||
133 | if (result) | ||
134 | dev_dbg(&port->dev, | ||
135 | "%s - failed submitting interrupt in urb, error code=%d\n", | ||
136 | __func__, result); | ||
137 | } | ||
138 | |||
139 | static void metrousb_cleanup(struct usb_serial_port *port) | ||
140 | { | ||
141 | dev_dbg(&port->dev, "%s\n", __func__); | ||
142 | |||
143 | if (port->serial->dev) { | ||
144 | /* Shutdown any interrupt in urbs. */ | ||
145 | if (port->interrupt_in_urb) { | ||
146 | usb_unlink_urb(port->interrupt_in_urb); | ||
147 | usb_kill_urb(port->interrupt_in_urb); | ||
148 | } | ||
149 | } | ||
150 | } | ||
151 | |||
152 | static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port) | ||
153 | { | ||
154 | struct usb_serial *serial = port->serial; | ||
155 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | ||
156 | unsigned long flags = 0; | ||
157 | int result = 0; | ||
158 | |||
159 | dev_dbg(&port->dev, "%s\n", __func__); | ||
160 | |||
161 | /* Make sure the urb is initialized. */ | ||
162 | if (!port->interrupt_in_urb) { | ||
163 | dev_dbg(&port->dev, "%s - interrupt urb not initialized\n", | ||
164 | __func__); | ||
165 | return -ENODEV; | ||
166 | } | ||
167 | |||
168 | /* Set the private data information for the port. */ | ||
169 | spin_lock_irqsave(&metro_priv->lock, flags); | ||
170 | metro_priv->control_state = 0; | ||
171 | metro_priv->throttled = 0; | ||
172 | spin_unlock_irqrestore(&metro_priv->lock, flags); | ||
173 | |||
174 | /* | ||
175 | * Force low_latency on so that our tty_push actually forces the data | ||
176 | * through, otherwise it is scheduled, and with high data rates (like | ||
177 | * with OHCI) data can get lost. | ||
178 | */ | ||
179 | if (tty) | ||
180 | tty->low_latency = 1; | ||
181 | |||
182 | /* Clear the urb pipe. */ | ||
183 | usb_clear_halt(serial->dev, port->interrupt_in_urb->pipe); | ||
184 | |||
185 | /* Start reading from the device */ | ||
186 | usb_fill_int_urb(port->interrupt_in_urb, serial->dev, | ||
187 | usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), | ||
188 | port->interrupt_in_urb->transfer_buffer, | ||
189 | port->interrupt_in_urb->transfer_buffer_length, | ||
190 | metrousb_read_int_callback, port, 1); | ||
191 | result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); | ||
192 | |||
193 | if (result) { | ||
194 | dev_dbg(&port->dev, | ||
195 | "%s - failed submitting interrupt in urb, error code=%d\n", | ||
196 | __func__, result); | ||
197 | goto exit; | ||
198 | } | ||
199 | |||
200 | dev_dbg(&port->dev, "%s - port open\n", __func__); | ||
201 | exit: | ||
202 | return result; | ||
203 | } | ||
204 | |||
205 | static int metrousb_set_modem_ctrl(struct usb_serial *serial, unsigned int control_state) | ||
206 | { | ||
207 | int retval = 0; | ||
208 | unsigned char mcr = METROUSB_MCR_NONE; | ||
209 | |||
210 | dev_dbg(&serial->dev->dev, "%s - control state = %d\n", | ||
211 | __func__, control_state); | ||
212 | |||
213 | /* Set the modem control value. */ | ||
214 | if (control_state & TIOCM_DTR) | ||
215 | mcr |= METROUSB_MCR_DTR; | ||
216 | if (control_state & TIOCM_RTS) | ||
217 | mcr |= METROUSB_MCR_RTS; | ||
218 | |||
219 | /* Send the command to the usb port. */ | ||
220 | retval = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), | ||
221 | METROUSB_SET_REQUEST_TYPE, METROUSB_SET_MODEM_CTRL_REQUEST, | ||
222 | control_state, 0, NULL, 0, WDR_TIMEOUT); | ||
223 | if (retval < 0) | ||
224 | dev_dbg(&serial->dev->dev, | ||
225 | "%s - set modem ctrl=0x%x failed, error code=%d\n", | ||
226 | __func__, mcr, retval); | ||
227 | |||
228 | return retval; | ||
229 | } | ||
230 | |||
231 | static void metrousb_shutdown(struct usb_serial *serial) | ||
232 | { | ||
233 | int i = 0; | ||
234 | |||
235 | dev_dbg(&serial->dev->dev, "%s\n", __func__); | ||
236 | |||
237 | /* Stop reading and writing on all ports. */ | ||
238 | for (i = 0; i < serial->num_ports; ++i) { | ||
239 | /* Close any open urbs. */ | ||
240 | metrousb_cleanup(serial->port[i]); | ||
241 | |||
242 | /* Free memory. */ | ||
243 | kfree(usb_get_serial_port_data(serial->port[i])); | ||
244 | usb_set_serial_port_data(serial->port[i], NULL); | ||
245 | |||
246 | dev_dbg(&serial->dev->dev, "%s - freed port number=%d\n", | ||
247 | __func__, serial->port[i]->number); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | static int metrousb_startup(struct usb_serial *serial) | ||
252 | { | ||
253 | struct metrousb_private *metro_priv; | ||
254 | struct usb_serial_port *port; | ||
255 | int i = 0; | ||
256 | |||
257 | dev_dbg(&serial->dev->dev, "%s\n", __func__); | ||
258 | |||
259 | /* Loop through the serial ports setting up the private structures. | ||
260 | * Currently we only use one port. */ | ||
261 | for (i = 0; i < serial->num_ports; ++i) { | ||
262 | port = serial->port[i]; | ||
263 | |||
264 | /* Declare memory. */ | ||
265 | metro_priv = kzalloc(sizeof(struct metrousb_private), GFP_KERNEL); | ||
266 | if (!metro_priv) | ||
267 | return -ENOMEM; | ||
268 | |||
269 | /* Initialize memory. */ | ||
270 | spin_lock_init(&metro_priv->lock); | ||
271 | usb_set_serial_port_data(port, metro_priv); | ||
272 | |||
273 | dev_dbg(&serial->dev->dev, "%s - port number=%d\n ", | ||
274 | __func__, port->number); | ||
275 | } | ||
276 | |||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | static void metrousb_throttle(struct tty_struct *tty) | ||
281 | { | ||
282 | struct usb_serial_port *port = tty->driver_data; | ||
283 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | ||
284 | unsigned long flags = 0; | ||
285 | |||
286 | dev_dbg(tty->dev, "%s\n", __func__); | ||
287 | |||
288 | /* Set the private information for the port to stop reading data. */ | ||
289 | spin_lock_irqsave(&metro_priv->lock, flags); | ||
290 | metro_priv->throttled = 1; | ||
291 | spin_unlock_irqrestore(&metro_priv->lock, flags); | ||
292 | } | ||
293 | |||
294 | static int metrousb_tiocmget(struct tty_struct *tty) | ||
295 | { | ||
296 | unsigned long control_state = 0; | ||
297 | struct usb_serial_port *port = tty->driver_data; | ||
298 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | ||
299 | unsigned long flags = 0; | ||
300 | |||
301 | dev_dbg(tty->dev, "%s\n", __func__); | ||
302 | |||
303 | spin_lock_irqsave(&metro_priv->lock, flags); | ||
304 | control_state = metro_priv->control_state; | ||
305 | spin_unlock_irqrestore(&metro_priv->lock, flags); | ||
306 | |||
307 | return control_state; | ||
308 | } | ||
309 | |||
310 | static int metrousb_tiocmset(struct tty_struct *tty, | ||
311 | unsigned int set, unsigned int clear) | ||
312 | { | ||
313 | struct usb_serial_port *port = tty->driver_data; | ||
314 | struct usb_serial *serial = port->serial; | ||
315 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | ||
316 | unsigned long flags = 0; | ||
317 | unsigned long control_state = 0; | ||
318 | |||
319 | dev_dbg(tty->dev, "%s - set=%d, clear=%d\n", __func__, set, clear); | ||
320 | |||
321 | spin_lock_irqsave(&metro_priv->lock, flags); | ||
322 | control_state = metro_priv->control_state; | ||
323 | |||
324 | /* Set the RTS and DTR values. */ | ||
325 | if (set & TIOCM_RTS) | ||
326 | control_state |= TIOCM_RTS; | ||
327 | if (set & TIOCM_DTR) | ||
328 | control_state |= TIOCM_DTR; | ||
329 | if (clear & TIOCM_RTS) | ||
330 | control_state &= ~TIOCM_RTS; | ||
331 | if (clear & TIOCM_DTR) | ||
332 | control_state &= ~TIOCM_DTR; | ||
333 | |||
334 | metro_priv->control_state = control_state; | ||
335 | spin_unlock_irqrestore(&metro_priv->lock, flags); | ||
336 | return metrousb_set_modem_ctrl(serial, control_state); | ||
337 | } | ||
338 | |||
339 | static void metrousb_unthrottle(struct tty_struct *tty) | ||
340 | { | ||
341 | struct usb_serial_port *port = tty->driver_data; | ||
342 | struct metrousb_private *metro_priv = usb_get_serial_port_data(port); | ||
343 | unsigned long flags = 0; | ||
344 | int result = 0; | ||
345 | |||
346 | dev_dbg(tty->dev, "%s\n", __func__); | ||
347 | |||
348 | /* Set the private information for the port to resume reading data. */ | ||
349 | spin_lock_irqsave(&metro_priv->lock, flags); | ||
350 | metro_priv->throttled = 0; | ||
351 | spin_unlock_irqrestore(&metro_priv->lock, flags); | ||
352 | |||
353 | /* Submit the urb to read from the port. */ | ||
354 | port->interrupt_in_urb->dev = port->serial->dev; | ||
355 | result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); | ||
356 | if (result) | ||
357 | dev_dbg(tty->dev, | ||
358 | "failed submitting interrupt in urb error code=%d\n", | ||
359 | result); | ||
360 | } | ||
361 | |||
362 | static struct usb_driver metrousb_driver = { | ||
363 | .name = "metro-usb", | ||
364 | .probe = usb_serial_probe, | ||
365 | .disconnect = usb_serial_disconnect, | ||
366 | .id_table = id_table | ||
367 | }; | ||
368 | |||
369 | static struct usb_serial_driver metrousb_device = { | ||
370 | .driver = { | ||
371 | .owner = THIS_MODULE, | ||
372 | .name = "metro-usb", | ||
373 | }, | ||
374 | .description = "Metrologic USB to serial converter.", | ||
375 | .id_table = id_table, | ||
376 | .num_ports = 1, | ||
377 | .open = metrousb_open, | ||
378 | .close = metrousb_cleanup, | ||
379 | .read_int_callback = metrousb_read_int_callback, | ||
380 | .attach = metrousb_startup, | ||
381 | .release = metrousb_shutdown, | ||
382 | .throttle = metrousb_throttle, | ||
383 | .unthrottle = metrousb_unthrottle, | ||
384 | .tiocmget = metrousb_tiocmget, | ||
385 | .tiocmset = metrousb_tiocmset, | ||
386 | }; | ||
387 | |||
388 | static struct usb_serial_driver * const serial_drivers[] = { | ||
389 | &metrousb_device, | ||
390 | NULL, | ||
391 | }; | ||
392 | |||
393 | module_usb_serial_driver(metrousb_driver, serial_drivers); | ||
394 | |||
395 | MODULE_LICENSE("GPL"); | ||
396 | MODULE_AUTHOR("Philip Nicastro"); | ||
397 | MODULE_AUTHOR("Aleksey Babahin <tamerlan311@gmail.com>"); | ||
398 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
399 | |||
400 | /* Module input parameters */ | ||
401 | module_param(debug, bool, S_IRUGO | S_IWUSR); | ||
402 | MODULE_PARM_DESC(debug, "Print debug info (bool 1=on, 0=off)"); | ||
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c index 4554ee49e635..bdce82034122 100644 --- a/drivers/usb/serial/mos7720.c +++ b/drivers/usb/serial/mos7720.c | |||
@@ -1294,7 +1294,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1294 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, | 1294 | urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, |
1295 | GFP_KERNEL); | 1295 | GFP_KERNEL); |
1296 | if (urb->transfer_buffer == NULL) { | 1296 | if (urb->transfer_buffer == NULL) { |
1297 | dev_err(&port->dev, "%s no more kernel memory...\n", | 1297 | dev_err_console(port, "%s no more kernel memory...\n", |
1298 | __func__); | 1298 | __func__); |
1299 | goto exit; | 1299 | goto exit; |
1300 | } | 1300 | } |
@@ -1315,7 +1315,7 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1315 | /* send it down the pipe */ | 1315 | /* send it down the pipe */ |
1316 | status = usb_submit_urb(urb, GFP_ATOMIC); | 1316 | status = usb_submit_urb(urb, GFP_ATOMIC); |
1317 | if (status) { | 1317 | if (status) { |
1318 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " | 1318 | dev_err_console(port, "%s - usb_submit_urb(write bulk) failed " |
1319 | "with status = %d\n", __func__, status); | 1319 | "with status = %d\n", __func__, status); |
1320 | bytes_sent = status; | 1320 | bytes_sent = status; |
1321 | goto exit; | 1321 | goto exit; |
@@ -2169,7 +2169,6 @@ static struct usb_driver usb_driver = { | |||
2169 | .probe = usb_serial_probe, | 2169 | .probe = usb_serial_probe, |
2170 | .disconnect = usb_serial_disconnect, | 2170 | .disconnect = usb_serial_disconnect, |
2171 | .id_table = moschip_port_id_table, | 2171 | .id_table = moschip_port_id_table, |
2172 | .no_dynamic_id = 1, | ||
2173 | }; | 2172 | }; |
2174 | 2173 | ||
2175 | static struct usb_serial_driver moschip7720_2port_driver = { | 2174 | static struct usb_serial_driver moschip7720_2port_driver = { |
@@ -2178,7 +2177,6 @@ static struct usb_serial_driver moschip7720_2port_driver = { | |||
2178 | .name = "moschip7720", | 2177 | .name = "moschip7720", |
2179 | }, | 2178 | }, |
2180 | .description = "Moschip 2 port adapter", | 2179 | .description = "Moschip 2 port adapter", |
2181 | .usb_driver = &usb_driver, | ||
2182 | .id_table = moschip_port_id_table, | 2180 | .id_table = moschip_port_id_table, |
2183 | .calc_num_ports = mos77xx_calc_num_ports, | 2181 | .calc_num_ports = mos77xx_calc_num_ports, |
2184 | .open = mos7720_open, | 2182 | .open = mos7720_open, |
@@ -2201,44 +2199,12 @@ static struct usb_serial_driver moschip7720_2port_driver = { | |||
2201 | .read_int_callback = NULL /* dynamically assigned in probe() */ | 2199 | .read_int_callback = NULL /* dynamically assigned in probe() */ |
2202 | }; | 2200 | }; |
2203 | 2201 | ||
2204 | static int __init moschip7720_init(void) | 2202 | static struct usb_serial_driver * const serial_drivers[] = { |
2205 | { | 2203 | &moschip7720_2port_driver, NULL |
2206 | int retval; | 2204 | }; |
2207 | |||
2208 | dbg("%s: Entering ..........", __func__); | ||
2209 | |||
2210 | /* Register with the usb serial */ | ||
2211 | retval = usb_serial_register(&moschip7720_2port_driver); | ||
2212 | if (retval) | ||
2213 | goto failed_port_device_register; | ||
2214 | |||
2215 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
2216 | DRIVER_DESC "\n"); | ||
2217 | |||
2218 | /* Register with the usb */ | ||
2219 | retval = usb_register(&usb_driver); | ||
2220 | if (retval) | ||
2221 | goto failed_usb_register; | ||
2222 | |||
2223 | return 0; | ||
2224 | |||
2225 | failed_usb_register: | ||
2226 | usb_serial_deregister(&moschip7720_2port_driver); | ||
2227 | |||
2228 | failed_port_device_register: | ||
2229 | return retval; | ||
2230 | } | ||
2231 | |||
2232 | static void __exit moschip7720_exit(void) | ||
2233 | { | ||
2234 | usb_deregister(&usb_driver); | ||
2235 | usb_serial_deregister(&moschip7720_2port_driver); | ||
2236 | } | ||
2237 | 2205 | ||
2238 | module_init(moschip7720_init); | 2206 | module_usb_serial_driver(usb_driver, serial_drivers); |
2239 | module_exit(moschip7720_exit); | ||
2240 | 2207 | ||
2241 | /* Module information */ | ||
2242 | MODULE_AUTHOR(DRIVER_AUTHOR); | 2208 | MODULE_AUTHOR(DRIVER_AUTHOR); |
2243 | MODULE_DESCRIPTION(DRIVER_DESC); | 2209 | MODULE_DESCRIPTION(DRIVER_DESC); |
2244 | MODULE_LICENSE("GPL"); | 2210 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 03b5e249e95e..c526550694a0 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -174,6 +174,7 @@ | |||
174 | 174 | ||
175 | #define CLK_MULTI_REGISTER ((__u16)(0x02)) | 175 | #define CLK_MULTI_REGISTER ((__u16)(0x02)) |
176 | #define CLK_START_VALUE_REGISTER ((__u16)(0x03)) | 176 | #define CLK_START_VALUE_REGISTER ((__u16)(0x03)) |
177 | #define GPIO_REGISTER ((__u16)(0x07)) | ||
177 | 178 | ||
178 | #define SERIAL_LCR_DLAB ((__u16)(0x0080)) | 179 | #define SERIAL_LCR_DLAB ((__u16)(0x0080)) |
179 | 180 | ||
@@ -1101,14 +1102,25 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1101 | mos7840_port->read_urb = port->read_urb; | 1102 | mos7840_port->read_urb = port->read_urb; |
1102 | 1103 | ||
1103 | /* set up our bulk in urb */ | 1104 | /* set up our bulk in urb */ |
1104 | 1105 | if ((serial->num_ports == 2) | |
1105 | usb_fill_bulk_urb(mos7840_port->read_urb, | 1106 | && ((((__u16)port->number - |
1106 | serial->dev, | 1107 | (__u16)(port->serial->minor)) % 2) != 0)) { |
1107 | usb_rcvbulkpipe(serial->dev, | 1108 | usb_fill_bulk_urb(mos7840_port->read_urb, |
1108 | port->bulk_in_endpointAddress), | 1109 | serial->dev, |
1109 | port->bulk_in_buffer, | 1110 | usb_rcvbulkpipe(serial->dev, |
1110 | mos7840_port->read_urb->transfer_buffer_length, | 1111 | (port->bulk_in_endpointAddress) + 2), |
1111 | mos7840_bulk_in_callback, mos7840_port); | 1112 | port->bulk_in_buffer, |
1113 | mos7840_port->read_urb->transfer_buffer_length, | ||
1114 | mos7840_bulk_in_callback, mos7840_port); | ||
1115 | } else { | ||
1116 | usb_fill_bulk_urb(mos7840_port->read_urb, | ||
1117 | serial->dev, | ||
1118 | usb_rcvbulkpipe(serial->dev, | ||
1119 | port->bulk_in_endpointAddress), | ||
1120 | port->bulk_in_buffer, | ||
1121 | mos7840_port->read_urb->transfer_buffer_length, | ||
1122 | mos7840_bulk_in_callback, mos7840_port); | ||
1123 | } | ||
1112 | 1124 | ||
1113 | dbg("mos7840_open: bulkin endpoint is %d", | 1125 | dbg("mos7840_open: bulkin endpoint is %d", |
1114 | port->bulk_in_endpointAddress); | 1126 | port->bulk_in_endpointAddress); |
@@ -1509,7 +1521,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1509 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); | 1521 | kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL); |
1510 | 1522 | ||
1511 | if (urb->transfer_buffer == NULL) { | 1523 | if (urb->transfer_buffer == NULL) { |
1512 | dev_err(&port->dev, "%s no more kernel memory...\n", | 1524 | dev_err_console(port, "%s no more kernel memory...\n", |
1513 | __func__); | 1525 | __func__); |
1514 | goto exit; | 1526 | goto exit; |
1515 | } | 1527 | } |
@@ -1519,13 +1531,25 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1519 | memcpy(urb->transfer_buffer, current_position, transfer_size); | 1531 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
1520 | 1532 | ||
1521 | /* fill urb with data and submit */ | 1533 | /* fill urb with data and submit */ |
1522 | usb_fill_bulk_urb(urb, | 1534 | if ((serial->num_ports == 2) |
1523 | serial->dev, | 1535 | && ((((__u16)port->number - |
1524 | usb_sndbulkpipe(serial->dev, | 1536 | (__u16)(port->serial->minor)) % 2) != 0)) { |
1525 | port->bulk_out_endpointAddress), | 1537 | usb_fill_bulk_urb(urb, |
1526 | urb->transfer_buffer, | 1538 | serial->dev, |
1527 | transfer_size, | 1539 | usb_sndbulkpipe(serial->dev, |
1528 | mos7840_bulk_out_data_callback, mos7840_port); | 1540 | (port->bulk_out_endpointAddress) + 2), |
1541 | urb->transfer_buffer, | ||
1542 | transfer_size, | ||
1543 | mos7840_bulk_out_data_callback, mos7840_port); | ||
1544 | } else { | ||
1545 | usb_fill_bulk_urb(urb, | ||
1546 | serial->dev, | ||
1547 | usb_sndbulkpipe(serial->dev, | ||
1548 | port->bulk_out_endpointAddress), | ||
1549 | urb->transfer_buffer, | ||
1550 | transfer_size, | ||
1551 | mos7840_bulk_out_data_callback, mos7840_port); | ||
1552 | } | ||
1529 | 1553 | ||
1530 | data1 = urb->transfer_buffer; | 1554 | data1 = urb->transfer_buffer; |
1531 | dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); | 1555 | dbg("bulkout endpoint is %d", port->bulk_out_endpointAddress); |
@@ -1535,7 +1559,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1535 | 1559 | ||
1536 | if (status) { | 1560 | if (status) { |
1537 | mos7840_port->busy[i] = 0; | 1561 | mos7840_port->busy[i] = 0; |
1538 | dev_err(&port->dev, "%s - usb_submit_urb(write bulk) failed " | 1562 | dev_err_console(port, "%s - usb_submit_urb(write bulk) failed " |
1539 | "with status = %d\n", __func__, status); | 1563 | "with status = %d\n", __func__, status); |
1540 | bytes_sent = status; | 1564 | bytes_sent = status; |
1541 | goto exit; | 1565 | goto exit; |
@@ -1838,7 +1862,7 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1838 | 1862 | ||
1839 | } else { | 1863 | } else { |
1840 | #ifdef HW_flow_control | 1864 | #ifdef HW_flow_control |
1841 | / *setting h/w flow control bit to 0 */ | 1865 | /* setting h/w flow control bit to 0 */ |
1842 | Data = 0xb; | 1866 | Data = 0xb; |
1843 | mos7840_port->shadowMCR = Data; | 1867 | mos7840_port->shadowMCR = Data; |
1844 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, | 1868 | status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, |
@@ -2305,19 +2329,26 @@ static int mos7840_ioctl(struct tty_struct *tty, | |||
2305 | 2329 | ||
2306 | static int mos7840_calc_num_ports(struct usb_serial *serial) | 2330 | static int mos7840_calc_num_ports(struct usb_serial *serial) |
2307 | { | 2331 | { |
2308 | int mos7840_num_ports = 0; | 2332 | __u16 Data = 0x00; |
2309 | 2333 | int ret = 0; | |
2310 | dbg("numberofendpoints: cur %d, alt %d", | 2334 | int mos7840_num_ports; |
2311 | (int)serial->interface->cur_altsetting->desc.bNumEndpoints, | 2335 | |
2312 | (int)serial->interface->altsetting->desc.bNumEndpoints); | 2336 | ret = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
2313 | if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) { | 2337 | MCS_RDREQ, MCS_RD_RTYPE, 0, GPIO_REGISTER, &Data, |
2314 | mos7840_num_ports = serial->num_ports = 2; | 2338 | VENDOR_READ_LENGTH, MOS_WDR_TIMEOUT); |
2315 | } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) { | 2339 | |
2340 | if ((Data & 0x01) == 0) { | ||
2341 | mos7840_num_ports = 2; | ||
2342 | serial->num_bulk_in = 2; | ||
2343 | serial->num_bulk_out = 2; | ||
2344 | serial->num_ports = 2; | ||
2345 | } else { | ||
2346 | mos7840_num_ports = 4; | ||
2316 | serial->num_bulk_in = 4; | 2347 | serial->num_bulk_in = 4; |
2317 | serial->num_bulk_out = 4; | 2348 | serial->num_bulk_out = 4; |
2318 | mos7840_num_ports = serial->num_ports = 4; | 2349 | serial->num_ports = 4; |
2319 | } | 2350 | } |
2320 | dbg ("mos7840_num_ports = %d", mos7840_num_ports); | 2351 | |
2321 | return mos7840_num_ports; | 2352 | return mos7840_num_ports; |
2322 | } | 2353 | } |
2323 | 2354 | ||
@@ -2638,7 +2669,6 @@ static struct usb_driver io_driver = { | |||
2638 | .probe = usb_serial_probe, | 2669 | .probe = usb_serial_probe, |
2639 | .disconnect = usb_serial_disconnect, | 2670 | .disconnect = usb_serial_disconnect, |
2640 | .id_table = moschip_id_table_combined, | 2671 | .id_table = moschip_id_table_combined, |
2641 | .no_dynamic_id = 1, | ||
2642 | }; | 2672 | }; |
2643 | 2673 | ||
2644 | static struct usb_serial_driver moschip7840_4port_device = { | 2674 | static struct usb_serial_driver moschip7840_4port_device = { |
@@ -2647,7 +2677,6 @@ static struct usb_serial_driver moschip7840_4port_device = { | |||
2647 | .name = "mos7840", | 2677 | .name = "mos7840", |
2648 | }, | 2678 | }, |
2649 | .description = DRIVER_DESC, | 2679 | .description = DRIVER_DESC, |
2650 | .usb_driver = &io_driver, | ||
2651 | .id_table = moschip_port_id_table, | 2680 | .id_table = moschip_port_id_table, |
2652 | .num_ports = 4, | 2681 | .num_ports = 4, |
2653 | .open = mos7840_open, | 2682 | .open = mos7840_open, |
@@ -2674,57 +2703,12 @@ static struct usb_serial_driver moschip7840_4port_device = { | |||
2674 | .read_int_callback = mos7840_interrupt_callback, | 2703 | .read_int_callback = mos7840_interrupt_callback, |
2675 | }; | 2704 | }; |
2676 | 2705 | ||
2677 | /**************************************************************************** | 2706 | static struct usb_serial_driver * const serial_drivers[] = { |
2678 | * moschip7840_init | 2707 | &moschip7840_4port_device, NULL |
2679 | * This is called by the module subsystem, or on startup to initialize us | 2708 | }; |
2680 | ****************************************************************************/ | ||
2681 | static int __init moschip7840_init(void) | ||
2682 | { | ||
2683 | int retval; | ||
2684 | |||
2685 | dbg("%s", " mos7840_init :entering.........."); | ||
2686 | |||
2687 | /* Register with the usb serial */ | ||
2688 | retval = usb_serial_register(&moschip7840_4port_device); | ||
2689 | |||
2690 | if (retval) | ||
2691 | goto failed_port_device_register; | ||
2692 | |||
2693 | dbg("%s", "Entering..."); | ||
2694 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
2695 | DRIVER_DESC "\n"); | ||
2696 | |||
2697 | /* Register with the usb */ | ||
2698 | retval = usb_register(&io_driver); | ||
2699 | if (retval == 0) { | ||
2700 | dbg("%s", "Leaving..."); | ||
2701 | return 0; | ||
2702 | } | ||
2703 | usb_serial_deregister(&moschip7840_4port_device); | ||
2704 | failed_port_device_register: | ||
2705 | return retval; | ||
2706 | } | ||
2707 | |||
2708 | /**************************************************************************** | ||
2709 | * moschip7840_exit | ||
2710 | * Called when the driver is about to be unloaded. | ||
2711 | ****************************************************************************/ | ||
2712 | static void __exit moschip7840_exit(void) | ||
2713 | { | ||
2714 | |||
2715 | dbg("%s", " mos7840_exit :entering.........."); | ||
2716 | |||
2717 | usb_deregister(&io_driver); | ||
2718 | |||
2719 | usb_serial_deregister(&moschip7840_4port_device); | ||
2720 | |||
2721 | dbg("%s", "Entering..."); | ||
2722 | } | ||
2723 | 2709 | ||
2724 | module_init(moschip7840_init); | 2710 | module_usb_serial_driver(io_driver, serial_drivers); |
2725 | module_exit(moschip7840_exit); | ||
2726 | 2711 | ||
2727 | /* Module information */ | ||
2728 | MODULE_DESCRIPTION(DRIVER_DESC); | 2712 | MODULE_DESCRIPTION(DRIVER_DESC); |
2729 | MODULE_LICENSE("GPL"); | 2713 | MODULE_LICENSE("GPL"); |
2730 | 2714 | ||
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c index e2bfecc46402..3ab6214b4bbf 100644 --- a/drivers/usb/serial/moto_modem.c +++ b/drivers/usb/serial/moto_modem.c | |||
@@ -36,7 +36,6 @@ static struct usb_driver moto_driver = { | |||
36 | .probe = usb_serial_probe, | 36 | .probe = usb_serial_probe, |
37 | .disconnect = usb_serial_disconnect, | 37 | .disconnect = usb_serial_disconnect, |
38 | .id_table = id_table, | 38 | .id_table = id_table, |
39 | .no_dynamic_id = 1, | ||
40 | }; | 39 | }; |
41 | 40 | ||
42 | static struct usb_serial_driver moto_device = { | 41 | static struct usb_serial_driver moto_device = { |
@@ -45,29 +44,12 @@ static struct usb_serial_driver moto_device = { | |||
45 | .name = "moto-modem", | 44 | .name = "moto-modem", |
46 | }, | 45 | }, |
47 | .id_table = id_table, | 46 | .id_table = id_table, |
48 | .usb_driver = &moto_driver, | ||
49 | .num_ports = 1, | 47 | .num_ports = 1, |
50 | }; | 48 | }; |
51 | 49 | ||
52 | static int __init moto_init(void) | 50 | static struct usb_serial_driver * const serial_drivers[] = { |
53 | { | 51 | &moto_device, NULL |
54 | int retval; | 52 | }; |
55 | |||
56 | retval = usb_serial_register(&moto_device); | ||
57 | if (retval) | ||
58 | return retval; | ||
59 | retval = usb_register(&moto_driver); | ||
60 | if (retval) | ||
61 | usb_serial_deregister(&moto_device); | ||
62 | return retval; | ||
63 | } | ||
64 | |||
65 | static void __exit moto_exit(void) | ||
66 | { | ||
67 | usb_deregister(&moto_driver); | ||
68 | usb_serial_deregister(&moto_device); | ||
69 | } | ||
70 | 53 | ||
71 | module_init(moto_init); | 54 | module_usb_serial_driver(moto_driver, serial_drivers); |
72 | module_exit(moto_exit); | ||
73 | MODULE_LICENSE("GPL"); | 55 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/navman.c b/drivers/usb/serial/navman.c index b28f1db0195f..29ab6eb5b536 100644 --- a/drivers/usb/serial/navman.c +++ b/drivers/usb/serial/navman.c | |||
@@ -35,7 +35,6 @@ static struct usb_driver navman_driver = { | |||
35 | .probe = usb_serial_probe, | 35 | .probe = usb_serial_probe, |
36 | .disconnect = usb_serial_disconnect, | 36 | .disconnect = usb_serial_disconnect, |
37 | .id_table = id_table, | 37 | .id_table = id_table, |
38 | .no_dynamic_id = 1, | ||
39 | }; | 38 | }; |
40 | 39 | ||
41 | static void navman_read_int_callback(struct urb *urb) | 40 | static void navman_read_int_callback(struct urb *urb) |
@@ -122,7 +121,6 @@ static struct usb_serial_driver navman_device = { | |||
122 | .name = "navman", | 121 | .name = "navman", |
123 | }, | 122 | }, |
124 | .id_table = id_table, | 123 | .id_table = id_table, |
125 | .usb_driver = &navman_driver, | ||
126 | .num_ports = 1, | 124 | .num_ports = 1, |
127 | .open = navman_open, | 125 | .open = navman_open, |
128 | .close = navman_close, | 126 | .close = navman_close, |
@@ -130,27 +128,12 @@ static struct usb_serial_driver navman_device = { | |||
130 | .read_int_callback = navman_read_int_callback, | 128 | .read_int_callback = navman_read_int_callback, |
131 | }; | 129 | }; |
132 | 130 | ||
133 | static int __init navman_init(void) | 131 | static struct usb_serial_driver * const serial_drivers[] = { |
134 | { | 132 | &navman_device, NULL |
135 | int retval; | 133 | }; |
136 | |||
137 | retval = usb_serial_register(&navman_device); | ||
138 | if (retval) | ||
139 | return retval; | ||
140 | retval = usb_register(&navman_driver); | ||
141 | if (retval) | ||
142 | usb_serial_deregister(&navman_device); | ||
143 | return retval; | ||
144 | } | ||
145 | 134 | ||
146 | static void __exit navman_exit(void) | 135 | module_usb_serial_driver(navman_driver, serial_drivers); |
147 | { | ||
148 | usb_deregister(&navman_driver); | ||
149 | usb_serial_deregister(&navman_device); | ||
150 | } | ||
151 | 136 | ||
152 | module_init(navman_init); | ||
153 | module_exit(navman_exit); | ||
154 | MODULE_LICENSE("GPL"); | 137 | MODULE_LICENSE("GPL"); |
155 | 138 | ||
156 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 139 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c index 8b8d58a2ac12..88dc785bb298 100644 --- a/drivers/usb/serial/omninet.c +++ b/drivers/usb/serial/omninet.c | |||
@@ -62,7 +62,6 @@ static struct usb_driver omninet_driver = { | |||
62 | .probe = usb_serial_probe, | 62 | .probe = usb_serial_probe, |
63 | .disconnect = usb_serial_disconnect, | 63 | .disconnect = usb_serial_disconnect, |
64 | .id_table = id_table, | 64 | .id_table = id_table, |
65 | .no_dynamic_id = 1, | ||
66 | }; | 65 | }; |
67 | 66 | ||
68 | 67 | ||
@@ -72,7 +71,6 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
72 | .name = "omninet", | 71 | .name = "omninet", |
73 | }, | 72 | }, |
74 | .description = "ZyXEL - omni.net lcd plus usb", | 73 | .description = "ZyXEL - omni.net lcd plus usb", |
75 | .usb_driver = &omninet_driver, | ||
76 | .id_table = id_table, | 74 | .id_table = id_table, |
77 | .num_ports = 1, | 75 | .num_ports = 1, |
78 | .attach = omninet_attach, | 76 | .attach = omninet_attach, |
@@ -86,6 +84,10 @@ static struct usb_serial_driver zyxel_omninet_device = { | |||
86 | .release = omninet_release, | 84 | .release = omninet_release, |
87 | }; | 85 | }; |
88 | 86 | ||
87 | static struct usb_serial_driver * const serial_drivers[] = { | ||
88 | &zyxel_omninet_device, NULL | ||
89 | }; | ||
90 | |||
89 | 91 | ||
90 | /* The protocol. | 92 | /* The protocol. |
91 | * | 93 | * |
@@ -254,7 +256,7 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
254 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); | 256 | result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); |
255 | if (result) { | 257 | if (result) { |
256 | set_bit(0, &wport->write_urbs_free); | 258 | set_bit(0, &wport->write_urbs_free); |
257 | dev_err(&port->dev, | 259 | dev_err_console(port, |
258 | "%s - failed submitting write urb, error %d\n", | 260 | "%s - failed submitting write urb, error %d\n", |
259 | __func__, result); | 261 | __func__, result); |
260 | } else | 262 | } else |
@@ -319,35 +321,7 @@ static void omninet_release(struct usb_serial *serial) | |||
319 | kfree(usb_get_serial_port_data(port)); | 321 | kfree(usb_get_serial_port_data(port)); |
320 | } | 322 | } |
321 | 323 | ||
322 | 324 | module_usb_serial_driver(omninet_driver, serial_drivers); | |
323 | static int __init omninet_init(void) | ||
324 | { | ||
325 | int retval; | ||
326 | retval = usb_serial_register(&zyxel_omninet_device); | ||
327 | if (retval) | ||
328 | goto failed_usb_serial_register; | ||
329 | retval = usb_register(&omninet_driver); | ||
330 | if (retval) | ||
331 | goto failed_usb_register; | ||
332 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
333 | DRIVER_DESC "\n"); | ||
334 | return 0; | ||
335 | failed_usb_register: | ||
336 | usb_serial_deregister(&zyxel_omninet_device); | ||
337 | failed_usb_serial_register: | ||
338 | return retval; | ||
339 | } | ||
340 | |||
341 | |||
342 | static void __exit omninet_exit(void) | ||
343 | { | ||
344 | usb_deregister(&omninet_driver); | ||
345 | usb_serial_deregister(&zyxel_omninet_device); | ||
346 | } | ||
347 | |||
348 | |||
349 | module_init(omninet_init); | ||
350 | module_exit(omninet_exit); | ||
351 | 325 | ||
352 | MODULE_AUTHOR(DRIVER_AUTHOR); | 326 | MODULE_AUTHOR(DRIVER_AUTHOR); |
353 | MODULE_DESCRIPTION(DRIVER_DESC); | 327 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c index 262ded9e076b..82cc9d202b83 100644 --- a/drivers/usb/serial/opticon.c +++ b/drivers/usb/serial/opticon.c | |||
@@ -604,7 +604,6 @@ static struct usb_driver opticon_driver = { | |||
604 | .suspend = opticon_suspend, | 604 | .suspend = opticon_suspend, |
605 | .resume = opticon_resume, | 605 | .resume = opticon_resume, |
606 | .id_table = id_table, | 606 | .id_table = id_table, |
607 | .no_dynamic_id = 1, | ||
608 | }; | 607 | }; |
609 | 608 | ||
610 | static struct usb_serial_driver opticon_device = { | 609 | static struct usb_serial_driver opticon_device = { |
@@ -613,7 +612,6 @@ static struct usb_serial_driver opticon_device = { | |||
613 | .name = "opticon", | 612 | .name = "opticon", |
614 | }, | 613 | }, |
615 | .id_table = id_table, | 614 | .id_table = id_table, |
616 | .usb_driver = &opticon_driver, | ||
617 | .num_ports = 1, | 615 | .num_ports = 1, |
618 | .attach = opticon_startup, | 616 | .attach = opticon_startup, |
619 | .open = opticon_open, | 617 | .open = opticon_open, |
@@ -629,27 +627,12 @@ static struct usb_serial_driver opticon_device = { | |||
629 | .tiocmset = opticon_tiocmset, | 627 | .tiocmset = opticon_tiocmset, |
630 | }; | 628 | }; |
631 | 629 | ||
632 | static int __init opticon_init(void) | 630 | static struct usb_serial_driver * const serial_drivers[] = { |
633 | { | 631 | &opticon_device, NULL |
634 | int retval; | 632 | }; |
635 | |||
636 | retval = usb_serial_register(&opticon_device); | ||
637 | if (retval) | ||
638 | return retval; | ||
639 | retval = usb_register(&opticon_driver); | ||
640 | if (retval) | ||
641 | usb_serial_deregister(&opticon_device); | ||
642 | return retval; | ||
643 | } | ||
644 | 633 | ||
645 | static void __exit opticon_exit(void) | 634 | module_usb_serial_driver(opticon_driver, serial_drivers); |
646 | { | ||
647 | usb_deregister(&opticon_driver); | ||
648 | usb_serial_deregister(&opticon_device); | ||
649 | } | ||
650 | 635 | ||
651 | module_init(opticon_init); | ||
652 | module_exit(opticon_exit); | ||
653 | MODULE_DESCRIPTION(DRIVER_DESC); | 636 | MODULE_DESCRIPTION(DRIVER_DESC); |
654 | MODULE_LICENSE("GPL"); | 637 | MODULE_LICENSE("GPL"); |
655 | 638 | ||
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index b54afceb9611..6815701cf656 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
@@ -307,6 +307,9 @@ static void option_instat_callback(struct urb *urb); | |||
307 | #define TELIT_VENDOR_ID 0x1bc7 | 307 | #define TELIT_VENDOR_ID 0x1bc7 |
308 | #define TELIT_PRODUCT_UC864E 0x1003 | 308 | #define TELIT_PRODUCT_UC864E 0x1003 |
309 | #define TELIT_PRODUCT_UC864G 0x1004 | 309 | #define TELIT_PRODUCT_UC864G 0x1004 |
310 | #define TELIT_PRODUCT_CC864_DUAL 0x1005 | ||
311 | #define TELIT_PRODUCT_CC864_SINGLE 0x1006 | ||
312 | #define TELIT_PRODUCT_DE910_DUAL 0x1010 | ||
310 | 313 | ||
311 | /* ZTE PRODUCTS */ | 314 | /* ZTE PRODUCTS */ |
312 | #define ZTE_VENDOR_ID 0x19d2 | 315 | #define ZTE_VENDOR_ID 0x19d2 |
@@ -484,6 +487,9 @@ static void option_instat_callback(struct urb *urb); | |||
484 | #define LG_VENDOR_ID 0x1004 | 487 | #define LG_VENDOR_ID 0x1004 |
485 | #define LG_PRODUCT_L02C 0x618f | 488 | #define LG_PRODUCT_L02C 0x618f |
486 | 489 | ||
490 | /* MediaTek products */ | ||
491 | #define MEDIATEK_VENDOR_ID 0x0e8d | ||
492 | |||
487 | /* some devices interfaces need special handling due to a number of reasons */ | 493 | /* some devices interfaces need special handling due to a number of reasons */ |
488 | enum option_blacklist_reason { | 494 | enum option_blacklist_reason { |
489 | OPTION_BLACKLIST_NONE = 0, | 495 | OPTION_BLACKLIST_NONE = 0, |
@@ -768,6 +774,9 @@ static const struct usb_device_id option_ids[] = { | |||
768 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) }, | 774 | { USB_DEVICE(CMOTECH_VENDOR_ID, CMOTECH_PRODUCT_6008) }, |
769 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, | 775 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864E) }, |
770 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, | 776 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UC864G) }, |
777 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_DUAL) }, | ||
778 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) }, | ||
779 | { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) }, | ||
771 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ | 780 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */ |
772 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), | 781 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0002, 0xff, 0xff, 0xff), |
773 | .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, | 782 | .driver_info = (kernel_ulong_t)&net_intf1_blacklist }, |
@@ -892,6 +901,8 @@ static const struct usb_device_id option_ids[] = { | |||
892 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, | 901 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, |
893 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) }, | 902 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0164, 0xff, 0xff, 0xff) }, |
894 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, | 903 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, |
904 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), | ||
905 | .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, | ||
895 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) }, | 906 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff) }, |
896 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) }, | 907 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff) }, |
897 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, | 908 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, |
@@ -1198,6 +1209,10 @@ static const struct usb_device_id option_ids[] = { | |||
1198 | { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, | 1209 | { USB_DEVICE_AND_INTERFACE_INFO(VIETTEL_VENDOR_ID, VIETTEL_PRODUCT_VT1000, 0xff, 0xff, 0xff) }, |
1199 | { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, | 1210 | { USB_DEVICE_AND_INTERFACE_INFO(ZD_VENDOR_ID, ZD_PRODUCT_7000, 0xff, 0xff, 0xff) }, |
1200 | { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */ | 1211 | { USB_DEVICE(LG_VENDOR_ID, LG_PRODUCT_L02C) }, /* docomo L-02C modem */ |
1212 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x00, 0x00) }, | ||
1213 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a1, 0xff, 0x02, 0x01) }, | ||
1214 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x00, 0x00) }, | ||
1215 | { USB_DEVICE_AND_INTERFACE_INFO(MEDIATEK_VENDOR_ID, 0x00a2, 0xff, 0x02, 0x01) }, /* MediaTek MT6276M modem & app port */ | ||
1201 | { } /* Terminating entry */ | 1216 | { } /* Terminating entry */ |
1202 | }; | 1217 | }; |
1203 | MODULE_DEVICE_TABLE(usb, option_ids); | 1218 | MODULE_DEVICE_TABLE(usb, option_ids); |
@@ -1212,7 +1227,6 @@ static struct usb_driver option_driver = { | |||
1212 | .supports_autosuspend = 1, | 1227 | .supports_autosuspend = 1, |
1213 | #endif | 1228 | #endif |
1214 | .id_table = option_ids, | 1229 | .id_table = option_ids, |
1215 | .no_dynamic_id = 1, | ||
1216 | }; | 1230 | }; |
1217 | 1231 | ||
1218 | /* The card has three separate interfaces, which the serial driver | 1232 | /* The card has three separate interfaces, which the serial driver |
@@ -1225,7 +1239,6 @@ static struct usb_serial_driver option_1port_device = { | |||
1225 | .name = "option1", | 1239 | .name = "option1", |
1226 | }, | 1240 | }, |
1227 | .description = "GSM modem (1-port)", | 1241 | .description = "GSM modem (1-port)", |
1228 | .usb_driver = &option_driver, | ||
1229 | .id_table = option_ids, | 1242 | .id_table = option_ids, |
1230 | .num_ports = 1, | 1243 | .num_ports = 1, |
1231 | .probe = option_probe, | 1244 | .probe = option_probe, |
@@ -1249,6 +1262,10 @@ static struct usb_serial_driver option_1port_device = { | |||
1249 | #endif | 1262 | #endif |
1250 | }; | 1263 | }; |
1251 | 1264 | ||
1265 | static struct usb_serial_driver * const serial_drivers[] = { | ||
1266 | &option_1port_device, NULL | ||
1267 | }; | ||
1268 | |||
1252 | static bool debug; | 1269 | static bool debug; |
1253 | 1270 | ||
1254 | /* per port private data */ | 1271 | /* per port private data */ |
@@ -1280,36 +1297,7 @@ struct option_port_private { | |||
1280 | unsigned long tx_start_time[N_OUT_URB]; | 1297 | unsigned long tx_start_time[N_OUT_URB]; |
1281 | }; | 1298 | }; |
1282 | 1299 | ||
1283 | /* Functions used by new usb-serial code. */ | 1300 | module_usb_serial_driver(option_driver, serial_drivers); |
1284 | static int __init option_init(void) | ||
1285 | { | ||
1286 | int retval; | ||
1287 | retval = usb_serial_register(&option_1port_device); | ||
1288 | if (retval) | ||
1289 | goto failed_1port_device_register; | ||
1290 | retval = usb_register(&option_driver); | ||
1291 | if (retval) | ||
1292 | goto failed_driver_register; | ||
1293 | |||
1294 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1295 | DRIVER_DESC "\n"); | ||
1296 | |||
1297 | return 0; | ||
1298 | |||
1299 | failed_driver_register: | ||
1300 | usb_serial_deregister(&option_1port_device); | ||
1301 | failed_1port_device_register: | ||
1302 | return retval; | ||
1303 | } | ||
1304 | |||
1305 | static void __exit option_exit(void) | ||
1306 | { | ||
1307 | usb_deregister(&option_driver); | ||
1308 | usb_serial_deregister(&option_1port_device); | ||
1309 | } | ||
1310 | |||
1311 | module_init(option_init); | ||
1312 | module_exit(option_exit); | ||
1313 | 1301 | ||
1314 | static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason, | 1302 | static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason, |
1315 | const struct option_blacklist_info *blacklist) | 1303 | const struct option_blacklist_info *blacklist) |
@@ -1360,6 +1348,7 @@ static int option_probe(struct usb_serial *serial, | |||
1360 | serial->interface->cur_altsetting->desc.bInterfaceNumber, | 1348 | serial->interface->cur_altsetting->desc.bInterfaceNumber, |
1361 | OPTION_BLACKLIST_RESERVED_IF, | 1349 | OPTION_BLACKLIST_RESERVED_IF, |
1362 | (const struct option_blacklist_info *) id->driver_info)) | 1350 | (const struct option_blacklist_info *) id->driver_info)) |
1351 | return -ENODEV; | ||
1363 | 1352 | ||
1364 | /* Don't bind network interface on Samsung GT-B3730, it is handled by a separate module */ | 1353 | /* Don't bind network interface on Samsung GT-B3730, it is handled by a separate module */ |
1365 | if (serial->dev->descriptor.idVendor == SAMSUNG_VENDOR_ID && | 1354 | if (serial->dev->descriptor.idVendor == SAMSUNG_VENDOR_ID && |
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c index e287fd32682c..5fdc33c6a3c0 100644 --- a/drivers/usb/serial/oti6858.c +++ b/drivers/usb/serial/oti6858.c | |||
@@ -71,7 +71,6 @@ static struct usb_driver oti6858_driver = { | |||
71 | .probe = usb_serial_probe, | 71 | .probe = usb_serial_probe, |
72 | .disconnect = usb_serial_disconnect, | 72 | .disconnect = usb_serial_disconnect, |
73 | .id_table = id_table, | 73 | .id_table = id_table, |
74 | .no_dynamic_id = 1, | ||
75 | }; | 74 | }; |
76 | 75 | ||
77 | static bool debug; | 76 | static bool debug; |
@@ -157,7 +156,6 @@ static struct usb_serial_driver oti6858_device = { | |||
157 | .name = "oti6858", | 156 | .name = "oti6858", |
158 | }, | 157 | }, |
159 | .id_table = id_table, | 158 | .id_table = id_table, |
160 | .usb_driver = &oti6858_driver, | ||
161 | .num_ports = 1, | 159 | .num_ports = 1, |
162 | .open = oti6858_open, | 160 | .open = oti6858_open, |
163 | .close = oti6858_close, | 161 | .close = oti6858_close, |
@@ -176,6 +174,10 @@ static struct usb_serial_driver oti6858_device = { | |||
176 | .release = oti6858_release, | 174 | .release = oti6858_release, |
177 | }; | 175 | }; |
178 | 176 | ||
177 | static struct usb_serial_driver * const serial_drivers[] = { | ||
178 | &oti6858_device, NULL | ||
179 | }; | ||
180 | |||
179 | struct oti6858_private { | 181 | struct oti6858_private { |
180 | spinlock_t lock; | 182 | spinlock_t lock; |
181 | 183 | ||
@@ -302,7 +304,7 @@ static void send_data(struct work_struct *work) | |||
302 | if (count != 0) { | 304 | if (count != 0) { |
303 | allow = kmalloc(1, GFP_KERNEL); | 305 | allow = kmalloc(1, GFP_KERNEL); |
304 | if (!allow) { | 306 | if (!allow) { |
305 | dev_err(&port->dev, "%s(): kmalloc failed\n", | 307 | dev_err_console(port, "%s(): kmalloc failed\n", |
306 | __func__); | 308 | __func__); |
307 | return; | 309 | return; |
308 | } | 310 | } |
@@ -334,7 +336,7 @@ static void send_data(struct work_struct *work) | |||
334 | port->write_urb->transfer_buffer_length = count; | 336 | port->write_urb->transfer_buffer_length = count; |
335 | result = usb_submit_urb(port->write_urb, GFP_NOIO); | 337 | result = usb_submit_urb(port->write_urb, GFP_NOIO); |
336 | if (result != 0) { | 338 | if (result != 0) { |
337 | dev_err(&port->dev, "%s(): usb_submit_urb() failed" | 339 | dev_err_console(port, "%s(): usb_submit_urb() failed" |
338 | " with error %d\n", __func__, result); | 340 | " with error %d\n", __func__, result); |
339 | priv->flags.write_urb_in_use = 0; | 341 | priv->flags.write_urb_in_use = 0; |
340 | } | 342 | } |
@@ -938,7 +940,7 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
938 | port->write_urb->transfer_buffer_length = 1; | 940 | port->write_urb->transfer_buffer_length = 1; |
939 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 941 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
940 | if (result) { | 942 | if (result) { |
941 | dev_err(&port->dev, "%s(): usb_submit_urb() failed," | 943 | dev_err_console(port, "%s(): usb_submit_urb() failed," |
942 | " error %d\n", __func__, result); | 944 | " error %d\n", __func__, result); |
943 | } else { | 945 | } else { |
944 | return; | 946 | return; |
@@ -956,29 +958,7 @@ static void oti6858_write_bulk_callback(struct urb *urb) | |||
956 | } | 958 | } |
957 | } | 959 | } |
958 | 960 | ||
959 | /* module description and (de)initialization */ | 961 | module_usb_serial_driver(oti6858_driver, serial_drivers); |
960 | |||
961 | static int __init oti6858_init(void) | ||
962 | { | ||
963 | int retval; | ||
964 | |||
965 | retval = usb_serial_register(&oti6858_device); | ||
966 | if (retval == 0) { | ||
967 | retval = usb_register(&oti6858_driver); | ||
968 | if (retval) | ||
969 | usb_serial_deregister(&oti6858_device); | ||
970 | } | ||
971 | return retval; | ||
972 | } | ||
973 | |||
974 | static void __exit oti6858_exit(void) | ||
975 | { | ||
976 | usb_deregister(&oti6858_driver); | ||
977 | usb_serial_deregister(&oti6858_device); | ||
978 | } | ||
979 | |||
980 | module_init(oti6858_init); | ||
981 | module_exit(oti6858_exit); | ||
982 | 962 | ||
983 | MODULE_DESCRIPTION(OTI6858_DESCRIPTION); | 963 | MODULE_DESCRIPTION(OTI6858_DESCRIPTION); |
984 | MODULE_AUTHOR(OTI6858_AUTHOR); | 964 | MODULE_AUTHOR(OTI6858_AUTHOR); |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index 3d8cda57ce7a..ff4a174fa5de 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -104,7 +104,6 @@ static struct usb_driver pl2303_driver = { | |||
104 | .id_table = id_table, | 104 | .id_table = id_table, |
105 | .suspend = usb_serial_suspend, | 105 | .suspend = usb_serial_suspend, |
106 | .resume = usb_serial_resume, | 106 | .resume = usb_serial_resume, |
107 | .no_dynamic_id = 1, | ||
108 | .supports_autosuspend = 1, | 107 | .supports_autosuspend = 1, |
109 | }; | 108 | }; |
110 | 109 | ||
@@ -834,7 +833,6 @@ static struct usb_serial_driver pl2303_device = { | |||
834 | .name = "pl2303", | 833 | .name = "pl2303", |
835 | }, | 834 | }, |
836 | .id_table = id_table, | 835 | .id_table = id_table, |
837 | .usb_driver = &pl2303_driver, | ||
838 | .num_ports = 1, | 836 | .num_ports = 1, |
839 | .bulk_in_size = 256, | 837 | .bulk_in_size = 256, |
840 | .bulk_out_size = 256, | 838 | .bulk_out_size = 256, |
@@ -853,32 +851,11 @@ static struct usb_serial_driver pl2303_device = { | |||
853 | .release = pl2303_release, | 851 | .release = pl2303_release, |
854 | }; | 852 | }; |
855 | 853 | ||
856 | static int __init pl2303_init(void) | 854 | static struct usb_serial_driver * const serial_drivers[] = { |
857 | { | 855 | &pl2303_device, NULL |
858 | int retval; | 856 | }; |
859 | |||
860 | retval = usb_serial_register(&pl2303_device); | ||
861 | if (retval) | ||
862 | goto failed_usb_serial_register; | ||
863 | retval = usb_register(&pl2303_driver); | ||
864 | if (retval) | ||
865 | goto failed_usb_register; | ||
866 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | ||
867 | return 0; | ||
868 | failed_usb_register: | ||
869 | usb_serial_deregister(&pl2303_device); | ||
870 | failed_usb_serial_register: | ||
871 | return retval; | ||
872 | } | ||
873 | |||
874 | static void __exit pl2303_exit(void) | ||
875 | { | ||
876 | usb_deregister(&pl2303_driver); | ||
877 | usb_serial_deregister(&pl2303_device); | ||
878 | } | ||
879 | 857 | ||
880 | module_init(pl2303_init); | 858 | module_usb_serial_driver(pl2303_driver, serial_drivers); |
881 | module_exit(pl2303_exit); | ||
882 | 859 | ||
883 | MODULE_DESCRIPTION(DRIVER_DESC); | 860 | MODULE_DESCRIPTION(DRIVER_DESC); |
884 | MODULE_LICENSE("GPL"); | 861 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/qcaux.c b/drivers/usb/serial/qcaux.c index a34819884c1a..966245680f55 100644 --- a/drivers/usb/serial/qcaux.c +++ b/drivers/usb/serial/qcaux.c | |||
@@ -82,7 +82,6 @@ static struct usb_driver qcaux_driver = { | |||
82 | .probe = usb_serial_probe, | 82 | .probe = usb_serial_probe, |
83 | .disconnect = usb_serial_disconnect, | 83 | .disconnect = usb_serial_disconnect, |
84 | .id_table = id_table, | 84 | .id_table = id_table, |
85 | .no_dynamic_id = 1, | ||
86 | }; | 85 | }; |
87 | 86 | ||
88 | static struct usb_serial_driver qcaux_device = { | 87 | static struct usb_serial_driver qcaux_device = { |
@@ -91,29 +90,12 @@ static struct usb_serial_driver qcaux_device = { | |||
91 | .name = "qcaux", | 90 | .name = "qcaux", |
92 | }, | 91 | }, |
93 | .id_table = id_table, | 92 | .id_table = id_table, |
94 | .usb_driver = &qcaux_driver, | ||
95 | .num_ports = 1, | 93 | .num_ports = 1, |
96 | }; | 94 | }; |
97 | 95 | ||
98 | static int __init qcaux_init(void) | 96 | static struct usb_serial_driver * const serial_drivers[] = { |
99 | { | 97 | &qcaux_device, NULL |
100 | int retval; | 98 | }; |
101 | |||
102 | retval = usb_serial_register(&qcaux_device); | ||
103 | if (retval) | ||
104 | return retval; | ||
105 | retval = usb_register(&qcaux_driver); | ||
106 | if (retval) | ||
107 | usb_serial_deregister(&qcaux_device); | ||
108 | return retval; | ||
109 | } | ||
110 | |||
111 | static void __exit qcaux_exit(void) | ||
112 | { | ||
113 | usb_deregister(&qcaux_driver); | ||
114 | usb_serial_deregister(&qcaux_device); | ||
115 | } | ||
116 | 99 | ||
117 | module_init(qcaux_init); | 100 | module_usb_serial_driver(qcaux_driver, serial_drivers); |
118 | module_exit(qcaux_exit); | ||
119 | MODULE_LICENSE("GPL"); | 101 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c index f98800f2324c..0206b10c9e6e 100644 --- a/drivers/usb/serial/qcserial.c +++ b/drivers/usb/serial/qcserial.c | |||
@@ -24,39 +24,44 @@ | |||
24 | 24 | ||
25 | static bool debug; | 25 | static bool debug; |
26 | 26 | ||
27 | #define DEVICE_G1K(v, p) \ | ||
28 | USB_DEVICE(v, p), .driver_info = 1 | ||
29 | |||
27 | static const struct usb_device_id id_table[] = { | 30 | static const struct usb_device_id id_table[] = { |
28 | {USB_DEVICE(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ | 31 | /* Gobi 1000 devices */ |
29 | {USB_DEVICE(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ | 32 | {DEVICE_G1K(0x05c6, 0x9211)}, /* Acer Gobi QDL device */ |
30 | {USB_DEVICE(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ | 33 | {DEVICE_G1K(0x05c6, 0x9212)}, /* Acer Gobi Modem Device */ |
31 | {USB_DEVICE(0x03f0, 0x201d)}, /* HP un2400 Gobi QDL Device */ | 34 | {DEVICE_G1K(0x03f0, 0x1f1d)}, /* HP un2400 Gobi Modem Device */ |
32 | {USB_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Mobile Broadband Module */ | 35 | {DEVICE_G1K(0x03f0, 0x201d)}, /* HP un2400 Gobi QDL Device */ |
33 | {USB_DEVICE(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */ | 36 | {DEVICE_G1K(0x04da, 0x250d)}, /* Panasonic Gobi Modem device */ |
34 | {USB_DEVICE(0x04da, 0x250c)}, /* Panasonic Gobi QDL device */ | 37 | {DEVICE_G1K(0x04da, 0x250c)}, /* Panasonic Gobi QDL device */ |
35 | {USB_DEVICE(0x413c, 0x8172)}, /* Dell Gobi Modem device */ | 38 | {DEVICE_G1K(0x413c, 0x8172)}, /* Dell Gobi Modem device */ |
36 | {USB_DEVICE(0x413c, 0x8171)}, /* Dell Gobi QDL device */ | 39 | {DEVICE_G1K(0x413c, 0x8171)}, /* Dell Gobi QDL device */ |
37 | {USB_DEVICE(0x1410, 0xa001)}, /* Novatel Gobi Modem device */ | 40 | {DEVICE_G1K(0x1410, 0xa001)}, /* Novatel Gobi Modem device */ |
38 | {USB_DEVICE(0x1410, 0xa008)}, /* Novatel Gobi QDL device */ | 41 | {DEVICE_G1K(0x1410, 0xa008)}, /* Novatel Gobi QDL device */ |
39 | {USB_DEVICE(0x1410, 0xa010)}, /* Novatel Gobi QDL device */ | 42 | {DEVICE_G1K(0x0b05, 0x1776)}, /* Asus Gobi Modem device */ |
40 | {USB_DEVICE(0x1410, 0xa011)}, /* Novatel Gobi QDL device */ | 43 | {DEVICE_G1K(0x0b05, 0x1774)}, /* Asus Gobi QDL device */ |
41 | {USB_DEVICE(0x1410, 0xa012)}, /* Novatel Gobi QDL device */ | 44 | {DEVICE_G1K(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */ |
42 | {USB_DEVICE(0x1410, 0xa013)}, /* Novatel Gobi QDL device */ | 45 | {DEVICE_G1K(0x19d2, 0xfff2)}, /* ONDA Gobi QDL device */ |
43 | {USB_DEVICE(0x1410, 0xa014)}, /* Novatel Gobi QDL device */ | 46 | {DEVICE_G1K(0x1557, 0x0a80)}, /* OQO Gobi QDL device */ |
44 | {USB_DEVICE(0x0b05, 0x1776)}, /* Asus Gobi Modem device */ | 47 | {DEVICE_G1K(0x05c6, 0x9001)}, /* Generic Gobi Modem device */ |
45 | {USB_DEVICE(0x0b05, 0x1774)}, /* Asus Gobi QDL device */ | 48 | {DEVICE_G1K(0x05c6, 0x9002)}, /* Generic Gobi Modem device */ |
46 | {USB_DEVICE(0x19d2, 0xfff3)}, /* ONDA Gobi Modem device */ | 49 | {DEVICE_G1K(0x05c6, 0x9202)}, /* Generic Gobi Modem device */ |
47 | {USB_DEVICE(0x19d2, 0xfff2)}, /* ONDA Gobi QDL device */ | 50 | {DEVICE_G1K(0x05c6, 0x9203)}, /* Generic Gobi Modem device */ |
48 | {USB_DEVICE(0x1557, 0x0a80)}, /* OQO Gobi QDL device */ | 51 | {DEVICE_G1K(0x05c6, 0x9222)}, /* Generic Gobi Modem device */ |
49 | {USB_DEVICE(0x05c6, 0x9001)}, /* Generic Gobi Modem device */ | 52 | {DEVICE_G1K(0x05c6, 0x9008)}, /* Generic Gobi QDL device */ |
50 | {USB_DEVICE(0x05c6, 0x9002)}, /* Generic Gobi Modem device */ | 53 | {DEVICE_G1K(0x05c6, 0x9009)}, /* Generic Gobi Modem device */ |
51 | {USB_DEVICE(0x05c6, 0x9202)}, /* Generic Gobi Modem device */ | 54 | {DEVICE_G1K(0x05c6, 0x9201)}, /* Generic Gobi QDL device */ |
52 | {USB_DEVICE(0x05c6, 0x9203)}, /* Generic Gobi Modem device */ | 55 | {DEVICE_G1K(0x05c6, 0x9221)}, /* Generic Gobi QDL device */ |
53 | {USB_DEVICE(0x05c6, 0x9222)}, /* Generic Gobi Modem device */ | 56 | {DEVICE_G1K(0x05c6, 0x9231)}, /* Generic Gobi QDL device */ |
54 | {USB_DEVICE(0x05c6, 0x9008)}, /* Generic Gobi QDL device */ | 57 | {DEVICE_G1K(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */ |
55 | {USB_DEVICE(0x05c6, 0x9009)}, /* Generic Gobi Modem device */ | 58 | |
56 | {USB_DEVICE(0x05c6, 0x9201)}, /* Generic Gobi QDL device */ | 59 | /* Gobi 2000 devices */ |
57 | {USB_DEVICE(0x05c6, 0x9221)}, /* Generic Gobi QDL device */ | 60 | {USB_DEVICE(0x1410, 0xa010)}, /* Novatel Gobi 2000 QDL device */ |
58 | {USB_DEVICE(0x05c6, 0x9231)}, /* Generic Gobi QDL device */ | 61 | {USB_DEVICE(0x1410, 0xa011)}, /* Novatel Gobi 2000 QDL device */ |
59 | {USB_DEVICE(0x1f45, 0x0001)}, /* Unknown Gobi QDL device */ | 62 | {USB_DEVICE(0x1410, 0xa012)}, /* Novatel Gobi 2000 QDL device */ |
63 | {USB_DEVICE(0x1410, 0xa013)}, /* Novatel Gobi 2000 QDL device */ | ||
64 | {USB_DEVICE(0x1410, 0xa014)}, /* Novatel Gobi 2000 QDL device */ | ||
60 | {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */ | 65 | {USB_DEVICE(0x413c, 0x8185)}, /* Dell Gobi 2000 QDL device (N0218, VU936) */ |
61 | {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */ | 66 | {USB_DEVICE(0x413c, 0x8186)}, /* Dell Gobi 2000 Modem device (N0218, VU936) */ |
62 | {USB_DEVICE(0x05c6, 0x9208)}, /* Generic Gobi 2000 QDL device */ | 67 | {USB_DEVICE(0x05c6, 0x9208)}, /* Generic Gobi 2000 QDL device */ |
@@ -92,6 +97,8 @@ static const struct usb_device_id id_table[] = { | |||
92 | {USB_DEVICE(0x05c6, 0x9204)}, /* Gobi 2000 QDL device */ | 97 | {USB_DEVICE(0x05c6, 0x9204)}, /* Gobi 2000 QDL device */ |
93 | {USB_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */ | 98 | {USB_DEVICE(0x05c6, 0x9205)}, /* Gobi 2000 Modem device */ |
94 | 99 | ||
100 | /* Gobi 3000 devices */ | ||
101 | {USB_DEVICE(0x03f0, 0x371d)}, /* HP un2430 Gobi 3000 QDL */ | ||
95 | {USB_DEVICE(0x05c6, 0x920c)}, /* Gobi 3000 QDL */ | 102 | {USB_DEVICE(0x05c6, 0x920c)}, /* Gobi 3000 QDL */ |
96 | {USB_DEVICE(0x05c6, 0x920d)}, /* Gobi 3000 Composite */ | 103 | {USB_DEVICE(0x05c6, 0x920d)}, /* Gobi 3000 Composite */ |
97 | {USB_DEVICE(0x1410, 0xa020)}, /* Novatel Gobi 3000 QDL */ | 104 | {USB_DEVICE(0x1410, 0xa020)}, /* Novatel Gobi 3000 QDL */ |
@@ -122,8 +129,10 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) | |||
122 | int retval = -ENODEV; | 129 | int retval = -ENODEV; |
123 | __u8 nintf; | 130 | __u8 nintf; |
124 | __u8 ifnum; | 131 | __u8 ifnum; |
132 | bool is_gobi1k = id->driver_info ? true : false; | ||
125 | 133 | ||
126 | dbg("%s", __func__); | 134 | dbg("%s", __func__); |
135 | dbg("Is Gobi 1000 = %d", is_gobi1k); | ||
127 | 136 | ||
128 | nintf = serial->dev->actconfig->desc.bNumInterfaces; | 137 | nintf = serial->dev->actconfig->desc.bNumInterfaces; |
129 | dbg("Num Interfaces = %d", nintf); | 138 | dbg("Num Interfaces = %d", nintf); |
@@ -169,15 +178,25 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) | |||
169 | 178 | ||
170 | case 3: | 179 | case 3: |
171 | case 4: | 180 | case 4: |
172 | /* Composite mode */ | 181 | /* Composite mode; don't bind to the QMI/net interface as that |
173 | /* ifnum == 0 is a broadband network adapter */ | 182 | * gets handled by other drivers. |
174 | if (ifnum == 1) { | 183 | */ |
175 | /* | 184 | |
176 | * Diagnostics Monitor (serial line 9600 8N1) | 185 | /* Gobi 1K USB layout: |
177 | * Qualcomm DM protocol | 186 | * 0: serial port (doesn't respond) |
178 | * use "libqcdm" (ModemManager) for communication | 187 | * 1: serial port (doesn't respond) |
179 | */ | 188 | * 2: AT-capable modem port |
180 | dbg("Diagnostics Monitor found"); | 189 | * 3: QMI/net |
190 | * | ||
191 | * Gobi 2K+ USB layout: | ||
192 | * 0: QMI/net | ||
193 | * 1: DM/DIAG (use libqcdm from ModemManager for communication) | ||
194 | * 2: AT-capable modem port | ||
195 | * 3: NMEA | ||
196 | */ | ||
197 | |||
198 | if (ifnum == 1 && !is_gobi1k) { | ||
199 | dbg("Gobi 2K+ DM/DIAG interface found"); | ||
181 | retval = usb_set_interface(serial->dev, ifnum, 0); | 200 | retval = usb_set_interface(serial->dev, ifnum, 0); |
182 | if (retval < 0) { | 201 | if (retval < 0) { |
183 | dev_err(&serial->dev->dev, | 202 | dev_err(&serial->dev->dev, |
@@ -196,13 +215,13 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) | |||
196 | retval = -ENODEV; | 215 | retval = -ENODEV; |
197 | kfree(data); | 216 | kfree(data); |
198 | } | 217 | } |
199 | } else if (ifnum==3) { | 218 | } else if (ifnum==3 && !is_gobi1k) { |
200 | /* | 219 | /* |
201 | * NMEA (serial line 9600 8N1) | 220 | * NMEA (serial line 9600 8N1) |
202 | * # echo "\$GPS_START" > /dev/ttyUSBx | 221 | * # echo "\$GPS_START" > /dev/ttyUSBx |
203 | * # echo "\$GPS_STOP" > /dev/ttyUSBx | 222 | * # echo "\$GPS_STOP" > /dev/ttyUSBx |
204 | */ | 223 | */ |
205 | dbg("NMEA GPS interface found"); | 224 | dbg("Gobi 2K+ NMEA GPS interface found"); |
206 | retval = usb_set_interface(serial->dev, ifnum, 0); | 225 | retval = usb_set_interface(serial->dev, ifnum, 0); |
207 | if (retval < 0) { | 226 | if (retval < 0) { |
208 | dev_err(&serial->dev->dev, | 227 | dev_err(&serial->dev->dev, |
@@ -246,7 +265,6 @@ static struct usb_serial_driver qcdevice = { | |||
246 | }, | 265 | }, |
247 | .description = "Qualcomm USB modem", | 266 | .description = "Qualcomm USB modem", |
248 | .id_table = id_table, | 267 | .id_table = id_table, |
249 | .usb_driver = &qcdriver, | ||
250 | .num_ports = 1, | 268 | .num_ports = 1, |
251 | .probe = qcprobe, | 269 | .probe = qcprobe, |
252 | .open = usb_wwan_open, | 270 | .open = usb_wwan_open, |
@@ -263,31 +281,11 @@ static struct usb_serial_driver qcdevice = { | |||
263 | #endif | 281 | #endif |
264 | }; | 282 | }; |
265 | 283 | ||
266 | static int __init qcinit(void) | 284 | static struct usb_serial_driver * const serial_drivers[] = { |
267 | { | 285 | &qcdevice, NULL |
268 | int retval; | 286 | }; |
269 | |||
270 | retval = usb_serial_register(&qcdevice); | ||
271 | if (retval) | ||
272 | return retval; | ||
273 | |||
274 | retval = usb_register(&qcdriver); | ||
275 | if (retval) { | ||
276 | usb_serial_deregister(&qcdevice); | ||
277 | return retval; | ||
278 | } | ||
279 | |||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | static void __exit qcexit(void) | ||
284 | { | ||
285 | usb_deregister(&qcdriver); | ||
286 | usb_serial_deregister(&qcdevice); | ||
287 | } | ||
288 | 287 | ||
289 | module_init(qcinit); | 288 | module_usb_serial_driver(qcdriver, serial_drivers); |
290 | module_exit(qcexit); | ||
291 | 289 | ||
292 | MODULE_AUTHOR(DRIVER_AUTHOR); | 290 | MODULE_AUTHOR(DRIVER_AUTHOR); |
293 | MODULE_DESCRIPTION(DRIVER_DESC); | 291 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c index d074b3740dcb..ae4ee30c7411 100644 --- a/drivers/usb/serial/safe_serial.c +++ b/drivers/usb/serial/safe_serial.c | |||
@@ -156,7 +156,6 @@ static struct usb_driver safe_driver = { | |||
156 | .probe = usb_serial_probe, | 156 | .probe = usb_serial_probe, |
157 | .disconnect = usb_serial_disconnect, | 157 | .disconnect = usb_serial_disconnect, |
158 | .id_table = id_table, | 158 | .id_table = id_table, |
159 | .no_dynamic_id = 1, | ||
160 | }; | 159 | }; |
161 | 160 | ||
162 | static const __u16 crc10_table[256] = { | 161 | static const __u16 crc10_table[256] = { |
@@ -309,16 +308,19 @@ static struct usb_serial_driver safe_device = { | |||
309 | .name = "safe_serial", | 308 | .name = "safe_serial", |
310 | }, | 309 | }, |
311 | .id_table = id_table, | 310 | .id_table = id_table, |
312 | .usb_driver = &safe_driver, | ||
313 | .num_ports = 1, | 311 | .num_ports = 1, |
314 | .process_read_urb = safe_process_read_urb, | 312 | .process_read_urb = safe_process_read_urb, |
315 | .prepare_write_buffer = safe_prepare_write_buffer, | 313 | .prepare_write_buffer = safe_prepare_write_buffer, |
316 | .attach = safe_startup, | 314 | .attach = safe_startup, |
317 | }; | 315 | }; |
318 | 316 | ||
317 | static struct usb_serial_driver * const serial_drivers[] = { | ||
318 | &safe_device, NULL | ||
319 | }; | ||
320 | |||
319 | static int __init safe_init(void) | 321 | static int __init safe_init(void) |
320 | { | 322 | { |
321 | int i, retval; | 323 | int i; |
322 | 324 | ||
323 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | 325 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" |
324 | DRIVER_DESC "\n"); | 326 | DRIVER_DESC "\n"); |
@@ -337,24 +339,12 @@ static int __init safe_init(void) | |||
337 | } | 339 | } |
338 | } | 340 | } |
339 | 341 | ||
340 | retval = usb_serial_register(&safe_device); | 342 | return usb_serial_register_drivers(&safe_driver, serial_drivers); |
341 | if (retval) | ||
342 | goto failed_usb_serial_register; | ||
343 | retval = usb_register(&safe_driver); | ||
344 | if (retval) | ||
345 | goto failed_usb_register; | ||
346 | |||
347 | return 0; | ||
348 | failed_usb_register: | ||
349 | usb_serial_deregister(&safe_device); | ||
350 | failed_usb_serial_register: | ||
351 | return retval; | ||
352 | } | 343 | } |
353 | 344 | ||
354 | static void __exit safe_exit(void) | 345 | static void __exit safe_exit(void) |
355 | { | 346 | { |
356 | usb_deregister(&safe_driver); | 347 | usb_serial_deregister_drivers(&safe_driver, serial_drivers); |
357 | usb_serial_deregister(&safe_device); | ||
358 | } | 348 | } |
359 | 349 | ||
360 | module_init(safe_init); | 350 | module_init(safe_init); |
diff --git a/drivers/usb/serial/siemens_mpi.c b/drivers/usb/serial/siemens_mpi.c index 74cd4ccdb3fc..46c0430fd38b 100644 --- a/drivers/usb/serial/siemens_mpi.c +++ b/drivers/usb/serial/siemens_mpi.c | |||
@@ -42,37 +42,15 @@ static struct usb_serial_driver siemens_usb_mpi_device = { | |||
42 | .name = "siemens_mpi", | 42 | .name = "siemens_mpi", |
43 | }, | 43 | }, |
44 | .id_table = id_table, | 44 | .id_table = id_table, |
45 | .usb_driver = &siemens_usb_mpi_driver, | ||
46 | .num_ports = 1, | 45 | .num_ports = 1, |
47 | }; | 46 | }; |
48 | 47 | ||
49 | static int __init siemens_usb_mpi_init(void) | 48 | static struct usb_serial_driver * const serial_drivers[] = { |
50 | { | 49 | &siemens_usb_mpi_device, NULL |
51 | int retval; | 50 | }; |
52 | |||
53 | retval = usb_serial_register(&siemens_usb_mpi_device); | ||
54 | if (retval) | ||
55 | goto failed_usb_serial_register; | ||
56 | retval = usb_register(&siemens_usb_mpi_driver); | ||
57 | if (retval) | ||
58 | goto failed_usb_register; | ||
59 | printk(KERN_INFO DRIVER_DESC "\n"); | ||
60 | printk(KERN_INFO DRIVER_VERSION " " DRIVER_AUTHOR "\n"); | ||
61 | return retval; | ||
62 | failed_usb_register: | ||
63 | usb_serial_deregister(&siemens_usb_mpi_device); | ||
64 | failed_usb_serial_register: | ||
65 | return retval; | ||
66 | } | ||
67 | 51 | ||
68 | static void __exit siemens_usb_mpi_exit(void) | 52 | module_usb_serial_driver(siemens_usb_mpi_driver, serial_drivers); |
69 | { | ||
70 | usb_deregister(&siemens_usb_mpi_driver); | ||
71 | usb_serial_deregister(&siemens_usb_mpi_device); | ||
72 | } | ||
73 | 53 | ||
74 | module_init(siemens_usb_mpi_init); | ||
75 | module_exit(siemens_usb_mpi_exit); | ||
76 | MODULE_AUTHOR(DRIVER_AUTHOR); | 54 | MODULE_AUTHOR(DRIVER_AUTHOR); |
77 | MODULE_DESCRIPTION(DRIVER_DESC); | 55 | MODULE_DESCRIPTION(DRIVER_DESC); |
78 | MODULE_LICENSE("GPL"); | 56 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c index fdae0a4407cb..f14465a83dd1 100644 --- a/drivers/usb/serial/sierra.c +++ b/drivers/usb/serial/sierra.c | |||
@@ -1084,7 +1084,6 @@ static struct usb_driver sierra_driver = { | |||
1084 | .resume = usb_serial_resume, | 1084 | .resume = usb_serial_resume, |
1085 | .reset_resume = sierra_reset_resume, | 1085 | .reset_resume = sierra_reset_resume, |
1086 | .id_table = id_table, | 1086 | .id_table = id_table, |
1087 | .no_dynamic_id = 1, | ||
1088 | .supports_autosuspend = 1, | 1087 | .supports_autosuspend = 1, |
1089 | }; | 1088 | }; |
1090 | 1089 | ||
@@ -1095,7 +1094,6 @@ static struct usb_serial_driver sierra_device = { | |||
1095 | }, | 1094 | }, |
1096 | .description = "Sierra USB modem", | 1095 | .description = "Sierra USB modem", |
1097 | .id_table = id_table, | 1096 | .id_table = id_table, |
1098 | .usb_driver = &sierra_driver, | ||
1099 | .calc_num_ports = sierra_calc_num_ports, | 1097 | .calc_num_ports = sierra_calc_num_ports, |
1100 | .probe = sierra_probe, | 1098 | .probe = sierra_probe, |
1101 | .open = sierra_open, | 1099 | .open = sierra_open, |
@@ -1113,38 +1111,11 @@ static struct usb_serial_driver sierra_device = { | |||
1113 | .read_int_callback = sierra_instat_callback, | 1111 | .read_int_callback = sierra_instat_callback, |
1114 | }; | 1112 | }; |
1115 | 1113 | ||
1116 | /* Functions used by new usb-serial code. */ | 1114 | static struct usb_serial_driver * const serial_drivers[] = { |
1117 | static int __init sierra_init(void) | 1115 | &sierra_device, NULL |
1118 | { | 1116 | }; |
1119 | int retval; | ||
1120 | retval = usb_serial_register(&sierra_device); | ||
1121 | if (retval) | ||
1122 | goto failed_device_register; | ||
1123 | |||
1124 | |||
1125 | retval = usb_register(&sierra_driver); | ||
1126 | if (retval) | ||
1127 | goto failed_driver_register; | ||
1128 | |||
1129 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1130 | DRIVER_DESC "\n"); | ||
1131 | |||
1132 | return 0; | ||
1133 | |||
1134 | failed_driver_register: | ||
1135 | usb_serial_deregister(&sierra_device); | ||
1136 | failed_device_register: | ||
1137 | return retval; | ||
1138 | } | ||
1139 | |||
1140 | static void __exit sierra_exit(void) | ||
1141 | { | ||
1142 | usb_deregister(&sierra_driver); | ||
1143 | usb_serial_deregister(&sierra_device); | ||
1144 | } | ||
1145 | 1117 | ||
1146 | module_init(sierra_init); | 1118 | module_usb_serial_driver(sierra_driver, serial_drivers); |
1147 | module_exit(sierra_exit); | ||
1148 | 1119 | ||
1149 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1120 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1150 | MODULE_DESCRIPTION(DRIVER_DESC); | 1121 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c index d7f5eee18f00..f06c9a8f3d37 100644 --- a/drivers/usb/serial/spcp8x5.c +++ b/drivers/usb/serial/spcp8x5.c | |||
@@ -156,7 +156,6 @@ static struct usb_driver spcp8x5_driver = { | |||
156 | .probe = usb_serial_probe, | 156 | .probe = usb_serial_probe, |
157 | .disconnect = usb_serial_disconnect, | 157 | .disconnect = usb_serial_disconnect, |
158 | .id_table = id_table, | 158 | .id_table = id_table, |
159 | .no_dynamic_id = 1, | ||
160 | }; | 159 | }; |
161 | 160 | ||
162 | 161 | ||
@@ -649,7 +648,6 @@ static struct usb_serial_driver spcp8x5_device = { | |||
649 | .name = "SPCP8x5", | 648 | .name = "SPCP8x5", |
650 | }, | 649 | }, |
651 | .id_table = id_table, | 650 | .id_table = id_table, |
652 | .usb_driver = &spcp8x5_driver, | ||
653 | .num_ports = 1, | 651 | .num_ports = 1, |
654 | .open = spcp8x5_open, | 652 | .open = spcp8x5_open, |
655 | .dtr_rts = spcp8x5_dtr_rts, | 653 | .dtr_rts = spcp8x5_dtr_rts, |
@@ -664,32 +662,11 @@ static struct usb_serial_driver spcp8x5_device = { | |||
664 | .process_read_urb = spcp8x5_process_read_urb, | 662 | .process_read_urb = spcp8x5_process_read_urb, |
665 | }; | 663 | }; |
666 | 664 | ||
667 | static int __init spcp8x5_init(void) | 665 | static struct usb_serial_driver * const serial_drivers[] = { |
668 | { | 666 | &spcp8x5_device, NULL |
669 | int retval; | 667 | }; |
670 | retval = usb_serial_register(&spcp8x5_device); | ||
671 | if (retval) | ||
672 | goto failed_usb_serial_register; | ||
673 | retval = usb_register(&spcp8x5_driver); | ||
674 | if (retval) | ||
675 | goto failed_usb_register; | ||
676 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
677 | DRIVER_DESC "\n"); | ||
678 | return 0; | ||
679 | failed_usb_register: | ||
680 | usb_serial_deregister(&spcp8x5_device); | ||
681 | failed_usb_serial_register: | ||
682 | return retval; | ||
683 | } | ||
684 | |||
685 | static void __exit spcp8x5_exit(void) | ||
686 | { | ||
687 | usb_deregister(&spcp8x5_driver); | ||
688 | usb_serial_deregister(&spcp8x5_device); | ||
689 | } | ||
690 | 668 | ||
691 | module_init(spcp8x5_init); | 669 | module_usb_serial_driver(spcp8x5_driver, serial_drivers); |
692 | module_exit(spcp8x5_exit); | ||
693 | 670 | ||
694 | MODULE_DESCRIPTION(DRIVER_DESC); | 671 | MODULE_DESCRIPTION(DRIVER_DESC); |
695 | MODULE_VERSION(DRIVER_VERSION); | 672 | MODULE_VERSION(DRIVER_VERSION); |
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c index 7697858d8858..3cdc8a52de44 100644 --- a/drivers/usb/serial/ssu100.c +++ b/drivers/usb/serial/ssu100.c | |||
@@ -70,7 +70,6 @@ static struct usb_driver ssu100_driver = { | |||
70 | .id_table = id_table, | 70 | .id_table = id_table, |
71 | .suspend = usb_serial_suspend, | 71 | .suspend = usb_serial_suspend, |
72 | .resume = usb_serial_resume, | 72 | .resume = usb_serial_resume, |
73 | .no_dynamic_id = 1, | ||
74 | .supports_autosuspend = 1, | 73 | .supports_autosuspend = 1, |
75 | }; | 74 | }; |
76 | 75 | ||
@@ -677,7 +676,6 @@ static struct usb_serial_driver ssu100_device = { | |||
677 | }, | 676 | }, |
678 | .description = DRIVER_DESC, | 677 | .description = DRIVER_DESC, |
679 | .id_table = id_table, | 678 | .id_table = id_table, |
680 | .usb_driver = &ssu100_driver, | ||
681 | .num_ports = 1, | 679 | .num_ports = 1, |
682 | .open = ssu100_open, | 680 | .open = ssu100_open, |
683 | .close = ssu100_close, | 681 | .close = ssu100_close, |
@@ -693,41 +691,11 @@ static struct usb_serial_driver ssu100_device = { | |||
693 | .disconnect = usb_serial_generic_disconnect, | 691 | .disconnect = usb_serial_generic_disconnect, |
694 | }; | 692 | }; |
695 | 693 | ||
696 | static int __init ssu100_init(void) | 694 | static struct usb_serial_driver * const serial_drivers[] = { |
697 | { | 695 | &ssu100_device, NULL |
698 | int retval; | 696 | }; |
699 | |||
700 | dbg("%s", __func__); | ||
701 | |||
702 | /* register with usb-serial */ | ||
703 | retval = usb_serial_register(&ssu100_device); | ||
704 | |||
705 | if (retval) | ||
706 | goto failed_usb_sio_register; | ||
707 | |||
708 | retval = usb_register(&ssu100_driver); | ||
709 | if (retval) | ||
710 | goto failed_usb_register; | ||
711 | |||
712 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
713 | DRIVER_DESC "\n"); | ||
714 | |||
715 | return 0; | ||
716 | |||
717 | failed_usb_register: | ||
718 | usb_serial_deregister(&ssu100_device); | ||
719 | failed_usb_sio_register: | ||
720 | return retval; | ||
721 | } | ||
722 | |||
723 | static void __exit ssu100_exit(void) | ||
724 | { | ||
725 | usb_deregister(&ssu100_driver); | ||
726 | usb_serial_deregister(&ssu100_device); | ||
727 | } | ||
728 | 697 | ||
729 | module_init(ssu100_init); | 698 | module_usb_serial_driver(ssu100_driver, serial_drivers); |
730 | module_exit(ssu100_exit); | ||
731 | 699 | ||
732 | MODULE_DESCRIPTION(DRIVER_DESC); | 700 | MODULE_DESCRIPTION(DRIVER_DESC); |
733 | MODULE_LICENSE("GPL"); | 701 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/symbolserial.c b/drivers/usb/serial/symbolserial.c index 50651cf4fc61..1a5be136e6cf 100644 --- a/drivers/usb/serial/symbolserial.c +++ b/drivers/usb/serial/symbolserial.c | |||
@@ -287,7 +287,6 @@ static struct usb_driver symbol_driver = { | |||
287 | .probe = usb_serial_probe, | 287 | .probe = usb_serial_probe, |
288 | .disconnect = usb_serial_disconnect, | 288 | .disconnect = usb_serial_disconnect, |
289 | .id_table = id_table, | 289 | .id_table = id_table, |
290 | .no_dynamic_id = 1, | ||
291 | }; | 290 | }; |
292 | 291 | ||
293 | static struct usb_serial_driver symbol_device = { | 292 | static struct usb_serial_driver symbol_device = { |
@@ -296,7 +295,6 @@ static struct usb_serial_driver symbol_device = { | |||
296 | .name = "symbol", | 295 | .name = "symbol", |
297 | }, | 296 | }, |
298 | .id_table = id_table, | 297 | .id_table = id_table, |
299 | .usb_driver = &symbol_driver, | ||
300 | .num_ports = 1, | 298 | .num_ports = 1, |
301 | .attach = symbol_startup, | 299 | .attach = symbol_startup, |
302 | .open = symbol_open, | 300 | .open = symbol_open, |
@@ -307,27 +305,12 @@ static struct usb_serial_driver symbol_device = { | |||
307 | .unthrottle = symbol_unthrottle, | 305 | .unthrottle = symbol_unthrottle, |
308 | }; | 306 | }; |
309 | 307 | ||
310 | static int __init symbol_init(void) | 308 | static struct usb_serial_driver * const serial_drivers[] = { |
311 | { | 309 | &symbol_device, NULL |
312 | int retval; | 310 | }; |
313 | |||
314 | retval = usb_serial_register(&symbol_device); | ||
315 | if (retval) | ||
316 | return retval; | ||
317 | retval = usb_register(&symbol_driver); | ||
318 | if (retval) | ||
319 | usb_serial_deregister(&symbol_device); | ||
320 | return retval; | ||
321 | } | ||
322 | 311 | ||
323 | static void __exit symbol_exit(void) | 312 | module_usb_serial_driver(symbol_driver, serial_drivers); |
324 | { | ||
325 | usb_deregister(&symbol_driver); | ||
326 | usb_serial_deregister(&symbol_device); | ||
327 | } | ||
328 | 313 | ||
329 | module_init(symbol_init); | ||
330 | module_exit(symbol_exit); | ||
331 | MODULE_LICENSE("GPL"); | 314 | MODULE_LICENSE("GPL"); |
332 | 315 | ||
333 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 316 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 75b838eff178..ab74123d658e 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
@@ -216,7 +216,6 @@ static struct usb_driver ti_usb_driver = { | |||
216 | .probe = usb_serial_probe, | 216 | .probe = usb_serial_probe, |
217 | .disconnect = usb_serial_disconnect, | 217 | .disconnect = usb_serial_disconnect, |
218 | .id_table = ti_id_table_combined, | 218 | .id_table = ti_id_table_combined, |
219 | .no_dynamic_id = 1, | ||
220 | }; | 219 | }; |
221 | 220 | ||
222 | static struct usb_serial_driver ti_1port_device = { | 221 | static struct usb_serial_driver ti_1port_device = { |
@@ -225,7 +224,6 @@ static struct usb_serial_driver ti_1port_device = { | |||
225 | .name = "ti_usb_3410_5052_1", | 224 | .name = "ti_usb_3410_5052_1", |
226 | }, | 225 | }, |
227 | .description = "TI USB 3410 1 port adapter", | 226 | .description = "TI USB 3410 1 port adapter", |
228 | .usb_driver = &ti_usb_driver, | ||
229 | .id_table = ti_id_table_3410, | 227 | .id_table = ti_id_table_3410, |
230 | .num_ports = 1, | 228 | .num_ports = 1, |
231 | .attach = ti_startup, | 229 | .attach = ti_startup, |
@@ -254,7 +252,6 @@ static struct usb_serial_driver ti_2port_device = { | |||
254 | .name = "ti_usb_3410_5052_2", | 252 | .name = "ti_usb_3410_5052_2", |
255 | }, | 253 | }, |
256 | .description = "TI USB 5052 2 port adapter", | 254 | .description = "TI USB 5052 2 port adapter", |
257 | .usb_driver = &ti_usb_driver, | ||
258 | .id_table = ti_id_table_5052, | 255 | .id_table = ti_id_table_5052, |
259 | .num_ports = 2, | 256 | .num_ports = 2, |
260 | .attach = ti_startup, | 257 | .attach = ti_startup, |
@@ -277,6 +274,9 @@ static struct usb_serial_driver ti_2port_device = { | |||
277 | .write_bulk_callback = ti_bulk_out_callback, | 274 | .write_bulk_callback = ti_bulk_out_callback, |
278 | }; | 275 | }; |
279 | 276 | ||
277 | static struct usb_serial_driver * const serial_drivers[] = { | ||
278 | &ti_1port_device, &ti_2port_device, NULL | ||
279 | }; | ||
280 | 280 | ||
281 | /* Module */ | 281 | /* Module */ |
282 | 282 | ||
@@ -344,36 +344,17 @@ static int __init ti_init(void) | |||
344 | ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE; | 344 | ti_id_table_combined[c].match_flags = USB_DEVICE_ID_MATCH_DEVICE; |
345 | } | 345 | } |
346 | 346 | ||
347 | ret = usb_serial_register(&ti_1port_device); | 347 | ret = usb_serial_register_drivers(&ti_usb_driver, serial_drivers); |
348 | if (ret) | 348 | if (ret == 0) |
349 | goto failed_1port; | 349 | printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":" |
350 | ret = usb_serial_register(&ti_2port_device); | 350 | TI_DRIVER_DESC "\n"); |
351 | if (ret) | ||
352 | goto failed_2port; | ||
353 | |||
354 | ret = usb_register(&ti_usb_driver); | ||
355 | if (ret) | ||
356 | goto failed_usb; | ||
357 | |||
358 | printk(KERN_INFO KBUILD_MODNAME ": " TI_DRIVER_VERSION ":" | ||
359 | TI_DRIVER_DESC "\n"); | ||
360 | |||
361 | return 0; | ||
362 | |||
363 | failed_usb: | ||
364 | usb_serial_deregister(&ti_2port_device); | ||
365 | failed_2port: | ||
366 | usb_serial_deregister(&ti_1port_device); | ||
367 | failed_1port: | ||
368 | return ret; | 351 | return ret; |
369 | } | 352 | } |
370 | 353 | ||
371 | 354 | ||
372 | static void __exit ti_exit(void) | 355 | static void __exit ti_exit(void) |
373 | { | 356 | { |
374 | usb_deregister(&ti_usb_driver); | 357 | usb_serial_deregister_drivers(&ti_usb_driver, serial_drivers); |
375 | usb_serial_deregister(&ti_1port_device); | ||
376 | usb_serial_deregister(&ti_2port_device); | ||
377 | } | 358 | } |
378 | 359 | ||
379 | 360 | ||
@@ -1250,7 +1231,6 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1250 | { | 1231 | { |
1251 | struct ti_port *tport = urb->context; | 1232 | struct ti_port *tport = urb->context; |
1252 | struct usb_serial_port *port = tport->tp_port; | 1233 | struct usb_serial_port *port = tport->tp_port; |
1253 | struct device *dev = &urb->dev->dev; | ||
1254 | int status = urb->status; | 1234 | int status = urb->status; |
1255 | 1235 | ||
1256 | dbg("%s - port %d", __func__, port->number); | 1236 | dbg("%s - port %d", __func__, port->number); |
@@ -1268,7 +1248,7 @@ static void ti_bulk_out_callback(struct urb *urb) | |||
1268 | wake_up_interruptible(&tport->tp_write_wait); | 1248 | wake_up_interruptible(&tport->tp_write_wait); |
1269 | return; | 1249 | return; |
1270 | default: | 1250 | default: |
1271 | dev_err(dev, "%s - nonzero urb status, %d\n", | 1251 | dev_err_console(port, "%s - nonzero urb status, %d\n", |
1272 | __func__, status); | 1252 | __func__, status); |
1273 | tport->tp_tdev->td_urb_error = 1; | 1253 | tport->tp_tdev->td_urb_error = 1; |
1274 | wake_up_interruptible(&tport->tp_write_wait); | 1254 | wake_up_interruptible(&tport->tp_write_wait); |
@@ -1337,7 +1317,7 @@ static void ti_send(struct ti_port *tport) | |||
1337 | 1317 | ||
1338 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 1318 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
1339 | if (result) { | 1319 | if (result) { |
1340 | dev_err(&port->dev, "%s - submit write urb failed, %d\n", | 1320 | dev_err_console(port, "%s - submit write urb failed, %d\n", |
1341 | __func__, result); | 1321 | __func__, result); |
1342 | tport->tp_write_urb_in_use = 0; | 1322 | tport->tp_write_urb_in_use = 0; |
1343 | /* TODO: reschedule ti_send */ | 1323 | /* TODO: reschedule ti_send */ |
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index d4e724d9b1f4..69230f01056a 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -1333,7 +1333,7 @@ static void fixup_generic(struct usb_serial_driver *device) | |||
1333 | set_to_generic_if_null(device, prepare_write_buffer); | 1333 | set_to_generic_if_null(device, prepare_write_buffer); |
1334 | } | 1334 | } |
1335 | 1335 | ||
1336 | int usb_serial_register(struct usb_serial_driver *driver) | 1336 | static int usb_serial_register(struct usb_serial_driver *driver) |
1337 | { | 1337 | { |
1338 | int retval; | 1338 | int retval; |
1339 | 1339 | ||
@@ -1367,10 +1367,8 @@ int usb_serial_register(struct usb_serial_driver *driver) | |||
1367 | mutex_unlock(&table_lock); | 1367 | mutex_unlock(&table_lock); |
1368 | return retval; | 1368 | return retval; |
1369 | } | 1369 | } |
1370 | EXPORT_SYMBOL_GPL(usb_serial_register); | ||
1371 | 1370 | ||
1372 | 1371 | static void usb_serial_deregister(struct usb_serial_driver *device) | |
1373 | void usb_serial_deregister(struct usb_serial_driver *device) | ||
1374 | { | 1372 | { |
1375 | printk(KERN_INFO "USB Serial deregistering driver %s\n", | 1373 | printk(KERN_INFO "USB Serial deregistering driver %s\n", |
1376 | device->description); | 1374 | device->description); |
@@ -1379,7 +1377,76 @@ void usb_serial_deregister(struct usb_serial_driver *device) | |||
1379 | usb_serial_bus_deregister(device); | 1377 | usb_serial_bus_deregister(device); |
1380 | mutex_unlock(&table_lock); | 1378 | mutex_unlock(&table_lock); |
1381 | } | 1379 | } |
1382 | EXPORT_SYMBOL_GPL(usb_serial_deregister); | 1380 | |
1381 | /** | ||
1382 | * usb_serial_register_drivers - register drivers for a usb-serial module | ||
1383 | * @udriver: usb_driver used for matching devices/interfaces | ||
1384 | * @serial_drivers: NULL-terminated array of pointers to drivers to be registered | ||
1385 | * | ||
1386 | * Registers @udriver and all the drivers in the @serial_drivers array. | ||
1387 | * Automatically fills in the .no_dynamic_id field in @udriver and | ||
1388 | * the .usb_driver field in each serial driver. | ||
1389 | */ | ||
1390 | int usb_serial_register_drivers(struct usb_driver *udriver, | ||
1391 | struct usb_serial_driver * const serial_drivers[]) | ||
1392 | { | ||
1393 | int rc; | ||
1394 | const struct usb_device_id *saved_id_table; | ||
1395 | struct usb_serial_driver * const *sd; | ||
1396 | |||
1397 | /* | ||
1398 | * udriver must be registered before any of the serial drivers, | ||
1399 | * because the store_new_id() routine for the serial drivers (in | ||
1400 | * bus.c) probes udriver. | ||
1401 | * | ||
1402 | * Performance hack: We don't want udriver to be probed until | ||
1403 | * the serial drivers are registered, because the probe would | ||
1404 | * simply fail for lack of a matching serial driver. | ||
1405 | * Therefore save off udriver's id_table until we are all set. | ||
1406 | */ | ||
1407 | saved_id_table = udriver->id_table; | ||
1408 | udriver->id_table = NULL; | ||
1409 | |||
1410 | udriver->no_dynamic_id = 1; | ||
1411 | rc = usb_register(udriver); | ||
1412 | if (rc) | ||
1413 | return rc; | ||
1414 | |||
1415 | for (sd = serial_drivers; *sd; ++sd) { | ||
1416 | (*sd)->usb_driver = udriver; | ||
1417 | rc = usb_serial_register(*sd); | ||
1418 | if (rc) | ||
1419 | goto failed; | ||
1420 | } | ||
1421 | |||
1422 | /* Now restore udriver's id_table and look for matches */ | ||
1423 | udriver->id_table = saved_id_table; | ||
1424 | rc = driver_attach(&udriver->drvwrap.driver); | ||
1425 | return 0; | ||
1426 | |||
1427 | failed: | ||
1428 | while (sd-- > serial_drivers) | ||
1429 | usb_serial_deregister(*sd); | ||
1430 | usb_deregister(udriver); | ||
1431 | return rc; | ||
1432 | } | ||
1433 | EXPORT_SYMBOL_GPL(usb_serial_register_drivers); | ||
1434 | |||
1435 | /** | ||
1436 | * usb_serial_deregister_drivers - deregister drivers for a usb-serial module | ||
1437 | * @udriver: usb_driver to unregister | ||
1438 | * @serial_drivers: NULL-terminated array of pointers to drivers to be deregistered | ||
1439 | * | ||
1440 | * Deregisters @udriver and all the drivers in the @serial_drivers array. | ||
1441 | */ | ||
1442 | void usb_serial_deregister_drivers(struct usb_driver *udriver, | ||
1443 | struct usb_serial_driver * const serial_drivers[]) | ||
1444 | { | ||
1445 | for (; *serial_drivers; ++serial_drivers) | ||
1446 | usb_serial_deregister(*serial_drivers); | ||
1447 | usb_deregister(udriver); | ||
1448 | } | ||
1449 | EXPORT_SYMBOL_GPL(usb_serial_deregister_drivers); | ||
1383 | 1450 | ||
1384 | /* Module information */ | 1451 | /* Module information */ |
1385 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1452 | MODULE_AUTHOR(DRIVER_AUTHOR); |
diff --git a/drivers/usb/serial/usb_debug.c b/drivers/usb/serial/usb_debug.c index 9b632e753210..e3e8995a4739 100644 --- a/drivers/usb/serial/usb_debug.c +++ b/drivers/usb/serial/usb_debug.c | |||
@@ -40,7 +40,6 @@ static struct usb_driver debug_driver = { | |||
40 | .probe = usb_serial_probe, | 40 | .probe = usb_serial_probe, |
41 | .disconnect = usb_serial_disconnect, | 41 | .disconnect = usb_serial_disconnect, |
42 | .id_table = id_table, | 42 | .id_table = id_table, |
43 | .no_dynamic_id = 1, | ||
44 | }; | 43 | }; |
45 | 44 | ||
46 | /* This HW really does not support a serial break, so one will be | 45 | /* This HW really does not support a serial break, so one will be |
@@ -74,32 +73,15 @@ static struct usb_serial_driver debug_device = { | |||
74 | .name = "debug", | 73 | .name = "debug", |
75 | }, | 74 | }, |
76 | .id_table = id_table, | 75 | .id_table = id_table, |
77 | .usb_driver = &debug_driver, | ||
78 | .num_ports = 1, | 76 | .num_ports = 1, |
79 | .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE, | 77 | .bulk_out_size = USB_DEBUG_MAX_PACKET_SIZE, |
80 | .break_ctl = usb_debug_break_ctl, | 78 | .break_ctl = usb_debug_break_ctl, |
81 | .process_read_urb = usb_debug_process_read_urb, | 79 | .process_read_urb = usb_debug_process_read_urb, |
82 | }; | 80 | }; |
83 | 81 | ||
84 | static int __init debug_init(void) | 82 | static struct usb_serial_driver * const serial_drivers[] = { |
85 | { | 83 | &debug_device, NULL |
86 | int retval; | 84 | }; |
87 | |||
88 | retval = usb_serial_register(&debug_device); | ||
89 | if (retval) | ||
90 | return retval; | ||
91 | retval = usb_register(&debug_driver); | ||
92 | if (retval) | ||
93 | usb_serial_deregister(&debug_device); | ||
94 | return retval; | ||
95 | } | ||
96 | |||
97 | static void __exit debug_exit(void) | ||
98 | { | ||
99 | usb_deregister(&debug_driver); | ||
100 | usb_serial_deregister(&debug_device); | ||
101 | } | ||
102 | 85 | ||
103 | module_init(debug_init); | 86 | module_usb_serial_driver(debug_driver, serial_drivers); |
104 | module_exit(debug_exit); | ||
105 | MODULE_LICENSE("GPL"); | 87 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 210e4b10dc11..71d696474f24 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -173,7 +173,6 @@ static struct usb_driver visor_driver = { | |||
173 | .probe = usb_serial_probe, | 173 | .probe = usb_serial_probe, |
174 | .disconnect = usb_serial_disconnect, | 174 | .disconnect = usb_serial_disconnect, |
175 | .id_table = id_table_combined, | 175 | .id_table = id_table_combined, |
176 | .no_dynamic_id = 1, | ||
177 | }; | 176 | }; |
178 | 177 | ||
179 | /* All of the device info needed for the Handspring Visor, | 178 | /* All of the device info needed for the Handspring Visor, |
@@ -184,7 +183,6 @@ static struct usb_serial_driver handspring_device = { | |||
184 | .name = "visor", | 183 | .name = "visor", |
185 | }, | 184 | }, |
186 | .description = "Handspring Visor / Palm OS", | 185 | .description = "Handspring Visor / Palm OS", |
187 | .usb_driver = &visor_driver, | ||
188 | .id_table = id_table, | 186 | .id_table = id_table, |
189 | .num_ports = 2, | 187 | .num_ports = 2, |
190 | .bulk_out_size = 256, | 188 | .bulk_out_size = 256, |
@@ -205,7 +203,6 @@ static struct usb_serial_driver clie_5_device = { | |||
205 | .name = "clie_5", | 203 | .name = "clie_5", |
206 | }, | 204 | }, |
207 | .description = "Sony Clie 5.0", | 205 | .description = "Sony Clie 5.0", |
208 | .usb_driver = &visor_driver, | ||
209 | .id_table = clie_id_5_table, | 206 | .id_table = clie_id_5_table, |
210 | .num_ports = 2, | 207 | .num_ports = 2, |
211 | .bulk_out_size = 256, | 208 | .bulk_out_size = 256, |
@@ -226,7 +223,6 @@ static struct usb_serial_driver clie_3_5_device = { | |||
226 | .name = "clie_3.5", | 223 | .name = "clie_3.5", |
227 | }, | 224 | }, |
228 | .description = "Sony Clie 3.5", | 225 | .description = "Sony Clie 3.5", |
229 | .usb_driver = &visor_driver, | ||
230 | .id_table = clie_id_3_5_table, | 226 | .id_table = clie_id_3_5_table, |
231 | .num_ports = 1, | 227 | .num_ports = 1, |
232 | .bulk_out_size = 256, | 228 | .bulk_out_size = 256, |
@@ -237,6 +233,10 @@ static struct usb_serial_driver clie_3_5_device = { | |||
237 | .attach = clie_3_5_startup, | 233 | .attach = clie_3_5_startup, |
238 | }; | 234 | }; |
239 | 235 | ||
236 | static struct usb_serial_driver * const serial_drivers[] = { | ||
237 | &handspring_device, &clie_5_device, &clie_3_5_device, NULL | ||
238 | }; | ||
239 | |||
240 | /****************************************************************************** | 240 | /****************************************************************************** |
241 | * Handspring Visor specific driver functions | 241 | * Handspring Visor specific driver functions |
242 | ******************************************************************************/ | 242 | ******************************************************************************/ |
@@ -685,38 +685,17 @@ static int __init visor_init(void) | |||
685 | ": Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x\n", | 685 | ": Adding Palm OS protocol 4.x support for unknown device: 0x%x/0x%x\n", |
686 | vendor, product); | 686 | vendor, product); |
687 | } | 687 | } |
688 | retval = usb_serial_register(&handspring_device); | ||
689 | if (retval) | ||
690 | goto failed_handspring_register; | ||
691 | retval = usb_serial_register(&clie_3_5_device); | ||
692 | if (retval) | ||
693 | goto failed_clie_3_5_register; | ||
694 | retval = usb_serial_register(&clie_5_device); | ||
695 | if (retval) | ||
696 | goto failed_clie_5_register; | ||
697 | retval = usb_register(&visor_driver); | ||
698 | if (retval) | ||
699 | goto failed_usb_register; | ||
700 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); | ||
701 | 688 | ||
702 | return 0; | 689 | retval = usb_serial_register_drivers(&visor_driver, serial_drivers); |
703 | failed_usb_register: | 690 | if (retval == 0) |
704 | usb_serial_deregister(&clie_5_device); | 691 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
705 | failed_clie_5_register: | ||
706 | usb_serial_deregister(&clie_3_5_device); | ||
707 | failed_clie_3_5_register: | ||
708 | usb_serial_deregister(&handspring_device); | ||
709 | failed_handspring_register: | ||
710 | return retval; | 692 | return retval; |
711 | } | 693 | } |
712 | 694 | ||
713 | 695 | ||
714 | static void __exit visor_exit (void) | 696 | static void __exit visor_exit (void) |
715 | { | 697 | { |
716 | usb_deregister(&visor_driver); | 698 | usb_serial_deregister_drivers(&visor_driver, serial_drivers); |
717 | usb_serial_deregister(&handspring_device); | ||
718 | usb_serial_deregister(&clie_3_5_device); | ||
719 | usb_serial_deregister(&clie_5_device); | ||
720 | } | 699 | } |
721 | 700 | ||
722 | 701 | ||
diff --git a/drivers/usb/serial/vivopay-serial.c b/drivers/usb/serial/vivopay-serial.c index f719d00972fc..078f338b5feb 100644 --- a/drivers/usb/serial/vivopay-serial.c +++ b/drivers/usb/serial/vivopay-serial.c | |||
@@ -30,7 +30,6 @@ static struct usb_driver vivopay_serial_driver = { | |||
30 | .probe = usb_serial_probe, | 30 | .probe = usb_serial_probe, |
31 | .disconnect = usb_serial_disconnect, | 31 | .disconnect = usb_serial_disconnect, |
32 | .id_table = id_table, | 32 | .id_table = id_table, |
33 | .no_dynamic_id = 1, | ||
34 | }; | 33 | }; |
35 | 34 | ||
36 | static struct usb_serial_driver vivopay_serial_device = { | 35 | static struct usb_serial_driver vivopay_serial_device = { |
@@ -39,36 +38,14 @@ static struct usb_serial_driver vivopay_serial_device = { | |||
39 | .name = "vivopay-serial", | 38 | .name = "vivopay-serial", |
40 | }, | 39 | }, |
41 | .id_table = id_table, | 40 | .id_table = id_table, |
42 | .usb_driver = &vivopay_serial_driver, | ||
43 | .num_ports = 1, | 41 | .num_ports = 1, |
44 | }; | 42 | }; |
45 | 43 | ||
46 | static int __init vivopay_serial_init(void) | 44 | static struct usb_serial_driver * const serial_drivers[] = { |
47 | { | 45 | &vivopay_serial_device, NULL |
48 | int retval; | 46 | }; |
49 | retval = usb_serial_register(&vivopay_serial_device); | ||
50 | if (retval) | ||
51 | goto failed_usb_serial_register; | ||
52 | retval = usb_register(&vivopay_serial_driver); | ||
53 | if (retval) | ||
54 | goto failed_usb_register; | ||
55 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
56 | DRIVER_DESC "\n"); | ||
57 | return 0; | ||
58 | failed_usb_register: | ||
59 | usb_serial_deregister(&vivopay_serial_device); | ||
60 | failed_usb_serial_register: | ||
61 | return retval; | ||
62 | } | ||
63 | |||
64 | static void __exit vivopay_serial_exit(void) | ||
65 | { | ||
66 | usb_deregister(&vivopay_serial_driver); | ||
67 | usb_serial_deregister(&vivopay_serial_device); | ||
68 | } | ||
69 | 47 | ||
70 | module_init(vivopay_serial_init); | 48 | module_usb_serial_driver(vivopay_serial_driver, serial_drivers); |
71 | module_exit(vivopay_serial_exit); | ||
72 | 49 | ||
73 | MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>"); | 50 | MODULE_AUTHOR("Forest Bond <forest.bond@outpostembedded.com>"); |
74 | MODULE_DESCRIPTION(DRIVER_DESC); | 51 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 7e0acf5c8e38..407e23c87946 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -83,7 +83,6 @@ static struct usb_driver whiteheat_driver = { | |||
83 | .probe = usb_serial_probe, | 83 | .probe = usb_serial_probe, |
84 | .disconnect = usb_serial_disconnect, | 84 | .disconnect = usb_serial_disconnect, |
85 | .id_table = id_table_combined, | 85 | .id_table = id_table_combined, |
86 | .no_dynamic_id = 1, | ||
87 | }; | 86 | }; |
88 | 87 | ||
89 | /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ | 88 | /* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ |
@@ -121,7 +120,6 @@ static struct usb_serial_driver whiteheat_fake_device = { | |||
121 | .name = "whiteheatnofirm", | 120 | .name = "whiteheatnofirm", |
122 | }, | 121 | }, |
123 | .description = "Connect Tech - WhiteHEAT - (prerenumeration)", | 122 | .description = "Connect Tech - WhiteHEAT - (prerenumeration)", |
124 | .usb_driver = &whiteheat_driver, | ||
125 | .id_table = id_table_prerenumeration, | 123 | .id_table = id_table_prerenumeration, |
126 | .num_ports = 1, | 124 | .num_ports = 1, |
127 | .probe = whiteheat_firmware_download, | 125 | .probe = whiteheat_firmware_download, |
@@ -134,7 +132,6 @@ static struct usb_serial_driver whiteheat_device = { | |||
134 | .name = "whiteheat", | 132 | .name = "whiteheat", |
135 | }, | 133 | }, |
136 | .description = "Connect Tech - WhiteHEAT", | 134 | .description = "Connect Tech - WhiteHEAT", |
137 | .usb_driver = &whiteheat_driver, | ||
138 | .id_table = id_table_std, | 135 | .id_table = id_table_std, |
139 | .num_ports = 4, | 136 | .num_ports = 4, |
140 | .attach = whiteheat_attach, | 137 | .attach = whiteheat_attach, |
@@ -155,6 +152,9 @@ static struct usb_serial_driver whiteheat_device = { | |||
155 | .write_bulk_callback = whiteheat_write_callback, | 152 | .write_bulk_callback = whiteheat_write_callback, |
156 | }; | 153 | }; |
157 | 154 | ||
155 | static struct usb_serial_driver * const serial_drivers[] = { | ||
156 | &whiteheat_fake_device, &whiteheat_device, NULL | ||
157 | }; | ||
158 | 158 | ||
159 | struct whiteheat_command_private { | 159 | struct whiteheat_command_private { |
160 | struct mutex mutex; | 160 | struct mutex mutex; |
@@ -740,7 +740,7 @@ static int whiteheat_write(struct tty_struct *tty, | |||
740 | urb->transfer_buffer_length = bytes; | 740 | urb->transfer_buffer_length = bytes; |
741 | result = usb_submit_urb(urb, GFP_ATOMIC); | 741 | result = usb_submit_urb(urb, GFP_ATOMIC); |
742 | if (result) { | 742 | if (result) { |
743 | dev_err(&port->dev, | 743 | dev_err_console(port, |
744 | "%s - failed submitting write urb, error %d\n", | 744 | "%s - failed submitting write urb, error %d\n", |
745 | __func__, result); | 745 | __func__, result); |
746 | sent = result; | 746 | sent = result; |
@@ -1454,44 +1454,7 @@ out: | |||
1454 | tty_kref_put(tty); | 1454 | tty_kref_put(tty); |
1455 | } | 1455 | } |
1456 | 1456 | ||
1457 | 1457 | module_usb_serial_driver(whiteheat_driver, serial_drivers); | |
1458 | /***************************************************************************** | ||
1459 | * Connect Tech's White Heat module functions | ||
1460 | *****************************************************************************/ | ||
1461 | static int __init whiteheat_init(void) | ||
1462 | { | ||
1463 | int retval; | ||
1464 | retval = usb_serial_register(&whiteheat_fake_device); | ||
1465 | if (retval) | ||
1466 | goto failed_fake_register; | ||
1467 | retval = usb_serial_register(&whiteheat_device); | ||
1468 | if (retval) | ||
1469 | goto failed_device_register; | ||
1470 | retval = usb_register(&whiteheat_driver); | ||
1471 | if (retval) | ||
1472 | goto failed_usb_register; | ||
1473 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":" | ||
1474 | DRIVER_DESC "\n"); | ||
1475 | return 0; | ||
1476 | failed_usb_register: | ||
1477 | usb_serial_deregister(&whiteheat_device); | ||
1478 | failed_device_register: | ||
1479 | usb_serial_deregister(&whiteheat_fake_device); | ||
1480 | failed_fake_register: | ||
1481 | return retval; | ||
1482 | } | ||
1483 | |||
1484 | |||
1485 | static void __exit whiteheat_exit(void) | ||
1486 | { | ||
1487 | usb_deregister(&whiteheat_driver); | ||
1488 | usb_serial_deregister(&whiteheat_fake_device); | ||
1489 | usb_serial_deregister(&whiteheat_device); | ||
1490 | } | ||
1491 | |||
1492 | |||
1493 | module_init(whiteheat_init); | ||
1494 | module_exit(whiteheat_exit); | ||
1495 | 1458 | ||
1496 | MODULE_AUTHOR(DRIVER_AUTHOR); | 1459 | MODULE_AUTHOR(DRIVER_AUTHOR); |
1497 | MODULE_DESCRIPTION(DRIVER_DESC); | 1460 | MODULE_DESCRIPTION(DRIVER_DESC); |
diff --git a/drivers/usb/serial/zio.c b/drivers/usb/serial/zio.c index f57967278833..9d0bb3752cd4 100644 --- a/drivers/usb/serial/zio.c +++ b/drivers/usb/serial/zio.c | |||
@@ -27,7 +27,6 @@ static struct usb_driver zio_driver = { | |||
27 | .probe = usb_serial_probe, | 27 | .probe = usb_serial_probe, |
28 | .disconnect = usb_serial_disconnect, | 28 | .disconnect = usb_serial_disconnect, |
29 | .id_table = id_table, | 29 | .id_table = id_table, |
30 | .no_dynamic_id = 1, | ||
31 | }; | 30 | }; |
32 | 31 | ||
33 | static struct usb_serial_driver zio_device = { | 32 | static struct usb_serial_driver zio_device = { |
@@ -36,29 +35,12 @@ static struct usb_serial_driver zio_device = { | |||
36 | .name = "zio", | 35 | .name = "zio", |
37 | }, | 36 | }, |
38 | .id_table = id_table, | 37 | .id_table = id_table, |
39 | .usb_driver = &zio_driver, | ||
40 | .num_ports = 1, | 38 | .num_ports = 1, |
41 | }; | 39 | }; |
42 | 40 | ||
43 | static int __init zio_init(void) | 41 | static struct usb_serial_driver * const serial_drivers[] = { |
44 | { | 42 | &zio_device, NULL |
45 | int retval; | 43 | }; |
46 | |||
47 | retval = usb_serial_register(&zio_device); | ||
48 | if (retval) | ||
49 | return retval; | ||
50 | retval = usb_register(&zio_driver); | ||
51 | if (retval) | ||
52 | usb_serial_deregister(&zio_device); | ||
53 | return retval; | ||
54 | } | ||
55 | |||
56 | static void __exit zio_exit(void) | ||
57 | { | ||
58 | usb_deregister(&zio_driver); | ||
59 | usb_serial_deregister(&zio_device); | ||
60 | } | ||
61 | 44 | ||
62 | module_init(zio_init); | 45 | module_usb_serial_driver(zio_driver, serial_drivers); |
63 | module_exit(zio_exit); | ||
64 | MODULE_LICENSE("GPL"); | 46 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 51af2fee2efd..bab8c8fe8290 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c | |||
@@ -1276,6 +1276,7 @@ static struct usb_driver alauda_driver = { | |||
1276 | .post_reset = usb_stor_post_reset, | 1276 | .post_reset = usb_stor_post_reset, |
1277 | .id_table = alauda_usb_ids, | 1277 | .id_table = alauda_usb_ids, |
1278 | .soft_unbind = 1, | 1278 | .soft_unbind = 1, |
1279 | .no_dynamic_id = 1, | ||
1279 | }; | 1280 | }; |
1280 | 1281 | ||
1281 | module_usb_driver(alauda_driver); | 1282 | module_usb_driver(alauda_driver); |
diff --git a/drivers/usb/storage/cypress_atacb.c b/drivers/usb/storage/cypress_atacb.c index 387cbd47acc9..5fe451d16e68 100644 --- a/drivers/usb/storage/cypress_atacb.c +++ b/drivers/usb/storage/cypress_atacb.c | |||
@@ -272,6 +272,7 @@ static struct usb_driver cypress_driver = { | |||
272 | .post_reset = usb_stor_post_reset, | 272 | .post_reset = usb_stor_post_reset, |
273 | .id_table = cypress_usb_ids, | 273 | .id_table = cypress_usb_ids, |
274 | .soft_unbind = 1, | 274 | .soft_unbind = 1, |
275 | .no_dynamic_id = 1, | ||
275 | }; | 276 | }; |
276 | 277 | ||
277 | module_usb_driver(cypress_driver); | 278 | module_usb_driver(cypress_driver); |
diff --git a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c index 15d41f2b3d6f..35e9c51e6696 100644 --- a/drivers/usb/storage/datafab.c +++ b/drivers/usb/storage/datafab.c | |||
@@ -751,6 +751,7 @@ static struct usb_driver datafab_driver = { | |||
751 | .post_reset = usb_stor_post_reset, | 751 | .post_reset = usb_stor_post_reset, |
752 | .id_table = datafab_usb_ids, | 752 | .id_table = datafab_usb_ids, |
753 | .soft_unbind = 1, | 753 | .soft_unbind = 1, |
754 | .no_dynamic_id = 1, | ||
754 | }; | 755 | }; |
755 | 756 | ||
756 | module_usb_driver(datafab_driver); | 757 | module_usb_driver(datafab_driver); |
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index a6ade4071a9a..e7e678109500 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c | |||
@@ -674,7 +674,7 @@ static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb) | |||
674 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 674 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
675 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 675 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
676 | bcb->DataTransferLength = blenByte; | 676 | bcb->DataTransferLength = blenByte; |
677 | bcb->Flags = 0x80; | 677 | bcb->Flags = US_BULK_FLAG_IN; |
678 | bcb->CDB[0] = 0xF1; | 678 | bcb->CDB[0] = 0xF1; |
679 | bcb->CDB[5] = (unsigned char)(bnByte); | 679 | bcb->CDB[5] = (unsigned char)(bnByte); |
680 | bcb->CDB[4] = (unsigned char)(bnByte>>8); | 680 | bcb->CDB[4] = (unsigned char)(bnByte>>8); |
@@ -858,7 +858,7 @@ static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr, | |||
858 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 858 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
859 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 859 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
860 | bcb->DataTransferLength = 0x200; | 860 | bcb->DataTransferLength = 0x200; |
861 | bcb->Flags = 0x80; | 861 | bcb->Flags = US_BULK_FLAG_IN; |
862 | bcb->CDB[0] = 0xF1; | 862 | bcb->CDB[0] = 0xF1; |
863 | 863 | ||
864 | bcb->CDB[1] = 0x02; /* in init.c ENE_MSInit() is 0x01 */ | 864 | bcb->CDB[1] = 0x02; /* in init.c ENE_MSInit() is 0x01 */ |
@@ -877,7 +877,7 @@ static int ms_read_readpage(struct us_data *us, u32 PhyBlockAddr, | |||
877 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 877 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
878 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 878 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
879 | bcb->DataTransferLength = 0x4; | 879 | bcb->DataTransferLength = 0x4; |
880 | bcb->Flags = 0x80; | 880 | bcb->Flags = US_BULK_FLAG_IN; |
881 | bcb->CDB[0] = 0xF1; | 881 | bcb->CDB[0] = 0xF1; |
882 | bcb->CDB[1] = 0x03; | 882 | bcb->CDB[1] = 0x03; |
883 | 883 | ||
@@ -1170,7 +1170,7 @@ static int ms_read_eraseblock(struct us_data *us, u32 PhyBlockAddr) | |||
1170 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1170 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1171 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1171 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1172 | bcb->DataTransferLength = 0x200; | 1172 | bcb->DataTransferLength = 0x200; |
1173 | bcb->Flags = 0x80; | 1173 | bcb->Flags = US_BULK_FLAG_IN; |
1174 | bcb->CDB[0] = 0xF2; | 1174 | bcb->CDB[0] = 0xF2; |
1175 | bcb->CDB[1] = 0x06; | 1175 | bcb->CDB[1] = 0x06; |
1176 | bcb->CDB[4] = (unsigned char)(bn); | 1176 | bcb->CDB[4] = (unsigned char)(bn); |
@@ -1249,7 +1249,7 @@ static int ms_lib_overwrite_extra(struct us_data *us, u32 PhyBlockAddr, | |||
1249 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1249 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1250 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1250 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1251 | bcb->DataTransferLength = 0x4; | 1251 | bcb->DataTransferLength = 0x4; |
1252 | bcb->Flags = 0x80; | 1252 | bcb->Flags = US_BULK_FLAG_IN; |
1253 | bcb->CDB[0] = 0xF2; | 1253 | bcb->CDB[0] = 0xF2; |
1254 | bcb->CDB[1] = 0x05; | 1254 | bcb->CDB[1] = 0x05; |
1255 | bcb->CDB[5] = (unsigned char)(PageNum); | 1255 | bcb->CDB[5] = (unsigned char)(PageNum); |
@@ -1331,7 +1331,7 @@ static int ms_lib_read_extra(struct us_data *us, u32 PhyBlock, | |||
1331 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1331 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1332 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1332 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1333 | bcb->DataTransferLength = 0x4; | 1333 | bcb->DataTransferLength = 0x4; |
1334 | bcb->Flags = 0x80; | 1334 | bcb->Flags = US_BULK_FLAG_IN; |
1335 | bcb->CDB[0] = 0xF1; | 1335 | bcb->CDB[0] = 0xF1; |
1336 | bcb->CDB[1] = 0x03; | 1336 | bcb->CDB[1] = 0x03; |
1337 | bcb->CDB[5] = (unsigned char)(PageNum); | 1337 | bcb->CDB[5] = (unsigned char)(PageNum); |
@@ -1533,7 +1533,7 @@ static int ms_lib_read_extrablock(struct us_data *us, u32 PhyBlock, | |||
1533 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1533 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1534 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1534 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1535 | bcb->DataTransferLength = 0x4 * blen; | 1535 | bcb->DataTransferLength = 0x4 * blen; |
1536 | bcb->Flags = 0x80; | 1536 | bcb->Flags = US_BULK_FLAG_IN; |
1537 | bcb->CDB[0] = 0xF1; | 1537 | bcb->CDB[0] = 0xF1; |
1538 | bcb->CDB[1] = 0x03; | 1538 | bcb->CDB[1] = 0x03; |
1539 | bcb->CDB[5] = (unsigned char)(PageNum); | 1539 | bcb->CDB[5] = (unsigned char)(PageNum); |
@@ -1650,7 +1650,7 @@ static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb) | |||
1650 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1650 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1651 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1651 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1652 | bcb->DataTransferLength = blenByte; | 1652 | bcb->DataTransferLength = blenByte; |
1653 | bcb->Flags = 0x80; | 1653 | bcb->Flags = US_BULK_FLAG_IN; |
1654 | bcb->CDB[0] = 0xF1; | 1654 | bcb->CDB[0] = 0xF1; |
1655 | bcb->CDB[1] = 0x02; | 1655 | bcb->CDB[1] = 0x02; |
1656 | bcb->CDB[5] = (unsigned char)(bn); | 1656 | bcb->CDB[5] = (unsigned char)(bn); |
@@ -1694,7 +1694,7 @@ static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb) | |||
1694 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1694 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1695 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1695 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1696 | bcb->DataTransferLength = 0x200 * len; | 1696 | bcb->DataTransferLength = 0x200 * len; |
1697 | bcb->Flags = 0x80; | 1697 | bcb->Flags = US_BULK_FLAG_IN; |
1698 | bcb->CDB[0] = 0xF1; | 1698 | bcb->CDB[0] = 0xF1; |
1699 | bcb->CDB[1] = 0x02; | 1699 | bcb->CDB[1] = 0x02; |
1700 | bcb->CDB[5] = (unsigned char)(blkno); | 1700 | bcb->CDB[5] = (unsigned char)(blkno); |
@@ -1827,7 +1827,7 @@ static int ene_get_card_type(struct us_data *us, u16 index, void *buf) | |||
1827 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 1827 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
1828 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1828 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1829 | bcb->DataTransferLength = 0x01; | 1829 | bcb->DataTransferLength = 0x01; |
1830 | bcb->Flags = 0x80; | 1830 | bcb->Flags = US_BULK_FLAG_IN; |
1831 | bcb->CDB[0] = 0xED; | 1831 | bcb->CDB[0] = 0xED; |
1832 | bcb->CDB[2] = (unsigned char)(index>>8); | 1832 | bcb->CDB[2] = (unsigned char)(index>>8); |
1833 | bcb->CDB[3] = (unsigned char)index; | 1833 | bcb->CDB[3] = (unsigned char)index; |
@@ -2083,7 +2083,7 @@ static int ene_ms_init(struct us_data *us) | |||
2083 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 2083 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
2084 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 2084 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
2085 | bcb->DataTransferLength = 0x200; | 2085 | bcb->DataTransferLength = 0x200; |
2086 | bcb->Flags = 0x80; | 2086 | bcb->Flags = US_BULK_FLAG_IN; |
2087 | bcb->CDB[0] = 0xF1; | 2087 | bcb->CDB[0] = 0xF1; |
2088 | bcb->CDB[1] = 0x01; | 2088 | bcb->CDB[1] = 0x01; |
2089 | 2089 | ||
@@ -2134,7 +2134,7 @@ static int ene_sd_init(struct us_data *us) | |||
2134 | 2134 | ||
2135 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 2135 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
2136 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 2136 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
2137 | bcb->Flags = 0x80; | 2137 | bcb->Flags = US_BULK_FLAG_IN; |
2138 | bcb->CDB[0] = 0xF2; | 2138 | bcb->CDB[0] = 0xF2; |
2139 | 2139 | ||
2140 | result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); | 2140 | result = ene_send_scsi_cmd(us, FDIR_READ, NULL, 0); |
@@ -2153,7 +2153,7 @@ static int ene_sd_init(struct us_data *us) | |||
2153 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); | 2153 | memset(bcb, 0, sizeof(struct bulk_cb_wrap)); |
2154 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 2154 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
2155 | bcb->DataTransferLength = 0x200; | 2155 | bcb->DataTransferLength = 0x200; |
2156 | bcb->Flags = 0x80; | 2156 | bcb->Flags = US_BULK_FLAG_IN; |
2157 | bcb->CDB[0] = 0xF1; | 2157 | bcb->CDB[0] = 0xF1; |
2158 | 2158 | ||
2159 | result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0); | 2159 | result = ene_send_scsi_cmd(us, FDIR_READ, &buf, 0); |
@@ -2407,6 +2407,7 @@ static struct usb_driver ene_ub6250_driver = { | |||
2407 | .post_reset = usb_stor_post_reset, | 2407 | .post_reset = usb_stor_post_reset, |
2408 | .id_table = ene_ub6250_usb_ids, | 2408 | .id_table = ene_ub6250_usb_ids, |
2409 | .soft_unbind = 1, | 2409 | .soft_unbind = 1, |
2410 | .no_dynamic_id = 1, | ||
2410 | }; | 2411 | }; |
2411 | 2412 | ||
2412 | module_usb_driver(ene_ub6250_driver); | 2413 | module_usb_driver(ene_ub6250_driver); |
diff --git a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c index fa1615748475..042cf9ef3153 100644 --- a/drivers/usb/storage/freecom.c +++ b/drivers/usb/storage/freecom.c | |||
@@ -553,6 +553,7 @@ static struct usb_driver freecom_driver = { | |||
553 | .post_reset = usb_stor_post_reset, | 553 | .post_reset = usb_stor_post_reset, |
554 | .id_table = freecom_usb_ids, | 554 | .id_table = freecom_usb_ids, |
555 | .soft_unbind = 1, | 555 | .soft_unbind = 1, |
556 | .no_dynamic_id = 1, | ||
556 | }; | 557 | }; |
557 | 558 | ||
558 | module_usb_driver(freecom_driver); | 559 | module_usb_driver(freecom_driver); |
diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c index bd5502700831..31fa24e7e68a 100644 --- a/drivers/usb/storage/isd200.c +++ b/drivers/usb/storage/isd200.c | |||
@@ -1566,6 +1566,7 @@ static struct usb_driver isd200_driver = { | |||
1566 | .post_reset = usb_stor_post_reset, | 1566 | .post_reset = usb_stor_post_reset, |
1567 | .id_table = isd200_usb_ids, | 1567 | .id_table = isd200_usb_ids, |
1568 | .soft_unbind = 1, | 1568 | .soft_unbind = 1, |
1569 | .no_dynamic_id = 1, | ||
1569 | }; | 1570 | }; |
1570 | 1571 | ||
1571 | module_usb_driver(isd200_driver); | 1572 | module_usb_driver(isd200_driver); |
diff --git a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c index a19211b5c265..e3b97383186a 100644 --- a/drivers/usb/storage/jumpshot.c +++ b/drivers/usb/storage/jumpshot.c | |||
@@ -677,6 +677,7 @@ static struct usb_driver jumpshot_driver = { | |||
677 | .post_reset = usb_stor_post_reset, | 677 | .post_reset = usb_stor_post_reset, |
678 | .id_table = jumpshot_usb_ids, | 678 | .id_table = jumpshot_usb_ids, |
679 | .soft_unbind = 1, | 679 | .soft_unbind = 1, |
680 | .no_dynamic_id = 1, | ||
680 | }; | 681 | }; |
681 | 682 | ||
682 | module_usb_driver(jumpshot_driver); | 683 | module_usb_driver(jumpshot_driver); |
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c index e720f8ebdf9f..a8708eae9788 100644 --- a/drivers/usb/storage/karma.c +++ b/drivers/usb/storage/karma.c | |||
@@ -230,6 +230,7 @@ static struct usb_driver karma_driver = { | |||
230 | .post_reset = usb_stor_post_reset, | 230 | .post_reset = usb_stor_post_reset, |
231 | .id_table = karma_usb_ids, | 231 | .id_table = karma_usb_ids, |
232 | .soft_unbind = 1, | 232 | .soft_unbind = 1, |
233 | .no_dynamic_id = 1, | ||
233 | }; | 234 | }; |
234 | 235 | ||
235 | module_usb_driver(karma_driver); | 236 | module_usb_driver(karma_driver); |
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c index d75155c38200..886567a3806d 100644 --- a/drivers/usb/storage/onetouch.c +++ b/drivers/usb/storage/onetouch.c | |||
@@ -312,6 +312,7 @@ static struct usb_driver onetouch_driver = { | |||
312 | .post_reset = usb_stor_post_reset, | 312 | .post_reset = usb_stor_post_reset, |
313 | .id_table = onetouch_usb_ids, | 313 | .id_table = onetouch_usb_ids, |
314 | .soft_unbind = 1, | 314 | .soft_unbind = 1, |
315 | .no_dynamic_id = 1, | ||
315 | }; | 316 | }; |
316 | 317 | ||
317 | module_usb_driver(onetouch_driver); | 318 | module_usb_driver(onetouch_driver); |
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c index d32f72061c09..63cf2822e299 100644 --- a/drivers/usb/storage/realtek_cr.c +++ b/drivers/usb/storage/realtek_cr.c | |||
@@ -219,7 +219,7 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun, | |||
219 | /* set up the command wrapper */ | 219 | /* set up the command wrapper */ |
220 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 220 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
221 | bcb->DataTransferLength = cpu_to_le32(buf_len); | 221 | bcb->DataTransferLength = cpu_to_le32(buf_len); |
222 | bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0; | 222 | bcb->Flags = (dir == DMA_FROM_DEVICE) ? US_BULK_FLAG_IN : 0; |
223 | bcb->Tag = ++us->tag; | 223 | bcb->Tag = ++us->tag; |
224 | bcb->Lun = lun; | 224 | bcb->Lun = lun; |
225 | bcb->Length = cmd_len; | 225 | bcb->Length = cmd_len; |
@@ -305,7 +305,7 @@ static int rts51x_bulk_transport_special(struct us_data *us, u8 lun, | |||
305 | /* set up the command wrapper */ | 305 | /* set up the command wrapper */ |
306 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 306 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
307 | bcb->DataTransferLength = cpu_to_le32(buf_len); | 307 | bcb->DataTransferLength = cpu_to_le32(buf_len); |
308 | bcb->Flags = (dir == DMA_FROM_DEVICE) ? 1 << 7 : 0; | 308 | bcb->Flags = (dir == DMA_FROM_DEVICE) ? US_BULK_FLAG_IN : 0; |
309 | bcb->Tag = ++us->tag; | 309 | bcb->Tag = ++us->tag; |
310 | bcb->Lun = lun; | 310 | bcb->Lun = lun; |
311 | bcb->Length = cmd_len; | 311 | bcb->Length = cmd_len; |
@@ -507,9 +507,14 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len) | |||
507 | { | 507 | { |
508 | int retval; | 508 | int retval; |
509 | u8 cmnd[12] = {0}; | 509 | u8 cmnd[12] = {0}; |
510 | u8 *buf; | ||
510 | 511 | ||
511 | US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len); | 512 | US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len); |
512 | 513 | ||
514 | buf = kmemdup(data, len, GFP_NOIO); | ||
515 | if (!buf) | ||
516 | return USB_STOR_TRANSPORT_ERROR; | ||
517 | |||
513 | cmnd[0] = 0xF0; | 518 | cmnd[0] = 0xF0; |
514 | cmnd[1] = 0x0E; | 519 | cmnd[1] = 0x0E; |
515 | cmnd[2] = 0xfe; | 520 | cmnd[2] = 0xfe; |
@@ -517,7 +522,8 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len) | |||
517 | cmnd[4] = (u8)(len >> 8); | 522 | cmnd[4] = (u8)(len >> 8); |
518 | cmnd[5] = (u8)len; | 523 | cmnd[5] = (u8)len; |
519 | 524 | ||
520 | retval = rts51x_bulk_transport_special(us, 0, cmnd, 12, data, len, DMA_TO_DEVICE, NULL); | 525 | retval = rts51x_bulk_transport_special(us, 0, cmnd, 12, buf, len, DMA_TO_DEVICE, NULL); |
526 | kfree(buf); | ||
521 | if (retval != USB_STOR_TRANSPORT_GOOD) { | 527 | if (retval != USB_STOR_TRANSPORT_GOOD) { |
522 | return -EIO; | 528 | return -EIO; |
523 | } | 529 | } |
@@ -1100,6 +1106,7 @@ static struct usb_driver realtek_cr_driver = { | |||
1100 | .id_table = realtek_cr_ids, | 1106 | .id_table = realtek_cr_ids, |
1101 | .soft_unbind = 1, | 1107 | .soft_unbind = 1, |
1102 | .supports_autosuspend = 1, | 1108 | .supports_autosuspend = 1, |
1109 | .no_dynamic_id = 1, | ||
1103 | }; | 1110 | }; |
1104 | 1111 | ||
1105 | module_usb_driver(realtek_cr_driver); | 1112 | module_usb_driver(realtek_cr_driver); |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 13b8bcdf3dba..a324a5d21e99 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
@@ -78,8 +78,6 @@ static const char* host_info(struct Scsi_Host *host) | |||
78 | 78 | ||
79 | static int slave_alloc (struct scsi_device *sdev) | 79 | static int slave_alloc (struct scsi_device *sdev) |
80 | { | 80 | { |
81 | struct us_data *us = host_to_us(sdev->host); | ||
82 | |||
83 | /* | 81 | /* |
84 | * Set the INQUIRY transfer length to 36. We don't use any of | 82 | * Set the INQUIRY transfer length to 36. We don't use any of |
85 | * the extra data and many devices choke if asked for more or | 83 | * the extra data and many devices choke if asked for more or |
@@ -104,18 +102,6 @@ static int slave_alloc (struct scsi_device *sdev) | |||
104 | */ | 102 | */ |
105 | blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); | 103 | blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1)); |
106 | 104 | ||
107 | /* | ||
108 | * The UFI spec treates the Peripheral Qualifier bits in an | ||
109 | * INQUIRY result as reserved and requires devices to set them | ||
110 | * to 0. However the SCSI spec requires these bits to be set | ||
111 | * to 3 to indicate when a LUN is not present. | ||
112 | * | ||
113 | * Let the scanning code know if this target merely sets | ||
114 | * Peripheral Device Type to 0x1f to indicate no LUN. | ||
115 | */ | ||
116 | if (us->subclass == USB_SC_UFI) | ||
117 | sdev->sdev_target->pdt_1f_for_no_lun = 1; | ||
118 | |||
119 | return 0; | 105 | return 0; |
120 | } | 106 | } |
121 | 107 | ||
@@ -197,6 +183,9 @@ static int slave_configure(struct scsi_device *sdev) | |||
197 | * page x08, so we will skip it. */ | 183 | * page x08, so we will skip it. */ |
198 | sdev->skip_ms_page_8 = 1; | 184 | sdev->skip_ms_page_8 = 1; |
199 | 185 | ||
186 | /* Some devices don't handle VPD pages correctly */ | ||
187 | sdev->skip_vpd_pages = 1; | ||
188 | |||
200 | /* Some disks return the total number of blocks in response | 189 | /* Some disks return the total number of blocks in response |
201 | * to READ CAPACITY rather than the highest block number. | 190 | * to READ CAPACITY rather than the highest block number. |
202 | * If this device makes that mistake, tell the sd driver. */ | 191 | * If this device makes that mistake, tell the sd driver. */ |
@@ -217,16 +206,6 @@ static int slave_configure(struct scsi_device *sdev) | |||
217 | if (sdev->scsi_level > SCSI_SPC_2) | 206 | if (sdev->scsi_level > SCSI_SPC_2) |
218 | us->fflags |= US_FL_SANE_SENSE; | 207 | us->fflags |= US_FL_SANE_SENSE; |
219 | 208 | ||
220 | /* Some devices report a SCSI revision level above 2 but are | ||
221 | * unable to handle the REPORT LUNS command (for which | ||
222 | * support is mandatory at level 3). Since we already have | ||
223 | * a Get-Max-LUN request, we won't lose much by setting the | ||
224 | * revision level down to 2. The only devices that would be | ||
225 | * affected are those with sparse LUNs. */ | ||
226 | if (sdev->scsi_level > SCSI_2) | ||
227 | sdev->sdev_target->scsi_level = | ||
228 | sdev->scsi_level = SCSI_2; | ||
229 | |||
230 | /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable | 209 | /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable |
231 | * Hardware Error) when any low-level error occurs, | 210 | * Hardware Error) when any low-level error occurs, |
232 | * recoverable or not. Setting this flag tells the SCSI | 211 | * recoverable or not. Setting this flag tells the SCSI |
@@ -283,6 +262,33 @@ static int slave_configure(struct scsi_device *sdev) | |||
283 | return 0; | 262 | return 0; |
284 | } | 263 | } |
285 | 264 | ||
265 | static int target_alloc(struct scsi_target *starget) | ||
266 | { | ||
267 | struct us_data *us = host_to_us(dev_to_shost(starget->dev.parent)); | ||
268 | |||
269 | /* | ||
270 | * Some USB drives don't support REPORT LUNS, even though they | ||
271 | * report a SCSI revision level above 2. Tell the SCSI layer | ||
272 | * not to issue that command; it will perform a normal sequential | ||
273 | * scan instead. | ||
274 | */ | ||
275 | starget->no_report_luns = 1; | ||
276 | |||
277 | /* | ||
278 | * The UFI spec treats the Peripheral Qualifier bits in an | ||
279 | * INQUIRY result as reserved and requires devices to set them | ||
280 | * to 0. However the SCSI spec requires these bits to be set | ||
281 | * to 3 to indicate when a LUN is not present. | ||
282 | * | ||
283 | * Let the scanning code know if this target merely sets | ||
284 | * Peripheral Device Type to 0x1f to indicate no LUN. | ||
285 | */ | ||
286 | if (us->subclass == USB_SC_UFI) | ||
287 | starget->pdt_1f_for_no_lun = 1; | ||
288 | |||
289 | return 0; | ||
290 | } | ||
291 | |||
286 | /* queue a command */ | 292 | /* queue a command */ |
287 | /* This is always called with scsi_lock(host) held */ | 293 | /* This is always called with scsi_lock(host) held */ |
288 | static int queuecommand_lck(struct scsi_cmnd *srb, | 294 | static int queuecommand_lck(struct scsi_cmnd *srb, |
@@ -546,6 +552,7 @@ struct scsi_host_template usb_stor_host_template = { | |||
546 | 552 | ||
547 | .slave_alloc = slave_alloc, | 553 | .slave_alloc = slave_alloc, |
548 | .slave_configure = slave_configure, | 554 | .slave_configure = slave_configure, |
555 | .target_alloc = target_alloc, | ||
549 | 556 | ||
550 | /* lots of sg segments can be handled */ | 557 | /* lots of sg segments can be handled */ |
551 | .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS, | 558 | .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS, |
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 425df7df2e56..3252a62b31bc 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
@@ -1787,6 +1787,7 @@ static struct usb_driver sddr09_driver = { | |||
1787 | .post_reset = usb_stor_post_reset, | 1787 | .post_reset = usb_stor_post_reset, |
1788 | .id_table = sddr09_usb_ids, | 1788 | .id_table = sddr09_usb_ids, |
1789 | .soft_unbind = 1, | 1789 | .soft_unbind = 1, |
1790 | .no_dynamic_id = 1, | ||
1790 | }; | 1791 | }; |
1791 | 1792 | ||
1792 | module_usb_driver(sddr09_driver); | 1793 | module_usb_driver(sddr09_driver); |
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index e4ca5fcb7cc3..c144078065a7 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
@@ -1006,6 +1006,7 @@ static struct usb_driver sddr55_driver = { | |||
1006 | .post_reset = usb_stor_post_reset, | 1006 | .post_reset = usb_stor_post_reset, |
1007 | .id_table = sddr55_usb_ids, | 1007 | .id_table = sddr55_usb_ids, |
1008 | .soft_unbind = 1, | 1008 | .soft_unbind = 1, |
1009 | .no_dynamic_id = 1, | ||
1009 | }; | 1010 | }; |
1010 | 1011 | ||
1011 | module_usb_driver(sddr55_driver); | 1012 | module_usb_driver(sddr55_driver); |
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 1369d2590616..fa1ceebc465c 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c | |||
@@ -1863,6 +1863,7 @@ static struct usb_driver usbat_driver = { | |||
1863 | .post_reset = usb_stor_post_reset, | 1863 | .post_reset = usb_stor_post_reset, |
1864 | .id_table = usbat_usb_ids, | 1864 | .id_table = usbat_usb_ids, |
1865 | .soft_unbind = 1, | 1865 | .soft_unbind = 1, |
1866 | .no_dynamic_id = 1, | ||
1866 | }; | 1867 | }; |
1867 | 1868 | ||
1868 | module_usb_driver(usbat_driver); | 1869 | module_usb_driver(usbat_driver); |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 0e5c91c6187f..c70109e5d60b 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -1071,7 +1071,8 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) | |||
1071 | /* set up the command wrapper */ | 1071 | /* set up the command wrapper */ |
1072 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); | 1072 | bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN); |
1073 | bcb->DataTransferLength = cpu_to_le32(transfer_length); | 1073 | bcb->DataTransferLength = cpu_to_le32(transfer_length); |
1074 | bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? 1 << 7 : 0; | 1074 | bcb->Flags = srb->sc_data_direction == DMA_FROM_DEVICE ? |
1075 | US_BULK_FLAG_IN : 0; | ||
1075 | bcb->Tag = ++us->tag; | 1076 | bcb->Tag = ++us->tag; |
1076 | bcb->Lun = srb->device->lun; | 1077 | bcb->Lun = srb->device->lun; |
1077 | if (us->fflags & US_FL_SCM_MULT_TARG) | 1078 | if (us->fflags & US_FL_SCM_MULT_TARG) |
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h index 242ff5e791a5..9369d752d419 100644 --- a/drivers/usb/storage/transport.h +++ b/drivers/usb/storage/transport.h | |||
@@ -42,45 +42,6 @@ | |||
42 | #include <linux/blkdev.h> | 42 | #include <linux/blkdev.h> |
43 | 43 | ||
44 | /* | 44 | /* |
45 | * Bulk only data structures | ||
46 | */ | ||
47 | |||
48 | /* command block wrapper */ | ||
49 | struct bulk_cb_wrap { | ||
50 | __le32 Signature; /* contains 'USBC' */ | ||
51 | __u32 Tag; /* unique per command id */ | ||
52 | __le32 DataTransferLength; /* size of data */ | ||
53 | __u8 Flags; /* direction in bit 0 */ | ||
54 | __u8 Lun; /* LUN normally 0 */ | ||
55 | __u8 Length; /* of of the CDB */ | ||
56 | __u8 CDB[16]; /* max command */ | ||
57 | }; | ||
58 | |||
59 | #define US_BULK_CB_WRAP_LEN 31 | ||
60 | #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */ | ||
61 | #define US_BULK_FLAG_IN 1 | ||
62 | #define US_BULK_FLAG_OUT 0 | ||
63 | |||
64 | /* command status wrapper */ | ||
65 | struct bulk_cs_wrap { | ||
66 | __le32 Signature; /* should = 'USBS' */ | ||
67 | __u32 Tag; /* same as original command */ | ||
68 | __le32 Residue; /* amount not transferred */ | ||
69 | __u8 Status; /* see below */ | ||
70 | __u8 Filler[18]; | ||
71 | }; | ||
72 | |||
73 | #define US_BULK_CS_WRAP_LEN 13 | ||
74 | #define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */ | ||
75 | #define US_BULK_STAT_OK 0 | ||
76 | #define US_BULK_STAT_FAIL 1 | ||
77 | #define US_BULK_STAT_PHASE 2 | ||
78 | |||
79 | /* bulk-only class specific requests */ | ||
80 | #define US_BULK_RESET_REQUEST 0xff | ||
81 | #define US_BULK_GET_MAX_LUN 0xfe | ||
82 | |||
83 | /* | ||
84 | * usb_stor_bulk_transfer_xxx() return codes, in order of severity | 45 | * usb_stor_bulk_transfer_xxx() return codes, in order of severity |
85 | */ | 46 | */ |
86 | 47 | ||
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index a33ead5dce20..8ec8a6e66f50 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c | |||
@@ -13,7 +13,9 @@ | |||
13 | #include <linux/types.h> | 13 | #include <linux/types.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
16 | #include <linux/usb/hcd.h> | ||
16 | #include <linux/usb/storage.h> | 17 | #include <linux/usb/storage.h> |
18 | #include <linux/usb/uas.h> | ||
17 | 19 | ||
18 | #include <scsi/scsi.h> | 20 | #include <scsi/scsi.h> |
19 | #include <scsi/scsi_dbg.h> | 21 | #include <scsi/scsi_dbg.h> |
@@ -22,49 +24,6 @@ | |||
22 | #include <scsi/scsi_host.h> | 24 | #include <scsi/scsi_host.h> |
23 | #include <scsi/scsi_tcq.h> | 25 | #include <scsi/scsi_tcq.h> |
24 | 26 | ||
25 | /* Common header for all IUs */ | ||
26 | struct iu { | ||
27 | __u8 iu_id; | ||
28 | __u8 rsvd1; | ||
29 | __be16 tag; | ||
30 | }; | ||
31 | |||
32 | enum { | ||
33 | IU_ID_COMMAND = 0x01, | ||
34 | IU_ID_STATUS = 0x03, | ||
35 | IU_ID_RESPONSE = 0x04, | ||
36 | IU_ID_TASK_MGMT = 0x05, | ||
37 | IU_ID_READ_READY = 0x06, | ||
38 | IU_ID_WRITE_READY = 0x07, | ||
39 | }; | ||
40 | |||
41 | struct command_iu { | ||
42 | __u8 iu_id; | ||
43 | __u8 rsvd1; | ||
44 | __be16 tag; | ||
45 | __u8 prio_attr; | ||
46 | __u8 rsvd5; | ||
47 | __u8 len; | ||
48 | __u8 rsvd7; | ||
49 | struct scsi_lun lun; | ||
50 | __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */ | ||
51 | }; | ||
52 | |||
53 | /* | ||
54 | * Also used for the Read Ready and Write Ready IUs since they have the | ||
55 | * same first four bytes | ||
56 | */ | ||
57 | struct sense_iu { | ||
58 | __u8 iu_id; | ||
59 | __u8 rsvd1; | ||
60 | __be16 tag; | ||
61 | __be16 status_qual; | ||
62 | __u8 status; | ||
63 | __u8 rsvd7[7]; | ||
64 | __be16 len; | ||
65 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; | ||
66 | }; | ||
67 | |||
68 | /* | 27 | /* |
69 | * The r00-r01c specs define this version of the SENSE IU data structure. | 28 | * The r00-r01c specs define this version of the SENSE IU data structure. |
70 | * It's still in use by several different firmware releases. | 29 | * It's still in use by several different firmware releases. |
@@ -79,18 +38,6 @@ struct sense_iu_old { | |||
79 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; | 38 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; |
80 | }; | 39 | }; |
81 | 40 | ||
82 | enum { | ||
83 | CMD_PIPE_ID = 1, | ||
84 | STATUS_PIPE_ID = 2, | ||
85 | DATA_IN_PIPE_ID = 3, | ||
86 | DATA_OUT_PIPE_ID = 4, | ||
87 | |||
88 | UAS_SIMPLE_TAG = 0, | ||
89 | UAS_HEAD_TAG = 1, | ||
90 | UAS_ORDERED_TAG = 2, | ||
91 | UAS_ACA = 4, | ||
92 | }; | ||
93 | |||
94 | struct uas_dev_info { | 41 | struct uas_dev_info { |
95 | struct usb_interface *intf; | 42 | struct usb_interface *intf; |
96 | struct usb_device *udev; | 43 | struct usb_device *udev; |
@@ -98,6 +45,8 @@ struct uas_dev_info { | |||
98 | unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe; | 45 | unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe; |
99 | unsigned use_streams:1; | 46 | unsigned use_streams:1; |
100 | unsigned uas_sense_old:1; | 47 | unsigned uas_sense_old:1; |
48 | struct scsi_cmnd *cmnd; | ||
49 | struct urb *status_urb; /* used only if stream support is available */ | ||
101 | }; | 50 | }; |
102 | 51 | ||
103 | enum { | 52 | enum { |
@@ -109,6 +58,9 @@ enum { | |||
109 | SUBMIT_DATA_OUT_URB = (1 << 5), | 58 | SUBMIT_DATA_OUT_URB = (1 << 5), |
110 | ALLOC_CMD_URB = (1 << 6), | 59 | ALLOC_CMD_URB = (1 << 6), |
111 | SUBMIT_CMD_URB = (1 << 7), | 60 | SUBMIT_CMD_URB = (1 << 7), |
61 | COMPLETED_DATA_IN = (1 << 8), | ||
62 | COMPLETED_DATA_OUT = (1 << 9), | ||
63 | DATA_COMPLETES_CMD = (1 << 10), | ||
112 | }; | 64 | }; |
113 | 65 | ||
114 | /* Overrides scsi_pointer */ | 66 | /* Overrides scsi_pointer */ |
@@ -116,6 +68,7 @@ struct uas_cmd_info { | |||
116 | unsigned int state; | 68 | unsigned int state; |
117 | unsigned int stream; | 69 | unsigned int stream; |
118 | struct urb *cmd_urb; | 70 | struct urb *cmd_urb; |
71 | /* status_urb is used only if stream support isn't available */ | ||
119 | struct urb *status_urb; | 72 | struct urb *status_urb; |
120 | struct urb *data_in_urb; | 73 | struct urb *data_in_urb; |
121 | struct urb *data_out_urb; | 74 | struct urb *data_out_urb; |
@@ -125,33 +78,43 @@ struct uas_cmd_info { | |||
125 | /* I hate forward declarations, but I actually have a loop */ | 78 | /* I hate forward declarations, but I actually have a loop */ |
126 | static int uas_submit_urbs(struct scsi_cmnd *cmnd, | 79 | static int uas_submit_urbs(struct scsi_cmnd *cmnd, |
127 | struct uas_dev_info *devinfo, gfp_t gfp); | 80 | struct uas_dev_info *devinfo, gfp_t gfp); |
81 | static void uas_do_work(struct work_struct *work); | ||
128 | 82 | ||
83 | static DECLARE_WORK(uas_work, uas_do_work); | ||
129 | static DEFINE_SPINLOCK(uas_work_lock); | 84 | static DEFINE_SPINLOCK(uas_work_lock); |
130 | static LIST_HEAD(uas_work_list); | 85 | static LIST_HEAD(uas_work_list); |
131 | 86 | ||
132 | static void uas_do_work(struct work_struct *work) | 87 | static void uas_do_work(struct work_struct *work) |
133 | { | 88 | { |
134 | struct uas_cmd_info *cmdinfo; | 89 | struct uas_cmd_info *cmdinfo; |
90 | struct uas_cmd_info *temp; | ||
135 | struct list_head list; | 91 | struct list_head list; |
92 | int err; | ||
136 | 93 | ||
137 | spin_lock_irq(&uas_work_lock); | 94 | spin_lock_irq(&uas_work_lock); |
138 | list_replace_init(&uas_work_list, &list); | 95 | list_replace_init(&uas_work_list, &list); |
139 | spin_unlock_irq(&uas_work_lock); | 96 | spin_unlock_irq(&uas_work_lock); |
140 | 97 | ||
141 | list_for_each_entry(cmdinfo, &list, list) { | 98 | list_for_each_entry_safe(cmdinfo, temp, &list, list) { |
142 | struct scsi_pointer *scp = (void *)cmdinfo; | 99 | struct scsi_pointer *scp = (void *)cmdinfo; |
143 | struct scsi_cmnd *cmnd = container_of(scp, | 100 | struct scsi_cmnd *cmnd = container_of(scp, |
144 | struct scsi_cmnd, SCp); | 101 | struct scsi_cmnd, SCp); |
145 | uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_NOIO); | 102 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_NOIO); |
103 | if (err) { | ||
104 | list_del(&cmdinfo->list); | ||
105 | spin_lock_irq(&uas_work_lock); | ||
106 | list_add_tail(&cmdinfo->list, &uas_work_list); | ||
107 | spin_unlock_irq(&uas_work_lock); | ||
108 | schedule_work(&uas_work); | ||
109 | } | ||
146 | } | 110 | } |
147 | } | 111 | } |
148 | 112 | ||
149 | static DECLARE_WORK(uas_work, uas_do_work); | ||
150 | |||
151 | static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) | 113 | static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) |
152 | { | 114 | { |
153 | struct sense_iu *sense_iu = urb->transfer_buffer; | 115 | struct sense_iu *sense_iu = urb->transfer_buffer; |
154 | struct scsi_device *sdev = cmnd->device; | 116 | struct scsi_device *sdev = cmnd->device; |
117 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | ||
155 | 118 | ||
156 | if (urb->actual_length > 16) { | 119 | if (urb->actual_length > 16) { |
157 | unsigned len = be16_to_cpup(&sense_iu->len); | 120 | unsigned len = be16_to_cpup(&sense_iu->len); |
@@ -169,16 +132,15 @@ static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd) | |||
169 | } | 132 | } |
170 | 133 | ||
171 | cmnd->result = sense_iu->status; | 134 | cmnd->result = sense_iu->status; |
172 | if (sdev->current_cmnd) | 135 | if (!(cmdinfo->state & DATA_COMPLETES_CMD)) |
173 | sdev->current_cmnd = NULL; | 136 | cmnd->scsi_done(cmnd); |
174 | cmnd->scsi_done(cmnd); | ||
175 | usb_free_urb(urb); | ||
176 | } | 137 | } |
177 | 138 | ||
178 | static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd) | 139 | static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd) |
179 | { | 140 | { |
180 | struct sense_iu_old *sense_iu = urb->transfer_buffer; | 141 | struct sense_iu_old *sense_iu = urb->transfer_buffer; |
181 | struct scsi_device *sdev = cmnd->device; | 142 | struct scsi_device *sdev = cmnd->device; |
143 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | ||
182 | 144 | ||
183 | if (urb->actual_length > 8) { | 145 | if (urb->actual_length > 8) { |
184 | unsigned len = be16_to_cpup(&sense_iu->len) - 2; | 146 | unsigned len = be16_to_cpup(&sense_iu->len) - 2; |
@@ -196,10 +158,8 @@ static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd) | |||
196 | } | 158 | } |
197 | 159 | ||
198 | cmnd->result = sense_iu->status; | 160 | cmnd->result = sense_iu->status; |
199 | if (sdev->current_cmnd) | 161 | if (!(cmdinfo->state & DATA_COMPLETES_CMD)) |
200 | sdev->current_cmnd = NULL; | 162 | cmnd->scsi_done(cmnd); |
201 | cmnd->scsi_done(cmnd); | ||
202 | usb_free_urb(urb); | ||
203 | } | 163 | } |
204 | 164 | ||
205 | static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, | 165 | static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, |
@@ -208,7 +168,7 @@ static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, | |||
208 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 168 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
209 | int err; | 169 | int err; |
210 | 170 | ||
211 | cmdinfo->state = direction | SUBMIT_STATUS_URB; | 171 | cmdinfo->state = direction; |
212 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC); | 172 | err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC); |
213 | if (err) { | 173 | if (err) { |
214 | spin_lock(&uas_work_lock); | 174 | spin_lock(&uas_work_lock); |
@@ -221,27 +181,61 @@ static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd, | |||
221 | static void uas_stat_cmplt(struct urb *urb) | 181 | static void uas_stat_cmplt(struct urb *urb) |
222 | { | 182 | { |
223 | struct iu *iu = urb->transfer_buffer; | 183 | struct iu *iu = urb->transfer_buffer; |
224 | struct scsi_device *sdev = urb->context; | 184 | struct Scsi_Host *shost = urb->context; |
225 | struct uas_dev_info *devinfo = sdev->hostdata; | 185 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
226 | struct scsi_cmnd *cmnd; | 186 | struct scsi_cmnd *cmnd; |
187 | struct uas_cmd_info *cmdinfo; | ||
227 | u16 tag; | 188 | u16 tag; |
189 | int ret; | ||
228 | 190 | ||
229 | if (urb->status) { | 191 | if (urb->status) { |
230 | dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status); | 192 | dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status); |
231 | usb_free_urb(urb); | 193 | if (devinfo->use_streams) |
194 | usb_free_urb(urb); | ||
232 | return; | 195 | return; |
233 | } | 196 | } |
234 | 197 | ||
235 | tag = be16_to_cpup(&iu->tag) - 1; | 198 | tag = be16_to_cpup(&iu->tag) - 1; |
236 | if (sdev->current_cmnd) | 199 | if (tag == 0) |
237 | cmnd = sdev->current_cmnd; | 200 | cmnd = devinfo->cmnd; |
238 | else | 201 | else |
239 | cmnd = scsi_find_tag(sdev, tag); | 202 | cmnd = scsi_host_find_tag(shost, tag - 1); |
240 | if (!cmnd) | 203 | if (!cmnd) { |
204 | if (devinfo->use_streams) { | ||
205 | usb_free_urb(urb); | ||
206 | return; | ||
207 | } | ||
208 | ret = usb_submit_urb(urb, GFP_ATOMIC); | ||
209 | if (ret) | ||
210 | dev_err(&urb->dev->dev, "failed submit status urb\n"); | ||
241 | return; | 211 | return; |
212 | } | ||
213 | cmdinfo = (void *)&cmnd->SCp; | ||
242 | 214 | ||
243 | switch (iu->iu_id) { | 215 | switch (iu->iu_id) { |
244 | case IU_ID_STATUS: | 216 | case IU_ID_STATUS: |
217 | if (devinfo->cmnd == cmnd) | ||
218 | devinfo->cmnd = NULL; | ||
219 | |||
220 | if (!(cmdinfo->state & COMPLETED_DATA_IN) && | ||
221 | cmdinfo->data_in_urb) { | ||
222 | if (devinfo->use_streams) { | ||
223 | cmdinfo->state |= DATA_COMPLETES_CMD; | ||
224 | usb_unlink_urb(cmdinfo->data_in_urb); | ||
225 | } else { | ||
226 | usb_free_urb(cmdinfo->data_in_urb); | ||
227 | } | ||
228 | } | ||
229 | if (!(cmdinfo->state & COMPLETED_DATA_OUT) && | ||
230 | cmdinfo->data_out_urb) { | ||
231 | if (devinfo->use_streams) { | ||
232 | cmdinfo->state |= DATA_COMPLETES_CMD; | ||
233 | usb_unlink_urb(cmdinfo->data_in_urb); | ||
234 | } else { | ||
235 | usb_free_urb(cmdinfo->data_out_urb); | ||
236 | } | ||
237 | } | ||
238 | |||
245 | if (urb->actual_length < 16) | 239 | if (urb->actual_length < 16) |
246 | devinfo->uas_sense_old = 1; | 240 | devinfo->uas_sense_old = 1; |
247 | if (devinfo->uas_sense_old) | 241 | if (devinfo->uas_sense_old) |
@@ -259,29 +253,70 @@ static void uas_stat_cmplt(struct urb *urb) | |||
259 | scmd_printk(KERN_ERR, cmnd, | 253 | scmd_printk(KERN_ERR, cmnd, |
260 | "Bogus IU (%d) received on status pipe\n", iu->iu_id); | 254 | "Bogus IU (%d) received on status pipe\n", iu->iu_id); |
261 | } | 255 | } |
256 | |||
257 | if (devinfo->use_streams) { | ||
258 | usb_free_urb(urb); | ||
259 | return; | ||
260 | } | ||
261 | |||
262 | ret = usb_submit_urb(urb, GFP_ATOMIC); | ||
263 | if (ret) | ||
264 | dev_err(&urb->dev->dev, "failed submit status urb\n"); | ||
262 | } | 265 | } |
263 | 266 | ||
264 | static void uas_data_cmplt(struct urb *urb) | 267 | static void uas_data_out_cmplt(struct urb *urb) |
265 | { | 268 | { |
266 | struct scsi_data_buffer *sdb = urb->context; | 269 | struct scsi_cmnd *cmnd = urb->context; |
270 | struct scsi_data_buffer *sdb = scsi_out(cmnd); | ||
271 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | ||
272 | |||
273 | cmdinfo->state |= COMPLETED_DATA_OUT; | ||
274 | |||
267 | sdb->resid = sdb->length - urb->actual_length; | 275 | sdb->resid = sdb->length - urb->actual_length; |
268 | usb_free_urb(urb); | 276 | usb_free_urb(urb); |
277 | |||
278 | if (cmdinfo->state & DATA_COMPLETES_CMD) | ||
279 | cmnd->scsi_done(cmnd); | ||
280 | } | ||
281 | |||
282 | static void uas_data_in_cmplt(struct urb *urb) | ||
283 | { | ||
284 | struct scsi_cmnd *cmnd = urb->context; | ||
285 | struct scsi_data_buffer *sdb = scsi_in(cmnd); | ||
286 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | ||
287 | |||
288 | cmdinfo->state |= COMPLETED_DATA_IN; | ||
289 | |||
290 | sdb->resid = sdb->length - urb->actual_length; | ||
291 | usb_free_urb(urb); | ||
292 | |||
293 | if (cmdinfo->state & DATA_COMPLETES_CMD) | ||
294 | cmnd->scsi_done(cmnd); | ||
269 | } | 295 | } |
270 | 296 | ||
271 | static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, | 297 | static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, |
272 | unsigned int pipe, u16 stream_id, | 298 | unsigned int pipe, struct scsi_cmnd *cmnd, |
273 | struct scsi_data_buffer *sdb, | 299 | enum dma_data_direction dir) |
274 | enum dma_data_direction dir) | ||
275 | { | 300 | { |
301 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | ||
276 | struct usb_device *udev = devinfo->udev; | 302 | struct usb_device *udev = devinfo->udev; |
277 | struct urb *urb = usb_alloc_urb(0, gfp); | 303 | struct urb *urb = usb_alloc_urb(0, gfp); |
304 | struct scsi_data_buffer *sdb; | ||
305 | usb_complete_t complete_fn; | ||
306 | u16 stream_id = cmdinfo->stream; | ||
278 | 307 | ||
279 | if (!urb) | 308 | if (!urb) |
280 | goto out; | 309 | goto out; |
281 | usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, uas_data_cmplt, | 310 | if (dir == DMA_FROM_DEVICE) { |
282 | sdb); | 311 | sdb = scsi_in(cmnd); |
283 | if (devinfo->use_streams) | 312 | complete_fn = uas_data_in_cmplt; |
284 | urb->stream_id = stream_id; | 313 | } else { |
314 | sdb = scsi_out(cmnd); | ||
315 | complete_fn = uas_data_out_cmplt; | ||
316 | } | ||
317 | usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, | ||
318 | complete_fn, cmnd); | ||
319 | urb->stream_id = stream_id; | ||
285 | urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0; | 320 | urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0; |
286 | urb->sg = sdb->table.sgl; | 321 | urb->sg = sdb->table.sgl; |
287 | out: | 322 | out: |
@@ -289,7 +324,7 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp, | |||
289 | } | 324 | } |
290 | 325 | ||
291 | static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, | 326 | static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, |
292 | struct scsi_cmnd *cmnd, u16 stream_id) | 327 | struct Scsi_Host *shost, u16 stream_id) |
293 | { | 328 | { |
294 | struct usb_device *udev = devinfo->udev; | 329 | struct usb_device *udev = devinfo->udev; |
295 | struct urb *urb = usb_alloc_urb(0, gfp); | 330 | struct urb *urb = usb_alloc_urb(0, gfp); |
@@ -303,7 +338,7 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp, | |||
303 | goto free; | 338 | goto free; |
304 | 339 | ||
305 | usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu), | 340 | usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu), |
306 | uas_stat_cmplt, cmnd->device); | 341 | uas_stat_cmplt, shost); |
307 | urb->stream_id = stream_id; | 342 | urb->stream_id = stream_id; |
308 | urb->transfer_flags |= URB_FREE_BUFFER; | 343 | urb->transfer_flags |= URB_FREE_BUFFER; |
309 | out: | 344 | out: |
@@ -334,7 +369,10 @@ static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp, | |||
334 | goto free; | 369 | goto free; |
335 | 370 | ||
336 | iu->iu_id = IU_ID_COMMAND; | 371 | iu->iu_id = IU_ID_COMMAND; |
337 | iu->tag = cpu_to_be16(stream_id); | 372 | if (blk_rq_tagged(cmnd->request)) |
373 | iu->tag = cpu_to_be16(cmnd->request->tag + 2); | ||
374 | else | ||
375 | iu->tag = cpu_to_be16(1); | ||
338 | iu->prio_attr = UAS_SIMPLE_TAG; | 376 | iu->prio_attr = UAS_SIMPLE_TAG; |
339 | iu->len = len; | 377 | iu->len = len; |
340 | int_to_scsilun(sdev->lun, &iu->lun); | 378 | int_to_scsilun(sdev->lun, &iu->lun); |
@@ -362,8 +400,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, | |||
362 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; | 400 | struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp; |
363 | 401 | ||
364 | if (cmdinfo->state & ALLOC_STATUS_URB) { | 402 | if (cmdinfo->state & ALLOC_STATUS_URB) { |
365 | cmdinfo->status_urb = uas_alloc_sense_urb(devinfo, gfp, cmnd, | 403 | cmdinfo->status_urb = uas_alloc_sense_urb(devinfo, gfp, |
366 | cmdinfo->stream); | 404 | cmnd->device->host, cmdinfo->stream); |
367 | if (!cmdinfo->status_urb) | 405 | if (!cmdinfo->status_urb) |
368 | return SCSI_MLQUEUE_DEVICE_BUSY; | 406 | return SCSI_MLQUEUE_DEVICE_BUSY; |
369 | cmdinfo->state &= ~ALLOC_STATUS_URB; | 407 | cmdinfo->state &= ~ALLOC_STATUS_URB; |
@@ -380,8 +418,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, | |||
380 | 418 | ||
381 | if (cmdinfo->state & ALLOC_DATA_IN_URB) { | 419 | if (cmdinfo->state & ALLOC_DATA_IN_URB) { |
382 | cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp, | 420 | cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp, |
383 | devinfo->data_in_pipe, cmdinfo->stream, | 421 | devinfo->data_in_pipe, cmnd, |
384 | scsi_in(cmnd), DMA_FROM_DEVICE); | 422 | DMA_FROM_DEVICE); |
385 | if (!cmdinfo->data_in_urb) | 423 | if (!cmdinfo->data_in_urb) |
386 | return SCSI_MLQUEUE_DEVICE_BUSY; | 424 | return SCSI_MLQUEUE_DEVICE_BUSY; |
387 | cmdinfo->state &= ~ALLOC_DATA_IN_URB; | 425 | cmdinfo->state &= ~ALLOC_DATA_IN_URB; |
@@ -398,8 +436,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd, | |||
398 | 436 | ||
399 | if (cmdinfo->state & ALLOC_DATA_OUT_URB) { | 437 | if (cmdinfo->state & ALLOC_DATA_OUT_URB) { |
400 | cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp, | 438 | cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp, |
401 | devinfo->data_out_pipe, cmdinfo->stream, | 439 | devinfo->data_out_pipe, cmnd, |
402 | scsi_out(cmnd), DMA_TO_DEVICE); | 440 | DMA_TO_DEVICE); |
403 | if (!cmdinfo->data_out_urb) | 441 | if (!cmdinfo->data_out_urb) |
404 | return SCSI_MLQUEUE_DEVICE_BUSY; | 442 | return SCSI_MLQUEUE_DEVICE_BUSY; |
405 | cmdinfo->state &= ~ALLOC_DATA_OUT_URB; | 443 | cmdinfo->state &= ~ALLOC_DATA_OUT_URB; |
@@ -444,13 +482,13 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
444 | 482 | ||
445 | BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); | 483 | BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer)); |
446 | 484 | ||
447 | if (!cmdinfo->status_urb && sdev->current_cmnd) | 485 | if (devinfo->cmnd) |
448 | return SCSI_MLQUEUE_DEVICE_BUSY; | 486 | return SCSI_MLQUEUE_DEVICE_BUSY; |
449 | 487 | ||
450 | if (blk_rq_tagged(cmnd->request)) { | 488 | if (blk_rq_tagged(cmnd->request)) { |
451 | cmdinfo->stream = cmnd->request->tag + 1; | 489 | cmdinfo->stream = cmnd->request->tag + 2; |
452 | } else { | 490 | } else { |
453 | sdev->current_cmnd = cmnd; | 491 | devinfo->cmnd = cmnd; |
454 | cmdinfo->stream = 1; | 492 | cmdinfo->stream = 1; |
455 | } | 493 | } |
456 | 494 | ||
@@ -472,7 +510,8 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, | |||
472 | } | 510 | } |
473 | 511 | ||
474 | if (!devinfo->use_streams) { | 512 | if (!devinfo->use_streams) { |
475 | cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB); | 513 | cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB | |
514 | ALLOC_STATUS_URB | SUBMIT_STATUS_URB); | ||
476 | cmdinfo->stream = 0; | 515 | cmdinfo->stream = 0; |
477 | } | 516 | } |
478 | 517 | ||
@@ -551,7 +590,7 @@ static int uas_slave_configure(struct scsi_device *sdev) | |||
551 | { | 590 | { |
552 | struct uas_dev_info *devinfo = sdev->hostdata; | 591 | struct uas_dev_info *devinfo = sdev->hostdata; |
553 | scsi_set_tag_type(sdev, MSG_ORDERED_TAG); | 592 | scsi_set_tag_type(sdev, MSG_ORDERED_TAG); |
554 | scsi_activate_tcq(sdev, devinfo->qdepth - 1); | 593 | scsi_activate_tcq(sdev, devinfo->qdepth - 2); |
555 | return 0; | 594 | return 0; |
556 | } | 595 | } |
557 | 596 | ||
@@ -589,22 +628,34 @@ static int uas_is_interface(struct usb_host_interface *intf) | |||
589 | intf->desc.bInterfaceProtocol == USB_PR_UAS); | 628 | intf->desc.bInterfaceProtocol == USB_PR_UAS); |
590 | } | 629 | } |
591 | 630 | ||
631 | static int uas_isnt_supported(struct usb_device *udev) | ||
632 | { | ||
633 | struct usb_hcd *hcd = bus_to_hcd(udev->bus); | ||
634 | |||
635 | dev_warn(&udev->dev, "The driver for the USB controller %s does not " | ||
636 | "support scatter-gather which is\n", | ||
637 | hcd->driver->description); | ||
638 | dev_warn(&udev->dev, "required by the UAS driver. Please try an" | ||
639 | "alternative USB controller if you wish to use UAS.\n"); | ||
640 | return -ENODEV; | ||
641 | } | ||
642 | |||
592 | static int uas_switch_interface(struct usb_device *udev, | 643 | static int uas_switch_interface(struct usb_device *udev, |
593 | struct usb_interface *intf) | 644 | struct usb_interface *intf) |
594 | { | 645 | { |
595 | int i; | 646 | int i; |
596 | 647 | int sg_supported = udev->bus->sg_tablesize != 0; | |
597 | if (uas_is_interface(intf->cur_altsetting)) | ||
598 | return 0; | ||
599 | 648 | ||
600 | for (i = 0; i < intf->num_altsetting; i++) { | 649 | for (i = 0; i < intf->num_altsetting; i++) { |
601 | struct usb_host_interface *alt = &intf->altsetting[i]; | 650 | struct usb_host_interface *alt = &intf->altsetting[i]; |
602 | if (alt == intf->cur_altsetting) | 651 | |
603 | continue; | 652 | if (uas_is_interface(alt)) { |
604 | if (uas_is_interface(alt)) | 653 | if (!sg_supported) |
654 | return uas_isnt_supported(udev); | ||
605 | return usb_set_interface(udev, | 655 | return usb_set_interface(udev, |
606 | alt->desc.bInterfaceNumber, | 656 | alt->desc.bInterfaceNumber, |
607 | alt->desc.bAlternateSetting); | 657 | alt->desc.bAlternateSetting); |
658 | } | ||
608 | } | 659 | } |
609 | 660 | ||
610 | return -ENODEV; | 661 | return -ENODEV; |
@@ -619,6 +670,7 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo) | |||
619 | unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints; | 670 | unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints; |
620 | 671 | ||
621 | devinfo->uas_sense_old = 0; | 672 | devinfo->uas_sense_old = 0; |
673 | devinfo->cmnd = NULL; | ||
622 | 674 | ||
623 | for (i = 0; i < n_endpoints; i++) { | 675 | for (i = 0; i < n_endpoints; i++) { |
624 | unsigned char *extra = endpoint[i].extra; | 676 | unsigned char *extra = endpoint[i].extra; |
@@ -670,6 +722,40 @@ static void uas_configure_endpoints(struct uas_dev_info *devinfo) | |||
670 | } | 722 | } |
671 | } | 723 | } |
672 | 724 | ||
725 | static int uas_alloc_status_urb(struct uas_dev_info *devinfo, | ||
726 | struct Scsi_Host *shost) | ||
727 | { | ||
728 | if (devinfo->use_streams) { | ||
729 | devinfo->status_urb = NULL; | ||
730 | return 0; | ||
731 | } | ||
732 | |||
733 | devinfo->status_urb = uas_alloc_sense_urb(devinfo, GFP_KERNEL, | ||
734 | shost, 0); | ||
735 | if (!devinfo->status_urb) | ||
736 | goto err_s_urb; | ||
737 | |||
738 | if (usb_submit_urb(devinfo->status_urb, GFP_KERNEL)) | ||
739 | goto err_submit_urb; | ||
740 | |||
741 | return 0; | ||
742 | err_submit_urb: | ||
743 | usb_free_urb(devinfo->status_urb); | ||
744 | err_s_urb: | ||
745 | return -ENOMEM; | ||
746 | } | ||
747 | |||
748 | static void uas_free_streams(struct uas_dev_info *devinfo) | ||
749 | { | ||
750 | struct usb_device *udev = devinfo->udev; | ||
751 | struct usb_host_endpoint *eps[3]; | ||
752 | |||
753 | eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe); | ||
754 | eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe); | ||
755 | eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe); | ||
756 | usb_free_streams(devinfo->intf, eps, 3, GFP_KERNEL); | ||
757 | } | ||
758 | |||
673 | /* | 759 | /* |
674 | * XXX: What I'd like to do here is register a SCSI host for each USB host in | 760 | * XXX: What I'd like to do here is register a SCSI host for each USB host in |
675 | * the system. Follow usb-storage's design of registering a SCSI host for | 761 | * the system. Follow usb-storage's design of registering a SCSI host for |
@@ -699,18 +785,33 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
699 | shost->max_id = 1; | 785 | shost->max_id = 1; |
700 | shost->sg_tablesize = udev->bus->sg_tablesize; | 786 | shost->sg_tablesize = udev->bus->sg_tablesize; |
701 | 787 | ||
702 | result = scsi_add_host(shost, &intf->dev); | 788 | devinfo->intf = intf; |
789 | devinfo->udev = udev; | ||
790 | uas_configure_endpoints(devinfo); | ||
791 | |||
792 | result = scsi_init_shared_tag_map(shost, devinfo->qdepth - 2); | ||
703 | if (result) | 793 | if (result) |
704 | goto free; | 794 | goto free; |
795 | |||
796 | result = scsi_add_host(shost, &intf->dev); | ||
797 | if (result) | ||
798 | goto deconfig_eps; | ||
799 | |||
705 | shost->hostdata[0] = (unsigned long)devinfo; | 800 | shost->hostdata[0] = (unsigned long)devinfo; |
706 | 801 | ||
707 | devinfo->intf = intf; | 802 | result = uas_alloc_status_urb(devinfo, shost); |
708 | devinfo->udev = udev; | 803 | if (result) |
709 | uas_configure_endpoints(devinfo); | 804 | goto err_alloc_status; |
710 | 805 | ||
711 | scsi_scan_host(shost); | 806 | scsi_scan_host(shost); |
712 | usb_set_intfdata(intf, shost); | 807 | usb_set_intfdata(intf, shost); |
713 | return result; | 808 | return result; |
809 | |||
810 | err_alloc_status: | ||
811 | scsi_remove_host(shost); | ||
812 | shost = NULL; | ||
813 | deconfig_eps: | ||
814 | uas_free_streams(devinfo); | ||
714 | free: | 815 | free: |
715 | kfree(devinfo); | 816 | kfree(devinfo); |
716 | if (shost) | 817 | if (shost) |
@@ -732,18 +833,13 @@ static int uas_post_reset(struct usb_interface *intf) | |||
732 | 833 | ||
733 | static void uas_disconnect(struct usb_interface *intf) | 834 | static void uas_disconnect(struct usb_interface *intf) |
734 | { | 835 | { |
735 | struct usb_device *udev = interface_to_usbdev(intf); | ||
736 | struct usb_host_endpoint *eps[3]; | ||
737 | struct Scsi_Host *shost = usb_get_intfdata(intf); | 836 | struct Scsi_Host *shost = usb_get_intfdata(intf); |
738 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; | 837 | struct uas_dev_info *devinfo = (void *)shost->hostdata[0]; |
739 | 838 | ||
740 | scsi_remove_host(shost); | 839 | scsi_remove_host(shost); |
741 | 840 | usb_kill_urb(devinfo->status_urb); | |
742 | eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe); | 841 | usb_free_urb(devinfo->status_urb); |
743 | eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe); | 842 | uas_free_streams(devinfo); |
744 | eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe); | ||
745 | usb_free_streams(intf, eps, 3, GFP_KERNEL); | ||
746 | |||
747 | kfree(devinfo); | 843 | kfree(devinfo); |
748 | } | 844 | } |
749 | 845 | ||
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index db51ba16dc07..c18538e4a6db 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -125,6 +125,9 @@ static struct us_unusual_dev us_unusual_dev_list[] = { | |||
125 | { } /* Terminating entry */ | 125 | { } /* Terminating entry */ |
126 | }; | 126 | }; |
127 | 127 | ||
128 | static struct us_unusual_dev for_dynamic_ids = | ||
129 | USUAL_DEV(USB_SC_SCSI, USB_PR_BULK, 0); | ||
130 | |||
128 | #undef UNUSUAL_DEV | 131 | #undef UNUSUAL_DEV |
129 | #undef COMPLIANT_DEV | 132 | #undef COMPLIANT_DEV |
130 | #undef USUAL_DEV | 133 | #undef USUAL_DEV |
@@ -999,8 +1002,10 @@ EXPORT_SYMBOL_GPL(usb_stor_disconnect); | |||
999 | static int storage_probe(struct usb_interface *intf, | 1002 | static int storage_probe(struct usb_interface *intf, |
1000 | const struct usb_device_id *id) | 1003 | const struct usb_device_id *id) |
1001 | { | 1004 | { |
1005 | struct us_unusual_dev *unusual_dev; | ||
1002 | struct us_data *us; | 1006 | struct us_data *us; |
1003 | int result; | 1007 | int result; |
1008 | int size; | ||
1004 | 1009 | ||
1005 | /* | 1010 | /* |
1006 | * If libusual is configured, let it decide whether a standard | 1011 | * If libusual is configured, let it decide whether a standard |
@@ -1019,8 +1024,19 @@ static int storage_probe(struct usb_interface *intf, | |||
1019 | * table, so we use the index of the id entry to find the | 1024 | * table, so we use the index of the id entry to find the |
1020 | * corresponding unusual_devs entry. | 1025 | * corresponding unusual_devs entry. |
1021 | */ | 1026 | */ |
1022 | result = usb_stor_probe1(&us, intf, id, | 1027 | |
1023 | (id - usb_storage_usb_ids) + us_unusual_dev_list); | 1028 | size = ARRAY_SIZE(us_unusual_dev_list); |
1029 | if (id >= usb_storage_usb_ids && id < usb_storage_usb_ids + size) { | ||
1030 | unusual_dev = (id - usb_storage_usb_ids) + us_unusual_dev_list; | ||
1031 | } else { | ||
1032 | unusual_dev = &for_dynamic_ids; | ||
1033 | |||
1034 | US_DEBUGP("%s %s 0x%04x 0x%04x\n", "Use Bulk-Only transport", | ||
1035 | "with the Transparent SCSI protocol for dynamic id:", | ||
1036 | id->idVendor, id->idProduct); | ||
1037 | } | ||
1038 | |||
1039 | result = usb_stor_probe1(&us, intf, id, unusual_dev); | ||
1024 | if (result) | 1040 | if (result) |
1025 | return result; | 1041 | return result; |
1026 | 1042 | ||
@@ -1046,7 +1062,6 @@ static struct usb_driver usb_storage_driver = { | |||
1046 | .id_table = usb_storage_usb_ids, | 1062 | .id_table = usb_storage_usb_ids, |
1047 | .supports_autosuspend = 1, | 1063 | .supports_autosuspend = 1, |
1048 | .soft_unbind = 1, | 1064 | .soft_unbind = 1, |
1049 | .no_dynamic_id = 1, | ||
1050 | }; | 1065 | }; |
1051 | 1066 | ||
1052 | static int __init usb_stor_init(void) | 1067 | static int __init usb_stor_init(void) |
diff --git a/include/linux/device.h b/include/linux/device.h index f62e21689fdd..7c46bc32fcbf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -1005,19 +1005,20 @@ extern long sysfs_deprecated; | |||
1005 | * @__driver: driver name | 1005 | * @__driver: driver name |
1006 | * @__register: register function for this driver type | 1006 | * @__register: register function for this driver type |
1007 | * @__unregister: unregister function for this driver type | 1007 | * @__unregister: unregister function for this driver type |
1008 | * @...: Additional arguments to be passed to __register and __unregister. | ||
1008 | * | 1009 | * |
1009 | * Use this macro to construct bus specific macros for registering | 1010 | * Use this macro to construct bus specific macros for registering |
1010 | * drivers, and do not use it on its own. | 1011 | * drivers, and do not use it on its own. |
1011 | */ | 1012 | */ |
1012 | #define module_driver(__driver, __register, __unregister) \ | 1013 | #define module_driver(__driver, __register, __unregister, ...) \ |
1013 | static int __init __driver##_init(void) \ | 1014 | static int __init __driver##_init(void) \ |
1014 | { \ | 1015 | { \ |
1015 | return __register(&(__driver)); \ | 1016 | return __register(&(__driver) , ##__VA_ARGS__); \ |
1016 | } \ | 1017 | } \ |
1017 | module_init(__driver##_init); \ | 1018 | module_init(__driver##_init); \ |
1018 | static void __exit __driver##_exit(void) \ | 1019 | static void __exit __driver##_exit(void) \ |
1019 | { \ | 1020 | { \ |
1020 | __unregister(&(__driver)); \ | 1021 | __unregister(&(__driver) , ##__VA_ARGS__); \ |
1021 | } \ | 1022 | } \ |
1022 | module_exit(__driver##_exit); | 1023 | module_exit(__driver##_exit); |
1023 | 1024 | ||
diff --git a/include/linux/platform_data/dwc3-exynos.h b/include/linux/platform_data/dwc3-exynos.h new file mode 100644 index 000000000000..5eb7da9b3772 --- /dev/null +++ b/include/linux/platform_data/dwc3-exynos.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /** | ||
2 | * dwc3-exynos.h - Samsung EXYNOS DWC3 Specific Glue layer, header. | ||
3 | * | ||
4 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. | ||
5 | * http://www.samsung.com | ||
6 | * | ||
7 | * Author: Anton Tikhomirov <av.tikhomirov@samsung.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | */ | ||
14 | |||
15 | #ifndef _DWC3_EXYNOS_H_ | ||
16 | #define _DWC3_EXYNOS_H_ | ||
17 | |||
18 | struct dwc3_exynos_data { | ||
19 | int phy_type; | ||
20 | int (*phy_init)(struct platform_device *pdev, int type); | ||
21 | int (*phy_exit)(struct platform_device *pdev, int type); | ||
22 | }; | ||
23 | |||
24 | #endif /* _DWC3_EXYNOS_H_ */ | ||
diff --git a/include/linux/usb.h b/include/linux/usb.h index 69d845739bc2..73b68d1f2cb0 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -376,6 +376,12 @@ struct usb_bus { | |||
376 | 376 | ||
377 | struct usb_tt; | 377 | struct usb_tt; |
378 | 378 | ||
379 | enum usb_device_removable { | ||
380 | USB_DEVICE_REMOVABLE_UNKNOWN = 0, | ||
381 | USB_DEVICE_REMOVABLE, | ||
382 | USB_DEVICE_FIXED, | ||
383 | }; | ||
384 | |||
379 | /** | 385 | /** |
380 | * struct usb_device - kernel's representation of a USB device | 386 | * struct usb_device - kernel's representation of a USB device |
381 | * @devnum: device number; address on a USB bus | 387 | * @devnum: device number; address on a USB bus |
@@ -432,6 +438,7 @@ struct usb_tt; | |||
432 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB | 438 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB |
433 | * specific data for the device. | 439 | * specific data for the device. |
434 | * @slot_id: Slot ID assigned by xHCI | 440 | * @slot_id: Slot ID assigned by xHCI |
441 | * @removable: Device can be physically removed from this port | ||
435 | * | 442 | * |
436 | * Notes: | 443 | * Notes: |
437 | * Usbcore drivers should not set usbdev->state directly. Instead use | 444 | * Usbcore drivers should not set usbdev->state directly. Instead use |
@@ -494,7 +501,7 @@ struct usb_device { | |||
494 | #endif | 501 | #endif |
495 | 502 | ||
496 | int maxchild; | 503 | int maxchild; |
497 | struct usb_device *children[USB_MAXCHILDREN]; | 504 | struct usb_device **children; |
498 | 505 | ||
499 | u32 quirks; | 506 | u32 quirks; |
500 | atomic_t urbnum; | 507 | atomic_t urbnum; |
@@ -509,6 +516,7 @@ struct usb_device { | |||
509 | #endif | 516 | #endif |
510 | struct wusb_dev *wusb_dev; | 517 | struct wusb_dev *wusb_dev; |
511 | int slot_id; | 518 | int slot_id; |
519 | enum usb_device_removable removable; | ||
512 | }; | 520 | }; |
513 | #define to_usb_device(d) container_of(d, struct usb_device, dev) | 521 | #define to_usb_device(d) container_of(d, struct usb_device, dev) |
514 | 522 | ||
diff --git a/include/linux/usb/audio-v2.h b/include/linux/usb/audio-v2.h index 964cb603f7c7..ed13053153f4 100644 --- a/include/linux/usb/audio-v2.h +++ b/include/linux/usb/audio-v2.h | |||
@@ -43,6 +43,27 @@ static inline bool uac2_control_is_writeable(u32 bmControls, u8 control) | |||
43 | return (bmControls >> (control * 2)) & 0x2; | 43 | return (bmControls >> (control * 2)) & 0x2; |
44 | } | 44 | } |
45 | 45 | ||
46 | /* 4.7.2 Class-Specific AC Interface Descriptor */ | ||
47 | struct uac2_ac_header_descriptor { | ||
48 | __u8 bLength; /* 9 */ | ||
49 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
50 | __u8 bDescriptorSubtype; /* UAC_MS_HEADER */ | ||
51 | __le16 bcdADC; /* 0x0200 */ | ||
52 | __u8 bCategory; | ||
53 | __le16 wTotalLength; /* includes Unit and Terminal desc. */ | ||
54 | __u8 bmControls; | ||
55 | } __packed; | ||
56 | |||
57 | /* 2.3.1.6 Type I Format Type Descriptor (Frmts20 final.pdf)*/ | ||
58 | struct uac2_format_type_i_descriptor { | ||
59 | __u8 bLength; /* in bytes: 6 */ | ||
60 | __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */ | ||
61 | __u8 bDescriptorSubtype; /* FORMAT_TYPE */ | ||
62 | __u8 bFormatType; /* FORMAT_TYPE_1 */ | ||
63 | __u8 bSubslotSize; /* {1,2,3,4} */ | ||
64 | __u8 bBitResolution; | ||
65 | } __packed; | ||
66 | |||
46 | /* 4.7.2.1 Clock Source Descriptor */ | 67 | /* 4.7.2.1 Clock Source Descriptor */ |
47 | 68 | ||
48 | struct uac_clock_source_descriptor { | 69 | struct uac_clock_source_descriptor { |
diff --git a/include/linux/usb/cdc-wdm.h b/include/linux/usb/cdc-wdm.h new file mode 100644 index 000000000000..719c332620fa --- /dev/null +++ b/include/linux/usb/cdc-wdm.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * USB CDC Device Management subdriver | ||
3 | * | ||
4 | * Copyright (c) 2012 Bjørn Mork <bjorn@mork.no> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #ifndef __LINUX_USB_CDC_WDM_H | ||
12 | #define __LINUX_USB_CDC_WDM_H | ||
13 | |||
14 | extern struct usb_driver *usb_cdc_wdm_register(struct usb_interface *intf, | ||
15 | struct usb_endpoint_descriptor *ep, | ||
16 | int bufsize, | ||
17 | int (*manage_power)(struct usb_interface *, int)); | ||
18 | |||
19 | #endif /* __LINUX_USB_CDC_WDM_H */ | ||
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h index 0b83acd3360a..f1d26b6067f1 100644 --- a/include/linux/usb/ch11.h +++ b/include/linux/usb/ch11.h | |||
@@ -76,6 +76,11 @@ | |||
76 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 | 76 | #define USB_PORT_FEAT_C_BH_PORT_RESET 29 |
77 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 | 77 | #define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 |
78 | 78 | ||
79 | /* USB 3.0 hub remote wake mask bits, see table 10-14 */ | ||
80 | #define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) | ||
81 | #define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) | ||
82 | #define USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT (1 << 10) | ||
83 | |||
79 | /* | 84 | /* |
80 | * Hub Status and Hub Change results | 85 | * Hub Status and Hub Change results |
81 | * See USB 2.0 spec Table 11-19 and Table 11-20 | 86 | * See USB 2.0 spec Table 11-19 and Table 11-20 |
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index 3b6f628880f8..af21f3115919 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h | |||
@@ -789,6 +789,11 @@ struct usb_ext_cap_descriptor { /* Link Power Management */ | |||
789 | __u8 bDevCapabilityType; | 789 | __u8 bDevCapabilityType; |
790 | __le32 bmAttributes; | 790 | __le32 bmAttributes; |
791 | #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ | 791 | #define USB_LPM_SUPPORT (1 << 1) /* supports LPM */ |
792 | #define USB_BESL_SUPPORT (1 << 2) /* supports BESL */ | ||
793 | #define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/ | ||
794 | #define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */ | ||
795 | #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) | ||
796 | #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) | ||
792 | } __attribute__((packed)); | 797 | } __attribute__((packed)); |
793 | 798 | ||
794 | #define USB_DT_USB_EXT_CAP_SIZE 7 | 799 | #define USB_DT_USB_EXT_CAP_SIZE 7 |
diff --git a/include/linux/usb/ehci_pdriver.h b/include/linux/usb/ehci_pdriver.h new file mode 100644 index 000000000000..1894f42fe3f7 --- /dev/null +++ b/include/linux/usb/ehci_pdriver.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | * 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 Foundation, | ||
16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | */ | ||
18 | |||
19 | #ifndef __USB_CORE_EHCI_PDRIVER_H | ||
20 | #define __USB_CORE_EHCI_PDRIVER_H | ||
21 | |||
22 | /** | ||
23 | * struct usb_ehci_pdata - platform_data for generic ehci driver | ||
24 | * | ||
25 | * @caps_offset: offset of the EHCI Capability Registers to the start of | ||
26 | * the io memory region provided to the driver. | ||
27 | * @has_tt: set to 1 if TT is integrated in root hub. | ||
28 | * @port_power_on: set to 1 if the controller needs a power up after | ||
29 | * initialization. | ||
30 | * @port_power_off: set to 1 if the controller needs to be powered down | ||
31 | * after initialization. | ||
32 | * | ||
33 | * These are general configuration options for the EHCI controller. All of | ||
34 | * these options are activating more or less workarounds for some hardware. | ||
35 | */ | ||
36 | struct usb_ehci_pdata { | ||
37 | int caps_offset; | ||
38 | unsigned has_tt:1; | ||
39 | unsigned has_synopsys_hc_bug:1; | ||
40 | unsigned big_endian_desc:1; | ||
41 | unsigned big_endian_mmio:1; | ||
42 | unsigned port_power_on:1; | ||
43 | unsigned port_power_off:1; | ||
44 | }; | ||
45 | |||
46 | #endif /* __USB_CORE_EHCI_PDRIVER_H */ | ||
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index da653b5c7134..9517466ababb 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h | |||
@@ -950,6 +950,16 @@ static inline void usb_free_descriptors(struct usb_descriptor_header **v) | |||
950 | 950 | ||
951 | /*-------------------------------------------------------------------------*/ | 951 | /*-------------------------------------------------------------------------*/ |
952 | 952 | ||
953 | /* utility to simplify map/unmap of usb_requests to/from DMA */ | ||
954 | |||
955 | extern int usb_gadget_map_request(struct usb_gadget *gadget, | ||
956 | struct usb_request *req, int is_in); | ||
957 | |||
958 | extern void usb_gadget_unmap_request(struct usb_gadget *gadget, | ||
959 | struct usb_request *req, int is_in); | ||
960 | |||
961 | /*-------------------------------------------------------------------------*/ | ||
962 | |||
953 | /* utility wrapping a simple endpoint selection policy */ | 963 | /* utility wrapping a simple endpoint selection policy */ |
954 | 964 | ||
955 | extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *, | 965 | extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *, |
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index b2f62f3a32af..5de415707c23 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h | |||
@@ -127,7 +127,7 @@ struct usb_hcd { | |||
127 | unsigned authorized_default:1; | 127 | unsigned authorized_default:1; |
128 | unsigned has_tt:1; /* Integrated TT in root hub */ | 128 | unsigned has_tt:1; /* Integrated TT in root hub */ |
129 | 129 | ||
130 | int irq; /* irq allocated */ | 130 | unsigned int irq; /* irq allocated */ |
131 | void __iomem *regs; /* device memory/io */ | 131 | void __iomem *regs; /* device memory/io */ |
132 | u64 rsrc_start; /* memory/io resource start */ | 132 | u64 rsrc_start; /* memory/io resource start */ |
133 | u64 rsrc_len; /* memory/io resource length */ | 133 | u64 rsrc_len; /* memory/io resource length */ |
@@ -412,6 +412,8 @@ extern irqreturn_t usb_hcd_irq(int irq, void *__hcd); | |||
412 | 412 | ||
413 | extern void usb_hc_died(struct usb_hcd *hcd); | 413 | extern void usb_hc_died(struct usb_hcd *hcd); |
414 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); | 414 | extern void usb_hcd_poll_rh_status(struct usb_hcd *hcd); |
415 | extern void usb_wakeup_notification(struct usb_device *hdev, | ||
416 | unsigned int portnum); | ||
415 | 417 | ||
416 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ | 418 | /* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ |
417 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) | 419 | #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) |
diff --git a/include/linux/usb/intel_mid_otg.h b/include/linux/usb/intel_mid_otg.h index a0ccf795f362..756cf5543ffd 100644 --- a/include/linux/usb/intel_mid_otg.h +++ b/include/linux/usb/intel_mid_otg.h | |||
@@ -104,11 +104,11 @@ struct iotg_ulpi_access_ops { | |||
104 | /* | 104 | /* |
105 | * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact | 105 | * the Intel MID (Langwell/Penwell) otg transceiver driver needs to interact |
106 | * with device and host drivers to implement the USB OTG related feature. More | 106 | * with device and host drivers to implement the USB OTG related feature. More |
107 | * function members are added based on otg_transceiver data structure for this | 107 | * function members are added based on usb_phy data structure for this |
108 | * purpose. | 108 | * purpose. |
109 | */ | 109 | */ |
110 | struct intel_mid_otg_xceiv { | 110 | struct intel_mid_otg_xceiv { |
111 | struct otg_transceiver otg; | 111 | struct usb_phy otg; |
112 | struct otg_hsm hsm; | 112 | struct otg_hsm hsm; |
113 | 113 | ||
114 | /* base address */ | 114 | /* base address */ |
@@ -147,7 +147,7 @@ struct intel_mid_otg_xceiv { | |||
147 | 147 | ||
148 | }; | 148 | }; |
149 | static inline | 149 | static inline |
150 | struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct otg_transceiver *otg) | 150 | struct intel_mid_otg_xceiv *otg_to_mid_xceiv(struct usb_phy *otg) |
151 | { | 151 | { |
152 | return container_of(otg, struct intel_mid_otg_xceiv, otg); | 152 | return container_of(otg, struct intel_mid_otg_xceiv, otg); |
153 | } | 153 | } |
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h index 00311fe9d0df..22a396c13f3a 100644 --- a/include/linux/usb/msm_hsusb.h +++ b/include/linux/usb/msm_hsusb.h | |||
@@ -160,7 +160,7 @@ struct msm_otg_platform_data { | |||
160 | * detection process. | 160 | * detection process. |
161 | */ | 161 | */ |
162 | struct msm_otg { | 162 | struct msm_otg { |
163 | struct otg_transceiver otg; | 163 | struct usb_phy phy; |
164 | struct msm_otg_platform_data *pdata; | 164 | struct msm_otg_platform_data *pdata; |
165 | int irq; | 165 | int irq; |
166 | struct clk *clk; | 166 | struct clk *clk; |
diff --git a/include/linux/usb/ohci_pdriver.h b/include/linux/usb/ohci_pdriver.h new file mode 100644 index 000000000000..2808f2a9cce8 --- /dev/null +++ b/include/linux/usb/ohci_pdriver.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | * 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 Foundation, | ||
16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | */ | ||
18 | |||
19 | #ifndef __USB_CORE_OHCI_PDRIVER_H | ||
20 | #define __USB_CORE_OHCI_PDRIVER_H | ||
21 | |||
22 | /** | ||
23 | * struct usb_ohci_pdata - platform_data for generic ohci driver | ||
24 | * | ||
25 | * @big_endian_desc: BE descriptors | ||
26 | * @big_endian_mmio: BE registers | ||
27 | * @no_big_frame_no: no big endian frame_no shift | ||
28 | * | ||
29 | * These are general configuration options for the OHCI controller. All of | ||
30 | * these options are activating more or less workarounds for some hardware. | ||
31 | */ | ||
32 | struct usb_ohci_pdata { | ||
33 | unsigned big_endian_desc:1; | ||
34 | unsigned big_endian_mmio:1; | ||
35 | unsigned no_big_frame_no:1; | ||
36 | }; | ||
37 | |||
38 | #endif /* __USB_CORE_OHCI_PDRIVER_H */ | ||
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index d87f44f5b04e..f67810f8f21b 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h | |||
@@ -35,7 +35,7 @@ enum usb_otg_state { | |||
35 | OTG_STATE_A_VBUS_ERR, | 35 | OTG_STATE_A_VBUS_ERR, |
36 | }; | 36 | }; |
37 | 37 | ||
38 | enum usb_xceiv_events { | 38 | enum usb_phy_events { |
39 | USB_EVENT_NONE, /* no events or cable disconnected */ | 39 | USB_EVENT_NONE, /* no events or cable disconnected */ |
40 | USB_EVENT_VBUS, /* vbus valid event */ | 40 | USB_EVENT_VBUS, /* vbus valid event */ |
41 | USB_EVENT_ID, /* id was grounded */ | 41 | USB_EVENT_ID, /* id was grounded */ |
@@ -43,14 +43,39 @@ enum usb_xceiv_events { | |||
43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ | 43 | USB_EVENT_ENUMERATED, /* gadget driver enumerated */ |
44 | }; | 44 | }; |
45 | 45 | ||
46 | struct otg_transceiver; | 46 | struct usb_phy; |
47 | 47 | ||
48 | /* for transceivers connected thru an ULPI interface, the user must | 48 | /* for transceivers connected thru an ULPI interface, the user must |
49 | * provide access ops | 49 | * provide access ops |
50 | */ | 50 | */ |
51 | struct otg_io_access_ops { | 51 | struct usb_phy_io_ops { |
52 | int (*read)(struct otg_transceiver *otg, u32 reg); | 52 | int (*read)(struct usb_phy *x, u32 reg); |
53 | int (*write)(struct otg_transceiver *otg, u32 val, u32 reg); | 53 | int (*write)(struct usb_phy *x, u32 val, u32 reg); |
54 | }; | ||
55 | |||
56 | struct usb_otg { | ||
57 | u8 default_a; | ||
58 | |||
59 | struct usb_phy *phy; | ||
60 | struct usb_bus *host; | ||
61 | struct usb_gadget *gadget; | ||
62 | |||
63 | /* bind/unbind the host controller */ | ||
64 | int (*set_host)(struct usb_otg *otg, struct usb_bus *host); | ||
65 | |||
66 | /* bind/unbind the peripheral controller */ | ||
67 | int (*set_peripheral)(struct usb_otg *otg, | ||
68 | struct usb_gadget *gadget); | ||
69 | |||
70 | /* effective for A-peripheral, ignored for B devices */ | ||
71 | int (*set_vbus)(struct usb_otg *otg, bool enabled); | ||
72 | |||
73 | /* for B devices only: start session with A-Host */ | ||
74 | int (*start_srp)(struct usb_otg *otg); | ||
75 | |||
76 | /* start or continue HNP role switch */ | ||
77 | int (*start_hnp)(struct usb_otg *otg); | ||
78 | |||
54 | }; | 79 | }; |
55 | 80 | ||
56 | /* | 81 | /* |
@@ -59,22 +84,20 @@ struct otg_io_access_ops { | |||
59 | * moment, using the transceiver, ID signal, HNP and sometimes static | 84 | * moment, using the transceiver, ID signal, HNP and sometimes static |
60 | * configuration information (including "board isn't wired for otg"). | 85 | * configuration information (including "board isn't wired for otg"). |
61 | */ | 86 | */ |
62 | struct otg_transceiver { | 87 | struct usb_phy { |
63 | struct device *dev; | 88 | struct device *dev; |
64 | const char *label; | 89 | const char *label; |
65 | unsigned int flags; | 90 | unsigned int flags; |
66 | 91 | ||
67 | u8 default_a; | ||
68 | enum usb_otg_state state; | 92 | enum usb_otg_state state; |
69 | enum usb_xceiv_events last_event; | 93 | enum usb_phy_events last_event; |
70 | 94 | ||
71 | struct usb_bus *host; | 95 | struct usb_otg *otg; |
72 | struct usb_gadget *gadget; | ||
73 | 96 | ||
74 | struct otg_io_access_ops *io_ops; | 97 | struct usb_phy_io_ops *io_ops; |
75 | void __iomem *io_priv; | 98 | void __iomem *io_priv; |
76 | 99 | ||
77 | /* for notification of usb_xceiv_events */ | 100 | /* for notification of usb_phy_events */ |
78 | struct atomic_notifier_head notifier; | 101 | struct atomic_notifier_head notifier; |
79 | 102 | ||
80 | /* to pass extra port status to the root hub */ | 103 | /* to pass extra port status to the root hub */ |
@@ -82,40 +105,22 @@ struct otg_transceiver { | |||
82 | u16 port_change; | 105 | u16 port_change; |
83 | 106 | ||
84 | /* initialize/shutdown the OTG controller */ | 107 | /* initialize/shutdown the OTG controller */ |
85 | int (*init)(struct otg_transceiver *otg); | 108 | int (*init)(struct usb_phy *x); |
86 | void (*shutdown)(struct otg_transceiver *otg); | 109 | void (*shutdown)(struct usb_phy *x); |
87 | |||
88 | /* bind/unbind the host controller */ | ||
89 | int (*set_host)(struct otg_transceiver *otg, | ||
90 | struct usb_bus *host); | ||
91 | |||
92 | /* bind/unbind the peripheral controller */ | ||
93 | int (*set_peripheral)(struct otg_transceiver *otg, | ||
94 | struct usb_gadget *gadget); | ||
95 | 110 | ||
96 | /* effective for B devices, ignored for A-peripheral */ | 111 | /* effective for B devices, ignored for A-peripheral */ |
97 | int (*set_power)(struct otg_transceiver *otg, | 112 | int (*set_power)(struct usb_phy *x, |
98 | unsigned mA); | 113 | unsigned mA); |
99 | 114 | ||
100 | /* effective for A-peripheral, ignored for B devices */ | ||
101 | int (*set_vbus)(struct otg_transceiver *otg, | ||
102 | bool enabled); | ||
103 | |||
104 | /* for non-OTG B devices: set transceiver into suspend mode */ | 115 | /* for non-OTG B devices: set transceiver into suspend mode */ |
105 | int (*set_suspend)(struct otg_transceiver *otg, | 116 | int (*set_suspend)(struct usb_phy *x, |
106 | int suspend); | 117 | int suspend); |
107 | 118 | ||
108 | /* for B devices only: start session with A-Host */ | ||
109 | int (*start_srp)(struct otg_transceiver *otg); | ||
110 | |||
111 | /* start or continue HNP role switch */ | ||
112 | int (*start_hnp)(struct otg_transceiver *otg); | ||
113 | |||
114 | }; | 119 | }; |
115 | 120 | ||
116 | 121 | ||
117 | /* for board-specific init logic */ | 122 | /* for board-specific init logic */ |
118 | extern int otg_set_transceiver(struct otg_transceiver *); | 123 | extern int usb_set_transceiver(struct usb_phy *); |
119 | 124 | ||
120 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) | 125 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) |
121 | /* sometimes transceivers are accessed only through e.g. ULPI */ | 126 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
@@ -132,50 +137,50 @@ static inline void usb_nop_xceiv_unregister(void) | |||
132 | #endif | 137 | #endif |
133 | 138 | ||
134 | /* helpers for direct access thru low-level io interface */ | 139 | /* helpers for direct access thru low-level io interface */ |
135 | static inline int otg_io_read(struct otg_transceiver *otg, u32 reg) | 140 | static inline int usb_phy_io_read(struct usb_phy *x, u32 reg) |
136 | { | 141 | { |
137 | if (otg->io_ops && otg->io_ops->read) | 142 | if (x->io_ops && x->io_ops->read) |
138 | return otg->io_ops->read(otg, reg); | 143 | return x->io_ops->read(x, reg); |
139 | 144 | ||
140 | return -EINVAL; | 145 | return -EINVAL; |
141 | } | 146 | } |
142 | 147 | ||
143 | static inline int otg_io_write(struct otg_transceiver *otg, u32 val, u32 reg) | 148 | static inline int usb_phy_io_write(struct usb_phy *x, u32 val, u32 reg) |
144 | { | 149 | { |
145 | if (otg->io_ops && otg->io_ops->write) | 150 | if (x->io_ops && x->io_ops->write) |
146 | return otg->io_ops->write(otg, val, reg); | 151 | return x->io_ops->write(x, val, reg); |
147 | 152 | ||
148 | return -EINVAL; | 153 | return -EINVAL; |
149 | } | 154 | } |
150 | 155 | ||
151 | static inline int | 156 | static inline int |
152 | otg_init(struct otg_transceiver *otg) | 157 | usb_phy_init(struct usb_phy *x) |
153 | { | 158 | { |
154 | if (otg->init) | 159 | if (x->init) |
155 | return otg->init(otg); | 160 | return x->init(x); |
156 | 161 | ||
157 | return 0; | 162 | return 0; |
158 | } | 163 | } |
159 | 164 | ||
160 | static inline void | 165 | static inline void |
161 | otg_shutdown(struct otg_transceiver *otg) | 166 | usb_phy_shutdown(struct usb_phy *x) |
162 | { | 167 | { |
163 | if (otg->shutdown) | 168 | if (x->shutdown) |
164 | otg->shutdown(otg); | 169 | x->shutdown(x); |
165 | } | 170 | } |
166 | 171 | ||
167 | /* for usb host and peripheral controller drivers */ | 172 | /* for usb host and peripheral controller drivers */ |
168 | #ifdef CONFIG_USB_OTG_UTILS | 173 | #ifdef CONFIG_USB_OTG_UTILS |
169 | extern struct otg_transceiver *otg_get_transceiver(void); | 174 | extern struct usb_phy *usb_get_transceiver(void); |
170 | extern void otg_put_transceiver(struct otg_transceiver *); | 175 | extern void usb_put_transceiver(struct usb_phy *); |
171 | extern const char *otg_state_string(enum usb_otg_state state); | 176 | extern const char *otg_state_string(enum usb_otg_state state); |
172 | #else | 177 | #else |
173 | static inline struct otg_transceiver *otg_get_transceiver(void) | 178 | static inline struct usb_phy *usb_get_transceiver(void) |
174 | { | 179 | { |
175 | return NULL; | 180 | return NULL; |
176 | } | 181 | } |
177 | 182 | ||
178 | static inline void otg_put_transceiver(struct otg_transceiver *x) | 183 | static inline void usb_put_transceiver(struct usb_phy *x) |
179 | { | 184 | { |
180 | } | 185 | } |
181 | 186 | ||
@@ -187,67 +192,84 @@ static inline const char *otg_state_string(enum usb_otg_state state) | |||
187 | 192 | ||
188 | /* Context: can sleep */ | 193 | /* Context: can sleep */ |
189 | static inline int | 194 | static inline int |
190 | otg_start_hnp(struct otg_transceiver *otg) | 195 | otg_start_hnp(struct usb_otg *otg) |
191 | { | 196 | { |
192 | return otg->start_hnp(otg); | 197 | if (otg && otg->start_hnp) |
198 | return otg->start_hnp(otg); | ||
199 | |||
200 | return -ENOTSUPP; | ||
193 | } | 201 | } |
194 | 202 | ||
195 | /* Context: can sleep */ | 203 | /* Context: can sleep */ |
196 | static inline int | 204 | static inline int |
197 | otg_set_vbus(struct otg_transceiver *otg, bool enabled) | 205 | otg_set_vbus(struct usb_otg *otg, bool enabled) |
198 | { | 206 | { |
199 | return otg->set_vbus(otg, enabled); | 207 | if (otg && otg->set_vbus) |
208 | return otg->set_vbus(otg, enabled); | ||
209 | |||
210 | return -ENOTSUPP; | ||
200 | } | 211 | } |
201 | 212 | ||
202 | /* for HCDs */ | 213 | /* for HCDs */ |
203 | static inline int | 214 | static inline int |
204 | otg_set_host(struct otg_transceiver *otg, struct usb_bus *host) | 215 | otg_set_host(struct usb_otg *otg, struct usb_bus *host) |
205 | { | 216 | { |
206 | return otg->set_host(otg, host); | 217 | if (otg && otg->set_host) |
218 | return otg->set_host(otg, host); | ||
219 | |||
220 | return -ENOTSUPP; | ||
207 | } | 221 | } |
208 | 222 | ||
209 | /* for usb peripheral controller drivers */ | 223 | /* for usb peripheral controller drivers */ |
210 | 224 | ||
211 | /* Context: can sleep */ | 225 | /* Context: can sleep */ |
212 | static inline int | 226 | static inline int |
213 | otg_set_peripheral(struct otg_transceiver *otg, struct usb_gadget *periph) | 227 | otg_set_peripheral(struct usb_otg *otg, struct usb_gadget *periph) |
214 | { | 228 | { |
215 | return otg->set_peripheral(otg, periph); | 229 | if (otg && otg->set_peripheral) |
230 | return otg->set_peripheral(otg, periph); | ||
231 | |||
232 | return -ENOTSUPP; | ||
216 | } | 233 | } |
217 | 234 | ||
218 | static inline int | 235 | static inline int |
219 | otg_set_power(struct otg_transceiver *otg, unsigned mA) | 236 | usb_phy_set_power(struct usb_phy *x, unsigned mA) |
220 | { | 237 | { |
221 | return otg->set_power(otg, mA); | 238 | if (x && x->set_power) |
239 | return x->set_power(x, mA); | ||
240 | return 0; | ||
222 | } | 241 | } |
223 | 242 | ||
224 | /* Context: can sleep */ | 243 | /* Context: can sleep */ |
225 | static inline int | 244 | static inline int |
226 | otg_set_suspend(struct otg_transceiver *otg, int suspend) | 245 | usb_phy_set_suspend(struct usb_phy *x, int suspend) |
227 | { | 246 | { |
228 | if (otg->set_suspend != NULL) | 247 | if (x->set_suspend != NULL) |
229 | return otg->set_suspend(otg, suspend); | 248 | return x->set_suspend(x, suspend); |
230 | else | 249 | else |
231 | return 0; | 250 | return 0; |
232 | } | 251 | } |
233 | 252 | ||
234 | static inline int | 253 | static inline int |
235 | otg_start_srp(struct otg_transceiver *otg) | 254 | otg_start_srp(struct usb_otg *otg) |
236 | { | 255 | { |
237 | return otg->start_srp(otg); | 256 | if (otg && otg->start_srp) |
257 | return otg->start_srp(otg); | ||
258 | |||
259 | return -ENOTSUPP; | ||
238 | } | 260 | } |
239 | 261 | ||
240 | /* notifiers */ | 262 | /* notifiers */ |
241 | static inline int | 263 | static inline int |
242 | otg_register_notifier(struct otg_transceiver *otg, struct notifier_block *nb) | 264 | usb_register_notifier(struct usb_phy *x, struct notifier_block *nb) |
243 | { | 265 | { |
244 | return atomic_notifier_chain_register(&otg->notifier, nb); | 266 | return atomic_notifier_chain_register(&x->notifier, nb); |
245 | } | 267 | } |
246 | 268 | ||
247 | static inline void | 269 | static inline void |
248 | otg_unregister_notifier(struct otg_transceiver *otg, struct notifier_block *nb) | 270 | usb_unregister_notifier(struct usb_phy *x, struct notifier_block *nb) |
249 | { | 271 | { |
250 | atomic_notifier_chain_unregister(&otg->notifier, nb); | 272 | atomic_notifier_chain_unregister(&x->notifier, nb); |
251 | } | 273 | } |
252 | 274 | ||
253 | /* for OTG controller drivers (and maybe other stuff) */ | 275 | /* for OTG controller drivers (and maybe other stuff) */ |
diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h index 0d3f98879256..547e59cc00ea 100644 --- a/include/linux/usb/renesas_usbhs.h +++ b/include/linux/usb/renesas_usbhs.h | |||
@@ -149,6 +149,7 @@ struct renesas_usbhs_driver_param { | |||
149 | * option: | 149 | * option: |
150 | */ | 150 | */ |
151 | u32 has_otg:1; /* for controlling PWEN/EXTLP */ | 151 | u32 has_otg:1; /* for controlling PWEN/EXTLP */ |
152 | u32 has_sudmac:1; /* for SUDMAC */ | ||
152 | }; | 153 | }; |
153 | 154 | ||
154 | /* | 155 | /* |
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 4267a9c717ba..fbb666b1b670 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -300,8 +300,10 @@ struct usb_serial_driver { | |||
300 | #define to_usb_serial_driver(d) \ | 300 | #define to_usb_serial_driver(d) \ |
301 | container_of(d, struct usb_serial_driver, driver) | 301 | container_of(d, struct usb_serial_driver, driver) |
302 | 302 | ||
303 | extern int usb_serial_register(struct usb_serial_driver *driver); | 303 | extern int usb_serial_register_drivers(struct usb_driver *udriver, |
304 | extern void usb_serial_deregister(struct usb_serial_driver *driver); | 304 | struct usb_serial_driver * const serial_drivers[]); |
305 | extern void usb_serial_deregister_drivers(struct usb_driver *udriver, | ||
306 | struct usb_serial_driver * const serial_drivers[]); | ||
305 | extern void usb_serial_port_softint(struct usb_serial_port *port); | 307 | extern void usb_serial_port_softint(struct usb_serial_port *port); |
306 | 308 | ||
307 | extern int usb_serial_probe(struct usb_interface *iface, | 309 | extern int usb_serial_probe(struct usb_interface *iface, |
@@ -389,5 +391,35 @@ do { \ | |||
389 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | 391 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ |
390 | } while (0) | 392 | } while (0) |
391 | 393 | ||
394 | /* | ||
395 | * Macro for reporting errors in write path to avoid inifinite loop | ||
396 | * when port is used as a console. | ||
397 | */ | ||
398 | #define dev_err_console(usport, fmt, ...) \ | ||
399 | do { \ | ||
400 | static bool __print_once; \ | ||
401 | struct usb_serial_port *__port = (usport); \ | ||
402 | \ | ||
403 | if (!__port->port.console || !__print_once) { \ | ||
404 | __print_once = true; \ | ||
405 | dev_err(&__port->dev, fmt, ##__VA_ARGS__); \ | ||
406 | } \ | ||
407 | } while (0) | ||
408 | |||
409 | /* | ||
410 | * module_usb_serial_driver() - Helper macro for registering a USB Serial driver | ||
411 | * @__usb_driver: usb_driver struct to register | ||
412 | * @__serial_drivers: list of usb_serial drivers to register | ||
413 | * | ||
414 | * Helper macro for USB serial drivers which do not do anything special | ||
415 | * in module init/exit. This eliminates a lot of boilerplate. Each | ||
416 | * module may only use this macro once, and calling it replaces | ||
417 | * module_init() and module_exit() | ||
418 | * | ||
419 | */ | ||
420 | #define module_usb_serial_driver(__usb_driver, __serial_drivers) \ | ||
421 | module_driver(__usb_driver, usb_serial_register_drivers, \ | ||
422 | usb_serial_deregister_drivers, __serial_drivers) | ||
423 | |||
392 | #endif /* __LINUX_USB_SERIAL_H */ | 424 | #endif /* __LINUX_USB_SERIAL_H */ |
393 | 425 | ||
diff --git a/include/linux/usb/storage.h b/include/linux/usb/storage.h index d7fc910f1dc4..cb33fff2ba0b 100644 --- a/include/linux/usb/storage.h +++ b/include/linux/usb/storage.h | |||
@@ -45,4 +45,42 @@ | |||
45 | 45 | ||
46 | #define USB_PR_DEVICE 0xff /* Use device's value */ | 46 | #define USB_PR_DEVICE 0xff /* Use device's value */ |
47 | 47 | ||
48 | /* | ||
49 | * Bulk only data structures | ||
50 | */ | ||
51 | |||
52 | /* command block wrapper */ | ||
53 | struct bulk_cb_wrap { | ||
54 | __le32 Signature; /* contains 'USBC' */ | ||
55 | __u32 Tag; /* unique per command id */ | ||
56 | __le32 DataTransferLength; /* size of data */ | ||
57 | __u8 Flags; /* direction in bit 0 */ | ||
58 | __u8 Lun; /* LUN normally 0 */ | ||
59 | __u8 Length; /* of of the CDB */ | ||
60 | __u8 CDB[16]; /* max command */ | ||
61 | }; | ||
62 | |||
63 | #define US_BULK_CB_WRAP_LEN 31 | ||
64 | #define US_BULK_CB_SIGN 0x43425355 /*spells out USBC */ | ||
65 | #define US_BULK_FLAG_IN (1 << 7) | ||
66 | #define US_BULK_FLAG_OUT 0 | ||
67 | |||
68 | /* command status wrapper */ | ||
69 | struct bulk_cs_wrap { | ||
70 | __le32 Signature; /* should = 'USBS' */ | ||
71 | __u32 Tag; /* same as original command */ | ||
72 | __le32 Residue; /* amount not transferred */ | ||
73 | __u8 Status; /* see below */ | ||
74 | }; | ||
75 | |||
76 | #define US_BULK_CS_WRAP_LEN 13 | ||
77 | #define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */ | ||
78 | #define US_BULK_STAT_OK 0 | ||
79 | #define US_BULK_STAT_FAIL 1 | ||
80 | #define US_BULK_STAT_PHASE 2 | ||
81 | |||
82 | /* bulk-only class specific requests */ | ||
83 | #define US_BULK_RESET_REQUEST 0xff | ||
84 | #define US_BULK_GET_MAX_LUN 0xfe | ||
85 | |||
48 | #endif | 86 | #endif |
diff --git a/include/linux/usb/uas.h b/include/linux/usb/uas.h new file mode 100644 index 000000000000..9a988e413694 --- /dev/null +++ b/include/linux/usb/uas.h | |||
@@ -0,0 +1,69 @@ | |||
1 | #ifndef __USB_UAS_H__ | ||
2 | #define __USB_UAS_H__ | ||
3 | |||
4 | #include <scsi/scsi.h> | ||
5 | #include <scsi/scsi_cmnd.h> | ||
6 | |||
7 | /* Common header for all IUs */ | ||
8 | struct iu { | ||
9 | __u8 iu_id; | ||
10 | __u8 rsvd1; | ||
11 | __be16 tag; | ||
12 | }; | ||
13 | |||
14 | enum { | ||
15 | IU_ID_COMMAND = 0x01, | ||
16 | IU_ID_STATUS = 0x03, | ||
17 | IU_ID_RESPONSE = 0x04, | ||
18 | IU_ID_TASK_MGMT = 0x05, | ||
19 | IU_ID_READ_READY = 0x06, | ||
20 | IU_ID_WRITE_READY = 0x07, | ||
21 | }; | ||
22 | |||
23 | struct command_iu { | ||
24 | __u8 iu_id; | ||
25 | __u8 rsvd1; | ||
26 | __be16 tag; | ||
27 | __u8 prio_attr; | ||
28 | __u8 rsvd5; | ||
29 | __u8 len; | ||
30 | __u8 rsvd7; | ||
31 | struct scsi_lun lun; | ||
32 | __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */ | ||
33 | }; | ||
34 | |||
35 | /* | ||
36 | * Also used for the Read Ready and Write Ready IUs since they have the | ||
37 | * same first four bytes | ||
38 | */ | ||
39 | struct sense_iu { | ||
40 | __u8 iu_id; | ||
41 | __u8 rsvd1; | ||
42 | __be16 tag; | ||
43 | __be16 status_qual; | ||
44 | __u8 status; | ||
45 | __u8 rsvd7[7]; | ||
46 | __be16 len; | ||
47 | __u8 sense[SCSI_SENSE_BUFFERSIZE]; | ||
48 | }; | ||
49 | |||
50 | struct usb_pipe_usage_descriptor { | ||
51 | __u8 bLength; | ||
52 | __u8 bDescriptorType; | ||
53 | |||
54 | __u8 bPipeID; | ||
55 | __u8 Reserved; | ||
56 | } __attribute__((__packed__)); | ||
57 | |||
58 | enum { | ||
59 | CMD_PIPE_ID = 1, | ||
60 | STATUS_PIPE_ID = 2, | ||
61 | DATA_IN_PIPE_ID = 3, | ||
62 | DATA_OUT_PIPE_ID = 4, | ||
63 | |||
64 | UAS_SIMPLE_TAG = 0, | ||
65 | UAS_HEAD_TAG = 1, | ||
66 | UAS_ORDERED_TAG = 2, | ||
67 | UAS_ACA = 4, | ||
68 | }; | ||
69 | #endif | ||
diff --git a/include/linux/usb/ulpi.h b/include/linux/usb/ulpi.h index 9595796d62ed..6f033a415ecb 100644 --- a/include/linux/usb/ulpi.h +++ b/include/linux/usb/ulpi.h | |||
@@ -181,12 +181,12 @@ | |||
181 | 181 | ||
182 | /*-------------------------------------------------------------------------*/ | 182 | /*-------------------------------------------------------------------------*/ |
183 | 183 | ||
184 | struct otg_transceiver *otg_ulpi_create(struct otg_io_access_ops *ops, | 184 | struct usb_phy *otg_ulpi_create(struct usb_phy_io_ops *ops, |
185 | unsigned int flags); | 185 | unsigned int flags); |
186 | 186 | ||
187 | #ifdef CONFIG_USB_ULPI_VIEWPORT | 187 | #ifdef CONFIG_USB_ULPI_VIEWPORT |
188 | /* access ops for controllers with a viewport register */ | 188 | /* access ops for controllers with a viewport register */ |
189 | extern struct otg_io_access_ops ulpi_viewport_access_ops; | 189 | extern struct usb_phy_io_ops ulpi_viewport_access_ops; |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | #endif /* __LINUX_USB_ULPI_H */ | 192 | #endif /* __LINUX_USB_ULPI_H */ |
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 77273f2fdd80..b3a1c2daf6cc 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h | |||
@@ -136,6 +136,7 @@ struct scsi_device { | |||
136 | unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ | 136 | unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ |
137 | unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ | 137 | unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ |
138 | unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ | 138 | unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ |
139 | unsigned skip_vpd_pages:1; /* do not read VPD pages */ | ||
139 | unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ | 140 | unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */ |
140 | unsigned no_start_on_add:1; /* do not issue start on add */ | 141 | unsigned no_start_on_add:1; /* do not issue start on add */ |
141 | unsigned allow_restart:1; /* issue START_UNIT in error handler */ | 142 | unsigned allow_restart:1; /* issue START_UNIT in error handler */ |
@@ -246,8 +247,10 @@ struct scsi_target { | |||
246 | unsigned int single_lun:1; /* Indicates we should only | 247 | unsigned int single_lun:1; /* Indicates we should only |
247 | * allow I/O to one of the luns | 248 | * allow I/O to one of the luns |
248 | * for the device at a time. */ | 249 | * for the device at a time. */ |
249 | unsigned int pdt_1f_for_no_lun; /* PDT = 0x1f */ | 250 | unsigned int pdt_1f_for_no_lun:1; /* PDT = 0x1f |
250 | /* means no lun present */ | 251 | * means no lun present. */ |
252 | unsigned int no_report_luns:1; /* Don't use | ||
253 | * REPORT LUNS for scanning. */ | ||
251 | /* commands actually active on LLD. protected by host lock. */ | 254 | /* commands actually active on LLD. protected by host lock. */ |
252 | unsigned int target_busy; | 255 | unsigned int target_busy; |
253 | /* | 256 | /* |
diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index b9c798631699..53452c35d5e1 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * ffs-test.c.c -- user mode filesystem api for usb composite function | 2 | * ffs-test.c.c -- user mode filesystem api for usb composite function |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Samsung Electronics | 4 | * Copyright (C) 2010 Samsung Electronics |
5 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 5 | * Author: Michal Nazarewicz <mina86@mina86.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
diff --git a/tools/usb/testusb.c b/tools/usb/testusb.c index f08e89463842..6e0f56701e44 100644 --- a/tools/usb/testusb.c +++ b/tools/usb/testusb.c | |||
@@ -3,7 +3,7 @@ | |||
3 | /* | 3 | /* |
4 | * Copyright (c) 2002 by David Brownell | 4 | * Copyright (c) 2002 by David Brownell |
5 | * Copyright (c) 2010 by Samsung Electronics | 5 | * Copyright (c) 2010 by Samsung Electronics |
6 | * Author: Michal Nazarewicz <m.nazarewicz@samsung.com> | 6 | * Author: Michal Nazarewicz <mina86@mina86.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |