Staging: rtl8812ae: Add Realtek 8821 PCI WIFI driver
[platform/adaptation/renesas_rcar/renesas_kernel.git] / drivers / staging / rtl8821ae / rtl8821ae / hal_bt_coexist.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2009-2010  Realtek Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  * The full GNU General Public License is included in this distribution in the
19  * file called LICENSE.
20  *
21  * Contact Information:
22  * wlanfae <wlanfae@realtek.com>
23  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24  * Hsinchu 300, Taiwan.
25  * Larry Finger <Larry.Finger@lwfinger.net>
26  *
27  *****************************************************************************/
28
29 #ifndef __RTL8821AE_HAL_BT_COEXIST_H__
30 #define __RTL8821AE_HAL_BT_COEXIST_H__
31
32 #include "../wifi.h"
33
34 /* The reg define is for 8723 */
35 #define REG_HIGH_PRIORITY_TXRX                  0x770
36 #define REG_LOW_PRIORITY_TXRX                   0x774
37
38 #define BT_FW_COEX_THRESH_TOL                   6
39 #define BT_FW_COEX_THRESH_20                    20
40 #define BT_FW_COEX_THRESH_23                    23
41 #define BT_FW_COEX_THRESH_25                    25
42 #define BT_FW_COEX_THRESH_30                    30
43 #define BT_FW_COEX_THRESH_35                    35
44 #define BT_FW_COEX_THRESH_40                    40
45 #define BT_FW_COEX_THRESH_45                    45
46 #define BT_FW_COEX_THRESH_47                    47
47 #define BT_FW_COEX_THRESH_50                    50
48 #define BT_FW_COEX_THRESH_55                    55
49
50 #define BT_COEX_STATE_BT30                              BIT(0)
51 #define BT_COEX_STATE_WIFI_HT20                 BIT(1)
52 #define BT_COEX_STATE_WIFI_HT40                 BIT(2)
53 #define BT_COEX_STATE_WIFI_LEGACY               BIT(3)
54
55 #define BT_COEX_STATE_WIFI_RSSI_LOW             BIT(4)
56 #define BT_COEX_STATE_WIFI_RSSI_MEDIUM  BIT(5)
57 #define BT_COEX_STATE_WIFI_RSSI_HIGH    BIT(6)
58 #define BT_COEX_STATE_DEC_BT_POWER              BIT(7)
59
60 #define BT_COEX_STATE_WIFI_IDLE                 BIT(8)
61 #define BT_COEX_STATE_WIFI_UPLINK               BIT(9)
62 #define BT_COEX_STATE_WIFI_DOWNLINK             BIT(10)
63
64 #define BT_COEX_STATE_BT_INQ_PAGE                       BIT(11)
65 #define BT_COEX_STATE_BT_IDLE                   BIT(12)
66 #define BT_COEX_STATE_BT_UPLINK                 BIT(13)
67 #define BT_COEX_STATE_BT_DOWNLINK               BIT(14)
68
69 #define BT_COEX_STATE_HOLD_FOR_BT_OPERATION     BIT(15)
70 #define BT_COEX_STATE_BT_RSSI_LOW               BIT(19)
71
72 #define BT_COEX_STATE_PROFILE_HID               BIT(20)
73 #define BT_COEX_STATE_PROFILE_A2DP              BIT(21)
74 #define BT_COEX_STATE_PROFILE_PAN               BIT(22)
75 #define BT_COEX_STATE_PROFILE_SCO               BIT(23)
76
77 #define BT_COEX_STATE_WIFI_RSSI_1_LOW           BIT(24)
78 #define BT_COEX_STATE_WIFI_RSSI_1_MEDIUM        BIT(25)
79 #define BT_COEX_STATE_WIFI_RSSI_1_HIGH          BIT(26)
80
81 #define BT_COEX_STATE_BTINFO_COMMON                     BIT(30)
82 #define BT_COEX_STATE_BTINFO_B_HID_SCOESCO      BIT(31)
83 #define BT_COEX_STATE_BTINFO_B_FTP_A2DP         BIT(29)
84
85 #define BT_COEX_STATE_BT_CNT_LEVEL_0            BIT(0)
86 #define BT_COEX_STATE_BT_CNT_LEVEL_1            BIT(1)
87 #define BT_COEX_STATE_BT_CNT_LEVEL_2            BIT(2)
88 #define BT_COEX_STATE_BT_CNT_LEVEL_3            BIT(3)
89
90 #define BT_RSSI_STATE_HIGH                      0
91 #define BT_RSSI_STATE_MEDIUM            1
92 #define BT_RSSI_STATE_LOW                       2
93 #define BT_RSSI_STATE_STAY_HIGH         3
94 #define BT_RSSI_STATE_STAY_MEDIUM       4
95 #define BT_RSSI_STATE_STAY_LOW          5
96
97 #define BT_AGCTABLE_OFF                         0
98 #define BT_AGCTABLE_ON                          1
99 #define BT_BB_BACKOFF_OFF                       0
100 #define BT_BB_BACKOFF_ON                        1
101 #define BT_FW_NAV_OFF                           0
102 #define BT_FW_NAV_ON                            1
103
104 #define BT_COEX_MECH_NONE                       0
105 #define BT_COEX_MECH_SCO                        1
106 #define BT_COEX_MECH_HID                        2
107 #define BT_COEX_MECH_A2DP                       3
108 #define BT_COEX_MECH_PAN                        4
109 #define BT_COEX_MECH_HID_A2DP           5
110 #define BT_COEX_MECH_HID_PAN            6
111 #define BT_COEX_MECH_PAN_A2DP           7
112 #define BT_COEX_MECH_HID_SCO_ESCO       8
113 #define BT_COEX_MECH_FTP_A2DP           9
114 #define BT_COEX_MECH_COMMON                     10
115 #define BT_COEX_MECH_MAX                        11
116
117 #define BT_DBG_PROFILE_NONE                     0
118 #define BT_DBG_PROFILE_SCO                      1
119 #define BT_DBG_PROFILE_HID                      2
120 #define BT_DBG_PROFILE_A2DP                     3
121 #define BT_DBG_PROFILE_PAN                      4
122 #define BT_DBG_PROFILE_HID_A2DP         5
123 #define BT_DBG_PROFILE_HID_PAN          6
124 #define BT_DBG_PROFILE_PAN_A2DP         7
125 #define BT_DBG_PROFILE_MAX                      9
126
127 #define BTINFO_B_FTP                                    BIT(7)
128 #define BTINFO_B_A2DP                                   BIT(6)
129 #define BTINFO_B_HID                                    BIT(5)
130 #define BTINFO_B_SCO_BUSY                               BIT(4)
131 #define BTINFO_B_ACL_BUSY                               BIT(3)
132 #define BTINFO_B_INQ_PAGE                               BIT(2)
133 #define BTINFO_B_SCO_ESCO                               BIT(1)
134 #define BTINFO_B_CONNECTION                             BIT(0)
135
136
137 void rtl8821ae_btdm_coex_all_off(struct ieee80211_hw *hw);
138 void rtl8821ae_dm_bt_fw_coex_all_off(struct ieee80211_hw *hw);
139
140 void rtl8821ae_dm_bt_sw_coex_all_off(struct ieee80211_hw *hw);
141 void rtl8821ae_dm_bt_hw_coex_all_off(struct ieee80211_hw *hw);
142 long rtl8821ae_dm_bt_get_rx_ss(struct ieee80211_hw *hw);
143 void rtl8821ae_dm_bt_balance(struct ieee80211_hw *hw,
144                         bool b_balance_on, u8 ms0, u8 ms1);
145 void rtl8821ae_dm_bt_agc_table(struct ieee80211_hw *hw, u8 tyep);
146 void rtl8821ae_dm_bt_bb_back_off_level(struct ieee80211_hw *hw, u8 type);
147 u8 rtl8821ae_dm_bt_check_coex_rssi_state(struct ieee80211_hw *hw,
148                                                 u8      level_num, u8   rssi_thresh, u8 rssi_thresh1);
149 u8 rtl8821ae_dm_bt_check_coex_rssi_state1(struct ieee80211_hw *hw,
150                                         u8  level_num, u8   rssi_thresh, u8 rssi_thresh1);
151 void _rtl8821ae_dm_bt_check_wifi_state(struct ieee80211_hw *hw);
152 void rtl8821ae_dm_bt_reject_ap_aggregated_packet(struct ieee80211_hw *hw,
153                         bool b_reject);
154
155 #if 0
156 VOID
157 BTDM_PWDBMonitor(
158                 PADAPTER        Adapter
159         );
160
161 BOOLEAN
162 BTDM_DIGByBTRSSI(
163                         PADAPTER        Adapter
164         );
165 #endif
166 bool rtl8821ae_dm_bt_is_coexist_state_changed(struct ieee80211_hw *hw);
167 bool rtl8821ae_dm_bt_is_wifi_up_link(struct ieee80211_hw *hw);
168 #endif
169