iwl-3945-hw.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  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. #ifndef __iwl_3945_hw__
  64. #define __iwl_3945_hw__
  65. /* uCode queue management definitions */
  66. #define IWL_CMD_QUEUE_NUM 4
  67. #define IWL_CMD_FIFO_NUM 4
  68. #define IWL_BACK_QUEUE_FIRST_ID 7
  69. /* Tx rates */
  70. #define IWL_CCK_RATES 4
  71. #define IWL_OFDM_RATES 8
  72. #define IWL_HT_RATES 0
  73. #define IWL_MAX_RATES (IWL_CCK_RATES+IWL_OFDM_RATES+IWL_HT_RATES)
  74. /* Time constants */
  75. #define SHORT_SLOT_TIME 9
  76. #define LONG_SLOT_TIME 20
  77. /* RSSI to dBm */
  78. #define IWL_RSSI_OFFSET 95
  79. /*
  80. * This file defines EEPROM related constants, enums, and inline functions.
  81. *
  82. */
  83. #define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
  84. #define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
  85. /* EEPROM field values */
  86. #define ANTENNA_SWITCH_NORMAL 0
  87. #define ANTENNA_SWITCH_INVERSE 1
  88. enum {
  89. EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
  90. EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
  91. /* Bit 2 Reserved */
  92. EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
  93. EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
  94. EEPROM_CHANNEL_WIDE = (1 << 5),
  95. EEPROM_CHANNEL_NARROW = (1 << 6),
  96. EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
  97. };
  98. /* EEPROM field lengths */
  99. #define EEPROM_BOARD_PBA_NUMBER_LENGTH 11
  100. /* EEPROM field lengths */
  101. #define EEPROM_BOARD_PBA_NUMBER_LENGTH 11
  102. #define EEPROM_REGULATORY_SKU_ID_LENGTH 4
  103. #define EEPROM_REGULATORY_BAND1_CHANNELS_LENGTH 14
  104. #define EEPROM_REGULATORY_BAND2_CHANNELS_LENGTH 13
  105. #define EEPROM_REGULATORY_BAND3_CHANNELS_LENGTH 12
  106. #define EEPROM_REGULATORY_BAND4_CHANNELS_LENGTH 11
  107. #define EEPROM_REGULATORY_BAND5_CHANNELS_LENGTH 6
  108. #define EEPROM_REGULATORY_CHANNELS_LENGTH ( \
  109. EEPROM_REGULATORY_BAND1_CHANNELS_LENGTH + \
  110. EEPROM_REGULATORY_BAND2_CHANNELS_LENGTH + \
  111. EEPROM_REGULATORY_BAND3_CHANNELS_LENGTH + \
  112. EEPROM_REGULATORY_BAND4_CHANNELS_LENGTH + \
  113. EEPROM_REGULATORY_BAND5_CHANNELS_LENGTH)
  114. #define EEPROM_REGULATORY_NUMBER_OF_BANDS 5
  115. /* SKU Capabilities */
  116. #define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
  117. #define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
  118. #define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
  119. /* *regulatory* channel data from eeprom, one for each channel */
  120. struct iwl_eeprom_channel {
  121. u8 flags; /* flags copied from EEPROM */
  122. s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
  123. } __attribute__ ((packed));
  124. /*
  125. * Mapping of a Tx power level, at factory calibration temperature,
  126. * to a radio/DSP gain table index.
  127. * One for each of 5 "sample" power levels in each band.
  128. * v_det is measured at the factory, using the 3945's built-in power amplifier
  129. * (PA) output voltage detector. This same detector is used during Tx of
  130. * long packets in normal operation to provide feedback as to proper output
  131. * level.
  132. * Data copied from EEPROM.
  133. */
  134. struct iwl_eeprom_txpower_sample {
  135. u8 gain_index; /* index into power (gain) setup table ... */
  136. s8 power; /* ... for this pwr level for this chnl group */
  137. u16 v_det; /* PA output voltage */
  138. } __attribute__ ((packed));
  139. /*
  140. * Mappings of Tx power levels -> nominal radio/DSP gain table indexes.
  141. * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
  142. * Tx power setup code interpolates between the 5 "sample" power levels
  143. * to determine the nominal setup for a requested power level.
  144. * Data copied from EEPROM.
  145. * DO NOT ALTER THIS STRUCTURE!!!
  146. */
  147. struct iwl_eeprom_txpower_group {
  148. struct iwl_eeprom_txpower_sample samples[5]; /* 5 power levels */
  149. s32 a, b, c, d, e; /* coefficients for voltage->power
  150. * formula (signed) */
  151. s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
  152. * frequency (signed) */
  153. s8 saturation_power; /* highest power possible by h/w in this
  154. * band */
  155. u8 group_channel; /* "representative" channel # in this band */
  156. s16 temperature; /* h/w temperature at factory calib this band
  157. * (signed) */
  158. } __attribute__ ((packed));
  159. /*
  160. * Temperature-based Tx-power compensation data, not band-specific.
  161. * These coefficients are use to modify a/b/c/d/e coeffs based on
  162. * difference between current temperature and factory calib temperature.
  163. * Data copied from EEPROM.
  164. */
  165. struct iwl_eeprom_temperature_corr {
  166. u32 Ta;
  167. u32 Tb;
  168. u32 Tc;
  169. u32 Td;
  170. u32 Te;
  171. } __attribute__ ((packed));
  172. struct iwl_eeprom {
  173. u8 reserved0[16];
  174. #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
  175. u16 device_id; /* abs.ofs: 16 */
  176. u8 reserved1[2];
  177. #define EEPROM_PMC (2*0x0A) /* 2 bytes */
  178. u16 pmc; /* abs.ofs: 20 */
  179. u8 reserved2[20];
  180. #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
  181. u8 mac_address[6]; /* abs.ofs: 42 */
  182. u8 reserved3[58];
  183. #define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
  184. u16 board_revision; /* abs.ofs: 106 */
  185. u8 reserved4[11];
  186. #define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
  187. u8 board_pba_number[9]; /* abs.ofs: 119 */
  188. u8 reserved5[8];
  189. #define EEPROM_VERSION (2*0x44) /* 2 bytes */
  190. u16 version; /* abs.ofs: 136 */
  191. #define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
  192. u8 sku_cap; /* abs.ofs: 138 */
  193. #define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
  194. u8 leds_mode; /* abs.ofs: 139 */
  195. #define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
  196. u16 oem_mode;
  197. #define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
  198. u16 wowlan_mode; /* abs.ofs: 142 */
  199. #define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
  200. u16 leds_time_interval; /* abs.ofs: 144 */
  201. #define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
  202. u8 leds_off_time; /* abs.ofs: 146 */
  203. #define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
  204. u8 leds_on_time; /* abs.ofs: 147 */
  205. #define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
  206. u8 almgor_m_version; /* abs.ofs: 148 */
  207. #define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
  208. u8 antenna_switch_type; /* abs.ofs: 149 */
  209. u8 reserved6[42];
  210. #define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
  211. u8 sku_id[4]; /* abs.ofs: 192 */
  212. #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
  213. u16 band_1_count; /* abs.ofs: 196 */
  214. #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
  215. struct iwl_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
  216. #define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
  217. u16 band_2_count; /* abs.ofs: 226 */
  218. #define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
  219. struct iwl_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
  220. #define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
  221. u16 band_3_count; /* abs.ofs: 254 */
  222. #define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
  223. struct iwl_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
  224. #define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
  225. u16 band_4_count; /* abs.ofs: 280 */
  226. #define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
  227. struct iwl_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
  228. #define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
  229. u16 band_5_count; /* abs.ofs: 304 */
  230. #define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
  231. struct iwl_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
  232. u8 reserved9[194];
  233. #define EEPROM_TXPOWER_CALIB_GROUP0 0x200
  234. #define EEPROM_TXPOWER_CALIB_GROUP1 0x240
  235. #define EEPROM_TXPOWER_CALIB_GROUP2 0x280
  236. #define EEPROM_TXPOWER_CALIB_GROUP3 0x2c0
  237. #define EEPROM_TXPOWER_CALIB_GROUP4 0x300
  238. #define IWL_NUM_TX_CALIB_GROUPS 5
  239. struct iwl_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS];
  240. /* abs.ofs: 512 */
  241. #define EEPROM_CALIB_TEMPERATURE_CORRECT 0x340
  242. struct iwl_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
  243. u8 reserved16[172]; /* fill out to full 1024 byte block */
  244. } __attribute__ ((packed));
  245. #define IWL_EEPROM_IMAGE_SIZE 1024
  246. #include "iwl-3945-commands.h"
  247. #define PCI_LINK_CTRL 0x0F0
  248. #define PCI_POWER_SOURCE 0x0C8
  249. #define PCI_REG_WUM8 0x0E8
  250. #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
  251. /*=== CSR (control and status registers) ===*/
  252. #define CSR_BASE (0x000)
  253. #define CSR_SW_VER (CSR_BASE+0x000)
  254. #define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */
  255. #define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */
  256. #define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */
  257. #define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */
  258. #define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/
  259. #define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */
  260. #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
  261. #define CSR_GP_CNTRL (CSR_BASE+0x024)
  262. #define CSR_HW_REV (CSR_BASE+0x028)
  263. #define CSR_EEPROM_REG (CSR_BASE+0x02c)
  264. #define CSR_EEPROM_GP (CSR_BASE+0x030)
  265. #define CSR_GP_UCODE (CSR_BASE+0x044)
  266. #define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
  267. #define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058)
  268. #define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
  269. #define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
  270. #define CSR_LED_REG (CSR_BASE+0x094)
  271. #define CSR_DRAM_INT_TBL_CTL (CSR_BASE+0x0A0)
  272. #define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
  273. #define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
  274. #define CSR_HW_REV_WA_REG (CSR_BASE+0x22C)
  275. /* HW I/F configuration */
  276. #define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB (0x00000100)
  277. #define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM (0x00000200)
  278. #define CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400)
  279. #define CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800)
  280. #define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000)
  281. #define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000)
  282. #define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
  283. /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
  284. * acknowledged (reset) by host writing "1" to flagged bits. */
  285. #define CSR_INT_BIT_FH_RX (1<<31) /* Rx DMA, cmd responses, FH_INT[17:16] */
  286. #define CSR_INT_BIT_HW_ERR (1<<29) /* DMA hardware error FH_INT[31] */
  287. #define CSR_INT_BIT_DNLD (1<<28) /* uCode Download */
  288. #define CSR_INT_BIT_FH_TX (1<<27) /* Tx DMA FH_INT[1:0] */
  289. #define CSR_INT_BIT_MAC_CLK_ACTV (1<<26) /* NIC controller's clock toggled on/off */
  290. #define CSR_INT_BIT_SW_ERR (1<<25) /* uCode error */
  291. #define CSR_INT_BIT_RF_KILL (1<<7) /* HW RFKILL switch GP_CNTRL[27] toggled */
  292. #define CSR_INT_BIT_CT_KILL (1<<6) /* Critical temp (chip too hot) rfkill */
  293. #define CSR_INT_BIT_SW_RX (1<<3) /* Rx, command responses, 3945 */
  294. #define CSR_INT_BIT_WAKEUP (1<<1) /* NIC controller waking up (pwr mgmt) */
  295. #define CSR_INT_BIT_ALIVE (1<<0) /* uCode interrupts once it initializes */
  296. #define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \
  297. CSR_INT_BIT_HW_ERR | \
  298. CSR_INT_BIT_FH_TX | \
  299. CSR_INT_BIT_SW_ERR | \
  300. CSR_INT_BIT_RF_KILL | \
  301. CSR_INT_BIT_SW_RX | \
  302. CSR_INT_BIT_WAKEUP | \
  303. CSR_INT_BIT_ALIVE)
  304. /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
  305. #define CSR_FH_INT_BIT_ERR (1<<31) /* Error */
  306. #define CSR_FH_INT_BIT_HI_PRIOR (1<<30) /* High priority Rx, bypass coalescing */
  307. #define CSR_FH_INT_BIT_RX_CHNL2 (1<<18) /* Rx channel 2 (3945 only) */
  308. #define CSR_FH_INT_BIT_RX_CHNL1 (1<<17) /* Rx channel 1 */
  309. #define CSR_FH_INT_BIT_RX_CHNL0 (1<<16) /* Rx channel 0 */
  310. #define CSR_FH_INT_BIT_TX_CHNL6 (1<<6) /* Tx channel 6 (3945 only) */
  311. #define CSR_FH_INT_BIT_TX_CHNL1 (1<<1) /* Tx channel 1 */
  312. #define CSR_FH_INT_BIT_TX_CHNL0 (1<<0) /* Tx channel 0 */
  313. #define CSR_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \
  314. CSR_FH_INT_BIT_RX_CHNL2 | \
  315. CSR_FH_INT_BIT_RX_CHNL1 | \
  316. CSR_FH_INT_BIT_RX_CHNL0)
  317. #define CSR_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL6 | \
  318. CSR_FH_INT_BIT_TX_CHNL1 | \
  319. CSR_FH_INT_BIT_TX_CHNL0 )
  320. /* RESET */
  321. #define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001)
  322. #define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002)
  323. #define CSR_RESET_REG_FLAG_SW_RESET (0x00000080)
  324. #define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100)
  325. #define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200)
  326. /* GP (general purpose) CONTROL */
  327. #define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001)
  328. #define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
  329. #define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008)
  330. #define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
  331. #define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001)
  332. #define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000)
  333. #define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000)
  334. #define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000)
  335. /* EEPROM REG */
  336. #define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
  337. #define CSR_EEPROM_REG_BIT_CMD (0x00000002)
  338. /* EEPROM GP */
  339. #define CSR_EEPROM_GP_VALID_MSK (0x00000006)
  340. #define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
  341. #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
  342. /* UCODE DRV GP */
  343. #define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001)
  344. #define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
  345. #define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
  346. #define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
  347. /* GPIO */
  348. #define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200)
  349. #define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000)
  350. #define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC CSR_GPIO_IN_BIT_AUX_POWER
  351. /* GI Chicken Bits */
  352. #define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
  353. #define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
  354. /* CSR_ANA_PLL_CFG */
  355. #define CSR_ANA_PLL_CFG_SH (0x00880300)
  356. #define CSR_LED_REG_TRUN_ON (0x00000078)
  357. #define CSR_LED_REG_TRUN_OFF (0x00000038)
  358. #define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF)
  359. /* DRAM_INT_TBL_CTRL */
  360. #define CSR_DRAM_INT_TBL_CTRL_EN (1<<31)
  361. #define CSR_DRAM_INT_TBL_CTRL_WRAP_CHK (1<<27)
  362. /*=== HBUS (Host-side Bus) ===*/
  363. #define HBUS_BASE (0x400)
  364. #define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c)
  365. #define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010)
  366. #define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018)
  367. #define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c)
  368. #define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044)
  369. #define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048)
  370. #define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c)
  371. #define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050)
  372. #define HBUS_TARG_WRPTR (HBUS_BASE+0x060)
  373. #define HBUS_TARG_MBX_C (HBUS_BASE+0x030)
  374. /* SCD (Scheduler) */
  375. #define SCD_BASE (CSR_BASE + 0x2E00)
  376. #define SCD_MODE_REG (SCD_BASE + 0x000)
  377. #define SCD_ARASTAT_REG (SCD_BASE + 0x004)
  378. #define SCD_TXFACT_REG (SCD_BASE + 0x010)
  379. #define SCD_TXF4MF_REG (SCD_BASE + 0x014)
  380. #define SCD_TXF5MF_REG (SCD_BASE + 0x020)
  381. #define SCD_SBYP_MODE_1_REG (SCD_BASE + 0x02C)
  382. #define SCD_SBYP_MODE_2_REG (SCD_BASE + 0x030)
  383. /*=== FH (data Flow Handler) ===*/
  384. #define FH_BASE (0x800)
  385. #define FH_CBCC_TABLE (FH_BASE+0x140)
  386. #define FH_TFDB_TABLE (FH_BASE+0x180)
  387. #define FH_RCSR_TABLE (FH_BASE+0x400)
  388. #define FH_RSSR_TABLE (FH_BASE+0x4c0)
  389. #define FH_TCSR_TABLE (FH_BASE+0x500)
  390. #define FH_TSSR_TABLE (FH_BASE+0x680)
  391. /* TFDB (Transmit Frame Buffer Descriptor) */
  392. #define FH_TFDB(_channel, buf) \
  393. (FH_TFDB_TABLE+((_channel)*2+(buf))*0x28)
  394. #define ALM_FH_TFDB_CHNL_BUF_CTRL_REG(_channel) \
  395. (FH_TFDB_TABLE + 0x50 * _channel)
  396. /* CBCC _channel is [0,2] */
  397. #define FH_CBCC(_channel) (FH_CBCC_TABLE+(_channel)*0x8)
  398. #define FH_CBCC_CTRL(_channel) (FH_CBCC(_channel)+0x00)
  399. #define FH_CBCC_BASE(_channel) (FH_CBCC(_channel)+0x04)
  400. /* RCSR _channel is [0,2] */
  401. #define FH_RCSR(_channel) (FH_RCSR_TABLE+(_channel)*0x40)
  402. #define FH_RCSR_CONFIG(_channel) (FH_RCSR(_channel)+0x00)
  403. #define FH_RCSR_RBD_BASE(_channel) (FH_RCSR(_channel)+0x04)
  404. #define FH_RCSR_WPTR(_channel) (FH_RCSR(_channel)+0x20)
  405. #define FH_RCSR_RPTR_ADDR(_channel) (FH_RCSR(_channel)+0x24)
  406. #define FH_RSCSR_CHNL0_WPTR (FH_RCSR_WPTR(0))
  407. /* RSSR */
  408. #define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
  409. #define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
  410. /* TCSR */
  411. #define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
  412. #define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
  413. #define FH_TCSR_CREDIT(_channel) (FH_TCSR(_channel)+0x04)
  414. #define FH_TCSR_BUFF_STTS(_channel) (FH_TCSR(_channel)+0x08)
  415. /* TSSR */
  416. #define FH_TSSR_CBB_BASE (FH_TSSR_TABLE+0x000)
  417. #define FH_TSSR_MSG_CONFIG (FH_TSSR_TABLE+0x008)
  418. #define FH_TSSR_TX_STATUS (FH_TSSR_TABLE+0x010)
  419. /* 18 - reserved */
  420. /* card static random access memory (SRAM) for processor data and instructs */
  421. #define RTC_INST_LOWER_BOUND (0x000000)
  422. #define RTC_DATA_LOWER_BOUND (0x800000)
  423. /* DBM */
  424. #define ALM_FH_SRVC_CHNL (6)
  425. #define ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
  426. #define ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
  427. #define ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
  428. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
  429. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
  430. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
  431. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
  432. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
  433. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
  434. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
  435. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
  436. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
  437. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
  438. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
  439. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
  440. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  441. #define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
  442. #define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
  443. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
  444. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
  445. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
  446. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
  447. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
  448. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
  449. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
  450. #define ALM_TB_MAX_BYTES_COUNT (0xFFF0)
  451. #define ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
  452. ((1LU << _channel) << 24)
  453. #define ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
  454. ((1LU << _channel) << 16)
  455. #define ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
  456. (ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
  457. ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
  458. #define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
  459. #define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
  460. #define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004)
  461. #define TFD_QUEUE_MIN 0
  462. #define TFD_QUEUE_MAX 6
  463. #define TFD_QUEUE_SIZE_MAX (256)
  464. /* spectrum and channel data structures */
  465. #define IWL_NUM_SCAN_RATES (2)
  466. #define IWL_SCAN_FLAG_24GHZ (1<<0)
  467. #define IWL_SCAN_FLAG_52GHZ (1<<1)
  468. #define IWL_SCAN_FLAG_ACTIVE (1<<2)
  469. #define IWL_SCAN_FLAG_DIRECT (1<<3)
  470. #define IWL_MAX_CMD_SIZE 1024
  471. #define IWL_DEFAULT_TX_RETRY 15
  472. #define IWL_MAX_TX_RETRY 16
  473. /*********************************************/
  474. #define RFD_SIZE 4
  475. #define NUM_TFD_CHUNKS 4
  476. #define RX_QUEUE_SIZE 256
  477. #define RX_QUEUE_MASK 255
  478. #define RX_QUEUE_SIZE_LOG 8
  479. /* QoS definitions */
  480. #define CW_MIN_OFDM 15
  481. #define CW_MAX_OFDM 1023
  482. #define CW_MIN_CCK 31
  483. #define CW_MAX_CCK 1023
  484. #define QOS_TX0_CW_MIN_OFDM CW_MIN_OFDM
  485. #define QOS_TX1_CW_MIN_OFDM CW_MIN_OFDM
  486. #define QOS_TX2_CW_MIN_OFDM ((CW_MIN_OFDM + 1) / 2 - 1)
  487. #define QOS_TX3_CW_MIN_OFDM ((CW_MIN_OFDM + 1) / 4 - 1)
  488. #define QOS_TX0_CW_MIN_CCK CW_MIN_CCK
  489. #define QOS_TX1_CW_MIN_CCK CW_MIN_CCK
  490. #define QOS_TX2_CW_MIN_CCK ((CW_MIN_CCK + 1) / 2 - 1)
  491. #define QOS_TX3_CW_MIN_CCK ((CW_MIN_CCK + 1) / 4 - 1)
  492. #define QOS_TX0_CW_MAX_OFDM CW_MAX_OFDM
  493. #define QOS_TX1_CW_MAX_OFDM CW_MAX_OFDM
  494. #define QOS_TX2_CW_MAX_OFDM CW_MIN_OFDM
  495. #define QOS_TX3_CW_MAX_OFDM ((CW_MIN_OFDM + 1) / 2 - 1)
  496. #define QOS_TX0_CW_MAX_CCK CW_MAX_CCK
  497. #define QOS_TX1_CW_MAX_CCK CW_MAX_CCK
  498. #define QOS_TX2_CW_MAX_CCK CW_MIN_CCK
  499. #define QOS_TX3_CW_MAX_CCK ((CW_MIN_CCK + 1) / 2 - 1)
  500. #define QOS_TX0_AIFS 3
  501. #define QOS_TX1_AIFS 7
  502. #define QOS_TX2_AIFS 2
  503. #define QOS_TX3_AIFS 2
  504. #define QOS_TX0_ACM 0
  505. #define QOS_TX1_ACM 0
  506. #define QOS_TX2_ACM 0
  507. #define QOS_TX3_ACM 0
  508. #define QOS_TX0_TXOP_LIMIT_CCK 0
  509. #define QOS_TX1_TXOP_LIMIT_CCK 0
  510. #define QOS_TX2_TXOP_LIMIT_CCK 6016
  511. #define QOS_TX3_TXOP_LIMIT_CCK 3264
  512. #define QOS_TX0_TXOP_LIMIT_OFDM 0
  513. #define QOS_TX1_TXOP_LIMIT_OFDM 0
  514. #define QOS_TX2_TXOP_LIMIT_OFDM 3008
  515. #define QOS_TX3_TXOP_LIMIT_OFDM 1504
  516. #define DEF_TX0_CW_MIN_OFDM CW_MIN_OFDM
  517. #define DEF_TX1_CW_MIN_OFDM CW_MIN_OFDM
  518. #define DEF_TX2_CW_MIN_OFDM CW_MIN_OFDM
  519. #define DEF_TX3_CW_MIN_OFDM CW_MIN_OFDM
  520. #define DEF_TX0_CW_MIN_CCK CW_MIN_CCK
  521. #define DEF_TX1_CW_MIN_CCK CW_MIN_CCK
  522. #define DEF_TX2_CW_MIN_CCK CW_MIN_CCK
  523. #define DEF_TX3_CW_MIN_CCK CW_MIN_CCK
  524. #define DEF_TX0_CW_MAX_OFDM CW_MAX_OFDM
  525. #define DEF_TX1_CW_MAX_OFDM CW_MAX_OFDM
  526. #define DEF_TX2_CW_MAX_OFDM CW_MAX_OFDM
  527. #define DEF_TX3_CW_MAX_OFDM CW_MAX_OFDM
  528. #define DEF_TX0_CW_MAX_CCK CW_MAX_CCK
  529. #define DEF_TX1_CW_MAX_CCK CW_MAX_CCK
  530. #define DEF_TX2_CW_MAX_CCK CW_MAX_CCK
  531. #define DEF_TX3_CW_MAX_CCK CW_MAX_CCK
  532. #define DEF_TX0_AIFS (2)
  533. #define DEF_TX1_AIFS (2)
  534. #define DEF_TX2_AIFS (2)
  535. #define DEF_TX3_AIFS (2)
  536. #define DEF_TX0_ACM 0
  537. #define DEF_TX1_ACM 0
  538. #define DEF_TX2_ACM 0
  539. #define DEF_TX3_ACM 0
  540. #define DEF_TX0_TXOP_LIMIT_CCK 0
  541. #define DEF_TX1_TXOP_LIMIT_CCK 0
  542. #define DEF_TX2_TXOP_LIMIT_CCK 0
  543. #define DEF_TX3_TXOP_LIMIT_CCK 0
  544. #define DEF_TX0_TXOP_LIMIT_OFDM 0
  545. #define DEF_TX1_TXOP_LIMIT_OFDM 0
  546. #define DEF_TX2_TXOP_LIMIT_OFDM 0
  547. #define DEF_TX3_TXOP_LIMIT_OFDM 0
  548. #define QOS_QOS_SETS 3
  549. #define QOS_PARAM_SET_ACTIVE 0
  550. #define QOS_PARAM_SET_DEF_CCK 1
  551. #define QOS_PARAM_SET_DEF_OFDM 2
  552. #define CTRL_QOS_NO_ACK (0x0020)
  553. #define DCT_FLAG_EXT_QOS_ENABLED (0x10)
  554. #define U32_PAD(n) ((4-(n))&0x3)
  555. /*
  556. * Generic queue structure
  557. *
  558. * Contains common data for Rx and Tx queues
  559. */
  560. #define TFD_CTL_COUNT_SET(n) (n<<24)
  561. #define TFD_CTL_COUNT_GET(ctl) ((ctl>>24) & 7)
  562. #define TFD_CTL_PAD_SET(n) (n<<28)
  563. #define TFD_CTL_PAD_GET(ctl) (ctl>>28)
  564. #define TFD_TX_CMD_SLOTS 256
  565. #define TFD_CMD_SLOTS 32
  566. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
  567. sizeof(struct iwl_cmd_meta))
  568. /*
  569. * RX related structures and functions
  570. */
  571. #define RX_FREE_BUFFERS 64
  572. #define RX_LOW_WATERMARK 8
  573. #define IWL_RX_BUF_SIZE 3000
  574. /* card static random access memory (SRAM) for processor data and instructs */
  575. #define ALM_RTC_INST_UPPER_BOUND (0x014000)
  576. #define ALM_RTC_DATA_UPPER_BOUND (0x808000)
  577. #define ALM_RTC_INST_SIZE (ALM_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
  578. #define ALM_RTC_DATA_SIZE (ALM_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
  579. #define IWL_MAX_BSM_SIZE ALM_RTC_INST_SIZE
  580. #define IWL_MAX_INST_SIZE ALM_RTC_INST_SIZE
  581. #define IWL_MAX_DATA_SIZE ALM_RTC_DATA_SIZE
  582. #define IWL_MAX_NUM_QUEUES 8
  583. static inline int iwl_hw_valid_rtc_data_addr(u32 addr)
  584. {
  585. return (addr >= RTC_DATA_LOWER_BOUND) &&
  586. (addr < ALM_RTC_DATA_UPPER_BOUND);
  587. }
  588. /* Base physical address of iwl_shared is provided to FH_TSSR_CBB_BASE
  589. * and &iwl_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */
  590. struct iwl_shared {
  591. __le32 tx_base_ptr[8];
  592. __le32 rx_read_ptr[3];
  593. } __attribute__ ((packed));
  594. struct iwl_tfd_frame_data {
  595. __le32 addr;
  596. __le32 len;
  597. } __attribute__ ((packed));
  598. struct iwl_tfd_frame {
  599. __le32 control_flags;
  600. struct iwl_tfd_frame_data pa[4];
  601. u8 reserved[28];
  602. } __attribute__ ((packed));
  603. static inline u8 iwl_hw_get_rate(__le16 rate_n_flags)
  604. {
  605. return le16_to_cpu(rate_n_flags) & 0xFF;
  606. }
  607. static inline u16 iwl_hw_get_rate_n_flags(__le16 rate_n_flags)
  608. {
  609. return le16_to_cpu(rate_n_flags);
  610. }
  611. static inline __le16 iwl_hw_set_rate_n_flags(u8 rate, u16 flags)
  612. {
  613. return cpu_to_le16((u16)rate|flags);
  614. }
  615. #endif