2 * ohci-omap3.c - driver for OHCI on OMAP3 and later processors
4 * Bus Glue for OMAP3 USBHOST 3 port OHCI controller
5 * This controller is also used in later OMAPs and AM35x chips
7 * Copyright (C) 2007-2010 Texas Instruments, Inc.
8 * Author: Vikram Pandita <vikram.pandita@ti.com>
9 * Author: Anand Gadiyar <gadiyar@ti.com>
10 * Author: Keshava Munegowda <keshava_mgowda@ti.com>
12 * Based on ehci-omap.c and some other ohci glue layers
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * TODO (last updated Feb 27, 2011):
32 #include <linux/platform_device.h>
34 #include <linux/pm_runtime.h>
36 /*-------------------------------------------------------------------------*/
38 static int ohci_omap3_init(struct usb_hcd
*hcd
)
40 dev_dbg(hcd
->self
.controller
, "starting OHCI controller\n");
42 return ohci_init(hcd_to_ohci(hcd
));
45 /*-------------------------------------------------------------------------*/
47 static int ohci_omap3_start(struct usb_hcd
*hcd
)
49 struct ohci_hcd
*ohci
= hcd_to_ohci(hcd
);
53 * RemoteWakeupConnected has to be set explicitly before
54 * calling ohci_run. The reset value of RWC is 0.
56 ohci
->hc_control
= OHCI_CTRL_RWC
;
57 writel(OHCI_CTRL_RWC
, &ohci
->regs
->control
);
62 dev_err(hcd
->self
.controller
, "can't start\n");
69 /*-------------------------------------------------------------------------*/
71 static const struct hc_driver ohci_omap3_hc_driver
= {
72 .description
= hcd_name
,
73 .product_desc
= "OMAP3 OHCI Host Controller",
74 .hcd_priv_size
= sizeof(struct ohci_hcd
),
77 * generic hardware linkage
80 .flags
= HCD_USB11
| HCD_MEMORY
,
83 * basic lifecycle operations
85 .reset
= ohci_omap3_init
,
86 .start
= ohci_omap3_start
,
88 .shutdown
= ohci_shutdown
,
91 * managing i/o requests and associated device resources
93 .urb_enqueue
= ohci_urb_enqueue
,
94 .urb_dequeue
= ohci_urb_dequeue
,
95 .endpoint_disable
= ohci_endpoint_disable
,
100 .get_frame_number
= ohci_get_frame
,
105 .hub_status_data
= ohci_hub_status_data
,
106 .hub_control
= ohci_hub_control
,
108 .bus_suspend
= ohci_bus_suspend
,
109 .bus_resume
= ohci_bus_resume
,
111 .start_port_reset
= ohci_start_port_reset
,
114 /*-------------------------------------------------------------------------*/
117 * configure so an HC device and id are always provided
118 * always called with process context; sleeping is OK
122 * ohci_hcd_omap3_probe - initialize OMAP-based HCDs
124 * Allocates basic resources for this USB host controller, and
125 * then invokes the start() method for the HCD associated with it
126 * through the hotplug entry's driver_data.
128 static int __devinit
ohci_hcd_omap3_probe(struct platform_device
*pdev
)
130 struct device
*dev
= &pdev
->dev
;
131 struct usb_hcd
*hcd
= NULL
;
132 void __iomem
*regs
= NULL
;
133 struct resource
*res
;
141 dev_err(dev
, "Missing parent device\n");
145 irq
= platform_get_irq_byname(pdev
, "ohci-irq");
147 dev_err(dev
, "OHCI irq failed\n");
151 res
= platform_get_resource_byname(pdev
,
152 IORESOURCE_MEM
, "ohci");
154 dev_err(dev
, "UHH OHCI get resource failed\n");
158 regs
= ioremap(res
->start
, resource_size(res
));
160 dev_err(dev
, "UHH OHCI ioremap failed\n");
165 hcd
= usb_create_hcd(&ohci_omap3_hc_driver
, dev
,
168 dev_err(dev
, "usb_create_hcd failed\n");
172 hcd
->rsrc_start
= res
->start
;
173 hcd
->rsrc_len
= resource_size(res
);
176 pm_runtime_enable(dev
);
177 pm_runtime_get_sync(dev
);
179 ohci_hcd_init(hcd_to_ohci(hcd
));
181 ret
= usb_add_hcd(hcd
, irq
, 0);
183 dev_dbg(dev
, "failed to add hcd with err %d\n", ret
);
190 pm_runtime_put_sync(dev
);
200 * may be called without controller electrically present
201 * may be called with controller, bus, and devices active
205 * ohci_hcd_omap3_remove - shutdown processing for OHCI HCDs
206 * @pdev: USB Host Controller being removed
208 * Reverses the effect of ohci_hcd_omap3_probe(), first invoking
209 * the HCD's stop() method. It is always called from a thread
210 * context, normally "rmmod", "apmd", or something similar.
212 static int __devexit
ohci_hcd_omap3_remove(struct platform_device
*pdev
)
214 struct device
*dev
= &pdev
->dev
;
215 struct usb_hcd
*hcd
= dev_get_drvdata(dev
);
219 pm_runtime_put_sync(dev
);
220 pm_runtime_disable(dev
);
225 static void ohci_hcd_omap3_shutdown(struct platform_device
*pdev
)
227 struct usb_hcd
*hcd
= dev_get_drvdata(&pdev
->dev
);
229 if (hcd
->driver
->shutdown
)
230 hcd
->driver
->shutdown(hcd
);
233 static struct platform_driver ohci_hcd_omap3_driver
= {
234 .probe
= ohci_hcd_omap3_probe
,
235 .remove
= __devexit_p(ohci_hcd_omap3_remove
),
236 .shutdown
= ohci_hcd_omap3_shutdown
,
238 .name
= "ohci-omap3",
242 MODULE_ALIAS("platform:ohci-omap3");
243 MODULE_AUTHOR("Anand Gadiyar <gadiyar@ti.com>");