aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2007-04-07 11:00:30 -0400
committerJeff Garzik <jeff@garzik.org>2007-04-28 11:01:04 -0400
commitba528c4587005a004d136ed2e69705401ee4b878 (patch)
tree3bba6f763a41ff1c307af5df5e6150c4c68e7f2c /drivers/net/wireless/zd1211rw
parent72018b223dcacb631f140d4c8fada3790bd1b03c (diff)
[PATCH] zd1211rw: Add AL7230B RF support for ZD1211B
This patch adds support for some new ZD1211B devices which ship with the AL7230B RF. Signed-off-by: Daniel Drake <dsd@gentoo.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/zd1211rw')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_rf_al7230b.c317
1 files changed, 267 insertions, 50 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c b/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c
index d2c3ee69df8a..5e5e9ddc6a74 100644
--- a/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c
+++ b/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c
@@ -51,9 +51,52 @@ static const u32 std_rv[] = {
51 0xd8c010, 51 0xd8c010,
52}; 52};
53 53
54static int al7230b_init_hw(struct zd_rf *rf) 54static const u32 rv_init1[] = {
55 0x3c9000,
56 0xbfffff,
57 0x700000,
58 0xf15d58,
59};
60
61static const u32 rv_init2[] = {
62 0xf15d59,
63 0xf15d5c,
64 0xf15d58,
65};
66
67static const struct zd_ioreq16 ioreqs_sw[] = {
68 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
69 { CR38, 0x38 }, { CR136, 0xdf },
70};
71
72static int zd1211b_al7230b_finalize(struct zd_chip *chip)
55{ 73{
56 int i, r; 74 int r;
75 static const struct zd_ioreq16 ioreqs[] = {
76 { CR80, 0x30 }, { CR81, 0x30 }, { CR79, 0x58 },
77 { CR12, 0xf0 }, { CR77, 0x1b }, { CR78, 0x58 },
78 { CR203, 0x04 },
79 { },
80 { CR240, 0x80 },
81 };
82
83 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
84 if (r)
85 return r;
86
87 if (chip->new_phy_layout) {
88 /* antenna selection? */
89 r = zd_iowrite16_locked(chip, 0xe5, CR9);
90 if (r)
91 return r;
92 }
93
94 return zd_iowrite16_locked(chip, 0x04, CR203);
95}
96
97static int zd1211_al7230b_init_hw(struct zd_rf *rf)
98{
99 int r;
57 struct zd_chip *chip = zd_rf_to_chip(rf); 100 struct zd_chip *chip = zd_rf_to_chip(rf);
58 101
59 /* All of these writes are identical to AL2230 unless otherwise 102 /* All of these writes are identical to AL2230 unless otherwise
@@ -117,39 +160,136 @@ static int al7230b_init_hw(struct zd_rf *rf)
117 }; 160 };
118 161
119 static const struct zd_ioreq16 ioreqs_2[] = { 162 static const struct zd_ioreq16 ioreqs_2[] = {
120 /* PLL_ON */ 163 { CR251, 0x3f }, /* PLL_ON */
121 { CR251, 0x3f },
122 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 }, 164 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
123 { CR38, 0x38 }, { CR136, 0xdf }, 165 { CR38, 0x38 }, { CR136, 0xdf },
124 }; 166 };
125 167
126 r = zd_iowrite16a_locked(chip, ioreqs_1, ARRAY_SIZE(ioreqs_1)); 168 r = zd_iowrite16a_locked(chip, ioreqs_1, ARRAY_SIZE(ioreqs_1));
127 if (r) 169 if (r)
128 return r; 170 return r;
129 171
130 r = zd_rfwrite_cr_locked(chip, 0x09ec04); 172 r = zd_rfwritev_cr_locked(chip, chan_rv[0], ARRAY_SIZE(chan_rv[0]));
131 if (r) 173 if (r)
132 return r; 174 return r;
133 r = zd_rfwrite_cr_locked(chip, 0x8cccc8); 175
176 r = zd_rfwritev_cr_locked(chip, std_rv, ARRAY_SIZE(std_rv));
134 if (r) 177 if (r)
135 return r; 178 return r;
136 179
137 for (i = 0; i < ARRAY_SIZE(std_rv); i++) { 180 r = zd_rfwritev_cr_locked(chip, rv_init1, ARRAY_SIZE(rv_init1));
138 r = zd_rfwrite_cr_locked(chip, std_rv[i]); 181 if (r)
139 if (r) 182 return r;
140 return r;
141 }
142 183
143 r = zd_rfwrite_cr_locked(chip, 0x3c9000); 184 r = zd_iowrite16a_locked(chip, ioreqs_2, ARRAY_SIZE(ioreqs_2));
144 if (r) 185 if (r)
145 return r; 186 return r;
146 r = zd_rfwrite_cr_locked(chip, 0xbfffff); 187
188 r = zd_rfwritev_cr_locked(chip, rv_init2, ARRAY_SIZE(rv_init2));
147 if (r) 189 if (r)
148 return r; 190 return r;
149 r = zd_rfwrite_cr_locked(chip, 0x700000); 191
192 r = zd_iowrite16_locked(chip, 0x06, CR203);
150 if (r) 193 if (r)
151 return r; 194 return r;
152 r = zd_rfwrite_cr_locked(chip, 0xf15d58); 195 r = zd_iowrite16_locked(chip, 0x80, CR240);
196 if (r)
197 return r;
198
199 return 0;
200}
201
202static int zd1211b_al7230b_init_hw(struct zd_rf *rf)
203{
204 int r;
205 struct zd_chip *chip = zd_rf_to_chip(rf);
206
207 static const struct zd_ioreq16 ioreqs_1[] = {
208 { CR240, 0x57 }, { CR9, 0x9 },
209 { },
210 { CR10, 0x8b }, { CR15, 0x20 },
211 { CR17, 0x2B }, /* for newest (3rd cut) AL2230 */
212 { CR20, 0x10 }, /* 4N25->Stone Request */
213 { CR23, 0x40 }, { CR24, 0x20 }, { CR26, 0x93 },
214 { CR28, 0x3e }, { CR29, 0x00 },
215 { CR33, 0x28 }, /* 5613 */
216 { CR34, 0x30 },
217 { CR35, 0x3e }, /* for newest (3rd cut) AL2230 */
218 { CR41, 0x24 }, { CR44, 0x32 },
219 { CR46, 0x99 }, /* for newest (3rd cut) AL2230 */
220 { CR47, 0x1e },
221
222 /* ZD1215 5610 */
223 { CR48, 0x00 }, { CR49, 0x00 }, { CR51, 0x01 },
224 { CR52, 0x80 }, { CR53, 0x7e }, { CR65, 0x00 },
225 { CR66, 0x00 }, { CR67, 0x00 }, { CR68, 0x00 },
226 { CR69, 0x28 },
227
228 { CR79, 0x58 }, { CR80, 0x30 }, { CR81, 0x30 },
229 { CR87, 0x0A }, { CR89, 0x04 },
230 { CR90, 0x58 }, /* 5112 */
231 { CR91, 0x00 }, /* 5613 */
232 { CR92, 0x0a },
233 { CR98, 0x8d }, /* 4804, for 1212 new algorithm */
234 { CR99, 0x00 }, { CR100, 0x02 }, { CR101, 0x13 },
235 { CR102, 0x27 },
236 { CR106, 0x20 }, /* change to 0x24 for AL7230B */
237 { CR109, 0x13 }, /* 4804, for 1212 new algorithm */
238 { CR112, 0x1f },
239 };
240
241 static const struct zd_ioreq16 ioreqs_new_phy[] = {
242 { CR107, 0x28 },
243 { CR110, 0x1f }, /* 5127, 0x13->0x1f */
244 { CR111, 0x1f }, /* 0x13 to 0x1f for AL7230B */
245 { CR116, 0x2a }, { CR118, 0xfa }, { CR119, 0x12 },
246 { CR121, 0x6c }, /* 5613 */
247 };
248
249 static const struct zd_ioreq16 ioreqs_old_phy[] = {
250 { CR107, 0x24 },
251 { CR110, 0x13 }, /* 5127, 0x13->0x1f */
252 { CR111, 0x13 }, /* 0x13 to 0x1f for AL7230B */
253 { CR116, 0x24 }, { CR118, 0xfc }, { CR119, 0x11 },
254 { CR121, 0x6a }, /* 5613 */
255 };
256
257 static const struct zd_ioreq16 ioreqs_2[] = {
258 { CR113, 0x27 }, { CR114, 0x27 }, { CR115, 0x24 },
259 { CR117, 0xfa }, { CR120, 0x4f },
260 { CR122, 0xfc }, /* E0->FCh at 4901 */
261 { CR123, 0x57 }, /* 5613 */
262 { CR125, 0xad }, /* 4804, for 1212 new algorithm */
263 { CR126, 0x6c }, /* 5613 */
264 { CR127, 0x03 }, /* 4804, for 1212 new algorithm */
265 { CR130, 0x10 },
266 { CR131, 0x00 }, /* 5112 */
267 { CR137, 0x50 }, /* 5613 */
268 { CR138, 0xa8 }, /* 5112 */
269 { CR144, 0xac }, /* 5613 */
270 { CR148, 0x40 }, /* 5112 */
271 { CR149, 0x40 }, /* 4O07, 50->40 */
272 { CR150, 0x1a }, /* 5112, 0C->1A */
273 { CR252, 0x34 }, { CR253, 0x34 },
274 { CR251, 0x2f }, /* PLL_OFF */
275 };
276
277 static const struct zd_ioreq16 ioreqs_3[] = {
278 { CR251, 0x7f }, /* PLL_ON */
279 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
280 { CR38, 0x38 }, { CR136, 0xdf },
281 };
282
283 r = zd_iowrite16a_locked(chip, ioreqs_1, ARRAY_SIZE(ioreqs_1));
284 if (r)
285 return r;
286
287 if (chip->new_phy_layout)
288 r = zd_iowrite16a_locked(chip, ioreqs_new_phy,
289 ARRAY_SIZE(ioreqs_new_phy));
290 else
291 r = zd_iowrite16a_locked(chip, ioreqs_old_phy,
292 ARRAY_SIZE(ioreqs_old_phy));
153 if (r) 293 if (r)
154 return r; 294 return r;
155 295
@@ -157,38 +297,36 @@ static int al7230b_init_hw(struct zd_rf *rf)
157 if (r) 297 if (r)
158 return r; 298 return r;
159 299
160 r = zd_rfwrite_cr_locked(chip, 0xf15d59); 300 r = zd_rfwritev_cr_locked(chip, chan_rv[0], ARRAY_SIZE(chan_rv[0]));
161 if (r) 301 if (r)
162 return r; 302 return r;
163 r = zd_rfwrite_cr_locked(chip, 0xf15d5c); 303
304 r = zd_rfwritev_cr_locked(chip, std_rv, ARRAY_SIZE(std_rv));
164 if (r) 305 if (r)
165 return r; 306 return r;
166 r = zd_rfwrite_cr_locked(chip, 0xf15d58); 307
308 r = zd_rfwritev_cr_locked(chip, rv_init1, ARRAY_SIZE(rv_init1));
167 if (r) 309 if (r)
168 return r; 310 return r;
169 311
170 r = zd_iowrite16_locked(chip, 0x06, CR203); 312 r = zd_iowrite16a_locked(chip, ioreqs_3, ARRAY_SIZE(ioreqs_3));
171 if (r) 313 if (r)
172 return r; 314 return r;
173 r = zd_iowrite16_locked(chip, 0x80, CR240); 315
316 r = zd_rfwritev_cr_locked(chip, rv_init2, ARRAY_SIZE(rv_init2));
174 if (r) 317 if (r)
175 return r; 318 return r;
176 319
177 return 0; 320 return zd1211b_al7230b_finalize(chip);
178} 321}
179 322
180static int al7230b_set_channel(struct zd_rf *rf, u8 channel) 323static int zd1211_al7230b_set_channel(struct zd_rf *rf, u8 channel)
181{ 324{
182 int i, r; 325 int r;
183 const u32 *rv = chan_rv[channel-1]; 326 const u32 *rv = chan_rv[channel-1];
184 struct zd_chip *chip = zd_rf_to_chip(rf); 327 struct zd_chip *chip = zd_rf_to_chip(rf);
185 328
186 static const struct zd_ioreq16 ioreqs_1[] = { 329 static const struct zd_ioreq16 ioreqs[] = {
187 { CR128, 0x14 }, { CR129, 0x12 }, { CR130, 0x10 },
188 { CR38, 0x38 }, { CR136, 0xdf },
189 };
190
191 static const struct zd_ioreq16 ioreqs_2[] = {
192 /* PLL_ON */ 330 /* PLL_ON */
193 { CR251, 0x3f }, 331 { CR251, 0x3f },
194 { CR203, 0x06 }, { CR240, 0x08 }, 332 { CR203, 0x06 }, { CR240, 0x08 },
@@ -203,11 +341,9 @@ static int al7230b_set_channel(struct zd_rf *rf, u8 channel)
203 if (r) 341 if (r)
204 return r; 342 return r;
205 343
206 for (i = 0; i < ARRAY_SIZE(std_rv); i++) { 344 r = zd_rfwritev_cr_locked(chip, std_rv, ARRAY_SIZE(std_rv));
207 r = zd_rfwrite_cr_locked(chip, std_rv[i]); 345 if (r)
208 if (r) 346 return r;
209 return r;
210 }
211 347
212 r = zd_rfwrite_cr_locked(chip, 0x3c9000); 348 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
213 if (r) 349 if (r)
@@ -216,24 +352,69 @@ static int al7230b_set_channel(struct zd_rf *rf, u8 channel)
216 if (r) 352 if (r)
217 return r; 353 return r;
218 354
219 r = zd_iowrite16a_locked(chip, ioreqs_1, ARRAY_SIZE(ioreqs_1)); 355 r = zd_iowrite16a_locked(chip, ioreqs_sw, ARRAY_SIZE(ioreqs_sw));
220 if (r) 356 if (r)
221 return r; 357 return r;
222 358
223 for (i = 0; i < 2; i++) { 359 r = zd_rfwritev_cr_locked(chip, rv, 2);
224 r = zd_rfwrite_cr_locked(chip, rv[i]); 360 if (r)
225 if (r) 361 return r;
226 return r; 362
227 } 363 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
364 if (r)
365 return r;
366
367 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
368}
369
370static int zd1211b_al7230b_set_channel(struct zd_rf *rf, u8 channel)
371{
372 int r;
373 const u32 *rv = chan_rv[channel-1];
374 struct zd_chip *chip = zd_rf_to_chip(rf);
375
376 r = zd_iowrite16_locked(chip, 0x57, CR240);
377 if (r)
378 return r;
379 r = zd_iowrite16_locked(chip, 0xe4, CR9);
380 if (r)
381 return r;
382
383 /* PLL_OFF */
384 r = zd_iowrite16_locked(chip, 0x2f, CR251);
385 if (r)
386 return r;
387 r = zd_rfwritev_cr_locked(chip, std_rv, ARRAY_SIZE(std_rv));
388 if (r)
389 return r;
228 390
229 r = zd_rfwrite_cr_locked(chip, 0x3c9000); 391 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
230 if (r) 392 if (r)
231 return r; 393 return r;
394 r = zd_rfwrite_cr_locked(chip, 0xf15d58);
395 if (r)
396 return r;
232 397
233 return zd_iowrite16a_locked(chip, ioreqs_2, ARRAY_SIZE(ioreqs_2)); 398 r = zd_iowrite16a_locked(chip, ioreqs_sw, ARRAY_SIZE(ioreqs_sw));
399 if (r)
400 return r;
401
402 r = zd_rfwritev_cr_locked(chip, rv, 2);
403 if (r)
404 return r;
405
406 r = zd_rfwrite_cr_locked(chip, 0x3c9000);
407 if (r)
408 return r;
409
410 r = zd_iowrite16_locked(chip, 0x7f, CR251);
411 if (r)
412 return r;
413
414 return zd1211b_al7230b_finalize(chip);
234} 415}
235 416
236static int al7230b_switch_radio_on(struct zd_rf *rf) 417static int zd1211_al7230b_switch_radio_on(struct zd_rf *rf)
237{ 418{
238 struct zd_chip *chip = zd_rf_to_chip(rf); 419 struct zd_chip *chip = zd_rf_to_chip(rf);
239 static const struct zd_ioreq16 ioreqs[] = { 420 static const struct zd_ioreq16 ioreqs[] = {
@@ -244,6 +425,17 @@ static int al7230b_switch_radio_on(struct zd_rf *rf)
244 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 425 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
245} 426}
246 427
428static int zd1211b_al7230b_switch_radio_on(struct zd_rf *rf)
429{
430 struct zd_chip *chip = zd_rf_to_chip(rf);
431 static const struct zd_ioreq16 ioreqs[] = {
432 { CR11, 0x00 },
433 { CR251, 0x7f },
434 };
435
436 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
437}
438
247static int al7230b_switch_radio_off(struct zd_rf *rf) 439static int al7230b_switch_radio_off(struct zd_rf *rf)
248{ 440{
249 struct zd_chip *chip = zd_rf_to_chip(rf); 441 struct zd_chip *chip = zd_rf_to_chip(rf);
@@ -255,20 +447,45 @@ static int al7230b_switch_radio_off(struct zd_rf *rf)
255 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 447 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
256} 448}
257 449
450/* ZD1211B+AL7230B 6m band edge patching differs slightly from other
451 * configurations */
452static int zd1211b_al7230b_patch_6m(struct zd_rf *rf, u8 channel)
453{
454 struct zd_chip *chip = zd_rf_to_chip(rf);
455 struct zd_ioreq16 ioreqs[] = {
456 { CR128, 0x14 }, { CR129, 0x12 },
457 };
458
459 /* FIXME: Channel 11 is not the edge for all regulatory domains. */
460 if (channel == 1) {
461 ioreqs[0].value = 0x0e;
462 ioreqs[1].value = 0x10;
463 } else if (channel == 11) {
464 ioreqs[0].value = 0x10;
465 ioreqs[1].value = 0x10;
466 }
467
468 dev_dbg_f(zd_chip_dev(chip), "patching for channel %d\n", channel);
469 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
470}
471
258int zd_rf_init_al7230b(struct zd_rf *rf) 472int zd_rf_init_al7230b(struct zd_rf *rf)
259{ 473{
260 struct zd_chip *chip = zd_rf_to_chip(rf); 474 struct zd_chip *chip = zd_rf_to_chip(rf);
261 475
262 if (chip->is_zd1211b) { 476 if (chip->is_zd1211b) {
263 dev_err(zd_chip_dev(chip), "AL7230B is currently not " 477 rf->init_hw = zd1211b_al7230b_init_hw;
264 "supported for ZD1211B devices\n"); 478 rf->switch_radio_on = zd1211b_al7230b_switch_radio_on;
265 return -ENODEV; 479 rf->set_channel = zd1211b_al7230b_set_channel;
480 rf->patch_6m_band_edge = zd1211b_al7230b_patch_6m;
481 } else {
482 rf->init_hw = zd1211_al7230b_init_hw;
483 rf->switch_radio_on = zd1211_al7230b_switch_radio_on;
484 rf->set_channel = zd1211_al7230b_set_channel;
485 rf->patch_6m_band_edge = zd_rf_generic_patch_6m;
266 } 486 }
267 487
268 rf->init_hw = al7230b_init_hw;
269 rf->set_channel = al7230b_set_channel;
270 rf->switch_radio_on = al7230b_switch_radio_on;
271 rf->switch_radio_off = al7230b_switch_radio_off; 488 rf->switch_radio_off = al7230b_switch_radio_off;
272 rf->patch_6m_band_edge = zd_rf_generic_patch_6m; 489
273 return 0; 490 return 0;
274} 491}