Skip to content

Commit

Permalink
wifi: mt76: mt7915: rely on band_idx of mt76_phy
Browse files Browse the repository at this point in the history
The commit dc44c45c8cd0 added band_idx into mt76_phy, so switching to
rely on that.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
ryderlee1110 authored and nbd168 committed Dec 1, 2022
1 parent a7b9153 commit 525592c
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 166 deletions.
16 changes: 9 additions & 7 deletions mt7915/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mt7915_sys_recovery_set(struct file *file, const char __user *user_buf,
{
struct mt7915_phy *phy = file->private_data;
struct mt7915_dev *dev = phy->dev;
bool band = phy->band_idx;
bool band = phy->mt76->band_idx;
char buf[16];
int ret = 0;
u16 val;
Expand Down Expand Up @@ -692,15 +692,16 @@ mt7915_ampdu_stat_read_phy(struct mt7915_phy *phy,
struct mt7915_dev *dev = phy->dev;
bool ext_phy = phy != &dev->phy;
int bound[15], range[4], i;
u8 band = phy->mt76->band_idx;

/* Tx ampdu stat */
for (i = 0; i < ARRAY_SIZE(range); i++)
range[i] = mt76_rr(dev, MT_MIB_ARNG(phy->band_idx, i));
range[i] = mt76_rr(dev, MT_MIB_ARNG(band, i));

for (i = 0; i < ARRAY_SIZE(bound); i++)
bound[i] = MT_MIB_ARNCR_RANGE(range[i / 4], i % 4) + 1;

seq_printf(file, "\nPhy %d, Phy band %d\n", ext_phy, phy->band_idx);
seq_printf(file, "\nPhy %d, Phy band %d\n", ext_phy, band);

seq_printf(file, "Length: %8d | ", bound[0]);
for (i = 0; i < ARRAY_SIZE(bound) - 1; i++)
Expand Down Expand Up @@ -983,6 +984,7 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
struct mt7915_dev *dev = phy->dev;
s8 txpwr[MT7915_SKU_RATE_NUM];
static const size_t sz = 2048;
u8 band = phy->mt76->band_idx;
int i, offs = 0, len = 0;
ssize_t ret;
char *buf;
Expand Down Expand Up @@ -1038,8 +1040,8 @@ mt7915_rate_txpower_get(struct file *file, char __user *user_buf,
mt7915_txpower_puts(HE996, SKU_HE_RU996);
mt7915_txpower_puts(HE996x2, SKU_HE_RU2x996);

reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(phy->band_idx) :
MT_WF_PHY_TPC_CTRL_STAT_MT7916(phy->band_idx);
reg = is_mt7915(&dev->mt76) ? MT_WF_PHY_TPC_CTRL_STAT(band) :
MT_WF_PHY_TPC_CTRL_STAT_MT7916(band);

len += scnprintf(buf + len, sz - len, "\nTx power (bbp) : %6ld\n",
mt76_get_field(dev, reg, MT_WF_PHY_TPC_POWER));
Expand All @@ -1058,7 +1060,7 @@ mt7915_rate_txpower_set(struct file *file, const char __user *user_buf,
struct mt76_phy *mphy = phy->mt76;
struct mt7915_mcu_txpower_sku req = {
.format_id = TX_POWER_LIMIT_TABLE,
.band_idx = phy->band_idx,
.band_idx = phy->mt76->band_idx,
};
char buf[100];
int i, ret, pwr160 = 0, pwr80 = 0, pwr40 = 0, pwr20 = 0;
Expand Down Expand Up @@ -1241,7 +1243,7 @@ int mt7915_init_debugfs(struct mt7915_phy *phy)
mt7915_twt_stats);
debugfs_create_file("rf_regval", 0600, dir, dev, &fops_rf_regval);

if (!dev->dbdc_support || phy->band_idx) {
if (!dev->dbdc_support || phy->mt76->band_idx) {
debugfs_create_u32("dfs_hw_pattern", 0400, dir,
&dev->hw_pattern);
debugfs_create_file("radar_trigger", 0200, dir, dev,
Expand Down
12 changes: 6 additions & 6 deletions mt7915/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ static int mt7915_dma_enable(struct mt7915_dev *dev)
MT_INT_TX_DONE_MCU |
MT_INT_MCU_CMD;

if (!dev->phy.band_idx)
if (!dev->phy.mt76->band_idx)
irq_mask |= MT_INT_BAND0_RX_DONE;

if (dev->dbdc_support || dev->phy.band_idx)
if (dev->dbdc_support || dev->phy.mt76->band_idx)
irq_mask |= MT_INT_BAND1_RX_DONE;

if (mtk_wed_device_active(&dev->mt76.mmio.wed)) {
Expand Down Expand Up @@ -418,15 +418,15 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)

/* init tx queue */
ret = mt7915_init_tx_queues(&dev->phy,
MT_TXQ_ID(dev->phy.band_idx),
MT_TXQ_ID(dev->phy.mt76->band_idx),
MT7915_TX_RING_SIZE,
MT_TXQ_RING_BASE(0));
if (ret)
return ret;

if (phy2) {
ret = mt7915_init_tx_queues(phy2,
MT_TXQ_ID(phy2->band_idx),
MT_TXQ_ID(phy2->mt76->band_idx),
MT7915_TX_RING_SIZE,
MT_TXQ_RING_BASE(1));
if (ret)
Expand Down Expand Up @@ -482,7 +482,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
return ret;

/* rx data queue for band0 */
if (!dev->phy.band_idx) {
if (!dev->phy.mt76->band_idx) {
if (mtk_wed_device_active(&mdev->mmio.wed) &&
mtk_wed_get_rx_capa(&mdev->mmio.wed)) {
dev->mt76.q_rx[MT_RXQ_MAIN].flags =
Expand Down Expand Up @@ -519,7 +519,7 @@ int mt7915_dma_init(struct mt7915_dev *dev, struct mt7915_phy *phy2)
return ret;
}

if (dev->dbdc_support || dev->phy.band_idx) {
if (dev->dbdc_support || dev->phy.mt76->band_idx) {
if (mtk_wed_device_active(&mdev->mmio.wed) &&
mtk_wed_get_rx_capa(&mdev->mmio.wed)) {
dev->mt76.q_rx[MT_RXQ_BAND1].flags =
Expand Down
14 changes: 8 additions & 6 deletions mt7915/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
{
struct mt7915_dev *dev = phy->dev;
u8 *eeprom = dev->mt76.eeprom.data;
u8 band = phy->mt76->band_idx;
u32 val;

val = eeprom[MT_EE_WIFI_CONF + phy->band_idx];
val = eeprom[MT_EE_WIFI_CONF + band];
val = FIELD_GET(MT_EE_WIFI_CONF0_BAND_SEL, val);

if (!is_mt7915(&dev->mt76)) {
Expand All @@ -153,7 +154,7 @@ static void mt7915_eeprom_parse_band_config(struct mt7915_phy *phy)
return;
}
} else if (val == MT_EE_BAND_SEL_DEFAULT && dev->dbdc_support) {
val = phy->band_idx ? MT_EE_BAND_SEL_5GHZ : MT_EE_BAND_SEL_2GHZ;
val = band ? MT_EE_BAND_SEL_5GHZ : MT_EE_BAND_SEL_2GHZ;
}

switch (val) {
Expand All @@ -175,6 +176,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
{
u8 path, nss, nss_max = 4, *eeprom = dev->mt76.eeprom.data;
struct mt76_phy *mphy = phy->mt76;
u8 band = phy->mt76->band_idx;

mt7915_eeprom_parse_band_config(phy);

Expand All @@ -184,7 +186,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
eeprom[MT_EE_WIFI_CONF]);
} else {
path = FIELD_GET(MT_EE_WIFI_CONF0_TX_PATH,
eeprom[MT_EE_WIFI_CONF + phy->band_idx]);
eeprom[MT_EE_WIFI_CONF + band]);
}

if (!path || path > 4)
Expand All @@ -197,12 +199,12 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
path = min_t(u8, path, 2);
nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B0,
eeprom[MT_EE_WIFI_CONF + 3]);
if (phy->band_idx)
if (band)
nss = FIELD_GET(MT_EE_WIFI_CONF3_TX_PATH_B1,
eeprom[MT_EE_WIFI_CONF + 3]);
} else {
nss = FIELD_GET(MT_EE_WIFI_CONF_STREAM_NUM,
eeprom[MT_EE_WIFI_CONF + 2 + phy->band_idx]);
eeprom[MT_EE_WIFI_CONF + 2 + band]);
}

if (!is_mt7986(&dev->mt76))
Expand All @@ -214,7 +216,7 @@ void mt7915_eeprom_parse_hw_cap(struct mt7915_dev *dev,
nss = min_t(u8, min_t(u8, nss_max, nss), path);

mphy->chainmask = BIT(path) - 1;
if (phy->band_idx)
if (band)
mphy->chainmask <<= dev->chainshift;
mphy->antenna_mask = BIT(nss) - 1;
dev->chainmask |= mphy->chainmask;
Expand Down
6 changes: 3 additions & 3 deletions mt7915/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ mt7915_alloc_ext_phy(struct mt7915_dev *dev)
phy->mt76 = mphy;

/* Bind main phy to band0 and ext_phy to band1 for dbdc case */
phy->band_idx = 1;
phy->mt76->band_idx = 1;

return phy;
}
Expand Down Expand Up @@ -663,7 +663,7 @@ static bool mt7915_band_config(struct mt7915_dev *dev)
{
bool ret = true;

dev->phy.band_idx = 0;
dev->phy.mt76->band_idx = 0;

if (is_mt7986(&dev->mt76)) {
u32 sku = mt7915_check_adie(dev, true);
Expand All @@ -674,7 +674,7 @@ static bool mt7915_band_config(struct mt7915_dev *dev)
* dbdc is disabled.
*/
if (sku == MT7975_ONE_ADIE || sku == MT7976_ONE_ADIE) {
dev->phy.band_idx = 1;
dev->phy.mt76->band_idx = 1;
ret = false;
}
} else {
Expand Down

0 comments on commit 525592c

Please sign in to comment.