1 From 1c042f183a52db009c2c0940ecff04ae954318e2 Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sun, 8 Feb 2009 00:08:37 +0100
4 Subject: [PATCH] rt2x00: Channel HT40+/- fixes (rt2800pci)
6 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
8 drivers/net/wireless/rt2x00/rt2800pci.c | 69 +++++++++++++++----------------
9 drivers/net/wireless/rt2x00/rt2800pci.h | 3 +-
10 2 files changed, 36 insertions(+), 36 deletions(-)
12 diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
13 index 95eb053..ddea65b 100644
14 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
15 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
16 @@ -603,7 +603,7 @@ static void rt2800pci_config_ant(struct rt2x00_dev *rt2x00dev,
17 rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
20 - rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 16);
21 + rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2);
25 @@ -653,6 +653,7 @@ static void rt2800pci_config_lna_gain(struct rt2x00_dev *rt2x00dev,
28 static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
29 + struct ieee80211_conf *conf,
30 struct rf_channel *rf,
31 struct channel_info *info)
33 @@ -660,34 +661,20 @@ static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
38 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
39 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
40 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
41 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
42 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
43 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
44 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
46 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
49 * Determine antenna settings from EEPROM
51 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
53 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) {
54 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
55 - /* Turn off unused PA or LNA when only 1T or 1R */
56 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 0);
57 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 0);
60 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) {
61 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1);
62 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
63 - /* Turn off unused PA or LNA when only 1T or 1R */
64 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 0);
65 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 0);
66 } else if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 2)
67 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
69 @@ -715,19 +702,14 @@ static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
71 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A,
72 TXPOWER_A_TO_DEV(info->tx_power2));
74 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, 1);
76 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G,
77 TXPOWER_G_TO_DEV(info->tx_power1));
78 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G,
79 TXPOWER_G_TO_DEV(info->tx_power2));
81 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
84 - rt2x00_set_field32(&rf->rf4, RF4_BW40,
85 - test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags));
86 + rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
88 rt2800pci_rf_write(rt2x00dev, 1, rf->rf1);
89 rt2800pci_rf_write(rt2x00dev, 2, rf->rf2);
90 @@ -764,11 +746,6 @@ static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
91 rt2800pci_bbp_write(rt2x00dev, 82, 0x84);
92 rt2800pci_bbp_write(rt2x00dev, 75, 0x50);
95 - rt2x00pci_register_read(rt2x00dev, TX_BAND_CFG, ®);
96 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 0);
97 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 1);
98 - rt2x00pci_register_write(rt2x00dev, TX_BAND_CFG, reg);
100 rt2800pci_bbp_write(rt2x00dev, 82, 0xf2);
102 @@ -776,13 +753,35 @@ static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
103 rt2800pci_bbp_write(rt2x00dev, 75, 0x46);
105 rt2800pci_bbp_write(rt2x00dev, 75, 0x50);
108 - rt2x00pci_register_read(rt2x00dev, TX_BAND_CFG, ®);
109 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 1);
110 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 0);
111 - rt2x00pci_register_write(rt2x00dev, TX_BAND_CFG, reg);
112 + rt2x00pci_register_read(rt2x00dev, TX_BAND_CFG, ®);
113 + rt2x00_set_field32(®, TX_BAND_CFG_HT40_PLUS, conf_is_ht40_plus(conf));
114 + rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14);
115 + rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14);
116 + rt2x00pci_register_write(rt2x00dev, TX_BAND_CFG, reg);
120 + /* Turn on unused PA or LNA when not using 1T or 1R */
121 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) != 1) {
122 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1);
123 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
126 + /* Turn on unused PA or LNA when not using 1T or 1R */
127 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) != 1) {
128 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
129 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
132 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
133 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
134 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
135 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
136 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, rf->channel <= 14);
137 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
139 rt2x00pci_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
142 @@ -917,8 +916,8 @@ static void rt2800pci_config(struct rt2x00_dev *rt2x00dev,
143 rt2800pci_config_lna_gain(rt2x00dev, libconf);
145 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
146 - rt2800pci_config_channel(rt2x00dev, &libconf->rf,
147 - &libconf->channel);
148 + rt2800pci_config_channel(rt2x00dev, libconf->conf,
149 + &libconf->rf, &libconf->channel);
150 if (flags & IEEE80211_CONF_CHANGE_POWER)
151 rt2800pci_config_txpower(rt2x00dev, libconf->conf->power_level);
152 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
153 @@ -2724,14 +2723,14 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = {
155 static const struct data_queue_desc rt2800pci_queue_rx = {
156 .entry_num = RX_ENTRIES,
157 - .data_size = DATA_FRAME_SIZE,
158 + .data_size = AGGREGATION_SIZE,
159 .desc_size = RXD_DESC_SIZE,
160 .priv_size = sizeof(struct queue_entry_priv_pci),
163 static const struct data_queue_desc rt2800pci_queue_tx = {
164 .entry_num = TX_ENTRIES,
165 - .data_size = DATA_FRAME_SIZE,
166 + .data_size = AGGREGATION_SIZE,
167 .desc_size = TXD_DESC_SIZE,
168 .priv_size = sizeof(struct queue_entry_priv_pci),
170 diff --git a/drivers/net/wireless/rt2x00/rt2800pci.h b/drivers/net/wireless/rt2x00/rt2800pci.h
171 index 39f045c..0682a6a 100644
172 --- a/drivers/net/wireless/rt2x00/rt2800pci.h
173 +++ b/drivers/net/wireless/rt2x00/rt2800pci.h
175 * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
177 #define TX_BAND_CFG 0x132c
178 +#define TX_BAND_CFG_HT40_PLUS FIELD32(0x00000001)
179 #define TX_BAND_CFG_A FIELD32(0x00000002)
180 #define TX_BAND_CFG_BG FIELD32(0x00000004)
182 @@ -1496,7 +1497,7 @@ struct mac_iveiv_entry {
183 #define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
184 #define RF4_TXPOWER_A FIELD32(0x00000780)
185 #define RF4_FREQ_OFFSET FIELD32(0x001f8000)
186 -#define RF4_BW40 FIELD32(0x00200000)
187 +#define RF4_HT40 FIELD32(0x00200000)