Merge tag 'v3.16-rc1' into i2c/for-next
[linux-2.6-block.git] / drivers / net / wireless / ath / ath6kl / usb.c
CommitLineData
241b128b
KV
1/*
2 * Copyright (c) 2007-2011 Atheros Communications Inc.
1b2df407 3 * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
241b128b
KV
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <linux/module.h>
19#include <linux/usb.h>
20
21#include "debug.h"
22#include "core.h"
23
9cbee358
KV
24/* constants */
25#define TX_URB_COUNT 32
26#define RX_URB_COUNT 32
987cdcba 27#define ATH6KL_USB_RX_BUFFER_SIZE 4096
9cbee358
KV
28
29/* tx/rx pipes for usb */
30enum ATH6KL_USB_PIPE_ID {
31 ATH6KL_USB_PIPE_TX_CTRL = 0,
32 ATH6KL_USB_PIPE_TX_DATA_LP,
33 ATH6KL_USB_PIPE_TX_DATA_MP,
34 ATH6KL_USB_PIPE_TX_DATA_HP,
35 ATH6KL_USB_PIPE_RX_CTRL,
36 ATH6KL_USB_PIPE_RX_DATA,
37 ATH6KL_USB_PIPE_RX_DATA2,
38 ATH6KL_USB_PIPE_RX_INT,
39 ATH6KL_USB_PIPE_MAX
40};
41
42#define ATH6KL_USB_PIPE_INVALID ATH6KL_USB_PIPE_MAX
43
44struct ath6kl_usb_pipe {
45 struct list_head urb_list_head;
46 struct usb_anchor urb_submitted;
47 u32 urb_alloc;
48 u32 urb_cnt;
49 u32 urb_cnt_thresh;
50 unsigned int usb_pipe_handle;
51 u32 flags;
52 u8 ep_address;
53 u8 logical_pipe_num;
54 struct ath6kl_usb *ar_usb;
55 u16 max_packet_size;
56 struct work_struct io_complete_work;
57 struct sk_buff_head io_comp_queue;
58 struct usb_endpoint_descriptor *ep_desc;
59};
60
61#define ATH6KL_USB_PIPE_FLAG_TX (1 << 0)
62
241b128b
KV
63/* usb device object */
64struct ath6kl_usb {
9cbee358
KV
65 /* protects pipe->urb_list_head and pipe->urb_cnt */
66 spinlock_t cs_lock;
67
241b128b
KV
68 struct usb_device *udev;
69 struct usb_interface *interface;
9cbee358 70 struct ath6kl_usb_pipe pipes[ATH6KL_USB_PIPE_MAX];
241b128b
KV
71 u8 *diag_cmd_buffer;
72 u8 *diag_resp_buffer;
73 struct ath6kl *ar;
74};
75
9cbee358
KV
76/* usb urb object */
77struct ath6kl_urb_context {
78 struct list_head link;
79 struct ath6kl_usb_pipe *pipe;
80 struct sk_buff *skb;
81 struct ath6kl *ar;
82};
83
84/* USB endpoint definitions */
85#define ATH6KL_USB_EP_ADDR_APP_CTRL_IN 0x81
86#define ATH6KL_USB_EP_ADDR_APP_DATA_IN 0x82
87#define ATH6KL_USB_EP_ADDR_APP_DATA2_IN 0x83
88#define ATH6KL_USB_EP_ADDR_APP_INT_IN 0x84
89
90#define ATH6KL_USB_EP_ADDR_APP_CTRL_OUT 0x01
91#define ATH6KL_USB_EP_ADDR_APP_DATA_LP_OUT 0x02
92#define ATH6KL_USB_EP_ADDR_APP_DATA_MP_OUT 0x03
93#define ATH6KL_USB_EP_ADDR_APP_DATA_HP_OUT 0x04
94
241b128b
KV
95/* diagnostic command defnitions */
96#define ATH6KL_USB_CONTROL_REQ_SEND_BMI_CMD 1
97#define ATH6KL_USB_CONTROL_REQ_RECV_BMI_RESP 2
98#define ATH6KL_USB_CONTROL_REQ_DIAG_CMD 3
99#define ATH6KL_USB_CONTROL_REQ_DIAG_RESP 4
100
101#define ATH6KL_USB_CTRL_DIAG_CC_READ 0
102#define ATH6KL_USB_CTRL_DIAG_CC_WRITE 1
103
104struct ath6kl_usb_ctrl_diag_cmd_write {
105 __le32 cmd;
106 __le32 address;
107 __le32 value;
108 __le32 _pad[1];
109} __packed;
110
111struct ath6kl_usb_ctrl_diag_cmd_read {
112 __le32 cmd;
113 __le32 address;
114} __packed;
115
116struct ath6kl_usb_ctrl_diag_resp_read {
117 __le32 value;
118} __packed;
119
9cbee358
KV
120/* function declarations */
121static void ath6kl_usb_recv_complete(struct urb *urb);
122
123#define ATH6KL_USB_IS_BULK_EP(attr) (((attr) & 3) == 0x02)
124#define ATH6KL_USB_IS_INT_EP(attr) (((attr) & 3) == 0x03)
125#define ATH6KL_USB_IS_ISOC_EP(attr) (((attr) & 3) == 0x01)
126#define ATH6KL_USB_IS_DIR_IN(addr) ((addr) & 0x80)
127
128/* pipe/urb operations */
129static struct ath6kl_urb_context *
130ath6kl_usb_alloc_urb_from_pipe(struct ath6kl_usb_pipe *pipe)
131{
132 struct ath6kl_urb_context *urb_context = NULL;
133 unsigned long flags;
134
135 spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags);
136 if (!list_empty(&pipe->urb_list_head)) {
137 urb_context =
138 list_first_entry(&pipe->urb_list_head,
139 struct ath6kl_urb_context, link);
140 list_del(&urb_context->link);
141 pipe->urb_cnt--;
142 }
143 spin_unlock_irqrestore(&pipe->ar_usb->cs_lock, flags);
144
145 return urb_context;
146}
147
148static void ath6kl_usb_free_urb_to_pipe(struct ath6kl_usb_pipe *pipe,
149 struct ath6kl_urb_context *urb_context)
150{
151 unsigned long flags;
152
153 spin_lock_irqsave(&pipe->ar_usb->cs_lock, flags);
154 pipe->urb_cnt++;
155
156 list_add(&urb_context->link, &pipe->urb_list_head);
157 spin_unlock_irqrestore(&pipe->ar_usb->cs_lock, flags);
158}
159
160static void ath6kl_usb_cleanup_recv_urb(struct ath6kl_urb_context *urb_context)
161{
e16ccfee
MSS
162 dev_kfree_skb(urb_context->skb);
163 urb_context->skb = NULL;
9cbee358
KV
164
165 ath6kl_usb_free_urb_to_pipe(urb_context->pipe, urb_context);
166}
167
168static inline struct ath6kl_usb *ath6kl_usb_priv(struct ath6kl *ar)
169{
170 return ar->hif_priv;
171}
172
173/* pipe resource allocation/cleanup */
174static int ath6kl_usb_alloc_pipe_resources(struct ath6kl_usb_pipe *pipe,
175 int urb_cnt)
176{
177 struct ath6kl_urb_context *urb_context;
178 int status = 0, i;
179
180 INIT_LIST_HEAD(&pipe->urb_list_head);
181 init_usb_anchor(&pipe->urb_submitted);
182
183 for (i = 0; i < urb_cnt; i++) {
184 urb_context = kzalloc(sizeof(struct ath6kl_urb_context),
185 GFP_KERNEL);
5dbdf6fe
MSS
186 if (urb_context == NULL) {
187 status = -ENOMEM;
188 goto fail_alloc_pipe_resources;
189 }
9cbee358
KV
190
191 urb_context->pipe = pipe;
192
193 /*
194 * we are only allocate the urb contexts here, the actual URB
195 * is allocated from the kernel as needed to do a transaction
196 */
197 pipe->urb_alloc++;
198 ath6kl_usb_free_urb_to_pipe(pipe, urb_context);
199 }
200
201 ath6kl_dbg(ATH6KL_DBG_USB,
202 "ath6kl usb: alloc resources lpipe:%d hpipe:0x%X urbs:%d\n",
203 pipe->logical_pipe_num, pipe->usb_pipe_handle,
204 pipe->urb_alloc);
205
5dbdf6fe 206fail_alloc_pipe_resources:
9cbee358
KV
207 return status;
208}
209
210static void ath6kl_usb_free_pipe_resources(struct ath6kl_usb_pipe *pipe)
211{
212 struct ath6kl_urb_context *urb_context;
213
214 if (pipe->ar_usb == NULL) {
215 /* nothing allocated for this pipe */
216 return;
217 }
218
219 ath6kl_dbg(ATH6KL_DBG_USB,
220 "ath6kl usb: free resources lpipe:%d"
221 "hpipe:0x%X urbs:%d avail:%d\n",
222 pipe->logical_pipe_num, pipe->usb_pipe_handle,
223 pipe->urb_alloc, pipe->urb_cnt);
224
225 if (pipe->urb_alloc != pipe->urb_cnt) {
226 ath6kl_dbg(ATH6KL_DBG_USB,
227 "ath6kl usb: urb leak! lpipe:%d"
228 "hpipe:0x%X urbs:%d avail:%d\n",
229 pipe->logical_pipe_num, pipe->usb_pipe_handle,
230 pipe->urb_alloc, pipe->urb_cnt);
231 }
232
233 while (true) {
234 urb_context = ath6kl_usb_alloc_urb_from_pipe(pipe);
235 if (urb_context == NULL)
236 break;
237 kfree(urb_context);
238 }
9cbee358
KV
239}
240
241static void ath6kl_usb_cleanup_pipe_resources(struct ath6kl_usb *ar_usb)
242{
243 int i;
244
245 for (i = 0; i < ATH6KL_USB_PIPE_MAX; i++)
246 ath6kl_usb_free_pipe_resources(&ar_usb->pipes[i]);
9cbee358
KV
247}
248
249static u8 ath6kl_usb_get_logical_pipe_num(struct ath6kl_usb *ar_usb,
250 u8 ep_address, int *urb_count)
251{
252 u8 pipe_num = ATH6KL_USB_PIPE_INVALID;
253
254 switch (ep_address) {
255 case ATH6KL_USB_EP_ADDR_APP_CTRL_IN:
256 pipe_num = ATH6KL_USB_PIPE_RX_CTRL;
257 *urb_count = RX_URB_COUNT;
258 break;
259 case ATH6KL_USB_EP_ADDR_APP_DATA_IN:
260 pipe_num = ATH6KL_USB_PIPE_RX_DATA;
261 *urb_count = RX_URB_COUNT;
262 break;
263 case ATH6KL_USB_EP_ADDR_APP_INT_IN:
264 pipe_num = ATH6KL_USB_PIPE_RX_INT;
265 *urb_count = RX_URB_COUNT;
266 break;
267 case ATH6KL_USB_EP_ADDR_APP_DATA2_IN:
268 pipe_num = ATH6KL_USB_PIPE_RX_DATA2;
269 *urb_count = RX_URB_COUNT;
270 break;
271 case ATH6KL_USB_EP_ADDR_APP_CTRL_OUT:
272 pipe_num = ATH6KL_USB_PIPE_TX_CTRL;
273 *urb_count = TX_URB_COUNT;
274 break;
275 case ATH6KL_USB_EP_ADDR_APP_DATA_LP_OUT:
276 pipe_num = ATH6KL_USB_PIPE_TX_DATA_LP;
277 *urb_count = TX_URB_COUNT;
278 break;
279 case ATH6KL_USB_EP_ADDR_APP_DATA_MP_OUT:
280 pipe_num = ATH6KL_USB_PIPE_TX_DATA_MP;
281 *urb_count = TX_URB_COUNT;
282 break;
283 case ATH6KL_USB_EP_ADDR_APP_DATA_HP_OUT:
284 pipe_num = ATH6KL_USB_PIPE_TX_DATA_HP;
285 *urb_count = TX_URB_COUNT;
286 break;
287 default:
288 /* note: there may be endpoints not currently used */
289 break;
290 }
291
292 return pipe_num;
293}
294
295static int ath6kl_usb_setup_pipe_resources(struct ath6kl_usb *ar_usb)
296{
297 struct usb_interface *interface = ar_usb->interface;
298 struct usb_host_interface *iface_desc = interface->cur_altsetting;
299 struct usb_endpoint_descriptor *endpoint;
300 struct ath6kl_usb_pipe *pipe;
301 int i, urbcount, status = 0;
302 u8 pipe_num;
303
304 ath6kl_dbg(ATH6KL_DBG_USB, "setting up USB Pipes using interface\n");
305
306 /* walk decriptors and setup pipes */
307 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
308 endpoint = &iface_desc->endpoint[i].desc;
309
310 if (ATH6KL_USB_IS_BULK_EP(endpoint->bmAttributes)) {
311 ath6kl_dbg(ATH6KL_DBG_USB,
312 "%s Bulk Ep:0x%2.2X maxpktsz:%d\n",
313 ATH6KL_USB_IS_DIR_IN
314 (endpoint->bEndpointAddress) ?
315 "RX" : "TX", endpoint->bEndpointAddress,
316 le16_to_cpu(endpoint->wMaxPacketSize));
317 } else if (ATH6KL_USB_IS_INT_EP(endpoint->bmAttributes)) {
318 ath6kl_dbg(ATH6KL_DBG_USB,
319 "%s Int Ep:0x%2.2X maxpktsz:%d interval:%d\n",
320 ATH6KL_USB_IS_DIR_IN
321 (endpoint->bEndpointAddress) ?
322 "RX" : "TX", endpoint->bEndpointAddress,
323 le16_to_cpu(endpoint->wMaxPacketSize),
324 endpoint->bInterval);
325 } else if (ATH6KL_USB_IS_ISOC_EP(endpoint->bmAttributes)) {
326 /* TODO for ISO */
327 ath6kl_dbg(ATH6KL_DBG_USB,
328 "%s ISOC Ep:0x%2.2X maxpktsz:%d interval:%d\n",
329 ATH6KL_USB_IS_DIR_IN
330 (endpoint->bEndpointAddress) ?
331 "RX" : "TX", endpoint->bEndpointAddress,
332 le16_to_cpu(endpoint->wMaxPacketSize),
333 endpoint->bInterval);
334 }
335 urbcount = 0;
336
337 pipe_num =
338 ath6kl_usb_get_logical_pipe_num(ar_usb,
339 endpoint->bEndpointAddress,
340 &urbcount);
341 if (pipe_num == ATH6KL_USB_PIPE_INVALID)
342 continue;
343
344 pipe = &ar_usb->pipes[pipe_num];
345 if (pipe->ar_usb != NULL) {
346 /* hmmm..pipe was already setup */
347 continue;
348 }
349
350 pipe->ar_usb = ar_usb;
351 pipe->logical_pipe_num = pipe_num;
352 pipe->ep_address = endpoint->bEndpointAddress;
353 pipe->max_packet_size = le16_to_cpu(endpoint->wMaxPacketSize);
354
355 if (ATH6KL_USB_IS_BULK_EP(endpoint->bmAttributes)) {
356 if (ATH6KL_USB_IS_DIR_IN(pipe->ep_address)) {
357 pipe->usb_pipe_handle =
358 usb_rcvbulkpipe(ar_usb->udev,
359 pipe->ep_address);
360 } else {
361 pipe->usb_pipe_handle =
362 usb_sndbulkpipe(ar_usb->udev,
363 pipe->ep_address);
364 }
365 } else if (ATH6KL_USB_IS_INT_EP(endpoint->bmAttributes)) {
366 if (ATH6KL_USB_IS_DIR_IN(pipe->ep_address)) {
367 pipe->usb_pipe_handle =
368 usb_rcvintpipe(ar_usb->udev,
369 pipe->ep_address);
370 } else {
371 pipe->usb_pipe_handle =
372 usb_sndintpipe(ar_usb->udev,
373 pipe->ep_address);
374 }
375 } else if (ATH6KL_USB_IS_ISOC_EP(endpoint->bmAttributes)) {
376 /* TODO for ISO */
377 if (ATH6KL_USB_IS_DIR_IN(pipe->ep_address)) {
378 pipe->usb_pipe_handle =
379 usb_rcvisocpipe(ar_usb->udev,
380 pipe->ep_address);
381 } else {
382 pipe->usb_pipe_handle =
383 usb_sndisocpipe(ar_usb->udev,
384 pipe->ep_address);
385 }
386 }
387
388 pipe->ep_desc = endpoint;
389
390 if (!ATH6KL_USB_IS_DIR_IN(pipe->ep_address))
391 pipe->flags |= ATH6KL_USB_PIPE_FLAG_TX;
392
393 status = ath6kl_usb_alloc_pipe_resources(pipe, urbcount);
394 if (status != 0)
395 break;
396 }
397
398 return status;
399}
400
401/* pipe operations */
402static void ath6kl_usb_post_recv_transfers(struct ath6kl_usb_pipe *recv_pipe,
403 int buffer_length)
404{
405 struct ath6kl_urb_context *urb_context;
406 struct urb *urb;
407 int usb_status;
408
409 while (true) {
410 urb_context = ath6kl_usb_alloc_urb_from_pipe(recv_pipe);
411 if (urb_context == NULL)
412 break;
413
414 urb_context->skb = dev_alloc_skb(buffer_length);
415 if (urb_context->skb == NULL)
416 goto err_cleanup_urb;
417
418 urb = usb_alloc_urb(0, GFP_ATOMIC);
419 if (urb == NULL)
420 goto err_cleanup_urb;
421
422 usb_fill_bulk_urb(urb,
423 recv_pipe->ar_usb->udev,
424 recv_pipe->usb_pipe_handle,
425 urb_context->skb->data,
426 buffer_length,
427 ath6kl_usb_recv_complete, urb_context);
428
429 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
430 "ath6kl usb: bulk recv submit:%d, 0x%X (ep:0x%2.2X), %d bytes buf:0x%p\n",
431 recv_pipe->logical_pipe_num,
432 recv_pipe->usb_pipe_handle, recv_pipe->ep_address,
433 buffer_length, urb_context->skb);
434
435 usb_anchor_urb(urb, &recv_pipe->urb_submitted);
436 usb_status = usb_submit_urb(urb, GFP_ATOMIC);
437
438 if (usb_status) {
439 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
440 "ath6kl usb : usb bulk recv failed %d\n",
441 usb_status);
442 usb_unanchor_urb(urb);
443 usb_free_urb(urb);
444 goto err_cleanup_urb;
445 }
446 usb_free_urb(urb);
447 }
448 return;
449
450err_cleanup_urb:
451 ath6kl_usb_cleanup_recv_urb(urb_context);
452 return;
453}
454
455static void ath6kl_usb_flush_all(struct ath6kl_usb *ar_usb)
456{
457 int i;
458
459 for (i = 0; i < ATH6KL_USB_PIPE_MAX; i++) {
460 if (ar_usb->pipes[i].ar_usb != NULL)
461 usb_kill_anchored_urbs(&ar_usb->pipes[i].urb_submitted);
462 }
463
464 /*
465 * Flushing any pending I/O may schedule work this call will block
466 * until all scheduled work runs to completion.
467 */
468 flush_scheduled_work();
469}
470
471static void ath6kl_usb_start_recv_pipes(struct ath6kl_usb *ar_usb)
472{
473 /*
474 * note: control pipe is no longer used
475 * ar_usb->pipes[ATH6KL_USB_PIPE_RX_CTRL].urb_cnt_thresh =
476 * ar_usb->pipes[ATH6KL_USB_PIPE_RX_CTRL].urb_alloc/2;
477 * ath6kl_usb_post_recv_transfers(&ar_usb->
478 * pipes[ATH6KL_USB_PIPE_RX_CTRL],
479 * ATH6KL_USB_RX_BUFFER_SIZE);
480 */
481
61118fbf
JM
482 ar_usb->pipes[ATH6KL_USB_PIPE_RX_DATA].urb_cnt_thresh = 1;
483
9cbee358
KV
484 ath6kl_usb_post_recv_transfers(&ar_usb->pipes[ATH6KL_USB_PIPE_RX_DATA],
485 ATH6KL_USB_RX_BUFFER_SIZE);
486}
487
488/* hif usb rx/tx completion functions */
489static void ath6kl_usb_recv_complete(struct urb *urb)
490{
491 struct ath6kl_urb_context *urb_context = urb->context;
492 struct ath6kl_usb_pipe *pipe = urb_context->pipe;
493 struct sk_buff *skb = NULL;
494 int status = 0;
495
496 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
497 "%s: recv pipe: %d, stat:%d, len:%d urb:0x%p\n", __func__,
498 pipe->logical_pipe_num, urb->status, urb->actual_length,
499 urb);
500
501 if (urb->status != 0) {
502 status = -EIO;
503 switch (urb->status) {
504 case -ECONNRESET:
505 case -ENOENT:
506 case -ESHUTDOWN:
507 /*
508 * no need to spew these errors when device
509 * removed or urb killed due to driver shutdown
510 */
511 status = -ECANCELED;
512 break;
513 default:
514 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
515 "%s recv pipe: %d (ep:0x%2.2X), failed:%d\n",
516 __func__, pipe->logical_pipe_num,
517 pipe->ep_address, urb->status);
518 break;
519 }
520 goto cleanup_recv_urb;
521 }
522
523 if (urb->actual_length == 0)
524 goto cleanup_recv_urb;
525
526 skb = urb_context->skb;
527
528 /* we are going to pass it up */
529 urb_context->skb = NULL;
530 skb_put(skb, urb->actual_length);
531
532 /* note: queue implements a lock */
533 skb_queue_tail(&pipe->io_comp_queue, skb);
534 schedule_work(&pipe->io_complete_work);
535
536cleanup_recv_urb:
537 ath6kl_usb_cleanup_recv_urb(urb_context);
538
539 if (status == 0 &&
540 pipe->urb_cnt >= pipe->urb_cnt_thresh) {
541 /* our free urbs are piling up, post more transfers */
542 ath6kl_usb_post_recv_transfers(pipe, ATH6KL_USB_RX_BUFFER_SIZE);
543 }
544}
545
546static void ath6kl_usb_usb_transmit_complete(struct urb *urb)
547{
548 struct ath6kl_urb_context *urb_context = urb->context;
549 struct ath6kl_usb_pipe *pipe = urb_context->pipe;
550 struct sk_buff *skb;
551
552 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
553 "%s: pipe: %d, stat:%d, len:%d\n",
554 __func__, pipe->logical_pipe_num, urb->status,
555 urb->actual_length);
556
557 if (urb->status != 0) {
558 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
559 "%s: pipe: %d, failed:%d\n",
560 __func__, pipe->logical_pipe_num, urb->status);
561 }
562
563 skb = urb_context->skb;
564 urb_context->skb = NULL;
565 ath6kl_usb_free_urb_to_pipe(urb_context->pipe, urb_context);
566
567 /* note: queue implements a lock */
568 skb_queue_tail(&pipe->io_comp_queue, skb);
569 schedule_work(&pipe->io_complete_work);
570}
571
572static void ath6kl_usb_io_comp_work(struct work_struct *work)
573{
574 struct ath6kl_usb_pipe *pipe = container_of(work,
575 struct ath6kl_usb_pipe,
576 io_complete_work);
577 struct ath6kl_usb *ar_usb;
578 struct sk_buff *skb;
579
580 ar_usb = pipe->ar_usb;
581
582 while ((skb = skb_dequeue(&pipe->io_comp_queue))) {
583 if (pipe->flags & ATH6KL_USB_PIPE_FLAG_TX) {
584 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
585 "ath6kl usb xmit callback buf:0x%p\n", skb);
586 ath6kl_core_tx_complete(ar_usb->ar, skb);
587 } else {
588 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
589 "ath6kl usb recv callback buf:0x%p\n", skb);
590 ath6kl_core_rx_complete(ar_usb->ar, skb,
591 pipe->logical_pipe_num);
592 }
593 }
594}
595
241b128b
KV
596#define ATH6KL_USB_MAX_DIAG_CMD (sizeof(struct ath6kl_usb_ctrl_diag_cmd_write))
597#define ATH6KL_USB_MAX_DIAG_RESP (sizeof(struct ath6kl_usb_ctrl_diag_resp_read))
598
599static void ath6kl_usb_destroy(struct ath6kl_usb *ar_usb)
600{
9cbee358
KV
601 ath6kl_usb_flush_all(ar_usb);
602
603 ath6kl_usb_cleanup_pipe_resources(ar_usb);
604
241b128b
KV
605 usb_set_intfdata(ar_usb->interface, NULL);
606
607 kfree(ar_usb->diag_cmd_buffer);
608 kfree(ar_usb->diag_resp_buffer);
609
610 kfree(ar_usb);
611}
612
613static struct ath6kl_usb *ath6kl_usb_create(struct usb_interface *interface)
614{
241b128b 615 struct usb_device *dev = interface_to_usbdev(interface);
9cbee358
KV
616 struct ath6kl_usb *ar_usb;
617 struct ath6kl_usb_pipe *pipe;
241b128b 618 int status = 0;
9cbee358 619 int i;
241b128b
KV
620
621 ar_usb = kzalloc(sizeof(struct ath6kl_usb), GFP_KERNEL);
622 if (ar_usb == NULL)
623 goto fail_ath6kl_usb_create;
624
241b128b 625 usb_set_intfdata(interface, ar_usb);
9cbee358 626 spin_lock_init(&(ar_usb->cs_lock));
241b128b
KV
627 ar_usb->udev = dev;
628 ar_usb->interface = interface;
629
9cbee358
KV
630 for (i = 0; i < ATH6KL_USB_PIPE_MAX; i++) {
631 pipe = &ar_usb->pipes[i];
632 INIT_WORK(&pipe->io_complete_work,
633 ath6kl_usb_io_comp_work);
634 skb_queue_head_init(&pipe->io_comp_queue);
635 }
636
241b128b
KV
637 ar_usb->diag_cmd_buffer = kzalloc(ATH6KL_USB_MAX_DIAG_CMD, GFP_KERNEL);
638 if (ar_usb->diag_cmd_buffer == NULL) {
639 status = -ENOMEM;
640 goto fail_ath6kl_usb_create;
641 }
642
643 ar_usb->diag_resp_buffer = kzalloc(ATH6KL_USB_MAX_DIAG_RESP,
644 GFP_KERNEL);
645 if (ar_usb->diag_resp_buffer == NULL) {
646 status = -ENOMEM;
647 goto fail_ath6kl_usb_create;
648 }
649
9cbee358
KV
650 status = ath6kl_usb_setup_pipe_resources(ar_usb);
651
241b128b
KV
652fail_ath6kl_usb_create:
653 if (status != 0) {
654 ath6kl_usb_destroy(ar_usb);
655 ar_usb = NULL;
656 }
657 return ar_usb;
658}
659
660static void ath6kl_usb_device_detached(struct usb_interface *interface)
661{
662 struct ath6kl_usb *ar_usb;
663
664 ar_usb = usb_get_intfdata(interface);
665 if (ar_usb == NULL)
666 return;
667
668 ath6kl_stop_txrx(ar_usb->ar);
669
9cbee358
KV
670 /* Delay to wait for the target to reboot */
671 mdelay(20);
241b128b 672 ath6kl_core_cleanup(ar_usb->ar);
241b128b
KV
673 ath6kl_usb_destroy(ar_usb);
674}
675
9cbee358
KV
676/* exported hif usb APIs for htc pipe */
677static void hif_start(struct ath6kl *ar)
678{
679 struct ath6kl_usb *device = ath6kl_usb_priv(ar);
680 int i;
681
682 ath6kl_usb_start_recv_pipes(device);
683
684 /* set the TX resource avail threshold for each TX pipe */
685 for (i = ATH6KL_USB_PIPE_TX_CTRL;
686 i <= ATH6KL_USB_PIPE_TX_DATA_HP; i++) {
687 device->pipes[i].urb_cnt_thresh =
688 device->pipes[i].urb_alloc / 2;
689 }
690}
691
692static int ath6kl_usb_send(struct ath6kl *ar, u8 PipeID,
693 struct sk_buff *hdr_skb, struct sk_buff *skb)
694{
695 struct ath6kl_usb *device = ath6kl_usb_priv(ar);
696 struct ath6kl_usb_pipe *pipe = &device->pipes[PipeID];
697 struct ath6kl_urb_context *urb_context;
698 int usb_status, status = 0;
699 struct urb *urb;
700 u8 *data;
701 u32 len;
702
703 ath6kl_dbg(ATH6KL_DBG_USB_BULK, "+%s pipe : %d, buf:0x%p\n",
704 __func__, PipeID, skb);
705
706 urb_context = ath6kl_usb_alloc_urb_from_pipe(pipe);
707
708 if (urb_context == NULL) {
709 /*
710 * TODO: it is possible to run out of urbs if
711 * 2 endpoints map to the same pipe ID
712 */
713 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
714 "%s pipe:%d no urbs left. URB Cnt : %d\n",
715 __func__, PipeID, pipe->urb_cnt);
716 status = -ENOMEM;
717 goto fail_hif_send;
718 }
719
720 urb_context->skb = skb;
721
722 data = skb->data;
723 len = skb->len;
724
725 urb = usb_alloc_urb(0, GFP_ATOMIC);
726 if (urb == NULL) {
727 status = -ENOMEM;
728 ath6kl_usb_free_urb_to_pipe(urb_context->pipe,
729 urb_context);
730 goto fail_hif_send;
731 }
732
733 usb_fill_bulk_urb(urb,
734 device->udev,
735 pipe->usb_pipe_handle,
736 data,
737 len,
738 ath6kl_usb_usb_transmit_complete, urb_context);
739
740 if ((len % pipe->max_packet_size) == 0) {
741 /* hit a max packet boundary on this pipe */
742 urb->transfer_flags |= URB_ZERO_PACKET;
743 }
744
745 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
746 "athusb bulk send submit:%d, 0x%X (ep:0x%2.2X), %d bytes\n",
747 pipe->logical_pipe_num, pipe->usb_pipe_handle,
748 pipe->ep_address, len);
749
750 usb_anchor_urb(urb, &pipe->urb_submitted);
751 usb_status = usb_submit_urb(urb, GFP_ATOMIC);
752
753 if (usb_status) {
754 ath6kl_dbg(ATH6KL_DBG_USB_BULK,
755 "ath6kl usb : usb bulk transmit failed %d\n",
756 usb_status);
757 usb_unanchor_urb(urb);
758 ath6kl_usb_free_urb_to_pipe(urb_context->pipe,
759 urb_context);
760 status = -EINVAL;
761 }
762 usb_free_urb(urb);
763
764fail_hif_send:
765 return status;
766}
767
768static void hif_stop(struct ath6kl *ar)
769{
770 struct ath6kl_usb *device = ath6kl_usb_priv(ar);
771
772 ath6kl_usb_flush_all(device);
773}
774
775static void ath6kl_usb_get_default_pipe(struct ath6kl *ar,
776 u8 *ul_pipe, u8 *dl_pipe)
777{
778 *ul_pipe = ATH6KL_USB_PIPE_TX_CTRL;
779 *dl_pipe = ATH6KL_USB_PIPE_RX_CTRL;
780}
781
782static int ath6kl_usb_map_service_pipe(struct ath6kl *ar, u16 svc_id,
783 u8 *ul_pipe, u8 *dl_pipe)
784{
785 int status = 0;
786
787 switch (svc_id) {
788 case HTC_CTRL_RSVD_SVC:
789 case WMI_CONTROL_SVC:
790 *ul_pipe = ATH6KL_USB_PIPE_TX_CTRL;
791 /* due to large control packets, shift to data pipe */
792 *dl_pipe = ATH6KL_USB_PIPE_RX_DATA;
793 break;
794 case WMI_DATA_BE_SVC:
795 case WMI_DATA_BK_SVC:
796 *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_LP;
797 /*
798 * Disable rxdata2 directly, it will be enabled
799 * if FW enable rxdata2
800 */
801 *dl_pipe = ATH6KL_USB_PIPE_RX_DATA;
802 break;
803 case WMI_DATA_VI_SVC:
171fe768
MSS
804
805 if (ar->hw.flags & ATH6KL_HW_MAP_LP_ENDPOINT)
806 *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_LP;
807 else
808 *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_MP;
9cbee358
KV
809 /*
810 * Disable rxdata2 directly, it will be enabled
811 * if FW enable rxdata2
812 */
813 *dl_pipe = ATH6KL_USB_PIPE_RX_DATA;
814 break;
815 case WMI_DATA_VO_SVC:
171fe768
MSS
816
817 if (ar->hw.flags & ATH6KL_HW_MAP_LP_ENDPOINT)
818 *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_LP;
819 else
820 *ul_pipe = ATH6KL_USB_PIPE_TX_DATA_MP;
9cbee358
KV
821 /*
822 * Disable rxdata2 directly, it will be enabled
823 * if FW enable rxdata2
824 */
825 *dl_pipe = ATH6KL_USB_PIPE_RX_DATA;
826 break;
827 default:
828 status = -EPERM;
829 break;
830 }
831
832 return status;
833}
834
835static u16 ath6kl_usb_get_free_queue_number(struct ath6kl *ar, u8 pipe_id)
836{
837 struct ath6kl_usb *device = ath6kl_usb_priv(ar);
838
839 return device->pipes[pipe_id].urb_cnt;
840}
841
842static void hif_detach_htc(struct ath6kl *ar)
843{
844 struct ath6kl_usb *device = ath6kl_usb_priv(ar);
845
846 ath6kl_usb_flush_all(device);
847}
848
241b128b
KV
849static int ath6kl_usb_submit_ctrl_out(struct ath6kl_usb *ar_usb,
850 u8 req, u16 value, u16 index, void *data,
851 u32 size)
852{
853 u8 *buf = NULL;
854 int ret;
855
856 if (size > 0) {
a41d9a91 857 buf = kmemdup(data, size, GFP_KERNEL);
241b128b
KV
858 if (buf == NULL)
859 return -ENOMEM;
241b128b
KV
860 }
861
862 /* note: if successful returns number of bytes transfered */
863 ret = usb_control_msg(ar_usb->udev,
864 usb_sndctrlpipe(ar_usb->udev, 0),
865 req,
866 USB_DIR_OUT | USB_TYPE_VENDOR |
867 USB_RECIP_DEVICE, value, index, buf,
868 size, 1000);
869
870 if (ret < 0) {
4e1609c9
KV
871 ath6kl_warn("Failed to submit usb control message: %d\n", ret);
872 kfree(buf);
873 return ret;
241b128b
KV
874 }
875
876 kfree(buf);
877
878 return 0;
879}
880
881static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb,
882 u8 req, u16 value, u16 index, void *data,
883 u32 size)
884{
885 u8 *buf = NULL;
886 int ret;
887
888 if (size > 0) {
889 buf = kmalloc(size, GFP_KERNEL);
890 if (buf == NULL)
891 return -ENOMEM;
892 }
893
894 /* note: if successful returns number of bytes transfered */
895 ret = usb_control_msg(ar_usb->udev,
896 usb_rcvctrlpipe(ar_usb->udev, 0),
897 req,
898 USB_DIR_IN | USB_TYPE_VENDOR |
899 USB_RECIP_DEVICE, value, index, buf,
900 size, 2 * HZ);
901
902 if (ret < 0) {
4e1609c9
KV
903 ath6kl_warn("Failed to read usb control message: %d\n", ret);
904 kfree(buf);
905 return ret;
241b128b
KV
906 }
907
908 memcpy((u8 *) data, buf, size);
909
910 kfree(buf);
911
912 return 0;
913}
914
915static int ath6kl_usb_ctrl_msg_exchange(struct ath6kl_usb *ar_usb,
916 u8 req_val, u8 *req_buf, u32 req_len,
917 u8 resp_val, u8 *resp_buf, u32 *resp_len)
918{
919 int ret;
920
921 /* send command */
922 ret = ath6kl_usb_submit_ctrl_out(ar_usb, req_val, 0, 0,
923 req_buf, req_len);
924
925 if (ret != 0)
926 return ret;
927
928 if (resp_buf == NULL) {
929 /* no expected response */
930 return ret;
931 }
932
933 /* get response */
934 ret = ath6kl_usb_submit_ctrl_in(ar_usb, resp_val, 0, 0,
935 resp_buf, *resp_len);
936
937 return ret;
938}
939
940static int ath6kl_usb_diag_read32(struct ath6kl *ar, u32 address, u32 *data)
941{
942 struct ath6kl_usb *ar_usb = ar->hif_priv;
943 struct ath6kl_usb_ctrl_diag_resp_read *resp;
944 struct ath6kl_usb_ctrl_diag_cmd_read *cmd;
945 u32 resp_len;
946 int ret;
947
948 cmd = (struct ath6kl_usb_ctrl_diag_cmd_read *) ar_usb->diag_cmd_buffer;
949
950 memset(cmd, 0, sizeof(*cmd));
951 cmd->cmd = ATH6KL_USB_CTRL_DIAG_CC_READ;
952 cmd->address = cpu_to_le32(address);
953 resp_len = sizeof(*resp);
954
955 ret = ath6kl_usb_ctrl_msg_exchange(ar_usb,
956 ATH6KL_USB_CONTROL_REQ_DIAG_CMD,
957 (u8 *) cmd,
958 sizeof(struct ath6kl_usb_ctrl_diag_cmd_write),
959 ATH6KL_USB_CONTROL_REQ_DIAG_RESP,
960 ar_usb->diag_resp_buffer, &resp_len);
961
4e1609c9
KV
962 if (ret) {
963 ath6kl_warn("diag read32 failed: %d\n", ret);
241b128b 964 return ret;
4e1609c9 965 }
241b128b
KV
966
967 resp = (struct ath6kl_usb_ctrl_diag_resp_read *)
968 ar_usb->diag_resp_buffer;
969
970 *data = le32_to_cpu(resp->value);
971
972 return ret;
973}
974
975static int ath6kl_usb_diag_write32(struct ath6kl *ar, u32 address, __le32 data)
976{
977 struct ath6kl_usb *ar_usb = ar->hif_priv;
978 struct ath6kl_usb_ctrl_diag_cmd_write *cmd;
4e1609c9 979 int ret;
241b128b
KV
980
981 cmd = (struct ath6kl_usb_ctrl_diag_cmd_write *) ar_usb->diag_cmd_buffer;
982
983 memset(cmd, 0, sizeof(struct ath6kl_usb_ctrl_diag_cmd_write));
984 cmd->cmd = cpu_to_le32(ATH6KL_USB_CTRL_DIAG_CC_WRITE);
985 cmd->address = cpu_to_le32(address);
986 cmd->value = data;
987
4e1609c9
KV
988 ret = ath6kl_usb_ctrl_msg_exchange(ar_usb,
989 ATH6KL_USB_CONTROL_REQ_DIAG_CMD,
990 (u8 *) cmd,
991 sizeof(*cmd),
992 0, NULL, NULL);
993 if (ret) {
994 ath6kl_warn("diag_write32 failed: %d\n", ret);
995 return ret;
996 }
241b128b 997
4e1609c9 998 return 0;
241b128b
KV
999}
1000
1001static int ath6kl_usb_bmi_read(struct ath6kl *ar, u8 *buf, u32 len)
1002{
1003 struct ath6kl_usb *ar_usb = ar->hif_priv;
1004 int ret;
1005
1006 /* get response */
1007 ret = ath6kl_usb_submit_ctrl_in(ar_usb,
1008 ATH6KL_USB_CONTROL_REQ_RECV_BMI_RESP,
1009 0, 0, buf, len);
4e1609c9 1010 if (ret) {
241b128b
KV
1011 ath6kl_err("Unable to read the bmi data from the device: %d\n",
1012 ret);
1013 return ret;
1014 }
1015
1016 return 0;
1017}
1018
1019static int ath6kl_usb_bmi_write(struct ath6kl *ar, u8 *buf, u32 len)
1020{
1021 struct ath6kl_usb *ar_usb = ar->hif_priv;
1022 int ret;
1023
1024 /* send command */
1025 ret = ath6kl_usb_submit_ctrl_out(ar_usb,
1026 ATH6KL_USB_CONTROL_REQ_SEND_BMI_CMD,
1027 0, 0, buf, len);
4e1609c9 1028 if (ret) {
241b128b
KV
1029 ath6kl_err("unable to send the bmi data to the device: %d\n",
1030 ret);
1031 return ret;
1032 }
1033
1034 return 0;
1035}
1036
1037static int ath6kl_usb_power_on(struct ath6kl *ar)
1038{
9cbee358 1039 hif_start(ar);
241b128b
KV
1040 return 0;
1041}
1042
1043static int ath6kl_usb_power_off(struct ath6kl *ar)
1044{
9cbee358 1045 hif_detach_htc(ar);
241b128b
KV
1046 return 0;
1047}
1048
9cbee358
KV
1049static void ath6kl_usb_stop(struct ath6kl *ar)
1050{
1051 hif_stop(ar);
1052}
1053
08c61009
RC
1054static void ath6kl_usb_cleanup_scatter(struct ath6kl *ar)
1055{
1056 /*
1057 * USB doesn't support it. Just return.
1058 */
1059 return;
1060}
1061
8c40e4e0
MSS
1062static int ath6kl_usb_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow)
1063{
1064 /*
1065 * cfg80211 suspend/WOW currently not supported for USB.
1066 */
1067 return 0;
1068}
1069
1070static int ath6kl_usb_resume(struct ath6kl *ar)
1071{
1072 /*
1073 * cfg80211 resume currently not supported for USB.
1074 */
1075 return 0;
1076}
1077
241b128b
KV
1078static const struct ath6kl_hif_ops ath6kl_usb_ops = {
1079 .diag_read32 = ath6kl_usb_diag_read32,
1080 .diag_write32 = ath6kl_usb_diag_write32,
1081 .bmi_read = ath6kl_usb_bmi_read,
1082 .bmi_write = ath6kl_usb_bmi_write,
1083 .power_on = ath6kl_usb_power_on,
1084 .power_off = ath6kl_usb_power_off,
9cbee358
KV
1085 .stop = ath6kl_usb_stop,
1086 .pipe_send = ath6kl_usb_send,
1087 .pipe_get_default = ath6kl_usb_get_default_pipe,
1088 .pipe_map_service = ath6kl_usb_map_service_pipe,
1089 .pipe_get_free_queue_number = ath6kl_usb_get_free_queue_number,
08c61009 1090 .cleanup_scatter = ath6kl_usb_cleanup_scatter,
8c40e4e0
MSS
1091 .suspend = ath6kl_usb_suspend,
1092 .resume = ath6kl_usb_resume,
241b128b
KV
1093};
1094
1095/* ath6kl usb driver registered functions */
1096static int ath6kl_usb_probe(struct usb_interface *interface,
1097 const struct usb_device_id *id)
1098{
1099 struct usb_device *dev = interface_to_usbdev(interface);
1100 struct ath6kl *ar;
1101 struct ath6kl_usb *ar_usb = NULL;
1102 int vendor_id, product_id;
1103 int ret = 0;
1104
1105 usb_get_dev(dev);
1106
1107 vendor_id = le16_to_cpu(dev->descriptor.idVendor);
1108 product_id = le16_to_cpu(dev->descriptor.idProduct);
1109
1110 ath6kl_dbg(ATH6KL_DBG_USB, "vendor_id = %04x\n", vendor_id);
1111 ath6kl_dbg(ATH6KL_DBG_USB, "product_id = %04x\n", product_id);
1112
1113 if (interface->cur_altsetting)
1114 ath6kl_dbg(ATH6KL_DBG_USB, "USB Interface %d\n",
1115 interface->cur_altsetting->desc.bInterfaceNumber);
1116
1117
1118 if (dev->speed == USB_SPEED_HIGH)
1119 ath6kl_dbg(ATH6KL_DBG_USB, "USB 2.0 Host\n");
1120 else
1121 ath6kl_dbg(ATH6KL_DBG_USB, "USB 1.1 Host\n");
1122
1123 ar_usb = ath6kl_usb_create(interface);
1124
1125 if (ar_usb == NULL) {
1126 ret = -ENOMEM;
1127 goto err_usb_put;
1128 }
1129
1130 ar = ath6kl_core_create(&ar_usb->udev->dev);
1131 if (ar == NULL) {
1132 ath6kl_err("Failed to alloc ath6kl core\n");
1133 ret = -ENOMEM;
1134 goto err_usb_destroy;
1135 }
1136
1137 ar->hif_priv = ar_usb;
1138 ar->hif_type = ATH6KL_HIF_TYPE_USB;
1139 ar->hif_ops = &ath6kl_usb_ops;
1140 ar->mbox_info.block_size = 16;
1141 ar->bmi.max_data_size = 252;
1142
1143 ar_usb->ar = ar;
1144
9cbee358 1145 ret = ath6kl_core_init(ar, ATH6KL_HTC_TYPE_PIPE);
241b128b
KV
1146 if (ret) {
1147 ath6kl_err("Failed to init ath6kl core: %d\n", ret);
1148 goto err_core_free;
1149 }
1150
1151 return ret;
1152
1153err_core_free:
1154 ath6kl_core_destroy(ar);
1155err_usb_destroy:
1156 ath6kl_usb_destroy(ar_usb);
1157err_usb_put:
1158 usb_put_dev(dev);
1159
1160 return ret;
1161}
1162
1163static void ath6kl_usb_remove(struct usb_interface *interface)
1164{
1165 usb_put_dev(interface_to_usbdev(interface));
1166 ath6kl_usb_device_detached(interface);
1167}
1168
9cbee358
KV
1169#ifdef CONFIG_PM
1170
0b3d3ff1 1171static int ath6kl_usb_pm_suspend(struct usb_interface *interface,
9cbee358
KV
1172 pm_message_t message)
1173{
1174 struct ath6kl_usb *device;
1175 device = usb_get_intfdata(interface);
1176
1177 ath6kl_usb_flush_all(device);
1178 return 0;
1179}
1180
0b3d3ff1 1181static int ath6kl_usb_pm_resume(struct usb_interface *interface)
9cbee358
KV
1182{
1183 struct ath6kl_usb *device;
1184 device = usb_get_intfdata(interface);
1185
1186 ath6kl_usb_post_recv_transfers(&device->pipes[ATH6KL_USB_PIPE_RX_DATA],
1187 ATH6KL_USB_RX_BUFFER_SIZE);
1188 ath6kl_usb_post_recv_transfers(&device->pipes[ATH6KL_USB_PIPE_RX_DATA2],
1189 ATH6KL_USB_RX_BUFFER_SIZE);
1190
1191 return 0;
1192}
1193
0b3d3ff1 1194static int ath6kl_usb_pm_reset_resume(struct usb_interface *intf)
9cbee358
KV
1195{
1196 if (usb_get_intfdata(intf))
1197 ath6kl_usb_remove(intf);
1198 return 0;
1199}
1200
1201#else
1202
0b3d3ff1
MSS
1203#define ath6kl_usb_pm_suspend NULL
1204#define ath6kl_usb_pm_resume NULL
1205#define ath6kl_usb_pm_reset_resume NULL
9cbee358
KV
1206
1207#endif
1208
241b128b
KV
1209/* table of devices that work with this driver */
1210static struct usb_device_id ath6kl_usb_ids[] = {
1211 {USB_DEVICE(0x0cf3, 0x9374)},
1212 { /* Terminating entry */ },
1213};
1214
1215MODULE_DEVICE_TABLE(usb, ath6kl_usb_ids);
1216
1217static struct usb_driver ath6kl_usb_driver = {
1218 .name = "ath6kl_usb",
1219 .probe = ath6kl_usb_probe,
0b3d3ff1
MSS
1220 .suspend = ath6kl_usb_pm_suspend,
1221 .resume = ath6kl_usb_pm_resume,
1222 .reset_resume = ath6kl_usb_pm_reset_resume,
241b128b
KV
1223 .disconnect = ath6kl_usb_remove,
1224 .id_table = ath6kl_usb_ids,
9cbee358 1225 .supports_autosuspend = true,
e1f12eb6 1226 .disable_hub_initiated_lpm = 1,
241b128b
KV
1227};
1228
1229static int ath6kl_usb_init(void)
1230{
a3b3842c
MM
1231 int ret;
1232
1233 ret = usb_register(&ath6kl_usb_driver);
1234 if (ret) {
1235 ath6kl_err("usb registration failed: %d\n", ret);
1236 return ret;
1237 }
1238
241b128b
KV
1239 return 0;
1240}
1241
1242static void ath6kl_usb_exit(void)
1243{
1244 usb_deregister(&ath6kl_usb_driver);
1245}
1246
1247module_init(ath6kl_usb_init);
1248module_exit(ath6kl_usb_exit);
1249
1250MODULE_AUTHOR("Atheros Communications, Inc.");
1251MODULE_DESCRIPTION("Driver support for Atheros AR600x USB devices");
1252MODULE_LICENSE("Dual BSD/GPL");
1253MODULE_FIRMWARE(AR6004_HW_1_0_FIRMWARE_FILE);
1254MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE);
1255MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE);
1256MODULE_FIRMWARE(AR6004_HW_1_1_FIRMWARE_FILE);
1257MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE);
1258MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE);
6146ca69
RC
1259MODULE_FIRMWARE(AR6004_HW_1_2_FIRMWARE_FILE);
1260MODULE_FIRMWARE(AR6004_HW_1_2_BOARD_DATA_FILE);
1261MODULE_FIRMWARE(AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE);
bf744f11
BS
1262MODULE_FIRMWARE(AR6004_HW_1_3_FW_DIR "/" AR6004_HW_1_3_FIRMWARE_FILE);
1263MODULE_FIRMWARE(AR6004_HW_1_3_BOARD_DATA_FILE);
1264MODULE_FIRMWARE(AR6004_HW_1_3_DEFAULT_BOARD_DATA_FILE);