1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-26 15:14:02 +00:00
rtl8812au/hal/phydm/phydm_interface.c

1469 lines
42 KiB
C
Raw Normal View History

2018-06-22 16:48:32 +00:00
/******************************************************************************
*
2018-08-24 20:52:34 +00:00
* Copyright(c) 2007 - 2017 Realtek Corporation.
2018-06-22 16:48:32 +00:00
*
* 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
2018-08-24 20:52:34 +00:00
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
2018-06-22 16:48:32 +00:00
* more details.
*
2018-08-24 20:52:34 +00:00
* 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>
*
2018-06-22 16:48:32 +00:00
*****************************************************************************/
2019-05-24 19:43:57 +00:00
/*@************************************************************
2018-06-22 16:48:32 +00:00
* include files
2019-05-24 19:43:57 +00:00
************************************************************/
2018-06-22 16:48:32 +00:00
#include "mp_precomp.h"
#include "phydm_precomp.h"
2019-05-24 19:43:57 +00:00
/*@
2018-06-22 16:48:32 +00:00
* ODM IO Relative API.
2019-05-24 19:43:57 +00:00
*/
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
u8 odm_read_1byte(struct dm_struct *dm, u32 reg_addr)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
return RTL_R8(reg_addr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_read_byte(rtlpriv, reg_addr);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
return rtw_read8(rtwdev, reg_addr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
return rtw_read8(adapter, reg_addr);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return PlatformEFIORead1Byte(adapter, reg_addr);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
return rtw_read8(adapter, reg_addr);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
u16 odm_read_2byte(struct dm_struct *dm, u32 reg_addr)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
return RTL_R16(reg_addr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_read_word(rtlpriv, reg_addr);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
return rtw_read16(rtwdev, reg_addr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
return rtw_read16(adapter, reg_addr);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return PlatformEFIORead2Byte(adapter, reg_addr);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
return rtw_read16(adapter, reg_addr);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
u32 odm_read_4byte(struct dm_struct *dm, u32 reg_addr)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
return RTL_R32(reg_addr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_read_dword(rtlpriv, reg_addr);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
return rtw_read32(rtwdev, reg_addr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
return rtw_read32(adapter, reg_addr);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return PlatformEFIORead4Byte(adapter, reg_addr);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
return rtw_read32(adapter, reg_addr);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void odm_write_1byte(struct dm_struct *dm, u32 reg_addr, u8 data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
2018-06-22 16:48:32 +00:00
RTL_W8(reg_addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_write_byte(rtlpriv, reg_addr, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
rtw_write8(rtwdev, reg_addr, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
rtw_write8(adapter, reg_addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
PlatformEFIOWrite1Byte(adapter, reg_addr, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
rtw_write8(adapter, reg_addr, data);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void odm_write_2byte(struct dm_struct *dm, u32 reg_addr, u16 data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
2018-06-22 16:48:32 +00:00
RTL_W16(reg_addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_write_word(rtlpriv, reg_addr, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
rtw_write16(rtwdev, reg_addr, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
rtw_write16(adapter, reg_addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
PlatformEFIOWrite2Byte(adapter, reg_addr, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
rtw_write16(adapter, reg_addr, data);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void odm_write_4byte(struct dm_struct *dm, u32 reg_addr, u32 data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
2018-06-22 16:48:32 +00:00
RTL_W32(reg_addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_write_dword(rtlpriv, reg_addr, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
rtw_write32(rtwdev, reg_addr, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
rtw_write32(adapter, reg_addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
PlatformEFIOWrite4Byte(adapter, reg_addr, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
rtw_write32(adapter, reg_addr, data);
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void odm_set_mac_reg(struct dm_struct *dm, u32 reg_addr, u32 bit_mask, u32 data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
phy_set_bb_reg(dm->priv, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
PHY_SetBBReg(adapter, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_set_bbreg(rtlpriv->hw, reg_addr, bit_mask, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
rtw_set_reg_with_mask(rtwdev, reg_addr, bit_mask, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
phy_set_bb_reg(dm->adapter, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
phy_set_bb_reg(dm->adapter, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u32 odm_get_mac_reg(struct dm_struct *dm, u32 reg_addr, u32 bit_mask)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
return phy_query_bb_reg(dm->priv, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
return PHY_QueryMacReg(dm->adapter, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_get_bbreg(rtlpriv->hw, reg_addr, bit_mask);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
return rtw_get_reg_with_mask(rtwdev, reg_addr, bit_mask);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
return phy_query_bb_reg(dm->adapter, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
return phy_query_mac_reg(dm->adapter, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_set_bb_reg(struct dm_struct *dm, u32 reg_addr, u32 bit_mask, u32 data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
phy_set_bb_reg(dm->priv, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
PHY_SetBBReg(adapter, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_set_bbreg(rtlpriv->hw, reg_addr, bit_mask, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
rtw_set_reg_with_mask(rtwdev, reg_addr, bit_mask, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
phy_set_bb_reg(dm->adapter, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
phy_set_bb_reg(dm->adapter, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u32 odm_get_bb_reg(struct dm_struct *dm, u32 reg_addr, u32 bit_mask)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
return phy_query_bb_reg(dm->priv, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return PHY_QueryBBReg(adapter, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_get_bbreg(rtlpriv->hw, reg_addr, bit_mask);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
return rtw_get_reg_with_mask(rtwdev, reg_addr, bit_mask);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
return phy_query_bb_reg(dm->adapter, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
return phy_query_bb_reg(dm->adapter, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_set_rf_reg(struct dm_struct *dm, u8 e_rf_path, u32 reg_addr,
u32 bit_mask, u32 data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
2018-08-24 20:52:34 +00:00
phy_set_rf_reg(dm->priv, e_rf_path, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
PHY_SetRFReg(adapter, e_rf_path, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
ODM_delay_us(2);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_set_rfreg(rtlpriv->hw, e_rf_path, reg_addr, bit_mask, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
rtw_write_rf(rtwdev, e_rf_path, reg_addr, bit_mask, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
phy_set_rf_reg(dm->adapter, e_rf_path, reg_addr, bit_mask, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
phy_set_rf_reg(dm->adapter, e_rf_path, reg_addr, bit_mask, data);
ODM_delay_us(2);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u32 odm_get_rf_reg(struct dm_struct *dm, u8 e_rf_path, u32 reg_addr,
u32 bit_mask)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
return phy_query_rf_reg(dm->priv, e_rf_path, reg_addr, bit_mask, 1);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return PHY_QueryRFReg(adapter, e_rf_path, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_get_rfreg(rtlpriv->hw, e_rf_path, reg_addr, bit_mask);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
return rtw_read_rf(rtwdev, e_rf_path, reg_addr, bit_mask);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
return phy_query_rf_reg(dm->adapter, e_rf_path, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
return phy_query_rf_reg(dm->adapter, e_rf_path, reg_addr, bit_mask);
2018-06-22 16:48:32 +00:00
#endif
}
enum hal_status
2019-05-24 19:43:57 +00:00
phydm_set_reg_by_fw(struct dm_struct *dm, enum phydm_halmac_param config_type,
u32 offset, u32 data, u32 mask, enum rf_path e_rf_path,
u32 delay_time)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
2018-08-24 20:52:34 +00:00
return HAL_MAC_Config_PHY_WriteNByte(dm,
2019-05-24 19:43:57 +00:00
config_type,
offset,
data,
mask,
e_rf_path,
delay_time);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
PHYDM_DBG(dm, DBG_CMN, "Not support for CE MAC80211 driver!\n");
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
return -ENOTSUPP;
2018-08-24 20:52:34 +00:00
#else
return rtw_phydm_cfg_phy_para(dm,
2019-05-24 19:43:57 +00:00
config_type,
offset,
data,
mask,
e_rf_path,
delay_time);
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
PHYDM_DBG(dm, DBG_CMN, "Not support for CE MAC80211 driver!\n");
2018-08-24 20:52:34 +00:00
#endif
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
/*@
2018-06-22 16:48:32 +00:00
* ODM Memory relative API.
2019-05-24 19:43:57 +00:00
*/
void odm_allocate_memory(struct dm_struct *dm, void **ptr, u32 length)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
*ptr = kmalloc(length, GFP_ATOMIC);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
*ptr = kmalloc(length, GFP_ATOMIC);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
*ptr = kmalloc(length, GFP_ATOMIC);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
*ptr = rtw_zvmalloc(length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-08-24 20:52:34 +00:00
PlatformAllocateMemory(adapter, ptr, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
*ptr = rtw_zvmalloc(length);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
/* @length could be ignored, used to detect memory leakage. */
void odm_free_memory(struct dm_struct *dm, void *ptr, u32 length)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
kfree(ptr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
kfree(ptr);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
kfree(ptr);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
rtw_vmfree(ptr, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
/* struct void* adapter = dm->adapter; */
PlatformFreeMemory(ptr, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_vmfree(ptr, length);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_move_memory(struct dm_struct *dm, void *dest, void *src, u32 length)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
2018-08-24 20:52:34 +00:00
memcpy(dest, src, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
memcpy(dest, src, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
memcpy(dest, src, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
_rtw_memcpy(dest, src, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
PlatformMoveMemory(dest, src, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_memcpy(dest, src, length);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_memory_set(struct dm_struct *dm, void *pbuf, s8 value, u32 length)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
memset(pbuf, value, length);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
memset(pbuf, value, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
memset(pbuf, value, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
_rtw_memset(pbuf, value, length);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformFillMemory(pbuf, length, value);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_memset(pbuf, value, length);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
s32 odm_compare_memory(struct dm_struct *dm, void *buf1, void *buf2, u32 length)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
2018-08-24 20:52:34 +00:00
return memcmp(buf1, buf2, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
return memcmp(buf1, buf2, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
return memcmp(buf1, buf2, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
return _rtw_memcmp(buf1, buf2, length);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
return PlatformCompareMemory(buf1, buf2, length);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
return rtw_memcmp(buf1, buf2, length);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
/*@
2018-06-22 16:48:32 +00:00
* ODM MISC relative API.
2019-05-24 19:43:57 +00:00
*/
void odm_acquire_spin_lock(struct dm_struct *dm, enum rt_spinlock_type type)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2019-05-24 19:43:57 +00:00
2018-08-24 20:52:34 +00:00
rtl_odm_acquirespinlock(rtlpriv, type);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
spin_lock(&rtwdev->hal.dm_lock);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
rtw_odm_acquirespinlock(adapter, type);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
PlatformAcquireSpinLock(adapter, type);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
rtw_odm_acquirespinlock(adapter, type);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_release_spin_lock(struct dm_struct *dm, enum rt_spinlock_type type)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2019-05-24 19:43:57 +00:00
2018-08-24 20:52:34 +00:00
rtl_odm_releasespinlock(rtlpriv, type);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
spin_unlock(&rtwdev->hal.dm_lock);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
rtw_odm_releasespinlock(adapter, type);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
PlatformReleaseSpinLock(adapter, type);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
rtw_odm_releasespinlock(adapter, type);
2018-06-22 16:48:32 +00:00
#endif
}
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2019-05-24 19:43:57 +00:00
/*@
2018-06-22 16:48:32 +00:00
* Work item relative API. FOr MP driver only~!
* */
2019-05-24 19:43:57 +00:00
void odm_initialize_work_item(
struct dm_struct *dm,
PRT_WORK_ITEM work_item,
RT_WORKITEM_CALL_BACK callback,
void *context,
const char *id)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
PlatformInitializeWorkItem(adapter, work_item, callback, context, id);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_start_work_item(
PRT_WORK_ITEM p_rt_work_item)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformStartWorkItem(p_rt_work_item);
#endif
}
2019-05-24 19:43:57 +00:00
void odm_stop_work_item(
PRT_WORK_ITEM p_rt_work_item)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformStopWorkItem(p_rt_work_item);
#endif
}
2019-05-24 19:43:57 +00:00
void odm_free_work_item(
PRT_WORK_ITEM p_rt_work_item)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformFreeWorkItem(p_rt_work_item);
#endif
}
2019-05-24 19:43:57 +00:00
void odm_schedule_work_item(
PRT_WORK_ITEM p_rt_work_item)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformScheduleWorkItem(p_rt_work_item);
#endif
}
boolean
odm_is_work_item_scheduled(
2019-05-24 19:43:57 +00:00
PRT_WORK_ITEM p_rt_work_item)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
return PlatformIsWorkItemScheduled(p_rt_work_item);
#endif
}
#endif
2019-05-24 19:43:57 +00:00
/*@
2018-06-22 16:48:32 +00:00
* ODM Timer relative API.
2019-05-24 19:43:57 +00:00
*/
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void ODM_delay_ms(u32 ms)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
delay_ms(ms);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
mdelay(ms);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
mdelay(ms);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
rtw_mdelay_os(ms);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
delay_ms(ms);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_mdelay_os(ms);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void ODM_delay_us(u32 us)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
delay_us(us);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
udelay(us);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
udelay(us);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
rtw_udelay_os(us);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformStallExecution(us);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_udelay_os(us);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void ODM_sleep_ms(u32 ms)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
delay_ms(ms);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
msleep(ms);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
msleep(ms);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
rtw_msleep_os(ms);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
delay_ms(ms);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_msleep_os(ms);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void ODM_sleep_us(u32 us)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
delay_us(us);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
usleep_range(us, us + 1);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
usleep_range(us, us + 1);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
rtw_usleep_os(us);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
PlatformStallExecution(us);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_usleep_os(us);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_set_timer(struct dm_struct *dm, struct phydm_timer_list *timer,
u32 ms_delay)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
2018-08-24 20:52:34 +00:00
mod_timer(timer, jiffies + RTL_MILISECONDS_TO_JIFFIES(ms_delay));
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
mod_timer(timer, jiffies + msecs_to_jiffies(ms_delay));
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
mod_timer(&timer->timer, jiffies + msecs_to_jiffies(ms_delay));
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
_set_timer(timer, ms_delay); /* @ms */
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-08-24 20:52:34 +00:00
PlatformSetTimer(adapter, timer, ms_delay);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_set_timer(timer, ms_delay); /* @ms */
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_initialize_timer(struct dm_struct *dm, struct phydm_timer_list *timer,
void *call_back_func, void *context,
const char *sz_id)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
2018-08-24 20:52:34 +00:00
init_timer(timer);
timer->function = call_back_func;
timer->data = (unsigned long)dm;
2019-05-24 19:43:57 +00:00
#if 0
/*@mod_timer(timer, jiffies+RTL_MILISECONDS_TO_JIFFIES(10)); */
#endif
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
timer_setup(timer, call_back_func, 0);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
struct _ADAPTER *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
_init_timer(timer, adapter->pnetdev, call_back_func, dm);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PlatformInitializeTimer(adapter, timer, (RT_TIMER_CALL_BACK)call_back_func, context, sz_id);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
struct _ADAPTER *adapter = dm->adapter;
rtw_init_timer(timer, adapter->pnetdev, (TIMER_FUN)call_back_func, dm, NULL);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_cancel_timer(struct dm_struct *dm, struct phydm_timer_list *timer)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_AP)
2018-08-24 20:52:34 +00:00
del_timer(timer);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
del_timer(timer);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
del_timer(&timer->timer);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
_cancel_timer_ex(timer);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
PlatformCancelTimer(adapter, timer);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_cancel_timer(timer);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_release_timer(struct dm_struct *dm, struct phydm_timer_list *timer)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
/* @<20120301, Kordan> If the initilization fails,
* InitializeAdapterXxx will return regardless of InitHalDm.
* Hence, uninitialized timers cause BSOD when the driver
* releases resources since the init fail.
*/
2018-08-24 20:52:34 +00:00
if (timer == 0) {
2019-05-24 19:43:57 +00:00
PHYDM_DBG(dm, ODM_COMP_INIT,
"[%s] Timer is NULL! Please check!\n", __func__);
2018-06-22 16:48:32 +00:00
return;
}
2018-08-24 20:52:34 +00:00
PlatformReleaseTimer(adapter, timer);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_del_timer(timer);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u8 phydm_trans_h2c_id(struct dm_struct *dm, u8 phydm_h2c_id)
2018-06-22 16:48:32 +00:00
{
u8 platform_h2c_id = phydm_h2c_id;
switch (phydm_h2c_id) {
2019-05-24 19:43:57 +00:00
/* @1 [0] */
2018-06-22 16:48:32 +00:00
case ODM_H2C_RSSI_REPORT:
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
#if (RTL8188E_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8188E)
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_88E_RSSI_REPORT;
else
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_RSSI_REPORT;
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
platform_h2c_id = H2C_RSSI_SETTING;
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
#if ((RTL8881A_SUPPORT == 1) || (RTL8192E_SUPPORT == 1) || (RTL8814A_SUPPORT == 1) || (RTL8822B_SUPPORT == 1) || (RTL8197F_SUPPORT == 1) || (RTL8192F_SUPPORT == 1)) /*@jj add 20170822*/
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8881A || dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type & PHYDM_IC_3081_SERIES)
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_88XX_RSSI_REPORT;
else
#endif
#if (RTL8812A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8812)
2019-05-24 19:43:57 +00:00
platform_h2c_id = H2C_8812_RSSI_REPORT;
else
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
{
}
2018-06-22 16:48:32 +00:00
#endif
break;
2019-05-24 19:43:57 +00:00
/* @1 [3] */
2018-06-22 16:48:32 +00:00
case ODM_H2C_WIFI_CALIBRATION:
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
platform_h2c_id = H2C_WIFI_CALIBRATION;
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#if (RTL8723B_SUPPORT == 1)
platform_h2c_id = H2C_8723B_BT_WLAN_CALIBRATION;
#endif
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
#endif
break;
2019-05-24 19:43:57 +00:00
/* @1 [4] */
2018-06-22 16:48:32 +00:00
case ODM_H2C_IQ_CALIBRATION:
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
platform_h2c_id = H2C_IQ_CALIBRATION;
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#if ((RTL8812A_SUPPORT == 1) || (RTL8821A_SUPPORT == 1))
platform_h2c_id = H2C_8812_IQ_CALIBRATION;
#endif
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
#endif
break;
2019-05-24 19:43:57 +00:00
/* @1 [5] */
2018-06-22 16:48:32 +00:00
case ODM_H2C_RA_PARA_ADJUST:
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
platform_h2c_id = H2C_RA_PARA_ADJUST;
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#if ((RTL8812A_SUPPORT == 1) || (RTL8821A_SUPPORT == 1))
platform_h2c_id = H2C_8812_RA_PARA_ADJUST;
#elif ((RTL8814A_SUPPORT == 1) || (RTL8822B_SUPPORT == 1))
platform_h2c_id = H2C_RA_PARA_ADJUST;
#elif (RTL8192E_SUPPORT == 1)
platform_h2c_id = H2C_8192E_RA_PARA_ADJUST;
#elif (RTL8723B_SUPPORT == 1)
platform_h2c_id = H2C_8723B_RA_PARA_ADJUST;
#endif
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
#if ((RTL8881A_SUPPORT == 1) || (RTL8192E_SUPPORT == 1) || (RTL8814A_SUPPORT == 1) || (RTL8822B_SUPPORT == 1) || (RTL8197F_SUPPORT == 1) || (RTL8192F_SUPPORT == 1)) /*@jj add 20170822*/
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8881A || dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type & PHYDM_IC_3081_SERIES)
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_88XX_RA_PARA_ADJUST;
else
#endif
#if (RTL8812A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8812)
2019-05-24 19:43:57 +00:00
platform_h2c_id = H2C_8812_RA_PARA_ADJUST;
else
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
{
}
2018-06-22 16:48:32 +00:00
#endif
break;
2019-05-24 19:43:57 +00:00
/* @1 [6] */
2018-06-22 16:48:32 +00:00
case PHYDM_H2C_DYNAMIC_TX_PATH:
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
#if (RTL8814A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8814A)
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_8814A_DYNAMIC_TX_PATH;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#if (RTL8814A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8814A)
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_DYNAMIC_TX_PATH;
#endif
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
#if (RTL8814A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8814A)
2018-06-22 16:48:32 +00:00
platform_h2c_id = H2C_88XX_DYNAMIC_TX_PATH;
#endif
#endif
break;
2019-05-24 19:43:57 +00:00
/* @[7]*/
2018-06-22 16:48:32 +00:00
case PHYDM_H2C_FW_TRACE_EN:
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
platform_h2c_id = H2C_FW_TRACE_EN;
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
platform_h2c_id = 0x49;
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
#if ((RTL8881A_SUPPORT == 1) || (RTL8192E_SUPPORT == 1) || (RTL8814A_SUPPORT == 1) || (RTL8822B_SUPPORT == 1) || (RTL8197F_SUPPORT == 1) || (RTL8192F_SUPPORT == 1)) /*@jj add 20170822*/
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8881A || dm->support_ic_type == ODM_RTL8192E || dm->support_ic_type & PHYDM_IC_3081_SERIES)
2019-05-24 19:43:57 +00:00
platform_h2c_id = H2C_88XX_FW_TRACE_EN;
2018-06-22 16:48:32 +00:00
else
#endif
#if (RTL8812A_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
if (dm->support_ic_type == ODM_RTL8812)
platform_h2c_id = H2C_8812_FW_TRACE_EN;
else
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
{
}
2018-06-22 16:48:32 +00:00
#endif
break;
case PHYDM_H2C_TXBF:
#if ((RTL8192E_SUPPORT == 1) || (RTL8812A_SUPPORT == 1))
2019-05-24 19:43:57 +00:00
platform_h2c_id = 0x41; /*@H2C_TxBF*/
2018-06-22 16:48:32 +00:00
#endif
break;
case PHYDM_H2C_MU:
#if (RTL8822B_SUPPORT == 1)
2019-05-24 19:43:57 +00:00
platform_h2c_id = 0x4a; /*@H2C_MU*/
2018-06-22 16:48:32 +00:00
#endif
break;
default:
platform_h2c_id = phydm_h2c_id;
break;
}
return platform_h2c_id;
}
2019-05-24 19:43:57 +00:00
/*@ODM FW relative API.*/
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void odm_fill_h2c_cmd(struct dm_struct *dm, u8 phydm_h2c_id, u32 cmd_len,
u8 *cmd_buf)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2018-08-24 20:52:34 +00:00
struct rtl_priv *rtlpriv = (struct rtl_priv *)dm->adapter;
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
struct rtw_dev *rtwdev = dm->adapter;
u8 cmd_id, cmd_class;
u8 h2c_pkt[8];
2018-06-22 16:48:32 +00:00
#else
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
u8 h2c_id = phydm_trans_h2c_id(dm, phydm_h2c_id);
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
PHYDM_DBG(dm, DBG_RA, "[H2C] h2c_id=((0x%x))\n", h2c_id);
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
if (dm->support_ic_type == ODM_RTL8188E) {
2018-08-24 20:52:34 +00:00
if (!dm->ra_support88e)
2019-05-24 19:43:57 +00:00
FillH2CCmd88E(adapter, h2c_id, cmd_len, cmd_buf);
2018-08-24 20:52:34 +00:00
} else if (dm->support_ic_type == ODM_RTL8814A)
2019-05-24 19:43:57 +00:00
FillH2CCmd8814A(adapter, h2c_id, cmd_len, cmd_buf);
2018-08-24 20:52:34 +00:00
else if (dm->support_ic_type == ODM_RTL8822B)
2019-05-24 19:43:57 +00:00
FillH2CCmd8822B(adapter, h2c_id, cmd_len, cmd_buf);
2018-06-22 16:48:32 +00:00
else
2019-05-24 19:43:57 +00:00
FillH2CCmd(adapter, h2c_id, cmd_len, cmd_buf);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#ifdef DM_ODM_CE_MAC80211
2019-05-24 19:43:57 +00:00
rtlpriv->cfg->ops->fill_h2c_cmd(rtlpriv->hw, h2c_id, cmd_len, cmd_buf);
#elif defined(DM_ODM_CE_MAC80211_V2)
cmd_id = phydm_h2c_id & 0x1f;
cmd_class = (phydm_h2c_id >> RTW_H2C_CLASS_OFFSET) & 0x7;
memcpy(h2c_pkt + 1, cmd_buf, 7);
h2c_pkt[0] = phydm_h2c_id;
rtw_fw_send_h2c_packet(rtwdev, h2c_pkt, cmd_id, cmd_class);
/* TODO: implement fill h2c command for rtwlan */
2018-06-22 16:48:32 +00:00
#else
2019-05-24 19:43:57 +00:00
rtw_hal_fill_h2c_cmd(adapter, h2c_id, cmd_len, cmd_buf);
2018-06-22 16:48:32 +00:00
#endif
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
#if (RTL8812A_SUPPORT == 1)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type == ODM_RTL8812) {
2019-05-24 19:43:57 +00:00
fill_h2c_cmd8812(dm->priv, h2c_id, cmd_len, cmd_buf);
2018-06-22 16:48:32 +00:00
} else
#endif
{
2019-05-24 19:43:57 +00:00
GET_HAL_INTERFACE(dm->priv)->fill_h2c_cmd_handler(dm->priv, h2c_id, cmd_len, cmd_buf);
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
rtw_hal_fill_h2c_cmd(adapter, h2c_id, cmd_len, cmd_buf);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u8 phydm_c2H_content_parsing(void *dm_void, u8 c2h_cmd_id, u8 c2h_cmd_len,
u8 *tmp_buf)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
struct dm_struct *dm = (struct dm_struct *)dm_void;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
#endif
u8 extend_c2h_sub_id = 0;
u8 find_c2h_cmd = true;
if (c2h_cmd_len > 12 || c2h_cmd_len == 0) {
pr_debug("[Warning] Error C2H ID=%d, len=%d\n",
c2h_cmd_id, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
find_c2h_cmd = false;
return find_c2h_cmd;
}
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
switch (c2h_cmd_id) {
case PHYDM_C2H_DBG:
2018-08-24 20:52:34 +00:00
phydm_fw_trace_handler(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
case PHYDM_C2H_RA_RPT:
2018-08-24 20:52:34 +00:00
phydm_c2h_ra_report_handler(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
case PHYDM_C2H_RA_PARA_RPT:
2018-08-24 20:52:34 +00:00
odm_c2h_ra_para_report_handler(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
#ifdef CONFIG_PATH_DIVERSITY
2018-06-22 16:48:32 +00:00
case PHYDM_C2H_DYNAMIC_TX_PATH_RPT:
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type & (ODM_RTL8814A))
phydm_c2h_dtp_handler(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
case PHYDM_C2H_IQK_FINISH:
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
2018-08-24 20:52:34 +00:00
if (dm->support_ic_type & (ODM_RTL8812 | ODM_RTL8821)) {
2018-06-22 16:48:32 +00:00
RT_TRACE(COMP_MP, DBG_LOUD, ("== FW IQK Finish ==\n"));
2018-08-24 20:52:34 +00:00
odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.is_iqk_in_progress = false;
odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
dm->rf_calibrate_info.iqk_progressing_time = 0;
dm->rf_calibrate_info.iqk_progressing_time = odm_get_progressing_time(dm, dm->rf_calibrate_info.iqk_start_time);
2018-06-22 16:48:32 +00:00
}
#endif
break;
case PHYDM_C2H_CLM_MONITOR:
2018-08-24 20:52:34 +00:00
phydm_clm_c2h_report_handler(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
case PHYDM_C2H_DBG_CODE:
2018-08-24 20:52:34 +00:00
phydm_fw_trace_handler_code(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
case PHYDM_C2H_EXTEND:
extend_c2h_sub_id = tmp_buf[0];
if (extend_c2h_sub_id == PHYDM_EXTEND_C2H_DBG_PRINT)
2018-08-24 20:52:34 +00:00
phydm_fw_trace_handler_8051(dm, tmp_buf, c2h_cmd_len);
2018-06-22 16:48:32 +00:00
break;
default:
find_c2h_cmd = false;
break;
}
return find_c2h_cmd;
}
2019-05-24 19:43:57 +00:00
u64 odm_get_current_time(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
return (u64)rtw_get_current_time();
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
return jiffies;
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
return jiffies;
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
return rtw_get_current_time();
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
return PlatformGetCurrentTime();
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
return rtw_get_current_time();
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u64 odm_get_progressing_time(struct dm_struct *dm, u64 start_time)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
return rtw_get_passing_time_ms((u32)start_time);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
return jiffies_to_msecs(jiffies - start_time);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
return jiffies_to_msecs(jiffies - start_time);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
return rtw_get_passing_time_ms((systime)start_time);
#elif (DM_ODM_SUPPORT_TYPE & ODM_WIN)
return ((PlatformGetCurrentTime() - start_time) >> 10);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
return rtw_get_passing_time_ms(start_time);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE)) && \
(!defined(DM_ODM_CE_MAC80211) && !defined(DM_ODM_CE_MAC80211_V2))
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void phydm_set_hw_reg_handler_interface(struct dm_struct *dm, u8 RegName,
u8 *val)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
struct _ADAPTER *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2018-08-24 20:52:34 +00:00
((PADAPTER)adapter)->HalFunc.SetHwRegHandler(adapter, RegName, val);
2018-06-22 16:48:32 +00:00
#else
adapter->hal_func.set_hw_reg_handler(adapter, RegName, val);
#endif
#endif
}
2019-05-24 19:43:57 +00:00
void phydm_get_hal_def_var_handler_interface(struct dm_struct *dm,
enum _HAL_DEF_VARIABLE e_variable,
void *value)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
struct _ADAPTER *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
((PADAPTER)adapter)->HalFunc.GetHalDefVarHandler(adapter, e_variable, value);
2018-06-22 16:48:32 +00:00
#else
2018-08-24 20:52:34 +00:00
adapter->hal_func.get_hal_def_var_handler(adapter, e_variable, value);
2018-06-22 16:48:32 +00:00
#endif
#endif
}
#endif
2019-05-24 19:43:57 +00:00
void odm_set_tx_power_index_by_rate_section(struct dm_struct *dm,
enum rf_path path, u8 ch,
u8 section)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
PHY_SetTxPowerIndexByRateSection(adapter, path, ch, section);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
phy_set_tx_power_index_by_rs(adapter, ch, path, section);
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
phy_set_tx_power_index_by_rate_section(dm->adapter, path, ch, section);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
PHY_SetTxPowerIndexByRateSection(adapter, path, ch, section);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u8 odm_get_tx_power_index(struct dm_struct *dm, enum rf_path path, u8 rate,
u8 bw, u8 ch)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return PHY_GetTxPowerIndex(dm->adapter, path, rate, (CHANNEL_WIDTH)bw, ch);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
return phy_get_tx_power_index(adapter, path, rate, bw, ch);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
void *adapter = dm->adapter;
return phy_get_tx_power_index(adapter, path, rate, bw, ch);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2019-05-24 19:43:57 +00:00
return phy_get_tx_power_index(dm->adapter, path, rate, bw, ch);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
return PHY_GetTxPowerIndex(dm->adapter, path, rate, bw, ch);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u8 odm_efuse_one_byte_read(struct dm_struct *dm, u16 addr, u8 *data,
boolean b_pseu_do_test)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
return (u8)EFUSE_OneByteRead(adapter, addr, data, b_pseu_do_test);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
return rtl_efuse_onebyte_read(adapter, addr, data, b_pseu_do_test);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
return -1;
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
return efuse_onebyte_read(dm->adapter, addr, data, b_pseu_do_test);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
return Efuse_OneByteRead(dm, addr, data);
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
return (u8)efuse_OneByteRead(adapter, addr, data, b_pseu_do_test);
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
void odm_efuse_logical_map_read(struct dm_struct *dm, u8 type, u16 offset,
u32 *data)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
EFUSE_ShadowRead(adapter, type, offset, data);
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
rtl_efuse_logical_map_read(adapter, type, offset, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
efuse_logical_map_read(dm->adapter, type, offset, data);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
void *adapter = dm->adapter;
EFUSE_ShadowRead(adapter, type, offset, data);
2018-06-22 16:48:32 +00:00
#endif
}
enum hal_status
2019-05-24 19:43:57 +00:00
odm_iq_calibrate_by_fw(struct dm_struct *dm, u8 clear, u8 segment)
2018-06-22 16:48:32 +00:00
{
enum hal_status iqk_result = HAL_STATUS_FAILURE;
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
2019-05-24 19:43:57 +00:00
struct _ADAPTER *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
if (HAL_MAC_FWIQK_Trigger(&GET_HAL_MAC_INFO(adapter), clear, segment) == 0)
iqk_result = HAL_STATUS_SUCCESS;
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
2018-08-24 20:52:34 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-08-24 20:52:34 +00:00
iqk_result = rtl_phydm_fw_iqk(adapter, clear, segment);
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
2018-08-24 20:52:34 +00:00
#else
iqk_result = rtw_phydm_fw_iqk(dm, clear, segment);
#endif
2019-05-24 19:43:57 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_IOT)
iqk_result = rtw_phydm_fw_iqk(dm, clear, segment);
2018-06-22 16:48:32 +00:00
#endif
return iqk_result;
}
2019-05-24 19:43:57 +00:00
void odm_cmn_info_ptr_array_hook(struct dm_struct *dm,
enum odm_cmninfo cmn_info, u16 index,
void *value)
2018-06-22 16:48:32 +00:00
{
2019-05-24 19:43:57 +00:00
/*ODM_CMNINFO_STA_STATUS*/
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_cmn_sta_info_hook(struct dm_struct *dm, u8 mac_id,
struct cmn_sta_info *pcmn_sta_info)
2018-06-22 16:48:32 +00:00
{
2018-08-24 20:52:34 +00:00
dm->phydm_sta_info[mac_id] = pcmn_sta_info;
2018-06-22 16:48:32 +00:00
if (is_sta_active(pcmn_sta_info))
2018-08-24 20:52:34 +00:00
dm->phydm_macid_table[pcmn_sta_info->mac_id] = mac_id;
}
2019-05-24 19:43:57 +00:00
void phydm_macid2sta_idx_table(struct dm_struct *dm, u8 entry_idx,
struct cmn_sta_info *pcmn_sta_info)
2018-08-24 20:52:34 +00:00
{
if (is_sta_active(pcmn_sta_info))
dm->phydm_macid_table[pcmn_sta_info->mac_id] = entry_idx;
2018-06-22 16:48:32 +00:00
}
2019-05-24 19:43:57 +00:00
void phydm_add_interrupt_mask_handler(struct dm_struct *dm, u8 interrupt_type)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
#elif (DM_ODM_SUPPORT_TYPE == ODM_AP)
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
2018-06-22 16:48:32 +00:00
#if IS_EXIST_PCI || IS_EXIST_EMBEDDED
2019-05-24 19:43:57 +00:00
if (dm->support_interface == ODM_ITRF_PCIE)
GET_HAL_INTERFACE(priv)->AddInterruptMaskHandler(priv,
interrupt_type)
;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
#endif
}
2019-05-24 19:43:57 +00:00
void phydm_enable_rx_related_interrupt_handler(struct dm_struct *dm)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE == ODM_WIN)
#elif (DM_ODM_SUPPORT_TYPE == ODM_AP)
2019-05-24 19:43:57 +00:00
struct rtl8192cd_priv *priv = dm->priv;
2018-06-22 16:48:32 +00:00
#if IS_EXIST_PCI || IS_EXIST_EMBEDDED
2019-05-24 19:43:57 +00:00
if (dm->support_interface == ODM_ITRF_PCIE)
GET_HAL_INTERFACE(priv)->EnableRxRelatedInterruptHandler(priv);
2018-06-22 16:48:32 +00:00
#endif
#elif (DM_ODM_SUPPORT_TYPE == ODM_CE)
#endif
}
2018-08-24 20:52:34 +00:00
#if 0
2018-06-22 16:48:32 +00:00
boolean
phydm_get_txbf_en(
2018-08-24 20:52:34 +00:00
struct dm_struct *dm,
2018-06-22 16:48:32 +00:00
u16 mac_id,
u8 i
)
{
boolean txbf_en = false;
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && !defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
#ifdef CONFIG_BEAMFORMING
2018-06-22 16:48:32 +00:00
enum beamforming_cap beamform_cap;
2018-08-24 20:52:34 +00:00
void *adapter = dm->adapter;
2019-05-24 19:43:57 +00:00
#ifdef PHYDM_BEAMFORMING_SUPPORT
2018-06-22 16:48:32 +00:00
beamform_cap =
2018-08-24 20:52:34 +00:00
phydm_beamforming_get_entry_beam_cap_by_mac_id(dm, mac_id);
2019-05-24 19:43:57 +00:00
#else/*@for drv beamforming*/
2018-06-22 16:48:32 +00:00
beamform_cap =
beamforming_get_entry_beam_cap_by_mac_id(&adapter->mlmepriv, mac_id);
#endif
if (beamform_cap & (BEAMFORMER_CAP_HT_EXPLICIT | BEAMFORMER_CAP_VHT_SU))
txbf_en = true;
else
txbf_en = false;
2019-05-24 19:43:57 +00:00
#endif /*@#ifdef CONFIG_BEAMFORMING*/
2018-06-22 16:48:32 +00:00
#elif (DM_ODM_SUPPORT_TYPE & ODM_AP)
2019-05-24 19:43:57 +00:00
#ifdef PHYDM_BEAMFORMING_SUPPORT
2018-06-22 16:48:32 +00:00
u8 idx = 0xff;
boolean act_bfer = false;
BEAMFORMING_CAP beamform_cap = BEAMFORMING_CAP_NONE;
2018-08-24 20:52:34 +00:00
PRT_BEAMFORMING_ENTRY entry = NULL;
struct rtl8192cd_priv *priv = dm->priv;
2018-06-22 16:48:32 +00:00
#if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY))
2018-08-24 20:52:34 +00:00
struct _BF_DIV_COEX_ *dm_bdc_table = &dm->dm_bdc_table;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
dm_bdc_table->num_txbfee_client = 0;
dm_bdc_table->num_txbfer_client = 0;
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
#ifdef PHYDM_BEAMFORMING_SUPPORT
2018-06-22 16:48:32 +00:00
beamform_cap = Beamforming_GetEntryBeamCapByMacId(priv, mac_id);
2018-08-24 20:52:34 +00:00
entry = Beamforming_GetEntryByMacId(priv, mac_id, &idx);
2018-06-22 16:48:32 +00:00
if (beamform_cap & (BEAMFORMER_CAP_HT_EXPLICIT | BEAMFORMER_CAP_VHT_SU)) {
2018-08-24 20:52:34 +00:00
if (entry->Sounding_En)
2018-06-22 16:48:32 +00:00
txbf_en = true;
else
txbf_en = false;
act_bfer = true;
}
2019-05-24 19:43:57 +00:00
#if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY)) /*@BDC*/
2018-06-22 16:48:32 +00:00
if (act_bfer == true) {
2019-05-24 19:43:57 +00:00
dm_bdc_table->w_bfee_client[i] = true; /* @AP act as BFer */
2018-08-24 20:52:34 +00:00
dm_bdc_table->num_txbfee_client++;
2018-06-22 16:48:32 +00:00
} else
2019-05-24 19:43:57 +00:00
dm_bdc_table->w_bfee_client[i] = false; /* @AP act as BFer */
2018-06-22 16:48:32 +00:00
if (beamform_cap & (BEAMFORMEE_CAP_HT_EXPLICIT | BEAMFORMEE_CAP_VHT_SU)) {
2019-05-24 19:43:57 +00:00
dm_bdc_table->w_bfer_client[i] = true; /* @AP act as BFee */
2018-08-24 20:52:34 +00:00
dm_bdc_table->num_txbfer_client++;
2018-06-22 16:48:32 +00:00
} else
2019-05-24 19:43:57 +00:00
dm_bdc_table->w_bfer_client[i] = false; /* @AP act as BFer */
2018-06-22 16:48:32 +00:00
#endif
2019-05-24 19:43:57 +00:00
#endif
2018-06-22 16:48:32 +00:00
#endif
return txbf_en;
}
2018-08-24 20:52:34 +00:00
#endif
2018-06-22 16:48:32 +00:00
2019-05-24 19:43:57 +00:00
void phydm_iqk_wait(struct dm_struct *dm, u32 timeout)
2018-06-22 16:48:32 +00:00
{
#if (DM_ODM_SUPPORT_TYPE == ODM_CE)
2018-08-24 20:52:34 +00:00
#if (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
2019-05-24 19:43:57 +00:00
PHYDM_DBG(dm, DBG_CMN, "Not support for CE MAC80211 driver!\n");
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211_V2)
2018-08-24 20:52:34 +00:00
#else
2019-05-24 19:43:57 +00:00
void *adapter = dm->adapter;
2018-06-22 16:48:32 +00:00
2018-08-24 20:52:34 +00:00
rtl8812_iqk_wait(adapter, timeout);
#endif
2018-06-22 16:48:32 +00:00
#endif
}
2019-05-24 19:43:57 +00:00
u8 phydm_get_hwrate_to_mrate(struct dm_struct *dm, u8 rate)
{
#if (DM_ODM_SUPPORT_TYPE == ODM_IOT)
return HwRateToMRate(rate);
#endif
return 0;
}
void phydm_set_crystalcap(struct dm_struct *dm, u8 crystal_cap)
{
#if (DM_ODM_SUPPORT_TYPE == ODM_IOT)
ROM_odm_SetCrystalCap(dm, crystal_cap);
#endif
}
void phydm_run_in_thread_cmd(struct dm_struct *dm, void (*func)(void *),
void *context)
{
#if (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
PHYDM_DBG(dm, DBG_CMN, "Not support for CE MAC80211 driver!\n");
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
void *adapter = dm->adapter;
rtw_run_in_thread_cmd(adapter, func, context);
#endif
}
u32 phydm_get_tx_rate(struct dm_struct *dm)
{
struct _hal_rf_ *rf = &dm->rf_table;
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
struct _ADAPTER *adapter = dm->adapter;
#endif
u8 tx_rate = 0xFF;
u8 mpt_rate_index = 0;
if (*dm->mp_mode == 1) {
#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE))
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
#if (MP_DRIVER == 1)
PMPT_CONTEXT p_mpt_ctx = &adapter->MptCtx;
tx_rate = MptToMgntRate(p_mpt_ctx->MptRateIndex);
#endif
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
#ifdef CONFIG_MP_INCLUDED
if (rf->mp_rate_index)
mpt_rate_index = *rf->mp_rate_index;
tx_rate = mpt_to_mgnt_rate(mpt_rate_index);
#endif
#endif
#endif
} else {
u16 rate = *dm->forced_data_rate;
if (!rate) { /*auto rate*/
#if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
struct _ADAPTER *adapter = dm->adapter;
tx_rate = ((PADAPTER)adapter)->HalFunc.GetHwRateFromMRateHandler(dm->tx_rate);
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE) && defined(DM_ODM_CE_MAC80211)
tx_rate = dm->tx_rate;
#elif (DM_ODM_SUPPORT_TYPE & ODM_CE)
if (dm->number_linked_client != 0)
tx_rate = hw_rate_to_m_rate(dm->tx_rate);
else
tx_rate = rf->p_rate_index;
#endif
} else { /*force rate*/
tx_rate = (u8)rate;
}
}
return tx_rate;
}