iwl-fh.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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 - 2014 Intel Corporation. All rights reserved.
  9. * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
  23. * USA
  24. *
  25. * The full GNU General Public License is included in this distribution
  26. * in the file called COPYING.
  27. *
  28. * Contact Information:
  29. * Intel Linux Wireless <linuxwifi@intel.com>
  30. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  31. *
  32. * BSD LICENSE
  33. *
  34. * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved.
  35. * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
  36. * All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. *
  42. * * Redistributions of source code must retain the above copyright
  43. * notice, this list of conditions and the following disclaimer.
  44. * * Redistributions in binary form must reproduce the above copyright
  45. * notice, this list of conditions and the following disclaimer in
  46. * the documentation and/or other materials provided with the
  47. * distribution.
  48. * * Neither the name Intel Corporation nor the names of its
  49. * contributors may be used to endorse or promote products derived
  50. * from this software without specific prior written permission.
  51. *
  52. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  53. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  54. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  55. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  56. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  57. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  58. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  59. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  60. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  61. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  62. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  63. *
  64. *****************************************************************************/
  65. #ifndef __iwl_fh_h__
  66. #define __iwl_fh_h__
  67. #include <linux/types.h>
  68. /****************************/
  69. /* Flow Handler Definitions */
  70. /****************************/
  71. /**
  72. * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
  73. * Addresses are offsets from device's PCI hardware base address.
  74. */
  75. #define FH_MEM_LOWER_BOUND (0x1000)
  76. #define FH_MEM_UPPER_BOUND (0x2000)
  77. /**
  78. * Keep-Warm (KW) buffer base address.
  79. *
  80. * Driver must allocate a 4KByte buffer that is for keeping the
  81. * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
  82. * DRAM access when doing Txing or Rxing. The dummy accesses prevent host
  83. * from going into a power-savings mode that would cause higher DRAM latency,
  84. * and possible data over/under-runs, before all Tx/Rx is complete.
  85. *
  86. * Driver loads FH_KW_MEM_ADDR_REG with the physical address (bits 35:4)
  87. * of the buffer, which must be 4K aligned. Once this is set up, the device
  88. * automatically invokes keep-warm accesses when normal accesses might not
  89. * be sufficient to maintain fast DRAM response.
  90. *
  91. * Bit fields:
  92. * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned
  93. */
  94. #define FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C)
  95. /**
  96. * TFD Circular Buffers Base (CBBC) addresses
  97. *
  98. * Device has 16 base pointer registers, one for each of 16 host-DRAM-resident
  99. * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
  100. * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04
  101. * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
  102. * aligned (address bits 0-7 must be 0).
  103. * Later devices have 20 (5000 series) or 30 (higher) queues, but the registers
  104. * for them are in different places.
  105. *
  106. * Bit fields in each pointer register:
  107. * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
  108. */
  109. #define FH_MEM_CBBC_0_15_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
  110. #define FH_MEM_CBBC_0_15_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10)
  111. #define FH_MEM_CBBC_16_19_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBF0)
  112. #define FH_MEM_CBBC_16_19_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  113. #define FH_MEM_CBBC_20_31_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xB20)
  114. #define FH_MEM_CBBC_20_31_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xB80)
  115. /* Find TFD CB base pointer for given queue */
  116. static inline unsigned int FH_MEM_CBBC_QUEUE(unsigned int chnl)
  117. {
  118. if (chnl < 16)
  119. return FH_MEM_CBBC_0_15_LOWER_BOUND + 4 * chnl;
  120. if (chnl < 20)
  121. return FH_MEM_CBBC_16_19_LOWER_BOUND + 4 * (chnl - 16);
  122. WARN_ON_ONCE(chnl >= 32);
  123. return FH_MEM_CBBC_20_31_LOWER_BOUND + 4 * (chnl - 20);
  124. }
  125. /**
  126. * Rx SRAM Control and Status Registers (RSCSR)
  127. *
  128. * These registers provide handshake between driver and device for the Rx queue
  129. * (this queue handles *all* command responses, notifications, Rx data, etc.
  130. * sent from uCode to host driver). Unlike Tx, there is only one Rx
  131. * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can
  132. * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
  133. * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
  134. * mapping between RBDs and RBs.
  135. *
  136. * Driver must allocate host DRAM memory for the following, and set the
  137. * physical address of each into device registers:
  138. *
  139. * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
  140. * entries (although any power of 2, up to 4096, is selectable by driver).
  141. * Each entry (1 dword) points to a receive buffer (RB) of consistent size
  142. * (typically 4K, although 8K or 16K are also selectable by driver).
  143. * Driver sets up RB size and number of RBDs in the CB via Rx config
  144. * register FH_MEM_RCSR_CHNL0_CONFIG_REG.
  145. *
  146. * Bit fields within one RBD:
  147. * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned
  148. *
  149. * Driver sets physical address [35:8] of base of RBD circular buffer
  150. * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
  151. *
  152. * 2) Rx status buffer, 8 bytes, in which uCode indicates which Rx Buffers
  153. * (RBs) have been filled, via a "write pointer", actually the index of
  154. * the RB's corresponding RBD within the circular buffer. Driver sets
  155. * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
  156. *
  157. * Bit fields in lower dword of Rx status buffer (upper dword not used
  158. * by driver:
  159. * 31-12: Not used by driver
  160. * 11- 0: Index of last filled Rx buffer descriptor
  161. * (device writes, driver reads this value)
  162. *
  163. * As the driver prepares Receive Buffers (RBs) for device to fill, driver must
  164. * enter pointers to these RBs into contiguous RBD circular buffer entries,
  165. * and update the device's "write" index register,
  166. * FH_RSCSR_CHNL0_RBDCB_WPTR_REG.
  167. *
  168. * This "write" index corresponds to the *next* RBD that the driver will make
  169. * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
  170. * the circular buffer. This value should initially be 0 (before preparing any
  171. * RBs), should be 8 after preparing the first 8 RBs (for example), and must
  172. * wrap back to 0 at the end of the circular buffer (but don't wrap before
  173. * "read" index has advanced past 1! See below).
  174. * NOTE: DEVICE EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8.
  175. *
  176. * As the device fills RBs (referenced from contiguous RBDs within the circular
  177. * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
  178. * to tell the driver the index of the latest filled RBD. The driver must
  179. * read this "read" index from DRAM after receiving an Rx interrupt from device
  180. *
  181. * The driver must also internally keep track of a third index, which is the
  182. * next RBD to process. When receiving an Rx interrupt, driver should process
  183. * all filled but unprocessed RBs up to, but not including, the RB
  184. * corresponding to the "read" index. For example, if "read" index becomes "1",
  185. * driver may process the RB pointed to by RBD 0. Depending on volume of
  186. * traffic, there may be many RBs to process.
  187. *
  188. * If read index == write index, device thinks there is no room to put new data.
  189. * Due to this, the maximum number of filled RBs is 255, instead of 256. To
  190. * be safe, make sure that there is a gap of at least 2 RBDs between "write"
  191. * and "read" indexes; that is, make sure that there are no more than 254
  192. * buffers waiting to be filled.
  193. */
  194. #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0)
  195. #define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00)
  196. #define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND)
  197. /**
  198. * Physical base address of 8-byte Rx Status buffer.
  199. * Bit fields:
  200. * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
  201. */
  202. #define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0)
  203. /**
  204. * Physical base address of Rx Buffer Descriptor Circular Buffer.
  205. * Bit fields:
  206. * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned.
  207. */
  208. #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004)
  209. /**
  210. * Rx write pointer (index, really!).
  211. * Bit fields:
  212. * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1.
  213. * NOTE: For 256-entry circular buffer, use only bits [7:0].
  214. */
  215. #define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008)
  216. #define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG)
  217. #define FW_RSCSR_CHNL0_RXDCB_RDPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x00c)
  218. #define FH_RSCSR_CHNL0_RDPTR FW_RSCSR_CHNL0_RXDCB_RDPTR_REG
  219. /**
  220. * Rx Config/Status Registers (RCSR)
  221. * Rx Config Reg for channel 0 (only channel used)
  222. *
  223. * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for
  224. * normal operation (see bit fields).
  225. *
  226. * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
  227. * Driver should poll FH_MEM_RSSR_RX_STATUS_REG for
  228. * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
  229. *
  230. * Bit fields:
  231. * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
  232. * '10' operate normally
  233. * 29-24: reserved
  234. * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
  235. * min "5" for 32 RBDs, max "12" for 4096 RBDs.
  236. * 19-18: reserved
  237. * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
  238. * '10' 12K, '11' 16K.
  239. * 15-14: reserved
  240. * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
  241. * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
  242. * typical value 0x10 (about 1/2 msec)
  243. * 3- 0: reserved
  244. */
  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. #define FH_MEM_RCSR_CHNL0_RBDCB_WPTR (FH_MEM_RCSR_CHNL0 + 0x8)
  250. #define FH_MEM_RCSR_CHNL0_FLUSH_RB_REQ (FH_MEM_RCSR_CHNL0 + 0x10)
  251. #define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */
  252. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */
  253. #define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */
  254. #define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */
  255. #define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */
  256. #define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/
  257. #define FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20)
  258. #define FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4)
  259. #define RX_RB_TIMEOUT (0x11)
  260. #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
  261. #define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
  262. #define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
  263. #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
  264. #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000)
  265. #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000)
  266. #define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000)
  267. #define FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004)
  268. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
  269. #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
  270. /**
  271. * Rx Shared Status Registers (RSSR)
  272. *
  273. * After stopping Rx DMA channel (writing 0 to
  274. * FH_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
  275. * FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
  276. *
  277. * Bit fields:
  278. * 24: 1 = Channel 0 is idle
  279. *
  280. * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
  281. * contain default values that should not be altered by the driver.
  282. */
  283. #define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40)
  284. #define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
  285. #define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND)
  286. #define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004)
  287. #define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
  288. (FH_MEM_RSSR_LOWER_BOUND + 0x008)
  289. #define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
  290. #define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
  291. #define FH_MEM_TB_MAX_LENGTH (0x00020000)
  292. /* 9000 rx series registers */
  293. #define RFH_Q0_FRBDCB_BA_LSB 0xA08000 /* 64 bit address */
  294. #define RFH_Q_FRBDCB_BA_LSB(q) (RFH_Q0_FRBDCB_BA_LSB + (q) * 8)
  295. /* Write index table */
  296. #define RFH_Q0_FRBDCB_WIDX 0xA08080
  297. #define RFH_Q_FRBDCB_WIDX(q) (RFH_Q0_FRBDCB_WIDX + (q) * 4)
  298. /* Read index table */
  299. #define RFH_Q0_FRBDCB_RIDX 0xA080C0
  300. #define RFH_Q_FRBDCB_RIDX(q) (RFH_Q0_FRBDCB_RIDX + (q) * 4)
  301. /* Used list table */
  302. #define RFH_Q0_URBDCB_BA_LSB 0xA08100 /* 64 bit address */
  303. #define RFH_Q_URBDCB_BA_LSB(q) (RFH_Q0_URBDCB_BA_LSB + (q) * 8)
  304. /* Write index table */
  305. #define RFH_Q0_URBDCB_WIDX 0xA08180
  306. #define RFH_Q_URBDCB_WIDX(q) (RFH_Q0_URBDCB_WIDX + (q) * 4)
  307. #define RFH_Q0_URBDCB_VAID 0xA081C0
  308. #define RFH_Q_URBDCB_VAID(q) (RFH_Q0_URBDCB_VAID + (q) * 4)
  309. /* stts */
  310. #define RFH_Q0_URBD_STTS_WPTR_LSB 0xA08200 /*64 bits address */
  311. #define RFH_Q_URBD_STTS_WPTR_LSB(q) (RFH_Q0_URBD_STTS_WPTR_LSB + (q) * 8)
  312. #define RFH_Q0_ORB_WPTR_LSB 0xA08280
  313. #define RFH_Q_ORB_WPTR_LSB(q) (RFH_Q0_ORB_WPTR_LSB + (q) * 8)
  314. #define RFH_RBDBUF_RBD0_LSB 0xA08300
  315. #define RFH_RBDBUF_RBD_LSB(q) (RFH_RBDBUF_RBD0_LSB + (q) * 8)
  316. /* DMA configuration */
  317. #define RFH_RXF_DMA_CFG 0xA09820
  318. /* RB size */
  319. #define RFH_RXF_DMA_RB_SIZE_MASK (0x000F0000) /* bits 16-19 */
  320. #define RFH_RXF_DMA_RB_SIZE_POS 16
  321. #define RFH_RXF_DMA_RB_SIZE_1K (0x1 << RFH_RXF_DMA_RB_SIZE_POS)
  322. #define RFH_RXF_DMA_RB_SIZE_2K (0x2 << RFH_RXF_DMA_RB_SIZE_POS)
  323. #define RFH_RXF_DMA_RB_SIZE_4K (0x4 << RFH_RXF_DMA_RB_SIZE_POS)
  324. #define RFH_RXF_DMA_RB_SIZE_8K (0x8 << RFH_RXF_DMA_RB_SIZE_POS)
  325. #define RFH_RXF_DMA_RB_SIZE_12K (0x9 << RFH_RXF_DMA_RB_SIZE_POS)
  326. #define RFH_RXF_DMA_RB_SIZE_16K (0xA << RFH_RXF_DMA_RB_SIZE_POS)
  327. #define RFH_RXF_DMA_RB_SIZE_20K (0xB << RFH_RXF_DMA_RB_SIZE_POS)
  328. #define RFH_RXF_DMA_RB_SIZE_24K (0xC << RFH_RXF_DMA_RB_SIZE_POS)
  329. #define RFH_RXF_DMA_RB_SIZE_28K (0xD << RFH_RXF_DMA_RB_SIZE_POS)
  330. #define RFH_RXF_DMA_RB_SIZE_32K (0xE << RFH_RXF_DMA_RB_SIZE_POS)
  331. /* RB Circular Buffer size:defines the table sizes in RBD units */
  332. #define RFH_RXF_DMA_RBDCB_SIZE_MASK (0x00F00000) /* bits 20-23 */
  333. #define RFH_RXF_DMA_RBDCB_SIZE_POS 20
  334. #define RFH_RXF_DMA_RBDCB_SIZE_8 (0x3 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  335. #define RFH_RXF_DMA_RBDCB_SIZE_16 (0x4 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  336. #define RFH_RXF_DMA_RBDCB_SIZE_32 (0x5 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  337. #define RFH_RXF_DMA_RBDCB_SIZE_64 (0x7 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  338. #define RFH_RXF_DMA_RBDCB_SIZE_128 (0x7 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  339. #define RFH_RXF_DMA_RBDCB_SIZE_256 (0x8 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  340. #define RFH_RXF_DMA_RBDCB_SIZE_512 (0x9 << RFH_RXF_DMA_RBDCB_SIZE_POS)
  341. #define RFH_RXF_DMA_RBDCB_SIZE_1024 (0xA << RFH_RXF_DMA_RBDCB_SIZE_POS)
  342. #define RFH_RXF_DMA_RBDCB_SIZE_2048 (0xB << RFH_RXF_DMA_RBDCB_SIZE_POS)
  343. #define RFH_RXF_DMA_MIN_RB_SIZE_MASK (0x03000000) /* bit 24-25 */
  344. #define RFH_RXF_DMA_MIN_RB_SIZE_POS 24
  345. #define RFH_RXF_DMA_MIN_RB_4_8 (3 << RFH_RXF_DMA_MIN_RB_SIZE_POS)
  346. #define RFH_RXF_DMA_DROP_TOO_LARGE_MASK (0x04000000) /* bit 26 */
  347. #define RFH_RXF_DMA_SINGLE_FRAME_MASK (0x20000000) /* bit 29 */
  348. #define RFH_DMA_EN_MASK (0xC0000000) /* bits 30-31*/
  349. #define RFH_DMA_EN_ENABLE_VAL BIT(31)
  350. #define RFH_RXF_RXQ_ACTIVE 0xA0980C
  351. #define RFH_GEN_CFG 0xA09800
  352. #define RFH_GEN_CFG_SERVICE_DMA_SNOOP BIT(0)
  353. #define RFH_GEN_CFG_RFH_DMA_SNOOP BIT(1)
  354. #define RFH_GEN_CFG_RB_CHUNK_SIZE BIT(4) /* 0 - 64B, 1- 128B */
  355. #define RFH_GEN_CFG_DEFAULT_RXQ_NUM_MASK 0xF00
  356. #define RFH_GEN_CFG_DEFAULT_RXQ_NUM_POS 8
  357. #define DEFAULT_RXQ_NUM 0
  358. /* end of 9000 rx series registers */
  359. /* TFDB Area - TFDs buffer table */
  360. #define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
  361. #define FH_TFDIB_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x900)
  362. #define FH_TFDIB_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x958)
  363. #define FH_TFDIB_CTRL0_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
  364. #define FH_TFDIB_CTRL1_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
  365. /**
  366. * Transmit DMA Channel Control/Status Registers (TCSR)
  367. *
  368. * Device has one configuration register for each of 8 Tx DMA/FIFO channels
  369. * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
  370. * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
  371. *
  372. * To use a Tx DMA channel, driver must initialize its
  373. * FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
  374. *
  375. * FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
  376. * FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
  377. *
  378. * All other bits should be 0.
  379. *
  380. * Bit fields:
  381. * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
  382. * '10' operate normally
  383. * 29- 4: Reserved, set to "0"
  384. * 3: Enable internal DMA requests (1, normal operation), disable (0)
  385. * 2- 0: Reserved, set to "0"
  386. */
  387. #define FH_TCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xD00)
  388. #define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60)
  389. /* Find Control/Status reg for given Tx DMA/FIFO channel */
  390. #define FH_TCSR_CHNL_NUM (8)
  391. /* TCSR: tx_config register values */
  392. #define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
  393. (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl))
  394. #define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \
  395. (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
  396. #define FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \
  397. (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
  398. #define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
  399. #define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001)
  400. #define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000)
  401. #define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008)
  402. #define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
  403. #define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
  404. #define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
  405. #define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
  406. #define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
  407. #define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
  408. #define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
  409. #define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
  410. #define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
  411. #define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
  412. #define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
  413. #define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
  414. #define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
  415. #define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
  416. /**
  417. * Tx Shared Status Registers (TSSR)
  418. *
  419. * After stopping Tx DMA channel (writing 0 to
  420. * FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
  421. * FH_TSSR_TX_STATUS_REG until selected Tx channel is idle
  422. * (channel's buffers empty | no pending requests).
  423. *
  424. * Bit fields:
  425. * 31-24: 1 = Channel buffers empty (channel 7:0)
  426. * 23-16: 1 = No pending requests (channel 7:0)
  427. */
  428. #define FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0)
  429. #define FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0)
  430. #define FH_TSSR_TX_STATUS_REG (FH_TSSR_LOWER_BOUND + 0x010)
  431. /**
  432. * Bit fields for TSSR(Tx Shared Status & Control) error status register:
  433. * 31: Indicates an address error when accessed to internal memory
  434. * uCode/driver must write "1" in order to clear this flag
  435. * 30: Indicates that Host did not send the expected number of dwords to FH
  436. * uCode/driver must write "1" in order to clear this flag
  437. * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
  438. * command was received from the scheduler while the TRB was already full
  439. * with previous command
  440. * uCode/driver must write "1" in order to clear this flag
  441. * 7-0: Each status bit indicates a channel's TxCredit error. When an error
  442. * bit is set, it indicates that the FH has received a full indication
  443. * from the RTC TxFIFO and the current value of the TxCredit counter was
  444. * not equal to zero. This mean that the credit mechanism was not
  445. * synchronized to the TxFIFO status
  446. * uCode/driver must write "1" in order to clear this flag
  447. */
  448. #define FH_TSSR_TX_ERROR_REG (FH_TSSR_LOWER_BOUND + 0x018)
  449. #define FH_TSSR_TX_MSG_CONFIG_REG (FH_TSSR_LOWER_BOUND + 0x008)
  450. #define FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
  451. /* Tx service channels */
  452. #define FH_SRVC_CHNL (9)
  453. #define FH_SRVC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9C8)
  454. #define FH_SRVC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0)
  455. #define FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
  456. (FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
  457. #define FH_TX_CHICKEN_BITS_REG (FH_MEM_LOWER_BOUND + 0xE98)
  458. #define FH_TX_TRB_REG(_chan) (FH_MEM_LOWER_BOUND + 0x958 + (_chan) * 4)
  459. /* Instruct FH to increment the retry count of a packet when
  460. * it is brought from the memory to TX-FIFO
  461. */
  462. #define FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002)
  463. #define MQ_RX_TABLE_SIZE 512
  464. #define MQ_RX_TABLE_MASK (MQ_RX_TABLE_SIZE - 1)
  465. #define MQ_RX_NUM_RBDS (MQ_RX_TABLE_SIZE - 1)
  466. #define RX_POOL_SIZE (MQ_RX_NUM_RBDS + \
  467. IWL_MAX_RX_HW_QUEUES * \
  468. (RX_CLAIM_REQ_ALLOC - RX_POST_REQ_ALLOC))
  469. #define RX_QUEUE_SIZE 256
  470. #define RX_QUEUE_MASK 255
  471. #define RX_QUEUE_SIZE_LOG 8
  472. /**
  473. * struct iwl_rb_status - reserve buffer status
  474. * host memory mapped FH registers
  475. * @closed_rb_num [0:11] - Indicates the index of the RB which was closed
  476. * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed
  477. * @finished_rb_num [0:11] - Indicates the index of the current RB
  478. * in which the last frame was written to
  479. * @finished_fr_num [0:11] - Indicates the index of the RX Frame
  480. * which was transferred
  481. */
  482. struct iwl_rb_status {
  483. __le16 closed_rb_num;
  484. __le16 closed_fr_num;
  485. __le16 finished_rb_num;
  486. __le16 finished_fr_nam;
  487. __le32 __unused;
  488. } __packed;
  489. #define TFD_QUEUE_SIZE_MAX (256)
  490. #define TFD_QUEUE_SIZE_BC_DUP (64)
  491. #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
  492. #define IWL_TX_DMA_MASK DMA_BIT_MASK(36)
  493. #define IWL_NUM_OF_TBS 20
  494. static inline u8 iwl_get_dma_hi_addr(dma_addr_t addr)
  495. {
  496. return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF;
  497. }
  498. /**
  499. * struct iwl_tfd_tb transmit buffer descriptor within transmit frame descriptor
  500. *
  501. * This structure contains dma address and length of transmission address
  502. *
  503. * @lo: low [31:0] portion of the dma address of TX buffer
  504. * every even is unaligned on 16 bit boundary
  505. * @hi_n_len 0-3 [35:32] portion of dma
  506. * 4-15 length of the tx buffer
  507. */
  508. struct iwl_tfd_tb {
  509. __le32 lo;
  510. __le16 hi_n_len;
  511. } __packed;
  512. /**
  513. * struct iwl_tfd
  514. *
  515. * Transmit Frame Descriptor (TFD)
  516. *
  517. * @ __reserved1[3] reserved
  518. * @ num_tbs 0-4 number of active tbs
  519. * 5 reserved
  520. * 6-7 padding (not used)
  521. * @ tbs[20] transmit frame buffer descriptors
  522. * @ __pad padding
  523. *
  524. * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
  525. * Both driver and device share these circular buffers, each of which must be
  526. * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
  527. *
  528. * Driver must indicate the physical address of the base of each
  529. * circular buffer via the FH_MEM_CBBC_QUEUE registers.
  530. *
  531. * Each TFD contains pointer/size information for up to 20 data buffers
  532. * in host DRAM. These buffers collectively contain the (one) frame described
  533. * by the TFD. Each buffer must be a single contiguous block of memory within
  534. * itself, but buffers may be scattered in host DRAM. Each buffer has max size
  535. * of (4K - 4). The concatenates all of a TFD's buffers into a single
  536. * Tx frame, up to 8 KBytes in size.
  537. *
  538. * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
  539. */
  540. struct iwl_tfd {
  541. u8 __reserved1[3];
  542. u8 num_tbs;
  543. struct iwl_tfd_tb tbs[IWL_NUM_OF_TBS];
  544. __le32 __pad;
  545. } __packed;
  546. /* Keep Warm Size */
  547. #define IWL_KW_SIZE 0x1000 /* 4k */
  548. /* Fixed (non-configurable) rx data from phy */
  549. /**
  550. * struct iwlagn_schedq_bc_tbl scheduler byte count table
  551. * base physical address provided by SCD_DRAM_BASE_ADDR
  552. * @tfd_offset 0-12 - tx command byte count
  553. * 12-16 - station index
  554. */
  555. struct iwlagn_scd_bc_tbl {
  556. __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
  557. } __packed;
  558. #endif /* !__iwl_fh_h__ */