iwl-4965-hw.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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 Geeral 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_4965_hw_h__
  64. #define __iwl_4965_hw_h__
  65. #define IWL_RX_BUF_SIZE (4 * 1024)
  66. #define IWL_MAX_BSM_SIZE BSM_SRAM_SIZE
  67. #define KDR_RTC_INST_UPPER_BOUND (0x018000)
  68. #define KDR_RTC_DATA_UPPER_BOUND (0x80A000)
  69. #define KDR_RTC_INST_SIZE (KDR_RTC_INST_UPPER_BOUND - RTC_INST_LOWER_BOUND)
  70. #define KDR_RTC_DATA_SIZE (KDR_RTC_DATA_UPPER_BOUND - RTC_DATA_LOWER_BOUND)
  71. #define IWL_MAX_INST_SIZE KDR_RTC_INST_SIZE
  72. #define IWL_MAX_DATA_SIZE KDR_RTC_DATA_SIZE
  73. static inline int iwl_hw_valid_rtc_data_addr(u32 addr)
  74. {
  75. return (addr >= RTC_DATA_LOWER_BOUND) &&
  76. (addr < KDR_RTC_DATA_UPPER_BOUND);
  77. }
  78. /********************* START TXPOWER *****************************************/
  79. enum {
  80. HT_IE_EXT_CHANNEL_NONE = 0,
  81. HT_IE_EXT_CHANNEL_ABOVE,
  82. HT_IE_EXT_CHANNEL_INVALID,
  83. HT_IE_EXT_CHANNEL_BELOW,
  84. HT_IE_EXT_CHANNEL_MAX
  85. };
  86. enum {
  87. CALIB_CH_GROUP_1 = 0,
  88. CALIB_CH_GROUP_2 = 1,
  89. CALIB_CH_GROUP_3 = 2,
  90. CALIB_CH_GROUP_4 = 3,
  91. CALIB_CH_GROUP_5 = 4,
  92. CALIB_CH_GROUP_MAX
  93. };
  94. /* Temperature calibration offset is 3% 0C in Kelvin */
  95. #define TEMPERATURE_CALIB_KELVIN_OFFSET 8
  96. #define TEMPERATURE_CALIB_A_VAL 259
  97. #define IWL_TX_POWER_TEMPERATURE_MIN (263)
  98. #define IWL_TX_POWER_TEMPERATURE_MAX (410)
  99. #define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
  100. (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \
  101. ((t) > IWL_TX_POWER_TEMPERATURE_MAX))
  102. #define IWL_TX_POWER_ILLEGAL_TEMPERATURE (300)
  103. #define IWL_TX_POWER_TEMPERATURE_DIFFERENCE (2)
  104. #define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
  105. #define IWL_TX_POWER_TARGET_POWER_MIN (0) /* 0 dBm = 1 milliwatt */
  106. #define IWL_TX_POWER_TARGET_POWER_MAX (16) /* 16 dBm */
  107. /* timeout equivalent to 3 minutes */
  108. #define IWL_TX_POWER_TIMELIMIT_NOCALIB 1800000000
  109. #define IWL_TX_POWER_CCK_COMPENSATION (9)
  110. #define MIN_TX_GAIN_INDEX (0)
  111. #define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9)
  112. #define MAX_TX_GAIN_INDEX_52GHZ (98)
  113. #define MIN_TX_GAIN_52GHZ (98)
  114. #define MAX_TX_GAIN_INDEX_24GHZ (98)
  115. #define MIN_TX_GAIN_24GHZ (98)
  116. #define MAX_TX_GAIN (0)
  117. #define MAX_TX_GAIN_52GHZ_EXT (-9)
  118. #define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34)
  119. #define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34)
  120. #define IWL_TX_POWER_REGULATORY_MIN (0)
  121. #define IWL_TX_POWER_REGULATORY_MAX (34)
  122. #define IWL_TX_POWER_DEFAULT_SATURATION_24 (38)
  123. #define IWL_TX_POWER_DEFAULT_SATURATION_52 (38)
  124. #define IWL_TX_POWER_SATURATION_MIN (20)
  125. #define IWL_TX_POWER_SATURATION_MAX (50)
  126. /* dv *0.4 = dt; so that 5 degrees temperature diff equals
  127. * 12.5 in voltage diff */
  128. #define IWL_TX_TEMPERATURE_UPDATE_LIMIT 9
  129. #define IWL_INVALID_CHANNEL (0xffffffff)
  130. #define IWL_TX_POWER_REGITRY_BIT (2)
  131. #define MIN_IWL_TX_POWER_CALIB_DUR (100)
  132. #define IWL_CCK_FROM_OFDM_POWER_DIFF (-5)
  133. #define IWL_CCK_FROM_OFDM_INDEX_DIFF (9)
  134. /* Number of entries in the gain table */
  135. #define POWER_GAIN_NUM_ENTRIES 78
  136. #define TX_POW_MAX_SESSION_NUM 5
  137. /* timeout equivalent to 3 minutes */
  138. #define TX_IWL_TIMELIMIT_NOCALIB 1800000000
  139. /* Kedron TX_CALIB_STATES */
  140. #define IWL_TX_CALIB_STATE_SEND_TX 0x00000001
  141. #define IWL_TX_CALIB_WAIT_TX_RESPONSE 0x00000002
  142. #define IWL_TX_CALIB_ENABLED 0x00000004
  143. #define IWL_TX_CALIB_XVT_ON 0x00000008
  144. #define IWL_TX_CALIB_TEMPERATURE_CORRECT 0x00000010
  145. #define IWL_TX_CALIB_WORKING_WITH_XVT 0x00000020
  146. #define IWL_TX_CALIB_XVT_PERIODICAL 0x00000040
  147. #define NUM_IWL_TX_CALIB_SETTINS 5 /* Number of tx correction groups */
  148. #define IWL_MIN_POWER_IN_VP_TABLE 1 /* 0.5dBm multiplied by 2 */
  149. #define IWL_MAX_POWER_IN_VP_TABLE 40 /* 20dBm - multiplied by 2 (because
  150. * entries are for each 0.5dBm) */
  151. #define IWL_STEP_IN_VP_TABLE 1 /* 0.5dB - multiplied by 2 */
  152. #define IWL_NUM_POINTS_IN_VPTABLE \
  153. (1 + IWL_MAX_POWER_IN_VP_TABLE - IWL_MIN_POWER_IN_VP_TABLE)
  154. #define MIN_TX_GAIN_INDEX (0)
  155. #define MAX_TX_GAIN_INDEX_52GHZ (98)
  156. #define MIN_TX_GAIN_52GHZ (98)
  157. #define MAX_TX_GAIN_INDEX_24GHZ (98)
  158. #define MIN_TX_GAIN_24GHZ (98)
  159. #define MAX_TX_GAIN (0)
  160. /* First and last channels of all groups */
  161. #define CALIB_IWL_TX_ATTEN_GR1_FCH 34
  162. #define CALIB_IWL_TX_ATTEN_GR1_LCH 43
  163. #define CALIB_IWL_TX_ATTEN_GR2_FCH 44
  164. #define CALIB_IWL_TX_ATTEN_GR2_LCH 70
  165. #define CALIB_IWL_TX_ATTEN_GR3_FCH 71
  166. #define CALIB_IWL_TX_ATTEN_GR3_LCH 124
  167. #define CALIB_IWL_TX_ATTEN_GR4_FCH 125
  168. #define CALIB_IWL_TX_ATTEN_GR4_LCH 200
  169. #define CALIB_IWL_TX_ATTEN_GR5_FCH 1
  170. #define CALIB_IWL_TX_ATTEN_GR5_LCH 20
  171. union iwl_tx_power_dual_stream {
  172. struct {
  173. u8 radio_tx_gain[2];
  174. u8 dsp_predis_atten[2];
  175. } s;
  176. u32 dw;
  177. };
  178. /********************* END TXPOWER *****************************************/
  179. /* HT flags */
  180. #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22)
  181. #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK __constant_cpu_to_le32(0x1<<22)
  182. #define RXON_FLG_HT_OPERATING_MODE_POS (23)
  183. #define RXON_FLG_HT_PROT_MSK __constant_cpu_to_le32(0x1<<23)
  184. #define RXON_FLG_FAT_PROT_MSK __constant_cpu_to_le32(0x2<<23)
  185. #define RXON_FLG_CHANNEL_MODE_POS (25)
  186. #define RXON_FLG_CHANNEL_MODE_MSK __constant_cpu_to_le32(0x3<<25)
  187. #define RXON_FLG_CHANNEL_MODE_PURE_40_MSK __constant_cpu_to_le32(0x1<<25)
  188. #define RXON_FLG_CHANNEL_MODE_MIXED_MSK __constant_cpu_to_le32(0x2<<25)
  189. #define RXON_RX_CHAIN_DRIVER_FORCE_MSK __constant_cpu_to_le16(0x1<<0)
  190. #define RXON_RX_CHAIN_VALID_MSK __constant_cpu_to_le16(0x7<<1)
  191. #define RXON_RX_CHAIN_VALID_POS (1)
  192. #define RXON_RX_CHAIN_FORCE_SEL_MSK __constant_cpu_to_le16(0x7<<4)
  193. #define RXON_RX_CHAIN_FORCE_SEL_POS (4)
  194. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK __constant_cpu_to_le16(0x7<<7)
  195. #define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7)
  196. #define RXON_RX_CHAIN_CNT_MSK __constant_cpu_to_le16(0x3<<10)
  197. #define RXON_RX_CHAIN_CNT_POS (10)
  198. #define RXON_RX_CHAIN_MIMO_CNT_MSK __constant_cpu_to_le16(0x3<<12)
  199. #define RXON_RX_CHAIN_MIMO_CNT_POS (12)
  200. #define RXON_RX_CHAIN_MIMO_FORCE_MSK __constant_cpu_to_le16(0x1<<14)
  201. #define RXON_RX_CHAIN_MIMO_FORCE_POS (14)
  202. #define MCS_DUP_6M_PLCP 0x20
  203. /* OFDM HT rate masks */
  204. /* ***************************************** */
  205. #define R_MCS_6M_MSK 0x1
  206. #define R_MCS_12M_MSK 0x2
  207. #define R_MCS_18M_MSK 0x4
  208. #define R_MCS_24M_MSK 0x8
  209. #define R_MCS_36M_MSK 0x10
  210. #define R_MCS_48M_MSK 0x20
  211. #define R_MCS_54M_MSK 0x40
  212. #define R_MCS_60M_MSK 0x80
  213. #define R_MCS_12M_DUAL_MSK 0x100
  214. #define R_MCS_24M_DUAL_MSK 0x200
  215. #define R_MCS_36M_DUAL_MSK 0x400
  216. #define R_MCS_48M_DUAL_MSK 0x800
  217. #define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A))
  218. #define is_siso(tbl) (((tbl) == LQ_SISO))
  219. #define is_mimo(tbl) (((tbl) == LQ_MIMO))
  220. #define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
  221. #define is_a_band(tbl) (((tbl) == LQ_A))
  222. #define is_g_and(tbl) (((tbl) == LQ_G))
  223. /* Flow Handler Definitions */
  224. /**********************/
  225. /* Addresses */
  226. /**********************/
  227. #define FH_MEM_LOWER_BOUND (0x1000)
  228. #define FH_MEM_UPPER_BOUND (0x1EF0)
  229. #define IWL_FH_REGS_LOWER_BOUND (0x1000)
  230. #define IWL_FH_REGS_UPPER_BOUND (0x2000)
  231. #define IWL_FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
  232. /* CBBC Area - Circular buffers base address cache pointers table */
  233. #define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
  234. #define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
  235. /* queues 0 - 15 */
  236. #define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
  237. /* RSCSR Area */
  238. #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
  239. #define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  240. #define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
  241. #define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
  242. #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
  243. #define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
  244. /* RCSR Area - Registers address map */
  245. #define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  246. #define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0)
  247. #define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND)
  248. #define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0)
  249. /* RSSR Area - Rx shared ctrl & status registers */
  250. #define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
  251. #define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
  252. #define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
  253. #define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
  254. #define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV (FH_MEM_RSSR_LOWER_BOUND + 0x008)
  255. /* TCSR */
  256. #define IWL_FH_TCSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xD00)
  257. #define IWL_FH_TCSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xE60)
  258. #define IWL_FH_TCSR_CHNL_NUM (7)
  259. #define IWL_FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
  260. (IWL_FH_TCSR_LOWER_BOUND + 0x20 * _chnl)
  261. /* TSSR Area - Tx shared status registers */
  262. /* TSSR */
  263. #define IWL_FH_TSSR_LOWER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEA0)
  264. #define IWL_FH_TSSR_UPPER_BOUND (IWL_FH_REGS_LOWER_BOUND + 0xEC0)
  265. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG (IWL_FH_TSSR_LOWER_BOUND + 0x008)
  266. #define IWL_FH_TSSR_TX_STATUS_REG (IWL_FH_TSSR_LOWER_BOUND + 0x010)
  267. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000)
  268. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000)
  269. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_64B (0x00000000)
  270. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400)
  271. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_256B (0x00000800)
  272. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_512B (0x00000C00)
  273. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100)
  274. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080)
  275. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020)
  276. #define IWL_FH_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005)
  277. #define IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) \
  278. ((1 << (_chnl)) << 24)
  279. #define IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl) \
  280. ((1 << (_chnl)) << 16)
  281. #define IWL_FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) \
  282. (IWL_FH_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_chnl) | \
  283. IWL_FH_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_chnl))
  284. /* TCSR: tx_config register values */
  285. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
  286. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001)
  287. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_ARC (0x00000002)
  288. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000)
  289. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008)
  290. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
  291. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
  292. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
  293. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
  294. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
  295. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
  296. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
  297. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
  298. #define IWL_FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  299. #define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
  300. #define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
  301. #define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
  302. #define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001)
  303. #define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
  304. #define IWL_FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
  305. /* RCSR: channel 0 rx_config register defines */
  306. #define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MASK (0xC0000000) /* bits 30-31 */
  307. #define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MASK (0x00F00000) /* bits 20-23 */
  308. #define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MASK (0x00030000) /* bits 16-17 */
  309. #define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MASK (0x00008000) /* bit 15 */
  310. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MASK (0x00001000) /* bit 12 */
  311. #define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MASK (0x00000FF0) /* bit 4-11 */
  312. #define FH_RCSR_RX_CONFIG_RBDCB_SIZE_BITSHIFT (20)
  313. #define FH_RCSR_RX_CONFIG_RB_SIZE_BITSHIFT (16)
  314. /* RCSR: rx_config register values */
  315. #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
  316. #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
  317. #define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
  318. #define IWL_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
  319. /* RCSR channel 0 config register values */
  320. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
  321. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
  322. /* RSCSR: defs used in normal mode */
  323. #define FH_RSCSR_CHNL0_RBDCB_WPTR_MASK (0x00000FFF) /* bits 0-11 */
  324. #define SCD_WIN_SIZE 64
  325. #define SCD_FRAME_LIMIT 64
  326. /* memory mapped registers */
  327. #define SCD_START_OFFSET 0xa02c00
  328. #define SCD_SRAM_BASE_ADDR (SCD_START_OFFSET + 0x0)
  329. #define SCD_EMPTY_BITS (SCD_START_OFFSET + 0x4)
  330. #define SCD_DRAM_BASE_ADDR (SCD_START_OFFSET + 0x10)
  331. #define SCD_AIT (SCD_START_OFFSET + 0x18)
  332. #define SCD_TXFACT (SCD_START_OFFSET + 0x1c)
  333. #define SCD_QUEUE_WRPTR(x) (SCD_START_OFFSET + 0x24 + (x) * 4)
  334. #define SCD_QUEUE_RDPTR(x) (SCD_START_OFFSET + 0x64 + (x) * 4)
  335. #define SCD_SETQUEUENUM (SCD_START_OFFSET + 0xa4)
  336. #define SCD_SET_TXSTAT_TXED (SCD_START_OFFSET + 0xa8)
  337. #define SCD_SET_TXSTAT_DONE (SCD_START_OFFSET + 0xac)
  338. #define SCD_SET_TXSTAT_NOT_SCHD (SCD_START_OFFSET + 0xb0)
  339. #define SCD_DECREASE_CREDIT (SCD_START_OFFSET + 0xb4)
  340. #define SCD_DECREASE_SCREDIT (SCD_START_OFFSET + 0xb8)
  341. #define SCD_LOAD_CREDIT (SCD_START_OFFSET + 0xbc)
  342. #define SCD_LOAD_SCREDIT (SCD_START_OFFSET + 0xc0)
  343. #define SCD_BAR (SCD_START_OFFSET + 0xc4)
  344. #define SCD_BAR_DW0 (SCD_START_OFFSET + 0xc8)
  345. #define SCD_BAR_DW1 (SCD_START_OFFSET + 0xcc)
  346. #define SCD_QUEUECHAIN_SEL (SCD_START_OFFSET + 0xd0)
  347. #define SCD_QUERY_REQ (SCD_START_OFFSET + 0xd8)
  348. #define SCD_QUERY_RES (SCD_START_OFFSET + 0xdc)
  349. #define SCD_PENDING_FRAMES (SCD_START_OFFSET + 0xe0)
  350. #define SCD_INTERRUPT_MASK (SCD_START_OFFSET + 0xe4)
  351. #define SCD_INTERRUPT_THRESHOLD (SCD_START_OFFSET + 0xe8)
  352. #define SCD_QUERY_MIN_FRAME_SIZE (SCD_START_OFFSET + 0x100)
  353. #define SCD_QUEUE_STATUS_BITS(x) (SCD_START_OFFSET + 0x104 + (x) * 4)
  354. /* SRAM structures */
  355. #define SCD_CONTEXT_DATA_OFFSET 0x380
  356. #define SCD_TX_STTS_BITMAP_OFFSET 0x400
  357. #define SCD_TRANSLATE_TBL_OFFSET 0x500
  358. #define SCD_CONTEXT_QUEUE_OFFSET(x) (SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
  359. #define SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
  360. ((SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
  361. #define SCD_TXFACT_REG_TXFIFO_MASK(lo, hi) \
  362. ((1<<(hi))|((1<<(hi))-(1<<(lo))))
  363. #define SCD_MODE_REG_BIT_SEARCH_MODE (1<<0)
  364. #define SCD_MODE_REG_BIT_SBYP_MODE (1<<1)
  365. #define SCD_TXFIFO_POS_TID (0)
  366. #define SCD_TXFIFO_POS_RA (4)
  367. #define SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
  368. #define SCD_QUEUE_STTS_REG_POS_TXF (1)
  369. #define SCD_QUEUE_STTS_REG_POS_WSL (5)
  370. #define SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
  371. #define SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
  372. #define SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
  373. #define SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
  374. #define SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
  375. #define SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
  376. #define SCD_QUEUE_CTX_REG1_CREDIT_POS (8)
  377. #define SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00)
  378. #define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24)
  379. #define SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000)
  380. #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
  381. #define SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
  382. #define CSR_HW_IF_CONFIG_REG_BIT_KEDRON_R (0x00000010)
  383. #define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00)
  384. #define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100)
  385. #define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200)
  386. static inline u8 iwl_hw_get_rate(__le32 rate_n_flags)
  387. {
  388. return le32_to_cpu(rate_n_flags) & 0xFF;
  389. }
  390. static inline u16 iwl_hw_get_rate_n_flags(__le32 rate_n_flags)
  391. {
  392. return le32_to_cpu(rate_n_flags) & 0xFFFF;
  393. }
  394. static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u16 flags)
  395. {
  396. return cpu_to_le32(flags|(u16)rate);
  397. }
  398. struct iwl_tfd_frame_data {
  399. __le32 tb1_addr;
  400. __le32 val1;
  401. /* __le32 ptb1_32_35:4; */
  402. #define IWL_tb1_addr_hi_POS 0
  403. #define IWL_tb1_addr_hi_LEN 4
  404. #define IWL_tb1_addr_hi_SYM val1
  405. /* __le32 tb_len1:12; */
  406. #define IWL_tb1_len_POS 4
  407. #define IWL_tb1_len_LEN 12
  408. #define IWL_tb1_len_SYM val1
  409. /* __le32 ptb2_0_15:16; */
  410. #define IWL_tb2_addr_lo16_POS 16
  411. #define IWL_tb2_addr_lo16_LEN 16
  412. #define IWL_tb2_addr_lo16_SYM val1
  413. __le32 val2;
  414. /* __le32 ptb2_16_35:20; */
  415. #define IWL_tb2_addr_hi20_POS 0
  416. #define IWL_tb2_addr_hi20_LEN 20
  417. #define IWL_tb2_addr_hi20_SYM val2
  418. /* __le32 tb_len2:12; */
  419. #define IWL_tb2_len_POS 20
  420. #define IWL_tb2_len_LEN 12
  421. #define IWL_tb2_len_SYM val2
  422. } __attribute__ ((packed));
  423. struct iwl_tfd_frame {
  424. __le32 val0;
  425. /* __le32 rsvd1:24; */
  426. /* __le32 num_tbs:5; */
  427. #define IWL_num_tbs_POS 24
  428. #define IWL_num_tbs_LEN 5
  429. #define IWL_num_tbs_SYM val0
  430. /* __le32 rsvd2:1; */
  431. /* __le32 padding:2; */
  432. struct iwl_tfd_frame_data pa[10];
  433. __le32 reserved;
  434. } __attribute__ ((packed));
  435. #define IWL4965_MAX_WIN_SIZE 64
  436. #define IWL4965_QUEUE_SIZE 256
  437. #define IWL4965_NUM_FIFOS 7
  438. #define IWL_MAX_NUM_QUEUES 16
  439. struct iwl4965_queue_byte_cnt_entry {
  440. __le16 val;
  441. /* __le16 byte_cnt:12; */
  442. #define IWL_byte_cnt_POS 0
  443. #define IWL_byte_cnt_LEN 12
  444. #define IWL_byte_cnt_SYM val
  445. /* __le16 rsvd:4; */
  446. } __attribute__ ((packed));
  447. struct iwl4965_sched_queue_byte_cnt_tbl {
  448. struct iwl4965_queue_byte_cnt_entry tfd_offset[IWL4965_QUEUE_SIZE +
  449. IWL4965_MAX_WIN_SIZE];
  450. u8 dont_care[1024 -
  451. (IWL4965_QUEUE_SIZE + IWL4965_MAX_WIN_SIZE) *
  452. sizeof(__le16)];
  453. } __attribute__ ((packed));
  454. /* Base physical address of iwl_shared is provided to SCD_DRAM_BASE_ADDR
  455. * and &iwl_shared.val0 is provided to FH_RSCSR_CHNL0_STTS_WPTR_REG */
  456. struct iwl_shared {
  457. struct iwl4965_sched_queue_byte_cnt_tbl
  458. queues_byte_cnt_tbls[IWL_MAX_NUM_QUEUES];
  459. __le32 val0;
  460. /* __le32 rb_closed_stts_rb_num:12; */
  461. #define IWL_rb_closed_stts_rb_num_POS 0
  462. #define IWL_rb_closed_stts_rb_num_LEN 12
  463. #define IWL_rb_closed_stts_rb_num_SYM val0
  464. /* __le32 rsrv1:4; */
  465. /* __le32 rb_closed_stts_rx_frame_num:12; */
  466. #define IWL_rb_closed_stts_rx_frame_num_POS 16
  467. #define IWL_rb_closed_stts_rx_frame_num_LEN 12
  468. #define IWL_rb_closed_stts_rx_frame_num_SYM val0
  469. /* __le32 rsrv2:4; */
  470. __le32 val1;
  471. /* __le32 frame_finished_stts_rb_num:12; */
  472. #define IWL_frame_finished_stts_rb_num_POS 0
  473. #define IWL_frame_finished_stts_rb_num_LEN 12
  474. #define IWL_frame_finished_stts_rb_num_SYM val1
  475. /* __le32 rsrv3:4; */
  476. /* __le32 frame_finished_stts_rx_frame_num:12; */
  477. #define IWL_frame_finished_stts_rx_frame_num_POS 16
  478. #define IWL_frame_finished_stts_rx_frame_num_LEN 12
  479. #define IWL_frame_finished_stts_rx_frame_num_SYM val1
  480. /* __le32 rsrv4:4; */
  481. __le32 padding1; /* so that allocation will be aligned to 16B */
  482. __le32 padding2;
  483. } __attribute__ ((packed));
  484. #endif /* __iwl_4965_hw_h__ */