iwl-4965-hw.h 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673
  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. /****************************/
  1174. /* Flow Handler Definitions */
  1175. /****************************/
  1176. /**
  1177. * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
  1178. * Addresses are offsets from device's PCI hardware base address.
  1179. */
  1180. #define FH_MEM_LOWER_BOUND (0x1000)
  1181. #define FH_MEM_UPPER_BOUND (0x1EF0)
  1182. /**
  1183. * Keep-Warm (KW) buffer base address.
  1184. *
  1185. * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
  1186. * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
  1187. * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host
  1188. * from going into a power-savings mode that would cause higher DRAM latency,
  1189. * and possible data over/under-runs, before all Tx/Rx is complete.
  1190. *
  1191. * Driver loads IWL_FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
  1192. * of the buffer, which must be 4K aligned. Once this is set up, the 4965
  1193. * automatically invokes keep-warm accesses when normal accesses might not
  1194. * be sufficient to maintain fast DRAM response.
  1195. *
  1196. * Bit fields:
  1197. * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned
  1198. */
  1199. #define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
  1200. /**
  1201. * TFD Circular Buffers Base (CBBC) addresses
  1202. *
  1203. * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
  1204. * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
  1205. * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04
  1206. * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
  1207. * aligned (address bits 0-7 must be 0).
  1208. *
  1209. * Bit fields in each pointer register:
  1210. * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
  1211. */
  1212. #define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
  1213. #define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
  1214. /* Find TFD CB base pointer for given queue (range 0-15). */
  1215. #define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
  1216. /**
  1217. * Rx SRAM Control and Status Registers (RSCSR)
  1218. *
  1219. * These registers provide handshake between driver and 4965 for the Rx queue
  1220. * (this queue handles *all* command responses, notifications, Rx data, etc.
  1221. * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx
  1222. * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can
  1223. * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
  1224. * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
  1225. * mapping between RBDs and RBs.
  1226. *
  1227. * Driver must allocate host DRAM memory for the following, and set the
  1228. * physical address of each into 4965 registers:
  1229. *
  1230. * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
  1231. * entries (although any power of 2, up to 4096, is selectable by driver).
  1232. * Each entry (1 dword) points to a receive buffer (RB) of consistent size
  1233. * (typically 4K, although 8K or 16K are also selectable by driver).
  1234. * Driver sets up RB size and number of RBDs in the CB via Rx config
  1235. * register FH_MEM_RCSR_CHNL0_CONFIG_REG.
  1236. *
  1237. * Bit fields within one RBD:
  1238. * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned
  1239. *
  1240. * Driver sets physical address [35:8] of base of RBD circular buffer
  1241. * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
  1242. *
  1243. * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
  1244. * (RBs) have been filled, via a "write pointer", actually the index of
  1245. * the RB's corresponding RBD within the circular buffer. Driver sets
  1246. * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
  1247. *
  1248. * Bit fields in lower dword of Rx status buffer (upper dword not used
  1249. * by driver; see struct iwl4965_shared, val0):
  1250. * 31-12: Not used by driver
  1251. * 11- 0: Index of last filled Rx buffer descriptor
  1252. * (4965 writes, driver reads this value)
  1253. *
  1254. * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
  1255. * enter pointers to these RBs into contiguous RBD circular buffer entries,
  1256. * and update the 4965's "write" index register, FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
  1257. *
  1258. * This "write" index corresponds to the *next* RBD that the driver will make
  1259. * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
  1260. * the circular buffer. This value should initially be 0 (before preparing any
  1261. * RBs), should be 8 after preparing the first 8 RBs (for example), and must
  1262. * wrap back to 0 at the end of the circular buffer (but don't wrap before
  1263. * "read" index has advanced past 1! See below).
  1264. * NOTE: 4965 EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
  1265. *
  1266. * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
  1267. * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
  1268. * to tell the driver the index of the latest filled RBD. The driver must
  1269. * read this "read" index from DRAM after receiving an Rx interrupt from 4965.
  1270. *
  1271. * The driver must also internally keep track of a third index, which is the
  1272. * next RBD to process. When receiving an Rx interrupt, driver should process
  1273. * all filled but unprocessed RBs up to, but not including, the RB
  1274. * corresponding to the "read" index. For example, if "read" index becomes "1",
  1275. * driver may process the RB pointed to by RBD 0. Depending on volume of
  1276. * traffic, there may be many RBs to process.
  1277. *
  1278. * If read index == write index, 4965 thinks there is no room to put new data.
  1279. * Due to this, the maximum number of filled RBs is 255, instead of 256. To
  1280. * be safe, make sure that there is a gap of at least 2 RBDs between "write"
  1281. * and "read" indexes; that is, make sure that there are no more than 254
  1282. * buffers waiting to be filled.
  1283. */
  1284. #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
  1285. #define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  1286. #define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
  1287. /**
  1288. * Physical base address of 8-byte Rx Status buffer.
  1289. * Bit fields:
  1290. * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
  1291. */
  1292. #define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
  1293. /**
  1294. * Physical base address of Rx Buffer Descriptor Circular Buffer.
  1295. * Bit fields:
  1296. * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned.
  1297. */
  1298. #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
  1299. /**
  1300. * Rx write pointer (index, really!).
  1301. * Bit fields:
  1302. * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1.
  1303. * NOTE: For 256-entry circular buffer, use only bits [7:0].
  1304. */
  1305. #define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
  1306. /**
  1307. * Rx Config/Status Registers (RCSR)
  1308. * Rx Config Reg for channel 0 (only channel used)
  1309. *
  1310. * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
  1311. * normal operation (see bit fields).
  1312. *
  1313. * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
  1314. * Driver should poll FH_MEM_RSSR_RX_STATUS_REG for
  1315. * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
  1316. *
  1317. * Bit fields:
  1318. * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
  1319. * '10' operate normally
  1320. * 29-24: reserved
  1321. * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
  1322. * min "5" for 32 RBDs, max "12" for 4096 RBDs.
  1323. * 19-18: reserved
  1324. * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
  1325. * '10' 12K, '11' 16K.
  1326. * 15-14: reserved
  1327. * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
  1328. * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
  1329. * typical value 0x10 (about 1/2 msec)
  1330. * 3- 0: reserved
  1331. */
  1332. #define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  1333. #define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0)
  1334. #define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND)
  1335. #define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0)
  1336. #define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
  1337. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
  1338. #define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
  1339. #define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
  1340. #define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
  1341. #define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
  1342. #define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20)
  1343. #define FH_RCSR_RX_CONFIG_RB_SIZE_BITSHIFT (16)
  1344. #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
  1345. #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
  1346. #define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
  1347. #define IWL_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
  1348. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
  1349. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
  1350. /**
  1351. * Rx Shared Status Registers (RSSR)
  1352. *
  1353. * After stopping Rx DMA channel (writing 0 to FH_MEM_RCSR_CHNL0_CONFIG_REG),
  1354. * driver must poll FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
  1355. *
  1356. * Bit fields:
  1357. * 24: 1 = Channel 0 is idle
  1358. *
  1359. * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV contain
  1360. * default values that should not be altered by the driver.
  1361. */
  1362. #define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
  1363. #define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
  1364. #define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
  1365. #define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
  1366. #define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
  1367. #define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
  1368. /* TCSR */
  1369. #define IWL_FH_TCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
  1370. #define IWL_FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60)
  1371. #define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
  1372. (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
  1373. /* TSSR Area - Tx shared status registers */
  1374. /* TSSR */
  1375. #define IWL_FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0)
  1376. #define IWL_FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0)
  1377. #define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010)
  1378. #define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \
  1379. ((1 << (_chnl)) << 24)
  1380. #define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
  1381. ((1 << (_chnl)) << 16)
  1382. #define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
  1383. (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
  1384. IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
  1385. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
  1386. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  1387. #define SCD_WIN_SIZE 64
  1388. #define SCD_FRAME_LIMIT 64
  1389. /* SRAM structures */
  1390. #define SCD_CONTEXT_DATA_OFFSET 0x380
  1391. #define SCD_TX_STTS_BITMAP_OFFSET 0x400
  1392. #define SCD_TRANSLATE_TBL_OFFSET 0x500
  1393. #define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
  1394. #define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
  1395. ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
  1396. #define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
  1397. ((1<<(hi))|((1<<(hi))-(1<<(lo))))
  1398. #define SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
  1399. #define SCD_QUEUE_STTS_REG_POS_TXF (1)
  1400. #define SCD_QUEUE_STTS_REG_POS_WSL (5)
  1401. #define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
  1402. #define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
  1403. #define SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
  1404. #define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
  1405. #define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
  1406. #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
  1407. #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
  1408. #define CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R (0x00000010)
  1409. #define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00)
  1410. #define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100)
  1411. #define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200)
  1412. #define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
  1413. static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags)
  1414. {
  1415. return le32_to_cpu(rate_n_flags) & 0xFF;
  1416. }
  1417. static inline u16 iwl4965_hw_get_rate_n_flags(__le32 rate_n_flags)
  1418. {
  1419. return le32_to_cpu(rate_n_flags) & 0xFFFF;
  1420. }
  1421. static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u16 flags)
  1422. {
  1423. return cpu_to_le32(flags|(u16)rate);
  1424. }
  1425. struct iwl4965_tfd_frame_data {
  1426. __le32 tb1_addr;
  1427. __le32 val1;
  1428. /* __le32 ptb1_32_35:4; */
  1429. #define IWL_tb1_addr_hi_POS 0
  1430. #define IWL_tb1_addr_hi_LEN 4
  1431. #define IWL_tb1_addr_hi_SYM val1
  1432. /* __le32 tb_len1:12; */
  1433. #define IWL_tb1_len_POS 4
  1434. #define IWL_tb1_len_LEN 12
  1435. #define IWL_tb1_len_SYM val1
  1436. /* __le32 ptb2_0_15:16; */
  1437. #define IWL_tb2_addr_lo16_POS 16
  1438. #define IWL_tb2_addr_lo16_LEN 16
  1439. #define IWL_tb2_addr_lo16_SYM val1
  1440. __le32 val2;
  1441. /* __le32 ptb2_16_35:20; */
  1442. #define IWL_tb2_addr_hi20_POS 0
  1443. #define IWL_tb2_addr_hi20_LEN 20
  1444. #define IWL_tb2_addr_hi20_SYM val2
  1445. /* __le32 tb_len2:12; */
  1446. #define IWL_tb2_len_POS 20
  1447. #define IWL_tb2_len_LEN 12
  1448. #define IWL_tb2_len_SYM val2
  1449. } __attribute__ ((packed));
  1450. struct iwl4965_tfd_frame {
  1451. __le32 val0;
  1452. /* __le32 rsvd1:24; */
  1453. /* __le32 num_tbs:5; */
  1454. #define IWL_num_tbs_POS 24
  1455. #define IWL_num_tbs_LEN 5
  1456. #define IWL_num_tbs_SYM val0
  1457. /* __le32 rsvd2:1; */
  1458. /* __le32 padding:2; */
  1459. struct iwl4965_tfd_frame_data pa[10];
  1460. __le32 reserved;
  1461. } __attribute__ ((packed));
  1462. #define IWL4965_MAX_WIN_SIZE 64
  1463. #define IWL4965_QUEUE_SIZE 256
  1464. #define IWL4965_NUM_FIFOS 7
  1465. #define IWL_MAX_NUM_QUEUES 16
  1466. struct iwl4965_queue_byte_cnt_entry {
  1467. __le16 val;
  1468. /* __le16 byte_cnt:12; */
  1469. #define IWL_byte_cnt_POS 0
  1470. #define IWL_byte_cnt_LEN 12
  1471. #define IWL_byte_cnt_SYM val
  1472. /* __le16 rsvd:4; */
  1473. } __attribute__ ((packed));
  1474. struct iwl4965_sched_queue_byte_cnt_tbl {
  1475. struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE +
  1476. IWL4965_MAX_WIN_SIZE];
  1477. u8 dont_care[1024 -
  1478. (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) *
  1479. sizeof(__le16)];
  1480. } __attribute__ ((packed));
  1481. /* Base physical address of iwl4965_shared is provided to KDR_SCD_DRAM_BASE_ADDR
  1482. * and &iwl4965_shared.val0 is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG */
  1483. struct iwl4965_shared {
  1484. struct iwl4965_sched_queue_byte_cnt_tbl
  1485. queues_byte_cnt_tbls[IWL_MAX_NUM_QUEUES];
  1486. __le32 val0;
  1487. /* __le32 rb_closed_stts_rb_num:12; */
  1488. #define IWL_rb_closed_stts_rb_num_POS 0
  1489. #define IWL_rb_closed_stts_rb_num_LEN 12
  1490. #define IWL_rb_closed_stts_rb_num_SYM val0
  1491. /* __le32 rsrv1:4; */
  1492. /* __le32 rb_closed_stts_rx_frame_num:12; */
  1493. #define IWL_rb_closed_stts_rx_frame_num_POS 16
  1494. #define IWL_rb_closed_stts_rx_frame_num_LEN 12
  1495. #define IWL_rb_closed_stts_rx_frame_num_SYM val0
  1496. /* __le32 rsrv2:4; */
  1497. __le32 val1;
  1498. /* __le32 frame_finished_stts_rb_num:12; */
  1499. #define IWL_frame_finished_stts_rb_num_POS 0
  1500. #define IWL_frame_finished_stts_rb_num_LEN 12
  1501. #define IWL_frame_finished_stts_rb_num_SYM val1
  1502. /* __le32 rsrv3:4; */
  1503. /* __le32 frame_finished_stts_rx_frame_num:12; */
  1504. #define IWL_frame_finished_stts_rx_frame_num_POS 16
  1505. #define IWL_frame_finished_stts_rx_frame_num_LEN 12
  1506. #define IWL_frame_finished_stts_rx_frame_num_SYM val1
  1507. /* __le32 rsrv4:4; */
  1508. __le32 padding1; /* so that allocation will be aligned to 16B */
  1509. __le32 padding2;
  1510. } __attribute__ ((packed));
  1511. #endif /* __iwl4965_4965_hw_h__ */