2 * Bus Glue for the built-in EHCI controller of the Ralink RT3662/RT3883 SoCs
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6 * Parts of this file are based on Ralink's 2.6.21 BSP
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <asm/mach-ralink/rt3883.h>
15 #include <asm/mach-ralink/rt3883_ehci_platform.h>
17 static int ehci_rt3883_init(struct usb_hcd *hcd)
19 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
22 ehci->caps = hcd->regs;
23 ehci->regs = hcd->regs +
24 HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
25 dbg_hcs_params(ehci, "reset");
26 dbg_hcc_params(ehci, "reset");
28 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
37 ehci_port_power(ehci, 0);
42 static const struct hc_driver ehci_rt3883_hc_driver = {
43 .description = hcd_name,
44 .product_desc = "Ralink RT3883 built-in EHCI controller",
45 .hcd_priv_size = sizeof(struct ehci_hcd),
47 .flags = HCD_MEMORY | HCD_USB2,
49 .reset = ehci_rt3883_init,
52 .shutdown = ehci_shutdown,
54 .urb_enqueue = ehci_urb_enqueue,
55 .urb_dequeue = ehci_urb_dequeue,
56 .endpoint_disable = ehci_endpoint_disable,
57 .endpoint_reset = ehci_endpoint_reset,
59 .get_frame_number = ehci_get_frame,
61 .hub_status_data = ehci_hub_status_data,
62 .hub_control = ehci_hub_control,
63 .relinquish_port = ehci_relinquish_port,
64 .port_handed_over = ehci_port_handed_over,
66 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
69 static int ehci_rt3883_probe(struct platform_device *pdev)
71 struct rt3883_ehci_platform_data *pdata;
80 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
82 dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
83 dev_name(&pdev->dev));
88 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
90 dev_dbg(&pdev->dev, "no base address specified for %s\n",
91 dev_name(&pdev->dev));
95 hcd = usb_create_hcd(&ehci_rt3883_hc_driver, &pdev->dev,
96 dev_name(&pdev->dev));
100 hcd->rsrc_start = res->start;
101 hcd->rsrc_len = res->end - res->start + 1;
103 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
104 dev_dbg(&pdev->dev, "controller already in use\n");
109 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
111 dev_dbg(&pdev->dev, "error mapping memory\n");
113 goto err_release_region;
116 pdata = pdev->dev.platform_data;
117 if (pdata && pdata->start_hw)
120 ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
130 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
136 static int ehci_rt3883_remove(struct platform_device *pdev)
138 struct usb_hcd *hcd = platform_get_drvdata(pdev);
139 struct rt3883_ehci_platform_data *pdata;
143 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
146 pdata = pdev->dev.platform_data;
147 if (pdata && pdata->stop_hw)
153 static struct platform_driver ehci_rt3883_driver = {
154 .probe = ehci_rt3883_probe,
155 .remove = ehci_rt3883_remove,
157 .owner = THIS_MODULE,
158 .name = "rt3883-ehci",
162 MODULE_ALIAS("platform:rt3883-ehci");