1 #include "mp_precomp.h"
3 static struct rfe_type_8821c_wifi_only gl_rfe_type_8821c_1ant;
4 static struct rfe_type_8821c_wifi_only *rfe_type = &gl_rfe_type_8821c_1ant;
8 VOID hal8821c_wifi_only_switch_antenna(
9 IN struct wifi_only_cfg *pwifionlycfg,
13 boolean switch_polatiry_inverse = false;
15 u8 pos_type, ctrl_type;
17 if (!rfe_type->ext_ant_switch_exist)
20 /* swap control polarity if use different switch control polarity*/
21 /* Normal switch polarity for DPDT, 0xcb4[29:28] = 2b'01 => BTG to Main, WLG to Aux, 0xcb4[29:28] = 2b'10 => BTG to Aux, WLG to Main */
22 /* Normal switch polarity for SPDT, 0xcb4[29:28] = 2b'01 => Ant to BTG, 0xcb4[29:28] = 2b'10 => Ant to WLG */
23 if (rfe_type->ext_ant_switch_ctrl_polarity)
24 switch_polatiry_inverse = !switch_polatiry_inverse;
26 /* swap control polarity if 1-Ant at Aux */
27 if (rfe_type->ant_at_main_port == false)
28 switch_polatiry_inverse = !switch_polatiry_inverse;
31 pos_type = BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_TO_WLA;
33 pos_type = BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_TO_WLG;
37 case BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_TO_WLA:
40 case BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_TO_WLG:
41 if (!rfe_type->wlg_Locate_at_btg)
42 switch_polatiry_inverse = !switch_polatiry_inverse;
46 if (pwifionlycfg->haldata_info.ant_div_cfg)
47 ctrl_type = BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_CTRL_BY_ANTDIV;
49 ctrl_type = BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_CTRL_BY_BBSW;
54 case BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_CTRL_BY_BBSW:
55 halwifionly_phy_set_bb_reg(pwifionlycfg, 0x4c, 0x01800000, 0x2);
57 /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as control pin */
58 halwifionly_phy_set_bb_reg(pwifionlycfg, 0xcb4, 0x000000ff, 0x77);
60 regval_0xcb7 = (switch_polatiry_inverse == false ? 0x1 : 0x2);
62 /* 0xcb4[29:28] = 2b'01 for no switch_polatiry_inverse, DPDT_SEL_N =1, DPDT_SEL_P =0 */
63 halwifionly_phy_set_bb_reg(pwifionlycfg, 0xcb4, 0x30000000, regval_0xcb7);
66 case BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_CTRL_BY_ANTDIV:
67 halwifionly_phy_set_bb_reg(pwifionlycfg, 0x4c, 0x01800000, 0x2);
69 /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as control pin */
70 halwifionly_phy_set_bb_reg(pwifionlycfg, 0xcb4, 0x000000ff, 0x88);
72 /* no regval_0xcb7 setup required, because antenna switch control value by antenna diversity */
81 VOID halbtc8821c_wifi_only_set_rfe_type(
82 IN struct wifi_only_cfg *pwifionlycfg
86 /* the following setup should be got from Efuse in the future */
87 rfe_type->rfe_module_type = (pwifionlycfg->haldata_info.rfe_type) & 0x1f;
89 rfe_type->ext_ant_switch_ctrl_polarity = 0;
91 switch (rfe_type->rfe_module_type) {
94 rfe_type->ext_ant_switch_exist = true;
95 rfe_type->ext_ant_switch_type =
96 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_USE_DPDT; /*2-Ant, DPDT, WLG*/
97 rfe_type->wlg_Locate_at_btg = false;
98 rfe_type->ant_at_main_port = true;
101 rfe_type->ext_ant_switch_exist = true;
102 rfe_type->ext_ant_switch_type =
103 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_USE_SPDT; /*1-Ant, Main, DPDT or SPDT, WLG */
104 rfe_type->wlg_Locate_at_btg = false;
105 rfe_type->ant_at_main_port = true;
108 rfe_type->ext_ant_switch_exist = true;
109 rfe_type->ext_ant_switch_type =
110 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_USE_SPDT; /*1-Ant, Main, DPDT or SPDT, BTG */
111 rfe_type->wlg_Locate_at_btg = true;
112 rfe_type->ant_at_main_port = true;
115 rfe_type->ext_ant_switch_exist = true;
116 rfe_type->ext_ant_switch_type =
117 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_USE_DPDT; /*1-Ant, Aux, DPDT, WLG */
118 rfe_type->wlg_Locate_at_btg = false;
119 rfe_type->ant_at_main_port = false;
122 rfe_type->ext_ant_switch_exist = true;
123 rfe_type->ext_ant_switch_type =
124 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_USE_DPDT; /*1-Ant, Aux, DPDT, BTG */
125 rfe_type->wlg_Locate_at_btg = true;
126 rfe_type->ant_at_main_port = false;
129 rfe_type->ext_ant_switch_exist = false; /*2-Ant, no antenna switch, WLG*/
130 rfe_type->ext_ant_switch_type =
131 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_NONE;
132 rfe_type->wlg_Locate_at_btg = false;
133 rfe_type->ant_at_main_port = true;
136 rfe_type->ext_ant_switch_exist = false; /*2-Ant, no antenna switch, WLG*/
137 rfe_type->ext_ant_switch_type =
138 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_NONE;
139 rfe_type->wlg_Locate_at_btg = false;
140 rfe_type->ant_at_main_port = true;
143 rfe_type->ext_ant_switch_exist = true; /*2-Ant, DPDT, BTG*/
144 rfe_type->ext_ant_switch_type =
145 BT_8821C_WIFI_ONLY_EXT_ANT_SWITCH_USE_DPDT;
146 rfe_type->wlg_Locate_at_btg = true;
147 rfe_type->ant_at_main_port = true;
155 ex_hal8821c_wifi_only_hw_config(
156 IN struct wifi_only_cfg *pwifionlycfg
159 halbtc8821c_wifi_only_set_rfe_type(pwifionlycfg);
161 /* set gnt_wl, gnt_bt control owner to WL*/
162 halwifionly_phy_set_bb_reg(pwifionlycfg, 0x70, 0x400000, 0x1);
164 /*gnt_wl=1 , gnt_bt=0*/
165 halwifionly_phy_set_bb_reg(pwifionlycfg, 0x1704, 0xffffffff, 0x7700);
166 halwifionly_phy_set_bb_reg(pwifionlycfg, 0x1700, 0xffffffff, 0xc00f0038);
170 ex_hal8821c_wifi_only_scannotify(
171 IN struct wifi_only_cfg *pwifionlycfg,
175 hal8821c_wifi_only_switch_antenna(pwifionlycfg, is_5g);
179 ex_hal8821c_wifi_only_switchbandnotify(
180 IN struct wifi_only_cfg *pwifionlycfg,
184 hal8821c_wifi_only_switch_antenna(pwifionlycfg, is_5g);