162306a36Sopenharmony_ci/****************************************************************************** 262306a36Sopenharmony_ci * 362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 462306a36Sopenharmony_ci * redistributing this file, you may do so under either license. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * GPL LICENSE SUMMARY 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 962306a36Sopenharmony_ci * 1062306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify 1162306a36Sopenharmony_ci * it under the terms of version 2 of the GNU General Public License as 1262306a36Sopenharmony_ci * published by the Free Software Foundation. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, but 1562306a36Sopenharmony_ci * WITHOUT ANY WARRANTY; without even the implied warranty of 1662306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1762306a36Sopenharmony_ci * General Public License for more details. 1862306a36Sopenharmony_ci * 1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License 2062306a36Sopenharmony_ci * along with this program; if not, write to the Free Software 2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, 2262306a36Sopenharmony_ci * USA 2362306a36Sopenharmony_ci * 2462306a36Sopenharmony_ci * The full GNU General Public License is included in this distribution 2562306a36Sopenharmony_ci * in the file called LICENSE.GPL. 2662306a36Sopenharmony_ci * 2762306a36Sopenharmony_ci * Contact Information: 2862306a36Sopenharmony_ci * Intel Linux Wireless <ilw@linux.intel.com> 2962306a36Sopenharmony_ci * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 3062306a36Sopenharmony_ci * 3162306a36Sopenharmony_ci * BSD LICENSE 3262306a36Sopenharmony_ci * 3362306a36Sopenharmony_ci * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. 3462306a36Sopenharmony_ci * All rights reserved. 3562306a36Sopenharmony_ci * 3662306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 3762306a36Sopenharmony_ci * modification, are permitted provided that the following conditions 3862306a36Sopenharmony_ci * are met: 3962306a36Sopenharmony_ci * 4062306a36Sopenharmony_ci * * Redistributions of source code must retain the above copyright 4162306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 4262306a36Sopenharmony_ci * * Redistributions in binary form must reproduce the above copyright 4362306a36Sopenharmony_ci * notice, this list of conditions and the following disclaimer in 4462306a36Sopenharmony_ci * the documentation and/or other materials provided with the 4562306a36Sopenharmony_ci * distribution. 4662306a36Sopenharmony_ci * * Neither the name Intel Corporation nor the names of its 4762306a36Sopenharmony_ci * contributors may be used to endorse or promote products derived 4862306a36Sopenharmony_ci * from this software without specific prior written permission. 4962306a36Sopenharmony_ci * 5062306a36Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 5162306a36Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5262306a36Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 5362306a36Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 5462306a36Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 5562306a36Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 5662306a36Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 5762306a36Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 5862306a36Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5962306a36Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 6062306a36Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6162306a36Sopenharmony_ci *****************************************************************************/ 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#ifndef __il_prph_h__ 6462306a36Sopenharmony_ci#define __il_prph_h__ 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/* 6762306a36Sopenharmony_ci * Registers in this file are internal, not PCI bus memory mapped. 6862306a36Sopenharmony_ci * Driver accesses these via HBUS_TARG_PRPH_* registers. 6962306a36Sopenharmony_ci */ 7062306a36Sopenharmony_ci#define PRPH_BASE (0x00000) 7162306a36Sopenharmony_ci#define PRPH_END (0xFFFFF) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/* APMG (power management) constants */ 7462306a36Sopenharmony_ci#define APMG_BASE (PRPH_BASE + 0x3000) 7562306a36Sopenharmony_ci#define APMG_CLK_CTRL_REG (APMG_BASE + 0x0000) 7662306a36Sopenharmony_ci#define APMG_CLK_EN_REG (APMG_BASE + 0x0004) 7762306a36Sopenharmony_ci#define APMG_CLK_DIS_REG (APMG_BASE + 0x0008) 7862306a36Sopenharmony_ci#define APMG_PS_CTRL_REG (APMG_BASE + 0x000c) 7962306a36Sopenharmony_ci#define APMG_PCIDEV_STT_REG (APMG_BASE + 0x0010) 8062306a36Sopenharmony_ci#define APMG_RFKILL_REG (APMG_BASE + 0x0014) 8162306a36Sopenharmony_ci#define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c) 8262306a36Sopenharmony_ci#define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020) 8362306a36Sopenharmony_ci#define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058) 8462306a36Sopenharmony_ci#define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C) 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#define APMS_CLK_VAL_MRB_FUNC_MODE (0x00000001) 8762306a36Sopenharmony_ci#define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200) 8862306a36Sopenharmony_ci#define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS (0x00400000) 9162306a36Sopenharmony_ci#define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) 9262306a36Sopenharmony_ci#define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) 9362306a36Sopenharmony_ci#define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) 9462306a36Sopenharmony_ci#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ 9562306a36Sopenharmony_ci#define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) 9662306a36Sopenharmony_ci#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ 9762306a36Sopenharmony_ci#define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci/** 10262306a36Sopenharmony_ci * BSM (Bootstrap State Machine) 10362306a36Sopenharmony_ci * 10462306a36Sopenharmony_ci * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program 10562306a36Sopenharmony_ci * in special SRAM that does not power down when the embedded control 10662306a36Sopenharmony_ci * processor is sleeping (e.g. for periodic power-saving shutdowns of radio). 10762306a36Sopenharmony_ci * 10862306a36Sopenharmony_ci * When powering back up after sleeps (or during initial uCode load), the BSM 10962306a36Sopenharmony_ci * internally loads the short bootstrap program from the special SRAM into the 11062306a36Sopenharmony_ci * embedded processor's instruction SRAM, and starts the processor so it runs 11162306a36Sopenharmony_ci * the bootstrap program. 11262306a36Sopenharmony_ci * 11362306a36Sopenharmony_ci * This bootstrap program loads (via PCI busmaster DMA) instructions and data 11462306a36Sopenharmony_ci * images for a uCode program from host DRAM locations. The host driver 11562306a36Sopenharmony_ci * indicates DRAM locations and sizes for instruction and data images via the 11662306a36Sopenharmony_ci * four BSM_DRAM_* registers. Once the bootstrap program loads the new program, 11762306a36Sopenharmony_ci * the new program starts automatically. 11862306a36Sopenharmony_ci * 11962306a36Sopenharmony_ci * The uCode used for open-source drivers includes two programs: 12062306a36Sopenharmony_ci * 12162306a36Sopenharmony_ci * 1) Initialization -- performs hardware calibration and sets up some 12262306a36Sopenharmony_ci * internal data, then notifies host via "initialize alive" notification 12362306a36Sopenharmony_ci * (struct il_init_alive_resp) that it has completed all of its work. 12462306a36Sopenharmony_ci * After signal from host, it then loads and starts the runtime program. 12562306a36Sopenharmony_ci * The initialization program must be used when initially setting up the 12662306a36Sopenharmony_ci * NIC after loading the driver. 12762306a36Sopenharmony_ci * 12862306a36Sopenharmony_ci * 2) Runtime/Protocol -- performs all normal runtime operations. This 12962306a36Sopenharmony_ci * notifies host via "alive" notification (struct il_alive_resp) that it 13062306a36Sopenharmony_ci * is ready to be used. 13162306a36Sopenharmony_ci * 13262306a36Sopenharmony_ci * When initializing the NIC, the host driver does the following procedure: 13362306a36Sopenharmony_ci * 13462306a36Sopenharmony_ci * 1) Load bootstrap program (instructions only, no data image for bootstrap) 13562306a36Sopenharmony_ci * into bootstrap memory. Use dword writes starting at BSM_SRAM_LOWER_BOUND 13662306a36Sopenharmony_ci * 13762306a36Sopenharmony_ci * 2) Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction 13862306a36Sopenharmony_ci * images in host DRAM. 13962306a36Sopenharmony_ci * 14062306a36Sopenharmony_ci * 3) Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked: 14162306a36Sopenharmony_ci * BSM_WR_MEM_SRC_REG = 0 14262306a36Sopenharmony_ci * BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND 14362306a36Sopenharmony_ci * BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image 14462306a36Sopenharmony_ci * 14562306a36Sopenharmony_ci * 4) Load bootstrap into instruction SRAM: 14662306a36Sopenharmony_ci * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START 14762306a36Sopenharmony_ci * 14862306a36Sopenharmony_ci * 5) Wait for load completion: 14962306a36Sopenharmony_ci * Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0 15062306a36Sopenharmony_ci * 15162306a36Sopenharmony_ci * 6) Enable future boot loads whenever NIC's power management triggers it: 15262306a36Sopenharmony_ci * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN 15362306a36Sopenharmony_ci * 15462306a36Sopenharmony_ci * 7) Start the NIC by removing all reset bits: 15562306a36Sopenharmony_ci * CSR_RESET = 0 15662306a36Sopenharmony_ci * 15762306a36Sopenharmony_ci * The bootstrap uCode (already in instruction SRAM) loads initialization 15862306a36Sopenharmony_ci * uCode. Initialization uCode performs data initialization, sends 15962306a36Sopenharmony_ci * "initialize alive" notification to host, and waits for a signal from 16062306a36Sopenharmony_ci * host to load runtime code. 16162306a36Sopenharmony_ci * 16262306a36Sopenharmony_ci * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction 16362306a36Sopenharmony_ci * images in host DRAM. The last register loaded must be the instruction 16462306a36Sopenharmony_ci * byte count register ("1" in MSbit tells initialization uCode to load 16562306a36Sopenharmony_ci * the runtime uCode): 16662306a36Sopenharmony_ci * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD 16762306a36Sopenharmony_ci * 16862306a36Sopenharmony_ci * 5) Wait for "alive" notification, then issue normal runtime commands. 16962306a36Sopenharmony_ci * 17062306a36Sopenharmony_ci * Data caching during power-downs: 17162306a36Sopenharmony_ci * 17262306a36Sopenharmony_ci * Just before the embedded controller powers down (e.g for automatic 17362306a36Sopenharmony_ci * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA) 17462306a36Sopenharmony_ci * a current snapshot of the embedded processor's data SRAM into host DRAM. 17562306a36Sopenharmony_ci * This caches the data while the embedded processor's memory is powered down. 17662306a36Sopenharmony_ci * Location and size are controlled by BSM_DRAM_DATA_* registers. 17762306a36Sopenharmony_ci * 17862306a36Sopenharmony_ci * NOTE: Instruction SRAM does not need to be saved, since that doesn't 17962306a36Sopenharmony_ci * change during operation; the original image (from uCode distribution 18062306a36Sopenharmony_ci * file) can be used for reload. 18162306a36Sopenharmony_ci * 18262306a36Sopenharmony_ci * When powering back up, the BSM loads the bootstrap program. Bootstrap looks 18362306a36Sopenharmony_ci * at the BSM_DRAM_* registers, which now point to the runtime instruction 18462306a36Sopenharmony_ci * image and the cached (modified) runtime data (*not* the initialization 18562306a36Sopenharmony_ci * uCode). Bootstrap reloads these runtime images into SRAM, and restarts the 18662306a36Sopenharmony_ci * uCode from where it left off before the power-down. 18762306a36Sopenharmony_ci * 18862306a36Sopenharmony_ci * NOTE: Initialization uCode does *not* run as part of the save/restore 18962306a36Sopenharmony_ci * procedure. 19062306a36Sopenharmony_ci * 19162306a36Sopenharmony_ci * This save/restore method is mostly for autonomous power management during 19262306a36Sopenharmony_ci * normal operation (result of C_POWER_TBL). Platform suspend/resume and 19362306a36Sopenharmony_ci * RFKILL should use complete restarts (with total re-initialization) of uCode, 19462306a36Sopenharmony_ci * allowing total shutdown (including BSM memory). 19562306a36Sopenharmony_ci * 19662306a36Sopenharmony_ci * Note that, during normal operation, the host DRAM that held the initial 19762306a36Sopenharmony_ci * startup data for the runtime code is now being used as a backup data cache 19862306a36Sopenharmony_ci * for modified data! If you need to completely re-initialize the NIC, make 19962306a36Sopenharmony_ci * sure that you use the runtime data image from the uCode distribution file, 20062306a36Sopenharmony_ci * not the modified/saved runtime data. You may want to store a separate 20162306a36Sopenharmony_ci * "clean" runtime data image in DRAM to avoid disk reads of distribution file. 20262306a36Sopenharmony_ci */ 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci/* BSM bit fields */ 20562306a36Sopenharmony_ci#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ 20662306a36Sopenharmony_ci#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup */ 20762306a36Sopenharmony_ci#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci/* BSM addresses */ 21062306a36Sopenharmony_ci#define BSM_BASE (PRPH_BASE + 0x3400) 21162306a36Sopenharmony_ci#define BSM_END (PRPH_BASE + 0x3800) 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ 21462306a36Sopenharmony_ci#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ 21562306a36Sopenharmony_ci#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ 21662306a36Sopenharmony_ci#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ 21762306a36Sopenharmony_ci#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci/* 22062306a36Sopenharmony_ci * Pointers and size regs for bootstrap load and data SRAM save/restore. 22162306a36Sopenharmony_ci * NOTE: 3945 pointers use bits 31:0 of DRAM address. 22262306a36Sopenharmony_ci * 4965 pointers use bits 35:4 of DRAM address. 22362306a36Sopenharmony_ci */ 22462306a36Sopenharmony_ci#define BSM_DRAM_INST_PTR_REG (BSM_BASE + 0x090) 22562306a36Sopenharmony_ci#define BSM_DRAM_INST_BYTECOUNT_REG (BSM_BASE + 0x094) 22662306a36Sopenharmony_ci#define BSM_DRAM_DATA_PTR_REG (BSM_BASE + 0x098) 22762306a36Sopenharmony_ci#define BSM_DRAM_DATA_BYTECOUNT_REG (BSM_BASE + 0x09C) 22862306a36Sopenharmony_ci 22962306a36Sopenharmony_ci/* 23062306a36Sopenharmony_ci * BSM special memory, stays powered on during power-save sleeps. 23162306a36Sopenharmony_ci * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) 23262306a36Sopenharmony_ci */ 23362306a36Sopenharmony_ci#define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) 23462306a36Sopenharmony_ci#define BSM_SRAM_SIZE (1024) /* bytes */ 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci/* 3945 Tx scheduler registers */ 23762306a36Sopenharmony_ci#define ALM_SCD_BASE (PRPH_BASE + 0x2E00) 23862306a36Sopenharmony_ci#define ALM_SCD_MODE_REG (ALM_SCD_BASE + 0x000) 23962306a36Sopenharmony_ci#define ALM_SCD_ARASTAT_REG (ALM_SCD_BASE + 0x004) 24062306a36Sopenharmony_ci#define ALM_SCD_TXFACT_REG (ALM_SCD_BASE + 0x010) 24162306a36Sopenharmony_ci#define ALM_SCD_TXF4MF_REG (ALM_SCD_BASE + 0x014) 24262306a36Sopenharmony_ci#define ALM_SCD_TXF5MF_REG (ALM_SCD_BASE + 0x020) 24362306a36Sopenharmony_ci#define ALM_SCD_SBYP_MODE_1_REG (ALM_SCD_BASE + 0x02C) 24462306a36Sopenharmony_ci#define ALM_SCD_SBYP_MODE_2_REG (ALM_SCD_BASE + 0x030) 24562306a36Sopenharmony_ci 24662306a36Sopenharmony_ci/** 24762306a36Sopenharmony_ci * Tx Scheduler 24862306a36Sopenharmony_ci * 24962306a36Sopenharmony_ci * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs 25062306a36Sopenharmony_ci * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in 25162306a36Sopenharmony_ci * host DRAM. It steers each frame's Tx command (which contains the frame 25262306a36Sopenharmony_ci * data) into one of up to 7 prioritized Tx DMA FIFO channels within the 25362306a36Sopenharmony_ci * device. A queue maps to only one (selectable by driver) Tx DMA channel, 25462306a36Sopenharmony_ci * but one DMA channel may take input from several queues. 25562306a36Sopenharmony_ci * 25662306a36Sopenharmony_ci * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows 25762306a36Sopenharmony_ci * (cf. default_queue_to_tx_fifo in 4965.c): 25862306a36Sopenharmony_ci * 25962306a36Sopenharmony_ci * 0 -- EDCA BK (background) frames, lowest priority 26062306a36Sopenharmony_ci * 1 -- EDCA BE (best effort) frames, normal priority 26162306a36Sopenharmony_ci * 2 -- EDCA VI (video) frames, higher priority 26262306a36Sopenharmony_ci * 3 -- EDCA VO (voice) and management frames, highest priority 26362306a36Sopenharmony_ci * 4 -- Commands (e.g. RXON, etc.) 26462306a36Sopenharmony_ci * 5 -- unused (HCCA) 26562306a36Sopenharmony_ci * 6 -- unused (HCCA) 26662306a36Sopenharmony_ci * 7 -- not used by driver (device-internal only) 26762306a36Sopenharmony_ci * 26862306a36Sopenharmony_ci * 26962306a36Sopenharmony_ci * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. 27062306a36Sopenharmony_ci * In addition, driver can map the remaining queues to Tx DMA/FIFO 27162306a36Sopenharmony_ci * channels 0-3 to support 11n aggregation via EDCA DMA channels. 27262306a36Sopenharmony_ci * 27362306a36Sopenharmony_ci * The driver sets up each queue to work in one of two modes: 27462306a36Sopenharmony_ci * 27562306a36Sopenharmony_ci * 1) Scheduler-Ack, in which the scheduler automatically supports a 27662306a36Sopenharmony_ci * block-ack (BA) win of up to 64 TFDs. In this mode, each queue 27762306a36Sopenharmony_ci * contains TFDs for a unique combination of Recipient Address (RA) 27862306a36Sopenharmony_ci * and Traffic Identifier (TID), that is, traffic of a given 27962306a36Sopenharmony_ci * Quality-Of-Service (QOS) priority, destined for a single station. 28062306a36Sopenharmony_ci * 28162306a36Sopenharmony_ci * In scheduler-ack mode, the scheduler keeps track of the Tx status of 28262306a36Sopenharmony_ci * each frame within the BA win, including whether it's been transmitted, 28362306a36Sopenharmony_ci * and whether it's been acknowledged by the receiving station. The device 28462306a36Sopenharmony_ci * automatically processes block-acks received from the receiving STA, 28562306a36Sopenharmony_ci * and reschedules un-acked frames to be retransmitted (successful 28662306a36Sopenharmony_ci * Tx completion may end up being out-of-order). 28762306a36Sopenharmony_ci * 28862306a36Sopenharmony_ci * The driver must maintain the queue's Byte Count table in host DRAM 28962306a36Sopenharmony_ci * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. 29062306a36Sopenharmony_ci * This mode does not support fragmentation. 29162306a36Sopenharmony_ci * 29262306a36Sopenharmony_ci * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. 29362306a36Sopenharmony_ci * The device may automatically retry Tx, but will retry only one frame 29462306a36Sopenharmony_ci * at a time, until receiving ACK from receiving station, or reaching 29562306a36Sopenharmony_ci * retry limit and giving up. 29662306a36Sopenharmony_ci * 29762306a36Sopenharmony_ci * The command queue (#4/#9) must use this mode! 29862306a36Sopenharmony_ci * This mode does not require use of the Byte Count table in host DRAM. 29962306a36Sopenharmony_ci * 30062306a36Sopenharmony_ci * Driver controls scheduler operation via 3 means: 30162306a36Sopenharmony_ci * 1) Scheduler registers 30262306a36Sopenharmony_ci * 2) Shared scheduler data base in internal 4956 SRAM 30362306a36Sopenharmony_ci * 3) Shared data in host DRAM 30462306a36Sopenharmony_ci * 30562306a36Sopenharmony_ci * Initialization: 30662306a36Sopenharmony_ci * 30762306a36Sopenharmony_ci * When loading, driver should allocate memory for: 30862306a36Sopenharmony_ci * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs. 30962306a36Sopenharmony_ci * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory 31062306a36Sopenharmony_ci * (1024 bytes for each queue). 31162306a36Sopenharmony_ci * 31262306a36Sopenharmony_ci * After receiving "Alive" response from uCode, driver must initialize 31362306a36Sopenharmony_ci * the scheduler (especially for queue #4/#9, the command queue, otherwise 31462306a36Sopenharmony_ci * the driver can't issue commands!): 31562306a36Sopenharmony_ci */ 31662306a36Sopenharmony_ci 31762306a36Sopenharmony_ci/** 31862306a36Sopenharmony_ci * Max Tx win size is the max number of contiguous TFDs that the scheduler 31962306a36Sopenharmony_ci * can keep track of at one time when creating block-ack chains of frames. 32062306a36Sopenharmony_ci * Note that "64" matches the number of ack bits in a block-ack packet. 32162306a36Sopenharmony_ci * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize 32262306a36Sopenharmony_ci * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. 32362306a36Sopenharmony_ci */ 32462306a36Sopenharmony_ci#define SCD_WIN_SIZE 64 32562306a36Sopenharmony_ci#define SCD_FRAME_LIMIT 64 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci/* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ 32862306a36Sopenharmony_ci#define IL49_SCD_START_OFFSET 0xa02c00 32962306a36Sopenharmony_ci 33062306a36Sopenharmony_ci/* 33162306a36Sopenharmony_ci * 4965 tells driver SRAM address for internal scheduler structs via this reg. 33262306a36Sopenharmony_ci * Value is valid only after "Alive" response from uCode. 33362306a36Sopenharmony_ci */ 33462306a36Sopenharmony_ci#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) 33562306a36Sopenharmony_ci 33662306a36Sopenharmony_ci/* 33762306a36Sopenharmony_ci * Driver may need to update queue-empty bits after changing queue's 33862306a36Sopenharmony_ci * write and read pointers (idxes) during (re-)initialization (i.e. when 33962306a36Sopenharmony_ci * scheduler is not tracking what's happening). 34062306a36Sopenharmony_ci * Bit fields: 34162306a36Sopenharmony_ci * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit 34262306a36Sopenharmony_ci * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty 34362306a36Sopenharmony_ci * NOTE: This register is not used by Linux driver. 34462306a36Sopenharmony_ci */ 34562306a36Sopenharmony_ci#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci/* 34862306a36Sopenharmony_ci * Physical base address of array of byte count (BC) circular buffers (CBs). 34962306a36Sopenharmony_ci * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode. 35062306a36Sopenharmony_ci * This register points to BC CB for queue 0, must be on 1024-byte boundary. 35162306a36Sopenharmony_ci * Others are spaced by 1024 bytes. 35262306a36Sopenharmony_ci * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. 35362306a36Sopenharmony_ci * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). 35462306a36Sopenharmony_ci * Bit fields: 35562306a36Sopenharmony_ci * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. 35662306a36Sopenharmony_ci */ 35762306a36Sopenharmony_ci#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) 35862306a36Sopenharmony_ci 35962306a36Sopenharmony_ci/* 36062306a36Sopenharmony_ci * Enables any/all Tx DMA/FIFO channels. 36162306a36Sopenharmony_ci * Scheduler generates requests for only the active channels. 36262306a36Sopenharmony_ci * Set this to 0xff to enable all 8 channels (normal usage). 36362306a36Sopenharmony_ci * Bit fields: 36462306a36Sopenharmony_ci * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 36562306a36Sopenharmony_ci */ 36662306a36Sopenharmony_ci#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) 36762306a36Sopenharmony_ci/* 36862306a36Sopenharmony_ci * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. 36962306a36Sopenharmony_ci * Initialized and updated by driver as new TFDs are added to queue. 37062306a36Sopenharmony_ci * NOTE: If using Block Ack, idx must correspond to frame's 37162306a36Sopenharmony_ci * Start Sequence Number; idx = (SSN & 0xff) 37262306a36Sopenharmony_ci * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? 37362306a36Sopenharmony_ci */ 37462306a36Sopenharmony_ci#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_ci/* 37762306a36Sopenharmony_ci * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. 37862306a36Sopenharmony_ci * For FIFO mode, idx indicates next frame to transmit. 37962306a36Sopenharmony_ci * For Scheduler-ACK mode, idx indicates first frame in Tx win. 38062306a36Sopenharmony_ci * Initialized by driver, updated by scheduler. 38162306a36Sopenharmony_ci */ 38262306a36Sopenharmony_ci#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci/* 38562306a36Sopenharmony_ci * Select which queues work in chain mode (1) vs. not (0). 38662306a36Sopenharmony_ci * Use chain mode to build chains of aggregated frames. 38762306a36Sopenharmony_ci * Bit fields: 38862306a36Sopenharmony_ci * 31-16: Reserved 38962306a36Sopenharmony_ci * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time 39062306a36Sopenharmony_ci * NOTE: If driver sets up queue for chain mode, it should be also set up 39162306a36Sopenharmony_ci * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). 39262306a36Sopenharmony_ci */ 39362306a36Sopenharmony_ci#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) 39462306a36Sopenharmony_ci 39562306a36Sopenharmony_ci/* 39662306a36Sopenharmony_ci * Select which queues interrupt driver when scheduler increments 39762306a36Sopenharmony_ci * a queue's read pointer (idx). 39862306a36Sopenharmony_ci * Bit fields: 39962306a36Sopenharmony_ci * 31-16: Reserved 40062306a36Sopenharmony_ci * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled 40162306a36Sopenharmony_ci * NOTE: This functionality is apparently a no-op; driver relies on interrupts 40262306a36Sopenharmony_ci * from Rx queue to read Tx command responses and update Tx queues. 40362306a36Sopenharmony_ci */ 40462306a36Sopenharmony_ci#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) 40562306a36Sopenharmony_ci 40662306a36Sopenharmony_ci/* 40762306a36Sopenharmony_ci * Queue search status registers. One for each queue. 40862306a36Sopenharmony_ci * Sets up queue mode and assigns queue to Tx DMA channel. 40962306a36Sopenharmony_ci * Bit fields: 41062306a36Sopenharmony_ci * 19-10: Write mask/enable bits for bits 0-9 41162306a36Sopenharmony_ci * 9: Driver should init to "0" 41262306a36Sopenharmony_ci * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0). 41362306a36Sopenharmony_ci * Driver should init to "1" for aggregation mode, or "0" otherwise. 41462306a36Sopenharmony_ci * 7-6: Driver should init to "0" 41562306a36Sopenharmony_ci * 5: Window Size Left; indicates whether scheduler can request 41662306a36Sopenharmony_ci * another TFD, based on win size, etc. Driver should init 41762306a36Sopenharmony_ci * this bit to "1" for aggregation mode, or "0" for non-agg. 41862306a36Sopenharmony_ci * 4-1: Tx FIFO to use (range 0-7). 41962306a36Sopenharmony_ci * 0: Queue is active (1), not active (0). 42062306a36Sopenharmony_ci * Other bits should be written as "0" 42162306a36Sopenharmony_ci * 42262306a36Sopenharmony_ci * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled 42362306a36Sopenharmony_ci * via SCD_QUEUECHAIN_SEL. 42462306a36Sopenharmony_ci */ 42562306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STATUS_BITS(x)\ 42662306a36Sopenharmony_ci (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) 42762306a36Sopenharmony_ci 42862306a36Sopenharmony_ci/* Bit field positions */ 42962306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) 43062306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) 43162306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) 43262306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) 43362306a36Sopenharmony_ci 43462306a36Sopenharmony_ci/* Write masks */ 43562306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) 43662306a36Sopenharmony_ci#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) 43762306a36Sopenharmony_ci 43862306a36Sopenharmony_ci/** 43962306a36Sopenharmony_ci * 4965 internal SRAM structures for scheduler, shared with driver ... 44062306a36Sopenharmony_ci * 44162306a36Sopenharmony_ci * Driver should clear and initialize the following areas after receiving 44262306a36Sopenharmony_ci * "Alive" response from 4965 uCode, i.e. after initial 44362306a36Sopenharmony_ci * uCode load, or after a uCode load done for error recovery: 44462306a36Sopenharmony_ci * 44562306a36Sopenharmony_ci * SCD_CONTEXT_DATA_OFFSET (size 128 bytes) 44662306a36Sopenharmony_ci * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes) 44762306a36Sopenharmony_ci * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes) 44862306a36Sopenharmony_ci * 44962306a36Sopenharmony_ci * Driver accesses SRAM via HBUS_TARG_MEM_* registers. 45062306a36Sopenharmony_ci * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR. 45162306a36Sopenharmony_ci * All OFFSET values must be added to this base address. 45262306a36Sopenharmony_ci */ 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_ci/* 45562306a36Sopenharmony_ci * Queue context. One 8-byte entry for each of 16 queues. 45662306a36Sopenharmony_ci * 45762306a36Sopenharmony_ci * Driver should clear this entire area (size 0x80) to 0 after receiving 45862306a36Sopenharmony_ci * "Alive" notification from uCode. Additionally, driver should init 45962306a36Sopenharmony_ci * each queue's entry as follows: 46062306a36Sopenharmony_ci * 46162306a36Sopenharmony_ci * LS Dword bit fields: 46262306a36Sopenharmony_ci * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. 46362306a36Sopenharmony_ci * 46462306a36Sopenharmony_ci * MS Dword bit fields: 46562306a36Sopenharmony_ci * 16-22: Frame limit. Driver should init to 10 (0xa). 46662306a36Sopenharmony_ci * 46762306a36Sopenharmony_ci * Driver should init all other bits to 0. 46862306a36Sopenharmony_ci * 46962306a36Sopenharmony_ci * Init must be done after driver receives "Alive" response from 4965 uCode, 47062306a36Sopenharmony_ci * and when setting up queue for aggregation. 47162306a36Sopenharmony_ci */ 47262306a36Sopenharmony_ci#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 47362306a36Sopenharmony_ci#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ 47462306a36Sopenharmony_ci (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) 47562306a36Sopenharmony_ci 47662306a36Sopenharmony_ci#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) 47762306a36Sopenharmony_ci#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) 47862306a36Sopenharmony_ci#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) 47962306a36Sopenharmony_ci#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) 48062306a36Sopenharmony_ci 48162306a36Sopenharmony_ci/* 48262306a36Sopenharmony_ci * Tx Status Bitmap 48362306a36Sopenharmony_ci * 48462306a36Sopenharmony_ci * Driver should clear this entire area (size 0x100) to 0 after receiving 48562306a36Sopenharmony_ci * "Alive" notification from uCode. Area is used only by device itself; 48662306a36Sopenharmony_ci * no other support (besides clearing) is required from driver. 48762306a36Sopenharmony_ci */ 48862306a36Sopenharmony_ci#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_ci/* 49162306a36Sopenharmony_ci * RAxTID to queue translation mapping. 49262306a36Sopenharmony_ci * 49362306a36Sopenharmony_ci * When queue is in Scheduler-ACK mode, frames placed in a that queue must be 49462306a36Sopenharmony_ci * for only one combination of receiver address (RA) and traffic ID (TID), i.e. 49562306a36Sopenharmony_ci * one QOS priority level destined for one station (for this wireless link, 49662306a36Sopenharmony_ci * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit 49762306a36Sopenharmony_ci * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK 49862306a36Sopenharmony_ci * mode, the device ignores the mapping value. 49962306a36Sopenharmony_ci * 50062306a36Sopenharmony_ci * Bit fields, for each 16-bit map: 50162306a36Sopenharmony_ci * 15-9: Reserved, set to 0 50262306a36Sopenharmony_ci * 8-4: Index into device's station table for recipient station 50362306a36Sopenharmony_ci * 3-0: Traffic ID (tid), range 0-15 50462306a36Sopenharmony_ci * 50562306a36Sopenharmony_ci * Driver should clear this entire area (size 32 bytes) to 0 after receiving 50662306a36Sopenharmony_ci * "Alive" notification from uCode. To update a 16-bit map value, driver 50762306a36Sopenharmony_ci * must read a dword-aligned value from device SRAM, replace the 16-bit map 50862306a36Sopenharmony_ci * value of interest, and write the dword value back into device SRAM. 50962306a36Sopenharmony_ci */ 51062306a36Sopenharmony_ci#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 51162306a36Sopenharmony_ci 51262306a36Sopenharmony_ci/* Find translation table dword to read/write for given queue */ 51362306a36Sopenharmony_ci#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ 51462306a36Sopenharmony_ci ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) 51562306a36Sopenharmony_ci 51662306a36Sopenharmony_ci#define IL_SCD_TXFIFO_POS_TID (0) 51762306a36Sopenharmony_ci#define IL_SCD_TXFIFO_POS_RA (4) 51862306a36Sopenharmony_ci#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) 51962306a36Sopenharmony_ci 52062306a36Sopenharmony_ci/*********************** END TX SCHEDULER *************************************/ 52162306a36Sopenharmony_ci 52262306a36Sopenharmony_ci#endif /* __il_prph_h__ */ 523