ath9k: fix enabling PC-OEM card support (#16624)
[openwrt.git] / package / kernel / mac80211 / patches / 560-ath9k_pcoem_optional.patch
1 --- a/drivers/net/wireless/ath/ath9k/Kconfig
2 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
3 @@ -133,6 +133,11 @@ config ATH9K_RFKILL
4           seconds. Turn off to save power, but enable it if you have
5           a platform that can toggle the RF-Kill GPIO.
6  
7 +config ATH9K_PCOEM
8 +       bool "Atheros ath9k support for PC OEM cards" if EXPERT
9 +       depends on ATH9K
10 +       default y
11 +
12  config ATH9K_HTC
13         tristate "Atheros HTC based wireless cards support"
14         depends on m
15 --- a/drivers/net/wireless/ath/ath9k/Makefile
16 +++ b/drivers/net/wireless/ath/ath9k/Makefile
17 @@ -31,7 +31,6 @@ ath9k_hw-y:=  \
18                 ar5008_phy.o \
19                 ar9002_calib.o \
20                 ar9003_calib.o \
21 -               ar9003_rtt.o \
22                 calib.o \
23                 eeprom.o \
24                 eeprom_def.o \
25 @@ -48,6 +47,8 @@ ath9k_hw-$(CPTCFG_ATH9K_WOW) += ar9003_w
26  
27  ath9k_hw-$(CPTCFG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \
28                                            ar9003_mci.o
29 +ath9k_hw-$(CPTCFG_ATH9K_PCOEM) += ar9003_rtt.o
30 +
31  obj-$(CPTCFG_ATH9K_HW) += ath9k_hw.o
32  
33  obj-$(CPTCFG_ATH9K_COMMON) += ath9k_common.o
34 --- a/drivers/net/wireless/ath/ath9k/ar9003_rtt.h
35 +++ b/drivers/net/wireless/ath/ath9k/ar9003_rtt.h
36 @@ -17,6 +17,7 @@
37  #ifndef AR9003_RTT_H
38  #define AR9003_RTT_H
39  
40 +#ifdef CPTCFG_ATH9K_PCOEM
41  void ar9003_hw_rtt_enable(struct ath_hw *ah);
42  void ar9003_hw_rtt_disable(struct ath_hw *ah);
43  void ar9003_hw_rtt_set_mask(struct ath_hw *ah, u32 rtt_mask);
44 @@ -25,5 +26,40 @@ void ar9003_hw_rtt_load_hist(struct ath_
45  void ar9003_hw_rtt_fill_hist(struct ath_hw *ah);
46  void ar9003_hw_rtt_clear_hist(struct ath_hw *ah);
47  bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan);
48 +#else
49 +static inline void ar9003_hw_rtt_enable(struct ath_hw *ah)
50 +{
51 +}
52 +
53 +static inline void ar9003_hw_rtt_disable(struct ath_hw *ah)
54 +{
55 +}
56 +
57 +static inline void ar9003_hw_rtt_set_mask(struct ath_hw *ah, u32 rtt_mask)
58 +{
59 +}
60 +
61 +static inline bool ar9003_hw_rtt_force_restore(struct ath_hw *ah)
62 +{
63 +       return false;
64 +}
65 +
66 +static inline void ar9003_hw_rtt_load_hist(struct ath_hw *ah)
67 +{
68 +}
69 +
70 +static inline void ar9003_hw_rtt_fill_hist(struct ath_hw *ah)
71 +{
72 +}
73 +
74 +static inline void ar9003_hw_rtt_clear_hist(struct ath_hw *ah)
75 +{
76 +}
77 +
78 +static inline bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan)
79 +{
80 +       return false;
81 +}
82 +#endif
83  
84  #endif
85 --- a/drivers/net/wireless/ath/ath9k/hw.h
86 +++ b/drivers/net/wireless/ath/ath9k/hw.h
87 @@ -244,13 +244,20 @@ enum ath9k_hw_caps {
88         ATH9K_HW_CAP_2GHZ                       = BIT(11),
89         ATH9K_HW_CAP_5GHZ                       = BIT(12),
90         ATH9K_HW_CAP_APM                        = BIT(13),
91 +#ifdef CPTCFG_ATH9K_PCOEM
92         ATH9K_HW_CAP_RTT                        = BIT(14),
93         ATH9K_HW_CAP_MCI                        = BIT(15),
94 -       ATH9K_HW_CAP_DFS                        = BIT(16),
95 -       ATH9K_HW_WOW_DEVICE_CAPABLE             = BIT(17),
96 -       ATH9K_HW_CAP_PAPRD                      = BIT(18),
97 -       ATH9K_HW_CAP_FCC_BAND_SWITCH            = BIT(19),
98 -       ATH9K_HW_CAP_BT_ANT_DIV                 = BIT(20),
99 +       ATH9K_HW_WOW_DEVICE_CAPABLE             = BIT(16),
100 +       ATH9K_HW_CAP_BT_ANT_DIV                 = BIT(17),
101 +#else
102 +       ATH9K_HW_CAP_RTT                        = 0,
103 +       ATH9K_HW_CAP_MCI                        = 0,
104 +       ATH9K_HW_WOW_DEVICE_CAPABLE             = 0,
105 +       ATH9K_HW_CAP_BT_ANT_DIV                 = 0,
106 +#endif
107 +       ATH9K_HW_CAP_DFS                        = BIT(18),
108 +       ATH9K_HW_CAP_PAPRD                      = BIT(19),
109 +       ATH9K_HW_CAP_FCC_BAND_SWITCH            = BIT(20),
110  };
111  
112  /*
113 --- a/drivers/net/wireless/ath/ath9k/init.c
114 +++ b/drivers/net/wireless/ath/ath9k/init.c
115 @@ -355,6 +355,9 @@ static void ath9k_init_pcoem_platform(st
116         struct ath9k_hw_capabilities *pCap = &ah->caps;
117         struct ath_common *common = ath9k_hw_common(ah);
118  
119 +       if (!IS_ENABLED(CPTCFG_ATH9K_PCOEM))
120 +               return;
121 +
122         if (common->bus_ops->ath_bus_type != ATH_PCI)
123                 return;
124  
125 --- a/drivers/net/wireless/ath/ath9k/pci.c
126 +++ b/drivers/net/wireless/ath/ath9k/pci.c
127 @@ -30,6 +30,7 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
128         { PCI_VDEVICE(ATHEROS, 0x0029) }, /* PCI   */
129         { PCI_VDEVICE(ATHEROS, 0x002A) }, /* PCI-E */
130  
131 +#ifdef CPTCFG_ATH9K_PCOEM
132         { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
133                          0x002A,
134                          PCI_VENDOR_ID_AZWAVE,
135 @@ -82,6 +83,7 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
136                          PCI_VENDOR_ID_AZWAVE,
137                          0x2C37),
138           .driver_data = ATH9K_PCI_BT_ANT_DIV },
139 +#endif
140  
141         { PCI_VDEVICE(ATHEROS, 0x002B) }, /* PCI-E */
142         { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
143 @@ -102,6 +104,7 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
144  
145         { PCI_VDEVICE(ATHEROS, 0x0030) }, /* PCI-E  AR9300 */
146  
147 +#ifdef CPTCFG_ATH9K_PCOEM
148         /* PCI-E CUS198 */
149         { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
150                          0x0032,
151 @@ -294,10 +297,12 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
152                          PCI_VENDOR_ID_ASUSTEK,
153                          0x850D),
154           .driver_data = ATH9K_PCI_NO_PLL_PWRSAVE },
155 +#endif
156  
157         { PCI_VDEVICE(ATHEROS, 0x0032) }, /* PCI-E  AR9485 */
158         { PCI_VDEVICE(ATHEROS, 0x0033) }, /* PCI-E  AR9580 */
159  
160 +#ifdef CPTCFG_ATH9K_PCOEM
161         /* PCI-E CUS217 */
162         { PCI_DEVICE_SUB(PCI_VENDOR_ID_ATHEROS,
163                          0x0034,
164 @@ -657,6 +662,7 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
165         /* PCI-E AR9565 (WB335) */
166         { PCI_VDEVICE(ATHEROS, 0x0036),
167           .driver_data = ATH9K_PCI_BT_ANT_DIV },
168 +#endif
169  
170         { PCI_VDEVICE(ATHEROS, 0xabcd) }, /* PCI-E  internal chip default ID */
171         { 0 }
172 --- a/drivers/net/wireless/ath/ath9k/reg.h
173 +++ b/drivers/net/wireless/ath/ath9k/reg.h
174 @@ -891,10 +891,21 @@
175         (AR_SREV_9330((_ah)) && \
176          ((_ah)->hw_version.macRev == AR_SREV_REVISION_9330_12))
177  
178 +#ifdef CPTCFG_ATH9K_PCOEM
179 +#define AR_SREV_9462(_ah) \
180 +       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462))
181  #define AR_SREV_9485(_ah) \
182         (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485))
183 +#define AR_SREV_9565(_ah) \
184 +       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565))
185 +#else
186 +#define AR_SREV_9462(_ah) 0
187 +#define AR_SREV_9485(_ah) 0
188 +#define AR_SREV_9565(_ah) 0
189 +#endif
190 +
191  #define AR_SREV_9485_11_OR_LATER(_ah) \
192 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9485) && \
193 +       (AR_SREV_9485(_ah) && \
194          ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9485_11))
195  #define AR_SREV_9485_OR_LATER(_ah) \
196         (((_ah)->hw_version.macVersion >= AR_SREV_VERSION_9485))
197 @@ -910,34 +921,30 @@
198      (AR_SREV_9285_12_OR_LATER(_ah) && \
199       ((REG_READ(_ah, AR_AN_SYNTH9) & 0x7) == 0x1))
200  
201 -#define AR_SREV_9462(_ah) \
202 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462))
203  #define AR_SREV_9462_20(_ah) \
204 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \
205 +       (AR_SREV_9462(_ah) && \
206          ((_ah)->hw_version.macRev == AR_SREV_REVISION_9462_20))
207  #define AR_SREV_9462_21(_ah) \
208 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \
209 +       (AR_SREV_9462(_ah) && \
210          ((_ah)->hw_version.macRev == AR_SREV_REVISION_9462_21))
211  #define AR_SREV_9462_20_OR_LATER(_ah) \
212 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \
213 +       (AR_SREV_9462(_ah) && \
214          ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9462_20))
215  #define AR_SREV_9462_21_OR_LATER(_ah) \
216 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9462) && \
217 +       (AR_SREV_9462(_ah) && \
218          ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9462_21))
219  
220 -#define AR_SREV_9565(_ah) \
221 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565))
222  #define AR_SREV_9565_10(_ah) \
223 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \
224 +       (AR_SREV_9565(_ah) && \
225          ((_ah)->hw_version.macRev == AR_SREV_REVISION_9565_10))
226  #define AR_SREV_9565_101(_ah) \
227 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \
228 +       (AR_SREV_9565(_ah) && \
229          ((_ah)->hw_version.macRev == AR_SREV_REVISION_9565_101))
230  #define AR_SREV_9565_11(_ah) \
231 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \
232 +       (AR_SREV_9565(_ah) && \
233          ((_ah)->hw_version.macRev == AR_SREV_REVISION_9565_11))
234  #define AR_SREV_9565_11_OR_LATER(_ah) \
235 -       (((_ah)->hw_version.macVersion == AR_SREV_VERSION_9565) && \
236 +       (AR_SREV_9565(_ah) && \
237          ((_ah)->hw_version.macRev >= AR_SREV_REVISION_9565_11))
238  
239  #define AR_SREV_9550(_ah) \
240 --- a/.local-symbols
241 +++ b/.local-symbols
242 @@ -129,6 +129,7 @@ ATH9K_HW=
243  ATH9K_COMMON=
244  ATH9K_DFS_DEBUGFS=
245  ATH9K_BTCOEX_SUPPORT=
246 +ATH9K_PCOEM=
247  ATH9K=
248  ATH9K_PCI=
249  ATH9K_AHB=