Skip to content

Commit eb99cc9

Browse files
LorenzoBianconinbd168
authored andcommitted
mt76: mt7615: introduce mt7663u support
Introduce support for mt7663u 802.11ac 2x2:2 chipset to mt7615 driver. Main difference respect to pcie code base is the usb code needs to configure wtbl from non-atomic context Co-developed-by: Sean Wang <[email protected]> Signed-off-by: Sean Wang <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: Felix Fietkau <[email protected]>
1 parent e90354e commit eb99cc9

File tree

13 files changed

+756
-3
lines changed

13 files changed

+756
-3
lines changed

drivers/net/wireless/mediatek/mt76/mt76.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ enum {
285285
MT76_MCU_RESET,
286286
MT76_REMOVED,
287287
MT76_READING_STATS,
288+
MT76_STATE_POWER_OFF,
288289
};
289290

290291
struct mt76_hw_cap {

drivers/net/wireless/mediatek/mt76/mt7615/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,14 @@ config MT7622_WMAC
2727
This adds support for the built-in WMAC on MT7622 SoC devices
2828
which has the same feature set as a MT7615, but limited to
2929
2.4 GHz only.
30+
31+
config MT7663U
32+
tristate "MediaTek MT7663U (USB) support"
33+
select MT76_USB
34+
select MT7615_COMMON
35+
depends on MAC80211
36+
depends on USB
37+
help
38+
This adds support for MT7663U 802.11ax 2x2:2 wireless devices.
39+
40+
To compile this driver as a module, choose M here.

drivers/net/wireless/mediatek/mt76/mt7615/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
obj-$(CONFIG_MT7615_COMMON) += mt7615-common.o
44
obj-$(CONFIG_MT7615E) += mt7615e.o
5+
obj-$(CONFIG_MT7663U) += mt7663u.o
56

67
CFLAGS_trace.o := -I$(src)
78

@@ -10,3 +11,5 @@ mt7615-common-y := main.o init.o mcu.o eeprom.o mac.o \
1011

1112
mt7615e-y := pci.o pci_init.o dma.o pci_mac.o mmio.o
1213
mt7615e-$(CONFIG_MT7622_WMAC) += soc.o
14+
15+
mt7663u-y := usb.o usb_mcu.o usb_init.o

drivers/net/wireless/mediatek/mt76/mt7615/mac.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,29 @@ mt7615_mac_update_rate_desc(struct mt7615_phy *phy, struct mt7615_sta *sta,
871871
rd->bw = bw;
872872
}
873873

874+
static int
875+
mt7615_mac_queue_rate_update(struct mt7615_phy *phy, struct mt7615_sta *sta,
876+
struct ieee80211_tx_rate *probe_rate,
877+
struct ieee80211_tx_rate *rates)
878+
{
879+
struct mt7615_dev *dev = phy->dev;
880+
struct mt7615_wtbl_desc *wd;
881+
882+
wd = kzalloc(sizeof(*wd), GFP_ATOMIC);
883+
if (!wd)
884+
return -ENOMEM;
885+
886+
wd->type = MT7615_WTBL_RATE_DESC;
887+
wd->sta = sta;
888+
889+
mt7615_mac_update_rate_desc(phy, sta, probe_rate, rates,
890+
&wd->rate);
891+
list_add_tail(&wd->node, &dev->wd_head);
892+
queue_work(dev->mt76.usb.wq, &dev->wtbl_work);
893+
894+
return 0;
895+
}
896+
874897
void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
875898
struct ieee80211_tx_rate *probe_rate,
876899
struct ieee80211_tx_rate *rates)
@@ -880,6 +903,11 @@ void mt7615_mac_set_rates(struct mt7615_phy *phy, struct mt7615_sta *sta,
880903
struct mt7615_rate_desc rd;
881904
u32 w5, w27, addr;
882905

906+
if (mt76_is_usb(&dev->mt76)) {
907+
mt7615_mac_queue_rate_update(phy, sta, probe_rate, rates);
908+
return;
909+
}
910+
883911
if (!mt76_poll(dev, MT_WTBL_UPDATE, MT_WTBL_UPDATE_BUSY, 0, 5000))
884912
return;
885913

drivers/net/wireless/mediatek/mt76/mt7615/mac.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,12 @@ enum tx_phy_bandwidth {
165165
#define MT_CT_INFO_NONE_CIPHER_FRAME BIT(3)
166166
#define MT_CT_INFO_HSR2_TX BIT(4)
167167

168-
#define MT_USB_TXD_SIZE (MT_TXD_SIZE + 8 * 4)
169168
#define MT_TXD_SIZE (8 * 4)
170169

170+
#define MT_USB_TXD_SIZE (MT_TXD_SIZE + 8 * 4)
171+
#define MT_USB_HDR_SIZE 4
172+
#define MT_USB_TAIL_SIZE 4
173+
171174
#define MT_TXD0_P_IDX BIT(31)
172175
#define MT_TXD0_Q_IDX GENMASK(30, 26)
173176
#define MT_TXD0_UDP_TCP_SUM BIT(24)

drivers/net/wireless/mediatek/mt76/mt7615/main.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,37 @@ static int mt7615_set_channel(struct mt7615_phy *phy)
277277
return ret;
278278
}
279279

280+
static int
281+
mt7615_queue_key_update(struct mt7615_dev *dev, enum set_key_cmd cmd,
282+
struct mt7615_sta *msta,
283+
struct ieee80211_key_conf *key)
284+
{
285+
struct mt7615_wtbl_desc *wd;
286+
287+
wd = kzalloc(sizeof(*wd), GFP_KERNEL);
288+
if (!wd)
289+
return -ENOMEM;
290+
291+
wd->type = MT7615_WTBL_KEY_DESC;
292+
wd->sta = msta;
293+
294+
wd->key.key = kzalloc(key->keylen, GFP_KERNEL);
295+
if (!wd->key.key) {
296+
kfree(wd);
297+
return -ENOMEM;
298+
}
299+
memcpy(wd->key.key, key->key, key->keylen);
300+
wd->key.cipher = key->cipher;
301+
wd->key.keyidx = key->keyidx;
302+
wd->key.keylen = key->keylen;
303+
wd->key.cmd = cmd;
304+
305+
list_add_tail(&wd->node, &dev->wd_head);
306+
queue_work(dev->mt76.usb.wq, &dev->wtbl_work);
307+
308+
return 0;
309+
}
310+
280311
static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
281312
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
282313
struct ieee80211_key_conf *key)
@@ -325,6 +356,9 @@ static int mt7615_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
325356
mt76_wcid_key_setup(&dev->mt76, wcid,
326357
cmd == SET_KEY ? key : NULL);
327358

359+
if (mt76_is_usb(&dev->mt76))
360+
return mt7615_queue_key_update(dev, cmd, msta, key);
361+
328362
return mt7615_mac_wtbl_set_key(dev, wcid, key, cmd);
329363
}
330364

drivers/net/wireless/mediatek/mt76/mt7615/mcu.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,7 @@ static int mt7615_mcu_send_firmware(struct mt7615_dev *dev, const void *data,
15981598
int ret = 0, cur_len;
15991599

16001600
while (len > 0) {
1601-
cur_len = min_t(int, 4096 - sizeof(struct mt7615_mcu_txd),
1602-
len);
1601+
cur_len = min_t(int, 4096 - dev->mt76.mcu_ops->headroom, len);
16031602

16041603
ret = __mt76_mcu_send_msg(&dev->mt76, MCU_CMD_FW_SCATTER,
16051604
data, cur_len, false);

drivers/net/wireless/mediatek/mt76/mt7615/mcu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ enum {
449449
FW_STATE_CR4_RDY = 7
450450
};
451451

452+
enum {
453+
FW_STATE_PWR_ON = 1,
454+
FW_STATE_N9_RDY = 2,
455+
};
456+
452457
#define STA_TYPE_STA BIT(0)
453458
#define STA_TYPE_AP BIT(1)
454459
#define STA_TYPE_ADHOC BIT(2)

drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ struct mt7615_dev {
269269
struct idr token;
270270

271271
u8 fw_ver;
272+
273+
struct work_struct wtbl_work;
274+
struct list_head wd_head;
272275
};
273276

274277
enum {
@@ -508,6 +511,13 @@ int mt7615_mcu_apply_tx_dpd(struct mt7615_phy *phy);
508511
int mt7615_dfs_init_radar_detector(struct mt7615_phy *phy);
509512

510513
int mt7615_init_debugfs(struct mt7615_dev *dev);
514+
int mt7615_mcu_wait_response(struct mt7615_dev *dev, int cmd, int seq);
515+
511516
int __mt7663_load_firmware(struct mt7615_dev *dev);
512517

518+
/* usb */
519+
void mt7663u_wtbl_work(struct work_struct *work);
520+
int mt7663u_mcu_init(struct mt7615_dev *dev);
521+
int mt7663u_register_device(struct mt7615_dev *dev);
522+
513523
#endif

drivers/net/wireless/mediatek/mt76/mt7615/regs.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ enum mt7615_reg_base {
4343
#define MT_TOP_MISC2_FW_STATE GENMASK(2, 0)
4444

4545
#define MT7663_TOP_MISC2_FW_STATE GENMASK(3, 1)
46+
#define MT_TOP_MISC2_FW_PWR_ON BIT(1)
4647

4748
#define MT_MCU_BASE 0x2000
4849
#define MT_MCU(ofs) (MT_MCU_BASE + (ofs))
@@ -58,6 +59,8 @@ enum mt7615_reg_base {
5859
#define MT_PCIE_REMAP_BASE_2 ((dev)->reg_map[MT_PCIE_REMAP_BASE2])
5960

6061
#define MT_HIF(ofs) ((dev)->reg_map[MT_HIF_BASE] + (ofs))
62+
#define MT_HIF_RST MT_HIF(0x100)
63+
#define MT_HIF_LOGIC_RST_N BIT(4)
6164

6265
#define MT7663_MCU_PCIE_REMAP_2_OFFSET GENMASK(15, 0)
6366
#define MT7663_MCU_PCIE_REMAP_2_BASE GENMASK(31, 16)
@@ -483,4 +486,27 @@ enum mt7615_reg_base {
483486
#define MT_INFRACFG_MISC 0x700
484487
#define MT_INFRACFG_MISC_AP2CONN_WAKE BIT(1)
485488

489+
#define MT_UMAC_BASE 0x7c000000
490+
#define MT_UMAC(ofs) (MT_UMAC_BASE + (ofs))
491+
#define MT_UDMA_TX_QSEL MT_UMAC(0x008)
492+
#define MT_FW_DL_EN BIT(3)
493+
494+
#define MT_UDMA_WLCFG_1 MT_UMAC(0x00c)
495+
#define MT_WL_RX_AGG_PKT_LMT GENMASK(7, 0)
496+
#define MT_WL_TX_TMOUT_LMT GENMASK(27, 8)
497+
498+
#define MT_UDMA_WLCFG_0 MT_UMAC(0x18)
499+
#define MT_WL_RX_AGG_TO GENMASK(7, 0)
500+
#define MT_WL_RX_AGG_LMT GENMASK(15, 8)
501+
#define MT_WL_TX_TMOUT_FUNC_EN BIT(16)
502+
#define MT_WL_TX_DPH_CHK_EN BIT(17)
503+
#define MT_WL_RX_MPSZ_PAD0 BIT(18)
504+
#define MT_WL_RX_FLUSH BIT(19)
505+
#define MT_TICK_1US_EN BIT(20)
506+
#define MT_WL_RX_AGG_EN BIT(21)
507+
#define MT_WL_RX_EN BIT(22)
508+
#define MT_WL_TX_EN BIT(23)
509+
#define MT_WL_RX_BUSY BIT(30)
510+
#define MT_WL_TX_BUSY BIT(31)
511+
486512
#endif

0 commit comments

Comments
 (0)