-
-void rtl8225_rf_sleep(struct net_device *dev)
-{
- write_rtl8225(dev,0x4,0xdff);
- force_pci_posting(dev);
- mdelay(1);
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_SLEEP);
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_SLEEP);
- force_pci_posting(dev);
-}
-
-void rtl8225_rf_wakeup(struct net_device *dev)
-{
- write_rtl8225(dev,0x4,0x9ff);
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
- rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
- force_pci_posting(dev);
-}
-
-void rtl8225_rf_init(struct net_device *dev)
-{
- struct r8180_priv *priv = ieee80211_priv(dev);
- int i;
- short channel = 1;
- u16 brsr;
-
- priv->chan = channel;
-
- rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-
-
- if(priv->card_type == USB)
- rtl8225_host_usb_init(dev);
- else
- rtl8225_host_pci_init(dev);
-
- write_nic_dword(dev, RF_TIMING, 0x000a8008);
-
- brsr = read_nic_word(dev, BRSR);
-
- write_nic_word(dev, BRSR, 0xffff);
-
- write_nic_dword(dev, RF_PARA, 0x100044);
-
- #if 1 //0->1
- rtl8180_set_mode(dev, EPROM_CMD_CONFIG);
- write_nic_byte(dev, CONFIG3, 0x44);
- rtl8180_set_mode(dev, EPROM_CMD_NORMAL);
- #endif
-
- if(priv->card_type == USB){
- rtl8185_rf_pins_enable(dev);
-
- mdelay(1000);
- }
-
- write_rtl8225(dev, 0x0, 0x67); mdelay(1);
-
-
- write_rtl8225(dev, 0x1, 0xfe0); mdelay(1);
-
- write_rtl8225(dev, 0x2, 0x44d); mdelay(1);
-
- write_rtl8225(dev, 0x3, 0x441); mdelay(1);
-
- if(priv->card_type == USB)
- write_rtl8225(dev, 0x4, 0x486);
- else
- write_rtl8225(dev, 0x4, 0x8be);
-
- mdelay(1);
-
- /* version B & C */
-
- if(priv->card_type == USB)
- write_rtl8225(dev, 0x5, 0xbc0);
- else if(priv->card_type == MINIPCI)
- write_rtl8225(dev, 0x5, 0xbc0 + 3 +(6<<3));
- else
- write_rtl8225(dev, 0x5, 0xbc0 + (6<<3));
-
- mdelay(1);
-// }
-
- write_rtl8225(dev, 0x6, 0xae6); mdelay(1);
-
- write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1);
-
- write_rtl8225(dev, 0x8, 0x1f); mdelay(1);
-
- write_rtl8225(dev, 0x9, 0x334); mdelay(1);
-
- write_rtl8225(dev, 0xa, 0xfd4); mdelay(1);
-
- write_rtl8225(dev, 0xb, 0x391); mdelay(1);
-
- write_rtl8225(dev, 0xc, 0x50); mdelay(1);
-
-
- write_rtl8225(dev, 0xd, 0x6db); mdelay(1);
-
- write_rtl8225(dev, 0xe, 0x29); mdelay(1);
-
- write_rtl8225(dev, 0xf, 0x914);
-
- if(priv->card_type == USB){
- //force_pci_posting(dev);
- mdelay(100);
- }
-
- write_rtl8225(dev, 0x2, 0xc4d);
-
- if(priv->card_type == USB){
- // force_pci_posting(dev);
- mdelay(200);
-
- write_rtl8225(dev, 0x2, 0x44d);
-
- // force_pci_posting(dev);
- mdelay(100);
-
- }//End of if(priv->card_type == USB)
- /* FIXME!! rtl8187 we have to check if calibrarion
- * is successful and eventually cal. again (repeat
- * the two write on reg 2)
- */
- force_pci_posting(dev);
-
- mdelay(100); //200 for 8187
-
- //if(priv->card_type != USB) /* maybe not needed even for 8185 */
-// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
-
- write_rtl8225(dev, 0x0, 0x127);
-
- for(i=0;i<95;i++){
- write_rtl8225(dev, 0x1, (u8)(i+1));
-
- /* version B & C & D*/
-
- write_rtl8225(dev, 0x2, rtl8225bcd_rxgain[i]);
- }
-
- write_rtl8225(dev, 0x0, 0x27);
-
-
-// //if(priv->card_type != USB){
-// write_rtl8225(dev, 0x2, 0x44d);
-// write_rtl8225(dev, 0x7, rtl8225_chan[channel]);
-// write_rtl8225(dev, 0x2, 0x47d);
-//
-// force_pci_posting(dev);
-// mdelay(100);
-//
-// write_rtl8225(dev, 0x2, 0x44d);
-// //}
-
- write_rtl8225(dev, 0x0, 0x22f);
-
- if(priv->card_type != USB)
- rtl8185_rf_pins_enable(dev);
-
- for(i=0;i<128;i++){
- write_phy_ofdm(dev, 0xb, rtl8225_agc[i]);
-
- mdelay(1);
- write_phy_ofdm(dev, 0xa, (u8)i+ 0x80);
-
- mdelay(1);
- }
-
- force_pci_posting(dev);
- mdelay(1);
-
- write_phy_ofdm(dev, 0x0, 0x1); mdelay(1);
- write_phy_ofdm(dev, 0x1, 0x2); mdelay(1);
- write_phy_ofdm(dev, 0x2, ((priv->card_type == USB)? 0x42 : 0x62)); mdelay(1);
- write_phy_ofdm(dev, 0x3, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x4, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x5, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x6, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x7, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x8, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x9, 0xfe); mdelay(1);
-
- /* ver C & D */
- write_phy_ofdm(dev, 0xa, 0x9); mdelay(1);
-
- //write_phy_ofdm(dev, 0x18, 0xef);
- // }
- //}
- write_phy_ofdm(dev, 0xb, 0x80); mdelay(1);
-
- write_phy_ofdm(dev, 0xc, 0x1);mdelay(1);
-
-
- //if(priv->card_type != USB)
- //write_phy_ofdm(dev, 0xd, 0x33); // <>
-
- write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1);
-
-
- write_phy_ofdm(dev, 0xf, 0x38);mdelay(1);
-/*ver D & 8187*/
-// }
-
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion)
-// write_phy_ofdm(dev, 0x10, 0x04);/*ver B*/
-// else
- write_phy_ofdm(dev, 0x10, 0x84);mdelay(1);
-/*ver C & D & 8187*/
-
- write_phy_ofdm(dev, 0x11, 0x06);mdelay(1);
-/*agc resp time 700*/
-
-
-// if(priv->card_8185 == 2){
- /* Ver D & 8187*/
- write_phy_ofdm(dev, 0x12, 0x20);mdelay(1);
-
- write_phy_ofdm(dev, 0x13, 0x20);mdelay(1);
-
- write_phy_ofdm(dev, 0x14, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x15, 0x40); mdelay(1);
- write_phy_ofdm(dev, 0x16, 0x0); mdelay(1);
- write_phy_ofdm(dev, 0x17, 0x40); mdelay(1);
-
-// if (priv->card_type == USB)
-// write_phy_ofdm(dev, 0x18, 0xef);
-
- write_phy_ofdm(dev, 0x18, 0xef);mdelay(1);
-
-
- write_phy_ofdm(dev, 0x19, 0x19); mdelay(1);
- write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1);
-
-// if (priv->card_type != USB){
-// if(priv->card_8185 == 1 && priv->card_8185_Bversion)
-// write_phy_ofdm(dev, 0x1b, 0x66); /* Ver B */
-// else
- write_phy_ofdm(dev, 0x1b, 0x76);mdelay(1);
- /* Ver C & D */ //FIXME:MAYBE not needed
-// }
-
- write_phy_ofdm(dev, 0x1c, 0x4);mdelay(1);
-
- /*ver D & 8187*/
- write_phy_ofdm(dev, 0x1e, 0x95);mdelay(1);
-
- write_phy_ofdm(dev, 0x1f, 0x75); mdelay(1);
-
-// }
-
- write_phy_ofdm(dev, 0x20, 0x1f);mdelay(1);
-
- write_phy_ofdm(dev, 0x21, 0x27);mdelay(1);
-
- write_phy_ofdm(dev, 0x22, 0x16);mdelay(1);
-
-// if(priv->card_type != USB)
- //write_phy_ofdm(dev, 0x23, 0x43); //FIXME maybe not needed // <>
-
- write_phy_ofdm(dev, 0x24, 0x46); mdelay(1);
- write_phy_ofdm(dev, 0x25, 0x20); mdelay(1);
- write_phy_ofdm(dev, 0x26, 0x90); mdelay(1);
- write_phy_ofdm(dev, 0x27, 0x88); mdelay(1);
-/* Ver C & D & 8187*/
-
- // <> Set init. gain to m74dBm.
- write_phy_ofdm(dev, 0x0d, 0x43); mdelay(1);
- write_phy_ofdm(dev, 0x1b, 0x76); mdelay(1);
- write_phy_ofdm(dev, 0x1d, 0xc5); mdelay(1);
- write_phy_ofdm(dev, 0x23, 0x78); mdelay(1);
-
- //if(priv->card_type == USB);
- // rtl8225_set_gain_usb(dev, 1); /* FIXME this '2' is random */
-
- write_phy_cck(dev, 0x0, 0x98); mdelay(1);
- write_phy_cck(dev, 0x3, 0x20); mdelay(1);
- write_phy_cck(dev, 0x4, 0x7e); mdelay(1);
- write_phy_cck(dev, 0x5, 0x12); mdelay(1);
- write_phy_cck(dev, 0x6, 0xfc); mdelay(1);
- write_phy_cck(dev, 0x7, 0x78);mdelay(1);
- /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x8, 0x2e);mdelay(1);
-
- write_phy_cck(dev, 0x10, ((priv->card_type == USB) ? 0x9b: 0x93)); mdelay(1);
- write_phy_cck(dev, 0x11, 0x88); mdelay(1);
- write_phy_cck(dev, 0x12, 0x47); mdelay(1);
- write_phy_cck(dev, 0x13, 0xd0); /* Ver C & D & 8187*/
-
- write_phy_cck(dev, 0x19, 0x0);
- write_phy_cck(dev, 0x1a, 0xa0);
- write_phy_cck(dev, 0x1b, 0x8);
- write_phy_cck(dev, 0x40, 0x86); /* CCK Carrier Sense Threshold */
-
- write_phy_cck(dev, 0x41, 0x8d);mdelay(1);
-
-
- write_phy_cck(dev, 0x42, 0x15); mdelay(1);
- write_phy_cck(dev, 0x43, 0x18); mdelay(1);
- write_phy_cck(dev, 0x44, 0x1f); mdelay(1);
- write_phy_cck(dev, 0x45, 0x1e); mdelay(1);
- write_phy_cck(dev, 0x46, 0x1a); mdelay(1);
- write_phy_cck(dev, 0x47, 0x15); mdelay(1);
- write_phy_cck(dev, 0x48, 0x10); mdelay(1);
- write_phy_cck(dev, 0x49, 0xa); mdelay(1);
- write_phy_cck(dev, 0x4a, 0x5); mdelay(1);
- write_phy_cck(dev, 0x4b, 0x2); mdelay(1);
- write_phy_cck(dev, 0x4c, 0x5);mdelay(1);
-
-
- write_nic_byte(dev, 0x5b, 0x0d); mdelay(1);
-
-
-
-// <>
-// // TESTR 0xb 8187
-// write_phy_cck(dev, 0x10, 0x93);// & 0xfb);
-//
-// //if(priv->card_type != USB){
-// write_phy_ofdm(dev, 0x2, 0x62);
-// write_phy_ofdm(dev, 0x6, 0x0);
-// write_phy_ofdm(dev, 0x8, 0x0);
-// //}
-
- rtl8225_SetTXPowerLevel(dev, channel);
-
- write_phy_cck(dev, 0x10, 0x9b); mdelay(1); /* Rx ant A, 0xdb for B */
- write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* Rx ant A, 0x10 for B */
-
- rtl8185_tx_antenna(dev, 0x3); /* TX ant A, 0x0 for B */
-
- /* switch to high-speed 3-wire
- * last digit. 2 for both cck and ofdm
- */
- if(priv->card_type == USB)
- write_nic_dword(dev, 0x94, 0x3dc00002);
- else{
- write_nic_dword(dev, 0x94, 0x15c00002);
- rtl8185_rf_pins_enable(dev);
- }
-
-// if(priv->card_type != USB)
-// rtl8225_set_gain(dev, 4); /* FIXME this '1' is random */ // <>
-// rtl8225_set_mode(dev, 1); /* FIXME start in B mode */ // <>
-//
-// /* make sure is waken up! */
-// write_rtl8225(dev,0x4, 0x9ff);
-// rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON);
-// rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_ON);
-
- rtl8225_rf_set_chan(dev, priv->chan);
-
- write_nic_word(dev,BRSR,brsr);
-
-}