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>
This commit is contained in:
parent
fe3326903d
commit
0bf198eb4d
2 changed files with 44 additions and 62 deletions
|
@ -553,6 +553,46 @@ static int rtl8187b_init_status_urb(struct ieee80211_hw *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rtl8187_set_anaparam(struct rtl8187_priv *priv, bool rfon)
|
||||||
|
{
|
||||||
|
u32 anaparam, anaparam2;
|
||||||
|
u8 anaparam3, reg;
|
||||||
|
|
||||||
|
if (!priv->is_rtl8187b) {
|
||||||
|
if (rfon) {
|
||||||
|
anaparam = RTL8187_RTL8225_ANAPARAM_ON;
|
||||||
|
anaparam2 = RTL8187_RTL8225_ANAPARAM2_ON;
|
||||||
|
} else {
|
||||||
|
anaparam = RTL8187_RTL8225_ANAPARAM_OFF;
|
||||||
|
anaparam2 = RTL8187_RTL8225_ANAPARAM2_OFF;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rfon) {
|
||||||
|
anaparam = RTL8187B_RTL8225_ANAPARAM_ON;
|
||||||
|
anaparam2 = RTL8187B_RTL8225_ANAPARAM2_ON;
|
||||||
|
anaparam3 = RTL8187B_RTL8225_ANAPARAM3_ON;
|
||||||
|
} else {
|
||||||
|
anaparam = RTL8187B_RTL8225_ANAPARAM_OFF;
|
||||||
|
anaparam2 = RTL8187B_RTL8225_ANAPARAM2_OFF;
|
||||||
|
anaparam3 = RTL8187B_RTL8225_ANAPARAM3_OFF;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
|
||||||
|
RTL818X_EEPROM_CMD_CONFIG);
|
||||||
|
reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
|
||||||
|
reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
|
||||||
|
rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
|
||||||
|
rtl818x_iowrite32(priv, &priv->map->ANAPARAM, anaparam);
|
||||||
|
rtl818x_iowrite32(priv, &priv->map->ANAPARAM2, anaparam2);
|
||||||
|
if (priv->is_rtl8187b)
|
||||||
|
rtl818x_iowrite8(priv, &priv->map->ANAPARAM3, anaparam3);
|
||||||
|
reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
|
||||||
|
rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
|
||||||
|
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
|
||||||
|
RTL818X_EEPROM_CMD_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
static int rtl8187_cmd_reset(struct ieee80211_hw *dev)
|
static int rtl8187_cmd_reset(struct ieee80211_hw *dev)
|
||||||
{
|
{
|
||||||
struct rtl8187_priv *priv = dev->priv;
|
struct rtl8187_priv *priv = dev->priv;
|
||||||
|
@ -603,19 +643,7 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
/* reset */
|
/* reset */
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
|
rtl8187_set_anaparam(priv, true);
|
||||||
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->ANAPARAM,
|
|
||||||
RTL8187_RTL8225_ANAPARAM_ON);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
|
|
||||||
RTL8187_RTL8225_ANAPARAM2_ON);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg &
|
|
||||||
~RTL818X_CONFIG3_ANAPARAM_WRITE);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
|
|
||||||
RTL818X_EEPROM_CMD_NORMAL);
|
|
||||||
|
|
||||||
rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0);
|
rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0);
|
||||||
|
|
||||||
|
@ -629,17 +657,7 @@ static int rtl8187_init_hw(struct ieee80211_hw *dev)
|
||||||
if (res)
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
|
rtl8187_set_anaparam(priv, true);
|
||||||
reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->CONFIG3,
|
|
||||||
reg | RTL818X_CONFIG3_ANAPARAM_WRITE);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
|
|
||||||
RTL8187_RTL8225_ANAPARAM_ON);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
|
|
||||||
RTL8187_RTL8225_ANAPARAM2_ON);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->CONFIG3,
|
|
||||||
reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
|
|
||||||
|
|
||||||
/* setup card */
|
/* setup card */
|
||||||
rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0);
|
rtl818x_iowrite16(priv, &priv->map->RFPinsSelect, 0);
|
||||||
|
@ -740,22 +758,7 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
|
||||||
int res, i;
|
int res, i;
|
||||||
u8 reg;
|
u8 reg;
|
||||||
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
|
rtl8187_set_anaparam(priv, true);
|
||||||
RTL818X_EEPROM_CMD_CONFIG);
|
|
||||||
reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
|
|
||||||
reg |= RTL818X_CONFIG3_ANAPARAM_WRITE;
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
|
|
||||||
RTL8187B_RTL8225_ANAPARAM2_ON);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
|
|
||||||
RTL8187B_RTL8225_ANAPARAM_ON);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
|
|
||||||
RTL8187B_RTL8225_ANAPARAM3_ON);
|
|
||||||
reg = rtl818x_ioread8(priv, &priv->map->CONFIG3);
|
|
||||||
reg &= ~RTL818X_CONFIG3_ANAPARAM_WRITE;
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD,
|
|
||||||
RTL818X_EEPROM_CMD_NORMAL);
|
|
||||||
|
|
||||||
/* Reset PLL sequence on 8187B. Realtek note: reduces power
|
/* Reset PLL sequence on 8187B. Realtek note: reduces power
|
||||||
* consumption about 30 mA */
|
* consumption about 30 mA */
|
||||||
|
@ -1006,6 +1009,7 @@ static void rtl8187_stop(struct ieee80211_hw *dev)
|
||||||
rtl818x_iowrite8(priv, &priv->map->CMD, reg);
|
rtl818x_iowrite8(priv, &priv->map->CMD, reg);
|
||||||
|
|
||||||
priv->rf->stop(dev);
|
priv->rf->stop(dev);
|
||||||
|
rtl8187_set_anaparam(priv, false);
|
||||||
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
|
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
|
||||||
reg = rtl818x_ioread8(priv, &priv->map->CONFIG4);
|
reg = rtl818x_ioread8(priv, &priv->map->CONFIG4);
|
||||||
|
|
|
@ -898,29 +898,7 @@ static void rtl8225z2_b_rf_init(struct ieee80211_hw *dev)
|
||||||
|
|
||||||
static void rtl8225_rf_stop(struct ieee80211_hw *dev)
|
static void rtl8225_rf_stop(struct ieee80211_hw *dev)
|
||||||
{
|
{
|
||||||
u8 reg;
|
|
||||||
struct rtl8187_priv *priv = dev->priv;
|
|
||||||
|
|
||||||
rtl8225_write(dev, 0x4, 0x1f);
|
rtl8225_write(dev, 0x4, 0x1f);
|
||||||
|
|
||||||
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);
|
|
||||||
if (!priv->is_rtl8187b) {
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
|
|
||||||
RTL8187_RTL8225_ANAPARAM2_OFF);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
|
|
||||||
RTL8187_RTL8225_ANAPARAM_OFF);
|
|
||||||
} else {
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM2,
|
|
||||||
RTL8187B_RTL8225_ANAPARAM2_OFF);
|
|
||||||
rtl818x_iowrite32(priv, &priv->map->ANAPARAM,
|
|
||||||
RTL8187B_RTL8225_ANAPARAM_OFF);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->ANAPARAM3,
|
|
||||||
RTL8187B_RTL8225_ANAPARAM3_OFF);
|
|
||||||
}
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg & ~RTL818X_CONFIG3_ANAPARAM_WRITE);
|
|
||||||
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rtl8225_rf_set_channel(struct ieee80211_hw *dev,
|
static void rtl8225_rf_set_channel(struct ieee80211_hw *dev,
|
||||||
|
|
Loading…
Reference in a new issue