xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8822bs/include/rtw_pwrctrl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
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  *****************************************************************************/
15 #ifndef __RTW_PWRCTRL_H_
16 #define __RTW_PWRCTRL_H_
17 
18 
19 #define FW_PWR0	0
20 #define FW_PWR1	1
21 #define FW_PWR2	2
22 #define FW_PWR3	3
23 
24 
25 #define HW_PWR0	7
26 #define HW_PWR1	6
27 #define HW_PWR2	2
28 #define HW_PWR3	0
29 #define HW_PWR4	8
30 
31 #define FW_PWRMSK	0x7
32 
33 
34 #define XMIT_ALIVE	BIT(0)
35 #define RECV_ALIVE	BIT(1)
36 #define CMD_ALIVE	BIT(2)
37 #define EVT_ALIVE	BIT(3)
38 #ifdef CONFIG_BT_COEXIST
39 #define BTCOEX_ALIVE	BIT(4)
40 #endif /* CONFIG_BT_COEXIST */
41 
42 #ifdef CONFIG_WOWLAN
43 	#ifdef CONFIG_PLATFORM_ANDROID_INTEL_X86
44 		/* TCP/ICMP/UDP multicast with specific IP addr */
45 		#define DEFAULT_PATTERN_NUM 4
46 	#else
47 		/* TCP/ICMP */
48 		#define DEFAULT_PATTERN_NUM 3
49 	#endif
50 
51 #ifdef CONFIG_WOW_PATTERN_HW_CAM	/* Frame Mask Cam number for pattern match */
52 #define MAX_WKFM_CAM_NUM	12
53 #else
54 #define MAX_WKFM_CAM_NUM	16
55 #endif
56 
57 #define MAX_WKFM_SIZE	16 /* (16 bytes for WKFM bit mask, 16*8 = 128 bits) */
58 #define MAX_WKFM_PATTERN_SIZE	128
59 
60 /*
61  * MAX_WKFM_PATTERN_STR_LEN : the max. length of wow pattern string
62  *	e.g. echo 00:01:02:...:7f > /proc/net/rtl88x2bu/wlan0/wow_pattern_info
63  *	- each byte of pattern is represented as 2-bytes ascii : MAX_WKFM_PATTERN_SIZE * 2
64  *	- the number of common ':' in pattern string : MAX_WKFM_PATTERN_SIZE - 1
65  *	- 1 byte '\n'(0x0a) is generated at the end when we use echo command
66  *	so total max. length is (MAX_WKFM_PATTERN_SIZE * 3)
67  */
68 #define MAX_WKFM_PATTERN_STR_LEN (MAX_WKFM_PATTERN_SIZE * 3)
69 
70 #define WKFMCAM_ADDR_NUM 6
71 #define WKFMCAM_SIZE 24 /* each entry need 6*4 bytes */
72 enum pattern_type {
73 	PATTERN_BROADCAST = 0,
74 	PATTERN_MULTICAST,
75 	PATTERN_UNICAST,
76 	PATTERN_VALID,
77 	PATTERN_INVALID,
78 };
79 
80 typedef struct rtl_priv_pattern {
81 	int len;
82 	char content[MAX_WKFM_PATTERN_SIZE];
83 	char mask[MAX_WKFM_SIZE];
84 } rtl_priv_pattern_t;
85 
86 #endif /* CONFIG_WOWLAN */
87 
88 enum Power_Mgnt {
89 	PS_MODE_ACTIVE	= 0	,
90 	PS_MODE_MIN			,
91 	PS_MODE_MAX			,
92 	PS_MODE_DTIM			,	/* PS_MODE_SELF_DEFINED */
93 	PS_MODE_VOIP			,
94 	PS_MODE_UAPSD_WMM	,
95 	PS_MODE_UAPSD			,
96 	PS_MODE_IBSS			,
97 	PS_MODE_WWLAN		,
98 	PM_Radio_Off			,
99 	PM_Card_Disable		,
100 	PS_MODE_NUM,
101 };
102 
103 enum lps_level {
104 	LPS_NORMAL = 0,
105 	LPS_LCLK,
106 	LPS_PG,
107 	LPS_LEVEL_MAX,
108 };
109 
110 #ifdef CONFIG_PNO_SUPPORT
111 #define MAX_PNO_LIST_COUNT 16
112 #define MAX_SCAN_LIST_COUNT 14	/* 2.4G only */
113 #define MAX_HIDDEN_AP 8		/* 8 hidden AP */
114 #endif
115 
116 /*
117 	BIT[2:0] = HW state
118 	BIT[3] = Protocol PS state,   0: register active state , 1: register sleep state
119 	BIT[4] = sub-state
120 */
121 
122 #define PS_DPS				BIT(0)
123 #define PS_LCLK				(PS_DPS)
124 #define PS_RF_OFF			BIT(1)
125 #define PS_ALL_ON			BIT(2)
126 #define PS_ST_ACTIVE		BIT(3)
127 
128 #define PS_ISR_ENABLE		BIT(4)
129 #define PS_IMR_ENABLE		BIT(5)
130 #define PS_ACK				BIT(6)
131 #define PS_TOGGLE			BIT(7)
132 
133 #define PS_STATE_MASK		(0x0F)
134 #define PS_STATE_HW_MASK	(0x07)
135 #define PS_SEQ_MASK			(0xc0)
136 
137 #define PS_STATE(x)		(PS_STATE_MASK & (x))
138 #define PS_STATE_HW(x)	(PS_STATE_HW_MASK & (x))
139 #define PS_SEQ(x)		(PS_SEQ_MASK & (x))
140 
141 #define PS_STATE_S0		(PS_DPS)
142 #define PS_STATE_S1		(PS_LCLK)
143 #define PS_STATE_S2		(PS_RF_OFF)
144 #define PS_STATE_S3		(PS_ALL_ON)
145 #define PS_STATE_S4		((PS_ST_ACTIVE) | (PS_ALL_ON))
146 
147 
148 #define PS_IS_RF_ON(x)	((x) & (PS_ALL_ON))
149 #define PS_IS_ACTIVE(x)	((x) & (PS_ST_ACTIVE))
150 #define CLR_PS_STATE(x)	((x) = ((x) & (0xF0)))
151 
152 
153 struct reportpwrstate_parm {
154 	unsigned char mode;
155 	unsigned char state; /* the CPWM value */
156 	unsigned short rsvd;
157 };
158 
159 
160 typedef _sema _pwrlock;
161 
162 
_init_pwrlock(_pwrlock * plock)163 __inline static void _init_pwrlock(_pwrlock *plock)
164 {
165 	_rtw_init_sema(plock, 1);
166 }
167 
_free_pwrlock(_pwrlock * plock)168 __inline static void _free_pwrlock(_pwrlock *plock)
169 {
170 	_rtw_free_sema(plock);
171 }
172 
173 
_enter_pwrlock(_pwrlock * plock)174 __inline static void _enter_pwrlock(_pwrlock *plock)
175 {
176 	_rtw_down_sema(plock);
177 }
178 
179 
_exit_pwrlock(_pwrlock * plock)180 __inline static void _exit_pwrlock(_pwrlock *plock)
181 {
182 	_rtw_up_sema(plock);
183 }
184 
185 #define LPS_DELAY_MS	1000 /* 1 sec */
186 
187 #define EXE_PWR_NONE	0x01
188 #define EXE_PWR_IPS		0x02
189 #define EXE_PWR_LPS		0x04
190 
191 /* RF state. */
192 typedef enum _rt_rf_power_state {
193 	rf_on,		/* RF is on after RFSleep or RFOff */
194 	rf_sleep,	/* 802.11 Power Save mode */
195 	rf_off,		/* HW/SW Radio OFF or Inactive Power Save */
196 	/* =====Add the new RF state above this line===== */
197 	rf_max
198 } rt_rf_power_state;
199 
200 /* ASPM OSC Control bit, added by Roger, 2013.03.29. */
201 #define	RT_PCI_ASPM_OSC_IGNORE		0	 /* PCI ASPM ignore OSC control in default */
202 #define	RT_PCI_ASPM_OSC_ENABLE		BIT0 /* PCI ASPM controlled by OS according to ACPI Spec 5.0 */
203 #define	RT_PCI_ASPM_OSC_DISABLE		BIT1 /* PCI ASPM controlled by driver or BIOS, i.e., force enable ASPM */
204 
205 
206 enum _PS_BBRegBackup_ {
207 	PSBBREG_RF0 = 0,
208 	PSBBREG_RF1,
209 	PSBBREG_RF2,
210 	PSBBREG_AFE0,
211 	PSBBREG_TOTALCNT
212 };
213 
214 enum { /* for ips_mode */
215 	IPS_NONE = 0,
216 	IPS_NORMAL,
217 	IPS_LEVEL_2,
218 	IPS_NUM
219 };
220 
221 /* Design for pwrctrl_priv.ips_deny, 32 bits for 32 reasons at most */
222 typedef enum _PS_DENY_REASON {
223 	PS_DENY_DRV_INITIAL = 0,
224 	PS_DENY_SCAN,
225 	PS_DENY_JOIN,
226 	PS_DENY_DISCONNECT,
227 	PS_DENY_SUSPEND,
228 	PS_DENY_IOCTL,
229 	PS_DENY_MGNT_TX,
230 	PS_DENY_MONITOR_MODE,
231 	PS_DENY_BEAMFORMING,		/* Beamforming */
232 	PS_DENY_DRV_REMOVE = 30,
233 	PS_DENY_OTHERS = 31
234 } PS_DENY_REASON;
235 
236 #ifdef CONFIG_PNO_SUPPORT
237 typedef struct pno_nlo_info {
238 	u32 fast_scan_period;				/* Fast scan period */
239 	u8	ssid_num;				/* number of entry */
240 	u8	hidden_ssid_num;
241 	u32	slow_scan_period;			/* slow scan period */
242 	u32	fast_scan_iterations;			/* Fast scan iterations */
243 	u8	ssid_length[MAX_PNO_LIST_COUNT];	/* SSID Length Array */
244 	u8	ssid_cipher_info[MAX_PNO_LIST_COUNT];	/* Cipher information for security */
245 	u8	ssid_channel_info[MAX_PNO_LIST_COUNT];	/* channel information */
246 	u8	loc_probe_req[MAX_HIDDEN_AP];		/* loc_probeReq */
247 } pno_nlo_info_t;
248 
249 typedef struct pno_ssid {
250 	u32		SSID_len;
251 	u8		SSID[32];
252 } pno_ssid_t;
253 
254 typedef struct pno_ssid_list {
255 	pno_ssid_t	node[MAX_PNO_LIST_COUNT];
256 } pno_ssid_list_t;
257 
258 typedef struct pno_scan_channel_info {
259 	u8	channel;
260 	u8	tx_power;
261 	u8	timeout;
262 	u8	active;				/* set 1 means active scan, or pasivite scan. */
263 } pno_scan_channel_info_t;
264 
265 typedef struct pno_scan_info {
266 	u8	enableRFE;			/* Enable RFE */
267 	u8	period_scan_time;		/* exclusive with fast_scan_period and slow_scan_period */
268 	u8	periodScan;			/* exclusive with fast_scan_period and slow_scan_period */
269 	u8	orig_80_offset;			/* original channel 80 offset */
270 	u8	orig_40_offset;			/* original channel 40 offset */
271 	u8	orig_bw;			/* original bandwidth */
272 	u8	orig_ch;			/* original channel */
273 	u8	channel_num;			/* number of channel */
274 	u64	rfe_type;			/* rfe_type && 0x00000000000000ff */
275 	pno_scan_channel_info_t ssid_channel_info[MAX_SCAN_LIST_COUNT];
276 } pno_scan_info_t;
277 #endif /* CONFIG_PNO_SUPPORT */
278 
279 #ifdef CONFIG_LPS_POFF
280 /* Driver context for LPS 32K Close IO Power */
281 typedef struct lps_poff_info {
282 	bool	bEn;
283 	u8	*pStaticFile;
284 	u8	*pDynamicFile;
285 	u32	ConfFileOffset;
286 	u32	tx_bndy_static;
287 	u32	tx_bndy_dynamic;
288 	u16	ConfLenForPTK;
289 	u16	ConfLenForGTK;
290 	ATOMIC_T bEnterPOFF;
291 	ATOMIC_T bTxBoundInProgress;
292 	ATOMIC_T bSetPOFFParm;
293 } lps_poff_info_t;
294 #endif /*CONFIG_LPS_POFF*/
295 
296 struct aoac_report {
297 	u8 iv[8];
298 	u8 replay_counter_eapol_key[8];
299 	u8 group_key[32];
300 	u8 key_index;
301 	u8 security_type;
302 	u8 wow_pattern_idx;
303 	u8 version_info;
304 	u8 rekey_ok:1;
305 	u8 dummy:7;
306 	u8 reserved[3];
307 	u8 rxptk_iv[8];
308 	u8 rxgtk_iv[4][8];
309 };
310 
311 struct rsvd_page_cache_t;
312 
313 struct pwrctrl_priv {
314 	_pwrlock	lock;
315 	_pwrlock	check_32k_lock;
316 	volatile u8 rpwm; /* requested power state for fw */
317 	volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */
318 	volatile u8 tog; /* toggling */
319 	volatile u8 cpwm_tog; /* toggling */
320 	u8 rpwm_retry;
321 
322 	u8	pwr_mode;
323 	u8	smart_ps;
324 	u8	bcn_ant_mode;
325 	u8	dtim;
326 #ifdef CONFIG_LPS_CHK_BY_TP
327 	u8	lps_chk_by_tp;
328 	u16	lps_tx_tp_th;/*Mbps*/
329 	u16	lps_rx_tp_th;/*Mbps*/
330 	u16	lps_bi_tp_th;/*Mbps*//*TRX TP*/
331 	int	lps_chk_cnt_th;
332 	int	lps_chk_cnt;
333 	u32	lps_tx_pkts;
334 	u32	lps_rx_pkts;
335 
336 #endif
337 
338 #ifdef CONFIG_WMMPS_STA
339 	u8 wmm_smart_ps;
340 #endif /* CONFIG_WMMPS_STA */
341 
342 	u32	alives;
343 	_workitem cpwm_event;
344 	_workitem dma_event; /*for handle un-synchronized tx dma*/
345 #ifdef CONFIG_LPS_RPWM_TIMER
346 	u8 brpwmtimeout;
347 	_workitem rpwmtimeoutwi;
348 	_timer pwr_rpwm_timer;
349 #endif /* CONFIG_LPS_RPWM_TIMER */
350 	u8	bpower_saving; /* for LPS/IPS */
351 
352 	u8	b_hw_radio_off;
353 	u8	reg_rfoff;
354 	u8	reg_pdnmode; /* powerdown mode */
355 	u32	rfoff_reason;
356 
357 	uint	ips_enter_cnts;
358 	uint	ips_leave_cnts;
359 	uint	lps_enter_cnts;
360 	uint	lps_leave_cnts;
361 
362 	u8	ips_mode;
363 	u8	ips_org_mode;
364 	u8	ips_mode_req; /* used to accept the mode setting request, will update to ipsmode later */
365 	uint bips_processing;
366 	systime ips_deny_time; /* will deny IPS when system time is smaller than this */
367 	u8 pre_ips_type;/* 0: default flow, 1: carddisbale flow */
368 
369 	/* ps_deny: if 0, power save is free to go; otherwise deny all kinds of power save. */
370 	/* Use PS_DENY_REASON to decide reason. */
371 	/* Don't access this variable directly without control function, */
372 	/* and this variable should be protected by lock. */
373 	u32 ps_deny;
374 
375 	u8 ps_processing; /* temporarily used to mark whether in rtw_ps_processor */
376 
377 	u8 fw_psmode_iface_id;
378 	u8	bLeisurePs;
379 	u8	LpsIdleCount;
380 	u8	power_mgnt;
381 	u8	org_power_mgnt;
382 	u8	bFwCurrentInPSMode;
383 	systime	lps_deny_time; /* will deny LPS when system time is smaller than this */
384 	s32		pnp_current_pwr_state;
385 	u8		pnp_bstop_trx;
386 
387 	#ifdef CONFIG_AUTOSUSPEND
388 	int		ps_flag; /* used by autosuspend */
389 	u8		bInternalAutoSuspend;
390 	#endif
391 	u8		bInSuspend;
392 #ifdef CONFIG_BT_COEXIST
393 	u8		bAutoResume;
394 	u8		autopm_cnt;
395 #endif
396 	u8		bSupportRemoteWakeup;
397 	u8		wowlan_wake_reason;
398 	u8		wowlan_last_wake_reason;
399 	u8		wowlan_ap_mode;
400 	u8		wowlan_mode;
401 	u8		wowlan_p2p_mode;
402 	u8		wowlan_pno_enable;
403 	u8		wowlan_in_resume;
404 
405 #ifdef CONFIG_GPIO_WAKEUP
406 	u8		is_high_active;
407 #endif /* CONFIG_GPIO_WAKEUP */
408 	u8		hst2dev_high_active;
409 #ifdef CONFIG_WOWLAN
410 	bool		default_patterns_en;
411 #ifdef CONFIG_IPV6
412 	u8		wowlan_ns_offload_en;
413 #endif /*CONFIG_IPV6*/
414 	u8		wowlan_txpause_status;
415 	u8		wowlan_pattern_idx;
416 	u64		wowlan_fw_iv;
417 	struct rtl_priv_pattern	patterns[MAX_WKFM_CAM_NUM];
418 #ifdef CONFIG_PNO_SUPPORT
419 	u8		pno_inited;
420 	pno_nlo_info_t	*pnlo_info;
421 	pno_scan_info_t	*pscan_info;
422 	pno_ssid_list_t	*pno_ssid_list;
423 #endif /* CONFIG_PNO_SUPPORT */
424 #ifdef CONFIG_WOW_PATTERN_HW_CAM
425 	_mutex	wowlan_pattern_cam_mutex;
426 #endif
427 	u8		wowlan_aoac_rpt_loc;
428 	struct aoac_report wowlan_aoac_rpt;
429 	u8		wowlan_power_mgmt;
430 	u8		wowlan_lps_level;
431 	#ifdef CONFIG_LPS_1T1R
432 	u8		wowlan_lps_1t1r;
433 	#endif
434 #endif /* CONFIG_WOWLAN */
435 	_timer	pwr_state_check_timer;
436 	int		pwr_state_check_interval;
437 	u8		pwr_state_check_cnts;
438 
439 
440 	rt_rf_power_state	rf_pwrstate;/* cur power state, only for IPS */
441 	/* rt_rf_power_state	current_rfpwrstate; */
442 	rt_rf_power_state	change_rfpwrstate;
443 
444 	u8		bHWPowerdown; /* power down mode selection. 0:radio off, 1:power down */
445 	u8		bHWPwrPindetect; /* come from registrypriv.hwpwrp_detect. enable power down function. 0:disable, 1:enable */
446 	u8		bkeepfwalive;
447 	u8		brfoffbyhw;
448 	unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT];
449 
450 #ifdef CONFIG_RESUME_IN_WORKQUEUE
451 	struct workqueue_struct *rtw_workqueue;
452 	_workitem resume_work;
453 #endif
454 
455 #ifdef CONFIG_HAS_EARLYSUSPEND
456 	struct early_suspend early_suspend;
457 	u8 do_late_resume;
458 #endif /* CONFIG_HAS_EARLYSUSPEND */
459 
460 #ifdef CONFIG_ANDROID_POWER
461 	android_early_suspend_t early_suspend;
462 	u8 do_late_resume;
463 #endif
464 
465 #ifdef CONFIG_LPS_POFF
466 	lps_poff_info_t	*plps_poff_info;
467 #endif
468 	u8 lps_level_bk;
469 	u8 lps_level; /*LPS_NORMAL,LPA_CG,LPS_PG*/
470 #ifdef CONFIG_LPS_1T1R
471 	u8 lps_1t1r_bk;
472 	u8 lps_1t1r;
473 #endif
474 #ifdef CONFIG_LPS_PG
475 	struct rsvd_page_cache_t lpspg_info;
476 #ifdef CONFIG_RTL8822C
477 	struct rsvd_page_cache_t lpspg_dpk_info;
478 	struct rsvd_page_cache_t lpspg_iqk_info;
479 #endif
480 #endif
481 	u8 current_lps_hw_port_id;
482 
483 #ifdef CONFIG_RTW_CFGVEDNOR_LLSTATS
484 	systime radio_on_start_time;
485 	systime pwr_saving_start_time;
486 	u32 pwr_saving_time;
487 	u32 on_time;
488 	u32 tx_time;
489 	u32 rx_time;
490 #endif /* CONFIG_RTW_CFGVEDNOR_LLSTATS */
491 
492 #ifdef CONFIG_LPS_ACK
493 	struct submit_ctx lps_ack_sctx;
494 	s8 lps_ack_status;
495 	_mutex lps_ack_mutex;
496 #endif /* CONFIG_LPS_ACK */
497 };
498 
499 #define rtw_get_ips_mode_req(pwrctl) \
500 	(pwrctl)->ips_mode_req
501 
502 #define rtw_ips_mode_req(pwrctl, ips_mode) \
503 	(pwrctl)->ips_mode_req = (ips_mode)
504 
505 #define RTW_PWR_STATE_CHK_INTERVAL 2000
506 
507 #define _rtw_set_pwr_state_check_timer(pwrctl, ms) \
508 	do { \
509 		/*RTW_INFO("%s _rtw_set_pwr_state_check_timer(%p, %d)\n", __FUNCTION__, (pwrctl), (ms));*/ \
510 		_set_timer(&(pwrctl)->pwr_state_check_timer, (ms)); \
511 	} while (0)
512 
513 #define rtw_set_pwr_state_check_timer(pwrctl) \
514 	_rtw_set_pwr_state_check_timer((pwrctl), (pwrctl)->pwr_state_check_interval)
515 
516 extern void rtw_init_pwrctrl_priv(_adapter *adapter);
517 extern void rtw_free_pwrctrl_priv(_adapter *adapter);
518 
519 #ifdef CONFIG_LPS_LCLK
520 s32 rtw_register_task_alive(PADAPTER, u32 task);
521 void rtw_unregister_task_alive(PADAPTER, u32 task);
522 extern s32 rtw_register_tx_alive(PADAPTER padapter);
523 extern void rtw_unregister_tx_alive(PADAPTER padapter);
524 extern s32 rtw_register_rx_alive(PADAPTER padapter);
525 extern void rtw_unregister_rx_alive(PADAPTER padapter);
526 extern s32 rtw_register_cmd_alive(PADAPTER padapter);
527 extern void rtw_unregister_cmd_alive(PADAPTER padapter);
528 extern s32 rtw_register_evt_alive(PADAPTER padapter);
529 extern void rtw_unregister_evt_alive(PADAPTER padapter);
530 extern void cpwm_int_hdl(PADAPTER padapter, struct reportpwrstate_parm *preportpwrstate);
531 extern void LPS_Leave_check(PADAPTER padapter);
532 #endif
533 
534 extern void LeaveAllPowerSaveMode(PADAPTER Adapter);
535 extern void LeaveAllPowerSaveModeDirect(PADAPTER Adapter);
536 #ifdef CONFIG_IPS
537 void _ips_enter(_adapter *padapter);
538 void ips_enter(_adapter *padapter);
539 int _ips_leave(_adapter *padapter);
540 int ips_leave(_adapter *padapter);
541 #endif
542 
543 void rtw_ps_processor(_adapter *padapter);
544 
545 #ifdef CONFIG_AUTOSUSPEND
546 int autoresume_enter(_adapter *padapter);
547 #endif
548 #ifdef SUPPORT_HW_RFOFF_DETECTED
549 rt_rf_power_state RfOnOffDetect(PADAPTER pAdapter);
550 #endif
551 
552 
553 #ifdef DBG_CHECK_FW_PS_STATE
554 int rtw_fw_ps_state(PADAPTER padapter);
555 #endif
556 
557 #ifdef CONFIG_LPS
558 extern const char * const LPS_CTRL_PHYDM;
559 void LPS_Enter(PADAPTER padapter, const char *msg);
560 void LPS_Leave(PADAPTER padapter, const char *msg);
561 void rtw_leave_lps_and_chk(_adapter *padapter, u8 ps_mode);
562 #ifdef CONFIG_CHECK_LEAVE_LPS
563 #ifdef CONFIG_LPS_CHK_BY_TP
564 void traffic_check_for_leave_lps_by_tp(PADAPTER padapter, u8 tx, struct sta_info *sta);
565 #endif
566 void traffic_check_for_leave_lps(PADAPTER padapter, u8 tx, u32 tx_packets);
567 #endif /*CONFIG_CHECK_LEAVE_LPS*/
568 void rtw_set_ps_mode(PADAPTER padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode, const char *msg);
569 void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable);
570 u8 rtw_set_rpwm(_adapter *padapter, u8 val8);
571 #ifdef CONFIG_WOWLAN
572 void rtw_wow_lps_level_decide(_adapter *adapter, u8 wow_en);
573 #endif /* CONFIG_WOWLAN */
574 #endif /* CONFIG_LPS */
575 
576 #ifdef CONFIG_RESUME_IN_WORKQUEUE
577 void rtw_resume_in_workqueue(struct pwrctrl_priv *pwrpriv);
578 #endif /* CONFIG_RESUME_IN_WORKQUEUE */
579 
580 #if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_ANDROID_POWER)
581 bool rtw_is_earlysuspend_registered(struct pwrctrl_priv *pwrpriv);
582 bool rtw_is_do_late_resume(struct pwrctrl_priv *pwrpriv);
583 void rtw_set_do_late_resume(struct pwrctrl_priv *pwrpriv, bool enable);
584 void rtw_register_early_suspend(struct pwrctrl_priv *pwrpriv);
585 void rtw_unregister_early_suspend(struct pwrctrl_priv *pwrpriv);
586 #else
587 #define rtw_is_earlysuspend_registered(pwrpriv) _FALSE
588 #define rtw_is_do_late_resume(pwrpriv) _FALSE
589 #define rtw_set_do_late_resume(pwrpriv, enable) do {} while (0)
590 #define rtw_register_early_suspend(pwrpriv) do {} while (0)
591 #define rtw_unregister_early_suspend(pwrpriv) do {} while (0)
592 #endif /* CONFIG_HAS_EARLYSUSPEND || CONFIG_ANDROID_POWER */
593 
594 u8 rtw_interface_ps_func(_adapter *padapter, HAL_INTF_PS_FUNC efunc_id, u8 *val);
595 void rtw_set_ips_deny(_adapter *padapter, u32 ms);
596 int _rtw_pwr_wakeup(_adapter *padapter, u32 ips_deffer_ms, const char *caller);
597 #define rtw_pwr_wakeup(adapter) _rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __FUNCTION__)
598 #define rtw_pwr_wakeup_ex(adapter, ips_deffer_ms) _rtw_pwr_wakeup(adapter, ips_deffer_ms, __FUNCTION__)
599 int rtw_pm_set_ips(_adapter *padapter, u8 mode);
600 int rtw_pm_set_lps(_adapter *padapter, u8 mode);
601 int rtw_pm_set_lps_level(_adapter *padapter, u8 level);
602 #ifdef CONFIG_LPS_1T1R
603 int rtw_pm_set_lps_1t1r(_adapter *padapter, u8 en);
604 #endif
605 void rtw_set_lps_deny(_adapter *adapter, u32 ms);
606 #ifdef CONFIG_WOWLAN
607 int rtw_pm_set_wow_lps(_adapter *padapter, u8 mode);
608 int rtw_pm_set_wow_lps_level(_adapter *padapter, u8 level);
609 #ifdef CONFIG_LPS_1T1R
610 int rtw_pm_set_wow_lps_1t1r(_adapter *padapter, u8 en);
611 #endif
612 #endif /* CONFIG_WOWLAN */
613 
614 void rtw_ps_deny(PADAPTER padapter, PS_DENY_REASON reason);
615 void rtw_ps_deny_cancel(PADAPTER padapter, PS_DENY_REASON reason);
616 u32 rtw_ps_deny_get(PADAPTER padapter);
617 
618 #if defined(CONFIG_WOWLAN)
619 void rtw_get_current_ip_address(PADAPTER padapter, u8 *pcurrentip);
620 void rtw_get_sec_iv(PADAPTER padapter, u8 *pcur_dot11txpn, u8 *StaAddr);
621 bool rtw_wowlan_parser_pattern_cmd(u8 *input, char *pattern,
622 				int *pattern_len, char *bit_mask);
623 void rtw_wow_pattern_sw_reset(_adapter *adapter);
624 u8 rtw_set_default_pattern(_adapter *adapter);
625 void rtw_wow_pattern_sw_dump(_adapter *adapter);
626 #endif /* CONFIG_WOWLAN */
627 void rtw_ssmps_enter(_adapter *adapter, struct sta_info *sta);
628 void rtw_ssmps_leave(_adapter *adapter, struct sta_info *sta);
629 #endif /* __RTL871X_PWRCTRL_H_ */
630