ath9k: Fix HW wait timeout
[safe/jmp/linux-2.6] / drivers / net / wireless / ath9k / hw.h
index f4bf702..ddab3b7 100644 (file)
@@ -42,8 +42,8 @@
 #define AR5416_MAGIC           0x19641014
 
 /* Register read/write primitives */
-#define REG_WRITE(_ah, _reg, _val) iowrite32(_val, _ah->ah_sh + _reg)
-#define REG_READ(_ah, _reg) ioread32(_ah->ah_sh + _reg)
+#define REG_WRITE(_ah, _reg, _val) iowrite32(_val, _ah->ah_sc->mem + _reg)
+#define REG_READ(_ah, _reg) ioread32(_ah->ah_sc->mem + _reg)
 
 #define SM(_v, _f)  (((_v) << _f##_S) & _f)
 #define MS(_v, _f)  (((_v) & _f) >> _f##_S)
@@ -93,7 +93,7 @@
 #define ATH9K_NUM_QUEUES            10
 
 #define MAX_RATE_POWER              63
-#define AH_TIMEOUT                  100000
+#define AH_WAIT_TIMEOUT             100000 /* (us) */
 #define AH_TIME_QUANTUM             10
 #define AR_KEYTABLE_SIZE            128
 #define POWER_UP_TIME               200000
@@ -162,7 +162,8 @@ enum ath9k_capability_type {
        ATH9K_CAP_WME_TKIPMIC,
        ATH9K_CAP_RFSILENT,
        ATH9K_CAP_ANT_CFG_2GHZ,
-       ATH9K_CAP_ANT_CFG_5GHZ
+       ATH9K_CAP_ANT_CFG_5GHZ,
+       ATH9K_CAP_DS
 };
 
 struct ath9k_hw_capabilities {
@@ -249,6 +250,7 @@ enum ath9k_int {
        ATH9K_INT_DTIMSYNC = 0x00800000,
        ATH9K_INT_GPIO = 0x01000000,
        ATH9K_INT_CABEND = 0x02000000,
+       ATH9K_INT_TSFOOR = 0x04000000,
        ATH9K_INT_CST = 0x10000000,
        ATH9K_INT_GTT = 0x20000000,
        ATH9K_INT_FATAL = 0x40000000,
@@ -256,6 +258,7 @@ enum ath9k_int {
        ATH9K_INT_BMISC = ATH9K_INT_TIM |
                ATH9K_INT_DTIM |
                ATH9K_INT_DTIMSYNC |
+               ATH9K_INT_TSFOOR |
                ATH9K_INT_CABEND,
        ATH9K_INT_COMMON = ATH9K_INT_RXNOFRM |
                ATH9K_INT_RXDESC |
@@ -385,6 +388,7 @@ struct ath9k_beacon_state {
 #define ATH9K_BEACON_PERIOD       0x0000ffff
 #define ATH9K_BEACON_ENA          0x00800000
 #define ATH9K_BEACON_RESET_TSF    0x01000000
+#define ATH9K_TSFOOR_THRESHOLD    0x00004240 /* 16k us */
        u32 bs_dtimperiod;
        u16 bs_cfpperiod;
        u16 bs_cfpmaxduration;
@@ -392,6 +396,7 @@ struct ath9k_beacon_state {
        u16 bs_timoffset;
        u16 bs_bmissthreshold;
        u32 bs_sleepduration;
+       u32 bs_tsfoor_threshold;
 };
 
 struct chan_centers {
@@ -417,242 +422,233 @@ struct ath9k_hw_version {
        u16 analog2GhzRev;
 };
 
-struct ath_hal {
-       struct ath9k_hw_version hw_version;
-       void __iomem *ah_sh;
+struct ath_hw {
        struct ath_softc *ah_sc;
-
-       enum nl80211_iftype ah_opmode;
-       struct ath9k_ops_config ah_config;
-       struct ath9k_hw_capabilities ah_caps;
+       struct ath9k_hw_version hw_version;
+       struct ath9k_ops_config config;
+       struct ath9k_hw_capabilities caps;
        struct ath9k_regulatory regulatory;
-       u32 ah_flags;
-       u8 macaddr[ETH_ALEN];
+       struct ath9k_channel channels[38];
+       struct ath9k_channel *curchan;
 
-       enum ath9k_power_mode ah_power_mode;
-       enum ath9k_power_mode ah_restore_mode;
+       union {
+               struct ar5416_eeprom_def def;
+               struct ar5416_eeprom_4k map4k;
+       } eeprom;
+       const struct eeprom_ops *eep_ops;
+       enum ath9k_eep_map eep_map;
 
-       struct ath9k_channel ah_channels[38];
-       struct ath9k_channel *ah_curchan;
+       bool sw_mgmt_crypto;
+       bool is_pciexpress;
+       u8 macaddr[ETH_ALEN];
+       u16 tx_trig_level;
+       u16 rfsilent;
+       u32 rfkill_gpio;
+       u32 rfkill_polarity;
+       u32 btactive_gpio;
+       u32 wlanactive_gpio;
+       u32 ah_flags;
 
-       bool ah_isPciExpress;
-       u16 ah_txTrigLevel;
-       u16 ah_rfsilent;
-       u32 ah_rfkill_gpio;
-       u32 ah_rfkill_polarity;
-       u32 ah_btactive_gpio;
-       u32 ah_wlanactive_gpio;
+       enum nl80211_iftype opmode;
+       enum ath9k_power_mode power_mode;
+       enum ath9k_power_mode restore_mode;
 
        struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
-
-       bool sw_mgmt_crypto;
-};
-
-struct ath_hal_5416 {
-       struct ath_hal ah;
-       union {
-               struct ar5416_eeprom_def def;
-               struct ar5416_eeprom_4k map4k;
-       } ah_eeprom;
-       struct ar5416Stats ah_stats;
-       struct ath9k_tx_queue_info ah_txq[ATH9K_NUM_TX_QUEUES];
-       void __iomem *ah_cal_mem;
-
-       int16_t ah_curchanRadIndex;
-       u32 ah_maskReg;
-       u32 ah_txOkInterruptMask;
-       u32 ah_txErrInterruptMask;
-       u32 ah_txDescInterruptMask;
-       u32 ah_txEolInterruptMask;
-       u32 ah_txUrnInterruptMask;
-       bool ah_chipFullSleep;
-       u32 ah_atimWindow;
-       u16 ah_antennaSwitchSwap;
-       enum ath9k_ant_setting ah_diversityControl;
+       struct ar5416Stats stats;
+       struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES];
+
+       int16_t curchan_rad_index;
+       u32 mask_reg;
+       u32 txok_interrupt_mask;
+       u32 txerr_interrupt_mask;
+       u32 txdesc_interrupt_mask;
+       u32 txeol_interrupt_mask;
+       u32 txurn_interrupt_mask;
+       bool chip_fullsleep;
+       u32 atim_window;
+       u16 antenna_switch_swap;
+       enum ath9k_ant_setting diversity_control;
 
        /* Calibration */
-       enum hal_cal_types ah_suppCals;
-       struct hal_cal_list ah_iqCalData;
-       struct hal_cal_list ah_adcGainCalData;
-       struct hal_cal_list ah_adcDcCalInitData;
-       struct hal_cal_list ah_adcDcCalData;
-       struct hal_cal_list *ah_cal_list;
-       struct hal_cal_list *ah_cal_list_last;
-       struct hal_cal_list *ah_cal_list_curr;
-#define ah_totalPowerMeasI ah_Meas0.unsign
-#define ah_totalPowerMeasQ ah_Meas1.unsign
-#define ah_totalIqCorrMeas ah_Meas2.sign
-#define ah_totalAdcIOddPhase  ah_Meas0.unsign
-#define ah_totalAdcIEvenPhase ah_Meas1.unsign
-#define ah_totalAdcQOddPhase  ah_Meas2.unsign
-#define ah_totalAdcQEvenPhase ah_Meas3.unsign
-#define ah_totalAdcDcOffsetIOddPhase  ah_Meas0.sign
-#define ah_totalAdcDcOffsetIEvenPhase ah_Meas1.sign
-#define ah_totalAdcDcOffsetQOddPhase  ah_Meas2.sign
-#define ah_totalAdcDcOffsetQEvenPhase ah_Meas3.sign
+       enum hal_cal_types supp_cals;
+       struct hal_cal_list iq_caldata;
+       struct hal_cal_list adcgain_caldata;
+       struct hal_cal_list adcdc_calinitdata;
+       struct hal_cal_list adcdc_caldata;
+       struct hal_cal_list *cal_list;
+       struct hal_cal_list *cal_list_last;
+       struct hal_cal_list *cal_list_curr;
+#define totalPowerMeasI meas0.unsign
+#define totalPowerMeasQ meas1.unsign
+#define totalIqCorrMeas meas2.sign
+#define totalAdcIOddPhase  meas0.unsign
+#define totalAdcIEvenPhase meas1.unsign
+#define totalAdcQOddPhase  meas2.unsign
+#define totalAdcQEvenPhase meas3.unsign
+#define totalAdcDcOffsetIOddPhase  meas0.sign
+#define totalAdcDcOffsetIEvenPhase meas1.sign
+#define totalAdcDcOffsetQOddPhase  meas2.sign
+#define totalAdcDcOffsetQEvenPhase meas3.sign
        union {
                u32 unsign[AR5416_MAX_CHAINS];
                int32_t sign[AR5416_MAX_CHAINS];
-       } ah_Meas0;
+       } meas0;
        union {
                u32 unsign[AR5416_MAX_CHAINS];
                int32_t sign[AR5416_MAX_CHAINS];
-       } ah_Meas1;
+       } meas1;
        union {
                u32 unsign[AR5416_MAX_CHAINS];
                int32_t sign[AR5416_MAX_CHAINS];
-       } ah_Meas2;
+       } meas2;
        union {
                u32 unsign[AR5416_MAX_CHAINS];
                int32_t sign[AR5416_MAX_CHAINS];
-       } ah_Meas3;
-       u16 ah_CalSamples;
+       } meas3;
+       u16 cal_samples;
 
-       u32 ah_staId1Defaults;
-       u32 ah_miscMode;
+       u32 sta_id1_defaults;
+       u32 misc_mode;
        enum {
                AUTO_32KHZ,
                USE_32KHZ,
                DONT_USE_32KHZ,
-       } ah_enable32kHzClock;
+       } enable_32kHz_clock;
 
        /* RF */
-       u32 *ah_analogBank0Data;
-       u32 *ah_analogBank1Data;
-       u32 *ah_analogBank2Data;
-       u32 *ah_analogBank3Data;
-       u32 *ah_analogBank6Data;
-       u32 *ah_analogBank6TPCData;
-       u32 *ah_analogBank7Data;
-       u32 *ah_addac5416_21;
-       u32 *ah_bank6Temp;
-
-       int16_t ah_txPowerIndexOffset;
-       u32 ah_beaconInterval;
-       u32 ah_slottime;
-       u32 ah_acktimeout;
-       u32 ah_ctstimeout;
-       u32 ah_globaltxtimeout;
-       u8 ah_gBeaconRate;
-       u32 ah_gpioSelect;
-       u32 ah_polarity;
-       u32 ah_gpioBit;
+       u32 *analogBank0Data;
+       u32 *analogBank1Data;
+       u32 *analogBank2Data;
+       u32 *analogBank3Data;
+       u32 *analogBank6Data;
+       u32 *analogBank6TPCData;
+       u32 *analogBank7Data;
+       u32 *addac5416_21;
+       u32 *bank6Temp;
+
+       int16_t txpower_indexoffset;
+       u32 beacon_interval;
+       u32 slottime;
+       u32 acktimeout;
+       u32 ctstimeout;
+       u32 globaltxtimeout;
+       u8 gbeacon_rate;
 
        /* ANI */
-       u32 ah_procPhyErr;
-       bool ah_hasHwPhyCounters;
-       u32 ah_aniPeriod;
-       struct ar5416AniState *ah_curani;
-       struct ar5416AniState ah_ani[255];
-       int ah_totalSizeDesired[5];
-       int ah_coarseHigh[5];
-       int ah_coarseLow[5];
-       int ah_firpwr[5];
-       enum ath9k_ani_cmd ah_ani_function;
-
-       u32 ah_intrTxqs;
-       bool ah_intrMitigation;
-       enum ath9k_ht_extprotspacing ah_extprotspacing;
-       u8 ah_txchainmask;
-       u8 ah_rxchainmask;
-
-       struct ar5416IniArray ah_iniModes;
-       struct ar5416IniArray ah_iniCommon;
-       struct ar5416IniArray ah_iniBank0;
-       struct ar5416IniArray ah_iniBB_RfGain;
-       struct ar5416IniArray ah_iniBank1;
-       struct ar5416IniArray ah_iniBank2;
-       struct ar5416IniArray ah_iniBank3;
-       struct ar5416IniArray ah_iniBank6;
-       struct ar5416IniArray ah_iniBank6TPC;
-       struct ar5416IniArray ah_iniBank7;
-       struct ar5416IniArray ah_iniAddac;
-       struct ar5416IniArray ah_iniPcieSerdes;
-       struct ar5416IniArray ah_iniModesAdditional;
-       struct ar5416IniArray ah_iniModesRxGain;
-       struct ar5416IniArray ah_iniModesTxGain;
-       /* To indicate EEPROM mapping used */
-       enum hal_eep_map ah_eep_map;
+       u32 proc_phyerr;
+       bool has_hw_phycounters;
+       u32 aniperiod;
+       struct ar5416AniState *curani;
+       struct ar5416AniState ani[255];
+       int totalSizeDesired[5];
+       int coarse_high[5];
+       int coarse_low[5];
+       int firpwr[5];
+       enum ath9k_ani_cmd ani_function;
+
+       u32 intr_txqs;
+       bool intr_mitigation;
+       enum ath9k_ht_extprotspacing extprotspacing;
+       u8 txchainmask;
+       u8 rxchainmask;
+
+       u32 originalGain[22];
+       int initPDADC;
+       int PDADCdelta;
+
+       struct ar5416IniArray iniModes;
+       struct ar5416IniArray iniCommon;
+       struct ar5416IniArray iniBank0;
+       struct ar5416IniArray iniBB_RfGain;
+       struct ar5416IniArray iniBank1;
+       struct ar5416IniArray iniBank2;
+       struct ar5416IniArray iniBank3;
+       struct ar5416IniArray iniBank6;
+       struct ar5416IniArray iniBank6TPC;
+       struct ar5416IniArray iniBank7;
+       struct ar5416IniArray iniAddac;
+       struct ar5416IniArray iniPcieSerdes;
+       struct ar5416IniArray iniModesAdditional;
+       struct ar5416IniArray iniModesRxGain;
+       struct ar5416IniArray iniModesTxGain;
 };
-#define AH5416(_ah) ((struct ath_hal_5416 *)(_ah))
 
 /* Attach, Detach, Reset */
 const char *ath9k_hw_probe(u16 vendorid, u16 devid);
-void ath9k_hw_detach(struct ath_hal *ah);
-struct ath_hal *ath9k_hw_attach(u16 devid, struct ath_softc *sc,
-                               void __iomem *mem, int *error);
-void ath9k_hw_rfdetach(struct ath_hal *ah);
-int ath9k_hw_reset(struct ath_hal *ah, struct ath9k_channel *chan,
+void ath9k_hw_detach(struct ath_hw *ah);
+struct ath_hw *ath9k_hw_attach(u16 devid, struct ath_softc *sc, int *error);
+void ath9k_hw_rfdetach(struct ath_hw *ah);
+int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
                   bool bChannelChange);
-bool ath9k_hw_fill_cap_info(struct ath_hal *ah);
-bool ath9k_hw_getcapability(struct ath_hal *ah, enum ath9k_capability_type type,
+bool ath9k_hw_fill_cap_info(struct ath_hw *ah);
+bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type,
                            u32 capability, u32 *result);
-bool ath9k_hw_setcapability(struct ath_hal *ah, enum ath9k_capability_type type,
+bool ath9k_hw_setcapability(struct ath_hw *ah, enum ath9k_capability_type type,
                            u32 capability, u32 setting, int *status);
 
 /* Key Cache Management */
-bool ath9k_hw_keyreset(struct ath_hal *ah, u16 entry);
-bool ath9k_hw_keysetmac(struct ath_hal *ah, u16 entry, const u8 *mac);
-bool ath9k_hw_set_keycache_entry(struct ath_hal *ah, u16 entry,
+bool ath9k_hw_keyreset(struct ath_hw *ah, u16 entry);
+bool ath9k_hw_keysetmac(struct ath_hw *ah, u16 entry, const u8 *mac);
+bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
                                 const struct ath9k_keyval *k,
                                 const u8 *mac, int xorKey);
-bool ath9k_hw_keyisvalid(struct ath_hal *ah, u16 entry);
+bool ath9k_hw_keyisvalid(struct ath_hw *ah, u16 entry);
 
 /* GPIO / RFKILL / Antennae */
-void ath9k_hw_cfg_gpio_input(struct ath_hal *ah, u32 gpio);
-u32 ath9k_hw_gpio_get(struct ath_hal *ah, u32 gpio);
-void ath9k_hw_cfg_output(struct ath_hal *ah, u32 gpio,
+void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio);
+u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio);
+void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio,
                         u32 ah_signal_type);
-void ath9k_hw_set_gpio(struct ath_hal *ah, u32 gpio, u32 val);
+void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val);
 #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE)
-void ath9k_enable_rfkill(struct ath_hal *ah);
+void ath9k_enable_rfkill(struct ath_hw *ah);
 #endif
-u32 ath9k_hw_getdefantenna(struct ath_hal *ah);
-void ath9k_hw_setantenna(struct ath_hal *ah, u32 antenna);
-bool ath9k_hw_setantennaswitch(struct ath_hal *ah,
+u32 ath9k_hw_getdefantenna(struct ath_hw *ah);
+void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
+bool ath9k_hw_setantennaswitch(struct ath_hw *ah,
                               enum ath9k_ant_setting settings,
                               struct ath9k_channel *chan,
                               u8 *tx_chainmask, u8 *rx_chainmask,
                               u8 *antenna_cfgd);
 
 /* General Operation */
-bool ath9k_hw_wait(struct ath_hal *ah, u32 reg, u32 mask, u32 val);
+bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
 u32 ath9k_hw_reverse_bits(u32 val, u32 n);
-bool ath9k_get_channel_edges(struct ath_hal *ah, u16 flags, u16 *low, u16 *high);
-u16 ath9k_hw_computetxtime(struct ath_hal *ah, struct ath_rate_table *rates,
+bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high);
+u16 ath9k_hw_computetxtime(struct ath_hw *ah, struct ath_rate_table *rates,
                           u32 frameLen, u16 rateix, bool shortPreamble);
-void ath9k_hw_get_channel_centers(struct ath_hal *ah,
+void ath9k_hw_get_channel_centers(struct ath_hw *ah,
                                  struct ath9k_channel *chan,
                                  struct chan_centers *centers);
-u32 ath9k_hw_getrxfilter(struct ath_hal *ah);
-void ath9k_hw_setrxfilter(struct ath_hal *ah, u32 bits);
-bool ath9k_hw_phy_disable(struct ath_hal *ah);
-bool ath9k_hw_disable(struct ath_hal *ah);
-bool ath9k_hw_set_txpowerlimit(struct ath_hal *ah, u32 limit);
-void ath9k_hw_setmac(struct ath_hal *ah, const u8 *mac);
-void ath9k_hw_setopmode(struct ath_hal *ah);
-void ath9k_hw_setmcastfilter(struct ath_hal *ah, u32 filter0, u32 filter1);
+u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
+void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
+bool ath9k_hw_phy_disable(struct ath_hw *ah);
+bool ath9k_hw_disable(struct ath_hw *ah);
+bool ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit);
+void ath9k_hw_setmac(struct ath_hw *ah, const u8 *mac);
+void ath9k_hw_setopmode(struct ath_hw *ah);
+void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
 void ath9k_hw_setbssidmask(struct ath_softc *sc);
 void ath9k_hw_write_associd(struct ath_softc *sc);
-u64 ath9k_hw_gettsf64(struct ath_hal *ah);
-void ath9k_hw_settsf64(struct ath_hal *ah, u64 tsf64);
-void ath9k_hw_reset_tsf(struct ath_hal *ah);
-bool ath9k_hw_set_tsfadjust(struct ath_hal *ah, u32 setting);
-bool ath9k_hw_setslottime(struct ath_hal *ah, u32 us);
-void ath9k_hw_set11nmac2040(struct ath_hal *ah, enum ath9k_ht_macmode mode);
-void ath9k_hw_beaconinit(struct ath_hal *ah, u32 next_beacon, u32 beacon_period);
-void ath9k_hw_set_sta_beacon_timers(struct ath_hal *ah,
+u64 ath9k_hw_gettsf64(struct ath_hw *ah);
+void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64);
+void ath9k_hw_reset_tsf(struct ath_hw *ah);
+bool ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting);
+bool ath9k_hw_setslottime(struct ath_hw *ah, u32 us);
+void ath9k_hw_set11nmac2040(struct ath_hw *ah, enum ath9k_ht_macmode mode);
+void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
+void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
                                    const struct ath9k_beacon_state *bs);
-bool ath9k_hw_setpower(struct ath_hal *ah,
+bool ath9k_hw_setpower(struct ath_hw *ah,
                       enum ath9k_power_mode mode);
-void ath9k_hw_configpcipowersave(struct ath_hal *ah, int restore);
+void ath9k_hw_configpcipowersave(struct ath_hw *ah, int restore);
 
 /* Interrupt Handling */
-bool ath9k_hw_intrpend(struct ath_hal *ah);
-bool ath9k_hw_getisr(struct ath_hal *ah, enum ath9k_int *masked);
-enum ath9k_int ath9k_hw_intrget(struct ath_hal *ah);
-enum ath9k_int ath9k_hw_set_interrupts(struct ath_hal *ah, enum ath9k_int ints);
+bool ath9k_hw_intrpend(struct ath_hw *ah);
+bool ath9k_hw_getisr(struct ath_hw *ah, enum ath9k_int *masked);
+enum ath9k_int ath9k_hw_intrget(struct ath_hw *ah);
+enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints);
 
-void ath9k_hw_btcoex_enable(struct ath_hal *ah);
+void ath9k_hw_btcoex_enable(struct ath_hw *ah);
 
 #endif