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 #include <asm/mach-ar71xx/platform.h>
20 extern int usb_disabled(void);
22 static void ehci_ar71xx_setup(void)
29 static int ehci_ar71xx_probe(const struct hc_driver *driver,
30 struct usb_hcd **hcd_out,
31 struct platform_device *pdev)
34 struct ehci_hcd *ehci;
39 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
41 dev_dbg(&pdev->dev, "no IRQ specified for %s\n",
47 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
49 dev_dbg(&pdev->dev, "no base address specified for %s\n",
54 hcd = usb_create_hcd(driver, &pdev->dev, pdev->dev.bus_id);
58 hcd->rsrc_start = res->start;
59 hcd->rsrc_len = res->end - res->start + 1;
61 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
62 dev_dbg(&pdev->dev, "controller already in use\n");
67 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
69 dev_dbg(&pdev->dev, "error mapping memory\n");
71 goto err_release_region;
74 ehci = hcd_to_ehci(hcd);
75 ehci->caps = hcd->regs;
76 ehci->regs = hcd->regs +
77 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
78 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
82 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
92 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
98 static void ehci_ar71xx_remove(struct usb_hcd *hcd,
99 struct platform_device *pdev)
103 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
107 static const struct hc_driver ehci_ar71xx_hc_driver = {
108 .description = hcd_name,
109 .product_desc = "Atheros AR71xx built-in EHCI controller",
110 .hcd_priv_size = sizeof(struct ehci_hcd),
113 * generic hardware linkage
116 .flags = HCD_MEMORY | HCD_USB2,
119 * basic lifecycle operations
124 .shutdown = ehci_shutdown,
127 * managing i/o requests and associated device resources
129 .urb_enqueue = ehci_urb_enqueue,
130 .urb_dequeue = ehci_urb_dequeue,
131 .endpoint_disable = ehci_endpoint_disable,
136 .get_frame_number = ehci_get_frame,
141 .hub_status_data = ehci_hub_status_data,
142 .hub_control = ehci_hub_control,
144 .hub_suspend = ehci_hub_suspend,
145 .hub_resume = ehci_hub_resume,
149 static int ehci_ar71xx_driver_probe(struct platform_device *pdev)
151 struct usb_hcd *hcd = NULL;
156 return ehci_ar71xx_probe(&ehci_ar71xx_hc_driver, &hcd, pdev);
159 static int ehci_ar71xx_driver_remove(struct platform_device *pdev)
161 struct usb_hcd *hcd = platform_get_drvdata(pdev);
163 ehci_ar71xx_remove(hcd, pdev);
167 MODULE_ALIAS("platform:ar71xx-ehci");
169 static struct platform_driver ehci_ar71xx_driver = {
170 .probe = ehci_ar71xx_driver_probe,
171 .remove = ehci_ar71xx_driver_remove,
173 .name = "ar71xx-ehci",