iwl-prph.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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 - 2010 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. * Intel Linux Wireless <ilw@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 - 2010 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. #ifndef __iwl_prph_h__
  63. #define __iwl_prph_h__
  64. /*
  65. * Registers in this file are internal, not PCI bus memory mapped.
  66. * Driver accesses these via HBUS_TARG_PRPH_* registers.
  67. */
  68. #define PRPH_BASE (0x00000)
  69. #define PRPH_END (0xFFFFF)
  70. /* APMG (power management) constants */
  71. #define APMG_BASE (PRPH_BASE + 0x3000)
  72. #define APMG_CLK_CTRL_REG (APMG_BASE + 0x0000)
  73. #define APMG_CLK_EN_REG (APMG_BASE + 0x0004)
  74. #define APMG_CLK_DIS_REG (APMG_BASE + 0x0008)
  75. #define APMG_PS_CTRL_REG (APMG_BASE + 0x000c)
  76. #define APMG_PCIDEV_STT_REG (APMG_BASE + 0x0010)
  77. #define APMG_RFKILL_REG (APMG_BASE + 0x0014)
  78. #define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c)
  79. #define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020)
  80. #define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058)
  81. #define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C)
  82. #define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200)
  83. #define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800)
  84. #define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS (0x00400000)
  85. #define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000)
  86. #define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000)
  87. #define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000)
  88. #define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */
  89. #define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000)
  90. #define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */
  91. #define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060)
  92. #define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800)
  93. /**
  94. * BSM (Bootstrap State Machine)
  95. *
  96. * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program
  97. * in special SRAM that does not power down when the embedded control
  98. * processor is sleeping (e.g. for periodic power-saving shutdowns of radio).
  99. *
  100. * When powering back up after sleeps (or during initial uCode load), the BSM
  101. * internally loads the short bootstrap program from the special SRAM into the
  102. * embedded processor's instruction SRAM, and starts the processor so it runs
  103. * the bootstrap program.
  104. *
  105. * This bootstrap program loads (via PCI busmaster DMA) instructions and data
  106. * images for a uCode program from host DRAM locations. The host driver
  107. * indicates DRAM locations and sizes for instruction and data images via the
  108. * four BSM_DRAM_* registers. Once the bootstrap program loads the new program,
  109. * the new program starts automatically.
  110. *
  111. * The uCode used for open-source drivers includes two programs:
  112. *
  113. * 1) Initialization -- performs hardware calibration and sets up some
  114. * internal data, then notifies host via "initialize alive" notification
  115. * (struct iwl_init_alive_resp) that it has completed all of its work.
  116. * After signal from host, it then loads and starts the runtime program.
  117. * The initialization program must be used when initially setting up the
  118. * NIC after loading the driver.
  119. *
  120. * 2) Runtime/Protocol -- performs all normal runtime operations. This
  121. * notifies host via "alive" notification (struct iwl_alive_resp) that it
  122. * is ready to be used.
  123. *
  124. * When initializing the NIC, the host driver does the following procedure:
  125. *
  126. * 1) Load bootstrap program (instructions only, no data image for bootstrap)
  127. * into bootstrap memory. Use dword writes starting at BSM_SRAM_LOWER_BOUND
  128. *
  129. * 2) Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction
  130. * images in host DRAM.
  131. *
  132. * 3) Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked:
  133. * BSM_WR_MEM_SRC_REG = 0
  134. * BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND
  135. * BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image
  136. *
  137. * 4) Load bootstrap into instruction SRAM:
  138. * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START
  139. *
  140. * 5) Wait for load completion:
  141. * Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0
  142. *
  143. * 6) Enable future boot loads whenever NIC's power management triggers it:
  144. * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN
  145. *
  146. * 7) Start the NIC by removing all reset bits:
  147. * CSR_RESET = 0
  148. *
  149. * The bootstrap uCode (already in instruction SRAM) loads initialization
  150. * uCode. Initialization uCode performs data initialization, sends
  151. * "initialize alive" notification to host, and waits for a signal from
  152. * host to load runtime code.
  153. *
  154. * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction
  155. * images in host DRAM. The last register loaded must be the instruction
  156. * byte count register ("1" in MSbit tells initialization uCode to load
  157. * the runtime uCode):
  158. * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD
  159. *
  160. * 5) Wait for "alive" notification, then issue normal runtime commands.
  161. *
  162. * Data caching during power-downs:
  163. *
  164. * Just before the embedded controller powers down (e.g for automatic
  165. * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA)
  166. * a current snapshot of the embedded processor's data SRAM into host DRAM.
  167. * This caches the data while the embedded processor's memory is powered down.
  168. * Location and size are controlled by BSM_DRAM_DATA_* registers.
  169. *
  170. * NOTE: Instruction SRAM does not need to be saved, since that doesn't
  171. * change during operation; the original image (from uCode distribution
  172. * file) can be used for reload.
  173. *
  174. * When powering back up, the BSM loads the bootstrap program. Bootstrap looks
  175. * at the BSM_DRAM_* registers, which now point to the runtime instruction
  176. * image and the cached (modified) runtime data (*not* the initialization
  177. * uCode). Bootstrap reloads these runtime images into SRAM, and restarts the
  178. * uCode from where it left off before the power-down.
  179. *
  180. * NOTE: Initialization uCode does *not* run as part of the save/restore
  181. * procedure.
  182. *
  183. * This save/restore method is mostly for autonomous power management during
  184. * normal operation (result of POWER_TABLE_CMD). Platform suspend/resume and
  185. * RFKILL should use complete restarts (with total re-initialization) of uCode,
  186. * allowing total shutdown (including BSM memory).
  187. *
  188. * Note that, during normal operation, the host DRAM that held the initial
  189. * startup data for the runtime code is now being used as a backup data cache
  190. * for modified data! If you need to completely re-initialize the NIC, make
  191. * sure that you use the runtime data image from the uCode distribution file,
  192. * not the modified/saved runtime data. You may want to store a separate
  193. * "clean" runtime data image in DRAM to avoid disk reads of distribution file.
  194. */
  195. /* BSM bit fields */
  196. #define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */
  197. #define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/
  198. #define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */
  199. /* BSM addresses */
  200. #define BSM_BASE (PRPH_BASE + 0x3400)
  201. #define BSM_END (PRPH_BASE + 0x3800)
  202. #define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */
  203. #define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */
  204. #define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */
  205. #define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */
  206. #define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */
  207. /*
  208. * Pointers and size regs for bootstrap load and data SRAM save/restore.
  209. * NOTE: 3945 pointers use bits 31:0 of DRAM address.
  210. * 4965 pointers use bits 35:4 of DRAM address.
  211. */
  212. #define BSM_DRAM_INST_PTR_REG (BSM_BASE + 0x090)
  213. #define BSM_DRAM_INST_BYTECOUNT_REG (BSM_BASE + 0x094)
  214. #define BSM_DRAM_DATA_PTR_REG (BSM_BASE + 0x098)
  215. #define BSM_DRAM_DATA_BYTECOUNT_REG (BSM_BASE + 0x09C)
  216. /*
  217. * BSM special memory, stays powered on during power-save sleeps.
  218. * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1)
  219. */
  220. #define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800)
  221. #define BSM_SRAM_SIZE (1024) /* bytes */
  222. /* 3945 Tx scheduler registers */
  223. #define ALM_SCD_BASE (PRPH_BASE + 0x2E00)
  224. #define ALM_SCD_MODE_REG (ALM_SCD_BASE + 0x000)
  225. #define ALM_SCD_ARASTAT_REG (ALM_SCD_BASE + 0x004)
  226. #define ALM_SCD_TXFACT_REG (ALM_SCD_BASE + 0x010)
  227. #define ALM_SCD_TXF4MF_REG (ALM_SCD_BASE + 0x014)
  228. #define ALM_SCD_TXF5MF_REG (ALM_SCD_BASE + 0x020)
  229. #define ALM_SCD_SBYP_MODE_1_REG (ALM_SCD_BASE + 0x02C)
  230. #define ALM_SCD_SBYP_MODE_2_REG (ALM_SCD_BASE + 0x030)
  231. /**
  232. * Tx Scheduler
  233. *
  234. * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs
  235. * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in
  236. * host DRAM. It steers each frame's Tx command (which contains the frame
  237. * data) into one of up to 7 prioritized Tx DMA FIFO channels within the
  238. * device. A queue maps to only one (selectable by driver) Tx DMA channel,
  239. * but one DMA channel may take input from several queues.
  240. *
  241. * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows
  242. * (cf. default_queue_to_tx_fifo in iwl-4965.c):
  243. *
  244. * 0 -- EDCA BK (background) frames, lowest priority
  245. * 1 -- EDCA BE (best effort) frames, normal priority
  246. * 2 -- EDCA VI (video) frames, higher priority
  247. * 3 -- EDCA VO (voice) and management frames, highest priority
  248. * 4 -- Commands (e.g. RXON, etc.)
  249. * 5 -- unused (HCCA)
  250. * 6 -- unused (HCCA)
  251. * 7 -- not used by driver (device-internal only)
  252. *
  253. * For 5000 series and up, they are used differently
  254. * (cf. iwl5000_default_queue_to_tx_fifo in iwl-5000.c):
  255. *
  256. * 0 -- EDCA BK (background) frames, lowest priority
  257. * 1 -- EDCA BE (best effort) frames, normal priority
  258. * 2 -- EDCA VI (video) frames, higher priority
  259. * 3 -- EDCA VO (voice) and management frames, highest priority
  260. * 4 -- unused
  261. * 5 -- unused
  262. * 6 -- unused
  263. * 7 -- Commands
  264. *
  265. * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
  266. * In addition, driver can map the remaining queues to Tx DMA/FIFO
  267. * channels 0-3 to support 11n aggregation via EDCA DMA channels.
  268. *
  269. * The driver sets up each queue to work in one of two modes:
  270. *
  271. * 1) Scheduler-Ack, in which the scheduler automatically supports a
  272. * block-ack (BA) window of up to 64 TFDs. In this mode, each queue
  273. * contains TFDs for a unique combination of Recipient Address (RA)
  274. * and Traffic Identifier (TID), that is, traffic of a given
  275. * Quality-Of-Service (QOS) priority, destined for a single station.
  276. *
  277. * In scheduler-ack mode, the scheduler keeps track of the Tx status of
  278. * each frame within the BA window, including whether it's been transmitted,
  279. * and whether it's been acknowledged by the receiving station. The device
  280. * automatically processes block-acks received from the receiving STA,
  281. * and reschedules un-acked frames to be retransmitted (successful
  282. * Tx completion may end up being out-of-order).
  283. *
  284. * The driver must maintain the queue's Byte Count table in host DRAM
  285. * (struct iwl4965_sched_queue_byte_cnt_tbl) for this mode.
  286. * This mode does not support fragmentation.
  287. *
  288. * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
  289. * The device may automatically retry Tx, but will retry only one frame
  290. * at a time, until receiving ACK from receiving station, or reaching
  291. * retry limit and giving up.
  292. *
  293. * The command queue (#4/#9) must use this mode!
  294. * This mode does not require use of the Byte Count table in host DRAM.
  295. *
  296. * Driver controls scheduler operation via 3 means:
  297. * 1) Scheduler registers
  298. * 2) Shared scheduler data base in internal 4956 SRAM
  299. * 3) Shared data in host DRAM
  300. *
  301. * Initialization:
  302. *
  303. * When loading, driver should allocate memory for:
  304. * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs.
  305. * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory
  306. * (1024 bytes for each queue).
  307. *
  308. * After receiving "Alive" response from uCode, driver must initialize
  309. * the scheduler (especially for queue #4/#9, the command queue, otherwise
  310. * the driver can't issue commands!):
  311. */
  312. /**
  313. * Max Tx window size is the max number of contiguous TFDs that the scheduler
  314. * can keep track of at one time when creating block-ack chains of frames.
  315. * Note that "64" matches the number of ack bits in a block-ack packet.
  316. * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize
  317. * IWL49_SCD_CONTEXT_QUEUE_OFFSET(x) values.
  318. */
  319. #define SCD_WIN_SIZE 64
  320. #define SCD_FRAME_LIMIT 64
  321. /* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */
  322. #define IWL49_SCD_START_OFFSET 0xa02c00
  323. /*
  324. * 4965 tells driver SRAM address for internal scheduler structs via this reg.
  325. * Value is valid only after "Alive" response from uCode.
  326. */
  327. #define IWL49_SCD_SRAM_BASE_ADDR (IWL49_SCD_START_OFFSET + 0x0)
  328. /*
  329. * Driver may need to update queue-empty bits after changing queue's
  330. * write and read pointers (indexes) during (re-)initialization (i.e. when
  331. * scheduler is not tracking what's happening).
  332. * Bit fields:
  333. * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit
  334. * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty
  335. * NOTE: This register is not used by Linux driver.
  336. */
  337. #define IWL49_SCD_EMPTY_BITS (IWL49_SCD_START_OFFSET + 0x4)
  338. /*
  339. * Physical base address of array of byte count (BC) circular buffers (CBs).
  340. * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode.
  341. * This register points to BC CB for queue 0, must be on 1024-byte boundary.
  342. * Others are spaced by 1024 bytes.
  343. * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad.
  344. * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff).
  345. * Bit fields:
  346. * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned.
  347. */
  348. #define IWL49_SCD_DRAM_BASE_ADDR (IWL49_SCD_START_OFFSET + 0x10)
  349. /*
  350. * Enables any/all Tx DMA/FIFO channels.
  351. * Scheduler generates requests for only the active channels.
  352. * Set this to 0xff to enable all 8 channels (normal usage).
  353. * Bit fields:
  354. * 7- 0: Enable (1), disable (0), one bit for each channel 0-7
  355. */
  356. #define IWL49_SCD_TXFACT (IWL49_SCD_START_OFFSET + 0x1c)
  357. /*
  358. * Queue (x) Write Pointers (indexes, really!), one for each Tx queue.
  359. * Initialized and updated by driver as new TFDs are added to queue.
  360. * NOTE: If using Block Ack, index must correspond to frame's
  361. * Start Sequence Number; index = (SSN & 0xff)
  362. * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses?
  363. */
  364. #define IWL49_SCD_QUEUE_WRPTR(x) (IWL49_SCD_START_OFFSET + 0x24 + (x) * 4)
  365. /*
  366. * Queue (x) Read Pointers (indexes, really!), one for each Tx queue.
  367. * For FIFO mode, index indicates next frame to transmit.
  368. * For Scheduler-ACK mode, index indicates first frame in Tx window.
  369. * Initialized by driver, updated by scheduler.
  370. */
  371. #define IWL49_SCD_QUEUE_RDPTR(x) (IWL49_SCD_START_OFFSET + 0x64 + (x) * 4)
  372. /*
  373. * Select which queues work in chain mode (1) vs. not (0).
  374. * Use chain mode to build chains of aggregated frames.
  375. * Bit fields:
  376. * 31-16: Reserved
  377. * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time
  378. * NOTE: If driver sets up queue for chain mode, it should be also set up
  379. * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x).
  380. */
  381. #define IWL49_SCD_QUEUECHAIN_SEL (IWL49_SCD_START_OFFSET + 0xd0)
  382. /*
  383. * Select which queues interrupt driver when scheduler increments
  384. * a queue's read pointer (index).
  385. * Bit fields:
  386. * 31-16: Reserved
  387. * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled
  388. * NOTE: This functionality is apparently a no-op; driver relies on interrupts
  389. * from Rx queue to read Tx command responses and update Tx queues.
  390. */
  391. #define IWL49_SCD_INTERRUPT_MASK (IWL49_SCD_START_OFFSET + 0xe4)
  392. /*
  393. * Queue search status registers. One for each queue.
  394. * Sets up queue mode and assigns queue to Tx DMA channel.
  395. * Bit fields:
  396. * 19-10: Write mask/enable bits for bits 0-9
  397. * 9: Driver should init to "0"
  398. * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0).
  399. * Driver should init to "1" for aggregation mode, or "0" otherwise.
  400. * 7-6: Driver should init to "0"
  401. * 5: Window Size Left; indicates whether scheduler can request
  402. * another TFD, based on window size, etc. Driver should init
  403. * this bit to "1" for aggregation mode, or "0" for non-agg.
  404. * 4-1: Tx FIFO to use (range 0-7).
  405. * 0: Queue is active (1), not active (0).
  406. * Other bits should be written as "0"
  407. *
  408. * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled
  409. * via SCD_QUEUECHAIN_SEL.
  410. */
  411. #define IWL49_SCD_QUEUE_STATUS_BITS(x)\
  412. (IWL49_SCD_START_OFFSET + 0x104 + (x) * 4)
  413. /* Bit field positions */
  414. #define IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0)
  415. #define IWL49_SCD_QUEUE_STTS_REG_POS_TXF (1)
  416. #define IWL49_SCD_QUEUE_STTS_REG_POS_WSL (5)
  417. #define IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8)
  418. /* Write masks */
  419. #define IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10)
  420. #define IWL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00)
  421. /**
  422. * 4965 internal SRAM structures for scheduler, shared with driver ...
  423. *
  424. * Driver should clear and initialize the following areas after receiving
  425. * "Alive" response from 4965 uCode, i.e. after initial
  426. * uCode load, or after a uCode load done for error recovery:
  427. *
  428. * SCD_CONTEXT_DATA_OFFSET (size 128 bytes)
  429. * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes)
  430. * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
  431. *
  432. * Driver accesses SRAM via HBUS_TARG_MEM_* registers.
  433. * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR.
  434. * All OFFSET values must be added to this base address.
  435. */
  436. /*
  437. * Queue context. One 8-byte entry for each of 16 queues.
  438. *
  439. * Driver should clear this entire area (size 0x80) to 0 after receiving
  440. * "Alive" notification from uCode. Additionally, driver should init
  441. * each queue's entry as follows:
  442. *
  443. * LS Dword bit fields:
  444. * 0-06: Max Tx window size for Scheduler-ACK. Driver should init to 64.
  445. *
  446. * MS Dword bit fields:
  447. * 16-22: Frame limit. Driver should init to 10 (0xa).
  448. *
  449. * Driver should init all other bits to 0.
  450. *
  451. * Init must be done after driver receives "Alive" response from 4965 uCode,
  452. * and when setting up queue for aggregation.
  453. */
  454. #define IWL49_SCD_CONTEXT_DATA_OFFSET 0x380
  455. #define IWL49_SCD_CONTEXT_QUEUE_OFFSET(x) \
  456. (IWL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
  457. #define IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0)
  458. #define IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F)
  459. #define IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
  460. #define IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
  461. /*
  462. * Tx Status Bitmap
  463. *
  464. * Driver should clear this entire area (size 0x100) to 0 after receiving
  465. * "Alive" notification from uCode. Area is used only by device itself;
  466. * no other support (besides clearing) is required from driver.
  467. */
  468. #define IWL49_SCD_TX_STTS_BITMAP_OFFSET 0x400
  469. /*
  470. * RAxTID to queue translation mapping.
  471. *
  472. * When queue is in Scheduler-ACK mode, frames placed in a that queue must be
  473. * for only one combination of receiver address (RA) and traffic ID (TID), i.e.
  474. * one QOS priority level destined for one station (for this wireless link,
  475. * not final destination). The SCD_TRANSLATE_TABLE area provides 16 16-bit
  476. * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK
  477. * mode, the device ignores the mapping value.
  478. *
  479. * Bit fields, for each 16-bit map:
  480. * 15-9: Reserved, set to 0
  481. * 8-4: Index into device's station table for recipient station
  482. * 3-0: Traffic ID (tid), range 0-15
  483. *
  484. * Driver should clear this entire area (size 32 bytes) to 0 after receiving
  485. * "Alive" notification from uCode. To update a 16-bit map value, driver
  486. * must read a dword-aligned value from device SRAM, replace the 16-bit map
  487. * value of interest, and write the dword value back into device SRAM.
  488. */
  489. #define IWL49_SCD_TRANSLATE_TBL_OFFSET 0x500
  490. /* Find translation table dword to read/write for given queue */
  491. #define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
  492. ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
  493. #define IWL_SCD_TXFIFO_POS_TID (0)
  494. #define IWL_SCD_TXFIFO_POS_RA (4)
  495. #define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF)
  496. /* agn SCD */
  497. #define IWLAGN_SCD_QUEUE_STTS_REG_POS_TXF (0)
  498. #define IWLAGN_SCD_QUEUE_STTS_REG_POS_ACTIVE (3)
  499. #define IWLAGN_SCD_QUEUE_STTS_REG_POS_WSL (4)
  500. #define IWLAGN_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (19)
  501. #define IWLAGN_SCD_QUEUE_STTS_REG_MSK (0x00FF0000)
  502. #define IWLAGN_SCD_QUEUE_CTX_REG1_CREDIT_POS (8)
  503. #define IWLAGN_SCD_QUEUE_CTX_REG1_CREDIT_MSK (0x00FFFF00)
  504. #define IWLAGN_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_POS (24)
  505. #define IWLAGN_SCD_QUEUE_CTX_REG1_SUPER_CREDIT_MSK (0xFF000000)
  506. #define IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_POS (0)
  507. #define IWLAGN_SCD_QUEUE_CTX_REG2_WIN_SIZE_MSK (0x0000007F)
  508. #define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16)
  509. #define IWLAGN_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000)
  510. #define IWLAGN_SCD_CONTEXT_DATA_OFFSET (0x600)
  511. #define IWLAGN_SCD_TX_STTS_BITMAP_OFFSET (0x7B1)
  512. #define IWLAGN_SCD_TRANSLATE_TBL_OFFSET (0x7E0)
  513. #define IWLAGN_SCD_CONTEXT_QUEUE_OFFSET(x)\
  514. (IWLAGN_SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
  515. #define IWLAGN_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
  516. ((IWLAGN_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffc)
  517. #define IWLAGN_SCD_QUEUECHAIN_SEL_ALL(priv) \
  518. (((1<<(priv)->hw_params.max_txq_num) - 1) &\
  519. (~(1<<(priv)->cmd_queue)))
  520. #define IWLAGN_SCD_BASE (PRPH_BASE + 0xa02c00)
  521. #define IWLAGN_SCD_SRAM_BASE_ADDR (IWLAGN_SCD_BASE + 0x0)
  522. #define IWLAGN_SCD_DRAM_BASE_ADDR (IWLAGN_SCD_BASE + 0x8)
  523. #define IWLAGN_SCD_AIT (IWLAGN_SCD_BASE + 0x0c)
  524. #define IWLAGN_SCD_TXFACT (IWLAGN_SCD_BASE + 0x10)
  525. #define IWLAGN_SCD_ACTIVE (IWLAGN_SCD_BASE + 0x14)
  526. #define IWLAGN_SCD_QUEUE_WRPTR(x) (IWLAGN_SCD_BASE + 0x18 + (x) * 4)
  527. #define IWLAGN_SCD_QUEUE_RDPTR(x) (IWLAGN_SCD_BASE + 0x68 + (x) * 4)
  528. #define IWLAGN_SCD_QUEUECHAIN_SEL (IWLAGN_SCD_BASE + 0xe8)
  529. #define IWLAGN_SCD_AGGR_SEL (IWLAGN_SCD_BASE + 0x248)
  530. #define IWLAGN_SCD_INTERRUPT_MASK (IWLAGN_SCD_BASE + 0x108)
  531. #define IWLAGN_SCD_QUEUE_STATUS_BITS(x) (IWLAGN_SCD_BASE + 0x10c + (x) * 4)
  532. /*********************** END TX SCHEDULER *************************************/
  533. #endif /* __iwl_prph_h__ */