2 * Bus Glue for the built-in OHCI controller of the Ralink RT3662/RT3883 SoCs
4 * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
6 * Parts of this file are based on Ralink's 2.6.21 BSP
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
13 #include <linux/platform_device.h>
14 #include <asm/mach-ralink/rt3883.h>
15 #include <asm/mach-ralink/rt3883_ohci_platform.h>
17 static int __devinit
ohci_rt3883_start(struct usb_hcd
*hcd
)
19 struct ohci_hcd
*ohci
= hcd_to_ohci(hcd
);
22 ret
= ohci_init(ohci
);
37 static const struct hc_driver ohci_rt3883_hc_driver
= {
38 .description
= hcd_name
,
39 .product_desc
= "Ralink RT3883 built-in OHCI controller",
40 .hcd_priv_size
= sizeof(struct ohci_hcd
),
43 .flags
= HCD_USB11
| HCD_MEMORY
,
45 .start
= ohci_rt3883_start
,
47 .shutdown
= ohci_shutdown
,
49 .urb_enqueue
= ohci_urb_enqueue
,
50 .urb_dequeue
= ohci_urb_dequeue
,
51 .endpoint_disable
= ohci_endpoint_disable
,
56 .get_frame_number
= ohci_get_frame
,
61 .hub_status_data
= ohci_hub_status_data
,
62 .hub_control
= ohci_hub_control
,
63 .start_port_reset
= ohci_start_port_reset
,
66 static int ohci_rt3883_probe(struct platform_device
*pdev
)
68 struct rt3883_ohci_platform_data
*pdata
;
77 res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, 0);
79 dev_dbg(&pdev
->dev
, "no IRQ specified for %s\n",
80 dev_name(&pdev
->dev
));
85 hcd
= usb_create_hcd(&ohci_rt3883_hc_driver
,
86 &pdev
->dev
, dev_name(&pdev
->dev
));
90 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
92 dev_dbg(&pdev
->dev
, "no base address specified for %s\n",
93 dev_name(&pdev
->dev
));
97 hcd
->rsrc_start
= res
->start
;
98 hcd
->rsrc_len
= res
->end
- res
->start
+ 1;
100 if (!request_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
, hcd_name
)) {
101 dev_dbg(&pdev
->dev
, "controller already in use\n");
106 hcd
->regs
= ioremap(hcd
->rsrc_start
, hcd
->rsrc_len
);
108 dev_dbg(&pdev
->dev
, "error mapping memory\n");
110 goto err_release_region
;
113 pdata
= pdev
->dev
.platform_data
;
114 if (pdata
&& pdata
->start_hw
)
117 ohci_hcd_init(hcd_to_ohci(hcd
));
119 ret
= usb_add_hcd(hcd
, irq
, IRQF_SHARED
);
128 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
134 static int ohci_rt3883_remove(struct platform_device
*pdev
)
136 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
137 struct rt3883_ohci_platform_data
*pdata
;
141 release_mem_region(hcd
->rsrc_start
, hcd
->rsrc_len
);
144 pdata
= pdev
->dev
.platform_data
;
145 if (pdata
&& pdata
->stop_hw
)
151 static struct platform_driver ohci_rt3883_driver
= {
152 .probe
= ohci_rt3883_probe
,
153 .remove
= ohci_rt3883_remove
,
154 .shutdown
= usb_hcd_platform_shutdown
,
156 .name
= "rt3883-ohci",
157 .owner
= THIS_MODULE
,
161 MODULE_ALIAS("platform:rt3883-ohci");