From 32645cebe040bae0370c7671d5c72f26ac695111 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 27 Feb 2016 13:16:35 +0100 Subject: [PATCH] mt7603: control wtbl powersave mode flag in software Signed-off-by: Felix Fietkau --- mt7603.h | 1 + mt7603_mac.c | 12 +++++++++++- mt7603_main.c | 4 ++++ mt7603_regs.h | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mt7603.h b/mt7603.h index e89f48c9..2fb90a34 100644 --- a/mt7603.h +++ b/mt7603.h @@ -198,6 +198,7 @@ void mt7603_wtbl_update_cap(struct mt7603_dev *dev, struct ieee80211_sta *sta); void mt7603_wtbl_set_rates(struct mt7603_dev *dev, struct mt7603_sta *sta); int mt7603_wtbl_set_key(struct mt7603_dev *dev, int wcid, struct ieee80211_key_conf *key); +void mt7603_wtbl_set_ps(struct mt7603_dev *dev, int idx, bool val); int mt7603_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct sk_buff *skb, struct mt76_queue *q, diff --git a/mt7603_mac.c b/mt7603_mac.c index 81566652..a52c628e 100644 --- a/mt7603_mac.c +++ b/mt7603_mac.c @@ -131,6 +131,15 @@ void mt7603_wtbl_init(struct mt7603_dev *dev, int idx, const u8 *mac_addr) mt76_wr(dev, addr + i, 0); } +void mt7603_wtbl_set_ps(struct mt7603_dev *dev, int idx, bool val) +{ + u32 addr = mt7603_wtbl1_addr(idx); + + mt76_set(dev, MT_WTBL1_OR, MT_WTBL1_OR_PSM_WRITE); + mt76_rmw_field(dev, addr + 3 * 4, MT_WTBL1_W3_POWER_SAVE, val); + mt76_clear(dev, MT_WTBL1_OR, MT_WTBL1_OR_PSM_WRITE); +} + void mt7603_wtbl_clear(struct mt7603_dev *dev, int idx) { int wtbl2_frame_size = MT_PSE_PAGE_SIZE / MT_WTBL2_SIZE; @@ -162,7 +171,8 @@ void mt7603_wtbl_clear(struct mt7603_dev *dev, int idx) 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_SET(MT_WTBL1_W3_WTBL4_FRAME_ID, wtbl4_frame) | + MT_WTBL1_W3_I_PSM | MT_WTBL1_W3_KEEP_I_PSM); 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) | diff --git a/mt7603_main.c b/mt7603_main.c index 6dab38cc..11b42307 100644 --- a/mt7603_main.c +++ b/mt7603_main.c @@ -295,12 +295,16 @@ mt7603_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum sta_notify_cmd cmd, struct ieee80211_sta *sta) { struct mt7603_dev *dev = hw->priv; + struct mt7603_sta *msta = (struct mt7603_sta *) sta->drv_priv; + int idx = msta->wcid.idx; switch (cmd) { case STA_NOTIFY_SLEEP: + mt7603_wtbl_set_ps(dev, idx, true); mt76_stop_tx_queues(&dev->mt76, sta); break; case STA_NOTIFY_AWAKE: + mt7603_wtbl_set_ps(dev, idx, false); break; } } diff --git a/mt7603_regs.h b/mt7603_regs.h index 6ba06989..53198413 100644 --- a/mt7603_regs.h +++ b/mt7603_regs.h @@ -538,7 +538,7 @@ enum { #define MT_WTBL1_W3_WTBL2_ENTRY_ID GENMASK(15, 11) #define MT_WTBL1_W3_WTBL4_FRAME_ID GENMASK(26, 16) #define MT_WTBL1_W3_CHECK_PER BIT(27) -#define MT_WTBL1_W3_UPDATE_I_PSM BIT(28) +#define MT_WTBL1_W3_KEEP_I_PSM BIT(28) #define MT_WTBL1_W3_I_PSM BIT(29) #define MT_WTBL1_W3_POWER_SAVE BIT(30) #define MT_WTBL1_W3_SKIP_TX BIT(31)