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