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