Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
wlcore.h
Go to the documentation of this file.
1 /*
2  * This file is part of wlcore
3  *
4  * Copyright (C) 2011 Texas Instruments Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA
19  *
20  */
21 
22 #ifndef __WLCORE_H__
23 #define __WLCORE_H__
24 
25 #include <linux/platform_device.h>
26 
27 #include "wlcore_i.h"
28 #include "event.h"
29 #include "boot.h"
30 
31 /* The maximum number of Tx descriptors in all chip families */
32 #define WLCORE_MAX_TX_DESCRIPTORS 32
33 
34 /*
35  * We always allocate this number of mac addresses. If we don't
36  * have enough allocated addresses, the LAA bit is used
37  */
38 #define WLCORE_NUM_MAC_ADDRESSES 3
39 
40 /* forward declaration */
41 struct wl1271_tx_hw_descr;
42 enum wl_rx_buf_align;
44 
45 struct wlcore_ops {
46  int (*setup)(struct wl1271 *wl);
47  int (*identify_chip)(struct wl1271 *wl);
48  int (*identify_fw)(struct wl1271 *wl);
49  int (*boot)(struct wl1271 *wl);
50  int (*plt_init)(struct wl1271 *wl);
51  int (*trigger_cmd)(struct wl1271 *wl, int cmd_box_addr,
52  void *buf, size_t len);
53  int (*ack_event)(struct wl1271 *wl);
54  u32 (*calc_tx_blocks)(struct wl1271 *wl, u32 len, u32 spare_blks);
56  struct wl1271_tx_hw_descr *desc,
57  u32 blks, u32 spare_blks);
59  struct wl1271_tx_hw_descr *desc,
60  struct sk_buff *skb);
62  u32 rx_desc);
63  int (*prepare_read)(struct wl1271 *wl, u32 rx_desc, u32 len);
64  u32 (*get_rx_packet_len)(struct wl1271 *wl, void *rx_data,
65  u32 data_len);
66  int (*tx_delayed_compl)(struct wl1271 *wl);
67  void (*tx_immediate_compl)(struct wl1271 *wl);
68  int (*hw_init)(struct wl1271 *wl);
69  int (*init_vif)(struct wl1271 *wl, struct wl12xx_vif *wlvif);
71  struct wl12xx_vif *wlvif);
72  int (*get_pg_ver)(struct wl1271 *wl, s8 *ver);
73  int (*get_mac)(struct wl1271 *wl);
74  void (*set_tx_desc_csum)(struct wl1271 *wl,
75  struct wl1271_tx_hw_descr *desc,
76  struct sk_buff *skb);
77  void (*set_rx_csum)(struct wl1271 *wl,
78  struct wl1271_rx_descriptor *desc,
79  struct sk_buff *skb);
81  struct wl12xx_vif *wlvif);
82  int (*debugfs_init)(struct wl1271 *wl, struct dentry *rootdir);
83  int (*handle_static_data)(struct wl1271 *wl,
84  struct wl1271_static_data *static_data);
85  int (*get_spare_blocks)(struct wl1271 *wl, bool is_gem);
86  int (*set_key)(struct wl1271 *wl, enum set_key_cmd cmd,
87  struct ieee80211_vif *vif,
88  struct ieee80211_sta *sta,
89  struct ieee80211_key_conf *key_conf);
90  u32 (*pre_pkt_send)(struct wl1271 *wl, u32 buf_offset, u32 last_len);
91 };
92 
100 
102 };
103 
107 };
108 
114 };
115 
117  /* register addresses, used with partition translation */
128 
129  /* data access memory addresses, used with partition translation */
132 
133  /* raw data access memory addresses */
135 
137 };
138 
139 struct wl1271_stats {
140  void *fw_stats;
141  unsigned long fw_stats_update;
142  size_t fw_stats_len;
143 
144  unsigned int retry_count;
145  unsigned int excessive_retries;
146 };
147 
148 struct wl1271 {
150  struct ieee80211_hw *hw;
152 
153  struct device *dev;
155 
156  void *if_priv;
157 
159 
161  int irq;
162 
164 
167  bool plt;
171  struct mutex mutex;
172 
173  unsigned long flags;
174 
176 
178 
180 
181  u8 *fw;
182  size_t fw_len;
183  void *nvs;
184  size_t nvs_len;
185 
187 
188  /* address read from the fuse ROM */
191 
192  /* we have up to 2 MAC addresses */
194  int channel;
196 
200  unsigned long rate_policies_map[
202  unsigned long klv_templates_map[
204 
206 
209 
211 
212  /* Accounting for allocated / available TX blocks on HW */
217 
218  /* Accounting for allocated / available Tx packets in HW */
221 
222  /* Transmitted TX packets counter for chipset interface */
224 
225  /* Time-offset between host and chipset clocks */
227 
228  /* Frames scheduled for transmission, not handled yet */
231 
232  /* Frames received, not handled yet by mac80211 */
234 
235  /* Frames sent, not returned yet to mac80211 */
237 
240 
241  /* Pending TX frames */
245 
246  /* FW Rx counter */
248 
249  /* Intermediate buffer, used for packet aggregation */
252 
253  /* Reusable dummy packet template */
255 
256  /* Network stack work */
258 
259  /* FW log buffer */
261 
262  /* Number of valid bytes in the FW log buffer */
264 
265  /* Sysfs FW log entry readers wait queue */
267 
268  /* Hardware recovery work */
271 
272  /* Pointer that holds DMA-friendly block for the mailbox */
274 
275  /* The mbox event mask */
277 
278  /* Mailbox pointers */
280 
281  /* Are we currently scanning */
285 
286  /* Connection loss work */
288 
290 
291  /* The current band */
293 
296 
297  /* in dBm */
299 
301 
305 
309 
310  /* Current chipset configuration */
312 
314 
316 
317  /* Most recently reported noise in dBm */
319 
320  /* bands supported by this instance of wl12xx */
322 
323  /*
324  * wowlan trigger was configured during suspend.
325  * (currently, only "ANY" trigger is supported)
326  */
329 
330  /*
331  * AP-mode - links indexed by HLID. The global and broadcast links
332  * are always active.
333  */
335 
336  /* AP-mode - a bitmap of links currently in PS mode according to FW */
338 
339  /* AP-mode - a bitmap of links currently in PS mode in mac80211 */
340  unsigned long ap_ps_map;
341 
342  /* Quirks of specific hardware revisions */
343  unsigned int quirks;
344 
345  /* Platform limitations */
346  unsigned int platform_quirks;
347 
348  /* number of currently active RX BA sessions */
350 
351  /* AP-mode - number of currently connected stations */
353 
354  /* last wlvif we transmitted from */
356 
357  /* work to fire when Tx is stuck */
359 
360  struct wlcore_ops *ops;
361  /* pointer to the lower driver partition table */
363  /* pointer to the lower driver register table */
364  const int *rtable;
365  /* name of the firmwares to load - for PLT, single role, multi-role */
366  const char *plt_fw_name;
367  const char *sr_fw_name;
368  const char *mr_fw_name;
369 
370  /* per-chip-family private structure */
371  void *priv;
372 
373  /* number of TX descriptors the HW supports. */
375  /* number of RX descriptors the HW supports. */
377 
378  /* translate HW Tx rates to standard rate-indices */
380 
381  /* size of table for HW rates that can be received from chip */
383 
384  /* this HW rate and below are considered HT rates for this chip */
386 
387  /* HW HT (11n) capabilities */
389 
390  /* size of the private FW status data */
392 
393  /* RX Data filter rule state - enabled/disabled */
395 
396  /* size of the private static data */
398 
399  /* the current channel type */
401 
402  /* mutex for protecting the tx_flush function */
404 
405  /* sleep auth value currently configured to FW */
407 
408  /* the number of allocated MAC addresses in this chip */
410 
411  /* the minimum FW version required for the driver to work */
412  unsigned int min_fw_ver[NUM_FW_VER];
413 
415 };
416 
417 int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev);
418 int __devexit wlcore_remove(struct platform_device *pdev);
419 struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size, u32 aggr_buf_size);
420 int wlcore_free_hw(struct wl1271 *wl);
421 int wlcore_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
422  struct ieee80211_vif *vif,
423  struct ieee80211_sta *sta,
424  struct ieee80211_key_conf *key_conf);
425 
426 static inline void
427 wlcore_set_ht_cap(struct wl1271 *wl, enum ieee80211_band band,
428  struct ieee80211_sta_ht_cap *ht_cap)
429 {
430  memcpy(&wl->ht_cap[band], ht_cap, sizeof(*ht_cap));
431 }
432 
433 static inline void
434 wlcore_set_min_fw_ver(struct wl1271 *wl, unsigned int chip,
435  unsigned int iftype, unsigned int major,
436  unsigned int subtype, unsigned int minor)
437 {
438  wl->min_fw_ver[FW_VER_CHIP] = chip;
440  wl->min_fw_ver[FW_VER_MAJOR] = major;
442  wl->min_fw_ver[FW_VER_MINOR] = minor;
443 }
444 
445 /* Firmware image load chunk size */
446 #define CHUNK_SIZE 16384
447 
448 /* Quirks */
449 
450 /* Each RX/TX transaction requires an end-of-transaction transfer */
451 #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0)
452 
453 /* wl127x and SPI don't support SDIO block size alignment */
454 #define WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN BIT(2)
455 
456 /* means aggregated Rx packets are aligned to a SDIO block */
457 #define WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN BIT(3)
458 
459 /* Older firmwares did not implement the FW logger over bus feature */
460 #define WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4)
461 
462 /* Older firmwares use an old NVS format */
463 #define WLCORE_QUIRK_LEGACY_NVS BIT(5)
464 
465 /* Some firmwares may not support ELP */
466 #define WLCORE_QUIRK_NO_ELP BIT(6)
467 
468 /* pad only the last frame in the aggregate buffer */
469 #define WLCORE_QUIRK_TX_PAD_LAST_FRAME BIT(7)
470 
471 /* extra header space is required for TKIP */
472 #define WLCORE_QUIRK_TKIP_HEADER_SPACE BIT(8)
473 
474 /* Some firmwares not support sched scans while connected */
475 #define WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN BIT(9)
476 
477 /* separate probe response templates for one-shot and sched scans */
478 #define WLCORE_QUIRK_DUAL_PROBE_TMPL BIT(10)
479 
480 /* TODO: move to the lower drivers when all usages are abstracted */
481 #define CHIP_ID_1271_PG10 (0x4030101)
482 #define CHIP_ID_1271_PG20 (0x4030111)
483 #define CHIP_ID_1283_PG10 (0x05030101)
484 #define CHIP_ID_1283_PG20 (0x05030111)
485 
486 /* TODO: move all these common registers and values elsewhere */
487 #define HW_ACCESS_ELP_CTRL_REG 0x1FFFC
488 
489 /* ELP register commands */
490 #define ELPCTRL_WAKE_UP 0x1
491 #define ELPCTRL_WAKE_UP_WLAN_READY 0x5
492 #define ELPCTRL_SLEEP 0x0
493 /* ELP WLAN_READY bit */
494 #define ELPCTRL_WLAN_READY 0x2
495 
496 /*************************************************************************
497 
498  Interrupt Trigger Register (Host -> WiLink)
499 
500 **************************************************************************/
501 
502 /* Hardware to Embedded CPU Interrupts - first 32-bit register set */
503 
504 /*
505  * The host sets this bit to inform the Wlan
506  * FW that a TX packet is in the XFER
507  * Buffer #0.
508  */
509 #define INTR_TRIG_TX_PROC0 BIT(2)
510 
511 /*
512  * The host sets this bit to inform the FW
513  * that it read a packet from RX XFER
514  * Buffer #0.
515  */
516 #define INTR_TRIG_RX_PROC0 BIT(3)
517 
518 #define INTR_TRIG_DEBUG_ACK BIT(4)
519 
520 #define INTR_TRIG_STATE_CHANGED BIT(5)
521 
522 /* Hardware to Embedded CPU Interrupts - second 32-bit register set */
523 
524 /*
525  * The host sets this bit to inform the FW
526  * that it read a packet from RX XFER
527  * Buffer #1.
528  */
529 #define INTR_TRIG_RX_PROC1 BIT(17)
530 
531 /*
532  * The host sets this bit to inform the Wlan
533  * hardware that a TX packet is in the XFER
534  * Buffer #1.
535  */
536 #define INTR_TRIG_TX_PROC1 BIT(18)
537 
538 #define ACX_SLV_SOFT_RESET_BIT BIT(1)
539 #define SOFT_RESET_MAX_TIME 1000000
540 #define SOFT_RESET_STALL_TIME 1000
541 
542 #define ECPU_CONTROL_HALT 0x00000101
543 
544 #define WELP_ARM_COMMAND_VAL 0x4
545 
546 #endif /* __WLCORE_H__ */