static void write_rtl8225(struct net_device *dev, u8 adr, u16 data) { int i; u16 out, select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; write_nic_word(dev, RFPinsEnable, (read_nic_word(dev, RFPinsEnable) | 0x7)); select = read_nic_word(dev, RFPinsSelect); write_nic_word(dev, RFPinsSelect, select | 0x7 | SW_CONTROL_GPIO); force_pci_posting(dev); udelay(10); write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); force_pci_posting(dev); udelay(2); write_nic_word(dev, RFPinsOutput, out); force_pci_posting(dev); udelay(10); for (i = 15; i >= 0; i--) { bit = (bangdata & (1 << i)) >> i; write_nic_word(dev, RFPinsOutput, bit | out); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1 << i)) >> i; write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); force_pci_posting(dev); udelay(10); write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); write_nic_word(dev, RFPinsSelect, select | SW_CONTROL_GPIO); rtl8185_rf_pins_enable(dev); }
static void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); rtl8185_rf_pins_enable(dev); write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); write_nic_byte(dev, GP_ENABLE, 0); force_pci_posting(dev); mdelay(200); /* bit 6 is for RF on/off detection */ write_nic_word(dev, GP_ENABLE, 0xff & (~(1 << 6))); }
void rtl8225_host_pci_init(struct net_device *dev) { write_nic_word(dev, RFPinsOutput, 0x480); rtl8185_rf_pins_enable(dev); //if(priv->card_8185 == 2 && priv->enable_gpio0 ) /* version D */ //write_nic_word(dev, RFPinsSelect, 0x88); //else write_nic_word(dev, RFPinsSelect, 0x88 | SW_CONTROL_GPIO); /* 0x488 | SW_CONTROL_GPIO */ write_nic_byte(dev, GP_ENABLE, 0); force_pci_posting(dev); mdelay(200); write_nic_word(dev, GP_ENABLE, 0xff & (~(1<<6))); /* bit 6 is for RF on/off detection */ }
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); #if 0 if(priv->card_8185 == 1){/* version C or B */ if(priv->card_8185_Bversion) /* version B*/ write_nic_dword(dev, RF_PARA, 0x44); else /* version C */ write_nic_dword(dev, RF_PARA, 0x100044); }else{ /* version D */ if(priv->enable_gpio0) write_nic_dword(dev, RF_PARA, 0x20100044); else /* also USB */ write_nic_dword(dev, RF_PARA, 0x100044); } #endif 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); #if 0 }else if(priv->phy_ver == 1){
void write_rtl8225(struct net_device *dev, u8 adr, u16 data) { int i; u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); struct r8180_priv *priv = ieee80211_priv(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); select = read_nic_word(dev, RFPinsSelect); write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); force_pci_posting(dev); udelay(10); write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); force_pci_posting(dev); udelay(2); write_nic_word(dev, RFPinsOutput, out); force_pci_posting(dev); udelay(10); for(i=15; i>=0;i--){ bit = (bangdata & (1<<i)) >> i; write_nic_word(dev, RFPinsOutput, bit | out); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<<i)) >> i; write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); force_pci_posting(dev); udelay(10); write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); write_nic_word(dev, RFPinsSelect, select | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); else rtl8185_rf_pins_enable(dev); }
void rtl8225z2_rf_init(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); int i; short channel = 1; u16 brsr; u32 data, addr; priv->chan = channel; 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); rtl8180_set_mode(dev, EPROM_CMD_CONFIG); write_nic_byte(dev, CONFIG3, 0x44); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); rtl8185_rf_pins_enable(dev); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); write_rtl8225(dev, 0x4, 0x8c3); mdelay(1); write_rtl8225(dev, 0x5, 0xc72); mdelay(1); write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, rtl8225_chan[channel]); mdelay(1); write_rtl8225(dev, 0x8, 0x3f); mdelay(1); write_rtl8225(dev, 0x9, 0x335); mdelay(1); write_rtl8225(dev, 0xa, 0x9d4); mdelay(1); write_rtl8225(dev, 0xb, 0x7bb); mdelay(1); write_rtl8225(dev, 0xc, 0x850); mdelay(1); write_rtl8225(dev, 0xd, 0xcdf); mdelay(1); write_rtl8225(dev, 0xe, 0x2b); mdelay(1); write_rtl8225(dev, 0xf, 0x114); mdelay(100); write_rtl8225(dev, 0x0, 0x1b7); for (i = 0; i < 95; i++) { write_rtl8225(dev, 0x1, (u8)(i + 1)); write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); write_rtl8225(dev, 0x5, 0x4); write_rtl8225(dev, 0x0, 0xb7); write_rtl8225(dev, 0x2, 0xc4d); /* FIXME!! rtl8187 we have to check if calibrarion * is successful and eventually cal. again (repeat * the two write on reg 2) */ data = read_rtl8225(dev, 6); if (!(data & 0x00000080)) { write_rtl8225(dev, 0x02, 0x0c4d); force_pci_posting(dev); mdelay(200); write_rtl8225(dev, 0x02, 0x044d); force_pci_posting(dev); mdelay(100); data = read_rtl8225(dev, 6); if (!(data & 0x00000080)) DMESGW("RF Calibration Failed!!!!\n"); } mdelay(200); write_rtl8225(dev, 0x0, 0x2bf); for (i = 0; i < 128; i++) { data = rtl8225_agc[i]; addr = i + 0x80; /* enable writing AGC table */ write_phy_ofdm(dev, 0xb, data); mdelay(1); write_phy_ofdm(dev, 0xa, addr); mdelay(1); } force_pci_posting(dev); mdelay(1); write_phy_ofdm(dev, 0x00, 0x01); mdelay(1); write_phy_ofdm(dev, 0x01, 0x02); mdelay(1); write_phy_ofdm(dev, 0x02, 0x62); mdelay(1); write_phy_ofdm(dev, 0x03, 0x00); mdelay(1); write_phy_ofdm(dev, 0x04, 0x00); mdelay(1); write_phy_ofdm(dev, 0x05, 0x00); mdelay(1); write_phy_ofdm(dev, 0x06, 0x40); mdelay(1); write_phy_ofdm(dev, 0x07, 0x00); mdelay(1); write_phy_ofdm(dev, 0x08, 0x40); mdelay(1); write_phy_ofdm(dev, 0x09, 0xfe); mdelay(1); write_phy_ofdm(dev, 0x0a, 0x08); mdelay(1); write_phy_ofdm(dev, 0x0b, 0x80); mdelay(1); write_phy_ofdm(dev, 0x0c, 0x01); mdelay(1); write_phy_ofdm(dev, 0x0d, 0x43); write_phy_ofdm(dev, 0x0e, 0xd3); mdelay(1); write_phy_ofdm(dev, 0x0f, 0x38); mdelay(1); write_phy_ofdm(dev, 0x10, 0x84); mdelay(1); write_phy_ofdm(dev, 0x11, 0x07); mdelay(1); write_phy_ofdm(dev, 0x12, 0x20); mdelay(1); write_phy_ofdm(dev, 0x13, 0x20); mdelay(1); write_phy_ofdm(dev, 0x14, 0x00); mdelay(1); write_phy_ofdm(dev, 0x15, 0x40); mdelay(1); write_phy_ofdm(dev, 0x16, 0x00); mdelay(1); write_phy_ofdm(dev, 0x17, 0x40); mdelay(1); write_phy_ofdm(dev, 0x18, 0xef); mdelay(1); write_phy_ofdm(dev, 0x19, 0x19); mdelay(1); write_phy_ofdm(dev, 0x1a, 0x20); mdelay(1); write_phy_ofdm(dev, 0x1b, 0x15); mdelay(1); write_phy_ofdm(dev, 0x1c, 0x04); mdelay(1); write_phy_ofdm(dev, 0x1d, 0xc5); mdelay(1); 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, 0x17); mdelay(1); write_phy_ofdm(dev, 0x22, 0x16); mdelay(1); write_phy_ofdm(dev, 0x23, 0x80); mdelay(1); /* FIXME maybe not needed */ write_phy_ofdm(dev, 0x24, 0x46); mdelay(1); write_phy_ofdm(dev, 0x25, 0x00); mdelay(1); write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); rtl8225z2_set_gain(dev, 4); 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); write_phy_cck(dev, 0x8, 0x2e); mdelay(1); write_phy_cck(dev, 0x10, 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); write_phy_cck(dev, 0x19, 0x00); write_phy_cck(dev, 0x1a, 0xa0); write_phy_cck(dev, 0x1b, 0x08); 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, 0x36); mdelay(1); write_phy_cck(dev, 0x45, 0x35); mdelay(1); write_phy_cck(dev, 0x46, 0x2e); mdelay(1); write_phy_cck(dev, 0x47, 0x25); mdelay(1); write_phy_cck(dev, 0x48, 0x1c); mdelay(1); write_phy_cck(dev, 0x49, 0x12); mdelay(1); write_phy_cck(dev, 0x4a, 0x09); mdelay(1); write_phy_cck(dev, 0x4b, 0x04); mdelay(1); write_phy_cck(dev, 0x4c, 0x05); mdelay(1); write_nic_byte(dev, 0x5b, 0x0d); mdelay(1); rtl8225z2_SetTXPowerLevel(dev, channel); /* RX antenna default to A */ write_phy_cck(dev, 0x11, 0x9b); mdelay(1); /* B: 0xDB */ write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); /* B: 0x10 */ rtl8185_tx_antenna(dev, 0x03); /* B: 0x00 */ /* switch to high-speed 3-wire * last digit. 2 for both cck and ofdm */ write_nic_dword(dev, 0x94, 0x15c00002); rtl8185_rf_pins_enable(dev); rtl8225_rf_set_chan(dev, priv->chan); }
void rtl8225z2_rf_init(struct net_device *dev) { struct r8180_priv *priv = ieee80211_priv(dev); int i; short channel = 1; u16 brsr; u32 data,addr; 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 rtl8185_rf_pins_enable(dev); // mdelay(1000); write_rtl8225(dev, 0x0, 0x2bf); mdelay(1); write_rtl8225(dev, 0x1, 0xee0); mdelay(1); write_rtl8225(dev, 0x2, 0x44d); mdelay(1); write_rtl8225(dev, 0x3, 0x441); mdelay(1); write_rtl8225(dev, 0x4, 0x8c3);mdelay(1); write_rtl8225(dev, 0x5, 0xc72);mdelay(1); // } write_rtl8225(dev, 0x6, 0xe6); mdelay(1); write_rtl8225(dev, 0x7, ((priv->card_type == USB)? 0x82a : rtl8225_chan[channel])); mdelay(1); write_rtl8225(dev, 0x8, 0x3f); mdelay(1); write_rtl8225(dev, 0x9, 0x335); mdelay(1); write_rtl8225(dev, 0xa, 0x9d4); mdelay(1); write_rtl8225(dev, 0xb, 0x7bb); mdelay(1); write_rtl8225(dev, 0xc, 0x850); mdelay(1); write_rtl8225(dev, 0xd, 0xcdf); mdelay(1); write_rtl8225(dev, 0xe, 0x2b); mdelay(1); write_rtl8225(dev, 0xf, 0x114); mdelay(100); //if(priv->card_type != USB) /* maybe not needed even for 8185 */ // write_rtl8225(dev, 0x7, rtl8225_chan[channel]); write_rtl8225(dev, 0x0, 0x1b7); for(i=0;i<95;i++){ write_rtl8225(dev, 0x1, (u8)(i+1)); #if 0 if(priv->phy_ver == 1) /* version A */ write_rtl8225(dev, 0x2, rtl8225a_rxgain[i]); else #endif /* version B & C & D*/ write_rtl8225(dev, 0x2, rtl8225z2_rxgain[i]); } write_rtl8225(dev, 0x3, 0x80); write_rtl8225(dev, 0x5, 0x4); write_rtl8225(dev, 0x0, 0xb7); 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) */ // Check for calibration status, 2005.11.17, data = read_rtl8225(dev, 6); if (!(data&0x00000080)) { write_rtl8225(dev, 0x02, 0x0c4d); force_pci_posting(dev); mdelay(200); write_rtl8225(dev, 0x02, 0x044d); force_pci_posting(dev); mdelay(100); data = read_rtl8225(dev, 6); if (!(data&0x00000080)) { DMESGW("RF Calibration Failed!!!!\n"); } } //force_pci_posting(dev); mdelay(200); //200 for 8187 // //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, 0x2bf); if(priv->card_type != USB) rtl8185_rf_pins_enable(dev); //set up ZEBRA AGC table, 2005.11.17, for(i=0;i<128;i++){ data = rtl8225_agc[i]; addr = i + 0x80; //enable writing AGC table write_phy_ofdm(dev, 0xb, data); mdelay(1); write_phy_ofdm(dev, 0xa, addr); mdelay(1); } #if 0 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); } #endif 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); write_phy_ofdm(dev, 0xa, 0x8); 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, 0x43); write_phy_ofdm(dev, 0xe, 0xd3);mdelay(1); #if 0 if(priv->card_8185 == 1){ if(priv->card_8185_Bversion) write_phy_ofdm(dev, 0xf, 0x20);/*ver B*/ else write_phy_ofdm(dev, 0xf, 0x28);/*ver C*/ }else{ #endif 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, 0x07);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); #if 0 }else{
void write_rtl8225(struct net_device *dev, u8 adr, u16 data) { #ifdef THOMAS_3WIRE struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; int status; data = (data << 4) | (u16)(adr & 0x0f); // // OUT a vendor request to ask 8051 do HW three write operation. // //printk("before write rtl8225 , data = %x\n",data); status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x04, RTL8187_REQT_WRITE, 0x0000, 0x1304, &data, 2, HZ / 2); if (status < 0) { printk("write_rtl8225 TimeOut! status:%x\n", status); } /*mdelay(1); u16 Tmpdata; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x04, RTL8187_REQT_READ, 0x0000, 0x1304, &Tmpdata, 2, HZ / 2); if (status < 0) { printk("read_rtl8225 TimeOut! status:%x\n", status); } printk("after read rtl8225 , data = %x\n",Tmpdata);*/ #else #ifdef USE_8051_3WIRE struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; //u8 bit; u16 wReg80, wReg82, wReg84; wReg80 = read_nic_word(dev, RFPinsOutput); wReg80 &= 0xfff3; wReg82 = read_nic_word(dev, RFPinsEnable); wReg84 = 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. //wReg84 &= 0xfff0; wReg84 &= 0xfff8; //modified by david according to windows segment code. // We must set SW enabled before terminating HW 3-wire, 2005.07.29, by rcnjko. write_nic_word(dev, RFPinsEnable, (wReg82|0x0007)); // Set To Output Enable write_nic_word(dev, RFPinsSelect, (wReg84|0x0007)); // Set To SW Switch force_pci_posting(dev); udelay(10); // write_nic_word(dev, 0x80, (BB_HOST_BANG_EN|wReg80)); // Set SI_EN (RFLE) force_pci_posting(dev); udelay(2); //twreg.struc.enableB = 0; write_nic_word(dev, 0x80, (wReg80)); // Clear SI_EN (RFLE) force_pci_posting(dev); udelay(10); usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, adr, 0x8225, &data, 2, HZ / 2); write_nic_word(dev, 0x80, (BB_HOST_BANG_EN|wReg80)); force_pci_posting(dev); udelay(10); write_nic_word(dev, 0x80, (wReg80|0x0004)); write_nic_word(dev, 0x84, (wReg84|0x0000));// Set To SW Switch if(priv->card_type == USB) mdelay(2); else rtl8185_rf_pins_enable(dev); #else int i; u16 out,select; u8 bit; u32 bangdata = (data << 4) | (adr & 0xf); struct r8180_priv *priv = ieee80211_priv(dev); out = read_nic_word(dev, RFPinsOutput) & 0xfff3; write_nic_word(dev,RFPinsEnable, (read_nic_word(dev,RFPinsEnable) | 0x7)); select = read_nic_word(dev, RFPinsSelect); write_nic_word(dev, RFPinsSelect, select | 0x7 | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); force_pci_posting(dev); udelay(10); write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN );//| 0x1fff); force_pci_posting(dev); udelay(2); write_nic_word(dev, RFPinsOutput, out); force_pci_posting(dev); udelay(10); for(i=15; i>=0;i--){ bit = (bangdata & (1<<i)) >> i; write_nic_word(dev, RFPinsOutput, bit | out); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); i--; bit = (bangdata & (1<<i)) >> i; write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out | BB_HOST_BANG_CLK); write_nic_word(dev, RFPinsOutput, bit | out); } write_nic_word(dev, RFPinsOutput, out | BB_HOST_BANG_EN); force_pci_posting(dev); udelay(10); write_nic_word(dev, RFPinsOutput, out | ((priv->card_type == USB) ? 4 : BB_HOST_BANG_EN)); write_nic_word(dev, RFPinsSelect, select | ((priv->card_type == USB) ? 0 : SW_CONTROL_GPIO)); if(priv->card_type == USB) mdelay(2); else rtl8185_rf_pins_enable(dev); #endif #endif /*THOMAS_3WIRE*/ }