5606891ec909eb0f3a99dc970630db97655120aa
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bs / include / usb_ops.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4  *                                        
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __USB_OPS_H_
21 #define __USB_OPS_H_
22
23
24 #define REALTEK_USB_VENQT_READ          0xC0
25 #define REALTEK_USB_VENQT_WRITE         0x40
26 #define REALTEK_USB_VENQT_CMD_REQ       0x05
27 #define REALTEK_USB_VENQT_CMD_IDX       0x00
28
29 enum{
30         VENDOR_WRITE = 0x00,
31         VENDOR_READ = 0x01,
32 };
33 #define ALIGNMENT_UNIT                          16
34 #define MAX_VENDOR_REQ_CMD_SIZE 254             //8188cu SIE Support
35 #define MAX_USB_IO_CTL_SIZE             (MAX_VENDOR_REQ_CMD_SIZE +ALIGNMENT_UNIT)
36
37 #ifdef PLATFORM_LINUX
38 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)) 
39 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
40         usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), (timeout_ms)) 
41 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
42         usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), (timeout_ms))
43 #else
44 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size,timeout_ms) \
45         usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), \
46                 ((timeout_ms) == 0) ||((timeout_ms)*HZ/1000>0)?((timeout_ms)*HZ/1000):1) 
47 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
48         usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \
49                 ((timeout_ms) == 0) ||((timeout_ms)*HZ/1000>0)?((timeout_ms)*HZ/1000):1) 
50 #endif
51 #include <usb_ops_linux.h>
52 #endif //PLATFORM_LINUX
53
54 #ifdef CONFIG_RTL8192C
55 void rtl8192cu_set_hw_type(_adapter *padapter);
56 void rtl8192cu_set_intf_ops(struct _io_ops *pops);
57 void rtl8192cu_recv_tasklet(void *priv);
58 void rtl8192cu_xmit_tasklet(void *priv);
59 #endif
60
61 #ifdef CONFIG_RTL8723A
62 void rtl8723au_set_hw_type(_adapter *padapter);
63 void rtl8723au_set_intf_ops(struct _io_ops *pops);
64 void rtl8192cu_recv_tasklet(void *priv);
65 void rtl8192cu_xmit_tasklet(void *priv);
66 #endif
67
68 #ifdef CONFIG_RTL8192D
69 void rtl8192du_set_hw_type(_adapter *padapter);
70 void rtl8192du_set_intf_ops(struct _io_ops *pops);
71 #ifndef PLATFORM_FREEBSD
72 void rtl8192du_recv_tasklet(void *priv);
73 #else   // PLATFORM_FREEBSD
74 void rtl8192du_recv_tasklet(void *priv, int npending);
75 #ifdef CONFIG_RX_INDICATE_QUEUE
76 void rtw_rx_indicate_tasklet(void *priv, int npending);
77 #endif  // CONFIG_RX_INDICATE_QUEUE
78 #endif  // PLATFORM_FREEBSD
79
80 void rtl8192du_xmit_tasklet(void *priv);
81 #endif
82
83 #ifdef CONFIG_RTL8188E
84 void rtl8188eu_set_hw_type(_adapter *padapter);
85 void rtl8188eu_set_intf_ops(struct _io_ops *pops);
86 #endif
87
88 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
89 void rtl8812au_set_hw_type(_adapter *padapter);
90 void rtl8812au_set_intf_ops(struct _io_ops *pops);
91 #endif
92
93 #ifdef CONFIG_RTL8192E
94 void rtl8192eu_set_hw_type(_adapter *padapter);
95 void rtl8192eu_set_intf_ops(struct _io_ops *pops);
96 #endif
97
98 #ifdef CONFIG_RTL8723B
99 void rtl8723bu_set_hw_type(_adapter *padapter);
100 void rtl8723bu_set_intf_ops(struct _io_ops *pops);
101 void rtl8723bu_recv_tasklet(void *priv);
102 void rtl8723bu_xmit_tasklet(void *priv);
103 #endif
104
105
106 enum RTW_USB_SPEED {
107         RTW_USB_SPEED_UNKNOWN   = 0,
108         RTW_USB_SPEED_1_1       = 1,
109         RTW_USB_SPEED_2         = 2,
110         RTW_USB_SPEED_3         = 3,
111 };
112
113 #define IS_FULL_SPEED_USB(Adapter)      (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
114 #define IS_HIGH_SPEED_USB(Adapter)      (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
115 #define IS_SUPER_SPEED_USB(Adapter)     (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
116
117 #define USB_SUPER_SPEED_BULK_SIZE       1024    // usb 3.0
118 #define USB_HIGH_SPEED_BULK_SIZE        512             // usb 2.0
119 #define USB_FULL_SPEED_BULK_SIZE        64              // usb 1.1
120
121 static inline u8 rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)
122 {
123         u8 rst = _TRUE;
124
125         if (IS_SUPER_SPEED_USB(padapter))
126                 rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE)?_TRUE:_FALSE;
127         if (IS_HIGH_SPEED_USB(padapter))
128                 rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE)?_TRUE:_FALSE; 
129         else    
130                 rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE)?_TRUE:_FALSE;         
131         return rst;
132 }
133
134
135 #endif //__USB_OPS_H_
136