diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-11 16:56:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-11 16:56:29 -0400 |
commit | 1cd572fc0c5f6887ea0542e2d3ec26625e2cdfb7 (patch) | |
tree | 9b987397f34f685edbb4b1f282a32d229c15a1bd /drivers/usb/musb/davinci.c | |
parent | e6d49d093e1076df060c18d28b8ebc36077f76e7 (diff) | |
parent | d8c3ef256f88b7c6ecd673d03073b5645be9c5e4 (diff) |
Merge tag 'musb-for-v3.7' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-next
usb: musb: patches for v3.7 merge window
Here we have a bunch of miscellaneous cleanups and fixes
to the musb driver. It fixes a bunch of mistakes errors
which nobody has triggered before, so I'm not Ccing stable
tree.
We are finally improving OMAP's VBUS/ID Mailbox usage so
that we can introduce our PHY drivers properly. Also, we're
adding support for multiple instances of the MUSB IP in
the same SoC, as seen on some platforms from TI which
have 2 MUSB instances.
Other than that, we have some small fixes like not kicking
DMA for a zero byte transfer, or properly handling NAK timeout
on MUSB's host side, and the enabling of DMA Mode1 for any
transfers which are aligned to wMaxPacketSize.
All patches have been pending on mailing list for a long time
and I don't expect any big surprises with this pull request.
Diffstat (limited to 'drivers/usb/musb/davinci.c')
-rw-r--r-- | drivers/usb/musb/davinci.c | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 863a9b6286c3..606bfd00cde6 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c | |||
@@ -116,8 +116,7 @@ static void davinci_musb_enable(struct musb *musb) | |||
116 | dma_off = 0; | 116 | dma_off = 0; |
117 | 117 | ||
118 | /* force a DRVVBUS irq so we can start polling for ID change */ | 118 | /* force a DRVVBUS irq so we can start polling for ID change */ |
119 | if (is_otg_enabled(musb)) | 119 | musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, |
120 | musb_writel(musb->ctrl_base, DAVINCI_USB_INT_SET_REG, | ||
121 | DAVINCI_INTR_DRVVBUS << DAVINCI_USB_USBINT_SHIFT); | 120 | DAVINCI_INTR_DRVVBUS << DAVINCI_USB_USBINT_SHIFT); |
122 | } | 121 | } |
123 | 122 | ||
@@ -235,10 +234,8 @@ static void otg_timer(unsigned long _musb) | |||
235 | MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT); | 234 | MUSB_INTR_VBUSERROR << DAVINCI_USB_USBINT_SHIFT); |
236 | break; | 235 | break; |
237 | case OTG_STATE_B_IDLE: | 236 | case OTG_STATE_B_IDLE: |
238 | if (!is_peripheral_enabled(musb)) | 237 | /* |
239 | break; | 238 | * There's no ID-changed IRQ, so we have no good way to tell |
240 | |||
241 | /* There's no ID-changed IRQ, so we have no good way to tell | ||
242 | * when to switch to the A-Default state machine (by setting | 239 | * when to switch to the A-Default state machine (by setting |
243 | * the DEVCTL.SESSION flag). | 240 | * the DEVCTL.SESSION flag). |
244 | * | 241 | * |
@@ -316,8 +313,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
316 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); | 313 | u8 devctl = musb_readb(mregs, MUSB_DEVCTL); |
317 | int err = musb->int_usb & MUSB_INTR_VBUSERROR; | 314 | int err = musb->int_usb & MUSB_INTR_VBUSERROR; |
318 | 315 | ||
319 | err = is_host_enabled(musb) | 316 | err = musb->int_usb & MUSB_INTR_VBUSERROR; |
320 | && (musb->int_usb & MUSB_INTR_VBUSERROR); | ||
321 | if (err) { | 317 | if (err) { |
322 | /* The Mentor core doesn't debounce VBUS as needed | 318 | /* The Mentor core doesn't debounce VBUS as needed |
323 | * to cope with device connect current spikes. This | 319 | * to cope with device connect current spikes. This |
@@ -333,7 +329,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
333 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; | 329 | musb->xceiv->state = OTG_STATE_A_WAIT_VFALL; |
334 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 330 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
335 | WARNING("VBUS error workaround (delay coming)\n"); | 331 | WARNING("VBUS error workaround (delay coming)\n"); |
336 | } else if (is_host_enabled(musb) && drvvbus) { | 332 | } else if (drvvbus) { |
337 | MUSB_HST_MODE(musb); | 333 | MUSB_HST_MODE(musb); |
338 | otg->default_a = 1; | 334 | otg->default_a = 1; |
339 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; | 335 | musb->xceiv->state = OTG_STATE_A_WAIT_VRISE; |
@@ -366,8 +362,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) | |||
366 | musb_writel(tibase, DAVINCI_USB_EOI_REG, 0); | 362 | musb_writel(tibase, DAVINCI_USB_EOI_REG, 0); |
367 | 363 | ||
368 | /* poll for ID change */ | 364 | /* poll for ID change */ |
369 | if (is_otg_enabled(musb) | 365 | if (musb->xceiv->state == OTG_STATE_B_IDLE) |
370 | && musb->xceiv->state == OTG_STATE_B_IDLE) | ||
371 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); | 366 | mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ); |
372 | 367 | ||
373 | spin_unlock_irqrestore(&musb->lock, flags); | 368 | spin_unlock_irqrestore(&musb->lock, flags); |
@@ -398,8 +393,7 @@ static int davinci_musb_init(struct musb *musb) | |||
398 | if (revision == 0) | 393 | if (revision == 0) |
399 | goto fail; | 394 | goto fail; |
400 | 395 | ||
401 | if (is_host_enabled(musb)) | 396 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); |
402 | setup_timer(&otg_workaround, otg_timer, (unsigned long) musb); | ||
403 | 397 | ||
404 | davinci_musb_source_power(musb, 0, 1); | 398 | davinci_musb_source_power(musb, 0, 1); |
405 | 399 | ||
@@ -420,12 +414,7 @@ static int davinci_musb_init(struct musb *musb) | |||
420 | if (cpu_is_davinci_dm355()) { | 414 | if (cpu_is_davinci_dm355()) { |
421 | u32 deepsleep = __raw_readl(DM355_DEEPSLEEP); | 415 | u32 deepsleep = __raw_readl(DM355_DEEPSLEEP); |
422 | 416 | ||
423 | if (is_host_enabled(musb)) { | 417 | deepsleep &= ~DRVVBUS_FORCE; |
424 | deepsleep &= ~DRVVBUS_OVERRIDE; | ||
425 | } else { | ||
426 | deepsleep &= ~DRVVBUS_FORCE; | ||
427 | deepsleep |= DRVVBUS_OVERRIDE; | ||
428 | } | ||
429 | __raw_writel(deepsleep, DM355_DEEPSLEEP); | 418 | __raw_writel(deepsleep, DM355_DEEPSLEEP); |
430 | } | 419 | } |
431 | 420 | ||
@@ -454,8 +443,7 @@ unregister: | |||
454 | 443 | ||
455 | static int davinci_musb_exit(struct musb *musb) | 444 | static int davinci_musb_exit(struct musb *musb) |
456 | { | 445 | { |
457 | if (is_host_enabled(musb)) | 446 | del_timer_sync(&otg_workaround); |
458 | del_timer_sync(&otg_workaround); | ||
459 | 447 | ||
460 | /* force VBUS off */ | 448 | /* force VBUS off */ |
461 | if (cpu_is_davinci_dm355()) { | 449 | if (cpu_is_davinci_dm355()) { |
@@ -469,7 +457,7 @@ static int davinci_musb_exit(struct musb *musb) | |||
469 | davinci_musb_source_power(musb, 0 /*off*/, 1); | 457 | davinci_musb_source_power(musb, 0 /*off*/, 1); |
470 | 458 | ||
471 | /* delay, to avoid problems with module reload */ | 459 | /* delay, to avoid problems with module reload */ |
472 | if (is_host_enabled(musb) && musb->xceiv->otg->default_a) { | 460 | if (musb->xceiv->otg->default_a) { |
473 | int maxdelay = 30; | 461 | int maxdelay = 30; |
474 | u8 devctl, warn = 0; | 462 | u8 devctl, warn = 0; |
475 | 463 | ||
@@ -524,6 +512,7 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
524 | struct clk *clk; | 512 | struct clk *clk; |
525 | 513 | ||
526 | int ret = -ENOMEM; | 514 | int ret = -ENOMEM; |
515 | int musbid; | ||
527 | 516 | ||
528 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); | 517 | glue = kzalloc(sizeof(*glue), GFP_KERNEL); |
529 | if (!glue) { | 518 | if (!glue) { |
@@ -531,25 +520,34 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
531 | goto err0; | 520 | goto err0; |
532 | } | 521 | } |
533 | 522 | ||
534 | musb = platform_device_alloc("musb-hdrc", -1); | 523 | /* get the musb id */ |
524 | musbid = musb_get_id(&pdev->dev, GFP_KERNEL); | ||
525 | if (musbid < 0) { | ||
526 | dev_err(&pdev->dev, "failed to allocate musb id\n"); | ||
527 | ret = -ENOMEM; | ||
528 | goto err1; | ||
529 | } | ||
530 | |||
531 | musb = platform_device_alloc("musb-hdrc", musbid); | ||
535 | if (!musb) { | 532 | if (!musb) { |
536 | dev_err(&pdev->dev, "failed to allocate musb device\n"); | 533 | dev_err(&pdev->dev, "failed to allocate musb device\n"); |
537 | goto err1; | 534 | goto err2; |
538 | } | 535 | } |
539 | 536 | ||
540 | clk = clk_get(&pdev->dev, "usb"); | 537 | clk = clk_get(&pdev->dev, "usb"); |
541 | if (IS_ERR(clk)) { | 538 | if (IS_ERR(clk)) { |
542 | dev_err(&pdev->dev, "failed to get clock\n"); | 539 | dev_err(&pdev->dev, "failed to get clock\n"); |
543 | ret = PTR_ERR(clk); | 540 | ret = PTR_ERR(clk); |
544 | goto err2; | 541 | goto err3; |
545 | } | 542 | } |
546 | 543 | ||
547 | ret = clk_enable(clk); | 544 | ret = clk_enable(clk); |
548 | if (ret) { | 545 | if (ret) { |
549 | dev_err(&pdev->dev, "failed to enable clock\n"); | 546 | dev_err(&pdev->dev, "failed to enable clock\n"); |
550 | goto err3; | 547 | goto err4; |
551 | } | 548 | } |
552 | 549 | ||
550 | musb->id = musbid; | ||
553 | musb->dev.parent = &pdev->dev; | 551 | musb->dev.parent = &pdev->dev; |
554 | musb->dev.dma_mask = &davinci_dmamask; | 552 | musb->dev.dma_mask = &davinci_dmamask; |
555 | musb->dev.coherent_dma_mask = davinci_dmamask; | 553 | musb->dev.coherent_dma_mask = davinci_dmamask; |
@@ -566,32 +564,35 @@ static int __devinit davinci_probe(struct platform_device *pdev) | |||
566 | pdev->num_resources); | 564 | pdev->num_resources); |
567 | if (ret) { | 565 | if (ret) { |
568 | dev_err(&pdev->dev, "failed to add resources\n"); | 566 | dev_err(&pdev->dev, "failed to add resources\n"); |
569 | goto err4; | 567 | goto err5; |
570 | } | 568 | } |
571 | 569 | ||
572 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); | 570 | ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); |
573 | if (ret) { | 571 | if (ret) { |
574 | dev_err(&pdev->dev, "failed to add platform_data\n"); | 572 | dev_err(&pdev->dev, "failed to add platform_data\n"); |
575 | goto err4; | 573 | goto err5; |
576 | } | 574 | } |
577 | 575 | ||
578 | ret = platform_device_add(musb); | 576 | ret = platform_device_add(musb); |
579 | if (ret) { | 577 | if (ret) { |
580 | dev_err(&pdev->dev, "failed to register musb device\n"); | 578 | dev_err(&pdev->dev, "failed to register musb device\n"); |
581 | goto err4; | 579 | goto err5; |
582 | } | 580 | } |
583 | 581 | ||
584 | return 0; | 582 | return 0; |
585 | 583 | ||
586 | err4: | 584 | err5: |
587 | clk_disable(clk); | 585 | clk_disable(clk); |
588 | 586 | ||
589 | err3: | 587 | err4: |
590 | clk_put(clk); | 588 | clk_put(clk); |
591 | 589 | ||
592 | err2: | 590 | err3: |
593 | platform_device_put(musb); | 591 | platform_device_put(musb); |
594 | 592 | ||
593 | err2: | ||
594 | musb_put_id(&pdev->dev, musbid); | ||
595 | |||
595 | err1: | 596 | err1: |
596 | kfree(glue); | 597 | kfree(glue); |
597 | 598 | ||
@@ -603,6 +604,7 @@ static int __devexit davinci_remove(struct platform_device *pdev) | |||
603 | { | 604 | { |
604 | struct davinci_glue *glue = platform_get_drvdata(pdev); | 605 | struct davinci_glue *glue = platform_get_drvdata(pdev); |
605 | 606 | ||
607 | musb_put_id(&pdev->dev, glue->musb->id); | ||
606 | platform_device_del(glue->musb); | 608 | platform_device_del(glue->musb); |
607 | platform_device_put(glue->musb); | 609 | platform_device_put(glue->musb); |
608 | clk_disable(glue->clk); | 610 | clk_disable(glue->clk); |