From 85d873df16262f393fdccc09dd2500d4956af704 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 20 Feb 2016 20:16:23 +0100 Subject: [PATCH] mt7603: fix wtbl3/4 offsets Signed-off-by: Felix Fietkau --- mt7603_mac.c | 18 ++++++++++++------ mt7603_regs.h | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/mt7603_mac.c b/mt7603_mac.c index f18c07e5..6f0b88a8 100644 --- a/mt7603_mac.c +++ b/mt7603_mac.c @@ -106,12 +106,18 @@ void mt7603_wtbl_init(struct mt7603_dev *dev, int idx, const u8 *mac_addr) 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; + int wtbl2_offset = idx * MT_WTBL2_SIZE; + int wtbl2_frame = wtbl2_offset / MT_PSE_PAGE_SIZE; + int wtbl2_entry = wtbl2_offset % MT_PSE_PAGE_SIZE; + + int wtbl3_offset = idx * MT_WTBL3_SIZE + MT_WTBL3_OFFSET; + int wtbl3_frame = wtbl3_offset / MT_PSE_PAGE_SIZE; + int wtbl3_entry = (wtbl3_offset % MT_PSE_PAGE_SIZE) * 2; + + int wtbl4_offset = idx * MT_WTBL4_SIZE + MT_WTBL4_OFFSET; + int wtbl4_frame = wtbl4_offset / MT_PSE_PAGE_SIZE; + int wtbl4_entry = wtbl4_offset % MT_PSE_PAGE_SIZE; + u32 addr = MT_WTBL1_BASE + idx * MT_WTBL1_SIZE; int i; diff --git a/mt7603_regs.h b/mt7603_regs.h index e51da8c0..b6028578 100644 --- a/mt7603_regs.h +++ b/mt7603_regs.h @@ -349,7 +349,10 @@ #define MT_WTBL1_SIZE (8 * 4) #define MT_WTBL2_SIZE (16 * 4) +#define MT_WTBL3_OFFSET (MT7603_WTBL_SIZE * MT_WTBL2_SIZE) #define MT_WTBL3_SIZE (16 * 4) +#define MT_WTBL4_OFFSET (MT7603_WTBL_SIZE * MT_WTBL3_SIZE + \ + MT_WTBL3_OFFSET) #define MT_WTBL4_SIZE (8 * 4) #define MT_WTBL1_W0_ADDR_HI GENMASK(15, 0)