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_set_gain(struct net_device *dev, short gain) { struct r8180_priv *priv = ieee80211_priv(dev); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_ON); if(priv->card_8185 == 2) write_phy_ofdm(dev, 0x21, 0x27); else write_phy_ofdm(dev, 0x21, 0x37); write_phy_ofdm(dev, 0x25, 0x20); write_phy_ofdm(dev, 0x11, 0x6); if(priv->card_8185 == 1 && priv->card_8185_Bversion) write_phy_ofdm(dev, 0x27, 0x8); else write_phy_ofdm(dev, 0x27, 0x88); write_phy_ofdm(dev, 0x14, 0); write_phy_ofdm(dev, 0x16, 0); write_phy_ofdm(dev, 0x15, 0x40); write_phy_ofdm(dev, 0x17, 0x40); write_phy_ofdm(dev, 0x0d, rtl8225_gain[gain * 4]); write_phy_ofdm(dev, 0x23, rtl8225_gain[gain * 4 + 1]); write_phy_ofdm(dev, 0x1b, rtl8225_gain[gain * 4 + 2]); write_phy_ofdm(dev, 0x1d, rtl8225_gain[gain * 4 + 3]); //rtl8225_set_gain_usb(dev, gain); }
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_close(struct net_device *dev) { write_rtl8225(dev, 0x4, 0x1f); force_pci_posting(dev); mdelay(1); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); }
void rtl8225_rf_close(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); if( priv->bSurpriseRemoved == _FALSE) { write_rtl8225(dev, 0x4, 0x1f); force_pci_posting(dev); mdelay(1); rtl8180_set_anaparam(dev, RTL8225_ANAPARAM_OFF); rtl8185_set_anaparam2(dev, RTL8225_ANAPARAM2_OFF); } }
static void grf5101_rf_stop(struct ieee80211_hw *dev) { struct rtl8180_priv *priv = dev->priv; u32 anaparam; anaparam = priv->anaparam; anaparam &= 0x000fffff; anaparam |= 0x3f900000; rtl8180_set_anaparam(priv, anaparam); write_grf5101(dev, 0x07, 0x0); write_grf5101(dev, 0x1f, 0x45); write_grf5101(dev, 0x1f, 0x5); write_grf5101(dev, 0x00, 0x8e4); }
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){
static int rtl8180_init_hw(struct ieee80211_hw *dev) { struct rtl8180_priv *priv = dev->priv; u16 reg; rtl818x_iowrite8(priv, &priv->map->CMD, 0); rtl818x_ioread8(priv, &priv->map->CMD); msleep(10); /* reset */ rtl818x_iowrite16(priv, &priv->map->INT_MASK, 0); rtl818x_ioread8(priv, &priv->map->CMD); reg = rtl818x_ioread8(priv, &priv->map->CMD); reg &= (1 << 1); reg |= RTL818X_CMD_RESET; rtl818x_iowrite8(priv, &priv->map->CMD, RTL818X_CMD_RESET); rtl818x_ioread8(priv, &priv->map->CMD); msleep(200); /* check success of reset */ if (rtl818x_ioread8(priv, &priv->map->CMD) & RTL818X_CMD_RESET) { printk(KERN_ERR "%s: reset timeout!\n", wiphy_name(dev->wiphy)); return -ETIMEDOUT; } rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_LOAD); rtl818x_ioread8(priv, &priv->map->CMD); msleep(200); if (rtl818x_ioread8(priv, &priv->map->CONFIG3) & (1 << 3)) { /* For cardbus */ reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); reg |= 1 << 1; rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg); reg = rtl818x_ioread16(priv, &priv->map->FEMR); reg |= (1 << 15) | (1 << 14) | (1 << 4); rtl818x_iowrite16(priv, &priv->map->FEMR, reg); } rtl818x_iowrite8(priv, &priv->map->MSR, 0); if (!priv->r8185) rtl8180_set_anaparam(priv, priv->anaparam); rtl818x_iowrite32(priv, &priv->map->RDSAR, priv->rx_ring_dma); rtl818x_iowrite32(priv, &priv->map->TBDA, priv->tx_ring[3].dma); rtl818x_iowrite32(priv, &priv->map->THPDA, priv->tx_ring[2].dma); rtl818x_iowrite32(priv, &priv->map->TNPDA, priv->tx_ring[1].dma); rtl818x_iowrite32(priv, &priv->map->TLPDA, priv->tx_ring[0].dma); /* TODO: necessary? specs indicate not */ rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); reg = rtl818x_ioread8(priv, &priv->map->CONFIG2); rtl818x_iowrite8(priv, &priv->map->CONFIG2, reg & ~(1 << 3)); if (priv->r8185) { reg = rtl818x_ioread8(priv, &priv->map->CONFIG2); rtl818x_iowrite8(priv, &priv->map->CONFIG2, reg | (1 << 4)); } rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); /* TODO: set CONFIG5 for calibrating AGC on rtl8180 + philips radio? */ /* TODO: turn off hw wep on rtl8180 */ rtl818x_iowrite32(priv, &priv->map->INT_TIMEOUT, 0); if (priv->r8185) { rtl818x_iowrite8(priv, &priv->map->WPA_CONF, 0); rtl818x_iowrite8(priv, &priv->map->RATE_FALLBACK, 0x81); rtl818x_iowrite8(priv, &priv->map->RESP_RATE, (8 << 4) | 0); rtl818x_iowrite16(priv, &priv->map->BRSR, 0x01F3); /* TODO: set ClkRun enable? necessary? */ reg = rtl818x_ioread8(priv, &priv->map->GP_ENABLE); rtl818x_iowrite8(priv, &priv->map->GP_ENABLE, reg & ~(1 << 6)); rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG); reg = rtl818x_ioread8(priv, &priv->map->CONFIG3); rtl818x_iowrite8(priv, &priv->map->CONFIG3, reg | (1 << 2)); rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_NORMAL); } else { rtl818x_iowrite16(priv, &priv->map->BRSR, 0x1); rtl818x_iowrite8(priv, &priv->map->SECURITY, 0); rtl818x_iowrite8(priv, &priv->map->PHY_DELAY, 0x6); rtl818x_iowrite8(priv, &priv->map->CARRIER_SENSE_COUNTER, 0x4C); } priv->rf->init(dev); if (priv->r8185) rtl818x_iowrite16(priv, &priv->map->BRSR, 0x01F3); return 0; }
static void grf5101_rf_init(struct ieee80211_hw *dev) { struct rtl8180_priv *priv = dev->priv; rtl8180_set_anaparam(priv, priv->anaparam); write_grf5101(dev, 0x1f, 0x0); write_grf5101(dev, 0x1f, 0x0); write_grf5101(dev, 0x1f, 0x40); write_grf5101(dev, 0x1f, 0x60); write_grf5101(dev, 0x1f, 0x61); write_grf5101(dev, 0x1f, 0x61); write_grf5101(dev, 0x00, 0xae4); write_grf5101(dev, 0x1f, 0x1); write_grf5101(dev, 0x1f, 0x41); write_grf5101(dev, 0x1f, 0x61); write_grf5101(dev, 0x01, 0x1a23); write_grf5101(dev, 0x02, 0x4971); write_grf5101(dev, 0x03, 0x41de); write_grf5101(dev, 0x04, 0x2d80); write_grf5101(dev, 0x05, 0x68ff); /* 0x61ff original value */ write_grf5101(dev, 0x06, 0x0); write_grf5101(dev, 0x07, 0x0); write_grf5101(dev, 0x08, 0x7533); write_grf5101(dev, 0x09, 0xc401); write_grf5101(dev, 0x0a, 0x0); write_grf5101(dev, 0x0c, 0x1c7); write_grf5101(dev, 0x0d, 0x29d3); write_grf5101(dev, 0x0e, 0x2e8); write_grf5101(dev, 0x10, 0x192); write_grf5101(dev, 0x11, 0x248); write_grf5101(dev, 0x12, 0x0); write_grf5101(dev, 0x13, 0x20c4); write_grf5101(dev, 0x14, 0xf4fc); write_grf5101(dev, 0x15, 0x0); write_grf5101(dev, 0x16, 0x1500); write_grf5101(dev, 0x07, 0x1000); /* baseband configuration */ rtl8180_write_phy(dev, 0, 0xa8); rtl8180_write_phy(dev, 3, 0x0); rtl8180_write_phy(dev, 4, 0xc0); rtl8180_write_phy(dev, 5, 0x90); rtl8180_write_phy(dev, 6, 0x1e); rtl8180_write_phy(dev, 7, 0x64); grf5101_write_phy_antenna(dev, 1); rtl8180_write_phy(dev, 0x11, 0x88); if (rtl818x_ioread8(priv, &priv->map->CONFIG2) & RTL818X_CONFIG2_ANTENNA_DIV) rtl8180_write_phy(dev, 0x12, 0xc0); /* enable ant diversity */ else rtl8180_write_phy(dev, 0x12, 0x40); /* disable ant diversity */ rtl8180_write_phy(dev, 0x13, 0x90 | priv->csthreshold); rtl8180_write_phy(dev, 0x19, 0x0); rtl8180_write_phy(dev, 0x1a, 0xa0); rtl8180_write_phy(dev, 0x1b, 0x44); }
static void sa2400_rf_init(struct ieee80211_hw *dev) { struct rtl8180_priv *priv = dev->priv; u32 anaparam, txconf; u8 firdac; int analogphy = priv->rfparam & RF_PARAM_ANALOGPHY; anaparam = priv->anaparam; anaparam &= ~(1 << ANAPARAM_TXDACOFF_SHIFT); anaparam &= ~ANAPARAM_PWR1_MASK; anaparam &= ~ANAPARAM_PWR0_MASK; if (analogphy) { anaparam |= SA2400_ANA_ANAPARAM_PWR1_ON << ANAPARAM_PWR1_SHIFT; firdac = 0; } else { anaparam |= (SA2400_DIG_ANAPARAM_PWR1_ON << ANAPARAM_PWR1_SHIFT); anaparam |= (SA2400_ANAPARAM_PWR0_ON << ANAPARAM_PWR0_SHIFT); firdac = 1 << SA2400_REG4_FIRDAC_SHIFT; } rtl8180_set_anaparam(priv, anaparam); write_sa2400(dev, 0, sa2400_chan[0]); 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, 0x1dfb | (SA2400_MAX_SENS - 54) << 15); write_sa2400(dev, 4, 0x19348 | firdac); /* calibrate VCO */ if (!analogphy) write_sa2400(dev, 4, 0x1938c); /*???*/ write_sa2400(dev, 4, 0x19340 | firdac); write_sa2400(dev, 0, sa2400_chan[0]); write_sa2400(dev, 1, 0xbb50); write_sa2400(dev, 2, 0x80); write_sa2400(dev, 3, 0); write_sa2400(dev, 4, 0x19344 | firdac); /* calibrate filter */ /* new from rtl8180 embedded driver (rtl8181 project) */ write_sa2400(dev, 6, 0x13ff | (1 << 23)); /* MANRX */ write_sa2400(dev, 8, 0); /* VCO */ if (analogphy) { rtl8180_set_anaparam(priv, anaparam | (1 << ANAPARAM_TXDACOFF_SHIFT)); txconf = rtl818x_ioread32(priv, &priv->map->TX_CONF); rtl818x_iowrite32(priv, &priv->map->TX_CONF, txconf | RTL818X_TX_CONF_LOOPBACK_CONT); write_sa2400(dev, 4, 0x19341); /* calibrates DC */ /* a 5us sleep is required here, * we rely on the 3ms delay introduced in write_sa2400 */ write_sa2400(dev, 4, 0x19345); /* a 20us sleep is required here, * we rely on the 3ms delay introduced in write_sa2400 */ rtl818x_iowrite32(priv, &priv->map->TX_CONF, txconf); rtl8180_set_anaparam(priv, anaparam); } /* end new code */ write_sa2400(dev, 4, 0x19341 | firdac); /* RTX MODE */ /* baseband configuration */ rtl8180_write_phy(dev, 0, 0x98); rtl8180_write_phy(dev, 3, 0x38); rtl8180_write_phy(dev, 4, 0xe0); rtl8180_write_phy(dev, 5, 0x90); rtl8180_write_phy(dev, 6, 0x1a); rtl8180_write_phy(dev, 7, 0x64); sa2400_write_phy_antenna(dev, 1); rtl8180_write_phy(dev, 0x11, 0x80); if (rtl818x_ioread8(priv, &priv->map->CONFIG2) & RTL818X_CONFIG2_ANTENNA_DIV) rtl8180_write_phy(dev, 0x12, 0xc7); /* enable ant diversity */ else rtl8180_write_phy(dev, 0x12, 0x47); /* disable ant diversity */ rtl8180_write_phy(dev, 0x13, 0x90 | priv->csthreshold); rtl8180_write_phy(dev, 0x19, 0x0); rtl8180_write_phy(dev, 0x1a, 0xa0); }
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{