blob: 4741fa228315e75b2f32fe95a7367a8cc85676f4 [file] [log] [blame]
Zhu Yib481de92007-09-25 17:54:57 -07001/******************************************************************************
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
Ian Schram01ebd062007-10-25 17:15:22 +080011 * it under the terms of version 2 of the GNU General Public License as
Zhu Yib481de92007-09-25 17:54:57 -070012 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22 * USA
23 *
24 * The full GNU General Public License is included in this distribution
25 * in the file called LICENSE.GPL.
26 *
27 * Contact Information:
28 * James P. Ketrenos <ipw2100-admin@linux.intel.com>
29 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30 *
31 * BSD LICENSE
32 *
33 * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
34 * All rights reserved.
35 *
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
38 * are met:
39 *
40 * * Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * * Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in
44 * the documentation and/or other materials provided with the
45 * distribution.
46 * * Neither the name Intel Corporation nor the names of its
47 * contributors may be used to endorse or promote products derived
48 * from this software without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61 *
62 *****************************************************************************/
63
64#ifndef __iwl_4965_hw_h__
65#define __iwl_4965_hw_h__
66
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080067/* uCode queue management definitions */
68#define IWL_CMD_QUEUE_NUM 4
69#define IWL_CMD_FIFO_NUM 4
70#define IWL_BACK_QUEUE_FIRST_ID 7
71
72/* Tx rates */
73#define IWL_CCK_RATES 4
74#define IWL_OFDM_RATES 8
75
76#define IWL_HT_RATES 16
77
78#define IWL_MAX_RATES (IWL_CCK_RATES+IWL_OFDM_RATES+IWL_HT_RATES)
79
80/* Time constants */
81#define SHORT_SLOT_TIME 9
82#define LONG_SLOT_TIME 20
83
84/* RSSI to dBm */
85#define IWL_RSSI_OFFSET 44
86
87/*
Ben Cahill796083c2007-11-29 11:09:45 +080088 * EEPROM related constants, enums, and structures.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080089 */
90
Ben Cahill796083c2007-11-29 11:09:45 +080091/*
92 * EEPROM access time values:
93 *
94 * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG,
95 * then clearing (with subsequent read/modify/write) CSR_EEPROM_REG bit
96 * CSR_EEPROM_REG_BIT_CMD (0x2).
97 * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
98 * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
99 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
100 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800101#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
102#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
Ben Cahill796083c2007-11-29 11:09:45 +0800103
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800104/* EEPROM field values */
105#define ANTENNA_SWITCH_NORMAL 0
106#define ANTENNA_SWITCH_INVERSE 1
107
Ben Cahill796083c2007-11-29 11:09:45 +0800108/*
109 * Regulatory channel usage flags in EEPROM struct iwl4965_eeprom_channel.flags.
110 *
111 * IBSS and/or AP operation is allowed *only* on those channels with
112 * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
113 * RADAR detection is not supported by the 4965 driver, but is a
114 * requirement for establishing a new network for legal operation on channels
115 * requiring RADAR detection or restricting ACTIVE scanning.
116 *
117 * NOTE: "WIDE" flag does not indicate anything about "FAT" 40 MHz channels.
118 * It only indicates that 20 MHz channel use is supported; FAT channel
119 * usage is indicated by a separate set of regulatory flags for each
120 * FAT channel pair.
121 *
122 * NOTE: Using a channel inappropriately will result in a uCode error!
123 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800124enum {
125 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
Ben Cahill796083c2007-11-29 11:09:45 +0800126 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800127 /* Bit 2 Reserved */
128 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
129 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
Ben Cahill796083c2007-11-29 11:09:45 +0800130 EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
131 EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel, not used */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800132 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
133};
134
135/* EEPROM field lengths */
136#define EEPROM_BOARD_PBA_NUMBER_LENGTH 11
137
138/* EEPROM field lengths */
139#define EEPROM_BOARD_PBA_NUMBER_LENGTH 11
140#define EEPROM_REGULATORY_SKU_ID_LENGTH 4
141#define EEPROM_REGULATORY_BAND1_CHANNELS_LENGTH 14
142#define EEPROM_REGULATORY_BAND2_CHANNELS_LENGTH 13
143#define EEPROM_REGULATORY_BAND3_CHANNELS_LENGTH 12
144#define EEPROM_REGULATORY_BAND4_CHANNELS_LENGTH 11
145#define EEPROM_REGULATORY_BAND5_CHANNELS_LENGTH 6
146
147#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS_LENGTH 7
148#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS_LENGTH 11
149#define EEPROM_REGULATORY_CHANNELS_LENGTH ( \
150 EEPROM_REGULATORY_BAND1_CHANNELS_LENGTH + \
151 EEPROM_REGULATORY_BAND2_CHANNELS_LENGTH + \
152 EEPROM_REGULATORY_BAND3_CHANNELS_LENGTH + \
153 EEPROM_REGULATORY_BAND4_CHANNELS_LENGTH + \
154 EEPROM_REGULATORY_BAND5_CHANNELS_LENGTH + \
155 EEPROM_REGULATORY_BAND_24_FAT_CHANNELS_LENGTH + \
156 EEPROM_REGULATORY_BAND_52_FAT_CHANNELS_LENGTH)
157
158#define EEPROM_REGULATORY_NUMBER_OF_BANDS 5
159
160/* SKU Capabilities */
161#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
162#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
163#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
164
Ben Cahill796083c2007-11-29 11:09:45 +0800165/* *regulatory* channel data format in eeprom, one for each channel.
166 * There are separate entries for FAT (40 MHz) vs. normal (20 MHz) channels. */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800167struct iwl4965_eeprom_channel {
Ben Cahill796083c2007-11-29 11:09:45 +0800168 u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800169 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
170} __attribute__ ((packed));
171
172/*
173 * Mapping of a Tx power level, at factory calibration temperature,
174 * to a radio/DSP gain table index.
175 * One for each of 5 "sample" power levels in each band.
176 * v_det is measured at the factory, using the 3945's built-in power amplifier
177 * (PA) output voltage detector. This same detector is used during Tx of
178 * long packets in normal operation to provide feedback as to proper output
179 * level.
180 * Data copied from EEPROM.
181 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800182struct iwl4965_eeprom_txpower_sample {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800183 u8 gain_index; /* index into power (gain) setup table ... */
184 s8 power; /* ... for this pwr level for this chnl group */
185 u16 v_det; /* PA output voltage */
186} __attribute__ ((packed));
187
188/*
189 * Mappings of Tx power levels -> nominal radio/DSP gain table indexes.
190 * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
191 * Tx power setup code interpolates between the 5 "sample" power levels
192 * to determine the nominal setup for a requested power level.
193 * Data copied from EEPROM.
194 * DO NOT ALTER THIS STRUCTURE!!!
195 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800196struct iwl4965_eeprom_txpower_group {
197 struct iwl4965_eeprom_txpower_sample samples[5]; /* 5 power levels */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800198 s32 a, b, c, d, e; /* coefficients for voltage->power
199 * formula (signed) */
200 s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
201 * frequency (signed) */
202 s8 saturation_power; /* highest power possible by h/w in this
203 * band */
204 u8 group_channel; /* "representative" channel # in this band */
205 s16 temperature; /* h/w temperature at factory calib this band
206 * (signed) */
207} __attribute__ ((packed));
208
209/*
210 * Temperature-based Tx-power compensation data, not band-specific.
211 * These coefficients are use to modify a/b/c/d/e coeffs based on
212 * difference between current temperature and factory calib temperature.
213 * Data copied from EEPROM.
214 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800215struct iwl4965_eeprom_temperature_corr {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800216 u32 Ta;
217 u32 Tb;
218 u32 Tc;
219 u32 Td;
220 u32 Te;
221} __attribute__ ((packed));
222
Ben Cahill796083c2007-11-29 11:09:45 +0800223/* 4965 has two radio transmitters (and 3 radio receivers) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800224#define EEPROM_TX_POWER_TX_CHAINS (2)
Ben Cahill796083c2007-11-29 11:09:45 +0800225
226/* 4965 has room for up to 8 sets of txpower calibration data */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800227#define EEPROM_TX_POWER_BANDS (8)
Ben Cahill796083c2007-11-29 11:09:45 +0800228
229/* 4965 factory calibration measures txpower gain settings for
230 * each of 3 target output levels */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800231#define EEPROM_TX_POWER_MEASUREMENTS (3)
Ben Cahill796083c2007-11-29 11:09:45 +0800232
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800233#define EEPROM_TX_POWER_VERSION (2)
Ben Cahill796083c2007-11-29 11:09:45 +0800234
235/* 4965 driver does not work with txpower calibration version < 5.
236 * Look for this in calib_version member of struct iwl4965_eeprom. */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800237#define EEPROM_TX_POWER_VERSION_NEW (5)
238
Ben Cahill796083c2007-11-29 11:09:45 +0800239
240/*
241 * 4965 factory calibration data for one txpower level, on one channel,
242 * measured on one of the 2 tx chains (radio transmitter and associated
243 * antenna). EEPROM contains:
244 *
245 * 1) Temperature (degrees Celsius) of device when measurement was made.
246 *
247 * 2) Gain table index used to achieve the target measurement power.
248 * This refers to the "well-known" gain tables (see iwl-4965-hw.h).
249 *
250 * 3) Actual measured output power, in half-dBm ("34" = 17 dBm).
251 *
252 * 4) RF power amplifier detector level measurement (not used).
253 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800254struct iwl4965_eeprom_calib_measure {
Ben Cahill796083c2007-11-29 11:09:45 +0800255 u8 temperature; /* Device temperature (Celsius) */
256 u8 gain_idx; /* Index into gain table */
257 u8 actual_pow; /* Measured RF output power, half-dBm */
258 s8 pa_det; /* Power amp detector level (not used) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800259} __attribute__ ((packed));
260
Ben Cahill796083c2007-11-29 11:09:45 +0800261
262/*
263 * 4965 measurement set for one channel. EEPROM contains:
264 *
265 * 1) Channel number measured
266 *
267 * 2) Measurements for each of 3 power levels for each of 2 radio transmitters
268 * (a.k.a. "tx chains") (6 measurements altogether)
269 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800270struct iwl4965_eeprom_calib_ch_info {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800271 u8 ch_num;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800272 struct iwl4965_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS]
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800273 [EEPROM_TX_POWER_MEASUREMENTS];
274} __attribute__ ((packed));
275
Ben Cahill796083c2007-11-29 11:09:45 +0800276/*
277 * 4965 txpower subband info.
278 *
279 * For each frequency subband, EEPROM contains the following:
280 *
281 * 1) First and last channels within range of the subband. "0" values
282 * indicate that this sample set is not being used.
283 *
284 * 2) Sample measurement sets for 2 channels close to the range endpoints.
285 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800286struct iwl4965_eeprom_calib_subband_info {
Ben Cahill796083c2007-11-29 11:09:45 +0800287 u8 ch_from; /* channel number of lowest channel in subband */
288 u8 ch_to; /* channel number of highest channel in subband */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800289 struct iwl4965_eeprom_calib_ch_info ch1;
290 struct iwl4965_eeprom_calib_ch_info ch2;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800291} __attribute__ ((packed));
292
Ben Cahill796083c2007-11-29 11:09:45 +0800293
294/*
295 * 4965 txpower calibration info. EEPROM contains:
296 *
297 * 1) Factory-measured saturation power levels (maximum levels at which
298 * tx power amplifier can output a signal without too much distortion).
299 * There is one level for 2.4 GHz band and one for 5 GHz band. These
300 * values apply to all channels within each of the bands.
301 *
302 * 2) Factory-measured power supply voltage level. This is assumed to be
303 * constant (i.e. same value applies to all channels/bands) while the
304 * factory measurements are being made.
305 *
306 * 3) Up to 8 sets of factory-measured txpower calibration values.
307 * These are for different frequency ranges, since txpower gain
308 * characteristics of the analog radio circuitry vary with frequency.
309 *
310 * Not all sets need to be filled with data;
311 * struct iwl4965_eeprom_calib_subband_info contains range of channels
312 * (0 if unused) for each set of data.
313 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800314struct iwl4965_eeprom_calib_info {
Ben Cahill796083c2007-11-29 11:09:45 +0800315 u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
316 u8 saturation_power52; /* half-dBm */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800317 s16 voltage; /* signed */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800318 struct iwl4965_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800319} __attribute__ ((packed));
320
321
Ben Cahill796083c2007-11-29 11:09:45 +0800322/*
323 * 4965 EEPROM map
324 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800325struct iwl4965_eeprom {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800326 u8 reserved0[16];
327#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800328 u16 device_id; /* abs.ofs: 16 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800329 u8 reserved1[2];
330#define EEPROM_PMC (2*0x0A) /* 2 bytes */
331 u16 pmc; /* abs.ofs: 20 */
332 u8 reserved2[20];
333#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
334 u8 mac_address[6]; /* abs.ofs: 42 */
335 u8 reserved3[58];
336#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
337 u16 board_revision; /* abs.ofs: 106 */
338 u8 reserved4[11];
339#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
340 u8 board_pba_number[9]; /* abs.ofs: 119 */
341 u8 reserved5[8];
342#define EEPROM_VERSION (2*0x44) /* 2 bytes */
343 u16 version; /* abs.ofs: 136 */
344#define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
345 u8 sku_cap; /* abs.ofs: 138 */
346#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
347 u8 leds_mode; /* abs.ofs: 139 */
348#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
349 u16 oem_mode;
350#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
351 u16 wowlan_mode; /* abs.ofs: 142 */
352#define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
353 u16 leds_time_interval; /* abs.ofs: 144 */
354#define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
355 u8 leds_off_time; /* abs.ofs: 146 */
356#define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
357 u8 leds_on_time; /* abs.ofs: 147 */
358#define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
359 u8 almgor_m_version; /* abs.ofs: 148 */
360#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
361 u8 antenna_switch_type; /* abs.ofs: 149 */
362 u8 reserved6[8];
363#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
364 u16 board_revision_4965; /* abs.ofs: 158 */
365 u8 reserved7[13];
366#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
367 u8 board_pba_number_4965[9]; /* abs.ofs: 173 */
368 u8 reserved8[10];
369#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
370 u8 sku_id[4]; /* abs.ofs: 192 */
Ben Cahill796083c2007-11-29 11:09:45 +0800371
372/*
373 * Per-channel regulatory data.
374 *
375 * Each channel that *might* be supported by 3945 or 4965 has a fixed location
376 * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
377 * txpower (MSB).
378 *
379 * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
380 * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
381 *
382 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
383 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800384#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
385 u16 band_1_count; /* abs.ofs: 196 */
386#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800387 struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
388
389/*
390 * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
391 * 5.0 GHz channels 7, 8, 11, 12, 16
392 * (4915-5080MHz) (none of these is ever supported)
393 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800394#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
395 u16 band_2_count; /* abs.ofs: 226 */
396#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800397 struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
398
399/*
400 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
401 * (5170-5320MHz)
402 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800403#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
404 u16 band_3_count; /* abs.ofs: 254 */
405#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800406 struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
407
408/*
409 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
410 * (5500-5700MHz)
411 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800412#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
413 u16 band_4_count; /* abs.ofs: 280 */
414#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800415 struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
416
417/*
418 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
419 * (5725-5825MHz)
420 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800421#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
422 u16 band_5_count; /* abs.ofs: 304 */
423#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800424 struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800425
426 u8 reserved10[2];
Ben Cahill796083c2007-11-29 11:09:45 +0800427
428
429/*
430 * 2.4 GHz FAT channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11)
431 *
432 * The channel listed is the center of the lower 20 MHz half of the channel.
433 * The overall center frequency is actually 2 channels (10 MHz) above that,
434 * and the upper half of each FAT channel is centered 4 channels (20 MHz) away
435 * from the lower half; e.g. the upper half of FAT channel 1 is channel 5,
436 * and the overall FAT channel width centers on channel 3.
437 *
438 * NOTE: The RXON command uses 20 MHz channel numbers to specify the
439 * control channel to which to tune. RXON also specifies whether the
440 * control channel is the upper or lower half of a FAT channel.
441 *
442 * NOTE: 4965 does not support FAT channels on 2.4 GHz.
443 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800444#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800445 struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800446 u8 reserved11[2];
Ben Cahill796083c2007-11-29 11:09:45 +0800447
448/*
449 * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64),
450 * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
451 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800452#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800453 struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800454 u8 reserved12[6];
Ben Cahill796083c2007-11-29 11:09:45 +0800455
456/*
457 * 4965 driver requires txpower calibration format version 5 or greater.
458 * Driver does not work with txpower calibration version < 5.
459 * This value is simply a 16-bit number, no major/minor versions here.
460 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800461#define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
462 u16 calib_version; /* abs.ofs: 364 */
463 u8 reserved13[2];
Ben Cahill796083c2007-11-29 11:09:45 +0800464
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800465#define EEPROM_SATURATION_POWER_OFFSET (2*0xB8) /* 2 bytes */
466 u16 satruation_power; /* abs.ofs: 368 */
467 u8 reserved14[94];
Ben Cahill796083c2007-11-29 11:09:45 +0800468
469/*
470 * 4965 Txpower calibration data.
471 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800472#define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800473 struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800474
475 u8 reserved16[140]; /* fill out to full 1024 byte block */
476
477
478} __attribute__ ((packed));
479
480#define IWL_EEPROM_IMAGE_SIZE 1024
481
Ben Cahill796083c2007-11-29 11:09:45 +0800482/* End of EEPROM */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800483
484#include "iwl-4965-commands.h"
485
486#define PCI_LINK_CTRL 0x0F0
487#define PCI_POWER_SOURCE 0x0C8
488#define PCI_REG_WUM8 0x0E8
489#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
490
491/*=== CSR (control and status registers) ===*/
492#define CSR_BASE (0x000)
493
494#define CSR_SW_VER (CSR_BASE+0x000)
495#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */
496#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */
497#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */
498#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */
499#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/
500#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */
501#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
502#define CSR_GP_CNTRL (CSR_BASE+0x024)
503#define CSR_HW_REV (CSR_BASE+0x028)
504#define CSR_EEPROM_REG (CSR_BASE+0x02c)
505#define CSR_EEPROM_GP (CSR_BASE+0x030)
506#define CSR_GP_UCODE (CSR_BASE+0x044)
507#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
508#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058)
509#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
510#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
511#define CSR_LED_REG (CSR_BASE+0x094)
512#define CSR_DRAM_INT_TBL_CTL (CSR_BASE+0x0A0)
513#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
514#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
515#define CSR_HW_REV_WA_REG (CSR_BASE+0x22C)
516
517/* HW I/F configuration */
518#define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB (0x00000100)
519#define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM (0x00000200)
520#define CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400)
521#define CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800)
522#define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000)
523#define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000)
524#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
525
526/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
527 * acknowledged (reset) by host writing "1" to flagged bits. */
528#define CSR_INT_BIT_FH_RX (1<<31) /* Rx DMA, cmd responses, FH_INT[17:16] */
529#define CSR_INT_BIT_HW_ERR (1<<29) /* DMA hardware error FH_INT[31] */
530#define CSR_INT_BIT_DNLD (1<<28) /* uCode Download */
531#define CSR_INT_BIT_FH_TX (1<<27) /* Tx DMA FH_INT[1:0] */
532#define CSR_INT_BIT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
533#define CSR_INT_BIT_SW_ERR (1<<25) /* uCode error */
534#define CSR_INT_BIT_RF_KILL (1<<7) /* HW RFKILL switch GP_CNTRL[27] toggled */
535#define CSR_INT_BIT_CT_KILL (1<<6) /* Critical temp (chip too hot) rfkill */
536#define CSR_INT_BIT_SW_RX (1<<3) /* Rx, command responses, 3945 */
537#define CSR_INT_BIT_WAKEUP (1<<1) /* NIC controller waking up (pwr mgmt) */
538#define CSR_INT_BIT_ALIVE (1<<0) /* uCode interrupts once it initializes */
539
540#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \
541 CSR_INT_BIT_HW_ERR | \
542 CSR_INT_BIT_FH_TX | \
543 CSR_INT_BIT_SW_ERR | \
544 CSR_INT_BIT_RF_KILL | \
545 CSR_INT_BIT_SW_RX | \
546 CSR_INT_BIT_WAKEUP | \
547 CSR_INT_BIT_ALIVE)
548
549/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
550#define CSR_FH_INT_BIT_ERR (1<<31) /* Error */
551#define CSR_FH_INT_BIT_HI_PRIOR (1<<30) /* High priority Rx, bypass coalescing */
552#define CSR_FH_INT_BIT_RX_CHNL2 (1<<18) /* Rx channel 2 (3945 only) */
553#define CSR_FH_INT_BIT_RX_CHNL1 (1<<17) /* Rx channel 1 */
554#define CSR_FH_INT_BIT_RX_CHNL0 (1<<16) /* Rx channel 0 */
555#define CSR_FH_INT_BIT_TX_CHNL6 (1<<6) /* Tx channel 6 (3945 only) */
556#define CSR_FH_INT_BIT_TX_CHNL1 (1<<1) /* Tx channel 1 */
557#define CSR_FH_INT_BIT_TX_CHNL0 (1<<0) /* Tx channel 0 */
558
559#define CSR_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \
560 CSR_FH_INT_BIT_RX_CHNL2 | \
561 CSR_FH_INT_BIT_RX_CHNL1 | \
562 CSR_FH_INT_BIT_RX_CHNL0)
563
564#define CSR_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL6 | \
565 CSR_FH_INT_BIT_TX_CHNL1 | \
Jeff Garzik93a3b602007-11-23 21:50:20 -0500566 CSR_FH_INT_BIT_TX_CHNL0)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800567
568
569/* RESET */
570#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001)
571#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002)
572#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080)
573#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100)
574#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200)
575
576/* GP (general purpose) CONTROL */
577#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001)
578#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
579#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008)
580#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
581
582#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001)
583
584#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000)
585#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000)
586#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000)
587
588
589/* EEPROM REG */
590#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
591#define CSR_EEPROM_REG_BIT_CMD (0x00000002)
592
593/* EEPROM GP */
594#define CSR_EEPROM_GP_VALID_MSK (0x00000006)
595#define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
596#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
597
598/* UCODE DRV GP */
599#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001)
600#define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
601#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
602#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
603
604/* GPIO */
605#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200)
606#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000)
607#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC CSR_GPIO_IN_BIT_AUX_POWER
608
609/* GI Chicken Bits */
610#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
611#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
612
613/* CSR_ANA_PLL_CFG */
614#define CSR_ANA_PLL_CFG_SH (0x00880300)
615
616#define CSR_LED_REG_TRUN_ON (0x00000078)
617#define CSR_LED_REG_TRUN_OFF (0x00000038)
618#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
619
620/* DRAM_INT_TBL_CTRL */
621#define CSR_DRAM_INT_TBL_CTRL_EN (1<<31)
622#define CSR_DRAM_INT_TBL_CTRL_WRAP_CHK (1<<27)
623
624/*=== HBUS (Host-side Bus) ===*/
625#define HBUS_BASE (0x400)
626
627#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c)
628#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010)
629#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018)
630#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c)
631#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044)
632#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048)
633#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c)
634#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050)
635#define HBUS_TARG_WRPTR (HBUS_BASE+0x060)
636
637#define HBUS_TARG_MBX_C (HBUS_BASE+0x030)
638
639
640/* SCD (Scheduler) */
641#define SCD_BASE (CSR_BASE + 0x2E00)
642
643#define SCD_MODE_REG (SCD_BASE + 0x000)
644#define SCD_ARASTAT_REG (SCD_BASE + 0x004)
645#define SCD_TXFACT_REG (SCD_BASE + 0x010)
646#define SCD_TXF4MF_REG (SCD_BASE + 0x014)
647#define SCD_TXF5MF_REG (SCD_BASE + 0x020)
648#define SCD_SBYP_MODE_1_REG (SCD_BASE + 0x02C)
649#define SCD_SBYP_MODE_2_REG (SCD_BASE + 0x030)
650
651/*=== FH (data Flow Handler) ===*/
652#define FH_BASE (0x800)
653
654#define FH_CBCC_TABLE (FH_BASE+0x140)
655#define FH_TFDB_TABLE (FH_BASE+0x180)
656#define FH_RCSR_TABLE (FH_BASE+0x400)
657#define FH_RSSR_TABLE (FH_BASE+0x4c0)
658#define FH_TCSR_TABLE (FH_BASE+0x500)
659#define FH_TSSR_TABLE (FH_BASE+0x680)
660
661/* TFDB (Transmit Frame Buffer Descriptor) */
662#define FH_TFDB(_channel, buf) \
663 (FH_TFDB_TABLE+((_channel)*2+(buf))*0x28)
664#define ALM_FH_TFDB_CHNL_BUF_CTRL_REG(_channel) \
665 (FH_TFDB_TABLE + 0x50 * _channel)
666/* CBCC _channel is [0,2] */
667#define FH_CBCC(_channel) (FH_CBCC_TABLE+(_channel)*0x8)
668#define FH_CBCC_CTRL(_channel) (FH_CBCC(_channel)+0x00)
669#define FH_CBCC_BASE(_channel) (FH_CBCC(_channel)+0x04)
670
671/* RCSR _channel is [0,2] */
672#define FH_RCSR(_channel) (FH_RCSR_TABLE+(_channel)*0x40)
673#define FH_RCSR_CONFIG(_channel) (FH_RCSR(_channel)+0x00)
674#define FH_RCSR_RBD_BASE(_channel) (FH_RCSR(_channel)+0x04)
675#define FH_RCSR_WPTR(_channel) (FH_RCSR(_channel)+0x20)
676#define FH_RCSR_RPTR_ADDR(_channel) (FH_RCSR(_channel)+0x24)
677
678#define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
679
680/* RSSR */
681#define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
682#define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
683/* TCSR */
684#define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
685#define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
686#define FH_TCSR_CREDIT(_channel) (FH_TCSR(_channel)+0x04)
687#define FH_TCSR_BUFF_STTS(_channel) (FH_TCSR(_channel)+0x08)
688/* TSSR */
689#define FH_TSSR_CBB_BASE (FH_TSSR_TABLE+0x000)
690#define FH_TSSR_MSG_CONFIG (FH_TSSR_TABLE+0x008)
691#define FH_TSSR_TX_STATUS (FH_TSSR_TABLE+0x010)
692/* 18 - reserved */
693
694/* card static random access memory (SRAM) for processor data and instructs */
695#define RTC_INST_LOWER_BOUND (0x000000)
696#define RTC_DATA_LOWER_BOUND (0x800000)
697
698
699/* DBM */
700
701#define ALM_FH_SRVC_CHNL (6)
702
703#define ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
704#define ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
705
706#define ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
707
708#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
709
710#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
711
712#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
713
714#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
715
716#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
717
718#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
719#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
720
721#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
722#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
723
724#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
725
726#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
727
728#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
729#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
730
731#define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
732
733#define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
734
735#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
736#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
737
738#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
739
740#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
741#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
742
743#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
744#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
745
746#define ALM_TB_MAX_BYTES_COUNT (0xFFF0)
747
748#define ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
749 ((1LU << _channel) << 24)
750#define ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
751 ((1LU << _channel) << 16)
752
753#define ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
754 (ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
755 ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
756#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
757#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
758
759#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004)
760
761#define TFD_QUEUE_MIN 0
762#define TFD_QUEUE_MAX 6
763#define TFD_QUEUE_SIZE_MAX (256)
764
765/* spectrum and channel data structures */
766#define IWL_NUM_SCAN_RATES (2)
767
768#define IWL_SCAN_FLAG_24GHZ (1<<0)
769#define IWL_SCAN_FLAG_52GHZ (1<<1)
770#define IWL_SCAN_FLAG_ACTIVE (1<<2)
771#define IWL_SCAN_FLAG_DIRECT (1<<3)
772
773#define IWL_MAX_CMD_SIZE 1024
774
775#define IWL_DEFAULT_TX_RETRY 15
776#define IWL_MAX_TX_RETRY 16
777
778/*********************************************/
779
780#define RFD_SIZE 4
781#define NUM_TFD_CHUNKS 4
782
783#define RX_QUEUE_SIZE 256
784#define RX_QUEUE_MASK 255
785#define RX_QUEUE_SIZE_LOG 8
786
787/* QoS definitions */
788
789#define CW_MIN_OFDM 15
790#define CW_MAX_OFDM 1023
791#define CW_MIN_CCK 31
792#define CW_MAX_CCK 1023
793
794#define QOS_TX0_CW_MIN_OFDM CW_MIN_OFDM
795#define QOS_TX1_CW_MIN_OFDM CW_MIN_OFDM
796#define QOS_TX2_CW_MIN_OFDM ((CW_MIN_OFDM + 1) / 2 - 1)
797#define QOS_TX3_CW_MIN_OFDM ((CW_MIN_OFDM + 1) / 4 - 1)
798
799#define QOS_TX0_CW_MIN_CCK CW_MIN_CCK
800#define QOS_TX1_CW_MIN_CCK CW_MIN_CCK
801#define QOS_TX2_CW_MIN_CCK ((CW_MIN_CCK + 1) / 2 - 1)
802#define QOS_TX3_CW_MIN_CCK ((CW_MIN_CCK + 1) / 4 - 1)
803
804#define QOS_TX0_CW_MAX_OFDM CW_MAX_OFDM
805#define QOS_TX1_CW_MAX_OFDM CW_MAX_OFDM
806#define QOS_TX2_CW_MAX_OFDM CW_MIN_OFDM
807#define QOS_TX3_CW_MAX_OFDM ((CW_MIN_OFDM + 1) / 2 - 1)
808
809#define QOS_TX0_CW_MAX_CCK CW_MAX_CCK
810#define QOS_TX1_CW_MAX_CCK CW_MAX_CCK
811#define QOS_TX2_CW_MAX_CCK CW_MIN_CCK
812#define QOS_TX3_CW_MAX_CCK ((CW_MIN_CCK + 1) / 2 - 1)
813
814#define QOS_TX0_AIFS 3
815#define QOS_TX1_AIFS 7
816#define QOS_TX2_AIFS 2
817#define QOS_TX3_AIFS 2
818
819#define QOS_TX0_ACM 0
820#define QOS_TX1_ACM 0
821#define QOS_TX2_ACM 0
822#define QOS_TX3_ACM 0
823
824#define QOS_TX0_TXOP_LIMIT_CCK 0
825#define QOS_TX1_TXOP_LIMIT_CCK 0
826#define QOS_TX2_TXOP_LIMIT_CCK 6016
827#define QOS_TX3_TXOP_LIMIT_CCK 3264
828
829#define QOS_TX0_TXOP_LIMIT_OFDM 0
830#define QOS_TX1_TXOP_LIMIT_OFDM 0
831#define QOS_TX2_TXOP_LIMIT_OFDM 3008
832#define QOS_TX3_TXOP_LIMIT_OFDM 1504
833
834#define DEF_TX0_CW_MIN_OFDM CW_MIN_OFDM
835#define DEF_TX1_CW_MIN_OFDM CW_MIN_OFDM
836#define DEF_TX2_CW_MIN_OFDM CW_MIN_OFDM
837#define DEF_TX3_CW_MIN_OFDM CW_MIN_OFDM
838
839#define DEF_TX0_CW_MIN_CCK CW_MIN_CCK
840#define DEF_TX1_CW_MIN_CCK CW_MIN_CCK
841#define DEF_TX2_CW_MIN_CCK CW_MIN_CCK
842#define DEF_TX3_CW_MIN_CCK CW_MIN_CCK
843
844#define DEF_TX0_CW_MAX_OFDM CW_MAX_OFDM
845#define DEF_TX1_CW_MAX_OFDM CW_MAX_OFDM
846#define DEF_TX2_CW_MAX_OFDM CW_MAX_OFDM
847#define DEF_TX3_CW_MAX_OFDM CW_MAX_OFDM
848
849#define DEF_TX0_CW_MAX_CCK CW_MAX_CCK
850#define DEF_TX1_CW_MAX_CCK CW_MAX_CCK
851#define DEF_TX2_CW_MAX_CCK CW_MAX_CCK
852#define DEF_TX3_CW_MAX_CCK CW_MAX_CCK
853
854#define DEF_TX0_AIFS (2)
855#define DEF_TX1_AIFS (2)
856#define DEF_TX2_AIFS (2)
857#define DEF_TX3_AIFS (2)
858
859#define DEF_TX0_ACM 0
860#define DEF_TX1_ACM 0
861#define DEF_TX2_ACM 0
862#define DEF_TX3_ACM 0
863
864#define DEF_TX0_TXOP_LIMIT_CCK 0
865#define DEF_TX1_TXOP_LIMIT_CCK 0
866#define DEF_TX2_TXOP_LIMIT_CCK 0
867#define DEF_TX3_TXOP_LIMIT_CCK 0
868
869#define DEF_TX0_TXOP_LIMIT_OFDM 0
870#define DEF_TX1_TXOP_LIMIT_OFDM 0
871#define DEF_TX2_TXOP_LIMIT_OFDM 0
872#define DEF_TX3_TXOP_LIMIT_OFDM 0
873
874#define QOS_QOS_SETS 3
875#define QOS_PARAM_SET_ACTIVE 0
876#define QOS_PARAM_SET_DEF_CCK 1
877#define QOS_PARAM_SET_DEF_OFDM 2
878
879#define CTRL_QOS_NO_ACK (0x0020)
880#define DCT_FLAG_EXT_QOS_ENABLED (0x10)
881
882#define U32_PAD(n) ((4-(n))&0x3)
883
884/*
885 * Generic queue structure
886 *
887 * Contains common data for Rx and Tx queues
888 */
889#define TFD_CTL_COUNT_SET(n) (n<<24)
890#define TFD_CTL_COUNT_GET(ctl) ((ctl>>24) & 7)
891#define TFD_CTL_PAD_SET(n) (n<<28)
892#define TFD_CTL_PAD_GET(ctl) (ctl>>28)
893
894#define TFD_TX_CMD_SLOTS 256
895#define TFD_CMD_SLOTS 32
896
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800897#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl4965_cmd) - \
898 sizeof(struct iwl4965_cmd_meta))
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800899
900/*
901 * RX related structures and functions
902 */
903#define RX_FREE_BUFFERS 64
904#define RX_LOW_WATERMARK 8
905
906
Zhu Yib481de92007-09-25 17:54:57 -0700907#define IWL_RX_BUF_SIZE (4 * 1024)
908#define IWL_MAX_BSM_SIZE BSM_SRAM_SIZE
909#define KDR_RTC_INST_UPPER_BOUND (0x018000)
910#define KDR_RTC_DATA_UPPER_BOUND (0x80A000)
911#define KDR_RTC_INST_SIZE (KDR_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
912#define KDR_RTC_DATA_SIZE (KDR_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
913
914#define IWL_MAX_INST_SIZE KDR_RTC_INST_SIZE
915#define IWL_MAX_DATA_SIZE KDR_RTC_DATA_SIZE
916
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800917static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr)
Zhu Yib481de92007-09-25 17:54:57 -0700918{
919 return (addr >= RTC_DATA_LOWER_BOUND) &&
920 (addr < KDR_RTC_DATA_UPPER_BOUND);
921}
922
923/********************* START TXPOWER *****************************************/
924enum {
925 HT_IE_EXT_CHANNEL_NONE = 0,
926 HT_IE_EXT_CHANNEL_ABOVE,
927 HT_IE_EXT_CHANNEL_INVALID,
928 HT_IE_EXT_CHANNEL_BELOW,
929 HT_IE_EXT_CHANNEL_MAX
930};
931
932enum {
933 CALIB_CH_GROUP_1 = 0,
934 CALIB_CH_GROUP_2 = 1,
935 CALIB_CH_GROUP_3 = 2,
936 CALIB_CH_GROUP_4 = 3,
937 CALIB_CH_GROUP_5 = 4,
938 CALIB_CH_GROUP_MAX
939};
940
941/* Temperature calibration offset is 3% 0C in Kelvin */
942#define TEMPERATURE_CALIB_KELVIN_OFFSET 8
943#define TEMPERATURE_CALIB_A_VAL 259
944
945#define IWL_TX_POWER_TEMPERATURE_MIN (263)
946#define IWL_TX_POWER_TEMPERATURE_MAX (410)
947
948#define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
949 (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \
950 ((t) > IWL_TX_POWER_TEMPERATURE_MAX))
951
952#define IWL_TX_POWER_ILLEGAL_TEMPERATURE (300)
953
954#define IWL_TX_POWER_TEMPERATURE_DIFFERENCE (2)
955
956#define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
957
958#define IWL_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */
959#define IWL_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */
960
961/* timeout equivalent to 3 minutes */
962#define IWL_TX_POWER_TIMELIMIT_NOCALIB 1800000000
963
964#define IWL_TX_POWER_CCK_COMPENSATION (9)
965
966#define MIN_TX_GAIN_INDEX (0)
967#define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9)
968#define MAX_TX_GAIN_INDEX_52GHZ (98)
969#define MIN_TX_GAIN_52GHZ (98)
970#define MAX_TX_GAIN_INDEX_24GHZ (98)
971#define MIN_TX_GAIN_24GHZ (98)
972#define MAX_TX_GAIN (0)
973#define MAX_TX_GAIN_52GHZ_EXT (-9)
974
975#define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34)
976#define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34)
977#define IWL_TX_POWER_REGULATORY_MIN (0)
978#define IWL_TX_POWER_REGULATORY_MAX (34)
979#define IWL_TX_POWER_DEFAULT_SATURATION_24 (38)
980#define IWL_TX_POWER_DEFAULT_SATURATION_52 (38)
981#define IWL_TX_POWER_SATURATION_MIN (20)
982#define IWL_TX_POWER_SATURATION_MAX (50)
983
984/* dv *0.4 = dt; so that 5 degrees temperature diff equals
985 * 12.5 in voltage diff */
986#define IWL_TX_TEMPERATURE_UPDATE_LIMIT 9
987
988#define IWL_INVALID_CHANNEL (0xffffffff)
989#define IWL_TX_POWER_REGITRY_BIT (2)
990
991#define MIN_IWL_TX_POWER_CALIB_DUR (100)
992#define IWL_CCK_FROM_OFDM_POWER_DIFF (-5)
993#define IWL_CCK_FROM_OFDM_INDEX_DIFF (9)
994
995/* Number of entries in the gain table */
996#define POWER_GAIN_NUM_ENTRIES 78
997#define TX_POW_MAX_SESSION_NUM 5
998/* timeout equivalent to 3 minutes */
999#define TX_IWL_TIMELIMIT_NOCALIB 1800000000
1000
1001/* Kedron TX_CALIB_STATES */
1002#define IWL_TX_CALIB_STATE_SEND_TX 0x00000001
1003#define IWL_TX_CALIB_WAIT_TX_RESPONSE 0x00000002
1004#define IWL_TX_CALIB_ENABLED 0x00000004
1005#define IWL_TX_CALIB_XVT_ON 0x00000008
1006#define IWL_TX_CALIB_TEMPERATURE_CORRECT 0x00000010
1007#define IWL_TX_CALIB_WORKING_WITH_XVT 0x00000020
1008#define IWL_TX_CALIB_XVT_PERIODICAL 0x00000040
1009
1010#define NUM_IWL_TX_CALIB_SETTINS 5 /* Number of tx correction groups */
1011
1012#define IWL_MIN_POWER_IN_VP_TABLE 1 /* 0.5dBm multiplied by 2 */
1013#define IWL_MAX_POWER_IN_VP_TABLE 40 /* 20dBm - multiplied by 2 (because
1014 * entries are for each 0.5dBm) */
1015#define IWL_STEP_IN_VP_TABLE 1 /* 0.5dB - multiplied by 2 */
1016#define IWL_NUM_POINTS_IN_VPTABLE \
1017 (1 + IWL_MAX_POWER_IN_VP_TABLE - IWL_MIN_POWER_IN_VP_TABLE)
1018
1019#define MIN_TX_GAIN_INDEX (0)
1020#define MAX_TX_GAIN_INDEX_52GHZ (98)
1021#define MIN_TX_GAIN_52GHZ (98)
1022#define MAX_TX_GAIN_INDEX_24GHZ (98)
1023#define MIN_TX_GAIN_24GHZ (98)
1024#define MAX_TX_GAIN (0)
1025
1026/* First and last channels of all groups */
1027#define CALIB_IWL_TX_ATTEN_GR1_FCH 34
1028#define CALIB_IWL_TX_ATTEN_GR1_LCH 43
1029#define CALIB_IWL_TX_ATTEN_GR2_FCH 44
1030#define CALIB_IWL_TX_ATTEN_GR2_LCH 70
1031#define CALIB_IWL_TX_ATTEN_GR3_FCH 71
1032#define CALIB_IWL_TX_ATTEN_GR3_LCH 124
1033#define CALIB_IWL_TX_ATTEN_GR4_FCH 125
1034#define CALIB_IWL_TX_ATTEN_GR4_LCH 200
1035#define CALIB_IWL_TX_ATTEN_GR5_FCH 1
1036#define CALIB_IWL_TX_ATTEN_GR5_LCH 20
1037
1038
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001039union iwl4965_tx_power_dual_stream {
Zhu Yib481de92007-09-25 17:54:57 -07001040 struct {
1041 u8 radio_tx_gain[2];
1042 u8 dsp_predis_atten[2];
1043 } s;
1044 u32 dw;
1045};
1046
1047/********************* END TXPOWER *****************************************/
1048
1049/* HT flags */
1050#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
1051#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1<<22)
1052
1053#define RXON_FLG_HT_OPERATING_MODE_POS (23)
1054
1055#define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1<<23)
1056#define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2<<23)
1057
1058#define RXON_FLG_CHANNEL_MODE_POS (25)
1059#define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3<<25)
1060#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1<<25)
1061#define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2<<25)
1062
1063#define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1<<0)
1064#define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7<<1)
1065#define RXON_RX_CHAIN_VALID_POS (1)
1066#define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7<<4)
1067#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
1068#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7<<7)
1069#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
1070#define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3<<10)
1071#define RXON_RX_CHAIN_CNT_POS (10)
1072#define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3<<12)
1073#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
1074#define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1<<14)
1075#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
1076
1077
1078#define MCS_DUP_6M_PLCP 0x20
1079
1080/* OFDM HT rate masks */
1081/* ***************************************** */
1082#define R_MCS_6M_MSK 0x1
1083#define R_MCS_12M_MSK 0x2
1084#define R_MCS_18M_MSK 0x4
1085#define R_MCS_24M_MSK 0x8
1086#define R_MCS_36M_MSK 0x10
1087#define R_MCS_48M_MSK 0x20
1088#define R_MCS_54M_MSK 0x40
1089#define R_MCS_60M_MSK 0x80
1090#define R_MCS_12M_DUAL_MSK 0x100
1091#define R_MCS_24M_DUAL_MSK 0x200
1092#define R_MCS_36M_DUAL_MSK 0x400
1093#define R_MCS_48M_DUAL_MSK 0x800
1094
1095#define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A))
1096#define is_siso(tbl) (((tbl) == LQ_SISO))
1097#define is_mimo(tbl) (((tbl) == LQ_MIMO))
1098#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
1099#define is_a_band(tbl) (((tbl) == LQ_A))
1100#define is_g_and(tbl) (((tbl) == LQ_G))
1101
1102/* Flow Handler Definitions */
1103
1104/**********************/
1105/* Addresses */
1106/**********************/
1107
1108#define FH_MEM_LOWER_BOUND (0x1000)
1109#define FH_MEM_UPPER_BOUND (0x1EF0)
1110
1111#define IWL_FH_REGS_LOWER_BOUND (0x1000)
1112#define IWL_FH_REGS_UPPER_BOUND (0x2000)
1113
1114#define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
1115
1116/* CBBC Area - Circular buffers base address cache pointers table */
1117#define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
1118#define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
1119/* queues 0 - 15 */
1120#define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
1121
1122/* RSCSR Area */
1123#define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
1124#define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
1125#define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
1126
1127#define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
1128#define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
1129#define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
1130
1131/* RCSR Area - Registers address map */
1132#define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
1133#define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0)
1134#define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND)
1135
1136#define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0)
1137
1138/* RSSR Area - Rx shared ctrl & status registers */
1139#define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
1140#define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
1141#define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
1142#define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
1143#define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
1144
1145/* TCSR */
1146#define IWL_FH_TCSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xD00)
1147#define IWL_FH_TCSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xE60)
1148
1149#define IWL_FH_TCSR_CHNL_NUM (7)
1150#define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
1151 (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
1152
1153/* TSSR Area - Tx shared status registers */
1154/* TSSR */
1155#define IWL_FH_TSSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEA0)
1156#define IWL_FH_TSSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEC0)
1157
1158#define IWL_FH_TSSR_TX_MSG_CONFIG_REG (IWL_FH_TSSR_LOWER_BOUND + 0x008)
1159#define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010)
1160
1161#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
1162#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
1163
1164#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_64B (0x00000000)
1165#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
1166#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_256B (0x00000800)
1167#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_512B (0x00000C00)
1168
1169#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
1170#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
1171
1172#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
1173#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
1174
1175#define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \
1176 ((1 << (_chnl)) << 24)
1177#define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
1178 ((1 << (_chnl)) << 16)
1179
1180#define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
1181 (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
1182 IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
1183
1184/* TCSR: tx_config register values */
1185#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
1186#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
1187#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_ARC (0x00000002)
1188
1189#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
1190#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
1191
1192#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
1193#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
1194#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
1195
1196#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
1197#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
1198#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
1199
1200#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
1201#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
1202#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
1203
1204#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
1205#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
1206#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
1207
1208#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
1209
1210#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
1211#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
1212
1213/* RCSR: channel 0 rx_config register defines */
1214#define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
1215#define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
1216#define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
1217#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
1218#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
1219#define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
1220
1221#define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20)
1222#define FH_RCSR_RX_CONFIG_RB_SIZE_BITSHIFT (16)
1223
1224/* RCSR: rx_config register values */
1225#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
1226#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
1227#define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
1228
1229#define IWL_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
1230
1231/* RCSR channel 0 config register values */
1232#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
1233#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
1234
1235/* RSCSR: defs used in normal mode */
1236#define FH_RSCSR_CHNL0_RBDCB_WPTR_MASK (0x00000FFF) /* bits 0-11 */
1237
1238#define SCD_WIN_SIZE 64
1239#define SCD_FRAME_LIMIT 64
1240
Zhu Yib481de92007-09-25 17:54:57 -07001241/* SRAM structures */
1242#define SCD_CONTEXT_DATA_OFFSET 0x380
1243#define SCD_TX_STTS_BITMAP_OFFSET 0x400
1244#define SCD_TRANSLATE_TBL_OFFSET 0x500
1245#define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
1246#define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
1247 ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
1248
1249#define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
1250 ((1<<(hi))|((1<<(hi))-(1<<(lo))))
1251
1252
1253#define SCD_MODE_REG_BIT_SEARCH_MODE (1<<0)
1254#define SCD_MODE_REG_BIT_SBYP_MODE (1<<1)
1255
1256#define SCD_TXFIFO_POS_TID (0)
1257#define SCD_TXFIFO_POS_RA (4)
1258#define SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
1259#define SCD_QUEUE_STTS_REG_POS_TXF (1)
1260#define SCD_QUEUE_STTS_REG_POS_WSL (5)
1261#define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
1262#define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
1263#define SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
1264
1265#define SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
1266
1267#define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
1268#define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
1269#define SCD_QUEUE_CTX_REG1_CREDIT_POS (8)
1270#define SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00)
1271#define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24)
1272#define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000)
1273#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
1274#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
1275
1276#define CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R (0x00000010)
1277#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00)
1278#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100)
1279#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200)
1280
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001281static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags)
Zhu Yib481de92007-09-25 17:54:57 -07001282{
1283 return le32_to_cpu(rate_n_flags) & 0xFF;
1284}
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001285static inline u16 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags)
Zhu Yib481de92007-09-25 17:54:57 -07001286{
1287 return le32_to_cpu(rate_n_flags) & 0xFFFF;
1288}
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001289static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
Zhu Yib481de92007-09-25 17:54:57 -07001290{
1291 return cpu_to_le32(flags|(u16)rate);
1292}
1293
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001294struct iwl4965_tfd_frame_data {
Zhu Yib481de92007-09-25 17:54:57 -07001295 __le32 tb1_addr;
1296
1297 __le32 val1;
1298 /* __le32 ptb1_32_35:4; */
1299#define IWL_tb1_addr_hi_POS 0
1300#define IWL_tb1_addr_hi_LEN 4
1301#define IWL_tb1_addr_hi_SYM val1
1302 /* __le32 tb_len1:12; */
1303#define IWL_tb1_len_POS 4
1304#define IWL_tb1_len_LEN 12
1305#define IWL_tb1_len_SYM val1
1306 /* __le32 ptb2_0_15:16; */
1307#define IWL_tb2_addr_lo16_POS 16
1308#define IWL_tb2_addr_lo16_LEN 16
1309#define IWL_tb2_addr_lo16_SYM val1
1310
1311 __le32 val2;
1312 /* __le32 ptb2_16_35:20; */
1313#define IWL_tb2_addr_hi20_POS 0
1314#define IWL_tb2_addr_hi20_LEN 20
1315#define IWL_tb2_addr_hi20_SYM val2
1316 /* __le32 tb_len2:12; */
1317#define IWL_tb2_len_POS 20
1318#define IWL_tb2_len_LEN 12
1319#define IWL_tb2_len_SYM val2
1320} __attribute__ ((packed));
1321
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001322struct iwl4965_tfd_frame {
Zhu Yib481de92007-09-25 17:54:57 -07001323 __le32 val0;
1324 /* __le32 rsvd1:24; */
1325 /* __le32 num_tbs:5; */
1326#define IWL_num_tbs_POS 24
1327#define IWL_num_tbs_LEN 5
1328#define IWL_num_tbs_SYM val0
1329 /* __le32 rsvd2:1; */
1330 /* __le32 padding:2; */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001331 struct iwl4965_tfd_frame_data pa[10];
Zhu Yib481de92007-09-25 17:54:57 -07001332 __le32 reserved;
1333} __attribute__ ((packed));
1334
1335#define IWL4965_MAX_WIN_SIZE 64
1336#define IWL4965_QUEUE_SIZE 256
1337#define IWL4965_NUM_FIFOS 7
1338#define IWL_MAX_NUM_QUEUES 16
1339
1340struct iwl4965_queue_byte_cnt_entry {
1341 __le16 val;
1342 /* __le16 byte_cnt:12; */
1343#define IWL_byte_cnt_POS 0
1344#define IWL_byte_cnt_LEN 12
1345#define IWL_byte_cnt_SYM val
1346 /* __le16 rsvd:4; */
1347} __attribute__ ((packed));
1348
1349struct iwl4965_sched_queue_byte_cnt_tbl {
1350 struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE +
1351 IWL4965_MAX_WIN_SIZE];
1352 u8 dont_care[1024 -
1353 (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) *
1354 sizeof(__le16)];
1355} __attribute__ ((packed));
1356
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001357/* Base physical address of iwl4965_shared is provided to KDR_SCD_DRAM_BASE_ADDR
1358 * and &iwl4965_shared.val0 is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG */
1359struct iwl4965_shared {
Zhu Yib481de92007-09-25 17:54:57 -07001360 struct iwl4965_sched_queue_byte_cnt_tbl
1361 queues_byte_cnt_tbls[IWL_MAX_NUM_QUEUES];
1362 __le32 val0;
1363
1364 /* __le32 rb_closed_stts_rb_num:12; */
1365#define IWL_rb_closed_stts_rb_num_POS 0
1366#define IWL_rb_closed_stts_rb_num_LEN 12
1367#define IWL_rb_closed_stts_rb_num_SYM val0
1368 /* __le32 rsrv1:4; */
1369 /* __le32 rb_closed_stts_rx_frame_num:12; */
1370#define IWL_rb_closed_stts_rx_frame_num_POS 16
1371#define IWL_rb_closed_stts_rx_frame_num_LEN 12
1372#define IWL_rb_closed_stts_rx_frame_num_SYM val0
1373 /* __le32 rsrv2:4; */
1374
1375 __le32 val1;
1376 /* __le32 frame_finished_stts_rb_num:12; */
1377#define IWL_frame_finished_stts_rb_num_POS 0
1378#define IWL_frame_finished_stts_rb_num_LEN 12
1379#define IWL_frame_finished_stts_rb_num_SYM val1
1380 /* __le32 rsrv3:4; */
1381 /* __le32 frame_finished_stts_rx_frame_num:12; */
1382#define IWL_frame_finished_stts_rx_frame_num_POS 16
1383#define IWL_frame_finished_stts_rx_frame_num_LEN 12
1384#define IWL_frame_finished_stts_rx_frame_num_SYM val1
1385 /* __le32 rsrv4:4; */
1386
1387 __le32 padding1; /* so that allocation will be aligned to 16B */
1388 __le32 padding2;
1389} __attribute__ ((packed));
1390
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001391#endif /* __iwl4965_4965_hw_h__ */