/* ========================================================================== Description: AsicSwitchChannel() dedicated for RT28xx ATE. ========================================================================== */ VOID RT28xxATEAsicSwitchChannel( IN PRTMP_ADAPTER pAd) { PATE_INFO pATEInfo = &(pAd->ate); UINT32 Value = 0; CHAR TxPwer = 0, TxPwer2 = 0; UCHAR index = 0, BbpValue = 0, Channel = 0; UINT32 R2 = 0, R3 = DEFAULT_RF_TX_POWER, R4 = 0; RTMP_RF_REGS *RFRegTable = NULL; SYNC_CHANNEL_WITH_QA(pATEInfo, &Channel); /* fill Tx power value */ TxPwer = pATEInfo->TxPower0; TxPwer2 = pATEInfo->TxPower1; RFRegTable = RF2850RegTable; switch (pAd->RfIcType) { /* But only 2850 and 2750 support 5.5GHz band... */ case RFIC_2820: case RFIC_2850: case RFIC_2720: case RFIC_2750: for (index = 0; index < NUM_OF_2850_CHNL; index++) { if (Channel == RFRegTable[index].Channel) { R2 = RFRegTable[index].R2; /* If TX path is 1, bit 14 = 1. */ if (pAd->Antenna.field.TxPath == 1) { R2 |= 0x4000; } if (pAd->Antenna.field.TxPath == 2) { if (pATEInfo->TxAntennaSel == 1) { /* If TX Antenna select is 1 , bit 14 = 1; Disable Ant 2 */ R2 |= 0x4000; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue); BbpValue &= 0xE7; /* 11100111B */ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue); } else if (pATEInfo->TxAntennaSel == 2) { /* If TX Antenna select is 2 , bit 15 = 1; Disable Ant 1 */ R2 |= 0x8000; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue); BbpValue &= 0xE7; BbpValue |= 0x08; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue); } else { ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R1, &BbpValue); BbpValue &= 0xE7; BbpValue |= 0x10; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R1, BbpValue); } } if (pAd->Antenna.field.RxPath == 2) { switch (pATEInfo->RxAntennaSel) { case 1: R2 |= 0x20040; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; BbpValue |= 0x00; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; case 2: R2 |= 0x10040; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; BbpValue |= 0x01; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; default: R2 |= 0x40; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; /* Only enable two Antenna to receive. */ BbpValue |= 0x08; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; } } else if (pAd->Antenna.field.RxPath == 1) { /* write 1 to off RxPath */ R2 |= 0x20040; } if (pAd->Antenna.field.RxPath == 3) { switch (pATEInfo->RxAntennaSel) { case 1: R2 |= 0x20040; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; BbpValue |= 0x00; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; case 2: R2 |= 0x10040; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; BbpValue |= 0x01; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; case 3: R2 |= 0x30000; ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; BbpValue |= 0x02; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; default: ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R3, &BbpValue); BbpValue &= 0xE4; BbpValue |= 0x10; ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R3, BbpValue); break; } } if (Channel > 14) { /* initialize R3, R4 */ R3 = (RFRegTable[index].R3 & 0xffffc1ff); R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pATEInfo->RFFreqOffset << 15); /* According the Rory's suggestion to solve the middle range issue. 5.5G band power range : 0xF9~0X0F, TX0 Reg3 bit9/TX1 Reg4 bit6="0" means the TX power reduce 7dB. */ /* R3 */ if ((TxPwer >= -7) && (TxPwer < 0)) { TxPwer = (7+TxPwer); R3 |= (TxPwer << 10); DBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer=%d \n", TxPwer)); } else { TxPwer = (TxPwer > 0xF) ? (0xF) : (TxPwer); R3 |= (TxPwer << 10) | (1 << 9); } /* R4 */ if ((TxPwer2 >= -7) && (TxPwer2 < 0)) { TxPwer2 = (7+TxPwer2); R4 |= (TxPwer2 << 7); DBGPRINT(RT_DEBUG_TRACE, ("ATEAsicSwitchChannel: TxPwer2=%d \n", TxPwer2)); } else { TxPwer2 = (TxPwer2 > 0xF) ? (0xF) : (TxPwer2); R4 |= (TxPwer2 << 7) | (1 << 6); } } else { /* Set TX power0. */ R3 = (RFRegTable[index].R3 & 0xffffc1ff) | (TxPwer << 9); /* Set frequency offset and TX power1. */ R4 = (RFRegTable[index].R4 & (~0x001f87c0)) | (pATEInfo->RFFreqOffset << 15) | (TxPwer2 <<6); } /* based on BBP current mode before changing RF channel */ if (pATEInfo->TxWI.BW == BW_40) { R4 |=0x200000; } /* Update variables. */ pAd->LatchRfRegs.Channel = Channel; pAd->hw_cfg.lan_gain = GET_LNA_GAIN(pAd); pAd->LatchRfRegs.R1 = RFRegTable[index].R1; pAd->LatchRfRegs.R2 = R2; pAd->LatchRfRegs.R3 = R3; pAd->LatchRfRegs.R4 = R4; RtmpRfIoWrite(pAd); break; } } break; default: break; } /* Change BBP setting during switch from a->g, g->a */ if (Channel <= 14) { UINT32 TxPinCfg = 0x00050F0A;/* 2007.10.09 by Brian : 0x0005050A ==> 0x00050F0A */ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - pAd->hw_cfg.lan_gain)); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - pAd->hw_cfg.lan_gain)); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - pAd->hw_cfg.lan_gain)); /* According the Rory's suggestion to solve the middle range issue. */ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0); /* Rx High power VGA offset for LNA select */ if (pAd->NicConfig2.field.ExternalLNAForG) { ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x62); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46); } else { ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0x84); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50); } /* 2.4 G band selection PIN */ rtmp_mac_set_band(pAd, BAND_24G); /* Turn off unused PA or LNA when only 1T or 1R. */ if (pAd->Antenna.field.TxPath == 1) { TxPinCfg &= 0xFFFFFFF3; } if (pAd->Antenna.field.RxPath == 1) { TxPinCfg &= 0xFFFFF3FF; } /* calibration power unbalance issues */ if (pAd->Antenna.field.TxPath == 2) { if (pATEInfo->TxAntennaSel == 1) { TxPinCfg &= 0xFFFFFFF7; } else if (pATEInfo->TxAntennaSel == 2) { TxPinCfg &= 0xFFFFFFFD; } } RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg); } /* channel > 14 */ else { UINT32 TxPinCfg = 0x00050F05;/* 2007.10.09 by Brian : 0x00050505 ==> 0x00050F05 */ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R62, (0x37 - pAd->hw_cfg.lan_gain)); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R63, (0x37 - pAd->hw_cfg.lan_gain)); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R64, (0x37 - pAd->hw_cfg.lan_gain)); /* According the Rory's suggestion to solve the middle range issue. */ ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R86, 0); ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R82, 0xF2); /* Rx High power VGA offset for LNA select */ if (pAd->NicConfig2.field.ExternalLNAForA) { ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x46); } else { ATE_BBP_IO_WRITE8_BY_REG_ID(pAd, BBP_R75, 0x50); } ATE_BBP_IO_READ8_BY_REG_ID(pAd, BBP_R91, &BbpValue); ASSERT((BbpValue == 0x04)); /* 5 G band selection PIN, bit1 and bit2 are complement */ rtmp_mac_set_band(pAd, BAND_5G); /* Turn off unused PA or LNA when only 1T or 1R. */ if (pAd->Antenna.field.TxPath == 1) { TxPinCfg &= 0xFFFFFFF3; } if (pAd->Antenna.field.RxPath == 1) { TxPinCfg &= 0xFFFFF3FF; } RTMP_IO_WRITE32(pAd, TX_PIN_CFG, TxPinCfg); } ATE_CHIP_RX_VGA_GAIN_INIT(pAd); #ifdef RELEASE_EXCLUDE /* On 11A, We should delay and wait RF/BBP to be stable and the appropriate time should be 1000 micro seconds. 2005/06/05 - On 11G, We also need this delay time. Otherwise it's difficult to pass the WHQL. */ #endif /* RELEASE_EXCLUDE */ RtmpOsMsDelay(1); #ifndef RTMP_RF_RW_SUPPORT if (Channel > 14) { /* When 5.5GHz band the LSB of TxPwr will be used to reduced 7dB or not. */ DBGPRINT(RT_DEBUG_TRACE, ("RT28xx:SwitchChannel#%d(RF=%d, %dT) to , R1=0x%08x, R2=0x%08x, R3=0x%08x, R4=0x%08x\n", Channel, pAd->RfIcType, pAd->Antenna.field.TxPath, pAd->LatchRfRegs.R1, pAd->LatchRfRegs.R2, pAd->LatchRfRegs.R3, pAd->LatchRfRegs.R4)); } else { DBGPRINT(RT_DEBUG_TRACE, ("RT28xx:SwitchChannel#%d(RF=%d, Pwr0=%u, Pwr1=%u, %dT) to , R1=0x%08x, R2=0x%08x, R3=0x%08x, R4=0x%08x\n", Channel, pAd->RfIcType, (R3 & 0x00003e00) >> 9, (R4 & 0x000007c0) >> 6, pAd->Antenna.field.TxPath, pAd->LatchRfRegs.R1, pAd->LatchRfRegs.R2, pAd->LatchRfRegs.R3, pAd->LatchRfRegs.R4)); } #endif /* !RTMP_RF_RW_SUPPORT */ }
static VOID mt76x0_ate_switch_channel( IN PRTMP_ADAPTER pAd) { PATE_INFO pATEInfo = &(pAd->ate); UINT32 idx = 0, rf_phy_mode, rf_bw = RF_BW_20; UCHAR channel = 0; SYNC_CHANNEL_WITH_QA(pATEInfo, &channel); mt76x0_ate_bbp_adjust(pAd); DBGPRINT(RT_DEBUG_TRACE, ("%s::Channel = %d, TXWI_N.BW = %d , RFFreqOffset = %d, TxPower0 = %d\n", __FUNCTION__, channel, pATEInfo->TxWI.TXWI_N.BW, pATEInfo->RFFreqOffset, pATEInfo->TxPower0)); if (channel > 14) rf_phy_mode = RF_A_BAND; else rf_phy_mode = RF_G_BAND; if (pATEInfo->TxWI.TXWI_N.BW == BW_80) rf_bw = RF_BW_80; else if (pATEInfo->TxWI.TXWI_N.BW == BW_40) rf_bw = RF_BW_40; else rf_bw = RF_BW_20; /* Configure 2.4/5GHz before accessing other MAC/BB/RF registers */ SelectBandMT76x0(pAd, channel); /* Set RF channel frequency parameters (Rdiv, N, K, D and Ksd) */ SetRfChFreqParametersMT76x0(pAd, channel); for (idx = 0; idx < MT76x0_BPP_SWITCH_Tab_Size; idx++) { if (((rf_phy_mode | rf_bw) & MT76x0_BPP_SWITCH_Tab[idx].BwBand) == (rf_phy_mode | rf_bw)) { if ((MT76x0_BPP_SWITCH_Tab[idx].RegDate.Register == AGC1_R8)) { UINT32 eLNAgain = (MT76x0_BPP_SWITCH_Tab[idx].RegDate.Value & 0x0000FF00) >> 8; if (channel > 14) { if (channel < 100) eLNAgain -= (pAd->ALNAGain0*2); else if (channel < 137) eLNAgain -= (pAd->ALNAGain1*2); else eLNAgain -= (pAd->ALNAGain2*2); } else eLNAgain -= (pAd->BLNAGain*2); RTMP_BBP_IO_WRITE32(pAd, MT76x0_BPP_SWITCH_Tab[idx].RegDate.Register, (MT76x0_BPP_SWITCH_Tab[idx].RegDate.Value&(~0x0000FF00))|(eLNAgain << 8)); } else { RTMP_BBP_IO_WRITE32(pAd, MT76x0_BPP_SWITCH_Tab[idx].RegDate.Register, MT76x0_BPP_SWITCH_Tab[idx].RegDate.Value); } }