25 #include <linux/slab.h>
27 #include <mach/hardware.h>
32 #define ULPI_VIEWPORT_OFFSET 0x170
40 static int ehci_mxc_setup(
struct usb_hcd *hcd)
42 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
47 retval = ehci_setup(hcd);
51 ehci_port_power(ehci, 0);
55 static const struct hc_driver ehci_mxc_hc_driver = {
56 .description = hcd_name,
57 .product_desc =
"Freescale On-Chip EHCI Host Controller",
58 .hcd_priv_size =
sizeof(
struct ehci_hcd),
64 .flags = HCD_USB2 | HCD_MEMORY,
69 .reset = ehci_mxc_setup,
72 .shutdown = ehci_shutdown,
77 .urb_enqueue = ehci_urb_enqueue,
78 .urb_dequeue = ehci_urb_dequeue,
79 .endpoint_disable = ehci_endpoint_disable,
80 .endpoint_reset = ehci_endpoint_reset,
85 .get_frame_number = ehci_get_frame,
90 .hub_status_data = ehci_hub_status_data,
91 .hub_control = ehci_hub_control,
94 .relinquish_port = ehci_relinquish_port,
95 .port_handed_over = ehci_port_handed_over,
97 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
111 dev_info(&pdev->
dev,
"initializing i.MX USB Controller\n");
114 dev_err(dev,
"No platform data given, bailing out.\n");
132 dev_err(dev,
"Found HC with no register addr. Check setup!\n");
137 hcd->rsrc_start = res->
start;
138 hcd->rsrc_len = resource_size(res);
142 dev_err(dev,
"error mapping memory\n");
149 if (IS_ERR(priv->
usbclk)) {
150 ret = PTR_ERR(priv->
usbclk);
153 clk_prepare_enable(priv->
usbclk);
156 if (IS_ERR(priv->
ahbclk)) {
157 ret = PTR_ERR(priv->
ahbclk);
160 clk_prepare_enable(priv->
ahbclk);
167 clk_prepare_enable(priv->
phyclk);
172 ret = pdata->
init(pdev);
174 dev_err(dev,
"platform init failed\n");
181 ehci = hcd_to_ehci(hcd);
184 ehci->
caps = hcd->regs + 0x100;
185 ehci->
regs = hcd->regs + 0x100 +
189 ehci_writel(ehci, pdata->
portsc, &ehci->
regs->port_status[0]);
197 ret = usb_phy_init(pdata->
otg);
199 dev_err(dev,
"unable to init transceiver, probably missing\n");
203 ret = otg_set_vbus(pdata->
otg->otg, 1);
205 dev_err(dev,
"unable to enable vbus on transceiver\n");
211 platform_set_drvdata(pdev, priv);
223 if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
224 flags = usb_phy_io_read(pdata->
otg,
227 ret = usb_phy_io_write(pdata->
otg, flags,
230 dev_err(dev,
"unable to set CHRVBUS\n");
239 if (pdata && pdata->
exit)
243 clk_disable_unprepare(priv->
phyclk);
245 clk_disable_unprepare(priv->
ahbclk);
247 clk_disable_unprepare(priv->
usbclk);
257 struct usb_hcd *hcd = priv->
hcd;
259 if (pdata && pdata->
exit)
263 usb_phy_shutdown(pdata->
otg);
267 platform_set_drvdata(pdev,
NULL);
269 clk_disable_unprepare(priv->
usbclk);
270 clk_disable_unprepare(priv->
ahbclk);
273 clk_disable_unprepare(priv->
phyclk);
281 struct usb_hcd *hcd = priv->
hcd;
283 if (hcd->driver->shutdown)
284 hcd->driver->shutdown(hcd);
290 .probe = ehci_mxc_drv_probe,
291 .remove =
__exit_p(ehci_mxc_drv_remove),
292 .shutdown = ehci_mxc_drv_shutdown,