aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtl8187_dev.c
diff options
context:
space:
mode:
authorMichael Wu <flamingice@sourmilk.net>2007-10-14 14:43:16 -0400
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:35 -0500
commitf653211197f3841f383fa9757ef8ce182c6cf627 (patch)
treeba56e1fa09924d1ffab4f825044175291786b58e /drivers/net/wireless/rtl8187_dev.c
parentfa1c114fdaa605496045e56c42d0c8aa4c139e57 (diff)
Add rtl8180 wireless driver
This patch adds a mac80211 based wireless driver for the rtl8180 and rtl8185 PCI wireless cards. Also included are some rtl8187 changes required due to the relationship between that driver and this one. Michael Wu is primarily responsible for the initial driver and rtl8185 support. Andreas Merello provided the additional rtl8180 support. Thanks to Jukka Ruohonen for the donating a rtl8185 card! It was very helpful for the rtl8225z2 code. The Signed-off-by information below is collected from the individual patches submitted to wireless-2.6 before merging this driver upstream. Signed-off-by: Andrea Merello <andreamrl@tiscali.it> Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: Michael Wu <flamingice@sourmilk.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rtl8187_dev.c')
-rw-r--r--drivers/net/wireless/rtl8187_dev.c60
1 files changed, 23 insertions, 37 deletions
diff --git a/drivers/net/wireless/rtl8187_dev.c b/drivers/net/wireless/rtl8187_dev.c
index 09e48d3bef36..8dab25a65990 100644
--- a/drivers/net/wireless/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl8187_dev.c
@@ -393,37 +393,19 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
393 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1FF7); 393 rtl818x_iowrite16(priv, &priv->map->RFPinsEnable, 0x1FF7);
394 msleep(100); 394 msleep(100);
395 395
396 priv->rf_init(dev); 396 priv->rf->init(dev);
397 397
398 rtl818x_iowrite16(priv, &priv->map->BRSR, 0x01F3); 398 rtl818x_iowrite16(priv, &priv->map->BRSR, 0x01F3);
399 reg = rtl818x_ioread16(priv, &priv->map->PGSELECT) & 0xfffe; 399 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~1;
400 rtl818x_iowrite16(priv, &priv->map->PGSELECT, reg | 0x1); 400 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg | 1);
401 rtl818x_iowrite16(priv, (__le16 *)0xFFFE, 0x10); 401 rtl818x_iowrite16(priv, (__le16 *)0xFFFE, 0x10);
402 rtl818x_iowrite8(priv, &priv->map->TALLY_SEL, 0x80); 402 rtl818x_iowrite8(priv, &priv->map->TALLY_SEL, 0x80);
403 rtl818x_iowrite8(priv, (u8 *)0xFFFF, 0x60); 403 rtl818x_iowrite8(priv, (u8 *)0xFFFF, 0x60);
404 rtl818x_iowrite16(priv, &priv->map->PGSELECT, reg); 404 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg);
405 405
406 return 0; 406 return 0;
407} 407}
408 408
409static void rtl8187_set_channel(struct ieee80211_hw *dev, int channel)
410{
411 u32 reg;
412 struct rtl8187_priv *priv = dev->priv;
413
414 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF);
415 /* Enable TX loopback on MAC level to avoid TX during channel
416 * changes, as this has be seen to causes problems and the
417 * card will stop work until next reset
418 */
419 rtl818x_iowrite32(priv, &priv->map->TX_CONF,
420 reg | RTL818X_TX_CONF_LOOPBACK_MAC);
421 msleep(10);
422 rtl8225_rf_set_channel(dev, channel);
423 msleep(10);
424 rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg);
425}
426
427static int rtl8187_start(struct ieee80211_hw *dev) 409static int rtl8187_start(struct ieee80211_hw *dev)
428{ 410{
429 struct rtl8187_priv *priv = dev->priv; 411 struct rtl8187_priv *priv = dev->priv;
@@ -492,7 +474,7 @@ static void rtl8187_stop(struct ieee80211_hw *dev)
492 reg &= ~RTL818X_CMD_RX_ENABLE; 474 reg &= ~RTL818X_CMD_RX_ENABLE;
493 rtl818x_iowrite8(priv, &priv->map->CMD, reg); 475 rtl818x_iowrite8(priv, &priv->map->CMD, reg);
494 476
495 rtl8225_rf_stop(dev); 477 priv->rf->stop(dev);
496 478
497 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); 479 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
498 reg = rtl818x_ioread8(priv, &priv->map->CONFIG4); 480 reg = rtl818x_ioread8(priv, &priv->map->CONFIG4);
@@ -543,7 +525,19 @@ static void rtl8187_remove_interface(struct ieee80211_hw *dev,
543static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) 525static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
544{ 526{
545 struct rtl8187_priv *priv = dev->priv; 527 struct rtl8187_priv *priv = dev->priv;
546 rtl8187_set_channel(dev, conf->channel); 528 u32 reg;
529
530 reg = rtl818x_ioread32(priv, &priv->map->TX_CONF);
531 /* Enable TX loopback on MAC level to avoid TX during channel
532 * changes, as this has be seen to causes problems and the
533 * card will stop work until next reset
534 */
535 rtl818x_iowrite32(priv, &priv->map->TX_CONF,
536 reg | RTL818X_TX_CONF_LOOPBACK_MAC);
537 msleep(10);
538 priv->rf->set_chan(dev, conf);
539 msleep(10);
540 rtl818x_iowrite32(priv, &priv->map->TX_CONF, reg);
547 541
548 rtl818x_iowrite8(priv, &priv->map->SIFS, 0x22); 542 rtl818x_iowrite8(priv, &priv->map->SIFS, 0x22);
549 543
@@ -753,23 +747,16 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
753 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE, 747 eeprom_93cx6_read(&eeprom, RTL8187_EEPROM_TXPWR_BASE,
754 &priv->txpwr_base); 748 &priv->txpwr_base);
755 749
756 reg = rtl818x_ioread16(priv, &priv->map->PGSELECT) & ~1; 750 reg = rtl818x_ioread8(priv, &priv->map->PGSELECT) & ~1;
757 rtl818x_iowrite16(priv, &priv->map->PGSELECT, reg | 1); 751 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg | 1);
758 /* 0 means asic B-cut, we should use SW 3 wire 752 /* 0 means asic B-cut, we should use SW 3 wire
759 * bit-by-bit banging for radio. 1 means we can use 753 * bit-by-bit banging for radio. 1 means we can use
760 * USB specific request to write radio registers */ 754 * USB specific request to write radio registers */
761 priv->asic_rev = rtl818x_ioread8(priv, (u8 *)0xFFFE) & 0x3; 755 priv->asic_rev = rtl818x_ioread8(priv, (u8 *)0xFFFE) & 0x3;
762 rtl818x_iowrite16(priv, &priv->map->PGSELECT, reg); 756 rtl818x_iowrite8(priv, &priv->map->PGSELECT, reg);
763 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); 757 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
764 758
765 rtl8225_write(dev, 0, 0x1B7); 759 priv->rf = rtl8187_detect_rf(dev);
766
767 if (rtl8225_read(dev, 8) != 0x588 || rtl8225_read(dev, 9) != 0x700)
768 priv->rf_init = rtl8225_rf_init;
769 else
770 priv->rf_init = rtl8225z2_rf_init;
771
772 rtl8225_write(dev, 0, 0x0B7);
773 760
774 err = ieee80211_register_hw(dev); 761 err = ieee80211_register_hw(dev);
775 if (err) { 762 if (err) {
@@ -779,8 +766,7 @@ static int __devinit rtl8187_probe(struct usb_interface *intf,
779 766
780 printk(KERN_INFO "%s: hwaddr %s, rtl8187 V%d + %s\n", 767 printk(KERN_INFO "%s: hwaddr %s, rtl8187 V%d + %s\n",
781 wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr), 768 wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr),
782 priv->asic_rev, priv->rf_init == rtl8225_rf_init ? 769 priv->asic_rev, priv->rf->name);
783 "rtl8225" : "rtl8225z2");
784 770
785 return 0; 771 return 0;
786 772