2013-06-24 21:03:33

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH v3 0/3] rt2x00: rt2800: prepare for three-chain device support

Gabor Juhos (3):
rt2x00: rt2800: increase EEPROM_SIZE to 512 bytes
rt2x00: rt2800lib: turn on secondary PAs/LNAs for 3T/3R devices
rt2x00: rt2800lib: turn on tertiary PAs/LNAs for 3T/3R devices

drivers/net/wireless/rt2x00/rt2800.h | 2 +-
drivers/net/wireless/rt2x00/rt2800lib.c | 47 +++++++++++++++++++++++--------
2 files changed, 36 insertions(+), 13 deletions(-)

--
1.7.10



2013-06-24 21:19:43

by Gertjan van Wingerde

[permalink] [raw]
Subject: Re: [PATCH v3 3/3] rt2x00: rt2800lib: turn on tertiary PAs/LNAs for 3T/3R devices



Sent from my iPad

On 24 jun. 2013, at 23:03, Gabor Juhos <[email protected]> wrote:

> The 3T/3R devices are using the tertiary PAs/LNAs
> however those are never turned on. Fix the code to
> turn on those on for such devices.
>
> Also modify the code to use switch statements to
> improve readability.
>
> Signed-off-by: Gabor Juhos <[email protected]>

Acked-by: Gertjan van Wingerde <[email protected]>

> ---
> Changes in v3:
> - also move setting of the primary PA of the 5GHz band into the first
> switch statement
> Changes in v2:
> - use a switch statement to improve readability as suggested
> by Gertjan
> - add detailed commit description
> ---
> drivers/net/wireless/rt2x00/rt2800lib.c | 47 +++++++++++++++++++++++--------
> 1 file changed, 35 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
> index b7119e3..25f7dbe 100644
> --- a/drivers/net/wireless/rt2x00/rt2800lib.c
> +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
> @@ -2678,30 +2678,53 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
>
> tx_pin = 0;
>
> - if (rt2x00dev->default_ant.tx_chain_num > 1) {
> - /* Turn on secondary PAs for 2T and for 3T devices*/
> + switch (rt2x00dev->default_ant.tx_chain_num) {
> + case 3:
> + /* Turn on tertiary PAs */
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A2_EN,
> + rf->channel > 14);
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G2_EN,
> + rf->channel <= 14);
> + /* fall-through */
> + case 2:
> + /* Turn on secondary PAs */
> rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN,
> rf->channel > 14);
> rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN,
> rf->channel <= 14);
> + /* fall-through */
> + case 1:
> + /* Turn on primary PAs */
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN,
> + rf->channel > 14);
> + if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags))
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
> + else
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN,
> + rf->channel <= 14);
> + break;
> }
>
> - if (rt2x00dev->default_ant.rx_chain_num > 1) {
> - /* Turn on secondary LNAs for 2R and for 3R devices */
> + switch (rt2x00dev->default_ant.rx_chain_num) {
> + case 3:
> + /* Turn on tertiary LNAs */
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A2_EN, 1);
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G2_EN, 1);
> + /* fall-through */
> + case 2:
> + /* Turn on secondary LNAs */
> rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
> rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
> + /* fall-through */
> + case 1:
> + /* Turn on primary LNAs */
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
> + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
> + break;
> }
>
> - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
> - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
> rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
> rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
> - if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags))
> - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
> - else
> - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN,
> - rf->channel <= 14);
> - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
>
> rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
>
> --
> 1.7.10
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-06-24 21:03:33

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH v3 2/3] rt2x00: rt2800lib: turn on secondary PAs/LNAs for 3T/3R devices

The secondary PAs/LNAs are turned on only for 2T/2R
devices, however these are used for 3T/3R devices as
well. Always turn those on if the device uses more
than one tx/rx chains.

Signed-off-by: Gabor Juhos <[email protected]>
Acked-by: Stanislaw Gruszka <[email protected]>
Acked-by: Gertjan van Wingerde <[email protected]>
---
Changes in v3: ---
Changes in v2:
- fix a typo
- add Acked-by tags
---
drivers/net/wireless/rt2x00/rt2800lib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 4072242..b7119e3 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2678,16 +2678,16 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,

tx_pin = 0;

- /* Turn on unused PA or LNA when not using 1T or 1R */
- if (rt2x00dev->default_ant.tx_chain_num == 2) {
+ if (rt2x00dev->default_ant.tx_chain_num > 1) {
+ /* Turn on secondary PAs for 2T and for 3T devices*/
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN,
rf->channel > 14);
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN,
rf->channel <= 14);
}

- /* Turn on unused PA or LNA when not using 1T or 1R */
- if (rt2x00dev->default_ant.rx_chain_num == 2) {
+ if (rt2x00dev->default_ant.rx_chain_num > 1) {
+ /* Turn on secondary LNAs for 2R and for 3R devices */
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
}
--
1.7.10


2013-06-24 21:03:33

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH v3 1/3] rt2x00: rt2800: increase EEPROM_SIZE to 512 bytes

Ralink 3T chipsets are using a different EEPROM
layout than the others. The EEPROM on these devices
contain more data than the others which does not fit
into 272 byte which the rt2800 driver actually uses.

The Ralink reference driver defines EEPROM_SIZE to
512/1024 bytes for PCI/USB devices respectively.

Increase the EEPROM_SIZE constant to 512 bytes, in
order to make room for EEPROM data of 3T devices.

Signed-off-by: Gabor Juhos <[email protected]>
Acked-by: Helmut Schaa <[email protected]>
Acked-by: Stanislaw Gruszka <[email protected]>
Acked-by: Gertjan van Wingerde <[email protected]>
---
Changes in v3: ---
Changes in v2: add Acked-by tags
---
drivers/net/wireless/rt2x00/rt2800.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800.h b/drivers/net/wireless/rt2x00/rt2800.h
index fe43d01..d78c495 100644
--- a/drivers/net/wireless/rt2x00/rt2800.h
+++ b/drivers/net/wireless/rt2x00/rt2800.h
@@ -100,7 +100,7 @@
#define CSR_REG_BASE 0x1000
#define CSR_REG_SIZE 0x0800
#define EEPROM_BASE 0x0000
-#define EEPROM_SIZE 0x0110
+#define EEPROM_SIZE 0x0200
#define BBP_BASE 0x0000
#define BBP_SIZE 0x00ff
#define RF_BASE 0x0004
--
1.7.10


2013-06-24 21:03:34

by Gabor Juhos

[permalink] [raw]
Subject: [PATCH v3 3/3] rt2x00: rt2800lib: turn on tertiary PAs/LNAs for 3T/3R devices

The 3T/3R devices are using the tertiary PAs/LNAs
however those are never turned on. Fix the code to
turn on those on for such devices.

Also modify the code to use switch statements to
improve readability.

Signed-off-by: Gabor Juhos <[email protected]>
---
Changes in v3:
- also move setting of the primary PA of the 5GHz band into the first
switch statement
Changes in v2:
- use a switch statement to improve readability as suggested
by Gertjan
- add detailed commit description
---
drivers/net/wireless/rt2x00/rt2800lib.c | 47 +++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index b7119e3..25f7dbe 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2678,30 +2678,53 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,

tx_pin = 0;

- if (rt2x00dev->default_ant.tx_chain_num > 1) {
- /* Turn on secondary PAs for 2T and for 3T devices*/
+ switch (rt2x00dev->default_ant.tx_chain_num) {
+ case 3:
+ /* Turn on tertiary PAs */
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A2_EN,
+ rf->channel > 14);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G2_EN,
+ rf->channel <= 14);
+ /* fall-through */
+ case 2:
+ /* Turn on secondary PAs */
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN,
rf->channel > 14);
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN,
rf->channel <= 14);
+ /* fall-through */
+ case 1:
+ /* Turn on primary PAs */
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN,
+ rf->channel > 14);
+ if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags))
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
+ else
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN,
+ rf->channel <= 14);
+ break;
}

- if (rt2x00dev->default_ant.rx_chain_num > 1) {
- /* Turn on secondary LNAs for 2R and for 3R devices */
+ switch (rt2x00dev->default_ant.rx_chain_num) {
+ case 3:
+ /* Turn on tertiary LNAs */
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A2_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G2_EN, 1);
+ /* fall-through */
+ case 2:
+ /* Turn on secondary LNAs */
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
+ /* fall-through */
+ case 1:
+ /* Turn on primary LNAs */
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
+ rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
+ break;
}

- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
- if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags))
- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
- else
- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN,
- rf->channel <= 14);
- rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);

rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);

--
1.7.10