2 * EHCI-compliant USB host controller driver for NVIDIA Tegra SoCs
4 * Copyright (C) 2010 Google, Inc.
5 * Copyright (C) 2009 NVIDIA Corporation
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 #include <linux/clk.h>
20 #include <linux/err.h>
21 #include <linux/platform_device.h>
22 #include <linux/platform_data/tegra_usb.h>
23 #include <linux/irq.h>
24 #include <linux/usb/otg.h>
25 #include <linux/gpio.h>
27 #include <linux/of_gpio.h>
28 #include <linux/pm_runtime.h>
30 #include <mach/usb_phy.h>
31 #include <mach/iomap.h>
33 #define TEGRA_USB_DMA_ALIGN 32
35 struct tegra_ehci_hcd
{
36 struct ehci_hcd
*ehci
;
37 struct tegra_usb_phy
*phy
;
40 struct usb_phy
*transceiver
;
43 enum tegra_usb_phy_port_speed port_speed
;
46 static void tegra_ehci_power_up(struct usb_hcd
*hcd
)
48 struct tegra_ehci_hcd
*tegra
= dev_get_drvdata(hcd
->self
.controller
);
50 clk_prepare_enable(tegra
->emc_clk
);
51 clk_prepare_enable(tegra
->clk
);
52 tegra_usb_phy_power_on(tegra
->phy
);
53 tegra
->host_resumed
= 1;
56 static void tegra_ehci_power_down(struct usb_hcd
*hcd
)
58 struct tegra_ehci_hcd
*tegra
= dev_get_drvdata(hcd
->self
.controller
);
60 tegra
->host_resumed
= 0;
61 tegra_usb_phy_power_off(tegra
->phy
);
62 clk_disable_unprepare(tegra
->clk
);
63 clk_disable_unprepare(tegra
->emc_clk
);
66 static int tegra_ehci_internal_port_reset(
67 struct ehci_hcd
*ehci
,
68 u32 __iomem
*portsc_reg
77 spin_lock_irqsave(&ehci
->lock
, flags
);
78 saved_usbintr
= ehci_readl(ehci
, &ehci
->regs
->intr_enable
);
79 /* disable USB interrupt */
80 ehci_writel(ehci
, 0, &ehci
->regs
->intr_enable
);
81 spin_unlock_irqrestore(&ehci
->lock
, flags
);
84 * Here we have to do Port Reset at most twice for
85 * Port Enable bit to be set.
87 for (i
= 0; i
< 2; i
++) {
88 temp
= ehci_readl(ehci
, portsc_reg
);
90 ehci_writel(ehci
, temp
, portsc_reg
);
93 ehci_writel(ehci
, temp
, portsc_reg
);
99 * Up to this point, Port Enable bit is
100 * expected to be set after 2 ms waiting.
101 * USB1 usually takes extra 45 ms, for safety,
102 * we take 100 ms as timeout.
104 temp
= ehci_readl(ehci
, portsc_reg
);
105 } while (!(temp
& PORT_PE
) && tries
--);
113 * Clear Connect Status Change bit if it's set.
114 * We can't clear PORT_PEC. It will also cause PORT_PE to be cleared.
117 ehci_writel(ehci
, PORT_CSC
, portsc_reg
);
120 * Write to clear any interrupt status bits that might be set
123 temp
= ehci_readl(ehci
, &ehci
->regs
->status
);
124 ehci_writel(ehci
, temp
, &ehci
->regs
->status
);
126 /* restore original interrupt enable bits */
127 ehci_writel(ehci
, saved_usbintr
, &ehci
->regs
->intr_enable
);
131 static int tegra_ehci_hub_control(
140 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
141 struct tegra_ehci_hcd
*tegra
= dev_get_drvdata(hcd
->self
.controller
);
142 u32 __iomem
*status_reg
;
147 status_reg
= &ehci
->regs
->port_status
[(wIndex
& 0xff) - 1];
149 spin_lock_irqsave(&ehci
->lock
, flags
);
151 if (typeReq
== GetPortStatus
) {
152 temp
= ehci_readl(ehci
, status_reg
);
153 if (tegra
->port_resuming
&& !(temp
& PORT_SUSPEND
)) {
154 /* Resume completed, re-enable disconnect detection */
155 tegra
->port_resuming
= 0;
156 tegra_usb_phy_postresume(tegra
->phy
);
160 else if (typeReq
== SetPortFeature
&& wValue
== USB_PORT_FEAT_SUSPEND
) {
161 temp
= ehci_readl(ehci
, status_reg
);
162 if ((temp
& PORT_PE
) == 0 || (temp
& PORT_RESET
) != 0) {
167 temp
&= ~(PORT_RWC_BITS
| PORT_WKCONN_E
);
168 temp
|= PORT_WKDISC_E
| PORT_WKOC_E
;
169 ehci_writel(ehci
, temp
| PORT_SUSPEND
, status_reg
);
172 * If a transaction is in progress, there may be a delay in
173 * suspending the port. Poll until the port is suspended.
175 if (handshake(ehci
, status_reg
, PORT_SUSPEND
,
177 pr_err("%s: timeout waiting for SUSPEND\n", __func__
);
179 set_bit((wIndex
& 0xff) - 1, &ehci
->suspended_ports
);
183 /* For USB1 port we need to issue Port Reset twice internally */
184 if (tegra
->phy
->instance
== 0 &&
185 (typeReq
== SetPortFeature
&& wValue
== USB_PORT_FEAT_RESET
)) {
186 spin_unlock_irqrestore(&ehci
->lock
, flags
);
187 return tegra_ehci_internal_port_reset(ehci
, status_reg
);
191 * Tegra host controller will time the resume operation to clear the bit
192 * when the port control state switches to HS or FS Idle. This behavior
193 * is different from EHCI where the host controller driver is required
194 * to set this bit to a zero after the resume duration is timed in the
197 else if (typeReq
== ClearPortFeature
&&
198 wValue
== USB_PORT_FEAT_SUSPEND
) {
199 temp
= ehci_readl(ehci
, status_reg
);
200 if ((temp
& PORT_RESET
) || !(temp
& PORT_PE
)) {
205 if (!(temp
& PORT_SUSPEND
))
208 /* Disable disconnect detection during port resume */
209 tegra_usb_phy_preresume(tegra
->phy
);
211 ehci
->reset_done
[wIndex
-1] = jiffies
+ msecs_to_jiffies(25);
213 temp
&= ~(PORT_RWC_BITS
| PORT_WAKE_BITS
);
214 /* start resume signalling */
215 ehci_writel(ehci
, temp
| PORT_RESUME
, status_reg
);
216 set_bit(wIndex
-1, &ehci
->resuming_ports
);
218 spin_unlock_irqrestore(&ehci
->lock
, flags
);
220 spin_lock_irqsave(&ehci
->lock
, flags
);
222 /* Poll until the controller clears RESUME and SUSPEND */
223 if (handshake(ehci
, status_reg
, PORT_RESUME
, 0, 2000))
224 pr_err("%s: timeout waiting for RESUME\n", __func__
);
225 if (handshake(ehci
, status_reg
, PORT_SUSPEND
, 0, 2000))
226 pr_err("%s: timeout waiting for SUSPEND\n", __func__
);
228 ehci
->reset_done
[wIndex
-1] = 0;
229 clear_bit(wIndex
-1, &ehci
->resuming_ports
);
231 tegra
->port_resuming
= 1;
235 spin_unlock_irqrestore(&ehci
->lock
, flags
);
237 /* Handle the hub control events here */
238 return ehci_hub_control(hcd
, typeReq
, wValue
, wIndex
, buf
, wLength
);
240 spin_unlock_irqrestore(&ehci
->lock
, flags
);
244 static void tegra_ehci_restart(struct usb_hcd
*hcd
)
246 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
250 /* setup the frame list and Async q heads */
251 ehci_writel(ehci
, ehci
->periodic_dma
, &ehci
->regs
->frame_list
);
252 ehci_writel(ehci
, (u32
)ehci
->async
->qh_dma
, &ehci
->regs
->async_next
);
253 /* setup the command register and set the controller in RUN mode */
254 ehci
->command
&= ~(CMD_LRESET
|CMD_IAAD
|CMD_PSE
|CMD_ASE
|CMD_RESET
);
255 ehci
->command
|= CMD_RUN
;
256 ehci_writel(ehci
, ehci
->command
, &ehci
->regs
->command
);
258 down_write(&ehci_cf_port_reset_rwsem
);
259 ehci_writel(ehci
, FLAG_CF
, &ehci
->regs
->configured_flag
);
260 /* flush posted writes */
261 ehci_readl(ehci
, &ehci
->regs
->command
);
262 up_write(&ehci_cf_port_reset_rwsem
);
265 static void tegra_ehci_shutdown(struct usb_hcd
*hcd
)
267 struct tegra_ehci_hcd
*tegra
= dev_get_drvdata(hcd
->self
.controller
);
269 /* ehci_shutdown touches the USB controller registers, make sure
270 * controller has clocks to it */
271 if (!tegra
->host_resumed
)
272 tegra_ehci_power_up(hcd
);
277 static int tegra_ehci_setup(struct usb_hcd
*hcd
)
279 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
282 /* EHCI registers start at offset 0x100 */
283 ehci
->caps
= hcd
->regs
+ 0x100;
285 /* switch to host mode */
288 retval
= ehci_setup(hcd
);
292 ehci_port_power(ehci
, 1);
296 struct dma_aligned_buffer
{
298 void *old_xfer_buffer
;
302 static void free_dma_aligned_buffer(struct urb
*urb
)
304 struct dma_aligned_buffer
*temp
;
306 if (!(urb
->transfer_flags
& URB_ALIGNED_TEMP_BUFFER
))
309 temp
= container_of(urb
->transfer_buffer
,
310 struct dma_aligned_buffer
, data
);
312 if (usb_urb_dir_in(urb
))
313 memcpy(temp
->old_xfer_buffer
, temp
->data
,
314 urb
->transfer_buffer_length
);
315 urb
->transfer_buffer
= temp
->old_xfer_buffer
;
316 kfree(temp
->kmalloc_ptr
);
318 urb
->transfer_flags
&= ~URB_ALIGNED_TEMP_BUFFER
;
321 static int alloc_dma_aligned_buffer(struct urb
*urb
, gfp_t mem_flags
)
323 struct dma_aligned_buffer
*temp
, *kmalloc_ptr
;
326 if (urb
->num_sgs
|| urb
->sg
||
327 urb
->transfer_buffer_length
== 0 ||
328 !((uintptr_t)urb
->transfer_buffer
& (TEGRA_USB_DMA_ALIGN
- 1)))
331 /* Allocate a buffer with enough padding for alignment */
332 kmalloc_size
= urb
->transfer_buffer_length
+
333 sizeof(struct dma_aligned_buffer
) + TEGRA_USB_DMA_ALIGN
- 1;
335 kmalloc_ptr
= kmalloc(kmalloc_size
, mem_flags
);
339 /* Position our struct dma_aligned_buffer such that data is aligned */
340 temp
= PTR_ALIGN(kmalloc_ptr
+ 1, TEGRA_USB_DMA_ALIGN
) - 1;
341 temp
->kmalloc_ptr
= kmalloc_ptr
;
342 temp
->old_xfer_buffer
= urb
->transfer_buffer
;
343 if (usb_urb_dir_out(urb
))
344 memcpy(temp
->data
, urb
->transfer_buffer
,
345 urb
->transfer_buffer_length
);
346 urb
->transfer_buffer
= temp
->data
;
348 urb
->transfer_flags
|= URB_ALIGNED_TEMP_BUFFER
;
353 static int tegra_ehci_map_urb_for_dma(struct usb_hcd
*hcd
, struct urb
*urb
,
358 ret
= alloc_dma_aligned_buffer(urb
, mem_flags
);
362 ret
= usb_hcd_map_urb_for_dma(hcd
, urb
, mem_flags
);
364 free_dma_aligned_buffer(urb
);
369 static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd
*hcd
, struct urb
*urb
)
371 usb_hcd_unmap_urb_for_dma(hcd
, urb
);
372 free_dma_aligned_buffer(urb
);
375 static const struct hc_driver tegra_ehci_hc_driver
= {
376 .description
= hcd_name
,
377 .product_desc
= "Tegra EHCI Host Controller",
378 .hcd_priv_size
= sizeof(struct ehci_hcd
),
379 .flags
= HCD_USB2
| HCD_MEMORY
,
381 /* standard ehci functions */
385 .urb_enqueue
= ehci_urb_enqueue
,
386 .urb_dequeue
= ehci_urb_dequeue
,
387 .endpoint_disable
= ehci_endpoint_disable
,
388 .endpoint_reset
= ehci_endpoint_reset
,
389 .get_frame_number
= ehci_get_frame
,
390 .hub_status_data
= ehci_hub_status_data
,
391 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
392 .relinquish_port
= ehci_relinquish_port
,
393 .port_handed_over
= ehci_port_handed_over
,
395 /* modified ehci functions for tegra */
396 .reset
= tegra_ehci_setup
,
397 .shutdown
= tegra_ehci_shutdown
,
398 .map_urb_for_dma
= tegra_ehci_map_urb_for_dma
,
399 .unmap_urb_for_dma
= tegra_ehci_unmap_urb_for_dma
,
400 .hub_control
= tegra_ehci_hub_control
,
402 .bus_suspend
= ehci_bus_suspend
,
403 .bus_resume
= ehci_bus_resume
,
407 static int setup_vbus_gpio(struct platform_device
*pdev
,
408 struct tegra_ehci_platform_data
*pdata
)
413 gpio
= pdata
->vbus_gpio
;
414 if (!gpio_is_valid(gpio
))
415 gpio
= of_get_named_gpio(pdev
->dev
.of_node
,
416 "nvidia,vbus-gpio", 0);
417 if (!gpio_is_valid(gpio
))
420 err
= gpio_request(gpio
, "vbus_gpio");
422 dev_err(&pdev
->dev
, "can't request vbus gpio %d", gpio
);
425 err
= gpio_direction_output(gpio
, 1);
427 dev_err(&pdev
->dev
, "can't enable vbus\n");
436 static int controller_suspend(struct device
*dev
)
438 struct tegra_ehci_hcd
*tegra
=
439 platform_get_drvdata(to_platform_device(dev
));
440 struct ehci_hcd
*ehci
= tegra
->ehci
;
441 struct usb_hcd
*hcd
= ehci_to_hcd(ehci
);
442 struct ehci_regs __iomem
*hw
= ehci
->regs
;
445 if (time_before(jiffies
, ehci
->next_statechange
))
450 spin_lock_irqsave(&ehci
->lock
, flags
);
451 tegra
->port_speed
= (readl(&hw
->port_status
[0]) >> 26) & 0x3;
452 clear_bit(HCD_FLAG_HW_ACCESSIBLE
, &hcd
->flags
);
453 spin_unlock_irqrestore(&ehci
->lock
, flags
);
455 tegra_ehci_power_down(hcd
);
459 static int controller_resume(struct device
*dev
)
461 struct tegra_ehci_hcd
*tegra
=
462 platform_get_drvdata(to_platform_device(dev
));
463 struct ehci_hcd
*ehci
= tegra
->ehci
;
464 struct usb_hcd
*hcd
= ehci_to_hcd(ehci
);
465 struct ehci_regs __iomem
*hw
= ehci
->regs
;
468 set_bit(HCD_FLAG_HW_ACCESSIBLE
, &hcd
->flags
);
469 tegra_ehci_power_up(hcd
);
471 if (tegra
->port_speed
> TEGRA_USB_PHY_PORT_SPEED_HIGH
) {
472 /* Wait for the phy to detect new devices
473 * before we restart the controller */
478 /* Force the phy to keep data lines in suspend state */
479 tegra_ehci_phy_restore_start(tegra
->phy
, tegra
->port_speed
);
481 /* Enable host mode */
484 /* Enable Port Power */
485 val
= readl(&hw
->port_status
[0]);
487 writel(val
, &hw
->port_status
[0]);
490 /* Check if the phy resume from LP0. When the phy resume from LP0
491 * USB register will be reset. */
492 if (!readl(&hw
->async_next
)) {
493 /* Program the field PTC based on the saved speed mode */
494 val
= readl(&hw
->port_status
[0]);
495 val
&= ~PORT_TEST(~0);
496 if (tegra
->port_speed
== TEGRA_USB_PHY_PORT_SPEED_HIGH
)
497 val
|= PORT_TEST_FORCE
;
498 else if (tegra
->port_speed
== TEGRA_USB_PHY_PORT_SPEED_FULL
)
500 else if (tegra
->port_speed
== TEGRA_USB_PHY_PORT_SPEED_LOW
)
502 writel(val
, &hw
->port_status
[0]);
505 /* Disable test mode by setting PTC field to NORMAL_OP */
506 val
= readl(&hw
->port_status
[0]);
507 val
&= ~PORT_TEST(~0);
508 writel(val
, &hw
->port_status
[0]);
512 /* Poll until CCS is enabled */
513 if (handshake(ehci
, &hw
->port_status
[0], PORT_CONNECT
,
514 PORT_CONNECT
, 2000)) {
515 pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__
);
519 /* Poll until PE is enabled */
520 if (handshake(ehci
, &hw
->port_status
[0], PORT_PE
,
522 pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__
);
526 /* Clear the PCI status, to avoid an interrupt taken upon resume */
527 val
= readl(&hw
->status
);
529 writel(val
, &hw
->status
);
531 /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */
532 val
= readl(&hw
->port_status
[0]);
533 if ((val
& PORT_POWER
) && (val
& PORT_PE
)) {
535 writel(val
, &hw
->port_status
[0]);
537 /* Wait until port suspend completes */
538 if (handshake(ehci
, &hw
->port_status
[0], PORT_SUSPEND
,
539 PORT_SUSPEND
, 1000)) {
540 pr_err("%s: timeout waiting for PORT_SUSPEND\n",
546 tegra_ehci_phy_restore_end(tegra
->phy
);
550 if (tegra
->port_speed
<= TEGRA_USB_PHY_PORT_SPEED_HIGH
)
551 tegra_ehci_phy_restore_end(tegra
->phy
);
553 tegra_ehci_restart(hcd
);
556 tegra_usb_phy_preresume(tegra
->phy
);
557 tegra
->port_resuming
= 1;
561 static int tegra_ehci_suspend(struct device
*dev
)
563 struct tegra_ehci_hcd
*tegra
=
564 platform_get_drvdata(to_platform_device(dev
));
565 struct usb_hcd
*hcd
= ehci_to_hcd(tegra
->ehci
);
569 * When system sleep is supported and USB controller wakeup is
570 * implemented: If the controller is runtime-suspended and the
571 * wakeup setting needs to be changed, call pm_runtime_resume().
573 if (HCD_HW_ACCESSIBLE(hcd
))
574 rc
= controller_suspend(dev
);
578 static int tegra_ehci_resume(struct device
*dev
)
582 rc
= controller_resume(dev
);
584 pm_runtime_disable(dev
);
585 pm_runtime_set_active(dev
);
586 pm_runtime_enable(dev
);
591 static int tegra_ehci_runtime_suspend(struct device
*dev
)
593 return controller_suspend(dev
);
596 static int tegra_ehci_runtime_resume(struct device
*dev
)
598 return controller_resume(dev
);
601 static const struct dev_pm_ops tegra_ehci_pm_ops
= {
602 .suspend
= tegra_ehci_suspend
,
603 .resume
= tegra_ehci_resume
,
604 .runtime_suspend
= tegra_ehci_runtime_suspend
,
605 .runtime_resume
= tegra_ehci_runtime_resume
,
610 static u64 tegra_ehci_dma_mask
= DMA_BIT_MASK(32);
612 static int tegra_ehci_probe(struct platform_device
*pdev
)
614 struct resource
*res
;
616 struct tegra_ehci_hcd
*tegra
;
617 struct tegra_ehci_platform_data
*pdata
;
620 int instance
= pdev
->id
;
622 pdata
= pdev
->dev
.platform_data
;
624 dev_err(&pdev
->dev
, "Platform data missing\n");
628 /* Right now device-tree probed devices don't get dma_mask set.
629 * Since shared usb code relies on it, set it here for now.
630 * Once we have dma capability bindings this can go away.
632 if (!pdev
->dev
.dma_mask
)
633 pdev
->dev
.dma_mask
= &tegra_ehci_dma_mask
;
635 setup_vbus_gpio(pdev
, pdata
);
637 tegra
= kzalloc(sizeof(struct tegra_ehci_hcd
), GFP_KERNEL
);
641 hcd
= usb_create_hcd(&tegra_ehci_hc_driver
, &pdev
->dev
,
642 dev_name(&pdev
->dev
));
644 dev_err(&pdev
->dev
, "Unable to create HCD\n");
649 platform_set_drvdata(pdev
, tegra
);
651 tegra
->clk
= clk_get(&pdev
->dev
, NULL
);
652 if (IS_ERR(tegra
->clk
)) {
653 dev_err(&pdev
->dev
, "Can't get ehci clock\n");
654 err
= PTR_ERR(tegra
->clk
);
658 err
= clk_prepare_enable(tegra
->clk
);
662 tegra
->emc_clk
= clk_get(&pdev
->dev
, "emc");
663 if (IS_ERR(tegra
->emc_clk
)) {
664 dev_err(&pdev
->dev
, "Can't get emc clock\n");
665 err
= PTR_ERR(tegra
->emc_clk
);
669 clk_prepare_enable(tegra
->emc_clk
);
670 clk_set_rate(tegra
->emc_clk
, 400000000);
672 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
674 dev_err(&pdev
->dev
, "Failed to get I/O memory\n");
678 hcd
->rsrc_start
= res
->start
;
679 hcd
->rsrc_len
= resource_size(res
);
680 hcd
->regs
= ioremap(res
->start
, resource_size(res
));
682 dev_err(&pdev
->dev
, "Failed to remap I/O memory\n");
687 /* This is pretty ugly and needs to be fixed when we do only
688 * device-tree probing. Old code relies on the platform_device
689 * numbering that we lack for device-tree-instantiated devices.
692 switch (res
->start
) {
696 case TEGRA_USB2_BASE
:
699 case TEGRA_USB3_BASE
:
704 dev_err(&pdev
->dev
, "unknown usb instance\n");
709 tegra
->phy
= tegra_usb_phy_open(&pdev
->dev
, instance
, hcd
->regs
,
711 TEGRA_USB_PHY_MODE_HOST
);
712 if (IS_ERR(tegra
->phy
)) {
713 dev_err(&pdev
->dev
, "Failed to open USB phy\n");
718 err
= tegra_usb_phy_power_on(tegra
->phy
);
720 dev_err(&pdev
->dev
, "Failed to power on the phy\n");
724 tegra
->host_resumed
= 1;
725 tegra
->ehci
= hcd_to_ehci(hcd
);
727 irq
= platform_get_irq(pdev
, 0);
729 dev_err(&pdev
->dev
, "Failed to get IRQ\n");
734 #ifdef CONFIG_USB_OTG_UTILS
735 if (pdata
->operating_mode
== TEGRA_USB_OTG
) {
736 tegra
->transceiver
= usb_get_phy(USB_PHY_TYPE_USB2
);
737 if (!IS_ERR_OR_NULL(tegra
->transceiver
))
738 otg_set_host(tegra
->transceiver
->otg
, &hcd
->self
);
742 err
= usb_add_hcd(hcd
, irq
, IRQF_SHARED
);
744 dev_err(&pdev
->dev
, "Failed to add USB HCD\n");
748 pm_runtime_set_active(&pdev
->dev
);
749 pm_runtime_get_noresume(&pdev
->dev
);
751 /* Don't skip the pm_runtime_forbid call if wakeup isn't working */
752 /* if (!pdata->power_down_on_bus_suspend) */
753 pm_runtime_forbid(&pdev
->dev
);
754 pm_runtime_enable(&pdev
->dev
);
755 pm_runtime_put_sync(&pdev
->dev
);
759 #ifdef CONFIG_USB_OTG_UTILS
760 if (!IS_ERR_OR_NULL(tegra
->transceiver
)) {
761 otg_set_host(tegra
->transceiver
->otg
, NULL
);
762 usb_put_phy(tegra
->transceiver
);
765 tegra_usb_phy_close(tegra
->phy
);
769 clk_disable_unprepare(tegra
->emc_clk
);
770 clk_put(tegra
->emc_clk
);
772 clk_disable_unprepare(tegra
->clk
);
782 static int tegra_ehci_remove(struct platform_device
*pdev
)
784 struct tegra_ehci_hcd
*tegra
= platform_get_drvdata(pdev
);
785 struct usb_hcd
*hcd
= ehci_to_hcd(tegra
->ehci
);
787 if (tegra
== NULL
|| hcd
== NULL
)
790 pm_runtime_get_sync(&pdev
->dev
);
791 pm_runtime_disable(&pdev
->dev
);
792 pm_runtime_put_noidle(&pdev
->dev
);
794 #ifdef CONFIG_USB_OTG_UTILS
795 if (!IS_ERR_OR_NULL(tegra
->transceiver
)) {
796 otg_set_host(tegra
->transceiver
->otg
, NULL
);
797 usb_put_phy(tegra
->transceiver
);
803 tegra_usb_phy_close(tegra
->phy
);
808 clk_disable_unprepare(tegra
->clk
);
811 clk_disable_unprepare(tegra
->emc_clk
);
812 clk_put(tegra
->emc_clk
);
818 static void tegra_ehci_hcd_shutdown(struct platform_device
*pdev
)
820 struct tegra_ehci_hcd
*tegra
= platform_get_drvdata(pdev
);
821 struct usb_hcd
*hcd
= ehci_to_hcd(tegra
->ehci
);
823 if (hcd
->driver
->shutdown
)
824 hcd
->driver
->shutdown(hcd
);
827 static struct of_device_id tegra_ehci_of_match
[] __devinitdata
= {
828 { .compatible
= "nvidia,tegra20-ehci", },
832 static struct platform_driver tegra_ehci_driver
= {
833 .probe
= tegra_ehci_probe
,
834 .remove
= tegra_ehci_remove
,
835 .shutdown
= tegra_ehci_hcd_shutdown
,
837 .name
= "tegra-ehci",
838 .of_match_table
= tegra_ehci_of_match
,
840 .pm
= &tegra_ehci_pm_ops
,