linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/11] rt2800: cleanup rfcsr init procedures
@ 2013-04-09 15:05 stf_xl
  2013-04-09 15:05 ` [PATCH 01/11] rt2800: merge 5xxx normal mode setup stf_xl
                   ` (10 more replies)
  0 siblings, 11 replies; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users

This patch set move code from common RFCSR init procedure to individual
chipset procedures. That make code easier to maintain and modify.

 rt2800lib.c |  548 ++++++++++++++++++++++++++++++------------------------------
 1 file changed, 280 insertions(+), 268 deletions(-)


^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH 01/11] rt2800: merge 5xxx normal mode setup
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <3B6ED6A8-A24C-4F0C-941C-7A24F55172DA@gmail.com>
  2013-04-09 15:05 ` [PATCH 02/11] rt2800: move rf init calibration code stf_xl
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Merge code which program the same registes at the end of rfcsr
initialization for 5592, 5392 and 5390 chips.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   91 ++++++++++++-------------------
 1 files changed, 34 insertions(+), 57 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 7deac4d..d092b47 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -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;
+
+	rt2800_bbp_read(rt2x00dev, 138, &reg);
+	/*  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(&reg, BBP138_RX_ADC1, 0);
+	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
+		rt2x00_set_field8(&reg, BBP138_TX_DAC1, 1);
+	rt2800_bbp_write(rt2x00dev, 138, reg);
+
+	rt2800_rfcsr_read(rt2x00dev, 38, &reg);
+	rt2x00_set_field8(&reg, RFCSR38_RX_LO1_EN, 0);
+	rt2800_rfcsr_write(rt2x00dev, 38, reg);
+
+	rt2800_rfcsr_read(rt2x00dev, 39, &reg);
+	rt2x00_set_field8(&reg, RFCSR39_RX_LO2_EN, 0);
+	rt2800_rfcsr_write(rt2x00dev, 39, reg);
+
+	rt2800_bbp4_mac_if_ctrl(rt2x00dev);
+
+	rt2800_rfcsr_read(rt2x00dev, 30, &reg);
+	rt2x00_set_field8(&reg, 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, &reg);
-
-	/*  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(&reg, BBP138_RX_ADC1, 0);
-	if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
-		rt2x00_set_field8(&reg, 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, &reg);
-	rt2x00_set_field8(&reg, RFCSR38_RX_LO1_EN, 0);
-	rt2800_rfcsr_write(rt2x00dev, 38, reg);
-
-	rt2800_rfcsr_read(rt2x00dev, 39, &reg);
-	rt2x00_set_field8(&reg, RFCSR39_RX_LO2_EN, 0);
-	rt2800_rfcsr_write(rt2x00dev, 39, reg);
-
-	rt2800_bbp4_mac_if_ctrl(rt2x00dev);
-
-	rt2800_rfcsr_read(rt2x00dev, 30, &reg);
-	rt2x00_set_field8(&reg, 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)
@@ -5051,20 +5058,6 @@ 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);
-
-		/*  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(&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)) {
@@ -5107,22 +5100,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;
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 02/11] rt2800: move rf init calibration code
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
  2013-04-09 15:05 ` [PATCH 01/11] rt2800: merge 5xxx normal mode setup stf_xl
@ 2013-04-09 15:05 ` stf_xl
  2013-04-10  7:12   ` Gabor Juhos
       [not found]   ` <F57510E7-8DE6-4BA4-8256-2144DDE5B30D@gmail.com>
  2013-04-09 15:05 ` [PATCH 03/11] rt2800: move RFCSR29_RSSI_GAIN to 3290 specific rfcsr init stf_xl
                   ` (8 subsequent siblings)
  10 siblings, 2 replies; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Add separate functions for rf init calibration code and use it in
proper init rf routines.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   53 ++++++++++++++++++-------------
 1 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index d092b47..334973a 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4425,6 +4425,18 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
 	rt2800_rfcsr_write(rt2x00dev, 30, reg);
 }
 
+static void rt2800_rf_init_calibration_53xx(struct rt2x00_dev *rt2x00dev)
+{
+	u8 rfcsr;
+
+	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);
+}
+
 static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
 {
 	rt2800_rfcsr_write(rt2x00dev, 0, 0x50);
@@ -4463,6 +4475,19 @@ static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
 
 static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
 {
+	u8 rfcsr;
+
+	/*
+	 * Init RF calibration.
+	 * XXX: vendor driver do this only for 3070 ?
+	 */
+	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);
+
 	rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
 	rt2800_rfcsr_write(rt2x00dev, 5, 0x03);
 	rt2800_rfcsr_write(rt2x00dev, 6, 0x02);
@@ -4486,6 +4511,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_53xx(rt2x00dev);
+
 	rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
 	rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
 	rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
@@ -4674,6 +4701,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_53xx(rt2x00dev);
+
 	rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
 	rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
 	rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
@@ -4760,6 +4789,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_53xx(rt2x00dev);
+
 	rt2800_rfcsr_write(rt2x00dev, 1, 0x17);
 	rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
 	rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
@@ -4882,28 +4913,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;
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 03/11] rt2800: move RFCSR29_RSSI_GAIN to 3290 specific rfcsr init
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
  2013-04-09 15:05 ` [PATCH 01/11] rt2800: merge 5xxx normal mode setup stf_xl
  2013-04-09 15:05 ` [PATCH 02/11] rt2800: move rf init calibration code stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <413EC3EA-0BB4-42CC-A95A-52468DC35C67@gmail.com>
  2013-04-09 15:05 ` [PATCH 04/11] rt2800: move 30xx common rf init code stf_xl
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 334973a..085b60c 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4511,6 +4511,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_53xx(rt2x00dev);
 
 	rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
@@ -4559,6 +4561,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)
@@ -5103,12 +5109,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;
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 04/11] rt2800: move 30xx common rf init code
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (2 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 03/11] rt2800: move RFCSR29_RSSI_GAIN to 3290 specific rfcsr init stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <A636A59B-CC0A-41E2-98A8-0165993938FA@gmail.com>
  2013-04-09 15:05 ` [PATCH 05/11] rt2800: move GPIO_SWITCH setup to 3390 specific rfcsr init stf_xl
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   62 ++++++++++++++++--------------
 1 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 085b60c..216ceb6 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4476,6 +4476,8 @@ 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;
 
 	/*
 	 * Init RF calibration.
@@ -4507,6 +4509,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, &reg);
+		rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
+		rt2x00_set_field32(&reg, 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, &reg);
+		rt2x00_set_field32(&reg, 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(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
+			else
+				rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
+		}
+		rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
+
+		rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
+		rt2x00_set_field32(&reg, GPIO_SWITCH_5, 0);
+		rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg);
+	}
 }
 
 static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
@@ -4903,7 +4935,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 	u8 rfcsr;
 	u8 bbp;
 	u32 reg;
-	u16 eeprom;
 
 	if (!rt2x00_rt(rt2x00dev, RT3070) &&
 	    !rt2x00_rt(rt2x00dev, RT3071) &&
@@ -4953,35 +4984,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, &reg);
-		rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
-		rt2x00_set_field32(&reg, 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, &reg);
-		rt2x00_set_field32(&reg, 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(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
-			else
-				rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
-		}
-		rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
 
-		rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
-		rt2x00_set_field32(&reg, 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, &reg);
 		rt2x00_set_field32(&reg, GPIO_SWITCH_5, 0);
 		rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 05/11] rt2800: move GPIO_SWITCH setup to 3390 specific rfcsr init
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (3 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 04/11] rt2800: move 30xx common rf init code stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <5FA86BE2-7773-4D09-B891-6B1C80DCED72@gmail.com>
  2013-04-09 15:05 ` [PATCH 06/11] rt2800: move RFCSR6_R2 & LDO_CFG0 setup to 3572 " stf_xl
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 216ceb6..83554da 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4668,6 +4668,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
 
 static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)
 {
+	u32 reg;
+
 	rt2800_rfcsr_write(rt2x00dev, 0, 0xa0);
 	rt2800_rfcsr_write(rt2x00dev, 1, 0xe1);
 	rt2800_rfcsr_write(rt2x00dev, 2, 0xf1);
@@ -4700,6 +4702,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, &reg);
+	rt2x00_set_field32(&reg, GPIO_SWITCH_5, 0);
+	rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg);
 }
 
 static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)
@@ -4985,11 +4991,7 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 	}
 
 
-	if (rt2x00_rt(rt2x00dev, RT3390)) {
-		rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
-		rt2x00_set_field32(&reg, 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);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 06/11] rt2800: move RFCSR6_R2 & LDO_CFG0 setup to 3572 specific rfcsr init
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (4 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 05/11] rt2800: move GPIO_SWITCH setup to 3390 specific rfcsr init stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <66918CCA-AAE0-47BF-B989-58A019810AC7@gmail.com>
  2013-04-09 15:05 ` [PATCH 07/11] rt2800: add rt2800_rx_filter_calibration procedure stf_xl
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   34 +++++++++++++++---------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 83554da..7130040 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4710,6 +4710,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_rfcsr_write(rt2x00dev, 0, 0x70);
 	rt2800_rfcsr_write(rt2x00dev, 1, 0x81);
 	rt2800_rfcsr_write(rt2x00dev, 2, 0xf1);
@@ -4741,6 +4744,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, &reg);
+	rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
+	rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
+	rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
+	msleep(1);
+	rt2800_register_read(rt2x00dev, LDO_CFG0, &reg);
+	rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
+	rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
+	rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
 }
 
 static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)
@@ -4990,23 +5007,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, &reg);
-		rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
-		rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
-		rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
-		msleep(1);
-		rt2800_register_read(rt2x00dev, LDO_CFG0, &reg);
-		rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
-		rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
-		rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
-	}
-
 	/*
 	 * Set RX Filter calibration for 20MHz and 40MHz
 	 */
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 07/11] rt2800: add rt2800_rx_filter_calibration procedure
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (5 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 06/11] rt2800: move RFCSR6_R2 & LDO_CFG0 setup to 3572 " stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <948863C1-A75D-4625-A880-5589875479D0@gmail.com>
  2013-04-09 15:05 ` [PATCH 08/11] rt2800: move RF_R27 setup to individual rfcsr init subroutines stf_xl
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Add procedure for both bands filter calibration and use it on individual
chipset init rfcsr subroutines.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |  106 +++++++++++++++++--------------
 1 files changed, 59 insertions(+), 47 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 7130040..df8760f 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -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);
 
@@ -4396,6 +4397,52 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,
 	return rfcsr24;
 }
 
+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;
@@ -4539,6 +4586,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
 		rt2x00_set_field32(&reg, 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)
@@ -4597,6 +4646,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_rx_filter_calibration(rt2x00dev);
 }
 
 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
@@ -4664,6 +4715,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)
@@ -4706,6 +4759,8 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)
 	rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
 	rt2x00_set_field32(&reg, 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)
@@ -4758,6 +4813,8 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)
 	rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
 	rt2x00_set_field32(&reg, 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)
@@ -4956,7 +5013,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 {
 	struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
 	u8 rfcsr;
-	u8 bbp;
 	u32 reg;
 
 	if (!rt2x00_rt(rt2x00dev, RT3070) &&
@@ -5007,50 +5063,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) ||
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 08/11] rt2800: move RF_R27 setup to individual rfcsr init subroutines
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (6 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 07/11] rt2800: add rt2800_rx_filter_calibration procedure stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <742363D2-2E4F-40E5-81BB-69252F998D43@gmail.com>
  2013-04-09 15:05 ` [PATCH 09/11] rt2800: add rt2800_led_open_drain_enable subroutine stf_xl
                   ` (2 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index df8760f..fe0df88 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4588,6 +4588,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)
@@ -4761,6 +4766,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)
@@ -5007,6 +5015,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)
@@ -5063,13 +5074,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, &reg);
 	rt2x00_set_field32(&reg, OPT_14_CSR_BIT0, 1);
 	rt2800_register_write(rt2x00dev, OPT_14_CSR, reg);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 09/11] rt2800: add rt2800_led_open_drain_enable subroutine
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (7 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 08/11] rt2800: move RF_R27 setup to individual rfcsr init subroutines stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <0E1FF2EE-1777-42C7-9052-51895C784968@gmail.com>
  2013-04-09 15:05 ` [PATCH 10/11] rt2800: add rt2800_normal_mode_setup_3xxx subroutine stf_xl
  2013-04-09 15:05 ` [PATCH 11/11] rt2800: cleanup rt2800_init_rfcsr stf_xl
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index fe0df88..009fe47 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -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, &reg);
+	rt2x00_set_field32(&reg, 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)
 {
@@ -4593,6 +4602,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)
@@ -4653,6 +4664,8 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
 	rt2800_rfcsr_write(rt2x00dev, 29, rfcsr);
 
 	rt2800_rx_filter_calibration(rt2x00dev);
+
+	rt2800_led_open_drain_enable(rt2x00dev);
 }
 
 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
@@ -4722,6 +4735,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)
@@ -4769,6 +4784,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)
@@ -4823,6 +4840,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)
@@ -4911,6 +4930,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)
@@ -4978,6 +4999,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)
@@ -5018,6 +5041,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)
@@ -5074,10 +5099,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 		return 0;
 	}
 
-	rt2800_register_read(rt2x00dev, OPT_14_CSR, &reg);
-	rt2x00_set_field32(&reg, OPT_14_CSR_BIT0, 1);
-	rt2800_register_write(rt2x00dev, OPT_14_CSR, reg);
-
 	if (!rt2x00_rt(rt2x00dev, RT5390) &&
 	    !rt2x00_rt(rt2x00dev, RT5392)) {
 		rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 10/11] rt2800: add rt2800_normal_mode_setup_3xxx subroutine
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (8 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 09/11] rt2800: add rt2800_led_open_drain_enable subroutine stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <D7DE287D-EED7-4657-B388-ADCCDB823A8B@gmail.com>
  2013-04-09 15:05 ` [PATCH 11/11] rt2800: cleanup rt2800_init_rfcsr stf_xl
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |  114 ++++++++++++++++---------------
 1 files changed, 58 insertions(+), 56 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 009fe47..f31b9b9 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -4452,6 +4452,59 @@ 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 rfcsr;
+
+	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);
+	}
+	rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
+			  drv_data->txmixer_gain_24g);
+	rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
+
+	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);
+	} else 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);
+	}
+}
+
 static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
 {
 	u8 reg;
@@ -4604,6 +4657,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)
@@ -4664,8 +4718,8 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
 	rt2800_rfcsr_write(rt2x00dev, 29, rfcsr);
 
 	rt2800_rx_filter_calibration(rt2x00dev);
-
 	rt2800_led_open_drain_enable(rt2x00dev);
+	rt2800_normal_mode_setup_3xxx(rt2x00dev);
 }
 
 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
@@ -4735,8 +4789,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)
@@ -4786,6 +4840,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)
@@ -4840,8 +4895,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)
@@ -5099,59 +5154,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 		return 0;
 	}
 
-	if (!rt2x00_rt(rt2x00dev, RT5390) &&
-	    !rt2x00_rt(rt2x00dev, RT5392)) {
-		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);
-		}
-		rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
-				  drv_data->txmixer_gain_24g);
-		rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
-	}
-
-	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;
 }
 
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 11/11] rt2800: cleanup rt2800_init_rfcsr
  2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
                   ` (9 preceding siblings ...)
  2013-04-09 15:05 ` [PATCH 10/11] rt2800: add rt2800_normal_mode_setup_3xxx subroutine stf_xl
@ 2013-04-09 15:05 ` stf_xl
       [not found]   ` <35BCCCCF-97E2-42EE-839F-89DB7542719B@gmail.com>
  10 siblings, 1 reply; 26+ messages in thread
From: stf_xl @ 2013-04-09 15:05 UTC (permalink / raw)
  To: John W. Linville"; +Cc: linux-wireless, users, Stanislaw Gruszka

From: Stanislaw Gruszka <stf_xl@wp.pl>

This procedure is simple switch now and return no error any longer.

Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   31 ++++++-------------------------
 1 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index f31b9b9..b084e90 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -5100,29 +5100,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)
 {
-	struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
-	u8 rfcsr;
-	u32 reg;
-
-	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) {
@@ -5151,10 +5133,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)
@@ -5180,10 +5160,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) ||
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH 02/11] rt2800: move rf init calibration code
  2013-04-09 15:05 ` [PATCH 02/11] rt2800: move rf init calibration code stf_xl
@ 2013-04-10  7:12   ` Gabor Juhos
  2013-04-10 15:15     ` Stanislaw Gruszka
       [not found]   ` <F57510E7-8DE6-4BA4-8256-2144DDE5B30D@gmail.com>
  1 sibling, 1 reply; 26+ messages in thread
From: Gabor Juhos @ 2013-04-10  7:12 UTC (permalink / raw)
  To: stf_xl; +Cc: linville, linux-wireless, users

Hi Stanislaw,

> From: Stanislaw Gruszka <stf_xl@wp.pl>
> 
> Add separate functions for rf init calibration code and use it in
> proper init rf routines.
> 
> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
> ---
>  drivers/net/wireless/rt2x00/rt2800lib.c |   53 ++++++++++++++++++-------------
>  1 files changed, 31 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index d092b47..334973a 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -4425,6 +4425,18 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
>  	rt2800_rfcsr_write(rt2x00dev, 30, reg);
>  }
>  
> +static void rt2800_rf_init_calibration_53xx(struct rt2x00_dev *rt2x00dev)
> +{
> +	u8 rfcsr;
> +
> +	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);
> +}
> +
>  static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
>  {
>  	rt2800_rfcsr_write(rt2x00dev, 0, 0x50);
> @@ -4463,6 +4475,19 @@ static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
>  
>  static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
>  {
> +	u8 rfcsr;
> +
> +	/*
> +	 * Init RF calibration.
> +	 * XXX: vendor driver do this only for 3070 ?
> +	 */
> +	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);
> +
>  	rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
>  	rt2800_rfcsr_write(rt2x00dev, 5, 0x03);
>  	rt2800_rfcsr_write(rt2x00dev, 6, 0x02);
> @@ -4486,6 +4511,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_53xx(rt2x00dev);
> +
>  	rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
>  	rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
>  	rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
> @@ -4674,6 +4701,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_53xx(rt2x00dev);
> +
>  	rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
>  	rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
>  	rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
> @@ -4760,6 +4789,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_53xx(rt2x00dev);
> +
>  	rt2800_rfcsr_write(rt2x00dev, 1, 0x17);
>  	rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
>  	rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
> @@ -4882,28 +4913,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);
> -	}

The code in the else branch is required by the 305x_soc devices. However the
change moves it into the 'rt2800_init_rfcsr_30xx' function and that is only
called for RT3070, RT3071, RT3090.

Either add the code into the 'rt2800_init_rfcsr_305x_soc function' as well or
create a helper function and call that from 'rt2800_init_rfcsr_30xx' and from
'rt2800_init_rfcsr_305x_soc'.

> -
>  	if (rt2800_is_305x_soc(rt2x00dev)) {
>  		rt2800_init_rfcsr_305x_soc(rt2x00dev);
>  		return 0;
> 

-Gabor

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 02/11] rt2800: move rf init calibration code
  2013-04-10  7:12   ` Gabor Juhos
@ 2013-04-10 15:15     ` Stanislaw Gruszka
  0 siblings, 0 replies; 26+ messages in thread
From: Stanislaw Gruszka @ 2013-04-10 15:15 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: linville, linux-wireless, users

On Wed, Apr 10, 2013 at 09:12:22AM +0200, Gabor Juhos wrote:
> > -	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);
> > -	}
> 
> The code in the else branch is required by the 305x_soc devices. However the
> change moves it into the 'rt2800_init_rfcsr_30xx' function and that is only
> called for RT3070, RT3071, RT3090.
> 
> Either add the code into the 'rt2800_init_rfcsr_305x_soc function' as well or
> create a helper function and call that from 'rt2800_init_rfcsr_30xx' and from
> 'rt2800_init_rfcsr_305x_soc'.

Right. 3352 and 3572 need that too. I'll post v2 shortly.

Thanks
Stanislaw
 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 02/11] rt2800: move rf init calibration code
       [not found]   ` <F57510E7-8DE6-4BA4-8256-2144DDE5B30D@gmail.com>
@ 2013-04-14 20:14     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:14 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Some more comments on top of those of Gabor.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Add separate functions for rf init calibration code and use it in
>> proper init rf routines.
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   53 ++++++++++++++++++-------------
>> 1 files changed, 31 insertions(+), 22 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index d092b47..334973a 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4425,6 +4425,18 @@ static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
>>   rt2800_rfcsr_write(rt2x00dev, 30, reg);
>> }
>> 
>> +static void rt2800_rf_init_calibration_53xx(struct rt2x00_dev *rt2x00dev)
> 
> The name of the function is't great, as you call it from the RT3290 setup code as well. How about generalizing it to a rt2800_init_calibration, which also takes an RF CSR number and a value bitmask as parameters, which then can also be used for the other chipsets?
> 
>> +{
>> +    u8 rfcsr;
>> +
>> +    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);
>> +}
>> +
>> static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
>> {
>>   rt2800_rfcsr_write(rt2x00dev, 0, 0x50);
>> @@ -4463,6 +4475,19 @@ static void rt2800_init_rfcsr_305x_soc(struct rt2x00_dev *rt2x00dev)
>> 
>> static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
>> {
>> +    u8 rfcsr;
>> +
>> +    /*
>> +     * Init RF calibration.
>> +     * XXX: vendor driver do this only for 3070 ?
>> +     */
>> +    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);
>> +
>>   rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
>>   rt2800_rfcsr_write(rt2x00dev, 5, 0x03);
>>   rt2800_rfcsr_write(rt2x00dev, 6, 0x02);
>> @@ -4486,6 +4511,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_53xx(rt2x00dev);
>> +
>>   rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
>>   rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
>>   rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
>> @@ -4674,6 +4701,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_53xx(rt2x00dev);
>> +
>>   rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
>>   rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
>>   rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
>> @@ -4760,6 +4789,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_53xx(rt2x00dev);
>> +
>>   rt2800_rfcsr_write(rt2x00dev, 1, 0x17);
>>   rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
>>   rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
>> @@ -4882,28 +4913,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);
>> -    }
>> -
> 
> As Gabor already mentioned, this else branch is used for other chipsets (not just 305x_soc, but also RT35xx, RT55xx).
> 
>>   if (rt2800_is_305x_soc(rt2x00dev)) {
>>       rt2800_init_rfcsr_305x_soc(rt2x00dev);
>>       return 0;
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 03/11] rt2800: move RFCSR29_RSSI_GAIN to 3290 specific rfcsr init
       [not found]   ` <413EC3EA-0BB4-42CC-A95A-52468DC35C67@gmail.com>
@ 2013-04-14 20:15     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:15 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)


> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   12 ++++++------
>> 1 files changed, 6 insertions(+), 6 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 334973a..085b60c 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4511,6 +4511,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_53xx(rt2x00dev);
>> 
>>   rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
>> @@ -4559,6 +4561,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)
>> @@ -5103,12 +5109,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;
>> }
>> 
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 04/11] rt2800: move 30xx common rf init code
       [not found]   ` <A636A59B-CC0A-41E2-98A8-0165993938FA@gmail.com>
@ 2013-04-14 20:15     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:15 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)


> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   62 ++++++++++++++++--------------
>> 1 files changed, 33 insertions(+), 29 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 085b60c..216ceb6 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4476,6 +4476,8 @@ 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;
>> 
>>   /*
>>    * Init RF calibration.
>> @@ -4507,6 +4509,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, &reg);
>> +        rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>> +        rt2x00_set_field32(&reg, 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, &reg);
>> +        rt2x00_set_field32(&reg, 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(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
>> +            else
>> +                rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
>> +        }
>> +        rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
>> +
>> +        rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
>> +        rt2x00_set_field32(&reg, GPIO_SWITCH_5, 0);
>> +        rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg);
>> +    }
>> }
>> 
>> static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
>> @@ -4903,7 +4935,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
>>   u8 rfcsr;
>>   u8 bbp;
>>   u32 reg;
>> -    u16 eeprom;
>> 
>>   if (!rt2x00_rt(rt2x00dev, RT3070) &&
>>       !rt2x00_rt(rt2x00dev, RT3071) &&
>> @@ -4953,35 +4984,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, &reg);
>> -        rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>> -        rt2x00_set_field32(&reg, 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, &reg);
>> -        rt2x00_set_field32(&reg, 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(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
>> -            else
>> -                rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
>> -        }
>> -        rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
>> 
>> -        rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
>> -        rt2x00_set_field32(&reg, 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, &reg);
>>       rt2x00_set_field32(&reg, GPIO_SWITCH_5, 0);
>>       rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg);
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 05/11] rt2800: move GPIO_SWITCH setup to 3390 specific rfcsr init
       [not found]   ` <5FA86BE2-7773-4D09-B891-6B1C80DCED72@gmail.com>
@ 2013-04-14 20:16     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:16 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)


> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   12 +++++++-----
>> 1 files changed, 7 insertions(+), 5 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 216ceb6..83554da 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4668,6 +4668,8 @@ static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
>> 
>> static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)
>> {
>> +    u32 reg;
>> +
>>   rt2800_rfcsr_write(rt2x00dev, 0, 0xa0);
>>   rt2800_rfcsr_write(rt2x00dev, 1, 0xe1);
>>   rt2800_rfcsr_write(rt2x00dev, 2, 0xf1);
>> @@ -4700,6 +4702,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, &reg);
>> +    rt2x00_set_field32(&reg, GPIO_SWITCH_5, 0);
>> +    rt2800_register_write(rt2x00dev, GPIO_SWITCH, reg);
>> }
>> 
>> static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)
>> @@ -4985,11 +4991,7 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
>>   }
>> 
>> 
>> -    if (rt2x00_rt(rt2x00dev, RT3390)) {
>> -        rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
>> -        rt2x00_set_field32(&reg, 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);
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 06/11] rt2800: move RFCSR6_R2 & LDO_CFG0 setup to 3572 specific rfcsr init
       [not found]   ` <66918CCA-AAE0-47BF-B989-58A019810AC7@gmail.com>
@ 2013-04-14 20:17     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:17 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   34 +++++++++++++++---------------
>> 1 files changed, 17 insertions(+), 17 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 83554da..7130040 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4710,6 +4710,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_rfcsr_write(rt2x00dev, 0, 0x70);
>>   rt2800_rfcsr_write(rt2x00dev, 1, 0x81);
>>   rt2800_rfcsr_write(rt2x00dev, 2, 0xf1);
>> @@ -4741,6 +4744,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, &reg);
>> +    rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
>> +    rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>> +    rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
>> +    msleep(1);
>> +    rt2800_register_read(rt2x00dev, LDO_CFG0, &reg);
>> +    rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
>> +    rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>> +    rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
>> }
>> 
>> static void rt2800_init_rfcsr_5390(struct rt2x00_dev *rt2x00dev)
>> @@ -4990,23 +5007,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, &reg);
>> -        rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 3);
>> -        rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>> -        rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
>> -        msleep(1);
>> -        rt2800_register_read(rt2x00dev, LDO_CFG0, &reg);
>> -        rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
>> -        rt2x00_set_field32(&reg, LDO_CFG0_BGSEL, 1);
>> -        rt2800_register_write(rt2x00dev, LDO_CFG0, reg);
>> -    }
>> -
>>   /*
>>    * Set RX Filter calibration for 20MHz and 40MHz
>>    */
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 07/11] rt2800: add rt2800_rx_filter_calibration procedure
       [not found]   ` <948863C1-A75D-4625-A880-5589875479D0@gmail.com>
@ 2013-04-14 20:17     ` Gertjan van Wingerde
  2013-04-17  8:23       ` Stanislaw Gruszka
  0 siblings, 1 reply; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:17 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Add procedure for both bands filter calibration and use it on individual
>> chipset init rfcsr subroutines.
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |  106 +++++++++++++++++--------------
>> 1 files changed, 59 insertions(+), 47 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 7130040..df8760f 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -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);
>> 
>> @@ -4396,6 +4397,52 @@ static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev,
>>   return rfcsr24;
>> }
>> 
>> +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;
>> @@ -4539,6 +4586,8 @@ static void rt2800_init_rfcsr_30xx(struct rt2x00_dev *rt2x00dev)
>>       rt2x00_set_field32(&reg, 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)
>> @@ -4597,6 +4646,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_rx_filter_calibration(rt2x00dev);
>> }
> 
> This looks a bit fishy to me, as the original code doesn't completely apply to RT3290, but now it does.
> 
>> 
>> static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
>> @@ -4664,6 +4715,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)
>> @@ -4706,6 +4759,8 @@ static void rt2800_init_rfcsr_3390(struct rt2x00_dev *rt2x00dev)
>>   rt2800_register_read(rt2x00dev, GPIO_SWITCH, &reg);
>>   rt2x00_set_field32(&reg, 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)
>> @@ -4758,6 +4813,8 @@ static void rt2800_init_rfcsr_3572(struct rt2x00_dev *rt2x00dev)
>>   rt2x00_set_field32(&reg, LDO_CFG0_LDO_CORE_VLEVEL, 0);
>>   rt2x00_set_field32(&reg, 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)
>> @@ -4956,7 +5013,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
>> {
>>   struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
>>   u8 rfcsr;
>> -    u8 bbp;
>>   u32 reg;
>> 
>>   if (!rt2x00_rt(rt2x00dev, RT3070) &&
>> @@ -5007,50 +5063,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) ||
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 08/11] rt2800: move RF_R27 setup to individual rfcsr init subroutines
       [not found]   ` <742363D2-2E4F-40E5-81BB-69252F998D43@gmail.com>
@ 2013-04-14 20:18     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:18 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   18 +++++++++++-------
>> 1 files changed, 11 insertions(+), 7 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index df8760f..fe0df88 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4588,6 +4588,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)
>> @@ -4761,6 +4766,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)
>> @@ -5007,6 +5015,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)
>> @@ -5063,13 +5074,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, &reg);
>>   rt2x00_set_field32(&reg, OPT_14_CSR_BIT0, 1);
>>   rt2800_register_write(rt2x00dev, OPT_14_CSR, reg);
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 09/11] rt2800: add rt2800_led_open_drain_enable subroutine
       [not found]   ` <0E1FF2EE-1777-42C7-9052-51895C784968@gmail.com>
@ 2013-04-14 20:18     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:18 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   29 +++++++++++++++++++++++++----
>> 1 files changed, 25 insertions(+), 4 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index fe0df88..009fe47 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -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, &reg);
>> +    rt2x00_set_field32(&reg, 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)
>> {
>> @@ -4593,6 +4602,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)
>> @@ -4653,6 +4664,8 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
>>   rt2800_rfcsr_write(rt2x00dev, 29, rfcsr);
>> 
>>   rt2800_rx_filter_calibration(rt2x00dev);
>> +
>> +    rt2800_led_open_drain_enable(rt2x00dev);
>> }
>> 
>> static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
>> @@ -4722,6 +4735,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)
>> @@ -4769,6 +4784,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)
>> @@ -4823,6 +4840,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)
>> @@ -4911,6 +4930,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)
>> @@ -4978,6 +4999,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)
>> @@ -5018,6 +5041,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)
>> @@ -5074,10 +5099,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
>>       return 0;
>>   }
>> 
>> -    rt2800_register_read(rt2x00dev, OPT_14_CSR, &reg);
>> -    rt2x00_set_field32(&reg, OPT_14_CSR_BIT0, 1);
>> -    rt2800_register_write(rt2x00dev, OPT_14_CSR, reg);
>> -
>>   if (!rt2x00_rt(rt2x00dev, RT5390) &&
>>       !rt2x00_rt(rt2x00dev, RT5392)) {
>>       rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 10/11] rt2800: add rt2800_normal_mode_setup_3xxx subroutine
       [not found]   ` <D7DE287D-EED7-4657-B388-ADCCDB823A8B@gmail.com>
@ 2013-04-14 20:19     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:19 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |  114 ++++++++++++++++---------------
>> 1 files changed, 58 insertions(+), 56 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 009fe47..f31b9b9 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -4452,6 +4452,59 @@ 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 rfcsr;
>> +
>> +    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);
>> +    }
>> +    rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
>> +              drv_data->txmixer_gain_24g);
>> +    rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
>> +
>> +    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);
>> +    } else 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);
>> +    }
> 
> Personally, I would switch the if- and else branches, to have the RT chipset numbers in numerical order.
> 
>> +}
>> +
>> static void rt2800_normal_mode_setup_5xxx(struct rt2x00_dev *rt2x00dev)
>> {
>>   u8 reg;
>> @@ -4604,6 +4657,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)
>> @@ -4664,8 +4718,8 @@ static void rt2800_init_rfcsr_3290(struct rt2x00_dev *rt2x00dev)
>>   rt2800_rfcsr_write(rt2x00dev, 29, rfcsr);
>> 
>>   rt2800_rx_filter_calibration(rt2x00dev);
>> -
>>   rt2800_led_open_drain_enable(rt2x00dev);
>> +    rt2800_normal_mode_setup_3xxx(rt2x00dev);
>> }
>> 
>> static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
>> @@ -4735,8 +4789,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)
>> @@ -4786,6 +4840,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)
>> @@ -4840,8 +4895,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)
>> @@ -5099,59 +5154,6 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
>>       return 0;
>>   }
>> 
>> -    if (!rt2x00_rt(rt2x00dev, RT5390) &&
>> -        !rt2x00_rt(rt2x00dev, RT5392)) {
>> -        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);
>> -        }
>> -        rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
>> -                  drv_data->txmixer_gain_24g);
>> -        rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
>> -    }
>> -
>> -    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;
>> }
>> 
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 11/11] rt2800: cleanup rt2800_init_rfcsr
       [not found]   ` <35BCCCCF-97E2-42EE-839F-89DB7542719B@gmail.com>
@ 2013-04-14 20:20     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:20 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)

> Hi Stanislaw,
> 
> Looks good to me. When you repost the series with all comments fixed, you can add my acked-by.
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> This procedure is simple switch now and return no error any longer.
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   31 ++++++-------------------------
>> 1 files changed, 6 insertions(+), 25 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index f31b9b9..b084e90 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -5100,29 +5100,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)
>> {
>> -    struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
>> -    u8 rfcsr;
>> -    u32 reg;
>> -
>> -    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) {
>> @@ -5151,10 +5133,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)
>> @@ -5180,10 +5160,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) ||
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 01/11] rt2800: merge 5xxx normal mode setup
       [not found]   ` <3B6ED6A8-A24C-4F0C-941C-7A24F55172DA@gmail.com>
@ 2013-04-14 20:20     ` Gertjan van Wingerde
  0 siblings, 0 replies; 26+ messages in thread
From: Gertjan van Wingerde @ 2013-04-14 20:20 UTC (permalink / raw)
  To: stf_xl; +Cc: John Linville, linux-wireless

(Resending as the message didn't seem to end up on the mailing list)


> Hi Stanislaw,
> 
> Sent from my iPad
> 
> On 9 apr. 2013, at 17:05, stf_xl@wp.pl wrote:
> 
>> From: Stanislaw Gruszka <stf_xl@wp.pl>
>> 
>> Merge code which program the same registes at the end of rfcsr
>> initialization for 5592, 5392 and 5390 chips.
>> 
>> Signed-off-by: Stanislaw Gruszka <stf_xl@wp.pl>
>> ---
>> drivers/net/wireless/rt2x00/rt2800lib.c |   91 ++++++++++++-------------------
>> 1 files changed, 34 insertions(+), 57 deletions(-)
>> 
>> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
>> index 7deac4d..d092b47 100644
>> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
>> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
>> @@ -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;
>> +
>> +    rt2800_bbp_read(rt2x00dev, 138, &reg);
>> +    /*  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(&reg, BBP138_RX_ADC1, 0);
>> +    if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
>> +        rt2x00_set_field8(&reg, BBP138_TX_DAC1, 1);
>> +    rt2800_bbp_write(rt2x00dev, 138, reg);
> 
> I would put the comment above the bbp_read call, as it applies to the whole block and makes the code better readable, IMHO.
> 
>> +
>> +    rt2800_rfcsr_read(rt2x00dev, 38, &reg);
>> +    rt2x00_set_field8(&reg, RFCSR38_RX_LO1_EN, 0);
>> +    rt2800_rfcsr_write(rt2x00dev, 38, reg);
>> +
>> +    rt2800_rfcsr_read(rt2x00dev, 39, &reg);
>> +    rt2x00_set_field8(&reg, RFCSR39_RX_LO2_EN, 0);
>> +    rt2800_rfcsr_write(rt2x00dev, 39, reg);
>> +
>> +    rt2800_bbp4_mac_if_ctrl(rt2x00dev);
>> +
>> +    rt2800_rfcsr_read(rt2x00dev, 30, &reg);
>> +    rt2x00_set_field8(&reg, 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, &reg);
>> -
>> -    /*  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(&reg, BBP138_RX_ADC1, 0);
>> -    if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH) == 1)
>> -        rt2x00_set_field8(&reg, 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, &reg);
>> -    rt2x00_set_field8(&reg, RFCSR38_RX_LO1_EN, 0);
>> -    rt2800_rfcsr_write(rt2x00dev, 38, reg);
>> -
>> -    rt2800_rfcsr_read(rt2x00dev, 39, &reg);
>> -    rt2x00_set_field8(&reg, RFCSR39_RX_LO2_EN, 0);
>> -    rt2800_rfcsr_write(rt2x00dev, 39, reg);
>> -
>> -    rt2800_bbp4_mac_if_ctrl(rt2x00dev);
>> -
>> -    rt2800_rfcsr_read(rt2x00dev, 30, &reg);
>> -    rt2x00_set_field8(&reg, 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)
>> @@ -5051,20 +5058,6 @@ 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);
> 
> I don't see the addition of this code to the function for RT3090, but this code is removed here. I guess it still needs to be added to rt2800_init_rfcsr_30xx.
> 
>> -
>> -        /*  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(&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)) {
>> @@ -5107,22 +5100,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;
>> }
>> 
>> -- 
>> 1.7.4.4
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH 07/11] rt2800: add rt2800_rx_filter_calibration procedure
  2013-04-14 20:17     ` Gertjan van Wingerde
@ 2013-04-17  8:23       ` Stanislaw Gruszka
  0 siblings, 0 replies; 26+ messages in thread
From: Stanislaw Gruszka @ 2013-04-17  8:23 UTC (permalink / raw)
  To: Gertjan van Wingerde; +Cc: John Linville, linux-wireless

On Sun, Apr 14, 2013 at 10:17:56PM +0200, Gertjan van Wingerde wrote:
> >> +    /*
> >> +     * 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);
[snip]
> >> +
> >> +    rt2800_rx_filter_calibration(rt2x00dev);
> >> }
> > 
> > This looks a bit fishy to me, as the original code doesn't completely apply to RT3290, but now it does.

On vendor DPO_RT3290_LinuxSTA_V2600_20120508 we do not do this
"set back to initial state" code at all, so I'll remove
rt2800_rx_filter_calibration() from 3290 procedure.

Stanislaw 

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-04-17  8:22 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-09 15:05 [PATCH 0/11] rt2800: cleanup rfcsr init procedures stf_xl
2013-04-09 15:05 ` [PATCH 01/11] rt2800: merge 5xxx normal mode setup stf_xl
     [not found]   ` <3B6ED6A8-A24C-4F0C-941C-7A24F55172DA@gmail.com>
2013-04-14 20:20     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 02/11] rt2800: move rf init calibration code stf_xl
2013-04-10  7:12   ` Gabor Juhos
2013-04-10 15:15     ` Stanislaw Gruszka
     [not found]   ` <F57510E7-8DE6-4BA4-8256-2144DDE5B30D@gmail.com>
2013-04-14 20:14     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 03/11] rt2800: move RFCSR29_RSSI_GAIN to 3290 specific rfcsr init stf_xl
     [not found]   ` <413EC3EA-0BB4-42CC-A95A-52468DC35C67@gmail.com>
2013-04-14 20:15     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 04/11] rt2800: move 30xx common rf init code stf_xl
     [not found]   ` <A636A59B-CC0A-41E2-98A8-0165993938FA@gmail.com>
2013-04-14 20:15     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 05/11] rt2800: move GPIO_SWITCH setup to 3390 specific rfcsr init stf_xl
     [not found]   ` <5FA86BE2-7773-4D09-B891-6B1C80DCED72@gmail.com>
2013-04-14 20:16     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 06/11] rt2800: move RFCSR6_R2 & LDO_CFG0 setup to 3572 " stf_xl
     [not found]   ` <66918CCA-AAE0-47BF-B989-58A019810AC7@gmail.com>
2013-04-14 20:17     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 07/11] rt2800: add rt2800_rx_filter_calibration procedure stf_xl
     [not found]   ` <948863C1-A75D-4625-A880-5589875479D0@gmail.com>
2013-04-14 20:17     ` Gertjan van Wingerde
2013-04-17  8:23       ` Stanislaw Gruszka
2013-04-09 15:05 ` [PATCH 08/11] rt2800: move RF_R27 setup to individual rfcsr init subroutines stf_xl
     [not found]   ` <742363D2-2E4F-40E5-81BB-69252F998D43@gmail.com>
2013-04-14 20:18     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 09/11] rt2800: add rt2800_led_open_drain_enable subroutine stf_xl
     [not found]   ` <0E1FF2EE-1777-42C7-9052-51895C784968@gmail.com>
2013-04-14 20:18     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 10/11] rt2800: add rt2800_normal_mode_setup_3xxx subroutine stf_xl
     [not found]   ` <D7DE287D-EED7-4657-B388-ADCCDB823A8B@gmail.com>
2013-04-14 20:19     ` Gertjan van Wingerde
2013-04-09 15:05 ` [PATCH 11/11] rt2800: cleanup rt2800_init_rfcsr stf_xl
     [not found]   ` <35BCCCCF-97E2-42EE-839F-89DB7542719B@gmail.com>
2013-04-14 20:20     ` Gertjan van Wingerde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).