sfc: Don't use enums as a bitmask.
[zen-stable.git] / drivers / usb / host / ehci-tegra.c
bloba516af28c29b745c7cf72f225f78bd5914d073e4
1 /*
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
15 * more details.
19 #include <linux/clk.h>
20 #include <linux/platform_device.h>
21 #include <linux/platform_data/tegra_usb.h>
22 #include <linux/irq.h>
23 #include <linux/usb/otg.h>
24 #include <mach/usb_phy.h>
26 #define TEGRA_USB_DMA_ALIGN 32
28 struct tegra_ehci_hcd {
29 struct ehci_hcd *ehci;
30 struct tegra_usb_phy *phy;
31 struct clk *clk;
32 struct clk *emc_clk;
33 struct otg_transceiver *transceiver;
34 int host_resumed;
35 int bus_suspended;
36 int port_resuming;
37 int power_down_on_bus_suspend;
38 enum tegra_usb_phy_port_speed port_speed;
41 static void tegra_ehci_power_up(struct usb_hcd *hcd)
43 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
45 clk_enable(tegra->emc_clk);
46 clk_enable(tegra->clk);
47 tegra_usb_phy_power_on(tegra->phy);
48 tegra->host_resumed = 1;
51 static void tegra_ehci_power_down(struct usb_hcd *hcd)
53 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
55 tegra->host_resumed = 0;
56 tegra_usb_phy_power_off(tegra->phy);
57 clk_disable(tegra->clk);
58 clk_disable(tegra->emc_clk);
61 static int tegra_ehci_hub_control(
62 struct usb_hcd *hcd,
63 u16 typeReq,
64 u16 wValue,
65 u16 wIndex,
66 char *buf,
67 u16 wLength
70 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
71 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
72 u32 __iomem *status_reg;
73 u32 temp;
74 unsigned long flags;
75 int retval = 0;
77 status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1];
79 spin_lock_irqsave(&ehci->lock, flags);
82 * In ehci_hub_control() for USB_PORT_FEAT_ENABLE clears the other bits
83 * that are write on clear, by writing back the register read value, so
84 * USB_PORT_FEAT_ENABLE is handled by masking the set on clear bits
86 if (typeReq == ClearPortFeature && wValue == USB_PORT_FEAT_ENABLE) {
87 temp = ehci_readl(ehci, status_reg) & ~PORT_RWC_BITS;
88 ehci_writel(ehci, temp & ~PORT_PE, status_reg);
89 goto done;
92 else if (typeReq == GetPortStatus) {
93 temp = ehci_readl(ehci, status_reg);
94 if (tegra->port_resuming && !(temp & PORT_SUSPEND)) {
95 /* Resume completed, re-enable disconnect detection */
96 tegra->port_resuming = 0;
97 tegra_usb_phy_postresume(tegra->phy);
101 else if (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_SUSPEND) {
102 temp = ehci_readl(ehci, status_reg);
103 if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) {
104 retval = -EPIPE;
105 goto done;
108 temp &= ~PORT_WKCONN_E;
109 temp |= PORT_WKDISC_E | PORT_WKOC_E;
110 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
113 * If a transaction is in progress, there may be a delay in
114 * suspending the port. Poll until the port is suspended.
116 if (handshake(ehci, status_reg, PORT_SUSPEND,
117 PORT_SUSPEND, 5000))
118 pr_err("%s: timeout waiting for SUSPEND\n", __func__);
120 set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports);
121 goto done;
125 * Tegra host controller will time the resume operation to clear the bit
126 * when the port control state switches to HS or FS Idle. This behavior
127 * is different from EHCI where the host controller driver is required
128 * to set this bit to a zero after the resume duration is timed in the
129 * driver.
131 else if (typeReq == ClearPortFeature &&
132 wValue == USB_PORT_FEAT_SUSPEND) {
133 temp = ehci_readl(ehci, status_reg);
134 if ((temp & PORT_RESET) || !(temp & PORT_PE)) {
135 retval = -EPIPE;
136 goto done;
139 if (!(temp & PORT_SUSPEND))
140 goto done;
142 /* Disable disconnect detection during port resume */
143 tegra_usb_phy_preresume(tegra->phy);
145 ehci->reset_done[wIndex-1] = jiffies + msecs_to_jiffies(25);
147 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
148 /* start resume signalling */
149 ehci_writel(ehci, temp | PORT_RESUME, status_reg);
151 spin_unlock_irqrestore(&ehci->lock, flags);
152 msleep(20);
153 spin_lock_irqsave(&ehci->lock, flags);
155 /* Poll until the controller clears RESUME and SUSPEND */
156 if (handshake(ehci, status_reg, PORT_RESUME, 0, 2000))
157 pr_err("%s: timeout waiting for RESUME\n", __func__);
158 if (handshake(ehci, status_reg, PORT_SUSPEND, 0, 2000))
159 pr_err("%s: timeout waiting for SUSPEND\n", __func__);
161 ehci->reset_done[wIndex-1] = 0;
163 tegra->port_resuming = 1;
164 goto done;
167 spin_unlock_irqrestore(&ehci->lock, flags);
169 /* Handle the hub control events here */
170 return ehci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
171 done:
172 spin_unlock_irqrestore(&ehci->lock, flags);
173 return retval;
176 static void tegra_ehci_restart(struct usb_hcd *hcd)
178 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
180 ehci_reset(ehci);
182 /* setup the frame list and Async q heads */
183 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
184 ehci_writel(ehci, (u32)ehci->async->qh_dma, &ehci->regs->async_next);
185 /* setup the command register and set the controller in RUN mode */
186 ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
187 ehci->command |= CMD_RUN;
188 ehci_writel(ehci, ehci->command, &ehci->regs->command);
190 down_write(&ehci_cf_port_reset_rwsem);
191 ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag);
192 /* flush posted writes */
193 ehci_readl(ehci, &ehci->regs->command);
194 up_write(&ehci_cf_port_reset_rwsem);
197 static int tegra_usb_suspend(struct usb_hcd *hcd)
199 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
200 struct ehci_regs __iomem *hw = tegra->ehci->regs;
201 unsigned long flags;
203 spin_lock_irqsave(&tegra->ehci->lock, flags);
205 tegra->port_speed = (readl(&hw->port_status[0]) >> 26) & 0x3;
206 ehci_halt(tegra->ehci);
207 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
209 spin_unlock_irqrestore(&tegra->ehci->lock, flags);
211 tegra_ehci_power_down(hcd);
212 return 0;
215 static int tegra_usb_resume(struct usb_hcd *hcd)
217 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
218 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
219 struct ehci_regs __iomem *hw = ehci->regs;
220 unsigned long val;
222 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
223 tegra_ehci_power_up(hcd);
225 if (tegra->port_speed > TEGRA_USB_PHY_PORT_SPEED_HIGH) {
226 /* Wait for the phy to detect new devices
227 * before we restart the controller */
228 msleep(10);
229 goto restart;
232 /* Force the phy to keep data lines in suspend state */
233 tegra_ehci_phy_restore_start(tegra->phy, tegra->port_speed);
235 /* Enable host mode */
236 tdi_reset(ehci);
238 /* Enable Port Power */
239 val = readl(&hw->port_status[0]);
240 val |= PORT_POWER;
241 writel(val, &hw->port_status[0]);
242 udelay(10);
244 /* Check if the phy resume from LP0. When the phy resume from LP0
245 * USB register will be reset. */
246 if (!readl(&hw->async_next)) {
247 /* Program the field PTC based on the saved speed mode */
248 val = readl(&hw->port_status[0]);
249 val &= ~PORT_TEST(~0);
250 if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_HIGH)
251 val |= PORT_TEST_FORCE;
252 else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_FULL)
253 val |= PORT_TEST(6);
254 else if (tegra->port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW)
255 val |= PORT_TEST(7);
256 writel(val, &hw->port_status[0]);
257 udelay(10);
259 /* Disable test mode by setting PTC field to NORMAL_OP */
260 val = readl(&hw->port_status[0]);
261 val &= ~PORT_TEST(~0);
262 writel(val, &hw->port_status[0]);
263 udelay(10);
266 /* Poll until CCS is enabled */
267 if (handshake(ehci, &hw->port_status[0], PORT_CONNECT,
268 PORT_CONNECT, 2000)) {
269 pr_err("%s: timeout waiting for PORT_CONNECT\n", __func__);
270 goto restart;
273 /* Poll until PE is enabled */
274 if (handshake(ehci, &hw->port_status[0], PORT_PE,
275 PORT_PE, 2000)) {
276 pr_err("%s: timeout waiting for USB_PORTSC1_PE\n", __func__);
277 goto restart;
280 /* Clear the PCI status, to avoid an interrupt taken upon resume */
281 val = readl(&hw->status);
282 val |= STS_PCD;
283 writel(val, &hw->status);
285 /* Put controller in suspend mode by writing 1 to SUSP bit of PORTSC */
286 val = readl(&hw->port_status[0]);
287 if ((val & PORT_POWER) && (val & PORT_PE)) {
288 val |= PORT_SUSPEND;
289 writel(val, &hw->port_status[0]);
291 /* Wait until port suspend completes */
292 if (handshake(ehci, &hw->port_status[0], PORT_SUSPEND,
293 PORT_SUSPEND, 1000)) {
294 pr_err("%s: timeout waiting for PORT_SUSPEND\n",
295 __func__);
296 goto restart;
300 tegra_ehci_phy_restore_end(tegra->phy);
301 return 0;
303 restart:
304 if (tegra->port_speed <= TEGRA_USB_PHY_PORT_SPEED_HIGH)
305 tegra_ehci_phy_restore_end(tegra->phy);
307 tegra_ehci_restart(hcd);
308 return 0;
311 static void tegra_ehci_shutdown(struct usb_hcd *hcd)
313 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
315 /* ehci_shutdown touches the USB controller registers, make sure
316 * controller has clocks to it */
317 if (!tegra->host_resumed)
318 tegra_ehci_power_up(hcd);
320 ehci_shutdown(hcd);
323 static int tegra_ehci_setup(struct usb_hcd *hcd)
325 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
326 int retval;
328 /* EHCI registers start at offset 0x100 */
329 ehci->caps = hcd->regs + 0x100;
330 ehci->regs = hcd->regs + 0x100 +
331 HC_LENGTH(readl(&ehci->caps->hc_capbase));
333 dbg_hcs_params(ehci, "reset");
334 dbg_hcc_params(ehci, "reset");
336 /* cache this readonly data; minimize chip reads */
337 ehci->hcs_params = readl(&ehci->caps->hcs_params);
339 /* switch to host mode */
340 hcd->has_tt = 1;
341 ehci_reset(ehci);
343 retval = ehci_halt(ehci);
344 if (retval)
345 return retval;
347 /* data structure init */
348 retval = ehci_init(hcd);
349 if (retval)
350 return retval;
352 ehci->sbrn = 0x20;
354 ehci_port_power(ehci, 1);
355 return retval;
358 #ifdef CONFIG_PM
359 static int tegra_ehci_bus_suspend(struct usb_hcd *hcd)
361 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
362 int error_status = 0;
364 error_status = ehci_bus_suspend(hcd);
365 if (!error_status && tegra->power_down_on_bus_suspend) {
366 tegra_usb_suspend(hcd);
367 tegra->bus_suspended = 1;
370 return error_status;
373 static int tegra_ehci_bus_resume(struct usb_hcd *hcd)
375 struct tegra_ehci_hcd *tegra = dev_get_drvdata(hcd->self.controller);
377 if (tegra->bus_suspended && tegra->power_down_on_bus_suspend) {
378 tegra_usb_resume(hcd);
379 tegra->bus_suspended = 0;
382 tegra_usb_phy_preresume(tegra->phy);
383 tegra->port_resuming = 1;
384 return ehci_bus_resume(hcd);
386 #endif
388 struct temp_buffer {
389 void *kmalloc_ptr;
390 void *old_xfer_buffer;
391 u8 data[0];
394 static void free_temp_buffer(struct urb *urb)
396 enum dma_data_direction dir;
397 struct temp_buffer *temp;
399 if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
400 return;
402 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
404 temp = container_of(urb->transfer_buffer, struct temp_buffer,
405 data);
407 if (dir == DMA_FROM_DEVICE)
408 memcpy(temp->old_xfer_buffer, temp->data,
409 urb->transfer_buffer_length);
410 urb->transfer_buffer = temp->old_xfer_buffer;
411 kfree(temp->kmalloc_ptr);
413 urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
416 static int alloc_temp_buffer(struct urb *urb, gfp_t mem_flags)
418 enum dma_data_direction dir;
419 struct temp_buffer *temp, *kmalloc_ptr;
420 size_t kmalloc_size;
422 if (urb->num_sgs || urb->sg ||
423 urb->transfer_buffer_length == 0 ||
424 !((uintptr_t)urb->transfer_buffer & (TEGRA_USB_DMA_ALIGN - 1)))
425 return 0;
427 dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
429 /* Allocate a buffer with enough padding for alignment */
430 kmalloc_size = urb->transfer_buffer_length +
431 sizeof(struct temp_buffer) + TEGRA_USB_DMA_ALIGN - 1;
433 kmalloc_ptr = kmalloc(kmalloc_size, mem_flags);
434 if (!kmalloc_ptr)
435 return -ENOMEM;
437 /* Position our struct temp_buffer such that data is aligned */
438 temp = PTR_ALIGN(kmalloc_ptr + 1, TEGRA_USB_DMA_ALIGN) - 1;
440 temp->kmalloc_ptr = kmalloc_ptr;
441 temp->old_xfer_buffer = urb->transfer_buffer;
442 if (dir == DMA_TO_DEVICE)
443 memcpy(temp->data, urb->transfer_buffer,
444 urb->transfer_buffer_length);
445 urb->transfer_buffer = temp->data;
447 urb->transfer_flags |= URB_ALIGNED_TEMP_BUFFER;
449 return 0;
452 static int tegra_ehci_map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
453 gfp_t mem_flags)
455 int ret;
457 ret = alloc_temp_buffer(urb, mem_flags);
458 if (ret)
459 return ret;
461 ret = usb_hcd_map_urb_for_dma(hcd, urb, mem_flags);
462 if (ret)
463 free_temp_buffer(urb);
465 return ret;
468 static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
470 usb_hcd_unmap_urb_for_dma(hcd, urb);
471 free_temp_buffer(urb);
474 static const struct hc_driver tegra_ehci_hc_driver = {
475 .description = hcd_name,
476 .product_desc = "Tegra EHCI Host Controller",
477 .hcd_priv_size = sizeof(struct ehci_hcd),
479 .flags = HCD_USB2 | HCD_MEMORY,
481 .reset = tegra_ehci_setup,
482 .irq = ehci_irq,
484 .start = ehci_run,
485 .stop = ehci_stop,
486 .shutdown = tegra_ehci_shutdown,
487 .urb_enqueue = ehci_urb_enqueue,
488 .urb_dequeue = ehci_urb_dequeue,
489 .map_urb_for_dma = tegra_ehci_map_urb_for_dma,
490 .unmap_urb_for_dma = tegra_ehci_unmap_urb_for_dma,
491 .endpoint_disable = ehci_endpoint_disable,
492 .endpoint_reset = ehci_endpoint_reset,
493 .get_frame_number = ehci_get_frame,
494 .hub_status_data = ehci_hub_status_data,
495 .hub_control = tegra_ehci_hub_control,
496 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
497 #ifdef CONFIG_PM
498 .bus_suspend = tegra_ehci_bus_suspend,
499 .bus_resume = tegra_ehci_bus_resume,
500 #endif
501 .relinquish_port = ehci_relinquish_port,
502 .port_handed_over = ehci_port_handed_over,
505 static int tegra_ehci_probe(struct platform_device *pdev)
507 struct resource *res;
508 struct usb_hcd *hcd;
509 struct tegra_ehci_hcd *tegra;
510 struct tegra_ehci_platform_data *pdata;
511 int err = 0;
512 int irq;
513 int instance = pdev->id;
515 pdata = pdev->dev.platform_data;
516 if (!pdata) {
517 dev_err(&pdev->dev, "Platform data missing\n");
518 return -EINVAL;
521 tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL);
522 if (!tegra)
523 return -ENOMEM;
525 hcd = usb_create_hcd(&tegra_ehci_hc_driver, &pdev->dev,
526 dev_name(&pdev->dev));
527 if (!hcd) {
528 dev_err(&pdev->dev, "Unable to create HCD\n");
529 err = -ENOMEM;
530 goto fail_hcd;
533 platform_set_drvdata(pdev, tegra);
535 tegra->clk = clk_get(&pdev->dev, NULL);
536 if (IS_ERR(tegra->clk)) {
537 dev_err(&pdev->dev, "Can't get ehci clock\n");
538 err = PTR_ERR(tegra->clk);
539 goto fail_clk;
542 err = clk_enable(tegra->clk);
543 if (err)
544 goto fail_clken;
546 tegra->emc_clk = clk_get(&pdev->dev, "emc");
547 if (IS_ERR(tegra->emc_clk)) {
548 dev_err(&pdev->dev, "Can't get emc clock\n");
549 err = PTR_ERR(tegra->emc_clk);
550 goto fail_emc_clk;
553 clk_enable(tegra->emc_clk);
554 clk_set_rate(tegra->emc_clk, 400000000);
556 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
557 if (!res) {
558 dev_err(&pdev->dev, "Failed to get I/O memory\n");
559 err = -ENXIO;
560 goto fail_io;
562 hcd->rsrc_start = res->start;
563 hcd->rsrc_len = resource_size(res);
564 hcd->regs = ioremap(res->start, resource_size(res));
565 if (!hcd->regs) {
566 dev_err(&pdev->dev, "Failed to remap I/O memory\n");
567 err = -ENOMEM;
568 goto fail_io;
571 tegra->phy = tegra_usb_phy_open(instance, hcd->regs, pdata->phy_config,
572 TEGRA_USB_PHY_MODE_HOST);
573 if (IS_ERR(tegra->phy)) {
574 dev_err(&pdev->dev, "Failed to open USB phy\n");
575 err = -ENXIO;
576 goto fail_phy;
579 err = tegra_usb_phy_power_on(tegra->phy);
580 if (err) {
581 dev_err(&pdev->dev, "Failed to power on the phy\n");
582 goto fail;
585 tegra->host_resumed = 1;
586 tegra->power_down_on_bus_suspend = pdata->power_down_on_bus_suspend;
587 tegra->ehci = hcd_to_ehci(hcd);
589 irq = platform_get_irq(pdev, 0);
590 if (!irq) {
591 dev_err(&pdev->dev, "Failed to get IRQ\n");
592 err = -ENODEV;
593 goto fail;
595 set_irq_flags(irq, IRQF_VALID);
597 #ifdef CONFIG_USB_OTG_UTILS
598 if (pdata->operating_mode == TEGRA_USB_OTG) {
599 tegra->transceiver = otg_get_transceiver();
600 if (tegra->transceiver)
601 otg_set_host(tegra->transceiver, &hcd->self);
603 #endif
605 err = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
606 if (err) {
607 dev_err(&pdev->dev, "Failed to add USB HCD\n");
608 goto fail;
611 return err;
613 fail:
614 #ifdef CONFIG_USB_OTG_UTILS
615 if (tegra->transceiver) {
616 otg_set_host(tegra->transceiver, NULL);
617 otg_put_transceiver(tegra->transceiver);
619 #endif
620 tegra_usb_phy_close(tegra->phy);
621 fail_phy:
622 iounmap(hcd->regs);
623 fail_io:
624 clk_disable(tegra->emc_clk);
625 clk_put(tegra->emc_clk);
626 fail_emc_clk:
627 clk_disable(tegra->clk);
628 fail_clken:
629 clk_put(tegra->clk);
630 fail_clk:
631 usb_put_hcd(hcd);
632 fail_hcd:
633 kfree(tegra);
634 return err;
637 #ifdef CONFIG_PM
638 static int tegra_ehci_resume(struct platform_device *pdev)
640 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
641 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
643 if (tegra->bus_suspended)
644 return 0;
646 return tegra_usb_resume(hcd);
649 static int tegra_ehci_suspend(struct platform_device *pdev, pm_message_t state)
651 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
652 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
654 if (tegra->bus_suspended)
655 return 0;
657 if (time_before(jiffies, tegra->ehci->next_statechange))
658 msleep(10);
660 return tegra_usb_suspend(hcd);
662 #endif
664 static int tegra_ehci_remove(struct platform_device *pdev)
666 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
667 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
669 if (tegra == NULL || hcd == NULL)
670 return -EINVAL;
672 #ifdef CONFIG_USB_OTG_UTILS
673 if (tegra->transceiver) {
674 otg_set_host(tegra->transceiver, NULL);
675 otg_put_transceiver(tegra->transceiver);
677 #endif
679 usb_remove_hcd(hcd);
680 usb_put_hcd(hcd);
682 tegra_usb_phy_close(tegra->phy);
683 iounmap(hcd->regs);
685 clk_disable(tegra->clk);
686 clk_put(tegra->clk);
688 clk_disable(tegra->emc_clk);
689 clk_put(tegra->emc_clk);
691 kfree(tegra);
692 return 0;
695 static void tegra_ehci_hcd_shutdown(struct platform_device *pdev)
697 struct tegra_ehci_hcd *tegra = platform_get_drvdata(pdev);
698 struct usb_hcd *hcd = ehci_to_hcd(tegra->ehci);
700 if (hcd->driver->shutdown)
701 hcd->driver->shutdown(hcd);
704 static struct platform_driver tegra_ehci_driver = {
705 .probe = tegra_ehci_probe,
706 .remove = tegra_ehci_remove,
707 #ifdef CONFIG_PM
708 .suspend = tegra_ehci_suspend,
709 .resume = tegra_ehci_resume,
710 #endif
711 .shutdown = tegra_ehci_hcd_shutdown,
712 .driver = {
713 .name = "tegra-ehci",