Commit | Line | Data |
---|---|---|
00b3ed16 GKH |
1 | #include "hfa384x_usb.c" |
2 | #include "prism2mgmt.c" | |
3 | #include "prism2mib.c" | |
4 | #include "prism2sta.c" | |
76e3e7c4 | 5 | #include "prism2fw.c" |
00b3ed16 | 6 | |
297f06ce MT |
7 | #define PRISM_USB_DEVICE(vid, pid, name) \ |
8 | USB_DEVICE(vid, pid), \ | |
9 | .driver_info = (unsigned long) name | |
00b3ed16 GKH |
10 | |
11 | static struct usb_device_id usb_prism_tbl[] = { | |
12 | {PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")}, | |
13 | {PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")}, | |
14 | {PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")}, | |
f4ee0f42 MM |
15 | {PRISM_USB_DEVICE |
16 | (0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, | |
17 | {PRISM_USB_DEVICE | |
18 | (0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")}, | |
19 | {PRISM_USB_DEVICE | |
20 | (0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")}, | |
21 | {PRISM_USB_DEVICE | |
22 | (0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")}, | |
23 | {PRISM_USB_DEVICE | |
24 | (0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")}, | |
25 | {PRISM_USB_DEVICE | |
26 | (0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")}, | |
09257969 JD |
27 | {PRISM_USB_DEVICE |
28 | (0x049f, 0x0033, | |
29 | "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")}, | |
f4ee0f42 MM |
30 | {PRISM_USB_DEVICE |
31 | (0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")}, | |
32 | {PRISM_USB_DEVICE | |
33 | (0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, | |
34 | {PRISM_USB_DEVICE | |
35 | (0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")}, | |
36 | {PRISM_USB_DEVICE | |
37 | (0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")}, | |
38 | {PRISM_USB_DEVICE | |
39 | (0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")}, | |
00b3ed16 | 40 | {PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")}, |
f4ee0f42 MM |
41 | {PRISM_USB_DEVICE |
42 | (0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")}, | |
43 | {PRISM_USB_DEVICE | |
44 | (0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")}, | |
45 | {PRISM_USB_DEVICE | |
46 | (0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")}, | |
47 | {PRISM_USB_DEVICE | |
48 | (0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")}, | |
49 | {PRISM_USB_DEVICE | |
50 | (0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")}, | |
51 | {PRISM_USB_DEVICE | |
52 | (0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")}, | |
53 | {PRISM_USB_DEVICE | |
54 | (0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")}, | |
55 | {PRISM_USB_DEVICE | |
56 | (0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")}, | |
00b3ed16 | 57 | {PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")}, |
f4ee0f42 | 58 | {PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")}, |
00b3ed16 GKH |
59 | {PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")}, |
60 | {PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")}, | |
f4ee0f42 MM |
61 | {PRISM_USB_DEVICE |
62 | (0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")}, | |
00b3ed16 GKH |
63 | {PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")}, |
64 | {PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")}, | |
65 | {PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")}, | |
66 | {PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")}, | |
67 | {PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")}, | |
f4ee0f42 MM |
68 | {PRISM_USB_DEVICE |
69 | (0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")}, | |
00b3ed16 | 70 | {PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")}, |
f4ee0f42 MM |
71 | {PRISM_USB_DEVICE |
72 | (0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")}, | |
00b3ed16 | 73 | {PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")}, |
f4ee0f42 MM |
74 | {PRISM_USB_DEVICE |
75 | (0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")}, | |
76 | {PRISM_USB_DEVICE | |
77 | (0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")}, | |
00b3ed16 GKH |
78 | { /* terminator */ } |
79 | }; | |
80 | ||
81 | MODULE_DEVICE_TABLE(usb, usb_prism_tbl); | |
82 | ||
83 | /*---------------------------------------------------------------- | |
84 | * prism2sta_probe_usb | |
85 | * | |
86 | * Probe routine called by the USB subsystem. | |
87 | * | |
88 | * Arguments: | |
89 | * dev ptr to the usb_device struct | |
90 | * ifnum interface number being offered | |
91 | * | |
92 | * Returns: | |
93 | * NULL - we're not claiming the device+interface | |
94 | * non-NULL - we are claiming the device+interface and | |
95 | * this is a ptr to the data we want back | |
96 | * when disconnect is called. | |
97 | * | |
98 | * Side effects: | |
99 | * | |
100 | * Call context: | |
101 | * I'm not sure, assume it's interrupt. | |
102 | * | |
103 | ----------------------------------------------------------------*/ | |
f4ee0f42 MM |
104 | static int prism2sta_probe_usb(struct usb_interface *interface, |
105 | const struct usb_device_id *id) | |
00b3ed16 | 106 | { |
00b3ed16 | 107 | struct usb_device *dev; |
00b3ed16 | 108 | |
f4ee0f42 MM |
109 | wlandevice_t *wlandev = NULL; |
110 | hfa384x_t *hw = NULL; | |
111 | int result = 0; | |
00b3ed16 | 112 | |
00b3ed16 | 113 | dev = interface_to_usbdev(interface); |
297f06ce MT |
114 | wlandev = create_wlan(); |
115 | if (wlandev == NULL) { | |
318e16b9 | 116 | dev_err(&interface->dev, "Memory allocation failure.\n"); |
00b3ed16 GKH |
117 | result = -EIO; |
118 | goto failed; | |
119 | } | |
120 | hw = wlandev->priv; | |
121 | ||
cb3126e6 | 122 | if (wlan_setup(wlandev, &(interface->dev)) != 0) { |
318e16b9 | 123 | dev_err(&interface->dev, "wlan_setup() failed.\n"); |
00b3ed16 GKH |
124 | result = -EIO; |
125 | goto failed; | |
126 | } | |
127 | ||
128 | /* Initialize the hw data */ | |
129 | hfa384x_create(hw, dev); | |
130 | hw->wlandev = wlandev; | |
131 | ||
132 | /* Register the wlandev, this gets us a name and registers the | |
133 | * linux netdevice. | |
134 | */ | |
00b3ed16 | 135 | SET_NETDEV_DEV(wlandev->netdev, &(interface->dev)); |
00b3ed16 GKH |
136 | |
137 | /* Do a chip-level reset on the MAC */ | |
138 | if (prism2_doreset) { | |
139 | result = hfa384x_corereset(hw, | |
f4ee0f42 MM |
140 | prism2_reset_holdtime, |
141 | prism2_reset_settletime, 0); | |
00b3ed16 GKH |
142 | if (result != 0) { |
143 | unregister_wlandev(wlandev); | |
144 | hfa384x_destroy(hw); | |
145 | result = -EIO; | |
318e16b9 | 146 | dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); |
00b3ed16 GKH |
147 | goto failed; |
148 | } | |
149 | } | |
150 | ||
00b3ed16 | 151 | usb_get_dev(dev); |
00b3ed16 GKH |
152 | |
153 | wlandev->msdstate = WLAN_MSD_HWPRESENT; | |
154 | ||
76e3e7c4 KR |
155 | /* Try and load firmware, then enable card before we register */ |
156 | prism2_fwtry(dev, wlandev); | |
157 | prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); | |
158 | ||
f4ee0f42 | 159 | if (register_wlandev(wlandev) != 0) { |
318e16b9 | 160 | dev_err(&interface->dev, "register_wlandev() failed.\n"); |
1d1b6985 RK |
161 | result = -EIO; |
162 | goto failed; | |
f4ee0f42 | 163 | } |
1d1b6985 | 164 | |
00b3ed16 GKH |
165 | goto done; |
166 | ||
f4ee0f42 | 167 | failed: |
7c98f718 MM |
168 | kfree(wlandev); |
169 | kfree(hw); | |
00b3ed16 GKH |
170 | wlandev = NULL; |
171 | ||
f4ee0f42 | 172 | done: |
00b3ed16 GKH |
173 | usb_set_intfdata(interface, wlandev); |
174 | return result; | |
00b3ed16 GKH |
175 | } |
176 | ||
00b3ed16 GKH |
177 | /*---------------------------------------------------------------- |
178 | * prism2sta_disconnect_usb | |
179 | * | |
180 | * Called when a device previously claimed by probe is removed | |
181 | * from the USB. | |
182 | * | |
183 | * Arguments: | |
184 | * dev ptr to the usb_device struct | |
185 | * ptr ptr returned by probe() when the device | |
186 | * was claimed. | |
187 | * | |
188 | * Returns: | |
189 | * Nothing | |
190 | * | |
191 | * Side effects: | |
192 | * | |
193 | * Call context: | |
194 | * process | |
195 | ----------------------------------------------------------------*/ | |
f4ee0f42 | 196 | static void prism2sta_disconnect_usb(struct usb_interface *interface) |
00b3ed16 | 197 | { |
f4ee0f42 | 198 | wlandevice_t *wlandev; |
00b3ed16 | 199 | |
00b3ed16 | 200 | wlandev = (wlandevice_t *) usb_get_intfdata(interface); |
00b3ed16 | 201 | |
f4ee0f42 | 202 | if (wlandev != NULL) { |
00b3ed16 | 203 | LIST_HEAD(cleanlist); |
f4ee0f42 MM |
204 | struct list_head *entry; |
205 | struct list_head *temp; | |
206 | unsigned long flags; | |
00b3ed16 | 207 | |
f4ee0f42 | 208 | hfa384x_t *hw = wlandev->priv; |
00b3ed16 GKH |
209 | |
210 | if (!hw) | |
211 | goto exit; | |
212 | ||
213 | spin_lock_irqsave(&hw->ctlxq.lock, flags); | |
214 | ||
215 | p80211netdev_hwremoved(wlandev); | |
216 | list_splice_init(&hw->ctlxq.reapable, &cleanlist); | |
217 | list_splice_init(&hw->ctlxq.completing, &cleanlist); | |
218 | list_splice_init(&hw->ctlxq.pending, &cleanlist); | |
219 | list_splice_init(&hw->ctlxq.active, &cleanlist); | |
220 | ||
221 | spin_unlock_irqrestore(&hw->ctlxq.lock, flags); | |
222 | ||
223 | /* There's no hardware to shutdown, but the driver | |
224 | * might have some tasks or tasklets that must be | |
225 | * stopped before we can tear everything down. | |
226 | */ | |
227 | prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable); | |
228 | ||
229 | del_singleshot_timer_sync(&hw->throttle); | |
230 | del_singleshot_timer_sync(&hw->reqtimer); | |
231 | del_singleshot_timer_sync(&hw->resptimer); | |
232 | ||
233 | /* Unlink all the URBs. This "removes the wheels" | |
234 | * from the entire CTLX handling mechanism. | |
235 | */ | |
236 | usb_kill_urb(&hw->rx_urb); | |
237 | usb_kill_urb(&hw->tx_urb); | |
238 | usb_kill_urb(&hw->ctlx_urb); | |
239 | ||
240 | tasklet_kill(&hw->completion_bh); | |
241 | tasklet_kill(&hw->reaper_bh); | |
242 | ||
243 | flush_scheduled_work(); | |
244 | ||
245 | /* Now we complete any outstanding commands | |
246 | * and tell everyone who is waiting for their | |
247 | * responses that we have shut down. | |
248 | */ | |
249 | list_for_each(entry, &cleanlist) { | |
f4ee0f42 | 250 | hfa384x_usbctlx_t *ctlx; |
00b3ed16 GKH |
251 | |
252 | ctlx = list_entry(entry, hfa384x_usbctlx_t, list); | |
253 | complete(&ctlx->done); | |
254 | } | |
255 | ||
256 | /* Give any outstanding synchronous commands | |
257 | * a chance to complete. All they need to do | |
258 | * is "wake up", so that's easy. | |
259 | * (I'd like a better way to do this, really.) | |
260 | */ | |
261 | msleep(100); | |
262 | ||
263 | /* Now delete the CTLXs, because no-one else can now. */ | |
264 | list_for_each_safe(entry, temp, &cleanlist) { | |
265 | hfa384x_usbctlx_t *ctlx; | |
266 | ||
267 | ctlx = list_entry(entry, hfa384x_usbctlx_t, list); | |
268 | kfree(ctlx); | |
269 | } | |
270 | ||
271 | /* Unhook the wlandev */ | |
272 | unregister_wlandev(wlandev); | |
273 | wlan_unsetup(wlandev); | |
274 | ||
00b3ed16 | 275 | usb_put_dev(hw->usb); |
00b3ed16 GKH |
276 | |
277 | hfa384x_destroy(hw); | |
278 | kfree(hw); | |
279 | ||
280 | kfree(wlandev); | |
281 | } | |
282 | ||
f4ee0f42 | 283 | exit: |
00b3ed16 | 284 | usb_set_intfdata(interface, NULL); |
00b3ed16 GKH |
285 | } |
286 | ||
59497bba CF |
287 | #ifdef CONFIG_PM |
288 | static int prism2sta_suspend(struct usb_interface *interface, | |
289 | pm_message_t message) | |
290 | { | |
291 | hfa384x_t *hw = NULL; | |
292 | wlandevice_t *wlandev; | |
293 | wlandev = (wlandevice_t *) usb_get_intfdata(interface); | |
294 | if (!wlandev) | |
295 | return -ENODEV; | |
296 | ||
297 | hw = wlandev->priv; | |
298 | if (!hw) | |
299 | return -ENODEV; | |
300 | ||
301 | prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable); | |
302 | ||
303 | usb_kill_urb(&hw->rx_urb); | |
304 | usb_kill_urb(&hw->tx_urb); | |
305 | usb_kill_urb(&hw->ctlx_urb); | |
306 | ||
307 | return 0; | |
308 | } | |
309 | ||
310 | static int prism2sta_resume(struct usb_interface *interface) | |
311 | { | |
312 | int result = 0; | |
313 | hfa384x_t *hw = NULL; | |
314 | wlandevice_t *wlandev; | |
315 | wlandev = (wlandevice_t *) usb_get_intfdata(interface); | |
316 | if (!wlandev) | |
317 | return -ENODEV; | |
318 | ||
319 | hw = wlandev->priv; | |
320 | if (!hw) | |
321 | return -ENODEV; | |
322 | ||
323 | /* Do a chip-level reset on the MAC */ | |
324 | if (prism2_doreset) { | |
325 | result = hfa384x_corereset(hw, | |
326 | prism2_reset_holdtime, | |
327 | prism2_reset_settletime, 0); | |
328 | if (result != 0) { | |
329 | unregister_wlandev(wlandev); | |
330 | hfa384x_destroy(hw); | |
318e16b9 | 331 | dev_err(&interface->dev, "hfa384x_corereset() failed.\n"); |
59497bba CF |
332 | kfree(wlandev); |
333 | kfree(hw); | |
334 | wlandev = NULL; | |
335 | return -ENODEV; | |
336 | } | |
337 | } | |
338 | ||
339 | prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable); | |
340 | ||
341 | return 0; | |
342 | } | |
343 | #else | |
344 | #define prism2sta_suspend NULL | |
345 | #define prism2sta_resume NULL | |
346 | #endif /* CONFIG_PM */ | |
347 | ||
00b3ed16 | 348 | static struct usb_driver prism2_usb_driver = { |
00b3ed16 GKH |
349 | .name = "prism2_usb", |
350 | .probe = prism2sta_probe_usb, | |
351 | .disconnect = prism2sta_disconnect_usb, | |
352 | .id_table = usb_prism_tbl, | |
59497bba CF |
353 | .suspend = prism2sta_suspend, |
354 | .resume = prism2sta_resume, | |
355 | .reset_resume = prism2sta_resume, | |
00b3ed16 GKH |
356 | /* fops, minor? */ |
357 | }; | |
358 | ||
bac2c126 | 359 | module_usb_driver(prism2_usb_driver); |