Commit 8daba6b9 authored by Larry Finger's avatar Larry Finger Committed by Greg Kroah-Hartman

Staging: r8187se: Remove two private variables that have a fixed value

For the RTL8187SE, the variable priv->rf_chip is always RF_ZEBRA4
and priv->RegThreeWireMode is always HW_THREE_WIRE_SI. Remove these
2 variables.
Signed-off-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b1b7621b
......@@ -366,7 +366,6 @@ typedef struct r8180_priv
short diversity;
u8 cs_treshold;
short rcr_csense;
short rf_chip;
u32 key0[4];
short (*rf_set_sens)(struct net_device *dev,short sens);
void (*rf_set_chan)(struct net_device *dev,short ch);
......@@ -479,9 +478,6 @@ typedef struct r8180_priv
u8 retry_rts;
u16 rts;
//add for RF power on power off by lizhaoming 080512
u8 RegThreeWireMode; // See "Three wire mode" defined above, 2006.05.31, by rcnjko.
//by amy for led
LED_STRATEGY_8185 LedStrategy;
//by amy for led
......
......@@ -663,11 +663,8 @@ unsigned char STRENGTH_MAP[] = {
void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u32 temp;
u32 temp2;
u32 temp3;
u32 lsb;
u32 q;
u32 orig_qual;
u8 _rssi;
......@@ -689,88 +686,6 @@ void rtl8180_RSSI_calc(struct net_device *dev, u8 *rssi, u8 *qual)
*qual = temp;
temp2 = *rssi;
switch(priv->rf_chip){
case RFCHIPID_RFMD:
lsb = temp2 & 1;
temp2 &= 0x7e;
if ( !lsb || !(temp2 <= 0x3c) ) {
temp2 = 0x64;
} else {
temp2 = 100 * temp2 / 0x3c;
}
*rssi = temp2 & 0xff;
_rssi = temp2 & 0xff;
break;
case RFCHIPID_INTERSIL:
lsb = temp2;
temp2 &= 0xfffffffe;
temp2 *= 251;
temp3 = temp2;
temp2 <<= 6;
temp3 += temp2;
temp3 <<= 1;
temp2 = 0x4950df;
temp2 -= temp3;
lsb &= 1;
if ( temp2 <= 0x3e0000 ) {
if ( temp2 < 0xffef0000 )
temp2 = 0xffef0000;
} else {
temp2 = 0x3e0000;
}
if ( !lsb ) {
temp2 -= 0xf0000;
} else {
temp2 += 0xf0000;
}
temp3 = 0x4d0000;
temp3 -= temp2;
temp3 *= 100;
temp3 = temp3 / 0x6d;
temp3 >>= 0x10;
_rssi = temp3 & 0xff;
*rssi = temp3 & 0xff;
break;
case RFCHIPID_GCT:
lsb = temp2 & 1;
temp2 &= 0x7e;
if ( ! lsb || !(temp2 <= 0x3c) ){
temp2 = 0x64;
} else {
temp2 = (100 * temp2) / 0x3c;
}
*rssi = temp2 & 0xff;
_rssi = temp2 & 0xff;
break;
case RFCHIPID_PHILIPS:
if( orig_qual <= 0x4e ){
_rssi = STRENGTH_MAP[orig_qual];
*rssi = _rssi;
} else {
orig_qual -= 0x80;
if ( !orig_qual ){
_rssi = 1;
*rssi = 1;
} else {
_rssi = 0x32;
*rssi = 0x32;
}
}
break;
case RFCHIPID_MAXIM:
lsb = temp2 & 1;
temp2 &= 0x7e;
temp2 >>= 1;
temp2 += 0x42;
if( lsb != 0 ){
temp2 += 0xa;
}
*rssi = temp2 & 0xff;
_rssi = temp2 & 0xff;
break;
}
if ( _rssi < 0x64 ){
if ( _rssi == 0 ) {
*rssi = 1;
......@@ -2707,8 +2622,6 @@ short rtl8180_init(struct net_device *dev)
priv->txbeaconcount = 2;
priv->rx_skb_complete = 1;
priv->RegThreeWireMode = HW_THREE_WIRE_SI;
priv->RFChangeInProgress = false;
priv->SetRFPowerStateInProgress = false;
priv->RFProgType = 0;
......@@ -2999,9 +2912,6 @@ short rtl8180_init(struct net_device *dev)
priv->cs_treshold = (eeprom_val & 0xff00) >> 8;
eeprom_93cx6_read(&eeprom, RFCHIPID, &eeprom_val);
priv->rf_chip = 0xff & eeprom_val;
priv->rf_chip = RF_ZEBRA4;
priv->rf_sleep = rtl8225z4_rf_sleep;
priv->rf_wakeup = rtl8225z4_rf_wakeup;
DMESGW("**PLEASE** REPORT SUCCESSFUL/UNSUCCESSFUL TO Realtek!");
......
......@@ -282,30 +282,13 @@ DIG_Zebra(
// Dispatch DIG implementation according to RF.
//
void
DynamicInitGain(
struct net_device *dev
)
DynamicInitGain(struct net_device *dev)
{
struct r8180_priv *priv = ieee80211_priv(dev);
switch(priv->rf_chip)
{
case RF_ZEBRA2: // [AnnieWorkaround] For Zebra2, 2005-08-01.
case RF_ZEBRA4:
DIG_Zebra( dev );
break;
default:
printk("DynamicInitGain(): unknown RFChipID(%d) !!!\n", priv->rf_chip);
break;
}
DIG_Zebra(dev);
}
void rtl8180_hw_dig_wq (struct work_struct *work)
{
// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
// struct ieee80211_device * ieee = (struct ieee80211_device*)
// container_of(work, struct ieee80211_device, watch_dog_wq);
struct delayed_work *dwork = to_delayed_work(work);
struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_dig_wq);
struct net_device *dev = ieee->dev;
......@@ -1310,44 +1293,24 @@ SetAntenna8185(
switch(u1bAntennaIndex)
{
case 0:
switch(priv->rf_chip)
{
case RF_ZEBRA2:
case RF_ZEBRA4:
// Mac register, main antenna
/* Mac register, main antenna */
write_nic_byte(dev, ANTSEL, 0x03);
//base band
write_phy_cck(dev,0x11, 0x9b); // Config CCK RX antenna.
write_phy_ofdm(dev, 0x0d, 0x5c); // Config OFDM RX antenna.
/* base band */
write_phy_cck(dev, 0x11, 0x9b); /* Config CCK RX antenna. */
write_phy_ofdm(dev, 0x0d, 0x5c); /* Config OFDM RX antenna. */
bAntennaSwitched = true;
break;
default:
printk("SetAntenna8185: unknown RFChipID(%d)\n", priv->rf_chip);
break;
}
break;
case 1:
switch(priv->rf_chip)
{
case RF_ZEBRA2:
case RF_ZEBRA4:
// Mac register, aux antenna
/* Mac register, aux antenna */
write_nic_byte(dev, ANTSEL, 0x00);
//base band
write_phy_cck(dev, 0x11, 0xbb); // Config CCK RX antenna.
write_phy_ofdm(dev, 0x0d, 0x54); // Config OFDM RX antenna.
/* base band */
write_phy_cck(dev, 0x11, 0xbb); /* Config CCK RX antenna. */
write_phy_ofdm(dev, 0x0d, 0x54); /* Config OFDM RX antenna. */
bAntennaSwitched = true;
break;
default:
printk("SetAntenna8185: unknown RFChipID(%d)\n", priv->rf_chip);
break;
}
break;
default:
......
......@@ -854,31 +854,6 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
btConfig3 = read_nic_byte(dev, CONFIG3);
write_nic_byte(dev, CONFIG3, (btConfig3 | CONFIG3_PARM_En));
switch (priv->rf_chip) {
case RF_ZEBRA2:
switch (eRFPowerState) {
case eRfOn:
RF_WriteReg(dev,0x4,0x9FF);
write_nic_dword(dev, ANAPARAM, ANAPARM_ON);
write_nic_dword(dev, ANAPARAM2, ANAPARM2_ON);
write_nic_byte(dev, CONFIG4, priv->RFProgType);
/* turn on CCK and OFDM */
u1bTmp = read_nic_byte(dev, 0x24E);
write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6))));
break;
case eRfSleep:
break;
case eRfOff:
break;
default:
bResult = false;
break;
}
break;
case RF_ZEBRA4:
switch (eRFPowerState) {
case eRfOn:
write_nic_word(dev, 0x37C, 0x00EC);
......@@ -896,8 +871,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
RF_WriteReg(dev, 0x4, 0x0972); udelay(500);
/* turn on BB */
write_phy_ofdm(dev,0x10,0x40);
write_phy_ofdm(dev,0x12,0x40);
write_phy_ofdm(dev, 0x10, 0x40);
write_phy_ofdm(dev, 0x12, 0x40);
/* Avoid power down at init time. */
write_nic_byte(dev, CONFIG4, priv->RFProgType);
......@@ -911,7 +886,7 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
QueueID++;
continue;
} else {
priv->TxPollingTimes ++;
priv->TxPollingTimes++;
if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) {
bActionAllowed = false;
break;
......@@ -999,8 +974,7 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
{
int i = 0;
while (true)
{
while (true) {
u8 tmp24F = read_nic_byte(dev, 0x24f);
if ((tmp24F == 0x01) || (tmp24F == 0x09)) {
......@@ -1027,12 +1001,6 @@ bool SetZebraRFPowerState8185(struct net_device *dev,
write_nic_word(dev, 0x37C, 0x00FC);
}
break;
default:
bResult = false;
printk("SetZebraRFPowerState8185(): unknown state to set: 0x%X!!!\n", eRFPowerState);
break;
}
break;
}
btConfig3 &= ~(CONFIG3_PARM_En);
......
......@@ -238,22 +238,9 @@ PlatformIORead4Byte(
return data;
}
void
SetOutputEnableOfRfPins(
struct net_device *dev
)
void SetOutputEnableOfRfPins(struct net_device *dev)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
switch(priv->rf_chip)
{
case RFCHIPID_RTL8225:
case RF_ZEBRA2:
case RF_ZEBRA4:
write_nic_word(dev, RFPinsEnable, 0x1bff);
//write_nic_word(dev, RFPinsEnable, 0x1fff);
break;
}
}
void
......@@ -603,109 +590,25 @@ HwThreeWire(
void
RF_WriteReg(
struct net_device *dev,
u8 offset,
u32 data
)
RF_WriteReg(struct net_device *dev, u8 offset, u32 data)
{
//RFReg reg;
u32 data2Write;
u8 len;
u8 low2high;
//u32 RF_Read = 0;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
switch(priv->rf_chip)
{
case RFCHIPID_RTL8225:
case RF_ZEBRA2: // Annie 2006-05-12.
case RF_ZEBRA4: //by amy
switch(priv->RegThreeWireMode)
{
case SW_THREE_WIRE:
{ // Perform SW 3-wire programming by driver.
data2Write = (data << 4) | (u32)(offset & 0x0f);
len = 16;
low2high = 0;
ZEBRA_RFSerialWrite(dev, data2Write, len, low2high);
}
break;
case HW_THREE_WIRE:
{ // Pure HW 3-wire.
data2Write = (data << 4) | (u32)(offset & 0x0f);
len = 16;
HwThreeWire(
dev,
(u8 *)(&data2Write), // pDataBuf,
len, // nDataBufBitCnt,
0, // bHold,
1); // bWrite
}
break;
case HW_THREE_WIRE_PI: //Parallel Interface
{ // Pure HW 3-wire.
data2Write = (data << 4) | (u32)(offset & 0x0f);
len = 16;
HwHSSIThreeWire(
dev,
(u8*)(&data2Write), // pDataBuf,
len, // nDataBufBitCnt,
0, // bSI
1); // bWrite
//printk("33333\n");
}
break;
case HW_THREE_WIRE_SI: //Serial Interface
{ // Pure HW 3-wire.
/* Pure HW 3-wire. */
data2Write = (data << 4) | (u32)(offset & 0x0f);
len = 16;
// printk(" enter ZEBRA_RFSerialWrite\n ");
// low2high = 0;
// ZEBRA_RFSerialWrite(dev, data2Write, len, low2high);
HwHSSIThreeWire(
dev,
(u8*)(&data2Write), // pDataBuf,
len, // nDataBufBitCnt,
1, // bSI
1); // bWrite
// printk(" exit ZEBRA_RFSerialWrite\n ");
}
break;
default:
DMESGE("RF_WriteReg(): invalid RegThreeWireMode(%d) !!!", priv->RegThreeWireMode);
break;
}
break;
default:
DMESGE("RF_WriteReg(): unknown RFChipID: %#X", priv->rf_chip);
break;
}
HwHSSIThreeWire(dev, (u8 *)(&data2Write), len, 1, 1);
}
void
ZEBRA_RFSerialRead(
struct net_device *dev,
u32 data2Write,
u8 wLength,
u32 *data2Read,
u8 rLength,
u8 low2high
)
ZEBRA_RFSerialRead(struct net_device *dev, u32 data2Write, u8 wLength,
u32 *data2Read, u8 rLength, u8 low2high)
{
ThreeWireReg twreg;
int i;
u16 oval,oval2,oval3,tmp, wReg80;
u16 oval, oval2, oval3, tmp, wReg80;
u32 mask;
u8 u1bTmp;
ThreeWireReg tdata;
......@@ -818,71 +721,16 @@ ZEBRA_RFSerialRead(
}
u32
RF_ReadReg(
struct net_device *dev,
u8 offset
)
u32 RF_ReadReg(struct net_device *dev, u8 offset)
{
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
u32 data2Write;
u8 wlen;
u8 rlen;
u8 low2high;
u32 dataRead;
switch(priv->rf_chip)
{
case RFCHIPID_RTL8225:
case RF_ZEBRA2:
case RF_ZEBRA4:
switch(priv->RegThreeWireMode)
{
case HW_THREE_WIRE_PI: // For 87S Parallel Interface.
{
data2Write = ((u32)(offset&0x0f));
wlen=16;
HwHSSIThreeWire(
dev,
(u8*)(&data2Write), // pDataBuf,
wlen, // nDataBufBitCnt,
0, // bSI
0); // bWrite
dataRead= data2Write;
}
break;
case HW_THREE_WIRE_SI: // For 87S Serial Interface.
{
data2Write = ((u32)(offset&0x0f)) ;
wlen=16;
HwHSSIThreeWire(
dev,
(u8*)(&data2Write), // pDataBuf,
wlen, // nDataBufBitCnt,
1, // bSI
0 // bWrite
);
dataRead= data2Write;
}
break;
// Perform SW 3-wire programming by driver.
default:
{
data2Write = ((u32)(offset&0x1f)) << 27; // For Zebra E-cut. 2005.04.11, by rcnjko.
wlen = 6;
rlen = 12;
low2high = 0;
ZEBRA_RFSerialRead(dev, data2Write, wlen,&dataRead,rlen, low2high);
}
break;
}
break;
default:
dataRead = 0;
break;
}
data2Write = ((u32)(offset & 0x0f));
wlen = 16;
HwHSSIThreeWire(dev, (u8 *)(&data2Write), wlen, 1, 0);
dataRead = data2Write;
return dataRead;
}
......@@ -1291,83 +1139,61 @@ UpdateInitialGain(
return;
}
switch(priv->rf_chip)
{
case RF_ZEBRA4:
// Dynamic set initial gain, follow 87B
switch(priv->InitialGain)
{
case 1: //m861dBm
//DMESG("RTL8187 + 8225 Initial Gain State 1: -82 dBm \n");
switch (priv->InitialGain) {
case 1: /* m861dBm */
write_phy_ofdm(dev, 0x17, 0x26); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x86); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfa); mdelay(1);
break;
case 2: //m862dBm
//DMESG("RTL8187 + 8225 Initial Gain State 2: -82 dBm \n");
case 2: /* m862dBm */
write_phy_ofdm(dev, 0x17, 0x36); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x86); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfa); mdelay(1);
break;
case 3: //m863dBm
//DMESG("RTL8187 + 8225 Initial Gain State 3: -82 dBm \n");
case 3: /* m863dBm */
write_phy_ofdm(dev, 0x17, 0x36); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x86); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfb); mdelay(1);
break;
case 4: //m864dBm
//DMESG("RTL8187 + 8225 Initial Gain State 4: -78 dBm \n");
case 4: /* m864dBm */
write_phy_ofdm(dev, 0x17, 0x46); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x86); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfb); mdelay(1);
break;
case 5: //m82dBm
//DMESG("RTL8187 + 8225 Initial Gain State 5: -74 dBm \n");
case 5: /* m82dBm */
write_phy_ofdm(dev, 0x17, 0x46); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x96); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfb); mdelay(1);
break;
case 6: //m78dBm
//DMESG ("RTL8187 + 8225 Initial Gain State 6: -70 dBm \n");
case 6: /* m78dBm */
write_phy_ofdm(dev, 0x17, 0x56); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x96); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfc); mdelay(1);
break;
case 7: //m74dBm
//DMESG("RTL8187 + 8225 Initial Gain State 7: -66 dBm \n");
case 7: /* m74dBm */
write_phy_ofdm(dev, 0x17, 0x56); mdelay(1);
write_phy_ofdm(dev, 0x24, 0xa6); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfc); mdelay(1);
break;
case 8:
//DMESG("RTL8187 + 8225 Initial Gain State 8:\n");
write_phy_ofdm(dev, 0x17, 0x66); mdelay(1);
write_phy_ofdm(dev, 0x24, 0xb6); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfc); mdelay(1);
break;
default: //MP
//DMESG("RTL8187 + 8225 Initial Gain State 1: -82 dBm (default)\n");
default: /* MP */
write_phy_ofdm(dev, 0x17, 0x26); mdelay(1);
write_phy_ofdm(dev, 0x24, 0x86); mdelay(1);
write_phy_ofdm(dev, 0x05, 0xfa); mdelay(1);
break;
}
break;
default:
DMESG("UpdateInitialGain(): unknown RFChipID: %#X\n", priv->rf_chip);
break;
}
}
//
// Description:
......@@ -1397,14 +1223,8 @@ PhyConfig8185(
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
write_nic_dword(dev, RCR, priv->ReceiveConfig);
priv->RFProgType = read_nic_byte(dev, CONFIG4) & 0x03;
// RF config
switch(priv->rf_chip)
{
case RF_ZEBRA2:
case RF_ZEBRA4:
ZEBRA_Config_85BASIC_HardCode( dev);
break;
}
/* RF config */
ZEBRA_Config_85BASIC_HardCode(dev);
//{by amy 080312
// Set default initial gain state to 4, approved by SD3 DZ, by Bruce, 2007-06-06.
if(priv->bDigMechanism)
......@@ -1614,19 +1434,8 @@ GetSupportedWirelessMode8185(
)
{
u8 btSupportedWirelessMode = 0;
struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev);
switch(priv->rf_chip)
{
case RF_ZEBRA2:
case RF_ZEBRA4:
btSupportedWirelessMode = (WIRELESS_MODE_B | WIRELESS_MODE_G);
break;
default:
btSupportedWirelessMode = WIRELESS_MODE_B;
break;
}
return btSupportedWirelessMode;
}
......@@ -1881,23 +1690,11 @@ ActSetWirelessMode8185(
}
// 2. Swtich band: RF or BB specific actions,
// for example, refresh tables in omc8255, or change initial gain if necessary.
switch(priv->rf_chip)
{
case RF_ZEBRA2:
case RF_ZEBRA4:
{
// Nothing to do for Zebra to switch band.
// Update current wireless mode if we swtich to specified band successfully.
/* 2. Swtich band: RF or BB specific actions,
* for example, refresh tables in omc8255, or change initial gain if necessary.
* Nothing to do for Zebra to switch band.
* Update current wireless mode if we swtich to specified band successfully. */
ieee->mode = (WIRELESS_MODE)btWirelessMode;
}
break;
default:
DMESGW("ActSetWirelessMode8185(): unsupported RF: 0x%X !!!\n", priv->rf_chip);
break;
}
// 3. Change related setting.
if( ieee->mode == WIRELESS_MODE_A ){
......@@ -2108,18 +1905,7 @@ SetRFPowerState(
return bResult;
}
switch(priv->rf_chip)
{
case RF_ZEBRA2:
case RF_ZEBRA4:
bResult = SetZebraRFPowerState8185(dev, eRFPowerState);
break;
default:
printk("SetRFPowerState8185(): unknown RFChipID: 0x%X!!!\n", priv->rf_chip);
break;;
}
// printk("<--------- SetRFPowerState(): bResult(%d)\n", bResult);
return bResult;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment