Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wl1251.h
Go to the documentation of this file.
1 /*
2  * This file is part of wl1251
3  *
4  * Copyright (c) 1998-2007 Texas Instruments Incorporated
5  * Copyright (C) 2008-2009 Nokia Corporation
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * version 2 as 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 St, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  *
21  */
22 
23 #ifndef __WL1251_H__
24 #define __WL1251_H__
25 
26 #include <linux/mutex.h>
27 #include <linux/list.h>
28 #include <linux/bitops.h>
29 #include <net/mac80211.h>
30 
31 #define DRIVER_NAME "wl1251"
32 #define DRIVER_PREFIX DRIVER_NAME ": "
33 
34 enum {
36  DEBUG_IRQ = BIT(0),
37  DEBUG_SPI = BIT(1),
42  DEBUG_TX = BIT(6),
43  DEBUG_RX = BIT(7),
46  DEBUG_PSM = BIT(10),
48  DEBUG_CMD = BIT(12),
49  DEBUG_ACX = BIT(13),
50  DEBUG_ALL = ~0,
51 };
52 
53 #define DEBUG_LEVEL (DEBUG_NONE)
54 
55 #define DEBUG_DUMP_LIMIT 1024
56 
57 #define wl1251_error(fmt, arg...) \
58  printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
59 
60 #define wl1251_warning(fmt, arg...) \
61  printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
62 
63 #define wl1251_notice(fmt, arg...) \
64  printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg)
65 
66 #define wl1251_info(fmt, arg...) \
67  printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg)
68 
69 #define wl1251_debug(level, fmt, arg...) \
70  do { \
71  if (level & DEBUG_LEVEL) \
72  printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \
73  } while (0)
74 
75 #define wl1251_dump(level, prefix, buf, len) \
76  do { \
77  if (level & DEBUG_LEVEL) \
78  print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
79  DUMP_PREFIX_OFFSET, 16, 1, \
80  buf, \
81  min_t(size_t, len, DEBUG_DUMP_LIMIT), \
82  0); \
83  } while (0)
84 
85 #define wl1251_dump_ascii(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  true); \
93  } while (0)
94 
95 #define WL1251_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \
96  CFG_BSSID_FILTER_EN)
97 
98 #define WL1251_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \
99  CFG_RX_MGMT_EN | \
100  CFG_RX_DATA_EN | \
101  CFG_RX_CTL_EN | \
102  CFG_RX_BCN_EN | \
103  CFG_RX_AUTH_EN | \
104  CFG_RX_ASSOC_EN)
105 
106 #define WL1251_BUSY_WORD_LEN 8
107 
108 struct boot_attr {
116 };
117 
122 };
123 
128 
130 };
131 
136 };
137 
141 };
142 
146 };
147 
148 struct wl1251;
149 
150 struct wl1251_stats {
152  unsigned long fw_stats_update;
153 
154  unsigned int retry_count;
155  unsigned int excessive_retries;
156 };
157 
159  struct dentry *rootdir;
161 
163 
172 
177 
179  struct dentry *isr_fiqs;
183  struct dentry *isr_irqs;
196 
199  /* skipping wep.reserved */
204 
217  /* skipping cont_miss_bcns_spread for now */
219 
222 
229 
238 
246 
252 
255 
258 };
259 
261  void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
262  void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
263  void (*read_elp)(struct wl1251 *wl, int addr, u32 *val);
264  void (*write_elp)(struct wl1251 *wl, int addr, u32 val);
265  int (*power)(struct wl1251 *wl, bool enable);
266  void (*reset)(struct wl1251 *wl);
267  void (*enable_irq)(struct wl1251 *wl);
268  void (*disable_irq)(struct wl1251 *wl);
269 };
270 
271 struct wl1251 {
272  struct ieee80211_hw *hw;
274 
275  void *if_priv;
277 
279  int irq;
281 
283 
285  struct mutex mutex;
286 
291 
295 
296  u8 *fw;
297  size_t fw_len;
298  u8 *nvs;
299  size_t nvs_len;
300 
305  int channel;
306 
309 
310  /* Number of TX packets transferred to the FW, modulo 16 */
312 
313  /* Frames scheduled for transmission, not handled yet */
316 
318 
319  /* Pending TX frames */
320  struct sk_buff *tx_frames[16];
321 
322  /*
323  * Index pointing to the next TX complete entry
324  * in the cyclic XT complete array we get from
325  * the FW.
326  */
328 
329  /* FW Rx counter */
331 
332  /* Rx frames handled */
334 
335  /* Current double buffer */
338 
339  /* The target interrupt mask */
342 
343  /* The mbox event mask */
345 
346  /* Mailbox pointers */
348 
349  /* Are we currently scanning */
350  bool scanning;
351 
352  /* Default key (for WEP) */
354 
355  unsigned int tx_mgmt_frm_rate;
356  unsigned int tx_mgmt_frm_mod;
357 
358  unsigned int rx_config;
359  unsigned int rx_filter;
360 
361  /* is firmware in elp mode */
362  bool elp;
363 
365 
367 
368  /* PSM mode requested */
370 
373 
374  /* in dBm */
376 
378 
381 
386 
388 
390  char fw_ver[21];
391 
392  /* Most recently reported noise in dBm */
394 };
395 
396 int wl1251_plt_start(struct wl1251 *wl);
397 int wl1251_plt_stop(struct wl1251 *wl);
398 
399 struct ieee80211_hw *wl1251_alloc_hw(void);
400 int wl1251_free_hw(struct wl1251 *wl);
401 int wl1251_init_ieee80211(struct wl1251 *wl);
402 void wl1251_enable_interrupts(struct wl1251 *wl);
403 void wl1251_disable_interrupts(struct wl1251 *wl);
404 
405 #define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */
406 #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS
407 #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
408 
409 #define WL1251_DEFAULT_POWER_LEVEL 20
410 
411 #define WL1251_TX_QUEUE_LOW_WATERMARK 10
412 #define WL1251_TX_QUEUE_HIGH_WATERMARK 25
413 
414 #define WL1251_DEFAULT_BEACON_INT 100
415 #define WL1251_DEFAULT_DTIM_PERIOD 1
416 
417 #define WL1251_DEFAULT_CHANNEL 0
418 
419 #define WL1251_DEFAULT_BET_CONSECUTIVE 10
420 
421 #define CHIP_ID_1251_PG10 (0x7010101)
422 #define CHIP_ID_1251_PG11 (0x7020101)
423 #define CHIP_ID_1251_PG12 (0x7030101)
424 #define CHIP_ID_1271_PG10 (0x4030101)
425 #define CHIP_ID_1271_PG20 (0x4030111)
426 
427 #define WL1251_FW_NAME "wl1251-fw.bin"
428 #define WL1251_NVS_NAME "wl1251-nvs.bin"
429 
430 #define WL1251_POWER_ON_SLEEP 10 /* in milliseconds */
431 
432 #define WL1251_PART_DOWN_MEM_START 0x0
433 #define WL1251_PART_DOWN_MEM_SIZE 0x16800
434 #define WL1251_PART_DOWN_REG_START REGISTERS_BASE
435 #define WL1251_PART_DOWN_REG_SIZE REGISTERS_DOWN_SIZE
436 
437 #define WL1251_PART_WORK_MEM_START 0x28000
438 #define WL1251_PART_WORK_MEM_SIZE 0x14000
439 #define WL1251_PART_WORK_REG_START REGISTERS_BASE
440 #define WL1251_PART_WORK_REG_SIZE REGISTERS_WORK_SIZE
441 
442 #define WL1251_DEFAULT_LOW_RSSI_WEIGHT 10
443 #define WL1251_DEFAULT_LOW_RSSI_DEPTH 10
444 
445 #endif