18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file contains definitions for mwifiex USB interface driver. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright 2011-2020 NXP 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This software file (the "File") is distributed by NXP 78c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License Version 2, June 1991 88c2ecf20Sopenharmony_ci * (the "License"). You may use, redistribute and/or modify this File in 98c2ecf20Sopenharmony_ci * accordance with the terms and conditions of the License, a copy of which 108c2ecf20Sopenharmony_ci * is available by writing to the Free Software Foundation, Inc., 118c2ecf20Sopenharmony_ci * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the 128c2ecf20Sopenharmony_ci * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE 158c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE 168c2ecf20Sopenharmony_ci * ARE EXPRESSLY DISCLAIMED. The License provides additional details about 178c2ecf20Sopenharmony_ci * this warranty disclaimer. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#ifndef _MWIFIEX_USB_H 218c2ecf20Sopenharmony_ci#define _MWIFIEX_USB_H 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <linux/completion.h> 248c2ecf20Sopenharmony_ci#include <linux/usb.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define USB8XXX_VID 0x1286 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define USB8766_PID_1 0x2041 298c2ecf20Sopenharmony_ci#define USB8766_PID_2 0x2042 308c2ecf20Sopenharmony_ci#define USB8797_PID_1 0x2043 318c2ecf20Sopenharmony_ci#define USB8797_PID_2 0x2044 328c2ecf20Sopenharmony_ci#define USB8801_PID_1 0x2049 338c2ecf20Sopenharmony_ci#define USB8801_PID_2 0x204a 348c2ecf20Sopenharmony_ci#define USB8997_PID_1 0x2052 358c2ecf20Sopenharmony_ci#define USB8997_PID_2 0x204e 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define USB8XXX_FW_DNLD 1 398c2ecf20Sopenharmony_ci#define USB8XXX_FW_READY 2 408c2ecf20Sopenharmony_ci#define USB8XXX_FW_MAX_RETRY 3 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define MWIFIEX_TX_DATA_PORT 2 438c2ecf20Sopenharmony_ci#define MWIFIEX_TX_DATA_URB 6 448c2ecf20Sopenharmony_ci#define MWIFIEX_RX_DATA_URB 6 458c2ecf20Sopenharmony_ci#define MWIFIEX_USB_TIMEOUT 100 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define USB8766_DEFAULT_FW_NAME "mrvl/usb8766_uapsta.bin" 488c2ecf20Sopenharmony_ci#define USB8797_DEFAULT_FW_NAME "mrvl/usb8797_uapsta.bin" 498c2ecf20Sopenharmony_ci#define USB8801_DEFAULT_FW_NAME "mrvl/usb8801_uapsta.bin" 508c2ecf20Sopenharmony_ci#define USB8997_DEFAULT_FW_NAME "mrvl/usbusb8997_combo_v4.bin" 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define FW_DNLD_TX_BUF_SIZE 620 538c2ecf20Sopenharmony_ci#define FW_DNLD_RX_BUF_SIZE 2048 548c2ecf20Sopenharmony_ci#define FW_HAS_LAST_BLOCK 0x00000004 558c2ecf20Sopenharmony_ci#define FW_CMD_7 0x00000007 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define FW_DATA_XMIT_SIZE \ 588c2ecf20Sopenharmony_ci (sizeof(struct fw_header) + dlen + sizeof(u32)) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct urb_context { 618c2ecf20Sopenharmony_ci struct mwifiex_adapter *adapter; 628c2ecf20Sopenharmony_ci struct sk_buff *skb; 638c2ecf20Sopenharmony_ci struct urb *urb; 648c2ecf20Sopenharmony_ci u8 ep; 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define MWIFIEX_USB_TX_AGGR_TMO_MIN 1 688c2ecf20Sopenharmony_ci#define MWIFIEX_USB_TX_AGGR_TMO_MAX 4 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct tx_aggr_tmr_cnxt { 718c2ecf20Sopenharmony_ci struct mwifiex_adapter *adapter; 728c2ecf20Sopenharmony_ci struct usb_tx_data_port *port; 738c2ecf20Sopenharmony_ci struct timer_list hold_timer; 748c2ecf20Sopenharmony_ci bool is_hold_timer_set; 758c2ecf20Sopenharmony_ci u32 hold_tmo_msecs; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistruct usb_tx_aggr { 798c2ecf20Sopenharmony_ci struct sk_buff_head aggr_list; 808c2ecf20Sopenharmony_ci int aggr_len; 818c2ecf20Sopenharmony_ci int aggr_num; 828c2ecf20Sopenharmony_ci struct tx_aggr_tmr_cnxt timer_cnxt; 838c2ecf20Sopenharmony_ci}; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistruct usb_tx_data_port { 868c2ecf20Sopenharmony_ci u8 tx_data_ep; 878c2ecf20Sopenharmony_ci u8 block_status; 888c2ecf20Sopenharmony_ci atomic_t tx_data_urb_pending; 898c2ecf20Sopenharmony_ci int tx_data_ix; 908c2ecf20Sopenharmony_ci struct urb_context tx_data_list[MWIFIEX_TX_DATA_URB]; 918c2ecf20Sopenharmony_ci /* usb tx aggregation*/ 928c2ecf20Sopenharmony_ci struct usb_tx_aggr tx_aggr; 938c2ecf20Sopenharmony_ci struct sk_buff *skb_aggr[MWIFIEX_TX_DATA_URB]; 948c2ecf20Sopenharmony_ci /* lock for protect tx aggregation data path*/ 958c2ecf20Sopenharmony_ci spinlock_t tx_aggr_lock; 968c2ecf20Sopenharmony_ci}; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_cistruct usb_card_rec { 998c2ecf20Sopenharmony_ci struct mwifiex_adapter *adapter; 1008c2ecf20Sopenharmony_ci struct usb_device *udev; 1018c2ecf20Sopenharmony_ci struct usb_interface *intf; 1028c2ecf20Sopenharmony_ci struct completion fw_done; 1038c2ecf20Sopenharmony_ci u8 rx_cmd_ep; 1048c2ecf20Sopenharmony_ci struct urb_context rx_cmd; 1058c2ecf20Sopenharmony_ci atomic_t rx_cmd_urb_pending; 1068c2ecf20Sopenharmony_ci struct urb_context rx_data_list[MWIFIEX_RX_DATA_URB]; 1078c2ecf20Sopenharmony_ci u8 usb_boot_state; 1088c2ecf20Sopenharmony_ci u8 rx_data_ep; 1098c2ecf20Sopenharmony_ci atomic_t rx_data_urb_pending; 1108c2ecf20Sopenharmony_ci u8 tx_cmd_ep; 1118c2ecf20Sopenharmony_ci atomic_t tx_cmd_urb_pending; 1128c2ecf20Sopenharmony_ci int bulk_out_maxpktsize; 1138c2ecf20Sopenharmony_ci struct urb_context tx_cmd; 1148c2ecf20Sopenharmony_ci u8 mc_resync_flag; 1158c2ecf20Sopenharmony_ci struct usb_tx_data_port port[MWIFIEX_TX_DATA_PORT]; 1168c2ecf20Sopenharmony_ci int rx_cmd_ep_type; 1178c2ecf20Sopenharmony_ci u8 rx_cmd_interval; 1188c2ecf20Sopenharmony_ci int tx_cmd_ep_type; 1198c2ecf20Sopenharmony_ci u8 tx_cmd_interval; 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct fw_header { 1238c2ecf20Sopenharmony_ci __le32 dnld_cmd; 1248c2ecf20Sopenharmony_ci __le32 base_addr; 1258c2ecf20Sopenharmony_ci __le32 data_len; 1268c2ecf20Sopenharmony_ci __le32 crc; 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistruct fw_sync_header { 1308c2ecf20Sopenharmony_ci __le32 cmd; 1318c2ecf20Sopenharmony_ci __le32 seq_num; 1328c2ecf20Sopenharmony_ci} __packed; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_cistruct fw_data { 1358c2ecf20Sopenharmony_ci struct fw_header fw_hdr; 1368c2ecf20Sopenharmony_ci __le32 seq_num; 1378c2ecf20Sopenharmony_ci u8 data[1]; 1388c2ecf20Sopenharmony_ci} __packed; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#endif /*_MWIFIEX_USB_H */ 141