2 * Copyright (c) 2014 Redpine Signals Inc.
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
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <linux/module.h>
19 #include <linux/types.h>
20 #include <net/rsi_91x.h>
25 /* Default operating mode is wlan STA + BT */
26 static u16 dev_oper_mode
= DEV_OPMODE_STA_BT_DUAL
;
27 module_param(dev_oper_mode
, ushort
, 0444);
28 MODULE_PARM_DESC(dev_oper_mode
, DEV_OPMODE_PARAM_DESC
);
30 static int rsi_rx_urb_submit(struct rsi_hw
*adapter
, u8 ep_num
, gfp_t flags
);
33 * rsi_usb_card_write() - This function writes to the USB Card.
34 * @adapter: Pointer to the adapter structure.
35 * @buf: Pointer to the buffer from where the data has to be taken.
36 * @len: Length to be written.
37 * @endpoint: Type of endpoint.
39 * Return: status: 0 on success, a negative error code on failure.
41 static int rsi_usb_card_write(struct rsi_hw
*adapter
,
46 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
48 u8
*seg
= dev
->tx_buffer
;
50 int ep
= dev
->bulkout_endpoint_addr
[endpoint
- 1];
52 memset(seg
, 0, len
+ RSI_USB_TX_HEAD_ROOM
);
53 memcpy(seg
+ RSI_USB_TX_HEAD_ROOM
, buf
, len
);
54 len
+= RSI_USB_TX_HEAD_ROOM
;
56 status
= usb_bulk_msg(dev
->usbdev
,
57 usb_sndbulkpipe(dev
->usbdev
, ep
),
61 USB_CTRL_SET_TIMEOUT
);
65 "Card write failed with error code :%10d\n", status
);
72 * rsi_write_multiple() - This function writes multiple bytes of information
74 * @adapter: Pointer to the adapter structure.
75 * @endpoint: Type of endpoint.
76 * @data: Pointer to the data that has to be written.
77 * @count: Number of multiple bytes to be written.
79 * Return: 0 on success, a negative error code on failure.
81 static int rsi_write_multiple(struct rsi_hw
*adapter
,
86 struct rsi_91x_usbdev
*dev
;
94 dev
= adapter
->rsi_dev
;
98 return rsi_usb_card_write(adapter
, data
, count
, endpoint
);
102 * rsi_find_bulk_in_and_out_endpoints() - This function initializes the bulk
103 * endpoints to the device.
104 * @interface: Pointer to the USB interface structure.
105 * @adapter: Pointer to the adapter structure.
107 * Return: ret_val: 0 on success, -ENOMEM on failure.
109 static int rsi_find_bulk_in_and_out_endpoints(struct usb_interface
*interface
,
110 struct rsi_hw
*adapter
)
112 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
113 struct usb_host_interface
*iface_desc
;
114 struct usb_endpoint_descriptor
*endpoint
;
116 int ii
, bin_found
= 0, bout_found
= 0;
118 iface_desc
= interface
->cur_altsetting
;
120 for (ii
= 0; ii
< iface_desc
->desc
.bNumEndpoints
; ++ii
) {
121 endpoint
= &(iface_desc
->endpoint
[ii
].desc
);
123 if (!dev
->bulkin_endpoint_addr
[bin_found
] &&
124 (endpoint
->bEndpointAddress
& USB_DIR_IN
) &&
125 ((endpoint
->bmAttributes
& USB_ENDPOINT_XFERTYPE_MASK
) ==
126 USB_ENDPOINT_XFER_BULK
)) {
127 buffer_size
= endpoint
->wMaxPacketSize
;
128 dev
->bulkin_size
[bin_found
] = buffer_size
;
129 dev
->bulkin_endpoint_addr
[bin_found
] =
130 endpoint
->bEndpointAddress
;
134 if (!dev
->bulkout_endpoint_addr
[bout_found
] &&
135 !(endpoint
->bEndpointAddress
& USB_DIR_IN
) &&
136 ((endpoint
->bmAttributes
& USB_ENDPOINT_XFERTYPE_MASK
) ==
137 USB_ENDPOINT_XFER_BULK
)) {
138 buffer_size
= endpoint
->wMaxPacketSize
;
139 dev
->bulkout_endpoint_addr
[bout_found
] =
140 endpoint
->bEndpointAddress
;
141 dev
->bulkout_size
[bout_found
] = buffer_size
;
145 if (bin_found
>= MAX_BULK_EP
|| bout_found
>= MAX_BULK_EP
)
149 if (!(dev
->bulkin_endpoint_addr
[0] && dev
->bulkout_endpoint_addr
[0])) {
150 dev_err(&interface
->dev
, "missing wlan bulk endpoints\n");
154 if (adapter
->priv
->coex_mode
> 1) {
155 if (!dev
->bulkin_endpoint_addr
[1]) {
156 dev_err(&interface
->dev
, "missing bt bulk-in endpoint\n");
164 #define RSI_USB_REQ_OUT (USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE)
165 #define RSI_USB_REQ_IN (USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE)
167 /* rsi_usb_reg_read() - This function reads data from given register address.
168 * @usbdev: Pointer to the usb_device structure.
169 * @reg: Address of the register to be read.
170 * @value: Value to be read.
171 * @len: length of data to be read.
173 * Return: status: 0 on success, a negative error code on failure.
175 static int rsi_usb_reg_read(struct usb_device
*usbdev
,
181 int status
= -ENOMEM
;
183 if (len
> RSI_USB_CTRL_BUF_SIZE
)
186 buf
= kmalloc(RSI_USB_CTRL_BUF_SIZE
, GFP_KERNEL
);
190 status
= usb_control_msg(usbdev
,
191 usb_rcvctrlpipe(usbdev
, 0),
192 USB_VENDOR_REGISTER_READ
,
194 ((reg
& 0xffff0000) >> 16), (reg
& 0xffff),
197 USB_CTRL_GET_TIMEOUT
);
199 *value
= (buf
[0] | (buf
[1] << 8));
202 "%s: Reg read failed with error code :%d\n",
211 * rsi_usb_reg_write() - This function writes the given data into the given
213 * @usbdev: Pointer to the usb_device structure.
214 * @reg: Address of the register.
215 * @value: Value to write.
216 * @len: Length of data to be written.
218 * Return: status: 0 on success, a negative error code on failure.
220 static int rsi_usb_reg_write(struct usb_device
*usbdev
,
226 int status
= -ENOMEM
;
228 if (len
> RSI_USB_CTRL_BUF_SIZE
)
231 usb_reg_buf
= kmalloc(RSI_USB_CTRL_BUF_SIZE
, GFP_KERNEL
);
235 usb_reg_buf
[0] = value
& 0x00ff;
236 usb_reg_buf
[1] = (value
& 0xff00) >> 8;
237 usb_reg_buf
[2] = (value
& 0x00ff0000) >> 16;
238 usb_reg_buf
[3] = (value
& 0xff000000) >> 24;
240 status
= usb_control_msg(usbdev
,
241 usb_sndctrlpipe(usbdev
, 0),
242 USB_VENDOR_REGISTER_WRITE
,
244 (reg
& 0xffff0000) >> 16,
248 USB_CTRL_SET_TIMEOUT
);
251 "%s: Reg write failed with error code :%d\n",
260 * rsi_rx_done_handler() - This function is called when a packet is received
261 * from USB stack. This is callback to receive done.
262 * @urb: Received URB.
266 static void rsi_rx_done_handler(struct urb
*urb
)
268 struct rx_usb_ctrl_block
*rx_cb
= urb
->context
;
269 struct rsi_91x_usbdev
*dev
= (struct rsi_91x_usbdev
*)rx_cb
->data
;
270 int status
= -EINVAL
;
276 dev_kfree_skb(rx_cb
->rx_skb
);
277 rx_cb
->rx_skb
= NULL
;
281 if (urb
->actual_length
<= 0 ||
282 urb
->actual_length
> rx_cb
->rx_skb
->len
) {
283 rsi_dbg(INFO_ZONE
, "%s: Invalid packet length = %d\n",
284 __func__
, urb
->actual_length
);
287 if (skb_queue_len(&dev
->rx_q
) >= RSI_MAX_RX_PKTS
) {
288 rsi_dbg(INFO_ZONE
, "Max RX packets reached\n");
291 skb_trim(rx_cb
->rx_skb
, urb
->actual_length
);
292 skb_queue_tail(&dev
->rx_q
, rx_cb
->rx_skb
);
294 rsi_set_event(&dev
->rx_thread
.event
);
298 if (rsi_rx_urb_submit(dev
->priv
, rx_cb
->ep_num
, GFP_ATOMIC
))
299 rsi_dbg(ERR_ZONE
, "%s: Failed in urb submission", __func__
);
302 dev_kfree_skb(rx_cb
->rx_skb
);
303 rx_cb
->rx_skb
= NULL
;
307 static void rsi_rx_urb_kill(struct rsi_hw
*adapter
, u8 ep_num
)
309 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
310 struct rx_usb_ctrl_block
*rx_cb
= &dev
->rx_cb
[ep_num
- 1];
311 struct urb
*urb
= rx_cb
->rx_urb
;
317 * rsi_rx_urb_submit() - This function submits the given URB to the USB stack.
318 * @adapter: Pointer to the adapter structure.
319 * @ep_num: Endpoint number.
320 * @mem_flags: The type of memory to allocate.
322 * Return: 0 on success, a negative error code on failure.
324 static int rsi_rx_urb_submit(struct rsi_hw
*adapter
, u8 ep_num
, gfp_t mem_flags
)
326 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
327 struct rx_usb_ctrl_block
*rx_cb
= &dev
->rx_cb
[ep_num
- 1];
328 struct urb
*urb
= rx_cb
->rx_urb
;
331 u8 dword_align_bytes
= 0;
333 skb
= dev_alloc_skb(RSI_MAX_RX_USB_PKT_SIZE
);
336 skb_reserve(skb
, MAX_DWORD_ALIGN_BYTES
);
337 skb_put(skb
, RSI_MAX_RX_USB_PKT_SIZE
- MAX_DWORD_ALIGN_BYTES
);
338 dword_align_bytes
= (unsigned long)skb
->data
& 0x3f;
339 if (dword_align_bytes
> 0)
340 skb_push(skb
, dword_align_bytes
);
341 urb
->transfer_buffer
= skb
->data
;
344 usb_fill_bulk_urb(urb
,
346 usb_rcvbulkpipe(dev
->usbdev
,
347 dev
->bulkin_endpoint_addr
[ep_num
- 1]),
348 urb
->transfer_buffer
,
353 status
= usb_submit_urb(urb
, mem_flags
);
355 rsi_dbg(ERR_ZONE
, "%s: Failed in urb submission\n", __func__
);
362 static int rsi_usb_read_register_multiple(struct rsi_hw
*adapter
, u32 addr
,
365 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
373 buf
= kzalloc(RSI_USB_BUF_SIZE
, GFP_KERNEL
);
378 transfer
= min_t(u16
, count
, RSI_USB_BUF_SIZE
);
379 status
= usb_control_msg(dev
->usbdev
,
380 usb_rcvctrlpipe(dev
->usbdev
, 0),
381 USB_VENDOR_REGISTER_READ
,
383 ((addr
& 0xffff0000) >> 16),
384 (addr
& 0xffff), (void *)buf
,
385 transfer
, USB_CTRL_GET_TIMEOUT
);
388 "Reg read failed with error code :%d\n",
393 memcpy(data
, buf
, transfer
);
403 * rsi_usb_write_register_multiple() - This function writes multiple bytes of
404 * information to multiple registers.
405 * @adapter: Pointer to the adapter structure.
406 * @addr: Address of the register.
407 * @data: Pointer to the data that has to be written.
408 * @count: Number of multiple bytes to be written on to the registers.
410 * Return: status: 0 on success, a negative error code on failure.
412 static int rsi_usb_write_register_multiple(struct rsi_hw
*adapter
, u32 addr
,
415 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
420 buf
= kzalloc(RSI_USB_BUF_SIZE
, GFP_KERNEL
);
425 transfer
= min_t(u16
, count
, RSI_USB_BUF_SIZE
);
426 memcpy(buf
, data
, transfer
);
427 status
= usb_control_msg(dev
->usbdev
,
428 usb_sndctrlpipe(dev
->usbdev
, 0),
429 USB_VENDOR_REGISTER_WRITE
,
431 ((addr
& 0xffff0000) >> 16),
435 USB_CTRL_SET_TIMEOUT
);
438 "Reg write failed with error code :%d\n",
453 *rsi_usb_host_intf_write_pkt() - This function writes the packet to the
455 * @adapter: Pointer to the adapter structure.
456 * @pkt: Pointer to the data to be written on to the card.
457 * @len: Length of the data to be written on to the card.
459 * Return: 0 on success, a negative error code on failure.
461 static int rsi_usb_host_intf_write_pkt(struct rsi_hw
*adapter
,
465 u32 queueno
= ((pkt
[1] >> 4) & 0x7);
468 endpoint
= ((queueno
== RSI_WIFI_MGMT_Q
|| queueno
== RSI_WIFI_DATA_Q
||
469 queueno
== RSI_COEX_Q
) ? WLAN_EP
: BT_EP
);
471 return rsi_write_multiple(adapter
,
477 static int rsi_usb_master_reg_read(struct rsi_hw
*adapter
, u32 reg
,
480 struct usb_device
*usbdev
=
481 ((struct rsi_91x_usbdev
*)adapter
->rsi_dev
)->usbdev
;
485 ret
= rsi_usb_reg_read(usbdev
, reg
, &temp
, len
);
493 static int rsi_usb_master_reg_write(struct rsi_hw
*adapter
,
495 unsigned long value
, u16 len
)
497 struct usb_device
*usbdev
=
498 ((struct rsi_91x_usbdev
*)adapter
->rsi_dev
)->usbdev
;
500 return rsi_usb_reg_write(usbdev
, reg
, value
, len
);
503 static int rsi_usb_load_data_master_write(struct rsi_hw
*adapter
,
505 u32 instructions_sz
, u16 block_size
,
513 num_blocks
= instructions_sz
/ block_size
;
514 rsi_dbg(INFO_ZONE
, "num_blocks: %d\n", num_blocks
);
516 for (cur_indx
= 0, i
= 0; i
< num_blocks
; i
++, cur_indx
+= block_size
) {
517 memcpy(temp_buf
, ta_firmware
+ cur_indx
, block_size
);
518 status
= rsi_usb_write_register_multiple(adapter
, base_address
,
524 rsi_dbg(INFO_ZONE
, "%s: loading block: %d\n", __func__
, i
);
525 base_address
+= block_size
;
528 if (instructions_sz
% block_size
) {
529 memset(temp_buf
, 0, block_size
);
530 memcpy(temp_buf
, ta_firmware
+ cur_indx
,
531 instructions_sz
% block_size
);
532 status
= rsi_usb_write_register_multiple
533 (adapter
, base_address
,
535 instructions_sz
% block_size
);
539 "Written Last Block in Address 0x%x Successfully\n",
545 static struct rsi_host_intf_ops usb_host_intf_ops
= {
546 .write_pkt
= rsi_usb_host_intf_write_pkt
,
547 .read_reg_multiple
= rsi_usb_read_register_multiple
,
548 .write_reg_multiple
= rsi_usb_write_register_multiple
,
549 .master_reg_read
= rsi_usb_master_reg_read
,
550 .master_reg_write
= rsi_usb_master_reg_write
,
551 .load_data_master_write
= rsi_usb_load_data_master_write
,
555 * rsi_deinit_usb_interface() - This function deinitializes the usb interface.
556 * @adapter: Pointer to the adapter structure.
560 static void rsi_deinit_usb_interface(struct rsi_hw
*adapter
)
562 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
564 rsi_kill_thread(&dev
->rx_thread
);
566 usb_free_urb(dev
->rx_cb
[0].rx_urb
);
567 if (adapter
->priv
->coex_mode
> 1)
568 usb_free_urb(dev
->rx_cb
[1].rx_urb
);
570 kfree(dev
->tx_buffer
);
573 static int rsi_usb_init_rx(struct rsi_hw
*adapter
)
575 struct rsi_91x_usbdev
*dev
= adapter
->rsi_dev
;
576 struct rx_usb_ctrl_block
*rx_cb
;
579 num_rx_cb
= (adapter
->priv
->coex_mode
> 1 ? 2 : 1);
581 for (idx
= 0; idx
< num_rx_cb
; idx
++) {
582 rx_cb
= &dev
->rx_cb
[idx
];
584 rx_cb
->rx_urb
= usb_alloc_urb(0, GFP_KERNEL
);
585 if (!rx_cb
->rx_urb
) {
586 rsi_dbg(ERR_ZONE
, "Failed alloc rx urb[%d]\n", idx
);
589 rx_cb
->ep_num
= idx
+ 1;
590 rx_cb
->data
= (void *)dev
;
592 skb_queue_head_init(&dev
->rx_q
);
593 rsi_init_event(&dev
->rx_thread
.event
);
594 if (rsi_create_kthread(adapter
->priv
, &dev
->rx_thread
,
595 rsi_usb_rx_thread
, "RX-Thread")) {
596 rsi_dbg(ERR_ZONE
, "%s: Unable to init rx thrd\n", __func__
);
603 usb_free_urb(dev
->rx_cb
[0].rx_urb
);
604 if (adapter
->priv
->coex_mode
> 1)
605 usb_free_urb(dev
->rx_cb
[1].rx_urb
);
611 * rsi_init_usb_interface() - This function initializes the usb interface.
612 * @adapter: Pointer to the adapter structure.
613 * @pfunction: Pointer to USB interface structure.
615 * Return: 0 on success, a negative error code on failure.
617 static int rsi_init_usb_interface(struct rsi_hw
*adapter
,
618 struct usb_interface
*pfunction
)
620 struct rsi_91x_usbdev
*rsi_dev
;
623 rsi_dev
= kzalloc(sizeof(*rsi_dev
), GFP_KERNEL
);
627 adapter
->rsi_dev
= rsi_dev
;
628 rsi_dev
->usbdev
= interface_to_usbdev(pfunction
);
629 rsi_dev
->priv
= (void *)adapter
;
631 if (rsi_find_bulk_in_and_out_endpoints(pfunction
, adapter
)) {
636 adapter
->device
= &pfunction
->dev
;
637 usb_set_intfdata(pfunction
, adapter
);
639 rsi_dev
->tx_buffer
= kmalloc(2048, GFP_KERNEL
);
640 if (!rsi_dev
->tx_buffer
) {
645 if (rsi_usb_init_rx(adapter
)) {
646 rsi_dbg(ERR_ZONE
, "Failed to init RX handle\n");
651 rsi_dev
->tx_blk_size
= 252;
652 adapter
->block_size
= rsi_dev
->tx_blk_size
;
654 /* Initializing function callbacks */
655 adapter
->check_hw_queue_status
= rsi_usb_check_queue_status
;
656 adapter
->determine_event_timeout
= rsi_usb_event_timeout
;
657 adapter
->rsi_host_intf
= RSI_HOST_INTF_USB
;
658 adapter
->host_intf_ops
= &usb_host_intf_ops
;
660 #ifdef CONFIG_RSI_DEBUGFS
661 /* In USB, one less than the MAX_DEBUGFS_ENTRIES entries is required */
662 adapter
->num_debugfs_entries
= (MAX_DEBUGFS_ENTRIES
- 1);
665 rsi_dbg(INIT_ZONE
, "%s: Enabled the interface\n", __func__
);
669 kfree(rsi_dev
->tx_buffer
);
676 static int usb_ulp_read_write(struct rsi_hw
*adapter
, u16 addr
, u32 data
,
681 ret
= rsi_usb_master_reg_write
682 (adapter
, RSI_GSPI_DATA_REG1
,
683 ((addr
<< 6) | ((data
>> 16) & 0xffff)), 2);
687 ret
= rsi_usb_master_reg_write(adapter
, RSI_GSPI_DATA_REG0
,
692 /* Initializing GSPI for ULP read/writes */
693 rsi_usb_master_reg_write(adapter
, RSI_GSPI_CTRL_REG0
,
694 RSI_GSPI_CTRL_REG0_VALUE
, 2);
696 ret
= rsi_usb_master_reg_write(adapter
, RSI_GSPI_CTRL_REG1
,
697 ((len_in_bits
- 1) | RSI_GSPI_TRIG
), 2);
706 static int rsi_reset_card(struct rsi_hw
*adapter
)
710 rsi_dbg(INFO_ZONE
, "Resetting Card...\n");
711 rsi_usb_master_reg_write(adapter
, RSI_TA_HOLD_REG
, 0xE, 4);
713 /* This msleep will ensure Thread-Arch processor to go to hold
714 * and any pending dma transfers to rf in device to finish.
718 ret
= rsi_usb_master_reg_write(adapter
, SWBL_REGOUT
,
719 RSI_FW_WDT_DISABLE_REQ
,
720 RSI_COMMON_REG_SIZE
);
722 rsi_dbg(ERR_ZONE
, "Disabling firmware watchdog timer failed\n");
726 if (adapter
->device_model
!= RSI_DEV_9116
) {
727 ret
= usb_ulp_read_write(adapter
, RSI_WATCH_DOG_TIMER_1
,
728 RSI_ULP_WRITE_2
, 32);
731 ret
= usb_ulp_read_write(adapter
, RSI_WATCH_DOG_TIMER_2
,
732 RSI_ULP_WRITE_0
, 32);
735 ret
= usb_ulp_read_write(adapter
, RSI_WATCH_DOG_DELAY_TIMER_1
,
736 RSI_ULP_WRITE_50
, 32);
739 ret
= usb_ulp_read_write(adapter
, RSI_WATCH_DOG_DELAY_TIMER_2
,
740 RSI_ULP_WRITE_0
, 32);
743 ret
= usb_ulp_read_write(adapter
, RSI_WATCH_DOG_TIMER_ENABLE
,
744 RSI_ULP_TIMER_ENABLE
, 32);
748 ret
= rsi_usb_master_reg_write(adapter
,
749 NWP_WWD_INTERRUPT_TIMER
,
750 NWP_WWD_INT_TIMER_CLKS
,
754 ret
= rsi_usb_master_reg_write(adapter
,
755 NWP_WWD_SYSTEM_RESET_TIMER
,
756 NWP_WWD_SYS_RESET_TIMER_CLKS
,
760 ret
= rsi_usb_master_reg_write(adapter
,
761 NWP_WWD_MODE_AND_RSTART
,
762 NWP_WWD_TIMER_DISABLE
,
768 rsi_dbg(INFO_ZONE
, "Reset card done\n");
772 rsi_dbg(ERR_ZONE
, "Reset card failed\n");
777 * rsi_probe() - This function is called by kernel when the driver provided
778 * Vendor and device IDs are matched. All the initialization
780 * @pfunction: Pointer to the USB interface structure.
781 * @id: Pointer to the usb_device_id structure.
783 * Return: 0 on success, a negative error code on failure.
785 static int rsi_probe(struct usb_interface
*pfunction
,
786 const struct usb_device_id
*id
)
788 struct rsi_hw
*adapter
;
789 struct rsi_91x_usbdev
*dev
;
793 rsi_dbg(INIT_ZONE
, "%s: Init function called\n", __func__
);
795 adapter
= rsi_91x_init(dev_oper_mode
);
797 rsi_dbg(ERR_ZONE
, "%s: Failed to init os intf ops\n",
801 adapter
->rsi_host_intf
= RSI_HOST_INTF_USB
;
803 status
= rsi_init_usb_interface(adapter
, pfunction
);
805 rsi_dbg(ERR_ZONE
, "%s: Failed to init usb interface\n",
810 rsi_dbg(ERR_ZONE
, "%s: Initialized os intf ops\n", __func__
);
812 if (id
->idProduct
== RSI_USB_PID_9113
) {
813 rsi_dbg(INIT_ZONE
, "%s: 9113 module detected\n", __func__
);
814 adapter
->device_model
= RSI_DEV_9113
;
815 } else if (id
->idProduct
== RSI_USB_PID_9116
) {
816 rsi_dbg(INIT_ZONE
, "%s: 9116 module detected\n", __func__
);
817 adapter
->device_model
= RSI_DEV_9116
;
819 rsi_dbg(ERR_ZONE
, "%s: Unsupported RSI device id 0x%x\n",
820 __func__
, id
->idProduct
);
825 dev
= adapter
->rsi_dev
;
827 status
= rsi_usb_reg_read(dev
->usbdev
, FW_STATUS_REG
, &fw_status
, 2);
834 rsi_dbg(INIT_ZONE
, "Loading firmware...\n");
835 status
= rsi_hal_device_init(adapter
);
837 rsi_dbg(ERR_ZONE
, "%s: Failed in device init\n",
841 rsi_dbg(INIT_ZONE
, "%s: Device Init Done\n", __func__
);
844 status
= rsi_rx_urb_submit(adapter
, WLAN_EP
, GFP_KERNEL
);
848 if (adapter
->priv
->coex_mode
> 1) {
849 status
= rsi_rx_urb_submit(adapter
, BT_EP
, GFP_KERNEL
);
851 goto err_kill_wlan_urb
;
857 rsi_rx_urb_kill(adapter
, WLAN_EP
);
859 rsi_deinit_usb_interface(adapter
);
861 rsi_91x_deinit(adapter
);
862 rsi_dbg(ERR_ZONE
, "%s: Failed in probe...Exiting\n", __func__
);
867 * rsi_disconnect() - This function performs the reverse of the probe function,
868 * it deinitialize the driver structure.
869 * @pfunction: Pointer to the USB interface structure.
873 static void rsi_disconnect(struct usb_interface
*pfunction
)
875 struct rsi_hw
*adapter
= usb_get_intfdata(pfunction
);
880 rsi_mac80211_detach(adapter
);
882 if (IS_ENABLED(CONFIG_RSI_COEX
) && adapter
->priv
->coex_mode
> 1 &&
883 adapter
->priv
->bt_adapter
) {
884 rsi_bt_ops
.detach(adapter
->priv
->bt_adapter
);
885 adapter
->priv
->bt_adapter
= NULL
;
888 if (adapter
->priv
->coex_mode
> 1)
889 rsi_rx_urb_kill(adapter
, BT_EP
);
890 rsi_rx_urb_kill(adapter
, WLAN_EP
);
892 rsi_reset_card(adapter
);
893 rsi_deinit_usb_interface(adapter
);
894 rsi_91x_deinit(adapter
);
896 rsi_dbg(INFO_ZONE
, "%s: Deinitialization completed\n", __func__
);
900 static int rsi_suspend(struct usb_interface
*intf
, pm_message_t message
)
902 /* Not yet implemented */
906 static int rsi_resume(struct usb_interface
*intf
)
908 /* Not yet implemented */
913 static const struct usb_device_id rsi_dev_table
[] = {
914 { USB_DEVICE(RSI_USB_VENDOR_ID
, RSI_USB_PID_9113
) },
915 { USB_DEVICE(RSI_USB_VENDOR_ID
, RSI_USB_PID_9116
) },
919 static struct usb_driver rsi_driver
= {
920 .name
= "RSI-USB WLAN",
922 .disconnect
= rsi_disconnect
,
923 .id_table
= rsi_dev_table
,
925 .suspend
= rsi_suspend
,
926 .resume
= rsi_resume
,
930 module_usb_driver(rsi_driver
);
932 MODULE_AUTHOR("Redpine Signals Inc");
933 MODULE_DESCRIPTION("Common USB layer for RSI drivers");
934 MODULE_DEVICE_TABLE(usb
, rsi_dev_table
);
935 MODULE_FIRMWARE(FIRMWARE_RSI9113
);
936 MODULE_VERSION("0.1");
937 MODULE_LICENSE("Dual BSD/GPL");