blob: a71c32a649d93f4203b429e8d3134d773edaa7bc [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
Ben Cahill796083c2007-11-29 11:09:45 +0800172/* 4965 has two radio transmitters (and 3 radio receivers) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800173#define EEPROM_TX_POWER_TX_CHAINS (2)
Ben Cahill796083c2007-11-29 11:09:45 +0800174
175/* 4965 has room for up to 8 sets of txpower calibration data */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800176#define EEPROM_TX_POWER_BANDS (8)
Ben Cahill796083c2007-11-29 11:09:45 +0800177
178/* 4965 factory calibration measures txpower gain settings for
179 * each of 3 target output levels */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800180#define EEPROM_TX_POWER_MEASUREMENTS (3)
Ben Cahill796083c2007-11-29 11:09:45 +0800181
Ben Cahill796083c2007-11-29 11:09:45 +0800182/* 4965 driver does not work with txpower calibration version < 5.
183 * Look for this in calib_version member of struct iwl4965_eeprom. */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800184#define EEPROM_TX_POWER_VERSION_NEW (5)
185
Ben Cahill796083c2007-11-29 11:09:45 +0800186
187/*
188 * 4965 factory calibration data for one txpower level, on one channel,
189 * measured on one of the 2 tx chains (radio transmitter and associated
190 * antenna). EEPROM contains:
191 *
192 * 1) Temperature (degrees Celsius) of device when measurement was made.
193 *
194 * 2) Gain table index used to achieve the target measurement power.
195 * This refers to the "well-known" gain tables (see iwl-4965-hw.h).
196 *
197 * 3) Actual measured output power, in half-dBm ("34" = 17 dBm).
198 *
199 * 4) RF power amplifier detector level measurement (not used).
200 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800201struct iwl4965_eeprom_calib_measure {
Ben Cahill796083c2007-11-29 11:09:45 +0800202 u8 temperature; /* Device temperature (Celsius) */
203 u8 gain_idx; /* Index into gain table */
204 u8 actual_pow; /* Measured RF output power, half-dBm */
205 s8 pa_det; /* Power amp detector level (not used) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800206} __attribute__ ((packed));
207
Ben Cahill796083c2007-11-29 11:09:45 +0800208
209/*
210 * 4965 measurement set for one channel. EEPROM contains:
211 *
212 * 1) Channel number measured
213 *
214 * 2) Measurements for each of 3 power levels for each of 2 radio transmitters
215 * (a.k.a. "tx chains") (6 measurements altogether)
216 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800217struct iwl4965_eeprom_calib_ch_info {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800218 u8 ch_num;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800219 struct iwl4965_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS]
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800220 [EEPROM_TX_POWER_MEASUREMENTS];
221} __attribute__ ((packed));
222
Ben Cahill796083c2007-11-29 11:09:45 +0800223/*
224 * 4965 txpower subband info.
225 *
226 * For each frequency subband, EEPROM contains the following:
227 *
228 * 1) First and last channels within range of the subband. "0" values
229 * indicate that this sample set is not being used.
230 *
231 * 2) Sample measurement sets for 2 channels close to the range endpoints.
232 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800233struct iwl4965_eeprom_calib_subband_info {
Ben Cahill796083c2007-11-29 11:09:45 +0800234 u8 ch_from; /* channel number of lowest channel in subband */
235 u8 ch_to; /* channel number of highest channel in subband */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800236 struct iwl4965_eeprom_calib_ch_info ch1;
237 struct iwl4965_eeprom_calib_ch_info ch2;
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800238} __attribute__ ((packed));
239
Ben Cahill796083c2007-11-29 11:09:45 +0800240
241/*
242 * 4965 txpower calibration info. EEPROM contains:
243 *
244 * 1) Factory-measured saturation power levels (maximum levels at which
245 * tx power amplifier can output a signal without too much distortion).
246 * There is one level for 2.4 GHz band and one for 5 GHz band. These
247 * values apply to all channels within each of the bands.
248 *
249 * 2) Factory-measured power supply voltage level. This is assumed to be
250 * constant (i.e. same value applies to all channels/bands) while the
251 * factory measurements are being made.
252 *
253 * 3) Up to 8 sets of factory-measured txpower calibration values.
254 * These are for different frequency ranges, since txpower gain
255 * characteristics of the analog radio circuitry vary with frequency.
256 *
257 * Not all sets need to be filled with data;
258 * struct iwl4965_eeprom_calib_subband_info contains range of channels
259 * (0 if unused) for each set of data.
260 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800261struct iwl4965_eeprom_calib_info {
Ben Cahill796083c2007-11-29 11:09:45 +0800262 u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
263 u8 saturation_power52; /* half-dBm */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800264 s16 voltage; /* signed */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800265 struct iwl4965_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800266} __attribute__ ((packed));
267
268
Ben Cahill796083c2007-11-29 11:09:45 +0800269/*
270 * 4965 EEPROM map
271 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800272struct iwl4965_eeprom {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800273 u8 reserved0[16];
274#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800275 u16 device_id; /* abs.ofs: 16 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800276 u8 reserved1[2];
277#define EEPROM_PMC (2*0x0A) /* 2 bytes */
278 u16 pmc; /* abs.ofs: 20 */
279 u8 reserved2[20];
280#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
281 u8 mac_address[6]; /* abs.ofs: 42 */
282 u8 reserved3[58];
283#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
284 u16 board_revision; /* abs.ofs: 106 */
285 u8 reserved4[11];
286#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
287 u8 board_pba_number[9]; /* abs.ofs: 119 */
288 u8 reserved5[8];
289#define EEPROM_VERSION (2*0x44) /* 2 bytes */
290 u16 version; /* abs.ofs: 136 */
291#define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
292 u8 sku_cap; /* abs.ofs: 138 */
293#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
294 u8 leds_mode; /* abs.ofs: 139 */
295#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
296 u16 oem_mode;
297#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
298 u16 wowlan_mode; /* abs.ofs: 142 */
299#define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
300 u16 leds_time_interval; /* abs.ofs: 144 */
301#define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
302 u8 leds_off_time; /* abs.ofs: 146 */
303#define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
304 u8 leds_on_time; /* abs.ofs: 147 */
305#define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
306 u8 almgor_m_version; /* abs.ofs: 148 */
307#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
308 u8 antenna_switch_type; /* abs.ofs: 149 */
309 u8 reserved6[8];
310#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
311 u16 board_revision_4965; /* abs.ofs: 158 */
312 u8 reserved7[13];
313#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
314 u8 board_pba_number_4965[9]; /* abs.ofs: 173 */
315 u8 reserved8[10];
316#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
317 u8 sku_id[4]; /* abs.ofs: 192 */
Ben Cahill796083c2007-11-29 11:09:45 +0800318
319/*
320 * Per-channel regulatory data.
321 *
322 * Each channel that *might* be supported by 3945 or 4965 has a fixed location
323 * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
324 * txpower (MSB).
325 *
326 * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
327 * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
328 *
329 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
330 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800331#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
332 u16 band_1_count; /* abs.ofs: 196 */
333#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800334 struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
335
336/*
337 * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
338 * 5.0 GHz channels 7, 8, 11, 12, 16
339 * (4915-5080MHz) (none of these is ever supported)
340 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800341#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
342 u16 band_2_count; /* abs.ofs: 226 */
343#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800344 struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
345
346/*
347 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
348 * (5170-5320MHz)
349 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800350#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
351 u16 band_3_count; /* abs.ofs: 254 */
352#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800353 struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
354
355/*
356 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
357 * (5500-5700MHz)
358 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800359#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
360 u16 band_4_count; /* abs.ofs: 280 */
361#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800362 struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
363
364/*
365 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
366 * (5725-5825MHz)
367 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800368#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
369 u16 band_5_count; /* abs.ofs: 304 */
370#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800371 struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800372
373 u8 reserved10[2];
Ben Cahill796083c2007-11-29 11:09:45 +0800374
375
376/*
377 * 2.4 GHz FAT channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11)
378 *
379 * The channel listed is the center of the lower 20 MHz half of the channel.
380 * The overall center frequency is actually 2 channels (10 MHz) above that,
381 * and the upper half of each FAT channel is centered 4 channels (20 MHz) away
382 * from the lower half; e.g. the upper half of FAT channel 1 is channel 5,
383 * and the overall FAT channel width centers on channel 3.
384 *
385 * NOTE: The RXON command uses 20 MHz channel numbers to specify the
386 * control channel to which to tune. RXON also specifies whether the
387 * control channel is the upper or lower half of a FAT channel.
388 *
389 * NOTE: 4965 does not support FAT channels on 2.4 GHz.
390 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800391#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800392 struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800393 u8 reserved11[2];
Ben Cahill796083c2007-11-29 11:09:45 +0800394
395/*
396 * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64),
397 * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
398 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800399#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800400 struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800401 u8 reserved12[6];
Ben Cahill796083c2007-11-29 11:09:45 +0800402
403/*
404 * 4965 driver requires txpower calibration format version 5 or greater.
405 * Driver does not work with txpower calibration version < 5.
406 * This value is simply a 16-bit number, no major/minor versions here.
407 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800408#define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
409 u16 calib_version; /* abs.ofs: 364 */
410 u8 reserved13[2];
Ben Cahill40ac81a2007-11-29 11:09:46 +0800411 u8 reserved14[96]; /* abs.ofs: 368 */
Ben Cahill796083c2007-11-29 11:09:45 +0800412
413/*
414 * 4965 Txpower calibration data.
415 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800416#define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800417 struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800418
419 u8 reserved16[140]; /* fill out to full 1024 byte block */
420
421
422} __attribute__ ((packed));
423
424#define IWL_EEPROM_IMAGE_SIZE 1024
425
Ben Cahill796083c2007-11-29 11:09:45 +0800426/* End of EEPROM */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800427
428#include "iwl-4965-commands.h"
429
430#define PCI_LINK_CTRL 0x0F0
431#define PCI_POWER_SOURCE 0x0C8
432#define PCI_REG_WUM8 0x0E8
433#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
434
435/*=== CSR (control and status registers) ===*/
436#define CSR_BASE (0x000)
437
438#define CSR_SW_VER (CSR_BASE+0x000)
439#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */
440#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */
441#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */
442#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */
443#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/
444#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */
445#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
446#define CSR_GP_CNTRL (CSR_BASE+0x024)
447#define CSR_HW_REV (CSR_BASE+0x028)
448#define CSR_EEPROM_REG (CSR_BASE+0x02c)
449#define CSR_EEPROM_GP (CSR_BASE+0x030)
450#define CSR_GP_UCODE (CSR_BASE+0x044)
451#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
452#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058)
453#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
454#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
455#define CSR_LED_REG (CSR_BASE+0x094)
456#define CSR_DRAM_INT_TBL_CTL (CSR_BASE+0x0A0)
457#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
458#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
459#define CSR_HW_REV_WA_REG (CSR_BASE+0x22C)
460
461/* HW I/F configuration */
462#define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB (0x00000100)
463#define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM (0x00000200)
464#define CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400)
465#define CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800)
466#define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000)
467#define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000)
468#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
469
470/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
471 * acknowledged (reset) by host writing "1" to flagged bits. */
472#define CSR_INT_BIT_FH_RX (1<<31) /* Rx DMA, cmd responses, FH_INT[17:16] */
473#define CSR_INT_BIT_HW_ERR (1<<29) /* DMA hardware error FH_INT[31] */
474#define CSR_INT_BIT_DNLD (1<<28) /* uCode Download */
475#define CSR_INT_BIT_FH_TX (1<<27) /* Tx DMA FH_INT[1:0] */
476#define CSR_INT_BIT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
477#define CSR_INT_BIT_SW_ERR (1<<25) /* uCode error */
478#define CSR_INT_BIT_RF_KILL (1<<7) /* HW RFKILL switch GP_CNTRL[27] toggled */
479#define CSR_INT_BIT_CT_KILL (1<<6) /* Critical temp (chip too hot) rfkill */
480#define CSR_INT_BIT_SW_RX (1<<3) /* Rx, command responses, 3945 */
481#define CSR_INT_BIT_WAKEUP (1<<1) /* NIC controller waking up (pwr mgmt) */
482#define CSR_INT_BIT_ALIVE (1<<0) /* uCode interrupts once it initializes */
483
484#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \
485 CSR_INT_BIT_HW_ERR | \
486 CSR_INT_BIT_FH_TX | \
487 CSR_INT_BIT_SW_ERR | \
488 CSR_INT_BIT_RF_KILL | \
489 CSR_INT_BIT_SW_RX | \
490 CSR_INT_BIT_WAKEUP | \
491 CSR_INT_BIT_ALIVE)
492
493/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
494#define CSR_FH_INT_BIT_ERR (1<<31) /* Error */
495#define CSR_FH_INT_BIT_HI_PRIOR (1<<30) /* High priority Rx, bypass coalescing */
496#define CSR_FH_INT_BIT_RX_CHNL2 (1<<18) /* Rx channel 2 (3945 only) */
497#define CSR_FH_INT_BIT_RX_CHNL1 (1<<17) /* Rx channel 1 */
498#define CSR_FH_INT_BIT_RX_CHNL0 (1<<16) /* Rx channel 0 */
499#define CSR_FH_INT_BIT_TX_CHNL6 (1<<6) /* Tx channel 6 (3945 only) */
500#define CSR_FH_INT_BIT_TX_CHNL1 (1<<1) /* Tx channel 1 */
501#define CSR_FH_INT_BIT_TX_CHNL0 (1<<0) /* Tx channel 0 */
502
503#define CSR_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \
504 CSR_FH_INT_BIT_RX_CHNL2 | \
505 CSR_FH_INT_BIT_RX_CHNL1 | \
506 CSR_FH_INT_BIT_RX_CHNL0)
507
508#define CSR_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL6 | \
509 CSR_FH_INT_BIT_TX_CHNL1 | \
Jeff Garzik93a3b602007-11-23 21:50:20 -0500510 CSR_FH_INT_BIT_TX_CHNL0)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800511
512
513/* RESET */
514#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001)
515#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002)
516#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080)
517#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100)
518#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200)
519
520/* GP (general purpose) CONTROL */
521#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001)
522#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
523#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008)
524#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
525
526#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001)
527
528#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000)
529#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000)
530#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000)
531
532
533/* EEPROM REG */
534#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
535#define CSR_EEPROM_REG_BIT_CMD (0x00000002)
536
537/* EEPROM GP */
538#define CSR_EEPROM_GP_VALID_MSK (0x00000006)
539#define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
540#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
541
542/* UCODE DRV GP */
543#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001)
544#define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
545#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
546#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
547
548/* GPIO */
549#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200)
550#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000)
551#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC CSR_GPIO_IN_BIT_AUX_POWER
552
553/* GI Chicken Bits */
554#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
555#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
556
557/* CSR_ANA_PLL_CFG */
558#define CSR_ANA_PLL_CFG_SH (0x00880300)
559
560#define CSR_LED_REG_TRUN_ON (0x00000078)
561#define CSR_LED_REG_TRUN_OFF (0x00000038)
562#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
563
564/* DRAM_INT_TBL_CTRL */
565#define CSR_DRAM_INT_TBL_CTRL_EN (1<<31)
566#define CSR_DRAM_INT_TBL_CTRL_WRAP_CHK (1<<27)
567
568/*=== HBUS (Host-side Bus) ===*/
569#define HBUS_BASE (0x400)
570
571#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c)
572#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010)
573#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018)
574#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c)
575#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044)
576#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048)
577#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c)
578#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050)
579#define HBUS_TARG_WRPTR (HBUS_BASE+0x060)
580
581#define HBUS_TARG_MBX_C (HBUS_BASE+0x030)
582
583
584/* SCD (Scheduler) */
585#define SCD_BASE (CSR_BASE + 0x2E00)
586
587#define SCD_MODE_REG (SCD_BASE + 0x000)
588#define SCD_ARASTAT_REG (SCD_BASE + 0x004)
589#define SCD_TXFACT_REG (SCD_BASE + 0x010)
590#define SCD_TXF4MF_REG (SCD_BASE + 0x014)
591#define SCD_TXF5MF_REG (SCD_BASE + 0x020)
592#define SCD_SBYP_MODE_1_REG (SCD_BASE + 0x02C)
593#define SCD_SBYP_MODE_2_REG (SCD_BASE + 0x030)
594
595/*=== FH (data Flow Handler) ===*/
596#define FH_BASE (0x800)
597
598#define FH_CBCC_TABLE (FH_BASE+0x140)
599#define FH_TFDB_TABLE (FH_BASE+0x180)
600#define FH_RCSR_TABLE (FH_BASE+0x400)
601#define FH_RSSR_TABLE (FH_BASE+0x4c0)
602#define FH_TCSR_TABLE (FH_BASE+0x500)
603#define FH_TSSR_TABLE (FH_BASE+0x680)
604
605/* TFDB (Transmit Frame Buffer Descriptor) */
606#define FH_TFDB(_channel, buf) \
607 (FH_TFDB_TABLE+((_channel)*2+(buf))*0x28)
608#define ALM_FH_TFDB_CHNL_BUF_CTRL_REG(_channel) \
609 (FH_TFDB_TABLE + 0x50 * _channel)
610/* CBCC _channel is [0,2] */
611#define FH_CBCC(_channel) (FH_CBCC_TABLE+(_channel)*0x8)
612#define FH_CBCC_CTRL(_channel) (FH_CBCC(_channel)+0x00)
613#define FH_CBCC_BASE(_channel) (FH_CBCC(_channel)+0x04)
614
615/* RCSR _channel is [0,2] */
616#define FH_RCSR(_channel) (FH_RCSR_TABLE+(_channel)*0x40)
617#define FH_RCSR_CONFIG(_channel) (FH_RCSR(_channel)+0x00)
618#define FH_RCSR_RBD_BASE(_channel) (FH_RCSR(_channel)+0x04)
619#define FH_RCSR_WPTR(_channel) (FH_RCSR(_channel)+0x20)
620#define FH_RCSR_RPTR_ADDR(_channel) (FH_RCSR(_channel)+0x24)
621
622#define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
623
624/* RSSR */
625#define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
626#define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
627/* TCSR */
628#define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
629#define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
630#define FH_TCSR_CREDIT(_channel) (FH_TCSR(_channel)+0x04)
631#define FH_TCSR_BUFF_STTS(_channel) (FH_TCSR(_channel)+0x08)
632/* TSSR */
633#define FH_TSSR_CBB_BASE (FH_TSSR_TABLE+0x000)
634#define FH_TSSR_MSG_CONFIG (FH_TSSR_TABLE+0x008)
635#define FH_TSSR_TX_STATUS (FH_TSSR_TABLE+0x010)
636/* 18 - reserved */
637
638/* card static random access memory (SRAM) for processor data and instructs */
639#define RTC_INST_LOWER_BOUND (0x000000)
640#define RTC_DATA_LOWER_BOUND (0x800000)
641
642
643/* DBM */
644
645#define ALM_FH_SRVC_CHNL (6)
646
647#define ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
648#define ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
649
650#define ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
651
652#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
653
654#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
655
656#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
657
658#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
659
660#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
661
662#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
663#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
664
665#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
666#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
667
668#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
669
670#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
671
672#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
673#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
674
675#define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
676
677#define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
678
679#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
680#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
681
682#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
683
684#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
685#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
686
687#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
688#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
689
690#define ALM_TB_MAX_BYTES_COUNT (0xFFF0)
691
692#define ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
693 ((1LU << _channel) << 24)
694#define ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
695 ((1LU << _channel) << 16)
696
697#define ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
698 (ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
699 ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
700#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
701#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
702
703#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004)
704
705#define TFD_QUEUE_MIN 0
706#define TFD_QUEUE_MAX 6
707#define TFD_QUEUE_SIZE_MAX (256)
708
709/* spectrum and channel data structures */
710#define IWL_NUM_SCAN_RATES (2)
711
712#define IWL_SCAN_FLAG_24GHZ (1<<0)
713#define IWL_SCAN_FLAG_52GHZ (1<<1)
714#define IWL_SCAN_FLAG_ACTIVE (1<<2)
715#define IWL_SCAN_FLAG_DIRECT (1<<3)
716
717#define IWL_MAX_CMD_SIZE 1024
718
719#define IWL_DEFAULT_TX_RETRY 15
720#define IWL_MAX_TX_RETRY 16
721
722/*********************************************/
723
724#define RFD_SIZE 4
725#define NUM_TFD_CHUNKS 4
726
727#define RX_QUEUE_SIZE 256
728#define RX_QUEUE_MASK 255
729#define RX_QUEUE_SIZE_LOG 8
730
731/* QoS definitions */
732
733#define CW_MIN_OFDM 15
734#define CW_MAX_OFDM 1023
735#define CW_MIN_CCK 31
736#define CW_MAX_CCK 1023
737
738#define QOS_TX0_CW_MIN_OFDM CW_MIN_OFDM
739#define QOS_TX1_CW_MIN_OFDM CW_MIN_OFDM
740#define QOS_TX2_CW_MIN_OFDM ((CW_MIN_OFDM + 1) / 2 - 1)
741#define QOS_TX3_CW_MIN_OFDM ((CW_MIN_OFDM + 1) / 4 - 1)
742
743#define QOS_TX0_CW_MIN_CCK CW_MIN_CCK
744#define QOS_TX1_CW_MIN_CCK CW_MIN_CCK
745#define QOS_TX2_CW_MIN_CCK ((CW_MIN_CCK + 1) / 2 - 1)
746#define QOS_TX3_CW_MIN_CCK ((CW_MIN_CCK + 1) / 4 - 1)
747
748#define QOS_TX0_CW_MAX_OFDM CW_MAX_OFDM
749#define QOS_TX1_CW_MAX_OFDM CW_MAX_OFDM
750#define QOS_TX2_CW_MAX_OFDM CW_MIN_OFDM
751#define QOS_TX3_CW_MAX_OFDM ((CW_MIN_OFDM + 1) / 2 - 1)
752
753#define QOS_TX0_CW_MAX_CCK CW_MAX_CCK
754#define QOS_TX1_CW_MAX_CCK CW_MAX_CCK
755#define QOS_TX2_CW_MAX_CCK CW_MIN_CCK
756#define QOS_TX3_CW_MAX_CCK ((CW_MIN_CCK + 1) / 2 - 1)
757
758#define QOS_TX0_AIFS 3
759#define QOS_TX1_AIFS 7
760#define QOS_TX2_AIFS 2
761#define QOS_TX3_AIFS 2
762
763#define QOS_TX0_ACM 0
764#define QOS_TX1_ACM 0
765#define QOS_TX2_ACM 0
766#define QOS_TX3_ACM 0
767
768#define QOS_TX0_TXOP_LIMIT_CCK 0
769#define QOS_TX1_TXOP_LIMIT_CCK 0
770#define QOS_TX2_TXOP_LIMIT_CCK 6016
771#define QOS_TX3_TXOP_LIMIT_CCK 3264
772
773#define QOS_TX0_TXOP_LIMIT_OFDM 0
774#define QOS_TX1_TXOP_LIMIT_OFDM 0
775#define QOS_TX2_TXOP_LIMIT_OFDM 3008
776#define QOS_TX3_TXOP_LIMIT_OFDM 1504
777
778#define DEF_TX0_CW_MIN_OFDM CW_MIN_OFDM
779#define DEF_TX1_CW_MIN_OFDM CW_MIN_OFDM
780#define DEF_TX2_CW_MIN_OFDM CW_MIN_OFDM
781#define DEF_TX3_CW_MIN_OFDM CW_MIN_OFDM
782
783#define DEF_TX0_CW_MIN_CCK CW_MIN_CCK
784#define DEF_TX1_CW_MIN_CCK CW_MIN_CCK
785#define DEF_TX2_CW_MIN_CCK CW_MIN_CCK
786#define DEF_TX3_CW_MIN_CCK CW_MIN_CCK
787
788#define DEF_TX0_CW_MAX_OFDM CW_MAX_OFDM
789#define DEF_TX1_CW_MAX_OFDM CW_MAX_OFDM
790#define DEF_TX2_CW_MAX_OFDM CW_MAX_OFDM
791#define DEF_TX3_CW_MAX_OFDM CW_MAX_OFDM
792
793#define DEF_TX0_CW_MAX_CCK CW_MAX_CCK
794#define DEF_TX1_CW_MAX_CCK CW_MAX_CCK
795#define DEF_TX2_CW_MAX_CCK CW_MAX_CCK
796#define DEF_TX3_CW_MAX_CCK CW_MAX_CCK
797
798#define DEF_TX0_AIFS (2)
799#define DEF_TX1_AIFS (2)
800#define DEF_TX2_AIFS (2)
801#define DEF_TX3_AIFS (2)
802
803#define DEF_TX0_ACM 0
804#define DEF_TX1_ACM 0
805#define DEF_TX2_ACM 0
806#define DEF_TX3_ACM 0
807
808#define DEF_TX0_TXOP_LIMIT_CCK 0
809#define DEF_TX1_TXOP_LIMIT_CCK 0
810#define DEF_TX2_TXOP_LIMIT_CCK 0
811#define DEF_TX3_TXOP_LIMIT_CCK 0
812
813#define DEF_TX0_TXOP_LIMIT_OFDM 0
814#define DEF_TX1_TXOP_LIMIT_OFDM 0
815#define DEF_TX2_TXOP_LIMIT_OFDM 0
816#define DEF_TX3_TXOP_LIMIT_OFDM 0
817
818#define QOS_QOS_SETS 3
819#define QOS_PARAM_SET_ACTIVE 0
820#define QOS_PARAM_SET_DEF_CCK 1
821#define QOS_PARAM_SET_DEF_OFDM 2
822
823#define CTRL_QOS_NO_ACK (0x0020)
824#define DCT_FLAG_EXT_QOS_ENABLED (0x10)
825
826#define U32_PAD(n) ((4-(n))&0x3)
827
828/*
829 * Generic queue structure
830 *
831 * Contains common data for Rx and Tx queues
832 */
833#define TFD_CTL_COUNT_SET(n) (n<<24)
834#define TFD_CTL_COUNT_GET(ctl) ((ctl>>24) & 7)
835#define TFD_CTL_PAD_SET(n) (n<<28)
836#define TFD_CTL_PAD_GET(ctl) (ctl>>28)
837
838#define TFD_TX_CMD_SLOTS 256
839#define TFD_CMD_SLOTS 32
840
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800841#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl4965_cmd) - \
842 sizeof(struct iwl4965_cmd_meta))
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800843
844/*
845 * RX related structures and functions
846 */
847#define RX_FREE_BUFFERS 64
848#define RX_LOW_WATERMARK 8
849
850
Zhu Yib481de92007-09-25 17:54:57 -0700851#define IWL_RX_BUF_SIZE (4 * 1024)
852#define IWL_MAX_BSM_SIZE BSM_SRAM_SIZE
853#define KDR_RTC_INST_UPPER_BOUND (0x018000)
854#define KDR_RTC_DATA_UPPER_BOUND (0x80A000)
855#define KDR_RTC_INST_SIZE (KDR_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
856#define KDR_RTC_DATA_SIZE (KDR_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
857
858#define IWL_MAX_INST_SIZE KDR_RTC_INST_SIZE
859#define IWL_MAX_DATA_SIZE KDR_RTC_DATA_SIZE
860
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800861static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr)
Zhu Yib481de92007-09-25 17:54:57 -0700862{
863 return (addr >= RTC_DATA_LOWER_BOUND) &&
864 (addr < KDR_RTC_DATA_UPPER_BOUND);
865}
866
867/********************* START TXPOWER *****************************************/
868enum {
869 HT_IE_EXT_CHANNEL_NONE = 0,
870 HT_IE_EXT_CHANNEL_ABOVE,
871 HT_IE_EXT_CHANNEL_INVALID,
872 HT_IE_EXT_CHANNEL_BELOW,
873 HT_IE_EXT_CHANNEL_MAX
874};
875
876enum {
877 CALIB_CH_GROUP_1 = 0,
878 CALIB_CH_GROUP_2 = 1,
879 CALIB_CH_GROUP_3 = 2,
880 CALIB_CH_GROUP_4 = 3,
881 CALIB_CH_GROUP_5 = 4,
882 CALIB_CH_GROUP_MAX
883};
884
885/* Temperature calibration offset is 3% 0C in Kelvin */
886#define TEMPERATURE_CALIB_KELVIN_OFFSET 8
887#define TEMPERATURE_CALIB_A_VAL 259
888
889#define IWL_TX_POWER_TEMPERATURE_MIN (263)
890#define IWL_TX_POWER_TEMPERATURE_MAX (410)
891
892#define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
893 (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \
894 ((t) > IWL_TX_POWER_TEMPERATURE_MAX))
895
896#define IWL_TX_POWER_ILLEGAL_TEMPERATURE (300)
897
898#define IWL_TX_POWER_TEMPERATURE_DIFFERENCE (2)
899
900#define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
901
902#define IWL_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */
903#define IWL_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */
904
905/* timeout equivalent to 3 minutes */
906#define IWL_TX_POWER_TIMELIMIT_NOCALIB 1800000000
907
908#define IWL_TX_POWER_CCK_COMPENSATION (9)
909
910#define MIN_TX_GAIN_INDEX (0)
911#define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9)
912#define MAX_TX_GAIN_INDEX_52GHZ (98)
913#define MIN_TX_GAIN_52GHZ (98)
914#define MAX_TX_GAIN_INDEX_24GHZ (98)
915#define MIN_TX_GAIN_24GHZ (98)
916#define MAX_TX_GAIN (0)
917#define MAX_TX_GAIN_52GHZ_EXT (-9)
918
919#define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34)
920#define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34)
921#define IWL_TX_POWER_REGULATORY_MIN (0)
922#define IWL_TX_POWER_REGULATORY_MAX (34)
923#define IWL_TX_POWER_DEFAULT_SATURATION_24 (38)
924#define IWL_TX_POWER_DEFAULT_SATURATION_52 (38)
925#define IWL_TX_POWER_SATURATION_MIN (20)
926#define IWL_TX_POWER_SATURATION_MAX (50)
927
928/* dv *0.4 = dt; so that 5 degrees temperature diff equals
929 * 12.5 in voltage diff */
930#define IWL_TX_TEMPERATURE_UPDATE_LIMIT 9
931
932#define IWL_INVALID_CHANNEL (0xffffffff)
933#define IWL_TX_POWER_REGITRY_BIT (2)
934
935#define MIN_IWL_TX_POWER_CALIB_DUR (100)
936#define IWL_CCK_FROM_OFDM_POWER_DIFF (-5)
937#define IWL_CCK_FROM_OFDM_INDEX_DIFF (9)
938
939/* Number of entries in the gain table */
940#define POWER_GAIN_NUM_ENTRIES 78
941#define TX_POW_MAX_SESSION_NUM 5
942/* timeout equivalent to 3 minutes */
943#define TX_IWL_TIMELIMIT_NOCALIB 1800000000
944
945/* Kedron TX_CALIB_STATES */
946#define IWL_TX_CALIB_STATE_SEND_TX 0x00000001
947#define IWL_TX_CALIB_WAIT_TX_RESPONSE 0x00000002
948#define IWL_TX_CALIB_ENABLED 0x00000004
949#define IWL_TX_CALIB_XVT_ON 0x00000008
950#define IWL_TX_CALIB_TEMPERATURE_CORRECT 0x00000010
951#define IWL_TX_CALIB_WORKING_WITH_XVT 0x00000020
952#define IWL_TX_CALIB_XVT_PERIODICAL 0x00000040
953
954#define NUM_IWL_TX_CALIB_SETTINS 5 /* Number of tx correction groups */
955
956#define IWL_MIN_POWER_IN_VP_TABLE 1 /* 0.5dBm multiplied by 2 */
957#define IWL_MAX_POWER_IN_VP_TABLE 40 /* 20dBm - multiplied by 2 (because
958 * entries are for each 0.5dBm) */
959#define IWL_STEP_IN_VP_TABLE 1 /* 0.5dB - multiplied by 2 */
960#define IWL_NUM_POINTS_IN_VPTABLE \
961 (1 + IWL_MAX_POWER_IN_VP_TABLE - IWL_MIN_POWER_IN_VP_TABLE)
962
963#define MIN_TX_GAIN_INDEX (0)
964#define MAX_TX_GAIN_INDEX_52GHZ (98)
965#define MIN_TX_GAIN_52GHZ (98)
966#define MAX_TX_GAIN_INDEX_24GHZ (98)
967#define MIN_TX_GAIN_24GHZ (98)
968#define MAX_TX_GAIN (0)
969
970/* First and last channels of all groups */
971#define CALIB_IWL_TX_ATTEN_GR1_FCH 34
972#define CALIB_IWL_TX_ATTEN_GR1_LCH 43
973#define CALIB_IWL_TX_ATTEN_GR2_FCH 44
974#define CALIB_IWL_TX_ATTEN_GR2_LCH 70
975#define CALIB_IWL_TX_ATTEN_GR3_FCH 71
976#define CALIB_IWL_TX_ATTEN_GR3_LCH 124
977#define CALIB_IWL_TX_ATTEN_GR4_FCH 125
978#define CALIB_IWL_TX_ATTEN_GR4_LCH 200
979#define CALIB_IWL_TX_ATTEN_GR5_FCH 1
980#define CALIB_IWL_TX_ATTEN_GR5_LCH 20
981
982
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800983union iwl4965_tx_power_dual_stream {
Zhu Yib481de92007-09-25 17:54:57 -0700984 struct {
985 u8 radio_tx_gain[2];
986 u8 dsp_predis_atten[2];
987 } s;
988 u32 dw;
989};
990
991/********************* END TXPOWER *****************************************/
992
993/* HT flags */
994#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
995#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1<<22)
996
997#define RXON_FLG_HT_OPERATING_MODE_POS (23)
998
999#define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1<<23)
1000#define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2<<23)
1001
1002#define RXON_FLG_CHANNEL_MODE_POS (25)
1003#define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3<<25)
1004#define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1<<25)
1005#define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2<<25)
1006
1007#define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1<<0)
1008#define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7<<1)
1009#define RXON_RX_CHAIN_VALID_POS (1)
1010#define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7<<4)
1011#define RXON_RX_CHAIN_FORCE_SEL_POS (4)
1012#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7<<7)
1013#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
1014#define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3<<10)
1015#define RXON_RX_CHAIN_CNT_POS (10)
1016#define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3<<12)
1017#define RXON_RX_CHAIN_MIMO_CNT_POS (12)
1018#define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1<<14)
1019#define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
1020
1021
1022#define MCS_DUP_6M_PLCP 0x20
1023
1024/* OFDM HT rate masks */
1025/* ***************************************** */
1026#define R_MCS_6M_MSK 0x1
1027#define R_MCS_12M_MSK 0x2
1028#define R_MCS_18M_MSK 0x4
1029#define R_MCS_24M_MSK 0x8
1030#define R_MCS_36M_MSK 0x10
1031#define R_MCS_48M_MSK 0x20
1032#define R_MCS_54M_MSK 0x40
1033#define R_MCS_60M_MSK 0x80
1034#define R_MCS_12M_DUAL_MSK 0x100
1035#define R_MCS_24M_DUAL_MSK 0x200
1036#define R_MCS_36M_DUAL_MSK 0x400
1037#define R_MCS_48M_DUAL_MSK 0x800
1038
1039#define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A))
1040#define is_siso(tbl) (((tbl) == LQ_SISO))
1041#define is_mimo(tbl) (((tbl) == LQ_MIMO))
1042#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
1043#define is_a_band(tbl) (((tbl) == LQ_A))
1044#define is_g_and(tbl) (((tbl) == LQ_G))
1045
1046/* Flow Handler Definitions */
1047
1048/**********************/
1049/* Addresses */
1050/**********************/
1051
1052#define FH_MEM_LOWER_BOUND (0x1000)
1053#define FH_MEM_UPPER_BOUND (0x1EF0)
1054
1055#define IWL_FH_REGS_LOWER_BOUND (0x1000)
1056#define IWL_FH_REGS_UPPER_BOUND (0x2000)
1057
1058#define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
1059
1060/* CBBC Area - Circular buffers base address cache pointers table */
1061#define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
1062#define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
1063/* queues 0 - 15 */
1064#define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
1065
1066/* RSCSR Area */
1067#define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
1068#define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
1069#define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
1070
1071#define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
1072#define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
1073#define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
1074
1075/* RCSR Area - Registers address map */
1076#define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
1077#define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0)
1078#define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND)
1079
1080#define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0)
1081
1082/* RSSR Area - Rx shared ctrl & status registers */
1083#define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
1084#define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
1085#define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
1086#define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
1087#define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
1088
1089/* TCSR */
1090#define IWL_FH_TCSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xD00)
1091#define IWL_FH_TCSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xE60)
1092
1093#define IWL_FH_TCSR_CHNL_NUM (7)
1094#define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
1095 (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
1096
1097/* TSSR Area - Tx shared status registers */
1098/* TSSR */
1099#define IWL_FH_TSSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEA0)
1100#define IWL_FH_TSSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEC0)
1101
1102#define IWL_FH_TSSR_TX_MSG_CONFIG_REG (IWL_FH_TSSR_LOWER_BOUND + 0x008)
1103#define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010)
1104
1105#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
1106#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
1107
1108#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_64B (0x00000000)
1109#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
1110#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_256B (0x00000800)
1111#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_512B (0x00000C00)
1112
1113#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
1114#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
1115
1116#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
1117#define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
1118
1119#define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \
1120 ((1 << (_chnl)) << 24)
1121#define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
1122 ((1 << (_chnl)) << 16)
1123
1124#define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
1125 (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
1126 IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
1127
1128/* TCSR: tx_config register values */
1129#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
1130#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
1131#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_ARC (0x00000002)
1132
1133#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
1134#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
1135
1136#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
1137#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
1138#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
1139
1140#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
1141#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
1142#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
1143
1144#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
1145#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
1146#define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
1147
1148#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
1149#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
1150#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
1151
1152#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
1153
1154#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
1155#define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
1156
1157/* RCSR: channel 0 rx_config register defines */
1158#define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
1159#define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
1160#define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
1161#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
1162#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
1163#define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
1164
1165#define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20)
1166#define FH_RCSR_RX_CONFIG_RB_SIZE_BITSHIFT (16)
1167
1168/* RCSR: rx_config register values */
1169#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
1170#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
1171#define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
1172
1173#define IWL_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
1174
1175/* RCSR channel 0 config register values */
1176#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
1177#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
1178
1179/* RSCSR: defs used in normal mode */
1180#define FH_RSCSR_CHNL0_RBDCB_WPTR_MASK (0x00000FFF) /* bits 0-11 */
1181
1182#define SCD_WIN_SIZE 64
1183#define SCD_FRAME_LIMIT 64
1184
Zhu Yib481de92007-09-25 17:54:57 -07001185/* SRAM structures */
1186#define SCD_CONTEXT_DATA_OFFSET 0x380
1187#define SCD_TX_STTS_BITMAP_OFFSET 0x400
1188#define SCD_TRANSLATE_TBL_OFFSET 0x500
1189#define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
1190#define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
1191 ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
1192
1193#define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
1194 ((1<<(hi))|((1<<(hi))-(1<<(lo))))
1195
1196
1197#define SCD_MODE_REG_BIT_SEARCH_MODE (1<<0)
1198#define SCD_MODE_REG_BIT_SBYP_MODE (1<<1)
1199
1200#define SCD_TXFIFO_POS_TID (0)
1201#define SCD_TXFIFO_POS_RA (4)
1202#define SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
1203#define SCD_QUEUE_STTS_REG_POS_TXF (1)
1204#define SCD_QUEUE_STTS_REG_POS_WSL (5)
1205#define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
1206#define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
1207#define SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
1208
1209#define SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
1210
1211#define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
1212#define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
1213#define SCD_QUEUE_CTX_REG1_CREDIT_POS (8)
1214#define SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00)
1215#define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24)
1216#define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000)
1217#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
1218#define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
1219
1220#define CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R (0x00000010)
1221#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00)
1222#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100)
1223#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200)
1224
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001225static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags)
Zhu Yib481de92007-09-25 17:54:57 -07001226{
1227 return le32_to_cpu(rate_n_flags) & 0xFF;
1228}
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001229static inline u16 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags)
Zhu Yib481de92007-09-25 17:54:57 -07001230{
1231 return le32_to_cpu(rate_n_flags) & 0xFFFF;
1232}
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001233static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
Zhu Yib481de92007-09-25 17:54:57 -07001234{
1235 return cpu_to_le32(flags|(u16)rate);
1236}
1237
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001238struct iwl4965_tfd_frame_data {
Zhu Yib481de92007-09-25 17:54:57 -07001239 __le32 tb1_addr;
1240
1241 __le32 val1;
1242 /* __le32 ptb1_32_35:4; */
1243#define IWL_tb1_addr_hi_POS 0
1244#define IWL_tb1_addr_hi_LEN 4
1245#define IWL_tb1_addr_hi_SYM val1
1246 /* __le32 tb_len1:12; */
1247#define IWL_tb1_len_POS 4
1248#define IWL_tb1_len_LEN 12
1249#define IWL_tb1_len_SYM val1
1250 /* __le32 ptb2_0_15:16; */
1251#define IWL_tb2_addr_lo16_POS 16
1252#define IWL_tb2_addr_lo16_LEN 16
1253#define IWL_tb2_addr_lo16_SYM val1
1254
1255 __le32 val2;
1256 /* __le32 ptb2_16_35:20; */
1257#define IWL_tb2_addr_hi20_POS 0
1258#define IWL_tb2_addr_hi20_LEN 20
1259#define IWL_tb2_addr_hi20_SYM val2
1260 /* __le32 tb_len2:12; */
1261#define IWL_tb2_len_POS 20
1262#define IWL_tb2_len_LEN 12
1263#define IWL_tb2_len_SYM val2
1264} __attribute__ ((packed));
1265
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001266struct iwl4965_tfd_frame {
Zhu Yib481de92007-09-25 17:54:57 -07001267 __le32 val0;
1268 /* __le32 rsvd1:24; */
1269 /* __le32 num_tbs:5; */
1270#define IWL_num_tbs_POS 24
1271#define IWL_num_tbs_LEN 5
1272#define IWL_num_tbs_SYM val0
1273 /* __le32 rsvd2:1; */
1274 /* __le32 padding:2; */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001275 struct iwl4965_tfd_frame_data pa[10];
Zhu Yib481de92007-09-25 17:54:57 -07001276 __le32 reserved;
1277} __attribute__ ((packed));
1278
1279#define IWL4965_MAX_WIN_SIZE 64
1280#define IWL4965_QUEUE_SIZE 256
1281#define IWL4965_NUM_FIFOS 7
1282#define IWL_MAX_NUM_QUEUES 16
1283
1284struct iwl4965_queue_byte_cnt_entry {
1285 __le16 val;
1286 /* __le16 byte_cnt:12; */
1287#define IWL_byte_cnt_POS 0
1288#define IWL_byte_cnt_LEN 12
1289#define IWL_byte_cnt_SYM val
1290 /* __le16 rsvd:4; */
1291} __attribute__ ((packed));
1292
1293struct iwl4965_sched_queue_byte_cnt_tbl {
1294 struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE +
1295 IWL4965_MAX_WIN_SIZE];
1296 u8 dont_care[1024 -
1297 (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) *
1298 sizeof(__le16)];
1299} __attribute__ ((packed));
1300
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001301/* Base physical address of iwl4965_shared is provided to KDR_SCD_DRAM_BASE_ADDR
1302 * and &iwl4965_shared.val0 is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG */
1303struct iwl4965_shared {
Zhu Yib481de92007-09-25 17:54:57 -07001304 struct iwl4965_sched_queue_byte_cnt_tbl
1305 queues_byte_cnt_tbls[IWL_MAX_NUM_QUEUES];
1306 __le32 val0;
1307
1308 /* __le32 rb_closed_stts_rb_num:12; */
1309#define IWL_rb_closed_stts_rb_num_POS 0
1310#define IWL_rb_closed_stts_rb_num_LEN 12
1311#define IWL_rb_closed_stts_rb_num_SYM val0
1312 /* __le32 rsrv1:4; */
1313 /* __le32 rb_closed_stts_rx_frame_num:12; */
1314#define IWL_rb_closed_stts_rx_frame_num_POS 16
1315#define IWL_rb_closed_stts_rx_frame_num_LEN 12
1316#define IWL_rb_closed_stts_rx_frame_num_SYM val0
1317 /* __le32 rsrv2:4; */
1318
1319 __le32 val1;
1320 /* __le32 frame_finished_stts_rb_num:12; */
1321#define IWL_frame_finished_stts_rb_num_POS 0
1322#define IWL_frame_finished_stts_rb_num_LEN 12
1323#define IWL_frame_finished_stts_rb_num_SYM val1
1324 /* __le32 rsrv3:4; */
1325 /* __le32 frame_finished_stts_rx_frame_num:12; */
1326#define IWL_frame_finished_stts_rx_frame_num_POS 16
1327#define IWL_frame_finished_stts_rx_frame_num_LEN 12
1328#define IWL_frame_finished_stts_rx_frame_num_SYM val1
1329 /* __le32 rsrv4:4; */
1330
1331 __le32 padding1; /* so that allocation will be aligned to 16B */
1332 __le32 padding2;
1333} __attribute__ ((packed));
1334
Christoph Hellwigbb8c0932008-01-27 16:41:47 -08001335#endif /* __iwl4965_4965_hw_h__ */