diff options
Diffstat (limited to 'drivers/staging/rtl8187se/r8185b_init.c')
-rw-r--r-- | drivers/staging/rtl8187se/r8185b_init.c | 239 |
1 files changed, 67 insertions, 172 deletions
diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c index bf343199bd21..f1db9e401c87 100644 --- a/drivers/staging/rtl8187se/r8185b_init.c +++ b/drivers/staging/rtl8187se/r8185b_init.c @@ -207,156 +207,84 @@ void SetOutputEnableOfRfPins(struct net_device *dev) write_nic_word(dev, RFPinsEnable, 0x1bff); } -static int HwHSSIThreeWire(struct net_device *dev, - u8 *pDataBuf, - u8 nDataBufBitCnt, - int bSI, - int bWrite) +static bool HwHSSIThreeWire(struct net_device *dev, + u8 *pDataBuf, + bool write) { - int bResult = 1; u8 TryCnt; u8 u1bTmp; - do { - /* Check if WE and RE are cleared. */ - for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) { - u1bTmp = read_nic_byte(dev, SW_3W_CMD1); - if ((u1bTmp & (SW_3W_CMD1_RE|SW_3W_CMD1_WE)) == 0) - break; - - udelay(10); - } - if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) { - printk(KERN_ERR "rtl8187se: HwThreeWire(): CmdReg:" - " %#X RE|WE bits are not clear!!\n", u1bTmp); - dump_stack(); - return 0; - } - - /* RTL8187S HSSI Read/Write Function */ - u1bTmp = read_nic_byte(dev, RF_SW_CONFIG); - - if (bSI) - u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */ - - else - u1bTmp &= ~RF_SW_CFG_SI; /* reg08[1]=0 Parallel Interface(PI) */ - - - write_nic_byte(dev, RF_SW_CONFIG, u1bTmp); - - if (bSI) { - /* jong: HW SI read must set reg84[3]=0. */ - u1bTmp = read_nic_byte(dev, RFPinsSelect); - u1bTmp &= ~BIT3; - write_nic_byte(dev, RFPinsSelect, u1bTmp); - } - /* Fill up data buffer for write operation. */ - - if (bWrite) { - if (nDataBufBitCnt == 16) { - write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf)); - } else if (nDataBufBitCnt == 64) { - /* RTL8187S shouldn't enter this case */ - write_nic_dword(dev, SW_3W_DB0, *((u32 *)pDataBuf)); - write_nic_dword(dev, SW_3W_DB1, *((u32 *)(pDataBuf + 4))); - } else { - int idx; - int ByteCnt = nDataBufBitCnt / 8; - /* printk("%d\n",nDataBufBitCnt); */ - if ((nDataBufBitCnt % 8) != 0) { - printk(KERN_ERR "rtl8187se: " - "HwThreeWire(): nDataBufBitCnt(%d)" - " should be multiple of 8!!!\n", - nDataBufBitCnt); - dump_stack(); - nDataBufBitCnt += 8; - nDataBufBitCnt &= ~7; - } - - if (nDataBufBitCnt > 64) { - printk(KERN_ERR "rtl8187se: HwThreeWire():" - " nDataBufBitCnt(%d) should <= 64!!!\n", - nDataBufBitCnt); - dump_stack(); - nDataBufBitCnt = 64; - } + /* Check if WE and RE are cleared. */ + for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) { + u1bTmp = read_nic_byte(dev, SW_3W_CMD1); + if ((u1bTmp & (SW_3W_CMD1_RE|SW_3W_CMD1_WE)) == 0) + break; - for (idx = 0; idx < ByteCnt; idx++) - write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx)); + udelay(10); + } + if (TryCnt == TC_3W_POLL_MAX_TRY_CNT) { + netdev_err(dev, + "HwThreeWire(): CmdReg: %#X RE|WE bits are not clear!!\n", + u1bTmp); + return false; + } - } - } else { /* read */ - if (bSI) { - /* SI - reg274[3:0] : RF register's Address */ - write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf)); - } else { - /* PI - reg274[15:12] : RF register's Address */ - write_nic_word(dev, SW_3W_DB0, (*((u16 *)pDataBuf)) << 12); - } - } + /* RTL8187S HSSI Read/Write Function */ + u1bTmp = read_nic_byte(dev, RF_SW_CONFIG); + u1bTmp |= RF_SW_CFG_SI; /* reg08[1]=1 Serial Interface(SI) */ + write_nic_byte(dev, RF_SW_CONFIG, u1bTmp); - /* Set up command: WE or RE. */ - if (bWrite) - write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_WE); + /* jong: HW SI read must set reg84[3]=0. */ + u1bTmp = read_nic_byte(dev, RFPinsSelect); + u1bTmp &= ~BIT3; + write_nic_byte(dev, RFPinsSelect, u1bTmp); + /* Fill up data buffer for write operation. */ - else - write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_RE); + /* SI - reg274[3:0] : RF register's Address */ + if (write) + write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf)); + else + write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf)); + /* Set up command: WE or RE. */ + if (write) + write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_WE); + else + write_nic_byte(dev, SW_3W_CMD1, SW_3W_CMD1_RE); - /* Check if DONE is set. */ - for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) { - u1bTmp = read_nic_byte(dev, SW_3W_CMD1); - if ((u1bTmp & SW_3W_CMD1_DONE) != 0) - break; - udelay(10); - } + /* Check if DONE is set. */ + for (TryCnt = 0; TryCnt < TC_3W_POLL_MAX_TRY_CNT; TryCnt++) { + u1bTmp = read_nic_byte(dev, SW_3W_CMD1); + if (u1bTmp & SW_3W_CMD1_DONE) + break; - write_nic_byte(dev, SW_3W_CMD1, 0); + udelay(10); + } - /* Read back data for read operation. */ - if (bWrite == 0) { - if (bSI) { - /* Serial Interface : reg363_362[11:0] */ - *((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ) ; - } else { - /* Parallel Interface : reg361_360[11:0] */ - *((u16 *)pDataBuf) = read_nic_word(dev, PI_DATA_READ); - } + write_nic_byte(dev, SW_3W_CMD1, 0); - *((u16 *)pDataBuf) &= 0x0FFF; - } - - } while (0); + /* Read back data for read operation. */ + if (!write) { + /* Serial Interface : reg363_362[11:0] */ + *((u16 *)pDataBuf) = read_nic_word(dev, SI_DATA_READ); + *((u16 *)pDataBuf) &= 0x0FFF; + } - return bResult; + return true; } -void RF_WriteReg(struct net_device *dev, u8 offset, u32 data) +void RF_WriteReg(struct net_device *dev, u8 offset, u16 data) { - u32 data2Write; - u8 len; - - /* Pure HW 3-wire. */ - data2Write = (data << 4) | (u32)(offset & 0x0f); - len = 16; - - HwHSSIThreeWire(dev, (u8 *)(&data2Write), len, 1, 1); + u16 reg = (data << 4) | (offset & 0x0f); + HwHSSIThreeWire(dev, (u8 *)®, true); } -u32 RF_ReadReg(struct net_device *dev, u8 offset) +u16 RF_ReadReg(struct net_device *dev, u8 offset) { - u32 data2Write; - u8 wlen; - u32 dataRead; - - data2Write = ((u32)(offset & 0x0f)); - wlen = 16; - HwHSSIThreeWire(dev, (u8 *)(&data2Write), wlen, 1, 0); - dataRead = data2Write; - - return dataRead; + u16 reg = offset & 0x0f; + HwHSSIThreeWire(dev, (u8 *)®, false); + return reg; } @@ -472,7 +400,8 @@ void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev) struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u32 i; u32 addr, data; - u32 u4bRegOffset, u4bRegValue, u4bRF23, u4bRF24; + u32 u4bRegOffset, u4bRegValue; + u16 u4bRF23, u4bRF24; u8 u1b24E; int d_cut = 0; @@ -491,7 +420,7 @@ void ZEBRA_Config_85BASIC_HardCode(struct net_device *dev) if (u4bRF23 == 0x818 && u4bRF24 == 0x70C) { d_cut = 1; - printk(KERN_INFO "rtl8187se: card type changed from C- to D-cut\n"); + netdev_info(dev, "card type changed from C- to D-cut\n"); } /* Page0 : reg0-reg15 */ @@ -930,10 +859,7 @@ static void MacConfig_85BASIC(struct net_device *dev) u8 GetSupportedWirelessMode8185(struct net_device *dev) { - u8 btSupportedWirelessMode = 0; - - btSupportedWirelessMode = (WIRELESS_MODE_B | WIRELESS_MODE_G); - return btSupportedWirelessMode; + return WIRELESS_MODE_B | WIRELESS_MODE_G; } void ActUpdateChannelAccessSetting(struct net_device *dev, @@ -1130,13 +1056,13 @@ void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode) ieee->mode = (WIRELESS_MODE)btWirelessMode; /* 3. Change related setting. */ - if( ieee->mode == WIRELESS_MODE_A ) { + if (ieee->mode == WIRELESS_MODE_A) DMESG("WIRELESS_MODE_A\n"); - } else if( ieee->mode == WIRELESS_MODE_B ) { + else if (ieee->mode == WIRELESS_MODE_B) DMESG("WIRELESS_MODE_B\n"); - } else if( ieee->mode == WIRELESS_MODE_G ) { + else if (ieee->mode == WIRELESS_MODE_G) DMESG("WIRELESS_MODE_G\n"); - } + ActUpdateChannelAccessSetting( dev, ieee->mode, &priv->ChannelAccessSetting); } @@ -1148,18 +1074,11 @@ void rtl8185b_irq_enable(struct net_device *dev) write_nic_dword(dev, IMR, priv->IntrMask); } -void DrvIFIndicateDisassociation(struct net_device *dev, u16 reason) -{ - /* nothing is needed after disassociation request. */ -} - void MgntDisconnectIBSS(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u8 i; - DrvIFIndicateDisassociation(dev, unspec_reason); - for (i = 0; i < 6 ; i++) priv->ieee80211->current_network.bssid[i] = 0x55; @@ -1190,8 +1109,6 @@ void MlmeDisassociateRequest(struct net_device *dev, u8 *asSta, u8 asRsn) if (memcmp(priv->ieee80211->current_network.bssid, asSta, 6) == 0) { /* ShuChen TODO: change media status. */ - /* ShuChen TODO: What to do when disassociate. */ - DrvIFIndicateDisassociation(dev, unspec_reason); for (i = 0; i < 6; i++) priv->ieee80211->current_network.bssid[i] = 0x22; @@ -1267,14 +1184,6 @@ bool SetRFPowerState(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState) return bResult; } -void HalEnableRx8185Dummy(struct net_device *dev) -{ -} - -void HalDisableRx8185Dummy(struct net_device *dev) -{ -} - bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u32 ChangeSource) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); @@ -1323,11 +1232,9 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u priv->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW && !priv->bInHctTest) + if (rtState == eRfOff && ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; - - } else - ; + } break; case eRfOff: @@ -1359,18 +1266,6 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, u if (bActionAllowed) { /* Config HW to the specified mode. */ SetRFPowerState(dev, StateToSet); - - /* Turn on RF. */ - if (StateToSet == eRfOn) { - HalEnableRx8185Dummy(dev); - if (bConnectBySSID) { - /* by amy not supported */ - } - } - /* Turn off RF. */ - else if (StateToSet == eRfOff) - HalDisableRx8185Dummy(dev); - } /* Release RF spinlock */ |