xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/nxp/mlinux/moal_usb.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file moal_usb.h
2  *
3  * @brief This file contains definitions for USB interface.
4  * driver.
5  *
6  *
7  * Copyright 2008-2021 NXP
8  *
9  * This software file (the File) is distributed by NXP
10  * under the terms of the GNU General Public License Version 2, June 1991
11  * (the License).  You may use, redistribute and/or modify the File in
12  * accordance with the terms and conditions of the License, a copy of which
13  * is available by writing to the Free Software Foundation, Inc.,
14  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
15  * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
16  *
17  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
19  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
20  * this warranty disclaimer.
21  *
22  */
23 /*************************************************************
24 Change Log:
25     10/21/2008: initial version
26 ************************************************************/
27 
28 #ifndef _MOAL_USB_H
29 #define _MOAL_USB_H
30 
31 #ifdef USB8801
32 /** USB VID 1 */
33 #define USB8801_VID_1 0x1286
34 /** USB PID 1 */
35 #define USB8801_PID_1 0x2049
36 /** USB PID 2 */
37 #define USB8801_PID_2 0x204a
38 #endif /* USB8801 */
39 #ifdef USB8997
40 /** USB VID 1 */
41 #define USB8997_VID_1 0x1286
42 /** USB PID 1 */
43 #define USB8997_PID_1 0x204D
44 /** USB PID 2 */
45 #define USB8997_PID_2 0x204E
46 #define USB8997_PID_3 0x2047
47 #define USB8997_PID_4 0x2048
48 #define USB8997_PID_5 0x2050
49 #define USB8997_PID_6 0x2051
50 #define USB8997V2_PID_1 0x2052
51 #endif /* USB8997 */
52 
53 #ifdef USB8978
54 /** USB VID 1 */
55 #define USB8978_VID_1 0x1286
56 /** USB PID 1 */
57 #define USB8978_PID_1 0x2062
58 /** USB PID 2 */
59 #define USB8978_PID_2 0x2063
60 /* BT downloaded combo  firmware; register for WLAN enumeration */
61 #define USB8978_PID_1_BT 0x2064
62 #define USB8978_PID_2_BT 0x2065
63 #endif
64 
65 #ifdef USB8897
66 /** USB VID 1 */
67 #define USB8897_VID_1 0x1286
68 /** USB PID 1 */
69 #define USB8897_PID_1 0x2045
70 /** USB PID 2 */
71 #define USB8897_PID_2 0x2046
72 #endif /* USB8897 */
73 
74 #ifdef USB9098
75 /** USB VID 1 */
76 #define USB9098_VID_1 0x1286
77 /** USB PID 1 */
78 #define USB9098_PID_1 0x2056
79 /** USB PID 2 */
80 #define USB9098_PID_2 0x2057
81 #endif /* USB9098 */
82 
83 #ifdef USB9097
84 /** USB VID 1 */
85 #define USB9097_VID_1 0x1286
86 /** USB PID 1 */
87 #define USB9097_PID_1 0x2060
88 /** USB PID 2 */
89 #define USB9097_PID_2 0x2061
90 #endif /* USB9097 */
91 
92 #ifdef USBNW62X
93 /** USB VID 1 */
94 #define USBNW62X_VID_1 0x0471
95 /** USB PID 1 */
96 #define USBNW62X_PID_1 0x020E
97 /** USB PID 2 */
98 #define USBNW62X_PID_2 0x020F
99 #endif /* USBNW62X */
100 
101 /** Boot state: FW download */
102 #define USB_FW_DNLD 1
103 /** Boot state: FW ready */
104 #define USB_FW_READY 2
105 
106 /** High watermark for Tx data */
107 #define MVUSB_TX_HIGH_WMARK 12
108 
109 /** Number of Rx data URB */
110 #define MVUSB_RX_DATA_URB 6
111 
112 #if defined(USB8997) || defined(USB9098) || defined(USB9097) ||                \
113 	defined(USB8978) || defined(USB8801) || defined(USBNW62X)
114 /* Transmit buffer size for chip revision check */
115 #define CHIP_REV_TX_BUF_SIZE 16
116 /* Receive buffer size for chip revision check */
117 #define CHIP_REV_RX_BUF_SIZE 2048
118 
119 /* Extensions */
120 #define EXTEND_HDR (0xAB950000)
121 #define EXTEND_V1 (0x00000001)
122 #define EXTEND_V2 (0x00000002)
123 #ifdef USB8801
124 #define USB8801_DEFAULT_WLAN_FW_NAME "nxp/usb8801_uapsta.bin"
125 #endif /* USB8801 */
126 
127 #endif
128 
129 /** Default firmaware name */
130 #ifdef USB8997
131 #define USB8997_DEFAULT_COMBO_FW_NAME "nxp/usbusb8997_combo_v4.bin"
132 #define USB8997_DEFAULT_WLAN_FW_NAME "nxp/usb8997_wlan_v4.bin"
133 #define USBUART8997_DEFAULT_COMBO_FW_NAME "nxp/usbuart8997_combo_v4.bin"
134 #define USBUSB8997_DEFAULT_COMBO_FW_NAME "nxp/usbusb8997_combo_v4.bin"
135 
136 #endif /* USB8997 */
137 
138 #ifdef USB8978
139 #define USB8978_DEFAULT_COMBO_FW_NAME "nxp/usbusbiw416_combo.bin"
140 #define USB8978_DEFAULT_WLAN_FW_NAME "nxp/usbiw416_wlan.bin"
141 #define USBUART8978_DEFAULT_COMBO_FW_NAME "nxp/usbuartiw416_combo.bin"
142 #define USBUSB8978_DEFAULT_COMBO_FW_NAME "nxp/usbusbiw416_combo.bin"
143 #endif /* USB8978 */
144 
145 #ifdef USB8897
146 #define USB8897_DEFAULT_COMBO_FW_NAME "nxp/usb8897_uapsta.bin"
147 #define USB8897_DEFAULT_WLAN_FW_NAME "nxp/usb8897_wlan.bin"
148 #endif /* USB8897 */
149 
150 #ifdef USB9098
151 #define USB9098_Z1Z2 0x00
152 #define USB9098_A0 0x01
153 #define USB9098_A1 0x02
154 #define USB9098_A2 0x03
155 #define USB9098_DEFAULT_COMBO_FW_NAME "nxp/usbusb9098_combo.bin"
156 #define USB9098_DEFAULT_WLAN_FW_NAME "nxp/usb9098_wlan.bin"
157 #define USBUART9098_DEFAULT_COMBO_FW_NAME "nxp/usbuart9098_combo.bin"
158 #define USBUSB9098_DEFAULT_COMBO_FW_NAME "nxp/usbusb9098_combo.bin"
159 #define USB9098_WLAN_V1_FW_NAME "nxp/usb9098_wlan_v1.bin"
160 #define USBUART9098_COMBO_V1_FW_NAME "nxp/usbuart9098_combo_v1.bin"
161 #define USBUSB9098_COMBO_V1_FW_NAME "nxp/usbusb9098_combo_v1.bin"
162 #endif /* USB9098 */
163 
164 #ifdef USB9097
165 #define USB9097_B0 0x01
166 #define USB9097_B1 0x02
167 #define USB9097_DEFAULT_COMBO_FW_NAME "nxp/usbusbiw620_combo_v1.bin"
168 #define USB9097_DEFAULT_WLAN_FW_NAME "nxp/usbiw620_wlan_v1.bin"
169 #define USB9097_WLAN_V1_FW_NAME "nxp/usbiw620_wlan_v1.bin"
170 #define USBUART9097_COMBO_V1_FW_NAME "nxp/usbuartiw620_combo_v1.bin"
171 #define USBUSB9097_COMBO_V1_FW_NAME "nxp/usbusbiw620_combo_v1.bin"
172 #endif /* USB9097 */
173 
174 #ifdef USBNW62X
175 #define USBNW62X_DEFAULT_COMBO_FW_NAME "nxp/usbusbnw62x_combo.bin"
176 #define USBUARTNW62X_COMBO_FW_NAME "nxp/usbuartnw62x_combo.bin"
177 #define USBUSBNW62X_COMBO_FW_NAME "nxp/usbusbnw62x_combo.bin"
178 #define USBNW62X_DEFAULT_WLAN_FW_NAME "nxp/usbnw62x_wlan.bin"
179 #endif /* USBNW62X */
180 
181 /** urb context */
182 typedef struct _urb_context {
183 	/** Pointer to moal_handle structure */
184 	moal_handle *handle;
185 	/** Pointer to mlan buffer */
186 	mlan_buffer *pmbuf;
187 	/** URB */
188 	struct urb *urb;
189 	/** EP */
190 	t_u8 ep;
191 } urb_context;
192 
193 /** USB card description structure*/
194 struct usb_card_rec {
195 	/** USB device */
196 	struct usb_device *udev;
197 	/** MOAL handle */
198 	moal_handle *phandle;
199 	/** USB interface */
200 	struct usb_interface *intf;
201 	/** Rx command endpoint type */
202 	int rx_cmd_ep_type;
203 	/** Rx command interval for INTR type */
204 	t_u8 rx_cmd_interval;
205 	/** Rx data endpoint address */
206 	t_u8 rx_cmd_ep;
207 	/** Rx cmd contxt */
208 	urb_context rx_cmd;
209 	/** Rx command URB pending count */
210 	atomic_t rx_cmd_urb_pending;
211 	/** Rx data context list */
212 	urb_context rx_data_list[MVUSB_RX_DATA_URB];
213 	/** Flag to indicate boot state */
214 	t_u8 boot_state;
215 	/** Rx data endpoint address */
216 	t_u8 rx_data_ep;
217 	/** Rx data URB pending count */
218 	atomic_t rx_data_urb_pending;
219 	/** Tx data endpoint address */
220 	t_u8 tx_data_ep;
221 	/** Tx command endpoint type */
222 	int tx_cmd_ep_type;
223 	/** Tx command interval for INTR type */
224 	t_u8 tx_cmd_interval;
225 	/** Tx command endpoint address */
226 	t_u8 tx_cmd_ep;
227 	/** Tx data URB pending count */
228 	atomic_t tx_data_urb_pending;
229 	/** Tx command URB pending count */
230 	atomic_t tx_cmd_urb_pending;
231 	/** Tx data endpoint max pkt size */
232 	int tx_data_maxpktsize;
233 	/** Tx cmd endpoint max pkt size */
234 	int tx_cmd_maxpktsize;
235 	/** Pre-allocated urb for command */
236 	urb_context tx_cmd;
237 	/** Index to point to next data urb to use */
238 	int tx_data_ix;
239 	/** Pre-allocated urb for data */
240 	urb_context tx_data_list[MVUSB_TX_HIGH_WMARK];
241 	usb_aggr_ctrl_cfg tx_aggr_ctrl;
242 	usb_aggr_ctrl_cfg rx_deaggr_ctrl;
243 	t_u8 resubmit_urbs;
244 	/** USB card type */
245 	t_u16 card_type;
246 	t_u8 second_mac;
247 };
248 
249 void woal_kill_urbs(moal_handle *handle);
250 void woal_resubmit_urbs(moal_handle *handle);
251 
252 mlan_status woal_write_data_async(moal_handle *handle, mlan_buffer *pmbuf,
253 				  t_u8 ep);
254 mlan_status woal_usb_submit_rx_data_urbs(moal_handle *handle);
255 mlan_status woal_usb_rx_init(moal_handle *handle);
256 mlan_status woal_usb_tx_init(moal_handle *handle);
257 mlan_status woal_usb_aggr_init(moal_handle *handle);
258 void woal_submit_rx_urb(moal_handle *handle, t_u8 ep);
259 void woal_usb_bus_unregister(void);
260 mlan_status woal_usb_bus_register(void);
261 void woal_usb_free(struct usb_card_rec *cardp);
262 #endif /*_MOAL_USB_H */
263