diff options
Diffstat (limited to 'drivers/usb/dwc3')
-rw-r--r-- | drivers/usb/dwc3/Kconfig | 32 | ||||
-rw-r--r-- | drivers/usb/dwc3/Makefile | 13 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.c | 196 | ||||
-rw-r--r-- | drivers/usb/dwc3/core.h | 53 | ||||
-rw-r--r-- | drivers/usb/dwc3/debug.h | 34 | ||||
-rw-r--r-- | drivers/usb/dwc3/debugfs.c | 34 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-exynos.c | 22 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 44 | ||||
-rw-r--r-- | drivers/usb/dwc3/dwc3-pci.c | 54 | ||||
-rw-r--r-- | drivers/usb/dwc3/ep0.c | 49 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.c | 257 | ||||
-rw-r--r-- | drivers/usb/dwc3/gadget.h | 34 | ||||
-rw-r--r-- | drivers/usb/dwc3/host.c | 34 | ||||
-rw-r--r-- | drivers/usb/dwc3/io.h | 34 | ||||
-rw-r--r-- | drivers/usb/dwc3/platform_data.h | 27 |
15 files changed, 366 insertions, 551 deletions
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 2378958ea63e..3e225d5846f6 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig | |||
@@ -40,6 +40,38 @@ config USB_DWC3_DUAL_ROLE | |||
40 | 40 | ||
41 | endchoice | 41 | endchoice |
42 | 42 | ||
43 | comment "Platform Glue Driver Support" | ||
44 | |||
45 | config USB_DWC3_OMAP | ||
46 | tristate "Texas Instruments OMAP5 and similar Platforms" | ||
47 | depends on EXTCON | ||
48 | default USB_DWC3 | ||
49 | help | ||
50 | Some platforms from Texas Instruments like OMAP5, DRA7xxx and | ||
51 | AM437x use this IP for USB2/3 functionality. | ||
52 | |||
53 | Say 'Y' or 'M' here if you have one such device | ||
54 | |||
55 | config USB_DWC3_EXYNOS | ||
56 | tristate "Samsung Exynos Platform" | ||
57 | default USB_DWC3 | ||
58 | help | ||
59 | Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, | ||
60 | say 'Y' or 'M' if you have one such device. | ||
61 | |||
62 | config USB_DWC3_PCI | ||
63 | tristate "PCIe-based Platforms" | ||
64 | depends on PCI | ||
65 | default USB_DWC3 | ||
66 | help | ||
67 | If you're using the DesignWare Core IP with a PCIe, please say | ||
68 | 'Y' or 'M' here. | ||
69 | |||
70 | One such PCIe-based platform is Synopsys' PCIe HAPS model of | ||
71 | this IP. | ||
72 | |||
73 | comment "Debugging features" | ||
74 | |||
43 | config USB_DWC3_DEBUG | 75 | config USB_DWC3_DEBUG |
44 | bool "Enable Debugging Messages" | 76 | bool "Enable Debugging Messages" |
45 | help | 77 | help |
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 0c7ac92582be..dd1760145c46 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
@@ -27,15 +27,8 @@ endif | |||
27 | # the entire driver (with all its glue layers) on several architectures | 27 | # the entire driver (with all its glue layers) on several architectures |
28 | # and make sure it compiles fine. This will also help with allmodconfig | 28 | # and make sure it compiles fine. This will also help with allmodconfig |
29 | # and allyesconfig builds. | 29 | # and allyesconfig builds. |
30 | # | ||
31 | # The only exception is the PCI glue layer, but that's only because | ||
32 | # PCI doesn't provide nops if CONFIG_PCI isn't enabled. | ||
33 | ## | 30 | ## |
34 | 31 | ||
35 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o | 32 | obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o |
36 | obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o | 33 | obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o |
37 | 34 | obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o | |
38 | ifneq ($(CONFIG_PCI),) | ||
39 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o | ||
40 | endif | ||
41 | |||
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 358375e0b291..577af1b237f2 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
@@ -6,34 +6,17 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | ||
25 | * | 17 | * |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | 18 | * You should have received a copy of the GNU General Public License |
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 20 | */ |
38 | 21 | ||
39 | #include <linux/module.h> | 22 | #include <linux/module.h> |
@@ -53,17 +36,16 @@ | |||
53 | #include <linux/usb/otg.h> | 36 | #include <linux/usb/otg.h> |
54 | #include <linux/usb/ch9.h> | 37 | #include <linux/usb/ch9.h> |
55 | #include <linux/usb/gadget.h> | 38 | #include <linux/usb/gadget.h> |
39 | #include <linux/usb/of.h> | ||
40 | #include <linux/usb/otg.h> | ||
56 | 41 | ||
42 | #include "platform_data.h" | ||
57 | #include "core.h" | 43 | #include "core.h" |
58 | #include "gadget.h" | 44 | #include "gadget.h" |
59 | #include "io.h" | 45 | #include "io.h" |
60 | 46 | ||
61 | #include "debug.h" | 47 | #include "debug.h" |
62 | 48 | ||
63 | static char *maximum_speed = "super"; | ||
64 | module_param(maximum_speed, charp, 0); | ||
65 | MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); | ||
66 | |||
67 | /* -------------------------------------------------------------------------- */ | 49 | /* -------------------------------------------------------------------------- */ |
68 | 50 | ||
69 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | 51 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) |
@@ -236,7 +218,7 @@ static int dwc3_event_buffers_setup(struct dwc3 *dwc) | |||
236 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), | 218 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), |
237 | upper_32_bits(evt->dma)); | 219 | upper_32_bits(evt->dma)); |
238 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), | 220 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), |
239 | evt->length & 0xffff); | 221 | DWC3_GEVNTSIZ_SIZE(evt->length)); |
240 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); | 222 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); |
241 | } | 223 | } |
242 | 224 | ||
@@ -255,7 +237,8 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | |||
255 | 237 | ||
256 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); | 238 | dwc3_writel(dwc->regs, DWC3_GEVNTADRLO(n), 0); |
257 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); | 239 | dwc3_writel(dwc->regs, DWC3_GEVNTADRHI(n), 0); |
258 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), 0); | 240 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(n), DWC3_GEVNTSIZ_INTMASK |
241 | | DWC3_GEVNTSIZ_SIZE(0)); | ||
259 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); | 242 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(n), 0); |
260 | } | 243 | } |
261 | } | 244 | } |
@@ -367,18 +350,17 @@ static void dwc3_core_exit(struct dwc3 *dwc) | |||
367 | 350 | ||
368 | static int dwc3_probe(struct platform_device *pdev) | 351 | static int dwc3_probe(struct platform_device *pdev) |
369 | { | 352 | { |
370 | struct device_node *node = pdev->dev.of_node; | 353 | struct device *dev = &pdev->dev; |
354 | struct dwc3_platform_data *pdata = dev_get_platdata(dev); | ||
355 | struct device_node *node = dev->of_node; | ||
371 | struct resource *res; | 356 | struct resource *res; |
372 | struct dwc3 *dwc; | 357 | struct dwc3 *dwc; |
373 | struct device *dev = &pdev->dev; | ||
374 | 358 | ||
375 | int ret = -ENOMEM; | 359 | int ret = -ENOMEM; |
376 | 360 | ||
377 | void __iomem *regs; | 361 | void __iomem *regs; |
378 | void *mem; | 362 | void *mem; |
379 | 363 | ||
380 | u8 mode; | ||
381 | |||
382 | mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); | 364 | mem = devm_kzalloc(dev, sizeof(*dwc) + DWC3_ALIGN_MASK, GFP_KERNEL); |
383 | if (!mem) { | 365 | if (!mem) { |
384 | dev_err(dev, "not enough memory\n"); | 366 | dev_err(dev, "not enough memory\n"); |
@@ -402,38 +384,32 @@ static int dwc3_probe(struct platform_device *pdev) | |||
402 | dev_err(dev, "missing memory resource\n"); | 384 | dev_err(dev, "missing memory resource\n"); |
403 | return -ENODEV; | 385 | return -ENODEV; |
404 | } | 386 | } |
405 | dwc->xhci_resources[0].start = res->start; | ||
406 | dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + | ||
407 | DWC3_XHCI_REGS_END; | ||
408 | dwc->xhci_resources[0].flags = res->flags; | ||
409 | dwc->xhci_resources[0].name = res->name; | ||
410 | |||
411 | /* | ||
412 | * Request memory region but exclude xHCI regs, | ||
413 | * since it will be requested by the xhci-plat driver. | ||
414 | */ | ||
415 | res = devm_request_mem_region(dev, res->start + DWC3_GLOBALS_REGS_START, | ||
416 | resource_size(res) - DWC3_GLOBALS_REGS_START, | ||
417 | dev_name(dev)); | ||
418 | if (!res) { | ||
419 | dev_err(dev, "can't request mem region\n"); | ||
420 | return -ENOMEM; | ||
421 | } | ||
422 | |||
423 | regs = devm_ioremap_nocache(dev, res->start, resource_size(res)); | ||
424 | if (!regs) { | ||
425 | dev_err(dev, "ioremap failed\n"); | ||
426 | return -ENOMEM; | ||
427 | } | ||
428 | 387 | ||
429 | if (node) { | 388 | if (node) { |
389 | dwc->maximum_speed = of_usb_get_maximum_speed(node); | ||
390 | |||
430 | dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); | 391 | dwc->usb2_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0); |
431 | dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); | 392 | dwc->usb3_phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 1); |
393 | |||
394 | dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); | ||
395 | dwc->dr_mode = of_usb_get_dr_mode(node); | ||
396 | } else if (pdata) { | ||
397 | dwc->maximum_speed = pdata->maximum_speed; | ||
398 | |||
399 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); | ||
400 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); | ||
401 | |||
402 | dwc->needs_fifo_resize = pdata->tx_fifo_resize; | ||
403 | dwc->dr_mode = pdata->dr_mode; | ||
432 | } else { | 404 | } else { |
433 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); | 405 | dwc->usb2_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); |
434 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); | 406 | dwc->usb3_phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB3); |
435 | } | 407 | } |
436 | 408 | ||
409 | /* default to superspeed if no maximum_speed passed */ | ||
410 | if (dwc->maximum_speed == USB_SPEED_UNKNOWN) | ||
411 | dwc->maximum_speed = USB_SPEED_SUPER; | ||
412 | |||
437 | if (IS_ERR(dwc->usb2_phy)) { | 413 | if (IS_ERR(dwc->usb2_phy)) { |
438 | ret = PTR_ERR(dwc->usb2_phy); | 414 | ret = PTR_ERR(dwc->usb2_phy); |
439 | 415 | ||
@@ -464,6 +440,22 @@ static int dwc3_probe(struct platform_device *pdev) | |||
464 | return -EPROBE_DEFER; | 440 | return -EPROBE_DEFER; |
465 | } | 441 | } |
466 | 442 | ||
443 | dwc->xhci_resources[0].start = res->start; | ||
444 | dwc->xhci_resources[0].end = dwc->xhci_resources[0].start + | ||
445 | DWC3_XHCI_REGS_END; | ||
446 | dwc->xhci_resources[0].flags = res->flags; | ||
447 | dwc->xhci_resources[0].name = res->name; | ||
448 | |||
449 | res->start += DWC3_GLOBALS_REGS_START; | ||
450 | |||
451 | /* | ||
452 | * Request memory region but exclude xHCI regs, | ||
453 | * since it will be requested by the xhci-plat driver. | ||
454 | */ | ||
455 | regs = devm_ioremap_resource(dev, res); | ||
456 | if (IS_ERR(regs)) | ||
457 | return PTR_ERR(regs); | ||
458 | |||
467 | usb_phy_set_suspend(dwc->usb2_phy, 0); | 459 | usb_phy_set_suspend(dwc->usb2_phy, 0); |
468 | usb_phy_set_suspend(dwc->usb3_phy, 0); | 460 | usb_phy_set_suspend(dwc->usb3_phy, 0); |
469 | 461 | ||
@@ -478,19 +470,6 @@ static int dwc3_probe(struct platform_device *pdev) | |||
478 | dev->dma_parms = dev->parent->dma_parms; | 470 | dev->dma_parms = dev->parent->dma_parms; |
479 | dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); | 471 | dma_set_coherent_mask(dev, dev->parent->coherent_dma_mask); |
480 | 472 | ||
481 | if (!strncmp("super", maximum_speed, 5)) | ||
482 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | ||
483 | else if (!strncmp("high", maximum_speed, 4)) | ||
484 | dwc->maximum_speed = DWC3_DCFG_HIGHSPEED; | ||
485 | else if (!strncmp("full", maximum_speed, 4)) | ||
486 | dwc->maximum_speed = DWC3_DCFG_FULLSPEED1; | ||
487 | else if (!strncmp("low", maximum_speed, 3)) | ||
488 | dwc->maximum_speed = DWC3_DCFG_LOWSPEED; | ||
489 | else | ||
490 | dwc->maximum_speed = DWC3_DCFG_SUPERSPEED; | ||
491 | |||
492 | dwc->needs_fifo_resize = of_property_read_bool(node, "tx-fifo-resize"); | ||
493 | |||
494 | pm_runtime_enable(dev); | 473 | pm_runtime_enable(dev); |
495 | pm_runtime_get_sync(dev); | 474 | pm_runtime_get_sync(dev); |
496 | pm_runtime_forbid(dev); | 475 | pm_runtime_forbid(dev); |
@@ -517,14 +496,15 @@ static int dwc3_probe(struct platform_device *pdev) | |||
517 | } | 496 | } |
518 | 497 | ||
519 | if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) | 498 | if (IS_ENABLED(CONFIG_USB_DWC3_HOST)) |
520 | mode = DWC3_MODE_HOST; | 499 | dwc->dr_mode = USB_DR_MODE_HOST; |
521 | else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) | 500 | else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) |
522 | mode = DWC3_MODE_DEVICE; | 501 | dwc->dr_mode = USB_DR_MODE_PERIPHERAL; |
523 | else | 502 | |
524 | mode = DWC3_MODE_DRD; | 503 | if (dwc->dr_mode == USB_DR_MODE_UNKNOWN) |
504 | dwc->dr_mode = USB_DR_MODE_OTG; | ||
525 | 505 | ||
526 | switch (mode) { | 506 | switch (dwc->dr_mode) { |
527 | case DWC3_MODE_DEVICE: | 507 | case USB_DR_MODE_PERIPHERAL: |
528 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); | 508 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); |
529 | ret = dwc3_gadget_init(dwc); | 509 | ret = dwc3_gadget_init(dwc); |
530 | if (ret) { | 510 | if (ret) { |
@@ -532,7 +512,7 @@ static int dwc3_probe(struct platform_device *pdev) | |||
532 | goto err2; | 512 | goto err2; |
533 | } | 513 | } |
534 | break; | 514 | break; |
535 | case DWC3_MODE_HOST: | 515 | case USB_DR_MODE_HOST: |
536 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); | 516 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST); |
537 | ret = dwc3_host_init(dwc); | 517 | ret = dwc3_host_init(dwc); |
538 | if (ret) { | 518 | if (ret) { |
@@ -540,7 +520,7 @@ static int dwc3_probe(struct platform_device *pdev) | |||
540 | goto err2; | 520 | goto err2; |
541 | } | 521 | } |
542 | break; | 522 | break; |
543 | case DWC3_MODE_DRD: | 523 | case USB_DR_MODE_OTG: |
544 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); | 524 | dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); |
545 | ret = dwc3_host_init(dwc); | 525 | ret = dwc3_host_init(dwc); |
546 | if (ret) { | 526 | if (ret) { |
@@ -555,10 +535,9 @@ static int dwc3_probe(struct platform_device *pdev) | |||
555 | } | 535 | } |
556 | break; | 536 | break; |
557 | default: | 537 | default: |
558 | dev_err(dev, "Unsupported mode of operation %d\n", mode); | 538 | dev_err(dev, "Unsupported mode of operation %d\n", dwc->dr_mode); |
559 | goto err2; | 539 | goto err2; |
560 | } | 540 | } |
561 | dwc->mode = mode; | ||
562 | 541 | ||
563 | ret = dwc3_debugfs_init(dwc); | 542 | ret = dwc3_debugfs_init(dwc); |
564 | if (ret) { | 543 | if (ret) { |
@@ -571,14 +550,14 @@ static int dwc3_probe(struct platform_device *pdev) | |||
571 | return 0; | 550 | return 0; |
572 | 551 | ||
573 | err3: | 552 | err3: |
574 | switch (mode) { | 553 | switch (dwc->dr_mode) { |
575 | case DWC3_MODE_DEVICE: | 554 | case USB_DR_MODE_PERIPHERAL: |
576 | dwc3_gadget_exit(dwc); | 555 | dwc3_gadget_exit(dwc); |
577 | break; | 556 | break; |
578 | case DWC3_MODE_HOST: | 557 | case USB_DR_MODE_HOST: |
579 | dwc3_host_exit(dwc); | 558 | dwc3_host_exit(dwc); |
580 | break; | 559 | break; |
581 | case DWC3_MODE_DRD: | 560 | case USB_DR_MODE_OTG: |
582 | dwc3_host_exit(dwc); | 561 | dwc3_host_exit(dwc); |
583 | dwc3_gadget_exit(dwc); | 562 | dwc3_gadget_exit(dwc); |
584 | break; | 563 | break; |
@@ -611,14 +590,14 @@ static int dwc3_remove(struct platform_device *pdev) | |||
611 | 590 | ||
612 | dwc3_debugfs_exit(dwc); | 591 | dwc3_debugfs_exit(dwc); |
613 | 592 | ||
614 | switch (dwc->mode) { | 593 | switch (dwc->dr_mode) { |
615 | case DWC3_MODE_DEVICE: | 594 | case USB_DR_MODE_PERIPHERAL: |
616 | dwc3_gadget_exit(dwc); | 595 | dwc3_gadget_exit(dwc); |
617 | break; | 596 | break; |
618 | case DWC3_MODE_HOST: | 597 | case USB_DR_MODE_HOST: |
619 | dwc3_host_exit(dwc); | 598 | dwc3_host_exit(dwc); |
620 | break; | 599 | break; |
621 | case DWC3_MODE_DRD: | 600 | case USB_DR_MODE_OTG: |
622 | dwc3_host_exit(dwc); | 601 | dwc3_host_exit(dwc); |
623 | dwc3_gadget_exit(dwc); | 602 | dwc3_gadget_exit(dwc); |
624 | break; | 603 | break; |
@@ -642,12 +621,12 @@ static int dwc3_prepare(struct device *dev) | |||
642 | 621 | ||
643 | spin_lock_irqsave(&dwc->lock, flags); | 622 | spin_lock_irqsave(&dwc->lock, flags); |
644 | 623 | ||
645 | switch (dwc->mode) { | 624 | switch (dwc->dr_mode) { |
646 | case DWC3_MODE_DEVICE: | 625 | case USB_DR_MODE_PERIPHERAL: |
647 | case DWC3_MODE_DRD: | 626 | case USB_DR_MODE_OTG: |
648 | dwc3_gadget_prepare(dwc); | 627 | dwc3_gadget_prepare(dwc); |
649 | /* FALLTHROUGH */ | 628 | /* FALLTHROUGH */ |
650 | case DWC3_MODE_HOST: | 629 | case USB_DR_MODE_HOST: |
651 | default: | 630 | default: |
652 | dwc3_event_buffers_cleanup(dwc); | 631 | dwc3_event_buffers_cleanup(dwc); |
653 | break; | 632 | break; |
@@ -665,12 +644,12 @@ static void dwc3_complete(struct device *dev) | |||
665 | 644 | ||
666 | spin_lock_irqsave(&dwc->lock, flags); | 645 | spin_lock_irqsave(&dwc->lock, flags); |
667 | 646 | ||
668 | switch (dwc->mode) { | 647 | switch (dwc->dr_mode) { |
669 | case DWC3_MODE_DEVICE: | 648 | case USB_DR_MODE_PERIPHERAL: |
670 | case DWC3_MODE_DRD: | 649 | case USB_DR_MODE_OTG: |
671 | dwc3_gadget_complete(dwc); | 650 | dwc3_gadget_complete(dwc); |
672 | /* FALLTHROUGH */ | 651 | /* FALLTHROUGH */ |
673 | case DWC3_MODE_HOST: | 652 | case USB_DR_MODE_HOST: |
674 | default: | 653 | default: |
675 | dwc3_event_buffers_setup(dwc); | 654 | dwc3_event_buffers_setup(dwc); |
676 | break; | 655 | break; |
@@ -686,12 +665,12 @@ static int dwc3_suspend(struct device *dev) | |||
686 | 665 | ||
687 | spin_lock_irqsave(&dwc->lock, flags); | 666 | spin_lock_irqsave(&dwc->lock, flags); |
688 | 667 | ||
689 | switch (dwc->mode) { | 668 | switch (dwc->dr_mode) { |
690 | case DWC3_MODE_DEVICE: | 669 | case USB_DR_MODE_PERIPHERAL: |
691 | case DWC3_MODE_DRD: | 670 | case USB_DR_MODE_OTG: |
692 | dwc3_gadget_suspend(dwc); | 671 | dwc3_gadget_suspend(dwc); |
693 | /* FALLTHROUGH */ | 672 | /* FALLTHROUGH */ |
694 | case DWC3_MODE_HOST: | 673 | case USB_DR_MODE_HOST: |
695 | default: | 674 | default: |
696 | /* do nothing */ | 675 | /* do nothing */ |
697 | break; | 676 | break; |
@@ -719,12 +698,12 @@ static int dwc3_resume(struct device *dev) | |||
719 | 698 | ||
720 | dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); | 699 | dwc3_writel(dwc->regs, DWC3_GCTL, dwc->gctl); |
721 | 700 | ||
722 | switch (dwc->mode) { | 701 | switch (dwc->dr_mode) { |
723 | case DWC3_MODE_DEVICE: | 702 | case USB_DR_MODE_PERIPHERAL: |
724 | case DWC3_MODE_DRD: | 703 | case USB_DR_MODE_OTG: |
725 | dwc3_gadget_resume(dwc); | 704 | dwc3_gadget_resume(dwc); |
726 | /* FALLTHROUGH */ | 705 | /* FALLTHROUGH */ |
727 | case DWC3_MODE_HOST: | 706 | case USB_DR_MODE_HOST: |
728 | default: | 707 | default: |
729 | /* do nothing */ | 708 | /* do nothing */ |
730 | break; | 709 | break; |
@@ -754,6 +733,9 @@ static const struct dev_pm_ops dwc3_dev_pm_ops = { | |||
754 | #ifdef CONFIG_OF | 733 | #ifdef CONFIG_OF |
755 | static const struct of_device_id of_dwc3_match[] = { | 734 | static const struct of_device_id of_dwc3_match[] = { |
756 | { | 735 | { |
736 | .compatible = "snps,dwc3" | ||
737 | }, | ||
738 | { | ||
757 | .compatible = "synopsys,dwc3" | 739 | .compatible = "synopsys,dwc3" |
758 | }, | 740 | }, |
759 | { }, | 741 | { }, |
@@ -775,5 +757,5 @@ module_platform_driver(dwc3_driver); | |||
775 | 757 | ||
776 | MODULE_ALIAS("platform:dwc3"); | 758 | MODULE_ALIAS("platform:dwc3"); |
777 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 759 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
778 | MODULE_LICENSE("Dual BSD/GPL"); | 760 | MODULE_LICENSE("GPL v2"); |
779 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); | 761 | MODULE_DESCRIPTION("DesignWare USB3 DRD Controller Driver"); |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 27dad993b007..f8af8d44af85 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #ifndef __DRIVERS_USB_DWC3_CORE_H | 19 | #ifndef __DRIVERS_USB_DWC3_CORE_H |
@@ -49,6 +29,7 @@ | |||
49 | 29 | ||
50 | #include <linux/usb/ch9.h> | 30 | #include <linux/usb/ch9.h> |
51 | #include <linux/usb/gadget.h> | 31 | #include <linux/usb/gadget.h> |
32 | #include <linux/usb/otg.h> | ||
52 | 33 | ||
53 | /* Global constants */ | 34 | /* Global constants */ |
54 | #define DWC3_EP0_BOUNCE_SIZE 512 | 35 | #define DWC3_EP0_BOUNCE_SIZE 512 |
@@ -194,6 +175,10 @@ | |||
194 | #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff) | 175 | #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff) |
195 | #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000) | 176 | #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000) |
196 | 177 | ||
178 | /* Global Event Size Registers */ | ||
179 | #define DWC3_GEVNTSIZ_INTMASK (1 << 31) | ||
180 | #define DWC3_GEVNTSIZ_SIZE(n) ((n) & 0xffff) | ||
181 | |||
197 | /* Global HWPARAMS1 Register */ | 182 | /* Global HWPARAMS1 Register */ |
198 | #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24) | 183 | #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24) |
199 | #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0 | 184 | #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0 |
@@ -207,7 +192,6 @@ | |||
207 | #define DWC3_MAX_HIBER_SCRATCHBUFS 15 | 192 | #define DWC3_MAX_HIBER_SCRATCHBUFS 15 |
208 | 193 | ||
209 | /* Device Configuration Register */ | 194 | /* Device Configuration Register */ |
210 | #define DWC3_DCFG_LPM_CAP (1 << 22) | ||
211 | #define DWC3_DCFG_DEVADDR(addr) ((addr) << 3) | 195 | #define DWC3_DCFG_DEVADDR(addr) ((addr) << 3) |
212 | #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f) | 196 | #define DWC3_DCFG_DEVADDR_MASK DWC3_DCFG_DEVADDR(0x7f) |
213 | 197 | ||
@@ -367,7 +351,6 @@ struct dwc3_trb; | |||
367 | 351 | ||
368 | /** | 352 | /** |
369 | * struct dwc3_event_buffer - Software event buffer representation | 353 | * struct dwc3_event_buffer - Software event buffer representation |
370 | * @list: a list of event buffers | ||
371 | * @buf: _THE_ buffer | 354 | * @buf: _THE_ buffer |
372 | * @length: size of this buffer | 355 | * @length: size of this buffer |
373 | * @lpos: event offset | 356 | * @lpos: event offset |
@@ -415,7 +398,7 @@ struct dwc3_event_buffer { | |||
415 | * @number: endpoint number (1 - 15) | 398 | * @number: endpoint number (1 - 15) |
416 | * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK | 399 | * @type: set to bmAttributes & USB_ENDPOINT_XFERTYPE_MASK |
417 | * @resource_index: Resource transfer index | 400 | * @resource_index: Resource transfer index |
418 | * @interval: the intervall on which the ISOC transfer is started | 401 | * @interval: the interval on which the ISOC transfer is started |
419 | * @name: a human readable name e.g. ep1out-bulk | 402 | * @name: a human readable name e.g. ep1out-bulk |
420 | * @direction: true for TX, false for RX | 403 | * @direction: true for TX, false for RX |
421 | * @stream_capable: true when streams are enabled | 404 | * @stream_capable: true when streams are enabled |
@@ -566,11 +549,6 @@ struct dwc3_hwparams { | |||
566 | /* HWPARAMS0 */ | 549 | /* HWPARAMS0 */ |
567 | #define DWC3_MODE(n) ((n) & 0x7) | 550 | #define DWC3_MODE(n) ((n) & 0x7) |
568 | 551 | ||
569 | #define DWC3_MODE_DEVICE 0 | ||
570 | #define DWC3_MODE_HOST 1 | ||
571 | #define DWC3_MODE_DRD 2 | ||
572 | #define DWC3_MODE_HUB 3 | ||
573 | |||
574 | #define DWC3_MDWIDTH(n) (((n) & 0xff00) >> 8) | 552 | #define DWC3_MDWIDTH(n) (((n) & 0xff00) >> 8) |
575 | 553 | ||
576 | /* HWPARAMS1 */ | 554 | /* HWPARAMS1 */ |
@@ -632,7 +610,7 @@ struct dwc3_scratchpad_array { | |||
632 | * @u1u2: only used on revisions <1.83a for workaround | 610 | * @u1u2: only used on revisions <1.83a for workaround |
633 | * @maximum_speed: maximum speed requested (mainly for testing purposes) | 611 | * @maximum_speed: maximum speed requested (mainly for testing purposes) |
634 | * @revision: revision register contents | 612 | * @revision: revision register contents |
635 | * @mode: mode of operation | 613 | * @dr_mode: requested mode of operation |
636 | * @usb2_phy: pointer to USB2 PHY | 614 | * @usb2_phy: pointer to USB2 PHY |
637 | * @usb3_phy: pointer to USB3 PHY | 615 | * @usb3_phy: pointer to USB3 PHY |
638 | * @dcfg: saved contents of DCFG register | 616 | * @dcfg: saved contents of DCFG register |
@@ -690,6 +668,8 @@ struct dwc3 { | |||
690 | void __iomem *regs; | 668 | void __iomem *regs; |
691 | size_t regs_size; | 669 | size_t regs_size; |
692 | 670 | ||
671 | enum usb_dr_mode dr_mode; | ||
672 | |||
693 | /* used for suspend/resume */ | 673 | /* used for suspend/resume */ |
694 | u32 dcfg; | 674 | u32 dcfg; |
695 | u32 gctl; | 675 | u32 gctl; |
@@ -698,7 +678,6 @@ struct dwc3 { | |||
698 | u32 u1u2; | 678 | u32 u1u2; |
699 | u32 maximum_speed; | 679 | u32 maximum_speed; |
700 | u32 revision; | 680 | u32 revision; |
701 | u32 mode; | ||
702 | 681 | ||
703 | #define DWC3_REVISION_173A 0x5533173a | 682 | #define DWC3_REVISION_173A 0x5533173a |
704 | #define DWC3_REVISION_175A 0x5533175a | 683 | #define DWC3_REVISION_175A 0x5533175a |
diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h index 5894ee8222af..fceb39dc4bba 100644 --- a/drivers/usb/dwc3/debug.h +++ b/drivers/usb/dwc3/debug.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include "core.h" | 19 | #include "core.h" |
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index 9e9f122162f2..9ac37fe1b6a7 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index 8ce9d7fd6cfc..2f2e88a3a11a 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
@@ -6,10 +6,14 @@ | |||
6 | * | 6 | * |
7 | * Author: Anton Tikhomirov <av.tikhomirov@samsung.com> | 7 | * Author: Anton Tikhomirov <av.tikhomirov@samsung.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 version 2 of |
11 | * the Free Software Foundation; either version 2 of the License, or | 11 | * the License as published by the Free Software Foundation. |
12 | * (at your option) any later version. | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
13 | */ | 17 | */ |
14 | 18 | ||
15 | #include <linux/module.h> | 19 | #include <linux/module.h> |
@@ -20,7 +24,7 @@ | |||
20 | #include <linux/dma-mapping.h> | 24 | #include <linux/dma-mapping.h> |
21 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
22 | #include <linux/usb/otg.h> | 26 | #include <linux/usb/otg.h> |
23 | #include <linux/usb/nop-usb-xceiv.h> | 27 | #include <linux/usb/usb_phy_gen_xceiv.h> |
24 | #include <linux/of.h> | 28 | #include <linux/of.h> |
25 | #include <linux/of_platform.h> | 29 | #include <linux/of_platform.h> |
26 | 30 | ||
@@ -34,13 +38,13 @@ struct dwc3_exynos { | |||
34 | 38 | ||
35 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | 39 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) |
36 | { | 40 | { |
37 | struct nop_usb_xceiv_platform_data pdata; | 41 | struct usb_phy_gen_xceiv_platform_data pdata; |
38 | struct platform_device *pdev; | 42 | struct platform_device *pdev; |
39 | int ret; | 43 | int ret; |
40 | 44 | ||
41 | memset(&pdata, 0x00, sizeof(pdata)); | 45 | memset(&pdata, 0x00, sizeof(pdata)); |
42 | 46 | ||
43 | pdev = platform_device_alloc("nop_usb_xceiv", PLATFORM_DEVID_AUTO); | 47 | pdev = platform_device_alloc("usb_phy_gen_xceiv", PLATFORM_DEVID_AUTO); |
44 | if (!pdev) | 48 | if (!pdev) |
45 | return -ENOMEM; | 49 | return -ENOMEM; |
46 | 50 | ||
@@ -51,7 +55,7 @@ static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | |||
51 | if (ret) | 55 | if (ret) |
52 | goto err1; | 56 | goto err1; |
53 | 57 | ||
54 | pdev = platform_device_alloc("nop_usb_xceiv", PLATFORM_DEVID_AUTO); | 58 | pdev = platform_device_alloc("usb_phy_gen_xceiv", PLATFORM_DEVID_AUTO); |
55 | if (!pdev) { | 59 | if (!pdev) { |
56 | ret = -ENOMEM; | 60 | ret = -ENOMEM; |
57 | goto err1; | 61 | goto err1; |
@@ -228,5 +232,5 @@ module_platform_driver(dwc3_exynos_driver); | |||
228 | 232 | ||
229 | MODULE_ALIAS("platform:exynos-dwc3"); | 233 | MODULE_ALIAS("platform:exynos-dwc3"); |
230 | MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>"); | 234 | MODULE_AUTHOR("Anton Tikhomirov <av.tikhomirov@samsung.com>"); |
231 | MODULE_LICENSE("GPL"); | 235 | MODULE_LICENSE("GPL v2"); |
232 | MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer"); | 236 | MODULE_DESCRIPTION("DesignWare USB3 EXYNOS Glue Layer"); |
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 077f110bd746..ecd99451ee90 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/module.h> | 19 | #include <linux/module.h> |
@@ -409,11 +389,9 @@ static int dwc3_omap_probe(struct platform_device *pdev) | |||
409 | return -EINVAL; | 389 | return -EINVAL; |
410 | } | 390 | } |
411 | 391 | ||
412 | base = devm_ioremap_nocache(dev, res->start, resource_size(res)); | 392 | base = devm_ioremap_resource(dev, res); |
413 | if (!base) { | 393 | if (IS_ERR(base)) |
414 | dev_err(dev, "ioremap failed\n"); | 394 | return PTR_ERR(base); |
415 | return -ENOMEM; | ||
416 | } | ||
417 | 395 | ||
418 | spin_lock_init(&omap->lock); | 396 | spin_lock_init(&omap->lock); |
419 | 397 | ||
@@ -610,5 +588,5 @@ module_platform_driver(dwc3_omap_driver); | |||
610 | 588 | ||
611 | MODULE_ALIAS("platform:omap-dwc3"); | 589 | MODULE_ALIAS("platform:omap-dwc3"); |
612 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 590 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
613 | MODULE_LICENSE("Dual BSD/GPL"); | 591 | MODULE_LICENSE("GPL v2"); |
614 | MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer"); | 592 | MODULE_DESCRIPTION("DesignWare USB3 OMAP Glue Layer"); |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index ed07ec04a962..9b138129e856 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -43,7 +23,7 @@ | |||
43 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
44 | 24 | ||
45 | #include <linux/usb/otg.h> | 25 | #include <linux/usb/otg.h> |
46 | #include <linux/usb/nop-usb-xceiv.h> | 26 | #include <linux/usb/usb_phy_gen_xceiv.h> |
47 | 27 | ||
48 | /* FIXME define these in <linux/pci_ids.h> */ | 28 | /* FIXME define these in <linux/pci_ids.h> */ |
49 | #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 | 29 | #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 |
@@ -58,13 +38,13 @@ struct dwc3_pci { | |||
58 | 38 | ||
59 | static int dwc3_pci_register_phys(struct dwc3_pci *glue) | 39 | static int dwc3_pci_register_phys(struct dwc3_pci *glue) |
60 | { | 40 | { |
61 | struct nop_usb_xceiv_platform_data pdata; | 41 | struct usb_phy_gen_xceiv_platform_data pdata; |
62 | struct platform_device *pdev; | 42 | struct platform_device *pdev; |
63 | int ret; | 43 | int ret; |
64 | 44 | ||
65 | memset(&pdata, 0x00, sizeof(pdata)); | 45 | memset(&pdata, 0x00, sizeof(pdata)); |
66 | 46 | ||
67 | pdev = platform_device_alloc("nop_usb_xceiv", 0); | 47 | pdev = platform_device_alloc("usb_phy_gen_xceiv", 0); |
68 | if (!pdev) | 48 | if (!pdev) |
69 | return -ENOMEM; | 49 | return -ENOMEM; |
70 | 50 | ||
@@ -75,7 +55,7 @@ static int dwc3_pci_register_phys(struct dwc3_pci *glue) | |||
75 | if (ret) | 55 | if (ret) |
76 | goto err1; | 56 | goto err1; |
77 | 57 | ||
78 | pdev = platform_device_alloc("nop_usb_xceiv", 1); | 58 | pdev = platform_device_alloc("usb_phy_gen_xceiv", 1); |
79 | if (!pdev) { | 59 | if (!pdev) { |
80 | ret = -ENOMEM; | 60 | ret = -ENOMEM; |
81 | goto err1; | 61 | goto err1; |
@@ -211,7 +191,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { | |||
211 | }; | 191 | }; |
212 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); | 192 | MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); |
213 | 193 | ||
214 | #ifdef CONFIG_PM | 194 | #ifdef CONFIG_PM_SLEEP |
215 | static int dwc3_pci_suspend(struct device *dev) | 195 | static int dwc3_pci_suspend(struct device *dev) |
216 | { | 196 | { |
217 | struct pci_dev *pci = to_pci_dev(dev); | 197 | struct pci_dev *pci = to_pci_dev(dev); |
@@ -236,28 +216,24 @@ static int dwc3_pci_resume(struct device *dev) | |||
236 | 216 | ||
237 | return 0; | 217 | return 0; |
238 | } | 218 | } |
219 | #endif /* CONFIG_PM_SLEEP */ | ||
239 | 220 | ||
240 | static const struct dev_pm_ops dwc3_pci_dev_pm_ops = { | 221 | static const struct dev_pm_ops dwc3_pci_dev_pm_ops = { |
241 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume) | 222 | SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_suspend, dwc3_pci_resume) |
242 | }; | 223 | }; |
243 | 224 | ||
244 | #define DEV_PM_OPS (&dwc3_pci_dev_pm_ops) | ||
245 | #else | ||
246 | #define DEV_PM_OPS NULL | ||
247 | #endif /* CONFIG_PM */ | ||
248 | |||
249 | static struct pci_driver dwc3_pci_driver = { | 225 | static struct pci_driver dwc3_pci_driver = { |
250 | .name = "dwc3-pci", | 226 | .name = "dwc3-pci", |
251 | .id_table = dwc3_pci_id_table, | 227 | .id_table = dwc3_pci_id_table, |
252 | .probe = dwc3_pci_probe, | 228 | .probe = dwc3_pci_probe, |
253 | .remove = dwc3_pci_remove, | 229 | .remove = dwc3_pci_remove, |
254 | .driver = { | 230 | .driver = { |
255 | .pm = DEV_PM_OPS, | 231 | .pm = &dwc3_pci_dev_pm_ops, |
256 | }, | 232 | }, |
257 | }; | 233 | }; |
258 | 234 | ||
259 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 235 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
260 | MODULE_LICENSE("Dual BSD/GPL"); | 236 | MODULE_LICENSE("GPL v2"); |
261 | MODULE_DESCRIPTION("DesignWare USB3 PCI Glue Layer"); | 237 | MODULE_DESCRIPTION("DesignWare USB3 PCI Glue Layer"); |
262 | 238 | ||
263 | module_pci_driver(dwc3_pci_driver); | 239 | module_pci_driver(dwc3_pci_driver); |
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c index 5acbb948b704..7fa93f4bc507 100644 --- a/drivers/usb/dwc3/ep0.c +++ b/drivers/usb/dwc3/ep0.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -168,6 +148,7 @@ static int __dwc3_gadget_ep0_queue(struct dwc3_ep *dep, | |||
168 | 148 | ||
169 | direction = !dwc->ep0_expect_in; | 149 | direction = !dwc->ep0_expect_in; |
170 | dwc->delayed_status = false; | 150 | dwc->delayed_status = false; |
151 | usb_gadget_set_state(&dwc->gadget, USB_STATE_CONFIGURED); | ||
171 | 152 | ||
172 | if (dwc->ep0state == EP0_STATUS_PHASE) | 153 | if (dwc->ep0state == EP0_STATUS_PHASE) |
173 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); | 154 | __dwc3_ep0_do_control_status(dwc, dwc->eps[direction]); |
@@ -553,8 +534,16 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
553 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 534 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
554 | /* if the cfg matches and the cfg is non zero */ | 535 | /* if the cfg matches and the cfg is non zero */ |
555 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { | 536 | if (cfg && (!ret || (ret == USB_GADGET_DELAYED_STATUS))) { |
556 | usb_gadget_set_state(&dwc->gadget, | 537 | |
557 | USB_STATE_CONFIGURED); | 538 | /* |
539 | * only change state if set_config has already | ||
540 | * been processed. If gadget driver returns | ||
541 | * USB_GADGET_DELAYED_STATUS, we will wait | ||
542 | * to change the state on the next usb_ep_queue() | ||
543 | */ | ||
544 | if (ret == 0) | ||
545 | usb_gadget_set_state(&dwc->gadget, | ||
546 | USB_STATE_CONFIGURED); | ||
558 | 547 | ||
559 | /* | 548 | /* |
560 | * Enable transition to U1/U2 state when | 549 | * Enable transition to U1/U2 state when |
@@ -571,7 +560,7 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl) | |||
571 | 560 | ||
572 | case USB_STATE_CONFIGURED: | 561 | case USB_STATE_CONFIGURED: |
573 | ret = dwc3_ep0_delegate_req(dwc, ctrl); | 562 | ret = dwc3_ep0_delegate_req(dwc, ctrl); |
574 | if (!cfg) | 563 | if (!cfg && !ret) |
575 | usb_gadget_set_state(&dwc->gadget, | 564 | usb_gadget_set_state(&dwc->gadget, |
576 | USB_STATE_ADDRESS); | 565 | USB_STATE_ADDRESS); |
577 | break; | 566 | break; |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index f77083fedc68..f168eaebdef8 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
@@ -520,6 +500,8 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, | |||
520 | u32 reg; | 500 | u32 reg; |
521 | int ret = -ENOMEM; | 501 | int ret = -ENOMEM; |
522 | 502 | ||
503 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); | ||
504 | |||
523 | if (!(dep->flags & DWC3_EP_ENABLED)) { | 505 | if (!(dep->flags & DWC3_EP_ENABLED)) { |
524 | ret = dwc3_gadget_start_config(dwc, dep); | 506 | ret = dwc3_gadget_start_config(dwc, dep); |
525 | if (ret) | 507 | if (ret) |
@@ -676,8 +658,6 @@ static int dwc3_gadget_ep_enable(struct usb_ep *ep, | |||
676 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); | 658 | dev_err(dwc->dev, "invalid endpoint transfer type\n"); |
677 | } | 659 | } |
678 | 660 | ||
679 | dev_vdbg(dwc->dev, "Enabling %s\n", dep->name); | ||
680 | |||
681 | spin_lock_irqsave(&dwc->lock, flags); | 661 | spin_lock_irqsave(&dwc->lock, flags); |
682 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false); | 662 | ret = __dwc3_gadget_ep_enable(dep, desc, ep->comp_desc, false); |
683 | spin_unlock_irqrestore(&dwc->lock, flags); | 663 | spin_unlock_irqrestore(&dwc->lock, flags); |
@@ -1508,6 +1488,15 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1508 | int irq; | 1488 | int irq; |
1509 | u32 reg; | 1489 | u32 reg; |
1510 | 1490 | ||
1491 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1492 | ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt, | ||
1493 | IRQF_SHARED, "dwc3", dwc); | ||
1494 | if (ret) { | ||
1495 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", | ||
1496 | irq, ret); | ||
1497 | goto err0; | ||
1498 | } | ||
1499 | |||
1511 | spin_lock_irqsave(&dwc->lock, flags); | 1500 | spin_lock_irqsave(&dwc->lock, flags); |
1512 | 1501 | ||
1513 | if (dwc->gadget_driver) { | 1502 | if (dwc->gadget_driver) { |
@@ -1515,7 +1504,7 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1515 | dwc->gadget.name, | 1504 | dwc->gadget.name, |
1516 | dwc->gadget_driver->driver.name); | 1505 | dwc->gadget_driver->driver.name); |
1517 | ret = -EBUSY; | 1506 | ret = -EBUSY; |
1518 | goto err0; | 1507 | goto err1; |
1519 | } | 1508 | } |
1520 | 1509 | ||
1521 | dwc->gadget_driver = driver; | 1510 | dwc->gadget_driver = driver; |
@@ -1536,10 +1525,25 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1536 | * STAR#9000525659: Clock Domain Crossing on DCTL in | 1525 | * STAR#9000525659: Clock Domain Crossing on DCTL in |
1537 | * USB 2.0 Mode | 1526 | * USB 2.0 Mode |
1538 | */ | 1527 | */ |
1539 | if (dwc->revision < DWC3_REVISION_220A) | 1528 | if (dwc->revision < DWC3_REVISION_220A) { |
1540 | reg |= DWC3_DCFG_SUPERSPEED; | 1529 | reg |= DWC3_DCFG_SUPERSPEED; |
1541 | else | 1530 | } else { |
1542 | reg |= dwc->maximum_speed; | 1531 | switch (dwc->maximum_speed) { |
1532 | case USB_SPEED_LOW: | ||
1533 | reg |= DWC3_DSTS_LOWSPEED; | ||
1534 | break; | ||
1535 | case USB_SPEED_FULL: | ||
1536 | reg |= DWC3_DSTS_FULLSPEED1; | ||
1537 | break; | ||
1538 | case USB_SPEED_HIGH: | ||
1539 | reg |= DWC3_DSTS_HIGHSPEED; | ||
1540 | break; | ||
1541 | case USB_SPEED_SUPER: /* FALLTHROUGH */ | ||
1542 | case USB_SPEED_UNKNOWN: /* FALTHROUGH */ | ||
1543 | default: | ||
1544 | reg |= DWC3_DSTS_SUPERSPEED; | ||
1545 | } | ||
1546 | } | ||
1543 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | 1547 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); |
1544 | 1548 | ||
1545 | dwc->start_config_issued = false; | 1549 | dwc->start_config_issued = false; |
@@ -1551,42 +1555,38 @@ static int dwc3_gadget_start(struct usb_gadget *g, | |||
1551 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); | 1555 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); |
1552 | if (ret) { | 1556 | if (ret) { |
1553 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1557 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1554 | goto err0; | 1558 | goto err2; |
1555 | } | 1559 | } |
1556 | 1560 | ||
1557 | dep = dwc->eps[1]; | 1561 | dep = dwc->eps[1]; |
1558 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); | 1562 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, false); |
1559 | if (ret) { | 1563 | if (ret) { |
1560 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); | 1564 | dev_err(dwc->dev, "failed to enable %s\n", dep->name); |
1561 | goto err1; | 1565 | goto err3; |
1562 | } | 1566 | } |
1563 | 1567 | ||
1564 | /* begin to receive SETUP packets */ | 1568 | /* begin to receive SETUP packets */ |
1565 | dwc->ep0state = EP0_SETUP_PHASE; | 1569 | dwc->ep0state = EP0_SETUP_PHASE; |
1566 | dwc3_ep0_out_start(dwc); | 1570 | dwc3_ep0_out_start(dwc); |
1567 | 1571 | ||
1568 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1569 | ret = request_threaded_irq(irq, dwc3_interrupt, dwc3_thread_interrupt, | ||
1570 | IRQF_SHARED | IRQF_ONESHOT, "dwc3", dwc); | ||
1571 | if (ret) { | ||
1572 | dev_err(dwc->dev, "failed to request irq #%d --> %d\n", | ||
1573 | irq, ret); | ||
1574 | goto err1; | ||
1575 | } | ||
1576 | |||
1577 | dwc3_gadget_enable_irq(dwc); | 1572 | dwc3_gadget_enable_irq(dwc); |
1578 | 1573 | ||
1579 | spin_unlock_irqrestore(&dwc->lock, flags); | 1574 | spin_unlock_irqrestore(&dwc->lock, flags); |
1580 | 1575 | ||
1581 | return 0; | 1576 | return 0; |
1582 | 1577 | ||
1583 | err1: | 1578 | err3: |
1584 | __dwc3_gadget_ep_disable(dwc->eps[0]); | 1579 | __dwc3_gadget_ep_disable(dwc->eps[0]); |
1585 | 1580 | ||
1586 | err0: | 1581 | err2: |
1587 | dwc->gadget_driver = NULL; | 1582 | dwc->gadget_driver = NULL; |
1583 | |||
1584 | err1: | ||
1588 | spin_unlock_irqrestore(&dwc->lock, flags); | 1585 | spin_unlock_irqrestore(&dwc->lock, flags); |
1589 | 1586 | ||
1587 | free_irq(irq, dwc); | ||
1588 | |||
1589 | err0: | ||
1590 | return ret; | 1590 | return ret; |
1591 | } | 1591 | } |
1592 | 1592 | ||
@@ -1600,9 +1600,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g, | |||
1600 | spin_lock_irqsave(&dwc->lock, flags); | 1600 | spin_lock_irqsave(&dwc->lock, flags); |
1601 | 1601 | ||
1602 | dwc3_gadget_disable_irq(dwc); | 1602 | dwc3_gadget_disable_irq(dwc); |
1603 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1604 | free_irq(irq, dwc); | ||
1605 | |||
1606 | __dwc3_gadget_ep_disable(dwc->eps[0]); | 1603 | __dwc3_gadget_ep_disable(dwc->eps[0]); |
1607 | __dwc3_gadget_ep_disable(dwc->eps[1]); | 1604 | __dwc3_gadget_ep_disable(dwc->eps[1]); |
1608 | 1605 | ||
@@ -1610,6 +1607,9 @@ static int dwc3_gadget_stop(struct usb_gadget *g, | |||
1610 | 1607 | ||
1611 | spin_unlock_irqrestore(&dwc->lock, flags); | 1608 | spin_unlock_irqrestore(&dwc->lock, flags); |
1612 | 1609 | ||
1610 | irq = platform_get_irq(to_platform_device(dwc->dev), 0); | ||
1611 | free_irq(irq, dwc); | ||
1612 | |||
1613 | return 0; | 1613 | return 0; |
1614 | } | 1614 | } |
1615 | 1615 | ||
@@ -1642,13 +1642,15 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, | |||
1642 | 1642 | ||
1643 | dep->dwc = dwc; | 1643 | dep->dwc = dwc; |
1644 | dep->number = epnum; | 1644 | dep->number = epnum; |
1645 | dep->direction = !!direction; | ||
1645 | dwc->eps[epnum] = dep; | 1646 | dwc->eps[epnum] = dep; |
1646 | 1647 | ||
1647 | snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1, | 1648 | snprintf(dep->name, sizeof(dep->name), "ep%d%s", epnum >> 1, |
1648 | (epnum & 1) ? "in" : "out"); | 1649 | (epnum & 1) ? "in" : "out"); |
1649 | 1650 | ||
1650 | dep->endpoint.name = dep->name; | 1651 | dep->endpoint.name = dep->name; |
1651 | dep->direction = (epnum & 1); | 1652 | |
1653 | dev_vdbg(dwc->dev, "initializing %s\n", dep->name); | ||
1652 | 1654 | ||
1653 | if (epnum == 0 || epnum == 1) { | 1655 | if (epnum == 0 || epnum == 1) { |
1654 | dep->endpoint.maxpacket = 512; | 1656 | dep->endpoint.maxpacket = 512; |
@@ -2105,34 +2107,6 @@ static void dwc3_gadget_disconnect_interrupt(struct dwc3 *dwc) | |||
2105 | dwc->setup_packet_pending = false; | 2107 | dwc->setup_packet_pending = false; |
2106 | } | 2108 | } |
2107 | 2109 | ||
2108 | static void dwc3_gadget_usb3_phy_suspend(struct dwc3 *dwc, int suspend) | ||
2109 | { | ||
2110 | u32 reg; | ||
2111 | |||
2112 | reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)); | ||
2113 | |||
2114 | if (suspend) | ||
2115 | reg |= DWC3_GUSB3PIPECTL_SUSPHY; | ||
2116 | else | ||
2117 | reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; | ||
2118 | |||
2119 | dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); | ||
2120 | } | ||
2121 | |||
2122 | static void dwc3_gadget_usb2_phy_suspend(struct dwc3 *dwc, int suspend) | ||
2123 | { | ||
2124 | u32 reg; | ||
2125 | |||
2126 | reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0)); | ||
2127 | |||
2128 | if (suspend) | ||
2129 | reg |= DWC3_GUSB2PHYCFG_SUSPHY; | ||
2130 | else | ||
2131 | reg &= ~DWC3_GUSB2PHYCFG_SUSPHY; | ||
2132 | |||
2133 | dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg); | ||
2134 | } | ||
2135 | |||
2136 | static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | 2110 | static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) |
2137 | { | 2111 | { |
2138 | u32 reg; | 2112 | u32 reg; |
@@ -2173,13 +2147,6 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc) | |||
2173 | /* after reset -> Default State */ | 2147 | /* after reset -> Default State */ |
2174 | usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT); | 2148 | usb_gadget_set_state(&dwc->gadget, USB_STATE_DEFAULT); |
2175 | 2149 | ||
2176 | /* Recent versions support automatic phy suspend and don't need this */ | ||
2177 | if (dwc->revision < DWC3_REVISION_194A) { | ||
2178 | /* Resume PHYs */ | ||
2179 | dwc3_gadget_usb2_phy_suspend(dwc, false); | ||
2180 | dwc3_gadget_usb3_phy_suspend(dwc, false); | ||
2181 | } | ||
2182 | |||
2183 | if (dwc->gadget.speed != USB_SPEED_UNKNOWN) | 2150 | if (dwc->gadget.speed != USB_SPEED_UNKNOWN) |
2184 | dwc3_disconnect_gadget(dwc); | 2151 | dwc3_disconnect_gadget(dwc); |
2185 | 2152 | ||
@@ -2223,20 +2190,6 @@ static void dwc3_update_ram_clk_sel(struct dwc3 *dwc, u32 speed) | |||
2223 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 2190 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
2224 | } | 2191 | } |
2225 | 2192 | ||
2226 | static void dwc3_gadget_phy_suspend(struct dwc3 *dwc, u8 speed) | ||
2227 | { | ||
2228 | switch (speed) { | ||
2229 | case USB_SPEED_SUPER: | ||
2230 | dwc3_gadget_usb2_phy_suspend(dwc, true); | ||
2231 | break; | ||
2232 | case USB_SPEED_HIGH: | ||
2233 | case USB_SPEED_FULL: | ||
2234 | case USB_SPEED_LOW: | ||
2235 | dwc3_gadget_usb3_phy_suspend(dwc, true); | ||
2236 | break; | ||
2237 | } | ||
2238 | } | ||
2239 | |||
2240 | static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | 2193 | static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) |
2241 | { | 2194 | { |
2242 | struct dwc3_ep *dep; | 2195 | struct dwc3_ep *dep; |
@@ -2312,12 +2265,6 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) | |||
2312 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); | 2265 | dwc3_writel(dwc->regs, DWC3_DCTL, reg); |
2313 | } | 2266 | } |
2314 | 2267 | ||
2315 | /* Recent versions support automatic phy suspend and don't need this */ | ||
2316 | if (dwc->revision < DWC3_REVISION_194A) { | ||
2317 | /* Suspend unneeded PHY */ | ||
2318 | dwc3_gadget_phy_suspend(dwc, dwc->gadget.speed); | ||
2319 | } | ||
2320 | |||
2321 | dep = dwc->eps[0]; | 2268 | dep = dwc->eps[0]; |
2322 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); | 2269 | ret = __dwc3_gadget_ep_enable(dep, &dwc3_gadget_ep0_desc, NULL, true); |
2323 | if (ret) { | 2270 | if (ret) { |
@@ -2495,61 +2442,75 @@ static void dwc3_process_event_entry(struct dwc3 *dwc, | |||
2495 | } | 2442 | } |
2496 | } | 2443 | } |
2497 | 2444 | ||
2498 | static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) | 2445 | static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) |
2499 | { | 2446 | { |
2500 | struct dwc3 *dwc = _dwc; | 2447 | struct dwc3_event_buffer *evt; |
2501 | unsigned long flags; | ||
2502 | irqreturn_t ret = IRQ_NONE; | 2448 | irqreturn_t ret = IRQ_NONE; |
2503 | int i; | 2449 | int left; |
2450 | u32 reg; | ||
2504 | 2451 | ||
2505 | spin_lock_irqsave(&dwc->lock, flags); | 2452 | evt = dwc->ev_buffs[buf]; |
2453 | left = evt->count; | ||
2506 | 2454 | ||
2507 | for (i = 0; i < dwc->num_event_buffers; i++) { | 2455 | if (!(evt->flags & DWC3_EVENT_PENDING)) |
2508 | struct dwc3_event_buffer *evt; | 2456 | return IRQ_NONE; |
2509 | int left; | ||
2510 | 2457 | ||
2511 | evt = dwc->ev_buffs[i]; | 2458 | while (left > 0) { |
2512 | left = evt->count; | 2459 | union dwc3_event event; |
2513 | 2460 | ||
2514 | if (!(evt->flags & DWC3_EVENT_PENDING)) | 2461 | event.raw = *(u32 *) (evt->buf + evt->lpos); |
2515 | continue; | ||
2516 | 2462 | ||
2517 | while (left > 0) { | 2463 | dwc3_process_event_entry(dwc, &event); |
2518 | union dwc3_event event; | ||
2519 | 2464 | ||
2520 | event.raw = *(u32 *) (evt->buf + evt->lpos); | 2465 | /* |
2466 | * FIXME we wrap around correctly to the next entry as | ||
2467 | * almost all entries are 4 bytes in size. There is one | ||
2468 | * entry which has 12 bytes which is a regular entry | ||
2469 | * followed by 8 bytes data. ATM I don't know how | ||
2470 | * things are organized if we get next to the a | ||
2471 | * boundary so I worry about that once we try to handle | ||
2472 | * that. | ||
2473 | */ | ||
2474 | evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; | ||
2475 | left -= 4; | ||
2521 | 2476 | ||
2522 | dwc3_process_event_entry(dwc, &event); | 2477 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(buf), 4); |
2478 | } | ||
2523 | 2479 | ||
2524 | /* | 2480 | evt->count = 0; |
2525 | * FIXME we wrap around correctly to the next entry as | 2481 | evt->flags &= ~DWC3_EVENT_PENDING; |
2526 | * almost all entries are 4 bytes in size. There is one | 2482 | ret = IRQ_HANDLED; |
2527 | * entry which has 12 bytes which is a regular entry | ||
2528 | * followed by 8 bytes data. ATM I don't know how | ||
2529 | * things are organized if we get next to the a | ||
2530 | * boundary so I worry about that once we try to handle | ||
2531 | * that. | ||
2532 | */ | ||
2533 | evt->lpos = (evt->lpos + 4) % DWC3_EVENT_BUFFERS_SIZE; | ||
2534 | left -= 4; | ||
2535 | 2483 | ||
2536 | dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(i), 4); | 2484 | /* Unmask interrupt */ |
2537 | } | 2485 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf)); |
2486 | reg &= ~DWC3_GEVNTSIZ_INTMASK; | ||
2487 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg); | ||
2538 | 2488 | ||
2539 | evt->count = 0; | 2489 | return ret; |
2540 | evt->flags &= ~DWC3_EVENT_PENDING; | 2490 | } |
2541 | ret = IRQ_HANDLED; | 2491 | |
2542 | } | 2492 | static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc) |
2493 | { | ||
2494 | struct dwc3 *dwc = _dwc; | ||
2495 | unsigned long flags; | ||
2496 | irqreturn_t ret = IRQ_NONE; | ||
2497 | int i; | ||
2498 | |||
2499 | spin_lock_irqsave(&dwc->lock, flags); | ||
2500 | |||
2501 | for (i = 0; i < dwc->num_event_buffers; i++) | ||
2502 | ret |= dwc3_process_event_buf(dwc, i); | ||
2543 | 2503 | ||
2544 | spin_unlock_irqrestore(&dwc->lock, flags); | 2504 | spin_unlock_irqrestore(&dwc->lock, flags); |
2545 | 2505 | ||
2546 | return ret; | 2506 | return ret; |
2547 | } | 2507 | } |
2548 | 2508 | ||
2549 | static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | 2509 | static irqreturn_t dwc3_check_event_buf(struct dwc3 *dwc, u32 buf) |
2550 | { | 2510 | { |
2551 | struct dwc3_event_buffer *evt; | 2511 | struct dwc3_event_buffer *evt; |
2552 | u32 count; | 2512 | u32 count; |
2513 | u32 reg; | ||
2553 | 2514 | ||
2554 | evt = dwc->ev_buffs[buf]; | 2515 | evt = dwc->ev_buffs[buf]; |
2555 | 2516 | ||
@@ -2561,6 +2522,11 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf) | |||
2561 | evt->count = count; | 2522 | evt->count = count; |
2562 | evt->flags |= DWC3_EVENT_PENDING; | 2523 | evt->flags |= DWC3_EVENT_PENDING; |
2563 | 2524 | ||
2525 | /* Mask interrupt */ | ||
2526 | reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(buf)); | ||
2527 | reg |= DWC3_GEVNTSIZ_INTMASK; | ||
2528 | dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(buf), reg); | ||
2529 | |||
2564 | return IRQ_WAKE_THREAD; | 2530 | return IRQ_WAKE_THREAD; |
2565 | } | 2531 | } |
2566 | 2532 | ||
@@ -2575,7 +2541,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
2575 | for (i = 0; i < dwc->num_event_buffers; i++) { | 2541 | for (i = 0; i < dwc->num_event_buffers; i++) { |
2576 | irqreturn_t status; | 2542 | irqreturn_t status; |
2577 | 2543 | ||
2578 | status = dwc3_process_event_buf(dwc, i); | 2544 | status = dwc3_check_event_buf(dwc, i); |
2579 | if (status == IRQ_WAKE_THREAD) | 2545 | if (status == IRQ_WAKE_THREAD) |
2580 | ret = status; | 2546 | ret = status; |
2581 | } | 2547 | } |
@@ -2593,7 +2559,6 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
2593 | */ | 2559 | */ |
2594 | int dwc3_gadget_init(struct dwc3 *dwc) | 2560 | int dwc3_gadget_init(struct dwc3 *dwc) |
2595 | { | 2561 | { |
2596 | u32 reg; | ||
2597 | int ret; | 2562 | int ret; |
2598 | 2563 | ||
2599 | dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req), | 2564 | dwc->ctrl_req = dma_alloc_coherent(dwc->dev, sizeof(*dwc->ctrl_req), |
@@ -2643,16 +2608,6 @@ int dwc3_gadget_init(struct dwc3 *dwc) | |||
2643 | if (ret) | 2608 | if (ret) |
2644 | goto err4; | 2609 | goto err4; |
2645 | 2610 | ||
2646 | reg = dwc3_readl(dwc->regs, DWC3_DCFG); | ||
2647 | reg |= DWC3_DCFG_LPM_CAP; | ||
2648 | dwc3_writel(dwc->regs, DWC3_DCFG, reg); | ||
2649 | |||
2650 | /* Enable USB2 LPM and automatic phy suspend only on recent versions */ | ||
2651 | if (dwc->revision >= DWC3_REVISION_194A) { | ||
2652 | dwc3_gadget_usb2_phy_suspend(dwc, false); | ||
2653 | dwc3_gadget_usb3_phy_suspend(dwc, false); | ||
2654 | } | ||
2655 | |||
2656 | ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget); | 2611 | ret = usb_add_gadget_udc(dwc->dev, &dwc->gadget); |
2657 | if (ret) { | 2612 | if (ret) { |
2658 | dev_err(dwc->dev, "failed to register udc\n"); | 2613 | dev_err(dwc->dev, "failed to register udc\n"); |
diff --git a/drivers/usb/dwc3/gadget.h b/drivers/usb/dwc3/gadget.h index 99e6d7248820..febe1aa7b714 100644 --- a/drivers/usb/dwc3/gadget.h +++ b/drivers/usb/dwc3/gadget.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #ifndef __DRIVERS_USB_DWC3_GADGET_H | 19 | #ifndef __DRIVERS_USB_DWC3_GADGET_H |
diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 0fa1846eda4c..32db328cc769 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c | |||
@@ -5,34 +5,14 @@ | |||
5 | * | 5 | * |
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * This program is free software: you can redistribute it and/or modify |
9 | * modification, are permitted provided that the following conditions | 9 | * it under the terms of the GNU General Public License version 2 of |
10 | * are met: | 10 | * the License as published by the Free Software Foundation. |
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions, and the following disclaimer, | ||
13 | * without modification. | ||
14 | * 2. Redistributions in binary form must reproduce the above copyright | ||
15 | * notice, this list of conditions and the following disclaimer in the | ||
16 | * documentation and/or other materials provided with the distribution. | ||
17 | * 3. The names of the above-listed copyright holders may not be used | ||
18 | * to endorse or promote products derived from this software without | ||
19 | * specific prior written permission. | ||
20 | * | 11 | * |
21 | * ALTERNATIVELY, this software may be distributed under the terms of the | 12 | * This program is distributed in the hope that it will be useful, |
22 | * GNU General Public License ("GPL") version 2, as published by the Free | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | * Software Foundation. | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24 | * | 15 | * GNU General Public License for more details. |
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
26 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
27 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
28 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
29 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
30 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
31 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
32 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
33 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
34 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
35 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
36 | */ | 16 | */ |
37 | 17 | ||
38 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
diff --git a/drivers/usb/dwc3/io.h b/drivers/usb/dwc3/io.h index a50f76b9d19b..d94441c14d8c 100644 --- a/drivers/usb/dwc3/io.h +++ b/drivers/usb/dwc3/io.h | |||
@@ -6,34 +6,14 @@ | |||
6 | * Authors: Felipe Balbi <balbi@ti.com>, | 6 | * Authors: Felipe Balbi <balbi@ti.com>, |
7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 7 | * Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
8 | * | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * This program is free software: you can redistribute it and/or modify |
10 | * modification, are permitted provided that the following conditions | 10 | * it under the terms of the GNU General Public License version 2 of |
11 | * are met: | 11 | * the License as published by the Free Software Foundation. |
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions, and the following disclaimer, | ||
14 | * without modification. | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in the | ||
17 | * documentation and/or other materials provided with the distribution. | ||
18 | * 3. The names of the above-listed copyright holders may not be used | ||
19 | * to endorse or promote products derived from this software without | ||
20 | * specific prior written permission. | ||
21 | * | 12 | * |
22 | * ALTERNATIVELY, this software may be distributed under the terms of the | 13 | * This program is distributed in the hope that it will be useful, |
23 | * GNU General Public License ("GPL") version 2, as published by the Free | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * Software Foundation. | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * | 16 | * GNU General Public License for more details. |
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
27 | * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
28 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
29 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
30 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
31 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
32 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
33 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
34 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
35 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
36 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
37 | */ | 17 | */ |
38 | 18 | ||
39 | #ifndef __DRIVERS_USB_DWC3_IO_H | 19 | #ifndef __DRIVERS_USB_DWC3_IO_H |
diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h new file mode 100644 index 000000000000..7db34f00b89a --- /dev/null +++ b/drivers/usb/dwc3/platform_data.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /** | ||
2 | * platform_data.h - USB DWC3 Platform Data Support | ||
3 | * | ||
4 | * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com | ||
5 | * Author: Felipe Balbi <balbi@ti.com> | ||
6 | * | ||
7 | * This program is free software: you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 of | ||
9 | * the License as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #include <linux/usb/ch9.h> | ||
21 | #include <linux/usb/otg.h> | ||
22 | |||
23 | struct dwc3_platform_data { | ||
24 | enum usb_device_speed maximum_speed; | ||
25 | enum usb_dr_mode dr_mode; | ||
26 | bool tx_fifo_resize; | ||
27 | }; | ||