2 * Bus Glue for Atheros AR7XXX/AR9XXX built-in EHCI controller.
4 * Copyright (C) 2008-2011 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>
22 static const struct platform_device_id ehci_ath79_id_table
[] = {
24 .name
= "ar71xx-ehci",
25 .driver_data
= EHCI_ATH79_IP_V1
,
28 .name
= "ar724x-ehci",
29 .driver_data
= EHCI_ATH79_IP_V2
,
32 .name
= "ar913x-ehci",
33 .driver_data
= EHCI_ATH79_IP_V2
,
36 .name
= "ar933x-ehci",
37 .driver_data
= EHCI_ATH79_IP_V2
,
40 /* terminating entry */
44 MODULE_DEVICE_TABLE(platform
, ehci_ath79_id_table
);
46 static int ehci_ath79_init(struct usb_hcd
*hcd
)
48 struct ehci_hcd
*ehci
= hcd_to_ehci(hcd
);
49 struct platform_device
*pdev
= to_platform_device(hcd
->self
.controller
);
50 const struct platform_device_id
*id
;
53 id
= platform_get_device_id(pdev
);
55 dev_err(hcd
->self
.controller
, "missing device id\n");
59 switch (id
->driver_data
) {
60 case EHCI_ATH79_IP_V1
:
61 ehci
->has_synopsys_hc_bug
= 1;
63 ehci
->caps
= hcd
->regs
;
64 ehci
->regs
= hcd
->regs
+
66 ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
69 case EHCI_ATH79_IP_V2
:
72 ehci
->caps
= hcd
->regs
+ 0x100;
73 ehci
->regs
= hcd
->regs
+ 0x100 +
75 ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
82 dbg_hcs_params(ehci
, "reset");
83 dbg_hcc_params(ehci
, "reset");
84 ehci
->hcs_params
= ehci_readl(ehci
, &ehci
->caps
->hcs_params
);
93 ehci_port_power(ehci
, 0);
98 static const struct hc_driver ehci_ath79_hc_driver
= {
99 .description
= hcd_name
,
100 .product_desc
= "Atheros built-in EHCI controller",
101 .hcd_priv_size
= sizeof(struct ehci_hcd
),
103 .flags
= HCD_MEMORY
| HCD_USB2
,
105 .reset
= ehci_ath79_init
,
108 .shutdown
= ehci_shutdown
,
110 .urb_enqueue
= ehci_urb_enqueue
,
111 .urb_dequeue
= ehci_urb_dequeue
,
112 .endpoint_disable
= ehci_endpoint_disable
,
113 .endpoint_reset
= ehci_endpoint_reset
,
115 .get_frame_number
= ehci_get_frame
,
117 .hub_status_data
= ehci_hub_status_data
,
118 .hub_control
= ehci_hub_control
,
120 .relinquish_port
= ehci_relinquish_port
,
121 .port_handed_over
= ehci_port_handed_over
,
123 .clear_tt_buffer_complete
= ehci_clear_tt_buffer_complete
,
126 static int ehci_ath79_probe(struct platform_device
*pdev
)
129 struct resource
*res
;
136 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
138 dev_dbg(&pdev
->dev
, "no IRQ specified\n");
143 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
145 dev_dbg(&pdev
->dev
, "no base address specified\n");
149 hcd
= usb_create_hcd(&ehci_ath79_hc_driver
, &pdev
->dev
,
150 dev_name(&pdev
->dev
));
154 hcd
->rsrc_start
= res
->start
;
155 hcd
->rsrc_len
= resource_size(res
);
157 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
158 dev_dbg(&pdev
->dev
, "controller already in use\n");
163 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
165 dev_dbg(&pdev
->dev
, "error mapping memory\n");
167 goto err_release_region
;
170 ret
= usb_add_hcd(hcd
, irq
, IRQF_SHARED
);
180 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
186 static int ehci_ath79_remove(struct platform_device
*pdev
)
188 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
192 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
198 static struct platform_driver ehci_ath79_driver
= {
199 .probe
= ehci_ath79_probe
,
200 .remove
= ehci_ath79_remove
,
201 .id_table
= ehci_ath79_id_table
,
203 .owner
= THIS_MODULE
,
204 .name
= "ath79-ehci",
208 MODULE_ALIAS(PLATFORM_MODULE_PREFIX
"ath79-ehci");