aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-09-09 04:18:09 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-10-07 16:39:20 -0400
commit2e20250a2ce1f4a7ba7c83ccb62d9b7b9b96c736 (patch)
treef359dee35712538c6640fd0d1a559419315bbc24
parent4d6b228d84ba992ee13c90312c1ed539191c94b1 (diff)
ath9k: move btcoex core driver info to its own struct
There is some bluetooth coexistance data which is driver specific, stuff that into its own structure. Cc: Vasanthakumar Thiagarajan <vasanth@atheros.com> Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/ath/ath9k/ath9k.h11
-rw-r--r--drivers/net/wireless/ath/ath9k/btcoex.c73
-rw-r--r--drivers/net/wireless/ath/ath9k/btcoex.h16
-rw-r--r--drivers/net/wireless/ath/ath9k/main.c4
4 files changed, 55 insertions, 49 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 1d59f10f68da..831874c621ec 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -451,6 +451,16 @@ struct ath_ani {
451 struct timer_list timer; 451 struct timer_list timer;
452}; 452};
453 453
454struct ath_btcoex {
455 bool hw_timer_enabled;
456 spinlock_t btcoex_lock;
457 struct timer_list period_timer; /* Timer for BT period */
458 u32 bt_priority_cnt;
459 unsigned long bt_priority_time;
460 u32 btcoex_no_stomp; /* in usec */
461 u32 btcoex_period; /* in usec */
462};
463
454/********************/ 464/********************/
455/* LED Control */ 465/* LED Control */
456/********************/ 466/********************/
@@ -613,6 +623,7 @@ struct ath_softc {
613 struct ath_beacon_config cur_beacon_conf; 623 struct ath_beacon_config cur_beacon_conf;
614 struct delayed_work tx_complete_work; 624 struct delayed_work tx_complete_work;
615 struct ath_btcoex_info btcoex_info; 625 struct ath_btcoex_info btcoex_info;
626 struct ath_btcoex btcoex;
616}; 627};
617 628
618struct ath_wiphy { 629struct ath_wiphy {
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c
index e19a9c99fb20..e88a0a3f68f0 100644
--- a/drivers/net/wireless/ath/ath9k/btcoex.c
+++ b/drivers/net/wireless/ath/ath9k/btcoex.c
@@ -48,14 +48,14 @@ bool ath_btcoex_supported(u16 subsysid)
48 */ 48 */
49static void ath_detect_bt_priority(struct ath_softc *sc) 49static void ath_detect_bt_priority(struct ath_softc *sc)
50{ 50{
51 struct ath_btcoex_info *btinfo = &sc->btcoex_info; 51 struct ath_btcoex *btcoex = &sc->btcoex;
52 52
53 if (ath9k_hw_gpio_get(sc->sc_ah, btinfo->btpriority_gpio)) 53 if (ath9k_hw_gpio_get(sc->sc_ah, sc->btcoex_info.btpriority_gpio))
54 btinfo->bt_priority_cnt++; 54 btcoex->bt_priority_cnt++;
55 55
56 if (time_after(jiffies, btinfo->bt_priority_time + 56 if (time_after(jiffies, btcoex->bt_priority_time +
57 msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) { 57 msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) {
58 if (btinfo->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) { 58 if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) {
59 DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, 59 DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX,
60 "BT priority traffic detected"); 60 "BT priority traffic detected");
61 sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED; 61 sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED;
@@ -63,8 +63,8 @@ static void ath_detect_bt_priority(struct ath_softc *sc)
63 sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED; 63 sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED;
64 } 64 }
65 65
66 btinfo->bt_priority_cnt = 0; 66 btcoex->bt_priority_cnt = 0;
67 btinfo->bt_priority_time = jiffies; 67 btcoex->bt_priority_time = jiffies;
68 } 68 }
69} 69}
70 70
@@ -106,29 +106,30 @@ static void ath_btcoex_bt_stomp(struct ath_softc *sc,
106static void ath_btcoex_period_timer(unsigned long data) 106static void ath_btcoex_period_timer(unsigned long data)
107{ 107{
108 struct ath_softc *sc = (struct ath_softc *) data; 108 struct ath_softc *sc = (struct ath_softc *) data;
109 struct ath_btcoex *btcoex = &sc->btcoex;
109 struct ath_btcoex_info *btinfo = &sc->btcoex_info; 110 struct ath_btcoex_info *btinfo = &sc->btcoex_info;
110 111
111 ath_detect_bt_priority(sc); 112 ath_detect_bt_priority(sc);
112 113
113 spin_lock_bh(&btinfo->btcoex_lock); 114 spin_lock_bh(&btcoex->btcoex_lock);
114 115
115 ath_btcoex_bt_stomp(sc, btinfo, btinfo->bt_stomp_type); 116 ath_btcoex_bt_stomp(sc, btinfo, btinfo->bt_stomp_type);
116 117
117 spin_unlock_bh(&btinfo->btcoex_lock); 118 spin_unlock_bh(&btcoex->btcoex_lock);
118 119
119 if (btinfo->btcoex_period != btinfo->btcoex_no_stomp) { 120 if (btcoex->btcoex_period != btcoex->btcoex_no_stomp) {
120 if (btinfo->hw_timer_enabled) 121 if (btcoex->hw_timer_enabled)
121 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer); 122 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer);
122 123
123 ath_gen_timer_start(sc->sc_ah, 124 ath_gen_timer_start(sc->sc_ah,
124 btinfo->no_stomp_timer, 125 btinfo->no_stomp_timer,
125 (ath9k_hw_gettsf32(sc->sc_ah) + 126 (ath9k_hw_gettsf32(sc->sc_ah) +
126 btinfo->btcoex_no_stomp), 127 btcoex->btcoex_no_stomp),
127 btinfo->btcoex_no_stomp * 10); 128 btcoex->btcoex_no_stomp * 10);
128 btinfo->hw_timer_enabled = true; 129 btcoex->hw_timer_enabled = true;
129 } 130 }
130 131
131 mod_timer(&btinfo->period_timer, jiffies + 132 mod_timer(&btcoex->period_timer, jiffies +
132 msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD)); 133 msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD));
133} 134}
134 135
@@ -140,23 +141,25 @@ static void ath_btcoex_period_timer(unsigned long data)
140static void ath_btcoex_no_stomp_timer(void *arg) 141static void ath_btcoex_no_stomp_timer(void *arg)
141{ 142{
142 struct ath_softc *sc = (struct ath_softc *)arg; 143 struct ath_softc *sc = (struct ath_softc *)arg;
144 struct ath_btcoex *btcoex = &sc->btcoex;
143 struct ath_btcoex_info *btinfo = &sc->btcoex_info; 145 struct ath_btcoex_info *btinfo = &sc->btcoex_info;
144 146
145 DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, "no stomp timer running \n"); 147 DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, "no stomp timer running \n");
146 148
147 spin_lock_bh(&btinfo->btcoex_lock); 149 spin_lock_bh(&btcoex->btcoex_lock);
148 150
149 if (btinfo->bt_stomp_type == ATH_BTCOEX_STOMP_LOW) 151 if (btinfo->bt_stomp_type == ATH_BTCOEX_STOMP_LOW)
150 ath_btcoex_bt_stomp(sc, btinfo, ATH_BTCOEX_STOMP_NONE); 152 ath_btcoex_bt_stomp(sc, btinfo, ATH_BTCOEX_STOMP_NONE);
151 else if (btinfo->bt_stomp_type == ATH_BTCOEX_STOMP_ALL) 153 else if (btinfo->bt_stomp_type == ATH_BTCOEX_STOMP_ALL)
152 ath_btcoex_bt_stomp(sc, btinfo, ATH_BTCOEX_STOMP_LOW); 154 ath_btcoex_bt_stomp(sc, btinfo, ATH_BTCOEX_STOMP_LOW);
153 155
154 spin_unlock_bh(&btinfo->btcoex_lock); 156 spin_unlock_bh(&btcoex->btcoex_lock);
155} 157}
156 158
157static int ath_init_btcoex_info(struct ath_hw *hw, 159static int ath_init_btcoex_info(struct ath_hw *hw,
158 struct ath_btcoex_info *btcoex_info) 160 struct ath_btcoex_info *btcoex_info)
159{ 161{
162 struct ath_btcoex *btcoex = &hw->ah_sc->btcoex;
160 u32 i; 163 u32 i;
161 int qnum; 164 int qnum;
162 165
@@ -181,15 +184,15 @@ static int ath_init_btcoex_info(struct ath_hw *hw,
181 184
182 btcoex_info->bt_stomp_type = ATH_BTCOEX_STOMP_LOW; 185 btcoex_info->bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
183 186
184 btcoex_info->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000; 187 btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000;
185 188
186 btcoex_info->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * 189 btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) *
187 btcoex_info->btcoex_period / 100; 190 btcoex->btcoex_period / 100;
188 191
189 for (i = 0; i < 32; i++) 192 for (i = 0; i < 32; i++)
190 hw->hw_gen_timers.gen_timer_index[(debruijn32 << i) >> 27] = i; 193 hw->hw_gen_timers.gen_timer_index[(debruijn32 << i) >> 27] = i;
191 194
192 setup_timer(&btcoex_info->period_timer, ath_btcoex_period_timer, 195 setup_timer(&btcoex->period_timer, ath_btcoex_period_timer,
193 (unsigned long) hw->ah_sc); 196 (unsigned long) hw->ah_sc);
194 197
195 btcoex_info->no_stomp_timer = ath_gen_timer_alloc(hw, 198 btcoex_info->no_stomp_timer = ath_gen_timer_alloc(hw,
@@ -200,7 +203,7 @@ static int ath_init_btcoex_info(struct ath_hw *hw,
200 if (btcoex_info->no_stomp_timer == NULL) 203 if (btcoex_info->no_stomp_timer == NULL)
201 return -ENOMEM; 204 return -ENOMEM;
202 205
203 spin_lock_init(&btcoex_info->btcoex_lock); 206 spin_lock_init(&btcoex->btcoex_lock);
204 207
205 return 0; 208 return 0;
206} 209}
@@ -307,34 +310,34 @@ void ath9k_hw_btcoex_disable(struct ath_hw *ah)
307/* 310/*
308 * Pause btcoex timer and bt duty cycle timer 311 * Pause btcoex timer and bt duty cycle timer
309 */ 312 */
310void ath_btcoex_timer_pause(struct ath_softc *sc, 313void ath_btcoex_timer_pause(struct ath_softc *sc)
311 struct ath_btcoex_info *btinfo)
312{ 314{
315 struct ath_btcoex *btcoex = &sc->btcoex;
313 316
314 del_timer_sync(&btinfo->period_timer); 317 del_timer_sync(&btcoex->period_timer);
315 318
316 if (btinfo->hw_timer_enabled) 319 if (btcoex->hw_timer_enabled)
317 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer); 320 ath_gen_timer_stop(sc->sc_ah, sc->btcoex_info.no_stomp_timer);
318 321
319 btinfo->hw_timer_enabled = false; 322 btcoex->hw_timer_enabled = false;
320} 323}
321 324
322/* 325/*
323 * (Re)start btcoex timers 326 * (Re)start btcoex timers
324 */ 327 */
325void ath_btcoex_timer_resume(struct ath_softc *sc, 328void ath_btcoex_timer_resume(struct ath_softc *sc)
326 struct ath_btcoex_info *btinfo)
327{ 329{
330 struct ath_btcoex *btcoex = &sc->btcoex;
328 331
329 DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, "Starting btcoex timers"); 332 DPRINTF(sc->sc_ah, ATH_DBG_BTCOEX, "Starting btcoex timers");
330 333
331 /* make sure duty cycle timer is also stopped when resuming */ 334 /* make sure duty cycle timer is also stopped when resuming */
332 if (btinfo->hw_timer_enabled) 335 if (btcoex->hw_timer_enabled)
333 ath_gen_timer_stop(sc->sc_ah, btinfo->no_stomp_timer); 336 ath_gen_timer_stop(sc->sc_ah, sc->btcoex_info.no_stomp_timer);
334 337
335 btinfo->bt_priority_cnt = 0; 338 btcoex->bt_priority_cnt = 0;
336 btinfo->bt_priority_time = jiffies; 339 btcoex->bt_priority_time = jiffies;
337 sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED; 340 sc->sc_flags &= ~SC_OP_BT_PRIORITY_DETECTED;
338 341
339 mod_timer(&btinfo->period_timer, jiffies); 342 mod_timer(&btcoex->period_timer, jiffies);
340} 343}
diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h
index 297b027fd3c3..6cbbc14f9c39 100644
--- a/drivers/net/wireless/ath/ath9k/btcoex.h
+++ b/drivers/net/wireless/ath/ath9k/btcoex.h
@@ -70,13 +70,6 @@ struct ath_btcoex_info {
70 u32 bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */ 70 u32 bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */
71 u32 bt_coex_weights; /* Register setting for AR_BT_COEX_WEIGHT */ 71 u32 bt_coex_weights; /* Register setting for AR_BT_COEX_WEIGHT */
72 u32 bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */ 72 u32 bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */
73 u32 btcoex_no_stomp; /* in usec */
74 u32 btcoex_period; /* in usec */
75 u32 bt_priority_cnt;
76 unsigned long bt_priority_time;
77 bool hw_timer_enabled;
78 spinlock_t btcoex_lock;
79 struct timer_list period_timer; /* Timer for BT period */
80 struct ath_gen_timer *no_stomp_timer; /*Timer for no BT stomping*/ 73 struct ath_gen_timer *no_stomp_timer; /*Timer for no BT stomping*/
81}; 74};
82 75
@@ -84,16 +77,15 @@ bool ath_btcoex_supported(u16 subsysid);
84int ath9k_hw_btcoex_init(struct ath_hw *ah); 77int ath9k_hw_btcoex_init(struct ath_hw *ah);
85void ath9k_hw_btcoex_enable(struct ath_hw *ah); 78void ath9k_hw_btcoex_enable(struct ath_hw *ah);
86void ath9k_hw_btcoex_disable(struct ath_hw *ah); 79void ath9k_hw_btcoex_disable(struct ath_hw *ah);
87void ath_btcoex_timer_resume(struct ath_softc *sc, 80
88 struct ath_btcoex_info *btinfo); 81void ath_btcoex_timer_resume(struct ath_softc *sc);
89void ath_btcoex_timer_pause(struct ath_softc *sc, 82void ath_btcoex_timer_pause(struct ath_softc *sc);
90 struct ath_btcoex_info *btinfo);
91 83
92static inline void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info, 84static inline void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info,
93 u32 bt_weight, 85 u32 bt_weight,
94 u32 wlan_weight) 86 u32 wlan_weight)
95{ 87{
96 btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) | 88 btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
97 SM(wlan_weight, AR_BTCOEX_WL_WGHT); 89 SM(wlan_weight, AR_BTCOEX_WL_WGHT);
98} 90}
99 91
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 68d8dd9602dc..612e83678b23 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -2013,7 +2013,7 @@ static int ath9k_start(struct ieee80211_hw *hw)
2013 2013
2014 ath_pcie_aspm_disable(sc); 2014 ath_pcie_aspm_disable(sc);
2015 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE) 2015 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE)
2016 ath_btcoex_timer_resume(sc, &sc->btcoex_info); 2016 ath_btcoex_timer_resume(sc);
2017 } 2017 }
2018 2018
2019mutex_unlock: 2019mutex_unlock:
@@ -2152,7 +2152,7 @@ static void ath9k_stop(struct ieee80211_hw *hw)
2152 if (sc->sc_flags & SC_OP_BTCOEX_ENABLED) { 2152 if (sc->sc_flags & SC_OP_BTCOEX_ENABLED) {
2153 ath9k_hw_btcoex_disable(sc->sc_ah); 2153 ath9k_hw_btcoex_disable(sc->sc_ah);
2154 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE) 2154 if (sc->btcoex_info.btcoex_scheme == ATH_BTCOEX_CFG_3WIRE)
2155 ath_btcoex_timer_pause(sc, &sc->btcoex_info); 2155 ath_btcoex_timer_pause(sc);
2156 } 2156 }
2157 2157
2158 /* make sure h/w will not generate any interrupt 2158 /* make sure h/w will not generate any interrupt