mirror of
				https://github.com/AetherDroid/android_kernel_samsung_on5xelte.git
				synced 2025-11-01 00:28: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
				
			
		
							
								
								
									
										19
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/Makefile
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/Makefile
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| obj-m := rtl8723be.o | ||||
| 
 | ||||
| 
 | ||||
| rtl8723be-objs :=		\
 | ||||
| 		dm.o		\
 | ||||
| 		fw.o		\
 | ||||
| 		hw.o		\
 | ||||
| 		led.o		\
 | ||||
| 		phy.o		\
 | ||||
| 		pwrseq.o	\
 | ||||
| 		rf.o		\
 | ||||
| 		sw.o		\
 | ||||
| 		table.o		\
 | ||||
| 		trx.o		\
 | ||||
| 
 | ||||
| 
 | ||||
| obj-$(CONFIG_RTL8723BE) += rtl8723be.o | ||||
| 
 | ||||
| ccflags-y += -D__CHECK_ENDIAN__ | ||||
							
								
								
									
										92
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/def.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/def.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,92 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_DEF_H__ | ||||
| #define __RTL8723BE_DEF_H__ | ||||
| 
 | ||||
| #define HAL_PRIME_CHNL_OFFSET_DONT_CARE		0 | ||||
| #define HAL_PRIME_CHNL_OFFSET_LOWER		1 | ||||
| #define HAL_PRIME_CHNL_OFFSET_UPPER		2 | ||||
| 
 | ||||
| 
 | ||||
| #define RX_MPDU_QUEUE				0 | ||||
| #define CHIP_8723B				(BIT(1) | BIT(2)) | ||||
| #define NORMAL_CHIP				BIT(3) | ||||
| #define CHIP_VENDOR_SMIC			BIT(8) | ||||
| /* Currently only for RTL8723B */ | ||||
| #define EXT_VENDOR_ID				(BIT(18) | BIT(19)) | ||||
| 
 | ||||
| enum rx_packet_type { | ||||
| 	NORMAL_RX, | ||||
| 	TX_REPORT1, | ||||
| 	TX_REPORT2, | ||||
| 	HIS_REPORT, | ||||
| 	C2H_PACKET, | ||||
| }; | ||||
| 
 | ||||
| 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, | ||||
| }; | ||||
| #endif | ||||
							
								
								
									
										1326
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/dm.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1326
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/dm.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										300
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/dm.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										300
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/dm.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,300 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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. | ||||
|  * | ||||
|  * 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	__RTL8723BE_DM_H__ | ||||
| #define __RTL8723BE_DM_H__ | ||||
| 
 | ||||
| #define	MAIN_ANT		0 | ||||
| #define	AUX_ANT			1 | ||||
| #define	MAIN_ANT_CG_TRX		1 | ||||
| #define	AUX_ANT_CG_TRX		0 | ||||
| #define	MAIN_ANT_CGCS_RX	0 | ||||
| #define	AUX_ANT_CGCS_RX		1 | ||||
| 
 | ||||
| #define	TXSCALE_TABLE_SIZE	30 | ||||
| 
 | ||||
| /*RF REG LIST*/ | ||||
| #define	DM_REG_RF_MODE_11N			0x00 | ||||
| #define	DM_REG_RF_0B_11N			0x0B | ||||
| #define	DM_REG_CHNBW_11N			0x18 | ||||
| #define	DM_REG_T_METER_11N			0x24 | ||||
| #define	DM_REG_RF_25_11N			0x25 | ||||
| #define	DM_REG_RF_26_11N			0x26 | ||||
| #define	DM_REG_RF_27_11N			0x27 | ||||
| #define	DM_REG_RF_2B_11N			0x2B | ||||
| #define	DM_REG_RF_2C_11N			0x2C | ||||
| #define	DM_REG_RXRF_A3_11N			0x3C | ||||
| #define	DM_REG_T_METER_92D_11N			0x42 | ||||
| #define	DM_REG_T_METER_88E_11N			0x42 | ||||
| 
 | ||||
| /*BB REG LIST*/ | ||||
| /*PAGE 8 */ | ||||
| #define	DM_REG_BB_CTRL_11N			0x800 | ||||
| #define	DM_REG_RF_PIN_11N			0x804 | ||||
| #define	DM_REG_PSD_CTRL_11N			0x808 | ||||
| #define	DM_REG_TX_ANT_CTRL_11N			0x80C | ||||
| #define	DM_REG_BB_PWR_SAV5_11N			0x818 | ||||
| #define	DM_REG_CCK_RPT_FORMAT_11N		0x824 | ||||
| #define	DM_REG_RX_DEFUALT_A_11N			0x858 | ||||
| #define	DM_REG_RX_DEFUALT_B_11N			0x85A | ||||
| #define	DM_REG_BB_PWR_SAV3_11N			0x85C | ||||
| #define	DM_REG_ANTSEL_CTRL_11N			0x860 | ||||
| #define	DM_REG_RX_ANT_CTRL_11N			0x864 | ||||
| #define	DM_REG_PIN_CTRL_11N			0x870 | ||||
| #define	DM_REG_BB_PWR_SAV1_11N			0x874 | ||||
| #define	DM_REG_ANTSEL_PATH_11N			0x878 | ||||
| #define	DM_REG_BB_3WIRE_11N			0x88C | ||||
| #define	DM_REG_SC_CNT_11N			0x8C4 | ||||
| #define	DM_REG_PSD_DATA_11N			0x8B4 | ||||
| /*PAGE 9*/ | ||||
| #define	DM_REG_ANT_MAPPING1_11N			0x914 | ||||
| #define	DM_REG_ANT_MAPPING2_11N			0x918 | ||||
| /*PAGE A*/ | ||||
| #define	DM_REG_CCK_ANTDIV_PARA1_11N		0xA00 | ||||
| #define	DM_REG_CCK_CCA_11N			0xA0A | ||||
| #define	DM_REG_CCK_ANTDIV_PARA2_11N		0xA0C | ||||
| #define	DM_REG_CCK_ANTDIV_PARA3_11N		0xA10 | ||||
| #define	DM_REG_CCK_ANTDIV_PARA4_11N		0xA14 | ||||
| #define	DM_REG_CCK_FILTER_PARA1_11N		0xA22 | ||||
| #define	DM_REG_CCK_FILTER_PARA2_11N		0xA23 | ||||
| #define	DM_REG_CCK_FILTER_PARA3_11N		0xA24 | ||||
| #define	DM_REG_CCK_FILTER_PARA4_11N		0xA25 | ||||
| #define	DM_REG_CCK_FILTER_PARA5_11N		0xA26 | ||||
| #define	DM_REG_CCK_FILTER_PARA6_11N		0xA27 | ||||
| #define	DM_REG_CCK_FILTER_PARA7_11N		0xA28 | ||||
| #define	DM_REG_CCK_FILTER_PARA8_11N		0xA29 | ||||
| #define	DM_REG_CCK_FA_RST_11N			0xA2C | ||||
| #define	DM_REG_CCK_FA_MSB_11N			0xA58 | ||||
| #define	DM_REG_CCK_FA_LSB_11N			0xA5C | ||||
| #define	DM_REG_CCK_CCA_CNT_11N			0xA60 | ||||
| #define	DM_REG_BB_PWR_SAV4_11N			0xA74 | ||||
| /*PAGE B */ | ||||
| #define	DM_REG_LNA_SWITCH_11N			0xB2C | ||||
| #define	DM_REG_PATH_SWITCH_11N			0xB30 | ||||
| #define	DM_REG_RSSI_CTRL_11N			0xB38 | ||||
| #define	DM_REG_CONFIG_ANTA_11N			0xB68 | ||||
| #define	DM_REG_RSSI_BT_11N			0xB9C | ||||
| /*PAGE C */ | ||||
| #define	DM_REG_OFDM_FA_HOLDC_11N		0xC00 | ||||
| #define	DM_REG_RX_PATH_11N			0xC04 | ||||
| #define	DM_REG_TRMUX_11N			0xC08 | ||||
| #define	DM_REG_OFDM_FA_RSTC_11N			0xC0C | ||||
| #define	DM_REG_RXIQI_MATRIX_11N			0xC14 | ||||
| #define	DM_REG_TXIQK_MATRIX_LSB1_11N		0xC4C | ||||
| #define	DM_REG_IGI_A_11N			0xC50 | ||||
| #define	DM_REG_ANTDIV_PARA2_11N			0xC54 | ||||
| #define	DM_REG_IGI_B_11N			0xC58 | ||||
| #define	DM_REG_ANTDIV_PARA3_11N			0xC5C | ||||
| #define	DM_REG_BB_PWR_SAV2_11N			0xC70 | ||||
| #define	DM_REG_RX_OFF_11N			0xC7C | ||||
| #define	DM_REG_TXIQK_MATRIXA_11N		0xC80 | ||||
| #define	DM_REG_TXIQK_MATRIXB_11N		0xC88 | ||||
| #define	DM_REG_TXIQK_MATRIXA_LSB2_11N		0xC94 | ||||
| #define	DM_REG_TXIQK_MATRIXB_LSB2_11N		0xC9C | ||||
| #define	DM_REG_RXIQK_MATRIX_LSB_11N		0xCA0 | ||||
| #define	DM_REG_ANTDIV_PARA1_11N			0xCA4 | ||||
| #define	DM_REG_OFDM_FA_TYPE1_11N		0xCF0 | ||||
| /*PAGE D */ | ||||
| #define	DM_REG_OFDM_FA_RSTD_11N			0xD00 | ||||
| #define	DM_REG_OFDM_FA_TYPE2_11N		0xDA0 | ||||
| #define	DM_REG_OFDM_FA_TYPE3_11N		0xDA4 | ||||
| #define	DM_REG_OFDM_FA_TYPE4_11N		0xDA8 | ||||
| /*PAGE E */ | ||||
| #define	DM_REG_TXAGC_A_6_18_11N			0xE00 | ||||
| #define	DM_REG_TXAGC_A_24_54_11N		0xE04 | ||||
| #define	DM_REG_TXAGC_A_1_MCS32_11N		0xE08 | ||||
| #define	DM_REG_TXAGC_A_MCS0_3_11N		0xE10 | ||||
| #define	DM_REG_TXAGC_A_MCS4_7_11N		0xE14 | ||||
| #define	DM_REG_TXAGC_A_MCS8_11_11N		0xE18 | ||||
| #define	DM_REG_TXAGC_A_MCS12_15_11N		0xE1C | ||||
| #define	DM_REG_FPGA0_IQK_11N			0xE28 | ||||
| #define	DM_REG_TXIQK_TONE_A_11N			0xE30 | ||||
| #define	DM_REG_RXIQK_TONE_A_11N			0xE34 | ||||
| #define	DM_REG_TXIQK_PI_A_11N			0xE38 | ||||
| #define	DM_REG_RXIQK_PI_A_11N			0xE3C | ||||
| #define	DM_REG_TXIQK_11N			0xE40 | ||||
| #define	DM_REG_RXIQK_11N			0xE44 | ||||
| #define	DM_REG_IQK_AGC_PTS_11N			0xE48 | ||||
| #define	DM_REG_IQK_AGC_RSP_11N			0xE4C | ||||
| #define	DM_REG_BLUETOOTH_11N			0xE6C | ||||
| #define	DM_REG_RX_WAIT_CCA_11N			0xE70 | ||||
| #define	DM_REG_TX_CCK_RFON_11N			0xE74 | ||||
| #define	DM_REG_TX_CCK_BBON_11N			0xE78 | ||||
| #define	DM_REG_OFDM_RFON_11N			0xE7C | ||||
| #define	DM_REG_OFDM_BBON_11N			0xE80 | ||||
| #define		DM_REG_TX2RX_11N		0xE84 | ||||
| #define	DM_REG_TX2TX_11N			0xE88 | ||||
| #define	DM_REG_RX_CCK_11N			0xE8C | ||||
| #define	DM_REG_RX_OFDM_11N			0xED0 | ||||
| #define	DM_REG_RX_WAIT_RIFS_11N			0xED4 | ||||
| #define	DM_REG_RX2RX_11N			0xED8 | ||||
| #define	DM_REG_STANDBY_11N			0xEDC | ||||
| #define	DM_REG_SLEEP_11N			0xEE0 | ||||
| #define	DM_REG_PMPD_ANAEN_11N			0xEEC | ||||
| 
 | ||||
| /*MAC REG LIST*/ | ||||
| #define	DM_REG_BB_RST_11N			0x02 | ||||
| #define	DM_REG_ANTSEL_PIN_11N			0x4C | ||||
| #define	DM_REG_EARLY_MODE_11N			0x4D0 | ||||
| #define	DM_REG_RSSI_MONITOR_11N			0x4FE | ||||
| #define	DM_REG_EDCA_VO_11N			0x500 | ||||
| #define	DM_REG_EDCA_VI_11N			0x504 | ||||
| #define	DM_REG_EDCA_BE_11N			0x508 | ||||
| #define	DM_REG_EDCA_BK_11N			0x50C | ||||
| #define	DM_REG_TXPAUSE_11N			0x522 | ||||
| #define	DM_REG_RESP_TX_11N			0x6D8 | ||||
| #define	DM_REG_ANT_TRAIN_PARA1_11N		0x7b0 | ||||
| #define	DM_REG_ANT_TRAIN_PARA2_11N		0x7b4 | ||||
| 
 | ||||
| /*DIG Related*/ | ||||
| #define	DM_BIT_IGI_11N				0x0000007F | ||||
| 
 | ||||
| #define HAL_DM_DIG_DISABLE			BIT(0) | ||||
| #define HAL_DM_HIPWR_DISABLE			BIT(1) | ||||
| 
 | ||||
| #define OFDM_TABLE_LENGTH			43 | ||||
| #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_MAX_AP				0x32 | ||||
| #define DM_DIG_MIN_AP				0x20 | ||||
| 
 | ||||
| #define DM_DIG_FA_UPPER				0x3e | ||||
| #define DM_DIG_FA_LOWER				0x1e | ||||
| #define DM_DIG_FA_TH0				0x200 | ||||
| #define DM_DIG_FA_TH1				0x300 | ||||
| #define DM_DIG_FA_TH2				0x400 | ||||
| 
 | ||||
| #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 | ||||
| #define TXPWRTRACK_MAX_IDX			6 | ||||
| 
 | ||||
| /* Dynamic ATC switch */ | ||||
| #define ATC_STATUS_OFF				0x0 /* enable */ | ||||
| #define	ATC_STATUS_ON				0x1 /* disable */ | ||||
| #define	CFO_THRESHOLD_XTAL			10 /* kHz */ | ||||
| #define	CFO_THRESHOLD_ATC			80 /* kHz */ | ||||
| 
 | ||||
| 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 | ||||
| }; | ||||
| 
 | ||||
| enum pwr_track_control_method { | ||||
| 	BBSWING, | ||||
| 	TXAGC | ||||
| }; | ||||
| 
 | ||||
| #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_undecoratedsmoothed_pwdb) :\ | ||||
| 	(((struct rtl_priv *)(_priv))->dm.undecorated_smoothed_pwdb)) | ||||
| 
 | ||||
| void rtl8723be_dm_set_tx_ant_by_tx_info(struct ieee80211_hw *hw, u8 *pdesc, | ||||
| 					u32 mac_id); | ||||
| void rtl8723be_dm_ant_sel_statistics(struct ieee80211_hw *hw, u8 antsel_tr_mux, | ||||
| 				     u32 mac_id, u32 rx_pwdb_all); | ||||
| void rtl8723be_dm_fast_antenna_training_callback(unsigned long data); | ||||
| void rtl8723be_dm_init(struct ieee80211_hw *hw); | ||||
| void rtl8723be_dm_watchdog(struct ieee80211_hw *hw); | ||||
| void rtl8723be_dm_write_dig(struct ieee80211_hw *hw, u8 current_igi); | ||||
| void rtl8723be_dm_check_txpower_tracking(struct ieee80211_hw *hw); | ||||
| void rtl8723be_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw); | ||||
| void rtl8723be_dm_txpower_track_adjust(struct ieee80211_hw *hw, u8 type, | ||||
| 				       u8 *pdirection, u32 *poutwrite_val); | ||||
| #endif | ||||
							
								
								
									
										640
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/fw.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										640
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/fw.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,640 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 _rtl8723be_check_fw_read_last_h2c(struct ieee80211_hw *hw, | ||||
| 					      u8 boxnum) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 val_hmetfr; | ||||
| 	bool result = false; | ||||
| 
 | ||||
| 	val_hmetfr = rtl_read_byte(rtlpriv, REG_HMETFR); | ||||
| 	if (((val_hmetfr >> boxnum) & BIT(0)) == 0) | ||||
| 		result = true; | ||||
| 	return result; | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723be_fill_h2c_command(struct ieee80211_hw *hw, u8 element_id, | ||||
| 					u32 cmd_len, u8 *p_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[4]; | ||||
| 	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 = _rtl8723be_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, | ||||
| 					 "Waiting too long for FW read clear HMEBox(%d)!\n", | ||||
| 					 boxnum); | ||||
| 				break; | ||||
| 			} | ||||
| 
 | ||||
| 			udelay(10); | ||||
| 
 | ||||
| 			isfw_read = _rtl8723be_check_fw_read_last_h2c(hw, | ||||
| 								boxnum); | ||||
| 			u1b_tmp = rtl_read_byte(rtlpriv, 0x130); | ||||
| 			RT_TRACE(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 				 "Waiting for FW read clear HMEBox(%d)!!! 0x130 = %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: | ||||
| 		case 2: | ||||
| 		case 3: | ||||
| 			/*boxcontent[0] &= ~(BIT(7));*/ | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       p_cmdbuffer + buf_index, cmd_len); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; idx++) { | ||||
| 				rtl_write_byte(rtlpriv, box_reg + idx, | ||||
| 					       boxcontent[idx]); | ||||
| 			} | ||||
| 			break; | ||||
| 		case 4: | ||||
| 		case 5: | ||||
| 		case 6: | ||||
| 		case 7: | ||||
| 			/*boxcontent[0] |= (BIT(7));*/ | ||||
| 			memcpy((u8 *)(boxextcontent), | ||||
| 			       p_cmdbuffer + buf_index+3, cmd_len-3); | ||||
| 			memcpy((u8 *)(boxcontent) + 1, | ||||
| 			       p_cmdbuffer + buf_index, 3); | ||||
| 
 | ||||
| 			for (idx = 0; idx < 4; 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 rtl8723be_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, | ||||
| 			    u32 cmd_len, u8 *p_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, p_cmdbuffer, cmd_len); | ||||
| 	_rtl8723be_fill_h2c_command(hw, element_id, cmd_len, | ||||
| 				    (u8 *)&tmp_cmdbuf); | ||||
| 	return; | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 u1_h2c_set_pwrmode[H2C_PWEMODE_LENGTH] = { 0 }; | ||||
| 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); | ||||
| 	u8 rlbm, power_state = 0; | ||||
| 	RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD, "FW LPS mode = %d\n", mode); | ||||
| 
 | ||||
| 	SET_H2CCMD_PWRMODE_PARM_MODE(u1_h2c_set_pwrmode, ((mode) ? 1 : 0)); | ||||
| 	rlbm = 0;/*YJ,temp,120316. FW now not support RLBM=2.*/ | ||||
| 	SET_H2CCMD_PWRMODE_PARM_RLBM(u1_h2c_set_pwrmode, rlbm); | ||||
| 	SET_H2CCMD_PWRMODE_PARM_SMART_PS(u1_h2c_set_pwrmode, | ||||
| 					 (rtlpriv->mac80211.p2p) ? | ||||
| 					  ppsc->smart_ps : 1); | ||||
| 	SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(u1_h2c_set_pwrmode, | ||||
| 					       ppsc->reg_max_lps_awakeintvl); | ||||
| 	SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(u1_h2c_set_pwrmode, 0); | ||||
| 	if (mode == FW_PS_ACTIVE_MODE) | ||||
| 		power_state |= FW_PWR_STATE_ACTIVE; | ||||
| 	else | ||||
| 		power_state |= FW_PWR_STATE_RF_OFF; | ||||
| 	SET_H2CCMD_PWRMODE_PARM_PWR_STATE(u1_h2c_set_pwrmode, power_state); | ||||
| 
 | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, | ||||
| 		      "rtl92c_set_fw_pwrmode(): u1_h2c_set_pwrmode\n", | ||||
| 		      u1_h2c_set_pwrmode, H2C_PWEMODE_LENGTH); | ||||
| 	rtl8723be_fill_h2c_cmd(hw, H2C_8723B_SETPWRMODE, H2C_PWEMODE_LENGTH, | ||||
| 			       u1_h2c_set_pwrmode); | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus) | ||||
| { | ||||
| 	u8 parm[3] = { 0, 0, 0 }; | ||||
| 	/* parm[0]: bit0=0-->Disconnect, bit0=1-->Connect
 | ||||
| 	 *          bit1=0-->update Media Status to MACID | ||||
| 	 *          bit1=1-->update Media Status from MACID to MACID_End | ||||
| 	 * parm[1]: MACID, if this is INFRA_STA, MacID = 0 | ||||
| 	 * parm[2]: MACID_End | ||||
| 	*/ | ||||
| 	SET_H2CCMD_MSRRPT_PARM_OPMODE(parm, mstatus); | ||||
| 	SET_H2CCMD_MSRRPT_PARM_MACID_IND(parm, 0); | ||||
| 
 | ||||
| 	rtl8723be_fill_h2c_cmd(hw, H2C_8723B_MSRRPT, 3, parm); | ||||
| } | ||||
| 
 | ||||
| #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, 0x02, 0xB1, 0x78, | ||||
| 	0xEC, 0x1A, 0x59, 0x0B, 0xAD, 0xD4, 0x20, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x64, 0x00, 0x10, 0x04, 0x00, 0x05, 0x54, 0x65, | ||||
| 	0x73, 0x74, 0x32, 0x01, 0x08, 0x82, 0x84, 0x0B, | ||||
| 	0x16, 0x24, 0x30, 0x48, 0x6C, 0x03, 0x01, 0x06, | ||||
| 	0x06, 0x02, 0x00, 0x00, 0x2A, 0x01, 0x02, 0x32, | ||||
| 	0x04, 0x0C, 0x12, 0x18, 0x60, 0x2D, 0x1A, 0x6C, | ||||
| 	0x09, 0x03, 0xFF, 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, 0x07, 0x00, 0xE0, 0x4C, | ||||
| 	0x02, 0x02, 0x00, 0x00, 0xDD, 0x18, 0x00, 0x50, | ||||
| 	0xF2, 0x01, 0x01, 0x00, 0x00, 0x50, 0xF2, 0x04, | ||||
| 	0x01, 0x00, 0x00, 0x50, 0xF2, 0x04, 0x01, 0x00, | ||||
| 
 | ||||
| 	/* page 1 beacon */ | ||||
| 	0x00, 0x50, 0xF2, 0x02, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	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, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 2  ps-poll */ | ||||
| 	0xA4, 0x10, 0x01, 0xC0, 0xEC, 0x1A, 0x59, 0x0B, | ||||
| 	0xAD, 0xD4, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	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, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 
 | ||||
| 	/* page 3  null */ | ||||
| 	0x48, 0x01, 0x00, 0x00, 0xEC, 0x1A, 0x59, 0x0B, | ||||
| 	0xAD, 0xD4, 0x00, 0xE0, 0x4C, 0x02, 0xB1, 0x78, | ||||
| 	0xEC, 0x1A, 0x59, 0x0B, 0xAD, 0xD4, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	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, 0x28, 0x8C, 0x00, 0x12, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
| 	0x00, 0x80, 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 rtl8723be_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[5] = { 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, | ||||
| 		      "rtl8723be_set_fw_rsvdpagepkt(): HW_VAR_SET_TX_CMD: ALL\n", | ||||
| 		      &reserved_page_packet[0], totalpacketlen); | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_DMESG, | ||||
| 		      "rtl8723be_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); | ||||
| 		rtl8723be_fill_h2c_cmd(hw, H2C_8723B_RSVDPAGE, | ||||
| 				       sizeof(u1rsvdpageloc), u1rsvdpageloc); | ||||
| 	} else | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, | ||||
| 			 "Set RSVD page location to Fw FAIL!!!!!!.\n"); | ||||
| } | ||||
| 
 | ||||
| /*Should check FW support p2p or not.*/ | ||||
| static void rtl8723be_set_p2p_ctw_period_cmd(struct ieee80211_hw *hw, | ||||
| 					     u8 ctwindow) | ||||
| { | ||||
| 	u8 u1_ctwindow_period[1] = { ctwindow}; | ||||
| 
 | ||||
| 	rtl8723be_fill_h2c_cmd(hw, H2C_8723B_P2P_PS_CTW_CMD, 1, | ||||
| 			       u1_ctwindow_period); | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_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; | ||||
| 			rtl8723be_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; | ||||
| 	} | ||||
| 
 | ||||
| 	rtl8723be_fill_h2c_cmd(hw, H2C_8723B_P2P_PS_OFFLOAD, 1, | ||||
| 			       (u8 *)p2p_ps_offload); | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723be_c2h_content_parsing(struct ieee80211_hw *hw, | ||||
| 					   u8 c2h_cmd_id, | ||||
| 					   u8 c2h_cmd_len, u8 *tmp_buf) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	switch (c2h_cmd_id) { | ||||
| 	case C2H_8723B_DBG: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 			 "[C2H], C2H_8723BE_DBG!!\n"); | ||||
| 		break; | ||||
| 	case C2H_8723B_TX_REPORT: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 			 "[C2H], C2H_8723BE_TX_REPORT!\n"); | ||||
| 		break; | ||||
| 	case C2H_8723B_BT_INFO: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 			 "[C2H], C2H_8723BE_BT_INFO!!\n"); | ||||
| 		rtlpriv->btcoexist.btc_ops->btc_btinfo_notify(rtlpriv, tmp_buf, | ||||
| 							      c2h_cmd_len); | ||||
| 		break; | ||||
| 	case C2H_8723B_BT_MP: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 			 "[C2H], C2H_8723BE_BT_MP!!\n"); | ||||
| 		break; | ||||
| 	default: | ||||
| 		RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 			 "[C2H], Unkown packet!! CmdId(%#X)!\n", c2h_cmd_id); | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	u8 c2h_cmd_id = 0, c2h_cmd_seq = 0, c2h_cmd_len = 0; | ||||
| 	u8 *tmp_buf = NULL; | ||||
| 
 | ||||
| 	c2h_cmd_id = buffer[0]; | ||||
| 	c2h_cmd_seq = buffer[1]; | ||||
| 	c2h_cmd_len = len - 2; | ||||
| 	tmp_buf = buffer + 2; | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 		 "[C2H packet], c2hCmdId=0x%x, c2hCmdSeq=0x%x, c2hCmdLen=%d\n", | ||||
| 		 c2h_cmd_id, c2h_cmd_seq, c2h_cmd_len); | ||||
| 
 | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_FW, DBG_TRACE, | ||||
| 		      "[C2H packet], Content Hex:\n", tmp_buf, c2h_cmd_len); | ||||
| 
 | ||||
| 	_rtl8723be_c2h_content_parsing(hw, c2h_cmd_id, c2h_cmd_len, tmp_buf); | ||||
| } | ||||
							
								
								
									
										152
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/fw.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/fw.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,152 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE__FW__H__ | ||||
| #define __RTL8723BE__FW__H__ | ||||
| 
 | ||||
| #define FW_8192C_SIZE				0x8000 | ||||
| #define FW_8192C_START_ADDRESS			0x1000 | ||||
| #define FW_8192C_END_ADDRESS			0x5FFF | ||||
| #define FW_8192C_PAGE_SIZE			4096 | ||||
| #define FW_8192C_POLLING_DELAY			5 | ||||
| 
 | ||||
| #define USE_OLD_WOWLAN_DEBUG_FW			0 | ||||
| 
 | ||||
| #define H2C_PWEMODE_LENGTH			5 | ||||
| 
 | ||||
| /* Fw PS state for RPWM.
 | ||||
| *BIT[2:0] = HW state | ||||
| *BIT[3] = Protocol PS state, 1: register active state , 0: register sleep state | ||||
| *BIT[4] = sub-state | ||||
| */ | ||||
| #define	FW_PS_RF_ON		BIT(2) | ||||
| #define	FW_PS_REGISTER_ACTIVE	BIT(3) | ||||
| 
 | ||||
| #define	FW_PS_ACK		BIT(6) | ||||
| #define	FW_PS_TOGGLE		BIT(7) | ||||
| 
 | ||||
|  /* 8723BE RPWM value*/ | ||||
|  /* BIT[0] = 1: 32k, 0: 40M*/ | ||||
| #define	FW_PS_CLOCK_OFF		BIT(0)		/* 32k*/ | ||||
| #define	FW_PS_CLOCK_ON		0		/*40M*/ | ||||
| 
 | ||||
| #define	FW_PS_STATE_MASK	(0x0F) | ||||
| #define	FW_PS_STATE_HW_MASK	(0x07) | ||||
| /*ISR_ENABLE, IMR_ENABLE, and PS mode should be inherited.*/ | ||||
| #define	FW_PS_STATE_INT_MASK	(0x3F) | ||||
| 
 | ||||
| #define	FW_PS_STATE(x)		(FW_PS_STATE_MASK & (x)) | ||||
| 
 | ||||
| /* ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))*/ | ||||
| #define	FW_PS_STATE_ALL_ON	(FW_PS_CLOCK_ON) | ||||
| /* (FW_PS_RF_ON)*/ | ||||
| #define	FW_PS_STATE_RF_ON	(FW_PS_CLOCK_ON) | ||||
| /* 0x0*/ | ||||
| #define	FW_PS_STATE_RF_OFF	(FW_PS_CLOCK_ON) | ||||
| /* (FW_PS_STATE_RF_OFF)*/ | ||||
| #define	FW_PS_STATE_RF_OFF_LOW_PWR	(FW_PS_CLOCK_OFF) | ||||
| 
 | ||||
| 
 | ||||
| /* For 8723BE H2C PwrMode Cmd ID 5.*/ | ||||
| #define	FW_PWR_STATE_ACTIVE	((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE)) | ||||
| #define	FW_PWR_STATE_RF_OFF	0 | ||||
| 
 | ||||
| #define	FW_PS_IS_ACK(x)		((x) & FW_PS_ACK) | ||||
| 
 | ||||
| #define	IS_IN_LOW_POWER_STATE(__fwpsstate)	\ | ||||
| 	(FW_PS_STATE(__fwpsstate) == FW_PS_CLOCK_OFF) | ||||
| 
 | ||||
| #define	FW_PWR_STATE_ACTIVE	((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE)) | ||||
| #define	FW_PWR_STATE_RF_OFF	0 | ||||
| 
 | ||||
| enum rtl8723b_h2c_cmd { | ||||
| 	H2C_8723B_RSVDPAGE = 0, | ||||
| 	H2C_8723B_MSRRPT = 1, | ||||
| 	H2C_8723B_SCAN = 2, | ||||
| 	H2C_8723B_KEEP_ALIVE_CTRL = 3, | ||||
| 	H2C_8723B_DISCONNECT_DECISION = 4, | ||||
| 	H2C_8723B_BCN_RSVDPAGE = 9, | ||||
| 	H2C_8723B_PROBERSP_RSVDPAGE = 10, | ||||
| 
 | ||||
| 	H2C_8723B_SETPWRMODE = 0x20, | ||||
| 	H2C_8723B_PS_LPS_PARA = 0x23, | ||||
| 	H2C_8723B_P2P_PS_OFFLOAD = 0x24, | ||||
| 
 | ||||
| 	H2C_8723B_RA_MASK = 0x40, | ||||
| 	H2C_RSSIBE_REPORT = 0x42, | ||||
| 	/*Not defined CTW CMD for P2P yet*/ | ||||
| 	H2C_8723B_P2P_PS_CTW_CMD, | ||||
| 	MAX_8723B_H2CCMD | ||||
| }; | ||||
| 
 | ||||
| enum rtl8723b_c2h_evt { | ||||
| 	C2H_8723B_DBG = 0, | ||||
| 	C2H_8723B_LB = 1, | ||||
| 	C2H_8723B_TXBF = 2, | ||||
| 	C2H_8723B_TX_REPORT = 3, | ||||
| 	C2H_8723B_BT_INFO = 9, | ||||
| 	C2H_8723B_BT_MP = 11, | ||||
| 	MAX_8723B_C2HEVENT | ||||
| }; | ||||
| 
 | ||||
| #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_RLBM(__ph2ccmd, __val)			\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 4, __val) | ||||
| #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 4, 4, __val) | ||||
| #define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__ph2ccmd, __val)	\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val) | ||||
| #define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__ph2ccmd, __val)	\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+3, 0, 8, __val) | ||||
| #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE((__ph2ccmd)+4, 0, 8, __val) | ||||
| #define GET_88E_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd)			\ | ||||
| 	LE_BITS_TO_1BYTE(__ph2ccmd, 0, 8) | ||||
| 
 | ||||
| #define SET_H2CCMD_MSRRPT_PARM_OPMODE(__ph2ccmd, __val)		\ | ||||
| 	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 1, __val) | ||||
| #define SET_H2CCMD_MSRRPT_PARM_MACID_IND(__ph2ccmd, __val)	\ | ||||
| 	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 1, 1, __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 rtl8723be_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, | ||||
| 			    u32 cmd_len, u8 *p_cmdbuffer); | ||||
| void rtl8723be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); | ||||
| void rtl8723be_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus); | ||||
| void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); | ||||
| void rtl8723be_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); | ||||
| void rtl8723be_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										2751
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/hw.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2751
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/hw.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										63
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/hw.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/hw.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,63 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_HW_H__ | ||||
| #define __RTL8723BE_HW_H__ | ||||
| 
 | ||||
| void rtl8723be_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); | ||||
| void rtl8723be_read_eeprom_info(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| void rtl8723be_interrupt_recognized(struct ieee80211_hw *hw, | ||||
| 				    u32 *p_inta, u32 *p_intb); | ||||
| int rtl8723be_hw_init(struct ieee80211_hw *hw); | ||||
| void rtl8723be_card_disable(struct ieee80211_hw *hw); | ||||
| void rtl8723be_enable_interrupt(struct ieee80211_hw *hw); | ||||
| void rtl8723be_disable_interrupt(struct ieee80211_hw *hw); | ||||
| int rtl8723be_set_network_type(struct ieee80211_hw *hw, | ||||
| 			       enum nl80211_iftype type); | ||||
| void rtl8723be_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid); | ||||
| void rtl8723be_set_qos(struct ieee80211_hw *hw, int aci); | ||||
| void rtl8723be_set_beacon_related_registers(struct ieee80211_hw *hw); | ||||
| void rtl8723be_set_beacon_interval(struct ieee80211_hw *hw); | ||||
| void rtl8723be_update_interrupt_mask(struct ieee80211_hw *hw, | ||||
| 				     u32 add_msr, u32 rm_msr); | ||||
| void rtl8723be_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val); | ||||
| void rtl8723be_update_hal_rate_tbl(struct ieee80211_hw *hw, | ||||
| 				   struct ieee80211_sta *sta, | ||||
| 				   u8 rssi_level); | ||||
| void rtl8723be_update_channel_access_setting(struct ieee80211_hw *hw); | ||||
| bool rtl8723be_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid); | ||||
| void rtl8723be_enable_hw_security_config(struct ieee80211_hw *hw); | ||||
| void rtl8723be_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 rtl8723be_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw, | ||||
| 					      bool autoload_fail, u8 *hwinfo); | ||||
| void rtl8723be_bt_reg_init(struct ieee80211_hw *hw); | ||||
| void rtl8723be_bt_hw_init(struct ieee80211_hw *hw); | ||||
| void rtl8723be_suspend(struct ieee80211_hw *hw); | ||||
| void rtl8723be_resume(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										153
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/led.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										153
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/led.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,153 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 "reg.h" | ||||
| #include "led.h" | ||||
| 
 | ||||
| static void _rtl8723be_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 rtl8723be_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 rtl8723be_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 rtl8723be_init_sw_leds(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); | ||||
| 	_rtl8723be_init_led(hw, &(pcipriv->ledctl.sw_led0), LED_PIN_LED0); | ||||
| 	_rtl8723be_init_led(hw, &(pcipriv->ledctl.sw_led1), LED_PIN_LED1); | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723be_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: | ||||
| 		rtl8723be_sw_led_on(hw, pled0); | ||||
| 		break; | ||||
| 	case LED_CTL_POWER_OFF: | ||||
| 		rtl8723be_sw_led_off(hw, pled0); | ||||
| 		break; | ||||
| 	default: | ||||
| 		break; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_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); | ||||
| 	_rtl8723be_sw_led_control(hw, ledaction); | ||||
| } | ||||
							
								
								
									
										35
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/led.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/led.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_LED_H__ | ||||
| #define __RTL8723BE_LED_H__ | ||||
| 
 | ||||
| void rtl8723be_init_sw_leds(struct ieee80211_hw *hw); | ||||
| void rtl8723be_sw_led_on(struct ieee80211_hw *hw, struct rtl_led *pled); | ||||
| void rtl8723be_sw_led_off(struct ieee80211_hw *hw, struct rtl_led *pled); | ||||
| void rtl8723be_led_control(struct ieee80211_hw *hw, | ||||
| 			   enum led_ctl_mode ledaction); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										2755
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/phy.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2755
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/phy.c
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										137
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/phy.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/phy.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,137 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_PHY_H__ | ||||
| #define __RTL8723BE_PHY_H__ | ||||
| 
 | ||||
| /* MAX_TX_COUNT must always set to 4, otherwise read efuse table sequence
 | ||||
|  * will be wrong. | ||||
|  */ | ||||
| #define MAX_TX_COUNT		4 | ||||
| #define	TX_1S			0 | ||||
| #define	TX_2S			1 | ||||
| #define	TX_3S			2 | ||||
| #define	TX_4S			3 | ||||
| 
 | ||||
| #define	MAX_POWER_INDEX		0x3F | ||||
| 
 | ||||
| #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 TARGET_CHNL_NUM_2G_5G		59 | ||||
| 
 | ||||
| #define IQK_ADDA_REG_NUM		16 | ||||
| #define IQK_BB_REG_NUM			9 | ||||
| #define MAX_TOLERANCE			5 | ||||
| #define	IQK_DELAY_TIME			10 | ||||
| #define	index_mapping_NUM		15 | ||||
| 
 | ||||
| #define	APK_BB_REG_NUM			5 | ||||
| #define	APK_AFE_REG_NUM			16 | ||||
| #define	APK_CURVE_REG_NUM		4 | ||||
| #define	PATH_NUM			1 | ||||
| 
 | ||||
| #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 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 baseband_config_type { | ||||
| 	BASEBAND_CONFIG_PHY_REG = 0, | ||||
| 	BASEBAND_CONFIG_AGC_TAB = 1, | ||||
| }; | ||||
| 
 | ||||
| enum ant_div_type { | ||||
| 	NO_ANTDIV		= 0xFF, | ||||
| 	CG_TRX_HW_ANTDIV	= 0x01, | ||||
| 	CGCS_RX_HW_ANTDIV	= 0x02, | ||||
| 	FIXED_HW_ANTDIV         = 0x03, | ||||
| 	CG_TRX_SMART_ANTDIV	= 0x04, | ||||
| 	CGCS_RX_SW_ANTDIV	= 0x05, | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| u32 rtl8723be_phy_query_rf_reg(struct ieee80211_hw *hw, | ||||
| 			       enum radio_path rfpath, | ||||
| 			       u32 regaddr, u32 bitmask); | ||||
| void rtl8723be_phy_set_rf_reg(struct ieee80211_hw *hw, | ||||
| 			      enum radio_path rfpath, | ||||
| 			      u32 regaddr, u32 bitmask, u32 data); | ||||
| bool rtl8723be_phy_mac_config(struct ieee80211_hw *hw); | ||||
| bool rtl8723be_phy_bb_config(struct ieee80211_hw *hw); | ||||
| bool rtl8723be_phy_rf_config(struct ieee80211_hw *hw); | ||||
| void rtl8723be_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); | ||||
| void rtl8723be_phy_get_txpower_level(struct ieee80211_hw *hw, | ||||
| 				     long *powerlevel); | ||||
| void rtl8723be_phy_set_txpower_level(struct ieee80211_hw *hw, | ||||
| 				     u8 channel); | ||||
| void rtl8723be_phy_scan_operation_backup(struct ieee80211_hw *hw, | ||||
| 					 u8 operation); | ||||
| void rtl8723be_phy_set_bw_mode_callback(struct ieee80211_hw *hw); | ||||
| void rtl8723be_phy_set_bw_mode(struct ieee80211_hw *hw, | ||||
| 			       enum nl80211_channel_type ch_type); | ||||
| void rtl8723be_phy_sw_chnl_callback(struct ieee80211_hw *hw); | ||||
| u8 rtl8723be_phy_sw_chnl(struct ieee80211_hw *hw); | ||||
| void rtl8723be_phy_iq_calibrate(struct ieee80211_hw *hw, | ||||
| 				bool b_recovery); | ||||
| void rtl8723be_phy_lc_calibrate(struct ieee80211_hw *hw); | ||||
| void rtl8723be_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain); | ||||
| bool rtl8723be_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, | ||||
| 					     enum radio_path rfpath); | ||||
| bool rtl8723be_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); | ||||
| bool rtl8723be_phy_set_rf_power_state(struct ieee80211_hw *hw, | ||||
| 				      enum rf_pwrstate rfpwr_state); | ||||
| #endif | ||||
							
								
								
									
										106
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/pwrseq.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/pwrseq.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,106 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 rtl8723B_power_on_flow[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS + | ||||
| 					   RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_CARDEMU_TO_ACT | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3Radio off GPIO Array */ | ||||
| struct wlan_pwr_cfg rtl8723B_radio_off_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS | ||||
| 					    + RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3Card Disable Array*/ | ||||
| struct wlan_pwr_cfg rtl8723B_card_disable_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723B_TRANS_CARDEMU_TO_CARDDIS | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Card Enable Array*/ | ||||
| struct wlan_pwr_cfg rtl8723B_card_enable_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_CARDDIS_TO_CARDEMU | ||||
| 	RTL8723B_TRANS_CARDEMU_TO_ACT | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3Suspend Array*/ | ||||
| struct wlan_pwr_cfg rtl8723B_suspend_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 					  RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 					  RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723B_TRANS_CARDEMU_TO_SUS | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Resume Array*/ | ||||
| struct wlan_pwr_cfg rtl8723B_resume_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 					 RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 					 RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_SUS_TO_CARDEMU | ||||
| 	RTL8723B_TRANS_CARDEMU_TO_ACT | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3HWPDN Array*/ | ||||
| struct wlan_pwr_cfg rtl8723B_hwpdn_flow[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 					RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 					RTL8723B_TRANS_END_STEPS] = { | ||||
| 	RTL8723B_TRANS_ACT_TO_CARDEMU | ||||
| 	RTL8723B_TRANS_CARDEMU_TO_PDN | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Enter LPS */ | ||||
| struct wlan_pwr_cfg rtl8723B_enter_lps_flow[RTL8723B_TRANS_ACT_TO_LPS_STEPS + | ||||
| 					    RTL8723B_TRANS_END_STEPS] = { | ||||
| 	/*FW behavior*/ | ||||
| 	RTL8723B_TRANS_ACT_TO_LPS | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
| 
 | ||||
| /*3 Leave LPS */ | ||||
| struct wlan_pwr_cfg rtl8723B_leave_lps_flow[RTL8723B_TRANS_LPS_TO_ACT_STEPS + | ||||
| 					    RTL8723B_TRANS_END_STEPS] = { | ||||
| 	/*FW behavior*/ | ||||
| 	RTL8723B_TRANS_LPS_TO_ACT | ||||
| 	RTL8723B_TRANS_END | ||||
| }; | ||||
							
								
								
									
										423
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/pwrseq.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										423
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/pwrseq.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,423 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_PWRSEQ_H__ | ||||
| #define __RTL8723BE_PWRSEQ_H__ | ||||
| 
 | ||||
| #include "../pwrseqcmd.h" | ||||
| /**
 | ||||
|  *	Check document WM-20130425-JackieLau-RTL8723B_Power_Architecture v05.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	RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS	23 | ||||
| #define	RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS	15 | ||||
| #define	RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS	15 | ||||
| #define	RTL8723B_TRANS_SUS_TO_CARDEMU_STEPS	15 | ||||
| #define	RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS	15 | ||||
| #define	RTL8723B_TRANS_PDN_TO_CARDEMU_STEPS	15 | ||||
| #define	RTL8723B_TRANS_ACT_TO_LPS_STEPS		15 | ||||
| #define	RTL8723B_TRANS_LPS_TO_ACT_STEPS		15 | ||||
| #define	RTL8723B_TRANS_END_STEPS		1 | ||||
| 
 | ||||
| #define RTL8723B_TRANS_CARDEMU_TO_ACT					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* {offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value}, */\ | ||||
| 	/*0x20[0] = 1b'1 enable LDOA12 MACRO block for all interface*/  \ | ||||
| 	{0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK,				\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)},		\ | ||||
| 	/*0x67[0] = 0 to disable BT_GPS_SEL pins*/			\ | ||||
| 	{0x0067, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK,				\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0},			\ | ||||
| 	/*Delay 1ms*/							\ | ||||
| 	{0x0001, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK,				\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_DELAY, 1, PWRSEQ_DELAY_MS},		\ | ||||
| 	/*0x00[5] = 1b'0 release analog Ips to digital ,1:isolation*/   \ | ||||
| 	{0x0000, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK,				\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(5), 0},			\ | ||||
| 	/* disable SW LPS 0x04[10]=0 and WLSUS_EN 0x04[11]=0*/		\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, (BIT(4)|BIT(3)|BIT(2)), 0},	\ | ||||
| 	/* Disable USB suspend */					\ | ||||
| 	{0x0075, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0) , BIT(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)},		\ | ||||
| 	/* Enable USB suspend */					\ | ||||
| 	{0x0075, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0) , 0},			\ | ||||
| 	/* 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},			\ | ||||
| 	/* Enable WL control XTAL setting*/				\ | ||||
| 	{0x0010, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(6), BIT(6)},		\ | ||||
| 	/*Enable falling edge triggering interrupt*/			\ | ||||
| 	{0x0049, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)},		\ | ||||
| 	/*Enable GPIO9 interrupt mode*/					\ | ||||
| 	{0x0063, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)},		\ | ||||
| 	/*Enable GPIO9 input mode*/					\ | ||||
| 	{0x0062, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},			\ | ||||
| 	/*Enable HSISR GPIO[C:0] interrupt*/				\ | ||||
| 	{0x0058, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)},		\ | ||||
| 	/*Enable HSISR GPIO9 interrupt*/				\ | ||||
| 	{0x005A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)},		\ | ||||
| 	/*For GPIO9 internal pull high setting by test chip*/		\ | ||||
| 	{0x0068, PWR_CUT_TESTCHIP_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3), BIT(3)},		\ | ||||
| 	/*For GPIO9 internal pull high setting*/			\ | ||||
| 	{0x0069, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(6), BIT(6)}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_ACT_TO_CARDEMU					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*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},			\ | ||||
| 	/*0x4C[24] = 0x4F[0] = 0, */					\ | ||||
| 	/*switch DPDT_SEL_P output from register 0x65[2] */		\ | ||||
| 	{0x004F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},			\ | ||||
| 	/*Enable rising edge triggering interrupt*/			\ | ||||
| 	{0x0049, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},			\ | ||||
| 	 /*0x04[9] = 1 turn off MAC by HW state machine*/		\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)},		\ | ||||
| 	 /*wait till 0x04[9] = 0 polling until return 0 to disable*/	\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), 0},			\ | ||||
| 	/* Enable BT control XTAL setting*/				\ | ||||
| 	{0x0010, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(6), 0},			\ | ||||
| 	/*0x00[5] = 1b'1 analog Ips to digital ,1:isolation*/		\ | ||||
| 	{0x0000, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC,	\ | ||||
| 	 PWR_CMD_WRITE, BIT(5), BIT(5)},				\ | ||||
| 	/*0x20[0] = 1b'0 disable LDOA12 MACRO block*/			\ | ||||
| 	{0x0020, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_USB_MSK | PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC,	\ | ||||
| 	 PWR_CMD_WRITE, BIT(0), 0}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_CARDEMU_TO_SUS					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value },*/\ | ||||
| 	/*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)},			\ | ||||
| 	/*0x23[4] = 1b'1 12H LDO enter sleep mode*/			\ | ||||
| 	{0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)},		\ | ||||
| 	/*0x07[7:0] = 0x20 SDIO SOP option to disable BG/MB/ACK/SWR*/   \ | ||||
| 	{0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x20},			\ | ||||
| 	/*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}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_SUS_TO_CARDEMU					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*clear suspend enable and power down enable*/			\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3) | BIT(7), 0},		\ | ||||
| 	/*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)},		\ | ||||
| 	/*0x23[4] = 1b'0 12H LDO enter normal mode*/			\ | ||||
| 	{0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0},			\ | ||||
| 	/*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}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_CARDEMU_TO_CARDDIS				\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*0x07=0x20 , SOP option to disable BG/MB*/			\ | ||||
| 	{0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x20},			\ | ||||
| 	/*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)},		\ | ||||
| 	/*0x48[16] = 1 to enable GPIO9 as EXT WAKEUP*/			\ | ||||
| 	{0x004A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 1},			\ | ||||
| 	/*0x23[4] = 1b'1 12H LDO enter sleep mode*/			\ | ||||
| 	{0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 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}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_CARDDIS_TO_CARDEMU				\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*clear suspend enable and power down enable*/			\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3) | BIT(7), 0},		\ | ||||
| 	/*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)},		\ | ||||
| 	/*0x48[16] = 0 to disable GPIO9 as EXT WAKEUP*/			\ | ||||
| 	{0x004A, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},			\ | ||||
| 	/*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},		\ | ||||
| 	/*0x23[4] = 1b'0 12H LDO enter normal mode*/			\ | ||||
| 	{0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0},			\ | ||||
| 	/*PCIe DMA start*/						\ | ||||
| 	{0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_CARDEMU_TO_PDN					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*0x23[4] = 1b'1 12H LDO enter sleep mode*/			\ | ||||
| 	{0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)},		\ | ||||
| 	/*0x07[7:0] = 0x20 SOP option to disable BG/MB/ACK/SWR*/	\ | ||||
| 	{0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,			\ | ||||
| 	 PWR_INTF_SDIO_MSK | PWR_INTF_USB_MSK, PWR_BASEADDR_MAC,	\ | ||||
| 	 PWR_CMD_WRITE, 0xFF, 0x20},					\ | ||||
| 	/* 0x04[16] = 0*/						\ | ||||
| 	{0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},			\ | ||||
| 	/* 0x04[15] = 1*/						\ | ||||
| 	{0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), BIT(7)}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_PDN_TO_CARDEMU					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/* 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}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_ACT_TO_LPS					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*PCIe DMA stop*/						\ | ||||
| 	{0x0301, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF},			\ | ||||
| 	/*Tx Pause*/							\ | ||||
| 	{0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF},			\ | ||||
| 	/*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},			\ | ||||
| 	/*Delay 1us*/							\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US},		\ | ||||
| 	/*Whole BB is reset*/						\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},			\ | ||||
| 	/*Reset MAC TRX*/						\ | ||||
| 	{0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x03},			\ | ||||
| 	/*check if removed later*/					\ | ||||
| 	{0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},			\ | ||||
| 	/*When driver enter Sus/ Disable, enable LOP for BT*/		\ | ||||
| 	{0x0093, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x00},			\ | ||||
| 	/*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 RTL8723B_TRANS_LPS_TO_ACT					\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	/*SDIO RPWM*/							\ | ||||
| 	{0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK,	\ | ||||
| 	 PWR_BASEADDR_SDIO, PWR_CMD_WRITE, 0xFF, 0x84},			\ | ||||
| 	/*USB RPWM*/							\ | ||||
| 	{0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84},			\ | ||||
| 	/*PCIe RPWM*/							\ | ||||
| 	{0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84},			\ | ||||
| 	/*Delay*/							\ | ||||
| 	{0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS},		\ | ||||
| 	/*.	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)}, \ | ||||
| 	/*.	0x522 = 0*/						\ | ||||
| 	{0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,	\ | ||||
| 	 PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, | ||||
| 
 | ||||
| #define RTL8723B_TRANS_END						\ | ||||
| 	/* format */							\ | ||||
| 	/* comments here */						\ | ||||
| 	/* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, */\ | ||||
| 	{0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, 0,	\ | ||||
| 	 PWR_CMD_END, 0, 0}, | ||||
| 
 | ||||
| extern struct wlan_pwr_cfg rtl8723B_power_on_flow | ||||
| 				[RTL8723B_TRANS_CARDEMU_TO_ACT_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_radio_off_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_card_disable_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_card_enable_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_suspend_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_resume_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_SUS_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_hwpdn_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_CARDEMU_STEPS + | ||||
| 				 RTL8723B_TRANS_CARDEMU_TO_PDN_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_enter_lps_flow | ||||
| 				[RTL8723B_TRANS_ACT_TO_LPS_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| extern struct wlan_pwr_cfg rtl8723B_leave_lps_flow | ||||
| 				[RTL8723B_TRANS_LPS_TO_ACT_STEPS + | ||||
| 				 RTL8723B_TRANS_END_STEPS]; | ||||
| 
 | ||||
| /* RTL8723 Power Configuration CMDs for PCIe interface */ | ||||
| #define RTL8723_NIC_PWR_ON_FLOW		rtl8723B_power_on_flow | ||||
| #define RTL8723_NIC_RF_OFF_FLOW		rtl8723B_radio_off_flow | ||||
| #define RTL8723_NIC_DISABLE_FLOW	rtl8723B_card_disable_flow | ||||
| #define RTL8723_NIC_ENABLE_FLOW		rtl8723B_card_enable_flow | ||||
| #define RTL8723_NIC_SUSPEND_FLOW	rtl8723B_suspend_flow | ||||
| #define RTL8723_NIC_RESUME_FLOW		rtl8723B_resume_flow | ||||
| #define RTL8723_NIC_PDN_FLOW		rtl8723B_hwpdn_flow | ||||
| #define RTL8723_NIC_LPS_ENTER_FLOW	rtl8723B_enter_lps_flow | ||||
| #define RTL8723_NIC_LPS_LEAVE_FLOW	rtl8723B_leave_lps_flow | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										2295
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/reg.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										2295
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/reg.h
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										512
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/rf.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										512
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/rf.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,512 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 _rtl8723be_phy_rf6052_config_parafile(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| void rtl8723be_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) | BIT(10) | BIT(11)); | ||||
| 		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) | BIT(10)); | ||||
| 		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 rtl8723be_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; | ||||
| 	u8 direction; | ||||
| 	u32 pwrtrac_value; | ||||
| 
 | ||||
| 	if (rtlefuse->eeprom_regulatory != 0) | ||||
| 		turbo_scanoff = true; | ||||
| 
 | ||||
| 	if (mac->act_scanning) { | ||||
| 		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++; | ||||
| 		} | ||||
| 	} | ||||
| 	rtl8723be_dm_txpower_track_adjust(hw, 1, &direction, &pwrtrac_value); | ||||
| 	if (direction == 1) { | ||||
| 		tx_agc[0] += pwrtrac_value; | ||||
| 		tx_agc[1] += pwrtrac_value; | ||||
| 	} else if (direction == 2) { | ||||
| 		tx_agc[0] -= pwrtrac_value; | ||||
| 		tx_agc[1] -= pwrtrac_value; | ||||
| 	} | ||||
| 	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 rtl8723be_phy_get_power_base(struct ieee80211_hw *hw, | ||||
| 					 u8 *ppowerlevel_ofdm, | ||||
| 					 u8 *ppowerlevel_bw20, | ||||
| 					 u8 *ppowerlevel_bw40, | ||||
| 					 u8 channel, u32 *ofdmbase, | ||||
| 					 u32 *mcsbase) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_phy *rtlphy = &(rtlpriv->phy); | ||||
| 	u32 powerbase0, powerbase1; | ||||
| 	u8 i, powerlevel[2]; | ||||
| 
 | ||||
| 	for (i = 0; i < 2; i++) { | ||||
| 		powerbase0 = ppowerlevel_ofdm[i]; | ||||
| 
 | ||||
| 		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) | ||||
| 			powerlevel[i] = ppowerlevel_bw20[i]; | ||||
| 		else | ||||
| 			powerlevel[i] = ppowerlevel_bw40[i]; | ||||
| 
 | ||||
| 		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 _rtl8723be_get_txpower_writeval_by_regulatory( | ||||
| 							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], pwr_diff = 0, customer_pwr_diff; | ||||
| 	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->pwrgroup_cnt == 1) { | ||||
| 				chnlgroup = 0; | ||||
| 			} else { | ||||
| 				if (channel < 3) | ||||
| 					chnlgroup = 0; | ||||
| 				else if (channel < 6) | ||||
| 					chnlgroup = 1; | ||||
| 				else if (channel < 9) | ||||
| 					chnlgroup = 2; | ||||
| 				else if (channel < 12) | ||||
| 					chnlgroup = 3; | ||||
| 				else if (channel < 14) | ||||
| 					chnlgroup = 4; | ||||
| 				else if (channel == 14) | ||||
| 					chnlgroup = 5; | ||||
| 			} | ||||
| 
 | ||||
| 			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]); | ||||
| 			} | ||||
| 
 | ||||
| 			if (index < 2) | ||||
| 				pwr_diff = | ||||
| 				    rtlefuse->txpwr_legacyhtdiff[rf][channel-1]; | ||||
| 			else if (rtlphy->current_chan_bw == | ||||
| 				 HT_CHANNEL_WIDTH_20) | ||||
| 				pwr_diff = | ||||
| 				    rtlefuse->txpwr_ht20diff[rf][channel-1]; | ||||
| 
 | ||||
| 			if (rtlphy->current_chan_bw == HT_CHANNEL_WIDTH_20_40) | ||||
| 				customer_pwr_diff = | ||||
| 					rtlefuse->pwrgroup_ht40[rf][channel-1]; | ||||
| 			else | ||||
| 				customer_pwr_diff = | ||||
| 					rtlefuse->pwrgroup_ht20[rf][channel-1]; | ||||
| 
 | ||||
| 			if (pwr_diff > customer_pwr_diff) | ||||
| 				pwr_diff = 0; | ||||
| 			else | ||||
| 				pwr_diff = customer_pwr_diff - pwr_diff; | ||||
| 
 | ||||
| 			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 (pwr_diff_limit[i] > pwr_diff) | ||||
| 						pwr_diff_limit[i] = pwr_diff; | ||||
| 			} | ||||
| 
 | ||||
| 			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 _rtl8723be_write_ofdm_power_reg(struct ieee80211_hw *hw, | ||||
| 					 u8 index, u32 *pvalue) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	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); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_phy_rf6052_set_ofdm_txpower(struct ieee80211_hw *hw, | ||||
| 					   u8 *ppowerlevel_ofdm, | ||||
| 					   u8 *ppowerlevel_bw20, | ||||
| 					   u8 *ppowerlevel_bw40, u8 channel) | ||||
| { | ||||
| 	u32 writeval[2], powerbase0[2], powerbase1[2]; | ||||
| 	u8 index; | ||||
| 	u8 direction; | ||||
| 	u32 pwrtrac_value; | ||||
| 
 | ||||
| 	rtl8723be_phy_get_power_base(hw, ppowerlevel_ofdm, ppowerlevel_bw20, | ||||
| 				     ppowerlevel_bw40, channel, | ||||
| 				     &powerbase0[0], &powerbase1[0]); | ||||
| 
 | ||||
| 	rtl8723be_dm_txpower_track_adjust(hw, 1, &direction, &pwrtrac_value); | ||||
| 
 | ||||
| 	for (index = 0; index < 6; index++) { | ||||
| 		_rtl8723be_get_txpower_writeval_by_regulatory(hw, | ||||
| 							      channel, index, | ||||
| 							      &powerbase0[0], | ||||
| 							      &powerbase1[0], | ||||
| 							      &writeval[0]); | ||||
| 		if (direction == 1) { | ||||
| 			writeval[0] += pwrtrac_value; | ||||
| 			writeval[1] += pwrtrac_value; | ||||
| 		} else if (direction == 2) { | ||||
| 			writeval[0] -= pwrtrac_value; | ||||
| 			writeval[1] -= pwrtrac_value; | ||||
| 		} | ||||
| 		_rtl8723be_write_ofdm_power_reg(hw, index, &writeval[0]); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| bool rtl8723be_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 _rtl8723be_phy_rf6052_config_parafile(hw); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| static bool _rtl8723be_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 = rtl8723be_phy_config_rf_with_headerfile(hw, | ||||
| 						      (enum radio_path)rfpath); | ||||
| 			break; | ||||
| 		case RF90_PATH_B: | ||||
| 			rtstatus = rtl8723be_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) { | ||||
| 			RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, | ||||
| 				 "Radio[%d] Fail!!", rfpath); | ||||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "\n"); | ||||
| 	return rtstatus; | ||||
| } | ||||
							
								
								
									
										43
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/rf.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/rf.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_RF_H__ | ||||
| #define __RTL8723BE_RF_H__ | ||||
| 
 | ||||
| #define RF6052_MAX_TX_PWR		0x3F | ||||
| #define RF6052_MAX_REG			0x3F | ||||
| 
 | ||||
| void rtl8723be_phy_rf6052_set_bandwidth(struct ieee80211_hw *hw, | ||||
| 					u8 bandwidth); | ||||
| void rtl8723be_phy_rf6052_set_cck_txpower(struct ieee80211_hw *hw, | ||||
| 					  u8 *ppowerlevel); | ||||
| void rtl8723be_phy_rf6052_set_ofdm_txpower(struct ieee80211_hw *hw, | ||||
| 					   u8 *ppowerlevel_ofdm, | ||||
| 					   u8 *ppowerlevel_bw20, | ||||
| 					   u8 *ppowerlevel_bw40, | ||||
| 					   u8 channel); | ||||
| bool rtl8723be_phy_rf6052_config(struct ieee80211_hw *hw); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										407
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/sw.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										407
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/sw.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,407 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 "../rtl8723com/phy_common.h" | ||||
| #include "dm.h" | ||||
| #include "../rtl8723com/dm_common.h" | ||||
| #include "hw.h" | ||||
| #include "fw.h" | ||||
| #include "../rtl8723com/fw_common.h" | ||||
| #include "sw.h" | ||||
| #include "trx.h" | ||||
| #include "led.h" | ||||
| #include "table.h" | ||||
| #include "../btcoexist/rtl_btc.h" | ||||
| 
 | ||||
| #include <linux/vmalloc.h> | ||||
| #include <linux/module.h> | ||||
| 
 | ||||
| static void rtl8723be_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 rtl8723be_init_sw_vars(struct ieee80211_hw *hw) | ||||
| { | ||||
| 	int err = 0; | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); | ||||
| 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); | ||||
| 
 | ||||
| 	rtl8723be_bt_reg_init(hw); | ||||
| 	rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; | ||||
| 	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(15) | BIT(24) | BIT(25); | ||||
| 
 | ||||
| 	rtlpriv->phy.lck_inprogress = false; | ||||
| 
 | ||||
| 	mac->ht_enable = true; | ||||
| 
 | ||||
| 	/* 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) (IMR_PSTIMEOUT	| | ||||
| 				     IMR_HSISR_IND_ON_INT	| | ||||
| 				     IMR_C2HCMD		| | ||||
| 				     IMR_HIGHDOK	| | ||||
| 				     IMR_MGNTDOK	| | ||||
| 				     IMR_BKDOK		| | ||||
| 				     IMR_BEDOK		| | ||||
| 				     IMR_VIDOK		| | ||||
| 				     IMR_VODOK		| | ||||
| 				     IMR_RDU		| | ||||
| 				     IMR_ROK		| | ||||
| 				     0); | ||||
| 
 | ||||
| 	rtlpci->irq_mask[1] = (u32)(IMR_RXFOVW | 0); | ||||
| 
 | ||||
| 	rtlpci->sys_irq_mask = (u32)(HSIMR_PDN_INT_EN	| | ||||
| 				     HSIMR_RON_INT_EN	| | ||||
| 				     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; | ||||
| 	rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support; | ||||
| 	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; | ||||
| 	/* for ASPM, you can close aspm through
 | ||||
| 	 * set const_support_pciaspm = 0 | ||||
| 	 */ | ||||
| 	rtl8723be_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; | ||||
| 
 | ||||
| 	/*low power: Disable 32k */ | ||||
| 	rtlpriv->psc.low_power_enable = false; | ||||
| 
 | ||||
| 	rtlpriv->rtlhal.earlymode_enable = false; | ||||
| 
 | ||||
| 	/* for firmware buf */ | ||||
| 	rtlpriv->rtlhal.pfirmware = vzalloc(0x8000); | ||||
| 	if (!rtlpriv->rtlhal.pfirmware) { | ||||
| 		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, | ||||
| 			 "Can't alloc buffer for fw.\n"); | ||||
| 		return 1; | ||||
| 	} | ||||
| 
 | ||||
| 	rtlpriv->max_fw_size = 0x8000; | ||||
| 	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 rtl8723be_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 rtl8723be_get_btc_status(void) | ||||
| { | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| static bool is_fw_header(struct rtl8723e_firmware_header *hdr) | ||||
| { | ||||
| 	return (hdr->signature & 0xfff0) == 0x5300; | ||||
| } | ||||
| 
 | ||||
| static struct rtl_hal_ops rtl8723be_hal_ops = { | ||||
| 	.init_sw_vars = rtl8723be_init_sw_vars, | ||||
| 	.deinit_sw_vars = rtl8723be_deinit_sw_vars, | ||||
| 	.read_eeprom_info = rtl8723be_read_eeprom_info, | ||||
| 	.interrupt_recognized = rtl8723be_interrupt_recognized, | ||||
| 	.hw_init = rtl8723be_hw_init, | ||||
| 	.hw_disable = rtl8723be_card_disable, | ||||
| 	.hw_suspend = rtl8723be_suspend, | ||||
| 	.hw_resume = rtl8723be_resume, | ||||
| 	.enable_interrupt = rtl8723be_enable_interrupt, | ||||
| 	.disable_interrupt = rtl8723be_disable_interrupt, | ||||
| 	.set_network_type = rtl8723be_set_network_type, | ||||
| 	.set_chk_bssid = rtl8723be_set_check_bssid, | ||||
| 	.set_qos = rtl8723be_set_qos, | ||||
| 	.set_bcn_reg = rtl8723be_set_beacon_related_registers, | ||||
| 	.set_bcn_intv = rtl8723be_set_beacon_interval, | ||||
| 	.update_interrupt_mask = rtl8723be_update_interrupt_mask, | ||||
| 	.get_hw_reg = rtl8723be_get_hw_reg, | ||||
| 	.set_hw_reg = rtl8723be_set_hw_reg, | ||||
| 	.update_rate_tbl = rtl8723be_update_hal_rate_tbl, | ||||
| 	.fill_tx_desc = rtl8723be_tx_fill_desc, | ||||
| 	.fill_tx_cmddesc = rtl8723be_tx_fill_cmddesc, | ||||
| 	.query_rx_desc = rtl8723be_rx_query_desc, | ||||
| 	.set_channel_access = rtl8723be_update_channel_access_setting, | ||||
| 	.radio_onoff_checking = rtl8723be_gpio_radio_on_off_checking, | ||||
| 	.set_bw_mode = rtl8723be_phy_set_bw_mode, | ||||
| 	.switch_channel = rtl8723be_phy_sw_chnl, | ||||
| 	.dm_watchdog = rtl8723be_dm_watchdog, | ||||
| 	.scan_operation_backup = rtl8723be_phy_scan_operation_backup, | ||||
| 	.set_rf_power_state = rtl8723be_phy_set_rf_power_state, | ||||
| 	.led_control = rtl8723be_led_control, | ||||
| 	.set_desc = rtl8723be_set_desc, | ||||
| 	.get_desc = rtl8723be_get_desc, | ||||
| 	.is_tx_desc_closed = rtl8723be_is_tx_desc_closed, | ||||
| 	.tx_polling = rtl8723be_tx_polling, | ||||
| 	.enable_hw_sec = rtl8723be_enable_hw_security_config, | ||||
| 	.set_key = rtl8723be_set_key, | ||||
| 	.init_sw_leds = rtl8723be_init_sw_leds, | ||||
| 	.get_bbreg = rtl8723_phy_query_bb_reg, | ||||
| 	.set_bbreg = rtl8723_phy_set_bb_reg, | ||||
| 	.get_rfreg = rtl8723be_phy_query_rf_reg, | ||||
| 	.set_rfreg = rtl8723be_phy_set_rf_reg, | ||||
| 	.fill_h2c_cmd = rtl8723be_fill_h2c_cmd, | ||||
| 	.get_btc_status = rtl8723be_get_btc_status, | ||||
| 	.rx_command_packet = rtl8723be_rx_command_packet, | ||||
| 	.is_fw_header = is_fw_header, | ||||
| }; | ||||
| 
 | ||||
| static struct rtl_mod_params rtl8723be_mod_params = { | ||||
| 	.sw_crypto = false, | ||||
| 	.inactiveps = true, | ||||
| 	.swctrl_lps = false, | ||||
| 	.fwctrl_lps = true, | ||||
| }; | ||||
| 
 | ||||
| static struct rtl_hal_cfg rtl8723be_hal_cfg = { | ||||
| 	.bar_id = 2, | ||||
| 	.write_readback = true, | ||||
| 	.name = "rtl8723be_pci", | ||||
| 	.fw_name = "rtlwifi/rtl8723befw.bin", | ||||
| 	.ops = &rtl8723be_hal_ops, | ||||
| 	.mod_params = &rtl8723be_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[MAC_HSISR] = REG_HSISR, | ||||
| 
 | ||||
| 	.maps[EFUSE_ACCESS] = REG_EFUSE_ACCESS, | ||||
| 
 | ||||
| 	.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,     */   /*need check*/ | ||||
| 	.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] = IMR_TXFOVW, | ||||
| 	.maps[RTL_IMR_PSTIMEOUT] = IMR_PSTIMEOUT, | ||||
| 	.maps[RTL_IMR_BCNINT] = IMR_BCNDMAINT0, | ||||
| 	.maps[RTL_IMR_RXFOVW] = IMR_RXFOVW, | ||||
| 	.maps[RTL_IMR_RDU] = IMR_RDU, | ||||
| 	.maps[RTL_IMR_ATIMEND] = IMR_ATIMEND, | ||||
| 	.maps[RTL_IMR_BDOK] = IMR_BCNDOK0, | ||||
| 	.maps[RTL_IMR_MGNTDOK] = IMR_MGNTDOK, | ||||
| 	.maps[RTL_IMR_TBDER] = IMR_TBDER, | ||||
| 	.maps[RTL_IMR_HIGHDOK] = IMR_HIGHDOK, | ||||
| 	.maps[RTL_IMR_TBDOK] = IMR_TBDOK, | ||||
| 	.maps[RTL_IMR_BKDOK] = IMR_BKDOK, | ||||
| 	.maps[RTL_IMR_BEDOK] = IMR_BEDOK, | ||||
| 	.maps[RTL_IMR_VIDOK] = IMR_VIDOK, | ||||
| 	.maps[RTL_IMR_VODOK] = IMR_VODOK, | ||||
| 	.maps[RTL_IMR_ROK] = IMR_ROK, | ||||
| 	.maps[RTL_IMR_HSISR_IND] = IMR_HSISR_IND_ON_INT, | ||||
| 	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNDMAINT0 | IMR_TBDOK | IMR_TBDER), | ||||
| 
 | ||||
| 	.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 rtl8723be_pci_ids[] = { | ||||
| 	{RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xB723, rtl8723be_hal_cfg)}, | ||||
| 	{}, | ||||
| }; | ||||
| 
 | ||||
| MODULE_DEVICE_TABLE(pci, rtl8723be_pci_ids); | ||||
| 
 | ||||
| MODULE_AUTHOR("PageHe	<page_he@realsil.com.cn>"); | ||||
| MODULE_AUTHOR("Realtek WlanFAE	<wlanfae@realtek.com>"); | ||||
| MODULE_LICENSE("GPL"); | ||||
| MODULE_DESCRIPTION("Realtek 8723BE 802.11n PCI wireless"); | ||||
| MODULE_FIRMWARE("rtlwifi/rtl8723befw.bin"); | ||||
| 
 | ||||
| module_param_named(swenc, rtl8723be_mod_params.sw_crypto, bool, 0444); | ||||
| module_param_named(debug, rtl8723be_mod_params.debug, int, 0444); | ||||
| module_param_named(ips, rtl8723be_mod_params.inactiveps, bool, 0444); | ||||
| module_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444); | ||||
| module_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444); | ||||
| module_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog, | ||||
| 		   bool, 0444); | ||||
| MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n"); | ||||
| MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n"); | ||||
| MODULE_PARM_DESC(fwlps, "using linked fw control power save (default 1 is open)\n"); | ||||
| MODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\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 rtl8723be_driver = { | ||||
| 	.name = KBUILD_MODNAME, | ||||
| 	.id_table = rtl8723be_pci_ids, | ||||
| 	.probe = rtl_pci_probe, | ||||
| 	.remove = rtl_pci_disconnect, | ||||
| 	.driver.pm = &rtlwifi_pm_ops, | ||||
| }; | ||||
| 
 | ||||
| module_pci_driver(rtl8723be_driver); | ||||
							
								
								
									
										35
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/sw.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/sw.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_SW_H__ | ||||
| #define __RTL8723BE_SW_H__ | ||||
| 
 | ||||
| int rtl8723be_init_sw_vars(struct ieee80211_hw *hw); | ||||
| void rtl8723be_deinit_sw_vars(struct ieee80211_hw *hw); | ||||
| void rtl8723be_init_var_map(struct ieee80211_hw *hw); | ||||
| bool rtl8723be_get_btc_status(void); | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										577
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/table.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										577
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/table.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,577 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 RTL8723BEPHY_REG_1TARRAY[] = { | ||||
| 		0x800, 0x80040000, | ||||
| 		0x804, 0x00000003, | ||||
| 		0x808, 0x0000FC00, | ||||
| 		0x80C, 0x0000000A, | ||||
| 		0x810, 0x10001331, | ||||
| 		0x814, 0x020C3D10, | ||||
| 		0x818, 0x02200385, | ||||
| 		0x81C, 0x00000000, | ||||
| 		0x820, 0x01000100, | ||||
| 		0x824, 0x00390204, | ||||
| 		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, 0x569A11A9, | ||||
| 		0x85C, 0x01000014, | ||||
| 		0x860, 0x66F60110, | ||||
| 		0x864, 0x061F0649, | ||||
| 		0x868, 0x00000000, | ||||
| 		0x86C, 0x27272700, | ||||
| 		0x870, 0x07000760, | ||||
| 		0x874, 0x25004000, | ||||
| 		0x878, 0x00000808, | ||||
| 		0x87C, 0x00000000, | ||||
| 		0x880, 0xB0000C1C, | ||||
| 		0x884, 0x00000001, | ||||
| 		0x888, 0x00000000, | ||||
| 		0x88C, 0xCCC000C0, | ||||
| 		0x890, 0x00000800, | ||||
| 		0x894, 0xFFFFFFFE, | ||||
| 		0x898, 0x40302010, | ||||
| 		0x89C, 0x00706050, | ||||
| 		0x900, 0x00000000, | ||||
| 		0x904, 0x00000023, | ||||
| 		0x908, 0x00000000, | ||||
| 		0x90C, 0x81121111, | ||||
| 		0x910, 0x00000002, | ||||
| 		0x914, 0x00000201, | ||||
| 		0x948, 0x00000280, | ||||
| 		0xA00, 0x00D047C8, | ||||
| 		0xA04, 0x80FF000C, | ||||
| 		0xA08, 0x8C838300, | ||||
| 		0xA0C, 0x2E7F120F, | ||||
| 		0xA10, 0x9500BB78, | ||||
| 		0xA14, 0x1114D028, | ||||
| 		0xA18, 0x00881117, | ||||
| 		0xA1C, 0x89140F00, | ||||
| 		0xA20, 0x1A1B0000, | ||||
| 		0xA24, 0x090E1317, | ||||
| 		0xA28, 0x00000204, | ||||
| 		0xA2C, 0x00D30000, | ||||
| 		0xA70, 0x101FBF00, | ||||
| 		0xA74, 0x00000007, | ||||
| 		0xA78, 0x00000900, | ||||
| 		0xA7C, 0x225B0606, | ||||
| 		0xA80, 0x21806490, | ||||
| 		0xB2C, 0x00000000, | ||||
| 		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, 0x469652AF, | ||||
| 		0xC38, 0x49795994, | ||||
| 		0xC3C, 0x0A97971C, | ||||
| 		0xC40, 0x1F7C403F, | ||||
| 		0xC44, 0x000100B7, | ||||
| 		0xC48, 0xEC020107, | ||||
| 		0xC4C, 0x007F037F, | ||||
| 		0xC50, 0x69553420, | ||||
| 		0xC54, 0x43BC0094, | ||||
| 		0xC58, 0x00023169, | ||||
| 		0xC5C, 0x00250492, | ||||
| 		0xC60, 0x00000000, | ||||
| 		0xC64, 0x7112848B, | ||||
| 		0xC68, 0x47C00BFF, | ||||
| 		0xC6C, 0x00000036, | ||||
| 		0xC70, 0x2C7F000D, | ||||
| 		0xC74, 0x020610DB, | ||||
| 		0xC78, 0x0000001F, | ||||
| 		0xC7C, 0x00B91612, | ||||
| 		0xC80, 0x390000E4, | ||||
| 		0xC84, 0x20F60000, | ||||
| 		0xC88, 0x40000100, | ||||
| 		0xC8C, 0x20200000, | ||||
| 		0xC90, 0x00020E1A, | ||||
| 		0xC94, 0x00000000, | ||||
| 		0xC98, 0x00020E1A, | ||||
| 		0xC9C, 0x00007F7F, | ||||
| 		0xCA0, 0x00000000, | ||||
| 		0xCA4, 0x000300A0, | ||||
| 		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, 0x00000740, | ||||
| 		0xD04, 0x40020401, | ||||
| 		0xD08, 0x0000907F, | ||||
| 		0xD0C, 0x20010201, | ||||
| 		0xD10, 0xA0633333, | ||||
| 		0xD14, 0x3333BC53, | ||||
| 		0xD18, 0x7A8F5B6F, | ||||
| 		0xD2C, 0xCC979975, | ||||
| 		0xD30, 0x00000000, | ||||
| 		0xD34, 0x80608000, | ||||
| 		0xD38, 0x00000000, | ||||
| 		0xD3C, 0x00127353, | ||||
| 		0xD40, 0x00000000, | ||||
| 		0xD44, 0x00000000, | ||||
| 		0xD48, 0x00000000, | ||||
| 		0xD4C, 0x00000000, | ||||
| 		0xD50, 0x6437140A, | ||||
| 		0xD54, 0x00000000, | ||||
| 		0xD58, 0x00000282, | ||||
| 		0xD5C, 0x30032064, | ||||
| 		0xD60, 0x4653DE68, | ||||
| 		0xD64, 0x04518A3C, | ||||
| 		0xD68, 0x00002101, | ||||
| 		0xD6C, 0x2A201C16, | ||||
| 		0xD70, 0x1812362E, | ||||
| 		0xD74, 0x322C2220, | ||||
| 		0xD78, 0x000E3C24, | ||||
| 		0xE00, 0x2D2D2D2D, | ||||
| 		0xE04, 0x2D2D2D2D, | ||||
| 		0xE08, 0x0390272D, | ||||
| 		0xE10, 0x2D2D2D2D, | ||||
| 		0xE14, 0x2D2D2D2D, | ||||
| 		0xE18, 0x2D2D2D2D, | ||||
| 		0xE1C, 0x2D2D2D2D, | ||||
| 		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, 0x001B2556, | ||||
| 		0xE6C, 0x00C00096, | ||||
| 		0xE70, 0x00C00096, | ||||
| 		0xE74, 0x01000056, | ||||
| 		0xE78, 0x01000014, | ||||
| 		0xE7C, 0x01000056, | ||||
| 		0xE80, 0x01000014, | ||||
| 		0xE84, 0x00C00096, | ||||
| 		0xE88, 0x01000056, | ||||
| 		0xE8C, 0x00C00096, | ||||
| 		0xED0, 0x00C00096, | ||||
| 		0xED4, 0x00C00096, | ||||
| 		0xED8, 0x00C00096, | ||||
| 		0xEDC, 0x000000D6, | ||||
| 		0xEE0, 0x000000D6, | ||||
| 		0xEEC, 0x01C00016, | ||||
| 		0xF14, 0x00000003, | ||||
| 		0xF4C, 0x00000000, | ||||
| 		0xF00, 0x00000300, | ||||
| 		0x820, 0x01000100, | ||||
| 		0x800, 0x83040000, | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723BEPHY_REG_ARRAY_PG[] = { | ||||
| 	0, 0, 0, 0x00000e08, 0x0000ff00, 0x00004000, | ||||
| 	0, 0, 0, 0x0000086c, 0xffffff00, 0x34363800, | ||||
| 	0, 0, 0, 0x00000e00, 0xffffffff, 0x42444646, | ||||
| 	0, 0, 0, 0x00000e04, 0xffffffff, 0x30343840, | ||||
| 	0, 0, 0, 0x00000e10, 0xffffffff, 0x38404244, | ||||
| 	0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436 | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723BE_RADIOA_1TARRAY[] = { | ||||
| 		0x000, 0x00010000, | ||||
| 		0x0B0, 0x000DFFE0, | ||||
| 		0x0FE, 0x00000000, | ||||
| 		0x0FE, 0x00000000, | ||||
| 		0x0FE, 0x00000000, | ||||
| 		0x0B1, 0x00000018, | ||||
| 		0x0FE, 0x00000000, | ||||
| 		0x0FE, 0x00000000, | ||||
| 		0x0FE, 0x00000000, | ||||
| 		0x0B2, 0x00084C00, | ||||
| 		0x0B5, 0x0000D2CC, | ||||
| 		0x0B6, 0x000925AA, | ||||
| 		0x0B7, 0x00000010, | ||||
| 		0x0B8, 0x0000907F, | ||||
| 		0x05C, 0x00000002, | ||||
| 		0x07C, 0x00000002, | ||||
| 		0x07E, 0x00000005, | ||||
| 		0x08B, 0x0006FC00, | ||||
| 		0x0B0, 0x000FF9F0, | ||||
| 		0x01C, 0x000739D2, | ||||
| 		0x01E, 0x00000000, | ||||
| 		0x0DF, 0x00000780, | ||||
| 		0x050, 0x00067435, | ||||
| 		0x051, 0x0006B04E, | ||||
| 		0x052, 0x000007D2, | ||||
| 		0x053, 0x00000000, | ||||
| 		0x054, 0x00050400, | ||||
| 		0x055, 0x0004026E, | ||||
| 		0x0DD, 0x0000004C, | ||||
| 		0x070, 0x00067435, | ||||
| 		0x071, 0x0006B04E, | ||||
| 		0x072, 0x000007D2, | ||||
| 		0x073, 0x00000000, | ||||
| 		0x074, 0x00050400, | ||||
| 		0x075, 0x0004026E, | ||||
| 		0x0EF, 0x00000100, | ||||
| 		0x034, 0x0000ADD7, | ||||
| 		0x035, 0x00005C00, | ||||
| 		0x034, 0x00009DD4, | ||||
| 		0x035, 0x00005000, | ||||
| 		0x034, 0x00008DD1, | ||||
| 		0x035, 0x00004400, | ||||
| 		0x034, 0x00007DCE, | ||||
| 		0x035, 0x00003800, | ||||
| 		0x034, 0x00006CD1, | ||||
| 		0x035, 0x00004400, | ||||
| 		0x034, 0x00005CCE, | ||||
| 		0x035, 0x00003800, | ||||
| 		0x034, 0x000048CE, | ||||
| 		0x035, 0x00004400, | ||||
| 		0x034, 0x000034CE, | ||||
| 		0x035, 0x00003800, | ||||
| 		0x034, 0x00002451, | ||||
| 		0x035, 0x00004400, | ||||
| 		0x034, 0x0000144E, | ||||
| 		0x035, 0x00003800, | ||||
| 		0x034, 0x00000051, | ||||
| 		0x035, 0x00004400, | ||||
| 		0x0EF, 0x00000000, | ||||
| 		0x0EF, 0x00000100, | ||||
| 		0x0ED, 0x00000010, | ||||
| 		0x044, 0x0000ADD7, | ||||
| 		0x044, 0x00009DD4, | ||||
| 		0x044, 0x00008DD1, | ||||
| 		0x044, 0x00007DCE, | ||||
| 		0x044, 0x00006CC1, | ||||
| 		0x044, 0x00005CCE, | ||||
| 		0x044, 0x000044D1, | ||||
| 		0x044, 0x000034CE, | ||||
| 		0x044, 0x00002451, | ||||
| 		0x044, 0x0000144E, | ||||
| 		0x044, 0x00000051, | ||||
| 		0x0EF, 0x00000000, | ||||
| 		0x0ED, 0x00000000, | ||||
| 		0x0EF, 0x00002000, | ||||
| 		0x03B, 0x000380EF, | ||||
| 		0x03B, 0x000302FE, | ||||
| 		0x03B, 0x00028CE6, | ||||
| 		0x03B, 0x000200BC, | ||||
| 		0x03B, 0x000188A5, | ||||
| 		0x03B, 0x00010FBC, | ||||
| 		0x03B, 0x00008F71, | ||||
| 		0x03B, 0x00000900, | ||||
| 		0x0EF, 0x00000000, | ||||
| 		0x0ED, 0x00000001, | ||||
| 		0x040, 0x000380EF, | ||||
| 		0x040, 0x000302FE, | ||||
| 		0x040, 0x00028CE6, | ||||
| 		0x040, 0x000200BC, | ||||
| 		0x040, 0x000188A5, | ||||
| 		0x040, 0x00010FBC, | ||||
| 		0x040, 0x00008F71, | ||||
| 		0x040, 0x00000900, | ||||
| 		0x0ED, 0x00000000, | ||||
| 		0x082, 0x00080000, | ||||
| 		0x083, 0x00008000, | ||||
| 		0x084, 0x00048D80, | ||||
| 		0x085, 0x00068000, | ||||
| 		0x0A2, 0x00080000, | ||||
| 		0x0A3, 0x00008000, | ||||
| 		0x0A4, 0x00048D80, | ||||
| 		0x0A5, 0x00068000, | ||||
| 		0x000, 0x00033D80, | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723BEMAC_1T_ARRAY[] = { | ||||
| 		0x02F, 0x00000030, | ||||
| 		0x035, 0x00000000, | ||||
| 		0x067, 0x00000020, | ||||
| 		0x428, 0x0000000A, | ||||
| 		0x429, 0x00000010, | ||||
| 		0x430, 0x00000000, | ||||
| 		0x431, 0x00000000, | ||||
| 		0x432, 0x00000000, | ||||
| 		0x433, 0x00000001, | ||||
| 		0x434, 0x00000004, | ||||
| 		0x435, 0x00000005, | ||||
| 		0x436, 0x00000007, | ||||
| 		0x437, 0x00000008, | ||||
| 		0x43C, 0x00000004, | ||||
| 		0x43D, 0x00000005, | ||||
| 		0x43E, 0x00000007, | ||||
| 		0x43F, 0x00000008, | ||||
| 		0x440, 0x0000005D, | ||||
| 		0x441, 0x00000001, | ||||
| 		0x442, 0x00000000, | ||||
| 		0x444, 0x00000010, | ||||
| 		0x445, 0x00000000, | ||||
| 		0x446, 0x00000000, | ||||
| 		0x447, 0x00000000, | ||||
| 		0x448, 0x00000000, | ||||
| 		0x449, 0x000000F0, | ||||
| 		0x44A, 0x0000000F, | ||||
| 		0x44B, 0x0000003E, | ||||
| 		0x44C, 0x00000010, | ||||
| 		0x44D, 0x00000000, | ||||
| 		0x44E, 0x00000000, | ||||
| 		0x44F, 0x00000000, | ||||
| 		0x450, 0x00000000, | ||||
| 		0x451, 0x000000F0, | ||||
| 		0x452, 0x0000000F, | ||||
| 		0x453, 0x00000000, | ||||
| 		0x456, 0x0000005E, | ||||
| 		0x460, 0x00000066, | ||||
| 		0x461, 0x00000066, | ||||
| 		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, | ||||
| 		0x516, 0x0000000A, | ||||
| 		0x525, 0x0000004F, | ||||
| 		0x550, 0x00000010, | ||||
| 		0x551, 0x00000010, | ||||
| 		0x559, 0x00000002, | ||||
| 		0x55C, 0x00000050, | ||||
| 		0x55D, 0x000000FF, | ||||
| 		0x605, 0x00000030, | ||||
| 		0x608, 0x0000000E, | ||||
| 		0x609, 0x0000002A, | ||||
| 		0x620, 0x000000FF, | ||||
| 		0x621, 0x000000FF, | ||||
| 		0x622, 0x000000FF, | ||||
| 		0x623, 0x000000FF, | ||||
| 		0x624, 0x000000FF, | ||||
| 		0x625, 0x000000FF, | ||||
| 		0x626, 0x000000FF, | ||||
| 		0x627, 0x000000FF, | ||||
| 		0x638, 0x00000050, | ||||
| 		0x63C, 0x0000000A, | ||||
| 		0x63D, 0x0000000A, | ||||
| 		0x63E, 0x0000000E, | ||||
| 		0x63F, 0x0000000E, | ||||
| 		0x640, 0x00000040, | ||||
| 		0x642, 0x00000040, | ||||
| 		0x643, 0x00000000, | ||||
| 		0x652, 0x000000C8, | ||||
| 		0x66E, 0x00000005, | ||||
| 		0x700, 0x00000021, | ||||
| 		0x701, 0x00000043, | ||||
| 		0x702, 0x00000065, | ||||
| 		0x703, 0x00000087, | ||||
| 		0x708, 0x00000021, | ||||
| 		0x709, 0x00000043, | ||||
| 		0x70A, 0x00000065, | ||||
| 		0x70B, 0x00000087, | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| u32 RTL8723BEAGCTAB_1TARRAY[] = { | ||||
| 		0xC78, 0xFD000001, | ||||
| 		0xC78, 0xFC010001, | ||||
| 		0xC78, 0xFB020001, | ||||
| 		0xC78, 0xFA030001, | ||||
| 		0xC78, 0xF9040001, | ||||
| 		0xC78, 0xF8050001, | ||||
| 		0xC78, 0xF7060001, | ||||
| 		0xC78, 0xF6070001, | ||||
| 		0xC78, 0xF5080001, | ||||
| 		0xC78, 0xF4090001, | ||||
| 		0xC78, 0xF30A0001, | ||||
| 		0xC78, 0xF20B0001, | ||||
| 		0xC78, 0xF10C0001, | ||||
| 		0xC78, 0xF00D0001, | ||||
| 		0xC78, 0xEF0E0001, | ||||
| 		0xC78, 0xEE0F0001, | ||||
| 		0xC78, 0xED100001, | ||||
| 		0xC78, 0xEC110001, | ||||
| 		0xC78, 0xEB120001, | ||||
| 		0xC78, 0xEA130001, | ||||
| 		0xC78, 0xE9140001, | ||||
| 		0xC78, 0xE8150001, | ||||
| 		0xC78, 0xE7160001, | ||||
| 		0xC78, 0xAA170001, | ||||
| 		0xC78, 0xA9180001, | ||||
| 		0xC78, 0xA8190001, | ||||
| 		0xC78, 0xA71A0001, | ||||
| 		0xC78, 0xA61B0001, | ||||
| 		0xC78, 0xA51C0001, | ||||
| 		0xC78, 0xA41D0001, | ||||
| 		0xC78, 0xA31E0001, | ||||
| 		0xC78, 0x671F0001, | ||||
| 		0xC78, 0x66200001, | ||||
| 		0xC78, 0x65210001, | ||||
| 		0xC78, 0x64220001, | ||||
| 		0xC78, 0x63230001, | ||||
| 		0xC78, 0x62240001, | ||||
| 		0xC78, 0x61250001, | ||||
| 		0xC78, 0x47260001, | ||||
| 		0xC78, 0x46270001, | ||||
| 		0xC78, 0x45280001, | ||||
| 		0xC78, 0x44290001, | ||||
| 		0xC78, 0x432A0001, | ||||
| 		0xC78, 0x422B0001, | ||||
| 		0xC78, 0x292C0001, | ||||
| 		0xC78, 0x282D0001, | ||||
| 		0xC78, 0x272E0001, | ||||
| 		0xC78, 0x262F0001, | ||||
| 		0xC78, 0x25300001, | ||||
| 		0xC78, 0x24310001, | ||||
| 		0xC78, 0x09320001, | ||||
| 		0xC78, 0x08330001, | ||||
| 		0xC78, 0x07340001, | ||||
| 		0xC78, 0x06350001, | ||||
| 		0xC78, 0x05360001, | ||||
| 		0xC78, 0x04370001, | ||||
| 		0xC78, 0x03380001, | ||||
| 		0xC78, 0x02390001, | ||||
| 		0xC78, 0x013A0001, | ||||
| 		0xC78, 0x003B0001, | ||||
| 		0xC78, 0x003C0001, | ||||
| 		0xC78, 0x003D0001, | ||||
| 		0xC78, 0x003E0001, | ||||
| 		0xC78, 0x003F0001, | ||||
| 		0xC78, 0xFC400001, | ||||
| 		0xC78, 0xFB410001, | ||||
| 		0xC78, 0xFA420001, | ||||
| 		0xC78, 0xF9430001, | ||||
| 		0xC78, 0xF8440001, | ||||
| 		0xC78, 0xF7450001, | ||||
| 		0xC78, 0xF6460001, | ||||
| 		0xC78, 0xF5470001, | ||||
| 		0xC78, 0xF4480001, | ||||
| 		0xC78, 0xF3490001, | ||||
| 		0xC78, 0xF24A0001, | ||||
| 		0xC78, 0xF14B0001, | ||||
| 		0xC78, 0xF04C0001, | ||||
| 		0xC78, 0xEF4D0001, | ||||
| 		0xC78, 0xEE4E0001, | ||||
| 		0xC78, 0xED4F0001, | ||||
| 		0xC78, 0xEC500001, | ||||
| 		0xC78, 0xEB510001, | ||||
| 		0xC78, 0xEA520001, | ||||
| 		0xC78, 0xE9530001, | ||||
| 		0xC78, 0xE8540001, | ||||
| 		0xC78, 0xE7550001, | ||||
| 		0xC78, 0xE6560001, | ||||
| 		0xC78, 0xE5570001, | ||||
| 		0xC78, 0xAA580001, | ||||
| 		0xC78, 0xA9590001, | ||||
| 		0xC78, 0xA85A0001, | ||||
| 		0xC78, 0xA75B0001, | ||||
| 		0xC78, 0xA65C0001, | ||||
| 		0xC78, 0xA55D0001, | ||||
| 		0xC78, 0xA45E0001, | ||||
| 		0xC78, 0x675F0001, | ||||
| 		0xC78, 0x66600001, | ||||
| 		0xC78, 0x65610001, | ||||
| 		0xC78, 0x64620001, | ||||
| 		0xC78, 0x63630001, | ||||
| 		0xC78, 0x62640001, | ||||
| 		0xC78, 0x61650001, | ||||
| 		0xC78, 0x47660001, | ||||
| 		0xC78, 0x46670001, | ||||
| 		0xC78, 0x45680001, | ||||
| 		0xC78, 0x44690001, | ||||
| 		0xC78, 0x436A0001, | ||||
| 		0xC78, 0x426B0001, | ||||
| 		0xC78, 0x296C0001, | ||||
| 		0xC78, 0x286D0001, | ||||
| 		0xC78, 0x276E0001, | ||||
| 		0xC78, 0x266F0001, | ||||
| 		0xC78, 0x25700001, | ||||
| 		0xC78, 0x24710001, | ||||
| 		0xC78, 0x09720001, | ||||
| 		0xC78, 0x08730001, | ||||
| 		0xC78, 0x07740001, | ||||
| 		0xC78, 0x06750001, | ||||
| 		0xC78, 0x05760001, | ||||
| 		0xC78, 0x04770001, | ||||
| 		0xC78, 0x03780001, | ||||
| 		0xC78, 0x02790001, | ||||
| 		0xC78, 0x017A0001, | ||||
| 		0xC78, 0x007B0001, | ||||
| 		0xC78, 0x007C0001, | ||||
| 		0xC78, 0x007D0001, | ||||
| 		0xC78, 0x007E0001, | ||||
| 		0xC78, 0x007F0001, | ||||
| 		0xC50, 0x69553422, | ||||
| 		0xC50, 0x69553420, | ||||
| 
 | ||||
| }; | ||||
							
								
								
									
										43
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/table.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/table.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_TABLE__H_ | ||||
| #define __RTL8723BE_TABLE__H_ | ||||
| 
 | ||||
| #include <linux/types.h> | ||||
| #define  RTL8723BEPHY_REG_1TARRAYLEN	388 | ||||
| extern u32 RTL8723BEPHY_REG_1TARRAY[]; | ||||
| #define RTL8723BEPHY_REG_ARRAY_PGLEN	36 | ||||
| extern u32 RTL8723BEPHY_REG_ARRAY_PG[]; | ||||
| #define	RTL8723BE_RADIOA_1TARRAYLEN	206 | ||||
| extern u32 RTL8723BE_RADIOA_1TARRAY[]; | ||||
| #define RTL8723BEMAC_1T_ARRAYLEN	196 | ||||
| extern u32 RTL8723BEMAC_1T_ARRAY[]; | ||||
| #define RTL8723BEAGCTAB_1TARRAYLEN	260 | ||||
| extern u32 RTL8723BEAGCTAB_1TARRAY[]; | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										941
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/trx.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										941
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/trx.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,941 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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" | ||||
| #include "dm.h" | ||||
| #include "fw.h" | ||||
| 
 | ||||
| static u8 _rtl8723be_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 _rtl8723be_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 _rtl8723be_query_rxphystatus(struct ieee80211_hw *hw, | ||||
| 					 struct rtl_stats *pstatus, u8 *pdesc, | ||||
| 					 struct rx_fwinfo_8723be *p_drvinfo, | ||||
| 					 bool bpacket_match_bssid, | ||||
| 					 bool bpacket_toself, | ||||
| 					 bool packet_beacon) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct phy_status_rpt *p_phystrpt = (struct phy_status_rpt *)p_drvinfo; | ||||
| 	char rx_pwr_all = 0, rx_pwr[4]; | ||||
| 	u8 rf_rx_num = 0, evm, pwdb_all, pwdb_all_bt = 0; | ||||
| 	u8 i, max_spatial_stream; | ||||
| 	u32 rssi, total_rssi = 0; | ||||
| 	bool is_cck = pstatus->is_cck; | ||||
| 	u8 lan_idx, vga_idx; | ||||
| 
 | ||||
| 	/* 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 cck_highpwr; | ||||
| 		u8 cck_agc_rpt; | ||||
| 
 | ||||
| 		cck_agc_rpt = p_phystrpt->cck_agc_rpt_ofdm_cfosho_a; | ||||
| 
 | ||||
| 		/* (1)Hardware does not provide RSSI for CCK */ | ||||
| 		/* (2)PWDB, Average PWDB cacluated by
 | ||||
| 		 * hardware (for rate adaptive) | ||||
| 		 */ | ||||
| 		cck_highpwr = (u8)rtl_get_bbreg(hw, RFPGA0_XA_HSSIPARAMETER2, | ||||
| 						 BIT(9)); | ||||
| 
 | ||||
| 		lan_idx = ((cck_agc_rpt & 0xE0) >> 5); | ||||
| 		vga_idx = (cck_agc_rpt & 0x1f); | ||||
| 
 | ||||
| 		switch (lan_idx) { | ||||
| 		/* 46 53 73 95 201301231630 */ | ||||
| 		/* 46 53 77 99 201301241630 */ | ||||
| 		case 6: | ||||
| 			rx_pwr_all = -34 - (2 * vga_idx); | ||||
| 			break; | ||||
| 		case 4: | ||||
| 			rx_pwr_all = -14 - (2 * vga_idx); | ||||
| 			break; | ||||
| 		case 1: | ||||
| 			rx_pwr_all = 6 - (2 * vga_idx); | ||||
| 			break; | ||||
| 		case 0: | ||||
| 			rx_pwr_all = 16 - (2 * vga_idx); | ||||
| 			break; | ||||
| 		default: | ||||
| 			break; | ||||
| 		} | ||||
| 
 | ||||
| 		pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all); | ||||
| 		if (pwdb_all > 100) | ||||
| 			pwdb_all = 100; | ||||
| 
 | ||||
| 		pstatus->rx_pwdb_all = pwdb_all; | ||||
| 		pstatus->bt_rx_rssi_percentage = pwdb_all; | ||||
| 		pstatus->recvsignalpower = rx_pwr_all; | ||||
| 
 | ||||
| 		/* (3) Get Signal Quality (EVM) */ | ||||
| 		if (bpacket_match_bssid) { | ||||
| 			u8 sq, sq_rpt; | ||||
| 			if (pstatus->rx_pwdb_all > 40) { | ||||
| 				sq = 100; | ||||
| 			} else { | ||||
| 				sq_rpt = p_phystrpt->cck_sig_qual_ofdm_pwdb_all; | ||||
| 				if (sq_rpt > 64) | ||||
| 					sq = 0; | ||||
| 				else if (sq_rpt < 20) | ||||
| 					sq = 100; | ||||
| 				else | ||||
| 					sq = ((64 - sq_rpt) * 100) / 44; | ||||
| 			} | ||||
| 			pstatus->signalquality = sq; | ||||
| 			pstatus->rx_mimo_signalquality[0] = sq; | ||||
| 			pstatus->rx_mimo_signalquality[1] = -1; | ||||
| 		} | ||||
| 	} else { | ||||
| 		/* (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_phystrpt->path_agc[i].gain & 0x3f) * 2) | ||||
| 				    - 110; | ||||
| 
 | ||||
| 			pstatus->rx_pwr[i] = rx_pwr[i]; | ||||
| 			/* Translate DBM to percentage. */ | ||||
| 			rssi = rtl_query_rxpwrpercentage(rx_pwr[i]); | ||||
| 			total_rssi += rssi; | ||||
| 
 | ||||
| 			pstatus->rx_mimo_signalstrength[i] = (u8)rssi; | ||||
| 		} | ||||
| 
 | ||||
| 		/* (2)PWDB, Average PWDB cacluated by
 | ||||
| 		 * hardware (for rate adaptive) | ||||
| 		 */ | ||||
| 		rx_pwr_all = ((p_phystrpt->cck_sig_qual_ofdm_pwdb_all >> 1) & | ||||
| 			     0x7f) - 110; | ||||
| 
 | ||||
| 		pwdb_all = rtl_query_rxpwrpercentage(rx_pwr_all); | ||||
| 		pwdb_all_bt = pwdb_all; | ||||
| 		pstatus->rx_pwdb_all = pwdb_all; | ||||
| 		pstatus->bt_rx_rssi_percentage = pwdb_all_bt; | ||||
| 		pstatus->rxpower = rx_pwr_all; | ||||
| 		pstatus->recvsignalpower = rx_pwr_all; | ||||
| 
 | ||||
| 		/* (3)EVM of HT rate */ | ||||
| 		if (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_phystrpt->stream_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); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		if (bpacket_match_bssid) { | ||||
| 			for (i = RF90_PATH_A; i <= RF90_PATH_B; i++) | ||||
| 				rtl_priv(hw)->dm.cfo_tail[i] = | ||||
| 					(int)p_phystrpt->path_cfotail[i]; | ||||
| 
 | ||||
| 			if (rtl_priv(hw)->dm.packet_count == 0xffffffff) | ||||
| 				rtl_priv(hw)->dm.packet_count = 0; | ||||
| 			else | ||||
| 				rtl_priv(hw)->dm.packet_count++; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/* 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 _rtl8723be_translate_rx_signal_stuff(struct ieee80211_hw *hw, | ||||
| 					struct sk_buff *skb, | ||||
| 					struct rtl_stats *pstatus, | ||||
| 					u8 *pdesc, | ||||
| 					struct rx_fwinfo_8723be *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; | ||||
| 	psaddr = ieee80211_get_SA(hdr); | ||||
| 	memcpy(pstatus->psaddr, psaddr, ETH_ALEN); | ||||
| 
 | ||||
| 	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)); | ||||
| 
 | ||||
| 	/* YP: packet_beacon is not initialized,
 | ||||
| 	 * this assignment is neccesary, | ||||
| 	 * otherwise it counld be true in this case | ||||
| 	 * the situation is much worse in Kernel 3.10 | ||||
| 	 */ | ||||
| 	if (ieee80211_is_beacon(hdr->frame_control)) | ||||
| 		packet_beacon = true; | ||||
| 	else | ||||
| 		packet_beacon = false; | ||||
| 
 | ||||
| 	if (packet_beacon && packet_matchbssid) | ||||
| 		rtl_priv(hw)->dm.dbginfo.num_qry_beacon_pkt++; | ||||
| 
 | ||||
| 	_rtl8723be_query_rxphystatus(hw, pstatus, pdesc, p_drvinfo, | ||||
| 				     packet_matchbssid, | ||||
| 				     packet_toself, | ||||
| 				     packet_beacon); | ||||
| 
 | ||||
| 	rtl_process_phyinfo(hw, tmp_buf, pstatus); | ||||
| } | ||||
| 
 | ||||
| static void _rtl8723be_insert_emcontent(struct rtl_tcb_desc *ptcb_desc, | ||||
| 					u8 *virtualaddress) | ||||
| { | ||||
| 	u32 dwtmp = 0; | ||||
| 	memset(virtualaddress, 0, 8); | ||||
| 
 | ||||
| 	SET_EARLYMODE_PKTNUM(virtualaddress, ptcb_desc->empkt_num); | ||||
| 	if (ptcb_desc->empkt_num == 1) { | ||||
| 		dwtmp = ptcb_desc->empkt_len[0]; | ||||
| 	} else { | ||||
| 		dwtmp = ptcb_desc->empkt_len[0]; | ||||
| 		dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | ||||
| 		dwtmp += ptcb_desc->empkt_len[1]; | ||||
| 	} | ||||
| 	SET_EARLYMODE_LEN0(virtualaddress, dwtmp); | ||||
| 
 | ||||
| 	if (ptcb_desc->empkt_num <= 3) { | ||||
| 		dwtmp = ptcb_desc->empkt_len[2]; | ||||
| 	} else { | ||||
| 		dwtmp = ptcb_desc->empkt_len[2]; | ||||
| 		dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | ||||
| 		dwtmp += ptcb_desc->empkt_len[3]; | ||||
| 	} | ||||
| 	SET_EARLYMODE_LEN1(virtualaddress, dwtmp); | ||||
| 	if (ptcb_desc->empkt_num <= 5) { | ||||
| 		dwtmp = ptcb_desc->empkt_len[4]; | ||||
| 	} else { | ||||
| 		dwtmp = ptcb_desc->empkt_len[4]; | ||||
| 		dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | ||||
| 		dwtmp += ptcb_desc->empkt_len[5]; | ||||
| 	} | ||||
| 	SET_EARLYMODE_LEN2_1(virtualaddress, dwtmp & 0xF); | ||||
| 	SET_EARLYMODE_LEN2_2(virtualaddress, dwtmp >> 4); | ||||
| 	if (ptcb_desc->empkt_num <= 7) { | ||||
| 		dwtmp = ptcb_desc->empkt_len[6]; | ||||
| 	} else { | ||||
| 		dwtmp = ptcb_desc->empkt_len[6]; | ||||
| 		dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | ||||
| 		dwtmp += ptcb_desc->empkt_len[7]; | ||||
| 	} | ||||
| 	SET_EARLYMODE_LEN3(virtualaddress, dwtmp); | ||||
| 	if (ptcb_desc->empkt_num <= 9) { | ||||
| 		dwtmp = ptcb_desc->empkt_len[8]; | ||||
| 	} else { | ||||
| 		dwtmp = ptcb_desc->empkt_len[8]; | ||||
| 		dwtmp += ((dwtmp % 4) ? (4 - dwtmp % 4) : 0) + 4; | ||||
| 		dwtmp += ptcb_desc->empkt_len[9]; | ||||
| 	} | ||||
| 	SET_EARLYMODE_LEN4(virtualaddress, dwtmp); | ||||
| } | ||||
| 
 | ||||
| bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw, | ||||
| 			     struct rtl_stats *status, | ||||
| 			     struct ieee80211_rx_status *rx_status, | ||||
| 			     u8 *pdesc, struct sk_buff *skb) | ||||
| { | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 	struct rx_fwinfo_8723be *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); | ||||
| 	status->timestamp_low = GET_RX_DESC_TSFL(pdesc); | ||||
| 	status->rx_is40Mhzpacket = (bool)GET_RX_DESC_BW(pdesc); | ||||
| 	status->bandwidth = (u8)GET_RX_DESC_BW(pdesc); | ||||
| 	status->macid = GET_RX_DESC_MACID(pdesc); | ||||
| 	status->is_ht = (bool)GET_RX_DESC_RXHT(pdesc); | ||||
| 
 | ||||
| 	status->is_cck = RX_HAL_IS_CCK_RATE(status->rate); | ||||
| 
 | ||||
| 	if (GET_RX_STATUS_DESC_RPT_SEL(pdesc)) | ||||
| 		status->packet_report_type = C2H_PACKET; | ||||
| 	else | ||||
| 		status->packet_report_type = NORMAL_RX; | ||||
| 
 | ||||
| 
 | ||||
| 	if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc)) | ||||
| 		status->wake_match = BIT(2); | ||||
| 	else if (GET_RX_STATUS_DESC_MAGIC_MATCH(pdesc)) | ||||
| 		status->wake_match = BIT(1); | ||||
| 	else if (GET_RX_STATUS_DESC_UNICAST_MATCH(pdesc)) | ||||
| 		status->wake_match = BIT(0); | ||||
| 	else | ||||
| 		status->wake_match = 0; | ||||
| 	if (status->wake_match) | ||||
| 		RT_TRACE(rtlpriv, COMP_RXDESC, DBG_LOUD, | ||||
| 		"GGGGGGGGGGGGGet Wakeup Packet!! WakeMatch=%d\n", | ||||
| 		status->wake_match); | ||||
| 	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) | ||||
| 	 */ | ||||
| 	rx_status->rate_idx = _rtl8723be_rate_mapping(hw, status->is_ht, | ||||
| 						      status->rate); | ||||
| 
 | ||||
| 	rx_status->mactime = status->timestamp_low; | ||||
| 	if (phystatus) { | ||||
| 		p_drvinfo = (struct rx_fwinfo_8723be *)(skb->data + | ||||
| 							status->rx_bufshift); | ||||
| 
 | ||||
| 		_rtl8723be_translate_rx_signal_stuff(hw, skb, status, | ||||
| 						     pdesc, p_drvinfo); | ||||
| 	} | ||||
| 	rx_status->signal = status->recvsignalpower + 10; | ||||
| 	if (status->packet_report_type == TX_REPORT2) { | ||||
| 		status->macid_valid_entry[0] = | ||||
| 		  GET_RX_RPT2_DESC_MACID_VALID_1(pdesc); | ||||
| 		status->macid_valid_entry[1] = | ||||
| 		  GET_RX_RPT2_DESC_MACID_VALID_2(pdesc); | ||||
| 	} | ||||
| 	return true; | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_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_hal *rtlhal = rtl_hal(rtlpriv); | ||||
| 	u8 *pdesc = (u8 *)pdesc_tx; | ||||
| 	u16 seq_number; | ||||
| 	__le16 fc = hdr->frame_control; | ||||
| 	unsigned int buf_len = 0; | ||||
| 	unsigned int skb_len = skb->len; | ||||
| 	u8 fw_qsel = _rtl8723be_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; | ||||
| 	u8 bw_40 = 0; | ||||
| 	u8 short_gi = 0; | ||||
| 
 | ||||
| 	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); | ||||
| 	/* reserve 8 byte for AMPDU early mode */ | ||||
| 	if (rtlhal->earlymode_enable) { | ||||
| 		skb_push(skb, EM_HDR_LEN); | ||||
| 		memset(skb->data, 0, EM_HDR_LEN); | ||||
| 	} | ||||
| 	buf_len = skb->len; | ||||
| 	mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len, | ||||
| 				 PCI_DMA_TODEVICE); | ||||
| 	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, sizeof(struct tx_desc_8723be)); | ||||
| 	if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) { | ||||
| 		firstseg = true; | ||||
| 		lastseg = true; | ||||
| 	} | ||||
| 	if (firstseg) { | ||||
| 		if (rtlhal->earlymode_enable) { | ||||
| 			SET_TX_DESC_PKT_OFFSET(pdesc, 1); | ||||
| 			SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN + | ||||
| 					   EM_HDR_LEN); | ||||
| 			if (ptcb_desc->empkt_num) { | ||||
| 				RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE, | ||||
| 					 "Insert 8 byte.pTcb->EMPktNum:%d\n", | ||||
| 					  ptcb_desc->empkt_num); | ||||
| 				_rtl8723be_insert_emcontent(ptcb_desc, | ||||
| 							    (u8 *)(skb->data)); | ||||
| 			} | ||||
| 		} else { | ||||
| 			SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN); | ||||
| 		} | ||||
| 
 | ||||
| 		/* ptcb_desc->use_driver_rate = true; */ | ||||
| 		SET_TX_DESC_TX_RATE(pdesc, ptcb_desc->hw_rate); | ||||
| 		if (ptcb_desc->hw_rate > DESC92C_RATEMCS0) | ||||
| 			short_gi = (ptcb_desc->use_shortgi) ? 1 : 0; | ||||
| 		else | ||||
| 			short_gi = (ptcb_desc->use_shortpreamble) ? 1 : 0; | ||||
| 
 | ||||
| 		SET_TX_DESC_DATA_SHORTGI(pdesc, short_gi); | ||||
| 
 | ||||
| 		if (info->flags & IEEE80211_TX_CTL_AMPDU) { | ||||
| 			SET_TX_DESC_AGG_ENABLE(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, 0); | ||||
| 		SET_TX_DESC_CTS2SELF(pdesc, ((ptcb_desc->cts_enable) ? | ||||
| 					      1 : 0)); | ||||
| 
 | ||||
| 		SET_TX_DESC_RTS_RATE(pdesc, ptcb_desc->rts_rate); | ||||
| 
 | ||||
| 		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 (ptcb_desc->tx_enable_sw_calc_duration) | ||||
| 			SET_TX_DESC_NAV_USE_HDR(pdesc, 1); | ||||
| 
 | ||||
| 		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_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, ptcb_desc->disable_ratefallback ? | ||||
| 					      1 : 0); | ||||
| 		SET_TX_DESC_USE_RATE(pdesc, ptcb_desc->use_driver_rate ? 1 : 0); | ||||
| 
 | ||||
| 		/* Set TxRate and RTSRate in TxDesc  */ | ||||
| 		/* This prevent Tx initial rate of new-coming packets */ | ||||
| 		/* from being overwritten by retried  packet rate.*/ | ||||
| 		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) buf_len); | ||||
| 	SET_TX_DESC_TX_BUFFER_ADDRESS(pdesc, mapping); | ||||
| 	/* if (rtlpriv->dm.useramask) { */ | ||||
| 	if (1) { | ||||
| 		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->mac_id); | ||||
| 	} | ||||
| 	if (!ieee80211_is_data_qos(fc))  { | ||||
| 		SET_TX_DESC_HWSEQ_EN(pdesc, 1); | ||||
| 		SET_TX_DESC_HWSEQ_SEL(pdesc, 0); | ||||
| 	} | ||||
| 	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 rtl8723be_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); | ||||
| 
 | ||||
| 	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); | ||||
| 
 | ||||
| 	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, 0); | ||||
| 	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_USE_RATE(pdesc, 1); | ||||
| 
 | ||||
| 	RT_PRINT_DATA(rtlpriv, COMP_CMD, DBG_LOUD, | ||||
| 		      "H2C Tx Cmd Content\n", pdesc, TX_DESC_SIZE); | ||||
| } | ||||
| 
 | ||||
| void rtl8723be_set_desc(struct ieee80211_hw *hw, u8 *pdesc, | ||||
| 			bool istx, u8 desc_name, u8 *val) | ||||
| { | ||||
| 	if (istx) { | ||||
| 		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 rtl8723be_get_desc(u8 *pdesc, bool istx, u8 desc_name) | ||||
| { | ||||
| 	u32 ret = 0; | ||||
| 
 | ||||
| 	if (istx) { | ||||
| 		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 rtl8723be_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)rtl8723be_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 rtl8723be_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 rtl8723be_rx_command_packet(struct ieee80211_hw *hw, | ||||
| 				struct rtl_stats status, | ||||
| 				struct sk_buff *skb) | ||||
| { | ||||
| 	u32 result = 0; | ||||
| 	struct rtl_priv *rtlpriv = rtl_priv(hw); | ||||
| 
 | ||||
| 	switch (status.packet_report_type) { | ||||
| 	case NORMAL_RX: | ||||
| 			result = 0; | ||||
| 			break; | ||||
| 	case C2H_PACKET: | ||||
| 			rtl8723be_c2h_packet_handler(hw, skb->data, | ||||
| 						     (u8)skb->len); | ||||
| 			result = 1; | ||||
| 			break; | ||||
| 	default: | ||||
| 			RT_TRACE(rtlpriv, COMP_RECV, DBG_TRACE, | ||||
| 				 "No this packet type!!\n"); | ||||
| 			break; | ||||
| 	} | ||||
| 
 | ||||
| 	return result; | ||||
| } | ||||
							
								
								
									
										625
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/trx.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										625
									
								
								drivers/net/wireless/rtlwifi/rtl8723be/trx.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,625 @@ | |||
| /******************************************************************************
 | ||||
|  * | ||||
|  * Copyright(c) 2009-2014  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 __RTL8723BE_TRX_H__ | ||||
| #define __RTL8723BE_TRX_H__ | ||||
| 
 | ||||
| #define TX_DESC_SIZE				40 | ||||
| #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			40 | ||||
| #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, 7, __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, 5, __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, 5, __val) | ||||
| 
 | ||||
| 
 | ||||
| #define SET_TX_DESC_PAID(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 0, 9, __val) | ||||
| #define SET_TX_DESC_CCA_RTS(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 10, 2, __val) | ||||
| #define SET_TX_DESC_AGG_ENABLE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 12, 1, __val) | ||||
| #define SET_TX_DESC_RDG_ENABLE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 13, 1, __val) | ||||
| #define SET_TX_DESC_BAR_RTY_TH(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 14, 2, __val) | ||||
| #define SET_TX_DESC_AGG_BREAK(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 16, 1, __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_SPE_RPT(__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_BT_INT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 23, 1, __val) | ||||
| #define SET_TX_DESC_GID(__pdesc, __val)			\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+8, 24, 6, __val) | ||||
| 
 | ||||
| 
 | ||||
| #define SET_TX_DESC_WHEADER_LEN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 0, 4, __val) | ||||
| #define SET_TX_DESC_CHK_EN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 4, 1, __val) | ||||
| #define SET_TX_DESC_EARLY_MODE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 5, 1, __val) | ||||
| #define SET_TX_DESC_HWSEQ_SEL(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 6, 2, __val) | ||||
| #define SET_TX_DESC_USE_RATE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 8, 1, __val) | ||||
| #define SET_TX_DESC_DISABLE_RTS_FB(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 9, 1, __val) | ||||
| #define SET_TX_DESC_DISABLE_FB(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 10, 1, __val) | ||||
| #define SET_TX_DESC_CTS2SELF(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 11, 1, __val) | ||||
| #define SET_TX_DESC_RTS_ENABLE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 12, 1, __val) | ||||
| #define SET_TX_DESC_HW_RTS_ENABLE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 13, 1, __val) | ||||
| #define SET_TX_DESC_NAV_USE_HDR(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 15, 1, __val) | ||||
| #define SET_TX_DESC_USE_MAX_LEN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 16, 1, __val) | ||||
| #define SET_TX_DESC_MAX_AGG_NUM(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 17, 5, __val) | ||||
| #define SET_TX_DESC_NDPA(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 22, 2, __val) | ||||
| #define SET_TX_DESC_AMPDU_MAX_TIME(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+12, 24, 8, __val) | ||||
| 
 | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_RATE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 0, 7, __val) | ||||
| #define SET_TX_DESC_DATA_RATE_FB_LIMIT(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 8, 5, __val) | ||||
| #define SET_TX_DESC_RTS_RATE_FB_LIMIT(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 13, 4, __val) | ||||
| #define SET_TX_DESC_RETRY_LIMIT_ENABLE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 17, 1, __val) | ||||
| #define SET_TX_DESC_DATA_RETRY_LIMIT(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 18, 6, __val) | ||||
| #define SET_TX_DESC_RTS_RATE(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+16, 24, 5, __val) | ||||
| 
 | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_SUB_CARRIER(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 0, 4, __val) | ||||
| #define SET_TX_DESC_DATA_SHORTGI(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 4, 1, __val) | ||||
| #define SET_TX_DESC_DATA_BW(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 5, 2, __val) | ||||
| #define SET_TX_DESC_DATA_LDPC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 7, 1, __val) | ||||
| #define SET_TX_DESC_DATA_STBC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 8, 2, __val) | ||||
| #define SET_TX_DESC_CTROL_STBC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 10, 2, __val) | ||||
| #define SET_TX_DESC_RTS_SHORT(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 12, 1, __val) | ||||
| #define SET_TX_DESC_RTS_SC(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+20, 13, 4, __val) | ||||
| 
 | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_BUFFER_SIZE(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+28, 0, 16, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_TX_BUFFER_SIZE(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+28, 0, 16) | ||||
| 
 | ||||
| #define SET_TX_DESC_HWSEQ_EN(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+32, 15, 1, __val) | ||||
| 
 | ||||
| #define SET_TX_DESC_SEQ(__pdesc, __val)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+36, 12, 12, __val) | ||||
| 
 | ||||
| #define SET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+40, 0, 32, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_TX_BUFFER_ADDRESS(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+40, 0, 32) | ||||
| 
 | ||||
| 
 | ||||
| #define SET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc, __val)	\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__pdesc+48, 0, 32, __val) | ||||
| 
 | ||||
| #define GET_TX_DESC_NEXT_DESC_ADDRESS(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+48, 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, 7) | ||||
| #define GET_RX_DESC_TID(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 8, 4) | ||||
| #define GET_RX_DESC_AMSDU(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 13, 1) | ||||
| #define GET_RX_STATUS_DESC_RXID_MATCH(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 14, 1) | ||||
| #define GET_RX_DESC_PAGGR(__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_CHKERR(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 20, 1) | ||||
| #define GET_RX_DESC_IPVER(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 21, 1) | ||||
| #define GET_RX_STATUS_DESC_IS_TCPUDP(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 22, 1) | ||||
| #define GET_RX_STATUS_DESC_CHK_VLD(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+4, 23, 1) | ||||
| #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_STATUS_DESC_RX_IS_QOS(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 16, 1) | ||||
| #define GET_RX_STATUS_DESC_WLANHD_IV_LEN(__pdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 18, 6) | ||||
| #define GET_RX_STATUS_DESC_RPT_SEL(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+8, 28, 1) | ||||
| 
 | ||||
| 
 | ||||
| #define GET_RX_DESC_RXMCS(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 0, 7) | ||||
| #define GET_RX_DESC_RXHT(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 6, 1) | ||||
| #define GET_RX_STATUS_DESC_RX_GF(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 7, 1) | ||||
| #define GET_RX_DESC_HTC(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 10, 1) | ||||
| #define GET_RX_STATUS_DESC_EOSP(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 11, 1) | ||||
| #define GET_RX_STATUS_DESC_BSSID_FIT(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 12, 2) | ||||
| 
 | ||||
| #define GET_RX_STATUS_DESC_PATTERN_MATCH(__pdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 29, 1) | ||||
| #define GET_RX_STATUS_DESC_UNICAST_MATCH(__pdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 30, 1) | ||||
| #define GET_RX_STATUS_DESC_MAGIC_MATCH(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+12, 31, 1) | ||||
| 
 | ||||
| #define GET_RX_DESC_SPLCP(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 0, 1) | ||||
| #define GET_RX_STATUS_DESC_LDPC(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 1, 1) | ||||
| #define GET_RX_STATUS_DESC_STBC(__pdesc)		\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 2, 1) | ||||
| #define GET_RX_DESC_BW(__pdesc)			\ | ||||
| 	LE_BITS_TO_4BYTE(__pdesc+16, 4, 2) | ||||
| 
 | ||||
| #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) | ||||
| 
 | ||||
| 
 | ||||
| /* TX report 2 format in Rx desc*/ | ||||
| 
 | ||||
| #define GET_RX_RPT2_DESC_PKT_LEN(__rxstatusdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__rxstatusdesc, 0, 9) | ||||
| #define GET_RX_RPT2_DESC_MACID_VALID_1(__rxstatusdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__rxstatusdesc+16, 0, 32) | ||||
| #define GET_RX_RPT2_DESC_MACID_VALID_2(__rxstatusdesc)	\ | ||||
| 	LE_BITS_TO_4BYTE(__rxstatusdesc+20, 0, 32) | ||||
| 
 | ||||
| #define SET_EARLYMODE_PKTNUM(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr, 0, 4, __value) | ||||
| #define SET_EARLYMODE_LEN0(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr, 4, 12, __value) | ||||
| #define SET_EARLYMODE_LEN1(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr, 16, 12, __value) | ||||
| #define SET_EARLYMODE_LEN2_1(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr, 28, 4, __value) | ||||
| #define SET_EARLYMODE_LEN2_2(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr+4, 0, 8, __value) | ||||
| #define SET_EARLYMODE_LEN3(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr+4, 8, 12, __value) | ||||
| #define SET_EARLYMODE_LEN4(__paddr, __value)		\ | ||||
| 	SET_BITS_TO_LE_4BYTE(__paddr+4, 20, 12, __value) | ||||
| 
 | ||||
| #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 phy_rx_agc_info_t { | ||||
| 	#ifdef __LITTLE_ENDIAN | ||||
| 		u8 gain:7, trsw:1; | ||||
| 	#else | ||||
| 		u8 trsw:1, gain:7; | ||||
| 	#endif | ||||
| }; | ||||
| struct phy_status_rpt { | ||||
| 	struct phy_rx_agc_info_t path_agc[2]; | ||||
| 	u8 ch_corr[2]; | ||||
| 	u8 cck_sig_qual_ofdm_pwdb_all; | ||||
| 	u8 cck_agc_rpt_ofdm_cfosho_a; | ||||
| 	u8 cck_rpt_b_ofdm_cfosho_b; | ||||
| 	u8 rsvd_1;/* ch_corr_msb; */ | ||||
| 	u8 noise_power_db_msb; | ||||
| 	char path_cfotail[2]; | ||||
| 	u8 pcts_mask[2]; | ||||
| 	char stream_rxevm[2]; | ||||
| 	u8 path_rxsnr[2]; | ||||
| 	u8 noise_power_db_lsb; | ||||
| 	u8 rsvd_2[3]; | ||||
| 	u8 stream_csi[2]; | ||||
| 	u8 stream_target_csi[2]; | ||||
| 	u8 sig_evm; | ||||
| 	u8 rsvd_3; | ||||
| #ifdef __LITTLE_ENDIAN | ||||
| 	u8 antsel_rx_keep_2:1;	/*ex_intf_flg:1;*/ | ||||
| 	u8 sgi_en:1; | ||||
| 	u8 rxsc:2; | ||||
| 	u8 idle_long:1; | ||||
| 	u8 r_ant_train_en:1; | ||||
| 	u8 ant_sel_b:1; | ||||
| 	u8 ant_sel:1; | ||||
| #else	/* _BIG_ENDIAN_	*/ | ||||
| 	u8 ant_sel:1; | ||||
| 	u8 ant_sel_b:1; | ||||
| 	u8 r_ant_train_en:1; | ||||
| 	u8 idle_long:1; | ||||
| 	u8 rxsc:2; | ||||
| 	u8 sgi_en:1; | ||||
| 	u8 antsel_rx_keep_2:1;	/*ex_intf_flg:1;*/ | ||||
| #endif | ||||
| } __packed; | ||||
| 
 | ||||
| struct rx_fwinfo_8723be { | ||||
| 	u8 gain_trsw[2]; | ||||
| 	u16 chl_num:10; | ||||
| 	u16 sub_chnl:4; | ||||
| 	u16 r_rfmod:2; | ||||
| 	u8 pwdb_all; | ||||
| 	u8 cfosho[4]; | ||||
| 	u8 cfotail[4]; | ||||
| 	char rxevm[2]; | ||||
| 	char rxsnr[2]; | ||||
| 	u8 pcts_msk_rpt[2]; | ||||
| 	u8 pdsnr[2]; | ||||
| 	u8 csi_current[2]; | ||||
| 	u8 rx_gain_c; | ||||
| 	u8 rx_gain_d; | ||||
| 	u8 sigevm; | ||||
| 	u8 resvd_0; | ||||
| 	u8 antidx_anta:3; | ||||
| 	u8 antidx_antb:3; | ||||
| 	u8 resvd_1:2; | ||||
| } __packed; | ||||
| 
 | ||||
| struct tx_desc_8723be { | ||||
| 	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:6; | ||||
| 	u32 rsvd0:2; | ||||
| 	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 agg_en:1; | ||||
| 	u32 rdg_en:1; | ||||
| 	u32 bar_retryht:2; | ||||
| 	u32 agg_break:1; | ||||
| 	u32 morefrag:1; | ||||
| 	u32 raw:1; | ||||
| 	u32 ccx:1; | ||||
| 	u32 ampdudensity:3; | ||||
| 	u32 bt_int: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 cpu_handle:1; | ||||
| 	u32 tag1:1; | ||||
| 	u32 trigger_int:1; | ||||
| 	u32 hwseq_en:1; | ||||
| 
 | ||||
| 	u32 rtsrate:5; | ||||
| 	u32 apdcfe:1; | ||||
| 	u32 qos:1; | ||||
| 	u32 hwseq_ssn: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 pwr_status: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 sw_offset30:8; | ||||
| 	u32 sw_offset31:4; | ||||
| 	u32 rsvd1:1; | ||||
| 	u32 antsel_c:1; | ||||
| 	u32 null_0:1; | ||||
| 	u32 null_1:1; | ||||
| 
 | ||||
| 	u32 txbuffaddr; | ||||
| 	u32 txbufferaddr64; | ||||
| 	u32 nextdescaddress; | ||||
| 	u32 nextdescaddress64; | ||||
| 
 | ||||
| 	u32 reserve_pass_pcie_mm_limit[4]; | ||||
| } __packed; | ||||
| 
 | ||||
| struct rx_desc_8723be { | ||||
| 	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:6; | ||||
| 	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 rtl8723be_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); | ||||
| bool rtl8723be_rx_query_desc(struct ieee80211_hw *hw, | ||||
| 			     struct rtl_stats *status, | ||||
| 			     struct ieee80211_rx_status *rx_status, | ||||
| 			     u8 *pdesc, struct sk_buff *skb); | ||||
| void rtl8723be_set_desc(struct ieee80211_hw *hw, u8 *pdesc, | ||||
| 			bool istx, u8 desc_name, u8 *val); | ||||
| u32 rtl8723be_get_desc(u8 *pdesc, bool istx, u8 desc_name); | ||||
| bool rtl8723be_is_tx_desc_closed(struct ieee80211_hw *hw, | ||||
| 				 u8 hw_queue, u16 index); | ||||
| void rtl8723be_tx_polling(struct ieee80211_hw *hw, u8 hw_queue); | ||||
| void rtl8723be_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc, | ||||
| 			       bool firstseg, bool lastseg, | ||||
| 			       struct sk_buff *skb); | ||||
| u32 rtl8723be_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