aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
authorIvo van Doorn <ivdoorn@gmail.com>2008-10-29 12:17:57 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-11-10 15:17:33 -0500
commite4ea1c403acece78c271bf9cd6f797d1cb093df9 (patch)
tree4356693a16f2596de08f6afee76490f1ebe6b066 /drivers/net/wireless/rt2x00/rt2500usb.c
parent3f64b435ab76e79bfb3b4d36f043e6f892093b71 (diff)
rt2x00: Optimize configuration handling
Implement latest changed from mac80211 configuration handling to optmize configuration handling in rt2x00. * Remove set_retry_limit callback function, handled through config() * Move config_antenna to its own callback function, it isn't handled by mac80211 anymore * Use IEEE80211_CONF_CHANGED_* flags and remove manual checks * Removed deprecated short slot setting through config() and put it in config_erp() through which mac80211 now configures it * Remove config_phymode() and move contents to config_erp() since it only managed the basic rates which is now determined by mac80211 through config_erp(). 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/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c110
1 files changed, 52 insertions, 58 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index d19bee43861d..19970de94639 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -423,57 +423,16 @@ static void rt2500usb_config_erp(struct rt2x00_dev *rt2x00dev,
423 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE, 423 rt2x00_set_field16(&reg, TXRX_CSR10_AUTORESPOND_PREAMBLE,
424 !!erp->short_preamble); 424 !!erp->short_preamble);
425 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg); 425 rt2500usb_register_write(rt2x00dev, TXRX_CSR10, reg);
426}
427
428static void rt2500usb_config_phymode(struct rt2x00_dev *rt2x00dev,
429 const int basic_rate_mask)
430{
431 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, basic_rate_mask);
432}
433
434static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
435 struct rf_channel *rf, const int txpower)
436{
437 /*
438 * Set TXpower.
439 */
440 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
441
442 /*
443 * For RT2525E we should first set the channel to half band higher.
444 */
445 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {
446 static const u32 vals[] = {
447 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
448 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
449 0x000008ba, 0x000008be, 0x000008b7, 0x00000902,
450 0x00000902, 0x00000906
451 };
452 426
453 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->channel - 1]); 427 rt2500usb_register_write(rt2x00dev, TXRX_CSR11, erp->basic_rates);
454 if (rf->rf4)
455 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
456 }
457 428
458 rt2500usb_rf_write(rt2x00dev, 1, rf->rf1); 429 rt2500usb_register_write(rt2x00dev, MAC_CSR10, erp->slot_time);
459 rt2500usb_rf_write(rt2x00dev, 2, rf->rf2); 430 rt2500usb_register_write(rt2x00dev, MAC_CSR11, erp->sifs);
460 rt2500usb_rf_write(rt2x00dev, 3, rf->rf3); 431 rt2500usb_register_write(rt2x00dev, MAC_CSR12, erp->eifs);
461 if (rf->rf4)
462 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
463}
464
465static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
466 const int txpower)
467{
468 u32 rf3;
469
470 rt2x00_rf_read(rt2x00dev, 3, &rf3);
471 rt2x00_set_field32(&rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
472 rt2500usb_rf_write(rt2x00dev, 3, rf3);
473} 432}
474 433
475static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev, 434static void rt2500usb_config_ant(struct rt2x00_dev *rt2x00dev,
476 struct antenna_setup *ant) 435 struct antenna_setup *ant)
477{ 436{
478 u8 r2; 437 u8 r2;
479 u8 r14; 438 u8 r14;
@@ -555,15 +514,52 @@ static void rt2500usb_config_antenna(struct rt2x00_dev *rt2x00dev,
555 rt2500usb_register_write(rt2x00dev, PHY_CSR6, csr6); 514 rt2500usb_register_write(rt2x00dev, PHY_CSR6, csr6);
556} 515}
557 516
517static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
518 struct rf_channel *rf, const int txpower)
519{
520 /*
521 * Set TXpower.
522 */
523 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
524
525 /*
526 * For RT2525E we should first set the channel to half band higher.
527 */
528 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) {
529 static const u32 vals[] = {
530 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
531 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
532 0x000008ba, 0x000008be, 0x000008b7, 0x00000902,
533 0x00000902, 0x00000906
534 };
535
536 rt2500usb_rf_write(rt2x00dev, 2, vals[rf->channel - 1]);
537 if (rf->rf4)
538 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
539 }
540
541 rt2500usb_rf_write(rt2x00dev, 1, rf->rf1);
542 rt2500usb_rf_write(rt2x00dev, 2, rf->rf2);
543 rt2500usb_rf_write(rt2x00dev, 3, rf->rf3);
544 if (rf->rf4)
545 rt2500usb_rf_write(rt2x00dev, 4, rf->rf4);
546}
547
548static void rt2500usb_config_txpower(struct rt2x00_dev *rt2x00dev,
549 const int txpower)
550{
551 u32 rf3;
552
553 rt2x00_rf_read(rt2x00dev, 3, &rf3);
554 rt2x00_set_field32(&rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower));
555 rt2500usb_rf_write(rt2x00dev, 3, rf3);
556}
557
558static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev, 558static void rt2500usb_config_duration(struct rt2x00_dev *rt2x00dev,
559 struct rt2x00lib_conf *libconf) 559 struct rt2x00lib_conf *libconf)
560{ 560{
561 u16 reg; 561 u16 reg;
562 562
563 rt2500usb_register_write(rt2x00dev, MAC_CSR10, libconf->slot_time);
564 rt2500usb_register_write(rt2x00dev, MAC_CSR11, libconf->sifs);
565 rt2500usb_register_write(rt2x00dev, MAC_CSR12, libconf->eifs);
566
567 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg); 563 rt2500usb_register_read(rt2x00dev, TXRX_CSR18, &reg);
568 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL, 564 rt2x00_set_field16(&reg, TXRX_CSR18_INTERVAL,
569 libconf->conf->beacon_int * 4); 565 libconf->conf->beacon_int * 4);
@@ -574,17 +570,14 @@ static void rt2500usb_config(struct rt2x00_dev *rt2x00dev,
574 struct rt2x00lib_conf *libconf, 570 struct rt2x00lib_conf *libconf,
575 const unsigned int flags) 571 const unsigned int flags)
576{ 572{
577 if (flags & CONFIG_UPDATE_PHYMODE) 573 if (flags & IEEE80211_CONF_CHANGE_CHANNEL)
578 rt2500usb_config_phymode(rt2x00dev, libconf->basic_rates);
579 if (flags & CONFIG_UPDATE_CHANNEL)
580 rt2500usb_config_channel(rt2x00dev, &libconf->rf, 574 rt2500usb_config_channel(rt2x00dev, &libconf->rf,
581 libconf->conf->power_level); 575 libconf->conf->power_level);
582 if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) 576 if ((flags & IEEE80211_CONF_CHANGE_POWER) &&
577 !(flags & IEEE80211_CONF_CHANGE_CHANNEL))
583 rt2500usb_config_txpower(rt2x00dev, 578 rt2500usb_config_txpower(rt2x00dev,
584 libconf->conf->power_level); 579 libconf->conf->power_level);
585 if (flags & CONFIG_UPDATE_ANTENNA) 580 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
586 rt2500usb_config_antenna(rt2x00dev, &libconf->ant);
587 if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT))
588 rt2500usb_config_duration(rt2x00dev, libconf); 581 rt2500usb_config_duration(rt2x00dev, libconf);
589} 582}
590 583
@@ -1794,6 +1787,7 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1794 .config_filter = rt2500usb_config_filter, 1787 .config_filter = rt2500usb_config_filter,
1795 .config_intf = rt2500usb_config_intf, 1788 .config_intf = rt2500usb_config_intf,
1796 .config_erp = rt2500usb_config_erp, 1789 .config_erp = rt2500usb_config_erp,
1790 .config_ant = rt2500usb_config_ant,
1797 .config = rt2500usb_config, 1791 .config = rt2500usb_config,
1798}; 1792};
1799 1793