• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
2 /* Copyright(c) 2007 - 2012 Realtek Corporation. */
3 
4 #ifndef __HAL_INTF_H__
5 #define __HAL_INTF_H__
6 
7 #include "osdep_service.h"
8 #include "drv_types.h"
9 #include "Hal8188EPhyCfg.h"
10 
11 enum RTL871X_HCI_TYPE {
12 	RTW_PCIE	= BIT(0),
13 	RTW_USB		= BIT(1),
14 	RTW_SDIO	= BIT(2),
15 	RTW_GSPI	= BIT(3),
16 };
17 
18 enum _CHIP_TYPE {
19 	NULL_CHIP_TYPE,
20 	RTL8712_8188S_8191S_8192S,
21 	RTL8188C_8192C,
22 	RTL8192D,
23 	RTL8723A,
24 	RTL8188E,
25 	MAX_CHIP_TYPE
26 };
27 
28 enum hw_variables {
29 	HW_VAR_MEDIA_STATUS,
30 	HW_VAR_MEDIA_STATUS1,
31 	HW_VAR_SET_OPMODE,
32 	HW_VAR_MAC_ADDR,
33 	HW_VAR_BSSID,
34 	HW_VAR_INIT_RTS_RATE,
35 	HW_VAR_BASIC_RATE,
36 	HW_VAR_TXPAUSE,
37 	HW_VAR_BCN_FUNC,
38 	HW_VAR_CORRECT_TSF,
39 	HW_VAR_CHECK_BSSID,
40 	HW_VAR_MLME_DISCONNECT,
41 	HW_VAR_MLME_SITESURVEY,
42 	HW_VAR_MLME_JOIN,
43 	HW_VAR_BEACON_INTERVAL,
44 	HW_VAR_SLOT_TIME,
45 	HW_VAR_RESP_SIFS,
46 	HW_VAR_ACK_PREAMBLE,
47 	HW_VAR_SEC_CFG,
48 	HW_VAR_BCN_VALID,
49 	HW_VAR_RF_TYPE,
50 	HW_VAR_DM_FLAG,
51 	HW_VAR_DM_FUNC_OP,
52 	HW_VAR_DM_FUNC_SET,
53 	HW_VAR_DM_FUNC_CLR,
54 	HW_VAR_CAM_EMPTY_ENTRY,
55 	HW_VAR_CAM_INVALID_ALL,
56 	HW_VAR_CAM_WRITE,
57 	HW_VAR_CAM_READ,
58 	HW_VAR_AC_PARAM_VO,
59 	HW_VAR_AC_PARAM_VI,
60 	HW_VAR_AC_PARAM_BE,
61 	HW_VAR_AC_PARAM_BK,
62 	HW_VAR_ACM_CTRL,
63 	HW_VAR_AMPDU_MIN_SPACE,
64 	HW_VAR_AMPDU_FACTOR,
65 	HW_VAR_RXDMA_AGG_PG_TH,
66 	HW_VAR_SET_RPWM,
67 	HW_VAR_H2C_FW_PWRMODE,
68 	HW_VAR_H2C_FW_JOINBSSRPT,
69 	HW_VAR_FWLPS_RF_ON,
70 	HW_VAR_H2C_FW_P2P_PS_OFFLOAD,
71 	HW_VAR_TDLS_WRCR,
72 	HW_VAR_TDLS_INIT_CH_SEN,
73 	HW_VAR_TDLS_RS_RCR,
74 	HW_VAR_TDLS_DONE_CH_SEN,
75 	HW_VAR_INITIAL_GAIN,
76 	HW_VAR_TRIGGER_GPIO_0,
77 	HW_VAR_BT_SET_COEXIST,
78 	HW_VAR_BT_ISSUE_DELBA,
79 	HW_VAR_CURRENT_ANTENNA,
80 	HW_VAR_ANTENNA_DIVERSITY_LINK,
81 	HW_VAR_ANTENNA_DIVERSITY_SELECT,
82 	HW_VAR_SWITCH_EPHY_WoWLAN,
83 	HW_VAR_EFUSE_USAGE,
84 	HW_VAR_EFUSE_BYTES,
85 	HW_VAR_EFUSE_BT_USAGE,
86 	HW_VAR_EFUSE_BT_BYTES,
87 	HW_VAR_FIFO_CLEARN_UP,
88 	HW_VAR_CHECK_TXBUF,
89 	HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation,
90 			     * power control for MAC only */
91 	/*  The valid upper nav range for the HW updating, if the true value is
92 	 *  larger than the upper range, the HW won't update it. */
93 	/*  Unit in microsecond. 0 means disable this function. */
94 	HW_VAR_NAV_UPPER,
95 	HW_VAR_RPT_TIMER_SETTING,
96 	HW_VAR_TX_RPT_MAX_MACID,
97 	HW_VAR_H2C_MEDIA_STATUS_RPT,
98 	HW_VAR_CHK_HI_QUEUE_EMPTY,
99 };
100 
101 enum hal_def_variable {
102 	HAL_DEF_UNDERCORATEDSMOOTHEDPWDB,
103 	HAL_DEF_IS_SUPPORT_ANT_DIV,
104 	HAL_DEF_CURRENT_ANTENNA,
105 	HAL_DEF_DRVINFO_SZ,
106 	HAL_DEF_MAX_RECVBUF_SZ,
107 	HAL_DEF_RX_PACKET_OFFSET,
108 	HAL_DEF_DBG_DUMP_RXPKT,/* for dbg */
109 	HAL_DEF_DBG_DM_FUNC,/* for dbg */
110 	HAL_DEF_RA_DECISION_RATE,
111 	HAL_DEF_RA_SGI,
112 	HAL_DEF_PT_PWR_STATUS,
113 	HW_VAR_MAX_RX_AMPDU_FACTOR,
114 	HW_DEF_RA_INFO_DUMP,
115 	HAL_DEF_DBG_DUMP_TXPKT,
116 };
117 
118 enum hal_odm_variable {
119 	HAL_ODM_STA_INFO,
120 	HAL_ODM_P2P_STATE,
121 	HAL_ODM_WIFI_DISPLAY_STATE,
122 };
123 
124 enum hal_intf_ps_func {
125 	HAL_USB_SELECT_SUSPEND,
126 	HAL_MAX_ID,
127 };
128 
129 typedef s32 (*c2h_id_filter)(u8 id);
130 
131 struct hal_ops {
132 	u32	(*hal_power_on)(struct adapter *padapter);
133 	u32	(*hal_init)(struct adapter *padapter);
134 	u32	(*hal_deinit)(struct adapter *padapter);
135 
136 	void	(*free_hal_data)(struct adapter *padapter);
137 
138 	u32	(*inirp_init)(struct adapter *padapter);
139 	u32	(*inirp_deinit)(struct adapter *padapter);
140 
141 	s32	(*init_xmit_priv)(struct adapter *padapter);
142 
143 	s32	(*init_recv_priv)(struct adapter *padapter);
144 	void	(*free_recv_priv)(struct adapter *padapter);
145 
146 	void	(*InitSwLeds)(struct adapter *padapter);
147 	void	(*DeInitSwLeds)(struct adapter *padapter);
148 
149 	void	(*dm_init)(struct adapter *padapter);
150 	void	(*dm_deinit)(struct adapter *padapter);
151 	void	(*read_chip_version)(struct adapter *padapter);
152 
153 	void	(*init_default_value)(struct adapter *padapter);
154 
155 	void	(*intf_chip_configure)(struct adapter *padapter);
156 
157 	void	(*read_adapter_info)(struct adapter *padapter);
158 
159 	void	(*enable_interrupt)(struct adapter *padapter);
160 	void	(*disable_interrupt)(struct adapter *padapter);
161 	s32	(*interrupt_handler)(struct adapter *padapter);
162 
163 	void	(*set_bwmode_handler)(struct adapter *padapter,
164 				      enum ht_channel_width Bandwidth,
165 				      u8 Offset);
166 	void	(*set_channel_handler)(struct adapter *padapter, u8 channel);
167 
168 	void	(*hal_dm_watchdog)(struct adapter *padapter);
169 
170 	void	(*SetHwRegHandler)(struct adapter *padapter, u8	variable,
171 				   u8 *val);
172 	void	(*GetHwRegHandler)(struct adapter *padapter, u8	variable,
173 				   u8 *val);
174 
175 	u8	(*GetHalDefVarHandler)(struct adapter *padapter,
176 				       enum hal_def_variable eVariable,
177 				       void *pValue);
178 	u8	(*SetHalDefVarHandler)(struct adapter *padapter,
179 				       enum hal_def_variable eVariable,
180 				       void *pValue);
181 
182 	void	(*GetHalODMVarHandler)(struct adapter *padapter,
183 				       enum hal_odm_variable eVariable,
184 				       void *pValue1, bool bSet);
185 	void	(*SetHalODMVarHandler)(struct adapter *padapter,
186 				       enum hal_odm_variable eVariable,
187 				       void *pValue1, bool bSet);
188 
189 	void	(*UpdateRAMaskHandler)(struct adapter *padapter,
190 				       u32 mac_id, u8 rssi_level);
191 	void	(*SetBeaconRelatedRegistersHandler)(struct adapter *padapter);
192 
193 	void	(*Add_RateATid)(struct adapter *adapter, u32 bitmap, u8 arg,
194 				u8 rssi_level);
195 	void	(*run_thread)(struct adapter *adapter);
196 	void	(*cancel_thread)(struct adapter *adapter);
197 
198 	u8	(*AntDivBeforeLinkHandler)(struct adapter *adapter);
199 	void	(*AntDivCompareHandler)(struct adapter *adapter,
200 					struct wlan_bssid_ex *dst,
201 					struct wlan_bssid_ex *src);
202 	u8	(*interface_ps_func)(struct adapter *padapter,
203 				     enum hal_intf_ps_func efunc_id, u8 *val);
204 
205 	s32	(*hal_xmit)(struct adapter *padapter,
206 			    struct xmit_frame *pxmitframe);
207 	s32 (*mgnt_xmit)(struct adapter *padapter,
208 			 struct xmit_frame *pmgntframe);
209 	s32 (*hal_xmitframe_enqueue)(struct adapter *padapter,
210 				     struct xmit_frame *pxmitframe);
211 
212 	u32	(*read_bbreg)(struct adapter *padapter, u32 RegAddr,
213 			      u32 BitMask);
214 	void	(*write_bbreg)(struct adapter *padapter, u32 RegAddr,
215 			       u32 BitMask, u32 Data);
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 (*EfusePowerSwitch)(struct adapter *padapter, u8 bWrite,
224 				 u8 PwrState);
225 	void (*ReadEFuse)(struct adapter *padapter, u8 efuseType, u16 _offset,
226 			  u16 _size_byte, u8 *pbuf, bool bPseudoTest);
227 	void (*EFUSEGetEfuseDefinition)(struct adapter *padapter, u8 efuseType,
228 					u8 type, void *pOut, bool bPseudoTest);
229 	u16	(*EfuseGetCurrentSize)(struct adapter *padapter, u8 efuseType,
230 				       bool bPseudoTest);
231 	int	(*Efuse_PgPacketRead)(struct adapter *adapter, u8 offset,
232 				      u8 *data, bool bPseudoTest);
233 	int	(*Efuse_PgPacketWrite)(struct adapter *padapter, u8 offset,
234 				       u8 word_en, u8 *data, bool bPseudoTest);
235 	u8	(*Efuse_WordEnableDataWrite)(struct adapter *padapter,
236 					     u16 efuse_addr, u8 word_en,
237 					     u8 *data, bool bPseudoTest);
238 	bool	(*Efuse_PgPacketWrite_BT)(struct adapter *padapter, u8 offset,
239 					  u8 word_en, u8 *data, bool test);
240 
241 	void (*sreset_init_value)(struct adapter *padapter);
242 	void (*sreset_reset_value)(struct adapter *padapter);
243 	void (*silentreset)(struct adapter *padapter);
244 	void (*sreset_xmit_status_check)(struct adapter *padapter);
245 	void (*sreset_linked_status_check) (struct adapter *padapter);
246 	u8 (*sreset_get_wifi_status)(struct adapter *padapter);
247 
248 	int (*IOL_exec_cmds_sync)(struct adapter *padapter,
249 				  struct xmit_frame *frame, u32 max_wait,
250 				  u32 bndy_cnt);
251 
252 	void (*hal_notch_filter)(struct adapter *adapter, bool enable);
253 	void (*hal_reset_security_engine)(struct adapter *adapter);
254 	s32 (*c2h_handler)(struct adapter *padapter,
255 			   struct c2h_evt_hdr *c2h_evt);
256 	c2h_id_filter c2h_id_filter_ccx;
257 };
258 
259 enum rt_eeprom_type {
260 	EEPROM_93C46,
261 	EEPROM_93C56,
262 	EEPROM_BOOT_EFUSE,
263 };
264 
265 #define RF_CHANGE_BY_INIT	0
266 #define RF_CHANGE_BY_IPS	BIT(28)
267 #define RF_CHANGE_BY_PS		BIT(29)
268 #define RF_CHANGE_BY_HW		BIT(30)
269 #define RF_CHANGE_BY_SW		BIT(31)
270 
271 enum hardware_type {
272 	HARDWARE_TYPE_RTL8180,
273 	HARDWARE_TYPE_RTL8185,
274 	HARDWARE_TYPE_RTL8187,
275 	HARDWARE_TYPE_RTL8188,
276 	HARDWARE_TYPE_RTL8190P,
277 	HARDWARE_TYPE_RTL8192E,
278 	HARDWARE_TYPE_RTL819xU,
279 	HARDWARE_TYPE_RTL8192SE,
280 	HARDWARE_TYPE_RTL8192SU,
281 	HARDWARE_TYPE_RTL8192CE,
282 	HARDWARE_TYPE_RTL8192CU,
283 	HARDWARE_TYPE_RTL8192DE,
284 	HARDWARE_TYPE_RTL8192DU,
285 	HARDWARE_TYPE_RTL8723AE,
286 	HARDWARE_TYPE_RTL8723AU,
287 	HARDWARE_TYPE_RTL8723AS,
288 	HARDWARE_TYPE_RTL8188EE,
289 	HARDWARE_TYPE_RTL8188EU,
290 	HARDWARE_TYPE_RTL8188ES,
291 	HARDWARE_TYPE_MAX,
292 };
293 
294 /*  RTL8188E Series */
295 #define IS_HARDWARE_TYPE_8188EE(_Adapter)			\
296 (((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EE)
297 #define IS_HARDWARE_TYPE_8188EU(_Adapter)			\
298 (((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EU)
299 #define IS_HARDWARE_TYPE_8188ES(_Adapter)			\
300 (((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188ES)
301 #define	IS_HARDWARE_TYPE_8188E(_Adapter)	\
302 (IS_HARDWARE_TYPE_8188EE(_Adapter) || IS_HARDWARE_TYPE_8188EU(_Adapter) || \
303  IS_HARDWARE_TYPE_8188ES(_Adapter))
304 
305 #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv)
306 
307 #define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse)
308 
309 void rtl8188eu_set_hal_ops(struct adapter *padapter);
310 void rtw_hal_def_value_init(struct adapter *padapter);
311 
312 void	rtw_hal_free_data(struct adapter *padapter);
313 
314 void rtw_hal_dm_init(struct adapter *padapter);
315 void rtw_hal_dm_deinit(struct adapter *padapter);
316 void rtw_hal_sw_led_init(struct adapter *padapter);
317 void rtw_hal_sw_led_deinit(struct adapter *padapter);
318 
319 u32 rtw_hal_power_on(struct adapter *padapter);
320 uint rtw_hal_init(struct adapter *padapter);
321 uint rtw_hal_deinit(struct adapter *padapter);
322 void rtw_hal_stop(struct adapter *padapter);
323 void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val);
324 void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val);
325 
326 void rtw_hal_chip_configure(struct adapter *padapter);
327 void rtw_hal_read_chip_info(struct adapter *padapter);
328 void rtw_hal_read_chip_version(struct adapter *padapter);
329 
330 u8 rtw_hal_set_def_var(struct adapter *padapter,
331 		       enum hal_def_variable eVariable, void *pValue);
332 u8 rtw_hal_get_def_var(struct adapter *padapter,
333 		       enum hal_def_variable eVariable, void *pValue);
334 
335 void rtw_hal_set_odm_var(struct adapter *padapter,
336 			 enum hal_odm_variable eVariable, void *pValue1,
337 			 bool bSet);
338 void rtw_hal_get_odm_var(struct adapter *padapter,
339 			 enum hal_odm_variable eVariable,
340 			 void *pValue1, bool bSet);
341 
342 void rtw_hal_enable_interrupt(struct adapter *padapter);
343 void rtw_hal_disable_interrupt(struct adapter *padapter);
344 
345 u32	rtw_hal_inirp_init(struct adapter *padapter);
346 u32	rtw_hal_inirp_deinit(struct adapter *padapter);
347 
348 u8	rtw_hal_intf_ps_func(struct adapter *padapter,
349 			     enum hal_intf_ps_func efunc_id, u8 *val);
350 s32 rtw_hal_xmitframe_enqueue(struct adapter *padapter,
351 			      struct xmit_frame *pxmitframe);
352 
353 s32	rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe);
354 s32	rtw_hal_mgnt_xmit(struct adapter *padapter,
355 			  struct xmit_frame *pmgntframe);
356 
357 s32	rtw_hal_init_xmit_priv(struct adapter *padapter);
358 
359 s32	rtw_hal_init_recv_priv(struct adapter *padapter);
360 void	rtw_hal_free_recv_priv(struct adapter *padapter);
361 
362 void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level);
363 void	rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, u8 level);
364 void	rtw_hal_clone_data(struct adapter *dst_adapt,
365 			   struct adapter *src_adapt);
366 void	rtw_hal_start_thread(struct adapter *padapter);
367 void	rtw_hal_stop_thread(struct adapter *padapter);
368 
369 void rtw_hal_bcn_related_reg_setting(struct adapter *padapter);
370 
371 u32	rtw_hal_read_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask);
372 void	rtw_hal_write_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask,
373 			    u32 Data);
374 u32	rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath,
375 			   u32 RegAddr, u32 BitMask);
376 void	rtw_hal_write_rfreg(struct adapter *padapter,
377 			    enum rf_radio_path eRFPath, u32 RegAddr,
378 			    u32 BitMask, u32 Data);
379 
380 s32	rtw_hal_interrupt_handler(struct adapter *padapter);
381 
382 void	rtw_hal_set_bwmode(struct adapter *padapter,
383 			   enum ht_channel_width Bandwidth, u8 Offset);
384 void	rtw_hal_set_chan(struct adapter *padapter, u8 channel);
385 void	rtw_hal_dm_watchdog(struct adapter *padapter);
386 
387 u8	rtw_hal_antdiv_before_linked(struct adapter *padapter);
388 void	rtw_hal_antdiv_rssi_compared(struct adapter *padapter,
389 				     struct wlan_bssid_ex *dst,
390 				     struct wlan_bssid_ex *src);
391 
392 void rtw_hal_sreset_init(struct adapter *padapter);
393 void rtw_hal_sreset_reset(struct adapter *padapter);
394 void rtw_hal_sreset_reset_value(struct adapter *padapter);
395 void rtw_hal_sreset_xmit_status_check(struct adapter *padapter);
396 void rtw_hal_sreset_linked_status_check(struct adapter *padapter);
397 u8   rtw_hal_sreset_get_wifi_status(struct adapter *padapter);
398 
399 int rtw_hal_iol_cmd(struct adapter  *adapter, struct xmit_frame *xmit_frame,
400 		    u32 max_wating_ms, u32 bndy_cnt);
401 
402 void rtw_hal_notch_filter(struct adapter *adapter, bool enable);
403 void rtw_hal_reset_security_engine(struct adapter *adapter);
404 
405 s32 rtw_hal_c2h_handler(struct adapter *adapter,
406 			struct c2h_evt_hdr *c2h_evt);
407 c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter);
408 void indicate_wx_scan_complete_event(struct adapter *padapter);
409 u8 rtw_do_join(struct adapter *padapter);
410 
411 #endif /* __HAL_INTF_H__ */
412