diff --git a/Makefile b/Makefile index 5efba43b..dc2238f5 100644 --- a/Makefile +++ b/Makefile @@ -15,4 +15,4 @@ mt76x2e-$(CONFIG_OF) += mt76x2_of.o mt7603e-y := \ mt7603_pci.o mt7603_main.o mt7603_init.o mt7603_mcu.o \ - mt7603_core.o mt7603_dma.o + mt7603_core.o mt7603_dma.o mt7603_mac.o diff --git a/mt7603.h b/mt7603.h index 9f4e13a8..399fcc5f 100644 --- a/mt7603.h +++ b/mt7603.h @@ -111,4 +111,6 @@ int mt7603_set_channel(struct mt7603_dev *dev, struct cfg80211_chan_def *def); int mt7603_mcu_set_channel(struct mt7603_dev *dev); int mt7603_mcu_reg_read(struct mt7603_dev *dev, u32 reg, u32 *val, bool rf); +void mt7603_wtbl_clear(struct mt7603_dev *dev, int idx); + #endif diff --git a/mt7603_init.c b/mt7603_init.c index 3750c462..aaad1350 100644 --- a/mt7603_init.c +++ b/mt7603_init.c @@ -195,6 +195,15 @@ mt7603_phy_init(struct mt7603_dev *dev) tx_chains); } +static void +mt7603_mac_init(struct mt7603_dev *dev) +{ + int i; + + for (i = 0; i < MT7603_WTBL_SIZE; i++) + mt7603_wtbl_clear(dev, i); +} + static int mt7603_init_hardware(struct mt7603_dev *dev) { @@ -226,6 +235,7 @@ mt7603_init_hardware(struct mt7603_dev *dev) mt7603_dma_sched_init(dev); mt7603_phy_init(dev); + mt7603_mac_init(dev); return 0; } diff --git a/mt7603_mac.c b/mt7603_mac.c new file mode 100644 index 00000000..446cc1c1 --- /dev/null +++ b/mt7603_mac.c @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2015 Felix Fietkau + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * 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 FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "mt7603.h" + +#define MT_PSE_PAGE_SIZE 128 + +void mt7603_wtbl_clear(struct mt7603_dev *dev, int idx) +{ + int wtbl2_frame = (idx * MT_WTBL2_SIZE) / MT_PSE_PAGE_SIZE; + int wtbl2_entry = (idx * MT_WTBL2_SIZE) % MT_PSE_PAGE_SIZE; + int wtbl3_frame = (idx * MT_WTBL3_SIZE) / MT_PSE_PAGE_SIZE; + int wtbl3_entry = ((idx * MT_WTBL3_SIZE) % MT_PSE_PAGE_SIZE) * 2; + int wtbl4_frame = (idx * MT_WTBL4_SIZE) / MT_PSE_PAGE_SIZE; + int wtbl4_entry = (idx * MT_WTBL4_SIZE) % MT_PSE_PAGE_SIZE; + u32 addr; + + addr = MT_WTBL1_BASE + idx * MT_WTBL1_SIZE; + + mt76_wr(dev, addr + 0 * 4, + MT_WTBL1_W0_RX_CHECK_A2 | + MT_WTBL1_W0_RX_VALID); + mt76_wr(dev, addr + 1 * 4, 0); + mt76_wr(dev, addr + 2 * 4, 0); + mt76_wr(dev, addr + 3 * 4, + MT76_SET(MT_WTBL1_W3_WTBL2_FRAME_ID, wtbl2_frame) | + MT76_SET(MT_WTBL1_W3_WTBL2_ENTRY_ID, wtbl2_entry) | + MT76_SET(MT_WTBL1_W3_WTBL4_FRAME_ID, wtbl4_frame)); + mt76_wr(dev, addr + 4 * 4, + MT76_SET(MT_WTBL1_W4_WTBL3_FRAME_ID, wtbl3_frame) | + MT76_SET(MT_WTBL1_W4_WTBL3_ENTRY_ID, wtbl3_entry) | + MT76_SET(MT_WTBL1_W4_WTBL4_ENTRY_ID, wtbl4_entry)); +} diff --git a/mt7603_mac.h b/mt7603_mac.h new file mode 100644 index 00000000..e69de29b diff --git a/mt7603_regs.h b/mt7603_regs.h index fc7463ca..23c0b0af 100644 --- a/mt7603_regs.h +++ b/mt7603_regs.h @@ -215,6 +215,8 @@ #define MT_WF_RFCR1 MT_WF_RMAC(0x0a4) #define MT_WF_RMAC_TMR_PA MT_WF_RMAC(0x0e0) +#define MT_WTBL1_BASE 0x28000 + #define MT_PCIE_REMAP_BASE_1 0x40000 #define MT_PCIE_REMAP_BASE_2 0x80000