linux/drivers/staging/rtl8188eu/hal/hal_intf.c
<<
>>
Prefs
   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
  21#define _HAL_INTF_C_
  22#include <osdep_service.h>
  23#include <drv_types.h>
  24#include <hal_intf.h>
  25#include <usb_hal.h>
  26
  27void rtw_hal_chip_configure(struct adapter *adapt)
  28{
  29        if (adapt->HalFunc.intf_chip_configure)
  30                adapt->HalFunc.intf_chip_configure(adapt);
  31}
  32
  33void rtw_hal_read_chip_info(struct adapter *adapt)
  34{
  35        if (adapt->HalFunc.read_adapter_info)
  36                adapt->HalFunc.read_adapter_info(adapt);
  37}
  38
  39void rtw_hal_read_chip_version(struct adapter *adapt)
  40{
  41        if (adapt->HalFunc.read_chip_version)
  42                adapt->HalFunc.read_chip_version(adapt);
  43}
  44
  45void rtw_hal_def_value_init(struct adapter *adapt)
  46{
  47        if (adapt->HalFunc.init_default_value)
  48                adapt->HalFunc.init_default_value(adapt);
  49}
  50
  51void rtw_hal_free_data(struct adapter *adapt)
  52{
  53        if (adapt->HalFunc.free_hal_data)
  54                adapt->HalFunc.free_hal_data(adapt);
  55}
  56
  57void rtw_hal_dm_init(struct adapter *adapt)
  58{
  59        if (adapt->HalFunc.dm_init)
  60                adapt->HalFunc.dm_init(adapt);
  61}
  62
  63void rtw_hal_sw_led_init(struct adapter *adapt)
  64{
  65        if (adapt->HalFunc.InitSwLeds)
  66                adapt->HalFunc.InitSwLeds(adapt);
  67}
  68
  69void rtw_hal_sw_led_deinit(struct adapter *adapt)
  70{
  71        if (adapt->HalFunc.DeInitSwLeds)
  72                adapt->HalFunc.DeInitSwLeds(adapt);
  73}
  74
  75u32 rtw_hal_power_on(struct adapter *adapt)
  76{
  77        if (adapt->HalFunc.hal_power_on)
  78                return adapt->HalFunc.hal_power_on(adapt);
  79        return _FAIL;
  80}
  81
  82uint     rtw_hal_init(struct adapter *adapt)
  83{
  84        uint    status = _SUCCESS;
  85
  86        adapt->hw_init_completed = false;
  87
  88        status = adapt->HalFunc.hal_init(adapt);
  89
  90        if (status == _SUCCESS) {
  91                adapt->hw_init_completed = true;
  92
  93                if (adapt->registrypriv.notch_filter == 1)
  94                        rtw_hal_notch_filter(adapt, 1);
  95
  96                rtw_hal_reset_security_engine(adapt);
  97        } else {
  98                adapt->hw_init_completed = false;
  99                DBG_88E("rtw_hal_init: hal__init fail\n");
 100        }
 101
 102        RT_TRACE(_module_hal_init_c_, _drv_err_,
 103                 ("-rtl871x_hal_init:status=0x%x\n", status));
 104
 105        return status;
 106}
 107
 108uint rtw_hal_deinit(struct adapter *adapt)
 109{
 110        uint    status = _SUCCESS;
 111
 112        status = adapt->HalFunc.hal_deinit(adapt);
 113
 114        if (status == _SUCCESS)
 115                adapt->hw_init_completed = false;
 116        else
 117                DBG_88E("\n rtw_hal_deinit: hal_init fail\n");
 118
 119        return status;
 120}
 121
 122void rtw_hal_set_hwreg(struct adapter *adapt, u8 variable, u8 *val)
 123{
 124        if (adapt->HalFunc.SetHwRegHandler)
 125                adapt->HalFunc.SetHwRegHandler(adapt, variable, val);
 126}
 127
 128void rtw_hal_get_hwreg(struct adapter *adapt, u8 variable, u8 *val)
 129{
 130        if (adapt->HalFunc.GetHwRegHandler)
 131                adapt->HalFunc.GetHwRegHandler(adapt, variable, val);
 132}
 133
 134u8 rtw_hal_set_def_var(struct adapter *adapt, enum hal_def_variable var,
 135                      void *val)
 136{
 137        if (adapt->HalFunc.SetHalDefVarHandler)
 138                return adapt->HalFunc.SetHalDefVarHandler(adapt, var, val);
 139        return _FAIL;
 140}
 141
 142u8 rtw_hal_get_def_var(struct adapter *adapt,
 143                       enum hal_def_variable var, void *val)
 144{
 145        if (adapt->HalFunc.GetHalDefVarHandler)
 146                return adapt->HalFunc.GetHalDefVarHandler(adapt, var, val);
 147        return _FAIL;
 148}
 149
 150void rtw_hal_set_odm_var(struct adapter *adapt,
 151                         enum hal_odm_variable var, void *val1,
 152                         bool set)
 153{
 154        if (adapt->HalFunc.SetHalODMVarHandler)
 155                adapt->HalFunc.SetHalODMVarHandler(adapt, var,
 156                                                      val1, set);
 157}
 158
 159void rtw_hal_enable_interrupt(struct adapter *adapt)
 160{
 161        if (adapt->HalFunc.enable_interrupt)
 162                adapt->HalFunc.enable_interrupt(adapt);
 163        else
 164                DBG_88E("%s: HalFunc.enable_interrupt is NULL!\n", __func__);
 165}
 166
 167void rtw_hal_disable_interrupt(struct adapter *adapt)
 168{
 169        if (adapt->HalFunc.disable_interrupt)
 170                adapt->HalFunc.disable_interrupt(adapt);
 171        else
 172                DBG_88E("%s: HalFunc.disable_interrupt is NULL!\n", __func__);
 173}
 174
 175u32 rtw_hal_inirp_init(struct adapter *adapt)
 176{
 177        u32 rst = _FAIL;
 178
 179        if (adapt->HalFunc.inirp_init)
 180                rst = adapt->HalFunc.inirp_init(adapt);
 181        else
 182                DBG_88E(" %s HalFunc.inirp_init is NULL!!!\n", __func__);
 183        return rst;
 184}
 185
 186u32 rtw_hal_inirp_deinit(struct adapter *adapt)
 187{
 188        if (adapt->HalFunc.inirp_deinit)
 189                return adapt->HalFunc.inirp_deinit(adapt);
 190
 191        return _FAIL;
 192}
 193
 194s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
 195{
 196        if (adapt->HalFunc.hal_xmit)
 197                return adapt->HalFunc.hal_xmit(adapt, pxmitframe);
 198
 199        return false;
 200}
 201
 202s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe)
 203{
 204        s32 ret = _FAIL;
 205        if (adapt->HalFunc.mgnt_xmit)
 206                ret = adapt->HalFunc.mgnt_xmit(adapt, pmgntframe);
 207        return ret;
 208}
 209
 210s32 rtw_hal_init_xmit_priv(struct adapter *adapt)
 211{
 212        if (adapt->HalFunc.init_xmit_priv != NULL)
 213                return adapt->HalFunc.init_xmit_priv(adapt);
 214        return _FAIL;
 215}
 216
 217s32 rtw_hal_init_recv_priv(struct adapter *adapt)
 218{
 219        if (adapt->HalFunc.init_recv_priv)
 220                return adapt->HalFunc.init_recv_priv(adapt);
 221
 222        return _FAIL;
 223}
 224
 225void rtw_hal_free_recv_priv(struct adapter *adapt)
 226{
 227        if (adapt->HalFunc.free_recv_priv)
 228                adapt->HalFunc.free_recv_priv(adapt);
 229}
 230
 231void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level)
 232{
 233        struct mlme_priv *pmlmepriv = &(adapt->mlmepriv);
 234
 235        if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
 236#ifdef CONFIG_88EU_AP_MODE
 237                struct sta_info *psta = NULL;
 238                struct sta_priv *pstapriv = &adapt->stapriv;
 239                if ((mac_id-1) > 0)
 240                        psta = pstapriv->sta_aid[(mac_id-1) - 1];
 241                if (psta)
 242                        add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/
 243#endif
 244        } else {
 245                if (adapt->HalFunc.UpdateRAMaskHandler)
 246                        adapt->HalFunc.UpdateRAMaskHandler(adapt, mac_id,
 247                                                              rssi_level);
 248        }
 249}
 250
 251void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg,
 252                        u8 rssi_level)
 253{
 254        if (adapt->HalFunc.Add_RateATid)
 255                adapt->HalFunc.Add_RateATid(adapt, bitmap, arg,
 256                                               rssi_level);
 257}
 258
 259u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rfpath,
 260                       u32 regaddr, u32 bitmask)
 261{
 262        u32 data = 0;
 263
 264        if (adapt->HalFunc.read_rfreg)
 265                data = adapt->HalFunc.read_rfreg(adapt, rfpath, regaddr,
 266                                                    bitmask);
 267        return data;
 268}
 269
 270void rtw_hal_write_rfreg(struct adapter *adapt, enum rf_radio_path rfpath,
 271                         u32 regaddr, u32 bitmask, u32 data)
 272{
 273        if (adapt->HalFunc.write_rfreg)
 274                adapt->HalFunc.write_rfreg(adapt, rfpath, regaddr,
 275                                              bitmask, data);
 276}
 277
 278s32 rtw_hal_interrupt_handler(struct adapter *adapt)
 279{
 280        if (adapt->HalFunc.interrupt_handler)
 281                return adapt->HalFunc.interrupt_handler(adapt);
 282        return _FAIL;
 283}
 284
 285void rtw_hal_set_bwmode(struct adapter *adapt,
 286                        enum ht_channel_width bandwidth, u8 offset)
 287{
 288        if (adapt->HalFunc.set_bwmode_handler)
 289                adapt->HalFunc.set_bwmode_handler(adapt, bandwidth,
 290                                                     offset);
 291}
 292
 293void rtw_hal_set_chan(struct adapter *adapt, u8 channel)
 294{
 295        if (adapt->HalFunc.set_channel_handler)
 296                adapt->HalFunc.set_channel_handler(adapt, channel);
 297}
 298
 299void rtw_hal_dm_watchdog(struct adapter *adapt)
 300{
 301        if (adapt->HalFunc.hal_dm_watchdog)
 302                adapt->HalFunc.hal_dm_watchdog(adapt);
 303}
 304
 305void rtw_hal_bcn_related_reg_setting(struct adapter *adapt)
 306{
 307        if (adapt->HalFunc.SetBeaconRelatedRegistersHandler)
 308                adapt->HalFunc.SetBeaconRelatedRegistersHandler(adapt);
 309}
 310
 311u8 rtw_hal_antdiv_before_linked(struct adapter *adapt)
 312{
 313        if (adapt->HalFunc.AntDivBeforeLinkHandler)
 314                return adapt->HalFunc.AntDivBeforeLinkHandler(adapt);
 315        return false;
 316}
 317
 318void rtw_hal_antdiv_rssi_compared(struct adapter *adapt,
 319                                  struct wlan_bssid_ex *dst,
 320                                  struct wlan_bssid_ex *src)
 321{
 322        if (adapt->HalFunc.AntDivCompareHandler)
 323                adapt->HalFunc.AntDivCompareHandler(adapt, dst, src);
 324}
 325
 326void rtw_hal_sreset_init(struct adapter *adapt)
 327{
 328        if (adapt->HalFunc.sreset_init_value)
 329                adapt->HalFunc.sreset_init_value(adapt);
 330}
 331
 332u8   rtw_hal_sreset_get_wifi_status(struct adapter *adapt)
 333{
 334        u8 status = 0;
 335
 336        if (adapt->HalFunc.sreset_get_wifi_status)
 337                status = adapt->HalFunc.sreset_get_wifi_status(adapt);
 338        return status;
 339}
 340
 341void rtw_hal_notch_filter(struct adapter *adapter, bool enable)
 342{
 343        if (adapter->HalFunc.hal_notch_filter)
 344                adapter->HalFunc.hal_notch_filter(adapter, enable);
 345}
 346
 347void rtw_hal_reset_security_engine(struct adapter *adapter)
 348{
 349        if (adapter->HalFunc.hal_reset_security_engine)
 350                adapter->HalFunc.hal_reset_security_engine(adapter);
 351}
 352