blob: 00d3336fd16b2605177aee49dda6be32ee287d4f [file] [log] [blame]
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +02001/******************************************************************************
2 *
3 * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
27#ifndef __il_3945_h__
28#define __il_3945_h__
29
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010030#include <linux/pci.h> /* for struct pci_device_id */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +020031#include <linux/kernel.h>
32#include <net/ieee80211_radiotap.h>
33
34/* Hardware specific file defines the PCI IDs table for that hardware module */
35extern const struct pci_device_id il3945_hw_card_ids[];
36
Stanislaw Gruszkae94a4092011-08-31 13:23:20 +020037#include "common.h"
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +020038
39/* Highest firmware API version supported */
40#define IL3945_UCODE_API_MAX 2
41
42/* Lowest firmware API version supported */
43#define IL3945_UCODE_API_MIN 1
44
45#define IL3945_FW_PRE "iwlwifi-3945-"
46#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode"
47#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api)
48
49/* Default noise level to report when noise measurement is not available.
50 * This may be because we're:
51 * 1) Not associated (4965, no beacon stats being sent to driver)
52 * 2) Scanning (noise measurement does not apply to associated channel)
53 * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
54 * Use default noise value of -127 ... this is below the range of measurable
55 * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
56 * Also, -127 works better than 0 when averaging frames with/without
57 * noise info (e.g. averaging might be done in app); measured dBm values are
58 * always negative ... using a negative value as the default keeps all
59 * averages within an s8's (used in some apps) range of negative values. */
60#define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
61
62/* Module parameters accessible from iwl-*.c */
63extern struct il_mod_params il3945_mod_params;
64
65struct il3945_rate_scale_data {
66 u64 data;
67 s32 success_counter;
68 s32 success_ratio;
69 s32 counter;
70 s32 average_tpt;
71 unsigned long stamp;
72};
73
74struct il3945_rs_sta {
75 spinlock_t lock;
76 struct il_priv *il;
77 s32 *expected_tpt;
78 unsigned long last_partial_flush;
79 unsigned long last_flush;
80 u32 flush_time;
81 u32 last_tx_packets;
82 u32 tx_packets;
83 u8 tgg;
84 u8 flush_pending;
85 u8 start_rate;
86 struct timer_list rate_scale_flush;
87 struct il3945_rate_scale_data win[RATE_COUNT_3945];
88#ifdef CONFIG_MAC80211_DEBUGFS
89 struct dentry *rs_sta_dbgfs_stats_table_file;
90#endif
91
92 /* used to be in sta_info */
93 int last_txrate_idx;
94};
95
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +020096/*
97 * The common struct MUST be first because it is shared between
98 * 3945 and 4965!
99 */
100struct il3945_sta_priv {
101 struct il_station_priv_common common;
102 struct il3945_rs_sta rs_sta;
103};
104
105enum il3945_antenna {
106 IL_ANTENNA_DIVERSITY,
107 IL_ANTENNA_MAIN,
108 IL_ANTENNA_AUX
109};
110
111/*
112 * RTS threshold here is total size [2347] minus 4 FCS bytes
113 * Per spec:
114 * a value of 0 means RTS on all data/management packets
115 * a value > max MSDU size means no RTS
116 * else RTS for data/management frames where MPDU is larger
117 * than RTS value.
118 */
119#define DEFAULT_RTS_THRESHOLD 2347U
120#define MIN_RTS_THRESHOLD 0U
121#define MAX_RTS_THRESHOLD 2347U
122#define MAX_MSDU_SIZE 2304U
123#define MAX_MPDU_SIZE 2346U
124#define DEFAULT_BEACON_INTERVAL 100U
125#define DEFAULT_SHORT_RETRY_LIMIT 7U
126#define DEFAULT_LONG_RETRY_LIMIT 4U
127
128#define IL_TX_FIFO_AC0 0
129#define IL_TX_FIFO_AC1 1
130#define IL_TX_FIFO_AC2 2
131#define IL_TX_FIFO_AC3 3
132#define IL_TX_FIFO_HCCA_1 5
133#define IL_TX_FIFO_HCCA_2 6
134#define IL_TX_FIFO_NONE 7
135
136#define IEEE80211_DATA_LEN 2304
137#define IEEE80211_4ADDR_LEN 30
138#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
139#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
140
141struct il3945_frame {
142 union {
143 struct ieee80211_hdr frame;
144 struct il3945_tx_beacon_cmd beacon;
145 u8 raw[IEEE80211_FRAME_LEN];
146 u8 cmd[360];
147 } u;
148 struct list_head list;
149};
150
151#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
152#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
153#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
154
155#define SUP_RATE_11A_MAX_NUM_CHANNELS 8
156#define SUP_RATE_11B_MAX_NUM_CHANNELS 4
157#define SUP_RATE_11G_MAX_NUM_CHANNELS 12
158
159#define IL_SUPPORTED_RATES_IE_LEN 8
160
161#define SCAN_INTERVAL 100
162
163#define MAX_TID_COUNT 9
164
165#define IL_INVALID_RATE 0xFF
166#define IL_INVALID_VALUE -1
167
168#define STA_PS_STATUS_WAKE 0
169#define STA_PS_STATUS_SLEEP 1
170
171struct il3945_ibss_seq {
172 u8 mac[ETH_ALEN];
173 u16 seq_num;
174 u16 frag_num;
175 unsigned long packet_time;
176 struct list_head list;
177};
178
179#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\
180 x->u.rx_frame.stats.payload + \
181 x->u.rx_frame.stats.phy_count))
182#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\
183 IL_RX_HDR(x)->payload + \
184 le16_to_cpu(IL_RX_HDR(x)->len)))
185#define IL_RX_STATS(x) (&x->u.rx_frame.stats)
186#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload)
187
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200188/******************************************************************************
189 *
190 * Functions implemented in iwl3945-base.c which are forward declared here
191 * for use by iwl-*.c
192 *
193 *****************************************************************************/
194extern int il3945_calc_db_from_ratio(int sig_ratio);
195extern void il3945_rx_replenish(void *data);
196extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
197extern unsigned int il3945_fill_beacon_frame(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100198 struct ieee80211_hdr *hdr,
199 int left);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200200extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100201 char **buf, bool display);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200202extern void il3945_dump_nic_error_log(struct il_priv *il);
203
204/******************************************************************************
205 *
206 * Functions implemented in iwl-[34]*.c which are forward declared here
207 * for use by iwl3945-base.c
208 *
209 * NOTE: The implementation of these functions are hardware specific
210 * which is why they are in the hardware specific files (vs. iwl-base.c)
211 *
212 * Naming convention --
213 * il3945_ <-- Its part of iwlwifi (should be changed to il3945_)
214 * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
215 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
216 * il3945_bg_ <-- Called from work queue context
217 * il3945_mac_ <-- mac80211 callback
218 *
219 ****************************************************************************/
Stanislaw Gruszkad0c72342011-08-30 15:39:42 +0200220extern void il3945_hw_handler_setup(struct il_priv *il);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200221extern void il3945_hw_setup_deferred_work(struct il_priv *il);
222extern void il3945_hw_cancel_deferred_work(struct il_priv *il);
223extern int il3945_hw_rxq_stop(struct il_priv *il);
224extern int il3945_hw_set_hw_params(struct il_priv *il);
225extern int il3945_hw_nic_init(struct il_priv *il);
226extern int il3945_hw_nic_stop_master(struct il_priv *il);
227extern void il3945_hw_txq_ctx_free(struct il_priv *il);
228extern void il3945_hw_txq_ctx_stop(struct il_priv *il);
229extern int il3945_hw_nic_reset(struct il_priv *il);
230extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100231 struct il_tx_queue *txq,
232 dma_addr_t addr, u16 len, u8 reset,
233 u8 pad);
234extern void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200235extern int il3945_hw_get_temperature(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100236extern int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200237extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100238 struct il3945_frame *frame,
239 u8 rate);
240void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd,
241 struct ieee80211_tx_info *info,
242 struct ieee80211_hdr *hdr, int sta_id,
243 int tx_id);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200244extern int il3945_hw_reg_send_txpower(struct il_priv *il);
245extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100246extern void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb);
247void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200248extern void il3945_disable_events(struct il_priv *il);
249extern int il4965_get_temperature(const struct il_priv *il);
250extern void il3945_post_associate(struct il_priv *il);
251extern void il3945_config_ap(struct il_priv *il);
252
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100253extern int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200254
255/**
256 * il3945_hw_find_station - Find station id for a given BSSID
257 * @bssid: MAC address of station ID to find
258 *
259 * NOTE: This should not be hardware specific but the code has
260 * not yet been merged into a single common layer for managing the
261 * station tables.
262 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100263extern u8 il3945_hw_find_station(struct il_priv *il, const u8 * bssid);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200264
265extern struct ieee80211_ops il3945_hw_ops;
266
267extern __le32 il3945_get_antenna_flags(const struct il_priv *il);
268extern int il3945_init_hw_rate_table(struct il_priv *il);
269extern void il3945_reg_txpower_periodic(struct il_priv *il);
270extern int il3945_txpower_set_from_eeprom(struct il_priv *il);
271
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200272extern int il3945_rs_next_rate(struct il_priv *il, int rate);
273
274/* scanning */
275int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
276void il3945_post_scan(struct il_priv *il);
277
278/* rates */
279extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945];
280
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200281/* RSSI to dBm */
282#define IL39_RSSI_OFFSET 95
283
284/*
285 * EEPROM related constants, enums, and structures.
286 */
287#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
288
289/*
290 * Mapping of a Tx power level, at factory calibration temperature,
291 * to a radio/DSP gain table idx.
292 * One for each of 5 "sample" power levels in each band.
293 * v_det is measured at the factory, using the 3945's built-in power amplifier
294 * (PA) output voltage detector. This same detector is used during Tx of
295 * long packets in normal operation to provide feedback as to proper output
296 * level.
297 * Data copied from EEPROM.
298 * DO NOT ALTER THIS STRUCTURE!!!
299 */
300struct il3945_eeprom_txpower_sample {
301 u8 gain_idx; /* idx into power (gain) setup table ... */
302 s8 power; /* ... for this pwr level for this chnl group */
303 u16 v_det; /* PA output voltage */
304} __packed;
305
306/*
307 * Mappings of Tx power levels -> nominal radio/DSP gain table idxes.
308 * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
309 * Tx power setup code interpolates between the 5 "sample" power levels
310 * to determine the nominal setup for a requested power level.
311 * Data copied from EEPROM.
312 * DO NOT ALTER THIS STRUCTURE!!!
313 */
314struct il3945_eeprom_txpower_group {
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100315 struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200316 s32 a, b, c, d, e; /* coefficients for voltage->power
317 * formula (signed) */
318 s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
319 * frequency (signed) */
320 s8 saturation_power; /* highest power possible by h/w in this
321 * band */
322 u8 group_channel; /* "representative" channel # in this band */
323 s16 temperature; /* h/w temperature at factory calib this band
324 * (signed) */
325} __packed;
326
327/*
328 * Temperature-based Tx-power compensation data, not band-specific.
329 * These coefficients are use to modify a/b/c/d/e coeffs based on
330 * difference between current temperature and factory calib temperature.
331 * Data copied from EEPROM.
332 */
333struct il3945_eeprom_temperature_corr {
334 u32 Ta;
335 u32 Tb;
336 u32 Tc;
337 u32 Td;
338 u32 Te;
339} __packed;
340
341/*
342 * EEPROM map
343 */
344struct il3945_eeprom {
345 u8 reserved0[16];
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100346 u16 device_id; /* abs.ofs: 16 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200347 u8 reserved1[2];
348 u16 pmc; /* abs.ofs: 20 */
349 u8 reserved2[20];
350 u8 mac_address[6]; /* abs.ofs: 42 */
351 u8 reserved3[58];
352 u16 board_revision; /* abs.ofs: 106 */
353 u8 reserved4[11];
354 u8 board_pba_number[9]; /* abs.ofs: 119 */
355 u8 reserved5[8];
356 u16 version; /* abs.ofs: 136 */
357 u8 sku_cap; /* abs.ofs: 138 */
358 u8 leds_mode; /* abs.ofs: 139 */
359 u16 oem_mode;
360 u16 wowlan_mode; /* abs.ofs: 142 */
361 u16 leds_time_interval; /* abs.ofs: 144 */
362 u8 leds_off_time; /* abs.ofs: 146 */
363 u8 leds_on_time; /* abs.ofs: 147 */
364 u8 almgor_m_version; /* abs.ofs: 148 */
365 u8 antenna_switch_type; /* abs.ofs: 149 */
366 u8 reserved6[42];
367 u8 sku_id[4]; /* abs.ofs: 192 */
368
369/*
370 * Per-channel regulatory data.
371 *
372 * Each channel that *might* be supported by 3945 has a fixed location
373 * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
374 * txpower (MSB).
375 *
376 * Entries immediately below are for 20 MHz channel width.
377 *
378 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
379 */
380 u16 band_1_count; /* abs.ofs: 196 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100381 struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200382
383/*
384 * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
385 * 5.0 GHz channels 7, 8, 11, 12, 16
386 * (4915-5080MHz) (none of these is ever supported)
387 */
388 u16 band_2_count; /* abs.ofs: 226 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100389 struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200390
391/*
392 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
393 * (5170-5320MHz)
394 */
395 u16 band_3_count; /* abs.ofs: 254 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100396 struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200397
398/*
399 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
400 * (5500-5700MHz)
401 */
402 u16 band_4_count; /* abs.ofs: 280 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100403 struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200404
405/*
406 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
407 * (5725-5825MHz)
408 */
409 u16 band_5_count; /* abs.ofs: 304 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100410 struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200411
412 u8 reserved9[194];
413
414/*
415 * 3945 Txpower calibration data.
416 */
417#define IL_NUM_TX_CALIB_GROUPS 5
418 struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS];
419/* abs.ofs: 512 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100420 struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200421 u8 reserved16[172]; /* fill out to full 1024 byte block */
422} __packed;
423
424#define IL3945_EEPROM_IMG_SIZE 1024
425
426/* End of EEPROM */
427
428#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
429#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
430
431/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */
432#define IL39_NUM_QUEUES 5
433#define IL39_CMD_QUEUE_NUM 4
434
435#define IL_DEFAULT_TX_RETRY 15
436
437/*********************************************/
438
439#define RFD_SIZE 4
440#define NUM_TFD_CHUNKS 4
441
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200442#define TFD_CTL_COUNT_SET(n) (n << 24)
443#define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7)
444#define TFD_CTL_PAD_SET(n) (n << 28)
445#define TFD_CTL_PAD_GET(ctl) (ctl >> 28)
446
447/* Sizes and addresses for instruction and data memory (SRAM) in
448 * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
449#define IL39_RTC_INST_LOWER_BOUND (0x000000)
450#define IL39_RTC_INST_UPPER_BOUND (0x014000)
451
452#define IL39_RTC_DATA_LOWER_BOUND (0x800000)
453#define IL39_RTC_DATA_UPPER_BOUND (0x808000)
454
455#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \
456 IL39_RTC_INST_LOWER_BOUND)
457#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \
458 IL39_RTC_DATA_LOWER_BOUND)
459
460#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE
461#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE
462
463/* Size of uCode instruction memory in bootstrap state machine */
464#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE
465
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100466static inline int
467il3945_hw_valid_rtc_data_addr(u32 addr)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200468{
469 return (addr >= IL39_RTC_DATA_LOWER_BOUND &&
470 addr < IL39_RTC_DATA_UPPER_BOUND);
471}
472
Stanislaw Gruszka53143a12011-08-31 14:14:18 +0200473/* Base physical address of il3945_shared is provided to FH39_TSSR_CBB_BASE
474 * and &il3945_shared.rx_read_ptr[0] is provided to FH39_RCSR_RPTR_ADDR(0) */
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200475struct il3945_shared {
476 __le32 tx_base_ptr[8];
477} __packed;
478
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100479static inline u8
480il3945_hw_get_rate(__le16 rate_n_flags)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200481{
482 return le16_to_cpu(rate_n_flags) & 0xFF;
483}
484
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100485static inline u16
486il3945_hw_get_rate_n_flags(__le16 rate_n_flags)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200487{
488 return le16_to_cpu(rate_n_flags);
489}
490
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100491static inline __le16
492il3945_hw_set_rate_n_flags(u8 rate, u16 flags)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200493{
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100494 return cpu_to_le16((u16) rate | flags);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200495}
496
497/************************************/
498/* iwl3945 Flow Handler Definitions */
499/************************************/
500
501/**
502 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
503 * Addresses are offsets from device's PCI hardware base address.
504 */
505#define FH39_MEM_LOWER_BOUND (0x0800)
506#define FH39_MEM_UPPER_BOUND (0x1000)
507
508#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140)
509#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180)
510#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400)
511#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0)
512#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500)
513#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680)
514
515/* TFDB (Transmit Frame Buffer Descriptor) */
516#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \
517 ((_ch) * 2 + (buf)) * 0x28)
518#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch))
519
520/* CBCC channel is [0,2] */
521#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8)
522#define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00)
523#define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04)
524
525/* RCSR channel is [0,2] */
526#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40)
527#define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00)
528#define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04)
529#define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20)
530#define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24)
531
532#define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0))
533
534/* RSSR */
535#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000)
536#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004)
537
538/* TCSR */
539#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20)
540#define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00)
541#define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04)
542#define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08)
543
544/* TSSR */
545#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000)
546#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008)
547#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010)
548
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200549/* DBM */
550
551#define FH39_SRVC_CHNL (6)
552
553#define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
554#define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
555
556#define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
557
558#define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
559
560#define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
561
562#define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
563
564#define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
565
566#define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
567
568#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
569#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
570
571#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
572#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
573
574#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
575
576#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
577
578#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
579#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
580
581#define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
582
583#define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
584
585#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
586#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
587
588#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
589
590#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
591#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
592
593#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
594#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
595
596#define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24)
597#define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16)
598
599#define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \
600 (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \
601 FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch))
602
603#define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
604
605struct il3945_tfd_tb {
606 __le32 addr;
607 __le32 len;
608} __packed;
609
610struct il3945_tfd {
611 __le32 control_flags;
612 struct il3945_tfd_tb tbs[4];
613 u8 __pad[28];
614} __packed;
615
616#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100617ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
618 size_t count, loff_t *ppos);
619ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
620 size_t count, loff_t *ppos);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200621ssize_t il3945_ucode_general_stats_read(struct file *file,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100622 char __user *user_buf, size_t count,
623 loff_t *ppos);
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200624#else
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100625static ssize_t
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100626il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
627 size_t count, loff_t *ppos)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200628{
629 return 0;
630}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100631
632static ssize_t
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100633il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
634 size_t count, loff_t *ppos)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200635{
636 return 0;
637}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100638
639static ssize_t
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100640il3945_ucode_general_stats_read(struct file *file, char __user *user_buf,
641 size_t count, loff_t *ppos)
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200642{
643 return 0;
644}
645#endif
646
Stanislaw Gruszka6bbb1372011-08-30 14:12:12 +0200647#endif