aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2006-08-12 12:59:42 -0400
committerJohn W. Linville <linville@tuxdriver.com>2006-08-14 15:43:21 -0400
commit20fe2176e5edbeb5957f113df1282a917ef87b5d (patch)
treebf1b07ba5bc22060f42e37209d41bc51183b72f4 /drivers
parent98227a90a727029613f23c5e53554f1f4d7a1c89 (diff)
[PATCH] zd1211rw: AL2230 ZD1211B vendor sync
This patch synchronizes our code to some recent vendor driver modifications. A new PHY layout is supported, some values are tweaked, and the AL2230 is now programmed over a new interface which is many times faster. Signed-off-by: Daniel Drake <dsd@gentoo.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c44
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h4
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_al2230.c155
3 files changed, 152 insertions, 51 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 92ddcd952423..8cc693d80f7f 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -68,10 +68,11 @@ static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size)
68 i += scnprint_mac_oui(chip->e2p_mac, buffer+i, size-i); 68 i += scnprint_mac_oui(chip->e2p_mac, buffer+i, size-i);
69 i += scnprintf(buffer+i, size-i, " "); 69 i += scnprintf(buffer+i, size-i, " ");
70 i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i); 70 i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i);
71 i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c", chip->pa_type, 71 i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c", chip->pa_type,
72 chip->patch_cck_gain ? 'g' : '-', 72 chip->patch_cck_gain ? 'g' : '-',
73 chip->patch_cr157 ? '7' : '-', 73 chip->patch_cr157 ? '7' : '-',
74 chip->patch_6m_band_edge ? '6' : '-'); 74 chip->patch_6m_band_edge ? '6' : '-',
75 chip->new_phy_layout ? 'N' : '-');
75 return i; 76 return i;
76} 77}
77 78
@@ -330,13 +331,14 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
330 chip->patch_cck_gain = (value >> 8) & 0x1; 331 chip->patch_cck_gain = (value >> 8) & 0x1;
331 chip->patch_cr157 = (value >> 13) & 0x1; 332 chip->patch_cr157 = (value >> 13) & 0x1;
332 chip->patch_6m_band_edge = (value >> 21) & 0x1; 333 chip->patch_6m_band_edge = (value >> 21) & 0x1;
334 chip->new_phy_layout = (value >> 31) & 0x1;
333 335
334 dev_dbg_f(zd_chip_dev(chip), 336 dev_dbg_f(zd_chip_dev(chip),
335 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d " 337 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d "
336 "patch 6M %d\n", 338 "patch 6M %d new PHY %d\n",
337 zd_rf_name(*rf_type), *rf_type, 339 zd_rf_name(*rf_type), *rf_type,
338 chip->pa_type, chip->patch_cck_gain, 340 chip->pa_type, chip->patch_cck_gain,
339 chip->patch_cr157, chip->patch_6m_band_edge); 341 chip->patch_cr157, chip->patch_6m_band_edge, chip->new_phy_layout);
340 return 0; 342 return 0;
341error: 343error:
342 *rf_type = 0; 344 *rf_type = 0;
@@ -344,6 +346,7 @@ error:
344 chip->patch_cck_gain = 0; 346 chip->patch_cck_gain = 0;
345 chip->patch_cr157 = 0; 347 chip->patch_cr157 = 0;
346 chip->patch_6m_band_edge = 0; 348 chip->patch_6m_band_edge = 0;
349 chip->new_phy_layout = 0;
347 return r; 350 return r;
348} 351}
349 352
@@ -856,7 +859,7 @@ static int zd1211b_hw_init_hmac(struct zd_chip *chip)
856 { CR_RX_PE_DELAY, 0x70 }, 859 { CR_RX_PE_DELAY, 0x70 },
857 { CR_PS_CTRL, 0x10000000 }, 860 { CR_PS_CTRL, 0x10000000 },
858 { CR_RTS_CTS_RATE, 0x02030203 }, 861 { CR_RTS_CTS_RATE, 0x02030203 },
859 { CR_RX_THRESHOLD, 0x000c0640 }, 862 { CR_RX_THRESHOLD, 0x000c0eff, },
860 { CR_AFTER_PNP, 0x1 }, 863 { CR_AFTER_PNP, 0x1 },
861 { CR_WEP_PROTECT, 0x114 }, 864 { CR_WEP_PROTECT, 0x114 },
862 }; 865 };
@@ -1616,3 +1619,34 @@ int zd_rfwritev_locked(struct zd_chip *chip,
1616 1619
1617 return 0; 1620 return 0;
1618} 1621}
1622
1623/*
1624 * We can optionally program the RF directly through CR regs, if supported by
1625 * the hardware. This is much faster than the older method.
1626 */
1627static int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value)
1628{
1629 struct zd_ioreq16 ioreqs[] = {
1630 { CR244, (value >> 16) & 0xff },
1631 { CR243, (value >> 8) & 0xff },
1632 { CR242, value & 0xff },
1633 };
1634 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1635 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1636}
1637
1638int zd_rfwritev_cr_locked(struct zd_chip *chip,
1639 const u32 *values, unsigned int count)
1640{
1641 int r;
1642 unsigned int i;
1643
1644 for (i = 0; i < count; i++) {
1645 r = zd_rfwrite_cr_locked(chip, values[i]);
1646 if (r)
1647 return r;
1648 }
1649
1650 return 0;
1651}
1652
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index 4a412eea8818..a7fc61ba5874 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -663,7 +663,7 @@ struct zd_chip {
663 /* SetPointOFDM in the vendor driver */ 663 /* SetPointOFDM in the vendor driver */
664 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT]; 664 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
665 u8 pa_type:4, patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1, 665 u8 pa_type:4, patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
666 is_zd1211b:1; 666 new_phy_layout:1, is_zd1211b:1;
667}; 667};
668 668
669static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb) 669static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
@@ -749,6 +749,8 @@ static inline int zd_rfwrite_locked(struct zd_chip *chip, u32 value, u8 bits)
749 749
750int zd_rfwritev_locked(struct zd_chip *chip, 750int zd_rfwritev_locked(struct zd_chip *chip,
751 const u32* values, unsigned int count, u8 bits); 751 const u32* values, unsigned int count, u8 bits);
752int zd_rfwritev_cr_locked(struct zd_chip *chip,
753 const u32* values, unsigned int count);
752 754
753/* Locking functions for reading and writing registers. 755/* Locking functions for reading and writing registers.
754 * The different parameters are intentional. 756 * The different parameters are intentional.
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
index 0948b25f660d..25323a13a3db 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c
@@ -21,7 +21,7 @@
21#include "zd_usb.h" 21#include "zd_usb.h"
22#include "zd_chip.h" 22#include "zd_chip.h"
23 23
24static const u32 al2230_table[][3] = { 24static const u32 zd1211_al2230_table[][3] = {
25 RF_CHANNEL( 1) = { 0x03f790, 0x033331, 0x00000d, }, 25 RF_CHANNEL( 1) = { 0x03f790, 0x033331, 0x00000d, },
26 RF_CHANNEL( 2) = { 0x03f790, 0x0b3331, 0x00000d, }, 26 RF_CHANNEL( 2) = { 0x03f790, 0x0b3331, 0x00000d, },
27 RF_CHANNEL( 3) = { 0x03e790, 0x033331, 0x00000d, }, 27 RF_CHANNEL( 3) = { 0x03e790, 0x033331, 0x00000d, },
@@ -38,6 +38,53 @@ static const u32 al2230_table[][3] = {
38 RF_CHANNEL(14) = { 0x03e7c0, 0x066661, 0x00000d, }, 38 RF_CHANNEL(14) = { 0x03e7c0, 0x066661, 0x00000d, },
39}; 39};
40 40
41static const u32 zd1211b_al2230_table[][3] = {
42 RF_CHANNEL( 1) = { 0x09efc0, 0x8cccc0, 0xb00000, },
43 RF_CHANNEL( 2) = { 0x09efc0, 0x8cccd0, 0xb00000, },
44 RF_CHANNEL( 3) = { 0x09e7c0, 0x8cccc0, 0xb00000, },
45 RF_CHANNEL( 4) = { 0x09e7c0, 0x8cccd0, 0xb00000, },
46 RF_CHANNEL( 5) = { 0x05efc0, 0x8cccc0, 0xb00000, },
47 RF_CHANNEL( 6) = { 0x05efc0, 0x8cccd0, 0xb00000, },
48 RF_CHANNEL( 7) = { 0x05e7c0, 0x8cccc0, 0xb00000, },
49 RF_CHANNEL( 8) = { 0x05e7c0, 0x8cccd0, 0xb00000, },
50 RF_CHANNEL( 9) = { 0x0defc0, 0x8cccc0, 0xb00000, },
51 RF_CHANNEL(10) = { 0x0defc0, 0x8cccd0, 0xb00000, },
52 RF_CHANNEL(11) = { 0x0de7c0, 0x8cccc0, 0xb00000, },
53 RF_CHANNEL(12) = { 0x0de7c0, 0x8cccd0, 0xb00000, },
54 RF_CHANNEL(13) = { 0x03efc0, 0x8cccc0, 0xb00000, },
55 RF_CHANNEL(14) = { 0x03e7c0, 0x866660, 0xb00000, },
56};
57
58static const struct zd_ioreq16 zd1211b_ioreqs_shared_1[] = {
59 { CR240, 0x57 }, { CR9, 0xe0 },
60};
61
62static int zd1211b_al2230_finalize_rf(struct zd_chip *chip)
63{
64 int r;
65 static const struct zd_ioreq16 ioreqs[] = {
66 { CR80, 0x30 }, { CR81, 0x30 }, { CR79, 0x58 },
67 { CR12, 0xf0 }, { CR77, 0x1b }, { CR78, 0x58 },
68 { CR203, 0x06 },
69 { },
70
71 { CR240, 0x80 },
72 };
73
74 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
75 if (r)
76 return r;
77
78 /* related to antenna selection? */
79 if (chip->new_phy_layout) {
80 r = zd_iowrite16_locked(chip, 0xe1, CR9);
81 if (r)
82 return r;
83 }
84
85 return zd_iowrite16_locked(chip, 0x06, CR203);
86}
87
41static int zd1211_al2230_init_hw(struct zd_rf *rf) 88static int zd1211_al2230_init_hw(struct zd_rf *rf)
42{ 89{
43 int r; 90 int r;
@@ -139,7 +186,7 @@ static int zd1211b_al2230_init_hw(struct zd_rf *rf)
139 { CR47, 0x1e }, 186 { CR47, 0x1e },
140 187
141 /* ZD1211B 05.06.10 */ 188 /* ZD1211B 05.06.10 */
142 { CR48, 0x00 }, { CR49, 0x00 }, { CR51, 0x01 }, 189 { CR48, 0x06 }, { CR49, 0xf9 }, { CR51, 0x01 },
143 { CR52, 0x80 }, { CR53, 0x7e }, { CR65, 0x00 }, 190 { CR52, 0x80 }, { CR53, 0x7e }, { CR65, 0x00 },
144 { CR66, 0x00 }, { CR67, 0x00 }, { CR68, 0x00 }, 191 { CR66, 0x00 }, { CR67, 0x00 }, { CR68, 0x00 },
145 { CR69, 0x28 }, 192 { CR69, 0x28 },
@@ -172,79 +219,78 @@ static int zd1211b_al2230_init_hw(struct zd_rf *rf)
172 { CR137, 0x50 }, /* 5614 */ 219 { CR137, 0x50 }, /* 5614 */
173 { CR138, 0xa8 }, 220 { CR138, 0xa8 },
174 { CR144, 0xac }, /* 5621 */ 221 { CR144, 0xac }, /* 5621 */
175 { CR150, 0x0d }, { CR252, 0x00 }, { CR253, 0x00 }, 222 { CR150, 0x0d }, { CR252, 0x34 }, { CR253, 0x34 },
176 }; 223 };
177 224
178 static const u32 rv1[] = { 225 static const u32 rv1[] = {
179 /* channel 1 */ 226 0x8cccd0,
180 0x03f790, 227 0x481dc0,
181 0x033331, 228 0xcfff00,
182 0x00000d, 229 0x25a000,
183 230
184 0x0b3331, 231 /* To improve AL2230 yield, improve phase noise, 4713 */
185 0x03b812, 232 0x25a000,
186 0x00fff3, 233 0xa3b2f0,
187 0x0005a4, 234
188 0x0f4dc5, /* fix freq shift 0x044dc5 */ 235 0x6da010, /* Reg6 update for MP versio */
189 0x0805b6, 236 0xe36280, /* Modified by jxiao for Bor-Chin on 2004/08/02 */
190 0x0146c7, 237 0x116000,
191 0x000688, 238 0x9dc020, /* External control TX power (CR31) */
192 0x0403b9, /* External control TX power (CR31) */ 239 0x5ddb00, /* RegA update for MP version */
193 0x00dbba, 240 0xd99000, /* RegB update for MP version */
194 0x00099b, 241 0x3ffbd0, /* RegC update for MP version */
195 0x0bdffc, 242 0xb00000, /* RegD update for MP version */
196 0x00000d, 243
197 0x00580f, 244 /* improve phase noise and remove phase calibration,4713 */
245 0xf01a00,
198 }; 246 };
199 247
200 static const struct zd_ioreq16 ioreqs2[] = { 248 static const struct zd_ioreq16 ioreqs2[] = {
201 { CR47, 0x1e }, { CR_RFCFG, 0x03 }, 249 { CR251, 0x2f }, /* shdnb(PLL_ON)=0 */
250 { CR251, 0x7f }, /* shdnb(PLL_ON)=1 */
202 }; 251 };
203 252
204 static const u32 rv2[] = { 253 static const u32 rv2[] = {
205 0x00880f, 254 /* To improve AL2230 yield, 4713 */
206 0x00080f, 255 0xf01b00,
256 0xf01e00,
257 0xf01a00,
207 }; 258 };
208 259
209 static const struct zd_ioreq16 ioreqs3[] = { 260 static const struct zd_ioreq16 ioreqs3[] = {
210 { CR_RFCFG, 0x00 }, { CR47, 0x1e }, { CR251, 0x7f }, 261 /* related to 6M band edge patching, happens unconditionally */
211 }; 262 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
212
213 static const u32 rv3[] = {
214 0x00d80f,
215 0x00780f,
216 0x00580f,
217 };
218
219 static const struct zd_ioreq16 ioreqs4[] = {
220 { CR138, 0x28 }, { CR203, 0x06 },
221 }; 263 };
222 264
265 r = zd_iowrite16a_locked(chip, zd1211b_ioreqs_shared_1,
266 ARRAY_SIZE(zd1211b_ioreqs_shared_1));
267 if (r)
268 return r;
223 r = zd_iowrite16a_locked(chip, ioreqs1, ARRAY_SIZE(ioreqs1)); 269 r = zd_iowrite16a_locked(chip, ioreqs1, ARRAY_SIZE(ioreqs1));
224 if (r) 270 if (r)
225 return r; 271 return r;
226 r = zd_rfwritev_locked(chip, rv1, ARRAY_SIZE(rv1), RF_RV_BITS); 272 r = zd_rfwritev_cr_locked(chip, zd1211b_al2230_table[0], 3);
227 if (r) 273 if (r)
228 return r; 274 return r;
229 r = zd_iowrite16a_locked(chip, ioreqs2, ARRAY_SIZE(ioreqs2)); 275 r = zd_rfwritev_cr_locked(chip, rv1, ARRAY_SIZE(rv1));
230 if (r) 276 if (r)
231 return r; 277 return r;
232 r = zd_rfwritev_locked(chip, rv2, ARRAY_SIZE(rv2), RF_RV_BITS); 278 r = zd_iowrite16a_locked(chip, ioreqs2, ARRAY_SIZE(ioreqs2));
233 if (r) 279 if (r)
234 return r; 280 return r;
235 r = zd_iowrite16a_locked(chip, ioreqs3, ARRAY_SIZE(ioreqs3)); 281 r = zd_rfwritev_cr_locked(chip, rv2, ARRAY_SIZE(rv2));
236 if (r) 282 if (r)
237 return r; 283 return r;
238 r = zd_rfwritev_locked(chip, rv3, ARRAY_SIZE(rv3), RF_RV_BITS); 284 r = zd_iowrite16a_locked(chip, ioreqs3, ARRAY_SIZE(ioreqs3));
239 if (r) 285 if (r)
240 return r; 286 return r;
241 return zd_iowrite16a_locked(chip, ioreqs4, ARRAY_SIZE(ioreqs4)); 287 return zd1211b_al2230_finalize_rf(chip);
242} 288}
243 289
244static int al2230_set_channel(struct zd_rf *rf, u8 channel) 290static int zd1211_al2230_set_channel(struct zd_rf *rf, u8 channel)
245{ 291{
246 int r; 292 int r;
247 const u32 *rv = al2230_table[channel-1]; 293 const u32 *rv = zd1211_al2230_table[channel-1];
248 struct zd_chip *chip = zd_rf_to_chip(rf); 294 struct zd_chip *chip = zd_rf_to_chip(rf);
249 static const struct zd_ioreq16 ioreqs[] = { 295 static const struct zd_ioreq16 ioreqs[] = {
250 { CR138, 0x28 }, 296 { CR138, 0x28 },
@@ -257,6 +303,24 @@ static int al2230_set_channel(struct zd_rf *rf, u8 channel)
257 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 303 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
258} 304}
259 305
306static int zd1211b_al2230_set_channel(struct zd_rf *rf, u8 channel)
307{
308 int r;
309 const u32 *rv = zd1211b_al2230_table[channel-1];
310 struct zd_chip *chip = zd_rf_to_chip(rf);
311
312 r = zd_iowrite16a_locked(chip, zd1211b_ioreqs_shared_1,
313 ARRAY_SIZE(zd1211b_ioreqs_shared_1));
314 if (r)
315 return r;
316
317 r = zd_rfwritev_cr_locked(chip, rv, 3);
318 if (r)
319 return r;
320
321 return zd1211b_al2230_finalize_rf(chip);
322}
323
260static int zd1211_al2230_switch_radio_on(struct zd_rf *rf) 324static int zd1211_al2230_switch_radio_on(struct zd_rf *rf)
261{ 325{
262 struct zd_chip *chip = zd_rf_to_chip(rf); 326 struct zd_chip *chip = zd_rf_to_chip(rf);
@@ -294,13 +358,14 @@ int zd_rf_init_al2230(struct zd_rf *rf)
294{ 358{
295 struct zd_chip *chip = zd_rf_to_chip(rf); 359 struct zd_chip *chip = zd_rf_to_chip(rf);
296 360
297 rf->set_channel = al2230_set_channel;
298 rf->switch_radio_off = al2230_switch_radio_off; 361 rf->switch_radio_off = al2230_switch_radio_off;
299 if (chip->is_zd1211b) { 362 if (chip->is_zd1211b) {
300 rf->init_hw = zd1211b_al2230_init_hw; 363 rf->init_hw = zd1211b_al2230_init_hw;
364 rf->set_channel = zd1211b_al2230_set_channel;
301 rf->switch_radio_on = zd1211b_al2230_switch_radio_on; 365 rf->switch_radio_on = zd1211b_al2230_switch_radio_on;
302 } else { 366 } else {
303 rf->init_hw = zd1211_al2230_init_hw; 367 rf->init_hw = zd1211_al2230_init_hw;
368 rf->set_channel = zd1211_al2230_set_channel;
304 rf->switch_radio_on = zd1211_al2230_switch_radio_on; 369 rf->switch_radio_on = zd1211_al2230_switch_radio_on;
305 } 370 }
306 rf->patch_6m_band_edge = 1; 371 rf->patch_6m_band_edge = 1;