linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes
@ 2013-08-16 20:38 Gabor Juhos
  2013-08-16 20:38 ` [PATCH 1/5] rt2x00: rt2800lib: fix frequency offset boundary calculation Gabor Juhos
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-16 20:38 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Gabor Juhos

The patch-set contain small fixes for the frequency adjustment 
code of the rt2800 driver.

Gabor Juhos (5):
  rt2x00: rt2800lib: fix frequency offset boundary calculation
  rt2x00: rt2800lib: optimize frequency offset adjustment
  rt2x00: rt2800lib: use a MCU command for frequency adjustment on USB
    devices
  rt2x00: rt2800lib: move rt2800_adjust_freq_offset function
  rt2x00: rt2800lib: adjust frequency offset for RF3053

 drivers/net/wireless/rt2x00/rt2800lib.c |   38 +++++++++++++++++++------------
 1 file changed, 24 insertions(+), 14 deletions(-)

-- 
1.7.10

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

* [PATCH 1/5] rt2x00: rt2800lib: fix frequency offset boundary calculation
  2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
@ 2013-08-16 20:38 ` Gabor Juhos
  2013-08-16 20:38 ` [PATCH 2/5] rt2x00: rt2800lib: optimize frequency offset adjustment Gabor Juhos
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-16 20:38 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Gabor Juhos

The current code in the 'rt2800_adjust_freq_offset'
function limits the device specific frequency offset
value to FREQ_BOUND but ignores the fact that the
uppermost bit is not part of the frequency offset
value. As the result, the driver always uses the
FREQ_BOUND value if the uppermost bit is set.

Update the code to use the correct source value
for calculating the boundary.

Based on the DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.

Reference:
  RTMPAdjustFrequencyOffset function in common/rt_rf.c

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 313da6a..d4e6dea 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2494,13 +2494,14 @@ static void rt2800_config_channel_rf3053(struct rt2x00_dev *rt2x00dev,
 
 static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev)
 {
+	u8 freq_offset;
 	u8 rfcsr;
 
+	freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE);
+	freq_offset = min_t(u8, freq_offset, FREQ_OFFSET_BOUND);
+
 	rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
-	if (rt2x00dev->freq_offset > FREQ_OFFSET_BOUND)
-		rt2x00_set_field8(&rfcsr, RFCSR17_CODE, FREQ_OFFSET_BOUND);
-	else
-		rt2x00_set_field8(&rfcsr, RFCSR17_CODE, rt2x00dev->freq_offset);
+	rt2x00_set_field8(&rfcsr, RFCSR17_CODE, freq_offset);
 	rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
 }
 
-- 
1.7.10

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

* [PATCH 2/5] rt2x00: rt2800lib: optimize frequency offset adjustment
  2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
  2013-08-16 20:38 ` [PATCH 1/5] rt2x00: rt2800lib: fix frequency offset boundary calculation Gabor Juhos
@ 2013-08-16 20:38 ` Gabor Juhos
  2013-08-16 20:38 ` [PATCH 3/5] rt2x00: rt2800lib: use a MCU command for frequency adjustment on USB devices Gabor Juhos
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-16 20:38 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Gabor Juhos

Don't write the new value into the register if it is
the same as the old value to avoid unncessary USB bus
traffic with USB devices. The change also saves a few
cycle on MMIO based devices.

Based on the DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.

Reference:
  RTMPAdjustFrequencyOffset function in common/rt_rf.c

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index d4e6dea..c990a27 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2495,13 +2495,17 @@ static void rt2800_config_channel_rf3053(struct rt2x00_dev *rt2x00dev,
 static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev)
 {
 	u8 freq_offset;
-	u8 rfcsr;
+	u8 rfcsr, prev_rfcsr;
 
 	freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE);
 	freq_offset = min_t(u8, freq_offset, FREQ_OFFSET_BOUND);
 
 	rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
+	prev_rfcsr = rfcsr;
 	rt2x00_set_field8(&rfcsr, RFCSR17_CODE, freq_offset);
+	if (rfcsr == prev_rfcsr)
+		return;
+
 	rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
 }
 
-- 
1.7.10

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

* [PATCH 3/5] rt2x00: rt2800lib: use a MCU command for frequency adjustment on USB devices
  2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
  2013-08-16 20:38 ` [PATCH 1/5] rt2x00: rt2800lib: fix frequency offset boundary calculation Gabor Juhos
  2013-08-16 20:38 ` [PATCH 2/5] rt2x00: rt2800lib: optimize frequency offset adjustment Gabor Juhos
@ 2013-08-16 20:38 ` Gabor Juhos
  2013-08-16 20:38 ` [PATCH 4/5] rt2x00: rt2800lib: move rt2800_adjust_freq_offset function Gabor Juhos
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-16 20:38 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Gabor Juhos

According to the Ralink driver, there is an MCU
command which can be used to send the frequency
offset value directly to the USB device without
going through the RFCSR writing sequence.

Based on the DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.

Reference:
  RTMPAdjustFrequencyOffset function in common/rt_rf.c

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index c990a27..60b4bfe 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2506,7 +2506,11 @@ static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev)
 	if (rfcsr == prev_rfcsr)
 		return;
 
-	rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
+	if (rt2x00_is_usb(rt2x00dev))
+		rt2800_mcu_request(rt2x00dev, 0x74, 0xff, freq_offset,
+				   prev_rfcsr);
+	else
+		rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
 }
 
 static void rt2800_config_channel_rf3290(struct rt2x00_dev *rt2x00dev,
-- 
1.7.10

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

* [PATCH 4/5] rt2x00: rt2800lib: move rt2800_adjust_freq_offset function
  2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
                   ` (2 preceding siblings ...)
  2013-08-16 20:38 ` [PATCH 3/5] rt2x00: rt2800lib: use a MCU command for frequency adjustment on USB devices Gabor Juhos
@ 2013-08-16 20:38 ` Gabor Juhos
  2013-08-16 20:38 ` [PATCH 5/5] rt2x00: rt2800lib: adjust frequency offset for RF3053 Gabor Juhos
  2013-08-17  9:50 ` [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
  5 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-16 20:38 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Gabor Juhos

Move the rt2800_adjust_freq_offset function before
the channel configuration functions to make it usable
from those without a forward declaration.

The patch contains no functional changes.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |   45 ++++++++++++++++---------------
 1 file changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 60b4bfe..9b4d836 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1873,6 +1873,29 @@ static void rt2800_config_lna_gain(struct rt2x00_dev *rt2x00dev,
 	rt2x00dev->lna_gain = lna_gain;
 }
 
+#define FREQ_OFFSET_BOUND	0x5f
+
+static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev)
+{
+	u8 freq_offset;
+	u8 rfcsr, prev_rfcsr;
+
+	freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE);
+	freq_offset = min_t(u8, freq_offset, FREQ_OFFSET_BOUND);
+
+	rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
+	prev_rfcsr = rfcsr;
+	rt2x00_set_field8(&rfcsr, RFCSR17_CODE, freq_offset);
+	if (rfcsr == prev_rfcsr)
+		return;
+
+	if (rt2x00_is_usb(rt2x00dev))
+		rt2800_mcu_request(rt2x00dev, 0x74, 0xff, freq_offset,
+				   prev_rfcsr);
+	else
+		rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
+}
+
 static void rt2800_config_channel_rf2xxx(struct rt2x00_dev *rt2x00dev,
 					 struct ieee80211_conf *conf,
 					 struct rf_channel *rf,
@@ -2490,28 +2513,6 @@ static void rt2800_config_channel_rf3053(struct rt2x00_dev *rt2x00dev,
 
 #define POWER_BOUND		0x27
 #define POWER_BOUND_5G		0x2b
-#define FREQ_OFFSET_BOUND	0x5f
-
-static void rt2800_adjust_freq_offset(struct rt2x00_dev *rt2x00dev)
-{
-	u8 freq_offset;
-	u8 rfcsr, prev_rfcsr;
-
-	freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE);
-	freq_offset = min_t(u8, freq_offset, FREQ_OFFSET_BOUND);
-
-	rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
-	prev_rfcsr = rfcsr;
-	rt2x00_set_field8(&rfcsr, RFCSR17_CODE, freq_offset);
-	if (rfcsr == prev_rfcsr)
-		return;
-
-	if (rt2x00_is_usb(rt2x00dev))
-		rt2800_mcu_request(rt2x00dev, 0x74, 0xff, freq_offset,
-				   prev_rfcsr);
-	else
-		rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
-}
 
 static void rt2800_config_channel_rf3290(struct rt2x00_dev *rt2x00dev,
 					 struct ieee80211_conf *conf,
-- 
1.7.10

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

* [PATCH 5/5] rt2x00: rt2800lib: adjust frequency offset for RF3053
  2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
                   ` (3 preceding siblings ...)
  2013-08-16 20:38 ` [PATCH 4/5] rt2x00: rt2800lib: move rt2800_adjust_freq_offset function Gabor Juhos
@ 2013-08-16 20:38 ` Gabor Juhos
  2013-08-17  9:50 ` [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
  5 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-16 20:38 UTC (permalink / raw)
  To: John W. Linville; +Cc: linux-wireless, users, Gabor Juhos

Along with other chipsets, the Ralink driver uses the
frequency adjustment code for RF3053 as well. Remove
the bogus place-holder comment from the RF3053 specific
channel configuration function and call the frequency
adjustment function instead

Based on the DPO_RT5572_LinuxSTA_2.6.0.1_20120629
driver.

Reference:
  RT3593_ChipSwitchChannel function in chips/rt3593.c

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 drivers/net/wireless/rt2x00/rt2800lib.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 9b4d836..fb71ed6 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2344,7 +2344,7 @@ static void rt2800_config_channel_rf3053(struct rt2x00_dev *rt2x00dev,
 	}
 	rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
 
-	/* TODO: frequency calibration? */
+	rt2800_adjust_freq_offset(rt2x00dev);
 
 	if (conf_is_ht40(conf)) {
 		txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40,
-- 
1.7.10

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

* Re: [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes
  2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
                   ` (4 preceding siblings ...)
  2013-08-16 20:38 ` [PATCH 5/5] rt2x00: rt2800lib: adjust frequency offset for RF3053 Gabor Juhos
@ 2013-08-17  9:50 ` Gabor Juhos
  5 siblings, 0 replies; 7+ messages in thread
From: Gabor Juhos @ 2013-08-17  9:50 UTC (permalink / raw)
  To: Gabor Juhos; +Cc: John W. Linville, linux-wireless, users

2013.08.16. 22:38 keltezéssel, Gabor Juhos írta:
> The patch-set contain small fixes for the frequency adjustment 
> code of the rt2800 driver.
> 
> Gabor Juhos (5):
>   rt2x00: rt2800lib: fix frequency offset boundary calculation
>   rt2x00: rt2800lib: optimize frequency offset adjustment
>   rt2x00: rt2800lib: use a MCU command for frequency adjustment on USB
>     devices
>   rt2x00: rt2800lib: move rt2800_adjust_freq_offset function
>   rt2x00: rt2800lib: adjust frequency offset for RF3053
> 
>  drivers/net/wireless/rt2x00/rt2800lib.c |   38 +++++++++++++++++++------------
>  1 file changed, 24 insertions(+), 14 deletions(-)
> 

John,

Please ignore this set. I will send a slightly improved version.

-Gabor

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

end of thread, other threads:[~2013-08-17  9:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-16 20:38 [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos
2013-08-16 20:38 ` [PATCH 1/5] rt2x00: rt2800lib: fix frequency offset boundary calculation Gabor Juhos
2013-08-16 20:38 ` [PATCH 2/5] rt2x00: rt2800lib: optimize frequency offset adjustment Gabor Juhos
2013-08-16 20:38 ` [PATCH 3/5] rt2x00: rt2800lib: use a MCU command for frequency adjustment on USB devices Gabor Juhos
2013-08-16 20:38 ` [PATCH 4/5] rt2x00: rt2800lib: move rt2800_adjust_freq_offset function Gabor Juhos
2013-08-16 20:38 ` [PATCH 5/5] rt2x00: rt2800lib: adjust frequency offset for RF3053 Gabor Juhos
2013-08-17  9:50 ` [PATCH 0/5] rt2x00: rt2800lib: frequency offset adjustment fixes Gabor Juhos

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).