blob: 67899602ee52bfd4d1a6a1f6fb8cb7c5f6b79b36 [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;
41
42extern struct il_mod_params il4965_mod_params;
43
44extern struct ieee80211_ops il4965_hw_ops;
45
46/* tx queue */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010047void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid,
48 int freed);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020049
50/* RXON */
Stanislaw Gruszka83007192012-02-03 17:31:57 +010051void il4965_set_rxon_chain(struct il_priv *il);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020052
53/* uCode */
54int il4965_verify_ucode(struct il_priv *il);
55
56/* lib */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010057void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020058
59void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
60int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq);
61int il4965_hw_nic_init(struct il_priv *il);
62int il4965_dump_fh(struct il_priv *il, char **buf, bool display);
63
64/* rx */
65void il4965_rx_queue_restock(struct il_priv *il);
66void il4965_rx_replenish(struct il_priv *il);
67void il4965_rx_replenish_now(struct il_priv *il);
68void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq);
69int il4965_rxq_stop(struct il_priv *il);
70int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010071void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb);
72void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020073void il4965_rx_handle(struct il_priv *il);
74
75/* tx */
76void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010077int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
78 dma_addr_t addr, u16 len, u8 reset, u8 pad);
79int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020080void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010081 struct ieee80211_tx_info *info);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020082int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb);
83int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010084 struct ieee80211_sta *sta, u16 tid, u16 * ssn);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020085int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif,
86 struct ieee80211_sta *sta, u16 tid);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +010087int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id);
88void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +020089int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx);
90void il4965_hw_txq_ctx_free(struct il_priv *il);
91int il4965_txq_ctx_alloc(struct il_priv *il);
92void il4965_txq_ctx_reset(struct il_priv *il);
93void il4965_txq_ctx_stop(struct il_priv *il);
94void il4965_txq_set_sched(struct il_priv *il, u32 mask);
95
96/*
97 * Acquire il->lock before calling this function !
98 */
99void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx);
100/**
101 * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue
102 * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed
103 * @scd_retry: (1) Indicates queue will be used in aggregation mode
104 *
105 * NOTE: Acquire il->lock before calling this function !
106 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100107void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq,
108 int tx_fifo_id, int scd_retry);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200109
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200110/* rx */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100111void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb);
112bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt);
113void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb);
114void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200115
116/* scan */
117int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
118
119/* station mgmt */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100120int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
121 bool add);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200122
123/* hcmd */
124int il4965_send_beacon_cmd(struct il_priv *il);
125
126#ifdef CONFIG_IWLEGACY_DEBUG
127const char *il4965_get_tx_fail_reason(u32 status);
128#else
129static inline const char *
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100130il4965_get_tx_fail_reason(u32 status)
131{
132 return "";
133}
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200134#endif
135
136/* station management */
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100137int il4965_alloc_bcast_station(struct il_priv *il);
138int il4965_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200139int il4965_remove_default_wep_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100140 struct ieee80211_key_conf *key);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100141int il4965_set_default_wep_key(struct il_priv *il,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200142 struct ieee80211_key_conf *key);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100143int il4965_restore_default_wep_keys(struct il_priv *il);
144int il4965_set_dynamic_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100145 struct ieee80211_key_conf *key, u8 sta_id);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100146int il4965_remove_dynamic_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100147 struct ieee80211_key_conf *key, u8 sta_id);
Stanislaw Gruszka83007192012-02-03 17:31:57 +0100148void il4965_update_tkip_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100149 struct ieee80211_key_conf *keyconf,
150 struct ieee80211_sta *sta, u32 iv32,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100151 u16 *phase1key);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100152int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200153int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100154 int tid, u16 ssn);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200155int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100156 int tid);
157void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200158int il4965_update_bcast_stations(struct il_priv *il);
159
160/* rate */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100161static inline u8
162il4965_hw_get_rate(__le32 rate_n_flags)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200163{
164 return le32_to_cpu(rate_n_flags) & 0xFF;
165}
166
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200167/* eeprom */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100168void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200169int il4965_eeprom_acquire_semaphore(struct il_priv *il);
170void il4965_eeprom_release_semaphore(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100171int il4965_eeprom_check_version(struct il_priv *il);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200172
173/* mac80211 handlers (for 4965) */
174void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
175int il4965_mac_start(struct ieee80211_hw *hw);
176void il4965_mac_stop(struct ieee80211_hw *hw);
177void il4965_configure_filter(struct ieee80211_hw *hw,
178 unsigned int changed_flags,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100179 unsigned int *total_flags, u64 multicast);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200180int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
181 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
182 struct ieee80211_key_conf *key);
183void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
184 struct ieee80211_vif *vif,
185 struct ieee80211_key_conf *keyconf,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100186 struct ieee80211_sta *sta, u32 iv32,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100187 u16 *phase1key);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100188int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200189 enum ieee80211_ampdu_mlme_action action,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100190 struct ieee80211_sta *sta, u16 tid, u16 * ssn,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200191 u8 buf_size);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100192int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200193 struct ieee80211_sta *sta);
194void il4965_mac_channel_switch(struct ieee80211_hw *hw,
195 struct ieee80211_channel_switch *ch_switch);
196
197void il4965_led_enable(struct il_priv *il);
198
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800199/* EEPROM */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100200#define IL4965_EEPROM_IMG_SIZE 1024
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800201
202/*
203 * uCode queue management definitions ...
204 * The first queue used for block-ack aggregation is #7 (4965 only).
205 * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7.
206 */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100207#define IL49_FIRST_AMPDU_QUEUE 7
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800208
209/* Sizes and addresses for instruction and data memory (SRAM) in
210 * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100211#define IL49_RTC_INST_LOWER_BOUND (0x000000)
212#define IL49_RTC_INST_UPPER_BOUND (0x018000)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800213
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100214#define IL49_RTC_DATA_LOWER_BOUND (0x800000)
215#define IL49_RTC_DATA_UPPER_BOUND (0x80A000)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800216
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100217#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \
218 IL49_RTC_INST_LOWER_BOUND)
219#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \
220 IL49_RTC_DATA_LOWER_BOUND)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800221
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100222#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE
223#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800224
225/* Size of uCode instruction memory in bootstrap state machine */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100226#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800227
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100228static inline int
229il4965_hw_valid_rtc_data_addr(u32 addr)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800230{
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100231 return (addr >= IL49_RTC_DATA_LOWER_BOUND &&
232 addr < IL49_RTC_DATA_UPPER_BOUND);
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800233}
234
235/********************* START TEMPERATURE *************************************/
236
237/**
238 * 4965 temperature calculation.
239 *
240 * The driver must calculate the device temperature before calculating
241 * a txpower setting (amplifier gain is temperature dependent). The
242 * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration
243 * values used for the life of the driver, and one of which (R4) is the
244 * real-time temperature indicator.
245 *
246 * uCode provides all 4 values to the driver via the "initialize alive"
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200247 * notification (see struct il4965_init_alive_resp). After the runtime uCode
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +0200248 * image loads, uCode updates the R4 value via stats notifications
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200249 * (see N_STATS), which occur after each received beacon
250 * when associated, or can be requested via C_STATS.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800251 *
252 * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver
253 * must sign-extend to 32 bits before applying formula below.
254 *
255 * Formula:
256 *
257 * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8
258 *
259 * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is
260 * an additional correction, which should be centered around 0 degrees
261 * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for
262 * centering the 97/100 correction around 0 degrees K.
263 *
264 * Add 273 to Kelvin value to find degrees Celsius, for comparing current
265 * temperature with factory-measured temperatures when calculating txpower
266 * settings.
267 */
268#define TEMPERATURE_CALIB_KELVIN_OFFSET 8
269#define TEMPERATURE_CALIB_A_VAL 259
270
271/* Limit range of calculated temperature to be between these Kelvin values */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200272#define IL_TX_POWER_TEMPERATURE_MIN (263)
273#define IL_TX_POWER_TEMPERATURE_MAX (410)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800274
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200275#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
Stanislaw Gruszka232913b2011-08-26 10:45:16 +0200276 ((t) < IL_TX_POWER_TEMPERATURE_MIN || \
277 (t) > IL_TX_POWER_TEMPERATURE_MAX)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800278
279/********************* END TEMPERATURE ***************************************/
280
281/********************* START TXPOWER *****************************************/
282
283/**
284 * 4965 txpower calculations rely on information from three sources:
285 *
286 * 1) EEPROM
287 * 2) "initialize" alive notification
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +0200288 * 3) stats notifications
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800289 *
290 * EEPROM data consists of:
291 *
292 * 1) Regulatory information (max txpower and channel usage flags) is provided
293 * separately for each channel that can possibly supported by 4965.
294 * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz
295 * (legacy) channels.
296 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200297 * See struct il4965_eeprom_channel for format, and struct il4965_eeprom
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800298 * for locations in EEPROM.
299 *
300 * 2) Factory txpower calibration information is provided separately for
301 * sub-bands of contiguous channels. 2.4GHz has just one sub-band,
302 * but 5 GHz has several sub-bands.
303 *
304 * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided.
305 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200306 * See struct il4965_eeprom_calib_info (and the tree of structures
307 * contained within it) for format, and struct il4965_eeprom for
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800308 * locations in EEPROM.
309 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200310 * "Initialization alive" notification (see struct il4965_init_alive_resp)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800311 * consists of:
312 *
313 * 1) Temperature calculation parameters.
314 *
315 * 2) Power supply voltage measurement.
316 *
317 * 3) Tx gain compensation to balance 2 transmitters for MIMO use.
318 *
319 * Statistics notifications deliver:
320 *
321 * 1) Current values for temperature param R4.
322 */
323
324/**
325 * To calculate a txpower setting for a given desired target txpower, channel,
326 * modulation bit rate, and transmitter chain (4965 has 2 transmitters to
327 * support MIMO and transmit diversity), driver must do the following:
328 *
329 * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel.
330 * Do not exceed regulatory limit; reduce target txpower if necessary.
331 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100332 * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800333 * 2 transmitters will be used simultaneously; driver must reduce the
334 * regulatory limit by 3 dB (half-power) for each transmitter, so the
335 * combined total output of the 2 transmitters is within regulatory limits.
336 *
337 *
338 * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by
339 * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]);
340 * reduce target txpower if necessary.
341 *
342 * Backoff values below are in 1/2 dB units (equivalent to steps in
343 * txpower gain tables):
344 *
345 * OFDM 6 - 36 MBit: 10 steps (5 dB)
346 * OFDM 48 MBit: 15 steps (7.5 dB)
347 * OFDM 54 MBit: 17 steps (8.5 dB)
348 * OFDM 60 MBit: 20 steps (10 dB)
349 * CCK all rates: 10 steps (5 dB)
350 *
351 * Backoff values apply to saturation txpower on a per-transmitter basis;
352 * when using MIMO (2 transmitters), each transmitter uses the same
353 * saturation level provided in EEPROM, and the same backoff values;
354 * no reduction (such as with regulatory txpower limits) is required.
355 *
356 * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel
357 * widths and 40 Mhz (.11n HT40) channel widths; there is no separate
358 * factory measurement for ht40 channels.
359 *
360 * The result of this step is the final target txpower. The rest of
361 * the steps figure out the proper settings for the device to achieve
362 * that target txpower.
363 *
364 *
365 * 3) Determine (EEPROM) calibration sub band for the target channel, by
366 * comparing against first and last channels in each sub band
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200367 * (see struct il4965_eeprom_calib_subband_info).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800368 *
369 *
370 * 4) Linearly interpolate (EEPROM) factory calibration measurement sets,
371 * referencing the 2 factory-measured (sample) channels within the sub band.
372 *
373 * Interpolation is based on difference between target channel's frequency
374 * and the sample channels' frequencies. Since channel numbers are based
375 * on frequency (5 MHz between each channel number), this is equivalent
376 * to interpolating based on channel number differences.
377 *
378 * Note that the sample channels may or may not be the channels at the
379 * edges of the sub band. The target channel may be "outside" of the
380 * span of the sampled channels.
381 *
382 * Driver may choose the pair (for 2 Tx chains) of measurements (see
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200383 * struct il4965_eeprom_calib_ch_info) for which the actual measured
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800384 * txpower comes closest to the desired txpower. Usually, though,
385 * the middle set of measurements is closest to the regulatory limits,
386 * and is therefore a good choice for all txpower calculations (this
387 * assumes that high accuracy is needed for maximizing legal txpower,
388 * while lower txpower configurations do not need as much accuracy).
389 *
390 * Driver should interpolate both members of the chosen measurement pair,
391 * i.e. for both Tx chains (radio transmitters), unless the driver knows
392 * that only one of the chains will be used (e.g. only one tx antenna
393 * connected, but this should be unusual). The rate scaling algorithm
394 * switches antennas to find best performance, so both Tx chains will
395 * be used (although only one at a time) even for non-MIMO transmissions.
396 *
397 * Driver should interpolate factory values for temperature, gain table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100398 * idx, and actual power. The power amplifier detector values are
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800399 * not used by the driver.
400 *
401 * Sanity check: If the target channel happens to be one of the sample
402 * channels, the results should agree with the sample channel's
403 * measurements!
404 *
405 *
406 * 5) Find difference between desired txpower and (interpolated)
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100407 * factory-measured txpower. Using (interpolated) factory gain table idx
408 * (shown elsewhere) as a starting point, adjust this idx lower to
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800409 * increase txpower, or higher to decrease txpower, until the target
410 * txpower is reached. Each step in the gain table is 1/2 dB.
411 *
412 * For example, if factory measured txpower is 16 dBm, and target txpower
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100413 * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800414 * by 3 dB.
415 *
416 *
417 * 6) Find difference between current device temperature and (interpolated)
418 * factory-measured temperature for sub-band. Factory values are in
419 * degrees Celsius. To calculate current temperature, see comments for
420 * "4965 temperature calculation".
421 *
422 * If current temperature is higher than factory temperature, driver must
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100423 * increase gain (lower gain table idx), and vice verse.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800424 *
425 * Temperature affects gain differently for different channels:
426 *
427 * 2.4 GHz all channels: 3.5 degrees per half-dB step
428 * 5 GHz channels 34-43: 4.5 degrees per half-dB step
429 * 5 GHz channels >= 44: 4.0 degrees per half-dB step
430 *
431 * NOTE: Temperature can increase rapidly when transmitting, especially
432 * with heavy traffic at high txpowers. Driver should update
433 * temperature calculations often under these conditions to
434 * maintain strong txpower in the face of rising temperature.
435 *
436 *
437 * 7) Find difference between current power supply voltage indicator
438 * (from "initialize alive") and factory-measured power supply voltage
439 * indicator (EEPROM).
440 *
441 * If the current voltage is higher (indicator is lower) than factory
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100442 * voltage, gain should be reduced (gain table idx increased) by:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800443 *
444 * (eeprom - current) / 7
445 *
446 * If the current voltage is lower (indicator is higher) than factory
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100447 * voltage, gain should be increased (gain table idx decreased) by:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800448 *
449 * 2 * (current - eeprom) / 7
450 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100451 * If number of idx steps in either direction turns out to be > 2,
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800452 * something is wrong ... just use 0.
453 *
454 * NOTE: Voltage compensation is independent of band/channel.
455 *
456 * NOTE: "Initialize" uCode measures current voltage, which is assumed
457 * to be constant after this initial measurement. Voltage
458 * compensation for txpower (number of steps in gain table)
459 * may be calculated once and used until the next uCode bootload.
460 *
461 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100462 * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800463 * adjust txpower for each transmitter chain, so txpower is balanced
464 * between the two chains. There are 5 pairs of tx_atten[group][chain]
465 * values in "initialize alive", one pair for each of 5 channel ranges:
466 *
467 * Group 0: 5 GHz channel 34-43
468 * Group 1: 5 GHz channel 44-70
469 * Group 2: 5 GHz channel 71-124
470 * Group 3: 5 GHz channel 125-200
471 * Group 4: 2.4 GHz all channels
472 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100473 * Add the tx_atten[group][chain] value to the idx for the target chain.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800474 * The values are signed, but are in pairs of 0 and a non-negative number,
475 * so as to reduce gain (if necessary) of the "hotter" channel. This
476 * avoids any need to double-check for regulatory compliance after
477 * this step.
478 *
479 *
480 * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100481 * value to the idx:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800482 *
483 * Hardware rev B: 9 steps (4.5 dB)
484 * Hardware rev C: 5 steps (2.5 dB)
485 *
486 * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
487 * bits [3:2], 1 = B, 2 = C.
488 *
489 * NOTE: This compensation is in addition to any saturation backoff that
490 * might have been applied in an earlier step.
491 *
492 *
493 * 10) Select the gain table, based on band (2.4 vs 5 GHz).
494 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100495 * Limit the adjusted idx to stay within the table!
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800496 *
497 *
498 * 11) Read gain table entries for DSP and radio gain, place into appropriate
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200499 * location(s) in command (struct il4965_txpowertable_cmd).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800500 */
501
502/**
503 * When MIMO is used (2 transmitters operating simultaneously), driver should
504 * limit each transmitter to deliver a max of 3 dB below the regulatory limit
505 * for the device. That is, use half power for each transmitter, so total
506 * txpower is within regulatory limits.
507 *
508 * The value "6" represents number of steps in gain table to reduce power 3 dB.
509 * Each step is 1/2 dB.
510 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200511#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800512
513/**
514 * CCK gain compensation.
515 *
516 * When calculating txpowers for CCK, after making sure that the target power
517 * is within regulatory and saturation limits, driver must additionally
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100518 * back off gain by adding these values to the gain table idx.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800519 *
520 * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
521 * bits [3:2], 1 = B, 2 = C.
522 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200523#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
524#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800525
526/*
527 * 4965 power supply voltage compensation for txpower
528 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200529#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800530
531/**
532 * Gain tables.
533 *
534 * The following tables contain pair of values for setting txpower, i.e.
535 * gain settings for the output of the device's digital signal processor (DSP),
536 * and for the analog gain structure of the transmitter.
537 *
538 * Each entry in the gain tables represents a step of 1/2 dB. Note that these
539 * are *relative* steps, not indications of absolute output power. Output
540 * power varies with temperature, voltage, and channel frequency, and also
541 * requires consideration of average power (to satisfy regulatory constraints),
542 * and peak power (to avoid distortion of the output signal).
543 *
544 * Each entry contains two values:
545 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
546 * linear value that multiplies the output of the digital signal processor,
547 * before being sent to the analog radio.
548 * 2) Radio gain. This sets the analog gain of the radio Tx path.
549 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
550 *
551 * EEPROM contains factory calibration data for txpower. This maps actual
552 * measured txpower levels to gain settings in the "well known" tables
553 * below ("well-known" means here that both factory calibration *and* the
554 * driver work with the same table).
555 *
556 * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100557 * has an extension (into negative idxes), in case the driver needs to
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800558 * boost power setting for high device temperatures (higher than would be
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100559 * present during factory calibration). A 5 Ghz EEPROM idx of "40"
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800560 * corresponds to the 49th entry in the table used by the driver.
561 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100562#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */
563#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800564
565/**
566 * 2.4 GHz gain table
567 *
568 * Index Dsp gain Radio gain
569 * 0 110 0x3f (highest gain)
570 * 1 104 0x3f
571 * 2 98 0x3f
572 * 3 110 0x3e
573 * 4 104 0x3e
574 * 5 98 0x3e
575 * 6 110 0x3d
576 * 7 104 0x3d
577 * 8 98 0x3d
578 * 9 110 0x3c
579 * 10 104 0x3c
580 * 11 98 0x3c
581 * 12 110 0x3b
582 * 13 104 0x3b
583 * 14 98 0x3b
584 * 15 110 0x3a
585 * 16 104 0x3a
586 * 17 98 0x3a
587 * 18 110 0x39
588 * 19 104 0x39
589 * 20 98 0x39
590 * 21 110 0x38
591 * 22 104 0x38
592 * 23 98 0x38
593 * 24 110 0x37
594 * 25 104 0x37
595 * 26 98 0x37
596 * 27 110 0x36
597 * 28 104 0x36
598 * 29 98 0x36
599 * 30 110 0x35
600 * 31 104 0x35
601 * 32 98 0x35
602 * 33 110 0x34
603 * 34 104 0x34
604 * 35 98 0x34
605 * 36 110 0x33
606 * 37 104 0x33
607 * 38 98 0x33
608 * 39 110 0x32
609 * 40 104 0x32
610 * 41 98 0x32
611 * 42 110 0x31
612 * 43 104 0x31
613 * 44 98 0x31
614 * 45 110 0x30
615 * 46 104 0x30
616 * 47 98 0x30
617 * 48 110 0x6
618 * 49 104 0x6
619 * 50 98 0x6
620 * 51 110 0x5
621 * 52 104 0x5
622 * 53 98 0x5
623 * 54 110 0x4
624 * 55 104 0x4
625 * 56 98 0x4
626 * 57 110 0x3
627 * 58 104 0x3
628 * 59 98 0x3
629 * 60 110 0x2
630 * 61 104 0x2
631 * 62 98 0x2
632 * 63 110 0x1
633 * 64 104 0x1
634 * 65 98 0x1
635 * 66 110 0x0
636 * 67 104 0x0
637 * 68 98 0x0
638 * 69 97 0
639 * 70 96 0
640 * 71 95 0
641 * 72 94 0
642 * 73 93 0
643 * 74 92 0
644 * 75 91 0
645 * 76 90 0
646 * 77 89 0
647 * 78 88 0
648 * 79 87 0
649 * 80 86 0
650 * 81 85 0
651 * 82 84 0
652 * 83 83 0
653 * 84 82 0
654 * 85 81 0
655 * 86 80 0
656 * 87 79 0
657 * 88 78 0
658 * 89 77 0
659 * 90 76 0
660 * 91 75 0
661 * 92 74 0
662 * 93 73 0
663 * 94 72 0
664 * 95 71 0
665 * 96 70 0
666 * 97 69 0
667 * 98 68 0
668 */
669
670/**
671 * 5 GHz gain table
672 *
673 * Index Dsp gain Radio gain
674 * -9 123 0x3F (highest gain)
675 * -8 117 0x3F
676 * -7 110 0x3F
677 * -6 104 0x3F
678 * -5 98 0x3F
679 * -4 110 0x3E
680 * -3 104 0x3E
681 * -2 98 0x3E
682 * -1 110 0x3D
683 * 0 104 0x3D
684 * 1 98 0x3D
685 * 2 110 0x3C
686 * 3 104 0x3C
687 * 4 98 0x3C
688 * 5 110 0x3B
689 * 6 104 0x3B
690 * 7 98 0x3B
691 * 8 110 0x3A
692 * 9 104 0x3A
693 * 10 98 0x3A
694 * 11 110 0x39
695 * 12 104 0x39
696 * 13 98 0x39
697 * 14 110 0x38
698 * 15 104 0x38
699 * 16 98 0x38
700 * 17 110 0x37
701 * 18 104 0x37
702 * 19 98 0x37
703 * 20 110 0x36
704 * 21 104 0x36
705 * 22 98 0x36
706 * 23 110 0x35
707 * 24 104 0x35
708 * 25 98 0x35
709 * 26 110 0x34
710 * 27 104 0x34
711 * 28 98 0x34
712 * 29 110 0x33
713 * 30 104 0x33
714 * 31 98 0x33
715 * 32 110 0x32
716 * 33 104 0x32
717 * 34 98 0x32
718 * 35 110 0x31
719 * 36 104 0x31
720 * 37 98 0x31
721 * 38 110 0x30
722 * 39 104 0x30
723 * 40 98 0x30
724 * 41 110 0x25
725 * 42 104 0x25
726 * 43 98 0x25
727 * 44 110 0x24
728 * 45 104 0x24
729 * 46 98 0x24
730 * 47 110 0x23
731 * 48 104 0x23
732 * 49 98 0x23
733 * 50 110 0x22
734 * 51 104 0x18
735 * 52 98 0x18
736 * 53 110 0x17
737 * 54 104 0x17
738 * 55 98 0x17
739 * 56 110 0x16
740 * 57 104 0x16
741 * 58 98 0x16
742 * 59 110 0x15
743 * 60 104 0x15
744 * 61 98 0x15
745 * 62 110 0x14
746 * 63 104 0x14
747 * 64 98 0x14
748 * 65 110 0x13
749 * 66 104 0x13
750 * 67 98 0x13
751 * 68 110 0x12
752 * 69 104 0x08
753 * 70 98 0x08
754 * 71 110 0x07
755 * 72 104 0x07
756 * 73 98 0x07
757 * 74 110 0x06
758 * 75 104 0x06
759 * 76 98 0x06
760 * 77 110 0x05
761 * 78 104 0x05
762 * 79 98 0x05
763 * 80 110 0x04
764 * 81 104 0x04
765 * 82 98 0x04
766 * 83 110 0x03
767 * 84 104 0x03
768 * 85 98 0x03
769 * 86 110 0x02
770 * 87 104 0x02
771 * 88 98 0x02
772 * 89 110 0x01
773 * 90 104 0x01
774 * 91 98 0x01
775 * 92 110 0x00
776 * 93 104 0x00
777 * 94 98 0x00
778 * 95 93 0x00
779 * 96 88 0x00
780 * 97 83 0x00
781 * 98 78 0x00
782 */
783
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800784/**
785 * Sanity checks and default values for EEPROM regulatory levels.
786 * If EEPROM values fall outside MIN/MAX range, use default values.
787 *
788 * Regulatory limits refer to the maximum average txpower allowed by
789 * regulatory agencies in the geographies in which the device is meant
790 * to be operated. These limits are SKU-specific (i.e. geography-specific),
791 * and channel-specific; each channel has an individual regulatory limit
792 * listed in the EEPROM.
793 *
794 * Units are in half-dBm (i.e. "34" means 17 dBm).
795 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200796#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34)
797#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34)
798#define IL_TX_POWER_REGULATORY_MIN (0)
799#define IL_TX_POWER_REGULATORY_MAX (34)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800800
801/**
802 * Sanity checks and default values for EEPROM saturation levels.
803 * If EEPROM values fall outside MIN/MAX range, use default values.
804 *
805 * Saturation is the highest level that the output power amplifier can produce
806 * without significant clipping distortion. This is a "peak" power level.
807 * Different types of modulation (i.e. various "rates", and OFDM vs. CCK)
808 * require differing amounts of backoff, relative to their average power output,
809 * in order to avoid clipping distortion.
810 *
811 * Driver must make sure that it is violating neither the saturation limit,
812 * nor the regulatory limit, when calculating Tx power settings for various
813 * rates.
814 *
815 * Units are in half-dBm (i.e. "38" means 19 dBm).
816 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200817#define IL_TX_POWER_DEFAULT_SATURATION_24 (38)
818#define IL_TX_POWER_DEFAULT_SATURATION_52 (38)
819#define IL_TX_POWER_SATURATION_MIN (20)
820#define IL_TX_POWER_SATURATION_MAX (50)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800821
822/**
823 * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance)
824 * and thermal Txpower calibration.
825 *
826 * When calculating txpower, driver must compensate for current device
827 * temperature; higher temperature requires higher gain. Driver must calculate
828 * current temperature (see "4965 temperature calculation"), then compare vs.
829 * factory calibration temperature in EEPROM; if current temperature is higher
830 * than factory temperature, driver must *increase* gain by proportions shown
831 * in table below. If current temperature is lower than factory, driver must
832 * *decrease* gain.
833 *
834 * Different frequency ranges require different compensation, as shown below.
835 */
836/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200837#define CALIB_IL_TX_ATTEN_GR1_FCH 34
838#define CALIB_IL_TX_ATTEN_GR1_LCH 43
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800839
840/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200841#define CALIB_IL_TX_ATTEN_GR2_FCH 44
842#define CALIB_IL_TX_ATTEN_GR2_LCH 70
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800843
844/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200845#define CALIB_IL_TX_ATTEN_GR3_FCH 71
846#define CALIB_IL_TX_ATTEN_GR3_LCH 124
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800847
848/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200849#define CALIB_IL_TX_ATTEN_GR4_FCH 125
850#define CALIB_IL_TX_ATTEN_GR4_LCH 200
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800851
852/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200853#define CALIB_IL_TX_ATTEN_GR5_FCH 1
854#define CALIB_IL_TX_ATTEN_GR5_LCH 20
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800855
856enum {
857 CALIB_CH_GROUP_1 = 0,
858 CALIB_CH_GROUP_2 = 1,
859 CALIB_CH_GROUP_3 = 2,
860 CALIB_CH_GROUP_4 = 3,
861 CALIB_CH_GROUP_5 = 4,
862 CALIB_CH_GROUP_MAX
863};
864
865/********************* END TXPOWER *****************************************/
866
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800867/**
868 * Tx/Rx Queues
869 *
870 * Most communication between driver and 4965 is via queues of data buffers.
871 * For example, all commands that the driver issues to device's embedded
872 * controller (uCode) are via the command queue (one of the Tx queues). All
873 * uCode command responses/replies/notifications, including Rx frames, are
874 * conveyed from uCode to driver via the Rx queue.
875 *
876 * Most support for these queues, including handshake support, resides in
877 * structures in host DRAM, shared between the driver and the device. When
878 * allocating this memory, the driver must make sure that data written by
879 * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
880 * cache memory), so DRAM and cache are consistent, and the device can
881 * immediately see changes made by the driver.
882 *
883 * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via
884 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array
885 * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
886 */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100887#define IL49_NUM_FIFOS 7
888#define IL49_CMD_FIFO_NUM 4
889#define IL49_NUM_QUEUES 16
890#define IL49_NUM_AMPDU_QUEUES 8
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800891
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800892/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200893 * struct il4965_schedq_bc_tbl
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800894 *
895 * Byte Count table
896 *
897 * Each Tx queue uses a byte-count table containing 320 entries:
898 * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200899 * duplicate the first 64 entries (to avoid wrap-around within a Tx win;
900 * max Tx win is 64 TFDs).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800901 *
902 * When driver sets up a new TFD, it must also enter the total byte count
903 * of the frame to be transmitted into the corresponding entry in the byte
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100904 * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver
905 * must duplicate the byte count entry in corresponding idx 256-319.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800906 *
907 * padding puts each byte count table on a 1024-byte boundary;
908 * 4965 assumes tables are separated by 1024 bytes.
909 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200910struct il4965_scd_bc_tbl {
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800911 __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
912 u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)];
913} __packed;
914
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100915#define IL4965_RTC_INST_LOWER_BOUND (0x000000)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800916
917/* RSSI to dBm */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100918#define IL4965_RSSI_OFFSET 44
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800919
920/* PCI registers */
921#define PCI_CFG_RETRY_TIMEOUT 0x041
922
923/* PCI register values */
924#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
925#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
926
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100927#define IL4965_DEFAULT_TX_RETRY 15
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800928
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800929/* EEPROM */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100930#define IL4965_FIRST_AMPDU_QUEUE 10
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800931
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200932/* Calibration */
933void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp);
934void il4965_sensitivity_calibration(struct il_priv *il, void *resp);
935void il4965_init_sensitivity(struct il_priv *il);
936void il4965_reset_run_time_calib(struct il_priv *il);
937void il4965_calib_free_results(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800938
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200939/* Debug */
940#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100941ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf,
942 size_t count, loff_t *ppos);
943ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf,
944 size_t count, loff_t *ppos);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200945ssize_t il4965_ucode_general_stats_read(struct file *file,
Stanislaw Gruszka1722f8e2011-11-15 14:51:01 +0100946 char __user *user_buf, size_t count,
947 loff_t *ppos);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200948#endif
949
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200950/****************************/
951/* Flow Handler Definitions */
952/****************************/
953
954/**
955 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
956 * Addresses are offsets from device's PCI hardware base address.
957 */
958#define FH49_MEM_LOWER_BOUND (0x1000)
959#define FH49_MEM_UPPER_BOUND (0x2000)
960
961/**
962 * Keep-Warm (KW) buffer base address.
963 *
964 * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
965 * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
966 * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host
967 * from going into a power-savings mode that would cause higher DRAM latency,
968 * and possible data over/under-runs, before all Tx/Rx is complete.
969 *
970 * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4)
971 * of the buffer, which must be 4K aligned. Once this is set up, the 4965
972 * automatically invokes keep-warm accesses when normal accesses might not
973 * be sufficient to maintain fast DRAM response.
974 *
975 * Bit fields:
976 * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned
977 */
978#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C)
979
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200980/**
981 * TFD Circular Buffers Base (CBBC) addresses
982 *
983 * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
984 * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
985 * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04
986 * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
987 * aligned (address bits 0-7 must be 0).
988 *
989 * Bit fields in each pointer register:
990 * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
991 */
992#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0)
993#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10)
994
995/* Find TFD CB base pointer for given queue (range 0-15). */
996#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
997
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200998/**
999 * Rx SRAM Control and Status Registers (RSCSR)
1000 *
1001 * These registers provide handshake between driver and 4965 for the Rx queue
1002 * (this queue handles *all* command responses, notifications, Rx data, etc.
1003 * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx
1004 * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can
1005 * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
1006 * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
1007 * mapping between RBDs and RBs.
1008 *
1009 * Driver must allocate host DRAM memory for the following, and set the
1010 * physical address of each into 4965 registers:
1011 *
1012 * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
1013 * entries (although any power of 2, up to 4096, is selectable by driver).
1014 * Each entry (1 dword) points to a receive buffer (RB) of consistent size
1015 * (typically 4K, although 8K or 16K are also selectable by driver).
1016 * Driver sets up RB size and number of RBDs in the CB via Rx config
1017 * register FH49_MEM_RCSR_CHNL0_CONFIG_REG.
1018 *
1019 * Bit fields within one RBD:
1020 * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned
1021 *
1022 * Driver sets physical address [35:8] of base of RBD circular buffer
1023 * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
1024 *
1025 * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
1026 * (RBs) have been filled, via a "write pointer", actually the idx of
1027 * the RB's corresponding RBD within the circular buffer. Driver sets
1028 * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
1029 *
1030 * Bit fields in lower dword of Rx status buffer (upper dword not used
1031 * by driver; see struct il4965_shared, val0):
1032 * 31-12: Not used by driver
1033 * 11- 0: Index of last filled Rx buffer descriptor
1034 * (4965 writes, driver reads this value)
1035 *
1036 * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
1037 * enter pointers to these RBs into contiguous RBD circular buffer entries,
1038 * and update the 4965's "write" idx register,
1039 * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG.
1040 *
1041 * This "write" idx corresponds to the *next* RBD that the driver will make
1042 * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
1043 * the circular buffer. This value should initially be 0 (before preparing any
1044 * RBs), should be 8 after preparing the first 8 RBs (for example), and must
1045 * wrap back to 0 at the end of the circular buffer (but don't wrap before
1046 * "read" idx has advanced past 1! See below).
1047 * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8.
1048 *
1049 * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
1050 * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
1051 * to tell the driver the idx of the latest filled RBD. The driver must
1052 * read this "read" idx from DRAM after receiving an Rx interrupt from 4965.
1053 *
1054 * The driver must also internally keep track of a third idx, which is the
1055 * next RBD to process. When receiving an Rx interrupt, driver should process
1056 * all filled but unprocessed RBs up to, but not including, the RB
1057 * corresponding to the "read" idx. For example, if "read" idx becomes "1",
1058 * driver may process the RB pointed to by RBD 0. Depending on volume of
1059 * traffic, there may be many RBs to process.
1060 *
1061 * If read idx == write idx, 4965 thinks there is no room to put new data.
1062 * Due to this, the maximum number of filled RBs is 255, instead of 256. To
1063 * be safe, make sure that there is a gap of at least 2 RBDs between "write"
1064 * and "read" idxes; that is, make sure that there are no more than 254
1065 * buffers waiting to be filled.
1066 */
1067#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0)
1068#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00)
1069#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND)
1070
1071/**
1072 * Physical base address of 8-byte Rx Status buffer.
1073 * Bit fields:
1074 * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
1075 */
1076#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0)
1077
1078/**
1079 * Physical base address of Rx Buffer Descriptor Circular Buffer.
1080 * Bit fields:
1081 * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned.
1082 */
1083#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004)
1084
1085/**
1086 * Rx write pointer (idx, really!).
1087 * Bit fields:
1088 * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1.
1089 * NOTE: For 256-entry circular buffer, use only bits [7:0].
1090 */
1091#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008)
1092#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG)
1093
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001094/**
1095 * Rx Config/Status Registers (RCSR)
1096 * Rx Config Reg for channel 0 (only channel used)
1097 *
1098 * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for
1099 * normal operation (see bit fields).
1100 *
1101 * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
1102 * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for
1103 * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
1104 *
1105 * Bit fields:
1106 * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1107 * '10' operate normally
1108 * 29-24: reserved
1109 * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
1110 * min "5" for 32 RBDs, max "12" for 4096 RBDs.
1111 * 19-18: reserved
1112 * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
1113 * '10' 12K, '11' 16K.
1114 * 15-14: reserved
1115 * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
1116 * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
1117 * typical value 0x10 (about 1/2 msec)
1118 * 3- 0: reserved
1119 */
1120#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00)
1121#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0)
1122#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND)
1123
1124#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0)
1125
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001126#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */
1127#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */
1128#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */
1129#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */
1130#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */
1131#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31 */
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001132
1133#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20)
1134#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4)
1135#define RX_RB_TIMEOUT (0x10)
1136
1137#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
1138#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
1139#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
1140
1141#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
1142#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000)
1143#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000)
1144#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000)
1145
1146#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004)
1147#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
1148#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
1149
1150/**
1151 * Rx Shared Status Registers (RSSR)
1152 *
1153 * After stopping Rx DMA channel (writing 0 to
1154 * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
1155 * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
1156 *
1157 * Bit fields:
1158 * 24: 1 = Channel 0 is idle
1159 *
1160 * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
1161 * contain default values that should not be altered by the driver.
1162 */
1163#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40)
1164#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00)
1165
1166#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND)
1167#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004)
1168#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
1169 (FH49_MEM_RSSR_LOWER_BOUND + 0x008)
1170
1171#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
1172
1173#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
1174
1175/* TFDB Area - TFDs buffer table */
1176#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
1177#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900)
1178#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958)
1179#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
1180#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
1181
1182/**
1183 * Transmit DMA Channel Control/Status Registers (TCSR)
1184 *
1185 * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels
1186 * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1187 * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1188 *
1189 * To use a Tx DMA channel, driver must initialize its
1190 * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1191 *
1192 * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1193 * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1194 *
1195 * All other bits should be 0.
1196 *
1197 * Bit fields:
1198 * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1199 * '10' operate normally
1200 * 29- 4: Reserved, set to "0"
1201 * 3: Enable internal DMA requests (1, normal operation), disable (0)
1202 * 2- 0: Reserved, set to "0"
1203 */
1204#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00)
1205#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60)
1206
1207/* Find Control/Status reg for given Tx DMA/FIFO channel */
1208#define FH49_TCSR_CHNL_NUM (7)
1209#define FH50_TCSR_CHNL_NUM (8)
1210
1211/* TCSR: tx_config register values */
1212#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
1213 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl))
1214#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \
1215 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
1216#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \
1217 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
1218
1219#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
1220#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001)
1221
1222#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000)
1223#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008)
1224
1225#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
1226#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
1227#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
1228
1229#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
1230#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
1231#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
1232
1233#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
1234#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
1235#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
1236
1237#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
1238#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
1239#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
1240
1241#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
1242#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
1243
1244/**
1245 * Tx Shared Status Registers (TSSR)
1246 *
1247 * After stopping Tx DMA channel (writing 0 to
1248 * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1249 * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle
1250 * (channel's buffers empty | no pending requests).
1251 *
1252 * Bit fields:
1253 * 31-24: 1 = Channel buffers empty (channel 7:0)
1254 * 23-16: 1 = No pending requests (channel 7:0)
1255 */
1256#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0)
1257#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0)
1258
1259#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010)
1260
1261/**
1262 * Bit fields for TSSR(Tx Shared Status & Control) error status register:
1263 * 31: Indicates an address error when accessed to internal memory
1264 * uCode/driver must write "1" in order to clear this flag
1265 * 30: Indicates that Host did not send the expected number of dwords to FH
1266 * uCode/driver must write "1" in order to clear this flag
1267 * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
1268 * command was received from the scheduler while the TRB was already full
1269 * with previous command
1270 * uCode/driver must write "1" in order to clear this flag
1271 * 7-0: Each status bit indicates a channel's TxCredit error. When an error
1272 * bit is set, it indicates that the FH has received a full indication
1273 * from the RTC TxFIFO and the current value of the TxCredit counter was
1274 * not equal to zero. This mean that the credit mechanism was not
1275 * synchronized to the TxFIFO status
1276 * uCode/driver must write "1" in order to clear this flag
1277 */
1278#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018)
1279
1280#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
1281
1282/* Tx service channels */
1283#define FH49_SRVC_CHNL (9)
1284#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8)
1285#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0)
1286#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
1287 (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
1288
1289#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98)
1290/* Instruct FH to increment the retry count of a packet when
1291 * it is brought from the memory to TX-FIFO
1292 */
1293#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002)
1294
1295/* Keep Warm Size */
1296#define IL_KW_SIZE 0x1000 /* 4k */
1297
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +02001298#endif /* __il_4965_h__ */