mirror of https://gitee.com/openkylin/linux.git
mt76: introduce mt76x02_init_beacon_config routine
Add mt76x02_init_beacon_config utility routine in mt76x02-lib module in order to be reused by mt76x0 driver configuring BSSID registers and remove duplicated code Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
parent
f7c8a0f2da
commit
fc245983a8
|
@ -135,8 +135,6 @@ static void mt76x0_init_mac_registers(struct mt76x02_dev *dev)
|
|||
{
|
||||
RANDOM_WRITE(dev, common_mac_reg_table);
|
||||
|
||||
mt76x02_set_beacon_offsets(dev);
|
||||
|
||||
/* Enable PBF and MAC clock SYS_CTRL[11:10] = 0x3 */
|
||||
RANDOM_WRITE(dev, mt76x0_mac_reg_table);
|
||||
|
||||
|
@ -297,11 +295,6 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
mt76_clear(dev, MT_BEACON_TIME_CFG, (MT_BEACON_TIME_CFG_TIMER_EN |
|
||||
MT_BEACON_TIME_CFG_SYNC_MODE |
|
||||
MT_BEACON_TIME_CFG_TBTT_EN |
|
||||
MT_BEACON_TIME_CFG_BEACON_TX));
|
||||
|
||||
mt76x0_reset_counters(dev);
|
||||
|
||||
ret = mt76x0_eeprom_init(dev);
|
||||
|
@ -309,6 +302,7 @@ int mt76x0_init_hardware(struct mt76x02_dev *dev)
|
|||
return ret;
|
||||
|
||||
mt76x0_phy_init(dev);
|
||||
mt76x02_init_beacon_config(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ int mt76x02_get_txpower(struct ieee80211_hw *hw,
|
|||
void mt76x02_sta_ps(struct mt76_dev *dev, struct ieee80211_sta *sta, bool ps);
|
||||
|
||||
extern const u16 mt76x02_beacon_offsets[16];
|
||||
void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev);
|
||||
void mt76x02_init_beacon_config(struct mt76x02_dev *dev);
|
||||
void mt76x02_set_irq_mask(struct mt76x02_dev *dev, u32 clear, u32 set);
|
||||
void mt76x02_mac_start(struct mt76x02_dev *dev);
|
||||
|
||||
|
|
|
@ -560,7 +560,7 @@ const u16 mt76x02_beacon_offsets[16] = {
|
|||
};
|
||||
EXPORT_SYMBOL_GPL(mt76x02_beacon_offsets);
|
||||
|
||||
void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev)
|
||||
static void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev)
|
||||
{
|
||||
u16 val, base = MT_BEACON_BASE;
|
||||
u32 regs[4] = {};
|
||||
|
@ -574,6 +574,32 @@ void mt76x02_set_beacon_offsets(struct mt76x02_dev *dev)
|
|||
for (i = 0; i < 4; i++)
|
||||
mt76_wr(dev, MT_BCN_OFFSET(i), regs[i]);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76x02_set_beacon_offsets);
|
||||
|
||||
void mt76x02_init_beacon_config(struct mt76x02_dev *dev)
|
||||
{
|
||||
static const u8 null_addr[ETH_ALEN] = {};
|
||||
int i;
|
||||
|
||||
mt76_wr(dev, MT_MAC_BSSID_DW0,
|
||||
get_unaligned_le32(dev->mt76.macaddr));
|
||||
mt76_wr(dev, MT_MAC_BSSID_DW1,
|
||||
get_unaligned_le16(dev->mt76.macaddr + 4) |
|
||||
FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 beacons */
|
||||
MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
|
||||
|
||||
/* Fire a pre-TBTT interrupt 8 ms before TBTT */
|
||||
mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
|
||||
8 << 4);
|
||||
mt76_wr(dev, MT_INT_TIMER_EN, 0);
|
||||
|
||||
mt76_wr(dev, MT_BCN_BYPASS_MASK, 0xffff);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
mt76x02_mac_set_bssid(dev, i, null_addr);
|
||||
mt76x02_mac_set_beacon(dev, i, NULL);
|
||||
}
|
||||
mt76x02_set_beacon_offsets(dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mt76x02_init_beacon_config);
|
||||
|
||||
MODULE_LICENSE("Dual BSD/GPL");
|
||||
|
|
|
@ -79,7 +79,6 @@ mt76x2_fixup_xtal(struct mt76x02_dev *dev)
|
|||
|
||||
static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
|
||||
{
|
||||
static const u8 null_addr[ETH_ALEN] = {};
|
||||
const u8 *macaddr = dev->mt76.macaddr;
|
||||
u32 val;
|
||||
int i, k;
|
||||
|
@ -123,19 +122,10 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
|
|||
mt76_wr(dev, MT_MAC_ADDR_DW0, get_unaligned_le32(macaddr));
|
||||
mt76_wr(dev, MT_MAC_ADDR_DW1, get_unaligned_le16(macaddr + 4));
|
||||
|
||||
mt76_wr(dev, MT_MAC_BSSID_DW0, get_unaligned_le32(macaddr));
|
||||
mt76_wr(dev, MT_MAC_BSSID_DW1, get_unaligned_le16(macaddr + 4) |
|
||||
FIELD_PREP(MT_MAC_BSSID_DW1_MBSS_MODE, 3) | /* 8 beacons */
|
||||
MT_MAC_BSSID_DW1_MBSS_LOCAL_BIT);
|
||||
|
||||
/* Fire a pre-TBTT interrupt 8 ms before TBTT */
|
||||
mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_PRE_TBTT,
|
||||
8 << 4);
|
||||
mt76_rmw_field(dev, MT_INT_TIMER_CFG, MT_INT_TIMER_CFG_GP_TIMER,
|
||||
MT_DFS_GP_INTERVAL);
|
||||
mt76_wr(dev, MT_INT_TIMER_EN, 0);
|
||||
|
||||
mt76_wr(dev, MT_BCN_BYPASS_MASK, 0xffff);
|
||||
mt76x02_init_beacon_config(dev);
|
||||
if (!hard)
|
||||
return 0;
|
||||
|
||||
|
@ -152,11 +142,6 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
|
|||
for (k = 0; k < 4; k++)
|
||||
mt76x02_mac_shared_key_setup(dev, i, k, NULL);
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
mt76x02_mac_set_bssid(dev, i, null_addr);
|
||||
mt76x02_mac_set_beacon(dev, i, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
mt76_rr(dev, MT_TX_STAT_FIFO);
|
||||
|
||||
|
@ -168,8 +153,6 @@ static int mt76x2_mac_reset(struct mt76x02_dev *dev, bool hard)
|
|||
MT_CH_TIME_CFG_EIFS_AS_BUSY |
|
||||
FIELD_PREP(MT_CH_TIME_CFG_CH_TIMER_CLR, 1));
|
||||
|
||||
mt76x02_set_beacon_offsets(dev);
|
||||
|
||||
mt76x2_set_tx_ackto(dev);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue