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