1 From dbcbcdd001c5943adbb18db3b8f0dafc405559eb Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Tue, 13 Mar 2012 01:04:53 +0100
4 Subject: [PATCH 03/47] USB: use generic platform driver on ath79
6 The ath79 usb driver doesn't do anything special and is now converted
7 to the generic ehci and ohci driver.
8 This was tested on a TP-Link TL-WR1043ND (AR9132)
10 Acked-by: Gabor Juhos <juhosg@openwrt.org>
11 CC: Imre Kaloz <kaloz@openwrt.org>
12 CC: linux-mips@linux-mips.org
13 CC: Ralf Baechle <ralf@linux-mips.org>
14 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
15 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 arch/mips/ath79/dev-usb.c | 31 +++++-
18 drivers/usb/host/Kconfig | 12 ++-
19 drivers/usb/host/ehci-ath79.c | 208 -----------------------------------------
20 drivers/usb/host/ehci-hcd.c | 5 -
21 drivers/usb/host/ohci-ath79.c | 151 -----------------------------
22 drivers/usb/host/ohci-hcd.c | 5 -
23 6 files changed, 35 insertions(+), 377 deletions(-)
24 delete mode 100644 drivers/usb/host/ehci-ath79.c
25 delete mode 100644 drivers/usb/host/ohci-ath79.c
27 --- a/arch/mips/ath79/dev-usb.c
28 +++ b/arch/mips/ath79/dev-usb.c
30 #include <linux/irq.h>
31 #include <linux/dma-mapping.h>
32 #include <linux/platform_device.h>
33 +#include <linux/usb/ehci_pdriver.h>
34 +#include <linux/usb/ohci_pdriver.h>
36 #include <asm/mach-ath79/ath79.h>
37 #include <asm/mach-ath79/ar71xx_regs.h>
38 @@ -36,14 +38,19 @@ static struct resource ath79_ohci_resour
41 static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32);
43 +static struct usb_ohci_pdata ath79_ohci_pdata = {
46 static struct platform_device ath79_ohci_device = {
47 - .name = "ath79-ohci",
48 + .name = "ohci-platform",
50 .resource = ath79_ohci_resources,
51 .num_resources = ARRAY_SIZE(ath79_ohci_resources),
53 .dma_mask = &ath79_ohci_dmamask,
54 .coherent_dma_mask = DMA_BIT_MASK(32),
55 + .platform_data = &ath79_ohci_pdata,
59 @@ -60,8 +67,20 @@ static struct resource ath79_ehci_resour
62 static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32);
64 +static struct usb_ehci_pdata ath79_ehci_pdata_v1 = {
65 + .has_synopsys_hc_bug = 1,
66 + .port_power_off = 1,
69 +static struct usb_ehci_pdata ath79_ehci_pdata_v2 = {
70 + .caps_offset = 0x100,
72 + .port_power_off = 1,
75 static struct platform_device ath79_ehci_device = {
76 - .name = "ath79-ehci",
77 + .name = "ehci-platform",
79 .resource = ath79_ehci_resources,
80 .num_resources = ARRAY_SIZE(ath79_ehci_resources),
81 @@ -101,7 +120,7 @@ static void __init ath79_usb_setup(void)
83 ath79_ehci_resources[0].start = AR71XX_EHCI_BASE;
84 ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1;
85 - ath79_ehci_device.name = "ar71xx-ehci";
86 + ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1;
87 platform_device_register(&ath79_ehci_device);
90 @@ -142,7 +161,7 @@ static void __init ar724x_usb_setup(void
92 ath79_ehci_resources[0].start = AR724X_EHCI_BASE;
93 ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1;
94 - ath79_ehci_device.name = "ar724x-ehci";
95 + ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
96 platform_device_register(&ath79_ehci_device);
99 @@ -159,7 +178,7 @@ static void __init ar913x_usb_setup(void
101 ath79_ehci_resources[0].start = AR913X_EHCI_BASE;
102 ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1;
103 - ath79_ehci_device.name = "ar913x-ehci";
104 + ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
105 platform_device_register(&ath79_ehci_device);
108 @@ -176,7 +195,7 @@ static void __init ar933x_usb_setup(void
110 ath79_ehci_resources[0].start = AR933X_EHCI_BASE;
111 ath79_ehci_resources[0].end = AR933X_EHCI_BASE + AR933X_EHCI_SIZE - 1;
112 - ath79_ehci_device.name = "ar933x-ehci";
113 + ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2;
114 platform_device_register(&ath79_ehci_device);
117 --- a/drivers/usb/host/Kconfig
118 +++ b/drivers/usb/host/Kconfig
119 @@ -218,11 +218,15 @@ config USB_CNS3XXX_EHCI
122 config USB_EHCI_ATH79
123 - bool "EHCI support for AR7XXX/AR9XXX SoCs"
124 + bool "EHCI support for AR7XXX/AR9XXX SoCs (DEPRECATED)"
125 depends on USB_EHCI_HCD && (SOC_AR71XX || SOC_AR724X || SOC_AR913X || SOC_AR933X)
126 select USB_EHCI_ROOT_HUB_TT
127 + select USB_EHCI_HCD_PLATFORM
130 + This option is deprecated now and the driver was removed, use
131 + USB_EHCI_HCD_PLATFORM instead.
133 Enables support for the built-in EHCI controller present
134 on the Atheros AR7XXX/AR9XXX SoCs.
136 @@ -312,10 +316,14 @@ config USB_OHCI_HCD_OMAP3
137 OMAP3 and later chips.
139 config USB_OHCI_ATH79
140 - bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs"
141 + bool "USB OHCI support for the Atheros AR71XX/AR7240 SoCs (DEPRECATED)"
142 depends on USB_OHCI_HCD && (SOC_AR71XX || SOC_AR724X)
143 + select USB_OHCI_HCD_PLATFORM
146 + This option is deprecated now and the driver was removed, use
147 + USB_OHCI_HCD_PLATFORM instead.
149 Enables support for the built-in OHCI controller present on the
150 Atheros AR71XX/AR7240 SoCs.
152 --- a/drivers/usb/host/ehci-ath79.c
156 - * Bus Glue for Atheros AR7XXX/AR9XXX built-in EHCI controller.
158 - * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
159 - * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
161 - * Parts of this file are based on Atheros' 2.6.15 BSP
162 - * Copyright (C) 2007 Atheros Communications, Inc.
164 - * This program is free software; you can redistribute it and/or modify it
165 - * under the terms of the GNU General Public License version 2 as published
166 - * by the Free Software Foundation.
169 -#include <linux/platform_device.h>
172 - EHCI_ATH79_IP_V1 = 0,
176 -static const struct platform_device_id ehci_ath79_id_table[] = {
178 - .name = "ar71xx-ehci",
179 - .driver_data = EHCI_ATH79_IP_V1,
182 - .name = "ar724x-ehci",
183 - .driver_data = EHCI_ATH79_IP_V2,
186 - .name = "ar913x-ehci",
187 - .driver_data = EHCI_ATH79_IP_V2,
190 - .name = "ar933x-ehci",
191 - .driver_data = EHCI_ATH79_IP_V2,
194 - /* terminating entry */
198 -MODULE_DEVICE_TABLE(platform, ehci_ath79_id_table);
200 -static int ehci_ath79_init(struct usb_hcd *hcd)
202 - struct ehci_hcd *ehci = hcd_to_ehci(hcd);
203 - struct platform_device *pdev = to_platform_device(hcd->self.controller);
204 - const struct platform_device_id *id;
207 - id = platform_get_device_id(pdev);
209 - dev_err(hcd->self.controller, "missing device id\n");
213 - switch (id->driver_data) {
214 - case EHCI_ATH79_IP_V1:
215 - ehci->has_synopsys_hc_bug = 1;
217 - ehci->caps = hcd->regs;
218 - ehci->regs = hcd->regs +
220 - ehci_readl(ehci, &ehci->caps->hc_capbase));
223 - case EHCI_ATH79_IP_V2:
226 - ehci->caps = hcd->regs + 0x100;
227 - ehci->regs = hcd->regs + 0x100 +
229 - ehci_readl(ehci, &ehci->caps->hc_capbase));
236 - dbg_hcs_params(ehci, "reset");
237 - dbg_hcc_params(ehci, "reset");
238 - ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
243 - ret = ehci_init(hcd);
247 - ehci_port_power(ehci, 0);
252 -static const struct hc_driver ehci_ath79_hc_driver = {
253 - .description = hcd_name,
254 - .product_desc = "Atheros built-in EHCI controller",
255 - .hcd_priv_size = sizeof(struct ehci_hcd),
257 - .flags = HCD_MEMORY | HCD_USB2,
259 - .reset = ehci_ath79_init,
262 - .shutdown = ehci_shutdown,
264 - .urb_enqueue = ehci_urb_enqueue,
265 - .urb_dequeue = ehci_urb_dequeue,
266 - .endpoint_disable = ehci_endpoint_disable,
267 - .endpoint_reset = ehci_endpoint_reset,
269 - .get_frame_number = ehci_get_frame,
271 - .hub_status_data = ehci_hub_status_data,
272 - .hub_control = ehci_hub_control,
274 - .relinquish_port = ehci_relinquish_port,
275 - .port_handed_over = ehci_port_handed_over,
277 - .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
280 -static int ehci_ath79_probe(struct platform_device *pdev)
282 - struct usb_hcd *hcd;
283 - struct resource *res;
287 - if (usb_disabled())
290 - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
292 - dev_dbg(&pdev->dev, "no IRQ specified\n");
297 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
299 - dev_dbg(&pdev->dev, "no base address specified\n");
303 - hcd = usb_create_hcd(&ehci_ath79_hc_driver, &pdev->dev,
304 - dev_name(&pdev->dev));
308 - hcd->rsrc_start = res->start;
309 - hcd->rsrc_len = resource_size(res);
311 - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
312 - dev_dbg(&pdev->dev, "controller already in use\n");
317 - hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
319 - dev_dbg(&pdev->dev, "error mapping memory\n");
321 - goto err_release_region;
324 - ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
331 - iounmap(hcd->regs);
334 - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
340 -static int ehci_ath79_remove(struct platform_device *pdev)
342 - struct usb_hcd *hcd = platform_get_drvdata(pdev);
344 - usb_remove_hcd(hcd);
345 - iounmap(hcd->regs);
346 - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
352 -static struct platform_driver ehci_ath79_driver = {
353 - .probe = ehci_ath79_probe,
354 - .remove = ehci_ath79_remove,
355 - .id_table = ehci_ath79_id_table,
357 - .owner = THIS_MODULE,
358 - .name = "ath79-ehci",
362 -MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ath79-ehci");
363 --- a/drivers/usb/host/ehci-hcd.c
364 +++ b/drivers/usb/host/ehci-hcd.c
365 @@ -1356,11 +1356,6 @@ MODULE_LICENSE ("GPL");
366 #define PLATFORM_DRIVER s5p_ehci_driver
369 -#ifdef CONFIG_USB_EHCI_ATH79
370 -#include "ehci-ath79.c"
371 -#define PLATFORM_DRIVER ehci_ath79_driver
374 #ifdef CONFIG_SPARC_LEON
375 #include "ehci-grlib.c"
376 #define PLATFORM_DRIVER ehci_grlib_driver
377 --- a/drivers/usb/host/ohci-ath79.c
381 - * OHCI HCD (Host Controller Driver) for USB.
383 - * Bus Glue for Atheros AR71XX/AR724X built-in OHCI controller.
385 - * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
386 - * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
388 - * Parts of this file are based on Atheros' 2.6.15 BSP
389 - * Copyright (C) 2007 Atheros Communications, Inc.
391 - * This program is free software; you can redistribute it and/or modify it
392 - * under the terms of the GNU General Public License version 2 as published
393 - * by the Free Software Foundation.
396 -#include <linux/platform_device.h>
398 -static int __devinit ohci_ath79_start(struct usb_hcd *hcd)
400 - struct ohci_hcd *ohci = hcd_to_ohci(hcd);
403 - ret = ohci_init(ohci);
407 - ret = ohci_run(ohci);
418 -static const struct hc_driver ohci_ath79_hc_driver = {
419 - .description = hcd_name,
420 - .product_desc = "Atheros built-in OHCI controller",
421 - .hcd_priv_size = sizeof(struct ohci_hcd),
424 - .flags = HCD_USB11 | HCD_MEMORY,
426 - .start = ohci_ath79_start,
428 - .shutdown = ohci_shutdown,
430 - .urb_enqueue = ohci_urb_enqueue,
431 - .urb_dequeue = ohci_urb_dequeue,
432 - .endpoint_disable = ohci_endpoint_disable,
435 - * scheduling support
437 - .get_frame_number = ohci_get_frame,
442 - .hub_status_data = ohci_hub_status_data,
443 - .hub_control = ohci_hub_control,
444 - .start_port_reset = ohci_start_port_reset,
447 -static int ohci_ath79_probe(struct platform_device *pdev)
449 - struct usb_hcd *hcd;
450 - struct resource *res;
454 - if (usb_disabled())
457 - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
459 - dev_dbg(&pdev->dev, "no IRQ specified\n");
464 - hcd = usb_create_hcd(&ohci_ath79_hc_driver, &pdev->dev,
465 - dev_name(&pdev->dev));
469 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
471 - dev_dbg(&pdev->dev, "no base address specified\n");
475 - hcd->rsrc_start = res->start;
476 - hcd->rsrc_len = resource_size(res);
478 - if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
479 - dev_dbg(&pdev->dev, "controller already in use\n");
484 - hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
486 - dev_dbg(&pdev->dev, "error mapping memory\n");
488 - goto err_release_region;
491 - ohci_hcd_init(hcd_to_ohci(hcd));
493 - ret = usb_add_hcd(hcd, irq, 0);
500 - iounmap(hcd->regs);
502 - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
508 -static int ohci_ath79_remove(struct platform_device *pdev)
510 - struct usb_hcd *hcd = platform_get_drvdata(pdev);
512 - usb_remove_hcd(hcd);
513 - iounmap(hcd->regs);
514 - release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
520 -static struct platform_driver ohci_hcd_ath79_driver = {
521 - .probe = ohci_ath79_probe,
522 - .remove = ohci_ath79_remove,
523 - .shutdown = usb_hcd_platform_shutdown,
525 - .name = "ath79-ohci",
526 - .owner = THIS_MODULE,
530 -MODULE_ALIAS(PLATFORM_MODULE_PREFIX "ath79-ohci");
531 --- a/drivers/usb/host/ohci-hcd.c
532 +++ b/drivers/usb/host/ohci-hcd.c
533 @@ -1111,11 +1111,6 @@ MODULE_LICENSE ("GPL");
534 #define PLATFORM_DRIVER ohci_hcd_cns3xxx_driver
537 -#ifdef CONFIG_USB_OHCI_ATH79
538 -#include "ohci-ath79.c"
539 -#define PLATFORM_DRIVER ohci_hcd_ath79_driver
542 #ifdef CONFIG_CPU_XLR
543 #include "ohci-xls.c"
544 #define PLATFORM_DRIVER ohci_xls_driver