2 * Copyright (c) 2010-2011 Atheros Communications Inc.
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.
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.
20 #include "ar9003_mci.h"
22 #define ATH_MCI_SCHED_BUF_SIZE (16 * 16) /* 16 entries, 4 dword each */
23 #define ATH_MCI_GPM_MAX_ENTRY 16
24 #define ATH_MCI_GPM_BUF_SIZE (ATH_MCI_GPM_MAX_ENTRY * 16)
25 #define ATH_MCI_DEF_BT_PERIOD 40
26 #define ATH_MCI_BDR_DUTY_CYCLE 20
27 #define ATH_MCI_MAX_DUTY_CYCLE 90
29 #define ATH_MCI_DEF_AGGR_LIMIT 6 /* in 0.24 ms */
30 #define ATH_MCI_MAX_ACL_PROFILE 7
31 #define ATH_MCI_MAX_SCO_PROFILE 1
32 #define ATH_MCI_MAX_PROFILE (ATH_MCI_MAX_ACL_PROFILE +\
33 ATH_MCI_MAX_SCO_PROFILE)
35 #define ATH_MCI_INQUIRY_PRIO 62
36 #define ATH_MCI_HI_PRIO 60
37 #define ATH_MCI_NUM_BT_CHANNELS 79
38 #define ATH_MCI_CONCUR_TX_SWITCH 5
40 #define MCI_GPM_SET_CHANNEL_BIT(_p_gpm, _bt_chan) \
42 if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) { \
43 *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
44 (_bt_chan / 8)) |= (1 << (_bt_chan & 7)); \
48 #define MCI_GPM_CLR_CHANNEL_BIT(_p_gpm, _bt_chan) \
50 if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) { \
51 *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
52 (_bt_chan / 8)) &= ~(1 << (_bt_chan & 7));\
56 #define INC_PROF(_mci, _info) do { \
57 switch (_info->type) { \
58 case MCI_GPM_COEX_PROFILE_RFCOMM:\
59 _mci->num_other_acl++; \
61 case MCI_GPM_COEX_PROFILE_A2DP: \
66 case MCI_GPM_COEX_PROFILE_HID: \
69 case MCI_GPM_COEX_PROFILE_BNEP: \
72 case MCI_GPM_COEX_PROFILE_VOICE: \
73 case MCI_GPM_COEX_PROFILE_A2DPVO:\
81 #define DEC_PROF(_mci, _info) do { \
82 switch (_info->type) { \
83 case MCI_GPM_COEX_PROFILE_RFCOMM:\
84 _mci->num_other_acl--; \
86 case MCI_GPM_COEX_PROFILE_A2DP: \
91 case MCI_GPM_COEX_PROFILE_HID: \
94 case MCI_GPM_COEX_PROFILE_BNEP: \
97 case MCI_GPM_COEX_PROFILE_VOICE: \
98 case MCI_GPM_COEX_PROFILE_A2DPVO:\
106 #define NUM_PROF(_mci) (_mci->num_other_acl + _mci->num_a2dp + \
107 _mci->num_hid + _mci->num_pan + _mci->num_sco)
109 struct ath_mci_profile_info
{
116 u16 T
; /* Voice: Tvoice, HID: Tsniff, in slots */
117 u8 W
; /* Voice: Wvoice, HID: Sniff timeout, in slots */
118 u8 A
; /* HID: Sniff attempt, in slots */
119 struct list_head list
;
122 struct ath_mci_profile_status
{
128 struct ath_mci_profile
{
129 struct list_head info
;
130 DECLARE_BITMAP(status
, ATH_MCI_MAX_PROFILE
);
143 void *bf_addr
; /* virtual addr of desc */
144 dma_addr_t bf_paddr
; /* physical addr of buffer */
145 u32 bf_len
; /* len of data */
148 struct ath_mci_coex
{
149 struct ath_mci_buf sched_buf
;
150 struct ath_mci_buf gpm_buf
;
153 void ath_mci_flush_profile(struct ath_mci_profile
*mci
);
154 int ath_mci_setup(struct ath_softc
*sc
);
155 void ath_mci_cleanup(struct ath_softc
*sc
);
156 void ath_mci_intr(struct ath_softc
*sc
);
157 void ath9k_mci_update_rssi(struct ath_softc
*sc
);
159 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
160 void ath_mci_enable(struct ath_softc
*sc
);
161 void ath9k_mci_update_wlan_channels(struct ath_softc
*sc
, bool allow_all
);
162 void ath9k_mci_set_txpower(struct ath_softc
*sc
, bool setchannel
,
165 static inline void ath_mci_enable(struct ath_softc
*sc
)
168 static inline void ath9k_mci_update_wlan_channels(struct ath_softc
*sc
,
172 static inline void ath9k_mci_set_txpower(struct ath_softc
*sc
, bool setchannel
,
176 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */