• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __HAL_INTF_H__
21 #define __HAL_INTF_H__
22 
23 #include <osdep_service.h>
24 #include <drv_types.h>
25 #include <Hal8188EPhyCfg.h>
26 
27 enum RTL871X_HCI_TYPE {
28 	RTW_PCIE	= BIT0,
29 	RTW_USB		= BIT1,
30 	RTW_SDIO	= BIT2,
31 	RTW_GSPI	= BIT3,
32 };
33 
34 enum _CHIP_TYPE {
35 	NULL_CHIP_TYPE,
36 	RTL8712_8188S_8191S_8192S,
37 	RTL8188C_8192C,
38 	RTL8192D,
39 	RTL8723A,
40 	RTL8188E,
41 	MAX_CHIP_TYPE
42 };
43 
44 enum hw_variables {
45 	HW_VAR_MEDIA_STATUS,
46 	HW_VAR_MEDIA_STATUS1,
47 	HW_VAR_SET_OPMODE,
48 	HW_VAR_MAC_ADDR,
49 	HW_VAR_BSSID,
50 	HW_VAR_INIT_RTS_RATE,
51 	HW_VAR_BASIC_RATE,
52 	HW_VAR_TXPAUSE,
53 	HW_VAR_BCN_FUNC,
54 	HW_VAR_CORRECT_TSF,
55 	HW_VAR_CHECK_BSSID,
56 	HW_VAR_MLME_DISCONNECT,
57 	HW_VAR_MLME_SITESURVEY,
58 	HW_VAR_MLME_JOIN,
59 	HW_VAR_BEACON_INTERVAL,
60 	HW_VAR_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 	HW_VAR_CHECK_TXBUF,
105 	HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation,
106 			     * power control for MAC only */
107 	/*  The valid upper nav range for the HW updating, if the true value is
108 	 *  larger than the upper range, the HW won't update it. */
109 	/*  Unit in microsecond. 0 means disable this function. */
110 	HW_VAR_NAV_UPPER,
111 	HW_VAR_RPT_TIMER_SETTING,
112 	HW_VAR_TX_RPT_MAX_MACID,
113 	HW_VAR_H2C_MEDIA_STATUS_RPT,
114 	HW_VAR_CHK_HI_QUEUE_EMPTY,
115 };
116 
117 enum hal_def_variable {
118 	HAL_DEF_UNDERCORATEDSMOOTHEDPWDB,
119 	HAL_DEF_IS_SUPPORT_ANT_DIV,
120 	HAL_DEF_CURRENT_ANTENNA,
121 	HAL_DEF_DRVINFO_SZ,
122 	HAL_DEF_MAX_RECVBUF_SZ,
123 	HAL_DEF_RX_PACKET_OFFSET,
124 	HAL_DEF_DBG_DUMP_RXPKT,/* for dbg */
125 	HAL_DEF_DBG_DM_FUNC,/* for dbg */
126 	HAL_DEF_RA_DECISION_RATE,
127 	HAL_DEF_RA_SGI,
128 	HAL_DEF_PT_PWR_STATUS,
129 	HW_VAR_MAX_RX_AMPDU_FACTOR,
130 	HW_DEF_RA_INFO_DUMP,
131 	HAL_DEF_DBG_DUMP_TXPKT,
132 	HW_DEF_FA_CNT_DUMP,
133 	HW_DEF_ODM_DBG_FLAG,
134 };
135 
136 enum hal_odm_variable {
137 	HAL_ODM_STA_INFO,
138 	HAL_ODM_P2P_STATE,
139 	HAL_ODM_WIFI_DISPLAY_STATE,
140 };
141 
142 enum hal_intf_ps_func {
143 	HAL_USB_SELECT_SUSPEND,
144 	HAL_MAX_ID,
145 };
146 
147 struct hal_ops {
148 	u32	(*hal_power_on)(struct adapter *padapter);
149 	u32	(*hal_init)(struct adapter *padapter);
150 	u32	(*hal_deinit)(struct adapter *padapter);
151 
152 	void	(*free_hal_data)(struct adapter *padapter);
153 
154 	u32	(*inirp_init)(struct adapter *padapter);
155 	u32	(*inirp_deinit)(struct adapter *padapter);
156 
157 	s32	(*init_xmit_priv)(struct adapter *padapter);
158 
159 	s32	(*init_recv_priv)(struct adapter *padapter);
160 	void	(*free_recv_priv)(struct adapter *padapter);
161 
162 	void	(*InitSwLeds)(struct adapter *padapter);
163 	void	(*DeInitSwLeds)(struct adapter *padapter);
164 
165 	void	(*dm_init)(struct adapter *padapter);
166 	void	(*read_chip_version)(struct adapter *padapter);
167 
168 	void	(*init_default_value)(struct adapter *padapter);
169 
170 	void	(*intf_chip_configure)(struct adapter *padapter);
171 
172 	void	(*read_adapter_info)(struct adapter *padapter);
173 
174 	void	(*enable_interrupt)(struct adapter *padapter);
175 	void	(*disable_interrupt)(struct adapter *padapter);
176 	s32	(*interrupt_handler)(struct adapter *padapter);
177 
178 	void	(*set_bwmode_handler)(struct adapter *padapter,
179 				      enum ht_channel_width Bandwidth,
180 				      u8 Offset);
181 	void	(*set_channel_handler)(struct adapter *padapter, u8 channel);
182 
183 	void	(*hal_dm_watchdog)(struct adapter *padapter);
184 
185 	void	(*SetHwRegHandler)(struct adapter *padapter, u8	variable,
186 				   u8 *val);
187 	void	(*GetHwRegHandler)(struct adapter *padapter, u8	variable,
188 				   u8 *val);
189 
190 	u8	(*GetHalDefVarHandler)(struct adapter *padapter,
191 				       enum hal_def_variable eVariable,
192 				       void *pValue);
193 	u8	(*SetHalDefVarHandler)(struct adapter *padapter,
194 				       enum hal_def_variable eVariable,
195 				       void *pValue);
196 
197 	void	(*SetHalODMVarHandler)(struct adapter *padapter,
198 				       enum hal_odm_variable eVariable,
199 				       void *pValue1, bool bSet);
200 
201 	void	(*UpdateRAMaskHandler)(struct adapter *padapter,
202 				       u32 mac_id, u8 rssi_level);
203 	void	(*SetBeaconRelatedRegistersHandler)(struct adapter *padapter);
204 
205 	void	(*Add_RateATid)(struct adapter *adapter, u32 bitmap, u8 arg,
206 				u8 rssi_level);
207 
208 	u8	(*AntDivBeforeLinkHandler)(struct adapter *adapter);
209 	void	(*AntDivCompareHandler)(struct adapter *adapter,
210 					struct wlan_bssid_ex *dst,
211 					struct wlan_bssid_ex *src);
212 	s32	(*hal_xmit)(struct adapter *padapter,
213 			    struct xmit_frame *pxmitframe);
214 	s32 (*mgnt_xmit)(struct adapter *padapter,
215 			 struct xmit_frame *pmgntframe);
216 	u32	(*read_rfreg)(struct adapter *padapter,
217 			      enum rf_radio_path eRFPath, u32 RegAddr,
218 			      u32 BitMask);
219 	void	(*write_rfreg)(struct adapter *padapter,
220 			       enum rf_radio_path eRFPath, u32 RegAddr,
221 			       u32 BitMask, u32 Data);
222 
223 	void (*sreset_init_value)(struct adapter *padapter);
224 	u8 (*sreset_get_wifi_status)(struct adapter *padapter);
225 
226 	void (*hal_notch_filter)(struct adapter *adapter, bool enable);
227 	void (*hal_reset_security_engine)(struct adapter *adapter);
228 };
229 
230 enum rt_eeprom_type {
231 	EEPROM_93C46,
232 	EEPROM_93C56,
233 	EEPROM_BOOT_EFUSE,
234 };
235 
236 #define RF_CHANGE_BY_INIT	0
237 #define RF_CHANGE_BY_IPS	BIT28
238 #define RF_CHANGE_BY_PS		BIT29
239 #define RF_CHANGE_BY_HW		BIT30
240 #define RF_CHANGE_BY_SW		BIT31
241 
242 enum hardware_type {
243 	HARDWARE_TYPE_RTL8188EU,
244 	HARDWARE_TYPE_MAX,
245 };
246 
247 #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv)
248 
249 #define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse)
250 
251 void rtw_hal_def_value_init(struct adapter *padapter);
252 
253 void	rtw_hal_free_data(struct adapter *padapter);
254 
255 void rtw_hal_dm_init(struct adapter *padapter);
256 void rtw_hal_sw_led_init(struct adapter *padapter);
257 void rtw_hal_sw_led_deinit(struct adapter *padapter);
258 
259 u32 rtw_hal_power_on(struct adapter *padapter);
260 uint rtw_hal_init(struct adapter *padapter);
261 uint rtw_hal_deinit(struct adapter *padapter);
262 void rtw_hal_stop(struct adapter *padapter);
263 void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val);
264 void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val);
265 
266 void rtw_hal_chip_configure(struct adapter *padapter);
267 void rtw_hal_read_chip_info(struct adapter *padapter);
268 void rtw_hal_read_chip_version(struct adapter *padapter);
269 
270 u8 rtw_hal_set_def_var(struct adapter *padapter,
271 		       enum hal_def_variable eVariable, void *pValue);
272 u8 rtw_hal_get_def_var(struct adapter *padapter,
273 		       enum hal_def_variable eVariable, void *pValue);
274 
275 void rtw_hal_set_odm_var(struct adapter *padapter,
276 			 enum hal_odm_variable eVariable, void *pValue1,
277 			 bool bSet);
278 
279 void rtw_hal_enable_interrupt(struct adapter *padapter);
280 void rtw_hal_disable_interrupt(struct adapter *padapter);
281 
282 u32	rtw_hal_inirp_init(struct adapter *padapter);
283 u32	rtw_hal_inirp_deinit(struct adapter *padapter);
284 
285 s32	rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe);
286 s32	rtw_hal_mgnt_xmit(struct adapter *padapter,
287 			  struct xmit_frame *pmgntframe);
288 
289 s32	rtw_hal_init_xmit_priv(struct adapter *padapter);
290 
291 s32	rtw_hal_init_recv_priv(struct adapter *padapter);
292 void	rtw_hal_free_recv_priv(struct adapter *padapter);
293 
294 void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level);
295 void	rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, u8 level);
296 void	rtw_hal_clone_data(struct adapter *dst_adapt,
297 			   struct adapter *src_adapt);
298 
299 void rtw_hal_bcn_related_reg_setting(struct adapter *padapter);
300 
301 u32	rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath,
302 			   u32 RegAddr, u32 BitMask);
303 void	rtw_hal_write_rfreg(struct adapter *padapter,
304 			    enum rf_radio_path eRFPath, u32 RegAddr,
305 			    u32 BitMask, u32 Data);
306 
307 s32	rtw_hal_interrupt_handler(struct adapter *padapter);
308 
309 void	rtw_hal_set_bwmode(struct adapter *padapter,
310 			   enum ht_channel_width Bandwidth, u8 Offset);
311 void	rtw_hal_set_chan(struct adapter *padapter, u8 channel);
312 void	rtw_hal_dm_watchdog(struct adapter *padapter);
313 
314 u8	rtw_hal_antdiv_before_linked(struct adapter *padapter);
315 void	rtw_hal_antdiv_rssi_compared(struct adapter *padapter,
316 				     struct wlan_bssid_ex *dst,
317 				     struct wlan_bssid_ex *src);
318 
319 void rtw_hal_sreset_init(struct adapter *padapter);
320 u8   rtw_hal_sreset_get_wifi_status(struct adapter *padapter);
321 
322 void rtw_hal_notch_filter(struct adapter *adapter, bool enable);
323 void rtw_hal_reset_security_engine(struct adapter *adapter);
324 
325 void indicate_wx_scan_complete_event(struct adapter *padapter);
326 u8 rtw_do_join(struct adapter *padapter);
327 
328 #endif /* __HAL_INTF_H__ */
329