1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3 *
4 * Copyright(c) 2016 - 2017 Realtek Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
14 *
15 *****************************************************************************/
16 #include "mp_precomp.h"
17
18
19 VOID
ex_hal8723b_wifi_only_hw_config(IN struct wifi_only_cfg * pwifionlycfg)20 ex_hal8723b_wifi_only_hw_config(
21 IN struct wifi_only_cfg *pwifionlycfg
22 )
23 {
24 struct wifi_only_haldata *pwifionly_haldata = &pwifionlycfg->haldata_info;
25
26
27 halwifionly_write1byte(pwifionlycfg, 0x778, 0x3); /* Set pta for wifi first priority, 0x1 need to reference pta table to determine wifi and bt priority */
28 halwifionly_bitmaskwrite1byte(pwifionlycfg, 0x40, 0x20, 0x1);
29
30 /* Set Antenna path to Wifi */
31 halwifionly_write2byte(pwifionlycfg, 0x0765, 0x8); /* Set pta for wifi first priority, 0x0 need to reference pta table to determine wifi and bt priority */
32 halwifionly_write2byte(pwifionlycfg, 0x076e, 0xc);
33
34 halwifionly_write4byte(pwifionlycfg, 0x000006c0, 0xaaaaaaaa); /* pta table, 0xaaaaaaaa means wifi is higher priority than bt */
35 halwifionly_write4byte(pwifionlycfg, 0x000006c4, 0xaaaaaaaa);
36
37 halwifionly_bitmaskwrite1byte(pwifionlycfg, 0x67, 0x20, 0x1); /* BT select s0/s1 is controlled by WiFi */
38
39 /* 0x948 setting */
40 if (pwifionlycfg->chip_interface == WIFIONLY_INTF_PCI) {
41 /* HP Foxconn NGFF at S0
42 not sure HP pg correct or not(EEPROMBluetoothSingleAntPath), so here we just write
43 0x948=0x280 for HP HW id NIC. */
44 if (pwifionly_haldata->customer_id == CUSTOMER_HP_1) {
45 halwifionly_write4byte(pwifionlycfg, 0x948, 0x280);
46 halwifionly_phy_set_rf_reg(pwifionlycfg, 0, 0x1, 0xfffff, 0x0); /* WiFi TRx Mask off */
47 return;
48 }
49 }
50
51 if (pwifionly_haldata->efuse_pg_antnum == 2) {
52 halwifionly_write4byte(pwifionlycfg, 0x948, 0x0);
53 } else {
54 /* 3Attention !!! For 8723BU !!!!
55 For 8723BU single ant case: jira [USB-1237]
56 Because of 8723BU S1 has HW problem, we only can use S0 instead.
57 Whether Efuse 0xc3 [6] is 0 or 1, we should always use S0 and write 0x948 to 80/280
58
59 --------------------------------------------------
60 BT Team :
61 When in Single Ant case, Reg[0x948] has two case : 0x80 or 0x200
62 When in Two Ant case, Reg[0x948] has two case : 0x280 or 0x0
63 Efuse 0xc3 [6] Antenna Path
64 0xc3 [6] = 0 ==> S1 ==> 0x948 = 0/40/200
65 0xc3 [6] = 1 ==> S0 ==> 0x948 = 80/240/280 */
66
67 if (pwifionlycfg->chip_interface == WIFIONLY_INTF_USB)
68 halwifionly_write4byte(pwifionlycfg, 0x948, 0x80);
69 else {
70 if (pwifionly_haldata->efuse_pg_antpath == 0)
71 halwifionly_write4byte(pwifionlycfg, 0x948, 0x0);
72 else
73 halwifionly_write4byte(pwifionlycfg, 0x948, 0x280);
74 }
75
76 }
77
78
79 /* after 8723B F-cut, TRx Mask should be set when 0x948=0x0 or 0x280
80 PHY_SetRFReg(Adapter, 0, 0x1, 0xfffff, 0x780); WiFi TRx Mask on */
81 halwifionly_phy_set_rf_reg(pwifionlycfg, 0, 0x1, 0xfffff, 0x0); /*WiFi TRx Mask off */
82
83 }
84