Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 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 | |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 35 | #include "wl1271_conf.h" |
| 36 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 37 | #define DRIVER_NAME "wl1271" |
| 38 | #define DRIVER_PREFIX DRIVER_NAME ": " |
| 39 | |
| 40 | enum { |
| 41 | DEBUG_NONE = 0, |
| 42 | DEBUG_IRQ = BIT(0), |
| 43 | DEBUG_SPI = BIT(1), |
| 44 | DEBUG_BOOT = BIT(2), |
| 45 | DEBUG_MAILBOX = BIT(3), |
Kalle Valo | c8c9087 | 2010-02-18 13:25:53 +0200 | [diff] [blame] | 46 | DEBUG_TESTMODE = BIT(4), |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 47 | DEBUG_EVENT = BIT(5), |
| 48 | DEBUG_TX = BIT(6), |
| 49 | DEBUG_RX = BIT(7), |
| 50 | DEBUG_SCAN = BIT(8), |
| 51 | DEBUG_CRYPT = BIT(9), |
| 52 | DEBUG_PSM = BIT(10), |
| 53 | DEBUG_MAC80211 = BIT(11), |
| 54 | DEBUG_CMD = BIT(12), |
| 55 | DEBUG_ACX = BIT(13), |
Teemu Paasikivi | a3b8ea7 | 2010-03-18 12:26:41 +0200 | [diff] [blame] | 56 | DEBUG_SDIO = BIT(14), |
Juuso Oikarinen | 14b228a | 2010-03-18 12:26:43 +0200 | [diff] [blame^] | 57 | DEBUG_FILTERS = BIT(15), |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 58 | DEBUG_ALL = ~0, |
| 59 | }; |
| 60 | |
| 61 | #define DEBUG_LEVEL (DEBUG_NONE) |
| 62 | |
| 63 | #define DEBUG_DUMP_LIMIT 1024 |
| 64 | |
| 65 | #define wl1271_error(fmt, arg...) \ |
| 66 | printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg) |
| 67 | |
| 68 | #define wl1271_warning(fmt, arg...) \ |
| 69 | printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg) |
| 70 | |
| 71 | #define wl1271_notice(fmt, arg...) \ |
| 72 | printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg) |
| 73 | |
| 74 | #define wl1271_info(fmt, arg...) \ |
| 75 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg) |
| 76 | |
| 77 | #define wl1271_debug(level, fmt, arg...) \ |
| 78 | do { \ |
| 79 | if (level & DEBUG_LEVEL) \ |
| 80 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \ |
| 81 | } while (0) |
| 82 | |
| 83 | #define wl1271_dump(level, prefix, buf, len) \ |
| 84 | do { \ |
| 85 | if (level & DEBUG_LEVEL) \ |
| 86 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ |
| 87 | DUMP_PREFIX_OFFSET, 16, 1, \ |
| 88 | buf, \ |
| 89 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ |
| 90 | 0); \ |
| 91 | } while (0) |
| 92 | |
| 93 | #define wl1271_dump_ascii(level, prefix, buf, len) \ |
| 94 | do { \ |
| 95 | if (level & DEBUG_LEVEL) \ |
| 96 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ |
| 97 | DUMP_PREFIX_OFFSET, 16, 1, \ |
| 98 | buf, \ |
| 99 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ |
| 100 | true); \ |
| 101 | } while (0) |
| 102 | |
| 103 | #define WL1271_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \ |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 104 | CFG_BSSID_FILTER_EN | \ |
| 105 | CFG_MC_FILTER_EN) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 106 | |
| 107 | #define WL1271_DEFAULT_RX_FILTER (CFG_RX_RCTS_ACK | CFG_RX_PRSP_EN | \ |
| 108 | CFG_RX_MGMT_EN | CFG_RX_DATA_EN | \ |
| 109 | CFG_RX_CTL_EN | CFG_RX_BCN_EN | \ |
| 110 | CFG_RX_AUTH_EN | CFG_RX_ASSOC_EN) |
| 111 | |
| 112 | #define WL1271_FW_NAME "wl1271-fw.bin" |
| 113 | #define WL1271_NVS_NAME "wl1271-nvs.bin" |
Juuso Oikarinen | 152ee6e | 2010-02-18 13:25:42 +0200 | [diff] [blame] | 114 | |
Juuso Oikarinen | 04e36fc | 2010-02-22 08:38:40 +0200 | [diff] [blame] | 115 | #define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff)) |
| 116 | #define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff)) |
| 117 | |
Juuso Oikarinen | 152ee6e | 2010-02-18 13:25:42 +0200 | [diff] [blame] | 118 | /* NVS data structure */ |
| 119 | #define WL1271_NVS_SECTION_SIZE 468 |
| 120 | |
| 121 | #define WL1271_NVS_GENERAL_PARAMS_SIZE 57 |
| 122 | #define WL1271_NVS_GENERAL_PARAMS_SIZE_PADDED \ |
| 123 | (WL1271_NVS_GENERAL_PARAMS_SIZE + 1) |
| 124 | #define WL1271_NVS_STAT_RADIO_PARAMS_SIZE 17 |
| 125 | #define WL1271_NVS_STAT_RADIO_PARAMS_SIZE_PADDED \ |
| 126 | (WL1271_NVS_STAT_RADIO_PARAMS_SIZE + 1) |
| 127 | #define WL1271_NVS_DYN_RADIO_PARAMS_SIZE 65 |
| 128 | #define WL1271_NVS_DYN_RADIO_PARAMS_SIZE_PADDED \ |
| 129 | (WL1271_NVS_DYN_RADIO_PARAMS_SIZE + 1) |
| 130 | #define WL1271_NVS_FEM_COUNT 2 |
| 131 | #define WL1271_NVS_INI_SPARE_SIZE 124 |
| 132 | |
| 133 | struct wl1271_nvs_file { |
| 134 | /* NVS section */ |
| 135 | u8 nvs[WL1271_NVS_SECTION_SIZE]; |
| 136 | |
| 137 | /* INI section */ |
| 138 | u8 general_params[WL1271_NVS_GENERAL_PARAMS_SIZE_PADDED]; |
| 139 | u8 stat_radio_params[WL1271_NVS_STAT_RADIO_PARAMS_SIZE_PADDED]; |
| 140 | u8 dyn_radio_params[WL1271_NVS_FEM_COUNT] |
| 141 | [WL1271_NVS_DYN_RADIO_PARAMS_SIZE_PADDED]; |
| 142 | u8 ini_spare[WL1271_NVS_INI_SPARE_SIZE]; |
| 143 | } __attribute__ ((packed)); |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 144 | |
Juuso Oikarinen | 545f1da | 2009-10-08 21:56:23 +0300 | [diff] [blame] | 145 | /* |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 146 | * Enable/disable 802.11a support for WL1273 |
| 147 | */ |
| 148 | #undef WL1271_80211A_ENABLED |
| 149 | |
| 150 | /* |
Juuso Oikarinen | 545f1da | 2009-10-08 21:56:23 +0300 | [diff] [blame] | 151 | * FIXME: for the wl1271, a busy word count of 1 here will result in a more |
| 152 | * optimal SPI interface. There is some SPI bug however, causing RXS time outs |
Juuso Oikarinen | c6d5d06 | 2009-10-13 12:47:47 +0300 | [diff] [blame] | 153 | * with this mode occasionally on boot, so lets have three for now. A value of |
| 154 | * three should make sure, that the chipset will always be ready, though this |
| 155 | * will impact throughput and latencies slightly. |
Juuso Oikarinen | 545f1da | 2009-10-08 21:56:23 +0300 | [diff] [blame] | 156 | */ |
Juuso Oikarinen | c6d5d06 | 2009-10-13 12:47:47 +0300 | [diff] [blame] | 157 | #define WL1271_BUSY_WORD_CNT 3 |
Juuso Oikarinen | 545f1da | 2009-10-08 21:56:23 +0300 | [diff] [blame] | 158 | #define WL1271_BUSY_WORD_LEN (WL1271_BUSY_WORD_CNT * sizeof(u32)) |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 159 | |
| 160 | #define WL1271_ELP_HW_STATE_ASLEEP 0 |
| 161 | #define WL1271_ELP_HW_STATE_IRQ 1 |
| 162 | |
Juuso Oikarinen | d94cd29 | 2009-10-08 21:56:25 +0300 | [diff] [blame] | 163 | #define WL1271_DEFAULT_BEACON_INT 100 |
| 164 | #define WL1271_DEFAULT_DTIM_PERIOD 1 |
| 165 | |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 166 | #define ACX_TX_DESCRIPTORS 32 |
Juuso Oikarinen | be7078c | 2009-10-08 21:56:26 +0300 | [diff] [blame] | 167 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 168 | enum wl1271_state { |
| 169 | WL1271_STATE_OFF, |
| 170 | WL1271_STATE_ON, |
| 171 | WL1271_STATE_PLT, |
| 172 | }; |
| 173 | |
| 174 | enum wl1271_partition_type { |
| 175 | PART_DOWN, |
| 176 | PART_WORK, |
| 177 | PART_DRPW, |
| 178 | |
| 179 | PART_TABLE_LEN |
| 180 | }; |
| 181 | |
| 182 | struct wl1271_partition { |
| 183 | u32 size; |
| 184 | u32 start; |
| 185 | }; |
| 186 | |
| 187 | struct wl1271_partition_set { |
| 188 | struct wl1271_partition mem; |
| 189 | struct wl1271_partition reg; |
Juuso Oikarinen | 451de97 | 2009-10-12 15:08:46 +0300 | [diff] [blame] | 190 | struct wl1271_partition mem2; |
| 191 | struct wl1271_partition mem3; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | struct wl1271; |
| 195 | |
| 196 | /* FIXME: I'm not sure about this structure name */ |
| 197 | struct wl1271_chip { |
| 198 | u32 id; |
| 199 | char fw_ver[21]; |
| 200 | }; |
| 201 | |
| 202 | struct wl1271_stats { |
| 203 | struct acx_statistics *fw_stats; |
| 204 | unsigned long fw_stats_update; |
| 205 | |
| 206 | unsigned int retry_count; |
| 207 | unsigned int excessive_retries; |
| 208 | }; |
| 209 | |
| 210 | struct wl1271_debugfs { |
| 211 | struct dentry *rootdir; |
| 212 | struct dentry *fw_statistics; |
| 213 | |
| 214 | struct dentry *tx_internal_desc_overflow; |
| 215 | |
| 216 | struct dentry *rx_out_of_mem; |
| 217 | struct dentry *rx_hdr_overflow; |
| 218 | struct dentry *rx_hw_stuck; |
| 219 | struct dentry *rx_dropped; |
| 220 | struct dentry *rx_fcs_err; |
| 221 | struct dentry *rx_xfr_hint_trig; |
| 222 | struct dentry *rx_path_reset; |
| 223 | struct dentry *rx_reset_counter; |
| 224 | |
| 225 | struct dentry *dma_rx_requested; |
| 226 | struct dentry *dma_rx_errors; |
| 227 | struct dentry *dma_tx_requested; |
| 228 | struct dentry *dma_tx_errors; |
| 229 | |
| 230 | struct dentry *isr_cmd_cmplt; |
| 231 | struct dentry *isr_fiqs; |
| 232 | struct dentry *isr_rx_headers; |
| 233 | struct dentry *isr_rx_mem_overflow; |
| 234 | struct dentry *isr_rx_rdys; |
| 235 | struct dentry *isr_irqs; |
| 236 | struct dentry *isr_tx_procs; |
| 237 | struct dentry *isr_decrypt_done; |
| 238 | struct dentry *isr_dma0_done; |
| 239 | struct dentry *isr_dma1_done; |
| 240 | struct dentry *isr_tx_exch_complete; |
| 241 | struct dentry *isr_commands; |
| 242 | struct dentry *isr_rx_procs; |
| 243 | struct dentry *isr_hw_pm_mode_changes; |
| 244 | struct dentry *isr_host_acknowledges; |
| 245 | struct dentry *isr_pci_pm; |
| 246 | struct dentry *isr_wakeups; |
| 247 | struct dentry *isr_low_rssi; |
| 248 | |
| 249 | struct dentry *wep_addr_key_count; |
| 250 | struct dentry *wep_default_key_count; |
| 251 | /* skipping wep.reserved */ |
| 252 | struct dentry *wep_key_not_found; |
| 253 | struct dentry *wep_decrypt_fail; |
| 254 | struct dentry *wep_packets; |
| 255 | struct dentry *wep_interrupt; |
| 256 | |
| 257 | struct dentry *pwr_ps_enter; |
| 258 | struct dentry *pwr_elp_enter; |
| 259 | struct dentry *pwr_missing_bcns; |
| 260 | struct dentry *pwr_wake_on_host; |
| 261 | struct dentry *pwr_wake_on_timer_exp; |
| 262 | struct dentry *pwr_tx_with_ps; |
| 263 | struct dentry *pwr_tx_without_ps; |
| 264 | struct dentry *pwr_rcvd_beacons; |
| 265 | struct dentry *pwr_power_save_off; |
| 266 | struct dentry *pwr_enable_ps; |
| 267 | struct dentry *pwr_disable_ps; |
| 268 | struct dentry *pwr_fix_tsf_ps; |
| 269 | /* skipping cont_miss_bcns_spread for now */ |
| 270 | struct dentry *pwr_rcvd_awake_beacons; |
| 271 | |
| 272 | struct dentry *mic_rx_pkts; |
| 273 | struct dentry *mic_calc_failure; |
| 274 | |
| 275 | struct dentry *aes_encrypt_fail; |
| 276 | struct dentry *aes_decrypt_fail; |
| 277 | struct dentry *aes_encrypt_packets; |
| 278 | struct dentry *aes_decrypt_packets; |
| 279 | struct dentry *aes_encrypt_interrupt; |
| 280 | struct dentry *aes_decrypt_interrupt; |
| 281 | |
| 282 | struct dentry *event_heart_beat; |
| 283 | struct dentry *event_calibration; |
| 284 | struct dentry *event_rx_mismatch; |
| 285 | struct dentry *event_rx_mem_empty; |
| 286 | struct dentry *event_rx_pool; |
| 287 | struct dentry *event_oom_late; |
| 288 | struct dentry *event_phy_transmit_error; |
| 289 | struct dentry *event_tx_stuck; |
| 290 | |
| 291 | struct dentry *ps_pspoll_timeouts; |
| 292 | struct dentry *ps_upsd_timeouts; |
| 293 | struct dentry *ps_upsd_max_sptime; |
| 294 | struct dentry *ps_upsd_max_apturn; |
| 295 | struct dentry *ps_pspoll_max_apturn; |
| 296 | struct dentry *ps_pspoll_utilization; |
| 297 | struct dentry *ps_upsd_utilization; |
| 298 | |
| 299 | struct dentry *rxpipe_rx_prep_beacon_drop; |
| 300 | struct dentry *rxpipe_descr_host_int_trig_rx_data; |
| 301 | struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data; |
| 302 | struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data; |
| 303 | struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data; |
| 304 | |
| 305 | struct dentry *tx_queue_len; |
| 306 | |
| 307 | struct dentry *retry_count; |
| 308 | struct dentry *excessive_retries; |
Luciano Coelho | 98b2a68 | 2009-12-11 15:40:52 +0200 | [diff] [blame] | 309 | struct dentry *gpio_power; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | #define NUM_TX_QUEUES 4 |
| 313 | #define NUM_RX_PKT_DESC 8 |
| 314 | |
| 315 | /* FW status registers */ |
| 316 | struct wl1271_fw_status { |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 317 | __le32 intr; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 318 | u8 fw_rx_counter; |
| 319 | u8 drv_rx_counter; |
| 320 | u8 reserved; |
| 321 | u8 tx_results_counter; |
Luciano Coelho | d0f63b2 | 2009-10-15 10:33:29 +0300 | [diff] [blame] | 322 | __le32 rx_pkt_descs[NUM_RX_PKT_DESC]; |
| 323 | __le32 tx_released_blks[NUM_TX_QUEUES]; |
| 324 | __le32 fw_localtime; |
| 325 | __le32 padding[2]; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 326 | } __attribute__ ((packed)); |
| 327 | |
| 328 | struct wl1271_rx_mem_pool_addr { |
| 329 | u32 addr; |
| 330 | u32 addr_extra; |
| 331 | }; |
| 332 | |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 333 | struct wl1271_scan { |
| 334 | u8 state; |
| 335 | u8 ssid[IW_ESSID_MAX_SIZE+1]; |
| 336 | size_t ssid_len; |
| 337 | u8 active; |
| 338 | u8 high_prio; |
| 339 | u8 probe_requests; |
| 340 | }; |
| 341 | |
Teemu Paasikivi | 8197b71 | 2010-02-22 08:38:23 +0200 | [diff] [blame] | 342 | struct wl1271_if_operations { |
| 343 | void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len, |
| 344 | bool fixed); |
| 345 | void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len, |
| 346 | bool fixed); |
| 347 | void (*reset)(struct wl1271 *wl); |
| 348 | void (*init)(struct wl1271 *wl); |
Teemu Paasikivi | becd551 | 2010-03-18 12:26:27 +0200 | [diff] [blame] | 349 | void (*power)(struct wl1271 *wl, bool enable); |
Teemu Paasikivi | 8197b71 | 2010-02-22 08:38:23 +0200 | [diff] [blame] | 350 | struct device* (*dev)(struct wl1271 *wl); |
| 351 | void (*enable_irq)(struct wl1271 *wl); |
| 352 | void (*disable_irq)(struct wl1271 *wl); |
| 353 | }; |
| 354 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 355 | struct wl1271 { |
| 356 | struct ieee80211_hw *hw; |
| 357 | bool mac80211_registered; |
| 358 | |
Teemu Paasikivi | 8197b71 | 2010-02-22 08:38:23 +0200 | [diff] [blame] | 359 | void *if_priv; |
| 360 | |
| 361 | struct wl1271_if_operations *if_ops; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 362 | |
| 363 | void (*set_power)(bool enable); |
| 364 | int irq; |
| 365 | |
| 366 | spinlock_t wl_lock; |
| 367 | |
| 368 | enum wl1271_state state; |
| 369 | struct mutex mutex; |
| 370 | |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 371 | #define WL1271_FLAG_STA_RATES_CHANGED (0) |
| 372 | #define WL1271_FLAG_STA_ASSOCIATED (1) |
Juuso Oikarinen | 71449f8 | 2009-12-11 15:41:07 +0200 | [diff] [blame] | 373 | #define WL1271_FLAG_JOINED (2) |
| 374 | #define WL1271_FLAG_GPIO_POWER (3) |
| 375 | #define WL1271_FLAG_TX_QUEUE_STOPPED (4) |
| 376 | #define WL1271_FLAG_SCANNING (5) |
| 377 | #define WL1271_FLAG_IN_ELP (6) |
| 378 | #define WL1271_FLAG_PSM (7) |
| 379 | #define WL1271_FLAG_PSM_REQUESTED (8) |
Juuso Oikarinen | 1e73eb6 | 2010-02-22 08:38:37 +0200 | [diff] [blame] | 380 | #define WL1271_FLAG_IRQ_PENDING (9) |
| 381 | #define WL1271_FLAG_IRQ_RUNNING (10) |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 382 | unsigned long flags; |
| 383 | |
Juuso Oikarinen | 451de97 | 2009-10-12 15:08:46 +0300 | [diff] [blame] | 384 | struct wl1271_partition_set part; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 385 | |
| 386 | struct wl1271_chip chip; |
| 387 | |
| 388 | int cmd_box_addr; |
| 389 | int event_box_addr; |
| 390 | |
| 391 | u8 *fw; |
| 392 | size_t fw_len; |
Juuso Oikarinen | 152ee6e | 2010-02-18 13:25:42 +0200 | [diff] [blame] | 393 | struct wl1271_nvs_file *nvs; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 394 | |
| 395 | u8 bssid[ETH_ALEN]; |
| 396 | u8 mac_addr[ETH_ALEN]; |
| 397 | u8 bss_type; |
| 398 | u8 ssid[IW_ESSID_MAX_SIZE + 1]; |
| 399 | u8 ssid_len; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 400 | int channel; |
| 401 | |
| 402 | struct wl1271_acx_mem_map *target_mem_map; |
| 403 | |
| 404 | /* Accounting for allocated / available TX blocks on HW */ |
| 405 | u32 tx_blocks_freed[NUM_TX_QUEUES]; |
| 406 | u32 tx_blocks_available; |
Juuso Oikarinen | ffb591c | 2010-02-22 08:38:31 +0200 | [diff] [blame] | 407 | u32 tx_results_count; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 408 | |
| 409 | /* Transmitted TX packets counter for chipset interface */ |
Juuso Oikarinen | ffb591c | 2010-02-22 08:38:31 +0200 | [diff] [blame] | 410 | u32 tx_packets_count; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 411 | |
| 412 | /* Time-offset between host and chipset clocks */ |
Juuso Oikarinen | ac5e1e3 | 2010-02-22 08:38:38 +0200 | [diff] [blame] | 413 | s64 time_offset; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 414 | |
| 415 | /* Session counter for the chipset */ |
| 416 | int session_counter; |
| 417 | |
| 418 | /* Frames scheduled for transmission, not handled yet */ |
| 419 | struct sk_buff_head tx_queue; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 420 | |
| 421 | struct work_struct tx_work; |
Juuso Oikarinen | c87dec9 | 2009-10-08 21:56:31 +0300 | [diff] [blame] | 422 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 423 | /* Pending TX frames */ |
Juuso Oikarinen | be7078c | 2009-10-08 21:56:26 +0300 | [diff] [blame] | 424 | struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS]; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 425 | |
Juuso Oikarinen | ac4e4ce | 2009-10-08 21:56:19 +0300 | [diff] [blame] | 426 | /* Security sequence number counters */ |
| 427 | u8 tx_security_last_seq; |
Juuso Oikarinen | 04e36fc | 2010-02-22 08:38:40 +0200 | [diff] [blame] | 428 | s64 tx_security_seq; |
Juuso Oikarinen | ac4e4ce | 2009-10-08 21:56:19 +0300 | [diff] [blame] | 429 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 430 | /* FW Rx counter */ |
| 431 | u32 rx_counter; |
| 432 | |
| 433 | /* Rx memory pool address */ |
| 434 | struct wl1271_rx_mem_pool_addr rx_mem_pool_addr; |
| 435 | |
| 436 | /* The target interrupt mask */ |
| 437 | struct work_struct irq_work; |
| 438 | |
| 439 | /* The mbox event mask */ |
| 440 | u32 event_mask; |
| 441 | |
| 442 | /* Mailbox pointers */ |
| 443 | u32 mbox_ptr[2]; |
| 444 | |
| 445 | /* Are we currently scanning */ |
Teemu Paasikivi | abb0b3b | 2009-10-13 12:47:50 +0300 | [diff] [blame] | 446 | struct wl1271_scan scan; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 447 | |
| 448 | /* Our association ID */ |
| 449 | u16 aid; |
| 450 | |
Juuso Oikarinen | d94cd29 | 2009-10-08 21:56:25 +0300 | [diff] [blame] | 451 | /* currently configured rate set */ |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 452 | u32 sta_rate_set; |
Juuso Oikarinen | d94cd29 | 2009-10-08 21:56:25 +0300 | [diff] [blame] | 453 | u32 basic_rate_set; |
Juuso Oikarinen | 830fb67 | 2009-12-11 15:41:06 +0200 | [diff] [blame] | 454 | u32 rate_set; |
Juuso Oikarinen | d94cd29 | 2009-10-08 21:56:25 +0300 | [diff] [blame] | 455 | |
Juuso Oikarinen | 8a5a37a | 2009-10-08 21:56:24 +0300 | [diff] [blame] | 456 | /* The current band */ |
| 457 | enum ieee80211_band band; |
| 458 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 459 | /* Default key (for WEP) */ |
| 460 | u32 default_key; |
| 461 | |
Juuso Oikarinen | 14b228a | 2010-03-18 12:26:43 +0200 | [diff] [blame^] | 462 | unsigned int filters; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 463 | unsigned int rx_config; |
| 464 | unsigned int rx_filter; |
| 465 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 466 | struct completion *elp_compl; |
Juuso Oikarinen | 37b70a8 | 2009-10-08 21:56:21 +0300 | [diff] [blame] | 467 | struct delayed_work elp_work; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 468 | |
Juuso Oikarinen | 19ad071 | 2009-11-02 20:22:11 +0200 | [diff] [blame] | 469 | /* retry counter for PSM entries */ |
| 470 | u8 psm_entry_retry; |
| 471 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 472 | /* in dBm */ |
| 473 | int power_level; |
| 474 | |
| 475 | struct wl1271_stats stats; |
| 476 | struct wl1271_debugfs debugfs; |
| 477 | |
| 478 | u32 buffer_32; |
| 479 | u32 buffer_cmd; |
Juuso Oikarinen | 545f1da | 2009-10-08 21:56:23 +0300 | [diff] [blame] | 480 | u32 buffer_busyword[WL1271_BUSY_WORD_CNT]; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 481 | |
| 482 | struct wl1271_fw_status *fw_status; |
| 483 | struct wl1271_tx_hw_res_if *tx_res_if; |
Juuso Oikarinen | b771eee | 2009-10-08 21:56:34 +0300 | [diff] [blame] | 484 | |
| 485 | struct ieee80211_vif *vif; |
Luciano Coelho | d6e19d13 | 2009-10-12 15:08:43 +0300 | [diff] [blame] | 486 | |
Juuso Oikarinen | 2b60100b | 2009-10-13 12:47:39 +0300 | [diff] [blame] | 487 | /* Current chipset configuration */ |
| 488 | struct conf_drv_settings conf; |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 489 | |
Juuso Oikarinen | 7fc3a86 | 2010-03-18 12:26:32 +0200 | [diff] [blame] | 490 | bool sg_enabled; |
| 491 | |
Juuso Oikarinen | 01c0916 | 2009-10-13 12:47:55 +0300 | [diff] [blame] | 492 | struct list_head list; |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 493 | }; |
| 494 | |
| 495 | int wl1271_plt_start(struct wl1271 *wl); |
| 496 | int wl1271_plt_stop(struct wl1271 *wl); |
| 497 | |
| 498 | #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ |
| 499 | |
| 500 | #define SESSION_COUNTER_MAX 7 /* maximum value for the session counter */ |
| 501 | |
| 502 | #define WL1271_DEFAULT_POWER_LEVEL 0 |
| 503 | |
Juuso Oikarinen | 06f7bc7 | 2010-02-22 08:38:33 +0200 | [diff] [blame] | 504 | #define WL1271_TX_QUEUE_LOW_WATERMARK 10 |
| 505 | #define WL1271_TX_QUEUE_HIGH_WATERMARK 25 |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 506 | |
Juuso Oikarinen | 01ac17e | 2009-12-11 15:41:02 +0200 | [diff] [blame] | 507 | /* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power |
| 508 | on in case is has been shut down shortly before */ |
| 509 | #define WL1271_PRE_POWER_ON_SLEEP 20 /* in miliseconds */ |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 510 | #define WL1271_POWER_ON_SLEEP 200 /* in miliseconds */ |
| 511 | |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 512 | static inline bool wl1271_11a_enabled(void) |
| 513 | { |
Juuso Oikarinen | 152ee6e | 2010-02-18 13:25:42 +0200 | [diff] [blame] | 514 | /* FIXME: this could be determined based on the NVS-INI file */ |
Teemu Paasikivi | 1ebec3d | 2009-10-13 12:47:48 +0300 | [diff] [blame] | 515 | #ifdef WL1271_80211A_ENABLED |
| 516 | return true; |
| 517 | #else |
| 518 | return false; |
| 519 | #endif |
| 520 | } |
| 521 | |
Luciano Coelho | f5fc0f8 | 2009-08-06 16:25:28 +0300 | [diff] [blame] | 522 | #endif |