summaryrefslogtreecommitdiff
path: root/package/mac80211/patches/409-ath9k-add-wndr3700-antenna-initialization.patch
blob: 83eabaf09dad0bfa2fcb268f46279d71aa0e6ecf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -14,6 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "linux/ath9k_platform.h"
 #include "ath9k.h"
 
 static char *dev_info = "ath9k";
@@ -546,6 +547,8 @@ static int ath9k_init_softc(u16 devid, s
 	pdata = (struct ath9k_platform_data *) sc->dev->platform_data;
 	if (!pdata)
 		ah->ah_flags |= AH_USE_EEPROM;
+	else
+		sc->quirk_wndr3700 = pdata->quirk_wndr3700;
 
 	common = ath9k_hw_common(ah);
 	common->ops = &ath9k_common_ops;
@@ -671,6 +674,24 @@ void ath9k_set_hw_capab(struct ath_softc
 	SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
 }
 
+#ifdef CONFIG_ATHEROS_AR71XX
+static void wndr3700_init_antenna(struct ath_hw *ah)
+{
+	ath9k_hw_cfg_output(ah, 6, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+	ath9k_hw_cfg_output(ah, 7, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+	ath9k_hw_cfg_output(ah, 8, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+	ath9k_hw_cfg_output(ah, 9, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
+
+	/* select the first antenna group */
+	ath9k_hw_set_gpio(ah, 6, 0);
+	ath9k_hw_set_gpio(ah, 7, 1);
+	ath9k_hw_set_gpio(ah, 8, 0);
+	ath9k_hw_set_gpio(ah, 9, 1);
+}
+#else
+static inline void wndr3700_init_antenna(struct ath_hw *ah) {}
+#endif /* CONFIG_ATHEROS_AR71XX */
+
 int ath9k_init_device(u16 devid, struct ath_softc *sc, u16 subsysid,
 		    const struct ath_bus_ops *bus_ops)
 {
@@ -689,6 +710,9 @@ int ath9k_init_device(u16 devid, struct 
 	common = ath9k_hw_common(ah);
 	ath9k_set_hw_capab(sc, hw);
 
+	if (sc->quirk_wndr3700)
+		wndr3700_init_antenna(ah);
+
 	/* Initialize regulatory */
 	error = ath_regd_init(&common->regulatory, sc->hw->wiphy,
 			      ath9k_reg_notifier);
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -511,6 +511,8 @@ struct ath_softc {
 	struct ath_beacon_config cur_beacon_conf;
 	struct delayed_work tx_complete_work;
 	struct ath_btcoex btcoex;
+
+	unsigned long quirk_wndr3700:1;
 };
 
 struct ath_wiphy {
--- a/include/linux/ath9k_platform.h
+++ b/include/linux/ath9k_platform.h
@@ -24,6 +24,8 @@
 struct ath9k_platform_data {
 	u16 eeprom_data[ATH9K_PLAT_EEP_MAX_WORDS];
 	u8 *macaddr;
+
+	unsigned long quirk_wndr3700:1;
 };
 
 #endif /* _LINUX_ATH9K_PLATFORM_H */