]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/net/wireless/iwlegacy/3945.h
e89ca5da7f3c9862cd127ebf03cd4cbb6796d9da
[mv-sheeva.git] / drivers / net / wireless / iwlegacy / 3945.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  * The full GNU General Public License is included in this distribution in the
19  * file called LICENSE.
20  *
21  * Contact Information:
22  *  Intel Linux Wireless <ilw@linux.intel.com>
23  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24  *
25  *****************************************************************************/
26
27 #ifndef __il_3945_h__
28 #define __il_3945_h__
29
30 #include <linux/pci.h> /* for struct pci_device_id */
31 #include <linux/kernel.h>
32 #include <net/ieee80211_radiotap.h>
33
34 /* Hardware specific file defines the PCI IDs table for that hardware module */
35 extern const struct pci_device_id il3945_hw_card_ids[];
36
37 #include "iwl-prph.h"
38 #include "iwl-debug.h"
39 #include "iwl-power.h"
40 #include "iwl-dev.h"
41 #include "iwl-led.h"
42 #include "iwl-eeprom.h"
43
44 /* Highest firmware API version supported */
45 #define IL3945_UCODE_API_MAX 2
46
47 /* Lowest firmware API version supported */
48 #define IL3945_UCODE_API_MIN 1
49
50 #define IL3945_FW_PRE   "iwlwifi-3945-"
51 #define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode"
52 #define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api)
53
54 /* Default noise level to report when noise measurement is not available.
55  *   This may be because we're:
56  *   1)  Not associated (4965, no beacon stats being sent to driver)
57  *   2)  Scanning (noise measurement does not apply to associated channel)
58  *   3)  Receiving CCK (3945 delivers noise info only for OFDM frames)
59  * Use default noise value of -127 ... this is below the range of measurable
60  *   Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
61  *   Also, -127 works better than 0 when averaging frames with/without
62  *   noise info (e.g. averaging might be done in app); measured dBm values are
63  *   always negative ... using a negative value as the default keeps all
64  *   averages within an s8's (used in some apps) range of negative values. */
65 #define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
66
67 /* Module parameters accessible from iwl-*.c */
68 extern struct il_mod_params il3945_mod_params;
69
70 struct il3945_rate_scale_data {
71         u64 data;
72         s32 success_counter;
73         s32 success_ratio;
74         s32 counter;
75         s32 average_tpt;
76         unsigned long stamp;
77 };
78
79 struct il3945_rs_sta {
80         spinlock_t lock;
81         struct il_priv *il;
82         s32 *expected_tpt;
83         unsigned long last_partial_flush;
84         unsigned long last_flush;
85         u32 flush_time;
86         u32 last_tx_packets;
87         u32 tx_packets;
88         u8 tgg;
89         u8 flush_pending;
90         u8 start_rate;
91         struct timer_list rate_scale_flush;
92         struct il3945_rate_scale_data win[RATE_COUNT_3945];
93 #ifdef CONFIG_MAC80211_DEBUGFS
94         struct dentry *rs_sta_dbgfs_stats_table_file;
95 #endif
96
97         /* used to be in sta_info */
98         int last_txrate_idx;
99 };
100
101
102 /*
103  * The common struct MUST be first because it is shared between
104  * 3945 and 4965!
105  */
106 struct il3945_sta_priv {
107         struct il_station_priv_common common;
108         struct il3945_rs_sta rs_sta;
109 };
110
111 enum il3945_antenna {
112         IL_ANTENNA_DIVERSITY,
113         IL_ANTENNA_MAIN,
114         IL_ANTENNA_AUX
115 };
116
117 /*
118  * RTS threshold here is total size [2347] minus 4 FCS bytes
119  * Per spec:
120  *   a value of 0 means RTS on all data/management packets
121  *   a value > max MSDU size means no RTS
122  * else RTS for data/management frames where MPDU is larger
123  *   than RTS value.
124  */
125 #define DEFAULT_RTS_THRESHOLD     2347U
126 #define MIN_RTS_THRESHOLD         0U
127 #define MAX_RTS_THRESHOLD         2347U
128 #define MAX_MSDU_SIZE             2304U
129 #define MAX_MPDU_SIZE             2346U
130 #define DEFAULT_BEACON_INTERVAL   100U
131 #define DEFAULT_SHORT_RETRY_LIMIT 7U
132 #define DEFAULT_LONG_RETRY_LIMIT  4U
133
134 #define IL_TX_FIFO_AC0  0
135 #define IL_TX_FIFO_AC1  1
136 #define IL_TX_FIFO_AC2  2
137 #define IL_TX_FIFO_AC3  3
138 #define IL_TX_FIFO_HCCA_1       5
139 #define IL_TX_FIFO_HCCA_2       6
140 #define IL_TX_FIFO_NONE 7
141
142 #define IEEE80211_DATA_LEN              2304
143 #define IEEE80211_4ADDR_LEN             30
144 #define IEEE80211_HLEN                  (IEEE80211_4ADDR_LEN)
145 #define IEEE80211_FRAME_LEN             (IEEE80211_DATA_LEN + IEEE80211_HLEN)
146
147 struct il3945_frame {
148         union {
149                 struct ieee80211_hdr frame;
150                 struct il3945_tx_beacon_cmd beacon;
151                 u8 raw[IEEE80211_FRAME_LEN];
152                 u8 cmd[360];
153         } u;
154         struct list_head list;
155 };
156
157 #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
158 #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
159 #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
160
161 #define SUP_RATE_11A_MAX_NUM_CHANNELS  8
162 #define SUP_RATE_11B_MAX_NUM_CHANNELS  4
163 #define SUP_RATE_11G_MAX_NUM_CHANNELS  12
164
165 #define IL_SUPPORTED_RATES_IE_LEN         8
166
167 #define SCAN_INTERVAL 100
168
169 #define MAX_TID_COUNT        9
170
171 #define IL_INVALID_RATE     0xFF
172 #define IL_INVALID_VALUE    -1
173
174 #define STA_PS_STATUS_WAKE             0
175 #define STA_PS_STATUS_SLEEP            1
176
177 struct il3945_ibss_seq {
178         u8 mac[ETH_ALEN];
179         u16 seq_num;
180         u16 frag_num;
181         unsigned long packet_time;
182         struct list_head list;
183 };
184
185 #define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\
186                        x->u.rx_frame.stats.payload + \
187                        x->u.rx_frame.stats.phy_count))
188 #define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\
189                        IL_RX_HDR(x)->payload + \
190                        le16_to_cpu(IL_RX_HDR(x)->len)))
191 #define IL_RX_STATS(x) (&x->u.rx_frame.stats)
192 #define IL_RX_DATA(x) (IL_RX_HDR(x)->payload)
193
194
195 /******************************************************************************
196  *
197  * Functions implemented in iwl3945-base.c which are forward declared here
198  * for use by iwl-*.c
199  *
200  *****************************************************************************/
201 extern int il3945_calc_db_from_ratio(int sig_ratio);
202 extern void il3945_rx_replenish(void *data);
203 extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq);
204 extern unsigned int il3945_fill_beacon_frame(struct il_priv *il,
205                                         struct ieee80211_hdr *hdr, int left);
206 extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log,
207                                        char **buf, bool display);
208 extern void il3945_dump_nic_error_log(struct il_priv *il);
209
210 /******************************************************************************
211  *
212  * Functions implemented in iwl-[34]*.c which are forward declared here
213  * for use by iwl3945-base.c
214  *
215  * NOTE:  The implementation of these functions are hardware specific
216  * which is why they are in the hardware specific files (vs. iwl-base.c)
217  *
218  * Naming convention --
219  * il3945_         <-- Its part of iwlwifi (should be changed to il3945_)
220  * il3945_hw_      <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
221  * iwlXXXX_     <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
222  * il3945_bg_      <-- Called from work queue context
223  * il3945_mac_     <-- mac80211 callback
224  *
225  ****************************************************************************/
226 extern void il3945_hw_handler_setup(struct il_priv *il);
227 extern void il3945_hw_setup_deferred_work(struct il_priv *il);
228 extern void il3945_hw_cancel_deferred_work(struct il_priv *il);
229 extern int il3945_hw_rxq_stop(struct il_priv *il);
230 extern int il3945_hw_set_hw_params(struct il_priv *il);
231 extern int il3945_hw_nic_init(struct il_priv *il);
232 extern int il3945_hw_nic_stop_master(struct il_priv *il);
233 extern void il3945_hw_txq_ctx_free(struct il_priv *il);
234 extern void il3945_hw_txq_ctx_stop(struct il_priv *il);
235 extern int il3945_hw_nic_reset(struct il_priv *il);
236 extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il,
237                                             struct il_tx_queue *txq,
238                                             dma_addr_t addr, u16 len,
239                                             u8 reset, u8 pad);
240 extern void il3945_hw_txq_free_tfd(struct il_priv *il,
241                                     struct il_tx_queue *txq);
242 extern int il3945_hw_get_temperature(struct il_priv *il);
243 extern int il3945_hw_tx_queue_init(struct il_priv *il,
244                                 struct il_tx_queue *txq);
245 extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il,
246                                  struct il3945_frame *frame, u8 rate);
247 void il3945_hw_build_tx_cmd_rate(struct il_priv *il,
248                                   struct il_device_cmd *cmd,
249                                   struct ieee80211_tx_info *info,
250                                   struct ieee80211_hdr *hdr,
251                                   int sta_id, int tx_id);
252 extern int il3945_hw_reg_send_txpower(struct il_priv *il);
253 extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power);
254 extern void il3945_hdl_stats(struct il_priv *il,
255                                  struct il_rx_buf *rxb);
256 void il3945_hdl_c_stats(struct il_priv *il,
257                               struct il_rx_buf *rxb);
258 extern void il3945_disable_events(struct il_priv *il);
259 extern int il4965_get_temperature(const struct il_priv *il);
260 extern void il3945_post_associate(struct il_priv *il);
261 extern void il3945_config_ap(struct il_priv *il);
262
263 extern int il3945_commit_rxon(struct il_priv *il,
264                                struct il_rxon_context *ctx);
265
266 /**
267  * il3945_hw_find_station - Find station id for a given BSSID
268  * @bssid: MAC address of station ID to find
269  *
270  * NOTE:  This should not be hardware specific but the code has
271  * not yet been merged into a single common layer for managing the
272  * station tables.
273  */
274 extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid);
275
276 extern struct ieee80211_ops il3945_hw_ops;
277
278 extern __le32 il3945_get_antenna_flags(const struct il_priv *il);
279 extern int il3945_init_hw_rate_table(struct il_priv *il);
280 extern void il3945_reg_txpower_periodic(struct il_priv *il);
281 extern int il3945_txpower_set_from_eeprom(struct il_priv *il);
282
283 extern const struct il_channel_info *il3945_get_channel_info(
284         const struct il_priv *il, enum ieee80211_band band, u16 channel);
285
286 extern int il3945_rs_next_rate(struct il_priv *il, int rate);
287
288 /* scanning */
289 int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif);
290 void il3945_post_scan(struct il_priv *il);
291
292 /* rates */
293 extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945];
294
295
296
297 /* RSSI to dBm */
298 #define IL39_RSSI_OFFSET        95
299
300 /*
301  * EEPROM related constants, enums, and structures.
302  */
303 #define EEPROM_SKU_CAP_OP_MODE_MRC                      (1 << 7)
304
305 /*
306  * Mapping of a Tx power level, at factory calibration temperature,
307  *   to a radio/DSP gain table idx.
308  * One for each of 5 "sample" power levels in each band.
309  * v_det is measured at the factory, using the 3945's built-in power amplifier
310  *   (PA) output voltage detector.  This same detector is used during Tx of
311  *   long packets in normal operation to provide feedback as to proper output
312  *   level.
313  * Data copied from EEPROM.
314  * DO NOT ALTER THIS STRUCTURE!!!
315  */
316 struct il3945_eeprom_txpower_sample {
317         u8 gain_idx;            /* idx into power (gain) setup table ... */
318         s8 power;               /* ... for this pwr level for this chnl group */
319         u16 v_det;              /* PA output voltage */
320 } __packed;
321
322 /*
323  * Mappings of Tx power levels -> nominal radio/DSP gain table idxes.
324  * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
325  * Tx power setup code interpolates between the 5 "sample" power levels
326  *    to determine the nominal setup for a requested power level.
327  * Data copied from EEPROM.
328  * DO NOT ALTER THIS STRUCTURE!!!
329  */
330 struct il3945_eeprom_txpower_group {
331         struct il3945_eeprom_txpower_sample samples[5];  /* 5 power levels */
332         s32 a, b, c, d, e;      /* coefficients for voltage->power
333                                  * formula (signed) */
334         s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on
335                                  * frequency (signed) */
336         s8 saturation_power;    /* highest power possible by h/w in this
337                                  * band */
338         u8 group_channel;       /* "representative" channel # in this band */
339         s16 temperature;        /* h/w temperature at factory calib this band
340                                  * (signed) */
341 } __packed;
342
343 /*
344  * Temperature-based Tx-power compensation data, not band-specific.
345  * These coefficients are use to modify a/b/c/d/e coeffs based on
346  *   difference between current temperature and factory calib temperature.
347  * Data copied from EEPROM.
348  */
349 struct il3945_eeprom_temperature_corr {
350         u32 Ta;
351         u32 Tb;
352         u32 Tc;
353         u32 Td;
354         u32 Te;
355 } __packed;
356
357 /*
358  * EEPROM map
359  */
360 struct il3945_eeprom {
361         u8 reserved0[16];
362         u16 device_id;  /* abs.ofs: 16 */
363         u8 reserved1[2];
364         u16 pmc;                /* abs.ofs: 20 */
365         u8 reserved2[20];
366         u8 mac_address[6];      /* abs.ofs: 42 */
367         u8 reserved3[58];
368         u16 board_revision;     /* abs.ofs: 106 */
369         u8 reserved4[11];
370         u8 board_pba_number[9]; /* abs.ofs: 119 */
371         u8 reserved5[8];
372         u16 version;            /* abs.ofs: 136 */
373         u8 sku_cap;             /* abs.ofs: 138 */
374         u8 leds_mode;           /* abs.ofs: 139 */
375         u16 oem_mode;
376         u16 wowlan_mode;        /* abs.ofs: 142 */
377         u16 leds_time_interval; /* abs.ofs: 144 */
378         u8 leds_off_time;       /* abs.ofs: 146 */
379         u8 leds_on_time;        /* abs.ofs: 147 */
380         u8 almgor_m_version;    /* abs.ofs: 148 */
381         u8 antenna_switch_type; /* abs.ofs: 149 */
382         u8 reserved6[42];
383         u8 sku_id[4];           /* abs.ofs: 192 */
384
385 /*
386  * Per-channel regulatory data.
387  *
388  * Each channel that *might* be supported by 3945 has a fixed location
389  * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
390  * txpower (MSB).
391  *
392  * Entries immediately below are for 20 MHz channel width.
393  *
394  * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
395  */
396         u16 band_1_count;       /* abs.ofs: 196 */
397         struct il_eeprom_channel band_1_channels[14];  /* abs.ofs: 198 */
398
399 /*
400  * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
401  * 5.0 GHz channels 7, 8, 11, 12, 16
402  * (4915-5080MHz) (none of these is ever supported)
403  */
404         u16 band_2_count;       /* abs.ofs: 226 */
405         struct il_eeprom_channel band_2_channels[13];  /* abs.ofs: 228 */
406
407 /*
408  * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
409  * (5170-5320MHz)
410  */
411         u16 band_3_count;       /* abs.ofs: 254 */
412         struct il_eeprom_channel band_3_channels[12];  /* abs.ofs: 256 */
413
414 /*
415  * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
416  * (5500-5700MHz)
417  */
418         u16 band_4_count;       /* abs.ofs: 280 */
419         struct il_eeprom_channel band_4_channels[11];  /* abs.ofs: 282 */
420
421 /*
422  * 5.7 GHz channels 145, 149, 153, 157, 161, 165
423  * (5725-5825MHz)
424  */
425         u16 band_5_count;       /* abs.ofs: 304 */
426         struct il_eeprom_channel band_5_channels[6];  /* abs.ofs: 306 */
427
428         u8 reserved9[194];
429
430 /*
431  * 3945 Txpower calibration data.
432  */
433 #define IL_NUM_TX_CALIB_GROUPS 5
434         struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS];
435 /* abs.ofs: 512 */
436         struct il3945_eeprom_temperature_corr corrections;  /* abs.ofs: 832 */
437         u8 reserved16[172];     /* fill out to full 1024 byte block */
438 } __packed;
439
440 #define IL3945_EEPROM_IMG_SIZE 1024
441
442 /* End of EEPROM */
443
444 #define PCI_CFG_REV_ID_BIT_BASIC_SKU                (0x40)      /* bit 6    */
445 #define PCI_CFG_REV_ID_BIT_RTP                      (0x80)      /* bit 7    */
446
447 /* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */
448 #define IL39_NUM_QUEUES        5
449 #define IL39_CMD_QUEUE_NUM      4
450
451 #define IL_DEFAULT_TX_RETRY  15
452
453 /*********************************************/
454
455 #define RFD_SIZE                              4
456 #define NUM_TFD_CHUNKS                        4
457
458 #define RX_QUEUE_SIZE                         256
459 #define RX_QUEUE_MASK                         255
460 #define RX_QUEUE_SIZE_LOG                     8
461
462 #define TFD_CTL_COUNT_SET(n)       (n << 24)
463 #define TFD_CTL_COUNT_GET(ctl)     ((ctl >> 24) & 7)
464 #define TFD_CTL_PAD_SET(n)         (n << 28)
465 #define TFD_CTL_PAD_GET(ctl)       (ctl >> 28)
466
467 /* Sizes and addresses for instruction and data memory (SRAM) in
468  * 3945's embedded processor.  Driver access is via HBUS_TARG_MEM_* regs. */
469 #define IL39_RTC_INST_LOWER_BOUND               (0x000000)
470 #define IL39_RTC_INST_UPPER_BOUND               (0x014000)
471
472 #define IL39_RTC_DATA_LOWER_BOUND               (0x800000)
473 #define IL39_RTC_DATA_UPPER_BOUND               (0x808000)
474
475 #define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \
476                                 IL39_RTC_INST_LOWER_BOUND)
477 #define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \
478                                 IL39_RTC_DATA_LOWER_BOUND)
479
480 #define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE
481 #define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE
482
483 /* Size of uCode instruction memory in bootstrap state machine */
484 #define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE
485
486 static inline int il3945_hw_valid_rtc_data_addr(u32 addr)
487 {
488         return (addr >= IL39_RTC_DATA_LOWER_BOUND &&
489                 addr < IL39_RTC_DATA_UPPER_BOUND);
490 }
491
492 /* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE
493  * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */
494 struct il3945_shared {
495         __le32 tx_base_ptr[8];
496 } __packed;
497
498 static inline u8 il3945_hw_get_rate(__le16 rate_n_flags)
499 {
500         return le16_to_cpu(rate_n_flags) & 0xFF;
501 }
502
503 static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags)
504 {
505         return le16_to_cpu(rate_n_flags);
506 }
507
508 static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags)
509 {
510         return cpu_to_le16((u16)rate|flags);
511 }
512
513 /************************************/
514 /* iwl3945 Flow Handler Definitions */
515 /************************************/
516
517 /**
518  * This I/O area is directly read/writable by driver (e.g. Linux uses writel())
519  * Addresses are offsets from device's PCI hardware base address.
520  */
521 #define FH39_MEM_LOWER_BOUND                   (0x0800)
522 #define FH39_MEM_UPPER_BOUND                   (0x1000)
523
524 #define FH39_CBCC_TBL           (FH39_MEM_LOWER_BOUND + 0x140)
525 #define FH39_TFDB_TBL           (FH39_MEM_LOWER_BOUND + 0x180)
526 #define FH39_RCSR_TBL           (FH39_MEM_LOWER_BOUND + 0x400)
527 #define FH39_RSSR_TBL           (FH39_MEM_LOWER_BOUND + 0x4c0)
528 #define FH39_TCSR_TBL           (FH39_MEM_LOWER_BOUND + 0x500)
529 #define FH39_TSSR_TBL           (FH39_MEM_LOWER_BOUND + 0x680)
530
531 /* TFDB (Transmit Frame Buffer Descriptor) */
532 #define FH39_TFDB(_ch, buf)                     (FH39_TFDB_TBL + \
533                                                  ((_ch) * 2 + (buf)) * 0x28)
534 #define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch)        (FH39_TFDB_TBL + 0x50 * (_ch))
535
536 /* CBCC channel is [0,2] */
537 #define FH39_CBCC(_ch)          (FH39_CBCC_TBL + (_ch) * 0x8)
538 #define FH39_CBCC_CTRL(_ch)     (FH39_CBCC(_ch) + 0x00)
539 #define FH39_CBCC_BASE(_ch)     (FH39_CBCC(_ch) + 0x04)
540
541 /* RCSR channel is [0,2] */
542 #define FH39_RCSR(_ch)                  (FH39_RCSR_TBL + (_ch) * 0x40)
543 #define FH39_RCSR_CONFIG(_ch)           (FH39_RCSR(_ch) + 0x00)
544 #define FH39_RCSR_RBD_BASE(_ch)         (FH39_RCSR(_ch) + 0x04)
545 #define FH39_RCSR_WPTR(_ch)             (FH39_RCSR(_ch) + 0x20)
546 #define FH39_RCSR_RPTR_ADDR(_ch)        (FH39_RCSR(_ch) + 0x24)
547
548 #define FH39_RSCSR_CHNL0_WPTR           (FH39_RCSR_WPTR(0))
549
550 /* RSSR */
551 #define FH39_RSSR_CTRL                  (FH39_RSSR_TBL + 0x000)
552 #define FH39_RSSR_STATUS                (FH39_RSSR_TBL + 0x004)
553
554 /* TCSR */
555 #define FH39_TCSR(_ch)                  (FH39_TCSR_TBL + (_ch) * 0x20)
556 #define FH39_TCSR_CONFIG(_ch)           (FH39_TCSR(_ch) + 0x00)
557 #define FH39_TCSR_CREDIT(_ch)           (FH39_TCSR(_ch) + 0x04)
558 #define FH39_TCSR_BUFF_STTS(_ch)        (FH39_TCSR(_ch) + 0x08)
559
560 /* TSSR */
561 #define FH39_TSSR_CBB_BASE        (FH39_TSSR_TBL + 0x000)
562 #define FH39_TSSR_MSG_CONFIG      (FH39_TSSR_TBL + 0x008)
563 #define FH39_TSSR_TX_STATUS       (FH39_TSSR_TBL + 0x010)
564
565
566 /* DBM */
567
568 #define FH39_SRVC_CHNL                            (6)
569
570 #define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE     (20)
571 #define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH      (4)
572
573 #define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN    (0x08000000)
574
575 #define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE        (0x80000000)
576
577 #define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE           (0x20000000)
578
579 #define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128           (0x01000000)
580
581 #define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST           (0x00001000)
582
583 #define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH                 (0x00000000)
584
585 #define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF                (0x00000000)
586 #define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER             (0x00000001)
587
588 #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL      (0x00000000)
589 #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL       (0x00000008)
590
591 #define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD             (0x00200000)
592
593 #define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT              (0x00000000)
594
595 #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE              (0x00000000)
596 #define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE             (0x80000000)
597
598 #define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID            (0x00004000)
599
600 #define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR             (0x00000001)
601
602 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON        (0xFF000000)
603 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON        (0x00FF0000)
604
605 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B      (0x00000400)
606
607 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON         (0x00000100)
608 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON         (0x00000080)
609
610 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH       (0x00000020)
611 #define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH             (0x00000005)
612
613 #define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch)     (BIT(_ch) << 24)
614 #define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch)    (BIT(_ch) << 16)
615
616 #define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \
617         (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \
618          FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch))
619
620 #define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE                     (0x01000000)
621
622 struct il3945_tfd_tb {
623         __le32 addr;
624         __le32 len;
625 } __packed;
626
627 struct il3945_tfd {
628         __le32 control_flags;
629         struct il3945_tfd_tb tbs[4];
630         u8 __pad[28];
631 } __packed;
632
633 #ifdef CONFIG_IWLEGACY_DEBUGFS
634 ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf,
635                                     size_t count, loff_t *ppos);
636 ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf,
637                                     size_t count, loff_t *ppos);
638 ssize_t il3945_ucode_general_stats_read(struct file *file,
639                                          char __user *user_buf, size_t count,
640                                          loff_t *ppos);
641 #else
642 static ssize_t il3945_ucode_rx_stats_read(struct file *file,
643                                            char __user *user_buf, size_t count,
644                                            loff_t *ppos)
645 {
646         return 0;
647 }
648 static ssize_t il3945_ucode_tx_stats_read(struct file *file,
649                                            char __user *user_buf, size_t count,
650                                            loff_t *ppos)
651 {
652         return 0;
653 }
654 static ssize_t il3945_ucode_general_stats_read(struct file *file,
655                                                 char __user *user_buf,
656                                                 size_t count, loff_t *ppos)
657 {
658         return 0;
659 }
660 #endif
661
662 /* Requires full declaration of il_priv before including */
663 #include "iwl-io.h"
664
665 #endif