2 * OHCI HCD (Host Controller Driver) for USB.
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
10 * Written by Christopher Hoover <ch@hpl.hp.com>
11 * Based on fragments of previous driver by Russell King et al.
13 * Modified for LH7A404 from ohci-sa1111.c
14 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
16 * Modified for pxa27x from ohci-lh7a404.c
17 * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004
19 * Modified for ep93xx from ohci-pxa27x.c
20 * by Lennert Buytenhek <buytenh@wantstofly.org> 28-2-2006
21 * Based on an earlier driver by Ray Lehtiniemi
23 * This file is licenced under the GPL.
26 #include <linux/clk.h>
27 #include <linux/device.h>
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/platform_device.h>
32 #include <linux/signal.h>
33 #include <linux/usb.h>
34 #include <linux/usb/hcd.h>
38 #define DRIVER_DESC "OHCI EP93xx driver"
40 static const char hcd_name[] = "ohci-ep93xx";
42 static struct hc_driver __read_mostly ohci_ep93xx_hc_driver;
44 static struct clk *usb_host_clock;
46 static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev)
56 irq = platform_get_irq(pdev, 0);
60 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
64 hcd = usb_create_hcd(&ohci_ep93xx_hc_driver, &pdev->dev, "ep93xx");
68 hcd->rsrc_start = res->start;
69 hcd->rsrc_len = resource_size(res);
71 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
72 if (IS_ERR(hcd->regs)) {
73 ret = PTR_ERR(hcd->regs);
77 usb_host_clock = devm_clk_get(&pdev->dev, NULL);
78 if (IS_ERR(usb_host_clock)) {
79 ret = PTR_ERR(usb_host_clock);
83 clk_enable(usb_host_clock);
85 ret = usb_add_hcd(hcd, irq, 0);
92 clk_disable(usb_host_clock);
99 static int ohci_hcd_ep93xx_drv_remove(struct platform_device *pdev)
101 struct usb_hcd *hcd = platform_get_drvdata(pdev);
104 clk_disable(usb_host_clock);
111 static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_t state)
113 struct usb_hcd *hcd = platform_get_drvdata(pdev);
114 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
115 bool do_wakeup = device_may_wakeup(&pdev->dev);
118 if (time_before(jiffies, ohci->next_statechange))
120 ohci->next_statechange = jiffies;
122 ret = ohci_suspend(hcd, do_wakeup);
126 ep93xx_stop_hc(&pdev->dev);
131 static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
133 struct usb_hcd *hcd = platform_get_drvdata(pdev);
134 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
136 if (time_before(jiffies, ohci->next_statechange))
138 ohci->next_statechange = jiffies;
140 clk_enable(usb_host_clock);
142 ohci_resume(hcd, false);
147 static struct platform_driver ohci_hcd_ep93xx_driver = {
148 .probe = ohci_hcd_ep93xx_drv_probe,
149 .remove = ohci_hcd_ep93xx_drv_remove,
150 .shutdown = usb_hcd_platform_shutdown,
152 .suspend = ohci_hcd_ep93xx_drv_suspend,
153 .resume = ohci_hcd_ep93xx_drv_resume,
156 .name = "ep93xx-ohci",
157 .owner = THIS_MODULE,
161 static int __init ohci_ep93xx_init(void)
166 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
168 ohci_init_driver(&ohci_ep93xx_hc_driver, NULL);
169 return platform_driver_register(&ohci_hcd_ep93xx_driver);
171 module_init(ohci_ep93xx_init);
173 static void __exit ohci_ep93xx_cleanup(void)
175 platform_driver_unregister(&ohci_hcd_ep93xx_driver);
177 module_exit(ohci_ep93xx_cleanup);
179 MODULE_DESCRIPTION(DRIVER_DESC);
180 MODULE_LICENSE("GPL");
181 MODULE_ALIAS("platform:ep93xx-ohci");