rt2x00: RT3572 fixes.
cover rt2x00: RT3572 fixes.
This patch series contains some general clean-ups and a series of fixes to the RT3572 channel switching code inside rt2800pci and rt2800usb. These fixes are based on the v2.5.0.0 version of the RT3572 Ralink driver and bring rt2x00 closer to that driver with respect to channel switching.
With these changes the performance seems to be enhanced as I can measure over 100 Mbps as raw network speed.
Gertjan van Wingerde (9):
rt2x00: Introduce concept of driver data in struct rt2x00_dev.
rt2x00: Use struct rt2x00_dev driver data in rt2800{pci,usb}.
rt2x00: Update comment on freq_offset field in struct rt2x00_dev.
rt2x00: Use saved BBP 25 and 26 values when configuring channel on
RT3572.
rt2x00: Fix RFCSR 12 & 13 programming on RT3572 channel switching.
rt2x00: Align RT3572 channel switch RFCSR 1 programming with Ralink
driver.
rt2x00: Fix RT3572 channel switch RFCSR 7 programming.
rt2x00: Correctly set txmixer_gain in RT3572 channel switching.
rt2x00: Add support for RT3593 devices.
drivers/net/wireless/rt2x00/rt2800.h | 33 +++++++++- drivers/net/wireless/rt2x00/rt2800lib.c | 102 ++++++++++++++++++++++--------- drivers/net/wireless/rt2x00/rt2800pci.c | 1 + drivers/net/wireless/rt2x00/rt2800usb.c | 1 + drivers/net/wireless/rt2x00/rt2x00.h | 15 ++--- drivers/net/wireless/rt2x00/rt2x00dev.c | 18 ++++++ 6 files changed, 130 insertions(+), 40 deletions(-)
Signature · 1 line
1.7.9
PATCH 7/8 rt2x00: Fix RT3572 channel switch RFCSR 7 programming.
In reply to Gertjan van WingerdeAlign with the v2.5.0.0 Ralink RT3572 driver.
drivers/net/wireless/rt2x00/rt2800.h +6 -4
@@ -1819,10 +1819,12 @@ struct mac_iveiv_entry {* RFCSR 7: */ #define RFCSR7_RF_TUNING FIELD8(0x01) -#define RFCSR7_R02 FIELD8(0x07) -#define RFCSR7_R3 FIELD8(0x08) -#define RFCSR7_R45 FIELD8(0x30) -#define RFCSR7_R67 FIELD8(0xc0) +#define RFCSR7_BIT1 FIELD8(0x02) +#define RFCSR7_BIT2 FIELD8(0x04) +#define RFCSR7_BIT3 FIELD8(0x08) +#define RFCSR7_BIT4 FIELD8(0x10) +#define RFCSR7_BIT5 FIELD8(0x20) +#define RFCSR7_BITS67 FIELD8(0xc0)/* * RFCSR 11:
drivers/net/wireless/rt2x00/rt2800lib.c +6 -1
@@ -1865,7 +1865,12 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,rt2800_rfcsr_write (rt2x00dev,27 ,0x00 );rt2800_rfcsr_write (rt2x00dev,29 ,0x9b ); }else { -rt2800_rfcsr_write (rt2x00dev,7 ,0x14 ); +rt2800_rfcsr_read (rt2x00dev,7 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR7_BIT2 ,1 ); +rt2x00_set_field8 (&rfcsr,RFCSR7_BIT3 ,0 ); +rt2x00_set_field8 (&rfcsr,RFCSR7_BIT4 ,1 ); +rt2x00_set_field8 (&rfcsr,RFCSR7_BITS67 ,0 ); +rt2800_rfcsr_write (rt2x00dev,7 , rfcsr);rt2800_rfcsr_write (rt2x00dev,9 ,0xc0 );rt2800_rfcsr_write (rt2x00dev,10 ,0xf1 );rt2800_rfcsr_write (rt2x00dev,11 ,0x00 );
Signature · 1 line
1.7.9
PATCH 2/8 rt2x00: Use struct rt2x00_dev driver data in rt2800{pci,usb}.
In reply to Gertjan van WingerdeStart using the struct rt2x00_dev driver data in rt2800 for the calibration data.
drivers/net/wireless/rt2x00/rt2800.h +8 -0
@@ -2438,4 +2438,12 @@ struct mac_iveiv_entry {*/ #define EIRP_MAX_TX_POWER_LIMIT 0x50 +/* +* RT2800 driver data structure +*/ +struct rt2800_drv_data { +u8 calibration_bw20; +u8 calibration_bw40; +}; +#endif /* RT2800_H */
drivers/net/wireless/rt2x00/rt2800lib.c +21 -10
@@ -1645,6 +1645,7 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev,struct rf_channel *rf, struct channel_info *info) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;u8 rfcsr, calib_tx, calib_rx;rt2800_rfcsr_write (rt2x00dev,2 , rf->rf1);
@@ -1714,8 +1715,13 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, calib_tx =conf_is_ht40 (conf) ?0x68 :0x4f ; calib_rx =conf_is_ht40 (conf) ?0x6f :0x4f ; }else { - calib_tx = rt2x00dev->calibration[conf_is_ht40 (conf)]; - calib_rx = rt2x00dev->calibration[conf_is_ht40 (conf)]; +if (conf_is_ht40 (conf)) { + calib_tx = drv_data->calibration_bw40; + calib_rx = drv_data->calibration_bw40; + }else { + calib_tx = drv_data->calibration_bw20; + calib_rx = drv_data->calibration_bw20; + } }rt2800_rfcsr_read (rt2x00dev,24 , &rfcsr);
@@ -1743,6 +1749,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,struct rf_channel *rf, struct channel_info *info) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;u8 rfcsr;u32 reg;
@@ -1836,10 +1843,13 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,rt2x00_set_field8 (&rfcsr,RFCSR23_FREQ_OFFSET , rt2x00dev->freq_offset);rt2800_rfcsr_write (rt2x00dev,23 , rfcsr); -rt2800_rfcsr_write (rt2x00dev,24 , - rt2x00dev->calibration[conf_is_ht40 (conf)]); -rt2800_rfcsr_write (rt2x00dev,31 , - rt2x00dev->calibration[conf_is_ht40 (conf)]); +if (conf_is_ht40 (conf)) { +rt2800_rfcsr_write (rt2x00dev,24 , drv_data->calibration_bw40); +rt2800_rfcsr_write (rt2x00dev,31 , drv_data->calibration_bw40); + }else { +rt2800_rfcsr_write (rt2x00dev,24 , drv_data->calibration_bw20); +rt2800_rfcsr_write (rt2x00dev,31 , drv_data->calibration_bw20); + }if (rf->channel <=14 ) {rt2800_rfcsr_write (rt2x00dev,7 ,0xd8 );
@@ -3310,6 +3320,7 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,static int rt2800_init_rfcsr (struct rt2x00_dev *rt2x00dev) { +struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;u8 rfcsr;u8 bbp;u32 reg;
@@ -3598,17 +3609,17 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)* Set RX Filter calibration for 20MHz and 40MHz */ if (rt2x00_rt (rt2x00dev,RT3070 )) { - rt2x00dev->calibration[0 ] = + drv_data->calibration_bw20 =rt2800_init_rx_filter (rt2x00dev, false,0x07 ,0x16 ); - rt2x00dev->calibration[1 ] = + drv_data->calibration_bw40 =rt2800_init_rx_filter (rt2x00dev, true,0x27 ,0x19 ); }else if (rt2x00_rt (rt2x00dev,RT3071 ) ||rt2x00_rt (rt2x00dev,RT3090 ) ||rt2x00_rt (rt2x00dev,RT3390 ) ||rt2x00_rt (rt2x00dev,RT3572 )) { - rt2x00dev->calibration[0 ] = + drv_data->calibration_bw20 =rt2800_init_rx_filter (rt2x00dev, false,0x07 ,0x13 ); - rt2x00dev->calibration[1 ] = + drv_data->calibration_bw40 =rt2800_init_rx_filter (rt2x00dev, true,0x27 ,0x15 ); }
drivers/net/wireless/rt2x00/rt2800pci.c +1 -0
@@ -1093,6 +1093,7 @@ static const struct data_queue_desc rt2800pci_queue_bcn = {static const struct rt2x00_ops rt2800pci_ops = { .name =KBUILD_MODNAME , + .drv_data_size =sizeof (struct rt2800_drv_data ), .max_sta_intf =1 , .max_ap_intf =8 , .eeprom_size =EEPROM_SIZE ,
drivers/net/wireless/rt2x00/rt2800usb.c +1 -0
@@ -827,6 +827,7 @@ static const struct data_queue_desc rt2800usb_queue_bcn = {static const struct rt2x00_ops rt2800usb_ops = { .name =KBUILD_MODNAME , + .drv_data_size =sizeof (struct rt2800_drv_data ), .max_sta_intf =1 , .max_ap_intf =8 , .eeprom_size =EEPROM_SIZE ,
drivers/net/wireless/rt2x00/rt2x00.h +0 -7
@@ -897,13 +897,6 @@ struct rt2x00_dev {u8 freq_offset;/* -* Calibration information (for rt2800usb & rt2800pci). -* [0] -> BW20 -* [1] -> BW40 -*/ -u8 calibration[2 ]; - -/* * Association id. */ u16 aid;
Signature · 1 line
1.7.9
PATCH 3/8 rt2x00: Update comment on freq_offset field in struct rt2x00_dev.
The comment states that the field is only used for rt61pci and rt73usb. However, it is now used by rt2800pci and rt2800usb as well, so the comment is not correct anymore.
Update the comment to not state any low-level drivers anymore.
drivers/net/wireless/rt2x00/rt2x00.h +1 -1
@@ -892,7 +892,7 @@ struct rt2x00_dev {u8 rssi_offset;/* -* Frequency offset (for rt61pci & rt73usb). +* Frequency offset. */ u8 freq_offset;
Signature · 1 line
1.7.9
PATCH 5/8 rt2x00: Fix RFCSR 12 & 13 programming on RT3572 channel switching.
In reply to Gertjan van WingerdeAlign with v2.5.0.0 Ralink RT3572 driver for 2.4GHz band channel switch.
drivers/net/wireless/rt2x00/rt2800lib.c +2 -4
@@ -1783,8 +1783,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,if (rf->channel <=14 ) {rt2x00_set_field8 (&rfcsr,RFCSR12_DR0 ,3 );rt2x00_set_field8 (&rfcsr,RFCSR12_TX_POWER , - (info->default_power1 &0x3 ) | - ((info->default_power1 &0xC ) <<1 )); + info->default_power1); }else {rt2x00_set_field8 (&rfcsr,RFCSR12_DR0 ,7 ); rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER,
@@ -1797,8 +1796,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,if (rf->channel <=14 ) {rt2x00_set_field8 (&rfcsr,RFCSR13_DR0 ,3 );rt2x00_set_field8 (&rfcsr,RFCSR13_TX_POWER , - (info->default_power2 &0x3 ) | - ((info->default_power2 &0xC ) <<1 )); + info->default_power2); }else {rt2x00_set_field8 (&rfcsr,RFCSR13_DR0 ,7 ); rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER,
Signature · 1 line
1.7.9
PATCH 8/8 rt2x00: Correctly set txmixer_gain in RT3572 channel switching.
In reply to Gertjan van WingerdeAlign with the v2.5.0.0 Ralink RT3572 driver.
Save the EEPROM txmixer_gain values inside the rt2800 driver data structure and use it throughout the code.
drivers/net/wireless/rt2x00/rt2800.h +13 -0
@@ -1849,6 +1849,11 @@ struct mac_iveiv_entry {#define RFCSR15_TX_LO2_EN FIELD8(0x08)/* +* RFCSR 16: +*/ +#define RFCSR16_TXMIXER_GAIN FIELD8(0x07) + +/* * RFCSR 17: */ #define RFCSR17_TXMIXER_GAIN FIELD8(0x07)
@@ -2111,6 +2116,12 @@ struct mac_iveiv_entry {#define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00)/* +* EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2). +*/ +#define EEPROM_TXMIXER_GAIN_A 0x0026 +#define EEPROM_TXMIXER_GAIN_A_VAL FIELD16(0x0007) + +/* * EEPROM EIRP Maximum TX power values(unit: dbm) */ #define EEPROM_EIRP_MAX_TX_POWER 0x0027
@@ -2448,6 +2459,8 @@ struct rt2800_drv_data {u8 calibration_bw40;u8 bbp25;u8 bbp26; +u8 txmixer_gain_24g; + u8 txmixer_gain_5g; };#endif /* RT2800_H */
drivers/net/wireless/rt2x00/rt2800lib.c +27 -7
@@ -1856,7 +1856,10 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,rt2800_rfcsr_write (rt2x00dev,10 ,0xf1 );rt2800_rfcsr_write (rt2x00dev,11 ,0xb9 );rt2800_rfcsr_write (rt2x00dev,15 ,0x53 ); -rt2800_rfcsr_write (rt2x00dev,16 ,0x4c ); + rfcsr =0x4c ; +rt2x00_set_field8 (&rfcsr,RFCSR16_TXMIXER_GAIN , + drv_data->txmixer_gain_24g); +rt2800_rfcsr_write (rt2x00dev,16 , rfcsr);rt2800_rfcsr_write (rt2x00dev,17 ,0x23 );rt2800_rfcsr_write (rt2x00dev,19 ,0x93 );rt2800_rfcsr_write (rt2x00dev,20 ,0xb3 );
@@ -1875,7 +1878,10 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,rt2800_rfcsr_write (rt2x00dev,10 ,0xf1 );rt2800_rfcsr_write (rt2x00dev,11 ,0x00 );rt2800_rfcsr_write (rt2x00dev,15 ,0x43 ); -rt2800_rfcsr_write (rt2x00dev,16 ,0x7a ); + rfcsr =0x7a ; +rt2x00_set_field8 (&rfcsr,RFCSR16_TXMIXER_GAIN , + drv_data->txmixer_gain_5g); +rt2800_rfcsr_write (rt2x00dev,16 , rfcsr);rt2800_rfcsr_write (rt2x00dev,17 ,0x23 );if (rf->channel <=64 ) {rt2800_rfcsr_write (rt2x00dev,19 ,0xb7 );
@@ -3672,11 +3678,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) &rt2x00dev->cap_flags))rt2x00_set_field8 (&rfcsr,RFCSR17_R ,1 ); } -rt2x00_eeprom_read (rt2x00dev,EEPROM_TXMIXER_GAIN_BG , &eeprom); -if (rt2x00_get_field16 (eeprom,EEPROM_TXMIXER_GAIN_BG_VAL ) >=1 ) -rt2x00_set_field8 (&rfcsr,RFCSR17_TXMIXER_GAIN , -rt2x00_get_field16 (eeprom, -EEPROM_TXMIXER_GAIN_BG_VAL )); +rt2x00_set_field8 (&rfcsr,RFCSR17_TXMIXER_GAIN , + drv_data->txmixer_gain_24g);rt2800_rfcsr_write (rt2x00dev,17 , rfcsr); }
@@ -3884,6 +3887,7 @@ EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);int rt2800_validate_eeprom (struct rt2x00_dev *rt2x00dev) { +struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;u16 word;u8 *mac;u8 default_lna_gain;
@@ -3967,6 +3971,14 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)rt2x00_set_field16 (&word,EEPROM_RSSI_BG_OFFSET1 ,0 );rt2x00_eeprom_write (rt2x00dev,EEPROM_RSSI_BG , word); +rt2x00_eeprom_read (rt2x00dev,EEPROM_TXMIXER_GAIN_BG , &word); +if ((word &0x00ff ) !=0x00ff ) { + drv_data->txmixer_gain_24g = +rt2x00_get_field16 (word,EEPROM_TXMIXER_GAIN_BG_VAL ); + }else { + drv_data->txmixer_gain_24g =0 ; + } +rt2x00_eeprom_read (rt2x00dev,EEPROM_RSSI_BG2 , &word);if (abs (rt2x00_get_field16 (word,EEPROM_RSSI_BG2_OFFSET2 )) >10 )rt2x00_set_field16 (&word,EEPROM_RSSI_BG2_OFFSET2 ,0 );
@@ -3976,6 +3988,14 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) default_lna_gain);rt2x00_eeprom_write (rt2x00dev,EEPROM_RSSI_BG2 , word); +rt2x00_eeprom_read (rt2x00dev,EEPROM_TXMIXER_GAIN_A , &word); +if ((word &0x00ff ) !=0x00ff ) { + drv_data->txmixer_gain_5g = +rt2x00_get_field16 (word,EEPROM_TXMIXER_GAIN_A_VAL ); + }else { + drv_data->txmixer_gain_5g =0 ; + } +rt2x00_eeprom_read (rt2x00dev,EEPROM_RSSI_A , &word);if (abs (rt2x00_get_field16 (word,EEPROM_RSSI_A_OFFSET0 )) >10 )rt2x00_set_field16 (&word,EEPROM_RSSI_A_OFFSET0 ,0 );
Signature · 1 line
1.7.9
PATCH 1/8 rt2x00: Introduce concept of driver data in struct rt2x00_dev.
In reply to Gertjan van WingerdeWe are getting more and more fields in struct rt2x00_dev that are specific to one or two of the low-level drivers. Instead of putting these fields inside the main structure and thus clobbering all low-level drivers with these fields, introduce the concept of driver data inside struct rt2x00_dev, whose size is indicated by the low-level driver and which can be populated by the low-level driver.
drivers/net/wireless/rt2x00/rt2x00.h +6 -0
@@ -647,6 +647,7 @@ struct rt2x00lib_ops {*/ struct rt2x00_ops {const char *name; +const unsigned int drv_data_size;const unsigned int max_sta_intf;const unsigned int max_ap_intf;const unsigned int eeprom_size;
@@ -742,6 +743,11 @@ struct rt2x00_dev {const struct rt2x00_ops *ops;/* +* Driver data. +*/ +void *drv_data; + +/* * IEEE80211 control structure. */ struct ieee80211_hw *hw;
drivers/net/wireless/rt2x00/rt2x00dev.c +18 -0
@@ -1121,6 +1121,18 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) {int retval = -ENOMEM ; +/* +* Allocate the driver data memory, if necessary. +*/ +if (rt2x00dev->ops->drv_data_size >0 ) { + rt2x00dev->drv_data =kzalloc (rt2x00dev->ops->drv_data_size, +GFP_KERNEL ); +if (!rt2x00dev->drv_data) { + retval = -ENOMEM ; + goto exit; + } + } +spin_lock_init (&rt2x00dev->irqmask_lock);mutex_init (&rt2x00dev->csr_mutex);
@@ -1261,6 +1273,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)* Free queue structures. */ rt2x00queue_free (rt2x00dev); + +/* +* Free the driver data. +*/ +if (rt2x00dev->drv_data) +kfree (rt2x00dev->drv_data); }EXPORT_SYMBOL_GPL (rt2x00lib_remove_dev);
Signature · 1 line
1.7.9
PATCH 4/8 rt2x00: Use saved BBP 25 and 26 values when configuring channel on RT3572.
In reply to Gertjan van WingerdeThis brings the rt2800 channel switching code for RT3572 closer to the v2.5.0.0 Ralink RT3572 driver.
drivers/net/wireless/rt2x00/rt2800.h +2 -0
@@ -2444,6 +2444,8 @@ struct mac_iveiv_entry {struct rt2800_drv_data {u8 calibration_bw20;u8 calibration_bw40; +u8 bbp25; +u8 bbp26; };#endif /* RT2800_H */
drivers/net/wireless/rt2x00/rt2800lib.c +8 -2
@@ -1754,8 +1754,8 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,u32 reg;if (rf->channel <=14 ) { -rt2800_bbp_write (rt2x00dev,25 ,0x15 ); -rt2800_bbp_write (rt2x00dev,26 ,0x85 ); +rt2800_bbp_write (rt2x00dev,25 , drv_data->bbp25); +rt2800_bbp_write (rt2x00dev,26 , drv_data->bbp26); }else {rt2800_bbp_write (rt2x00dev,25 ,0x09 );rt2800_bbp_write (rt2x00dev,26 ,0xff );
@@ -3623,6 +3623,12 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)rt2800_init_rx_filter (rt2x00dev, true,0x27 ,0x15 ); } +/* +* Save BBP 25 & 26 values for later use in channel switching +*/ +rt2800_bbp_read (rt2x00dev,25 , &drv_data->bbp25); +rt2800_bbp_read (rt2x00dev,26 , &drv_data->bbp26); +if (!rt2x00_rt (rt2x00dev,RT5390 )) {/* * Set back to initial state
Signature · 1 line
1.7.9
PATCH 6/8 rt2x00: Align RT3572 channel switch RFCSR 1 programming with Ralink driver.
In reply to Gertjan van WingerdeAlign with the v2.5.0.0 Ralink RT3572 driver.
drivers/net/wireless/rt2x00/rt2800lib.c +2 -1
@@ -1806,11 +1806,12 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev,rt2800_rfcsr_write (rt2x00dev,13 , rfcsr);rt2800_rfcsr_read (rt2x00dev,1 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR1_RF_BLOCK_EN ,1 );rt2x00_set_field8 (&rfcsr,RFCSR1_RX0_PD ,0 );rt2x00_set_field8 (&rfcsr,RFCSR1_TX0_PD ,0 );rt2x00_set_field8 (&rfcsr,RFCSR1_RX1_PD ,0 );rt2x00_set_field8 (&rfcsr,RFCSR1_TX1_PD ,0 ); +rt2x00_set_field8 (&rfcsr,RFCSR1_RX2_PD ,0 ); +rt2x00_set_field8 (&rfcsr,RFCSR1_TX2_PD ,0 );if (test_bit (CAPABILITY_BT_COEXIST , &rt2x00dev->cap_flags)) {if (rf->channel <=14 ) {rt2x00_set_field8 (&rfcsr,RFCSR1_RX0_PD ,1 );
Signature · 1 line
1.7.9
Re: [PATCH 1/8] rt2x00: Introduce concept of driver data in struct rt2x00_dev.
In reply to Gertjan van WingerdeQuoted 8 lines · Gertjan van Wingerde
We are getting more and more fields in struct
rt2x00_devthat are specific to one or two of the low-level drivers. Instead of putting these fields inside the main structure and thus clobbering all low-level drivers with these fields, introduce the concept of driver data inside structrt2x00_dev, whose size is indicated by the low-level driver and which can be populated by the low-level driver.Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 64 lines
drivers/net/wireless/rt2x00/rt2x00.h +6
-0@@ -647,6 +647,7 @@ struct rt2x00lib_ops {*/ struct rt2x00_ops { const char *name; + const unsigned int drv_data_size; const unsigned int max_sta_intf; const unsigned int max_ap_intf; const unsigned int eeprom_size;@@ -742,6 +743,11 @@ struct rt2x00_dev { const struct rt2x00_ops *ops; /* + * Driver data. + */ + void *drv_data; + + /* * IEEE80211 control structure. */ struct ieee80211_hw *hw;drivers/net/wireless/rt2x00/rt2x00dev.c +18
-1@@ -1121,6 +1121,18 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) { int retval = -ENOMEM; + /* + * Allocate the driver data memory, if necessary. + */ + if (rt2x00dev->ops->drv_data_size > 0) { + rt2x00dev->drv_data = kzalloc(rt2x00dev->ops->drv_data_size, + GFP_KERNEL); + if (!rt2x00dev->drv_data) { + retval = -ENOMEM; + goto exit; + } + } + spin_lock_init(&rt2x00dev->irqmask_lock); mutex_init(&rt2x00dev->csr_mutex);@@ -1261,6 +1273,12 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)* Free queue structures. */ rt2x00queue_free(rt2x00dev); + + /* + * Free the driver data. + */ + if (rt2x00dev->drv_data) + kfree(rt2x00dev->drv_data); } EXPORT_SYMBOL_GPL(rt2x00lib_remove_dev); --1.7.9
Re: [PATCH 2/8] rt2x00: Use struct rt2x00_dev driver data in rt2800{pci,usb}.
In reply to Gertjan van WingerdeQuoted 4 lines · Gertjan van Wingerde
Start using the struct
rt2x00_devdriver data in rt2800 for the calibration data.Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 147 lines
drivers/net/wireless/rt2x00/rt2800.h +8
-0@@ -2438,4 +2438,12 @@ struct mac_iveiv_entry {*/ #define EIRP_MAX_TX_POWER_LIMIT 0x50 +/* +* RT2800 driver data structure +*/ +struct rt2800_drv_data { + u8 calibration_bw20; + u8 calibration_bw40; +}; + #endif /* RT2800_H */drivers/net/wireless/rt2x00/rt2800lib.c +19
-8@@ -1645,6 +1645,7 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, struct rf_channel *rf, struct channel_info *info) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u8 rfcsr, calib_tx, calib_rx; rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1);@@ -1714,8 +1715,13 @@ static void rt2800_config_channel_rf3xxx(struct rt2x00_dev *rt2x00dev, calib_tx = conf_is_ht40(conf) ? 0x68 : 0x4f; calib_rx = conf_is_ht40(conf) ? 0x6f : 0x4f; } else { - calib_tx = rt2x00dev->calibration[conf_is_ht40(conf)]; - calib_rx = rt2x00dev->calibration[conf_is_ht40(conf)]; + if (conf_is_ht40(conf)) { + calib_tx = drv_data->calibration_bw40; + calib_rx = drv_data->calibration_bw40; + } else { + calib_tx = drv_data->calibration_bw20; + calib_rx = drv_data->calibration_bw20; + } } rt2800_rfcsr_read(rt2x00dev, 24, &rfcsr);@@ -1743,6 +1749,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, struct rf_channel *rf, struct channel_info *info) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u8 rfcsr; u32 reg;@@ -1836,10 +1843,13 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); rt2800_rfcsr_write(rt2x00dev, 23, rfcsr); - rt2800_rfcsr_write(rt2x00dev, 24, - rt2x00dev->calibration[conf_is_ht40(conf)]); - rt2800_rfcsr_write(rt2x00dev, 31, - rt2x00dev->calibration[conf_is_ht40(conf)]); + if (conf_is_ht40(conf)) { + rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw40); + rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw40); + } else { + rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw20); + rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw20); + } if (rf->channel <= 14) { rt2800_rfcsr_write(rt2x00dev, 7, 0xd8);@@ -3310,6 +3320,7 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev, static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u8 rfcsr; u8 bbp; u32 reg;@@ -3598,17 +3609,17 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)* Set RX Filter calibration for 20MHz and 40MHz */ if (rt2x00_rt(rt2x00dev, RT3070)) { - rt2x00dev->calibration[0] = + drv_data->calibration_bw20 = rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x16); - rt2x00dev->calibration[1] = + drv_data->calibration_bw40 = rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x19); } else if (rt2x00_rt(rt2x00dev, RT3071) ||rt2x00_rt(rt2x00dev, RT3090) || rt2x00_rt(rt2x00dev, RT3390) ||
rt2x00_rt(rt2x00dev, RT3572)) {
- rt2x00dev->calibration[0] =
+drv_data->calibration_bw20=rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x13);
- rt2x00dev->calibration[1] =
+drv_data->calibration_bw40=rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x15); }drivers/net/wireless/rt2x00/rt2800pci.c +1
-0@@ -1093,6 +1093,7 @@ static const struct data_queue_desc rt2800pci_queue_bcn = { static const struct rt2x00_ops rt2800pci_ops = { .name = KBUILD_MODNAME, + .drv_data_size = sizeof(struct rt2800_drv_data), .max_sta_intf = 1, .max_ap_intf = 8, .eeprom_size = EEPROM_SIZE,drivers/net/wireless/rt2x00/rt2800usb.c +1
-0@@ -827,6 +827,7 @@ static const struct data_queue_desc rt2800usb_queue_bcn = { static const struct rt2x00_ops rt2800usb_ops = { .name = KBUILD_MODNAME, + .drv_data_size = sizeof(struct rt2800_drv_data), .max_sta_intf = 1, .max_ap_intf = 8, .eeprom_size = EEPROM_SIZE,drivers/net/wireless/rt2x00/rt2x00.h +0
-8@@ -897,13 +897,6 @@ struct rt2x00_dev { u8 freq_offset; /* - * Calibration information (for rt2800usb & rt2800pci). - * [0] -> BW20 - * [1] -> BW40 - */ - u8 calibration[2]; - - /* * Association id. */ u16 aid; --1.7.9
Re: [PATCH 3/8] rt2x00: Update comment on freq_offset field in struct rt2x00_dev.
In reply to Gertjan van WingerdeQuoted 8 lines · Gertjan van Wingerde
The comment states that the field is only used for rt61pci and rt73usb. However, it is now used by rt2800pci and rt2800usb as well, so the comment is not correct anymore.
Update the comment to not state any low-level drivers anymore.
Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 16 lines
drivers/net/wireless/rt2x00/rt2x00.h +1
-2@@ -892,7 +892,7 @@ struct rt2x00_dev { u8 rssi_offset; /* - * Frequency offset (for rt61pci & rt73usb). + * Frequency offset. */ u8 freq_offset; --1.7.9
Re: [PATCH 4/8] rt2x00: Use saved BBP 25 and 26 values when configuring channel on RT3572.
In reply to Gertjan van WingerdeQuoted 4 lines · Gertjan van Wingerde
This brings the rt2800 channel switching code for RT3572 closer to the v2.5.0.0 Ralink RT3572 driver.
Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 44 lines
drivers/net/wireless/rt2x00/rt2800.h +2
-0@@ -2444,6 +2444,8 @@ struct mac_iveiv_entry { struct rt2800_drv_data { u8 calibration_bw20; u8 calibration_bw40; + u8 bbp25; + u8 bbp26; }; #endif /* RT2800_H */drivers/net/wireless/rt2x00/rt2800lib.c +8
-3@@ -1754,8 +1754,8 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, u32 reg; if (rf->channel <= 14) { - rt2800_bbp_write(rt2x00dev, 25, 0x15); - rt2800_bbp_write(rt2x00dev, 26, 0x85); + rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); + rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); } else { rt2800_bbp_write(rt2x00dev, 25, 0x09); rt2800_bbp_write(rt2x00dev, 26, 0xff);@@ -3623,6 +3623,12 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x15); } + /* + * Save BBP 25 & 26 values for later use in channel switching + */ + rt2800_bbp_read(rt2x00dev, 25, &drv_data->bbp25); + rt2800_bbp_read(rt2x00dev, 26, &drv_data->bbp26); + if (!rt2x00_rt(rt2x00dev, RT5390)) { /** Set back to initial state -- 1.7.9
Re: [PATCH 5/8] rt2x00: Fix RFCSR 12 & 13 programming on RT3572 channel switching.
In reply to Gertjan van WingerdeQuoted 4 lines · Gertjan van Wingerde
Align with v2.5.0.0 Ralink RT3572 driver for 2.4GHz band channel switch.
Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 27 lines
drivers/net/wireless/rt2x00/rt2800lib.c +2
-5@@ -1783,8 +1783,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, if (rf->channel <= 14) { rt2x00_set_field8(&rfcsr, RFCSR12_DR0, 3); rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, - (info->default_power1 & 0x3) | - ((info->default_power1 & 0xC) << 1)); + info->default_power1); } else { rt2x00_set_field8(&rfcsr, RFCSR12_DR0, 7); rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER,@@ -1797,8 +1796,7 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, if (rf->channel <= 14) { rt2x00_set_field8(&rfcsr, RFCSR13_DR0, 3); rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, - (info->default_power2 & 0x3) | - ((info->default_power2 & 0xC) << 1)); + info->default_power2); } else { rt2x00_set_field8(&rfcsr, RFCSR13_DR0, 7); rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, --1.7.9
Re: [PATCH 6/8] rt2x00: Align RT3572 channel switch RFCSR 1 programming with Ralink driver.
In reply to Gertjan van WingerdeQuoted 4 lines · Gertjan van Wingerde
Align with the v2.5.0.0 Ralink RT3572 driver.
Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 21 lines
drivers/net/wireless/rt2x00/rt2800lib.c +2
-2@@ -1806,11 +1806,12 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 13, rfcsr); rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr); - rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1); rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 0); rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 0); rt2x00_set_field8(&rfcsr, RFCSR1_RX1_PD, 0); rt2x00_set_field8(&rfcsr, RFCSR1_TX1_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_RX2_PD, 0); + rt2x00_set_field8(&rfcsr, RFCSR1_TX2_PD, 0); if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags)) { if (rf->channel <= 14) { rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1); --1.7.9
Re: [PATCH 7/8] rt2x00: Fix RT3572 channel switch RFCSR 7 programming.
In reply to Gertjan van WingerdeQuoted 4 lines · Gertjan van Wingerde
Align with the v2.5.0.0 Ralink RT3572 driver.
Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 42 lines
drivers/net/wireless/rt2x00/rt2800.h +6
-4@@ -1819,10 +1819,12 @@ struct mac_iveiv_entry {* RFCSR 7: */ #define RFCSR7_RF_TUNING FIELD8(0x01) -#define RFCSR7_R02 FIELD8(0x07) -#define RFCSR7_R3 FIELD8(0x08) -#define RFCSR7_R45 FIELD8(0x30) -#define RFCSR7_R67 FIELD8(0xc0) +#define RFCSR7_BIT1 FIELD8(0x02) +#define RFCSR7_BIT2 FIELD8(0x04) +#define RFCSR7_BIT3 FIELD8(0x08) +#define RFCSR7_BIT4 FIELD8(0x10) +#define RFCSR7_BIT5 FIELD8(0x20) +#define RFCSR7_BITS67 FIELD8(0xc0) /** RFCSR 11: drivers/net/wireless/rt2x00/rt2800lib.c +6
-2@@ -1865,7 +1865,12 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 27, 0x00); rt2800_rfcsr_write(rt2x00dev, 29, 0x9b); } else { - rt2800_rfcsr_write(rt2x00dev, 7, 0x14); + rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr); + rt2x00_set_field8(&rfcsr, RFCSR7_BIT2, 1); + rt2x00_set_field8(&rfcsr, RFCSR7_BIT3, 0); + rt2x00_set_field8(&rfcsr, RFCSR7_BIT4, 1); + rt2x00_set_field8(&rfcsr, RFCSR7_BITS67, 0); + rt2800_rfcsr_write(rt2x00dev, 7, rfcsr); rt2800_rfcsr_write(rt2x00dev, 9, 0xc0); rt2800_rfcsr_write(rt2x00dev, 10, 0xf1); rt2800_rfcsr_write(rt2x00dev, 11, 0x00); --1.7.9
Re: [PATCH 8/8] rt2x00: Correctly set txmixer_gain in RT3572 channel switching.
In reply to Gertjan van WingerdeQuoted 7 lines · Gertjan van Wingerde
Align with the v2.5.0.0 Ralink RT3572 driver.
Save the EEPROM
txmixer_gainvalues inside the rt2800 driver data structure and use it throughout the code.Signed-off-by Gertjan van Wingerde <[email protected]>
Quoted 121 lines
drivers/net/wireless/rt2x00/rt2800.h +13
-0@@ -1849,6 +1849,11 @@ struct mac_iveiv_entry { #define RFCSR15_TX_LO2_EN FIELD8(0x08) /* +* RFCSR 16: +*/ +#define RFCSR16_TXMIXER_GAIN FIELD8(0x07) + +/* * RFCSR 17: */ #define RFCSR17_TXMIXER_GAIN FIELD8(0x07)@@ -2111,6 +2116,12 @@ struct mac_iveiv_entry { #define EEPROM_RSSI_A2_LNA_A2 FIELD16(0xff00) /* +* EEPROM TXMIXER GAIN A offset (note overlaps with EEPROM RSSI A2). +*/ +#define EEPROM_TXMIXER_GAIN_A 0x0026 +#define EEPROM_TXMIXER_GAIN_A_VAL FIELD16(0x0007) + +/* * EEPROM EIRP Maximum TX power values(unit: dbm) */ #define EEPROM_EIRP_MAX_TX_POWER 0x0027@@ -2448,6 +2459,8 @@ struct rt2800_drv_data { u8 calibration_bw40; u8 bbp25; u8 bbp26; + u8 txmixer_gain_24g; + u8 txmixer_gain_5g; }; #endif /* RT2800_H */drivers/net/wireless/rt2x00/rt2800lib.c +27
-8@@ -1856,7 +1856,10 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 10, 0xf1); rt2800_rfcsr_write(rt2x00dev, 11, 0xb9); rt2800_rfcsr_write(rt2x00dev, 15, 0x53); - rt2800_rfcsr_write(rt2x00dev, 16, 0x4c); + rfcsr = 0x4c; + rt2x00_set_field8(&rfcsr, RFCSR16_TXMIXER_GAIN, + drv_data->txmixer_gain_24g); + rt2800_rfcsr_write(rt2x00dev, 16, rfcsr); rt2800_rfcsr_write(rt2x00dev, 17, 0x23); rt2800_rfcsr_write(rt2x00dev, 19, 0x93); rt2800_rfcsr_write(rt2x00dev, 20, 0xb3);@@ -1875,7 +1878,10 @@ static void rt2800_config_channel_rf3052(struct rt2x00_dev *rt2x00dev, rt2800_rfcsr_write(rt2x00dev, 10, 0xf1); rt2800_rfcsr_write(rt2x00dev, 11, 0x00); rt2800_rfcsr_write(rt2x00dev, 15, 0x43); - rt2800_rfcsr_write(rt2x00dev, 16, 0x7a); + rfcsr = 0x7a; + rt2x00_set_field8(&rfcsr, RFCSR16_TXMIXER_GAIN, + drv_data->txmixer_gain_5g); + rt2800_rfcsr_write(rt2x00dev, 16, rfcsr); rt2800_rfcsr_write(rt2x00dev, 17, 0x23); if (rf->channel <= 64) { rt2800_rfcsr_write(rt2x00dev, 19, 0xb7);@@ -3672,11 +3678,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) &rt2x00dev->cap_flags)) rt2x00_set_field8(&rfcsr, RFCSR17_R, 1); } - rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom); - if (rt2x00_get_field16(eeprom, EEPROM_TXMIXER_GAIN_BG_VAL) >= 1) - rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN, - rt2x00_get_field16(eeprom, - EEPROM_TXMIXER_GAIN_BG_VAL)); + rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN, + drv_data->txmixer_gain_24g); rt2800_rfcsr_write(rt2x00dev, 17, rfcsr); }@@ -3884,6 +3887,7 @@ EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) { + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; u16 word; u8 *mac; u8 default_lna_gain;@@ -3967,6 +3971,14 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); + rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &word); + if ((word & 0x00ff) != 0x00ff) { + drv_data->txmixer_gain_24g = + rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_BG_VAL); + } else { + drv_data->txmixer_gain_24g = 0; + } + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0);@@ -3976,6 +3988,14 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) default_lna_gain); rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); + rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_A, &word); + if ((word & 0x00ff) != 0x00ff) { + drv_data->txmixer_gain_5g = + rt2x00_get_field16(word, EEPROM_TXMIXER_GAIN_A_VAL); + } else { + drv_data->txmixer_gain_5g = 0; + } + rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0); --1.7.9