162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright(c) 2009-2012 Realtek Corporation.*/ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef __RTL92D_PHY_H__ 562306a36Sopenharmony_ci#define __RTL92D_PHY_H__ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#define MAX_PRECMD_CNT 16 862306a36Sopenharmony_ci#define MAX_RFDEPENDCMD_CNT 16 962306a36Sopenharmony_ci#define MAX_POSTCMD_CNT 16 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define MAX_DOZE_WAITING_TIMES_9x 64 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#define RT_CANNOT_IO(hw) false 1462306a36Sopenharmony_ci#define HIGHPOWER_RADIOA_ARRAYLEN 22 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define MAX_TOLERANCE 5 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define APK_BB_REG_NUM 5 1962306a36Sopenharmony_ci#define APK_AFE_REG_NUM 16 2062306a36Sopenharmony_ci#define APK_CURVE_REG_NUM 4 2162306a36Sopenharmony_ci#define PATH_NUM 2 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#define LOOP_LIMIT 5 2462306a36Sopenharmony_ci#define MAX_STALL_TIME 50 2562306a36Sopenharmony_ci#define ANTENNA_DIVERSITY_VALUE 0x80 2662306a36Sopenharmony_ci#define MAX_TXPWR_IDX_NMODE_92S 63 2762306a36Sopenharmony_ci#define RESET_CNT_LIMIT 3 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define IQK_ADDA_REG_NUM 16 3062306a36Sopenharmony_ci#define IQK_BB_REG_NUM 10 3162306a36Sopenharmony_ci#define IQK_BB_REG_NUM_test 6 3262306a36Sopenharmony_ci#define IQK_MAC_REG_NUM 4 3362306a36Sopenharmony_ci#define RX_INDEX_MAPPING_NUM 15 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define IQK_DELAY_TIME 1 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define CT_OFFSET_MAC_ADDR 0X16 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define CT_OFFSET_CCK_TX_PWR_IDX 0x5A 4062306a36Sopenharmony_ci#define CT_OFFSET_HT401S_TX_PWR_IDX 0x60 4162306a36Sopenharmony_ci#define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF 0x66 4262306a36Sopenharmony_ci#define CT_OFFSET_HT20_TX_PWR_IDX_DIFF 0x69 4362306a36Sopenharmony_ci#define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF 0x6C 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define CT_OFFSET_HT40_MAX_PWR_OFFSET 0x6F 4662306a36Sopenharmony_ci#define CT_OFFSET_HT20_MAX_PWR_OFFSET 0x72 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define CT_OFFSET_CHANNEL_PLAH 0x75 4962306a36Sopenharmony_ci#define CT_OFFSET_THERMAL_METER 0x78 5062306a36Sopenharmony_ci#define CT_OFFSET_RF_OPTION 0x79 5162306a36Sopenharmony_ci#define CT_OFFSET_VERSION 0x7E 5262306a36Sopenharmony_ci#define CT_OFFSET_CUSTOMER_ID 0x7F 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cienum swchnlcmd_id { 5562306a36Sopenharmony_ci CMDID_END, 5662306a36Sopenharmony_ci CMDID_SET_TXPOWEROWER_LEVEL, 5762306a36Sopenharmony_ci CMDID_BBREGWRITE10, 5862306a36Sopenharmony_ci CMDID_WRITEPORT_ULONG, 5962306a36Sopenharmony_ci CMDID_WRITEPORT_USHORT, 6062306a36Sopenharmony_ci CMDID_WRITEPORT_UCHAR, 6162306a36Sopenharmony_ci CMDID_RF_WRITEREG, 6262306a36Sopenharmony_ci}; 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_cistruct swchnlcmd { 6562306a36Sopenharmony_ci enum swchnlcmd_id cmdid; 6662306a36Sopenharmony_ci u32 para1; 6762306a36Sopenharmony_ci u32 para2; 6862306a36Sopenharmony_ci u32 msdelay; 6962306a36Sopenharmony_ci}; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_cienum baseband_config_type { 7262306a36Sopenharmony_ci BASEBAND_CONFIG_PHY_REG = 0, 7362306a36Sopenharmony_ci BASEBAND_CONFIG_AGC_TAB = 1, 7462306a36Sopenharmony_ci}; 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cienum rf_content { 7762306a36Sopenharmony_ci radioa_txt = 0, 7862306a36Sopenharmony_ci radiob_txt = 1, 7962306a36Sopenharmony_ci radioc_txt = 2, 8062306a36Sopenharmony_ci radiod_txt = 3 8162306a36Sopenharmony_ci}; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_cistatic inline void rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw, 8462306a36Sopenharmony_ci unsigned long *flag) 8562306a36Sopenharmony_ci{ 8662306a36Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci if (rtlpriv->rtlhal.interfaceindex == 1) 8962306a36Sopenharmony_ci spin_lock_irqsave(&rtlpriv->locks.cck_and_rw_pagea_lock, *flag); 9062306a36Sopenharmony_ci} 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cistatic inline void rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw, 9362306a36Sopenharmony_ci unsigned long *flag) 9462306a36Sopenharmony_ci{ 9562306a36Sopenharmony_ci struct rtl_priv *rtlpriv = rtl_priv(hw); 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ci if (rtlpriv->rtlhal.interfaceindex == 1) 9862306a36Sopenharmony_ci spin_unlock_irqrestore(&rtlpriv->locks.cck_and_rw_pagea_lock, 9962306a36Sopenharmony_ci *flag); 10062306a36Sopenharmony_ci} 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ciu32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, 10362306a36Sopenharmony_ci u32 regaddr, u32 bitmask); 10462306a36Sopenharmony_civoid rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw, 10562306a36Sopenharmony_ci u32 regaddr, u32 bitmask, u32 data); 10662306a36Sopenharmony_ciu32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw, 10762306a36Sopenharmony_ci enum radio_path rfpath, u32 regaddr, 10862306a36Sopenharmony_ci u32 bitmask); 10962306a36Sopenharmony_civoid rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, 11062306a36Sopenharmony_ci enum radio_path rfpath, u32 regaddr, 11162306a36Sopenharmony_ci u32 bitmask, u32 data); 11262306a36Sopenharmony_cibool rtl92d_phy_mac_config(struct ieee80211_hw *hw); 11362306a36Sopenharmony_cibool rtl92d_phy_bb_config(struct ieee80211_hw *hw); 11462306a36Sopenharmony_cibool rtl92d_phy_rf_config(struct ieee80211_hw *hw); 11562306a36Sopenharmony_cibool rtl92c_phy_config_rf_with_feaderfile(struct ieee80211_hw *hw, 11662306a36Sopenharmony_ci enum radio_path rfpath); 11762306a36Sopenharmony_civoid rtl92d_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); 11862306a36Sopenharmony_civoid rtl92d_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); 11962306a36Sopenharmony_civoid rtl92d_phy_set_bw_mode(struct ieee80211_hw *hw, 12062306a36Sopenharmony_ci enum nl80211_channel_type ch_type); 12162306a36Sopenharmony_ciu8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw); 12262306a36Sopenharmony_cibool rtl92d_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, 12362306a36Sopenharmony_ci enum rf_content content, 12462306a36Sopenharmony_ci enum radio_path rfpath); 12562306a36Sopenharmony_cibool rtl92d_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); 12662306a36Sopenharmony_cibool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, 12762306a36Sopenharmony_ci enum rf_pwrstate rfpwr_state); 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_civoid rtl92d_phy_config_macphymode(struct ieee80211_hw *hw); 13062306a36Sopenharmony_civoid rtl92d_phy_config_macphymode_info(struct ieee80211_hw *hw); 13162306a36Sopenharmony_ciu8 rtl92d_get_chnlgroup_fromarray(u8 chnl); 13262306a36Sopenharmony_civoid rtl92d_phy_set_poweron(struct ieee80211_hw *hw); 13362306a36Sopenharmony_civoid rtl92d_phy_config_maccoexist_rfpage(struct ieee80211_hw *hw); 13462306a36Sopenharmony_cibool rtl92d_phy_check_poweroff(struct ieee80211_hw *hw); 13562306a36Sopenharmony_civoid rtl92d_phy_lc_calibrate(struct ieee80211_hw *hw); 13662306a36Sopenharmony_civoid rtl92d_update_bbrf_configuration(struct ieee80211_hw *hw); 13762306a36Sopenharmony_civoid rtl92d_phy_ap_calibrate(struct ieee80211_hw *hw, s8 delta); 13862306a36Sopenharmony_civoid rtl92d_phy_iq_calibrate(struct ieee80211_hw *hw); 13962306a36Sopenharmony_civoid rtl92d_phy_reset_iqk_result(struct ieee80211_hw *hw); 14062306a36Sopenharmony_civoid rtl92d_release_cckandrw_pagea_ctl(struct ieee80211_hw *hw, 14162306a36Sopenharmony_ci unsigned long *flag); 14262306a36Sopenharmony_civoid rtl92d_acquire_cckandrw_pagea_ctl(struct ieee80211_hw *hw, 14362306a36Sopenharmony_ci unsigned long *flag); 14462306a36Sopenharmony_ciu8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl); 14562306a36Sopenharmony_civoid rtl92d_phy_reload_iqk_setting(struct ieee80211_hw *hw, u8 channel); 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci#endif 148