Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include "ath9k.h" |
| 18 | |
| 19 | /********************************/ |
| 20 | /* LED functions */ |
| 21 | /********************************/ |
| 22 | |
| 23 | static void ath_led_blink_work(struct work_struct *work) |
| 24 | { |
| 25 | struct ath_softc *sc = container_of(work, struct ath_softc, |
| 26 | ath_led_blink_work.work); |
| 27 | |
| 28 | if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED)) |
| 29 | return; |
| 30 | |
| 31 | if ((sc->led_on_duration == ATH_LED_ON_DURATION_IDLE) || |
| 32 | (sc->led_off_duration == ATH_LED_OFF_DURATION_IDLE)) |
| 33 | ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); |
| 34 | else |
| 35 | ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, |
| 36 | (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0); |
| 37 | |
| 38 | ieee80211_queue_delayed_work(sc->hw, |
| 39 | &sc->ath_led_blink_work, |
| 40 | (sc->sc_flags & SC_OP_LED_ON) ? |
| 41 | msecs_to_jiffies(sc->led_off_duration) : |
| 42 | msecs_to_jiffies(sc->led_on_duration)); |
| 43 | |
| 44 | sc->led_on_duration = sc->led_on_cnt ? |
| 45 | max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25) : |
| 46 | ATH_LED_ON_DURATION_IDLE; |
| 47 | sc->led_off_duration = sc->led_off_cnt ? |
| 48 | max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10) : |
| 49 | ATH_LED_OFF_DURATION_IDLE; |
| 50 | sc->led_on_cnt = sc->led_off_cnt = 0; |
| 51 | if (sc->sc_flags & SC_OP_LED_ON) |
| 52 | sc->sc_flags &= ~SC_OP_LED_ON; |
| 53 | else |
| 54 | sc->sc_flags |= SC_OP_LED_ON; |
| 55 | } |
| 56 | |
| 57 | static void ath_led_brightness(struct led_classdev *led_cdev, |
| 58 | enum led_brightness brightness) |
| 59 | { |
| 60 | struct ath_led *led = container_of(led_cdev, struct ath_led, led_cdev); |
| 61 | struct ath_softc *sc = led->sc; |
| 62 | |
| 63 | switch (brightness) { |
| 64 | case LED_OFF: |
| 65 | if (led->led_type == ATH_LED_ASSOC || |
| 66 | led->led_type == ATH_LED_RADIO) { |
| 67 | ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, |
| 68 | (led->led_type == ATH_LED_RADIO)); |
| 69 | sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; |
| 70 | if (led->led_type == ATH_LED_RADIO) |
| 71 | sc->sc_flags &= ~SC_OP_LED_ON; |
| 72 | } else { |
| 73 | sc->led_off_cnt++; |
| 74 | } |
| 75 | break; |
| 76 | case LED_FULL: |
| 77 | if (led->led_type == ATH_LED_ASSOC) { |
| 78 | sc->sc_flags |= SC_OP_LED_ASSOCIATED; |
| 79 | ieee80211_queue_delayed_work(sc->hw, |
| 80 | &sc->ath_led_blink_work, 0); |
| 81 | } else if (led->led_type == ATH_LED_RADIO) { |
| 82 | ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); |
| 83 | sc->sc_flags |= SC_OP_LED_ON; |
| 84 | } else { |
| 85 | sc->led_on_cnt++; |
| 86 | } |
| 87 | break; |
| 88 | default: |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | static int ath_register_led(struct ath_softc *sc, struct ath_led *led, |
| 94 | char *trigger) |
| 95 | { |
| 96 | int ret; |
| 97 | |
| 98 | led->sc = sc; |
| 99 | led->led_cdev.name = led->name; |
| 100 | led->led_cdev.default_trigger = trigger; |
| 101 | led->led_cdev.brightness_set = ath_led_brightness; |
| 102 | |
| 103 | ret = led_classdev_register(wiphy_dev(sc->hw->wiphy), &led->led_cdev); |
| 104 | if (ret) |
| 105 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL, |
| 106 | "Failed to register led:%s", led->name); |
| 107 | else |
| 108 | led->registered = 1; |
| 109 | return ret; |
| 110 | } |
| 111 | |
| 112 | static void ath_unregister_led(struct ath_led *led) |
| 113 | { |
| 114 | if (led->registered) { |
| 115 | led_classdev_unregister(&led->led_cdev); |
| 116 | led->registered = 0; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | void ath_deinit_leds(struct ath_softc *sc) |
| 121 | { |
| 122 | ath_unregister_led(&sc->assoc_led); |
| 123 | sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; |
| 124 | ath_unregister_led(&sc->tx_led); |
| 125 | ath_unregister_led(&sc->rx_led); |
| 126 | ath_unregister_led(&sc->radio_led); |
| 127 | ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); |
| 128 | } |
| 129 | |
| 130 | void ath_init_leds(struct ath_softc *sc) |
| 131 | { |
| 132 | char *trigger; |
| 133 | int ret; |
| 134 | |
| 135 | if (AR_SREV_9287(sc->sc_ah)) |
| 136 | sc->sc_ah->led_pin = ATH_LED_PIN_9287; |
| 137 | else |
| 138 | sc->sc_ah->led_pin = ATH_LED_PIN_DEF; |
| 139 | |
| 140 | /* Configure gpio 1 for output */ |
| 141 | ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin, |
| 142 | AR_GPIO_OUTPUT_MUX_AS_OUTPUT); |
| 143 | /* LED off, active low */ |
| 144 | ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); |
| 145 | |
| 146 | INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work); |
| 147 | |
| 148 | trigger = ieee80211_get_radio_led_name(sc->hw); |
| 149 | snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), |
| 150 | "ath9k-%s::radio", wiphy_name(sc->hw->wiphy)); |
| 151 | ret = ath_register_led(sc, &sc->radio_led, trigger); |
| 152 | sc->radio_led.led_type = ATH_LED_RADIO; |
| 153 | if (ret) |
| 154 | goto fail; |
| 155 | |
| 156 | trigger = ieee80211_get_assoc_led_name(sc->hw); |
| 157 | snprintf(sc->assoc_led.name, sizeof(sc->assoc_led.name), |
| 158 | "ath9k-%s::assoc", wiphy_name(sc->hw->wiphy)); |
| 159 | ret = ath_register_led(sc, &sc->assoc_led, trigger); |
| 160 | sc->assoc_led.led_type = ATH_LED_ASSOC; |
| 161 | if (ret) |
| 162 | goto fail; |
| 163 | |
| 164 | trigger = ieee80211_get_tx_led_name(sc->hw); |
| 165 | snprintf(sc->tx_led.name, sizeof(sc->tx_led.name), |
| 166 | "ath9k-%s::tx", wiphy_name(sc->hw->wiphy)); |
| 167 | ret = ath_register_led(sc, &sc->tx_led, trigger); |
| 168 | sc->tx_led.led_type = ATH_LED_TX; |
| 169 | if (ret) |
| 170 | goto fail; |
| 171 | |
| 172 | trigger = ieee80211_get_rx_led_name(sc->hw); |
| 173 | snprintf(sc->rx_led.name, sizeof(sc->rx_led.name), |
| 174 | "ath9k-%s::rx", wiphy_name(sc->hw->wiphy)); |
| 175 | ret = ath_register_led(sc, &sc->rx_led, trigger); |
| 176 | sc->rx_led.led_type = ATH_LED_RX; |
| 177 | if (ret) |
| 178 | goto fail; |
| 179 | |
| 180 | return; |
| 181 | |
| 182 | fail: |
| 183 | cancel_delayed_work_sync(&sc->ath_led_blink_work); |
| 184 | ath_deinit_leds(sc); |
| 185 | } |
| 186 | |
| 187 | /*******************/ |
| 188 | /* Rfkill */ |
| 189 | /*******************/ |
| 190 | |
| 191 | static bool ath_is_rfkill_set(struct ath_softc *sc) |
| 192 | { |
| 193 | struct ath_hw *ah = sc->sc_ah; |
| 194 | |
| 195 | return ath9k_hw_gpio_get(ah, ah->rfkill_gpio) == |
| 196 | ah->rfkill_polarity; |
| 197 | } |
| 198 | |
| 199 | void ath9k_rfkill_poll_state(struct ieee80211_hw *hw) |
| 200 | { |
| 201 | struct ath_wiphy *aphy = hw->priv; |
| 202 | struct ath_softc *sc = aphy->sc; |
| 203 | bool blocked = !!ath_is_rfkill_set(sc); |
| 204 | |
| 205 | wiphy_rfkill_set_hw_state(hw->wiphy, blocked); |
| 206 | } |
| 207 | |
| 208 | void ath_start_rfkill_poll(struct ath_softc *sc) |
| 209 | { |
| 210 | struct ath_hw *ah = sc->sc_ah; |
| 211 | |
| 212 | if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT) |
| 213 | wiphy_rfkill_start_polling(sc->hw->wiphy); |
| 214 | } |
| 215 | |
| 216 | /******************/ |
| 217 | /* BTCOEX */ |
| 218 | /******************/ |
| 219 | |
| 220 | /* |
| 221 | * Detects if there is any priority bt traffic |
| 222 | */ |
| 223 | static void ath_detect_bt_priority(struct ath_softc *sc) |
| 224 | { |
| 225 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 226 | struct ath_hw *ah = sc->sc_ah; |
| 227 | |
| 228 | if (ath9k_hw_gpio_get(sc->sc_ah, ah->btcoex_hw.btpriority_gpio)) |
| 229 | btcoex->bt_priority_cnt++; |
| 230 | |
| 231 | if (time_after(jiffies, btcoex->bt_priority_time + |
| 232 | msecs_to_jiffies(ATH_BT_PRIORITY_TIME_THRESHOLD))) { |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 233 | sc->sc_flags &= ~(SC_OP_BT_PRIORITY_DETECTED | SC_OP_BT_SCAN); |
| 234 | /* Detect if colocated bt started scanning */ |
| 235 | if (btcoex->bt_priority_cnt >= ATH_BT_CNT_SCAN_THRESHOLD) { |
| 236 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_BTCOEX, |
| 237 | "BT scan detected"); |
| 238 | sc->sc_flags |= (SC_OP_BT_SCAN | |
| 239 | SC_OP_BT_PRIORITY_DETECTED); |
| 240 | } else if (btcoex->bt_priority_cnt >= ATH_BT_CNT_THRESHOLD) { |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 241 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_BTCOEX, |
| 242 | "BT priority traffic detected"); |
| 243 | sc->sc_flags |= SC_OP_BT_PRIORITY_DETECTED; |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | btcoex->bt_priority_cnt = 0; |
| 247 | btcoex->bt_priority_time = jiffies; |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | /* |
| 252 | * Configures appropriate weight based on stomp type. |
| 253 | */ |
| 254 | static void ath9k_btcoex_bt_stomp(struct ath_softc *sc, |
| 255 | enum ath_stomp_type stomp_type) |
| 256 | { |
| 257 | struct ath_hw *ah = sc->sc_ah; |
| 258 | |
| 259 | switch (stomp_type) { |
| 260 | case ATH_BTCOEX_STOMP_ALL: |
| 261 | ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, |
| 262 | AR_STOMP_ALL_WLAN_WGHT); |
| 263 | break; |
| 264 | case ATH_BTCOEX_STOMP_LOW: |
| 265 | ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, |
| 266 | AR_STOMP_LOW_WLAN_WGHT); |
| 267 | break; |
| 268 | case ATH_BTCOEX_STOMP_NONE: |
| 269 | ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, |
| 270 | AR_STOMP_NONE_WLAN_WGHT); |
| 271 | break; |
| 272 | default: |
| 273 | ath_print(ath9k_hw_common(ah), ATH_DBG_BTCOEX, |
| 274 | "Invalid Stomptype\n"); |
| 275 | break; |
| 276 | } |
| 277 | |
| 278 | ath9k_hw_btcoex_enable(ah); |
| 279 | } |
| 280 | |
| 281 | static void ath9k_gen_timer_start(struct ath_hw *ah, |
| 282 | struct ath_gen_timer *timer, |
| 283 | u32 timer_next, |
| 284 | u32 timer_period) |
| 285 | { |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 286 | ath9k_hw_gen_timer_start(ah, timer, timer_next, timer_period); |
| 287 | |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame^] | 288 | if ((ah->imask & ATH9K_INT_GENTIMER) == 0) { |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 289 | ath9k_hw_set_interrupts(ah, 0); |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame^] | 290 | ah->imask |= ATH9K_INT_GENTIMER; |
| 291 | ath9k_hw_set_interrupts(ah, ah->imask); |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
| 295 | static void ath9k_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer) |
| 296 | { |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 297 | struct ath_gen_timer_table *timer_table = &ah->hw_gen_timers; |
| 298 | |
| 299 | ath9k_hw_gen_timer_stop(ah, timer); |
| 300 | |
| 301 | /* if no timer is enabled, turn off interrupt mask */ |
| 302 | if (timer_table->timer_mask.val == 0) { |
| 303 | ath9k_hw_set_interrupts(ah, 0); |
Pavel Roskin | 3069168 | 2010-03-31 18:05:31 -0400 | [diff] [blame^] | 304 | ah->imask &= ~ATH9K_INT_GENTIMER; |
| 305 | ath9k_hw_set_interrupts(ah, ah->imask); |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 306 | } |
| 307 | } |
| 308 | |
| 309 | /* |
| 310 | * This is the master bt coex timer which runs for every |
| 311 | * 45ms, bt traffic will be given priority during 55% of this |
| 312 | * period while wlan gets remaining 45% |
| 313 | */ |
| 314 | static void ath_btcoex_period_timer(unsigned long data) |
| 315 | { |
| 316 | struct ath_softc *sc = (struct ath_softc *) data; |
| 317 | struct ath_hw *ah = sc->sc_ah; |
| 318 | struct ath_btcoex *btcoex = &sc->btcoex; |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 319 | u32 timer_period; |
| 320 | bool is_btscan; |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 321 | |
| 322 | ath_detect_bt_priority(sc); |
| 323 | |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 324 | is_btscan = sc->sc_flags & SC_OP_BT_SCAN; |
| 325 | |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 326 | spin_lock_bh(&btcoex->btcoex_lock); |
| 327 | |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 328 | ath9k_btcoex_bt_stomp(sc, is_btscan ? ATH_BTCOEX_STOMP_ALL : |
| 329 | btcoex->bt_stomp_type); |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 330 | |
| 331 | spin_unlock_bh(&btcoex->btcoex_lock); |
| 332 | |
| 333 | if (btcoex->btcoex_period != btcoex->btcoex_no_stomp) { |
| 334 | if (btcoex->hw_timer_enabled) |
| 335 | ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer); |
| 336 | |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 337 | timer_period = is_btscan ? btcoex->btscan_no_stomp : |
| 338 | btcoex->btcoex_no_stomp; |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 339 | ath9k_gen_timer_start(ah, |
| 340 | btcoex->no_stomp_timer, |
| 341 | (ath9k_hw_gettsf32(ah) + |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 342 | timer_period), timer_period * 10); |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 343 | btcoex->hw_timer_enabled = true; |
| 344 | } |
| 345 | |
| 346 | mod_timer(&btcoex->period_timer, jiffies + |
| 347 | msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD)); |
| 348 | } |
| 349 | |
| 350 | /* |
| 351 | * Generic tsf based hw timer which configures weight |
| 352 | * registers to time slice between wlan and bt traffic |
| 353 | */ |
| 354 | static void ath_btcoex_no_stomp_timer(void *arg) |
| 355 | { |
| 356 | struct ath_softc *sc = (struct ath_softc *)arg; |
| 357 | struct ath_hw *ah = sc->sc_ah; |
| 358 | struct ath_btcoex *btcoex = &sc->btcoex; |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 359 | bool is_btscan = sc->sc_flags & SC_OP_BT_SCAN; |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 360 | |
| 361 | ath_print(ath9k_hw_common(ah), ATH_DBG_BTCOEX, |
| 362 | "no stomp timer running \n"); |
| 363 | |
| 364 | spin_lock_bh(&btcoex->btcoex_lock); |
| 365 | |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 366 | if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_LOW || is_btscan) |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 367 | ath9k_btcoex_bt_stomp(sc, ATH_BTCOEX_STOMP_NONE); |
| 368 | else if (btcoex->bt_stomp_type == ATH_BTCOEX_STOMP_ALL) |
| 369 | ath9k_btcoex_bt_stomp(sc, ATH_BTCOEX_STOMP_LOW); |
| 370 | |
| 371 | spin_unlock_bh(&btcoex->btcoex_lock); |
| 372 | } |
| 373 | |
| 374 | int ath_init_btcoex_timer(struct ath_softc *sc) |
| 375 | { |
| 376 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 377 | |
| 378 | btcoex->btcoex_period = ATH_BTCOEX_DEF_BT_PERIOD * 1000; |
| 379 | btcoex->btcoex_no_stomp = (100 - ATH_BTCOEX_DEF_DUTY_CYCLE) * |
| 380 | btcoex->btcoex_period / 100; |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 381 | btcoex->btscan_no_stomp = (100 - ATH_BTCOEX_BTSCAN_DUTY_CYCLE) * |
| 382 | btcoex->btcoex_period / 100; |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 383 | |
| 384 | setup_timer(&btcoex->period_timer, ath_btcoex_period_timer, |
| 385 | (unsigned long) sc); |
| 386 | |
| 387 | spin_lock_init(&btcoex->btcoex_lock); |
| 388 | |
| 389 | btcoex->no_stomp_timer = ath_gen_timer_alloc(sc->sc_ah, |
| 390 | ath_btcoex_no_stomp_timer, |
| 391 | ath_btcoex_no_stomp_timer, |
| 392 | (void *) sc, AR_FIRST_NDP_TIMER); |
| 393 | |
| 394 | if (!btcoex->no_stomp_timer) |
| 395 | return -ENOMEM; |
| 396 | |
| 397 | return 0; |
| 398 | } |
| 399 | |
| 400 | /* |
| 401 | * (Re)start btcoex timers |
| 402 | */ |
| 403 | void ath9k_btcoex_timer_resume(struct ath_softc *sc) |
| 404 | { |
| 405 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 406 | struct ath_hw *ah = sc->sc_ah; |
| 407 | |
| 408 | ath_print(ath9k_hw_common(ah), ATH_DBG_BTCOEX, |
| 409 | "Starting btcoex timers"); |
| 410 | |
| 411 | /* make sure duty cycle timer is also stopped when resuming */ |
| 412 | if (btcoex->hw_timer_enabled) |
| 413 | ath9k_gen_timer_stop(sc->sc_ah, btcoex->no_stomp_timer); |
| 414 | |
| 415 | btcoex->bt_priority_cnt = 0; |
| 416 | btcoex->bt_priority_time = jiffies; |
Vasanthakumar Thiagarajan | 58da131 | 2010-01-21 11:17:27 +0530 | [diff] [blame] | 417 | sc->sc_flags &= ~(SC_OP_BT_PRIORITY_DETECTED | SC_OP_BT_SCAN); |
Sujith | 0fca65c | 2010-01-08 10:36:00 +0530 | [diff] [blame] | 418 | |
| 419 | mod_timer(&btcoex->period_timer, jiffies); |
| 420 | } |
| 421 | |
| 422 | |
| 423 | /* |
| 424 | * Pause btcoex timer and bt duty cycle timer |
| 425 | */ |
| 426 | void ath9k_btcoex_timer_pause(struct ath_softc *sc) |
| 427 | { |
| 428 | struct ath_btcoex *btcoex = &sc->btcoex; |
| 429 | struct ath_hw *ah = sc->sc_ah; |
| 430 | |
| 431 | del_timer_sync(&btcoex->period_timer); |
| 432 | |
| 433 | if (btcoex->hw_timer_enabled) |
| 434 | ath9k_gen_timer_stop(ah, btcoex->no_stomp_timer); |
| 435 | |
| 436 | btcoex->hw_timer_enabled = false; |
| 437 | } |