ath9k_hw: Fix pll2_divfrac for AR953x
[linux-2.6-block.git] / drivers / net / wireless / ath / ath9k / hw.c
index c8a9dfab1fee2ea4778046b186428ba3f014e054..fd0158fdf144df989c501316cbbe4692899dc693 100644 (file)
@@ -26,7 +26,6 @@
 #include "ar9003_mac.h"
 #include "ar9003_mci.h"
 #include "ar9003_phy.h"
-#include "debug.h"
 #include "ath9k.h"
 
 static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type);
@@ -246,6 +245,8 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah)
                return;
        case AR9300_DEVID_AR953X:
                ah->hw_version.macVersion = AR_SREV_VERSION_9531;
+               if (ah->get_mac_revision)
+                       ah->hw_version.macRev = ah->get_mac_revision();
                return;
        }
 
@@ -790,7 +791,8 @@ static void ath9k_hw_init_pll(struct ath_hw *ah,
                                refdiv = 5;
                        } else {
                                pll2_divint = 0x11;
-                               pll2_divfrac = 0x26666;
+                               pll2_divfrac =
+                                       AR_SREV_9531(ah) ? 0x26665 : 0x26666;
                                refdiv = 1;
                        }
                }
@@ -1729,6 +1731,23 @@ fail:
        return -EINVAL;
 }
 
+u32 ath9k_hw_get_tsf_offset(struct timespec *last, struct timespec *cur)
+{
+       struct timespec ts;
+       s64 usec;
+
+       if (!cur) {
+               getrawmonotonic(&ts);
+               cur = &ts;
+       }
+
+       usec = cur->tv_sec * 1000000ULL + cur->tv_nsec / 1000;
+       usec -= last->tv_sec * 1000000ULL + last->tv_nsec / 1000;
+
+       return (u32) usec;
+}
+EXPORT_SYMBOL(ath9k_hw_get_tsf_offset);
+
 int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
                   struct ath9k_hw_cal_data *caldata, bool fastcc)
 {
@@ -1738,7 +1757,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        u32 saveDefAntenna;
        u32 macStaId1;
        u64 tsf = 0;
-       s64 usec = 0;
        int r;
        bool start_mci_reset = false;
        bool save_fullsleep = ah->chip_fullsleep;
@@ -1784,7 +1802,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        /* Save TSF before chip reset, a cold reset clears it */
        tsf = ath9k_hw_gettsf64(ah);
        getrawmonotonic(&ts);
-       usec = ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000;
 
        saveLedState = REG_READ(ah, AR_CFG_LED) &
                (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
@@ -1817,9 +1834,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        }
 
        /* Restore TSF */
-       getrawmonotonic(&ts);
-       usec = ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000 - usec;
-       ath9k_hw_settsf64(ah, tsf + usec);
+       ath9k_hw_settsf64(ah, tsf + ath9k_hw_get_tsf_offset(&ts, NULL));
 
        if (AR_SREV_9280_20_OR_LATER(ah))
                REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);