1 From c2288ea288283cea727dfa547339d245458071fc 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 --- a/drivers/net/wireless/rt2x00/rt2800usb.c
13 +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
14 @@ -641,7 +641,7 @@ static void rt2800usb_config_ant(struct
15 rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
18 - rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 16);
19 + rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2);
23 @@ -691,6 +691,7 @@ static void rt2800usb_config_lna_gain(st
26 static void rt2800usb_config_channel_rt2x(struct rt2x00_dev *rt2x00dev,
27 + struct ieee80211_conf *conf,
28 struct rf_channel *rf,
29 struct channel_info *info)
31 @@ -702,6 +703,7 @@ static void rt2800usb_config_channel_rt2
32 * Determine antenna settings from EEPROM
34 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
36 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1)
37 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
39 @@ -742,8 +744,7 @@ static void rt2800usb_config_channel_rt2
40 TXPOWER_G_TO_DEV(info->tx_power2));
43 - rt2x00_set_field32(&rf->rf4, RF4_BW40,
44 - test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags));
45 + rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
47 rt2800usb_rf_write(rt2x00dev, 1, rf->rf1);
48 rt2800usb_rf_write(rt2x00dev, 2, rf->rf2);
49 @@ -766,6 +767,7 @@ static void rt2800usb_config_channel_rt2
52 static void rt2800usb_config_channel_rt3x(struct rt2x00_dev *rt2x00dev,
53 + struct ieee80211_conf *conf,
54 struct rf_channel *rf,
55 struct channel_info *info)
57 @@ -787,10 +789,12 @@ static void rt2800usb_config_channel_rt3
58 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset);
59 rt2800usb_rfcsr_write(rt2x00dev, 23, rfcsr);
61 - if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags))
62 - rt2800usb_rfcsr_write(rt2x00dev, 24, rt2x00dev->calibration_bw40);
63 + if (conf_is_ht40(conf))
64 + rt2800usb_rfcsr_write(rt2x00dev, 24,
65 + rt2x00dev->calibration_bw40);
67 - rt2800usb_rfcsr_write(rt2x00dev, 24, rt2x00dev->calibration_bw20);
68 + rt2800usb_rfcsr_write(rt2x00dev, 24,
69 + rt2x00dev->calibration_bw20);
71 rt2800usb_rfcsr_read(rt2x00dev, 23, &rfcsr);
72 rt2x00_set_field8(&rfcsr, RFCSR7_RF_TUNING, 1);
73 @@ -798,46 +802,24 @@ static void rt2800usb_config_channel_rt3
76 static void rt2800usb_config_channel(struct rt2x00_dev *rt2x00dev,
77 + struct ieee80211_conf *conf,
78 struct rf_channel *rf,
79 struct channel_info *info)
86 - if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
87 - rt2800usb_config_channel_rt2x(rt2x00dev, rf, info);
89 - rt2800usb_config_channel_rt3x(rt2x00dev, rf, info);
92 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
93 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
94 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
95 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
96 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
97 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
98 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
101 + * Determine antenna settings from EEPROM
103 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
105 - /* Turn off unused PA or LNA when only 1T or 1R */
106 - if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) {
108 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 0);
109 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 0);
112 - /* Turn off unused PA or LNA when only 1T or 1R */
113 - if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) {
114 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 0);
115 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 0);
118 - if (rf->channel > 14)
119 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, 1);
120 + if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION)
121 + rt2800usb_config_channel_rt2x(rt2x00dev, conf, rf, info);
123 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
124 + rt2800usb_config_channel_rt3x(rt2x00dev, conf, rf, info);
127 * Change BBP settings
128 @@ -855,11 +837,6 @@ static void rt2800usb_config_channel(str
129 rt2800usb_bbp_write(rt2x00dev, 82, 0x84);
130 rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
133 - rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
134 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 0);
135 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 1);
136 - rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
138 rt2800usb_bbp_write(rt2x00dev, 82, 0xf2);
140 @@ -867,15 +844,45 @@ static void rt2800usb_config_channel(str
141 rt2800usb_bbp_write(rt2x00dev, 75, 0x46);
143 rt2800usb_bbp_write(rt2x00dev, 75, 0x50);
146 + rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
147 + rt2x00_set_field32(®, TX_BAND_CFG_HT40_PLUS, conf_is_ht40_plus(conf));
148 + rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14);
149 + rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14);
150 + rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
154 + /* Turn on unused PA or LNA when not using 1T or 1R */
155 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) != 1) {
156 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1);
157 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
160 - rt2x00usb_register_read(rt2x00dev, TX_BAND_CFG, ®);
161 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 1);
162 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 0);
163 - rt2x00usb_register_write(rt2x00dev, TX_BAND_CFG, reg);
164 + /* Turn on unused PA or LNA when not using 1T or 1R */
165 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) != 1) {
166 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
167 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
170 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
171 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
172 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
173 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
174 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, rf->channel <= 14);
175 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
177 rt2x00usb_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
179 + rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
180 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * conf_is_ht40(conf));
181 + rt2800usb_bbp_write(rt2x00dev, 4, bbp);
183 + rt2800usb_bbp_read(rt2x00dev, 3, &bbp);
184 + rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf));
185 + rt2800usb_bbp_write(rt2x00dev, 3, bbp);
190 @@ -1008,8 +1015,8 @@ static void rt2800usb_config(struct rt2x
191 rt2800usb_config_lna_gain(rt2x00dev, libconf);
193 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
194 - rt2800usb_config_channel(rt2x00dev, &libconf->rf,
195 - &libconf->channel);
196 + rt2800usb_config_channel(rt2x00dev, libconf->conf,
197 + &libconf->rf, &libconf->channel);
198 if (flags & IEEE80211_CONF_CHANGE_POWER)
199 rt2800usb_config_txpower(rt2x00dev, libconf->conf->power_level);
200 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
201 @@ -1643,7 +1650,7 @@ static u8 rt2800usb_init_rx_filter(struc
204 rt2800usb_bbp_read(rt2x00dev, 4, &bbp);
205 - rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0x10);
206 + rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2);
207 rt2800usb_bbp_write(rt2x00dev, 4, bbp);
210 @@ -2777,14 +2784,14 @@ static const struct rt2x00lib_ops rt2800
212 static const struct data_queue_desc rt2800usb_queue_rx = {
213 .entry_num = RX_ENTRIES,
214 - .data_size = DATA_FRAME_SIZE,
215 + .data_size = AGGREGATION_SIZE,
216 .desc_size = RXD_DESC_SIZE + RXWI_DESC_SIZE,
217 .priv_size = sizeof(struct queue_entry_priv_usb),
220 static const struct data_queue_desc rt2800usb_queue_tx = {
221 .entry_num = TX_ENTRIES,
222 - .data_size = DATA_FRAME_SIZE,
223 + .data_size = AGGREGATION_SIZE,
224 .desc_size = TXINFO_DESC_SIZE + TXWI_DESC_SIZE,
225 .priv_size = sizeof(struct queue_entry_priv_usb),
227 --- a/drivers/net/wireless/rt2x00/rt2800usb.h
228 +++ b/drivers/net/wireless/rt2x00/rt2800usb.h
230 * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
232 #define TX_BAND_CFG 0x132c
233 +#define TX_BAND_CFG_HT40_PLUS FIELD32(0x00000001)
234 #define TX_BAND_CFG_A FIELD32(0x00000002)
235 #define TX_BAND_CFG_BG FIELD32(0x00000004)
237 @@ -1482,10 +1483,12 @@ struct mac_iveiv_entry {
240 #define BBP3_RX_ANTENNA FIELD8(0x18)
241 +#define BBP3_HT40_PLUS FIELD8(0x20)
246 +#define BBP4_TX_BF FIELD8(0x01)
247 #define BBP4_BANDWIDTH FIELD8(0x18)
250 @@ -1548,7 +1551,7 @@ struct mac_iveiv_entry {
251 #define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
252 #define RF4_TXPOWER_A FIELD32(0x00000780)
253 #define RF4_FREQ_OFFSET FIELD32(0x001f8000)
254 -#define RF4_BW40 FIELD32(0x00200000)
255 +#define RF4_HT40 FIELD32(0x00200000)