diff options
Diffstat (limited to 'drivers/usb/host/ehci-tegra.c')
-rw-r--r-- | drivers/usb/host/ehci-tegra.c | 397 |
1 files changed, 207 insertions, 190 deletions
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 3de48a2d7955..99ae5ea3f8d1 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
25 | #include <linux/of.h> | 25 | #include <linux/of.h> |
26 | #include <linux/of_gpio.h> | 26 | #include <linux/of_gpio.h> |
27 | #include <linux/pm_runtime.h> | ||
27 | 28 | ||
28 | #include <mach/usb_phy.h> | 29 | #include <mach/usb_phy.h> |
29 | #include <mach/iomap.h> | 30 | #include <mach/iomap.h> |
@@ -37,9 +38,7 @@ struct tegra_ehci_hcd { | |||
37 | struct clk *emc_clk; | 38 | struct clk *emc_clk; |
38 | struct usb_phy *transceiver; | 39 | struct usb_phy *transceiver; |
39 | int host_resumed; | 40 | int host_resumed; |
40 | int bus_suspended; | ||
41 | int port_resuming; | 41 | int port_resuming; |
42 | int power_down_on_bus_suspend; | ||
43 | enum tegra_usb_phy_port_speed port_speed; | 42 | enum tegra_usb_phy_port_speed port_speed; |
44 | }; | 43 | }; |
45 | 44 | ||
@@ -224,6 +223,7 @@ static int tegra_ehci_hub_control( | |||
224 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); | 223 | temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); |
225 | /* start resume signalling */ | 224 | /* start resume signalling */ |
226 | ehci_writel(ehci, temp | PORT_RESUME, status_reg); | 225 | ehci_writel(ehci, temp | PORT_RESUME, status_reg); |
226 | set_bit(wIndex-1, &ehci->resuming_ports); | ||
227 | 227 | ||
228 | spin_unlock_irqrestore(&ehci->lock, flags); | 228 | spin_unlock_irqrestore(&ehci->lock, flags); |
229 | msleep(20); | 229 | msleep(20); |
@@ -236,6 +236,7 @@ static int tegra_ehci_hub_control( | |||
236 | pr_err("%s: timeout waiting for SUSPEND\n", __func__); | 236 | pr_err("%s: timeout waiting for SUSPEND\n", __func__); |
237 | 237 | ||
238 | ehci->reset_done[wIndex-1] = 0; | 238 | ehci->reset_done[wIndex-1] = 0; |
239 | clear_bit(wIndex-1, &ehci->resuming_ports); | ||
239 | 240 | ||
240 | tegra->port_resuming = 1; | 241 | tegra->port_resuming = 1; |
241 | goto done; | 242 | goto done; |
@@ -271,120 +272,6 @@ static void tegra_ehci_restart(struct usb_hcd *hcd) | |||
271 | up_write(&ehci_cf_port_reset_rwsem); | 272 | up_write(&ehci_cf_port_reset_rwsem); |
272 | } | 273 | } |
273 | 274 | ||
274 | static int tegra_usb_suspend(struct usb_hcd *hcd) | ||
275 | { | ||
276 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
277 | struct ehci_regs __iomem *hw = tegra->ehci->regs; | ||
278 | unsigned long flags; | ||
279 | |||
280 | spin_lock_irqsave(&tegra->ehci->lock, flags); | ||
281 | |||
282 | tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3; | ||
283 | ehci_halt(tegra->ehci); | ||
284 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
285 | |||
286 | spin_unlock_irqrestore(&tegra->ehci->lock, flags); | ||
287 | |||
288 | tegra_ehci_power_down(hcd); | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int tegra_usb_resume(struct usb_hcd *hcd) | ||
293 | { | ||
294 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
295 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
296 | struct ehci_regs __iomem *hw = ehci->regs; | ||
297 | unsigned long val; | ||
298 | |||
299 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
300 | tegra_ehci_power_up(hcd); | ||
301 | |||
302 | if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) { | ||
303 | /* Wait for the phy to detect new devices | ||
304 | * before we restart the controller */ | ||
305 | msleep(10); | ||
306 | goto restart; | ||
307 | } | ||
308 | |||
309 | /* Force the phy to keep data lines in suspend state */ | ||
310 | tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed); | ||
311 | |||
312 | /* Enable host mode */ | ||
313 | tdi_reset(ehci); | ||
314 | |||
315 | /* Enable Port Power */ | ||
316 | val = readl(&hw->port_status[0]); | ||
317 | val |= PORT_POWER; | ||
318 | writel(val, &hw->port_status[0]); | ||
319 | udelay(10); | ||
320 | |||
321 | /* Check if the phy resume from LP0. When the phy resume from LP0 | ||
322 | * USB register will be reset. */ | ||
323 | if (!readl(&hw->async_next)) { | ||
324 | /* Program the field PTC based on the saved speed mode */ | ||
325 | val = readl(&hw->port_status[0]); | ||
326 | val &= ~PORT_TEST(~0); | ||
327 | if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
328 | val |= PORT_TEST_FORCE; | ||
329 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL) | ||
330 | val |= PORT_TEST(6); | ||
331 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW) | ||
332 | val |= PORT_TEST(7); | ||
333 | writel(val, &hw->port_status[0]); | ||
334 | udelay(10); | ||
335 | |||
336 | /* Disable test mode by setting PTC field to NORMAL_OP */ | ||
337 | val = readl(&hw->port_status[0]); | ||
338 | val &= ~PORT_TEST(~0); | ||
339 | writel(val, &hw->port_status[0]); | ||
340 | udelay(10); | ||
341 | } | ||
342 | |||
343 | /* Poll until CCS is enabled */ | ||
344 | if (handshake(ehci, &hw->port_status[0], PORT_CONNECT, | ||
345 | PORT_CONNECT, 2000)) { | ||
346 | pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__); | ||
347 | goto restart; | ||
348 | } | ||
349 | |||
350 | /* Poll until PE is enabled */ | ||
351 | if (handshake(ehci, &hw->port_status[0], PORT_PE, | ||
352 | PORT_PE, 2000)) { | ||
353 | pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__); | ||
354 | goto restart; | ||
355 | } | ||
356 | |||
357 | /* Clear the PCI status, to avoid an interrupt taken upon resume */ | ||
358 | val = readl(&hw->status); | ||
359 | val |= STS_PCD; | ||
360 | writel(val, &hw->status); | ||
361 | |||
362 | /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */ | ||
363 | val = readl(&hw->port_status[0]); | ||
364 | if ((val & PORT_POWER) && (val & PORT_PE)) { | ||
365 | val |= PORT_SUSPEND; | ||
366 | writel(val, &hw->port_status[0]); | ||
367 | |||
368 | /* Wait until port suspend completes */ | ||
369 | if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND, | ||
370 | PORT_SUSPEND, 1000)) { | ||
371 | pr_err("%s: timeout waiting for PORT_SUSPEND\n", | ||
372 | __func__); | ||
373 | goto restart; | ||
374 | } | ||
375 | } | ||
376 | |||
377 | tegra_ehci_phy_restore_end(tegra->phy); | ||
378 | return 0; | ||
379 | |||
380 | restart: | ||
381 | if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
382 | tegra_ehci_phy_restore_end(tegra->phy); | ||
383 | |||
384 | tegra_ehci_restart(hcd); | ||
385 | return 0; | ||
386 | } | ||
387 | |||
388 | static void tegra_ehci_shutdown(struct usb_hcd *hcd) | 275 | static void tegra_ehci_shutdown(struct usb_hcd *hcd) |
389 | { | 276 | { |
390 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | 277 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); |
@@ -432,36 +319,6 @@ static int tegra_ehci_setup(struct usb_hcd *hcd) | |||
432 | return retval; | 319 | return retval; |
433 | } | 320 | } |
434 | 321 | ||
435 | #ifdef CONFIG_PM | ||
436 | static int tegra_ehci_bus_suspend(struct usb_hcd *hcd) | ||
437 | { | ||
438 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
439 | int error_status = 0; | ||
440 | |||
441 | error_status = ehci_bus_suspend(hcd); | ||
442 | if (!error_status && tegra->power_down_on_bus_suspend) { | ||
443 | tegra_usb_suspend(hcd); | ||
444 | tegra->bus_suspended = 1; | ||
445 | } | ||
446 | |||
447 | return error_status; | ||
448 | } | ||
449 | |||
450 | static int tegra_ehci_bus_resume(struct usb_hcd *hcd) | ||
451 | { | ||
452 | struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller); | ||
453 | |||
454 | if (tegra->bus_suspended && tegra->power_down_on_bus_suspend) { | ||
455 | tegra_usb_resume(hcd); | ||
456 | tegra->bus_suspended = 0; | ||
457 | } | ||
458 | |||
459 | tegra_usb_phy_preresume(tegra->phy); | ||
460 | tegra->port_resuming = 1; | ||
461 | return ehci_bus_resume(hcd); | ||
462 | } | ||
463 | #endif | ||
464 | |||
465 | struct temp_buffer { | 322 | struct temp_buffer { |
466 | void *kmalloc_ptr; | 323 | void *kmalloc_ptr; |
467 | void *old_xfer_buffer; | 324 | void *old_xfer_buffer; |
@@ -572,22 +429,23 @@ static const struct hc_driver tegra_ehci_hc_driver = { | |||
572 | .hub_control = tegra_ehci_hub_control, | 429 | .hub_control = tegra_ehci_hub_control, |
573 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | 430 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, |
574 | #ifdef CONFIG_PM | 431 | #ifdef CONFIG_PM |
575 | .bus_suspend = tegra_ehci_bus_suspend, | 432 | .bus_suspend = ehci_bus_suspend, |
576 | .bus_resume = tegra_ehci_bus_resume, | 433 | .bus_resume = ehci_bus_resume, |
577 | #endif | 434 | #endif |
578 | .relinquish_port = ehci_relinquish_port, | 435 | .relinquish_port = ehci_relinquish_port, |
579 | .port_handed_over = ehci_port_handed_over, | 436 | .port_handed_over = ehci_port_handed_over, |
580 | }; | 437 | }; |
581 | 438 | ||
582 | static int setup_vbus_gpio(struct platform_device *pdev) | 439 | static int setup_vbus_gpio(struct platform_device *pdev, |
440 | struct tegra_ehci_platform_data *pdata) | ||
583 | { | 441 | { |
584 | int err = 0; | 442 | int err = 0; |
585 | int gpio; | 443 | int gpio; |
586 | 444 | ||
587 | if (!pdev->dev.of_node) | 445 | gpio = pdata->vbus_gpio; |
588 | return 0; | 446 | if (!gpio_is_valid(gpio)) |
589 | 447 | gpio = of_get_named_gpio(pdev->dev.of_node, | |
590 | gpio = of_get_named_gpio(pdev->dev.of_node, "nvidia,vbus-gpio", 0); | 448 | "nvidia,vbus-gpio", 0); |
591 | if (!gpio_is_valid(gpio)) | 449 | if (!gpio_is_valid(gpio)) |
592 | return 0; | 450 | return 0; |
593 | 451 | ||
@@ -601,11 +459,187 @@ static int setup_vbus_gpio(struct platform_device *pdev) | |||
601 | dev_err(&pdev->dev, "can't enable vbus\n"); | 459 | dev_err(&pdev->dev, "can't enable vbus\n"); |
602 | return err; | 460 | return err; |
603 | } | 461 | } |
604 | gpio_set_value(gpio, 1); | ||
605 | 462 | ||
606 | return err; | 463 | return err; |
607 | } | 464 | } |
608 | 465 | ||
466 | #ifdef CONFIG_PM | ||
467 | |||
468 | static int controller_suspend(struct device *dev) | ||
469 | { | ||
470 | struct tegra_ehci_hcd *tegra = | ||
471 | platform_get_drvdata(to_platform_device(dev)); | ||
472 | struct ehci_hcd *ehci = tegra->ehci; | ||
473 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | ||
474 | struct ehci_regs __iomem *hw = ehci->regs; | ||
475 | unsigned long flags; | ||
476 | |||
477 | if (time_before(jiffies, ehci->next_statechange)) | ||
478 | msleep(10); | ||
479 | |||
480 | spin_lock_irqsave(&ehci->lock, flags); | ||
481 | |||
482 | tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3; | ||
483 | ehci_halt(ehci); | ||
484 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
485 | |||
486 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
487 | |||
488 | tegra_ehci_power_down(hcd); | ||
489 | return 0; | ||
490 | } | ||
491 | |||
492 | static int controller_resume(struct device *dev) | ||
493 | { | ||
494 | struct tegra_ehci_hcd *tegra = | ||
495 | platform_get_drvdata(to_platform_device(dev)); | ||
496 | struct ehci_hcd *ehci = tegra->ehci; | ||
497 | struct usb_hcd *hcd = ehci_to_hcd(ehci); | ||
498 | struct ehci_regs __iomem *hw = ehci->regs; | ||
499 | unsigned long val; | ||
500 | |||
501 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
502 | tegra_ehci_power_up(hcd); | ||
503 | |||
504 | if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) { | ||
505 | /* Wait for the phy to detect new devices | ||
506 | * before we restart the controller */ | ||
507 | msleep(10); | ||
508 | goto restart; | ||
509 | } | ||
510 | |||
511 | /* Force the phy to keep data lines in suspend state */ | ||
512 | tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed); | ||
513 | |||
514 | /* Enable host mode */ | ||
515 | tdi_reset(ehci); | ||
516 | |||
517 | /* Enable Port Power */ | ||
518 | val = readl(&hw->port_status[0]); | ||
519 | val |= PORT_POWER; | ||
520 | writel(val, &hw->port_status[0]); | ||
521 | udelay(10); | ||
522 | |||
523 | /* Check if the phy resume from LP0. When the phy resume from LP0 | ||
524 | * USB register will be reset. */ | ||
525 | if (!readl(&hw->async_next)) { | ||
526 | /* Program the field PTC based on the saved speed mode */ | ||
527 | val = readl(&hw->port_status[0]); | ||
528 | val &= ~PORT_TEST(~0); | ||
529 | if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
530 | val |= PORT_TEST_FORCE; | ||
531 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL) | ||
532 | val |= PORT_TEST(6); | ||
533 | else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW) | ||
534 | val |= PORT_TEST(7); | ||
535 | writel(val, &hw->port_status[0]); | ||
536 | udelay(10); | ||
537 | |||
538 | /* Disable test mode by setting PTC field to NORMAL_OP */ | ||
539 | val = readl(&hw->port_status[0]); | ||
540 | val &= ~PORT_TEST(~0); | ||
541 | writel(val, &hw->port_status[0]); | ||
542 | udelay(10); | ||
543 | } | ||
544 | |||
545 | /* Poll until CCS is enabled */ | ||
546 | if (handshake(ehci, &hw->port_status[0], PORT_CONNECT, | ||
547 | PORT_CONNECT, 2000)) { | ||
548 | pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__); | ||
549 | goto restart; | ||
550 | } | ||
551 | |||
552 | /* Poll until PE is enabled */ | ||
553 | if (handshake(ehci, &hw->port_status[0], PORT_PE, | ||
554 | PORT_PE, 2000)) { | ||
555 | pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__); | ||
556 | goto restart; | ||
557 | } | ||
558 | |||
559 | /* Clear the PCI status, to avoid an interrupt taken upon resume */ | ||
560 | val = readl(&hw->status); | ||
561 | val |= STS_PCD; | ||
562 | writel(val, &hw->status); | ||
563 | |||
564 | /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */ | ||
565 | val = readl(&hw->port_status[0]); | ||
566 | if ((val & PORT_POWER) && (val & PORT_PE)) { | ||
567 | val |= PORT_SUSPEND; | ||
568 | writel(val, &hw->port_status[0]); | ||
569 | |||
570 | /* Wait until port suspend completes */ | ||
571 | if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND, | ||
572 | PORT_SUSPEND, 1000)) { | ||
573 | pr_err("%s: timeout waiting for PORT_SUSPEND\n", | ||
574 | __func__); | ||
575 | goto restart; | ||
576 | } | ||
577 | } | ||
578 | |||
579 | tegra_ehci_phy_restore_end(tegra->phy); | ||
580 | goto done; | ||
581 | |||
582 | restart: | ||
583 | if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH) | ||
584 | tegra_ehci_phy_restore_end(tegra->phy); | ||
585 | |||
586 | tegra_ehci_restart(hcd); | ||
587 | |||
588 | done: | ||
589 | tegra_usb_phy_preresume(tegra->phy); | ||
590 | tegra->port_resuming = 1; | ||
591 | return 0; | ||
592 | } | ||
593 | |||
594 | static int tegra_ehci_suspend(struct device *dev) | ||
595 | { | ||
596 | struct tegra_ehci_hcd *tegra = | ||
597 | platform_get_drvdata(to_platform_device(dev)); | ||
598 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
599 | int rc = 0; | ||
600 | |||
601 | /* | ||
602 | * When system sleep is supported and USB controller wakeup is | ||
603 | * implemented: If the controller is runtime-suspended and the | ||
604 | * wakeup setting needs to be changed, call pm_runtime_resume(). | ||
605 | */ | ||
606 | if (HCD_HW_ACCESSIBLE(hcd)) | ||
607 | rc = controller_suspend(dev); | ||
608 | return rc; | ||
609 | } | ||
610 | |||
611 | static int tegra_ehci_resume(struct device *dev) | ||
612 | { | ||
613 | int rc; | ||
614 | |||
615 | rc = controller_resume(dev); | ||
616 | if (rc == 0) { | ||
617 | pm_runtime_disable(dev); | ||
618 | pm_runtime_set_active(dev); | ||
619 | pm_runtime_enable(dev); | ||
620 | } | ||
621 | return rc; | ||
622 | } | ||
623 | |||
624 | static int tegra_ehci_runtime_suspend(struct device *dev) | ||
625 | { | ||
626 | return controller_suspend(dev); | ||
627 | } | ||
628 | |||
629 | static int tegra_ehci_runtime_resume(struct device *dev) | ||
630 | { | ||
631 | return controller_resume(dev); | ||
632 | } | ||
633 | |||
634 | static const struct dev_pm_ops tegra_ehci_pm_ops = { | ||
635 | .suspend = tegra_ehci_suspend, | ||
636 | .resume = tegra_ehci_resume, | ||
637 | .runtime_suspend = tegra_ehci_runtime_suspend, | ||
638 | .runtime_resume = tegra_ehci_runtime_resume, | ||
639 | }; | ||
640 | |||
641 | #endif | ||
642 | |||
609 | static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32); | 643 | static u64 tegra_ehci_dma_mask = DMA_BIT_MASK(32); |
610 | 644 | ||
611 | static int tegra_ehci_probe(struct platform_device *pdev) | 645 | static int tegra_ehci_probe(struct platform_device *pdev) |
@@ -631,7 +665,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
631 | if (!pdev->dev.dma_mask) | 665 | if (!pdev->dev.dma_mask) |
632 | pdev->dev.dma_mask = &tegra_ehci_dma_mask; | 666 | pdev->dev.dma_mask = &tegra_ehci_dma_mask; |
633 | 667 | ||
634 | setup_vbus_gpio(pdev); | 668 | setup_vbus_gpio(pdev, pdata); |
635 | 669 | ||
636 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); | 670 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); |
637 | if (!tegra) | 671 | if (!tegra) |
@@ -705,8 +739,9 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
705 | } | 739 | } |
706 | } | 740 | } |
707 | 741 | ||
708 | tegra->phy = tegra_usb_phy_open(instance, hcd->regs, pdata->phy_config, | 742 | tegra->phy = tegra_usb_phy_open(&pdev->dev, instance, hcd->regs, |
709 | TEGRA_USB_PHY_MODE_HOST); | 743 | pdata->phy_config, |
744 | TEGRA_USB_PHY_MODE_HOST); | ||
710 | if (IS_ERR(tegra->phy)) { | 745 | if (IS_ERR(tegra->phy)) { |
711 | dev_err(&pdev->dev, "Failed to open USB phy\n"); | 746 | dev_err(&pdev->dev, "Failed to open USB phy\n"); |
712 | err = -ENXIO; | 747 | err = -ENXIO; |
@@ -720,7 +755,6 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
720 | } | 755 | } |
721 | 756 | ||
722 | tegra->host_resumed = 1; | 757 | tegra->host_resumed = 1; |
723 | tegra->power_down_on_bus_suspend = pdata->power_down_on_bus_suspend; | ||
724 | tegra->ehci = hcd_to_ehci(hcd); | 758 | tegra->ehci = hcd_to_ehci(hcd); |
725 | 759 | ||
726 | irq = platform_get_irq(pdev, 0); | 760 | irq = platform_get_irq(pdev, 0); |
@@ -729,7 +763,6 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
729 | err = -ENODEV; | 763 | err = -ENODEV; |
730 | goto fail; | 764 | goto fail; |
731 | } | 765 | } |
732 | set_irq_flags(irq, IRQF_VALID); | ||
733 | 766 | ||
734 | #ifdef CONFIG_USB_OTG_UTILS | 767 | #ifdef CONFIG_USB_OTG_UTILS |
735 | if (pdata->operating_mode == TEGRA_USB_OTG) { | 768 | if (pdata->operating_mode == TEGRA_USB_OTG) { |
@@ -745,6 +778,14 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
745 | goto fail; | 778 | goto fail; |
746 | } | 779 | } |
747 | 780 | ||
781 | pm_runtime_set_active(&pdev->dev); | ||
782 | pm_runtime_get_noresume(&pdev->dev); | ||
783 | |||
784 | /* Don't skip the pm_runtime_forbid call if wakeup isn't working */ | ||
785 | /* if (!pdata->power_down_on_bus_suspend) */ | ||
786 | pm_runtime_forbid(&pdev->dev); | ||
787 | pm_runtime_enable(&pdev->dev); | ||
788 | pm_runtime_put_sync(&pdev->dev); | ||
748 | return err; | 789 | return err; |
749 | 790 | ||
750 | fail: | 791 | fail: |
@@ -771,33 +812,6 @@ fail_hcd: | |||
771 | return err; | 812 | return err; |
772 | } | 813 | } |
773 | 814 | ||
774 | #ifdef CONFIG_PM | ||
775 | static int tegra_ehci_resume(struct platform_device *pdev) | ||
776 | { | ||
777 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | ||
778 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
779 | |||
780 | if (tegra->bus_suspended) | ||
781 | return 0; | ||
782 | |||
783 | return tegra_usb_resume(hcd); | ||
784 | } | ||
785 | |||
786 | static int tegra_ehci_suspend(struct platform_device *pdev, pm_message_t state) | ||
787 | { | ||
788 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | ||
789 | struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci); | ||
790 | |||
791 | if (tegra->bus_suspended) | ||
792 | return 0; | ||
793 | |||
794 | if (time_before(jiffies, tegra->ehci->next_statechange)) | ||
795 | msleep(10); | ||
796 | |||
797 | return tegra_usb_suspend(hcd); | ||
798 | } | ||
799 | #endif | ||
800 | |||
801 | static int tegra_ehci_remove(struct platform_device *pdev) | 815 | static int tegra_ehci_remove(struct platform_device *pdev) |
802 | { | 816 | { |
803 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); | 817 | struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev); |
@@ -806,6 +820,10 @@ static int tegra_ehci_remove(struct platform_device *pdev) | |||
806 | if (tegra == NULL || hcd == NULL) | 820 | if (tegra == NULL || hcd == NULL) |
807 | return -EINVAL; | 821 | return -EINVAL; |
808 | 822 | ||
823 | pm_runtime_get_sync(&pdev->dev); | ||
824 | pm_runtime_disable(&pdev->dev); | ||
825 | pm_runtime_put_noidle(&pdev->dev); | ||
826 | |||
809 | #ifdef CONFIG_USB_OTG_UTILS | 827 | #ifdef CONFIG_USB_OTG_UTILS |
810 | if (tegra->transceiver) { | 828 | if (tegra->transceiver) { |
811 | otg_set_host(tegra->transceiver->otg, NULL); | 829 | otg_set_host(tegra->transceiver->otg, NULL); |
@@ -846,13 +864,12 @@ static struct of_device_id tegra_ehci_of_match[] __devinitdata = { | |||
846 | static struct platform_driver tegra_ehci_driver = { | 864 | static struct platform_driver tegra_ehci_driver = { |
847 | .probe = tegra_ehci_probe, | 865 | .probe = tegra_ehci_probe, |
848 | .remove = tegra_ehci_remove, | 866 | .remove = tegra_ehci_remove, |
849 | #ifdef CONFIG_PM | ||
850 | .suspend = tegra_ehci_suspend, | ||
851 | .resume = tegra_ehci_resume, | ||
852 | #endif | ||
853 | .shutdown = tegra_ehci_hcd_shutdown, | 867 | .shutdown = tegra_ehci_hcd_shutdown, |
854 | .driver = { | 868 | .driver = { |
855 | .name = "tegra-ehci", | 869 | .name = "tegra-ehci", |
856 | .of_match_table = tegra_ehci_of_match, | 870 | .of_match_table = tegra_ehci_of_match, |
871 | #ifdef CONFIG_PM | ||
872 | .pm = &tegra_ehci_pm_ops, | ||
873 | #endif | ||
857 | } | 874 | } |
858 | }; | 875 | }; |