aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLarry Finger <Larry.Finger@lwfinger.net>2009-11-09 11:53:20 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 15:23:20 -0500
commitd44eb889ccf80e417794963e57cc40bd1519e554 (patch)
tree3f5dc7beb1dd9fd06e61a7c35ae289174a128f95
parentbbc9a9916bc1cd997f3bf303e7930d5f3c804d37 (diff)
Staging: rtl8187se: Remove card8185 variable to simplify flow
When this code is used for the rtl8187se, the value of card_8185 in struct r8180_priv is always 7 or 8. As a result, the program flow can be simplified. Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Tested-by: Bernhard Schiffner <bernhard@schiffner-limbach.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/rtl8187se/r8180.h17
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c239
-rw-r--r--drivers/staging/rtl8187se/r8180_dm.c1
-rw-r--r--drivers/staging/rtl8187se/r8180_rtl8225z2.c46
-rw-r--r--drivers/staging/rtl8187se/r8185b_init.c29
5 files changed, 73 insertions, 259 deletions
diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h
index 1fd953036399..8b33fe006253 100644
--- a/drivers/staging/rtl8187se/r8180.h
+++ b/drivers/staging/rtl8187se/r8180.h
@@ -77,21 +77,6 @@ typedef enum _WIRELESS_MODE {
77 WIRELESS_MODE_AUTO = 0x08, 77 WIRELESS_MODE_AUTO = 0x08,
78} WIRELESS_MODE; 78} WIRELESS_MODE;
79 79
80typedef enum _VERSION_8185{
81 // RTL8185
82 VERSION_8185_UNKNOWN,
83 VERSION_8185_C, // C-cut
84 VERSION_8185_D, // D-cut
85 // RTL8185B
86 VERSION_8185B_B, // B-cut
87 VERSION_8185B_D, // D-cut
88 VERSION_8185B_E, // E-cut
89 //RTL8187S-PCIE
90 VERSION_8187S_B, // B-cut
91 VERSION_8187S_C, // C-cut
92 VERSION_8187S_D, // D-cut
93
94}VERSION_8185,*PVERSION_8185;
95typedef struct ChnlAccessSetting { 80typedef struct ChnlAccessSetting {
96 u16 SIFS_Timer; 81 u16 SIFS_Timer;
97 u16 DIFS_Timer; 82 u16 DIFS_Timer;
@@ -341,8 +326,6 @@ typedef struct r8180_priv
341 int irq; 326 int irq;
342 struct ieee80211_device *ieee80211; 327 struct ieee80211_device *ieee80211;
343 328
344 short card_8185; /* O: rtl8180, 1:rtl8185 V B/C, 2:rtl8185 V D, 3:rtl8185B */
345 short card_8185_Bversion; /* if TCR reports card V B/C this discriminates */
346 short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */ 329 short phy_ver; /* meaningful for rtl8225 1:A 2:B 3:C */
347 short enable_gpio0; 330 short enable_gpio0;
348 enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type; 331 enum card_type {PCI,MINIPCI,CARDBUS,USB/*rtl8187*/}card_type;
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index dfe5ed90739a..585cf683a044 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -886,8 +886,6 @@ void rtl8180_rx_enable(struct net_device *dev)
886 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT); 886 rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT);
887 }else{ 887 }else{
888 rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT); 888 rxconf = rxconf | (1<<ACCEPT_NICMAC_FRAME_SHIFT);
889 if(priv->card_8185 == 0)
890 rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT);
891 } 889 }
892 890
893 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){ 891 if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){
@@ -910,9 +908,6 @@ void rtl8180_rx_enable(struct net_device *dev)
910 908
911 rxconf = rxconf &~ RCR_CS_MASK; 909 rxconf = rxconf &~ RCR_CS_MASK;
912 910
913 if (!priv->card_8185)
914 rxconf |= (priv->rcr_csense<<RCR_CS_SHIFT);
915
916 write_nic_dword(dev, RX_CONF, rxconf); 911 write_nic_dword(dev, RX_CONF, rxconf);
917 912
918 fix_rx_fifo(dev); 913 fix_rx_fifo(dev);
@@ -964,28 +959,19 @@ void rtl8180_tx_enable(struct net_device *dev)
964 959
965 txconf = read_nic_dword(dev, TX_CONF); 960 txconf = read_nic_dword(dev, TX_CONF);
966 961
967 if (priv->card_8185) { 962 byte = read_nic_byte(dev, CW_CONF);
968 byte = read_nic_byte(dev,CW_CONF); 963 byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT);
969 byte &= ~(1<<CW_CONF_PERPACKET_CW_SHIFT); 964 byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT);
970 byte &= ~(1<<CW_CONF_PERPACKET_RETRY_SHIFT); 965 write_nic_byte(dev, CW_CONF, byte);
971 write_nic_byte(dev, CW_CONF, byte);
972
973 tx_agc_ctl = read_nic_byte(dev, TX_AGC_CTL);
974 tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
975 tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
976 tx_agc_ctl |=(1<<TX_AGC_CTL_FEEDBACK_ANT);
977 write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl);
978 write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */
979 }
980 966
981 if (priv->card_8185) 967 tx_agc_ctl = read_nic_byte(dev, TX_AGC_CTL);
982 txconf = txconf &~ (1<<TCR_PROBE_NOTIMESTAMP_SHIFT); 968 tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_GAIN_SHIFT);
983 else { 969 tx_agc_ctl &= ~(1<<TX_AGC_CTL_PERPACKET_ANTSEL_SHIFT);
984 if(hwseqnum) 970 tx_agc_ctl |= (1<<TX_AGC_CTL_FEEDBACK_ANT);
985 txconf= txconf &~ (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT); 971 write_nic_byte(dev, TX_AGC_CTL, tx_agc_ctl);
986 else 972 write_nic_byte(dev, 0xec, 0x3f); /* Disable early TX */
987 txconf= txconf | (1<<TX_CONF_HEADER_AUTOICREMENT_SHIFT); 973
988 } 974 txconf = txconf & ~(1<<TCR_PROBE_NOTIMESTAMP_SHIFT);
989 975
990 txconf = txconf &~ TX_LOOPBACK_MASK; 976 txconf = txconf &~ TX_LOOPBACK_MASK;
991 txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT); 977 txconf = txconf | (TX_LOOPBACK_NONE <<TX_LOOPBACK_SHIFT);
@@ -995,13 +981,10 @@ void rtl8180_tx_enable(struct net_device *dev)
995 txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT); 981 txconf = txconf | (priv->retry_rts<<TX_RTSRETRY_SHIFT);
996 txconf = txconf &~ (1<<TX_NOCRC_SHIFT); 982 txconf = txconf &~ (1<<TX_NOCRC_SHIFT);
997 983
998 if (priv->card_8185) { 984 if (priv->hw_plcp_len)
999 if (priv->hw_plcp_len) 985 txconf = txconf & ~TCR_PLCP_LEN;
1000 txconf = txconf &~ TCR_PLCP_LEN; 986 else
1001 else 987 txconf = txconf | TCR_PLCP_LEN;
1002 txconf = txconf | TCR_PLCP_LEN;
1003 } else
1004 txconf = txconf &~ TCR_SAT;
1005 988
1006 txconf = txconf &~ TCR_MXDMA_MASK; 989 txconf = txconf &~ TCR_MXDMA_MASK;
1007 txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT); 990 txconf = txconf | (TCR_MXDMA_2048<<TCR_MXDMA_SHIFT);
@@ -1720,8 +1703,6 @@ void rtl8180_rx(struct net_device *dev)
1720 else 1703 else
1721 quality = 127 - quality; 1704 quality = 127 - quality;
1722 priv->SignalQuality = quality; 1705 priv->SignalQuality = quality;
1723 if(!priv->card_8185)
1724 printk("check your card type\n");
1725 1706
1726 stats.signal = (u8)quality;//priv->wstats.qual.level = priv->SignalStrength; 1707 stats.signal = (u8)quality;//priv->wstats.qual.level = priv->SignalStrength;
1727 stats.signalstrength = RXAGC; 1708 stats.signalstrength = RXAGC;
@@ -2221,10 +2202,8 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
2221 *(tail+6) = 0; 2202 *(tail+6) = 0;
2222 *(tail+7) = 0; 2203 *(tail+7) = 0;
2223 2204
2224 if(priv->card_8185){ 2205 /*FIXME: this should be triggered by HW encryption parameters.*/
2225 //FIXME: this should be triggered by HW encryption parameters. 2206 *tail |= (1<<15); /* no encrypt */
2226 *tail |= (1<<15); //no encrypt
2227 }
2228 2207
2229 if(remain==len && !descfrag) { 2208 if(remain==len && !descfrag) {
2230 ownbit_flag = false; //added by david woo,2007.12.14 2209 ownbit_flag = false; //added by david woo,2007.12.14
@@ -2266,7 +2245,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority,
2266 2245
2267 /* hw_plcp_len is not used for rtl8180 chip */ 2246 /* hw_plcp_len is not used for rtl8180 chip */
2268 /* FIXME */ 2247 /* FIXME */
2269 if(priv->card_8185 == 0 || !priv->hw_plcp_len){ 2248 if (!priv->hw_plcp_len) {
2270 duration = rtl8180_len2duration(len, rate, &ext); 2249 duration = rtl8180_len2duration(len, rate, &ext);
2271 *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16); 2250 *(tail+1) = *(tail+1) | ((duration & 0x7fff)<<16);
2272 if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension 2251 if(ext) *(tail+1) = *(tail+1) |(1<<31); //plcp length extension
@@ -2355,8 +2334,7 @@ void rtl8180_link_change(struct net_device *dev)
2355 2334
2356 rtl8180_set_mode(dev, EPROM_CMD_NORMAL); 2335 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
2357 2336
2358 if(priv->card_8185) 2337 rtl8180_set_chan(dev, priv->chan);
2359 rtl8180_set_chan(dev, priv->chan);
2360} 2338}
2361 2339
2362void rtl8180_rq_tx_ack(struct net_device *dev){ 2340void rtl8180_rq_tx_ack(struct net_device *dev){
@@ -2702,8 +2680,6 @@ short rtl8180_init(struct net_device *dev)
2702 struct r8180_priv *priv = ieee80211_priv(dev); 2680 struct r8180_priv *priv = ieee80211_priv(dev);
2703 u16 word; 2681 u16 word;
2704 u16 version; 2682 u16 version;
2705 u8 hw_version;
2706 //u8 config3;
2707 u32 usValue; 2683 u32 usValue;
2708 u16 tmpu16; 2684 u16 tmpu16;
2709 int i, j; 2685 int i, j;
@@ -2928,46 +2904,11 @@ short rtl8180_init(struct net_device *dev)
2928 2904
2929 priv->InitialGain = 6; 2905 priv->InitialGain = 6;
2930 2906
2931 hw_version =( read_nic_dword(dev, TCR) & TCR_HWVERID_MASK)>>TCR_HWVERID_SHIFT; 2907 DMESG("MAC controller is a RTL8187SE b/g");
2908 priv->phy_ver = 2;
2932 2909
2933 switch (hw_version){ 2910 priv->ieee80211->modulation |= IEEE80211_OFDM_MODULATION;
2934 case HW_VERID_R8185B_B: 2911 priv->ieee80211->short_slot = 1;
2935 priv->card_8185 = VERSION_8187S_C;
2936 DMESG("MAC controller is a RTL8187SE b/g");
2937 priv->phy_ver = 2;
2938 break;
2939 case HW_VERID_R8185_ABC:
2940 DMESG("MAC controller is a RTL8185 b/g");
2941 priv->card_8185 = 1;
2942 /* you should not find a card with 8225 PHY ver < C*/
2943 priv->phy_ver = 2;
2944 break;
2945 case HW_VERID_R8185_D:
2946 DMESG("MAC controller is a RTL8185 b/g (V. D)");
2947 priv->card_8185 = 2;
2948 /* you should not find a card with 8225 PHY ver < C*/
2949 priv->phy_ver = 2;
2950 break;
2951 case HW_VERID_R8180_ABCD:
2952 DMESG("MAC controller is a RTL8180");
2953 priv->card_8185 = 0;
2954 break;
2955 case HW_VERID_R8180_F:
2956 DMESG("MAC controller is a RTL8180 (v. F)");
2957 priv->card_8185 = 0;
2958 break;
2959 default:
2960 DMESGW("MAC chip not recognized: version %x. Assuming RTL8180",hw_version);
2961 priv->card_8185 = 0;
2962 break;
2963 }
2964
2965 if(priv->card_8185){
2966 priv->ieee80211->modulation |= IEEE80211_OFDM_MODULATION;
2967 priv->ieee80211->short_slot = 1;
2968 }
2969 /* you should not found any 8185 Ver B Card */
2970 priv->card_8185_Bversion = 0;
2971 2912
2972 // just for sync 85 2913 // just for sync 85
2973 priv->card_type = PCI; 2914 priv->card_type = PCI;
@@ -3026,12 +2967,10 @@ short rtl8180_init(struct net_device *dev)
3026 priv->chtxpwr[i]=word & 0xff; 2967 priv->chtxpwr[i]=word & 0xff;
3027 priv->chtxpwr[i+1]=(word & 0xff00)>>8; 2968 priv->chtxpwr[i+1]=(word & 0xff00)>>8;
3028 } 2969 }
3029 if(priv->card_8185){ 2970 for (i = 1, j = 0; i < 14; i += 2, j++) {
3030 for(i=1,j=0; i<14; i+=2,j++){ 2971 word = eprom_read(dev, EPROM_TXPW_OFDM_CH1_2 + j);
3031 word = eprom_read(dev,EPROM_TXPW_OFDM_CH1_2 + j); 2972 priv->chtxpwr_ofdm[i] = word & 0xff;
3032 priv->chtxpwr_ofdm[i]=word & 0xff; 2973 priv->chtxpwr_ofdm[i+1] = (word & 0xff00)>>8;
3033 priv->chtxpwr_ofdm[i+1]=(word & 0xff00)>>8;
3034 }
3035 } 2974 }
3036 2975
3037 //3Read crystal calibtration and thermal meter indication on 87SE. 2976 //3Read crystal calibtration and thermal meter indication on 87SE.
@@ -3057,37 +2996,11 @@ short rtl8180_init(struct net_device *dev)
3057 2996
3058 version = eprom_read(dev,EPROM_VERSION); 2997 version = eprom_read(dev,EPROM_VERSION);
3059 DMESG("EEPROM version %x",version); 2998 DMESG("EEPROM version %x",version);
3060 if( (!priv->card_8185) && version < 0x0101){ 2999 priv->rcr_csense = 3;
3061 DMESG ("EEPROM version too old, assuming defaults");
3062 DMESG ("If you see this message *plase* send your \
3063DMESG output to andreamrl@tiscali.it THANKS");
3064 priv->digphy=1;
3065 priv->antb=0;
3066 priv->diversity=1;
3067 priv->cs_treshold=0xc;
3068 priv->rcr_csense=1;
3069 priv->rf_chip=RFCHIPID_PHILIPS;
3070 }else{
3071 if(!priv->card_8185){
3072 u8 rfparam = eprom_read(dev,RF_PARAM);
3073 DMESG("RfParam: %x",rfparam);
3074 3000
3075 priv->digphy = rfparam & (1<<RF_PARAM_DIGPHY_SHIFT) ? 0:1; 3001 priv->cs_treshold = (eprom_read(dev, ENERGY_TRESHOLD) & 0xff00) >> 8;
3076 priv->antb = rfparam & (1<<RF_PARAM_ANTBDEFAULT_SHIFT) ? 1:0;
3077 3002
3078 priv->rcr_csense = (rfparam & RF_PARAM_CARRIERSENSE_MASK) >> 3003 priv->rf_chip = 0xff & eprom_read(dev, RFCHIPID);
3079 RF_PARAM_CARRIERSENSE_SHIFT;
3080
3081 priv->diversity =
3082 (read_nic_byte(dev,CONFIG2)&(1<<CONFIG2_ANTENNA_SHIFT)) ? 1:0;
3083 }else{
3084 priv->rcr_csense = 3;
3085 }
3086
3087 priv->cs_treshold = (eprom_read(dev,ENERGY_TRESHOLD)&0xff00) >>8;
3088
3089 priv->rf_chip = 0xff & eprom_read(dev,RFCHIPID);
3090 }
3091 3004
3092 priv->rf_chip = RF_ZEBRA4; 3005 priv->rf_chip = RF_ZEBRA4;
3093 priv->rf_sleep = rtl8225z4_rf_sleep; 3006 priv->rf_sleep = rtl8225z4_rf_sleep;
@@ -3099,19 +3012,6 @@ DMESG output to andreamrl@tiscali.it THANKS");
3099 priv->rf_set_chan = rtl8225z2_rf_set_chan; 3012 priv->rf_set_chan = rtl8225z2_rf_set_chan;
3100 priv->rf_set_sens = NULL; 3013 priv->rf_set_sens = NULL;
3101 3014
3102 if(!priv->card_8185){
3103 if(priv->antb)
3104 DMESG ("Antenna B is default antenna");
3105 else
3106 DMESG ("Antenna A is default antenna");
3107
3108 if(priv->diversity)
3109 DMESG ("Antenna diversity is enabled");
3110 else
3111 DMESG("Antenna diversity is disabled");
3112
3113 DMESG("Carrier sense %d",priv->rcr_csense);
3114 }
3115 3015
3116 if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) 3016 if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount))
3117 return -ENOMEM; 3017 return -ENOMEM;
@@ -3144,17 +3044,6 @@ DMESG output to andreamrl@tiscali.it THANKS");
3144 TX_BEACON_RING_ADDR)) 3044 TX_BEACON_RING_ADDR))
3145 return -ENOMEM; 3045 return -ENOMEM;
3146 3046
3147 if(!priv->card_8185){
3148 if(read_nic_byte(dev, CONFIG0) & (1<<CONFIG0_WEP40_SHIFT))
3149 DMESG ("40-bit WEP is supported in hardware");
3150 else
3151 DMESG ("40-bit WEP is NOT supported in hardware");
3152
3153 if(read_nic_byte(dev,CONFIG0) & (1<<CONFIG0_WEP104_SHIFT))
3154 DMESG ("104-bit WEP is supported in hardware");
3155 else
3156 DMESG ("104-bit WEP is NOT supported in hardware");
3157 }
3158#if !defined(SA_SHIRQ) 3047#if !defined(SA_SHIRQ)
3159 if(request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)){ 3048 if(request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)){
3160#else 3049#else
@@ -3172,17 +3061,6 @@ DMESG output to andreamrl@tiscali.it THANKS");
3172 3061
3173void rtl8180_no_hw_wep(struct net_device *dev) 3062void rtl8180_no_hw_wep(struct net_device *dev)
3174{ 3063{
3175 struct r8180_priv *priv = ieee80211_priv(dev);
3176
3177 if (!priv->card_8185) {
3178 u8 security;
3179
3180 security = read_nic_byte(dev, SECURITY);
3181 security &=~(1<<SECURITY_WEP_TX_ENABLE_SHIFT);
3182 security &=~(1<<SECURITY_WEP_RX_ENABLE_SHIFT);
3183
3184 write_nic_byte(dev, SECURITY, security);
3185 }
3186} 3064}
3187 3065
3188void rtl8180_set_hw_wep(struct net_device *dev) 3066void rtl8180_set_hw_wep(struct net_device *dev)
@@ -3355,8 +3233,6 @@ void rtl8185_set_rate(struct net_device *dev)
3355void rtl8180_adapter_start(struct net_device *dev) 3233void rtl8180_adapter_start(struct net_device *dev)
3356{ 3234{
3357 struct r8180_priv *priv = ieee80211_priv(dev); 3235 struct r8180_priv *priv = ieee80211_priv(dev);
3358 u32 anaparam;
3359 u16 word;
3360 u8 config3; 3236 u8 config3;
3361 3237
3362 rtl8180_rtx_disable(dev); 3238 rtl8180_rtx_disable(dev);
@@ -3384,12 +3260,6 @@ void rtl8180_adapter_start(struct net_device *dev)
3384 3260
3385 rtl8180_update_msr(dev); 3261 rtl8180_update_msr(dev);
3386 3262
3387 if(!priv->card_8185){
3388 anaparam = eprom_read(dev,EPROM_ANAPARAM_ADDRLWORD);
3389 anaparam |= eprom_read(dev,EPROM_ANAPARAM_ADDRHWORD)<<16;
3390
3391 rtl8180_set_anaparam(dev,anaparam);
3392 }
3393 /* These might be unnecessary since we do in rx_enable / tx_enable */ 3263 /* These might be unnecessary since we do in rx_enable / tx_enable */
3394 fix_rx_fifo(dev); 3264 fix_rx_fifo(dev);
3395 fix_tx_fifo(dev); 3265 fix_tx_fifo(dev);
@@ -3406,54 +3276,27 @@ void rtl8180_adapter_start(struct net_device *dev)
3406 CONFIG2, read_nic_byte(dev,CONFIG2) &~\ 3276 CONFIG2, read_nic_byte(dev,CONFIG2) &~\
3407 (1<<CONFIG2_DMA_POLLING_MODE_SHIFT)); 3277 (1<<CONFIG2_DMA_POLLING_MODE_SHIFT));
3408 //^the nic isn't in test mode 3278 //^the nic isn't in test mode
3409 if(priv->card_8185) 3279 write_nic_byte(dev,
3410 write_nic_byte(dev,
3411 CONFIG2, read_nic_byte(dev,CONFIG2)|(1<<4)); 3280 CONFIG2, read_nic_byte(dev,CONFIG2)|(1<<4));
3412 3281
3413 rtl8180_set_mode(dev,EPROM_CMD_NORMAL); 3282 rtl8180_set_mode(dev,EPROM_CMD_NORMAL);
3414 3283
3415 write_nic_dword(dev,INT_TIMEOUT,0); 3284 write_nic_dword(dev,INT_TIMEOUT,0);
3416 3285
3417 if(!priv->card_8185) 3286 write_nic_byte(dev, WPA_CONFIG, 0);
3418 {
3419 /*
3420 experimental - this might be needed to calibrate AGC,
3421 anyway it shouldn't hurt
3422 */
3423 write_nic_byte(dev, CONFIG5,
3424 read_nic_byte(dev, CONFIG5) | (1<<AGCRESET_SHIFT));
3425 read_nic_byte(dev, CONFIG5);
3426 udelay(15);
3427 write_nic_byte(dev, CONFIG5,
3428 read_nic_byte(dev, CONFIG5) &~ (1<<AGCRESET_SHIFT));
3429 }else{
3430 write_nic_byte(dev, WPA_CONFIG, 0);
3431 //write_nic_byte(dev, TESTR, 0xd);
3432 }
3433 3287
3434 rtl8180_no_hw_wep(dev); 3288 rtl8180_no_hw_wep(dev);
3435 3289
3436 if(priv->card_8185){ 3290 rtl8185_set_rate(dev);
3437 rtl8185_set_rate(dev); 3291 write_nic_byte(dev, RATE_FALLBACK, 0x81);
3438 write_nic_byte(dev, RATE_FALLBACK, 0x81);
3439 }else{
3440 word = read_nic_word(dev, BRSR);
3441 word &= ~BRSR_MBR;
3442 word &= ~BRSR_BPLCP;
3443 word |= ieeerate2rtlrate(priv->ieee80211->basic_rate);
3444 word |= 0x0f;
3445 write_nic_word(dev, BRSR, word);
3446 }
3447 3292
3448 if(priv->card_8185){ 3293 write_nic_byte(dev, GP_ENABLE, read_nic_byte(dev, GP_ENABLE) & ~(1<<6));
3449 write_nic_byte(dev, GP_ENABLE,read_nic_byte(dev, GP_ENABLE) & ~(1<<6));
3450 3294
3451 //FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? 3295 /*FIXME cfg 3 ClkRun enable - isn't it ReadOnly ? */
3452 rtl8180_set_mode(dev, EPROM_CMD_CONFIG); 3296 rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
3453 write_nic_byte(dev,CONFIG3, read_nic_byte(dev, CONFIG3) 3297 write_nic_byte(dev, CONFIG3, read_nic_byte(dev, CONFIG3)
3454 | (1 << CONFIG3_CLKRUN_SHIFT)); 3298 | (1 << CONFIG3_CLKRUN_SHIFT));
3455 rtl8180_set_mode(dev, EPROM_CMD_NORMAL); 3299 rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
3456 }
3457 3300
3458 priv->rf_init(dev); 3301 priv->rf_init(dev);
3459 3302
diff --git a/drivers/staging/rtl8187se/r8180_dm.c b/drivers/staging/rtl8187se/r8180_dm.c
index e0c1606677d4..cbca58db85e1 100644
--- a/drivers/staging/rtl8187se/r8180_dm.c
+++ b/drivers/staging/rtl8187se/r8180_dm.c
@@ -197,7 +197,6 @@ DIG_Zebra(
197 { // Advised from SD3 DZ 197 { // Advised from SD3 DZ
198 priv->InitialGain = 4; // In 87B, m74dBm means State 4 (m82dBm) 198 priv->InitialGain = 4; // In 87B, m74dBm means State 4 (m82dBm)
199 } 199 }
200 //if(pHalData->VersionID != VERSION_8187B_B)
201 { // Advised from SD3 DZ 200 { // Advised from SD3 DZ
202 OfdmFA1 = 0x20; 201 OfdmFA1 = 0x20;
203 } 202 }
diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
index 60ee3bcb63ab..830a571be540 100644
--- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c
+++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c
@@ -445,30 +445,28 @@ s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode,
445 * OFDM Power in dBm = Index * 0.5 + 0 445 * OFDM Power in dBm = Index * 0.5 + 0
446 * CCK Power in dBm = Index * 0.25 + 13 446 * CCK Power in dBm = Index * 0.25 + 13
447 */ 447 */
448 if (priv->card_8185 >= VERSION_8187S_B) { 448 s32 tmp = 0;
449 s32 tmp = 0; 449
450 450 if (WirelessMode == WIRELESS_MODE_G) {
451 if (WirelessMode == WIRELESS_MODE_G) { 451 bUseDefault = false;
452 bUseDefault = false; 452 tmp = (2 * PowerInDbm);
453 tmp = (2 * PowerInDbm); 453
454 454 if (tmp < 0)
455 if (tmp < 0) 455 TxPwrIdx = 0;
456 TxPwrIdx = 0; 456 else if (tmp > 40) /* 40 means 20 dBm. */
457 else if (tmp > 40) /* 40 means 20 dBm. */ 457 TxPwrIdx = 40;
458 TxPwrIdx = 40; 458 else
459 else 459 TxPwrIdx = (s8)tmp;
460 TxPwrIdx = (s8)tmp; 460 } else if (WirelessMode == WIRELESS_MODE_B) {
461 } else if (WirelessMode == WIRELESS_MODE_B) { 461 bUseDefault = false;
462 bUseDefault = false; 462 tmp = (4 * PowerInDbm) - 52;
463 tmp = (4 * PowerInDbm) - 52; 463
464 464 if (tmp < 0)
465 if(tmp < 0) 465 TxPwrIdx = 0;
466 TxPwrIdx = 0; 466 else if (tmp > 28) /* 28 means 20 dBm. */
467 else if (tmp > 28) /* 28 means 20 dBm. */ 467 TxPwrIdx = 28;
468 TxPwrIdx = 28; 468 else
469 else 469 TxPwrIdx = (s8)tmp;
470 TxPwrIdx = (s8)tmp;
471 }
472 } 470 }
473 471
474 /* 472 /*
diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c
index bdb66d83778c..50309f2da9c1 100644
--- a/drivers/staging/rtl8187se/r8185b_init.c
+++ b/drivers/staging/rtl8187se/r8185b_init.c
@@ -1023,6 +1023,7 @@ ZEBRA_Config_85BASIC_HardCode(
1023 u32 addr,data; 1023 u32 addr,data;
1024 u32 u4bRegOffset, u4bRegValue, u4bRF23, u4bRF24; 1024 u32 u4bRegOffset, u4bRegValue, u4bRF23, u4bRF24;
1025 u8 u1b24E; 1025 u8 u1b24E;
1026 int d_cut = 0;
1026 1027
1027 1028
1028 //============================================================================= 1029 //=============================================================================
@@ -1035,8 +1036,10 @@ ZEBRA_Config_85BASIC_HardCode(
1035 u4bRF23= RF_ReadReg(dev, 0x08); mdelay(1); 1036 u4bRF23= RF_ReadReg(dev, 0x08); mdelay(1);
1036 u4bRF24= RF_ReadReg(dev, 0x09); mdelay(1); 1037 u4bRF24= RF_ReadReg(dev, 0x09); mdelay(1);
1037 1038
1038 if (u4bRF23==0x818 && u4bRF24==0x70C && priv->card_8185 == VERSION_8187S_C) 1039 if (u4bRF23 == 0x818 && u4bRF24 == 0x70C) {
1039 priv->card_8185 = VERSION_8187S_D; 1040 d_cut = 1;
1041 printk(KERN_INFO "rtl8187se: card type changed from C- to D-cut\n");
1042 }
1040 1043
1041 // Page0 : reg0-reg15 1044 // Page0 : reg0-reg15
1042 1045
@@ -1070,18 +1073,9 @@ ZEBRA_Config_85BASIC_HardCode(
1070 1073
1071 RF_WriteReg(dev, 0x03, 0x0806); mdelay(1); 1074 RF_WriteReg(dev, 0x03, 0x0806); mdelay(1);
1072 1075
1073 if(priv->card_8185 < VERSION_8187S_C) 1076 RF_WriteReg(dev, 0x04, 0x03a7); mdelay(1);
1074 { 1077 RF_WriteReg(dev, 0x05, 0x059b); mdelay(1);
1075 RF_WriteReg(dev, 0x04, 0x03f7); mdelay(1); 1078 RF_WriteReg(dev, 0x06, 0x0081); mdelay(1);
1076 RF_WriteReg(dev, 0x05, 0x05ab); mdelay(1);
1077 RF_WriteReg(dev, 0x06, 0x00c1); mdelay(1);
1078 }
1079 else
1080 {
1081 RF_WriteReg(dev, 0x04, 0x03a7); mdelay(1);
1082 RF_WriteReg(dev, 0x05, 0x059b); mdelay(1);
1083 RF_WriteReg(dev, 0x06, 0x0081); mdelay(1);
1084 }
1085 1079
1086 1080
1087 RF_WriteReg(dev, 0x07, 0x01A0); mdelay(1); 1081 RF_WriteReg(dev, 0x07, 0x01A0); mdelay(1);
@@ -1091,14 +1085,11 @@ ZEBRA_Config_85BASIC_HardCode(
1091 RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1); 1085 RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1);
1092 RF_WriteReg(dev, 0x0b, 0x0418); mdelay(1); 1086 RF_WriteReg(dev, 0x0b, 0x0418); mdelay(1);
1093 1087
1094 if(priv->card_8185 == VERSION_8187S_D) 1088 if (d_cut) {
1095 {
1096 RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1); 1089 RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1);
1097 RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); 1090 RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1);
1098 RF_WriteReg(dev, 0x0e, 0x0807); mdelay(1); // RX LO buffer 1091 RF_WriteReg(dev, 0x0e, 0x0807); mdelay(1); // RX LO buffer
1099 } 1092 } else {
1100 else
1101 {
1102 RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1); 1093 RF_WriteReg(dev, 0x0c, 0x0fbe); mdelay(1);
1103 RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); 1094 RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1);
1104 RF_WriteReg(dev, 0x0e, 0x0806); mdelay(1); // RX LO buffer 1095 RF_WriteReg(dev, 0x0e, 0x0806); mdelay(1); // RX LO buffer