1 --- a/drivers/usb/host/Kconfig
2 +++ b/drivers/usb/host/Kconfig
3 @@ -378,6 +378,16 @@ config USB_CNS3XXX_OHCI
4 Enable support for the CNS3XXX SOC's on-chip OHCI controller.
5 It is needed for low-speed USB 1.0 device support.
7 +config USB_OHCI_HCD_PLATFORM
8 + bool "Generic OHCI driver for a platform device"
9 + depends on USB_OHCI_HCD && EXPERIMENTAL
12 + Adds an OHCI host driver for a generic platform device, which
13 + provieds a memory space and an irq.
17 config USB_OHCI_BIG_ENDIAN_DESC
19 depends on USB_OHCI_HCD
20 --- a/drivers/usb/host/ohci-hcd.c
21 +++ b/drivers/usb/host/ohci-hcd.c
22 @@ -1116,6 +1116,11 @@ MODULE_LICENSE ("GPL");
23 #define PLATFORM_DRIVER ohci_xls_driver
26 +#ifdef CONFIG_USB_OHCI_HCD_PLATFORM
27 +#include "ohci-platform.c"
28 +#define PLATFORM_DRIVER ohci_platform_driver
31 #if !defined(PCI_DRIVER) && \
32 !defined(PLATFORM_DRIVER) && \
33 !defined(OMAP1_PLATFORM_DRIVER) && \
35 +++ b/drivers/usb/host/ohci-platform.c
38 + * Generic platform ohci driver
40 + * Copyright 2007 Michael Buesch <m@bues.ch>
41 + * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de>
43 + * Derived from the OCHI-SSB driver
44 + * Derived from the OHCI-PCI driver
45 + * Copyright 1999 Roman Weissgaerber
46 + * Copyright 2000-2002 David Brownell
47 + * Copyright 1999 Linus Torvalds
48 + * Copyright 1999 Gregory P. Smith
50 + * Licensed under the GNU/GPL. See COPYING for details.
52 +#include <linux/platform_device.h>
53 +#include <linux/usb/ohci_pdriver.h>
55 +static int ohci_platform_reset(struct usb_hcd *hcd)
57 + struct platform_device *pdev = to_platform_device(hcd->self.controller);
58 + struct usb_ohci_pdata *pdata = pdev->dev.platform_data;
59 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
62 + if (pdata->big_endian_desc)
63 + ohci->flags |= OHCI_QUIRK_BE_DESC;
64 + if (pdata->big_endian_mmio)
65 + ohci->flags |= OHCI_QUIRK_BE_MMIO;
66 + if (pdata->no_big_frame_no)
67 + ohci->flags |= OHCI_QUIRK_FRAME_NO;
69 + ohci_hcd_init(ohci);
70 + err = ohci_init(ohci);
75 +static int ohci_platform_start(struct usb_hcd *hcd)
77 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
80 + err = ohci_run(ohci);
82 + ohci_err(ohci, "can't start\n");
89 +static const struct hc_driver ohci_platform_hc_driver = {
90 + .description = hcd_name,
91 + .product_desc = "Generic Platform OHCI Controller",
92 + .hcd_priv_size = sizeof(struct ohci_hcd),
95 + .flags = HCD_MEMORY | HCD_USB11,
97 + .reset = ohci_platform_reset,
98 + .start = ohci_platform_start,
100 + .shutdown = ohci_shutdown,
102 + .urb_enqueue = ohci_urb_enqueue,
103 + .urb_dequeue = ohci_urb_dequeue,
104 + .endpoint_disable = ohci_endpoint_disable,
106 + .get_frame_number = ohci_get_frame,
108 + .hub_status_data = ohci_hub_status_data,
109 + .hub_control = ohci_hub_control,
111 + .bus_suspend = ohci_bus_suspend,
112 + .bus_resume = ohci_bus_resume,
115 + .start_port_reset = ohci_start_port_reset,
118 +static int __devinit ohci_platform_probe(struct platform_device *dev)
120 + struct usb_hcd *hcd;
121 + struct resource *res_mem;
125 + BUG_ON(!dev->dev.platform_data);
127 + if (usb_disabled())
130 + irq = platform_get_irq(dev, 0);
132 + pr_err("no irq provieded");
136 + res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
138 + pr_err("no memory recourse provieded");
142 + hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev,
143 + dev_name(&dev->dev));
147 + hcd->rsrc_start = res_mem->start;
148 + hcd->rsrc_len = resource_size(res_mem);
150 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
151 + pr_err("controller already in use");
156 + hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
158 + goto err_release_region;
159 + err = usb_add_hcd(hcd, irq, IRQF_SHARED);
163 + platform_set_drvdata(dev, hcd);
168 + iounmap(hcd->regs);
170 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
176 +static int __devexit ohci_platform_remove(struct platform_device *dev)
178 + struct usb_hcd *hcd = platform_get_drvdata(dev);
180 + usb_remove_hcd(hcd);
181 + iounmap(hcd->regs);
182 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
184 + platform_set_drvdata(dev, NULL);
191 +static int ohci_platform_suspend(struct device *dev)
196 +static int ohci_platform_resume(struct device *dev)
198 + struct usb_hcd *hcd = dev_get_drvdata(dev);
200 + ohci_finish_controller_resume(hcd);
204 +#else /* !CONFIG_PM */
205 +#define ohci_platform_suspend NULL
206 +#define ohci_platform_resume NULL
207 +#endif /* CONFIG_PM */
209 +static const struct platform_device_id ohci_platform_table[] = {
210 + { "ohci-platform", 0 },
213 +MODULE_DEVICE_TABLE(platform, ohci_platform_table);
215 +static const struct dev_pm_ops ohci_platform_pm_ops = {
216 + .suspend = ohci_platform_suspend,
217 + .resume = ohci_platform_resume,
220 +static struct platform_driver ohci_platform_driver = {
221 + .id_table = ohci_platform_table,
222 + .probe = ohci_platform_probe,
223 + .remove = __devexit_p(ohci_platform_remove),
224 + .shutdown = usb_hcd_platform_shutdown,
226 + .owner = THIS_MODULE,
227 + .name = "ohci-platform",
228 + .pm = &ohci_platform_pm_ops,
232 +++ b/include/linux/usb/ohci_pdriver.h
235 + * Copyright (C) 2012 Hauke Mehrtens <hauke@hauke-m.de>
237 + * This program is free software; you can redistribute it and/or modify it
238 + * under the terms of the GNU General Public License as published by the
239 + * Free Software Foundation; either version 2 of the License, or (at your
240 + * option) any later version.
242 + * This program is distributed in the hope that it will be useful, but
243 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
244 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
245 + * for more details.
247 + * You should have received a copy of the GNU General Public License
248 + * along with this program; if not, write to the Free Software Foundation,
249 + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
252 +#ifndef __USB_CORE_OHCI_PDRIVER_H
253 +#define __USB_CORE_OHCI_PDRIVER_H
256 + * struct usb_ohci_pdata - platform_data for generic ohci driver
258 + * @big_endian_desc: BE descriptors
259 + * @big_endian_mmio: BE registers
260 + * @no_big_frame_no: no big endian frame_no shift
262 + * These are general configuration options for the OHCI controller. All of
263 + * these options are activating more or less workarounds for some hardware.
265 +struct usb_ohci_pdata {
266 + unsigned big_endian_desc:1;
267 + unsigned big_endian_mmio:1;
268 + unsigned no_big_frame_no:1;
271 +#endif /* __USB_CORE_OHCI_PDRIVER_H */