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 Moschip MCS814x.
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 mcs814x from ohci-mcs814x.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/device.h>
27 #include <linux/signal.h>
28 #include <linux/platform_device.h>
31 static int usb_hcd_mcs814x_probe(const struct hc_driver
*driver
,
32 struct platform_device
*pdev
)
37 if (pdev
->resource
[1].flags
!= IORESOURCE_IRQ
) {
38 pr_debug("resource[1] is not IORESOURCE_IRQ");
42 pdev
->dev
.coherent_dma_mask
= DMA_BIT_MASK(32);
43 pdev
->dev
.dma_mask
= &pdev
->dev
.coherent_dma_mask
;
45 hcd
= usb_create_hcd(driver
, &pdev
->dev
, "mcs814x");
49 hcd
->rsrc_start
= pdev
->resource
[0].start
;
50 hcd
->rsrc_len
= pdev
->resource
[0].end
- pdev
->resource
[0].start
+ 1;
51 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
57 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
58 if (hcd
->regs
== NULL
) {
59 pr_debug("ioremap failed");
64 ohci_hcd_init(hcd_to_ohci(hcd
));
66 retval
= usb_add_hcd(hcd
, pdev
->resource
[1].start
, IRQF_DISABLED
);
72 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
79 static void usb_hcd_mcs814x_remove(struct usb_hcd
*hcd
,
80 struct platform_device
*pdev
)
84 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
88 static int __devinit
ohci_mcs814x_start(struct usb_hcd
*hcd
)
90 struct ohci_hcd
*ohci
= hcd_to_ohci(hcd
);
93 ret
= ohci_init(ohci
);
99 err("can't start %s", hcd
->self
.bus_name
);
107 static struct hc_driver ohci_mcs814x_hc_driver
= {
108 .description
= hcd_name
,
109 .product_desc
= "MCS814X OHCI",
110 .hcd_priv_size
= sizeof(struct ohci_hcd
),
112 .flags
= HCD_USB11
| HCD_MEMORY
,
113 .start
= ohci_mcs814x_start
,
115 .shutdown
= ohci_shutdown
,
116 .urb_enqueue
= ohci_urb_enqueue
,
117 .urb_dequeue
= ohci_urb_dequeue
,
118 .endpoint_disable
= ohci_endpoint_disable
,
119 .get_frame_number
= ohci_get_frame
,
120 .hub_status_data
= ohci_hub_status_data
,
121 .hub_control
= ohci_hub_control
,
123 .bus_suspend
= ohci_bus_suspend
,
124 .bus_resume
= ohci_bus_resume
,
126 .start_port_reset
= ohci_start_port_reset
,
129 extern int usb_disabled(void);
131 static int ohci_hcd_mcs814x_drv_probe(struct platform_device
*pdev
)
137 ret
= usb_hcd_mcs814x_probe(&ohci_mcs814x_hc_driver
, pdev
);
142 static int ohci_hcd_mcs814x_drv_remove(struct platform_device
*pdev
)
144 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
146 usb_hcd_mcs814x_remove(hcd
, pdev
);
152 static int ohci_hcd_mcs814x_drv_suspend(struct platform_device
*pdev
, pm_message_t state
)
154 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
155 struct ohci_hcd
*ohci
= hcd_to_ohci(hcd
);
157 if (time_before(jiffies
, ohci
->next_statechange
))
159 ohci
->next_statechange
= jiffies
;
161 hcd
->state
= HC_STATE_SUSPENDED
;
166 static int ohci_hcd_mcs814x_drv_resume(struct platform_device
*pdev
)
168 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
169 struct ohci_hcd
*ohci
= hcd_to_ohci(hcd
);
172 if (time_before(jiffies
, ohci
->next_statechange
))
174 ohci
->next_statechange
= jiffies
;
176 ohci_finish_controller_resume(hcd
);
181 static const struct of_device_id mcs814x_ohci_id
[] = {
182 { .compatible
= "moschip,mcs814x-ohci" },
183 { .compatible
= "ohci-le" },
187 static struct platform_driver ohci_hcd_mcs814x_driver
= {
188 .probe
= ohci_hcd_mcs814x_drv_probe
,
189 .remove
= ohci_hcd_mcs814x_drv_remove
,
190 .shutdown
= usb_hcd_platform_shutdown
,
192 .suspend
= ohci_hcd_mcs814x_drv_suspend
,
193 .resume
= ohci_hcd_mcs814x_drv_resume
,
196 .name
= "mcs814x-ohci",
197 .owner
= THIS_MODULE
,
198 .of_match_table
= mcs814x_ohci_id
,
202 MODULE_ALIAS("platform:mcs814x-ohci");