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 int ehci_ar71xx_init(struct usb_hcd
*hcd
)
24 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
27 ehci
->caps
= hcd
->regs
;
28 ehci
->regs
= hcd
->regs
+
29 HC_LENGTH(ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
30 ehci
->hcs_params
= ehci_readl(ehci
, &ehci
->caps
->hcs_params
);
40 ehci_port_power(ehci
, 0);
45 static int ehci_ar91xx_init(struct usb_hcd
*hcd
)
47 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
50 ehci
->caps
= hcd
->regs
+ 0x100;
51 ehci
->regs
= hcd
->regs
+ 0x100 +
52 HC_LENGTH(ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
53 ehci
->hcs_params
= ehci_readl(ehci
, &ehci
->caps
->hcs_params
);
64 ehci_port_power(ehci
, 0);
69 static int ehci_ar71xx_probe(const struct hc_driver
*driver
,
70 struct usb_hcd
**hcd_out
,
71 struct platform_device
*pdev
)
78 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
80 dev_dbg(&pdev
->dev
, "no IRQ specified for %s\n",
86 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
88 dev_dbg(&pdev
->dev
, "no base address specified for %s\n",
93 hcd
= usb_create_hcd(driver
, &pdev
->dev
, pdev
->dev
.bus_id
);
97 hcd
->rsrc_start
= res
->start
;
98 hcd
->rsrc_len
= res
->end
- res
->start
+ 1;
100 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
101 dev_dbg(&pdev
->dev
, "controller already in use\n");
106 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
108 dev_dbg(&pdev
->dev
, "error mapping memory\n");
110 goto err_release_region
;
113 ret
= usb_add_hcd(hcd
, irq
, IRQF_DISABLED
| IRQF_SHARED
);
123 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
129 static void ehci_ar71xx_remove(struct usb_hcd
*hcd
,
130 struct platform_device
*pdev
)
134 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
138 static const struct hc_driver ehci_ar71xx_hc_driver
= {
139 .description
= hcd_name
,
140 .product_desc
= "Atheros AR71xx built-in EHCI controller",
141 .hcd_priv_size
= sizeof(struct ehci_hcd
),
144 .flags
= HCD_MEMORY
| HCD_USB2
,
146 .reset
= ehci_ar71xx_init
,
149 .shutdown
= ehci_shutdown
,
151 .urb_enqueue
= ehci_urb_enqueue
,
152 .urb_dequeue
= ehci_urb_dequeue
,
153 .endpoint_disable
= ehci_endpoint_disable
,
155 .get_frame_number
= ehci_get_frame
,
157 .hub_status_data
= ehci_hub_status_data
,
158 .hub_control
= ehci_hub_control
,
160 .hub_suspend
= ehci_hub_suspend
,
161 .hub_resume
= ehci_hub_resume
,
163 .relinquish_port
= ehci_relinquish_port
,
164 .port_handed_over
= ehci_port_handed_over
,
167 static const struct hc_driver ehci_ar91xx_hc_driver
= {
168 .description
= hcd_name
,
169 .product_desc
= "Atheros AR91xx built-in EHCI controller",
170 .hcd_priv_size
= sizeof(struct ehci_hcd
),
172 .flags
= HCD_MEMORY
| HCD_USB2
,
174 .reset
= ehci_ar91xx_init
,
177 .shutdown
= ehci_shutdown
,
179 .urb_enqueue
= ehci_urb_enqueue
,
180 .urb_dequeue
= ehci_urb_dequeue
,
181 .endpoint_disable
= ehci_endpoint_disable
,
183 .get_frame_number
= ehci_get_frame
,
185 .hub_status_data
= ehci_hub_status_data
,
186 .hub_control
= ehci_hub_control
,
188 .hub_suspend
= ehci_hub_suspend
,
189 .hub_resume
= ehci_hub_resume
,
191 .relinquish_port
= ehci_relinquish_port
,
192 .port_handed_over
= ehci_port_handed_over
,
195 static int ehci_ar71xx_driver_probe(struct platform_device
*pdev
)
197 struct ar71xx_ehci_platform_data
*pdata
;
198 struct usb_hcd
*hcd
= NULL
;
204 pdata
= pdev
->dev
.platform_data
;
206 dev_err(&pdev
->dev
, "no platform data specified for %s\n",
211 if (pdata
->is_ar91xx
)
212 ret
= ehci_ar71xx_probe(&ehci_ar91xx_hc_driver
, &hcd
, pdev
);
214 ret
= ehci_ar71xx_probe(&ehci_ar71xx_hc_driver
, &hcd
, pdev
);
219 static int ehci_ar71xx_driver_remove(struct platform_device
*pdev
)
221 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
223 ehci_ar71xx_remove(hcd
, pdev
);
227 MODULE_ALIAS("platform:ar71xx-ehci");
229 static struct platform_driver ehci_ar71xx_driver
= {
230 .probe
= ehci_ar71xx_driver_probe
,
231 .remove
= ehci_ar71xx_driver_remove
,
233 .name
= "ar71xx-ehci",