]>
Commit | Line | Data |
---|---|---|
b481de9c ZY |
1 | /****************************************************************************** |
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 | * | |
eb7ae89c | 8 | * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. |
b481de9c ZY |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify | |
01ebd063 | 11 | * it under the terms of version 2 of the GNU General Public License as |
b481de9c ZY |
12 | * 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: | |
759ef89f | 28 | * Intel Linux Wireless <ilw@linux.intel.com> |
b481de9c ZY |
29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
30 | * | |
31 | * BSD LICENSE | |
32 | * | |
eb7ae89c | 33 | * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. |
b481de9c ZY |
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 | *****************************************************************************/ | |
fcd427bb BC |
63 | /* |
64 | * Please use this file (iwl-4965-hw.h) only for hardware-related definitions. | |
5a36ba0e | 65 | * Use iwl-commands.h for uCode API definitions. |
3e0d4cb1 | 66 | * Use iwl-dev.h for driver implementation definitions. |
fcd427bb | 67 | */ |
b481de9c ZY |
68 | |
69 | #ifndef __iwl_4965_hw_h__ | |
70 | #define __iwl_4965_hw_h__ | |
71 | ||
4b52c39d EG |
72 | #include "iwl-fh.h" |
73 | ||
a96a27f9 | 74 | /* EEPROM */ |
073d3f5f TW |
75 | #define IWL4965_EEPROM_IMG_SIZE 1024 |
76 | ||
1fea8e88 BC |
77 | /* |
78 | * uCode queue management definitions ... | |
79 | * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4. | |
80 | * The first queue used for block-ack aggregation is #7 (4965 only). | |
81 | * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. | |
82 | */ | |
5d08cd1d CH |
83 | #define IWL_CMD_QUEUE_NUM 4 |
84 | #define IWL_CMD_FIFO_NUM 4 | |
7f3e4bb6 | 85 | #define IWL49_FIRST_AMPDU_QUEUE 7 |
5d08cd1d | 86 | |
5d08cd1d CH |
87 | /* Time constants */ |
88 | #define SHORT_SLOT_TIME 9 | |
89 | #define LONG_SLOT_TIME 20 | |
90 | ||
91 | /* RSSI to dBm */ | |
250bdd21 | 92 | #define IWL49_RSSI_OFFSET 44 |
5d08cd1d | 93 | |
5d08cd1d | 94 | |
5d08cd1d | 95 | |
8f061891 | 96 | /* PCI registers */ |
e7b63581 TW |
97 | #define PCI_CFG_RETRY_TIMEOUT 0x041 |
98 | #define PCI_CFG_POWER_SOURCE 0x0C8 | |
99 | #define PCI_REG_WUM8 0x0E8 | |
100 | #define PCI_CFG_LINK_CTRL 0x0F0 | |
8f061891 TW |
101 | |
102 | /* PCI register values */ | |
e7b63581 TW |
103 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 |
104 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 | |
105 | #define PCI_CFG_CMD_REG_INT_DIS_MSK 0x04 | |
5d08cd1d CH |
106 | #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) |
107 | ||
5d08cd1d | 108 | |
5d08cd1d CH |
109 | #define IWL_NUM_SCAN_RATES (2) |
110 | ||
5d08cd1d | 111 | #define IWL_DEFAULT_TX_RETRY 15 |
5d08cd1d CH |
112 | |
113 | #define RX_QUEUE_SIZE 256 | |
114 | #define RX_QUEUE_MASK 255 | |
115 | #define RX_QUEUE_SIZE_LOG 8 | |
116 | ||
5d08cd1d CH |
117 | /* |
118 | * RX related structures and functions | |
119 | */ | |
120 | #define RX_FREE_BUFFERS 64 | |
121 | #define RX_LOW_WATERMARK 8 | |
122 | ||
fcd427bb | 123 | /* Size of one Rx buffer in host DRAM */ |
9ee1ba47 RR |
124 | #define IWL_RX_BUF_SIZE_4K (4 * 1024) |
125 | #define IWL_RX_BUF_SIZE_8K (8 * 1024) | |
fcd427bb BC |
126 | |
127 | /* Sizes and addresses for instruction and data memory (SRAM) in | |
128 | * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ | |
250bdd21 | 129 | #define IWL49_RTC_INST_LOWER_BOUND (0x000000) |
12a81f60 | 130 | #define IWL49_RTC_INST_UPPER_BOUND (0x018000) |
fcd427bb | 131 | |
250bdd21 | 132 | #define IWL49_RTC_DATA_LOWER_BOUND (0x800000) |
12a81f60 | 133 | #define IWL49_RTC_DATA_UPPER_BOUND (0x80A000) |
fcd427bb | 134 | |
250bdd21 SO |
135 | #define IWL49_RTC_INST_SIZE (IWL49_RTC_INST_UPPER_BOUND - \ |
136 | IWL49_RTC_INST_LOWER_BOUND) | |
137 | #define IWL49_RTC_DATA_SIZE (IWL49_RTC_DATA_UPPER_BOUND - \ | |
138 | IWL49_RTC_DATA_LOWER_BOUND) | |
b481de9c | 139 | |
250bdd21 SO |
140 | #define IWL49_MAX_INST_SIZE IWL49_RTC_INST_SIZE |
141 | #define IWL49_MAX_DATA_SIZE IWL49_RTC_DATA_SIZE | |
b481de9c | 142 | |
fcd427bb | 143 | /* Size of uCode instruction memory in bootstrap state machine */ |
250bdd21 | 144 | #define IWL49_MAX_BSM_SIZE BSM_SRAM_SIZE |
fcd427bb | 145 | |
bb8c093b | 146 | static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) |
b481de9c | 147 | { |
250bdd21 | 148 | return (addr >= IWL49_RTC_DATA_LOWER_BOUND) && |
12a81f60 | 149 | (addr < IWL49_RTC_DATA_UPPER_BOUND); |
b481de9c ZY |
150 | } |
151 | ||
5991b419 | 152 | /********************* START TEMPERATURE *************************************/ |
b481de9c | 153 | |
0c434c5a | 154 | /** |
5991b419 BC |
155 | * 4965 temperature calculation. |
156 | * | |
157 | * The driver must calculate the device temperature before calculating | |
158 | * a txpower setting (amplifier gain is temperature dependent). The | |
159 | * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration | |
160 | * values used for the life of the driver, and one of which (R4) is the | |
161 | * real-time temperature indicator. | |
162 | * | |
163 | * uCode provides all 4 values to the driver via the "initialize alive" | |
164 | * notification (see struct iwl4965_init_alive_resp). After the runtime uCode | |
165 | * image loads, uCode updates the R4 value via statistics notifications | |
166 | * (see STATISTICS_NOTIFICATION), which occur after each received beacon | |
167 | * when associated, or can be requested via REPLY_STATISTICS_CMD. | |
168 | * | |
169 | * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver | |
170 | * must sign-extend to 32 bits before applying formula below. | |
171 | * | |
172 | * Formula: | |
173 | * | |
174 | * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 | |
175 | * | |
176 | * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is | |
177 | * an additional correction, which should be centered around 0 degrees | |
178 | * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for | |
179 | * centering the 97/100 correction around 0 degrees K. | |
180 | * | |
181 | * Add 273 to Kelvin value to find degrees Celsius, for comparing current | |
182 | * temperature with factory-measured temperatures when calculating txpower | |
183 | * settings. | |
184 | */ | |
b481de9c ZY |
185 | #define TEMPERATURE_CALIB_KELVIN_OFFSET 8 |
186 | #define TEMPERATURE_CALIB_A_VAL 259 | |
187 | ||
5991b419 | 188 | /* Limit range of calculated temperature to be between these Kelvin values */ |
b481de9c ZY |
189 | #define IWL_TX_POWER_TEMPERATURE_MIN (263) |
190 | #define IWL_TX_POWER_TEMPERATURE_MAX (410) | |
191 | ||
192 | #define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ | |
193 | (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \ | |
194 | ((t) > IWL_TX_POWER_TEMPERATURE_MAX)) | |
195 | ||
5991b419 BC |
196 | /********************* END TEMPERATURE ***************************************/ |
197 | ||
198 | /********************* START TXPOWER *****************************************/ | |
199 | ||
0c434c5a BC |
200 | /** |
201 | * 4965 txpower calculations rely on information from three sources: | |
202 | * | |
203 | * 1) EEPROM | |
204 | * 2) "initialize" alive notification | |
205 | * 3) statistics notifications | |
206 | * | |
207 | * EEPROM data consists of: | |
208 | * | |
209 | * 1) Regulatory information (max txpower and channel usage flags) is provided | |
210 | * separately for each channel that can possibly supported by 4965. | |
211 | * 40 MHz wide (.11n fat) channels are listed separately from 20 MHz | |
212 | * (legacy) channels. | |
213 | * | |
214 | * See struct iwl4965_eeprom_channel for format, and struct iwl4965_eeprom | |
215 | * for locations in EEPROM. | |
216 | * | |
217 | * 2) Factory txpower calibration information is provided separately for | |
218 | * sub-bands of contiguous channels. 2.4GHz has just one sub-band, | |
219 | * but 5 GHz has several sub-bands. | |
220 | * | |
221 | * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. | |
222 | * | |
223 | * See struct iwl4965_eeprom_calib_info (and the tree of structures | |
224 | * contained within it) for format, and struct iwl4965_eeprom for | |
225 | * locations in EEPROM. | |
226 | * | |
227 | * "Initialization alive" notification (see struct iwl4965_init_alive_resp) | |
228 | * consists of: | |
229 | * | |
230 | * 1) Temperature calculation parameters. | |
231 | * | |
232 | * 2) Power supply voltage measurement. | |
233 | * | |
234 | * 3) Tx gain compensation to balance 2 transmitters for MIMO use. | |
235 | * | |
236 | * Statistics notifications deliver: | |
237 | * | |
238 | * 1) Current values for temperature param R4. | |
239 | */ | |
5991b419 | 240 | |
0c434c5a BC |
241 | /** |
242 | * To calculate a txpower setting for a given desired target txpower, channel, | |
243 | * modulation bit rate, and transmitter chain (4965 has 2 transmitters to | |
244 | * support MIMO and transmit diversity), driver must do the following: | |
245 | * | |
246 | * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. | |
247 | * Do not exceed regulatory limit; reduce target txpower if necessary. | |
248 | * | |
249 | * If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), | |
250 | * 2 transmitters will be used simultaneously; driver must reduce the | |
251 | * regulatory limit by 3 dB (half-power) for each transmitter, so the | |
252 | * combined total output of the 2 transmitters is within regulatory limits. | |
253 | * | |
254 | * | |
255 | * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by | |
256 | * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); | |
257 | * reduce target txpower if necessary. | |
258 | * | |
259 | * Backoff values below are in 1/2 dB units (equivalent to steps in | |
260 | * txpower gain tables): | |
261 | * | |
262 | * OFDM 6 - 36 MBit: 10 steps (5 dB) | |
263 | * OFDM 48 MBit: 15 steps (7.5 dB) | |
264 | * OFDM 54 MBit: 17 steps (8.5 dB) | |
265 | * OFDM 60 MBit: 20 steps (10 dB) | |
266 | * CCK all rates: 10 steps (5 dB) | |
267 | * | |
268 | * Backoff values apply to saturation txpower on a per-transmitter basis; | |
269 | * when using MIMO (2 transmitters), each transmitter uses the same | |
270 | * saturation level provided in EEPROM, and the same backoff values; | |
271 | * no reduction (such as with regulatory txpower limits) is required. | |
272 | * | |
273 | * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel | |
274 | * widths and 40 Mhz (.11n fat) channel widths; there is no separate | |
275 | * factory measurement for fat channels. | |
276 | * | |
277 | * The result of this step is the final target txpower. The rest of | |
278 | * the steps figure out the proper settings for the device to achieve | |
279 | * that target txpower. | |
280 | * | |
281 | * | |
a96a27f9 TW |
282 | * 3) Determine (EEPROM) calibration sub band for the target channel, by |
283 | * comparing against first and last channels in each sub band | |
0c434c5a BC |
284 | * (see struct iwl4965_eeprom_calib_subband_info). |
285 | * | |
286 | * | |
287 | * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, | |
a96a27f9 | 288 | * referencing the 2 factory-measured (sample) channels within the sub band. |
0c434c5a BC |
289 | * |
290 | * Interpolation is based on difference between target channel's frequency | |
291 | * and the sample channels' frequencies. Since channel numbers are based | |
292 | * on frequency (5 MHz between each channel number), this is equivalent | |
293 | * to interpolating based on channel number differences. | |
294 | * | |
295 | * Note that the sample channels may or may not be the channels at the | |
a96a27f9 | 296 | * edges of the sub band. The target channel may be "outside" of the |
0c434c5a BC |
297 | * span of the sampled channels. |
298 | * | |
299 | * Driver may choose the pair (for 2 Tx chains) of measurements (see | |
300 | * struct iwl4965_eeprom_calib_ch_info) for which the actual measured | |
301 | * txpower comes closest to the desired txpower. Usually, though, | |
302 | * the middle set of measurements is closest to the regulatory limits, | |
303 | * and is therefore a good choice for all txpower calculations (this | |
304 | * assumes that high accuracy is needed for maximizing legal txpower, | |
305 | * while lower txpower configurations do not need as much accuracy). | |
306 | * | |
307 | * Driver should interpolate both members of the chosen measurement pair, | |
308 | * i.e. for both Tx chains (radio transmitters), unless the driver knows | |
309 | * that only one of the chains will be used (e.g. only one tx antenna | |
310 | * connected, but this should be unusual). The rate scaling algorithm | |
311 | * switches antennas to find best performance, so both Tx chains will | |
312 | * be used (although only one at a time) even for non-MIMO transmissions. | |
313 | * | |
314 | * Driver should interpolate factory values for temperature, gain table | |
315 | * index, and actual power. The power amplifier detector values are | |
316 | * not used by the driver. | |
317 | * | |
318 | * Sanity check: If the target channel happens to be one of the sample | |
319 | * channels, the results should agree with the sample channel's | |
320 | * measurements! | |
321 | * | |
322 | * | |
323 | * 5) Find difference between desired txpower and (interpolated) | |
324 | * factory-measured txpower. Using (interpolated) factory gain table index | |
325 | * (shown elsewhere) as a starting point, adjust this index lower to | |
326 | * increase txpower, or higher to decrease txpower, until the target | |
327 | * txpower is reached. Each step in the gain table is 1/2 dB. | |
328 | * | |
329 | * For example, if factory measured txpower is 16 dBm, and target txpower | |
330 | * is 13 dBm, add 6 steps to the factory gain index to reduce txpower | |
331 | * by 3 dB. | |
332 | * | |
333 | * | |
334 | * 6) Find difference between current device temperature and (interpolated) | |
335 | * factory-measured temperature for sub-band. Factory values are in | |
336 | * degrees Celsius. To calculate current temperature, see comments for | |
337 | * "4965 temperature calculation". | |
338 | * | |
339 | * If current temperature is higher than factory temperature, driver must | |
a96a27f9 | 340 | * increase gain (lower gain table index), and vice verse. |
0c434c5a BC |
341 | * |
342 | * Temperature affects gain differently for different channels: | |
343 | * | |
344 | * 2.4 GHz all channels: 3.5 degrees per half-dB step | |
345 | * 5 GHz channels 34-43: 4.5 degrees per half-dB step | |
346 | * 5 GHz channels >= 44: 4.0 degrees per half-dB step | |
347 | * | |
348 | * NOTE: Temperature can increase rapidly when transmitting, especially | |
349 | * with heavy traffic at high txpowers. Driver should update | |
350 | * temperature calculations often under these conditions to | |
351 | * maintain strong txpower in the face of rising temperature. | |
352 | * | |
353 | * | |
354 | * 7) Find difference between current power supply voltage indicator | |
355 | * (from "initialize alive") and factory-measured power supply voltage | |
356 | * indicator (EEPROM). | |
357 | * | |
358 | * If the current voltage is higher (indicator is lower) than factory | |
359 | * voltage, gain should be reduced (gain table index increased) by: | |
360 | * | |
361 | * (eeprom - current) / 7 | |
362 | * | |
363 | * If the current voltage is lower (indicator is higher) than factory | |
364 | * voltage, gain should be increased (gain table index decreased) by: | |
365 | * | |
366 | * 2 * (current - eeprom) / 7 | |
367 | * | |
368 | * If number of index steps in either direction turns out to be > 2, | |
369 | * something is wrong ... just use 0. | |
370 | * | |
371 | * NOTE: Voltage compensation is independent of band/channel. | |
372 | * | |
373 | * NOTE: "Initialize" uCode measures current voltage, which is assumed | |
374 | * to be constant after this initial measurement. Voltage | |
375 | * compensation for txpower (number of steps in gain table) | |
376 | * may be calculated once and used until the next uCode bootload. | |
377 | * | |
378 | * | |
379 | * 8) If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), | |
380 | * adjust txpower for each transmitter chain, so txpower is balanced | |
381 | * between the two chains. There are 5 pairs of tx_atten[group][chain] | |
382 | * values in "initialize alive", one pair for each of 5 channel ranges: | |
383 | * | |
384 | * Group 0: 5 GHz channel 34-43 | |
385 | * Group 1: 5 GHz channel 44-70 | |
386 | * Group 2: 5 GHz channel 71-124 | |
387 | * Group 3: 5 GHz channel 125-200 | |
388 | * Group 4: 2.4 GHz all channels | |
389 | * | |
390 | * Add the tx_atten[group][chain] value to the index for the target chain. | |
391 | * The values are signed, but are in pairs of 0 and a non-negative number, | |
392 | * so as to reduce gain (if necessary) of the "hotter" channel. This | |
393 | * avoids any need to double-check for regulatory compliance after | |
394 | * this step. | |
395 | * | |
396 | * | |
397 | * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation | |
398 | * value to the index: | |
399 | * | |
400 | * Hardware rev B: 9 steps (4.5 dB) | |
401 | * Hardware rev C: 5 steps (2.5 dB) | |
402 | * | |
403 | * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, | |
404 | * bits [3:2], 1 = B, 2 = C. | |
405 | * | |
406 | * NOTE: This compensation is in addition to any saturation backoff that | |
407 | * might have been applied in an earlier step. | |
408 | * | |
409 | * | |
410 | * 10) Select the gain table, based on band (2.4 vs 5 GHz). | |
411 | * | |
412 | * Limit the adjusted index to stay within the table! | |
413 | * | |
414 | * | |
415 | * 11) Read gain table entries for DSP and radio gain, place into appropriate | |
416 | * location(s) in command (struct iwl4965_txpowertable_cmd). | |
417 | */ | |
b481de9c | 418 | |
0c434c5a | 419 | /* Limit range of txpower output target to be between these values */ |
b481de9c ZY |
420 | #define IWL_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */ |
421 | #define IWL_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */ | |
422 | ||
0c434c5a BC |
423 | /** |
424 | * When MIMO is used (2 transmitters operating simultaneously), driver should | |
425 | * limit each transmitter to deliver a max of 3 dB below the regulatory limit | |
426 | * for the device. That is, use half power for each transmitter, so total | |
427 | * txpower is within regulatory limits. | |
428 | * | |
429 | * The value "6" represents number of steps in gain table to reduce power 3 dB. | |
430 | * Each step is 1/2 dB. | |
431 | */ | |
432 | #define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) | |
433 | ||
434 | /** | |
435 | * CCK gain compensation. | |
436 | * | |
437 | * When calculating txpowers for CCK, after making sure that the target power | |
438 | * is within regulatory and saturation limits, driver must additionally | |
439 | * back off gain by adding these values to the gain table index. | |
440 | * | |
441 | * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, | |
442 | * bits [3:2], 1 = B, 2 = C. | |
443 | */ | |
444 | #define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9) | |
445 | #define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5) | |
446 | ||
447 | /* | |
448 | * 4965 power supply voltage compensation for txpower | |
449 | */ | |
450 | #define TX_POWER_IWL_VOLTAGE_CODES_PER_03V (7) | |
451 | ||
452 | /** | |
453 | * Gain tables. | |
454 | * | |
455 | * The following tables contain pair of values for setting txpower, i.e. | |
456 | * gain settings for the output of the device's digital signal processor (DSP), | |
457 | * and for the analog gain structure of the transmitter. | |
458 | * | |
459 | * Each entry in the gain tables represents a step of 1/2 dB. Note that these | |
460 | * are *relative* steps, not indications of absolute output power. Output | |
461 | * power varies with temperature, voltage, and channel frequency, and also | |
462 | * requires consideration of average power (to satisfy regulatory constraints), | |
463 | * and peak power (to avoid distortion of the output signal). | |
464 | * | |
465 | * Each entry contains two values: | |
466 | * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained | |
467 | * linear value that multiplies the output of the digital signal processor, | |
468 | * before being sent to the analog radio. | |
469 | * 2) Radio gain. This sets the analog gain of the radio Tx path. | |
470 | * It is a coarser setting, and behaves in a logarithmic (dB) fashion. | |
471 | * | |
472 | * EEPROM contains factory calibration data for txpower. This maps actual | |
473 | * measured txpower levels to gain settings in the "well known" tables | |
474 | * below ("well-known" means here that both factory calibration *and* the | |
475 | * driver work with the same table). | |
476 | * | |
477 | * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table | |
478 | * has an extension (into negative indexes), in case the driver needs to | |
479 | * boost power setting for high device temperatures (higher than would be | |
480 | * present during factory calibration). A 5 Ghz EEPROM index of "40" | |
481 | * corresponds to the 49th entry in the table used by the driver. | |
482 | */ | |
483 | #define MIN_TX_GAIN_INDEX (0) /* highest gain, lowest idx, 2.4 */ | |
484 | #define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ | |
485 | ||
486 | /** | |
487 | * 2.4 GHz gain table | |
488 | * | |
489 | * Index Dsp gain Radio gain | |
490 | * 0 110 0x3f (highest gain) | |
491 | * 1 104 0x3f | |
492 | * 2 98 0x3f | |
493 | * 3 110 0x3e | |
494 | * 4 104 0x3e | |
495 | * 5 98 0x3e | |
496 | * 6 110 0x3d | |
497 | * 7 104 0x3d | |
498 | * 8 98 0x3d | |
499 | * 9 110 0x3c | |
500 | * 10 104 0x3c | |
501 | * 11 98 0x3c | |
502 | * 12 110 0x3b | |
503 | * 13 104 0x3b | |
504 | * 14 98 0x3b | |
505 | * 15 110 0x3a | |
506 | * 16 104 0x3a | |
507 | * 17 98 0x3a | |
508 | * 18 110 0x39 | |
509 | * 19 104 0x39 | |
510 | * 20 98 0x39 | |
511 | * 21 110 0x38 | |
512 | * 22 104 0x38 | |
513 | * 23 98 0x38 | |
514 | * 24 110 0x37 | |
515 | * 25 104 0x37 | |
516 | * 26 98 0x37 | |
517 | * 27 110 0x36 | |
518 | * 28 104 0x36 | |
519 | * 29 98 0x36 | |
520 | * 30 110 0x35 | |
521 | * 31 104 0x35 | |
522 | * 32 98 0x35 | |
523 | * 33 110 0x34 | |
524 | * 34 104 0x34 | |
525 | * 35 98 0x34 | |
526 | * 36 110 0x33 | |
527 | * 37 104 0x33 | |
528 | * 38 98 0x33 | |
529 | * 39 110 0x32 | |
530 | * 40 104 0x32 | |
531 | * 41 98 0x32 | |
532 | * 42 110 0x31 | |
533 | * 43 104 0x31 | |
534 | * 44 98 0x31 | |
535 | * 45 110 0x30 | |
536 | * 46 104 0x30 | |
537 | * 47 98 0x30 | |
538 | * 48 110 0x6 | |
539 | * 49 104 0x6 | |
540 | * 50 98 0x6 | |
541 | * 51 110 0x5 | |
542 | * 52 104 0x5 | |
543 | * 53 98 0x5 | |
544 | * 54 110 0x4 | |
545 | * 55 104 0x4 | |
546 | * 56 98 0x4 | |
547 | * 57 110 0x3 | |
548 | * 58 104 0x3 | |
549 | * 59 98 0x3 | |
550 | * 60 110 0x2 | |
551 | * 61 104 0x2 | |
552 | * 62 98 0x2 | |
553 | * 63 110 0x1 | |
554 | * 64 104 0x1 | |
555 | * 65 98 0x1 | |
556 | * 66 110 0x0 | |
557 | * 67 104 0x0 | |
558 | * 68 98 0x0 | |
559 | * 69 97 0 | |
560 | * 70 96 0 | |
561 | * 71 95 0 | |
562 | * 72 94 0 | |
563 | * 73 93 0 | |
564 | * 74 92 0 | |
565 | * 75 91 0 | |
566 | * 76 90 0 | |
567 | * 77 89 0 | |
568 | * 78 88 0 | |
569 | * 79 87 0 | |
570 | * 80 86 0 | |
571 | * 81 85 0 | |
572 | * 82 84 0 | |
573 | * 83 83 0 | |
574 | * 84 82 0 | |
575 | * 85 81 0 | |
576 | * 86 80 0 | |
577 | * 87 79 0 | |
578 | * 88 78 0 | |
579 | * 89 77 0 | |
580 | * 90 76 0 | |
581 | * 91 75 0 | |
582 | * 92 74 0 | |
583 | * 93 73 0 | |
584 | * 94 72 0 | |
585 | * 95 71 0 | |
586 | * 96 70 0 | |
587 | * 97 69 0 | |
588 | * 98 68 0 | |
589 | */ | |
590 | ||
591 | /** | |
592 | * 5 GHz gain table | |
593 | * | |
594 | * Index Dsp gain Radio gain | |
595 | * -9 123 0x3F (highest gain) | |
596 | * -8 117 0x3F | |
597 | * -7 110 0x3F | |
598 | * -6 104 0x3F | |
599 | * -5 98 0x3F | |
600 | * -4 110 0x3E | |
601 | * -3 104 0x3E | |
602 | * -2 98 0x3E | |
603 | * -1 110 0x3D | |
604 | * 0 104 0x3D | |
605 | * 1 98 0x3D | |
606 | * 2 110 0x3C | |
607 | * 3 104 0x3C | |
608 | * 4 98 0x3C | |
609 | * 5 110 0x3B | |
610 | * 6 104 0x3B | |
611 | * 7 98 0x3B | |
612 | * 8 110 0x3A | |
613 | * 9 104 0x3A | |
614 | * 10 98 0x3A | |
615 | * 11 110 0x39 | |
616 | * 12 104 0x39 | |
617 | * 13 98 0x39 | |
618 | * 14 110 0x38 | |
619 | * 15 104 0x38 | |
620 | * 16 98 0x38 | |
621 | * 17 110 0x37 | |
622 | * 18 104 0x37 | |
623 | * 19 98 0x37 | |
624 | * 20 110 0x36 | |
625 | * 21 104 0x36 | |
626 | * 22 98 0x36 | |
627 | * 23 110 0x35 | |
628 | * 24 104 0x35 | |
629 | * 25 98 0x35 | |
630 | * 26 110 0x34 | |
631 | * 27 104 0x34 | |
632 | * 28 98 0x34 | |
633 | * 29 110 0x33 | |
634 | * 30 104 0x33 | |
635 | * 31 98 0x33 | |
636 | * 32 110 0x32 | |
637 | * 33 104 0x32 | |
638 | * 34 98 0x32 | |
639 | * 35 110 0x31 | |
640 | * 36 104 0x31 | |
641 | * 37 98 0x31 | |
642 | * 38 110 0x30 | |
643 | * 39 104 0x30 | |
644 | * 40 98 0x30 | |
645 | * 41 110 0x25 | |
646 | * 42 104 0x25 | |
647 | * 43 98 0x25 | |
648 | * 44 110 0x24 | |
649 | * 45 104 0x24 | |
650 | * 46 98 0x24 | |
651 | * 47 110 0x23 | |
652 | * 48 104 0x23 | |
653 | * 49 98 0x23 | |
654 | * 50 110 0x22 | |
655 | * 51 104 0x18 | |
656 | * 52 98 0x18 | |
657 | * 53 110 0x17 | |
658 | * 54 104 0x17 | |
659 | * 55 98 0x17 | |
660 | * 56 110 0x16 | |
661 | * 57 104 0x16 | |
662 | * 58 98 0x16 | |
663 | * 59 110 0x15 | |
664 | * 60 104 0x15 | |
665 | * 61 98 0x15 | |
666 | * 62 110 0x14 | |
667 | * 63 104 0x14 | |
668 | * 64 98 0x14 | |
669 | * 65 110 0x13 | |
670 | * 66 104 0x13 | |
671 | * 67 98 0x13 | |
672 | * 68 110 0x12 | |
673 | * 69 104 0x08 | |
674 | * 70 98 0x08 | |
675 | * 71 110 0x07 | |
676 | * 72 104 0x07 | |
677 | * 73 98 0x07 | |
678 | * 74 110 0x06 | |
679 | * 75 104 0x06 | |
680 | * 76 98 0x06 | |
681 | * 77 110 0x05 | |
682 | * 78 104 0x05 | |
683 | * 79 98 0x05 | |
684 | * 80 110 0x04 | |
685 | * 81 104 0x04 | |
686 | * 82 98 0x04 | |
687 | * 83 110 0x03 | |
688 | * 84 104 0x03 | |
689 | * 85 98 0x03 | |
690 | * 86 110 0x02 | |
691 | * 87 104 0x02 | |
692 | * 88 98 0x02 | |
693 | * 89 110 0x01 | |
694 | * 90 104 0x01 | |
695 | * 91 98 0x01 | |
696 | * 92 110 0x00 | |
697 | * 93 104 0x00 | |
698 | * 94 98 0x00 | |
699 | * 95 93 0x00 | |
700 | * 96 88 0x00 | |
701 | * 97 83 0x00 | |
702 | * 98 78 0x00 | |
703 | */ | |
b481de9c | 704 | |
0c434c5a BC |
705 | |
706 | /** | |
707 | * Sanity checks and default values for EEPROM regulatory levels. | |
708 | * If EEPROM values fall outside MIN/MAX range, use default values. | |
709 | * | |
710 | * Regulatory limits refer to the maximum average txpower allowed by | |
711 | * regulatory agencies in the geographies in which the device is meant | |
712 | * to be operated. These limits are SKU-specific (i.e. geography-specific), | |
713 | * and channel-specific; each channel has an individual regulatory limit | |
714 | * listed in the EEPROM. | |
715 | * | |
716 | * Units are in half-dBm (i.e. "34" means 17 dBm). | |
717 | */ | |
b481de9c ZY |
718 | #define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34) |
719 | #define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34) | |
720 | #define IWL_TX_POWER_REGULATORY_MIN (0) | |
721 | #define IWL_TX_POWER_REGULATORY_MAX (34) | |
0c434c5a BC |
722 | |
723 | /** | |
724 | * Sanity checks and default values for EEPROM saturation levels. | |
725 | * If EEPROM values fall outside MIN/MAX range, use default values. | |
726 | * | |
727 | * Saturation is the highest level that the output power amplifier can produce | |
728 | * without significant clipping distortion. This is a "peak" power level. | |
729 | * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) | |
730 | * require differing amounts of backoff, relative to their average power output, | |
731 | * in order to avoid clipping distortion. | |
732 | * | |
733 | * Driver must make sure that it is violating neither the saturation limit, | |
734 | * nor the regulatory limit, when calculating Tx power settings for various | |
735 | * rates. | |
736 | * | |
737 | * Units are in half-dBm (i.e. "38" means 19 dBm). | |
738 | */ | |
b481de9c ZY |
739 | #define IWL_TX_POWER_DEFAULT_SATURATION_24 (38) |
740 | #define IWL_TX_POWER_DEFAULT_SATURATION_52 (38) | |
741 | #define IWL_TX_POWER_SATURATION_MIN (20) | |
742 | #define IWL_TX_POWER_SATURATION_MAX (50) | |
743 | ||
0c434c5a BC |
744 | /** |
745 | * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) | |
746 | * and thermal Txpower calibration. | |
747 | * | |
748 | * When calculating txpower, driver must compensate for current device | |
749 | * temperature; higher temperature requires higher gain. Driver must calculate | |
750 | * current temperature (see "4965 temperature calculation"), then compare vs. | |
751 | * factory calibration temperature in EEPROM; if current temperature is higher | |
752 | * than factory temperature, driver must *increase* gain by proportions shown | |
753 | * in table below. If current temperature is lower than factory, driver must | |
754 | * *decrease* gain. | |
755 | * | |
756 | * Different frequency ranges require different compensation, as shown below. | |
757 | */ | |
758 | /* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ | |
b481de9c ZY |
759 | #define CALIB_IWL_TX_ATTEN_GR1_FCH 34 |
760 | #define CALIB_IWL_TX_ATTEN_GR1_LCH 43 | |
0c434c5a BC |
761 | |
762 | /* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ | |
b481de9c ZY |
763 | #define CALIB_IWL_TX_ATTEN_GR2_FCH 44 |
764 | #define CALIB_IWL_TX_ATTEN_GR2_LCH 70 | |
0c434c5a BC |
765 | |
766 | /* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ | |
b481de9c ZY |
767 | #define CALIB_IWL_TX_ATTEN_GR3_FCH 71 |
768 | #define CALIB_IWL_TX_ATTEN_GR3_LCH 124 | |
0c434c5a BC |
769 | |
770 | /* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ | |
b481de9c ZY |
771 | #define CALIB_IWL_TX_ATTEN_GR4_FCH 125 |
772 | #define CALIB_IWL_TX_ATTEN_GR4_LCH 200 | |
0c434c5a BC |
773 | |
774 | /* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ | |
b481de9c ZY |
775 | #define CALIB_IWL_TX_ATTEN_GR5_FCH 1 |
776 | #define CALIB_IWL_TX_ATTEN_GR5_LCH 20 | |
777 | ||
0c434c5a BC |
778 | enum { |
779 | CALIB_CH_GROUP_1 = 0, | |
780 | CALIB_CH_GROUP_2 = 1, | |
781 | CALIB_CH_GROUP_3 = 2, | |
782 | CALIB_CH_GROUP_4 = 3, | |
783 | CALIB_CH_GROUP_5 = 4, | |
784 | CALIB_CH_GROUP_MAX | |
785 | }; | |
786 | ||
b481de9c ZY |
787 | /********************* END TXPOWER *****************************************/ |
788 | ||
5d5456fe BC |
789 | |
790 | /** | |
791 | * Tx/Rx Queues | |
792 | * | |
793 | * Most communication between driver and 4965 is via queues of data buffers. | |
794 | * For example, all commands that the driver issues to device's embedded | |
795 | * controller (uCode) are via the command queue (one of the Tx queues). All | |
796 | * uCode command responses/replies/notifications, including Rx frames, are | |
797 | * conveyed from uCode to driver via the Rx queue. | |
798 | * | |
799 | * Most support for these queues, including handshake support, resides in | |
800 | * structures in host DRAM, shared between the driver and the device. When | |
801 | * allocating this memory, the driver must make sure that data written by | |
802 | * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's | |
803 | * cache memory), so DRAM and cache are consistent, and the device can | |
804 | * immediately see changes made by the driver. | |
805 | * | |
806 | * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via | |
807 | * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array | |
808 | * in DRAM containing 256 Transmit Frame Descriptors (TFDs). | |
809 | */ | |
038669e4 EG |
810 | #define IWL49_NUM_FIFOS 7 |
811 | #define IWL49_CMD_FIFO_NUM 4 | |
812 | #define IWL49_NUM_QUEUES 16 | |
9f17b318 | 813 | #define IWL49_NUM_AMPDU_QUEUES 8 |
5d5456fe | 814 | |
b481de9c | 815 | |
5d5456fe | 816 | /** |
127901ab | 817 | * struct iwl4965_schedq_bc_tbl |
5d5456fe BC |
818 | * |
819 | * Byte Count table | |
820 | * | |
821 | * Each Tx queue uses a byte-count table containing 320 entries: | |
822 | * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that | |
823 | * duplicate the first 64 entries (to avoid wrap-around within a Tx window; | |
824 | * max Tx window is 64 TFDs). | |
825 | * | |
826 | * When driver sets up a new TFD, it must also enter the total byte count | |
827 | * of the frame to be transmitted into the corresponding entry in the byte | |
828 | * count table for the chosen Tx queue. If the TFD index is 0-63, the driver | |
829 | * must duplicate the byte count entry in corresponding index 256-319. | |
830 | * | |
127901ab | 831 | * padding puts each byte count table on a 1024-byte boundary; |
5d5456fe BC |
832 | * 4965 assumes tables are separated by 1024 bytes. |
833 | */ | |
4ddbb7d0 | 834 | struct iwl4965_scd_bc_tbl { |
127901ab TW |
835 | __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; |
836 | u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; | |
b481de9c ZY |
837 | } __attribute__ ((packed)); |
838 | ||
4ddbb7d0 | 839 | #endif /* !__iwl_4965_hw_h__ */ |