blob: 83ab60496388e2b40a62cee01faec0b3fde491ff [file] [log] [blame]
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -08001/******************************************************************************
2 *
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -08003 * GPL LICENSE SUMMARY
4 *
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +02005 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -08006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -080028 *****************************************************************************/
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -080029
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020030#ifndef __il_4965_h__
31#define __il_4965_h__
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -080032
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020033struct il_rx_queue;
34struct il_rx_buf;
35struct il_rx_pkt;
36struct il_tx_queue;
37struct il_rxon_context;
38
39/* configuration for the _4965 devices */
40extern struct il_cfg il4965_cfg;
Stanislaw Gruszkac39ae9f2012-02-03 17:31:58 +010041extern const struct il_ops il4965_ops;
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020042
43extern struct il_mod_params il4965_mod_params;
44
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020045/* tx queue */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010046void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid,
47 int freed);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020048
49/* RXON */
Stanislaw Gruszka83007192012-02-03 17:31:57 +010050void il4965_set_rxon_chain(struct il_priv *il);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020051
52/* uCode */
53int il4965_verify_ucode(struct il_priv *il);
54
55/* lib */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010056void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020057
58void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
59int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq);
60int il4965_hw_nic_init(struct il_priv *il);
61int il4965_dump_fh(struct il_priv *il, char **buf, bool display);
62
63/* rx */
64void il4965_rx_queue_restock(struct il_priv *il);
65void il4965_rx_replenish(struct il_priv *il);
66void il4965_rx_replenish_now(struct il_priv *il);
67void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq);
68int il4965_rxq_stop(struct il_priv *il);
69int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010070void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb);
71void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020072void il4965_rx_handle(struct il_priv *il);
73
74/* tx */
75void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010076int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
77 dma_addr_t addr, u16 len, u8 reset, u8 pad);
78int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020079void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010080 struct ieee80211_tx_info *info);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020081int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb);
82int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010083 struct ieee80211_sta *sta, u16 tid, u16 * ssn);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020084int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
85 struct ieee80211_sta *sta, u16 tid);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010086int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id);
87void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020088int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx);
89void il4965_hw_txq_ctx_free(struct il_priv *il);
90int il4965_txq_ctx_alloc(struct il_priv *il);
91void il4965_txq_ctx_reset(struct il_priv *il);
92void il4965_txq_ctx_stop(struct il_priv *il);
93void il4965_txq_set_sched(struct il_priv *il, u32 mask);
94
95/*
96 * Acquire il->lock before calling this function !
97 */
98void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx);
99/**
100 * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue
101 * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed
102 * @scd_retry: (1) Indicates queue will be used in aggregation mode
103 *
104 * NOTE: Acquire il->lock before calling this function !
105 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100106void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq,
107 int tx_fifo_id, int scd_retry);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200108
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200109/* rx */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100110void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb);
111bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt);
112void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb);
113void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200114
115/* scan */
116int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
117
118/* station mgmt */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100119int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
120 bool add);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200121
122/* hcmd */
123int il4965_send_beacon_cmd(struct il_priv *il);
124
125#ifdef CONFIG_IWLEGACY_DEBUG
126const char *il4965_get_tx_fail_reason(u32 status);
127#else
128static inline const char *
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100129il4965_get_tx_fail_reason(u32 status)
130{
131 return "";
132}
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200133#endif
134
135/* station management */
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100136int il4965_alloc_bcast_station(struct il_priv *il);
137int il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200138int il4965_remove_default_wep_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100139 struct ieee80211_key_conf *key);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100140int il4965_set_default_wep_key(struct il_priv *il,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200141 struct ieee80211_key_conf *key);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100142int il4965_restore_default_wep_keys(struct il_priv *il);
143int il4965_set_dynamic_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100144 struct ieee80211_key_conf *key, u8 sta_id);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100145int il4965_remove_dynamic_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100146 struct ieee80211_key_conf *key, u8 sta_id);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100147void il4965_update_tkip_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100148 struct ieee80211_key_conf *keyconf,
149 struct ieee80211_sta *sta, u32 iv32,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100150 u16 *phase1key);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100151int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200152int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100153 int tid, u16 ssn);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200154int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100155 int tid);
156void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200157int il4965_update_bcast_stations(struct il_priv *il);
158
159/* rate */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100160static inline u8
161il4965_hw_get_rate(__le32 rate_n_flags)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200162{
163 return le32_to_cpu(rate_n_flags) & 0xFF;
164}
165
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200166/* eeprom */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100167void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200168int il4965_eeprom_acquire_semaphore(struct il_priv *il);
169void il4965_eeprom_release_semaphore(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100170int il4965_eeprom_check_version(struct il_priv *il);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200171
172/* mac80211 handlers (for 4965) */
173void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
174int il4965_mac_start(struct ieee80211_hw *hw);
175void il4965_mac_stop(struct ieee80211_hw *hw);
176void il4965_configure_filter(struct ieee80211_hw *hw,
177 unsigned int changed_flags,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100178 unsigned int *total_flags, u64 multicast);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200179int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
180 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
181 struct ieee80211_key_conf *key);
182void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
183 struct ieee80211_vif *vif,
184 struct ieee80211_key_conf *keyconf,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100185 struct ieee80211_sta *sta, u32 iv32,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100186 u16 *phase1key);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100187int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200188 enum ieee80211_ampdu_mlme_action action,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100189 struct ieee80211_sta *sta, u16 tid, u16 * ssn,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200190 u8 buf_size);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100191int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200192 struct ieee80211_sta *sta);
193void il4965_mac_channel_switch(struct ieee80211_hw *hw,
194 struct ieee80211_channel_switch *ch_switch);
195
196void il4965_led_enable(struct il_priv *il);
197
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800198/* EEPROM */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100199#define IL4965_EEPROM_IMG_SIZE 1024
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800200
201/*
202 * uCode queue management definitions ...
203 * The first queue used for block-ack aggregation is #7 (4965 only).
204 * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7.
205 */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100206#define IL49_FIRST_AMPDU_QUEUE 7
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800207
208/* Sizes and addresses for instruction and data memory (SRAM) in
209 * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100210#define IL49_RTC_INST_LOWER_BOUND (0x000000)
211#define IL49_RTC_INST_UPPER_BOUND (0x018000)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800212
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100213#define IL49_RTC_DATA_LOWER_BOUND (0x800000)
214#define IL49_RTC_DATA_UPPER_BOUND (0x80A000)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800215
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100216#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \
217 IL49_RTC_INST_LOWER_BOUND)
218#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \
219 IL49_RTC_DATA_LOWER_BOUND)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800220
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100221#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE
222#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800223
224/* Size of uCode instruction memory in bootstrap state machine */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100225#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800226
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100227static inline int
228il4965_hw_valid_rtc_data_addr(u32 addr)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800229{
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100230 return (addr >= IL49_RTC_DATA_LOWER_BOUND &&
231 addr < IL49_RTC_DATA_UPPER_BOUND);
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800232}
233
234/********************* START TEMPERATURE *************************************/
235
236/**
237 * 4965 temperature calculation.
238 *
239 * The driver must calculate the device temperature before calculating
240 * a txpower setting (amplifier gain is temperature dependent). The
241 * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration
242 * values used for the life of the driver, and one of which (R4) is the
243 * real-time temperature indicator.
244 *
245 * uCode provides all 4 values to the driver via the "initialize alive"
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200246 * notification (see struct il4965_init_alive_resp). After the runtime uCode
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +0200247 * image loads, uCode updates the R4 value via stats notifications
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200248 * (see N_STATS), which occur after each received beacon
249 * when associated, or can be requested via C_STATS.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800250 *
251 * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver
252 * must sign-extend to 32 bits before applying formula below.
253 *
254 * Formula:
255 *
256 * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8
257 *
258 * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is
259 * an additional correction, which should be centered around 0 degrees
260 * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for
261 * centering the 97/100 correction around 0 degrees K.
262 *
263 * Add 273 to Kelvin value to find degrees Celsius, for comparing current
264 * temperature with factory-measured temperatures when calculating txpower
265 * settings.
266 */
267#define TEMPERATURE_CALIB_KELVIN_OFFSET 8
268#define TEMPERATURE_CALIB_A_VAL 259
269
270/* Limit range of calculated temperature to be between these Kelvin values */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200271#define IL_TX_POWER_TEMPERATURE_MIN (263)
272#define IL_TX_POWER_TEMPERATURE_MAX (410)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800273
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200274#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
Stanislaw Gruszka232913b2011-08-26 10:45:16 +0200275 ((t) < IL_TX_POWER_TEMPERATURE_MIN || \
276 (t) > IL_TX_POWER_TEMPERATURE_MAX)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800277
278/********************* END TEMPERATURE ***************************************/
279
280/********************* START TXPOWER *****************************************/
281
282/**
283 * 4965 txpower calculations rely on information from three sources:
284 *
285 * 1) EEPROM
286 * 2) "initialize" alive notification
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +0200287 * 3) stats notifications
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800288 *
289 * EEPROM data consists of:
290 *
291 * 1) Regulatory information (max txpower and channel usage flags) is provided
292 * separately for each channel that can possibly supported by 4965.
293 * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz
294 * (legacy) channels.
295 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200296 * See struct il4965_eeprom_channel for format, and struct il4965_eeprom
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800297 * for locations in EEPROM.
298 *
299 * 2) Factory txpower calibration information is provided separately for
300 * sub-bands of contiguous channels. 2.4GHz has just one sub-band,
301 * but 5 GHz has several sub-bands.
302 *
303 * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided.
304 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200305 * See struct il4965_eeprom_calib_info (and the tree of structures
306 * contained within it) for format, and struct il4965_eeprom for
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800307 * locations in EEPROM.
308 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200309 * "Initialization alive" notification (see struct il4965_init_alive_resp)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800310 * consists of:
311 *
312 * 1) Temperature calculation parameters.
313 *
314 * 2) Power supply voltage measurement.
315 *
316 * 3) Tx gain compensation to balance 2 transmitters for MIMO use.
317 *
318 * Statistics notifications deliver:
319 *
320 * 1) Current values for temperature param R4.
321 */
322
323/**
324 * To calculate a txpower setting for a given desired target txpower, channel,
325 * modulation bit rate, and transmitter chain (4965 has 2 transmitters to
326 * support MIMO and transmit diversity), driver must do the following:
327 *
328 * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel.
329 * Do not exceed regulatory limit; reduce target txpower if necessary.
330 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100331 * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800332 * 2 transmitters will be used simultaneously; driver must reduce the
333 * regulatory limit by 3 dB (half-power) for each transmitter, so the
334 * combined total output of the 2 transmitters is within regulatory limits.
335 *
336 *
337 * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by
338 * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]);
339 * reduce target txpower if necessary.
340 *
341 * Backoff values below are in 1/2 dB units (equivalent to steps in
342 * txpower gain tables):
343 *
344 * OFDM 6 - 36 MBit: 10 steps (5 dB)
345 * OFDM 48 MBit: 15 steps (7.5 dB)
346 * OFDM 54 MBit: 17 steps (8.5 dB)
347 * OFDM 60 MBit: 20 steps (10 dB)
348 * CCK all rates: 10 steps (5 dB)
349 *
350 * Backoff values apply to saturation txpower on a per-transmitter basis;
351 * when using MIMO (2 transmitters), each transmitter uses the same
352 * saturation level provided in EEPROM, and the same backoff values;
353 * no reduction (such as with regulatory txpower limits) is required.
354 *
355 * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel
356 * widths and 40 Mhz (.11n HT40) channel widths; there is no separate
357 * factory measurement for ht40 channels.
358 *
359 * The result of this step is the final target txpower. The rest of
360 * the steps figure out the proper settings for the device to achieve
361 * that target txpower.
362 *
363 *
364 * 3) Determine (EEPROM) calibration sub band for the target channel, by
365 * comparing against first and last channels in each sub band
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200366 * (see struct il4965_eeprom_calib_subband_info).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800367 *
368 *
369 * 4) Linearly interpolate (EEPROM) factory calibration measurement sets,
370 * referencing the 2 factory-measured (sample) channels within the sub band.
371 *
372 * Interpolation is based on difference between target channel's frequency
373 * and the sample channels' frequencies. Since channel numbers are based
374 * on frequency (5 MHz between each channel number), this is equivalent
375 * to interpolating based on channel number differences.
376 *
377 * Note that the sample channels may or may not be the channels at the
378 * edges of the sub band. The target channel may be "outside" of the
379 * span of the sampled channels.
380 *
381 * Driver may choose the pair (for 2 Tx chains) of measurements (see
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200382 * struct il4965_eeprom_calib_ch_info) for which the actual measured
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800383 * txpower comes closest to the desired txpower. Usually, though,
384 * the middle set of measurements is closest to the regulatory limits,
385 * and is therefore a good choice for all txpower calculations (this
386 * assumes that high accuracy is needed for maximizing legal txpower,
387 * while lower txpower configurations do not need as much accuracy).
388 *
389 * Driver should interpolate both members of the chosen measurement pair,
390 * i.e. for both Tx chains (radio transmitters), unless the driver knows
391 * that only one of the chains will be used (e.g. only one tx antenna
392 * connected, but this should be unusual). The rate scaling algorithm
393 * switches antennas to find best performance, so both Tx chains will
394 * be used (although only one at a time) even for non-MIMO transmissions.
395 *
396 * Driver should interpolate factory values for temperature, gain table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100397 * idx, and actual power. The power amplifier detector values are
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800398 * not used by the driver.
399 *
400 * Sanity check: If the target channel happens to be one of the sample
401 * channels, the results should agree with the sample channel's
402 * measurements!
403 *
404 *
405 * 5) Find difference between desired txpower and (interpolated)
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100406 * factory-measured txpower. Using (interpolated) factory gain table idx
407 * (shown elsewhere) as a starting point, adjust this idx lower to
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800408 * increase txpower, or higher to decrease txpower, until the target
409 * txpower is reached. Each step in the gain table is 1/2 dB.
410 *
411 * For example, if factory measured txpower is 16 dBm, and target txpower
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100412 * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800413 * by 3 dB.
414 *
415 *
416 * 6) Find difference between current device temperature and (interpolated)
417 * factory-measured temperature for sub-band. Factory values are in
418 * degrees Celsius. To calculate current temperature, see comments for
419 * "4965 temperature calculation".
420 *
421 * If current temperature is higher than factory temperature, driver must
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100422 * increase gain (lower gain table idx), and vice verse.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800423 *
424 * Temperature affects gain differently for different channels:
425 *
426 * 2.4 GHz all channels: 3.5 degrees per half-dB step
427 * 5 GHz channels 34-43: 4.5 degrees per half-dB step
428 * 5 GHz channels >= 44: 4.0 degrees per half-dB step
429 *
430 * NOTE: Temperature can increase rapidly when transmitting, especially
431 * with heavy traffic at high txpowers. Driver should update
432 * temperature calculations often under these conditions to
433 * maintain strong txpower in the face of rising temperature.
434 *
435 *
436 * 7) Find difference between current power supply voltage indicator
437 * (from "initialize alive") and factory-measured power supply voltage
438 * indicator (EEPROM).
439 *
440 * If the current voltage is higher (indicator is lower) than factory
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100441 * voltage, gain should be reduced (gain table idx increased) by:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800442 *
443 * (eeprom - current) / 7
444 *
445 * If the current voltage is lower (indicator is higher) than factory
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100446 * voltage, gain should be increased (gain table idx decreased) by:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800447 *
448 * 2 * (current - eeprom) / 7
449 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100450 * If number of idx steps in either direction turns out to be > 2,
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800451 * something is wrong ... just use 0.
452 *
453 * NOTE: Voltage compensation is independent of band/channel.
454 *
455 * NOTE: "Initialize" uCode measures current voltage, which is assumed
456 * to be constant after this initial measurement. Voltage
457 * compensation for txpower (number of steps in gain table)
458 * may be calculated once and used until the next uCode bootload.
459 *
460 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100461 * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800462 * adjust txpower for each transmitter chain, so txpower is balanced
463 * between the two chains. There are 5 pairs of tx_atten[group][chain]
464 * values in "initialize alive", one pair for each of 5 channel ranges:
465 *
466 * Group 0: 5 GHz channel 34-43
467 * Group 1: 5 GHz channel 44-70
468 * Group 2: 5 GHz channel 71-124
469 * Group 3: 5 GHz channel 125-200
470 * Group 4: 2.4 GHz all channels
471 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100472 * Add the tx_atten[group][chain] value to the idx for the target chain.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800473 * The values are signed, but are in pairs of 0 and a non-negative number,
474 * so as to reduce gain (if necessary) of the "hotter" channel. This
475 * avoids any need to double-check for regulatory compliance after
476 * this step.
477 *
478 *
479 * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100480 * value to the idx:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800481 *
482 * Hardware rev B: 9 steps (4.5 dB)
483 * Hardware rev C: 5 steps (2.5 dB)
484 *
485 * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
486 * bits [3:2], 1 = B, 2 = C.
487 *
488 * NOTE: This compensation is in addition to any saturation backoff that
489 * might have been applied in an earlier step.
490 *
491 *
492 * 10) Select the gain table, based on band (2.4 vs 5 GHz).
493 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100494 * Limit the adjusted idx to stay within the table!
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800495 *
496 *
497 * 11) Read gain table entries for DSP and radio gain, place into appropriate
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200498 * location(s) in command (struct il4965_txpowertable_cmd).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800499 */
500
501/**
502 * When MIMO is used (2 transmitters operating simultaneously), driver should
503 * limit each transmitter to deliver a max of 3 dB below the regulatory limit
504 * for the device. That is, use half power for each transmitter, so total
505 * txpower is within regulatory limits.
506 *
507 * The value "6" represents number of steps in gain table to reduce power 3 dB.
508 * Each step is 1/2 dB.
509 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200510#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800511
512/**
513 * CCK gain compensation.
514 *
515 * When calculating txpowers for CCK, after making sure that the target power
516 * is within regulatory and saturation limits, driver must additionally
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100517 * back off gain by adding these values to the gain table idx.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800518 *
519 * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
520 * bits [3:2], 1 = B, 2 = C.
521 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200522#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
523#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800524
525/*
526 * 4965 power supply voltage compensation for txpower
527 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200528#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800529
530/**
531 * Gain tables.
532 *
533 * The following tables contain pair of values for setting txpower, i.e.
534 * gain settings for the output of the device's digital signal processor (DSP),
535 * and for the analog gain structure of the transmitter.
536 *
537 * Each entry in the gain tables represents a step of 1/2 dB. Note that these
538 * are *relative* steps, not indications of absolute output power. Output
539 * power varies with temperature, voltage, and channel frequency, and also
540 * requires consideration of average power (to satisfy regulatory constraints),
541 * and peak power (to avoid distortion of the output signal).
542 *
543 * Each entry contains two values:
544 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
545 * linear value that multiplies the output of the digital signal processor,
546 * before being sent to the analog radio.
547 * 2) Radio gain. This sets the analog gain of the radio Tx path.
548 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
549 *
550 * EEPROM contains factory calibration data for txpower. This maps actual
551 * measured txpower levels to gain settings in the "well known" tables
552 * below ("well-known" means here that both factory calibration *and* the
553 * driver work with the same table).
554 *
555 * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100556 * has an extension (into negative idxes), in case the driver needs to
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800557 * boost power setting for high device temperatures (higher than would be
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100558 * present during factory calibration). A 5 Ghz EEPROM idx of "40"
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800559 * corresponds to the 49th entry in the table used by the driver.
560 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100561#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */
562#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800563
564/**
565 * 2.4 GHz gain table
566 *
567 * Index Dsp gain Radio gain
568 * 0 110 0x3f (highest gain)
569 * 1 104 0x3f
570 * 2 98 0x3f
571 * 3 110 0x3e
572 * 4 104 0x3e
573 * 5 98 0x3e
574 * 6 110 0x3d
575 * 7 104 0x3d
576 * 8 98 0x3d
577 * 9 110 0x3c
578 * 10 104 0x3c
579 * 11 98 0x3c
580 * 12 110 0x3b
581 * 13 104 0x3b
582 * 14 98 0x3b
583 * 15 110 0x3a
584 * 16 104 0x3a
585 * 17 98 0x3a
586 * 18 110 0x39
587 * 19 104 0x39
588 * 20 98 0x39
589 * 21 110 0x38
590 * 22 104 0x38
591 * 23 98 0x38
592 * 24 110 0x37
593 * 25 104 0x37
594 * 26 98 0x37
595 * 27 110 0x36
596 * 28 104 0x36
597 * 29 98 0x36
598 * 30 110 0x35
599 * 31 104 0x35
600 * 32 98 0x35
601 * 33 110 0x34
602 * 34 104 0x34
603 * 35 98 0x34
604 * 36 110 0x33
605 * 37 104 0x33
606 * 38 98 0x33
607 * 39 110 0x32
608 * 40 104 0x32
609 * 41 98 0x32
610 * 42 110 0x31
611 * 43 104 0x31
612 * 44 98 0x31
613 * 45 110 0x30
614 * 46 104 0x30
615 * 47 98 0x30
616 * 48 110 0x6
617 * 49 104 0x6
618 * 50 98 0x6
619 * 51 110 0x5
620 * 52 104 0x5
621 * 53 98 0x5
622 * 54 110 0x4
623 * 55 104 0x4
624 * 56 98 0x4
625 * 57 110 0x3
626 * 58 104 0x3
627 * 59 98 0x3
628 * 60 110 0x2
629 * 61 104 0x2
630 * 62 98 0x2
631 * 63 110 0x1
632 * 64 104 0x1
633 * 65 98 0x1
634 * 66 110 0x0
635 * 67 104 0x0
636 * 68 98 0x0
637 * 69 97 0
638 * 70 96 0
639 * 71 95 0
640 * 72 94 0
641 * 73 93 0
642 * 74 92 0
643 * 75 91 0
644 * 76 90 0
645 * 77 89 0
646 * 78 88 0
647 * 79 87 0
648 * 80 86 0
649 * 81 85 0
650 * 82 84 0
651 * 83 83 0
652 * 84 82 0
653 * 85 81 0
654 * 86 80 0
655 * 87 79 0
656 * 88 78 0
657 * 89 77 0
658 * 90 76 0
659 * 91 75 0
660 * 92 74 0
661 * 93 73 0
662 * 94 72 0
663 * 95 71 0
664 * 96 70 0
665 * 97 69 0
666 * 98 68 0
667 */
668
669/**
670 * 5 GHz gain table
671 *
672 * Index Dsp gain Radio gain
673 * -9 123 0x3F (highest gain)
674 * -8 117 0x3F
675 * -7 110 0x3F
676 * -6 104 0x3F
677 * -5 98 0x3F
678 * -4 110 0x3E
679 * -3 104 0x3E
680 * -2 98 0x3E
681 * -1 110 0x3D
682 * 0 104 0x3D
683 * 1 98 0x3D
684 * 2 110 0x3C
685 * 3 104 0x3C
686 * 4 98 0x3C
687 * 5 110 0x3B
688 * 6 104 0x3B
689 * 7 98 0x3B
690 * 8 110 0x3A
691 * 9 104 0x3A
692 * 10 98 0x3A
693 * 11 110 0x39
694 * 12 104 0x39
695 * 13 98 0x39
696 * 14 110 0x38
697 * 15 104 0x38
698 * 16 98 0x38
699 * 17 110 0x37
700 * 18 104 0x37
701 * 19 98 0x37
702 * 20 110 0x36
703 * 21 104 0x36
704 * 22 98 0x36
705 * 23 110 0x35
706 * 24 104 0x35
707 * 25 98 0x35
708 * 26 110 0x34
709 * 27 104 0x34
710 * 28 98 0x34
711 * 29 110 0x33
712 * 30 104 0x33
713 * 31 98 0x33
714 * 32 110 0x32
715 * 33 104 0x32
716 * 34 98 0x32
717 * 35 110 0x31
718 * 36 104 0x31
719 * 37 98 0x31
720 * 38 110 0x30
721 * 39 104 0x30
722 * 40 98 0x30
723 * 41 110 0x25
724 * 42 104 0x25
725 * 43 98 0x25
726 * 44 110 0x24
727 * 45 104 0x24
728 * 46 98 0x24
729 * 47 110 0x23
730 * 48 104 0x23
731 * 49 98 0x23
732 * 50 110 0x22
733 * 51 104 0x18
734 * 52 98 0x18
735 * 53 110 0x17
736 * 54 104 0x17
737 * 55 98 0x17
738 * 56 110 0x16
739 * 57 104 0x16
740 * 58 98 0x16
741 * 59 110 0x15
742 * 60 104 0x15
743 * 61 98 0x15
744 * 62 110 0x14
745 * 63 104 0x14
746 * 64 98 0x14
747 * 65 110 0x13
748 * 66 104 0x13
749 * 67 98 0x13
750 * 68 110 0x12
751 * 69 104 0x08
752 * 70 98 0x08
753 * 71 110 0x07
754 * 72 104 0x07
755 * 73 98 0x07
756 * 74 110 0x06
757 * 75 104 0x06
758 * 76 98 0x06
759 * 77 110 0x05
760 * 78 104 0x05
761 * 79 98 0x05
762 * 80 110 0x04
763 * 81 104 0x04
764 * 82 98 0x04
765 * 83 110 0x03
766 * 84 104 0x03
767 * 85 98 0x03
768 * 86 110 0x02
769 * 87 104 0x02
770 * 88 98 0x02
771 * 89 110 0x01
772 * 90 104 0x01
773 * 91 98 0x01
774 * 92 110 0x00
775 * 93 104 0x00
776 * 94 98 0x00
777 * 95 93 0x00
778 * 96 88 0x00
779 * 97 83 0x00
780 * 98 78 0x00
781 */
782
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800783/**
784 * Sanity checks and default values for EEPROM regulatory levels.
785 * If EEPROM values fall outside MIN/MAX range, use default values.
786 *
787 * Regulatory limits refer to the maximum average txpower allowed by
788 * regulatory agencies in the geographies in which the device is meant
789 * to be operated. These limits are SKU-specific (i.e. geography-specific),
790 * and channel-specific; each channel has an individual regulatory limit
791 * listed in the EEPROM.
792 *
793 * Units are in half-dBm (i.e. "34" means 17 dBm).
794 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200795#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34)
796#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34)
797#define IL_TX_POWER_REGULATORY_MIN (0)
798#define IL_TX_POWER_REGULATORY_MAX (34)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800799
800/**
801 * Sanity checks and default values for EEPROM saturation levels.
802 * If EEPROM values fall outside MIN/MAX range, use default values.
803 *
804 * Saturation is the highest level that the output power amplifier can produce
805 * without significant clipping distortion. This is a "peak" power level.
806 * Different types of modulation (i.e. various "rates", and OFDM vs. CCK)
807 * require differing amounts of backoff, relative to their average power output,
808 * in order to avoid clipping distortion.
809 *
810 * Driver must make sure that it is violating neither the saturation limit,
811 * nor the regulatory limit, when calculating Tx power settings for various
812 * rates.
813 *
814 * Units are in half-dBm (i.e. "38" means 19 dBm).
815 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200816#define IL_TX_POWER_DEFAULT_SATURATION_24 (38)
817#define IL_TX_POWER_DEFAULT_SATURATION_52 (38)
818#define IL_TX_POWER_SATURATION_MIN (20)
819#define IL_TX_POWER_SATURATION_MAX (50)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800820
821/**
822 * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance)
823 * and thermal Txpower calibration.
824 *
825 * When calculating txpower, driver must compensate for current device
826 * temperature; higher temperature requires higher gain. Driver must calculate
827 * current temperature (see "4965 temperature calculation"), then compare vs.
828 * factory calibration temperature in EEPROM; if current temperature is higher
829 * than factory temperature, driver must *increase* gain by proportions shown
830 * in table below. If current temperature is lower than factory, driver must
831 * *decrease* gain.
832 *
833 * Different frequency ranges require different compensation, as shown below.
834 */
835/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200836#define CALIB_IL_TX_ATTEN_GR1_FCH 34
837#define CALIB_IL_TX_ATTEN_GR1_LCH 43
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800838
839/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200840#define CALIB_IL_TX_ATTEN_GR2_FCH 44
841#define CALIB_IL_TX_ATTEN_GR2_LCH 70
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800842
843/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200844#define CALIB_IL_TX_ATTEN_GR3_FCH 71
845#define CALIB_IL_TX_ATTEN_GR3_LCH 124
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800846
847/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200848#define CALIB_IL_TX_ATTEN_GR4_FCH 125
849#define CALIB_IL_TX_ATTEN_GR4_LCH 200
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800850
851/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200852#define CALIB_IL_TX_ATTEN_GR5_FCH 1
853#define CALIB_IL_TX_ATTEN_GR5_LCH 20
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800854
855enum {
856 CALIB_CH_GROUP_1 = 0,
857 CALIB_CH_GROUP_2 = 1,
858 CALIB_CH_GROUP_3 = 2,
859 CALIB_CH_GROUP_4 = 3,
860 CALIB_CH_GROUP_5 = 4,
861 CALIB_CH_GROUP_MAX
862};
863
864/********************* END TXPOWER *****************************************/
865
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800866/**
867 * Tx/Rx Queues
868 *
869 * Most communication between driver and 4965 is via queues of data buffers.
870 * For example, all commands that the driver issues to device's embedded
871 * controller (uCode) are via the command queue (one of the Tx queues). All
872 * uCode command responses/replies/notifications, including Rx frames, are
873 * conveyed from uCode to driver via the Rx queue.
874 *
875 * Most support for these queues, including handshake support, resides in
876 * structures in host DRAM, shared between the driver and the device. When
877 * allocating this memory, the driver must make sure that data written by
878 * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
879 * cache memory), so DRAM and cache are consistent, and the device can
880 * immediately see changes made by the driver.
881 *
882 * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via
883 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array
884 * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
885 */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100886#define IL49_NUM_FIFOS 7
887#define IL49_CMD_FIFO_NUM 4
888#define IL49_NUM_QUEUES 16
889#define IL49_NUM_AMPDU_QUEUES 8
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800890
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800891/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200892 * struct il4965_schedq_bc_tbl
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800893 *
894 * Byte Count table
895 *
896 * Each Tx queue uses a byte-count table containing 320 entries:
897 * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200898 * duplicate the first 64 entries (to avoid wrap-around within a Tx win;
899 * max Tx win is 64 TFDs).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800900 *
901 * When driver sets up a new TFD, it must also enter the total byte count
902 * of the frame to be transmitted into the corresponding entry in the byte
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100903 * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver
904 * must duplicate the byte count entry in corresponding idx 256-319.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800905 *
906 * padding puts each byte count table on a 1024-byte boundary;
907 * 4965 assumes tables are separated by 1024 bytes.
908 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200909struct il4965_scd_bc_tbl {
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800910 __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
911 u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)];
912} __packed;
913
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100914#define IL4965_RTC_INST_LOWER_BOUND (0x000000)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800915
916/* RSSI to dBm */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100917#define IL4965_RSSI_OFFSET 44
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800918
919/* PCI registers */
920#define PCI_CFG_RETRY_TIMEOUT 0x041
921
922/* PCI register values */
923#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
924#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
925
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100926#define IL4965_DEFAULT_TX_RETRY 15
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800927
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800928/* EEPROM */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100929#define IL4965_FIRST_AMPDU_QUEUE 10
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800930
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200931/* Calibration */
932void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp);
933void il4965_sensitivity_calibration(struct il_priv *il, void *resp);
934void il4965_init_sensitivity(struct il_priv *il);
935void il4965_reset_run_time_calib(struct il_priv *il);
936void il4965_calib_free_results(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800937
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200938/* Debug */
939#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100940ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf,
941 size_t count, loff_t *ppos);
942ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf,
943 size_t count, loff_t *ppos);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200944ssize_t il4965_ucode_general_stats_read(struct file *file,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100945 char __user *user_buf, size_t count,
946 loff_t *ppos);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200947#endif
948
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200949/****************************/
950/* Flow Handler Definitions */
951/****************************/
952
953/**
954 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
955 * Addresses are offsets from device's PCI hardware base address.
956 */
957#define FH49_MEM_LOWER_BOUND (0x1000)
958#define FH49_MEM_UPPER_BOUND (0x2000)
959
960/**
961 * Keep-Warm (KW) buffer base address.
962 *
963 * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
964 * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
965 * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host
966 * from going into a power-savings mode that would cause higher DRAM latency,
967 * and possible data over/under-runs, before all Tx/Rx is complete.
968 *
969 * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4)
970 * of the buffer, which must be 4K aligned. Once this is set up, the 4965
971 * automatically invokes keep-warm accesses when normal accesses might not
972 * be sufficient to maintain fast DRAM response.
973 *
974 * Bit fields:
975 * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned
976 */
977#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C)
978
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200979/**
980 * TFD Circular Buffers Base (CBBC) addresses
981 *
982 * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
983 * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
984 * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04
985 * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
986 * aligned (address bits 0-7 must be 0).
987 *
988 * Bit fields in each pointer register:
989 * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
990 */
991#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0)
992#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10)
993
994/* Find TFD CB base pointer for given queue (range 0-15). */
995#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
996
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200997/**
998 * Rx SRAM Control and Status Registers (RSCSR)
999 *
1000 * These registers provide handshake between driver and 4965 for the Rx queue
1001 * (this queue handles *all* command responses, notifications, Rx data, etc.
1002 * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx
1003 * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can
1004 * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
1005 * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
1006 * mapping between RBDs and RBs.
1007 *
1008 * Driver must allocate host DRAM memory for the following, and set the
1009 * physical address of each into 4965 registers:
1010 *
1011 * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
1012 * entries (although any power of 2, up to 4096, is selectable by driver).
1013 * Each entry (1 dword) points to a receive buffer (RB) of consistent size
1014 * (typically 4K, although 8K or 16K are also selectable by driver).
1015 * Driver sets up RB size and number of RBDs in the CB via Rx config
1016 * register FH49_MEM_RCSR_CHNL0_CONFIG_REG.
1017 *
1018 * Bit fields within one RBD:
1019 * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned
1020 *
1021 * Driver sets physical address [35:8] of base of RBD circular buffer
1022 * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
1023 *
1024 * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
1025 * (RBs) have been filled, via a "write pointer", actually the idx of
1026 * the RB's corresponding RBD within the circular buffer. Driver sets
1027 * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
1028 *
1029 * Bit fields in lower dword of Rx status buffer (upper dword not used
1030 * by driver; see struct il4965_shared, val0):
1031 * 31-12: Not used by driver
1032 * 11- 0: Index of last filled Rx buffer descriptor
1033 * (4965 writes, driver reads this value)
1034 *
1035 * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
1036 * enter pointers to these RBs into contiguous RBD circular buffer entries,
1037 * and update the 4965's "write" idx register,
1038 * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG.
1039 *
1040 * This "write" idx corresponds to the *next* RBD that the driver will make
1041 * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
1042 * the circular buffer. This value should initially be 0 (before preparing any
1043 * RBs), should be 8 after preparing the first 8 RBs (for example), and must
1044 * wrap back to 0 at the end of the circular buffer (but don't wrap before
1045 * "read" idx has advanced past 1! See below).
1046 * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8.
1047 *
1048 * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
1049 * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
1050 * to tell the driver the idx of the latest filled RBD. The driver must
1051 * read this "read" idx from DRAM after receiving an Rx interrupt from 4965.
1052 *
1053 * The driver must also internally keep track of a third idx, which is the
1054 * next RBD to process. When receiving an Rx interrupt, driver should process
1055 * all filled but unprocessed RBs up to, but not including, the RB
1056 * corresponding to the "read" idx. For example, if "read" idx becomes "1",
1057 * driver may process the RB pointed to by RBD 0. Depending on volume of
1058 * traffic, there may be many RBs to process.
1059 *
1060 * If read idx == write idx, 4965 thinks there is no room to put new data.
1061 * Due to this, the maximum number of filled RBs is 255, instead of 256. To
1062 * be safe, make sure that there is a gap of at least 2 RBDs between "write"
1063 * and "read" idxes; that is, make sure that there are no more than 254
1064 * buffers waiting to be filled.
1065 */
1066#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0)
1067#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00)
1068#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND)
1069
1070/**
1071 * Physical base address of 8-byte Rx Status buffer.
1072 * Bit fields:
1073 * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
1074 */
1075#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0)
1076
1077/**
1078 * Physical base address of Rx Buffer Descriptor Circular Buffer.
1079 * Bit fields:
1080 * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned.
1081 */
1082#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004)
1083
1084/**
1085 * Rx write pointer (idx, really!).
1086 * Bit fields:
1087 * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1.
1088 * NOTE: For 256-entry circular buffer, use only bits [7:0].
1089 */
1090#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008)
1091#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG)
1092
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001093/**
1094 * Rx Config/Status Registers (RCSR)
1095 * Rx Config Reg for channel 0 (only channel used)
1096 *
1097 * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for
1098 * normal operation (see bit fields).
1099 *
1100 * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
1101 * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for
1102 * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
1103 *
1104 * Bit fields:
1105 * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1106 * '10' operate normally
1107 * 29-24: reserved
1108 * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
1109 * min "5" for 32 RBDs, max "12" for 4096 RBDs.
1110 * 19-18: reserved
1111 * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
1112 * '10' 12K, '11' 16K.
1113 * 15-14: reserved
1114 * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
1115 * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
1116 * typical value 0x10 (about 1/2 msec)
1117 * 3- 0: reserved
1118 */
1119#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00)
1120#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0)
1121#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND)
1122
1123#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0)
1124
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001125#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */
1126#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */
1127#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */
1128#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */
1129#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */
1130#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31 */
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001131
1132#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20)
1133#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4)
1134#define RX_RB_TIMEOUT (0x10)
1135
1136#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
1137#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
1138#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
1139
1140#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
1141#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000)
1142#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000)
1143#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000)
1144
1145#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004)
1146#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
1147#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
1148
1149/**
1150 * Rx Shared Status Registers (RSSR)
1151 *
1152 * After stopping Rx DMA channel (writing 0 to
1153 * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
1154 * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
1155 *
1156 * Bit fields:
1157 * 24: 1 = Channel 0 is idle
1158 *
1159 * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
1160 * contain default values that should not be altered by the driver.
1161 */
1162#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40)
1163#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00)
1164
1165#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND)
1166#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004)
1167#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
1168 (FH49_MEM_RSSR_LOWER_BOUND + 0x008)
1169
1170#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
1171
1172#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
1173
1174/* TFDB Area - TFDs buffer table */
1175#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
1176#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900)
1177#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958)
1178#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
1179#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
1180
1181/**
1182 * Transmit DMA Channel Control/Status Registers (TCSR)
1183 *
1184 * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels
1185 * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1186 * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1187 *
1188 * To use a Tx DMA channel, driver must initialize its
1189 * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1190 *
1191 * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1192 * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1193 *
1194 * All other bits should be 0.
1195 *
1196 * Bit fields:
1197 * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1198 * '10' operate normally
1199 * 29- 4: Reserved, set to "0"
1200 * 3: Enable internal DMA requests (1, normal operation), disable (0)
1201 * 2- 0: Reserved, set to "0"
1202 */
1203#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00)
1204#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60)
1205
1206/* Find Control/Status reg for given Tx DMA/FIFO channel */
1207#define FH49_TCSR_CHNL_NUM (7)
1208#define FH50_TCSR_CHNL_NUM (8)
1209
1210/* TCSR: tx_config register values */
1211#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
1212 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl))
1213#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \
1214 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
1215#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \
1216 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
1217
1218#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
1219#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001)
1220
1221#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000)
1222#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008)
1223
1224#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
1225#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
1226#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
1227
1228#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
1229#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
1230#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
1231
1232#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
1233#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
1234#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
1235
1236#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
1237#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
1238#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
1239
1240#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
1241#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
1242
1243/**
1244 * Tx Shared Status Registers (TSSR)
1245 *
1246 * After stopping Tx DMA channel (writing 0 to
1247 * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1248 * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle
1249 * (channel's buffers empty | no pending requests).
1250 *
1251 * Bit fields:
1252 * 31-24: 1 = Channel buffers empty (channel 7:0)
1253 * 23-16: 1 = No pending requests (channel 7:0)
1254 */
1255#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0)
1256#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0)
1257
1258#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010)
1259
1260/**
1261 * Bit fields for TSSR(Tx Shared Status & Control) error status register:
1262 * 31: Indicates an address error when accessed to internal memory
1263 * uCode/driver must write "1" in order to clear this flag
1264 * 30: Indicates that Host did not send the expected number of dwords to FH
1265 * uCode/driver must write "1" in order to clear this flag
1266 * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
1267 * command was received from the scheduler while the TRB was already full
1268 * with previous command
1269 * uCode/driver must write "1" in order to clear this flag
1270 * 7-0: Each status bit indicates a channel's TxCredit error. When an error
1271 * bit is set, it indicates that the FH has received a full indication
1272 * from the RTC TxFIFO and the current value of the TxCredit counter was
1273 * not equal to zero. This mean that the credit mechanism was not
1274 * synchronized to the TxFIFO status
1275 * uCode/driver must write "1" in order to clear this flag
1276 */
1277#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018)
1278
1279#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
1280
1281/* Tx service channels */
1282#define FH49_SRVC_CHNL (9)
1283#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8)
1284#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0)
1285#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
1286 (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
1287
1288#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98)
1289/* Instruct FH to increment the retry count of a packet when
1290 * it is brought from the memory to TX-FIFO
1291 */
1292#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002)
1293
1294/* Keep Warm Size */
1295#define IL_KW_SIZE 0x1000 /* 4k */
1296
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +02001297#endif /* __il_4965_h__ */