iwl-4965-hw.h 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509
  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 - 2007 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. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  29. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  30. *
  31. * BSD LICENSE
  32. *
  33. * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. *
  40. * * Redistributions of source code must retain the above copyright
  41. * notice, this list of conditions and the following disclaimer.
  42. * * Redistributions in binary form must reproduce the above copyright
  43. * notice, this list of conditions and the following disclaimer in
  44. * the documentation and/or other materials provided with the
  45. * distribution.
  46. * * Neither the name Intel Corporation nor the names of its
  47. * contributors may be used to endorse or promote products derived
  48. * from this software without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  54. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  55. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  56. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  57. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  58. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  59. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  60. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61. *
  62. *****************************************************************************/
  63. /*
  64. * 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. */
  68. #ifndef __iwl_4965_hw_h__
  69. #define __iwl_4965_hw_h__
  70. /*
  71. * uCode queue management definitions ...
  72. * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4.
  73. * The first queue used for block-ack aggregation is #7 (4965 only).
  74. * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7.
  75. */
  76. #define IWL_CMD_QUEUE_NUM 4
  77. #define IWL_CMD_FIFO_NUM 4
  78. #define IWL_BACK_QUEUE_FIRST_ID 7
  79. /* Tx rates */
  80. #define IWL_CCK_RATES 4
  81. #define IWL_OFDM_RATES 8
  82. #define IWL_HT_RATES 16
  83. #define IWL_MAX_RATES (IWL_CCK_RATES+IWL_OFDM_RATES+IWL_HT_RATES)
  84. /* Time constants */
  85. #define SHORT_SLOT_TIME 9
  86. #define LONG_SLOT_TIME 20
  87. /* RSSI to dBm */
  88. #define IWL_RSSI_OFFSET 44
  89. /*
  90. * EEPROM related constants, enums, and structures.
  91. */
  92. /*
  93. * EEPROM access time values:
  94. *
  95. * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG,
  96. * then clearing (with subsequent read/modify/write) CSR_EEPROM_REG bit
  97. * CSR_EEPROM_REG_BIT_CMD (0x2).
  98. * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
  99. * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
  100. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
  101. */
  102. #define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
  103. #define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
  104. /*
  105. * Regulatory channel usage flags in EEPROM struct iwl4965_eeprom_channel.flags.
  106. *
  107. * IBSS and/or AP operation is allowed *only* on those channels with
  108. * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
  109. * RADAR detection is not supported by the 4965 driver, but is a
  110. * requirement for establishing a new network for legal operation on channels
  111. * requiring RADAR detection or restricting ACTIVE scanning.
  112. *
  113. * NOTE: "WIDE" flag does not indicate anything about "FAT" 40 MHz channels.
  114. * It only indicates that 20 MHz channel use is supported; FAT channel
  115. * usage is indicated by a separate set of regulatory flags for each
  116. * FAT channel pair.
  117. *
  118. * NOTE: Using a channel inappropriately will result in a uCode error!
  119. */
  120. enum {
  121. EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
  122. EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
  123. /* Bit 2 Reserved */
  124. EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
  125. EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
  126. EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
  127. EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel (not used) */
  128. EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
  129. };
  130. /* SKU Capabilities */
  131. #define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
  132. #define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
  133. /* *regulatory* channel data format in eeprom, one for each channel.
  134. * There are separate entries for FAT (40 MHz) vs. normal (20 MHz) channels. */
  135. struct iwl4965_eeprom_channel {
  136. u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */
  137. s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
  138. } __attribute__ ((packed));
  139. /* 4965 has two radio transmitters (and 3 radio receivers) */
  140. #define EEPROM_TX_POWER_TX_CHAINS (2)
  141. /* 4965 has room for up to 8 sets of txpower calibration data */
  142. #define EEPROM_TX_POWER_BANDS (8)
  143. /* 4965 factory calibration measures txpower gain settings for
  144. * each of 3 target output levels */
  145. #define EEPROM_TX_POWER_MEASUREMENTS (3)
  146. /* 4965 driver does not work with txpower calibration version < 5.
  147. * Look for this in calib_version member of struct iwl4965_eeprom. */
  148. #define EEPROM_TX_POWER_VERSION_NEW (5)
  149. /*
  150. * 4965 factory calibration data for one txpower level, on one channel,
  151. * measured on one of the 2 tx chains (radio transmitter and associated
  152. * antenna). EEPROM contains:
  153. *
  154. * 1) Temperature (degrees Celsius) of device when measurement was made.
  155. *
  156. * 2) Gain table index used to achieve the target measurement power.
  157. * This refers to the "well-known" gain tables (see iwl-4965-hw.h).
  158. *
  159. * 3) Actual measured output power, in half-dBm ("34" = 17 dBm).
  160. *
  161. * 4) RF power amplifier detector level measurement (not used).
  162. */
  163. struct iwl4965_eeprom_calib_measure {
  164. u8 temperature; /* Device temperature (Celsius) */
  165. u8 gain_idx; /* Index into gain table */
  166. u8 actual_pow; /* Measured RF output power, half-dBm */
  167. s8 pa_det; /* Power amp detector level (not used) */
  168. } __attribute__ ((packed));
  169. /*
  170. * 4965 measurement set for one channel. EEPROM contains:
  171. *
  172. * 1) Channel number measured
  173. *
  174. * 2) Measurements for each of 3 power levels for each of 2 radio transmitters
  175. * (a.k.a. "tx chains") (6 measurements altogether)
  176. */
  177. struct iwl4965_eeprom_calib_ch_info {
  178. u8 ch_num;
  179. struct iwl4965_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS]
  180. [EEPROM_TX_POWER_MEASUREMENTS];
  181. } __attribute__ ((packed));
  182. /*
  183. * 4965 txpower subband info.
  184. *
  185. * For each frequency subband, EEPROM contains the following:
  186. *
  187. * 1) First and last channels within range of the subband. "0" values
  188. * indicate that this sample set is not being used.
  189. *
  190. * 2) Sample measurement sets for 2 channels close to the range endpoints.
  191. */
  192. struct iwl4965_eeprom_calib_subband_info {
  193. u8 ch_from; /* channel number of lowest channel in subband */
  194. u8 ch_to; /* channel number of highest channel in subband */
  195. struct iwl4965_eeprom_calib_ch_info ch1;
  196. struct iwl4965_eeprom_calib_ch_info ch2;
  197. } __attribute__ ((packed));
  198. /*
  199. * 4965 txpower calibration info. EEPROM contains:
  200. *
  201. * 1) Factory-measured saturation power levels (maximum levels at which
  202. * tx power amplifier can output a signal without too much distortion).
  203. * There is one level for 2.4 GHz band and one for 5 GHz band. These
  204. * values apply to all channels within each of the bands.
  205. *
  206. * 2) Factory-measured power supply voltage level. This is assumed to be
  207. * constant (i.e. same value applies to all channels/bands) while the
  208. * factory measurements are being made.
  209. *
  210. * 3) Up to 8 sets of factory-measured txpower calibration values.
  211. * These are for different frequency ranges, since txpower gain
  212. * characteristics of the analog radio circuitry vary with frequency.
  213. *
  214. * Not all sets need to be filled with data;
  215. * struct iwl4965_eeprom_calib_subband_info contains range of channels
  216. * (0 if unused) for each set of data.
  217. */
  218. struct iwl4965_eeprom_calib_info {
  219. u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
  220. u8 saturation_power52; /* half-dBm */
  221. s16 voltage; /* signed */
  222. struct iwl4965_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS];
  223. } __attribute__ ((packed));
  224. /*
  225. * 4965 EEPROM map
  226. */
  227. struct iwl4965_eeprom {
  228. u8 reserved0[16];
  229. #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
  230. u16 device_id; /* abs.ofs: 16 */
  231. u8 reserved1[2];
  232. #define EEPROM_PMC (2*0x0A) /* 2 bytes */
  233. u16 pmc; /* abs.ofs: 20 */
  234. u8 reserved2[20];
  235. #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
  236. u8 mac_address[6]; /* abs.ofs: 42 */
  237. u8 reserved3[58];
  238. #define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
  239. u16 board_revision; /* abs.ofs: 106 */
  240. u8 reserved4[11];
  241. #define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
  242. u8 board_pba_number[9]; /* abs.ofs: 119 */
  243. u8 reserved5[8];
  244. #define EEPROM_VERSION (2*0x44) /* 2 bytes */
  245. u16 version; /* abs.ofs: 136 */
  246. #define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
  247. u8 sku_cap; /* abs.ofs: 138 */
  248. #define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
  249. u8 leds_mode; /* abs.ofs: 139 */
  250. #define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
  251. u16 oem_mode;
  252. #define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
  253. u16 wowlan_mode; /* abs.ofs: 142 */
  254. #define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
  255. u16 leds_time_interval; /* abs.ofs: 144 */
  256. #define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
  257. u8 leds_off_time; /* abs.ofs: 146 */
  258. #define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
  259. u8 leds_on_time; /* abs.ofs: 147 */
  260. #define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
  261. u8 almgor_m_version; /* abs.ofs: 148 */
  262. #define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
  263. u8 antenna_switch_type; /* abs.ofs: 149 */
  264. u8 reserved6[8];
  265. #define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
  266. u16 board_revision_4965; /* abs.ofs: 158 */
  267. u8 reserved7[13];
  268. #define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
  269. u8 board_pba_number_4965[9]; /* abs.ofs: 173 */
  270. u8 reserved8[10];
  271. #define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
  272. u8 sku_id[4]; /* abs.ofs: 192 */
  273. /*
  274. * Per-channel regulatory data.
  275. *
  276. * Each channel that *might* be supported by 3945 or 4965 has a fixed location
  277. * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
  278. * txpower (MSB).
  279. *
  280. * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
  281. * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
  282. *
  283. * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  284. */
  285. #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
  286. u16 band_1_count; /* abs.ofs: 196 */
  287. #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
  288. struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
  289. /*
  290. * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
  291. * 5.0 GHz channels 7, 8, 11, 12, 16
  292. * (4915-5080MHz) (none of these is ever supported)
  293. */
  294. #define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
  295. u16 band_2_count; /* abs.ofs: 226 */
  296. #define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
  297. struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
  298. /*
  299. * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
  300. * (5170-5320MHz)
  301. */
  302. #define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
  303. u16 band_3_count; /* abs.ofs: 254 */
  304. #define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
  305. struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
  306. /*
  307. * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
  308. * (5500-5700MHz)
  309. */
  310. #define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
  311. u16 band_4_count; /* abs.ofs: 280 */
  312. #define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
  313. struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
  314. /*
  315. * 5.7 GHz channels 145, 149, 153, 157, 161, 165
  316. * (5725-5825MHz)
  317. */
  318. #define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
  319. u16 band_5_count; /* abs.ofs: 304 */
  320. #define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
  321. struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
  322. u8 reserved10[2];
  323. /*
  324. * 2.4 GHz FAT channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11)
  325. *
  326. * The channel listed is the center of the lower 20 MHz half of the channel.
  327. * The overall center frequency is actually 2 channels (10 MHz) above that,
  328. * and the upper half of each FAT channel is centered 4 channels (20 MHz) away
  329. * from the lower half; e.g. the upper half of FAT channel 1 is channel 5,
  330. * and the overall FAT channel width centers on channel 3.
  331. *
  332. * NOTE: The RXON command uses 20 MHz channel numbers to specify the
  333. * control channel to which to tune. RXON also specifies whether the
  334. * control channel is the upper or lower half of a FAT channel.
  335. *
  336. * NOTE: 4965 does not support FAT channels on 2.4 GHz.
  337. */
  338. #define EEPROM_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */
  339. struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */
  340. u8 reserved11[2];
  341. /*
  342. * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64),
  343. * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
  344. */
  345. #define EEPROM_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */
  346. struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */
  347. u8 reserved12[6];
  348. /*
  349. * 4965 driver requires txpower calibration format version 5 or greater.
  350. * Driver does not work with txpower calibration version < 5.
  351. * This value is simply a 16-bit number, no major/minor versions here.
  352. */
  353. #define EEPROM_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
  354. u16 calib_version; /* abs.ofs: 364 */
  355. u8 reserved13[2];
  356. u8 reserved14[96]; /* abs.ofs: 368 */
  357. /*
  358. * 4965 Txpower calibration data.
  359. */
  360. #define EEPROM_IWL_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
  361. struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */
  362. u8 reserved16[140]; /* fill out to full 1024 byte block */
  363. } __attribute__ ((packed));
  364. #define IWL_EEPROM_IMAGE_SIZE 1024
  365. /* End of EEPROM */
  366. #include "iwl-4965-commands.h"
  367. #define PCI_LINK_CTRL 0x0F0
  368. #define PCI_POWER_SOURCE 0x0C8
  369. #define PCI_REG_WUM8 0x0E8
  370. #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
  371. /*=== CSR (control and status registers) ===*/
  372. #define CSR_BASE (0x000)
  373. #define CSR_SW_VER (CSR_BASE+0x000)
  374. #define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */
  375. #define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */
  376. #define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */
  377. #define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */
  378. #define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/
  379. #define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */
  380. #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
  381. #define CSR_GP_CNTRL (CSR_BASE+0x024)
  382. /*
  383. * Hardware revision info
  384. * Bit fields:
  385. * 31-8: Reserved
  386. * 7-4: Type of device: 0x0 = 4965, 0xd = 3945
  387. * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D
  388. * 1-0: "Dash" value, as in A-1, etc.
  389. *
  390. * NOTE: Revision step affects calculation of CCK txpower for 4965.
  391. */
  392. #define CSR_HW_REV (CSR_BASE+0x028)
  393. /* EEPROM reads */
  394. #define CSR_EEPROM_REG (CSR_BASE+0x02c)
  395. #define CSR_EEPROM_GP (CSR_BASE+0x030)
  396. #define CSR_GP_UCODE (CSR_BASE+0x044)
  397. #define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
  398. #define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058)
  399. #define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
  400. #define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
  401. #define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
  402. /*
  403. * Indicates hardware rev, to determine CCK backoff for txpower calculation.
  404. * Bit fields:
  405. * 3-2: 0 = A, 1 = B, 2 = C, 3 = D step
  406. */
  407. #define CSR_HW_REV_WA_REG (CSR_BASE+0x22C)
  408. /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
  409. * acknowledged (reset) by host writing "1" to flagged bits. */
  410. #define CSR_INT_BIT_FH_RX (1<<31) /* Rx DMA, cmd responses, FH_INT[17:16] */
  411. #define CSR_INT_BIT_HW_ERR (1<<29) /* DMA hardware error FH_INT[31] */
  412. #define CSR_INT_BIT_DNLD (1<<28) /* uCode Download */
  413. #define CSR_INT_BIT_FH_TX (1<<27) /* Tx DMA FH_INT[1:0] */
  414. #define CSR_INT_BIT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
  415. #define CSR_INT_BIT_SW_ERR (1<<25) /* uCode error */
  416. #define CSR_INT_BIT_RF_KILL (1<<7) /* HW RFKILL switch GP_CNTRL[27] toggled */
  417. #define CSR_INT_BIT_CT_KILL (1<<6) /* Critical temp (chip too hot) rfkill */
  418. #define CSR_INT_BIT_SW_RX (1<<3) /* Rx, command responses, 3945 */
  419. #define CSR_INT_BIT_WAKEUP (1<<1) /* NIC controller waking up (pwr mgmt) */
  420. #define CSR_INT_BIT_ALIVE (1<<0) /* uCode interrupts once it initializes */
  421. #define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \
  422. CSR_INT_BIT_HW_ERR | \
  423. CSR_INT_BIT_FH_TX | \
  424. CSR_INT_BIT_SW_ERR | \
  425. CSR_INT_BIT_RF_KILL | \
  426. CSR_INT_BIT_SW_RX | \
  427. CSR_INT_BIT_WAKEUP | \
  428. CSR_INT_BIT_ALIVE)
  429. /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
  430. #define CSR_FH_INT_BIT_ERR (1<<31) /* Error */
  431. #define CSR_FH_INT_BIT_HI_PRIOR (1<<30) /* High priority Rx, bypass coalescing */
  432. #define CSR_FH_INT_BIT_RX_CHNL1 (1<<17) /* Rx channel 1 */
  433. #define CSR_FH_INT_BIT_RX_CHNL0 (1<<16) /* Rx channel 0 */
  434. #define CSR_FH_INT_BIT_TX_CHNL1 (1<<1) /* Tx channel 1 */
  435. #define CSR_FH_INT_BIT_TX_CHNL0 (1<<0) /* Tx channel 0 */
  436. #define CSR_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \
  437. CSR_FH_INT_BIT_RX_CHNL1 | \
  438. CSR_FH_INT_BIT_RX_CHNL0)
  439. #define CSR_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL1 | \
  440. CSR_FH_INT_BIT_TX_CHNL0)
  441. /* RESET */
  442. #define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001)
  443. #define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002)
  444. #define CSR_RESET_REG_FLAG_SW_RESET (0x00000080)
  445. #define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100)
  446. #define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200)
  447. /* GP (general purpose) CONTROL */
  448. #define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001)
  449. #define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
  450. #define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008)
  451. #define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
  452. #define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001)
  453. #define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000)
  454. #define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000)
  455. #define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000)
  456. /* EEPROM REG */
  457. #define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
  458. #define CSR_EEPROM_REG_BIT_CMD (0x00000002)
  459. /* EEPROM GP */
  460. #define CSR_EEPROM_GP_VALID_MSK (0x00000006)
  461. #define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
  462. #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
  463. /* UCODE DRV GP */
  464. #define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001)
  465. #define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
  466. #define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
  467. #define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
  468. /* GPIO */
  469. #define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200)
  470. #define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000)
  471. #define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC CSR_GPIO_IN_BIT_AUX_POWER
  472. /* GI Chicken Bits */
  473. #define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
  474. #define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
  475. /*=== HBUS (Host-side Bus) ===*/
  476. #define HBUS_BASE (0x400)
  477. /*
  478. * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
  479. * structures, error log, event log, verifying uCode load).
  480. * First write to address register, then read from or write to data register
  481. * to complete the job. Once the address register is set up, accesses to
  482. * data registers auto-increment the address by one dword.
  483. * Bit usage for address registers (read or write):
  484. * 0-31: memory address within device
  485. */
  486. #define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c)
  487. #define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010)
  488. #define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018)
  489. #define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c)
  490. /*
  491. * Registers for accessing device's internal peripheral registers
  492. * (e.g. SCD, BSM, etc.). First write to address register,
  493. * then read from or write to data register to complete the job.
  494. * Bit usage for address registers (read or write):
  495. * 0-15: register address (offset) within device
  496. * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword)
  497. */
  498. #define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044)
  499. #define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048)
  500. #define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c)
  501. #define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050)
  502. /*
  503. * Per-Tx-queue write pointer (index, really!) (3945 and 4965).
  504. * Indicates index to next TFD that driver will fill (1 past latest filled).
  505. * Bit usage:
  506. * 0-7: queue write index (0-255)
  507. * 11-8: queue selector (0-15)
  508. */
  509. #define HBUS_TARG_WRPTR (HBUS_BASE+0x060)
  510. #define HBUS_TARG_MBX_C (HBUS_BASE+0x030)
  511. /*=== FH (data Flow Handler) ===*/
  512. #define FH_BASE (0x800)
  513. #define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
  514. /* RSSR */
  515. #define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
  516. #define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
  517. /* TCSR */
  518. #define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
  519. #define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
  520. #define FH_TCSR_CREDIT(_channel) (FH_TCSR(_channel)+0x04)
  521. #define FH_TCSR_BUFF_STTS(_channel) (FH_TCSR(_channel)+0x08)
  522. /* TSSR */
  523. #define FH_TSSR_CBB_BASE (FH_TSSR_TABLE+0x000)
  524. #define FH_TSSR_MSG_CONFIG (FH_TSSR_TABLE+0x008)
  525. #define FH_TSSR_TX_STATUS (FH_TSSR_TABLE+0x010)
  526. #define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004)
  527. #define TFD_QUEUE_SIZE_MAX (256)
  528. #define IWL_NUM_SCAN_RATES (2)
  529. #define IWL_DEFAULT_TX_RETRY 15
  530. #define RX_QUEUE_SIZE 256
  531. #define RX_QUEUE_MASK 255
  532. #define RX_QUEUE_SIZE_LOG 8
  533. #define TFD_TX_CMD_SLOTS 256
  534. #define TFD_CMD_SLOTS 32
  535. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl4965_cmd) - \
  536. sizeof(struct iwl4965_cmd_meta))
  537. /*
  538. * RX related structures and functions
  539. */
  540. #define RX_FREE_BUFFERS 64
  541. #define RX_LOW_WATERMARK 8
  542. /* Size of one Rx buffer in host DRAM */
  543. #define IWL_RX_BUF_SIZE (4 * 1024)
  544. /* Sizes and addresses for instruction and data memory (SRAM) in
  545. * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
  546. #define RTC_INST_LOWER_BOUND (0x000000)
  547. #define KDR_RTC_INST_UPPER_BOUND (0x018000)
  548. #define RTC_DATA_LOWER_BOUND (0x800000)
  549. #define KDR_RTC_DATA_UPPER_BOUND (0x80A000)
  550. #define KDR_RTC_INST_SIZE (KDR_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
  551. #define KDR_RTC_DATA_SIZE (KDR_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
  552. #define IWL_MAX_INST_SIZE KDR_RTC_INST_SIZE
  553. #define IWL_MAX_DATA_SIZE KDR_RTC_DATA_SIZE
  554. /* Size of uCode instruction memory in bootstrap state machine */
  555. #define IWL_MAX_BSM_SIZE BSM_SRAM_SIZE
  556. static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr)
  557. {
  558. return (addr >= RTC_DATA_LOWER_BOUND) &&
  559. (addr < KDR_RTC_DATA_UPPER_BOUND);
  560. }
  561. /********************* START TEMPERATURE *************************************/
  562. /**
  563. * 4965 temperature calculation.
  564. *
  565. * The driver must calculate the device temperature before calculating
  566. * a txpower setting (amplifier gain is temperature dependent). The
  567. * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration
  568. * values used for the life of the driver, and one of which (R4) is the
  569. * real-time temperature indicator.
  570. *
  571. * uCode provides all 4 values to the driver via the "initialize alive"
  572. * notification (see struct iwl4965_init_alive_resp). After the runtime uCode
  573. * image loads, uCode updates the R4 value via statistics notifications
  574. * (see STATISTICS_NOTIFICATION), which occur after each received beacon
  575. * when associated, or can be requested via REPLY_STATISTICS_CMD.
  576. *
  577. * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver
  578. * must sign-extend to 32 bits before applying formula below.
  579. *
  580. * Formula:
  581. *
  582. * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8
  583. *
  584. * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is
  585. * an additional correction, which should be centered around 0 degrees
  586. * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for
  587. * centering the 97/100 correction around 0 degrees K.
  588. *
  589. * Add 273 to Kelvin value to find degrees Celsius, for comparing current
  590. * temperature with factory-measured temperatures when calculating txpower
  591. * settings.
  592. */
  593. #define TEMPERATURE_CALIB_KELVIN_OFFSET 8
  594. #define TEMPERATURE_CALIB_A_VAL 259
  595. /* Limit range of calculated temperature to be between these Kelvin values */
  596. #define IWL_TX_POWER_TEMPERATURE_MIN (263)
  597. #define IWL_TX_POWER_TEMPERATURE_MAX (410)
  598. #define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
  599. (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \
  600. ((t) > IWL_TX_POWER_TEMPERATURE_MAX))
  601. /********************* END TEMPERATURE ***************************************/
  602. /********************* START TXPOWER *****************************************/
  603. /**
  604. * 4965 txpower calculations rely on information from three sources:
  605. *
  606. * 1) EEPROM
  607. * 2) "initialize" alive notification
  608. * 3) statistics notifications
  609. *
  610. * EEPROM data consists of:
  611. *
  612. * 1) Regulatory information (max txpower and channel usage flags) is provided
  613. * separately for each channel that can possibly supported by 4965.
  614. * 40 MHz wide (.11n fat) channels are listed separately from 20 MHz
  615. * (legacy) channels.
  616. *
  617. * See struct iwl4965_eeprom_channel for format, and struct iwl4965_eeprom
  618. * for locations in EEPROM.
  619. *
  620. * 2) Factory txpower calibration information is provided separately for
  621. * sub-bands of contiguous channels. 2.4GHz has just one sub-band,
  622. * but 5 GHz has several sub-bands.
  623. *
  624. * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided.
  625. *
  626. * See struct iwl4965_eeprom_calib_info (and the tree of structures
  627. * contained within it) for format, and struct iwl4965_eeprom for
  628. * locations in EEPROM.
  629. *
  630. * "Initialization alive" notification (see struct iwl4965_init_alive_resp)
  631. * consists of:
  632. *
  633. * 1) Temperature calculation parameters.
  634. *
  635. * 2) Power supply voltage measurement.
  636. *
  637. * 3) Tx gain compensation to balance 2 transmitters for MIMO use.
  638. *
  639. * Statistics notifications deliver:
  640. *
  641. * 1) Current values for temperature param R4.
  642. */
  643. /**
  644. * To calculate a txpower setting for a given desired target txpower, channel,
  645. * modulation bit rate, and transmitter chain (4965 has 2 transmitters to
  646. * support MIMO and transmit diversity), driver must do the following:
  647. *
  648. * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel.
  649. * Do not exceed regulatory limit; reduce target txpower if necessary.
  650. *
  651. * If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31),
  652. * 2 transmitters will be used simultaneously; driver must reduce the
  653. * regulatory limit by 3 dB (half-power) for each transmitter, so the
  654. * combined total output of the 2 transmitters is within regulatory limits.
  655. *
  656. *
  657. * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by
  658. * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]);
  659. * reduce target txpower if necessary.
  660. *
  661. * Backoff values below are in 1/2 dB units (equivalent to steps in
  662. * txpower gain tables):
  663. *
  664. * OFDM 6 - 36 MBit: 10 steps (5 dB)
  665. * OFDM 48 MBit: 15 steps (7.5 dB)
  666. * OFDM 54 MBit: 17 steps (8.5 dB)
  667. * OFDM 60 MBit: 20 steps (10 dB)
  668. * CCK all rates: 10 steps (5 dB)
  669. *
  670. * Backoff values apply to saturation txpower on a per-transmitter basis;
  671. * when using MIMO (2 transmitters), each transmitter uses the same
  672. * saturation level provided in EEPROM, and the same backoff values;
  673. * no reduction (such as with regulatory txpower limits) is required.
  674. *
  675. * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel
  676. * widths and 40 Mhz (.11n fat) channel widths; there is no separate
  677. * factory measurement for fat channels.
  678. *
  679. * The result of this step is the final target txpower. The rest of
  680. * the steps figure out the proper settings for the device to achieve
  681. * that target txpower.
  682. *
  683. *
  684. * 3) Determine (EEPROM) calibration subband for the target channel, by
  685. * comparing against first and last channels in each subband
  686. * (see struct iwl4965_eeprom_calib_subband_info).
  687. *
  688. *
  689. * 4) Linearly interpolate (EEPROM) factory calibration measurement sets,
  690. * referencing the 2 factory-measured (sample) channels within the subband.
  691. *
  692. * Interpolation is based on difference between target channel's frequency
  693. * and the sample channels' frequencies. Since channel numbers are based
  694. * on frequency (5 MHz between each channel number), this is equivalent
  695. * to interpolating based on channel number differences.
  696. *
  697. * Note that the sample channels may or may not be the channels at the
  698. * edges of the subband. The target channel may be "outside" of the
  699. * span of the sampled channels.
  700. *
  701. * Driver may choose the pair (for 2 Tx chains) of measurements (see
  702. * struct iwl4965_eeprom_calib_ch_info) for which the actual measured
  703. * txpower comes closest to the desired txpower. Usually, though,
  704. * the middle set of measurements is closest to the regulatory limits,
  705. * and is therefore a good choice for all txpower calculations (this
  706. * assumes that high accuracy is needed for maximizing legal txpower,
  707. * while lower txpower configurations do not need as much accuracy).
  708. *
  709. * Driver should interpolate both members of the chosen measurement pair,
  710. * i.e. for both Tx chains (radio transmitters), unless the driver knows
  711. * that only one of the chains will be used (e.g. only one tx antenna
  712. * connected, but this should be unusual). The rate scaling algorithm
  713. * switches antennas to find best performance, so both Tx chains will
  714. * be used (although only one at a time) even for non-MIMO transmissions.
  715. *
  716. * Driver should interpolate factory values for temperature, gain table
  717. * index, and actual power. The power amplifier detector values are
  718. * not used by the driver.
  719. *
  720. * Sanity check: If the target channel happens to be one of the sample
  721. * channels, the results should agree with the sample channel's
  722. * measurements!
  723. *
  724. *
  725. * 5) Find difference between desired txpower and (interpolated)
  726. * factory-measured txpower. Using (interpolated) factory gain table index
  727. * (shown elsewhere) as a starting point, adjust this index lower to
  728. * increase txpower, or higher to decrease txpower, until the target
  729. * txpower is reached. Each step in the gain table is 1/2 dB.
  730. *
  731. * For example, if factory measured txpower is 16 dBm, and target txpower
  732. * is 13 dBm, add 6 steps to the factory gain index to reduce txpower
  733. * by 3 dB.
  734. *
  735. *
  736. * 6) Find difference between current device temperature and (interpolated)
  737. * factory-measured temperature for sub-band. Factory values are in
  738. * degrees Celsius. To calculate current temperature, see comments for
  739. * "4965 temperature calculation".
  740. *
  741. * If current temperature is higher than factory temperature, driver must
  742. * increase gain (lower gain table index), and vice versa.
  743. *
  744. * Temperature affects gain differently for different channels:
  745. *
  746. * 2.4 GHz all channels: 3.5 degrees per half-dB step
  747. * 5 GHz channels 34-43: 4.5 degrees per half-dB step
  748. * 5 GHz channels >= 44: 4.0 degrees per half-dB step
  749. *
  750. * NOTE: Temperature can increase rapidly when transmitting, especially
  751. * with heavy traffic at high txpowers. Driver should update
  752. * temperature calculations often under these conditions to
  753. * maintain strong txpower in the face of rising temperature.
  754. *
  755. *
  756. * 7) Find difference between current power supply voltage indicator
  757. * (from "initialize alive") and factory-measured power supply voltage
  758. * indicator (EEPROM).
  759. *
  760. * If the current voltage is higher (indicator is lower) than factory
  761. * voltage, gain should be reduced (gain table index increased) by:
  762. *
  763. * (eeprom - current) / 7
  764. *
  765. * If the current voltage is lower (indicator is higher) than factory
  766. * voltage, gain should be increased (gain table index decreased) by:
  767. *
  768. * 2 * (current - eeprom) / 7
  769. *
  770. * If number of index steps in either direction turns out to be > 2,
  771. * something is wrong ... just use 0.
  772. *
  773. * NOTE: Voltage compensation is independent of band/channel.
  774. *
  775. * NOTE: "Initialize" uCode measures current voltage, which is assumed
  776. * to be constant after this initial measurement. Voltage
  777. * compensation for txpower (number of steps in gain table)
  778. * may be calculated once and used until the next uCode bootload.
  779. *
  780. *
  781. * 8) If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31),
  782. * adjust txpower for each transmitter chain, so txpower is balanced
  783. * between the two chains. There are 5 pairs of tx_atten[group][chain]
  784. * values in "initialize alive", one pair for each of 5 channel ranges:
  785. *
  786. * Group 0: 5 GHz channel 34-43
  787. * Group 1: 5 GHz channel 44-70
  788. * Group 2: 5 GHz channel 71-124
  789. * Group 3: 5 GHz channel 125-200
  790. * Group 4: 2.4 GHz all channels
  791. *
  792. * Add the tx_atten[group][chain] value to the index for the target chain.
  793. * The values are signed, but are in pairs of 0 and a non-negative number,
  794. * so as to reduce gain (if necessary) of the "hotter" channel. This
  795. * avoids any need to double-check for regulatory compliance after
  796. * this step.
  797. *
  798. *
  799. * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation
  800. * value to the index:
  801. *
  802. * Hardware rev B: 9 steps (4.5 dB)
  803. * Hardware rev C: 5 steps (2.5 dB)
  804. *
  805. * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
  806. * bits [3:2], 1 = B, 2 = C.
  807. *
  808. * NOTE: This compensation is in addition to any saturation backoff that
  809. * might have been applied in an earlier step.
  810. *
  811. *
  812. * 10) Select the gain table, based on band (2.4 vs 5 GHz).
  813. *
  814. * Limit the adjusted index to stay within the table!
  815. *
  816. *
  817. * 11) Read gain table entries for DSP and radio gain, place into appropriate
  818. * location(s) in command (struct iwl4965_txpowertable_cmd).
  819. */
  820. /* Limit range of txpower output target to be between these values */
  821. #define IWL_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */
  822. #define IWL_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */
  823. /**
  824. * When MIMO is used (2 transmitters operating simultaneously), driver should
  825. * limit each transmitter to deliver a max of 3 dB below the regulatory limit
  826. * for the device. That is, use half power for each transmitter, so total
  827. * txpower is within regulatory limits.
  828. *
  829. * The value "6" represents number of steps in gain table to reduce power 3 dB.
  830. * Each step is 1/2 dB.
  831. */
  832. #define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
  833. /**
  834. * CCK gain compensation.
  835. *
  836. * When calculating txpowers for CCK, after making sure that the target power
  837. * is within regulatory and saturation limits, driver must additionally
  838. * back off gain by adding these values to the gain table index.
  839. *
  840. * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
  841. * bits [3:2], 1 = B, 2 = C.
  842. */
  843. #define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
  844. #define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
  845. /*
  846. * 4965 power supply voltage compensation for txpower
  847. */
  848. #define TX_POWER_IWL_VOLTAGE_CODES_PER_03V (7)
  849. /**
  850. * Gain tables.
  851. *
  852. * The following tables contain pair of values for setting txpower, i.e.
  853. * gain settings for the output of the device's digital signal processor (DSP),
  854. * and for the analog gain structure of the transmitter.
  855. *
  856. * Each entry in the gain tables represents a step of 1/2 dB. Note that these
  857. * are *relative* steps, not indications of absolute output power. Output
  858. * power varies with temperature, voltage, and channel frequency, and also
  859. * requires consideration of average power (to satisfy regulatory constraints),
  860. * and peak power (to avoid distortion of the output signal).
  861. *
  862. * Each entry contains two values:
  863. * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
  864. * linear value that multiplies the output of the digital signal processor,
  865. * before being sent to the analog radio.
  866. * 2) Radio gain. This sets the analog gain of the radio Tx path.
  867. * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
  868. *
  869. * EEPROM contains factory calibration data for txpower. This maps actual
  870. * measured txpower levels to gain settings in the "well known" tables
  871. * below ("well-known" means here that both factory calibration *and* the
  872. * driver work with the same table).
  873. *
  874. * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table
  875. * has an extension (into negative indexes), in case the driver needs to
  876. * boost power setting for high device temperatures (higher than would be
  877. * present during factory calibration). A 5 Ghz EEPROM index of "40"
  878. * corresponds to the 49th entry in the table used by the driver.
  879. */
  880. #define MIN_TX_GAIN_INDEX (0) /* highest gain, lowest idx, 2.4 */
  881. #define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */
  882. /**
  883. * 2.4 GHz gain table
  884. *
  885. * Index Dsp gain Radio gain
  886. * 0 110 0x3f (highest gain)
  887. * 1 104 0x3f
  888. * 2 98 0x3f
  889. * 3 110 0x3e
  890. * 4 104 0x3e
  891. * 5 98 0x3e
  892. * 6 110 0x3d
  893. * 7 104 0x3d
  894. * 8 98 0x3d
  895. * 9 110 0x3c
  896. * 10 104 0x3c
  897. * 11 98 0x3c
  898. * 12 110 0x3b
  899. * 13 104 0x3b
  900. * 14 98 0x3b
  901. * 15 110 0x3a
  902. * 16 104 0x3a
  903. * 17 98 0x3a
  904. * 18 110 0x39
  905. * 19 104 0x39
  906. * 20 98 0x39
  907. * 21 110 0x38
  908. * 22 104 0x38
  909. * 23 98 0x38
  910. * 24 110 0x37
  911. * 25 104 0x37
  912. * 26 98 0x37
  913. * 27 110 0x36
  914. * 28 104 0x36
  915. * 29 98 0x36
  916. * 30 110 0x35
  917. * 31 104 0x35
  918. * 32 98 0x35
  919. * 33 110 0x34
  920. * 34 104 0x34
  921. * 35 98 0x34
  922. * 36 110 0x33
  923. * 37 104 0x33
  924. * 38 98 0x33
  925. * 39 110 0x32
  926. * 40 104 0x32
  927. * 41 98 0x32
  928. * 42 110 0x31
  929. * 43 104 0x31
  930. * 44 98 0x31
  931. * 45 110 0x30
  932. * 46 104 0x30
  933. * 47 98 0x30
  934. * 48 110 0x6
  935. * 49 104 0x6
  936. * 50 98 0x6
  937. * 51 110 0x5
  938. * 52 104 0x5
  939. * 53 98 0x5
  940. * 54 110 0x4
  941. * 55 104 0x4
  942. * 56 98 0x4
  943. * 57 110 0x3
  944. * 58 104 0x3
  945. * 59 98 0x3
  946. * 60 110 0x2
  947. * 61 104 0x2
  948. * 62 98 0x2
  949. * 63 110 0x1
  950. * 64 104 0x1
  951. * 65 98 0x1
  952. * 66 110 0x0
  953. * 67 104 0x0
  954. * 68 98 0x0
  955. * 69 97 0
  956. * 70 96 0
  957. * 71 95 0
  958. * 72 94 0
  959. * 73 93 0
  960. * 74 92 0
  961. * 75 91 0
  962. * 76 90 0
  963. * 77 89 0
  964. * 78 88 0
  965. * 79 87 0
  966. * 80 86 0
  967. * 81 85 0
  968. * 82 84 0
  969. * 83 83 0
  970. * 84 82 0
  971. * 85 81 0
  972. * 86 80 0
  973. * 87 79 0
  974. * 88 78 0
  975. * 89 77 0
  976. * 90 76 0
  977. * 91 75 0
  978. * 92 74 0
  979. * 93 73 0
  980. * 94 72 0
  981. * 95 71 0
  982. * 96 70 0
  983. * 97 69 0
  984. * 98 68 0
  985. */
  986. /**
  987. * 5 GHz gain table
  988. *
  989. * Index Dsp gain Radio gain
  990. * -9 123 0x3F (highest gain)
  991. * -8 117 0x3F
  992. * -7 110 0x3F
  993. * -6 104 0x3F
  994. * -5 98 0x3F
  995. * -4 110 0x3E
  996. * -3 104 0x3E
  997. * -2 98 0x3E
  998. * -1 110 0x3D
  999. * 0 104 0x3D
  1000. * 1 98 0x3D
  1001. * 2 110 0x3C
  1002. * 3 104 0x3C
  1003. * 4 98 0x3C
  1004. * 5 110 0x3B
  1005. * 6 104 0x3B
  1006. * 7 98 0x3B
  1007. * 8 110 0x3A
  1008. * 9 104 0x3A
  1009. * 10 98 0x3A
  1010. * 11 110 0x39
  1011. * 12 104 0x39
  1012. * 13 98 0x39
  1013. * 14 110 0x38
  1014. * 15 104 0x38
  1015. * 16 98 0x38
  1016. * 17 110 0x37
  1017. * 18 104 0x37
  1018. * 19 98 0x37
  1019. * 20 110 0x36
  1020. * 21 104 0x36
  1021. * 22 98 0x36
  1022. * 23 110 0x35
  1023. * 24 104 0x35
  1024. * 25 98 0x35
  1025. * 26 110 0x34
  1026. * 27 104 0x34
  1027. * 28 98 0x34
  1028. * 29 110 0x33
  1029. * 30 104 0x33
  1030. * 31 98 0x33
  1031. * 32 110 0x32
  1032. * 33 104 0x32
  1033. * 34 98 0x32
  1034. * 35 110 0x31
  1035. * 36 104 0x31
  1036. * 37 98 0x31
  1037. * 38 110 0x30
  1038. * 39 104 0x30
  1039. * 40 98 0x30
  1040. * 41 110 0x25
  1041. * 42 104 0x25
  1042. * 43 98 0x25
  1043. * 44 110 0x24
  1044. * 45 104 0x24
  1045. * 46 98 0x24
  1046. * 47 110 0x23
  1047. * 48 104 0x23
  1048. * 49 98 0x23
  1049. * 50 110 0x22
  1050. * 51 104 0x18
  1051. * 52 98 0x18
  1052. * 53 110 0x17
  1053. * 54 104 0x17
  1054. * 55 98 0x17
  1055. * 56 110 0x16
  1056. * 57 104 0x16
  1057. * 58 98 0x16
  1058. * 59 110 0x15
  1059. * 60 104 0x15
  1060. * 61 98 0x15
  1061. * 62 110 0x14
  1062. * 63 104 0x14
  1063. * 64 98 0x14
  1064. * 65 110 0x13
  1065. * 66 104 0x13
  1066. * 67 98 0x13
  1067. * 68 110 0x12
  1068. * 69 104 0x08
  1069. * 70 98 0x08
  1070. * 71 110 0x07
  1071. * 72 104 0x07
  1072. * 73 98 0x07
  1073. * 74 110 0x06
  1074. * 75 104 0x06
  1075. * 76 98 0x06
  1076. * 77 110 0x05
  1077. * 78 104 0x05
  1078. * 79 98 0x05
  1079. * 80 110 0x04
  1080. * 81 104 0x04
  1081. * 82 98 0x04
  1082. * 83 110 0x03
  1083. * 84 104 0x03
  1084. * 85 98 0x03
  1085. * 86 110 0x02
  1086. * 87 104 0x02
  1087. * 88 98 0x02
  1088. * 89 110 0x01
  1089. * 90 104 0x01
  1090. * 91 98 0x01
  1091. * 92 110 0x00
  1092. * 93 104 0x00
  1093. * 94 98 0x00
  1094. * 95 93 0x00
  1095. * 96 88 0x00
  1096. * 97 83 0x00
  1097. * 98 78 0x00
  1098. */
  1099. /**
  1100. * Sanity checks and default values for EEPROM regulatory levels.
  1101. * If EEPROM values fall outside MIN/MAX range, use default values.
  1102. *
  1103. * Regulatory limits refer to the maximum average txpower allowed by
  1104. * regulatory agencies in the geographies in which the device is meant
  1105. * to be operated. These limits are SKU-specific (i.e. geography-specific),
  1106. * and channel-specific; each channel has an individual regulatory limit
  1107. * listed in the EEPROM.
  1108. *
  1109. * Units are in half-dBm (i.e. "34" means 17 dBm).
  1110. */
  1111. #define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34)
  1112. #define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34)
  1113. #define IWL_TX_POWER_REGULATORY_MIN (0)
  1114. #define IWL_TX_POWER_REGULATORY_MAX (34)
  1115. /**
  1116. * Sanity checks and default values for EEPROM saturation levels.
  1117. * If EEPROM values fall outside MIN/MAX range, use default values.
  1118. *
  1119. * Saturation is the highest level that the output power amplifier can produce
  1120. * without significant clipping distortion. This is a "peak" power level.
  1121. * Different types of modulation (i.e. various "rates", and OFDM vs. CCK)
  1122. * require differing amounts of backoff, relative to their average power output,
  1123. * in order to avoid clipping distortion.
  1124. *
  1125. * Driver must make sure that it is violating neither the saturation limit,
  1126. * nor the regulatory limit, when calculating Tx power settings for various
  1127. * rates.
  1128. *
  1129. * Units are in half-dBm (i.e. "38" means 19 dBm).
  1130. */
  1131. #define IWL_TX_POWER_DEFAULT_SATURATION_24 (38)
  1132. #define IWL_TX_POWER_DEFAULT_SATURATION_52 (38)
  1133. #define IWL_TX_POWER_SATURATION_MIN (20)
  1134. #define IWL_TX_POWER_SATURATION_MAX (50)
  1135. /**
  1136. * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance)
  1137. * and thermal Txpower calibration.
  1138. *
  1139. * When calculating txpower, driver must compensate for current device
  1140. * temperature; higher temperature requires higher gain. Driver must calculate
  1141. * current temperature (see "4965 temperature calculation"), then compare vs.
  1142. * factory calibration temperature in EEPROM; if current temperature is higher
  1143. * than factory temperature, driver must *increase* gain by proportions shown
  1144. * in table below. If current temperature is lower than factory, driver must
  1145. * *decrease* gain.
  1146. *
  1147. * Different frequency ranges require different compensation, as shown below.
  1148. */
  1149. /* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */
  1150. #define CALIB_IWL_TX_ATTEN_GR1_FCH 34
  1151. #define CALIB_IWL_TX_ATTEN_GR1_LCH 43
  1152. /* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */
  1153. #define CALIB_IWL_TX_ATTEN_GR2_FCH 44
  1154. #define CALIB_IWL_TX_ATTEN_GR2_LCH 70
  1155. /* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */
  1156. #define CALIB_IWL_TX_ATTEN_GR3_FCH 71
  1157. #define CALIB_IWL_TX_ATTEN_GR3_LCH 124
  1158. /* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */
  1159. #define CALIB_IWL_TX_ATTEN_GR4_FCH 125
  1160. #define CALIB_IWL_TX_ATTEN_GR4_LCH 200
  1161. /* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */
  1162. #define CALIB_IWL_TX_ATTEN_GR5_FCH 1
  1163. #define CALIB_IWL_TX_ATTEN_GR5_LCH 20
  1164. enum {
  1165. CALIB_CH_GROUP_1 = 0,
  1166. CALIB_CH_GROUP_2 = 1,
  1167. CALIB_CH_GROUP_3 = 2,
  1168. CALIB_CH_GROUP_4 = 3,
  1169. CALIB_CH_GROUP_5 = 4,
  1170. CALIB_CH_GROUP_MAX
  1171. };
  1172. /********************* END TXPOWER *****************************************/
  1173. /* Flow Handler Definitions */
  1174. /**********************/
  1175. /* Addresses */
  1176. /**********************/
  1177. #define FH_MEM_LOWER_BOUND (0x1000)
  1178. #define FH_MEM_UPPER_BOUND (0x1EF0)
  1179. #define IWL_FH_REGS_LOWER_BOUND (0x1000)
  1180. #define IWL_FH_REGS_UPPER_BOUND (0x2000)
  1181. #define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
  1182. /* CBBC Area - Circular buffers base address cache pointers table */
  1183. #define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
  1184. #define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
  1185. /* queues 0 - 15 */
  1186. #define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
  1187. /* RSCSR Area */
  1188. #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
  1189. #define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  1190. #define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
  1191. #define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
  1192. #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
  1193. #define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
  1194. /* RCSR Area - Registers address map */
  1195. #define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  1196. #define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0)
  1197. #define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND)
  1198. #define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0)
  1199. /* RSSR Area - Rx shared ctrl & status registers */
  1200. #define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
  1201. #define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
  1202. #define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
  1203. #define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
  1204. #define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
  1205. /* TCSR */
  1206. #define IWL_FH_TCSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xD00)
  1207. #define IWL_FH_TCSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xE60)
  1208. #define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
  1209. (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
  1210. /* TSSR Area - Tx shared status registers */
  1211. /* TSSR */
  1212. #define IWL_FH_TSSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEA0)
  1213. #define IWL_FH_TSSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEC0)
  1214. #define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010)
  1215. #define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \
  1216. ((1 << (_chnl)) << 24)
  1217. #define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
  1218. ((1 << (_chnl)) << 16)
  1219. #define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
  1220. (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
  1221. IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
  1222. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
  1223. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  1224. /* RCSR: channel 0 rx_config register defines */
  1225. #define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20)
  1226. #define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
  1227. #define IWL_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
  1228. /* RCSR channel 0 config register values */
  1229. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
  1230. #define SCD_WIN_SIZE 64
  1231. #define SCD_FRAME_LIMIT 64
  1232. /* SRAM structures */
  1233. #define SCD_CONTEXT_DATA_OFFSET 0x380
  1234. #define SCD_TX_STTS_BITMAP_OFFSET 0x400
  1235. #define SCD_TRANSLATE_TBL_OFFSET 0x500
  1236. #define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
  1237. #define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
  1238. ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
  1239. #define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
  1240. ((1<<(hi))|((1<<(hi))-(1<<(lo))))
  1241. #define SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
  1242. #define SCD_QUEUE_STTS_REG_POS_TXF (1)
  1243. #define SCD_QUEUE_STTS_REG_POS_WSL (5)
  1244. #define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
  1245. #define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
  1246. #define SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
  1247. #define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
  1248. #define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
  1249. #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
  1250. #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
  1251. #define CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R (0x00000010)
  1252. #define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00)
  1253. #define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100)
  1254. #define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200)
  1255. #define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
  1256. static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags)
  1257. {
  1258. return le32_to_cpu(rate_n_flags) & 0xFF;
  1259. }
  1260. static inline u16 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags)
  1261. {
  1262. return le32_to_cpu(rate_n_flags) & 0xFFFF;
  1263. }
  1264. static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
  1265. {
  1266. return cpu_to_le32(flags|(u16)rate);
  1267. }
  1268. struct iwl4965_tfd_frame_data {
  1269. __le32 tb1_addr;
  1270. __le32 val1;
  1271. /* __le32 ptb1_32_35:4; */
  1272. #define IWL_tb1_addr_hi_POS 0
  1273. #define IWL_tb1_addr_hi_LEN 4
  1274. #define IWL_tb1_addr_hi_SYM val1
  1275. /* __le32 tb_len1:12; */
  1276. #define IWL_tb1_len_POS 4
  1277. #define IWL_tb1_len_LEN 12
  1278. #define IWL_tb1_len_SYM val1
  1279. /* __le32 ptb2_0_15:16; */
  1280. #define IWL_tb2_addr_lo16_POS 16
  1281. #define IWL_tb2_addr_lo16_LEN 16
  1282. #define IWL_tb2_addr_lo16_SYM val1
  1283. __le32 val2;
  1284. /* __le32 ptb2_16_35:20; */
  1285. #define IWL_tb2_addr_hi20_POS 0
  1286. #define IWL_tb2_addr_hi20_LEN 20
  1287. #define IWL_tb2_addr_hi20_SYM val2
  1288. /* __le32 tb_len2:12; */
  1289. #define IWL_tb2_len_POS 20
  1290. #define IWL_tb2_len_LEN 12
  1291. #define IWL_tb2_len_SYM val2
  1292. } __attribute__ ((packed));
  1293. struct iwl4965_tfd_frame {
  1294. __le32 val0;
  1295. /* __le32 rsvd1:24; */
  1296. /* __le32 num_tbs:5; */
  1297. #define IWL_num_tbs_POS 24
  1298. #define IWL_num_tbs_LEN 5
  1299. #define IWL_num_tbs_SYM val0
  1300. /* __le32 rsvd2:1; */
  1301. /* __le32 padding:2; */
  1302. struct iwl4965_tfd_frame_data pa[10];
  1303. __le32 reserved;
  1304. } __attribute__ ((packed));
  1305. #define IWL4965_MAX_WIN_SIZE 64
  1306. #define IWL4965_QUEUE_SIZE 256
  1307. #define IWL4965_NUM_FIFOS 7
  1308. #define IWL_MAX_NUM_QUEUES 16
  1309. struct iwl4965_queue_byte_cnt_entry {
  1310. __le16 val;
  1311. /* __le16 byte_cnt:12; */
  1312. #define IWL_byte_cnt_POS 0
  1313. #define IWL_byte_cnt_LEN 12
  1314. #define IWL_byte_cnt_SYM val
  1315. /* __le16 rsvd:4; */
  1316. } __attribute__ ((packed));
  1317. struct iwl4965_sched_queue_byte_cnt_tbl {
  1318. struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE +
  1319. IWL4965_MAX_WIN_SIZE];
  1320. u8 dont_care[1024 -
  1321. (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) *
  1322. sizeof(__le16)];
  1323. } __attribute__ ((packed));
  1324. /* Base physical address of iwl4965_shared is provided to KDR_SCD_DRAM_BASE_ADDR
  1325. * and &iwl4965_shared.val0 is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG */
  1326. struct iwl4965_shared {
  1327. struct iwl4965_sched_queue_byte_cnt_tbl
  1328. queues_byte_cnt_tbls[IWL_MAX_NUM_QUEUES];
  1329. __le32 val0;
  1330. /* __le32 rb_closed_stts_rb_num:12; */
  1331. #define IWL_rb_closed_stts_rb_num_POS 0
  1332. #define IWL_rb_closed_stts_rb_num_LEN 12
  1333. #define IWL_rb_closed_stts_rb_num_SYM val0
  1334. /* __le32 rsrv1:4; */
  1335. /* __le32 rb_closed_stts_rx_frame_num:12; */
  1336. #define IWL_rb_closed_stts_rx_frame_num_POS 16
  1337. #define IWL_rb_closed_stts_rx_frame_num_LEN 12
  1338. #define IWL_rb_closed_stts_rx_frame_num_SYM val0
  1339. /* __le32 rsrv2:4; */
  1340. __le32 val1;
  1341. /* __le32 frame_finished_stts_rb_num:12; */
  1342. #define IWL_frame_finished_stts_rb_num_POS 0
  1343. #define IWL_frame_finished_stts_rb_num_LEN 12
  1344. #define IWL_frame_finished_stts_rb_num_SYM val1
  1345. /* __le32 rsrv3:4; */
  1346. /* __le32 frame_finished_stts_rx_frame_num:12; */
  1347. #define IWL_frame_finished_stts_rx_frame_num_POS 16
  1348. #define IWL_frame_finished_stts_rx_frame_num_LEN 12
  1349. #define IWL_frame_finished_stts_rx_frame_num_SYM val1
  1350. /* __le32 rsrv4:4; */
  1351. __le32 padding1; /* so that allocation will be aligned to 16B */
  1352. __le32 padding2;
  1353. } __attribute__ ((packed));
  1354. #endif /* __iwl4965_4965_hw_h__ */