/* Clear FW RPWM for FW control LPS.*/
rtl_write_byte(rtlpriv, RPWM, 0x0);
/* Reset MAC-IO and CPU and Core Digital BIT(10)/11/15 */
tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
tmpu1b &= 0x73;
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b); /* wait for BIT 10/11/15 to pull high automatically!! */
mdelay(1);
/* Switch the control path. */
tmpu2b = rtl_read_word(rtlpriv, SYS_CLKR);
rtl_write_word(rtlpriv, SYS_CLKR, (tmpu2b & (~BIT(2))));
tmpu1b = rtl_read_byte(rtlpriv, (SYS_CLKR + 1));
tmpu1b = ((tmpu1b | BIT(7)) & (~BIT(6))); if (!_rtl92se_halset_sysclk(hw, tmpu1b)) return; /* Set failed, return to prevent hang. */
rtl_write_word(rtlpriv, CMDR, 0x07FC);
/* MH We must enable the section of code to prevent load IMEM fail. */ /* Load MAC register from WMAc temporarily We simulate macreg. */ /* txt HW will provide MAC txt later */
rtl_write_byte(rtlpriv, 0x6, 0x30);
rtl_write_byte(rtlpriv, 0x49, 0xf0);
/* To make sure that TxDMA can ready to download FW. */ /* We should reset TxDMA if IMEM RPT was not ready. */ do {
tmpu1b = rtl_read_byte(rtlpriv, TCR); if ((tmpu1b & TXDMA_INIT_VALUE) == TXDMA_INIT_VALUE) break;
/* 4. Timing Control Register (Offset: 0x0080 - 0x009F) */ /* Set CCK/OFDM SIFS */ /* CCK SIFS shall always be 10us. */
rtl_write_word(rtlpriv, SIFS_CCK, 0x0a0a);
rtl_write_word(rtlpriv, SIFS_OFDM, 0x1010);
/* Set AckTimeout */
rtl_write_byte(rtlpriv, ACK_TIMEOUT, 0x40);
/* Beacon related */
rtl_write_word(rtlpriv, BCN_INTERVAL, 100);
rtl_write_word(rtlpriv, ATIMWND, 2);
/* 5. FIFO Control Register (Offset: 0x00A0 - 0x015F) */ /* 5.1 Initialize Number of Reserved Pages in Firmware Queue */ /* Firmware allocate now, associate with FW internal setting.!!! */
/* 5.2 Setting TX/RX page size 0/1/2/3/4=64/128/256/512/1024 */ /* 5.3 Set driver info, we only accept PHY status now. */ /* 5.4 Set RXDMA arbitration to control RXDMA/MAC/FW R/W for RXFIFO */
rtl_write_byte(rtlpriv, RXDMA, rtl_read_byte(rtlpriv, RXDMA) | BIT(6));
/* 6. Adaptive Control Register (Offset: 0x0160 - 0x01CF) */ /* Set RRSR to all legacy rate and HT rate * CCK rate is supported by default. * CCK rate will be filtered out only when associated * AP does not support it. * Only enable ACK rate to OFDM 24M
* Disable RRSR for CCK rate in A-Cut */
/* A-Cut IC do not support CCK rate. We forbid ARFR to */ /* fallback to CCK rate */ for (i = 0; i < 8; i++) { /*Disable RRSR for CCK rate in A-Cut */ if (rtlhal->version == VERSION_8192S_ACUT)
rtl_write_dword(rtlpriv, ARFR0 + i * 4, 0x1f0ff0f0);
}
/* Different rate use different AMPDU size */ /* MCS32/ MCS15_SG use max AMPDU size 15*2=30K */
rtl_write_byte(rtlpriv, AGGLEN_LMT_H, 0x0f); /* MCS0/1/2/3 use max AMPDU size 4*2=8K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L, 0x7442); /* MCS4/5 use max AMPDU size 8*2=16K 6/7 use 10*2=20K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L + 2, 0xddd7); /* MCS8/9 use max AMPDU size 8*2=16K 10/11 use 10*2=20K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L + 4, 0xd772); /* MCS12/13/14/15 use max AMPDU size 15*2=30K */
rtl_write_word(rtlpriv, AGGLEN_LMT_L + 6, 0xfffd);
/* Set Data / Response auto rate fallack retry count */
rtl_write_dword(rtlpriv, DARFRC, 0x04010000);
rtl_write_dword(rtlpriv, DARFRC + 4, 0x09070605);
rtl_write_dword(rtlpriv, RARFRC, 0x04010000);
rtl_write_dword(rtlpriv, RARFRC + 4, 0x09070605);
/* 7. EDCA Setting Register (Offset: 0x01D0 - 0x01FF) */ /* Set all rate to support SG */
rtl_write_word(rtlpriv, SG_RATE, 0xFFFF);
/* 8. WMAC, BA, and CCX related Register (Offset: 0x0200 - 0x023F) */ /* Set NAV protection length */
rtl_write_word(rtlpriv, NAV_PROT_LEN, 0x0080); /* CF-END Threshold */
rtl_write_byte(rtlpriv, CFEND_TH, 0xFF); /* Set AMPDU minimum space */
rtl_write_byte(rtlpriv, AMPDU_MIN_SPACE, 0x07); /* Set TXOP stall control for several queue/HI/BCN/MGT/ */
rtl_write_byte(rtlpriv, TXOP_STALL_CTRL, 0x00);
/* 9. Security Control Register (Offset: 0x0240 - 0x025F) */ /* 10. Power Save Control Register (Offset: 0x0260 - 0x02DF) */ /* 11. General Purpose Register (Offset: 0x02E0 - 0x02FF) */ /* 12. Host Interrupt Status Register (Offset: 0x0300 - 0x030F) */ /* 13. Test mode and Debug Control Register (Offset: 0x0310 - 0x034F) */
/* 14. Set driver info, we only accept PHY status now. */
rtl_write_byte(rtlpriv, RXDRVINFO_SZ, 4);
/* 15. For EEPROM R/W Workaround */ /* 16. For EFUSE to share REG_SYS_FUNC_EN with EEPROM!!! */
tmpu2b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN);
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, tmpu2b | BIT(13));
tmpu2b = rtl_read_byte(rtlpriv, REG_SYS_ISO_CTRL);
rtl_write_byte(rtlpriv, REG_SYS_ISO_CTRL, tmpu2b & (~BIT(8)));
/* 17. For EFUSE */ /* We may R/W EFUSE in EEPROM mode */ if (rtlefuse->epromtype == EEPROM_BOOT_EFUSE) {
u8 tempval;
/* As this function can take a very long time (up to 350 ms) * and can be called with irqs disabled, reenable the irqs * to let the other devices continue being serviced. * * It is safe doing so since our own interrupts will only be enabled * in a subsequent step.
*/
local_save_flags(flags);
local_irq_enable();
rtlpriv->intf_ops->disable_aspm(hw);
/* 1. MAC Initialize */ /* Before FW download, we have to set some MAC register */
_rtl92se_macconfig_before_fwdownload(hw);
/* 3. Initialize MAC/PHY Config by MACPHY_reg.txt */ if (!rtl92s_phy_mac_config(hw)) {
pr_err("MAC Config failed\n");
err = rtstatus; gotoexit;
}
/* because last function modify RCR, so we update * rcr var here, or TP will unstable for receive_config * is wrong, RX RCR_ACRC32 will cause TP unstabel & Rx * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252
*/
rtlpci->receive_config = rtl_read_dword(rtlpriv, RCR);
rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV);
rtl_write_dword(rtlpriv, RCR, rtlpci->receive_config);
/* Make sure BB/RF write OK. We should prevent enter IPS. radio off. */ /* We must set flag avoid BB/RF config period later!! */
rtl_write_dword(rtlpriv, CMDR, 0x37FC);
/* 4. Initialize BB After MAC Config PHY_reg.txt, AGC_Tab.txt */ if (!rtl92s_phy_bb_config(hw)) {
pr_err("BB Config failed\n");
err = rtstatus; gotoexit;
}
/* 5. Initiailze RF RAIO_A.txt RF RAIO_B.txt */ /* Before initalizing RF. We can not use FW to do RF-R/W. */
rtlphy->rf_mode = RF_OP_BY_SW_3WIRE;
/* Before RF-R/W we must execute the IO from Scott's suggestion. */
rtl_write_byte(rtlpriv, AFE_XTAL_CTRL + 1, 0xDB); if (rtlhal->version == VERSION_8192S_ACUT)
rtl_write_byte(rtlpriv, SPS1_CTRL + 3, 0x07); else
rtl_write_byte(rtlpriv, RF_CTRL, 0x07);
/*---- Set CCK and OFDM Block "ON"----*/
rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1);
rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1);
/*3 Set Hardware(Do nothing now) */
_rtl92se_hw_configure(hw);
/* Read EEPROM TX power index and PHY_REG_PG.txt to capture correct */ /* TX power index for different rate set. */ /* Get original hw reg values */
rtl92s_phy_get_hw_reg_originalvalue(hw); /* Write correct tx power index */
rtl92s_phy_set_txpower(hw, rtlphy->current_channel);
/* We must set MAC address after firmware download. */ for (i = 0; i < 6; i++)
rtl_write_byte(rtlpriv, MACIDR0 + i, rtlefuse->dev_addr[i]);
switch (type) { case NL80211_IFTYPE_UNSPECIFIED:
bt_msr |= (MSR_LINK_NONE << MSR_LINK_SHIFT);
rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "Set Network type to NO LINK!\n"); break; case NL80211_IFTYPE_ADHOC:
bt_msr |= (MSR_LINK_ADHOC << MSR_LINK_SHIFT);
rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "Set Network type to Ad Hoc!\n"); break; case NL80211_IFTYPE_STATION:
bt_msr |= (MSR_LINK_MANAGED << MSR_LINK_SHIFT);
rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "Set Network type to STA!\n"); break; case NL80211_IFTYPE_AP:
bt_msr |= (MSR_LINK_MASTER << MSR_LINK_SHIFT);
rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "Set Network type to AP!\n"); break; default:
pr_err("Network type %d not supported!\n", type); return 1;
if (_rtl92se_set_media_status(hw, type)) return -EOPNOTSUPP;
if (rtlpriv->mac80211.link_state == MAC80211_LINKED) { if (type != NL80211_IFTYPE_AP)
rtl92se_set_check_bssid(hw, true);
} else {
rtl92se_set_check_bssid(hw, false);
}
return 0;
}
/* don't set REG_EDCA_BE_PARAM here because mac80211 will send pkt when scan */ void rtl92se_set_qos(struct ieee80211_hw *hw, int aci)
{ struct rtl_priv *rtlpriv = rtl_priv(hw);
rtl92s_dm_init_edca_turbo(hw);
switch (aci) { case AC1_BK:
rtl_write_dword(rtlpriv, EDCAPARA_BK, 0xa44f); break; case AC0_BE: /* rtl_write_dword(rtlpriv, EDCAPARA_BE, u4b_ac_param); */ break; case AC2_VI:
rtl_write_dword(rtlpriv, EDCAPARA_VI, 0x5e4322); break; case AC3_VO:
rtl_write_dword(rtlpriv, EDCAPARA_VO, 0x2f3222); break; default:
WARN_ONCE(true, "rtl8192se: invalid aci: %d !\n", aci); break;
}
}
rtl_write_dword(rtlpriv, INTA_MASK, rtlpci->irq_mask[0]); /* Support Bit 32-37(Assign as Bit 0-5) interrupt setting now */
rtl_write_dword(rtlpriv, INTA_MASK + 4, rtlpci->irq_mask[1] & 0x3F);
rtlpci->irq_enabled = true;
}
/* Add description. After switch control path. register * after page1 will be invisible. We can not do any IO * for register>0x40. After resume&MACIO reset, we need
* to remember previous reg content. */ if (u1btmp & BIT(7)) {
u1btmp &= ~(BIT(6) | BIT(7)); if (!_rtl92s_set_sysclk(hw, u1btmp)) {
pr_err("Switch ctrl path fail\n"); return;
}
}
/* Power save for MAC */ if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS &&
!rtlhal->driver_is_goingto_unload) { /* enable LED function */
rtl_write_byte(rtlpriv, 0x03, 0xF9); /* SW/HW radio off or halt adapter!! For example S3/S4 */
} else { /* LED function disable. Power range is about 8mA now. */ /* if write 0xF1 disconnect_pci power
* ifconfig wlan0 down power are both high 35:70 */ /* if write oxF9 disconnect_pci power
* ifconfig wlan0 down power are both low 12:45*/
rtl_write_byte(rtlpriv, 0x03, 0xF9);
}
/* Reset MAC-IO and CPU and Core Digital BIT10/11/15 */
tmpu1b = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN + 1);
/* If IPS we need to turn LED on. So we not
* disable BIT 3/7 of reg3. */ if (rtlpriv->psc.rfoff_reason & (RF_CHANGE_BY_IPS | RF_CHANGE_BY_HW))
tmpu1b &= 0xFB; else
tmpu1b &= 0x73;
rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN + 1, tmpu1b); /* wait for BIT 10/11/15 to pull high automatically!! */
mdelay(1);
if (rtlpci->driver_is_goingto_unload ||
ppsc->rfoff_reason > RF_CHANGE_BY_PS)
rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF);
/* we should chnge GPIO to input mode
* this will drop away current about 25mA*/
rtl8192se_gpiobit3_cfg_inputmode(hw);
/* this is very important for ips power save */ while (wait-- >= 10 && rtlpriv->psc.pwrdomain_protect) { if (rtlpriv->psc.pwrdomain_protect)
mdelay(20); else break;
}
/* ATIM Window (in unit of TU). */
rtl_write_word(rtlpriv, ATIMWND, atim_window);
/* Beacon interval (in unit of TU). */
rtl_write_word(rtlpriv, BCN_INTERVAL, mac->beacon_interval);
/* DrvErlyInt (in unit of TU). (Time to send * interrupt to notify driver to change
* beacon content) */
rtl_write_word(rtlpriv, BCN_DRV_EARLY_INT, 10 << 4);
/* BcnDMATIM(in unit of us). Indicates the
* time before TBTT to perform beacon queue DMA */
rtl_write_word(rtlpriv, BCN_DMATIME, 256);
/* Force beacon frame transmission even * after receiving beacon frame from
* other ad hoc STA */
rtl_write_byte(rtlpriv, BCN_ERR_THRESH, 100);
/* Beacon interval (in unit of TU). */
rtl_write_word(rtlpriv, BCN_INTERVAL, bcn_interval); /* 2008.10.24 added by tynli for beacon changed. */
rtl92s_phy_set_beacon_hwreg(hw, bcn_interval);
}
/* Only retrieving while using EFUSE. */ if ((rtlefuse->epromtype == EEPROM_BOOT_EFUSE) &&
!rtlefuse->autoload_failflag) {
efuse_id = efuse_read_1byte(hw, EFUSE_IC_ID_OFFSET);
if (efuse_id == 0xfe)
rtlhal->ic_class = IC_INFERIORITY_B;
}
}
/* Get Tx Power Level by Channel */ /* Read Tx power of Channel 1 ~ 14 from EEPROM. */ /* 92S suupport RF A & B */ for (rf_path = 0; rf_path < 2; rf_path++) { for (i = 0; i < 3; i++) { /* Read CCK RF A & B Tx power */
rtlefuse->eeprom_chnlarea_txpwr_cck[rf_path][i] =
hwinfo[EEPROM_TXPOWERBASE + rf_path * 3 + i];
/* Read OFDM RF A & B Tx power for 1T */
rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][i] =
hwinfo[EEPROM_TXPOWERBASE + 6 + rf_path * 3 + i];
/* Read OFDM RF A & B Tx power for 2T */
rtlefuse->eprom_chnl_txpwr_ht40_2sdf[rf_path][i]
= hwinfo[EEPROM_TXPOWERBASE + 12 +
rf_path * 3 + i];
}
}
for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++)
RTPRINT(rtlpriv, FINIT, INIT_EEPROM, "RF(%d) EEPROM CCK Area(%d) = 0x%x\n",
rf_path, i,
rtlefuse->eeprom_chnlarea_txpwr_cck
[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++)
RTPRINT(rtlpriv, FINIT, INIT_EEPROM, "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
rf_path, i,
rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
[rf_path][i]); for (rf_path = 0; rf_path < 2; rf_path++) for (i = 0; i < 3; i++)
RTPRINT(rtlpriv, FINIT, INIT_EEPROM, "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
rf_path, i,
rtlefuse->eprom_chnl_txpwr_ht40_2sdf
[rf_path][i]);
for (rf_path = 0; rf_path < 2; rf_path++) {
/* Assign dedicated channel tx power */ for (i = 0; i < 14; i++) { /* channel 1~3 use the same Tx Power Level. */ if (i < 3)
index = 0; /* Channel 4-8 */ elseif (i < 8)
index = 1; /* Channel 9-14 */ else
index = 2;
/* Record A & B CCK /OFDM - 1T/2T Channel area
* tx power */
rtlefuse->txpwrlevel_cck[rf_path][i] =
rtlefuse->eeprom_chnlarea_txpwr_cck
[rf_path][index];
rtlefuse->txpwrlevel_ht40_1s[rf_path][i] =
rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
[rf_path][index];
rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
rtlefuse->eprom_chnl_txpwr_ht40_2sdf
[rf_path][index];
}
for (i = 0; i < 14; i++) {
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
rf_path, i,
rtlefuse->txpwrlevel_cck[rf_path][i],
rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
}
}
for (rf_path = 0; rf_path < 2; rf_path++) { for (i = 0; i < 3; i++) { /* Read Power diff limit. */
rtlefuse->eeprom_pwrgroup[rf_path][i] =
hwinfo[EEPROM_TXPWRGROUP + rf_path * 3 + i];
}
}
for (rf_path = 0; rf_path < 2; rf_path++) { /* Fill Pwr group */ for (i = 0; i < 14; i++) { /* Chanel 1-3 */ if (i < 3)
index = 0; /* Channel 4-8 */ elseif (i < 8)
index = 1; /* Channel 9-13 */ else
index = 2;
for (i = 0; i < 14; i++) { /* Read tx power difference between HT OFDM 20/40 MHZ */ /* channel 1-3 */ if (i < 3)
index = 0; /* Channel 4-8 */ elseif (i < 8)
index = 1; /* Channel 9-14 */ else
index = 2;
for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]); for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]); for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]); for (i = 0; i < 14; i++)
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "RF-B Legacy to HT40 Diff[%d] = 0x%x\n",
i, rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
/* Read RF-indication and Tx Power gain
* index diff of legacy to HT OFDM rate. */
tempval = hwinfo[EEPROM_RFIND_POWERDIFF] & 0xff;
rtlefuse->eeprom_txpowerdiff = tempval;
rtlefuse->legacy_ht_txpowerdiff =
rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][0];
/* Read antenna tx power offset of B/C/D to A from EEPROM */ /* and read ThermalMeter from EEPROM */
tempval = hwinfo[EEPROM_THERMALMETER];
rtlefuse->eeprom_thermalmeter = tempval;
RTPRINT(rtlpriv, FINIT, INIT_TXPOWER, "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
/* ThermalMeter, BIT(0)~3 for RFIC1, BIT(4)~7 for RFIC2 */
rtlefuse->thermalmeter[0] = (rtlefuse->eeprom_thermalmeter & 0x1f);
rtlefuse->tssi_13dbm = rtlefuse->eeprom_thermalmeter * 100;
/* this ifunction is for RFKILL, it's different with windows, * because UI will disable wireless when GPIO Radio Off.
* And here we not check or Disable/Enable ASPM like windows*/ bool rtl92se_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
{ struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); enum rf_pwrstate rfpwr_toset /*, cur_rfstate */; unsignedlong flag = 0; bool actuallyset = false; bool turnonbypowerdomain = false;
/* just 8191se can check gpio before firstup, 92c/92d have fixed it */ if (rtlpci->up_first_time || rtlpci->being_init_adapter) returnfalse;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.