ath9k: add some cleanups and minor fixes
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 610-rt2x00-fix-rt3352-ext-pa.patch
1 --- a/drivers/net/wireless/rt2x00/rt2800lib.c
2 +++ b/drivers/net/wireless/rt2x00/rt2800lib.c
3 @@ -3186,11 +3186,17 @@ static void rt2800_config_channel(struct
4 /*
5 * Change BBP settings
6 */
7 + rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
8 + rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
9 + rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
10 +
11 if (rt2x00_rt(rt2x00dev, RT3352)) {
12 rt2800_bbp_write(rt2x00dev, 27, 0x0);
13 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
14 rt2800_bbp_write(rt2x00dev, 27, 0x20);
15 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain);
16 + rt2800_bbp_write(rt2x00dev, 86, 0x38);
17 + rt2800_bbp_write(rt2x00dev, 83, 0x6a);
18 } else if (rt2x00_rt(rt2x00dev, RT3593)) {
19 if (rf->channel > 14) {
20 /* Disable CCK Packet detection on 5GHz */
21 @@ -3204,14 +3210,8 @@ static void rt2800_config_channel(struct
22 else
23 rt2800_bbp_write(rt2x00dev, 105, 0x34);
24
25 - rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
26 - rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
27 - rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
28 rt2800_bbp_write(rt2x00dev, 77, 0x98);
29 } else {
30 - rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
31 - rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
32 - rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
33 rt2800_bbp_write(rt2x00dev, 86, 0);
34 }
35
36 @@ -6093,6 +6093,12 @@ static void rt2800_init_rfcsr_3290(struc
37
38 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
39 {
40 + int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
41 + &rt2x00dev->cap_flags);
42 + int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
43 + &rt2x00dev->cap_flags);
44 + u8 rfcsr;
45 +
46 rt2800_rf_init_calibration(rt2x00dev, 30);
47
48 rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
49 @@ -6128,15 +6134,30 @@ static void rt2800_init_rfcsr_3352(struc
50 rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
51 rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
52 rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
53 - rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
54 + rfcsr = 0x01;
55 + if (!tx0_int_pa)
56 + rt2x00_set_field8(&rfcsr, RFCSR34_TX0_EXT_PA, 1);
57 + if (!tx1_int_pa)
58 + rt2x00_set_field8(&rfcsr, RFCSR34_TX1_EXT_PA, 1);
59 + rt2800_rfcsr_write(rt2x00dev, 34, rfcsr);
60 rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
61 rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);
62 rt2800_rfcsr_write(rt2x00dev, 37, 0x3c);
63 rt2800_rfcsr_write(rt2x00dev, 38, 0x5f);
64 rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
65 rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
66 - rt2800_rfcsr_write(rt2x00dev, 41, 0x5b);
67 - rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
68 + rfcsr = 0x52;
69 + if (tx0_int_pa) {
70 + rt2x00_set_field8(&rfcsr, RFCSR41_BIT1, 1);
71 + rt2x00_set_field8(&rfcsr, RFCSR41_BIT4, 1);
72 + }
73 + rt2800_rfcsr_write(rt2x00dev, 41, rfcsr);
74 + rfcsr = 0x52;
75 + if (tx1_int_pa) {
76 + rt2x00_set_field8(&rfcsr, RFCSR42_BIT1, 1);
77 + rt2x00_set_field8(&rfcsr, RFCSR42_BIT4, 1);
78 + }
79 + rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
80 rt2800_rfcsr_write(rt2x00dev, 43, 0xdb);
81 rt2800_rfcsr_write(rt2x00dev, 44, 0xdb);
82 rt2800_rfcsr_write(rt2x00dev, 45, 0xdb);
83 @@ -6144,15 +6165,20 @@ static void rt2800_init_rfcsr_3352(struc
84 rt2800_rfcsr_write(rt2x00dev, 47, 0x0d);
85 rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
86 rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
87 - rt2800_rfcsr_write(rt2x00dev, 50, 0x2d);
88 - rt2800_rfcsr_write(rt2x00dev, 51, 0x7f);
89 - rt2800_rfcsr_write(rt2x00dev, 52, 0x00);
90 - rt2800_rfcsr_write(rt2x00dev, 53, 0x52);
91 - rt2800_rfcsr_write(rt2x00dev, 54, 0x1b);
92 - rt2800_rfcsr_write(rt2x00dev, 55, 0x7f);
93 - rt2800_rfcsr_write(rt2x00dev, 56, 0x00);
94 - rt2800_rfcsr_write(rt2x00dev, 57, 0x52);
95 - rt2800_rfcsr_write(rt2x00dev, 58, 0x1b);
96 + rfcsr = 0x2d;
97 + if (!tx0_int_pa)
98 + rt2x00_set_field8(&rfcsr, RFCSR50_TX0_EXT_PA, 1);
99 + if (!tx1_int_pa)
100 + rt2x00_set_field8(&rfcsr, RFCSR50_TX1_EXT_PA, 1);
101 + rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
102 + rt2800_rfcsr_write(rt2x00dev, 51, (tx0_int_pa ? 0x7f : 0x52));
103 + rt2800_rfcsr_write(rt2x00dev, 52, (tx0_int_pa ? 0x00 : 0xc0));
104 + rt2800_rfcsr_write(rt2x00dev, 53, (tx0_int_pa ? 0x52 : 0xd2));
105 + rt2800_rfcsr_write(rt2x00dev, 54, (tx0_int_pa ? 0x1b : 0xc0));
106 + rt2800_rfcsr_write(rt2x00dev, 55, (tx1_int_pa ? 0x7f : 0x52));
107 + rt2800_rfcsr_write(rt2x00dev, 56, (tx1_int_pa ? 0x00 : 0xc0));
108 + rt2800_rfcsr_write(rt2x00dev, 57, (tx0_int_pa ? 0x52 : 0x49));
109 + rt2800_rfcsr_write(rt2x00dev, 58, (tx1_int_pa ? 0x1b : 0xc0));
110 rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
111 rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
112 rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
113 @@ -7004,6 +7030,7 @@ static int rt2800_init_eeprom(struct rt2
114 * RT53xx: defined in "EEPROM_CHIP_ID" field
115 */
116 if (rt2x00_rt(rt2x00dev, RT3290) ||
117 + rt2x00_rt(rt2x00dev, RT3352) ||
118 rt2x00_rt(rt2x00dev, RT5390) ||
119 rt2x00_rt(rt2x00dev, RT5392))
120 rt2800_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
121 @@ -7094,7 +7121,8 @@ static int rt2800_init_eeprom(struct rt2
122 /*
123 * Detect if this device has Bluetooth co-existence.
124 */
125 - if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
126 + if (!rt2x00_rt(rt2x00dev, RT3352) &&
127 + rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
128 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
129
130 /*
131 @@ -7123,6 +7151,22 @@ static int rt2800_init_eeprom(struct rt2
132 EIRP_MAX_TX_POWER_LIMIT)
133 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
134
135 + /*
136 + * Detect if device uses internal or external PA
137 + */
138 + rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
139 +
140 + if (rt2x00_rt(rt2x00dev, RT3352)) {
141 + if (!rt2x00_get_field16(eeprom,
142 + EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
143 + __set_bit(CAPABILITY_INTERNAL_PA_TX0,
144 + &rt2x00dev->cap_flags);
145 + if (!rt2x00_get_field16(eeprom,
146 + EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352))
147 + __set_bit(CAPABILITY_INTERNAL_PA_TX1,
148 + &rt2x00dev->cap_flags);
149 + }
150 +
151 return 0;
152 }
153
154 --- a/drivers/net/wireless/rt2x00/rt2800.h
155 +++ b/drivers/net/wireless/rt2x00/rt2800.h
156 @@ -2299,6 +2299,12 @@ struct mac_iveiv_entry {
157 #define RFCSR36_RF_BS FIELD8(0x80)
158
159 /*
160 + * RFCSR 34:
161 + */
162 +#define RFCSR34_TX0_EXT_PA FIELD8(0x04)
163 +#define RFCSR34_TX1_EXT_PA FIELD8(0x08)
164 +
165 +/*
166 * RFCSR 38:
167 */
168 #define RFCSR38_RX_LO1_EN FIELD8(0x20)
169 @@ -2310,6 +2316,18 @@ struct mac_iveiv_entry {
170 #define RFCSR39_RX_LO2_EN FIELD8(0x80)
171
172 /*
173 + * RFCSR 41:
174 + */
175 +#define RFCSR41_BIT1 FIELD8(0x01)
176 +#define RFCSR41_BIT4 FIELD8(0x08)
177 +
178 +/*
179 + * RFCSR 42:
180 + */
181 +#define RFCSR42_BIT1 FIELD8(0x01)
182 +#define RFCSR42_BIT4 FIELD8(0x08)
183 +
184 +/*
185 * RFCSR 49:
186 */
187 #define RFCSR49_TX FIELD8(0x3f)
188 @@ -2322,6 +2340,8 @@ struct mac_iveiv_entry {
189 * RFCSR 50:
190 */
191 #define RFCSR50_TX FIELD8(0x3f)
192 +#define RFCSR50_TX0_EXT_PA FIELD8(0x02)
193 +#define RFCSR50_TX1_EXT_PA FIELD8(0x10)
194 #define RFCSR50_EP FIELD8(0xc0)
195 /* bits for RT3593 */
196 #define RFCSR50_TX_LO1_EN FIELD8(0x20)
197 @@ -2469,6 +2489,8 @@ enum rt2800_eeprom_word {
198 * INTERNAL_TX_ALC: 0: disable, 1: enable
199 * BT_COEXIST: 0: disable, 1: enable
200 * DAC_TEST: 0: disable, 1: enable
201 + * EXTERNAL_TX0_PA: 0: disable, 1: enable (only on RT3352)
202 + * EXTERNAL_TX1_PA: 0: disable, 1: enable (only on RT3352)
203 */
204 #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001)
205 #define EEPROM_NIC_CONF1_EXTERNAL_TX_ALC FIELD16(0x0002)
206 @@ -2485,6 +2507,8 @@ enum rt2800_eeprom_word {
207 #define EEPROM_NIC_CONF1_INTERNAL_TX_ALC FIELD16(0x2000)
208 #define EEPROM_NIC_CONF1_BT_COEXIST FIELD16(0x4000)
209 #define EEPROM_NIC_CONF1_DAC_TEST FIELD16(0x8000)
210 +#define EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352 FIELD16(0x4000)
211 +#define EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352 FIELD16(0x8000)
212
213 /*
214 * EEPROM frequency
215 --- a/drivers/net/wireless/rt2x00/rt2x00.h
216 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
217 @@ -727,6 +727,8 @@ enum rt2x00_capability_flags {
218 CAPABILITY_DOUBLE_ANTENNA,
219 CAPABILITY_BT_COEXIST,
220 CAPABILITY_VCO_RECALIBRATION,
221 + CAPABILITY_INTERNAL_PA_TX0,
222 + CAPABILITY_INTERNAL_PA_TX1,
223 };
224
225 /*