Commit 3e5831ca authored by Zong-Zhe Yang's avatar Zong-Zhe Yang Committed by Kalle Valo

wifi: rtw89: introduce rtw89_chan for channel stuffs

Introduce struct rtw89_chan ahead to encapsulate stuffs from struct
rtw89_channel_params. These stuffs have a clone in HAL and are used
throughout driver. After multiple channels support, it's expected that
each channel instance has a configuration of them. So, we refine them
with struct rtw89_chan by precise type first, and will re-arrange HAL
by struct rtw89_chan in the following as well.

(No logic has changed.)
Signed-off-by: default avatarZong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220809104952.61355-3-pkshih@realtek.com
parent 967439c7
...@@ -226,7 +226,7 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev, ...@@ -226,7 +226,7 @@ static void rtw89_traffic_stats_accu(struct rtw89_dev *rtwdev,
} }
static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef, static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef,
struct rtw89_channel_params *chan_param) struct rtw89_chan *chan)
{ {
struct ieee80211_channel *channel = chandef->chan; struct ieee80211_channel *channel = chandef->chan;
enum nl80211_chan_width width = chandef->width; enum nl80211_chan_width width = chandef->width;
...@@ -344,13 +344,13 @@ static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef, ...@@ -344,13 +344,13 @@ static void rtw89_get_channel_params(struct cfg80211_chan_def *chandef,
break; break;
} }
chan_param->center_chan = center_chan; chan->channel = center_chan;
chan_param->center_freq = center_freq; chan->freq = center_freq;
chan_param->primary_chan = channel->hw_value; chan->primary_channel = channel->hw_value;
chan_param->bandwidth = bandwidth; chan->band_type = band;
chan_param->pri_ch_idx = primary_chan_idx; chan->band_width = bandwidth;
chan_param->band_type = band; chan->subband_type = subband;
chan_param->subband_type = subband; chan->pri_ch_idx = primary_chan_idx;
} }
void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev) void rtw89_core_set_chip_txpwr(struct rtw89_dev *rtwdev)
...@@ -371,7 +371,7 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev) ...@@ -371,7 +371,7 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev)
struct ieee80211_hw *hw = rtwdev->hw; struct ieee80211_hw *hw = rtwdev->hw;
const struct rtw89_chip_info *chip = rtwdev->chip; const struct rtw89_chip_info *chip = rtwdev->chip;
struct rtw89_hal *hal = &rtwdev->hal; struct rtw89_hal *hal = &rtwdev->hal;
struct rtw89_channel_params ch_param; struct rtw89_chan chan;
struct rtw89_channel_help_params bak; struct rtw89_channel_help_params bak;
u8 center_chan, bandwidth; u8 center_chan, bandwidth;
bool band_changed; bool band_changed;
...@@ -379,28 +379,28 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev) ...@@ -379,28 +379,28 @@ void rtw89_set_channel(struct rtw89_dev *rtwdev)
entity_active = rtw89_get_entity_state(rtwdev); entity_active = rtw89_get_entity_state(rtwdev);
rtw89_get_channel_params(&hw->conf.chandef, &ch_param); rtw89_get_channel_params(&hw->conf.chandef, &chan);
if (WARN(ch_param.center_chan == 0, "Invalid channel\n")) if (WARN(chan.channel == 0, "Invalid channel\n"))
return; return;
center_chan = ch_param.center_chan; center_chan = chan.channel;
bandwidth = ch_param.bandwidth; bandwidth = chan.band_width;
band_changed = hal->current_band_type != ch_param.band_type; band_changed = hal->current_band_type != chan.band_type;
hal->current_band_width = bandwidth; hal->current_band_width = bandwidth;
hal->current_channel = center_chan; hal->current_channel = center_chan;
hal->current_freq = ch_param.center_freq; hal->current_freq = chan.freq;
hal->prev_primary_channel = hal->current_primary_channel; hal->prev_primary_channel = hal->current_primary_channel;
hal->prev_band_type = hal->current_band_type; hal->prev_band_type = hal->current_band_type;
hal->current_primary_channel = ch_param.primary_chan; hal->current_primary_channel = chan.primary_channel;
hal->current_band_type = ch_param.band_type; hal->current_band_type = chan.band_type;
hal->current_subband = ch_param.subband_type; hal->current_subband = chan.subband_type;
rtw89_set_entity_state(rtwdev, true); rtw89_set_entity_state(rtwdev, true);
rtw89_chip_set_channel_prepare(rtwdev, &bak); rtw89_chip_set_channel_prepare(rtwdev, &bak);
chip->ops->set_channel(rtwdev, &ch_param); chip->ops->set_channel(rtwdev, &chan);
rtw89_core_set_chip_txpwr(rtwdev); rtw89_core_set_chip_txpwr(rtwdev);
......
...@@ -624,14 +624,14 @@ enum rtw89_sc_offset { ...@@ -624,14 +624,14 @@ enum rtw89_sc_offset {
RTW89_SC_40_LOWER = 10, RTW89_SC_40_LOWER = 10,
}; };
struct rtw89_channel_params { struct rtw89_chan {
u8 center_chan; u8 channel;
u32 center_freq; u32 freq;
u8 primary_chan; u8 primary_channel;
u8 bandwidth; enum rtw89_band band_type;
u8 pri_ch_idx; enum rtw89_bandwidth band_width;
u8 band_type; enum rtw89_subband subband_type;
u8 subband_type; enum rtw89_sc_offset pri_ch_idx;
}; };
struct rtw89_channel_help_params { struct rtw89_channel_help_params {
...@@ -2100,7 +2100,7 @@ struct rtw89_chip_ops { ...@@ -2100,7 +2100,7 @@ struct rtw89_chip_ops {
bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path, bool (*write_rf)(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
u32 addr, u32 mask, u32 data); u32 addr, u32 mask, u32 data);
void (*set_channel)(struct rtw89_dev *rtwdev, void (*set_channel)(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param); const struct rtw89_chan *chan);
void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter, void (*set_channel_help)(struct rtw89_dev *rtwdev, bool enter,
struct rtw89_channel_help_params *p); struct rtw89_channel_help_params *p);
int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map); int (*read_efuse)(struct rtw89_dev *rtwdev, u8 *log_map);
......
...@@ -542,12 +542,12 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct ieee80211_sta *sta) ...@@ -542,12 +542,12 @@ void rtw89_phy_ra_assoc(struct rtw89_dev *rtwdev, struct ieee80211_sta *sta)
} }
u8 rtw89_phy_get_txsc(struct rtw89_dev *rtwdev, u8 rtw89_phy_get_txsc(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param, const struct rtw89_chan *chan,
enum rtw89_bandwidth dbw) enum rtw89_bandwidth dbw)
{ {
enum rtw89_bandwidth cbw = param->bandwidth; enum rtw89_bandwidth cbw = chan->band_width;
u8 pri_ch = param->primary_chan; u8 pri_ch = chan->primary_channel;
u8 central_ch = param->center_chan; u8 central_ch = chan->channel;
u8 txsc_idx = 0; u8 txsc_idx = 0;
u8 tmp = 0; u8 tmp = 0;
......
...@@ -439,7 +439,7 @@ rtw89_rfk_parser(struct rtw89_dev *rtwdev, const struct rtw89_rfk_tbl *tbl); ...@@ -439,7 +439,7 @@ rtw89_rfk_parser(struct rtw89_dev *rtwdev, const struct rtw89_rfk_tbl *tbl);
void rtw89_phy_write_reg3_tbl(struct rtw89_dev *rtwdev, void rtw89_phy_write_reg3_tbl(struct rtw89_dev *rtwdev,
const struct rtw89_phy_reg3_tbl *tbl); const struct rtw89_phy_reg3_tbl *tbl);
u8 rtw89_phy_get_txsc(struct rtw89_dev *rtwdev, u8 rtw89_phy_get_txsc(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param, const struct rtw89_chan *chan,
enum rtw89_bandwidth dbw); enum rtw89_bandwidth dbw);
u32 rtw89_phy_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path, u32 rtw89_phy_read_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,
u32 addr, u32 mask); u32 addr, u32 mask);
......
...@@ -660,7 +660,7 @@ static void rtw8852a_power_trim(struct rtw89_dev *rtwdev) ...@@ -660,7 +660,7 @@ static void rtw8852a_power_trim(struct rtw89_dev *rtwdev)
} }
static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev, static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param, const struct rtw89_chan *chan,
u8 mac_idx) u8 mac_idx)
{ {
u32 rf_mod = rtw89_mac_reg_by_idx(R_AX_WMAC_RFMOD, mac_idx); u32 rf_mod = rtw89_mac_reg_by_idx(R_AX_WMAC_RFMOD, mac_idx);
...@@ -669,20 +669,20 @@ static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev, ...@@ -669,20 +669,20 @@ static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev,
u32 chk_rate = rtw89_mac_reg_by_idx(R_AX_TXRATE_CHK, mac_idx); u32 chk_rate = rtw89_mac_reg_by_idx(R_AX_TXRATE_CHK, mac_idx);
u8 txsc20 = 0, txsc40 = 0; u8 txsc20 = 0, txsc40 = 0;
switch (param->bandwidth) { switch (chan->band_width) {
case RTW89_CHANNEL_WIDTH_80: case RTW89_CHANNEL_WIDTH_80:
txsc40 = rtw89_phy_get_txsc(rtwdev, param, txsc40 = rtw89_phy_get_txsc(rtwdev, chan,
RTW89_CHANNEL_WIDTH_40); RTW89_CHANNEL_WIDTH_40);
fallthrough; fallthrough;
case RTW89_CHANNEL_WIDTH_40: case RTW89_CHANNEL_WIDTH_40:
txsc20 = rtw89_phy_get_txsc(rtwdev, param, txsc20 = rtw89_phy_get_txsc(rtwdev, chan,
RTW89_CHANNEL_WIDTH_20); RTW89_CHANNEL_WIDTH_20);
break; break;
default: default:
break; break;
} }
switch (param->bandwidth) { switch (chan->band_width) {
case RTW89_CHANNEL_WIDTH_80: case RTW89_CHANNEL_WIDTH_80:
rtw89_write8_mask(rtwdev, rf_mod, B_AX_WMAC_RFMOD_MASK, BIT(1)); rtw89_write8_mask(rtwdev, rf_mod, B_AX_WMAC_RFMOD_MASK, BIT(1));
rtw89_write32(rtwdev, sub_carr, txsc20 | (txsc40 << 4)); rtw89_write32(rtwdev, sub_carr, txsc20 | (txsc40 << 4));
...@@ -699,7 +699,7 @@ static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev, ...@@ -699,7 +699,7 @@ static void rtw8852a_set_channel_mac(struct rtw89_dev *rtwdev,
break; break;
} }
if (param->center_chan > 14) if (chan->channel > 14)
rtw89_write8_set(rtwdev, chk_rate, rtw89_write8_set(rtwdev, chk_rate,
B_AX_CHECK_CCK_EN | B_AX_RTS_LIMIT_IN_OFDM6); B_AX_CHECK_CCK_EN | B_AX_RTS_LIMIT_IN_OFDM6);
else else
...@@ -1130,35 +1130,36 @@ static void rtw8852a_bbrst_for_rfk(struct rtw89_dev *rtwdev, ...@@ -1130,35 +1130,36 @@ static void rtw8852a_bbrst_for_rfk(struct rtw89_dev *rtwdev,
} }
static void rtw8852a_set_channel_bb(struct rtw89_dev *rtwdev, static void rtw8852a_set_channel_bb(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param, const struct rtw89_chan *chan,
enum rtw89_phy_idx phy_idx) enum rtw89_phy_idx phy_idx)
{ {
bool cck_en = param->center_chan <= 14; bool cck_en = chan->channel <= 14;
u8 pri_ch_idx = param->pri_ch_idx; u8 pri_ch_idx = chan->pri_ch_idx;
if (cck_en) if (cck_en)
rtw8852a_ctrl_sco_cck(rtwdev, param->center_chan, rtw8852a_ctrl_sco_cck(rtwdev, chan->channel,
param->primary_chan, param->bandwidth); chan->primary_channel,
chan->band_width);
rtw8852a_ctrl_ch(rtwdev, param->center_chan, phy_idx); rtw8852a_ctrl_ch(rtwdev, chan->channel, phy_idx);
rtw8852a_ctrl_bw(rtwdev, pri_ch_idx, param->bandwidth, phy_idx); rtw8852a_ctrl_bw(rtwdev, pri_ch_idx, chan->band_width, phy_idx);
if (cck_en) { if (cck_en) {
rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 0); rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 0);
} else { } else {
rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 1); rtw89_phy_write32_mask(rtwdev, R_RXCCA, B_RXCCA_DIS, 1);
rtw8852a_bbrst_for_rfk(rtwdev, phy_idx); rtw8852a_bbrst_for_rfk(rtwdev, phy_idx);
} }
rtw8852a_spur_elimination(rtwdev, param->center_chan); rtw8852a_spur_elimination(rtwdev, chan->channel);
rtw89_phy_write32_mask(rtwdev, R_MAC_PIN_SEL, B_CH_IDX_SEG0, rtw89_phy_write32_mask(rtwdev, R_MAC_PIN_SEL, B_CH_IDX_SEG0,
param->primary_chan); chan->primary_channel);
rtw8852a_bb_reset_all(rtwdev, phy_idx); rtw8852a_bb_reset_all(rtwdev, phy_idx);
} }
static void rtw8852a_set_channel(struct rtw89_dev *rtwdev, static void rtw8852a_set_channel(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *params) const struct rtw89_chan *chan)
{ {
rtw8852a_set_channel_mac(rtwdev, params, RTW89_MAC_0); rtw8852a_set_channel_mac(rtwdev, chan, RTW89_MAC_0);
rtw8852a_set_channel_bb(rtwdev, params, RTW89_PHY_0); rtw8852a_set_channel_bb(rtwdev, chan, RTW89_PHY_0);
} }
static void rtw8852a_dfs_en(struct rtw89_dev *rtwdev, bool en) static void rtw8852a_dfs_en(struct rtw89_dev *rtwdev, bool en)
......
...@@ -3802,11 +3802,12 @@ void rtw8852c_ctrl_bw_ch(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy, ...@@ -3802,11 +3802,12 @@ void rtw8852c_ctrl_bw_ch(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy,
} }
void rtw8852c_set_channel_rf(struct rtw89_dev *rtwdev, void rtw8852c_set_channel_rf(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param, const struct rtw89_chan *chan,
enum rtw89_phy_idx phy_idx) enum rtw89_phy_idx phy_idx)
{ {
rtw8852c_ctrl_bw_ch(rtwdev, phy_idx, param->center_chan, param->band_type, rtw8852c_ctrl_bw_ch(rtwdev, phy_idx, chan->channel,
param->bandwidth); chan->band_type,
chan->band_width);
} }
void rtw8852c_mcc_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx) void rtw8852c_mcc_get_ch_info(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
......
...@@ -21,7 +21,7 @@ void rtw8852c_tssi_cont_en_phyidx(struct rtw89_dev *rtwdev, bool en, u8 phy_idx) ...@@ -21,7 +21,7 @@ void rtw8852c_tssi_cont_en_phyidx(struct rtw89_dev *rtwdev, bool en, u8 phy_idx)
void rtw8852c_wifi_scan_notify(struct rtw89_dev *rtwdev, bool scan_start, void rtw8852c_wifi_scan_notify(struct rtw89_dev *rtwdev, bool scan_start,
enum rtw89_phy_idx phy_idx); enum rtw89_phy_idx phy_idx);
void rtw8852c_set_channel_rf(struct rtw89_dev *rtwdev, void rtw8852c_set_channel_rf(struct rtw89_dev *rtwdev,
struct rtw89_channel_params *param, const struct rtw89_chan *chan,
enum rtw89_phy_idx phy_idx); enum rtw89_phy_idx phy_idx);
void rtw8852c_lck_init(struct rtw89_dev *rtwdev); void rtw8852c_lck_init(struct rtw89_dev *rtwdev);
void rtw8852c_lck_track(struct rtw89_dev *rtwdev); void rtw8852c_lck_track(struct rtw89_dev *rtwdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment