1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __RTL871X_PWRCTRL_H_
15#define __RTL871X_PWRCTRL_H_
16
17#include "osdep_service.h"
18#include "drv_types.h"
19
20#define CMD_ALIVE BIT(2)
21
22enum Power_Mgnt {
23 PS_MODE_ACTIVE = 0,
24 PS_MODE_MIN,
25 PS_MODE_MAX,
26 PS_MODE_DTIM,
27 PS_MODE_VOIP,
28 PS_MODE_UAPSD_WMM,
29 PS_MODE_UAPSD,
30 PS_MODE_IBSS,
31 PS_MODE_WWLAN,
32 PM_Radio_Off,
33 PM_Card_Disable,
34 PS_MODE_NUM
35};
36
37
38
39
40
41
42
43
44#define PS_DPS BIT(0)
45#define PS_LCLK (PS_DPS)
46#define PS_RF_OFF BIT(1)
47#define PS_ALL_ON BIT(2)
48#define PS_ST_ACTIVE BIT(3)
49#define PS_LP BIT(4)
50
51#define PS_STATE_MASK (0x0F)
52#define PS_STATE_HW_MASK (0x07)
53#define PS_SEQ_MASK (0xc0)
54
55#define PS_STATE(x) (PS_STATE_MASK & (x))
56#define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x))
57#define PS_SEQ(x) (PS_SEQ_MASK & (x))
58
59#define PS_STATE_S0 (PS_DPS)
60#define PS_STATE_S1 (PS_LCLK)
61#define PS_STATE_S2 (PS_RF_OFF)
62#define PS_STATE_S3 (PS_ALL_ON)
63#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON))
64
65#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON))
66#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE))
67#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0)))
68
69struct reportpwrstate_parm {
70 unsigned char mode;
71 unsigned char state;
72 unsigned short rsvd;
73};
74
75struct pwrctrl_priv {
76 struct mutex mutex_lock;
77 u8 rpwm;
78
79
80
81 u8 cpwm;
82 u8 tog;
83 u8 cpwm_tog;
84 u8 tgt_rpwm;
85 uint pwr_mode;
86 uint smart_ps;
87 uint alives;
88 uint ImrContent;
89 uint bSleep;
90
91 struct work_struct SetPSModeWorkItem;
92 struct work_struct rpwm_workitem;
93 struct timer_list rpwm_check_timer;
94 u8 rpwm_retry;
95 uint bSetPSModeWorkItemInProgress;
96
97 spinlock_t pnp_pwr_mgnt_lock;
98 s32 pnp_current_pwr_state;
99 u8 pnp_bstop_trx;
100 u8 pnp_wwirp_pending;
101};
102
103void r8712_init_pwrctrl_priv(struct _adapter *adapter);
104int r8712_register_cmd_alive(struct _adapter *padapter);
105void r8712_unregister_cmd_alive(struct _adapter *padapter);
106void r8712_cpwm_int_hdl(struct _adapter *padapter,
107 struct reportpwrstate_parm *preportpwrstate);
108void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode,
109 uint smart_ps);
110void r8712_set_rpwm(struct _adapter *padapter, u8 val8);
111void r8712_flush_rwctrl_works(struct _adapter *padapter);
112
113#endif
114