]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/wireless/wl12xx/wl1271.h
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[net-next-2.6.git] / drivers / net / wireless / wl12xx / wl1271.h
CommitLineData
f5fc0f86
LC
1/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 1998-2009 Texas Instruments. All rights reserved.
5 * Copyright (C) 2008-2009 Nokia Corporation
6 *
7 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __WL1271_H__
26#define __WL1271_H__
27
28#include <linux/mutex.h>
29#include <linux/completion.h>
30#include <linux/spinlock.h>
31#include <linux/list.h>
32#include <linux/bitops.h>
33#include <net/mac80211.h>
34
2b60100b 35#include "wl1271_conf.h"
eb70eb72 36#include "wl1271_ini.h"
2b60100b 37
f5fc0f86
LC
38#define DRIVER_NAME "wl1271"
39#define DRIVER_PREFIX DRIVER_NAME ": "
40
41enum {
42 DEBUG_NONE = 0,
43 DEBUG_IRQ = BIT(0),
44 DEBUG_SPI = BIT(1),
45 DEBUG_BOOT = BIT(2),
46 DEBUG_MAILBOX = BIT(3),
c8c90873 47 DEBUG_TESTMODE = BIT(4),
f5fc0f86
LC
48 DEBUG_EVENT = BIT(5),
49 DEBUG_TX = BIT(6),
50 DEBUG_RX = BIT(7),
51 DEBUG_SCAN = BIT(8),
52 DEBUG_CRYPT = BIT(9),
53 DEBUG_PSM = BIT(10),
54 DEBUG_MAC80211 = BIT(11),
55 DEBUG_CMD = BIT(12),
56 DEBUG_ACX = BIT(13),
a3b8ea75 57 DEBUG_SDIO = BIT(14),
14b228a0 58 DEBUG_FILTERS = BIT(15),
5da11dcd 59 DEBUG_ADHOC = BIT(16),
f5fc0f86
LC
60 DEBUG_ALL = ~0,
61};
62
63#define DEBUG_LEVEL (DEBUG_NONE)
64
65#define DEBUG_DUMP_LIMIT 1024
66
67#define wl1271_error(fmt, arg...) \
68 printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
69
70#define wl1271_warning(fmt, arg...) \
71 printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
72
73#define wl1271_notice(fmt, arg...) \
74 printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg)
75
76#define wl1271_info(fmt, arg...) \
77 printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg)
78
79#define wl1271_debug(level, fmt, arg...) \
80 do { \
81 if (level & DEBUG_LEVEL) \
82 printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \
83 } while (0)
84
85#define wl1271_dump(level, prefix, buf, len) \
86 do { \
87 if (level & DEBUG_LEVEL) \
88 print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
89 DUMP_PREFIX_OFFSET, 16, 1, \
90 buf, \
91 min_t(size_t, len, DEBUG_DUMP_LIMIT), \
92 0); \
93 } while (0)
94
95#define wl1271_dump_ascii(level, prefix, buf, len) \
96 do { \
97 if (level & DEBUG_LEVEL) \
98 print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
99 DUMP_PREFIX_OFFSET, 16, 1, \
100 buf, \
101 min_t(size_t, len, DEBUG_DUMP_LIMIT), \
102 true); \
103 } while (0)
104
105#define WL1271_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \
c87dec9f
JO
106 CFG_BSSID_FILTER_EN | \
107 CFG_MC_FILTER_EN)
f5fc0f86
LC
108
109#define WL1271_DEFAULT_RX_FILTER (CFG_RX_RCTS_ACK | CFG_RX_PRSP_EN | \
110 CFG_RX_MGMT_EN | CFG_RX_DATA_EN | \
111 CFG_RX_CTL_EN | CFG_RX_BCN_EN | \
112 CFG_RX_AUTH_EN | CFG_RX_ASSOC_EN)
113
114#define WL1271_FW_NAME "wl1271-fw.bin"
115#define WL1271_NVS_NAME "wl1271-nvs.bin"
152ee6e0 116
04e36fc5
JO
117#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
118#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
119
1ebec3d7
TP
120/*
121 * Enable/disable 802.11a support for WL1273
122 */
123#undef WL1271_80211A_ENABLED
124
259da430 125#define WL1271_BUSY_WORD_CNT 1
545f1da8 126#define WL1271_BUSY_WORD_LEN (WL1271_BUSY_WORD_CNT * sizeof(u32))
f5fc0f86
LC
127
128#define WL1271_ELP_HW_STATE_ASLEEP 0
129#define WL1271_ELP_HW_STATE_IRQ 1
130
d94cd297
JO
131#define WL1271_DEFAULT_BEACON_INT 100
132#define WL1271_DEFAULT_DTIM_PERIOD 1
133
c87dec9f 134#define ACX_TX_DESCRIPTORS 32
be7078c2 135
f5fc0f86
LC
136enum wl1271_state {
137 WL1271_STATE_OFF,
138 WL1271_STATE_ON,
139 WL1271_STATE_PLT,
140};
141
142enum wl1271_partition_type {
143 PART_DOWN,
144 PART_WORK,
145 PART_DRPW,
146
147 PART_TABLE_LEN
148};
149
150struct wl1271_partition {
151 u32 size;
152 u32 start;
153};
154
155struct wl1271_partition_set {
156 struct wl1271_partition mem;
157 struct wl1271_partition reg;
451de97a
JO
158 struct wl1271_partition mem2;
159 struct wl1271_partition mem3;
f5fc0f86
LC
160};
161
162struct wl1271;
163
164/* FIXME: I'm not sure about this structure name */
165struct wl1271_chip {
166 u32 id;
167 char fw_ver[21];
168};
169
170struct wl1271_stats {
171 struct acx_statistics *fw_stats;
172 unsigned long fw_stats_update;
173
174 unsigned int retry_count;
175 unsigned int excessive_retries;
176};
177
178struct wl1271_debugfs {
179 struct dentry *rootdir;
180 struct dentry *fw_statistics;
181
182 struct dentry *tx_internal_desc_overflow;
183
184 struct dentry *rx_out_of_mem;
185 struct dentry *rx_hdr_overflow;
186 struct dentry *rx_hw_stuck;
187 struct dentry *rx_dropped;
188 struct dentry *rx_fcs_err;
189 struct dentry *rx_xfr_hint_trig;
190 struct dentry *rx_path_reset;
191 struct dentry *rx_reset_counter;
192
193 struct dentry *dma_rx_requested;
194 struct dentry *dma_rx_errors;
195 struct dentry *dma_tx_requested;
196 struct dentry *dma_tx_errors;
197
198 struct dentry *isr_cmd_cmplt;
199 struct dentry *isr_fiqs;
200 struct dentry *isr_rx_headers;
201 struct dentry *isr_rx_mem_overflow;
202 struct dentry *isr_rx_rdys;
203 struct dentry *isr_irqs;
204 struct dentry *isr_tx_procs;
205 struct dentry *isr_decrypt_done;
206 struct dentry *isr_dma0_done;
207 struct dentry *isr_dma1_done;
208 struct dentry *isr_tx_exch_complete;
209 struct dentry *isr_commands;
210 struct dentry *isr_rx_procs;
211 struct dentry *isr_hw_pm_mode_changes;
212 struct dentry *isr_host_acknowledges;
213 struct dentry *isr_pci_pm;
214 struct dentry *isr_wakeups;
215 struct dentry *isr_low_rssi;
216
217 struct dentry *wep_addr_key_count;
218 struct dentry *wep_default_key_count;
219 /* skipping wep.reserved */
220 struct dentry *wep_key_not_found;
221 struct dentry *wep_decrypt_fail;
222 struct dentry *wep_packets;
223 struct dentry *wep_interrupt;
224
225 struct dentry *pwr_ps_enter;
226 struct dentry *pwr_elp_enter;
227 struct dentry *pwr_missing_bcns;
228 struct dentry *pwr_wake_on_host;
229 struct dentry *pwr_wake_on_timer_exp;
230 struct dentry *pwr_tx_with_ps;
231 struct dentry *pwr_tx_without_ps;
232 struct dentry *pwr_rcvd_beacons;
233 struct dentry *pwr_power_save_off;
234 struct dentry *pwr_enable_ps;
235 struct dentry *pwr_disable_ps;
236 struct dentry *pwr_fix_tsf_ps;
237 /* skipping cont_miss_bcns_spread for now */
238 struct dentry *pwr_rcvd_awake_beacons;
239
240 struct dentry *mic_rx_pkts;
241 struct dentry *mic_calc_failure;
242
243 struct dentry *aes_encrypt_fail;
244 struct dentry *aes_decrypt_fail;
245 struct dentry *aes_encrypt_packets;
246 struct dentry *aes_decrypt_packets;
247 struct dentry *aes_encrypt_interrupt;
248 struct dentry *aes_decrypt_interrupt;
249
250 struct dentry *event_heart_beat;
251 struct dentry *event_calibration;
252 struct dentry *event_rx_mismatch;
253 struct dentry *event_rx_mem_empty;
254 struct dentry *event_rx_pool;
255 struct dentry *event_oom_late;
256 struct dentry *event_phy_transmit_error;
257 struct dentry *event_tx_stuck;
258
259 struct dentry *ps_pspoll_timeouts;
260 struct dentry *ps_upsd_timeouts;
261 struct dentry *ps_upsd_max_sptime;
262 struct dentry *ps_upsd_max_apturn;
263 struct dentry *ps_pspoll_max_apturn;
264 struct dentry *ps_pspoll_utilization;
265 struct dentry *ps_upsd_utilization;
266
267 struct dentry *rxpipe_rx_prep_beacon_drop;
268 struct dentry *rxpipe_descr_host_int_trig_rx_data;
269 struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data;
270 struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data;
271 struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data;
272
273 struct dentry *tx_queue_len;
274
275 struct dentry *retry_count;
276 struct dentry *excessive_retries;
98b2a684 277 struct dentry *gpio_power;
f5fc0f86
LC
278};
279
280#define NUM_TX_QUEUES 4
281#define NUM_RX_PKT_DESC 8
282
283/* FW status registers */
284struct wl1271_fw_status {
d0f63b20 285 __le32 intr;
f5fc0f86
LC
286 u8 fw_rx_counter;
287 u8 drv_rx_counter;
288 u8 reserved;
289 u8 tx_results_counter;
d0f63b20
LC
290 __le32 rx_pkt_descs[NUM_RX_PKT_DESC];
291 __le32 tx_released_blks[NUM_TX_QUEUES];
292 __le32 fw_localtime;
293 __le32 padding[2];
ba2d3587 294} __packed;
f5fc0f86
LC
295
296struct wl1271_rx_mem_pool_addr {
297 u32 addr;
298 u32 addr_extra;
299};
300
abb0b3bf 301struct wl1271_scan {
4fb26fa9 302 struct cfg80211_scan_request *req;
08688d6b 303 bool *scanned_ch;
abb0b3bf
TP
304 u8 state;
305 u8 ssid[IW_ESSID_MAX_SIZE+1];
306 size_t ssid_len;
abb0b3bf
TP
307};
308
8197b711
TP
309struct wl1271_if_operations {
310 void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len,
311 bool fixed);
312 void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len,
313 bool fixed);
314 void (*reset)(struct wl1271 *wl);
315 void (*init)(struct wl1271 *wl);
2cc78ff7 316 int (*power)(struct wl1271 *wl, bool enable);
8197b711
TP
317 struct device* (*dev)(struct wl1271 *wl);
318 void (*enable_irq)(struct wl1271 *wl);
319 void (*disable_irq)(struct wl1271 *wl);
320};
321
f5fc0f86 322struct wl1271 {
3b56dd6a 323 struct platform_device *plat_dev;
f5fc0f86
LC
324 struct ieee80211_hw *hw;
325 bool mac80211_registered;
326
8197b711
TP
327 void *if_priv;
328
329 struct wl1271_if_operations *if_ops;
f5fc0f86
LC
330
331 void (*set_power)(bool enable);
332 int irq;
15cea993 333 int ref_clock;
f5fc0f86
LC
334
335 spinlock_t wl_lock;
336
337 enum wl1271_state state;
338 struct mutex mutex;
339
830fb67b
JO
340#define WL1271_FLAG_STA_RATES_CHANGED (0)
341#define WL1271_FLAG_STA_ASSOCIATED (1)
71449f8d
JO
342#define WL1271_FLAG_JOINED (2)
343#define WL1271_FLAG_GPIO_POWER (3)
344#define WL1271_FLAG_TX_QUEUE_STOPPED (4)
08688d6b
LC
345#define WL1271_FLAG_IN_ELP (5)
346#define WL1271_FLAG_PSM (6)
347#define WL1271_FLAG_PSM_REQUESTED (7)
348#define WL1271_FLAG_IRQ_PENDING (8)
349#define WL1271_FLAG_IRQ_RUNNING (9)
350#define WL1271_FLAG_IDLE (10)
351#define WL1271_FLAG_IDLE_REQUESTED (11)
352#define WL1271_FLAG_PSPOLL_FAILURE (12)
830fb67b
JO
353 unsigned long flags;
354
451de97a 355 struct wl1271_partition_set part;
f5fc0f86
LC
356
357 struct wl1271_chip chip;
358
359 int cmd_box_addr;
360 int event_box_addr;
361
362 u8 *fw;
363 size_t fw_len;
152ee6e0 364 struct wl1271_nvs_file *nvs;
f5fc0f86 365
d717fd61
JO
366 s8 hw_pg_ver;
367
f5fc0f86
LC
368 u8 bssid[ETH_ALEN];
369 u8 mac_addr[ETH_ALEN];
370 u8 bss_type;
5da11dcd 371 u8 set_bss_type;
f5fc0f86
LC
372 u8 ssid[IW_ESSID_MAX_SIZE + 1];
373 u8 ssid_len;
f5fc0f86
LC
374 int channel;
375
376 struct wl1271_acx_mem_map *target_mem_map;
377
378 /* Accounting for allocated / available TX blocks on HW */
379 u32 tx_blocks_freed[NUM_TX_QUEUES];
380 u32 tx_blocks_available;
ffb591cd 381 u32 tx_results_count;
f5fc0f86
LC
382
383 /* Transmitted TX packets counter for chipset interface */
ffb591cd 384 u32 tx_packets_count;
f5fc0f86
LC
385
386 /* Time-offset between host and chipset clocks */
ac5e1e39 387 s64 time_offset;
f5fc0f86
LC
388
389 /* Session counter for the chipset */
390 int session_counter;
391
392 /* Frames scheduled for transmission, not handled yet */
393 struct sk_buff_head tx_queue;
f5fc0f86
LC
394
395 struct work_struct tx_work;
c87dec9f 396
f5fc0f86 397 /* Pending TX frames */
be7078c2 398 struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS];
781608c4 399 int tx_frames_cnt;
f5fc0f86 400
ac4e4ce5
JO
401 /* Security sequence number counters */
402 u8 tx_security_last_seq;
04e36fc5 403 s64 tx_security_seq;
ac4e4ce5 404
f5fc0f86
LC
405 /* FW Rx counter */
406 u32 rx_counter;
407
408 /* Rx memory pool address */
409 struct wl1271_rx_mem_pool_addr rx_mem_pool_addr;
410
411 /* The target interrupt mask */
412 struct work_struct irq_work;
413
414 /* The mbox event mask */
415 u32 event_mask;
416
417 /* Mailbox pointers */
418 u32 mbox_ptr[2];
419
420 /* Are we currently scanning */
abb0b3bf 421 struct wl1271_scan scan;
f5fc0f86
LC
422
423 /* Our association ID */
424 u16 aid;
425
d94cd297 426 /* currently configured rate set */
830fb67b 427 u32 sta_rate_set;
d94cd297 428 u32 basic_rate_set;
ebba60c6 429 u32 basic_rate;
830fb67b 430 u32 rate_set;
d94cd297 431
8a5a37a6
JO
432 /* The current band */
433 enum ieee80211_band band;
434
60e84c2e
JO
435 /* Beaconing interval (needed for ad-hoc) */
436 u32 beacon_int;
437
f5fc0f86
LC
438 /* Default key (for WEP) */
439 u32 default_key;
440
14b228a0 441 unsigned int filters;
f5fc0f86
LC
442 unsigned int rx_config;
443 unsigned int rx_filter;
444
f5fc0f86 445 struct completion *elp_compl;
37b70a81 446 struct delayed_work elp_work;
90494a90
JO
447 struct delayed_work pspoll_work;
448
449 /* counter for ps-poll delivery failures */
450 int ps_poll_failures;
f5fc0f86 451
19ad0715
JO
452 /* retry counter for PSM entries */
453 u8 psm_entry_retry;
454
f5fc0f86
LC
455 /* in dBm */
456 int power_level;
457
00236aed
JO
458 int rssi_thold;
459 int last_rssi_event;
460
f5fc0f86
LC
461 struct wl1271_stats stats;
462 struct wl1271_debugfs debugfs;
463
554d7209 464 __le32 buffer_32;
f5fc0f86 465 u32 buffer_cmd;
545f1da8 466 u32 buffer_busyword[WL1271_BUSY_WORD_CNT];
f5fc0f86
LC
467
468 struct wl1271_fw_status *fw_status;
469 struct wl1271_tx_hw_res_if *tx_res_if;
b771eee5
JO
470
471 struct ieee80211_vif *vif;
d6e19d13 472
2b60100b
JO
473 /* Current chipset configuration */
474 struct conf_drv_settings conf;
01c09162 475
7fc3a864
JO
476 bool sg_enabled;
477
01c09162 478 struct list_head list;
ece550d0
JL
479
480 /* Most recently reported noise in dBm */
481 s8 noise;
f5fc0f86
LC
482};
483
484int wl1271_plt_start(struct wl1271 *wl);
485int wl1271_plt_stop(struct wl1271 *wl);
486
487#define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
488
489#define SESSION_COUNTER_MAX 7 /* maximum value for the session counter */
490
491#define WL1271_DEFAULT_POWER_LEVEL 0
492
06f7bc7d
JO
493#define WL1271_TX_QUEUE_LOW_WATERMARK 10
494#define WL1271_TX_QUEUE_HIGH_WATERMARK 25
f5fc0f86 495
01ac17ec
JO
496/* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power
497 on in case is has been shut down shortly before */
498#define WL1271_PRE_POWER_ON_SLEEP 20 /* in miliseconds */
f5fc0f86
LC
499#define WL1271_POWER_ON_SLEEP 200 /* in miliseconds */
500
1ebec3d7
TP
501static inline bool wl1271_11a_enabled(void)
502{
152ee6e0 503 /* FIXME: this could be determined based on the NVS-INI file */
1ebec3d7
TP
504#ifdef WL1271_80211A_ENABLED
505 return true;
506#else
507 return false;
508#endif
509}
510
f5fc0f86 511#endif