📄 rtmp_init.c
字号:
} // Choose the desired Tx&Rx stream. if ((pAd->CommonCfg.TxStream == 0) || (pAd->CommonCfg.TxStream > Antenna.field.TxPath)) pAd->CommonCfg.TxStream = Antenna.field.TxPath; if ((pAd->CommonCfg.RxStream == 0) || (pAd->CommonCfg.RxStream > Antenna.field.RxPath)) { pAd->CommonCfg.RxStream = Antenna.field.RxPath; if ((pAd->MACVersion < RALINK_2883_VERSION) && (pAd->CommonCfg.RxStream > 2)) { // only 2 Rx streams for RT2860 series pAd->CommonCfg.RxStream = 2; } } // 3*3 // read value from EEPROM and set them to CSR174 ~ 177 in chain0 ~ chain2 // yet implement for(i=0; i<3; i++) { } NicConfig2.word = pAd->EEPROMDefaultValue[1];#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { if ((NicConfig2.word & 0x00ff) == 0xff) { NicConfig2.word &= 0xff00; } if ((NicConfig2.word >> 8) == 0xff) { NicConfig2.word &= 0x00ff; } }#endif // CONFIG_STA_SUPPORT // if (NicConfig2.field.DynamicTxAgcControl == 1) pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE; else pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE; DBGPRINT_RAW(RT_DEBUG_TRACE, ("NICReadEEPROMParameters: RxPath = %d, TxPath = %d\n", Antenna.field.RxPath, Antenna.field.TxPath)); // Save the antenna for future use pAd->Antenna.word = Antenna.word; // Set the RfICType here, then we can initialize RFIC related operation callbacks pAd->Mlme.RealRxPath = (UCHAR) Antenna.field.RxPath; pAd->RfIcType = (UCHAR) Antenna.field.RfIcType; // // Reset PhyMode if we don't support 802.11a // Only RFIC_2850 & RFIC_2750 support 802.11a // if ((Antenna.field.RfIcType != RFIC_2850) && (Antenna.field.RfIcType != RFIC_2750) && (Antenna.field.RfIcType != RFIC_3052)) { if ((pAd->CommonCfg.PhyMode == PHY_11ABG_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11A)) pAd->CommonCfg.PhyMode = PHY_11BG_MIXED;#ifdef DOT11_N_SUPPORT else if ((pAd->CommonCfg.PhyMode == PHY_11ABGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11AGN_MIXED) || (pAd->CommonCfg.PhyMode == PHY_11N_5G)) pAd->CommonCfg.PhyMode = PHY_11BGN_MIXED;#endif // DOT11_N_SUPPORT // } // Read TSSI reference and TSSI boundary for temperature compensation. This is ugly // 0. 11b/g { /* these are tempature reference value (0x00 ~ 0xFE) ex: 0x00 0x15 0x25 0x45 0x88 0xA0 0xB5 0xD0 0xF0 TssiPlusBoundaryG [4] [3] [2] [1] [0] (smaller) + TssiMinusBoundaryG[0] [1] [2] [3] [4] (larger) */ RT28xx_EEPROM_READ16(pAd, 0x6E, Power.word); pAd->TssiMinusBoundaryG[4] = Power.field.Byte0; pAd->TssiMinusBoundaryG[3] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0x70, Power.word); pAd->TssiMinusBoundaryG[2] = Power.field.Byte0; pAd->TssiMinusBoundaryG[1] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0x72, Power.word); pAd->TssiRefG = Power.field.Byte0; /* reference value [0] */ pAd->TssiPlusBoundaryG[1] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0x74, Power.word); pAd->TssiPlusBoundaryG[2] = Power.field.Byte0; pAd->TssiPlusBoundaryG[3] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0x76, Power.word); pAd->TssiPlusBoundaryG[4] = Power.field.Byte0; pAd->TxAgcStepG = Power.field.Byte1; pAd->TxAgcCompensateG = 0; pAd->TssiMinusBoundaryG[0] = pAd->TssiRefG; pAd->TssiPlusBoundaryG[0] = pAd->TssiRefG; // Disable TxAgc if the based value is not right if (pAd->TssiRefG == 0xff) pAd->bAutoTxAgcG = FALSE; DBGPRINT(RT_DEBUG_TRACE,("E2PROM: G Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n", pAd->TssiMinusBoundaryG[4], pAd->TssiMinusBoundaryG[3], pAd->TssiMinusBoundaryG[2], pAd->TssiMinusBoundaryG[1], pAd->TssiRefG, pAd->TssiPlusBoundaryG[1], pAd->TssiPlusBoundaryG[2], pAd->TssiPlusBoundaryG[3], pAd->TssiPlusBoundaryG[4], pAd->TxAgcStepG, pAd->bAutoTxAgcG)); } // 1. 11a { RT28xx_EEPROM_READ16(pAd, 0xD4, Power.word); pAd->TssiMinusBoundaryA[4] = Power.field.Byte0; pAd->TssiMinusBoundaryA[3] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0xD6, Power.word); pAd->TssiMinusBoundaryA[2] = Power.field.Byte0; pAd->TssiMinusBoundaryA[1] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0xD8, Power.word); pAd->TssiRefA = Power.field.Byte0; pAd->TssiPlusBoundaryA[1] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0xDA, Power.word); pAd->TssiPlusBoundaryA[2] = Power.field.Byte0; pAd->TssiPlusBoundaryA[3] = Power.field.Byte1; RT28xx_EEPROM_READ16(pAd, 0xDC, Power.word); pAd->TssiPlusBoundaryA[4] = Power.field.Byte0; pAd->TxAgcStepA = Power.field.Byte1; pAd->TxAgcCompensateA = 0; pAd->TssiMinusBoundaryA[0] = pAd->TssiRefA; pAd->TssiPlusBoundaryA[0] = pAd->TssiRefA; // Disable TxAgc if the based value is not right if (pAd->TssiRefA == 0xff) pAd->bAutoTxAgcA = FALSE; DBGPRINT(RT_DEBUG_TRACE,("E2PROM: A Tssi[-4 .. +4] = %d %d %d %d - %d -%d %d %d %d, step=%d, tuning=%d\n", pAd->TssiMinusBoundaryA[4], pAd->TssiMinusBoundaryA[3], pAd->TssiMinusBoundaryA[2], pAd->TssiMinusBoundaryA[1], pAd->TssiRefA, pAd->TssiPlusBoundaryA[1], pAd->TssiPlusBoundaryA[2], pAd->TssiPlusBoundaryA[3], pAd->TssiPlusBoundaryA[4], pAd->TxAgcStepA, pAd->bAutoTxAgcA)); } pAd->BbpRssiToDbmDelta = 0x0; // Read frequency offset setting for RF RT28xx_EEPROM_READ16(pAd, EEPROM_FREQ_OFFSET, value); if ((value & 0x00FF) != 0x00FF) pAd->RfFreqOffset = (ULONG) (value & 0x00FF); else pAd->RfFreqOffset = 0; DBGPRINT(RT_DEBUG_TRACE, ("E2PROM: RF FreqOffset=0x%lx \n", pAd->RfFreqOffset)); //CountryRegion byte offset (38h) value = pAd->EEPROMDefaultValue[2] >> 8; // 2.4G band value2 = pAd->EEPROMDefaultValue[2] & 0x00FF; // 5G band if ((value <= REGION_MAXIMUM_BG_BAND) && (value2 <= REGION_MAXIMUM_A_BAND)) { pAd->CommonCfg.CountryRegion = ((UCHAR) value) | 0x80; pAd->CommonCfg.CountryRegionForABand = ((UCHAR) value2) | 0x80; TmpPhy = pAd->CommonCfg.PhyMode; pAd->CommonCfg.PhyMode = 0xff; RTMPSetPhyMode(pAd, TmpPhy);#ifdef DOT11_N_SUPPORT SetCommonHT(pAd);#endif // DOT11_N_SUPPORT // } // // Get RSSI Offset on EEPROM 0x9Ah & 0x9Ch. // The valid value are (-10 ~ 10) // RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET, value); pAd->BGRssiOffset0 = value & 0x00ff; pAd->BGRssiOffset1 = (value >> 8); RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_BG_OFFSET+2, value); pAd->BGRssiOffset2 = value & 0x00ff; pAd->ALNAGain1 = (value >> 8); RT28xx_EEPROM_READ16(pAd, EEPROM_LNA_OFFSET, value); pAd->BLNAGain = value & 0x00ff; pAd->ALNAGain0 = (value >> 8); // Validate 11b/g RSSI_0 offset. if ((pAd->BGRssiOffset0 < -10) || (pAd->BGRssiOffset0 > 10)) pAd->BGRssiOffset0 = 0; // Validate 11b/g RSSI_1 offset. if ((pAd->BGRssiOffset1 < -10) || (pAd->BGRssiOffset1 > 10)) pAd->BGRssiOffset1 = 0; // Validate 11b/g RSSI_2 offset. if ((pAd->BGRssiOffset2 < -10) || (pAd->BGRssiOffset2 > 10)) pAd->BGRssiOffset2 = 0; RT28xx_EEPROM_READ16(pAd, EEPROM_RSSI_A_OFFSET, value); pAd->ARssiOffset0 = value & 0x00ff; pAd->ARssiOffset1 = (value >> 8); RT28xx_EEPROM_READ16(pAd, (EEPROM_RSSI_A_OFFSET+2), value); pAd->ARssiOffset2 = value & 0x00ff; pAd->ALNAGain2 = (value >> 8); if (((UCHAR)pAd->ALNAGain1 == 0xFF) || (pAd->ALNAGain1 == 0x00)) pAd->ALNAGain1 = pAd->ALNAGain0; if (((UCHAR)pAd->ALNAGain2 == 0xFF) || (pAd->ALNAGain2 == 0x00)) pAd->ALNAGain2 = pAd->ALNAGain0; // Validate 11a RSSI_0 offset. if ((pAd->ARssiOffset0 < -10) || (pAd->ARssiOffset0 > 10)) pAd->ARssiOffset0 = 0; // Validate 11a RSSI_1 offset. if ((pAd->ARssiOffset1 < -10) || (pAd->ARssiOffset1 > 10)) pAd->ARssiOffset1 = 0; //Validate 11a RSSI_2 offset. if ((pAd->ARssiOffset2 < -10) || (pAd->ARssiOffset2 > 10)) pAd->ARssiOffset2 = 0; // // Get LED Setting. // RT28xx_EEPROM_READ16(pAd, 0x3a, value); pAd->LedCntl.word = (value&0xff00) >> 8; RT28xx_EEPROM_READ16(pAd, EEPROM_LED1_OFFSET, value); pAd->Led1 = value; RT28xx_EEPROM_READ16(pAd, EEPROM_LED2_OFFSET, value); pAd->Led2 = value; RT28xx_EEPROM_READ16(pAd, EEPROM_LED3_OFFSET, value); pAd->Led3 = value; RTMPReadTxPwrPerRate(pAd);#ifdef SINGLE_SKU RT28xx_EEPROM_READ16(pAd, EEPROM_DEFINE_MAX_TXPWR, pAd->CommonCfg.DefineMaxTxPwr);#endif // SINGLE_SKU // DBGPRINT(RT_DEBUG_TRACE, ("<-- NICReadEEPROMParameters\n"));}/* ======================================================================== Routine Description: Set default value from EEPROM Arguments: Adapter Pointer to our adapter Return Value: None IRQL = PASSIVE_LEVEL Note: ========================================================================*/VOID NICInitAsicFromEEPROM( IN PRTMP_ADAPTER pAd){#ifdef CONFIG_STA_SUPPORT UINT32 data = 0; UCHAR BBPR1 = 0; #endif // CONFIG_STA_SUPPORT // USHORT i;// EEPROM_ANTENNA_STRUC Antenna; EEPROM_NIC_CONFIG2_STRUC NicConfig2; UCHAR BBPR3 = 0; DBGPRINT(RT_DEBUG_TRACE, ("--> NICInitAsicFromEEPROM\n")); for(i = 3; i < NUM_EEPROM_BBP_PARMS; i++) { UCHAR BbpRegIdx, BbpValue; if ((pAd->EEPROMDefaultValue[i] != 0xFFFF) && (pAd->EEPROMDefaultValue[i] != 0)) { BbpRegIdx = (UCHAR)(pAd->EEPROMDefaultValue[i] >> 8); BbpValue = (UCHAR)(pAd->EEPROMDefaultValue[i] & 0xff); RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BbpRegIdx, BbpValue); } } NicConfig2.word = pAd->EEPROMDefaultValue[1];#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { if ((NicConfig2.word & 0x00ff) == 0xff) { NicConfig2.word &= 0xff00; } if ((NicConfig2.word >> 8) == 0xff) { NicConfig2.word &= 0x00ff; } }#endif // CONFIG_STA_SUPPORT // // Save the antenna for future use pAd->NicConfig2.word = NicConfig2.word; // // Send LED Setting to MCU. // if (pAd->LedCntl.word == 0xFF) { pAd->LedCntl.word = 0x01; pAd->Led1 = 0x5555; pAd->Led2 = 0x2221;#ifdef RTMP_MAC_USB pAd->Led3 = 0x5627;#endif // RTMP_MAC_USB // } AsicSendCommandToMcu(pAd, 0x52, 0xff, (UCHAR)pAd->Led1, (UCHAR)(pAd->Led1 >> 8)); AsicSendCommandToMcu(pAd, 0x53, 0xff, (UCHAR)pAd->Led2, (UCHAR)(pAd->Led2 >> 8)); AsicSendCommandToMcu(pAd, 0x54, 0xff, (UCHAR)pAd->Led3, (UCHAR)(pAd->Led3 >> 8)); pAd->LedIndicatorStrength = 0xFF; RTMPSetSignalLED(pAd, -100); // Force signal strength Led to be turned off, before link up#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { // Read Hardware controlled Radio state enable bit if (NicConfig2.field.HardwareRadioControl == 1) { pAd->StaCfg.bHardwareRadio = TRUE; // Read GPIO pin2 as Hardware controlled radio state RTMP_IO_READ32(pAd, GPIO_CTRL_CFG, &data); if ((data & 0x04) == 0) { pAd->StaCfg.bHwRadio = FALSE; pAd->StaCfg.bRadio = FALSE;// RTMP_IO_WRITE32(pAd, PWR_PIN_CFG, 0x00001818); RTMP_SET_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); } } else pAd->StaCfg.bHardwareRadio = FALSE; if (pAd->StaCfg.bRadio == FALSE) { RTMPSetLED(pAd, LED_RADIO_OFF); } else { RTMPSetLED(pAd, LED_RADIO_ON); } }#endif // CONFIG_STA_SUPPORT // // Turn off patching for cardbus controller if (NicConfig2.field.CardbusAcceleration == 1) {// pAd->bTest1 = TRUE; } if (NicConfig2.field.DynamicTxAgcControl == 1) pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = TRUE; else pAd->bAutoTxAgcA = pAd->bAutoTxAgcG = FALSE; // // Since BBP has been progamed, to make sure BBP setting will be // upate inside of AsicAntennaSelect, so reset to UNKNOWN_BAND!! // pAd->CommonCfg.BandState = UNKNOWN_BAND; RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BBPR3); BBPR3 &= (~0x18); if(pAd->Antenna.field.RxPath == 3) { BBPR3 |= (0x10); } else if(pAd->Antenna.field.RxPath == 2) { BBPR3 |= (0x8); } else if(pAd->Antenna.field.RxPath == 1) { BBPR3 |= (0x0); } RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BBPR3);#ifdef CONFIG_STA_SUPPORT IF_DEV_CONFIG_OPMODE_ON_STA(pAd) { // Handle the difference when 1T RTMP_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BBPR1); if(pAd->Antenna.field.TxPath == 1) { BBPR1 &= (~0x18); } RTMP_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BBPR1); DBGPRINT(RT_DEBUG_TRACE, ("Use Hw Radio Control Pin=%d; if used Pin=%d;\n", pAd->CommonCfg.bHardwareRadio, pAd->CommonCfg.bHardwareRadio)); }#endif // CONFIG_STA_SUPPORT //#ifdef RTMP_MAC_USB#endif // RTMP_MAC_USB // DBGPRINT(RT_DEBUG_TRACE, ("TxPath = %d, RxPath = %d, RFIC=%d, Polar+LED mode=%x\n", pAd->Antenna.field.TxPath, pAd->Antenna.field.RxPath, pAd->RfIcType, pAd->LedCntl.word)); DBGPRINT(RT_DEBUG_TRACE, ("<-- NICInitAsicFromEEPROM\n"));}/* ======================================================================== Routine Description: Initialize NIC hardware Arguments: Adapter Pointer to our adapter Return Value: None IRQL = PASSIVE_LEVEL Note:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -