mirror of
				https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
				synced 2025-10-31 16:18:51 +01:00 
			
		
		
		
	Fixed MTP to work with TWRP
This commit is contained in:
		
						commit
						f6dfaef42e
					
				
					 50820 changed files with 20846062 additions and 0 deletions
				
			
		
							
								
								
									
										21
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/Makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| obj-m := rtl8723ae.o | ||||
| 
 | ||||
| 
 | ||||
| rtl8723ae-objs :=		\
 | ||||
| 		dm.o		\
 | ||||
| 		fw.o		\
 | ||||
| 		hal_btc.o	\
 | ||||
| 		hal_bt_coexist.o\
 | ||||
| 		hw.o		\
 | ||||
| 		led.o		\
 | ||||
| 		phy.o		\
 | ||||
| 		pwrseq.o	\
 | ||||
| 		rf.o		\
 | ||||
| 		sw.o		\
 | ||||
| 		table.o		\
 | ||||
| 		trx.o		\
 | ||||
| 
 | ||||
| 
 | ||||
| obj-$(CONFIG_RTL8723AE) += rtl8723ae.o | ||||
| 
 | ||||
| ccflags-y += -D__CHECK_ENDIAN__ | ||||
							
								
								
									
										36
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/btc.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/btc.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| /******************************************************************************
 | ||||
|  ** | ||||
|  ** Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  ** | ||||
|  ** This program is free software; you can redistribute it and/or modify it | ||||
|  ** under the terms of version 2 of the GNU General Public License as | ||||
|  ** published by the Free Software Foundation. | ||||
|  ** | ||||
|  ** This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  ** FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  ** more details. | ||||
|  ** | ||||
|  ** The full GNU General Public License is included in this distribution in the | ||||
|  ** file called LICENSE. | ||||
|  ** | ||||
|  ** Contact Information: | ||||
|  ** wlanfae <wlanfae@realtek.com> | ||||
|  ** Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  ** Hsinchu 300, Taiwan. | ||||
|  ** Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  ** | ||||
|  ******************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_BTC_H__ | ||||
| #define __RTL8723E_BTC_H__ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "hal_bt_coexist.h" | ||||
| 
 | ||||
| struct bt_coexist_c2h_info { | ||||
| 	u8 no_parse_c2h; | ||||
| 	u8 has_c2h; | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										279
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/def.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										279
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/def.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,279 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_DEF_H__ | ||||
| #define __RTL8723E_DEF_H__ | ||||
| 
 | ||||
| #define HAL_RETRY_LIMIT_INFRA				48 | ||||
| #define HAL_RETRY_LIMIT_AP_ADHOC			7 | ||||
| 
 | ||||
| #define RESET_DELAY_8185					20 | ||||
| 
 | ||||
| #define RT_IBSS_INT_MASKS	(IMR_BCNINT | IMR_TBDOK | IMR_TBDER) | ||||
| #define RT_AC_INT_MASKS		(IMR_VIDOK | IMR_VODOK | IMR_BEDOK|IMR_BKDOK) | ||||
| 
 | ||||
| #define NUM_OF_FIRMWARE_QUEUE				10 | ||||
| #define NUM_OF_PAGES_IN_FW					0x100 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_BK			0x07 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_BE			0x07 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_VI			0x07 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_VO			0x07 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_HCCA		0x0 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_CMD			0x0 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_MGNT		0x02 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_HIGH		0x02 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_BCN			0x2 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_PUB			0xA1 | ||||
| 
 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_BK_DTM		0x026 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_BE_DTM		0x048 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_VI_DTM		0x048 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_VO_DTM		0x026 | ||||
| #define NUM_OF_PAGE_IN_FW_QUEUE_PUB_DTM		0x00 | ||||
| 
 | ||||
| #define MAX_LINES_HWCONFIG_TXT				1000 | ||||
| #define MAX_BYTES_LINE_HWCONFIG_TXT			256 | ||||
| 
 | ||||
| #define SW_THREE_WIRE						0 | ||||
| #define HW_THREE_WIRE						2 | ||||
| 
 | ||||
| #define BT_DEMO_BOARD						0 | ||||
| #define BT_QA_BOARD							1 | ||||
| #define BT_FPGA								2 | ||||
| 
 | ||||
| #define HAL_PRIME_CHNL_OFFSET_DONT_CARE		0 | ||||
| #define HAL_PRIME_CHNL_OFFSET_LOWER			1 | ||||
| #define HAL_PRIME_CHNL_OFFSET_UPPER			2 | ||||
| 
 | ||||
| #define MAX_H2C_QUEUE_NUM					10 | ||||
| 
 | ||||
| #define RX_MPDU_QUEUE						0 | ||||
| #define RX_CMD_QUEUE						1 | ||||
| #define RX_MAX_QUEUE						2 | ||||
| #define AC2QUEUEID(_AC)						(_AC) | ||||
| 
 | ||||
| #define	C2H_RX_CMD_HDR_LEN					8 | ||||
| #define	GET_C2H_CMD_CMD_LEN(__prxhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE((__prxhdr), 0, 16) | ||||
| #define	GET_C2H_CMD_ELEMENT_ID(__prxhdr)	\ | ||||
| 	LE_BITS_TO_4BYTE((__prxhdr), 16, 8) | ||||
| #define	GET_C2H_CMD_CMD_SEQ(__prxhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE((__prxhdr), 24, 7) | ||||
| #define	GET_C2H_CMD_CONTINUE(__prxhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE((__prxhdr), 31, 1) | ||||
| #define	GET_C2H_CMD_CONTENT(__prxhdr)		\ | ||||
| 	((u8 *)(__prxhdr) + C2H_RX_CMD_HDR_LEN) | ||||
| 
 | ||||
| #define	GET_C2H_CMD_FEEDBACK_ELEMENT_ID(__pcmdfbhdr)	\ | ||||
| 	LE_BITS_TO_4BYTE((__pcmdfbhdr), 0, 8) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_LEN(__pcmdfbhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE((__pcmdfbhdr), 8, 8) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_CMD_CNT(__pcmdfbhdr)	\ | ||||
| 	LE_BITS_TO_4BYTE((__pcmdfbhdr), 16, 16) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_MAC_ID(__pcmdfbhdr)	\ | ||||
| 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 0, 5) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_VALID(__pcmdfbhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 7, 1) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_RETRY_CNT(__pcmdfbhdr)	\ | ||||
| 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 8, 5) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_TOK(__pcmdfbhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 15, 1) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_QSEL(__pcmdfbhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 16, 4) | ||||
| #define	GET_C2H_CMD_FEEDBACK_CCX_SEQ(__pcmdfbhdr)		\ | ||||
| 	LE_BITS_TO_4BYTE(((__pcmdfbhdr) + 4), 20, 12) | ||||
| 
 | ||||
| #define CHIP_BONDING_IDENTIFIER(_value)	(((_value)>>22)&0x3) | ||||
| #define	CHIP_BONDING_92C_1T2R		0x1 | ||||
| 
 | ||||
| #define CHIP_8723		BIT(0) | ||||
| #define NORMAL_CHIP		BIT(3) | ||||
| #define RF_TYPE_1T1R		(~(BIT(4)|BIT(5)|BIT(6))) | ||||
| #define RF_TYPE_1T2R		BIT(4) | ||||
| #define RF_TYPE_2T2R		BIT(5) | ||||
| #define CHIP_VENDOR_UMC		BIT(7) | ||||
| #define B_CUT_VERSION		BIT(12) | ||||
| #define C_CUT_VERSION		BIT(13) | ||||
| #define D_CUT_VERSION		((BIT(12)|BIT(13))) | ||||
| #define E_CUT_VERSION		BIT(14) | ||||
| #define	RF_RL_ID		(BIT(31)|BIT(30)|BIT(29)|BIT(28)) | ||||
| 
 | ||||
| /* MASK */ | ||||
| #define IC_TYPE_MASK		(BIT(0)|BIT(1)|BIT(2)) | ||||
| #define CHIP_TYPE_MASK		BIT(3) | ||||
| #define RF_TYPE_MASK		(BIT(4)|BIT(5)|BIT(6)) | ||||
| #define MANUFACTUER_MASK	BIT(7) | ||||
| #define ROM_VERSION_MASK	(BIT(11)|BIT(10)|BIT(9)|BIT(8)) | ||||
| #define CUT_VERSION_MASK	(BIT(15)|BIT(14)|BIT(13)|BIT(12)) | ||||
| 
 | ||||
| /* Get element */ | ||||
| #define GET_CVID_IC_TYPE(version)	((version) & IC_TYPE_MASK) | ||||
| #define GET_CVID_CHIP_TYPE(version)	((version) & CHIP_TYPE_MASK) | ||||
| #define GET_CVID_RF_TYPE(version)	((version) & RF_TYPE_MASK) | ||||
| #define GET_CVID_MANUFACTUER(version)	((version) & MANUFACTUER_MASK) | ||||
| #define GET_CVID_ROM_VERSION(version)	((version) & ROM_VERSION_MASK) | ||||
| #define GET_CVID_CUT_VERSION(version)	((version) & CUT_VERSION_MASK) | ||||
| 
 | ||||
| #define IS_81XXC(version)	((GET_CVID_IC_TYPE(version) == 0) ?\ | ||||
| 						true : false) | ||||
| #define IS_8723_SERIES(version)	((GET_CVID_IC_TYPE(version) == CHIP_8723) ? \ | ||||
| 						true : false) | ||||
| #define IS_1T1R(version)	((GET_CVID_RF_TYPE(version)) ? false : true) | ||||
| #define IS_1T2R(version)	((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R)\ | ||||
| 						? true : false) | ||||
| #define IS_2T2R(version)	((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R)\ | ||||
| 						? true : false) | ||||
| #define IS_CHIP_VENDOR_UMC(version)	((GET_CVID_MANUFACTUER(version)) ? \ | ||||
| 						true : false) | ||||
| 
 | ||||
| #define IS_VENDOR_UMC_A_CUT(version)	((IS_CHIP_VENDOR_UMC(version))\ | ||||
| 					? ((GET_CVID_CUT_VERSION(version)) ? \ | ||||
| 					false : true) : false) | ||||
| #define IS_VENDOR_8723_A_CUT(version)	((IS_8723_SERIES(version))\ | ||||
| 					? ((GET_CVID_CUT_VERSION(version)) ? \ | ||||
| 					false : true) : false) | ||||
| #define IS_VENDOR_8723A_B_CUT(version)	((IS_8723_SERIES(version))\ | ||||
| 		? ((GET_CVID_CUT_VERSION(version) == \ | ||||
| 		B_CUT_VERSION) ? true : false) : false) | ||||
| #define IS_81xxC_VENDOR_UMC_B_CUT(version)	((IS_CHIP_VENDOR_UMC(version))\ | ||||
| 		? ((GET_CVID_CUT_VERSION(version) == \ | ||||
| 		B_CUT_VERSION) ? true : false) : false) | ||||
| 
 | ||||
| enum rf_optype { | ||||
| 	RF_OP_BY_SW_3WIRE = 0, | ||||
| 	RF_OP_BY_FW, | ||||
| 	RF_OP_MAX | ||||
| }; | ||||
| 
 | ||||
| enum rf_power_state { | ||||
| 	RF_ON, | ||||
| 	RF_OFF, | ||||
| 	RF_SLEEP, | ||||
| 	RF_SHUT_DOWN, | ||||
| }; | ||||
| 
 | ||||
| enum power_save_mode { | ||||
| 	POWER_SAVE_MODE_ACTIVE, | ||||
| 	POWER_SAVE_MODE_SAVE, | ||||
| }; | ||||
| 
 | ||||
| enum power_policy_config { | ||||
| 	POWERCFG_MAX_POWER_SAVINGS, | ||||
| 	POWERCFG_GLOBAL_POWER_SAVINGS, | ||||
| 	POWERCFG_LOCAL_POWER_SAVINGS, | ||||
| 	POWERCFG_LENOVO, | ||||
| }; | ||||
| 
 | ||||
| enum interface_select_pci { | ||||
| 	INTF_SEL1_MINICARD = 0, | ||||
| 	INTF_SEL0_PCIE = 1, | ||||
| 	INTF_SEL2_RSV = 2, | ||||
| 	INTF_SEL3_RSV = 3, | ||||
| }; | ||||
| 
 | ||||
| enum hal_fw_c2h_cmd_id { | ||||
| 	HAL_FW_C2H_CMD_Read_MACREG = 0, | ||||
| 	HAL_FW_C2H_CMD_Read_BBREG = 1, | ||||
| 	HAL_FW_C2H_CMD_Read_RFREG = 2, | ||||
| 	HAL_FW_C2H_CMD_Read_EEPROM = 3, | ||||
| 	HAL_FW_C2H_CMD_Read_EFUSE = 4, | ||||
| 	HAL_FW_C2H_CMD_Read_CAM = 5, | ||||
| 	HAL_FW_C2H_CMD_Get_BasicRate = 6, | ||||
| 	HAL_FW_C2H_CMD_Get_DataRate = 7, | ||||
| 	HAL_FW_C2H_CMD_Survey = 8, | ||||
| 	HAL_FW_C2H_CMD_SurveyDone = 9, | ||||
| 	HAL_FW_C2H_CMD_JoinBss = 10, | ||||
| 	HAL_FW_C2H_CMD_AddSTA = 11, | ||||
| 	HAL_FW_C2H_CMD_DelSTA = 12, | ||||
| 	HAL_FW_C2H_CMD_AtimDone = 13, | ||||
| 	HAL_FW_C2H_CMD_TX_Report = 14, | ||||
| 	HAL_FW_C2H_CMD_CCX_Report = 15, | ||||
| 	HAL_FW_C2H_CMD_DTM_Report = 16, | ||||
| 	HAL_FW_C2H_CMD_TX_Rate_Statistics = 17, | ||||
| 	HAL_FW_C2H_CMD_C2HLBK = 18, | ||||
| 	HAL_FW_C2H_CMD_C2HDBG = 19, | ||||
| 	HAL_FW_C2H_CMD_C2HFEEDBACK = 20, | ||||
| 	HAL_FW_C2H_CMD_MAX | ||||
| }; | ||||
| 
 | ||||
| enum rtl_desc_qsel { | ||||
| 	QSLT_BK = 0x2, | ||||
| 	QSLT_BE = 0x0, | ||||
| 	QSLT_VI = 0x5, | ||||
| 	QSLT_VO = 0x7, | ||||
| 	QSLT_BEACON = 0x10, | ||||
| 	QSLT_HIGH = 0x11, | ||||
| 	QSLT_MGNT = 0x12, | ||||
| 	QSLT_CMD = 0x13, | ||||
| }; | ||||
| 
 | ||||
| enum rtl_desc8723e_rate { | ||||
| 	DESC92C_RATE1M = 0x00, | ||||
| 	DESC92C_RATE2M = 0x01, | ||||
| 	DESC92C_RATE5_5M = 0x02, | ||||
| 	DESC92C_RATE11M = 0x03, | ||||
| 
 | ||||
| 	DESC92C_RATE6M = 0x04, | ||||
| 	DESC92C_RATE9M = 0x05, | ||||
| 	DESC92C_RATE12M = 0x06, | ||||
| 	DESC92C_RATE18M = 0x07, | ||||
| 	DESC92C_RATE24M = 0x08, | ||||
| 	DESC92C_RATE36M = 0x09, | ||||
| 	DESC92C_RATE48M = 0x0a, | ||||
| 	DESC92C_RATE54M = 0x0b, | ||||
| 
 | ||||
| 	DESC92C_RATEMCS0 = 0x0c, | ||||
| 	DESC92C_RATEMCS1 = 0x0d, | ||||
| 	DESC92C_RATEMCS2 = 0x0e, | ||||
| 	DESC92C_RATEMCS3 = 0x0f, | ||||
| 	DESC92C_RATEMCS4 = 0x10, | ||||
| 	DESC92C_RATEMCS5 = 0x11, | ||||
| 	DESC92C_RATEMCS6 = 0x12, | ||||
| 	DESC92C_RATEMCS7 = 0x13, | ||||
| 	DESC92C_RATEMCS8 = 0x14, | ||||
| 	DESC92C_RATEMCS9 = 0x15, | ||||
| 	DESC92C_RATEMCS10 = 0x16, | ||||
| 	DESC92C_RATEMCS11 = 0x17, | ||||
| 	DESC92C_RATEMCS12 = 0x18, | ||||
| 	DESC92C_RATEMCS13 = 0x19, | ||||
| 	DESC92C_RATEMCS14 = 0x1a, | ||||
| 	DESC92C_RATEMCS15 = 0x1b, | ||||
| 	DESC92C_RATEMCS15_SG = 0x1c, | ||||
| 	DESC92C_RATEMCS32 = 0x20, | ||||
| }; | ||||
| 
 | ||||
| struct phy_sts_cck_8723e_t { | ||||
| 	u8 adc_pwdb_X[4]; | ||||
| 	u8 sq_rpt; | ||||
| 	u8 cck_agc_rpt; | ||||
| }; | ||||
| 
 | ||||
| struct h2c_cmd_8723e { | ||||
| 	u8 element_id; | ||||
| 	u32 cmd_len; | ||||
| 	u8 *p_cmdbuffer; | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										905
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										905
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/dm.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,905 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "../base.h" | ||||
| #include "../pci.h" | ||||
| #include "reg.h" | ||||
| #include "def.h" | ||||
| #include "phy.h" | ||||
| #include "dm.h" | ||||
| #include "../rtl8723com/dm_common.h" | ||||
| #include "fw.h" | ||||
| #include "hal_btc.h" | ||||
| 
 | ||||
| static const u32 ofdmswing_table[OFDM_TABLE_SIZE] = { | ||||
| 	0x7f8001fe, | ||||
| 	0x788001e2, | ||||
| 	0x71c001c7, | ||||
| 	0x6b8001ae, | ||||
| 	0x65400195, | ||||
| 	0x5fc0017f, | ||||
| 	0x5a400169, | ||||
| 	0x55400155, | ||||
| 	0x50800142, | ||||
| 	0x4c000130, | ||||
| 	0x47c0011f, | ||||
| 	0x43c0010f, | ||||
| 	0x40000100, | ||||
| 	0x3c8000f2, | ||||
| 	0x390000e4, | ||||
| 	0x35c000d7, | ||||
| 	0x32c000cb, | ||||
| 	0x300000c0, | ||||
| 	0x2d4000b5, | ||||
| 	0x2ac000ab, | ||||
| 	0x288000a2, | ||||
| 	0x26000098, | ||||
| 	0x24000090, | ||||
| 	0x22000088, | ||||
| 	0x20000080, | ||||
| 	0x1e400079, | ||||
| 	0x1c800072, | ||||
| 	0x1b00006c, | ||||
| 	0x19800066, | ||||
| 	0x18000060, | ||||
| 	0x16c0005b, | ||||
| 	0x15800056, | ||||
| 	0x14400051, | ||||
| 	0x1300004c, | ||||
| 	0x12000048, | ||||
| 	0x11000044, | ||||
| 	0x10000040, | ||||
| }; | ||||
| 
 | ||||
| static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE][8] = { | ||||
| 	{0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, | ||||
| 	{0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, | ||||
| 	{0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, | ||||
| 	{0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, | ||||
| 	{0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, | ||||
| 	{0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, | ||||
| 	{0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, | ||||
| 	{0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, | ||||
| 	{0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, | ||||
| 	{0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, | ||||
| 	{0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, | ||||
| 	{0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, | ||||
| 	{0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, | ||||
| 	{0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, | ||||
| 	{0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, | ||||
| 	{0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, | ||||
| 	{0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, | ||||
| 	{0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, | ||||
| 	{0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, | ||||
| 	{0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, | ||||
| 	{0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, | ||||
| 	{0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, | ||||
| 	{0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, | ||||
| 	{0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, | ||||
| 	{0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, | ||||
| 	{0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, | ||||
| 	{0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, | ||||
| 	{0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, | ||||
| 	{0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, | ||||
| 	{0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, | ||||
| 	{0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, | ||||
| 	{0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, | ||||
| 	{0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} | ||||
| }; | ||||
| 
 | ||||
| static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = { | ||||
| 	{0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, | ||||
| 	{0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} | ||||
| }; | ||||
| 
 | ||||
| static void rtl8723e_dm_diginit(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	dm_digtable->dig_enable_flag = true; | ||||
| 	dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; | ||||
| 	dm_digtable->cur_igvalue = 0x20; | ||||
| 	dm_digtable->pre_igvalue = 0x0; | ||||
| 	dm_digtable->cursta_cstate = DIG_STA_DISCONNECT; | ||||
| 	dm_digtable->presta_cstate = DIG_STA_DISCONNECT; | ||||
| 	dm_digtable->curmultista_cstate = DIG_MULTISTA_DISCONNECT; | ||||
| 	dm_digtable->rssi_lowthresh = DM_DIG_THRESH_LOW; | ||||
| 	dm_digtable->rssi_highthresh = DM_DIG_THRESH_HIGH; | ||||
| 	dm_digtable->fa_lowthresh = DM_FALSEALARM_THRESH_LOW; | ||||
| 	dm_digtable->fa_highthresh = DM_FALSEALARM_THRESH_HIGH; | ||||
| 	dm_digtable->rx_gain_max = DM_DIG_MAX; | ||||
| 	dm_digtable->rx_gain_min = DM_DIG_MIN; | ||||
| 	dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT; | ||||
| 	dm_digtable->back_range_max = DM_DIG_BACKOFF_MAX; | ||||
| 	dm_digtable->back_range_min = DM_DIG_BACKOFF_MIN; | ||||
| 	dm_digtable->pre_cck_pd_state = CCK_PD_STAGE_MAX; | ||||
| 	dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX; | ||||
| } | ||||
| 
 | ||||
| static u8 rtl8723e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 	long rssi_val_min = 0; | ||||
| 
 | ||||
| 	if ((dm_digtable->curmultista_cstate == DIG_MULTISTA_CONNECT) && | ||||
| 	    (dm_digtable->cursta_cstate == DIG_STA_CONNECT)) { | ||||
| 		if (rtlpriv->dm.entry_min_undec_sm_pwdb != 0) | ||||
| 			rssi_val_min = | ||||
| 			    (rtlpriv->dm.entry_min_undec_sm_pwdb > | ||||
| 			     rtlpriv->dm.undec_sm_pwdb) ? | ||||
| 			    rtlpriv->dm.undec_sm_pwdb : | ||||
| 			    rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 		else | ||||
| 			rssi_val_min = rtlpriv->dm.undec_sm_pwdb; | ||||
| 	} else if (dm_digtable->cursta_cstate == DIG_STA_CONNECT || | ||||
| 		   dm_digtable->cursta_cstate == DIG_STA_BEFORE_CONNECT) { | ||||
| 		rssi_val_min = rtlpriv->dm.undec_sm_pwdb; | ||||
| 	} else if (dm_digtable->curmultista_cstate == | ||||
| 		DIG_MULTISTA_CONNECT) { | ||||
| 		rssi_val_min = rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 	} | ||||
| 
 | ||||
| 	return (u8) rssi_val_min; | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	u32 ret_value; | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt); | ||||
| 
 | ||||
| 	ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER1, MASKDWORD); | ||||
| 	falsealm_cnt->cnt_parity_fail = ((ret_value & 0xffff0000) >> 16); | ||||
| 
 | ||||
| 	ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER2, MASKDWORD); | ||||
| 	falsealm_cnt->cnt_rate_illegal = (ret_value & 0xffff); | ||||
| 	falsealm_cnt->cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16); | ||||
| 
 | ||||
| 	ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER3, MASKDWORD); | ||||
| 	falsealm_cnt->cnt_mcs_fail = (ret_value & 0xffff); | ||||
| 	falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail + | ||||
| 	    falsealm_cnt->cnt_rate_illegal + | ||||
| 	    falsealm_cnt->cnt_crc8_fail + falsealm_cnt->cnt_mcs_fail; | ||||
| 
 | ||||
| 	rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, BIT(14), 1); | ||||
| 	ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERLOWER, MASKBYTE0); | ||||
| 	falsealm_cnt->cnt_cck_fail = ret_value; | ||||
| 
 | ||||
| 	ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERUPPER, MASKBYTE3); | ||||
| 	falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8; | ||||
| 	falsealm_cnt->cnt_all = (falsealm_cnt->cnt_parity_fail + | ||||
| 				 falsealm_cnt->cnt_rate_illegal + | ||||
| 				 falsealm_cnt->cnt_crc8_fail + | ||||
| 				 falsealm_cnt->cnt_mcs_fail + | ||||
| 				 falsealm_cnt->cnt_cck_fail); | ||||
| 
 | ||||
| 	rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 1); | ||||
| 	rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 0); | ||||
| 	rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 0); | ||||
| 	rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||||
| 		 "cnt_parity_fail = %d, cnt_rate_illegal = %d, cnt_crc8_fail = %d, cnt_mcs_fail = %d\n", | ||||
| 		 falsealm_cnt->cnt_parity_fail, | ||||
| 		 falsealm_cnt->cnt_rate_illegal, | ||||
| 		 falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||||
| 		 "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n", | ||||
| 		 falsealm_cnt->cnt_ofdm_fail, | ||||
| 		 falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all); | ||||
| } | ||||
| 
 | ||||
| static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 	u8 value_igi = dm_digtable->cur_igvalue; | ||||
| 
 | ||||
| 	if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH0) | ||||
| 		value_igi--; | ||||
| 	else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH1) | ||||
| 		value_igi += 0; | ||||
| 	else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH2) | ||||
| 		value_igi++; | ||||
| 	else if (rtlpriv->falsealm_cnt.cnt_all >= DM_DIG_FA_TH2) | ||||
| 		value_igi += 2; | ||||
| 	if (value_igi > DM_DIG_FA_UPPER) | ||||
| 		value_igi = DM_DIG_FA_UPPER; | ||||
| 	else if (value_igi < DM_DIG_FA_LOWER) | ||||
| 		value_igi = DM_DIG_FA_LOWER; | ||||
| 	if (rtlpriv->falsealm_cnt.cnt_all > 10000) | ||||
| 		value_igi = 0x32; | ||||
| 
 | ||||
| 	dm_digtable->cur_igvalue = value_igi; | ||||
| 	rtl8723e_dm_write_dig(hw); | ||||
| } | ||||
| 
 | ||||
| static void rtl92c_dm_ctrl_initgain_by_rssi(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	if (rtlpriv->falsealm_cnt.cnt_all > dm_digtable->fa_highthresh) { | ||||
| 		if ((dm_digtable->back_val - 2) < | ||||
| 		    dm_digtable->back_range_min) | ||||
| 			dm_digtable->back_val = | ||||
| 			    dm_digtable->back_range_min; | ||||
| 		else | ||||
| 			dm_digtable->back_val -= 2; | ||||
| 	} else if (rtlpriv->falsealm_cnt.cnt_all < dm_digtable->fa_lowthresh) { | ||||
| 		if ((dm_digtable->back_val + 2) > | ||||
| 		    dm_digtable->back_range_max) | ||||
| 			dm_digtable->back_val = | ||||
| 			    dm_digtable->back_range_max; | ||||
| 		else | ||||
| 			dm_digtable->back_val += 2; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((dm_digtable->rssi_val_min + 10 - dm_digtable->back_val) > | ||||
| 	    dm_digtable->rx_gain_max) | ||||
| 		dm_digtable->cur_igvalue = dm_digtable->rx_gain_max; | ||||
| 	else if ((dm_digtable->rssi_val_min + 10 - | ||||
| 		  dm_digtable->back_val) < dm_digtable->rx_gain_min) | ||||
| 		dm_digtable->cur_igvalue = dm_digtable->rx_gain_min; | ||||
| 	else | ||||
| 		dm_digtable->cur_igvalue = dm_digtable->rssi_val_min + 10 - | ||||
| 		    dm_digtable->back_val; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||||
| 		 "rssi_val_min = %x back_val %x\n", | ||||
| 		  dm_digtable->rssi_val_min, dm_digtable->back_val); | ||||
| 
 | ||||
| 	rtl8723e_dm_write_dig(hw); | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_initial_gain_multi_sta(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	static u8 binitialized; | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 	long rssi_strength = rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 	bool multi_sta = false; | ||||
| 
 | ||||
| 	if (mac->opmode == NL80211_IFTYPE_ADHOC) | ||||
| 		multi_sta = true; | ||||
| 
 | ||||
| 	if (!multi_sta || (dm_digtable->cursta_cstate != DIG_STA_DISCONNECT)) { | ||||
| 		binitialized = false; | ||||
| 		dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; | ||||
| 		return; | ||||
| 	} else if (!binitialized) { | ||||
| 		binitialized = true; | ||||
| 		dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_0; | ||||
| 		dm_digtable->cur_igvalue = 0x20; | ||||
| 		rtl8723e_dm_write_dig(hw); | ||||
| 	} | ||||
| 
 | ||||
| 	if (dm_digtable->curmultista_cstate == DIG_MULTISTA_CONNECT) { | ||||
| 		if ((rssi_strength < dm_digtable->rssi_lowthresh) && | ||||
| 		    (dm_digtable->dig_ext_port_stage != DIG_EXT_PORT_STAGE_1)) { | ||||
| 
 | ||||
| 			if (dm_digtable->dig_ext_port_stage == | ||||
| 			    DIG_EXT_PORT_STAGE_2) { | ||||
| 				dm_digtable->cur_igvalue = 0x20; | ||||
| 				rtl8723e_dm_write_dig(hw); | ||||
| 			} | ||||
| 
 | ||||
| 			dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_1; | ||||
| 		} else if (rssi_strength > dm_digtable->rssi_highthresh) { | ||||
| 			dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_2; | ||||
| 			rtl92c_dm_ctrl_initgain_by_fa(hw); | ||||
| 		} | ||||
| 	} else if (dm_digtable->dig_ext_port_stage != DIG_EXT_PORT_STAGE_0) { | ||||
| 		dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_0; | ||||
| 		dm_digtable->cur_igvalue = 0x20; | ||||
| 		rtl8723e_dm_write_dig(hw); | ||||
| 	} | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||||
| 		 "curmultista_cstate = %x dig_ext_port_stage %x\n", | ||||
| 		 dm_digtable->curmultista_cstate, | ||||
| 		 dm_digtable->dig_ext_port_stage); | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_initial_gain_sta(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||||
| 		 "presta_cstate = %x, cursta_cstate = %x\n", | ||||
| 		  dm_digtable->presta_cstate, | ||||
| 		  dm_digtable->cursta_cstate); | ||||
| 
 | ||||
| 	if (dm_digtable->presta_cstate == dm_digtable->cursta_cstate || | ||||
| 	    dm_digtable->cursta_cstate == DIG_STA_BEFORE_CONNECT || | ||||
| 	    dm_digtable->cursta_cstate == DIG_STA_CONNECT) { | ||||
| 		if (dm_digtable->cursta_cstate != DIG_STA_DISCONNECT) { | ||||
| 			dm_digtable->rssi_val_min = | ||||
| 			    rtl8723e_dm_initial_gain_min_pwdb(hw); | ||||
| 			rtl92c_dm_ctrl_initgain_by_rssi(hw); | ||||
| 		} | ||||
| 	} else { | ||||
| 		dm_digtable->rssi_val_min = 0; | ||||
| 		dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX; | ||||
| 		dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT; | ||||
| 		dm_digtable->cur_igvalue = 0x20; | ||||
| 		dm_digtable->pre_igvalue = 0; | ||||
| 		rtl8723e_dm_write_dig(hw); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	if (dm_digtable->cursta_cstate == DIG_STA_CONNECT) { | ||||
| 		dm_digtable->rssi_val_min = rtl8723e_dm_initial_gain_min_pwdb(hw); | ||||
| 
 | ||||
| 		if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LowRssi) { | ||||
| 			if (dm_digtable->rssi_val_min <= 25) | ||||
| 				dm_digtable->cur_cck_pd_state = | ||||
| 				    CCK_PD_STAGE_LowRssi; | ||||
| 			else | ||||
| 				dm_digtable->cur_cck_pd_state = | ||||
| 				    CCK_PD_STAGE_HighRssi; | ||||
| 		} else { | ||||
| 			if (dm_digtable->rssi_val_min <= 20) | ||||
| 				dm_digtable->cur_cck_pd_state = | ||||
| 				    CCK_PD_STAGE_LowRssi; | ||||
| 			else | ||||
| 				dm_digtable->cur_cck_pd_state = | ||||
| 				    CCK_PD_STAGE_HighRssi; | ||||
| 		} | ||||
| 	} else { | ||||
| 		dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX; | ||||
| 	} | ||||
| 
 | ||||
| 	if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) { | ||||
| 		if (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LowRssi) { | ||||
| 			if (rtlpriv->falsealm_cnt.cnt_cck_fail > 800) | ||||
| 				dm_digtable->cur_cck_fa_state = | ||||
| 				    CCK_FA_STAGE_High; | ||||
| 			else | ||||
| 				dm_digtable->cur_cck_fa_state = | ||||
| 				    CCK_FA_STAGE_LOW; | ||||
| 			if (dm_digtable->pre_cck_fa_state != | ||||
| 			    dm_digtable->cur_cck_fa_state) { | ||||
| 				if (dm_digtable->cur_cck_fa_state == | ||||
| 				    CCK_FA_STAGE_LOW) | ||||
| 					rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, | ||||
| 						      0x83); | ||||
| 				else | ||||
| 					rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, | ||||
| 						      0xcd); | ||||
| 
 | ||||
| 				dm_digtable->pre_cck_fa_state = | ||||
| 				    dm_digtable->cur_cck_fa_state; | ||||
| 			} | ||||
| 
 | ||||
| 			rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x40); | ||||
| 
 | ||||
| 		} else { | ||||
| 			rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd); | ||||
| 			rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x47); | ||||
| 
 | ||||
| 		} | ||||
| 		dm_digtable->pre_cck_pd_state = dm_digtable->cur_cck_pd_state; | ||||
| 	} | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE, | ||||
| 		 "CCKPDStage=%x\n", dm_digtable->cur_cck_pd_state); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	if (mac->act_scanning) | ||||
| 		return; | ||||
| 
 | ||||
| 	if (mac->link_state >= MAC80211_LINKED) | ||||
| 		dm_digtable->cursta_cstate = DIG_STA_CONNECT; | ||||
| 	else | ||||
| 		dm_digtable->cursta_cstate = DIG_STA_DISCONNECT; | ||||
| 
 | ||||
| 	rtl8723e_dm_initial_gain_sta(hw); | ||||
| 	rtl8723e_dm_initial_gain_multi_sta(hw); | ||||
| 	rtl8723e_dm_cck_packet_detection_thresh(hw); | ||||
| 
 | ||||
| 	dm_digtable->presta_cstate = dm_digtable->cursta_cstate; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_dig(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	if (!rtlpriv->dm.dm_initialgain_enable) | ||||
| 		return; | ||||
| 	if (!dm_digtable->dig_enable_flag) | ||||
| 		return; | ||||
| 
 | ||||
| 	rtl8723e_dm_ctrl_initgain_by_twoport(hw); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_dynamic_txpower(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	long undec_sm_pwdb; | ||||
| 
 | ||||
| 	if (!rtlpriv->dm.dynamic_txpower_enable) | ||||
| 		return; | ||||
| 
 | ||||
| 	if (rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) { | ||||
| 		rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	if ((mac->link_state < MAC80211_LINKED) && | ||||
| 	    (rtlpriv->dm.entry_min_undec_sm_pwdb == 0)) { | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE, | ||||
| 			 "Not connected to any\n"); | ||||
| 
 | ||||
| 		rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||||
| 
 | ||||
| 		rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL; | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	if (mac->link_state >= MAC80211_LINKED) { | ||||
| 		if (mac->opmode == NL80211_IFTYPE_ADHOC) { | ||||
| 			undec_sm_pwdb = | ||||
| 			    rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 			RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 				 "AP Client PWDB = 0x%lx\n", | ||||
| 				  undec_sm_pwdb); | ||||
| 		} else { | ||||
| 			undec_sm_pwdb = | ||||
| 			    rtlpriv->dm.undec_sm_pwdb; | ||||
| 			RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 				 "STA Default Port PWDB = 0x%lx\n", | ||||
| 				  undec_sm_pwdb); | ||||
| 		} | ||||
| 	} else { | ||||
| 		undec_sm_pwdb = | ||||
| 		    rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 
 | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 			 "AP Ext Port PWDB = 0x%lx\n", | ||||
| 			  undec_sm_pwdb); | ||||
| 	} | ||||
| 
 | ||||
| 	if (undec_sm_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) { | ||||
| 		rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 			 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n"); | ||||
| 	} else if ((undec_sm_pwdb < | ||||
| 		    (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) && | ||||
| 		   (undec_sm_pwdb >= | ||||
| 		    TX_POWER_NEAR_FIELD_THRESH_LVL1)) { | ||||
| 		rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1; | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 			 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n"); | ||||
| 	} else if (undec_sm_pwdb < | ||||
| 		   (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) { | ||||
| 		rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL; | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 			 "TXHIGHPWRLEVEL_NORMAL\n"); | ||||
| 	} | ||||
| 
 | ||||
| 	if (rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl) { | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 			 "PHY_SetTxPowerLevel8192S() Channel = %d\n", | ||||
| 			  rtlphy->current_channel); | ||||
| 		rtl8723e_phy_set_txpower_level(hw, rtlphy->current_channel); | ||||
| 	} | ||||
| 
 | ||||
| 	rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_write_dig(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct dig_t *dm_digtable = &rtlpriv->dm_digtable; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD, | ||||
| 		 "cur_igvalue = 0x%x, pre_igvalue = 0x%x, back_val = %d\n", | ||||
| 		  dm_digtable->cur_igvalue, dm_digtable->pre_igvalue, | ||||
| 		  dm_digtable->back_val); | ||||
| 
 | ||||
| 	if (dm_digtable->pre_igvalue != dm_digtable->cur_igvalue) { | ||||
| 		rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f, | ||||
| 			      dm_digtable->cur_igvalue); | ||||
| 		rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1, 0x7f, | ||||
| 			      dm_digtable->cur_igvalue); | ||||
| 
 | ||||
| 		dm_digtable->pre_igvalue = dm_digtable->cur_igvalue; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_pwdb_monitor(struct ieee80211_hw *hw) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_check_edca_turbo(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 
 | ||||
| 	static u64 last_txok_cnt; | ||||
| 	static u64 last_rxok_cnt; | ||||
| 	static u32 last_bt_edca_ul; | ||||
| 	static u32 last_bt_edca_dl; | ||||
| 	u64 cur_txok_cnt = 0; | ||||
| 	u64 cur_rxok_cnt = 0; | ||||
| 	u32 edca_be_ul = 0x5ea42b; | ||||
| 	u32 edca_be_dl = 0x5ea42b; | ||||
| 	bool bt_change_edca = false; | ||||
| 
 | ||||
| 	if ((last_bt_edca_ul != rtlpriv->btcoexist.bt_edca_ul) || | ||||
| 	    (last_bt_edca_dl != rtlpriv->btcoexist.bt_edca_dl)) { | ||||
| 		rtlpriv->dm.current_turbo_edca = false; | ||||
| 		last_bt_edca_ul = rtlpriv->btcoexist.bt_edca_ul; | ||||
| 		last_bt_edca_dl = rtlpriv->btcoexist.bt_edca_dl; | ||||
| 	} | ||||
| 
 | ||||
| 	if (rtlpriv->btcoexist.bt_edca_ul != 0) { | ||||
| 		edca_be_ul = rtlpriv->btcoexist.bt_edca_ul; | ||||
| 		bt_change_edca = true; | ||||
| 	} | ||||
| 
 | ||||
| 	if (rtlpriv->btcoexist.bt_edca_dl != 0) { | ||||
| 		edca_be_ul = rtlpriv->btcoexist.bt_edca_dl; | ||||
| 		bt_change_edca = true; | ||||
| 	} | ||||
| 
 | ||||
| 	if (mac->link_state != MAC80211_LINKED) { | ||||
| 		rtlpriv->dm.current_turbo_edca = false; | ||||
| 		return; | ||||
| 	} | ||||
| 	if ((bt_change_edca) || ((!rtlpriv->dm.is_any_nonbepkts) && | ||||
| 	     (!rtlpriv->dm.disable_framebursting))) { | ||||
| 
 | ||||
| 		cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt; | ||||
| 		cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt; | ||||
| 
 | ||||
| 		if (cur_rxok_cnt > 4 * cur_txok_cnt) { | ||||
| 			if (!rtlpriv->dm.is_cur_rdlstate || | ||||
| 			    !rtlpriv->dm.current_turbo_edca) { | ||||
| 				rtl_write_dword(rtlpriv, | ||||
| 						REG_EDCA_BE_PARAM, | ||||
| 						edca_be_dl); | ||||
| 				rtlpriv->dm.is_cur_rdlstate = true; | ||||
| 			} | ||||
| 		} else { | ||||
| 			if (rtlpriv->dm.is_cur_rdlstate || | ||||
| 			    !rtlpriv->dm.current_turbo_edca) { | ||||
| 				rtl_write_dword(rtlpriv, | ||||
| 						REG_EDCA_BE_PARAM, | ||||
| 						edca_be_ul); | ||||
| 				rtlpriv->dm.is_cur_rdlstate = false; | ||||
| 			} | ||||
| 		} | ||||
| 		rtlpriv->dm.current_turbo_edca = true; | ||||
| 	} else { | ||||
| 		if (rtlpriv->dm.current_turbo_edca) { | ||||
| 			u8 tmp = AC0_BE; | ||||
| 			rtlpriv->cfg->ops->set_hw_reg(hw, | ||||
| 						      HW_VAR_AC_PARAM, | ||||
| 						      (u8 *)(&tmp)); | ||||
| 			rtlpriv->dm.current_turbo_edca = false; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	rtlpriv->dm.is_any_nonbepkts = false; | ||||
| 	last_txok_cnt = rtlpriv->stats.txbytesunicast; | ||||
| 	last_rxok_cnt = rtlpriv->stats.rxbytesunicast; | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_initialize_txpower_tracking_thermalmeter( | ||||
| 				struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	rtlpriv->dm.txpower_tracking = true; | ||||
| 	rtlpriv->dm.txpower_trackinginit = false; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, | ||||
| 		 "pMgntInfo->txpower_tracking = %d\n", | ||||
| 		  rtlpriv->dm.txpower_tracking); | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_initialize_txpower_tracking(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	rtl8723e_dm_initialize_txpower_tracking_thermalmeter(hw); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_check_txpower_tracking(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	return; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rate_adaptive *p_ra = &(rtlpriv->ra); | ||||
| 
 | ||||
| 	p_ra->ratr_state = DM_RATR_STA_INIT; | ||||
| 	p_ra->pre_ratr_state = DM_RATR_STA_INIT; | ||||
| 
 | ||||
| 	if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER) | ||||
| 		rtlpriv->dm.useramask = true; | ||||
| 	else | ||||
| 		rtlpriv->dm.useramask = false; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct ps_t *dm_pstable = &rtlpriv->dm_pstable; | ||||
| 	static u8 initialize; | ||||
| 	static u32 reg_874, reg_c70, reg_85c, reg_a74; | ||||
| 
 | ||||
| 	if (initialize == 0) { | ||||
| 		reg_874 = (rtl_get_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||||
| 					 MASKDWORD) & 0x1CC000) >> 14; | ||||
| 
 | ||||
| 		reg_c70 = (rtl_get_bbreg(hw, ROFDM0_AGCPARAMETER1, | ||||
| 					 MASKDWORD) & BIT(3)) >> 3; | ||||
| 
 | ||||
| 		reg_85c = (rtl_get_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, | ||||
| 					 MASKDWORD) & 0xFF000000) >> 24; | ||||
| 
 | ||||
| 		reg_a74 = (rtl_get_bbreg(hw, 0xa74, MASKDWORD) & 0xF000) >> 12; | ||||
| 
 | ||||
| 		initialize = 1; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!bforce_in_normal) { | ||||
| 		if (dm_pstable->rssi_val_min != 0) { | ||||
| 			if (dm_pstable->pre_rfstate == RF_NORMAL) { | ||||
| 				if (dm_pstable->rssi_val_min >= 30) | ||||
| 					dm_pstable->cur_rfstate = RF_SAVE; | ||||
| 				else | ||||
| 					dm_pstable->cur_rfstate = RF_NORMAL; | ||||
| 			} else { | ||||
| 				if (dm_pstable->rssi_val_min <= 25) | ||||
| 					dm_pstable->cur_rfstate = RF_NORMAL; | ||||
| 				else | ||||
| 					dm_pstable->cur_rfstate = RF_SAVE; | ||||
| 			} | ||||
| 		} else { | ||||
| 			dm_pstable->cur_rfstate = RF_MAX; | ||||
| 		} | ||||
| 	} else { | ||||
| 		dm_pstable->cur_rfstate = RF_NORMAL; | ||||
| 	} | ||||
| 
 | ||||
| 	if (dm_pstable->pre_rfstate != dm_pstable->cur_rfstate) { | ||||
| 		if (dm_pstable->cur_rfstate == RF_SAVE) { | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||||
| 				      BIT(5), 0x1); | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||||
| 				      0x1C0000, 0x2); | ||||
| 			rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, BIT(3), 0); | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, | ||||
| 				      0xFF000000, 0x63); | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||||
| 				      0xC000, 0x2); | ||||
| 			rtl_set_bbreg(hw, 0xa74, 0xF000, 0x3); | ||||
| 			rtl_set_bbreg(hw, 0x818, BIT(28), 0x0); | ||||
| 			rtl_set_bbreg(hw, 0x818, BIT(28), 0x1); | ||||
| 		} else { | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||||
| 				      0x1CC000, reg_874); | ||||
| 			rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, BIT(3), | ||||
| 				      reg_c70); | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, 0xFF000000, | ||||
| 				      reg_85c); | ||||
| 			rtl_set_bbreg(hw, 0xa74, 0xF000, reg_a74); | ||||
| 			rtl_set_bbreg(hw, 0x818, BIT(28), 0x0); | ||||
| 			rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW, | ||||
| 				      BIT(5), 0x0); | ||||
| 		} | ||||
| 
 | ||||
| 		dm_pstable->pre_rfstate = dm_pstable->cur_rfstate; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct ps_t *dm_pstable = &rtlpriv->dm_pstable; | ||||
| 
 | ||||
| 	if (((mac->link_state == MAC80211_NOLINK)) && | ||||
| 	    (rtlpriv->dm.entry_min_undec_sm_pwdb == 0)) { | ||||
| 		dm_pstable->rssi_val_min = 0; | ||||
| 		RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||||
| 			 "Not connected to any\n"); | ||||
| 	} | ||||
| 
 | ||||
| 	if (mac->link_state == MAC80211_LINKED) { | ||||
| 		if (mac->opmode == NL80211_IFTYPE_ADHOC) { | ||||
| 			dm_pstable->rssi_val_min = | ||||
| 			    rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 			RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||||
| 				 "AP Client PWDB = 0x%lx\n", | ||||
| 				  dm_pstable->rssi_val_min); | ||||
| 		} else { | ||||
| 			dm_pstable->rssi_val_min = | ||||
| 			    rtlpriv->dm.undec_sm_pwdb; | ||||
| 			RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||||
| 				 "STA Default Port PWDB = 0x%lx\n", | ||||
| 				  dm_pstable->rssi_val_min); | ||||
| 		} | ||||
| 	} else { | ||||
| 		dm_pstable->rssi_val_min = | ||||
| 		    rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 
 | ||||
| 		RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD, | ||||
| 			 "AP Ext Port PWDB = 0x%lx\n", | ||||
| 			  dm_pstable->rssi_val_min); | ||||
| 	} | ||||
| 
 | ||||
| 	rtl8723e_dm_rf_saving(hw, false); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_init(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER; | ||||
| 	rtl8723e_dm_diginit(hw); | ||||
| 	rtl8723_dm_init_dynamic_txpower(hw); | ||||
| 	rtl8723_dm_init_edca_turbo(hw); | ||||
| 	rtl8723e_dm_init_rate_adaptive_mask(hw); | ||||
| 	rtl8723e_dm_initialize_txpower_tracking(hw); | ||||
| 	rtl8723_dm_init_dynamic_bb_powersaving(hw); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_watchdog(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | ||||
| 	bool fw_current_inpsmode = false; | ||||
| 	bool fw_ps_awake = true; | ||||
| 	rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS, | ||||
| 				      (u8 *)(&fw_current_inpsmode)); | ||||
| 	rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FWLPS_RF_ON, | ||||
| 				      (u8 *)(&fw_ps_awake)); | ||||
| 
 | ||||
| 	if (ppsc->p2p_ps_info.p2p_ps_mode) | ||||
| 		fw_ps_awake = false; | ||||
| 
 | ||||
| 	if ((ppsc->rfpwr_state == ERFON) && | ||||
| 	    ((!fw_current_inpsmode) && fw_ps_awake) && | ||||
| 	    (!ppsc->rfchange_inprogress)) { | ||||
| 		rtl8723e_dm_pwdb_monitor(hw); | ||||
| 		rtl8723e_dm_dig(hw); | ||||
| 		rtl8723e_dm_false_alarm_counter_statistics(hw); | ||||
| 		rtl8723e_dm_dynamic_bb_powersaving(hw); | ||||
| 		rtl8723e_dm_dynamic_txpower(hw); | ||||
| 		rtl8723e_dm_check_txpower_tracking(hw); | ||||
| 		/* rtl92c_dm_refresh_rate_adaptive_mask(hw); */ | ||||
| 		rtl8723e_dm_bt_coexist(hw); | ||||
| 		rtl8723e_dm_check_edca_turbo(hw); | ||||
| 	} | ||||
| 	if (rtlpriv->btcoexist.init_set) | ||||
| 		rtl_write_byte(rtlpriv, 0x76e, 0xc); | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_dm_init_bt_coexist(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	rtlpriv->btcoexist.bt_rfreg_origin_1e | ||||
| 		= rtl_get_rfreg(hw, (enum radio_path)0, RF_RCK1, 0xfffff); | ||||
| 	rtlpriv->btcoexist.bt_rfreg_origin_1f | ||||
| 		= rtl_get_rfreg(hw, (enum radio_path)0, RF_RCK2, 0xf0); | ||||
| 
 | ||||
| 	rtlpriv->btcoexist.cstate = 0; | ||||
| 	rtlpriv->btcoexist.previous_state = 0; | ||||
| 	rtlpriv->btcoexist.cstate_h = 0; | ||||
| 	rtlpriv->btcoexist.previous_state_h = 0; | ||||
| 	rtlpriv->btcoexist.lps_counter = 0; | ||||
| 
 | ||||
| 	/*  Enable counter statistics */ | ||||
| 	rtl_write_byte(rtlpriv, 0x76e, 0x4); | ||||
| 	rtl_write_byte(rtlpriv, 0x778, 0x3); | ||||
| 	rtl_write_byte(rtlpriv, 0x40, 0x20); | ||||
| 
 | ||||
| 	rtlpriv->btcoexist.init_set = true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_bt_coexist(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 tmp_byte = 0; | ||||
| 	if (!rtlpriv->btcoexist.bt_coexistence) { | ||||
| 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, | ||||
| 			 "[DM]{BT], BT not exist!!\n"); | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	if (!rtlpriv->btcoexist.init_set) { | ||||
| 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, | ||||
| 			 "[DM][BT], rtl8723e_dm_bt_coexist()\n"); | ||||
| 		rtl8723e_dm_init_bt_coexist(hw); | ||||
| 	} | ||||
| 
 | ||||
| 	tmp_byte = rtl_read_byte(rtlpriv, 0x40); | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD, | ||||
| 		 "[DM][BT], 0x40 is 0x%x", tmp_byte); | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG, | ||||
| 		 "[DM][BT], bt_dm_coexist start"); | ||||
| 	rtl8723e_dm_bt_coexist_8723(hw); | ||||
| } | ||||
							
								
								
									
										174
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										174
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/dm.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,174 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with | ||||
|  * this program; if not, write to the Free Software Foundation, Inc., | ||||
|  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef	__RTL8723E_DM_H__ | ||||
| #define __RTL8723E_DM_H__ | ||||
| 
 | ||||
| #define HAL_DM_DIG_DISABLE			BIT(0) | ||||
| #define HAL_DM_HIPWR_DISABLE			BIT(1) | ||||
| 
 | ||||
| #define OFDM_TABLE_LENGTH			37 | ||||
| #define CCK_TABLE_LENGTH			33 | ||||
| 
 | ||||
| #define OFDM_TABLE_SIZE				37 | ||||
| #define CCK_TABLE_SIZE				33 | ||||
| 
 | ||||
| #define BW_AUTO_SWITCH_HIGH_LOW			25 | ||||
| #define BW_AUTO_SWITCH_LOW_HIGH			30 | ||||
| 
 | ||||
| #define DM_DIG_THRESH_HIGH			40 | ||||
| #define DM_DIG_THRESH_LOW			35 | ||||
| 
 | ||||
| #define DM_FALSEALARM_THRESH_LOW		400 | ||||
| #define DM_FALSEALARM_THRESH_HIGH		1000 | ||||
| 
 | ||||
| #define DM_DIG_MAX				0x3e | ||||
| #define DM_DIG_MIN				0x1e | ||||
| 
 | ||||
| #define DM_DIG_FA_UPPER				0x32 | ||||
| #define DM_DIG_FA_LOWER				0x20 | ||||
| #define DM_DIG_FA_TH0				0x20 | ||||
| #define DM_DIG_FA_TH1				0x100 | ||||
| #define DM_DIG_FA_TH2				0x200 | ||||
| 
 | ||||
| #define DM_DIG_BACKOFF_MAX			12 | ||||
| #define DM_DIG_BACKOFF_MIN			-4 | ||||
| #define DM_DIG_BACKOFF_DEFAULT			10 | ||||
| 
 | ||||
| #define RXPATHSELECTION_SS_TH_LOW		30 | ||||
| #define RXPATHSELECTION_DIFF_TH			18 | ||||
| 
 | ||||
| #define DM_RATR_STA_INIT			0 | ||||
| #define DM_RATR_STA_HIGH			1 | ||||
| #define DM_RATR_STA_MIDDLE			2 | ||||
| #define DM_RATR_STA_LOW				3 | ||||
| 
 | ||||
| #define CTS2SELF_THVAL				30 | ||||
| #define REGC38_TH				20 | ||||
| 
 | ||||
| #define WAIOTTHVAL				25 | ||||
| 
 | ||||
| #define TXHIGHPWRLEVEL_NORMAL			0 | ||||
| #define TXHIGHPWRLEVEL_LEVEL1			1 | ||||
| #define TXHIGHPWRLEVEL_LEVEL2			2 | ||||
| #define TXHIGHPWRLEVEL_BT1			3 | ||||
| #define TXHIGHPWRLEVEL_BT2			4 | ||||
| 
 | ||||
| #define DM_TYPE_BYFW				0 | ||||
| #define DM_TYPE_BYDRIVER			1 | ||||
| 
 | ||||
| #define TX_POWER_NEAR_FIELD_THRESH_LVL2		74 | ||||
| #define TX_POWER_NEAR_FIELD_THRESH_LVL1		67 | ||||
| 
 | ||||
| struct swat_t { | ||||
| 	u8 failure_cnt; | ||||
| 	u8 try_flag; | ||||
| 	u8 stop_trying; | ||||
| 	long pre_rssi; | ||||
| 	long trying_threshold; | ||||
| 	u8 cur_antenna; | ||||
| 	u8 pre_antenna; | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| enum tag_dynamic_init_gain_operation_type_definition { | ||||
| 	DIG_TYPE_THRESH_HIGH = 0, | ||||
| 	DIG_TYPE_THRESH_LOW = 1, | ||||
| 	DIG_TYPE_BACKOFF = 2, | ||||
| 	DIG_TYPE_RX_GAIN_MIN = 3, | ||||
| 	DIG_TYPE_RX_GAIN_MAX = 4, | ||||
| 	DIG_TYPE_ENABLE = 5, | ||||
| 	DIG_TYPE_DISABLE = 6, | ||||
| 	DIG_OP_TYPE_MAX | ||||
| }; | ||||
| 
 | ||||
| enum tag_cck_packet_detection_threshold_type_definition { | ||||
| 	CCK_PD_STAGE_LowRssi = 0, | ||||
| 	CCK_PD_STAGE_HighRssi = 1, | ||||
| 	CCK_FA_STAGE_LOW = 2, | ||||
| 	CCK_FA_STAGE_High = 3, | ||||
| 	CCK_PD_STAGE_MAX = 4, | ||||
| }; | ||||
| 
 | ||||
| enum dm_1r_cca_e { | ||||
| 	CCA_1R = 0, | ||||
| 	CCA_2R = 1, | ||||
| 	CCA_MAX = 2, | ||||
| }; | ||||
| 
 | ||||
| enum dm_rf_e { | ||||
| 	RF_SAVE = 0, | ||||
| 	RF_NORMAL = 1, | ||||
| 	RF_MAX = 2, | ||||
| }; | ||||
| 
 | ||||
| enum dm_sw_ant_switch_e { | ||||
| 	ANS_ANTENNA_B = 1, | ||||
| 	ANS_ANTENNA_A = 2, | ||||
| 	ANS_ANTENNA_MAX = 3, | ||||
| }; | ||||
| 
 | ||||
| enum dm_dig_ext_port_alg_e { | ||||
| 	DIG_EXT_PORT_STAGE_0 = 0, | ||||
| 	DIG_EXT_PORT_STAGE_1 = 1, | ||||
| 	DIG_EXT_PORT_STAGE_2 = 2, | ||||
| 	DIG_EXT_PORT_STAGE_3 = 3, | ||||
| 	DIG_EXT_PORT_STAGE_MAX = 4, | ||||
| }; | ||||
| 
 | ||||
| enum dm_dig_connect_e { | ||||
| 	DIG_STA_DISCONNECT = 0, | ||||
| 	DIG_STA_CONNECT = 1, | ||||
| 	DIG_STA_BEFORE_CONNECT = 2, | ||||
| 	DIG_MULTISTA_DISCONNECT = 3, | ||||
| 	DIG_MULTISTA_CONNECT = 4, | ||||
| 	DIG_CONNECT_MAX | ||||
| }; | ||||
| 
 | ||||
| #define BT_RSSI_STATE_NORMAL_POWER      BIT_OFFSET_LEN_MASK_32(0, 1) | ||||
| #define BT_RSSI_STATE_AMDPU_OFF         BIT_OFFSET_LEN_MASK_32(1, 1) | ||||
| #define BT_RSSI_STATE_SPECIAL_LOW       BIT_OFFSET_LEN_MASK_32(2, 1) | ||||
| #define BT_RSSI_STATE_BG_EDCA_LOW       BIT_OFFSET_LEN_MASK_32(3, 1) | ||||
| #define BT_RSSI_STATE_TXPOWER_LOW       BIT_OFFSET_LEN_MASK_32(4, 1) | ||||
| #define GET_UNDECORATED_AVERAGE_RSSI(_priv)     \ | ||||
| 	( \ | ||||
| 	(((struct rtl_priv *)(_priv))->mac80211.opmode ==		\ | ||||
| 			     NL80211_IFTYPE_ADHOC) ?			\ | ||||
| 	(((struct rtl_priv *)(_priv))->dm.entry_min_undec_sm_pwdb) :	\ | ||||
| 	(((struct rtl_priv *)(_priv))->dm.undec_sm_pwdb)		\ | ||||
| 	) | ||||
| 
 | ||||
| void rtl8723e_dm_init(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_watchdog(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_write_dig(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_check_txpower_tracking(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal); | ||||
| void rtl8723e_dm_bt_coexist(struct ieee80211_hw *hw); | ||||
| #endif | ||||
							
								
								
									
										603
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/fw.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										603
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/fw.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,603 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "../pci.h" | ||||
| #include "../base.h" | ||||
| #include "../core.h" | ||||
| #include "reg.h" | ||||
| #include "def.h" | ||||
| #include "fw.h" | ||||
| #include "../rtl8723com/fw_common.h" | ||||
| 
 | ||||
| static bool _rtl8723e_check_fw_read_last_h2c(struct ieee80211_hw *hw, | ||||
| 					     u8 boxnum) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 val_hmetfr, val_mcutst_1; | ||||
| 	bool result = false; | ||||
| 
 | ||||
| 	val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR); | ||||
| 	val_mcutst_1 = rtl_read_byte(rtlpriv, (REG_MCUTST_1 + boxnum)); | ||||
| 
 | ||||
| 	if (((val_hmetfr >> boxnum) & BIT(0)) == 0 && val_mcutst_1 == 0) | ||||
| 		result = true; | ||||
| 	return result; | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723e_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id, | ||||
| 				       u32 cmd_len, u8 *cmdbuffer) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||||
| 	u8 boxnum; | ||||
| 	u16 box_reg = 0, box_extreg = 0; | ||||
| 	u8 u1b_tmp; | ||||
| 	bool isfw_read = false; | ||||
| 	u8 buf_index = 0; | ||||
| 	bool bwrite_sucess = false; | ||||
| 	u8 wait_h2c_limmit = 100; | ||||
| 	u8 wait_writeh2c_limmit = 100; | ||||
| 	u8 boxcontent[4], boxextcontent[2]; | ||||
| 	u32 h2c_waitcounter = 0; | ||||
| 	unsigned long flag; | ||||
| 	u8 idx; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "come in\n"); | ||||
| 
 | ||||
| 	while (true) { | ||||
| 		spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); | ||||
| 		if (rtlhal->h2c_setinprogress) { | ||||
| 			RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 				 "H2C set in progress! Wait to set..element_id(%d).\n", | ||||
| 				 element_id); | ||||
| 
 | ||||
| 			while (rtlhal->h2c_setinprogress) { | ||||
| 				spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, | ||||
| 						       flag); | ||||
| 				h2c_waitcounter++; | ||||
| 				RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 					 "Wait 100 us (%d times)...\n", | ||||
| 					  h2c_waitcounter); | ||||
| 				udelay(100); | ||||
| 
 | ||||
| 				if (h2c_waitcounter > 1000) | ||||
| 					return; | ||||
| 				spin_lock_irqsave(&rtlpriv->locks.h2c_lock, | ||||
| 						  flag); | ||||
| 			} | ||||
| 			spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); | ||||
| 		} else { | ||||
| 			rtlhal->h2c_setinprogress = true; | ||||
| 			spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	while (!bwrite_sucess) { | ||||
| 		wait_writeh2c_limmit--; | ||||
| 		if (wait_writeh2c_limmit == 0) { | ||||
| 			RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 				 "Write H2C fail because no trigger for FW INT!\n"); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		boxnum = rtlhal->last_hmeboxnum; | ||||
| 		switch (boxnum) { | ||||
| 		case 0: | ||||
| 			box_reg = REG_HMEBOX_0; | ||||
| 			box_extreg = REG_HMEBOX_EXT_0; | ||||
| 			break; | ||||
| 		case 1: | ||||
| 			box_reg = REG_HMEBOX_1; | ||||
| 			box_extreg = REG_HMEBOX_EXT_1; | ||||
| 			break; | ||||
| 		case 2: | ||||
| 			box_reg = REG_HMEBOX_2; | ||||
| 			box_extreg = REG_HMEBOX_EXT_2; | ||||
| 			break; | ||||
| 		case 3: | ||||
| 			box_reg = REG_HMEBOX_3; | ||||
| 			box_extreg = REG_HMEBOX_EXT_3; | ||||
| 			break; | ||||
| 		default: | ||||
| 			RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 				 "switch case not process\n"); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		isfw_read = _rtl8723e_check_fw_read_last_h2c(hw, boxnum); | ||||
| 		while (!isfw_read) { | ||||
| 
 | ||||
| 			wait_h2c_limmit--; | ||||
| 			if (wait_h2c_limmit == 0) { | ||||
| 				RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 					 "Wating too long for FW read clear HMEBox(%d)!\n", | ||||
| 					 boxnum); | ||||
| 				break; | ||||
| 			} | ||||
| 
 | ||||
| 			udelay(10); | ||||
| 
 | ||||
| 			isfw_read = _rtl8723e_check_fw_read_last_h2c(hw, | ||||
| 								boxnum); | ||||
| 			u1b_tmp = rtl_read_byte(rtlpriv, 0x1BF); | ||||
| 			RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 				 "Waiting for FW read clear HMEBox(%d)!!! 0x1BF = %2x\n", | ||||
| 				 boxnum, u1b_tmp); | ||||
| 		} | ||||
| 
 | ||||
| 		if (!isfw_read) { | ||||
| 			RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 				 "Write H2C register BOX[%d] fail!!!!! Fw do not read.\n", | ||||
| 				 boxnum); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		memset(boxcontent, 0, sizeof(boxcontent)); | ||||
| 		memset(boxextcontent, 0, sizeof(boxextcontent)); | ||||
| 		boxcontent[0] = element_id; | ||||
| 		RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 			 "Write element_id box_reg(%4x) = %2x\n", | ||||
| 			  box_reg, element_id); | ||||
| 
 | ||||
| 		switch (cmd_len) { | ||||
| 		case 1: | ||||
| 			boxcontent[0] &= ~(BIT(7)); | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       cmdbuffer + buf_index, 1); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_reg + idx, | ||||
| 					       boxcontent[idx]); | ||||
| 			} | ||||
| 			break; | ||||
| 		case 2: | ||||
| 			boxcontent[0] &= ~(BIT(7)); | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       cmdbuffer + buf_index, 2); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_reg + idx, | ||||
| 					       boxcontent[idx]); | ||||
| 			} | ||||
| 			break; | ||||
| 		case 3: | ||||
| 			boxcontent[0] &= ~(BIT(7)); | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       cmdbuffer + buf_index, 3); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_reg + idx, | ||||
| 					       boxcontent[idx]); | ||||
| 			} | ||||
| 			break; | ||||
| 		case 4: | ||||
| 			boxcontent[0] |= (BIT(7)); | ||||
| 			memcpy((u8 *)(boxextcontent), | ||||
| 			       cmdbuffer + buf_index, 2); | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       cmdbuffer + buf_index + 2, 2); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 2; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_extreg + idx, | ||||
| 					       boxextcontent[idx]); | ||||
| 			} | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_reg + idx, | ||||
| 					       boxcontent[idx]); | ||||
| 			} | ||||
| 			break; | ||||
| 		case 5: | ||||
| 			boxcontent[0] |= (BIT(7)); | ||||
| 			memcpy((u8 *)(boxextcontent), | ||||
| 			       cmdbuffer + buf_index, 2); | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       cmdbuffer + buf_index + 2, 3); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 2; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_extreg + idx, | ||||
| 					       boxextcontent[idx]); | ||||
| 			} | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_reg + idx, | ||||
| 					       boxcontent[idx]); | ||||
| 			} | ||||
| 			break; | ||||
| 		default: | ||||
| 			RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 				 "switch case not process\n"); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		bwrite_sucess = true; | ||||
| 
 | ||||
| 		rtlhal->last_hmeboxnum = boxnum + 1; | ||||
| 		if (rtlhal->last_hmeboxnum == 4) | ||||
| 			rtlhal->last_hmeboxnum = 0; | ||||
| 
 | ||||
| 		RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 			 "pHalData->last_hmeboxnum  = %d\n", | ||||
| 			  rtlhal->last_hmeboxnum); | ||||
| 	} | ||||
| 
 | ||||
| 	spin_lock_irqsave(&rtlpriv->locks.h2c_lock, flag); | ||||
| 	rtlhal->h2c_setinprogress = false; | ||||
| 	spin_unlock_irqrestore(&rtlpriv->locks.h2c_lock, flag); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, "go out\n"); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_fill_h2c_cmd(struct ieee80211_hw *hw, | ||||
| 			   u8 element_id, u32 cmd_len, u8 *cmdbuffer) | ||||
| { | ||||
| 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||||
| 	u32 tmp_cmdbuf[2]; | ||||
| 
 | ||||
| 	if (!rtlhal->fw_ready) { | ||||
| 		RT_ASSERT(false, | ||||
| 			  "return H2C cmd because of Fw download fail!!!\n"); | ||||
| 		return; | ||||
| 	} | ||||
| 	memset(tmp_cmdbuf, 0, 8); | ||||
| 	memcpy(tmp_cmdbuf, cmdbuffer, cmd_len); | ||||
| 	_rtl8723e_fill_h2c_command(hw, element_id, cmd_len, | ||||
| 				   (u8 *)&tmp_cmdbuf); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 u1_h2c_set_pwrmode[3] = { 0 }; | ||||
| 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode); | ||||
| 
 | ||||
| 	SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, mode); | ||||
| 	SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, | ||||
| 		(rtlpriv->mac80211.p2p) ? ppsc->smart_ps : 1); | ||||
| 	SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(u1_h2c_set_pwrmode, | ||||
| 					      ppsc->reg_max_lps_awakeintvl); | ||||
| 
 | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, | ||||
| 		      "rtl8723e_set_fw_rsvdpagepkt(): u1_h2c_set_pwrmode\n", | ||||
| 		      u1_h2c_set_pwrmode, 3); | ||||
| 	rtl8723e_fill_h2c_cmd(hw, H2C_SETPWRMODE, 3, u1_h2c_set_pwrmode); | ||||
| } | ||||
| 
 | ||||
| #define BEACON_PG		0 /* ->1 */ | ||||
| #define PSPOLL_PG		2 | ||||
| #define NULL_PG			3 | ||||
| #define PROBERSP_PG		4 /* ->5 */ | ||||
| 
 | ||||
| #define TOTAL_RESERVED_PKT_LEN	768 | ||||
| 
 | ||||
| static u8 reserved_page_packet[TOTAL_RESERVED_PKT_LEN] = { | ||||
| 	/* page 0 beacon */ | ||||
| 	0x80, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, | ||||
| 	0xFF, 0xFF, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, | ||||
| 	0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x50, 0x08, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, | ||||
| 	0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, | ||||
| 	0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, | ||||
| 	0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, | ||||
| 	0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, | ||||
| 	0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, | ||||
| 	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, | ||||
| 	0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 1 beacon */ | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x10, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x10, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 2  ps-poll */ | ||||
| 	0xA4, 0x10, 0x01, 0xC0, 0x00, 0x40, 0x10, 0x10, | ||||
| 	0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x18, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | ||||
| 	0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 3  null */ | ||||
| 	0x48, 0x01, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, | ||||
| 	0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, | ||||
| 	0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x72, 0x00, 0x20, 0x8C, 0x00, 0x12, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, | ||||
| 	0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 4  probe_resp */ | ||||
| 	0x50, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x10, | ||||
| 	0x00, 0x03, 0x00, 0xE0, 0x4C, 0x76, 0x00, 0x42, | ||||
| 	0x00, 0x40, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, | ||||
| 	0x9E, 0x46, 0x15, 0x32, 0x27, 0xF2, 0x2D, 0x00, | ||||
| 	0x64, 0x00, 0x00, 0x04, 0x00, 0x0C, 0x6C, 0x69, | ||||
| 	0x6E, 0x6B, 0x73, 0x79, 0x73, 0x5F, 0x77, 0x6C, | ||||
| 	0x61, 0x6E, 0x01, 0x04, 0x82, 0x84, 0x8B, 0x96, | ||||
| 	0x03, 0x01, 0x01, 0x06, 0x02, 0x00, 0x00, 0x2A, | ||||
| 	0x01, 0x00, 0x32, 0x08, 0x24, 0x30, 0x48, 0x6C, | ||||
| 	0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, 0x18, | ||||
| 	0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x3D, 0x00, 0xDD, 0x06, 0x00, 0xE0, 0x4C, 0x02, | ||||
| 	0x01, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 5  probe_resp */ | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| }; | ||||
| 
 | ||||
| void rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct sk_buff *skb = NULL; | ||||
| 	u32 totalpacketlen; | ||||
| 	bool rtstatus; | ||||
| 	u8 u1rsvdpageloc[3] = { 0 }; | ||||
| 	bool b_dlok = false; | ||||
| 	u8 *beacon; | ||||
| 	u8 *p_pspoll; | ||||
| 	u8 *nullfunc; | ||||
| 	u8 *p_probersp; | ||||
| 
 | ||||
| 	/*---------------------------------------------------------
 | ||||
| 	 *			(1) beacon | ||||
| 	 *--------------------------------------------------------- | ||||
| 	 */ | ||||
| 	beacon = &reserved_page_packet[BEACON_PG * 128]; | ||||
| 	SET_80211_HDR_ADDRESS2(beacon, mac->mac_addr); | ||||
| 	SET_80211_HDR_ADDRESS3(beacon, mac->bssid); | ||||
| 
 | ||||
| 	/*-------------------------------------------------------
 | ||||
| 	 *			(2) ps-poll | ||||
| 	 *-------------------------------------------------------- | ||||
| 	 */ | ||||
| 	p_pspoll = &reserved_page_packet[PSPOLL_PG * 128]; | ||||
| 	SET_80211_PS_POLL_AID(p_pspoll, (mac->assoc_id | 0xc000)); | ||||
| 	SET_80211_PS_POLL_BSSID(p_pspoll, mac->bssid); | ||||
| 	SET_80211_PS_POLL_TA(p_pspoll, mac->mac_addr); | ||||
| 
 | ||||
| 	SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(u1rsvdpageloc, PSPOLL_PG); | ||||
| 
 | ||||
| 	/*--------------------------------------------------------
 | ||||
| 	 *			(3) null data | ||||
| 	 *--------------------------------------------------------- | ||||
| 	 */ | ||||
| 	nullfunc = &reserved_page_packet[NULL_PG * 128]; | ||||
| 	SET_80211_HDR_ADDRESS1(nullfunc, mac->bssid); | ||||
| 	SET_80211_HDR_ADDRESS2(nullfunc, mac->mac_addr); | ||||
| 	SET_80211_HDR_ADDRESS3(nullfunc, mac->bssid); | ||||
| 
 | ||||
| 	SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(u1rsvdpageloc, NULL_PG); | ||||
| 
 | ||||
| 	/*---------------------------------------------------------
 | ||||
| 	 *			(4) probe response | ||||
| 	 *---------------------------------------------------------- | ||||
| 	 */ | ||||
| 	p_probersp = &reserved_page_packet[PROBERSP_PG * 128]; | ||||
| 	SET_80211_HDR_ADDRESS1(p_probersp, mac->bssid); | ||||
| 	SET_80211_HDR_ADDRESS2(p_probersp, mac->mac_addr); | ||||
| 	SET_80211_HDR_ADDRESS3(p_probersp, mac->bssid); | ||||
| 
 | ||||
| 	SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(u1rsvdpageloc, PROBERSP_PG); | ||||
| 
 | ||||
| 	totalpacketlen = TOTAL_RESERVED_PKT_LEN; | ||||
| 
 | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 		      "rtl8723e_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", | ||||
| 		      &reserved_page_packet[0], totalpacketlen); | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, | ||||
| 		      "rtl8723e_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", | ||||
| 		      u1rsvdpageloc, 3); | ||||
| 
 | ||||
| 	skb = dev_alloc_skb(totalpacketlen); | ||||
| 	memcpy((u8 *)skb_put(skb, totalpacketlen), | ||||
| 	       &reserved_page_packet, totalpacketlen); | ||||
| 
 | ||||
| 	rtstatus = rtl_cmd_send_packet(hw, skb); | ||||
| 
 | ||||
| 	if (rtstatus) | ||||
| 		b_dlok = true; | ||||
| 
 | ||||
| 	if (b_dlok) { | ||||
| 		RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, | ||||
| 			 "Set RSVD page location to Fw.\n"); | ||||
| 		RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, | ||||
| 			      "H2C_RSVDPAGE:\n", | ||||
| 			      u1rsvdpageloc, 3); | ||||
| 		rtl8723e_fill_h2c_cmd(hw, H2C_RSVDPAGE, | ||||
| 				      sizeof(u1rsvdpageloc), u1rsvdpageloc); | ||||
| 	} else | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, | ||||
| 			 "Set RSVD page location to Fw FAIL!!!!!!.\n"); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus) | ||||
| { | ||||
| 	u8 u1_joinbssrpt_parm[1] = { 0 }; | ||||
| 
 | ||||
| 	SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(u1_joinbssrpt_parm, mstatus); | ||||
| 
 | ||||
| 	rtl8723e_fill_h2c_cmd(hw, H2C_JOINBSSRPT, 1, u1_joinbssrpt_parm); | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_set_p2p_ctw_period_cmd(struct ieee80211_hw *hw, | ||||
| 					    u8 ctwindow) | ||||
| { | ||||
| 	u8 u1_ctwindow_period[1] = { ctwindow}; | ||||
| 
 | ||||
| 	rtl8723e_fill_h2c_cmd(hw, H2C_P2P_PS_CTW_CMD, 1, u1_ctwindow_period); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_ps_ctl *rtlps = rtl_psc(rtl_priv(hw)); | ||||
| 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||||
| 	struct rtl_p2p_ps_info *p2pinfo = &(rtlps->p2p_ps_info); | ||||
| 	struct p2p_ps_offload_t *p2p_ps_offload = &rtlhal->p2p_ps_offload; | ||||
| 	u8	i; | ||||
| 	u16	ctwindow; | ||||
| 	u32	start_time, tsf_low; | ||||
| 
 | ||||
| 	switch (p2p_ps_state) { | ||||
| 	case P2P_PS_DISABLE: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_DISABLE\n"); | ||||
| 		memset(p2p_ps_offload, 0, sizeof(*p2p_ps_offload)); | ||||
| 		break; | ||||
| 	case P2P_PS_ENABLE: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_ENABLE\n"); | ||||
| 		/* update CTWindow value. */ | ||||
| 		if (p2pinfo->ctwindow > 0) { | ||||
| 			p2p_ps_offload->ctwindow_en = 1; | ||||
| 			ctwindow = p2pinfo->ctwindow; | ||||
| 			rtl8723e_set_p2p_ctw_period_cmd(hw, ctwindow); | ||||
| 		} | ||||
| 
 | ||||
| 		/* hw only support 2 set of NoA */ | ||||
| 		for (i = 0 ; i < p2pinfo->noa_num ; i++) { | ||||
| 			/* To control the register setting for which NOA*/ | ||||
| 			rtl_write_byte(rtlpriv, 0x5cf, (i << 4)); | ||||
| 			if (i == 0) | ||||
| 				p2p_ps_offload->noa0_en = 1; | ||||
| 			else | ||||
| 				p2p_ps_offload->noa1_en = 1; | ||||
| 
 | ||||
| 			/* config P2P NoA Descriptor Register */ | ||||
| 			rtl_write_dword(rtlpriv, 0x5E0, | ||||
| 					p2pinfo->noa_duration[i]); | ||||
| 			rtl_write_dword(rtlpriv, 0x5E4, | ||||
| 					p2pinfo->noa_interval[i]); | ||||
| 
 | ||||
| 			/*Get Current TSF value */ | ||||
| 			tsf_low = rtl_read_dword(rtlpriv, REG_TSFTR); | ||||
| 
 | ||||
| 			start_time = p2pinfo->noa_start_time[i]; | ||||
| 			if (p2pinfo->noa_count_type[i] != 1) { | ||||
| 				while (start_time <= | ||||
| 					(tsf_low+(50*1024))) { | ||||
| 					start_time += | ||||
| 						p2pinfo->noa_interval[i]; | ||||
| 					if (p2pinfo->noa_count_type[i] != 255) | ||||
| 						p2pinfo->noa_count_type[i]--; | ||||
| 				} | ||||
| 			} | ||||
| 			rtl_write_dword(rtlpriv, 0x5E8, start_time); | ||||
| 			rtl_write_dword(rtlpriv, 0x5EC, | ||||
| 				p2pinfo->noa_count_type[i]); | ||||
| 
 | ||||
| 		} | ||||
| 
 | ||||
| 		if ((p2pinfo->opp_ps == 1) || (p2pinfo->noa_num > 0)) { | ||||
| 			/* rst p2p circuit */ | ||||
| 			rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, BIT(4)); | ||||
| 
 | ||||
| 			p2p_ps_offload->offload_en = 1; | ||||
| 
 | ||||
| 			if (P2P_ROLE_GO == rtlpriv->mac80211.p2p) { | ||||
| 				p2p_ps_offload->role = 1; | ||||
| 				p2p_ps_offload->allstasleep = 0; | ||||
| 			} else { | ||||
| 				p2p_ps_offload->role = 0; | ||||
| 			} | ||||
| 
 | ||||
| 			p2p_ps_offload->discovery = 0; | ||||
| 		} | ||||
| 		break; | ||||
| 	case P2P_PS_SCAN: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN\n"); | ||||
| 		p2p_ps_offload->discovery = 1; | ||||
| 		break; | ||||
| 	case P2P_PS_SCAN_DONE: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD, "P2P_PS_SCAN_DONE\n"); | ||||
| 		p2p_ps_offload->discovery = 0; | ||||
| 		p2pinfo->p2p_ps_state = P2P_PS_ENABLE; | ||||
| 		break; | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| 
 | ||||
| 	rtl8723e_fill_h2c_cmd(hw, H2C_P2P_PS_OFFLOAD, 1, (u8 *)p2p_ps_offload); | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										66
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/fw.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/fw.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,66 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with | ||||
|  * this program; if not, write to the Free Software Foundation, Inc., | ||||
|  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL92C__FW__H__ | ||||
| #define __RTL92C__FW__H__ | ||||
| 
 | ||||
| #define FW_8192C_SIZE					0x3000 | ||||
| #define FW_8192C_START_ADDRESS			0x1000 | ||||
| #define FW_8192C_END_ADDRESS			0x3FFF | ||||
| #define FW_8192C_PAGE_SIZE				4096 | ||||
| #define FW_8192C_POLLING_DELAY			5 | ||||
| 
 | ||||
| #define IS_FW_HEADER_EXIST(_pfwhdr)	\ | ||||
| 	((_pfwhdr->signature&0xFFFF) == 0x2300 ||\ | ||||
| 	(_pfwhdr->signature&0xFFFF) == 0x2301 ||\ | ||||
| 	(_pfwhdr->signature&0xFFFF) == 0x2302) | ||||
| 
 | ||||
| #define pagenum_128(_len)	(u32)(((_len)>>7) + ((_len)&0x7F ? 1 : 0)) | ||||
| 
 | ||||
| #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val)			\ | ||||
| 	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) | ||||
| #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val) | ||||
| #define SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__ph2ccmd, __val)	\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val) | ||||
| #define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) | ||||
| #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) | ||||
| #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val) | ||||
| #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val) | ||||
| 
 | ||||
| void rtl8723e_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, | ||||
| 			   u32 cmd_len, u8 *p_cmdbuffer); | ||||
| void rtl8723e_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); | ||||
| void rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); | ||||
| void rtl8723e_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); | ||||
| void rtl8723e_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); | ||||
| #endif | ||||
							
								
								
									
										537
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										537
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,537 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "hal_bt_coexist.h" | ||||
| #include "../pci.h" | ||||
| #include "dm.h" | ||||
| #include "fw.h" | ||||
| #include "phy.h" | ||||
| #include "reg.h" | ||||
| #include "hal_btc.h" | ||||
| 
 | ||||
| static bool bt_operation_on; | ||||
| 
 | ||||
| void rtl8723e_dm_bt_reject_ap_aggregated_packet(struct ieee80211_hw *hw, | ||||
| 						bool b_reject) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void _rtl8723_dm_bt_check_wifi_state(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||||
| 
 | ||||
| 	if (rtlpriv->link_info.busytraffic) { | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_IDLE; | ||||
| 
 | ||||
| 		if (rtlpriv->link_info.tx_busy_traffic) | ||||
| 			rtlpriv->btcoexist.cstate |= | ||||
| 				BT_COEX_STATE_WIFI_UPLINK; | ||||
| 		else | ||||
| 			rtlpriv->btcoexist.cstate &= | ||||
| 				~BT_COEX_STATE_WIFI_UPLINK; | ||||
| 
 | ||||
| 		if (rtlpriv->link_info.rx_busy_traffic) | ||||
| 			rtlpriv->btcoexist.cstate |= | ||||
| 				BT_COEX_STATE_WIFI_DOWNLINK; | ||||
| 		else | ||||
| 			rtlpriv->btcoexist.cstate &= | ||||
| 				~BT_COEX_STATE_WIFI_DOWNLINK; | ||||
| 	} else { | ||||
| 		rtlpriv->btcoexist.cstate |= BT_COEX_STATE_WIFI_IDLE; | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_UPLINK; | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_DOWNLINK; | ||||
| 	} | ||||
| 
 | ||||
| 	if (rtlpriv->mac80211.mode == WIRELESS_MODE_G || | ||||
| 	    rtlpriv->mac80211.mode == WIRELESS_MODE_B) { | ||||
| 		rtlpriv->btcoexist.cstate |= | ||||
| 			BT_COEX_STATE_WIFI_LEGACY; | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_HT20; | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_HT40; | ||||
| 	} else { | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_LEGACY; | ||||
| 		if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { | ||||
| 			rtlpriv->btcoexist.cstate |= | ||||
| 				BT_COEX_STATE_WIFI_HT40; | ||||
| 			rtlpriv->btcoexist.cstate &= | ||||
| 				~BT_COEX_STATE_WIFI_HT20; | ||||
| 		} else { | ||||
| 			rtlpriv->btcoexist.cstate |= | ||||
| 				BT_COEX_STATE_WIFI_HT20; | ||||
| 			rtlpriv->btcoexist.cstate &= | ||||
| 				~BT_COEX_STATE_WIFI_HT40; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if (bt_operation_on) | ||||
| 		rtlpriv->btcoexist.cstate |= BT_COEX_STATE_BT30; | ||||
| 	else | ||||
| 		rtlpriv->btcoexist.cstate &= ~BT_COEX_STATE_BT30; | ||||
| } | ||||
| 
 | ||||
| u8 rtl8723e_dm_bt_check_coex_rssi_state1(struct ieee80211_hw *hw, | ||||
| 					 u8 level_num, u8 rssi_thresh, | ||||
| 					 u8 rssi_thresh1) | ||||
| 
 | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	long undecoratedsmoothed_pwdb; | ||||
| 	u8 bt_rssi_state = 0; | ||||
| 
 | ||||
| 	undecoratedsmoothed_pwdb = rtl8723e_dm_bt_get_rx_ss(hw); | ||||
| 
 | ||||
| 	if (level_num == 2) { | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||||
| 
 | ||||
| 		if ((rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_LOW) || | ||||
| 		    (rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_STAY_LOW)) { | ||||
| 			if (undecoratedsmoothed_pwdb >= | ||||
| 			    (rssi_thresh + BT_FW_COEX_THRESH_TOL)) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate |= | ||||
| 					BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state switch to High\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state stay at Low\n"); | ||||
| 			} | ||||
| 		} else { | ||||
| 			if (undecoratedsmoothed_pwdb < rssi_thresh) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_LOW; | ||||
| 				rtlpriv->btcoexist.cstate |= | ||||
| 					BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state switch to Low\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state stay at High\n"); | ||||
| 			} | ||||
| 		} | ||||
| 	} else if (level_num == 3) { | ||||
| 		if (rssi_thresh > rssi_thresh1) { | ||||
| 			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 				 "[DM][BT], RSSI_1 thresh error!!\n"); | ||||
| 			return rtlpriv->btcoexist.bt_pre_rssi_state; | ||||
| 		} | ||||
| 
 | ||||
| 		if ((rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_LOW) || | ||||
| 		    (rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_STAY_LOW)) { | ||||
| 			if (undecoratedsmoothed_pwdb >= | ||||
| 			    (rssi_thresh+BT_FW_COEX_THRESH_TOL)) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate |= | ||||
| 					BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state switch to Medium\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state stay at Low\n"); | ||||
| 			} | ||||
| 		} else if ((rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 			    BT_RSSI_STATE_MEDIUM) || | ||||
| 			   (rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 			    BT_RSSI_STATE_STAY_MEDIUM)) { | ||||
| 			if (undecoratedsmoothed_pwdb >= | ||||
| 			    (rssi_thresh1 + BT_FW_COEX_THRESH_TOL)) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate |= | ||||
| 					BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state switch to High\n"); | ||||
| 			} else if (undecoratedsmoothed_pwdb < rssi_thresh) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_LOW; | ||||
| 				rtlpriv->btcoexist.cstate |= | ||||
| 					BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state switch to Low\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_MEDIUM; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state stay at Medium\n"); | ||||
| 			} | ||||
| 		} else { | ||||
| 			if (undecoratedsmoothed_pwdb < rssi_thresh1) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate |= | ||||
| 					BT_COEX_STATE_WIFI_RSSI_1_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate &= | ||||
| 					~BT_COEX_STATE_WIFI_RSSI_1_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state switch to Medium\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI_1 state stay at High\n"); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	rtlpriv->btcoexist.bt_pre_rssi_state1 = bt_rssi_state; | ||||
| 
 | ||||
| 	return bt_rssi_state; | ||||
| } | ||||
| 
 | ||||
| u8 rtl8723e_dm_bt_check_coex_rssi_state(struct ieee80211_hw *hw, | ||||
| 					u8 level_num, | ||||
| 					u8 rssi_thresh, | ||||
| 					u8 rssi_thresh1) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	long undecoratedsmoothed_pwdb = 0; | ||||
| 	u8 bt_rssi_state = 0; | ||||
| 
 | ||||
| 	undecoratedsmoothed_pwdb = rtl8723e_dm_bt_get_rx_ss(hw); | ||||
| 
 | ||||
| 	if (level_num == 2) { | ||||
| 		rtlpriv->btcoexist.cstate &= | ||||
| 			~BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||||
| 
 | ||||
| 		if ((rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_LOW) || | ||||
| 		    (rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_STAY_LOW)) { | ||||
| 			if (undecoratedsmoothed_pwdb >= | ||||
| 			    (rssi_thresh + BT_FW_COEX_THRESH_TOL)) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					|= BT_COEX_STATE_WIFI_RSSI_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state switch to High\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state stay at Low\n"); | ||||
| 			} | ||||
| 		} else { | ||||
| 			if (undecoratedsmoothed_pwdb < rssi_thresh) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_LOW; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					|= BT_COEX_STATE_WIFI_RSSI_LOW; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state switch to Low\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state stay at High\n"); | ||||
| 			} | ||||
| 		} | ||||
| 	} else if (level_num == 3) { | ||||
| 		if (rssi_thresh > rssi_thresh1) { | ||||
| 			RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 				 "[DM][BT], RSSI thresh error!!\n"); | ||||
| 			return rtlpriv->btcoexist.bt_pre_rssi_state; | ||||
| 		} | ||||
| 		if ((rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_LOW) || | ||||
| 		    (rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 		     BT_RSSI_STATE_STAY_LOW)) { | ||||
| 			if (undecoratedsmoothed_pwdb >= | ||||
| 			    (rssi_thresh + BT_FW_COEX_THRESH_TOL)) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					|= BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state switch to Medium\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state stay at Low\n"); | ||||
| 			} | ||||
| 		} else if ((rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 				BT_RSSI_STATE_MEDIUM) || | ||||
| 			(rtlpriv->btcoexist.bt_pre_rssi_state == | ||||
| 				BT_RSSI_STATE_STAY_MEDIUM)) { | ||||
| 			if (undecoratedsmoothed_pwdb >= | ||||
| 			    (rssi_thresh1 + BT_FW_COEX_THRESH_TOL)) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					|= BT_COEX_STATE_WIFI_RSSI_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state switch to High\n"); | ||||
| 			} else if (undecoratedsmoothed_pwdb < rssi_thresh) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_LOW; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					|= BT_COEX_STATE_WIFI_RSSI_LOW; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state switch to Low\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_MEDIUM; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state stay at Medium\n"); | ||||
| 			} | ||||
| 		} else { | ||||
| 			if (undecoratedsmoothed_pwdb < rssi_thresh1) { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					|= BT_COEX_STATE_WIFI_RSSI_MEDIUM; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_HIGH; | ||||
| 				rtlpriv->btcoexist.cstate | ||||
| 					&= ~BT_COEX_STATE_WIFI_RSSI_LOW; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state switch to Medium\n"); | ||||
| 			} else { | ||||
| 				bt_rssi_state = BT_RSSI_STATE_STAY_HIGH; | ||||
| 				RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 					 "[DM][BT], RSSI state stay at High\n"); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	rtlpriv->btcoexist.bt_pre_rssi_state = bt_rssi_state; | ||||
| 	return bt_rssi_state; | ||||
| } | ||||
| 
 | ||||
| long rtl8723e_dm_bt_get_rx_ss(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	long undecoratedsmoothed_pwdb = 0; | ||||
| 
 | ||||
| 	if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) { | ||||
| 		undecoratedsmoothed_pwdb = | ||||
| 			GET_UNDECORATED_AVERAGE_RSSI(rtlpriv); | ||||
| 	} else { | ||||
| 		undecoratedsmoothed_pwdb | ||||
| 			= rtlpriv->dm.entry_min_undec_sm_pwdb; | ||||
| 	} | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_get_rx_ss() = %ld\n", | ||||
| 		 undecoratedsmoothed_pwdb); | ||||
| 
 | ||||
| 	return undecoratedsmoothed_pwdb; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_bt_balance(struct ieee80211_hw *hw, | ||||
| 			    bool balance_on, u8 ms0, u8 ms1) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 h2c_parameter[3] = {0}; | ||||
| 
 | ||||
| 	if (balance_on) { | ||||
| 		h2c_parameter[2] = 1; | ||||
| 		h2c_parameter[1] = ms1; | ||||
| 		h2c_parameter[0] = ms0; | ||||
| 		rtlpriv->btcoexist.fw_coexist_all_off = false; | ||||
| 	} else { | ||||
| 		h2c_parameter[2] = 0; | ||||
| 		h2c_parameter[1] = 0; | ||||
| 		h2c_parameter[0] = 0; | ||||
| 	} | ||||
| 	rtlpriv->btcoexist.balance_on = balance_on; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "[DM][BT], Balance=[%s:%dms:%dms], write 0xc=0x%x\n", | ||||
| 		 balance_on ? "ON" : "OFF", ms0, ms1, h2c_parameter[0]<<16 | | ||||
| 		 h2c_parameter[1]<<8 | h2c_parameter[2]); | ||||
| 
 | ||||
| 	rtl8723e_fill_h2c_cmd(hw, 0xc, 3, h2c_parameter); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void rtl8723e_dm_bt_agc_table(struct ieee80211_hw *hw, u8 type) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	if (type == BT_AGCTABLE_OFF) { | ||||
| 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 			 "[BT]AGCTable Off!\n"); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x641c0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x631d0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x621e0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x611f0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x60200001); | ||||
| 
 | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0x32000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0x71000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0xb0000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0xfc000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_G1, 0xfffff, 0x30355); | ||||
| 	} else if (type == BT_AGCTABLE_ON) { | ||||
| 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 			 "[BT]AGCTable On!\n"); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x4e1c0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x4d1d0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x4c1e0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x4b1f0001); | ||||
| 		rtl_write_dword(rtlpriv, 0xc78, 0x4a200001); | ||||
| 
 | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0xdc000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0x90000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0x51000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_AGC_HP, 0xfffff, 0x12000); | ||||
| 		rtl8723e_phy_set_rf_reg(hw, RF90_PATH_A, | ||||
| 					RF_RX_G1, 0xfffff, 0x00355); | ||||
| 
 | ||||
| 		rtlpriv->btcoexist.sw_coexist_all_off = false; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_bt_bb_back_off_level(struct ieee80211_hw *hw, u8 type) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	if (type == BT_BB_BACKOFF_OFF) { | ||||
| 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 			 "[BT]BBBackOffLevel Off!\n"); | ||||
| 		rtl_write_dword(rtlpriv, 0xc04, 0x3a05611); | ||||
| 	} else if (type == BT_BB_BACKOFF_ON) { | ||||
| 		RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 			 "[BT]BBBackOffLevel On!\n"); | ||||
| 		rtl_write_dword(rtlpriv, 0xc04, 0x3a07611); | ||||
| 		rtlpriv->btcoexist.sw_coexist_all_off = false; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_bt_fw_coex_all_off(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_fw_coex_all_off()\n"); | ||||
| 
 | ||||
| 	if (rtlpriv->btcoexist.fw_coexist_all_off) | ||||
| 		return; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_fw_coex_all_off(), real Do\n"); | ||||
| 	rtl8723e_dm_bt_fw_coex_all_off_8723a(hw); | ||||
| 	rtlpriv->btcoexist.fw_coexist_all_off = true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_bt_sw_coex_all_off(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_sw_coex_all_off()\n"); | ||||
| 
 | ||||
| 	if (rtlpriv->btcoexist.sw_coexist_all_off) | ||||
| 		return; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_sw_coex_all_off(), real Do\n"); | ||||
| 	rtl8723e_dm_bt_sw_coex_all_off_8723a(hw); | ||||
| 	rtlpriv->btcoexist.sw_coexist_all_off = true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_dm_bt_hw_coex_all_off(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_hw_coex_all_off()\n"); | ||||
| 
 | ||||
| 	if (rtlpriv->btcoexist.hw_coexist_all_off) | ||||
| 		return; | ||||
| 	RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE, | ||||
| 		 "rtl8723e_dm_bt_hw_coex_all_off(), real Do\n"); | ||||
| 
 | ||||
| 	rtl8723e_dm_bt_hw_coex_all_off_8723a(hw); | ||||
| 
 | ||||
| 	rtlpriv->btcoexist.hw_coexist_all_off = true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_btdm_coex_all_off(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	rtl8723e_dm_bt_fw_coex_all_off(hw); | ||||
| 	rtl8723e_dm_bt_sw_coex_all_off(hw); | ||||
| 	rtl8723e_dm_bt_hw_coex_all_off(hw); | ||||
| } | ||||
| 
 | ||||
| bool rtl8723e_dm_bt_is_coexist_state_changed(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	if ((rtlpriv->btcoexist.previous_state == rtlpriv->btcoexist.cstate) && | ||||
| 	    (rtlpriv->btcoexist.previous_state_h == | ||||
| 	     rtlpriv->btcoexist.cstate_h)) | ||||
| 		return false; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| bool rtl8723e_dm_bt_is_wifi_up_link(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	if (rtlpriv->link_info.tx_busy_traffic) | ||||
| 		return true; | ||||
| 	return false; | ||||
| } | ||||
							
								
								
									
										158
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										158
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_bt_coexist.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,158 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with | ||||
|  * this program; if not, write to the Free Software Foundation, Inc., | ||||
|  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_HAL_BT_COEXIST_H__ | ||||
| #define __RTL8723E_HAL_BT_COEXIST_H__ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| 
 | ||||
| /* The reg define is for 8723 */ | ||||
| #define	REG_HIGH_PRIORITY_TXRX			0x770 | ||||
| #define	REG_LOW_PRIORITY_TXRX			0x774 | ||||
| 
 | ||||
| #define BT_FW_COEX_THRESH_TOL			6 | ||||
| #define BT_FW_COEX_THRESH_20			20 | ||||
| #define BT_FW_COEX_THRESH_23			23 | ||||
| #define BT_FW_COEX_THRESH_25			25 | ||||
| #define BT_FW_COEX_THRESH_30			30 | ||||
| #define BT_FW_COEX_THRESH_35			35 | ||||
| #define BT_FW_COEX_THRESH_40			40 | ||||
| #define BT_FW_COEX_THRESH_45			45 | ||||
| #define BT_FW_COEX_THRESH_47			47 | ||||
| #define BT_FW_COEX_THRESH_50			50 | ||||
| #define BT_FW_COEX_THRESH_55			55 | ||||
| 
 | ||||
| #define BT_COEX_STATE_BT30			BIT(0) | ||||
| #define BT_COEX_STATE_WIFI_HT20			BIT(1) | ||||
| #define BT_COEX_STATE_WIFI_HT40			BIT(2) | ||||
| #define BT_COEX_STATE_WIFI_LEGACY		BIT(3) | ||||
| 
 | ||||
| #define BT_COEX_STATE_WIFI_RSSI_LOW		BIT(4) | ||||
| #define BT_COEX_STATE_WIFI_RSSI_MEDIUM	BIT(5) | ||||
| #define BT_COEX_STATE_WIFI_RSSI_HIGH	BIT(6) | ||||
| #define BT_COEX_STATE_DEC_BT_POWER		BIT(7) | ||||
| 
 | ||||
| #define BT_COEX_STATE_WIFI_IDLE			BIT(8) | ||||
| #define BT_COEX_STATE_WIFI_UPLINK		BIT(9) | ||||
| #define BT_COEX_STATE_WIFI_DOWNLINK		BIT(10) | ||||
| 
 | ||||
| #define BT_COEX_STATE_BT_INQ_PAGE		BIT(11) | ||||
| #define BT_COEX_STATE_BT_IDLE			BIT(12) | ||||
| #define BT_COEX_STATE_BT_UPLINK			BIT(13) | ||||
| #define BT_COEX_STATE_BT_DOWNLINK		BIT(14) | ||||
| 
 | ||||
| #define BT_COEX_STATE_HOLD_FOR_BT_OPERATION	BIT(15) | ||||
| #define BT_COEX_STATE_BT_RSSI_LOW		BIT(19) | ||||
| 
 | ||||
| #define BT_COEX_STATE_PROFILE_HID		BIT(20) | ||||
| #define BT_COEX_STATE_PROFILE_A2DP		BIT(21) | ||||
| #define BT_COEX_STATE_PROFILE_PAN		BIT(22) | ||||
| #define BT_COEX_STATE_PROFILE_SCO		BIT(23) | ||||
| 
 | ||||
| #define BT_COEX_STATE_WIFI_RSSI_1_LOW		BIT(24) | ||||
| #define BT_COEX_STATE_WIFI_RSSI_1_MEDIUM	BIT(25) | ||||
| #define BT_COEX_STATE_WIFI_RSSI_1_HIGH		BIT(26) | ||||
| 
 | ||||
| #define BT_COEX_STATE_BTINFO_COMMON			BIT(30) | ||||
| #define BT_COEX_STATE_BTINFO_B_HID_SCOESCO	BIT(31) | ||||
| #define BT_COEX_STATE_BTINFO_B_FTP_A2DP		BIT(29) | ||||
| 
 | ||||
| #define BT_COEX_STATE_BT_CNT_LEVEL_0		BIT(0) | ||||
| #define BT_COEX_STATE_BT_CNT_LEVEL_1		BIT(1) | ||||
| #define BT_COEX_STATE_BT_CNT_LEVEL_2		BIT(2) | ||||
| #define BT_COEX_STATE_BT_CNT_LEVEL_3		BIT(3) | ||||
| 
 | ||||
| #define BT_RSSI_STATE_HIGH			0 | ||||
| #define BT_RSSI_STATE_MEDIUM			1 | ||||
| #define BT_RSSI_STATE_LOW			2 | ||||
| #define BT_RSSI_STATE_STAY_HIGH			3 | ||||
| #define BT_RSSI_STATE_STAY_MEDIUM		4 | ||||
| #define BT_RSSI_STATE_STAY_LOW			5 | ||||
| 
 | ||||
| #define	BT_AGCTABLE_OFF				0 | ||||
| #define	BT_AGCTABLE_ON				1 | ||||
| #define	BT_BB_BACKOFF_OFF			0 | ||||
| #define	BT_BB_BACKOFF_ON			1 | ||||
| #define	BT_FW_NAV_OFF				0 | ||||
| #define	BT_FW_NAV_ON				1 | ||||
| 
 | ||||
| #define	BT_COEX_MECH_NONE			0 | ||||
| #define	BT_COEX_MECH_SCO			1 | ||||
| #define	BT_COEX_MECH_HID			2 | ||||
| #define	BT_COEX_MECH_A2DP			3 | ||||
| #define	BT_COEX_MECH_PAN			4 | ||||
| #define	BT_COEX_MECH_HID_A2DP			5 | ||||
| #define	BT_COEX_MECH_HID_PAN			6 | ||||
| #define	BT_COEX_MECH_PAN_A2DP			7 | ||||
| #define	BT_COEX_MECH_HID_SCO_ESCO		8 | ||||
| #define	BT_COEX_MECH_FTP_A2DP			9 | ||||
| #define	BT_COEX_MECH_COMMON			10 | ||||
| #define	BT_COEX_MECH_MAX			11 | ||||
| 
 | ||||
| #define	BT_DBG_PROFILE_NONE			0 | ||||
| #define	BT_DBG_PROFILE_SCO			1 | ||||
| #define	BT_DBG_PROFILE_HID			2 | ||||
| #define	BT_DBG_PROFILE_A2DP			3 | ||||
| #define	BT_DBG_PROFILE_PAN			4 | ||||
| #define	BT_DBG_PROFILE_HID_A2DP			5 | ||||
| #define	BT_DBG_PROFILE_HID_PAN			6 | ||||
| #define	BT_DBG_PROFILE_PAN_A2DP			7 | ||||
| #define	BT_DBG_PROFILE_MAX			9 | ||||
| 
 | ||||
| #define	BTINFO_B_FTP				BIT(7) | ||||
| #define	BTINFO_B_A2DP				BIT(6) | ||||
| #define	BTINFO_B_HID				BIT(5) | ||||
| #define	BTINFO_B_SCO_BUSY			BIT(4) | ||||
| #define	BTINFO_B_ACL_BUSY			BIT(3) | ||||
| #define	BTINFO_B_INQ_PAGE			BIT(2) | ||||
| #define	BTINFO_B_SCO_ESCO			BIT(1) | ||||
| #define	BTINFO_B_CONNECTION			BIT(0) | ||||
| 
 | ||||
| void rtl8723e_btdm_coex_all_off(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_fw_coex_all_off(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| void rtl8723e_dm_bt_sw_coex_all_off(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_hw_coex_all_off(struct ieee80211_hw *hw); | ||||
| long rtl8723e_dm_bt_get_rx_ss(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_balance(struct ieee80211_hw *hw, | ||||
| 			    bool balance_on, u8 ms0, u8 ms1); | ||||
| void rtl8723e_dm_bt_agc_table(struct ieee80211_hw *hw, u8 tyep); | ||||
| void rtl8723e_dm_bt_bb_back_off_level(struct ieee80211_hw *hw, u8 type); | ||||
| u8 rtl8723e_dm_bt_check_coex_rssi_state(struct ieee80211_hw *hw, | ||||
| 					u8 level_num, u8 rssi_thresh, | ||||
| 					u8 rssi_thresh1); | ||||
| u8 rtl8723e_dm_bt_check_coex_rssi_state1(struct ieee80211_hw *hw, | ||||
| 					 u8 level_num, u8 rssi_thresh, | ||||
| 					 u8 rssi_thresh1); | ||||
| void _rtl8723_dm_bt_check_wifi_state(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_reject_ap_aggregated_packet(struct ieee80211_hw *hw, | ||||
| 						bool b_reject); | ||||
| bool rtl8723e_dm_bt_is_coexist_state_changed(struct ieee80211_hw *hw); | ||||
| bool rtl8723e_dm_bt_is_wifi_up_link(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										1780
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_btc.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1780
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_btc.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										159
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_btc.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hal_btc.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,159 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_HAL_BTC_H__ | ||||
| #define __RTL8723E_HAL_BTC_H__ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "btc.h" | ||||
| #include "hal_bt_coexist.h" | ||||
| 
 | ||||
| #define	BT_TXRX_CNT_THRES_1			1200 | ||||
| #define	BT_TXRX_CNT_THRES_2			1400 | ||||
| #define	BT_TXRX_CNT_THRES_3			3000 | ||||
| /* < 1200 */ | ||||
| #define	BT_TXRX_CNT_LEVEL_0			0 | ||||
| /* >= 1200 && < 1400 */ | ||||
| #define	BT_TXRX_CNT_LEVEL_1			1 | ||||
| /* >= 1400 */ | ||||
| #define	BT_TXRX_CNT_LEVEL_2			2 | ||||
| #define	BT_TXRX_CNT_LEVEL_3			3 | ||||
| 
 | ||||
| #define	BT_COEX_DISABLE			0 | ||||
| #define	BT_Q_PKT_OFF			0 | ||||
| #define	BT_Q_PKT_ON			1 | ||||
| 
 | ||||
| #define	BT_TX_PWR_OFF			0 | ||||
| #define	BT_TX_PWR_ON			1 | ||||
| 
 | ||||
| /* TDMA mode definition */ | ||||
| #define	TDMA_2ANT			0 | ||||
| #define	TDMA_1ANT			1 | ||||
| #define	TDMA_NAV_OFF			0 | ||||
| #define	TDMA_NAV_ON			1 | ||||
| #define	TDMA_DAC_SWING_OFF		0 | ||||
| #define	TDMA_DAC_SWING_ON		1 | ||||
| 
 | ||||
| /* PTA mode related definition */ | ||||
| #define	BT_PTA_MODE_OFF		0 | ||||
| #define	BT_PTA_MODE_ON		1 | ||||
| 
 | ||||
| /* Penalty Tx Rate Adaptive */ | ||||
| #define	BT_TX_RATE_ADAPTIVE_NORMAL	0 | ||||
| #define	BT_TX_RATE_ADAPTIVE_LOW_PENALTY	1 | ||||
| 
 | ||||
| /* RF Corner */ | ||||
| #define	BT_RF_RX_LPF_CORNER_RESUME	0 | ||||
| #define	BT_RF_RX_LPF_CORNER_SHRINK	1 | ||||
| 
 | ||||
| #define C2H_EVT_HOST_CLOSE		0x00 | ||||
| #define C2H_EVT_FW_CLOSE		0xFF | ||||
| 
 | ||||
| enum bt_traffic_mode { | ||||
| 	BT_MOTOR_EXT_BE = 0x00, | ||||
| 	BT_MOTOR_EXT_GUL = 0x01, | ||||
| 	BT_MOTOR_EXT_GUB = 0x02, | ||||
| 	BT_MOTOR_EXT_GULB = 0x03 | ||||
| }; | ||||
| 
 | ||||
| enum bt_traffic_mode_profile { | ||||
| 	BT_PROFILE_NONE, | ||||
| 	BT_PROFILE_A2DP, | ||||
| 	BT_PROFILE_PAN, | ||||
| 	BT_PROFILE_HID, | ||||
| 	BT_PROFILE_SCO | ||||
| }; | ||||
| 
 | ||||
| /*
 | ||||
| enum hci_ext_bt_operation { | ||||
| 	HCI_BT_OP_NONE = 0x0, | ||||
| 	HCI_BT_OP_INQUIRE_START	= 0x1, | ||||
| 	HCI_BT_OP_INQUIRE_FINISH = 0x2, | ||||
| 	HCI_BT_OP_PAGING_START = 0x3, | ||||
| 	HCI_BT_OP_PAGING_SUCCESS = 0x4, | ||||
| 	HCI_BT_OP_PAGING_UNSUCCESS = 0x5, | ||||
| 	HCI_BT_OP_PAIRING_START = 0x6, | ||||
| 	HCI_BT_OP_PAIRING_FINISH = 0x7, | ||||
| 	HCI_BT_OP_BT_DEV_ENABLE = 0x8, | ||||
| 	HCI_BT_OP_BT_DEV_DISABLE = 0x9, | ||||
| 	HCI_BT_OP_MAX, | ||||
| }; | ||||
| */ | ||||
| 
 | ||||
| enum bt_spec { | ||||
| 	BT_SPEC_1_0_b = 0x00, | ||||
| 	BT_SPEC_1_1 = 0x01, | ||||
| 	BT_SPEC_1_2 = 0x02, | ||||
| 	BT_SPEC_2_0_EDR = 0x03, | ||||
| 	BT_SPEC_2_1_EDR = 0x04, | ||||
| 	BT_SPEC_3_0_HS = 0x05, | ||||
| 	BT_SPEC_4_0 = 0x06 | ||||
| }; | ||||
| 
 | ||||
| struct c2h_evt_hdr { | ||||
| 	u8 cmd_id; | ||||
| 	u8 cmd_len; | ||||
| 	u8 cmd_seq; | ||||
| }; | ||||
| 
 | ||||
| enum bt_state { | ||||
| 	BT_INFO_STATE_DISABLED = 0, | ||||
| 	BT_INFO_STATE_NO_CONNECTION = 1, | ||||
| 	BT_INFO_STATE_CONNECT_IDLE = 2, | ||||
| 	BT_INFO_STATE_INQ_OR_PAG = 3, | ||||
| 	BT_INFO_STATE_ACL_ONLY_BUSY = 4, | ||||
| 	BT_INFO_STATE_SCO_ONLY_BUSY = 5, | ||||
| 	BT_INFO_STATE_ACL_SCO_BUSY = 6, | ||||
| 	BT_INFO_STATE_HID_BUSY = 7, | ||||
| 	BT_INFO_STATE_HID_SCO_BUSY = 8, | ||||
| 	BT_INFO_STATE_MAX = 7 | ||||
| }; | ||||
| 
 | ||||
| enum rtl8723e_c2h_evt { | ||||
| 	C2H_DBG = 0, | ||||
| 	C2H_TSF = 1, | ||||
| 	C2H_AP_RPT_RSP = 2, | ||||
| 	/* The FW notify the report of the specific tx packet. */ | ||||
| 	C2H_CCX_TX_RPT = 3, | ||||
| 	C2H_BT_RSSI = 4, | ||||
| 	C2H_BT_OP_MODE = 5, | ||||
| 	C2H_HW_INFO_EXCH = 10, | ||||
| 	C2H_C2H_H2C_TEST = 11, | ||||
| 	BT_INFO = 12, | ||||
| 	MAX_C2HEVENT | ||||
| }; | ||||
| 
 | ||||
| void rtl8723e_dm_bt_fw_coex_all_off_8723a(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_sw_coex_all_off_8723a(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_hw_coex_all_off_8723a(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_coexist_8723(struct ieee80211_hw *hw); | ||||
| void rtl8723e_dm_bt_set_bt_dm(struct ieee80211_hw *hw, | ||||
| 			      struct btdm_8723 *p_btdm); | ||||
| void rtl_8723e_c2h_command_handle(struct ieee80211_hw *hw); | ||||
| void rtl_8723e_bt_wifi_media_status_notify(struct ieee80211_hw *hw, | ||||
| 					bool mstatus); | ||||
| void rtl8723e_dm_bt_turn_off_bt_coexist_before_enter_lps( | ||||
| 				struct ieee80211_hw *hw); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										2495
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hw.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2495
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hw.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										67
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hw.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/hw.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,67 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_HW_H__ | ||||
| #define __RTL8723E_HW_H__ | ||||
| 
 | ||||
| #define CHK_SVID_SMID(_val1, _val2)				\ | ||||
| 	((rtlefuse->eeprom_svid == (_val1)) &&			\ | ||||
| 	 (rtlefuse->eeprom_smid == (_val2))) | ||||
| 
 | ||||
| void rtl8723e_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); | ||||
| void rtl8723e_read_eeprom_info(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw, | ||||
| 				   u32 *p_inta, u32 *p_intb); | ||||
| int rtl8723e_hw_init(struct ieee80211_hw *hw); | ||||
| void rtl8723e_card_disable(struct ieee80211_hw *hw); | ||||
| void rtl8723e_enable_interrupt(struct ieee80211_hw *hw); | ||||
| void rtl8723e_disable_interrupt(struct ieee80211_hw *hw); | ||||
| int rtl8723e_set_network_type(struct ieee80211_hw *hw, | ||||
| 			      enum nl80211_iftype type); | ||||
| void rtl8723e_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); | ||||
| void rtl8723e_set_qos(struct ieee80211_hw *hw, int aci); | ||||
| void rtl8723e_set_beacon_related_registers(struct ieee80211_hw *hw); | ||||
| void rtl8723e_set_beacon_interval(struct ieee80211_hw *hw); | ||||
| void rtl8723e_update_interrupt_mask(struct ieee80211_hw *hw, | ||||
| 				    u32 add_msr, u32 rm_msr); | ||||
| void rtl8723e_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); | ||||
| void rtl8723e_update_hal_rate_tbl(struct ieee80211_hw *hw, | ||||
| 				  struct ieee80211_sta *sta, u8 rssi_level); | ||||
| void rtl8723e_update_channel_access_setting(struct ieee80211_hw *hw); | ||||
| bool rtl8723e_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid); | ||||
| void rtl8723e_enable_hw_security_config(struct ieee80211_hw *hw); | ||||
| void rtl8723e_set_key(struct ieee80211_hw *hw, u32 key_index, | ||||
| 		      u8 *p_macaddr, bool is_group, u8 enc_algo, | ||||
| 		      bool is_wepkey, bool clear_all); | ||||
| 
 | ||||
| void rtl8723e_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, | ||||
| 					     bool autoload_fail, u8 *hwinfo); | ||||
| void rtl8723e_bt_reg_init(struct ieee80211_hw *hw); | ||||
| void rtl8723e_bt_hw_init(struct ieee80211_hw *hw); | ||||
| void rtl8723e_suspend(struct ieee80211_hw *hw); | ||||
| void rtl8723e_resume(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										159
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/led.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/led.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,159 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License along with | ||||
|  * this program; if not, write to the Free Software Foundation, Inc., | ||||
|  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "../pci.h" | ||||
| #include "reg.h" | ||||
| #include "led.h" | ||||
| 
 | ||||
| static void _rtl8723e_init_led(struct ieee80211_hw *hw, | ||||
| 			       struct rtl_led *pled, enum rtl_led_pin ledpin) | ||||
| { | ||||
| 	pled->hw = hw; | ||||
| 	pled->ledpin = ledpin; | ||||
| 	pled->ledon = false; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled) | ||||
| { | ||||
| 	u8 ledcfg; | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, | ||||
| 		 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin); | ||||
| 
 | ||||
| 	switch (pled->ledpin) { | ||||
| 	case LED_PIN_GPIO0: | ||||
| 		break; | ||||
| 	case LED_PIN_LED0: | ||||
| 		ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); | ||||
| 		ledcfg &= ~BIT(6); | ||||
| 		rtl_write_byte(rtlpriv, | ||||
| 			       REG_LEDCFG2, (ledcfg & 0xf0) | BIT(5)); | ||||
| 		break; | ||||
| 	case LED_PIN_LED1: | ||||
| 		ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG1); | ||||
| 		rtl_write_byte(rtlpriv, REG_LEDCFG1, ledcfg & 0x10); | ||||
| 		break; | ||||
| 	default: | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 			 "switch case not process\n"); | ||||
| 		break; | ||||
| 	} | ||||
| 	pled->ledon = true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); | ||||
| 	u8 ledcfg; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, | ||||
| 		 "LedAddr:%X ledpin=%d\n", REG_LEDCFG2, pled->ledpin); | ||||
| 
 | ||||
| 	ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG2); | ||||
| 
 | ||||
| 	switch (pled->ledpin) { | ||||
| 	case LED_PIN_GPIO0: | ||||
| 		break; | ||||
| 	case LED_PIN_LED0: | ||||
| 		ledcfg &= 0xf0; | ||||
| 		if (pcipriv->ledctl.led_opendrain) { | ||||
| 			ledcfg &= 0x90; /* Set to software control. */ | ||||
| 			rtl_write_byte(rtlpriv, REG_LEDCFG2, (ledcfg|BIT(3))); | ||||
| 			ledcfg = rtl_read_byte(rtlpriv, REG_MAC_PINMUX_CFG); | ||||
| 			ledcfg &= 0xFE; | ||||
| 			rtl_write_byte(rtlpriv, REG_MAC_PINMUX_CFG, ledcfg); | ||||
| 		} else { | ||||
| 			ledcfg &= ~BIT(6); | ||||
| 			rtl_write_byte(rtlpriv, REG_LEDCFG2, | ||||
| 					(ledcfg | BIT(3) | BIT(5))); | ||||
| 		} | ||||
| 		break; | ||||
| 	case LED_PIN_LED1: | ||||
| 		ledcfg = rtl_read_byte(rtlpriv, REG_LEDCFG1); | ||||
| 		ledcfg &= 0x10; /* Set to software control. */ | ||||
| 		rtl_write_byte(rtlpriv, REG_LEDCFG1, ledcfg|BIT(3)); | ||||
| 
 | ||||
| 		break; | ||||
| 	default: | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 			 "switch case not process\n"); | ||||
| 		break; | ||||
| 	} | ||||
| 	pled->ledon = false; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_init_sw_leds(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); | ||||
| 	_rtl8723e_init_led(hw, &pcipriv->ledctl.sw_led0, LED_PIN_LED0); | ||||
| 	_rtl8723e_init_led(hw, &pcipriv->ledctl.sw_led1, LED_PIN_LED1); | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723e_sw_led_control(struct ieee80211_hw *hw, | ||||
| 				     enum led_ctl_mode ledaction) | ||||
| { | ||||
| 	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); | ||||
| 	struct rtl_led *pLed0 = &(pcipriv->ledctl.sw_led0); | ||||
| 	switch (ledaction) { | ||||
| 	case LED_CTL_POWER_ON: | ||||
| 	case LED_CTL_LINK: | ||||
| 	case LED_CTL_NO_LINK: | ||||
| 		rtl8723e_sw_led_on(hw, pLed0); | ||||
| 		break; | ||||
| 	case LED_CTL_POWER_OFF: | ||||
| 		rtl8723e_sw_led_off(hw, pLed0); | ||||
| 		break; | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_led_control(struct ieee80211_hw *hw, | ||||
| 			  enum led_ctl_mode ledaction) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | ||||
| 
 | ||||
| 	if ((ppsc->rfoff_reason > RF_CHANGE_BY_PS) && | ||||
| 	    (ledaction == LED_CTL_TX || | ||||
| 	     ledaction == LED_CTL_RX || | ||||
| 	     ledaction == LED_CTL_SITE_SURVEY || | ||||
| 	     ledaction == LED_CTL_LINK || | ||||
| 	     ledaction == LED_CTL_NO_LINK || | ||||
| 	     ledaction == LED_CTL_START_TO_LINK || | ||||
| 	     ledaction == LED_CTL_POWER_ON)) { | ||||
| 		return; | ||||
| 	} | ||||
| 	RT_TRACE(rtlpriv, COMP_LED, DBG_LOUD, "ledaction %d,\n", | ||||
| 		 ledaction); | ||||
| 	_rtl8723e_sw_led_control(hw, ledaction); | ||||
| } | ||||
							
								
								
									
										34
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/led.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/led.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL92CE_LED_H__ | ||||
| #define __RTL92CE_LED_H__ | ||||
| 
 | ||||
| void rtl8723e_init_sw_leds(struct ieee80211_hw *hw); | ||||
| void rtl8723e_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled); | ||||
| void rtl8723e_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled); | ||||
| void rtl8723e_led_control(struct ieee80211_hw *hw, enum led_ctl_mode ledaction); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										1705
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/phy.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1705
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/phy.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										202
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/phy.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										202
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/phy.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,202 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL92C_PHY_H__ | ||||
| #define __RTL92C_PHY_H__ | ||||
| 
 | ||||
| #define MAX_PRECMD_CNT				16 | ||||
| #define MAX_RFDEPENDCMD_CNT			16 | ||||
| #define MAX_POSTCMD_CNT				16 | ||||
| 
 | ||||
| #define MAX_DOZE_WAITING_TIMES_9x		64 | ||||
| 
 | ||||
| #define RT_CANNOT_IO(hw)			false | ||||
| #define HIGHPOWER_RADIOA_ARRAYLEN		22 | ||||
| 
 | ||||
| #define IQK_ADDA_REG_NUM			16 | ||||
| #define MAX_TOLERANCE				5 | ||||
| #define	IQK_DELAY_TIME				1 | ||||
| 
 | ||||
| #define	APK_BB_REG_NUM				5 | ||||
| #define	APK_AFE_REG_NUM				16 | ||||
| #define	APK_CURVE_REG_NUM			4 | ||||
| #define	PATH_NUM				2 | ||||
| 
 | ||||
| #define LOOP_LIMIT				5 | ||||
| #define MAX_STALL_TIME				50 | ||||
| #define ANTENNADIVERSITYVALUE			0x80 | ||||
| #define MAX_TXPWR_IDX_NMODE_92S			63 | ||||
| #define Reset_Cnt_Limit				3 | ||||
| 
 | ||||
| #define IQK_ADDA_REG_NUM			16 | ||||
| #define IQK_MAC_REG_NUM				4 | ||||
| 
 | ||||
| #define IQK_DELAY_TIME				1 | ||||
| 
 | ||||
| #define RF6052_MAX_PATH				2 | ||||
| 
 | ||||
| #define CT_OFFSET_MAC_ADDR			0X16 | ||||
| 
 | ||||
| #define CT_OFFSET_CCK_TX_PWR_IDX		0x5A | ||||
| #define CT_OFFSET_HT401S_TX_PWR_IDX		0x60 | ||||
| #define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF	0x66 | ||||
| #define CT_OFFSET_HT20_TX_PWR_IDX_DIFF		0x69 | ||||
| #define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF		0x6C | ||||
| 
 | ||||
| #define CT_OFFSET_HT40_MAX_PWR_OFFSET		0x6F | ||||
| #define CT_OFFSET_HT20_MAX_PWR_OFFSET		0x72 | ||||
| 
 | ||||
| #define CT_OFFSET_CHANNEL_PLAH			0x75 | ||||
| #define CT_OFFSET_THERMAL_METER			0x78 | ||||
| #define CT_OFFSET_RF_OPTION			0x79 | ||||
| #define CT_OFFSET_VERSION			0x7E | ||||
| #define CT_OFFSET_CUSTOMER_ID			0x7F | ||||
| 
 | ||||
| #define RTL92C_MAX_PATH_NUM			2 | ||||
| 
 | ||||
| enum hw90_block_e { | ||||
| 	HW90_BLOCK_MAC = 0, | ||||
| 	HW90_BLOCK_PHY0 = 1, | ||||
| 	HW90_BLOCK_PHY1 = 2, | ||||
| 	HW90_BLOCK_RF = 3, | ||||
| 	HW90_BLOCK_MAXIMUM = 4, | ||||
| }; | ||||
| 
 | ||||
| enum baseband_config_type { | ||||
| 	BASEBAND_CONFIG_PHY_REG = 0, | ||||
| 	BASEBAND_CONFIG_AGC_TAB = 1, | ||||
| }; | ||||
| 
 | ||||
| enum ra_offset_area { | ||||
| 	RA_OFFSET_LEGACY_OFDM1, | ||||
| 	RA_OFFSET_LEGACY_OFDM2, | ||||
| 	RA_OFFSET_HT_OFDM1, | ||||
| 	RA_OFFSET_HT_OFDM2, | ||||
| 	RA_OFFSET_HT_OFDM3, | ||||
| 	RA_OFFSET_HT_OFDM4, | ||||
| 	RA_OFFSET_HT_CCK, | ||||
| }; | ||||
| 
 | ||||
| enum antenna_path { | ||||
| 	ANTENNA_NONE, | ||||
| 	ANTENNA_D, | ||||
| 	ANTENNA_C, | ||||
| 	ANTENNA_CD, | ||||
| 	ANTENNA_B, | ||||
| 	ANTENNA_BD, | ||||
| 	ANTENNA_BC, | ||||
| 	ANTENNA_BCD, | ||||
| 	ANTENNA_A, | ||||
| 	ANTENNA_AD, | ||||
| 	ANTENNA_AC, | ||||
| 	ANTENNA_ACD, | ||||
| 	ANTENNA_AB, | ||||
| 	ANTENNA_ABD, | ||||
| 	ANTENNA_ABC, | ||||
| 	ANTENNA_ABCD | ||||
| }; | ||||
| 
 | ||||
| struct r_antenna_select_ofdm { | ||||
| 	u32 r_tx_antenna:4; | ||||
| 	u32 r_ant_l:4; | ||||
| 	u32 r_ant_non_ht:4; | ||||
| 	u32 r_ant_ht1:4; | ||||
| 	u32 r_ant_ht2:4; | ||||
| 	u32 r_ant_ht_s1:4; | ||||
| 	u32 r_ant_non_ht_s1:4; | ||||
| 	u32 ofdm_txsc:2; | ||||
| 	u32 reserved:2; | ||||
| }; | ||||
| 
 | ||||
| struct r_antenna_select_cck { | ||||
| 	u8 r_cckrx_enable_2:2; | ||||
| 	u8 r_cckrx_enable:2; | ||||
| 	u8 r_ccktx_enable:4; | ||||
| }; | ||||
| 
 | ||||
| struct efuse_contents { | ||||
| 	u8 mac_addr[ETH_ALEN]; | ||||
| 	u8 cck_tx_power_idx[6]; | ||||
| 	u8 ht40_1s_tx_power_idx[6]; | ||||
| 	u8 ht40_2s_tx_power_idx_diff[3]; | ||||
| 	u8 ht20_tx_power_idx_diff[3]; | ||||
| 	u8 ofdm_tx_power_idx_diff[3]; | ||||
| 	u8 ht40_max_power_offset[3]; | ||||
| 	u8 ht20_max_power_offset[3]; | ||||
| 	u8 channel_plan; | ||||
| 	u8 thermal_meter; | ||||
| 	u8 rf_option[5]; | ||||
| 	u8 version; | ||||
| 	u8 oem_id; | ||||
| 	u8 regulatory; | ||||
| }; | ||||
| 
 | ||||
| struct tx_power_struct { | ||||
| 	u8 cck[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 ht40_1s[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 ht40_2s[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 ht20_diff[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 legacy_ht_diff[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 legacy_ht_txpowerdiff; | ||||
| 	u8 groupht20[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 groupht40[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; | ||||
| 	u8 pwrgroup_cnt; | ||||
| 	u32 mcs_original_offset[4][16]; | ||||
| }; | ||||
| 
 | ||||
| u32 rtl8723e_phy_query_rf_reg(struct ieee80211_hw *hw, | ||||
| 			      enum radio_path rfpath, u32 regaddr, | ||||
| 			      u32 bitmask); | ||||
| void rtl8723e_phy_set_rf_reg(struct ieee80211_hw *hw, | ||||
| 			     enum radio_path rfpath, u32 regaddr, | ||||
| 			     u32 bitmask, u32 data); | ||||
| bool rtl8723e_phy_mac_config(struct ieee80211_hw *hw); | ||||
| bool rtl8723e_phy_bb_config(struct ieee80211_hw *hw); | ||||
| bool rtl8723e_phy_rf_config(struct ieee80211_hw *hw); | ||||
| bool rtl92c_phy_config_rf_with_feaderfile(struct ieee80211_hw *hw, | ||||
| 					  enum radio_path rfpath); | ||||
| void rtl8723e_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); | ||||
| void rtl8723e_phy_get_txpower_level(struct ieee80211_hw *hw, | ||||
| 				    long *powerlevel); | ||||
| void rtl8723e_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); | ||||
| bool rtl8723e_phy_update_txpower_dbm(struct ieee80211_hw *hw, | ||||
| 				     long power_indbm); | ||||
| void rtl8723e_phy_scan_operation_backup(struct ieee80211_hw *hw, | ||||
| 					u8 operation); | ||||
| void rtl8723e_phy_set_bw_mode_callback(struct ieee80211_hw *hw); | ||||
| void rtl8723e_phy_set_bw_mode(struct ieee80211_hw *hw, | ||||
| 			      enum nl80211_channel_type ch_type); | ||||
| void rtl8723e_phy_sw_chnl_callback(struct ieee80211_hw *hw); | ||||
| u8 rtl8723e_phy_sw_chnl(struct ieee80211_hw *hw); | ||||
| void rtl8723e_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery); | ||||
| void rtl8723e_phy_lc_calibrate(struct ieee80211_hw *hw); | ||||
| void rtl8723e_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain); | ||||
| bool rtl8723e_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, | ||||
| 					    enum radio_path rfpath); | ||||
| bool rtl8723e_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); | ||||
| bool rtl8723e_phy_set_rf_power_state(struct ieee80211_hw *hw, | ||||
| 				     enum rf_pwrstate rfpwr_state); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										112
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/pwrseq.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										112
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/pwrseq.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,112 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../pwrseqcmd.h" | ||||
| #include "pwrseq.h" | ||||
| 
 | ||||
| /* drivers should parse below arrays and do the corresponding actions */ | ||||
| /*3 Power on  Array*/ | ||||
| struct wlan_pwr_cfg rtl8723A_power_on_flow | ||||
| 		[RTL8723A_TRANS_CARDEMU_TO_ACT_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_CARDEMU_TO_ACT | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3Radio off GPIO Array */ | ||||
| struct wlan_pwr_cfg rtl8723A_radio_off_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3Card Disable Array*/ | ||||
| struct wlan_pwr_cfg rtl8723A_card_disable_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723A_TRANS_CARDEMU_TO_CARDDIS | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Card Enable Array*/ | ||||
| struct wlan_pwr_cfg rtl8723A_card_enable_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_CARDDIS_TO_CARDEMU | ||||
| 	RTL8723A_TRANS_CARDEMU_TO_ACT | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3Suspend Array*/ | ||||
| struct wlan_pwr_cfg rtl8723A_suspend_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723A_TRANS_CARDEMU_TO_SUS | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Resume Array*/ | ||||
| struct wlan_pwr_cfg rtl8723A_resume_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_SUS_TO_CARDEMU | ||||
| 	RTL8723A_TRANS_CARDEMU_TO_ACT | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3HWPDN Array*/ | ||||
| struct wlan_pwr_cfg rtl8723A_hwpdn_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	RTL8723A_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723A_TRANS_CARDEMU_TO_PDN | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Enter LPS */ | ||||
| struct wlan_pwr_cfg rtl8723A_enter_lps_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_LPS_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	/*FW behavior*/ | ||||
| 	RTL8723A_TRANS_ACT_TO_LPS | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Leave LPS */ | ||||
| struct wlan_pwr_cfg rtl8723A_leave_lps_flow | ||||
| 		[RTL8723A_TRANS_LPS_TO_ACT_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS] = { | ||||
| 	/*FW behavior*/ | ||||
| 	RTL8723A_TRANS_LPS_TO_ACT | ||||
| 	RTL8723A_TRANS_END | ||||
| }; | ||||
							
								
								
									
										340
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/pwrseq.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										340
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/pwrseq.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,340 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_PWRSEQ_H__ | ||||
| #define __RTL8723E_PWRSEQ_H__ | ||||
| 
 | ||||
| #include "../pwrseqcmd.h" | ||||
| /*
 | ||||
|  *	Check document WM-20110607-Paul-RTL8723A_Power_Architecture-R02.vsd | ||||
|  *	There are 6 HW Power States: | ||||
|  *	0: POFF--Power Off | ||||
|  *	1: PDN--Power Down | ||||
|  *	2: CARDEMU--Card Emulation | ||||
|  *	3: ACT--Active Mode | ||||
|  *	4: LPS--Low Power State | ||||
|  *	5: SUS--Suspend | ||||
|  * | ||||
|  *	The transision from different states are defined below | ||||
|  *	TRANS_CARDEMU_TO_ACT | ||||
|  *	TRANS_ACT_TO_CARDEMU | ||||
|  *	TRANS_CARDEMU_TO_SUS | ||||
|  *	TRANS_SUS_TO_CARDEMU | ||||
|  *	TRANS_CARDEMU_TO_PDN | ||||
|  *	TRANS_ACT_TO_LPS | ||||
|  *	TRANS_LPS_TO_ACT | ||||
|  * | ||||
|  *	TRANS_END | ||||
|  */ | ||||
| 
 | ||||
| #define	RTL8723A_TRANS_CARDEMU_TO_ACT_STEPS	10 | ||||
| #define	RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS	10 | ||||
| #define	RTL8723A_TRANS_CARDEMU_TO_SUS_STEPS	10 | ||||
| #define	RTL8723A_TRANS_SUS_TO_CARDEMU_STEPS	10 | ||||
| #define	RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS	10 | ||||
| #define	RTL8723A_TRANS_PDN_TO_CARDEMU_STEPS	10 | ||||
| #define	RTL8723A_TRANS_ACT_TO_LPS_STEPS		15 | ||||
| #define	RTL8723A_TRANS_LPS_TO_ACT_STEPS		15 | ||||
| #define	RTL8723A_TRANS_END_STEPS		1 | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }*/ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_CARDEMU_TO_ACT	\ | ||||
| 	/* disable SW LPS 0x04[10]=0*/	\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(2), 0},\ | ||||
| 	/* wait till 0x04[17] = 1    power ready*/	\ | ||||
| 	{0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), BIT(1)},\ | ||||
| 	/* release WLON reset  0x04[16]=1*/	\ | ||||
| 	{0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)},\ | ||||
| 	/* disable HWPDN 0x04[15]=0*/ \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0},\ | ||||
| 	/* disable WL suspend*/ \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, (BIT(4)|BIT(3)), 0},\ | ||||
| 	/* polling until return 0*/ \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)},\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(0), 0}, | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_ACT_TO_CARDEMU	\ | ||||
| 	/*0x1F[7:0] = 0 turn off RF*/ \ | ||||
| 	{0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0},	\ | ||||
| 	{0x004E, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0},\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)}, \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), 0}, | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/ | ||||
| #define RTL8723A_TRANS_CARDEMU_TO_SUS			\ | ||||
| 		/*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/	\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, \ | ||||
| 		BIT(4)|BIT(3), (BIT(4)|BIT(3))},\ | ||||
| /*0x04[12:11] = 2b'01 enable WL suspend*/	\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK| \ | ||||
| 		PWR_INTF_SDIO_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, \ | ||||
| 		PWR_CMD_WRITE, \ | ||||
| 		BIT(3)|BIT(4), BIT(3)}, \ | ||||
| /*0x04[12:11] = 2b'11 enable WL suspend for PCIe*/ \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, \ | ||||
| 		PWR_CMD_WRITE, BIT(3)|BIT(4), \ | ||||
| 		BIT(3)|BIT(4)}, \ | ||||
| /*Set SDIO suspend local register*/	\ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_WRITE, BIT(0), BIT(0)}, \ | ||||
| /*wait power state to suspend*/ \ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_POLLING, BIT(1), 0}, | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_SUS_TO_CARDEMU	\ | ||||
|  /*Set SDIO suspend local register*/	\ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,\ | ||||
| 		PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), 0},\ | ||||
|  /*wait power state to suspend*/ \ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,\ | ||||
| 		PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), BIT(1)},\ | ||||
|  /*0x04[12:11] = 2b'01enable WL suspend*/ \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), 0}, | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_CARDEMU_TO_CARDDIS \ | ||||
|  /*0x04[12:11] = 2b'01 enable WL suspend*/	 \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, \ | ||||
| 		PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, \ | ||||
| /*0x04[10] = 1, enable SW LPS*/	\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(2), BIT(2)}, \ | ||||
| /*Set SDIO suspend local register*/ \ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_WRITE, BIT(0), BIT(0)}, \ | ||||
|  /*wait power state to suspend*/ \ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_POLLING, BIT(1), 0}, | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_CARDDIS_TO_CARDEMU\ | ||||
| /*Set SDIO suspend local register*/	\ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_WRITE, BIT(0), 0}, \ | ||||
|  /*wait power state to suspend*/ \ | ||||
| 	{0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_POLLING, BIT(1), BIT(1)},\ | ||||
|  /*0x04[12:11] = 2b'00enable WL suspend*/ \ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(3)|BIT(4), 0},\ | ||||
| /*PCIe DMA start*/ \ | ||||
| 	{0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0}, | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| #define RTL8723A_TRANS_CARDEMU_TO_PDN	\ | ||||
| 	{0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(0), 0},/* 0x04[16] = 0*/\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(7), BIT(7)},/* 0x04[15] = 1*/ | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| #define RTL8723A_TRANS_PDN_TO_CARDEMU	\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(7), 0},/* 0x04[15] = 0*/ | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_ACT_TO_LPS	\ | ||||
| 	{0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0xFF},/*PCIe DMA stop*/	\ | ||||
| 	{0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/	\ | ||||
| 	/*Should be zero if no packet is transmitting*/	\ | ||||
| 	{0x05F8, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_POLLING, 0xFF, 0},\ | ||||
| 	/*Should be zero if no packet is transmitting*/	\ | ||||
| 	{0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_POLLING, 0xFF, 0},\ | ||||
| 	/*Should be zero if no packet is transmitting*/	\ | ||||
| 	{0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_POLLING, 0xFF, 0},\ | ||||
| 	/*Should be zero if no packet is transmitting*/	\ | ||||
| 	{0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_POLLING, 0xFF, 0},\ | ||||
| 	/*CCK and OFDM are disabled,and clock are gated*/ \ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(0), 0},\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US},/*Delay 1us*/\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(1), 0},/*Whole BB is reset*/	\ | ||||
| 	{0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0x3F},/*Reset MAC TRX*/	\ | ||||
| 	{0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(1), 0},/*check if removed later*/	\ | ||||
| 	/*Respond TxOK to scheduler*/	\ | ||||
| 	{0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(5), BIT(5)},\ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_LPS_TO_ACT\ | ||||
| /* format */	\ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */	\ | ||||
| 	{0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0x84}, /*SDIO RPWM*/\ | ||||
| 	{0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_USB_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0x84}, /*USB RPWM*/\ | ||||
| 	{0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0x84}, /*PCIe RPWM*/\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, /*Delay*/\ | ||||
| 	/*.	0x08[4] = 0		 switch TSF to 40M*/\ | ||||
| 	{0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(4), 0},  \ | ||||
| 	/*Polling 0x109[7]=0  TSF in 40M*/\ | ||||
| 	{0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_POLLING, BIT(7), 0}, \ | ||||
| 	/*.	0x29[7:6] = 2b'00	 enable BB clock*/\ | ||||
| 	{0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(6)|BIT(7), 0},\ | ||||
| 	 /*.	0x101[1] = 1*/\ | ||||
| 	{0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(1), BIT(1)},\ | ||||
| 	 /*.	0x100[7:0] = 0xFF	 enable WMAC TRX*/\ | ||||
| 	{0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0xFF},\ | ||||
| 	 /*.	0x02[1:0] = 2b'11	 enable BB macro*/\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, BIT(1)|BIT(0), BIT(1)|BIT(0)},\ | ||||
| 	{0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, \ | ||||
| 		PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC,\ | ||||
| 		PWR_CMD_WRITE, 0xFF, 0}, /*.	0x522 = 0*/ | ||||
| 
 | ||||
| /* format */ | ||||
| /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */ | ||||
| 
 | ||||
| #define RTL8723A_TRANS_END \ | ||||
| 	{0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 	0, PWR_CMD_END, 0, 0} | ||||
| 
 | ||||
| extern struct wlan_pwr_cfg rtl8723A_power_on_flow | ||||
| 		[RTL8723A_TRANS_CARDEMU_TO_ACT_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_radio_off_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_card_disable_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_card_enable_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_suspend_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_resume_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_hwpdn_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 		 RTL8723A_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 		 RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_enter_lps_flow | ||||
| 		[RTL8723A_TRANS_ACT_TO_LPS_STEPS + RTL8723A_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723A_leave_lps_flow | ||||
| 		[RTL8723A_TRANS_LPS_TO_ACT_STEPS + RTL8723A_TRANS_END_STEPS]; | ||||
| 
 | ||||
| /* RTL8723 Power Configuration CMDs for PCIe interface */ | ||||
| #define Rtl8723_NIC_PWR_ON_FLOW		rtl8723A_power_on_flow | ||||
| #define Rtl8723_NIC_RF_OFF_FLOW		rtl8723A_radio_off_flow | ||||
| #define Rtl8723_NIC_DISABLE_FLOW	rtl8723A_card_disable_flow | ||||
| #define Rtl8723_NIC_ENABLE_FLOW		rtl8723A_card_enable_flow | ||||
| #define Rtl8723_NIC_SUSPEND_FLOW	rtl8723A_suspend_flow | ||||
| #define Rtl8723_NIC_RESUME_FLOW		rtl8723A_resume_flow | ||||
| #define Rtl8723_NIC_PDN_FLOW		rtl8723A_hwpdn_flow | ||||
| #define Rtl8723_NIC_LPS_ENTER_FLOW	rtl8723A_enter_lps_flow | ||||
| #define Rtl8723_NIC_LPS_LEAVE_FLOW	rtl8723A_leave_lps_flow | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										2120
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/reg.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2120
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/reg.h
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										514
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/rf.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										514
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/rf.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,514 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "reg.h" | ||||
| #include "def.h" | ||||
| #include "phy.h" | ||||
| #include "rf.h" | ||||
| #include "dm.h" | ||||
| 
 | ||||
| static bool _rtl8723e_phy_rf6052_config_parafile(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| void rtl8723e_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, u8 bandwidth) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 
 | ||||
| 	switch (bandwidth) { | ||||
| 	case HT_CHANNEL_WIDTH_20: | ||||
| 		rtlphy->rfreg_chnlval[0] = ((rtlphy->rfreg_chnlval[0] & | ||||
| 					     0xfffff3ff) | 0x0400); | ||||
| 		rtl_set_rfreg(hw, RF90_PATH_A, RF_CHNLBW, RFREG_OFFSET_MASK, | ||||
| 			      rtlphy->rfreg_chnlval[0]); | ||||
| 		break; | ||||
| 	case HT_CHANNEL_WIDTH_20_40: | ||||
| 		rtlphy->rfreg_chnlval[0] = ((rtlphy->rfreg_chnlval[0] & | ||||
| 					     0xfffff3ff)); | ||||
| 		rtl_set_rfreg(hw, RF90_PATH_A, RF_CHNLBW, RFREG_OFFSET_MASK, | ||||
| 			      rtlphy->rfreg_chnlval[0]); | ||||
| 		break; | ||||
| 	default: | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 			 "unknown bandwidth: %#X\n", bandwidth); | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, | ||||
| 					 u8 *ppowerlevel) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||||
| 	u32 tx_agc[2] = {0, 0}, tmpval; | ||||
| 	bool turbo_scanoff = false; | ||||
| 	u8 idx1, idx2; | ||||
| 	u8 *ptr; | ||||
| 
 | ||||
| 	if (rtlefuse->eeprom_regulatory != 0) | ||||
| 		turbo_scanoff = true; | ||||
| 
 | ||||
| 	if (mac->act_scanning == true) { | ||||
| 		tx_agc[RF90_PATH_A] = 0x3f3f3f3f; | ||||
| 		tx_agc[RF90_PATH_B] = 0x3f3f3f3f; | ||||
| 
 | ||||
| 		if (turbo_scanoff) { | ||||
| 			for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; | ||||
| 				idx1++) { | ||||
| 				tx_agc[idx1] = ppowerlevel[idx1] | | ||||
| 				    (ppowerlevel[idx1] << 8) | | ||||
| 				    (ppowerlevel[idx1] << 16) | | ||||
| 				    (ppowerlevel[idx1] << 24); | ||||
| 			} | ||||
| 		} | ||||
| 	} else { | ||||
| 		for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) { | ||||
| 			tx_agc[idx1] = ppowerlevel[idx1] | | ||||
| 			    (ppowerlevel[idx1] << 8) | | ||||
| 			    (ppowerlevel[idx1] << 16) | | ||||
| 			    (ppowerlevel[idx1] << 24); | ||||
| 		} | ||||
| 
 | ||||
| 		if (rtlefuse->eeprom_regulatory == 0) { | ||||
| 			tmpval = | ||||
| 			    (rtlphy->mcs_txpwrlevel_origoffset[0][6]) + | ||||
| 			    (rtlphy->mcs_txpwrlevel_origoffset[0][7] << | ||||
| 			     8); | ||||
| 			tx_agc[RF90_PATH_A] += tmpval; | ||||
| 
 | ||||
| 			tmpval = (rtlphy->mcs_txpwrlevel_origoffset[0][14]) + | ||||
| 			    (rtlphy->mcs_txpwrlevel_origoffset[0][15] << | ||||
| 			     24); | ||||
| 			tx_agc[RF90_PATH_B] += tmpval; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	for (idx1 = RF90_PATH_A; idx1 <= RF90_PATH_B; idx1++) { | ||||
| 		ptr = (u8 *)&tx_agc[idx1]; | ||||
| 		for (idx2 = 0; idx2 < 4; idx2++) { | ||||
| 			if (*ptr > RF6052_MAX_TX_PWR) | ||||
| 				*ptr = RF6052_MAX_TX_PWR; | ||||
| 			ptr++; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	tmpval = tx_agc[RF90_PATH_A] & 0xff; | ||||
| 	rtl_set_bbreg(hw, RTXAGC_A_CCK1_MCS32, MASKBYTE1, tmpval); | ||||
| 
 | ||||
| 	RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 		"CCK PWR 1M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, | ||||
| 		 RTXAGC_A_CCK1_MCS32); | ||||
| 
 | ||||
| 	tmpval = tx_agc[RF90_PATH_A] >> 8; | ||||
| 
 | ||||
| 	tmpval = tmpval & 0xff00ffff; | ||||
| 
 | ||||
| 	rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); | ||||
| 
 | ||||
| 	RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 		"CCK PWR 2~11M (rf-A) = 0x%x (reg 0x%x)\n", tmpval, | ||||
| 		 RTXAGC_B_CCK11_A_CCK2_11); | ||||
| 
 | ||||
| 	tmpval = tx_agc[RF90_PATH_B] >> 24; | ||||
| 	rtl_set_bbreg(hw, RTXAGC_B_CCK11_A_CCK2_11, MASKBYTE0, tmpval); | ||||
| 
 | ||||
| 	RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 		"CCK PWR 11M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, | ||||
| 		 RTXAGC_B_CCK11_A_CCK2_11); | ||||
| 
 | ||||
| 	tmpval = tx_agc[RF90_PATH_B] & 0x00ffffff; | ||||
| 	rtl_set_bbreg(hw, RTXAGC_B_CCK1_55_MCS32, 0xffffff00, tmpval); | ||||
| 
 | ||||
| 	RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 		"CCK PWR 1~5.5M (rf-B) = 0x%x (reg 0x%x)\n", tmpval, | ||||
| 		 RTXAGC_B_CCK1_55_MCS32); | ||||
| } | ||||
| 
 | ||||
| static void rtl8723e_phy_get_power_base(struct ieee80211_hw *hw, | ||||
| 					u8 *ppowerlevel, u8 channel, | ||||
| 					u32 *ofdmbase, u32 *mcsbase) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||||
| 	u32 powerbase0, powerbase1; | ||||
| 	u8 legacy_pwrdiff, ht20_pwrdiff; | ||||
| 	u8 i, powerlevel[2]; | ||||
| 
 | ||||
| 	for (i = 0; i < 2; i++) { | ||||
| 		powerlevel[i] = ppowerlevel[i]; | ||||
| 		legacy_pwrdiff = rtlefuse->txpwr_legacyhtdiff[i][channel - 1]; | ||||
| 		powerbase0 = powerlevel[i] + legacy_pwrdiff; | ||||
| 
 | ||||
| 		powerbase0 = (powerbase0 << 24) | (powerbase0 << 16) | | ||||
| 		    (powerbase0 << 8) | powerbase0; | ||||
| 		*(ofdmbase + i) = powerbase0; | ||||
| 		RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 			" [OFDM power base index rf(%c) = 0x%x]\n", | ||||
| 			 ((i == 0) ? 'A' : 'B'), *(ofdmbase + i)); | ||||
| 	} | ||||
| 
 | ||||
| 	for (i = 0; i < 2; i++) { | ||||
| 		if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20) { | ||||
| 			ht20_pwrdiff = | ||||
| 				rtlefuse->txpwr_ht20diff[i][channel - 1]; | ||||
| 			powerlevel[i] += ht20_pwrdiff; | ||||
| 		} | ||||
| 		powerbase1 = powerlevel[i]; | ||||
| 		powerbase1 = (powerbase1 << 24) | | ||||
| 		    (powerbase1 << 16) | (powerbase1 << 8) | powerbase1; | ||||
| 
 | ||||
| 		*(mcsbase + i) = powerbase1; | ||||
| 
 | ||||
| 		RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 			" [MCS power base index rf(%c) = 0x%x]\n", | ||||
| 			 ((i == 0) ? 'A' : 'B'), *(mcsbase + i)); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void get_txpower_writeval_by_reg(struct ieee80211_hw *hw, | ||||
| 					u8 channel, u8 index, | ||||
| 					u32 *powerbase0, | ||||
| 					u32 *powerbase1, | ||||
| 					u32 *p_outwriteval) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||||
| 	u8 i, chnlgroup = 0, pwr_diff_limit[4]; | ||||
| 	u32 writeval, customer_limit, rf; | ||||
| 
 | ||||
| 	for (rf = 0; rf < 2; rf++) { | ||||
| 		switch (rtlefuse->eeprom_regulatory) { | ||||
| 		case 0: | ||||
| 			chnlgroup = 0; | ||||
| 
 | ||||
| 			writeval = | ||||
| 			    rtlphy->mcs_txpwrlevel_origoffset[chnlgroup][index + | ||||
| 								(rf ? 8 : 0)] | ||||
| 			    + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); | ||||
| 
 | ||||
| 			RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 				"RTK better performance, writeval(%c) = 0x%x\n", | ||||
| 				((rf == 0) ? 'A' : 'B'), writeval); | ||||
| 			break; | ||||
| 		case 1: | ||||
| 			if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { | ||||
| 				writeval = ((index < 2) ? powerbase0[rf] : | ||||
| 					    powerbase1[rf]); | ||||
| 
 | ||||
| 				RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 					"Realtek regulatory, 40MHz, writeval(%c) = 0x%x\n", | ||||
| 					((rf == 0) ? 'A' : 'B'), writeval); | ||||
| 			} else { | ||||
| 				if (rtlphy->pwrgroup_cnt == 1) | ||||
| 					chnlgroup = 0; | ||||
| 				if (rtlphy->pwrgroup_cnt >= 3) { | ||||
| 					if (channel <= 3) | ||||
| 						chnlgroup = 0; | ||||
| 					else if (channel >= 4 && channel <= 9) | ||||
| 						chnlgroup = 1; | ||||
| 					else if (channel > 9) | ||||
| 						chnlgroup = 2; | ||||
| 					if (rtlphy->current_chan_bw == | ||||
| 						HT_CHANNEL_WIDTH_20) | ||||
| 						chnlgroup++; | ||||
| 					else | ||||
| 						chnlgroup += 4; | ||||
| 				} | ||||
| 
 | ||||
| 				writeval = | ||||
| 				    rtlphy->mcs_txpwrlevel_origoffset[chnlgroup] | ||||
| 				    [index + (rf ? 8 : 0)] + ((index < 2) ? | ||||
| 							      powerbase0[rf] : | ||||
| 							      powerbase1[rf]); | ||||
| 
 | ||||
| 				RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 					"Realtek regulatory, 20MHz, writeval(%c) = 0x%x\n", | ||||
| 					((rf == 0) ? 'A' : 'B'), writeval); | ||||
| 			} | ||||
| 			break; | ||||
| 		case 2: | ||||
| 			writeval = | ||||
| 			    ((index < 2) ? powerbase0[rf] : powerbase1[rf]); | ||||
| 
 | ||||
| 			RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 				"Better regulatory, writeval(%c) = 0x%x\n", | ||||
| 				((rf == 0) ? 'A' : 'B'), writeval); | ||||
| 			break; | ||||
| 		case 3: | ||||
| 			chnlgroup = 0; | ||||
| 
 | ||||
| 			if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) { | ||||
| 				RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 					"customer's limit, 40MHz rf(%c) = 0x%x\n", | ||||
| 					((rf == 0) ? 'A' : 'B'), | ||||
| 					rtlefuse->pwrgroup_ht40[rf][channel - | ||||
| 								     1]); | ||||
| 			} else { | ||||
| 				RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 					"customer's limit, 20MHz rf(%c) = 0x%x\n", | ||||
| 					((rf == 0) ? 'A' : 'B'), | ||||
| 					rtlefuse->pwrgroup_ht20[rf][channel - | ||||
| 								     1]); | ||||
| 			} | ||||
| 			for (i = 0; i < 4; i++) { | ||||
| 				pwr_diff_limit[i] = | ||||
| 				    (u8)((rtlphy->mcs_txpwrlevel_origoffset | ||||
| 					  [chnlgroup][index + | ||||
| 						(rf ? 8 : 0)] & (0x7f << | ||||
| 						(i * 8))) >> (i * 8)); | ||||
| 
 | ||||
| 				if (rtlphy->current_chan_bw == | ||||
| 				    HT_CHANNEL_WIDTH_20_40) { | ||||
| 					if (pwr_diff_limit[i] > | ||||
| 					    rtlefuse-> | ||||
| 					    pwrgroup_ht40[rf][channel - 1]) | ||||
| 						pwr_diff_limit[i] = | ||||
| 						    rtlefuse->pwrgroup_ht40[rf] | ||||
| 						    [channel - 1]; | ||||
| 				} else { | ||||
| 					if (pwr_diff_limit[i] > | ||||
| 					    rtlefuse-> | ||||
| 					    pwrgroup_ht20[rf][channel - 1]) | ||||
| 						pwr_diff_limit[i] = | ||||
| 						    rtlefuse->pwrgroup_ht20[rf] | ||||
| 						    [channel - 1]; | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			customer_limit = (pwr_diff_limit[3] << 24) | | ||||
| 			    (pwr_diff_limit[2] << 16) | | ||||
| 			    (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); | ||||
| 
 | ||||
| 			RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 				"Customer's limit rf(%c) = 0x%x\n", | ||||
| 				 ((rf == 0) ? 'A' : 'B'), customer_limit); | ||||
| 
 | ||||
| 			writeval = customer_limit + | ||||
| 			    ((index < 2) ? powerbase0[rf] : powerbase1[rf]); | ||||
| 
 | ||||
| 			RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 				"Customer, writeval rf(%c)= 0x%x\n", | ||||
| 				 ((rf == 0) ? 'A' : 'B'), writeval); | ||||
| 			break; | ||||
| 		default: | ||||
| 			chnlgroup = 0; | ||||
| 			writeval = | ||||
| 			    rtlphy->mcs_txpwrlevel_origoffset[chnlgroup] | ||||
| 			    [index + (rf ? 8 : 0)] | ||||
| 			    + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); | ||||
| 
 | ||||
| 			RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 				"RTK better performance, writeval rf(%c) = 0x%x\n", | ||||
| 				((rf == 0) ? 'A' : 'B'), writeval); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		if (rtlpriv->dm.dynamic_txhighpower_lvl == TXHIGHPWRLEVEL_BT1) | ||||
| 			writeval = writeval - 0x06060606; | ||||
| 		else if (rtlpriv->dm.dynamic_txhighpower_lvl == | ||||
| 			 TXHIGHPWRLEVEL_BT2) | ||||
| 			writeval = writeval - 0x0c0c0c0c; | ||||
| 		*(p_outwriteval + rf) = writeval; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723e_write_ofdm_power_reg(struct ieee80211_hw *hw, | ||||
| 					   u8 index, u32 *pvalue) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 
 | ||||
| 	u16 regoffset_a[6] = { | ||||
| 		RTXAGC_A_RATE18_06, RTXAGC_A_RATE54_24, | ||||
| 		RTXAGC_A_MCS03_MCS00, RTXAGC_A_MCS07_MCS04, | ||||
| 		RTXAGC_A_MCS11_MCS08, RTXAGC_A_MCS15_MCS12 | ||||
| 	}; | ||||
| 	u16 regoffset_b[6] = { | ||||
| 		RTXAGC_B_RATE18_06, RTXAGC_B_RATE54_24, | ||||
| 		RTXAGC_B_MCS03_MCS00, RTXAGC_B_MCS07_MCS04, | ||||
| 		RTXAGC_B_MCS11_MCS08, RTXAGC_B_MCS15_MCS12 | ||||
| 	}; | ||||
| 	u8 i, rf, pwr_val[4]; | ||||
| 	u32 writeval; | ||||
| 	u16 regoffset; | ||||
| 
 | ||||
| 	for (rf = 0; rf < 2; rf++) { | ||||
| 		writeval = pvalue[rf]; | ||||
| 		for (i = 0; i < 4; i++) { | ||||
| 			pwr_val[i] = (u8)((writeval & (0x7f << | ||||
| 					   (i * 8))) >> (i * 8)); | ||||
| 
 | ||||
| 			if (pwr_val[i] > RF6052_MAX_TX_PWR) | ||||
| 				pwr_val[i] = RF6052_MAX_TX_PWR; | ||||
| 		} | ||||
| 		writeval = (pwr_val[3] << 24) | (pwr_val[2] << 16) | | ||||
| 		    (pwr_val[1] << 8) | pwr_val[0]; | ||||
| 
 | ||||
| 		if (rf == 0) | ||||
| 			regoffset = regoffset_a[index]; | ||||
| 		else | ||||
| 			regoffset = regoffset_b[index]; | ||||
| 		rtl_set_bbreg(hw, regoffset, MASKDWORD, writeval); | ||||
| 
 | ||||
| 		RTPRINT(rtlpriv, FPHY, PHY_TXPWR, | ||||
| 			"Set 0x%x = %08x\n", regoffset, writeval); | ||||
| 
 | ||||
| 		if (((get_rf_type(rtlphy) == RF_2T2R) && | ||||
| 		     (regoffset == RTXAGC_A_MCS15_MCS12 || | ||||
| 		      regoffset == RTXAGC_B_MCS15_MCS12)) || | ||||
| 		    ((get_rf_type(rtlphy) != RF_2T2R) && | ||||
| 		     (regoffset == RTXAGC_A_MCS07_MCS04 || | ||||
| 		      regoffset == RTXAGC_B_MCS07_MCS04))) { | ||||
| 
 | ||||
| 			writeval = pwr_val[3]; | ||||
| 			if (regoffset == RTXAGC_A_MCS15_MCS12 || | ||||
| 			    regoffset == RTXAGC_A_MCS07_MCS04) | ||||
| 				regoffset = 0xc90; | ||||
| 			if (regoffset == RTXAGC_B_MCS15_MCS12 || | ||||
| 			    regoffset == RTXAGC_B_MCS07_MCS04) | ||||
| 				regoffset = 0xc98; | ||||
| 
 | ||||
| 			for (i = 0; i < 3; i++) { | ||||
| 				writeval = (writeval > 6) ? (writeval - 6) : 0; | ||||
| 				rtl_write_byte(rtlpriv, (u32) (regoffset + i), | ||||
| 					       (u8)writeval); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_phy_rf6052_set_ofdm_txpower(struct ieee80211_hw *hw, | ||||
| 					  u8 *ppowerlevel, u8 channel) | ||||
| { | ||||
| 	u32 writeval[2], powerbase0[2], powerbase1[2]; | ||||
| 	u8 index; | ||||
| 
 | ||||
| 	rtl8723e_phy_get_power_base(hw, ppowerlevel, | ||||
| 				    channel, &powerbase0[0], &powerbase1[0]); | ||||
| 
 | ||||
| 	for (index = 0; index < 6; index++) { | ||||
| 		get_txpower_writeval_by_reg(hw, channel, index, &powerbase0[0], | ||||
| 					    &powerbase1[0], | ||||
| 					    &writeval[0]); | ||||
| 
 | ||||
| 		_rtl8723e_write_ofdm_power_reg(hw, index, &writeval[0]); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| bool rtl8723e_phy_rf6052_config(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 
 | ||||
| 	if (rtlphy->rf_type == RF_1T1R) | ||||
| 		rtlphy->num_total_rfpath = 1; | ||||
| 	else | ||||
| 		rtlphy->num_total_rfpath = 2; | ||||
| 
 | ||||
| 	return _rtl8723e_phy_rf6052_config_parafile(hw); | ||||
| } | ||||
| 
 | ||||
| static bool _rtl8723e_phy_rf6052_config_parafile(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &rtlpriv->phy; | ||||
| 	u32 u4_regvalue = 0; | ||||
| 	u8 rfpath; | ||||
| 	bool rtstatus = true; | ||||
| 	struct bb_reg_def *pphyreg; | ||||
| 
 | ||||
| 	for (rfpath = 0; rfpath < rtlphy->num_total_rfpath; rfpath++) { | ||||
| 
 | ||||
| 		pphyreg = &rtlphy->phyreg_def[rfpath]; | ||||
| 
 | ||||
| 		switch (rfpath) { | ||||
| 		case RF90_PATH_A: | ||||
| 		case RF90_PATH_C: | ||||
| 			u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs, | ||||
| 						    BRFSI_RFENV); | ||||
| 			break; | ||||
| 		case RF90_PATH_B: | ||||
| 		case RF90_PATH_D: | ||||
| 			u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs, | ||||
| 						    BRFSI_RFENV << 16); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		rtl_set_bbreg(hw, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1); | ||||
| 		udelay(1); | ||||
| 
 | ||||
| 		rtl_set_bbreg(hw, pphyreg->rfintfo, BRFSI_RFENV, 0x1); | ||||
| 		udelay(1); | ||||
| 
 | ||||
| 		rtl_set_bbreg(hw, pphyreg->rfhssi_para2, | ||||
| 			      B3WIREADDREAALENGTH, 0x0); | ||||
| 		udelay(1); | ||||
| 
 | ||||
| 		rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0); | ||||
| 		udelay(1); | ||||
| 
 | ||||
| 		switch (rfpath) { | ||||
| 		case RF90_PATH_A: | ||||
| 			rtstatus = rtl8723e_phy_config_rf_with_headerfile(hw, | ||||
| 						(enum radio_path)rfpath); | ||||
| 			break; | ||||
| 		case RF90_PATH_B: | ||||
| 			rtstatus = | ||||
| 			  rtl8723e_phy_config_rf_with_headerfile(hw, | ||||
| 						(enum radio_path)rfpath); | ||||
| 			break; | ||||
| 		case RF90_PATH_C: | ||||
| 			break; | ||||
| 		case RF90_PATH_D: | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		switch (rfpath) { | ||||
| 		case RF90_PATH_A: | ||||
| 		case RF90_PATH_C: | ||||
| 			rtl_set_bbreg(hw, pphyreg->rfintfs, | ||||
| 				      BRFSI_RFENV, u4_regvalue); | ||||
| 			break; | ||||
| 		case RF90_PATH_B: | ||||
| 		case RF90_PATH_D: | ||||
| 			rtl_set_bbreg(hw, pphyreg->rfintfs, | ||||
| 				      BRFSI_RFENV << 16, u4_regvalue); | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		if (rtstatus != true) { | ||||
| 			RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||||
| 				 "Radio[%d] Fail!!", rfpath); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "\n"); | ||||
| 	return rtstatus; | ||||
| } | ||||
							
								
								
									
										40
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/rf.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/rf.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,40 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_RF_H__ | ||||
| #define __RTL8723E_RF_H__ | ||||
| 
 | ||||
| #define RF6052_MAX_TX_PWR		0x3F | ||||
| #define RF6052_MAX_REG			0x3F | ||||
| 
 | ||||
| void rtl8723e_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, | ||||
| 				       u8 bandwidth); | ||||
| void rtl8723e_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, | ||||
| 					 u8 *ppowerlevel); | ||||
| void rtl8723e_phy_rf6052_set_ofdm_txpower(struct ieee80211_hw *hw, | ||||
| 					  u8 *ppowerlevel, u8 channel); | ||||
| bool rtl8723e_phy_rf6052_config(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										405
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/sw.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										405
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/sw.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,405 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "../core.h" | ||||
| #include "../pci.h" | ||||
| #include "reg.h" | ||||
| #include "def.h" | ||||
| #include "phy.h" | ||||
| #include "dm.h" | ||||
| #include "fw.h" | ||||
| #include "../rtl8723com/fw_common.h" | ||||
| #include "hw.h" | ||||
| #include "sw.h" | ||||
| #include "trx.h" | ||||
| #include "led.h" | ||||
| #include "table.h" | ||||
| #include "hal_btc.h" | ||||
| #include "../btcoexist/rtl_btc.h" | ||||
| #include "../rtl8723com/phy_common.h" | ||||
| 
 | ||||
| #include <linux/vmalloc.h> | ||||
| #include <linux/module.h> | ||||
| 
 | ||||
| static void rtl8723e_init_aspm_vars(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||||
| 
 | ||||
| 	/*close ASPM for AMD defaultly */ | ||||
| 	rtlpci->const_amdpci_aspm = 0; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * ASPM PS mode. | ||||
| 	 * 0 - Disable ASPM, | ||||
| 	 * 1 - Enable ASPM without Clock Req, | ||||
| 	 * 2 - Enable ASPM with Clock Req, | ||||
| 	 * 3 - Alwyas Enable ASPM with Clock Req, | ||||
| 	 * 4 - Always Enable ASPM without Clock Req. | ||||
| 	 * set defult to RTL8192CE:3 RTL8192E:2 | ||||
| 	 */ | ||||
| 	rtlpci->const_pci_aspm = 3; | ||||
| 
 | ||||
| 	/*Setting for PCI-E device */ | ||||
| 	rtlpci->const_devicepci_aspm_setting = 0x03; | ||||
| 
 | ||||
| 	/*Setting for PCI-E bridge */ | ||||
| 	rtlpci->const_hostpci_aspm_setting = 0x02; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * In Hw/Sw Radio Off situation. | ||||
| 	 * 0 - Default, | ||||
| 	 * 1 - From ASPM setting without low Mac Pwr, | ||||
| 	 * 2 - From ASPM setting with low Mac Pwr, | ||||
| 	 * 3 - Bus D3 | ||||
| 	 * set default to RTL8192CE:0 RTL8192SE:2 | ||||
| 	 */ | ||||
| 	rtlpci->const_hwsw_rfoff_d3 = 0; | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 * This setting works for those device with | ||||
| 	 * backdoor ASPM setting such as EPHY setting. | ||||
| 	 * 0 - Not support ASPM, | ||||
| 	 * 1 - Support ASPM, | ||||
| 	 * 2 - According to chipset. | ||||
| 	 */ | ||||
| 	rtlpci->const_support_pciaspm = 1; | ||||
| } | ||||
| 
 | ||||
| int rtl8723e_init_sw_vars(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||||
| 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); | ||||
| 	int err = 0; | ||||
| 
 | ||||
| 	rtl8723e_bt_reg_init(hw); | ||||
| 
 | ||||
| 	rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer(); | ||||
| 
 | ||||
| 	rtlpriv->dm.dm_initialgain_enable = 1; | ||||
| 	rtlpriv->dm.dm_flag = 0; | ||||
| 	rtlpriv->dm.disable_framebursting = 0; | ||||
| 	rtlpriv->dm.thermalvalue = 0; | ||||
| 	rtlpci->transmit_config = CFENDFORM | BIT(12) | BIT(13); | ||||
| 
 | ||||
| 	/* compatible 5G band 88ce just 2.4G band & smsp */ | ||||
| 	rtlpriv->rtlhal.current_bandtype = BAND_ON_2_4G; | ||||
| 	rtlpriv->rtlhal.bandset = BAND_ON_2_4G; | ||||
| 	rtlpriv->rtlhal.macphymode = SINGLEMAC_SINGLEPHY; | ||||
| 
 | ||||
| 	rtlpci->receive_config = (RCR_APPFCS | | ||||
| 				  RCR_APP_MIC | | ||||
| 				  RCR_APP_ICV | | ||||
| 				  RCR_APP_PHYST_RXFF | | ||||
| 				  RCR_HTC_LOC_CTRL | | ||||
| 				  RCR_AMF | | ||||
| 				  RCR_ACF | | ||||
| 				  RCR_ADF | | ||||
| 				  RCR_AICV | | ||||
| 				  RCR_AB | | ||||
| 				  RCR_AM | | ||||
| 				  RCR_APM | | ||||
| 				  0); | ||||
| 
 | ||||
| 	rtlpci->irq_mask[0] = | ||||
| 	    (u32) (PHIMR_ROK | | ||||
| 		   PHIMR_RDU | | ||||
| 		   PHIMR_VODOK | | ||||
| 		   PHIMR_VIDOK | | ||||
| 		   PHIMR_BEDOK | | ||||
| 		   PHIMR_BKDOK | | ||||
| 		   PHIMR_MGNTDOK | | ||||
| 		   PHIMR_HIGHDOK | | ||||
| 		   PHIMR_C2HCMD | | ||||
| 		   PHIMR_HISRE_IND | | ||||
| 		   PHIMR_TSF_BIT32_TOGGLE | | ||||
| 		   PHIMR_TXBCNOK | | ||||
| 		   PHIMR_PSTIMEOUT | | ||||
| 		   0); | ||||
| 
 | ||||
| 	rtlpci->irq_mask[1]	= | ||||
| 		 (u32)(PHIMR_RXFOVW | | ||||
| 				0); | ||||
| 
 | ||||
| 	/* for debug level */ | ||||
| 	rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug; | ||||
| 	/* for LPS & IPS */ | ||||
| 	rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps; | ||||
| 	rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; | ||||
| 	rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; | ||||
| 	if (rtlpriv->cfg->mod_params->disable_watchdog) | ||||
| 		pr_info("watchdog disabled\n"); | ||||
| 	rtlpriv->psc.reg_fwctrl_lps = 3; | ||||
| 	rtlpriv->psc.reg_max_lps_awakeintvl = 5; | ||||
| 	rtl8723e_init_aspm_vars(hw); | ||||
| 
 | ||||
| 	if (rtlpriv->psc.reg_fwctrl_lps == 1) | ||||
| 		rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE; | ||||
| 	else if (rtlpriv->psc.reg_fwctrl_lps == 2) | ||||
| 		rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE; | ||||
| 	else if (rtlpriv->psc.reg_fwctrl_lps == 3) | ||||
| 		rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE; | ||||
| 
 | ||||
| 	/* for firmware buf */ | ||||
| 	rtlpriv->rtlhal.pfirmware = vzalloc(0x6000); | ||||
| 	if (!rtlpriv->rtlhal.pfirmware) { | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 			 "Can't alloc buffer for fw.\n"); | ||||
| 		return 1; | ||||
| 	} | ||||
| 
 | ||||
| 	if (IS_VENDOR_8723_A_CUT(rtlhal->version)) | ||||
| 		rtlpriv->cfg->fw_name = "rtlwifi/rtl8723fw.bin"; | ||||
| 	else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) | ||||
| 		rtlpriv->cfg->fw_name = "rtlwifi/rtl8723fw_B.bin"; | ||||
| 
 | ||||
| 	rtlpriv->max_fw_size = 0x6000; | ||||
| 	pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name); | ||||
| 	err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name, | ||||
| 				      rtlpriv->io.dev, GFP_KERNEL, hw, | ||||
| 				      rtl_fw_cb); | ||||
| 	if (err) { | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 			 "Failed to request firmware!\n"); | ||||
| 		return 1; | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_deinit_sw_vars(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	if (rtlpriv->rtlhal.pfirmware) { | ||||
| 		vfree(rtlpriv->rtlhal.pfirmware); | ||||
| 		rtlpriv->rtlhal.pfirmware = NULL; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| /* get bt coexist status */ | ||||
| bool rtl8723e_get_btc_status(void) | ||||
| { | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| static bool is_fw_header(struct rtl8723e_firmware_header *hdr) | ||||
| { | ||||
| 	return (hdr->signature & 0xfff0) == 0x2300; | ||||
| } | ||||
| 
 | ||||
| static struct rtl_hal_ops rtl8723e_hal_ops = { | ||||
| 	.init_sw_vars = rtl8723e_init_sw_vars, | ||||
| 	.deinit_sw_vars = rtl8723e_deinit_sw_vars, | ||||
| 	.read_eeprom_info = rtl8723e_read_eeprom_info, | ||||
| 	.interrupt_recognized = rtl8723e_interrupt_recognized, | ||||
| 	.hw_init = rtl8723e_hw_init, | ||||
| 	.hw_disable = rtl8723e_card_disable, | ||||
| 	.hw_suspend = rtl8723e_suspend, | ||||
| 	.hw_resume = rtl8723e_resume, | ||||
| 	.enable_interrupt = rtl8723e_enable_interrupt, | ||||
| 	.disable_interrupt = rtl8723e_disable_interrupt, | ||||
| 	.set_network_type = rtl8723e_set_network_type, | ||||
| 	.set_chk_bssid = rtl8723e_set_check_bssid, | ||||
| 	.set_qos = rtl8723e_set_qos, | ||||
| 	.set_bcn_reg = rtl8723e_set_beacon_related_registers, | ||||
| 	.set_bcn_intv = rtl8723e_set_beacon_interval, | ||||
| 	.update_interrupt_mask = rtl8723e_update_interrupt_mask, | ||||
| 	.get_hw_reg = rtl8723e_get_hw_reg, | ||||
| 	.set_hw_reg = rtl8723e_set_hw_reg, | ||||
| 	.update_rate_tbl = rtl8723e_update_hal_rate_tbl, | ||||
| 	.fill_tx_desc = rtl8723e_tx_fill_desc, | ||||
| 	.fill_tx_cmddesc = rtl8723e_tx_fill_cmddesc, | ||||
| 	.query_rx_desc = rtl8723e_rx_query_desc, | ||||
| 	.set_channel_access = rtl8723e_update_channel_access_setting, | ||||
| 	.radio_onoff_checking = rtl8723e_gpio_radio_on_off_checking, | ||||
| 	.set_bw_mode = rtl8723e_phy_set_bw_mode, | ||||
| 	.switch_channel = rtl8723e_phy_sw_chnl, | ||||
| 	.dm_watchdog = rtl8723e_dm_watchdog, | ||||
| 	.scan_operation_backup = rtl8723e_phy_scan_operation_backup, | ||||
| 	.set_rf_power_state = rtl8723e_phy_set_rf_power_state, | ||||
| 	.led_control = rtl8723e_led_control, | ||||
| 	.set_desc = rtl8723e_set_desc, | ||||
| 	.get_desc = rtl8723e_get_desc, | ||||
| 	.is_tx_desc_closed = rtl8723e_is_tx_desc_closed, | ||||
| 	.tx_polling = rtl8723e_tx_polling, | ||||
| 	.enable_hw_sec = rtl8723e_enable_hw_security_config, | ||||
| 	.set_key = rtl8723e_set_key, | ||||
| 	.init_sw_leds = rtl8723e_init_sw_leds, | ||||
| 	.get_bbreg = rtl8723_phy_query_bb_reg, | ||||
| 	.set_bbreg = rtl8723_phy_set_bb_reg, | ||||
| 	.get_rfreg = rtl8723e_phy_query_rf_reg, | ||||
| 	.set_rfreg = rtl8723e_phy_set_rf_reg, | ||||
| 	.c2h_command_handle = rtl_8723e_c2h_command_handle, | ||||
| 	.bt_wifi_media_status_notify = rtl_8723e_bt_wifi_media_status_notify, | ||||
| 	.bt_coex_off_before_lps = | ||||
| 		rtl8723e_dm_bt_turn_off_bt_coexist_before_enter_lps, | ||||
| 	.get_btc_status = rtl8723e_get_btc_status, | ||||
| 	.rx_command_packet = rtl8723e_rx_command_packet, | ||||
| 	.is_fw_header = is_fw_header, | ||||
| }; | ||||
| 
 | ||||
| static struct rtl_mod_params rtl8723e_mod_params = { | ||||
| 	.sw_crypto = false, | ||||
| 	.inactiveps = true, | ||||
| 	.swctrl_lps = false, | ||||
| 	.fwctrl_lps = true, | ||||
| 	.debug = DBG_EMERG, | ||||
| }; | ||||
| 
 | ||||
| static struct rtl_hal_cfg rtl8723e_hal_cfg = { | ||||
| 	.bar_id = 2, | ||||
| 	.write_readback = true, | ||||
| 	.name = "rtl8723e_pci", | ||||
| 	.fw_name = "rtlwifi/rtl8723efw.bin", | ||||
| 	.ops = &rtl8723e_hal_ops, | ||||
| 	.mod_params = &rtl8723e_mod_params, | ||||
| 	.maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL, | ||||
| 	.maps[SYS_FUNC_EN] = REG_SYS_FUNC_EN, | ||||
| 	.maps[SYS_CLK] = REG_SYS_CLKR, | ||||
| 	.maps[MAC_RCR_AM] = AM, | ||||
| 	.maps[MAC_RCR_AB] = AB, | ||||
| 	.maps[MAC_RCR_ACRC32] = ACRC32, | ||||
| 	.maps[MAC_RCR_ACF] = ACF, | ||||
| 	.maps[MAC_RCR_AAP] = AAP, | ||||
| 	.maps[MAC_HIMR] = REG_HIMR, | ||||
| 	.maps[MAC_HIMRE] = REG_HIMRE, | ||||
| 	.maps[EFUSE_TEST] = REG_EFUSE_TEST, | ||||
| 	.maps[EFUSE_CTRL] = REG_EFUSE_CTRL, | ||||
| 	.maps[EFUSE_CLK] = 0, | ||||
| 	.maps[EFUSE_CLK_CTRL] = REG_EFUSE_CTRL, | ||||
| 	.maps[EFUSE_PWC_EV12V] = PWC_EV12V, | ||||
| 	.maps[EFUSE_FEN_ELDR] = FEN_ELDR, | ||||
| 	.maps[EFUSE_LOADER_CLK_EN] = LOADER_CLK_EN, | ||||
| 	.maps[EFUSE_ANA8M] = ANA8M, | ||||
| 	.maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE, | ||||
| 	.maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION, | ||||
| 	.maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN, | ||||
| 	.maps[EFUSE_OOB_PROTECT_BYTES_LEN] = EFUSE_OOB_PROTECT_BYTES, | ||||
| 
 | ||||
| 	.maps[RWCAM] = REG_CAMCMD, | ||||
| 	.maps[WCAMI] = REG_CAMWRITE, | ||||
| 	.maps[RCAMO] = REG_CAMREAD, | ||||
| 	.maps[CAMDBG] = REG_CAMDBG, | ||||
| 	.maps[SECR] = REG_SECCFG, | ||||
| 	.maps[SEC_CAM_NONE] = CAM_NONE, | ||||
| 	.maps[SEC_CAM_WEP40] = CAM_WEP40, | ||||
| 	.maps[SEC_CAM_TKIP] = CAM_TKIP, | ||||
| 	.maps[SEC_CAM_AES] = CAM_AES, | ||||
| 	.maps[SEC_CAM_WEP104] = CAM_WEP104, | ||||
| 
 | ||||
| 	.maps[RTL_IMR_BCNDMAINT6] = IMR_BCNDMAINT6, | ||||
| 	.maps[RTL_IMR_BCNDMAINT5] = IMR_BCNDMAINT5, | ||||
| 	.maps[RTL_IMR_BCNDMAINT4] = IMR_BCNDMAINT4, | ||||
| 	.maps[RTL_IMR_BCNDMAINT3] = IMR_BCNDMAINT3, | ||||
| 	.maps[RTL_IMR_BCNDMAINT2] = IMR_BCNDMAINT2, | ||||
| 	.maps[RTL_IMR_BCNDMAINT1] = IMR_BCNDMAINT1, | ||||
| 	.maps[RTL_IMR_BCNDOK8] = IMR_BCNDOK8, | ||||
| 	.maps[RTL_IMR_BCNDOK7] = IMR_BCNDOK7, | ||||
| 	.maps[RTL_IMR_BCNDOK6] = IMR_BCNDOK6, | ||||
| 	.maps[RTL_IMR_BCNDOK5] = IMR_BCNDOK5, | ||||
| 	.maps[RTL_IMR_BCNDOK4] = IMR_BCNDOK4, | ||||
| 	.maps[RTL_IMR_BCNDOK3] = IMR_BCNDOK3, | ||||
| 	.maps[RTL_IMR_BCNDOK2] = IMR_BCNDOK2, | ||||
| 	.maps[RTL_IMR_BCNDOK1] = IMR_BCNDOK1, | ||||
| 	.maps[RTL_IMR_TIMEOUT2] = IMR_TIMEOUT2, | ||||
| 	.maps[RTL_IMR_TIMEOUT1] = IMR_TIMEOUT1, | ||||
| 
 | ||||
| 	.maps[RTL_IMR_TXFOVW] = PHIMR_TXFOVW, | ||||
| 	.maps[RTL_IMR_PSTIMEOUT] = PHIMR_PSTIMEOUT, | ||||
| 	.maps[RTL_IMR_BCNINT] = PHIMR_BCNDMAINT0, | ||||
| 	.maps[RTL_IMR_RXFOVW] = PHIMR_RXFOVW, | ||||
| 	.maps[RTL_IMR_RDU] = PHIMR_RDU, | ||||
| 	.maps[RTL_IMR_ATIMEND] = PHIMR_ATIMEND_E, | ||||
| 	.maps[RTL_IMR_BDOK] = PHIMR_BCNDOK0, | ||||
| 	.maps[RTL_IMR_MGNTDOK] = PHIMR_MGNTDOK, | ||||
| 	.maps[RTL_IMR_TBDER] = PHIMR_TXBCNERR, | ||||
| 	.maps[RTL_IMR_HIGHDOK] = PHIMR_HIGHDOK, | ||||
| 	.maps[RTL_IMR_TBDOK] = PHIMR_TXBCNOK, | ||||
| 	.maps[RTL_IMR_BKDOK] = PHIMR_BKDOK, | ||||
| 	.maps[RTL_IMR_BEDOK] = PHIMR_BEDOK, | ||||
| 	.maps[RTL_IMR_VIDOK] = PHIMR_VIDOK, | ||||
| 	.maps[RTL_IMR_VODOK] = PHIMR_VODOK, | ||||
| 	.maps[RTL_IMR_ROK] = PHIMR_ROK, | ||||
| 	.maps[RTL_IBSS_INT_MASKS] = | ||||
| 		(PHIMR_BCNDMAINT0 | PHIMR_TXBCNOK | PHIMR_TXBCNERR), | ||||
| 	.maps[RTL_IMR_C2HCMD] = PHIMR_C2HCMD, | ||||
| 
 | ||||
| 
 | ||||
| 	.maps[RTL_RC_CCK_RATE1M] = DESC92C_RATE1M, | ||||
| 	.maps[RTL_RC_CCK_RATE2M] = DESC92C_RATE2M, | ||||
| 	.maps[RTL_RC_CCK_RATE5_5M] = DESC92C_RATE5_5M, | ||||
| 	.maps[RTL_RC_CCK_RATE11M] = DESC92C_RATE11M, | ||||
| 	.maps[RTL_RC_OFDM_RATE6M] = DESC92C_RATE6M, | ||||
| 	.maps[RTL_RC_OFDM_RATE9M] = DESC92C_RATE9M, | ||||
| 	.maps[RTL_RC_OFDM_RATE12M] = DESC92C_RATE12M, | ||||
| 	.maps[RTL_RC_OFDM_RATE18M] = DESC92C_RATE18M, | ||||
| 	.maps[RTL_RC_OFDM_RATE24M] = DESC92C_RATE24M, | ||||
| 	.maps[RTL_RC_OFDM_RATE36M] = DESC92C_RATE36M, | ||||
| 	.maps[RTL_RC_OFDM_RATE48M] = DESC92C_RATE48M, | ||||
| 	.maps[RTL_RC_OFDM_RATE54M] = DESC92C_RATE54M, | ||||
| 
 | ||||
| 	.maps[RTL_RC_HT_RATEMCS7] = DESC92C_RATEMCS7, | ||||
| 	.maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15, | ||||
| }; | ||||
| 
 | ||||
| static struct pci_device_id rtl8723e_pci_ids[] = { | ||||
| 	{RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8723, rtl8723e_hal_cfg)}, | ||||
| 	{}, | ||||
| }; | ||||
| 
 | ||||
| MODULE_DEVICE_TABLE(pci, rtl8723e_pci_ids); | ||||
| 
 | ||||
| MODULE_AUTHOR("lizhaoming	<chaoming_li@realsil.com.cn>"); | ||||
| MODULE_AUTHOR("Realtek WlanFAE	<wlanfae@realtek.com>"); | ||||
| MODULE_LICENSE("GPL"); | ||||
| MODULE_DESCRIPTION("Realtek 8723E 802.11n PCI wireless"); | ||||
| MODULE_FIRMWARE("rtlwifi/rtl8723efw.bin"); | ||||
| 
 | ||||
| module_param_named(swenc, rtl8723e_mod_params.sw_crypto, bool, 0444); | ||||
| module_param_named(debug, rtl8723e_mod_params.debug, int, 0444); | ||||
| module_param_named(ips, rtl8723e_mod_params.inactiveps, bool, 0444); | ||||
| module_param_named(swlps, rtl8723e_mod_params.swctrl_lps, bool, 0444); | ||||
| module_param_named(fwlps, rtl8723e_mod_params.fwctrl_lps, bool, 0444); | ||||
| module_param_named(disable_watchdog, rtl8723e_mod_params.disable_watchdog, | ||||
| 		   bool, 0444); | ||||
| MODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n"); | ||||
| MODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n"); | ||||
| MODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n"); | ||||
| MODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n"); | ||||
| MODULE_PARM_DESC(debug, "Set debug level (0-5) (default 0)"); | ||||
| MODULE_PARM_DESC(disable_watchdog, "Set to 1 to disable the watchdog (default 0)\n"); | ||||
| 
 | ||||
| static SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume); | ||||
| 
 | ||||
| static struct pci_driver rtl8723e_driver = { | ||||
| 	.name = KBUILD_MODNAME, | ||||
| 	.id_table = rtl8723e_pci_ids, | ||||
| 	.probe = rtl_pci_probe, | ||||
| 	.remove = rtl_pci_disconnect, | ||||
| 	.driver.pm = &rtlwifi_pm_ops, | ||||
| }; | ||||
| 
 | ||||
| module_pci_driver(rtl8723e_driver); | ||||
							
								
								
									
										35
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/sw.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/sw.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_SW_H__ | ||||
| #define __RTL8723E_SW_H__ | ||||
| 
 | ||||
| int rtl8723e_init_sw_vars(struct ieee80211_hw *hw); | ||||
| void rtl8723e_deinit_sw_vars(struct ieee80211_hw *hw); | ||||
| void rtl8723e_init_var_map(struct ieee80211_hw *hw); | ||||
| bool rtl8723e_get_btc_status(void); | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										732
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/table.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										732
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/table.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,732 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Created on  2010/ 5/18,  1:41 | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "table.h" | ||||
| 
 | ||||
| u32 RTL8723EPHY_REG_1TARRAY[RTL8723E_PHY_REG_1TARRAY_LENGTH] = { | ||||
| 	0x800, 0x80040000, | ||||
| 	0x804, 0x00000003, | ||||
| 	0x808, 0x0000fc00, | ||||
| 	0x80c, 0x0000000a, | ||||
| 	0x810, 0x10005388, | ||||
| 	0x814, 0x020c3d10, | ||||
| 	0x818, 0x02200385, | ||||
| 	0x81c, 0x00000000, | ||||
| 	0x820, 0x01000100, | ||||
| 	0x824, 0x00390004, | ||||
| 	0x828, 0x00000000, | ||||
| 	0x82c, 0x00000000, | ||||
| 	0x830, 0x00000000, | ||||
| 	0x834, 0x00000000, | ||||
| 	0x838, 0x00000000, | ||||
| 	0x83c, 0x00000000, | ||||
| 	0x840, 0x00010000, | ||||
| 	0x844, 0x00000000, | ||||
| 	0x848, 0x00000000, | ||||
| 	0x84c, 0x00000000, | ||||
| 	0x850, 0x00000000, | ||||
| 	0x854, 0x00000000, | ||||
| 	0x858, 0x569a569a, | ||||
| 	0x85c, 0x001b25a4, | ||||
| 	0x860, 0x66f60110, | ||||
| 	0x864, 0x061f0130, | ||||
| 	0x868, 0x00000000, | ||||
| 	0x86c, 0x32323200, | ||||
| 	0x870, 0x07000760, | ||||
| 	0x874, 0x22004000, | ||||
| 	0x878, 0x00000808, | ||||
| 	0x87c, 0x00000000, | ||||
| 	0x880, 0xc0083070, | ||||
| 	0x884, 0x000004d5, | ||||
| 	0x888, 0x00000000, | ||||
| 	0x88c, 0xccc000c0, | ||||
| 	0x890, 0x00000800, | ||||
| 	0x894, 0xfffffffe, | ||||
| 	0x898, 0x40302010, | ||||
| 	0x89c, 0x00706050, | ||||
| 	0x900, 0x00000000, | ||||
| 	0x904, 0x00000023, | ||||
| 	0x908, 0x00000000, | ||||
| 	0x90c, 0x81121111, | ||||
| 	0xa00, 0x00d047c8, | ||||
| 	0xa04, 0x80ff000c, | ||||
| 	0xa08, 0x8c838300, | ||||
| 	0xa0c, 0x2e68120f, | ||||
| 	0xa10, 0x9500bb78, | ||||
| 	0xa14, 0x11144028, | ||||
| 	0xa18, 0x00881117, | ||||
| 	0xa1c, 0x89140f00, | ||||
| 	0xa20, 0x1a1b0000, | ||||
| 	0xa24, 0x090e1317, | ||||
| 	0xa28, 0x00000204, | ||||
| 	0xa2c, 0x00d30000, | ||||
| 	0xa70, 0x101fbf00, | ||||
| 	0xa74, 0x00000007, | ||||
| 	0xa78, 0x00000900, | ||||
| 	0xc00, 0x48071d40, | ||||
| 	0xc04, 0x03a05611, | ||||
| 	0xc08, 0x000000e4, | ||||
| 	0xc0c, 0x6c6c6c6c, | ||||
| 	0xc10, 0x08800000, | ||||
| 	0xc14, 0x40000100, | ||||
| 	0xc18, 0x08800000, | ||||
| 	0xc1c, 0x40000100, | ||||
| 	0xc20, 0x00000000, | ||||
| 	0xc24, 0x00000000, | ||||
| 	0xc28, 0x00000000, | ||||
| 	0xc2c, 0x00000000, | ||||
| 	0xc30, 0x69e9ac44, | ||||
| 	0xc34, 0x469652cf, | ||||
| 	0xc38, 0x49795994, | ||||
| 	0xc3c, 0x0a97971c, | ||||
| 	0xc40, 0x1f7c403f, | ||||
| 	0xc44, 0x000100b7, | ||||
| 	0xc48, 0xec020107, | ||||
| 	0xc4c, 0x007f037f, | ||||
| 	0xc50, 0x69543420, | ||||
| 	0xc54, 0x43bc0094, | ||||
| 	0xc58, 0x69543420, | ||||
| 	0xc5c, 0x433c0094, | ||||
| 	0xc60, 0x00000000, | ||||
| 	0xc64, 0x7116848b, | ||||
| 	0xc68, 0x47c00bff, | ||||
| 	0xc6c, 0x00000036, | ||||
| 	0xc70, 0x2c7f000d, | ||||
| 	0xc74, 0x018610db, | ||||
| 	0xc78, 0x0000001f, | ||||
| 	0xc7c, 0x00b91612, | ||||
| 	0xc80, 0x40000100, | ||||
| 	0xc84, 0x20f60000, | ||||
| 	0xc88, 0x40000100, | ||||
| 	0xc8c, 0x20200000, | ||||
| 	0xc90, 0x00121820, | ||||
| 	0xc94, 0x00000000, | ||||
| 	0xc98, 0x00121820, | ||||
| 	0xc9c, 0x00007f7f, | ||||
| 	0xca0, 0x00000000, | ||||
| 	0xca4, 0x00000080, | ||||
| 	0xca8, 0x00000000, | ||||
| 	0xcac, 0x00000000, | ||||
| 	0xcb0, 0x00000000, | ||||
| 	0xcb4, 0x00000000, | ||||
| 	0xcb8, 0x00000000, | ||||
| 	0xcbc, 0x28000000, | ||||
| 	0xcc0, 0x00000000, | ||||
| 	0xcc4, 0x00000000, | ||||
| 	0xcc8, 0x00000000, | ||||
| 	0xccc, 0x00000000, | ||||
| 	0xcd0, 0x00000000, | ||||
| 	0xcd4, 0x00000000, | ||||
| 	0xcd8, 0x64b22427, | ||||
| 	0xcdc, 0x00766932, | ||||
| 	0xce0, 0x00222222, | ||||
| 	0xce4, 0x00000000, | ||||
| 	0xce8, 0x37644302, | ||||
| 	0xcec, 0x2f97d40c, | ||||
| 	0xd00, 0x00080740, | ||||
| 	0xd04, 0x00020401, | ||||
| 	0xd08, 0x0000907f, | ||||
| 	0xd0c, 0x20010201, | ||||
| 	0xd10, 0xa0633333, | ||||
| 	0xd14, 0x3333bc43, | ||||
| 	0xd18, 0x7a8f5b6b, | ||||
| 	0xd2c, 0xcc979975, | ||||
| 	0xd30, 0x00000000, | ||||
| 	0xd34, 0x80608000, | ||||
| 	0xd38, 0x00000000, | ||||
| 	0xd3c, 0x00027293, | ||||
| 	0xd40, 0x00000000, | ||||
| 	0xd44, 0x00000000, | ||||
| 	0xd48, 0x00000000, | ||||
| 	0xd4c, 0x00000000, | ||||
| 	0xd50, 0x6437140a, | ||||
| 	0xd54, 0x00000000, | ||||
| 	0xd58, 0x00000000, | ||||
| 	0xd5c, 0x30032064, | ||||
| 	0xd60, 0x4653de68, | ||||
| 	0xd64, 0x04518a3c, | ||||
| 	0xd68, 0x00002101, | ||||
| 	0xd6c, 0x2a201c16, | ||||
| 	0xd70, 0x1812362e, | ||||
| 	0xd74, 0x322c2220, | ||||
| 	0xd78, 0x000e3c24, | ||||
| 	0xe00, 0x2a2a2a2a, | ||||
| 	0xe04, 0x2a2a2a2a, | ||||
| 	0xe08, 0x03902a2a, | ||||
| 	0xe10, 0x2a2a2a2a, | ||||
| 	0xe14, 0x2a2a2a2a, | ||||
| 	0xe18, 0x2a2a2a2a, | ||||
| 	0xe1c, 0x2a2a2a2a, | ||||
| 	0xe28, 0x00000000, | ||||
| 	0xe30, 0x1000dc1f, | ||||
| 	0xe34, 0x10008c1f, | ||||
| 	0xe38, 0x02140102, | ||||
| 	0xe3c, 0x681604c2, | ||||
| 	0xe40, 0x01007c00, | ||||
| 	0xe44, 0x01004800, | ||||
| 	0xe48, 0xfb000000, | ||||
| 	0xe4c, 0x000028d1, | ||||
| 	0xe50, 0x1000dc1f, | ||||
| 	0xe54, 0x10008c1f, | ||||
| 	0xe58, 0x02140102, | ||||
| 	0xe5c, 0x28160d05, | ||||
| 	0xe60, 0x00000008, | ||||
| 	0xe68, 0x001b25a4, | ||||
| 	0xe6c, 0x631b25a0, | ||||
| 	0xe70, 0x631b25a0, | ||||
| 	0xe74, 0x081b25a0, | ||||
| 	0xe78, 0x081b25a0, | ||||
| 	0xe7c, 0x081b25a0, | ||||
| 	0xe80, 0x081b25a0, | ||||
| 	0xe84, 0x631b25a0, | ||||
| 	0xe88, 0x081b25a0, | ||||
| 	0xe8c, 0x631b25a0, | ||||
| 	0xed0, 0x631b25a0, | ||||
| 	0xed4, 0x631b25a0, | ||||
| 	0xed8, 0x631b25a0, | ||||
| 	0xedc, 0x001b25a0, | ||||
| 	0xee0, 0x001b25a0, | ||||
| 	0xeec, 0x6b1b25a0, | ||||
| 	0xf14, 0x00000003, | ||||
| 	0xf4c, 0x00000000, | ||||
| 	0xf00, 0x00000300, | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723EPHY_REG_ARRAY_PG[RTL8723E_PHY_REG_ARRAY_PGLENGTH] = { | ||||
| 	0xe00, 0xffffffff, 0x0a0c0c0c, | ||||
| 	0xe04, 0xffffffff, 0x02040608, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x0a0c0d0e, | ||||
| 	0xe14, 0xffffffff, 0x02040608, | ||||
| 	0xe18, 0xffffffff, 0x0a0c0d0e, | ||||
| 	0xe1c, 0xffffffff, 0x02040608, | ||||
| 	0x830, 0xffffffff, 0x0a0c0c0c, | ||||
| 	0x834, 0xffffffff, 0x02040608, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x0a0c0d0e, | ||||
| 	0x848, 0xffffffff, 0x02040608, | ||||
| 	0x84c, 0xffffffff, 0x0a0c0d0e, | ||||
| 	0x868, 0xffffffff, 0x02040608, | ||||
| 	0xe00, 0xffffffff, 0x00000000, | ||||
| 	0xe04, 0xffffffff, 0x00000000, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x00000000, | ||||
| 	0xe14, 0xffffffff, 0x00000000, | ||||
| 	0xe18, 0xffffffff, 0x00000000, | ||||
| 	0xe1c, 0xffffffff, 0x00000000, | ||||
| 	0x830, 0xffffffff, 0x00000000, | ||||
| 	0x834, 0xffffffff, 0x00000000, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x00000000, | ||||
| 	0x848, 0xffffffff, 0x00000000, | ||||
| 	0x84c, 0xffffffff, 0x00000000, | ||||
| 	0x868, 0xffffffff, 0x00000000, | ||||
| 	0xe00, 0xffffffff, 0x04040404, | ||||
| 	0xe04, 0xffffffff, 0x00020204, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x06060606, | ||||
| 	0xe14, 0xffffffff, 0x00020406, | ||||
| 	0xe18, 0xffffffff, 0x00000000, | ||||
| 	0xe1c, 0xffffffff, 0x00000000, | ||||
| 	0x830, 0xffffffff, 0x04040404, | ||||
| 	0x834, 0xffffffff, 0x00020204, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x06060606, | ||||
| 	0x848, 0xffffffff, 0x00020406, | ||||
| 	0x84c, 0xffffffff, 0x00000000, | ||||
| 	0x868, 0xffffffff, 0x00000000, | ||||
| 	0xe00, 0xffffffff, 0x00000000, | ||||
| 	0xe04, 0xffffffff, 0x00000000, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x00000000, | ||||
| 	0xe14, 0xffffffff, 0x00000000, | ||||
| 	0xe18, 0xffffffff, 0x00000000, | ||||
| 	0xe1c, 0xffffffff, 0x00000000, | ||||
| 	0x830, 0xffffffff, 0x00000000, | ||||
| 	0x834, 0xffffffff, 0x00000000, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x00000000, | ||||
| 	0x848, 0xffffffff, 0x00000000, | ||||
| 	0x84c, 0xffffffff, 0x00000000, | ||||
| 	0x868, 0xffffffff, 0x00000000, | ||||
| 	0xe00, 0xffffffff, 0x00000000, | ||||
| 	0xe04, 0xffffffff, 0x00000000, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x00000000, | ||||
| 	0xe14, 0xffffffff, 0x00000000, | ||||
| 	0xe18, 0xffffffff, 0x00000000, | ||||
| 	0xe1c, 0xffffffff, 0x00000000, | ||||
| 	0x830, 0xffffffff, 0x00000000, | ||||
| 	0x834, 0xffffffff, 0x00000000, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x00000000, | ||||
| 	0x848, 0xffffffff, 0x00000000, | ||||
| 	0x84c, 0xffffffff, 0x00000000, | ||||
| 	0x868, 0xffffffff, 0x00000000, | ||||
| 	0xe00, 0xffffffff, 0x04040404, | ||||
| 	0xe04, 0xffffffff, 0x00020204, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x00000000, | ||||
| 	0xe14, 0xffffffff, 0x00000000, | ||||
| 	0xe18, 0xffffffff, 0x00000000, | ||||
| 	0xe1c, 0xffffffff, 0x00000000, | ||||
| 	0x830, 0xffffffff, 0x04040404, | ||||
| 	0x834, 0xffffffff, 0x00020204, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x00000000, | ||||
| 	0x848, 0xffffffff, 0x00000000, | ||||
| 	0x84c, 0xffffffff, 0x00000000, | ||||
| 	0x868, 0xffffffff, 0x00000000, | ||||
| 	0xe00, 0xffffffff, 0x00000000, | ||||
| 	0xe04, 0xffffffff, 0x00000000, | ||||
| 	0xe08, 0x0000ff00, 0x00000000, | ||||
| 	0x86c, 0xffffff00, 0x00000000, | ||||
| 	0xe10, 0xffffffff, 0x00000000, | ||||
| 	0xe14, 0xffffffff, 0x00000000, | ||||
| 	0xe18, 0xffffffff, 0x00000000, | ||||
| 	0xe1c, 0xffffffff, 0x00000000, | ||||
| 	0x830, 0xffffffff, 0x00000000, | ||||
| 	0x834, 0xffffffff, 0x00000000, | ||||
| 	0x838, 0xffffff00, 0x00000000, | ||||
| 	0x86c, 0x000000ff, 0x00000000, | ||||
| 	0x83c, 0xffffffff, 0x00000000, | ||||
| 	0x848, 0xffffffff, 0x00000000, | ||||
| 	0x84c, 0xffffffff, 0x00000000, | ||||
| 	0x868, 0xffffffff, 0x00000000, | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723E_RADIOA_1TARRAY[RTL8723ERADIOA_1TARRAYLENGTH] = { | ||||
| 	0x000, 0x00030159, | ||||
| 	0x001, 0x00031284, | ||||
| 	0x002, 0x00098000, | ||||
| 	0x003, 0x00018c63, | ||||
| 	0x004, 0x000210e7, | ||||
| 	0x009, 0x0002044f, | ||||
| 	0x00a, 0x0001a3f1, | ||||
| 	0x00b, 0x00014787, | ||||
| 	0x00c, 0x000896fe, | ||||
| 	0x00d, 0x0000e02c, | ||||
| 	0x00e, 0x00039ce7, | ||||
| 	0x00f, 0x00000451, | ||||
| 	0x019, 0x00000000, | ||||
| 	0x01a, 0x00030355, | ||||
| 	0x01b, 0x00060a00, | ||||
| 	0x01c, 0x000fc378, | ||||
| 	0x01d, 0x000a1250, | ||||
| 	0x01e, 0x0004445f, | ||||
| 	0x01f, 0x00080001, | ||||
| 	0x020, 0x0000b614, | ||||
| 	0x021, 0x0006c000, | ||||
| 	0x022, 0x00000000, | ||||
| 	0x023, 0x00001558, | ||||
| 	0x024, 0x00000060, | ||||
| 	0x025, 0x00000483, | ||||
| 	0x026, 0x0004f000, | ||||
| 	0x027, 0x000ec7d9, | ||||
| 	0x028, 0x00057730, | ||||
| 	0x029, 0x00004783, | ||||
| 	0x02a, 0x00000001, | ||||
| 	0x02b, 0x00021334, | ||||
| 	0x02a, 0x00000000, | ||||
| 	0x02b, 0x00000054, | ||||
| 	0x02a, 0x00000001, | ||||
| 	0x02b, 0x00000808, | ||||
| 	0x02b, 0x00053333, | ||||
| 	0x02c, 0x0000000c, | ||||
| 	0x02a, 0x00000002, | ||||
| 	0x02b, 0x00000808, | ||||
| 	0x02b, 0x0005b333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000003, | ||||
| 	0x02b, 0x00000808, | ||||
| 	0x02b, 0x00063333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000004, | ||||
| 	0x02b, 0x00000808, | ||||
| 	0x02b, 0x0006b333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000005, | ||||
| 	0x02b, 0x00000808, | ||||
| 	0x02b, 0x00073333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000006, | ||||
| 	0x02b, 0x00000709, | ||||
| 	0x02b, 0x0005b333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000007, | ||||
| 	0x02b, 0x00000709, | ||||
| 	0x02b, 0x00063333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000008, | ||||
| 	0x02b, 0x0000060a, | ||||
| 	0x02b, 0x0004b333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x00000009, | ||||
| 	0x02b, 0x0000060a, | ||||
| 	0x02b, 0x00053333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x0000000a, | ||||
| 	0x02b, 0x0000060a, | ||||
| 	0x02b, 0x0005b333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x0000000b, | ||||
| 	0x02b, 0x0000060a, | ||||
| 	0x02b, 0x00063333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x0000000c, | ||||
| 	0x02b, 0x0000060a, | ||||
| 	0x02b, 0x0006b333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x0000000d, | ||||
| 	0x02b, 0x0000060a, | ||||
| 	0x02b, 0x00073333, | ||||
| 	0x02c, 0x0000000d, | ||||
| 	0x02a, 0x0000000e, | ||||
| 	0x02b, 0x0000050b, | ||||
| 	0x02b, 0x00066666, | ||||
| 	0x02c, 0x0000001a, | ||||
| 	0x02a, 0x000e0000, | ||||
| 	0x010, 0x0004000f, | ||||
| 	0x011, 0x000e31fc, | ||||
| 	0x010, 0x0006000f, | ||||
| 	0x011, 0x000ff9f8, | ||||
| 	0x010, 0x0002000f, | ||||
| 	0x011, 0x000203f9, | ||||
| 	0x010, 0x0003000f, | ||||
| 	0x011, 0x000ff500, | ||||
| 	0x010, 0x00000000, | ||||
| 	0x011, 0x00000000, | ||||
| 	0x010, 0x0008000f, | ||||
| 	0x011, 0x0003f100, | ||||
| 	0x010, 0x0009000f, | ||||
| 	0x011, 0x00023100, | ||||
| 	0x012, 0x00032000, | ||||
| 	0x012, 0x00071000, | ||||
| 	0x012, 0x000b0000, | ||||
| 	0x012, 0x000fc000, | ||||
| 	0x013, 0x000287b3, | ||||
| 	0x013, 0x000244b7, | ||||
| 	0x013, 0x000204ab, | ||||
| 	0x013, 0x0001c49f, | ||||
| 	0x013, 0x00018493, | ||||
| 	0x013, 0x0001429b, | ||||
| 	0x013, 0x00010299, | ||||
| 	0x013, 0x0000c29c, | ||||
| 	0x013, 0x000081a0, | ||||
| 	0x013, 0x000040ac, | ||||
| 	0x013, 0x00000020, | ||||
| 	0x014, 0x0001944c, | ||||
| 	0x014, 0x00059444, | ||||
| 	0x014, 0x0009944c, | ||||
| 	0x014, 0x000d9444, | ||||
| 	0x015, 0x0000f424, | ||||
| 	0x015, 0x0004f407, | ||||
| 	0x015, 0x0008f424, | ||||
| 	0x015, 0x000cf424, | ||||
| 	0x016, 0x00000339, | ||||
| 	0x016, 0x00040339, | ||||
| 	0x016, 0x00080339, | ||||
| 	0x016, 0x000c0336, | ||||
| 	0x000, 0x00010159, | ||||
| 	0x018, 0x0000f401, | ||||
| 	0x0fe, 0x00000000, | ||||
| 	0x0fe, 0x00000000, | ||||
| 	0x01f, 0x00080003, | ||||
| 	0x0fe, 0x00000000, | ||||
| 	0x0fe, 0x00000000, | ||||
| 	0x01e, 0x00044457, | ||||
| 	0x01f, 0x00080000, | ||||
| 	0x000, 0x00030159, | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723E_RADIOB_1TARRAY[RTL8723E_RADIOB_1TARRAYLENGTH] = { | ||||
| 	0x0, | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723EMAC_ARRAY[RTL8723E_MACARRAYLENGTH] = { | ||||
| 	0x420, 0x00000080, | ||||
| 	0x423, 0x00000000, | ||||
| 	0x430, 0x00000000, | ||||
| 	0x431, 0x00000000, | ||||
| 	0x432, 0x00000000, | ||||
| 	0x433, 0x00000001, | ||||
| 	0x434, 0x00000004, | ||||
| 	0x435, 0x00000005, | ||||
| 	0x436, 0x00000006, | ||||
| 	0x437, 0x00000007, | ||||
| 	0x438, 0x00000000, | ||||
| 	0x439, 0x00000000, | ||||
| 	0x43a, 0x00000000, | ||||
| 	0x43b, 0x00000001, | ||||
| 	0x43c, 0x00000004, | ||||
| 	0x43d, 0x00000005, | ||||
| 	0x43e, 0x00000006, | ||||
| 	0x43f, 0x00000007, | ||||
| 	0x440, 0x0000005d, | ||||
| 	0x441, 0x00000001, | ||||
| 	0x442, 0x00000000, | ||||
| 	0x444, 0x00000015, | ||||
| 	0x445, 0x000000f0, | ||||
| 	0x446, 0x0000000f, | ||||
| 	0x447, 0x00000000, | ||||
| 	0x458, 0x00000041, | ||||
| 	0x459, 0x000000a8, | ||||
| 	0x45a, 0x00000072, | ||||
| 	0x45b, 0x000000b9, | ||||
| 	0x460, 0x00000066, | ||||
| 	0x461, 0x00000066, | ||||
| 	0x462, 0x00000008, | ||||
| 	0x463, 0x00000003, | ||||
| 	0x4c8, 0x000000ff, | ||||
| 	0x4c9, 0x00000008, | ||||
| 	0x4cc, 0x000000ff, | ||||
| 	0x4cd, 0x000000ff, | ||||
| 	0x4ce, 0x00000001, | ||||
| 	0x500, 0x00000026, | ||||
| 	0x501, 0x000000a2, | ||||
| 	0x502, 0x0000002f, | ||||
| 	0x503, 0x00000000, | ||||
| 	0x504, 0x00000028, | ||||
| 	0x505, 0x000000a3, | ||||
| 	0x506, 0x0000005e, | ||||
| 	0x507, 0x00000000, | ||||
| 	0x508, 0x0000002b, | ||||
| 	0x509, 0x000000a4, | ||||
| 	0x50a, 0x0000005e, | ||||
| 	0x50b, 0x00000000, | ||||
| 	0x50c, 0x0000004f, | ||||
| 	0x50d, 0x000000a4, | ||||
| 	0x50e, 0x00000000, | ||||
| 	0x50f, 0x00000000, | ||||
| 	0x512, 0x0000001c, | ||||
| 	0x514, 0x0000000a, | ||||
| 	0x515, 0x00000010, | ||||
| 	0x516, 0x0000000a, | ||||
| 	0x517, 0x00000010, | ||||
| 	0x51a, 0x00000016, | ||||
| 	0x524, 0x0000000f, | ||||
| 	0x525, 0x0000004f, | ||||
| 	0x546, 0x00000040, | ||||
| 	0x547, 0x00000000, | ||||
| 	0x550, 0x00000010, | ||||
| 	0x551, 0x00000010, | ||||
| 	0x559, 0x00000002, | ||||
| 	0x55a, 0x00000002, | ||||
| 	0x55d, 0x000000ff, | ||||
| 	0x605, 0x00000030, | ||||
| 	0x608, 0x0000000e, | ||||
| 	0x609, 0x0000002a, | ||||
| 	0x652, 0x00000020, | ||||
| 	0x63c, 0x0000000a, | ||||
| 	0x63d, 0x0000000e, | ||||
| 	0x63e, 0x0000000a, | ||||
| 	0x63f, 0x0000000e, | ||||
| 	0x66e, 0x00000005, | ||||
| 	0x700, 0x00000021, | ||||
| 	0x701, 0x00000043, | ||||
| 	0x702, 0x00000065, | ||||
| 	0x703, 0x00000087, | ||||
| 	0x708, 0x00000021, | ||||
| 	0x709, 0x00000043, | ||||
| 	0x70a, 0x00000065, | ||||
| 	0x70b, 0x00000087, | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723EAGCTAB_1TARRAY[RTL8723E_AGCTAB_1TARRAYLENGTH] = { | ||||
| 	0xc78, 0x7b000001, | ||||
| 	0xc78, 0x7b010001, | ||||
| 	0xc78, 0x7b020001, | ||||
| 	0xc78, 0x7b030001, | ||||
| 	0xc78, 0x7b040001, | ||||
| 	0xc78, 0x7b050001, | ||||
| 	0xc78, 0x7a060001, | ||||
| 	0xc78, 0x79070001, | ||||
| 	0xc78, 0x78080001, | ||||
| 	0xc78, 0x77090001, | ||||
| 	0xc78, 0x760a0001, | ||||
| 	0xc78, 0x750b0001, | ||||
| 	0xc78, 0x740c0001, | ||||
| 	0xc78, 0x730d0001, | ||||
| 	0xc78, 0x720e0001, | ||||
| 	0xc78, 0x710f0001, | ||||
| 	0xc78, 0x70100001, | ||||
| 	0xc78, 0x6f110001, | ||||
| 	0xc78, 0x6e120001, | ||||
| 	0xc78, 0x6d130001, | ||||
| 	0xc78, 0x6c140001, | ||||
| 	0xc78, 0x6b150001, | ||||
| 	0xc78, 0x6a160001, | ||||
| 	0xc78, 0x69170001, | ||||
| 	0xc78, 0x68180001, | ||||
| 	0xc78, 0x67190001, | ||||
| 	0xc78, 0x661a0001, | ||||
| 	0xc78, 0x651b0001, | ||||
| 	0xc78, 0x641c0001, | ||||
| 	0xc78, 0x631d0001, | ||||
| 	0xc78, 0x621e0001, | ||||
| 	0xc78, 0x611f0001, | ||||
| 	0xc78, 0x60200001, | ||||
| 	0xc78, 0x49210001, | ||||
| 	0xc78, 0x48220001, | ||||
| 	0xc78, 0x47230001, | ||||
| 	0xc78, 0x46240001, | ||||
| 	0xc78, 0x45250001, | ||||
| 	0xc78, 0x44260001, | ||||
| 	0xc78, 0x43270001, | ||||
| 	0xc78, 0x42280001, | ||||
| 	0xc78, 0x41290001, | ||||
| 	0xc78, 0x402a0001, | ||||
| 	0xc78, 0x262b0001, | ||||
| 	0xc78, 0x252c0001, | ||||
| 	0xc78, 0x242d0001, | ||||
| 	0xc78, 0x232e0001, | ||||
| 	0xc78, 0x222f0001, | ||||
| 	0xc78, 0x21300001, | ||||
| 	0xc78, 0x20310001, | ||||
| 	0xc78, 0x06320001, | ||||
| 	0xc78, 0x05330001, | ||||
| 	0xc78, 0x04340001, | ||||
| 	0xc78, 0x03350001, | ||||
| 	0xc78, 0x02360001, | ||||
| 	0xc78, 0x01370001, | ||||
| 	0xc78, 0x00380001, | ||||
| 	0xc78, 0x00390001, | ||||
| 	0xc78, 0x003a0001, | ||||
| 	0xc78, 0x003b0001, | ||||
| 	0xc78, 0x003c0001, | ||||
| 	0xc78, 0x003d0001, | ||||
| 	0xc78, 0x003e0001, | ||||
| 	0xc78, 0x003f0001, | ||||
| 	0xc78, 0x7b400001, | ||||
| 	0xc78, 0x7b410001, | ||||
| 	0xc78, 0x7b420001, | ||||
| 	0xc78, 0x7b430001, | ||||
| 	0xc78, 0x7b440001, | ||||
| 	0xc78, 0x7b450001, | ||||
| 	0xc78, 0x7a460001, | ||||
| 	0xc78, 0x79470001, | ||||
| 	0xc78, 0x78480001, | ||||
| 	0xc78, 0x77490001, | ||||
| 	0xc78, 0x764a0001, | ||||
| 	0xc78, 0x754b0001, | ||||
| 	0xc78, 0x744c0001, | ||||
| 	0xc78, 0x734d0001, | ||||
| 	0xc78, 0x724e0001, | ||||
| 	0xc78, 0x714f0001, | ||||
| 	0xc78, 0x70500001, | ||||
| 	0xc78, 0x6f510001, | ||||
| 	0xc78, 0x6e520001, | ||||
| 	0xc78, 0x6d530001, | ||||
| 	0xc78, 0x6c540001, | ||||
| 	0xc78, 0x6b550001, | ||||
| 	0xc78, 0x6a560001, | ||||
| 	0xc78, 0x69570001, | ||||
| 	0xc78, 0x68580001, | ||||
| 	0xc78, 0x67590001, | ||||
| 	0xc78, 0x665a0001, | ||||
| 	0xc78, 0x655b0001, | ||||
| 	0xc78, 0x645c0001, | ||||
| 	0xc78, 0x635d0001, | ||||
| 	0xc78, 0x625e0001, | ||||
| 	0xc78, 0x615f0001, | ||||
| 	0xc78, 0x60600001, | ||||
| 	0xc78, 0x49610001, | ||||
| 	0xc78, 0x48620001, | ||||
| 	0xc78, 0x47630001, | ||||
| 	0xc78, 0x46640001, | ||||
| 	0xc78, 0x45650001, | ||||
| 	0xc78, 0x44660001, | ||||
| 	0xc78, 0x43670001, | ||||
| 	0xc78, 0x42680001, | ||||
| 	0xc78, 0x41690001, | ||||
| 	0xc78, 0x406a0001, | ||||
| 	0xc78, 0x266b0001, | ||||
| 	0xc78, 0x256c0001, | ||||
| 	0xc78, 0x246d0001, | ||||
| 	0xc78, 0x236e0001, | ||||
| 	0xc78, 0x226f0001, | ||||
| 	0xc78, 0x21700001, | ||||
| 	0xc78, 0x20710001, | ||||
| 	0xc78, 0x06720001, | ||||
| 	0xc78, 0x05730001, | ||||
| 	0xc78, 0x04740001, | ||||
| 	0xc78, 0x03750001, | ||||
| 	0xc78, 0x02760001, | ||||
| 	0xc78, 0x01770001, | ||||
| 	0xc78, 0x00780001, | ||||
| 	0xc78, 0x00790001, | ||||
| 	0xc78, 0x007a0001, | ||||
| 	0xc78, 0x007b0001, | ||||
| 	0xc78, 0x007c0001, | ||||
| 	0xc78, 0x007d0001, | ||||
| 	0xc78, 0x007e0001, | ||||
| 	0xc78, 0x007f0001, | ||||
| 	0xc78, 0x3800001e, | ||||
| 	0xc78, 0x3801001e, | ||||
| 	0xc78, 0x3802001e, | ||||
| 	0xc78, 0x3803001e, | ||||
| 	0xc78, 0x3804001e, | ||||
| 	0xc78, 0x3805001e, | ||||
| 	0xc78, 0x3806001e, | ||||
| 	0xc78, 0x3807001e, | ||||
| 	0xc78, 0x3808001e, | ||||
| 	0xc78, 0x3c09001e, | ||||
| 	0xc78, 0x3e0a001e, | ||||
| 	0xc78, 0x400b001e, | ||||
| 	0xc78, 0x440c001e, | ||||
| 	0xc78, 0x480d001e, | ||||
| 	0xc78, 0x4c0e001e, | ||||
| 	0xc78, 0x500f001e, | ||||
| 	0xc78, 0x5210001e, | ||||
| 	0xc78, 0x5611001e, | ||||
| 	0xc78, 0x5a12001e, | ||||
| 	0xc78, 0x5e13001e, | ||||
| 	0xc78, 0x6014001e, | ||||
| 	0xc78, 0x6015001e, | ||||
| 	0xc78, 0x6016001e, | ||||
| 	0xc78, 0x6217001e, | ||||
| 	0xc78, 0x6218001e, | ||||
| 	0xc78, 0x6219001e, | ||||
| 	0xc78, 0x621a001e, | ||||
| 	0xc78, 0x621b001e, | ||||
| 	0xc78, 0x621c001e, | ||||
| 	0xc78, 0x621d001e, | ||||
| 	0xc78, 0x621e001e, | ||||
| 	0xc78, 0x621f001e, | ||||
| }; | ||||
							
								
								
									
										46
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/table.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/table.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,46 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Created on  2010/ 5/18,  1:41 | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_TABLE__H_ | ||||
| #define __RTL8723E_TABLE__H_ | ||||
| 
 | ||||
| #include <linux/types.h> | ||||
| 
 | ||||
| #define RTL8723E_PHY_REG_1TARRAY_LENGTH		372 | ||||
| extern u32 RTL8723EPHY_REG_1TARRAY[RTL8723E_PHY_REG_1TARRAY_LENGTH]; | ||||
| #define RTL8723E_PHY_REG_ARRAY_PGLENGTH		336 | ||||
| extern u32 RTL8723EPHY_REG_ARRAY_PG[RTL8723E_PHY_REG_ARRAY_PGLENGTH]; | ||||
| #define RTL8723ERADIOA_1TARRAYLENGTH		282 | ||||
| extern u32 RTL8723E_RADIOA_1TARRAY[RTL8723ERADIOA_1TARRAYLENGTH]; | ||||
| #define RTL8723E_RADIOB_1TARRAYLENGTH		1 | ||||
| extern u32 RTL8723E_RADIOB_1TARRAY[RTL8723E_RADIOB_1TARRAYLENGTH]; | ||||
| #define RTL8723E_MACARRAYLENGTH			172 | ||||
| extern u32 RTL8723EMAC_ARRAY[RTL8723E_MACARRAYLENGTH]; | ||||
| #define RTL8723E_AGCTAB_1TARRAYLENGTH		320 | ||||
| extern u32 RTL8723EAGCTAB_1TARRAY[RTL8723E_AGCTAB_1TARRAYLENGTH]; | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										875
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										875
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,875 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #include "../wifi.h" | ||||
| #include "../pci.h" | ||||
| #include "../base.h" | ||||
| #include "../stats.h" | ||||
| #include "reg.h" | ||||
| #include "def.h" | ||||
| #include "phy.h" | ||||
| #include "trx.h" | ||||
| #include "led.h" | ||||
| 
 | ||||
| static u8 _rtl8723e_map_hwqueue_to_fwqueue(struct sk_buff *skb, u8 hw_queue) | ||||
| { | ||||
| 	__le16 fc = rtl_get_fc(skb); | ||||
| 
 | ||||
| 	if (unlikely(ieee80211_is_beacon(fc))) | ||||
| 		return QSLT_BEACON; | ||||
| 	if (ieee80211_is_mgmt(fc) || ieee80211_is_ctl(fc)) | ||||
| 		return QSLT_MGNT; | ||||
| 
 | ||||
| 	return skb->priority; | ||||
| } | ||||
| 
 | ||||
| /* mac80211's rate_idx is like this:
 | ||||
|  * | ||||
|  * 2.4G band:rx_status->band == IEEE80211_BAND_2GHZ | ||||
|  * | ||||
|  * B/G rate: | ||||
|  * (rx_status->flag & RX_FLAG_HT) = 0, | ||||
|  * DESC92C_RATE1M-->DESC92C_RATE54M ==> idx is 0-->11, | ||||
|  * | ||||
|  * N rate: | ||||
|  * (rx_status->flag & RX_FLAG_HT) = 1, | ||||
|  * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15 | ||||
|  * | ||||
|  * 5G band:rx_status->band == IEEE80211_BAND_5GHZ | ||||
|  * A rate: | ||||
|  * (rx_status->flag & RX_FLAG_HT) = 0, | ||||
|  * DESC92C_RATE6M-->DESC92C_RATE54M ==> idx is 0-->7, | ||||
|  * | ||||
|  * N rate: | ||||
|  * (rx_status->flag & RX_FLAG_HT) = 1, | ||||
|  * DESC92C_RATEMCS0-->DESC92C_RATEMCS15 ==> idx is 0-->15 | ||||
|  */ | ||||
| static int _rtl8723e_rate_mapping(struct ieee80211_hw *hw, | ||||
| 				  bool isht, u8 desc_rate) | ||||
| { | ||||
| 	int rate_idx; | ||||
| 
 | ||||
| 	if (!isht) { | ||||
| 		if (IEEE80211_BAND_2GHZ == hw->conf.chandef.chan->band) { | ||||
| 			switch (desc_rate) { | ||||
| 			case DESC92C_RATE1M: | ||||
| 				rate_idx = 0; | ||||
| 				break; | ||||
| 			case DESC92C_RATE2M: | ||||
| 				rate_idx = 1; | ||||
| 				break; | ||||
| 			case DESC92C_RATE5_5M: | ||||
| 				rate_idx = 2; | ||||
| 				break; | ||||
| 			case DESC92C_RATE11M: | ||||
| 				rate_idx = 3; | ||||
| 				break; | ||||
| 			case DESC92C_RATE6M: | ||||
| 				rate_idx = 4; | ||||
| 				break; | ||||
| 			case DESC92C_RATE9M: | ||||
| 				rate_idx = 5; | ||||
| 				break; | ||||
| 			case DESC92C_RATE12M: | ||||
| 				rate_idx = 6; | ||||
| 				break; | ||||
| 			case DESC92C_RATE18M: | ||||
| 				rate_idx = 7; | ||||
| 				break; | ||||
| 			case DESC92C_RATE24M: | ||||
| 				rate_idx = 8; | ||||
| 				break; | ||||
| 			case DESC92C_RATE36M: | ||||
| 				rate_idx = 9; | ||||
| 				break; | ||||
| 			case DESC92C_RATE48M: | ||||
| 				rate_idx = 10; | ||||
| 				break; | ||||
| 			case DESC92C_RATE54M: | ||||
| 				rate_idx = 11; | ||||
| 				break; | ||||
| 			default: | ||||
| 				rate_idx = 0; | ||||
| 				break; | ||||
| 			} | ||||
| 		} else { | ||||
| 			switch (desc_rate) { | ||||
| 			case DESC92C_RATE6M: | ||||
| 				rate_idx = 0; | ||||
| 				break; | ||||
| 			case DESC92C_RATE9M: | ||||
| 				rate_idx = 1; | ||||
| 				break; | ||||
| 			case DESC92C_RATE12M: | ||||
| 				rate_idx = 2; | ||||
| 				break; | ||||
| 			case DESC92C_RATE18M: | ||||
| 				rate_idx = 3; | ||||
| 				break; | ||||
| 			case DESC92C_RATE24M: | ||||
| 				rate_idx = 4; | ||||
| 				break; | ||||
| 			case DESC92C_RATE36M: | ||||
| 				rate_idx = 5; | ||||
| 				break; | ||||
| 			case DESC92C_RATE48M: | ||||
| 				rate_idx = 6; | ||||
| 				break; | ||||
| 			case DESC92C_RATE54M: | ||||
| 				rate_idx = 7; | ||||
| 				break; | ||||
| 			default: | ||||
| 				rate_idx = 0; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} else { | ||||
| 		switch (desc_rate) { | ||||
| 		case DESC92C_RATEMCS0: | ||||
| 			rate_idx = 0; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS1: | ||||
| 			rate_idx = 1; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS2: | ||||
| 			rate_idx = 2; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS3: | ||||
| 			rate_idx = 3; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS4: | ||||
| 			rate_idx = 4; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS5: | ||||
| 			rate_idx = 5; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS6: | ||||
| 			rate_idx = 6; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS7: | ||||
| 			rate_idx = 7; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS8: | ||||
| 			rate_idx = 8; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS9: | ||||
| 			rate_idx = 9; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS10: | ||||
| 			rate_idx = 10; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS11: | ||||
| 			rate_idx = 11; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS12: | ||||
| 			rate_idx = 12; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS13: | ||||
| 			rate_idx = 13; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS14: | ||||
| 			rate_idx = 14; | ||||
| 			break; | ||||
| 		case DESC92C_RATEMCS15: | ||||
| 			rate_idx = 15; | ||||
| 			break; | ||||
| 		default: | ||||
| 			rate_idx = 0; | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	return rate_idx; | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723e_query_rxphystatus(struct ieee80211_hw *hw, | ||||
| 					struct rtl_stats *pstatus, u8 *pdesc, | ||||
| 					struct rx_fwinfo_8723e *p_drvinfo, | ||||
| 					bool bpacket_match_bssid, | ||||
| 					bool bpacket_toself, bool packet_beacon) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_ps_ctl *ppsc = rtl_psc(rtlpriv); | ||||
| 	struct phy_sts_cck_8723e_t *cck_buf; | ||||
| 	s8 rx_pwr_all = 0, rx_pwr[4]; | ||||
| 	u8 rf_rx_num = 0, evm, pwdb_all; | ||||
| 	u8 i, max_spatial_stream; | ||||
| 	u32 rssi, total_rssi = 0; | ||||
| 	bool is_cck = pstatus->is_cck; | ||||
| 
 | ||||
| 	/* Record it for next packet processing */ | ||||
| 	pstatus->packet_matchbssid = bpacket_match_bssid; | ||||
| 	pstatus->packet_toself = bpacket_toself; | ||||
| 	pstatus->packet_beacon = packet_beacon; | ||||
| 	pstatus->rx_mimo_signalquality[0] = -1; | ||||
| 	pstatus->rx_mimo_signalquality[1] = -1; | ||||
| 
 | ||||
| 	if (is_cck) { | ||||
| 		u8 report, cck_highpwr; | ||||
| 
 | ||||
| 		/* CCK Driver info Structure is not the same as OFDM packet. */ | ||||
| 		cck_buf = (struct phy_sts_cck_8723e_t *)p_drvinfo; | ||||
| 
 | ||||
| 		/* (1)Hardware does not provide RSSI for CCK */ | ||||
| 		/* (2)PWDB, Average PWDB cacluated by
 | ||||
| 		 * hardware (for rate adaptive) | ||||
| 		 */ | ||||
| 		if (ppsc->rfpwr_state == ERFON) | ||||
| 			cck_highpwr = (u8)rtl_get_bbreg(hw, | ||||
| 					RFPGA0_XA_HSSIPARAMETER2, | ||||
| 					BIT(9)); | ||||
| 		else | ||||
| 			cck_highpwr = false; | ||||
| 
 | ||||
| 		if (!cck_highpwr) { | ||||
| 			u8 cck_agc_rpt = cck_buf->cck_agc_rpt; | ||||
| 			report = cck_buf->cck_agc_rpt & 0xc0; | ||||
| 			report = report >> 6; | ||||
| 			switch (report) { | ||||
| 			case 0x3: | ||||
| 				rx_pwr_all = -46 - (cck_agc_rpt & 0x3e); | ||||
| 				break; | ||||
| 			case 0x2: | ||||
| 				rx_pwr_all = -26 - (cck_agc_rpt & 0x3e); | ||||
| 				break; | ||||
| 			case 0x1: | ||||
| 				rx_pwr_all = -12 - (cck_agc_rpt & 0x3e); | ||||
| 				break; | ||||
| 			case 0x0: | ||||
| 				rx_pwr_all = 16 - (cck_agc_rpt & 0x3e); | ||||
| 				break; | ||||
| 			} | ||||
| 		} else { | ||||
| 			u8 cck_agc_rpt = cck_buf->cck_agc_rpt; | ||||
| 			report = p_drvinfo->cfosho[0] & 0x60; | ||||
| 			report = report >> 5; | ||||
| 			switch (report) { | ||||
| 			case 0x3: | ||||
| 				rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f) << 1); | ||||
| 				break; | ||||
| 			case 0x2: | ||||
| 				rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f) << 1); | ||||
| 				break; | ||||
| 			case 0x1: | ||||
| 				rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f) << 1); | ||||
| 				break; | ||||
| 			case 0x0: | ||||
| 				rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f) << 1); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all); | ||||
| 		/* CCK gain is smaller than OFDM/MCS gain,  */ | ||||
| 		/* so we add gain diff by experiences,
 | ||||
| 		 * the val is 6 | ||||
| 		 */ | ||||
| 		pwdb_all += 6; | ||||
| 		if (pwdb_all > 100) | ||||
| 			pwdb_all = 100; | ||||
| 		/* modify the offset to make the same
 | ||||
| 		 * gain index with OFDM. | ||||
| 		 */ | ||||
| 		if (pwdb_all > 34 && pwdb_all <= 42) | ||||
| 			pwdb_all -= 2; | ||||
| 		else if (pwdb_all > 26 && pwdb_all <= 34) | ||||
| 			pwdb_all -= 6; | ||||
| 		else if (pwdb_all > 14 && pwdb_all <= 26) | ||||
| 			pwdb_all -= 8; | ||||
| 		else if (pwdb_all > 4 && pwdb_all <= 14) | ||||
| 			pwdb_all -= 4; | ||||
| 
 | ||||
| 		pstatus->rx_pwdb_all = pwdb_all; | ||||
| 		pstatus->recvsignalpower = rx_pwr_all; | ||||
| 
 | ||||
| 		/* (3) Get Signal Quality (EVM) */ | ||||
| 		if (bpacket_match_bssid) { | ||||
| 			u8 sq; | ||||
| 
 | ||||
| 			if (pstatus->rx_pwdb_all > 40) | ||||
| 				sq = 100; | ||||
| 			else { | ||||
| 				sq = cck_buf->sq_rpt; | ||||
| 				if (sq > 64) | ||||
| 					sq = 0; | ||||
| 				else if (sq < 20) | ||||
| 					sq = 100; | ||||
| 				else | ||||
| 					sq = ((64 - sq) * 100) / 44; | ||||
| 			} | ||||
| 
 | ||||
| 			pstatus->signalquality = sq; | ||||
| 			pstatus->rx_mimo_signalquality[0] = sq; | ||||
| 			pstatus->rx_mimo_signalquality[1] = -1; | ||||
| 		} | ||||
| 	} else { | ||||
| 		rtlpriv->dm.rfpath_rxenable[0] = | ||||
| 		    rtlpriv->dm.rfpath_rxenable[1] = true; | ||||
| 
 | ||||
| 		/* (1)Get RSSI for HT rate */ | ||||
| 		for (i = RF90_PATH_A; i < RF6052_MAX_PATH; i++) { | ||||
| 
 | ||||
| 			/* we will judge RF RX path now. */ | ||||
| 			if (rtlpriv->dm.rfpath_rxenable[i]) | ||||
| 				rf_rx_num++; | ||||
| 
 | ||||
| 			rx_pwr[i] = ((p_drvinfo->gain_trsw[i] & | ||||
| 				      0x3f) * 2) - 110; | ||||
| 
 | ||||
| 			/* Translate DBM to percentage. */ | ||||
| 			rssi = rtl_query_rxpwrpercentage(rx_pwr[i]); | ||||
| 			total_rssi += rssi; | ||||
| 
 | ||||
| 			/* Get Rx snr value in DB */ | ||||
| 			rtlpriv->stats.rx_snr_db[i] = | ||||
| 				(long)(p_drvinfo->rxsnr[i] / 2); | ||||
| 
 | ||||
| 			/* Record Signal Strength for next packet */ | ||||
| 			if (bpacket_match_bssid) | ||||
| 				pstatus->rx_mimo_signalstrength[i] = (u8)rssi; | ||||
| 		} | ||||
| 
 | ||||
| 		/* (2)PWDB, Average PWDB cacluated by
 | ||||
| 		 * hardware (for rate adaptive) | ||||
| 		 */ | ||||
| 		rx_pwr_all = ((p_drvinfo->pwdb_all >> 1) & 0x7f) - 110; | ||||
| 
 | ||||
| 		pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all); | ||||
| 		pstatus->rx_pwdb_all = pwdb_all; | ||||
| 		pstatus->rxpower = rx_pwr_all; | ||||
| 		pstatus->recvsignalpower = rx_pwr_all; | ||||
| 
 | ||||
| 		/* (3)EVM of HT rate */ | ||||
| 		if (pstatus->is_ht && pstatus->rate >= DESC92C_RATEMCS8 && | ||||
| 		    pstatus->rate <= DESC92C_RATEMCS15) | ||||
| 			max_spatial_stream = 2; | ||||
| 		else | ||||
| 			max_spatial_stream = 1; | ||||
| 
 | ||||
| 		for (i = 0; i < max_spatial_stream; i++) { | ||||
| 			evm = rtl_evm_db_to_percentage(p_drvinfo->rxevm[i]); | ||||
| 
 | ||||
| 			if (bpacket_match_bssid) { | ||||
| 				/* Fill value in RFD, Get the first
 | ||||
| 				 * spatial stream only | ||||
| 				 */ | ||||
| 				if (i == 0) | ||||
| 					pstatus->signalquality = | ||||
| 						(u8)(evm & 0xff); | ||||
| 				pstatus->rx_mimo_signalquality[i] = | ||||
| 					(u8)(evm & 0xff); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/* UI BSS List signal strength(in percentage),
 | ||||
| 	 * make it good looking, from 0~100. | ||||
| 	 */ | ||||
| 	if (is_cck) | ||||
| 		pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw, | ||||
| 			pwdb_all)); | ||||
| 	else if (rf_rx_num != 0) | ||||
| 		pstatus->signalstrength = (u8)(rtl_signal_scale_mapping(hw, | ||||
| 			total_rssi /= rf_rx_num)); | ||||
| } | ||||
| 
 | ||||
| static void translate_rx_signal_stuff(struct ieee80211_hw *hw, | ||||
| 				      struct sk_buff *skb, | ||||
| 				      struct rtl_stats *pstatus, u8 *pdesc, | ||||
| 				      struct rx_fwinfo_8723e *p_drvinfo) | ||||
| { | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); | ||||
| 	struct ieee80211_hdr *hdr; | ||||
| 	u8 *tmp_buf; | ||||
| 	u8 *praddr; | ||||
| 	/*u8 *psaddr;*/ | ||||
| 	u16 fc, type; | ||||
| 	bool packet_matchbssid, packet_toself, packet_beacon; | ||||
| 
 | ||||
| 	tmp_buf = skb->data + pstatus->rx_drvinfo_size + pstatus->rx_bufshift; | ||||
| 
 | ||||
| 	hdr = (struct ieee80211_hdr *)tmp_buf; | ||||
| 	fc = le16_to_cpu(hdr->frame_control); | ||||
| 	type = WLAN_FC_GET_TYPE(hdr->frame_control); | ||||
| 	praddr = hdr->addr1; | ||||
| 
 | ||||
| 	packet_matchbssid = ((IEEE80211_FTYPE_CTL != type) && | ||||
| 		(ether_addr_equal(mac->bssid, (fc & IEEE80211_FCTL_TODS) ? | ||||
| 		 hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? | ||||
| 		 hdr->addr2 : hdr->addr3)) && | ||||
| 		 (!pstatus->hwerror) && | ||||
| 		 (!pstatus->crc) && (!pstatus->icv)); | ||||
| 
 | ||||
| 	packet_toself = packet_matchbssid && | ||||
| 	    (ether_addr_equal(praddr, rtlefuse->dev_addr)); | ||||
| 
 | ||||
| 	if (ieee80211_is_beacon(hdr->frame_control)) | ||||
| 		packet_beacon = true; | ||||
| 	else | ||||
| 		packet_beacon = false; | ||||
| 
 | ||||
| 	_rtl8723e_query_rxphystatus(hw, pstatus, pdesc, p_drvinfo, | ||||
| 				    packet_matchbssid, packet_toself, | ||||
| 				    packet_beacon); | ||||
| 
 | ||||
| 	rtl_process_phyinfo(hw, tmp_buf, pstatus); | ||||
| } | ||||
| 
 | ||||
| bool rtl8723e_rx_query_desc(struct ieee80211_hw *hw, | ||||
| 			    struct rtl_stats *status, | ||||
| 			    struct ieee80211_rx_status *rx_status, | ||||
| 			    u8 *pdesc, struct sk_buff *skb) | ||||
| { | ||||
| 	struct rx_fwinfo_8723e *p_drvinfo; | ||||
| 	struct ieee80211_hdr *hdr; | ||||
| 	u32 phystatus = GET_RX_DESC_PHYST(pdesc); | ||||
| 
 | ||||
| 	status->length = (u16)GET_RX_DESC_PKT_LEN(pdesc); | ||||
| 	status->rx_drvinfo_size = (u8)GET_RX_DESC_DRV_INFO_SIZE(pdesc) * | ||||
| 	    RX_DRV_INFO_SIZE_UNIT; | ||||
| 	status->rx_bufshift = (u8)(GET_RX_DESC_SHIFT(pdesc) & 0x03); | ||||
| 	status->icv = (u16)GET_RX_DESC_ICV(pdesc); | ||||
| 	status->crc = (u16)GET_RX_DESC_CRC32(pdesc); | ||||
| 	status->hwerror = (status->crc | status->icv); | ||||
| 	status->decrypted = !GET_RX_DESC_SWDEC(pdesc); | ||||
| 	status->rate = (u8)GET_RX_DESC_RXMCS(pdesc); | ||||
| 	status->shortpreamble = (u16)GET_RX_DESC_SPLCP(pdesc); | ||||
| 	status->isampdu = (bool)(GET_RX_DESC_PAGGR(pdesc) == 1); | ||||
| 	status->isfirst_ampdu = (bool)((GET_RX_DESC_PAGGR(pdesc) == 1) && | ||||
| 				       (GET_RX_DESC_FAGGR(pdesc) == 1)); | ||||
| 	status->timestamp_low = GET_RX_DESC_TSFL(pdesc); | ||||
| 	status->rx_is40Mhzpacket = (bool)GET_RX_DESC_BW(pdesc); | ||||
| 	status->is_ht = (bool)GET_RX_DESC_RXHT(pdesc); | ||||
| 
 | ||||
| 	status->is_cck = RX_HAL_IS_CCK_RATE(status->rate); | ||||
| 
 | ||||
| 	rx_status->freq = hw->conf.chandef.chan->center_freq; | ||||
| 	rx_status->band = hw->conf.chandef.chan->band; | ||||
| 
 | ||||
| 	hdr = (struct ieee80211_hdr *)(skb->data + status->rx_drvinfo_size | ||||
| 			+ status->rx_bufshift); | ||||
| 
 | ||||
| 	if (status->crc) | ||||
| 		rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; | ||||
| 
 | ||||
| 	if (status->rx_is40Mhzpacket) | ||||
| 		rx_status->flag |= RX_FLAG_40MHZ; | ||||
| 
 | ||||
| 	if (status->is_ht) | ||||
| 		rx_status->flag |= RX_FLAG_HT; | ||||
| 
 | ||||
| 	rx_status->flag |= RX_FLAG_MACTIME_START; | ||||
| 
 | ||||
| 	/* hw will set status->decrypted true, if it finds the
 | ||||
| 	 * frame is open data frame or mgmt frame. | ||||
| 	 * So hw will not decryption robust managment frame | ||||
| 	 * for IEEE80211w but still set status->decrypted | ||||
| 	 * true, so here we should set it back to undecrypted | ||||
| 	 * for IEEE80211w frame, and mac80211 sw will help | ||||
| 	 * to decrypt it | ||||
| 	 */ | ||||
| 	if (status->decrypted) { | ||||
| 		if ((!_ieee80211_is_robust_mgmt_frame(hdr)) && | ||||
| 		    (ieee80211_has_protected(hdr->frame_control))) | ||||
| 			rx_status->flag |= RX_FLAG_DECRYPTED; | ||||
| 		else | ||||
| 			rx_status->flag &= ~RX_FLAG_DECRYPTED; | ||||
| 	} | ||||
| 
 | ||||
| 	/* rate_idx: index of data rate into band's
 | ||||
| 	 * supported rates or MCS index if HT rates | ||||
| 	 * are use (RX_FLAG_HT) | ||||
| 	 * Notice: this is diff with windows define | ||||
| 	 */ | ||||
| 	rx_status->rate_idx = _rtl8723e_rate_mapping(hw, | ||||
| 				status->is_ht, status->rate); | ||||
| 
 | ||||
| 	rx_status->mactime = status->timestamp_low; | ||||
| 	if (phystatus == true) { | ||||
| 		p_drvinfo = (struct rx_fwinfo_8723e *)(skb->data + | ||||
| 						     status->rx_bufshift); | ||||
| 
 | ||||
| 		translate_rx_signal_stuff(hw, skb, status, pdesc, p_drvinfo); | ||||
| 	} | ||||
| 	rx_status->signal = status->recvsignalpower + 10; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_tx_fill_desc(struct ieee80211_hw *hw, | ||||
| 			   struct ieee80211_hdr *hdr, u8 *pdesc_tx, | ||||
| 			   u8 *txbd, struct ieee80211_tx_info *info, | ||||
| 			   struct ieee80211_sta *sta, | ||||
| 			   struct sk_buff *skb, | ||||
| 			   u8 hw_queue, struct rtl_tcb_desc *ptcb_desc) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||||
| 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | ||||
| 	bool b_defaultadapter = true; | ||||
| 	/* bool b_trigger_ac = false; */ | ||||
| 	u8 *pdesc = (u8 *)pdesc_tx; | ||||
| 	u16 seq_number; | ||||
| 	__le16 fc = hdr->frame_control; | ||||
| 	u8 fw_qsel = _rtl8723e_map_hwqueue_to_fwqueue(skb, hw_queue); | ||||
| 	bool firstseg = ((hdr->seq_ctrl & | ||||
| 			  cpu_to_le16(IEEE80211_SCTL_FRAG)) == 0); | ||||
| 
 | ||||
| 	bool lastseg = ((hdr->frame_control & | ||||
| 			 cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) == 0); | ||||
| 
 | ||||
| 	dma_addr_t mapping = pci_map_single(rtlpci->pdev, | ||||
| 					    skb->data, skb->len, | ||||
| 					    PCI_DMA_TODEVICE); | ||||
| 	u8 bw_40 = 0; | ||||
| 
 | ||||
| 	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) { | ||||
| 		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, | ||||
| 			 "DMA mapping error"); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (mac->opmode == NL80211_IFTYPE_STATION) { | ||||
| 		bw_40 = mac->bw_40; | ||||
| 	} else if (mac->opmode == NL80211_IFTYPE_AP || | ||||
| 		mac->opmode == NL80211_IFTYPE_ADHOC) { | ||||
| 		if (sta) | ||||
| 			bw_40 = sta->ht_cap.cap & | ||||
| 				IEEE80211_HT_CAP_SUP_WIDTH_20_40; | ||||
| 	} | ||||
| 
 | ||||
| 	seq_number = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; | ||||
| 
 | ||||
| 	rtl_get_tcb_desc(hw, info, sta, skb, ptcb_desc); | ||||
| 
 | ||||
| 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_8723e)); | ||||
| 
 | ||||
| 	if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) { | ||||
| 		firstseg = true; | ||||
| 		lastseg = true; | ||||
| 	} | ||||
| 
 | ||||
| 	if (firstseg) { | ||||
| 		SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); | ||||
| 
 | ||||
| 		SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate); | ||||
| 
 | ||||
| 		if (ptcb_desc->use_shortgi || ptcb_desc->use_shortpreamble) | ||||
| 			SET_TX_DESC_DATA_SHORTGI(pdesc, 1); | ||||
| 
 | ||||
| 		if (info->flags & IEEE80211_TX_CTL_AMPDU) { | ||||
| 			SET_TX_DESC_AGG_BREAK(pdesc, 1); | ||||
| 			SET_TX_DESC_MAX_AGG_NUM(pdesc, 0x14); | ||||
| 		} | ||||
| 		SET_TX_DESC_SEQ(pdesc, seq_number); | ||||
| 
 | ||||
| 		SET_TX_DESC_RTS_ENABLE(pdesc, | ||||
| 				       ((ptcb_desc->rts_enable && | ||||
| 					!ptcb_desc->cts_enable) ? 1 : 0)); | ||||
| 		SET_TX_DESC_HW_RTS_ENABLE(pdesc, | ||||
| 					  ((ptcb_desc->rts_enable || | ||||
| 					  ptcb_desc->cts_enable) ? 1 : 0)); | ||||
| 		SET_TX_DESC_CTS2SELF(pdesc, | ||||
| 				     ((ptcb_desc->cts_enable) ? 1 : 0)); | ||||
| 		SET_TX_DESC_RTS_STBC(pdesc, | ||||
| 				     ((ptcb_desc->rts_stbc) ? 1 : 0)); | ||||
| 
 | ||||
| 		SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate); | ||||
| 		SET_TX_DESC_RTS_BW(pdesc, 0); | ||||
| 		SET_TX_DESC_RTS_SC(pdesc, ptcb_desc->rts_sc); | ||||
| 		SET_TX_DESC_RTS_SHORT(pdesc, | ||||
| 				((ptcb_desc->rts_rate <= DESC92C_RATE54M) ? | ||||
| 				(ptcb_desc->rts_use_shortpreamble ? 1 : 0) | ||||
| 				: (ptcb_desc->rts_use_shortgi ? 1 : 0))); | ||||
| 
 | ||||
| 		if (bw_40) { | ||||
| 			if (ptcb_desc->packet_bw == HT_CHANNEL_WIDTH_20_40) { | ||||
| 				SET_TX_DESC_DATA_BW(pdesc, 1); | ||||
| 				SET_TX_DESC_TX_SUB_CARRIER(pdesc, 3); | ||||
| 			} else { | ||||
| 				SET_TX_DESC_DATA_BW(pdesc, 0); | ||||
| 				SET_TX_DESC_TX_SUB_CARRIER(pdesc, | ||||
| 					mac->cur_40_prime_sc); | ||||
| 			} | ||||
| 		} else { | ||||
| 			SET_TX_DESC_DATA_BW(pdesc, 0); | ||||
| 			SET_TX_DESC_TX_SUB_CARRIER(pdesc, 0); | ||||
| 		} | ||||
| 
 | ||||
| 		SET_TX_DESC_LINIP(pdesc, 0); | ||||
| 		SET_TX_DESC_PKT_SIZE(pdesc, (u16) skb->len); | ||||
| 
 | ||||
| 		if (sta) { | ||||
| 			u8 ampdu_density = sta->ht_cap.ampdu_density; | ||||
| 			SET_TX_DESC_AMPDU_DENSITY(pdesc, ampdu_density); | ||||
| 		} | ||||
| 
 | ||||
| 		if (info->control.hw_key) { | ||||
| 			struct ieee80211_key_conf *keyconf = | ||||
| 			    info->control.hw_key; | ||||
| 
 | ||||
| 			switch (keyconf->cipher) { | ||||
| 			case WLAN_CIPHER_SUITE_WEP40: | ||||
| 			case WLAN_CIPHER_SUITE_WEP104: | ||||
| 			case WLAN_CIPHER_SUITE_TKIP: | ||||
| 				SET_TX_DESC_SEC_TYPE(pdesc, 0x1); | ||||
| 				break; | ||||
| 			case WLAN_CIPHER_SUITE_CCMP: | ||||
| 				SET_TX_DESC_SEC_TYPE(pdesc, 0x3); | ||||
| 				break; | ||||
| 			default: | ||||
| 				SET_TX_DESC_SEC_TYPE(pdesc, 0x0); | ||||
| 				break; | ||||
| 
 | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		SET_TX_DESC_PKT_ID(pdesc, 0); | ||||
| 		SET_TX_DESC_QUEUE_SEL(pdesc, fw_qsel); | ||||
| 
 | ||||
| 		SET_TX_DESC_DATA_RATE_FB_LIMIT(pdesc, 0x1F); | ||||
| 		SET_TX_DESC_RTS_RATE_FB_LIMIT(pdesc, 0xF); | ||||
| 		SET_TX_DESC_DISABLE_FB(pdesc, 0); | ||||
| 		SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); | ||||
| 
 | ||||
| 		if (ieee80211_is_data_qos(fc)) { | ||||
| 			if (mac->rdg_en) { | ||||
| 				RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, | ||||
| 					 "Enable RDG function.\n"); | ||||
| 				SET_TX_DESC_RDG_ENABLE(pdesc, 1); | ||||
| 				SET_TX_DESC_HTC(pdesc, 1); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	SET_TX_DESC_FIRST_SEG(pdesc, (firstseg ? 1 : 0)); | ||||
| 	SET_TX_DESC_LAST_SEG(pdesc, (lastseg ? 1 : 0)); | ||||
| 
 | ||||
| 	SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) skb->len); | ||||
| 
 | ||||
| 	SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); | ||||
| 
 | ||||
| 	if (rtlpriv->dm.useramask) { | ||||
| 		SET_TX_DESC_RATE_ID(pdesc, ptcb_desc->ratr_index); | ||||
| 		SET_TX_DESC_MACID(pdesc, ptcb_desc->mac_id); | ||||
| 	} else { | ||||
| 		SET_TX_DESC_RATE_ID(pdesc, 0xC + ptcb_desc->ratr_index); | ||||
| 		SET_TX_DESC_MACID(pdesc, ptcb_desc->ratr_index); | ||||
| 	} | ||||
| 
 | ||||
| 	if ((!ieee80211_is_data_qos(fc)) && ppsc->fwctrl_lps) { | ||||
| 		SET_TX_DESC_HWSEQ_EN_8723(pdesc, 1); | ||||
| 		/* SET_TX_DESC_HWSEQ_EN(pdesc, 1); */ | ||||
| 		/* SET_TX_DESC_PKT_ID(pdesc, 8); */ | ||||
| 
 | ||||
| 		if (!b_defaultadapter) | ||||
| 			SET_TX_DESC_HWSEQ_SEL_8723(pdesc, 1); | ||||
| 	/* SET_TX_DESC_QOS(pdesc, 1); */ | ||||
| 	} | ||||
| 
 | ||||
| 	SET_TX_DESC_MORE_FRAG(pdesc, (lastseg ? 0 : 1)); | ||||
| 
 | ||||
| 	if (is_multicast_ether_addr(ieee80211_get_DA(hdr)) || | ||||
| 	    is_broadcast_ether_addr(ieee80211_get_DA(hdr))) { | ||||
| 		SET_TX_DESC_BMC(pdesc, 1); | ||||
| 	} | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, "\n"); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_tx_fill_cmddesc(struct ieee80211_hw *hw, | ||||
| 			      u8 *pdesc, bool firstseg, | ||||
| 			      bool lastseg, struct sk_buff *skb) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||||
| 	u8 fw_queue = QSLT_BEACON; | ||||
| 
 | ||||
| 	dma_addr_t mapping = pci_map_single(rtlpci->pdev, | ||||
| 					    skb->data, skb->len, | ||||
| 					    PCI_DMA_TODEVICE); | ||||
| 
 | ||||
| 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data); | ||||
| 	__le16 fc = hdr->frame_control; | ||||
| 
 | ||||
| 	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) { | ||||
| 		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, | ||||
| 			 "DMA mapping error"); | ||||
| 		return; | ||||
| 	} | ||||
| 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE); | ||||
| 
 | ||||
| 	if (firstseg) | ||||
| 		SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); | ||||
| 
 | ||||
| 	SET_TX_DESC_TX_RATE(pdesc, DESC92C_RATE1M); | ||||
| 
 | ||||
| 	SET_TX_DESC_SEQ(pdesc, 0); | ||||
| 
 | ||||
| 	SET_TX_DESC_LINIP(pdesc, 0); | ||||
| 
 | ||||
| 	SET_TX_DESC_QUEUE_SEL(pdesc, fw_queue); | ||||
| 
 | ||||
| 	SET_TX_DESC_FIRST_SEG(pdesc, 1); | ||||
| 	SET_TX_DESC_LAST_SEG(pdesc, 1); | ||||
| 
 | ||||
| 	SET_TX_DESC_TX_BUFFER_SIZE(pdesc, (u16) (skb->len)); | ||||
| 
 | ||||
| 	SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); | ||||
| 
 | ||||
| 	SET_TX_DESC_RATE_ID(pdesc, 7); | ||||
| 	SET_TX_DESC_MACID(pdesc, 0); | ||||
| 
 | ||||
| 	SET_TX_DESC_OWN(pdesc, 1); | ||||
| 
 | ||||
| 	SET_TX_DESC_PKT_SIZE((u8 *)pdesc, (u16)(skb->len)); | ||||
| 
 | ||||
| 	SET_TX_DESC_FIRST_SEG(pdesc, 1); | ||||
| 	SET_TX_DESC_LAST_SEG(pdesc, 1); | ||||
| 
 | ||||
| 	SET_TX_DESC_OFFSET(pdesc, 0x20); | ||||
| 
 | ||||
| 	SET_TX_DESC_USE_RATE(pdesc, 1); | ||||
| 
 | ||||
| 	if (!ieee80211_is_data_qos(fc)) { | ||||
| 		SET_TX_DESC_HWSEQ_EN_8723(pdesc, 1); | ||||
| 		/* SET_TX_DESC_HWSEQ_EN(pdesc, 1); */ | ||||
| 		/* SET_TX_DESC_PKT_ID(pdesc, 8); */ | ||||
| 	} | ||||
| 
 | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 		      "H2C Tx Cmd Content\n", | ||||
| 		      pdesc, TX_DESC_SIZE); | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_set_desc(struct ieee80211_hw *hw, u8 *pdesc, | ||||
| 		       bool istx, u8 desc_name, u8 *val) | ||||
| { | ||||
| 	if (istx == true) { | ||||
| 		switch (desc_name) { | ||||
| 		case HW_DESC_OWN: | ||||
| 			SET_TX_DESC_OWN(pdesc, 1); | ||||
| 			break; | ||||
| 		case HW_DESC_TX_NEXTDESC_ADDR: | ||||
| 			SET_TX_DESC_NEXT_DESC_ADDRESS(pdesc, *(u32 *) val); | ||||
| 			break; | ||||
| 		default: | ||||
| 			RT_ASSERT(false, "ERR txdesc :%d not process\n", | ||||
| 				  desc_name); | ||||
| 			break; | ||||
| 		} | ||||
| 	} else { | ||||
| 		switch (desc_name) { | ||||
| 		case HW_DESC_RXOWN: | ||||
| 			SET_RX_DESC_OWN(pdesc, 1); | ||||
| 			break; | ||||
| 		case HW_DESC_RXBUFF_ADDR: | ||||
| 			SET_RX_DESC_BUFF_ADDR(pdesc, *(u32 *) val); | ||||
| 			break; | ||||
| 		case HW_DESC_RXPKT_LEN: | ||||
| 			SET_RX_DESC_PKT_LEN(pdesc, *(u32 *) val); | ||||
| 			break; | ||||
| 		case HW_DESC_RXERO: | ||||
| 			SET_RX_DESC_EOR(pdesc, 1); | ||||
| 			break; | ||||
| 		default: | ||||
| 			RT_ASSERT(false, "ERR rxdesc :%d not process\n", | ||||
| 				  desc_name); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| u32 rtl8723e_get_desc(u8 *pdesc, bool istx, u8 desc_name) | ||||
| { | ||||
| 	u32 ret = 0; | ||||
| 
 | ||||
| 	if (istx == true) { | ||||
| 		switch (desc_name) { | ||||
| 		case HW_DESC_OWN: | ||||
| 			ret = GET_TX_DESC_OWN(pdesc); | ||||
| 			break; | ||||
| 		case HW_DESC_TXBUFF_ADDR: | ||||
| 			ret = GET_TX_DESC_TX_BUFFER_ADDRESS(pdesc); | ||||
| 			break; | ||||
| 		default: | ||||
| 			RT_ASSERT(false, "ERR txdesc :%d not process\n", | ||||
| 				  desc_name); | ||||
| 			break; | ||||
| 		} | ||||
| 	} else { | ||||
| 		switch (desc_name) { | ||||
| 		case HW_DESC_OWN: | ||||
| 			ret = GET_RX_DESC_OWN(pdesc); | ||||
| 			break; | ||||
| 		case HW_DESC_RXPKT_LEN: | ||||
| 			ret = GET_RX_DESC_PKT_LEN(pdesc); | ||||
| 			break; | ||||
| 		case HW_DESC_RXBUFF_ADDR: | ||||
| 			ret = GET_RX_DESC_BUFF_ADDR(pdesc); | ||||
| 			break; | ||||
| 		default: | ||||
| 			RT_ASSERT(false, "ERR rxdesc :%d not process\n", | ||||
| 				  desc_name); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	return ret; | ||||
| } | ||||
| 
 | ||||
| bool rtl8723e_is_tx_desc_closed(struct ieee80211_hw *hw, | ||||
| 				u8 hw_queue, u16 index) | ||||
| { | ||||
| 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||||
| 	struct rtl8192_tx_ring *ring = &rtlpci->tx_ring[hw_queue]; | ||||
| 	u8 *entry = (u8 *)(&ring->desc[ring->idx]); | ||||
| 	u8 own = (u8)rtl8723e_get_desc(entry, true, HW_DESC_OWN); | ||||
| 
 | ||||
| 	/**
 | ||||
| 	 *beacon packet will only use the first | ||||
| 	 *descriptor defautly,and the own may not | ||||
| 	 *be cleared by the hardware | ||||
| 	 */ | ||||
| 	if (own) | ||||
| 		return false; | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723e_tx_polling(struct ieee80211_hw *hw, u8 hw_queue) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	if (hw_queue == BEACON_QUEUE) { | ||||
| 		rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG, BIT(4)); | ||||
| 	} else { | ||||
| 		rtl_write_word(rtlpriv, REG_PCIE_CTRL_REG, | ||||
| 			       BIT(0) << (hw_queue)); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| u32 rtl8723e_rx_command_packet(struct ieee80211_hw *hw, | ||||
| 			       struct rtl_stats status, | ||||
| 			       struct sk_buff *skb) | ||||
| { | ||||
| 	return 0; | ||||
| } | ||||
							
								
								
									
										721
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/trx.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										721
									
								
								drivers/net/wireless/rtlwifi/rtl8723ae/trx.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,721 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2012  Realtek Corporation. | ||||
|  * | ||||
|  * This program is free software; you can redistribute it and/or modify it | ||||
|  * under the terms of version 2 of the GNU General Public License as | ||||
|  * published by the Free Software Foundation. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, but WITHOUT | ||||
|  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
|  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
|  * more details. | ||||
|  * | ||||
|  * The full GNU General Public License is included in this distribution in the | ||||
|  * file called LICENSE. | ||||
|  * | ||||
|  * Contact Information: | ||||
|  * wlanfae <wlanfae@realtek.com> | ||||
|  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, | ||||
|  * Hsinchu 300, Taiwan. | ||||
|  * | ||||
|  * Larry Finger <Larry.Finger@lwfinger.net> | ||||
|  * | ||||
|  *****************************************************************************/ | ||||
| 
 | ||||
| #ifndef __RTL8723E_TRX_H__ | ||||
| #define __RTL8723E_TRX_H__ | ||||
| 
 | ||||
| #define TX_DESC_SIZE					64 | ||||
| #define TX_DESC_AGGR_SUBFRAME_SIZE		32 | ||||
| 
 | ||||
| #define RX_DESC_SIZE					32 | ||||
| #define RX_DRV_INFO_SIZE_UNIT			8 | ||||
| 
 | ||||
| #define	TX_DESC_NEXT_DESC_OFFSET		40 | ||||
| #define USB_HWDESC_HEADER_LEN			32 | ||||
| #define CRCLENGTH						4 | ||||
| 
 | ||||
| #define SET_TX_DESC_PKT_SIZE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 0, 16, __val) | ||||
| #define SET_TX_DESC_OFFSET(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 16, 8, __val) | ||||
| #define SET_TX_DESC_BMC(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 24, 1, __val) | ||||
| #define SET_TX_DESC_HTC(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 25, 1, __val) | ||||
| #define SET_TX_DESC_LAST_SEG(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 26, 1, __val) | ||||
| #define SET_TX_DESC_FIRST_SEG(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 27, 1, __val) | ||||
| #define SET_TX_DESC_LINIP(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 28, 1, __val) | ||||
| #define SET_TX_DESC_NO_ACM(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 29, 1, __val) | ||||
| #define SET_TX_DESC_GF(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 30, 1, __val) | ||||
| #define SET_TX_DESC_OWN(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_PKT_SIZE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 0, 16) | ||||
| #define GET_TX_DESC_OFFSET(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 16, 8) | ||||
| #define GET_TX_DESC_BMC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 24, 1) | ||||
| #define GET_TX_DESC_HTC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 25, 1) | ||||
| #define GET_TX_DESC_LAST_SEG(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 26, 1) | ||||
| #define GET_TX_DESC_FIRST_SEG(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 27, 1) | ||||
| #define GET_TX_DESC_LINIP(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 28, 1) | ||||
| #define GET_TX_DESC_NO_ACM(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 29, 1) | ||||
| #define GET_TX_DESC_GF(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 30, 1) | ||||
| #define GET_TX_DESC_OWN(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 31, 1) | ||||
| 
 | ||||
| #define SET_TX_DESC_MACID(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 0, 5, __val) | ||||
| #define SET_TX_DESC_AGG_BREAK(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 5, 1, __val) | ||||
| #define SET_TX_DESC_BK(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 6, 1, __val) | ||||
| #define SET_TX_DESC_RDG_ENABLE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 7, 1, __val) | ||||
| #define SET_TX_DESC_QUEUE_SEL(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 8, 5, __val) | ||||
| #define SET_TX_DESC_RDG_NAV_EXT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 13, 1, __val) | ||||
| #define SET_TX_DESC_LSIG_TXOP_EN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 14, 1, __val) | ||||
| #define SET_TX_DESC_PIFS(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 15, 1, __val) | ||||
| #define SET_TX_DESC_RATE_ID(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 16, 4, __val) | ||||
| #define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 20, 1, __val) | ||||
| #define SET_TX_DESC_EN_DESC_ID(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 21, 1, __val) | ||||
| #define SET_TX_DESC_SEC_TYPE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 22, 2, __val) | ||||
| #define SET_TX_DESC_PKT_OFFSET(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+4, 24, 8, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_MACID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 0, 5) | ||||
| #define GET_TX_DESC_AGG_ENABLE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 5, 1) | ||||
| #define GET_TX_DESC_AGG_BREAK(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 6, 1) | ||||
| #define GET_TX_DESC_RDG_ENABLE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 7, 1) | ||||
| #define GET_TX_DESC_QUEUE_SEL(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 8, 5) | ||||
| #define GET_TX_DESC_RDG_NAV_EXT(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 13, 1) | ||||
| #define GET_TX_DESC_LSIG_TXOP_EN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) | ||||
| #define GET_TX_DESC_PIFS(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 15, 1) | ||||
| #define GET_TX_DESC_RATE_ID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 16, 4) | ||||
| #define GET_TX_DESC_NAV_USE_HDR(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 20, 1) | ||||
| #define GET_TX_DESC_EN_DESC_ID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 21, 1) | ||||
| #define GET_TX_DESC_SEC_TYPE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 22, 2) | ||||
| #define GET_TX_DESC_PKT_OFFSET(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 24, 8) | ||||
| 
 | ||||
| #define SET_TX_DESC_RTS_RC(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 0, 6, __val) | ||||
| #define SET_TX_DESC_DATA_RC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 6, 6, __val) | ||||
| #define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 14, 2, __val) | ||||
| #define SET_TX_DESC_MORE_FRAG(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 17, 1, __val) | ||||
| #define SET_TX_DESC_RAW(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 18, 1, __val) | ||||
| #define SET_TX_DESC_CCX(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 19, 1, __val) | ||||
| #define SET_TX_DESC_AMPDU_DENSITY(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 20, 3, __val) | ||||
| #define SET_TX_DESC_ANTSEL_A(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 24, 1, __val) | ||||
| #define SET_TX_DESC_ANTSEL_B(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 25, 1, __val) | ||||
| #define SET_TX_DESC_TX_ANT_CCK(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 26, 2, __val) | ||||
| #define SET_TX_DESC_TX_ANTL(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 28, 2, __val) | ||||
| #define SET_TX_DESC_TX_ANT_HT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 30, 2, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_RTS_RC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 0, 6) | ||||
| #define GET_TX_DESC_DATA_RC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 6, 6) | ||||
| #define GET_TX_DESC_BAR_RTY_TH(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 14, 2) | ||||
| #define GET_TX_DESC_MORE_FRAG(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 17, 1) | ||||
| #define GET_TX_DESC_RAW(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 18, 1) | ||||
| #define GET_TX_DESC_CCX(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 19, 1) | ||||
| #define GET_TX_DESC_AMPDU_DENSITY(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 20, 3) | ||||
| #define GET_TX_DESC_ANTSEL_A(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 24, 1) | ||||
| #define GET_TX_DESC_ANTSEL_B(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 25, 1) | ||||
| #define GET_TX_DESC_TX_ANT_CCK(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 26, 2) | ||||
| #define GET_TX_DESC_TX_ANTL(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 28, 2) | ||||
| #define GET_TX_DESC_TX_ANT_HT(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 30, 2) | ||||
| 
 | ||||
| #define SET_TX_DESC_NEXT_HEAP_PAGE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 0, 8, __val) | ||||
| #define SET_TX_DESC_TAIL_PAGE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 8, 8, __val) | ||||
| #define SET_TX_DESC_SEQ(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 16, 12, __val) | ||||
| #define SET_TX_DESC_PKT_ID(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 28, 4, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_NEXT_HEAP_PAGE(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 0, 8) | ||||
| #define GET_TX_DESC_TAIL_PAGE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 8, 8) | ||||
| #define GET_TX_DESC_SEQ(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 16, 12) | ||||
| #define GET_TX_DESC_PKT_ID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 28, 4) | ||||
| 
 | ||||
| /* For RTL8723 */ | ||||
| #define SET_TX_DESC_TRIGGER_INT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 30, 1, __val) | ||||
| #define SET_TX_DESC_HWSEQ_EN_8723(__pdesc, __val)   \ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 31, 1, __val) | ||||
| #define SET_TX_DESC_HWSEQ_SEL_8723(__txdesc, __value) \ | ||||
| 	SET_BITS_TO_LE_4BYTE(__txdesc+16, 6, 2, __value) | ||||
| 
 | ||||
| #define SET_TX_DESC_RTS_RATE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 0, 5, __val) | ||||
| #define SET_TX_DESC_AP_DCFE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 5, 1, __val) | ||||
| #define SET_TX_DESC_QOS(__pdesc, __val)				\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 6, 1, __val) | ||||
| #define SET_TX_DESC_HWSEQ_EN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 7, 1, __val) | ||||
| #define SET_TX_DESC_USE_RATE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 8, 1, __val) | ||||
| #define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 9, 1, __val) | ||||
| #define SET_TX_DESC_DISABLE_FB(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 10, 1, __val) | ||||
| #define SET_TX_DESC_CTS2SELF(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 11, 1, __val) | ||||
| #define SET_TX_DESC_RTS_ENABLE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 12, 1, __val) | ||||
| #define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 13, 1, __val) | ||||
| #define SET_TX_DESC_PORT_ID(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 14, 1, __val) | ||||
| #define SET_TX_DESC_WAIT_DCTS(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 18, 1, __val) | ||||
| #define SET_TX_DESC_CTS2AP_EN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 19, 1, __val) | ||||
| #define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 20, 2, __val) | ||||
| #define SET_TX_DESC_TX_STBC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 22, 2, __val) | ||||
| #define SET_TX_DESC_DATA_SHORT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 24, 1, __val) | ||||
| #define SET_TX_DESC_DATA_BW(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 25, 1, __val) | ||||
| #define SET_TX_DESC_RTS_SHORT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 26, 1, __val) | ||||
| #define SET_TX_DESC_RTS_BW(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 27, 1, __val) | ||||
| #define SET_TX_DESC_RTS_SC(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 28, 2, __val) | ||||
| #define SET_TX_DESC_RTS_STBC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 30, 2, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_RTS_RATE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 0, 5) | ||||
| #define GET_TX_DESC_AP_DCFE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 5, 1) | ||||
| #define GET_TX_DESC_QOS(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 6, 1) | ||||
| #define GET_TX_DESC_HWSEQ_EN(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 7, 1) | ||||
| #define GET_TX_DESC_USE_RATE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 8, 1) | ||||
| #define GET_TX_DESC_DISABLE_RTS_FB(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 9, 1) | ||||
| #define GET_TX_DESC_DISABLE_FB(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 10, 1) | ||||
| #define GET_TX_DESC_CTS2SELF(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 11, 1) | ||||
| #define GET_TX_DESC_RTS_ENABLE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 12, 1) | ||||
| #define GET_TX_DESC_HW_RTS_ENABLE(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 13, 1) | ||||
| #define GET_TX_DESC_PORT_ID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 14, 1) | ||||
| #define GET_TX_DESC_WAIT_DCTS(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 18, 1) | ||||
| #define GET_TX_DESC_CTS2AP_EN(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 19, 1) | ||||
| #define GET_TX_DESC_TX_SUB_CARRIER(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 20, 2) | ||||
| #define GET_TX_DESC_TX_STBC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 22, 2) | ||||
| #define GET_TX_DESC_DATA_SHORT(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 24, 1) | ||||
| #define GET_TX_DESC_DATA_BW(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 25, 1) | ||||
| #define GET_TX_DESC_RTS_SHORT(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 26, 1) | ||||
| #define GET_TX_DESC_RTS_BW(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 27, 1) | ||||
| #define GET_TX_DESC_RTS_SC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 28, 2) | ||||
| #define GET_TX_DESC_RTS_STBC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 30, 2) | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_RATE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 0, 6, __val) | ||||
| #define SET_TX_DESC_DATA_SHORTGI(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 6, 1, __val) | ||||
| #define SET_TX_DESC_CCX_TAG(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 7, 1, __val) | ||||
| #define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 8, 5, __val) | ||||
| #define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 13, 4, __val) | ||||
| #define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 17, 1, __val) | ||||
| #define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 18, 6, __val) | ||||
| #define SET_TX_DESC_USB_TXAGG_NUM(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 24, 8, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_TX_RATE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 0, 6) | ||||
| #define GET_TX_DESC_DATA_SHORTGI(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 6, 1) | ||||
| #define GET_TX_DESC_CCX_TAG(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 7, 1) | ||||
| #define GET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 8, 5) | ||||
| #define GET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 13, 4) | ||||
| #define GET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 17, 1) | ||||
| #define GET_TX_DESC_DATA_RETRY_LIMIT(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 18, 6) | ||||
| #define GET_TX_DESC_USB_TXAGG_NUM(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 24, 8) | ||||
| 
 | ||||
| #define SET_TX_DESC_TXAGC_A(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 5, __val) | ||||
| #define SET_TX_DESC_TXAGC_B(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 5, 5, __val) | ||||
| #define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 10, 1, __val) | ||||
| #define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 11, 5, __val) | ||||
| #define SET_TX_DESC_MCSG1_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 16, 4, __val) | ||||
| #define SET_TX_DESC_MCSG2_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 20, 4, __val) | ||||
| #define SET_TX_DESC_MCSG3_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 24, 4, __val) | ||||
| #define SET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc, __val)\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 28, 4, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_TXAGC_A(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 0, 5) | ||||
| #define GET_TX_DESC_TXAGC_B(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 5, 5) | ||||
| #define GET_TX_DESC_USE_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 10, 1) | ||||
| #define GET_TX_DESC_MAX_AGG_NUM(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 11, 5) | ||||
| #define GET_TX_DESC_MCSG1_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 16, 4) | ||||
| #define GET_TX_DESC_MCSG2_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 20, 4) | ||||
| #define GET_TX_DESC_MCSG3_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 24, 4) | ||||
| #define GET_TX_DESC_MCS7_SGI_MAX_LEN(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 28, 4) | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 16, __val) | ||||
| #define SET_TX_DESC_MCSG4_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 16, 4, __val) | ||||
| #define SET_TX_DESC_MCSG5_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 20, 4, __val) | ||||
| #define SET_TX_DESC_MCSG6_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 24, 4, __val) | ||||
| #define SET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 28, 4, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_TX_BUFFER_SIZE(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 0, 16) | ||||
| #define GET_TX_DESC_MCSG4_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 16, 4) | ||||
| #define GET_TX_DESC_MCSG5_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 20, 4) | ||||
| #define GET_TX_DESC_MCSG6_MAX_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 24, 4) | ||||
| #define GET_TX_DESC_MCS15_SGI_MAX_LEN(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 28, 4) | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+32, 0, 32, __val) | ||||
| #define SET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc, __val) \ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+36, 0, 32, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+32, 0, 32) | ||||
| #define GET_TX_DESC_TX_BUFFER_ADDRESS64(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+36, 0, 32) | ||||
| 
 | ||||
| #define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+40, 0, 32, __val) | ||||
| #define SET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc, __val) \ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+44, 0, 32, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+40, 0, 32) | ||||
| #define GET_TX_DESC_NEXT_DESC_ADDRESS64(__pdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+44, 0, 32) | ||||
| 
 | ||||
| #define GET_RX_DESC_PKT_LEN(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 0, 14) | ||||
| #define GET_RX_DESC_CRC32(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 14, 1) | ||||
| #define GET_RX_DESC_ICV(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 15, 1) | ||||
| #define GET_RX_DESC_DRV_INFO_SIZE(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 16, 4) | ||||
| #define GET_RX_DESC_SECURITY(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 20, 3) | ||||
| #define GET_RX_DESC_QOS(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 23, 1) | ||||
| #define GET_RX_DESC_SHIFT(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 24, 2) | ||||
| #define GET_RX_DESC_PHYST(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 26, 1) | ||||
| #define GET_RX_DESC_SWDEC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 27, 1) | ||||
| #define GET_RX_DESC_LS(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 28, 1) | ||||
| #define GET_RX_DESC_FS(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 29, 1) | ||||
| #define GET_RX_DESC_EOR(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 30, 1) | ||||
| #define GET_RX_DESC_OWN(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc, 31, 1) | ||||
| 
 | ||||
| #define SET_RX_DESC_PKT_LEN(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 0, 14, __val) | ||||
| #define SET_RX_DESC_EOR(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 30, 1, __val) | ||||
| #define SET_RX_DESC_OWN(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc, 31, 1, __val) | ||||
| 
 | ||||
| #define GET_RX_DESC_MACID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 0, 5) | ||||
| #define GET_RX_DESC_TID(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 5, 4) | ||||
| #define GET_RX_DESC_HWRSVD(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 9, 5) | ||||
| #define GET_RX_DESC_PAGGR(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) | ||||
| #define GET_RX_DESC_FAGGR(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 15, 1) | ||||
| #define GET_RX_DESC_A1_FIT(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 16, 4) | ||||
| #define GET_RX_DESC_A2_FIT(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 20, 4) | ||||
| #define GET_RX_DESC_PAM(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 24, 1) | ||||
| #define GET_RX_DESC_PWR(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 25, 1) | ||||
| #define GET_RX_DESC_MD(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 26, 1) | ||||
| #define GET_RX_DESC_MF(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 27, 1) | ||||
| #define GET_RX_DESC_TYPE(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 28, 2) | ||||
| #define GET_RX_DESC_MC(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 30, 1) | ||||
| #define GET_RX_DESC_BC(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 31, 1) | ||||
| #define GET_RX_DESC_SEQ(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 0, 12) | ||||
| #define GET_RX_DESC_FRAG(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 12, 4) | ||||
| #define GET_RX_DESC_NEXT_PKT_LEN(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 16, 14) | ||||
| #define GET_RX_DESC_NEXT_IND(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 30, 1) | ||||
| #define GET_RX_DESC_RSVD(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 31, 1) | ||||
| 
 | ||||
| #define GET_RX_DESC_RXMCS(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 0, 6) | ||||
| #define GET_RX_DESC_RXHT(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 6, 1) | ||||
| #define GET_RX_DESC_SPLCP(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 8, 1) | ||||
| #define GET_RX_DESC_BW(__pdesc)					\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 9, 1) | ||||
| #define GET_RX_DESC_HTC(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 10, 1) | ||||
| #define GET_RX_DESC_HWPC_ERR(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 14, 1) | ||||
| #define GET_RX_DESC_HWPC_IND(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 15, 1) | ||||
| #define GET_RX_DESC_IV0(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 16, 16) | ||||
| 
 | ||||
| #define GET_RX_DESC_IV1(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 0, 32) | ||||
| #define GET_RX_DESC_TSFL(__pdesc)				\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+20, 0, 32) | ||||
| 
 | ||||
| #define GET_RX_DESC_BUFF_ADDR(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+24, 0, 32) | ||||
| #define GET_RX_DESC_BUFF_ADDR64(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 0, 32) | ||||
| 
 | ||||
| #define SET_RX_DESC_BUFF_ADDR(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+24, 0, 32, __val) | ||||
| #define SET_RX_DESC_BUFF_ADDR64(__pdesc, __val) \ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 32, __val) | ||||
| 
 | ||||
| #define CLEAR_PCI_TX_DESC_CONTENT(__pdesc, _size)		\ | ||||
| do {								\ | ||||
| 	if (_size > TX_DESC_NEXT_DESC_OFFSET)			\ | ||||
| 		memset(__pdesc, 0, TX_DESC_NEXT_DESC_OFFSET);	\ | ||||
| 	else							\ | ||||
| 		memset(__pdesc, 0, _size);			\ | ||||
| } while (0) | ||||
| 
 | ||||
| struct rx_fwinfo_8723e { | ||||
| 	u8 gain_trsw[4]; | ||||
| 	u8 pwdb_all; | ||||
| 	u8 cfosho[4]; | ||||
| 	u8 cfotail[4]; | ||||
| 	char rxevm[2]; | ||||
| 	char rxsnr[4]; | ||||
| 	u8 pdsnr[2]; | ||||
| 	u8 csi_current[2]; | ||||
| 	u8 csi_target[2]; | ||||
| 	u8 sigevm; | ||||
| 	u8 max_ex_pwr; | ||||
| 	u8 ex_intf_flag:1; | ||||
| 	u8 sgi_en:1; | ||||
| 	u8 rxsc:2; | ||||
| 	u8 reserve:4; | ||||
| } __packed; | ||||
| 
 | ||||
| struct tx_desc_8723e { | ||||
| 	u32 pktsize:16; | ||||
| 	u32 offset:8; | ||||
| 	u32 bmc:1; | ||||
| 	u32 htc:1; | ||||
| 	u32 lastseg:1; | ||||
| 	u32 firstseg:1; | ||||
| 	u32 linip:1; | ||||
| 	u32 noacm:1; | ||||
| 	u32 gf:1; | ||||
| 	u32 own:1; | ||||
| 
 | ||||
| 	u32 macid:5; | ||||
| 	u32 agg_en:1; | ||||
| 	u32 bk:1; | ||||
| 	u32 rdg_en:1; | ||||
| 	u32 queuesel:5; | ||||
| 	u32 rd_nav_ext:1; | ||||
| 	u32 lsig_txop_en:1; | ||||
| 	u32 pifs:1; | ||||
| 	u32 rateid:4; | ||||
| 	u32 nav_usehdr:1; | ||||
| 	u32 en_descid:1; | ||||
| 	u32 sectype:2; | ||||
| 	u32 pktoffset:8; | ||||
| 
 | ||||
| 	u32 rts_rc:6; | ||||
| 	u32 data_rc:6; | ||||
| 	u32 rsvd0:2; | ||||
| 	u32 bar_retryht:2; | ||||
| 	u32 rsvd1:1; | ||||
| 	u32 morefrag:1; | ||||
| 	u32 raw:1; | ||||
| 	u32 ccx:1; | ||||
| 	u32 ampdudensity:3; | ||||
| 	u32 rsvd2:1; | ||||
| 	u32 ant_sela:1; | ||||
| 	u32 ant_selb:1; | ||||
| 	u32 txant_cck:2; | ||||
| 	u32 txant_l:2; | ||||
| 	u32 txant_ht:2; | ||||
| 
 | ||||
| 	u32 nextheadpage:8; | ||||
| 	u32 tailpage:8; | ||||
| 	u32 seq:12; | ||||
| 	u32 pktid:4; | ||||
| 
 | ||||
| 	u32 rtsrate:5; | ||||
| 	u32 apdcfe:1; | ||||
| 	u32 qos:1; | ||||
| 	u32 hwseq_enable:1; | ||||
| 	u32 userrate:1; | ||||
| 	u32 dis_rtsfb:1; | ||||
| 	u32 dis_datafb:1; | ||||
| 	u32 cts2self:1; | ||||
| 	u32 rts_en:1; | ||||
| 	u32 hwrts_en:1; | ||||
| 	u32 portid:1; | ||||
| 	u32 rsvd3:3; | ||||
| 	u32 waitdcts:1; | ||||
| 	u32 cts2ap_en:1; | ||||
| 	u32 txsc:2; | ||||
| 	u32 stbc:2; | ||||
| 	u32 txshort:1; | ||||
| 	u32 txbw:1; | ||||
| 	u32 rtsshort:1; | ||||
| 	u32 rtsbw:1; | ||||
| 	u32 rtssc:2; | ||||
| 	u32 rtsstbc:2; | ||||
| 
 | ||||
| 	u32 txrate:6; | ||||
| 	u32 shortgi:1; | ||||
| 	u32 ccxt:1; | ||||
| 	u32 txrate_fb_lmt:5; | ||||
| 	u32 rtsrate_fb_lmt:4; | ||||
| 	u32 retrylmt_en:1; | ||||
| 	u32 txretrylmt:6; | ||||
| 	u32 usb_txaggnum:8; | ||||
| 
 | ||||
| 	u32 txagca:5; | ||||
| 	u32 txagcb:5; | ||||
| 	u32 usemaxlen:1; | ||||
| 	u32 maxaggnum:5; | ||||
| 	u32 mcsg1maxlen:4; | ||||
| 	u32 mcsg2maxlen:4; | ||||
| 	u32 mcsg3maxlen:4; | ||||
| 	u32 mcs7sgimaxlen:4; | ||||
| 
 | ||||
| 	u32 txbuffersize:16; | ||||
| 	u32 mcsg4maxlen:4; | ||||
| 	u32 mcsg5maxlen:4; | ||||
| 	u32 mcsg6maxlen:4; | ||||
| 	u32 mcsg15sgimaxlen:4; | ||||
| 
 | ||||
| 	u32 txbuffaddr; | ||||
| 	u32 txbufferaddr64; | ||||
| 	u32 nextdescaddress; | ||||
| 	u32 nextdescaddress64; | ||||
| 
 | ||||
| 	u32 reserve_pass_pcie_mm_limit[4]; | ||||
| } __packed; | ||||
| 
 | ||||
| struct rx_desc_8723e { | ||||
| 	u32 length:14; | ||||
| 	u32 crc32:1; | ||||
| 	u32 icverror:1; | ||||
| 	u32 drv_infosize:4; | ||||
| 	u32 security:3; | ||||
| 	u32 qos:1; | ||||
| 	u32 shift:2; | ||||
| 	u32 phystatus:1; | ||||
| 	u32 swdec:1; | ||||
| 	u32 lastseg:1; | ||||
| 	u32 firstseg:1; | ||||
| 	u32 eor:1; | ||||
| 	u32 own:1; | ||||
| 
 | ||||
| 	u32 macid:5; | ||||
| 	u32 tid:4; | ||||
| 	u32 hwrsvd:5; | ||||
| 	u32 paggr:1; | ||||
| 	u32 faggr:1; | ||||
| 	u32 a1_fit:4; | ||||
| 	u32 a2_fit:4; | ||||
| 	u32 pam:1; | ||||
| 	u32 pwr:1; | ||||
| 	u32 moredata:1; | ||||
| 	u32 morefrag:1; | ||||
| 	u32 type:2; | ||||
| 	u32 mc:1; | ||||
| 	u32 bc:1; | ||||
| 
 | ||||
| 	u32 seq:12; | ||||
| 	u32 frag:4; | ||||
| 	u32 nextpktlen:14; | ||||
| 	u32 nextind:1; | ||||
| 	u32 rsvd:1; | ||||
| 
 | ||||
| 	u32 rxmcs:6; | ||||
| 	u32 rxht:1; | ||||
| 	u32 amsdu:1; | ||||
| 	u32 splcp:1; | ||||
| 	u32 bandwidth:1; | ||||
| 	u32 htc:1; | ||||
| 	u32 tcpchk_rpt:1; | ||||
| 	u32 ipcchk_rpt:1; | ||||
| 	u32 tcpchk_valid:1; | ||||
| 	u32 hwpcerr:1; | ||||
| 	u32 hwpcind:1; | ||||
| 	u32 iv0:16; | ||||
| 
 | ||||
| 	u32 iv1; | ||||
| 
 | ||||
| 	u32 tsfl; | ||||
| 
 | ||||
| 	u32 bufferaddress; | ||||
| 	u32 bufferaddress64; | ||||
| 
 | ||||
| } __packed; | ||||
| 
 | ||||
| void rtl8723e_tx_fill_desc(struct ieee80211_hw *hw, | ||||
| 			   struct ieee80211_hdr *hdr, | ||||
| 			   u8 *pdesc, u8 *txbd, | ||||
| 			   struct ieee80211_tx_info *info, | ||||
| 			   struct ieee80211_sta *sta, | ||||
| 			   struct sk_buff *skb, u8 hw_queue, | ||||
| 			   struct rtl_tcb_desc *ptcb_desc); | ||||
| bool rtl8723e_rx_query_desc(struct ieee80211_hw *hw, | ||||
| 			    struct rtl_stats *status, | ||||
| 			    struct ieee80211_rx_status *rx_status, | ||||
| 			    u8 *pdesc, struct sk_buff *skb); | ||||
| void rtl8723e_set_desc(struct ieee80211_hw *hw, | ||||
| 		       u8 *pdesc, bool istx, u8 desc_name, u8 *val); | ||||
| u32 rtl8723e_get_desc(u8 *pdesc, bool istx, u8 desc_name); | ||||
| bool rtl8723e_is_tx_desc_closed(struct ieee80211_hw *hw, | ||||
| 				u8 hw_queue, u16 index); | ||||
| void rtl8723e_tx_polling(struct ieee80211_hw *hw, u8 hw_queue); | ||||
| void rtl8723e_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, | ||||
| 			      bool firstseg, bool lastseg, | ||||
| 			      struct sk_buff *skb); | ||||
| u32 rtl8723e_rx_command_packet(struct ieee80211_hw *hw, | ||||
| 			       struct rtl_stats status, | ||||
| 			       struct sk_buff *skb); | ||||
| #endif | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 awab228
						awab228