aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerton Ronaldo Krzesinski <herton@mandriva.com.br>2010-11-01 20:59:37 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-11-15 13:25:46 -0500
commit0bf198eb4d05a4662143e4a2e2a44fb592e2b177 (patch)
treed22764c30e312f2fbb848810283e9c00b7f6b6c5
parentfe3326903d7aafd7b5602d8e178537c8b0465f6c (diff)
rtl8187: consolidate anaparam on/off write sequences
There are repeated calls for anaparam on/off sequence in the code. Consolidate the common code in rtl8187_set_anaparam and use it where needed. Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c84
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_rtl8225.c22
2 files changed, 44 insertions, 62 deletions
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index d7ea5d1a2888..c0c75aa13db2 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -553,6 +553,46 @@ static int rtl8187b_init_status_urb(struct ieee80211_hw *dev)
553 return ret; 553 return ret;
554} 554}
555 555
556static void rtl8187_set_anaparam(struct rtl8187_priv *priv, bool rfon)
557{
558 u32 anaparam, anaparam2;
559 u8 anaparam3, reg;
560
561 if (!priv->is_rtl8187b) {
562 if (rfon) {
563 anaparam = RTL8187_RTL8225_ANAPARAM_ON;
564 anaparam2 = RTL8187_RTL8225_ANAPARAM2_ON;
565 } else {
566 anaparam = RTL8187_RTL8225_ANAPARAM_OFF;
567 anaparam2 = RTL8187_RTL8225_ANAPARAM2_OFF;
568 }
569 } else {
570 if (rfon) {
571 anaparam = RTL8187B_RTL8225_ANAPARAM_ON;
572 anaparam2 = RTL8187B_RTL8225_ANAPARAM2_ON;
573 anaparam3 = RTL8187B_RTL8225_ANAPARAM3_ON;
574 } else {
575 anaparam = RTL8187B_RTL8225_ANAPARAM_OFF;
576 anaparam2 = RTL8187B_RTL8225_ANAPARAM2_OFF;
577 anaparam3 = RTL8187B_RTL8225_ANAPARAM3_OFF;
578 }
579 }
580
581 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
582 RTL818X_EEPROM_CMD_CONFIG);
583 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
584 reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
585 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
586 rtl818x_iowrite32(priv, &priv->map->ANAPARAM, anaparam);
587 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, anaparam2);
588 if (priv->is_rtl8187b)
589 rtl818x_iowrite8(priv, &priv->map->ANAPARAM3, anaparam3);
590 reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
591 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
592 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
593 RTL818X_EEPROM_CMD_NORMAL);
594}
595
556static int rtl8187_cmd_reset(struct ieee80211_hw *dev) 596static int rtl8187_cmd_reset(struct ieee80211_hw *dev)
557{ 597{
558 struct rtl8187_priv *priv = dev->priv; 598 struct rtl8187_priv *priv = dev->priv;
@@ -603,19 +643,7 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
603 int res; 643 int res;
604 644
605 /* reset */ 645 /* reset */
606 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, 646 rtl8187_set_anaparam(priv, true);
607 RTL818X_EEPROM_CMD_CONFIG);
608 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
609 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg |
610 RTL818X_CONFIG3_ANAPARAM_WRITE);
611 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
612 RTL8187_RTL8225_ANAPARAM_ON);
613 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
614 RTL8187_RTL8225_ANAPARAM2_ON);
615 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg &
616 ~RTL818X_CONFIG3_ANAPARAM_WRITE);
617 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
618 RTL818X_EEPROM_CMD_NORMAL);
619 647
620 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0); 648 rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0);
621 649
@@ -629,17 +657,7 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
629 if (res) 657 if (res)
630 return res; 658 return res;
631 659
632 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); 660 rtl8187_set_anaparam(priv, true);
633 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
634 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
635 reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
636 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
637 RTL8187_RTL8225_ANAPARAM_ON);
638 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
639 RTL8187_RTL8225_ANAPARAM2_ON);
640 rtl818x_iowrite8(priv, &priv->map->CONFIG3,
641 reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
642 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
643 661
644 /* setup card */ 662 /* setup card */
645 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0); 663 rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0);
@@ -740,22 +758,7 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
740 int res, i; 758 int res, i;
741 u8 reg; 759 u8 reg;
742 760
743 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, 761 rtl8187_set_anaparam(priv, true);
744 RTL818X_EEPROM_CMD_CONFIG);
745 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
746 reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
747 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
748 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
749 RTL8187B_RTL8225_ANAPARAM2_ON);
750 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
751 RTL8187B_RTL8225_ANAPARAM_ON);
752 rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
753 RTL8187B_RTL8225_ANAPARAM3_ON);
754 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
755 reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
756 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
757 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
758 RTL818X_EEPROM_CMD_NORMAL);
759 762
760 /* Reset PLL sequence on 8187B. Realtek note: reduces power 763 /* Reset PLL sequence on 8187B. Realtek note: reduces power
761 * consumption about 30 mA */ 764 * consumption about 30 mA */
@@ -1006,6 +1009,7 @@ static void rtl8187_stop(struct ieee80211_hw *dev)
1006 rtl818x_iowrite8(priv, &priv->map->CMD, reg); 1009 rtl818x_iowrite8(priv, &priv->map->CMD, reg);
1007 1010
1008 priv->rf->stop(dev); 1011 priv->rf->stop(dev);
1012 rtl8187_set_anaparam(priv, false);
1009 1013
1010 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); 1014 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
1011 reg = rtl818x_ioread8(priv, &priv->map->CONFIG4); 1015 reg = rtl818x_ioread8(priv, &priv->map->CONFIG4);
diff --git a/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c b/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
index 97eebdcf7eb9..5c6666f09ac1 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_rtl8225.c
@@ -898,29 +898,7 @@ static void rtl8225z2_b_rf_init(struct ieee80211_hw *dev)
898 898
899static void rtl8225_rf_stop(struct ieee80211_hw *dev) 899static void rtl8225_rf_stop(struct ieee80211_hw *dev)
900{ 900{
901 u8 reg;
902 struct rtl8187_priv *priv = dev->priv;
903
904 rtl8225_write(dev, 0x4, 0x1f); 901 rtl8225_write(dev, 0x4, 0x1f);
905
906 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
907 reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
908 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
909 if (!priv->is_rtl8187b) {
910 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
911 RTL8187_RTL8225_ANAPARAM2_OFF);
912 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
913 RTL8187_RTL8225_ANAPARAM_OFF);
914 } else {
915 rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
916 RTL8187B_RTL8225_ANAPARAM2_OFF);
917 rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
918 RTL8187B_RTL8225_ANAPARAM_OFF);
919 rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
920 RTL8187B_RTL8225_ANAPARAM3_OFF);
921 }
922 rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
923 rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
924} 902}
925 903
926static void rtl8225_rf_set_channel(struct ieee80211_hw *dev, 904static void rtl8225_rf_set_channel(struct ieee80211_hw *dev,