aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2400pci.c
diff options
context:
space:
mode:
authorIvo van Doorn <IvDoorn@gmail.com>2007-10-06 07:34:52 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:15 -0400
commit5c58ee51ff8c0aca74c225e0263bc5dd2b917781 (patch)
treea08e875dade8a6f55d45419b728b2b077cec6dc0 /drivers/net/wireless/rt2x00/rt2400pci.c
parent4f5af6eb3d17f8e343597ea99d97eb2f2905b2fb (diff)
[PATCH] rt2x00: Reorganize configuration handler
Reorganize configuration handling by creating a extra structure which contains precalculated values based on the mac80211 values which are usefull for all individual drivers. This also fixes the preamble configuration problem, up untill now preamble was never configured since by default the rate->val value was used when changing the mode. Now rate->val will only be used to set the basic rate mask. The preamble configuration will now be done correctly through the erp_ie_changed callback function. Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2400pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c132
1 files changed, 54 insertions, 78 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index bfab5a165b76..31c1dd271627 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -291,90 +291,67 @@ static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, const int type,
291 rt2x00pci_register_write(rt2x00dev, CSR14, reg); 291 rt2x00pci_register_write(rt2x00dev, CSR14, reg);
292} 292}
293 293
294static void rt2400pci_config_rate(struct rt2x00_dev *rt2x00dev, const int rate) 294static void rt2400pci_config_preamble(struct rt2x00_dev *rt2x00dev,
295 const int short_preamble,
296 const int ack_timeout,
297 const int ack_consume_time)
295{ 298{
296 struct ieee80211_conf *conf = &rt2x00dev->hw->conf; 299 int preamble_mask;
297 u32 reg; 300 u32 reg;
298 u32 preamble;
299 u16 value;
300
301 if (DEVICE_GET_RATE_FIELD(rate, PREAMBLE))
302 preamble = SHORT_PREAMBLE;
303 else
304 preamble = PREAMBLE;
305 301
306 reg = DEVICE_GET_RATE_FIELD(rate, RATEMASK) & DEV_BASIC_RATEMASK; 302 /*
307 rt2x00pci_register_write(rt2x00dev, ARCSR1, reg); 303 * When short preamble is enabled, we should set bit 0x08
304 */
305 preamble_mask = short_preamble << 3;
308 306
309 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg); 307 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
310 value = ((conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) ? 308 rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, ack_timeout);
311 SHORT_DIFS : DIFS) + 309 rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, ack_consume_time);
312 PLCP + preamble + get_duration(ACK_SIZE, 10);
313 rt2x00_set_field32(&reg, TXCSR1_ACK_TIMEOUT, value);
314 value = SIFS + PLCP + preamble + get_duration(ACK_SIZE, 10);
315 rt2x00_set_field32(&reg, TXCSR1_ACK_CONSUME_TIME, value);
316 rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); 310 rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
317 311
318 preamble = DEVICE_GET_RATE_FIELD(rate, PREAMBLE) ? 0x08 : 0x00;
319
320 rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg); 312 rt2x00pci_register_read(rt2x00dev, ARCSR2, &reg);
321 rt2x00_set_field32(&reg, ARCSR2_SIGNAL, 0x00 | preamble); 313 rt2x00_set_field32(&reg, ARCSR2_SIGNAL, 0x00 | preamble_mask);
322 rt2x00_set_field32(&reg, ARCSR2_SERVICE, 0x04); 314 rt2x00_set_field32(&reg, ARCSR2_SERVICE, 0x04);
323 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10)); 315 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10));
324 rt2x00pci_register_write(rt2x00dev, ARCSR2, reg); 316 rt2x00pci_register_write(rt2x00dev, ARCSR2, reg);
325 317
326 rt2x00pci_register_read(rt2x00dev, ARCSR3, &reg); 318 rt2x00pci_register_read(rt2x00dev, ARCSR3, &reg);
327 rt2x00_set_field32(&reg, ARCSR3_SIGNAL, 0x01 | preamble); 319 rt2x00_set_field32(&reg, ARCSR3_SIGNAL, 0x01 | preamble_mask);
328 rt2x00_set_field32(&reg, ARCSR3_SERVICE, 0x04); 320 rt2x00_set_field32(&reg, ARCSR3_SERVICE, 0x04);
329 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 20)); 321 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 20));
330 rt2x00pci_register_write(rt2x00dev, ARCSR3, reg); 322 rt2x00pci_register_write(rt2x00dev, ARCSR3, reg);
331 323
332 rt2x00pci_register_read(rt2x00dev, ARCSR4, &reg); 324 rt2x00pci_register_read(rt2x00dev, ARCSR4, &reg);
333 rt2x00_set_field32(&reg, ARCSR4_SIGNAL, 0x02 | preamble); 325 rt2x00_set_field32(&reg, ARCSR4_SIGNAL, 0x02 | preamble_mask);
334 rt2x00_set_field32(&reg, ARCSR4_SERVICE, 0x04); 326 rt2x00_set_field32(&reg, ARCSR4_SERVICE, 0x04);
335 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 55)); 327 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 55));
336 rt2x00pci_register_write(rt2x00dev, ARCSR4, reg); 328 rt2x00pci_register_write(rt2x00dev, ARCSR4, reg);
337 329
338 rt2x00pci_register_read(rt2x00dev, ARCSR5, &reg); 330 rt2x00pci_register_read(rt2x00dev, ARCSR5, &reg);
339 rt2x00_set_field32(&reg, ARCSR5_SIGNAL, 0x03 | preamble); 331 rt2x00_set_field32(&reg, ARCSR5_SIGNAL, 0x03 | preamble_mask);
340 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84); 332 rt2x00_set_field32(&reg, ARCSR5_SERVICE, 0x84);
341 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); 333 rt2x00_set_field32(&reg, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110));
342 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); 334 rt2x00pci_register_write(rt2x00dev, ARCSR5, reg);
343} 335}
344 336
345static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev, 337static void rt2400pci_config_phymode(struct rt2x00_dev *rt2x00dev,
346 const int phymode) 338 const int basic_rate_mask)
347{ 339{
348 struct ieee80211_hw_mode *mode; 340 rt2x00pci_register_write(rt2x00dev, ARCSR1, basic_rate_mask);
349 struct ieee80211_rate *rate;
350
351 rt2x00dev->curr_hwmode = HWMODE_B;
352
353 mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode];
354 rate = &mode->rates[mode->num_rates - 1];
355
356 rt2400pci_config_rate(rt2x00dev, rate->val2);
357} 341}
358 342
359static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev, 343static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev,
360 const int index, const int channel) 344 struct rf_channel *rf)
361{ 345{
362 struct rf_channel reg;
363
364 /*
365 * Fill rf_reg structure.
366 */
367 memcpy(&reg, &rt2x00dev->spec.channels[index], sizeof(reg));
368
369 /* 346 /*
370 * Switch on tuning bits. 347 * Switch on tuning bits.
371 */ 348 */
372 rt2x00_set_field32(&reg.rf1, RF1_TUNER, 1); 349 rt2x00_set_field32(&rf->rf1, RF1_TUNER, 1);
373 rt2x00_set_field32(&reg.rf3, RF3_TUNER, 1); 350 rt2x00_set_field32(&rf->rf3, RF3_TUNER, 1);
374 351
375 rt2400pci_rf_write(rt2x00dev, 1, reg.rf1); 352 rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
376 rt2400pci_rf_write(rt2x00dev, 2, reg.rf2); 353 rt2400pci_rf_write(rt2x00dev, 2, rf->rf2);
377 rt2400pci_rf_write(rt2x00dev, 3, reg.rf3); 354 rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
378 355
379 /* 356 /*
380 * RF2420 chipset don't need any additional actions. 357 * RF2420 chipset don't need any additional actions.
@@ -387,31 +364,31 @@ static void rt2400pci_config_channel(struct rt2x00_dev *rt2x00dev,
387 * reference clock rate to activate auto_tune. 364 * reference clock rate to activate auto_tune.
388 * After that we set the value back to the correct channel. 365 * After that we set the value back to the correct channel.
389 */ 366 */
390 rt2400pci_rf_write(rt2x00dev, 1, reg.rf1); 367 rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
391 rt2400pci_rf_write(rt2x00dev, 2, 0x000c2a32); 368 rt2400pci_rf_write(rt2x00dev, 2, 0x000c2a32);
392 rt2400pci_rf_write(rt2x00dev, 3, reg.rf3); 369 rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
393 370
394 msleep(1); 371 msleep(1);
395 372
396 rt2400pci_rf_write(rt2x00dev, 1, reg.rf1); 373 rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
397 rt2400pci_rf_write(rt2x00dev, 2, reg.rf2); 374 rt2400pci_rf_write(rt2x00dev, 2, rf->rf2);
398 rt2400pci_rf_write(rt2x00dev, 3, reg.rf3); 375 rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
399 376
400 msleep(1); 377 msleep(1);
401 378
402 /* 379 /*
403 * Switch off tuning bits. 380 * Switch off tuning bits.
404 */ 381 */
405 rt2x00_set_field32(&reg.rf1, RF1_TUNER, 0); 382 rt2x00_set_field32(&rf->rf1, RF1_TUNER, 0);
406 rt2x00_set_field32(&reg.rf3, RF3_TUNER, 0); 383 rt2x00_set_field32(&rf->rf3, RF3_TUNER, 0);
407 384
408 rt2400pci_rf_write(rt2x00dev, 1, reg.rf1); 385 rt2400pci_rf_write(rt2x00dev, 1, rf->rf1);
409 rt2400pci_rf_write(rt2x00dev, 3, reg.rf3); 386 rt2400pci_rf_write(rt2x00dev, 3, rf->rf3);
410 387
411 /* 388 /*
412 * Clear false CRC during channel switch. 389 * Clear false CRC during channel switch.
413 */ 390 */
414 rt2x00pci_register_read(rt2x00dev, CNT0, &reg.rf1); 391 rt2x00pci_register_read(rt2x00dev, CNT0, &rf->rf1);
415} 392}
416 393
417static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower) 394static void rt2400pci_config_txpower(struct rt2x00_dev *rt2x00dev, int txpower)
@@ -465,25 +442,22 @@ static void rt2400pci_config_antenna(struct rt2x00_dev *rt2x00dev,
465} 442}
466 443
467static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev, 444static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
468 int short_slot_time, int beacon_int) 445 struct rt2x00lib_conf *libconf)
469{ 446{
470 u32 reg; 447 u32 reg;
471 448
472 rt2x00pci_register_read(rt2x00dev, CSR11, &reg); 449 rt2x00pci_register_read(rt2x00dev, CSR11, &reg);
473 rt2x00_set_field32(&reg, CSR11_SLOT_TIME, 450 rt2x00_set_field32(&reg, CSR11_SLOT_TIME, libconf->slot_time);
474 short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME);
475 rt2x00pci_register_write(rt2x00dev, CSR11, reg); 451 rt2x00pci_register_write(rt2x00dev, CSR11, reg);
476 452
477 rt2x00pci_register_read(rt2x00dev, CSR18, &reg); 453 rt2x00pci_register_read(rt2x00dev, CSR18, &reg);
478 rt2x00_set_field32(&reg, CSR18_SIFS, SIFS); 454 rt2x00_set_field32(&reg, CSR18_SIFS, libconf->sifs);
479 rt2x00_set_field32(&reg, CSR18_PIFS, 455 rt2x00_set_field32(&reg, CSR18_PIFS, libconf->pifs);
480 short_slot_time ? SHORT_PIFS : PIFS);
481 rt2x00pci_register_write(rt2x00dev, CSR18, reg); 456 rt2x00pci_register_write(rt2x00dev, CSR18, reg);
482 457
483 rt2x00pci_register_read(rt2x00dev, CSR19, &reg); 458 rt2x00pci_register_read(rt2x00dev, CSR19, &reg);
484 rt2x00_set_field32(&reg, CSR19_DIFS, 459 rt2x00_set_field32(&reg, CSR19_DIFS, libconf->difs);
485 short_slot_time ? SHORT_DIFS : DIFS); 460 rt2x00_set_field32(&reg, CSR19_EIFS, libconf->eifs);
486 rt2x00_set_field32(&reg, CSR19_EIFS, EIFS);
487 rt2x00pci_register_write(rt2x00dev, CSR19, reg); 461 rt2x00pci_register_write(rt2x00dev, CSR19, reg);
488 462
489 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg); 463 rt2x00pci_register_read(rt2x00dev, TXCSR1, &reg);
@@ -492,30 +466,30 @@ static void rt2400pci_config_duration(struct rt2x00_dev *rt2x00dev,
492 rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); 466 rt2x00pci_register_write(rt2x00dev, TXCSR1, reg);
493 467
494 rt2x00pci_register_read(rt2x00dev, CSR12, &reg); 468 rt2x00pci_register_read(rt2x00dev, CSR12, &reg);
495 rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL, beacon_int * 16); 469 rt2x00_set_field32(&reg, CSR12_BEACON_INTERVAL,
496 rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION, beacon_int * 16); 470 libconf->conf->beacon_int * 16);
471 rt2x00_set_field32(&reg, CSR12_CFP_MAX_DURATION,
472 libconf->conf->beacon_int * 16);
497 rt2x00pci_register_write(rt2x00dev, CSR12, reg); 473 rt2x00pci_register_write(rt2x00dev, CSR12, reg);
498} 474}
499 475
500static void rt2400pci_config(struct rt2x00_dev *rt2x00dev, 476static void rt2400pci_config(struct rt2x00_dev *rt2x00dev,
501 const unsigned int flags, 477 const unsigned int flags,
502 struct ieee80211_conf *conf) 478 struct rt2x00lib_conf *libconf)
503{ 479{
504 int short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME;
505
506 if (flags & CONFIG_UPDATE_PHYMODE) 480 if (flags & CONFIG_UPDATE_PHYMODE)
507 rt2400pci_config_phymode(rt2x00dev, conf->phymode); 481 rt2400pci_config_phymode(rt2x00dev, libconf->basic_rates);
508 if (flags & CONFIG_UPDATE_CHANNEL) 482 if (flags & CONFIG_UPDATE_CHANNEL)
509 rt2400pci_config_channel(rt2x00dev, conf->channel_val, 483 rt2400pci_config_channel(rt2x00dev, &libconf->rf);
510 conf->channel);
511 if (flags & CONFIG_UPDATE_TXPOWER) 484 if (flags & CONFIG_UPDATE_TXPOWER)
512 rt2400pci_config_txpower(rt2x00dev, conf->power_level); 485 rt2400pci_config_txpower(rt2x00dev,
486 libconf->conf->power_level);
513 if (flags & CONFIG_UPDATE_ANTENNA) 487 if (flags & CONFIG_UPDATE_ANTENNA)
514 rt2400pci_config_antenna(rt2x00dev, conf->antenna_sel_tx, 488 rt2400pci_config_antenna(rt2x00dev,
515 conf->antenna_sel_rx); 489 libconf->conf->antenna_sel_tx,
490 libconf->conf->antenna_sel_rx);
516 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) 491 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
517 rt2400pci_config_duration(rt2x00dev, short_slot_time, 492 rt2400pci_config_duration(rt2x00dev, libconf);
518 conf->beacon_int);
519} 493}
520 494
521static void rt2400pci_config_cw(struct rt2x00_dev *rt2x00dev, 495static void rt2400pci_config_cw(struct rt2x00_dev *rt2x00dev,
@@ -1609,6 +1583,7 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = {
1609 .configure_filter = rt2400pci_configure_filter, 1583 .configure_filter = rt2400pci_configure_filter,
1610 .get_stats = rt2x00mac_get_stats, 1584 .get_stats = rt2x00mac_get_stats,
1611 .set_retry_limit = rt2400pci_set_retry_limit, 1585 .set_retry_limit = rt2400pci_set_retry_limit,
1586 .erp_ie_changed = rt2x00mac_erp_ie_changed,
1612 .conf_tx = rt2400pci_conf_tx, 1587 .conf_tx = rt2400pci_conf_tx,
1613 .get_tx_stats = rt2x00mac_get_tx_stats, 1588 .get_tx_stats = rt2x00mac_get_tx_stats,
1614 .get_tsf = rt2400pci_get_tsf, 1589 .get_tsf = rt2400pci_get_tsf,
@@ -1634,6 +1609,7 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
1634 .config_mac_addr = rt2400pci_config_mac_addr, 1609 .config_mac_addr = rt2400pci_config_mac_addr,
1635 .config_bssid = rt2400pci_config_bssid, 1610 .config_bssid = rt2400pci_config_bssid,
1636 .config_type = rt2400pci_config_type, 1611 .config_type = rt2400pci_config_type,
1612 .config_preamble = rt2400pci_config_preamble,
1637 .config = rt2400pci_config, 1613 .config = rt2400pci_config,
1638}; 1614};
1639 1615