1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3 *
4 * Copyright(c) 2007 - 2017 Realtek Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 *****************************************************************************/
16 #ifndef __USB_OPS_H_
17 #define __USB_OPS_H_
18
19
20 #define REALTEK_USB_VENQT_READ 0xC0
21 #define REALTEK_USB_VENQT_WRITE 0x40
22 #define REALTEK_USB_VENQT_CMD_REQ 0x05
23 #define REALTEK_USB_VENQT_CMD_IDX 0x00
24 #define REALTEK_USB_IN_INT_EP_IDX 1
25
26 enum {
27 VENDOR_WRITE = 0x00,
28 VENDOR_READ = 0x01,
29 };
30 #define ALIGNMENT_UNIT 16
31 #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */
32 #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT)
33
34 #ifdef PLATFORM_LINUX
35 #include <usb_ops_linux.h>
36 #endif /* PLATFORM_LINUX */
37
38 #ifdef CONFIG_RTL8188E
39 void rtl8188eu_set_hw_type(struct dvobj_priv *pdvobj);
40 #ifdef CONFIG_SUPPORT_USB_INT
41 void interrupt_handler_8188eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
42 #endif
43 #endif
44
45 #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
46 void rtl8812au_set_hw_type(struct dvobj_priv *pdvobj);
47 #ifdef CONFIG_SUPPORT_USB_INT
48 void interrupt_handler_8812au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
49 #endif
50 #endif
51
52 #ifdef CONFIG_RTL8814A
53 void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj);
54 #ifdef CONFIG_SUPPORT_USB_INT
55 void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf);
56 #endif
57 #endif /* CONFIG_RTL8814 */
58
59 #ifdef CONFIG_RTL8192E
60 void rtl8192eu_set_hw_type(struct dvobj_priv *pdvobj);
61 #ifdef CONFIG_SUPPORT_USB_INT
62 void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
63 #endif
64
65 #endif
66
67 #ifdef CONFIG_RTL8188F
68 void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj);
69 #ifdef CONFIG_SUPPORT_USB_INT
70 void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
71 #endif
72 #endif
73
74 #ifdef CONFIG_RTL8188GTV
75 void rtl8188gtvu_set_hw_type(struct dvobj_priv *pdvobj);
76 #ifdef CONFIG_SUPPORT_USB_INT
77 void interrupt_handler_8188gtvu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
78 #endif
79 #endif
80
81 #ifdef CONFIG_RTL8723B
82 void rtl8723bu_set_hw_type(struct dvobj_priv *pdvobj);
83 #ifdef CONFIG_SUPPORT_USB_INT
84 void interrupt_handler_8723bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
85 #endif
86 #endif
87
88 #ifdef CONFIG_RTL8703B
89 void rtl8703bu_set_hw_type(struct dvobj_priv *pdvobj);
90 #ifdef CONFIG_SUPPORT_USB_INT
91 void interrupt_handler_8703bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
92 #endif /* CONFIG_SUPPORT_USB_INT */
93 #endif /* CONFIG_RTL8703B */
94
95 void usb_set_intf_ops(_adapter *padapter, struct _io_ops *pops);
96
97 #ifdef CONFIG_RTL8723D
98 void rtl8723du_set_hw_type(struct dvobj_priv *pdvobj);
99 void rtl8723du_set_intf_ops(struct _io_ops *pops);
100 void rtl8723du_recv_tasklet(void *priv);
101 void rtl8723du_xmit_tasklet(void *priv);
102 #ifdef CONFIG_SUPPORT_USB_INT
103 void interrupt_handler_8723du(_adapter *padapter, u16 pkt_len, u8 *pbuf);
104 #endif /* CONFIG_SUPPORT_USB_INT */
105 #endif /* CONFIG_RTL8723D */
106
107 #ifdef CONFIG_RTL8710B
108 void rtl8710bu_set_hw_type(struct dvobj_priv *pdvobj);
109 void rtl8710bu_set_intf_ops(struct _io_ops *pops);
110 void rtl8710bu_recv_tasklet(void *priv);
111 void rtl8710bu_xmit_tasklet(void *priv);
112 #ifdef CONFIG_SUPPORT_USB_INT
113 void interrupt_handler_8710bu(_adapter *padapter, u16 pkt_len, u8 *pbuf);
114 #endif /* CONFIG_SUPPORT_USB_INT */
115 #endif /* CONFIG_RTL8710B */
116
117 #ifdef CONFIG_RTL8192F
118 void rtl8192fu_set_hw_type(struct dvobj_priv *pdvobj);
119 void rtl8192fu_xmit_tasklet(void *priv);
120 #ifdef CONFIG_SUPPORT_USB_INT
121 void rtl8192fu_interrupt_handler(_adapter *padapter, u16 pkt_len, u8 *pbuf);
122 #endif /* CONFIG_SUPPORT_USB_INT */
123 #endif /* CONFIG_RTL8192F */
124
125 enum RTW_USB_SPEED {
126 RTW_USB_SPEED_UNKNOWN = 0,
127 RTW_USB_SPEED_1_1 = 1,
128 RTW_USB_SPEED_2 = 2,
129 RTW_USB_SPEED_3 = 3,
130 };
131
132 #define IS_FULL_SPEED_USB(Adapter) (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_1_1)
133 #define IS_HIGH_SPEED_USB(Adapter) (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_2)
134 #define IS_SUPER_SPEED_USB(Adapter) (adapter_to_dvobj(Adapter)->usb_speed == RTW_USB_SPEED_3)
135
136 #define USB_SUPER_SPEED_BULK_SIZE 1024 /* usb 3.0 */
137 #define USB_HIGH_SPEED_BULK_SIZE 512 /* usb 2.0 */
138 #define USB_FULL_SPEED_BULK_SIZE 64 /* usb 1.1 */
139
rtw_usb_bulk_size_boundary(_adapter * padapter,int buf_len)140 static inline u8 rtw_usb_bulk_size_boundary(_adapter *padapter, int buf_len)
141 {
142 u8 rst = _TRUE;
143
144 if (IS_SUPER_SPEED_USB(padapter))
145 rst = (0 == (buf_len) % USB_SUPER_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
146 else if (IS_HIGH_SPEED_USB(padapter))
147 rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
148 else
149 rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? _TRUE : _FALSE;
150 return rst;
151 }
152
153
154 #endif /* __USB_OPS_H_ */
155