Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2010-2011 Atheros Communications Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef MCI_H
0018 #define MCI_H
0019 
0020 #include "ar9003_mci.h"
0021 
0022 #define ATH_MCI_SCHED_BUF_SIZE      (16 * 16) /* 16 entries, 4 dword each */
0023 #define ATH_MCI_GPM_MAX_ENTRY       16
0024 #define ATH_MCI_GPM_BUF_SIZE        (ATH_MCI_GPM_MAX_ENTRY * 16)
0025 #define ATH_MCI_DEF_BT_PERIOD       40
0026 #define ATH_MCI_BDR_DUTY_CYCLE      20
0027 #define ATH_MCI_MAX_DUTY_CYCLE      90
0028 
0029 #define ATH_MCI_DEF_AGGR_LIMIT      6 /* in 0.24 ms */
0030 #define ATH_MCI_MAX_ACL_PROFILE     7
0031 #define ATH_MCI_MAX_SCO_PROFILE     1
0032 #define ATH_MCI_MAX_PROFILE     (ATH_MCI_MAX_ACL_PROFILE +\
0033                      ATH_MCI_MAX_SCO_PROFILE)
0034 
0035 #define ATH_MCI_INQUIRY_PRIO         62
0036 #define ATH_MCI_HI_PRIO              60
0037 #define ATH_MCI_NUM_BT_CHANNELS      79
0038 #define ATH_MCI_CONCUR_TX_SWITCH      5
0039 
0040 #define MCI_GPM_SET_CHANNEL_BIT(_p_gpm, _bt_chan)             \
0041     do {                                  \
0042         if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) {         \
0043             *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
0044                 (_bt_chan / 8)) |= (1 << (_bt_chan & 7)); \
0045         }                             \
0046     } while (0)
0047 
0048 #define MCI_GPM_CLR_CHANNEL_BIT(_p_gpm, _bt_chan)             \
0049     do {                                  \
0050         if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) {         \
0051             *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
0052                 (_bt_chan / 8)) &= ~(1 << (_bt_chan & 7));\
0053         }                             \
0054     } while (0)
0055 
0056 #define INC_PROF(_mci, _info) do {       \
0057         switch (_info->type) {       \
0058         case MCI_GPM_COEX_PROFILE_RFCOMM:\
0059             _mci->num_other_acl++;   \
0060             break;           \
0061         case MCI_GPM_COEX_PROFILE_A2DP:  \
0062             _mci->num_a2dp++;    \
0063             if (!_info->edr)     \
0064                 _mci->num_bdr++; \
0065             break;           \
0066         case MCI_GPM_COEX_PROFILE_HID:   \
0067             _mci->num_hid++;     \
0068             break;           \
0069         case MCI_GPM_COEX_PROFILE_BNEP:  \
0070             _mci->num_pan++;     \
0071             break;           \
0072         case MCI_GPM_COEX_PROFILE_VOICE: \
0073         case MCI_GPM_COEX_PROFILE_A2DPVO:\
0074             _mci->num_sco++;     \
0075             break;           \
0076         default:             \
0077             break;           \
0078         }                \
0079     } while (0)
0080 
0081 #define DEC_PROF(_mci, _info) do {       \
0082         switch (_info->type) {       \
0083         case MCI_GPM_COEX_PROFILE_RFCOMM:\
0084             _mci->num_other_acl--;   \
0085             break;           \
0086         case MCI_GPM_COEX_PROFILE_A2DP:  \
0087             _mci->num_a2dp--;    \
0088             if (!_info->edr)     \
0089                 _mci->num_bdr--; \
0090             break;           \
0091         case MCI_GPM_COEX_PROFILE_HID:   \
0092             _mci->num_hid--;     \
0093             break;           \
0094         case MCI_GPM_COEX_PROFILE_BNEP:  \
0095             _mci->num_pan--;     \
0096             break;           \
0097         case MCI_GPM_COEX_PROFILE_VOICE: \
0098         case MCI_GPM_COEX_PROFILE_A2DPVO:\
0099             _mci->num_sco--;     \
0100             break;           \
0101         default:             \
0102             break;           \
0103         }                \
0104     } while (0)
0105 
0106 #define NUM_PROF(_mci)  (_mci->num_other_acl + _mci->num_a2dp + \
0107              _mci->num_hid + _mci->num_pan + _mci->num_sco)
0108 
0109 struct ath_mci_profile_info {
0110     u8 type;
0111     u8 conn_handle;
0112     bool start;
0113     bool master;
0114     bool edr;
0115     u8 voice_type;
0116     u16 T;      /* Voice: Tvoice, HID: Tsniff,        in slots */
0117     u8 W;       /* Voice: Wvoice, HID: Sniff timeout, in slots */
0118     u8 A;       /*        HID: Sniff attempt, in slots */
0119     struct list_head list;
0120 };
0121 
0122 struct ath_mci_profile_status {
0123     bool is_critical;
0124     bool is_link;
0125     u8 conn_handle;
0126 };
0127 
0128 struct ath_mci_profile {
0129     struct list_head info;
0130     DECLARE_BITMAP(status, ATH_MCI_MAX_PROFILE);
0131     u16 aggr_limit;
0132     u8 num_mgmt;
0133     u8 num_sco;
0134     u8 num_a2dp;
0135     u8 num_hid;
0136     u8 num_pan;
0137     u8 num_other_acl;
0138     u8 num_bdr;
0139     u8 voice_priority;
0140 };
0141 
0142 struct ath_mci_buf {
0143     void *bf_addr;      /* virtual addr of desc */
0144     dma_addr_t bf_paddr;    /* physical addr of buffer */
0145     u32 bf_len;     /* len of data */
0146 };
0147 
0148 struct ath_mci_coex {
0149     struct ath_mci_buf sched_buf;
0150     struct ath_mci_buf gpm_buf;
0151 };
0152 
0153 void ath_mci_flush_profile(struct ath_mci_profile *mci);
0154 int ath_mci_setup(struct ath_softc *sc);
0155 void ath_mci_cleanup(struct ath_softc *sc);
0156 void ath_mci_intr(struct ath_softc *sc);
0157 void ath9k_mci_update_rssi(struct ath_softc *sc);
0158 
0159 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
0160 void ath_mci_enable(struct ath_softc *sc);
0161 void ath9k_mci_update_wlan_channels(struct ath_softc *sc, bool allow_all);
0162 void ath9k_mci_set_txpower(struct ath_softc *sc, bool setchannel,
0163                bool concur_tx);
0164 #else
0165 static inline void ath_mci_enable(struct ath_softc *sc)
0166 {
0167 }
0168 static inline void ath9k_mci_update_wlan_channels(struct ath_softc *sc,
0169                           bool allow_all)
0170 {
0171 }
0172 static inline void ath9k_mci_set_txpower(struct ath_softc *sc, bool setchannel,
0173                      bool concur_tx)
0174 {
0175 }
0176 #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
0177 
0178 #endif /* MCI_H*/