diff options
Diffstat (limited to 'drivers/usb/dwc3')
| -rw-r--r-- | drivers/usb/dwc3/Makefile | 14 | ||||
| -rw-r--r-- | drivers/usb/dwc3/core.c | 96 | ||||
| -rw-r--r-- | drivers/usb/dwc3/core.h | 3 | ||||
| -rw-r--r-- | drivers/usb/dwc3/debugfs.c | 6 | ||||
| -rw-r--r-- | drivers/usb/dwc3/dwc3-exynos.c | 57 | ||||
| -rw-r--r-- | drivers/usb/dwc3/dwc3-omap.c | 24 | ||||
| -rw-r--r-- | drivers/usb/dwc3/dwc3-pci.c | 24 | ||||
| -rw-r--r-- | drivers/usb/dwc3/gadget.c | 4 |
8 files changed, 69 insertions, 159 deletions
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index d441fe4c180b..4502648b8171 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile | |||
| @@ -27,19 +27,7 @@ endif | |||
| 27 | ## | 27 | ## |
| 28 | 28 | ||
| 29 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o | 29 | obj-$(CONFIG_USB_DWC3) += dwc3-omap.o |
| 30 | 30 | obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o | |
| 31 | ## | ||
| 32 | # REVISIT Samsung Exynos platform needs the clk API which isn't | ||
| 33 | # defined on all architectures. If we allow dwc3-exynos.c compile | ||
| 34 | # always we will fail the linking phase on those architectures | ||
| 35 | # which don't provide clk api implementation and that's unnaceptable. | ||
| 36 | # | ||
| 37 | # When Samsung's platform start supporting pm_runtime, this check | ||
| 38 | # for HAVE_CLK should be removed. | ||
| 39 | ## | ||
| 40 | ifneq ($(CONFIG_HAVE_CLK),) | ||
| 41 | obj-$(CONFIG_USB_DWC3) += dwc3-exynos.o | ||
| 42 | endif | ||
| 43 | 31 | ||
| 44 | ifneq ($(CONFIG_PCI),) | 32 | ifneq ($(CONFIG_PCI),) |
| 45 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o | 33 | obj-$(CONFIG_USB_DWC3) += dwc3-pci.o |
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index c14ebc975ba4..3a4004a620ad 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c | |||
| @@ -66,45 +66,6 @@ MODULE_PARM_DESC(maximum_speed, "Maximum supported speed."); | |||
| 66 | 66 | ||
| 67 | /* -------------------------------------------------------------------------- */ | 67 | /* -------------------------------------------------------------------------- */ |
| 68 | 68 | ||
| 69 | #define DWC3_DEVS_POSSIBLE 32 | ||
| 70 | |||
| 71 | static DECLARE_BITMAP(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
| 72 | |||
| 73 | int dwc3_get_device_id(void) | ||
| 74 | { | ||
| 75 | int id; | ||
| 76 | |||
| 77 | again: | ||
| 78 | id = find_first_zero_bit(dwc3_devs, DWC3_DEVS_POSSIBLE); | ||
| 79 | if (id < DWC3_DEVS_POSSIBLE) { | ||
| 80 | int old; | ||
| 81 | |||
| 82 | old = test_and_set_bit(id, dwc3_devs); | ||
| 83 | if (old) | ||
| 84 | goto again; | ||
| 85 | } else { | ||
| 86 | pr_err("dwc3: no space for new device\n"); | ||
| 87 | id = -ENOMEM; | ||
| 88 | } | ||
| 89 | |||
| 90 | return id; | ||
| 91 | } | ||
| 92 | EXPORT_SYMBOL_GPL(dwc3_get_device_id); | ||
| 93 | |||
| 94 | void dwc3_put_device_id(int id) | ||
| 95 | { | ||
| 96 | int ret; | ||
| 97 | |||
| 98 | if (id < 0) | ||
| 99 | return; | ||
| 100 | |||
| 101 | ret = test_bit(id, dwc3_devs); | ||
| 102 | WARN(!ret, "dwc3: ID %d not in use\n", id); | ||
| 103 | smp_mb__before_clear_bit(); | ||
| 104 | clear_bit(id, dwc3_devs); | ||
| 105 | } | ||
| 106 | EXPORT_SYMBOL_GPL(dwc3_put_device_id); | ||
| 107 | |||
| 108 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) | 69 | void dwc3_set_mode(struct dwc3 *dwc, u32 mode) |
| 109 | { | 70 | { |
| 110 | u32 reg; | 71 | u32 reg; |
| @@ -169,7 +130,6 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, | |||
| 169 | struct dwc3_event_buffer *evt) | 130 | struct dwc3_event_buffer *evt) |
| 170 | { | 131 | { |
| 171 | dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); | 132 | dma_free_coherent(dwc->dev, evt->length, evt->buf, evt->dma); |
| 172 | kfree(evt); | ||
| 173 | } | 133 | } |
| 174 | 134 | ||
| 175 | /** | 135 | /** |
| @@ -180,12 +140,11 @@ static void dwc3_free_one_event_buffer(struct dwc3 *dwc, | |||
| 180 | * Returns a pointer to the allocated event buffer structure on success | 140 | * Returns a pointer to the allocated event buffer structure on success |
| 181 | * otherwise ERR_PTR(errno). | 141 | * otherwise ERR_PTR(errno). |
| 182 | */ | 142 | */ |
| 183 | static struct dwc3_event_buffer *__devinit | 143 | static struct dwc3_event_buffer *dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) |
| 184 | dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) | ||
| 185 | { | 144 | { |
| 186 | struct dwc3_event_buffer *evt; | 145 | struct dwc3_event_buffer *evt; |
| 187 | 146 | ||
| 188 | evt = kzalloc(sizeof(*evt), GFP_KERNEL); | 147 | evt = devm_kzalloc(dwc->dev, sizeof(*evt), GFP_KERNEL); |
| 189 | if (!evt) | 148 | if (!evt) |
| 190 | return ERR_PTR(-ENOMEM); | 149 | return ERR_PTR(-ENOMEM); |
| 191 | 150 | ||
| @@ -193,10 +152,8 @@ dwc3_alloc_one_event_buffer(struct dwc3 *dwc, unsigned length) | |||
| 193 | evt->length = length; | 152 | evt->length = length; |
| 194 | evt->buf = dma_alloc_coherent(dwc->dev, length, | 153 | evt->buf = dma_alloc_coherent(dwc->dev, length, |
| 195 | &evt->dma, GFP_KERNEL); | 154 | &evt->dma, GFP_KERNEL); |
| 196 | if (!evt->buf) { | 155 | if (!evt->buf) |
| 197 | kfree(evt); | ||
| 198 | return ERR_PTR(-ENOMEM); | 156 | return ERR_PTR(-ENOMEM); |
| 199 | } | ||
| 200 | 157 | ||
| 201 | return evt; | 158 | return evt; |
| 202 | } | 159 | } |
| @@ -215,8 +172,6 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
| 215 | if (evt) | 172 | if (evt) |
| 216 | dwc3_free_one_event_buffer(dwc, evt); | 173 | dwc3_free_one_event_buffer(dwc, evt); |
| 217 | } | 174 | } |
| 218 | |||
| 219 | kfree(dwc->ev_buffs); | ||
| 220 | } | 175 | } |
| 221 | 176 | ||
| 222 | /** | 177 | /** |
| @@ -227,7 +182,7 @@ static void dwc3_free_event_buffers(struct dwc3 *dwc) | |||
| 227 | * Returns 0 on success otherwise negative errno. In the error case, dwc | 182 | * Returns 0 on success otherwise negative errno. In the error case, dwc |
| 228 | * may contain some buffers allocated but not all which were requested. | 183 | * may contain some buffers allocated but not all which were requested. |
| 229 | */ | 184 | */ |
| 230 | static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | 185 | static int dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) |
| 231 | { | 186 | { |
| 232 | int num; | 187 | int num; |
| 233 | int i; | 188 | int i; |
| @@ -235,7 +190,8 @@ static int __devinit dwc3_alloc_event_buffers(struct dwc3 *dwc, unsigned length) | |||
| 235 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); | 190 | num = DWC3_NUM_INT(dwc->hwparams.hwparams1); |
| 236 | dwc->num_event_buffers = num; | 191 | dwc->num_event_buffers = num; |
| 237 | 192 | ||
| 238 | dwc->ev_buffs = kzalloc(sizeof(*dwc->ev_buffs) * num, GFP_KERNEL); | 193 | dwc->ev_buffs = devm_kzalloc(dwc->dev, sizeof(*dwc->ev_buffs) * num, |
| 194 | GFP_KERNEL); | ||
| 239 | if (!dwc->ev_buffs) { | 195 | if (!dwc->ev_buffs) { |
| 240 | dev_err(dwc->dev, "can't allocate event buffers array\n"); | 196 | dev_err(dwc->dev, "can't allocate event buffers array\n"); |
| 241 | return -ENOMEM; | 197 | return -ENOMEM; |
| @@ -303,7 +259,7 @@ static void dwc3_event_buffers_cleanup(struct dwc3 *dwc) | |||
| 303 | } | 259 | } |
| 304 | } | 260 | } |
| 305 | 261 | ||
| 306 | static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc) | 262 | static void dwc3_cache_hwparams(struct dwc3 *dwc) |
| 307 | { | 263 | { |
| 308 | struct dwc3_hwparams *parms = &dwc->hwparams; | 264 | struct dwc3_hwparams *parms = &dwc->hwparams; |
| 309 | 265 | ||
| @@ -324,7 +280,7 @@ static void __devinit dwc3_cache_hwparams(struct dwc3 *dwc) | |||
| 324 | * | 280 | * |
| 325 | * Returns 0 on success otherwise negative errno. | 281 | * Returns 0 on success otherwise negative errno. |
| 326 | */ | 282 | */ |
| 327 | static int __devinit dwc3_core_init(struct dwc3 *dwc) | 283 | static int dwc3_core_init(struct dwc3 *dwc) |
| 328 | { | 284 | { |
| 329 | unsigned long timeout; | 285 | unsigned long timeout; |
| 330 | u32 reg; | 286 | u32 reg; |
| @@ -358,8 +314,6 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
| 358 | 314 | ||
| 359 | dwc3_core_soft_reset(dwc); | 315 | dwc3_core_soft_reset(dwc); |
| 360 | 316 | ||
| 361 | dwc3_cache_hwparams(dwc); | ||
| 362 | |||
| 363 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); | 317 | reg = dwc3_readl(dwc->regs, DWC3_GCTL); |
| 364 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; | 318 | reg &= ~DWC3_GCTL_SCALEDOWN_MASK; |
| 365 | reg &= ~DWC3_GCTL_DISSCRAMBLE; | 319 | reg &= ~DWC3_GCTL_DISSCRAMBLE; |
| @@ -383,24 +337,14 @@ static int __devinit dwc3_core_init(struct dwc3 *dwc) | |||
| 383 | 337 | ||
| 384 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); | 338 | dwc3_writel(dwc->regs, DWC3_GCTL, reg); |
| 385 | 339 | ||
| 386 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
| 387 | if (ret) { | ||
| 388 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
| 389 | ret = -ENOMEM; | ||
| 390 | goto err1; | ||
| 391 | } | ||
| 392 | |||
| 393 | ret = dwc3_event_buffers_setup(dwc); | 340 | ret = dwc3_event_buffers_setup(dwc); |
| 394 | if (ret) { | 341 | if (ret) { |
| 395 | dev_err(dwc->dev, "failed to setup event buffers\n"); | 342 | dev_err(dwc->dev, "failed to setup event buffers\n"); |
| 396 | goto err1; | 343 | goto err0; |
| 397 | } | 344 | } |
| 398 | 345 | ||
| 399 | return 0; | 346 | return 0; |
| 400 | 347 | ||
| 401 | err1: | ||
| 402 | dwc3_free_event_buffers(dwc); | ||
| 403 | |||
| 404 | err0: | 348 | err0: |
| 405 | return ret; | 349 | return ret; |
| 406 | } | 350 | } |
| @@ -408,16 +352,14 @@ err0: | |||
| 408 | static void dwc3_core_exit(struct dwc3 *dwc) | 352 | static void dwc3_core_exit(struct dwc3 *dwc) |
| 409 | { | 353 | { |
| 410 | dwc3_event_buffers_cleanup(dwc); | 354 | dwc3_event_buffers_cleanup(dwc); |
| 411 | dwc3_free_event_buffers(dwc); | ||
| 412 | 355 | ||
| 413 | usb_phy_shutdown(dwc->usb2_phy); | 356 | usb_phy_shutdown(dwc->usb2_phy); |
| 414 | usb_phy_shutdown(dwc->usb3_phy); | 357 | usb_phy_shutdown(dwc->usb3_phy); |
| 415 | |||
| 416 | } | 358 | } |
| 417 | 359 | ||
| 418 | #define DWC3_ALIGN_MASK (16 - 1) | 360 | #define DWC3_ALIGN_MASK (16 - 1) |
| 419 | 361 | ||
| 420 | static int __devinit dwc3_probe(struct platform_device *pdev) | 362 | static int dwc3_probe(struct platform_device *pdev) |
| 421 | { | 363 | { |
| 422 | struct device_node *node = pdev->dev.of_node; | 364 | struct device_node *node = pdev->dev.of_node; |
| 423 | struct resource *res; | 365 | struct resource *res; |
| @@ -515,10 +457,19 @@ static int __devinit dwc3_probe(struct platform_device *pdev) | |||
| 515 | pm_runtime_get_sync(dev); | 457 | pm_runtime_get_sync(dev); |
| 516 | pm_runtime_forbid(dev); | 458 | pm_runtime_forbid(dev); |
| 517 | 459 | ||
| 460 | dwc3_cache_hwparams(dwc); | ||
| 461 | |||
| 462 | ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); | ||
| 463 | if (ret) { | ||
| 464 | dev_err(dwc->dev, "failed to allocate event buffers\n"); | ||
| 465 | ret = -ENOMEM; | ||
| 466 | goto err0; | ||
| 467 | } | ||
| 468 | |||
| 518 | ret = dwc3_core_init(dwc); | 469 | ret = dwc3_core_init(dwc); |
| 519 | if (ret) { | 470 | if (ret) { |
| 520 | dev_err(dev, "failed to initialize core\n"); | 471 | dev_err(dev, "failed to initialize core\n"); |
| 521 | return ret; | 472 | goto err0; |
| 522 | } | 473 | } |
| 523 | 474 | ||
| 524 | mode = DWC3_MODE(dwc->hwparams.hwparams0); | 475 | mode = DWC3_MODE(dwc->hwparams.hwparams0); |
| @@ -590,10 +541,13 @@ err2: | |||
| 590 | err1: | 541 | err1: |
| 591 | dwc3_core_exit(dwc); | 542 | dwc3_core_exit(dwc); |
| 592 | 543 | ||
| 544 | err0: | ||
| 545 | dwc3_free_event_buffers(dwc); | ||
| 546 | |||
| 593 | return ret; | 547 | return ret; |
| 594 | } | 548 | } |
| 595 | 549 | ||
| 596 | static int __devexit dwc3_remove(struct platform_device *pdev) | 550 | static int dwc3_remove(struct platform_device *pdev) |
| 597 | { | 551 | { |
| 598 | struct dwc3 *dwc = platform_get_drvdata(pdev); | 552 | struct dwc3 *dwc = platform_get_drvdata(pdev); |
| 599 | struct resource *res; | 553 | struct resource *res; |
| @@ -628,7 +582,7 @@ static int __devexit dwc3_remove(struct platform_device *pdev) | |||
| 628 | 582 | ||
| 629 | static struct platform_driver dwc3_driver = { | 583 | static struct platform_driver dwc3_driver = { |
| 630 | .probe = dwc3_probe, | 584 | .probe = dwc3_probe, |
| 631 | .remove = __devexit_p(dwc3_remove), | 585 | .remove = dwc3_remove, |
| 632 | .driver = { | 586 | .driver = { |
| 633 | .name = "dwc3", | 587 | .name = "dwc3", |
| 634 | }, | 588 | }, |
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 243affc93431..499956344262 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h | |||
| @@ -868,7 +868,4 @@ void dwc3_host_exit(struct dwc3 *dwc); | |||
| 868 | int dwc3_gadget_init(struct dwc3 *dwc); | 868 | int dwc3_gadget_init(struct dwc3 *dwc); |
| 869 | void dwc3_gadget_exit(struct dwc3 *dwc); | 869 | void dwc3_gadget_exit(struct dwc3 *dwc); |
| 870 | 870 | ||
| 871 | extern int dwc3_get_device_id(void); | ||
| 872 | extern void dwc3_put_device_id(int id); | ||
| 873 | |||
| 874 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ | 871 | #endif /* __DRIVERS_USB_DWC3_CORE_H */ |
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index d4a30f118724..5945aadaa1c9 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | #define dump_register(nm) \ | 56 | #define dump_register(nm) \ |
| 57 | { \ | 57 | { \ |
| 58 | .name = __stringify(nm), \ | 58 | .name = __stringify(nm), \ |
| 59 | .offset = DWC3_ ##nm, \ | 59 | .offset = DWC3_ ##nm - DWC3_GLOBALS_REGS_START, \ |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static const struct debugfs_reg32 dwc3_regs[] = { | 62 | static const struct debugfs_reg32 dwc3_regs[] = { |
| @@ -652,7 +652,7 @@ static const struct file_operations dwc3_link_state_fops = { | |||
| 652 | .release = single_release, | 652 | .release = single_release, |
| 653 | }; | 653 | }; |
| 654 | 654 | ||
| 655 | int __devinit dwc3_debugfs_init(struct dwc3 *dwc) | 655 | int dwc3_debugfs_init(struct dwc3 *dwc) |
| 656 | { | 656 | { |
| 657 | struct dentry *root; | 657 | struct dentry *root; |
| 658 | struct dentry *file; | 658 | struct dentry *file; |
| @@ -703,7 +703,7 @@ err0: | |||
| 703 | return ret; | 703 | return ret; |
| 704 | } | 704 | } |
| 705 | 705 | ||
| 706 | void __devexit dwc3_debugfs_exit(struct dwc3 *dwc) | 706 | void dwc3_debugfs_exit(struct dwc3 *dwc) |
| 707 | { | 707 | { |
| 708 | debugfs_remove_recursive(dwc->root); | 708 | debugfs_remove_recursive(dwc->root); |
| 709 | dwc->root = NULL; | 709 | dwc->root = NULL; |
diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c index ca6597853f90..aae5328ac771 100644 --- a/drivers/usb/dwc3/dwc3-exynos.c +++ b/drivers/usb/dwc3/dwc3-exynos.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
| 22 | #include <linux/usb/otg.h> | 22 | #include <linux/usb/otg.h> |
| 23 | #include <linux/usb/nop-usb-xceiv.h> | 23 | #include <linux/usb/nop-usb-xceiv.h> |
| 24 | #include <linux/of.h> | ||
| 24 | 25 | ||
| 25 | #include "core.h" | 26 | #include "core.h" |
| 26 | 27 | ||
| @@ -33,7 +34,7 @@ struct dwc3_exynos { | |||
| 33 | struct clk *clk; | 34 | struct clk *clk; |
| 34 | }; | 35 | }; |
| 35 | 36 | ||
| 36 | static int __devinit dwc3_exynos_register_phys(struct dwc3_exynos *exynos) | 37 | static int dwc3_exynos_register_phys(struct dwc3_exynos *exynos) |
| 37 | { | 38 | { |
| 38 | struct nop_usb_xceiv_platform_data pdata; | 39 | struct nop_usb_xceiv_platform_data pdata; |
| 39 | struct platform_device *pdev; | 40 | struct platform_device *pdev; |
| @@ -87,14 +88,14 @@ err1: | |||
| 87 | return ret; | 88 | return ret; |
| 88 | } | 89 | } |
| 89 | 90 | ||
| 90 | static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | 91 | static u64 dwc3_exynos_dma_mask = DMA_BIT_MASK(32); |
| 92 | |||
| 93 | static int dwc3_exynos_probe(struct platform_device *pdev) | ||
| 91 | { | 94 | { |
| 92 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | ||
| 93 | struct platform_device *dwc3; | 95 | struct platform_device *dwc3; |
| 94 | struct dwc3_exynos *exynos; | 96 | struct dwc3_exynos *exynos; |
| 95 | struct clk *clk; | 97 | struct clk *clk; |
| 96 | 98 | ||
| 97 | int devid; | ||
| 98 | int ret = -ENOMEM; | 99 | int ret = -ENOMEM; |
| 99 | 100 | ||
| 100 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); | 101 | exynos = kzalloc(sizeof(*exynos), GFP_KERNEL); |
| @@ -103,11 +104,15 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
| 103 | goto err0; | 104 | goto err0; |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | platform_set_drvdata(pdev, exynos); | 107 | /* |
| 108 | * Right now device-tree probed devices don't get dma_mask set. | ||
| 109 | * Since shared usb code relies on it, set it here for now. | ||
| 110 | * Once we move to full device tree support this will vanish off. | ||
| 111 | */ | ||
| 112 | if (!pdev->dev.dma_mask) | ||
| 113 | pdev->dev.dma_mask = &dwc3_exynos_dma_mask; | ||
| 107 | 114 | ||
| 108 | devid = dwc3_get_device_id(); | 115 | platform_set_drvdata(pdev, exynos); |
| 109 | if (devid < 0) | ||
| 110 | goto err1; | ||
| 111 | 116 | ||
| 112 | ret = dwc3_exynos_register_phys(exynos); | 117 | ret = dwc3_exynos_register_phys(exynos); |
| 113 | if (ret) { | 118 | if (ret) { |
| @@ -115,10 +120,10 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
| 115 | goto err1; | 120 | goto err1; |
| 116 | } | 121 | } |
| 117 | 122 | ||
| 118 | dwc3 = platform_device_alloc("dwc3", devid); | 123 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
| 119 | if (!dwc3) { | 124 | if (!dwc3) { |
| 120 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); | 125 | dev_err(&pdev->dev, "couldn't allocate dwc3 device\n"); |
| 121 | goto err2; | 126 | goto err1; |
| 122 | } | 127 | } |
| 123 | 128 | ||
| 124 | clk = clk_get(&pdev->dev, "usbdrd30"); | 129 | clk = clk_get(&pdev->dev, "usbdrd30"); |
| @@ -139,14 +144,6 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
| 139 | 144 | ||
| 140 | clk_enable(exynos->clk); | 145 | clk_enable(exynos->clk); |
| 141 | 146 | ||
| 142 | /* PHY initialization */ | ||
| 143 | if (!pdata) { | ||
| 144 | dev_dbg(&pdev->dev, "missing platform data\n"); | ||
| 145 | } else { | ||
| 146 | if (pdata->phy_init) | ||
| 147 | pdata->phy_init(pdev, pdata->phy_type); | ||
| 148 | } | ||
| 149 | |||
| 150 | ret = platform_device_add_resources(dwc3, pdev->resource, | 147 | ret = platform_device_add_resources(dwc3, pdev->resource, |
| 151 | pdev->num_resources); | 148 | pdev->num_resources); |
| 152 | if (ret) { | 149 | if (ret) { |
| @@ -163,35 +160,24 @@ static int __devinit dwc3_exynos_probe(struct platform_device *pdev) | |||
| 163 | return 0; | 160 | return 0; |
| 164 | 161 | ||
| 165 | err4: | 162 | err4: |
| 166 | if (pdata && pdata->phy_exit) | ||
| 167 | pdata->phy_exit(pdev, pdata->phy_type); | ||
| 168 | |||
| 169 | clk_disable(clk); | 163 | clk_disable(clk); |
| 170 | clk_put(clk); | 164 | clk_put(clk); |
| 171 | err3: | 165 | err3: |
| 172 | platform_device_put(dwc3); | 166 | platform_device_put(dwc3); |
| 173 | err2: | ||
| 174 | dwc3_put_device_id(devid); | ||
| 175 | err1: | 167 | err1: |
| 176 | kfree(exynos); | 168 | kfree(exynos); |
| 177 | err0: | 169 | err0: |
| 178 | return ret; | 170 | return ret; |
| 179 | } | 171 | } |
| 180 | 172 | ||
| 181 | static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | 173 | static int dwc3_exynos_remove(struct platform_device *pdev) |
| 182 | { | 174 | { |
| 183 | struct dwc3_exynos *exynos = platform_get_drvdata(pdev); | 175 | struct dwc3_exynos *exynos = platform_get_drvdata(pdev); |
| 184 | struct dwc3_exynos_data *pdata = pdev->dev.platform_data; | ||
| 185 | 176 | ||
| 186 | platform_device_unregister(exynos->dwc3); | 177 | platform_device_unregister(exynos->dwc3); |
| 187 | platform_device_unregister(exynos->usb2_phy); | 178 | platform_device_unregister(exynos->usb2_phy); |
| 188 | platform_device_unregister(exynos->usb3_phy); | 179 | platform_device_unregister(exynos->usb3_phy); |
| 189 | 180 | ||
| 190 | dwc3_put_device_id(exynos->dwc3->id); | ||
| 191 | |||
| 192 | if (pdata && pdata->phy_exit) | ||
| 193 | pdata->phy_exit(pdev, pdata->phy_type); | ||
| 194 | |||
| 195 | clk_disable(exynos->clk); | 181 | clk_disable(exynos->clk); |
| 196 | clk_put(exynos->clk); | 182 | clk_put(exynos->clk); |
| 197 | 183 | ||
| @@ -200,11 +186,20 @@ static int __devexit dwc3_exynos_remove(struct platform_device *pdev) | |||
| 200 | return 0; | 186 | return 0; |
| 201 | } | 187 | } |
| 202 | 188 | ||
| 189 | #ifdef CONFIG_OF | ||
| 190 | static const struct of_device_id exynos_dwc3_match[] = { | ||
| 191 | { .compatible = "samsung,exynos-dwc3" }, | ||
| 192 | {}, | ||
| 193 | }; | ||
| 194 | MODULE_DEVICE_TABLE(of, exynos_dwc3_match); | ||
| 195 | #endif | ||
| 196 | |||
| 203 | static struct platform_driver dwc3_exynos_driver = { | 197 | static struct platform_driver dwc3_exynos_driver = { |
| 204 | .probe = dwc3_exynos_probe, | 198 | .probe = dwc3_exynos_probe, |
| 205 | .remove = __devexit_p(dwc3_exynos_remove), | 199 | .remove = dwc3_exynos_remove, |
| 206 | .driver = { | 200 | .driver = { |
| 207 | .name = "exynos-dwc3", | 201 | .name = "exynos-dwc3", |
| 202 | .of_match_table = of_match_ptr(exynos_dwc3_match), | ||
| 208 | }, | 203 | }, |
| 209 | }; | 204 | }; |
| 210 | 205 | ||
diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index ee57a10d90d0..f31867fd2574 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c | |||
| @@ -157,7 +157,7 @@ static inline void dwc3_omap_writel(void __iomem *base, u32 offset, u32 value) | |||
| 157 | writel(value, base + offset); | 157 | writel(value, base + offset); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | static int __devinit dwc3_omap_register_phys(struct dwc3_omap *omap) | 160 | static int dwc3_omap_register_phys(struct dwc3_omap *omap) |
| 161 | { | 161 | { |
| 162 | struct nop_usb_xceiv_platform_data pdata; | 162 | struct nop_usb_xceiv_platform_data pdata; |
| 163 | struct platform_device *pdev; | 163 | struct platform_device *pdev; |
| @@ -262,7 +262,7 @@ static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap) | |||
| 262 | return IRQ_HANDLED; | 262 | return IRQ_HANDLED; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | static int __devinit dwc3_omap_probe(struct platform_device *pdev) | 265 | static int dwc3_omap_probe(struct platform_device *pdev) |
| 266 | { | 266 | { |
| 267 | struct dwc3_omap_data *pdata = pdev->dev.platform_data; | 267 | struct dwc3_omap_data *pdata = pdev->dev.platform_data; |
| 268 | struct device_node *node = pdev->dev.of_node; | 268 | struct device_node *node = pdev->dev.of_node; |
| @@ -272,7 +272,6 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
| 272 | struct resource *res; | 272 | struct resource *res; |
| 273 | struct device *dev = &pdev->dev; | 273 | struct device *dev = &pdev->dev; |
| 274 | 274 | ||
| 275 | int devid; | ||
| 276 | int size; | 275 | int size; |
| 277 | int ret = -ENOMEM; | 276 | int ret = -ENOMEM; |
| 278 | int irq; | 277 | int irq; |
| @@ -315,14 +314,10 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
| 315 | return ret; | 314 | return ret; |
| 316 | } | 315 | } |
| 317 | 316 | ||
| 318 | devid = dwc3_get_device_id(); | 317 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
| 319 | if (devid < 0) | ||
| 320 | return -ENODEV; | ||
| 321 | |||
| 322 | dwc3 = platform_device_alloc("dwc3", devid); | ||
| 323 | if (!dwc3) { | 318 | if (!dwc3) { |
| 324 | dev_err(dev, "couldn't allocate dwc3 device\n"); | 319 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
| 325 | goto err1; | 320 | return -ENOMEM; |
| 326 | } | 321 | } |
| 327 | 322 | ||
| 328 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); | 323 | context = devm_kzalloc(dev, resource_size(res), GFP_KERNEL); |
| @@ -423,23 +418,16 @@ static int __devinit dwc3_omap_probe(struct platform_device *pdev) | |||
| 423 | 418 | ||
| 424 | err2: | 419 | err2: |
| 425 | platform_device_put(dwc3); | 420 | platform_device_put(dwc3); |
| 426 | |||
| 427 | err1: | ||
| 428 | dwc3_put_device_id(devid); | ||
| 429 | |||
| 430 | return ret; | 421 | return ret; |
| 431 | } | 422 | } |
| 432 | 423 | ||
| 433 | static int __devexit dwc3_omap_remove(struct platform_device *pdev) | 424 | static int dwc3_omap_remove(struct platform_device *pdev) |
| 434 | { | 425 | { |
| 435 | struct dwc3_omap *omap = platform_get_drvdata(pdev); | 426 | struct dwc3_omap *omap = platform_get_drvdata(pdev); |
| 436 | 427 | ||
| 437 | platform_device_unregister(omap->dwc3); | 428 | platform_device_unregister(omap->dwc3); |
| 438 | platform_device_unregister(omap->usb2_phy); | 429 | platform_device_unregister(omap->usb2_phy); |
| 439 | platform_device_unregister(omap->usb3_phy); | 430 | platform_device_unregister(omap->usb3_phy); |
| 440 | |||
| 441 | dwc3_put_device_id(omap->dwc3->id); | ||
| 442 | |||
| 443 | return 0; | 431 | return 0; |
| 444 | } | 432 | } |
| 445 | 433 | ||
| @@ -453,7 +441,7 @@ MODULE_DEVICE_TABLE(of, of_dwc3_matach); | |||
| 453 | 441 | ||
| 454 | static struct platform_driver dwc3_omap_driver = { | 442 | static struct platform_driver dwc3_omap_driver = { |
| 455 | .probe = dwc3_omap_probe, | 443 | .probe = dwc3_omap_probe, |
| 456 | .remove = __devexit_p(dwc3_omap_remove), | 444 | .remove = dwc3_omap_remove, |
| 457 | .driver = { | 445 | .driver = { |
| 458 | .name = "omap-dwc3", | 446 | .name = "omap-dwc3", |
| 459 | .of_match_table = of_dwc3_matach, | 447 | .of_match_table = of_dwc3_matach, |
diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 94f550e37f98..7d70f44567d2 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c | |||
| @@ -58,7 +58,7 @@ struct dwc3_pci { | |||
| 58 | struct platform_device *usb3_phy; | 58 | struct platform_device *usb3_phy; |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | static int __devinit dwc3_pci_register_phys(struct dwc3_pci *glue) | 61 | static int dwc3_pci_register_phys(struct dwc3_pci *glue) |
| 62 | { | 62 | { |
| 63 | struct nop_usb_xceiv_platform_data pdata; | 63 | struct nop_usb_xceiv_platform_data pdata; |
| 64 | struct platform_device *pdev; | 64 | struct platform_device *pdev; |
| @@ -112,14 +112,13 @@ err1: | |||
| 112 | return ret; | 112 | return ret; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static int __devinit dwc3_pci_probe(struct pci_dev *pci, | 115 | static int dwc3_pci_probe(struct pci_dev *pci, |
| 116 | const struct pci_device_id *id) | 116 | const struct pci_device_id *id) |
| 117 | { | 117 | { |
| 118 | struct resource res[2]; | 118 | struct resource res[2]; |
| 119 | struct platform_device *dwc3; | 119 | struct platform_device *dwc3; |
| 120 | struct dwc3_pci *glue; | 120 | struct dwc3_pci *glue; |
| 121 | int ret = -ENOMEM; | 121 | int ret = -ENOMEM; |
| 122 | int devid; | ||
| 123 | struct device *dev = &pci->dev; | 122 | struct device *dev = &pci->dev; |
| 124 | 123 | ||
| 125 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); | 124 | glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL); |
| @@ -145,13 +144,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
| 145 | return ret; | 144 | return ret; |
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | devid = dwc3_get_device_id(); | 147 | dwc3 = platform_device_alloc("dwc3", PLATFORM_DEVID_AUTO); |
| 149 | if (devid < 0) { | ||
| 150 | ret = -ENOMEM; | ||
| 151 | goto err1; | ||
| 152 | } | ||
| 153 | |||
| 154 | dwc3 = platform_device_alloc("dwc3", devid); | ||
| 155 | if (!dwc3) { | 148 | if (!dwc3) { |
| 156 | dev_err(dev, "couldn't allocate dwc3 device\n"); | 149 | dev_err(dev, "couldn't allocate dwc3 device\n"); |
| 157 | ret = -ENOMEM; | 150 | ret = -ENOMEM; |
| @@ -172,7 +165,7 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
| 172 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); | 165 | ret = platform_device_add_resources(dwc3, res, ARRAY_SIZE(res)); |
| 173 | if (ret) { | 166 | if (ret) { |
| 174 | dev_err(dev, "couldn't add resources to dwc3 device\n"); | 167 | dev_err(dev, "couldn't add resources to dwc3 device\n"); |
| 175 | goto err2; | 168 | goto err1; |
| 176 | } | 169 | } |
| 177 | 170 | ||
| 178 | pci_set_drvdata(pci, glue); | 171 | pci_set_drvdata(pci, glue); |
| @@ -195,23 +188,18 @@ static int __devinit dwc3_pci_probe(struct pci_dev *pci, | |||
| 195 | err3: | 188 | err3: |
| 196 | pci_set_drvdata(pci, NULL); | 189 | pci_set_drvdata(pci, NULL); |
| 197 | platform_device_put(dwc3); | 190 | platform_device_put(dwc3); |
| 198 | |||
| 199 | err2: | ||
| 200 | dwc3_put_device_id(devid); | ||
| 201 | |||
| 202 | err1: | 191 | err1: |
| 203 | pci_disable_device(pci); | 192 | pci_disable_device(pci); |
| 204 | 193 | ||
| 205 | return ret; | 194 | return ret; |
| 206 | } | 195 | } |
| 207 | 196 | ||
| 208 | static void __devexit dwc3_pci_remove(struct pci_dev *pci) | 197 | static void dwc3_pci_remove(struct pci_dev *pci) |
| 209 | { | 198 | { |
| 210 | struct dwc3_pci *glue = pci_get_drvdata(pci); | 199 | struct dwc3_pci *glue = pci_get_drvdata(pci); |
| 211 | 200 | ||
| 212 | platform_device_unregister(glue->usb2_phy); | 201 | platform_device_unregister(glue->usb2_phy); |
| 213 | platform_device_unregister(glue->usb3_phy); | 202 | platform_device_unregister(glue->usb3_phy); |
| 214 | dwc3_put_device_id(glue->dwc3->id); | ||
| 215 | platform_device_unregister(glue->dwc3); | 203 | platform_device_unregister(glue->dwc3); |
| 216 | pci_set_drvdata(pci, NULL); | 204 | pci_set_drvdata(pci, NULL); |
| 217 | pci_disable_device(pci); | 205 | pci_disable_device(pci); |
| @@ -230,7 +218,7 @@ static struct pci_driver dwc3_pci_driver = { | |||
| 230 | .name = "dwc3-pci", | 218 | .name = "dwc3-pci", |
| 231 | .id_table = dwc3_pci_id_table, | 219 | .id_table = dwc3_pci_id_table, |
| 232 | .probe = dwc3_pci_probe, | 220 | .probe = dwc3_pci_probe, |
| 233 | .remove = __devexit_p(dwc3_pci_remove), | 221 | .remove = dwc3_pci_remove, |
| 234 | }; | 222 | }; |
| 235 | 223 | ||
| 236 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); | 224 | MODULE_AUTHOR("Felipe Balbi <balbi@ti.com>"); |
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 7b7deddf6a52..2e43b332aae8 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c | |||
| @@ -1579,7 +1579,7 @@ static const struct usb_gadget_ops dwc3_gadget_ops = { | |||
| 1579 | 1579 | ||
| 1580 | /* -------------------------------------------------------------------------- */ | 1580 | /* -------------------------------------------------------------------------- */ |
| 1581 | 1581 | ||
| 1582 | static int __devinit dwc3_gadget_init_endpoints(struct dwc3 *dwc) | 1582 | static int dwc3_gadget_init_endpoints(struct dwc3 *dwc) |
| 1583 | { | 1583 | { |
| 1584 | struct dwc3_ep *dep; | 1584 | struct dwc3_ep *dep; |
| 1585 | u8 epnum; | 1585 | u8 epnum; |
| @@ -2374,7 +2374,7 @@ static irqreturn_t dwc3_interrupt(int irq, void *_dwc) | |||
| 2374 | * | 2374 | * |
| 2375 | * Returns 0 on success otherwise negative errno. | 2375 | * Returns 0 on success otherwise negative errno. |
| 2376 | */ | 2376 | */ |
| 2377 | int __devinit dwc3_gadget_init(struct dwc3 *dwc) | 2377 | int dwc3_gadget_init(struct dwc3 *dwc) |
| 2378 | { | 2378 | { |
| 2379 | u32 reg; | 2379 | u32 reg; |
| 2380 | int ret; | 2380 | int ret; |
