phydm_dynamicbbpowersaving.c 4.0 KB

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