blob: 4fa947d7bad553c5a11d76c611e47d6c89f8bd3d [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_3945_hw__
65#define __iwl_3945_hw__
66
Ben Cahill1fea8e82007-11-29 11:09:52 +080067/*
68 * uCode queue management definitions ...
69 * Queue #4 is the command queue for 3945 and 4965.
70 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080071#define IWL_CMD_QUEUE_NUM 4
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080072
73/* Tx rates */
74#define IWL_CCK_RATES 4
75#define IWL_OFDM_RATES 8
76
77#define IWL_HT_RATES 0
78
79#define IWL_MAX_RATES (IWL_CCK_RATES+IWL_OFDM_RATES+IWL_HT_RATES)
80
81/* Time constants */
82#define SHORT_SLOT_TIME 9
83#define LONG_SLOT_TIME 20
84
85/* RSSI to dBm */
86#define IWL_RSSI_OFFSET 95
87
88/*
Ben Cahill796083c2007-11-29 11:09:45 +080089 * EEPROM related constants, enums, and structures.
Christoph Hellwig5d08cd12007-10-25 17:15:50 +080090 */
91
Ben Cahill796083c2007-11-29 11:09:45 +080092/*
93 * EEPROM access time values:
94 *
95 * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG,
96 * then clearing (with subsequent read/modify/write) CSR_EEPROM_REG bit
97 * CSR_EEPROM_REG_BIT_CMD (0x2).
98 * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
99 * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
100 * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
101 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800102#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
103#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
Ben Cahill796083c2007-11-29 11:09:45 +0800104
Ben Cahill796083c2007-11-29 11:09:45 +0800105/*
106 * Regulatory channel usage flags in EEPROM struct iwl_eeprom_channel.flags.
107 *
108 * IBSS and/or AP operation is allowed *only* on those channels with
109 * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
110 * RADAR detection is not supported by the 3945 driver, but is a
111 * requirement for establishing a new network for legal operation on channels
112 * requiring RADAR detection or restricting ACTIVE scanning.
113 *
114 * NOTE: "WIDE" flag indicates that 20 MHz channel is supported;
115 * 3945 does not support FAT 40 MHz-wide channels.
116 *
117 * NOTE: Using a channel inappropriately will result in a uCode error!
118 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800119enum {
120 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
Ben Cahill796083c2007-11-29 11:09:45 +0800121 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800122 /* Bit 2 Reserved */
123 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
124 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
Ben Cahill796083c2007-11-29 11:09:45 +0800125 EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
Ben Cahill9948b542007-11-29 11:09:57 +0800126 EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel (not used) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800127 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
128};
129
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800130/* SKU Capabilities */
131#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
132#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
133#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
134
135/* *regulatory* channel data from eeprom, one for each channel */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800136struct iwl3945_eeprom_channel {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800137 u8 flags; /* flags copied from EEPROM */
138 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
139} __attribute__ ((packed));
140
141/*
142 * Mapping of a Tx power level, at factory calibration temperature,
143 * to a radio/DSP gain table index.
144 * One for each of 5 "sample" power levels in each band.
145 * v_det is measured at the factory, using the 3945's built-in power amplifier
146 * (PA) output voltage detector. This same detector is used during Tx of
147 * long packets in normal operation to provide feedback as to proper output
148 * level.
149 * Data copied from EEPROM.
Ben Cahill796083c2007-11-29 11:09:45 +0800150 * DO NOT ALTER THIS STRUCTURE!!!
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800151 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800152struct iwl3945_eeprom_txpower_sample {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800153 u8 gain_index; /* index into power (gain) setup table ... */
154 s8 power; /* ... for this pwr level for this chnl group */
155 u16 v_det; /* PA output voltage */
156} __attribute__ ((packed));
157
158/*
159 * Mappings of Tx power levels -> nominal radio/DSP gain table indexes.
160 * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
161 * Tx power setup code interpolates between the 5 "sample" power levels
162 * to determine the nominal setup for a requested power level.
163 * Data copied from EEPROM.
164 * DO NOT ALTER THIS STRUCTURE!!!
165 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800166struct iwl3945_eeprom_txpower_group {
Ben Cahill796083c2007-11-29 11:09:45 +0800167 struct iwl3945_eeprom_txpower_sample samples[5]; /* 5 power levels */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800168 s32 a, b, c, d, e; /* coefficients for voltage->power
169 * formula (signed) */
170 s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
Ben Cahill796083c2007-11-29 11:09:45 +0800171 * frequency (signed) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800172 s8 saturation_power; /* highest power possible by h/w in this
173 * band */
174 u8 group_channel; /* "representative" channel # in this band */
175 s16 temperature; /* h/w temperature at factory calib this band
176 * (signed) */
177} __attribute__ ((packed));
178
179/*
180 * Temperature-based Tx-power compensation data, not band-specific.
181 * These coefficients are use to modify a/b/c/d/e coeffs based on
182 * difference between current temperature and factory calib temperature.
183 * Data copied from EEPROM.
184 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800185struct iwl3945_eeprom_temperature_corr {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800186 u32 Ta;
187 u32 Tb;
188 u32 Tc;
189 u32 Td;
190 u32 Te;
191} __attribute__ ((packed));
192
Ben Cahill796083c2007-11-29 11:09:45 +0800193/*
194 * EEPROM map
195 */
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800196struct iwl3945_eeprom {
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800197 u8 reserved0[16];
198#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
199 u16 device_id; /* abs.ofs: 16 */
200 u8 reserved1[2];
201#define EEPROM_PMC (2*0x0A) /* 2 bytes */
202 u16 pmc; /* abs.ofs: 20 */
203 u8 reserved2[20];
204#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
205 u8 mac_address[6]; /* abs.ofs: 42 */
206 u8 reserved3[58];
207#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
208 u16 board_revision; /* abs.ofs: 106 */
209 u8 reserved4[11];
210#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
211 u8 board_pba_number[9]; /* abs.ofs: 119 */
212 u8 reserved5[8];
213#define EEPROM_VERSION (2*0x44) /* 2 bytes */
214 u16 version; /* abs.ofs: 136 */
215#define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
216 u8 sku_cap; /* abs.ofs: 138 */
217#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
218 u8 leds_mode; /* abs.ofs: 139 */
219#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
220 u16 oem_mode;
221#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
222 u16 wowlan_mode; /* abs.ofs: 142 */
223#define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
224 u16 leds_time_interval; /* abs.ofs: 144 */
225#define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
226 u8 leds_off_time; /* abs.ofs: 146 */
227#define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
228 u8 leds_on_time; /* abs.ofs: 147 */
229#define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
230 u8 almgor_m_version; /* abs.ofs: 148 */
231#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
232 u8 antenna_switch_type; /* abs.ofs: 149 */
233 u8 reserved6[42];
234#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
235 u8 sku_id[4]; /* abs.ofs: 192 */
Ben Cahill796083c2007-11-29 11:09:45 +0800236
237/*
238 * Per-channel regulatory data.
239 *
240 * Each channel that *might* be supported by 3945 or 4965 has a fixed location
241 * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
242 * txpower (MSB).
243 *
244 * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
245 * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
246 *
247 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
248 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800249#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
250 u16 band_1_count; /* abs.ofs: 196 */
251#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800252 struct iwl3945_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
253
254/*
255 * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
256 * 5.0 GHz channels 7, 8, 11, 12, 16
257 * (4915-5080MHz) (none of these is ever supported)
258 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800259#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
260 u16 band_2_count; /* abs.ofs: 226 */
261#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800262 struct iwl3945_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
263
264/*
265 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
266 * (5170-5320MHz)
267 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800268#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
269 u16 band_3_count; /* abs.ofs: 254 */
270#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800271 struct iwl3945_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
272
273/*
274 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
275 * (5500-5700MHz)
276 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800277#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
278 u16 band_4_count; /* abs.ofs: 280 */
279#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800280 struct iwl3945_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
281
282/*
283 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
284 * (5725-5825MHz)
285 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800286#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
287 u16 band_5_count; /* abs.ofs: 304 */
288#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
Ben Cahill796083c2007-11-29 11:09:45 +0800289 struct iwl3945_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800290
291 u8 reserved9[194];
292
Ben Cahill796083c2007-11-29 11:09:45 +0800293/*
294 * 3945 Txpower calibration data.
295 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800296#define EEPROM_TXPOWER_CALIB_GROUP0 0x200
297#define EEPROM_TXPOWER_CALIB_GROUP1 0x240
298#define EEPROM_TXPOWER_CALIB_GROUP2 0x280
299#define EEPROM_TXPOWER_CALIB_GROUP3 0x2c0
300#define EEPROM_TXPOWER_CALIB_GROUP4 0x300
301#define IWL_NUM_TX_CALIB_GROUPS 5
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800302 struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS];
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800303/* abs.ofs: 512 */
304#define EEPROM_CALIB_TEMPERATURE_CORRECT 0x340
Ben Cahill796083c2007-11-29 11:09:45 +0800305 struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800306 u8 reserved16[172]; /* fill out to full 1024 byte block */
307} __attribute__ ((packed));
308
309#define IWL_EEPROM_IMAGE_SIZE 1024
310
Ben Cahill796083c2007-11-29 11:09:45 +0800311/* End of EEPROM */
312
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800313
314#include "iwl-3945-commands.h"
315
316#define PCI_LINK_CTRL 0x0F0
317#define PCI_POWER_SOURCE 0x0C8
318#define PCI_REG_WUM8 0x0E8
319#define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
320
321/*=== CSR (control and status registers) ===*/
322#define CSR_BASE (0x000)
323
324#define CSR_SW_VER (CSR_BASE+0x000)
325#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */
326#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */
327#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */
328#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */
329#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/
330#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */
331#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
332#define CSR_GP_CNTRL (CSR_BASE+0x024)
Ben Cahill1fea8e82007-11-29 11:09:52 +0800333
334/*
335 * Hardware revision info
336 * Bit fields:
337 * 31-8: Reserved
338 * 7-4: Type of device: 0x0 = 4965, 0xd = 3945
339 * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D
340 * 1-0: "Dash" value, as in A-1, etc.
341 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800342#define CSR_HW_REV (CSR_BASE+0x028)
Ben Cahill1fea8e82007-11-29 11:09:52 +0800343
344/* EEPROM reads */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800345#define CSR_EEPROM_REG (CSR_BASE+0x02c)
346#define CSR_EEPROM_GP (CSR_BASE+0x030)
347#define CSR_GP_UCODE (CSR_BASE+0x044)
348#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
349#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058)
350#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
351#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800352#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800353
Ben Cahill1fea8e82007-11-29 11:09:52 +0800354/* Analog phase-lock-loop configuration (3945 only)
355 * Set bit 24. */
356#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
357
358/* Bits for CSR_HW_IF_CONFIG_REG */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800359#define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB (0x00000100)
360#define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM (0x00000200)
361#define CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400)
362#define CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800)
363#define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000)
364#define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000)
365#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
366
367/* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
368 * acknowledged (reset) by host writing "1" to flagged bits. */
369#define CSR_INT_BIT_FH_RX (1<<31) /* Rx DMA, cmd responses, FH_INT[17:16] */
370#define CSR_INT_BIT_HW_ERR (1<<29) /* DMA hardware error FH_INT[31] */
371#define CSR_INT_BIT_DNLD (1<<28) /* uCode Download */
372#define CSR_INT_BIT_FH_TX (1<<27) /* Tx DMA FH_INT[1:0] */
373#define CSR_INT_BIT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
374#define CSR_INT_BIT_SW_ERR (1<<25) /* uCode error */
375#define CSR_INT_BIT_RF_KILL (1<<7) /* HW RFKILL switch GP_CNTRL[27] toggled */
376#define CSR_INT_BIT_CT_KILL (1<<6) /* Critical temp (chip too hot) rfkill */
377#define CSR_INT_BIT_SW_RX (1<<3) /* Rx, command responses, 3945 */
378#define CSR_INT_BIT_WAKEUP (1<<1) /* NIC controller waking up (pwr mgmt) */
379#define CSR_INT_BIT_ALIVE (1<<0) /* uCode interrupts once it initializes */
380
381#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \
382 CSR_INT_BIT_HW_ERR | \
383 CSR_INT_BIT_FH_TX | \
384 CSR_INT_BIT_SW_ERR | \
385 CSR_INT_BIT_RF_KILL | \
386 CSR_INT_BIT_SW_RX | \
387 CSR_INT_BIT_WAKEUP | \
388 CSR_INT_BIT_ALIVE)
389
390/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
391#define CSR_FH_INT_BIT_ERR (1<<31) /* Error */
392#define CSR_FH_INT_BIT_HI_PRIOR (1<<30) /* High priority Rx, bypass coalescing */
393#define CSR_FH_INT_BIT_RX_CHNL2 (1<<18) /* Rx channel 2 (3945 only) */
394#define CSR_FH_INT_BIT_RX_CHNL1 (1<<17) /* Rx channel 1 */
395#define CSR_FH_INT_BIT_RX_CHNL0 (1<<16) /* Rx channel 0 */
396#define CSR_FH_INT_BIT_TX_CHNL6 (1<<6) /* Tx channel 6 (3945 only) */
397#define CSR_FH_INT_BIT_TX_CHNL1 (1<<1) /* Tx channel 1 */
398#define CSR_FH_INT_BIT_TX_CHNL0 (1<<0) /* Tx channel 0 */
399
400#define CSR_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \
401 CSR_FH_INT_BIT_RX_CHNL2 | \
402 CSR_FH_INT_BIT_RX_CHNL1 | \
403 CSR_FH_INT_BIT_RX_CHNL0)
404
405#define CSR_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL6 | \
406 CSR_FH_INT_BIT_TX_CHNL1 | \
Jeff Garzik93a3b602007-11-23 21:50:20 -0500407 CSR_FH_INT_BIT_TX_CHNL0)
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800408
409
410/* RESET */
411#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001)
412#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002)
413#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080)
414#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100)
415#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200)
416
417/* GP (general purpose) CONTROL */
418#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001)
419#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
420#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008)
421#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
422
423#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001)
424
425#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000)
426#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000)
427#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000)
428
429
430/* EEPROM REG */
431#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
432#define CSR_EEPROM_REG_BIT_CMD (0x00000002)
433
434/* EEPROM GP */
435#define CSR_EEPROM_GP_VALID_MSK (0x00000006)
436#define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
437#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
438
439/* UCODE DRV GP */
440#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001)
441#define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
442#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
443#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
444
445/* GPIO */
446#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200)
447#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000)
448#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC CSR_GPIO_IN_BIT_AUX_POWER
449
450/* GI Chicken Bits */
451#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
452#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
453
454/* CSR_ANA_PLL_CFG */
455#define CSR_ANA_PLL_CFG_SH (0x00880300)
456
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800457/*=== HBUS (Host-side Bus) ===*/
458#define HBUS_BASE (0x400)
459
Ben Cahill1fea8e82007-11-29 11:09:52 +0800460/*
461 * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
462 * structures, error log, event log, verifying uCode load).
463 * First write to address register, then read from or write to data register
464 * to complete the job. Once the address register is set up, accesses to
465 * data registers auto-increment the address by one dword.
466 * Bit usage for address registers (read or write):
467 * 0-31: memory address within device
468 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800469#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c)
470#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010)
471#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018)
472#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c)
Ben Cahill1fea8e82007-11-29 11:09:52 +0800473
474/*
475 * Registers for accessing device's internal peripheral registers
476 * (e.g. SCD, BSM, etc.). First write to address register,
477 * then read from or write to data register to complete the job.
478 * Bit usage for address registers (read or write):
479 * 0-15: register address (offset) within device
480 * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword)
481 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800482#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044)
483#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048)
484#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c)
485#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050)
Ben Cahill1fea8e82007-11-29 11:09:52 +0800486
487/*
488 * Per-Tx-queue write pointer (index, really!) (3945 and 4965).
489 * Indicates index to next TFD that driver will fill (1 past latest filled).
490 * Bit usage:
491 * 0-7: queue write index
492 * 11-8: queue selector
493 */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800494#define HBUS_TARG_WRPTR (HBUS_BASE+0x060)
495
Ben Cahill1fea8e82007-11-29 11:09:52 +0800496/* SCD (3945 Tx Frame Scheduler) */
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800497#define SCD_BASE (CSR_BASE + 0x2E00)
498
499#define SCD_MODE_REG (SCD_BASE + 0x000)
500#define SCD_ARASTAT_REG (SCD_BASE + 0x004)
501#define SCD_TXFACT_REG (SCD_BASE + 0x010)
502#define SCD_TXF4MF_REG (SCD_BASE + 0x014)
503#define SCD_TXF5MF_REG (SCD_BASE + 0x020)
504#define SCD_SBYP_MODE_1_REG (SCD_BASE + 0x02C)
505#define SCD_SBYP_MODE_2_REG (SCD_BASE + 0x030)
506
507/*=== FH (data Flow Handler) ===*/
508#define FH_BASE (0x800)
509
510#define FH_CBCC_TABLE (FH_BASE+0x140)
511#define FH_TFDB_TABLE (FH_BASE+0x180)
512#define FH_RCSR_TABLE (FH_BASE+0x400)
513#define FH_RSSR_TABLE (FH_BASE+0x4c0)
514#define FH_TCSR_TABLE (FH_BASE+0x500)
515#define FH_TSSR_TABLE (FH_BASE+0x680)
516
517/* TFDB (Transmit Frame Buffer Descriptor) */
518#define FH_TFDB(_channel, buf) \
519 (FH_TFDB_TABLE+((_channel)*2+(buf))*0x28)
520#define ALM_FH_TFDB_CHNL_BUF_CTRL_REG(_channel) \
521 (FH_TFDB_TABLE + 0x50 * _channel)
522/* CBCC _channel is [0,2] */
523#define FH_CBCC(_channel) (FH_CBCC_TABLE+(_channel)*0x8)
524#define FH_CBCC_CTRL(_channel) (FH_CBCC(_channel)+0x00)
525#define FH_CBCC_BASE(_channel) (FH_CBCC(_channel)+0x04)
526
527/* RCSR _channel is [0,2] */
528#define FH_RCSR(_channel) (FH_RCSR_TABLE+(_channel)*0x40)
529#define FH_RCSR_CONFIG(_channel) (FH_RCSR(_channel)+0x00)
530#define FH_RCSR_RBD_BASE(_channel) (FH_RCSR(_channel)+0x04)
531#define FH_RCSR_WPTR(_channel) (FH_RCSR(_channel)+0x20)
532#define FH_RCSR_RPTR_ADDR(_channel) (FH_RCSR(_channel)+0x24)
533
534#define FH_RSCSR_CHNL0_WPTR (FH_RCSR_WPTR(0))
535
536/* RSSR */
537#define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
538#define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
539/* TCSR */
540#define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
541#define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
542#define FH_TCSR_CREDIT(_channel) (FH_TCSR(_channel)+0x04)
543#define FH_TCSR_BUFF_STTS(_channel) (FH_TCSR(_channel)+0x08)
544/* TSSR */
545#define FH_TSSR_CBB_BASE (FH_TSSR_TABLE+0x000)
546#define FH_TSSR_MSG_CONFIG (FH_TSSR_TABLE+0x008)
547#define FH_TSSR_TX_STATUS (FH_TSSR_TABLE+0x010)
548/* 18 - reserved */
549
550/* card static random access memory (SRAM) for processor data and instructs */
551#define RTC_INST_LOWER_BOUND (0x000000)
552#define RTC_DATA_LOWER_BOUND (0x800000)
553
554
555/* DBM */
556
557#define ALM_FH_SRVC_CHNL (6)
558
559#define ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
560#define ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
561
562#define ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
563
564#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
565
566#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
567
568#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
569
570#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
571
572#define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
573
574#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
575#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
576
577#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
578#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
579
580#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
581
582#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
583
584#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
585#define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
586
587#define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
588
589#define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
590
591#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
592#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
593
594#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
595
596#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
597#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
598
599#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
600#define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
601
602#define ALM_TB_MAX_BYTES_COUNT (0xFFF0)
603
604#define ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
605 ((1LU << _channel) << 24)
606#define ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
607 ((1LU << _channel) << 16)
608
609#define ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
610 (ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
611 ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
612#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
613#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
614
615#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004)
616
617#define TFD_QUEUE_MIN 0
618#define TFD_QUEUE_MAX 6
619#define TFD_QUEUE_SIZE_MAX (256)
620
621/* spectrum and channel data structures */
622#define IWL_NUM_SCAN_RATES (2)
623
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800624#define IWL_DEFAULT_TX_RETRY 15
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800625
626/*********************************************/
627
628#define RFD_SIZE 4
629#define NUM_TFD_CHUNKS 4
630
631#define RX_QUEUE_SIZE 256
632#define RX_QUEUE_MASK 255
633#define RX_QUEUE_SIZE_LOG 8
634
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800635#define U32_PAD(n) ((4-(n))&0x3)
636
637/*
638 * Generic queue structure
639 *
640 * Contains common data for Rx and Tx queues
641 */
642#define TFD_CTL_COUNT_SET(n) (n<<24)
643#define TFD_CTL_COUNT_GET(ctl) ((ctl>>24) & 7)
644#define TFD_CTL_PAD_SET(n) (n<<28)
645#define TFD_CTL_PAD_GET(ctl) (ctl>>28)
646
647#define TFD_TX_CMD_SLOTS 256
648#define TFD_CMD_SLOTS 32
649
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800650#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl3945_cmd) - \
651 sizeof(struct iwl3945_cmd_meta))
Christoph Hellwig5d08cd12007-10-25 17:15:50 +0800652
653/*
654 * RX related structures and functions
655 */
656#define RX_FREE_BUFFERS 64
657#define RX_LOW_WATERMARK 8
658
659
Zhu Yib481de92007-09-25 17:54:57 -0700660#define IWL_RX_BUF_SIZE 3000
661/* card static random access memory (SRAM) for processor data and instructs */
662#define ALM_RTC_INST_UPPER_BOUND (0x014000)
663#define ALM_RTC_DATA_UPPER_BOUND (0x808000)
664
665#define ALM_RTC_INST_SIZE (ALM_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
666#define ALM_RTC_DATA_SIZE (ALM_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
667
668#define IWL_MAX_BSM_SIZE ALM_RTC_INST_SIZE
669#define IWL_MAX_INST_SIZE ALM_RTC_INST_SIZE
670#define IWL_MAX_DATA_SIZE ALM_RTC_DATA_SIZE
671#define IWL_MAX_NUM_QUEUES 8
672
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800673static inline int iwl3945_hw_valid_rtc_data_addr(u32 addr)
Zhu Yib481de92007-09-25 17:54:57 -0700674{
675 return (addr >= RTC_DATA_LOWER_BOUND) &&
676 (addr < ALM_RTC_DATA_UPPER_BOUND);
677}
678
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800679/* Base physical address of iwl3945_shared is provided to FH_TSSR_CBB_BASE
680 * and &iwl3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */
681struct iwl3945_shared {
Zhu Yib481de92007-09-25 17:54:57 -0700682 __le32 tx_base_ptr[8];
683 __le32 rx_read_ptr[3];
684} __attribute__ ((packed));
685
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800686struct iwl3945_tfd_frame_data {
Zhu Yib481de92007-09-25 17:54:57 -0700687 __le32 addr;
688 __le32 len;
689} __attribute__ ((packed));
690
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800691struct iwl3945_tfd_frame {
Zhu Yib481de92007-09-25 17:54:57 -0700692 __le32 control_flags;
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800693 struct iwl3945_tfd_frame_data pa[4];
Zhu Yib481de92007-09-25 17:54:57 -0700694 u8 reserved[28];
695} __attribute__ ((packed));
696
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800697static inline u8 iwl3945_hw_get_rate(__le16 rate_n_flags)
Zhu Yib481de92007-09-25 17:54:57 -0700698{
699 return le16_to_cpu(rate_n_flags) & 0xFF;
700}
701
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800702static inline u16 iwl3945_hw_get_rate_n_flags(__le16 rate_n_flags)
Zhu Yib481de92007-09-25 17:54:57 -0700703{
704 return le16_to_cpu(rate_n_flags);
705}
706
Christoph Hellwigbb8c0932008-01-27 16:41:47 -0800707static inline __le16 iwl3945_hw_set_rate_n_flags(u8 rate, u16 flags)
Zhu Yib481de92007-09-25 17:54:57 -0700708{
709 return cpu_to_le16((u16)rate|flags);
710}
711#endif