xref: /linux/drivers/net/wireless/marvell/mwifiex/usb.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * This file contains definitions for mwifiex USB interface driver.
4  *
5  * Copyright 2011-2020 NXP
6  */
7 
8 #ifndef _MWIFIEX_USB_H
9 #define _MWIFIEX_USB_H
10 
11 #include <linux/completion.h>
12 #include <linux/usb.h>
13 
14 #define USB8XXX_VID		0x1286
15 
16 #define USB8766_PID_1		0x2041
17 #define USB8766_PID_2		0x2042
18 #define USB8797_PID_1		0x2043
19 #define USB8797_PID_2		0x2044
20 #define USB8801_PID_1		0x2049
21 #define USB8801_PID_2		0x204a
22 #define USB8997_PID_1		0x2052
23 #define USB8997_PID_2		0x204e
24 
25 
26 #define USB8XXX_FW_DNLD		1
27 #define USB8XXX_FW_READY	2
28 #define USB8XXX_FW_MAX_RETRY	3
29 
30 #define MWIFIEX_TX_DATA_PORT	2
31 #define MWIFIEX_TX_DATA_URB	6
32 #define MWIFIEX_RX_DATA_URB	6
33 #define MWIFIEX_USB_TIMEOUT	100
34 
35 #define USB8766_DEFAULT_FW_NAME	"mrvl/usb8766_uapsta.bin"
36 #define USB8797_DEFAULT_FW_NAME	"mrvl/usb8797_uapsta.bin"
37 #define USB8801_DEFAULT_FW_NAME	"mrvl/usb8801_uapsta.bin"
38 #define USB8997_DEFAULT_FW_NAME	"mrvl/usbusb8997_combo_v4.bin"
39 
40 #define FW_DNLD_TX_BUF_SIZE	620
41 #define FW_DNLD_RX_BUF_SIZE	2048
42 #define FW_HAS_LAST_BLOCK	0x00000004
43 #define FW_CMD_7		0x00000007
44 
45 #define FW_DATA_XMIT_SIZE \
46 	(sizeof(struct fw_header) + dlen + sizeof(u32))
47 
48 struct urb_context {
49 	struct mwifiex_adapter *adapter;
50 	struct sk_buff *skb;
51 	struct urb *urb;
52 	u8 ep;
53 };
54 
55 #define MWIFIEX_USB_TX_AGGR_TMO_MIN	1
56 #define MWIFIEX_USB_TX_AGGR_TMO_MAX	4
57 
58 struct tx_aggr_tmr_cnxt {
59 	struct mwifiex_adapter *adapter;
60 	struct usb_tx_data_port *port;
61 	struct timer_list hold_timer;
62 	bool is_hold_timer_set;
63 	u32 hold_tmo_msecs;
64 };
65 
66 struct usb_tx_aggr {
67 	struct sk_buff_head aggr_list;
68 	int aggr_len;
69 	int aggr_num;
70 	struct tx_aggr_tmr_cnxt timer_cnxt;
71 };
72 
73 struct usb_tx_data_port {
74 	u8 tx_data_ep;
75 	u8 block_status;
76 	atomic_t tx_data_urb_pending;
77 	int tx_data_ix;
78 	struct urb_context tx_data_list[MWIFIEX_TX_DATA_URB];
79 	/* usb tx aggregation*/
80 	struct usb_tx_aggr tx_aggr;
81 	struct sk_buff *skb_aggr[MWIFIEX_TX_DATA_URB];
82 	/* lock for protect tx aggregation data path*/
83 	spinlock_t tx_aggr_lock;
84 };
85 
86 struct usb_card_rec {
87 	struct mwifiex_adapter *adapter;
88 	struct usb_device *udev;
89 	struct usb_interface *intf;
90 	struct completion fw_done;
91 	u8 rx_cmd_ep;
92 	struct urb_context rx_cmd;
93 	atomic_t rx_cmd_urb_pending;
94 	struct urb_context rx_data_list[MWIFIEX_RX_DATA_URB];
95 	u8 usb_boot_state;
96 	u8 rx_data_ep;
97 	atomic_t rx_data_urb_pending;
98 	u8 tx_cmd_ep;
99 	atomic_t tx_cmd_urb_pending;
100 	int bulk_out_maxpktsize;
101 	struct urb_context tx_cmd;
102 	u8 mc_resync_flag;
103 	struct usb_tx_data_port port[MWIFIEX_TX_DATA_PORT];
104 	int rx_cmd_ep_type;
105 	u8 rx_cmd_interval;
106 	int tx_cmd_ep_type;
107 	u8 tx_cmd_interval;
108 };
109 
110 struct fw_header {
111 	__le32 dnld_cmd;
112 	__le32 base_addr;
113 	__le32 data_len;
114 	__le32 crc;
115 };
116 
117 struct fw_sync_header {
118 	__le32 cmd;
119 	__le32 seq_num;
120 } __packed;
121 
122 struct fw_data {
123 	struct fw_header fw_hdr;
124 	__le32 seq_num;
125 	u8 data[];
126 } __packed;
127 
128 #endif /*_MWIFIEX_USB_H */
129