xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8822be/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 	#include <usb_ops_linux.h>
40 #endif /* PLATFORM_LINUX */
41 
42 #ifdef CONFIG_RTL8188E
43 	void rtl8188eu_set_hw_type(struct dvobj_priv *pdvobj);
44 	#ifdef CONFIG_SUPPORT_USB_INT
45 		void interrupt_handler_8188eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
46 	#endif
47 #endif
48 
49 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
50 	void rtl8812au_set_hw_type(struct dvobj_priv *pdvobj);
51 	#ifdef CONFIG_SUPPORT_USB_INT
52 		void interrupt_handler_8812au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
53 	#endif
54 #endif
55 
56 #ifdef CONFIG_RTL8814A
57 	void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj);
58 	#ifdef CONFIG_SUPPORT_USB_INT
59 		void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
60 	#endif
61 #endif /* CONFIG_RTL8814 */
62 
63 #ifdef CONFIG_RTL8192E
64 	void rtl8192eu_set_hw_type(struct dvobj_priv *pdvobj);
65 	#ifdef CONFIG_SUPPORT_USB_INT
66 		void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
67 	#endif
68 
69 #endif
70 
71 #ifdef CONFIG_RTL8188F
72 	void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj);
73 	#ifdef CONFIG_SUPPORT_USB_INT
74 		void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
75 	#endif
76 #endif
77 
78 #ifdef CONFIG_RTL8723B
79 	void rtl8723bu_set_hw_type(struct dvobj_priv *pdvobj);
80 	#ifdef CONFIG_SUPPORT_USB_INT
81 		void interrupt_handler_8723bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
82 	#endif
83 #endif
84 
85 #ifdef CONFIG_RTL8703B
86 	void rtl8703bu_set_hw_type(struct dvobj_priv *pdvobj);
87 	#ifdef CONFIG_SUPPORT_USB_INT
88 		void interrupt_handler_8703bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
89 	#endif /* CONFIG_SUPPORT_USB_INT */
90 #endif /* CONFIG_RTL8703B */
91 
92 void usb_set_intf_ops(_adapter *padapter, struct _io_ops *pops);
93 
94 #ifdef CONFIG_RTL8723D
95 	void rtl8723du_set_hw_type(struct dvobj_priv *pdvobj);
96 	void rtl8723du_set_intf_ops(struct _io_ops *pops);
97 	void rtl8723du_recv_tasklet(void *priv);
98 	void rtl8723du_xmit_tasklet(void *priv);
99 	#ifdef CONFIG_SUPPORT_USB_INT
100 		void interrupt_handler_8723du(_adapter *padapter, u16 pkt_len, u8 *pbuf);
101 	#endif /* CONFIG_SUPPORT_USB_INT */
102 #endif /* CONFIG_RTL8723D */
103 
104 enum RTW_USB_SPEED {
105 	RTW_USB_SPEED_UNKNOWN	= 0,
106 	RTW_USB_SPEED_1_1	= 1,
107 	RTW_USB_SPEED_2		= 2,
108 	RTW_USB_SPEED_3		= 3,
109 };
110 
111 #define IS_FULL_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
112 #define IS_HIGH_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
113 #define IS_SUPER_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
114 
115 #define USB_SUPER_SPEED_BULK_SIZE	1024	/* usb 3.0 */
116 #define USB_HIGH_SPEED_BULK_SIZE	512		/* usb 2.0 */
117 #define USB_FULL_SPEED_BULK_SIZE	64		/* usb 1.1 */
118 
rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)119 static inline u8 rtw_usb_bulk_size_boundary(_adapter *padapter, int buf_len)
120 {
121 	u8 rst = _TRUE;
122 
123 	if (IS_SUPER_SPEED_USB(padapter))
124 		rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
125 	if (IS_HIGH_SPEED_USB(padapter))
126 		rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
127 	else
128 		rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
129 	return rst;
130 }
131 
132 
133 #endif /* __USB_OPS_H_ */
134