OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* |
2 | * ADM5120 HCD (Host Controller Driver) for USB |
||
3 | * |
||
4 | * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org> |
||
5 | * |
||
6 | * This file was derived from: drivers/usb/host/ohci-au1xxx.c |
||
7 | * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> |
||
8 | * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> |
||
9 | * (C) Copyright 2002 Hewlett-Packard Company |
||
10 | * |
||
11 | * Written by Christopher Hoover <ch@hpl.hp.com> |
||
12 | * Based on fragments of previous driver by Russell King et al. |
||
13 | * |
||
14 | * Modified for LH7A404 from ahcd-sa1111.c |
||
15 | * by Durgesh Pattamatta <pattamattad@sharpsec.com> |
||
16 | * Modified for AMD Alchemy Au1xxx |
||
17 | * by Matt Porter <mporter@kernel.crashing.org> |
||
18 | * |
||
19 | * This program is free software; you can redistribute it and/or modify it |
||
20 | * under the terms of the GNU General Public License version 2 as published |
||
21 | * by the Free Software Foundation. |
||
22 | * |
||
23 | */ |
||
24 | |||
25 | #include <linux/platform_device.h> |
||
26 | #include <linux/signal.h> |
||
27 | |||
28 | #include <asm/bootinfo.h> |
||
29 | #include <asm/mach-adm5120/adm5120_defs.h> |
||
30 | |||
31 | #ifdef DEBUG |
||
32 | #define HCD_DBG(f, a...) printk(KERN_DEBUG "%s: " f, hcd_name, ## a) |
||
33 | #else |
||
34 | #define HCD_DBG(f, a...) do {} while (0) |
||
35 | #endif |
||
36 | #define HCD_ERR(f, a...) printk(KERN_ERR "%s: " f, hcd_name, ## a) |
||
37 | #define HCD_INFO(f, a...) printk(KERN_INFO "%s: " f, hcd_name, ## a) |
||
38 | |||
39 | /*-------------------------------------------------------------------------*/ |
||
40 | |||
41 | static int admhc_adm5120_probe(const struct hc_driver *driver, |
||
42 | struct platform_device *dev) |
||
43 | { |
||
44 | int retval; |
||
45 | struct usb_hcd *hcd; |
||
46 | int irq; |
||
47 | struct resource *regs; |
||
48 | |||
49 | /* sanity checks */ |
||
50 | regs = platform_get_resource(dev, IORESOURCE_MEM, 0); |
||
51 | if (!regs) { |
||
52 | HCD_DBG("no IOMEM resource found\n"); |
||
53 | return -ENODEV; |
||
54 | } |
||
55 | |||
56 | irq = platform_get_irq(dev, 0); |
||
57 | if (irq < 0) { |
||
58 | HCD_DBG("no IRQ resource found\n"); |
||
59 | return -ENODEV; |
||
60 | } |
||
61 | |||
62 | hcd = usb_create_hcd(driver, &dev->dev, "ADM5120"); |
||
63 | if (!hcd) |
||
64 | return -ENOMEM; |
||
65 | |||
66 | hcd->rsrc_start = regs->start; |
||
67 | hcd->rsrc_len = regs->end - regs->start + 1; |
||
68 | |||
69 | if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { |
||
70 | HCD_DBG("request_mem_region failed\n"); |
||
71 | retval = -EBUSY; |
||
72 | goto err_dev; |
||
73 | } |
||
74 | |||
75 | hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); |
||
76 | if (!hcd->regs) { |
||
77 | HCD_DBG("ioremap failed\n"); |
||
78 | retval = -ENOMEM; |
||
79 | goto err_mem; |
||
80 | } |
||
81 | |||
82 | admhc_hcd_init(hcd_to_admhcd(hcd)); |
||
83 | |||
84 | retval = usb_add_hcd(hcd, irq, 0); |
||
85 | if (retval) |
||
86 | goto err_io; |
||
87 | |||
88 | return 0; |
||
89 | |||
90 | err_io: |
||
91 | iounmap(hcd->regs); |
||
92 | err_mem: |
||
93 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
||
94 | err_dev: |
||
95 | usb_put_hcd(hcd); |
||
96 | return retval; |
||
97 | } |
||
98 | |||
99 | |||
100 | /* may be called without controller electrically present */ |
||
101 | /* may be called with controller, bus, and devices active */ |
||
102 | |||
103 | static void admhc_adm5120_remove(struct usb_hcd *hcd, |
||
104 | struct platform_device *dev) |
||
105 | { |
||
106 | usb_remove_hcd(hcd); |
||
107 | iounmap(hcd->regs); |
||
108 | release_mem_region(hcd->rsrc_start, hcd->rsrc_len); |
||
109 | usb_put_hcd(hcd); |
||
110 | } |
||
111 | |||
112 | static int admhc_adm5120_start(struct usb_hcd *hcd) |
||
113 | { |
||
114 | struct admhcd *ahcd = hcd_to_admhcd(hcd); |
||
115 | int ret; |
||
116 | |||
117 | ret = admhc_init(ahcd); |
||
118 | if (ret < 0) { |
||
119 | HCD_ERR("unable to init %s\n", hcd->self.bus_name); |
||
120 | goto err; |
||
121 | } |
||
122 | |||
123 | ret = admhc_run(ahcd); |
||
124 | if (ret < 0) { |
||
125 | HCD_ERR("unable to run %s\n", hcd->self.bus_name); |
||
126 | goto err_stop; |
||
127 | } |
||
128 | |||
129 | return 0; |
||
130 | |||
131 | err_stop: |
||
132 | admhc_stop(hcd); |
||
133 | err: |
||
134 | return ret; |
||
135 | } |
||
136 | |||
137 | static const struct hc_driver adm5120_hc_driver = { |
||
138 | .description = hcd_name, |
||
139 | .product_desc = "ADM5120 built-in USB 1.1 Host Controller", |
||
140 | .hcd_priv_size = sizeof(struct admhcd), |
||
141 | |||
142 | /* |
||
143 | * generic hardware linkage |
||
144 | */ |
||
145 | .irq = admhc_irq, |
||
146 | .flags = HCD_USB11 | HCD_MEMORY, |
||
147 | |||
148 | /* |
||
149 | * basic lifecycle operations |
||
150 | */ |
||
151 | .start = admhc_adm5120_start, |
||
152 | .stop = admhc_stop, |
||
153 | .shutdown = admhc_shutdown, |
||
154 | |||
155 | /* |
||
156 | * managing i/o requests and associated device resources |
||
157 | */ |
||
158 | .urb_enqueue = admhc_urb_enqueue, |
||
159 | .urb_dequeue = admhc_urb_dequeue, |
||
160 | .endpoint_disable = admhc_endpoint_disable, |
||
161 | |||
162 | /* |
||
163 | * scheduling support |
||
164 | */ |
||
165 | .get_frame_number = admhc_get_frame_number, |
||
166 | |||
167 | /* |
||
168 | * root hub support |
||
169 | */ |
||
170 | .hub_status_data = admhc_hub_status_data, |
||
171 | .hub_control = admhc_hub_control, |
||
172 | #ifdef CONFIG_PM |
||
173 | .bus_suspend = admhc_bus_suspend, |
||
174 | .bus_resume = admhc_bus_resume, |
||
175 | #endif |
||
176 | .start_port_reset = admhc_start_port_reset, |
||
177 | }; |
||
178 | |||
179 | static int usb_hcd_adm5120_probe(struct platform_device *pdev) |
||
180 | { |
||
181 | int ret; |
||
182 | |||
183 | ret = admhc_adm5120_probe(&adm5120_hc_driver, pdev); |
||
184 | |||
185 | return ret; |
||
186 | } |
||
187 | |||
188 | static int usb_hcd_adm5120_remove(struct platform_device *pdev) |
||
189 | { |
||
190 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
||
191 | |||
192 | admhc_adm5120_remove(hcd, pdev); |
||
193 | |||
194 | return 0; |
||
195 | } |
||
196 | |||
197 | #ifdef CONFIG_PM |
||
198 | /* TODO */ |
||
199 | static int usb_hcd_adm5120_suspend(struct platform_device *dev) |
||
200 | { |
||
201 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
||
202 | |||
203 | return 0; |
||
204 | } |
||
205 | |||
206 | static int usb_hcd_adm5120_resume(struct platform_device *dev) |
||
207 | { |
||
208 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
||
209 | |||
210 | return 0; |
||
211 | } |
||
212 | #else |
||
213 | #define usb_hcd_adm5120_suspend NULL |
||
214 | #define usb_hcd_adm5120_resume NULL |
||
215 | #endif /* CONFIG_PM */ |
||
216 | |||
217 | static struct platform_driver usb_hcd_adm5120_driver = { |
||
218 | .probe = usb_hcd_adm5120_probe, |
||
219 | .remove = usb_hcd_adm5120_remove, |
||
220 | .shutdown = usb_hcd_platform_shutdown, |
||
221 | .suspend = usb_hcd_adm5120_suspend, |
||
222 | .resume = usb_hcd_adm5120_resume, |
||
223 | .driver = { |
||
224 | .name = "adm5120-hcd", |
||
225 | .owner = THIS_MODULE, |
||
226 | }, |
||
227 | }; |
||
228 |