xref: /openbmc/linux/drivers/net/wireless/intel/iwlegacy/prph.h (revision 9938b04472d5c59f8bd8152a548533a8599596a2)
1*7ac9a364SKalle Valo /******************************************************************************
2*7ac9a364SKalle Valo  *
3*7ac9a364SKalle Valo  * This file is provided under a dual BSD/GPLv2 license.  When using or
4*7ac9a364SKalle Valo  * redistributing this file, you may do so under either license.
5*7ac9a364SKalle Valo  *
6*7ac9a364SKalle Valo  * GPL LICENSE SUMMARY
7*7ac9a364SKalle Valo  *
8*7ac9a364SKalle Valo  * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
9*7ac9a364SKalle Valo  *
10*7ac9a364SKalle Valo  * This program is free software; you can redistribute it and/or modify
11*7ac9a364SKalle Valo  * it under the terms of version 2 of the GNU General Public License as
12*7ac9a364SKalle Valo  * published by the Free Software Foundation.
13*7ac9a364SKalle Valo  *
14*7ac9a364SKalle Valo  * This program is distributed in the hope that it will be useful, but
15*7ac9a364SKalle Valo  * WITHOUT ANY WARRANTY; without even the implied warranty of
16*7ac9a364SKalle Valo  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17*7ac9a364SKalle Valo  * General Public License for more details.
18*7ac9a364SKalle Valo  *
19*7ac9a364SKalle Valo  * You should have received a copy of the GNU General Public License
20*7ac9a364SKalle Valo  * along with this program; if not, write to the Free Software
21*7ac9a364SKalle Valo  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
22*7ac9a364SKalle Valo  * USA
23*7ac9a364SKalle Valo  *
24*7ac9a364SKalle Valo  * The full GNU General Public License is included in this distribution
25*7ac9a364SKalle Valo  * in the file called LICENSE.GPL.
26*7ac9a364SKalle Valo  *
27*7ac9a364SKalle Valo  * Contact Information:
28*7ac9a364SKalle Valo  *  Intel Linux Wireless <ilw@linux.intel.com>
29*7ac9a364SKalle Valo  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30*7ac9a364SKalle Valo  *
31*7ac9a364SKalle Valo  * BSD LICENSE
32*7ac9a364SKalle Valo  *
33*7ac9a364SKalle Valo  * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved.
34*7ac9a364SKalle Valo  * All rights reserved.
35*7ac9a364SKalle Valo  *
36*7ac9a364SKalle Valo  * Redistribution and use in source and binary forms, with or without
37*7ac9a364SKalle Valo  * modification, are permitted provided that the following conditions
38*7ac9a364SKalle Valo  * are met:
39*7ac9a364SKalle Valo  *
40*7ac9a364SKalle Valo  *  * Redistributions of source code must retain the above copyright
41*7ac9a364SKalle Valo  *    notice, this list of conditions and the following disclaimer.
42*7ac9a364SKalle Valo  *  * Redistributions in binary form must reproduce the above copyright
43*7ac9a364SKalle Valo  *    notice, this list of conditions and the following disclaimer in
44*7ac9a364SKalle Valo  *    the documentation and/or other materials provided with the
45*7ac9a364SKalle Valo  *    distribution.
46*7ac9a364SKalle Valo  *  * Neither the name Intel Corporation nor the names of its
47*7ac9a364SKalle Valo  *    contributors may be used to endorse or promote products derived
48*7ac9a364SKalle Valo  *    from this software without specific prior written permission.
49*7ac9a364SKalle Valo  *
50*7ac9a364SKalle Valo  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
51*7ac9a364SKalle Valo  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
52*7ac9a364SKalle Valo  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
53*7ac9a364SKalle Valo  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
54*7ac9a364SKalle Valo  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55*7ac9a364SKalle Valo  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
56*7ac9a364SKalle Valo  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
57*7ac9a364SKalle Valo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
58*7ac9a364SKalle Valo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
59*7ac9a364SKalle Valo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
60*7ac9a364SKalle Valo  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
61*7ac9a364SKalle Valo  *****************************************************************************/
62*7ac9a364SKalle Valo 
63*7ac9a364SKalle Valo #ifndef	__il_prph_h__
64*7ac9a364SKalle Valo #define __il_prph_h__
65*7ac9a364SKalle Valo 
66*7ac9a364SKalle Valo /*
67*7ac9a364SKalle Valo  * Registers in this file are internal, not PCI bus memory mapped.
68*7ac9a364SKalle Valo  * Driver accesses these via HBUS_TARG_PRPH_* registers.
69*7ac9a364SKalle Valo  */
70*7ac9a364SKalle Valo #define PRPH_BASE	(0x00000)
71*7ac9a364SKalle Valo #define PRPH_END	(0xFFFFF)
72*7ac9a364SKalle Valo 
73*7ac9a364SKalle Valo /* APMG (power management) constants */
74*7ac9a364SKalle Valo #define APMG_BASE			(PRPH_BASE + 0x3000)
75*7ac9a364SKalle Valo #define APMG_CLK_CTRL_REG		(APMG_BASE + 0x0000)
76*7ac9a364SKalle Valo #define APMG_CLK_EN_REG			(APMG_BASE + 0x0004)
77*7ac9a364SKalle Valo #define APMG_CLK_DIS_REG		(APMG_BASE + 0x0008)
78*7ac9a364SKalle Valo #define APMG_PS_CTRL_REG		(APMG_BASE + 0x000c)
79*7ac9a364SKalle Valo #define APMG_PCIDEV_STT_REG		(APMG_BASE + 0x0010)
80*7ac9a364SKalle Valo #define APMG_RFKILL_REG			(APMG_BASE + 0x0014)
81*7ac9a364SKalle Valo #define APMG_RTC_INT_STT_REG		(APMG_BASE + 0x001c)
82*7ac9a364SKalle Valo #define APMG_RTC_INT_MSK_REG		(APMG_BASE + 0x0020)
83*7ac9a364SKalle Valo #define APMG_DIGITAL_SVR_REG		(APMG_BASE + 0x0058)
84*7ac9a364SKalle Valo #define APMG_ANALOG_SVR_REG		(APMG_BASE + 0x006C)
85*7ac9a364SKalle Valo 
86*7ac9a364SKalle Valo #define APMS_CLK_VAL_MRB_FUNC_MODE	(0x00000001)
87*7ac9a364SKalle Valo #define APMG_CLK_VAL_DMA_CLK_RQT	(0x00000200)
88*7ac9a364SKalle Valo #define APMG_CLK_VAL_BSM_CLK_RQT	(0x00000800)
89*7ac9a364SKalle Valo 
90*7ac9a364SKalle Valo #define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS	(0x00400000)
91*7ac9a364SKalle Valo #define APMG_PS_CTRL_VAL_RESET_REQ		(0x04000000)
92*7ac9a364SKalle Valo #define APMG_PS_CTRL_MSK_PWR_SRC		(0x03000000)
93*7ac9a364SKalle Valo #define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN		(0x00000000)
94*7ac9a364SKalle Valo #define APMG_PS_CTRL_VAL_PWR_SRC_MAX		(0x01000000)	/* 3945 only */
95*7ac9a364SKalle Valo #define APMG_PS_CTRL_VAL_PWR_SRC_VAUX		(0x02000000)
96*7ac9a364SKalle Valo #define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK	(0x000001E0)	/* bit 8:5 */
97*7ac9a364SKalle Valo #define APMG_SVR_DIGITAL_VOLTAGE_1_32		(0x00000060)
98*7ac9a364SKalle Valo 
99*7ac9a364SKalle Valo #define APMG_PCIDEV_STT_VAL_L1_ACT_DIS		(0x00000800)
100*7ac9a364SKalle Valo 
101*7ac9a364SKalle Valo /**
102*7ac9a364SKalle Valo  * BSM (Bootstrap State Machine)
103*7ac9a364SKalle Valo  *
104*7ac9a364SKalle Valo  * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program
105*7ac9a364SKalle Valo  * in special SRAM that does not power down when the embedded control
106*7ac9a364SKalle Valo  * processor is sleeping (e.g. for periodic power-saving shutdowns of radio).
107*7ac9a364SKalle Valo  *
108*7ac9a364SKalle Valo  * When powering back up after sleeps (or during initial uCode load), the BSM
109*7ac9a364SKalle Valo  * internally loads the short bootstrap program from the special SRAM into the
110*7ac9a364SKalle Valo  * embedded processor's instruction SRAM, and starts the processor so it runs
111*7ac9a364SKalle Valo  * the bootstrap program.
112*7ac9a364SKalle Valo  *
113*7ac9a364SKalle Valo  * This bootstrap program loads (via PCI busmaster DMA) instructions and data
114*7ac9a364SKalle Valo  * images for a uCode program from host DRAM locations.  The host driver
115*7ac9a364SKalle Valo  * indicates DRAM locations and sizes for instruction and data images via the
116*7ac9a364SKalle Valo  * four BSM_DRAM_* registers.  Once the bootstrap program loads the new program,
117*7ac9a364SKalle Valo  * the new program starts automatically.
118*7ac9a364SKalle Valo  *
119*7ac9a364SKalle Valo  * The uCode used for open-source drivers includes two programs:
120*7ac9a364SKalle Valo  *
121*7ac9a364SKalle Valo  * 1)  Initialization -- performs hardware calibration and sets up some
122*7ac9a364SKalle Valo  *     internal data, then notifies host via "initialize alive" notification
123*7ac9a364SKalle Valo  *     (struct il_init_alive_resp) that it has completed all of its work.
124*7ac9a364SKalle Valo  *     After signal from host, it then loads and starts the runtime program.
125*7ac9a364SKalle Valo  *     The initialization program must be used when initially setting up the
126*7ac9a364SKalle Valo  *     NIC after loading the driver.
127*7ac9a364SKalle Valo  *
128*7ac9a364SKalle Valo  * 2)  Runtime/Protocol -- performs all normal runtime operations.  This
129*7ac9a364SKalle Valo  *     notifies host via "alive" notification (struct il_alive_resp) that it
130*7ac9a364SKalle Valo  *     is ready to be used.
131*7ac9a364SKalle Valo  *
132*7ac9a364SKalle Valo  * When initializing the NIC, the host driver does the following procedure:
133*7ac9a364SKalle Valo  *
134*7ac9a364SKalle Valo  * 1)  Load bootstrap program (instructions only, no data image for bootstrap)
135*7ac9a364SKalle Valo  *     into bootstrap memory.  Use dword writes starting at BSM_SRAM_LOWER_BOUND
136*7ac9a364SKalle Valo  *
137*7ac9a364SKalle Valo  * 2)  Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction
138*7ac9a364SKalle Valo  *     images in host DRAM.
139*7ac9a364SKalle Valo  *
140*7ac9a364SKalle Valo  * 3)  Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked:
141*7ac9a364SKalle Valo  *     BSM_WR_MEM_SRC_REG = 0
142*7ac9a364SKalle Valo  *     BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND
143*7ac9a364SKalle Valo  *     BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image
144*7ac9a364SKalle Valo  *
145*7ac9a364SKalle Valo  * 4)  Load bootstrap into instruction SRAM:
146*7ac9a364SKalle Valo  *     BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START
147*7ac9a364SKalle Valo  *
148*7ac9a364SKalle Valo  * 5)  Wait for load completion:
149*7ac9a364SKalle Valo  *     Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0
150*7ac9a364SKalle Valo  *
151*7ac9a364SKalle Valo  * 6)  Enable future boot loads whenever NIC's power management triggers it:
152*7ac9a364SKalle Valo  *     BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN
153*7ac9a364SKalle Valo  *
154*7ac9a364SKalle Valo  * 7)  Start the NIC by removing all reset bits:
155*7ac9a364SKalle Valo  *     CSR_RESET = 0
156*7ac9a364SKalle Valo  *
157*7ac9a364SKalle Valo  *     The bootstrap uCode (already in instruction SRAM) loads initialization
158*7ac9a364SKalle Valo  *     uCode.  Initialization uCode performs data initialization, sends
159*7ac9a364SKalle Valo  *     "initialize alive" notification to host, and waits for a signal from
160*7ac9a364SKalle Valo  *     host to load runtime code.
161*7ac9a364SKalle Valo  *
162*7ac9a364SKalle Valo  * 4)  Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction
163*7ac9a364SKalle Valo  *     images in host DRAM.  The last register loaded must be the instruction
164*7ac9a364SKalle Valo  *     byte count register ("1" in MSbit tells initialization uCode to load
165*7ac9a364SKalle Valo  *     the runtime uCode):
166*7ac9a364SKalle Valo  *     BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD
167*7ac9a364SKalle Valo  *
168*7ac9a364SKalle Valo  * 5)  Wait for "alive" notification, then issue normal runtime commands.
169*7ac9a364SKalle Valo  *
170*7ac9a364SKalle Valo  * Data caching during power-downs:
171*7ac9a364SKalle Valo  *
172*7ac9a364SKalle Valo  * Just before the embedded controller powers down (e.g for automatic
173*7ac9a364SKalle Valo  * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA)
174*7ac9a364SKalle Valo  * a current snapshot of the embedded processor's data SRAM into host DRAM.
175*7ac9a364SKalle Valo  * This caches the data while the embedded processor's memory is powered down.
176*7ac9a364SKalle Valo  * Location and size are controlled by BSM_DRAM_DATA_* registers.
177*7ac9a364SKalle Valo  *
178*7ac9a364SKalle Valo  * NOTE:  Instruction SRAM does not need to be saved, since that doesn't
179*7ac9a364SKalle Valo  *        change during operation; the original image (from uCode distribution
180*7ac9a364SKalle Valo  *        file) can be used for reload.
181*7ac9a364SKalle Valo  *
182*7ac9a364SKalle Valo  * When powering back up, the BSM loads the bootstrap program.  Bootstrap looks
183*7ac9a364SKalle Valo  * at the BSM_DRAM_* registers, which now point to the runtime instruction
184*7ac9a364SKalle Valo  * image and the cached (modified) runtime data (*not* the initialization
185*7ac9a364SKalle Valo  * uCode).  Bootstrap reloads these runtime images into SRAM, and restarts the
186*7ac9a364SKalle Valo  * uCode from where it left off before the power-down.
187*7ac9a364SKalle Valo  *
188*7ac9a364SKalle Valo  * NOTE:  Initialization uCode does *not* run as part of the save/restore
189*7ac9a364SKalle Valo  *        procedure.
190*7ac9a364SKalle Valo  *
191*7ac9a364SKalle Valo  * This save/restore method is mostly for autonomous power management during
192*7ac9a364SKalle Valo  * normal operation (result of C_POWER_TBL).  Platform suspend/resume and
193*7ac9a364SKalle Valo  * RFKILL should use complete restarts (with total re-initialization) of uCode,
194*7ac9a364SKalle Valo  * allowing total shutdown (including BSM memory).
195*7ac9a364SKalle Valo  *
196*7ac9a364SKalle Valo  * Note that, during normal operation, the host DRAM that held the initial
197*7ac9a364SKalle Valo  * startup data for the runtime code is now being used as a backup data cache
198*7ac9a364SKalle Valo  * for modified data!  If you need to completely re-initialize the NIC, make
199*7ac9a364SKalle Valo  * sure that you use the runtime data image from the uCode distribution file,
200*7ac9a364SKalle Valo  * not the modified/saved runtime data.  You may want to store a separate
201*7ac9a364SKalle Valo  * "clean" runtime data image in DRAM to avoid disk reads of distribution file.
202*7ac9a364SKalle Valo  */
203*7ac9a364SKalle Valo 
204*7ac9a364SKalle Valo /* BSM bit fields */
205*7ac9a364SKalle Valo #define BSM_WR_CTRL_REG_BIT_START     (0x80000000)	/* start boot load now */
206*7ac9a364SKalle Valo #define BSM_WR_CTRL_REG_BIT_START_EN  (0x40000000)	/* enable boot after pwrup */
207*7ac9a364SKalle Valo #define BSM_DRAM_INST_LOAD            (0x80000000)	/* start program load now */
208*7ac9a364SKalle Valo 
209*7ac9a364SKalle Valo /* BSM addresses */
210*7ac9a364SKalle Valo #define BSM_BASE                     (PRPH_BASE + 0x3400)
211*7ac9a364SKalle Valo #define BSM_END                      (PRPH_BASE + 0x3800)
212*7ac9a364SKalle Valo 
213*7ac9a364SKalle Valo #define BSM_WR_CTRL_REG              (BSM_BASE + 0x000)	/* ctl and status */
214*7ac9a364SKalle Valo #define BSM_WR_MEM_SRC_REG           (BSM_BASE + 0x004)	/* source in BSM mem */
215*7ac9a364SKalle Valo #define BSM_WR_MEM_DST_REG           (BSM_BASE + 0x008)	/* dest in SRAM mem */
216*7ac9a364SKalle Valo #define BSM_WR_DWCOUNT_REG           (BSM_BASE + 0x00C)	/* bytes */
217*7ac9a364SKalle Valo #define BSM_WR_STATUS_REG            (BSM_BASE + 0x010)	/* bit 0:  1 == done */
218*7ac9a364SKalle Valo 
219*7ac9a364SKalle Valo /*
220*7ac9a364SKalle Valo  * Pointers and size regs for bootstrap load and data SRAM save/restore.
221*7ac9a364SKalle Valo  * NOTE:  3945 pointers use bits 31:0 of DRAM address.
222*7ac9a364SKalle Valo  *        4965 pointers use bits 35:4 of DRAM address.
223*7ac9a364SKalle Valo  */
224*7ac9a364SKalle Valo #define BSM_DRAM_INST_PTR_REG        (BSM_BASE + 0x090)
225*7ac9a364SKalle Valo #define BSM_DRAM_INST_BYTECOUNT_REG  (BSM_BASE + 0x094)
226*7ac9a364SKalle Valo #define BSM_DRAM_DATA_PTR_REG        (BSM_BASE + 0x098)
227*7ac9a364SKalle Valo #define BSM_DRAM_DATA_BYTECOUNT_REG  (BSM_BASE + 0x09C)
228*7ac9a364SKalle Valo 
229*7ac9a364SKalle Valo /*
230*7ac9a364SKalle Valo  * BSM special memory, stays powered on during power-save sleeps.
231*7ac9a364SKalle Valo  * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1)
232*7ac9a364SKalle Valo  */
233*7ac9a364SKalle Valo #define BSM_SRAM_LOWER_BOUND         (PRPH_BASE + 0x3800)
234*7ac9a364SKalle Valo #define BSM_SRAM_SIZE			(1024)	/* bytes */
235*7ac9a364SKalle Valo 
236*7ac9a364SKalle Valo /* 3945 Tx scheduler registers */
237*7ac9a364SKalle Valo #define ALM_SCD_BASE                        (PRPH_BASE + 0x2E00)
238*7ac9a364SKalle Valo #define ALM_SCD_MODE_REG                    (ALM_SCD_BASE + 0x000)
239*7ac9a364SKalle Valo #define ALM_SCD_ARASTAT_REG                 (ALM_SCD_BASE + 0x004)
240*7ac9a364SKalle Valo #define ALM_SCD_TXFACT_REG                  (ALM_SCD_BASE + 0x010)
241*7ac9a364SKalle Valo #define ALM_SCD_TXF4MF_REG                  (ALM_SCD_BASE + 0x014)
242*7ac9a364SKalle Valo #define ALM_SCD_TXF5MF_REG                  (ALM_SCD_BASE + 0x020)
243*7ac9a364SKalle Valo #define ALM_SCD_SBYP_MODE_1_REG             (ALM_SCD_BASE + 0x02C)
244*7ac9a364SKalle Valo #define ALM_SCD_SBYP_MODE_2_REG             (ALM_SCD_BASE + 0x030)
245*7ac9a364SKalle Valo 
246*7ac9a364SKalle Valo /**
247*7ac9a364SKalle Valo  * Tx Scheduler
248*7ac9a364SKalle Valo  *
249*7ac9a364SKalle Valo  * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs
250*7ac9a364SKalle Valo  * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in
251*7ac9a364SKalle Valo  * host DRAM.  It steers each frame's Tx command (which contains the frame
252*7ac9a364SKalle Valo  * data) into one of up to 7 prioritized Tx DMA FIFO channels within the
253*7ac9a364SKalle Valo  * device.  A queue maps to only one (selectable by driver) Tx DMA channel,
254*7ac9a364SKalle Valo  * but one DMA channel may take input from several queues.
255*7ac9a364SKalle Valo  *
256*7ac9a364SKalle Valo  * Tx DMA FIFOs have dedicated purposes.  For 4965, they are used as follows
257*7ac9a364SKalle Valo  * (cf. default_queue_to_tx_fifo in 4965.c):
258*7ac9a364SKalle Valo  *
259*7ac9a364SKalle Valo  * 0 -- EDCA BK (background) frames, lowest priority
260*7ac9a364SKalle Valo  * 1 -- EDCA BE (best effort) frames, normal priority
261*7ac9a364SKalle Valo  * 2 -- EDCA VI (video) frames, higher priority
262*7ac9a364SKalle Valo  * 3 -- EDCA VO (voice) and management frames, highest priority
263*7ac9a364SKalle Valo  * 4 -- Commands (e.g. RXON, etc.)
264*7ac9a364SKalle Valo  * 5 -- unused (HCCA)
265*7ac9a364SKalle Valo  * 6 -- unused (HCCA)
266*7ac9a364SKalle Valo  * 7 -- not used by driver (device-internal only)
267*7ac9a364SKalle Valo  *
268*7ac9a364SKalle Valo  *
269*7ac9a364SKalle Valo  * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6.
270*7ac9a364SKalle Valo  * In addition, driver can map the remaining queues to Tx DMA/FIFO
271*7ac9a364SKalle Valo  * channels 0-3 to support 11n aggregation via EDCA DMA channels.
272*7ac9a364SKalle Valo  *
273*7ac9a364SKalle Valo  * The driver sets up each queue to work in one of two modes:
274*7ac9a364SKalle Valo  *
275*7ac9a364SKalle Valo  * 1)  Scheduler-Ack, in which the scheduler automatically supports a
276*7ac9a364SKalle Valo  *     block-ack (BA) win of up to 64 TFDs.  In this mode, each queue
277*7ac9a364SKalle Valo  *     contains TFDs for a unique combination of Recipient Address (RA)
278*7ac9a364SKalle Valo  *     and Traffic Identifier (TID), that is, traffic of a given
279*7ac9a364SKalle Valo  *     Quality-Of-Service (QOS) priority, destined for a single station.
280*7ac9a364SKalle Valo  *
281*7ac9a364SKalle Valo  *     In scheduler-ack mode, the scheduler keeps track of the Tx status of
282*7ac9a364SKalle Valo  *     each frame within the BA win, including whether it's been transmitted,
283*7ac9a364SKalle Valo  *     and whether it's been acknowledged by the receiving station.  The device
284*7ac9a364SKalle Valo  *     automatically processes block-acks received from the receiving STA,
285*7ac9a364SKalle Valo  *     and reschedules un-acked frames to be retransmitted (successful
286*7ac9a364SKalle Valo  *     Tx completion may end up being out-of-order).
287*7ac9a364SKalle Valo  *
288*7ac9a364SKalle Valo  *     The driver must maintain the queue's Byte Count table in host DRAM
289*7ac9a364SKalle Valo  *     (struct il4965_sched_queue_byte_cnt_tbl) for this mode.
290*7ac9a364SKalle Valo  *     This mode does not support fragmentation.
291*7ac9a364SKalle Valo  *
292*7ac9a364SKalle Valo  * 2)  FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order.
293*7ac9a364SKalle Valo  *     The device may automatically retry Tx, but will retry only one frame
294*7ac9a364SKalle Valo  *     at a time, until receiving ACK from receiving station, or reaching
295*7ac9a364SKalle Valo  *     retry limit and giving up.
296*7ac9a364SKalle Valo  *
297*7ac9a364SKalle Valo  *     The command queue (#4/#9) must use this mode!
298*7ac9a364SKalle Valo  *     This mode does not require use of the Byte Count table in host DRAM.
299*7ac9a364SKalle Valo  *
300*7ac9a364SKalle Valo  * Driver controls scheduler operation via 3 means:
301*7ac9a364SKalle Valo  * 1)  Scheduler registers
302*7ac9a364SKalle Valo  * 2)  Shared scheduler data base in internal 4956 SRAM
303*7ac9a364SKalle Valo  * 3)  Shared data in host DRAM
304*7ac9a364SKalle Valo  *
305*7ac9a364SKalle Valo  * Initialization:
306*7ac9a364SKalle Valo  *
307*7ac9a364SKalle Valo  * When loading, driver should allocate memory for:
308*7ac9a364SKalle Valo  * 1)  16 TFD circular buffers, each with space for (typically) 256 TFDs.
309*7ac9a364SKalle Valo  * 2)  16 Byte Count circular buffers in 16 KBytes contiguous memory
310*7ac9a364SKalle Valo  *     (1024 bytes for each queue).
311*7ac9a364SKalle Valo  *
312*7ac9a364SKalle Valo  * After receiving "Alive" response from uCode, driver must initialize
313*7ac9a364SKalle Valo  * the scheduler (especially for queue #4/#9, the command queue, otherwise
314*7ac9a364SKalle Valo  * the driver can't issue commands!):
315*7ac9a364SKalle Valo  */
316*7ac9a364SKalle Valo 
317*7ac9a364SKalle Valo /**
318*7ac9a364SKalle Valo  * Max Tx win size is the max number of contiguous TFDs that the scheduler
319*7ac9a364SKalle Valo  * can keep track of at one time when creating block-ack chains of frames.
320*7ac9a364SKalle Valo  * Note that "64" matches the number of ack bits in a block-ack packet.
321*7ac9a364SKalle Valo  * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize
322*7ac9a364SKalle Valo  * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values.
323*7ac9a364SKalle Valo  */
324*7ac9a364SKalle Valo #define SCD_WIN_SIZE				64
325*7ac9a364SKalle Valo #define SCD_FRAME_LIMIT				64
326*7ac9a364SKalle Valo 
327*7ac9a364SKalle Valo /* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */
328*7ac9a364SKalle Valo #define IL49_SCD_START_OFFSET		0xa02c00
329*7ac9a364SKalle Valo 
330*7ac9a364SKalle Valo /*
331*7ac9a364SKalle Valo  * 4965 tells driver SRAM address for internal scheduler structs via this reg.
332*7ac9a364SKalle Valo  * Value is valid only after "Alive" response from uCode.
333*7ac9a364SKalle Valo  */
334*7ac9a364SKalle Valo #define IL49_SCD_SRAM_BASE_ADDR           (IL49_SCD_START_OFFSET + 0x0)
335*7ac9a364SKalle Valo 
336*7ac9a364SKalle Valo /*
337*7ac9a364SKalle Valo  * Driver may need to update queue-empty bits after changing queue's
338*7ac9a364SKalle Valo  * write and read pointers (idxes) during (re-)initialization (i.e. when
339*7ac9a364SKalle Valo  * scheduler is not tracking what's happening).
340*7ac9a364SKalle Valo  * Bit fields:
341*7ac9a364SKalle Valo  * 31-16:  Write mask -- 1: update empty bit, 0: don't change empty bit
342*7ac9a364SKalle Valo  * 15-00:  Empty state, one for each queue -- 1: empty, 0: non-empty
343*7ac9a364SKalle Valo  * NOTE:  This register is not used by Linux driver.
344*7ac9a364SKalle Valo  */
345*7ac9a364SKalle Valo #define IL49_SCD_EMPTY_BITS               (IL49_SCD_START_OFFSET + 0x4)
346*7ac9a364SKalle Valo 
347*7ac9a364SKalle Valo /*
348*7ac9a364SKalle Valo  * Physical base address of array of byte count (BC) circular buffers (CBs).
349*7ac9a364SKalle Valo  * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode.
350*7ac9a364SKalle Valo  * This register points to BC CB for queue 0, must be on 1024-byte boundary.
351*7ac9a364SKalle Valo  * Others are spaced by 1024 bytes.
352*7ac9a364SKalle Valo  * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad.
353*7ac9a364SKalle Valo  * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff).
354*7ac9a364SKalle Valo  * Bit fields:
355*7ac9a364SKalle Valo  * 25-00:  Byte Count CB physical address [35:10], must be 1024-byte aligned.
356*7ac9a364SKalle Valo  */
357*7ac9a364SKalle Valo #define IL49_SCD_DRAM_BASE_ADDR           (IL49_SCD_START_OFFSET + 0x10)
358*7ac9a364SKalle Valo 
359*7ac9a364SKalle Valo /*
360*7ac9a364SKalle Valo  * Enables any/all Tx DMA/FIFO channels.
361*7ac9a364SKalle Valo  * Scheduler generates requests for only the active channels.
362*7ac9a364SKalle Valo  * Set this to 0xff to enable all 8 channels (normal usage).
363*7ac9a364SKalle Valo  * Bit fields:
364*7ac9a364SKalle Valo  *  7- 0:  Enable (1), disable (0), one bit for each channel 0-7
365*7ac9a364SKalle Valo  */
366*7ac9a364SKalle Valo #define IL49_SCD_TXFACT                   (IL49_SCD_START_OFFSET + 0x1c)
367*7ac9a364SKalle Valo /*
368*7ac9a364SKalle Valo  * Queue (x) Write Pointers (idxes, really!), one for each Tx queue.
369*7ac9a364SKalle Valo  * Initialized and updated by driver as new TFDs are added to queue.
370*7ac9a364SKalle Valo  * NOTE:  If using Block Ack, idx must correspond to frame's
371*7ac9a364SKalle Valo  *        Start Sequence Number; idx = (SSN & 0xff)
372*7ac9a364SKalle Valo  * NOTE:  Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses?
373*7ac9a364SKalle Valo  */
374*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_WRPTR(x)  (IL49_SCD_START_OFFSET + 0x24 + (x) * 4)
375*7ac9a364SKalle Valo 
376*7ac9a364SKalle Valo /*
377*7ac9a364SKalle Valo  * Queue (x) Read Pointers (idxes, really!), one for each Tx queue.
378*7ac9a364SKalle Valo  * For FIFO mode, idx indicates next frame to transmit.
379*7ac9a364SKalle Valo  * For Scheduler-ACK mode, idx indicates first frame in Tx win.
380*7ac9a364SKalle Valo  * Initialized by driver, updated by scheduler.
381*7ac9a364SKalle Valo  */
382*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_RDPTR(x)  (IL49_SCD_START_OFFSET + 0x64 + (x) * 4)
383*7ac9a364SKalle Valo 
384*7ac9a364SKalle Valo /*
385*7ac9a364SKalle Valo  * Select which queues work in chain mode (1) vs. not (0).
386*7ac9a364SKalle Valo  * Use chain mode to build chains of aggregated frames.
387*7ac9a364SKalle Valo  * Bit fields:
388*7ac9a364SKalle Valo  * 31-16:  Reserved
389*7ac9a364SKalle Valo  * 15-00:  Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time
390*7ac9a364SKalle Valo  * NOTE:  If driver sets up queue for chain mode, it should be also set up
391*7ac9a364SKalle Valo  *        Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x).
392*7ac9a364SKalle Valo  */
393*7ac9a364SKalle Valo #define IL49_SCD_QUEUECHAIN_SEL  (IL49_SCD_START_OFFSET + 0xd0)
394*7ac9a364SKalle Valo 
395*7ac9a364SKalle Valo /*
396*7ac9a364SKalle Valo  * Select which queues interrupt driver when scheduler increments
397*7ac9a364SKalle Valo  * a queue's read pointer (idx).
398*7ac9a364SKalle Valo  * Bit fields:
399*7ac9a364SKalle Valo  * 31-16:  Reserved
400*7ac9a364SKalle Valo  * 15-00:  Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled
401*7ac9a364SKalle Valo  * NOTE:  This functionality is apparently a no-op; driver relies on interrupts
402*7ac9a364SKalle Valo  *        from Rx queue to read Tx command responses and update Tx queues.
403*7ac9a364SKalle Valo  */
404*7ac9a364SKalle Valo #define IL49_SCD_INTERRUPT_MASK  (IL49_SCD_START_OFFSET + 0xe4)
405*7ac9a364SKalle Valo 
406*7ac9a364SKalle Valo /*
407*7ac9a364SKalle Valo  * Queue search status registers.  One for each queue.
408*7ac9a364SKalle Valo  * Sets up queue mode and assigns queue to Tx DMA channel.
409*7ac9a364SKalle Valo  * Bit fields:
410*7ac9a364SKalle Valo  * 19-10: Write mask/enable bits for bits 0-9
411*7ac9a364SKalle Valo  *     9: Driver should init to "0"
412*7ac9a364SKalle Valo  *     8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0).
413*7ac9a364SKalle Valo  *        Driver should init to "1" for aggregation mode, or "0" otherwise.
414*7ac9a364SKalle Valo  *   7-6: Driver should init to "0"
415*7ac9a364SKalle Valo  *     5: Window Size Left; indicates whether scheduler can request
416*7ac9a364SKalle Valo  *        another TFD, based on win size, etc.  Driver should init
417*7ac9a364SKalle Valo  *        this bit to "1" for aggregation mode, or "0" for non-agg.
418*7ac9a364SKalle Valo  *   4-1: Tx FIFO to use (range 0-7).
419*7ac9a364SKalle Valo  *     0: Queue is active (1), not active (0).
420*7ac9a364SKalle Valo  * Other bits should be written as "0"
421*7ac9a364SKalle Valo  *
422*7ac9a364SKalle Valo  * NOTE:  If enabling Scheduler-ACK mode, chain mode should also be enabled
423*7ac9a364SKalle Valo  *        via SCD_QUEUECHAIN_SEL.
424*7ac9a364SKalle Valo  */
425*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STATUS_BITS(x)\
426*7ac9a364SKalle Valo 	(IL49_SCD_START_OFFSET + 0x104 + (x) * 4)
427*7ac9a364SKalle Valo 
428*7ac9a364SKalle Valo /* Bit field positions */
429*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE	(0)
430*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STTS_REG_POS_TXF	(1)
431*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STTS_REG_POS_WSL	(5)
432*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK	(8)
433*7ac9a364SKalle Valo 
434*7ac9a364SKalle Valo /* Write masks */
435*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN	(10)
436*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_STTS_REG_MSK		(0x0007FC00)
437*7ac9a364SKalle Valo 
438*7ac9a364SKalle Valo /**
439*7ac9a364SKalle Valo  * 4965 internal SRAM structures for scheduler, shared with driver ...
440*7ac9a364SKalle Valo  *
441*7ac9a364SKalle Valo  * Driver should clear and initialize the following areas after receiving
442*7ac9a364SKalle Valo  * "Alive" response from 4965 uCode, i.e. after initial
443*7ac9a364SKalle Valo  * uCode load, or after a uCode load done for error recovery:
444*7ac9a364SKalle Valo  *
445*7ac9a364SKalle Valo  * SCD_CONTEXT_DATA_OFFSET (size 128 bytes)
446*7ac9a364SKalle Valo  * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes)
447*7ac9a364SKalle Valo  * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes)
448*7ac9a364SKalle Valo  *
449*7ac9a364SKalle Valo  * Driver accesses SRAM via HBUS_TARG_MEM_* registers.
450*7ac9a364SKalle Valo  * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR.
451*7ac9a364SKalle Valo  * All OFFSET values must be added to this base address.
452*7ac9a364SKalle Valo  */
453*7ac9a364SKalle Valo 
454*7ac9a364SKalle Valo /*
455*7ac9a364SKalle Valo  * Queue context.  One 8-byte entry for each of 16 queues.
456*7ac9a364SKalle Valo  *
457*7ac9a364SKalle Valo  * Driver should clear this entire area (size 0x80) to 0 after receiving
458*7ac9a364SKalle Valo  * "Alive" notification from uCode.  Additionally, driver should init
459*7ac9a364SKalle Valo  * each queue's entry as follows:
460*7ac9a364SKalle Valo  *
461*7ac9a364SKalle Valo  * LS Dword bit fields:
462*7ac9a364SKalle Valo  *  0-06:  Max Tx win size for Scheduler-ACK.  Driver should init to 64.
463*7ac9a364SKalle Valo  *
464*7ac9a364SKalle Valo  * MS Dword bit fields:
465*7ac9a364SKalle Valo  * 16-22:  Frame limit.  Driver should init to 10 (0xa).
466*7ac9a364SKalle Valo  *
467*7ac9a364SKalle Valo  * Driver should init all other bits to 0.
468*7ac9a364SKalle Valo  *
469*7ac9a364SKalle Valo  * Init must be done after driver receives "Alive" response from 4965 uCode,
470*7ac9a364SKalle Valo  * and when setting up queue for aggregation.
471*7ac9a364SKalle Valo  */
472*7ac9a364SKalle Valo #define IL49_SCD_CONTEXT_DATA_OFFSET			0x380
473*7ac9a364SKalle Valo #define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \
474*7ac9a364SKalle Valo 			(IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8))
475*7ac9a364SKalle Valo 
476*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS		(0)
477*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK		(0x0000007F)
478*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS	(16)
479*7ac9a364SKalle Valo #define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK	(0x007F0000)
480*7ac9a364SKalle Valo 
481*7ac9a364SKalle Valo /*
482*7ac9a364SKalle Valo  * Tx Status Bitmap
483*7ac9a364SKalle Valo  *
484*7ac9a364SKalle Valo  * Driver should clear this entire area (size 0x100) to 0 after receiving
485*7ac9a364SKalle Valo  * "Alive" notification from uCode.  Area is used only by device itself;
486*7ac9a364SKalle Valo  * no other support (besides clearing) is required from driver.
487*7ac9a364SKalle Valo  */
488*7ac9a364SKalle Valo #define IL49_SCD_TX_STTS_BITMAP_OFFSET		0x400
489*7ac9a364SKalle Valo 
490*7ac9a364SKalle Valo /*
491*7ac9a364SKalle Valo  * RAxTID to queue translation mapping.
492*7ac9a364SKalle Valo  *
493*7ac9a364SKalle Valo  * When queue is in Scheduler-ACK mode, frames placed in a that queue must be
494*7ac9a364SKalle Valo  * for only one combination of receiver address (RA) and traffic ID (TID), i.e.
495*7ac9a364SKalle Valo  * one QOS priority level destined for one station (for this wireless link,
496*7ac9a364SKalle Valo  * not final destination).  The SCD_TRANSLATE_TBL area provides 16 16-bit
497*7ac9a364SKalle Valo  * mappings, one for each of the 16 queues.  If queue is not in Scheduler-ACK
498*7ac9a364SKalle Valo  * mode, the device ignores the mapping value.
499*7ac9a364SKalle Valo  *
500*7ac9a364SKalle Valo  * Bit fields, for each 16-bit map:
501*7ac9a364SKalle Valo  * 15-9:  Reserved, set to 0
502*7ac9a364SKalle Valo  *  8-4:  Index into device's station table for recipient station
503*7ac9a364SKalle Valo  *  3-0:  Traffic ID (tid), range 0-15
504*7ac9a364SKalle Valo  *
505*7ac9a364SKalle Valo  * Driver should clear this entire area (size 32 bytes) to 0 after receiving
506*7ac9a364SKalle Valo  * "Alive" notification from uCode.  To update a 16-bit map value, driver
507*7ac9a364SKalle Valo  * must read a dword-aligned value from device SRAM, replace the 16-bit map
508*7ac9a364SKalle Valo  * value of interest, and write the dword value back into device SRAM.
509*7ac9a364SKalle Valo  */
510*7ac9a364SKalle Valo #define IL49_SCD_TRANSLATE_TBL_OFFSET		0x500
511*7ac9a364SKalle Valo 
512*7ac9a364SKalle Valo /* Find translation table dword to read/write for given queue */
513*7ac9a364SKalle Valo #define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \
514*7ac9a364SKalle Valo 	((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc)
515*7ac9a364SKalle Valo 
516*7ac9a364SKalle Valo #define IL_SCD_TXFIFO_POS_TID			(0)
517*7ac9a364SKalle Valo #define IL_SCD_TXFIFO_POS_RA			(4)
518*7ac9a364SKalle Valo #define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK	(0x01FF)
519*7ac9a364SKalle Valo 
520*7ac9a364SKalle Valo /*********************** END TX SCHEDULER *************************************/
521*7ac9a364SKalle Valo 
522*7ac9a364SKalle Valo #endif /* __il_prph_h__ */
523