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
8 * Bus Glue for AMD Alchemy Au1xxx
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>
15 * Modified for AMD Alchemy Au1xxx
16 * by Matt Porter <mporter@kernel.crashing.org>
18 * This file is licenced under the GPL.
21 #include <linux/platform_device.h>
22 #include <linux/signal.h>
24 #include <asm/mach-au1x00/au1000.h>
27 extern int usb_disabled(void);
29 static int __devinit ohci_au1xxx_start(struct usb_hcd *hcd)
31 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
34 ohci_dbg(ohci, "ohci_au1xxx_start, ohci:%p", ohci);
36 if ((ret = ohci_init(ohci)) < 0)
39 if ((ret = ohci_run(ohci)) < 0) {
40 dev_err(hcd->self.controller, "can't start %s",
49 static const struct hc_driver ohci_au1xxx_hc_driver = {
50 .description = hcd_name,
51 .product_desc = "Au1xxx OHCI",
52 .hcd_priv_size = sizeof(struct ohci_hcd),
55 * generic hardware linkage
58 .flags = HCD_USB11 | HCD_MEMORY,
61 * basic lifecycle operations
63 .start = ohci_au1xxx_start,
65 .shutdown = ohci_shutdown,
68 * managing i/o requests and associated device resources
70 .urb_enqueue = ohci_urb_enqueue,
71 .urb_dequeue = ohci_urb_dequeue,
72 .endpoint_disable = ohci_endpoint_disable,
77 .get_frame_number = ohci_get_frame,
82 .hub_status_data = ohci_hub_status_data,
83 .hub_control = ohci_hub_control,
85 .bus_suspend = ohci_bus_suspend,
86 .bus_resume = ohci_bus_resume,
88 .start_port_reset = ohci_start_port_reset,
91 static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
99 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
100 pr_debug("resource[1] is not IORESOURCE_IRQ\n");
104 hcd = usb_create_hcd(&ohci_au1xxx_hc_driver, &pdev->dev, "au1xxx");
108 hcd->rsrc_start = pdev->resource[0].start;
109 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
111 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
112 pr_debug("request_mem_region failed\n");
117 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
119 pr_debug("ioremap failed\n");
124 unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ?
125 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
126 if (alchemy_usb_control(unit, 1)) {
127 printk(KERN_INFO "%s: controller init failed!\n", pdev->name);
132 ohci_hcd_init(hcd_to_ohci(hcd));
134 ret = usb_add_hcd(hcd, pdev->resource[1].start,
137 platform_set_drvdata(pdev, hcd);
141 alchemy_usb_control(unit, 0);
145 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
151 static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
153 struct usb_hcd *hcd = platform_get_drvdata(pdev);
156 unit = (hcd->rsrc_start == AU1300_USB_OHCI1_PHYS_ADDR) ?
157 ALCHEMY_USB_OHCI1 : ALCHEMY_USB_OHCI0;
159 alchemy_usb_control(unit, 0);
161 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
163 platform_set_drvdata(pdev, NULL);
169 static int ohci_hcd_au1xxx_drv_suspend(struct device *dev)
171 struct usb_hcd *hcd = dev_get_drvdata(dev);
172 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
178 /* Root hub was already suspended. Disable irq emission and
179 * mark HW unaccessible, bail out if RH has been resumed. Use
180 * the spinlock to properly synchronize with possible pending
181 * RH suspend or resume activity.
183 spin_lock_irqsave(&ohci->lock, flags);
184 if (ohci->rh_state != OHCI_RH_SUSPENDED) {
188 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
189 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
191 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
193 alchemy_usb_control(ALCHEMY_USB_OHCI0, 0);
195 spin_unlock_irqrestore(&ohci->lock, flags);
200 static int ohci_hcd_au1xxx_drv_resume(struct device *dev)
202 struct usb_hcd *hcd = dev_get_drvdata(dev);
204 alchemy_usb_control(ALCHEMY_USB_OHCI0, 1);
206 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
207 ohci_finish_controller_resume(hcd);
212 static const struct dev_pm_ops au1xxx_ohci_pmops = {
213 .suspend = ohci_hcd_au1xxx_drv_suspend,
214 .resume = ohci_hcd_au1xxx_drv_resume,
217 #define AU1XXX_OHCI_PMOPS &au1xxx_ohci_pmops
220 #define AU1XXX_OHCI_PMOPS NULL
223 static struct platform_driver ohci_hcd_au1xxx_driver = {
224 .probe = ohci_hcd_au1xxx_drv_probe,
225 .remove = ohci_hcd_au1xxx_drv_remove,
226 .shutdown = usb_hcd_platform_shutdown,
228 .name = "au1xxx-ohci",
229 .owner = THIS_MODULE,
230 .pm = AU1XXX_OHCI_PMOPS,
234 MODULE_ALIAS("platform:au1xxx-ohci");