iwl-3945-hw.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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-3945-hw.h) only for hardware-related definitions.
  65. * Please use iwl-3945-commands.h for uCode API definitions.
  66. * Please use iwl-3945.h for driver implementation definitions.
  67. */
  68. #ifndef __iwl_3945_hw__
  69. #define __iwl_3945_hw__
  70. /*
  71. * uCode queue management definitions ...
  72. * Queue #4 is the command queue for 3945 and 4965.
  73. */
  74. #define IWL_CMD_QUEUE_NUM 4
  75. /* Tx rates */
  76. #define IWL_CCK_RATES 4
  77. #define IWL_OFDM_RATES 8
  78. #define IWL_HT_RATES 0
  79. #define IWL_MAX_RATES (IWL_CCK_RATES+IWL_OFDM_RATES+IWL_HT_RATES)
  80. /* Time constants */
  81. #define SHORT_SLOT_TIME 9
  82. #define LONG_SLOT_TIME 20
  83. /* RSSI to dBm */
  84. #define IWL_RSSI_OFFSET 95
  85. /*
  86. * EEPROM related constants, enums, and structures.
  87. */
  88. /*
  89. * EEPROM access time values:
  90. *
  91. * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG,
  92. * then clearing (with subsequent read/modify/write) CSR_EEPROM_REG bit
  93. * CSR_EEPROM_REG_BIT_CMD (0x2).
  94. * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
  95. * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
  96. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
  97. */
  98. #define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
  99. #define IWL_EEPROM_ACCESS_DELAY 10 /* uSec */
  100. /*
  101. * Regulatory channel usage flags in EEPROM struct iwl_eeprom_channel.flags.
  102. *
  103. * IBSS and/or AP operation is allowed *only* on those channels with
  104. * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
  105. * RADAR detection is not supported by the 3945 driver, but is a
  106. * requirement for establishing a new network for legal operation on channels
  107. * requiring RADAR detection or restricting ACTIVE scanning.
  108. *
  109. * NOTE: "WIDE" flag indicates that 20 MHz channel is supported;
  110. * 3945 does not support FAT 40 MHz-wide channels.
  111. *
  112. * NOTE: Using a channel inappropriately will result in a uCode error!
  113. */
  114. enum {
  115. EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
  116. EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
  117. /* Bit 2 Reserved */
  118. EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
  119. EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
  120. EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
  121. EEPROM_CHANNEL_NARROW = (1 << 6), /* 10 MHz channel (not used) */
  122. EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
  123. };
  124. /* SKU Capabilities */
  125. #define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
  126. #define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
  127. #define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7)
  128. /* *regulatory* channel data from eeprom, one for each channel */
  129. struct iwl3945_eeprom_channel {
  130. u8 flags; /* flags copied from EEPROM */
  131. s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
  132. } __attribute__ ((packed));
  133. /*
  134. * Mapping of a Tx power level, at factory calibration temperature,
  135. * to a radio/DSP gain table index.
  136. * One for each of 5 "sample" power levels in each band.
  137. * v_det is measured at the factory, using the 3945's built-in power amplifier
  138. * (PA) output voltage detector. This same detector is used during Tx of
  139. * long packets in normal operation to provide feedback as to proper output
  140. * level.
  141. * Data copied from EEPROM.
  142. * DO NOT ALTER THIS STRUCTURE!!!
  143. */
  144. struct iwl3945_eeprom_txpower_sample {
  145. u8 gain_index; /* index into power (gain) setup table ... */
  146. s8 power; /* ... for this pwr level for this chnl group */
  147. u16 v_det; /* PA output voltage */
  148. } __attribute__ ((packed));
  149. /*
  150. * Mappings of Tx power levels -> nominal radio/DSP gain table indexes.
  151. * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
  152. * Tx power setup code interpolates between the 5 "sample" power levels
  153. * to determine the nominal setup for a requested power level.
  154. * Data copied from EEPROM.
  155. * DO NOT ALTER THIS STRUCTURE!!!
  156. */
  157. struct iwl3945_eeprom_txpower_group {
  158. struct iwl3945_eeprom_txpower_sample samples[5]; /* 5 power levels */
  159. s32 a, b, c, d, e; /* coefficients for voltage->power
  160. * formula (signed) */
  161. s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
  162. * frequency (signed) */
  163. s8 saturation_power; /* highest power possible by h/w in this
  164. * band */
  165. u8 group_channel; /* "representative" channel # in this band */
  166. s16 temperature; /* h/w temperature at factory calib this band
  167. * (signed) */
  168. } __attribute__ ((packed));
  169. /*
  170. * Temperature-based Tx-power compensation data, not band-specific.
  171. * These coefficients are use to modify a/b/c/d/e coeffs based on
  172. * difference between current temperature and factory calib temperature.
  173. * Data copied from EEPROM.
  174. */
  175. struct iwl3945_eeprom_temperature_corr {
  176. u32 Ta;
  177. u32 Tb;
  178. u32 Tc;
  179. u32 Td;
  180. u32 Te;
  181. } __attribute__ ((packed));
  182. /*
  183. * EEPROM map
  184. */
  185. struct iwl3945_eeprom {
  186. u8 reserved0[16];
  187. #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
  188. u16 device_id; /* abs.ofs: 16 */
  189. u8 reserved1[2];
  190. #define EEPROM_PMC (2*0x0A) /* 2 bytes */
  191. u16 pmc; /* abs.ofs: 20 */
  192. u8 reserved2[20];
  193. #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
  194. u8 mac_address[6]; /* abs.ofs: 42 */
  195. u8 reserved3[58];
  196. #define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
  197. u16 board_revision; /* abs.ofs: 106 */
  198. u8 reserved4[11];
  199. #define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
  200. u8 board_pba_number[9]; /* abs.ofs: 119 */
  201. u8 reserved5[8];
  202. #define EEPROM_VERSION (2*0x44) /* 2 bytes */
  203. u16 version; /* abs.ofs: 136 */
  204. #define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */
  205. u8 sku_cap; /* abs.ofs: 138 */
  206. #define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
  207. u8 leds_mode; /* abs.ofs: 139 */
  208. #define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
  209. u16 oem_mode;
  210. #define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
  211. u16 wowlan_mode; /* abs.ofs: 142 */
  212. #define EEPROM_LEDS_TIME_INTERVAL (2*0x48) /* 2 bytes */
  213. u16 leds_time_interval; /* abs.ofs: 144 */
  214. #define EEPROM_LEDS_OFF_TIME (2*0x49) /* 1 bytes */
  215. u8 leds_off_time; /* abs.ofs: 146 */
  216. #define EEPROM_LEDS_ON_TIME (2*0x49+1) /* 1 bytes */
  217. u8 leds_on_time; /* abs.ofs: 147 */
  218. #define EEPROM_ALMGOR_M_VERSION (2*0x4A) /* 1 bytes */
  219. u8 almgor_m_version; /* abs.ofs: 148 */
  220. #define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
  221. u8 antenna_switch_type; /* abs.ofs: 149 */
  222. u8 reserved6[42];
  223. #define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
  224. u8 sku_id[4]; /* abs.ofs: 192 */
  225. /*
  226. * Per-channel regulatory data.
  227. *
  228. * Each channel that *might* be supported by 3945 or 4965 has a fixed location
  229. * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
  230. * txpower (MSB).
  231. *
  232. * Entries immediately below are for 20 MHz channel width. FAT (40 MHz)
  233. * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
  234. *
  235. * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  236. */
  237. #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
  238. u16 band_1_count; /* abs.ofs: 196 */
  239. #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
  240. struct iwl3945_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */
  241. /*
  242. * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
  243. * 5.0 GHz channels 7, 8, 11, 12, 16
  244. * (4915-5080MHz) (none of these is ever supported)
  245. */
  246. #define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
  247. u16 band_2_count; /* abs.ofs: 226 */
  248. #define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
  249. struct iwl3945_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */
  250. /*
  251. * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
  252. * (5170-5320MHz)
  253. */
  254. #define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
  255. u16 band_3_count; /* abs.ofs: 254 */
  256. #define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
  257. struct iwl3945_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */
  258. /*
  259. * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
  260. * (5500-5700MHz)
  261. */
  262. #define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
  263. u16 band_4_count; /* abs.ofs: 280 */
  264. #define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
  265. struct iwl3945_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */
  266. /*
  267. * 5.7 GHz channels 145, 149, 153, 157, 161, 165
  268. * (5725-5825MHz)
  269. */
  270. #define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
  271. u16 band_5_count; /* abs.ofs: 304 */
  272. #define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
  273. struct iwl3945_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */
  274. u8 reserved9[194];
  275. /*
  276. * 3945 Txpower calibration data.
  277. */
  278. #define EEPROM_TXPOWER_CALIB_GROUP0 0x200
  279. #define EEPROM_TXPOWER_CALIB_GROUP1 0x240
  280. #define EEPROM_TXPOWER_CALIB_GROUP2 0x280
  281. #define EEPROM_TXPOWER_CALIB_GROUP3 0x2c0
  282. #define EEPROM_TXPOWER_CALIB_GROUP4 0x300
  283. #define IWL_NUM_TX_CALIB_GROUPS 5
  284. struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS];
  285. /* abs.ofs: 512 */
  286. #define EEPROM_CALIB_TEMPERATURE_CORRECT 0x340
  287. struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */
  288. u8 reserved16[172]; /* fill out to full 1024 byte block */
  289. } __attribute__ ((packed));
  290. #define IWL_EEPROM_IMAGE_SIZE 1024
  291. /* End of EEPROM */
  292. #include "iwl-3945-commands.h"
  293. #define PCI_LINK_CTRL 0x0F0
  294. #define PCI_POWER_SOURCE 0x0C8
  295. #define PCI_REG_WUM8 0x0E8
  296. #define PCI_CFG_PMC_PME_FROM_D3COLD_SUPPORT (0x80000000)
  297. /*=== CSR (control and status registers) ===*/
  298. #define CSR_BASE (0x000)
  299. #define CSR_SW_VER (CSR_BASE+0x000)
  300. #define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */
  301. #define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */
  302. #define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */
  303. #define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */
  304. #define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/
  305. #define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */
  306. #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/
  307. #define CSR_GP_CNTRL (CSR_BASE+0x024)
  308. /*
  309. * Hardware revision info
  310. * Bit fields:
  311. * 31-8: Reserved
  312. * 7-4: Type of device: 0x0 = 4965, 0xd = 3945
  313. * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D
  314. * 1-0: "Dash" value, as in A-1, etc.
  315. */
  316. #define CSR_HW_REV (CSR_BASE+0x028)
  317. /* EEPROM reads */
  318. #define CSR_EEPROM_REG (CSR_BASE+0x02c)
  319. #define CSR_EEPROM_GP (CSR_BASE+0x030)
  320. #define CSR_GP_UCODE (CSR_BASE+0x044)
  321. #define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054)
  322. #define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058)
  323. #define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c)
  324. #define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060)
  325. #define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100)
  326. /* Analog phase-lock-loop configuration (3945 only)
  327. * Set bit 24. */
  328. #define CSR_ANA_PLL_CFG (CSR_BASE+0x20c)
  329. /* Bits for CSR_HW_IF_CONFIG_REG */
  330. #define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MB (0x00000100)
  331. #define CSR_HW_IF_CONFIG_REG_BIT_ALMAGOR_MM (0x00000200)
  332. #define CSR_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400)
  333. #define CSR_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800)
  334. #define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000)
  335. #define CSR_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000)
  336. #define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000)
  337. /* interrupt flags in INTA, set by uCode or hardware (e.g. dma),
  338. * acknowledged (reset) by host writing "1" to flagged bits. */
  339. #define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */
  340. #define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */
  341. #define CSR_INT_BIT_DNLD (1 << 28) /* uCode Download */
  342. #define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */
  343. #define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */
  344. #define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */
  345. #define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */
  346. #define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */
  347. #define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */
  348. #define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */
  349. #define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */
  350. #define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \
  351. CSR_INT_BIT_HW_ERR | \
  352. CSR_INT_BIT_FH_TX | \
  353. CSR_INT_BIT_SW_ERR | \
  354. CSR_INT_BIT_RF_KILL | \
  355. CSR_INT_BIT_SW_RX | \
  356. CSR_INT_BIT_WAKEUP | \
  357. CSR_INT_BIT_ALIVE)
  358. /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */
  359. #define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */
  360. #define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */
  361. #define CSR_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */
  362. #define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */
  363. #define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */
  364. #define CSR_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */
  365. #define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */
  366. #define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */
  367. #define CSR_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \
  368. CSR_FH_INT_BIT_RX_CHNL2 | \
  369. CSR_FH_INT_BIT_RX_CHNL1 | \
  370. CSR_FH_INT_BIT_RX_CHNL0)
  371. #define CSR_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL6 | \
  372. CSR_FH_INT_BIT_TX_CHNL1 | \
  373. CSR_FH_INT_BIT_TX_CHNL0)
  374. /* RESET */
  375. #define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001)
  376. #define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002)
  377. #define CSR_RESET_REG_FLAG_SW_RESET (0x00000080)
  378. #define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100)
  379. #define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200)
  380. /* GP (general purpose) CONTROL */
  381. #define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001)
  382. #define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004)
  383. #define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008)
  384. #define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010)
  385. #define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001)
  386. #define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000)
  387. #define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000)
  388. #define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000)
  389. /* EEPROM REG */
  390. #define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001)
  391. #define CSR_EEPROM_REG_BIT_CMD (0x00000002)
  392. /* EEPROM GP */
  393. #define CSR_EEPROM_GP_VALID_MSK (0x00000006)
  394. #define CSR_EEPROM_GP_BAD_SIGNATURE (0x00000000)
  395. #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180)
  396. /* UCODE DRV GP */
  397. #define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001)
  398. #define CSR_UCODE_SW_BIT_RFKILL (0x00000002)
  399. #define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004)
  400. #define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008)
  401. /* GPIO */
  402. #define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200)
  403. #define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000)
  404. #define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC CSR_GPIO_IN_BIT_AUX_POWER
  405. /* GI Chicken Bits */
  406. #define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000)
  407. #define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000)
  408. /* CSR_ANA_PLL_CFG */
  409. #define CSR_ANA_PLL_CFG_SH (0x00880300)
  410. /*=== HBUS (Host-side Bus) ===*/
  411. #define HBUS_BASE (0x400)
  412. /*
  413. * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM
  414. * structures, error log, event log, verifying uCode load).
  415. * First write to address register, then read from or write to data register
  416. * to complete the job. Once the address register is set up, accesses to
  417. * data registers auto-increment the address by one dword.
  418. * Bit usage for address registers (read or write):
  419. * 0-31: memory address within device
  420. */
  421. #define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c)
  422. #define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010)
  423. #define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018)
  424. #define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c)
  425. /*
  426. * Registers for accessing device's internal peripheral registers
  427. * (e.g. SCD, BSM, etc.). First write to address register,
  428. * then read from or write to data register to complete the job.
  429. * Bit usage for address registers (read or write):
  430. * 0-15: register address (offset) within device
  431. * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword)
  432. */
  433. #define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044)
  434. #define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048)
  435. #define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c)
  436. #define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050)
  437. /*
  438. * Per-Tx-queue write pointer (index, really!) (3945 and 4965).
  439. * Indicates index to next TFD that driver will fill (1 past latest filled).
  440. * Bit usage:
  441. * 0-7: queue write index
  442. * 11-8: queue selector
  443. */
  444. #define HBUS_TARG_WRPTR (HBUS_BASE+0x060)
  445. /* SCD (3945 Tx Frame Scheduler) */
  446. #define SCD_BASE (CSR_BASE + 0x2E00)
  447. #define SCD_MODE_REG (SCD_BASE + 0x000)
  448. #define SCD_ARASTAT_REG (SCD_BASE + 0x004)
  449. #define SCD_TXFACT_REG (SCD_BASE + 0x010)
  450. #define SCD_TXF4MF_REG (SCD_BASE + 0x014)
  451. #define SCD_TXF5MF_REG (SCD_BASE + 0x020)
  452. #define SCD_SBYP_MODE_1_REG (SCD_BASE + 0x02C)
  453. #define SCD_SBYP_MODE_2_REG (SCD_BASE + 0x030)
  454. /*=== FH (data Flow Handler) ===*/
  455. #define FH_BASE (0x800)
  456. #define FH_CBCC_TABLE (FH_BASE+0x140)
  457. #define FH_TFDB_TABLE (FH_BASE+0x180)
  458. #define FH_RCSR_TABLE (FH_BASE+0x400)
  459. #define FH_RSSR_TABLE (FH_BASE+0x4c0)
  460. #define FH_TCSR_TABLE (FH_BASE+0x500)
  461. #define FH_TSSR_TABLE (FH_BASE+0x680)
  462. /* TFDB (Transmit Frame Buffer Descriptor) */
  463. #define FH_TFDB(_channel, buf) \
  464. (FH_TFDB_TABLE+((_channel)*2+(buf))*0x28)
  465. #define ALM_FH_TFDB_CHNL_BUF_CTRL_REG(_channel) \
  466. (FH_TFDB_TABLE + 0x50 * _channel)
  467. /* CBCC _channel is [0,2] */
  468. #define FH_CBCC(_channel) (FH_CBCC_TABLE+(_channel)*0x8)
  469. #define FH_CBCC_CTRL(_channel) (FH_CBCC(_channel)+0x00)
  470. #define FH_CBCC_BASE(_channel) (FH_CBCC(_channel)+0x04)
  471. /* RCSR _channel is [0,2] */
  472. #define FH_RCSR(_channel) (FH_RCSR_TABLE+(_channel)*0x40)
  473. #define FH_RCSR_CONFIG(_channel) (FH_RCSR(_channel)+0x00)
  474. #define FH_RCSR_RBD_BASE(_channel) (FH_RCSR(_channel)+0x04)
  475. #define FH_RCSR_WPTR(_channel) (FH_RCSR(_channel)+0x20)
  476. #define FH_RCSR_RPTR_ADDR(_channel) (FH_RCSR(_channel)+0x24)
  477. #define FH_RSCSR_CHNL0_WPTR (FH_RCSR_WPTR(0))
  478. /* RSSR */
  479. #define FH_RSSR_CTRL (FH_RSSR_TABLE+0x000)
  480. #define FH_RSSR_STATUS (FH_RSSR_TABLE+0x004)
  481. /* TCSR */
  482. #define FH_TCSR(_channel) (FH_TCSR_TABLE+(_channel)*0x20)
  483. #define FH_TCSR_CONFIG(_channel) (FH_TCSR(_channel)+0x00)
  484. #define FH_TCSR_CREDIT(_channel) (FH_TCSR(_channel)+0x04)
  485. #define FH_TCSR_BUFF_STTS(_channel) (FH_TCSR(_channel)+0x08)
  486. /* TSSR */
  487. #define FH_TSSR_CBB_BASE (FH_TSSR_TABLE+0x000)
  488. #define FH_TSSR_MSG_CONFIG (FH_TSSR_TABLE+0x008)
  489. #define FH_TSSR_TX_STATUS (FH_TSSR_TABLE+0x010)
  490. /* DBM */
  491. #define ALM_FH_SRVC_CHNL (6)
  492. #define ALM_FH_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20)
  493. #define ALM_FH_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4)
  494. #define ALM_FH_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000)
  495. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000)
  496. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000)
  497. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000)
  498. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000)
  499. #define ALM_FH_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000)
  500. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
  501. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
  502. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
  503. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
  504. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
  505. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
  506. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
  507. #define ALM_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  508. #define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000)
  509. #define ALM_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
  510. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
  511. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
  512. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
  513. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
  514. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
  515. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
  516. #define ALM_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
  517. #define ALM_TB_MAX_BYTES_COUNT (0xFFF0)
  518. #define ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) \
  519. ((1LU << _channel) << 24)
  520. #define ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel) \
  521. ((1LU << _channel) << 16)
  522. #define ALM_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_channel) \
  523. (ALM_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_channel) | \
  524. ALM_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_channel))
  525. #define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */
  526. #define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */
  527. #define TFD_QUEUE_MIN 0
  528. #define TFD_QUEUE_MAX 6
  529. #define TFD_QUEUE_SIZE_MAX (256)
  530. #define IWL_NUM_SCAN_RATES (2)
  531. #define IWL_DEFAULT_TX_RETRY 15
  532. /*********************************************/
  533. #define RFD_SIZE 4
  534. #define NUM_TFD_CHUNKS 4
  535. #define RX_QUEUE_SIZE 256
  536. #define RX_QUEUE_MASK 255
  537. #define RX_QUEUE_SIZE_LOG 8
  538. #define U32_PAD(n) ((4-(n))&0x3)
  539. #define TFD_CTL_COUNT_SET(n) (n << 24)
  540. #define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7)
  541. #define TFD_CTL_PAD_SET(n) (n << 28)
  542. #define TFD_CTL_PAD_GET(ctl) (ctl >> 28)
  543. #define TFD_TX_CMD_SLOTS 256
  544. #define TFD_CMD_SLOTS 32
  545. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl3945_cmd) - \
  546. sizeof(struct iwl3945_cmd_meta))
  547. /*
  548. * RX related structures and functions
  549. */
  550. #define RX_FREE_BUFFERS 64
  551. #define RX_LOW_WATERMARK 8
  552. /* Sizes and addresses for instruction and data memory (SRAM) in
  553. * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
  554. #define RTC_INST_LOWER_BOUND (0x000000)
  555. #define ALM_RTC_INST_UPPER_BOUND (0x014000)
  556. #define RTC_DATA_LOWER_BOUND (0x800000)
  557. #define ALM_RTC_DATA_UPPER_BOUND (0x808000)
  558. #define ALM_RTC_INST_SIZE (ALM_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
  559. #define ALM_RTC_DATA_SIZE (ALM_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
  560. #define IWL_MAX_INST_SIZE ALM_RTC_INST_SIZE
  561. #define IWL_MAX_DATA_SIZE ALM_RTC_DATA_SIZE
  562. /* Size of uCode instruction memory in bootstrap state machine */
  563. #define IWL_MAX_BSM_SIZE ALM_RTC_INST_SIZE
  564. #define IWL_MAX_NUM_QUEUES 8
  565. static inline int iwl3945_hw_valid_rtc_data_addr(u32 addr)
  566. {
  567. return (addr >= RTC_DATA_LOWER_BOUND) &&
  568. (addr < ALM_RTC_DATA_UPPER_BOUND);
  569. }
  570. /* Base physical address of iwl3945_shared is provided to FH_TSSR_CBB_BASE
  571. * and &iwl3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */
  572. struct iwl3945_shared {
  573. __le32 tx_base_ptr[8];
  574. __le32 rx_read_ptr[3];
  575. } __attribute__ ((packed));
  576. struct iwl3945_tfd_frame_data {
  577. __le32 addr;
  578. __le32 len;
  579. } __attribute__ ((packed));
  580. struct iwl3945_tfd_frame {
  581. __le32 control_flags;
  582. struct iwl3945_tfd_frame_data pa[4];
  583. u8 reserved[28];
  584. } __attribute__ ((packed));
  585. static inline u8 iwl3945_hw_get_rate(__le16 rate_n_flags)
  586. {
  587. return le16_to_cpu(rate_n_flags) & 0xFF;
  588. }
  589. static inline u16 iwl3945_hw_get_rate_n_flags(__le16 rate_n_flags)
  590. {
  591. return le16_to_cpu(rate_n_flags);
  592. }
  593. static inline __le16 iwl3945_hw_set_rate_n_flags(u8 rate, u16 flags)
  594. {
  595. return cpu_to_le16((u16)rate|flags);
  596. }
  597. #endif