Commit | Line | Data |
---|---|---|
876c9d3a MT |
1 | /** |
2 | * This file contains functions used in USB interface module. | |
3 | */ | |
4 | #include <linux/delay.h> | |
084708b6 | 5 | #include <linux/moduleparam.h> |
876c9d3a MT |
6 | #include <linux/firmware.h> |
7 | #include <linux/netdevice.h> | |
8 | #include <linux/usb.h> | |
9 | ||
ec3eef28 HS |
10 | #define DRV_NAME "usb8xxx" |
11 | ||
876c9d3a | 12 | #include "host.h" |
876c9d3a MT |
13 | #include "decl.h" |
14 | #include "defs.h" | |
15 | #include "dev.h" | |
14e865ba | 16 | #include "cmd.h" |
876c9d3a MT |
17 | #include "if_usb.h" |
18 | ||
eae86bf3 DW |
19 | #define INSANEDEBUG 0 |
20 | #define lbs_deb_usb2(...) do { if (INSANEDEBUG) lbs_deb_usbd(__VA_ARGS__); } while (0) | |
21 | ||
876c9d3a MT |
22 | #define MESSAGE_HEADER_LEN 4 |
23 | ||
82209adc | 24 | static char *lbs_fw_name = "usb8388.bin"; |
10078321 | 25 | module_param_named(fw_name, lbs_fw_name, charp, 0644); |
084708b6 | 26 | |
876c9d3a MT |
27 | static struct usb_device_id if_usb_table[] = { |
28 | /* Enter the device signature inside */ | |
66fcc559 HS |
29 | { USB_DEVICE(0x1286, 0x2001) }, |
30 | { USB_DEVICE(0x05a3, 0x8388) }, | |
876c9d3a MT |
31 | {} /* Terminating entry */ |
32 | }; | |
33 | ||
34 | MODULE_DEVICE_TABLE(usb, if_usb_table); | |
35 | ||
36 | static void if_usb_receive(struct urb *urb); | |
37 | static void if_usb_receive_fwload(struct urb *urb); | |
eae86bf3 DW |
38 | static int if_usb_prog_firmware(struct if_usb_card *cardp); |
39 | static int if_usb_host_to_card(struct lbs_private *priv, uint8_t type, | |
40 | uint8_t *payload, uint16_t nb); | |
eae86bf3 DW |
41 | static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload, |
42 | uint16_t nb); | |
43 | static void if_usb_free(struct if_usb_card *cardp); | |
44 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp); | |
45 | static int if_usb_reset_device(struct if_usb_card *cardp); | |
876c9d3a MT |
46 | |
47 | /** | |
48 | * @brief call back function to handle the status of the URB | |
49 | * @param urb pointer to urb structure | |
50 | * @return N/A | |
51 | */ | |
52 | static void if_usb_write_bulk_callback(struct urb *urb) | |
53 | { | |
eae86bf3 | 54 | struct if_usb_card *cardp = (struct if_usb_card *) urb->context; |
876c9d3a MT |
55 | |
56 | /* handle the transmission complete validations */ | |
57 | ||
954ee164 | 58 | if (urb->status == 0) { |
69f9032d | 59 | struct lbs_private *priv = cardp->priv; |
954ee164 | 60 | |
eae86bf3 DW |
61 | lbs_deb_usb2(&urb->dev->dev, "URB status is successful\n"); |
62 | lbs_deb_usb2(&urb->dev->dev, "Actual length transmitted %d\n", | |
63 | urb->actual_length); | |
954ee164 DW |
64 | |
65 | /* Used for both firmware TX and regular TX. priv isn't | |
66 | * valid at firmware load time. | |
67 | */ | |
e775ed7c DW |
68 | if (priv) |
69 | lbs_host_to_card_done(priv); | |
954ee164 DW |
70 | } else { |
71 | /* print the failure status number for debug */ | |
72 | lbs_pr_info("URB in failure status: %d\n", urb->status); | |
876c9d3a MT |
73 | } |
74 | ||
75 | return; | |
76 | } | |
77 | ||
78 | /** | |
79 | * @brief free tx/rx urb, skb and rx buffer | |
eae86bf3 | 80 | * @param cardp pointer if_usb_card |
876c9d3a MT |
81 | * @return N/A |
82 | */ | |
eae86bf3 | 83 | static void if_usb_free(struct if_usb_card *cardp) |
876c9d3a | 84 | { |
9012b28a | 85 | lbs_deb_enter(LBS_DEB_USB); |
876c9d3a MT |
86 | |
87 | /* Unlink tx & rx urb */ | |
88 | usb_kill_urb(cardp->tx_urb); | |
89 | usb_kill_urb(cardp->rx_urb); | |
90 | ||
91 | usb_free_urb(cardp->tx_urb); | |
92 | cardp->tx_urb = NULL; | |
93 | ||
94 | usb_free_urb(cardp->rx_urb); | |
95 | cardp->rx_urb = NULL; | |
96 | ||
eae86bf3 DW |
97 | kfree(cardp->ep_out_buf); |
98 | cardp->ep_out_buf = NULL; | |
876c9d3a | 99 | |
9012b28a | 100 | lbs_deb_leave(LBS_DEB_USB); |
876c9d3a MT |
101 | } |
102 | ||
4694961c | 103 | static void if_usb_setup_firmware(struct lbs_private *priv) |
04c80f1a | 104 | { |
4365929d | 105 | struct if_usb_card *cardp = priv->card; |
04c80f1a | 106 | struct cmd_ds_set_boot2_ver b2_cmd; |
4694961c | 107 | struct cmd_ds_802_11_fw_wake_method wake_method; |
04c80f1a | 108 | |
9fae899c | 109 | b2_cmd.hdr.size = cpu_to_le16(sizeof(b2_cmd)); |
04c80f1a | 110 | b2_cmd.action = 0; |
4365929d | 111 | b2_cmd.version = cardp->boot2_version; |
04c80f1a | 112 | |
b23b2061 | 113 | if (lbs_cmd_with_response(priv, CMD_SET_BOOT2_VER, &b2_cmd)) |
04c80f1a | 114 | lbs_deb_usb("Setting boot2 version failed\n"); |
4694961c DW |
115 | |
116 | priv->wol_gpio = 2; /* Wake via GPIO2... */ | |
117 | priv->wol_gap = 20; /* ... after 20ms */ | |
118 | lbs_host_sleep_cfg(priv, EHS_WAKE_ON_UNICAST_DATA); | |
119 | ||
120 | wake_method.hdr.size = cpu_to_le16(sizeof(wake_method)); | |
121 | wake_method.action = cpu_to_le16(CMD_ACT_GET); | |
122 | if (lbs_cmd_with_response(priv, CMD_802_11_FW_WAKE_METHOD, &wake_method)) { | |
123 | lbs_pr_info("Firmware does not seem to support PS mode\n"); | |
124 | } else { | |
125 | if (le16_to_cpu(wake_method.method) == CMD_WAKE_METHOD_COMMAND_INT) { | |
126 | lbs_deb_usb("Firmware seems to support PS with wake-via-command\n"); | |
127 | priv->ps_supported = 1; | |
128 | } else { | |
129 | /* The versions which boot up this way don't seem to | |
130 | work even if we set it to the command interrupt */ | |
131 | lbs_pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n"); | |
132 | } | |
133 | } | |
04c80f1a DW |
134 | } |
135 | ||
2fd6cfe3 | 136 | static void if_usb_fw_timeo(unsigned long priv) |
4f82f5c8 | 137 | { |
eae86bf3 | 138 | struct if_usb_card *cardp = (void *)priv; |
04c80f1a | 139 | |
4f82f5c8 DW |
140 | if (cardp->fwdnldover) { |
141 | lbs_deb_usb("Download complete, no event. Assuming success\n"); | |
142 | } else { | |
143 | lbs_pr_err("Download timed out\n"); | |
144 | cardp->surprise_removed = 1; | |
145 | } | |
146 | wake_up(&cardp->fw_wq); | |
147 | } | |
eae86bf3 | 148 | |
876c9d3a MT |
149 | /** |
150 | * @brief sets the configuration values | |
151 | * @param ifnum interface number | |
152 | * @param id pointer to usb_device_id | |
153 | * @return 0 on success, error code on failure | |
154 | */ | |
155 | static int if_usb_probe(struct usb_interface *intf, | |
156 | const struct usb_device_id *id) | |
157 | { | |
158 | struct usb_device *udev; | |
159 | struct usb_host_interface *iface_desc; | |
160 | struct usb_endpoint_descriptor *endpoint; | |
69f9032d | 161 | struct lbs_private *priv; |
eae86bf3 | 162 | struct if_usb_card *cardp; |
876c9d3a MT |
163 | int i; |
164 | ||
165 | udev = interface_to_usbdev(intf); | |
166 | ||
eae86bf3 | 167 | cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); |
435a1acb | 168 | if (!cardp) { |
876c9d3a MT |
169 | lbs_pr_err("Out of memory allocating private data.\n"); |
170 | goto error; | |
171 | } | |
172 | ||
4f82f5c8 DW |
173 | setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); |
174 | init_waitqueue_head(&cardp->fw_wq); | |
7e226272 | 175 | |
435a1acb | 176 | cardp->udev = udev; |
876c9d3a MT |
177 | iface_desc = intf->cur_altsetting; |
178 | ||
9012b28a | 179 | lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" |
eae86bf3 | 180 | " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X\n", |
981f187b DW |
181 | le16_to_cpu(udev->descriptor.bcdUSB), |
182 | udev->descriptor.bDeviceClass, | |
183 | udev->descriptor.bDeviceSubClass, | |
184 | udev->descriptor.bDeviceProtocol); | |
876c9d3a MT |
185 | |
186 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | |
187 | endpoint = &iface_desc->endpoint[i].desc; | |
eae86bf3 DW |
188 | if (usb_endpoint_is_bulk_in(endpoint)) { |
189 | cardp->ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize); | |
190 | cardp->ep_in = usb_endpoint_num(endpoint); | |
876c9d3a | 191 | |
eae86bf3 DW |
192 | lbs_deb_usbd(&udev->dev, "in_endpoint = %d\n", cardp->ep_in); |
193 | lbs_deb_usbd(&udev->dev, "Bulk in size is %d\n", cardp->ep_in_size); | |
876c9d3a | 194 | |
eae86bf3 DW |
195 | } else if (usb_endpoint_is_bulk_out(endpoint)) { |
196 | cardp->ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize); | |
197 | cardp->ep_out = usb_endpoint_num(endpoint); | |
198 | ||
199 | lbs_deb_usbd(&udev->dev, "out_endpoint = %d\n", cardp->ep_out); | |
200 | lbs_deb_usbd(&udev->dev, "Bulk out size is %d\n", cardp->ep_out_size); | |
876c9d3a MT |
201 | } |
202 | } | |
eae86bf3 DW |
203 | if (!cardp->ep_out_size || !cardp->ep_in_size) { |
204 | lbs_deb_usbd(&udev->dev, "Endpoints not found\n"); | |
205 | goto dealloc; | |
206 | } | |
207 | if (!(cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL))) { | |
208 | lbs_deb_usbd(&udev->dev, "Rx URB allocation failed\n"); | |
209 | goto dealloc; | |
210 | } | |
211 | if (!(cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL))) { | |
212 | lbs_deb_usbd(&udev->dev, "Tx URB allocation failed\n"); | |
213 | goto dealloc; | |
214 | } | |
215 | cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, GFP_KERNEL); | |
216 | if (!cardp->ep_out_buf) { | |
217 | lbs_deb_usbd(&udev->dev, "Could not allocate buffer\n"); | |
218 | goto dealloc; | |
219 | } | |
876c9d3a | 220 | |
954ee164 | 221 | /* Upload firmware */ |
954ee164 | 222 | if (if_usb_prog_firmware(cardp)) { |
23d36eec | 223 | lbs_deb_usbd(&udev->dev, "FW upload failed\n"); |
954ee164 DW |
224 | goto err_prog_firmware; |
225 | } | |
226 | ||
10078321 | 227 | if (!(priv = lbs_add_card(cardp, &udev->dev))) |
954ee164 | 228 | goto err_prog_firmware; |
3874d0fe | 229 | |
954ee164 | 230 | cardp->priv = priv; |
c9cd6f9d | 231 | cardp->priv->fw_ready = 1; |
965f8bbc | 232 | |
208fdd2f | 233 | priv->hw_host_to_card = if_usb_host_to_card; |
4365929d | 234 | cardp->boot2_version = udev->descriptor.bcdDevice; |
208fdd2f | 235 | |
954ee164 | 236 | if_usb_submit_rx_urb(cardp); |
954ee164 | 237 | |
10078321 | 238 | if (lbs_start_card(priv)) |
954ee164 | 239 | goto err_start_card; |
32a74b7c | 240 | |
4694961c | 241 | if_usb_setup_firmware(priv); |
d1f7a5b8 | 242 | |
876c9d3a | 243 | usb_get_dev(udev); |
435a1acb | 244 | usb_set_intfdata(intf, cardp); |
876c9d3a | 245 | |
876c9d3a MT |
246 | return 0; |
247 | ||
954ee164 | 248 | err_start_card: |
10078321 | 249 | lbs_remove_card(priv); |
954ee164 DW |
250 | err_prog_firmware: |
251 | if_usb_reset_device(cardp); | |
876c9d3a | 252 | dealloc: |
435a1acb | 253 | if_usb_free(cardp); |
876c9d3a MT |
254 | |
255 | error: | |
256 | return -ENOMEM; | |
257 | } | |
258 | ||
259 | /** | |
260 | * @brief free resource and cleanup | |
435a1acb | 261 | * @param intf USB interface structure |
876c9d3a MT |
262 | * @return N/A |
263 | */ | |
264 | static void if_usb_disconnect(struct usb_interface *intf) | |
265 | { | |
eae86bf3 | 266 | struct if_usb_card *cardp = usb_get_intfdata(intf); |
69f9032d | 267 | struct lbs_private *priv = (struct lbs_private *) cardp->priv; |
876c9d3a | 268 | |
954ee164 | 269 | lbs_deb_enter(LBS_DEB_MAIN); |
876c9d3a | 270 | |
954ee164 | 271 | cardp->surprise_removed = 1; |
876c9d3a | 272 | |
954ee164 | 273 | if (priv) { |
aa21c004 | 274 | priv->surpriseremoved = 1; |
10078321 | 275 | lbs_stop_card(priv); |
10078321 | 276 | lbs_remove_card(priv); |
954ee164 | 277 | } |
876c9d3a MT |
278 | |
279 | /* Unlink and free urb */ | |
280 | if_usb_free(cardp); | |
281 | ||
282 | usb_set_intfdata(intf, NULL); | |
283 | usb_put_dev(interface_to_usbdev(intf)); | |
284 | ||
954ee164 | 285 | lbs_deb_leave(LBS_DEB_MAIN); |
876c9d3a MT |
286 | } |
287 | ||
288 | /** | |
289 | * @brief This function download FW | |
69f9032d | 290 | * @param priv pointer to struct lbs_private |
876c9d3a MT |
291 | * @return 0 |
292 | */ | |
eae86bf3 | 293 | static int if_usb_send_fw_pkt(struct if_usb_card *cardp) |
876c9d3a | 294 | { |
eae86bf3 | 295 | struct fwdata *fwdata = cardp->ep_out_buf; |
6dfff895 | 296 | const uint8_t *firmware = cardp->fw->data; |
876c9d3a | 297 | |
eae86bf3 DW |
298 | /* If we got a CRC failure on the last block, back |
299 | up and retry it */ | |
876c9d3a MT |
300 | if (!cardp->CRC_OK) { |
301 | cardp->totalbytes = cardp->fwlastblksent; | |
eae86bf3 | 302 | cardp->fwseqnum--; |
876c9d3a MT |
303 | } |
304 | ||
eae86bf3 DW |
305 | lbs_deb_usb2(&cardp->udev->dev, "totalbytes = %d\n", |
306 | cardp->totalbytes); | |
876c9d3a | 307 | |
eae86bf3 DW |
308 | /* struct fwdata (which we sent to the card) has an |
309 | extra __le32 field in between the header and the data, | |
310 | which is not in the struct fwheader in the actual | |
311 | firmware binary. Insert the seqnum in the middle... */ | |
312 | memcpy(&fwdata->hdr, &firmware[cardp->totalbytes], | |
876c9d3a MT |
313 | sizeof(struct fwheader)); |
314 | ||
315 | cardp->fwlastblksent = cardp->totalbytes; | |
316 | cardp->totalbytes += sizeof(struct fwheader); | |
317 | ||
876c9d3a | 318 | memcpy(fwdata->data, &firmware[cardp->totalbytes], |
eae86bf3 | 319 | le32_to_cpu(fwdata->hdr.datalength)); |
876c9d3a | 320 | |
eae86bf3 DW |
321 | lbs_deb_usb2(&cardp->udev->dev, "Data length = %d\n", |
322 | le32_to_cpu(fwdata->hdr.datalength)); | |
876c9d3a | 323 | |
eae86bf3 DW |
324 | fwdata->seqnum = cpu_to_le32(++cardp->fwseqnum); |
325 | cardp->totalbytes += le32_to_cpu(fwdata->hdr.datalength); | |
876c9d3a | 326 | |
eae86bf3 DW |
327 | usb_tx_block(cardp, cardp->ep_out_buf, sizeof(struct fwdata) + |
328 | le32_to_cpu(fwdata->hdr.datalength)); | |
329 | ||
330 | if (fwdata->hdr.dnldcmd == cpu_to_le32(FW_HAS_DATA_TO_RECV)) { | |
331 | lbs_deb_usb2(&cardp->udev->dev, "There are data to follow\n"); | |
332 | lbs_deb_usb2(&cardp->udev->dev, "seqnum = %d totalbytes = %d\n", | |
333 | cardp->fwseqnum, cardp->totalbytes); | |
334 | } else if (fwdata->hdr.dnldcmd == cpu_to_le32(FW_HAS_LAST_BLOCK)) { | |
335 | lbs_deb_usb2(&cardp->udev->dev, "Host has finished FW downloading\n"); | |
336 | lbs_deb_usb2(&cardp->udev->dev, "Donwloading FW JUMP BLOCK\n"); | |
876c9d3a | 337 | |
876c9d3a MT |
338 | cardp->fwfinalblk = 1; |
339 | } | |
340 | ||
eae86bf3 DW |
341 | lbs_deb_usb2(&cardp->udev->dev, "Firmware download done; size %d\n", |
342 | cardp->totalbytes); | |
876c9d3a MT |
343 | |
344 | return 0; | |
345 | } | |
346 | ||
eae86bf3 | 347 | static int if_usb_reset_device(struct if_usb_card *cardp) |
876c9d3a | 348 | { |
eae86bf3 | 349 | struct cmd_ds_command *cmd = cardp->ep_out_buf + 4; |
876c9d3a | 350 | int ret; |
876c9d3a | 351 | |
3874d0fe HS |
352 | lbs_deb_enter(LBS_DEB_USB); |
353 | ||
eae86bf3 | 354 | *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); |
6d35fdfc DW |
355 | |
356 | cmd->command = cpu_to_le16(CMD_802_11_RESET); | |
357 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN); | |
358 | cmd->result = cpu_to_le16(0); | |
359 | cmd->seqnum = cpu_to_le16(0x5a5a); | |
360 | cmd->params.reset.action = cpu_to_le16(CMD_ACT_HALT); | |
eae86bf3 | 361 | usb_tx_block(cardp, cardp->ep_out_buf, 4 + S_DS_GEN + sizeof(struct cmd_ds_802_11_reset)); |
6d35fdfc | 362 | |
c8ba39d0 | 363 | msleep(100); |
876c9d3a | 364 | ret = usb_reset_device(cardp->udev); |
c8ba39d0 | 365 | msleep(100); |
3874d0fe HS |
366 | |
367 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); | |
368 | ||
876c9d3a MT |
369 | return ret; |
370 | } | |
371 | ||
372 | /** | |
373 | * @brief This function transfer the data to the device. | |
69f9032d | 374 | * @param priv pointer to struct lbs_private |
876c9d3a MT |
375 | * @param payload pointer to payload data |
376 | * @param nb data length | |
377 | * @return 0 or -1 | |
378 | */ | |
eae86bf3 | 379 | static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload, uint16_t nb) |
876c9d3a | 380 | { |
876c9d3a MT |
381 | int ret = -1; |
382 | ||
383 | /* check if device is removed */ | |
954ee164 | 384 | if (cardp->surprise_removed) { |
9012b28a | 385 | lbs_deb_usbd(&cardp->udev->dev, "Device removed\n"); |
876c9d3a MT |
386 | goto tx_ret; |
387 | } | |
388 | ||
389 | usb_fill_bulk_urb(cardp->tx_urb, cardp->udev, | |
390 | usb_sndbulkpipe(cardp->udev, | |
eae86bf3 | 391 | cardp->ep_out), |
954ee164 | 392 | payload, nb, if_usb_write_bulk_callback, cardp); |
876c9d3a MT |
393 | |
394 | cardp->tx_urb->transfer_flags |= URB_ZERO_PACKET; | |
395 | ||
396 | if ((ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC))) { | |
0856e681 | 397 | lbs_deb_usbd(&cardp->udev->dev, "usb_submit_urb failed: %d\n", ret); |
876c9d3a MT |
398 | ret = -1; |
399 | } else { | |
eae86bf3 | 400 | lbs_deb_usb2(&cardp->udev->dev, "usb_submit_urb success\n"); |
876c9d3a MT |
401 | ret = 0; |
402 | } | |
403 | ||
404 | tx_ret: | |
405 | return ret; | |
406 | } | |
407 | ||
eae86bf3 | 408 | static int __if_usb_submit_rx_urb(struct if_usb_card *cardp, |
954ee164 | 409 | void (*callbackfn)(struct urb *urb)) |
876c9d3a | 410 | { |
876c9d3a | 411 | struct sk_buff *skb; |
876c9d3a MT |
412 | int ret = -1; |
413 | ||
414 | if (!(skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE))) { | |
415 | lbs_pr_err("No free skb\n"); | |
416 | goto rx_ret; | |
417 | } | |
418 | ||
eae86bf3 | 419 | cardp->rx_skb = skb; |
876c9d3a MT |
420 | |
421 | /* Fill the receive configuration URB and initialise the Rx call back */ | |
422 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, | |
eae86bf3 | 423 | usb_rcvbulkpipe(cardp->udev, cardp->ep_in), |
4269e2ad | 424 | (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET), |
876c9d3a | 425 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, |
eae86bf3 | 426 | cardp); |
876c9d3a MT |
427 | |
428 | cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; | |
429 | ||
eae86bf3 | 430 | lbs_deb_usb2(&cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb); |
876c9d3a | 431 | if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) { |
0856e681 | 432 | lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB failed: %d\n", ret); |
77d8cf2c | 433 | kfree_skb(skb); |
eae86bf3 | 434 | cardp->rx_skb = NULL; |
876c9d3a MT |
435 | ret = -1; |
436 | } else { | |
eae86bf3 | 437 | lbs_deb_usb2(&cardp->udev->dev, "Submit Rx URB success\n"); |
876c9d3a MT |
438 | ret = 0; |
439 | } | |
440 | ||
441 | rx_ret: | |
442 | return ret; | |
443 | } | |
444 | ||
eae86bf3 | 445 | static int if_usb_submit_rx_urb_fwload(struct if_usb_card *cardp) |
876c9d3a | 446 | { |
954ee164 | 447 | return __if_usb_submit_rx_urb(cardp, &if_usb_receive_fwload); |
876c9d3a MT |
448 | } |
449 | ||
eae86bf3 | 450 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp) |
876c9d3a | 451 | { |
954ee164 | 452 | return __if_usb_submit_rx_urb(cardp, &if_usb_receive); |
876c9d3a MT |
453 | } |
454 | ||
455 | static void if_usb_receive_fwload(struct urb *urb) | |
456 | { | |
eae86bf3 DW |
457 | struct if_usb_card *cardp = urb->context; |
458 | struct sk_buff *skb = cardp->rx_skb; | |
876c9d3a | 459 | struct fwsyncheader *syncfwheader; |
eae86bf3 | 460 | struct bootcmdresp bootcmdresp; |
876c9d3a MT |
461 | |
462 | if (urb->status) { | |
9012b28a | 463 | lbs_deb_usbd(&cardp->udev->dev, |
eae86bf3 | 464 | "URB status is failed during fw load\n"); |
876c9d3a MT |
465 | kfree_skb(skb); |
466 | return; | |
467 | } | |
468 | ||
c9cd6f9d DW |
469 | if (cardp->fwdnldover) { |
470 | __le32 *tmp = (__le32 *)(skb->data + IPFIELD_ALIGN_OFFSET); | |
471 | ||
472 | if (tmp[0] == cpu_to_le32(CMD_TYPE_INDICATION) && | |
473 | tmp[1] == cpu_to_le32(MACREG_INT_CODE_FIRMWARE_READY)) { | |
474 | lbs_pr_info("Firmware ready event received\n"); | |
475 | wake_up(&cardp->fw_wq); | |
476 | } else { | |
eae86bf3 DW |
477 | lbs_deb_usb("Waiting for confirmation; got %x %x\n", |
478 | le32_to_cpu(tmp[0]), le32_to_cpu(tmp[1])); | |
c9cd6f9d DW |
479 | if_usb_submit_rx_urb_fwload(cardp); |
480 | } | |
481 | kfree_skb(skb); | |
482 | return; | |
483 | } | |
c8ba39d0 | 484 | if (cardp->bootcmdresp <= 0) { |
876c9d3a MT |
485 | memcpy (&bootcmdresp, skb->data + IPFIELD_ALIGN_OFFSET, |
486 | sizeof(bootcmdresp)); | |
eae86bf3 | 487 | |
981f187b | 488 | if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) { |
876c9d3a | 489 | kfree_skb(skb); |
954ee164 | 490 | if_usb_submit_rx_urb_fwload(cardp); |
876c9d3a | 491 | cardp->bootcmdresp = 1; |
9012b28a | 492 | lbs_deb_usbd(&cardp->udev->dev, |
eae86bf3 | 493 | "Received valid boot command response\n"); |
876c9d3a MT |
494 | return; |
495 | } | |
eae86bf3 DW |
496 | if (bootcmdresp.magic != cpu_to_le32(BOOT_CMD_MAGIC_NUMBER)) { |
497 | if (bootcmdresp.magic == cpu_to_le32(CMD_TYPE_REQUEST) || | |
498 | bootcmdresp.magic == cpu_to_le32(CMD_TYPE_DATA) || | |
499 | bootcmdresp.magic == cpu_to_le32(CMD_TYPE_INDICATION)) { | |
c9cd6f9d DW |
500 | if (!cardp->bootcmdresp) |
501 | lbs_pr_info("Firmware already seems alive; resetting\n"); | |
6d35fdfc DW |
502 | cardp->bootcmdresp = -1; |
503 | } else { | |
504 | lbs_pr_info("boot cmd response wrong magic number (0x%x)\n", | |
eae86bf3 | 505 | le32_to_cpu(bootcmdresp.magic)); |
6d35fdfc | 506 | } |
eae86bf3 DW |
507 | } else if (bootcmdresp.cmd != BOOT_CMD_FW_BY_USB) { |
508 | lbs_pr_info("boot cmd response cmd_tag error (%d)\n", | |
509 | bootcmdresp.cmd); | |
510 | } else if (bootcmdresp.result != BOOT_CMD_RESP_OK) { | |
511 | lbs_pr_info("boot cmd response result error (%d)\n", | |
512 | bootcmdresp.result); | |
876c9d3a MT |
513 | } else { |
514 | cardp->bootcmdresp = 1; | |
9012b28a | 515 | lbs_deb_usbd(&cardp->udev->dev, |
eae86bf3 | 516 | "Received valid boot command response\n"); |
876c9d3a MT |
517 | } |
518 | kfree_skb(skb); | |
954ee164 | 519 | if_usb_submit_rx_urb_fwload(cardp); |
876c9d3a MT |
520 | return; |
521 | } | |
522 | ||
523 | syncfwheader = kmalloc(sizeof(struct fwsyncheader), GFP_ATOMIC); | |
524 | if (!syncfwheader) { | |
9012b28a | 525 | lbs_deb_usbd(&cardp->udev->dev, "Failure to allocate syncfwheader\n"); |
876c9d3a MT |
526 | kfree_skb(skb); |
527 | return; | |
528 | } | |
529 | ||
530 | memcpy(syncfwheader, skb->data + IPFIELD_ALIGN_OFFSET, | |
eae86bf3 | 531 | sizeof(struct fwsyncheader)); |
876c9d3a MT |
532 | |
533 | if (!syncfwheader->cmd) { | |
eae86bf3 DW |
534 | lbs_deb_usb2(&cardp->udev->dev, "FW received Blk with correct CRC\n"); |
535 | lbs_deb_usb2(&cardp->udev->dev, "FW received Blk seqnum = %d\n", | |
536 | le32_to_cpu(syncfwheader->seqnum)); | |
876c9d3a MT |
537 | cardp->CRC_OK = 1; |
538 | } else { | |
eae86bf3 | 539 | lbs_deb_usbd(&cardp->udev->dev, "FW received Blk with CRC error\n"); |
876c9d3a MT |
540 | cardp->CRC_OK = 0; |
541 | } | |
542 | ||
543 | kfree_skb(skb); | |
544 | ||
4f82f5c8 DW |
545 | /* reschedule timer for 200ms hence */ |
546 | mod_timer(&cardp->fw_timeout, jiffies + (HZ/5)); | |
547 | ||
876c9d3a MT |
548 | if (cardp->fwfinalblk) { |
549 | cardp->fwdnldover = 1; | |
550 | goto exit; | |
551 | } | |
552 | ||
4f82f5c8 | 553 | if_usb_send_fw_pkt(cardp); |
876c9d3a | 554 | |
4f82f5c8 | 555 | exit: |
c9cd6f9d DW |
556 | if_usb_submit_rx_urb_fwload(cardp); |
557 | ||
876c9d3a MT |
558 | kfree(syncfwheader); |
559 | ||
560 | return; | |
876c9d3a MT |
561 | } |
562 | ||
563 | #define MRVDRV_MIN_PKT_LEN 30 | |
564 | ||
565 | static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb, | |
eae86bf3 | 566 | struct if_usb_card *cardp, |
69f9032d | 567 | struct lbs_private *priv) |
876c9d3a | 568 | { |
eae86bf3 DW |
569 | if (recvlength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + MESSAGE_HEADER_LEN |
570 | || recvlength < MRVDRV_MIN_PKT_LEN) { | |
571 | lbs_deb_usbd(&cardp->udev->dev, "Packet length is Invalid\n"); | |
876c9d3a MT |
572 | kfree_skb(skb); |
573 | return; | |
574 | } | |
575 | ||
576 | skb_reserve(skb, IPFIELD_ALIGN_OFFSET); | |
577 | skb_put(skb, recvlength); | |
578 | skb_pull(skb, MESSAGE_HEADER_LEN); | |
eae86bf3 | 579 | |
10078321 | 580 | lbs_process_rxed_packet(priv, skb); |
876c9d3a MT |
581 | } |
582 | ||
eae86bf3 | 583 | static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff, |
876c9d3a | 584 | struct sk_buff *skb, |
eae86bf3 | 585 | struct if_usb_card *cardp, |
69f9032d | 586 | struct lbs_private *priv) |
876c9d3a | 587 | { |
7919b89c HS |
588 | u8 i; |
589 | ||
ddac4526 | 590 | if (recvlength > LBS_CMD_BUFFER_SIZE) { |
9012b28a | 591 | lbs_deb_usbd(&cardp->udev->dev, |
eae86bf3 | 592 | "The receive buffer is too large\n"); |
876c9d3a MT |
593 | kfree_skb(skb); |
594 | return; | |
595 | } | |
596 | ||
597 | if (!in_interrupt()) | |
598 | BUG(); | |
599 | ||
aa21c004 | 600 | spin_lock(&priv->driver_lock); |
876c9d3a | 601 | |
7919b89c HS |
602 | i = (priv->resp_idx == 0) ? 1 : 0; |
603 | BUG_ON(priv->resp_len[i]); | |
604 | priv->resp_len[i] = (recvlength - MESSAGE_HEADER_LEN); | |
605 | memcpy(priv->resp_buf[i], recvbuff + MESSAGE_HEADER_LEN, | |
606 | priv->resp_len[i]); | |
876c9d3a | 607 | kfree_skb(skb); |
7919b89c HS |
608 | lbs_notify_command_response(priv, i); |
609 | ||
aa21c004 | 610 | spin_unlock(&priv->driver_lock); |
876c9d3a | 611 | |
9012b28a | 612 | lbs_deb_usbd(&cardp->udev->dev, |
876c9d3a | 613 | "Wake up main thread to handle cmd response\n"); |
876c9d3a MT |
614 | } |
615 | ||
616 | /** | |
617 | * @brief This function reads of the packet into the upload buff, | |
618 | * wake up the main thread and initialise the Rx callack. | |
619 | * | |
620 | * @param urb pointer to struct urb | |
621 | * @return N/A | |
622 | */ | |
623 | static void if_usb_receive(struct urb *urb) | |
624 | { | |
eae86bf3 DW |
625 | struct if_usb_card *cardp = urb->context; |
626 | struct sk_buff *skb = cardp->rx_skb; | |
69f9032d | 627 | struct lbs_private *priv = cardp->priv; |
876c9d3a | 628 | int recvlength = urb->actual_length; |
eae86bf3 DW |
629 | uint8_t *recvbuff = NULL; |
630 | uint32_t recvtype = 0; | |
631 | __le32 *pkt = (__le32 *)(skb->data + IPFIELD_ALIGN_OFFSET); | |
7919b89c | 632 | uint32_t event; |
876c9d3a | 633 | |
9012b28a | 634 | lbs_deb_enter(LBS_DEB_USB); |
876c9d3a MT |
635 | |
636 | if (recvlength) { | |
637 | if (urb->status) { | |
eae86bf3 DW |
638 | lbs_deb_usbd(&cardp->udev->dev, "RX URB failed: %d\n", |
639 | urb->status); | |
876c9d3a MT |
640 | kfree_skb(skb); |
641 | goto setup_for_next; | |
642 | } | |
643 | ||
644 | recvbuff = skb->data + IPFIELD_ALIGN_OFFSET; | |
eae86bf3 | 645 | recvtype = le32_to_cpu(pkt[0]); |
9012b28a | 646 | lbs_deb_usbd(&cardp->udev->dev, |
8362cd41 DW |
647 | "Recv length = 0x%x, Recv type = 0x%X\n", |
648 | recvlength, recvtype); | |
77d8cf2c DW |
649 | } else if (urb->status) { |
650 | kfree_skb(skb); | |
876c9d3a | 651 | goto rx_exit; |
77d8cf2c | 652 | } |
876c9d3a | 653 | |
876c9d3a MT |
654 | switch (recvtype) { |
655 | case CMD_TYPE_DATA: | |
656 | process_cmdtypedata(recvlength, skb, cardp, priv); | |
657 | break; | |
658 | ||
659 | case CMD_TYPE_REQUEST: | |
660 | process_cmdrequest(recvlength, recvbuff, skb, cardp, priv); | |
661 | break; | |
662 | ||
663 | case CMD_TYPE_INDICATION: | |
7919b89c HS |
664 | /* Event handling */ |
665 | event = le32_to_cpu(pkt[1]); | |
666 | lbs_deb_usbd(&cardp->udev->dev, "**EVENT** 0x%X\n", event); | |
667 | kfree_skb(skb); | |
eae86bf3 | 668 | |
7919b89c HS |
669 | /* Icky undocumented magic special case */ |
670 | if (event & 0xffff0000) { | |
671 | u32 trycount = (event & 0xffff0000) >> 16; | |
eae86bf3 | 672 | |
7919b89c HS |
673 | lbs_send_tx_feedback(priv, trycount); |
674 | } else | |
675 | lbs_queue_event(priv, event & 0xFF); | |
676 | break; | |
eae86bf3 | 677 | |
876c9d3a | 678 | default: |
8362cd41 | 679 | lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n", |
eae86bf3 | 680 | recvtype); |
876c9d3a MT |
681 | kfree_skb(skb); |
682 | break; | |
683 | } | |
684 | ||
685 | setup_for_next: | |
954ee164 | 686 | if_usb_submit_rx_urb(cardp); |
876c9d3a | 687 | rx_exit: |
9012b28a | 688 | lbs_deb_leave(LBS_DEB_USB); |
876c9d3a MT |
689 | } |
690 | ||
691 | /** | |
692 | * @brief This function downloads data to FW | |
69f9032d | 693 | * @param priv pointer to struct lbs_private structure |
876c9d3a MT |
694 | * @param type type of data |
695 | * @param buf pointer to data buffer | |
696 | * @param len number of bytes | |
697 | * @return 0 or -1 | |
698 | */ | |
eae86bf3 DW |
699 | static int if_usb_host_to_card(struct lbs_private *priv, uint8_t type, |
700 | uint8_t *payload, uint16_t nb) | |
876c9d3a | 701 | { |
eae86bf3 | 702 | struct if_usb_card *cardp = priv->card; |
876c9d3a | 703 | |
9012b28a HS |
704 | lbs_deb_usbd(&cardp->udev->dev,"*** type = %u\n", type); |
705 | lbs_deb_usbd(&cardp->udev->dev,"size after = %d\n", nb); | |
876c9d3a MT |
706 | |
707 | if (type == MVMS_CMD) { | |
eae86bf3 | 708 | *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); |
634b8f49 | 709 | priv->dnld_sent = DNLD_CMD_SENT; |
876c9d3a | 710 | } else { |
eae86bf3 | 711 | *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_DATA); |
634b8f49 | 712 | priv->dnld_sent = DNLD_DATA_SENT; |
876c9d3a MT |
713 | } |
714 | ||
eae86bf3 | 715 | memcpy((cardp->ep_out_buf + MESSAGE_HEADER_LEN), payload, nb); |
876c9d3a | 716 | |
eae86bf3 | 717 | return usb_tx_block(cardp, cardp->ep_out_buf, nb + MESSAGE_HEADER_LEN); |
876c9d3a MT |
718 | } |
719 | ||
9e22cb67 DW |
720 | /** |
721 | * @brief This function issues Boot command to the Boot2 code | |
722 | * @param ivalue 1:Boot from FW by USB-Download | |
723 | * 2:Boot from FW in EEPROM | |
724 | * @return 0 | |
725 | */ | |
eae86bf3 | 726 | static int if_usb_issue_boot_command(struct if_usb_card *cardp, int ivalue) |
9e22cb67 | 727 | { |
eae86bf3 | 728 | struct bootcmd *bootcmd = cardp->ep_out_buf; |
9e22cb67 DW |
729 | |
730 | /* Prepare command */ | |
eae86bf3 DW |
731 | bootcmd->magic = cpu_to_le32(BOOT_CMD_MAGIC_NUMBER); |
732 | bootcmd->cmd = ivalue; | |
733 | memset(bootcmd->pad, 0, sizeof(bootcmd->pad)); | |
9e22cb67 DW |
734 | |
735 | /* Issue command */ | |
eae86bf3 | 736 | usb_tx_block(cardp, cardp->ep_out_buf, sizeof(*bootcmd)); |
9e22cb67 DW |
737 | |
738 | return 0; | |
739 | } | |
876c9d3a MT |
740 | |
741 | ||
954ee164 DW |
742 | /** |
743 | * @brief This function checks the validity of Boot2/FW image. | |
744 | * | |
745 | * @param data pointer to image | |
746 | * len image length | |
747 | * @return 0 or -1 | |
748 | */ | |
6dfff895 | 749 | static int check_fwfile_format(const uint8_t *data, uint32_t totlen) |
954ee164 | 750 | { |
eae86bf3 DW |
751 | uint32_t bincmd, exit; |
752 | uint32_t blksize, offset, len; | |
954ee164 DW |
753 | int ret; |
754 | ||
755 | ret = 1; | |
756 | exit = len = 0; | |
757 | ||
758 | do { | |
759 | struct fwheader *fwh = (void *)data; | |
760 | ||
761 | bincmd = le32_to_cpu(fwh->dnldcmd); | |
762 | blksize = le32_to_cpu(fwh->datalength); | |
763 | switch (bincmd) { | |
764 | case FW_HAS_DATA_TO_RECV: | |
765 | offset = sizeof(struct fwheader) + blksize; | |
766 | data += offset; | |
767 | len += offset; | |
768 | if (len >= totlen) | |
769 | exit = 1; | |
770 | break; | |
771 | case FW_HAS_LAST_BLOCK: | |
772 | exit = 1; | |
773 | ret = 0; | |
774 | break; | |
775 | default: | |
776 | exit = 1; | |
777 | break; | |
778 | } | |
779 | } while (!exit); | |
780 | ||
781 | if (ret) | |
782 | lbs_pr_err("firmware file format check FAIL\n"); | |
783 | else | |
784 | lbs_deb_fw("firmware file format check PASS\n"); | |
785 | ||
786 | return ret; | |
787 | } | |
788 | ||
789 | ||
eae86bf3 | 790 | static int if_usb_prog_firmware(struct if_usb_card *cardp) |
876c9d3a | 791 | { |
876c9d3a MT |
792 | int i = 0; |
793 | static int reset_count = 10; | |
9012b28a | 794 | int ret = 0; |
876c9d3a | 795 | |
9012b28a | 796 | lbs_deb_enter(LBS_DEB_USB); |
876c9d3a | 797 | |
10078321 | 798 | if ((ret = request_firmware(&cardp->fw, lbs_fw_name, |
954ee164 DW |
799 | &cardp->udev->dev)) < 0) { |
800 | lbs_pr_err("request_firmware() failed with %#x\n", ret); | |
10078321 | 801 | lbs_pr_err("firmware %s not found\n", lbs_fw_name); |
954ee164 DW |
802 | goto done; |
803 | } | |
804 | ||
805 | if (check_fwfile_format(cardp->fw->data, cardp->fw->size)) | |
806 | goto release_fw; | |
876c9d3a MT |
807 | |
808 | restart: | |
954ee164 | 809 | if (if_usb_submit_rx_urb_fwload(cardp) < 0) { |
9012b28a HS |
810 | lbs_deb_usbd(&cardp->udev->dev, "URB submission is failed\n"); |
811 | ret = -1; | |
954ee164 | 812 | goto release_fw; |
876c9d3a MT |
813 | } |
814 | ||
876c9d3a MT |
815 | cardp->bootcmdresp = 0; |
816 | do { | |
817 | int j = 0; | |
818 | i++; | |
819 | /* Issue Boot command = 1, Boot from Download-FW */ | |
954ee164 | 820 | if_usb_issue_boot_command(cardp, BOOT_CMD_FW_BY_USB); |
876c9d3a MT |
821 | /* wait for command response */ |
822 | do { | |
823 | j++; | |
824 | msleep_interruptible(100); | |
825 | } while (cardp->bootcmdresp == 0 && j < 10); | |
826 | } while (cardp->bootcmdresp == 0 && i < 5); | |
827 | ||
6d35fdfc | 828 | if (cardp->bootcmdresp <= 0) { |
876c9d3a | 829 | if (--reset_count >= 0) { |
954ee164 | 830 | if_usb_reset_device(cardp); |
876c9d3a MT |
831 | goto restart; |
832 | } | |
833 | return -1; | |
834 | } | |
876c9d3a MT |
835 | |
836 | i = 0; | |
876c9d3a MT |
837 | |
838 | cardp->totalbytes = 0; | |
839 | cardp->fwlastblksent = 0; | |
840 | cardp->CRC_OK = 1; | |
841 | cardp->fwdnldover = 0; | |
842 | cardp->fwseqnum = -1; | |
843 | cardp->totalbytes = 0; | |
844 | cardp->fwfinalblk = 0; | |
845 | ||
4f82f5c8 DW |
846 | /* Send the first firmware packet... */ |
847 | if_usb_send_fw_pkt(cardp); | |
876c9d3a | 848 | |
4f82f5c8 DW |
849 | /* ... and wait for the process to complete */ |
850 | wait_event_interruptible(cardp->fw_wq, cardp->surprise_removed || cardp->fwdnldover); | |
7e226272 | 851 | |
4f82f5c8 | 852 | del_timer_sync(&cardp->fw_timeout); |
c9cd6f9d | 853 | usb_kill_urb(cardp->rx_urb); |
876c9d3a MT |
854 | |
855 | if (!cardp->fwdnldover) { | |
856 | lbs_pr_info("failed to load fw, resetting device!\n"); | |
857 | if (--reset_count >= 0) { | |
954ee164 | 858 | if_usb_reset_device(cardp); |
876c9d3a MT |
859 | goto restart; |
860 | } | |
861 | ||
862 | lbs_pr_info("FW download failure, time = %d ms\n", i * 100); | |
9012b28a | 863 | ret = -1; |
954ee164 | 864 | goto release_fw; |
876c9d3a MT |
865 | } |
866 | ||
eae86bf3 | 867 | release_fw: |
954ee164 DW |
868 | release_firmware(cardp->fw); |
869 | cardp->fw = NULL; | |
876c9d3a | 870 | |
eae86bf3 | 871 | done: |
9012b28a HS |
872 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); |
873 | return ret; | |
876c9d3a MT |
874 | } |
875 | ||
1df4e8fe | 876 | |
876c9d3a MT |
877 | #ifdef CONFIG_PM |
878 | static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) | |
879 | { | |
eae86bf3 | 880 | struct if_usb_card *cardp = usb_get_intfdata(intf); |
69f9032d | 881 | struct lbs_private *priv = cardp->priv; |
d1f7a5b8 | 882 | int ret; |
876c9d3a | 883 | |
9012b28a | 884 | lbs_deb_enter(LBS_DEB_USB); |
876c9d3a | 885 | |
aa21c004 | 886 | if (priv->psstate != PS_STATE_FULL_POWER) |
876c9d3a MT |
887 | return -1; |
888 | ||
d1f7a5b8 DW |
889 | ret = lbs_suspend(priv); |
890 | if (ret) | |
891 | goto out; | |
876c9d3a MT |
892 | |
893 | /* Unlink tx & rx urb */ | |
894 | usb_kill_urb(cardp->tx_urb); | |
895 | usb_kill_urb(cardp->rx_urb); | |
896 | ||
d1f7a5b8 | 897 | out: |
9012b28a | 898 | lbs_deb_leave(LBS_DEB_USB); |
d1f7a5b8 | 899 | return ret; |
876c9d3a MT |
900 | } |
901 | ||
902 | static int if_usb_resume(struct usb_interface *intf) | |
903 | { | |
eae86bf3 | 904 | struct if_usb_card *cardp = usb_get_intfdata(intf); |
69f9032d | 905 | struct lbs_private *priv = cardp->priv; |
876c9d3a | 906 | |
9012b28a | 907 | lbs_deb_enter(LBS_DEB_USB); |
876c9d3a | 908 | |
6bc822b5 | 909 | if_usb_submit_rx_urb(cardp); |
876c9d3a | 910 | |
d1f7a5b8 | 911 | lbs_resume(priv); |
876c9d3a | 912 | |
9012b28a | 913 | lbs_deb_leave(LBS_DEB_USB); |
876c9d3a MT |
914 | return 0; |
915 | } | |
916 | #else | |
917 | #define if_usb_suspend NULL | |
918 | #define if_usb_resume NULL | |
919 | #endif | |
920 | ||
921 | static struct usb_driver if_usb_driver = { | |
798fbfec | 922 | .name = DRV_NAME, |
876c9d3a | 923 | .probe = if_usb_probe, |
876c9d3a | 924 | .disconnect = if_usb_disconnect, |
876c9d3a MT |
925 | .id_table = if_usb_table, |
926 | .suspend = if_usb_suspend, | |
927 | .resume = if_usb_resume, | |
7b58ccfe | 928 | .reset_resume = if_usb_resume, |
876c9d3a MT |
929 | }; |
930 | ||
4fb910fd | 931 | static int __init if_usb_init_module(void) |
876c9d3a | 932 | { |
084708b6 | 933 | int ret = 0; |
876c9d3a | 934 | |
084708b6 HS |
935 | lbs_deb_enter(LBS_DEB_MAIN); |
936 | ||
084708b6 HS |
937 | ret = usb_register(&if_usb_driver); |
938 | ||
939 | lbs_deb_leave_args(LBS_DEB_MAIN, "ret %d", ret); | |
940 | return ret; | |
876c9d3a MT |
941 | } |
942 | ||
4fb910fd | 943 | static void __exit if_usb_exit_module(void) |
876c9d3a | 944 | { |
084708b6 HS |
945 | lbs_deb_enter(LBS_DEB_MAIN); |
946 | ||
876c9d3a | 947 | usb_deregister(&if_usb_driver); |
084708b6 HS |
948 | |
949 | lbs_deb_leave(LBS_DEB_MAIN); | |
876c9d3a | 950 | } |
084708b6 HS |
951 | |
952 | module_init(if_usb_init_module); | |
953 | module_exit(if_usb_exit_module); | |
954 | ||
955 | MODULE_DESCRIPTION("8388 USB WLAN Driver"); | |
eae86bf3 | 956 | MODULE_AUTHOR("Marvell International Ltd. and Red Hat, Inc."); |
084708b6 | 957 | MODULE_LICENSE("GPL"); |