wl1271: Idle handling into own function
[pandora-kernel.git] / drivers / net / wireless / wl12xx / wl1271.h
index 97ea509..a170aed 100644 (file)
@@ -33,6 +33,7 @@
 #include <net/mac80211.h>
 
 #include "wl1271_conf.h"
+#include "wl1271_ini.h"
 
 #define DRIVER_NAME "wl1271"
 #define DRIVER_PREFIX DRIVER_NAME ": "
@@ -53,6 +54,9 @@ enum {
        DEBUG_MAC80211  = BIT(11),
        DEBUG_CMD       = BIT(12),
        DEBUG_ACX       = BIT(13),
+       DEBUG_SDIO      = BIT(14),
+       DEBUG_FILTERS   = BIT(15),
+       DEBUG_ADHOC     = BIT(16),
        DEBUG_ALL       = ~0,
 };
 
@@ -110,46 +114,15 @@ enum {
 #define WL1271_FW_NAME "wl1271-fw.bin"
 #define WL1271_NVS_NAME "wl1271-nvs.bin"
 
-/* NVS data structure */
-#define WL1271_NVS_SECTION_SIZE                  468
-
-#define WL1271_NVS_GENERAL_PARAMS_SIZE            57
-#define WL1271_NVS_GENERAL_PARAMS_SIZE_PADDED \
-       (WL1271_NVS_GENERAL_PARAMS_SIZE + 1)
-#define WL1271_NVS_STAT_RADIO_PARAMS_SIZE         17
-#define WL1271_NVS_STAT_RADIO_PARAMS_SIZE_PADDED \
-       (WL1271_NVS_STAT_RADIO_PARAMS_SIZE + 1)
-#define WL1271_NVS_DYN_RADIO_PARAMS_SIZE          65
-#define WL1271_NVS_DYN_RADIO_PARAMS_SIZE_PADDED \
-       (WL1271_NVS_DYN_RADIO_PARAMS_SIZE + 1)
-#define WL1271_NVS_FEM_COUNT                       2
-#define WL1271_NVS_INI_SPARE_SIZE                124
-
-struct wl1271_nvs_file {
-       /* NVS section */
-       u8 nvs[WL1271_NVS_SECTION_SIZE];
-
-       /* INI section */
-       u8 general_params[WL1271_NVS_GENERAL_PARAMS_SIZE_PADDED];
-       u8 stat_radio_params[WL1271_NVS_STAT_RADIO_PARAMS_SIZE_PADDED];
-       u8 dyn_radio_params[WL1271_NVS_FEM_COUNT]
-                          [WL1271_NVS_DYN_RADIO_PARAMS_SIZE_PADDED];
-       u8 ini_spare[WL1271_NVS_INI_SPARE_SIZE];
-} __attribute__ ((packed));
+#define WL1271_TX_SECURITY_LO16(s) ((u16)((s) & 0xffff))
+#define WL1271_TX_SECURITY_HI32(s) ((u32)(((s) >> 16) & 0xffffffff))
 
 /*
  * Enable/disable 802.11a support for WL1273
  */
 #undef WL1271_80211A_ENABLED
 
-/*
- * FIXME: for the wl1271, a busy word count of 1 here will result in a more
- * optimal SPI interface. There is some SPI bug however, causing RXS time outs
- * with this mode occasionally on boot, so lets have three for now. A value of
- * three should make sure, that the chipset will always be ready, though this
- * will impact throughput and latencies slightly.
- */
-#define WL1271_BUSY_WORD_CNT 3
+#define WL1271_BUSY_WORD_CNT 1
 #define WL1271_BUSY_WORD_LEN (WL1271_BUSY_WORD_CNT * sizeof(u32))
 
 #define WL1271_ELP_HW_STATE_ASLEEP 0
@@ -334,11 +307,27 @@ struct wl1271_scan {
        u8 probe_requests;
 };
 
+struct wl1271_if_operations {
+       void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len,
+                    bool fixed);
+       void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len,
+                    bool fixed);
+       void (*reset)(struct wl1271 *wl);
+       void (*init)(struct wl1271 *wl);
+       void (*power)(struct wl1271 *wl, bool enable);
+       struct device* (*dev)(struct wl1271 *wl);
+       void (*enable_irq)(struct wl1271 *wl);
+       void (*disable_irq)(struct wl1271 *wl);
+};
+
 struct wl1271 {
+       struct platform_device *plat_dev;
        struct ieee80211_hw *hw;
        bool mac80211_registered;
 
-       struct spi_device *spi;
+       void *if_priv;
+
+       struct wl1271_if_operations *if_ops;
 
        void (*set_power)(bool enable);
        int irq;
@@ -357,6 +346,10 @@ struct wl1271 {
 #define WL1271_FLAG_IN_ELP             (6)
 #define WL1271_FLAG_PSM                (7)
 #define WL1271_FLAG_PSM_REQUESTED      (8)
+#define WL1271_FLAG_IRQ_PENDING        (9)
+#define WL1271_FLAG_IRQ_RUNNING       (10)
+#define WL1271_FLAG_IDLE              (11)
+#define WL1271_FLAG_IDLE_REQUESTED    (12)
        unsigned long flags;
 
        struct wl1271_partition_set part;
@@ -370,9 +363,12 @@ struct wl1271 {
        size_t fw_len;
        struct wl1271_nvs_file *nvs;
 
+       s8 hw_pg_ver;
+
        u8 bssid[ETH_ALEN];
        u8 mac_addr[ETH_ALEN];
        u8 bss_type;
+       u8 set_bss_type;
        u8 ssid[IW_ESSID_MAX_SIZE + 1];
        u8 ssid_len;
        int channel;
@@ -382,13 +378,13 @@ struct wl1271 {
        /* Accounting for allocated / available TX blocks on HW */
        u32 tx_blocks_freed[NUM_TX_QUEUES];
        u32 tx_blocks_available;
-       u8 tx_results_count;
+       u32 tx_results_count;
 
        /* Transmitted TX packets counter for chipset interface */
-       int tx_packets_count;
+       u32 tx_packets_count;
 
        /* Time-offset between host and chipset clocks */
-       int time_offset;
+       s64 time_offset;
 
        /* Session counter for the chipset */
        int session_counter;
@@ -403,8 +399,7 @@ struct wl1271 {
 
        /* Security sequence number counters */
        u8 tx_security_last_seq;
-       u16 tx_security_seq_16;
-       u32 tx_security_seq_32;
+       s64 tx_security_seq;
 
        /* FW Rx counter */
        u32 rx_counter;
@@ -430,14 +425,19 @@ struct wl1271 {
        /* currently configured rate set */
        u32 sta_rate_set;
        u32 basic_rate_set;
+       u32 basic_rate;
        u32 rate_set;
 
        /* The current band */
        enum ieee80211_band band;
 
+       /* Beaconing interval (needed for ad-hoc) */
+       u32 beacon_int;
+
        /* Default key (for WEP) */
        u32 default_key;
 
+       unsigned int filters;
        unsigned int rx_config;
        unsigned int rx_filter;
 
@@ -450,10 +450,13 @@ struct wl1271 {
        /* in dBm */
        int power_level;
 
+       int rssi_thold;
+       int last_rssi_event;
+
        struct wl1271_stats stats;
        struct wl1271_debugfs debugfs;
 
-       u32 buffer_32;
+       __le32 buffer_32;
        u32 buffer_cmd;
        u32 buffer_busyword[WL1271_BUSY_WORD_CNT];
 
@@ -465,6 +468,8 @@ struct wl1271 {
        /* Current chipset configuration */
        struct conf_drv_settings conf;
 
+       bool sg_enabled;
+
        struct list_head list;
 };
 
@@ -477,7 +482,8 @@ int wl1271_plt_stop(struct wl1271 *wl);
 
 #define WL1271_DEFAULT_POWER_LEVEL 0
 
-#define WL1271_TX_QUEUE_MAX_LENGTH 20
+#define WL1271_TX_QUEUE_LOW_WATERMARK  10
+#define WL1271_TX_QUEUE_HIGH_WATERMARK 25
 
 /* WL1271 needs a 200ms sleep after power on, and a 20ms sleep before power
    on in case is has been shut down shortly before */