madwifi: improve the autochannel decision making on systems with multiple cards
[openwrt/openwrt.git] / package / mac80211 / patches / 311-rt2x00-Channel-HT40-fixes-rt2800pci.patch
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)
5
6 Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
7 ---
8 drivers/net/wireless/rt2x00/rt2800pci.c | 69 +++++++++++++++----------------
9 drivers/net/wireless/rt2x00/rt2800pci.h | 3 +-
10 2 files changed, 36 insertions(+), 36 deletions(-)
11
12 --- a/drivers/net/wireless/rt2x00/rt2800pci.c
13 +++ b/drivers/net/wireless/rt2x00/rt2800pci.c
14 @@ -603,7 +603,7 @@ static void rt2800pci_config_ant(struct
15 rt2x00_set_field8(&r3, BBP3_RX_ANTENNA, 0);
16 break;
17 case 2:
18 - rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 16);
19 + rt2x00_set_field8(&r1, BBP1_TX_ANTENNA, 2);
20 break;
21 case 3:
22 /* Do nothing */
23 @@ -653,6 +653,7 @@ static void rt2800pci_config_lna_gain(st
24 }
25
26 static void rt2800pci_config_channel(struct rt2x00_dev *rt2x00dev,
27 + struct ieee80211_conf *conf,
28 struct rf_channel *rf,
29 struct channel_info *info)
30 {
31 @@ -660,34 +661,20 @@ static void rt2800pci_config_channel(str
32 unsigned int tx_pin;
33 u16 eeprom;
34
35 - tx_pin = 0;
36 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
37 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
38 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
39 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
40 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
41 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
42 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
43 -
44 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset);
45
46 /*
47 * Determine antenna settings from EEPROM
48 */
49 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
50 +
51 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) == 1) {
52 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1);
53 - /* Turn off unused PA or LNA when only 1T or 1R */
54 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 0);
55 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 0);
56 }
57
58 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 1) {
59 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1);
60 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
61 - /* Turn off unused PA or LNA when only 1T or 1R */
62 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 0);
63 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 0);
64 } else if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) == 2)
65 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1);
66
67 @@ -715,19 +702,14 @@ static void rt2800pci_config_channel(str
68
69 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A,
70 TXPOWER_A_TO_DEV(info->tx_power2));
71 -
72 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, 1);
73 } else {
74 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G,
75 TXPOWER_G_TO_DEV(info->tx_power1));
76 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G,
77 TXPOWER_G_TO_DEV(info->tx_power2));
78 -
79 - rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, 1);
80 }
81
82 - rt2x00_set_field32(&rf->rf4, RF4_BW40,
83 - test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags));
84 + rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf));
85
86 rt2800pci_rf_write(rt2x00dev, 1, rf->rf1);
87 rt2800pci_rf_write(rt2x00dev, 2, rf->rf2);
88 @@ -764,11 +746,6 @@ static void rt2800pci_config_channel(str
89 rt2800pci_bbp_write(rt2x00dev, 82, 0x84);
90 rt2800pci_bbp_write(rt2x00dev, 75, 0x50);
91 }
92 -
93 - rt2x00pci_register_read(rt2x00dev, TX_BAND_CFG, &reg);
94 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 0);
95 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 1);
96 - rt2x00pci_register_write(rt2x00dev, TX_BAND_CFG, reg);
97 } else {
98 rt2800pci_bbp_write(rt2x00dev, 82, 0xf2);
99
100 @@ -776,13 +753,35 @@ static void rt2800pci_config_channel(str
101 rt2800pci_bbp_write(rt2x00dev, 75, 0x46);
102 else
103 rt2800pci_bbp_write(rt2x00dev, 75, 0x50);
104 + }
105
106 - rt2x00pci_register_read(rt2x00dev, TX_BAND_CFG, &reg);
107 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_A, 1);
108 - rt2x00_set_field32(&rf->rf3, TX_BAND_CFG_BG, 0);
109 - rt2x00pci_register_write(rt2x00dev, TX_BAND_CFG, reg);
110 + rt2x00pci_register_read(rt2x00dev, TX_BAND_CFG, &reg);
111 + rt2x00_set_field32(&reg, TX_BAND_CFG_HT40_PLUS, conf_is_ht40_plus(conf));
112 + rt2x00_set_field32(&reg, TX_BAND_CFG_A, rf->channel > 14);
113 + rt2x00_set_field32(&reg, TX_BAND_CFG_BG, rf->channel <= 14);
114 + rt2x00pci_register_write(rt2x00dev, TX_BAND_CFG, reg);
115 +
116 + tx_pin = 0;
117 +
118 + /* Turn on unused PA or LNA when not using 1T or 1R */
119 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) != 1) {
120 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A1_EN, 1);
121 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G1_EN, 1);
122 + }
123 +
124 + /* Turn on unused PA or LNA when not using 1T or 1R */
125 + if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH) != 1) {
126 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A1_EN, 1);
127 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G1_EN, 1);
128 }
129
130 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_A0_EN, 1);
131 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_LNA_PE_G0_EN, 1);
132 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
133 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
134 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_G0_EN, rf->channel <= 14);
135 + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_PA_PE_A0_EN, rf->channel > 14);
136 +
137 rt2x00pci_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
138
139 msleep(1);
140 @@ -917,8 +916,8 @@ static void rt2800pci_config(struct rt2x
141 rt2800pci_config_lna_gain(rt2x00dev, libconf);
142
143 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
144 - rt2800pci_config_channel(rt2x00dev, &libconf->rf,
145 - &libconf->channel);
146 + rt2800pci_config_channel(rt2x00dev, libconf->conf,
147 + &libconf->rf, &libconf->channel);
148 if (flags & IEEE80211_CONF_CHANGE_POWER)
149 rt2800pci_config_txpower(rt2x00dev, libconf->conf->power_level);
150 if (flags & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
151 @@ -2724,14 +2723,14 @@ static const struct rt2x00lib_ops rt2800
152
153 static const struct data_queue_desc rt2800pci_queue_rx = {
154 .entry_num = RX_ENTRIES,
155 - .data_size = DATA_FRAME_SIZE,
156 + .data_size = AGGREGATION_SIZE,
157 .desc_size = RXD_DESC_SIZE,
158 .priv_size = sizeof(struct queue_entry_priv_pci),
159 };
160
161 static const struct data_queue_desc rt2800pci_queue_tx = {
162 .entry_num = TX_ENTRIES,
163 - .data_size = DATA_FRAME_SIZE,
164 + .data_size = AGGREGATION_SIZE,
165 .desc_size = TXD_DESC_SIZE,
166 .priv_size = sizeof(struct queue_entry_priv_pci),
167 };
168 --- a/drivers/net/wireless/rt2x00/rt2800pci.h
169 +++ b/drivers/net/wireless/rt2x00/rt2800pci.h
170 @@ -791,6 +791,7 @@
171 * TX_BAND_CFG: 0x1 use upper 20MHz, 0x0 use lower 20MHz
172 */
173 #define TX_BAND_CFG 0x132c
174 +#define TX_BAND_CFG_HT40_PLUS FIELD32(0x00000001)
175 #define TX_BAND_CFG_A FIELD32(0x00000002)
176 #define TX_BAND_CFG_BG FIELD32(0x00000004)
177
178 @@ -1496,7 +1497,7 @@ struct mac_iveiv_entry {
179 #define RF4_TXPOWER_A_7DBM_BOOST FIELD32(0x00000040)
180 #define RF4_TXPOWER_A FIELD32(0x00000780)
181 #define RF4_FREQ_OFFSET FIELD32(0x001f8000)
182 -#define RF4_BW40 FIELD32(0x00200000)
183 +#define RF4_HT40 FIELD32(0x00200000)
184
185 /*
186 * EEPROM content.