GNU Linux-libre 4.14.290-gnu1
[releases.git] / drivers / staging / rtlwifi / btcoexist / halbtc8822bwifionly.c
1 /******************************************************************************
2  *
3  * Copyright(c) 2016  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  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25 #include "halbt_precomp.h"
26
27 void ex_hal8822b_wifi_only_hw_config(struct wifi_only_cfg *wifionlycfg)
28 {
29         /*BB control*/
30         halwifionly_phy_set_bb_reg(wifionlycfg, 0x4c, 0x01800000, 0x2);
31         /*SW control*/
32         halwifionly_phy_set_bb_reg(wifionlycfg, 0xcb4, 0xff, 0x77);
33         /*antenna mux switch */
34         halwifionly_phy_set_bb_reg(wifionlycfg, 0x974, 0x300, 0x3);
35
36         halwifionly_phy_set_bb_reg(wifionlycfg, 0x1990, 0x300, 0x0);
37
38         halwifionly_phy_set_bb_reg(wifionlycfg, 0xcbc, 0x80000, 0x0);
39         /*switch to WL side controller and gnt_wl gnt_bt debug signal */
40         halwifionly_phy_set_bb_reg(wifionlycfg, 0x70, 0xff000000, 0x0e);
41         /*gnt_wl=1 , gnt_bt=0*/
42         halwifionly_phy_set_bb_reg(wifionlycfg, 0x1704, 0xffffffff, 0x7700);
43         halwifionly_phy_set_bb_reg(wifionlycfg, 0x1700, 0xffffffff, 0xc00f0038);
44 }
45
46 void ex_hal8822b_wifi_only_scannotify(struct wifi_only_cfg *wifionlycfg,
47                                       u8 is_5g)
48 {
49         hal8822b_wifi_only_switch_antenna(wifionlycfg, is_5g);
50 }
51
52 void ex_hal8822b_wifi_only_switchbandnotify(struct wifi_only_cfg *wifionlycfg,
53                                             u8 is_5g)
54 {
55         hal8822b_wifi_only_switch_antenna(wifionlycfg, is_5g);
56 }
57
58 void hal8822b_wifi_only_switch_antenna(struct wifi_only_cfg *wifionlycfg,
59                                        u8 is_5g)
60 {
61         if (is_5g)
62                 halwifionly_phy_set_bb_reg(wifionlycfg, 0xcbc, 0x300, 0x1);
63         else
64                 halwifionly_phy_set_bb_reg(wifionlycfg, 0xcbc, 0x300, 0x2);
65 }