blob: 78eae22c8f2967817e87637a5743154c1022164f [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 Gruszkae7392362011-11-15 14:45:59 +010051void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx);
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
110u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid);
111
112/* rx */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100113void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb);
114bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt);
115void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb);
116void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200117
118/* scan */
119int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
120
121/* station mgmt */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100122int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
123 bool add);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200124
125/* hcmd */
126int il4965_send_beacon_cmd(struct il_priv *il);
127
128#ifdef CONFIG_IWLEGACY_DEBUG
129const char *il4965_get_tx_fail_reason(u32 status);
130#else
131static inline const char *
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100132il4965_get_tx_fail_reason(u32 status)
133{
134 return "";
135}
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200136#endif
137
138/* station management */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100139int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx);
140int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx,
141 const u8 * addr, u8 * sta_id_r);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200142int il4965_remove_default_wep_key(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100143 struct il_rxon_context *ctx,
144 struct ieee80211_key_conf *key);
145int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200146 struct ieee80211_key_conf *key);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200147int il4965_restore_default_wep_keys(struct il_priv *il,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100148 struct il_rxon_context *ctx);
149int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
150 struct ieee80211_key_conf *key, u8 sta_id);
151int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx,
152 struct ieee80211_key_conf *key, u8 sta_id);
153void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx,
154 struct ieee80211_key_conf *keyconf,
155 struct ieee80211_sta *sta, u32 iv32,
156 u16 * phase1key);
157int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200158int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100159 int tid, u16 ssn);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200160int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100161 int tid);
162void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200163int il4965_update_bcast_stations(struct il_priv *il);
164
165/* rate */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100166static inline u8
167il4965_hw_get_rate(__le32 rate_n_flags)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200168{
169 return le32_to_cpu(rate_n_flags) & 0xFF;
170}
171
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100172static inline __le32
173il4965_hw_set_rate_n_flags(u8 rate, u32 flags)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200174{
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100175 return cpu_to_le32(flags | (u32) rate);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200176}
177
178/* eeprom */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100179void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200180int il4965_eeprom_acquire_semaphore(struct il_priv *il);
181void il4965_eeprom_release_semaphore(struct il_priv *il);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100182int il4965_eeprom_check_version(struct il_priv *il);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200183
184/* mac80211 handlers (for 4965) */
185void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
186int il4965_mac_start(struct ieee80211_hw *hw);
187void il4965_mac_stop(struct ieee80211_hw *hw);
188void il4965_configure_filter(struct ieee80211_hw *hw,
189 unsigned int changed_flags,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100190 unsigned int *total_flags, u64 multicast);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200191int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
192 struct ieee80211_vif *vif, struct ieee80211_sta *sta,
193 struct ieee80211_key_conf *key);
194void il4965_mac_update_tkip_key(struct ieee80211_hw *hw,
195 struct ieee80211_vif *vif,
196 struct ieee80211_key_conf *keyconf,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100197 struct ieee80211_sta *sta, u32 iv32,
198 u16 * phase1key);
199int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200200 enum ieee80211_ampdu_mlme_action action,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100201 struct ieee80211_sta *sta, u16 tid, u16 * ssn,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200202 u8 buf_size);
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100203int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200204 struct ieee80211_sta *sta);
205void il4965_mac_channel_switch(struct ieee80211_hw *hw,
206 struct ieee80211_channel_switch *ch_switch);
207
208void il4965_led_enable(struct il_priv *il);
209
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800210/* EEPROM */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100211#define IL4965_EEPROM_IMG_SIZE 1024
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800212
213/*
214 * uCode queue management definitions ...
215 * The first queue used for block-ack aggregation is #7 (4965 only).
216 * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7.
217 */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100218#define IL49_FIRST_AMPDU_QUEUE 7
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800219
220/* Sizes and addresses for instruction and data memory (SRAM) in
221 * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100222#define IL49_RTC_INST_LOWER_BOUND (0x000000)
223#define IL49_RTC_INST_UPPER_BOUND (0x018000)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800224
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100225#define IL49_RTC_DATA_LOWER_BOUND (0x800000)
226#define IL49_RTC_DATA_UPPER_BOUND (0x80A000)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800227
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100228#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \
229 IL49_RTC_INST_LOWER_BOUND)
230#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \
231 IL49_RTC_DATA_LOWER_BOUND)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800232
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100233#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE
234#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800235
236/* Size of uCode instruction memory in bootstrap state machine */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100237#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800238
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100239static inline int
240il4965_hw_valid_rtc_data_addr(u32 addr)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800241{
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100242 return (addr >= IL49_RTC_DATA_LOWER_BOUND &&
243 addr < IL49_RTC_DATA_UPPER_BOUND);
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800244}
245
246/********************* START TEMPERATURE *************************************/
247
248/**
249 * 4965 temperature calculation.
250 *
251 * The driver must calculate the device temperature before calculating
252 * a txpower setting (amplifier gain is temperature dependent). The
253 * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration
254 * values used for the life of the driver, and one of which (R4) is the
255 * real-time temperature indicator.
256 *
257 * uCode provides all 4 values to the driver via the "initialize alive"
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200258 * notification (see struct il4965_init_alive_resp). After the runtime uCode
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +0200259 * image loads, uCode updates the R4 value via stats notifications
Stanislaw Gruszka4d69c752011-08-30 15:26:35 +0200260 * (see N_STATS), which occur after each received beacon
261 * when associated, or can be requested via C_STATS.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800262 *
263 * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver
264 * must sign-extend to 32 bits before applying formula below.
265 *
266 * Formula:
267 *
268 * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8
269 *
270 * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is
271 * an additional correction, which should be centered around 0 degrees
272 * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for
273 * centering the 97/100 correction around 0 degrees K.
274 *
275 * Add 273 to Kelvin value to find degrees Celsius, for comparing current
276 * temperature with factory-measured temperatures when calculating txpower
277 * settings.
278 */
279#define TEMPERATURE_CALIB_KELVIN_OFFSET 8
280#define TEMPERATURE_CALIB_A_VAL 259
281
282/* Limit range of calculated temperature to be between these Kelvin values */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200283#define IL_TX_POWER_TEMPERATURE_MIN (263)
284#define IL_TX_POWER_TEMPERATURE_MAX (410)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800285
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200286#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
Stanislaw Gruszka232913b2011-08-26 10:45:16 +0200287 ((t) < IL_TX_POWER_TEMPERATURE_MIN || \
288 (t) > IL_TX_POWER_TEMPERATURE_MAX)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800289
290/********************* END TEMPERATURE ***************************************/
291
292/********************* START TXPOWER *****************************************/
293
294/**
295 * 4965 txpower calculations rely on information from three sources:
296 *
297 * 1) EEPROM
298 * 2) "initialize" alive notification
Stanislaw Gruszkaebf0d902011-08-26 15:43:47 +0200299 * 3) stats notifications
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800300 *
301 * EEPROM data consists of:
302 *
303 * 1) Regulatory information (max txpower and channel usage flags) is provided
304 * separately for each channel that can possibly supported by 4965.
305 * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz
306 * (legacy) channels.
307 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200308 * See struct il4965_eeprom_channel for format, and struct il4965_eeprom
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800309 * for locations in EEPROM.
310 *
311 * 2) Factory txpower calibration information is provided separately for
312 * sub-bands of contiguous channels. 2.4GHz has just one sub-band,
313 * but 5 GHz has several sub-bands.
314 *
315 * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided.
316 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200317 * See struct il4965_eeprom_calib_info (and the tree of structures
318 * contained within it) for format, and struct il4965_eeprom for
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800319 * locations in EEPROM.
320 *
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200321 * "Initialization alive" notification (see struct il4965_init_alive_resp)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800322 * consists of:
323 *
324 * 1) Temperature calculation parameters.
325 *
326 * 2) Power supply voltage measurement.
327 *
328 * 3) Tx gain compensation to balance 2 transmitters for MIMO use.
329 *
330 * Statistics notifications deliver:
331 *
332 * 1) Current values for temperature param R4.
333 */
334
335/**
336 * To calculate a txpower setting for a given desired target txpower, channel,
337 * modulation bit rate, and transmitter chain (4965 has 2 transmitters to
338 * support MIMO and transmit diversity), driver must do the following:
339 *
340 * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel.
341 * Do not exceed regulatory limit; reduce target txpower if necessary.
342 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100343 * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800344 * 2 transmitters will be used simultaneously; driver must reduce the
345 * regulatory limit by 3 dB (half-power) for each transmitter, so the
346 * combined total output of the 2 transmitters is within regulatory limits.
347 *
348 *
349 * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by
350 * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]);
351 * reduce target txpower if necessary.
352 *
353 * Backoff values below are in 1/2 dB units (equivalent to steps in
354 * txpower gain tables):
355 *
356 * OFDM 6 - 36 MBit: 10 steps (5 dB)
357 * OFDM 48 MBit: 15 steps (7.5 dB)
358 * OFDM 54 MBit: 17 steps (8.5 dB)
359 * OFDM 60 MBit: 20 steps (10 dB)
360 * CCK all rates: 10 steps (5 dB)
361 *
362 * Backoff values apply to saturation txpower on a per-transmitter basis;
363 * when using MIMO (2 transmitters), each transmitter uses the same
364 * saturation level provided in EEPROM, and the same backoff values;
365 * no reduction (such as with regulatory txpower limits) is required.
366 *
367 * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel
368 * widths and 40 Mhz (.11n HT40) channel widths; there is no separate
369 * factory measurement for ht40 channels.
370 *
371 * The result of this step is the final target txpower. The rest of
372 * the steps figure out the proper settings for the device to achieve
373 * that target txpower.
374 *
375 *
376 * 3) Determine (EEPROM) calibration sub band for the target channel, by
377 * comparing against first and last channels in each sub band
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200378 * (see struct il4965_eeprom_calib_subband_info).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800379 *
380 *
381 * 4) Linearly interpolate (EEPROM) factory calibration measurement sets,
382 * referencing the 2 factory-measured (sample) channels within the sub band.
383 *
384 * Interpolation is based on difference between target channel's frequency
385 * and the sample channels' frequencies. Since channel numbers are based
386 * on frequency (5 MHz between each channel number), this is equivalent
387 * to interpolating based on channel number differences.
388 *
389 * Note that the sample channels may or may not be the channels at the
390 * edges of the sub band. The target channel may be "outside" of the
391 * span of the sampled channels.
392 *
393 * Driver may choose the pair (for 2 Tx chains) of measurements (see
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200394 * struct il4965_eeprom_calib_ch_info) for which the actual measured
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800395 * txpower comes closest to the desired txpower. Usually, though,
396 * the middle set of measurements is closest to the regulatory limits,
397 * and is therefore a good choice for all txpower calculations (this
398 * assumes that high accuracy is needed for maximizing legal txpower,
399 * while lower txpower configurations do not need as much accuracy).
400 *
401 * Driver should interpolate both members of the chosen measurement pair,
402 * i.e. for both Tx chains (radio transmitters), unless the driver knows
403 * that only one of the chains will be used (e.g. only one tx antenna
404 * connected, but this should be unusual). The rate scaling algorithm
405 * switches antennas to find best performance, so both Tx chains will
406 * be used (although only one at a time) even for non-MIMO transmissions.
407 *
408 * Driver should interpolate factory values for temperature, gain table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100409 * idx, and actual power. The power amplifier detector values are
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800410 * not used by the driver.
411 *
412 * Sanity check: If the target channel happens to be one of the sample
413 * channels, the results should agree with the sample channel's
414 * measurements!
415 *
416 *
417 * 5) Find difference between desired txpower and (interpolated)
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100418 * factory-measured txpower. Using (interpolated) factory gain table idx
419 * (shown elsewhere) as a starting point, adjust this idx lower to
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800420 * increase txpower, or higher to decrease txpower, until the target
421 * txpower is reached. Each step in the gain table is 1/2 dB.
422 *
423 * For example, if factory measured txpower is 16 dBm, and target txpower
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100424 * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800425 * by 3 dB.
426 *
427 *
428 * 6) Find difference between current device temperature and (interpolated)
429 * factory-measured temperature for sub-band. Factory values are in
430 * degrees Celsius. To calculate current temperature, see comments for
431 * "4965 temperature calculation".
432 *
433 * If current temperature is higher than factory temperature, driver must
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100434 * increase gain (lower gain table idx), and vice verse.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800435 *
436 * Temperature affects gain differently for different channels:
437 *
438 * 2.4 GHz all channels: 3.5 degrees per half-dB step
439 * 5 GHz channels 34-43: 4.5 degrees per half-dB step
440 * 5 GHz channels >= 44: 4.0 degrees per half-dB step
441 *
442 * NOTE: Temperature can increase rapidly when transmitting, especially
443 * with heavy traffic at high txpowers. Driver should update
444 * temperature calculations often under these conditions to
445 * maintain strong txpower in the face of rising temperature.
446 *
447 *
448 * 7) Find difference between current power supply voltage indicator
449 * (from "initialize alive") and factory-measured power supply voltage
450 * indicator (EEPROM).
451 *
452 * If the current voltage is higher (indicator is lower) than factory
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100453 * voltage, gain should be reduced (gain table idx increased) by:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800454 *
455 * (eeprom - current) / 7
456 *
457 * If the current voltage is lower (indicator is higher) than factory
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100458 * voltage, gain should be increased (gain table idx decreased) by:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800459 *
460 * 2 * (current - eeprom) / 7
461 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100462 * If number of idx steps in either direction turns out to be > 2,
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800463 * something is wrong ... just use 0.
464 *
465 * NOTE: Voltage compensation is independent of band/channel.
466 *
467 * NOTE: "Initialize" uCode measures current voltage, which is assumed
468 * to be constant after this initial measurement. Voltage
469 * compensation for txpower (number of steps in gain table)
470 * may be calculated once and used until the next uCode bootload.
471 *
472 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100473 * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31),
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800474 * adjust txpower for each transmitter chain, so txpower is balanced
475 * between the two chains. There are 5 pairs of tx_atten[group][chain]
476 * values in "initialize alive", one pair for each of 5 channel ranges:
477 *
478 * Group 0: 5 GHz channel 34-43
479 * Group 1: 5 GHz channel 44-70
480 * Group 2: 5 GHz channel 71-124
481 * Group 3: 5 GHz channel 125-200
482 * Group 4: 2.4 GHz all channels
483 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100484 * Add the tx_atten[group][chain] value to the idx for the target chain.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800485 * The values are signed, but are in pairs of 0 and a non-negative number,
486 * so as to reduce gain (if necessary) of the "hotter" channel. This
487 * avoids any need to double-check for regulatory compliance after
488 * this step.
489 *
490 *
491 * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100492 * value to the idx:
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800493 *
494 * Hardware rev B: 9 steps (4.5 dB)
495 * Hardware rev C: 5 steps (2.5 dB)
496 *
497 * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
498 * bits [3:2], 1 = B, 2 = C.
499 *
500 * NOTE: This compensation is in addition to any saturation backoff that
501 * might have been applied in an earlier step.
502 *
503 *
504 * 10) Select the gain table, based on band (2.4 vs 5 GHz).
505 *
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100506 * Limit the adjusted idx to stay within the table!
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800507 *
508 *
509 * 11) Read gain table entries for DSP and radio gain, place into appropriate
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200510 * location(s) in command (struct il4965_txpowertable_cmd).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800511 */
512
513/**
514 * When MIMO is used (2 transmitters operating simultaneously), driver should
515 * limit each transmitter to deliver a max of 3 dB below the regulatory limit
516 * for the device. That is, use half power for each transmitter, so total
517 * txpower is within regulatory limits.
518 *
519 * The value "6" represents number of steps in gain table to reduce power 3 dB.
520 * Each step is 1/2 dB.
521 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200522#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800523
524/**
525 * CCK gain compensation.
526 *
527 * When calculating txpowers for CCK, after making sure that the target power
528 * is within regulatory and saturation limits, driver must additionally
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100529 * back off gain by adding these values to the gain table idx.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800530 *
531 * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG,
532 * bits [3:2], 1 = B, 2 = C.
533 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200534#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9)
535#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800536
537/*
538 * 4965 power supply voltage compensation for txpower
539 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200540#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800541
542/**
543 * Gain tables.
544 *
545 * The following tables contain pair of values for setting txpower, i.e.
546 * gain settings for the output of the device's digital signal processor (DSP),
547 * and for the analog gain structure of the transmitter.
548 *
549 * Each entry in the gain tables represents a step of 1/2 dB. Note that these
550 * are *relative* steps, not indications of absolute output power. Output
551 * power varies with temperature, voltage, and channel frequency, and also
552 * requires consideration of average power (to satisfy regulatory constraints),
553 * and peak power (to avoid distortion of the output signal).
554 *
555 * Each entry contains two values:
556 * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained
557 * linear value that multiplies the output of the digital signal processor,
558 * before being sent to the analog radio.
559 * 2) Radio gain. This sets the analog gain of the radio Tx path.
560 * It is a coarser setting, and behaves in a logarithmic (dB) fashion.
561 *
562 * EEPROM contains factory calibration data for txpower. This maps actual
563 * measured txpower levels to gain settings in the "well known" tables
564 * below ("well-known" means here that both factory calibration *and* the
565 * driver work with the same table).
566 *
567 * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100568 * has an extension (into negative idxes), in case the driver needs to
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800569 * boost power setting for high device temperatures (higher than would be
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100570 * present during factory calibration). A 5 Ghz EEPROM idx of "40"
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800571 * corresponds to the 49th entry in the table used by the driver.
572 */
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100573#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */
574#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800575
576/**
577 * 2.4 GHz gain table
578 *
579 * Index Dsp gain Radio gain
580 * 0 110 0x3f (highest gain)
581 * 1 104 0x3f
582 * 2 98 0x3f
583 * 3 110 0x3e
584 * 4 104 0x3e
585 * 5 98 0x3e
586 * 6 110 0x3d
587 * 7 104 0x3d
588 * 8 98 0x3d
589 * 9 110 0x3c
590 * 10 104 0x3c
591 * 11 98 0x3c
592 * 12 110 0x3b
593 * 13 104 0x3b
594 * 14 98 0x3b
595 * 15 110 0x3a
596 * 16 104 0x3a
597 * 17 98 0x3a
598 * 18 110 0x39
599 * 19 104 0x39
600 * 20 98 0x39
601 * 21 110 0x38
602 * 22 104 0x38
603 * 23 98 0x38
604 * 24 110 0x37
605 * 25 104 0x37
606 * 26 98 0x37
607 * 27 110 0x36
608 * 28 104 0x36
609 * 29 98 0x36
610 * 30 110 0x35
611 * 31 104 0x35
612 * 32 98 0x35
613 * 33 110 0x34
614 * 34 104 0x34
615 * 35 98 0x34
616 * 36 110 0x33
617 * 37 104 0x33
618 * 38 98 0x33
619 * 39 110 0x32
620 * 40 104 0x32
621 * 41 98 0x32
622 * 42 110 0x31
623 * 43 104 0x31
624 * 44 98 0x31
625 * 45 110 0x30
626 * 46 104 0x30
627 * 47 98 0x30
628 * 48 110 0x6
629 * 49 104 0x6
630 * 50 98 0x6
631 * 51 110 0x5
632 * 52 104 0x5
633 * 53 98 0x5
634 * 54 110 0x4
635 * 55 104 0x4
636 * 56 98 0x4
637 * 57 110 0x3
638 * 58 104 0x3
639 * 59 98 0x3
640 * 60 110 0x2
641 * 61 104 0x2
642 * 62 98 0x2
643 * 63 110 0x1
644 * 64 104 0x1
645 * 65 98 0x1
646 * 66 110 0x0
647 * 67 104 0x0
648 * 68 98 0x0
649 * 69 97 0
650 * 70 96 0
651 * 71 95 0
652 * 72 94 0
653 * 73 93 0
654 * 74 92 0
655 * 75 91 0
656 * 76 90 0
657 * 77 89 0
658 * 78 88 0
659 * 79 87 0
660 * 80 86 0
661 * 81 85 0
662 * 82 84 0
663 * 83 83 0
664 * 84 82 0
665 * 85 81 0
666 * 86 80 0
667 * 87 79 0
668 * 88 78 0
669 * 89 77 0
670 * 90 76 0
671 * 91 75 0
672 * 92 74 0
673 * 93 73 0
674 * 94 72 0
675 * 95 71 0
676 * 96 70 0
677 * 97 69 0
678 * 98 68 0
679 */
680
681/**
682 * 5 GHz gain table
683 *
684 * Index Dsp gain Radio gain
685 * -9 123 0x3F (highest gain)
686 * -8 117 0x3F
687 * -7 110 0x3F
688 * -6 104 0x3F
689 * -5 98 0x3F
690 * -4 110 0x3E
691 * -3 104 0x3E
692 * -2 98 0x3E
693 * -1 110 0x3D
694 * 0 104 0x3D
695 * 1 98 0x3D
696 * 2 110 0x3C
697 * 3 104 0x3C
698 * 4 98 0x3C
699 * 5 110 0x3B
700 * 6 104 0x3B
701 * 7 98 0x3B
702 * 8 110 0x3A
703 * 9 104 0x3A
704 * 10 98 0x3A
705 * 11 110 0x39
706 * 12 104 0x39
707 * 13 98 0x39
708 * 14 110 0x38
709 * 15 104 0x38
710 * 16 98 0x38
711 * 17 110 0x37
712 * 18 104 0x37
713 * 19 98 0x37
714 * 20 110 0x36
715 * 21 104 0x36
716 * 22 98 0x36
717 * 23 110 0x35
718 * 24 104 0x35
719 * 25 98 0x35
720 * 26 110 0x34
721 * 27 104 0x34
722 * 28 98 0x34
723 * 29 110 0x33
724 * 30 104 0x33
725 * 31 98 0x33
726 * 32 110 0x32
727 * 33 104 0x32
728 * 34 98 0x32
729 * 35 110 0x31
730 * 36 104 0x31
731 * 37 98 0x31
732 * 38 110 0x30
733 * 39 104 0x30
734 * 40 98 0x30
735 * 41 110 0x25
736 * 42 104 0x25
737 * 43 98 0x25
738 * 44 110 0x24
739 * 45 104 0x24
740 * 46 98 0x24
741 * 47 110 0x23
742 * 48 104 0x23
743 * 49 98 0x23
744 * 50 110 0x22
745 * 51 104 0x18
746 * 52 98 0x18
747 * 53 110 0x17
748 * 54 104 0x17
749 * 55 98 0x17
750 * 56 110 0x16
751 * 57 104 0x16
752 * 58 98 0x16
753 * 59 110 0x15
754 * 60 104 0x15
755 * 61 98 0x15
756 * 62 110 0x14
757 * 63 104 0x14
758 * 64 98 0x14
759 * 65 110 0x13
760 * 66 104 0x13
761 * 67 98 0x13
762 * 68 110 0x12
763 * 69 104 0x08
764 * 70 98 0x08
765 * 71 110 0x07
766 * 72 104 0x07
767 * 73 98 0x07
768 * 74 110 0x06
769 * 75 104 0x06
770 * 76 98 0x06
771 * 77 110 0x05
772 * 78 104 0x05
773 * 79 98 0x05
774 * 80 110 0x04
775 * 81 104 0x04
776 * 82 98 0x04
777 * 83 110 0x03
778 * 84 104 0x03
779 * 85 98 0x03
780 * 86 110 0x02
781 * 87 104 0x02
782 * 88 98 0x02
783 * 89 110 0x01
784 * 90 104 0x01
785 * 91 98 0x01
786 * 92 110 0x00
787 * 93 104 0x00
788 * 94 98 0x00
789 * 95 93 0x00
790 * 96 88 0x00
791 * 97 83 0x00
792 * 98 78 0x00
793 */
794
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800795/**
796 * Sanity checks and default values for EEPROM regulatory levels.
797 * If EEPROM values fall outside MIN/MAX range, use default values.
798 *
799 * Regulatory limits refer to the maximum average txpower allowed by
800 * regulatory agencies in the geographies in which the device is meant
801 * to be operated. These limits are SKU-specific (i.e. geography-specific),
802 * and channel-specific; each channel has an individual regulatory limit
803 * listed in the EEPROM.
804 *
805 * Units are in half-dBm (i.e. "34" means 17 dBm).
806 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200807#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34)
808#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34)
809#define IL_TX_POWER_REGULATORY_MIN (0)
810#define IL_TX_POWER_REGULATORY_MAX (34)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800811
812/**
813 * Sanity checks and default values for EEPROM saturation levels.
814 * If EEPROM values fall outside MIN/MAX range, use default values.
815 *
816 * Saturation is the highest level that the output power amplifier can produce
817 * without significant clipping distortion. This is a "peak" power level.
818 * Different types of modulation (i.e. various "rates", and OFDM vs. CCK)
819 * require differing amounts of backoff, relative to their average power output,
820 * in order to avoid clipping distortion.
821 *
822 * Driver must make sure that it is violating neither the saturation limit,
823 * nor the regulatory limit, when calculating Tx power settings for various
824 * rates.
825 *
826 * Units are in half-dBm (i.e. "38" means 19 dBm).
827 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200828#define IL_TX_POWER_DEFAULT_SATURATION_24 (38)
829#define IL_TX_POWER_DEFAULT_SATURATION_52 (38)
830#define IL_TX_POWER_SATURATION_MIN (20)
831#define IL_TX_POWER_SATURATION_MAX (50)
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800832
833/**
834 * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance)
835 * and thermal Txpower calibration.
836 *
837 * When calculating txpower, driver must compensate for current device
838 * temperature; higher temperature requires higher gain. Driver must calculate
839 * current temperature (see "4965 temperature calculation"), then compare vs.
840 * factory calibration temperature in EEPROM; if current temperature is higher
841 * than factory temperature, driver must *increase* gain by proportions shown
842 * in table below. If current temperature is lower than factory, driver must
843 * *decrease* gain.
844 *
845 * Different frequency ranges require different compensation, as shown below.
846 */
847/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200848#define CALIB_IL_TX_ATTEN_GR1_FCH 34
849#define CALIB_IL_TX_ATTEN_GR1_LCH 43
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800850
851/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200852#define CALIB_IL_TX_ATTEN_GR2_FCH 44
853#define CALIB_IL_TX_ATTEN_GR2_LCH 70
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800854
855/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200856#define CALIB_IL_TX_ATTEN_GR3_FCH 71
857#define CALIB_IL_TX_ATTEN_GR3_LCH 124
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800858
859/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200860#define CALIB_IL_TX_ATTEN_GR4_FCH 125
861#define CALIB_IL_TX_ATTEN_GR4_LCH 200
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800862
863/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200864#define CALIB_IL_TX_ATTEN_GR5_FCH 1
865#define CALIB_IL_TX_ATTEN_GR5_LCH 20
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800866
867enum {
868 CALIB_CH_GROUP_1 = 0,
869 CALIB_CH_GROUP_2 = 1,
870 CALIB_CH_GROUP_3 = 2,
871 CALIB_CH_GROUP_4 = 3,
872 CALIB_CH_GROUP_5 = 4,
873 CALIB_CH_GROUP_MAX
874};
875
876/********************* END TXPOWER *****************************************/
877
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800878/**
879 * Tx/Rx Queues
880 *
881 * Most communication between driver and 4965 is via queues of data buffers.
882 * For example, all commands that the driver issues to device's embedded
883 * controller (uCode) are via the command queue (one of the Tx queues). All
884 * uCode command responses/replies/notifications, including Rx frames, are
885 * conveyed from uCode to driver via the Rx queue.
886 *
887 * Most support for these queues, including handshake support, resides in
888 * structures in host DRAM, shared between the driver and the device. When
889 * allocating this memory, the driver must make sure that data written by
890 * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's
891 * cache memory), so DRAM and cache are consistent, and the device can
892 * immediately see changes made by the driver.
893 *
894 * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via
895 * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array
896 * in DRAM containing 256 Transmit Frame Descriptors (TFDs).
897 */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100898#define IL49_NUM_FIFOS 7
899#define IL49_CMD_FIFO_NUM 4
900#define IL49_NUM_QUEUES 16
901#define IL49_NUM_AMPDU_QUEUES 8
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800902
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800903/**
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200904 * struct il4965_schedq_bc_tbl
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800905 *
906 * Byte Count table
907 *
908 * Each Tx queue uses a byte-count table containing 320 entries:
909 * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that
Stanislaw Gruszka6ce1dc42011-08-26 15:49:28 +0200910 * duplicate the first 64 entries (to avoid wrap-around within a Tx win;
911 * max Tx win is 64 TFDs).
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800912 *
913 * When driver sets up a new TFD, it must also enter the total byte count
914 * of the frame to be transmitted into the corresponding entry in the byte
Stanislaw Gruszka0c2c8852011-11-15 12:30:17 +0100915 * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver
916 * must duplicate the byte count entry in corresponding idx 256-319.
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800917 *
918 * padding puts each byte count table on a 1024-byte boundary;
919 * 4965 assumes tables are separated by 1024 bytes.
920 */
Stanislaw Gruszkae2ebc832011-10-24 15:41:30 +0200921struct il4965_scd_bc_tbl {
Wey-Yi Guy4bc85c12011-02-21 11:11:05 -0800922 __le16 tfd_offset[TFD_QUEUE_BC_SIZE];
923 u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)];
924} __packed;
925
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100926#define IL4965_RTC_INST_LOWER_BOUND (0x000000)
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800927
928/* RSSI to dBm */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100929#define IL4965_RSSI_OFFSET 44
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800930
931/* PCI registers */
932#define PCI_CFG_RETRY_TIMEOUT 0x041
933
934/* PCI register values */
935#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
936#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
937
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100938#define IL4965_DEFAULT_TX_RETRY 15
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800939
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800940/* EEPROM */
Stanislaw Gruszkad3175162011-11-15 11:25:42 +0100941#define IL4965_FIRST_AMPDU_QUEUE 10
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800942
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200943/* Calibration */
944void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp);
945void il4965_sensitivity_calibration(struct il_priv *il, void *resp);
946void il4965_init_sensitivity(struct il_priv *il);
947void il4965_reset_run_time_calib(struct il_priv *il);
948void il4965_calib_free_results(struct il_priv *il);
Wey-Yi Guybe663ab2011-02-21 11:27:26 -0800949
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200950/* Debug */
951#ifdef CONFIG_IWLEGACY_DEBUGFS
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100952ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf,
953 size_t count, loff_t * ppos);
954ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf,
955 size_t count, loff_t * ppos);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200956ssize_t il4965_ucode_general_stats_read(struct file *file,
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100957 char __user * user_buf, size_t count,
958 loff_t * ppos);
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200959#else
960static ssize_t
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100961il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf,
962 size_t count, loff_t * ppos)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200963{
964 return 0;
965}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100966
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200967static ssize_t
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100968il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf,
969 size_t count, loff_t * ppos)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200970{
971 return 0;
972}
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100973
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200974static ssize_t
Stanislaw Gruszkae7392362011-11-15 14:45:59 +0100975il4965_ucode_general_stats_read(struct file *file, char __user * user_buf,
976 size_t count, loff_t * ppos)
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +0200977{
978 return 0;
979}
980#endif
981
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +0200982/****************************/
983/* Flow Handler Definitions */
984/****************************/
985
986/**
987 * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
988 * Addresses are offsets from device's PCI hardware base address.
989 */
990#define FH49_MEM_LOWER_BOUND (0x1000)
991#define FH49_MEM_UPPER_BOUND (0x2000)
992
993/**
994 * Keep-Warm (KW) buffer base address.
995 *
996 * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the
997 * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency
998 * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host
999 * from going into a power-savings mode that would cause higher DRAM latency,
1000 * and possible data over/under-runs, before all Tx/Rx is complete.
1001 *
1002 * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4)
1003 * of the buffer, which must be 4K aligned. Once this is set up, the 4965
1004 * automatically invokes keep-warm accesses when normal accesses might not
1005 * be sufficient to maintain fast DRAM response.
1006 *
1007 * Bit fields:
1008 * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned
1009 */
1010#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C)
1011
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001012/**
1013 * TFD Circular Buffers Base (CBBC) addresses
1014 *
1015 * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident
1016 * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs)
1017 * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04
1018 * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte
1019 * aligned (address bits 0-7 must be 0).
1020 *
1021 * Bit fields in each pointer register:
1022 * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned
1023 */
1024#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0)
1025#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10)
1026
1027/* Find TFD CB base pointer for given queue (range 0-15). */
1028#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4)
1029
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001030/**
1031 * Rx SRAM Control and Status Registers (RSCSR)
1032 *
1033 * These registers provide handshake between driver and 4965 for the Rx queue
1034 * (this queue handles *all* command responses, notifications, Rx data, etc.
1035 * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx
1036 * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can
1037 * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer
1038 * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1
1039 * mapping between RBDs and RBs.
1040 *
1041 * Driver must allocate host DRAM memory for the following, and set the
1042 * physical address of each into 4965 registers:
1043 *
1044 * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256
1045 * entries (although any power of 2, up to 4096, is selectable by driver).
1046 * Each entry (1 dword) points to a receive buffer (RB) of consistent size
1047 * (typically 4K, although 8K or 16K are also selectable by driver).
1048 * Driver sets up RB size and number of RBDs in the CB via Rx config
1049 * register FH49_MEM_RCSR_CHNL0_CONFIG_REG.
1050 *
1051 * Bit fields within one RBD:
1052 * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned
1053 *
1054 * Driver sets physical address [35:8] of base of RBD circular buffer
1055 * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0].
1056 *
1057 * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers
1058 * (RBs) have been filled, via a "write pointer", actually the idx of
1059 * the RB's corresponding RBD within the circular buffer. Driver sets
1060 * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0].
1061 *
1062 * Bit fields in lower dword of Rx status buffer (upper dword not used
1063 * by driver; see struct il4965_shared, val0):
1064 * 31-12: Not used by driver
1065 * 11- 0: Index of last filled Rx buffer descriptor
1066 * (4965 writes, driver reads this value)
1067 *
1068 * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must
1069 * enter pointers to these RBs into contiguous RBD circular buffer entries,
1070 * and update the 4965's "write" idx register,
1071 * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG.
1072 *
1073 * This "write" idx corresponds to the *next* RBD that the driver will make
1074 * available, i.e. one RBD past the tail of the ready-to-fill RBDs within
1075 * the circular buffer. This value should initially be 0 (before preparing any
1076 * RBs), should be 8 after preparing the first 8 RBs (for example), and must
1077 * wrap back to 0 at the end of the circular buffer (but don't wrap before
1078 * "read" idx has advanced past 1! See below).
1079 * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8.
1080 *
1081 * As the 4965 fills RBs (referenced from contiguous RBDs within the circular
1082 * buffer), it updates the Rx status buffer in host DRAM, 2) described above,
1083 * to tell the driver the idx of the latest filled RBD. The driver must
1084 * read this "read" idx from DRAM after receiving an Rx interrupt from 4965.
1085 *
1086 * The driver must also internally keep track of a third idx, which is the
1087 * next RBD to process. When receiving an Rx interrupt, driver should process
1088 * all filled but unprocessed RBs up to, but not including, the RB
1089 * corresponding to the "read" idx. For example, if "read" idx becomes "1",
1090 * driver may process the RB pointed to by RBD 0. Depending on volume of
1091 * traffic, there may be many RBs to process.
1092 *
1093 * If read idx == write idx, 4965 thinks there is no room to put new data.
1094 * Due to this, the maximum number of filled RBs is 255, instead of 256. To
1095 * be safe, make sure that there is a gap of at least 2 RBDs between "write"
1096 * and "read" idxes; that is, make sure that there are no more than 254
1097 * buffers waiting to be filled.
1098 */
1099#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0)
1100#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00)
1101#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND)
1102
1103/**
1104 * Physical base address of 8-byte Rx Status buffer.
1105 * Bit fields:
1106 * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned.
1107 */
1108#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0)
1109
1110/**
1111 * Physical base address of Rx Buffer Descriptor Circular Buffer.
1112 * Bit fields:
1113 * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned.
1114 */
1115#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004)
1116
1117/**
1118 * Rx write pointer (idx, really!).
1119 * Bit fields:
1120 * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1.
1121 * NOTE: For 256-entry circular buffer, use only bits [7:0].
1122 */
1123#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008)
1124#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG)
1125
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001126/**
1127 * Rx Config/Status Registers (RCSR)
1128 * Rx Config Reg for channel 0 (only channel used)
1129 *
1130 * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for
1131 * normal operation (see bit fields).
1132 *
1133 * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA.
1134 * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for
1135 * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing.
1136 *
1137 * Bit fields:
1138 * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1139 * '10' operate normally
1140 * 29-24: reserved
1141 * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal),
1142 * min "5" for 32 RBDs, max "12" for 4096 RBDs.
1143 * 19-18: reserved
1144 * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K,
1145 * '10' 12K, '11' 16K.
1146 * 15-14: reserved
1147 * 13-12: IRQ destination; '00' none, '01' host driver (normal operation)
1148 * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec)
1149 * typical value 0x10 (about 1/2 msec)
1150 * 3- 0: reserved
1151 */
1152#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00)
1153#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0)
1154#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND)
1155
1156#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0)
1157
Stanislaw Gruszkae7392362011-11-15 14:45:59 +01001158#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */
1159#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */
1160#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */
1161#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */
1162#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */
1163#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31 */
Stanislaw Gruszkaeac3b212011-08-31 14:29:46 +02001164
1165#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20)
1166#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4)
1167#define RX_RB_TIMEOUT (0x10)
1168
1169#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000)
1170#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000)
1171#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000)
1172
1173#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000)
1174#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000)
1175#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000)
1176#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000)
1177
1178#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004)
1179#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000)
1180#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000)
1181
1182/**
1183 * Rx Shared Status Registers (RSSR)
1184 *
1185 * After stopping Rx DMA channel (writing 0 to
1186 * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll
1187 * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle.
1188 *
1189 * Bit fields:
1190 * 24: 1 = Channel 0 is idle
1191 *
1192 * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV
1193 * contain default values that should not be altered by the driver.
1194 */
1195#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40)
1196#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00)
1197
1198#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND)
1199#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004)
1200#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\
1201 (FH49_MEM_RSSR_LOWER_BOUND + 0x008)
1202
1203#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
1204
1205#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
1206
1207/* TFDB Area - TFDs buffer table */
1208#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
1209#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900)
1210#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958)
1211#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl))
1212#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4)
1213
1214/**
1215 * Transmit DMA Channel Control/Status Registers (TCSR)
1216 *
1217 * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels
1218 * supported in hardware (don't confuse these with the 16 Tx queues in DRAM,
1219 * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes.
1220 *
1221 * To use a Tx DMA channel, driver must initialize its
1222 * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with:
1223 *
1224 * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
1225 * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL
1226 *
1227 * All other bits should be 0.
1228 *
1229 * Bit fields:
1230 * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame,
1231 * '10' operate normally
1232 * 29- 4: Reserved, set to "0"
1233 * 3: Enable internal DMA requests (1, normal operation), disable (0)
1234 * 2- 0: Reserved, set to "0"
1235 */
1236#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00)
1237#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60)
1238
1239/* Find Control/Status reg for given Tx DMA/FIFO channel */
1240#define FH49_TCSR_CHNL_NUM (7)
1241#define FH50_TCSR_CHNL_NUM (8)
1242
1243/* TCSR: tx_config register values */
1244#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \
1245 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl))
1246#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \
1247 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4)
1248#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \
1249 (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8)
1250
1251#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000)
1252#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001)
1253
1254#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000)
1255#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008)
1256
1257#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000)
1258#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000)
1259#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000)
1260
1261#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000)
1262#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000)
1263#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000)
1264
1265#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000)
1266#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000)
1267#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000)
1268
1269#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000)
1270#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000)
1271#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003)
1272
1273#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20)
1274#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12)
1275
1276/**
1277 * Tx Shared Status Registers (TSSR)
1278 *
1279 * After stopping Tx DMA channel (writing 0 to
1280 * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll
1281 * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle
1282 * (channel's buffers empty | no pending requests).
1283 *
1284 * Bit fields:
1285 * 31-24: 1 = Channel buffers empty (channel 7:0)
1286 * 23-16: 1 = No pending requests (channel 7:0)
1287 */
1288#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0)
1289#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0)
1290
1291#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010)
1292
1293/**
1294 * Bit fields for TSSR(Tx Shared Status & Control) error status register:
1295 * 31: Indicates an address error when accessed to internal memory
1296 * uCode/driver must write "1" in order to clear this flag
1297 * 30: Indicates that Host did not send the expected number of dwords to FH
1298 * uCode/driver must write "1" in order to clear this flag
1299 * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA
1300 * command was received from the scheduler while the TRB was already full
1301 * with previous command
1302 * uCode/driver must write "1" in order to clear this flag
1303 * 7-0: Each status bit indicates a channel's TxCredit error. When an error
1304 * bit is set, it indicates that the FH has received a full indication
1305 * from the RTC TxFIFO and the current value of the TxCredit counter was
1306 * not equal to zero. This mean that the credit mechanism was not
1307 * synchronized to the TxFIFO status
1308 * uCode/driver must write "1" in order to clear this flag
1309 */
1310#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018)
1311
1312#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16)
1313
1314/* Tx service channels */
1315#define FH49_SRVC_CHNL (9)
1316#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8)
1317#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0)
1318#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \
1319 (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4)
1320
1321#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98)
1322/* Instruct FH to increment the retry count of a packet when
1323 * it is brought from the memory to TX-FIFO
1324 */
1325#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002)
1326
1327/* Keep Warm Size */
1328#define IL_KW_SIZE 0x1000 /* 4k */
1329
Stanislaw Gruszkaaf038f42011-08-30 13:58:27 +02001330#endif /* __il_4965_h__ */