1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
21 /* ************************************************************
23 * ************************************************************ */
24 #include "mp_precomp.h"
25 #include "phydm_precomp.h"
27 #if (defined(CONFIG_BB_POWER_SAVING))
30 odm_dynamic_bb_power_saving_init(
34 struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
35 struct _dynamic_power_saving *p_dm_ps_table = &p_dm_odm->dm_ps_table;
37 p_dm_ps_table->pre_cca_state = CCA_MAX;
38 p_dm_ps_table->cur_cca_state = CCA_MAX;
39 p_dm_ps_table->pre_rf_state = RF_MAX;
40 p_dm_ps_table->cur_rf_state = RF_MAX;
41 p_dm_ps_table->rssi_val_min = 0;
42 p_dm_ps_table->initialize = 0;
51 struct PHY_DM_STRUCT *p_dm_odm = (struct PHY_DM_STRUCT *)p_dm_void;
52 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
53 struct _dynamic_power_saving *p_dm_ps_table = &p_dm_odm->dm_ps_table;
54 u8 rssi_up_bound = 30 ;
55 u8 rssi_low_bound = 25;
56 #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
57 if (p_dm_odm->patch_id == 40) { /* RT_CID_819x_FUNAI_TV */
62 if (p_dm_ps_table->initialize == 0) {
64 p_dm_ps_table->reg874 = (odm_get_bb_reg(p_dm_odm, 0x874, MASKDWORD) & 0x1CC000) >> 14;
65 p_dm_ps_table->regc70 = (odm_get_bb_reg(p_dm_odm, 0xc70, MASKDWORD) & BIT(3)) >> 3;
66 p_dm_ps_table->reg85c = (odm_get_bb_reg(p_dm_odm, 0x85c, MASKDWORD) & 0xFF000000) >> 24;
67 p_dm_ps_table->rega74 = (odm_get_bb_reg(p_dm_odm, 0xa74, MASKDWORD) & 0xF000) >> 12;
68 /* Reg818 = phy_query_bb_reg(p_adapter, 0x818, MASKDWORD); */
69 p_dm_ps_table->initialize = 1;
72 if (!is_force_in_normal) {
73 if (p_dm_odm->rssi_min != 0xFF) {
74 if (p_dm_ps_table->pre_rf_state == rf_normal) {
75 if (p_dm_odm->rssi_min >= rssi_up_bound)
76 p_dm_ps_table->cur_rf_state = rf_save;
78 p_dm_ps_table->cur_rf_state = rf_normal;
80 if (p_dm_odm->rssi_min <= rssi_low_bound)
81 p_dm_ps_table->cur_rf_state = rf_normal;
83 p_dm_ps_table->cur_rf_state = rf_save;
86 p_dm_ps_table->cur_rf_state = RF_MAX;
88 p_dm_ps_table->cur_rf_state = rf_normal;
90 if (p_dm_ps_table->pre_rf_state != p_dm_ps_table->cur_rf_state) {
91 if (p_dm_ps_table->cur_rf_state == rf_save) {
92 odm_set_bb_reg(p_dm_odm, 0x874, 0x1C0000, 0x2); /* reg874[20:18]=3'b010 */
93 odm_set_bb_reg(p_dm_odm, 0xc70, BIT(3), 0); /* regc70[3]=1'b0 */
94 odm_set_bb_reg(p_dm_odm, 0x85c, 0xFF000000, 0x63); /* reg85c[31:24]=0x63 */
95 odm_set_bb_reg(p_dm_odm, 0x874, 0xC000, 0x2); /* reg874[15:14]=2'b10 */
96 odm_set_bb_reg(p_dm_odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */
97 odm_set_bb_reg(p_dm_odm, 0x818, BIT(28), 0x0); /* Reg818[28]=1'b0 */
98 odm_set_bb_reg(p_dm_odm, 0x818, BIT(28), 0x1); /* Reg818[28]=1'b1 */
100 odm_set_bb_reg(p_dm_odm, 0x874, 0x1CC000, p_dm_ps_table->reg874);
101 odm_set_bb_reg(p_dm_odm, 0xc70, BIT(3), p_dm_ps_table->regc70);
102 odm_set_bb_reg(p_dm_odm, 0x85c, 0xFF000000, p_dm_ps_table->reg85c);
103 odm_set_bb_reg(p_dm_odm, 0xa74, 0xF000, p_dm_ps_table->rega74);
104 odm_set_bb_reg(p_dm_odm, 0x818, BIT(28), 0x0);
106 p_dm_ps_table->pre_rf_state = p_dm_ps_table->cur_rf_state;