forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mac80211: rt2x00: some experimental improvements
1. Increase the watchdog sampling frequency to avoid some unnecessary resets. 2. Always do calibration on MT7620 when switching channels. 3. Correct vgc value for MT7620 and only do gain calibration for supported devices. 4. Fix the clock cycle count reg value for MT7620. It uses the default fixed value 33. 5. Correct MT7620 SDM mode register. We expect to set the BIT(7) for this register. Signed-off-by: Shiji Yang <[email protected]>
- Loading branch information
1 parent
5702a45
commit 8b5e567
Showing
7 changed files
with
203 additions
and
20 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
.../kernel/mac80211/patches/rt2x00/620-rt2x00-increase-the-watchdog-sampling-frequency.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
@@ -1311,26 +1311,45 @@ static bool rt2800_watchdog_hung(struct | ||
return true; | ||
} | ||
|
||
+static inline bool check_dma_busy_rx(u32 reg_cfg, u32 reg_int) | ||
+{ | ||
+ return (rt2x00_get_field32(reg_cfg, WPDMA_GLO_CFG_RX_DMA_BUSY) && | ||
+ rt2x00_get_field32(reg_int, INT_SOURCE_CSR_RX_COHERENT)); | ||
+} | ||
+ | ||
+static inline bool check_dma_busy_tx(u32 reg_cfg, u32 reg_int) | ||
+{ | ||
+ return (rt2x00_get_field32(reg_cfg, WPDMA_GLO_CFG_TX_DMA_BUSY) && | ||
+ rt2x00_get_field32(reg_int, INT_SOURCE_CSR_TX_COHERENT)); | ||
+} | ||
+ | ||
static bool rt2800_watchdog_dma_busy(struct rt2x00_dev *rt2x00dev) | ||
{ | ||
bool busy_rx, busy_tx; | ||
u32 reg_cfg = rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG); | ||
u32 reg_int = rt2800_register_read(rt2x00dev, INT_SOURCE_CSR); | ||
|
||
- if (rt2x00_get_field32(reg_cfg, WPDMA_GLO_CFG_RX_DMA_BUSY) && | ||
- rt2x00_get_field32(reg_int, INT_SOURCE_CSR_RX_COHERENT)) | ||
- rt2x00dev->rxdma_busy++; | ||
- else | ||
- rt2x00dev->rxdma_busy = 0; | ||
- | ||
- if (rt2x00_get_field32(reg_cfg, WPDMA_GLO_CFG_TX_DMA_BUSY) && | ||
- rt2x00_get_field32(reg_int, INT_SOURCE_CSR_TX_COHERENT)) | ||
- rt2x00dev->txdma_busy++; | ||
- else | ||
- rt2x00dev->txdma_busy = 0; | ||
+ rt2x00dev->rxdma_busy = check_dma_busy_rx(reg_cfg, reg_int) ? | ||
+ rt2x00dev->rxdma_busy + 1 : 0; | ||
+ rt2x00dev->txdma_busy = check_dma_busy_tx(reg_cfg, reg_int) ? | ||
+ rt2x00dev->txdma_busy + 1 : 0; | ||
+ | ||
+ if (rt2x00dev->rxdma_busy > 25 || rt2x00dev->txdma_busy > 25) { | ||
+ int cnt; | ||
+ for (cnt = 0; cnt < 10; cnt++) { | ||
+ msleep(5); | ||
+ reg_cfg = rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG); | ||
+ reg_int = rt2800_register_read(rt2x00dev, INT_SOURCE_CSR); | ||
+ | ||
+ if (!check_dma_busy_rx(reg_cfg, reg_int)) | ||
+ rt2x00dev->rxdma_busy = 0; | ||
+ if (!check_dma_busy_tx(reg_cfg, reg_int)) | ||
+ rt2x00dev->txdma_busy = 0; | ||
+ } | ||
+ } | ||
|
||
- busy_rx = rt2x00dev->rxdma_busy > 30; | ||
- busy_tx = rt2x00dev->txdma_busy > 30; | ||
+ busy_rx = rt2x00dev->rxdma_busy > 40; | ||
+ busy_tx = rt2x00dev->txdma_busy > 40; | ||
|
||
if (!busy_rx && !busy_tx) | ||
return false; |
64 changes: 64 additions & 0 deletions
64
.../mac80211/patches/rt2x00/621-rt2x00-always-calibrate-MT7620-when-switching-channels.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
@@ -5695,6 +5695,9 @@ static void rt2800_config_ps(struct rt2x | ||
} | ||
} | ||
|
||
+static void rt2800_calibration_rt6352_stage1(struct rt2x00_dev *rt2x00dev); | ||
+static void rt2800_calibration_rt6352_stage2(struct rt2x00_dev *rt2x00dev); | ||
+ | ||
void rt2800_config(struct rt2x00_dev *rt2x00dev, | ||
struct rt2x00lib_conf *libconf, | ||
const unsigned int flags) | ||
@@ -5709,10 +5712,18 @@ void rt2800_config(struct rt2x00_dev *rt | ||
*/ | ||
rt2800_update_survey(rt2x00dev); | ||
|
||
+ if (rt2x00_rt(rt2x00dev, RT6352) && | ||
+ !test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) | ||
+ rt2800_calibration_rt6352_stage1(rt2x00dev); | ||
+ | ||
rt2800_config_channel(rt2x00dev, libconf->conf, | ||
&libconf->rf, &libconf->channel); | ||
rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, | ||
libconf->conf->power_level); | ||
+ | ||
+ if (rt2x00_rt(rt2x00dev, RT6352) && | ||
+ !test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) | ||
+ rt2800_calibration_rt6352_stage2(rt2x00dev); | ||
} | ||
if (flags & IEEE80211_CONF_CHANGE_POWER) | ||
rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, | ||
@@ -10418,15 +10429,19 @@ static void rt2800_restore_rf_bbp_rt6352 | ||
} | ||
} | ||
|
||
-static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev) | ||
+static void rt2800_calibration_rt6352_stage1(struct rt2x00_dev *rt2x00dev) | ||
{ | ||
- u32 reg; | ||
- | ||
if (rt2x00_has_cap_external_pa(rt2x00dev) || | ||
rt2x00_has_cap_external_lna_bg(rt2x00dev)) | ||
rt2800_restore_rf_bbp_rt6352(rt2x00dev); | ||
|
||
rt2800_r_calibration(rt2x00dev); | ||
+} | ||
+ | ||
+static void rt2800_calibration_rt6352_stage2(struct rt2x00_dev *rt2x00dev) | ||
+{ | ||
+ u32 reg; | ||
+ | ||
rt2800_rf_self_txdc_cal(rt2x00dev); | ||
rt2800_rxdcoc_calibration(rt2x00dev); | ||
rt2800_bw_filter_calibration(rt2x00dev, true); | ||
@@ -10757,9 +10772,6 @@ static void rt2800_init_rfcsr_6352(struc | ||
|
||
rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); | ||
rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C); | ||
- | ||
- /* Do calibration and init PA/LNA */ | ||
- rt2800_calibration_rt6352(rt2x00dev); | ||
} | ||
|
||
static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) |
35 changes: 35 additions & 0 deletions
35
package/kernel/mac80211/patches/rt2x00/622-rt2x00-rework-link-tuner-for-MT7620.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
@@ -5552,6 +5552,9 @@ static void rt2800_config_txpower(struct | ||
|
||
void rt2800_gain_calibration(struct rt2x00_dev *rt2x00dev) | ||
{ | ||
+ if (rt2x00_rt(rt2x00dev, RT6352)) | ||
+ return; | ||
+ | ||
rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, | ||
rt2x00dev->tx_power); | ||
} | ||
@@ -5764,9 +5767,10 @@ static u8 rt2800_get_default_vgc(struct | ||
rt2x00_rt(rt2x00dev, RT3593) || | ||
rt2x00_rt(rt2x00dev, RT5390) || | ||
rt2x00_rt(rt2x00dev, RT5392) || | ||
- rt2x00_rt(rt2x00dev, RT5592) || | ||
- rt2x00_rt(rt2x00dev, RT6352)) | ||
+ rt2x00_rt(rt2x00dev, RT5592)) | ||
vgc = 0x1c + (2 * rt2x00dev->lna_gain); | ||
+ else if(rt2x00_rt(rt2x00dev, RT6352)) | ||
+ vgc = 0x04 + (2 * rt2x00dev->lna_gain); | ||
else | ||
vgc = 0x2e + rt2x00dev->lna_gain; | ||
} else { /* 5GHZ band */ | ||
@@ -5819,7 +5823,8 @@ void rt2800_link_tuner(struct rt2x00_dev | ||
{ | ||
u8 vgc; | ||
|
||
- if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) | ||
+ if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C) || | ||
+ rt2x00_rt(rt2x00dev, RT6352)) | ||
return; | ||
|
||
/* When RSSI is better than a certain threshold, increase VGC |
12 changes: 12 additions & 0 deletions
12
package/kernel/mac80211/patches/rt2x00/623-rt2x00-correct-MT7620-clock-cycle-count.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
@@ -6305,7 +6305,8 @@ static int rt2800_init_registers(struct | ||
reg = rt2800_register_read(rt2x00dev, US_CYC_CNT); | ||
rt2x00_set_field32(®, US_CYC_CNT_CLOCK_CYCLE, 125); | ||
rt2800_register_write(rt2x00dev, US_CYC_CNT, reg); | ||
- } else if (rt2x00_is_soc(rt2x00dev)) { | ||
+ } else if (rt2x00_is_soc(rt2x00dev) && | ||
+ !rt2x00_rt(rt2x00dev, RT6352)) { | ||
struct clk *clk = clk_get_sys("bus", NULL); | ||
int rate; | ||
|
11 changes: 11 additions & 0 deletions
11
package/kernel/mac80211/patches/rt2x00/624-rt2x00-correct-MT7620-SDM-mode-reg.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | ||
@@ -3839,7 +3839,7 @@ static void rt2800_config_channel_rf7620 | ||
|
||
/* Default: XO=20MHz , SDM mode */ | ||
rfcsr = rt2800_rfcsr_read(rt2x00dev, 16); | ||
- rt2x00_set_field8(&rfcsr, RFCSR16_SDM_MODE_MT7620, 0x80); | ||
+ rt2x00_set_field8(&rfcsr, RFCSR16_SDM_MODE_MT7620, 4); | ||
rt2800_rfcsr_write(rt2x00dev, 16, rfcsr); | ||
|
||
rfcsr = rt2800_rfcsr_read(rt2x00dev, 21); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,9 +52,9 @@ Signed-off-by: Daniel Golle <[email protected]> | |
static const unsigned int rt2800_eeprom_map[EEPROM_WORD_COUNT] = { | ||
[EEPROM_CHIP_ID] = 0x0000, | ||
[EEPROM_VERSION] = 0x0001, | ||
@@ -10404,8 +10422,10 @@ static void rt2800_calibration_rt6352(st | ||
u32 reg; | ||
|
||
@@ -10438,8 +10456,10 @@ static void rt2800_restore_rf_bbp_rt6352 | ||
static void rt2800_calibration_rt6352_stage1(struct rt2x00_dev *rt2x00dev) | ||
{ | ||
if (rt2x00_has_cap_external_pa(rt2x00dev) || | ||
- rt2x00_has_cap_external_lna_bg(rt2x00dev)) | ||
+ rt2x00_has_cap_external_lna_bg(rt2x00dev)) { | ||
|
@@ -63,8 +63,8 @@ Signed-off-by: Daniel Golle <[email protected]> | |
+ } | ||
|
||
rt2800_r_calibration(rt2x00dev); | ||
rt2800_rf_self_txdc_cal(rt2x00dev); | ||
@@ -10423,6 +10443,8 @@ static void rt2800_calibration_rt6352(st | ||
} | ||
@@ -10463,6 +10483,8 @@ static void rt2800_calibration_rt6352_st | ||
!rt2x00_has_cap_external_lna_bg(rt2x00dev)) | ||
return; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters