Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 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 | * |
Reinette Chatre | eb7ae89 | 2008-03-11 16:17:17 -0700 | [diff] [blame] | 8 | * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
Ian Schram | 01ebd06 | 2007-10-25 17:15:22 +0800 | [diff] [blame] | 11 | * it under the terms of version 2 of the GNU General Public License as |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 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 | * James P. Ketrenos <ipw2100-admin@linux.intel.com> |
| 29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 30 | * |
| 31 | * BSD LICENSE |
| 32 | * |
Reinette Chatre | eb7ae89 | 2008-03-11 16:17:17 -0700 | [diff] [blame] | 33 | * Copyright(c) 2005 - 2008 Intel Corporation. All rights reserved. |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 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 | *****************************************************************************/ |
Ben Cahill | fcd427b | 2007-11-29 11:10:00 +0800 | [diff] [blame] | 63 | /* |
| 64 | * Please use this file (iwl-4965-hw.h) only for hardware-related definitions. |
| 65 | * Use iwl-4965-commands.h for uCode API definitions. |
| 66 | * Use iwl-4965.h for driver implementation definitions. |
| 67 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 68 | |
| 69 | #ifndef __iwl_4965_hw_h__ |
| 70 | #define __iwl_4965_hw_h__ |
| 71 | |
Tomas Winkler | 073d3f5 | 2008-04-21 15:41:52 -0700 | [diff] [blame^] | 72 | /* EERPROM */ |
| 73 | #define IWL4965_EEPROM_IMG_SIZE 1024 |
| 74 | |
Ben Cahill | 1fea8e8 | 2007-11-29 11:09:52 +0800 | [diff] [blame] | 75 | /* |
| 76 | * uCode queue management definitions ... |
| 77 | * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4. |
| 78 | * The first queue used for block-ack aggregation is #7 (4965 only). |
| 79 | * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. |
| 80 | */ |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 81 | #define IWL_CMD_QUEUE_NUM 4 |
| 82 | #define IWL_CMD_FIFO_NUM 4 |
| 83 | #define IWL_BACK_QUEUE_FIRST_ID 7 |
| 84 | |
| 85 | /* Tx rates */ |
| 86 | #define IWL_CCK_RATES 4 |
| 87 | #define IWL_OFDM_RATES 8 |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 88 | #define IWL_HT_RATES 16 |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 89 | #define IWL_MAX_RATES (IWL_CCK_RATES+IWL_OFDM_RATES+IWL_HT_RATES) |
| 90 | |
| 91 | /* Time constants */ |
| 92 | #define SHORT_SLOT_TIME 9 |
| 93 | #define LONG_SLOT_TIME 20 |
| 94 | |
| 95 | /* RSSI to dBm */ |
| 96 | #define IWL_RSSI_OFFSET 44 |
| 97 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 98 | |
| 99 | #include "iwl-4965-commands.h" |
| 100 | |
| 101 | #define PCI_LINK_CTRL 0x0F0 |
| 102 | #define PCI_POWER_SOURCE 0x0C8 |
| 103 | #define PCI_REG_WUM8 0x0E8 |
| 104 | #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000) |
| 105 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 106 | #define TFD_QUEUE_SIZE_MAX (256) |
| 107 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 108 | #define IWL_NUM_SCAN_RATES (2) |
| 109 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 110 | #define IWL_DEFAULT_TX_RETRY 15 |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 111 | |
| 112 | #define RX_QUEUE_SIZE 256 |
| 113 | #define RX_QUEUE_MASK 255 |
| 114 | #define RX_QUEUE_SIZE_LOG 8 |
| 115 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 116 | #define TFD_TX_CMD_SLOTS 256 |
| 117 | #define TFD_CMD_SLOTS 32 |
| 118 | |
Christoph Hellwig | 5d08cd1 | 2007-10-25 17:15:50 +0800 | [diff] [blame] | 119 | /* |
| 120 | * RX related structures and functions |
| 121 | */ |
| 122 | #define RX_FREE_BUFFERS 64 |
| 123 | #define RX_LOW_WATERMARK 8 |
| 124 | |
Ben Cahill | fcd427b | 2007-11-29 11:10:00 +0800 | [diff] [blame] | 125 | /* Size of one Rx buffer in host DRAM */ |
Ron Rindjunsky | 9ee1ba4 | 2007-11-26 16:14:42 +0200 | [diff] [blame] | 126 | #define IWL_RX_BUF_SIZE_4K (4 * 1024) |
| 127 | #define IWL_RX_BUF_SIZE_8K (8 * 1024) |
Ben Cahill | fcd427b | 2007-11-29 11:10:00 +0800 | [diff] [blame] | 128 | |
| 129 | /* Sizes and addresses for instruction and data memory (SRAM) in |
| 130 | * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ |
| 131 | #define RTC_INST_LOWER_BOUND (0x000000) |
Tomas Winkler | 12a81f6 | 2008-04-03 16:05:20 -0700 | [diff] [blame] | 132 | #define IWL49_RTC_INST_UPPER_BOUND (0x018000) |
Ben Cahill | fcd427b | 2007-11-29 11:10:00 +0800 | [diff] [blame] | 133 | |
| 134 | #define RTC_DATA_LOWER_BOUND (0x800000) |
Tomas Winkler | 12a81f6 | 2008-04-03 16:05:20 -0700 | [diff] [blame] | 135 | #define IWL49_RTC_DATA_UPPER_BOUND (0x80A000) |
Ben Cahill | fcd427b | 2007-11-29 11:10:00 +0800 | [diff] [blame] | 136 | |
Tomas Winkler | 12a81f6 | 2008-04-03 16:05:20 -0700 | [diff] [blame] | 137 | #define IWL49_RTC_INST_SIZE \ |
| 138 | (IWL49_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND) |
| 139 | #define IWL49_RTC_DATA_SIZE \ |
| 140 | (IWL49_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 141 | |
Tomas Winkler | 12a81f6 | 2008-04-03 16:05:20 -0700 | [diff] [blame] | 142 | #define IWL_MAX_INST_SIZE IWL49_RTC_INST_SIZE |
| 143 | #define IWL_MAX_DATA_SIZE IWL49_RTC_DATA_SIZE |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 144 | |
Ben Cahill | fcd427b | 2007-11-29 11:10:00 +0800 | [diff] [blame] | 145 | /* Size of uCode instruction memory in bootstrap state machine */ |
| 146 | #define IWL_MAX_BSM_SIZE BSM_SRAM_SIZE |
| 147 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 148 | static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 149 | { |
| 150 | return (addr >= RTC_DATA_LOWER_BOUND) && |
Tomas Winkler | 12a81f6 | 2008-04-03 16:05:20 -0700 | [diff] [blame] | 151 | (addr < IWL49_RTC_DATA_UPPER_BOUND); |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 152 | } |
| 153 | |
Ben Cahill | 5991b41 | 2007-11-29 11:10:01 +0800 | [diff] [blame] | 154 | /********************* START TEMPERATURE *************************************/ |
| 155 | |
Ben Cahill | 0c434c5 | 2007-11-29 11:10:02 +0800 | [diff] [blame] | 156 | /** |
Ben Cahill | 5991b41 | 2007-11-29 11:10:01 +0800 | [diff] [blame] | 157 | * 4965 temperature calculation. |
| 158 | * |
| 159 | * The driver must calculate the device temperature before calculating |
| 160 | * a txpower setting (amplifier gain is temperature dependent). The |
| 161 | * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration |
| 162 | * values used for the life of the driver, and one of which (R4) is the |
| 163 | * real-time temperature indicator. |
| 164 | * |
| 165 | * uCode provides all 4 values to the driver via the "initialize alive" |
| 166 | * notification (see struct iwl4965_init_alive_resp). After the runtime uCode |
| 167 | * image loads, uCode updates the R4 value via statistics notifications |
| 168 | * (see STATISTICS_NOTIFICATION), which occur after each received beacon |
| 169 | * when associated, or can be requested via REPLY_STATISTICS_CMD. |
| 170 | * |
| 171 | * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver |
| 172 | * must sign-extend to 32 bits before applying formula below. |
| 173 | * |
| 174 | * Formula: |
| 175 | * |
| 176 | * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 |
| 177 | * |
| 178 | * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is |
| 179 | * an additional correction, which should be centered around 0 degrees |
| 180 | * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for |
| 181 | * centering the 97/100 correction around 0 degrees K. |
| 182 | * |
| 183 | * Add 273 to Kelvin value to find degrees Celsius, for comparing current |
| 184 | * temperature with factory-measured temperatures when calculating txpower |
| 185 | * settings. |
| 186 | */ |
| 187 | #define TEMPERATURE_CALIB_KELVIN_OFFSET 8 |
| 188 | #define TEMPERATURE_CALIB_A_VAL 259 |
| 189 | |
| 190 | /* Limit range of calculated temperature to be between these Kelvin values */ |
| 191 | #define IWL_TX_POWER_TEMPERATURE_MIN (263) |
| 192 | #define IWL_TX_POWER_TEMPERATURE_MAX (410) |
| 193 | |
| 194 | #define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ |
| 195 | (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \ |
| 196 | ((t) > IWL_TX_POWER_TEMPERATURE_MAX)) |
| 197 | |
| 198 | /********************* END TEMPERATURE ***************************************/ |
| 199 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 200 | /********************* START TXPOWER *****************************************/ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 201 | |
Ben Cahill | 0c434c5 | 2007-11-29 11:10:02 +0800 | [diff] [blame] | 202 | /** |
| 203 | * 4965 txpower calculations rely on information from three sources: |
| 204 | * |
| 205 | * 1) EEPROM |
| 206 | * 2) "initialize" alive notification |
| 207 | * 3) statistics notifications |
| 208 | * |
| 209 | * EEPROM data consists of: |
| 210 | * |
| 211 | * 1) Regulatory information (max txpower and channel usage flags) is provided |
| 212 | * separately for each channel that can possibly supported by 4965. |
| 213 | * 40 MHz wide (.11n fat) channels are listed separately from 20 MHz |
| 214 | * (legacy) channels. |
| 215 | * |
| 216 | * See struct iwl4965_eeprom_channel for format, and struct iwl4965_eeprom |
| 217 | * for locations in EEPROM. |
| 218 | * |
| 219 | * 2) Factory txpower calibration information is provided separately for |
| 220 | * sub-bands of contiguous channels. 2.4GHz has just one sub-band, |
| 221 | * but 5 GHz has several sub-bands. |
| 222 | * |
| 223 | * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. |
| 224 | * |
| 225 | * See struct iwl4965_eeprom_calib_info (and the tree of structures |
| 226 | * contained within it) for format, and struct iwl4965_eeprom for |
| 227 | * locations in EEPROM. |
| 228 | * |
| 229 | * "Initialization alive" notification (see struct iwl4965_init_alive_resp) |
| 230 | * consists of: |
| 231 | * |
| 232 | * 1) Temperature calculation parameters. |
| 233 | * |
| 234 | * 2) Power supply voltage measurement. |
| 235 | * |
| 236 | * 3) Tx gain compensation to balance 2 transmitters for MIMO use. |
| 237 | * |
| 238 | * Statistics notifications deliver: |
| 239 | * |
| 240 | * 1) Current values for temperature param R4. |
| 241 | */ |
| 242 | |
| 243 | /** |
| 244 | * To calculate a txpower setting for a given desired target txpower, channel, |
| 245 | * modulation bit rate, and transmitter chain (4965 has 2 transmitters to |
| 246 | * support MIMO and transmit diversity), driver must do the following: |
| 247 | * |
| 248 | * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. |
| 249 | * Do not exceed regulatory limit; reduce target txpower if necessary. |
| 250 | * |
| 251 | * If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), |
| 252 | * 2 transmitters will be used simultaneously; driver must reduce the |
| 253 | * regulatory limit by 3 dB (half-power) for each transmitter, so the |
| 254 | * combined total output of the 2 transmitters is within regulatory limits. |
| 255 | * |
| 256 | * |
| 257 | * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by |
| 258 | * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); |
| 259 | * reduce target txpower if necessary. |
| 260 | * |
| 261 | * Backoff values below are in 1/2 dB units (equivalent to steps in |
| 262 | * txpower gain tables): |
| 263 | * |
| 264 | * OFDM 6 - 36 MBit: 10 steps (5 dB) |
| 265 | * OFDM 48 MBit: 15 steps (7.5 dB) |
| 266 | * OFDM 54 MBit: 17 steps (8.5 dB) |
| 267 | * OFDM 60 MBit: 20 steps (10 dB) |
| 268 | * CCK all rates: 10 steps (5 dB) |
| 269 | * |
| 270 | * Backoff values apply to saturation txpower on a per-transmitter basis; |
| 271 | * when using MIMO (2 transmitters), each transmitter uses the same |
| 272 | * saturation level provided in EEPROM, and the same backoff values; |
| 273 | * no reduction (such as with regulatory txpower limits) is required. |
| 274 | * |
| 275 | * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel |
| 276 | * widths and 40 Mhz (.11n fat) channel widths; there is no separate |
| 277 | * factory measurement for fat channels. |
| 278 | * |
| 279 | * The result of this step is the final target txpower. The rest of |
| 280 | * the steps figure out the proper settings for the device to achieve |
| 281 | * that target txpower. |
| 282 | * |
| 283 | * |
| 284 | * 3) Determine (EEPROM) calibration subband for the target channel, by |
| 285 | * comparing against first and last channels in each subband |
| 286 | * (see struct iwl4965_eeprom_calib_subband_info). |
| 287 | * |
| 288 | * |
| 289 | * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, |
| 290 | * referencing the 2 factory-measured (sample) channels within the subband. |
| 291 | * |
| 292 | * Interpolation is based on difference between target channel's frequency |
| 293 | * and the sample channels' frequencies. Since channel numbers are based |
| 294 | * on frequency (5 MHz between each channel number), this is equivalent |
| 295 | * to interpolating based on channel number differences. |
| 296 | * |
| 297 | * Note that the sample channels may or may not be the channels at the |
| 298 | * edges of the subband. The target channel may be "outside" of the |
| 299 | * span of the sampled channels. |
| 300 | * |
| 301 | * Driver may choose the pair (for 2 Tx chains) of measurements (see |
| 302 | * struct iwl4965_eeprom_calib_ch_info) for which the actual measured |
| 303 | * txpower comes closest to the desired txpower. Usually, though, |
| 304 | * the middle set of measurements is closest to the regulatory limits, |
| 305 | * and is therefore a good choice for all txpower calculations (this |
| 306 | * assumes that high accuracy is needed for maximizing legal txpower, |
| 307 | * while lower txpower configurations do not need as much accuracy). |
| 308 | * |
| 309 | * Driver should interpolate both members of the chosen measurement pair, |
| 310 | * i.e. for both Tx chains (radio transmitters), unless the driver knows |
| 311 | * that only one of the chains will be used (e.g. only one tx antenna |
| 312 | * connected, but this should be unusual). The rate scaling algorithm |
| 313 | * switches antennas to find best performance, so both Tx chains will |
| 314 | * be used (although only one at a time) even for non-MIMO transmissions. |
| 315 | * |
| 316 | * Driver should interpolate factory values for temperature, gain table |
| 317 | * index, and actual power. The power amplifier detector values are |
| 318 | * not used by the driver. |
| 319 | * |
| 320 | * Sanity check: If the target channel happens to be one of the sample |
| 321 | * channels, the results should agree with the sample channel's |
| 322 | * measurements! |
| 323 | * |
| 324 | * |
| 325 | * 5) Find difference between desired txpower and (interpolated) |
| 326 | * factory-measured txpower. Using (interpolated) factory gain table index |
| 327 | * (shown elsewhere) as a starting point, adjust this index lower to |
| 328 | * increase txpower, or higher to decrease txpower, until the target |
| 329 | * txpower is reached. Each step in the gain table is 1/2 dB. |
| 330 | * |
| 331 | * For example, if factory measured txpower is 16 dBm, and target txpower |
| 332 | * is 13 dBm, add 6 steps to the factory gain index to reduce txpower |
| 333 | * by 3 dB. |
| 334 | * |
| 335 | * |
| 336 | * 6) Find difference between current device temperature and (interpolated) |
| 337 | * factory-measured temperature for sub-band. Factory values are in |
| 338 | * degrees Celsius. To calculate current temperature, see comments for |
| 339 | * "4965 temperature calculation". |
| 340 | * |
| 341 | * If current temperature is higher than factory temperature, driver must |
| 342 | * increase gain (lower gain table index), and vice versa. |
| 343 | * |
| 344 | * Temperature affects gain differently for different channels: |
| 345 | * |
| 346 | * 2.4 GHz all channels: 3.5 degrees per half-dB step |
| 347 | * 5 GHz channels 34-43: 4.5 degrees per half-dB step |
| 348 | * 5 GHz channels >= 44: 4.0 degrees per half-dB step |
| 349 | * |
| 350 | * NOTE: Temperature can increase rapidly when transmitting, especially |
| 351 | * with heavy traffic at high txpowers. Driver should update |
| 352 | * temperature calculations often under these conditions to |
| 353 | * maintain strong txpower in the face of rising temperature. |
| 354 | * |
| 355 | * |
| 356 | * 7) Find difference between current power supply voltage indicator |
| 357 | * (from "initialize alive") and factory-measured power supply voltage |
| 358 | * indicator (EEPROM). |
| 359 | * |
| 360 | * If the current voltage is higher (indicator is lower) than factory |
| 361 | * voltage, gain should be reduced (gain table index increased) by: |
| 362 | * |
| 363 | * (eeprom - current) / 7 |
| 364 | * |
| 365 | * If the current voltage is lower (indicator is higher) than factory |
| 366 | * voltage, gain should be increased (gain table index decreased) by: |
| 367 | * |
| 368 | * 2 * (current - eeprom) / 7 |
| 369 | * |
| 370 | * If number of index steps in either direction turns out to be > 2, |
| 371 | * something is wrong ... just use 0. |
| 372 | * |
| 373 | * NOTE: Voltage compensation is independent of band/channel. |
| 374 | * |
| 375 | * NOTE: "Initialize" uCode measures current voltage, which is assumed |
| 376 | * to be constant after this initial measurement. Voltage |
| 377 | * compensation for txpower (number of steps in gain table) |
| 378 | * may be calculated once and used until the next uCode bootload. |
| 379 | * |
| 380 | * |
| 381 | * 8) If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), |
| 382 | * adjust txpower for each transmitter chain, so txpower is balanced |
| 383 | * between the two chains. There are 5 pairs of tx_atten[group][chain] |
| 384 | * values in "initialize alive", one pair for each of 5 channel ranges: |
| 385 | * |
| 386 | * Group 0: 5 GHz channel 34-43 |
| 387 | * Group 1: 5 GHz channel 44-70 |
| 388 | * Group 2: 5 GHz channel 71-124 |
| 389 | * Group 3: 5 GHz channel 125-200 |
| 390 | * Group 4: 2.4 GHz all channels |
| 391 | * |
| 392 | * Add the tx_atten[group][chain] value to the index for the target chain. |
| 393 | * The values are signed, but are in pairs of 0 and a non-negative number, |
| 394 | * so as to reduce gain (if necessary) of the "hotter" channel. This |
| 395 | * avoids any need to double-check for regulatory compliance after |
| 396 | * this step. |
| 397 | * |
| 398 | * |
| 399 | * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation |
| 400 | * value to the index: |
| 401 | * |
| 402 | * Hardware rev B: 9 steps (4.5 dB) |
| 403 | * Hardware rev C: 5 steps (2.5 dB) |
| 404 | * |
| 405 | * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, |
| 406 | * bits [3:2], 1 = B, 2 = C. |
| 407 | * |
| 408 | * NOTE: This compensation is in addition to any saturation backoff that |
| 409 | * might have been applied in an earlier step. |
| 410 | * |
| 411 | * |
| 412 | * 10) Select the gain table, based on band (2.4 vs 5 GHz). |
| 413 | * |
| 414 | * Limit the adjusted index to stay within the table! |
| 415 | * |
| 416 | * |
| 417 | * 11) Read gain table entries for DSP and radio gain, place into appropriate |
| 418 | * location(s) in command (struct iwl4965_txpowertable_cmd). |
| 419 | */ |
| 420 | |
| 421 | /* Limit range of txpower output target to be between these values */ |
| 422 | #define IWL_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */ |
| 423 | #define IWL_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */ |
| 424 | |
| 425 | /** |
| 426 | * When MIMO is used (2 transmitters operating simultaneously), driver should |
| 427 | * limit each transmitter to deliver a max of 3 dB below the regulatory limit |
| 428 | * for the device. That is, use half power for each transmitter, so total |
| 429 | * txpower is within regulatory limits. |
| 430 | * |
| 431 | * The value "6" represents number of steps in gain table to reduce power 3 dB. |
| 432 | * Each step is 1/2 dB. |
| 433 | */ |
| 434 | #define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) |
| 435 | |
| 436 | /** |
| 437 | * CCK gain compensation. |
| 438 | * |
| 439 | * When calculating txpowers for CCK, after making sure that the target power |
| 440 | * is within regulatory and saturation limits, driver must additionally |
| 441 | * back off gain by adding these values to the gain table index. |
| 442 | * |
| 443 | * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, |
| 444 | * bits [3:2], 1 = B, 2 = C. |
| 445 | */ |
| 446 | #define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9) |
| 447 | #define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5) |
| 448 | |
| 449 | /* |
| 450 | * 4965 power supply voltage compensation for txpower |
| 451 | */ |
| 452 | #define TX_POWER_IWL_VOLTAGE_CODES_PER_03V (7) |
| 453 | |
| 454 | /** |
| 455 | * Gain tables. |
| 456 | * |
| 457 | * The following tables contain pair of values for setting txpower, i.e. |
| 458 | * gain settings for the output of the device's digital signal processor (DSP), |
| 459 | * and for the analog gain structure of the transmitter. |
| 460 | * |
| 461 | * Each entry in the gain tables represents a step of 1/2 dB. Note that these |
| 462 | * are *relative* steps, not indications of absolute output power. Output |
| 463 | * power varies with temperature, voltage, and channel frequency, and also |
| 464 | * requires consideration of average power (to satisfy regulatory constraints), |
| 465 | * and peak power (to avoid distortion of the output signal). |
| 466 | * |
| 467 | * Each entry contains two values: |
| 468 | * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained |
| 469 | * linear value that multiplies the output of the digital signal processor, |
| 470 | * before being sent to the analog radio. |
| 471 | * 2) Radio gain. This sets the analog gain of the radio Tx path. |
| 472 | * It is a coarser setting, and behaves in a logarithmic (dB) fashion. |
| 473 | * |
| 474 | * EEPROM contains factory calibration data for txpower. This maps actual |
| 475 | * measured txpower levels to gain settings in the "well known" tables |
| 476 | * below ("well-known" means here that both factory calibration *and* the |
| 477 | * driver work with the same table). |
| 478 | * |
| 479 | * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table |
| 480 | * has an extension (into negative indexes), in case the driver needs to |
| 481 | * boost power setting for high device temperatures (higher than would be |
| 482 | * present during factory calibration). A 5 Ghz EEPROM index of "40" |
| 483 | * corresponds to the 49th entry in the table used by the driver. |
| 484 | */ |
| 485 | #define MIN_TX_GAIN_INDEX (0) /* highest gain, lowest idx, 2.4 */ |
| 486 | #define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ |
| 487 | |
| 488 | /** |
| 489 | * 2.4 GHz gain table |
| 490 | * |
| 491 | * Index Dsp gain Radio gain |
| 492 | * 0 110 0x3f (highest gain) |
| 493 | * 1 104 0x3f |
| 494 | * 2 98 0x3f |
| 495 | * 3 110 0x3e |
| 496 | * 4 104 0x3e |
| 497 | * 5 98 0x3e |
| 498 | * 6 110 0x3d |
| 499 | * 7 104 0x3d |
| 500 | * 8 98 0x3d |
| 501 | * 9 110 0x3c |
| 502 | * 10 104 0x3c |
| 503 | * 11 98 0x3c |
| 504 | * 12 110 0x3b |
| 505 | * 13 104 0x3b |
| 506 | * 14 98 0x3b |
| 507 | * 15 110 0x3a |
| 508 | * 16 104 0x3a |
| 509 | * 17 98 0x3a |
| 510 | * 18 110 0x39 |
| 511 | * 19 104 0x39 |
| 512 | * 20 98 0x39 |
| 513 | * 21 110 0x38 |
| 514 | * 22 104 0x38 |
| 515 | * 23 98 0x38 |
| 516 | * 24 110 0x37 |
| 517 | * 25 104 0x37 |
| 518 | * 26 98 0x37 |
| 519 | * 27 110 0x36 |
| 520 | * 28 104 0x36 |
| 521 | * 29 98 0x36 |
| 522 | * 30 110 0x35 |
| 523 | * 31 104 0x35 |
| 524 | * 32 98 0x35 |
| 525 | * 33 110 0x34 |
| 526 | * 34 104 0x34 |
| 527 | * 35 98 0x34 |
| 528 | * 36 110 0x33 |
| 529 | * 37 104 0x33 |
| 530 | * 38 98 0x33 |
| 531 | * 39 110 0x32 |
| 532 | * 40 104 0x32 |
| 533 | * 41 98 0x32 |
| 534 | * 42 110 0x31 |
| 535 | * 43 104 0x31 |
| 536 | * 44 98 0x31 |
| 537 | * 45 110 0x30 |
| 538 | * 46 104 0x30 |
| 539 | * 47 98 0x30 |
| 540 | * 48 110 0x6 |
| 541 | * 49 104 0x6 |
| 542 | * 50 98 0x6 |
| 543 | * 51 110 0x5 |
| 544 | * 52 104 0x5 |
| 545 | * 53 98 0x5 |
| 546 | * 54 110 0x4 |
| 547 | * 55 104 0x4 |
| 548 | * 56 98 0x4 |
| 549 | * 57 110 0x3 |
| 550 | * 58 104 0x3 |
| 551 | * 59 98 0x3 |
| 552 | * 60 110 0x2 |
| 553 | * 61 104 0x2 |
| 554 | * 62 98 0x2 |
| 555 | * 63 110 0x1 |
| 556 | * 64 104 0x1 |
| 557 | * 65 98 0x1 |
| 558 | * 66 110 0x0 |
| 559 | * 67 104 0x0 |
| 560 | * 68 98 0x0 |
| 561 | * 69 97 0 |
| 562 | * 70 96 0 |
| 563 | * 71 95 0 |
| 564 | * 72 94 0 |
| 565 | * 73 93 0 |
| 566 | * 74 92 0 |
| 567 | * 75 91 0 |
| 568 | * 76 90 0 |
| 569 | * 77 89 0 |
| 570 | * 78 88 0 |
| 571 | * 79 87 0 |
| 572 | * 80 86 0 |
| 573 | * 81 85 0 |
| 574 | * 82 84 0 |
| 575 | * 83 83 0 |
| 576 | * 84 82 0 |
| 577 | * 85 81 0 |
| 578 | * 86 80 0 |
| 579 | * 87 79 0 |
| 580 | * 88 78 0 |
| 581 | * 89 77 0 |
| 582 | * 90 76 0 |
| 583 | * 91 75 0 |
| 584 | * 92 74 0 |
| 585 | * 93 73 0 |
| 586 | * 94 72 0 |
| 587 | * 95 71 0 |
| 588 | * 96 70 0 |
| 589 | * 97 69 0 |
| 590 | * 98 68 0 |
| 591 | */ |
| 592 | |
| 593 | /** |
| 594 | * 5 GHz gain table |
| 595 | * |
| 596 | * Index Dsp gain Radio gain |
| 597 | * -9 123 0x3F (highest gain) |
| 598 | * -8 117 0x3F |
| 599 | * -7 110 0x3F |
| 600 | * -6 104 0x3F |
| 601 | * -5 98 0x3F |
| 602 | * -4 110 0x3E |
| 603 | * -3 104 0x3E |
| 604 | * -2 98 0x3E |
| 605 | * -1 110 0x3D |
| 606 | * 0 104 0x3D |
| 607 | * 1 98 0x3D |
| 608 | * 2 110 0x3C |
| 609 | * 3 104 0x3C |
| 610 | * 4 98 0x3C |
| 611 | * 5 110 0x3B |
| 612 | * 6 104 0x3B |
| 613 | * 7 98 0x3B |
| 614 | * 8 110 0x3A |
| 615 | * 9 104 0x3A |
| 616 | * 10 98 0x3A |
| 617 | * 11 110 0x39 |
| 618 | * 12 104 0x39 |
| 619 | * 13 98 0x39 |
| 620 | * 14 110 0x38 |
| 621 | * 15 104 0x38 |
| 622 | * 16 98 0x38 |
| 623 | * 17 110 0x37 |
| 624 | * 18 104 0x37 |
| 625 | * 19 98 0x37 |
| 626 | * 20 110 0x36 |
| 627 | * 21 104 0x36 |
| 628 | * 22 98 0x36 |
| 629 | * 23 110 0x35 |
| 630 | * 24 104 0x35 |
| 631 | * 25 98 0x35 |
| 632 | * 26 110 0x34 |
| 633 | * 27 104 0x34 |
| 634 | * 28 98 0x34 |
| 635 | * 29 110 0x33 |
| 636 | * 30 104 0x33 |
| 637 | * 31 98 0x33 |
| 638 | * 32 110 0x32 |
| 639 | * 33 104 0x32 |
| 640 | * 34 98 0x32 |
| 641 | * 35 110 0x31 |
| 642 | * 36 104 0x31 |
| 643 | * 37 98 0x31 |
| 644 | * 38 110 0x30 |
| 645 | * 39 104 0x30 |
| 646 | * 40 98 0x30 |
| 647 | * 41 110 0x25 |
| 648 | * 42 104 0x25 |
| 649 | * 43 98 0x25 |
| 650 | * 44 110 0x24 |
| 651 | * 45 104 0x24 |
| 652 | * 46 98 0x24 |
| 653 | * 47 110 0x23 |
| 654 | * 48 104 0x23 |
| 655 | * 49 98 0x23 |
| 656 | * 50 110 0x22 |
| 657 | * 51 104 0x18 |
| 658 | * 52 98 0x18 |
| 659 | * 53 110 0x17 |
| 660 | * 54 104 0x17 |
| 661 | * 55 98 0x17 |
| 662 | * 56 110 0x16 |
| 663 | * 57 104 0x16 |
| 664 | * 58 98 0x16 |
| 665 | * 59 110 0x15 |
| 666 | * 60 104 0x15 |
| 667 | * 61 98 0x15 |
| 668 | * 62 110 0x14 |
| 669 | * 63 104 0x14 |
| 670 | * 64 98 0x14 |
| 671 | * 65 110 0x13 |
| 672 | * 66 104 0x13 |
| 673 | * 67 98 0x13 |
| 674 | * 68 110 0x12 |
| 675 | * 69 104 0x08 |
| 676 | * 70 98 0x08 |
| 677 | * 71 110 0x07 |
| 678 | * 72 104 0x07 |
| 679 | * 73 98 0x07 |
| 680 | * 74 110 0x06 |
| 681 | * 75 104 0x06 |
| 682 | * 76 98 0x06 |
| 683 | * 77 110 0x05 |
| 684 | * 78 104 0x05 |
| 685 | * 79 98 0x05 |
| 686 | * 80 110 0x04 |
| 687 | * 81 104 0x04 |
| 688 | * 82 98 0x04 |
| 689 | * 83 110 0x03 |
| 690 | * 84 104 0x03 |
| 691 | * 85 98 0x03 |
| 692 | * 86 110 0x02 |
| 693 | * 87 104 0x02 |
| 694 | * 88 98 0x02 |
| 695 | * 89 110 0x01 |
| 696 | * 90 104 0x01 |
| 697 | * 91 98 0x01 |
| 698 | * 92 110 0x00 |
| 699 | * 93 104 0x00 |
| 700 | * 94 98 0x00 |
| 701 | * 95 93 0x00 |
| 702 | * 96 88 0x00 |
| 703 | * 97 83 0x00 |
| 704 | * 98 78 0x00 |
| 705 | */ |
| 706 | |
| 707 | |
| 708 | /** |
| 709 | * Sanity checks and default values for EEPROM regulatory levels. |
| 710 | * If EEPROM values fall outside MIN/MAX range, use default values. |
| 711 | * |
| 712 | * Regulatory limits refer to the maximum average txpower allowed by |
| 713 | * regulatory agencies in the geographies in which the device is meant |
| 714 | * to be operated. These limits are SKU-specific (i.e. geography-specific), |
| 715 | * and channel-specific; each channel has an individual regulatory limit |
| 716 | * listed in the EEPROM. |
| 717 | * |
| 718 | * Units are in half-dBm (i.e. "34" means 17 dBm). |
| 719 | */ |
| 720 | #define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34) |
| 721 | #define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34) |
| 722 | #define IWL_TX_POWER_REGULATORY_MIN (0) |
| 723 | #define IWL_TX_POWER_REGULATORY_MAX (34) |
| 724 | |
| 725 | /** |
| 726 | * Sanity checks and default values for EEPROM saturation levels. |
| 727 | * If EEPROM values fall outside MIN/MAX range, use default values. |
| 728 | * |
| 729 | * Saturation is the highest level that the output power amplifier can produce |
| 730 | * without significant clipping distortion. This is a "peak" power level. |
| 731 | * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) |
| 732 | * require differing amounts of backoff, relative to their average power output, |
| 733 | * in order to avoid clipping distortion. |
| 734 | * |
| 735 | * Driver must make sure that it is violating neither the saturation limit, |
| 736 | * nor the regulatory limit, when calculating Tx power settings for various |
| 737 | * rates. |
| 738 | * |
| 739 | * Units are in half-dBm (i.e. "38" means 19 dBm). |
| 740 | */ |
| 741 | #define IWL_TX_POWER_DEFAULT_SATURATION_24 (38) |
| 742 | #define IWL_TX_POWER_DEFAULT_SATURATION_52 (38) |
| 743 | #define IWL_TX_POWER_SATURATION_MIN (20) |
| 744 | #define IWL_TX_POWER_SATURATION_MAX (50) |
| 745 | |
| 746 | /** |
| 747 | * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) |
| 748 | * and thermal Txpower calibration. |
| 749 | * |
| 750 | * When calculating txpower, driver must compensate for current device |
| 751 | * temperature; higher temperature requires higher gain. Driver must calculate |
| 752 | * current temperature (see "4965 temperature calculation"), then compare vs. |
| 753 | * factory calibration temperature in EEPROM; if current temperature is higher |
| 754 | * than factory temperature, driver must *increase* gain by proportions shown |
| 755 | * in table below. If current temperature is lower than factory, driver must |
| 756 | * *decrease* gain. |
| 757 | * |
| 758 | * Different frequency ranges require different compensation, as shown below. |
| 759 | */ |
| 760 | /* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ |
| 761 | #define CALIB_IWL_TX_ATTEN_GR1_FCH 34 |
| 762 | #define CALIB_IWL_TX_ATTEN_GR1_LCH 43 |
| 763 | |
| 764 | /* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ |
| 765 | #define CALIB_IWL_TX_ATTEN_GR2_FCH 44 |
| 766 | #define CALIB_IWL_TX_ATTEN_GR2_LCH 70 |
| 767 | |
| 768 | /* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ |
| 769 | #define CALIB_IWL_TX_ATTEN_GR3_FCH 71 |
| 770 | #define CALIB_IWL_TX_ATTEN_GR3_LCH 124 |
| 771 | |
| 772 | /* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ |
| 773 | #define CALIB_IWL_TX_ATTEN_GR4_FCH 125 |
| 774 | #define CALIB_IWL_TX_ATTEN_GR4_LCH 200 |
| 775 | |
| 776 | /* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ |
| 777 | #define CALIB_IWL_TX_ATTEN_GR5_FCH 1 |
| 778 | #define CALIB_IWL_TX_ATTEN_GR5_LCH 20 |
| 779 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 780 | enum { |
| 781 | CALIB_CH_GROUP_1 = 0, |
| 782 | CALIB_CH_GROUP_2 = 1, |
| 783 | CALIB_CH_GROUP_3 = 2, |
| 784 | CALIB_CH_GROUP_4 = 3, |
| 785 | CALIB_CH_GROUP_5 = 4, |
| 786 | CALIB_CH_GROUP_MAX |
| 787 | }; |
| 788 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 789 | /********************* END TXPOWER *****************************************/ |
| 790 | |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 791 | /****************************/ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 792 | /* Flow Handler Definitions */ |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 793 | /****************************/ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 794 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 795 | /** |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 796 | * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) |
| 797 | * Addresses are offsets from device's PCI hardware base address. |
| 798 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 799 | #define FH_MEM_LOWER_BOUND (0x1000) |
| 800 | #define FH_MEM_UPPER_BOUND (0x1EF0) |
| 801 | |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 802 | /** |
| 803 | * Keep-Warm (KW) buffer base address. |
| 804 | * |
| 805 | * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the |
| 806 | * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency |
| 807 | * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host |
| 808 | * from going into a power-savings mode that would cause higher DRAM latency, |
| 809 | * and possible data over/under-runs, before all Tx/Rx is complete. |
| 810 | * |
| 811 | * Driver loads IWL_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4) |
| 812 | * of the buffer, which must be 4K aligned. Once this is set up, the 4965 |
| 813 | * automatically invokes keep-warm accesses when normal accesses might not |
| 814 | * be sufficient to maintain fast DRAM response. |
| 815 | * |
| 816 | * Bit fields: |
| 817 | * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned |
| 818 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 819 | #define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C) |
| 820 | |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 821 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 822 | /** |
| 823 | * TFD Circular Buffers Base (CBBC) addresses |
| 824 | * |
| 825 | * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident |
| 826 | * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) |
| 827 | * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04 |
| 828 | * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte |
| 829 | * aligned (address bits 0-7 must be 0). |
| 830 | * |
| 831 | * Bit fields in each pointer register: |
| 832 | * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned |
| 833 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 834 | #define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0) |
| 835 | #define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10) |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 836 | |
| 837 | /* Find TFD CB base pointer for given queue (range 0-15). */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 838 | #define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4) |
| 839 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 840 | |
| 841 | /** |
| 842 | * Rx SRAM Control and Status Registers (RSCSR) |
| 843 | * |
| 844 | * These registers provide handshake between driver and 4965 for the Rx queue |
| 845 | * (this queue handles *all* command responses, notifications, Rx data, etc. |
| 846 | * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx |
| 847 | * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can |
| 848 | * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer |
| 849 | * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1 |
| 850 | * mapping between RBDs and RBs. |
| 851 | * |
| 852 | * Driver must allocate host DRAM memory for the following, and set the |
| 853 | * physical address of each into 4965 registers: |
| 854 | * |
| 855 | * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256 |
| 856 | * entries (although any power of 2, up to 4096, is selectable by driver). |
| 857 | * Each entry (1 dword) points to a receive buffer (RB) of consistent size |
| 858 | * (typically 4K, although 8K or 16K are also selectable by driver). |
| 859 | * Driver sets up RB size and number of RBDs in the CB via Rx config |
| 860 | * register FH_MEM_RCSR_CHNL0_CONFIG_REG. |
| 861 | * |
| 862 | * Bit fields within one RBD: |
| 863 | * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned |
| 864 | * |
| 865 | * Driver sets physical address [35:8] of base of RBD circular buffer |
| 866 | * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. |
| 867 | * |
| 868 | * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers |
| 869 | * (RBs) have been filled, via a "write pointer", actually the index of |
| 870 | * the RB's corresponding RBD within the circular buffer. Driver sets |
| 871 | * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. |
| 872 | * |
| 873 | * Bit fields in lower dword of Rx status buffer (upper dword not used |
| 874 | * by driver; see struct iwl4965_shared, val0): |
| 875 | * 31-12: Not used by driver |
| 876 | * 11- 0: Index of last filled Rx buffer descriptor |
| 877 | * (4965 writes, driver reads this value) |
| 878 | * |
| 879 | * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must |
| 880 | * enter pointers to these RBs into contiguous RBD circular buffer entries, |
| 881 | * and update the 4965's "write" index register, FH_RSCSR_CHNL0_RBDCB_WPTR_REG. |
| 882 | * |
| 883 | * This "write" index corresponds to the *next* RBD that the driver will make |
| 884 | * available, i.e. one RBD past the tail of the ready-to-fill RBDs within |
| 885 | * the circular buffer. This value should initially be 0 (before preparing any |
| 886 | * RBs), should be 8 after preparing the first 8 RBs (for example), and must |
| 887 | * wrap back to 0 at the end of the circular buffer (but don't wrap before |
| 888 | * "read" index has advanced past 1! See below). |
| 889 | * NOTE: 4965 EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8. |
| 890 | * |
| 891 | * As the 4965 fills RBs (referenced from contiguous RBDs within the circular |
| 892 | * buffer), it updates the Rx status buffer in host DRAM, 2) described above, |
| 893 | * to tell the driver the index of the latest filled RBD. The driver must |
| 894 | * read this "read" index from DRAM after receiving an Rx interrupt from 4965. |
| 895 | * |
| 896 | * The driver must also internally keep track of a third index, which is the |
| 897 | * next RBD to process. When receiving an Rx interrupt, driver should process |
| 898 | * all filled but unprocessed RBs up to, but not including, the RB |
| 899 | * corresponding to the "read" index. For example, if "read" index becomes "1", |
| 900 | * driver may process the RB pointed to by RBD 0. Depending on volume of |
| 901 | * traffic, there may be many RBs to process. |
| 902 | * |
| 903 | * If read index == write index, 4965 thinks there is no room to put new data. |
| 904 | * Due to this, the maximum number of filled RBs is 255, instead of 256. To |
| 905 | * be safe, make sure that there is a gap of at least 2 RBDs between "write" |
| 906 | * and "read" indexes; that is, make sure that there are no more than 254 |
| 907 | * buffers waiting to be filled. |
| 908 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 909 | #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0) |
| 910 | #define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) |
| 911 | #define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND) |
| 912 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 913 | /** |
| 914 | * Physical base address of 8-byte Rx Status buffer. |
| 915 | * Bit fields: |
| 916 | * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. |
| 917 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 918 | #define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0) |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 919 | |
| 920 | /** |
| 921 | * Physical base address of Rx Buffer Descriptor Circular Buffer. |
| 922 | * Bit fields: |
| 923 | * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. |
| 924 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 925 | #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004) |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 926 | |
| 927 | /** |
| 928 | * Rx write pointer (index, really!). |
| 929 | * Bit fields: |
| 930 | * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. |
| 931 | * NOTE: For 256-entry circular buffer, use only bits [7:0]. |
| 932 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 933 | #define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008) |
Ben Cahill | 483fd7e | 2007-11-29 11:10:05 +0800 | [diff] [blame] | 934 | #define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 935 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 936 | |
| 937 | /** |
| 938 | * Rx Config/Status Registers (RCSR) |
| 939 | * Rx Config Reg for channel 0 (only channel used) |
| 940 | * |
| 941 | * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for |
| 942 | * normal operation (see bit fields). |
| 943 | * |
| 944 | * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. |
| 945 | * Driver should poll FH_MEM_RSSR_RX_STATUS_REG for |
| 946 | * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. |
| 947 | * |
| 948 | * Bit fields: |
| 949 | * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, |
| 950 | * '10' operate normally |
| 951 | * 29-24: reserved |
| 952 | * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal), |
| 953 | * min "5" for 32 RBDs, max "12" for 4096 RBDs. |
| 954 | * 19-18: reserved |
| 955 | * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K, |
| 956 | * '10' 12K, '11' 16K. |
| 957 | * 15-14: reserved |
| 958 | * 13-12: IRQ destination; '00' none, '01' host driver (normal operation) |
| 959 | * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec) |
| 960 | * typical value 0x10 (about 1/2 msec) |
| 961 | * 3- 0: reserved |
| 962 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 963 | #define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) |
| 964 | #define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0) |
| 965 | #define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND) |
| 966 | |
| 967 | #define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0) |
| 968 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 969 | #define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */ |
| 970 | #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */ |
| 971 | #define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */ |
| 972 | #define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */ |
| 973 | #define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */ |
| 974 | #define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */ |
| 975 | |
| 976 | #define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20) |
Ron Rindjunsky | 9ee1ba4 | 2007-11-26 16:14:42 +0200 | [diff] [blame] | 977 | #define FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_BITSHIFT (4) |
| 978 | #define RX_RB_TIMEOUT (0x10) |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 979 | |
| 980 | #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) |
| 981 | #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) |
| 982 | #define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) |
| 983 | |
Ron Rindjunsky | 9ee1ba4 | 2007-11-26 16:14:42 +0200 | [diff] [blame] | 984 | #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) |
| 985 | #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) |
| 986 | #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) |
| 987 | #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 988 | |
| 989 | #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) |
| 990 | #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) |
| 991 | |
| 992 | |
| 993 | /** |
| 994 | * Rx Shared Status Registers (RSSR) |
| 995 | * |
| 996 | * After stopping Rx DMA channel (writing 0 to FH_MEM_RCSR_CHNL0_CONFIG_REG), |
| 997 | * driver must poll FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. |
| 998 | * |
| 999 | * Bit fields: |
| 1000 | * 24: 1 = Channel 0 is idle |
| 1001 | * |
| 1002 | * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV contain |
| 1003 | * default values that should not be altered by the driver. |
| 1004 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1005 | #define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40) |
| 1006 | #define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00) |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 1007 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1008 | #define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND) |
| 1009 | #define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004) |
| 1010 | #define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008) |
| 1011 | |
Ben Cahill | 4d3cf5f | 2007-11-29 11:10:04 +0800 | [diff] [blame] | 1012 | #define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) |
| 1013 | |
Ben Cahill | 483fd7e | 2007-11-29 11:10:05 +0800 | [diff] [blame] | 1014 | |
| 1015 | /** |
| 1016 | * Transmit DMA Channel Control/Status Registers (TCSR) |
| 1017 | * |
| 1018 | * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels |
| 1019 | * supported in hardware (don't confuse these with the 16 Tx queues in DRAM, |
| 1020 | * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. |
| 1021 | * |
| 1022 | * To use a Tx DMA channel, driver must initialize its |
| 1023 | * IWL_FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with: |
| 1024 | * |
| 1025 | * IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | |
| 1026 | * IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL |
| 1027 | * |
| 1028 | * All other bits should be 0. |
| 1029 | * |
| 1030 | * Bit fields: |
| 1031 | * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame, |
| 1032 | * '10' operate normally |
| 1033 | * 29- 4: Reserved, set to "0" |
| 1034 | * 3: Enable internal DMA requests (1, normal operation), disable (0) |
| 1035 | * 2- 0: Reserved, set to "0" |
| 1036 | */ |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 1037 | #define IWL_FH_TCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xD00) |
| 1038 | #define IWL_FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1039 | |
Ben Cahill | 483fd7e | 2007-11-29 11:10:05 +0800 | [diff] [blame] | 1040 | /* Find Control/Status reg for given Tx DMA/FIFO channel */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1041 | #define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ |
| 1042 | (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl) |
| 1043 | |
Ben Cahill | 483fd7e | 2007-11-29 11:10:05 +0800 | [diff] [blame] | 1044 | #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000) |
| 1045 | #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008) |
| 1046 | |
| 1047 | #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) |
| 1048 | #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) |
| 1049 | #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) |
| 1050 | |
| 1051 | /** |
| 1052 | * Tx Shared Status Registers (TSSR) |
| 1053 | * |
| 1054 | * After stopping Tx DMA channel (writing 0 to |
| 1055 | * IWL_FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll |
| 1056 | * IWL_FH_TSSR_TX_STATUS_REG until selected Tx channel is idle |
| 1057 | * (channel's buffers empty | no pending requests). |
| 1058 | * |
| 1059 | * Bit fields: |
| 1060 | * 31-24: 1 = Channel buffers empty (channel 7:0) |
| 1061 | * 23-16: 1 = No pending requests (channel 7:0) |
| 1062 | */ |
Ben Cahill | aad1414 | 2007-11-29 11:10:03 +0800 | [diff] [blame] | 1063 | #define IWL_FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0) |
| 1064 | #define IWL_FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1065 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1066 | #define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010) |
| 1067 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1068 | #define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \ |
| 1069 | ((1 << (_chnl)) << 24) |
| 1070 | #define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \ |
| 1071 | ((1 << (_chnl)) << 16) |
| 1072 | |
| 1073 | #define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \ |
| 1074 | (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \ |
| 1075 | IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl)) |
| 1076 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1077 | |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1078 | /********************* START TX SCHEDULER *************************************/ |
| 1079 | |
| 1080 | /** |
| 1081 | * 4965 Tx Scheduler |
| 1082 | * |
| 1083 | * The Tx Scheduler selects the next frame to be transmitted, chosing TFDs |
| 1084 | * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in |
| 1085 | * host DRAM. It steers each frame's Tx command (which contains the frame |
| 1086 | * data) into one of up to 7 prioritized Tx DMA FIFO channels within the |
| 1087 | * device. A queue maps to only one (selectable by driver) Tx DMA channel, |
| 1088 | * but one DMA channel may take input from several queues. |
| 1089 | * |
| 1090 | * Tx DMA channels have dedicated purposes. For 4965, they are used as follows: |
| 1091 | * |
| 1092 | * 0 -- EDCA BK (background) frames, lowest priority |
| 1093 | * 1 -- EDCA BE (best effort) frames, normal priority |
| 1094 | * 2 -- EDCA VI (video) frames, higher priority |
| 1095 | * 3 -- EDCA VO (voice) and management frames, highest priority |
| 1096 | * 4 -- Commands (e.g. RXON, etc.) |
| 1097 | * 5 -- HCCA short frames |
| 1098 | * 6 -- HCCA long frames |
| 1099 | * 7 -- not used by driver (device-internal only) |
| 1100 | * |
| 1101 | * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. |
| 1102 | * In addition, driver can map queues 7-15 to Tx DMA/FIFO channels 0-3 to |
| 1103 | * support 11n aggregation via EDCA DMA channels. |
| 1104 | * |
| 1105 | * The driver sets up each queue to work in one of two modes: |
| 1106 | * |
| 1107 | * 1) Scheduler-Ack, in which the scheduler automatically supports a |
| 1108 | * block-ack (BA) window of up to 64 TFDs. In this mode, each queue |
| 1109 | * contains TFDs for a unique combination of Recipient Address (RA) |
| 1110 | * and Traffic Identifier (TID), that is, traffic of a given |
| 1111 | * Quality-Of-Service (QOS) priority, destined for a single station. |
| 1112 | * |
| 1113 | * In scheduler-ack mode, the scheduler keeps track of the Tx status of |
| 1114 | * each frame within the BA window, including whether it's been transmitted, |
| 1115 | * and whether it's been acknowledged by the receiving station. The device |
| 1116 | * automatically processes block-acks received from the receiving STA, |
| 1117 | * and reschedules un-acked frames to be retransmitted (successful |
| 1118 | * Tx completion may end up being out-of-order). |
| 1119 | * |
| 1120 | * The driver must maintain the queue's Byte Count table in host DRAM |
| 1121 | * (struct iwl4965_sched_queue_byte_cnt_tbl) for this mode. |
| 1122 | * This mode does not support fragmentation. |
| 1123 | * |
| 1124 | * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. |
| 1125 | * The device may automatically retry Tx, but will retry only one frame |
| 1126 | * at a time, until receiving ACK from receiving station, or reaching |
| 1127 | * retry limit and giving up. |
| 1128 | * |
| 1129 | * The command queue (#4) must use this mode! |
| 1130 | * This mode does not require use of the Byte Count table in host DRAM. |
| 1131 | * |
| 1132 | * Driver controls scheduler operation via 3 means: |
| 1133 | * 1) Scheduler registers |
| 1134 | * 2) Shared scheduler data base in internal 4956 SRAM |
| 1135 | * 3) Shared data in host DRAM |
| 1136 | * |
| 1137 | * Initialization: |
| 1138 | * |
| 1139 | * When loading, driver should allocate memory for: |
| 1140 | * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs. |
| 1141 | * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory |
| 1142 | * (1024 bytes for each queue). |
| 1143 | * |
| 1144 | * After receiving "Alive" response from uCode, driver must initialize |
| 1145 | * the scheduler (especially for queue #4, the command queue, otherwise |
| 1146 | * the driver can't issue commands!): |
| 1147 | */ |
| 1148 | |
| 1149 | /** |
| 1150 | * Max Tx window size is the max number of contiguous TFDs that the scheduler |
| 1151 | * can keep track of at one time when creating block-ack chains of frames. |
| 1152 | * Note that "64" matches the number of ack bits in a block-ack packet. |
| 1153 | * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize |
| 1154 | * SCD_CONTEXT_QUEUE_OFFSET(x) values. |
| 1155 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1156 | #define SCD_WIN_SIZE 64 |
| 1157 | #define SCD_FRAME_LIMIT 64 |
| 1158 | |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1159 | /* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ |
| 1160 | #define SCD_START_OFFSET 0xa02c00 |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1161 | |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1162 | /* |
| 1163 | * 4965 tells driver SRAM address for internal scheduler structs via this reg. |
| 1164 | * Value is valid only after "Alive" response from uCode. |
| 1165 | */ |
| 1166 | #define SCD_SRAM_BASE_ADDR (SCD_START_OFFSET + 0x0) |
| 1167 | |
| 1168 | /* |
| 1169 | * Driver may need to update queue-empty bits after changing queue's |
| 1170 | * write and read pointers (indexes) during (re-)initialization (i.e. when |
| 1171 | * scheduler is not tracking what's happening). |
| 1172 | * Bit fields: |
| 1173 | * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit |
| 1174 | * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty |
| 1175 | * NOTE: This register is not used by Linux driver. |
| 1176 | */ |
| 1177 | #define SCD_EMPTY_BITS (SCD_START_OFFSET + 0x4) |
| 1178 | |
| 1179 | /* |
| 1180 | * Physical base address of array of byte count (BC) circular buffers (CBs). |
| 1181 | * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode. |
| 1182 | * This register points to BC CB for queue 0, must be on 1024-byte boundary. |
| 1183 | * Others are spaced by 1024 bytes. |
| 1184 | * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. |
| 1185 | * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff). |
| 1186 | * Bit fields: |
| 1187 | * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. |
| 1188 | */ |
| 1189 | #define SCD_DRAM_BASE_ADDR (SCD_START_OFFSET + 0x10) |
| 1190 | |
| 1191 | /* |
| 1192 | * Enables any/all Tx DMA/FIFO channels. |
| 1193 | * Scheduler generates requests for only the active channels. |
| 1194 | * Set this to 0xff to enable all 8 channels (normal usage). |
| 1195 | * Bit fields: |
| 1196 | * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 |
| 1197 | */ |
| 1198 | #define SCD_TXFACT (SCD_START_OFFSET + 0x1c) |
| 1199 | |
| 1200 | /* Mask to enable contiguous Tx DMA/FIFO channels between "lo" and "hi". */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1201 | #define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \ |
Reinette Chatre | 8a1b024 | 2008-01-14 17:46:25 -0800 | [diff] [blame] | 1202 | ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1203 | |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1204 | /* |
| 1205 | * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. |
| 1206 | * Initialized and updated by driver as new TFDs are added to queue. |
| 1207 | * NOTE: If using Block Ack, index must correspond to frame's |
| 1208 | * Start Sequence Number; index = (SSN & 0xff) |
| 1209 | * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? |
| 1210 | */ |
| 1211 | #define SCD_QUEUE_WRPTR(x) (SCD_START_OFFSET + 0x24 + (x) * 4) |
| 1212 | |
| 1213 | /* |
| 1214 | * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. |
| 1215 | * For FIFO mode, index indicates next frame to transmit. |
| 1216 | * For Scheduler-ACK mode, index indicates first frame in Tx window. |
| 1217 | * Initialized by driver, updated by scheduler. |
| 1218 | */ |
| 1219 | #define SCD_QUEUE_RDPTR(x) (SCD_START_OFFSET + 0x64 + (x) * 4) |
| 1220 | |
| 1221 | /* |
| 1222 | * Select which queues work in chain mode (1) vs. not (0). |
| 1223 | * Use chain mode to build chains of aggregated frames. |
| 1224 | * Bit fields: |
| 1225 | * 31-16: Reserved |
| 1226 | * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time |
| 1227 | * NOTE: If driver sets up queue for chain mode, it should be also set up |
| 1228 | * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). |
| 1229 | */ |
| 1230 | #define SCD_QUEUECHAIN_SEL (SCD_START_OFFSET + 0xd0) |
| 1231 | |
| 1232 | /* |
| 1233 | * Select which queues interrupt driver when scheduler increments |
| 1234 | * a queue's read pointer (index). |
| 1235 | * Bit fields: |
| 1236 | * 31-16: Reserved |
| 1237 | * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled |
| 1238 | * NOTE: This functionality is apparently a no-op; driver relies on interrupts |
| 1239 | * from Rx queue to read Tx command responses and update Tx queues. |
| 1240 | */ |
| 1241 | #define SCD_INTERRUPT_MASK (SCD_START_OFFSET + 0xe4) |
| 1242 | |
| 1243 | /* |
| 1244 | * Queue search status registers. One for each queue. |
| 1245 | * Sets up queue mode and assigns queue to Tx DMA channel. |
| 1246 | * Bit fields: |
| 1247 | * 19-10: Write mask/enable bits for bits 0-9 |
| 1248 | * 9: Driver should init to "0" |
| 1249 | * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0). |
| 1250 | * Driver should init to "1" for aggregation mode, or "0" otherwise. |
| 1251 | * 7-6: Driver should init to "0" |
| 1252 | * 5: Window Size Left; indicates whether scheduler can request |
| 1253 | * another TFD, based on window size, etc. Driver should init |
| 1254 | * this bit to "1" for aggregation mode, or "0" for non-agg. |
| 1255 | * 4-1: Tx FIFO to use (range 0-7). |
| 1256 | * 0: Queue is active (1), not active (0). |
| 1257 | * Other bits should be written as "0" |
| 1258 | * |
| 1259 | * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled |
| 1260 | * via SCD_QUEUECHAIN_SEL. |
| 1261 | */ |
| 1262 | #define SCD_QUEUE_STATUS_BITS(x) (SCD_START_OFFSET + 0x104 + (x) * 4) |
| 1263 | |
| 1264 | /* Bit field positions */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1265 | #define SCD_QUEUE_STTS_REG_POS_ACTIVE (0) |
| 1266 | #define SCD_QUEUE_STTS_REG_POS_TXF (1) |
| 1267 | #define SCD_QUEUE_STTS_REG_POS_WSL (5) |
| 1268 | #define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1269 | |
| 1270 | /* Write masks */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1271 | #define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) |
| 1272 | #define SCD_QUEUE_STTS_REG_MSK (0x0007FC00) |
| 1273 | |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1274 | /** |
| 1275 | * 4965 internal SRAM structures for scheduler, shared with driver ... |
| 1276 | * |
| 1277 | * Driver should clear and initialize the following areas after receiving |
| 1278 | * "Alive" response from 4965 uCode, i.e. after initial |
| 1279 | * uCode load, or after a uCode load done for error recovery: |
| 1280 | * |
| 1281 | * SCD_CONTEXT_DATA_OFFSET (size 128 bytes) |
| 1282 | * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes) |
| 1283 | * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes) |
| 1284 | * |
| 1285 | * Driver accesses SRAM via HBUS_TARG_MEM_* registers. |
| 1286 | * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR. |
| 1287 | * All OFFSET values must be added to this base address. |
| 1288 | */ |
| 1289 | |
| 1290 | /* |
| 1291 | * Queue context. One 8-byte entry for each of 16 queues. |
| 1292 | * |
| 1293 | * Driver should clear this entire area (size 0x80) to 0 after receiving |
| 1294 | * "Alive" notification from uCode. Additionally, driver should init |
| 1295 | * each queue's entry as follows: |
| 1296 | * |
| 1297 | * LS Dword bit fields: |
| 1298 | * 0-06: Max Tx window size for Scheduler-ACK. Driver should init to 64. |
| 1299 | * |
| 1300 | * MS Dword bit fields: |
| 1301 | * 16-22: Frame limit. Driver should init to 10 (0xa). |
| 1302 | * |
| 1303 | * Driver should init all other bits to 0. |
| 1304 | * |
| 1305 | * Init must be done after driver receives "Alive" response from 4965 uCode, |
| 1306 | * and when setting up queue for aggregation. |
| 1307 | */ |
| 1308 | #define SCD_CONTEXT_DATA_OFFSET 0x380 |
| 1309 | #define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) |
| 1310 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1311 | #define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) |
| 1312 | #define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1313 | #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) |
| 1314 | #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) |
| 1315 | |
Ben Cahill | e385144 | 2007-11-29 11:10:07 +0800 | [diff] [blame] | 1316 | /* |
| 1317 | * Tx Status Bitmap |
| 1318 | * |
| 1319 | * Driver should clear this entire area (size 0x100) to 0 after receiving |
| 1320 | * "Alive" notification from uCode. Area is used only by device itself; |
| 1321 | * no other support (besides clearing) is required from driver. |
| 1322 | */ |
| 1323 | #define SCD_TX_STTS_BITMAP_OFFSET 0x400 |
| 1324 | |
| 1325 | /* |
| 1326 | * RAxTID to queue translation mapping. |
| 1327 | * |
| 1328 | * When queue is in Scheduler-ACK mode, frames placed in a that queue must be |
| 1329 | * for only one combination of receiver address (RA) and traffic ID (TID), i.e. |
| 1330 | * one QOS priority level destined for one station (for this wireless link, |
| 1331 | * not final destination). The SCD_TRANSLATE_TABLE area provides 16 16-bit |
| 1332 | * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK |
| 1333 | * mode, the device ignores the mapping value. |
| 1334 | * |
| 1335 | * Bit fields, for each 16-bit map: |
| 1336 | * 15-9: Reserved, set to 0 |
| 1337 | * 8-4: Index into device's station table for recipient station |
| 1338 | * 3-0: Traffic ID (tid), range 0-15 |
| 1339 | * |
| 1340 | * Driver should clear this entire area (size 32 bytes) to 0 after receiving |
| 1341 | * "Alive" notification from uCode. To update a 16-bit map value, driver |
| 1342 | * must read a dword-aligned value from device SRAM, replace the 16-bit map |
| 1343 | * value of interest, and write the dword value back into device SRAM. |
| 1344 | */ |
| 1345 | #define SCD_TRANSLATE_TBL_OFFSET 0x500 |
| 1346 | |
| 1347 | /* Find translation table dword to read/write for given queue */ |
| 1348 | #define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ |
| 1349 | ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) |
| 1350 | |
| 1351 | #define SCD_TXFIFO_POS_TID (0) |
| 1352 | #define SCD_TXFIFO_POS_RA (4) |
| 1353 | #define SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) |
| 1354 | |
| 1355 | /*********************** END TX SCHEDULER *************************************/ |
| 1356 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1357 | static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1358 | { |
| 1359 | return le32_to_cpu(rate_n_flags) & 0xFF; |
| 1360 | } |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1361 | static inline u16 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1362 | { |
| 1363 | return le32_to_cpu(rate_n_flags) & 0xFFFF; |
| 1364 | } |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1365 | static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags) |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1366 | { |
| 1367 | return cpu_to_le32(flags|(u16)rate); |
| 1368 | } |
| 1369 | |
Ben Cahill | 5d5456f | 2007-11-29 11:10:06 +0800 | [diff] [blame] | 1370 | |
| 1371 | /** |
| 1372 | * Tx/Rx Queues |
| 1373 | * |
| 1374 | * Most communication between driver and 4965 is via queues of data buffers. |
| 1375 | * For example, all commands that the driver issues to device's embedded |
| 1376 | * controller (uCode) are via the command queue (one of the Tx queues). All |
| 1377 | * uCode command responses/replies/notifications, including Rx frames, are |
| 1378 | * conveyed from uCode to driver via the Rx queue. |
| 1379 | * |
| 1380 | * Most support for these queues, including handshake support, resides in |
| 1381 | * structures in host DRAM, shared between the driver and the device. When |
| 1382 | * allocating this memory, the driver must make sure that data written by |
| 1383 | * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's |
| 1384 | * cache memory), so DRAM and cache are consistent, and the device can |
| 1385 | * immediately see changes made by the driver. |
| 1386 | * |
| 1387 | * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via |
| 1388 | * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array |
| 1389 | * in DRAM containing 256 Transmit Frame Descriptors (TFDs). |
| 1390 | */ |
Ron Rindjunsky | dfe7d45 | 2008-04-15 16:01:45 -0700 | [diff] [blame] | 1391 | #define IWL4965_MAX_WIN_SIZE 64 |
| 1392 | #define IWL4965_QUEUE_SIZE 256 |
| 1393 | #define IWL4965_NUM_FIFOS 7 |
| 1394 | #define IWL4965_MAX_NUM_QUEUES 16 |
Ben Cahill | 5d5456f | 2007-11-29 11:10:06 +0800 | [diff] [blame] | 1395 | |
| 1396 | |
| 1397 | /** |
| 1398 | * struct iwl4965_tfd_frame_data |
| 1399 | * |
| 1400 | * Describes up to 2 buffers containing (contiguous) portions of a Tx frame. |
| 1401 | * Each buffer must be on dword boundary. |
| 1402 | * Up to 10 iwl_tfd_frame_data structures, describing up to 20 buffers, |
| 1403 | * may be filled within a TFD (iwl_tfd_frame). |
| 1404 | * |
| 1405 | * Bit fields in tb1_addr: |
| 1406 | * 31- 0: Tx buffer 1 address bits [31:0] |
| 1407 | * |
| 1408 | * Bit fields in val1: |
| 1409 | * 31-16: Tx buffer 2 address bits [15:0] |
| 1410 | * 15- 4: Tx buffer 1 length (bytes) |
| 1411 | * 3- 0: Tx buffer 1 address bits [32:32] |
| 1412 | * |
| 1413 | * Bit fields in val2: |
| 1414 | * 31-20: Tx buffer 2 length (bytes) |
| 1415 | * 19- 0: Tx buffer 2 address bits [35:16] |
| 1416 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1417 | struct iwl4965_tfd_frame_data { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1418 | __le32 tb1_addr; |
| 1419 | |
| 1420 | __le32 val1; |
| 1421 | /* __le32 ptb1_32_35:4; */ |
| 1422 | #define IWL_tb1_addr_hi_POS 0 |
| 1423 | #define IWL_tb1_addr_hi_LEN 4 |
| 1424 | #define IWL_tb1_addr_hi_SYM val1 |
| 1425 | /* __le32 tb_len1:12; */ |
| 1426 | #define IWL_tb1_len_POS 4 |
| 1427 | #define IWL_tb1_len_LEN 12 |
| 1428 | #define IWL_tb1_len_SYM val1 |
| 1429 | /* __le32 ptb2_0_15:16; */ |
| 1430 | #define IWL_tb2_addr_lo16_POS 16 |
| 1431 | #define IWL_tb2_addr_lo16_LEN 16 |
| 1432 | #define IWL_tb2_addr_lo16_SYM val1 |
| 1433 | |
| 1434 | __le32 val2; |
| 1435 | /* __le32 ptb2_16_35:20; */ |
| 1436 | #define IWL_tb2_addr_hi20_POS 0 |
| 1437 | #define IWL_tb2_addr_hi20_LEN 20 |
| 1438 | #define IWL_tb2_addr_hi20_SYM val2 |
| 1439 | /* __le32 tb_len2:12; */ |
| 1440 | #define IWL_tb2_len_POS 20 |
| 1441 | #define IWL_tb2_len_LEN 12 |
| 1442 | #define IWL_tb2_len_SYM val2 |
| 1443 | } __attribute__ ((packed)); |
| 1444 | |
Ben Cahill | 5d5456f | 2007-11-29 11:10:06 +0800 | [diff] [blame] | 1445 | |
| 1446 | /** |
| 1447 | * struct iwl4965_tfd_frame |
| 1448 | * |
| 1449 | * Transmit Frame Descriptor (TFD) |
| 1450 | * |
| 1451 | * 4965 supports up to 16 Tx queues resident in host DRAM. |
| 1452 | * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. |
| 1453 | * Both driver and device share these circular buffers, each of which must be |
| 1454 | * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes for 4965. |
| 1455 | * |
| 1456 | * Driver must indicate the physical address of the base of each |
| 1457 | * circular buffer via the 4965's FH_MEM_CBBC_QUEUE registers. |
| 1458 | * |
| 1459 | * Each TFD contains pointer/size information for up to 20 data buffers |
| 1460 | * in host DRAM. These buffers collectively contain the (one) frame described |
| 1461 | * by the TFD. Each buffer must be a single contiguous block of memory within |
| 1462 | * itself, but buffers may be scattered in host DRAM. Each buffer has max size |
| 1463 | * of (4K - 4). The 4965 concatenates all of a TFD's buffers into a single |
| 1464 | * Tx frame, up to 8 KBytes in size. |
| 1465 | * |
| 1466 | * Bit fields in the control dword (val0): |
| 1467 | * 31-30: # dwords (0-3) of padding required at end of frame for 16-byte bound |
| 1468 | * 29: reserved |
| 1469 | * 28-24: # Transmit Buffer Descriptors in TFD |
| 1470 | * 23- 0: reserved |
| 1471 | * |
| 1472 | * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. |
| 1473 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1474 | struct iwl4965_tfd_frame { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1475 | __le32 val0; |
| 1476 | /* __le32 rsvd1:24; */ |
| 1477 | /* __le32 num_tbs:5; */ |
| 1478 | #define IWL_num_tbs_POS 24 |
| 1479 | #define IWL_num_tbs_LEN 5 |
| 1480 | #define IWL_num_tbs_SYM val0 |
| 1481 | /* __le32 rsvd2:1; */ |
| 1482 | /* __le32 padding:2; */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1483 | struct iwl4965_tfd_frame_data pa[10]; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1484 | __le32 reserved; |
| 1485 | } __attribute__ ((packed)); |
| 1486 | |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1487 | |
Ben Cahill | 5d5456f | 2007-11-29 11:10:06 +0800 | [diff] [blame] | 1488 | /** |
| 1489 | * struct iwl4965_queue_byte_cnt_entry |
| 1490 | * |
| 1491 | * Byte Count Table Entry |
| 1492 | * |
| 1493 | * Bit fields: |
| 1494 | * 15-12: reserved |
| 1495 | * 11- 0: total to-be-transmitted byte count of frame (does not include command) |
| 1496 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1497 | struct iwl4965_queue_byte_cnt_entry { |
| 1498 | __le16 val; |
| 1499 | /* __le16 byte_cnt:12; */ |
| 1500 | #define IWL_byte_cnt_POS 0 |
| 1501 | #define IWL_byte_cnt_LEN 12 |
| 1502 | #define IWL_byte_cnt_SYM val |
| 1503 | /* __le16 rsvd:4; */ |
| 1504 | } __attribute__ ((packed)); |
| 1505 | |
Ben Cahill | 5d5456f | 2007-11-29 11:10:06 +0800 | [diff] [blame] | 1506 | |
| 1507 | /** |
| 1508 | * struct iwl4965_sched_queue_byte_cnt_tbl |
| 1509 | * |
| 1510 | * Byte Count table |
| 1511 | * |
| 1512 | * Each Tx queue uses a byte-count table containing 320 entries: |
| 1513 | * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that |
| 1514 | * duplicate the first 64 entries (to avoid wrap-around within a Tx window; |
| 1515 | * max Tx window is 64 TFDs). |
| 1516 | * |
| 1517 | * When driver sets up a new TFD, it must also enter the total byte count |
| 1518 | * of the frame to be transmitted into the corresponding entry in the byte |
| 1519 | * count table for the chosen Tx queue. If the TFD index is 0-63, the driver |
| 1520 | * must duplicate the byte count entry in corresponding index 256-319. |
| 1521 | * |
| 1522 | * "dont_care" padding puts each byte count table on a 1024-byte boundary; |
| 1523 | * 4965 assumes tables are separated by 1024 bytes. |
| 1524 | */ |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1525 | struct iwl4965_sched_queue_byte_cnt_tbl { |
| 1526 | struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE + |
| 1527 | IWL4965_MAX_WIN_SIZE]; |
| 1528 | u8 dont_care[1024 - |
| 1529 | (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) * |
| 1530 | sizeof(__le16)]; |
| 1531 | } __attribute__ ((packed)); |
| 1532 | |
Ben Cahill | 5d5456f | 2007-11-29 11:10:06 +0800 | [diff] [blame] | 1533 | |
| 1534 | /** |
| 1535 | * struct iwl4965_shared - handshake area for Tx and Rx |
| 1536 | * |
| 1537 | * For convenience in allocating memory, this structure combines 2 areas of |
| 1538 | * DRAM which must be shared between driver and 4965. These do not need to |
| 1539 | * be combined, if better allocation would result from keeping them separate: |
| 1540 | * |
| 1541 | * 1) The Tx byte count tables occupy 1024 bytes each (16 KBytes total for |
| 1542 | * 16 queues). Driver uses SCD_DRAM_BASE_ADDR to tell 4965 where to find |
| 1543 | * the first of these tables. 4965 assumes tables are 1024 bytes apart. |
| 1544 | * |
| 1545 | * 2) The Rx status (val0 and val1) occupies only 8 bytes. Driver uses |
| 1546 | * FH_RSCSR_CHNL0_STTS_WPTR_REG to tell 4965 where to find this area. |
| 1547 | * Driver reads val0 to determine the latest Receive Buffer Descriptor (RBD) |
| 1548 | * that has been filled by the 4965. |
| 1549 | * |
| 1550 | * Bit fields val0: |
| 1551 | * 31-12: Not used |
| 1552 | * 11- 0: Index of last filled Rx buffer descriptor (4965 writes, driver reads) |
| 1553 | * |
| 1554 | * Bit fields val1: |
| 1555 | * 31- 0: Not used |
| 1556 | */ |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1557 | struct iwl4965_shared { |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1558 | struct iwl4965_sched_queue_byte_cnt_tbl |
Ron Rindjunsky | dfe7d45 | 2008-04-15 16:01:45 -0700 | [diff] [blame] | 1559 | queues_byte_cnt_tbls[IWL4965_MAX_NUM_QUEUES]; |
Tomas Winkler | 059ff82 | 2008-04-14 21:16:14 -0700 | [diff] [blame] | 1560 | __le32 rb_closed; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1561 | |
| 1562 | /* __le32 rb_closed_stts_rb_num:12; */ |
| 1563 | #define IWL_rb_closed_stts_rb_num_POS 0 |
| 1564 | #define IWL_rb_closed_stts_rb_num_LEN 12 |
Tomas Winkler | 059ff82 | 2008-04-14 21:16:14 -0700 | [diff] [blame] | 1565 | #define IWL_rb_closed_stts_rb_num_SYM rb_closed |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1566 | /* __le32 rsrv1:4; */ |
| 1567 | /* __le32 rb_closed_stts_rx_frame_num:12; */ |
| 1568 | #define IWL_rb_closed_stts_rx_frame_num_POS 16 |
| 1569 | #define IWL_rb_closed_stts_rx_frame_num_LEN 12 |
Tomas Winkler | 059ff82 | 2008-04-14 21:16:14 -0700 | [diff] [blame] | 1570 | #define IWL_rb_closed_stts_rx_frame_num_SYM rb_closed |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1571 | /* __le32 rsrv2:4; */ |
| 1572 | |
Tomas Winkler | 059ff82 | 2008-04-14 21:16:14 -0700 | [diff] [blame] | 1573 | __le32 frm_finished; |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1574 | /* __le32 frame_finished_stts_rb_num:12; */ |
| 1575 | #define IWL_frame_finished_stts_rb_num_POS 0 |
| 1576 | #define IWL_frame_finished_stts_rb_num_LEN 12 |
Tomas Winkler | 059ff82 | 2008-04-14 21:16:14 -0700 | [diff] [blame] | 1577 | #define IWL_frame_finished_stts_rb_num_SYM frm_finished |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1578 | /* __le32 rsrv3:4; */ |
| 1579 | /* __le32 frame_finished_stts_rx_frame_num:12; */ |
| 1580 | #define IWL_frame_finished_stts_rx_frame_num_POS 16 |
| 1581 | #define IWL_frame_finished_stts_rx_frame_num_LEN 12 |
Tomas Winkler | 059ff82 | 2008-04-14 21:16:14 -0700 | [diff] [blame] | 1582 | #define IWL_frame_finished_stts_rx_frame_num_SYM frm_finished |
Zhu Yi | b481de9 | 2007-09-25 17:54:57 -0700 | [diff] [blame] | 1583 | /* __le32 rsrv4:4; */ |
| 1584 | |
| 1585 | __le32 padding1; /* so that allocation will be aligned to 16B */ |
| 1586 | __le32 padding2; |
| 1587 | } __attribute__ ((packed)); |
| 1588 | |
Christoph Hellwig | bb8c093 | 2008-01-27 16:41:47 -0800 | [diff] [blame] | 1589 | #endif /* __iwl4965_4965_hw_h__ */ |