mac80211: rt2x00: add support for MT7620
PATCH 1/1 mac80211: rt2x00: add support for MT7620
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
--- drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +- drivers/net/wireless/ralink/rt2x00/rt2800.h | 150 ++++ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1081 +++++++++++++++++++++++- 3 files changed, 1209 insertions(+), 24 deletions(-)
drivers/net/wireless/ralink/rt2x00/Kconfig +1 -1
@@ -201,7 +201,7 @@ endif config RT2800SOC tristate "Ralink WiSoC support" - depends on SOC_RT288X || SOC_RT305X + depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 select RT2X00_LIB_SOC select RT2X00_LIB_MMIO select RT2X00_LIB_CRYPTO
drivers/net/wireless/ralink/rt2x00/rt2800.h +150 -0
240 lines not on this page · raw message
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +1058 -23
1,256 lines not on this page · raw message
Signature · 1 line
2.11.1
Hi
Please remove mac80211 from the topic, this is not mac80211 patch.
drivers/net/wireless/ralink/rt2x00/rt2800lib.c void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev, · line 601
Quoted 13 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +9
-0@@ -523,6 +590,16 @@ void rt2800_get_txwi_rxwi_size(struct rt2x00_dev *rt2x00dev, *rxwi_size =RXWI_DESC_SIZE_5WORDS ;break ; +case RT5390 : +if (rt2x00_rf (rt2x00dev,RF7620 )) { + *txwi_size =TXWI_DESC_SIZE_5WORDS ; + *rxwi_size =RXWI_DESC_SIZE_6WORDS ; + }else { + *txwi_size =TXWI_DESC_SIZE_4WORDS ; + *rxwi_size =RXWI_DESC_SIZE_4WORDS ; + } +break ;
TXWI, RXWI sizes are not RF chipset properties. Similar like vendor driver please introduce RT6352 (set chip.rt = RT6352 on init) and use it when need to identify RT chip instead of mixing RT checks and RF checks. There are few places below where this need to be changed, I pointed some but not all.
BTW, I wondered where all this low level settings came from until I realized that vendor driver use RT6352 name, that was confusing.
Quoted 33 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +33
-0+if (!test_bit (DEVICE_STATE_SCANNING , &rt2x00dev->flags)) { +if (conf_is_ht40 (conf)) { + txrx_agc_fc =rt2x00_get_field8 ( + drv_data->calibration_bw40, +RFCSR24_TX_AGC_FC ); + }else { + txrx_agc_fc =rt2x00_get_field8 ( + drv_data->calibration_bw20, +RFCSR24_TX_AGC_FC ); + } +rt2800_rfcsr_read_bank (rt2x00dev,5 ,6 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,5 ,6 , rfcsr); +rt2800_rfcsr_read_bank (rt2x00dev,5 ,7 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,5 ,7 , rfcsr); +rt2800_rfcsr_read_bank (rt2x00dev,7 ,6 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,7 ,6 , rfcsr); +rt2800_rfcsr_read_bank (rt2x00dev,7 ,7 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,7 ,7 , rfcsr); + +rt2800_rfcsr_read_bank (rt2x00dev,5 ,58 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,5 ,58 , rfcsr); +rt2800_rfcsr_read_bank (rt2x00dev,5 ,59 , &rfcsr); + rfcsr &= (~0x3F );
drivers/net/wireless/ralink/rt2x00/rt2800lib.c static void rt2800_config_channel_rf55xx(struct rt2x00_dev *rt2x00dev, · line 3355
Quoted 10 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +10
-0+ rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,5 ,59 , rfcsr); +rt2800_rfcsr_read_bank (rt2x00dev,7 ,58 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,7 ,58 , rfcsr); +rt2800_rfcsr_read_bank (rt2x00dev,7 ,59 , &rfcsr); + rfcsr &= (~0x3F ); + rfcsr |= txrx_agc_fc; +rt2800_rfcsr_write_bank (rt2x00dev,7 ,59 , rfcsr);
Vendor driver make this quite different. It use different procedure on initialization than we do rt2800_init_rx_filter and use different values for TX and RX. See BW_Filter_Calibration() and RT6352_ChipSwitchChannel().
For now we can apply this, but need to be fixed in the future.
drivers/net/wireless/ralink/rt2x00/rt2800lib.c static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, · line 3723
Quoted 2 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +1
-1- tx_pin =0 ; +rt2800_register_read (rt2x00dev,TX_PIN_CFG , &tx_pin);
I think this will not cause problems on other chipsets, but I would be careful here. Having tx_pin = 0 is a problem for MT7620 ?
drivers/net/wireless/ralink/rt2x00/rt2800lib.c static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, · line 3832
Quoted 3 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +2
-1-if (rt2x00_rt (rt2x00dev,RT5592 )) { +if (rt2x00_rt (rt2x00dev,RT5592 ) || + (rt2x00_rt (rt2x00dev,RT5390 ) &&rt2x00_rf (rt2x00dev,RF7620 ))) {
if (rt2x00_rt(rt2x00dev, RT5592) ||
rt2x00_rt(rt2x00dev, RT6352)) {drivers/net/wireless/ralink/rt2x00/rt2800lib.c static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev, · line 4838
Quoted 2 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +2
-0+else if (rt2x00_rf (rt2x00dev,RF7620 )) +rt2800_config_txpower_mt7620 (rt2x00dev, chan, power_level);
else if (rt2x00_rt(rt2x00dev, RT6352)) rt2800_config_txpower_rt6352(rt2x00dev, chan, power_level);
drivers/net/wireless/ralink/rt2x00/rt2800lib.c static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) · line 6569
Quoted 4 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +1
-1case RT5390 :case RT5392 : -rt2800_init_bbp_53xx (rt2x00dev); +if (rt2x00_rf (rt2x00dev,RF7620 ))
case RT6352:
Quoted 7 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +7
-0+static const struct rf_channel rf_vals_7620[] = { +/* Channel, Rdiv, N, K | (D >> 8), Ksd */ + {1 ,3 ,0x50 ,0 | (0 >>8 ),0x19999 }, + {2 ,3 ,0x50 ,0 | (0 >>8 ),0x24444 }, + {3 ,3 ,0x50 ,0 | (0 >>8 ),0x2EEEE }, + {4 ,3 ,0x50 ,0 | (0 >>8 ),0x39999 }, + {5 ,3 ,0x51 ,0 | (0 >>8 ),0x04444 },
drivers/net/wireless/ralink/rt2x00/rt2800lib.c static const struct rf_channel rf_vals_5592_xtal40[] = { · line 8776
Quoted 10 lines
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +10
-0+ {6, 3, 0x51, 0 | (0 >> 8), 0x0EEEE}, + {7, 3, 0x51, 0 | (0 >> 8), 0x19999}, + {8, 3, 0x51, 0 | (0 >> 8), 0x24444}, + {9, 3, 0x51, 0 | (0 >> 8), 0x2EEEE}, + {10, 3, 0x51, 0 | (0 >> 8), 0x39999}, + {11, 3, 0x52, 0 | (0 >> 8), 0x04444}, + {12, 3, 0x52, 0 | (0 >> 8), 0x0EEEE}, + {13, 3, 0x52, 0 | (0 >> 8), 0x19999}, + {14, 3, 0x52, 0 | (0 >> 8), 0x33333}, +};
It should D << 8, but it does not matter since values are 0. You can just remove those from rf_vals and use 0 for K & D on rt2800_config_channel_rf7620().
Stanislaw
PATCH 1/1 mac80211: rt2x00: add support for MT7620
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
---
v2: added RT6352 instead of checking against RF7620
cleaned up rf_vals_7620 and channel switching cargo-cult ported bandwidth filter calibration (feels fishy, but works)
fixed some typos in the comments
tx_pin should only be modified as higher bits contain setting polarity for external LNA and PA which should not be reset. If you believe it would cause regressions, let's only read it for RT6352 and set it to 0 for all other chips.
drivers/net/wireless/ralink/rt2x00/Kconfig | 2 +- drivers/net/wireless/ralink/rt2x00/rt2800.h | 177 +++ drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 1421 +++++++++++++++++++++++- drivers/net/wireless/ralink/rt2x00/rt2800lib.h | 4 + drivers/net/wireless/ralink/rt2x00/rt2x00.h | 1 + 5 files changed, 1578 insertions(+), 27 deletions(-)
drivers/net/wireless/ralink/rt2x00/Kconfig +1 -1
@@ -201,7 +201,7 @@ endif config RT2800SOC tristate "Ralink WiSoC support" - depends on SOC_RT288X || SOC_RT305X + depends on SOC_RT288X || SOC_RT305X || SOC_MT7620 select RT2X00_LIB_SOC select RT2X00_LIB_MMIO select RT2X00_LIB_CRYPTO
drivers/net/wireless/ralink/rt2x00/rt2800.h +177 -0
319 lines not on this page · raw message
drivers/net/wireless/ralink/rt2x00/rt2800lib.c +1395 -26
1,632 lines not on this page · raw message
drivers/net/wireless/ralink/rt2x00/rt2800lib.h +4 -0
@@ -33,6 +33,10 @@struct rt2800_drv_data {u8 calibration_bw20;u8 calibration_bw40; +char rx_calibration_bw20; +char rx_calibration_bw40; +char tx_calibration_bw20; +char tx_calibration_bw40;u8 bbp25;u8 bbp26;u8 txmixer_gain_24g;
drivers/net/wireless/ralink/rt2x00/rt2x00.h +1 -0
@@ -174,6 +174,7 @@ struct rt2x00_chip {#define RT5390 0x5390/* 2.4GHz */ #define RT5392 0x5392/* 2.4GHz */ #define RT5592 0x5592 +#define RT6352 0x6352/* WSOC 2.4GHz */ u16 rf;u16 rev;
Signature · 1 line
2.11.1
Hi again!
Quoted 9 lines · Daniel Golle
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
Signed-off-by Roman Yeryomin <[email protected]>Signed-off-by Daniel Golle <[email protected]>---
Binaries for testing have been generated by LEDE's buildbot. Download a build for your MT7620 board and try the updated patch
https://downloads.lede-project.org/snapshots/targets/ramips/mt7620/
(it's easy to recognize the updated patch because the chip is now detected as RT6352 rather than RT5390)
Cheers
Daniel
Quoted 8 lines · Daniel Golle
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
Signed-off-by Roman Yeryomin <[email protected]>Signed-off-by Daniel Golle <[email protected]>
Good job!
Quoted 4 lines
tx_pinshould only be modified as higher bits contain setting polarity for external LNA and PA which should not be reset. If you believe it would cause regressions, let's only read it for RT6352 and set it to 0 for all other chips.
I checked patch on various RTxxxx USB devices and do not find any regression, beside this was also tested with OpenWRT on various SOCs, so I think it is ok
Thanks
Stanislaw
Quoted 9 lines · Daniel Golle
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
Signed-off-by Roman Yeryomin <[email protected]>Signed-off-by Daniel Golle <[email protected]>
I'll remove the "mac80211:" prefix during commit, that should be only used with mac80211 patches.
Signature · 6 lines
https://patchwork.kernel.org/patch/9618995/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Kalle Valo
Quoted 6 lines · Daniel Golle
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
Quoted 6 lines
Quoted 3 lines
Signed-off-by Roman Yeryomin <[email protected]>Signed-off-by Daniel Golle <[email protected]>I'll remove the "mac80211:" prefix during commit, that should be only used with mac80211 patches.
Thanks, I forgot about changing the subject line for v2. Also make sure that https://patchwork.kernel.org/patch/9612163/ gets applied before this one, because it doesn't apply cleanly otherwise.
Quoted 9 lines
Signature · 7 lines
-- https://patchwork.kernel.org/patch/9618995/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: rt2x00: add support for MT7620
In reply to Daniel GolleQuoted 9 lines · Daniel Golle
From: Roman Yeryomin <[email protected]>
Basic support for MT7620 built-in wireless radio was added to OpenWrt in r41441. It has seen some heavy cleaning and refactoring since in order to match the Kernel's code quality standards.
Signed-off-by Roman Yeryomin <[email protected]>Signed-off-by Daniel Golle <[email protected]>
Failed to apply even if I had the dependency patch already applied:
error: Failed to merge in the changes.
Applying: rt2x00: add support for MT7620
Using index info to reconstruct a base tree...
M drivers/net/wireless/ralink/rt2x00/rt2800.h
Falling back to patching base and 3-way merge...
Auto-merging drivers/net/wireless/ralink/rt2x00/rt2800.h
CONFLICT (content): Merge conflict in drivers/net/wireless/ralink/rt2x00/rt2800.h Patch failed at 0001 rt2x00: add support for MT7620
The copy of the patch that failed is found in: .git/rebase-apply/patch
Patch set to Changes Requested.
Signature · 6 lines
https://patchwork.kernel.org/patch/9618995/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches