2 * Bus Glue for Atheros AR71xx built-in EHCI controller.
4 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * Parts of this file are based on Atheros' 2.6.15 BSP
8 * Copyright (C) 2007 Atheros Communications, Inc.
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
15 #include <linux/platform_device.h>
16 #include <linux/delay.h>
18 extern int usb_disabled(void);
20 static void ehci_ar71xx_setup(void)
27 static int ehci_ar71xx_probe(const struct hc_driver *driver,
28 struct usb_hcd **hcd_out,
29 struct platform_device *pdev)
32 struct ehci_hcd *ehci;
37 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
39 dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
45 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
47 dev_dbg(&pdev->dev, "no base address specified for %s\n",
52 hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id);
56 hcd->rsrc_start = res->start;
57 hcd->rsrc_len = res->end - res->start + 1;
59 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
60 dev_dbg(&pdev->dev, "controller already in use\n");
65 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
67 dev_dbg(&pdev->dev, "error mapping memory\n");
69 goto err_release_region;
72 ehci = hcd_to_ehci(hcd);
73 ehci->caps = hcd->regs;
74 ehci->regs = hcd->regs +
75 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
76 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
80 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
90 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
96 static void ehci_ar71xx_remove(struct usb_hcd *hcd,
97 struct platform_device *pdev)
101 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
105 static const struct hc_driver ehci_ar71xx_hc_driver = {
106 .description = hcd_name,
107 .product_desc = "Atheros AR71xx built-in EHCI controller",
108 .hcd_priv_size = sizeof(struct ehci_hcd),
111 * generic hardware linkage
114 .flags = HCD_MEMORY | HCD_USB2,
117 * basic lifecycle operations
122 .shutdown = ehci_shutdown,
125 * managing i/o requests and associated device resources
127 .urb_enqueue = ehci_urb_enqueue,
128 .urb_dequeue = ehci_urb_dequeue,
129 .endpoint_disable = ehci_endpoint_disable,
134 .get_frame_number = ehci_get_frame,
139 .hub_status_data = ehci_hub_status_data,
140 .hub_control = ehci_hub_control,
142 .hub_suspend = ehci_hub_suspend,
143 .hub_resume = ehci_hub_resume,
147 static int ehci_ar71xx_driver_probe(struct platform_device *pdev)
149 struct usb_hcd *hcd = NULL;
154 return ehci_ar71xx_probe(&ehci_ar71xx_hc_driver, &hcd, pdev);
157 static int ehci_ar71xx_driver_remove(struct platform_device *pdev)
159 struct usb_hcd *hcd = platform_get_drvdata(pdev);
161 ehci_ar71xx_remove(hcd, pdev);
165 MODULE_ALIAS("platform:ar71xx-ehci");
167 static struct platform_driver ehci_ar71xx_driver = {
168 .probe = ehci_ar71xx_driver_probe,
169 .remove = ehci_ar71xx_driver_remove,
171 .name = "ar71xx-ehci",