1*4882a593Smuzhiyun /**
2*4882a593Smuzhiyun * @section LICENSE
3*4882a593Smuzhiyun * Copyright (c) 2014 Redpine Signals Inc.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Permission to use, copy, modify, and/or distribute this software for any
6*4882a593Smuzhiyun * purpose with or without fee is hereby granted, provided that the above
7*4882a593Smuzhiyun * copyright notice and this permission notice appear in all copies.
8*4882a593Smuzhiyun *
9*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*4882a593Smuzhiyun * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*4882a593Smuzhiyun * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*4882a593Smuzhiyun * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*4882a593Smuzhiyun * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*4882a593Smuzhiyun * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*4882a593Smuzhiyun * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*4882a593Smuzhiyun */
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun #ifndef __RSI_USB_INTF__
19*4882a593Smuzhiyun #define __RSI_USB_INTF__
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun #include <linux/usb.h>
22*4882a593Smuzhiyun #include "rsi_main.h"
23*4882a593Smuzhiyun #include "rsi_common.h"
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun #define RSI_USB_VENDOR_ID 0x1618
26*4882a593Smuzhiyun #define RSI_USB_PID_9113 0x9113
27*4882a593Smuzhiyun #define RSI_USB_PID_9116 0x9116
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun #define USB_INTERNAL_REG_1 0x25000
30*4882a593Smuzhiyun #define RSI_USB_READY_MAGIC_NUM 0xab
31*4882a593Smuzhiyun #define FW_STATUS_REG 0x41050012
32*4882a593Smuzhiyun #define RSI_TA_HOLD_REG 0x22000844
33*4882a593Smuzhiyun #define RSI_FW_WDT_DISABLE_REQ 0x69
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun #define USB_VENDOR_REGISTER_READ 0x15
36*4882a593Smuzhiyun #define USB_VENDOR_REGISTER_WRITE 0x16
37*4882a593Smuzhiyun #define RSI_USB_TX_HEAD_ROOM 128
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun #define MAX_RX_URBS 2
40*4882a593Smuzhiyun #define MAX_BULK_EP 8
41*4882a593Smuzhiyun #define WLAN_EP 1
42*4882a593Smuzhiyun #define BT_EP 2
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun #define RSI_USB_BUF_SIZE 4096
45*4882a593Smuzhiyun #define RSI_USB_CTRL_BUF_SIZE 0x04
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #define RSI_MAX_RX_USB_PKT_SIZE 3000
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun struct rx_usb_ctrl_block {
50*4882a593Smuzhiyun u8 *data;
51*4882a593Smuzhiyun struct urb *rx_urb;
52*4882a593Smuzhiyun struct sk_buff *rx_skb;
53*4882a593Smuzhiyun u8 ep_num;
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun struct rsi_91x_usbdev {
57*4882a593Smuzhiyun void *priv;
58*4882a593Smuzhiyun struct rsi_thread rx_thread;
59*4882a593Smuzhiyun u8 endpoint;
60*4882a593Smuzhiyun struct usb_device *usbdev;
61*4882a593Smuzhiyun struct usb_interface *pfunction;
62*4882a593Smuzhiyun struct rx_usb_ctrl_block rx_cb[MAX_RX_URBS];
63*4882a593Smuzhiyun u8 *tx_buffer;
64*4882a593Smuzhiyun __le16 bulkin_size[MAX_BULK_EP];
65*4882a593Smuzhiyun u8 bulkin_endpoint_addr[MAX_BULK_EP];
66*4882a593Smuzhiyun __le16 bulkout_size[MAX_BULK_EP];
67*4882a593Smuzhiyun u8 bulkout_endpoint_addr[MAX_BULK_EP];
68*4882a593Smuzhiyun u32 tx_blk_size;
69*4882a593Smuzhiyun u8 write_fail;
70*4882a593Smuzhiyun struct sk_buff_head rx_q;
71*4882a593Smuzhiyun };
72*4882a593Smuzhiyun
rsi_usb_check_queue_status(struct rsi_hw * adapter,u8 q_num)73*4882a593Smuzhiyun static inline int rsi_usb_check_queue_status(struct rsi_hw *adapter, u8 q_num)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun /* In USB, there isn't any need to check the queue status */
76*4882a593Smuzhiyun return QUEUE_NOT_FULL;
77*4882a593Smuzhiyun }
78*4882a593Smuzhiyun
rsi_usb_event_timeout(struct rsi_hw * adapter)79*4882a593Smuzhiyun static inline int rsi_usb_event_timeout(struct rsi_hw *adapter)
80*4882a593Smuzhiyun {
81*4882a593Smuzhiyun return EVENT_WAIT_FOREVER;
82*4882a593Smuzhiyun }
83*4882a593Smuzhiyun
84*4882a593Smuzhiyun void rsi_usb_rx_thread(struct rsi_common *common);
85*4882a593Smuzhiyun #endif
86