From patchwork Mon Nov 9 16:53:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 58799 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA9Grsjo002983 for ; Mon, 9 Nov 2009 16:53:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752346AbZKIQxS (ORCPT ); Mon, 9 Nov 2009 11:53:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751036AbZKIQxS (ORCPT ); Mon, 9 Nov 2009 11:53:18 -0500 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:56715 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750941AbZKIQxQ (ORCPT ); Mon, 9 Nov 2009 11:53:16 -0500 Received: from larrylap.site ([65.28.92.235]) by hrndva-omta03.mail.rr.com with SMTP id <20091109165320849.UDNR6318@hrndva-omta03.mail.rr.com>; Mon, 9 Nov 2009 16:53:20 +0000 Date: Mon, 09 Nov 2009 10:53:20 -0600 From: Larry Finger To: Greg Kroah-Hartman Cc: Bernhard Schiffner , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org Subject: [PATCH] staging: rtl8187se: Remove card8185 variable to simplify flow Message-ID: <4af84900.8X31irYDg1fHCu04%Larry.Finger@lwfinger.net> User-Agent: Heirloom mailx 12.2 01/07/07 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Index: wireless-testing/drivers/staging/rtl8187se/r8180_core.c =================================================================== --- wireless-testing.orig/drivers/staging/rtl8187se/r8180_core.c +++ wireless-testing/drivers/staging/rtl8187se/r8180_core.c @@ -886,8 +886,6 @@ void rtl8180_rx_enable(struct net_device rxconf = rxconf | (1<card_8185 == 0) - rxconf = rxconf | (1<ieee80211->iw_mode == IW_MODE_MONITOR){ @@ -910,9 +908,6 @@ void rtl8180_rx_enable(struct net_device rxconf = rxconf &~ RCR_CS_MASK; - if (!priv->card_8185) - rxconf |= (priv->rcr_csense<card_8185) { - byte = read_nic_byte(dev,CW_CONF); - byte &= ~(1<card_8185) - txconf = txconf &~ (1<retry_rts<card_8185) { - if (priv->hw_plcp_len) - txconf = txconf &~ TCR_PLCP_LEN; - else - txconf = txconf | TCR_PLCP_LEN; - } else - txconf = txconf &~ TCR_SAT; + if (priv->hw_plcp_len) + txconf = txconf & ~TCR_PLCP_LEN; + else + txconf = txconf | TCR_PLCP_LEN; txconf = txconf &~ TCR_MXDMA_MASK; txconf = txconf | (TCR_MXDMA_2048<SignalQuality = quality; - if(!priv->card_8185) - printk("check your card type\n"); stats.signal = (u8)quality;//priv->wstats.qual.level = priv->SignalStrength; stats.signalstrength = RXAGC; @@ -2221,10 +2200,8 @@ short rtl8180_tx(struct net_device *dev, *(tail+6) = 0; *(tail+7) = 0; - if(priv->card_8185){ - //FIXME: this should be triggered by HW encryption parameters. - *tail |= (1<<15); //no encrypt - } + /*FIXME: this should be triggered by HW encryption parameters.*/ + *tail |= (1<<15); /* no encrypt */ if(remain==len && !descfrag) { ownbit_flag = false; //added by david woo,2007.12.14 @@ -2266,7 +2243,7 @@ short rtl8180_tx(struct net_device *dev, /* hw_plcp_len is not used for rtl8180 chip */ /* FIXME */ - if(priv->card_8185 == 0 || !priv->hw_plcp_len){ + if (!priv->hw_plcp_len) { duration = rtl8180_len2duration(len, rate, &ext); *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16); if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension @@ -2355,8 +2332,7 @@ void rtl8180_link_change(struct net_devi rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - if(priv->card_8185) - rtl8180_set_chan(dev, priv->chan); + rtl8180_set_chan(dev, priv->chan); } void rtl8180_rq_tx_ack(struct net_device *dev){ @@ -2702,8 +2678,6 @@ short rtl8180_init(struct net_device *de struct r8180_priv *priv = ieee80211_priv(dev); u16 word; u16 version; - u8 hw_version; - //u8 config3; u32 usValue; u16 tmpu16; int i, j; @@ -2928,46 +2902,11 @@ short rtl8180_init(struct net_device *de priv->InitialGain = 6; - hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; + DMESG("MAC controller is a RTL8187SE b/g"); + priv->phy_ver = 2; - switch (hw_version){ - case HW_VERID_R8185B_B: - priv->card_8185 = VERSION_8187S_C; - DMESG("MAC controller is a RTL8187SE b/g"); - priv->phy_ver = 2; - break; - case HW_VERID_R8185_ABC: - DMESG("MAC controller is a RTL8185 b/g"); - priv->card_8185 = 1; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - case HW_VERID_R8185_D: - DMESG("MAC controller is a RTL8185 b/g (V. D)"); - priv->card_8185 = 2; - /* you should not find a card with 8225 PHY ver < C*/ - priv->phy_ver = 2; - break; - case HW_VERID_R8180_ABCD: - DMESG("MAC controller is a RTL8180"); - priv->card_8185 = 0; - break; - case HW_VERID_R8180_F: - DMESG("MAC controller is a RTL8180 (v. F)"); - priv->card_8185 = 0; - break; - default: - DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version); - priv->card_8185 = 0; - break; - } - - if(priv->card_8185){ - priv->ieee80211->modulation |= IEEE80211_OFDM_MODULATION; - priv->ieee80211->short_slot = 1; - } - /* you should not found any 8185 Ver B Card */ - priv->card_8185_Bversion = 0; + priv->ieee80211->modulation |= IEEE80211_OFDM_MODULATION; + priv->ieee80211->short_slot = 1; // just for sync 85 priv->card_type = PCI; @@ -3026,12 +2965,10 @@ short rtl8180_init(struct net_device *de priv->chtxpwr[i]=word & 0xff; priv->chtxpwr[i+1]=(word & 0xff00)>>8; } - if(priv->card_8185){ - for(i=1,j=0; i<14; i+=2,j++){ - word = eprom_read(dev,EPROM_TXPW_OFDM_CH1_2 + j); - priv->chtxpwr_ofdm[i]=word & 0xff; - priv->chtxpwr_ofdm[i+1]=(word & 0xff00)>>8; - } + for (i = 1, j = 0; i < 14; i += 2, j++) { + word = eprom_read(dev, EPROM_TXPW_OFDM_CH1_2 + j); + priv->chtxpwr_ofdm[i] = word & 0xff; + priv->chtxpwr_ofdm[i+1] = (word & 0xff00)>>8; } //3Read crystal calibtration and thermal meter indication on 87SE. @@ -3057,37 +2994,11 @@ short rtl8180_init(struct net_device *de version = eprom_read(dev,EPROM_VERSION); DMESG("EEPROM version %x",version); - if( (!priv->card_8185) && version < 0x0101){ - DMESG ("EEPROM version too old, assuming defaults"); - DMESG ("If you see this message *plase* send your \ -DMESG output to andreamrl@tiscali.it THANKS"); - priv->digphy=1; - priv->antb=0; - priv->diversity=1; - priv->cs_treshold=0xc; - priv->rcr_csense=1; - priv->rf_chip=RFCHIPID_PHILIPS; - }else{ - if(!priv->card_8185){ - u8 rfparam = eprom_read(dev,RF_PARAM); - DMESG("RfParam: %x",rfparam); + priv->rcr_csense = 3; - priv->digphy = rfparam & (1<antb = rfparam & (1<cs_treshold = (eprom_read(dev, ENERGY_TRESHOLD) & 0xff00) >> 8; - priv->rcr_csense = (rfparam & RF_PARAM_CARRIERSENSE_MASK) >> - RF_PARAM_CARRIERSENSE_SHIFT; - - priv->diversity = - (read_nic_byte(dev,CONFIG2)&(1<rcr_csense = 3; - } - - priv->cs_treshold = (eprom_read(dev,ENERGY_TRESHOLD)&0xff00) >>8; - - priv->rf_chip = 0xff & eprom_read(dev,RFCHIPID); - } + priv->rf_chip = 0xff & eprom_read(dev, RFCHIPID); priv->rf_chip = RF_ZEBRA4; priv->rf_sleep = rtl8225z4_rf_sleep; @@ -3099,19 +3010,6 @@ DMESG output to andreamrl@tiscali.it THA priv->rf_set_chan = rtl8225z2_rf_set_chan; priv->rf_set_sens = NULL; - if(!priv->card_8185){ - if(priv->antb) - DMESG ("Antenna B is default antenna"); - else - DMESG ("Antenna A is default antenna"); - - if(priv->diversity) - DMESG ("Antenna diversity is enabled"); - else - DMESG("Antenna diversity is disabled"); - - DMESG("Carrier sense %d",priv->rcr_csense); - } if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; @@ -3144,17 +3042,6 @@ DMESG output to andreamrl@tiscali.it THA TX_BEACON_RING_ADDR)) return -ENOMEM; - if(!priv->card_8185){ - if(read_nic_byte(dev, CONFIG0) & (1<irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)){ #else @@ -3172,17 +3059,6 @@ DMESG output to andreamrl@tiscali.it THA void rtl8180_no_hw_wep(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); - - if (!priv->card_8185) { - u8 security; - - security = read_nic_byte(dev, SECURITY); - security &=~(1<card_8185){ - anaparam = eprom_read(dev,EPROM_ANAPARAM_ADDRLWORD); - anaparam |= eprom_read(dev,EPROM_ANAPARAM_ADDRHWORD)<<16; - - rtl8180_set_anaparam(dev,anaparam); - } /* These might be unnecessary since we do in rx_enable / tx_enable */ fix_rx_fifo(dev); fix_tx_fifo(dev); @@ -3406,54 +3274,27 @@ void rtl8180_adapter_start(struct net_de CONFIG2, read_nic_byte(dev,CONFIG2) &~\ (1<card_8185) - write_nic_byte(dev, + write_nic_byte(dev, CONFIG2, read_nic_byte(dev,CONFIG2)|(1<<4)); rtl8180_set_mode(dev,EPROM_CMD_NORMAL); write_nic_dword(dev,INT_TIMEOUT,0); - if(!priv->card_8185) - { - /* - experimental - this might be needed to calibrate AGC, - anyway it shouldn't hurt - */ - write_nic_byte(dev, CONFIG5, - read_nic_byte(dev, CONFIG5) | (1<card_8185){ - rtl8185_set_rate(dev); - write_nic_byte(dev, RATE_FALLBACK, 0x81); - }else{ - word = read_nic_word(dev, BRSR); - word &= ~BRSR_MBR; - word &= ~BRSR_BPLCP; - word |= ieeerate2rtlrate(priv->ieee80211->basic_rate); - word |= 0x0f; - write_nic_word(dev, BRSR, word); - } - - if(priv->card_8185){ - write_nic_byte(dev, GP_ENABLE,read_nic_byte(dev, GP_ENABLE) & ~(1<<6)); - - //FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? - rtl8180_set_mode(dev, EPROM_CMD_CONFIG); - write_nic_byte(dev,CONFIG3, read_nic_byte(dev, CONFIG3) - | (1 << CONFIG3_CLKRUN_SHIFT)); - rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - } + rtl8185_set_rate(dev); + write_nic_byte(dev, RATE_FALLBACK, 0x81); + + write_nic_byte(dev, GP_ENABLE, read_nic_byte(dev, GP_ENABLE) & ~(1<<6)); + + /*FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? */ + rtl8180_set_mode(dev, EPROM_CMD_CONFIG); + write_nic_byte(dev, CONFIG3, read_nic_byte(dev, CONFIG3) + | (1 << CONFIG3_CLKRUN_SHIFT)); + rtl8180_set_mode(dev, EPROM_CMD_NORMAL); priv->rf_init(dev); Index: wireless-testing/drivers/staging/rtl8187se/r8180.h =================================================================== --- wireless-testing.orig/drivers/staging/rtl8187se/r8180.h +++ wireless-testing/drivers/staging/rtl8187se/r8180.h @@ -77,21 +77,6 @@ typedef enum _WIRELESS_MODE { WIRELESS_MODE_AUTO = 0x08, } WIRELESS_MODE; -typedef enum _VERSION_8185{ - // RTL8185 - VERSION_8185_UNKNOWN, - VERSION_8185_C, // C-cut - VERSION_8185_D, // D-cut - // RTL8185B - VERSION_8185B_B, // B-cut - VERSION_8185B_D, // D-cut - VERSION_8185B_E, // E-cut - //RTL8187S-PCIE - VERSION_8187S_B, // B-cut - VERSION_8187S_C, // C-cut - VERSION_8187S_D, // D-cut - -}VERSION_8185,*PVERSION_8185; typedef struct ChnlAccessSetting { u16 SIFS_Timer; u16 DIFS_Timer; @@ -341,8 +326,6 @@ typedef struct r8180_priv int irq; struct ieee80211_device *ieee80211; - short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D, 3:rtl8185B */ - short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */ short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ short enable_gpio0; enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; Index: wireless-testing/drivers/staging/rtl8187se/r8185b_init.c =================================================================== --- wireless-testing.orig/drivers/staging/rtl8187se/r8185b_init.c +++ wireless-testing/drivers/staging/rtl8187se/r8185b_init.c @@ -1023,6 +1023,7 @@ ZEBRA_Config_85BASIC_HardCode( u32 addr,data; u32 u4bRegOffset, u4bRegValue, u4bRF23, u4bRF24; u8 u1b24E; + int d_cut = 0; //============================================================================= @@ -1035,8 +1036,10 @@ ZEBRA_Config_85BASIC_HardCode( u4bRF23= RF_ReadReg(dev, 0x08); mdelay(1); u4bRF24= RF_ReadReg(dev, 0x09); mdelay(1); - if (u4bRF23==0x818 && u4bRF24==0x70C && priv->card_8185 == VERSION_8187S_C) - priv->card_8185 = VERSION_8187S_D; + if (u4bRF23 == 0x818 && u4bRF24 == 0x70C) { + d_cut = 1; + printk(KERN_INFO "rtl8187se: card type changed from C- to D-cut\n"); + } // Page0 : reg0-reg15 @@ -1070,18 +1073,9 @@ ZEBRA_Config_85BASIC_HardCode( RF_WriteReg(dev, 0x03, 0x0806); mdelay(1); - if(priv->card_8185 < VERSION_8187S_C) - { - RF_WriteReg(dev, 0x04, 0x03f7); mdelay(1); - RF_WriteReg(dev, 0x05, 0x05ab); mdelay(1); - RF_WriteReg(dev, 0x06, 0x00c1); mdelay(1); - } - else - { - RF_WriteReg(dev, 0x04, 0x03a7); mdelay(1); - RF_WriteReg(dev, 0x05, 0x059b); mdelay(1); - RF_WriteReg(dev, 0x06, 0x0081); mdelay(1); - } + RF_WriteReg(dev, 0x04, 0x03a7); mdelay(1); + RF_WriteReg(dev, 0x05, 0x059b); mdelay(1); + RF_WriteReg(dev, 0x06, 0x0081); mdelay(1); RF_WriteReg(dev, 0x07, 0x01A0); mdelay(1); @@ -1091,14 +1085,11 @@ ZEBRA_Config_85BASIC_HardCode( RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1); RF_WriteReg(dev, 0x0b, 0x0418); mdelay(1); - if(priv->card_8185 == VERSION_8187S_D) - { + if (d_cut) { RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1); RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); RF_WriteReg(dev, 0x0e, 0x0807); mdelay(1); // RX LO buffer - } - else - { + } else { RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1); RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); RF_WriteReg(dev, 0x0e, 0x0806); mdelay(1); // RX LO buffer Index: wireless-testing/drivers/staging/rtl8187se/r8180_rtl8225z2.c =================================================================== --- wireless-testing.orig/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ wireless-testing/drivers/staging/rtl8187se/r8180_rtl8225z2.c @@ -445,30 +445,28 @@ s8 DbmToTxPwrIdx(struct r8180_priv *priv * OFDM Power in dBm = Index * 0.5 + 0 * CCK Power in dBm = Index * 0.25 + 13 */ - if (priv->card_8185 >= VERSION_8187S_B) { - s32 tmp = 0; + s32 tmp = 0; - if (WirelessMode == WIRELESS_MODE_G) { - bUseDefault = false; - tmp = (2 * PowerInDbm); + if (WirelessMode == WIRELESS_MODE_G) { + bUseDefault = false; + tmp = (2 * PowerInDbm); - if (tmp < 0) - TxPwrIdx = 0; - else if (tmp > 40) /* 40 means 20 dBm. */ - TxPwrIdx = 40; - else - TxPwrIdx = (s8)tmp; - } else if (WirelessMode == WIRELESS_MODE_B) { - bUseDefault = false; - tmp = (4 * PowerInDbm) - 52; + if (tmp < 0) + TxPwrIdx = 0; + else if (tmp > 40) /* 40 means 20 dBm. */ + TxPwrIdx = 40; + else + TxPwrIdx = (s8)tmp; + } else if (WirelessMode == WIRELESS_MODE_B) { + bUseDefault = false; + tmp = (4 * PowerInDbm) - 52; - if(tmp < 0) - TxPwrIdx = 0; - else if (tmp > 28) /* 28 means 20 dBm. */ - TxPwrIdx = 28; - else - TxPwrIdx = (s8)tmp; - } + if (tmp < 0) + TxPwrIdx = 0; + else if (tmp > 28) /* 28 means 20 dBm. */ + TxPwrIdx = 28; + else + TxPwrIdx = (s8)tmp; } /* Index: wireless-testing/drivers/staging/rtl8187se/r8180_dm.c =================================================================== --- wireless-testing.orig/drivers/staging/rtl8187se/r8180_dm.c +++ wireless-testing/drivers/staging/rtl8187se/r8180_dm.c @@ -197,7 +197,6 @@ DIG_Zebra( { // Advised from SD3 DZ priv->InitialGain = 4; // In 87B, m74dBm means State 4 (m82dBm) } - //if(pHalData->VersionID != VERSION_8187B_B) { // Advised from SD3 DZ OfdmFA1 = 0x20; }