1 From 1ef7772f766c72f9b767d32cc0b26d457a34ace2 Mon Sep 17 00:00:00 2001
2 From: Ivo van Doorn <IvDoorn@gmail.com>
3 Date: Sun, 8 Feb 2009 00:09:22 +0100
4 Subject: [PATCH] rt2x00: Channel HT40+/- fixes (rt2800usb)
6 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
8 drivers/net/wireless/rt2x00/rt2800usb.c | 107 ++++++++++++++++--------------
9 drivers/net/wireless/rt2x00/rt2800usb.h | 5 +-
10 2 files changed, 61 insertions(+), 51 deletions(-)
12 diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
13 index 1709e87..29ecaa8 100644
14 --- a/drivers/net/wireless/rt2x00/rt2800usb.c
15 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
16 @@ -641,7 +641,7 @@ static void rt2800usb_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 @@ -691,6 +691,7 @@ static void rt2800usb_config_lna_gain(struct rt2x00_dev *rt2x00dev,
28 static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
29 + struct ieee80211_conf *conf,
30 struct rf_channel *rf,
31 struct channel_info *info)
33 @@ -702,6 +703,7 @@ static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
34 * Determine antenna settings from EEPROM
36 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
38 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1)
39 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
41 @@ -742,8 +744,7 @@ static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
42 TXPOWER_G_TO_DEV(info->tx_power2));
45 - rt2x00_set_field32(&rf->rf4, RF4_BW40,
46 - test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags));
47 + rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
49 rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
50 rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
51 @@ -766,6 +767,7 @@ static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
54 static void rt2800usb_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
55 + struct ieee80211_conf *conf,
56 struct rf_channel *rf,
57 struct channel_info *info)
59 @@ -787,10 +789,12 @@ static void rt2800usb_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
60 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset);
61 rt2800usb_rfcsr_write(rt2x00dev, 23, rfcsr);
63 - if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags))
64 - rt2800usb_rfcsr_write(rt2x00dev, 24, rt2x00dev->calibration_bw40);
65 + if (conf_is_ht40(conf))
66 + rt2800usb_rfcsr_write(rt2x00dev, 24,
67 + rt2x00dev->calibration_bw40);
69 - rt2800usb_rfcsr_write(rt2x00dev, 24, rt2x00dev->calibration_bw20);
70 + rt2800usb_rfcsr_write(rt2x00dev, 24,
71 + rt2x00dev->calibration_bw20);
73 rt2800usb_rfcsr_read(rt2x00dev, 23, &rfcsr);
74 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
75 @@ -798,46 +802,24 @@ static void rt2800usb_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
78 static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
79 + struct ieee80211_conf *conf,
80 struct rf_channel *rf,
81 struct channel_info *info)
88 - if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
89 - rt2800usb_config_channel_rt2x(rt2x00dev, rf, info);
91 - rt2800usb_config_channel_rt3x(rt2x00dev, rf, info);
94 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
95 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
96 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
97 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
98 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
99 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
100 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
103 + * Determine antenna settings from EEPROM
105 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
107 - /* Turn off unused PA or LNA when only 1T or 1R */
108 - if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) {
110 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 0);
111 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 0);
114 - /* Turn off unused PA or LNA when only 1T or 1R */
115 - if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) {
116 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 0);
117 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 0);
120 - if (rf->channel > 14)
121 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, 1);
122 + if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
123 + rt2800usb_config_channel_rt2x(rt2x00dev, conf, rf, info);
125 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
126 + rt2800usb_config_channel_rt3x(rt2x00dev, conf, rf, info);
129 * Change BBP settings
130 @@ -855,11 +837,6 @@ static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
131 rt2800usb_bbp_write(rt2x00dev, 82, 0x84);
132 rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
135 - rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
136 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 0);
137 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 1);
138 - rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
140 rt2800usb_bbp_write(rt2x00dev, 82, 0xf2);
142 @@ -867,15 +844,45 @@ static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
143 rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
145 rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
148 + rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
149 + rt2x00_set_field32(®, TX_BAND_CFG_HT40_PLUS, conf_is_ht40_plus(conf));
150 + rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14);
151 + rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14);
152 + rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
156 + /* Turn on unused PA or LNA when not using 1T or 1R */
157 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) != 1) {
158 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1);
159 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
162 - rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
163 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 1);
164 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 0);
165 - rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
166 + /* Turn on unused PA or LNA when not using 1T or 1R */
167 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) != 1) {
168 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
169 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
172 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
173 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
174 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
175 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
176 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, rf->channel <= 14);
177 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
179 rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
181 + rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
182 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf));
183 + rt2800usb_bbp_write(rt2x00dev, 4, bbp);
185 + rt2800usb_bbp_read(rt2x00dev, 3, &bbp);
186 + rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf));
187 + rt2800usb_bbp_write(rt2x00dev, 3, bbp);
192 @@ -1008,8 +1015,8 @@ static void rt2800usb_config(struct rt2x00_dev *rt2x00dev,
193 rt2800usb_config_lna_gain(rt2x00dev, libconf);
195 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
196 - rt2800usb_config_channel(rt2x00dev, &libconf->rf,
197 - &libconf->channel);
198 + rt2800usb_config_channel(rt2x00dev, libconf->conf,
199 + &libconf->rf, &libconf->channel);
200 if (flags & IEEE80211_CONF_CHANGE_POWER)
201 rt2800usb_config_txpower(rt2x00dev, libconf->conf->power_level);
202 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
203 @@ -1643,7 +1650,7 @@ static u8 rt2800usb_init_rx_filter(struct rt2x00_dev *rt2x00dev,
206 rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
207 - rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0x10);
208 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2);
209 rt2800usb_bbp_write(rt2x00dev, 4, bbp);
212 @@ -2777,14 +2784,14 @@ static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = {
214 static const struct data_queue_desc rt2800usb_queue_rx = {
215 .entry_num = RX_ENTRIES,
216 - .data_size = DATA_FRAME_SIZE,
217 + .data_size = AGGREGATION_SIZE,
218 .desc_size = RXD_DESC_SIZE + RXWI_DESC_SIZE,
219 .priv_size = sizeof(struct queue_entry_priv_usb),
222 static const struct data_queue_desc rt2800usb_queue_tx = {
223 .entry_num = TX_ENTRIES,
224 - .data_size = DATA_FRAME_SIZE,
225 + .data_size = AGGREGATION_SIZE,
226 .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
227 .priv_size = sizeof(struct queue_entry_priv_usb),
229 diff --git a/drivers/net/wireless/rt2x00/rt2800usb.h b/drivers/net/wireless/rt2x00/rt2800usb.h
230 index db2eedd..ffccc21 100644
231 --- a/drivers/net/wireless/rt2x00/rt2800usb.h
232 +++ b/drivers/net/wireless/rt2x00/rt2800usb.h
234 * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
236 #define TX_BAND_CFG 0x132c
237 +#define TX_BAND_CFG_HT40_PLUS FIELD32(0x00000001)
238 #define TX_BAND_CFG_A FIELD32(0x00000002)
239 #define TX_BAND_CFG_BG FIELD32(0x00000004)
241 @@ -1482,10 +1483,12 @@ struct mac_iveiv_entry {
244 #define BBP3_RX_ANTENNA FIELD8(0x18)
245 +#define BBP3_HT40_PLUS FIELD8(0x20)
250 +#define BBP4_TX_BF FIELD8(0x01)
251 #define BBP4_BANDWIDTH FIELD8(0x18)
254 @@ -1548,7 +1551,7 @@ struct mac_iveiv_entry {
255 #define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
256 #define RF4_TXPOWER_A FIELD32(0x00000780)
257 #define RF4_FREQ_OFFSET FIELD32(0x001f8000)
258 -#define RF4_BW40 FIELD32(0x00200000)
259 +#define RF4_HT40 FIELD32(0x00200000)