gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / staging / vt6656 / device.h
blobe6ee9411f080731458327c48a634f3e43c83f5e2
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
4 * All rights reserved.
6 * File: device.h
8 * Purpose: MAC Data structure
10 * Author: Tevin Chen
12 * Date: Mar 17, 1997
16 #ifndef __DEVICE_H__
17 #define __DEVICE_H__
19 #include <linux/bits.h>
20 #include <linux/module.h>
21 #include <linux/kernel.h>
22 #include <linux/slab.h>
23 #include <linux/delay.h>
24 #include <linux/device.h>
25 #include <linux/firmware.h>
26 #include <linux/suspend.h>
27 #include <linux/if_arp.h>
28 #include <linux/wireless.h>
29 #include <linux/timer.h>
30 #include <linux/usb.h>
31 #include <linux/crc32.h>
32 #include <net/mac80211.h>
34 #ifdef SIOCETHTOOL
35 #define DEVICE_ETHTOOL_IOCTL_SUPPORT
36 #include <linux/ethtool.h>
37 #else
38 #undef DEVICE_ETHTOOL_IOCTL_SUPPORT
39 #endif
41 #define RATE_1M 0
42 #define RATE_2M 1
43 #define RATE_5M 2
44 #define RATE_11M 3
45 #define RATE_6M 4
46 #define RATE_9M 5
47 #define RATE_12M 6
48 #define RATE_18M 7
49 #define RATE_24M 8
50 #define RATE_36M 9
51 #define RATE_48M 10
52 #define RATE_54M 11
53 #define RATE_AUTO 12
55 #define MAX_RATE 12
56 #define VNT_B_RATES (BIT(RATE_1M) | BIT(RATE_2M) |\
57 BIT(RATE_5M) | BIT(RATE_11M))
60 * device specific
63 #include "wcmd.h"
64 #include "desc.h"
65 #include "key.h"
66 #include "card.h"
68 #define VNT_USB_VENDOR_ID 0x160a
69 #define VNT_USB_PRODUCT_ID 0x3184
71 #define DEVICE_NAME "vt6656"
72 #define DEVICE_FULL_DRV_NAM "VIA Networking Wireless LAN USB Driver"
74 #define DEVICE_VERSION "mac80211"
76 #define CONFIG_PATH "/etc/vntconfiguration.dat"
78 #define MAX_UINTS 8
79 #define OPTION_DEFAULT { [0 ... MAX_UINTS - 1] = -1}
81 #define DUPLICATE_RX_CACHE_LENGTH 5
83 #define AUTO_FB_NONE 0
84 #define AUTO_FB_0 1
85 #define AUTO_FB_1 2
87 #define FB_RATE0 0
88 #define FB_RATE1 1
90 /* Antenna Mode */
91 #define ANT_A 0
92 #define ANT_B 1
93 #define ANT_DIVERSITY 2
94 #define ANT_RXD_TXA 3
95 #define ANT_RXD_TXB 4
96 #define ANT_UNKNOWN 0xFF
97 #define ANT_TXA 0
98 #define ANT_TXB 1
99 #define ANT_RXA 2
100 #define ANT_RXB 3
102 #define BB_VGA_LEVEL 4
103 #define BB_VGA_CHANGE_THRESHOLD 3
105 #define EEP_MAX_CONTEXT_SIZE 256
107 /* Contents in the EEPROM */
108 #define EEP_OFS_PAR 0x0
109 #define EEP_OFS_ANTENNA 0x17
110 #define EEP_OFS_RADIOCTL 0x18
111 #define EEP_OFS_RFTYPE 0x1b
112 #define EEP_OFS_MINCHANNEL 0x1c
113 #define EEP_OFS_MAXCHANNEL 0x1d
114 #define EEP_OFS_SIGNATURE 0x1e
115 #define EEP_OFS_ZONETYPE 0x1f
116 #define EEP_OFS_RFTABLE 0x20
117 #define EEP_OFS_PWR_CCK 0x20
118 #define EEP_OFS_SETPT_CCK 0x21
119 #define EEP_OFS_PWR_OFDMG 0x23
121 #define EEP_OFS_CALIB_TX_IQ 0x24
122 #define EEP_OFS_CALIB_TX_DC 0x25
123 #define EEP_OFS_CALIB_RX_IQ 0x26
125 #define EEP_OFS_MAJOR_VER 0x2e
126 #define EEP_OFS_MINOR_VER 0x2f
128 #define EEP_OFS_CCK_PWR_TBL 0x30
129 #define EEP_OFS_OFDM_PWR_TBL 0x40
130 #define EEP_OFS_OFDMA_PWR_TBL 0x50
132 /* Bits in EEP_OFS_ANTENNA */
133 #define EEP_ANTENNA_MAIN BIT(0)
134 #define EEP_ANTENNA_AUX BIT(1)
135 #define EEP_ANTINV BIT(2)
137 /* Bits in EEP_OFS_RADIOCTL */
138 #define EEP_RADIOCTL_ENABLE BIT(7)
140 /* control commands */
141 #define MESSAGE_TYPE_READ 0x1
142 #define MESSAGE_TYPE_WRITE 0x0
143 #define MESSAGE_TYPE_LOCK_OR 0x2
144 #define MESSAGE_TYPE_LOCK_AND 0x3
145 #define MESSAGE_TYPE_WRITE_MASK 0x4
146 #define MESSAGE_TYPE_CARDINIT 0x5
147 #define MESSAGE_TYPE_INIT_RSP 0x6
148 #define MESSAGE_TYPE_MACSHUTDOWN 0x7
149 #define MESSAGE_TYPE_SETKEY 0x8
150 #define MESSAGE_TYPE_CLRKEYENTRY 0x9
151 #define MESSAGE_TYPE_WRITE_MISCFF 0xa
152 #define MESSAGE_TYPE_SET_ANTMD 0xb
153 #define MESSAGE_TYPE_SELECT_CHANNEL 0xc
154 #define MESSAGE_TYPE_SET_TSFTBTT 0xd
155 #define MESSAGE_TYPE_SET_SSTIFS 0xe
156 #define MESSAGE_TYPE_CHANGE_BBTYPE 0xf
157 #define MESSAGE_TYPE_DISABLE_PS 0x10
158 #define MESSAGE_TYPE_WRITE_IFRF 0x11
160 /* command read/write(index) */
161 #define MESSAGE_REQUEST_MEM 0x1
162 #define MESSAGE_REQUEST_BBREG 0x2
163 #define MESSAGE_REQUEST_MACREG 0x3
164 #define MESSAGE_REQUEST_EEPROM 0x4
165 #define MESSAGE_REQUEST_TSF 0x5
166 #define MESSAGE_REQUEST_TBTT 0x6
167 #define MESSAGE_REQUEST_BBAGC 0x7
168 #define MESSAGE_REQUEST_VERSION 0x8
169 #define MESSAGE_REQUEST_RF_INIT 0x9
170 #define MESSAGE_REQUEST_RF_INIT2 0xa
171 #define MESSAGE_REQUEST_RF_CH0 0xb
172 #define MESSAGE_REQUEST_RF_CH1 0xc
173 #define MESSAGE_REQUEST_RF_CH2 0xd
175 /* USB registers */
176 #define USB_REG4 0x604
178 #define DEVICE_INIT_COLD 0x0 /* cold init */
179 #define DEVICE_INIT_RESET 0x1 /* reset init or Dx to D0 power remain */
180 #define DEVICE_INIT_DXPL 0x2 /* Dx to D0 power lost init */
182 /* Device init */
183 struct vnt_cmd_card_init {
184 u8 init_class;
185 u8 exist_sw_net_addr;
186 u8 sw_net_addr[6];
187 u8 short_retry_limit;
188 u8 long_retry_limit;
191 struct vnt_rsp_card_init {
192 u8 status;
193 u8 net_addr[6];
194 u8 rf_type;
195 u8 min_channel;
196 u8 max_channel;
199 /* USB */
202 * Enum of context types for SendPacket
204 enum {
205 CONTEXT_DATA_PACKET = 1,
206 CONTEXT_MGMT_PACKET,
207 CONTEXT_BEACON_PACKET
210 struct vnt_rx_header {
211 u32 wbk_status;
212 u8 rx_sts;
213 u8 rx_rate;
214 u16 pay_load_len;
215 } __packed;
217 struct vnt_rx_tail {
218 __le64 tsf_time;
219 u8 sq;
220 u8 new_rsr;
221 u8 rssi;
222 u8 rsr;
223 u8 sq_3;
224 } __packed;
226 /* RCB (Receive Control Block) */
227 struct vnt_rcb {
228 void *priv;
229 struct urb *urb;
230 struct sk_buff *skb;
233 /* used to track bulk out irps */
234 struct vnt_usb_send_context {
235 void *priv;
236 struct sk_buff *skb;
237 struct urb *urb;
238 struct ieee80211_hdr *hdr;
239 unsigned int buf_len;
240 u32 frame_len;
241 u16 tx_hdr_size;
242 u16 tx_rate;
243 u8 type;
244 u8 pkt_no;
245 u8 pkt_type;
246 u8 need_ack;
247 bool in_use;
248 unsigned char data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
252 * Structure to keep track of USB interrupt packets
254 struct vnt_interrupt_buffer {
255 u8 *data_buf;
258 /* flags for options */
259 #define DEVICE_FLAGS_UNPLUG 0
260 #define DEVICE_FLAGS_DISCONNECTED 1
262 struct vnt_private {
263 /* mac80211 */
264 struct ieee80211_hw *hw;
265 struct ieee80211_vif *vif;
266 u8 mac_hw;
267 /* netdev */
268 struct usb_device *usb;
269 struct usb_interface *intf;
271 u64 tsf_time;
273 u32 rx_buf_sz;
274 int mc_list_count;
276 spinlock_t lock;
277 struct mutex usb_lock;
279 unsigned long flags;
281 /* USB */
282 struct urb *interrupt_urb;
283 u32 int_interval;
285 /* Variables to track resources for the BULK In Pipe */
286 struct vnt_rcb *rcb[CB_MAX_RX_DESC];
287 u32 num_rcb;
289 /* Variables to track resources for the BULK Out Pipe */
290 struct vnt_usb_send_context *tx_context[CB_MAX_TX_DESC];
291 u32 num_tx_context;
293 /* Variables to track resources for the Interrupt In Pipe */
294 struct vnt_interrupt_buffer int_buf;
296 /* Version control */
297 u16 firmware_version;
298 u8 local_id;
299 u8 rf_type;
300 u8 bb_rx_conf;
302 struct vnt_cmd_card_init init_command;
303 struct vnt_rsp_card_init init_response;
304 u8 current_net_addr[ETH_ALEN] __aligned(2);
305 u8 permanent_net_addr[ETH_ALEN] __aligned(2);
307 u8 exist_sw_net_addr;
309 u64 current_tsf;
311 /* 802.11 MAC specific */
312 u32 current_rssi;
314 /* Antenna Diversity */
315 int tx_rx_ant_inv;
316 u32 rx_antenna_sel;
317 u8 rx_antenna_mode;
318 u8 tx_antenna_mode;
319 u8 radio_ctl;
321 /* IFS & Cw */
322 u32 sifs; /* Current SIFS */
323 u32 difs; /* Current DIFS */
324 u32 eifs; /* Current EIFS */
325 u32 slot; /* Current SlotTime */
327 /* Rate */
328 u8 bb_type; /* 0: 11A, 1:11B, 2:11G */
329 u8 packet_type; /* 0:11a 1:11b 2:11gb 3:11ga */
330 u32 basic_rates;
331 u8 top_ofdm_basic_rate;
332 u8 top_cck_basic_rate;
334 u8 eeprom[EEP_MAX_CONTEXT_SIZE]; /*u32 alignment */
336 u8 preamble_type;
338 /* For RF Power table */
339 u8 cck_pwr;
340 u8 ofdm_pwr_g;
341 u8 ofdm_pwr_a;
342 u8 power;
343 u8 cck_pwr_tbl[14];
344 u8 ofdm_pwr_tbl[14];
345 u8 ofdm_a_pwr_tbl[42];
347 u16 current_rate;
348 u16 tx_rate_fb0;
349 u16 tx_rate_fb1;
351 u8 short_retry_limit;
352 u8 long_retry_limit;
354 enum nl80211_iftype op_mode;
356 int short_slot_time;
358 /* Power save */
359 u16 current_aid;
361 /* Beacon related */
362 u16 seq_counter;
364 enum vnt_cmd_state command_state;
366 enum vnt_cmd command;
368 /* 802.11 counter */
370 enum vnt_cmd cmd_queue[CMD_Q_SIZE];
371 u32 cmd_dequeue_idx;
372 u32 cmd_enqueue_idx;
373 u32 free_cmd_queue;
374 int cmd_running;
376 unsigned long key_entry_inuse;
378 u8 auto_fb_ctrl;
380 /* For Update BaseBand VGA Gain Offset */
381 u8 bb_vga[BB_VGA_LEVEL];
383 u8 bb_pre_ed_rssi;
384 u8 bb_pre_ed_index;
386 u16 wake_up_count;
388 /* command timer */
389 struct delayed_work run_command_work;
391 struct ieee80211_low_level_stats low_stats;
394 #define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) { \
395 if ((uVar) >= ((uModulo) - 1)) \
396 (uVar) = 0; \
397 else \
398 (uVar)++; \
401 int vnt_init(struct vnt_private *priv);
403 #endif