diff options
Diffstat (limited to 'drivers/staging/rtl8187se')
18 files changed, 423 insertions, 1645 deletions
diff --git a/drivers/staging/rtl8187se/Kconfig b/drivers/staging/rtl8187se/Kconfig index e24a6f7..155a78e 100644 --- a/drivers/staging/rtl8187se/Kconfig +++ b/drivers/staging/rtl8187se/Kconfig @@ -3,6 +3,7 @@ config R8187SE depends on PCI && WLAN select WIRELESS_EXT select WEXT_PRIV + select EEPROM_93CX6 default N ---help--- If built as a module, it will be called r8187se.ko. diff --git a/drivers/staging/rtl8187se/Makefile b/drivers/staging/rtl8187se/Makefile index b395acf..e6adf91 100644 --- a/drivers/staging/rtl8187se/Makefile +++ b/drivers/staging/rtl8187se/Makefile @@ -18,7 +18,6 @@ EXTRA_CFLAGS += -DENABLE_LPS r8187se-objs := \ r8180_core.o \ - r8180_93cx6.o \ r8180_wx.o \ r8180_rtl8225z2.o \ r8185b_init.o \ diff --git a/drivers/staging/rtl8187se/TODO b/drivers/staging/rtl8187se/TODO index a762e79..704949a 100644 --- a/drivers/staging/rtl8187se/TODO +++ b/drivers/staging/rtl8187se/TODO @@ -5,7 +5,6 @@ TODO: - switch to use shared "librtl" instead of private ieee80211 stack - switch to use LIB80211 - switch to use MAC80211 -- switch to use EEPROM_93CX6 - use kernel coding style - checkpatch.pl fixes - sparse fixes diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h index 9086047..4cd95c3 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h @@ -29,6 +29,7 @@ #include <linux/jiffies.h> #include <linux/timer.h> #include <linux/sched.h> +#include <linux/semaphore.h> #include <linux/wireless.h> #include <linux/ieee80211.h> @@ -161,10 +162,6 @@ do { if (ieee80211_debug_level & (level)) \ #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) #endif /* CONFIG_IEEE80211_DEBUG */ -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -#define MAC_ARG(x) ((u8 *)(x))[0], ((u8 *)(x))[1], ((u8 *)(x))[2], \ - ((u8 *)(x))[3], ((u8 *)(x))[4], ((u8 *)(x))[5] - /* * To use the debug system; * diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c index 172e8f3..40f1b99 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c @@ -285,7 +285,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPFormatErrors++; return -2; @@ -298,9 +298,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!key->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT + printk(KERN_DEBUG "CCMP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -315,11 +315,9 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: replay detected: STA=" MAC_FMT - " previous PN %02x%02x%02x%02x%02x%02x " - "received PN %02x%02x%02x%02x%02x%02x\n", - MAC_ARG(hdr->addr2), MAC_ARG(key->rx_pn), - MAC_ARG(pn)); + printk(KERN_DEBUG "CCMP: replay detected: STA=%pM" + " previous PN %pm received PN %pm\n", + hdr->addr2, key->rx_pn, pn); } key->dot11RSNAStatsCCMPReplays++; return -4; @@ -347,7 +345,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { if (net_ratelimit()) { printk(KERN_DEBUG "CCMP: decrypt failed: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + "%pM\n", hdr->addr2); } key->dot11RSNAStatsCCMPDecryptErrors++; return -5; @@ -423,11 +421,10 @@ static char * ieee80211_ccmp_print_stats(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; p += sprintf(p, "key[%d] alg=CCMP key_set=%d " - "tx_pn=%02x%02x%02x%02x%02x%02x " - "rx_pn=%02x%02x%02x%02x%02x%02x " + "tx_pn=%pm rx_pn=%pm " "format_errors=%d replays=%d decrypt_errors=%d\n", ccmp->key_idx, ccmp->key_set, - MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn), + ccmp->tx_pn, ccmp->rx_pn, ccmp->dot11RSNAStatsCCMPFormatErrors, ccmp->dot11RSNAStatsCCMPReplays, ccmp->dot11RSNAStatsCCMPDecryptErrors); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c index e6d8385..a525411 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c @@ -385,7 +385,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: received packet without ExtIV" - " flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2)); + " flag from %pM\n", hdr->addr2); } return -2; } @@ -397,9 +397,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (!tkey->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT + printk(KERN_DEBUG "TKIP: received packet from %pM" " with keyid=%d that does not have a configured" - " key\n", MAC_ARG(hdr->addr2), keyidx); + " key\n", hdr->addr2, keyidx); } return -3; } @@ -410,9 +410,9 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (iv32 < tkey->rx_iv32 || (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) { if (net_ratelimit()) { - printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT + printk(KERN_DEBUG "TKIP: replay detected: STA=%pM" " previous TSC %08x%04x received TSC " - "%08x%04x\n", MAC_ARG(hdr->addr2), + "%08x%04x\n", hdr->addr2, tkey->rx_iv32, tkey->rx_iv16, iv32, iv16); } tkey->dot11RSNAStatsTKIPReplays++; @@ -431,8 +431,8 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) { if (net_ratelimit()) { printk(KERN_DEBUG ": TKIP: failed to decrypt " - "received packet from " MAC_FMT "\n", - MAC_ARG(hdr->addr2)); + "received packet from %pM\n", + hdr->addr2); } return -7; } @@ -450,7 +450,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } if (net_ratelimit()) { printk(KERN_DEBUG "TKIP: ICV error detected: STA=" - MAC_FMT "\n", MAC_ARG(hdr->addr2)); + "%pM\n", hdr->addr2); } tkey->dot11RSNAStatsTKIPICVErrors++; return -5; @@ -604,8 +604,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, struct ieee80211_hdr_4addr *hdr; hdr = (struct ieee80211_hdr_4addr *)skb->data; printk(KERN_DEBUG "%s: Michael MIC verification failed for " - "MSDU from " MAC_FMT " keyidx=%d\n", - skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2), + "MSDU from %pM keyidx=%d\n", + skb->dev ? skb->dev->name : "N/A", hdr->addr2, keyidx); if (skb->dev) ieee80211_michael_mic_failure(skb->dev, hdr, keyidx); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c index 9128c18..2b7080c 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c @@ -311,8 +311,8 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, strcmp(crypt->ops->name, "TKIP") == 0) { if (net_ratelimit()) { printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " - "received packet from " MAC_FMT "\n", - ieee->dev->name, MAC_ARG(hdr->addr2)); + "received packet from %pM\n", + ieee->dev->name, hdr->addr2); } return -1; } @@ -323,8 +323,8 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb, atomic_dec(&crypt->refcnt); if (res < 0) { IEEE80211_DEBUG_DROP( - "decryption failed (SA=" MAC_FMT - ") res=%d\n", MAC_ARG(hdr->addr2), res); + "decryption failed (SA=%pM" + ") res=%d\n", hdr->addr2, res); if (res == -2) IEEE80211_DEBUG_DROP("Decryption failed ICV " "mismatch (key %d)\n", @@ -356,8 +356,8 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *s atomic_dec(&crypt->refcnt); if (res < 0) { printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed" - " (SA=" MAC_FMT " keyidx=%d)\n", - ieee->dev->name, MAC_ARG(hdr->addr2), keyidx); + " (SA=%pM keyidx=%d)\n", + ieee->dev->name, hdr->addr2, keyidx); return -1; } @@ -550,8 +550,8 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb, * frames silently instead of filling system log with * these reports. */ IEEE80211_DEBUG_DROP("Decryption failed (not set)" - " (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + " (SA=%pM)\n", + hdr->addr2); ieee->ieee_stats.rx_discards_undecryptable++; goto rx_dropped; } @@ -709,8 +709,8 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } else { IEEE80211_DEBUG_DROP( "encryption configured, but RX " - "frame not encrypted (SA=" MAC_FMT ")\n", - MAC_ARG(hdr->addr2)); + "frame not encrypted (SA=%pM)\n", + hdr->addr2); goto rx_dropped; } } @@ -729,9 +729,9 @@ int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb, !ieee80211_is_eapol_frame(ieee, skb, hdrlen)) { IEEE80211_DEBUG_DROP( "dropped unencrypted RX data " - "frame from " MAC_FMT + "frame from %pM" " (drop_unencrypted=1)\n", - MAC_ARG(hdr->addr2)); + hdr->addr2); goto rx_dropped; } /* @@ -1196,11 +1196,11 @@ inline int ieee80211_network_init( } if (network->mode == 0) { - IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' " + IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' " "network.\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid)); + network->bssid); return 1; } @@ -1341,9 +1341,9 @@ inline void ieee80211_process_probe_response( memset(&network, 0, sizeof(struct ieee80211_network)); IEEE80211_DEBUG_SCAN( - "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", + "'%s' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, (beacon->capability & (1<<0xf)) ? '1' : '0', (beacon->capability & (1<<0xe)) ? '1' : '0', (beacon->capability & (1<<0xd)) ? '1' : '0', @@ -1362,10 +1362,10 @@ inline void ieee80211_process_probe_response( (beacon->capability & (1<<0x0)) ? '1' : '0'); if (ieee80211_network_init(ieee, beacon, &network, stats)) { - IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n", + IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n", escape_essid(info_element->data, info_element->len), - MAC_ARG(beacon->header.addr3), + beacon->header.addr3, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -1464,11 +1464,11 @@ inline void ieee80211_process_probe_response( /* If there are no more slots, expire the oldest */ list_del(&oldest->list); target = oldest; - IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from " + IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from " "network list.\n", escape_essid(target->ssid, target->ssid_len), - MAC_ARG(target->bssid)); + target->bssid); } else { /* Otherwise just pull from the free list */ target = list_entry(ieee->network_free_list.next, @@ -1478,10 +1478,10 @@ inline void ieee80211_process_probe_response( #ifdef CONFIG_IEEE80211_DEBUG - IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n", + IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n", escape_essid(network.ssid, network.ssid_len), - MAC_ARG(network.bssid), + network.bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); @@ -1492,10 +1492,10 @@ inline void ieee80211_process_probe_response( if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) ieee80211_softmac_new_net(ieee,&network); } else { - IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n", + IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n", escape_essid(target->ssid, target->ssid_len), - MAC_ARG(target->bssid), + target->bssid, WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP ? "PROBE RESPONSE" : "BEACON"); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c index a215067..c2f472e 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c @@ -1573,7 +1573,7 @@ ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) ieee80211_resp_to_assoc_rq(ieee, dest); } - printk(KERN_INFO"New client associated: "MAC_FMT"\n", MAC_ARG(dest)); + printk(KERN_INFO"New client associated: %pM\n", dest); } diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c index f1d6cb4..ad42bcd 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c @@ -482,8 +482,7 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee, (!ieee->enter_sleep_state) || (!ieee->ps_is_queue_empty)){ - printk("ERROR. PS mode is tryied to be use but\ -driver missed a callback\n\n"); + printk("ERROR. PS mode tried to be use but driver missed a callback\n\n"); return -1; } diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c index 69bd021..6cb31e1 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_tx.c @@ -198,8 +198,8 @@ int ieee80211_encrypt_fragment( header = (struct ieee80211_hdr_4addr *)frag->data; if (net_ratelimit()) { printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " - "TX packet to " MAC_FMT "\n", - ieee->dev->name, MAC_ARG(header->addr1)); + "TX packet to %pM\n", + ieee->dev->name, header->addr1); } return -1; } @@ -407,7 +407,7 @@ int ieee80211_rtl_xmit(struct sk_buff *skb, memcpy(&header.addr2, src, ETH_ALEN); memcpy(&header.addr3, ieee->current_network.bssid, ETH_ALEN); } - // printk(KERN_WARNING "essid MAC address is "MAC_FMT, MAC_ARG(&header.addr1)); + // printk(KERN_WARNING "essid MAC address is %pM", &header.addr1); header.frame_ctl = cpu_to_le16(fc); //hdr_len = IEEE80211_3ADDR_LEN; diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c index 6aad48f..bd5e77b 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c @@ -234,10 +234,10 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, else IEEE80211_DEBUG_SCAN( "Not showing network '%s (" - MAC_FMT ")' due to age (%lums).\n", + "%pM)' due to age (%lums).\n", escape_essid(network->ssid, network->ssid_len), - MAC_ARG(network->bssid), + network->bssid, (jiffies - network->last_scanned) / (HZ / 100)); } } @@ -694,7 +694,7 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, #if 1 case IW_AUTH_WPA_ENABLED: ieee->wpa_enabled = (data->value)?1:0; - //printk("enalbe wpa:%d\n", ieee->wpa_enabled); + //printk("enable wpa:%d\n", ieee->wpa_enabled); break; #endif diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h index ce82888..d15bdf6 100644 --- a/drivers/staging/rtl8187se/r8180.h +++ b/drivers/staging/rtl8187se/r8180.h @@ -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 diff --git a/drivers/staging/rtl8187se/r8180_93cx6.c b/drivers/staging/rtl8187se/r8180_93cx6.c deleted file mode 100644 index 7e4711f..0000000 --- a/drivers/staging/rtl8187se/r8180_93cx6.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - This files contains card eeprom (93c46 or 93c56) programming routines, - memory is addressed by 16 bits words. - - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#include "r8180_93cx6.h" - -void eprom_cs(struct net_device *dev, short bit) -{ - if(bit) - write_nic_byte(dev, EPROM_CMD, - (1<<EPROM_CS_SHIFT) | \ - read_nic_byte(dev, EPROM_CMD)); //enable EPROM - else - write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev, EPROM_CMD)\ - &~(1<<EPROM_CS_SHIFT)); //disable EPROM - - force_pci_posting(dev); - udelay(EPROM_DELAY); -} - - -void eprom_ck_cycle(struct net_device *dev) -{ - write_nic_byte(dev, EPROM_CMD, - (1<<EPROM_CK_SHIFT) | read_nic_byte(dev,EPROM_CMD)); - force_pci_posting(dev); - udelay(EPROM_DELAY); - write_nic_byte(dev, EPROM_CMD, - read_nic_byte(dev, EPROM_CMD) &~ (1<<EPROM_CK_SHIFT)); - force_pci_posting(dev); - udelay(EPROM_DELAY); -} - - -void eprom_w(struct net_device *dev,short bit) -{ - if(bit) - write_nic_byte(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) | \ - read_nic_byte(dev,EPROM_CMD)); - else - write_nic_byte(dev, EPROM_CMD, read_nic_byte(dev,EPROM_CMD)\ - &~(1<<EPROM_W_SHIFT)); - - force_pci_posting(dev); - udelay(EPROM_DELAY); -} - - -short eprom_r(struct net_device *dev) -{ - short bit; - - bit=(read_nic_byte(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) ); - udelay(EPROM_DELAY); - - if(bit) return 1; - return 0; -} - - -void eprom_send_bits_string(struct net_device *dev, short b[], int len) -{ - int i; - - for(i=0; i<len; i++){ - eprom_w(dev, b[i]); - eprom_ck_cycle(dev); - } -} - - -u32 eprom_read(struct net_device *dev, u32 addr) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - short read_cmd[]={1,1,0}; - short addr_str[8]; - int i; - int addr_len; - u32 ret; - - ret=0; - //enable EPROM programming - write_nic_byte(dev, EPROM_CMD, - (EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT)); - force_pci_posting(dev); - udelay(EPROM_DELAY); - - if (priv->epromtype==EPROM_93c56){ - addr_str[7]=addr & 1; - addr_str[6]=addr & (1<<1); - addr_str[5]=addr & (1<<2); - addr_str[4]=addr & (1<<3); - addr_str[3]=addr & (1<<4); - addr_str[2]=addr & (1<<5); - addr_str[1]=addr & (1<<6); - addr_str[0]=addr & (1<<7); - addr_len=8; - }else{ - addr_str[5]=addr & 1; - addr_str[4]=addr & (1<<1); - addr_str[3]=addr & (1<<2); - addr_str[2]=addr & (1<<3); - addr_str[1]=addr & (1<<4); - addr_str[0]=addr & (1<<5); - addr_len=6; - } - eprom_cs(dev, 1); - eprom_ck_cycle(dev); - eprom_send_bits_string(dev, read_cmd, 3); - eprom_send_bits_string(dev, addr_str, addr_len); - - //keep chip pin D to low state while reading. - //I'm unsure if it is necessary, but anyway shouldn't hurt - eprom_w(dev, 0); - - for(i=0;i<16;i++){ - //eeprom needs a clk cycle between writing opcode&adr - //and reading data. (eeprom outs a dummy 0) - eprom_ck_cycle(dev); - ret |= (eprom_r(dev)<<(15-i)); - } - - eprom_cs(dev, 0); - eprom_ck_cycle(dev); - - //disable EPROM programming - write_nic_byte(dev, EPROM_CMD, - (EPROM_CMD_NORMAL<<EPROM_CMD_OPERATING_MODE_SHIFT)); - return ret; -} diff --git a/drivers/staging/rtl8187se/r8180_93cx6.h b/drivers/staging/rtl8187se/r8180_93cx6.h index 36ae100..79e7391 100644 --- a/drivers/staging/rtl8187se/r8180_93cx6.h +++ b/drivers/staging/rtl8187se/r8180_93cx6.h @@ -45,13 +45,10 @@ #define EPROM_TXPW_OFDM_CH1_2 0x20 -//#define EPROM_TXPW_CH1_2 0x10 -#define EPROM_TXPW_CH1_2 0x30 -#define EPROM_TXPW_CH3_4 0x11 -#define EPROM_TXPW_CH5_6 0x12 -#define EPROM_TXPW_CH7_8 0x13 -#define EPROM_TXPW_CH9_10 0x14 -#define EPROM_TXPW_CH11_12 0x15 -#define EPROM_TXPW_CH13_14 0x16 - -u32 eprom_read(struct net_device *dev,u32 addr); //reads a 16 bits word +#define EPROM_TXPW_CH1_2 0x30 + +#define RTL818X_EEPROM_CMD_READ (1 << 0) +#define RTL818X_EEPROM_CMD_WRITE (1 << 1) +#define RTL818X_EEPROM_CMD_CK (1 << 2) +#define RTL818X_EEPROM_CMD_CS (1 << 3) + diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 1847f38..b1757ac 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -31,6 +31,7 @@ #undef DUMMY_RX #include <linux/syscalls.h> +#include <linux/eeprom_93cx6.h> #include "r8180_hw.h" #include "r8180.h" @@ -41,13 +42,6 @@ #include "ieee80211/dot11d.h" -#ifndef PCI_VENDOR_ID_BELKIN - #define PCI_VENDOR_ID_BELKIN 0x1799 -#endif -#ifndef PCI_VENDOR_ID_DLINK - #define PCI_VENDOR_ID_DLINK 0x1186 -#endif - static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = { { .vendor = PCI_VENDOR_ID_REALTEK, @@ -669,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; @@ -695,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; @@ -1421,11 +1330,9 @@ u16 N_DBPSOfRate(u16 DataRate) return N_DBPS; } -//{by amy 080312 // // Description: // For Netgear case, they want good-looking singal strength. -// 2004.12.05, by rcnjko. // long NetgearSignalStrengthTranslate(long LastSS, long CurrSS) { @@ -1481,7 +1388,6 @@ long TranslateToDbm8185(u8 SignalStrengthIndex) // This is different with PerformSignalSmoothing8185 in smoothing fomula. // No dramatic adjustion is apply because dynamic mechanism need some degree // of correctness. Ported from 8187B. -// 2007-02-26, by Bruce. // void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv, bool bCckRate) @@ -1502,7 +1408,6 @@ void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv, priv->CurCCKRSSI = 0; } -//by amy 080312} /* This is rough RX isr handling routine*/ void rtl8180_rx(struct net_device *dev) @@ -1638,7 +1543,7 @@ void rtl8180_rx(struct net_device *dev) } signal=(unsigned char)(((*(priv->rxringtail+3))& (0x00ff0000))>>16); - signal=(signal&0xfe)>>1; // Modify by hikaru 6.6 + signal = (signal & 0xfe) >> 1; quality=(unsigned char)((*(priv->rxringtail+3)) & (0xff)); @@ -1652,7 +1557,6 @@ void rtl8180_rx(struct net_device *dev) stats.rate = rtl8180_rate2rate(rate); Antenna = (((*(priv->rxringtail +3))& (0x00008000)) == 0 )? 0:1 ; -//by amy for antenna if(!rtl8180_IsWirelessBMode(stats.rate)) { // OFDM rate. @@ -1691,11 +1595,10 @@ void rtl8180_rx(struct net_device *dev) RXAGC=(95-RXAGC)*100/65; } priv->SignalStrength = (u8)RXAGC; - priv->RecvSignalPower = RxAGC_dBm ; // It can use directly by SD3 CMLin + priv->RecvSignalPower = RxAGC_dBm; priv->RxPower = rxpower; priv->RSSI = RSSI; -//{by amy 080312 - // SQ translation formular is provided by SD3 DZ. 2006.06.27, by rcnjko. + /* SQ translation formula is provided by SD3 DZ. 2006.06.27 */ if(quality >= 127) quality = 1;//0; //0 will cause epc to show signal zero , walk aroud now; else if(quality < 27) @@ -1712,7 +1615,6 @@ void rtl8180_rx(struct net_device *dev) // printk("==========================>rx : RXAGC is %d,signalstrength is %d\n",RXAGC,stats.signalstrength); stats.rssi = priv->wstats.qual.qual = priv->SignalQuality; stats.noise = priv->wstats.qual.noise = 100 - priv ->wstats.qual.qual; -//by amy 080312} bHwError = (((*(priv->rxringtail))& (0x00000fff)) == 4080)| (((*(priv->rxringtail))& (0x04000000)) != 0 ) | (((*(priv->rxringtail))& (0x08000000)) != 0 )| (((~(*(priv->rxringtail)))& (0x10000000)) != 0 )| (((~(*(priv->rxringtail)))& (0x20000000)) != 0 ); bCRC = ((*(priv->rxringtail)) & (0x00002000)) >> 13; @@ -1725,11 +1627,12 @@ void rtl8180_rx(struct net_device *dev) (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) && (!bHwError) && (!bCRC)&& (!bICV)) { -//by amy 080312 - // Perform signal smoothing for dynamic mechanism on demand. - // This is different with PerformSignalSmoothing8185 in smoothing fomula. - // No dramatic adjustion is apply because dynamic mechanism need some degree - // of correctness. 2007.01.23, by shien chang. + /* Perform signal smoothing for dynamic + * mechanism on demand. This is different + * with PerformSignalSmoothing8185 in smoothing + * fomula. No dramatic adjustion is apply + * because dynamic mechanism need some degree + * of correctness. */ PerformUndecoratedSignalSmoothing8185(priv,bCckRate); // // For good-looking singal strength. @@ -1749,12 +1652,9 @@ void rtl8180_rx(struct net_device *dev) // Figure out which antenna that received the lasted packet. priv->LastRxPktAntenna = Antenna ? 1 : 0; // 0: aux, 1: main. -//by amy 080312 SwAntennaDiversityRxOk8185(dev, priv->SignalStrength); } -//by amy for antenna -#ifndef DUMMY_RX if(first){ if(!priv->rx_skb_complete){ /* seems that HW sometimes fails to reiceve and @@ -1810,19 +1710,12 @@ void rtl8180_rx(struct net_device *dev) if(last && !priv->rx_skb_complete){ if(priv->rx_skb->len > 4) skb_trim(priv->rx_skb,priv->rx_skb->len-4); -#ifndef RX_DONT_PASS_UL if(!ieee80211_rtl_rx(priv->ieee80211, - priv->rx_skb, &stats)){ -#endif // RX_DONT_PASS_UL - + priv->rx_skb, &stats)) dev_kfree_skb_any(priv->rx_skb); -#ifndef RX_DONT_PASS_UL - } -#endif priv->rx_skb_complete=1; } -#endif //DUMMY_RX pci_dma_sync_single_for_device(priv->pdev, priv->rxbuffer->dma, priv->rxbuffersize * \ @@ -2056,7 +1949,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, u16 RtsDur = 0; u16 ThisFrameTime = 0; u16 TxDescDuration = 0; - u8 ownbit_flag = false; //added by david woo for sync Tx, 2007.12.14 + u8 ownbit_flag = false; switch(priority) { case MANAGE_PRIORITY: @@ -2123,7 +2016,8 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, //YJ,add,080828,for Keep alive priv->NumTxUnicast++; - // Figure out ACK rate according to BSS basic rate and Tx rate, 2006.03.08 by rcnjko. + /* Figure out ACK rate according to BSS basic rate + * and Tx rate. */ AckTime = ComputeTxTime(14, 10,0, 0); // AckCTSLng = 14 use 1M bps send if ( ((len + sCrcLng) > priv->rts) && priv->rts ) @@ -2206,7 +2100,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, *tail |= (1<<15); /* no encrypt */ if(remain==len && !descfrag) { - ownbit_flag = false; //added by david woo,2007.12.14 + ownbit_flag = false; *tail = *tail| (1<<29) ; //fist segment of the packet *tail = *tail |(len); } else { @@ -2556,27 +2450,16 @@ void watch_dog_adaptive(unsigned long data) } // Tx High Power Mechanism. -#ifdef HIGH_POWER if(CheckHighPower((struct net_device *)data)) - { queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->tx_pw_wq); - } -#endif // Tx Power Tracking on 87SE. -#ifdef TX_TRACK - //if( priv->bTxPowerTrack ) //lzm mod 080826 - if( CheckTxPwrTracking((struct net_device *)data)); + if (CheckTxPwrTracking((struct net_device *)data)) TxPwrTracking87SE((struct net_device *)data); -#endif // Perform DIG immediately. -#ifdef SW_DIG if(CheckDig((struct net_device *)data) == true) - { queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq); - } -#endif rtl8180_watch_dog((struct net_device *)data); queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem); @@ -2675,6 +2558,36 @@ static void rtl8180_link_detect_init(plink_detect_t plink_detect) } //YJ,add,080828,end +static void rtl8187se_eeprom_register_read(struct eeprom_93cx6 *eeprom) +{ + struct net_device *dev = eeprom->data; + u8 reg = read_nic_byte(dev, EPROM_CMD); + + eeprom->reg_data_in = reg & RTL818X_EEPROM_CMD_WRITE; + eeprom->reg_data_out = reg & RTL818X_EEPROM_CMD_READ; + eeprom->reg_data_clock = reg & RTL818X_EEPROM_CMD_CK; + eeprom->reg_chip_select = reg & RTL818X_EEPROM_CMD_CS; +} + +static void rtl8187se_eeprom_register_write(struct eeprom_93cx6 *eeprom) +{ + struct net_device *dev = eeprom->data; + u8 reg = 2 << 6; + + if (eeprom->reg_data_in) + reg |= RTL818X_EEPROM_CMD_WRITE; + if (eeprom->reg_data_out) + reg |= RTL818X_EEPROM_CMD_READ; + if (eeprom->reg_data_clock) + reg |= RTL818X_EEPROM_CMD_CK; + if (eeprom->reg_chip_select) + reg |= RTL818X_EEPROM_CMD_CS; + + write_nic_byte(dev, EPROM_CMD, reg); + read_nic_byte(dev, EPROM_CMD); + udelay(10); +} + short rtl8180_init(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -2683,8 +2596,16 @@ short rtl8180_init(struct net_device *dev) u32 usValue; u16 tmpu16; int i, j; + struct eeprom_93cx6 eeprom; + u16 eeprom_val; + + eeprom.data = dev; + eeprom.register_read = rtl8187se_eeprom_register_read; + eeprom.register_write = rtl8187se_eeprom_register_write; + eeprom.width = PCI_EEPROM_WIDTH_93C46; - priv->channel_plan = eprom_read(dev, EEPROM_COUNTRY_CODE>>1) & 0xFF; + eeprom_93cx6_read(&eeprom, EEPROM_COUNTRY_CODE>>1, &eeprom_val); + priv->channel_plan = eeprom_val & 0xFF; if(priv->channel_plan > COUNTRY_CODE_GLOBAL_DOMAIN){ printk("rtl8180_init:Error channel plan! Set to default.\n"); priv->channel_plan = 0; @@ -2701,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; @@ -2747,10 +2666,8 @@ short rtl8180_init(struct net_device *dev) priv->TxPollingTimes = 0;//lzm add 080826 priv->bLeisurePs = true; priv->dot11PowerSaveMode = eActive; -//by amy for antenna priv->AdMinCheckPeriod = 5; priv->AdMaxCheckPeriod = 10; -// Lower signal strength threshold to fit the HW participation in antenna diversity. +by amy 080312 priv->AdMaxRxSsThreshold = 30;//60->30 priv->AdRxSsThreshold = 20;//50->20 priv->AdCheckPeriod = priv->AdMinCheckPeriod; @@ -2765,8 +2682,6 @@ short rtl8180_init(struct net_device *dev) init_timer(&priv->SwAntennaDiversityTimer); priv->SwAntennaDiversityTimer.data = (unsigned long)dev; priv->SwAntennaDiversityTimer.function = (void *)SwAntennaDiversityTimerCallback; -//by amy for antenna -//{by amy 080312 priv->bDigMechanism = 1; priv->InitialGain = 6; priv->bXtalCalibration = false; @@ -2803,58 +2718,63 @@ short rtl8180_init(struct net_device *dev) priv->NumTxUnicast = 0; priv->keepAliveLevel = DEFAULT_KEEP_ALIVE_LEVEL; priv->PowerProfile = POWER_PROFILE_AC; - priv->CurrRetryCnt=0; - priv->LastRetryCnt=0; - priv->LastTxokCnt=0; - priv->LastRxokCnt=0; - priv->LastRetryRate=0; - priv->bTryuping=0; - priv->CurrTxRate=0; - priv->CurrRetryRate=0; - priv->TryupingCount=0; - priv->TryupingCountNoData=0; - priv->TryDownCountLowData=0; - priv->LastTxOKBytes=0; - priv->LastFailTxRate=0; - priv->LastFailTxRateSS=0; - priv->FailTxRateCount=0; - priv->LastTxThroughput=0; - priv->NumTxOkBytesTotal=0; + priv->CurrRetryCnt = 0; + priv->LastRetryCnt = 0; + priv->LastTxokCnt = 0; + priv->LastRxokCnt = 0; + priv->LastRetryRate = 0; + priv->bTryuping = 0; + priv->CurrTxRate = 0; + priv->CurrRetryRate = 0; + priv->TryupingCount = 0; + priv->TryupingCountNoData = 0; + priv->TryDownCountLowData = 0; + priv->LastTxOKBytes = 0; + priv->LastFailTxRate = 0; + priv->LastFailTxRateSS = 0; + priv->FailTxRateCount = 0; + priv->LastTxThroughput = 0; + priv->NumTxOkBytesTotal = 0; priv->ForcedDataRate = 0; priv->RegBModeGainStage = 1; - priv->promisc = (dev->flags & IFF_PROMISC) ? 1:0; + priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; spin_lock_init(&priv->irq_lock); spin_lock_init(&priv->irq_th_lock); spin_lock_init(&priv->tx_lock); spin_lock_init(&priv->ps_lock); spin_lock_init(&priv->rf_ps_lock); - sema_init(&priv->wx_sem,1); - sema_init(&priv->rf_state,1); - INIT_WORK(&priv->reset_wq,(void*) rtl8180_restart_wq); - INIT_WORK(&priv->tx_irq_wq,(void*) rtl8180_tx_irq_wq); - INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq,(void*) rtl8180_hw_wakeup_wq); - INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq,(void*) rtl8180_hw_sleep_wq); - INIT_WORK(&priv->ieee80211->wmm_param_update_wq,(void*) rtl8180_wmm_param_update); - INIT_DELAYED_WORK(&priv->ieee80211->rate_adapter_wq,(void*)rtl8180_rate_adapter);//+by amy 080312 - INIT_DELAYED_WORK(&priv->ieee80211->hw_dig_wq,(void*)rtl8180_hw_dig_wq);//+by amy 080312 - INIT_DELAYED_WORK(&priv->ieee80211->tx_pw_wq,(void*)rtl8180_tx_pw_wq);//+by amy 080312 - - INIT_DELAYED_WORK(&priv->ieee80211->GPIOChangeRFWorkItem,(void*) GPIOChangeRFWorkItemCallBack); - + sema_init(&priv->wx_sem, 1); + sema_init(&priv->rf_state, 1); + INIT_WORK(&priv->reset_wq, (void *)rtl8180_restart_wq); + INIT_WORK(&priv->tx_irq_wq, (void *)rtl8180_tx_irq_wq); + INIT_DELAYED_WORK(&priv->ieee80211->hw_wakeup_wq, + (void *)rtl8180_hw_wakeup_wq); + INIT_DELAYED_WORK(&priv->ieee80211->hw_sleep_wq, + (void *)rtl8180_hw_sleep_wq); + INIT_WORK(&priv->ieee80211->wmm_param_update_wq, + (void *)rtl8180_wmm_param_update); + INIT_DELAYED_WORK(&priv->ieee80211->rate_adapter_wq, + (void *)rtl8180_rate_adapter); + INIT_DELAYED_WORK(&priv->ieee80211->hw_dig_wq, + (void *)rtl8180_hw_dig_wq); + INIT_DELAYED_WORK(&priv->ieee80211->tx_pw_wq, + (void *)rtl8180_tx_pw_wq); + INIT_DELAYED_WORK(&priv->ieee80211->GPIOChangeRFWorkItem, + (void *) GPIOChangeRFWorkItemCallBack); tasklet_init(&priv->irq_rx_tasklet, (void(*)(unsigned long)) rtl8180_irq_rx_tasklet, (unsigned long)priv); - init_timer(&priv->watch_dog_timer); + init_timer(&priv->watch_dog_timer); priv->watch_dog_timer.data = (unsigned long)dev; priv->watch_dog_timer.function = watch_dog_adaptive; - init_timer(&priv->rateadapter_timer); - priv->rateadapter_timer.data = (unsigned long)dev; - priv->rateadapter_timer.function = timer_rate_adaptive; - priv->RateAdaptivePeriod= RATE_ADAPTIVE_TIMER_PERIOD; - priv->bEnhanceTxPwr=false; + init_timer(&priv->rateadapter_timer); + priv->rateadapter_timer.data = (unsigned long)dev; + priv->rateadapter_timer.function = timer_rate_adaptive; + priv->RateAdaptivePeriod = RATE_ADAPTIVE_TIMER_PERIOD; + priv->bEnhanceTxPwr = false; priv->ieee80211->softmac_hard_start_xmit = rtl8180_hard_start_xmit; priv->ieee80211->set_chan = rtl8180_set_chan; @@ -2877,30 +2797,28 @@ short rtl8180_init(struct net_device *dev) priv->CSMethod = (0x01 << 29); - priv->TransmitConfig = - 1<<TCR_DurProcMode_OFFSET | //for RTL8185B, duration setting by HW - (7<<TCR_MXDMA_OFFSET) | // Max DMA Burst Size per Tx DMA Burst, 7: reservied. - (priv->ShortRetryLimit<<TCR_SRL_OFFSET) | // Short retry limit - (priv->LongRetryLimit<<TCR_LRL_OFFSET) | // Long retry limit - (0 ? TCR_SAT : 0); // FALSE: HW provies PLCP length and LENGEXT, TURE: SW proiveds them - - priv->ReceiveConfig = - RCR_AMF | RCR_ADF | //accept management/data - RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. - RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - (7<<RCR_MXDMA_OFFSET) | // Max DMA Burst Size per Rx DMA Burst, 7: unlimited. - (priv->EarlyRxThreshold<<RCR_FIFO_OFFSET) | // Rx FIFO Threshold, 7: No Rx threshold. - (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT:0); + priv->TransmitConfig = TCR_DurProcMode_OFFSET | + (7<<TCR_MXDMA_OFFSET) | + (priv->ShortRetryLimit<<TCR_SRL_OFFSET) | + (priv->LongRetryLimit<<TCR_LRL_OFFSET) | + (0 ? TCR_SAT : 0); + + priv->ReceiveConfig = RCR_AMF | RCR_ADF | RCR_ACF | + RCR_AB | RCR_AM | RCR_APM | + (7<<RCR_MXDMA_OFFSET) | + (priv->EarlyRxThreshold<<RCR_FIFO_OFFSET) | + (priv->EarlyRxThreshold == 7 ? + RCR_ONLYERLPKT : 0); priv->IntrMask = IMR_TMGDOK | IMR_TBDER | IMR_THPDER | - IMR_THPDER | IMR_THPDOK | - IMR_TVODER | IMR_TVODOK | - IMR_TVIDER | IMR_TVIDOK | - IMR_TBEDER | IMR_TBEDOK | - IMR_TBKDER | IMR_TBKDOK | - IMR_RDU | // To handle the defragmentation not enough Rx descriptors case. Annie, 2006-03-27. - IMR_RER | IMR_ROK | - IMR_RQoSOK; // <NOTE> ROK and RQoSOK are mutually exclusive, so, we must handle RQoSOK interrupt to receive QoS frames, 2005.12.09, by rcnjko. + IMR_THPDER | IMR_THPDOK | + IMR_TVODER | IMR_TVODOK | + IMR_TVIDER | IMR_TVIDOK | + IMR_TBEDER | IMR_TBEDOK | + IMR_TBKDER | IMR_TBKDOK | + IMR_RDU | + IMR_RER | IMR_ROK | + IMR_RQoSOK; priv->InitialGain = 6; @@ -2913,7 +2831,8 @@ short rtl8180_init(struct net_device *dev) // just for sync 85 priv->enable_gpio0 = 0; - usValue = eprom_read(dev, EEPROM_SW_REVD_OFFSET); + eeprom_93cx6_read(&eeprom, EEPROM_SW_REVD_OFFSET, &eeprom_val); + usValue = eeprom_val; DMESG("usValue is 0x%x\n",usValue); //3Read AntennaDiversity @@ -2953,54 +2872,46 @@ short rtl8180_init(struct net_device *dev) else priv->epromtype=EPROM_93c46; - dev->dev_addr[0]=eprom_read(dev,MAC_ADR) & 0xff; - dev->dev_addr[1]=(eprom_read(dev,MAC_ADR) & 0xff00)>>8; - dev->dev_addr[2]=eprom_read(dev,MAC_ADR+1) & 0xff; - dev->dev_addr[3]=(eprom_read(dev,MAC_ADR+1) & 0xff00)>>8; - dev->dev_addr[4]=eprom_read(dev,MAC_ADR+2) & 0xff; - dev->dev_addr[5]=(eprom_read(dev,MAC_ADR+2) & 0xff00)>>8; + eeprom_93cx6_multiread(&eeprom, 0x7, (__le16 *) + dev->dev_addr, 3); for(i=1,j=0; i<14; i+=2,j++){ - word = eprom_read(dev,EPROM_TXPW_CH1_2 + j); + eeprom_93cx6_read(&eeprom, EPROM_TXPW_CH1_2 + j, &word); priv->chtxpwr[i]=word & 0xff; priv->chtxpwr[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); + eeprom_93cx6_read(&eeprom, EPROM_TXPW_OFDM_CH1_2 + j, &word); priv->chtxpwr_ofdm[i] = word & 0xff; - priv->chtxpwr_ofdm[i+1] = (word & 0xff00)>>8; + priv->chtxpwr_ofdm[i+1] = (word & 0xff00) >> 8; } - //3Read crystal calibtration and thermal meter indication on 87SE. - - // By SD3 SY's request. Added by Roger, 2007.12.11. + /* 3Read crystal calibtration and thermal meter indication on 87SE. */ + eeprom_93cx6_read(&eeprom, EEPROM_RSV>>1, &tmpu16); - tmpu16 = eprom_read(dev, EEPROM_RSV>>1); + /* Crystal calibration for Xin and Xout resp. */ + priv->XtalCal_Xout = tmpu16 & EEPROM_XTAL_CAL_XOUT_MASK; + priv->XtalCal_Xin = (tmpu16 & EEPROM_XTAL_CAL_XIN_MASK) >> 4; + if ((tmpu16 & EEPROM_XTAL_CAL_ENABLE) >> 12) + priv->bXtalCalibration = true; - // Crystal calibration for Xin and Xout resp. - priv->XtalCal_Xout = tmpu16 & EEPROM_XTAL_CAL_XOUT_MASK; // 0~7.5pF - priv->XtalCal_Xin = (tmpu16 & EEPROM_XTAL_CAL_XIN_MASK)>>4; // 0~7.5pF - if((tmpu16 & EEPROM_XTAL_CAL_ENABLE)>>12) - priv->bXtalCalibration = true; + /* Thermal meter reference indication. */ + priv->ThermalMeter = (u8)((tmpu16 & EEPROM_THERMAL_METER_MASK) >> 8); + if ((tmpu16 & EEPROM_THERMAL_METER_ENABLE) >> 13) + priv->bTxPowerTrack = true; - // Thermal meter reference indication. - priv->ThermalMeter = (u8)((tmpu16 & EEPROM_THERMAL_METER_MASK)>>8); - if((tmpu16 & EEPROM_THERMAL_METER_ENABLE)>>13) - priv->bTxPowerTrack = true; - - word = eprom_read(dev,EPROM_TXPW_BASE); + eeprom_93cx6_read(&eeprom, EPROM_TXPW_BASE, &word); priv->cck_txpwr_base = word & 0xf; priv->ofdm_txpwr_base = (word>>4) & 0xf; - version = eprom_read(dev,EPROM_VERSION); + eeprom_93cx6_read(&eeprom, EPROM_VERSION, &version); DMESG("EEPROM version %x",version); priv->rcr_csense = 3; - priv->cs_treshold = (eprom_read(dev, ENERGY_TRESHOLD) & 0xff00) >> 8; - - priv->rf_chip = 0xff & eprom_read(dev, RFCHIPID); + eeprom_93cx6_read(&eeprom, ENERGY_TRESHOLD, &eeprom_val); + priv->cs_treshold = (eeprom_val & 0xff00) >> 8; - priv->rf_chip = RF_ZEBRA4; + eeprom_93cx6_read(&eeprom, RFCHIPID, &eeprom_val); priv->rf_sleep = rtl8225z4_rf_sleep; priv->rf_wakeup = rtl8225z4_rf_wakeup; DMESGW("**PLEASE** REPORT SUCCESSFUL/UNSUCCESSFUL TO Realtek!"); @@ -3010,7 +2921,6 @@ short rtl8180_init(struct net_device *dev) priv->rf_set_chan = rtl8225z2_rf_set_chan; priv->rf_set_sens = NULL; - if (0!=alloc_rx_desc_ring(dev, priv->rxbuffersize, priv->rxringcount)) return -ENOMEM; @@ -3042,11 +2952,7 @@ short rtl8180_init(struct net_device *dev) TX_BEACON_RING_ADDR)) return -ENOMEM; -#if !defined(SA_SHIRQ) if(request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)){ -#else - if(request_irq(dev->irq, (void *)rtl8180_interrupt, SA_SHIRQ, dev->name, dev)){ -#endif DMESGE("Error allocating IRQ %d",dev->irq); return -1; }else{ @@ -3169,43 +3075,6 @@ void write_phy_cck (struct net_device *dev, u8 adr, u32 data) rtl8185_write_phy(dev, adr, data | 0x10000); } -/* 70*3 = 210 ms - * I hope this is enougth - */ -#define MAX_PHY 70 -void write_phy(struct net_device *dev, u8 adr, u8 data) -{ - u32 phy; - int i; - - phy = 0xff0000; - phy |= adr; - phy |= 0x80; /* this should enable writing */ - phy |= (data<<8); - - //PHY_ADR, PHY_R and PHY_W are contig and treated as one dword - write_nic_dword(dev,PHY_ADR, phy); - - phy= 0xffff00; - phy |= adr; - - write_nic_dword(dev,PHY_ADR, phy); - for(i=0;i<MAX_PHY;i++){ - phy=read_nic_dword(dev,PHY_ADR); - phy= phy & 0xff0000; - phy= phy >> 16; - if(phy == data){ //SUCCESS! - force_pci_posting(dev); - mdelay(3); //random value - return; - }else{ - force_pci_posting(dev); - mdelay(3); //random value - } - } - DMESGW ("Phy writing %x %x failed!", adr,data); -} - void rtl8185_set_rate(struct net_device *dev) { int i; @@ -3335,7 +3204,6 @@ static struct net_device_stats *rtl8180_stats(struct net_device *dev) } // // Change current and default preamble mode. -// 2005.01.06, by rcnjko. // bool MgntActSet_802_11_PowerSaveMode( @@ -3454,7 +3322,6 @@ void rtl8180_watch_dog(struct net_device *dev) MgntLinkKeepAlive(priv); //YJ,add,080828,for LPS -#ifdef ENABLE_LPS if (priv->PowerProfile == POWER_PROFILE_BATTERY) priv->bLeisurePs = true; else if (priv->PowerProfile == POWER_PROFILE_AC) { @@ -3464,7 +3331,6 @@ void rtl8180_watch_dog(struct net_device *dev) if(priv->ieee80211->state == IEEE80211_LINKED){ priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod; - //printk("TxOk=%d RxOk=%d\n", priv->link_detect.NumTxOkInPeriod, priv->link_detect.NumRxOkInPeriod); if( priv->link_detect.NumRxOkInPeriod> 666 || priv->link_detect.NumTxOkInPeriod> 666 ) { bBusyTraffic = true; @@ -3481,7 +3347,6 @@ void rtl8180_watch_dog(struct net_device *dev) LeisurePSLeave(priv); } else LeisurePSLeave(priv); -#endif priv->link_detect.bBusyTraffic = bBusyTraffic; priv->link_detect.NumRxOkInPeriod = 0; priv->link_detect.NumTxOkInPeriod = 0; @@ -3503,16 +3368,11 @@ int _rtl8180_up(struct net_device *dev) if(priv->ieee80211->iw_mode == IW_MODE_ADHOC) IPSLeave(dev); } -#ifdef RATE_ADAPT timer_rate_adaptive((unsigned long)dev); -#endif watch_dog_adaptive((unsigned long)dev); -#ifdef SW_ANTE if(priv->bSwAntennaDiverity) SwAntennaDiversityTimerCallback(dev); -#endif ieee80211_softmac_start_protocol(priv->ieee80211); - return 0; } @@ -3748,7 +3608,7 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, dev->wireless_handlers = &r8180_wx_handlers_def; dev->type=ARPHRD_ETHER; - dev->watchdog_timeo = HZ*3; //added by david woo, 2007.12.13 + dev->watchdog_timeo = HZ*3; if (dev_alloc_name(dev, ifname) < 0){ DMESG("Oops: devname already taken! Trying wlan%%d...\n"); @@ -3864,8 +3724,7 @@ static int __init rtl8180_pci_module_init(void) return ret; } - printk(KERN_INFO "\nLinux kernel driver for RTL8180 \ -/ RTL8185 based WLAN cards\n"); + printk(KERN_INFO "\nLinux kernel driver for RTL8180 / RTL8185 based WLAN cards\n"); printk(KERN_INFO "Copyright (c) 2004-2005, Andrea Merello\n"); DMESG("Initializing module"); DMESG("Wireless extensions version %d", WIRELESS_EXT); @@ -4236,60 +4095,51 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work) static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; static int readf_count = 0; -#ifdef ENABLE_LPS if(readf_count % 10 == 0) priv->PowerProfile = read_acadapter_file("/proc/acpi/ac_adapter/AC0/state"); readf_count = (readf_count+1)%0xffff; -#endif - { - // We should turn off LED before polling FF51[4]. + /* We should turn off LED before polling FF51[4]. */ - //Turn off LED. - btPSR = read_nic_byte(dev, PSR); - write_nic_byte(dev, PSR, (btPSR & ~BIT3)); + /* Turn off LED. */ + btPSR = read_nic_byte(dev, PSR); + write_nic_byte(dev, PSR, (btPSR & ~BIT3)); - //It need to delay 4us suggested by Jong, 2008-01-16 - udelay(4); + /* It need to delay 4us suggested by Jong, 2008-01-16 */ + udelay(4); - //HW radio On/Off according to the value of FF51[4](config0) - btConfig0 = btPSR = read_nic_byte(dev, CONFIG0); + /* HW radio On/Off according to the value of FF51[4](config0) */ + btConfig0 = btPSR = read_nic_byte(dev, CONFIG0); - //Turn on LED. - write_nic_byte(dev, PSR, btPSR| BIT3); + eRfPowerStateToSet = (btConfig0 & BIT4) ? eRfOn : eRfOff; - eRfPowerStateToSet = (btConfig0 & BIT4) ? eRfOn : eRfOff; + /* Turn LED back on when radio enabled */ + if (eRfPowerStateToSet == eRfOn) + write_nic_byte(dev, PSR, btPSR | BIT3); - if((priv->ieee80211->bHwRadioOff == true) && (eRfPowerStateToSet == eRfOn)) - { - priv->ieee80211->bHwRadioOff = false; - bActuallySet = true; - } - else if((priv->ieee80211->bHwRadioOff == false) && (eRfPowerStateToSet == eRfOff)) - { - priv->ieee80211->bHwRadioOff = true; - bActuallySet = true; - } + if ((priv->ieee80211->bHwRadioOff == true) && + (eRfPowerStateToSet == eRfOn)) { + priv->ieee80211->bHwRadioOff = false; + bActuallySet = true; + } else if ((priv->ieee80211->bHwRadioOff == false) && + (eRfPowerStateToSet == eRfOff)) { + priv->ieee80211->bHwRadioOff = true; + bActuallySet = true; + } - if(bActuallySet) - { - MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW); - - /* To update the UI status for Power status changed */ - if(priv->ieee80211->bHwRadioOff == true) - argv[1] = "RFOFF"; - else{ - //if(!priv->RfOffReason) - argv[1] = "RFON"; - //else - // argv[1] = "RFOFF"; - } - argv[0] = RadioPowerPath; - argv[2] = NULL; - - call_usermodehelper(RadioPowerPath,argv,envp,1); - } - } + if (bActuallySet) { + MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW); + + /* To update the UI status for Power status changed */ + if (priv->ieee80211->bHwRadioOff == true) + argv[1] = "RFOFF"; + else + argv[1] = "RFON"; + argv[0] = RadioPowerPath; + argv[2] = NULL; + + call_usermodehelper(RadioPowerPath, argv, envp, 1); + } } static u8 read_acadapter_file(char *filename) diff --git a/drivers/staging/rtl8187se/r8180_dm.c b/drivers/staging/rtl8187se/r8180_dm.c index cbca58d..fc49078 100644 --- a/drivers/staging/rtl8187se/r8180_dm.c +++ b/drivers/staging/rtl8187se/r8180_dm.c @@ -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 - 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. - - - bAntennaSwitched = true; - break; + /* 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. */ - default: - printk("SetAntenna8185: unknown RFChipID(%d)\n", priv->rf_chip); - break; - } + bAntennaSwitched = true; break; case 1: - switch(priv->rf_chip) - { - case RF_ZEBRA2: - case RF_ZEBRA4: - // 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. - - bAntennaSwitched = true; - break; + /* 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. */ + + bAntennaSwitched = true; - default: - printk("SetAntenna8185: unknown RFChipID(%d)\n", priv->rf_chip); - break; - } break; default: diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c index afe10f0..6edf5a4 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c @@ -854,134 +854,48 @@ 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); + switch (eRFPowerState) { + case eRfOn: + write_nic_word(dev, 0x37C, 0x00EC); - write_nic_dword(dev, ANAPARAM, ANAPARM_ON); - write_nic_dword(dev, ANAPARAM2, ANAPARM2_ON); + /* turn on AFE */ + write_nic_byte(dev, 0x54, 0x00); + write_nic_byte(dev, 0x62, 0x00); - write_nic_byte(dev, CONFIG4, priv->RFProgType); + /* turn on RF */ + RF_WriteReg(dev, 0x0, 0x009f); udelay(500); + RF_WriteReg(dev, 0x4, 0x0972); udelay(500); - /* 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); - - /* turn on AFE */ - write_nic_byte(dev, 0x54, 0x00); - write_nic_byte(dev, 0x62, 0x00); - - /* turn on RF */ - RF_WriteReg(dev, 0x0, 0x009f); udelay(500); - RF_WriteReg(dev, 0x4, 0x0972); udelay(500); - - /* turn on RF again */ - RF_WriteReg(dev, 0x0, 0x009f); udelay(500); - RF_WriteReg(dev, 0x4, 0x0972); udelay(500); + /* turn on RF again */ + RF_WriteReg(dev, 0x0, 0x009f); udelay(500); + RF_WriteReg(dev, 0x4, 0x0972); udelay(500); - /* turn on BB */ - 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); - - u1bTmp = read_nic_byte(dev, 0x24E); - write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6)))); - break; - case eRfSleep: - for (QueueID = 0, i = 0; QueueID < 6;) { - if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { - QueueID++; - continue; - } else { - priv->TxPollingTimes ++; - if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) { - bActionAllowed = false; - break; - } else - udelay(10); - } - } + /* turn on BB */ + write_phy_ofdm(dev, 0x10, 0x40); + write_phy_ofdm(dev, 0x12, 0x40); - if (bActionAllowed) { - /* turn off BB RXIQ matrix to cut off rx signal */ - write_phy_ofdm(dev, 0x10, 0x00); - write_phy_ofdm(dev, 0x12, 0x00); - - /* turn off RF */ - RF_WriteReg(dev, 0x4, 0x0000); - RF_WriteReg(dev, 0x0, 0x0000); - - /* turn off AFE except PLL */ - write_nic_byte(dev, 0x62, 0xff); - write_nic_byte(dev, 0x54, 0xec); - - mdelay(1); - - { - int i = 0; - while (true) { - u8 tmp24F = read_nic_byte(dev, 0x24f); - - if ((tmp24F == 0x01) || (tmp24F == 0x09)) { - bTurnOffBB = true; - break; - } else { - udelay(10); - i++; - priv->TxPollingTimes++; - - if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) { - bTurnOffBB = false; - break; - } else - udelay(10); - } - } - } - - if (bTurnOffBB) { - /* turn off BB */ - u1bTmp = read_nic_byte(dev, 0x24E); - write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6)); - - /* turn off AFE PLL */ - write_nic_byte(dev, 0x54, 0xFC); - write_nic_word(dev, 0x37C, 0x00FC); - } - } - break; - case eRfOff: - for (QueueID = 0, i = 0; QueueID < 6;) { - if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { - QueueID++; - continue; - } else { - udelay(10); - i++; - } + /* Avoid power down at init time. */ + write_nic_byte(dev, CONFIG4, priv->RFProgType); - if (i >= MAX_DOZE_WAITING_TIMES_85B) + u1bTmp = read_nic_byte(dev, 0x24E); + write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6)))); + break; + case eRfSleep: + for (QueueID = 0, i = 0; QueueID < 6;) { + if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { + QueueID++; + continue; + } else { + priv->TxPollingTimes++; + if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) { + bActionAllowed = false; break; + } else + udelay(10); } + } + if (bActionAllowed) { /* turn off BB RXIQ matrix to cut off rx signal */ write_phy_ofdm(dev, 0x10, 0x00); write_phy_ofdm(dev, 0x12, 0x00); @@ -998,22 +912,23 @@ 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)) { bTurnOffBB = true; break; } else { - bTurnOffBB = false; udelay(10); i++; - } + priv->TxPollingTimes++; - if (i > MAX_POLLING_24F_TIMES_87SE) - break; + if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) { + bTurnOffBB = false; + break; + } else + udelay(10); + } } } @@ -1022,15 +937,68 @@ bool SetZebraRFPowerState8185(struct net_device *dev, u1bTmp = read_nic_byte(dev, 0x24E); write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6)); - /* turn off AFE PLL (80M) */ + /* turn off AFE PLL */ write_nic_byte(dev, 0x54, 0xFC); write_nic_word(dev, 0x37C, 0x00FC); } - break; - default: - bResult = false; - printk("SetZebraRFPowerState8185(): unknown state to set: 0x%X!!!\n", eRFPowerState); - break; + } + break; + case eRfOff: + for (QueueID = 0, i = 0; QueueID < 6;) { + if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { + QueueID++; + continue; + } else { + udelay(10); + i++; + } + + if (i >= MAX_DOZE_WAITING_TIMES_85B) + break; + } + + /* turn off BB RXIQ matrix to cut off rx signal */ + write_phy_ofdm(dev, 0x10, 0x00); + write_phy_ofdm(dev, 0x12, 0x00); + + /* turn off RF */ + RF_WriteReg(dev, 0x4, 0x0000); + RF_WriteReg(dev, 0x0, 0x0000); + + /* turn off AFE except PLL */ + write_nic_byte(dev, 0x62, 0xff); + write_nic_byte(dev, 0x54, 0xec); + + mdelay(1); + + { + int i = 0; + + while (true) { + u8 tmp24F = read_nic_byte(dev, 0x24f); + + if ((tmp24F == 0x01) || (tmp24F == 0x09)) { + bTurnOffBB = true; + break; + } else { + bTurnOffBB = false; + udelay(10); + i++; + } + + if (i > MAX_POLLING_24F_TIMES_87SE) + break; + } + } + + if (bTurnOffBB) { + /* turn off BB */ + u1bTmp = read_nic_byte(dev, 0x24E); + write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6)); + + /* turn off AFE PLL (80M) */ + write_nic_byte(dev, 0x54, 0xFC); + write_nic_word(dev, 0x37C, 0x00FC); } break; } diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c index 50309f2..a0ece1f 100644 --- a/drivers/staging/rtl8187se/r8185b_init.c +++ b/drivers/staging/rtl8187se/r8185b_init.c @@ -238,100 +238,12 @@ 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; - } + write_nic_word(dev, RFPinsEnable, 0x1bff); } -void -ZEBRA_RFSerialWrite( - struct net_device *dev, - u32 data2Write, - u8 totalLength, - u8 low2high - ) -{ - ThreeWireReg twreg; - int i; - u16 oval,oval2,oval3; - u32 mask; - u16 UshortBuffer; - - u8 u1bTmp; - // 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); - UshortBuffer = read_nic_word(dev, RFPinsOutput); - oval = UshortBuffer & 0xfff8; // We shall clear bit0, 1, 2 first, 2005.10.28, by rcnjko. - - oval2 = read_nic_word(dev, RFPinsEnable); - oval3 = read_nic_word(dev, RFPinsSelect); - - // <RJ_NOTE> 3-wire should be controled by HW when we finish SW 3-wire programming. 2005.08.10, by rcnjko. - oval3 &= 0xfff8; - - write_nic_word(dev, RFPinsEnable, (oval2|0x0007)); // Set To Output Enable - write_nic_word(dev, RFPinsSelect, (oval3|0x0007)); // Set To SW Switch - udelay(10); - - // Add this to avoid hardware and software 3-wire conflict. - // 2005.03.01, by rcnjko. - twreg.longData = 0; - twreg.struc.enableB = 1; - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); // Set SI_EN (RFLE) - udelay(2); - twreg.struc.enableB = 0; - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); // Clear SI_EN (RFLE) - udelay(10); - - mask = (low2high)?0x01:((u32)0x01<<(totalLength-1)); - - for(i=0; i<totalLength/2; i++) - { - twreg.struc.data = ((data2Write&mask)!=0) ? 1 : 0; - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); - twreg.struc.clk = 1; - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); - - mask = (low2high)?(mask<<1):(mask>>1); - twreg.struc.data = ((data2Write&mask)!=0) ? 1 : 0; - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); - twreg.struc.clk = 0; - write_nic_word(dev, RFPinsOutput, (twreg.longData|oval)); - mask = (low2high)?(mask<<1):(mask>>1); - } - - twreg.struc.enableB = 1; - twreg.struc.clk = 0; - twreg.struc.data = 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); - udelay(10); - - write_nic_word(dev, RFPinsOutput, oval|0x0004); - write_nic_word(dev, RFPinsSelect, oval3|0x0000); - - SetOutputEnableOfRfPins(dev); -} -//by amy - - -int +static int HwHSSIThreeWire( struct net_device *dev, u8 *pDataBuf, @@ -469,420 +381,30 @@ HwHSSIThreeWire( return bResult; } -//by amy - -int -HwThreeWire( - struct net_device *dev, - u8 *pDataBuf, - u8 nDataBufBitCnt, - int bHold, - int bWrite - ) -{ - 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) - panic("HwThreeWire(): CmdReg: %#X RE|WE bits are not clear!!\n", u1bTmp); - - // Fill up data buffer for write operation. - if(nDataBufBitCnt == 16) - { - write_nic_word(dev, SW_3W_DB0, *((u16 *)pDataBuf)); - } - else if(nDataBufBitCnt == 64) - { - 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; - - if ((nDataBufBitCnt % 8) != 0) - panic("HwThreeWire(): nDataBufBitCnt(%d) should be multiple of 8!!!\n", - nDataBufBitCnt); - - if (nDataBufBitCnt > 64) - panic("HwThreeWire(): nDataBufBitCnt(%d) should <= 64!!!\n", - nDataBufBitCnt); - - for(idx = 0; idx < ByteCnt; idx++) - { - write_nic_byte(dev, (SW_3W_DB0+idx), *(pDataBuf+idx)); - } - } - - // Fill up length field. - u1bTmp = (u8)(nDataBufBitCnt - 1); // Number of bits - 1. - if(bHold) - u1bTmp |= SW_3W_CMD0_HOLD; - write_nic_byte(dev, SW_3W_CMD0, u1bTmp); - - // Set up command: WE or RE. - if(bWrite) - { - 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 WE and RE are cleared and 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_RE|SW_3W_CMD1_WE)) == 0 && - (u1bTmp & SW_3W_CMD1_DONE) != 0 ) - { - break; - } - udelay(10); - } - if(TryCnt == TC_3W_POLL_MAX_TRY_CNT) - { - //RT_ASSERT(TryCnt != TC_3W_POLL_MAX_TRY_CNT, - // ("HwThreeWire(): CmdReg: %#X RE|WE bits are not clear or DONE is not set!!\n", u1bTmp)); - // Workaround suggested by wcchu: clear WE here. 2006.07.07, by rcnjko. - write_nic_byte(dev, SW_3W_CMD1, 0); - } - - // Read back data for read operation. - // <RJ_TODO> I am not sure if this is correct output format of a read operation. - if(bWrite == 0) - { - if(nDataBufBitCnt == 16) - { - *((u16 *)pDataBuf) = read_nic_word(dev, SW_3W_DB0); - } - else if(nDataBufBitCnt == 64) - { - *((u32 *)pDataBuf) = read_nic_dword(dev, SW_3W_DB0); - *((u32 *)(pDataBuf + 4)) = read_nic_dword(dev, SW_3W_DB1); - } - else - { - int idx; - int ByteCnt = nDataBufBitCnt / 8; - - if ((nDataBufBitCnt % 8) != 0) - panic("HwThreeWire(): nDataBufBitCnt(%d) should be multiple of 8!!!\n", - nDataBufBitCnt); - - if (nDataBufBitCnt > 64) - panic("HwThreeWire(): nDataBufBitCnt(%d) should <= 64!!!\n", - nDataBufBitCnt); - - for(idx = 0; idx < ByteCnt; idx++) - { - *(pDataBuf+idx) = read_nic_byte(dev, (SW_3W_DB0+idx)); - } - } - } - - }while(0); - - return bResult; -} - 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; + u32 data2Write; + u8 len; - 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. - 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; - } -} - - -void -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; - u32 mask; - u8 u1bTmp; - ThreeWireReg tdata; - //PHAL_DATA_8187 pHalData = GetHalData8187(pAdapter); - { // 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); - } - - wReg80 = oval = read_nic_word(dev, RFPinsOutput); - oval2 = read_nic_word(dev, RFPinsEnable); - oval3 = read_nic_word(dev, RFPinsSelect); - - write_nic_word(dev, RFPinsEnable, oval2|0xf); - write_nic_word(dev, RFPinsSelect, oval3|0xf); - - *data2Read = 0; - - // We must clear BIT0-3 here, otherwise, - // SW_Enalbe will be true when we first call ZEBRA_RFSerialRead() after 8187MPVC open, - // which will cause the value read become 0. 2005.04.11, by rcnjko. - oval &= ~0xf; - - // Avoid collision with hardware three-wire. - twreg.longData = 0; - twreg.struc.enableB = 1; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(4); - - twreg.longData = 0; - twreg.struc.enableB = 0; - twreg.struc.clk = 0; - twreg.struc.read_write = 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(5); - - mask = (low2high) ? 0x01 : ((u32)0x01<<(32-1)); - for(i = 0; i < wLength/2; i++) - { - twreg.struc.data = ((data2Write&mask) != 0) ? 1 : 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(1); - twreg.struc.clk = 1; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - - mask = (low2high) ? (mask<<1): (mask>>1); - - if(i == 2) - { - // Commented out by Jackie, 2004.08.26. <RJ_NOTE> We must comment out the following two lines for we cannot pull down VCOPDN during RF Serail Read. - //PlatformEFIOWrite2Byte(pAdapter, RFPinsEnable, 0xe); // turn off data enable - //PlatformEFIOWrite2Byte(pAdapter, RFPinsSelect, 0xe); - - twreg.struc.read_write=1; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - twreg.struc.clk = 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - break; - } - twreg.struc.data = ((data2Write&mask) != 0) ? 1: 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - - twreg.struc.clk = 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(1); - - mask = (low2high) ? (mask<<1) : (mask>>1); - } - - twreg.struc.clk = 0; - twreg.struc.data = 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - mask = (low2high) ? 0x01 : ((u32)0x01 << (12-1)); - - // - // 061016, by rcnjko: - // We must set data pin to HW controled, otherwise RF can't driver it and - // value RF register won't be able to read back properly. - // - write_nic_word(dev, RFPinsEnable, ( ((oval2|0x0E) & (~0x01))) ); + /* Pure HW 3-wire. */ + data2Write = (data << 4) | (u32)(offset & 0x0f); + len = 16; - for(i = 0; i < rLength; i++) - { - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(1); - twreg.struc.clk = 1; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - tmp = read_nic_word(dev, RFPinsInput); - tdata.longData = tmp; - *data2Read |= tdata.struc.clk ? mask : 0; - - twreg.struc.clk = 0; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - - mask = (low2high) ? (mask<<1) : (mask>>1); - } - twreg.struc.enableB = 1; - twreg.struc.clk = 0; - twreg.struc.data = 0; - twreg.struc.read_write = 1; - write_nic_word(dev, RFPinsOutput, twreg.longData|oval); udelay(2); - - //PlatformEFIOWrite2Byte(pAdapter, RFPinsEnable, oval2|0x8); // Set To Output Enable - write_nic_word(dev, RFPinsEnable, oval2); // Set To Output Enable, <RJ_NOTE> We cannot enable BIT3 here, otherwise, we will failed to switch channel. 2005.04.12. - //PlatformEFIOWrite2Byte(pAdapter, RFPinsEnable, 0x1bff); - write_nic_word(dev, RFPinsSelect, oval3); // Set To SW Switch - //PlatformEFIOWrite2Byte(pAdapter, RFPinsSelect, 0x0488); - write_nic_word(dev, RFPinsOutput, 0x3a0); - //PlatformEFIOWrite2Byte(pAdapter, RFPinsOutput, 0x0480); + HwHSSIThreeWire(dev, (u8 *)(&data2Write), len, 1, 1); } - -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; + u32 data2Write; + u8 wlen; + 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; } @@ -1043,15 +565,12 @@ ZEBRA_Config_85BASIC_HardCode( // Page0 : reg0-reg15 -// RF_WriteReg(dev, 0x00, 0x003f); mdelay(1);//1 RF_WriteReg(dev, 0x00, 0x009f); mdelay(1);// 1 RF_WriteReg(dev, 0x01, 0x06e0); mdelay(1); -// RF_WriteReg(dev, 0x02, 0x004c); mdelay(1);//2 RF_WriteReg(dev, 0x02, 0x004d); mdelay(1);// 2 -// RF_WriteReg(dev, 0x03, 0x0000); mdelay(1);//3 RF_WriteReg(dev, 0x03, 0x07f1); mdelay(1);// 3 RF_WriteReg(dev, 0x04, 0x0975); mdelay(1); @@ -1080,8 +599,6 @@ ZEBRA_Config_85BASIC_HardCode( RF_WriteReg(dev, 0x07, 0x01A0); mdelay(1); // Don't write RF23/RF24 to make a difference between 87S C cut and D cut. asked by SD3 stevenl. -// RF_WriteReg(dev, 0x08, 0x0597); mdelay(1); -// RF_WriteReg(dev, 0x09, 0x050a); mdelay(1); RF_WriteReg(dev, 0x0a, 0x0001); mdelay(1); RF_WriteReg(dev, 0x0b, 0x0418); mdelay(1); @@ -1097,7 +614,6 @@ ZEBRA_Config_85BASIC_HardCode( RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1); -// RF_WriteReg(dev, 0x00, 0x017f); mdelay(1);//6 RF_WriteReg(dev, 0x00, 0x01d7); mdelay(1);// 6 RF_WriteReg(dev, 0x03, 0x0e00); mdelay(1); @@ -1106,20 +622,14 @@ ZEBRA_Config_85BASIC_HardCode( { RF_WriteReg(dev, 0x01, i); mdelay(1); RF_WriteReg(dev, 0x02, ZEBRA_RF_RX_GAIN_TABLE[i]); mdelay(1); - //DbgPrint("RF - 0x%x = 0x%x", i, ZEBRA_RF_RX_GAIN_TABLE[i]); } RF_WriteReg(dev, 0x05, 0x0203); mdelay(1); /// 203, 343 - //RF_WriteReg(dev, 0x06, 0x0300); mdelay(1); // 400 RF_WriteReg(dev, 0x06, 0x0200); mdelay(1); // 400 RF_WriteReg(dev, 0x00, 0x0137); mdelay(1); // switch to reg16-reg30, and HSSI disable 137 mdelay(10); // Deay 10 ms. //0xfd -// RF_WriteReg(dev, 0x0c, 0x09be); mdelay(1); // 7 - //RF_WriteReg(dev, 0x0c, 0x07be); mdelay(1); - //mdelay(10); // Deay 10 ms. //0xfd - RF_WriteReg(dev, 0x0d, 0x0008); mdelay(1); // Z4 synthesizer loop filter setting, 392 mdelay(10); // Deay 10 ms. //0xfd @@ -1165,10 +675,8 @@ ZEBRA_Config_85BASIC_HardCode( RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1); } //by amy 080312 -// RF_WriteReg(dev, 0x0f, 0x0acc); mdelay(1); //-by amy 080312 RF_WriteReg(dev, 0x00, 0x00bf); mdelay(1); // switch to reg0-reg15, and HSSI enable -// RF_WriteReg(dev, 0x0d, 0x009f); mdelay(1); // Rx BB start calibration, 00c//-edward RF_WriteReg(dev, 0x0d, 0x08df); mdelay(1); // Rx BB start calibration, 00c//+edward RF_WriteReg(dev, 0x02, 0x004d); mdelay(1); // temperature meter off RF_WriteReg(dev, 0x04, 0x0975); mdelay(1); // Rx mode @@ -1217,13 +725,10 @@ ZEBRA_Config_85BASIC_HardCode( // AGC.txt //============================================================================= -// PlatformIOWrite4Byte( dev, PhyAddr, 0x00001280); // Annie, 2006-05-05 write_phy_ofdm(dev, 0x00, 0x12); - //WriteBBPortUchar(dev, 0x00001280); for (i=0; i<128; i++) { - //DbgPrint("AGC - [%x+1] = 0x%x\n", i, ZEBRA_AGC[i+1]); data = ZEBRA_AGC[i+1]; data = data << 8; @@ -1239,7 +744,6 @@ ZEBRA_Config_85BASIC_HardCode( } PlatformIOWrite4Byte( dev, PhyAddr, 0x00001080); // Annie, 2006-05-05 - //WriteBBPortUchar(dev, 0x00001080); //============================================================================= @@ -1252,8 +756,6 @@ ZEBRA_Config_85BASIC_HardCode( u4bRegOffset=i; u4bRegValue=OFDM_CONFIG[i]; - //DbgPrint("OFDM - 0x%x = 0x%x\n", u4bRegOffset, u4bRegValue); - WriteBBPortUchar(dev, (0x00000080 | (u4bRegOffset & 0x7f) | @@ -1277,9 +779,6 @@ UpdateInitialGain( ) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //unsigned char* IGTable; - //u8 DIG_CurrentInitialGain = 4; - //unsigned char u1Tmp; //lzm add 080826 if(priv->eRFPowerState != eRfOn) @@ -1291,81 +790,59 @@ 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"); - 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"); - 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"); - 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"); - 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; + 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 5: //m82dBm - //DMESG("RTL8187 + 8225 Initial Gain State 5: -74 dBm \n"); - 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 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 6: //m78dBm - //DMESG ("RTL8187 + 8225 Initial Gain State 6: -70 dBm \n"); - 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 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 7: //m74dBm - //DMESG("RTL8187 + 8225 Initial Gain State 7: -66 dBm \n"); - 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 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 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; + 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 */ + 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; - default: //MP - //DMESG("RTL8187 + 8225 Initial Gain State 1: -82 dBm (default)\n"); - 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 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: + 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: - DMESG("UpdateInitialGain(): unknown RFChipID: %#X\n", priv->rf_chip); + 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; } } @@ -1379,13 +856,11 @@ InitTxPwrTracking87SE( struct net_device *dev ) { - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u32 u4bRfReg; u4bRfReg = RF_ReadReg(dev, 0x02); // Enable Thermal meter indication. - //printk("InitTxPwrTracking87SE(): Enable thermal meter indication, Write RF[0x02] = %#x", u4bRfReg|PWR_METER_EN); RF_WriteReg(dev, 0x02, u4bRfReg|PWR_METER_EN); mdelay(1); } @@ -1397,21 +872,14 @@ 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) { if(priv->InitialGain == 0) priv->InitialGain = 4; - //printk("PhyConfig8185(): DIG is enabled, set default initial gain index to %d\n", priv->InitialGain); } // @@ -1429,34 +897,17 @@ PhyConfig8185( return; } - - - void HwConfigureRTL8185( struct net_device *dev ) { //RTL8185_TODO: Determine Retrylimit, TxAGC, AutoRateFallback control. -// u8 bUNIVERSAL_CONTROL_RL = 1; u8 bUNIVERSAL_CONTROL_RL = 0; - u8 bUNIVERSAL_CONTROL_AGC = 1; u8 bUNIVERSAL_CONTROL_ANT = 1; u8 bAUTO_RATE_FALLBACK_CTL = 1; u8 val8; - //struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //struct ieee80211_device *ieee = priv->ieee80211; - //if(IS_WIRELESS_MODE_A(dev) || IS_WIRELESS_MODE_G(dev)) -//{by amy 080312 if((ieee->mode == IEEE_G)||(ieee->mode == IEEE_A)) -// { -// write_nic_word(dev, BRSR, 0xffff); -// } -// else -// { -// write_nic_word(dev, BRSR, 0x000f); -// } -//by amy 080312} write_nic_word(dev, BRSR, 0x0fff); // Retry limit val8 = read_nic_byte(dev, CW_CONF); @@ -1507,20 +958,11 @@ HwConfigureRTL8185( val8 |= RATE_FALLBACK_CTL_ENABLE | RATE_FALLBACK_CTL_AUTO_STEP1; // <RJ_TODO_8185B> We shall set up the ARFR according to user's setting. - //write_nic_word(dev, ARFR, 0x0fff); // set 1M ~ 54M -//by amy - // Aadded by Roger, 2007.11.15. PlatformIOWrite2Byte(dev, ARFR, 0x0fff); //set 1M ~ 54Mbps. -//by amy - } - else - { } write_nic_byte(dev, RATE_FALLBACK, val8); } - - static void MacConfig_85BASIC_HardCode( struct net_device *dev) @@ -1548,14 +990,11 @@ MacConfig_85BASIC_HardCode( { u4bRegOffset |= (u4bPageIndex << 8); } - //DbgPrint("MAC - 0x%x = 0x%x\n", u4bRegOffset, u4bRegValue); write_nic_byte(dev, u4bRegOffset, (u8)u4bRegValue); } //============================================================================ } - - static void MacConfig_85BASIC( struct net_device *dev) @@ -1578,8 +1017,6 @@ MacConfig_85BASIC( PlatformIOWrite1Byte(dev, 0x1F8, 0x00); // Asked for by SD3 CM Lin, 2006.06.27, by rcnjko. - //PlatformIOWrite4Byte(dev, RFTiming, 0x00004001); -//by amy // power save parameter based on "87SE power save parameters 20071127.doc", as follow. //Enable DA10 TX power saving @@ -1598,35 +1035,18 @@ MacConfig_85BASIC( write_nic_word(dev, 0x378, 0x0560); write_nic_word(dev, 0x37A, 0x0560); write_nic_word(dev, 0x37C, 0x00EC); -// write_nic_word(dev, 0x37E, 0x00FE);//-edward write_nic_word(dev, 0x37E, 0x00EC);//+edward write_nic_byte(dev, 0x24E,0x01); -//by amy - } - - - u8 GetSupportedWirelessMode8185( struct net_device *dev ) { 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; - } + btSupportedWirelessMode = (WIRELESS_MODE_B | WIRELESS_MODE_G); return btSupportedWirelessMode; } @@ -1641,7 +1061,6 @@ ActUpdateChannelAccessSetting( struct ieee80211_device *ieee = priv->ieee80211; AC_CODING eACI; AC_PARAM AcParam; - //PSTA_QOS pStaQos = Adapter->MgntInfo.pStaQos; u8 bFollowLegacySetting = 0; u8 u1bAIFS; @@ -1663,40 +1082,14 @@ ActUpdateChannelAccessSetting( ChnlAccessSetting->CWmaxIndex = 7; // 2006.06.02, by rcnjko. write_nic_byte(dev, SIFS, ChnlAccessSetting->SIFS_Timer); - //Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_SLOT_TIME, &ChnlAccessSetting->SlotTimeTimer ); // Rewrited from directly use PlatformEFIOWrite1Byte(), by Annie, 2006-03-29. write_nic_byte(dev, SLOT, ChnlAccessSetting->SlotTimeTimer); // Rewrited from directly use PlatformEFIOWrite1Byte(), by Annie, 2006-03-29. u1bAIFS = aSifsTime + (2 * ChnlAccessSetting->SlotTimeTimer ); - //write_nic_byte(dev, AC_VO_PARAM, u1bAIFS); - //write_nic_byte(dev, AC_VI_PARAM, u1bAIFS); - //write_nic_byte(dev, AC_BE_PARAM, u1bAIFS); - //write_nic_byte(dev, AC_BK_PARAM, u1bAIFS); - write_nic_byte(dev, EIFS, ChnlAccessSetting->EIFS_Timer); write_nic_byte(dev, AckTimeOutReg, 0x5B); // <RJ_EXPR_QOS> Suggested by wcchu, it is the default value of EIFS register, 2005.12.08. -#ifdef TODO - // <RJ_TODO_NOW_8185B> Update ECWmin/ECWmax, AIFS, TXOP Limit of each AC to the value defined by SPEC. - if( pStaQos->CurrentQosMode > QOS_DISABLE ) - { // QoS mode. - if(pStaQos->QBssWirelessMode == WirelessMode) - { - // Follow AC Parameters of the QBSS. - for(eACI = 0; eACI < AC_MAX; eACI++) - { - Adapter->HalFunc.SetHwRegHandler(Adapter, HW_VAR_AC_PARAM, (pu1Byte)(&(pStaQos->WMMParamEle.AcParam[eACI])) ); - } - } - else - { - // Follow Default WMM AC Parameters. - bFollowLegacySetting = 1; - } - } - else -#endif { // Legacy 802.11. bFollowLegacySetting = 1; @@ -1719,14 +1112,12 @@ ActUpdateChannelAccessSetting( AcParam.f.TXOPLimit = 0; //lzm reserved 080826 -#if 1 // For turbo mode setting. port from 87B by Isaiah 2008-08-01 if( ieee->current_network.Turbo_Enable == 1 ) AcParam.f.TXOPLimit = 0x01FF; // For 87SE with Intel 4965 Ad-Hoc mode have poor throughput (19MB) if (ieee->iw_mode == IW_MODE_ADHOC) AcParam.f.TXOPLimit = 0x0020; -#endif for(eACI = 0; eACI < AC_MAX; eACI++) { @@ -1770,18 +1161,13 @@ ActUpdateChannelAccessSetting( // Cehck ACM bit. // If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13. - //write_nic_byte(dev, ACM_CONTROL, pAcParam->f.AciAifsn); { PACI_AIFSN pAciAifsn = (PACI_AIFSN)(&pAcParam->f.AciAifsn); AC_CODING eACI = pAciAifsn->f.ACI; //modified Joseph //for 8187B AsynIORead issue -#ifdef TODO - u8 AcmCtrl = pHalData->AcmControl; -#else u8 AcmCtrl = 0; -#endif if( pAciAifsn->f.ACM ) { // ACM bit is 1. switch(eACI) @@ -1823,19 +1209,10 @@ ActUpdateChannelAccessSetting( break; } } - - //printk(KERN_WARNING "SetHwReg8185(): [HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl); - -#ifdef TO_DO - pHalData->AcmControl = AcmCtrl; -#endif - //write_nic_byte(dev, ACM_CONTROL, AcmCtrl); write_nic_byte(dev, ACM_CONTROL, 0); } } } - - } } @@ -1847,7 +1224,6 @@ ActSetWirelessMode8185( { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; - //PMGNT_INFO pMgntInfo = &(Adapter->MgntInfo); u8 btSupportedWirelessMode = GetSupportedWirelessMode8185(dev); if( (btWirelessMode & btSupportedWirelessMode) == 0 ) @@ -1880,24 +1256,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. - ieee->mode = (WIRELESS_MODE)btWirelessMode; - } - break; - - default: - DMESGW("ActSetWirelessMode8185(): unsupported RF: 0x%X !!!\n", priv->rf_chip); - break; - } + /* 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; // 3. Change related setting. if( ieee->mode == WIRELESS_MODE_A ){ @@ -1909,7 +1272,6 @@ ActSetWirelessMode8185( else if( ieee->mode == WIRELESS_MODE_G ){ DMESG("WIRELESS_MODE_G\n"); } - ActUpdateChannelAccessSetting( dev, ieee->mode, &priv->ChannelAccessSetting); } @@ -1927,11 +1289,7 @@ DrvIFIndicateDisassociation( u16 reason ) { - //printk("==> DrvIFIndicateDisassociation()\n"); - // nothing is needed after disassociation request. - - //printk("<== DrvIFIndicateDisassociation()\n"); } void MgntDisconnectIBSS( @@ -1941,11 +1299,7 @@ MgntDisconnectIBSS( struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); u8 i; - //printk("XXXXXXXXXX MgntDisconnect IBSS\n"); - DrvIFIndicateDisassociation(dev, unspec_reason); - -// PlatformZeroMemory( pMgntInfo->Bssid, 6 ); for(i=0;i<6;i++) priv->ieee80211->current_network.bssid[i] = 0x55; priv->ieee80211->state = IEEE80211_NOLINK; @@ -1957,16 +1311,10 @@ MgntDisconnectIBSS( // Because Bcn DMA isn't complete, mgnt queue would stuck until Bcn packet send. // Disable Beacon Queue Own bit, suggested by jong -// Adapter->HalFunc.SetTxDescOWNHandler(Adapter, BEACON_QUEUE, 0, 0); ieee80211_stop_send_beacons(priv->ieee80211); priv->ieee80211->link_change(dev); notify_wx_assoc_event(priv->ieee80211); - - // Stop SW Beacon.Use hw beacon so do not need to do so.by amy - -// MgntIndicateMediaStatus( Adapter, RT_MEDIA_DISCONNECT, GENERAL_INDICATE ); - } void MlmeDisassociateRequest( @@ -1986,14 +1334,8 @@ MlmeDisassociateRequest( DrvIFIndicateDisassociation(dev, unspec_reason); - // pMgntInfo->AsocTimestamp = 0; for(i=0;i<6;i++) priv->ieee80211->current_network.bssid[i] = 0x22; -// pMgntInfo->mBrates.Length = 0; -// Adapter->HalFunc.SetHwRegHandler( Adapter, HW_VAR_BASIC_RATE, (pu1Byte)(&pMgntInfo->mBrates) ); - ieee80211_disassociate(priv->ieee80211); - - } } @@ -2011,23 +1353,12 @@ MgntDisconnectAP( // I move SecClearAllKeys() to MgntActSet_802_11_DISASSOCIATE(). // // //2004/09/15, kcwu, the key should be cleared, or the new handshaking will not success -// SecClearAllKeys(Adapter); // In WPA WPA2 need to Clear all key ... because new key will set after new handshaking. -#ifdef TODO - if( pMgntInfo->SecurityInfo.AuthMode > RT_802_11AuthModeAutoSwitch || - (pMgntInfo->bAPSuportCCKM && pMgntInfo->bCCX8021xenable) ) // In CCKM mode will Clear key - { - SecClearAllKeys(Adapter); - RT_TRACE(COMP_SEC, DBG_LOUD,("======>CCKM clear key...")) - } -#endif // 2004.10.11, by rcnjko. - //MlmeDisassociateRequest( Adapter, pMgntInfo->Bssid, disas_lv_ss ); MlmeDisassociateRequest( dev, priv->ieee80211->current_network.bssid, asRsn ); priv->ieee80211->state = IEEE80211_NOLINK; -// pMgntInfo->AsocTimestamp = 0; } bool MgntDisconnect( @@ -2039,20 +1370,7 @@ MgntDisconnect( // // Schedule an workitem to wake up for ps mode, 070109, by rcnjko. // -#ifdef TODO - if(pMgntInfo->mPss != eAwake) - { - // - // Using AwkaeTimer to prevent mismatch ps state. - // In the timer the state will be changed according to the RF is being awoke or not. By Bruce, 2007-10-31. - // - // PlatformScheduleWorkItem( &(pMgntInfo->AwakeWorkItem) ); - PlatformSetTimer( Adapter, &(pMgntInfo->AwakeTimer), 0 ); - } -#endif - // Indication of disassociation event. - //DrvIFIndicateDisassociation(Adapter, asRsn); if(IS_DOT11D_ENABLE(priv->ieee80211)) Dot11d_Reset(priv->ieee80211); // In adhoc mode, update beacon frame. @@ -2060,8 +1378,6 @@ MgntDisconnect( { if( priv->ieee80211->iw_mode == IW_MODE_ADHOC ) { -// RT_TRACE(COMP_MLME, DBG_LOUD, ("MgntDisconnect() ===> MgntDisconnectIBSS\n")); - //printk("MgntDisconnect() ===> MgntDisconnectIBSS\n"); MgntDisconnectIBSS(dev); } if( priv->ieee80211->iw_mode == IW_MODE_INFRA ) @@ -2071,17 +1387,10 @@ MgntDisconnect( // e.g. OID_802_11_DISASSOCIATE in Windows while as MgntDisconnectAP() is // used to handle disassociation related things to AP, e.g. send Disassoc // frame to AP. 2005.01.27, by rcnjko. -// SecClearAllKeys(Adapter); - -// RT_TRACE(COMP_MLME, DBG_LOUD, ("MgntDisconnect() ===> MgntDisconnectAP\n")); - //printk("MgntDisconnect() ===> MgntDisconnectAP\n"); MgntDisconnectAP(dev, asRsn); } - // Inidicate Disconnect, 2005.02.23, by rcnjko. -// MgntIndicateMediaStatus( Adapter, RT_MEDIA_DISCONNECT, GENERAL_INDICATE); } - return true; } // @@ -2101,25 +1410,12 @@ SetRFPowerState( struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); bool bResult = false; -// printk("---------> SetRFPowerState(): eRFPowerState(%d)\n", eRFPowerState); if(eRFPowerState == priv->eRFPowerState) { -// printk("<--------- SetRFPowerState(): discard the request for eRFPowerState(%d) is the same.\n", eRFPowerState); 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); + bResult = SetZebraRFPowerState8185(dev, eRFPowerState); return bResult; } @@ -2149,33 +1445,25 @@ MgntActSet_RF_State( RT_RF_POWER_STATE rtState; u16 RFWaitCounter = 0; unsigned long flag; -// printk("===>MgntActSet_RF_State(): StateToSet(%d), ChangeSource(0x%x)\n",StateToSet, ChangeSource); // // Prevent the race condition of RF state change. By Bruce, 2007-11-28. // Only one thread can change the RF state at one time, and others should wait to be executed. // -#if 1 while(true) { -// down(&priv->rf_state); spin_lock_irqsave(&priv->rf_ps_lock,flag); if(priv->RFChangeInProgress) { -// printk("====================>haha111111111\n"); -// up(&priv->rf_state); -// RT_TRACE(COMP_RF, DBG_LOUD, ("MgntActSet_RF_State(): RF Change in progress! Wait to set..StateToSet(%d).\n", StateToSet)); spin_unlock_irqrestore(&priv->rf_ps_lock,flag); // Set RF after the previous action is done. while(priv->RFChangeInProgress) { RFWaitCounter ++; -// RT_TRACE(COMP_RF, DBG_LOUD, ("MgntActSet_RF_State(): Wait 1 ms (%d times)...\n", RFWaitCounter)); udelay(1000); // 1 ms // Wait too long, return FALSE to avoid to be stuck here. if(RFWaitCounter > 1000) // 1sec { -// RT_ASSERT(FALSE, ("MgntActSet_RF_State(): Wait too logn to set RF\n")); printk("MgntActSet_RF_State(): Wait too long to set RF\n"); // TODO: Reset RF state? return false; @@ -2184,17 +1472,13 @@ MgntActSet_RF_State( } else { -// printk("========================>haha2\n"); priv->RFChangeInProgress = true; -// up(&priv->rf_state); spin_unlock_irqrestore(&priv->rf_ps_lock,flag); break; } } -#endif rtState = priv->eRFPowerState; - switch(StateToSet) { case eRfOn: @@ -2215,7 +1499,6 @@ MgntActSet_RF_State( } } else -// RT_TRACE(COMP_RF, DBG_LOUD, ("MgntActSet_RF_State - eRfon reject pMgntInfo->RfOffReason= 0x%x, ChangeSource=0x%X\n", pMgntInfo->RfOffReason, ChangeSource)); ; break; @@ -2232,38 +1515,26 @@ MgntActSet_RF_State( // // Calling MgntDisconnect() instead of MgntActSet_802_11_DISASSOCIATE(), // because we do NOT need to set ssid to dummy ones. - // Revised by Roger, 2007.12.04. // MgntDisconnect( dev, disas_lv_ss ); // Clear content of bssDesc[] and bssDesc4Query[] to avoid reporting old bss to UI. - // 2007.05.28, by shien chang. -// PlatformZeroMemory( pMgntInfo->bssDesc, sizeof(RT_WLAN_BSS)*MAX_BSS_DESC ); -// pMgntInfo->NumBssDesc = 0; -// PlatformZeroMemory( pMgntInfo->bssDesc4Query, sizeof(RT_WLAN_BSS)*MAX_BSS_DESC ); -// pMgntInfo->NumBssDesc4Query = 0; } - - priv->RfOffReason |= ChangeSource; bActionAllowed = true; break; - case eRfSleep: priv->RfOffReason |= ChangeSource; bActionAllowed = true; break; - default: break; } if(bActionAllowed) { -// RT_TRACE(COMP_RF, DBG_LOUD, ("MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, pMgntInfo->RfOffReason)); // Config HW to the specified mode. -// printk("MgntActSet_RF_State(): Action is allowed.... StateToSet(%d), RfOffReason(%#X)\n", StateToSet, priv->RfOffReason); SetRFPowerState(dev, StateToSet); // Turn on RF. @@ -2273,7 +1544,6 @@ MgntActSet_RF_State( if(bConnectBySSID) { // by amy not supported -// MgntActSet_802_11_SSID(Adapter, Adapter->MgntInfo.Ssid.Octet, Adapter->MgntInfo.Ssid.Length, TRUE ); } } // Turn off RF. @@ -2282,18 +1552,11 @@ MgntActSet_RF_State( HalDisableRx8185Dummy(dev); } } - else - { - // printk("MgntActSet_RF_State(): Action is rejected.... StateToSet(%d), ChangeSource(%#X), RfOffReason(%#X)\n", StateToSet, ChangeSource, priv->RfOffReason); - } // Release RF spinlock -// down(&priv->rf_state); spin_lock_irqsave(&priv->rf_ps_lock,flag); priv->RFChangeInProgress = false; -// up(&priv->rf_state); spin_unlock_irqrestore(&priv->rf_ps_lock,flag); -// printk("<===MgntActSet_RF_State()\n"); return bActionAllowed; } void @@ -2302,15 +1565,12 @@ InactivePowerSave( ) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - //u8 index = 0; - // // This flag "bSwRfProcessing", indicates the status of IPS procedure, should be set if the IPS workitem // is really scheduled. // The old code, sets this flag before scheduling the IPS workitem and however, at the same time the // previous IPS workitem did not end yet, fails to schedule the current workitem. Thus, bSwRfProcessing // blocks the IPS procedure of switching RF. - // By Bruce, 2007-12-25. // priv->bSwRfProcessing = true; @@ -2326,7 +1586,6 @@ InactivePowerSave( // // Description: // Enter the inactive power save mode. RF will be off -// 2007.08.17, by shien chang. // void IPSEnter( @@ -2335,13 +1594,11 @@ IPSEnter( { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); RT_RF_POWER_STATE rtState; - //printk("==============================>enter IPS\n"); if (priv->bInactivePs) { rtState = priv->eRFPowerState; // - // Added by Bruce, 2007-12-25. // Do not enter IPS in the following conditions: // (1) RF is already OFF or Sleep // (2) bSwRfProcessing (indicates the IPS is still under going) @@ -2352,12 +1609,10 @@ IPSEnter( if (rtState == eRfOn && !priv->bSwRfProcessing && (priv->ieee80211->state != IEEE80211_LINKED )) { - // printk("IPSEnter(): Turn off RF.\n"); priv->eInactivePowerState = eRfOff; InactivePowerSave(dev); } } -// printk("priv->eRFPowerState is %d\n",priv->eRFPowerState); } void IPSLeave( @@ -2366,20 +1621,17 @@ IPSLeave( { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); RT_RF_POWER_STATE rtState; - //printk("===================================>leave IPS\n"); if (priv->bInactivePs) { rtState = priv->eRFPowerState; if ((rtState == eRfOff || rtState == eRfSleep) && (!priv->bSwRfProcessing) && priv->RfOffReason <= RF_CHANGE_BY_IPS) { -// printk("IPSLeave(): Turn on RF.\n"); priv->eInactivePowerState = eRfOn; InactivePowerSave(dev); } } -// printk("priv->eRFPowerState is %d\n",priv->eRFPowerState); } -//by amy for power save + void rtl8185b_adapter_start(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); @@ -2388,75 +1640,45 @@ void rtl8185b_adapter_start(struct net_device *dev) u8 SupportedWirelessMode; u8 InitWirelessMode; u8 bInvalidWirelessMode = 0; - //int i; u8 tmpu8; - //u8 u1tmp,u2tmp; u8 btCR9346; u8 TmpU1b; u8 btPSR; - //rtl8180_rtx_disable(dev); -//{by amy 080312 write_nic_byte(dev,0x24e, (BIT5|BIT6|BIT0)); -//by amy 080312} rtl8180_reset(dev); priv->dma_poll_mask = 0; priv->dma_poll_stop_mask = 0; - //rtl8180_beacon_tx_disable(dev); - HwConfigureRTL8185(dev); - write_nic_dword(dev, MAC0, ((u32*)dev->dev_addr)[0]); write_nic_word(dev, MAC4, ((u32*)dev->dev_addr)[1] & 0xffff ); - write_nic_byte(dev, MSR, read_nic_byte(dev, MSR) & 0xf3); // default network type to 'No Link' - - //write_nic_byte(dev, BRSR, 0x0); // Set BRSR= 1M - write_nic_word(dev, BcnItv, 100); write_nic_word(dev, AtimWnd, 2); - - //PlatformEFIOWrite2Byte(dev, FEMR, 0xFFFF); PlatformIOWrite2Byte(dev, FEMR, 0xFFFF); - write_nic_byte(dev, WPA_CONFIG, 0); - MacConfig_85BASIC(dev); - // Override the RFSW_CTRL (MAC offset 0x272-0x273), 2006.06.07, by rcnjko. // BT_DEMO_BOARD type PlatformIOWrite2Byte(dev, RFSW_CTRL, 0x569a); -//by amy -//#ifdef CONFIG_RTL818X_S - // for jong required -// PlatformIOWrite2Byte(dev, RFSW_CTRL, 0x9a56); -//#endif -//by amy - //BT_QA_BOARD - //PlatformIOWrite2Byte(dev, RFSW_CTRL, 0x9a56); //----------------------------------------------------------------------------- // Set up PHY related. //----------------------------------------------------------------------------- // Enable Config3.PARAM_En to revise AnaaParm. write_nic_byte(dev, CR9346, 0xc0); // enable config register write -//by amy tmpu8 = read_nic_byte(dev, CONFIG3); write_nic_byte(dev, CONFIG3, (tmpu8 |CONFIG3_PARM_En) ); -//by amy // Turn on Analog power. // Asked for by William, otherwise, MAC 3-wire can't work, 2006.06.27, by rcnjko. write_nic_dword(dev, ANAPARAM2, ANAPARM2_ASIC_ON); write_nic_dword(dev, ANAPARAM, ANAPARM_ASIC_ON); -//by amy write_nic_word(dev, ANAPARAM3, 0x0010); -//by amy write_nic_byte(dev, CONFIG3, tmpu8); write_nic_byte(dev, CR9346, 0x00); -//{by amy 080312 for led // enable EEM0 and EEM1 in 9346CR btCR9346 = read_nic_byte(dev, CR9346); write_nic_byte(dev, CR9346, (btCR9346|0xC0) ); @@ -2474,7 +1696,6 @@ void rtl8185b_adapter_start(struct net_device *dev) // B-cut RF Radio on/off 5e[3]=0 btPSR = read_nic_byte(dev, PSR); write_nic_byte(dev, PSR, (btPSR | BIT3)); -//by amy 080312 for led} // setup initial timing for RFE. write_nic_word(dev, RFPinsOutput, 0x0480); SetOutputEnableOfRfPins(dev); @@ -2537,55 +1758,19 @@ void rtl8185b_adapter_start(struct net_device *dev) InitWirelessMode = ieee->mode; } //by amy for power save -// printk("initialize ENABLE_IPS\n"); priv->eRFPowerState = eRfOff; priv->RfOffReason = 0; { - // u32 tmp2; - // u32 tmp = jiffies; MgntActSet_RF_State(dev, eRfOn, 0); - // tmp2 = jiffies; - // printk("rf on cost jiffies:%lx\n", (tmp2-tmp)*1000/HZ); } -// DrvIFIndicateCurrentPhyStatus(priv); // // If inactive power mode is enabled, disable rf while in disconnected state. - // 2007.07.16, by shien chang. // if (priv->bInactivePs) { - // u32 tmp2; - // u32 tmp = jiffies; MgntActSet_RF_State(dev,eRfOff, RF_CHANGE_BY_IPS); - // tmp2 = jiffies; - // printk("rf off cost jiffies:%lx\n", (tmp2-tmp)*1000/HZ); - } -// IPSEnter(dev); //by amy for power save -#ifdef TODO - // Turn off RF if necessary. 2005.08.23, by rcnjko. - // We shall turn off RF after setting CMDR, otherwise, - // RF will be turnned on after we enable MAC Tx/Rx. - if(Adapter->MgntInfo.RegRfOff == TRUE) - { - SetRFPowerState8185(Adapter, RF_OFF); - } - else - { - SetRFPowerState8185(Adapter, RF_ON); - } -#endif - -/* //these is equal with above TODO. - write_nic_byte(dev, CR9346, 0xc0); // enable config register write - write_nic_byte(dev, CONFIG3, read_nic_byte(dev, CONFIG3) | CONFIG3_PARM_En); - RF_WriteReg(dev, 0x4, 0x9FF); - write_nic_dword(dev, ANAPARAM2, ANAPARM2_ASIC_ON); - write_nic_dword(dev, ANAPARAM, ANAPARM_ASIC_ON); - write_nic_byte(dev, CONFIG3, (read_nic_byte(dev, CONFIG3)&(~CONFIG3_PARM_En))); - write_nic_byte(dev, CR9346, 0x00); -*/ ActSetWirelessMode8185(dev, (u8)(InitWirelessMode)); @@ -2594,14 +1779,11 @@ void rtl8185b_adapter_start(struct net_device *dev) rtl8185b_irq_enable(dev); netif_start_queue(dev); - } - void rtl8185b_rx_enable(struct net_device *dev) { u8 cmd; - //u32 rxconf; /* for now we accept data, management & ctl frame*/ struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); @@ -2613,11 +1795,6 @@ void rtl8185b_rx_enable(struct net_device *dev) priv->ReceiveConfig = priv->ReceiveConfig | RCR_AAP; } - /*if(priv->ieee80211->iw_mode == IW_MODE_MASTER){ - rxconf = rxconf | (1<<ACCEPT_ALLMAC_FRAME_SHIFT); - rxconf = rxconf | (1<<RX_CHECK_BSSID_SHIFT); - }*/ - if(priv->ieee80211->iw_mode == IW_MODE_MONITOR){ priv->ReceiveConfig = priv->ReceiveConfig | RCR_ACF | RCR_APWRMGT | RCR_AICV; } @@ -2629,9 +1806,6 @@ void rtl8185b_rx_enable(struct net_device *dev) fix_rx_fifo(dev); -#ifdef DEBUG_RX - DMESG("rxconf: %x %x",priv->ReceiveConfig ,read_nic_dword(dev,RCR)); -#endif cmd=read_nic_byte(dev,CMD); write_nic_byte(dev,CMD,cmd | (1<<CMD_RX_ENABLE_SHIFT)); @@ -2640,9 +1814,7 @@ void rtl8185b_rx_enable(struct net_device *dev) void rtl8185b_tx_enable(struct net_device *dev) { u8 cmd; - //u8 tx_agc_ctl; u8 byte; - //u32 txconf; struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); write_nic_dword(dev, TCR, priv->TransmitConfig); @@ -2652,21 +1824,7 @@ void rtl8185b_tx_enable(struct net_device *dev) fix_tx_fifo(dev); -#ifdef DEBUG_TX - DMESG("txconf: %x %x",priv->TransmitConfig,read_nic_dword(dev,TCR)); -#endif - cmd=read_nic_byte(dev,CMD); write_nic_byte(dev,CMD,cmd | (1<<CMD_TX_ENABLE_SHIFT)); - - //write_nic_dword(dev,TX_CONF,txconf); - - -/* - rtl8180_set_mode(dev,EPROM_CMD_CONFIG); - write_nic_byte(dev, TX_DMA_POLLING, priv->dma_poll_mask); - rtl8180_set_mode(dev,EPROM_CMD_NORMAL); - */ } - |