blob: 45568196c59abc09c1ef1ecb0c4478b438ea2f35 [file] [log] [blame]
Vasanthakumar Thiagarajan17d50d12009-08-26 21:08:44 +05301/*
2 * Copyright (c) 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#ifndef BTCOEX_H
18#define BTCOEX_H
19
Vasanthakumar Thiagarajanf14462c2009-08-26 21:08:46 +053020#define ATH_WLANACTIVE_GPIO 5
21#define ATH_BTACTIVE_GPIO 6
22
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +053023#define ATH_BTCOEX_DEF_BT_PERIOD 45
24#define ATH_BTCOEX_DEF_DUTY_CYCLE 55
25#define ATH_BTCOEX_BMISS_THRESH 50
26
27#define ATH_BT_PRIORITY_TIME_THRESHOLD 1000 /* ms */
28#define ATH_BT_CNT_THRESHOLD 3
29
Vasanthakumar Thiagarajan22f25d02009-08-26 21:08:47 +053030enum ath_btcoex_scheme {
31 ATH_BTCOEX_CFG_NONE,
32 ATH_BTCOEX_CFG_2WIRE,
33 ATH_BTCOEX_CFG_3WIRE,
34};
35
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +053036enum ath_stomp_type {
37 ATH_BTCOEX_NO_STOMP,
38 ATH_BTCOEX_STOMP_ALL,
39 ATH_BTCOEX_STOMP_LOW,
40 ATH_BTCOEX_STOMP_NONE
41};
42
43enum ath_bt_mode {
44 ATH_BT_COEX_MODE_LEGACY, /* legacy rx_clear mode */
45 ATH_BT_COEX_MODE_UNSLOTTED, /* untimed/unslotted mode */
46 ATH_BT_COEX_MODE_SLOTTED, /* slotted mode */
47 ATH_BT_COEX_MODE_DISALBED, /* coexistence disabled */
48};
49
50struct ath_btcoex_config {
51 u8 bt_time_extend;
52 bool bt_txstate_extend;
53 bool bt_txframe_extend;
54 enum ath_bt_mode bt_mode; /* coexistence mode */
55 bool bt_quiet_collision;
56 bool bt_rxclear_polarity; /* invert rx_clear as WLAN_ACTIVE*/
57 u8 bt_priority_time;
58 u8 bt_first_slot_time;
59 bool bt_hold_rx_clear;
60};
61
Vasanthakumar Thiagarajanf14462c2009-08-26 21:08:46 +053062struct ath_btcoex_info {
Vasanthakumar Thiagarajan22f25d02009-08-26 21:08:47 +053063 enum ath_btcoex_scheme btcoex_scheme;
Vasanthakumar Thiagarajanf14462c2009-08-26 21:08:46 +053064 u8 wlanactive_gpio;
65 u8 btactive_gpio;
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +053066 u8 btpriority_gpio;
67 u8 bt_duty_cycle; /* BT duty cycle in percentage */
68 int bt_stomp_type; /* Types of BT stomping */
69 u32 bt_coex_mode; /* Register setting for AR_BT_COEX_MODE */
70 u32 bt_coex_weights; /* Register setting for AR_BT_COEX_WEIGHT */
71 u32 bt_coex_mode2; /* Register setting for AR_BT_COEX_MODE2 */
72 u32 btcoex_no_stomp; /* in usec */
73 u32 btcoex_period; /* in usec */
74 u32 bt_priority_cnt;
75 unsigned long bt_priority_time;
76 bool hw_timer_enabled;
77 spinlock_t btcoex_lock;
78 struct timer_list period_timer; /* Timer for BT period */
79 struct ath_gen_timer *no_stomp_timer; /*Timer for no BT stomping*/
Vasanthakumar Thiagarajanf14462c2009-08-26 21:08:46 +053080};
81
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +053082int ath9k_hw_btcoex_init(struct ath_hw *ah);
Vasanthakumar Thiagarajan17d50d12009-08-26 21:08:44 +053083void ath9k_hw_btcoex_enable(struct ath_hw *ah);
84void ath9k_hw_btcoex_disable(struct ath_hw *ah);
Vasanthakumar Thiagarajan17739122009-08-26 21:08:50 +053085void ath_btcoex_timer_resume(struct ath_softc *sc,
86 struct ath_btcoex_info *btinfo);
87void ath_btcoex_timer_pause(struct ath_softc *sc,
88 struct ath_btcoex_info *btinfo);
89
90static inline void ath_btcoex_set_weight(struct ath_btcoex_info *btcoex_info,
91 u32 bt_weight,
92 u32 wlan_weight)
93{
94 btcoex_info->bt_coex_weights = SM(bt_weight, AR_BTCOEX_BT_WGHT) |
95 SM(wlan_weight, AR_BTCOEX_WL_WGHT);
96}
Vasanthakumar Thiagarajan17d50d12009-08-26 21:08:44 +053097
98#endif