[brcm63xx] package the bcm63xx-spi driver
[openwrt.git] / package / mac80211 / patches / 405-ath9k-cleanup-AR5416-version-checking-macros.patch
1 From 0f1a8ac314c886aa3a4c14e3d868207483ad343c Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Thu, 5 Mar 2009 10:18:35 +0100
4 Subject: [PATCH v2 1/3] ath9k: cleanup AR5416 version checking macros
5
6 Currently we have two different versions of this macros. Because they
7 would have to do the same thing, we should simplify and merge them.
8
9 Changes-licensed-under: ISC
10
11 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
12 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
13 ---
14  drivers/net/wireless/ath9k/eeprom.c |   16 ++++++++--------
15  drivers/net/wireless/ath9k/hw.c     |    4 ++--
16  drivers/net/wireless/ath9k/mac.h    |    2 +-
17  drivers/net/wireless/ath9k/reg.h    |   19 +++++++++++--------
18  4 files changed, 22 insertions(+), 19 deletions(-)
19
20 --- a/drivers/net/wireless/ath9k/eeprom.c
21 +++ b/drivers/net/wireless/ath9k/eeprom.c
22 @@ -640,7 +640,7 @@ static void ath9k_hw_get_4k_gain_boundar
23                 pPdGainBoundaries[i] =
24                         min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i]);
25  
26 -               if ((i == 0) && !AR_SREV_5416_V20_OR_LATER(ah)) {
27 +               if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
28                         minDelta = pPdGainBoundaries[0] - 23;
29                         pPdGainBoundaries[0] = 23;
30                 } else {
31 @@ -755,7 +755,7 @@ static bool ath9k_hw_set_4k_power_cal_ta
32         REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_3, 0);
33  
34         for (i = 0; i < AR5416_MAX_CHAINS; i++) {
35 -               if (AR_SREV_5416_V20_OR_LATER(ah) &&
36 +               if (AR_SREV_5416_20_OR_LATER(ah) &&
37                     (ah->rxchainmask == 5 || ah->txchainmask == 5) &&
38                     (i != 0)) {
39                         regChainOffset = (i == 1) ? 0x2000 : 0x1000;
40 @@ -771,7 +771,7 @@ static bool ath9k_hw_set_4k_power_cal_ta
41                                             &tMinCalPower, gainBoundaries,
42                                             pdadcValues, numXpdGain);
43  
44 -                       if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
45 +                       if ((i == 0) || AR_SREV_5416_20_OR_LATER(ah)) {
46                                 REG_WRITE(ah, AR_PHY_TPCRG5 + regChainOffset,
47                                           SM(pdGainOverlap_t2,
48                                              AR_PHY_TPCRG5_PD_GAIN_OVERLAP)
49 @@ -1707,7 +1707,7 @@ static bool ath9k_hw_def_set_board_value
50                                 break;
51                 }
52  
53 -               if (AR_SREV_5416_V20_OR_LATER(ah) &&
54 +               if (AR_SREV_5416_20_OR_LATER(ah) &&
55                     (ah->rxchainmask == 5 || ah->txchainmask == 5)
56                     && (i != 0))
57                         regChainOffset = (i == 1) ? 0x2000 : 0x1000;
58 @@ -1728,7 +1728,7 @@ static bool ath9k_hw_def_set_board_value
59                           SM(pModal->iqCalQCh[i],
60                              AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
61  
62 -               if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
63 +               if ((i == 0) || AR_SREV_5416_20_OR_LATER(ah)) {
64                         if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
65                                 txRxAttenLocal = pModal->txRxAttenCh[i];
66                                 if (AR_SREV_9280_10_OR_LATER(ah)) {
67 @@ -2094,7 +2094,7 @@ static void ath9k_hw_get_def_gain_bounda
68                 pPdGainBoundaries[i] =
69                         min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i]);
70  
71 -               if ((i == 0) && !AR_SREV_5416_V20_OR_LATER(ah)) {
72 +               if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
73                         minDelta = pPdGainBoundaries[0] - 23;
74                         pPdGainBoundaries[0] = 23;
75                 } else {
76 @@ -2228,7 +2228,7 @@ static bool ath9k_hw_set_def_power_cal_t
77                       xpdGainValues[2]);
78  
79         for (i = 0; i < AR5416_MAX_CHAINS; i++) {
80 -               if (AR_SREV_5416_V20_OR_LATER(ah) &&
81 +               if (AR_SREV_5416_20_OR_LATER(ah) &&
82                     (ah->rxchainmask == 5 || ah->txchainmask == 5) &&
83                     (i != 0)) {
84                         regChainOffset = (i == 1) ? 0x2000 : 0x1000;
85 @@ -2262,7 +2262,7 @@ static bool ath9k_hw_set_def_power_cal_t
86                                                         numXpdGain);
87                         }
88  
89 -                       if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) {
90 +                       if ((i == 0) || AR_SREV_5416_20_OR_LATER(ah)) {
91                                 if (OLC_FOR_AR9280_20_LATER) {
92                                         REG_WRITE(ah,
93                                                 AR_PHY_TPCRG5 + regChainOffset,
94 --- a/drivers/net/wireless/ath9k/hw.c
95 +++ b/drivers/net/wireless/ath9k/hw.c
96 @@ -1160,7 +1160,7 @@ static void ath9k_hw_override_ini(struct
97         REG_SET_BIT(ah, AR_DIAG_SW, (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT));
98  
99  
100 -       if (!AR_SREV_5416_V20_OR_LATER(ah) ||
101 +       if (!AR_SREV_5416_20_OR_LATER(ah) ||
102             AR_SREV_9280_10_OR_LATER(ah))
103                 return;
104  
105 @@ -1262,7 +1262,7 @@ static int ath9k_hw_process_ini(struct a
106         REG_WRITE(ah, AR_PHY_ADC_SERIAL_CTL, AR_PHY_SEL_EXTERNAL_RADIO);
107         ah->eep_ops->set_addac(ah, chan);
108  
109 -       if (AR_SREV_5416_V22_OR_LATER(ah)) {
110 +       if (AR_SREV_5416_22_OR_LATER(ah)) {
111                 REG_WRITE_ARRAY(&ah->iniAddac, 1, regWrites);
112         } else {
113                 struct ar5416IniArray temp;
114 --- a/drivers/net/wireless/ath9k/mac.h
115 +++ b/drivers/net/wireless/ath9k/mac.h
116 @@ -17,7 +17,7 @@
117  #ifndef MAC_H
118  #define MAC_H
119  
120 -#define RXSTATUS_RATE(ah, ads) (AR_SREV_5416_V20_OR_LATER(ah) ?                \
121 +#define RXSTATUS_RATE(ah, ads) (AR_SREV_5416_20_OR_LATER(ah) ?         \
122                                 MS(ads->ds_rxstatus0, AR_RxRate) :      \
123                                 (ads->ds_rxstatus3 >> 2) & 0xFF)
124  
125 --- a/drivers/net/wireless/ath9k/reg.h
126 +++ b/drivers/net/wireless/ath9k/reg.h
127 @@ -161,10 +161,6 @@
128  #define AR_SREV_VERSION_9100                  0x014
129  
130  #define AR_SREV_9100(ah) ((ah->hw_version.macVersion) == AR_SREV_VERSION_9100)
131 -#define AR_SREV_5416_V20_OR_LATER(_ah) \
132 -       (AR_SREV_9100((_ah)) || AR_SREV_5416_20_OR_LATER(_ah))
133 -#define AR_SREV_5416_V22_OR_LATER(_ah) \
134 -       (AR_SREV_9100((_ah)) || AR_SREV_5416_22_OR_LATER(_ah))
135  
136  #define AR_ISR               0x0080
137  #define AR_ISR_RXOK          0x00000001
138 @@ -748,12 +744,19 @@
139  
140  #define AR_SREV_9100_OR_LATER(_ah) \
141         (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_5416_PCIE))
142 +
143 +#define AR_SREV_5416(_ah) \
144 +       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCI) || \
145 +        ((_ah)->hw_version.macVersion == AR_SREV_VERSION_5416_PCIE))
146  #define AR_SREV_5416_20_OR_LATER(_ah) \
147 -       (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9160) || \
148 -               ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_20))
149 +       (((AR_SREV_5416(_ah)) && \
150 +        ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_20)) || \
151 +        ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9100))
152  #define AR_SREV_5416_22_OR_LATER(_ah) \
153 -       (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9160) || \
154 -               ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_22))
155 +       (((AR_SREV_5416(_ah)) && \
156 +        ((_ah)->hw_version.macRev >= AR_SREV_REVISION_5416_22)) || \
157 +        ((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9100))
158 +
159  #define AR_SREV_9160(_ah) \
160         (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9160))
161  #define AR_SREV_9160_10_OR_LATER(_ah) \