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
);
76 ehci
= hcd_to_ehci(hcd
);
77 ehci
->caps
= hcd
->regs
;
78 ehci
->regs
= hcd
->regs
+ HC_LENGTH(readl(&ehci
->caps
->hc_capbase
));
79 ehci
->hcs_params
= readl(&ehci
->caps
->hcs_params
);
82 ret
= usb_add_hcd(hcd
, irq
, IRQF_DISABLED
| IRQF_SHARED
);
89 ar71xx_stop_ehci(pdev
);
93 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
99 /* may be called without controller electrically present */
100 /* may be called with controller, bus, and devices active */
103 * usb_ehci_ar71xx_remove - shutdown processing for AR71xx-based HCDs
104 * @dev: USB Host Controller being removed
105 * Context: !in_interrupt()
107 * Reverses the effect of usb_hcd_ar71xx_probe(), first invoking
108 * the HCD's stop() method. It is always called from a thread
109 * context, normally "rmmod", "apmd", or something similar.
112 static void usb_ehci_ar71xx_remove(struct usb_hcd
*hcd
,
113 struct platform_device
*pdev
)
116 ar71xx_stop_ehci(pdev
);
118 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
122 static const struct hc_driver ehci_ar71xx_hc_driver
= {
123 .description
= hcd_name
,
124 .product_desc
= "Atheros AR71xx built-in EHCI controller",
125 .hcd_priv_size
= sizeof(struct ehci_hcd
),
127 * generic hardware linkage
130 .flags
= HCD_MEMORY
| HCD_USB2
,
133 * basic lifecycle operations
138 .shutdown
= ehci_shutdown
,
141 * managing i/o requests and associated device resources
143 .urb_enqueue
= ehci_urb_enqueue
,
144 .urb_dequeue
= ehci_urb_dequeue
,
145 .endpoint_disable
= ehci_endpoint_disable
,
150 .get_frame_number
= ehci_get_frame
,
155 .hub_status_data
= ehci_hub_status_data
,
156 .hub_control
= ehci_hub_control
,
158 .hub_suspend
= ehci_hub_suspend
,
159 .hub_resume
= ehci_hub_resume
,
163 static int ehci_hcd_ar71xx_drv_probe(struct platform_device
*pdev
)
165 struct usb_hcd
*hcd
= NULL
;
170 ret
= usb_ehci_ar71xx_probe(&ehci_ar71xx_hc_driver
, &hcd
, pdev
);
175 static int ehci_hcd_ar71xx_drv_remove(struct platform_device
*pdev
)
177 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
179 usb_ehci_ar71xx_remove(hcd
, pdev
);
183 static struct platform_driver ehci_hcd_ar71xx_driver
= {
184 .probe
= ehci_hcd_ar71xx_drv_probe
,
185 .remove
= ehci_hcd_ar71xx_drv_remove
,
186 .shutdown
= usb_hcd_platform_shutdown
,
188 .name
= "ar71xx-ehci",
189 .bus
= &platform_bus_type
193 MODULE_ALIAS("ar71xx-ehci");