rt2800: cleanup rfcsr init procedures
v2 cover rt2800: cleanup rfcsr init procedures
v1 -> v2:
- address comments from Gabor Juhos and Gertjan van Wingerde
- rebase on top of "Fix transmit power troubles on some Ralink RT30xx cards" patch
PATCH v2 1/11 rt2800: merge 5xxx normal mode setup
From: Stanislaw Gruszka <[email protected]>
Merge code which program the same registes at the end of rfcsr initialization for 5592, 5392 and 5390 chips.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 84 +++++++++++++----------------- 1 files changed, 36 insertions(+), 48 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +36 -48
@@ -4396,6 +4396,35 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,return rfcsr24; } +static void rt2800_normal_mode_setup_5xxx (struct rt2x00_dev *rt2x00dev) +{ +u8 reg; +u16 eeprom; + +/* Turn off unused DAC1 and ADC1 to reduce power consumption */ +rt2800_bbp_read (rt2x00dev,138 , ®); +rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF0 , &eeprom); +if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_RXPATH ) ==1 ) +rt2x00_set_field8 (®,BBP138_RX_ADC1 ,0 ); +if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_TXPATH ) ==1 ) +rt2x00_set_field8 (®,BBP138_TX_DAC1 ,1 ); +rt2800_bbp_write (rt2x00dev,138 , reg); + +rt2800_rfcsr_read (rt2x00dev,38 , ®); +rt2x00_set_field8 (®,RFCSR38_RX_LO1_EN ,0 ); +rt2800_rfcsr_write (rt2x00dev,38 , reg); + +rt2800_rfcsr_read (rt2x00dev,39 , ®); +rt2x00_set_field8 (®,RFCSR39_RX_LO2_EN ,0 ); +rt2800_rfcsr_write (rt2x00dev,39 , reg); + +rt2800_bbp4_mac_if_ctrl (rt2x00dev); + +rt2800_rfcsr_read (rt2x00dev,30 , ®); +rt2x00_set_field8 (®,RFCSR30_RX_VCM ,2 ); +rt2800_rfcsr_write (rt2x00dev,30 , reg); +} +static void rt2800_init_rfcsr_305x_soc (struct rt2x00_dev *rt2x00dev) {rt2800_rfcsr_write (rt2x00dev,0 ,0x50 );
@@ -4725,6 +4754,8 @@ static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,61 ,0xdd );rt2800_rfcsr_write (rt2x00dev,62 ,0x00 );rt2800_rfcsr_write (rt2x00dev,63 ,0x00 ); + +rt2800_normal_mode_setup_5xxx (rt2x00dev); }static void rt2800_init_rfcsr_5392 (struct rt2x00_dev *rt2x00dev)
@@ -4788,13 +4819,12 @@ static void rt2800_init_rfcsr_5392(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,61 ,0x91 );rt2800_rfcsr_write (rt2x00dev,62 ,0x39 );rt2800_rfcsr_write (rt2x00dev,63 ,0x07 ); + +rt2800_normal_mode_setup_5xxx (rt2x00dev); }static void rt2800_init_rfcsr_5592 (struct rt2x00_dev *rt2x00dev) { -u8 reg; -u16 eeprom; -rt2800_rfcsr_write (rt2x00dev,1 ,0x3F );rt2800_rfcsr_write (rt2x00dev,3 ,0x08 );rt2800_rfcsr_write (rt2x00dev,3 ,0x08 );
@@ -4823,34 +4853,11 @@ static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev)rt2800_adjust_freq_offset (rt2x00dev); -rt2800_bbp_read (rt2x00dev,138 , ®); - -/* Turn off unused DAC1 and ADC1 to reduce power consumption */ -rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF0 , &eeprom); -if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_RXPATH ) ==1 ) -rt2x00_set_field8 (®,BBP138_RX_ADC1 ,0 ); -if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_TXPATH ) ==1 ) -rt2x00_set_field8 (®,BBP138_TX_DAC1 ,1 ); - -rt2800_bbp_write (rt2x00dev,138 , reg); -/* Enable DC filter */ if (rt2x00_rt_rev_gte (rt2x00dev,RT5592 ,REV_RT5592C ))rt2800_bbp_write (rt2x00dev,103 ,0xc0 ); -rt2800_rfcsr_read (rt2x00dev,38 , ®); -rt2x00_set_field8 (®,RFCSR38_RX_LO1_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,38 , reg); - -rt2800_rfcsr_read (rt2x00dev,39 , ®); -rt2x00_set_field8 (®,RFCSR39_RX_LO2_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,39 , reg); - -rt2800_bbp4_mac_if_ctrl (rt2x00dev); - -rt2800_rfcsr_read (rt2x00dev,30 , ®); -rt2x00_set_field8 (®,RFCSR30_RX_VCM ,2 ); -rt2800_rfcsr_write (rt2x00dev,30 , reg); +rt2800_normal_mode_setup_5xxx (rt2x00dev); }static int rt2800_init_rfcsr (struct rt2x00_dev *rt2x00dev)
@@ -5055,17 +5062,14 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,17 , rfcsr); } -if (rt2x00_rt (rt2x00dev,RT3090 ) || -rt2x00_rt (rt2x00dev,RT5592 )) { -rt2800_bbp_read (rt2x00dev,138 , &bbp); - +if (rt2x00_rt (rt2x00dev,RT3090 )) {/* Turn off unused DAC1 and ADC1 to reduce power consumption */ +rt2800_bbp_read (rt2x00dev,138 , &bbp);rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF0 , &eeprom);if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_RXPATH ) ==1 )rt2x00_set_field8 (&bbp,BBP138_RX_ADC1 ,0 );if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_TXPATH ) ==1 )rt2x00_set_field8 (&bbp,BBP138_TX_DAC1 ,1 ); -rt2800_bbp_write (rt2x00dev,138 , bbp); }
@@ -5111,22 +5115,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,29 , rfcsr); } -if (rt2x00_rt (rt2x00dev,RT5390 ) || -rt2x00_rt (rt2x00dev,RT5392 ) || -rt2x00_rt (rt2x00dev,RT5592 )) { -rt2800_rfcsr_read (rt2x00dev,38 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR38_RX_LO1_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,38 , rfcsr); - -rt2800_rfcsr_read (rt2x00dev,39 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR39_RX_LO2_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,39 , rfcsr); - -rt2800_rfcsr_read (rt2x00dev,30 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR30_RX_VCM ,2 ); -rt2800_rfcsr_write (rt2x00dev,30 , rfcsr); - } -return 0 ; }
Signature · 1 line
1.7.4.4
Re: [PATCH v2 01/11] rt2800: merge 5xxx normal mode setup
Quoted 6 lines · On Wed, Apr 17, 2013 at 2:08 PM, <[email protected]> wrote:
From: Stanislaw Gruszka <[email protected]>
Merge code which program the same registes at the end of rfcsr initialization for 5592, 5392 and 5390 chips.
Signed-off-by Stanislaw Gruszka <[email protected]>
---
Gertjan
PATCH v2 2/11 rt2800: move rf init calibration code
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
Add separate function for rf init calibration code and use it on all init rf subroutines.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 54 ++++++++++++++++++------------ 1 files changed, 32 insertions(+), 22 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +32 -22
@@ -4396,6 +4396,19 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,return rfcsr24; } +static void rt2800_rf_init_calibration (struct rt2x00_dev *rt2x00dev, +const unsigned int rf_reg) +{ +u8 rfcsr; + +rt2800_rfcsr_read (rt2x00dev, rf_reg, &rfcsr); +rt2x00_set_field8 (&rfcsr,FIELD8 (0x80 ),1 ); +rt2800_rfcsr_write (rt2x00dev, rf_reg, rfcsr); +msleep (1 ); +rt2x00_set_field8 (&rfcsr,FIELD8 (0x80 ),0 ); +rt2800_rfcsr_write (rt2x00dev, rf_reg, rfcsr); +} +static void rt2800_normal_mode_setup_5xxx (struct rt2x00_dev *rt2x00dev) {u8 reg;
@@ -4427,6 +4440,8 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_305x_soc (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,30 ); +rt2800_rfcsr_write (rt2x00dev,0 ,0x50 );rt2800_rfcsr_write (rt2x00dev,1 ,0x01 );rt2800_rfcsr_write (rt2x00dev,2 ,0xf7 );
@@ -4463,6 +4478,9 @@ static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_30xx (struct rt2x00_dev *rt2x00dev) { +/* XXX vendor driver do this only for 3070 */ +rt2800_rf_init_calibration (rt2x00dev,30 ); +rt2800_rfcsr_write (rt2x00dev,4 ,0x40 );rt2800_rfcsr_write (rt2x00dev,5 ,0x03 );rt2800_rfcsr_write (rt2x00dev,6 ,0x02 );
@@ -4486,6 +4504,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,2 ); +rt2800_rfcsr_write (rt2x00dev,1 ,0x0f );rt2800_rfcsr_write (rt2x00dev,2 ,0x80 );rt2800_rfcsr_write (rt2x00dev,3 ,0x08 );
@@ -4536,6 +4556,8 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3352 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,30 ); +rt2800_rfcsr_write (rt2x00dev,0 ,0xf0 );rt2800_rfcsr_write (rt2x00dev,1 ,0x23 );rt2800_rfcsr_write (rt2x00dev,2 ,0x50 );
@@ -4603,6 +4625,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3390 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,30 ); +rt2800_rfcsr_write (rt2x00dev,0 ,0xa0 );rt2800_rfcsr_write (rt2x00dev,1 ,0xe1 );rt2800_rfcsr_write (rt2x00dev,2 ,0xf1 );
@@ -4639,6 +4663,8 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,30 ); +rt2800_rfcsr_write (rt2x00dev,0 ,0x70 );rt2800_rfcsr_write (rt2x00dev,1 ,0x81 );rt2800_rfcsr_write (rt2x00dev,2 ,0xf1 );
@@ -4674,6 +4700,8 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_5390 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,2 ); +rt2800_rfcsr_write (rt2x00dev,1 ,0x0f );rt2800_rfcsr_write (rt2x00dev,2 ,0x80 );rt2800_rfcsr_write (rt2x00dev,3 ,0x88 );
@@ -4760,6 +4788,8 @@ static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_5392 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,2 ); +rt2800_rfcsr_write (rt2x00dev,1 ,0x17 );rt2800_rfcsr_write (rt2x00dev,2 ,0x80 );rt2800_rfcsr_write (rt2x00dev,3 ,0x88 );
@@ -4825,6 +4855,8 @@ static void rt2800_init_rfcsr_5392(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_5592 (struct rt2x00_dev *rt2x00dev) { +rt2800_rf_init_calibration (rt2x00dev,30 ); +rt2800_rfcsr_write (rt2x00dev,1 ,0x3F );rt2800_rfcsr_write (rt2x00dev,3 ,0x08 );rt2800_rfcsr_write (rt2x00dev,3 ,0x08 );
@@ -4882,28 +4914,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) !rt2800_is_305x_soc(rt2x00dev))return 0 ; -/* -* Init RF calibration. -*/ - -if (rt2x00_rt (rt2x00dev,RT3290 ) || -rt2x00_rt (rt2x00dev,RT5390 ) || -rt2x00_rt (rt2x00dev,RT5392 )) { -rt2800_rfcsr_read (rt2x00dev,2 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR2_RESCAL_EN ,1 ); -rt2800_rfcsr_write (rt2x00dev,2 , rfcsr); -msleep (1 ); -rt2x00_set_field8 (&rfcsr,RFCSR2_RESCAL_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,2 , rfcsr); - }else { -rt2800_rfcsr_read (rt2x00dev,30 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR30_RF_CALIBRATION ,1 ); -rt2800_rfcsr_write (rt2x00dev,30 , rfcsr); -msleep (1 ); -rt2x00_set_field8 (&rfcsr,RFCSR30_RF_CALIBRATION ,0 ); -rt2800_rfcsr_write (rt2x00dev,30 , rfcsr); - } -if (rt2800_is_305x_soc (rt2x00dev)) {rt2800_init_rfcsr_305x_soc (rt2x00dev);return 0 ;
Signature · 1 line
1.7.4.4
Re: [PATCH v2 02/11] rt2800: move rf init calibration code
Quoted 6 lines · On Wed, Apr 17, 2013 at 2:08 PM, <[email protected]> wrote:
From: Stanislaw Gruszka <[email protected]>
Add separate function for rf init calibration code and use it on all init rf subroutines.
Signed-off-by Stanislaw Gruszka <[email protected]>
---
Gertjan
PATCH v2 3/11 rt2800: move RFCSR29_RSSI_GAIN to 3290 specific rfcsr init
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +6 -6
@@ -4504,6 +4504,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev) { +u8 rfcsr; +rt2800_rf_init_calibration (rt2x00dev,2 );rt2800_rfcsr_write (rt2x00dev,1 ,0x0f );
@@ -4552,6 +4554,10 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,59 ,0x09 );rt2800_rfcsr_write (rt2x00dev,60 ,0x45 );rt2800_rfcsr_write (rt2x00dev,61 ,0xc1 ); + +rt2800_rfcsr_read (rt2x00dev,29 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR29_RSSI_GAIN ,3 ); +rt2800_rfcsr_write (rt2x00dev,29 , rfcsr); }static void rt2800_init_rfcsr_3352 (struct rt2x00_dev *rt2x00dev)
@@ -5119,12 +5125,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,27 , rfcsr); } -if (rt2x00_rt (rt2x00dev,RT3290 )) { -rt2800_rfcsr_read (rt2x00dev,29 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR29_RSSI_GAIN ,3 ); -rt2800_rfcsr_write (rt2x00dev,29 , rfcsr); - } -return 0 ; }
Signature · 1 line
1.7.4.4
PATCH v2 4/11 rt2800: move 30xx common rf init code
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 63 +++++++++++++++++-------------- 1 files changed, 35 insertions(+), 28 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +35 -28
@@ -4478,6 +4478,10 @@ static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_30xx (struct rt2x00_dev *rt2x00dev) { +u8 rfcsr; +u16 eeprom; +u32 reg; +/* XXX vendor driver do this only for 3070 */ rt2800_rf_init_calibration (rt2x00dev,30 );
@@ -4500,6 +4504,36 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,24 ,0x16 );rt2800_rfcsr_write (rt2x00dev,25 ,0x01 );rt2800_rfcsr_write (rt2x00dev,29 ,0x1f ); + +if (rt2x00_rt_rev_lt (rt2x00dev,RT3070 ,REV_RT3070F )) { +rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); +rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); +rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,3 ); +rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); + }else if (rt2x00_rt (rt2x00dev,RT3071 ) || +rt2x00_rt (rt2x00dev,RT3090 )) { +rt2800_rfcsr_write (rt2x00dev,31 ,0x14 ); + +rt2800_rfcsr_read (rt2x00dev,6 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR6_R2 ,1 ); +rt2800_rfcsr_write (rt2x00dev,6 , rfcsr); + +rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); +rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); +if (rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) || +rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E )) { +rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF1 , &eeprom); +if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF1_DAC_TEST )) +rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,3 ); +else +rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,0 ); + } +rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); + +rt2800_register_read (rt2x00dev,GPIO_SWITCH , ®); +rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 ); +rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg); + } }static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev)
@@ -4954,35 +4988,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)return 0 ; } -if (rt2x00_rt_rev_lt (rt2x00dev,RT3070 ,REV_RT3070F )) { -rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); -rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); -rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,3 ); -rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); - }else if (rt2x00_rt (rt2x00dev,RT3071 ) || -rt2x00_rt (rt2x00dev,RT3090 )) { -rt2800_rfcsr_write (rt2x00dev,31 ,0x14 ); - -rt2800_rfcsr_read (rt2x00dev,6 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR6_R2 ,1 ); -rt2800_rfcsr_write (rt2x00dev,6 , rfcsr); -rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); -rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); -if (rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E )) { -rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF1 , &eeprom); -if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF1_DAC_TEST )) -rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,3 ); -else -rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,0 ); - } -rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); - -rt2800_register_read (rt2x00dev,GPIO_SWITCH , ®); -rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 ); -rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg); - }else if (rt2x00_rt (rt2x00dev,RT3390 )) { +if (rt2x00_rt (rt2x00dev,RT3390 )) {rt2800_register_read (rt2x00dev,GPIO_SWITCH , ®);rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 );rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg);
Signature · 1 line
1.7.4.4
PATCH v2 5/11 rt2800: move GPIO_SWITCH setup to 3390 specific rfcsr init
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +7 -5
@@ -4665,6 +4665,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3390 (struct rt2x00_dev *rt2x00dev) { +u32 reg; +rt2800_rf_init_calibration (rt2x00dev,30 );rt2800_rfcsr_write (rt2x00dev,0 ,0xa0 );
@@ -4699,6 +4701,10 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,29 ,0x8f );rt2800_rfcsr_write (rt2x00dev,30 ,0x20 );rt2800_rfcsr_write (rt2x00dev,31 ,0x0f ); + +rt2800_register_read (rt2x00dev,GPIO_SWITCH , ®); +rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 ); +rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg); }static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev)
@@ -4989,11 +4995,7 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) } -if (rt2x00_rt (rt2x00dev,RT3390 )) { -rt2800_register_read (rt2x00dev,GPIO_SWITCH , ®); -rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 ); -rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg); - }else if (rt2x00_rt (rt2x00dev,RT3572 )) { +if (rt2x00_rt (rt2x00dev,RT3572 )) {rt2800_rfcsr_read (rt2x00dev,6 , &rfcsr);rt2x00_set_field8 (&rfcsr,RFCSR6_R2 ,1 );rt2800_rfcsr_write (rt2x00dev,6 , rfcsr);
Signature · 1 line
1.7.4.4
PATCH v2 6/11 rt2800: move RFCSR6_R2 & LDO_CFG0 setup to 3572 specific rfcsr init
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 34 +++++++++++++++--------------- 1 files changed, 17 insertions(+), 17 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +17 -17
@@ -4709,6 +4709,9 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev) { +u8 rfcsr; +u32 reg; +rt2800_rf_init_calibration (rt2x00dev,30 );rt2800_rfcsr_write (rt2x00dev,0 ,0x70 );
@@ -4742,6 +4745,20 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,29 ,0x9b );rt2800_rfcsr_write (rt2x00dev,30 ,0x09 );rt2800_rfcsr_write (rt2x00dev,31 ,0x10 ); + +rt2800_rfcsr_read (rt2x00dev,6 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR6_R2 ,1 ); +rt2800_rfcsr_write (rt2x00dev,6 , rfcsr); + +rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); +rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,3 ); +rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); +rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); +msleep (1 ); +rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); +rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,0 ); +rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); +rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); }static void rt2800_init_rfcsr_5390 (struct rt2x00_dev *rt2x00dev)
@@ -4994,23 +5011,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)return 0 ; } - -if (rt2x00_rt (rt2x00dev,RT3572 )) { -rt2800_rfcsr_read (rt2x00dev,6 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR6_R2 ,1 ); -rt2800_rfcsr_write (rt2x00dev,6 , rfcsr); - -rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); -rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,3 ); -rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); -rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); -msleep (1 ); -rt2800_register_read (rt2x00dev,LDO_CFG0 , ®); -rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,0 ); -rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 ); -rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); - } -/* * Set RX Filter calibration for 20MHz and 40MHz */
Signature · 1 line
1.7.4.4
PATCH v2 7/11 rt2800: add rt2800_rx_filter_calibration procedure
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
Add procedure for both bands filter calibration and use it on individual chipset init rfcsr subroutines.
Remove "Set back to initial state" code for 3290 since vendor driver DPO_RT3290_LinuxSTA_V2600_20120508 does not include it.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 103 +++++++++++++++++-------------- 1 files changed, 57 insertions(+), 46 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +57 -46
@@ -4332,8 +4332,8 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)return 0 ; } -static u8 rt2800_init_rx_filter (struct rt2x00_dev *rt2x00dev, -bool bw40,u8 rfcsr24,u8 filter_target) +static u8 rt2800_init_rx_filter (struct rt2x00_dev *rt2x00dev,bool bw40, +u8 filter_target) {unsigned int i;u8 bbp;
@@ -4341,6 +4341,7 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,u8 passband;u8 stopband;u8 overtuned =0 ; +u8 rfcsr24 = (bw40) ?0x27 :0x07 ;rt2800_rfcsr_write (rt2x00dev,24 , rfcsr24);
@@ -4409,6 +4410,52 @@ static void rt2800_rf_init_calibration(struct rt2x00_dev *rt2x00dev,rt2800_rfcsr_write (rt2x00dev, rf_reg, rfcsr); } +static void rt2800_rx_filter_calibration (struct rt2x00_dev *rt2x00dev) +{ +struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; +u8 filter_tgt_bw20; +u8 filter_tgt_bw40; +u8 rfcsr, bbp; + +/* +* TODO: sync filter_tgt values with vendor driver +*/ +if (rt2x00_rt (rt2x00dev,RT3070 )) { + filter_tgt_bw20 =0x16 ; + filter_tgt_bw40 =0x19 ; + }else { + filter_tgt_bw20 =0x13 ; + filter_tgt_bw40 =0x15 ; + } + + drv_data->calibration_bw20 = +rt2800_init_rx_filter (rt2x00dev, false, filter_tgt_bw20); + drv_data->calibration_bw40 = +rt2800_init_rx_filter (rt2x00dev, true, filter_tgt_bw40); + +/* +* Save BBP 25 & 26 values for later use in channel switching (for 3052) +*/ +rt2800_bbp_read (rt2x00dev,25 , &drv_data->bbp25); +rt2800_bbp_read (rt2x00dev,26 , &drv_data->bbp26); + +/* +* Set back to initial state +*/ +rt2800_bbp_write (rt2x00dev,24 ,0 ); + +rt2800_rfcsr_read (rt2x00dev,22 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR22_BASEBAND_LOOPBACK ,0 ); +rt2800_rfcsr_write (rt2x00dev,22 , rfcsr); + +/* +* Set BBP back to BW20 +*/ +rt2800_bbp_read (rt2x00dev,4 , &bbp); +rt2x00_set_field8 (&bbp,BBP4_BANDWIDTH ,0 ); +rt2800_bbp_write (rt2x00dev,4 , bbp); +} +static void rt2800_normal_mode_setup_5xxx (struct rt2x00_dev *rt2x00dev) {u8 reg;
@@ -4534,6 +4581,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 );rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg); } + +rt2800_rx_filter_calibration (rt2x00dev); }static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev)
@@ -4661,6 +4710,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,61 ,0x00 );rt2800_rfcsr_write (rt2x00dev,62 ,0x00 );rt2800_rfcsr_write (rt2x00dev,63 ,0x00 ); + +rt2800_rx_filter_calibration (rt2x00dev); }static void rt2800_init_rfcsr_3390 (struct rt2x00_dev *rt2x00dev)
@@ -4705,6 +4756,8 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)rt2800_register_read (rt2x00dev,GPIO_SWITCH , ®);rt2x00_set_field32 (®,GPIO_SWITCH_5 ,0 );rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg); + +rt2800_rx_filter_calibration (rt2x00dev); }static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev)
@@ -4759,6 +4812,8 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)rt2x00_set_field32 (®,LDO_CFG0_LDO_CORE_VLEVEL ,0 );rt2x00_set_field32 (®,LDO_CFG0_BGSEL ,1 );rt2800_register_write (rt2x00dev,LDO_CFG0 , reg); + +rt2800_rx_filter_calibration (rt2x00dev); }static void rt2800_init_rfcsr_5390 (struct rt2x00_dev *rt2x00dev)
@@ -5011,50 +5066,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)return 0 ; } -/* -* Set RX Filter calibration for 20MHz and 40MHz -*/ -if (rt2x00_rt (rt2x00dev,RT3070 )) { - drv_data->calibration_bw20 = -rt2800_init_rx_filter (rt2x00dev, false,0x07 ,0x16 ); - 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,RT3352 ) || -rt2x00_rt (rt2x00dev,RT3390 ) || -rt2x00_rt (rt2x00dev,RT3572 )) { - drv_data->calibration_bw20 = -rt2800_init_rx_filter (rt2x00dev, false,0x07 ,0x13 ); - drv_data->calibration_bw40 = -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 ) && - !rt2x00_rt (rt2x00dev,RT5392 )) { -/* -* Set back to initial state -*/ -rt2800_bbp_write (rt2x00dev,24 ,0 ); - -rt2800_rfcsr_read (rt2x00dev,22 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR22_BASEBAND_LOOPBACK ,0 ); -rt2800_rfcsr_write (rt2x00dev,22 , rfcsr); - -/* -* Set BBP back to BW20 -*/ -rt2800_bbp_read (rt2x00dev,4 , &bbp); -rt2x00_set_field8 (&bbp,BBP4_BANDWIDTH ,0 ); -rt2800_bbp_write (rt2x00dev,4 , bbp); - } - if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F) || rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
Signature · 1 line
1.7.4.4
Re: [PATCH v2 07/11] rt2800: add rt2800_rx_filter_calibration procedure
Quoted 9 lines · On Wed, Apr 17, 2013 at 2:08 PM, <[email protected]> wrote:
From: Stanislaw Gruszka <[email protected]>
Add procedure for both bands filter calibration and use it on individual chipset init rfcsr subroutines.
Remove "Set back to initial state" code for 3290 since vendor driver
DPO_RT3290_LinuxSTA_V2600_20120508does not include it.Signed-off-by Stanislaw Gruszka <[email protected]>
---
Gertjan
PATCH v2 8/11 rt2800: move RF_R27 setup to individual rfcsr init subroutines
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +11 -7
@@ -4583,6 +4583,11 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev) }rt2800_rx_filter_calibration (rt2x00dev); + +if (rt2x00_rt_rev_lt (rt2x00dev,RT3070 ,REV_RT3070F ) || +rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) || +rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E )) +rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); }static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev)
@@ -4758,6 +4763,9 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)rt2800_register_write (rt2x00dev,GPIO_SWITCH , reg);rt2800_rx_filter_calibration (rt2x00dev); + +if (rt2x00_rt_rev_lt (rt2x00dev,RT3390 ,REV_RT3390E )) +rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); }static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev)
@@ -5008,6 +5016,9 @@ static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev)rt2800_bbp_write (rt2x00dev,103 ,0xc0 );rt2800_normal_mode_setup_5xxx (rt2x00dev); + +if (rt2x00_rt_rev_lt (rt2x00dev,RT5592 ,REV_RT5592C )) +rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); }static int rt2800_init_rfcsr (struct rt2x00_dev *rt2x00dev)
@@ -5066,13 +5077,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)return 0 ; } -if (rt2x00_rt_rev_lt (rt2x00dev,RT3070 ,REV_RT3070F ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3390 ,REV_RT3390E ) || -rt2x00_rt_rev_lt (rt2x00dev,RT5592 ,REV_RT5592C )) -rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); -rt2800_register_read (rt2x00dev,OPT_14_CSR , ®);rt2x00_set_field32 (®,OPT_14_CSR_BIT0 ,1 );rt2800_register_write (rt2x00dev,OPT_14_CSR , reg);
Signature · 1 line
1.7.4.4
PATCH v2 9/11 rt2800: add rt2800_led_open_drain_enable subroutine
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +25 -4
@@ -4332,6 +4332,15 @@ static int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)return 0 ; } +static void rt2800_led_open_drain_enable (struct rt2x00_dev *rt2x00dev) +{ +u32 reg; + +rt2800_register_read (rt2x00dev,OPT_14_CSR , ®); +rt2x00_set_field32 (®,OPT_14_CSR_BIT0 ,1 ); +rt2800_register_write (rt2x00dev,OPT_14_CSR , reg); +} +static u8 rt2800_init_rx_filter (struct rt2x00_dev *rt2x00dev,bool bw40,u8 filter_target) {
@@ -4588,6 +4597,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev) rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E))rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev)
@@ -4646,6 +4657,8 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_read (rt2x00dev,29 , &rfcsr);rt2x00_set_field8 (&rfcsr,RFCSR29_RSSI_GAIN ,3 );rt2800_rfcsr_write (rt2x00dev,29 , rfcsr); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_3352 (struct rt2x00_dev *rt2x00dev)
@@ -4717,6 +4730,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,63 ,0x00 );rt2800_rx_filter_calibration (rt2x00dev); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_3390 (struct rt2x00_dev *rt2x00dev)
@@ -4766,6 +4781,8 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)if (rt2x00_rt_rev_lt (rt2x00dev,RT3390 ,REV_RT3390E ))rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev)
@@ -4822,6 +4839,8 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)rt2800_register_write (rt2x00dev,LDO_CFG0 , reg);rt2800_rx_filter_calibration (rt2x00dev); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_5390 (struct rt2x00_dev *rt2x00dev)
@@ -4910,6 +4929,8 @@ static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,63 ,0x00 );rt2800_normal_mode_setup_5xxx (rt2x00dev); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_5392 (struct rt2x00_dev *rt2x00dev)
@@ -4977,6 +4998,8 @@ static void rt2800_init_rfcsr_5392(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,63 ,0x07 );rt2800_normal_mode_setup_5xxx (rt2x00dev); + +rt2800_led_open_drain_enable (rt2x00dev); }static void rt2800_init_rfcsr_5592 (struct rt2x00_dev *rt2x00dev)
@@ -5019,6 +5042,8 @@ static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev)if (rt2x00_rt_rev_lt (rt2x00dev,RT5592 ,REV_RT5592C ))rt2800_rfcsr_write (rt2x00dev,27 ,0x03 ); + +rt2800_led_open_drain_enable (rt2x00dev); }static int rt2800_init_rfcsr (struct rt2x00_dev *rt2x00dev)
@@ -5077,10 +5102,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)return 0 ; } -rt2800_register_read (rt2x00dev,OPT_14_CSR , ®); -rt2x00_set_field32 (®,OPT_14_CSR_BIT0 ,1 ); -rt2800_register_write (rt2x00dev,OPT_14_CSR , reg); -if (!rt2x00_rt (rt2x00dev,RT5390 ) && !rt2x00_rt (rt2x00dev,RT5392 )) {u8 min_gain =rt2x00_rt (rt2x00dev,RT3070 ) ?1 :2 ;
Signature · 1 line
1.7.4.4
PATCH v2 10/11 rt2800: add rt2800_normal_mode_setup_3xxx subroutine
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
--- drivers/net/wireless/rt2x00/rt2800lib.c | 154 +++++++++++++++--------------- 1 files changed, 77 insertions(+), 77 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +77 -77
@@ -4465,6 +4465,77 @@ static void rt2800_rx_filter_calibration(struct rt2x00_dev *rt2x00dev)rt2800_bbp_write (rt2x00dev,4 , bbp); } +static void rt2800_normal_mode_setup_3xxx (struct rt2x00_dev *rt2x00dev) +{ +struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; +u8 min_gain, rfcsr, bbp; +u16 eeprom; + +rt2800_rfcsr_read (rt2x00dev,17 , &rfcsr); + +rt2x00_set_field8 (&rfcsr,RFCSR17_TX_LO1_EN ,0 ); +if (rt2x00_rt (rt2x00dev,RT3070 ) || +rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) || +rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E ) || +rt2x00_rt_rev_lt (rt2x00dev,RT3390 ,REV_RT3390E )) { +if (!test_bit (CAPABILITY_EXTERNAL_LNA_BG , &rt2x00dev->cap_flags)) +rt2x00_set_field8 (&rfcsr,RFCSR17_R ,1 ); + } + + min_gain =rt2x00_rt (rt2x00dev,RT3070 ) ?1 :2 ; +if (drv_data->txmixer_gain_24g >= min_gain) { +rt2x00_set_field8 (&rfcsr,RFCSR17_TXMIXER_GAIN , + drv_data->txmixer_gain_24g); + } + +rt2800_rfcsr_write (rt2x00dev,17 , rfcsr); + +if (rt2x00_rt (rt2x00dev,RT3090 )) { +/* Turn off unused DAC1 and ADC1 to reduce power consumption */ +rt2800_bbp_read (rt2x00dev,138 , &bbp); +rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF0 , &eeprom); +if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_RXPATH ) ==1 ) +rt2x00_set_field8 (&bbp,BBP138_RX_ADC1 ,0 ); +if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_TXPATH ) ==1 ) +rt2x00_set_field8 (&bbp,BBP138_TX_DAC1 ,1 ); +rt2800_bbp_write (rt2x00dev,138 , bbp); + } + +if (rt2x00_rt (rt2x00dev,RT3070 )) { +rt2800_rfcsr_read (rt2x00dev,27 , &rfcsr); +if (rt2x00_rt_rev_lt (rt2x00dev,RT3070 ,REV_RT3070F )) +rt2x00_set_field8 (&rfcsr,RFCSR27_R1 ,3 ); +else +rt2x00_set_field8 (&rfcsr,RFCSR27_R1 ,0 ); +rt2x00_set_field8 (&rfcsr,RFCSR27_R2 ,0 ); +rt2x00_set_field8 (&rfcsr,RFCSR27_R3 ,0 ); +rt2x00_set_field8 (&rfcsr,RFCSR27_R4 ,0 ); +rt2800_rfcsr_write (rt2x00dev,27 , rfcsr); + }else if (rt2x00_rt (rt2x00dev,RT3071 ) || +rt2x00_rt (rt2x00dev,RT3090 ) || +rt2x00_rt (rt2x00dev,RT3390 )) { +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 ,1 ); +rt2x00_set_field8 (&rfcsr,RFCSR1_TX1_PD ,1 ); +rt2800_rfcsr_write (rt2x00dev,1 , rfcsr); + +rt2800_rfcsr_read (rt2x00dev,15 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR15_TX_LO2_EN ,0 ); +rt2800_rfcsr_write (rt2x00dev,15 , rfcsr); + +rt2800_rfcsr_read (rt2x00dev,20 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR20_RX_LO1_EN ,0 ); +rt2800_rfcsr_write (rt2x00dev,20 , rfcsr); + +rt2800_rfcsr_read (rt2x00dev,21 , &rfcsr); +rt2x00_set_field8 (&rfcsr,RFCSR21_RX_LO2_EN ,0 ); +rt2800_rfcsr_write (rt2x00dev,21 , rfcsr); + } +} +static void rt2800_normal_mode_setup_5xxx (struct rt2x00_dev *rt2x00dev) {u8 reg;
@@ -4599,6 +4670,7 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,27 ,0x03 );rt2800_led_open_drain_enable (rt2x00dev); +rt2800_normal_mode_setup_3xxx (rt2x00dev); }static void rt2800_init_rfcsr_3290 (struct rt2x00_dev *rt2x00dev)
@@ -4659,6 +4731,7 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,29 , rfcsr);rt2800_led_open_drain_enable (rt2x00dev); +rt2800_normal_mode_setup_3xxx (rt2x00dev); }static void rt2800_init_rfcsr_3352 (struct rt2x00_dev *rt2x00dev)
@@ -4730,8 +4803,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,63 ,0x00 );rt2800_rx_filter_calibration (rt2x00dev); -rt2800_led_open_drain_enable (rt2x00dev); +rt2800_normal_mode_setup_3xxx (rt2x00dev); }static void rt2800_init_rfcsr_3390 (struct rt2x00_dev *rt2x00dev)
@@ -4783,6 +4856,7 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)rt2800_rfcsr_write (rt2x00dev,27 ,0x03 );rt2800_led_open_drain_enable (rt2x00dev); +rt2800_normal_mode_setup_3xxx (rt2x00dev); }static void rt2800_init_rfcsr_3572 (struct rt2x00_dev *rt2x00dev)
@@ -4839,8 +4913,8 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)rt2800_register_write (rt2x00dev,LDO_CFG0 , reg);rt2800_rx_filter_calibration (rt2x00dev); -rt2800_led_open_drain_enable (rt2x00dev); +rt2800_normal_mode_setup_3xxx (rt2x00dev); }static void rt2800_init_rfcsr_5390 (struct rt2x00_dev *rt2x00dev)
@@ -5048,12 +5122,6 @@ static void rt2800_init_rfcsr_5592(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; -u16 eeprom; - if (!rt2x00_rt(rt2x00dev, RT3070) && !rt2x00_rt(rt2x00dev, RT3071) && !rt2x00_rt(rt2x00dev, RT3090) &&
@@ -5102,75 +5170,7 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)return 0 ; } -if (!rt2x00_rt (rt2x00dev,RT5390 ) && - !rt2x00_rt (rt2x00dev,RT5392 )) { -u8 min_gain =rt2x00_rt (rt2x00dev,RT3070 ) ?1 :2 ; - -rt2800_rfcsr_read (rt2x00dev,17 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR17_TX_LO1_EN ,0 ); -if (rt2x00_rt (rt2x00dev,RT3070 ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3071 ,REV_RT3071E ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3090 ,REV_RT3090E ) || -rt2x00_rt_rev_lt (rt2x00dev,RT3390 ,REV_RT3390E )) { -if (!test_bit (CAPABILITY_EXTERNAL_LNA_BG , - &rt2x00dev->cap_flags)) -rt2x00_set_field8 (&rfcsr,RFCSR17_R ,1 ); - } -if (drv_data->txmixer_gain_24g >= min_gain) { -rt2x00_set_field8 (&rfcsr,RFCSR17_TXMIXER_GAIN , - drv_data->txmixer_gain_24g); - } -rt2800_rfcsr_write (rt2x00dev,17 , rfcsr); - } - -if (rt2x00_rt (rt2x00dev,RT3090 )) { -/* Turn off unused DAC1 and ADC1 to reduce power consumption */ -rt2800_bbp_read (rt2x00dev,138 , &bbp); -rt2x00_eeprom_read (rt2x00dev,EEPROM_NIC_CONF0 , &eeprom); -if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_RXPATH ) ==1 ) -rt2x00_set_field8 (&bbp,BBP138_RX_ADC1 ,0 ); -if (rt2x00_get_field16 (eeprom,EEPROM_NIC_CONF0_TXPATH ) ==1 ) -rt2x00_set_field8 (&bbp,BBP138_TX_DAC1 ,1 ); -rt2800_bbp_write (rt2x00dev,138 , bbp); - } - -if (rt2x00_rt (rt2x00dev,RT3071 ) || -rt2x00_rt (rt2x00dev,RT3090 ) || -rt2x00_rt (rt2x00dev,RT3390 )) { -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 ,1 ); -rt2x00_set_field8 (&rfcsr,RFCSR1_TX1_PD ,1 ); -rt2800_rfcsr_write (rt2x00dev,1 , rfcsr); - -rt2800_rfcsr_read (rt2x00dev,15 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR15_TX_LO2_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,15 , rfcsr); - -rt2800_rfcsr_read (rt2x00dev,20 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR20_RX_LO1_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,20 , rfcsr); - -rt2800_rfcsr_read (rt2x00dev,21 , &rfcsr); -rt2x00_set_field8 (&rfcsr,RFCSR21_RX_LO2_EN ,0 ); -rt2800_rfcsr_write (rt2x00dev,21 , rfcsr); - } - -if (rt2x00_rt (rt2x00dev,RT3070 )) { -rt2800_rfcsr_read (rt2x00dev,27 , &rfcsr); -if (rt2x00_rt_rev_lt (rt2x00dev,RT3070 ,REV_RT3070F )) -rt2x00_set_field8 (&rfcsr,RFCSR27_R1 ,3 ); -else -rt2x00_set_field8 (&rfcsr,RFCSR27_R1 ,0 ); -rt2x00_set_field8 (&rfcsr,RFCSR27_R2 ,0 ); -rt2x00_set_field8 (&rfcsr,RFCSR27_R3 ,0 ); -rt2x00_set_field8 (&rfcsr,RFCSR27_R4 ,0 ); -rt2800_rfcsr_write (rt2x00dev,27 , rfcsr); - } - -return 0 ; +return 0 ; }int rt2800_enable_radio (struct rt2x00_dev *rt2x00dev)
Signature · 1 line
1.7.4.4
Re: [PATCH v2 10/11] rt2800: add rt2800_normal_mode_setup_3xxx subroutine
Quoted 3 lines · On Wed, Apr 17, 2013 at 2:08 PM, <[email protected]> wrote:
From: Stanislaw Gruszka <[email protected]>
Signed-off-by Stanislaw Gruszka <[email protected]>
---
Gertjan
PATCH v2 11/11 rt2800: cleanup rt2800_init_rfcsr
In reply to [email protected]From: Stanislaw Gruszka <[email protected]>
This procedure is simple switch now and return no error any longer.
--- drivers/net/wireless/rt2x00/rt2800lib.c | 27 ++++++--------------------- 1 files changed, 6 insertions(+), 21 deletions(-)
drivers/net/wireless/rt2x00/rt2800lib.c +6 -21
@@ -5120,25 +5120,11 @@ static void rt2800_init_rfcsr_5592(struct rt2x00_dev *rt2x00dev)rt2800_led_open_drain_enable (rt2x00dev); } -static int rt2800_init_rfcsr (struct rt2x00_dev *rt2x00dev) +static void rt2800_init_rfcsr (struct rt2x00_dev *rt2x00dev) { -if (!rt2x00_rt (rt2x00dev,RT3070 ) && - !rt2x00_rt (rt2x00dev,RT3071 ) && - !rt2x00_rt (rt2x00dev,RT3090 ) && - !rt2x00_rt (rt2x00dev,RT3290 ) && - !rt2x00_rt (rt2x00dev,RT3352 ) && - !rt2x00_rt (rt2x00dev,RT3390 ) && - !rt2x00_rt (rt2x00dev,RT3572 ) && - !rt2x00_rt (rt2x00dev,RT5390 ) && - !rt2x00_rt (rt2x00dev,RT5392 ) && - !rt2x00_rt (rt2x00dev,RT5392 ) && - !rt2x00_rt (rt2x00dev,RT5592 ) && - !rt2800_is_305x_soc (rt2x00dev)) -return 0 ; -if (rt2800_is_305x_soc (rt2x00dev)) {rt2800_init_rfcsr_305x_soc (rt2x00dev); -return 0 ; +return ; }switch (rt2x00dev->chip.rt) {
@@ -5167,10 +5153,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)break ;case RT5592 :rt2800_init_rfcsr_5592 (rt2x00dev); -return 0 ; +break ; } - -return 0 ; }int rt2800_enable_radio (struct rt2x00_dev *rt2x00dev)
@@ -5196,10 +5180,11 @@ int rt2800_enable_radio(struct rt2x00_dev *rt2x00dev) }msleep (1 ); -if (unlikely (rt2800_init_bbp (rt2x00dev) || -rt2800_init_rfcsr (rt2x00dev))) +if (unlikely (rt2800_init_bbp (rt2x00dev)))return -EIO ; +rt2800_init_rfcsr (rt2x00dev); + if (rt2x00_is_usb(rt2x00dev) && (rt2x00_rt(rt2x00dev, RT3070) || rt2x00_rt(rt2x00dev, RT3071) ||
Signature · 1 line
1.7.4.4