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
);
33 ehci
->has_synopsys_hc_bug
= 1;
41 ehci_port_power(ehci
, 0);
46 static int ehci_ar91xx_init(struct usb_hcd
*hcd
)
48 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
51 ehci
->caps
= hcd
->regs
+ 0x100;
52 ehci
->regs
= hcd
->regs
+ 0x100 +
53 HC_LENGTH(ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
54 ehci
->hcs_params
= ehci_readl(ehci
, &ehci
->caps
->hcs_params
);
65 ehci_port_power(ehci
, 0);
70 static int ehci_ar71xx_probe(const struct hc_driver
*driver
,
71 struct usb_hcd
**hcd_out
,
72 struct platform_device
*pdev
)
79 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
81 dev_dbg(&pdev
->dev
, "no IRQ specified for %s\n",
82 dev_name(&pdev
->dev
));
87 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
89 dev_dbg(&pdev
->dev
, "no base address specified for %s\n",
90 dev_name(&pdev
->dev
));
94 hcd
= usb_create_hcd(driver
, &pdev
->dev
, dev_name(&pdev
->dev
));
98 hcd
->rsrc_start
= res
->start
;
99 hcd
->rsrc_len
= res
->end
- res
->start
+ 1;
101 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
102 dev_dbg(&pdev
->dev
, "controller already in use\n");
107 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
109 dev_dbg(&pdev
->dev
, "error mapping memory\n");
111 goto err_release_region
;
114 ret
= usb_add_hcd(hcd
, irq
, IRQF_DISABLED
| IRQF_SHARED
);
124 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
130 static void ehci_ar71xx_remove(struct usb_hcd
*hcd
,
131 struct platform_device
*pdev
)
135 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
139 static const struct hc_driver ehci_ar71xx_hc_driver
= {
140 .description
= hcd_name
,
141 .product_desc
= "Atheros AR71xx built-in EHCI controller",
142 .hcd_priv_size
= sizeof(struct ehci_hcd
),
145 .flags
= HCD_MEMORY
| HCD_USB2
,
147 .reset
= ehci_ar71xx_init
,
150 .shutdown
= ehci_shutdown
,
152 .urb_enqueue
= ehci_urb_enqueue
,
153 .urb_dequeue
= ehci_urb_dequeue
,
154 .endpoint_disable
= ehci_endpoint_disable
,
156 .get_frame_number
= ehci_get_frame
,
158 .hub_status_data
= ehci_hub_status_data
,
159 .hub_control
= ehci_hub_control
,
161 .hub_suspend
= ehci_hub_suspend
,
162 .hub_resume
= ehci_hub_resume
,
164 .relinquish_port
= ehci_relinquish_port
,
165 .port_handed_over
= ehci_port_handed_over
,
168 static const struct hc_driver ehci_ar91xx_hc_driver
= {
169 .description
= hcd_name
,
170 .product_desc
= "Atheros AR91xx built-in EHCI controller",
171 .hcd_priv_size
= sizeof(struct ehci_hcd
),
173 .flags
= HCD_MEMORY
| HCD_USB2
,
175 .reset
= ehci_ar91xx_init
,
178 .shutdown
= ehci_shutdown
,
180 .urb_enqueue
= ehci_urb_enqueue
,
181 .urb_dequeue
= ehci_urb_dequeue
,
182 .endpoint_disable
= ehci_endpoint_disable
,
184 .get_frame_number
= ehci_get_frame
,
186 .hub_status_data
= ehci_hub_status_data
,
187 .hub_control
= ehci_hub_control
,
189 .hub_suspend
= ehci_hub_suspend
,
190 .hub_resume
= ehci_hub_resume
,
192 .relinquish_port
= ehci_relinquish_port
,
193 .port_handed_over
= ehci_port_handed_over
,
196 static int ehci_ar71xx_driver_probe(struct platform_device
*pdev
)
198 struct ar71xx_ehci_platform_data
*pdata
;
199 struct usb_hcd
*hcd
= NULL
;
205 pdata
= pdev
->dev
.platform_data
;
207 dev_err(&pdev
->dev
, "no platform data specified for %s\n",
208 dev_name(&pdev
->dev
));
212 if (pdata
->is_ar91xx
)
213 ret
= ehci_ar71xx_probe(&ehci_ar91xx_hc_driver
, &hcd
, pdev
);
215 ret
= ehci_ar71xx_probe(&ehci_ar71xx_hc_driver
, &hcd
, pdev
);
220 static int ehci_ar71xx_driver_remove(struct platform_device
*pdev
)
222 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
224 ehci_ar71xx_remove(hcd
, pdev
);
228 MODULE_ALIAS("platform:ar71xx-ehci");
230 static struct platform_driver ehci_ar71xx_driver
= {
231 .probe
= ehci_ar71xx_driver_probe
,
232 .remove
= ehci_ar71xx_driver_remove
,
234 .name
= "ar71xx-ehci",