8723BU: Update 8723BU wifi driver to version v4.3.16_14189.20150519_BTCOEX2015119...
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bu / 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_RTL8188E
55 void rtl8188eu_set_hw_type(_adapter *padapter);
56 void rtl8188eu_set_intf_ops(struct _io_ops *pops);
57 #endif
58
59 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
60 void rtl8812au_set_hw_type(_adapter *padapter);
61 void rtl8812au_set_intf_ops(struct _io_ops *pops);
62 #endif
63
64 #ifdef CONFIG_RTL8814A
65 void rtl8814au_set_hw_type(_adapter *padapter);
66 void rtl8814au_set_intf_ops(struct _io_ops      *pops);
67 #endif /* CONFIG_RTL8814 */
68
69 #ifdef CONFIG_RTL8192E
70 void rtl8192eu_set_hw_type(_adapter *padapter);
71 void rtl8192eu_set_intf_ops(struct _io_ops *pops);
72 #endif
73
74 #ifdef CONFIG_RTL8723B
75 void rtl8723bu_set_hw_type(_adapter *padapter);
76 void rtl8723bu_set_intf_ops(struct _io_ops *pops);
77 void rtl8723bu_recv_tasklet(void *priv);
78 void rtl8723bu_xmit_tasklet(void *priv);
79 #endif
80
81
82 enum RTW_USB_SPEED {
83         RTW_USB_SPEED_UNKNOWN   = 0,
84         RTW_USB_SPEED_1_1       = 1,
85         RTW_USB_SPEED_2         = 2,
86         RTW_USB_SPEED_3         = 3,
87 };
88
89 #define IS_FULL_SPEED_USB(Adapter)      (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
90 #define IS_HIGH_SPEED_USB(Adapter)      (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
91 #define IS_SUPER_SPEED_USB(Adapter)     (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
92
93 #define USB_SUPER_SPEED_BULK_SIZE       1024    // usb 3.0
94 #define USB_HIGH_SPEED_BULK_SIZE        512             // usb 2.0
95 #define USB_FULL_SPEED_BULK_SIZE        64              // usb 1.1
96
97 static inline u8 rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)
98 {
99         u8 rst = _TRUE;
100
101         if (IS_SUPER_SPEED_USB(padapter))
102                 rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE)?_TRUE:_FALSE;
103         if (IS_HIGH_SPEED_USB(padapter))
104                 rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE)?_TRUE:_FALSE; 
105         else    
106                 rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE)?_TRUE:_FALSE;         
107         return rst;
108 }
109
110
111 #endif //__USB_OPS_H_
112