mac80211: update to wireless-testing 2013-06-27, fix ATH_USER_REGD handling
[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 @@ -2631,15 +2631,18 @@ 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 {
19 - rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain);
20 - rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain);
21 - rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain);
22 rt2800_bbp_write(rt2x00dev, 86, 0);
23 }
24
25 @@ -4971,6 +4974,12 @@ static void rt2800_init_rfcsr_3290(struc
26
27 static void rt2800_init_rfcsr_3352(struct rt2x00_dev *rt2x00dev)
28 {
29 + int tx0_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX0,
30 + &rt2x00dev->cap_flags);
31 + int tx1_int_pa = test_bit(CAPABILITY_INTERNAL_PA_TX1,
32 + &rt2x00dev->cap_flags);
33 + u8 rfcsr;
34 +
35 rt2800_rf_init_calibration(rt2x00dev, 30);
36
37 rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
38 @@ -5006,15 +5015,30 @@ static void rt2800_init_rfcsr_3352(struc
39 rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
40 rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
41 rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
42 - rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
43 + rfcsr = 0x01;
44 + if (!tx0_int_pa)
45 + rt2x00_set_field8(&rfcsr, RFCSR34_TX0_EXT_PA, 1);
46 + if (!tx1_int_pa)
47 + rt2x00_set_field8(&rfcsr, RFCSR34_TX1_EXT_PA, 1);
48 + rt2800_rfcsr_write(rt2x00dev, 34, rfcsr);
49 rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
50 rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);
51 rt2800_rfcsr_write(rt2x00dev, 37, 0x3c);
52 rt2800_rfcsr_write(rt2x00dev, 38, 0x5f);
53 rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
54 rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
55 - rt2800_rfcsr_write(rt2x00dev, 41, 0x5b);
56 - rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
57 + rfcsr = 0x52;
58 + if (tx0_int_pa) {
59 + rt2x00_set_field8(&rfcsr, RFCSR41_BIT1, 1);
60 + rt2x00_set_field8(&rfcsr, RFCSR41_BIT4, 1);
61 + }
62 + rt2800_rfcsr_write(rt2x00dev, 41, rfcsr);
63 + rfcsr = 0x52;
64 + if (tx1_int_pa) {
65 + rt2x00_set_field8(&rfcsr, RFCSR42_BIT1, 1);
66 + rt2x00_set_field8(&rfcsr, RFCSR42_BIT4, 1);
67 + }
68 + rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
69 rt2800_rfcsr_write(rt2x00dev, 43, 0xdb);
70 rt2800_rfcsr_write(rt2x00dev, 44, 0xdb);
71 rt2800_rfcsr_write(rt2x00dev, 45, 0xdb);
72 @@ -5022,15 +5046,20 @@ static void rt2800_init_rfcsr_3352(struc
73 rt2800_rfcsr_write(rt2x00dev, 47, 0x0d);
74 rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
75 rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
76 - rt2800_rfcsr_write(rt2x00dev, 50, 0x2d);
77 - rt2800_rfcsr_write(rt2x00dev, 51, 0x7f);
78 - rt2800_rfcsr_write(rt2x00dev, 52, 0x00);
79 - rt2800_rfcsr_write(rt2x00dev, 53, 0x52);
80 - rt2800_rfcsr_write(rt2x00dev, 54, 0x1b);
81 - rt2800_rfcsr_write(rt2x00dev, 55, 0x7f);
82 - rt2800_rfcsr_write(rt2x00dev, 56, 0x00);
83 - rt2800_rfcsr_write(rt2x00dev, 57, 0x52);
84 - rt2800_rfcsr_write(rt2x00dev, 58, 0x1b);
85 + rfcsr = 0x2d;
86 + if (!tx0_int_pa)
87 + rt2x00_set_field8(&rfcsr, RFCSR50_TX0_EXT_PA, 1);
88 + if (!tx1_int_pa)
89 + rt2x00_set_field8(&rfcsr, RFCSR50_TX1_EXT_PA, 1);
90 + rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
91 + rt2800_rfcsr_write(rt2x00dev, 51, (tx0_int_pa ? 0x7f : 0x52));
92 + rt2800_rfcsr_write(rt2x00dev, 52, (tx0_int_pa ? 0x00 : 0xc0));
93 + rt2800_rfcsr_write(rt2x00dev, 53, (tx0_int_pa ? 0x52 : 0xd2));
94 + rt2800_rfcsr_write(rt2x00dev, 54, (tx0_int_pa ? 0x1b : 0xc0));
95 + rt2800_rfcsr_write(rt2x00dev, 55, (tx1_int_pa ? 0x7f : 0x52));
96 + rt2800_rfcsr_write(rt2x00dev, 56, (tx1_int_pa ? 0x00 : 0xc0));
97 + rt2800_rfcsr_write(rt2x00dev, 57, (tx0_int_pa ? 0x52 : 0x49));
98 + rt2800_rfcsr_write(rt2x00dev, 58, (tx1_int_pa ? 0x1b : 0xc0));
99 rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
100 rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
101 rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
102 @@ -5715,6 +5744,7 @@ static int rt2800_init_eeprom(struct rt2
103 * RT53xx: defined in "EEPROM_CHIP_ID" field
104 */
105 if (rt2x00_rt(rt2x00dev, RT3290) ||
106 + rt2x00_rt(rt2x00dev, RT3352) ||
107 rt2x00_rt(rt2x00dev, RT5390) ||
108 rt2x00_rt(rt2x00dev, RT5392))
109 rt2x00_eeprom_read(rt2x00dev, EEPROM_CHIP_ID, &rf);
110 @@ -5804,7 +5834,8 @@ static int rt2800_init_eeprom(struct rt2
111 /*
112 * Detect if this device has Bluetooth co-existence.
113 */
114 - if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
115 + if (!rt2x00_rt(rt2x00dev, RT3352) &&
116 + rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
117 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
118
119 /*
120 @@ -5833,6 +5864,22 @@ static int rt2800_init_eeprom(struct rt2
121 EIRP_MAX_TX_POWER_LIMIT)
122 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
123
124 + /*
125 + * Detect if device uses internal or external PA
126 + */
127 + rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
128 +
129 + if (rt2x00_rt(rt2x00dev, RT3352)) {
130 + if (!rt2x00_get_field16(eeprom,
131 + EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352))
132 + __set_bit(CAPABILITY_INTERNAL_PA_TX0,
133 + &rt2x00dev->cap_flags);
134 + if (!rt2x00_get_field16(eeprom,
135 + EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352))
136 + __set_bit(CAPABILITY_INTERNAL_PA_TX1,
137 + &rt2x00dev->cap_flags);
138 + }
139 +
140 return 0;
141 }
142
143 --- a/drivers/net/wireless/rt2x00/rt2800.h
144 +++ b/drivers/net/wireless/rt2x00/rt2800.h
145 @@ -2153,6 +2153,12 @@ struct mac_iveiv_entry {
146 #define RFCSR31_RX_CALIB FIELD8(0x7f)
147
148 /*
149 + * RFCSR 34:
150 + */
151 +#define RFCSR34_TX0_EXT_PA FIELD8(0x04)
152 +#define RFCSR34_TX1_EXT_PA FIELD8(0x08)
153 +
154 +/*
155 * RFCSR 38:
156 */
157 #define RFCSR38_RX_LO1_EN FIELD8(0x20)
158 @@ -2163,6 +2169,18 @@ struct mac_iveiv_entry {
159 #define RFCSR39_RX_LO2_EN FIELD8(0x80)
160
161 /*
162 + * RFCSR 41:
163 + */
164 +#define RFCSR41_BIT1 FIELD8(0x01)
165 +#define RFCSR41_BIT4 FIELD8(0x08)
166 +
167 +/*
168 + * RFCSR 42:
169 + */
170 +#define RFCSR42_BIT1 FIELD8(0x01)
171 +#define RFCSR42_BIT4 FIELD8(0x08)
172 +
173 +/*
174 * RFCSR 49:
175 */
176 #define RFCSR49_TX FIELD8(0x3f)
177 @@ -2172,6 +2190,8 @@ struct mac_iveiv_entry {
178 * RFCSR 50:
179 */
180 #define RFCSR50_TX FIELD8(0x3f)
181 +#define RFCSR50_TX0_EXT_PA FIELD8(0x02)
182 +#define RFCSR50_TX1_EXT_PA FIELD8(0x10)
183 #define RFCSR50_EP FIELD8(0xc0)
184
185 /*
186 @@ -2260,6 +2280,8 @@ struct mac_iveiv_entry {
187 * INTERNAL_TX_ALC: 0: disable, 1: enable
188 * BT_COEXIST: 0: disable, 1: enable
189 * DAC_TEST: 0: disable, 1: enable
190 + * EXTERNAL_TX0_PA: 0: disable, 1: enable (only on RT3352)
191 + * EXTERNAL_TX1_PA: 0: disable, 1: enable (only on RT3352)
192 */
193 #define EEPROM_NIC_CONF1 0x001b
194 #define EEPROM_NIC_CONF1_HW_RADIO FIELD16(0x0001)
195 @@ -2277,6 +2299,8 @@ struct mac_iveiv_entry {
196 #define EEPROM_NIC_CONF1_INTERNAL_TX_ALC FIELD16(0x2000)
197 #define EEPROM_NIC_CONF1_BT_COEXIST FIELD16(0x4000)
198 #define EEPROM_NIC_CONF1_DAC_TEST FIELD16(0x8000)
199 +#define EEPROM_NIC_CONF1_EXTERNAL_TX0_PA_3352 FIELD16(0x4000)
200 +#define EEPROM_NIC_CONF1_EXTERNAL_TX1_PA_3352 FIELD16(0x8000)
201
202 /*
203 * EEPROM frequency
204 --- a/drivers/net/wireless/rt2x00/rt2x00.h
205 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
206 @@ -726,6 +726,8 @@ enum rt2x00_capability_flags {
207 CAPABILITY_DOUBLE_ANTENNA,
208 CAPABILITY_BT_COEXIST,
209 CAPABILITY_VCO_RECALIBRATION,
210 + CAPABILITY_INTERNAL_PA_TX0,
211 + CAPABILITY_INTERNAL_PA_TX1,
212 };
213
214 /*