1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
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.
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
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
19 ******************************************************************************/
22 #include <osdep_service.h>
23 #include <drv_types.h>
27 void rtw_hal_chip_configure(struct adapter
*adapt
)
29 if (adapt
->HalFunc
.intf_chip_configure
)
30 adapt
->HalFunc
.intf_chip_configure(adapt
);
33 void rtw_hal_read_chip_info(struct adapter
*adapt
)
35 if (adapt
->HalFunc
.read_adapter_info
)
36 adapt
->HalFunc
.read_adapter_info(adapt
);
39 void rtw_hal_read_chip_version(struct adapter
*adapt
)
41 if (adapt
->HalFunc
.read_chip_version
)
42 adapt
->HalFunc
.read_chip_version(adapt
);
45 void rtw_hal_def_value_init(struct adapter
*adapt
)
47 if (adapt
->HalFunc
.init_default_value
)
48 adapt
->HalFunc
.init_default_value(adapt
);
51 void rtw_hal_free_data(struct adapter
*adapt
)
53 if (adapt
->HalFunc
.free_hal_data
)
54 adapt
->HalFunc
.free_hal_data(adapt
);
57 void rtw_hal_dm_init(struct adapter
*adapt
)
59 if (adapt
->HalFunc
.dm_init
)
60 adapt
->HalFunc
.dm_init(adapt
);
63 void rtw_hal_sw_led_init(struct adapter
*adapt
)
65 if (adapt
->HalFunc
.InitSwLeds
)
66 adapt
->HalFunc
.InitSwLeds(adapt
);
69 void rtw_hal_sw_led_deinit(struct adapter
*adapt
)
71 if (adapt
->HalFunc
.DeInitSwLeds
)
72 adapt
->HalFunc
.DeInitSwLeds(adapt
);
75 u32
rtw_hal_power_on(struct adapter
*adapt
)
77 if (adapt
->HalFunc
.hal_power_on
)
78 return adapt
->HalFunc
.hal_power_on(adapt
);
82 uint
rtw_hal_init(struct adapter
*adapt
)
84 uint status
= _SUCCESS
;
86 adapt
->hw_init_completed
= false;
88 status
= adapt
->HalFunc
.hal_init(adapt
);
90 if (status
== _SUCCESS
) {
91 adapt
->hw_init_completed
= true;
93 if (adapt
->registrypriv
.notch_filter
== 1)
94 rtw_hal_notch_filter(adapt
, 1);
96 rtw_hal_reset_security_engine(adapt
);
98 adapt
->hw_init_completed
= false;
99 DBG_88E("rtw_hal_init: hal__init fail\n");
102 RT_TRACE(_module_hal_init_c_
, _drv_err_
,
103 ("-rtl871x_hal_init:status=0x%x\n", status
));
108 uint
rtw_hal_deinit(struct adapter
*adapt
)
110 uint status
= _SUCCESS
;
112 status
= adapt
->HalFunc
.hal_deinit(adapt
);
114 if (status
== _SUCCESS
)
115 adapt
->hw_init_completed
= false;
117 DBG_88E("\n rtw_hal_deinit: hal_init fail\n");
122 void rtw_hal_set_hwreg(struct adapter
*adapt
, u8 variable
, u8
*val
)
124 if (adapt
->HalFunc
.SetHwRegHandler
)
125 adapt
->HalFunc
.SetHwRegHandler(adapt
, variable
, val
);
128 void rtw_hal_get_hwreg(struct adapter
*adapt
, u8 variable
, u8
*val
)
130 if (adapt
->HalFunc
.GetHwRegHandler
)
131 adapt
->HalFunc
.GetHwRegHandler(adapt
, variable
, val
);
134 u8
rtw_hal_get_def_var(struct adapter
*adapt
,
135 enum hal_def_variable var
, void *val
)
137 if (adapt
->HalFunc
.GetHalDefVarHandler
)
138 return adapt
->HalFunc
.GetHalDefVarHandler(adapt
, var
, val
);
142 void rtw_hal_set_odm_var(struct adapter
*adapt
,
143 enum hal_odm_variable var
, void *val1
,
146 if (adapt
->HalFunc
.SetHalODMVarHandler
)
147 adapt
->HalFunc
.SetHalODMVarHandler(adapt
, var
,
151 u32
rtw_hal_inirp_init(struct adapter
*adapt
)
155 if (adapt
->HalFunc
.inirp_init
)
156 rst
= adapt
->HalFunc
.inirp_init(adapt
);
158 DBG_88E(" %s HalFunc.inirp_init is NULL!!!\n", __func__
);
162 u32
rtw_hal_inirp_deinit(struct adapter
*adapt
)
164 if (adapt
->HalFunc
.inirp_deinit
)
165 return adapt
->HalFunc
.inirp_deinit(adapt
);
170 s32
rtw_hal_xmit(struct adapter
*adapt
, struct xmit_frame
*pxmitframe
)
172 if (adapt
->HalFunc
.hal_xmit
)
173 return adapt
->HalFunc
.hal_xmit(adapt
, pxmitframe
);
178 s32
rtw_hal_mgnt_xmit(struct adapter
*adapt
, struct xmit_frame
*pmgntframe
)
182 if (adapt
->HalFunc
.mgnt_xmit
)
183 ret
= adapt
->HalFunc
.mgnt_xmit(adapt
, pmgntframe
);
187 s32
rtw_hal_init_xmit_priv(struct adapter
*adapt
)
189 if (adapt
->HalFunc
.init_xmit_priv
!= NULL
)
190 return adapt
->HalFunc
.init_xmit_priv(adapt
);
194 s32
rtw_hal_init_recv_priv(struct adapter
*adapt
)
196 if (adapt
->HalFunc
.init_recv_priv
)
197 return adapt
->HalFunc
.init_recv_priv(adapt
);
202 void rtw_hal_free_recv_priv(struct adapter
*adapt
)
204 if (adapt
->HalFunc
.free_recv_priv
)
205 adapt
->HalFunc
.free_recv_priv(adapt
);
208 void rtw_hal_update_ra_mask(struct adapter
*adapt
, u32 mac_id
, u8 rssi_level
)
210 struct mlme_priv
*pmlmepriv
= &(adapt
->mlmepriv
);
212 if (check_fwstate(pmlmepriv
, WIFI_AP_STATE
) == true) {
213 #ifdef CONFIG_88EU_AP_MODE
214 struct sta_info
*psta
= NULL
;
215 struct sta_priv
*pstapriv
= &adapt
->stapriv
;
218 psta
= pstapriv
->sta_aid
[(mac_id
-1) - 1];
220 add_RATid(adapt
, psta
, 0);/* todo: based on rssi_level*/
223 if (adapt
->HalFunc
.UpdateRAMaskHandler
)
224 adapt
->HalFunc
.UpdateRAMaskHandler(adapt
, mac_id
,
229 void rtw_hal_add_ra_tid(struct adapter
*adapt
, u32 bitmap
, u8 arg
,
232 if (adapt
->HalFunc
.Add_RateATid
)
233 adapt
->HalFunc
.Add_RateATid(adapt
, bitmap
, arg
,
237 u32
rtw_hal_read_rfreg(struct adapter
*adapt
, enum rf_radio_path rfpath
,
238 u32 regaddr
, u32 bitmask
)
242 if (adapt
->HalFunc
.read_rfreg
)
243 data
= adapt
->HalFunc
.read_rfreg(adapt
, rfpath
, regaddr
,
248 void rtw_hal_set_bwmode(struct adapter
*adapt
,
249 enum ht_channel_width bandwidth
, u8 offset
)
251 if (adapt
->HalFunc
.set_bwmode_handler
)
252 adapt
->HalFunc
.set_bwmode_handler(adapt
, bandwidth
,
256 void rtw_hal_set_chan(struct adapter
*adapt
, u8 channel
)
258 if (adapt
->HalFunc
.set_channel_handler
)
259 adapt
->HalFunc
.set_channel_handler(adapt
, channel
);
262 void rtw_hal_dm_watchdog(struct adapter
*adapt
)
264 if (adapt
->HalFunc
.hal_dm_watchdog
)
265 adapt
->HalFunc
.hal_dm_watchdog(adapt
);
268 void rtw_hal_bcn_related_reg_setting(struct adapter
*adapt
)
270 if (adapt
->HalFunc
.SetBeaconRelatedRegistersHandler
)
271 adapt
->HalFunc
.SetBeaconRelatedRegistersHandler(adapt
);
274 u8
rtw_hal_antdiv_before_linked(struct adapter
*adapt
)
276 if (adapt
->HalFunc
.AntDivBeforeLinkHandler
)
277 return adapt
->HalFunc
.AntDivBeforeLinkHandler(adapt
);
281 void rtw_hal_antdiv_rssi_compared(struct adapter
*adapt
,
282 struct wlan_bssid_ex
*dst
,
283 struct wlan_bssid_ex
*src
)
285 if (adapt
->HalFunc
.AntDivCompareHandler
)
286 adapt
->HalFunc
.AntDivCompareHandler(adapt
, dst
, src
);
289 void rtw_hal_sreset_init(struct adapter
*adapt
)
291 if (adapt
->HalFunc
.sreset_init_value
)
292 adapt
->HalFunc
.sreset_init_value(adapt
);
295 void rtw_hal_notch_filter(struct adapter
*adapter
, bool enable
)
297 if (adapter
->HalFunc
.hal_notch_filter
)
298 adapter
->HalFunc
.hal_notch_filter(adapter
, enable
);
301 void rtw_hal_reset_security_engine(struct adapter
*adapter
)
303 if (adapter
->HalFunc
.hal_reset_security_engine
)
304 adapter
->HalFunc
.hal_reset_security_engine(adapter
);