aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Cahill <ben.m.cahill@intel.com>2007-11-28 22:09:45 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:05:15 -0500
commit796083cb1d45d52d40ae2c933afcfc56d91ef427 (patch)
treec5dc4a5e7d6437a2a073ee15996f3b1e3ff7e657
parent7762635547ad31ecb045e7073989e76ae13e6c54 (diff)
iwlwifi: add comments to EEPROM stuff
Add comments to EEPROM stuff. Signed-off-by: Ben Cahill <ben.m.cahill@intel.com> Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945-hw.h94
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c9
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-hw.h209
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c9
4 files changed, 285 insertions, 36 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
index 8bbaa16442a..2c9f884be03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h
@@ -85,24 +85,48 @@
85#define IWL_RSSI_OFFSET 95 85#define IWL_RSSI_OFFSET 95
86 86
87/* 87/*
88 * This file defines EEPROM related constants, enums, and inline functions. 88 * EEPROM related constants, enums, and structures.
89 *
90 */ 89 */
91 90
91/*
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 */
92#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ 101#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
93#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */ 102#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
103
94/* EEPROM field values */ 104/* EEPROM field values */
95#define ANTENNA_SWITCH_NORMAL 0 105#define ANTENNA_SWITCH_NORMAL 0
96#define ANTENNA_SWITCH_INVERSE 1 106#define ANTENNA_SWITCH_INVERSE 1
97 107
108/*
109 * Regulatory channel usage flags in EEPROM struct iwl_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 3945 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 indicates that 20 MHz channel is supported;
118 * 3945 does not support FAT 40 MHz-wide channels.
119 *
120 * NOTE: Using a channel inappropriately will result in a uCode error!
121 */
98enum { 122enum {
99 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ 123 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
100 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ 124 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
101 /* Bit 2 Reserved */ 125 /* Bit 2 Reserved */
102 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ 126 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
103 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ 127 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
104 EEPROM_CHANNEL_WIDE = (1 << 5), 128 EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
105 EEPROM_CHANNEL_NARROW = (1 << 6), 129 EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel, not used */
106 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ 130 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
107}; 131};
108 132
@@ -147,6 +171,7 @@ struct iwl3945_eeprom_channel {
147 * long packets in normal operation to provide feedback as to proper output 171 * long packets in normal operation to provide feedback as to proper output
148 * level. 172 * level.
149 * Data copied from EEPROM. 173 * Data copied from EEPROM.
174 * DO NOT ALTER THIS STRUCTURE!!!
150 */ 175 */
151struct iwl3945_eeprom_txpower_sample { 176struct iwl3945_eeprom_txpower_sample {
152 u8 gain_index; /* index into power (gain) setup table ... */ 177 u8 gain_index; /* index into power (gain) setup table ... */
@@ -163,11 +188,11 @@ struct iwl3945_eeprom_txpower_sample {
163 * DO NOT ALTER THIS STRUCTURE!!! 188 * DO NOT ALTER THIS STRUCTURE!!!
164 */ 189 */
165struct iwl3945_eeprom_txpower_group { 190struct iwl3945_eeprom_txpower_group {
166 struct iwl3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ 191 struct iwl3945_eeprom_txpower_sample samples[5]; /* 5 power levels */
167 s32 a, b, c, d, e; /* coefficients for voltage->power 192 s32 a, b, c, d, e; /* coefficients for voltage->power
168 * formula (signed) */ 193 * formula (signed) */
169 s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on 194 s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
170 * frequency (signed) */ 195 * frequency (signed) */
171 s8 saturation_power; /* highest power possible by h/w in this 196 s8 saturation_power; /* highest power possible by h/w in this
172 * band */ 197 * band */
173 u8 group_channel; /* "representative" channel # in this band */ 198 u8 group_channel; /* "representative" channel # in this band */
@@ -189,6 +214,9 @@ struct iwl3945_eeprom_temperature_corr {
189 u32 Te; 214 u32 Te;
190} __attribute__ ((packed)); 215} __attribute__ ((packed));
191 216
217/*
218 * EEPROM map
219 */
192struct iwl3945_eeprom { 220struct iwl3945_eeprom {
193 u8 reserved0[16]; 221 u8 reserved0[16];
194#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ 222#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
@@ -229,29 +257,67 @@ struct iwl3945_eeprom {
229 u8 reserved6[42]; 257 u8 reserved6[42];
230#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ 258#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
231 u8 sku_id[4]; /* abs.ofs: 192 */ 259 u8 sku_id[4]; /* abs.ofs: 192 */
260
261/*
262 * Per-channel regulatory data.
263 *
264 * Each channel that *might* be supported by 3945 or 4965 has a fixed location
265 * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
266 * txpower (MSB).
267 *
268 * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
269 * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
270 *
271 * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
272 */
232#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ 273#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
233 u16 band_1_count; /* abs.ofs: 196 */ 274 u16 band_1_count; /* abs.ofs: 196 */
234#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ 275#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
235 struct iwl3945_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */ 276 struct iwl3945_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
277
278/*
279 * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
280 * 5.0 GHz channels 7, 8, 11, 12, 16
281 * (4915-5080MHz) (none of these is ever supported)
282 */
236#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ 283#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
237 u16 band_2_count; /* abs.ofs: 226 */ 284 u16 band_2_count; /* abs.ofs: 226 */
238#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ 285#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
239 struct iwl3945_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ 286 struct iwl3945_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
287
288/*
289 * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
290 * (5170-5320MHz)
291 */
240#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ 292#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
241 u16 band_3_count; /* abs.ofs: 254 */ 293 u16 band_3_count; /* abs.ofs: 254 */
242#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ 294#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
243 struct iwl3945_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ 295 struct iwl3945_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
296
297/*
298 * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
299 * (5500-5700MHz)
300 */
244#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ 301#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
245 u16 band_4_count; /* abs.ofs: 280 */ 302 u16 band_4_count; /* abs.ofs: 280 */
246#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ 303#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
247 struct iwl3945_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ 304 struct iwl3945_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
305
306/*
307 * 5.7 GHz channels 145, 149, 153, 157, 161, 165
308 * (5725-5825MHz)
309 */
248#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ 310#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
249 u16 band_5_count; /* abs.ofs: 304 */ 311 u16 band_5_count; /* abs.ofs: 304 */
250#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ 312#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
251 struct iwl3945_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ 313 struct iwl3945_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
252 314
253 u8 reserved9[194]; 315 u8 reserved9[194];
254 316
317
318/*
319 * 3945 Txpower calibration data.
320 */
255#define EEPROM_TXPOWER_CALIB_GROUP0 0x200 321#define EEPROM_TXPOWER_CALIB_GROUP0 0x200
256#define EEPROM_TXPOWER_CALIB_GROUP1 0x240 322#define EEPROM_TXPOWER_CALIB_GROUP1 0x240
257#define EEPROM_TXPOWER_CALIB_GROUP2 0x280 323#define EEPROM_TXPOWER_CALIB_GROUP2 0x280
@@ -261,12 +327,14 @@ struct iwl3945_eeprom {
261 struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS]; 327 struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS];
262/* abs.ofs: 512 */ 328/* abs.ofs: 512 */
263#define EEPROM_CALIB_TEMPERATURE_CORRECT 0x340 329#define EEPROM_CALIB_TEMPERATURE_CORRECT 0x340
264 struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ 330 struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
265 u8 reserved16[172]; /* fill out to full 1024 byte block */ 331 u8 reserved16[172]; /* fill out to full 1024 byte block */
266} __attribute__ ((packed)); 332} __attribute__ ((packed));
267 333
268#define IWL_EEPROM_IMAGE_SIZE 1024 334#define IWL_EEPROM_IMAGE_SIZE 1024
269 335
336/* End of EEPROM */
337
270 338
271#include "iwl-3945-commands.h" 339#include "iwl-3945-commands.h"
272 340
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 953a9bec063..51b90309ce5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -2202,6 +2202,7 @@ int iwl3945_init_hw_rate_table(struct iwl3945_priv *priv)
2202 &rate_cmd); 2202 &rate_cmd);
2203} 2203}
2204 2204
2205/* Called when initializing driver */
2205int iwl3945_hw_set_hw_setting(struct iwl3945_priv *priv) 2206int iwl3945_hw_set_hw_setting(struct iwl3945_priv *priv)
2206{ 2207{
2207 memset((void *)&priv->hw_setting, 0, 2208 memset((void *)&priv->hw_setting, 0,
@@ -2284,6 +2285,14 @@ struct pci_device_id iwl3945_hw_card_ids[] = {
2284 {0} 2285 {0}
2285}; 2286};
2286 2287
2288/*
2289 * Clear the OWNER_MSK, to establish driver (instead of uCode running on
2290 * embedded controller) as EEPROM reader; each read is a series of pulses
2291 * to/from the EEPROM chip, not a single event, so even reads could conflict
2292 * if they weren't arbitrated by some ownership mechanism. Here, the driver
2293 * simply claims ownership, which should be safe when this function is called
2294 * (i.e. before loading uCode!).
2295 */
2287inline int iwl3945_eeprom_acquire_semaphore(struct iwl3945_priv *priv) 2296inline int iwl3945_eeprom_acquire_semaphore(struct iwl3945_priv *priv)
2288{ 2297{
2289 _iwl3945_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); 2298 _iwl3945_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK);
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
index dfaa6077946..4741fa22831 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h
@@ -85,24 +85,50 @@
85#define IWL_RSSI_OFFSET 44 85#define IWL_RSSI_OFFSET 44
86 86
87/* 87/*
88 * This file defines EEPROM related constants, enums, and inline functions. 88 * EEPROM related constants, enums, and structures.
89 *
90 */ 89 */
91 90
91/*
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 */
92#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ 101#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
93#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */ 102#define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
103
94/* EEPROM field values */ 104/* EEPROM field values */
95#define ANTENNA_SWITCH_NORMAL 0 105#define ANTENNA_SWITCH_NORMAL 0
96#define ANTENNA_SWITCH_INVERSE 1 106#define ANTENNA_SWITCH_INVERSE 1
97 107
108/*
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 */
98enum { 124enum {
99 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ 125 EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
100 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ 126 EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
101 /* Bit 2 Reserved */ 127 /* Bit 2 Reserved */
102 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ 128 EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
103 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ 129 EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
104 EEPROM_CHANNEL_WIDE = (1 << 5), 130 EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
105 EEPROM_CHANNEL_NARROW = (1 << 6), 131 EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel, not used */
106 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ 132 EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
107}; 133};
108 134
@@ -136,9 +162,10 @@ enum {
136#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1) 162#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
137#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7) 163#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
138 164
139/* *regulatory* channel data from eeprom, one for each channel */ 165/* *regulatory* channel data format in eeprom, one for each channel.
166 * There are separate entries for FAT (40 MHz) vs. normal (20 MHz) channels. */
140struct iwl4965_eeprom_channel { 167struct iwl4965_eeprom_channel {
141 u8 flags; /* flags copied from EEPROM */ 168 u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */
142 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ 169 s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
143} __attribute__ ((packed)); 170} __attribute__ ((packed));
144 171
@@ -193,44 +220,112 @@ struct iwl4965_eeprom_temperature_corr {
193 u32 Te; 220 u32 Te;
194} __attribute__ ((packed)); 221} __attribute__ ((packed));
195 222
223/* 4965 has two radio transmitters (and 3 radio receivers) */
196#define EEPROM_TX_POWER_TX_CHAINS (2) 224#define EEPROM_TX_POWER_TX_CHAINS (2)
225
226/* 4965 has room for up to 8 sets of txpower calibration data */
197#define EEPROM_TX_POWER_BANDS (8) 227#define EEPROM_TX_POWER_BANDS (8)
228
229/* 4965 factory calibration measures txpower gain settings for
230 * each of 3 target output levels */
198#define EEPROM_TX_POWER_MEASUREMENTS (3) 231#define EEPROM_TX_POWER_MEASUREMENTS (3)
232
199#define EEPROM_TX_POWER_VERSION (2) 233#define EEPROM_TX_POWER_VERSION (2)
234
235/* 4965 driver does not work with txpower calibration version < 5.
236 * Look for this in calib_version member of struct iwl4965_eeprom. */
200#define EEPROM_TX_POWER_VERSION_NEW (5) 237#define EEPROM_TX_POWER_VERSION_NEW (5)
201 238
239
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 */
202struct iwl4965_eeprom_calib_measure { 254struct iwl4965_eeprom_calib_measure {
203 u8 temperature; 255 u8 temperature; /* Device temperature (Celsius) */
204 u8 gain_idx; 256 u8 gain_idx; /* Index into gain table */
205 u8 actual_pow; 257 u8 actual_pow; /* Measured RF output power, half-dBm */
206 s8 pa_det; 258 s8 pa_det; /* Power amp detector level (not used) */
207} __attribute__ ((packed)); 259} __attribute__ ((packed));
208 260
261
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 */
209struct iwl4965_eeprom_calib_ch_info { 270struct iwl4965_eeprom_calib_ch_info {
210 u8 ch_num; 271 u8 ch_num;
211 struct iwl4965_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS] 272 struct iwl4965_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS]
212 [EEPROM_TX_POWER_MEASUREMENTS]; 273 [EEPROM_TX_POWER_MEASUREMENTS];
213} __attribute__ ((packed)); 274} __attribute__ ((packed));
214 275
276/*
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 */
215struct iwl4965_eeprom_calib_subband_info { 286struct iwl4965_eeprom_calib_subband_info {
216 u8 ch_from; 287 u8 ch_from; /* channel number of lowest channel in subband */
217 u8 ch_to; 288 u8 ch_to; /* channel number of highest channel in subband */
218 struct iwl4965_eeprom_calib_ch_info ch1; 289 struct iwl4965_eeprom_calib_ch_info ch1;
219 struct iwl4965_eeprom_calib_ch_info ch2; 290 struct iwl4965_eeprom_calib_ch_info ch2;
220} __attribute__ ((packed)); 291} __attribute__ ((packed));
221 292
293
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 */
222struct iwl4965_eeprom_calib_info { 314struct iwl4965_eeprom_calib_info {
223 u8 saturation_power24; 315 u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
224 u8 saturation_power52; 316 u8 saturation_power52; /* half-dBm */
225 s16 voltage; /* signed */ 317 s16 voltage; /* signed */
226 struct iwl4965_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS]; 318 struct iwl4965_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS];
227} __attribute__ ((packed)); 319} __attribute__ ((packed));
228 320
229 321
322/*
323 * 4965 EEPROM map
324 */
230struct iwl4965_eeprom { 325struct iwl4965_eeprom {
231 u8 reserved0[16]; 326 u8 reserved0[16];
232#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ 327#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
233 u16 device_id; /* abs.ofs: 16 */ 328 u16 device_id; /* abs.ofs: 16 */
234 u8 reserved1[2]; 329 u8 reserved1[2];
235#define EEPROM_PMC (2*0x0A) /* 2 bytes */ 330#define EEPROM_PMC (2*0x0A) /* 2 bytes */
236 u16 pmc; /* abs.ofs: 20 */ 331 u16 pmc; /* abs.ofs: 20 */
@@ -273,40 +368,107 @@ struct iwl4965_eeprom {
273 u8 reserved8[10]; 368 u8 reserved8[10];
274#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ 369#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
275 u8 sku_id[4]; /* abs.ofs: 192 */ 370 u8 sku_id[4]; /* abs.ofs: 192 */
371
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 */
276#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ 384#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
277 u16 band_1_count; /* abs.ofs: 196 */ 385 u16 band_1_count; /* abs.ofs: 196 */
278#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ 386#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
279 struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */ 387 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 */
280#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ 394#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
281 u16 band_2_count; /* abs.ofs: 226 */ 395 u16 band_2_count; /* abs.ofs: 226 */
282#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ 396#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
283 struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ 397 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 */
284#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ 403#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
285 u16 band_3_count; /* abs.ofs: 254 */ 404 u16 band_3_count; /* abs.ofs: 254 */
286#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ 405#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
287 struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ 406 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 */
288#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ 412#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
289 u16 band_4_count; /* abs.ofs: 280 */ 413 u16 band_4_count; /* abs.ofs: 280 */
290#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ 414#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
291 struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ 415 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 */
292#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ 421#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
293 u16 band_5_count; /* abs.ofs: 304 */ 422 u16 band_5_count; /* abs.ofs: 304 */
294#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ 423#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
295 struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ 424 struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
296 425
297 u8 reserved10[2]; 426 u8 reserved10[2];
427
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 */
298#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */ 444#define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */
299 struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */ 445 struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */
300 u8 reserved11[2]; 446 u8 reserved11[2];
447
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 */
301#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */ 452#define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */
302 struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */ 453 struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */
303 u8 reserved12[6]; 454 u8 reserved12[6];
455
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 */
304#define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ 461#define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
305 u16 calib_version; /* abs.ofs: 364 */ 462 u16 calib_version; /* abs.ofs: 364 */
306 u8 reserved13[2]; 463 u8 reserved13[2];
464
307#define EEPROM_SATURATION_POWER_OFFSET (2*0xB8) /* 2 bytes */ 465#define EEPROM_SATURATION_POWER_OFFSET (2*0xB8) /* 2 bytes */
308 u16 satruation_power; /* abs.ofs: 368 */ 466 u16 satruation_power; /* abs.ofs: 368 */
309 u8 reserved14[94]; 467 u8 reserved14[94];
468
469/*
470 * 4965 Txpower calibration data.
471 */
310#define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ 472#define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
311 struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */ 473 struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */
312 474
@@ -317,6 +479,7 @@ struct iwl4965_eeprom {
317 479
318#define IWL_EEPROM_IMAGE_SIZE 1024 480#define IWL_EEPROM_IMAGE_SIZE 1024
319 481
482/* End of EEPROM */
320 483
321#include "iwl-4965-commands.h" 484#include "iwl-4965-commands.h"
322 485
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 5dee8e512c7..7d95de9d034 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -4687,14 +4687,23 @@ struct pci_device_id iwl4965_hw_card_ids[] = {
4687 {0} 4687 {0}
4688}; 4688};
4689 4689
4690/*
4691 * The device's EEPROM semaphore prevents conflicts between driver and uCode
4692 * when accessing the EEPROM; each access is a series of pulses to/from the
4693 * EEPROM chip, not a single event, so even reads could conflict if they
4694 * weren't arbitrated by the semaphore.
4695 */
4690int iwl4965_eeprom_acquire_semaphore(struct iwl4965_priv *priv) 4696int iwl4965_eeprom_acquire_semaphore(struct iwl4965_priv *priv)
4691{ 4697{
4692 u16 count; 4698 u16 count;
4693 int rc; 4699 int rc;
4694 4700
4695 for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { 4701 for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) {
4702 /* Request semaphore */
4696 iwl4965_set_bit(priv, CSR_HW_IF_CONFIG_REG, 4703 iwl4965_set_bit(priv, CSR_HW_IF_CONFIG_REG,
4697 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); 4704 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM);
4705
4706 /* See if we got it */
4698 rc = iwl4965_poll_bit(priv, CSR_HW_IF_CONFIG_REG, 4707 rc = iwl4965_poll_bit(priv, CSR_HW_IF_CONFIG_REG,
4699 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 4708 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,
4700 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 4709 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM,