• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
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  *****************************************************************************/
15 #ifndef __USB_OPS_H_
16 #define __USB_OPS_H_
17 
18 
19 #define REALTEK_USB_VENQT_READ		0xC0
20 #define REALTEK_USB_VENQT_WRITE	0x40
21 #define REALTEK_USB_VENQT_CMD_REQ	0x05
22 #define REALTEK_USB_VENQT_CMD_IDX	0x00
23 #define REALTEK_USB_IN_INT_EP_IDX	1
24 
25 enum {
26 	VENDOR_WRITE = 0x00,
27 	VENDOR_READ = 0x01,
28 };
29 #define ALIGNMENT_UNIT				16
30 #define MAX_VENDOR_REQ_CMD_SIZE	254		/* 8188cu SIE Support */
31 #define MAX_USB_IO_CTL_SIZE		(MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
32 
33 #ifdef PLATFORM_LINUX
34 #include <usb_ops_linux.h>
35 #endif /* PLATFORM_LINUX */
36 
37 #ifdef CONFIG_RTL8188E
38 void rtl8188eu_set_hw_type(struct dvobj_priv *pdvobj);
39 #ifdef CONFIG_SUPPORT_USB_INT
40 void interrupt_handler_8188eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
41 #endif
42 #endif
43 
44 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
45 void rtl8812au_set_hw_type(struct dvobj_priv *pdvobj);
46 #ifdef CONFIG_SUPPORT_USB_INT
47 void interrupt_handler_8812au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
48 #endif
49 #endif
50 
51 #ifdef CONFIG_RTL8814A
52 void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj);
53 #ifdef CONFIG_SUPPORT_USB_INT
54 void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
55 #endif
56 #endif /* CONFIG_RTL8814 */
57 
58 #ifdef CONFIG_RTL8192E
59 void rtl8192eu_set_hw_type(struct dvobj_priv *pdvobj);
60 #ifdef CONFIG_SUPPORT_USB_INT
61 void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
62 #endif
63 
64 #endif
65 
66 #ifdef CONFIG_RTL8188F
67 void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj);
68 #ifdef CONFIG_SUPPORT_USB_INT
69 void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
70 #endif
71 #endif
72 
73 #ifdef CONFIG_RTL8188GTV
74 void rtl8188gtvu_set_hw_type(struct dvobj_priv *pdvobj);
75 #ifdef CONFIG_SUPPORT_USB_INT
76 void interrupt_handler_8188gtvu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
77 #endif
78 #endif
79 
80 #ifdef CONFIG_RTL8723B
81 void rtl8723bu_set_hw_type(struct dvobj_priv *pdvobj);
82 #ifdef CONFIG_SUPPORT_USB_INT
83 void interrupt_handler_8723bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
84 #endif
85 #endif
86 
87 #ifdef CONFIG_RTL8703B
88 void rtl8703bu_set_hw_type(struct dvobj_priv *pdvobj);
89 #ifdef CONFIG_SUPPORT_USB_INT
90 void interrupt_handler_8703bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
91 #endif /* CONFIG_SUPPORT_USB_INT */
92 #endif /* CONFIG_RTL8703B */
93 
94 void usb_set_intf_ops(_adapter *padapter, struct _io_ops *pops);
95 
96 #ifdef CONFIG_RTL8723D
97 void rtl8723du_set_hw_type(struct dvobj_priv *pdvobj);
98 void rtl8723du_set_intf_ops(struct _io_ops *pops);
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 #ifdef CONFIG_RTL8710B
105 void rtl8710bu_set_hw_type(struct dvobj_priv *pdvobj);
106 void rtl8710bu_set_intf_ops(struct _io_ops *pops);
107 void rtl8710bu_recv_tasklet(void *priv);
108 void rtl8710bu_xmit_tasklet(void *priv);
109 #ifdef CONFIG_SUPPORT_USB_INT
110 void interrupt_handler_8710bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
111 #endif /* CONFIG_SUPPORT_USB_INT */
112 #endif /* CONFIG_RTL8710B */
113 
114 #ifdef CONFIG_RTL8192F
115 void rtl8192fu_set_hw_type(struct dvobj_priv *pdvobj);
116 #ifdef CONFIG_SUPPORT_USB_INT
117 void rtl8192fu_interrupt_handler(_adapter *padapter, u16 pkt_len, u8 *pbuf);
118 #endif /* CONFIG_SUPPORT_USB_INT */
119 #endif /* CONFIG_RTL8192F */
120 
121 enum RTW_USB_SPEED {
122 	RTW_USB_SPEED_UNKNOWN	= 0,
123 	RTW_USB_SPEED_1_1	= 1,
124 	RTW_USB_SPEED_2		= 2,
125 	RTW_USB_SPEED_3		= 3,
126 };
127 
128 #define IS_FULL_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
129 #define IS_HIGH_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
130 #define IS_SUPER_SPEED_USB(Adapter)	(adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
131 
132 #define USB_SUPER_SPEED_BULK_SIZE	1024	/* usb 3.0 */
133 #define USB_HIGH_SPEED_BULK_SIZE	512		/* usb 2.0 */
134 #define USB_FULL_SPEED_BULK_SIZE	64		/* usb 1.1 */
135 
rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)136 static inline u8 rtw_usb_bulk_size_boundary(_adapter *padapter, int buf_len)
137 {
138 	u8 rst = _TRUE;
139 
140 	if (IS_SUPER_SPEED_USB(padapter))
141 		rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
142 	else if (IS_HIGH_SPEED_USB(padapter))
143 		rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
144 	else
145 		rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
146 	return rst;
147 }
148 
149 
150 #endif /* __USB_OPS_H_ */
151