2 * Bus Glue for Atheros AR71xx built-in EHCI controller.
4 * Copyright (C) 2008-2010 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
,
155 .endpoint_reset
= ehci_endpoint_reset
,
157 .get_frame_number
= ehci_get_frame
,
159 .hub_status_data
= ehci_hub_status_data
,
160 .hub_control
= ehci_hub_control
,
162 .hub_suspend
= ehci_hub_suspend
,
163 .hub_resume
= ehci_hub_resume
,
165 .relinquish_port
= ehci_relinquish_port
,
166 .port_handed_over
= ehci_port_handed_over
,
168 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
171 static const struct hc_driver ehci_ar91xx_hc_driver
= {
172 .description
= hcd_name
,
173 .product_desc
= "Atheros AR91xx built-in EHCI controller",
174 .hcd_priv_size
= sizeof(struct ehci_hcd
),
176 .flags
= HCD_MEMORY
| HCD_USB2
,
178 .reset
= ehci_ar91xx_init
,
181 .shutdown
= ehci_shutdown
,
183 .urb_enqueue
= ehci_urb_enqueue
,
184 .urb_dequeue
= ehci_urb_dequeue
,
185 .endpoint_disable
= ehci_endpoint_disable
,
186 .endpoint_reset
= ehci_endpoint_reset
,
188 .get_frame_number
= ehci_get_frame
,
190 .hub_status_data
= ehci_hub_status_data
,
191 .hub_control
= ehci_hub_control
,
193 .hub_suspend
= ehci_hub_suspend
,
194 .hub_resume
= ehci_hub_resume
,
196 .relinquish_port
= ehci_relinquish_port
,
197 .port_handed_over
= ehci_port_handed_over
,
199 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
202 static int ehci_ar71xx_driver_probe(struct platform_device
*pdev
)
204 struct ar71xx_ehci_platform_data
*pdata
;
205 struct usb_hcd
*hcd
= NULL
;
211 pdata
= pdev
->dev
.platform_data
;
213 dev_err(&pdev
->dev
, "no platform data specified for %s\n",
214 dev_name(&pdev
->dev
));
218 if (pdata
->is_ar91xx
)
219 ret
= ehci_ar71xx_probe(&ehci_ar91xx_hc_driver
, &hcd
, pdev
);
221 ret
= ehci_ar71xx_probe(&ehci_ar71xx_hc_driver
, &hcd
, pdev
);
226 static int ehci_ar71xx_driver_remove(struct platform_device
*pdev
)
228 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
230 ehci_ar71xx_remove(hcd
, pdev
);
234 MODULE_ALIAS("platform:ar71xx-ehci");
236 static struct platform_driver ehci_ar71xx_driver
= {
237 .probe
= ehci_ar71xx_driver_probe
,
238 .remove
= ehci_ar71xx_driver_remove
,
240 .name
= "ar71xx-ehci",