]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/ath/ath9k/eeprom_4k.c
ath9k: consistently use get_eeprom_rev(ah)
[karo-tx-linux.git] / drivers / net / wireless / ath / ath9k / eeprom_4k.c
index 5da0826bf1be031472cb8c9a19743c7d2fe21154..76ce109629b9b0c2543990f246fe13ac0b450c47 100644 (file)
 
 static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
 {
-       return ((ah->eeprom.map4k.baseEepHeader.version >> 12) & 0xF);
+       u16 version = ah->eeprom.map4k.baseEepHeader.version;
+
+       return (version & AR5416_EEP_VER_MAJOR_MASK) >>
+               AR5416_EEP_VER_MAJOR_SHIFT;
 }
 
 static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
 {
-       return ((ah->eeprom.map4k.baseEepHeader.version) & 0xFFF);
+       u16 version = ah->eeprom.map4k.baseEepHeader.version;
+
+       return version & AR5416_EEP_VER_MINOR_MASK;
 }
 
 #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
@@ -136,8 +141,8 @@ static u32 ath9k_hw_4k_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
                goto out;
        }
 
-       PR_EEP("Major Version", pBase->version >> 12);
-       PR_EEP("Minor Version", pBase->version & 0xFFF);
+       PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah));
+       PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah));
        PR_EEP("Checksum", pBase->checksum);
        PR_EEP("Length", pBase->length);
        PR_EEP("RegDomain1", pBase->regDmn[0]);
@@ -154,7 +159,7 @@ static u32 ath9k_hw_4k_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
                                        AR5416_OPFLAGS_N_5G_HT20));
        PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
                                        AR5416_OPFLAGS_N_5G_HT40));
-       PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01));
+       PR_EEP("Big Endian", !!(pBase->eepMisc & AR5416_EEPMISC_BIG_ENDIAN));
        PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
        PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
        PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
@@ -254,9 +259,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah,
        struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
        struct modal_eep_4k_header *pModal = &eep->modalHeader;
        struct base_eep_header_4k *pBase = &eep->baseEepHeader;
-       u16 ver_minor;
-
-       ver_minor = pBase->version & AR5416_EEP_VER_MINOR_MASK;
 
        switch (param) {
        case EEP_NFTHRESH_2:
@@ -279,8 +281,6 @@ static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah,
                return pModal->ob_0;
        case EEP_DB_2:
                return pModal->db1_1;
-       case EEP_MINOR_REV:
-               return ver_minor;
        case EEP_TX_MASK:
                return pBase->txMask;
        case EEP_RX_MASK:
@@ -319,14 +319,12 @@ static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
 
        xpdMask = pEepData->modalHeader.xpdGain;
 
-       if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-           AR5416_EEP_MINOR_VER_2) {
+       if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
                pdGainOverlap_t2 =
                        pEepData->modalHeader.pdGainOverlap;
-       } else {
+       else
                pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
                                            AR_PHY_TPCRG5_PD_GAIN_OVERLAP));
-       }
 
        pCalBChans = pEepData->calFreqPier2G;
        numPiers = AR5416_EEP4K_NUM_2G_CAL_PIERS;
@@ -612,10 +610,8 @@ static void ath9k_hw_4k_set_txpower(struct ath_hw *ah,
 
        memset(ratesArray, 0, sizeof(ratesArray));
 
-       if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-           AR5416_EEP_MINOR_VER_2) {
+       if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
                ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
-       }
 
        ath9k_hw_set_4k_power_per_rate_table(ah, chan,
                                             &ratesArray[0], cfgCtl,
@@ -735,8 +731,7 @@ static void ath9k_hw_4k_set_gain(struct ath_hw *ah,
                SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF),
                AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF | AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF);
 
-       if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-           AR5416_EEP_MINOR_VER_3) {
+       if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
                txRxAttenLocal = pModal->txRxAttenCh[0];
 
                REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ,
@@ -1014,16 +1009,14 @@ static void ath9k_hw_4k_set_board_values(struct ath_hw *ah,
        REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0, AR_PHY_EXT_CCA0_THRESH62,
                      pModal->thresh62);
 
-       if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-                                               AR5416_EEP_MINOR_VER_2) {
+       if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
                REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_DATA_START,
                              pModal->txFrameToDataStart);
                REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON,
                              pModal->txFrameToPaOn);
        }
 
-       if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
-                                               AR5416_EEP_MINOR_VER_3) {
+       if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
                if (IS_CHAN_HT40(chan))
                        REG_RMW_FIELD(ah, AR_PHY_SETTLING,
                                      AR_PHY_SETTLING_SWITCH,
@@ -1064,6 +1057,11 @@ static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
        return ah->eeprom.map4k.modalHeader.spurChans[i].spurChan;
 }
 
+static u8 ath9k_hw_4k_get_eepmisc(struct ath_hw *ah)
+{
+       return ah->eeprom.map4k.baseEepHeader.eepMisc;
+}
+
 const struct eeprom_ops eep_4k_ops = {
        .check_eeprom           = ath9k_hw_4k_check_eeprom,
        .get_eeprom             = ath9k_hw_4k_get_eeprom,
@@ -1073,5 +1071,6 @@ const struct eeprom_ops eep_4k_ops = {
        .get_eeprom_rev         = ath9k_hw_4k_get_eeprom_rev,
        .set_board_values       = ath9k_hw_4k_set_board_values,
        .set_txpower            = ath9k_hw_4k_set_txpower,
-       .get_spur_channel       = ath9k_hw_4k_get_spur_channel
+       .get_spur_channel       = ath9k_hw_4k_get_spur_channel,
+       .get_eepmisc            = ath9k_hw_4k_get_eepmisc
 };