2 * EHCI HCD (Host Controller Driver) for USB.
4 * Copyright (C) 2007 Atheros Communications, Inc.
5 * Copyright (C) 2008 Gabor Juhos <juhosg@openwrt.org>
6 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
8 * Bus Glue for Atheros AR71xx built-in EHCI controller
12 #include <linux/platform_device.h>
13 #include <linux/delay.h>
15 extern int usb_disabled(void);
17 static void ar71xx_start_ehci(struct platform_device
*pdev
)
21 static void ar71xx_stop_ehci(struct platform_device
*pdev
)
28 int usb_ehci_ar71xx_probe(const struct hc_driver
*driver
,
29 struct usb_hcd
**hcd_out
,
30 struct platform_device
*pdev
)
33 struct ehci_hcd
*ehci
;
38 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
40 dev_dbg(&pdev
->dev
, "no IRQ specified for %s\n",
46 hcd
= usb_create_hcd(driver
, &pdev
->dev
, pdev
->dev
.bus_id
);
50 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
52 dev_dbg(&pdev
->dev
, "no base address specified for %s\n",
57 hcd
->rsrc_start
= res
->start
;
58 hcd
->rsrc_len
= res
->end
- res
->start
+ 1;
60 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
61 dev_dbg(&pdev
->dev
, "controller already in use\n");
66 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
68 dev_dbg(&pdev
->dev
, "error mapping memory\n");
70 goto err_release_region
;
73 ar71xx_start_ehci(pdev
);
75 ehci
= hcd_to_ehci(hcd
);
76 ehci
->caps
= hcd
->regs
;
77 ehci
->regs
= hcd
->regs
+ HC_LENGTH(readl(&ehci
->caps
->hc_capbase
));
78 ehci
->hcs_params
= readl(&ehci
->caps
->hcs_params
);
80 ret
= usb_add_hcd(hcd
, irq
, IRQF_DISABLED
| IRQF_SHARED
);
87 ar71xx_stop_ehci(pdev
);
91 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
97 /* may be called without controller electrically present */
98 /* may be called with controller, bus, and devices active */
101 * usb_ehci_ar71xx_remove - shutdown processing for AR71xx-based HCDs
102 * @dev: USB Host Controller being removed
103 * Context: !in_interrupt()
105 * Reverses the effect of usb_hcd_ar71xx_probe(), first invoking
106 * the HCD's stop() method. It is always called from a thread
107 * context, normally "rmmod", "apmd", or something similar.
110 static void usb_ehci_ar71xx_remove(struct usb_hcd
*hcd
,
111 struct platform_device
*pdev
)
114 ar71xx_stop_ehci(pdev
);
116 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
120 static const struct hc_driver ehci_ar71xx_hc_driver
= {
121 .description
= hcd_name
,
122 .product_desc
= "Atheros AR71xx built-in EHCI controller",
123 .hcd_priv_size
= sizeof(struct ehci_hcd
),
125 * generic hardware linkage
128 .flags
= HCD_MEMORY
| HCD_USB2
,
131 * basic lifecycle operations
136 .shutdown
= ehci_shutdown
,
139 * managing i/o requests and associated device resources
141 .urb_enqueue
= ehci_urb_enqueue
,
142 .urb_dequeue
= ehci_urb_dequeue
,
143 .endpoint_disable
= ehci_endpoint_disable
,
148 .get_frame_number
= ehci_get_frame
,
153 .hub_status_data
= ehci_hub_status_data
,
154 .hub_control
= ehci_hub_control
,
156 .hub_suspend
= ehci_hub_suspend
,
157 .hub_resume
= ehci_hub_resume
,
161 static int ehci_hcd_ar71xx_drv_probe(struct platform_device
*pdev
)
163 struct usb_hcd
*hcd
= NULL
;
168 ret
= usb_ehci_ar71xx_probe(&ehci_ar71xx_hc_driver
, &hcd
, pdev
);
173 static int ehci_hcd_ar71xx_drv_remove(struct platform_device
*pdev
)
175 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
177 usb_ehci_ar71xx_remove(hcd
, pdev
);
181 static struct platform_driver ehci_hcd_ar71xx_driver
= {
182 .probe
= ehci_hcd_ar71xx_drv_probe
,
183 .remove
= ehci_hcd_ar71xx_drv_remove
,
184 .shutdown
= usb_hcd_platform_shutdown
,
186 .name
= "ar71xx-ehci",
187 .bus
= &platform_bus_type
191 MODULE_ALIAS("ar71xx-ehci");