2 * Copyright (c) 2011 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/firmware.h>
20 #include <linux/usb.h>
21 #include <linux/vmalloc.h>
23 #include <brcmu_utils.h>
24 #include <brcm_hw_ids.h>
25 #include <brcmu_wifi.h>
32 #define IOCTL_RESP_TIMEOUT 2000
34 #define BRCMF_USB_RESET_GETVER_SPINWAIT 100 /* in unit of ms */
35 #define BRCMF_USB_RESET_GETVER_LOOP_CNT 10
37 #define BRCMF_POSTBOOT_ID 0xA123 /* ID to detect if dongle
39 #define BRCMF_USB_NRXQ 50
40 #define BRCMF_USB_NTXQ 50
42 #define BRCMF_USB_CBCTL_WRITE 0
43 #define BRCMF_USB_CBCTL_READ 1
44 #define BRCMF_USB_MAX_PKT_SIZE 1600
46 BRCMF_FW_DEF(43143, "brcmfmac43143.bin");
47 BRCMF_FW_DEF(43236B
, "brcmfmac43236b.bin");
48 BRCMF_FW_DEF(43242A
, "brcmfmac43242a.bin");
49 BRCMF_FW_DEF(43569, "brcmfmac43569.bin");
51 static struct brcmf_firmware_mapping brcmf_usb_fwnames
[] = {
52 BRCMF_FW_ENTRY(BRCM_CC_43143_CHIP_ID
, 0xFFFFFFFF, 43143),
53 BRCMF_FW_ENTRY(BRCM_CC_43235_CHIP_ID
, 0x00000008, 43236B
),
54 BRCMF_FW_ENTRY(BRCM_CC_43236_CHIP_ID
, 0x00000008, 43236B
),
55 BRCMF_FW_ENTRY(BRCM_CC_43238_CHIP_ID
, 0x00000008, 43236B
),
56 BRCMF_FW_ENTRY(BRCM_CC_43242_CHIP_ID
, 0xFFFFFFFF, 43242A
),
57 BRCMF_FW_ENTRY(BRCM_CC_43566_CHIP_ID
, 0xFFFFFFFF, 43569),
58 BRCMF_FW_ENTRY(BRCM_CC_43569_CHIP_ID
, 0xFFFFFFFF, 43569)
61 #define TRX_MAGIC 0x30524448 /* "HDR0" */
62 #define TRX_MAX_OFFSET 3 /* Max number of file offsets */
63 #define TRX_UNCOMP_IMAGE 0x20 /* Trx holds uncompressed img */
64 #define TRX_RDL_CHUNK 1500 /* size of each dl transfer */
65 #define TRX_OFFSETS_DLFWLEN_IDX 0
67 /* Control messages: bRequest values */
68 #define DL_GETSTATE 0 /* returns the rdl_state_t struct */
69 #define DL_CHECK_CRC 1 /* currently unused */
70 #define DL_GO 2 /* execute downloaded image */
71 #define DL_START 3 /* initialize dl state */
72 #define DL_REBOOT 4 /* reboot the device in 2 seconds */
73 #define DL_GETVER 5 /* returns the bootrom_id_t struct */
74 #define DL_GO_PROTECTED 6 /* execute the downloaded code and set reset
75 * event to occur in 2 seconds. It is the
76 * responsibility of the downloaded code to
79 #define DL_EXEC 7 /* jump to a supplied address */
80 #define DL_RESETCFG 8 /* To support single enum on dongle
81 * - Not used by bootloader
83 #define DL_DEFER_RESP_OK 9 /* Potentially defer the response to setup
88 #define DL_WAITING 0 /* waiting to rx first pkt */
89 #define DL_READY 1 /* hdr was good, waiting for more of the
92 #define DL_BAD_HDR 2 /* hdr was corrupted */
93 #define DL_BAD_CRC 3 /* compressed image was corrupted */
94 #define DL_RUNNABLE 4 /* download was successful,waiting for go cmd */
95 #define DL_START_FAIL 5 /* failed to initialize correctly */
96 #define DL_NVRAM_TOOBIG 6 /* host specified nvram data exceeds DL_NVRAM
99 #define DL_IMAGE_TOOBIG 7 /* firmware image too big */
102 struct trx_header_le
{
103 __le32 magic
; /* "HDR0" */
104 __le32 len
; /* Length of file including header */
105 __le32 crc32
; /* CRC from flag_version to end of file */
106 __le32 flag_version
; /* 0:15 flags, 16:31 version */
107 __le32 offsets
[TRX_MAX_OFFSET
]; /* Offsets of partitions from start of
112 struct rdl_state_le
{
117 struct bootrom_id_le
{
118 __le32 chip
; /* Chip id */
119 __le32 chiprev
; /* Chip rev */
120 __le32 ramsize
; /* Size of RAM */
121 __le32 remapbase
; /* Current remap base address */
122 __le32 boardtype
; /* Type of board */
123 __le32 boardrev
; /* Board revision */
126 struct brcmf_usb_image
{
127 struct list_head list
;
133 struct brcmf_usbdev_info
{
134 struct brcmf_usbdev bus_pub
; /* MUST BE FIRST */
136 struct list_head rx_freeq
;
137 struct list_head rx_postq
;
138 struct list_head tx_freeq
;
139 struct list_head tx_postq
;
140 uint rx_pipe
, tx_pipe
;
142 int rx_low_watermark
;
143 int tx_low_watermark
;
144 int tx_high_watermark
;
147 spinlock_t tx_flowblock_lock
;
149 struct brcmf_usbreq
*tx_reqs
;
150 struct brcmf_usbreq
*rx_reqs
;
152 char fw_name
[BRCMF_FW_NAME_LEN
];
153 const u8
*image
; /* buffer for combine fw and nvram */
156 struct usb_device
*usbdev
;
158 struct mutex dev_init_lock
;
160 int ctl_in_pipe
, ctl_out_pipe
;
161 struct urb
*ctl_urb
; /* URB for control endpoint */
162 struct usb_ctrlrequest ctl_write
;
163 struct usb_ctrlrequest ctl_read
;
164 u32 ctl_urb_actual_length
;
167 wait_queue_head_t ioctl_resp_wait
;
171 struct urb
*bulk_urb
; /* used for FW download */
176 static void brcmf_usb_rx_refill(struct brcmf_usbdev_info
*devinfo
,
177 struct brcmf_usbreq
*req
);
179 static struct brcmf_usbdev
*brcmf_usb_get_buspub(struct device
*dev
)
181 struct brcmf_bus
*bus_if
= dev_get_drvdata(dev
);
182 return bus_if
->bus_priv
.usb
;
185 static struct brcmf_usbdev_info
*brcmf_usb_get_businfo(struct device
*dev
)
187 return brcmf_usb_get_buspub(dev
)->devinfo
;
190 static int brcmf_usb_ioctl_resp_wait(struct brcmf_usbdev_info
*devinfo
)
192 return wait_event_timeout(devinfo
->ioctl_resp_wait
,
193 devinfo
->ctl_completed
,
194 msecs_to_jiffies(IOCTL_RESP_TIMEOUT
));
197 static void brcmf_usb_ioctl_resp_wake(struct brcmf_usbdev_info
*devinfo
)
199 wake_up(&devinfo
->ioctl_resp_wait
);
203 brcmf_usb_ctl_complete(struct brcmf_usbdev_info
*devinfo
, int type
, int status
)
205 brcmf_dbg(USB
, "Enter, status=%d\n", status
);
207 if (unlikely(devinfo
== NULL
))
210 if (type
== BRCMF_USB_CBCTL_READ
) {
212 devinfo
->bus_pub
.stats
.rx_ctlpkts
++;
214 devinfo
->bus_pub
.stats
.rx_ctlerrs
++;
215 } else if (type
== BRCMF_USB_CBCTL_WRITE
) {
217 devinfo
->bus_pub
.stats
.tx_ctlpkts
++;
219 devinfo
->bus_pub
.stats
.tx_ctlerrs
++;
222 devinfo
->ctl_urb_status
= status
;
223 devinfo
->ctl_completed
= true;
224 brcmf_usb_ioctl_resp_wake(devinfo
);
228 brcmf_usb_ctlread_complete(struct urb
*urb
)
230 struct brcmf_usbdev_info
*devinfo
=
231 (struct brcmf_usbdev_info
*)urb
->context
;
233 brcmf_dbg(USB
, "Enter\n");
234 devinfo
->ctl_urb_actual_length
= urb
->actual_length
;
235 brcmf_usb_ctl_complete(devinfo
, BRCMF_USB_CBCTL_READ
,
240 brcmf_usb_ctlwrite_complete(struct urb
*urb
)
242 struct brcmf_usbdev_info
*devinfo
=
243 (struct brcmf_usbdev_info
*)urb
->context
;
245 brcmf_dbg(USB
, "Enter\n");
246 brcmf_usb_ctl_complete(devinfo
, BRCMF_USB_CBCTL_WRITE
,
251 brcmf_usb_send_ctl(struct brcmf_usbdev_info
*devinfo
, u8
*buf
, int len
)
256 brcmf_dbg(USB
, "Enter\n");
257 if (devinfo
== NULL
|| buf
== NULL
||
258 len
== 0 || devinfo
->ctl_urb
== NULL
)
262 devinfo
->ctl_write
.wLength
= cpu_to_le16p(&size
);
263 devinfo
->ctl_urb
->transfer_buffer_length
= size
;
264 devinfo
->ctl_urb_status
= 0;
265 devinfo
->ctl_urb_actual_length
= 0;
267 usb_fill_control_urb(devinfo
->ctl_urb
,
269 devinfo
->ctl_out_pipe
,
270 (unsigned char *) &devinfo
->ctl_write
,
272 (usb_complete_t
)brcmf_usb_ctlwrite_complete
,
275 ret
= usb_submit_urb(devinfo
->ctl_urb
, GFP_ATOMIC
);
277 brcmf_err("usb_submit_urb failed %d\n", ret
);
283 brcmf_usb_recv_ctl(struct brcmf_usbdev_info
*devinfo
, u8
*buf
, int len
)
288 brcmf_dbg(USB
, "Enter\n");
289 if ((devinfo
== NULL
) || (buf
== NULL
) || (len
== 0)
290 || (devinfo
->ctl_urb
== NULL
))
294 devinfo
->ctl_read
.wLength
= cpu_to_le16p(&size
);
295 devinfo
->ctl_urb
->transfer_buffer_length
= size
;
297 devinfo
->ctl_read
.bRequestType
= USB_DIR_IN
298 | USB_TYPE_CLASS
| USB_RECIP_INTERFACE
;
299 devinfo
->ctl_read
.bRequest
= 1;
301 usb_fill_control_urb(devinfo
->ctl_urb
,
303 devinfo
->ctl_in_pipe
,
304 (unsigned char *) &devinfo
->ctl_read
,
306 (usb_complete_t
)brcmf_usb_ctlread_complete
,
309 ret
= usb_submit_urb(devinfo
->ctl_urb
, GFP_ATOMIC
);
311 brcmf_err("usb_submit_urb failed %d\n", ret
);
316 static int brcmf_usb_tx_ctlpkt(struct device
*dev
, u8
*buf
, u32 len
)
320 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(dev
);
322 brcmf_dbg(USB
, "Enter\n");
323 if (devinfo
->bus_pub
.state
!= BRCMFMAC_USB_STATE_UP
)
326 if (test_and_set_bit(0, &devinfo
->ctl_op
))
329 devinfo
->ctl_completed
= false;
330 err
= brcmf_usb_send_ctl(devinfo
, buf
, len
);
332 brcmf_err("fail %d bytes: %d\n", err
, len
);
333 clear_bit(0, &devinfo
->ctl_op
);
336 timeout
= brcmf_usb_ioctl_resp_wait(devinfo
);
337 clear_bit(0, &devinfo
->ctl_op
);
339 brcmf_err("Txctl wait timed out\n");
345 static int brcmf_usb_rx_ctlpkt(struct device
*dev
, u8
*buf
, u32 len
)
349 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(dev
);
351 brcmf_dbg(USB
, "Enter\n");
352 if (devinfo
->bus_pub
.state
!= BRCMFMAC_USB_STATE_UP
)
355 if (test_and_set_bit(0, &devinfo
->ctl_op
))
358 devinfo
->ctl_completed
= false;
359 err
= brcmf_usb_recv_ctl(devinfo
, buf
, len
);
361 brcmf_err("fail %d bytes: %d\n", err
, len
);
362 clear_bit(0, &devinfo
->ctl_op
);
365 timeout
= brcmf_usb_ioctl_resp_wait(devinfo
);
366 err
= devinfo
->ctl_urb_status
;
367 clear_bit(0, &devinfo
->ctl_op
);
369 brcmf_err("rxctl wait timed out\n");
373 return devinfo
->ctl_urb_actual_length
;
378 static struct brcmf_usbreq
*brcmf_usb_deq(struct brcmf_usbdev_info
*devinfo
,
379 struct list_head
*q
, int *counter
)
382 struct brcmf_usbreq
*req
;
383 spin_lock_irqsave(&devinfo
->qlock
, flags
);
385 spin_unlock_irqrestore(&devinfo
->qlock
, flags
);
388 req
= list_entry(q
->next
, struct brcmf_usbreq
, list
);
389 list_del_init(q
->next
);
392 spin_unlock_irqrestore(&devinfo
->qlock
, flags
);
397 static void brcmf_usb_enq(struct brcmf_usbdev_info
*devinfo
,
398 struct list_head
*q
, struct brcmf_usbreq
*req
,
402 spin_lock_irqsave(&devinfo
->qlock
, flags
);
403 list_add_tail(&req
->list
, q
);
406 spin_unlock_irqrestore(&devinfo
->qlock
, flags
);
409 static struct brcmf_usbreq
*
410 brcmf_usbdev_qinit(struct list_head
*q
, int qsize
)
413 struct brcmf_usbreq
*req
, *reqs
;
415 reqs
= kcalloc(qsize
, sizeof(struct brcmf_usbreq
), GFP_ATOMIC
);
421 for (i
= 0; i
< qsize
; i
++) {
422 req
->urb
= usb_alloc_urb(0, GFP_ATOMIC
);
426 INIT_LIST_HEAD(&req
->list
);
427 list_add_tail(&req
->list
, q
);
432 brcmf_err("fail!\n");
433 while (!list_empty(q
)) {
434 req
= list_entry(q
->next
, struct brcmf_usbreq
, list
);
436 usb_free_urb(req
->urb
);
443 static void brcmf_usb_free_q(struct list_head
*q
, bool pending
)
445 struct brcmf_usbreq
*req
, *next
;
447 list_for_each_entry_safe(req
, next
, q
, list
) {
449 brcmf_err("bad req\n");
454 usb_kill_urb(req
->urb
);
456 usb_free_urb(req
->urb
);
457 list_del_init(&req
->list
);
462 static void brcmf_usb_del_fromq(struct brcmf_usbdev_info
*devinfo
,
463 struct brcmf_usbreq
*req
)
467 spin_lock_irqsave(&devinfo
->qlock
, flags
);
468 list_del_init(&req
->list
);
469 spin_unlock_irqrestore(&devinfo
->qlock
, flags
);
473 static void brcmf_usb_tx_complete(struct urb
*urb
)
475 struct brcmf_usbreq
*req
= (struct brcmf_usbreq
*)urb
->context
;
476 struct brcmf_usbdev_info
*devinfo
= req
->devinfo
;
479 brcmf_dbg(USB
, "Enter, urb->status=%d, skb=%p\n", urb
->status
,
481 brcmf_usb_del_fromq(devinfo
, req
);
483 brcmf_txcomplete(devinfo
->dev
, req
->skb
, urb
->status
== 0);
485 brcmf_usb_enq(devinfo
, &devinfo
->tx_freeq
, req
, &devinfo
->tx_freecount
);
486 spin_lock_irqsave(&devinfo
->tx_flowblock_lock
, flags
);
487 if (devinfo
->tx_freecount
> devinfo
->tx_high_watermark
&&
488 devinfo
->tx_flowblock
) {
489 brcmf_txflowblock(devinfo
->dev
, false);
490 devinfo
->tx_flowblock
= false;
492 spin_unlock_irqrestore(&devinfo
->tx_flowblock_lock
, flags
);
495 static void brcmf_usb_rx_complete(struct urb
*urb
)
497 struct brcmf_usbreq
*req
= (struct brcmf_usbreq
*)urb
->context
;
498 struct brcmf_usbdev_info
*devinfo
= req
->devinfo
;
501 brcmf_dbg(USB
, "Enter, urb->status=%d\n", urb
->status
);
502 brcmf_usb_del_fromq(devinfo
, req
);
506 /* zero lenght packets indicate usb "failure". Do not refill */
507 if (urb
->status
!= 0 || !urb
->actual_length
) {
508 brcmu_pkt_buf_free_skb(skb
);
509 brcmf_usb_enq(devinfo
, &devinfo
->rx_freeq
, req
, NULL
);
513 if (devinfo
->bus_pub
.state
== BRCMFMAC_USB_STATE_UP
) {
514 skb_put(skb
, urb
->actual_length
);
515 brcmf_rx_frame(devinfo
->dev
, skb
);
516 brcmf_usb_rx_refill(devinfo
, req
);
518 brcmu_pkt_buf_free_skb(skb
);
519 brcmf_usb_enq(devinfo
, &devinfo
->rx_freeq
, req
, NULL
);
525 static void brcmf_usb_rx_refill(struct brcmf_usbdev_info
*devinfo
,
526 struct brcmf_usbreq
*req
)
531 if (!req
|| !devinfo
)
534 skb
= dev_alloc_skb(devinfo
->bus_pub
.bus_mtu
);
536 brcmf_usb_enq(devinfo
, &devinfo
->rx_freeq
, req
, NULL
);
541 usb_fill_bulk_urb(req
->urb
, devinfo
->usbdev
, devinfo
->rx_pipe
,
542 skb
->data
, skb_tailroom(skb
), brcmf_usb_rx_complete
,
544 req
->devinfo
= devinfo
;
545 brcmf_usb_enq(devinfo
, &devinfo
->rx_postq
, req
, NULL
);
547 ret
= usb_submit_urb(req
->urb
, GFP_ATOMIC
);
549 brcmf_usb_del_fromq(devinfo
, req
);
550 brcmu_pkt_buf_free_skb(req
->skb
);
552 brcmf_usb_enq(devinfo
, &devinfo
->rx_freeq
, req
, NULL
);
557 static void brcmf_usb_rx_fill_all(struct brcmf_usbdev_info
*devinfo
)
559 struct brcmf_usbreq
*req
;
561 if (devinfo
->bus_pub
.state
!= BRCMFMAC_USB_STATE_UP
) {
562 brcmf_err("bus is not up=%d\n", devinfo
->bus_pub
.state
);
565 while ((req
= brcmf_usb_deq(devinfo
, &devinfo
->rx_freeq
, NULL
)) != NULL
)
566 brcmf_usb_rx_refill(devinfo
, req
);
570 brcmf_usb_state_change(struct brcmf_usbdev_info
*devinfo
, int state
)
572 struct brcmf_bus
*bcmf_bus
= devinfo
->bus_pub
.bus
;
575 brcmf_dbg(USB
, "Enter, current state=%d, new state=%d\n",
576 devinfo
->bus_pub
.state
, state
);
578 if (devinfo
->bus_pub
.state
== state
)
581 old_state
= devinfo
->bus_pub
.state
;
582 devinfo
->bus_pub
.state
= state
;
584 /* update state of upper layer */
585 if (state
== BRCMFMAC_USB_STATE_DOWN
) {
586 brcmf_dbg(USB
, "DBUS is down\n");
587 brcmf_bus_change_state(bcmf_bus
, BRCMF_BUS_DOWN
);
588 } else if (state
== BRCMFMAC_USB_STATE_UP
) {
589 brcmf_dbg(USB
, "DBUS is up\n");
590 brcmf_bus_change_state(bcmf_bus
, BRCMF_BUS_UP
);
592 brcmf_dbg(USB
, "DBUS current state=%d\n", state
);
596 static int brcmf_usb_tx(struct device
*dev
, struct sk_buff
*skb
)
598 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(dev
);
599 struct brcmf_usbreq
*req
;
603 brcmf_dbg(USB
, "Enter, skb=%p\n", skb
);
604 if (devinfo
->bus_pub
.state
!= BRCMFMAC_USB_STATE_UP
) {
609 req
= brcmf_usb_deq(devinfo
, &devinfo
->tx_freeq
,
610 &devinfo
->tx_freecount
);
612 brcmf_err("no req to send\n");
618 req
->devinfo
= devinfo
;
619 usb_fill_bulk_urb(req
->urb
, devinfo
->usbdev
, devinfo
->tx_pipe
,
620 skb
->data
, skb
->len
, brcmf_usb_tx_complete
, req
);
621 req
->urb
->transfer_flags
|= URB_ZERO_PACKET
;
622 brcmf_usb_enq(devinfo
, &devinfo
->tx_postq
, req
, NULL
);
623 ret
= usb_submit_urb(req
->urb
, GFP_ATOMIC
);
625 brcmf_err("brcmf_usb_tx usb_submit_urb FAILED\n");
626 brcmf_usb_del_fromq(devinfo
, req
);
628 brcmf_usb_enq(devinfo
, &devinfo
->tx_freeq
, req
,
629 &devinfo
->tx_freecount
);
633 spin_lock_irqsave(&devinfo
->tx_flowblock_lock
, flags
);
634 if (devinfo
->tx_freecount
< devinfo
->tx_low_watermark
&&
635 !devinfo
->tx_flowblock
) {
636 brcmf_txflowblock(dev
, true);
637 devinfo
->tx_flowblock
= true;
639 spin_unlock_irqrestore(&devinfo
->tx_flowblock_lock
, flags
);
647 static int brcmf_usb_up(struct device
*dev
)
649 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(dev
);
651 brcmf_dbg(USB
, "Enter\n");
652 if (devinfo
->bus_pub
.state
== BRCMFMAC_USB_STATE_UP
)
655 /* Success, indicate devinfo is fully up */
656 brcmf_usb_state_change(devinfo
, BRCMFMAC_USB_STATE_UP
);
658 if (devinfo
->ctl_urb
) {
659 devinfo
->ctl_in_pipe
= usb_rcvctrlpipe(devinfo
->usbdev
, 0);
660 devinfo
->ctl_out_pipe
= usb_sndctrlpipe(devinfo
->usbdev
, 0);
663 devinfo
->ctl_write
.bRequestType
=
664 USB_DIR_OUT
| USB_TYPE_CLASS
| USB_RECIP_INTERFACE
;
665 devinfo
->ctl_write
.bRequest
= 0;
666 devinfo
->ctl_write
.wValue
= cpu_to_le16(0);
667 devinfo
->ctl_write
.wIndex
= cpu_to_le16(devinfo
->ifnum
);
670 devinfo
->ctl_read
.bRequestType
=
671 USB_DIR_IN
| USB_TYPE_CLASS
| USB_RECIP_INTERFACE
;
672 devinfo
->ctl_read
.bRequest
= 1;
673 devinfo
->ctl_read
.wValue
= cpu_to_le16(0);
674 devinfo
->ctl_read
.wIndex
= cpu_to_le16(devinfo
->ifnum
);
676 brcmf_usb_rx_fill_all(devinfo
);
680 static void brcmf_cancel_all_urbs(struct brcmf_usbdev_info
*devinfo
)
682 if (devinfo
->ctl_urb
)
683 usb_kill_urb(devinfo
->ctl_urb
);
684 if (devinfo
->bulk_urb
)
685 usb_kill_urb(devinfo
->bulk_urb
);
686 brcmf_usb_free_q(&devinfo
->tx_postq
, true);
687 brcmf_usb_free_q(&devinfo
->rx_postq
, true);
690 static void brcmf_usb_down(struct device
*dev
)
692 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(dev
);
694 brcmf_dbg(USB
, "Enter\n");
698 if (devinfo
->bus_pub
.state
== BRCMFMAC_USB_STATE_DOWN
)
701 brcmf_usb_state_change(devinfo
, BRCMFMAC_USB_STATE_DOWN
);
703 brcmf_cancel_all_urbs(devinfo
);
707 brcmf_usb_sync_complete(struct urb
*urb
)
709 struct brcmf_usbdev_info
*devinfo
=
710 (struct brcmf_usbdev_info
*)urb
->context
;
712 devinfo
->ctl_completed
= true;
713 brcmf_usb_ioctl_resp_wake(devinfo
);
716 static int brcmf_usb_dl_cmd(struct brcmf_usbdev_info
*devinfo
, u8 cmd
,
717 void *buffer
, int buflen
)
723 if ((!devinfo
) || (devinfo
->ctl_urb
== NULL
))
726 tmpbuf
= kmalloc(buflen
, GFP_ATOMIC
);
731 devinfo
->ctl_urb
->transfer_buffer_length
= size
;
733 devinfo
->ctl_read
.wLength
= cpu_to_le16p(&size
);
734 devinfo
->ctl_read
.bRequestType
= USB_DIR_IN
| USB_TYPE_VENDOR
|
736 devinfo
->ctl_read
.bRequest
= cmd
;
738 usb_fill_control_urb(devinfo
->ctl_urb
,
740 usb_rcvctrlpipe(devinfo
->usbdev
, 0),
741 (unsigned char *) &devinfo
->ctl_read
,
742 (void *) tmpbuf
, size
,
743 (usb_complete_t
)brcmf_usb_sync_complete
, devinfo
);
745 devinfo
->ctl_completed
= false;
746 ret
= usb_submit_urb(devinfo
->ctl_urb
, GFP_ATOMIC
);
748 brcmf_err("usb_submit_urb failed %d\n", ret
);
752 if (!brcmf_usb_ioctl_resp_wait(devinfo
)) {
753 usb_kill_urb(devinfo
->ctl_urb
);
756 memcpy(buffer
, tmpbuf
, buflen
);
765 brcmf_usb_dlneeded(struct brcmf_usbdev_info
*devinfo
)
767 struct bootrom_id_le id
;
770 brcmf_dbg(USB
, "Enter\n");
775 /* Check if firmware downloaded already by querying runtime ID */
776 id
.chip
= cpu_to_le32(0xDEAD);
777 brcmf_usb_dl_cmd(devinfo
, DL_GETVER
, &id
, sizeof(id
));
779 chipid
= le32_to_cpu(id
.chip
);
780 chiprev
= le32_to_cpu(id
.chiprev
);
782 if ((chipid
& 0x4300) == 0x4300)
783 brcmf_dbg(USB
, "chip %x rev 0x%x\n", chipid
, chiprev
);
785 brcmf_dbg(USB
, "chip %d rev 0x%x\n", chipid
, chiprev
);
786 if (chipid
== BRCMF_POSTBOOT_ID
) {
787 brcmf_dbg(USB
, "firmware already downloaded\n");
788 brcmf_usb_dl_cmd(devinfo
, DL_RESETCFG
, &id
, sizeof(id
));
791 devinfo
->bus_pub
.devid
= chipid
;
792 devinfo
->bus_pub
.chiprev
= chiprev
;
798 brcmf_usb_resetcfg(struct brcmf_usbdev_info
*devinfo
)
800 struct bootrom_id_le id
;
804 brcmf_dbg(USB
, "Enter\n");
808 mdelay(BRCMF_USB_RESET_GETVER_SPINWAIT
);
810 id
.chip
= cpu_to_le32(0xDEAD); /* Get the ID */
811 err
= brcmf_usb_dl_cmd(devinfo
, DL_GETVER
, &id
, sizeof(id
));
812 if ((err
) && (err
!= -ETIMEDOUT
))
814 if (id
.chip
== cpu_to_le32(BRCMF_POSTBOOT_ID
))
816 } while (loop_cnt
< BRCMF_USB_RESET_GETVER_LOOP_CNT
);
818 if (id
.chip
== cpu_to_le32(BRCMF_POSTBOOT_ID
)) {
819 brcmf_dbg(USB
, "postboot chip 0x%x/rev 0x%x\n",
820 le32_to_cpu(id
.chip
), le32_to_cpu(id
.chiprev
));
822 brcmf_usb_dl_cmd(devinfo
, DL_RESETCFG
, &id
, sizeof(id
));
825 brcmf_err("Cannot talk to Dongle. Firmware is not UP, %d ms\n",
826 BRCMF_USB_RESET_GETVER_SPINWAIT
* loop_cnt
);
833 brcmf_usb_dl_send_bulk(struct brcmf_usbdev_info
*devinfo
, void *buffer
, int len
)
837 if ((devinfo
== NULL
) || (devinfo
->bulk_urb
== NULL
))
840 /* Prepare the URB */
841 usb_fill_bulk_urb(devinfo
->bulk_urb
, devinfo
->usbdev
,
842 devinfo
->tx_pipe
, buffer
, len
,
843 (usb_complete_t
)brcmf_usb_sync_complete
, devinfo
);
845 devinfo
->bulk_urb
->transfer_flags
|= URB_ZERO_PACKET
;
847 devinfo
->ctl_completed
= false;
848 ret
= usb_submit_urb(devinfo
->bulk_urb
, GFP_ATOMIC
);
850 brcmf_err("usb_submit_urb failed %d\n", ret
);
853 ret
= brcmf_usb_ioctl_resp_wait(devinfo
);
858 brcmf_usb_dl_writeimage(struct brcmf_usbdev_info
*devinfo
, u8
*fw
, int fwlen
)
860 unsigned int sendlen
, sent
, dllen
;
861 char *bulkchunk
= NULL
, *dlpos
;
862 struct rdl_state_le state
;
863 u32 rdlstate
, rdlbytes
;
866 brcmf_dbg(USB
, "Enter, fw %p, len %d\n", fw
, fwlen
);
868 bulkchunk
= kmalloc(TRX_RDL_CHUNK
, GFP_ATOMIC
);
869 if (bulkchunk
== NULL
) {
874 /* 1) Prepare USB boot loader for runtime image */
875 brcmf_usb_dl_cmd(devinfo
, DL_START
, &state
, sizeof(state
));
877 rdlstate
= le32_to_cpu(state
.state
);
878 rdlbytes
= le32_to_cpu(state
.bytes
);
880 /* 2) Check we are in the Waiting state */
881 if (rdlstate
!= DL_WAITING
) {
882 brcmf_err("Failed to DL_START\n");
890 /* Get chip id and rev */
891 while (rdlbytes
!= dllen
) {
892 /* Wait until the usb device reports it received all
893 * the bytes we sent */
894 if ((rdlbytes
== sent
) && (rdlbytes
!= dllen
)) {
895 if ((dllen
-sent
) < TRX_RDL_CHUNK
)
896 sendlen
= dllen
-sent
;
898 sendlen
= TRX_RDL_CHUNK
;
900 /* simply avoid having to send a ZLP by ensuring we
908 memcpy(bulkchunk
, dlpos
, sendlen
);
909 if (brcmf_usb_dl_send_bulk(devinfo
, bulkchunk
,
911 brcmf_err("send_bulk failed\n");
919 err
= brcmf_usb_dl_cmd(devinfo
, DL_GETSTATE
, &state
,
922 brcmf_err("DL_GETSTATE Failed\n");
926 rdlstate
= le32_to_cpu(state
.state
);
927 rdlbytes
= le32_to_cpu(state
.bytes
);
929 /* restart if an error is reported */
930 if (rdlstate
== DL_BAD_HDR
|| rdlstate
== DL_BAD_CRC
) {
931 brcmf_err("Bad Hdr or Bad CRC state %d\n",
940 brcmf_dbg(USB
, "Exit, err=%d\n", err
);
944 static int brcmf_usb_dlstart(struct brcmf_usbdev_info
*devinfo
, u8
*fw
, int len
)
948 brcmf_dbg(USB
, "Enter\n");
953 if (devinfo
->bus_pub
.devid
== 0xDEAD)
956 err
= brcmf_usb_dl_writeimage(devinfo
, fw
, len
);
958 devinfo
->bus_pub
.state
= BRCMFMAC_USB_STATE_DL_DONE
;
960 devinfo
->bus_pub
.state
= BRCMFMAC_USB_STATE_DL_FAIL
;
961 brcmf_dbg(USB
, "Exit, err=%d\n", err
);
966 static int brcmf_usb_dlrun(struct brcmf_usbdev_info
*devinfo
)
968 struct rdl_state_le state
;
970 brcmf_dbg(USB
, "Enter\n");
974 if (devinfo
->bus_pub
.devid
== 0xDEAD)
977 /* Check we are runnable */
979 brcmf_usb_dl_cmd(devinfo
, DL_GETSTATE
, &state
, sizeof(state
));
981 /* Start the image */
982 if (state
.state
== cpu_to_le32(DL_RUNNABLE
)) {
983 if (brcmf_usb_dl_cmd(devinfo
, DL_GO
, &state
, sizeof(state
)))
985 if (brcmf_usb_resetcfg(devinfo
))
987 /* The Dongle may go for re-enumeration. */
989 brcmf_err("Dongle not runnable\n");
992 brcmf_dbg(USB
, "Exit\n");
997 brcmf_usb_fw_download(struct brcmf_usbdev_info
*devinfo
)
1001 brcmf_dbg(USB
, "Enter\n");
1002 if (devinfo
== NULL
)
1005 if (!devinfo
->image
) {
1006 brcmf_err("No firmware!\n");
1010 err
= brcmf_usb_dlstart(devinfo
,
1011 (u8
*)devinfo
->image
, devinfo
->image_len
);
1013 err
= brcmf_usb_dlrun(devinfo
);
1018 static void brcmf_usb_detach(struct brcmf_usbdev_info
*devinfo
)
1020 brcmf_dbg(USB
, "Enter, devinfo %p\n", devinfo
);
1023 brcmf_usb_free_q(&devinfo
->rx_freeq
, false);
1024 brcmf_usb_free_q(&devinfo
->tx_freeq
, false);
1026 usb_free_urb(devinfo
->ctl_urb
);
1027 usb_free_urb(devinfo
->bulk_urb
);
1029 kfree(devinfo
->tx_reqs
);
1030 kfree(devinfo
->rx_reqs
);
1034 static int check_file(const u8
*headers
)
1036 struct trx_header_le
*trx
;
1037 int actual_len
= -1;
1039 brcmf_dbg(USB
, "Enter\n");
1040 /* Extract trx header */
1041 trx
= (struct trx_header_le
*) headers
;
1042 if (trx
->magic
!= cpu_to_le32(TRX_MAGIC
))
1045 headers
+= sizeof(struct trx_header_le
);
1047 if (le32_to_cpu(trx
->flag_version
) & TRX_UNCOMP_IMAGE
) {
1048 actual_len
= le32_to_cpu(trx
->offsets
[TRX_OFFSETS_DLFWLEN_IDX
]);
1049 return actual_len
+ sizeof(struct trx_header_le
);
1056 struct brcmf_usbdev
*brcmf_usb_attach(struct brcmf_usbdev_info
*devinfo
,
1059 brcmf_dbg(USB
, "Enter\n");
1061 devinfo
->bus_pub
.nrxq
= nrxq
;
1062 devinfo
->rx_low_watermark
= nrxq
/ 2;
1063 devinfo
->bus_pub
.devinfo
= devinfo
;
1064 devinfo
->bus_pub
.ntxq
= ntxq
;
1065 devinfo
->bus_pub
.state
= BRCMFMAC_USB_STATE_DOWN
;
1067 /* flow control when too many tx urbs posted */
1068 devinfo
->tx_low_watermark
= ntxq
/ 4;
1069 devinfo
->tx_high_watermark
= devinfo
->tx_low_watermark
* 3;
1070 devinfo
->bus_pub
.bus_mtu
= BRCMF_USB_MAX_PKT_SIZE
;
1072 /* Initialize other structure content */
1073 init_waitqueue_head(&devinfo
->ioctl_resp_wait
);
1075 /* Initialize the spinlocks */
1076 spin_lock_init(&devinfo
->qlock
);
1077 spin_lock_init(&devinfo
->tx_flowblock_lock
);
1079 INIT_LIST_HEAD(&devinfo
->rx_freeq
);
1080 INIT_LIST_HEAD(&devinfo
->rx_postq
);
1082 INIT_LIST_HEAD(&devinfo
->tx_freeq
);
1083 INIT_LIST_HEAD(&devinfo
->tx_postq
);
1085 devinfo
->tx_flowblock
= false;
1087 devinfo
->rx_reqs
= brcmf_usbdev_qinit(&devinfo
->rx_freeq
, nrxq
);
1088 if (!devinfo
->rx_reqs
)
1091 devinfo
->tx_reqs
= brcmf_usbdev_qinit(&devinfo
->tx_freeq
, ntxq
);
1092 if (!devinfo
->tx_reqs
)
1094 devinfo
->tx_freecount
= ntxq
;
1096 devinfo
->ctl_urb
= usb_alloc_urb(0, GFP_ATOMIC
);
1097 if (!devinfo
->ctl_urb
) {
1098 brcmf_err("usb_alloc_urb (ctl) failed\n");
1101 devinfo
->bulk_urb
= usb_alloc_urb(0, GFP_ATOMIC
);
1102 if (!devinfo
->bulk_urb
) {
1103 brcmf_err("usb_alloc_urb (bulk) failed\n");
1107 return &devinfo
->bus_pub
;
1110 brcmf_err("failed!\n");
1111 brcmf_usb_detach(devinfo
);
1115 static void brcmf_usb_wowl_config(struct device
*dev
, bool enabled
)
1117 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(dev
);
1119 brcmf_dbg(USB
, "Configuring WOWL, enabled=%d\n", enabled
);
1120 devinfo
->wowl_enabled
= enabled
;
1122 device_set_wakeup_enable(devinfo
->dev
, true);
1124 device_set_wakeup_enable(devinfo
->dev
, false);
1127 static const struct brcmf_bus_ops brcmf_usb_bus_ops
= {
1128 .txdata
= brcmf_usb_tx
,
1129 .stop
= brcmf_usb_down
,
1130 .txctl
= brcmf_usb_tx_ctlpkt
,
1131 .rxctl
= brcmf_usb_rx_ctlpkt
,
1132 .wowl_config
= brcmf_usb_wowl_config
,
1135 static int brcmf_usb_bus_setup(struct brcmf_usbdev_info
*devinfo
)
1139 /* Attach to the common driver interface */
1140 ret
= brcmf_attach(devinfo
->dev
);
1142 brcmf_err("brcmf_attach failed\n");
1146 ret
= brcmf_usb_up(devinfo
->dev
);
1150 ret
= brcmf_bus_start(devinfo
->dev
);
1156 brcmf_detach(devinfo
->dev
);
1160 static void brcmf_usb_probe_phase2(struct device
*dev
,
1161 const struct firmware
*fw
,
1162 void *nvram
, u32 nvlen
)
1164 struct brcmf_bus
*bus
= dev_get_drvdata(dev
);
1165 struct brcmf_usbdev_info
*devinfo
;
1168 brcmf_dbg(USB
, "Start fw downloading\n");
1170 devinfo
= bus
->bus_priv
.usb
->devinfo
;
1171 ret
= check_file(fw
->data
);
1173 brcmf_err("invalid firmware\n");
1174 release_firmware(fw
);
1178 devinfo
->image
= fw
->data
;
1179 devinfo
->image_len
= fw
->size
;
1181 ret
= brcmf_usb_fw_download(devinfo
);
1182 release_firmware(fw
);
1186 ret
= brcmf_usb_bus_setup(devinfo
);
1190 mutex_unlock(&devinfo
->dev_init_lock
);
1193 brcmf_dbg(TRACE
, "failed: dev=%s, err=%d\n", dev_name(dev
), ret
);
1194 mutex_unlock(&devinfo
->dev_init_lock
);
1195 device_release_driver(dev
);
1198 static int brcmf_usb_probe_cb(struct brcmf_usbdev_info
*devinfo
)
1200 struct brcmf_bus
*bus
= NULL
;
1201 struct brcmf_usbdev
*bus_pub
= NULL
;
1202 struct device
*dev
= devinfo
->dev
;
1205 brcmf_dbg(USB
, "Enter\n");
1206 bus_pub
= brcmf_usb_attach(devinfo
, BRCMF_USB_NRXQ
, BRCMF_USB_NTXQ
);
1210 bus
= kzalloc(sizeof(struct brcmf_bus
), GFP_ATOMIC
);
1218 bus
->bus_priv
.usb
= bus_pub
;
1219 dev_set_drvdata(dev
, bus
);
1220 bus
->ops
= &brcmf_usb_bus_ops
;
1221 bus
->proto_type
= BRCMF_PROTO_BCDC
;
1222 bus
->always_use_fws_queue
= true;
1224 bus
->wowl_supported
= true;
1227 if (!brcmf_usb_dlneeded(devinfo
)) {
1228 ret
= brcmf_usb_bus_setup(devinfo
);
1232 mutex_unlock(&devinfo
->dev_init_lock
);
1235 bus
->chip
= bus_pub
->devid
;
1236 bus
->chiprev
= bus_pub
->chiprev
;
1238 ret
= brcmf_fw_map_chip_to_name(bus_pub
->devid
, bus_pub
->chiprev
,
1240 ARRAY_SIZE(brcmf_usb_fwnames
),
1241 devinfo
->fw_name
, NULL
);
1245 /* request firmware here */
1246 ret
= brcmf_fw_get_firmwares(dev
, 0, devinfo
->fw_name
, NULL
,
1247 brcmf_usb_probe_phase2
);
1249 brcmf_err("firmware request failed: %d\n", ret
);
1256 /* Release resources in reverse order */
1258 brcmf_usb_detach(devinfo
);
1263 brcmf_usb_disconnect_cb(struct brcmf_usbdev_info
*devinfo
)
1267 brcmf_dbg(USB
, "Enter, bus_pub %p\n", devinfo
);
1269 brcmf_detach(devinfo
->dev
);
1270 kfree(devinfo
->bus_pub
.bus
);
1271 brcmf_usb_detach(devinfo
);
1275 brcmf_usb_probe(struct usb_interface
*intf
, const struct usb_device_id
*id
)
1277 struct usb_device
*usb
= interface_to_usbdev(intf
);
1278 struct brcmf_usbdev_info
*devinfo
;
1279 struct usb_interface_descriptor
*desc
;
1280 struct usb_endpoint_descriptor
*endpoint
;
1283 u8 endpoint_num
, ep
;
1285 brcmf_dbg(USB
, "Enter 0x%04x:0x%04x\n", id
->idVendor
, id
->idProduct
);
1287 devinfo
= kzalloc(sizeof(*devinfo
), GFP_ATOMIC
);
1288 if (devinfo
== NULL
)
1291 devinfo
->usbdev
= usb
;
1292 devinfo
->dev
= &usb
->dev
;
1293 /* Take an init lock, to protect for disconnect while still loading.
1294 * Necessary because of the asynchronous firmware load construction
1296 mutex_init(&devinfo
->dev_init_lock
);
1297 mutex_lock(&devinfo
->dev_init_lock
);
1299 usb_set_intfdata(intf
, devinfo
);
1301 /* Check that the device supports only one configuration */
1302 if (usb
->descriptor
.bNumConfigurations
!= 1) {
1303 brcmf_err("Number of configurations: %d not supported\n",
1304 usb
->descriptor
.bNumConfigurations
);
1309 if ((usb
->descriptor
.bDeviceClass
!= USB_CLASS_VENDOR_SPEC
) &&
1310 (usb
->descriptor
.bDeviceClass
!= USB_CLASS_MISC
) &&
1311 (usb
->descriptor
.bDeviceClass
!= USB_CLASS_WIRELESS_CONTROLLER
)) {
1312 brcmf_err("Device class: 0x%x not supported\n",
1313 usb
->descriptor
.bDeviceClass
);
1318 desc
= &intf
->altsetting
[0].desc
;
1319 if ((desc
->bInterfaceClass
!= USB_CLASS_VENDOR_SPEC
) ||
1320 (desc
->bInterfaceSubClass
!= 2) ||
1321 (desc
->bInterfaceProtocol
!= 0xff)) {
1322 brcmf_err("non WLAN interface %d: 0x%x:0x%x:0x%x\n",
1323 desc
->bInterfaceNumber
, desc
->bInterfaceClass
,
1324 desc
->bInterfaceSubClass
, desc
->bInterfaceProtocol
);
1329 num_of_eps
= desc
->bNumEndpoints
;
1330 for (ep
= 0; ep
< num_of_eps
; ep
++) {
1331 endpoint
= &intf
->altsetting
[0].endpoint
[ep
].desc
;
1332 endpoint_num
= usb_endpoint_num(endpoint
);
1333 if (!usb_endpoint_xfer_bulk(endpoint
))
1335 if (usb_endpoint_dir_in(endpoint
)) {
1336 if (!devinfo
->rx_pipe
)
1338 usb_rcvbulkpipe(usb
, endpoint_num
);
1340 if (!devinfo
->tx_pipe
)
1342 usb_sndbulkpipe(usb
, endpoint_num
);
1345 if (devinfo
->rx_pipe
== 0) {
1346 brcmf_err("No RX (in) Bulk EP found\n");
1350 if (devinfo
->tx_pipe
== 0) {
1351 brcmf_err("No TX (out) Bulk EP found\n");
1356 devinfo
->ifnum
= desc
->bInterfaceNumber
;
1358 if (usb
->speed
== USB_SPEED_SUPER
)
1359 brcmf_dbg(USB
, "Broadcom super speed USB WLAN interface detected\n");
1360 else if (usb
->speed
== USB_SPEED_HIGH
)
1361 brcmf_dbg(USB
, "Broadcom high speed USB WLAN interface detected\n");
1363 brcmf_dbg(USB
, "Broadcom full speed USB WLAN interface detected\n");
1365 ret
= brcmf_usb_probe_cb(devinfo
);
1373 mutex_unlock(&devinfo
->dev_init_lock
);
1375 usb_set_intfdata(intf
, NULL
);
1380 brcmf_usb_disconnect(struct usb_interface
*intf
)
1382 struct brcmf_usbdev_info
*devinfo
;
1384 brcmf_dbg(USB
, "Enter\n");
1385 devinfo
= (struct brcmf_usbdev_info
*)usb_get_intfdata(intf
);
1388 mutex_lock(&devinfo
->dev_init_lock
);
1389 /* Make sure that devinfo still exists. Firmware probe routines
1390 * may have released the device and cleared the intfdata.
1392 if (!usb_get_intfdata(intf
))
1395 brcmf_usb_disconnect_cb(devinfo
);
1399 brcmf_dbg(USB
, "Exit\n");
1403 * only need to signal the bus being down and update the state.
1405 static int brcmf_usb_suspend(struct usb_interface
*intf
, pm_message_t state
)
1407 struct usb_device
*usb
= interface_to_usbdev(intf
);
1408 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(&usb
->dev
);
1410 brcmf_dbg(USB
, "Enter\n");
1411 devinfo
->bus_pub
.state
= BRCMFMAC_USB_STATE_SLEEP
;
1412 if (devinfo
->wowl_enabled
)
1413 brcmf_cancel_all_urbs(devinfo
);
1415 brcmf_detach(&usb
->dev
);
1420 * (re-) start the bus.
1422 static int brcmf_usb_resume(struct usb_interface
*intf
)
1424 struct usb_device
*usb
= interface_to_usbdev(intf
);
1425 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(&usb
->dev
);
1427 brcmf_dbg(USB
, "Enter\n");
1428 if (!devinfo
->wowl_enabled
)
1429 return brcmf_usb_bus_setup(devinfo
);
1431 devinfo
->bus_pub
.state
= BRCMFMAC_USB_STATE_UP
;
1432 brcmf_usb_rx_fill_all(devinfo
);
1436 static int brcmf_usb_reset_resume(struct usb_interface
*intf
)
1438 struct usb_device
*usb
= interface_to_usbdev(intf
);
1439 struct brcmf_usbdev_info
*devinfo
= brcmf_usb_get_businfo(&usb
->dev
);
1441 brcmf_dbg(USB
, "Enter\n");
1443 return brcmf_fw_get_firmwares(&usb
->dev
, 0, devinfo
->fw_name
, NULL
,
1444 brcmf_usb_probe_phase2
);
1447 #define BRCMF_USB_DEVICE(dev_id) \
1448 { USB_DEVICE(BRCM_USB_VENDOR_ID_BROADCOM, dev_id) }
1450 static struct usb_device_id brcmf_usb_devid_table
[] = {
1451 BRCMF_USB_DEVICE(BRCM_USB_43143_DEVICE_ID
),
1452 BRCMF_USB_DEVICE(BRCM_USB_43236_DEVICE_ID
),
1453 BRCMF_USB_DEVICE(BRCM_USB_43242_DEVICE_ID
),
1454 BRCMF_USB_DEVICE(BRCM_USB_43569_DEVICE_ID
),
1455 { USB_DEVICE(BRCM_USB_VENDOR_ID_LG
, BRCM_USB_43242_LG_DEVICE_ID
) },
1456 /* special entry for device with firmware loaded and running */
1457 BRCMF_USB_DEVICE(BRCM_USB_BCMFW_DEVICE_ID
),
1458 { /* end: all zeroes */ }
1461 MODULE_DEVICE_TABLE(usb
, brcmf_usb_devid_table
);
1463 static struct usb_driver brcmf_usbdrvr
= {
1464 .name
= KBUILD_MODNAME
,
1465 .probe
= brcmf_usb_probe
,
1466 .disconnect
= brcmf_usb_disconnect
,
1467 .id_table
= brcmf_usb_devid_table
,
1468 .suspend
= brcmf_usb_suspend
,
1469 .resume
= brcmf_usb_resume
,
1470 .reset_resume
= brcmf_usb_reset_resume
,
1471 .disable_hub_initiated_lpm
= 1,
1474 static int brcmf_usb_reset_device(struct device
*dev
, void *notused
)
1476 /* device past is the usb interface so we
1477 * need to use parent here.
1479 brcmf_dev_reset(dev
->parent
);
1483 void brcmf_usb_exit(void)
1485 struct device_driver
*drv
= &brcmf_usbdrvr
.drvwrap
.driver
;
1488 brcmf_dbg(USB
, "Enter\n");
1489 ret
= driver_for_each_device(drv
, NULL
, NULL
,
1490 brcmf_usb_reset_device
);
1491 usb_deregister(&brcmf_usbdrvr
);
1494 void brcmf_usb_register(void)
1496 brcmf_dbg(USB
, "Enter\n");
1497 usb_register(&brcmf_usbdrvr
);