Linux 4.16.11
[linux/fpc-iii.git] / drivers / net / wireless / rsi / rsi_91x_usb.c
blob8f84438333482c8c51ee32648f7aa37be5f5dc06
1 /**
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 "rsi_usb.h"
20 #include "rsi_hal.h"
22 /**
23 * rsi_usb_card_write() - This function writes to the USB Card.
24 * @adapter: Pointer to the adapter structure.
25 * @buf: Pointer to the buffer from where the data has to be taken.
26 * @len: Length to be written.
27 * @endpoint: Type of endpoint.
29 * Return: status: 0 on success, a negative error code on failure.
31 static int rsi_usb_card_write(struct rsi_hw *adapter,
32 u8 *buf,
33 u16 len,
34 u8 endpoint)
36 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
37 int status;
38 u8 *seg = dev->tx_buffer;
39 int transfer;
40 int ep = dev->bulkout_endpoint_addr[endpoint - 1];
42 memset(seg, 0, len + RSI_USB_TX_HEAD_ROOM);
43 memcpy(seg + RSI_USB_TX_HEAD_ROOM, buf, len);
44 len += RSI_USB_TX_HEAD_ROOM;
45 transfer = len;
46 status = usb_bulk_msg(dev->usbdev,
47 usb_sndbulkpipe(dev->usbdev, ep),
48 (void *)seg,
49 (int)len,
50 &transfer,
51 HZ * 5);
53 if (status < 0) {
54 rsi_dbg(ERR_ZONE,
55 "Card write failed with error code :%10d\n", status);
56 dev->write_fail = 1;
58 return status;
61 /**
62 * rsi_write_multiple() - This function writes multiple bytes of information
63 * to the USB card.
64 * @adapter: Pointer to the adapter structure.
65 * @addr: Address of the register.
66 * @data: Pointer to the data that has to be written.
67 * @count: Number of multiple bytes to be written.
69 * Return: 0 on success, a negative error code on failure.
71 static int rsi_write_multiple(struct rsi_hw *adapter,
72 u8 endpoint,
73 u8 *data,
74 u32 count)
76 struct rsi_91x_usbdev *dev;
78 if (!adapter)
79 return -ENODEV;
81 if (endpoint == 0)
82 return -EINVAL;
84 dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
85 if (dev->write_fail)
86 return -ENETDOWN;
88 return rsi_usb_card_write(adapter, data, count, endpoint);
91 /**
92 * rsi_find_bulk_in_and_out_endpoints() - This function initializes the bulk
93 * endpoints to the device.
94 * @interface: Pointer to the USB interface structure.
95 * @adapter: Pointer to the adapter structure.
97 * Return: ret_val: 0 on success, -ENOMEM on failure.
99 static int rsi_find_bulk_in_and_out_endpoints(struct usb_interface *interface,
100 struct rsi_hw *adapter)
102 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
103 struct usb_host_interface *iface_desc;
104 struct usb_endpoint_descriptor *endpoint;
105 __le16 buffer_size;
106 int ii, bep_found = 0;
108 iface_desc = &(interface->altsetting[0]);
110 for (ii = 0; ii < iface_desc->desc.bNumEndpoints; ++ii) {
111 endpoint = &(iface_desc->endpoint[ii].desc);
113 if ((!(dev->bulkin_endpoint_addr)) &&
114 (endpoint->bEndpointAddress & USB_DIR_IN) &&
115 ((endpoint->bmAttributes &
116 USB_ENDPOINT_XFERTYPE_MASK) ==
117 USB_ENDPOINT_XFER_BULK)) {
118 buffer_size = endpoint->wMaxPacketSize;
119 dev->bulkin_size = buffer_size;
120 dev->bulkin_endpoint_addr =
121 endpoint->bEndpointAddress;
124 if (!dev->bulkout_endpoint_addr[bep_found] &&
125 !(endpoint->bEndpointAddress & USB_DIR_IN) &&
126 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
127 USB_ENDPOINT_XFER_BULK)) {
128 dev->bulkout_endpoint_addr[bep_found] =
129 endpoint->bEndpointAddress;
130 buffer_size = endpoint->wMaxPacketSize;
131 dev->bulkout_size[bep_found] = buffer_size;
132 bep_found++;
135 if (bep_found >= MAX_BULK_EP)
136 break;
139 if (!(dev->bulkin_endpoint_addr) &&
140 (dev->bulkout_endpoint_addr[0]))
141 return -EINVAL;
143 return 0;
146 #define RSI_USB_REQ_OUT (USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE)
147 #define RSI_USB_REQ_IN (USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE)
149 /* rsi_usb_reg_read() - This function reads data from given register address.
150 * @usbdev: Pointer to the usb_device structure.
151 * @reg: Address of the register to be read.
152 * @value: Value to be read.
153 * @len: length of data to be read.
155 * Return: status: 0 on success, a negative error code on failure.
157 static int rsi_usb_reg_read(struct usb_device *usbdev,
158 u32 reg,
159 u16 *value,
160 u16 len)
162 u8 *buf;
163 int status = -ENOMEM;
165 if (len > RSI_USB_CTRL_BUF_SIZE)
166 return -EINVAL;
168 buf = kmalloc(RSI_USB_CTRL_BUF_SIZE, GFP_KERNEL);
169 if (!buf)
170 return status;
172 status = usb_control_msg(usbdev,
173 usb_rcvctrlpipe(usbdev, 0),
174 USB_VENDOR_REGISTER_READ,
175 RSI_USB_REQ_IN,
176 ((reg & 0xffff0000) >> 16), (reg & 0xffff),
177 (void *)buf,
178 len,
179 USB_CTRL_GET_TIMEOUT);
181 *value = (buf[0] | (buf[1] << 8));
182 if (status < 0) {
183 rsi_dbg(ERR_ZONE,
184 "%s: Reg read failed with error code :%d\n",
185 __func__, status);
187 kfree(buf);
189 return status;
193 * rsi_usb_reg_write() - This function writes the given data into the given
194 * register address.
195 * @usbdev: Pointer to the usb_device structure.
196 * @reg: Address of the register.
197 * @value: Value to write.
198 * @len: Length of data to be written.
200 * Return: status: 0 on success, a negative error code on failure.
202 static int rsi_usb_reg_write(struct usb_device *usbdev,
203 u32 reg,
204 u16 value,
205 u16 len)
207 u8 *usb_reg_buf;
208 int status = -ENOMEM;
210 if (len > RSI_USB_CTRL_BUF_SIZE)
211 return -EINVAL;
213 usb_reg_buf = kmalloc(RSI_USB_CTRL_BUF_SIZE, GFP_KERNEL);
214 if (!usb_reg_buf)
215 return status;
217 usb_reg_buf[0] = (value & 0x00ff);
218 usb_reg_buf[1] = (value & 0xff00) >> 8;
219 usb_reg_buf[2] = 0x0;
220 usb_reg_buf[3] = 0x0;
222 status = usb_control_msg(usbdev,
223 usb_sndctrlpipe(usbdev, 0),
224 USB_VENDOR_REGISTER_WRITE,
225 RSI_USB_REQ_OUT,
226 ((reg & 0xffff0000) >> 16),
227 (reg & 0xffff),
228 (void *)usb_reg_buf,
229 len,
230 USB_CTRL_SET_TIMEOUT);
231 if (status < 0) {
232 rsi_dbg(ERR_ZONE,
233 "%s: Reg write failed with error code :%d\n",
234 __func__, status);
236 kfree(usb_reg_buf);
238 return status;
242 * rsi_rx_done_handler() - This function is called when a packet is received
243 * from USB stack. This is callback to recieve done.
244 * @urb: Received URB.
246 * Return: None.
248 static void rsi_rx_done_handler(struct urb *urb)
250 struct rsi_hw *adapter = urb->context;
251 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
253 if (urb->status)
254 return;
256 rsi_set_event(&dev->rx_thread.event);
260 * rsi_rx_urb_submit() - This function submits the given URB to the USB stack.
261 * @adapter: Pointer to the adapter structure.
263 * Return: 0 on success, a negative error code on failure.
265 static int rsi_rx_urb_submit(struct rsi_hw *adapter)
267 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
268 struct urb *urb = dev->rx_usb_urb[0];
269 int status;
271 usb_fill_bulk_urb(urb,
272 dev->usbdev,
273 usb_rcvbulkpipe(dev->usbdev,
274 dev->bulkin_endpoint_addr),
275 urb->transfer_buffer,
276 3000,
277 rsi_rx_done_handler,
278 adapter);
280 status = usb_submit_urb(urb, GFP_KERNEL);
281 if (status)
282 rsi_dbg(ERR_ZONE, "%s: Failed in urb submission\n", __func__);
284 return status;
287 static int rsi_usb_read_register_multiple(struct rsi_hw *adapter, u32 addr,
288 u8 *data, u16 count)
290 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
291 u8 *buf;
292 u16 transfer;
293 int status;
295 if (!addr)
296 return -EINVAL;
298 buf = kzalloc(RSI_USB_BUF_SIZE, GFP_KERNEL);
299 if (!buf)
300 return -ENOMEM;
302 while (count) {
303 transfer = min_t(u16, count, RSI_USB_BUF_SIZE);
304 status = usb_control_msg(dev->usbdev,
305 usb_rcvctrlpipe(dev->usbdev, 0),
306 USB_VENDOR_REGISTER_READ,
307 RSI_USB_REQ_IN,
308 ((addr & 0xffff0000) >> 16),
309 (addr & 0xffff), (void *)buf,
310 transfer, USB_CTRL_GET_TIMEOUT);
311 if (status < 0) {
312 rsi_dbg(ERR_ZONE,
313 "Reg read failed with error code :%d\n",
314 status);
315 kfree(buf);
316 return status;
318 memcpy(data, buf, transfer);
319 count -= transfer;
320 data += transfer;
321 addr += transfer;
323 kfree(buf);
324 return 0;
328 * rsi_usb_write_register_multiple() - This function writes multiple bytes of
329 * information to multiple registers.
330 * @adapter: Pointer to the adapter structure.
331 * @addr: Address of the register.
332 * @data: Pointer to the data that has to be written.
333 * @count: Number of multiple bytes to be written on to the registers.
335 * Return: status: 0 on success, a negative error code on failure.
337 static int rsi_usb_write_register_multiple(struct rsi_hw *adapter, u32 addr,
338 u8 *data, u16 count)
340 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
341 u8 *buf;
342 u16 transfer;
343 int status = 0;
345 buf = kzalloc(RSI_USB_BUF_SIZE, GFP_KERNEL);
346 if (!buf)
347 return -ENOMEM;
349 while (count) {
350 transfer = min_t(u16, count, RSI_USB_BUF_SIZE);
351 memcpy(buf, data, transfer);
352 status = usb_control_msg(dev->usbdev,
353 usb_sndctrlpipe(dev->usbdev, 0),
354 USB_VENDOR_REGISTER_WRITE,
355 RSI_USB_REQ_OUT,
356 ((addr & 0xffff0000) >> 16),
357 (addr & 0xffff),
358 (void *)buf,
359 transfer,
360 USB_CTRL_SET_TIMEOUT);
361 if (status < 0) {
362 rsi_dbg(ERR_ZONE,
363 "Reg write failed with error code :%d\n",
364 status);
365 kfree(buf);
366 return status;
368 count -= transfer;
369 data += transfer;
370 addr += transfer;
373 kfree(buf);
374 return 0;
378 *rsi_usb_host_intf_write_pkt() - This function writes the packet to the
379 * USB card.
380 * @adapter: Pointer to the adapter structure.
381 * @pkt: Pointer to the data to be written on to the card.
382 * @len: Length of the data to be written on to the card.
384 * Return: 0 on success, a negative error code on failure.
386 static int rsi_usb_host_intf_write_pkt(struct rsi_hw *adapter,
387 u8 *pkt,
388 u32 len)
390 u32 queueno = ((pkt[1] >> 4) & 0x7);
391 u8 endpoint;
393 endpoint = ((queueno == RSI_WIFI_MGMT_Q || queueno == RSI_WIFI_DATA_Q ||
394 queueno == RSI_COEX_Q) ? WLAN_EP : BT_EP);
396 return rsi_write_multiple(adapter,
397 endpoint,
398 (u8 *)pkt,
399 len);
402 static int rsi_usb_master_reg_read(struct rsi_hw *adapter, u32 reg,
403 u32 *value, u16 len)
405 struct usb_device *usbdev =
406 ((struct rsi_91x_usbdev *)adapter->rsi_dev)->usbdev;
407 u16 temp;
408 int ret;
410 ret = rsi_usb_reg_read(usbdev, reg, &temp, len);
411 if (ret < 0)
412 return ret;
413 *value = temp;
415 return 0;
418 static int rsi_usb_master_reg_write(struct rsi_hw *adapter,
419 unsigned long reg,
420 unsigned long value, u16 len)
422 struct usb_device *usbdev =
423 ((struct rsi_91x_usbdev *)adapter->rsi_dev)->usbdev;
425 return rsi_usb_reg_write(usbdev, reg, value, len);
428 static int rsi_usb_load_data_master_write(struct rsi_hw *adapter,
429 u32 base_address,
430 u32 instructions_sz, u16 block_size,
431 u8 *ta_firmware)
433 u16 num_blocks;
434 u32 cur_indx, i;
435 u8 temp_buf[256];
436 int status;
438 num_blocks = instructions_sz / block_size;
439 rsi_dbg(INFO_ZONE, "num_blocks: %d\n", num_blocks);
441 for (cur_indx = 0, i = 0; i < num_blocks; i++, cur_indx += block_size) {
442 memcpy(temp_buf, ta_firmware + cur_indx, block_size);
443 status = rsi_usb_write_register_multiple(adapter, base_address,
444 (u8 *)(temp_buf),
445 block_size);
446 if (status < 0)
447 return status;
449 rsi_dbg(INFO_ZONE, "%s: loading block: %d\n", __func__, i);
450 base_address += block_size;
453 if (instructions_sz % block_size) {
454 memset(temp_buf, 0, block_size);
455 memcpy(temp_buf, ta_firmware + cur_indx,
456 instructions_sz % block_size);
457 status = rsi_usb_write_register_multiple
458 (adapter, base_address,
459 (u8 *)temp_buf,
460 instructions_sz % block_size);
461 if (status < 0)
462 return status;
463 rsi_dbg(INFO_ZONE,
464 "Written Last Block in Address 0x%x Successfully\n",
465 cur_indx);
467 return 0;
470 static struct rsi_host_intf_ops usb_host_intf_ops = {
471 .write_pkt = rsi_usb_host_intf_write_pkt,
472 .read_reg_multiple = rsi_usb_read_register_multiple,
473 .write_reg_multiple = rsi_usb_write_register_multiple,
474 .master_reg_read = rsi_usb_master_reg_read,
475 .master_reg_write = rsi_usb_master_reg_write,
476 .load_data_master_write = rsi_usb_load_data_master_write,
480 * rsi_deinit_usb_interface() - This function deinitializes the usb interface.
481 * @adapter: Pointer to the adapter structure.
483 * Return: None.
485 static void rsi_deinit_usb_interface(struct rsi_hw *adapter)
487 struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
489 rsi_kill_thread(&dev->rx_thread);
490 usb_free_urb(dev->rx_usb_urb[0]);
491 kfree(adapter->priv->rx_data_pkt);
492 kfree(dev->tx_buffer);
496 * rsi_init_usb_interface() - This function initializes the usb interface.
497 * @adapter: Pointer to the adapter structure.
498 * @pfunction: Pointer to USB interface structure.
500 * Return: 0 on success, a negative error code on failure.
502 static int rsi_init_usb_interface(struct rsi_hw *adapter,
503 struct usb_interface *pfunction)
505 struct rsi_91x_usbdev *rsi_dev;
506 struct rsi_common *common = adapter->priv;
507 int status;
509 rsi_dev = kzalloc(sizeof(*rsi_dev), GFP_KERNEL);
510 if (!rsi_dev)
511 return -ENOMEM;
513 adapter->rsi_dev = rsi_dev;
514 rsi_dev->usbdev = interface_to_usbdev(pfunction);
516 if (rsi_find_bulk_in_and_out_endpoints(pfunction, adapter))
517 return -EINVAL;
519 adapter->device = &pfunction->dev;
520 usb_set_intfdata(pfunction, adapter);
522 common->rx_data_pkt = kmalloc(2048, GFP_KERNEL);
523 if (!common->rx_data_pkt) {
524 rsi_dbg(ERR_ZONE, "%s: Failed to allocate memory\n",
525 __func__);
526 return -ENOMEM;
529 rsi_dev->tx_buffer = kmalloc(2048, GFP_KERNEL);
530 if (!rsi_dev->tx_buffer) {
531 status = -ENOMEM;
532 goto fail_tx;
534 rsi_dev->rx_usb_urb[0] = usb_alloc_urb(0, GFP_KERNEL);
535 if (!rsi_dev->rx_usb_urb[0]) {
536 status = -ENOMEM;
537 goto fail_rx;
539 rsi_dev->rx_usb_urb[0]->transfer_buffer = adapter->priv->rx_data_pkt;
540 rsi_dev->tx_blk_size = 252;
541 adapter->block_size = rsi_dev->tx_blk_size;
543 /* Initializing function callbacks */
544 adapter->rx_urb_submit = rsi_rx_urb_submit;
545 adapter->check_hw_queue_status = rsi_usb_check_queue_status;
546 adapter->determine_event_timeout = rsi_usb_event_timeout;
547 adapter->rsi_host_intf = RSI_HOST_INTF_USB;
548 adapter->host_intf_ops = &usb_host_intf_ops;
550 rsi_init_event(&rsi_dev->rx_thread.event);
551 status = rsi_create_kthread(common, &rsi_dev->rx_thread,
552 rsi_usb_rx_thread, "RX-Thread");
553 if (status) {
554 rsi_dbg(ERR_ZONE, "%s: Unable to init rx thrd\n", __func__);
555 goto fail_thread;
558 #ifdef CONFIG_RSI_DEBUGFS
559 /* In USB, one less than the MAX_DEBUGFS_ENTRIES entries is required */
560 adapter->num_debugfs_entries = (MAX_DEBUGFS_ENTRIES - 1);
561 #endif
563 rsi_dbg(INIT_ZONE, "%s: Enabled the interface\n", __func__);
564 return 0;
566 fail_thread:
567 usb_free_urb(rsi_dev->rx_usb_urb[0]);
568 fail_rx:
569 kfree(rsi_dev->tx_buffer);
570 fail_tx:
571 kfree(common->rx_data_pkt);
572 return status;
575 static int usb_ulp_read_write(struct rsi_hw *adapter, u16 addr, u32 data,
576 u16 len_in_bits)
578 int ret;
580 ret = rsi_usb_master_reg_write
581 (adapter, RSI_GSPI_DATA_REG1,
582 ((addr << 6) | ((data >> 16) & 0xffff)), 2);
583 if (ret < 0)
584 return ret;
586 ret = rsi_usb_master_reg_write(adapter, RSI_GSPI_DATA_REG0,
587 (data & 0xffff), 2);
588 if (ret < 0)
589 return ret;
591 /* Initializing GSPI for ULP read/writes */
592 rsi_usb_master_reg_write(adapter, RSI_GSPI_CTRL_REG0,
593 RSI_GSPI_CTRL_REG0_VALUE, 2);
595 ret = rsi_usb_master_reg_write(adapter, RSI_GSPI_CTRL_REG1,
596 ((len_in_bits - 1) | RSI_GSPI_TRIG), 2);
597 if (ret < 0)
598 return ret;
600 msleep(20);
602 return 0;
605 static int rsi_reset_card(struct rsi_hw *adapter)
607 int ret;
609 rsi_dbg(INFO_ZONE, "Resetting Card...\n");
610 rsi_usb_master_reg_write(adapter, RSI_TA_HOLD_REG, 0xE, 4);
612 /* This msleep will ensure Thread-Arch processor to go to hold
613 * and any pending dma transfers to rf in device to finish.
615 msleep(100);
617 ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_1,
618 RSI_ULP_WRITE_2, 32);
619 if (ret < 0)
620 goto fail;
621 ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_2,
622 RSI_ULP_WRITE_0, 32);
623 if (ret < 0)
624 goto fail;
625 ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_DELAY_TIMER_1,
626 RSI_ULP_WRITE_50, 32);
627 if (ret < 0)
628 goto fail;
629 ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_DELAY_TIMER_2,
630 RSI_ULP_WRITE_0, 32);
631 if (ret < 0)
632 goto fail;
633 ret = usb_ulp_read_write(adapter, RSI_WATCH_DOG_TIMER_ENABLE,
634 RSI_ULP_TIMER_ENABLE, 32);
635 if (ret < 0)
636 goto fail;
638 rsi_dbg(INFO_ZONE, "Reset card done\n");
639 return ret;
641 fail:
642 rsi_dbg(ERR_ZONE, "Reset card failed\n");
643 return ret;
647 * rsi_probe() - This function is called by kernel when the driver provided
648 * Vendor and device IDs are matched. All the initialization
649 * work is done here.
650 * @pfunction: Pointer to the USB interface structure.
651 * @id: Pointer to the usb_device_id structure.
653 * Return: 0 on success, a negative error code on failure.
655 static int rsi_probe(struct usb_interface *pfunction,
656 const struct usb_device_id *id)
658 struct rsi_hw *adapter;
659 struct rsi_91x_usbdev *dev;
660 u16 fw_status;
661 int status;
663 rsi_dbg(INIT_ZONE, "%s: Init function called\n", __func__);
665 adapter = rsi_91x_init();
666 if (!adapter) {
667 rsi_dbg(ERR_ZONE, "%s: Failed to init os intf ops\n",
668 __func__);
669 return -ENOMEM;
671 adapter->rsi_host_intf = RSI_HOST_INTF_USB;
673 status = rsi_init_usb_interface(adapter, pfunction);
674 if (status) {
675 rsi_dbg(ERR_ZONE, "%s: Failed to init usb interface\n",
676 __func__);
677 goto err;
680 rsi_dbg(ERR_ZONE, "%s: Initialized os intf ops\n", __func__);
682 dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
684 status = rsi_usb_reg_read(dev->usbdev, FW_STATUS_REG, &fw_status, 2);
685 if (status < 0)
686 goto err1;
687 else
688 fw_status &= 1;
690 if (!fw_status) {
691 rsi_dbg(INIT_ZONE, "Loading firmware...\n");
692 status = rsi_hal_device_init(adapter);
693 if (status) {
694 rsi_dbg(ERR_ZONE, "%s: Failed in device init\n",
695 __func__);
696 goto err1;
698 rsi_dbg(INIT_ZONE, "%s: Device Init Done\n", __func__);
701 status = rsi_rx_urb_submit(adapter);
702 if (status)
703 goto err1;
705 return 0;
706 err1:
707 rsi_deinit_usb_interface(adapter);
708 err:
709 rsi_91x_deinit(adapter);
710 rsi_dbg(ERR_ZONE, "%s: Failed in probe...Exiting\n", __func__);
711 return status;
715 * rsi_disconnect() - This function performs the reverse of the probe function,
716 * it deinitialize the driver structure.
717 * @pfunction: Pointer to the USB interface structure.
719 * Return: None.
721 static void rsi_disconnect(struct usb_interface *pfunction)
723 struct rsi_hw *adapter = usb_get_intfdata(pfunction);
725 if (!adapter)
726 return;
728 rsi_mac80211_detach(adapter);
729 rsi_reset_card(adapter);
730 rsi_deinit_usb_interface(adapter);
731 rsi_91x_deinit(adapter);
733 rsi_dbg(INFO_ZONE, "%s: Deinitialization completed\n", __func__);
736 #ifdef CONFIG_PM
737 static int rsi_suspend(struct usb_interface *intf, pm_message_t message)
739 /* Not yet implemented */
740 return -ENOSYS;
743 static int rsi_resume(struct usb_interface *intf)
745 /* Not yet implemented */
746 return -ENOSYS;
748 #endif
750 static const struct usb_device_id rsi_dev_table[] = {
751 { USB_DEVICE(0x0303, 0x0100) },
752 { USB_DEVICE(0x041B, 0x0301) },
753 { USB_DEVICE(0x041B, 0x0201) },
754 { USB_DEVICE(0x041B, 0x9330) },
755 { USB_DEVICE(0x1618, 0x9113) },
756 { /* Blank */},
759 static struct usb_driver rsi_driver = {
760 .name = "RSI-USB WLAN",
761 .probe = rsi_probe,
762 .disconnect = rsi_disconnect,
763 .id_table = rsi_dev_table,
764 #ifdef CONFIG_PM
765 .suspend = rsi_suspend,
766 .resume = rsi_resume,
767 #endif
770 module_usb_driver(rsi_driver);
772 MODULE_AUTHOR("Redpine Signals Inc");
773 MODULE_DESCRIPTION("Common USB layer for RSI drivers");
774 MODULE_SUPPORTED_DEVICE("RSI-91x");
775 MODULE_DEVICE_TABLE(usb, rsi_dev_table);
776 MODULE_FIRMWARE(FIRMWARE_RSI9113);
777 MODULE_VERSION("0.1");
778 MODULE_LICENSE("Dual BSD/GPL");