1
0

554-ath9k-consistently-use-get_eeprom_rev-ah.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. From c763af71bcc2f01bd5ef6e65c7c34b46c7235a16 Mon Sep 17 00:00:00 2001
  2. From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  3. Date: Mon, 3 Oct 2016 00:29:11 +0200
  4. Subject: [v2 PATCH 5/7] ath9k: consistently use get_eeprom_rev(ah)
  5. The AR5416_VER_MASK macro does the same as get_eeprom_rev, except that
  6. one has to know the actual EEPROM type (and providing a reference to
  7. that in a variable named "eep"). Additionally the eeprom_*.c
  8. implementations used the same shifting logic multiple times to get the
  9. eeprom revision which was also unnecessary duplication of
  10. get_eeprom_rev.
  11. Also use the AR5416_EEP_VER_MINOR_MASK macro where needed and introduce
  12. a similar macro (AR5416_EEP_VER_MAJOR_MASK) for the major version.
  13. Finally drop AR9287_EEP_VER_MINOR_MASK since it simply duplicates the
  14. already defined AR5416_EEP_VER_MINOR_MASK.
  15. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
  16. ---
  17. drivers/net/wireless/ath/ath9k/eeprom.h | 4 +--
  18. drivers/net/wireless/ath/ath9k/eeprom_4k.c | 32 ++++++++++------------
  19. drivers/net/wireless/ath/ath9k/eeprom_9287.c | 19 +++++++------
  20. drivers/net/wireless/ath/ath9k/eeprom_def.c | 41 +++++++++++++++-------------
  21. drivers/net/wireless/ath/ath9k/xmit.c | 3 +-
  22. 5 files changed, 52 insertions(+), 47 deletions(-)
  23. --- a/drivers/net/wireless/ath/ath9k/eeprom.h
  24. +++ b/drivers/net/wireless/ath/ath9k/eeprom.h
  25. @@ -99,7 +99,6 @@
  26. #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
  27. #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM))
  28. -#define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK)
  29. #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \
  30. ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
  31. #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
  32. @@ -121,6 +120,8 @@
  33. #define AR5416_EEP_NO_BACK_VER 0x1
  34. #define AR5416_EEP_VER 0xE
  35. +#define AR5416_EEP_VER_MAJOR_SHIFT 12
  36. +#define AR5416_EEP_VER_MAJOR_MASK 0xF000
  37. #define AR5416_EEP_VER_MINOR_MASK 0x0FFF
  38. #define AR5416_EEP_MINOR_VER_2 0x2
  39. #define AR5416_EEP_MINOR_VER_3 0x3
  40. @@ -177,7 +178,6 @@
  41. #define AR9280_TX_GAIN_TABLE_SIZE 22
  42. #define AR9287_EEP_VER 0xE
  43. -#define AR9287_EEP_VER_MINOR_MASK 0xFFF
  44. #define AR9287_EEP_MINOR_VER_1 0x1
  45. #define AR9287_EEP_MINOR_VER_2 0x2
  46. #define AR9287_EEP_MINOR_VER_3 0x3
  47. --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c
  48. +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c
  49. @@ -20,12 +20,17 @@
  50. static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
  51. {
  52. - return ((ah->eeprom.map4k.baseEepHeader.version >> 12) & 0xF);
  53. + u16 version = ah->eeprom.map4k.baseEepHeader.version;
  54. +
  55. + return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  56. + AR5416_EEP_VER_MAJOR_SHIFT;
  57. }
  58. static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
  59. {
  60. - return ((ah->eeprom.map4k.baseEepHeader.version) & 0xFFF);
  61. + u16 version = ah->eeprom.map4k.baseEepHeader.version;
  62. +
  63. + return version & AR5416_EEP_VER_MINOR_MASK;
  64. }
  65. #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
  66. @@ -136,8 +141,8 @@ static u32 ath9k_hw_4k_dump_eeprom(struc
  67. goto out;
  68. }
  69. - PR_EEP("Major Version", pBase->version >> 12);
  70. - PR_EEP("Minor Version", pBase->version & 0xFFF);
  71. + PR_EEP("Major Version", ath9k_hw_4k_get_eeprom_ver(ah));
  72. + PR_EEP("Minor Version", ath9k_hw_4k_get_eeprom_rev(ah));
  73. PR_EEP("Checksum", pBase->checksum);
  74. PR_EEP("Length", pBase->length);
  75. PR_EEP("RegDomain1", pBase->regDmn[0]);
  76. @@ -314,14 +319,12 @@ static void ath9k_hw_set_4k_power_cal_ta
  77. xpdMask = pEepData->modalHeader.xpdGain;
  78. - if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  79. - AR5416_EEP_MINOR_VER_2) {
  80. + if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
  81. pdGainOverlap_t2 =
  82. pEepData->modalHeader.pdGainOverlap;
  83. - } else {
  84. + else
  85. pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
  86. AR_PHY_TPCRG5_PD_GAIN_OVERLAP));
  87. - }
  88. pCalBChans = pEepData->calFreqPier2G;
  89. numPiers = AR5416_EEP4K_NUM_2G_CAL_PIERS;
  90. @@ -607,10 +610,8 @@ static void ath9k_hw_4k_set_txpower(stru
  91. memset(ratesArray, 0, sizeof(ratesArray));
  92. - if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  93. - AR5416_EEP_MINOR_VER_2) {
  94. + if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
  95. ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
  96. - }
  97. ath9k_hw_set_4k_power_per_rate_table(ah, chan,
  98. &ratesArray[0], cfgCtl,
  99. @@ -730,8 +731,7 @@ static void ath9k_hw_4k_set_gain(struct
  100. SM(pModal->iqCalQCh[0], AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF),
  101. AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF | AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF);
  102. - if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  103. - AR5416_EEP_MINOR_VER_3) {
  104. + if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
  105. txRxAttenLocal = pModal->txRxAttenCh[0];
  106. REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ,
  107. @@ -1009,16 +1009,14 @@ static void ath9k_hw_4k_set_board_values
  108. REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0, AR_PHY_EXT_CCA0_THRESH62,
  109. pModal->thresh62);
  110. - if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  111. - AR5416_EEP_MINOR_VER_2) {
  112. + if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
  113. REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_DATA_START,
  114. pModal->txFrameToDataStart);
  115. REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON,
  116. pModal->txFrameToPaOn);
  117. }
  118. - if ((eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  119. - AR5416_EEP_MINOR_VER_3) {
  120. + if (ath9k_hw_4k_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
  121. if (IS_CHAN_HT40(chan))
  122. REG_RMW_FIELD(ah, AR_PHY_SETTLING,
  123. AR_PHY_SETTLING_SWITCH,
  124. --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  125. +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c
  126. @@ -22,12 +22,17 @@
  127. static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
  128. {
  129. - return (ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF;
  130. + u16 version = ah->eeprom.map9287.baseEepHeader.version;
  131. +
  132. + return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  133. + AR5416_EEP_VER_MAJOR_SHIFT;
  134. }
  135. static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
  136. {
  137. - return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF;
  138. + u16 version = ah->eeprom.map9287.baseEepHeader.version;
  139. +
  140. + return version & AR5416_EEP_VER_MINOR_MASK;
  141. }
  142. static bool __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
  143. @@ -132,8 +137,8 @@ static u32 ath9k_hw_ar9287_dump_eeprom(s
  144. goto out;
  145. }
  146. - PR_EEP("Major Version", pBase->version >> 12);
  147. - PR_EEP("Minor Version", pBase->version & 0xFFF);
  148. + PR_EEP("Major Version", ath9k_hw_ar9287_get_eeprom_ver(ah));
  149. + PR_EEP("Minor Version", ath9k_hw_ar9287_get_eeprom_rev(ah));
  150. PR_EEP("Checksum", pBase->checksum);
  151. PR_EEP("Length", pBase->length);
  152. PR_EEP("RegDomain1", pBase->regDmn[0]);
  153. @@ -383,8 +388,7 @@ static void ath9k_hw_set_ar9287_power_ca
  154. xpdMask = pEepData->modalHeader.xpdGain;
  155. - if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >=
  156. - AR9287_EEP_MINOR_VER_2)
  157. + if (ath9k_hw_ar9287_get_eeprom_rev(ah) >= AR9287_EEP_MINOR_VER_2)
  158. pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap;
  159. else
  160. pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
  161. @@ -733,8 +737,7 @@ static void ath9k_hw_ar9287_set_txpower(
  162. memset(ratesArray, 0, sizeof(ratesArray));
  163. - if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >=
  164. - AR9287_EEP_MINOR_VER_2)
  165. + if (ath9k_hw_ar9287_get_eeprom_rev(ah) >= AR9287_EEP_MINOR_VER_2)
  166. ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
  167. ath9k_hw_set_ar9287_power_per_rate_table(ah, chan,
  168. --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c
  169. +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c
  170. @@ -79,12 +79,17 @@ static void ath9k_olc_get_pdadcs(struct
  171. static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
  172. {
  173. - return ((ah->eeprom.def.baseEepHeader.version >> 12) & 0xF);
  174. + u16 version = ah->eeprom.def.baseEepHeader.version;
  175. +
  176. + return (version & AR5416_EEP_VER_MAJOR_MASK) >>
  177. + AR5416_EEP_VER_MAJOR_SHIFT;
  178. }
  179. static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
  180. {
  181. - return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF);
  182. + u16 version = ah->eeprom.def.baseEepHeader.version;
  183. +
  184. + return version & AR5416_EEP_VER_MINOR_MASK;
  185. }
  186. #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16))
  187. @@ -214,8 +219,8 @@ static u32 ath9k_hw_def_dump_eeprom(stru
  188. goto out;
  189. }
  190. - PR_EEP("Major Version", pBase->version >> 12);
  191. - PR_EEP("Minor Version", pBase->version & 0xFFF);
  192. + PR_EEP("Major Version", ath9k_hw_def_get_eeprom_ver(ah));
  193. + PR_EEP("Minor Version", ath9k_hw_def_get_eeprom_rev(ah));
  194. PR_EEP("Checksum", pBase->checksum);
  195. PR_EEP("Length", pBase->length);
  196. PR_EEP("RegDomain1", pBase->regDmn[0]);
  197. @@ -391,27 +396,27 @@ static u32 ath9k_hw_def_get_eeprom(struc
  198. case EEP_TXGAIN_TYPE:
  199. return pBase->txGainType;
  200. case EEP_OL_PWRCTRL:
  201. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
  202. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19)
  203. return pBase->openLoopPwrCntl ? true : false;
  204. else
  205. return false;
  206. case EEP_RC_CHAIN_MASK:
  207. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
  208. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19)
  209. return pBase->rcChainMask;
  210. else
  211. return 0;
  212. case EEP_DAC_HPWR_5G:
  213. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20)
  214. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_20)
  215. return pBase->dacHiPwrMode_5G;
  216. else
  217. return 0;
  218. case EEP_FRAC_N_5G:
  219. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_22)
  220. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_22)
  221. return pBase->frac_n_5g;
  222. else
  223. return 0;
  224. case EEP_PWR_TABLE_OFFSET:
  225. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_21)
  226. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_21)
  227. return pBase->pwr_table_offset;
  228. else
  229. return AR5416_PWR_TABLE_OFFSET_DB;
  230. @@ -434,7 +439,7 @@ static void ath9k_hw_def_set_gain(struct
  231. u8 txRxAttenLocal, int regChainOffset, int i)
  232. {
  233. ENABLE_REG_RMW_BUFFER(ah);
  234. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
  235. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
  236. txRxAttenLocal = pModal->txRxAttenCh[i];
  237. if (AR_SREV_9280_20_OR_LATER(ah)) {
  238. @@ -603,7 +608,7 @@ static void ath9k_hw_def_set_board_value
  239. pModal->thresh62);
  240. }
  241. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) {
  242. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
  243. REG_RMW_FIELD(ah, AR_PHY_RF_CTL2,
  244. AR_PHY_TX_END_DATA_START,
  245. pModal->txFrameToDataStart);
  246. @@ -611,7 +616,7 @@ static void ath9k_hw_def_set_board_value
  247. pModal->txFrameToPaOn);
  248. }
  249. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
  250. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_3) {
  251. if (IS_CHAN_HT40(chan))
  252. REG_RMW_FIELD(ah, AR_PHY_SETTLING,
  253. AR_PHY_SETTLING_SWITCH,
  254. @@ -619,13 +624,14 @@ static void ath9k_hw_def_set_board_value
  255. }
  256. if (AR_SREV_9280_20_OR_LATER(ah) &&
  257. - AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
  258. + ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_19)
  259. REG_RMW_FIELD(ah, AR_PHY_CCK_TX_CTRL,
  260. AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK,
  261. pModal->miscBits);
  262. - if (AR_SREV_9280_20(ah) && AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) {
  263. + if (AR_SREV_9280_20(ah) &&
  264. + ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_20) {
  265. if (IS_CHAN_2GHZ(chan))
  266. REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
  267. eep->baseEepHeader.dacLpMode);
  268. @@ -796,8 +802,7 @@ static void ath9k_hw_set_def_power_cal_t
  269. pwr_table_offset = ah->eep_ops->get_eeprom(ah, EEP_PWR_TABLE_OFFSET);
  270. - if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  271. - AR5416_EEP_MINOR_VER_2) {
  272. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2) {
  273. pdGainOverlap_t2 =
  274. pEepData->modalHeader[modalIdx].pdGainOverlap;
  275. } else {
  276. @@ -1169,10 +1174,8 @@ static void ath9k_hw_def_set_txpower(str
  277. memset(ratesArray, 0, sizeof(ratesArray));
  278. - if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  279. - AR5416_EEP_MINOR_VER_2) {
  280. + if (ath9k_hw_def_get_eeprom_rev(ah) >= AR5416_EEP_MINOR_VER_2)
  281. ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
  282. - }
  283. ath9k_hw_set_def_power_per_rate_table(ah, chan,
  284. &ratesArray[0], cfgCtl,
  285. --- a/drivers/net/wireless/ath/ath9k/xmit.c
  286. +++ b/drivers/net/wireless/ath/ath9k/xmit.c
  287. @@ -1177,8 +1177,9 @@ static u8 ath_get_rate_txpower(struct at
  288. if (is_40) {
  289. u8 power_ht40delta;
  290. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  291. + u16 eeprom_rev = ah->eep_ops->get_eeprom_rev(ah);
  292. - if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) {
  293. + if (eeprom_rev >= AR5416_EEP_MINOR_VER_2) {
  294. bool is_2ghz;
  295. struct modal_eep_header *pmodal;