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
);
116 if (time_before(jiffies
, ohci
->next_statechange
))
118 ohci
->next_statechange
= jiffies
;
120 clk_disable(usb_host_clock
);
124 static int ohci_hcd_ep93xx_drv_resume(struct platform_device
*pdev
)
126 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
127 struct ohci_hcd
*ohci
= hcd_to_ohci(hcd
);
129 if (time_before(jiffies
, ohci
->next_statechange
))
131 ohci
->next_statechange
= jiffies
;
133 clk_enable(usb_host_clock
);
135 ohci_resume(hcd
, false);
140 static struct platform_driver ohci_hcd_ep93xx_driver
= {
141 .probe
= ohci_hcd_ep93xx_drv_probe
,
142 .remove
= ohci_hcd_ep93xx_drv_remove
,
143 .shutdown
= usb_hcd_platform_shutdown
,
145 .suspend
= ohci_hcd_ep93xx_drv_suspend
,
146 .resume
= ohci_hcd_ep93xx_drv_resume
,
149 .name
= "ep93xx-ohci",
150 .owner
= THIS_MODULE
,
154 static int __init
ohci_ep93xx_init(void)
159 pr_info("%s: " DRIVER_DESC
"\n", hcd_name
);
161 ohci_init_driver(&ohci_ep93xx_hc_driver
, NULL
);
162 return platform_driver_register(&ohci_hcd_ep93xx_driver
);
164 module_init(ohci_ep93xx_init
);
166 static void __exit
ohci_ep93xx_cleanup(void)
168 platform_driver_unregister(&ohci_hcd_ep93xx_driver
);
170 module_exit(ohci_ep93xx_cleanup
);
172 MODULE_DESCRIPTION(DRIVER_DESC
);
173 MODULE_LICENSE("GPL");
174 MODULE_ALIAS("platform:ep93xx-ohci");