rtl8180: introduce functions for setting ANAPARAM 2 and 3 params
authorAndrea Merello <andrea.merello@gmail.com>
Wed, 26 Mar 2014 20:02:05 +0000 (21:02 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 27 Mar 2014 18:20:08 +0000 (14:20 -0400)
rtl8180 has one register for analog converters setting ,rtl8185 has
two and rtl8187se has three.
Setting those registers require more than a simple write, and for
one of them a function is already provided.
This patch introduces functions for the other two.
rtl8187se will use them. rtl8185 doesen't yet, but should

Signed-off-by: Andrea Merello <andrea.merello@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rtl818x/rtl8180/dev.c
drivers/net/wireless/rtl818x/rtl8180/rtl8180.h
drivers/net/wireless/rtl818x/rtl8180/rtl8225.c

index 740a58308a90196d42ec08143ebd9d15ee05a534..a3b67e656e59f582ed21b498e8e729b6ad8b6d5c 100644 (file)
@@ -523,6 +523,46 @@ static void rtl8180_tx(struct ieee80211_hw *dev,
        }
 }
 
+static void rtl8180_set_anaparam3(struct rtl8180_priv *priv, u16 anaparam3)
+{
+       u8 reg;
+
+       rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
+                        RTL818X_EEPROM_CMD_CONFIG);
+
+       reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
+       rtl818x_iowrite8(priv, &priv->map->CONFIG3,
+                reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
+
+       rtl818x_iowrite16(priv, &priv->map->ANAPARAM3, anaparam3);
+
+       rtl818x_iowrite8(priv, &priv->map->CONFIG3,
+                reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
+
+       rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
+                        RTL818X_EEPROM_CMD_NORMAL);
+}
+
+void rtl8180_set_anaparam2(struct rtl8180_priv *priv, u32 anaparam2)
+{
+       u8 reg;
+
+       rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
+                        RTL818X_EEPROM_CMD_CONFIG);
+
+       reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
+       rtl818x_iowrite8(priv, &priv->map->CONFIG3,
+                reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
+
+       rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, anaparam2);
+
+       rtl818x_iowrite8(priv, &priv->map->CONFIG3,
+                reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
+
+       rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
+                        RTL818X_EEPROM_CMD_NORMAL);
+}
+
 void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam)
 {
        u8 reg;
index d8f92de196342a83e140b122e18ba7ed8a9d3511..0ef3fc758928391b059f7366c4e555536702bf44 100644 (file)
@@ -145,6 +145,7 @@ struct rtl8180_priv {
 
 void rtl8180_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
 void rtl8180_set_anaparam(struct rtl8180_priv *priv, u32 anaparam);
+void rtl8180_set_anaparam2(struct rtl8180_priv *priv, u32 anaparam2);
 
 static inline u8 rtl818x_ioread8(struct rtl8180_priv *priv, u8 __iomem *addr)
 {
index 1c0fe238d995326b81d026abe69bd1f251b8ae3e..9bda5bc78edafd72964b6f03772e62f10da01ca9 100644 (file)
@@ -282,6 +282,7 @@ static void rtl8225_rf_set_tx_power(struct ieee80211_hw *dev, int channel)
 
        msleep(1); /* FIXME: optional? */
 
+       /* TODO: use set_anaparam2 dev.c_func*/
        /* anaparam2 on */
        rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
        reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);