mac80211: update to 2014-10-08
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 334-ath9k-allow-disabling-bands-via-platform-data.patch
1 From: Felix Fietkau <nbd@openwrt.org>
2 Date: Sat, 18 Oct 2014 18:27:23 +0200
3 Subject: [PATCH] ath9k: allow disabling bands via platform data
4
5 Some devices have multiple bands enables in the EEPROM data, even though
6 they are only calibrated for one. Allow platform data to disable
7 unsupported bands.
8
9 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
10 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 ---
12
13 --- a/drivers/net/wireless/ath/ath9k/hw.c
14 +++ b/drivers/net/wireless/ath/ath9k/hw.c
15 @@ -2344,17 +2344,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw
16 }
17
18 eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
19 - if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
20 - ath_err(common,
21 - "no band has been marked as supported in EEPROM\n");
22 - return -EINVAL;
23 +
24 + if (eeval & AR5416_OPFLAGS_11A) {
25 + if (ah->disable_5ghz)
26 + ath_warn(common, "disabling 5GHz band\n");
27 + else
28 + pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
29 }
30
31 - if (eeval & AR5416_OPFLAGS_11A)
32 - pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
33 + if (eeval & AR5416_OPFLAGS_11G) {
34 + if (ah->disable_2ghz)
35 + ath_warn(common, "disabling 2GHz band\n");
36 + else
37 + pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
38 + }
39
40 - if (eeval & AR5416_OPFLAGS_11G)
41 - pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
42 + if ((pCap->hw_caps & (ATH9K_HW_CAP_2GHZ | ATH9K_HW_CAP_5GHZ)) == 0) {
43 + ath_err(common, "both bands are disabled\n");
44 + return -EINVAL;
45 + }
46
47 if (AR_SREV_9485(ah) ||
48 AR_SREV_9285(ah) ||
49 --- a/drivers/net/wireless/ath/ath9k/hw.h
50 +++ b/drivers/net/wireless/ath/ath9k/hw.h
51 @@ -930,6 +930,8 @@ struct ath_hw {
52 bool is_clk_25mhz;
53 int (*get_mac_revision)(void);
54 int (*external_reset)(void);
55 + bool disable_2ghz;
56 + bool disable_5ghz;
57
58 const struct firmware *eeprom_blob;
59
60 --- a/drivers/net/wireless/ath/ath9k/init.c
61 +++ b/drivers/net/wireless/ath/ath9k/init.c
62 @@ -531,6 +531,8 @@ static int ath9k_init_softc(u16 devid, s
63 ah->is_clk_25mhz = pdata->is_clk_25mhz;
64 ah->get_mac_revision = pdata->get_mac_revision;
65 ah->external_reset = pdata->external_reset;
66 + ah->disable_2ghz = pdata->disable_2ghz;
67 + ah->disable_5ghz = pdata->disable_5ghz;
68 if (!pdata->endian_check)
69 ah->ah_flags |= AH_NO_EEP_SWAP;
70 }
71 --- a/include/linux/ath9k_platform.h
72 +++ b/include/linux/ath9k_platform.h
73 @@ -34,6 +34,8 @@ struct ath9k_platform_data {
74 bool endian_check;
75 bool is_clk_25mhz;
76 bool tx_gain_buffalo;
77 + bool disable_2ghz;
78 + bool disable_5ghz;
79
80 int (*get_mac_revision)(void);
81 int (*external_reset)(void);