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