rtl871x_pwrctrl.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2010 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. * Modifications for inclusion into the Linux staging tree are
  19. * Copyright(c) 2010 Larry Finger. All rights reserved.
  20. *
  21. * Contact information:
  22. * WLAN FAE <wlanfae@realtek.com>
  23. * Larry Finger <Larry.Finger@lwfinger.net>
  24. *
  25. ******************************************************************************/
  26. #ifndef __RTL871X_PWRCTRL_H_
  27. #define __RTL871X_PWRCTRL_H_
  28. #include "osdep_service.h"
  29. #include "drv_types.h"
  30. #define CMD_ALIVE BIT(2)
  31. enum Power_Mgnt {
  32. PS_MODE_ACTIVE = 0,
  33. PS_MODE_MIN,
  34. PS_MODE_MAX,
  35. PS_MODE_DTIM,
  36. PS_MODE_VOIP,
  37. PS_MODE_UAPSD_WMM,
  38. PS_MODE_UAPSD,
  39. PS_MODE_IBSS,
  40. PS_MODE_WWLAN,
  41. PM_Radio_Off,
  42. PM_Card_Disable,
  43. PS_MODE_NUM
  44. };
  45. /*
  46. BIT[2:0] = HW state
  47. BIT[3] = Protocol PS state, 0: register active state,
  48. 1: register sleep state
  49. BIT[4] = sub-state
  50. */
  51. #define PS_DPS BIT(0)
  52. #define PS_LCLK (PS_DPS)
  53. #define PS_RF_OFF BIT(1)
  54. #define PS_ALL_ON BIT(2)
  55. #define PS_ST_ACTIVE BIT(3)
  56. #define PS_LP BIT(4) /* low performance */
  57. #define PS_STATE_MASK (0x0F)
  58. #define PS_STATE_HW_MASK (0x07)
  59. #define PS_SEQ_MASK (0xc0)
  60. #define PS_STATE(x) (PS_STATE_MASK & (x))
  61. #define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x))
  62. #define PS_SEQ(x) (PS_SEQ_MASK & (x))
  63. #define PS_STATE_S0 (PS_DPS)
  64. #define PS_STATE_S1 (PS_LCLK)
  65. #define PS_STATE_S2 (PS_RF_OFF)
  66. #define PS_STATE_S3 (PS_ALL_ON)
  67. #define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON))
  68. #define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON))
  69. #define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE))
  70. #define CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
  71. struct reportpwrstate_parm {
  72. unsigned char mode;
  73. unsigned char state; /* the CPWM value */
  74. unsigned short rsvd;
  75. };
  76. static inline void _enter_pwrlock(struct semaphore *plock)
  77. {
  78. _down_sema(plock);
  79. }
  80. struct pwrctrl_priv {
  81. struct semaphore lock;
  82. /*volatile*/ u8 rpwm; /* requested power state for fw */
  83. /* fw current power state. updated when 1. read from HCPWM or
  84. * 2. driver lowers power level */
  85. /*volatile*/ u8 cpwm;
  86. /*volatile*/ u8 tog; /* toggling */
  87. /*volatile*/ u8 cpwm_tog; /* toggling */
  88. /*volatile*/ u8 tgt_rpwm; /* wanted power state */
  89. uint pwr_mode;
  90. uint smart_ps;
  91. uint alives;
  92. uint ImrContent; /* used to store original imr. */
  93. uint bSleep; /* sleep -> active is different from active -> sleep. */
  94. struct work_struct SetPSModeWorkItem;
  95. struct work_struct rpwm_workitem;
  96. struct timer_list rpwm_check_timer;
  97. u8 rpwm_retry;
  98. uint bSetPSModeWorkItemInProgress;
  99. spinlock_t pnp_pwr_mgnt_lock;
  100. s32 pnp_current_pwr_state;
  101. u8 pnp_bstop_trx;
  102. u8 pnp_wwirp_pending;
  103. };
  104. void r8712_init_pwrctrl_priv(struct _adapter *adapter);
  105. sint r8712_register_cmd_alive(struct _adapter *padapter);
  106. void r8712_unregister_cmd_alive(struct _adapter *padapter);
  107. void r8712_cpwm_int_hdl(struct _adapter *padapter,
  108. struct reportpwrstate_parm *preportpwrstate);
  109. void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode,
  110. uint smart_ps);
  111. void r8712_set_rpwm(struct _adapter *padapter, u8 val8);
  112. #endif /* __RTL871X_PWRCTRL_H_ */