From aa6f5ffbdba45aa8e19e5048648fc6c7b25376d3 Mon Sep 17 00:00:00 2001 From: merge Date: Thu, 22 Jan 2009 13:55:32 +0000 Subject: MERGE-via-pending-tracking-hist-MERGE-via-stable-tracking-MERGE-via-mokopatches-tracking-fix-stray-endmenu-patch-1232632040-1232632141 pending-tracking-hist top was MERGE-via-stable-tracking-MERGE-via-mokopatches-tracking-fix-stray-endmenu-patch-1232632040-1232632141 / fdf777a63bcb59e0dfd78bfe2c6242e01f6d4eb9 ... parent commitmessage: From: merge MERGE-via-stable-tracking-hist-MERGE-via-mokopatches-tracking-fix-stray-endmenu-patch-1232632040 stable-tracking-hist top was MERGE-via-mokopatches-tracking-fix-stray-endmenu-patch-1232632040 / 90463bfd2d5a3c8b52f6e6d71024a00e052b0ced ... parent commitmessage: From: merge MERGE-via-mokopatches-tracking-hist-fix-stray-endmenu-patch mokopatches-tracking-hist top was fix-stray-endmenu-patch / 3630e0be570de8057e7f8d2fe501ed353cdf34e6 ... parent commitmessage: From: Andy Green fix-stray-endmenu.patch Signed-off-by: Andy Green --- drivers/staging/rtl8187se/r8180_sa2400.c | 233 +++++++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 drivers/staging/rtl8187se/r8180_sa2400.c (limited to 'drivers/staging/rtl8187se/r8180_sa2400.c') diff --git a/drivers/staging/rtl8187se/r8180_sa2400.c b/drivers/staging/rtl8187se/r8180_sa2400.c new file mode 100644 index 00000000000..d6495601715 --- /dev/null +++ b/drivers/staging/rtl8187se/r8180_sa2400.c @@ -0,0 +1,233 @@ +/* + This files contains PHILIPS SA2400 radio frontend programming routines. + + This is part of rtl8180 OpenSource driver + Copyright (C) Andrea Merello 2004-2005 + 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. + + Code at http://che.ojctech.com/~dyoung/rtw/ has been useful to me to + understand some things. + + Code from rtl8181 project has been useful to me to understand some things. + + We want to tanks the Authors of such projects and the Ndiswrapper + project Authors. +*/ + + +#include "r8180.h" +#include "r8180_hw.h" +#include "r8180_sa2400.h" + + +//#define DEBUG_SA2400 + +u32 sa2400_chan[] = { + 0x0, //dummy channel 0 + 0x00096c, //1 + 0x080970, //2 + 0x100974, //3 + 0x180978, //4 + 0x000980, //5 + 0x080984, //6 + 0x100988, //7 + 0x18098c, //8 + 0x000994, //9 + 0x080998, //10 + 0x10099c, //11 + 0x1809a0, //12 + 0x0009a8, //13 + 0x0009b4, //14 +}; + + +void rf_stabilize(struct net_device *dev) +{ + force_pci_posting(dev); + mdelay(3); //for now use a great value.. we may optimize in future +} + + +void write_sa2400(struct net_device *dev,u8 adr, u32 data) +{ +// struct r8180_priv *priv = ieee80211_priv(dev); + u32 phy_config; + + // philips sa2400 expects 24 bits data + + /*if(adr == 4 && priv->digphy){ + phy_config=0x60000000; + }else{ + phy_config=0xb0000000; + }*/ + + phy_config = 0xb0000000; // MAC will bang bits to the sa2400 + + phy_config |= (((u32)(adr&0xf))<< 24); + phy_config |= (data & 0xffffff); + write_nic_dword(dev,PHY_CONFIG,phy_config); +#ifdef DEBUG_SA2400 + DMESG("Writing sa2400: %x (adr %x)",phy_config,adr); +#endif + rf_stabilize(dev); +} + + + +void sa2400_write_phy_antenna(struct net_device *dev,short ch) +{ + struct r8180_priv *priv = ieee80211_priv(dev); + u8 ant; + + ant = SA2400_ANTENNA; + if(priv->antb) /*default antenna is antenna B */ + ant |= BB_ANTENNA_B; + if(ch == 14) + ant |= BB_ANTATTEN_CHAN14; + write_phy(dev,0x10,ant); + //DMESG("BB antenna %x ",ant); +} + + +/* from the rtl8181 embedded driver */ +short sa2400_rf_set_sens(struct net_device *dev, short sens) +{ + u8 finetune = 0; + if ((sens > 85) || (sens < 54)) return -1; + + write_sa2400(dev,5,0x1dfb | (sens-54) << 15 |(finetune<<20)); // AGC 0xc9dfb + + return 0; +} + + +void sa2400_rf_set_chan(struct net_device *dev, short ch) +{ + struct r8180_priv *priv = ieee80211_priv(dev); + u32 txpw = 0xff & priv->chtxpwr[ch]; + u32 chan = sa2400_chan[ch]; + + write_sa2400(dev,7,txpw); + //write_phy(dev,0x10,0xd1); + sa2400_write_phy_antenna(dev,ch); + write_sa2400(dev,0,chan); + write_sa2400(dev,1,0xbb50); + write_sa2400(dev,2,0x80); + write_sa2400(dev,3,0); +} + + +void sa2400_rf_close(struct net_device *dev) +{ + write_sa2400(dev, 4, 0); +} + + +void sa2400_rf_init(struct net_device *dev) +{ + struct r8180_priv *priv = ieee80211_priv(dev); + u32 anaparam; + u8 firdac; + + write_nic_byte(dev,PHY_DELAY,0x6); //this is general + write_nic_byte(dev,CARRIER_SENSE_COUNTER,0x4c); //this is general + + /*these are philips sa2400 specific*/ + anaparam = read_nic_dword(dev,ANAPARAM); + anaparam = anaparam &~ (1<digphy){ + anaparam |= (SA2400_DIG_ANAPARAM_PWR1_ON<digphy) ? (1<chan]); + write_sa2400(dev,1,0xbb50); + write_sa2400(dev,2,0x80); + write_sa2400(dev,3,0); + write_sa2400(dev,4,0x19340 | firdac); + write_sa2400(dev,5,0xc9dfb); // AGC + write_sa2400(dev,4,0x19348 | firdac); //calibrates VCO + + if(priv->digphy) + write_sa2400(dev,4,0x1938c); /*???*/ + + write_sa2400(dev,4,0x19340 | firdac); + + write_sa2400(dev,0,sa2400_chan[priv->chan]); + write_sa2400(dev,1,0xbb50); + write_sa2400(dev,2,0x80); + write_sa2400(dev,3,0); + write_sa2400(dev,4,0x19344 | firdac); //calibrates filter + + /* new from rtl8180 embedded driver (rtl8181 project) */ + write_sa2400(dev,6,0x13ff | (1<<23)); // MANRX + write_sa2400(dev,8,0); //VCO + + if(!priv->digphy) + { + rtl8180_set_anaparam(dev, anaparam | \ + (1<chan); + + write_phy(dev,0x11,0x80); + if(priv->diversity) + write_phy(dev,0x12,0xc7); + else + write_phy(dev,0x12,0x47); + + write_phy(dev,0x13,0x90 | priv->cs_treshold ); + + write_phy(dev,0x19,0x0); + write_phy(dev,0x1a,0xa0); + + sa2400_rf_set_chan(dev,priv->chan); +} -- cgit v1.2.3