xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8189es/include/usb_ops.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 #define REALTEK_USB_IN_INT_EP_IDX	1
29 
30 enum{
31 	VENDOR_WRITE = 0x00,
32 	VENDOR_READ = 0x01,
33 };
34 #define ALIGNMENT_UNIT				16
35 #define MAX_VENDOR_REQ_CMD_SIZE	254		//8188cu SIE Support
36 #define MAX_USB_IO_CTL_SIZE		(MAX_VENDOR_REQ_CMD_SIZE +ALIGNMENT_UNIT)
37 
38 #ifdef PLATFORM_LINUX
39 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
40 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size, timeout_ms) \
41 	usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), (timeout_ms))
42 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
43 	usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), (timeout_ms))
44 #else
45 #define rtw_usb_control_msg(dev, pipe, request, requesttype, value, index, data, size,timeout_ms) \
46 	usb_control_msg((dev), (pipe), (request), (requesttype), (value), (index), (data), (size), \
47 		((timeout_ms) == 0) ||((timeout_ms)*HZ/1000>0)?((timeout_ms)*HZ/1000):1)
48 #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \
49 	usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \
50 		((timeout_ms) == 0) ||((timeout_ms)*HZ/1000>0)?((timeout_ms)*HZ/1000):1)
51 #endif
52 #include <usb_ops_linux.h>
53 #endif //PLATFORM_LINUX
54 
55 #ifdef CONFIG_RTL8188E
56 void rtl8188eu_set_hw_type(struct dvobj_priv *pdvobj);
57 void rtl8188eu_set_intf_ops(struct _io_ops *pops);
58 #ifdef CONFIG_SUPPORT_USB_INT
59 void interrupt_handler_8188eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
60 #endif
61 #endif
62 
63 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
64 void rtl8812au_set_hw_type(struct dvobj_priv *pdvobj);
65 void rtl8812au_set_intf_ops(struct _io_ops *pops);
66 #ifdef CONFIG_SUPPORT_USB_INT
67 void interrupt_handler_8812au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
68 #endif
69 #endif
70 
71 #ifdef CONFIG_RTL8814A
72 void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj);
73 void rtl8814au_set_intf_ops(struct _io_ops	*pops);
74 #ifdef CONFIG_SUPPORT_USB_INT
75 void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
76 #endif
77 #endif /* CONFIG_RTL8814 */
78 
79 #ifdef CONFIG_RTL8192E
80 void rtl8192eu_set_hw_type(struct dvobj_priv *pdvobj);
81 void rtl8192eu_set_intf_ops(struct _io_ops *pops);
82 #ifdef CONFIG_SUPPORT_USB_INT
83 void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
84 #endif
85 
86 #endif
87 
88 #ifdef CONFIG_RTL8188F
89 void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj);
90 void rtl8188fu_set_intf_ops(struct _io_ops *pops);
91 void rtl8188fu_recv_tasklet(void *priv);
92 void rtl8188fu_xmit_tasklet(void *priv);
93 #ifdef CONFIG_SUPPORT_USB_INT
94 void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
95 #endif
96 #endif
97 
98 #ifdef CONFIG_RTL8723B
99 void rtl8723bu_set_hw_type(struct dvobj_priv *pdvobj);
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 #ifdef CONFIG_SUPPORT_USB_INT
104 void interrupt_handler_8723bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
105 #endif
106 #endif
107 
108 
109 enum RTW_USB_SPEED {
110 	RTW_USB_SPEED_UNKNOWN	= 0,
111 	RTW_USB_SPEED_1_1	= 1,
112 	RTW_USB_SPEED_2		= 2,
113 	RTW_USB_SPEED_3		= 3,
114 };
115 
116 #define IS_FULL_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
117 #define IS_HIGH_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
118 #define IS_SUPER_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
119 
120 #define USB_SUPER_SPEED_BULK_SIZE	1024	// usb 3.0
121 #define USB_HIGH_SPEED_BULK_SIZE	512		// usb 2.0
122 #define USB_FULL_SPEED_BULK_SIZE	64		// usb 1.1
123 
rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)124 static inline u8 rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)
125 {
126 	u8 rst = _TRUE;
127 
128 	if (IS_SUPER_SPEED_USB(padapter))
129 		rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE)?_TRUE:_FALSE;
130 	if (IS_HIGH_SPEED_USB(padapter))
131 		rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE)?_TRUE:_FALSE;
132 	else
133 		rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE)?_TRUE:_FALSE;
134 	return rst;
135 }
136 
137 
138 #endif //__USB_OPS_H_
139 
140